diff options
Diffstat (limited to 'Tests')
10 files changed, 51 insertions, 0 deletions
diff --git a/Tests/RunCMake/CMakeLists.txt b/Tests/RunCMake/CMakeLists.txt index 358521b..c8653b4 100644 --- a/Tests/RunCMake/CMakeLists.txt +++ b/Tests/RunCMake/CMakeLists.txt @@ -155,6 +155,7 @@ add_RunCMake_test(BuildDepends) if(UNIX AND "${CMAKE_GENERATOR}" MATCHES "Unix Makefiles|Ninja") add_RunCMake_test(Byproducts) endif() +add_RunCMake_test(CMakeRoleGlobalProperty) if(UNIX AND "${CMAKE_GENERATOR}" MATCHES "Unix Makefiles|Ninja") add_RunCMake_test(CompilerChange) endif() diff --git a/Tests/RunCMake/CMakeRoleGlobalProperty/CMakeLists.txt b/Tests/RunCMake/CMakeRoleGlobalProperty/CMakeLists.txt new file mode 100644 index 0000000..44025d3 --- /dev/null +++ b/Tests/RunCMake/CMakeRoleGlobalProperty/CMakeLists.txt @@ -0,0 +1,3 @@ +cmake_minimum_required(VERSION 3.12) +project(${RunCMake_TEST} NONE) +include(${RunCMake_TEST}.cmake) diff --git a/Tests/RunCMake/CMakeRoleGlobalProperty/CMakeLists.txt.in b/Tests/RunCMake/CMakeRoleGlobalProperty/CMakeLists.txt.in new file mode 100644 index 0000000..913239c --- /dev/null +++ b/Tests/RunCMake/CMakeRoleGlobalProperty/CMakeLists.txt.in @@ -0,0 +1,4 @@ +cmake_minimum_required(VERSION 3.1) +project(CTestStart@CASE_NAME@ NONE) +include(CTest) +add_test(NAME RunCMakeVersion COMMAND "${CMAKE_COMMAND}" --version) diff --git a/Tests/RunCMake/CMakeRoleGlobalProperty/FindDummyPackage.cmake b/Tests/RunCMake/CMakeRoleGlobalProperty/FindDummyPackage.cmake new file mode 100644 index 0000000..8299042 --- /dev/null +++ b/Tests/RunCMake/CMakeRoleGlobalProperty/FindDummyPackage.cmake @@ -0,0 +1,8 @@ +cmake_minimum_required(VERSION 3.12) + +get_property(role GLOBAL PROPERTY CMAKE_ROLE) +if(NOT role STREQUAL "FIND_PACKAGE") + message(SEND_ERROR "CMAKE_ROLE property is \"${role}\", should be \"FIND_PACKAGE\"") +endif() + +set(DummyPackage_FOUND 1) diff --git a/Tests/RunCMake/CMakeRoleGlobalProperty/Project.cmake b/Tests/RunCMake/CMakeRoleGlobalProperty/Project.cmake new file mode 100644 index 0000000..c0b6a48 --- /dev/null +++ b/Tests/RunCMake/CMakeRoleGlobalProperty/Project.cmake @@ -0,0 +1,6 @@ +get_property(role GLOBAL PROPERTY CMAKE_ROLE) +if(NOT role STREQUAL "PROJECT") + message(SEND_ERROR "CMAKE_ROLE property is \"${role}\", should be \"PROJECT\"") +endif() + +add_subdirectory(sub) diff --git a/Tests/RunCMake/CMakeRoleGlobalProperty/RunCMakeTest.cmake b/Tests/RunCMake/CMakeRoleGlobalProperty/RunCMakeTest.cmake new file mode 100644 index 0000000..b840317 --- /dev/null +++ b/Tests/RunCMake/CMakeRoleGlobalProperty/RunCMakeTest.cmake @@ -0,0 +1,7 @@ +include(RunCMake) +include(RunCTest) + +run_cmake(Project) +run_cmake_command(Script "${CMAKE_COMMAND}" -P "${CMAKE_CURRENT_LIST_DIR}/Script.cmake") +run_cmake_command(FindPackage "${CMAKE_COMMAND}" --find-package -DNAME=DummyPackage -DCOMPILER_ID=GNU -DLANGUAGE=CXX -DMODE=EXIST "-DCMAKE_MODULE_PATH=${CMAKE_CURRENT_LIST_DIR}") +run_ctest(CTest) diff --git a/Tests/RunCMake/CMakeRoleGlobalProperty/Script.cmake b/Tests/RunCMake/CMakeRoleGlobalProperty/Script.cmake new file mode 100644 index 0000000..371edbc --- /dev/null +++ b/Tests/RunCMake/CMakeRoleGlobalProperty/Script.cmake @@ -0,0 +1,6 @@ +cmake_minimum_required(VERSION 3.12) + +get_property(role GLOBAL PROPERTY CMAKE_ROLE) +if(NOT role STREQUAL "SCRIPT") + message(SEND_ERROR "CMAKE_ROLE property is \"${role}\", should be \"SCRIPT\"") +endif() diff --git a/Tests/RunCMake/CMakeRoleGlobalProperty/sub/CMakeLists.txt b/Tests/RunCMake/CMakeRoleGlobalProperty/sub/CMakeLists.txt new file mode 100644 index 0000000..8ecf671 --- /dev/null +++ b/Tests/RunCMake/CMakeRoleGlobalProperty/sub/CMakeLists.txt @@ -0,0 +1,4 @@ +get_property(role GLOBAL PROPERTY CMAKE_ROLE) +if(NOT role STREQUAL "PROJECT") + message(SEND_ERROR "CMAKE_ROLE property is \"${role}\", should be \"PROJECT\"") +endif() diff --git a/Tests/RunCMake/CMakeRoleGlobalProperty/test.cmake.in b/Tests/RunCMake/CMakeRoleGlobalProperty/test.cmake.in new file mode 100644 index 0000000..4e2c085 --- /dev/null +++ b/Tests/RunCMake/CMakeRoleGlobalProperty/test.cmake.in @@ -0,0 +1,7 @@ +cmake_minimum_required(VERSION 3.12) +set(CTEST_RUN_CURRENT_SCRIPT 0) + +get_property(role GLOBAL PROPERTY CMAKE_ROLE) +if(NOT role STREQUAL "CTEST") + message(SEND_ERROR "CMAKE_ROLE property is \"${role}\", should be \"CTEST\"") +endif() diff --git a/Tests/RunCMake/CPack/tests/EXTERNAL/create_package.cmake b/Tests/RunCMake/CPack/tests/EXTERNAL/create_package.cmake index 2d7f993..6f7c4c2 100644 --- a/Tests/RunCMake/CPack/tests/EXTERNAL/create_package.cmake +++ b/Tests/RunCMake/CPack/tests/EXTERNAL/create_package.cmake @@ -1,5 +1,10 @@ message("This script could run an external packaging tool") +get_property(role GLOBAL PROPERTY CMAKE_ROLE) +if(NOT role STREQUAL "CPACK") + message(SEND_ERROR "CMAKE_ROLE property is \"${role}\", should be \"CPACK\"") +endif() + function(expect_variable VAR) if(NOT ${VAR}) message(FATAL_ERROR "${VAR} is unexpectedly not set") |