summaryrefslogtreecommitdiffstats
path: root/Source
diff options
context:
space:
mode:
authorKyle Edwards <kyle.edwards@kitware.com>2020-02-04 19:12:01 (GMT)
committerKyle Edwards <kyle.edwards@kitware.com>2020-02-04 19:13:07 (GMT)
commit2ac835b9f9a7a4dec16c498a51c0dbc3d64844bc (patch)
tree9b52bf9b0a2ba5a32b87579fe184dadea3443318 /Source
parent28013c9434b748c5009061844f19b29f0d482c9e (diff)
downloadCMake-2ac835b9f9a7a4dec16c498a51c0dbc3d64844bc.zip
CMake-2ac835b9f9a7a4dec16c498a51c0dbc3d64844bc.tar.gz
CMake-2ac835b9f9a7a4dec16c498a51c0dbc3d64844bc.tar.bz2
Refactor: Allow generators to decide default configuration for build
And allow them to read any cache values they need.
Diffstat (limited to 'Source')
-rw-r--r--Source/cmGlobalGenerator.cxx8
-rw-r--r--Source/cmGlobalGenerator.h10
-rw-r--r--Source/cmake.cxx4
-rw-r--r--Source/cmakemain.cxx2
4 files changed, 21 insertions, 3 deletions
diff --git a/Source/cmGlobalGenerator.cxx b/Source/cmGlobalGenerator.cxx
index 1f084f5..7ddeb99 100644
--- a/Source/cmGlobalGenerator.cxx
+++ b/Source/cmGlobalGenerator.cxx
@@ -1878,6 +1878,10 @@ int cmGlobalGenerator::Build(
output += "\n";
return 1;
}
+ std::string realConfig = config;
+ if (realConfig.empty()) {
+ realConfig = this->GetDefaultBuildConfig();
+ }
int retVal = 0;
cmSystemTools::SetRunCommandHideConsole(true);
@@ -1886,7 +1890,7 @@ int cmGlobalGenerator::Build(
std::vector<GeneratedMakeCommand> makeCommand =
this->GenerateBuildCommand(makeCommandCSTR, projectName, bindir, targets,
- config, fast, jobs, verbose, nativeOptions);
+ realConfig, fast, jobs, verbose, nativeOptions);
// Workaround to convince some commands to produce output.
if (outputflag == cmSystemTools::OUTPUT_PASSTHROUGH &&
@@ -1898,7 +1902,7 @@ int cmGlobalGenerator::Build(
if (clean) {
std::vector<GeneratedMakeCommand> cleanCommand =
this->GenerateBuildCommand(makeCommandCSTR, projectName, bindir,
- { "clean" }, config, fast, jobs, verbose);
+ { "clean" }, realConfig, fast, jobs, verbose);
output += "\nRun Clean Command:";
output += cleanCommand.front().Printable();
output += "\n";
diff --git a/Source/cmGlobalGenerator.h b/Source/cmGlobalGenerator.h
index f6ed10f..e6ab1dd 100644
--- a/Source/cmGlobalGenerator.h
+++ b/Source/cmGlobalGenerator.h
@@ -44,6 +44,7 @@ class cmLocalGenerator;
class cmMakefile;
class cmOutputConverter;
class cmSourceFile;
+class cmState;
class cmStateDirectory;
class cmake;
@@ -135,6 +136,12 @@ public:
virtual bool SetGeneratorToolset(std::string const& ts, bool build,
cmMakefile* mf);
+ /** Read any other cache entries needed for cmake --build. */
+ virtual bool ReadCacheEntriesForBuild(const cmState& /*state*/)
+ {
+ return true;
+ }
+
/**
* Create LocalGenerators and process the CMakeLists files. This does not
* actually produce any makefiles, DSPs, etc.
@@ -382,6 +389,9 @@ public:
// Lookup edit_cache target command preferred by this generator.
virtual std::string GetEditCacheCommand() const { return ""; }
+ // Default config to use for cmake --build
+ virtual std::string GetDefaultBuildConfig() const { return "Debug"; }
+
// Class to track a set of dependencies.
using TargetDependSet = cmTargetDependSet;
diff --git a/Source/cmake.cxx b/Source/cmake.cxx
index 5fa40d5..f4b9f16 100644
--- a/Source/cmake.cxx
+++ b/Source/cmake.cxx
@@ -2767,6 +2767,10 @@ int cmake::Build(int jobs, const std::string& dir,
}
#endif
+ if (!this->GlobalGenerator->ReadCacheEntriesForBuild(*this->State)) {
+ return 1;
+ }
+
this->GlobalGenerator->PrintBuildCommandAdvice(std::cerr, jobs);
return this->GlobalGenerator->Build(
jobs, "", dir, projName, targets, output, "", config, clean, false,
diff --git a/Source/cmakemain.cxx b/Source/cmakemain.cxx
index 5579ae1..494d5d9 100644
--- a/Source/cmakemain.cxx
+++ b/Source/cmakemain.cxx
@@ -350,7 +350,7 @@ int do_build(int ac, char const* const* av)
#else
int jobs = cmake::NO_BUILD_PARALLEL_LEVEL;
std::vector<std::string> targets;
- std::string config = "Debug";
+ std::string config;
std::string dir;
std::vector<std::string> nativeOptions;
bool cleanFirst = false;