[CMake] target_link_libraries difficulties

Benoit Thomas benoit.thomas at gameloft.com
Thu Apr 1 14:52:54 EDT 2010


Hello,

I'm trying to find a work around since target_link_libraries cannot be 
used per-configuration. I know that out-of-build could solve my problem, 
but my team is currently migrating from Visual Studio to cmake, so I 
need something which "feel" more like Visual Studio.

My current project has around 20 configurations (debug, release, many 
many more, mostly combination of debug_something, release_something, 
etc.) and some of those configuration requires to include special 
external libraries, some not. Since I cannot classify all my 
configurations as debug or release, solution like target_link_libraries 
(target my_library debug|optimized) did not work.

To put it simply, what I'm trying to achieve is something like:

add_executable (exec)
add_library (my_lib)

set_target_properties (exec PROPERTIES COMPILE_DEFINITIONS_CONFIG1 
USING_MY_LIB)
set_target_properties (exec PROPERTIES COMPILE_DEFINITIONS_CONFIG2 
NOT_USING_MY_LIB)

# should only link the library under CONFIG1
target_link_libraries (exec my_library)

Thank you,
Ben.



More information about the CMake mailing list