diff options
author | Brad King <brad.king@kitware.com> | 2013-02-05 19:54:02 (GMT) |
---|---|---|
committer | Brad King <brad.king@kitware.com> | 2013-02-07 16:09:01 (GMT) |
commit | c0debb1f89de47f13f7b9682ebd24b772a649e78 (patch) | |
tree | 15e09c0a61f81ef5e4e0fdb6533ca7987c031d17 /Tests/ExportImport | |
parent | daae0d2f5b0f9f5e1db3615d85d39ee819d50175 (diff) | |
parent | ec85306025ae787e08d4ce097fde966f1809c74f (diff) | |
download | CMake-c0debb1f89de47f13f7b9682ebd24b772a649e78.zip CMake-c0debb1f89de47f13f7b9682ebd24b772a649e78.tar.gz CMake-c0debb1f89de47f13f7b9682ebd24b772a649e78.tar.bz2 |
Merge branch 'master' into generator-toolset
We need the latest Tests/CMakeLists.txt so we can refactor all tests.
Diffstat (limited to 'Tests/ExportImport')
-rw-r--r-- | Tests/ExportImport/Export/CMakeLists.txt | 76 | ||||
-rw-r--r-- | Tests/ExportImport/Import/A/CMakeLists.txt | 20 | ||||
-rw-r--r-- | Tests/ExportImport/Import/A/deps_shared_iface.cpp | 12 | ||||
-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 |
7 files changed, 156 insertions, 28 deletions
diff --git a/Tests/ExportImport/Export/CMakeLists.txt b/Tests/ExportImport/Export/CMakeLists.txt index dd615d1..ae938cd 100644 --- a/Tests/ExportImport/Export/CMakeLists.txt +++ b/Tests/ExportImport/Export/CMakeLists.txt @@ -90,32 +90,23 @@ set_property(TARGET testLibCycleA PROPERTY LINK_INTERFACE_MULTIPLICITY 3) # Test exporting dependent libraries into different exports add_library(testLibRequired testLibRequired.c) add_library(testLibDepends testLibDepends.c) -set_property(TARGET testLibDepends APPEND PROPERTY - INCLUDE_DIRECTORIES - $<TARGET_PROPERTY:testLibRequired,INTERFACE_INCLUDE_DIRECTORIES> -) -set_property(TARGET testLibDepends APPEND PROPERTY - COMPILE_DEFINITIONS - $<TARGET_PROPERTY:testLibRequired,INTERFACE_COMPILE_DEFINITIONS> -) -set_property(TARGET testLibDepends APPEND PROPERTY - INTERFACE_INCLUDE_DIRECTORIES - $<TARGET_PROPERTY:testLibRequired,INTERFACE_INCLUDE_DIRECTORIES> -) -set_property(TARGET testLibDepends APPEND PROPERTY - INTERFACE_COMPILE_DEFINITIONS - $<TARGET_PROPERTY:testLibRequired,INTERFACE_COMPILE_DEFINITIONS> -) -target_link_libraries(testLibDepends testLibRequired) +target_link_libraries(testLibDepends LINK_PUBLIC testLibRequired) macro(add_include_lib _libName) file(WRITE "${CMAKE_CURRENT_BINARY_DIR}/${_libName}.c" "// no content\n") add_library(${_libName} "${CMAKE_CURRENT_BINARY_DIR}/${_libName}.c") file(MAKE_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}/${_libName}") set_property(TARGET ${_libName} APPEND PROPERTY - INTERFACE_INCLUDE_DIRECTORIES "${CMAKE_CURRENT_BINARY_DIR}/${_libName}") + INTERFACE_INCLUDE_DIRECTORIES + "$<BUILD_INTERFACE:${CMAKE_CURRENT_BINARY_DIR}/${_libName}>" + "$<INSTALL_INTERFACE:$<INSTALL_PREFIX>/include/${_libName}>" + ) if (NOT "${ARGV1}" STREQUAL "NO_HEADER") file(WRITE "${CMAKE_CURRENT_BINARY_DIR}/${_libName}/${_libName}.h" "// no content\n") + install(FILES + "${CMAKE_CURRENT_BINARY_DIR}/${_libName}/${_libName}.h" + DESTINATION include/${_libName} + ) endif() endmacro() @@ -129,6 +120,10 @@ add_include_lib(testLibIncludeRequired3 NO_HEADER) # but we are testing that the INSTALL_INTERFACE causes it not to be used # at build time. file(WRITE "${CMAKE_CURRENT_BINARY_DIR}/testLibIncludeRequired3/testLibIncludeRequired4.h" "#error Should not be included\n") +install(FILES + "${CMAKE_CURRENT_BINARY_DIR}/testLibIncludeRequired3/testLibIncludeRequired4.h" + DESTINATION include/testLibIncludeRequired3 +) add_include_lib(testLibIncludeRequired4) add_include_lib(testLibIncludeRequired5 NO_HEADER) # Generate testLibIncludeRequired6 in the testLibIncludeRequired5 directory @@ -139,6 +134,10 @@ add_include_lib(testLibIncludeRequired5 NO_HEADER) # the Import side of this unit test, the '6' include from the '5' directory # will not be used because it is in the BUILD_INTERFACE only. file(WRITE "${CMAKE_CURRENT_BINARY_DIR}/testLibIncludeRequired5/testLibIncludeRequired6.h" "#error Should not be included\n") +install(FILES + "${CMAKE_CURRENT_BINARY_DIR}/testLibIncludeRequired5/testLibIncludeRequired6.h" + DESTINATION include/testLibIncludeRequired5 +) add_include_lib(testLibIncludeRequired6) set_property(TARGET testLibRequired APPEND PROPERTY @@ -149,6 +148,8 @@ set_property(TARGET testLibRequired APPEND PROPERTY $<BUILD_INTERFACE:$<TARGET_PROPERTY:testLibIncludeRequired4,INTERFACE_INCLUDE_DIRECTORIES>> $<BUILD_INTERFACE:$<TARGET_PROPERTY:testLibIncludeRequired5,INTERFACE_INCLUDE_DIRECTORIES>> $<INSTALL_INTERFACE:$<TARGET_PROPERTY:testLibIncludeRequired6,INTERFACE_INCLUDE_DIRECTORIES>> + # Test that the below is non-fatal + $<$<TARGET_DEFINED:not_a_target>:$<TARGET_PROPERTY:not_a_target,INTERFACE_INCLUDE_DIRECTORIES>> ) set_property(TARGET testLibRequired APPEND PROPERTY @@ -173,6 +174,22 @@ set_property(TARGET testSharedLibRequired APPEND PROPERTY INTERFACE_INCLUDE_DIRECTORIES "${CMAKE_CURRENT_BINARY_DIR}" "${CMAKE_CURRENT_SOURCE_DIR}" ) +set_property(TARGET testSharedLibRequired + APPEND PROPERTY + COMPATIBLE_INTERFACE_BOOL CUSTOM_PROP +) +set_property(TARGET testSharedLibRequired + PROPERTY + INTERFACE_CUSTOM_PROP ON +) +set_property(TARGET testSharedLibRequired + APPEND PROPERTY + COMPATIBLE_INTERFACE_STRING CUSTOM_STRING +) +set_property(TARGET testSharedLibRequired + PROPERTY + INTERFACE_CUSTOM_STRING testcontent +) add_library(testSharedLibDepends SHARED testSharedLibDepends.cpp) set_property(TARGET testSharedLibDepends APPEND PROPERTY @@ -201,11 +218,30 @@ install(TARGETS testLibRequired testLibIncludeRequired6 testSharedLibRequired EXPORT RequiredExp DESTINATION lib ) -install(EXPORT RequiredExp NAMESPACE Req:: FILE testLibRequiredConfig.cmake DESTINATION lib/cmake/testLibRequired) +install(EXPORT RequiredExp NAMESPACE Req:: FILE testLibRequiredTargets.cmake DESTINATION lib/cmake/testLibRequired) install(TARGETS testLibDepends testSharedLibDepends EXPORT DependsExp DESTINATION lib ) -install(EXPORT DependsExp FILE testLibDependsConfig.cmake DESTINATION lib/cmake/testLibDepends) +install(EXPORT DependsExp FILE testLibDependsTargets.cmake DESTINATION lib/cmake/testLibDepends) +file(WRITE + "${CMAKE_CURRENT_BINARY_DIR}/testLibRequiredConfig.cmake" + " +if(\${CMAKE_FIND_PACKAGE_NAME}_FIND_VERSION VERSION_LESS 2.3 AND NOT \${CMAKE_FIND_PACKAGE_NAME}_INTERFACES) + set(\${CMAKE_FIND_PACKAGE_NAME}_NO_INTERFACES 1) +endif() +include(\"\${CMAKE_CURRENT_LIST_DIR}/testLibRequiredTargets.cmake\") +set(\${CMAKE_FIND_PACKAGE_NAME}_INCLUDE_DIRS \"${CMAKE_CURRENT_BINARY_DIR}\" \"${CMAKE_CURRENT_SOURCE_DIR}\" ) +" +) + +include(CMakePackageConfigHelpers) +write_basic_package_version_file( testLibRequiredConfigVersion.cmake VERSION 2.5 COMPATIBILITY AnyNewerVersion) + +install(FILES + "${CMAKE_CURRENT_BINARY_DIR}/testLibRequiredConfig.cmake" + "${CMAKE_CURRENT_BINARY_DIR}/testLibRequiredConfigVersion.cmake" + DESTINATION lib/cmake/testLibRequired +) # Install and export from install tree. install( diff --git a/Tests/ExportImport/Import/A/CMakeLists.txt b/Tests/ExportImport/Import/A/CMakeLists.txt index 4812e7e..0337130 100644 --- a/Tests/ExportImport/Import/A/CMakeLists.txt +++ b/Tests/ExportImport/Import/A/CMakeLists.txt @@ -5,8 +5,8 @@ include(${Import_BINARY_DIR}/../Export/ExportBuildTree.cmake) include(${CMAKE_INSTALL_PREFIX}/lib/exp/exp.cmake) # Import two exports, where the Depends one depends on an exported target from the Required one: -include(${CMAKE_INSTALL_PREFIX}/lib/cmake/testLibRequired/testLibRequiredConfig.cmake) -include(${CMAKE_INSTALL_PREFIX}/lib/cmake/testLibDepends/testLibDependsConfig.cmake) +include(${CMAKE_INSTALL_PREFIX}/lib/cmake/testLibRequired/testLibRequiredTargets.cmake) +include(${CMAKE_INSTALL_PREFIX}/lib/cmake/testLibDepends/testLibDependsTargets.cmake) # Try referencing an executable imported from the install tree. add_custom_command( @@ -159,13 +159,15 @@ endif() add_executable(deps_iface deps_iface.c) target_link_libraries(deps_iface testLibDepends) -target_include_directories(deps_iface PRIVATE testLibDepends) -target_compile_definitions(deps_iface PRIVATE testLibDepends) add_executable(deps_shared_iface deps_shared_iface.cpp) target_link_libraries(deps_shared_iface testSharedLibDepends) -target_include_directories(deps_shared_iface PRIVATE testSharedLibDepends) -target_compile_definitions(deps_shared_iface PRIVATE testSharedLibDepends) +target_compile_definitions(deps_shared_iface + PRIVATE + $<$<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> +) if (APPLE OR CMAKE_CXX_COMPILER_ID MATCHES "GNU") include(CheckCXXCompilerFlag) @@ -191,7 +193,9 @@ 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 bld_testSharedLibDepends bld_subdirlib) target_compile_definitions(deps_shared_iface2 - PRIVATE bld_testSharedLibDepends 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/A/deps_shared_iface.cpp b/Tests/ExportImport/Import/A/deps_shared_iface.cpp index 43f832a..2f0e74a 100644 --- a/Tests/ExportImport/Import/A/deps_shared_iface.cpp +++ b/Tests/ExportImport/Import/A/deps_shared_iface.cpp @@ -8,6 +8,18 @@ #endif #endif +#ifndef PIC_PROPERTY_IS_ON +#error Expected PIC_PROPERTY_IS_ON +#endif + +#ifndef CUSTOM_PROPERTY_IS_ON +#error Expected CUSTOM_PROPERTY_IS_ON +#endif + +#ifndef CUSTOM_STRING_IS_MATCH +#error Expected CUSTOM_STRING_IS_MATCH +#endif + #ifdef TEST_SUBDIR_LIB #include "subdir.h" #endif 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}) |