[CMake] Linking installed libraries on a "sub" CMakeLists

d0b3rM4n at gmx.net d0b3rM4n at gmx.net
Tue Apr 3 04:06:01 EDT 2007


Hi all

I'm using cmake to compile lots of different libs under linux, with add_subdirectory.
I want to install the libs and headers in a directory ${CMAKE_BINARY_DIR}/dist/lib and ${CMAKE_BINARY_DIR}/dist/include

My root CMakeLists.txt file:
project(testproject)

add_subdirectory( libA )
add_subdirectory( libB )
...
add_subdirectory( testApplication )




My libA CMakeLists.txt file:
...
install(TARGETS libA DESTINATION ${TEST_LIB_INSTALL_DIR} )
install(FILES libA.h DESTINATION ${TEST_INCLUDE_INSTALL_DIR} )
...


In my testApplication I want to link againt some libraries and I need the installed header files.
...
include_directories ( ${TEST_INCLUDE_INSTALL_DIR} )
link_directories ( ${TEST_LIB_INSTALL_DIR} )
...

...
set ( LIBA_LIBRARY ${TEST_LIB_INSTALL_DIR}/liblibA.a )
target_link_libraries( ${TEST_EXECUTABLE} ${LIBA_LIBRARY} )
...
 
When I call cmake from my project root directory, I get the following error.
CMake Error: Attempt to add link library "/home/cmaketests/final/dist/lib/liblibA.a" to target "testApplication" which is not built by this project.
CMake Error: Cannot find source file "/home/cmaketests/final/dist/lib/liblibA.a" for target "testApplication"


Any ideas ? 
Thanks all.
Gerhard
-- 
"Feel free" - 10 GB Mailbox, 100 FreeSMS/Monat ...
Jetzt GMX TopMail testen: http://www.gmx.net/de/go/topmail


More information about the CMake mailing list