diff options
Diffstat (limited to 'Source')
-rw-r--r-- | Source/cmGeneratorTarget.cxx | 19 | ||||
-rw-r--r-- | Source/cmGlobalVisualStudio14Generator.cxx | 13 | ||||
-rw-r--r-- | Source/cmGlobalVisualStudio14Generator.h | 3 | ||||
-rw-r--r-- | Source/cmGlobalVisualStudioVersionedGenerator.cxx | 6 | ||||
-rw-r--r-- | Source/cmIncludeExternalMSProjectCommand.cxx | 4 | ||||
-rw-r--r-- | Source/cmInstallTargetGenerator.cxx | 16 | ||||
-rw-r--r-- | Source/cmInstallTargetGenerator.h | 1 | ||||
-rw-r--r-- | Source/cmLocalGenerator.cxx | 77 | ||||
-rw-r--r-- | Source/cmQtAutoGenGlobalInitializer.cxx | 64 | ||||
-rw-r--r-- | Source/cmQtAutoGenGlobalInitializer.h | 6 | ||||
-rw-r--r-- | Source/cmQtAutoGenInitializer.cxx | 53 | ||||
-rw-r--r-- | Source/cmQtAutoGenInitializer.h | 4 | ||||
-rw-r--r-- | Source/cmakemain.cxx | 2 |
13 files changed, 153 insertions, 115 deletions
diff --git a/Source/cmGeneratorTarget.cxx b/Source/cmGeneratorTarget.cxx index 78040c3..25349d4 100644 --- a/Source/cmGeneratorTarget.cxx +++ b/Source/cmGeneratorTarget.cxx @@ -510,21 +510,10 @@ const char* cmGeneratorTarget::GetLinkPIEProperty( return nullptr; } - switch (this->GetPolicyStatusCMP0083()) { - case cmPolicies::WARN: { - std::ostringstream e; - e << cmPolicies::GetPolicyWarning(cmPolicies::CMP0083); - this->LocalGenerator->IssueMessage(MessageType::AUTHOR_WARNING, e.str()); - CM_FALLTHROUGH; - } - case cmPolicies::OLD: - return nullptr; - default: - // nothing to do - break; - } - - return PICValue.c_str(); + auto status = this->GetPolicyStatusCMP0083(); + return (status != cmPolicies::WARN && status != cmPolicies::OLD) + ? PICValue.c_str() + : nullptr; } bool cmGeneratorTarget::IsIPOEnabled(std::string const& lang, diff --git a/Source/cmGlobalVisualStudio14Generator.cxx b/Source/cmGlobalVisualStudio14Generator.cxx index a0a9558..2025867 100644 --- a/Source/cmGlobalVisualStudio14Generator.cxx +++ b/Source/cmGlobalVisualStudio14Generator.cxx @@ -158,14 +158,22 @@ bool cmGlobalVisualStudio14Generator::SelectWindows10SDK(cmMakefile* mf, bool required) { // Find the default version of the Windows 10 SDK. - this->WindowsTargetPlatformVersion = this->GetWindows10SDKVersion(); - if (required && this->WindowsTargetPlatformVersion.empty()) { + std::string const version = this->GetWindows10SDKVersion(); + if (required && version.empty()) { std::ostringstream e; e << "Could not find an appropriate version of the Windows 10 SDK" << " installed on this machine"; mf->IssueMessage(MessageType::FATAL_ERROR, e.str()); return false; } + this->SetWindowsTargetPlatformVersion(version, mf); + return true; +} + +void cmGlobalVisualStudio14Generator::SetWindowsTargetPlatformVersion( + std::string const& version, cmMakefile* mf) +{ + this->WindowsTargetPlatformVersion = version; if (!cmSystemTools::VersionCompareEqual(this->WindowsTargetPlatformVersion, this->SystemVersion)) { std::ostringstream e; @@ -175,7 +183,6 @@ bool cmGlobalVisualStudio14Generator::SelectWindows10SDK(cmMakefile* mf, } mf->AddDefinition("CMAKE_VS_WINDOWS_TARGET_PLATFORM_VERSION", this->WindowsTargetPlatformVersion.c_str()); - return true; } bool cmGlobalVisualStudio14Generator::SelectWindowsStoreToolset( diff --git a/Source/cmGlobalVisualStudio14Generator.h b/Source/cmGlobalVisualStudio14Generator.h index 32008b0..6e12d3e 100644 --- a/Source/cmGlobalVisualStudio14Generator.h +++ b/Source/cmGlobalVisualStudio14Generator.h @@ -40,6 +40,9 @@ protected: virtual bool SelectWindows10SDK(cmMakefile* mf, bool required); + void SetWindowsTargetPlatformVersion(std::string const& version, + cmMakefile* mf); + // Used to verify that the Desktop toolset for the current generator is // installed on the machine. bool IsWindowsDesktopToolsetInstalled() const override; diff --git a/Source/cmGlobalVisualStudioVersionedGenerator.cxx b/Source/cmGlobalVisualStudioVersionedGenerator.cxx index 913fc4a..2f9eb3f 100644 --- a/Source/cmGlobalVisualStudioVersionedGenerator.cxx +++ b/Source/cmGlobalVisualStudioVersionedGenerator.cxx @@ -401,6 +401,12 @@ bool cmGlobalVisualStudioVersionedGenerator::InitializeWindows(cmMakefile* mf) // If the Win 8.1 SDK is installed then we can select a SDK matching // the target Windows version. if (this->IsWin81SDKInstalled()) { + // VS 2019 does not default to 8.1 so specify it explicitly when needed. + if (this->Version >= cmGlobalVisualStudioGenerator::VS16 && + !cmSystemTools::VersionCompareGreater(this->SystemVersion, "8.1")) { + this->SetWindowsTargetPlatformVersion("8.1", mf); + return true; + } return cmGlobalVisualStudio14Generator::InitializeWindows(mf); } // Otherwise we must choose a Win 10 SDK even if we are not targeting diff --git a/Source/cmIncludeExternalMSProjectCommand.cxx b/Source/cmIncludeExternalMSProjectCommand.cxx index b224d09..93134ad 100644 --- a/Source/cmIncludeExternalMSProjectCommand.cxx +++ b/Source/cmIncludeExternalMSProjectCommand.cxx @@ -85,10 +85,12 @@ bool cmIncludeExternalMSProjectCommand::InitialPass( // Create a target instance for this utility. cmTarget* target = this->Makefile->AddNewTarget(cmStateEnums::UTILITY, utility_name.c_str()); + if (this->Makefile->GetPropertyAsBool("EXCLUDE_FROM_ALL")) { + target->SetProperty("EXCLUDE_FROM_ALL", "TRUE"); + } target->SetProperty("GENERATOR_FILE_NAME", utility_name.c_str()); target->SetProperty("EXTERNAL_MSPROJECT", path.c_str()); - target->SetProperty("EXCLUDE_FROM_ALL", "FALSE"); if (!customType.empty()) target->SetProperty("VS_PROJECT_TYPE", customType.c_str()); diff --git a/Source/cmInstallTargetGenerator.cxx b/Source/cmInstallTargetGenerator.cxx index 59701a1..9d3a6bb 100644 --- a/Source/cmInstallTargetGenerator.cxx +++ b/Source/cmInstallTargetGenerator.cxx @@ -41,22 +41,6 @@ cmInstallTargetGenerator::cmInstallTargetGenerator( cmInstallTargetGenerator::~cmInstallTargetGenerator() = default; -void cmInstallTargetGenerator::GenerateScript(std::ostream& os) -{ - // Warn if installing an exclude-from-all target. - if (this->Target->GetPropertyAsBool("EXCLUDE_FROM_ALL")) { - std::ostringstream msg; - msg << "WARNING: Target \"" << this->Target->GetName() - << "\" has EXCLUDE_FROM_ALL set and will not be built by default " - << "but an install rule has been provided for it. CMake does " - << "not define behavior for this case."; - cmSystemTools::Message(msg.str(), "Warning"); - } - - // Perform the main install script generation. - this->cmInstallGenerator::GenerateScript(os); -} - void cmInstallTargetGenerator::GenerateScriptForConfig( std::ostream& os, const std::string& config, Indent indent) { diff --git a/Source/cmInstallTargetGenerator.h b/Source/cmInstallTargetGenerator.h index 715b4ae..6df5b1a 100644 --- a/Source/cmInstallTargetGenerator.h +++ b/Source/cmInstallTargetGenerator.h @@ -69,7 +69,6 @@ public: cmListFileBacktrace const& GetBacktrace() const { return this->Backtrace; } protected: - void GenerateScript(std::ostream& os) override; void GenerateScriptForConfig(std::ostream& os, const std::string& config, Indent indent) override; void GenerateScriptForConfigObjectLibrary(std::ostream& os, diff --git a/Source/cmLocalGenerator.cxx b/Source/cmLocalGenerator.cxx index 8090e00..7e56818 100644 --- a/Source/cmLocalGenerator.cxx +++ b/Source/cmLocalGenerator.cxx @@ -920,6 +920,20 @@ std::vector<BT<std::string>> cmLocalGenerator::GetIncludeDirectoriesImplicit( return result; } + // Standard include directories to be added unconditionally at the end. + // These are intended to simulate additional implicit include directories. + std::vector<std::string> userStandardDirs; + { + std::string key = "CMAKE_"; + key += lang; + key += "_STANDARD_INCLUDE_DIRECTORIES"; + std::string const value = this->Makefile->GetSafeDefinition(key); + cmSystemTools::ExpandListArgument(value, userStandardDirs); + for (std::string& usd : userStandardDirs) { + cmSystemTools::ConvertToUnixSlashes(usd); + } + } + // Implicit include directories std::vector<std::string> implicitDirs; std::set<std::string> implicitSet; @@ -928,24 +942,27 @@ std::vector<BT<std::string>> cmLocalGenerator::GetIncludeDirectoriesImplicit( return (implicitSet.find(dir) == implicitSet.end()); }; { - std::string rootPath; - if (const char* sysrootCompile = - this->Makefile->GetDefinition("CMAKE_SYSROOT_COMPILE")) { - rootPath = sysrootCompile; - } else { - rootPath = this->Makefile->GetSafeDefinition("CMAKE_SYSROOT"); - } - cmSystemTools::ConvertToUnixSlashes(rootPath); - // Raw list of implicit include directories - std::vector<std::string> impDirVec; + // Start with "standard" directories that we unconditionally add below. + std::vector<std::string> impDirVec = userStandardDirs; // Load implicit include directories for this language. - std::string key = "CMAKE_"; - key += lang; - key += "_IMPLICIT_INCLUDE_DIRECTORIES"; - if (const char* value = this->Makefile->GetDefinition(key)) { - cmSystemTools::ExpandListArgument(value, impDirVec); + // We ignore this for Fortran because: + // * There are no standard library headers to avoid overriding. + // * Compilers like gfortran do not search their own implicit include + // directories for modules ('.mod' files). + if (lang != "Fortran") { + std::string key = "CMAKE_"; + key += lang; + key += "_IMPLICIT_INCLUDE_DIRECTORIES"; + if (const char* value = this->Makefile->GetDefinition(key)) { + size_t const impDirVecOldSize = impDirVec.size(); + cmSystemTools::ExpandListArgument(value, impDirVec); + // FIXME: Use cmRange with 'advance()' when it supports non-const. + for (size_t i = impDirVecOldSize; i < impDirVec.size(); ++i) { + cmSystemTools::ConvertToUnixSlashes(impDirVec[i]); + } + } } // The Platform/UnixPaths module used to hard-code /usr/include for C, CXX, @@ -965,13 +982,8 @@ std::vector<BT<std::string>> cmLocalGenerator::GetIncludeDirectoriesImplicit( } for (std::string const& i : impDirVec) { - std::string imd = i; - cmSystemTools::ConvertToUnixSlashes(imd); - if (!rootPath.empty() && !cmHasPrefix(imd, rootPath)) { - imd = rootPath + imd; - } - if (implicitSet.insert(imd).second) { - implicitDirs.emplace_back(std::move(imd)); + if (implicitSet.insert(i).second) { + implicitDirs.emplace_back(i); } } } @@ -1010,23 +1022,10 @@ std::vector<BT<std::string>> cmLocalGenerator::GetIncludeDirectoriesImplicit( MoveSystemIncludesToEnd(result, config, lang, target); // Append standard include directories for this language. - { - std::vector<std::string> userStandardDirs; - { - std::string key = "CMAKE_"; - key += lang; - key += "_STANDARD_INCLUDE_DIRECTORIES"; - std::string const value = this->Makefile->GetSafeDefinition(key); - cmSystemTools::ExpandListArgument(value, userStandardDirs); - } - userDirs.reserve(userDirs.size() + userStandardDirs.size()); - for (std::string& usd : userStandardDirs) { - cmSystemTools::ConvertToUnixSlashes(usd); - if (notImplicit(usd)) { - emitDir(usd); - } - userDirs.emplace_back(std::move(usd)); - } + userDirs.reserve(userDirs.size() + userStandardDirs.size()); + for (std::string& usd : userStandardDirs) { + emitDir(usd); + userDirs.emplace_back(std::move(usd)); } // Append compiler implicit include directories diff --git a/Source/cmQtAutoGenGlobalInitializer.cxx b/Source/cmQtAutoGenGlobalInitializer.cxx index 95a297c..3ad91ee 100644 --- a/Source/cmQtAutoGenGlobalInitializer.cxx +++ b/Source/cmQtAutoGenGlobalInitializer.cxx @@ -6,10 +6,12 @@ #include "cmAlgorithms.h" #include "cmCustomCommandLines.h" +#include "cmDuration.h" #include "cmGeneratorTarget.h" #include "cmLocalGenerator.h" #include "cmMakefile.h" #include "cmMessageType.h" +#include "cmProcessOutput.h" #include "cmState.h" #include "cmStateTypes.h" #include "cmSystemTools.h" @@ -183,6 +185,68 @@ void cmQtAutoGenGlobalInitializer::AddToGlobalAutoRcc( } } +bool cmQtAutoGenGlobalInitializer::GetExecutableTestOutput( + std::string const& generator, std::string const& executable, + std::string& error, std::string* output) +{ + // Check if we have cached output + { + auto it = this->ExecutableTestOutputs_.find(executable); + if (it != this->ExecutableTestOutputs_.end()) { + // Return output on demand + if (output != nullptr) { + *output = it->second; + } + return true; + } + } + + // Check if the executable exists + if (!cmSystemTools::FileExists(executable, true)) { + error = "The \""; + error += generator; + error += "\" executable "; + error += cmQtAutoGen::Quoted(executable); + error += " does not exist."; + return false; + } + + // Test the executable + std::string stdOut; + { + std::string stdErr; + std::vector<std::string> command; + command.push_back(executable); + command.emplace_back("-h"); + int retVal = 0; + const bool runResult = cmSystemTools::RunSingleCommand( + command, &stdOut, &stdErr, &retVal, nullptr, cmSystemTools::OUTPUT_NONE, + cmDuration::zero(), cmProcessOutput::Auto); + if (!runResult) { + error = "Test run of \""; + error += generator; + error += "\" executable "; + error += cmQtAutoGen::Quoted(executable) + " failed.\n"; + error += cmQtAutoGen::QuotedCommand(command); + error += "\n"; + error += stdOut; + error += "\n"; + error += stdErr; + return false; + } + } + + // Return executable output on demand + if (output != nullptr) { + *output = stdOut; + } + + // Register executable and output + this->ExecutableTestOutputs_.emplace(executable, std::move(stdOut)); + + return true; +} + bool cmQtAutoGenGlobalInitializer::generate() { return (InitializeCustomTargets() && SetupCustomTargets()); diff --git a/Source/cmQtAutoGenGlobalInitializer.h b/Source/cmQtAutoGenGlobalInitializer.h index 9e6bac0..74184a0 100644 --- a/Source/cmQtAutoGenGlobalInitializer.h +++ b/Source/cmQtAutoGenGlobalInitializer.h @@ -8,6 +8,7 @@ #include <map> #include <memory> // IWYU pragma: keep #include <string> +#include <unordered_map> #include <vector> class cmLocalGenerator; @@ -38,10 +39,15 @@ private: void AddToGlobalAutoRcc(cmLocalGenerator* localGen, std::string const& targetName); + bool GetExecutableTestOutput(std::string const& generator, + std::string const& executable, + std::string& error, std::string* output); + private: std::vector<std::unique_ptr<cmQtAutoGenInitializer>> Initializers_; std::map<cmLocalGenerator*, std::string> GlobalAutoGenTargets_; std::map<cmLocalGenerator*, std::string> GlobalAutoRccTargets_; + std::unordered_map<std::string, std::string> ExecutableTestOutputs_; }; #endif diff --git a/Source/cmQtAutoGenInitializer.cxx b/Source/cmQtAutoGenInitializer.cxx index a96d574..614a88b 100644 --- a/Source/cmQtAutoGenInitializer.cxx +++ b/Source/cmQtAutoGenInitializer.cxx @@ -1439,18 +1439,18 @@ cmQtAutoGenInitializer::GetQtVersion(cmGeneratorTarget const* target) return res; } -std::pair<bool, std::string> GetQtExecutable( - const cmQtAutoGen::IntegerVersion& qtVersion, cmGeneratorTarget* target, +std::pair<bool, std::string> cmQtAutoGenInitializer::GetQtExecutable( const std::string& executable, bool ignoreMissingTarget, std::string* output) { const std::string upperExecutable = cmSystemTools::UpperCase(executable); - std::string result = - target->Target->GetSafeProperty("AUTO" + upperExecutable + "_EXECUTABLE"); + std::string result = this->Target->Target->GetSafeProperty( + "AUTO" + upperExecutable + "_EXECUTABLE"); if (!result.empty()) { - cmListFileBacktrace lfbt = target->Target->GetMakefile()->GetBacktrace(); + cmListFileBacktrace lfbt = + this->Target->Target->GetMakefile()->GetBacktrace(); cmGeneratorExpression ge(lfbt); std::unique_ptr<cmCompiledGeneratorExpression> cge = ge.Parse(result); - result = cge->Evaluate(target->GetLocalGenerator(), ""); + result = cge->Evaluate(this->Target->GetLocalGenerator(), ""); return std::make_pair(true, result); } @@ -1460,12 +1460,12 @@ std::pair<bool, std::string> GetQtExecutable( // Find executable { const std::string targetName = - GetQtExecutableTargetName(qtVersion, executable); + GetQtExecutableTargetName(this->QtVersion, executable); if (targetName.empty()) { err = "The AUTO" + upperExecutable + " feature "; err += "supports only Qt 4, Qt 5 and Qt 6."; } else { - cmLocalGenerator* localGen = target->GetLocalGenerator(); + cmLocalGenerator* localGen = this->Target->GetLocalGenerator(); cmGeneratorTarget* tgt = localGen->FindGeneratorTargetToUse(targetName); if (tgt != nullptr) { if (tgt->IsImported()) { @@ -1485,36 +1485,14 @@ std::pair<bool, std::string> GetQtExecutable( // Test executable if (err.empty()) { - if (cmSystemTools::FileExists(result, true)) { - std::vector<std::string> command; - command.push_back(result); - command.emplace_back("-h"); - std::string stdOut; - std::string stdErr; - int retVal = 0; - const bool runResult = cmSystemTools::RunSingleCommand( - command, &stdOut, &stdErr, &retVal, nullptr, - cmSystemTools::OUTPUT_NONE, cmDuration::zero(), cmProcessOutput::Auto); - if (!runResult) { - err = "Test of \"" + executable + "\" binary "; - err += cmQtAutoGen::Quoted(result) + " failed: "; - err += cmQtAutoGen::QuotedCommand(command); - } else { - if (output != nullptr) { - *output = stdOut; - } - } - } else { - err = "The \"" + executable + "\" binary "; - err += cmQtAutoGen::Quoted(result); - err += " does not exist"; - } + this->GlobalInitializer->GetExecutableTestOutput(executable, result, err, + output); } // Print error if (!err.empty()) { std::string msg = "AutoGen ("; - msg += target->GetName(); + msg += this->Target->GetName(); msg += "): "; msg += err; cmSystemTools::Error(msg); @@ -1526,16 +1504,14 @@ std::pair<bool, std::string> GetQtExecutable( bool cmQtAutoGenInitializer::GetMocExecutable() { - const auto result = - GetQtExecutable(this->QtVersion, this->Target, "moc", false, nullptr); + const auto result = this->GetQtExecutable("moc", false, nullptr); this->Moc.Executable = result.second; return result.first; } bool cmQtAutoGenInitializer::GetUicExecutable() { - const auto result = - GetQtExecutable(this->QtVersion, this->Target, "uic", true, nullptr); + const auto result = this->GetQtExecutable("uic", true, nullptr); this->Uic.Executable = result.second; return result.first; } @@ -1543,8 +1519,7 @@ bool cmQtAutoGenInitializer::GetUicExecutable() bool cmQtAutoGenInitializer::GetRccExecutable() { std::string stdOut; - const auto result = - GetQtExecutable(this->QtVersion, this->Target, "rcc", false, &stdOut); + const auto result = this->GetQtExecutable("rcc", false, &stdOut); this->Rcc.Executable = result.second; if (!result.first) { return false; diff --git a/Source/cmQtAutoGenInitializer.h b/Source/cmQtAutoGenInitializer.h index 10f0bf3..781dd15 100644 --- a/Source/cmQtAutoGenInitializer.h +++ b/Source/cmQtAutoGenInitializer.h @@ -110,6 +110,10 @@ private: std::vector<std::string>& files, std::string& errorMessage); + std::pair<bool, std::string> GetQtExecutable(const std::string& executable, + bool ignoreMissingTarget, + std::string* output); + private: cmQtAutoGenGlobalInitializer* GlobalInitializer; cmGeneratorTarget* Target; diff --git a/Source/cmakemain.cxx b/Source/cmakemain.cxx index 890b74e..a83f7dc 100644 --- a/Source/cmakemain.cxx +++ b/Source/cmakemain.cxx @@ -498,7 +498,7 @@ static int do_build(int ac, char const* const* av) return 1; } - cmake cm(cmake::RoleInternal, cmState::Unknown); + cmake cm(cmake::RoleInternal, cmState::Project); cmSystemTools::SetMessageCallback([&cm](const char* msg, const char* title) { cmakemainMessageCallback(msg, title, &cm); }); |