Let's say there's following directory structure:
root | +--projects | | | +-test | | | +-CMakeFiles.txt | +--libs | +-testlib | +-CMakeFiles.txt
testlib also contains
CMakeFiles.txt. "test" produces an executable and "testlib" produces a static library.
I want "test" to link with "testlib" without using symlinks and without moving "testlib" library into a subdirectory within "test".
Because "testlib" isn't a subdirectory of "test", I can't do
CMakeFiles.txt - CMake will complain about "testlib" not being in the "test" subdirectory.
Also, because system has several different compilers, I can't simply install "testlib" libraries into some kind of central directory, so I want
test to compile a local copy of
testlib and link with it (i.e. as if
testlib was a subdirectory). I also want the "test" project to automatically rebuild "testlib" if it has been changed.
So, how can I deal with it? I am using CMake 2.8.4 on Windows XP SP3.
You could either provide a top-level CMakeLists.txt in
root, or provide a binary directory to the
add_subdirectory command; e.g.
This creates a subdirectory called
testlib_build in your current build directory which contains the generated project files for testlib, but not the source.
For further info, run
cmake --help-command ADD_SUBDIRECTORY
add_subdirectorycall - Fraser 2015-08-14 00:10
The only way I see to do this - create
CMakeLists.txt in root and put the following code there:
When you have done this, you can do
target_link_libraries(test testlib) in
test/CMakeLists.txt, and it will be automatically rebuilt if you change something in