diff options
author | Stephen Kelly <steveire@gmail.com> | 2012-11-05 11:43:28 (GMT) |
---|---|---|
committer | Stephen Kelly <steveire@gmail.com> | 2013-01-31 16:34:20 (GMT) |
commit | 77cecb778ff1882d87401c1055ec06585462f787 (patch) | |
tree | 7abf8c4ffc3839e6b2f8593757cd34119aea17a2 /Tests/ExportImport/Import | |
parent | 0b92602b816e2584db3781b120a1e5200da72ada (diff) | |
download | CMake-77cecb778ff1882d87401c1055ec06585462f787.zip CMake-77cecb778ff1882d87401c1055ec06585462f787.tar.gz CMake-77cecb778ff1882d87401c1055ec06585462f787.tar.bz2 |
Add includes and compile definitions with target_link_libraries.
This establishes that linking is used to propagate usage-requirements
between targets in CMake code. The use of the target_link_libraries
command as the API for this is chosen because introducing a new command
would introduce confusion due to multiple commands which differ only in
a subtle way.
Diffstat (limited to 'Tests/ExportImport/Import')
-rw-r--r-- | Tests/ExportImport/Import/A/CMakeLists.txt | 14 | ||||
-rw-r--r-- | Tests/ExportImport/Import/CMakeLists.txt | 5 | ||||
-rw-r--r-- | Tests/ExportImport/Import/package_new_new/CMakeLists.txt | 23 | ||||
-rw-r--r-- | Tests/ExportImport/Import/package_new_old/CMakeLists.txt | 24 | ||||
-rw-r--r-- | Tests/ExportImport/Import/package_old_old/CMakeLists.txt | 24 |
5 files changed, 77 insertions, 13 deletions
diff --git a/Tests/ExportImport/Import/A/CMakeLists.txt b/Tests/ExportImport/Import/A/CMakeLists.txt index 0675594..0337130 100644 --- a/Tests/ExportImport/Import/A/CMakeLists.txt +++ b/Tests/ExportImport/Import/A/CMakeLists.txt @@ -159,18 +159,11 @@ endif() add_executable(deps_iface deps_iface.c) target_link_libraries(deps_iface testLibDepends) -target_include_directories(deps_iface PRIVATE $<TARGET_PROPERTY:testLibDepends,INTERFACE_INCLUDE_DIRECTORIES>) -target_compile_definitions(deps_iface PRIVATE $<TARGET_PROPERTY:testLibDepends,INTERFACE_COMPILE_DEFINITIONS>) add_executable(deps_shared_iface deps_shared_iface.cpp) target_link_libraries(deps_shared_iface testSharedLibDepends) -target_include_directories(deps_shared_iface - PRIVATE - $<TARGET_PROPERTY:testSharedLibDepends,INTERFACE_INCLUDE_DIRECTORIES> -) target_compile_definitions(deps_shared_iface PRIVATE - $<TARGET_PROPERTY:testSharedLibDepends,INTERFACE_COMPILE_DEFINITIONS> $<$<BOOL:$<TARGET_PROPERTY:POSITION_INDEPENDENT_CODE>>:PIC_PROPERTY_IS_ON> $<$<BOOL:$<TARGET_PROPERTY:CUSTOM_PROP>>:CUSTOM_PROPERTY_IS_ON> $<$<STREQUAL:$<TARGET_PROPERTY:CUSTOM_STRING>,testcontent>:CUSTOM_STRING_IS_MATCH> @@ -200,13 +193,8 @@ endif() add_executable(deps_shared_iface2 deps_shared_iface.cpp) target_link_libraries(deps_shared_iface2 bld_testSharedLibDepends bld_subdirlib) -target_include_directories(deps_shared_iface2 - PRIVATE - $<TARGET_PROPERTY:bld_testSharedLibDepends,INTERFACE_INCLUDE_DIRECTORIES> - $<TARGET_PROPERTY:bld_subdirlib,INTERFACE_INCLUDE_DIRECTORIES> -) target_compile_definitions(deps_shared_iface2 - PRIVATE $<TARGET_PROPERTY:bld_testSharedLibDepends,INTERFACE_COMPILE_DEFINITIONS> TEST_SUBDIR_LIB + PRIVATE TEST_SUBDIR_LIB $<$<BOOL:$<TARGET_PROPERTY:POSITION_INDEPENDENT_CODE>>:PIC_PROPERTY_IS_ON> $<$<BOOL:$<TARGET_PROPERTY:CUSTOM_PROP>>:CUSTOM_PROPERTY_IS_ON> $<$<STREQUAL:$<TARGET_PROPERTY:CUSTOM_STRING>,testcontent>:CUSTOM_STRING_IS_MATCH> diff --git a/Tests/ExportImport/Import/CMakeLists.txt b/Tests/ExportImport/Import/CMakeLists.txt index 3fc78a2..237f8fa 100644 --- a/Tests/ExportImport/Import/CMakeLists.txt +++ b/Tests/ExportImport/Import/CMakeLists.txt @@ -17,3 +17,8 @@ add_executable(imp_testTransExe1 imp_testTransExe1.c) target_link_libraries(imp_testTransExe1 imp_lib1) add_executable(imp_testTransExe1b imp_testTransExe1.c) target_link_libraries(imp_testTransExe1b imp_lib1b) + +# Test package INTERFACE controls +add_subdirectory(package_old_old) +add_subdirectory(package_new_old) +add_subdirectory(package_new_new) diff --git a/Tests/ExportImport/Import/package_new_new/CMakeLists.txt b/Tests/ExportImport/Import/package_new_new/CMakeLists.txt new file mode 100644 index 0000000..4e6f642 --- /dev/null +++ b/Tests/ExportImport/Import/package_new_new/CMakeLists.txt @@ -0,0 +1,23 @@ + +cmake_minimum_required(VERSION 2.8) + +find_package(testLibRequired 2.5 REQUIRED) + +file(WRITE "${CMAKE_CURRENT_BINARY_DIR}/main.cpp" + " +#include \"testSharedLibRequired.h\" +int main(int argc, char **argv) +{ + TestSharedLibRequired req; + return req.foo(); +} +" +) + +get_target_property(prop Req::testSharedLibRequired INTERFACE_INCLUDE_DIRECTORIES) +if (NOT prop) + message(SEND_ERROR "Interface of Req::testSharedLibRequired should not be empty") +endif() + +add_executable(new_new_test "${CMAKE_CURRENT_BINARY_DIR}/main.cpp") +target_link_libraries(new_new_test Req::testSharedLibRequired) diff --git a/Tests/ExportImport/Import/package_new_old/CMakeLists.txt b/Tests/ExportImport/Import/package_new_old/CMakeLists.txt new file mode 100644 index 0000000..e675d64 --- /dev/null +++ b/Tests/ExportImport/Import/package_new_old/CMakeLists.txt @@ -0,0 +1,24 @@ + +cmake_minimum_required(VERSION 2.8) + +find_package(testLibRequired 2.5 REQUIRED) + +file(WRITE "${CMAKE_CURRENT_BINARY_DIR}/main.cpp" + " +#include \"testSharedLibRequired.h\" +int main(int argc, char **argv) +{ + TestSharedLibRequired req; + return req.foo(); +} +" +) + +get_target_property(prop Req::testSharedLibRequired INTERFACE_INCLUDE_DIRECTORIES) +if ("${prop}" STREQUAL "") + message(SEND_ERROR "Interface of Req::testSharedLibRequired should not be empty") +endif() + +add_executable(new_old_test "${CMAKE_CURRENT_BINARY_DIR}/main.cpp") +target_link_libraries(new_old_test Req::testSharedLibRequired) +include_directories(${testLibRequired_INCLUDE_DIRS}) diff --git a/Tests/ExportImport/Import/package_old_old/CMakeLists.txt b/Tests/ExportImport/Import/package_old_old/CMakeLists.txt new file mode 100644 index 0000000..3b27330 --- /dev/null +++ b/Tests/ExportImport/Import/package_old_old/CMakeLists.txt @@ -0,0 +1,24 @@ + +cmake_minimum_required(VERSION 2.8) + +find_package(testLibRequired 2.1 REQUIRED) + +file(WRITE "${CMAKE_CURRENT_BINARY_DIR}/main.cpp" + " +#include \"testSharedLibRequired.h\" +int main(int argc, char **argv) +{ + TestSharedLibRequired req; + return req.foo(); +} +" +) + +get_target_property(prop Req::testSharedLibRequired INTERFACE_INCLUDE_DIRECTORIES) +if (prop) + message(SEND_ERROR "Interface of Req::testSharedLibRequired should be empty, but is ${prop}") +endif() + +add_executable(old_old_test "${CMAKE_CURRENT_BINARY_DIR}/main.cpp") +target_link_libraries(old_old_test Req::testSharedLibRequired) +include_directories(${testLibRequired_INCLUDE_DIRS}) |