[CMake] Transitive linking and imported targets
Tobias Rudolph
tobias.rudolph at artorg.unibe.ch
Tue Mar 31 13:48:49 EDT 2009
Hi All,
I am trying to build a project containing several subprojects that are
included via add_subdirectory. Now, here is an example demonstrating
the problem:
The test project contains the following CMakeLists.txt:
----
project( CMakeTest )
cmake_minimum_required( VERSION 2.6 )
add_subdirectory( libFoo )
add_executable( TestApp main.cpp )
target_link_libraries( TestApp libFoo )
----
The CMakeLists.txt of the subdirectory libFoo:
----
add_library( iLib SHARED IMPORTED )
set_target_properties( iLib PROPERTIES IMPORTED_LOCATION "/opt/local/
lib/libzip.dylib" )
add_library( libFoo SHARED foo.cpp )
target_link_libraries( libFoo iLib )
----
According to the documentation, the imported target (iLib) is only
know within libFoo and its subdirectories. So, when I try to link
'TestApp', it fails because the linker is looking for 'iLib' rather
than '/opt/local/lib/libzip.dylib' due transitive linking (I suspect).
Is that intended behavior?
Best regards,
Tobias
More information about the CMake
mailing list