From 30ff6cf9e9b3211a54187e416d6cc2ce9b0e9b77 Mon Sep 17 00:00:00 2001 From: Stephen Kelly Date: Sun, 7 Oct 2012 21:47:46 +0200 Subject: Refactor the Plugin test. Policy CMP0024 was introduced to disallow the include() of a file generated by export(). Use ExternalProject to test the plugins after building. --- Tests/Plugin/CMakeLists.txt | 38 +++++++--------------------------- Tests/Plugin/PluginTest/CMakeLists.txt | 34 ++++++++++++++++++++++++++++++ 2 files changed, 42 insertions(+), 30 deletions(-) create mode 100644 Tests/Plugin/PluginTest/CMakeLists.txt diff --git a/Tests/Plugin/CMakeLists.txt b/Tests/Plugin/CMakeLists.txt index d1b8334..c6ed15d 100644 --- a/Tests/Plugin/CMakeLists.txt +++ b/Tests/Plugin/CMakeLists.txt @@ -50,37 +50,15 @@ if(CMAKE_SHARED_LIBRARY_SONAME_C_FLAG AND # Verify that targets export with proper IMPORTED SONAME properties. export(TARGETS example_mod_1 example_mod_2 NAMESPACE exp_ FILE ${CMAKE_CURRENT_BINARY_DIR}/mods.cmake) - include(${CMAKE_CURRENT_BINARY_DIR}/mods.cmake) - get_property(configs TARGET exp_example_mod_1 PROPERTY IMPORTED_CONFIGURATIONS) - foreach(c ${configs}) - string(TOUPPER "${c}" CONFIG) - get_property(soname1 TARGET exp_example_mod_1 PROPERTY IMPORTED_SONAME_${CONFIG}) - get_property(soname2 TARGET exp_example_mod_2 PROPERTY IMPORTED_NO_SONAME_${CONFIG}) - if(soname1) - message(STATUS "exp_example_mod_1 has IMPORTED_SONAME_${CONFIG} as expected: ${soname1}") - else() - message(SEND_ERROR "exp_example_mod_1 does not have IMPORTED_SONAME_${CONFIG} but should") - endif() - if(soname2) - message(STATUS "exp_example_mod_2 has IMPORTED_NO_SONAME_${CONFIG} as expected: ${soname2}") - else() - message(SEND_ERROR "exp_example_mod_2 does not have IMPORTED_NO_SONAME_${CONFIG} but should") - endif() - endforeach() - # Parse the binary to check for SONAME if possible. - if("${CMAKE_EXECUTABLE_FORMAT}" MATCHES "ELF") - find_program(READELF_EXE readelf) - if(READELF_EXE) - add_custom_target(check_mod_soname ALL COMMAND - ${CMAKE_COMMAND} -Dreadelf=${READELF_EXE} - -Dmod1=$ - -Dmod2=$ - -P ${CMAKE_CURRENT_SOURCE_DIR}/check_mod_soname.cmake - ) - add_dependencies(check_mod_soname example_mod_1 example_mod_2) - endif() - endif() + include(ExternalProject) + ExternalProject_Add(PluginTest + SOURCE_DIR "${CMAKE_CURRENT_SOURCE_DIR}/PluginTest" + BINARY_DIR "${CMAKE_CURRENT_BINARY_DIR}/PluginTest" + DOWNLOAD_COMMAND "" + INSTALL_COMMAND "" + ) + add_dependencies(PluginTest example_mod_1 example_mod_2) endif() # TODO: diff --git a/Tests/Plugin/PluginTest/CMakeLists.txt b/Tests/Plugin/PluginTest/CMakeLists.txt new file mode 100644 index 0000000..79ef8a9 --- /dev/null +++ b/Tests/Plugin/PluginTest/CMakeLists.txt @@ -0,0 +1,34 @@ +cmake_minimum_required(VERSION 2.8) + +project(PluginTest) + +include(${CMAKE_CURRENT_BINARY_DIR}/../mods.cmake) +get_property(configs TARGET exp_example_mod_1 PROPERTY IMPORTED_CONFIGURATIONS) +foreach(c ${configs}) + string(TOUPPER "${c}" CONFIG) + get_property(soname1 TARGET exp_example_mod_1 PROPERTY IMPORTED_SONAME_${CONFIG}) + get_property(soname2 TARGET exp_example_mod_2 PROPERTY IMPORTED_NO_SONAME_${CONFIG}) + if(soname1) + message(STATUS "exp_example_mod_1 has IMPORTED_SONAME_${CONFIG} as expected: ${soname1}") + else() + message(SEND_ERROR "exp_example_mod_1 does not have IMPORTED_SONAME_${CONFIG} but should") + endif() + if(soname2) + message(STATUS "exp_example_mod_2 has IMPORTED_NO_SONAME_${CONFIG} as expected: ${soname2}") + else() + message(SEND_ERROR "exp_example_mod_2 does not have IMPORTED_NO_SONAME_${CONFIG} but should") + endif() +endforeach() + +# Parse the binary to check for SONAME if possible. +if("${CMAKE_EXECUTABLE_FORMAT}" MATCHES "ELF") + find_program(READELF_EXE readelf) + if(READELF_EXE) + add_custom_target(check_mod_soname ALL COMMAND + ${CMAKE_COMMAND} -Dreadelf=${READELF_EXE} + -Dmod1=$ + -Dmod2=$ + -P ${CMAKE_CURRENT_SOURCE_DIR}/../check_mod_soname.cmake + ) + endif() +endif() -- cgit v0.12 From 310aef959b6e41d60f35eec4b4a2e5698aa42abe Mon Sep 17 00:00:00 2001 From: Stephen Kelly Date: Sun, 7 Oct 2012 22:37:23 +0200 Subject: Make ExportLanguages a subtest of the ObjectLibrary test It was a subtest of the RunCMake.ObjectLibrary test. However, we need to test a build with ExternalProject after running CMake, which RunCMake tests do not do. --- Tests/ObjectLibrary/CMakeLists.txt | 2 ++ Tests/ObjectLibrary/ExportLanguages/CMakeLists.txt | 15 +++++++++++++++ .../ExportLanguages/ExportLanguagesTest/CMakeLists.txt | 14 ++++++++++++++ Tests/ObjectLibrary/ExportLanguages/a.c | 1 + Tests/ObjectLibrary/ExportLanguages/a.cxx | 1 + Tests/RunCMake/ObjectLibrary/ExportLanguages.cmake | 15 --------------- Tests/RunCMake/ObjectLibrary/RunCMakeTest.cmake | 1 - Tests/RunCMake/ObjectLibrary/a.cxx | 1 - 8 files changed, 33 insertions(+), 17 deletions(-) create mode 100644 Tests/ObjectLibrary/ExportLanguages/CMakeLists.txt create mode 100644 Tests/ObjectLibrary/ExportLanguages/ExportLanguagesTest/CMakeLists.txt create mode 100644 Tests/ObjectLibrary/ExportLanguages/a.c create mode 100644 Tests/ObjectLibrary/ExportLanguages/a.cxx delete mode 100644 Tests/RunCMake/ObjectLibrary/ExportLanguages.cmake delete mode 100644 Tests/RunCMake/ObjectLibrary/a.cxx diff --git a/Tests/ObjectLibrary/CMakeLists.txt b/Tests/ObjectLibrary/CMakeLists.txt index 13a07b4..0aeefaa 100644 --- a/Tests/ObjectLibrary/CMakeLists.txt +++ b/Tests/ObjectLibrary/CMakeLists.txt @@ -58,3 +58,5 @@ target_compile_definitions(ABmain PUBLIC $ $ $ ) + +add_subdirectory(ExportLanguages) diff --git a/Tests/ObjectLibrary/ExportLanguages/CMakeLists.txt b/Tests/ObjectLibrary/ExportLanguages/CMakeLists.txt new file mode 100644 index 0000000..22c92a7 --- /dev/null +++ b/Tests/ObjectLibrary/ExportLanguages/CMakeLists.txt @@ -0,0 +1,15 @@ +cmake_minimum_required(VERSION 2.8) +project(ExportLanguages CXX) +add_library(ExportLanguagesA OBJECT a.cxx) +add_library(ExportLanguagesB STATIC a.c $) + +# Verify that object library languages are propagated. +export(TARGETS ExportLanguagesB NAMESPACE Exp FILE BExport.cmake) +include(ExternalProject) +ExternalProject_Add(ExportLanguagesTest + SOURCE_DIR "${CMAKE_CURRENT_SOURCE_DIR}/ExportLanguagesTest" + BINARY_DIR "${CMAKE_CURRENT_BINARY_DIR}/ExportLanguagesTest" + DOWNLOAD_COMMAND "" + INSTALL_COMMAND "" +) +add_dependencies(ExportLanguagesTest ExportLanguagesA ExportLanguagesB) diff --git a/Tests/ObjectLibrary/ExportLanguages/ExportLanguagesTest/CMakeLists.txt b/Tests/ObjectLibrary/ExportLanguages/ExportLanguagesTest/CMakeLists.txt new file mode 100644 index 0000000..fc8dd2b --- /dev/null +++ b/Tests/ObjectLibrary/ExportLanguages/ExportLanguagesTest/CMakeLists.txt @@ -0,0 +1,14 @@ + +cmake_minimum_required(VERSION 2.8) + +project(ExportLanguagesTest) + +include(${CMAKE_CURRENT_BINARY_DIR}/../BExport.cmake) +get_property(configs TARGET ExpExportLanguagesB PROPERTY IMPORTED_CONFIGURATIONS) +foreach(c ${configs}) + get_property(langs TARGET ExpExportLanguagesB PROPERTY IMPORTED_LINK_INTERFACE_LANGUAGES_${c}) + list(FIND langs CXX pos) + if(${pos} LESS 0) + message(FATAL_ERROR "Target export does not list object library languages.") + endif() +endforeach() diff --git a/Tests/ObjectLibrary/ExportLanguages/a.c b/Tests/ObjectLibrary/ExportLanguages/a.c new file mode 100644 index 0000000..af20d3f --- /dev/null +++ b/Tests/ObjectLibrary/ExportLanguages/a.c @@ -0,0 +1 @@ +int a(void) { return 0; } diff --git a/Tests/ObjectLibrary/ExportLanguages/a.cxx b/Tests/ObjectLibrary/ExportLanguages/a.cxx new file mode 100644 index 0000000..ae9c87c --- /dev/null +++ b/Tests/ObjectLibrary/ExportLanguages/a.cxx @@ -0,0 +1 @@ +extern "C" int acxx(void) { return 0; } diff --git a/Tests/RunCMake/ObjectLibrary/ExportLanguages.cmake b/Tests/RunCMake/ObjectLibrary/ExportLanguages.cmake deleted file mode 100644 index 0796c21..0000000 --- a/Tests/RunCMake/ObjectLibrary/ExportLanguages.cmake +++ /dev/null @@ -1,15 +0,0 @@ -enable_language(CXX) -add_library(A OBJECT a.cxx) -add_library(B STATIC a.c $) - -# Verify that object library languages are propagated. -export(TARGETS B NAMESPACE Exp FILE BExport.cmake) -include(${CMAKE_CURRENT_BINARY_DIR}/BExport.cmake) -get_property(configs TARGET ExpB PROPERTY IMPORTED_CONFIGURATIONS) -foreach(c ${configs}) - get_property(langs TARGET ExpB PROPERTY IMPORTED_LINK_INTERFACE_LANGUAGES_${c}) - list(FIND langs CXX pos) - if(${pos} LESS 0) - message(FATAL_ERROR "Target export does not list object library languages.") - endif() -endforeach() diff --git a/Tests/RunCMake/ObjectLibrary/RunCMakeTest.cmake b/Tests/RunCMake/ObjectLibrary/RunCMakeTest.cmake index 55db14d..a74eaa8 100644 --- a/Tests/RunCMake/ObjectLibrary/RunCMakeTest.cmake +++ b/Tests/RunCMake/ObjectLibrary/RunCMakeTest.cmake @@ -6,7 +6,6 @@ run_cmake(BadSourceExpression3) run_cmake(BadObjSource1) run_cmake(BadObjSource2) run_cmake(Export) -run_cmake(ExportLanguages) run_cmake(Import) run_cmake(Install) run_cmake(LinkObjLHS) diff --git a/Tests/RunCMake/ObjectLibrary/a.cxx b/Tests/RunCMake/ObjectLibrary/a.cxx deleted file mode 100644 index ae9c87c..0000000 --- a/Tests/RunCMake/ObjectLibrary/a.cxx +++ /dev/null @@ -1 +0,0 @@ -extern "C" int acxx(void) { return 0; } -- cgit v0.12