summaryrefslogtreecommitdiffstats
path: root/Tests/RunCMake/project
diff options
context:
space:
mode:
authorCraig Scott <craig.scott@crascit.com>2022-05-10 12:52:18 (GMT)
committerCraig Scott <craig.scott@crascit.com>2022-05-13 08:03:36 (GMT)
commita6c34b0353e62457465248334703cbd641b2545c (patch)
tree7d51fc255e6b3fc36c474a80e08704be0c9f3208 /Tests/RunCMake/project
parent8aa29a1793f8f5c34b92864e53d6806725e5aa57 (diff)
downloadCMake-a6c34b0353e62457465248334703cbd641b2545c.zip
CMake-a6c34b0353e62457465248334703cbd641b2545c.tar.gz
CMake-a6c34b0353e62457465248334703cbd641b2545c.tar.bz2
project(): Add new CMAKE_PROJECT_TOP_LEVEL_INCLUDES file injection point
Fixes: #22685
Diffstat (limited to 'Tests/RunCMake/project')
-rw-r--r--Tests/RunCMake/project/CodeInjection-stdout.txt10
-rw-r--r--Tests/RunCMake/project/CodeInjection.cmake1
-rw-r--r--Tests/RunCMake/project/CodeInjection/CMakeLists.txt2
-rw-r--r--Tests/RunCMake/project/CodeInjection/cmake_project_include.cmake1
-rw-r--r--Tests/RunCMake/project/CodeInjection/cmake_project_include_before.cmake1
-rw-r--r--Tests/RunCMake/project/CodeInjection/cmake_project_subproj_include.cmake1
-rw-r--r--Tests/RunCMake/project/CodeInjection/cmake_project_subproj_include_before.cmake1
-rw-r--r--Tests/RunCMake/project/CodeInjection/cmake_project_top_level_includes_1.cmake1
-rw-r--r--Tests/RunCMake/project/CodeInjection/cmake_project_top_level_includes_2.cmake1
-rw-r--r--Tests/RunCMake/project/CodeInjection/initial_cache.cmake10
-rw-r--r--Tests/RunCMake/project/CodeInjection/passthrough_toolchain_file.cmake1
-rw-r--r--Tests/RunCMake/project/RunCMakeTest.cmake9
12 files changed, 39 insertions, 0 deletions
diff --git a/Tests/RunCMake/project/CodeInjection-stdout.txt b/Tests/RunCMake/project/CodeInjection-stdout.txt
new file mode 100644
index 0000000..88ac966
--- /dev/null
+++ b/Tests/RunCMake/project/CodeInjection-stdout.txt
@@ -0,0 +1,10 @@
+(-- )?Included CMAKE_PROJECT_INCLUDE_BEFORE
+(-- )?Included CMAKE_TOOLCHAIN_FILE
+.*Included CMAKE_PROJECT_TOP_LEVEL_INCLUDES first file
+(-- )?Included CMAKE_PROJECT_TOP_LEVEL_INCLUDES second file
+(-- )?Included CMAKE_PROJECT_INCLUDE
+(-- )?Calling sub-project
+(-- )?Included CMAKE_PROJECT_INCLUDE_BEFORE
+(-- )?Included CMAKE_PROJECT_SubProj_INCLUDE_BEFORE
+(-- )?Included CMAKE_PROJECT_INCLUDE
+(-- )?Included CMAKE_PROJECT_SubProj_INCLUDE
diff --git a/Tests/RunCMake/project/CodeInjection.cmake b/Tests/RunCMake/project/CodeInjection.cmake
new file mode 100644
index 0000000..dcf56a1
--- /dev/null
+++ b/Tests/RunCMake/project/CodeInjection.cmake
@@ -0,0 +1 @@
+add_subdirectory(CodeInjection)
diff --git a/Tests/RunCMake/project/CodeInjection/CMakeLists.txt b/Tests/RunCMake/project/CodeInjection/CMakeLists.txt
new file mode 100644
index 0000000..8ee99d0
--- /dev/null
+++ b/Tests/RunCMake/project/CodeInjection/CMakeLists.txt
@@ -0,0 +1,2 @@
+message(STATUS "Calling sub-project")
+project(SubProj LANGUAGES NONE)
diff --git a/Tests/RunCMake/project/CodeInjection/cmake_project_include.cmake b/Tests/RunCMake/project/CodeInjection/cmake_project_include.cmake
new file mode 100644
index 0000000..f3f0a7e
--- /dev/null
+++ b/Tests/RunCMake/project/CodeInjection/cmake_project_include.cmake
@@ -0,0 +1 @@
+message(STATUS "Included CMAKE_PROJECT_INCLUDE")
diff --git a/Tests/RunCMake/project/CodeInjection/cmake_project_include_before.cmake b/Tests/RunCMake/project/CodeInjection/cmake_project_include_before.cmake
new file mode 100644
index 0000000..01d53c9
--- /dev/null
+++ b/Tests/RunCMake/project/CodeInjection/cmake_project_include_before.cmake
@@ -0,0 +1 @@
+message(STATUS "Included CMAKE_PROJECT_INCLUDE_BEFORE")
diff --git a/Tests/RunCMake/project/CodeInjection/cmake_project_subproj_include.cmake b/Tests/RunCMake/project/CodeInjection/cmake_project_subproj_include.cmake
new file mode 100644
index 0000000..d68de6a
--- /dev/null
+++ b/Tests/RunCMake/project/CodeInjection/cmake_project_subproj_include.cmake
@@ -0,0 +1 @@
+message(STATUS "Included CMAKE_PROJECT_SubProj_INCLUDE")
diff --git a/Tests/RunCMake/project/CodeInjection/cmake_project_subproj_include_before.cmake b/Tests/RunCMake/project/CodeInjection/cmake_project_subproj_include_before.cmake
new file mode 100644
index 0000000..ef3bfc0
--- /dev/null
+++ b/Tests/RunCMake/project/CodeInjection/cmake_project_subproj_include_before.cmake
@@ -0,0 +1 @@
+message(STATUS "Included CMAKE_PROJECT_SubProj_INCLUDE_BEFORE")
diff --git a/Tests/RunCMake/project/CodeInjection/cmake_project_top_level_includes_1.cmake b/Tests/RunCMake/project/CodeInjection/cmake_project_top_level_includes_1.cmake
new file mode 100644
index 0000000..73ad037
--- /dev/null
+++ b/Tests/RunCMake/project/CodeInjection/cmake_project_top_level_includes_1.cmake
@@ -0,0 +1 @@
+message(STATUS "Included CMAKE_PROJECT_TOP_LEVEL_INCLUDES first file")
diff --git a/Tests/RunCMake/project/CodeInjection/cmake_project_top_level_includes_2.cmake b/Tests/RunCMake/project/CodeInjection/cmake_project_top_level_includes_2.cmake
new file mode 100644
index 0000000..80f9705
--- /dev/null
+++ b/Tests/RunCMake/project/CodeInjection/cmake_project_top_level_includes_2.cmake
@@ -0,0 +1 @@
+message(STATUS "Included CMAKE_PROJECT_TOP_LEVEL_INCLUDES second file")
diff --git a/Tests/RunCMake/project/CodeInjection/initial_cache.cmake b/Tests/RunCMake/project/CodeInjection/initial_cache.cmake
new file mode 100644
index 0000000..6c8995b
--- /dev/null
+++ b/Tests/RunCMake/project/CodeInjection/initial_cache.cmake
@@ -0,0 +1,10 @@
+set(CMAKE_TOOLCHAIN_FILE "${CMAKE_CURRENT_LIST_DIR}/passthrough_toolchain_file.cmake" CACHE FILEPATH "")
+set(CMAKE_PROJECT_INCLUDE "${CMAKE_CURRENT_LIST_DIR}/cmake_project_include.cmake" CACHE FILEPATH "")
+set(CMAKE_PROJECT_INCLUDE_BEFORE "${CMAKE_CURRENT_LIST_DIR}/cmake_project_include_before.cmake" CACHE FILEPATH "")
+set(CMAKE_PROJECT_SubProj_INCLUDE "${CMAKE_CURRENT_LIST_DIR}/cmake_project_subproj_include.cmake" CACHE FILEPATH "")
+set(CMAKE_PROJECT_SubProj_INCLUDE_BEFORE "${CMAKE_CURRENT_LIST_DIR}/cmake_project_subproj_include_before.cmake" CACHE FILEPATH "")
+set(CMAKE_PROJECT_TOP_LEVEL_INCLUDES
+ "${CMAKE_CURRENT_LIST_DIR}/cmake_project_top_level_includes_1.cmake"
+ "${CMAKE_CURRENT_LIST_DIR}/cmake_project_top_level_includes_2.cmake"
+ CACHE STRING ""
+)
diff --git a/Tests/RunCMake/project/CodeInjection/passthrough_toolchain_file.cmake b/Tests/RunCMake/project/CodeInjection/passthrough_toolchain_file.cmake
new file mode 100644
index 0000000..d045712
--- /dev/null
+++ b/Tests/RunCMake/project/CodeInjection/passthrough_toolchain_file.cmake
@@ -0,0 +1 @@
+message(STATUS "Included CMAKE_TOOLCHAIN_FILE")
diff --git a/Tests/RunCMake/project/RunCMakeTest.cmake b/Tests/RunCMake/project/RunCMakeTest.cmake
index d7dab12..945d9ed 100644
--- a/Tests/RunCMake/project/RunCMakeTest.cmake
+++ b/Tests/RunCMake/project/RunCMakeTest.cmake
@@ -1,5 +1,14 @@
include(RunCMake)
+# Use an initial cache file to define the project() variables
+# to avoid long command lines. Also see the CMakeOnly test case
+# which tests some of the individual variables one at a time.
+# Here, we are focused on testing that the variables are all injected
+# at the expected points in the expected order.
+run_cmake_with_options(CodeInjection
+ -C "${CMAKE_CURRENT_LIST_DIR}/CodeInjection/initial_cache.cmake"
+)
+
if(CMake_TEST_RESOURCES)
run_cmake(ExplicitRC)
endif()