On Thursday 12 September 2013, SF Markus Elfring wrote: > Hello, > > CMake supports also building of static and shared libraries together. > http://cmake.org/cmake/help/v2.8.11/cmake.html#command:add_library > > I get the impression from the tutorial that a needed library can be passed > as a target name for the macro "target_link_libraries". > http://cmake.org/cmake/help/cmake_tutorial.html#s2 > > But I get a different experience. > http://cmake.org/cmake/help/v2.8.11/cmake.html#command:target_link_librarie > s > > Now I try to give a build configurator the choice with which library type > some executable files should be linked. It seems that I need to construct > corresponding file names instead of target names.
No, you don't have to. Do you want to build static and dynamic lib at the same time ? Then do something like this ? add_library(foo STATIC ${libSrcs}) add_library(fooShared SHARED ${libSrcs}) set(myLibs foo) if (USER_DECIDED_TO_LINK_AGAINST_SHARED_LIBS) set(myLibs fooShared) else() set(myLibs foo) endif() add_executable(hello ${hellosSrcs}) target_link_libraries(hello ${myLibs} ) Alex -- Powered by www.kitware.com Please keep messages on-topic and check the CMake FAQ at: http://www.cmake.org/Wiki/CMake_FAQ Kitware offers various services to support the CMake community. For more information on each offering, please visit: CMake Support: http://cmake.org/cmake/help/support.html CMake Consulting: http://cmake.org/cmake/help/consulting.html CMake Training Courses: http://cmake.org/cmake/help/training.html Visit other Kitware open-source projects at http://www.kitware.com/opensource/opensource.html Follow this link to subscribe/unsubscribe: http://www.cmake.org/mailman/listinfo/cmake