[CMake] transitive dependencies & link flags

Tim Blechmann tim at klingt.org
Sun Mar 23 08:38:26 EDT 2014


hi,

i'm using usage requirements to pass on dependencies in the build system.

--
set(MY_DEBUG_LIB   libDebug.lib)
set(MY_RELEASE_LIB libRelease.lib)

target_link_libraries(mylib
  debug     ${MY_DEBUG_LIB}
  optimized ${MY_RELEASE_LIB})

add_executable(myapp somesrc.cpp)

target_link_libraries( myapp mylib )
--

under windows (ninja & msvc generators), both the libraries in
${MY_DEBUG_LIB} and the ones in ${MY_RELEASE_LIB} are linked into the
myapp target.

is this a bug or a feature? or is there any better way to ensure that
only the libraries for the current build type are linked?

thanks a lot,
tim



More information about the CMake mailing list