From 704acca96bcdf30c15bb64f2b7a92c21decc46ee Mon Sep 17 00:00:00 2001 From: Cristian Le Date: Mon, 16 Oct 2023 16:25:11 +0200 Subject: CMAKE_PROJECT_INCLUDE: Add support for including multiple files Fixes: #25341 Signed-off-by: Cristian Le --- Help/release/dev/project-include-multiple.rst | 9 ++++ Help/variable/CMAKE_PROJECT_INCLUDE.rst | 6 ++- Help/variable/CMAKE_PROJECT_INCLUDE_BEFORE.rst | 6 ++- .../CMAKE_PROJECT_PROJECT-NAME_INCLUDE.rst | 6 ++- .../CMAKE_PROJECT_PROJECT-NAME_INCLUDE_BEFORE.rst | 6 ++- Source/cmProjectCommand.cxx | 51 ++++++++++++++-------- Tests/RunCMake/project/CodeInjection-stdout.txt | 10 ----- Tests/RunCMake/project/CodeInjection.cmake | 1 - .../CodeInjection/cmake_project_include.cmake | 1 - .../cmake_project_include_before.cmake | 1 - .../CodeInjection/cmake_project_includes_1.cmake | 1 + .../CodeInjection/cmake_project_includes_2.cmake | 1 + .../cmake_project_includes_before_1.cmake | 1 + .../cmake_project_includes_before_2.cmake | 1 + .../cmake_project_subproj_include.cmake | 1 - .../cmake_project_subproj_include_before.cmake | 1 - .../cmake_project_subproj_includes_1.cmake | 1 + .../cmake_project_subproj_includes_2.cmake | 1 + .../cmake_project_subproj_includes_before_1.cmake | 1 + .../cmake_project_subproj_includes_before_2.cmake | 1 + .../project/CodeInjection/initial_cache.cmake | 10 ----- .../project/CodeInjection/initial_cache_1.cmake | 9 ++++ .../project/CodeInjection/initial_cache_2.cmake | 27 ++++++++++++ Tests/RunCMake/project/CodeInjection1-stdout.txt | 9 ++++ Tests/RunCMake/project/CodeInjection1.cmake | 1 + Tests/RunCMake/project/CodeInjection2-stdout.txt | 16 +++++++ Tests/RunCMake/project/CodeInjection2.cmake | 1 + Tests/RunCMake/project/RunCMakeTest.cmake | 8 +++- 28 files changed, 138 insertions(+), 50 deletions(-) create mode 100644 Help/release/dev/project-include-multiple.rst delete mode 100644 Tests/RunCMake/project/CodeInjection-stdout.txt delete mode 100644 Tests/RunCMake/project/CodeInjection.cmake delete mode 100644 Tests/RunCMake/project/CodeInjection/cmake_project_include.cmake delete mode 100644 Tests/RunCMake/project/CodeInjection/cmake_project_include_before.cmake create mode 100644 Tests/RunCMake/project/CodeInjection/cmake_project_includes_1.cmake create mode 100644 Tests/RunCMake/project/CodeInjection/cmake_project_includes_2.cmake create mode 100644 Tests/RunCMake/project/CodeInjection/cmake_project_includes_before_1.cmake create mode 100644 Tests/RunCMake/project/CodeInjection/cmake_project_includes_before_2.cmake delete mode 100644 Tests/RunCMake/project/CodeInjection/cmake_project_subproj_include.cmake delete mode 100644 Tests/RunCMake/project/CodeInjection/cmake_project_subproj_include_before.cmake create mode 100644 Tests/RunCMake/project/CodeInjection/cmake_project_subproj_includes_1.cmake create mode 100644 Tests/RunCMake/project/CodeInjection/cmake_project_subproj_includes_2.cmake create mode 100644 Tests/RunCMake/project/CodeInjection/cmake_project_subproj_includes_before_1.cmake create mode 100644 Tests/RunCMake/project/CodeInjection/cmake_project_subproj_includes_before_2.cmake delete mode 100644 Tests/RunCMake/project/CodeInjection/initial_cache.cmake create mode 100644 Tests/RunCMake/project/CodeInjection/initial_cache_1.cmake create mode 100644 Tests/RunCMake/project/CodeInjection/initial_cache_2.cmake create mode 100644 Tests/RunCMake/project/CodeInjection1-stdout.txt create mode 100644 Tests/RunCMake/project/CodeInjection1.cmake create mode 100644 Tests/RunCMake/project/CodeInjection2-stdout.txt create mode 100644 Tests/RunCMake/project/CodeInjection2.cmake diff --git a/Help/release/dev/project-include-multiple.rst b/Help/release/dev/project-include-multiple.rst new file mode 100644 index 0000000..d4c3bb9 --- /dev/null +++ b/Help/release/dev/project-include-multiple.rst @@ -0,0 +1,9 @@ +project-include-multiple +------------------------ + +* The :variable:`CMAKE_PROJECT_INCLUDE`, + :variable:`CMAKE_PROJECT_INCLUDE_BEFORE`, + :variable:`CMAKE_PROJECT__INCLUDE`, and + :variable:`CMAKE_PROJECT__INCLUDE_BEFORE` variables learned + to support a :ref:`semicolon-separated list ` of + CMake language files to be included sequentially. diff --git a/Help/variable/CMAKE_PROJECT_INCLUDE.rst b/Help/variable/CMAKE_PROJECT_INCLUDE.rst index 76b9d92..ab59ed7 100644 --- a/Help/variable/CMAKE_PROJECT_INCLUDE.rst +++ b/Help/variable/CMAKE_PROJECT_INCLUDE.rst @@ -3,12 +3,16 @@ CMAKE_PROJECT_INCLUDE .. versionadded:: 3.15 -A CMake language file or module to be included as the last step of all +A CMake language file to be included as the last step of all :command:`project` command calls. This is intended for injecting custom code into project builds without modifying their source. See :ref:`Code Injection` for a more detailed discussion of files potentially included during a :command:`project` call. +.. versionadded:: 3.29 + This variable can be a :ref:`semicolon-separated list ` + of CMake language files to be included sequentially. + See also the :variable:`CMAKE_PROJECT__INCLUDE`, :variable:`CMAKE_PROJECT__INCLUDE_BEFORE`, :variable:`CMAKE_PROJECT_INCLUDE_BEFORE`, and diff --git a/Help/variable/CMAKE_PROJECT_INCLUDE_BEFORE.rst b/Help/variable/CMAKE_PROJECT_INCLUDE_BEFORE.rst index 9a8c4b5..b5fbe6f 100644 --- a/Help/variable/CMAKE_PROJECT_INCLUDE_BEFORE.rst +++ b/Help/variable/CMAKE_PROJECT_INCLUDE_BEFORE.rst @@ -3,12 +3,16 @@ CMAKE_PROJECT_INCLUDE_BEFORE .. versionadded:: 3.15 -A CMake language file or module to be included as the first step of all +A CMake language file to be included as the first step of all :command:`project` command calls. This is intended for injecting custom code into project builds without modifying their source. See :ref:`Code Injection` for a more detailed discussion of files potentially included during a :command:`project` call. +.. versionadded:: 3.29 + This variable can be a :ref:`semicolon-separated list ` + of CMake language files to be included sequentially. + See also the :variable:`CMAKE_PROJECT__INCLUDE`, :variable:`CMAKE_PROJECT__INCLUDE_BEFORE`, :variable:`CMAKE_PROJECT_INCLUDE`, and diff --git a/Help/variable/CMAKE_PROJECT_PROJECT-NAME_INCLUDE.rst b/Help/variable/CMAKE_PROJECT_PROJECT-NAME_INCLUDE.rst index 3bb5cd8..5ea5234 100644 --- a/Help/variable/CMAKE_PROJECT_PROJECT-NAME_INCLUDE.rst +++ b/Help/variable/CMAKE_PROJECT_PROJECT-NAME_INCLUDE.rst @@ -1,12 +1,16 @@ CMAKE_PROJECT__INCLUDE ------------------------------------ -A CMake language file or module to be included as the last step of any +A CMake language file to be included as the last step of any :command:`project` command calls that specify ```` as the project name. This is intended for injecting custom code into project builds without modifying their source. See :ref:`Code Injection` for a more detailed discussion of files potentially included during a :command:`project` call. +.. versionadded:: 3.29 + This variable can be a :ref:`semicolon-separated list ` + of CMake language files to be included sequentially. + See also the :variable:`CMAKE_PROJECT__INCLUDE_BEFORE`, :variable:`CMAKE_PROJECT_INCLUDE`, :variable:`CMAKE_PROJECT_INCLUDE_BEFORE`, and :variable:`CMAKE_PROJECT_TOP_LEVEL_INCLUDES` variables. diff --git a/Help/variable/CMAKE_PROJECT_PROJECT-NAME_INCLUDE_BEFORE.rst b/Help/variable/CMAKE_PROJECT_PROJECT-NAME_INCLUDE_BEFORE.rst index ca584c1..0694823 100644 --- a/Help/variable/CMAKE_PROJECT_PROJECT-NAME_INCLUDE_BEFORE.rst +++ b/Help/variable/CMAKE_PROJECT_PROJECT-NAME_INCLUDE_BEFORE.rst @@ -3,12 +3,16 @@ CMAKE_PROJECT__INCLUDE_BEFORE .. versionadded:: 3.17 -A CMake language file or module to be included as the first step of any +A CMake language file to be included as the first step of any :command:`project` command calls that specify ```` as the project name. This is intended for injecting custom code into project builds without modifying their source. See :ref:`Code Injection` for a more detailed discussion of files potentially included during a :command:`project` call. +.. versionadded:: 3.29 + This variable can be a :ref:`semicolon-separated list ` + of CMake language files to be included sequentially. + See also the :variable:`CMAKE_PROJECT__INCLUDE`, :variable:`CMAKE_PROJECT_INCLUDE`, :variable:`CMAKE_PROJECT_INCLUDE_BEFORE`, and :variable:`CMAKE_PROJECT_TOP_LEVEL_INCLUDES` variables. diff --git a/Source/cmProjectCommand.cxx b/Source/cmProjectCommand.cxx index 3aef299..bb5f522 100644 --- a/Source/cmProjectCommand.cxx +++ b/Source/cmProjectCommand.cxx @@ -11,6 +11,7 @@ #include "cmsys/RegularExpression.hxx" #include "cmExecutionStatus.h" +#include "cmList.h" #include "cmMakefile.h" #include "cmMessageType.h" #include "cmPolicies.h" @@ -371,29 +372,41 @@ static bool IncludeByVariable(cmExecutionStatus& status, if (!include) { return true; } + cmList includeFiles{ *include }; + + bool failed = false; + for (auto const& filePath : includeFiles) { + std::string includeFile = cmSystemTools::CollapseFullPath( + filePath, mf.GetCurrentSourceDirectory()); + if (!cmSystemTools::FileExists(includeFile)) { + status.SetError( + cmStrCat("could not find requested file:\n ", filePath)); + failed = true; + continue; + } + if (cmSystemTools::FileIsDirectory(includeFile)) { + status.SetError( + cmStrCat("requested file is a directory:\n ", filePath)); + failed = true; + continue; + } - std::string includeFile = - cmSystemTools::CollapseFullPath(*include, mf.GetCurrentSourceDirectory()); - if (!cmSystemTools::FileExists(includeFile)) { - status.SetError(cmStrCat("could not find requested file:\n ", *include)); - return false; - } - if (cmSystemTools::FileIsDirectory(includeFile)) { - status.SetError(cmStrCat("requested file is a directory:\n ", *include)); - return false; - } + const bool readit = mf.ReadDependentFile(filePath); + if (readit) { + // If the included file ran successfully, continue to the next file + continue; + } - const bool readit = mf.ReadDependentFile(*include); - if (readit) { - return true; - } + if (cmSystemTools::GetFatalErrorOccurred()) { + failed = true; + continue; + } - if (cmSystemTools::GetFatalErrorOccurred()) { - return true; + status.SetError(cmStrCat("could not load requested file:\n ", filePath)); + failed = true; } - - status.SetError(cmStrCat("could not load requested file:\n ", *include)); - return false; + // At this point all files were processed + return !failed; } static void TopLevelCMakeVarCondSet(cmMakefile& mf, std::string const& name, diff --git a/Tests/RunCMake/project/CodeInjection-stdout.txt b/Tests/RunCMake/project/CodeInjection-stdout.txt deleted file mode 100644 index 88ac966..0000000 --- a/Tests/RunCMake/project/CodeInjection-stdout.txt +++ /dev/null @@ -1,10 +0,0 @@ -(-- )?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 deleted file mode 100644 index dcf56a1..0000000 --- a/Tests/RunCMake/project/CodeInjection.cmake +++ /dev/null @@ -1 +0,0 @@ -add_subdirectory(CodeInjection) diff --git a/Tests/RunCMake/project/CodeInjection/cmake_project_include.cmake b/Tests/RunCMake/project/CodeInjection/cmake_project_include.cmake deleted file mode 100644 index f3f0a7e..0000000 --- a/Tests/RunCMake/project/CodeInjection/cmake_project_include.cmake +++ /dev/null @@ -1 +0,0 @@ -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 deleted file mode 100644 index 01d53c9..0000000 --- a/Tests/RunCMake/project/CodeInjection/cmake_project_include_before.cmake +++ /dev/null @@ -1 +0,0 @@ -message(STATUS "Included CMAKE_PROJECT_INCLUDE_BEFORE") diff --git a/Tests/RunCMake/project/CodeInjection/cmake_project_includes_1.cmake b/Tests/RunCMake/project/CodeInjection/cmake_project_includes_1.cmake new file mode 100644 index 0000000..2bc65cf --- /dev/null +++ b/Tests/RunCMake/project/CodeInjection/cmake_project_includes_1.cmake @@ -0,0 +1 @@ +message(STATUS "Included CMAKE_PROJECT_INCLUDE first file") diff --git a/Tests/RunCMake/project/CodeInjection/cmake_project_includes_2.cmake b/Tests/RunCMake/project/CodeInjection/cmake_project_includes_2.cmake new file mode 100644 index 0000000..df7240c --- /dev/null +++ b/Tests/RunCMake/project/CodeInjection/cmake_project_includes_2.cmake @@ -0,0 +1 @@ +message(STATUS "Included CMAKE_PROJECT_INCLUDE second file") diff --git a/Tests/RunCMake/project/CodeInjection/cmake_project_includes_before_1.cmake b/Tests/RunCMake/project/CodeInjection/cmake_project_includes_before_1.cmake new file mode 100644 index 0000000..20bea78 --- /dev/null +++ b/Tests/RunCMake/project/CodeInjection/cmake_project_includes_before_1.cmake @@ -0,0 +1 @@ +message(STATUS "Included CMAKE_PROJECT_INCLUDE_BEFORE first file") diff --git a/Tests/RunCMake/project/CodeInjection/cmake_project_includes_before_2.cmake b/Tests/RunCMake/project/CodeInjection/cmake_project_includes_before_2.cmake new file mode 100644 index 0000000..91b59d1 --- /dev/null +++ b/Tests/RunCMake/project/CodeInjection/cmake_project_includes_before_2.cmake @@ -0,0 +1 @@ +message(STATUS "Included CMAKE_PROJECT_INCLUDE_BEFORE second file") diff --git a/Tests/RunCMake/project/CodeInjection/cmake_project_subproj_include.cmake b/Tests/RunCMake/project/CodeInjection/cmake_project_subproj_include.cmake deleted file mode 100644 index d68de6a..0000000 --- a/Tests/RunCMake/project/CodeInjection/cmake_project_subproj_include.cmake +++ /dev/null @@ -1 +0,0 @@ -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 deleted file mode 100644 index ef3bfc0..0000000 --- a/Tests/RunCMake/project/CodeInjection/cmake_project_subproj_include_before.cmake +++ /dev/null @@ -1 +0,0 @@ -message(STATUS "Included CMAKE_PROJECT_SubProj_INCLUDE_BEFORE") diff --git a/Tests/RunCMake/project/CodeInjection/cmake_project_subproj_includes_1.cmake b/Tests/RunCMake/project/CodeInjection/cmake_project_subproj_includes_1.cmake new file mode 100644 index 0000000..fe0fe4a --- /dev/null +++ b/Tests/RunCMake/project/CodeInjection/cmake_project_subproj_includes_1.cmake @@ -0,0 +1 @@ +message(STATUS "Included CMAKE_PROJECT_SubProj_INCLUDE first file") diff --git a/Tests/RunCMake/project/CodeInjection/cmake_project_subproj_includes_2.cmake b/Tests/RunCMake/project/CodeInjection/cmake_project_subproj_includes_2.cmake new file mode 100644 index 0000000..c36fb52 --- /dev/null +++ b/Tests/RunCMake/project/CodeInjection/cmake_project_subproj_includes_2.cmake @@ -0,0 +1 @@ +message(STATUS "Included CMAKE_PROJECT_SubProj_INCLUDE second file") diff --git a/Tests/RunCMake/project/CodeInjection/cmake_project_subproj_includes_before_1.cmake b/Tests/RunCMake/project/CodeInjection/cmake_project_subproj_includes_before_1.cmake new file mode 100644 index 0000000..23ae05a --- /dev/null +++ b/Tests/RunCMake/project/CodeInjection/cmake_project_subproj_includes_before_1.cmake @@ -0,0 +1 @@ +message(STATUS "Included CMAKE_PROJECT_SubProj_INCLUDE_BEFORE first file") diff --git a/Tests/RunCMake/project/CodeInjection/cmake_project_subproj_includes_before_2.cmake b/Tests/RunCMake/project/CodeInjection/cmake_project_subproj_includes_before_2.cmake new file mode 100644 index 0000000..17f1d29 --- /dev/null +++ b/Tests/RunCMake/project/CodeInjection/cmake_project_subproj_includes_before_2.cmake @@ -0,0 +1 @@ +message(STATUS "Included CMAKE_PROJECT_SubProj_INCLUDE_BEFORE second file") diff --git a/Tests/RunCMake/project/CodeInjection/initial_cache.cmake b/Tests/RunCMake/project/CodeInjection/initial_cache.cmake deleted file mode 100644 index 6c8995b..0000000 --- a/Tests/RunCMake/project/CodeInjection/initial_cache.cmake +++ /dev/null @@ -1,10 +0,0 @@ -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/initial_cache_1.cmake b/Tests/RunCMake/project/CodeInjection/initial_cache_1.cmake new file mode 100644 index 0000000..43bb817 --- /dev/null +++ b/Tests/RunCMake/project/CodeInjection/initial_cache_1.cmake @@ -0,0 +1,9 @@ +set(CMAKE_TOOLCHAIN_FILE "${CMAKE_CURRENT_LIST_DIR}/passthrough_toolchain_file.cmake" CACHE FILEPATH "") +set(CMAKE_PROJECT_INCLUDE "${CMAKE_CURRENT_LIST_DIR}/cmake_project_includes_1.cmake" CACHE FILEPATH "") +set(CMAKE_PROJECT_INCLUDE_BEFORE "${CMAKE_CURRENT_LIST_DIR}/cmake_project_includes_before_1.cmake" CACHE FILEPATH "") +set(CMAKE_PROJECT_SubProj_INCLUDE "${CMAKE_CURRENT_LIST_DIR}/cmake_project_subproj_includes_1.cmake" CACHE FILEPATH "") +set(CMAKE_PROJECT_SubProj_INCLUDE_BEFORE "${CMAKE_CURRENT_LIST_DIR}/cmake_project_subproj_includes_before_1.cmake" CACHE FILEPATH "") +set(CMAKE_PROJECT_TOP_LEVEL_INCLUDES + "${CMAKE_CURRENT_LIST_DIR}/cmake_project_top_level_includes_1.cmake" + CACHE FILEPATH "" +) diff --git a/Tests/RunCMake/project/CodeInjection/initial_cache_2.cmake b/Tests/RunCMake/project/CodeInjection/initial_cache_2.cmake new file mode 100644 index 0000000..09fcbfd --- /dev/null +++ b/Tests/RunCMake/project/CodeInjection/initial_cache_2.cmake @@ -0,0 +1,27 @@ +set(CMAKE_TOOLCHAIN_FILE + "${CMAKE_CURRENT_LIST_DIR}/passthrough_toolchain_file.cmake" CACHE FILEPATH "") +set(CMAKE_PROJECT_INCLUDE + "${CMAKE_CURRENT_LIST_DIR}/cmake_project_includes_1.cmake" + "${CMAKE_CURRENT_LIST_DIR}/cmake_project_includes_2.cmake" + CACHE STRING "" +) +set(CMAKE_PROJECT_INCLUDE_BEFORE + "${CMAKE_CURRENT_LIST_DIR}/cmake_project_includes_before_1.cmake" + "${CMAKE_CURRENT_LIST_DIR}/cmake_project_includes_before_2.cmake" + CACHE STRING "" +) +set(CMAKE_PROJECT_SubProj_INCLUDE + "${CMAKE_CURRENT_LIST_DIR}/cmake_project_subproj_includes_1.cmake" + "${CMAKE_CURRENT_LIST_DIR}/cmake_project_subproj_includes_2.cmake" + CACHE STRING "" +) +set(CMAKE_PROJECT_SubProj_INCLUDE_BEFORE + "${CMAKE_CURRENT_LIST_DIR}/cmake_project_subproj_includes_before_1.cmake" + "${CMAKE_CURRENT_LIST_DIR}/cmake_project_subproj_includes_before_2.cmake" + CACHE STRING "" +) +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/CodeInjection1-stdout.txt b/Tests/RunCMake/project/CodeInjection1-stdout.txt new file mode 100644 index 0000000..7a780b7 --- /dev/null +++ b/Tests/RunCMake/project/CodeInjection1-stdout.txt @@ -0,0 +1,9 @@ +(-- )?Included CMAKE_PROJECT_INCLUDE_BEFORE first file +(-- )?Included CMAKE_TOOLCHAIN_FILE +.*Included CMAKE_PROJECT_TOP_LEVEL_INCLUDES first file +(-- )?Included CMAKE_PROJECT_INCLUDE first file +(-- )?Calling sub-project +(-- )?Included CMAKE_PROJECT_INCLUDE_BEFORE first file +(-- )?Included CMAKE_PROJECT_SubProj_INCLUDE_BEFORE first file +(-- )?Included CMAKE_PROJECT_INCLUDE first file +(-- )?Included CMAKE_PROJECT_SubProj_INCLUDE first file diff --git a/Tests/RunCMake/project/CodeInjection1.cmake b/Tests/RunCMake/project/CodeInjection1.cmake new file mode 100644 index 0000000..dcf56a1 --- /dev/null +++ b/Tests/RunCMake/project/CodeInjection1.cmake @@ -0,0 +1 @@ +add_subdirectory(CodeInjection) diff --git a/Tests/RunCMake/project/CodeInjection2-stdout.txt b/Tests/RunCMake/project/CodeInjection2-stdout.txt new file mode 100644 index 0000000..5c18cdf --- /dev/null +++ b/Tests/RunCMake/project/CodeInjection2-stdout.txt @@ -0,0 +1,16 @@ +(-- )?Included CMAKE_PROJECT_INCLUDE_BEFORE first file +(-- )?Included CMAKE_PROJECT_INCLUDE_BEFORE second file +(-- )?Included CMAKE_TOOLCHAIN_FILE +.*Included CMAKE_PROJECT_TOP_LEVEL_INCLUDES first file +(-- )?Included CMAKE_PROJECT_TOP_LEVEL_INCLUDES second file +(-- )?Included CMAKE_PROJECT_INCLUDE first file +(-- )?Included CMAKE_PROJECT_INCLUDE second file +(-- )?Calling sub-project +(-- )?Included CMAKE_PROJECT_INCLUDE_BEFORE first file +(-- )?Included CMAKE_PROJECT_INCLUDE_BEFORE second file +(-- )?Included CMAKE_PROJECT_SubProj_INCLUDE_BEFORE first file +(-- )?Included CMAKE_PROJECT_SubProj_INCLUDE_BEFORE second file +(-- )?Included CMAKE_PROJECT_INCLUDE first file +(-- )?Included CMAKE_PROJECT_INCLUDE second file +(-- )?Included CMAKE_PROJECT_SubProj_INCLUDE first file +(-- )?Included CMAKE_PROJECT_SubProj_INCLUDE second file diff --git a/Tests/RunCMake/project/CodeInjection2.cmake b/Tests/RunCMake/project/CodeInjection2.cmake new file mode 100644 index 0000000..dcf56a1 --- /dev/null +++ b/Tests/RunCMake/project/CodeInjection2.cmake @@ -0,0 +1 @@ +add_subdirectory(CodeInjection) diff --git a/Tests/RunCMake/project/RunCMakeTest.cmake b/Tests/RunCMake/project/RunCMakeTest.cmake index 0f3716f..4ec1d48 100644 --- a/Tests/RunCMake/project/RunCMakeTest.cmake +++ b/Tests/RunCMake/project/RunCMakeTest.cmake @@ -5,8 +5,12 @@ include(RunCMake) # 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" +run_cmake_with_options(CodeInjection1 + -C "${CMAKE_CURRENT_LIST_DIR}/CodeInjection/initial_cache_1.cmake" +) +# This checks that List variables are allowed. +run_cmake_with_options(CodeInjection2 + -C "${CMAKE_CURRENT_LIST_DIR}/CodeInjection/initial_cache_2.cmake" ) if(CMake_TEST_RESOURCES) -- cgit v0.12