Mike Tarrant
Mike Tarrant

Reputation: 291

CMake Config based condition in a multi config generator

I am looking to specify different DLL's to use based on it building in debug or release. for example:

 IF CONFIGURATION MATCHES Debug
     SET(MYDLL my_dlld)
ELSE()
     SET(MYDLL my_dll)
ENDIF()

I have looked at logical expressions such as

$<$<CONFIG:Debug>:DEBUG_MODE>

But this did not seem to work, maybe my implementation of it was incorrect. Any help would be greatly appreciated

EDIT: Some minimal code for understanding

PROJECT(myproject)

#ADD_DEFINITIONS(-DMANAGER_EXPORTS)

INCLUDE_DIRECTORIES(
                     ${CMAKE_SOURCE_DIR}/API/mydll
                   )

$<$<CONFIG:Debug>:SET(MYDLL mydlld)>
$<$<CONFIG:Release>:SET(MYDLL mydll)>

SET(LIBS
          ${MYDLL}
   )

mydll - Is a pre-generated shared library which has a debug and release version

Upvotes: 2

Views: 806

Answers (1)

PowPowPowell
PowPowPowell

Reputation: 255

I think a possible solution is that you can do the following

#SET(LINK_LIB debug my_dlld optimized my_dll)
#TARGET_LINK_LIBRARIES(MYDLL ${LINK_LIB})

Hope this helps !

Upvotes: 2

Related Questions