2012/1/14 Matthias Fulz <[email protected]>: > Hi, > > could anybody give me a hint or an example on how to > use a static lib inside a project? > > I need to create a static lib, which is only used inside > a project for different executables. > > Let's say a project like the following: > > src > static_lib > lib.cpp > lib.hpp > executable1 > main.cpp > executable2 > main.cpp > > The lib should be static and used only inside this project.
src/CMakeList.txt add_subdirectory(static_lib) add_subdirectory(executable1) add_subdirectory(executable2) src/static_lib/CMakeLists.txt add_library(InternalUse STATIC lib.cpp lib.hpp) src/executable1/CMakeLists.txt add_executable(exe1 main.cpp) target_link_libraries(exe1 InternalUse) install(TARGETS exe1 DESTINATION bin) src/executable2/CMakeLists.txt add_executable(exe2 main.cpp) target_link_libraries(exe2 InternalUse) install(TARGETS exe2 DESTINATION bin) should work as expected. "only inside this project" would mean that you shouldn't install this library. -- Erk Membre de l'April - « promouvoir et défendre le logiciel libre » - http://www.april.org -- Powered by www.kitware.com Visit other Kitware open-source projects at http://www.kitware.com/opensource/opensource.html Please keep messages on-topic and check the CMake FAQ at: http://www.cmake.org/Wiki/CMake_FAQ Follow this link to subscribe/unsubscribe: http://www.cmake.org/mailman/listinfo/cmake
