diff options
author | Kyle Edwards <kyle.edwards@kitware.com> | 2019-01-14 17:27:14 (GMT) |
---|---|---|
committer | Kyle Edwards <kyle.edwards@kitware.com> | 2019-01-17 14:44:29 (GMT) |
commit | 4568d046c46a7357ab48ddfb1117bad39e65572c (patch) | |
tree | 851a7fbee311593712dfff42fdcf9070a2187427 /Tests/RunCMake/CMakeRoleGlobalProperty | |
parent | c59eae7ebc5423c2b06befd762f8639b0f23b7a0 (diff) | |
download | CMake-4568d046c46a7357ab48ddfb1117bad39e65572c.zip CMake-4568d046c46a7357ab48ddfb1117bad39e65572c.tar.gz CMake-4568d046c46a7357ab48ddfb1117bad39e65572c.tar.bz2 |
Properties: Add CMAKE_ROLE global property
This property allows scripts to determine whether they're in project
mode, script mode, find-package mode, CTest, or CPack.
Diffstat (limited to 'Tests/RunCMake/CMakeRoleGlobalProperty')
8 files changed, 45 insertions, 0 deletions
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() |