summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorKyle Edwards <kyle.edwards@kitware.com>2020-02-11 15:49:54 (GMT)
committerKyle Edwards <kyle.edwards@kitware.com>2020-02-11 15:49:54 (GMT)
commit46c836644d2566e2a568318e5676eaa08f65501e (patch)
tree1d9793be36aa666cda329558d8ea629c84753f83
parent0db0b721564a584ff1783ac2cf14db6fd867d6b2 (diff)
downloadCMake-46c836644d2566e2a568318e5676eaa08f65501e.zip
CMake-46c836644d2566e2a568318e5676eaa08f65501e.tar.gz
CMake-46c836644d2566e2a568318e5676eaa08f65501e.tar.bz2
Ninja Multi-Config: Fix issue with "all" in CMAKE_NMC_DEFAULT_CONFIGS
Prior to this fix, CMAKE_NMC_DEFAULT_CONFIGS would inherit "all" from the union of CMAKE_NMC_DEFAULT_BUILD_FILE_CONFIG and CMAKE_NMC_CROSS_CONFIGS. This is inconsistent with the behavior of the "all" target signifying CMAKE_NMC_CROSS_CONFIGS. Update "all" in CMAKE_NMC_DEFAULT_CONFIGS to inherit only from CMAKE_NMC_CROSS_CONFIGS.
-rw-r--r--Source/cmGlobalNinjaGenerator.cxx12
-rw-r--r--Source/cmGlobalNinjaGenerator.h2
-rw-r--r--Tests/RunCMake/NinjaMultiConfig/RunCMakeTest.cmake7
-rw-r--r--Tests/RunCMake/NinjaMultiConfig/SimpleDefaultBuildAliasListCross-target-configs-ninja-check.cmake37
-rw-r--r--Tests/RunCMake/NinjaMultiConfig/SimpleDefaultBuildAliasListCross.cmake1
5 files changed, 53 insertions, 6 deletions
diff --git a/Source/cmGlobalNinjaGenerator.cxx b/Source/cmGlobalNinjaGenerator.cxx
index 55efff2..35421b6 100644
--- a/Source/cmGlobalNinjaGenerator.cxx
+++ b/Source/cmGlobalNinjaGenerator.cxx
@@ -890,7 +890,8 @@ bool cmGlobalNinjaGenerator::OpenFileStream(
}
cm::optional<std::set<std::string>> cmGlobalNinjaGenerator::ListSubsetWithAll(
- const std::set<std::string>& defaults, const std::vector<std::string>& items)
+ const std::set<std::string>& all, const std::set<std::string>& defaults,
+ const std::vector<std::string>& items)
{
std::set<std::string> result;
@@ -901,7 +902,7 @@ cm::optional<std::set<std::string>> cmGlobalNinjaGenerator::ListSubsetWithAll(
} else {
return cm::nullopt;
}
- } else if (defaults.count(item)) {
+ } else if (all.count(item)) {
result.insert(item);
} else {
return cm::nullopt;
@@ -2640,7 +2641,7 @@ bool cmGlobalNinjaMultiGenerator::ReadCacheEntriesForBuild(
std::vector<std::string> crossConfigsVec;
cmExpandList(state.GetSafeCacheEntryValue("CMAKE_NMC_CROSS_CONFIGS"),
crossConfigsVec);
- auto crossConfigs = ListSubsetWithAll(configs, crossConfigsVec);
+ auto crossConfigs = ListSubsetWithAll(configs, configs, crossConfigsVec);
if (!crossConfigs) {
std::ostringstream msg;
msg << "CMAKE_NMC_CROSS_CONFIGS is not a subset of "
@@ -2671,8 +2672,9 @@ bool cmGlobalNinjaMultiGenerator::ReadCacheEntriesForBuild(
std::vector<std::string> defaultConfigsVec;
cmExpandList(defaultConfigsString, defaultConfigsVec);
if (!this->DefaultFileConfig.empty()) {
- auto defaultConfigs = ListSubsetWithAll(
- this->GetCrossConfigs(this->DefaultFileConfig), defaultConfigsVec);
+ auto defaultConfigs =
+ ListSubsetWithAll(this->GetCrossConfigs(this->DefaultFileConfig),
+ this->CrossConfigs, defaultConfigsVec);
if (!defaultConfigs) {
std::ostringstream msg;
msg << "CMAKE_NMC_DEFAULT_CONFIGS is not a subset of "
diff --git a/Source/cmGlobalNinjaGenerator.h b/Source/cmGlobalNinjaGenerator.h
index a59859e..3db8356 100644
--- a/Source/cmGlobalNinjaGenerator.h
+++ b/Source/cmGlobalNinjaGenerator.h
@@ -427,7 +427,7 @@ protected:
const std::string& name);
static cm::optional<std::set<std::string>> ListSubsetWithAll(
- const std::set<std::string>& defaults,
+ const std::set<std::string>& all, const std::set<std::string>& defaults,
const std::vector<std::string>& items);
virtual bool InspectConfigTypeVariables() { return true; }
diff --git a/Tests/RunCMake/NinjaMultiConfig/RunCMakeTest.cmake b/Tests/RunCMake/NinjaMultiConfig/RunCMakeTest.cmake
index 3626a29..9058b11 100644
--- a/Tests/RunCMake/NinjaMultiConfig/RunCMakeTest.cmake
+++ b/Tests/RunCMake/NinjaMultiConfig/RunCMakeTest.cmake
@@ -132,6 +132,13 @@ run_cmake_build(SimpleDefaultBuildAliasList all-configs "" all)
run_ninja(SimpleDefaultBuildAliasList all-relwithdebinfo build.ninja all:RelWithDebInfo)
run_ninja(SimpleDefaultBuildAliasList clean-configs build.ninja clean)
+set(RunCMake_TEST_BINARY_DIR ${RunCMake_BINARY_DIR}/SimpleDefaultBuildAliasListCross-build)
+set(RunCMake_TEST_OPTIONS "-DCMAKE_NMC_DEFAULT_BUILD_FILE_CONFIG=RelWithDebInfo;-DCMAKE_NMC_DEFAULT_CONFIGS=all;-DCMAKE_NMC_CROSS_CONFIGS=Debug\\;Release")
+run_cmake_configure(SimpleDefaultBuildAliasListCross)
+unset(RunCMake_TEST_OPTIONS)
+include(${RunCMake_TEST_BINARY_DIR}/target_files.cmake)
+run_ninja(SimpleDefaultBuildAliasListCross target-configs build.ninja simpleexe)
+
unset(RunCMake_TEST_BINARY_DIR)
set(RunCMake_TEST_OPTIONS "-DCMAKE_CONFIGURATION_TYPES=Debug\\;Release;-DCMAKE_NMC_CROSS_CONFIGS=Debug\\;Release\\;RelWithDebInfo")
diff --git a/Tests/RunCMake/NinjaMultiConfig/SimpleDefaultBuildAliasListCross-target-configs-ninja-check.cmake b/Tests/RunCMake/NinjaMultiConfig/SimpleDefaultBuildAliasListCross-target-configs-ninja-check.cmake
new file mode 100644
index 0000000..b6c77ab
--- /dev/null
+++ b/Tests/RunCMake/NinjaMultiConfig/SimpleDefaultBuildAliasListCross-target-configs-ninja-check.cmake
@@ -0,0 +1,37 @@
+check_files("${RunCMake_TEST_BINARY_DIR}"
+ INCLUDE
+ ${GENERATED_FILES}
+
+ ${TARGET_FILE_simpleexe_Debug}
+ ${TARGET_OBJECT_FILES_simpleexe_Debug}
+
+ ${TARGET_FILE_simpleshared_Debug}
+ ${TARGET_LINKER_FILE_simpleshared_Debug}
+ ${TARGET_OBJECT_FILES_simpleshared_Debug}
+
+ ${TARGET_OBJECT_FILES_simpleobj_Debug}
+
+ ${TARGET_FILE_simpleexe_Release}
+ ${TARGET_OBJECT_FILES_simpleexe_Release}
+
+ ${TARGET_FILE_simpleshared_Release}
+ ${TARGET_LINKER_FILE_simpleshared_Release}
+ ${TARGET_OBJECT_FILES_simpleshared_Release}
+
+ ${TARGET_OBJECT_FILES_simpleobj_Release}
+
+ EXCLUDE
+ ${TARGET_OBJECT_FILES_simplestatic_Debug}
+
+ ${TARGET_OBJECT_FILES_simplestatic_Release}
+
+ ${TARGET_OBJECT_FILES_simpleexe_MinSizeRel}
+ ${TARGET_OBJECT_FILES_simpleshared_MinSizeRel}
+ ${TARGET_OBJECT_FILES_simplestatic_MinSizeRel}
+ ${TARGET_OBJECT_FILES_simpleobj_MinSizeRel}
+
+ ${TARGET_OBJECT_FILES_simpleexe_RelWithDebInfo}
+ ${TARGET_OBJECT_FILES_simpleshared_RelWithDebInfo}
+ ${TARGET_OBJECT_FILES_simplestatic_RelWithDebInfo}
+ ${TARGET_OBJECT_FILES_simpleobj_RelWithDebInfo}
+ )
diff --git a/Tests/RunCMake/NinjaMultiConfig/SimpleDefaultBuildAliasListCross.cmake b/Tests/RunCMake/NinjaMultiConfig/SimpleDefaultBuildAliasListCross.cmake
new file mode 100644
index 0000000..2a5b708
--- /dev/null
+++ b/Tests/RunCMake/NinjaMultiConfig/SimpleDefaultBuildAliasListCross.cmake
@@ -0,0 +1 @@
+include("${CMAKE_CURRENT_SOURCE_DIR}/Simple.cmake")