summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorBrad King <brad.king@kitware.com>2021-01-25 20:12:17 (GMT)
committerBrad King <brad.king@kitware.com>2021-01-25 20:22:53 (GMT)
commitccbedb80e42e799209f2536ec2fdbecf1b108483 (patch)
tree6f580e911f24facd9eb678b9a8913874e05969cb
parent6fdbe9201ffa17af0d75db5f6ba33854044a56ee (diff)
downloadCMake-ccbedb80e42e799209f2536ec2fdbecf1b108483.zip
CMake-ccbedb80e42e799209f2536ec2fdbecf1b108483.tar.gz
CMake-ccbedb80e42e799209f2536ec2fdbecf1b108483.tar.bz2
Ninja Multi-Config: Restore rebuild_cache and edit_cache targets
Since commit dcf9f4d2f7 (Ninja Multi-Config: Add support for cross-config custom commands, 2020-12-09) we were not generating these targets. Restore them and add a test. Fixes: #21722
-rw-r--r--Source/cmNinjaUtilityTargetGenerator.cxx5
-rw-r--r--Tests/RunCMake/NinjaMultiConfig/RunCMakeTest.cmake3
-rw-r--r--Tests/RunCMake/NinjaMultiConfig/Simple-targets-debug-ninja-stdout.txt3
-rw-r--r--Tests/RunCMake/NinjaMultiConfig/Simple-targets-default-ninja-stdout.txt3
-rw-r--r--Tests/RunCMake/NinjaMultiConfig/Simple-targets-release-ninja-stdout.txt3
5 files changed, 17 insertions, 0 deletions
diff --git a/Source/cmNinjaUtilityTargetGenerator.cxx b/Source/cmNinjaUtilityTargetGenerator.cxx
index e3a9c02..a18ca20 100644
--- a/Source/cmNinjaUtilityTargetGenerator.cxx
+++ b/Source/cmNinjaUtilityTargetGenerator.cxx
@@ -35,6 +35,11 @@ cmNinjaUtilityTargetGenerator::~cmNinjaUtilityTargetGenerator() = default;
void cmNinjaUtilityTargetGenerator::Generate(const std::string& config)
{
+ if (!this->GetGeneratorTarget()->Target->IsPerConfig()) {
+ this->WriteUtilBuildStatements(config, config);
+ return;
+ }
+
for (auto const& fileConfig : this->GetConfigNames()) {
if (!this->GetGlobalGenerator()
->GetCrossConfigs(fileConfig)
diff --git a/Tests/RunCMake/NinjaMultiConfig/RunCMakeTest.cmake b/Tests/RunCMake/NinjaMultiConfig/RunCMakeTest.cmake
index 480d628..21c2658 100644
--- a/Tests/RunCMake/NinjaMultiConfig/RunCMakeTest.cmake
+++ b/Tests/RunCMake/NinjaMultiConfig/RunCMakeTest.cmake
@@ -85,6 +85,9 @@ set(RunCMake_TEST_OPTIONS "-DCMAKE_CONFIGURATION_TYPES=RelWithDebInfo\\;Debug\\;
run_cmake_configure(Simple)
unset(RunCMake_TEST_OPTIONS)
include(${RunCMake_TEST_BINARY_DIR}/target_files.cmake)
+run_ninja(Simple targets-default build.ninja -t targets)
+run_ninja(Simple targets-debug build-Debug.ninja -t targets)
+run_ninja(Simple targets-release build-Debug.ninja -t targets)
run_cmake_build(Simple debug-target Debug simpleexe)
run_ninja(Simple debug-target build-Debug.ninja simplestatic)
get_filename_component(simpleshared_Release "${TARGET_FILE_simpleshared_Release}" NAME)
diff --git a/Tests/RunCMake/NinjaMultiConfig/Simple-targets-debug-ninja-stdout.txt b/Tests/RunCMake/NinjaMultiConfig/Simple-targets-debug-ninja-stdout.txt
new file mode 100644
index 0000000..f72516f
--- /dev/null
+++ b/Tests/RunCMake/NinjaMultiConfig/Simple-targets-debug-ninja-stdout.txt
@@ -0,0 +1,3 @@
+(rebuild_cache: phony.*
+edit_cache: phony|edit_cache: phony.*
+rebuild_cache: phony)
diff --git a/Tests/RunCMake/NinjaMultiConfig/Simple-targets-default-ninja-stdout.txt b/Tests/RunCMake/NinjaMultiConfig/Simple-targets-default-ninja-stdout.txt
new file mode 100644
index 0000000..f72516f
--- /dev/null
+++ b/Tests/RunCMake/NinjaMultiConfig/Simple-targets-default-ninja-stdout.txt
@@ -0,0 +1,3 @@
+(rebuild_cache: phony.*
+edit_cache: phony|edit_cache: phony.*
+rebuild_cache: phony)
diff --git a/Tests/RunCMake/NinjaMultiConfig/Simple-targets-release-ninja-stdout.txt b/Tests/RunCMake/NinjaMultiConfig/Simple-targets-release-ninja-stdout.txt
new file mode 100644
index 0000000..f72516f
--- /dev/null
+++ b/Tests/RunCMake/NinjaMultiConfig/Simple-targets-release-ninja-stdout.txt
@@ -0,0 +1,3 @@
+(rebuild_cache: phony.*
+edit_cache: phony|edit_cache: phony.*
+rebuild_cache: phony)