diff options
author | Stephen Kelly <steveire@gmail.com> | 2013-06-04 14:47:57 (GMT) |
---|---|---|
committer | Stephen Kelly <steveire@gmail.com> | 2013-07-08 20:39:57 (GMT) |
commit | 574fec97fd011ea2899abdd05d97ea66f0faa063 (patch) | |
tree | 82de4bacc4771ff4f6ce085cccec04d99b28d35b /Tests | |
parent | d0a76ea07cfc2a73900a9539e940e1e60dbba120 (diff) | |
download | CMake-574fec97fd011ea2899abdd05d97ea66f0faa063.zip CMake-574fec97fd011ea2899abdd05d97ea66f0faa063.tar.gz CMake-574fec97fd011ea2899abdd05d97ea66f0faa063.tar.bz2 |
Export: Generate INTERFACE_LINK_LIBRARIES property on targets.
This property is generated only for targets which have recorded
policy CMP0022 as NEW, and a compatibility mode is added to
additionally export the old interfaces in that case too.
If the old interfaces are not exported, the generated export files
require CMake 2.8.12. Because the unit tests use a version which
is not yet called 2.8.12, temporarily require a lower version.
Diffstat (limited to 'Tests')
19 files changed, 115 insertions, 0 deletions
diff --git a/Tests/ExportImport/Export/CMakeLists.txt b/Tests/ExportImport/Export/CMakeLists.txt index efecd03..da15d62 100644 --- a/Tests/ExportImport/Export/CMakeLists.txt +++ b/Tests/ExportImport/Export/CMakeLists.txt @@ -232,6 +232,33 @@ target_link_libraries(testSharedLibDepends LINK_PUBLIC renamed_on_export) target_link_libraries(testSharedLibDepends LINK_INTERFACE_LIBRARIES $<$<STREQUAL:$<TARGET_PROPERTY:TYPE>,EXECUTABLE>:$<TARGET_NAME:testSharedLibRequired>>) +add_library(cmp0022OLD SHARED cmp0022_vs6_1.cpp) +generate_export_header(cmp0022OLD BASE_NAME cmp0022) +target_include_directories(cmp0022OLD PUBLIC + "$<BUILD_INTERFACE:${CMAKE_CURRENT_BINARY_DIR};${CMAKE_CURRENT_SOURCE_DIR}>" + "$<INSTALL_INTERFACE:$<INSTALL_PREFIX>/include/cmp0022>" +) +cmake_policy(SET CMP0022 NEW) +add_library(cmp0022NEW SHARED cmp0022_vs6_1.cpp) +target_include_directories(cmp0022NEW PUBLIC + "$<BUILD_INTERFACE:${CMAKE_CURRENT_BINARY_DIR};${CMAKE_CURRENT_SOURCE_DIR}>" + "$<INSTALL_INTERFACE:$<INSTALL_PREFIX>/include/cmp0022>" +) +cmake_policy(SET CMP0022 OLD) +install(FILES + "${CMAKE_CURRENT_SOURCE_DIR}/cmp0022.h" + "${CMAKE_CURRENT_BINARY_DIR}/cmp0022_export.h" + DESTINATION include/cmp0022 +) + +set_property(TARGET testLib2 APPEND PROPERTY INTERFACE_COMPILE_DEFINITIONS USING_TESTLIB2) +set_property(TARGET testLib3 APPEND PROPERTY INTERFACE_COMPILE_DEFINITIONS USING_TESTLIB3) + +set_property(TARGET cmp0022NEW APPEND PROPERTY INTERFACE_LINK_LIBRARIES testLib2) +# set_property(TARGET cmp0022NEW APPEND PROPERTY LINK_INTERFACE_LIBRARIES testLibIncludeRequired2) # TODO: Test for error +set_property(TARGET cmp0022OLD APPEND PROPERTY INTERFACE_LINK_LIBRARIES testLib2) +set_property(TARGET cmp0022OLD APPEND PROPERTY LINK_INTERFACE_LIBRARIES testLib3) + install(TARGETS testLibRequired testLibIncludeRequired1 testLibIncludeRequired2 @@ -273,6 +300,7 @@ install( testExe2lib testLib4lib testLib4libdbg testLib4libopt testLib6 testLibCycleA testLibCycleB + cmp0022NEW cmp0022OLD EXPORT exp RUNTIME DESTINATION bin LIBRARY DESTINATION lib NAMELINK_SKIP @@ -316,6 +344,7 @@ add_subdirectory(sublib) # For CMAKE_INCLUDE_CURRENT_DIR_IN_INTERFACE test. export(TARGETS testExe1 testLib1 testLib2 testLib3 testExe2libImp testLib3Imp testLib3ImpDep subdirlib testSharedLibRequired testSharedLibDepends renamed_on_export + cmp0022NEW cmp0022OLD NAMESPACE bld_ FILE ExportBuildTree.cmake ) diff --git a/Tests/ExportImport/Export/cmp0022.cpp b/Tests/ExportImport/Export/cmp0022.cpp new file mode 100644 index 0000000..bef8e61 --- /dev/null +++ b/Tests/ExportImport/Export/cmp0022.cpp @@ -0,0 +1,7 @@ + +#include "cmp0022.h" + +int cmp0022() +{ + return 0; +} diff --git a/Tests/ExportImport/Export/cmp0022.h b/Tests/ExportImport/Export/cmp0022.h new file mode 100644 index 0000000..32bf71a --- /dev/null +++ b/Tests/ExportImport/Export/cmp0022.h @@ -0,0 +1,4 @@ + +#include "cmp0022_export.h" + +int CMP0022_EXPORT cmp0022(); diff --git a/Tests/ExportImport/Export/cmp0022_vs6_1.cpp b/Tests/ExportImport/Export/cmp0022_vs6_1.cpp new file mode 100644 index 0000000..a6ec838 --- /dev/null +++ b/Tests/ExportImport/Export/cmp0022_vs6_1.cpp @@ -0,0 +1 @@ +#include "cmp0022.cpp" diff --git a/Tests/ExportImport/Export/cmp0022_vs6_2.cpp b/Tests/ExportImport/Export/cmp0022_vs6_2.cpp new file mode 100644 index 0000000..a6ec838 --- /dev/null +++ b/Tests/ExportImport/Export/cmp0022_vs6_2.cpp @@ -0,0 +1 @@ +#include "cmp0022.cpp" diff --git a/Tests/ExportImport/Import/A/CMakeLists.txt b/Tests/ExportImport/Import/A/CMakeLists.txt index 3bfbc46..376abac 100644 --- a/Tests/ExportImport/Import/A/CMakeLists.txt +++ b/Tests/ExportImport/Import/A/CMakeLists.txt @@ -68,6 +68,16 @@ target_link_libraries(imp_testExe1b bld_testLibCycleA ) +add_executable(cmp0022OLD_test cmp0022OLD_test_vs6_1.cpp) +target_link_libraries(cmp0022OLD_test bld_cmp0022OLD) +add_executable(cmp0022NEW_test cmp0022NEW_test_vs6_1.cpp) +target_link_libraries(cmp0022NEW_test bld_cmp0022NEW) + +add_executable(cmp0022OLD_exp_test cmp0022OLD_test_vs6_2.cpp) +target_link_libraries(cmp0022OLD_exp_test exp_cmp0022OLD) +add_executable(cmp0022NEW_exp_test cmp0022NEW_test_vs6_2.cpp) +target_link_libraries(cmp0022NEW_exp_test exp_cmp0022NEW) + # Try building a plugin to an executable imported from the build tree. add_library(imp_mod1b MODULE imp_mod1.c) target_link_libraries(imp_mod1b bld_testExe2) diff --git a/Tests/ExportImport/Import/A/cmp0022NEW_test.cpp b/Tests/ExportImport/Import/A/cmp0022NEW_test.cpp new file mode 100644 index 0000000..5878349 --- /dev/null +++ b/Tests/ExportImport/Import/A/cmp0022NEW_test.cpp @@ -0,0 +1,12 @@ + +#ifndef USING_TESTLIB2 +#error Expected USING_TESTLIB2 +#endif +#ifdef USING_TESTLIB3 +#error Unexpected USING_TESTLIB3 +#endif + +int main(void) +{ + return 0; +} diff --git a/Tests/ExportImport/Import/A/cmp0022NEW_test_vs6_1.cpp b/Tests/ExportImport/Import/A/cmp0022NEW_test_vs6_1.cpp new file mode 100644 index 0000000..033b746 --- /dev/null +++ b/Tests/ExportImport/Import/A/cmp0022NEW_test_vs6_1.cpp @@ -0,0 +1 @@ +#include "cmp0022NEW_test.cpp" diff --git a/Tests/ExportImport/Import/A/cmp0022NEW_test_vs6_2.cpp b/Tests/ExportImport/Import/A/cmp0022NEW_test_vs6_2.cpp new file mode 100644 index 0000000..033b746 --- /dev/null +++ b/Tests/ExportImport/Import/A/cmp0022NEW_test_vs6_2.cpp @@ -0,0 +1 @@ +#include "cmp0022NEW_test.cpp" diff --git a/Tests/ExportImport/Import/A/cmp0022OLD_test.cpp b/Tests/ExportImport/Import/A/cmp0022OLD_test.cpp new file mode 100644 index 0000000..e50158b --- /dev/null +++ b/Tests/ExportImport/Import/A/cmp0022OLD_test.cpp @@ -0,0 +1,12 @@ + +#ifdef USING_TESTLIB2 +#error Unexpected USING_TESTLIB2 +#endif +#ifndef USING_TESTLIB3 +#error Expected USING_TESTLIB3 +#endif + +int main(void) +{ + return 0; +} diff --git a/Tests/ExportImport/Import/A/cmp0022OLD_test_vs6_1.cpp b/Tests/ExportImport/Import/A/cmp0022OLD_test_vs6_1.cpp new file mode 100644 index 0000000..90d804c --- /dev/null +++ b/Tests/ExportImport/Import/A/cmp0022OLD_test_vs6_1.cpp @@ -0,0 +1 @@ +#include "cmp0022OLD_test.cpp" diff --git a/Tests/ExportImport/Import/A/cmp0022OLD_test_vs6_2.cpp b/Tests/ExportImport/Import/A/cmp0022OLD_test_vs6_2.cpp new file mode 100644 index 0000000..90d804c --- /dev/null +++ b/Tests/ExportImport/Import/A/cmp0022OLD_test_vs6_2.cpp @@ -0,0 +1 @@ +#include "cmp0022OLD_test.cpp" diff --git a/Tests/RunCMake/CMP0022/CMP0022-export-result.txt b/Tests/RunCMake/CMP0022/CMP0022-export-result.txt new file mode 100644 index 0000000..d00491f --- /dev/null +++ b/Tests/RunCMake/CMP0022/CMP0022-export-result.txt @@ -0,0 +1 @@ +1 diff --git a/Tests/RunCMake/CMP0022/CMP0022-export-stderr.txt b/Tests/RunCMake/CMP0022/CMP0022-export-stderr.txt new file mode 100644 index 0000000..6c29057 --- /dev/null +++ b/Tests/RunCMake/CMP0022/CMP0022-export-stderr.txt @@ -0,0 +1,4 @@ +CMake Error at CMP0022-export.cmake:11 \(export\): + Target "cmp0022NEW" has policy CMP0022 enabled, but also has old-style + INTERFACE_LINK_LIBRARIES properties populated, but it was exported without + the EXPORT_LINK_INTERFACE_LIBRARIES to export the old-style properties diff --git a/Tests/RunCMake/CMP0022/CMP0022-export.cmake b/Tests/RunCMake/CMP0022/CMP0022-export.cmake new file mode 100644 index 0000000..06147f3 --- /dev/null +++ b/Tests/RunCMake/CMP0022/CMP0022-export.cmake @@ -0,0 +1,11 @@ + +project(cmp0022NEW) + +cmake_policy(SET CMP0022 NEW) + +add_library(cmp0022NEW SHARED empty_vs6_1.cpp) +add_library(testLib SHARED empty_vs6_2.cpp) + +set_property(TARGET cmp0022NEW APPEND PROPERTY LINK_INTERFACE_LIBRARIES testLib) + +export(TARGETS cmp0022NEW testLib FILE "${CMAKE_CURRENT_BINARY_DIR}/cmp0022NEW.cmake") diff --git a/Tests/RunCMake/CMP0022/CMP0022-install-export-result.txt b/Tests/RunCMake/CMP0022/CMP0022-install-export-result.txt new file mode 100644 index 0000000..d00491f --- /dev/null +++ b/Tests/RunCMake/CMP0022/CMP0022-install-export-result.txt @@ -0,0 +1 @@ +1 diff --git a/Tests/RunCMake/CMP0022/CMP0022-install-export-stderr.txt b/Tests/RunCMake/CMP0022/CMP0022-install-export-stderr.txt new file mode 100644 index 0000000..3425e8e --- /dev/null +++ b/Tests/RunCMake/CMP0022/CMP0022-install-export-stderr.txt @@ -0,0 +1,4 @@ +CMake Error in CMakeLists.txt: + Target "cmp0022NEW" has policy CMP0022 enabled, but also has old-style + INTERFACE_LINK_LIBRARIES properties populated, but it was exported without + the EXPORT_LINK_INTERFACE_LIBRARIES to export the old-style properties diff --git a/Tests/RunCMake/CMP0022/CMP0022-install-export.cmake b/Tests/RunCMake/CMP0022/CMP0022-install-export.cmake new file mode 100644 index 0000000..171febe --- /dev/null +++ b/Tests/RunCMake/CMP0022/CMP0022-install-export.cmake @@ -0,0 +1,12 @@ + +project(cmp0022NEW) + +cmake_policy(SET CMP0022 NEW) + +add_library(cmp0022NEW SHARED empty_vs6_1.cpp) +add_library(testLib SHARED empty_vs6_2.cpp) + +set_property(TARGET cmp0022NEW APPEND PROPERTY LINK_INTERFACE_LIBRARIES testLib) + +install(TARGETS cmp0022NEW testLib EXPORT exp DESTINATION lib) +install(EXPORT exp FILE expTargets.cmake DESTINATION lib/cmake/exp) diff --git a/Tests/RunCMake/CMP0022/RunCMakeTest.cmake b/Tests/RunCMake/CMP0022/RunCMakeTest.cmake index 2e74f17..616d664 100644 --- a/Tests/RunCMake/CMP0022/RunCMakeTest.cmake +++ b/Tests/RunCMake/CMP0022/RunCMakeTest.cmake @@ -3,3 +3,5 @@ include(RunCMake) run_cmake(CMP0022-WARN) run_cmake(CMP0022-WARN-static) run_cmake(CMP0022-NOWARN-static) +run_cmake(CMP0022-export) +run_cmake(CMP0022-install-export) |