[CMake] Problems with target_link_libraries picking up both sets of libraries

Alexander Neundorf a.neundorf-work at gmx.net
Wed Feb 25 15:22:10 EST 2009


On Wednesday 25 February 2009, Jesse Perla wrote:
> I am using cmake 2.6.3 on vista.
>
> I am having trouble with the target_link_libraries appearing to not picking
> up the right libraries in visual studio and nmake when I use "debug" and
> "optimized"It appears to add both sets of libraries in many cases.  I
> haven't been able to detect clear patterns with it, but my cmakelists.txt
> have been very simple.
> When I turn on verbose makefiles and use nmake, it seems to be including
> both the debug and release libraries.  And in visual studio, the debug and
> release targets have all of the libraries in the library includes.  Am I
> doing something wrong ehre?
>
> My package just sets a couple of variables called ETK_...  .  I used
> message to make sure that they are filled with the right versions of the
> files.
>
> My code looks like this:
> cmake_minimum_required(VERSION 2.6)
> set(CMAKE_MODULE_PATH $ENV{ETK_BUILD} )
> find_package(ETK)
>
> project(hello_scl)
> set(libscl_INCLUDE
> c:/working/libraries/trunk/examples/cmake_example/libscl) #point to
> headers.
> include_directories(${ETK_INCLUDE_DIRS} ${libscl_INCLUDE})
> link_directories(${ETK_LIBRARY_DIRS})
>
> #Setup the executable and add the source
> set(hello2_SRCS
> hello-scl.cpp)
> add_executable(hello2 ${hello2_SRCS})
> message("The debug libraries are ${ETK_DEBUG_LIBRARIES}")
> message("The release libraries are ${ETK_RELEASE_LIBRARIES}")
>
> target_link_libraries(hello2
> debug ${ETK_DEBUG_LIBRARIES} scl-d.lib)
> target_link_libraries(hello2
> optimized ${ETK_RELEASE_LIBRARIES} scl.lib)

Did you try the following ?
target_link_libraries(hello2 debug ${ETK_DEBUG_LIBRARIES} scl-d.lib 
                             optimized ${ETK_RELEASE_LIBRARIES} scl.lib)

Alex


More information about the CMake mailing list