summaryrefslogtreecommitdiffstats
path: root/Source
diff options
context:
space:
mode:
authorBrad King <brad.king@kitware.com>2021-10-21 13:21:12 (GMT)
committerKitware Robot <kwrobot@kitware.com>2021-10-21 13:21:24 (GMT)
commitfcab9785c91e1ac5f97eda63fef57c6683bcfb6b (patch)
tree38cf38ae5158ec8159d48cfd4857043caa9e1067 /Source
parent52144401b904ab6f66376f7bae74aa307d975f21 (diff)
parent46e9ff57298b58b3a4669adcb913429b691ce5bb (diff)
downloadCMake-fcab9785c91e1ac5f97eda63fef57c6683bcfb6b.zip
CMake-fcab9785c91e1ac5f97eda63fef57c6683bcfb6b.tar.gz
CMake-fcab9785c91e1ac5f97eda63fef57c6683bcfb6b.tar.bz2
Merge topic 'vs-instance'
46e9ff5729 Restore honoring CMAKE_GENERATOR_INSTANCE in toolchain file 42418b02f7 Android: Refactor sysroot detection under Visual Studio 44a86d0b38 cmake_host_system_information: Add undocumented VS_MSBUILD_COMMAND key 6999b87133 cmGlobalVisualStudio10Generator: Add method to find MSBuild early 7f730464be cmGlobalGenerator: Add method to check if generator is at least VS 10 8917b8512f cmGlobalVisualStudioVersionedGenerator: Allow repeating SetGeneratorInstance 6511654164 cmGlobalVisualStudio10Generator: Allow subclasses to reset MSBuild search Acked-by: Kitware Robot <kwrobot@kitware.com> Tested-by: buildbot <buildbot@kitware.com> Merge-request: !6646
Diffstat (limited to 'Source')
-rw-r--r--Source/cmCMakeHostSystemInformationCommand.cxx7
-rw-r--r--Source/cmGlobalGenerator.cxx13
-rw-r--r--Source/cmGlobalGenerator.h13
-rw-r--r--Source/cmGlobalVisualStudio10Generator.cxx7
-rw-r--r--Source/cmGlobalVisualStudio10Generator.h6
-rw-r--r--Source/cmGlobalVisualStudioGenerator.h5
-rw-r--r--Source/cmGlobalVisualStudioVersionedGenerator.cxx17
-rw-r--r--Source/cmGlobalVisualStudioVersionedGenerator.h5
-rw-r--r--Source/cmGlobalXCodeGenerator.h5
9 files changed, 43 insertions, 35 deletions
diff --git a/Source/cmCMakeHostSystemInformationCommand.cxx b/Source/cmCMakeHostSystemInformationCommand.cxx
index 74071ff..3922c56 100644
--- a/Source/cmCMakeHostSystemInformationCommand.cxx
+++ b/Source/cmCMakeHostSystemInformationCommand.cxx
@@ -27,6 +27,7 @@
#ifdef _WIN32
# include "cmAlgorithms.h"
# include "cmGlobalGenerator.h"
+# include "cmGlobalVisualStudio10Generator.h"
# include "cmGlobalVisualStudioVersionedGenerator.h"
# include "cmVSSetupHelper.h"
# define HAVE_VS_SETUP_HELPER
@@ -434,6 +435,12 @@ cm::optional<std::string> GetValue(cmExecutionStatus& status,
}
}
+ if (key == "VS_MSBUILD_COMMAND"_s && gg->IsVisualStudioAtLeast10()) {
+ cmGlobalVisualStudio10Generator* vs10gen =
+ static_cast<cmGlobalVisualStudio10Generator*>(gg);
+ return vs10gen->FindMSBuildCommandEarly(&status.GetMakefile());
+ }
+
return {};
}
#endif
diff --git a/Source/cmGlobalGenerator.cxx b/Source/cmGlobalGenerator.cxx
index 6dabf637..ac283ab 100644
--- a/Source/cmGlobalGenerator.cxx
+++ b/Source/cmGlobalGenerator.cxx
@@ -593,16 +593,6 @@ void cmGlobalGenerator::EnableLanguage(
}
}
- if (readCMakeSystem) {
- // Find the native build tool for this generator.
- // This has to be done early so that MSBuild can be used to examine the
- // cross-compilation environment.
- if (this->GetFindMakeProgramStage() == FindMakeProgramStage::Early &&
- !this->FindMakeProgram(mf)) {
- return;
- }
- }
-
// Load the CMakeDetermineSystem.cmake file and find out
// what platform we are running on
if (!mf->GetDefinition("CMAKE_SYSTEM")) {
@@ -676,8 +666,7 @@ void cmGlobalGenerator::EnableLanguage(
}
// Find the native build tool for this generator.
- if (this->GetFindMakeProgramStage() == FindMakeProgramStage::Late &&
- !this->FindMakeProgram(mf)) {
+ if (!this->FindMakeProgram(mf)) {
return;
}
}
diff --git a/Source/cmGlobalGenerator.h b/Source/cmGlobalGenerator.h
index 23c5700..cc0ad29 100644
--- a/Source/cmGlobalGenerator.h
+++ b/Source/cmGlobalGenerator.h
@@ -444,6 +444,8 @@ public:
virtual bool IsVisualStudio() const { return false; }
+ virtual bool IsVisualStudioAtLeast10() const { return false; }
+
virtual bool IsNinja() const { return false; }
/** Return true if we know the exact location of object files.
@@ -623,17 +625,6 @@ protected:
std::string GetPredefinedTargetsFolder() const;
- enum class FindMakeProgramStage
- {
- Early,
- Late,
- };
-
- virtual FindMakeProgramStage GetFindMakeProgramStage() const
- {
- return FindMakeProgramStage::Late;
- }
-
private:
using TargetMap = std::unordered_map<std::string, cmTarget*>;
using GeneratorTargetMap =
diff --git a/Source/cmGlobalVisualStudio10Generator.cxx b/Source/cmGlobalVisualStudio10Generator.cxx
index 488ff2e..c11516d 100644
--- a/Source/cmGlobalVisualStudio10Generator.cxx
+++ b/Source/cmGlobalVisualStudio10Generator.cxx
@@ -139,7 +139,6 @@ cmGlobalVisualStudio10Generator::cmGlobalVisualStudio10Generator(
"ProductDir",
vc10Express, cmSystemTools::KeyWOW64_32);
this->CudaEnabled = false;
- this->MSBuildCommandInitialized = false;
{
std::string envPlatformToolset;
if (cmSystemTools::GetEnv("PlatformToolset", envPlatformToolset) &&
@@ -857,6 +856,12 @@ std::string const& cmGlobalVisualStudio10Generator::GetMSBuildCommand()
return this->MSBuildCommand;
}
+cm::optional<std::string>
+cmGlobalVisualStudio10Generator::FindMSBuildCommandEarly(cmMakefile*)
+{
+ return this->GetMSBuildCommand();
+}
+
std::string cmGlobalVisualStudio10Generator::FindMSBuildCommand()
{
std::string msbuild;
diff --git a/Source/cmGlobalVisualStudio10Generator.h b/Source/cmGlobalVisualStudio10Generator.h
index b7ae1ee..6e62390 100644
--- a/Source/cmGlobalVisualStudio10Generator.h
+++ b/Source/cmGlobalVisualStudio10Generator.h
@@ -20,6 +20,8 @@ class cmGlobalVisualStudio10Generator : public cmGlobalVisualStudio8Generator
public:
static std::unique_ptr<cmGlobalGeneratorFactory> NewFactory();
+ bool IsVisualStudioAtLeast10() const override { return true; }
+
bool MatchesGeneratorName(const std::string& name) const override;
bool SetSystemName(std::string const& s, cmMakefile* mf) override;
@@ -132,6 +134,8 @@ public:
bool GetSupportsUnityBuilds() const { return this->SupportsUnityBuilds; }
+ virtual cm::optional<std::string> FindMSBuildCommandEarly(cmMakefile* mf);
+
bool FindMakeProgram(cmMakefile* mf) override;
bool IsIPOSupported() const override { return true; }
@@ -222,6 +226,7 @@ protected:
bool SystemIsWindowsPhone = false;
bool SystemIsWindowsStore = false;
bool SystemIsAndroid = false;
+ bool MSBuildCommandInitialized = false;
private:
class Factory;
@@ -243,7 +248,6 @@ private:
LongestSourcePath LongestSource;
std::string MSBuildCommand;
- bool MSBuildCommandInitialized;
std::set<std::string> AndroidExecutableWarnings;
virtual std::string FindMSBuildCommand();
std::string FindDevEnvCommand() override;
diff --git a/Source/cmGlobalVisualStudioGenerator.h b/Source/cmGlobalVisualStudioGenerator.h
index d1bd6b1..23c8a02 100644
--- a/Source/cmGlobalVisualStudioGenerator.h
+++ b/Source/cmGlobalVisualStudioGenerator.h
@@ -167,11 +167,6 @@ protected:
void WriteSLNHeader(std::ostream& fout);
- FindMakeProgramStage GetFindMakeProgramStage() const override
- {
- return FindMakeProgramStage::Early;
- }
-
bool ComputeTargetDepends() override;
class VSDependSet : public std::set<std::string>
{
diff --git a/Source/cmGlobalVisualStudioVersionedGenerator.cxx b/Source/cmGlobalVisualStudioVersionedGenerator.cxx
index 3ecf32e..ec2e74f 100644
--- a/Source/cmGlobalVisualStudioVersionedGenerator.cxx
+++ b/Source/cmGlobalVisualStudioVersionedGenerator.cxx
@@ -436,6 +436,9 @@ bool cmGlobalVisualStudioVersionedGenerator::MatchesGeneratorName(
bool cmGlobalVisualStudioVersionedGenerator::SetGeneratorInstance(
std::string const& i, cmMakefile* mf)
{
+ if (this->GeneratorInstance && i == *(this->GeneratorInstance)) {
+ return true;
+ }
if (!i.empty()) {
if (!this->vsSetupAPIHelper.SetVSInstance(i)) {
std::ostringstream e;
@@ -472,6 +475,9 @@ bool cmGlobalVisualStudioVersionedGenerator::SetGeneratorInstance(
cmStateEnums::INTERNAL);
}
+ // The selected instance may have a different MSBuild than previously found.
+ this->MSBuildCommandInitialized = false;
+
return true;
}
@@ -712,6 +718,17 @@ cmGlobalVisualStudioVersionedGenerator::GetWindows10SDKMaxVersionDefault(
return std::string();
}
+cm::optional<std::string>
+cmGlobalVisualStudioVersionedGenerator::FindMSBuildCommandEarly(cmMakefile* mf)
+{
+ std::string instance = mf->GetSafeDefinition("CMAKE_GENERATOR_INSTANCE");
+ if (!this->SetGeneratorInstance(instance, mf)) {
+ cmSystemTools::SetFatalErrorOccured();
+ return {};
+ }
+ return this->cmGlobalVisualStudio14Generator::FindMSBuildCommandEarly(mf);
+}
+
std::string cmGlobalVisualStudioVersionedGenerator::FindMSBuildCommand()
{
std::string msbuild;
diff --git a/Source/cmGlobalVisualStudioVersionedGenerator.h b/Source/cmGlobalVisualStudioVersionedGenerator.h
index f07492d..b7760ac 100644
--- a/Source/cmGlobalVisualStudioVersionedGenerator.h
+++ b/Source/cmGlobalVisualStudioVersionedGenerator.h
@@ -8,6 +8,8 @@
#include <memory>
#include <string>
+#include <cm/optional>
+
#include "cmGlobalVisualStudio14Generator.h"
#include "cmVSSetupHelper.h"
@@ -29,6 +31,8 @@ public:
bool GetVSInstance(std::string& dir) const;
+ cm::optional<std::string> FindMSBuildCommandEarly(cmMakefile* mf) override;
+
cm::optional<std::string> GetVSInstanceVersion() const override;
AuxToolset FindAuxToolset(std::string& version,
@@ -72,4 +76,5 @@ private:
class Factory17;
friend class Factory17;
mutable cmVSSetupAPIHelper vsSetupAPIHelper;
+ cm::optional<std::string> GeneratorInstance;
};
diff --git a/Source/cmGlobalXCodeGenerator.h b/Source/cmGlobalXCodeGenerator.h
index 72af4a4..4d7ee90 100644
--- a/Source/cmGlobalXCodeGenerator.h
+++ b/Source/cmGlobalXCodeGenerator.h
@@ -138,11 +138,6 @@ protected:
void AddExtraIDETargets() override;
void Generate() override;
- FindMakeProgramStage GetFindMakeProgramStage() const override
- {
- return FindMakeProgramStage::Early;
- }
-
private:
enum EmbedActionFlags
{