diff options
Diffstat (limited to 'Source')
-rw-r--r-- | Source/CMakeVersion.cmake | 2 | ||||
-rw-r--r-- | Source/cmGlobalGenerator.cxx | 4 | ||||
-rw-r--r-- | Source/cmGlobalVisualStudio10Generator.cxx | 8 | ||||
-rw-r--r-- | Source/cmGlobalVisualStudio10Generator.h | 2 | ||||
-rw-r--r-- | Source/cmGlobalVisualStudio71Generator.cxx | 2 | ||||
-rw-r--r-- | Source/cmGlobalVisualStudioGenerator.cxx | 6 | ||||
-rw-r--r-- | Source/cmGlobalVisualStudioGenerator.h | 3 | ||||
-rw-r--r-- | Source/cmNinjaTargetGenerator.cxx | 8 | ||||
-rw-r--r-- | Source/cmTryRunCommand.cxx | 171 | ||||
-rw-r--r-- | Source/cmTryRunCommand.h | 10 | ||||
-rw-r--r-- | Source/cmVisualStudio10TargetGenerator.cxx | 2 |
11 files changed, 197 insertions, 21 deletions
diff --git a/Source/CMakeVersion.cmake b/Source/CMakeVersion.cmake index 0862ef7..b4b53c0 100644 --- a/Source/CMakeVersion.cmake +++ b/Source/CMakeVersion.cmake @@ -1,7 +1,7 @@ # CMake version number components. set(CMake_VERSION_MAJOR 3) set(CMake_VERSION_MINOR 24) -set(CMake_VERSION_PATCH 20220713) +set(CMake_VERSION_PATCH 20220722) #set(CMake_VERSION_RC 0) set(CMake_VERSION_IS_DIRTY 0) diff --git a/Source/cmGlobalGenerator.cxx b/Source/cmGlobalGenerator.cxx index 4cb541a..5113a46 100644 --- a/Source/cmGlobalGenerator.cxx +++ b/Source/cmGlobalGenerator.cxx @@ -1399,7 +1399,9 @@ void cmGlobalGenerator::CreateGenerationObjects(TargetTypes targetTypes) this->CheckTargetProperties(); } this->CreateGeneratorTargets(targetTypes); - this->ComputeBuildFileGenerators(); + if (targetTypes == TargetTypes::AllTargets) { + this->ComputeBuildFileGenerators(); + } } void cmGlobalGenerator::CreateImportedGenerationObjects( diff --git a/Source/cmGlobalVisualStudio10Generator.cxx b/Source/cmGlobalVisualStudio10Generator.cxx index 155efde..dec0858 100644 --- a/Source/cmGlobalVisualStudio10Generator.cxx +++ b/Source/cmGlobalVisualStudio10Generator.cxx @@ -1294,6 +1294,14 @@ bool cmGlobalVisualStudio10Generator::IsInSolution( gt->GetName() == CMAKE_CHECK_BUILD_SYSTEM_TARGET); } +bool cmGlobalVisualStudio10Generator::IsDepInSolution( + const std::string& targetName) const +{ + return !targetName.empty() && + !(this->Version >= cmGlobalVisualStudioGenerator::VSVersion::VS16 && + targetName == CMAKE_CHECK_BUILD_SYSTEM_TARGET); +} + bool cmGlobalVisualStudio10Generator::Find64BitTools(cmMakefile* mf) { if (this->DefaultPlatformToolset == "v100") { diff --git a/Source/cmGlobalVisualStudio10Generator.h b/Source/cmGlobalVisualStudio10Generator.h index 2203f71..12fd7a8 100644 --- a/Source/cmGlobalVisualStudio10Generator.h +++ b/Source/cmGlobalVisualStudio10Generator.h @@ -120,6 +120,8 @@ public: bool IsInSolution(const cmGeneratorTarget* gt) const override; + bool IsDepInSolution(const std::string& targetName) const override; + /** Return true if building for WindowsCE */ bool TargetsWindowsCE() const override { return this->SystemIsWindowsCE; } diff --git a/Source/cmGlobalVisualStudio71Generator.cxx b/Source/cmGlobalVisualStudio71Generator.cxx index ce943a2..758ce83 100644 --- a/Source/cmGlobalVisualStudio71Generator.cxx +++ b/Source/cmGlobalVisualStudio71Generator.cxx @@ -180,7 +180,7 @@ void cmGlobalVisualStudio71Generator::WriteExternalProject( fout << "\tProjectSection(ProjectDependencies) = postProject\n"; for (BT<std::pair<std::string, bool>> const& it : depends) { std::string const& dep = it.Value.first; - if (!dep.empty()) { + if (this->IsDepInSolution(dep)) { fout << "\t\t{" << this->GetGUID(dep) << "} = {" << this->GetGUID(dep) << "}\n"; } diff --git a/Source/cmGlobalVisualStudioGenerator.cxx b/Source/cmGlobalVisualStudioGenerator.cxx index cddaaa4..c6af20a 100644 --- a/Source/cmGlobalVisualStudioGenerator.cxx +++ b/Source/cmGlobalVisualStudioGenerator.cxx @@ -843,6 +843,12 @@ bool cmGlobalVisualStudioGenerator::IsInSolution( return gt->IsInBuildSystem(); } +bool cmGlobalVisualStudioGenerator::IsDepInSolution( + const std::string& targetName) const +{ + return !targetName.empty(); +} + bool cmGlobalVisualStudioGenerator::TargetCompare::operator()( cmGeneratorTarget const* l, cmGeneratorTarget const* r) const { diff --git a/Source/cmGlobalVisualStudioGenerator.h b/Source/cmGlobalVisualStudioGenerator.h index 4f5f100..f45b4d4 100644 --- a/Source/cmGlobalVisualStudioGenerator.h +++ b/Source/cmGlobalVisualStudioGenerator.h @@ -101,6 +101,9 @@ public: // return true if target should be included in solution. virtual bool IsInSolution(const cmGeneratorTarget* gt) const; + // return true if project dependency should be included in solution. + virtual bool IsDepInSolution(const std::string& targetName) const; + /** Get the top-level registry key for this VS version. */ std::string GetRegistryBase(); diff --git a/Source/cmNinjaTargetGenerator.cxx b/Source/cmNinjaTargetGenerator.cxx index 86ae45d..a4080d8 100644 --- a/Source/cmNinjaTargetGenerator.cxx +++ b/Source/cmNinjaTargetGenerator.cxx @@ -1343,9 +1343,11 @@ void cmNinjaTargetGenerator::WriteObjectBuildStatement( } } - this->ExportObjectCompileCommand( - language, sourceFilePath, objectDir, objectFileName, objectFileDir, - vars["FLAGS"], vars["DEFINES"], vars["INCLUDES"], config); + if (firstForConfig) { + this->ExportObjectCompileCommand( + language, sourceFilePath, objectDir, objectFileName, objectFileDir, + vars["FLAGS"], vars["DEFINES"], vars["INCLUDES"], config); + } objBuild.Outputs.push_back(objectFileName); if (firstForConfig) { diff --git a/Source/cmTryRunCommand.cxx b/Source/cmTryRunCommand.cxx index c82ac64..4cd0adc 100644 --- a/Source/cmTryRunCommand.cxx +++ b/Source/cmTryRunCommand.cxx @@ -42,6 +42,8 @@ bool cmTryRunCommand::InitialPass(std::vector<std::string> const& argv, this->RunResultVariable.clear(); this->OutputVariable.clear(); this->RunOutputVariable.clear(); + this->RunOutputStdOutVariable.clear(); + this->RunOutputStdErrVariable.clear(); this->CompileOutputVariable.clear(); std::string runArgs; @@ -76,6 +78,22 @@ bool cmTryRunCommand::InitialPass(std::vector<std::string> const& argv, } i++; this->RunOutputVariable = argv[i]; + } else if (argv[i] == "RUN_OUTPUT_STDOUT_VARIABLE") { + if (argv.size() <= (i + 1)) { + cmSystemTools::Error( + "RUN_OUTPUT_STDOUT_VARIABLE specified but there is no variable"); + return false; + } + i++; + this->RunOutputStdOutVariable = argv[i]; + } else if (argv[i] == "RUN_OUTPUT_STDERR_VARIABLE") { + if (argv.size() <= (i + 1)) { + cmSystemTools::Error( + "RUN_OUTPUT_STDERR_VARIABLE specified but there is no variable"); + return false; + } + i++; + this->RunOutputStdErrVariable = argv[i]; } else if (argv[i] == "COMPILE_OUTPUT_VARIABLE") { if (argv.size() <= (i + 1)) { cmSystemTools::Error( @@ -102,11 +120,27 @@ bool cmTryRunCommand::InitialPass(std::vector<std::string> const& argv, // using OUTPUT_VARIABLE makes crosscompiling harder if (!this->OutputVariable.empty() && (!this->RunOutputVariable.empty() || - !this->CompileOutputVariable.empty())) { + !this->CompileOutputVariable.empty() || + !this->RunOutputStdOutVariable.empty() || + !this->RunOutputStdErrVariable.empty())) { cmSystemTools::Error( "You cannot use OUTPUT_VARIABLE together with COMPILE_OUTPUT_VARIABLE " - "or RUN_OUTPUT_VARIABLE. Please use only COMPILE_OUTPUT_VARIABLE and/or " - "RUN_OUTPUT_VARIABLE."); + ", RUN_OUTPUT_VARIABLE, RUN_OUTPUT_STDOUT_VARIABLE or " + "RUN_OUTPUT_STDERR_VARIABLE. " + "Please use only COMPILE_OUTPUT_VARIABLE, RUN_OUTPUT_VARIABLE, " + "RUN_OUTPUT_STDOUT_VARIABLE " + "and/or RUN_OUTPUT_STDERR_VARIABLE."); + return false; + } + + if ((!this->RunOutputStdOutVariable.empty() || + !RunOutputStdErrVariable.empty()) && + !this->RunOutputVariable.empty()) { + cmSystemTools::Error( + "You cannot use RUN_OUTPUT_STDOUT_VARIABLE or " + "RUN_OUTPUT_STDERR_VARIABLE together " + "with RUN_OUTPUT_VARIABLE. Please use only COMPILE_OUTPUT_VARIABLE or " + "RUN_OUTPUT_STDOUT_VARIABLE and/or RUN_OUTPUT_STDERR_VARIABLE."); return false; } @@ -119,6 +153,7 @@ bool cmTryRunCommand::InitialPass(std::vector<std::string> const& argv, } bool captureRunOutput = false; + bool captureRunOutputStdOutErr = false; if (!this->OutputVariable.empty()) { captureRunOutput = true; tryCompile.emplace_back("OUTPUT_VARIABLE"); @@ -128,7 +163,10 @@ bool cmTryRunCommand::InitialPass(std::vector<std::string> const& argv, tryCompile.emplace_back("OUTPUT_VARIABLE"); tryCompile.push_back(this->CompileOutputVariable); } - if (!this->RunOutputVariable.empty()) { + if (!this->RunOutputStdOutVariable.empty() || + !RunOutputStdErrVariable.empty()) { + captureRunOutputStdOutErr = true; + } else if (!this->RunOutputVariable.empty()) { captureRunOutput = true; } @@ -145,12 +183,27 @@ bool cmTryRunCommand::InitialPass(std::vector<std::string> const& argv, } else { // "run" it and capture the output std::string runOutputContents; + std::string runOutputStdOutContents; + std::string runOutputStdErrContents; if (this->Makefile->IsOn("CMAKE_CROSSCOMPILING") && !this->Makefile->IsDefinitionSet("CMAKE_CROSSCOMPILING_EMULATOR")) { this->DoNotRunExecutable( - runArgs, argv[3], captureRunOutput ? &runOutputContents : nullptr); + runArgs, argv[3], captureRunOutput ? &runOutputContents : nullptr, + captureRunOutputStdOutErr && !RunOutputStdOutVariable.empty() + ? &runOutputStdOutContents + : nullptr, + captureRunOutputStdOutErr && !RunOutputStdErrVariable.empty() + ? &runOutputStdErrContents + : nullptr); } else { - this->RunExecutable(runArgs, &runOutputContents); + this->RunExecutable( + runArgs, captureRunOutput ? &runOutputContents : nullptr, + captureRunOutputStdOutErr && !RunOutputStdOutVariable.empty() + ? &runOutputStdOutContents + : nullptr, + captureRunOutputStdOutErr && !RunOutputStdErrVariable.empty() + ? &runOutputStdErrContents + : nullptr); } // now put the output into the variables @@ -158,6 +211,14 @@ bool cmTryRunCommand::InitialPass(std::vector<std::string> const& argv, this->Makefile->AddDefinition(this->RunOutputVariable, runOutputContents); } + if (!this->RunOutputStdOutVariable.empty()) { + this->Makefile->AddDefinition(this->RunOutputStdOutVariable, + runOutputStdOutContents); + } + if (!this->RunOutputStdErrVariable.empty()) { + this->Makefile->AddDefinition(this->RunOutputStdErrVariable, + runOutputStdErrContents); + } if (!this->OutputVariable.empty()) { // if the TryCompileCore saved output in this outputVariable then @@ -180,7 +241,8 @@ bool cmTryRunCommand::InitialPass(std::vector<std::string> const& argv, } void cmTryRunCommand::RunExecutable(const std::string& runArgs, - std::string* out) + std::string* out, std::string* stdOut, + std::string* stdErr) { int retVal = -1; @@ -204,7 +266,8 @@ void cmTryRunCommand::RunExecutable(const std::string& runArgs, finalCommand += runArgs; } bool worked = cmSystemTools::RunSingleCommand( - finalCommand, out, out, &retVal, + finalCommand, stdOut || stdErr ? stdOut : out, + stdOut || stdErr ? stdErr : out, &retVal, this->WorkingDirectory.empty() ? nullptr : this->WorkingDirectory.c_str(), cmSystemTools::OUTPUT_NONE, cmDuration::zero()); // set the run var @@ -227,7 +290,8 @@ void cmTryRunCommand::RunExecutable(const std::string& runArgs, */ void cmTryRunCommand::DoNotRunExecutable(const std::string& runArgs, const std::string& srcFile, - std::string* out) + std::string* out, std::string* stdOut, + std::string* stdErr) { // copy the executable out of the CMakeFiles/ directory, so it is not // removed at the end of try_run() and the user can run it manually @@ -246,6 +310,10 @@ void cmTryRunCommand::DoNotRunExecutable(const std::string& runArgs, std::string internalRunOutputName = this->RunResultVariable + "__TRYRUN_OUTPUT"; + std::string internalRunOutputStdOutName = + this->RunResultVariable + "__TRYRUN_OUTPUT_STDOUT"; + std::string internalRunOutputStdErrName = + this->RunResultVariable + "__TRYRUN_OUTPUT_STDERR"; bool error = false; if (!this->Makefile->GetDefinition(this->RunResultVariable)) { @@ -269,7 +337,51 @@ void cmTryRunCommand::DoNotRunExecutable(const std::string& runArgs, } // is the output from the executable used ? - if (out) { + if (stdOut || stdErr) { + if (!this->Makefile->GetDefinition(internalRunOutputStdOutName)) { + // if the variables doesn't exist, create it with a helpful error text + // and mark it as advanced + std::string comment = cmStrCat( + "Output of try_run(), contains the text, which the executable " + "would have printed on stdout on its target platform.\n", + detailsString); + + this->Makefile->AddCacheDefinition( + internalRunOutputStdOutName, "PLEASE_FILL_OUT-NOTFOUND", + comment.c_str(), cmStateEnums::STRING); + cmState* state = this->Makefile->GetState(); + cmValue existing = + state->GetCacheEntryValue(internalRunOutputStdOutName); + if (existing) { + state->SetCacheEntryProperty(internalRunOutputStdOutName, "ADVANCED", + "1"); + } + + error = true; + } + + if (!this->Makefile->GetDefinition(internalRunOutputStdErrName)) { + // if the variables doesn't exist, create it with a helpful error text + // and mark it as advanced + std::string comment = cmStrCat( + "Output of try_run(), contains the text, which the executable " + "would have printed on stderr on its target platform.\n", + detailsString); + + this->Makefile->AddCacheDefinition( + internalRunOutputStdErrName, "PLEASE_FILL_OUT-NOTFOUND", + comment.c_str(), cmStateEnums::STRING); + cmState* state = this->Makefile->GetState(); + cmValue existing = + state->GetCacheEntryValue(internalRunOutputStdErrName); + if (existing) { + state->SetCacheEntryProperty(internalRunOutputStdErrName, "ADVANCED", + "1"); + } + + error = true; + } + } else if (out) { if (!this->Makefile->GetDefinition(internalRunOutputName)) { // if the variables doesn't exist, create it with a helpful error text // and mark it as advanced @@ -317,7 +429,34 @@ void cmTryRunCommand::DoNotRunExecutable(const std::string& runArgs, " to\n" " the exit code (in many cases 0 for success), otherwise " "enter \"FAILED_TO_RUN\".\n"); - if (out) { + if (stdOut || stdErr) { + if (stdOut) { + comment += internalRunOutputStdOutName; + comment += + "\n contains the text the executable " + "would have printed on stdout.\n" + " If the executable would not have been able to run, set "; + comment += internalRunOutputStdOutName; + comment += " empty.\n" + " Otherwise check if the output is evaluated by the " + "calling CMake code. If so,\n" + " check what the source file would have printed when " + "called with the given arguments.\n"; + } + if (stdErr) { + comment += internalRunOutputStdErrName; + comment += + "\n contains the text the executable " + "would have printed on stderr.\n" + " If the executable would not have been able to run, set "; + comment += internalRunOutputStdErrName; + comment += " empty.\n" + " Otherwise check if the output is evaluated by the " + "calling CMake code. If so,\n" + " check what the source file would have printed when " + "called with the given arguments.\n"; + } + } else if (out) { comment += internalRunOutputName; comment += "\n contains the text the executable " @@ -330,6 +469,7 @@ void cmTryRunCommand::DoNotRunExecutable(const std::string& runArgs, " check what the source file would have printed when " "called with the given arguments.\n"; } + comment += "The "; comment += this->CompileResultVariable; comment += " variable holds the build result for this try_run().\n\n" @@ -370,7 +510,14 @@ void cmTryRunCommand::DoNotRunExecutable(const std::string& runArgs, return; } - if (out) { + if (stdOut || stdErr) { + if (stdOut) { + (*stdOut) = *this->Makefile->GetDefinition(internalRunOutputStdOutName); + } + if (stdErr) { + (*stdErr) = *this->Makefile->GetDefinition(internalRunOutputStdErrName); + } + } else if (out) { (*out) = *this->Makefile->GetDefinition(internalRunOutputName); } } diff --git a/Source/cmTryRunCommand.h b/Source/cmTryRunCommand.h index d45acd8..ccf678e 100644 --- a/Source/cmTryRunCommand.h +++ b/Source/cmTryRunCommand.h @@ -39,15 +39,21 @@ public: private: void RunExecutable(const std::string& runArgs, - std::string* runOutputContents); + std::string* runOutputContents, + std::string* runOutputStdOutContents, + std::string* runOutputStdErrContents); void DoNotRunExecutable(const std::string& runArgs, const std::string& srcFile, - std::string* runOutputContents); + std::string* runOutputContents, + std::string* runOutputStdOutContents, + std::string* runOutputStdErrContents); std::string CompileResultVariable; std::string RunResultVariable; std::string OutputVariable; std::string RunOutputVariable; + std::string RunOutputStdOutVariable; + std::string RunOutputStdErrVariable; std::string CompileOutputVariable; std::string WorkingDirectory; }; diff --git a/Source/cmVisualStudio10TargetGenerator.cxx b/Source/cmVisualStudio10TargetGenerator.cxx index a7460e8..2356869 100644 --- a/Source/cmVisualStudio10TargetGenerator.cxx +++ b/Source/cmVisualStudio10TargetGenerator.cxx @@ -2930,7 +2930,7 @@ void cmVisualStudio10TargetGenerator::WritePathAndIncrementalLinkOptions( Elem& e0) { cmStateEnums::TargetType ttype = this->GeneratorTarget->GetType(); - if (ttype > cmStateEnums::GLOBAL_TARGET) { + if (ttype > cmStateEnums::INTERFACE_LIBRARY) { return; } if (this->ProjectType == VsProjectType::csproj) { |