From kwrobot at kitware.com Thu Aug 1 00:01:46 2019 From: kwrobot at kitware.com (Kitware Robot) Date: Thu, 1 Aug 2019 00:01:46 -0400 (EDT) Subject: [Cmake-commits] CMake branch, master, updated. v3.15.1-552-g33d9a69 Message-ID: <20190801040146.9F796FA6B5@public.kitware.com> This is an automated email from the git hooks/post-receive script. It was generated because a ref change was pushed to the repository containing the project "CMake". The branch, master has been updated via 33d9a691306956750bffb10be9d0b17a47c0ec0b (commit) from 1672d3d5a5a0c5c73a857f5e4592fe998da3ae78 (commit) Those revisions listed above that are new to this repository have not appeared on any other notification email; so we list those revisions in full, below. - Log ----------------------------------------------------------------- https://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=33d9a691306956750bffb10be9d0b17a47c0ec0b commit 33d9a691306956750bffb10be9d0b17a47c0ec0b Author: Kitware Robot AuthorDate: Thu Aug 1 00:01:08 2019 -0400 Commit: Kitware Robot CommitDate: Thu Aug 1 00:01:08 2019 -0400 CMake Nightly Date Stamp diff --git a/Source/CMakeVersion.cmake b/Source/CMakeVersion.cmake index f02ef52..529c0cf 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 15) -set(CMake_VERSION_PATCH 20190731) +set(CMake_VERSION_PATCH 20190801) #set(CMake_VERSION_RC 0) set(CMake_VERSION_IS_DIRTY 0) ----------------------------------------------------------------------- Summary of changes: Source/CMakeVersion.cmake | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) hooks/post-receive -- CMake From kwrobot at kitware.com Fri Aug 2 00:01:15 2019 From: kwrobot at kitware.com (Kitware Robot) Date: Fri, 2 Aug 2019 00:01:15 -0400 (EDT) Subject: [Cmake-commits] CMake branch, master, updated. v3.15.1-553-ga1e3262 Message-ID: <20190802040115.10FC711DFF6@public.kitware.com> This is an automated email from the git hooks/post-receive script. It was generated because a ref change was pushed to the repository containing the project "CMake". The branch, master has been updated via a1e32626f735388f0ae17cf37265b2a9ac4abcdb (commit) from 33d9a691306956750bffb10be9d0b17a47c0ec0b (commit) Those revisions listed above that are new to this repository have not appeared on any other notification email; so we list those revisions in full, below. - Log ----------------------------------------------------------------- https://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=a1e32626f735388f0ae17cf37265b2a9ac4abcdb commit a1e32626f735388f0ae17cf37265b2a9ac4abcdb Author: Kitware Robot AuthorDate: Fri Aug 2 00:01:05 2019 -0400 Commit: Kitware Robot CommitDate: Fri Aug 2 00:01:05 2019 -0400 CMake Nightly Date Stamp diff --git a/Source/CMakeVersion.cmake b/Source/CMakeVersion.cmake index 529c0cf..22f9369 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 15) -set(CMake_VERSION_PATCH 20190801) +set(CMake_VERSION_PATCH 20190802) #set(CMake_VERSION_RC 0) set(CMake_VERSION_IS_DIRTY 0) ----------------------------------------------------------------------- Summary of changes: Source/CMakeVersion.cmake | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) hooks/post-receive -- CMake From kwrobot at kitware.com Fri Aug 2 10:41:02 2019 From: kwrobot at kitware.com (Kitware Robot) Date: Fri, 2 Aug 2019 10:41:02 -0400 (EDT) Subject: [Cmake-commits] CMake branch, master, updated. v3.15.1-557-g97d9876 Message-ID: <20190802144102.3C2641035B8@public.kitware.com> This is an automated email from the git hooks/post-receive script. It was generated because a ref change was pushed to the repository containing the project "CMake". The branch, master has been updated via 97d9876c78803879f3cd08a65dec9420873fcc92 (commit) via fa722a8792a770e682a329b6169843124b6af3f4 (commit) via 1ea751c8d156543c62c9e4b338a9bcf46c43b3b5 (commit) via 863f7eb6d7237b47a4347a2c517fd435a0edd44f (commit) from a1e32626f735388f0ae17cf37265b2a9ac4abcdb (commit) Those revisions listed above that are new to this repository have not appeared on any other notification email; so we list those revisions in full, below. - Log ----------------------------------------------------------------- https://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=97d9876c78803879f3cd08a65dec9420873fcc92 commit 97d9876c78803879f3cd08a65dec9420873fcc92 Merge: fa722a8 1ea751c Author: Brad King AuthorDate: Fri Aug 2 10:38:26 2019 -0400 Commit: Brad King CommitDate: Fri Aug 2 10:38:26 2019 -0400 Merge branch 'release-3.15' https://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=fa722a8792a770e682a329b6169843124b6af3f4 commit fa722a8792a770e682a329b6169843124b6af3f4 Merge: a1e3262 863f7eb Author: Brad King AuthorDate: Fri Aug 2 14:37:46 2019 +0000 Commit: Kitware Robot CommitDate: Fri Aug 2 10:37:57 2019 -0400 Merge topic 'clang-cl-non-windows' 863f7eb6d7 clang: Restore support for clang-cl on non-Windows hosts Acked-by: Kitware Robot Merge-request: !3634 ----------------------------------------------------------------------- Summary of changes: Modules/CMakeDetermineCompilerId.cmake | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) hooks/post-receive -- CMake From kwrobot at kitware.com Fri Aug 2 10:41:03 2019 From: kwrobot at kitware.com (Kitware Robot) Date: Fri, 2 Aug 2019 10:41:03 -0400 (EDT) Subject: [Cmake-commits] CMake branch, release, updated. v3.15.1-8-g1ea751c Message-ID: <20190802144103.6DC7411EADA@public.kitware.com> This is an automated email from the git hooks/post-receive script. It was generated because a ref change was pushed to the repository containing the project "CMake". The branch, release has been updated via 1ea751c8d156543c62c9e4b338a9bcf46c43b3b5 (commit) via 863f7eb6d7237b47a4347a2c517fd435a0edd44f (commit) from 7d98cd0442d695df809378dcd5a1eb0c3fb0928a (commit) Those revisions listed above that are new to this repository have not appeared on any other notification email; so we list those revisions in full, below. - Log ----------------------------------------------------------------- ----------------------------------------------------------------------- Summary of changes: Modules/CMakeDetermineCompilerId.cmake | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) hooks/post-receive -- CMake From kwrobot at kitware.com Fri Aug 2 11:00:56 2019 From: kwrobot at kitware.com (Kitware Robot) Date: Fri, 2 Aug 2019 11:00:56 -0400 (EDT) Subject: [Cmake-commits] CMake branch, master, updated. v3.15.1-565-g7bacf02 Message-ID: <20190802150056.A67231035B8@public.kitware.com> This is an automated email from the git hooks/post-receive script. It was generated because a ref change was pushed to the repository containing the project "CMake". The branch, master has been updated via 7bacf0233be03100b830e65cdd02a0d1fb2c2a13 (commit) via 94f7d19a983a4d5d9efc5e21d167a0a6a4ba18fa (commit) via a693e875db5d0939a316955f513396e533153b6d (commit) via 4aa555f9da5541d6b1f13b0cd3ec3e7387c75c89 (commit) via 75cf7ec263034e0212554f373bb6fd02d351163f (commit) via e5d3ea22d49e6d85082306d1f73d0689a3fbca81 (commit) via a7d0fe9c24e111bc4f325d608b31fdf394c24602 (commit) via 541361a58bae487956c5b50d475edc4fcb453030 (commit) from 97d9876c78803879f3cd08a65dec9420873fcc92 (commit) Those revisions listed above that are new to this repository have not appeared on any other notification email; so we list those revisions in full, below. - Log ----------------------------------------------------------------- https://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=7bacf0233be03100b830e65cdd02a0d1fb2c2a13 commit 7bacf0233be03100b830e65cdd02a0d1fb2c2a13 Merge: 94f7d19 a693e87 Author: Brad King AuthorDate: Fri Aug 2 14:56:50 2019 +0000 Commit: Kitware Robot CommitDate: Fri Aug 2 10:56:59 2019 -0400 Merge topic 'use_cmHasPrefix' a693e875db Cleanups: Use cmHas{Prefix,Suffix} instead of String{Starts,Ends}With Acked-by: Kitware Robot Merge-request: !3637 https://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=94f7d19a983a4d5d9efc5e21d167a0a6a4ba18fa commit 94f7d19a983a4d5d9efc5e21d167a0a6a4ba18fa Merge: 97d9876 4aa555f Author: Brad King AuthorDate: Fri Aug 2 14:55:11 2019 +0000 Commit: Kitware Robot CommitDate: Fri Aug 2 10:55:39 2019 -0400 Merge topic 'cmStringAlgorithms_modernize' 4aa555f9da Tests: Add CMakeLib.testStringAlgorithms test 75cf7ec263 cmStringAlgorithms: Modernize cmWrap using cm::string_view e5d3ea22d4 cmStringAlgorithms: Add cmCatViews and cmStrCat functions a7d0fe9c24 cmStringAlgorithms: Simplify cmJoin using cm::string_view 541361a58b cmStringAlgorithms: Simplify cmStrCmp using cm::string_view Acked-by: Kitware Robot Merge-request: !3628 https://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=a693e875db5d0939a316955f513396e533153b6d commit a693e875db5d0939a316955f513396e533153b6d Author: Sebastian Holtermann AuthorDate: Thu Aug 1 12:57:18 2019 +0200 Commit: Sebastian Holtermann CommitDate: Thu Aug 1 13:33:00 2019 +0200 Cleanups: Use cmHas{Prefix,Suffix} instead of String{Starts,Ends}With diff --git a/Source/CPack/cmCPackGenerator.cxx b/Source/CPack/cmCPackGenerator.cxx index 512ac7a..3fd124b 100644 --- a/Source/CPack/cmCPackGenerator.cxx +++ b/Source/CPack/cmCPackGenerator.cxx @@ -21,6 +21,7 @@ #include "cmMakefile.h" #include "cmState.h" #include "cmStateSnapshot.h" +#include "cmStringAlgorithms.h" #include "cmVersion.h" #include "cmWorkingDirectory.h" #include "cmXMLSafe.h" @@ -772,7 +773,7 @@ int cmCPackGenerator::InstallCMakeProject( // Make sure that DESTDIR + CPACK_INSTALL_PREFIX directory // exists: // - if (cmSystemTools::StringStartsWith(dir.c_str(), "/")) { + if (cmHasLiteralPrefix(dir, "/")) { dir = tempInstallDirectory + dir; } else { dir = tempInstallDirectory + "/" + dir; diff --git a/Source/CTest/cmCTestCoverageHandler.cxx b/Source/CTest/cmCTestCoverageHandler.cxx index f6028c4..54fe612 100644 --- a/Source/CTest/cmCTestCoverageHandler.cxx +++ b/Source/CTest/cmCTestCoverageHandler.cxx @@ -13,6 +13,7 @@ #include "cmParseGTMCoverage.h" #include "cmParseJacocoCoverage.h" #include "cmParsePHPCoverage.h" +#include "cmStringAlgorithms.h" #include "cmSystemTools.h" #include "cmWorkingDirectory.h" #include "cmXMLWriter.h" @@ -1181,7 +1182,7 @@ int cmCTestCoverageHandler::HandleGCovCoverage( // gcov 4.7 can have output lines saying "No executable lines" and // "Removing 'filename.gcov'"... Don't log those as "errors." if (line != "No executable lines" && - !cmSystemTools::StringStartsWith(line.c_str(), "Removing ")) { + !cmHasLiteralPrefix(line, "Removing ")) { cmCTestLog(this->CTest, ERROR_MESSAGE, "Unknown gcov output line: [" << line << "]" << std::endl); diff --git a/Source/CTest/cmCTestLaunch.cxx b/Source/CTest/cmCTestLaunch.cxx index 237ca82..bbf490e 100644 --- a/Source/CTest/cmCTestLaunch.cxx +++ b/Source/CTest/cmCTestLaunch.cxx @@ -16,6 +16,7 @@ #include "cmProcessOutput.h" #include "cmState.h" #include "cmStateSnapshot.h" +#include "cmStringAlgorithms.h" #include "cmSystemTools.h" #include "cmXMLWriter.h" #include "cmake.h" @@ -594,7 +595,7 @@ bool cmCTestLaunch::Match(std::string const& line, bool cmCTestLaunch::MatchesFilterPrefix(std::string const& line) const { return !this->OptionFilterPrefix.empty() && - cmSystemTools::StringStartsWith(line, this->OptionFilterPrefix.c_str()); + cmHasPrefix(line, this->OptionFilterPrefix); } int cmCTestLaunch::Main(int argc, const char* const argv[]) diff --git a/Source/CTest/cmParseJacocoCoverage.cxx b/Source/CTest/cmParseJacocoCoverage.cxx index b78142a..5f1e712 100644 --- a/Source/CTest/cmParseJacocoCoverage.cxx +++ b/Source/CTest/cmParseJacocoCoverage.cxx @@ -2,6 +2,7 @@ #include "cmCTest.h" #include "cmCTestCoverageHandler.h" +#include "cmStringAlgorithms.h" #include "cmSystemTools.h" #include "cmXMLParser.h" @@ -118,7 +119,7 @@ protected: // Check if any of the locations found match our package. for (std::string const& f : files) { std::string dir = cmsys::SystemTools::GetParentDirectory(f); - if (cmsys::SystemTools::StringEndsWith(dir, this->PackageName.c_str())) { + if (cmHasSuffix(dir, this->PackageName)) { cmCTestOptionalLog(this->CTest, HANDLER_VERBOSE_OUTPUT, "Found package directory for " << fileName << ": " << dir << std::endl, diff --git a/Source/cmCTest.cxx b/Source/cmCTest.cxx index 610e9f9..026250d 100644 --- a/Source/cmCTest.cxx +++ b/Source/cmCTest.cxx @@ -1965,7 +1965,7 @@ bool cmCTest::HandleCommandLineArguments(size_t& i, if (this->CheckArgument(arg, "-N", "--show-only")) { this->Impl->ShowOnly = true; } - if (cmSystemTools::StringStartsWith(arg.c_str(), "--show-only=")) { + if (cmHasLiteralPrefix(arg, "--show-only=")) { this->Impl->ShowOnly = true; // Check if a specific format is requested. Defaults to human readable @@ -2227,7 +2227,7 @@ int cmCTest::Run(std::vector& args, std::string* output) // attempts are simply ignored since previous ctest versions ignore // this too. (As well as many other unknown command line args.) // - if (arg != "-D" && cmSystemTools::StringStartsWith(arg.c_str(), "-D")) { + if (arg != "-D" && cmHasLiteralPrefix(arg, "-D")) { std::string input = arg.substr(2); this->AddVariableDefinition(input); } diff --git a/Source/cmCallVisualStudioMacro.cxx b/Source/cmCallVisualStudioMacro.cxx index f7a2244..9e152ff 100644 --- a/Source/cmCallVisualStudioMacro.cxx +++ b/Source/cmCallVisualStudioMacro.cxx @@ -4,6 +4,7 @@ #include +#include "cmStringAlgorithms.h" #include "cmSystemTools.h" #if defined(_MSC_VER) @@ -328,8 +329,7 @@ HRESULT FindVisualStudioInstances(const std::string& slnFile, if (SUCCEEDED(hr)) { std::map::iterator it; for (it = mrot.begin(); it != mrot.end(); ++it) { - if (cmSystemTools::StringStartsWith(it->first.c_str(), - "!VisualStudio.DTE.")) { + if (cmHasLiteralPrefix(it->first, "!VisualStudio.DTE.")) { IDispatchPtr disp(it->second); if (disp != (IDispatch*)0) { std::string slnName; diff --git a/Source/cmExportFileGenerator.cxx b/Source/cmExportFileGenerator.cxx index 8fd2947..87f9b4c 100644 --- a/Source/cmExportFileGenerator.cxx +++ b/Source/cmExportFileGenerator.cxx @@ -1209,8 +1209,8 @@ bool cmExportFileGenerator::PopulateExportProperties( targetProperties.GetPropertyValue("EXPORT_PROPERTIES")) { for (auto& prop : cmSystemTools::ExpandedListArgument(exportProperties)) { /* Black list reserved properties */ - if (cmSystemTools::StringStartsWith(prop, "IMPORTED_") || - cmSystemTools::StringStartsWith(prop, "INTERFACE_")) { + if (cmHasLiteralPrefix(prop, "IMPORTED_") || + cmHasLiteralPrefix(prop, "INTERFACE_")) { std::ostringstream e; e << "Target \"" << gte->Target->GetName() << "\" contains property \"" << prop << "\" in EXPORT_PROPERTIES but IMPORTED_* and INTERFACE_* " diff --git a/Source/cmFindProgramCommand.cxx b/Source/cmFindProgramCommand.cxx index 782f746..8fcf1ac 100644 --- a/Source/cmFindProgramCommand.cxx +++ b/Source/cmFindProgramCommand.cxx @@ -4,6 +4,7 @@ #include "cmMakefile.h" #include "cmStateTypes.h" +#include "cmStringAlgorithms.h" #include "cmSystemTools.h" class cmExecutionStatus; @@ -71,7 +72,7 @@ struct cmFindProgramHelper bool CheckDirectoryForName(std::string const& path, std::string const& name) { for (std::string const& ext : this->Extensions) { - if (!ext.empty() && cmSystemTools::StringEndsWith(name, ext.c_str())) { + if (!ext.empty() && cmHasSuffix(name, ext)) { continue; } this->TestNameExt = name; diff --git a/Source/cmGeneratorTarget.cxx b/Source/cmGeneratorTarget.cxx index 38f34ac..7340bc2 100644 --- a/Source/cmGeneratorTarget.cxx +++ b/Source/cmGeneratorTarget.cxx @@ -4192,7 +4192,7 @@ cmGeneratorTarget::GetTargetSourceFileFlags(const cmSourceFile* sf) const if (stripResources) { flags.MacFolder = ""; } - } else if (cmSystemTools::StringStartsWith(location, "Resources/")) { + } else if (cmHasLiteralPrefix(location, "Resources/")) { flags.Type = cmGeneratorTarget::SourceFileTypeDeepResource; if (stripResources) { flags.MacFolder += strlen("Resources/"); diff --git a/Source/cmGlobalVisualStudio7Generator.cxx b/Source/cmGlobalVisualStudio7Generator.cxx index 8401efb..bead0e3 100644 --- a/Source/cmGlobalVisualStudio7Generator.cxx +++ b/Source/cmGlobalVisualStudio7Generator.cxx @@ -8,7 +8,9 @@ #include "cmMakefile.h" #include "cmMessageType.h" #include "cmState.h" +#include "cmStringAlgorithms.h" #include "cmUuid.h" +#include "cm_string_view.hxx" #include "cmake.h" #include "cmsys/Encoding.hxx" @@ -432,16 +434,15 @@ void cmGlobalVisualStudio7Generator::WriteTargetDepends( void cmGlobalVisualStudio7Generator::WriteFolders(std::ostream& fout) { - const char* prefix = "CMAKE_FOLDER_GUID_"; - const std::string::size_type skip_prefix = strlen(prefix); + cm::string_view const prefix = "CMAKE_FOLDER_GUID_"; std::string guidProjectTypeFolder = "2150E333-8FDC-42A3-9474-1A3956D46DE8"; for (auto const& iter : VisualStudioFolders) { std::string fullName = iter.first; std::string guid = this->GetGUID(fullName); std::replace(fullName.begin(), fullName.end(), '/', '\\'); - if (cmSystemTools::StringStartsWith(fullName.c_str(), prefix)) { - fullName = fullName.substr(skip_prefix); + if (cmHasPrefix(fullName, prefix)) { + fullName = fullName.substr(prefix.size()); } std::string nameOnly = cmSystemTools::GetFilenameName(fullName); diff --git a/Source/cmQtAutoMocUic.cxx b/Source/cmQtAutoMocUic.cxx index 2aefe8f..0801c24 100644 --- a/Source/cmQtAutoMocUic.cxx +++ b/Source/cmQtAutoMocUic.cxx @@ -1894,7 +1894,7 @@ bool cmQtAutoMocUic::Init(cmMakefile* makefile) std::list::iterator it = includes.begin(); while (it != includes.end()) { std::string const& path = *it; - if (cmSystemTools::StringStartsWith(path, ppath->c_str())) { + if (cmHasPrefix(path, *ppath)) { MocConst_.IncludePaths.push_back(path); it = includes.erase(it); } else { diff --git a/Source/cmSourceGroupCommand.cxx b/Source/cmSourceGroupCommand.cxx index 04b4d72..ffdd0ce 100644 --- a/Source/cmSourceGroupCommand.cxx +++ b/Source/cmSourceGroupCommand.cxx @@ -9,6 +9,7 @@ #include "cmMakefile.h" #include "cmSourceGroup.h" +#include "cmStringAlgorithms.h" #include "cmSystemTools.h" namespace { @@ -54,7 +55,7 @@ bool rootIsPrefix(const std::string& root, const std::vector& files, std::string& error) { for (std::string const& file : files) { - if (!cmSystemTools::StringStartsWith(file, root.c_str())) { + if (!cmHasPrefix(file, root)) { error = "ROOT: " + root + " is not a prefix of file: " + file; return false; } diff --git a/Source/cmVisualStudioSlnParser.cxx b/Source/cmVisualStudioSlnParser.cxx index 9353276..3e7e142 100644 --- a/Source/cmVisualStudioSlnParser.cxx +++ b/Source/cmVisualStudioSlnParser.cxx @@ -2,6 +2,7 @@ file Copyright.txt or https://cmake.org/licensing for details. */ #include "cmVisualStudioSlnParser.h" +#include "cmStringAlgorithms.h" #include "cmSystemTools.h" #include "cmVisualStudioSlnData.h" #include "cmsys/FStream.hxx" @@ -192,8 +193,8 @@ bool cmVisualStudioSlnParser::State::Process( assert(!line.IsComment()); switch (this->Stack.top()) { case FileStateStart: - if (!cmSystemTools::StringStartsWith( - line.GetTag().c_str(), "Microsoft Visual Studio Solution File")) { + if (!cmHasLiteralPrefix(line.GetTag(), + "Microsoft Visual Studio Solution File")) { result.SetError(ResultErrorInputStructure, this->GetCurrentLine()); return false; } diff --git a/Source/cmake.cxx b/Source/cmake.cxx index b97152f..309efd3 100644 --- a/Source/cmake.cxx +++ b/Source/cmake.cxx @@ -2031,8 +2031,7 @@ void cmake::AppendGlobalGeneratorsDocumentation( for (cmGlobalGeneratorFactory* g : this->Generators) { cmDocumentationEntry e; g->GetDocumentation(e); - if (!foundDefaultOne && - cmSystemTools::StringStartsWith(e.Name, defaultName.c_str())) { + if (!foundDefaultOne && cmHasPrefix(e.Name, defaultName)) { e.CustomNamePrefix = '*'; foundDefaultOne = true; } https://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=4aa555f9da5541d6b1f13b0cd3ec3e7387c75c89 commit 4aa555f9da5541d6b1f13b0cd3ec3e7387c75c89 Author: Sebastian Holtermann AuthorDate: Wed Jul 31 12:44:51 2019 +0200 Commit: Sebastian Holtermann CommitDate: Thu Aug 1 11:45:04 2019 +0200 Tests: Add CMakeLib.testStringAlgorithms test diff --git a/Tests/CMakeLib/CMakeLists.txt b/Tests/CMakeLib/CMakeLists.txt index a25f25a..cd4dbc8 100644 --- a/Tests/CMakeLib/CMakeLists.txt +++ b/Tests/CMakeLib/CMakeLists.txt @@ -10,6 +10,7 @@ set(CMakeLib_TESTS testRST.cxx testRange.cxx testString.cxx + testStringAlgorithms.cxx testSystemTools.cxx testUTF8.cxx testXMLParser.cxx diff --git a/Tests/CMakeLib/testStringAlgorithms.cxx b/Tests/CMakeLib/testStringAlgorithms.cxx new file mode 100644 index 0000000..95616ff --- /dev/null +++ b/Tests/CMakeLib/testStringAlgorithms.cxx @@ -0,0 +1,134 @@ +/* Distributed under the OSI-approved BSD 3-Clause License. See accompanying + file Copyright.txt or https://cmake.org/licensing for details. */ + +#include // IWYU pragma: keep + +#include "cm_string_view.hxx" +#include +#include +#include +#include + +#include "cmStringAlgorithms.h" + +int testStringAlgorithms(int /*unused*/, char* /*unused*/ []) +{ + int failed = 0; + + auto assert_ok = [&failed](bool test, cm::string_view title) { + if (test) { + std::cout << "Passed: " << title << "\n"; + } else { + std::cout << "Failed: " << title << "\n"; + ++failed; + } + }; + + auto assert_string = [&failed](cm::string_view generated, + cm::string_view expected, + cm::string_view title) { + if (generated == expected) { + std::cout << "Passed: " << title << "\n"; + } else { + std::cout << "Failed: " << title << "\n"; + std::cout << "Expected: " << expected << "\n"; + std::cout << "Got: " << generated << "\n"; + ++failed; + } + }; + + // ---------------------------------------------------------------------- + // Test cmJoin + { + typedef std::string ST; + typedef std::vector VT; + assert_string(cmJoin(ST("abc"), ";"), "a;b;c", "cmJoin std::string"); + assert_string(cmJoin(VT{}, ";"), "", "cmJoin std::vector empty"); + assert_string(cmJoin(VT{ "a" }, ";"), "a", "cmJoin std::vector single"); + assert_string(cmJoin(VT{ "a", "b", "c" }, ";"), "a;b;c", + "cmJoin std::vector multiple"); + assert_string(cmJoin(VT{ "a", "b", "c" }, "<=>"), "a<=>b<=>c", + "cmJoin std::vector long sep"); + } + + // ---------------------------------------------------------------------- + // Test cmStrCat + { + int ni = -1100; + unsigned int nui = 1100u; + long int nli = -12000l; + unsigned long int nuli = 12000ul; + long long int nlli = -130000ll; + unsigned long long int nulli = 130000ull; + std::string val = + cmStrCat("", ni, ',', nui, ',', nli, ",", nuli, ", ", nlli, + std::string(", "), nulli, cm::string_view("")); + std::string expect = + "-1100,1100,-12000,12000, -130000, 130000"; + assert_string(val, expect, "cmStrCat strings and integers"); + } + { + float const val = 1.5f; + float const div = 0.00001f; + float f = 0.0f; + std::istringstream(cmStrCat("", val)) >> f; + f -= val; + assert_ok((f < div) && (f > -div), "cmStrCat float"); + } + { + double const val = 1.5; + double const div = 0.00001; + double d = 0.0; + std::istringstream(cmStrCat("", val)) >> d; + d -= val; + assert_ok((d < div) && (d > -div), "cmStrCat double"); + } + + // ---------------------------------------------------------------------- + // Test cmWrap + { + typedef std::vector VT; + assert_string(cmWrap("<", VT{}, ">", "; "), // + "", // + "cmWrap empty, string prefix and suffix"); + assert_string(cmWrap("<", VT{ "abc" }, ">", "; "), // + "", // + "cmWrap single, string prefix and suffix"); + assert_string(cmWrap("<", VT{ "a1", "a2", "a3" }, ">", "; "), // + "; ; ", // + "cmWrap multiple, string prefix and suffix"); + + assert_string(cmWrap('<', VT{}, '>', "; "), // + "", // + "cmWrap empty, char prefix and suffix"); + assert_string(cmWrap('<', VT{ "abc" }, '>', "; "), // + "", // + "cmWrap single, char prefix and suffix"); + assert_string(cmWrap('<', VT{ "a1", "a2", "a3" }, '>', "; "), // + "; ; ", // + "cmWrap multiple, char prefix and suffix"); + } + + // ---------------------------------------------------------------------- + // Test cmHas(Literal)Prefix and cmHas(Literal)Suffix + { + std::string str("abc"); + assert_ok(cmHasPrefix(str, 'a'), "cmHasPrefix char"); + assert_ok(!cmHasPrefix(str, 'c'), "cmHasPrefix char not"); + assert_ok(cmHasPrefix(str, "ab"), "cmHasPrefix string"); + assert_ok(!cmHasPrefix(str, "bc"), "cmHasPrefix string not"); + assert_ok(cmHasPrefix(str, str), "cmHasPrefix complete string"); + assert_ok(cmHasLiteralPrefix(str, "ab"), "cmHasLiteralPrefix string"); + assert_ok(!cmHasLiteralPrefix(str, "bc"), "cmHasLiteralPrefix string not"); + + assert_ok(cmHasSuffix(str, 'c'), "cmHasSuffix char"); + assert_ok(!cmHasSuffix(str, 'a'), "cmHasSuffix char not"); + assert_ok(cmHasSuffix(str, "bc"), "cmHasSuffix string"); + assert_ok(!cmHasSuffix(str, "ab"), "cmHasSuffix string not"); + assert_ok(cmHasSuffix(str, str), "cmHasSuffix complete string"); + assert_ok(cmHasLiteralSuffix(str, "bc"), "cmHasLiteralSuffix string"); + assert_ok(!cmHasLiteralSuffix(str, "ab"), "cmHasLiteralPrefix string not"); + } + + return failed; +} https://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=75cf7ec263034e0212554f373bb6fd02d351163f commit 75cf7ec263034e0212554f373bb6fd02d351163f Author: Sebastian Holtermann AuthorDate: Wed Jul 31 22:07:05 2019 +0200 Commit: Sebastian Holtermann CommitDate: Thu Aug 1 11:45:04 2019 +0200 cmStringAlgorithms: Modernize cmWrap using cm::string_view diff --git a/Source/cmStringAlgorithms.h b/Source/cmStringAlgorithms.h index 3037bef..cdb494f 100644 --- a/Source/cmStringAlgorithms.h +++ b/Source/cmStringAlgorithms.h @@ -98,21 +98,25 @@ inline std::string cmStrCat(cmAlphaNum const& a, cmAlphaNum const& b, { a.View(), b.View(), static_cast(args).View()... }); } +/** Joins wrapped elements of a range with separator into a single string. */ template -std::string cmWrap(std::string const& prefix, Range const& r, - std::string const& suffix, std::string const& sep) +std::string cmWrap(cm::string_view prefix, Range const& rng, + cm::string_view suffix, cm::string_view sep) { - if (r.empty()) { + if (rng.empty()) { return std::string(); } - return prefix + cmJoin(r, suffix + sep + prefix) + suffix; + return cmCatViews( + { prefix, cmJoin(rng, cmCatViews({ suffix, sep, prefix })), suffix }); } +/** Joins wrapped elements of a range with separator into a single string. */ template -std::string cmWrap(char prefix, Range const& r, char suffix, - std::string const& sep) +std::string cmWrap(char prefix, Range const& rng, char suffix, + cm::string_view sep) { - return cmWrap(std::string(1, prefix), r, std::string(1, suffix), sep); + return cmWrap(cm::string_view(&prefix, 1), rng, cm::string_view(&suffix, 1), + sep); } /** Returns true if string @a str starts with the character @a prefix. */ https://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=e5d3ea22d49e6d85082306d1f73d0689a3fbca81 commit e5d3ea22d49e6d85082306d1f73d0689a3fbca81 Author: Sebastian Holtermann AuthorDate: Mon Jul 29 17:34:54 2019 +0200 Commit: Sebastian Holtermann CommitDate: Thu Aug 1 11:45:04 2019 +0200 cmStringAlgorithms: Add cmCatViews and cmStrCat functions diff --git a/Source/CMakeLists.txt b/Source/CMakeLists.txt index 041c606..fe40af3 100644 --- a/Source/CMakeLists.txt +++ b/Source/CMakeLists.txt @@ -404,6 +404,7 @@ set(SRCS cmStateSnapshot.cxx cmStateSnapshot.h cmStateTypes.h + cmStringAlgorithms.cxx cmStringAlgorithms.h cmSystemTools.cxx cmSystemTools.h diff --git a/Source/cmStringAlgorithms.cxx b/Source/cmStringAlgorithms.cxx new file mode 100644 index 0000000..5deb9b0 --- /dev/null +++ b/Source/cmStringAlgorithms.cxx @@ -0,0 +1,73 @@ +/* Distributed under the OSI-approved BSD 3-Clause License. See accompanying + file Copyright.txt or https://cmake.org/licensing for details. */ +#include "cmStringAlgorithms.h" + +#include +#include + +namespace { +template +inline void MakeDigits(cm::string_view& view, char (&digits)[N], + const char* pattern, T value) +{ + int res = std::snprintf(digits, N, pattern, value); + if (res > 0 && res < static_cast(N)) { + view = cm::string_view(digits, static_cast(res)); + } +} +} // unnamed namespace + +cmAlphaNum::cmAlphaNum(int val) +{ + MakeDigits(View_, Digits_, "%i", val); +} + +cmAlphaNum::cmAlphaNum(unsigned int val) +{ + MakeDigits(View_, Digits_, "%u", val); +} + +cmAlphaNum::cmAlphaNum(long int val) +{ + MakeDigits(View_, Digits_, "%li", val); +} + +cmAlphaNum::cmAlphaNum(unsigned long int val) +{ + MakeDigits(View_, Digits_, "%lu", val); +} + +cmAlphaNum::cmAlphaNum(long long int val) +{ + MakeDigits(View_, Digits_, "%lli", val); +} + +cmAlphaNum::cmAlphaNum(unsigned long long int val) +{ + MakeDigits(View_, Digits_, "%llu", val); +} + +cmAlphaNum::cmAlphaNum(float val) +{ + MakeDigits(View_, Digits_, "%g", static_cast(val)); +} + +cmAlphaNum::cmAlphaNum(double val) +{ + MakeDigits(View_, Digits_, "%g", val); +} + +std::string cmCatViews(std::initializer_list views) +{ + std::size_t total_size = 0; + for (cm::string_view const& view : views) { + total_size += view.size(); + } + + std::string result(total_size, '\0'); + std::string::iterator sit = result.begin(); + for (cm::string_view const& view : views) { + sit = std::copy_n(view.data(), view.size(), sit); + } + return result; +} diff --git a/Source/cmStringAlgorithms.h b/Source/cmStringAlgorithms.h index 8d6aec6..3037bef 100644 --- a/Source/cmStringAlgorithms.h +++ b/Source/cmStringAlgorithms.h @@ -7,6 +7,7 @@ #include "cmRange.h" #include "cm_string_view.hxx" +#include #include #include #include @@ -48,6 +49,55 @@ std::string cmJoin(Range const& rng, cm::string_view separator) return os.str(); } +/** Concatenate string pieces into a single string. */ +std::string cmCatViews(std::initializer_list views); + +/** Utility class for cmStrCat. */ +class cmAlphaNum +{ +public: + cmAlphaNum(cm::string_view view) + : View_(view) + { + } + cmAlphaNum(std::string const& str) + : View_(str) + { + } + cmAlphaNum(const char* str) + : View_(str) + { + } + cmAlphaNum(char ch) + : View_(Digits_, 1) + { + Digits_[0] = ch; + } + cmAlphaNum(int val); + cmAlphaNum(unsigned int val); + cmAlphaNum(long int val); + cmAlphaNum(unsigned long int val); + cmAlphaNum(long long int val); + cmAlphaNum(unsigned long long int val); + cmAlphaNum(float val); + cmAlphaNum(double val); + + cm::string_view View() const { return View_; } + +private: + cm::string_view View_; + char Digits_[32]; +}; + +/** Concatenate string pieces and numbers into a single string. */ +template +inline std::string cmStrCat(cmAlphaNum const& a, cmAlphaNum const& b, + AV const&... args) +{ + return cmCatViews( + { a.View(), b.View(), static_cast(args).View()... }); +} + template std::string cmWrap(std::string const& prefix, Range const& r, std::string const& suffix, std::string const& sep) diff --git a/bootstrap b/bootstrap index 7d9631c..ac5adc8 100755 --- a/bootstrap +++ b/bootstrap @@ -422,6 +422,7 @@ CMAKE_CXX_SOURCES="\ cmState \ cmStateDirectory \ cmStateSnapshot \ + cmStringAlgorithms \ cmStringReplaceHelper \ cmStringCommand \ cmSubdirCommand \ https://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=a7d0fe9c24e111bc4f325d608b31fdf394c24602 commit a7d0fe9c24e111bc4f325d608b31fdf394c24602 Author: Sebastian Holtermann AuthorDate: Mon Jul 29 15:15:00 2019 +0200 Commit: Sebastian Holtermann CommitDate: Thu Aug 1 10:38:12 2019 +0200 cmStringAlgorithms: Simplify cmJoin using cm::string_view diff --git a/Source/cmStringAlgorithms.h b/Source/cmStringAlgorithms.h index 3f88692..8d6aec6 100644 --- a/Source/cmStringAlgorithms.h +++ b/Source/cmStringAlgorithms.h @@ -7,8 +7,6 @@ #include "cmRange.h" #include "cm_string_view.hxx" -#include -#include #include #include #include @@ -32,32 +30,25 @@ private: std::string const Test_; }; +/** Joins elements of a range with separator into a single string. */ template -std::string cmJoin(Range const& r, const char* delimiter) +std::string cmJoin(Range const& rng, cm::string_view separator) { - if (r.empty()) { + if (rng.empty()) { return std::string(); } - std::ostringstream os; - typedef typename Range::value_type ValueType; - typedef typename Range::const_iterator InputIt; - const InputIt first = r.begin(); - InputIt last = r.end(); - --last; - std::copy(first, last, std::ostream_iterator(os, delimiter)); - - os << *last; + std::ostringstream os; + auto it = rng.begin(); + auto const end = rng.end(); + os << *it; + while (++it != end) { + os << separator << *it; + } return os.str(); } template -std::string cmJoin(Range const& r, std::string const& delimiter) -{ - return cmJoin(r, delimiter.c_str()); -} - -template std::string cmWrap(std::string const& prefix, Range const& r, std::string const& suffix, std::string const& sep) { https://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=541361a58bae487956c5b50d475edc4fcb453030 commit 541361a58bae487956c5b50d475edc4fcb453030 Author: Sebastian Holtermann AuthorDate: Mon Jul 29 14:47:10 2019 +0200 Commit: Sebastian Holtermann CommitDate: Thu Aug 1 10:38:12 2019 +0200 cmStringAlgorithms: Simplify cmStrCmp using cm::string_view diff --git a/Source/cmStringAlgorithms.h b/Source/cmStringAlgorithms.h index 149e0ad..3f88692 100644 --- a/Source/cmStringAlgorithms.h +++ b/Source/cmStringAlgorithms.h @@ -15,28 +15,21 @@ #include #include +/** String range type. */ typedef cmRange::const_iterator> cmStringRange; +/** Callable string comparison struct. */ struct cmStrCmp { - cmStrCmp(const char* test) - : m_test(test) + cmStrCmp(std::string str) + : Test_(std::move(str)) { } - cmStrCmp(std::string test) - : m_test(std::move(test)) - { - } - - bool operator()(const std::string& input) const { return m_test == input; } - bool operator()(const char* input) const - { - return strcmp(input, m_test.c_str()) == 0; - } + bool operator()(cm::string_view sv) const { return Test_ == sv; } private: - const std::string m_test; + std::string const Test_; }; template @@ -81,46 +74,46 @@ std::string cmWrap(char prefix, Range const& r, char suffix, return cmWrap(std::string(1, prefix), r, std::string(1, suffix), sep); } -/** Returns true if string @a str starts with the character @a prefix. **/ +/** Returns true if string @a str starts with the character @a prefix. */ inline bool cmHasPrefix(cm::string_view str, char prefix) { return !str.empty() && (str.front() == prefix); } -/** Returns true if string @a str starts with string @a prefix. **/ +/** Returns true if string @a str starts with string @a prefix. */ inline bool cmHasPrefix(cm::string_view str, cm::string_view prefix) { return str.compare(0, prefix.size(), prefix) == 0; } -/** Returns true if string @a str starts with string @a prefix. **/ +/** Returns true if string @a str starts with string @a prefix. */ template inline bool cmHasLiteralPrefix(cm::string_view str, const char (&prefix)[N]) { return cmHasPrefix(str, cm::string_view(prefix, N - 1)); } -/** Returns true if string @a str ends with the character @a suffix. **/ +/** Returns true if string @a str ends with the character @a suffix. */ inline bool cmHasSuffix(cm::string_view str, char suffix) { return !str.empty() && (str.back() == suffix); } -/** Returns true if string @a str ends with string @a suffix. **/ +/** Returns true if string @a str ends with string @a suffix. */ inline bool cmHasSuffix(cm::string_view str, cm::string_view suffix) { return str.size() >= suffix.size() && str.compare(str.size() - suffix.size(), suffix.size(), suffix) == 0; } -/** Returns true if string @a str ends with string @a suffix. **/ +/** Returns true if string @a str ends with string @a suffix. */ template inline bool cmHasLiteralSuffix(cm::string_view str, const char (&suffix)[N]) { return cmHasSuffix(str, cm::string_view(suffix, N - 1)); } -/** Removes an existing suffix character of from the string @a str. **/ +/** Removes an existing suffix character of from the string @a str. */ inline void cmStripSuffixIfExists(std::string& str, char suffix) { if (cmHasSuffix(str, suffix)) { @@ -128,7 +121,7 @@ inline void cmStripSuffixIfExists(std::string& str, char suffix) } } -/** Removes an existing suffix string of from the string @a str. **/ +/** Removes an existing suffix string of from the string @a str. */ inline void cmStripSuffixIfExists(std::string& str, cm::string_view suffix) { if (cmHasSuffix(str, suffix)) { ----------------------------------------------------------------------- Summary of changes: Source/CMakeLists.txt | 1 + Source/CPack/cmCPackGenerator.cxx | 3 +- Source/CTest/cmCTestCoverageHandler.cxx | 3 +- Source/CTest/cmCTestLaunch.cxx | 3 +- Source/CTest/cmParseJacocoCoverage.cxx | 3 +- Source/cmCTest.cxx | 4 +- Source/cmCallVisualStudioMacro.cxx | 4 +- Source/cmExportFileGenerator.cxx | 4 +- Source/cmFindProgramCommand.cxx | 3 +- Source/cmGeneratorTarget.cxx | 2 +- Source/cmGlobalVisualStudio7Generator.cxx | 9 +- Source/cmQtAutoMocUic.cxx | 2 +- Source/cmSourceGroupCommand.cxx | 3 +- Source/cmStringAlgorithms.cxx | 73 ++++++++++++++++ Source/cmStringAlgorithms.h | 126 ++++++++++++++++++---------- Source/cmVisualStudioSlnParser.cxx | 5 +- Source/cmake.cxx | 3 +- Tests/CMakeLib/CMakeLists.txt | 1 + Tests/CMakeLib/testStringAlgorithms.cxx | 134 ++++++++++++++++++++++++++++++ bootstrap | 1 + 20 files changed, 321 insertions(+), 66 deletions(-) create mode 100644 Source/cmStringAlgorithms.cxx create mode 100644 Tests/CMakeLib/testStringAlgorithms.cxx hooks/post-receive -- CMake From kwrobot at kitware.com Sat Aug 3 00:03:07 2019 From: kwrobot at kitware.com (Kitware Robot) Date: Sat, 3 Aug 2019 00:03:07 -0400 (EDT) Subject: [Cmake-commits] CMake branch, master, updated. v3.15.1-566-g2a5d077 Message-ID: <20190803040307.890ED11FCBC@public.kitware.com> This is an automated email from the git hooks/post-receive script. It was generated because a ref change was pushed to the repository containing the project "CMake". The branch, master has been updated via 2a5d077a89ea3ef08409e4d3e043ae78c9d8132d (commit) from 7bacf0233be03100b830e65cdd02a0d1fb2c2a13 (commit) Those revisions listed above that are new to this repository have not appeared on any other notification email; so we list those revisions in full, below. - Log ----------------------------------------------------------------- https://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=2a5d077a89ea3ef08409e4d3e043ae78c9d8132d commit 2a5d077a89ea3ef08409e4d3e043ae78c9d8132d Author: Kitware Robot AuthorDate: Sat Aug 3 00:01:09 2019 -0400 Commit: Kitware Robot CommitDate: Sat Aug 3 00:01:09 2019 -0400 CMake Nightly Date Stamp diff --git a/Source/CMakeVersion.cmake b/Source/CMakeVersion.cmake index 22f9369..04564a0 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 15) -set(CMake_VERSION_PATCH 20190802) +set(CMake_VERSION_PATCH 20190803) #set(CMake_VERSION_RC 0) set(CMake_VERSION_IS_DIRTY 0) ----------------------------------------------------------------------- Summary of changes: Source/CMakeVersion.cmake | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) hooks/post-receive -- CMake From kwrobot at kitware.com Sun Aug 4 00:02:32 2019 From: kwrobot at kitware.com (Kitware Robot) Date: Sun, 4 Aug 2019 00:02:32 -0400 (EDT) Subject: [Cmake-commits] CMake branch, master, updated. v3.15.1-567-g18a0d47 Message-ID: <20190804040232.A57861278EE@public.kitware.com> This is an automated email from the git hooks/post-receive script. It was generated because a ref change was pushed to the repository containing the project "CMake". The branch, master has been updated via 18a0d47bec856c327b431cf4270a3a816d0477ce (commit) from 2a5d077a89ea3ef08409e4d3e043ae78c9d8132d (commit) Those revisions listed above that are new to this repository have not appeared on any other notification email; so we list those revisions in full, below. - Log ----------------------------------------------------------------- https://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=18a0d47bec856c327b431cf4270a3a816d0477ce commit 18a0d47bec856c327b431cf4270a3a816d0477ce Author: Kitware Robot AuthorDate: Sun Aug 4 00:01:07 2019 -0400 Commit: Kitware Robot CommitDate: Sun Aug 4 00:01:07 2019 -0400 CMake Nightly Date Stamp diff --git a/Source/CMakeVersion.cmake b/Source/CMakeVersion.cmake index 04564a0..a0f21de 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 15) -set(CMake_VERSION_PATCH 20190803) +set(CMake_VERSION_PATCH 20190804) #set(CMake_VERSION_RC 0) set(CMake_VERSION_IS_DIRTY 0) ----------------------------------------------------------------------- Summary of changes: Source/CMakeVersion.cmake | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) hooks/post-receive -- CMake From kwrobot at kitware.com Mon Aug 5 00:01:57 2019 From: kwrobot at kitware.com (Kitware Robot) Date: Mon, 5 Aug 2019 00:01:57 -0400 (EDT) Subject: [Cmake-commits] CMake branch, master, updated. v3.15.1-568-g3ebd3fa Message-ID: <20190805040157.8A0D1127AB1@public.kitware.com> This is an automated email from the git hooks/post-receive script. It was generated because a ref change was pushed to the repository containing the project "CMake". The branch, master has been updated via 3ebd3fa51d229e0067e8ca24f8fa4ed35ee5dac8 (commit) from 18a0d47bec856c327b431cf4270a3a816d0477ce (commit) Those revisions listed above that are new to this repository have not appeared on any other notification email; so we list those revisions in full, below. - Log ----------------------------------------------------------------- https://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=3ebd3fa51d229e0067e8ca24f8fa4ed35ee5dac8 commit 3ebd3fa51d229e0067e8ca24f8fa4ed35ee5dac8 Author: Kitware Robot AuthorDate: Mon Aug 5 00:01:06 2019 -0400 Commit: Kitware Robot CommitDate: Mon Aug 5 00:01:06 2019 -0400 CMake Nightly Date Stamp diff --git a/Source/CMakeVersion.cmake b/Source/CMakeVersion.cmake index a0f21de..3bbbd28 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 15) -set(CMake_VERSION_PATCH 20190804) +set(CMake_VERSION_PATCH 20190805) #set(CMake_VERSION_RC 0) set(CMake_VERSION_IS_DIRTY 0) ----------------------------------------------------------------------- Summary of changes: Source/CMakeVersion.cmake | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) hooks/post-receive -- CMake From kwrobot at kitware.com Mon Aug 5 10:21:45 2019 From: kwrobot at kitware.com (Kitware Robot) Date: Mon, 5 Aug 2019 10:21:45 -0400 (EDT) Subject: [Cmake-commits] CMake branch, master, updated. v3.15.1-570-g7eb2fd6 Message-ID: <20190805142145.148D911376E@public.kitware.com> This is an automated email from the git hooks/post-receive script. It was generated because a ref change was pushed to the repository containing the project "CMake". The branch, master has been updated via 7eb2fd6ca68e2681a08aef8b1dd8db253b172e00 (commit) via d70a0f8681919713940d254f9e23141f69f68c31 (commit) from 3ebd3fa51d229e0067e8ca24f8fa4ed35ee5dac8 (commit) Those revisions listed above that are new to this repository have not appeared on any other notification email; so we list those revisions in full, below. - Log ----------------------------------------------------------------- https://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=7eb2fd6ca68e2681a08aef8b1dd8db253b172e00 commit 7eb2fd6ca68e2681a08aef8b1dd8db253b172e00 Merge: 3ebd3fa d70a0f8 Author: Brad King AuthorDate: Mon Aug 5 14:20:13 2019 +0000 Commit: Kitware Robot CommitDate: Mon Aug 5 10:20:27 2019 -0400 Merge topic 'fileapi-install-generators' d70a0f8681 fileapi: Fix codemodel target install destination for cross-dir rules Acked-by: Kitware Robot Merge-request: !3639 https://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=d70a0f8681919713940d254f9e23141f69f68c31 commit d70a0f8681919713940d254f9e23141f69f68c31 Author: Brad King AuthorDate: Wed Jul 31 15:17:45 2019 -0400 Commit: Brad King CommitDate: Wed Jul 31 19:32:55 2019 -0400 fileapi: Fix codemodel target install destination for cross-dir rules Since commit e89ad0f94e (install: Allow installing targets created in another directory, 2018-06-18, v3.13.0-rc1~407^2) we support calling `install(TARGETS)` for targets created in another directory. However, install generators are associated with the directory in which the call to `install()` appears. This may not be the same directory in which the target is defined. Record in each target the list of install generators it has. Fixes: #19546 diff --git a/Source/cmFileAPICodemodel.cxx b/Source/cmFileAPICodemodel.cxx index 0fb166a..6025025 100644 --- a/Source/cmFileAPICodemodel.cxx +++ b/Source/cmFileAPICodemodel.cxx @@ -1025,12 +1025,9 @@ Json::Value Target::DumpInstallPrefix() Json::Value Target::DumpInstallDestinations() { Json::Value destinations = Json::arrayValue; - auto installGens = this->GT->Makefile->GetInstallGenerators(); - for (auto iGen : installGens) { - auto itGen = dynamic_cast(iGen); - if (itGen != nullptr && itGen->GetTarget() == this->GT) { - destinations.append(this->DumpInstallDestination(itGen)); - } + auto installGens = this->GT->Target->GetInstallGenerators(); + for (auto itGen : installGens) { + destinations.append(this->DumpInstallDestination(itGen)); } return destinations; } diff --git a/Source/cmInstallCommand.cxx b/Source/cmInstallCommand.cxx index dba4bbb..c9e6923 100644 --- a/Source/cmInstallCommand.cxx +++ b/Source/cmInstallCommand.cxx @@ -43,11 +43,13 @@ static cmInstallTargetGenerator* CreateInstallTargetGenerator( target.SetHaveInstallRule(true); const char* component = namelink ? args.GetNamelinkComponent().c_str() : args.GetComponent().c_str(); - return new cmInstallTargetGenerator( + auto g = new cmInstallTargetGenerator( target.GetName(), destination.c_str(), impLib, args.GetPermissions().c_str(), args.GetConfigurations(), component, message, args.GetExcludeFromAll(), args.GetOptional() || forceOpt, backtrace); + target.AddInstallGenerator(g); + return g; } static cmInstallTargetGenerator* CreateInstallTargetGenerator( diff --git a/Source/cmTarget.cxx b/Source/cmTarget.cxx index cd67586..a67122c 100644 --- a/Source/cmTarget.cxx +++ b/Source/cmTarget.cxx @@ -177,6 +177,7 @@ public: std::vector PreBuildCommands; std::vector PreLinkCommands; std::vector PostBuildCommands; + std::vector InstallGenerators; std::set SystemIncludeDirectories; cmTarget::LinkLibraryVectorType OriginalLinkLibraries; std::vector IncludeDirectoriesEntries; @@ -857,6 +858,17 @@ void cmTarget::SetHaveInstallRule(bool hir) impl->HaveInstallRule = hir; } +void cmTarget::AddInstallGenerator(cmInstallTargetGenerator* g) +{ + impl->InstallGenerators.emplace_back(g); +} + +std::vector const& cmTarget::GetInstallGenerators() + const +{ + return impl->InstallGenerators; +} + bool cmTarget::GetIsGeneratorProvided() const { return impl->IsGeneratorProvided; diff --git a/Source/cmTarget.h b/Source/cmTarget.h index fdcca47..2bd9e6d 100644 --- a/Source/cmTarget.h +++ b/Source/cmTarget.h @@ -20,6 +20,7 @@ class cmCustomCommand; class cmGlobalGenerator; +class cmInstallTargetGenerator; class cmMakefile; class cmMessenger; class cmPropertyMap; @@ -146,6 +147,9 @@ public: bool GetHaveInstallRule() const; void SetHaveInstallRule(bool hir); + void AddInstallGenerator(cmInstallTargetGenerator* g); + std::vector const& GetInstallGenerators() const; + /** * Get/Set whether this target was auto-created by a generator. */ diff --git a/Tests/RunCMake/FileAPI/codemodel-v2-check.py b/Tests/RunCMake/FileAPI/codemodel-v2-check.py index 18b9347..3096358 100644 --- a/Tests/RunCMake/FileAPI/codemodel-v2-check.py +++ b/Tests/RunCMake/FileAPI/codemodel-v2-check.py @@ -2087,7 +2087,40 @@ def gen_check_targets(c, g, inSource): ], "build": "^cxx$", "source": "^cxx$", - "install": None, + "install": { + "prefix": "^(/usr/local|[A-Za-z]:.*/codemodel-v2)$", + "destinations": [ + { + "path": "bin", + "backtrace": [ + { + "file": "^codemodel-v2\\.cmake$", + "line": 37, + "command": "install", + "hasParent": True, + }, + { + "file": "^codemodel-v2\\.cmake$", + "line": None, + "command": None, + "hasParent": True, + }, + { + "file": "^CMakeLists\\.txt$", + "line": 3, + "command": "include", + "hasParent": True, + }, + { + "file": "^CMakeLists\\.txt$", + "line": None, + "command": None, + "hasParent": False, + }, + ], + }, + ], + }, "link": { "language": "CXX", "lto": None, diff --git a/Tests/RunCMake/FileAPI/codemodel-v2.cmake b/Tests/RunCMake/FileAPI/codemodel-v2.cmake index 72073d5..c98a84c 100644 --- a/Tests/RunCMake/FileAPI/codemodel-v2.cmake +++ b/Tests/RunCMake/FileAPI/codemodel-v2.cmake @@ -33,3 +33,5 @@ if(_ipo) set_property(TARGET c_static_lib PROPERTY INTERPROCEDURAL_OPTIMIZATION ON) file(WRITE "${CMAKE_BINARY_DIR}/ipo_enabled.txt" "") endif() + +install(TARGETS cxx_exe) ----------------------------------------------------------------------- Summary of changes: Source/cmFileAPICodemodel.cxx | 9 +++---- Source/cmInstallCommand.cxx | 4 +++- Source/cmTarget.cxx | 12 ++++++++++ Source/cmTarget.h | 4 ++++ Tests/RunCMake/FileAPI/codemodel-v2-check.py | 35 +++++++++++++++++++++++++++- Tests/RunCMake/FileAPI/codemodel-v2.cmake | 2 ++ 6 files changed, 58 insertions(+), 8 deletions(-) hooks/post-receive -- CMake From kwrobot at kitware.com Mon Aug 5 10:31:42 2019 From: kwrobot at kitware.com (Kitware Robot) Date: Mon, 5 Aug 2019 10:31:42 -0400 (EDT) Subject: [Cmake-commits] CMake branch, release, updated. v3.15.1-10-gedca8d5 Message-ID: <20190805143142.5526B10EFEB@public.kitware.com> This is an automated email from the git hooks/post-receive script. It was generated because a ref change was pushed to the repository containing the project "CMake". The branch, release has been updated via edca8d5c3ad34a829e0d4af36a9fd8818603d457 (commit) via d70a0f8681919713940d254f9e23141f69f68c31 (commit) from 1ea751c8d156543c62c9e4b338a9bcf46c43b3b5 (commit) Those revisions listed above that are new to this repository have not appeared on any other notification email; so we list those revisions in full, below. - Log ----------------------------------------------------------------- ----------------------------------------------------------------------- Summary of changes: Source/cmFileAPICodemodel.cxx | 9 +++---- Source/cmInstallCommand.cxx | 4 +++- Source/cmTarget.cxx | 12 ++++++++++ Source/cmTarget.h | 4 ++++ Tests/RunCMake/FileAPI/codemodel-v2-check.py | 35 +++++++++++++++++++++++++++- Tests/RunCMake/FileAPI/codemodel-v2.cmake | 2 ++ 6 files changed, 58 insertions(+), 8 deletions(-) hooks/post-receive -- CMake From kwrobot at kitware.com Mon Aug 5 10:31:42 2019 From: kwrobot at kitware.com (Kitware Robot) Date: Mon, 5 Aug 2019 10:31:42 -0400 (EDT) Subject: [Cmake-commits] CMake branch, master, updated. v3.15.1-574-g26a3bcc Message-ID: <20190805143142.4264710A87E@public.kitware.com> This is an automated email from the git hooks/post-receive script. It was generated because a ref change was pushed to the repository containing the project "CMake". The branch, master has been updated via 26a3bccb60b1ba97b528187c244acf4c3bbceb3e (commit) via e9ade44cb13c35994d65ef6ae125e97c5514ba9b (commit) via f6d6dbc2933248dc7f17fd033e2b70fb161fddbd (commit) via edca8d5c3ad34a829e0d4af36a9fd8818603d457 (commit) from 7eb2fd6ca68e2681a08aef8b1dd8db253b172e00 (commit) Those revisions listed above that are new to this repository have not appeared on any other notification email; so we list those revisions in full, below. - Log ----------------------------------------------------------------- https://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=26a3bccb60b1ba97b528187c244acf4c3bbceb3e commit 26a3bccb60b1ba97b528187c244acf4c3bbceb3e Merge: e9ade44 f6d6dbc Author: Brad King AuthorDate: Mon Aug 5 14:31:04 2019 +0000 Commit: Kitware Robot CommitDate: Mon Aug 5 10:31:18 2019 -0400 Merge topic 'link-library-file-flag' f6d6dbc293 Make CMAKE_LINK_LIBRARY_FILE_FLAG work like CMAKE_LINK_LIBRARY_FLAG Acked-by: Kitware Robot Merge-request: !3641 https://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=e9ade44cb13c35994d65ef6ae125e97c5514ba9b commit e9ade44cb13c35994d65ef6ae125e97c5514ba9b Merge: 7eb2fd6 edca8d5 Author: Brad King AuthorDate: Mon Aug 5 10:27:47 2019 -0400 Commit: Brad King CommitDate: Mon Aug 5 10:27:47 2019 -0400 Merge branch 'release-3.15' https://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=f6d6dbc2933248dc7f17fd033e2b70fb161fddbd commit f6d6dbc2933248dc7f17fd033e2b70fb161fddbd Author: Brad King AuthorDate: Fri Aug 2 11:51:55 2019 -0400 Commit: Brad King CommitDate: Fri Aug 2 13:37:39 2019 -0400 Make CMAKE_LINK_LIBRARY_FILE_FLAG work like CMAKE_LINK_LIBRARY_FLAG The `CMAKE_LINK_LIBRARY_FILE_FLAG` variable is meant for linkers that want library file paths to be preceded by a flag. This is used only for OpenWatcom to add the `library` argument before library file paths. Refactor the approach to treat `CMAKE_LINK_LIBRARY_FILE_FLAG` as a command-line string fragment to add just before the library file path. This has two advantages: * `CMAKE_LINK_LIBRARY_FILE_FLAG` now works like `CMAKE_LINK_LIBRARY_FLAG`. * `CMAKE_LINK_LIBRARY_FILE_FLAG` can now be an attached flag whose value is the library file path. Technically this is a change in behavior, but this setting was created for internal use and should be rarely used outside of CMake itself. Fixes: #19541 diff --git a/Modules/Platform/Windows-OpenWatcom.cmake b/Modules/Platform/Windows-OpenWatcom.cmake index d38d616..76cd28b 100644 --- a/Modules/Platform/Windows-OpenWatcom.cmake +++ b/Modules/Platform/Windows-OpenWatcom.cmake @@ -10,7 +10,7 @@ set(__WINDOWS_OPENWATCOM 1) set(CMAKE_LIBRARY_PATH_FLAG "libpath ") set(CMAKE_LINK_LIBRARY_FLAG "library ") -set(CMAKE_LINK_LIBRARY_FILE_FLAG "library") +set(CMAKE_LINK_LIBRARY_FILE_FLAG "library ") if(CMAKE_VERBOSE_MAKEFILE) set(CMAKE_WCL_QUIET) diff --git a/Source/cmComputeLinkInformation.cxx b/Source/cmComputeLinkInformation.cxx index 78cddf0..5f46631 100644 --- a/Source/cmComputeLinkInformation.cxx +++ b/Source/cmComputeLinkInformation.cxx @@ -990,11 +990,6 @@ void cmComputeLinkInformation::AddTargetItem(std::string const& item, return; } - // If this platform wants a flag before the full path, add it. - if (!this->LibLinkFileFlag.empty()) { - this->Items.emplace_back(this->LibLinkFileFlag, false); - } - // For compatibility with CMake 2.4 include the item's directory in // the linker search path. if (this->OldLinkDirMode && !target->IsFrameworkOnApple() && @@ -1057,11 +1052,6 @@ void cmComputeLinkInformation::AddFullItem(std::string const& item) this->OldLinkDirItems.push_back(item); } - // If this platform wants a flag before the full path, add it. - if (!this->LibLinkFileFlag.empty()) { - this->Items.emplace_back(this->LibLinkFileFlag, false); - } - // Now add the full path to the library. this->Items.emplace_back(item, true); } diff --git a/Source/cmComputeLinkInformation.h b/Source/cmComputeLinkInformation.h index 3be2c7f..784d3fa 100644 --- a/Source/cmComputeLinkInformation.h +++ b/Source/cmComputeLinkInformation.h @@ -56,6 +56,11 @@ public: std::string GetChrpathString() const; std::set const& GetSharedLibrariesLinked() const; + std::string const& GetLibLinkFileFlag() const + { + return this->LibLinkFileFlag; + } + std::string const& GetRPathLinkFlag() const { return this->RPathLinkFlag; } std::string GetRPathLinkString() const; diff --git a/Source/cmLinkLineComputer.cxx b/Source/cmLinkLineComputer.cxx index 8746b35..4430f97 100644 --- a/Source/cmLinkLineComputer.cxx +++ b/Source/cmLinkLineComputer.cxx @@ -63,6 +63,7 @@ std::string cmLinkLineComputer::ComputeLinkLibs(cmComputeLinkInformation& cli) continue; } if (item.IsPath) { + linkLibs += cli.GetLibLinkFileFlag(); linkLibs += this->ConvertToOutputFormat(this->ConvertToLinkReference(item.Value)); } else { ----------------------------------------------------------------------- Summary of changes: Modules/Platform/Windows-OpenWatcom.cmake | 2 +- Source/cmComputeLinkInformation.cxx | 10 ---------- Source/cmComputeLinkInformation.h | 5 +++++ Source/cmLinkLineComputer.cxx | 1 + 4 files changed, 7 insertions(+), 11 deletions(-) hooks/post-receive -- CMake From kwrobot at kitware.com Mon Aug 5 10:41:42 2019 From: kwrobot at kitware.com (Kitware Robot) Date: Mon, 5 Aug 2019 10:41:42 -0400 (EDT) Subject: [Cmake-commits] CMake branch, master, updated. v3.15.1-580-gc969d46 Message-ID: <20190805144142.6C9A01034CF@public.kitware.com> This is an automated email from the git hooks/post-receive script. It was generated because a ref change was pushed to the repository containing the project "CMake". The branch, master has been updated via c969d4628bff6c5b45c788d3a61fff85c36272f6 (commit) via e0f735f8f53543773f01a4f692609d1b23fd3621 (commit) via 0962589627f9bb3399d8144fc8252e47484bc0b3 (commit) via d75cad01f0a43c55f999768fb63287fc247f9685 (commit) via 4b2e1fc9eeeb0b0b686b2e38a2a29e49eedb45e5 (commit) via 94648953befa6464e46469b1fa8d46b68d486321 (commit) from 26a3bccb60b1ba97b528187c244acf4c3bbceb3e (commit) Those revisions listed above that are new to this repository have not appeared on any other notification email; so we list those revisions in full, below. - Log ----------------------------------------------------------------- https://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=c969d4628bff6c5b45c788d3a61fff85c36272f6 commit c969d4628bff6c5b45c788d3a61fff85c36272f6 Merge: e0f735f 0962589 Author: Brad King AuthorDate: Mon Aug 5 14:40:21 2019 +0000 Commit: Kitware Robot CommitDate: Mon Aug 5 10:40:46 2019 -0400 Merge topic 'cleanup_cmake_constructor' 0962589627 cmake: Initialize booleans at declaration and cleanup constructor Acked-by: Kitware Robot Merge-request: !3646 https://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=e0f735f8f53543773f01a4f692609d1b23fd3621 commit e0f735f8f53543773f01a4f692609d1b23fd3621 Merge: 26a3bcc d75cad0 Author: Brad King AuthorDate: Mon Aug 5 14:37:30 2019 +0000 Commit: Kitware Robot CommitDate: Mon Aug 5 10:37:47 2019 -0400 Merge topic 'shared-deps-no-iface' d75cad01f0 Fix rpath-link for shared lib with only private deps 4b2e1fc9ee cmGeneratorTarget: Use local var to de-duplicate CMP0022 checks 94648953be cmLinkItem: Simplify tracking of whether link interface is explicit Acked-by: Kitware Robot Merge-request: !3642 https://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=0962589627f9bb3399d8144fc8252e47484bc0b3 commit 0962589627f9bb3399d8144fc8252e47484bc0b3 Author: Sebastian Holtermann AuthorDate: Fri Aug 2 11:43:35 2019 +0200 Commit: Sebastian Holtermann CommitDate: Sat Aug 3 11:44:38 2019 +0200 cmake: Initialize booleans at declaration and cleanup constructor diff --git a/Source/cmake.cxx b/Source/cmake.cxx index 309efd3..a81b7e4 100644 --- a/Source/cmake.cxx +++ b/Source/cmake.cxx @@ -28,6 +28,7 @@ #include "cmUtils.hxx" #include "cmVersionConfig.h" #include "cmWorkingDirectory.h" +#include "cm_string_view.hxx" #include "cm_sys_stat.h" #if defined(CMAKE_BUILD_WITH_CMAKE) @@ -132,22 +133,15 @@ static void cmWarnUnusedCliWarning(const std::string& variable, int /*unused*/, } cmake::cmake(Role role, cmState::Mode mode) + : FileTimeCache(cm::make_unique()) +#ifdef CMAKE_BUILD_WITH_CMAKE + , VariableWatch(cm::make_unique()) +#endif + , State(cm::make_unique()) + , Messenger(cm::make_unique()) { - this->Trace = false; - this->TraceExpand = false; - this->WarnUninitialized = false; - this->WarnUnused = false; - this->WarnUnusedCli = true; - this->CheckSystemVars = false; - this->DebugOutput = false; - this->DebugTryCompile = false; - this->ClearBuildSystem = false; - this->FileTimeCache = cm::make_unique(); - - this->State = cm::make_unique(); this->State->SetMode(mode); this->CurrentSnapshot = this->State->CreateBaseSnapshot(); - this->Messenger = cm::make_unique(); #ifdef __APPLE__ struct rlimit rlp; @@ -159,16 +153,6 @@ cmake::cmake(Role role, cmState::Mode mode) } #endif - this->GlobalGenerator = nullptr; - this->GeneratorInstanceSet = false; - this->GeneratorPlatformSet = false; - this->GeneratorToolsetSet = false; - this->CurrentWorkingMode = NORMAL_MODE; - -#ifdef CMAKE_BUILD_WITH_CMAKE - this->VariableWatch = cm::make_unique(); -#endif - this->AddDefaultGenerators(); this->AddDefaultExtraGenerators(); if (role == RoleScript || role == RoleProject) { @@ -188,32 +172,25 @@ cmake::cmake(Role role, cmState::Mode mode) // Set up a list of source and header extensions. // These are used to find files when the extension is not given. { - auto fillExts = [](FileExtensions& exts, - std::initializer_list extList) { + auto setupExts = [](FileExtensions& exts, + std::initializer_list extList) { // Fill ordered vector exts.ordered.reserve(extList.size()); - for (const char* ext : extList) { + for (cm::string_view ext : extList) { exts.ordered.emplace_back(ext); }; // Fill unordered set exts.unordered.insert(exts.ordered.begin(), exts.ordered.end()); }; - // Source extensions // The "c" extension MUST precede the "C" extension. - fillExts(this->SourceFileExtensions, - { "c", "C", "c++", "cc", "cpp", "cxx", "cu", "m", "M", "mm" }); - - // Header extensions - fillExts(this->HeaderFileExtensions, - { "h", "hh", "h++", "hm", "hpp", "hxx", "in", "txx" }); - - // Cuda extensions - fillExts(this->CudaFileExtensions, { "cu" }); - - // Fortran extensions - fillExts(this->FortranFileExtensions, - { "f", "F", "for", "f77", "f90", "f95", "f03" }); + setupExts(this->SourceFileExtensions, + { "c", "C", "c++", "cc", "cpp", "cxx", "cu", "m", "M", "mm" }); + setupExts(this->HeaderFileExtensions, + { "h", "hh", "h++", "hm", "hpp", "hxx", "in", "txx" }); + setupExts(this->CudaFileExtensions, { "cu" }); + setupExts(this->FortranFileExtensions, + { "f", "F", "for", "f77", "f90", "f95", "f03" }); } } diff --git a/Source/cmake.h b/Source/cmake.h index 6aa00e1..92494ae 100644 --- a/Source/cmake.h +++ b/Source/cmake.h @@ -509,14 +509,14 @@ protected: void AddDefaultGenerators(); void AddDefaultExtraGenerators(); - cmGlobalGenerator* GlobalGenerator; + cmGlobalGenerator* GlobalGenerator = nullptr; std::map DiagLevels; std::string GeneratorInstance; std::string GeneratorPlatform; std::string GeneratorToolset; - bool GeneratorInstanceSet; - bool GeneratorPlatformSet; - bool GeneratorToolsetSet; + bool GeneratorInstanceSet = false; + bool GeneratorPlatformSet = false; + bool GeneratorToolsetSet = false; //! read in a cmake list file to initialize the cache void ReadListFile(const std::vector& args, @@ -543,14 +543,14 @@ protected: private: ProgressCallbackType ProgressCallback; - WorkingMode CurrentWorkingMode; - bool DebugOutput; - bool Trace; - bool TraceExpand; - bool WarnUninitialized; - bool WarnUnused; - bool WarnUnusedCli; - bool CheckSystemVars; + WorkingMode CurrentWorkingMode = NORMAL_MODE; + bool DebugOutput = false; + bool Trace = false; + bool TraceExpand = false; + bool WarnUninitialized = false; + bool WarnUnused = false; + bool WarnUnusedCli = true; + bool CheckSystemVars = false; std::map UsedCliVariables; std::string CMakeEditCommand; std::string CXXEnvironment; @@ -564,8 +564,8 @@ private: FileExtensions HeaderFileExtensions; FileExtensions CudaFileExtensions; FileExtensions FortranFileExtensions; - bool ClearBuildSystem; - bool DebugTryCompile; + bool ClearBuildSystem = false; + bool DebugTryCompile = false; std::unique_ptr FileTimeCache; std::string GraphVizFile; InstalledFilesMap InstalledFiles; https://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=d75cad01f0a43c55f999768fb63287fc247f9685 commit d75cad01f0a43c55f999768fb63287fc247f9685 Author: Brad King AuthorDate: Fri Aug 2 14:50:43 2019 -0400 Commit: Brad King CommitDate: Fri Aug 2 14:50:57 2019 -0400 Fix rpath-link for shared lib with only private deps Under CMP0022 NEW behavior, the link interface is explicit even if there are no public dependencies (`INTERFACE_LINK_LIBRARIES` is not set). Mark it as such to activate our tracking of private runtime dependencies of shared libraries for generation of `-rpath-link` flags. Fixes: #19556 diff --git a/Source/cmGeneratorTarget.cxx b/Source/cmGeneratorTarget.cxx index 747051d..d9e5e71 100644 --- a/Source/cmGeneratorTarget.cxx +++ b/Source/cmGeneratorTarget.cxx @@ -5660,7 +5660,7 @@ void cmGeneratorTarget::ComputeLinkInterfaceLibraries( return; } iface.Exists = true; - iface.Explicit = explicitLibraries != nullptr; + iface.Explicit = cmp0022NEW || explicitLibraries != nullptr; if (explicitLibraries) { // The interface libraries have been explicitly set. diff --git a/Tests/RuntimePath/CMakeLists.txt b/Tests/RuntimePath/CMakeLists.txt index 6583a87..bb87440 100644 --- a/Tests/RuntimePath/CMakeLists.txt +++ b/Tests/RuntimePath/CMakeLists.txt @@ -1,4 +1,4 @@ -cmake_minimum_required (VERSION 2.6) +cmake_minimum_required (VERSION 3.15) project(RuntimePath C) # Add a simple chain of shared libraries that must be found. @@ -31,3 +31,14 @@ if(CMAKE_SHARED_LIBRARY_SONAME_C_FLAG) set_property(TARGET bar2 PROPERTY LIBRARY_OUTPUT_DIRECTORY A) target_link_libraries(bar2 foo2) endif() + +# Add a library that is missing the rpath for its dependency. +add_library(bar1_no_rpath SHARED bar1.c) +set_property(TARGET bar1_no_rpath PROPERTY LIBRARY_OUTPUT_DIRECTORY B) +set_property(TARGET bar1_no_rpath PROPERTY SKIP_BUILD_RPATH 1) +target_link_libraries(bar1_no_rpath PRIVATE foo1) + +# Add an executable linking to the library with a missing dependency rpath. +# CMake should generate the proper rpath-link flag to find it at build time. +add_executable(main_with_bar1_no_rpath main.c) +target_link_libraries(main_with_bar1_no_rpath bar1_no_rpath) https://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=4b2e1fc9eeeb0b0b686b2e38a2a29e49eedb45e5 commit 4b2e1fc9eeeb0b0b686b2e38a2a29e49eedb45e5 Author: Brad King AuthorDate: Fri Aug 2 14:47:33 2019 -0400 Commit: Brad King CommitDate: Fri Aug 2 14:48:34 2019 -0400 cmGeneratorTarget: Use local var to de-duplicate CMP0022 checks diff --git a/Source/cmGeneratorTarget.cxx b/Source/cmGeneratorTarget.cxx index 42683db..747051d 100644 --- a/Source/cmGeneratorTarget.cxx +++ b/Source/cmGeneratorTarget.cxx @@ -5603,8 +5603,9 @@ void cmGeneratorTarget::ComputeLinkInterfaceLibraries( // libraries and executables that export symbols. const char* explicitLibraries = nullptr; std::string linkIfaceProp; - if (this->GetPolicyStatusCMP0022() != cmPolicies::OLD && - this->GetPolicyStatusCMP0022() != cmPolicies::WARN) { + bool const cmp0022NEW = (this->GetPolicyStatusCMP0022() != cmPolicies::OLD && + this->GetPolicyStatusCMP0022() != cmPolicies::WARN); + if (cmp0022NEW) { // CMP0022 NEW behavior is to use INTERFACE_LINK_LIBRARIES. linkIfaceProp = "INTERFACE_LINK_LIBRARIES"; explicitLibraries = this->GetProperty(linkIfaceProp); @@ -5666,8 +5667,7 @@ void cmGeneratorTarget::ComputeLinkInterfaceLibraries( this->ExpandLinkItems(linkIfaceProp, explicitLibraries, config, headTarget, usage_requirements_only, iface.Libraries, iface.HadHeadSensitiveCondition); - } else if (this->GetPolicyStatusCMP0022() == cmPolicies::WARN || - this->GetPolicyStatusCMP0022() == cmPolicies::OLD) + } else if (!cmp0022NEW) // If CMP0022 is NEW then the plain tll signature sets the // INTERFACE_LINK_LIBRARIES, so if we get here then the project // cleared the property explicitly and we should not fall back https://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=94648953befa6464e46469b1fa8d46b68d486321 commit 94648953befa6464e46469b1fa8d46b68d486321 Author: Brad King AuthorDate: Fri Aug 2 14:42:14 2019 -0400 Commit: Brad King CommitDate: Fri Aug 2 14:43:16 2019 -0400 cmLinkItem: Simplify tracking of whether link interface is explicit We now only need a boolean. diff --git a/Source/cmGeneratorTarget.cxx b/Source/cmGeneratorTarget.cxx index 7340bc2..42683db 100644 --- a/Source/cmGeneratorTarget.cxx +++ b/Source/cmGeneratorTarget.cxx @@ -5219,7 +5219,7 @@ void cmGeneratorTarget::ComputeLinkInterface( const std::string& config, cmOptionalLinkInterface& iface, cmGeneratorTarget const* headTarget) const { - if (iface.ExplicitLibraries) { + if (iface.Explicit) { if (this->GetType() == cmStateEnums::SHARED_LIBRARY || this->GetType() == cmStateEnums::STATIC_LIBRARY || this->GetType() == cmStateEnums::INTERFACE_LIBRARY) { @@ -5659,7 +5659,7 @@ void cmGeneratorTarget::ComputeLinkInterfaceLibraries( return; } iface.Exists = true; - iface.ExplicitLibraries = explicitLibraries; + iface.Explicit = explicitLibraries != nullptr; if (explicitLibraries) { // The interface libraries have been explicitly set. diff --git a/Source/cmLinkItem.h b/Source/cmLinkItem.h index 6450c62..d71ff49 100644 --- a/Source/cmLinkItem.h +++ b/Source/cmLinkItem.h @@ -87,7 +87,7 @@ struct cmOptionalLinkInterface : public cmLinkInterface bool LibrariesDone = false; bool AllDone = false; bool Exists = false; - const char* ExplicitLibraries = nullptr; + bool Explicit = false; }; struct cmHeadToLinkInterfaceMap ----------------------------------------------------------------------- Summary of changes: Source/cmGeneratorTarget.cxx | 12 ++++----- Source/cmLinkItem.h | 2 +- Source/cmake.cxx | 57 ++++++++++++---------------------------- Source/cmake.h | 28 ++++++++++---------- Tests/RuntimePath/CMakeLists.txt | 13 ++++++++- 5 files changed, 50 insertions(+), 62 deletions(-) hooks/post-receive -- CMake From kwrobot at kitware.com Mon Aug 5 10:52:10 2019 From: kwrobot at kitware.com (Kitware Robot) Date: Mon, 5 Aug 2019 10:52:10 -0400 (EDT) Subject: [Cmake-commits] CMake branch, master, updated. v3.15.1-587-g2327cc0 Message-ID: <20190805145210.67CA810A87E@public.kitware.com> This is an automated email from the git hooks/post-receive script. It was generated because a ref change was pushed to the repository containing the project "CMake". The branch, master has been updated via 2327cc0e0575175e8dec4b7a6fa6cafd5d0f7ca9 (commit) via 41364824ad84a40c9906b7b5de492e45a74c8945 (commit) via 6491270e0d3699f5151c08ef41dce84724f9ffc1 (commit) via af24e4ef6e216184b8c207728d6b0312ce3c1525 (commit) via ef38ff22f71ad0ffe83db42d903d26d4a41f4114 (commit) via b51fba6298012c3b697c461486ce06c9e5c97c16 (commit) via c76500949d3fcf5ff83ac6e7f1d565f5d786c5f0 (commit) from c969d4628bff6c5b45c788d3a61fff85c36272f6 (commit) Those revisions listed above that are new to this repository have not appeared on any other notification email; so we list those revisions in full, below. - Log ----------------------------------------------------------------- https://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=2327cc0e0575175e8dec4b7a6fa6cafd5d0f7ca9 commit 2327cc0e0575175e8dec4b7a6fa6cafd5d0f7ca9 Merge: c969d46 4136482 Author: Brad King AuthorDate: Mon Aug 5 14:40:43 2019 +0000 Commit: Kitware Robot CommitDate: Mon Aug 5 10:42:50 2019 -0400 Merge topic 'control-block3' 41364824ad cmFunctionBlocker: Recycle functions 6491270e0d cmFunctionBlocker: Move check for matching args af24e4ef6e cmFunctionBlocker: Move common logic to base ef38ff22f7 cm*FunctionBlocker: Extract function Replay b51fba6298 cmMakefile: Add OnExecuteCommand callback c76500949d cm*FunctionBlocker: Move to source file Acked-by: Kitware Robot Merge-request: !3632 https://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=41364824ad84a40c9906b7b5de492e45a74c8945 commit 41364824ad84a40c9906b7b5de492e45a74c8945 Author: Regina Pfeifer AuthorDate: Tue Jul 30 23:54:12 2019 +0200 Commit: Kyle Edwards CommitDate: Wed Jul 31 13:22:42 2019 -0400 cmFunctionBlocker: Recycle functions diff --git a/Source/cmForEachCommand.cxx b/Source/cmForEachCommand.cxx index 10ce459..1d961be 100644 --- a/Source/cmForEachCommand.cxx +++ b/Source/cmForEachCommand.cxx @@ -31,7 +31,7 @@ public: bool ArgumentsMatch(cmListFileFunction const& lff, cmMakefile& mf) const override; - bool Replay(std::vector const& functions, + bool Replay(std::vector functions, cmExecutionStatus& inStatus) override; std::vector Args; @@ -60,8 +60,7 @@ bool cmForEachFunctionBlocker::ArgumentsMatch(cmListFileFunction const& lff, } bool cmForEachFunctionBlocker::Replay( - std::vector const& functions, - cmExecutionStatus& inStatus) + std::vector functions, cmExecutionStatus& inStatus) { cmMakefile& mf = inStatus.GetMakefile(); // at end of for each execute recorded commands diff --git a/Source/cmFunctionBlocker.cxx b/Source/cmFunctionBlocker.cxx index 437d4b5..5778a71 100644 --- a/Source/cmFunctionBlocker.cxx +++ b/Source/cmFunctionBlocker.cxx @@ -4,6 +4,7 @@ #include #include +#include #include "cmExecutionStatus.h" #include "cmMakefile.h" @@ -36,7 +37,7 @@ bool cmFunctionBlocker::IsFunctionBlocked(const cmListFileFunction& lff, mf.IssueMessage(MessageType::AUTHOR_WARNING, e.str()); } - return this->Replay(this->Functions, status); + return this->Replay(std::move(this->Functions), status); } } diff --git a/Source/cmFunctionBlocker.h b/Source/cmFunctionBlocker.h index 8b05993..87bdccd 100644 --- a/Source/cmFunctionBlocker.h +++ b/Source/cmFunctionBlocker.h @@ -42,7 +42,7 @@ private: virtual bool ArgumentsMatch(cmListFileFunction const& lff, cmMakefile& mf) const = 0; - virtual bool Replay(std::vector const& functions, + virtual bool Replay(std::vector functions, cmExecutionStatus& status) = 0; private: diff --git a/Source/cmFunctionCommand.cxx b/Source/cmFunctionCommand.cxx index dd0a5d0..610f516 100644 --- a/Source/cmFunctionCommand.cxx +++ b/Source/cmFunctionCommand.cxx @@ -116,7 +116,7 @@ public: bool ArgumentsMatch(cmListFileFunction const&, cmMakefile& mf) const override; - bool Replay(std::vector const& functions, + bool Replay(std::vector functions, cmExecutionStatus& status) override; std::vector Args; @@ -132,13 +132,13 @@ bool cmFunctionFunctionBlocker::ArgumentsMatch(cmListFileFunction const& lff, } bool cmFunctionFunctionBlocker::Replay( - std::vector const& functions, cmExecutionStatus& status) + std::vector functions, cmExecutionStatus& status) { cmMakefile& mf = status.GetMakefile(); // create a new command and add it to cmake cmFunctionHelperCommand f; f.Args = this->Args; - f.Functions = functions; + f.Functions = std::move(functions); f.FilePath = this->GetStartingContext().FilePath; mf.RecordPolicies(f.Policies); mf.GetState()->AddScriptedCommand(this->Args[0], std::move(f)); diff --git a/Source/cmIfCommand.cxx b/Source/cmIfCommand.cxx index 418a74b..c5cfd8c 100644 --- a/Source/cmIfCommand.cxx +++ b/Source/cmIfCommand.cxx @@ -41,7 +41,7 @@ public: bool ArgumentsMatch(cmListFileFunction const& lff, cmMakefile&) const override; - bool Replay(std::vector const& functions, + bool Replay(std::vector functions, cmExecutionStatus& inStatus) override; std::vector Args; @@ -56,9 +56,8 @@ bool cmIfFunctionBlocker::ArgumentsMatch(cmListFileFunction const& lff, return lff.Arguments.empty() || lff.Arguments == this->Args; } -bool cmIfFunctionBlocker::Replay( - std::vector const& functions, - cmExecutionStatus& inStatus) +bool cmIfFunctionBlocker::Replay(std::vector functions, + cmExecutionStatus& inStatus) { cmMakefile& mf = inStatus.GetMakefile(); // execute the functions for the true parts of the if statement diff --git a/Source/cmMacroCommand.cxx b/Source/cmMacroCommand.cxx index eb328cc..8689c8f 100644 --- a/Source/cmMacroCommand.cxx +++ b/Source/cmMacroCommand.cxx @@ -149,7 +149,7 @@ public: bool ArgumentsMatch(cmListFileFunction const&, cmMakefile& mf) const override; - bool Replay(std::vector const& functions, + bool Replay(std::vector functions, cmExecutionStatus& status) override; std::vector Args; @@ -164,15 +164,15 @@ bool cmMacroFunctionBlocker::ArgumentsMatch(cmListFileFunction const& lff, return expandedArguments.empty() || expandedArguments[0] == this->Args[0]; } -bool cmMacroFunctionBlocker::Replay( - std::vector const& functions, cmExecutionStatus& status) +bool cmMacroFunctionBlocker::Replay(std::vector functions, + cmExecutionStatus& status) { cmMakefile& mf = status.GetMakefile(); mf.AppendProperty("MACROS", this->Args[0].c_str()); // create a new command and add it to cmake cmMacroHelperCommand f; f.Args = this->Args; - f.Functions = functions; + f.Functions = std::move(functions); f.FilePath = this->GetStartingContext().FilePath; mf.RecordPolicies(f.Policies); mf.GetState()->AddScriptedCommand(this->Args[0], std::move(f)); diff --git a/Source/cmWhileCommand.cxx b/Source/cmWhileCommand.cxx index 1e442e5..a396852 100644 --- a/Source/cmWhileCommand.cxx +++ b/Source/cmWhileCommand.cxx @@ -30,7 +30,7 @@ public: bool ArgumentsMatch(cmListFileFunction const& lff, cmMakefile& mf) const override; - bool Replay(std::vector const& functions, + bool Replay(std::vector functions, cmExecutionStatus& inStatus) override; std::vector Args; @@ -56,9 +56,8 @@ bool cmWhileFunctionBlocker::ArgumentsMatch(cmListFileFunction const& lff, return lff.Arguments.empty() || lff.Arguments == this->Args; } -bool cmWhileFunctionBlocker::Replay( - std::vector const& functions, - cmExecutionStatus& inStatus) +bool cmWhileFunctionBlocker::Replay(std::vector functions, + cmExecutionStatus& inStatus) { cmMakefile& mf = inStatus.GetMakefile(); std::string errorString; https://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=6491270e0d3699f5151c08ef41dce84724f9ffc1 commit 6491270e0d3699f5151c08ef41dce84724f9ffc1 Author: Regina Pfeifer AuthorDate: Tue Jul 30 22:58:40 2019 +0200 Commit: Regina Pfeifer CommitDate: Wed Jul 31 00:03:17 2019 +0200 cmFunctionBlocker: Move check for matching args diff --git a/Source/cmForEachCommand.cxx b/Source/cmForEachCommand.cxx index 53ae479..10ce459 100644 --- a/Source/cmForEachCommand.cxx +++ b/Source/cmForEachCommand.cxx @@ -28,7 +28,9 @@ public: cm::string_view StartCommandName() const override { return "foreach"_s; } cm::string_view EndCommandName() const override { return "endforeach"_s; } - bool ShouldRemove(const cmListFileFunction& lff, cmMakefile& mf) override; + bool ArgumentsMatch(cmListFileFunction const& lff, + cmMakefile& mf) const override; + bool Replay(std::vector const& functions, cmExecutionStatus& inStatus) override; @@ -49,20 +51,12 @@ cmForEachFunctionBlocker::~cmForEachFunctionBlocker() this->Makefile->PopLoopBlock(); } -bool cmForEachFunctionBlocker::ShouldRemove(const cmListFileFunction& lff, - cmMakefile& mf) +bool cmForEachFunctionBlocker::ArgumentsMatch(cmListFileFunction const& lff, + cmMakefile& mf) const { - if (lff.Name.Lower == "endforeach") { - std::vector expandedArguments; - mf.ExpandArguments(lff.Arguments, expandedArguments); - // if the endforeach has arguments then make sure - // they match the begin foreach arguments - if ((expandedArguments.empty() || - (expandedArguments[0] == this->Args[0]))) { - return true; - } - } - return false; + std::vector expandedArguments; + mf.ExpandArguments(lff.Arguments, expandedArguments); + return expandedArguments.empty() || expandedArguments[0] == this->Args[0]; } bool cmForEachFunctionBlocker::Replay( diff --git a/Source/cmFunctionBlocker.cxx b/Source/cmFunctionBlocker.cxx index 2999691..437d4b5 100644 --- a/Source/cmFunctionBlocker.cxx +++ b/Source/cmFunctionBlocker.cxx @@ -2,8 +2,12 @@ file Copyright.txt or https://cmake.org/licensing for details. */ #include "cmFunctionBlocker.h" +#include +#include + #include "cmExecutionStatus.h" #include "cmMakefile.h" +#include "cmMessageType.h" bool cmFunctionBlocker::IsFunctionBlocked(const cmListFileFunction& lff, cmExecutionStatus& status) @@ -14,7 +18,24 @@ bool cmFunctionBlocker::IsFunctionBlocked(const cmListFileFunction& lff, this->ScopeDepth--; if (this->ScopeDepth == 0U) { cmMakefile& mf = status.GetMakefile(); - auto self = mf.RemoveFunctionBlocker(this, lff); + auto self = mf.RemoveFunctionBlocker(); + assert(self.get() == this); + + if (!this->ArgumentsMatch(lff, mf)) { + cmListFileContext const& lfc = this->GetStartingContext(); + cmListFileContext closingContext = + cmListFileContext::FromCommandContext(lff, lfc.FilePath); + std::ostringstream e; + /* clang-format off */ + e << "A logical block opening on the line\n" + << " " << lfc << "\n" + << "closes on the line\n" + << " " << closingContext << "\n" + << "with mis-matching arguments."; + /* clang-format on */ + mf.IssueMessage(MessageType::AUTHOR_WARNING, e.str()); + } + return this->Replay(this->Functions, status); } } diff --git a/Source/cmFunctionBlocker.h b/Source/cmFunctionBlocker.h index 8fc2c1c..8b05993 100644 --- a/Source/cmFunctionBlocker.h +++ b/Source/cmFunctionBlocker.h @@ -23,15 +23,6 @@ public: bool IsFunctionBlocked(cmListFileFunction const& lff, cmExecutionStatus& status); - /** - * should this function blocker be removed, useful when one function adds a - * blocker and another must remove it - */ - virtual bool ShouldRemove(const cmListFileFunction&, cmMakefile&) - { - return false; - } - virtual ~cmFunctionBlocker() = default; /** Set/Get the context in which this blocker is created. */ @@ -48,6 +39,9 @@ private: virtual cm::string_view StartCommandName() const = 0; virtual cm::string_view EndCommandName() const = 0; + virtual bool ArgumentsMatch(cmListFileFunction const& lff, + cmMakefile& mf) const = 0; + virtual bool Replay(std::vector const& functions, cmExecutionStatus& status) = 0; diff --git a/Source/cmFunctionCommand.cxx b/Source/cmFunctionCommand.cxx index 6a04196..dd0a5d0 100644 --- a/Source/cmFunctionCommand.cxx +++ b/Source/cmFunctionCommand.cxx @@ -113,29 +113,22 @@ public: cm::string_view StartCommandName() const override { return "function"_s; } cm::string_view EndCommandName() const override { return "endfunction"_s; } - bool ShouldRemove(const cmListFileFunction&, cmMakefile& mf) override; + bool ArgumentsMatch(cmListFileFunction const&, + cmMakefile& mf) const override; + bool Replay(std::vector const& functions, cmExecutionStatus& status) override; std::vector Args; }; -bool cmFunctionFunctionBlocker::ShouldRemove(const cmListFileFunction& lff, - cmMakefile& mf) +bool cmFunctionFunctionBlocker::ArgumentsMatch(cmListFileFunction const& lff, + cmMakefile& mf) const { - if (lff.Name.Lower == "endfunction") { - std::vector expandedArguments; - mf.ExpandArguments(lff.Arguments, expandedArguments, - this->GetStartingContext().FilePath.c_str()); - // if the endfunction has arguments then make sure - // they match the ones in the opening function command - if ((expandedArguments.empty() || - (expandedArguments[0] == this->Args[0]))) { - return true; - } - } - - return false; + std::vector expandedArguments; + mf.ExpandArguments(lff.Arguments, expandedArguments, + this->GetStartingContext().FilePath.c_str()); + return expandedArguments.empty() || expandedArguments[0] == this->Args[0]; } bool cmFunctionFunctionBlocker::Replay( diff --git a/Source/cmIfCommand.cxx b/Source/cmIfCommand.cxx index 63cdd20..418a74b 100644 --- a/Source/cmIfCommand.cxx +++ b/Source/cmIfCommand.cxx @@ -38,7 +38,9 @@ public: cm::string_view StartCommandName() const override { return "if"_s; } cm::string_view EndCommandName() const override { return "endif"_s; } - bool ShouldRemove(const cmListFileFunction& lff, cmMakefile& mf) override; + bool ArgumentsMatch(cmListFileFunction const& lff, + cmMakefile&) const override; + bool Replay(std::vector const& functions, cmExecutionStatus& inStatus) override; @@ -48,18 +50,10 @@ public: bool ElseSeen = false; }; -bool cmIfFunctionBlocker::ShouldRemove(const cmListFileFunction& lff, - cmMakefile&) +bool cmIfFunctionBlocker::ArgumentsMatch(cmListFileFunction const& lff, + cmMakefile&) const { - if (lff.Name.Lower == "endif") { - // if the endif has arguments, then make sure - // they match the arguments of the matching if - if (lff.Arguments.empty() || lff.Arguments == this->Args) { - return true; - } - } - - return false; + return lff.Arguments.empty() || lff.Arguments == this->Args; } bool cmIfFunctionBlocker::Replay( diff --git a/Source/cmMacroCommand.cxx b/Source/cmMacroCommand.cxx index 030bb66..eb328cc 100644 --- a/Source/cmMacroCommand.cxx +++ b/Source/cmMacroCommand.cxx @@ -146,29 +146,22 @@ public: cm::string_view StartCommandName() const override { return "macro"_s; } cm::string_view EndCommandName() const override { return "endmacro"_s; } - bool ShouldRemove(const cmListFileFunction&, cmMakefile& mf) override; + bool ArgumentsMatch(cmListFileFunction const&, + cmMakefile& mf) const override; + bool Replay(std::vector const& functions, cmExecutionStatus& status) override; std::vector Args; }; -bool cmMacroFunctionBlocker::ShouldRemove(const cmListFileFunction& lff, - cmMakefile& mf) +bool cmMacroFunctionBlocker::ArgumentsMatch(cmListFileFunction const& lff, + cmMakefile& mf) const { - if (lff.Name.Lower == "endmacro") { - std::vector expandedArguments; - mf.ExpandArguments(lff.Arguments, expandedArguments, - this->GetStartingContext().FilePath.c_str()); - // if the endmacro has arguments make sure they - // match the arguments of the macro - if ((expandedArguments.empty() || - (expandedArguments[0] == this->Args[0]))) { - return true; - } - } - - return false; + std::vector expandedArguments; + mf.ExpandArguments(lff.Arguments, expandedArguments, + this->GetStartingContext().FilePath.c_str()); + return expandedArguments.empty() || expandedArguments[0] == this->Args[0]; } bool cmMacroFunctionBlocker::Replay( diff --git a/Source/cmMakefile.cxx b/Source/cmMakefile.cxx index 8c11786..015453a 100644 --- a/Source/cmMakefile.cxx +++ b/Source/cmMakefile.cxx @@ -3220,30 +3220,12 @@ void cmMakefile::AddFunctionBlocker(std::unique_ptr fb) this->FunctionBlockers.push(std::move(fb)); } -std::unique_ptr cmMakefile::RemoveFunctionBlocker( - cmFunctionBlocker* fb, const cmListFileFunction& lff) +std::unique_ptr cmMakefile::RemoveFunctionBlocker() { assert(!this->FunctionBlockers.empty()); - assert(this->FunctionBlockers.top().get() == fb); assert(this->FunctionBlockerBarriers.empty() || this->FunctionBlockers.size() > this->FunctionBlockerBarriers.back()); - // Warn if the arguments do not match, but always remove. - if (!fb->ShouldRemove(lff, *this)) { - cmListFileContext const& lfc = fb->GetStartingContext(); - cmListFileContext closingContext = - cmListFileContext::FromCommandContext(lff, lfc.FilePath); - std::ostringstream e; - /* clang-format off */ - e << "A logical block opening on the line\n" - << " " << lfc << "\n" - << "closes on the line\n" - << " " << closingContext << "\n" - << "with mis-matching arguments."; - /* clang-format on */ - this->IssueMessage(MessageType::AUTHOR_WARNING, e.str()); - } - auto b = std::move(this->FunctionBlockers.top()); this->FunctionBlockers.pop(); return b; diff --git a/Source/cmMakefile.h b/Source/cmMakefile.h index 941e335..4d61c05 100644 --- a/Source/cmMakefile.h +++ b/Source/cmMakefile.h @@ -107,8 +107,7 @@ public: * Remove the function blocker whose scope ends with the given command. * This returns ownership of the function blocker object. */ - std::unique_ptr RemoveFunctionBlocker( - cmFunctionBlocker* fb, const cmListFileFunction& lff); + std::unique_ptr RemoveFunctionBlocker(); /** * Try running cmake and building a file. This is used for dynalically diff --git a/Source/cmWhileCommand.cxx b/Source/cmWhileCommand.cxx index bacee58..1e442e5 100644 --- a/Source/cmWhileCommand.cxx +++ b/Source/cmWhileCommand.cxx @@ -27,7 +27,9 @@ public: cm::string_view StartCommandName() const override { return "while"_s; } cm::string_view EndCommandName() const override { return "endwhile"_s; } - bool ShouldRemove(const cmListFileFunction& lff, cmMakefile& mf) override; + bool ArgumentsMatch(cmListFileFunction const& lff, + cmMakefile& mf) const override; + bool Replay(std::vector const& functions, cmExecutionStatus& inStatus) override; @@ -48,17 +50,10 @@ cmWhileFunctionBlocker::~cmWhileFunctionBlocker() this->Makefile->PopLoopBlock(); } -bool cmWhileFunctionBlocker::ShouldRemove(const cmListFileFunction& lff, - cmMakefile&) +bool cmWhileFunctionBlocker::ArgumentsMatch(cmListFileFunction const& lff, + cmMakefile&) const { - if (lff.Name.Lower == "endwhile") { - // if the endwhile has arguments, then make sure - // they match the arguments of the matching while - if (lff.Arguments.empty() || lff.Arguments == this->Args) { - return true; - } - } - return false; + return lff.Arguments.empty() || lff.Arguments == this->Args; } bool cmWhileFunctionBlocker::Replay( https://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=af24e4ef6e216184b8c207728d6b0312ce3c1525 commit af24e4ef6e216184b8c207728d6b0312ce3c1525 Author: Regina Pfeifer AuthorDate: Tue Jul 30 18:15:13 2019 +0200 Commit: Regina Pfeifer CommitDate: Wed Jul 31 00:03:17 2019 +0200 cmFunctionBlocker: Move common logic to base diff --git a/Source/CMakeLists.txt b/Source/CMakeLists.txt index 041c606..a6babe5 100644 --- a/Source/CMakeLists.txt +++ b/Source/CMakeLists.txt @@ -531,6 +531,8 @@ set(SRCS cmFindProgramCommand.h cmForEachCommand.cxx cmForEachCommand.h + cmFunctionBlocker.cxx + cmFunctionBlocker.h cmFunctionCommand.cxx cmFunctionCommand.h cmGetCMakePropertyCommand.cxx diff --git a/Source/cmForEachCommand.cxx b/Source/cmForEachCommand.cxx index af32040..53ae479 100644 --- a/Source/cmForEachCommand.cxx +++ b/Source/cmForEachCommand.cxx @@ -8,6 +8,8 @@ #include #include "cm_memory.hxx" +#include "cm_static_string_view.hxx" +#include "cm_string_view.hxx" #include "cmExecutionStatus.h" #include "cmFunctionBlocker.h" @@ -22,23 +24,22 @@ class cmForEachFunctionBlocker : public cmFunctionBlocker public: cmForEachFunctionBlocker(cmMakefile* mf); ~cmForEachFunctionBlocker() override; - bool IsFunctionBlocked(const cmListFileFunction& lff, cmMakefile& mf, - cmExecutionStatus&) override; + + cm::string_view StartCommandName() const override { return "foreach"_s; } + cm::string_view EndCommandName() const override { return "endforeach"_s; } + bool ShouldRemove(const cmListFileFunction& lff, cmMakefile& mf) override; bool Replay(std::vector const& functions, - cmExecutionStatus& inStatus); + cmExecutionStatus& inStatus) override; std::vector Args; - std::vector Functions; private: cmMakefile* Makefile; - int Depth; }; cmForEachFunctionBlocker::cmForEachFunctionBlocker(cmMakefile* mf) : Makefile(mf) - , Depth(0) { this->Makefile->PushLoopBlock(); } @@ -48,36 +49,6 @@ cmForEachFunctionBlocker::~cmForEachFunctionBlocker() this->Makefile->PopLoopBlock(); } -bool cmForEachFunctionBlocker::IsFunctionBlocked(const cmListFileFunction& lff, - cmMakefile& mf, - cmExecutionStatus& inStatus) -{ - if (lff.Name.Lower == "foreach") { - // record the number of nested foreach commands - this->Depth++; - } else if (lff.Name.Lower == "endforeach") { - // if this is the endofreach for this statement - if (!this->Depth) { - // Remove the function blocker for this scope or bail. - std::unique_ptr fb( - mf.RemoveFunctionBlocker(this, lff)); - if (!fb) { - return false; - } - - return this->Replay(this->Functions, inStatus); - } - // close out a nested foreach - this->Depth--; - } - - // record the command - this->Functions.push_back(lff); - - // always return true - return true; -} - bool cmForEachFunctionBlocker::ShouldRemove(const cmListFileFunction& lff, cmMakefile& mf) { diff --git a/Source/cmFunctionBlocker.cxx b/Source/cmFunctionBlocker.cxx new file mode 100644 index 0000000..2999691 --- /dev/null +++ b/Source/cmFunctionBlocker.cxx @@ -0,0 +1,24 @@ +/* Distributed under the OSI-approved BSD 3-Clause License. See accompanying + file Copyright.txt or https://cmake.org/licensing for details. */ +#include "cmFunctionBlocker.h" + +#include "cmExecutionStatus.h" +#include "cmMakefile.h" + +bool cmFunctionBlocker::IsFunctionBlocked(const cmListFileFunction& lff, + cmExecutionStatus& status) +{ + if (lff.Name.Lower == this->StartCommandName()) { + this->ScopeDepth++; + } else if (lff.Name.Lower == this->EndCommandName()) { + this->ScopeDepth--; + if (this->ScopeDepth == 0U) { + cmMakefile& mf = status.GetMakefile(); + auto self = mf.RemoveFunctionBlocker(this, lff); + return this->Replay(this->Functions, status); + } + } + + this->Functions.push_back(lff); + return true; +} diff --git a/Source/cmFunctionBlocker.h b/Source/cmFunctionBlocker.h index cd6b05d..8fc2c1c 100644 --- a/Source/cmFunctionBlocker.h +++ b/Source/cmFunctionBlocker.h @@ -3,6 +3,12 @@ #ifndef cmFunctionBlocker_h #define cmFunctionBlocker_h +#include "cmConfigure.h" // IWYU pragma: keep + +#include + +#include "cm_string_view.hxx" + #include "cmListFileCache.h" class cmExecutionStatus; @@ -14,8 +20,8 @@ public: /** * should a function be blocked */ - virtual bool IsFunctionBlocked(const cmListFileFunction& lff, cmMakefile& mf, - cmExecutionStatus& status) = 0; + bool IsFunctionBlocked(cmListFileFunction const& lff, + cmExecutionStatus& status); /** * should this function blocker be removed, useful when one function adds a @@ -39,7 +45,16 @@ public: } private: + virtual cm::string_view StartCommandName() const = 0; + virtual cm::string_view EndCommandName() const = 0; + + virtual bool Replay(std::vector const& functions, + cmExecutionStatus& status) = 0; + +private: cmListFileContext StartingContext; + std::vector Functions; + unsigned int ScopeDepth = 1; }; #endif diff --git a/Source/cmFunctionCommand.cxx b/Source/cmFunctionCommand.cxx index 51b6970..6a04196 100644 --- a/Source/cmFunctionCommand.cxx +++ b/Source/cmFunctionCommand.cxx @@ -5,6 +5,9 @@ #include #include +#include "cm_static_string_view.hxx" +#include "cm_string_view.hxx" + #include "cmAlgorithms.h" #include "cmExecutionStatus.h" #include "cmFunctionBlocker.h" @@ -107,40 +110,16 @@ bool cmFunctionHelperCommand::operator()( class cmFunctionFunctionBlocker : public cmFunctionBlocker { public: - bool IsFunctionBlocked(const cmListFileFunction&, cmMakefile& mf, - cmExecutionStatus&) override; + cm::string_view StartCommandName() const override { return "function"_s; } + cm::string_view EndCommandName() const override { return "endfunction"_s; } + bool ShouldRemove(const cmListFileFunction&, cmMakefile& mf) override; bool Replay(std::vector const& functions, - cmExecutionStatus& status); + cmExecutionStatus& status) override; std::vector Args; - std::vector Functions; - int Depth = 0; }; -bool cmFunctionFunctionBlocker::IsFunctionBlocked( - const cmListFileFunction& lff, cmMakefile& mf, cmExecutionStatus& status) -{ - // record commands until we hit the ENDFUNCTION - // at the ENDFUNCTION call we shift gears and start looking for invocations - if (lff.Name.Lower == "function") { - this->Depth++; - } else if (lff.Name.Lower == "endfunction") { - // if this is the endfunction for this function then execute - if (!this->Depth) { - auto self = mf.RemoveFunctionBlocker(this, lff); - return this->Replay(this->Functions, status); - } - // decrement for each nested function that ends - this->Depth--; - } - - // if it wasn't an endfunction and we are not executing then we must be - // recording - this->Functions.push_back(lff); - return true; -} - bool cmFunctionFunctionBlocker::ShouldRemove(const cmListFileFunction& lff, cmMakefile& mf) { diff --git a/Source/cmIfCommand.cxx b/Source/cmIfCommand.cxx index 95f8177..63cdd20 100644 --- a/Source/cmIfCommand.cxx +++ b/Source/cmIfCommand.cxx @@ -3,6 +3,8 @@ #include "cmIfCommand.h" #include "cm_memory.hxx" +#include "cm_static_string_view.hxx" +#include "cm_string_view.hxx" #include "cmConditionEvaluator.h" #include "cmExecutionStatus.h" @@ -33,51 +35,19 @@ static std::string cmIfCommandError( class cmIfFunctionBlocker : public cmFunctionBlocker { public: - bool IsFunctionBlocked(const cmListFileFunction& lff, cmMakefile& mf, - cmExecutionStatus&) override; + cm::string_view StartCommandName() const override { return "if"_s; } + cm::string_view EndCommandName() const override { return "endif"_s; } + bool ShouldRemove(const cmListFileFunction& lff, cmMakefile& mf) override; bool Replay(std::vector const& functions, - cmExecutionStatus& inStatus); + cmExecutionStatus& inStatus) override; std::vector Args; - std::vector Functions; bool IsBlocking; bool HasRun = false; bool ElseSeen = false; - unsigned int ScopeDepth = 0; }; -//========================================================================= -bool cmIfFunctionBlocker::IsFunctionBlocked(const cmListFileFunction& lff, - cmMakefile& mf, - cmExecutionStatus& inStatus) -{ - // we start by recording all the functions - if (lff.Name.Lower == "if") { - this->ScopeDepth++; - } else if (lff.Name.Lower == "endif") { - this->ScopeDepth--; - // if this is the endif for this if statement, then start executing - if (!this->ScopeDepth) { - // Remove the function blocker for this scope or bail. - std::unique_ptr fb( - mf.RemoveFunctionBlocker(this, lff)); - if (!fb) { - return false; - } - - return this->Replay(this->Functions, inStatus); - } - } - - // record the command - this->Functions.push_back(lff); - - // always return true - return true; -} - -//========================================================================= bool cmIfFunctionBlocker::ShouldRemove(const cmListFileFunction& lff, cmMakefile&) { @@ -235,7 +205,6 @@ bool cmIfCommand(std::vector const& args, { auto fb = cm::make_unique(); // if is isn't true block the commands - fb->ScopeDepth = 1; fb->IsBlocking = !isTrue; if (isTrue) { fb->HasRun = true; diff --git a/Source/cmMacroCommand.cxx b/Source/cmMacroCommand.cxx index e82d6fa..030bb66 100644 --- a/Source/cmMacroCommand.cxx +++ b/Source/cmMacroCommand.cxx @@ -7,6 +7,8 @@ #include #include "cm_memory.hxx" +#include "cm_static_string_view.hxx" +#include "cm_string_view.hxx" #include "cmAlgorithms.h" #include "cmExecutionStatus.h" @@ -141,41 +143,16 @@ bool cmMacroHelperCommand::operator()( class cmMacroFunctionBlocker : public cmFunctionBlocker { public: - bool IsFunctionBlocked(const cmListFileFunction&, cmMakefile& mf, - cmExecutionStatus&) override; + cm::string_view StartCommandName() const override { return "macro"_s; } + cm::string_view EndCommandName() const override { return "endmacro"_s; } + bool ShouldRemove(const cmListFileFunction&, cmMakefile& mf) override; bool Replay(std::vector const& functions, - cmExecutionStatus& status); + cmExecutionStatus& status) override; std::vector Args; - std::vector Functions; - int Depth = 0; }; -bool cmMacroFunctionBlocker::IsFunctionBlocked(const cmListFileFunction& lff, - cmMakefile& mf, - cmExecutionStatus& status) -{ - // record commands until we hit the ENDMACRO - // at the ENDMACRO call we shift gears and start looking for invocations - if (lff.Name.Lower == "macro") { - this->Depth++; - } else if (lff.Name.Lower == "endmacro") { - // if this is the endmacro for this macro then execute - if (!this->Depth) { - auto self = mf.RemoveFunctionBlocker(this, lff); - return this->Replay(this->Functions, status); - } - // decrement for each nested macro that ends - this->Depth--; - } - - // if it wasn't an endmacro and we are not executing then we must be - // recording - this->Functions.push_back(lff); - return true; -} - bool cmMacroFunctionBlocker::ShouldRemove(const cmListFileFunction& lff, cmMakefile& mf) { diff --git a/Source/cmMakefile.cxx b/Source/cmMakefile.cxx index f297fdf..8c11786 100644 --- a/Source/cmMakefile.cxx +++ b/Source/cmMakefile.cxx @@ -3070,7 +3070,7 @@ bool cmMakefile::IsFunctionBlocked(const cmListFileFunction& lff, return false; } - return this->FunctionBlockers.top()->IsFunctionBlocked(lff, *this, status); + return this->FunctionBlockers.top()->IsFunctionBlocked(lff, status); } void cmMakefile::PushFunctionBlockerBarrier() diff --git a/Source/cmWhileCommand.cxx b/Source/cmWhileCommand.cxx index 025d14a..bacee58 100644 --- a/Source/cmWhileCommand.cxx +++ b/Source/cmWhileCommand.cxx @@ -3,6 +3,8 @@ #include "cmWhileCommand.h" #include "cm_memory.hxx" +#include "cm_static_string_view.hxx" +#include "cm_string_view.hxx" #include "cmConditionEvaluator.h" #include "cmExecutionStatus.h" @@ -21,23 +23,22 @@ class cmWhileFunctionBlocker : public cmFunctionBlocker public: cmWhileFunctionBlocker(cmMakefile* mf); ~cmWhileFunctionBlocker() override; - bool IsFunctionBlocked(const cmListFileFunction& lff, cmMakefile& mf, - cmExecutionStatus&) override; + + cm::string_view StartCommandName() const override { return "while"_s; } + cm::string_view EndCommandName() const override { return "endwhile"_s; } + bool ShouldRemove(const cmListFileFunction& lff, cmMakefile& mf) override; bool Replay(std::vector const& functions, - cmExecutionStatus& inStatus); + cmExecutionStatus& inStatus) override; std::vector Args; - std::vector Functions; private: cmMakefile* Makefile; - int Depth; }; cmWhileFunctionBlocker::cmWhileFunctionBlocker(cmMakefile* mf) : Makefile(mf) - , Depth(0) { this->Makefile->PushLoopBlock(); } @@ -47,36 +48,6 @@ cmWhileFunctionBlocker::~cmWhileFunctionBlocker() this->Makefile->PopLoopBlock(); } -bool cmWhileFunctionBlocker::IsFunctionBlocked(const cmListFileFunction& lff, - cmMakefile& mf, - cmExecutionStatus& inStatus) -{ - // at end of for each execute recorded commands - if (lff.Name.Lower == "while") { - // record the number of while commands past this one - this->Depth++; - } else if (lff.Name.Lower == "endwhile") { - // if this is the endwhile for this while loop then execute - if (!this->Depth) { - // Remove the function blocker for this scope or bail. - std::unique_ptr fb( - mf.RemoveFunctionBlocker(this, lff)); - if (!fb) { - return false; - } - return this->Replay(this->Functions, inStatus); - } - // decrement for each nested while that ends - this->Depth--; - } - - // record the command - this->Functions.push_back(lff); - - // always return true - return true; -} - bool cmWhileFunctionBlocker::ShouldRemove(const cmListFileFunction& lff, cmMakefile&) { diff --git a/bootstrap b/bootstrap index 7d9631c..5742d53 100755 --- a/bootstrap +++ b/bootstrap @@ -326,6 +326,7 @@ CMAKE_CXX_SOURCES="\ cmFindPathCommand \ cmFindProgramCommand \ cmForEachCommand \ + cmFunctionBlocker \ cmFunctionCommand \ cmFSPermissions \ cmGeneratedFileStream \ https://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=ef38ff22f71ad0ffe83db42d903d26d4a41f4114 commit ef38ff22f71ad0ffe83db42d903d26d4a41f4114 Author: Regina Pfeifer AuthorDate: Tue Jul 23 23:50:33 2019 +0200 Commit: Regina Pfeifer CommitDate: Wed Jul 31 00:03:17 2019 +0200 cm*FunctionBlocker: Extract function Replay diff --git a/Source/cmForEachCommand.cxx b/Source/cmForEachCommand.cxx index b04f14c..af32040 100644 --- a/Source/cmForEachCommand.cxx +++ b/Source/cmForEachCommand.cxx @@ -25,6 +25,8 @@ public: bool IsFunctionBlocked(const cmListFileFunction& lff, cmMakefile& mf, cmExecutionStatus&) override; bool ShouldRemove(const cmListFileFunction& lff, cmMakefile& mf) override; + bool Replay(std::vector const& functions, + cmExecutionStatus& inStatus); std::vector Args; std::vector Functions; @@ -63,44 +65,7 @@ bool cmForEachFunctionBlocker::IsFunctionBlocked(const cmListFileFunction& lff, return false; } - // at end of for each execute recorded commands - // store the old value - std::string oldDef; - if (mf.GetDefinition(this->Args[0])) { - oldDef = mf.GetDefinition(this->Args[0]); - } - - for (std::string const& arg : cmMakeRange(this->Args).advance(1)) { - // set the variable to the loop value - mf.AddDefinition(this->Args[0], arg); - // Invoke all the functions that were collected in the block. - cmExecutionStatus status(mf); - for (cmListFileFunction const& func : this->Functions) { - status.Clear(); - mf.ExecuteCommand(func, status); - if (status.GetReturnInvoked()) { - inStatus.SetReturnInvoked(); - // restore the variable to its prior value - mf.AddDefinition(this->Args[0], oldDef); - return true; - } - if (status.GetBreakInvoked()) { - // restore the variable to its prior value - mf.AddDefinition(this->Args[0], oldDef); - return true; - } - if (status.GetContinueInvoked()) { - break; - } - if (cmSystemTools::GetFatalErrorOccured()) { - return true; - } - } - } - - // restore the variable to its prior value - mf.AddDefinition(this->Args[0], oldDef); - return true; + return this->Replay(this->Functions, inStatus); } // close out a nested foreach this->Depth--; @@ -129,6 +94,51 @@ bool cmForEachFunctionBlocker::ShouldRemove(const cmListFileFunction& lff, return false; } +bool cmForEachFunctionBlocker::Replay( + std::vector const& functions, + cmExecutionStatus& inStatus) +{ + cmMakefile& mf = inStatus.GetMakefile(); + // at end of for each execute recorded commands + // store the old value + std::string oldDef; + if (mf.GetDefinition(this->Args[0])) { + oldDef = mf.GetDefinition(this->Args[0]); + } + + for (std::string const& arg : cmMakeRange(this->Args).advance(1)) { + // set the variable to the loop value + mf.AddDefinition(this->Args[0], arg); + // Invoke all the functions that were collected in the block. + cmExecutionStatus status(mf); + for (cmListFileFunction const& func : functions) { + status.Clear(); + mf.ExecuteCommand(func, status); + if (status.GetReturnInvoked()) { + inStatus.SetReturnInvoked(); + // restore the variable to its prior value + mf.AddDefinition(this->Args[0], oldDef); + return true; + } + if (status.GetBreakInvoked()) { + // restore the variable to its prior value + mf.AddDefinition(this->Args[0], oldDef); + return true; + } + if (status.GetContinueInvoked()) { + break; + } + if (cmSystemTools::GetFatalErrorOccured()) { + return true; + } + } + } + + // restore the variable to its prior value + mf.AddDefinition(this->Args[0], oldDef); + return true; +} + bool cmForEachCommand::InitialPass(std::vector const& args, cmExecutionStatus&) { diff --git a/Source/cmFunctionCommand.cxx b/Source/cmFunctionCommand.cxx index f8230f1..51b6970 100644 --- a/Source/cmFunctionCommand.cxx +++ b/Source/cmFunctionCommand.cxx @@ -110,6 +110,8 @@ public: bool IsFunctionBlocked(const cmListFileFunction&, cmMakefile& mf, cmExecutionStatus&) override; bool ShouldRemove(const cmListFileFunction&, cmMakefile& mf) override; + bool Replay(std::vector const& functions, + cmExecutionStatus& status); std::vector Args; std::vector Functions; @@ -117,7 +119,7 @@ public: }; bool cmFunctionFunctionBlocker::IsFunctionBlocked( - const cmListFileFunction& lff, cmMakefile& mf, cmExecutionStatus&) + const cmListFileFunction& lff, cmMakefile& mf, cmExecutionStatus& status) { // record commands until we hit the ENDFUNCTION // at the ENDFUNCTION call we shift gears and start looking for invocations @@ -126,16 +128,8 @@ bool cmFunctionFunctionBlocker::IsFunctionBlocked( } else if (lff.Name.Lower == "endfunction") { // if this is the endfunction for this function then execute if (!this->Depth) { - // create a new command and add it to cmake - cmFunctionHelperCommand f; - f.Args = this->Args; - f.Functions = this->Functions; - f.FilePath = this->GetStartingContext().FilePath; - mf.RecordPolicies(f.Policies); - mf.GetState()->AddScriptedCommand(this->Args[0], std::move(f)); - // remove the function blocker now that the function is defined - mf.RemoveFunctionBlocker(this, lff); - return true; + auto self = mf.RemoveFunctionBlocker(this, lff); + return this->Replay(this->Functions, status); } // decrement for each nested function that ends this->Depth--; @@ -165,6 +159,20 @@ bool cmFunctionFunctionBlocker::ShouldRemove(const cmListFileFunction& lff, return false; } +bool cmFunctionFunctionBlocker::Replay( + std::vector const& functions, cmExecutionStatus& status) +{ + cmMakefile& mf = status.GetMakefile(); + // create a new command and add it to cmake + cmFunctionHelperCommand f; + f.Args = this->Args; + f.Functions = functions; + f.FilePath = this->GetStartingContext().FilePath; + mf.RecordPolicies(f.Policies); + mf.GetState()->AddScriptedCommand(this->Args[0], std::move(f)); + return true; +} + bool cmFunctionCommand::InitialPass(std::vector const& args, cmExecutionStatus&) { diff --git a/Source/cmIfCommand.cxx b/Source/cmIfCommand.cxx index 20fe2f8..95f8177 100644 --- a/Source/cmIfCommand.cxx +++ b/Source/cmIfCommand.cxx @@ -36,6 +36,8 @@ public: bool IsFunctionBlocked(const cmListFileFunction& lff, cmMakefile& mf, cmExecutionStatus&) override; bool ShouldRemove(const cmListFileFunction& lff, cmMakefile& mf) override; + bool Replay(std::vector const& functions, + cmExecutionStatus& inStatus); std::vector Args; std::vector Functions; @@ -64,110 +66,7 @@ bool cmIfFunctionBlocker::IsFunctionBlocked(const cmListFileFunction& lff, return false; } - // execute the functions for the true parts of the if statement - cmExecutionStatus status(mf); - int scopeDepth = 0; - for (cmListFileFunction const& func : this->Functions) { - // keep track of scope depth - if (func.Name.Lower == "if") { - scopeDepth++; - } - if (func.Name.Lower == "endif") { - scopeDepth--; - } - // watch for our state change - if (scopeDepth == 0 && func.Name.Lower == "else") { - - if (this->ElseSeen) { - cmListFileBacktrace bt = mf.GetBacktrace(func); - mf.GetCMakeInstance()->IssueMessage( - MessageType::FATAL_ERROR, - "A duplicate ELSE command was found inside an IF block.", bt); - cmSystemTools::SetFatalErrorOccured(); - return true; - } - - this->IsBlocking = this->HasRun; - this->HasRun = true; - this->ElseSeen = true; - - // if trace is enabled, print a (trivially) evaluated "else" - // statement - if (!this->IsBlocking && mf.GetCMakeInstance()->GetTrace()) { - mf.PrintCommandTrace(func); - } - } else if (scopeDepth == 0 && func.Name.Lower == "elseif") { - if (this->ElseSeen) { - cmListFileBacktrace bt = mf.GetBacktrace(func); - mf.GetCMakeInstance()->IssueMessage( - MessageType::FATAL_ERROR, - "An ELSEIF command was found after an ELSE command.", bt); - cmSystemTools::SetFatalErrorOccured(); - return true; - } - - if (this->HasRun) { - this->IsBlocking = true; - } else { - // if trace is enabled, print the evaluated "elseif" statement - if (mf.GetCMakeInstance()->GetTrace()) { - mf.PrintCommandTrace(func); - } - - std::string errorString; - - std::vector expandedArguments; - mf.ExpandArguments(func.Arguments, expandedArguments); - - MessageType messType; - - cmListFileContext conditionContext = - cmListFileContext::FromCommandContext( - func, this->GetStartingContext().FilePath); - - cmConditionEvaluator conditionEvaluator(mf, conditionContext, - mf.GetBacktrace(func)); - - bool isTrue = conditionEvaluator.IsTrue(expandedArguments, - errorString, messType); - - if (!errorString.empty()) { - std::string err = cmIfCommandError(expandedArguments); - err += errorString; - cmListFileBacktrace bt = mf.GetBacktrace(func); - mf.GetCMakeInstance()->IssueMessage(messType, err, bt); - if (messType == MessageType::FATAL_ERROR) { - cmSystemTools::SetFatalErrorOccured(); - return true; - } - } - - if (isTrue) { - this->IsBlocking = false; - this->HasRun = true; - } - } - } - - // should we execute? - else if (!this->IsBlocking) { - status.Clear(); - mf.ExecuteCommand(func, status); - if (status.GetReturnInvoked()) { - inStatus.SetReturnInvoked(); - return true; - } - if (status.GetBreakInvoked()) { - inStatus.SetBreakInvoked(); - return true; - } - if (status.GetContinueInvoked()) { - inStatus.SetContinueInvoked(); - return true; - } - } - } - return true; + return this->Replay(this->Functions, inStatus); } } @@ -193,6 +92,117 @@ bool cmIfFunctionBlocker::ShouldRemove(const cmListFileFunction& lff, return false; } +bool cmIfFunctionBlocker::Replay( + std::vector const& functions, + cmExecutionStatus& inStatus) +{ + cmMakefile& mf = inStatus.GetMakefile(); + // execute the functions for the true parts of the if statement + cmExecutionStatus status(mf); + int scopeDepth = 0; + for (cmListFileFunction const& func : functions) { + // keep track of scope depth + if (func.Name.Lower == "if") { + scopeDepth++; + } + if (func.Name.Lower == "endif") { + scopeDepth--; + } + // watch for our state change + if (scopeDepth == 0 && func.Name.Lower == "else") { + + if (this->ElseSeen) { + cmListFileBacktrace bt = mf.GetBacktrace(func); + mf.GetCMakeInstance()->IssueMessage( + MessageType::FATAL_ERROR, + "A duplicate ELSE command was found inside an IF block.", bt); + cmSystemTools::SetFatalErrorOccured(); + return true; + } + + this->IsBlocking = this->HasRun; + this->HasRun = true; + this->ElseSeen = true; + + // if trace is enabled, print a (trivially) evaluated "else" + // statement + if (!this->IsBlocking && mf.GetCMakeInstance()->GetTrace()) { + mf.PrintCommandTrace(func); + } + } else if (scopeDepth == 0 && func.Name.Lower == "elseif") { + if (this->ElseSeen) { + cmListFileBacktrace bt = mf.GetBacktrace(func); + mf.GetCMakeInstance()->IssueMessage( + MessageType::FATAL_ERROR, + "An ELSEIF command was found after an ELSE command.", bt); + cmSystemTools::SetFatalErrorOccured(); + return true; + } + + if (this->HasRun) { + this->IsBlocking = true; + } else { + // if trace is enabled, print the evaluated "elseif" statement + if (mf.GetCMakeInstance()->GetTrace()) { + mf.PrintCommandTrace(func); + } + + std::string errorString; + + std::vector expandedArguments; + mf.ExpandArguments(func.Arguments, expandedArguments); + + MessageType messType; + + cmListFileContext conditionContext = + cmListFileContext::FromCommandContext( + func, this->GetStartingContext().FilePath); + + cmConditionEvaluator conditionEvaluator(mf, conditionContext, + mf.GetBacktrace(func)); + + bool isTrue = + conditionEvaluator.IsTrue(expandedArguments, errorString, messType); + + if (!errorString.empty()) { + std::string err = cmIfCommandError(expandedArguments); + err += errorString; + cmListFileBacktrace bt = mf.GetBacktrace(func); + mf.GetCMakeInstance()->IssueMessage(messType, err, bt); + if (messType == MessageType::FATAL_ERROR) { + cmSystemTools::SetFatalErrorOccured(); + return true; + } + } + + if (isTrue) { + this->IsBlocking = false; + this->HasRun = true; + } + } + } + + // should we execute? + else if (!this->IsBlocking) { + status.Clear(); + mf.ExecuteCommand(func, status); + if (status.GetReturnInvoked()) { + inStatus.SetReturnInvoked(); + return true; + } + if (status.GetBreakInvoked()) { + inStatus.SetBreakInvoked(); + return true; + } + if (status.GetContinueInvoked()) { + inStatus.SetContinueInvoked(); + return true; + } + } + } + return true; +} + //========================================================================= bool cmIfCommand(std::vector const& args, cmExecutionStatus& inStatus) diff --git a/Source/cmMacroCommand.cxx b/Source/cmMacroCommand.cxx index a123f22..e82d6fa 100644 --- a/Source/cmMacroCommand.cxx +++ b/Source/cmMacroCommand.cxx @@ -144,6 +144,8 @@ public: bool IsFunctionBlocked(const cmListFileFunction&, cmMakefile& mf, cmExecutionStatus&) override; bool ShouldRemove(const cmListFileFunction&, cmMakefile& mf) override; + bool Replay(std::vector const& functions, + cmExecutionStatus& status); std::vector Args; std::vector Functions; @@ -152,7 +154,7 @@ public: bool cmMacroFunctionBlocker::IsFunctionBlocked(const cmListFileFunction& lff, cmMakefile& mf, - cmExecutionStatus&) + cmExecutionStatus& status) { // record commands until we hit the ENDMACRO // at the ENDMACRO call we shift gears and start looking for invocations @@ -161,17 +163,8 @@ bool cmMacroFunctionBlocker::IsFunctionBlocked(const cmListFileFunction& lff, } else if (lff.Name.Lower == "endmacro") { // if this is the endmacro for this macro then execute if (!this->Depth) { - mf.AppendProperty("MACROS", this->Args[0].c_str()); - // create a new command and add it to cmake - cmMacroHelperCommand f; - f.Args = this->Args; - f.Functions = this->Functions; - f.FilePath = this->GetStartingContext().FilePath; - mf.RecordPolicies(f.Policies); - mf.GetState()->AddScriptedCommand(this->Args[0], std::move(f)); - // remove the function blocker now that the macro is defined - mf.RemoveFunctionBlocker(this, lff); - return true; + auto self = mf.RemoveFunctionBlocker(this, lff); + return this->Replay(this->Functions, status); } // decrement for each nested macro that ends this->Depth--; @@ -201,6 +194,21 @@ bool cmMacroFunctionBlocker::ShouldRemove(const cmListFileFunction& lff, return false; } +bool cmMacroFunctionBlocker::Replay( + std::vector const& functions, cmExecutionStatus& status) +{ + cmMakefile& mf = status.GetMakefile(); + mf.AppendProperty("MACROS", this->Args[0].c_str()); + // create a new command and add it to cmake + cmMacroHelperCommand f; + f.Args = this->Args; + f.Functions = functions; + f.FilePath = this->GetStartingContext().FilePath; + mf.RecordPolicies(f.Policies); + mf.GetState()->AddScriptedCommand(this->Args[0], std::move(f)); + return true; +} + bool cmMacroCommand::InitialPass(std::vector const& args, cmExecutionStatus&) { diff --git a/Source/cmWhileCommand.cxx b/Source/cmWhileCommand.cxx index 914860c..025d14a 100644 --- a/Source/cmWhileCommand.cxx +++ b/Source/cmWhileCommand.cxx @@ -24,6 +24,8 @@ public: bool IsFunctionBlocked(const cmListFileFunction& lff, cmMakefile& mf, cmExecutionStatus&) override; bool ShouldRemove(const cmListFileFunction& lff, cmMakefile& mf) override; + bool Replay(std::vector const& functions, + cmExecutionStatus& inStatus); std::vector Args; std::vector Functions; @@ -62,68 +64,7 @@ bool cmWhileFunctionBlocker::IsFunctionBlocked(const cmListFileFunction& lff, if (!fb) { return false; } - - std::string errorString; - - std::vector expandedArguments; - mf.ExpandArguments(this->Args, expandedArguments); - MessageType messageType; - - cmListFileContext execContext = this->GetStartingContext(); - - cmCommandContext commandContext; - commandContext.Line = execContext.Line; - commandContext.Name = execContext.Name; - - cmConditionEvaluator conditionEvaluator(mf, this->GetStartingContext(), - mf.GetBacktrace(commandContext)); - - bool isTrue = - conditionEvaluator.IsTrue(expandedArguments, errorString, messageType); - - while (isTrue) { - if (!errorString.empty()) { - std::string err = "had incorrect arguments: "; - for (cmListFileArgument const& arg : this->Args) { - err += (arg.Delim ? "\"" : ""); - err += arg.Value; - err += (arg.Delim ? "\"" : ""); - err += " "; - } - err += "("; - err += errorString; - err += ")."; - mf.IssueMessage(messageType, err); - if (messageType == MessageType::FATAL_ERROR) { - cmSystemTools::SetFatalErrorOccured(); - return true; - } - } - - // Invoke all the functions that were collected in the block. - for (cmListFileFunction const& fn : this->Functions) { - cmExecutionStatus status(mf); - mf.ExecuteCommand(fn, status); - if (status.GetReturnInvoked()) { - inStatus.SetReturnInvoked(); - return true; - } - if (status.GetBreakInvoked()) { - return true; - } - if (status.GetContinueInvoked()) { - break; - } - if (cmSystemTools::GetFatalErrorOccured()) { - return true; - } - } - expandedArguments.clear(); - mf.ExpandArguments(this->Args, expandedArguments); - isTrue = conditionEvaluator.IsTrue(expandedArguments, errorString, - messageType); - } - return true; + return this->Replay(this->Functions, inStatus); } // decrement for each nested while that ends this->Depth--; @@ -149,6 +90,74 @@ bool cmWhileFunctionBlocker::ShouldRemove(const cmListFileFunction& lff, return false; } +bool cmWhileFunctionBlocker::Replay( + std::vector const& functions, + cmExecutionStatus& inStatus) +{ + cmMakefile& mf = inStatus.GetMakefile(); + std::string errorString; + + std::vector expandedArguments; + mf.ExpandArguments(this->Args, expandedArguments); + MessageType messageType; + + cmListFileContext execContext = this->GetStartingContext(); + + cmCommandContext commandContext; + commandContext.Line = execContext.Line; + commandContext.Name = execContext.Name; + + cmConditionEvaluator conditionEvaluator(mf, this->GetStartingContext(), + mf.GetBacktrace(commandContext)); + + bool isTrue = + conditionEvaluator.IsTrue(expandedArguments, errorString, messageType); + + while (isTrue) { + if (!errorString.empty()) { + std::string err = "had incorrect arguments: "; + for (cmListFileArgument const& arg : this->Args) { + err += (arg.Delim ? "\"" : ""); + err += arg.Value; + err += (arg.Delim ? "\"" : ""); + err += " "; + } + err += "("; + err += errorString; + err += ")."; + mf.IssueMessage(messageType, err); + if (messageType == MessageType::FATAL_ERROR) { + cmSystemTools::SetFatalErrorOccured(); + return true; + } + } + + // Invoke all the functions that were collected in the block. + for (cmListFileFunction const& fn : functions) { + cmExecutionStatus status(mf); + mf.ExecuteCommand(fn, status); + if (status.GetReturnInvoked()) { + inStatus.SetReturnInvoked(); + return true; + } + if (status.GetBreakInvoked()) { + return true; + } + if (status.GetContinueInvoked()) { + break; + } + if (cmSystemTools::GetFatalErrorOccured()) { + return true; + } + } + expandedArguments.clear(); + mf.ExpandArguments(this->Args, expandedArguments); + isTrue = + conditionEvaluator.IsTrue(expandedArguments, errorString, messageType); + } + return true; +} + bool cmWhileCommand(std::vector const& args, cmExecutionStatus& status) { https://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=b51fba6298012c3b697c461486ce06c9e5c97c16 commit b51fba6298012c3b697c461486ce06c9e5c97c16 Author: Regina Pfeifer AuthorDate: Sat Jul 27 00:21:01 2019 +0200 Commit: Regina Pfeifer CommitDate: Wed Jul 31 00:03:17 2019 +0200 cmMakefile: Add OnExecuteCommand callback In cmCTestScriptHandler, port away from cmFunctionBlocker and update the elapsed time with the new callback instead. diff --git a/Source/CTest/cmCTestScriptHandler.cxx b/Source/CTest/cmCTestScriptHandler.cxx index 7a5b8d1..f8d9f1b 100644 --- a/Source/CTest/cmCTestScriptHandler.cxx +++ b/Source/CTest/cmCTestScriptHandler.cxx @@ -24,7 +24,6 @@ #include "cmCTestUploadCommand.h" #include "cmCommand.h" #include "cmDuration.h" -#include "cmFunctionBlocker.h" #include "cmGeneratedFileStream.h" #include "cmGlobalGenerator.h" #include "cmMakefile.h" @@ -49,32 +48,8 @@ # include #endif -class cmExecutionStatus; -struct cmListFileFunction; - #define CTEST_INITIAL_CMAKE_OUTPUT_FILE_NAME "CTestInitialCMakeOutput.log" -// used to keep elapsed time up to date -class cmCTestScriptFunctionBlocker : public cmFunctionBlocker -{ -public: - bool IsFunctionBlocked(const cmListFileFunction& lff, cmMakefile& mf, - cmExecutionStatus& /*status*/) override; - // virtual bool ShouldRemove(const cmListFileFunction& lff, cmMakefile &mf); - // virtual void ScopeEnded(cmMakefile &mf); - - cmCTestScriptHandler* CTestScriptHandler; -}; - -// simply update the time and don't block anything -bool cmCTestScriptFunctionBlocker::IsFunctionBlocked( - const cmListFileFunction& /*lff*/, cmMakefile& /*mf*/, - cmExecutionStatus& /*status*/) -{ - this->CTestScriptHandler->UpdateElapsedTime(); - return false; -} - cmCTestScriptHandler::cmCTestScriptHandler() { this->Backup = false; @@ -373,12 +348,8 @@ int cmCTestScriptHandler::ReadInScript(const std::string& total_script_arg) this->Makefile->AddDefinition("CMAKE_LEGACY_CYGWIN_WIN32", "0"); #endif - // always add a function blocker to update the elapsed time - { - auto fb = cm::make_unique(); - fb->CTestScriptHandler = this; - this->Makefile->AddFunctionBlocker(std::move(fb)); - } + // set a callback function to update the elapsed time + this->Makefile->OnExecuteCommand([this] { this->UpdateElapsedTime(); }); /* Execute CTestScriptMode.cmake, which loads CMakeDetermineSystem and CMakeSystemSpecificInformation, so diff --git a/Source/cmMakefile.cxx b/Source/cmMakefile.cxx index 8188ffa..f297fdf 100644 --- a/Source/cmMakefile.cxx +++ b/Source/cmMakefile.cxx @@ -353,6 +353,11 @@ private: cmMakefile* Makefile; }; +void cmMakefile::OnExecuteCommand(std::function callback) +{ + this->ExecuteCommandCallback = std::move(callback); +} + bool cmMakefile::ExecuteCommand(const cmListFileFunction& lff, cmExecutionStatus& status) { @@ -364,6 +369,10 @@ bool cmMakefile::ExecuteCommand(const cmListFileFunction& lff, return result; } + if (this->ExecuteCommandCallback) { + this->ExecuteCommandCallback(); + } + // Place this call on the call stack. cmMakefileCall stack_manager(this, lff, status); static_cast(stack_manager); diff --git a/Source/cmMakefile.h b/Source/cmMakefile.h index dc196ac..941e335 100644 --- a/Source/cmMakefile.h +++ b/Source/cmMakefile.h @@ -628,6 +628,11 @@ public: void PrintCommandTrace(const cmListFileFunction& lff) const; /** + * Set a callback that is invoked whenever ExecuteCommand is called. + */ + void OnExecuteCommand(std::function callback); + + /** * Execute a single CMake command. Returns true if the command * succeeded or false if it failed. */ @@ -964,6 +969,7 @@ private: bool EnforceUniqueDir(const std::string& srcPath, const std::string& binPath) const; + std::function ExecuteCommandCallback; using FunctionBlockerPtr = std::unique_ptr; using FunctionBlockersType = std::stack>; https://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=c76500949d3fcf5ff83ac6e7f1d565f5d786c5f0 commit c76500949d3fcf5ff83ac6e7f1d565f5d786c5f0 Author: Regina Pfeifer AuthorDate: Tue Jul 23 23:00:28 2019 +0200 Commit: Regina Pfeifer CommitDate: Tue Jul 30 17:21:50 2019 +0200 cm*FunctionBlocker: Move to source file diff --git a/Source/cmForEachCommand.cxx b/Source/cmForEachCommand.cxx index 06dce2c..b04f14c 100644 --- a/Source/cmForEachCommand.cxx +++ b/Source/cmForEachCommand.cxx @@ -10,11 +10,30 @@ #include "cm_memory.hxx" #include "cmExecutionStatus.h" +#include "cmFunctionBlocker.h" +#include "cmListFileCache.h" #include "cmMakefile.h" #include "cmMessageType.h" #include "cmRange.h" #include "cmSystemTools.h" +class cmForEachFunctionBlocker : public cmFunctionBlocker +{ +public: + cmForEachFunctionBlocker(cmMakefile* mf); + ~cmForEachFunctionBlocker() override; + bool IsFunctionBlocked(const cmListFileFunction& lff, cmMakefile& mf, + cmExecutionStatus&) override; + bool ShouldRemove(const cmListFileFunction& lff, cmMakefile& mf) override; + + std::vector Args; + std::vector Functions; + +private: + cmMakefile* Makefile; + int Depth; +}; + cmForEachFunctionBlocker::cmForEachFunctionBlocker(cmMakefile* mf) : Makefile(mf) , Depth(0) diff --git a/Source/cmForEachCommand.h b/Source/cmForEachCommand.h index cd112b8..135abf0 100644 --- a/Source/cmForEachCommand.h +++ b/Source/cmForEachCommand.h @@ -11,28 +11,8 @@ #include "cm_memory.hxx" #include "cmCommand.h" -#include "cmFunctionBlocker.h" -#include "cmListFileCache.h" class cmExecutionStatus; -class cmMakefile; - -class cmForEachFunctionBlocker : public cmFunctionBlocker -{ -public: - cmForEachFunctionBlocker(cmMakefile* mf); - ~cmForEachFunctionBlocker() override; - bool IsFunctionBlocked(const cmListFileFunction& lff, cmMakefile& mf, - cmExecutionStatus&) override; - bool ShouldRemove(const cmListFileFunction& lff, cmMakefile& mf) override; - - std::vector Args; - std::vector Functions; - -private: - cmMakefile* Makefile; - int Depth; -}; /// Starts foreach() ... endforeach() block class cmForEachCommand : public cmCommand diff --git a/Source/cmFunctionCommand.cxx b/Source/cmFunctionCommand.cxx index 2809cf7..f8230f1 100644 --- a/Source/cmFunctionCommand.cxx +++ b/Source/cmFunctionCommand.cxx @@ -7,6 +7,8 @@ #include "cmAlgorithms.h" #include "cmExecutionStatus.h" +#include "cmFunctionBlocker.h" +#include "cmListFileCache.h" #include "cmMakefile.h" #include "cmPolicies.h" #include "cmRange.h" @@ -102,6 +104,18 @@ bool cmFunctionHelperCommand::operator()( return true; } +class cmFunctionFunctionBlocker : public cmFunctionBlocker +{ +public: + bool IsFunctionBlocked(const cmListFileFunction&, cmMakefile& mf, + cmExecutionStatus&) override; + bool ShouldRemove(const cmListFileFunction&, cmMakefile& mf) override; + + std::vector Args; + std::vector Functions; + int Depth = 0; +}; + bool cmFunctionFunctionBlocker::IsFunctionBlocked( const cmListFileFunction& lff, cmMakefile& mf, cmExecutionStatus&) { diff --git a/Source/cmFunctionCommand.h b/Source/cmFunctionCommand.h index 449a180..b334525 100644 --- a/Source/cmFunctionCommand.h +++ b/Source/cmFunctionCommand.h @@ -11,23 +11,8 @@ #include "cm_memory.hxx" #include "cmCommand.h" -#include "cmFunctionBlocker.h" -#include "cmListFileCache.h" class cmExecutionStatus; -class cmMakefile; - -class cmFunctionFunctionBlocker : public cmFunctionBlocker -{ -public: - bool IsFunctionBlocked(const cmListFileFunction&, cmMakefile& mf, - cmExecutionStatus&) override; - bool ShouldRemove(const cmListFileFunction&, cmMakefile& mf) override; - - std::vector Args; - std::vector Functions; - int Depth = 0; -}; /// Starts function() ... endfunction() block class cmFunctionCommand : public cmCommand diff --git a/Source/cmIfCommand.cxx b/Source/cmIfCommand.cxx index 385022c..20fe2f8 100644 --- a/Source/cmIfCommand.cxx +++ b/Source/cmIfCommand.cxx @@ -7,6 +7,8 @@ #include "cmConditionEvaluator.h" #include "cmExecutionStatus.h" #include "cmExpandedCommandArgument.h" +#include "cmFunctionBlocker.h" +#include "cmListFileCache.h" #include "cmMakefile.h" #include "cmMessageType.h" #include "cmOutputConverter.h" @@ -28,6 +30,21 @@ static std::string cmIfCommandError( return err; } +class cmIfFunctionBlocker : public cmFunctionBlocker +{ +public: + bool IsFunctionBlocked(const cmListFileFunction& lff, cmMakefile& mf, + cmExecutionStatus&) override; + bool ShouldRemove(const cmListFileFunction& lff, cmMakefile& mf) override; + + std::vector Args; + std::vector Functions; + bool IsBlocking; + bool HasRun = false; + bool ElseSeen = false; + unsigned int ScopeDepth = 0; +}; + //========================================================================= bool cmIfFunctionBlocker::IsFunctionBlocked(const cmListFileFunction& lff, cmMakefile& mf, diff --git a/Source/cmIfCommand.h b/Source/cmIfCommand.h index 775e609..820ffa4 100644 --- a/Source/cmIfCommand.h +++ b/Source/cmIfCommand.h @@ -7,26 +7,8 @@ #include -#include "cmFunctionBlocker.h" -#include "cmListFileCache.h" - class cmExecutionStatus; -class cmMakefile; - -class cmIfFunctionBlocker : public cmFunctionBlocker -{ -public: - bool IsFunctionBlocked(const cmListFileFunction& lff, cmMakefile& mf, - cmExecutionStatus&) override; - bool ShouldRemove(const cmListFileFunction& lff, cmMakefile& mf) override; - - std::vector Args; - std::vector Functions; - bool IsBlocking; - bool HasRun = false; - bool ElseSeen = false; - unsigned int ScopeDepth = 0; -}; +struct cmListFileArgument; /// Starts an if block bool cmIfCommand(std::vector const& args, diff --git a/Source/cmMacroCommand.cxx b/Source/cmMacroCommand.cxx index 1f2b5b2..a123f22 100644 --- a/Source/cmMacroCommand.cxx +++ b/Source/cmMacroCommand.cxx @@ -10,6 +10,8 @@ #include "cmAlgorithms.h" #include "cmExecutionStatus.h" +#include "cmFunctionBlocker.h" +#include "cmListFileCache.h" #include "cmMakefile.h" #include "cmPolicies.h" #include "cmRange.h" @@ -136,6 +138,18 @@ bool cmMacroHelperCommand::operator()( return true; } +class cmMacroFunctionBlocker : public cmFunctionBlocker +{ +public: + bool IsFunctionBlocked(const cmListFileFunction&, cmMakefile& mf, + cmExecutionStatus&) override; + bool ShouldRemove(const cmListFileFunction&, cmMakefile& mf) override; + + std::vector Args; + std::vector Functions; + int Depth = 0; +}; + bool cmMacroFunctionBlocker::IsFunctionBlocked(const cmListFileFunction& lff, cmMakefile& mf, cmExecutionStatus&) diff --git a/Source/cmMacroCommand.h b/Source/cmMacroCommand.h index 3ebd959..0d7083a 100644 --- a/Source/cmMacroCommand.h +++ b/Source/cmMacroCommand.h @@ -11,23 +11,8 @@ #include "cm_memory.hxx" #include "cmCommand.h" -#include "cmFunctionBlocker.h" -#include "cmListFileCache.h" class cmExecutionStatus; -class cmMakefile; - -class cmMacroFunctionBlocker : public cmFunctionBlocker -{ -public: - bool IsFunctionBlocked(const cmListFileFunction&, cmMakefile& mf, - cmExecutionStatus&) override; - bool ShouldRemove(const cmListFileFunction&, cmMakefile& mf) override; - - std::vector Args; - std::vector Functions; - int Depth = 0; -}; /// Starts macro() ... endmacro() block class cmMacroCommand : public cmCommand diff --git a/Source/cmWhileCommand.cxx b/Source/cmWhileCommand.cxx index 37d1c74..914860c 100644 --- a/Source/cmWhileCommand.cxx +++ b/Source/cmWhileCommand.cxx @@ -7,6 +7,8 @@ #include "cmConditionEvaluator.h" #include "cmExecutionStatus.h" #include "cmExpandedCommandArgument.h" +#include "cmFunctionBlocker.h" +#include "cmListFileCache.h" #include "cmMakefile.h" #include "cmMessageType.h" #include "cmSystemTools.h" @@ -14,6 +16,23 @@ #include #include +class cmWhileFunctionBlocker : public cmFunctionBlocker +{ +public: + cmWhileFunctionBlocker(cmMakefile* mf); + ~cmWhileFunctionBlocker() override; + bool IsFunctionBlocked(const cmListFileFunction& lff, cmMakefile& mf, + cmExecutionStatus&) override; + bool ShouldRemove(const cmListFileFunction& lff, cmMakefile& mf) override; + + std::vector Args; + std::vector Functions; + +private: + cmMakefile* Makefile; + int Depth; +}; + cmWhileFunctionBlocker::cmWhileFunctionBlocker(cmMakefile* mf) : Makefile(mf) , Depth(0) diff --git a/Source/cmWhileCommand.h b/Source/cmWhileCommand.h index 2257799..beca652 100644 --- a/Source/cmWhileCommand.h +++ b/Source/cmWhileCommand.h @@ -7,28 +7,8 @@ #include -#include "cmFunctionBlocker.h" -#include "cmListFileCache.h" - class cmExecutionStatus; -class cmMakefile; - -class cmWhileFunctionBlocker : public cmFunctionBlocker -{ -public: - cmWhileFunctionBlocker(cmMakefile* mf); - ~cmWhileFunctionBlocker() override; - bool IsFunctionBlocked(const cmListFileFunction& lff, cmMakefile& mf, - cmExecutionStatus&) override; - bool ShouldRemove(const cmListFileFunction& lff, cmMakefile& mf) override; - - std::vector Args; - std::vector Functions; - -private: - cmMakefile* Makefile; - int Depth; -}; +struct cmListFileArgument; /// \brief Starts a while loop bool cmWhileCommand(std::vector const& args, ----------------------------------------------------------------------- Summary of changes: Source/CMakeLists.txt | 2 + Source/CTest/cmCTestScriptHandler.cxx | 33 +---- Source/cmForEachCommand.cxx | 141 +++++++++---------- Source/cmForEachCommand.h | 20 --- Source/cmFunctionBlocker.cxx | 46 +++++++ Source/cmFunctionBlocker.h | 31 +++-- Source/cmFunctionCommand.cxx | 78 +++++------ Source/cmFunctionCommand.h | 15 -- Source/cmIfCommand.cxx | 249 ++++++++++++++++------------------ Source/cmIfCommand.h | 20 +-- Source/cmMacroCommand.cxx | 80 +++++------ Source/cmMacroCommand.h | 15 -- Source/cmMakefile.cxx | 31 ++--- Source/cmMakefile.h | 9 +- Source/cmWhileCommand.cxx | 185 ++++++++++++------------- Source/cmWhileCommand.h | 22 +-- bootstrap | 1 + 17 files changed, 438 insertions(+), 540 deletions(-) create mode 100644 Source/cmFunctionBlocker.cxx hooks/post-receive -- CMake From kwrobot at kitware.com Tue Aug 6 00:01:25 2019 From: kwrobot at kitware.com (Kitware Robot) Date: Tue, 6 Aug 2019 00:01:25 -0400 (EDT) Subject: [Cmake-commits] CMake branch, master, updated. v3.15.1-588-g53fc083 Message-ID: <20190806040125.DCB541251D5@public.kitware.com> This is an automated email from the git hooks/post-receive script. It was generated because a ref change was pushed to the repository containing the project "CMake". The branch, master has been updated via 53fc083d3744555600a6a20d9bbdc0712a46cce0 (commit) from 2327cc0e0575175e8dec4b7a6fa6cafd5d0f7ca9 (commit) Those revisions listed above that are new to this repository have not appeared on any other notification email; so we list those revisions in full, below. - Log ----------------------------------------------------------------- https://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=53fc083d3744555600a6a20d9bbdc0712a46cce0 commit 53fc083d3744555600a6a20d9bbdc0712a46cce0 Author: Kitware Robot AuthorDate: Tue Aug 6 00:01:07 2019 -0400 Commit: Kitware Robot CommitDate: Tue Aug 6 00:01:07 2019 -0400 CMake Nightly Date Stamp diff --git a/Source/CMakeVersion.cmake b/Source/CMakeVersion.cmake index 3bbbd28..e6d5e9d 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 15) -set(CMake_VERSION_PATCH 20190805) +set(CMake_VERSION_PATCH 20190806) #set(CMake_VERSION_RC 0) set(CMake_VERSION_IS_DIRTY 0) ----------------------------------------------------------------------- Summary of changes: Source/CMakeVersion.cmake | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) hooks/post-receive -- CMake From kwrobot at kitware.com Tue Aug 6 09:51:10 2019 From: kwrobot at kitware.com (Kitware Robot) Date: Tue, 6 Aug 2019 09:51:10 -0400 (EDT) Subject: [Cmake-commits] CMake branch, master, updated. v3.15.1-592-gfdaad9a Message-ID: <20190806135110.99B46F69E4@public.kitware.com> This is an automated email from the git hooks/post-receive script. It was generated because a ref change was pushed to the repository containing the project "CMake". The branch, master has been updated via fdaad9a067e8fa55816d9cef2481450fc5b1f18b (commit) via 6f359e120ff80e8ab280dc535aad5e9532cf5ef5 (commit) via 1c3404a301959690ca967b0c751c0df1f57a1ecd (commit) via a245479372363b6693c180f65781ac9d434a2380 (commit) from 53fc083d3744555600a6a20d9bbdc0712a46cce0 (commit) Those revisions listed above that are new to this repository have not appeared on any other notification email; so we list those revisions in full, below. - Log ----------------------------------------------------------------- https://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=fdaad9a067e8fa55816d9cef2481450fc5b1f18b commit fdaad9a067e8fa55816d9cef2481450fc5b1f18b Merge: 6f359e1 1c3404a Author: Brad King AuthorDate: Tue Aug 6 09:42:26 2019 -0400 Commit: Brad King CommitDate: Tue Aug 6 09:42:26 2019 -0400 Merge branch 'release-3.15' https://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=6f359e120ff80e8ab280dc535aad5e9532cf5ef5 commit 6f359e120ff80e8ab280dc535aad5e9532cf5ef5 Merge: 53fc083 a245479 Author: Brad King AuthorDate: Tue Aug 6 13:41:27 2019 +0000 Commit: Kitware Robot CommitDate: Tue Aug 6 09:41:38 2019 -0400 Merge topic 'clang-frontend-variant' a245479372 clang: Work around toolchain file use of internal CMake variables Acked-by: Kitware Robot Merge-request: !3650 ----------------------------------------------------------------------- Summary of changes: Modules/CMakeDetermineCCompiler.cmake | 16 ++++++++++++++++ Modules/CMakeDetermineCXXCompiler.cmake | 16 ++++++++++++++++ 2 files changed, 32 insertions(+) hooks/post-receive -- CMake From kwrobot at kitware.com Tue Aug 6 09:51:10 2019 From: kwrobot at kitware.com (Kitware Robot) Date: Tue, 6 Aug 2019 09:51:10 -0400 (EDT) Subject: [Cmake-commits] CMake branch, release, updated. v3.15.1-12-g1c3404a Message-ID: <20190806135110.E52C4FBF3E@public.kitware.com> This is an automated email from the git hooks/post-receive script. It was generated because a ref change was pushed to the repository containing the project "CMake". The branch, release has been updated via 1c3404a301959690ca967b0c751c0df1f57a1ecd (commit) via a245479372363b6693c180f65781ac9d434a2380 (commit) from edca8d5c3ad34a829e0d4af36a9fd8818603d457 (commit) Those revisions listed above that are new to this repository have not appeared on any other notification email; so we list those revisions in full, below. - Log ----------------------------------------------------------------- ----------------------------------------------------------------------- Summary of changes: Modules/CMakeDetermineCCompiler.cmake | 16 ++++++++++++++++ Modules/CMakeDetermineCXXCompiler.cmake | 16 ++++++++++++++++ 2 files changed, 32 insertions(+) hooks/post-receive -- CMake From kwrobot at kitware.com Tue Aug 6 10:01:07 2019 From: kwrobot at kitware.com (Kitware Robot) Date: Tue, 6 Aug 2019 10:01:07 -0400 (EDT) Subject: [Cmake-commits] CMake branch, master, updated. v3.15.1-596-g52d9cd6 Message-ID: <20190806140107.E9A75F69E4@public.kitware.com> This is an automated email from the git hooks/post-receive script. It was generated because a ref change was pushed to the repository containing the project "CMake". The branch, master has been updated via 52d9cd624fc0da9b26fd677d92e67dd033603337 (commit) via a09d14bbce9b68f9249b0d2698c3de7eb4114143 (commit) via 493b8eae369977530294ab243b0cc2215a243a81 (commit) via d192caefff3a0a750c7ab86582b08b2b98142f08 (commit) from fdaad9a067e8fa55816d9cef2481450fc5b1f18b (commit) Those revisions listed above that are new to this repository have not appeared on any other notification email; so we list those revisions in full, below. - Log ----------------------------------------------------------------- https://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=52d9cd624fc0da9b26fd677d92e67dd033603337 commit 52d9cd624fc0da9b26fd677d92e67dd033603337 Merge: a09d14b 493b8ea Author: Brad King AuthorDate: Tue Aug 6 13:57:39 2019 +0000 Commit: Kitware Robot CommitDate: Tue Aug 6 09:58:25 2019 -0400 Merge topic 'doc-fix-CMAKE_MESSAGE_INDENT-sample-output' 493b8eae36 Help: Fix example output in the `CMAKE_MESSAGE_INDENT` documentation Acked-by: Kitware Robot Merge-request: !3651 https://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=a09d14bbce9b68f9249b0d2698c3de7eb4114143 commit a09d14bbce9b68f9249b0d2698c3de7eb4114143 Merge: fdaad9a d192cae Author: Brad King AuthorDate: Tue Aug 6 13:57:10 2019 +0000 Commit: Kitware Robot CommitDate: Tue Aug 6 09:57:19 2019 -0400 Merge topic 'cmake-dependent-option-doc' d192caefff CMakeDependentOption: Document that 4th parameter follows if-syntax Acked-by: Kitware Robot Merge-request: !3643 https://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=493b8eae369977530294ab243b0cc2215a243a81 commit 493b8eae369977530294ab243b0cc2215a243a81 Author: Alex Turbov AuthorDate: Mon Aug 5 18:17:46 2019 +0300 Commit: Alex Turbov CommitDate: Mon Aug 5 18:17:46 2019 +0300 Help: Fix example output in the `CMAKE_MESSAGE_INDENT` documentation diff --git a/Help/variable/CMAKE_MESSAGE_INDENT.rst b/Help/variable/CMAKE_MESSAGE_INDENT.rst index f7975ab..d502121 100644 --- a/Help/variable/CMAKE_MESSAGE_INDENT.rst +++ b/Help/variable/CMAKE_MESSAGE_INDENT.rst @@ -23,6 +23,8 @@ Example: Which results in the following output: +.. code-block:: none + -- Collected items in the "listVar": -- one -- two https://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=d192caefff3a0a750c7ab86582b08b2b98142f08 commit d192caefff3a0a750c7ab86582b08b2b98142f08 Author: Hong Xu AuthorDate: Fri Aug 2 13:30:39 2019 -0700 Commit: Brad King CommitDate: Mon Aug 5 10:15:21 2019 -0400 CMakeDependentOption: Document that 4th parameter follows if-syntax diff --git a/Help/command/if.rst b/Help/command/if.rst index d8e3a45..be992df 100644 --- a/Help/command/if.rst +++ b/Help/command/if.rst @@ -29,6 +29,8 @@ If used, it must be a verbatim repeat of the argument of the opening ``if`` command. +.. _`Condition Syntax`: + Condition Syntax ^^^^^^^^^^^^^^^^ diff --git a/Modules/CMakeDependentOption.cmake b/Modules/CMakeDependentOption.cmake index 6046d85..99d5070 100644 --- a/Modules/CMakeDependentOption.cmake +++ b/Modules/CMakeDependentOption.cmake @@ -12,7 +12,7 @@ conditions are true. When the option is not presented a default value is used, but any value set by the user is preserved for when the option is presented again. Example invocation: -:: +.. code-block:: cmake CMAKE_DEPENDENT_OPTION(USE_FOO "Use Foo" ON "USE_BAR;NOT USE_ZOT" OFF) @@ -21,7 +21,8 @@ If USE_BAR is true and USE_ZOT is false, this provides an option called USE_FOO that defaults to ON. Otherwise, it sets USE_FOO to OFF. If the status of USE_BAR or USE_ZOT ever changes, any value for the USE_FOO option is saved so that when the option is re-enabled it -retains its old value. +retains its old value. Each element in the fourth parameter is +evaluated as an if-condition, so :ref:`Condition Syntax` can be used. #]=======================================================================] macro(CMAKE_DEPENDENT_OPTION option doc default depends force) ----------------------------------------------------------------------- Summary of changes: Help/command/if.rst | 2 ++ Help/variable/CMAKE_MESSAGE_INDENT.rst | 2 ++ Modules/CMakeDependentOption.cmake | 5 +++-- 3 files changed, 7 insertions(+), 2 deletions(-) hooks/post-receive -- CMake From kwrobot at kitware.com Wed Aug 7 00:00:52 2019 From: kwrobot at kitware.com (Kitware Robot) Date: Wed, 7 Aug 2019 00:00:52 -0400 (EDT) Subject: [Cmake-commits] CMake branch, master, updated. v3.15.1-597-ge295290 Message-ID: <20190807040052.30DC411FB9C@public.kitware.com> This is an automated email from the git hooks/post-receive script. It was generated because a ref change was pushed to the repository containing the project "CMake". The branch, master has been updated via e295290ed707a78a0ba6c66cbd1bbf069b5d582c (commit) from 52d9cd624fc0da9b26fd677d92e67dd033603337 (commit) Those revisions listed above that are new to this repository have not appeared on any other notification email; so we list those revisions in full, below. - Log ----------------------------------------------------------------- https://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=e295290ed707a78a0ba6c66cbd1bbf069b5d582c commit e295290ed707a78a0ba6c66cbd1bbf069b5d582c Author: Kitware Robot AuthorDate: Wed Aug 7 00:01:08 2019 -0400 Commit: Kitware Robot CommitDate: Wed Aug 7 00:01:08 2019 -0400 CMake Nightly Date Stamp diff --git a/Source/CMakeVersion.cmake b/Source/CMakeVersion.cmake index e6d5e9d..96e5ee5 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 15) -set(CMake_VERSION_PATCH 20190806) +set(CMake_VERSION_PATCH 20190807) #set(CMake_VERSION_RC 0) set(CMake_VERSION_IS_DIRTY 0) ----------------------------------------------------------------------- Summary of changes: Source/CMakeVersion.cmake | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) hooks/post-receive -- CMake From kwrobot at kitware.com Wed Aug 7 10:00:38 2019 From: kwrobot at kitware.com (Kitware Robot) Date: Wed, 7 Aug 2019 10:00:38 -0400 (EDT) Subject: [Cmake-commits] CMake branch, master, updated. v3.15.1-606-g2ad2819 Message-ID: <20190807140039.0CA74FACCA@public.kitware.com> This is an automated email from the git hooks/post-receive script. It was generated because a ref change was pushed to the repository containing the project "CMake". The branch, master has been updated via 2ad281996ec6e59a885fc7ef6b343814ee3fadce (commit) via 26f0f8bfca2e11a14bd8bcb9f82c505aeff40721 (commit) via ce14f6c67724fccc25547db62e645ab8d115841c (commit) via 1c7a4f93ddc258e059933ec873bca02deee54f47 (commit) via feeb0381bcd73dfffd3ccf4f57d78caf518528ff (commit) via ab822a9b48d43ffec3cc775eb8c8028ac4a96d2e (commit) via a8a3efa3be3ec6162495abc0ec0d6721a9fcdf5e (commit) via 9a384e73044f4295a50c8923389b1de832cee36a (commit) via 8ed868606ddae005b4a50319bdc291b8df5b525a (commit) from e295290ed707a78a0ba6c66cbd1bbf069b5d582c (commit) Those revisions listed above that are new to this repository have not appeared on any other notification email; so we list those revisions in full, below. - Log ----------------------------------------------------------------- https://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=2ad281996ec6e59a885fc7ef6b343814ee3fadce commit 2ad281996ec6e59a885fc7ef6b343814ee3fadce Merge: 26f0f8b 1c7a4f9 Author: Brad King AuthorDate: Wed Aug 7 09:59:43 2019 -0400 Commit: Brad King CommitDate: Wed Aug 7 09:59:43 2019 -0400 Merge branch 'release-3.15' https://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=26f0f8bfca2e11a14bd8bcb9f82c505aeff40721 commit 26f0f8bfca2e11a14bd8bcb9f82c505aeff40721 Merge: ce14f6c feeb038 Author: Brad King AuthorDate: Wed Aug 7 13:57:33 2019 +0000 Commit: Kitware Robot CommitDate: Wed Aug 7 09:58:56 2019 -0400 Merge topic 'FindGLEW-macOS' feeb0381bc FindGLEW: Fix typo in verbose log message ab822a9b48 FindGLEW: Add required OpenGL dependency in macOS a8a3efa3be FindGLEW: Fix macOS library suffix selection Acked-by: Kitware Robot Merge-request: !3656 https://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=ce14f6c67724fccc25547db62e645ab8d115841c commit ce14f6c67724fccc25547db62e645ab8d115841c Merge: e295290 8ed8686 Author: Brad King AuthorDate: Wed Aug 7 13:57:22 2019 +0000 Commit: Kitware Robot CommitDate: Wed Aug 7 09:57:35 2019 -0400 Merge topic 'find_package-prefer-config-not-found' 8ed868606d find_package: Fix prefer-config mode to not fail on missing optional package Acked-by: Kitware Robot Merge-request: !3653 ----------------------------------------------------------------------- Summary of changes: Modules/FindGLEW.cmake | 37 +++++++++++++++++++++++++++++++++--- Source/cmFindPackageCommand.cxx | 4 +++- Tests/FindPackageTest/CMakeLists.txt | 6 ++++++ 3 files changed, 43 insertions(+), 4 deletions(-) hooks/post-receive -- CMake From kwrobot at kitware.com Wed Aug 7 10:00:39 2019 From: kwrobot at kitware.com (Kitware Robot) Date: Wed, 7 Aug 2019 10:00:39 -0400 (EDT) Subject: [Cmake-commits] CMake branch, release, updated. v3.15.1-18-g1c7a4f9 Message-ID: <20190807140039.24C4810308D@public.kitware.com> This is an automated email from the git hooks/post-receive script. It was generated because a ref change was pushed to the repository containing the project "CMake". The branch, release has been updated via 1c7a4f93ddc258e059933ec873bca02deee54f47 (commit) via feeb0381bcd73dfffd3ccf4f57d78caf518528ff (commit) via ab822a9b48d43ffec3cc775eb8c8028ac4a96d2e (commit) via a8a3efa3be3ec6162495abc0ec0d6721a9fcdf5e (commit) via 9a384e73044f4295a50c8923389b1de832cee36a (commit) via 8ed868606ddae005b4a50319bdc291b8df5b525a (commit) from 1c3404a301959690ca967b0c751c0df1f57a1ecd (commit) Those revisions listed above that are new to this repository have not appeared on any other notification email; so we list those revisions in full, below. - Log ----------------------------------------------------------------- ----------------------------------------------------------------------- Summary of changes: Modules/FindGLEW.cmake | 37 +++++++++++++++++++++++++++++++++--- Source/cmFindPackageCommand.cxx | 4 +++- Tests/FindPackageTest/CMakeLists.txt | 6 ++++++ 3 files changed, 43 insertions(+), 4 deletions(-) hooks/post-receive -- CMake From kwrobot at kitware.com Wed Aug 7 11:50:36 2019 From: kwrobot at kitware.com (Kitware Robot) Date: Wed, 7 Aug 2019 11:50:36 -0400 (EDT) Subject: [Cmake-commits] CMake branch, master, updated. v3.15.1-611-gddb1759 Message-ID: <20190807155036.B4301FBF3E@public.kitware.com> This is an automated email from the git hooks/post-receive script. It was generated because a ref change was pushed to the repository containing the project "CMake". The branch, master has been updated via ddb1759b3e2b5c1b2c56734cd2ae0fa6dcf3a815 (commit) via 97b12c7922f75c169736f65a3d9549a3084167c0 (commit) via 8fe129e314e9fe965e68905caf924d1d71629fc6 (commit) via 959b97a27f8816fb1db5c3a1d51cd994086a886b (commit) via 7fbcc16dcd92a80eb30baab93388a0b8e294969b (commit) from 2ad281996ec6e59a885fc7ef6b343814ee3fadce (commit) Those revisions listed above that are new to this repository have not appeared on any other notification email; so we list those revisions in full, below. - Log ----------------------------------------------------------------- https://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=ddb1759b3e2b5c1b2c56734cd2ae0fa6dcf3a815 commit ddb1759b3e2b5c1b2c56734cd2ae0fa6dcf3a815 Merge: 97b12c7 959b97a Author: Brad King AuthorDate: Wed Aug 7 15:45:15 2019 +0000 Commit: Kitware Robot CommitDate: Wed Aug 7 11:47:54 2019 -0400 Merge topic 'cmStringAlgorithms_move_functions' 959b97a27f Tests: testStringAlgorithms: Add cmTrimWhitespace, cmEscapeQuotes, cmTokenize 7fbcc16dcd cmStringAlgorithms: cmIsSpace, cmTrimWhitespace, cmEscapeQuotes, cmTokenize Acked-by: Kitware Robot Merge-request: !3647 https://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=97b12c7922f75c169736f65a3d9549a3084167c0 commit 97b12c7922f75c169736f65a3d9549a3084167c0 Merge: 2ad2819 8fe129e Author: Brad King AuthorDate: Wed Aug 7 15:44:32 2019 +0000 Commit: Kitware Robot CommitDate: Wed Aug 7 11:44:57 2019 -0400 Merge topic 'doc-CMAKE_MESSAGE_INDENT-spelling-typo' 8fe129e314 Help: Fix spelling typo in `CMAKE_MESSAGE_INDENT` docs Acked-by: Kitware Robot Merge-request: !3658 https://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=8fe129e314e9fe965e68905caf924d1d71629fc6 commit 8fe129e314e9fe965e68905caf924d1d71629fc6 Author: Alex Turbov AuthorDate: Tue Aug 6 18:35:10 2019 +0300 Commit: Alex Turbov CommitDate: Tue Aug 6 18:35:10 2019 +0300 Help: Fix spelling typo in `CMAKE_MESSAGE_INDENT` docs diff --git a/Help/variable/CMAKE_MESSAGE_INDENT.rst b/Help/variable/CMAKE_MESSAGE_INDENT.rst index d502121..7e44a4c 100644 --- a/Help/variable/CMAKE_MESSAGE_INDENT.rst +++ b/Help/variable/CMAKE_MESSAGE_INDENT.rst @@ -28,5 +28,5 @@ Which results in the following output: -- Collected items in the "listVar": -- one -- two - -- tree + -- three -- No more indent https://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=959b97a27f8816fb1db5c3a1d51cd994086a886b commit 959b97a27f8816fb1db5c3a1d51cd994086a886b Author: Sebastian Holtermann AuthorDate: Fri Aug 2 14:46:13 2019 +0200 Commit: Sebastian Holtermann CommitDate: Mon Aug 5 11:25:30 2019 +0200 Tests: testStringAlgorithms: Add cmTrimWhitespace, cmEscapeQuotes, cmTokenize Extend the testStringAlgorithms test with tests for `cmTrimWhitespace`, `cmEscapeQuotes` and `cmTokenize`. diff --git a/Tests/CMakeLib/testStringAlgorithms.cxx b/Tests/CMakeLib/testStringAlgorithms.cxx index 95616ff..55d2a8f 100644 --- a/Tests/CMakeLib/testStringAlgorithms.cxx +++ b/Tests/CMakeLib/testStringAlgorithms.cxx @@ -38,6 +38,28 @@ int testStringAlgorithms(int /*unused*/, char* /*unused*/ []) }; // ---------------------------------------------------------------------- + // Test cmTrimWhitespace + { + std::string base = "base"; + std::string spaces = " \f\f\n\n\r\r\t\t\v\v"; + assert_string(cmTrimWhitespace(spaces + base), base, + "cmTrimWhitespace front"); + assert_string(cmTrimWhitespace(base + spaces), base, + "cmTrimWhitespace back"); + assert_string(cmTrimWhitespace(spaces + base + spaces), base, + "cmTrimWhitespace front and back"); + } + + // ---------------------------------------------------------------------- + // Test cmEscapeQuotes + { + assert_string(cmEscapeQuotes("plain"), "plain", "cmEscapeQuotes plain"); + std::string base = "\"base\"\""; + std::string result = "\\\"base\\\"\\\""; + assert_string(cmEscapeQuotes(base), result, "cmEscapeQuotes escaped"); + } + + // ---------------------------------------------------------------------- // Test cmJoin { typedef std::string ST; @@ -52,6 +74,21 @@ int testStringAlgorithms(int /*unused*/, char* /*unused*/ []) } // ---------------------------------------------------------------------- + // Test cmTokenize + { + typedef std::vector VT; + assert_ok(cmTokenize("", ";") == VT{ "" }, "cmTokenize empty"); + assert_ok(cmTokenize(";", ";") == VT{ "" }, "cmTokenize sep"); + assert_ok(cmTokenize("abc", ";") == VT{ "abc" }, "cmTokenize item"); + assert_ok(cmTokenize("abc;", ";") == VT{ "abc" }, "cmTokenize item sep"); + assert_ok(cmTokenize(";abc", ";") == VT{ "abc" }, "cmTokenize sep item"); + assert_ok(cmTokenize("abc;;efg", ";") == VT{ "abc", "efg" }, + "cmTokenize item sep sep item"); + assert_ok(cmTokenize("a1;a2;a3;a4", ";") == VT{ "a1", "a2", "a3", "a4" }, + "cmTokenize multiple items"); + } + + // ---------------------------------------------------------------------- // Test cmStrCat { int ni = -1100; https://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=7fbcc16dcd92a80eb30baab93388a0b8e294969b commit 7fbcc16dcd92a80eb30baab93388a0b8e294969b Author: Sebastian Holtermann AuthorDate: Wed Jul 31 09:06:04 2019 +0200 Commit: Sebastian Holtermann CommitDate: Mon Aug 5 11:25:30 2019 +0200 cmStringAlgorithms: cmIsSpace, cmTrimWhitespace, cmEscapeQuotes, cmTokenize This adds the following functions to `cmStringAlgorithms`: - `cmIsSpace` - `cmTrimWhitespace` (moved from `cmSystemTools::TrimWhitespace`) - `cmEscapeQuotes` (moved from `cmSystemTools::EscapeQuotes`) - `cmTokenize` (moved from `cmSystemTools::tokenize` and adapted to accept `cm::string_view`) diff --git a/Source/CPack/IFW/cmCPackIFWInstaller.cxx b/Source/CPack/IFW/cmCPackIFWInstaller.cxx index a075a17..f130e05 100644 --- a/Source/CPack/IFW/cmCPackIFWInstaller.cxx +++ b/Source/CPack/IFW/cmCPackIFWInstaller.cxx @@ -8,6 +8,7 @@ #include "cmCPackIFWRepository.h" #include "cmCPackLog.h" // IWYU pragma: keep #include "cmGeneratedFileStream.h" +#include "cmStringAlgorithms.h" #include "cmSystemTools.h" #include "cmXMLParser.h" #include "cmXMLWriter.h" @@ -292,7 +293,7 @@ protected: { if (this->file) { std::string content(data, data + length); - content = cmSystemTools::TrimWhitespace(content); + content = cmTrimWhitespace(content); std::string source = this->basePath + "/" + content; std::string destination = this->path + "/" + content; if (!cmSystemTools::CopyFileIfDifferent(source, destination)) { diff --git a/Source/CPack/WiX/cmCMakeToWixPath.cxx b/Source/CPack/WiX/cmCMakeToWixPath.cxx index b3889cf..630a8f8 100644 --- a/Source/CPack/WiX/cmCMakeToWixPath.cxx +++ b/Source/CPack/WiX/cmCMakeToWixPath.cxx @@ -2,7 +2,7 @@ file Copyright.txt or https://cmake.org/licensing for details. */ #include "cmCMakeToWixPath.h" -#include "cmSystemTools.h" +#include "cmStringAlgorithms.h" #include #include @@ -29,7 +29,7 @@ std::string CMakeToWixPath(const std::string& cygpath) return cygpath; } - return cmSystemTools::TrimWhitespace(winpath_chars.data()); + return cmTrimWhitespace(winpath_chars.data()); } #else std::string CMakeToWixPath(const std::string& path) diff --git a/Source/CPack/WiX/cmWIXAccessControlList.cxx b/Source/CPack/WiX/cmWIXAccessControlList.cxx index 563de02..b5e287d 100644 --- a/Source/CPack/WiX/cmWIXAccessControlList.cxx +++ b/Source/CPack/WiX/cmWIXAccessControlList.cxx @@ -4,6 +4,7 @@ #include "cmCPackGenerator.h" +#include "cmStringAlgorithms.h" #include "cmSystemTools.h" cmWIXAccessControlList::cmWIXAccessControlList( @@ -48,8 +49,7 @@ void cmWIXAccessControlList::CreatePermissionElement(std::string const& entry) user = user_and_domain; } - std::vector permissions = - cmSystemTools::tokenize(permission_string, ","); + std::vector permissions = cmTokenize(permission_string, ","); this->SourceWriter.BeginElement("Permission"); this->SourceWriter.AddAttribute("User", user); @@ -57,8 +57,7 @@ void cmWIXAccessControlList::CreatePermissionElement(std::string const& entry) this->SourceWriter.AddAttribute("Domain", domain); } for (std::string const& permission : permissions) { - this->EmitBooleanAttribute(entry, - cmSystemTools::TrimWhitespace(permission)); + this->EmitBooleanAttribute(entry, cmTrimWhitespace(permission)); } this->SourceWriter.EndElement("Permission"); } diff --git a/Source/cmCommandArgumentParserHelper.cxx b/Source/cmCommandArgumentParserHelper.cxx index ca29967..5583520 100644 --- a/Source/cmCommandArgumentParserHelper.cxx +++ b/Source/cmCommandArgumentParserHelper.cxx @@ -5,6 +5,7 @@ #include "cmCommandArgumentLexer.h" #include "cmMakefile.h" #include "cmState.h" +#include "cmStringAlgorithms.h" #include "cmSystemTools.h" #include @@ -58,7 +59,7 @@ const char* cmCommandArgumentParserHelper::ExpandSpecialVariable( std::string str; if (cmSystemTools::GetEnv(var, str)) { if (this->EscapeQuotes) { - return this->AddString(cmSystemTools::EscapeQuotes(str)); + return this->AddString(cmEscapeQuotes(str)); } return this->AddString(str); } @@ -68,7 +69,7 @@ const char* cmCommandArgumentParserHelper::ExpandSpecialVariable( if (const std::string* c = this->Makefile->GetState()->GetInitializedCacheValue(var)) { if (this->EscapeQuotes) { - return this->AddString(cmSystemTools::EscapeQuotes(*c)); + return this->AddString(cmEscapeQuotes(*c)); } return this->AddString(*c); } @@ -99,7 +100,7 @@ const char* cmCommandArgumentParserHelper::ExpandVariable(const char* var) } } if (this->EscapeQuotes && value) { - return this->AddString(cmSystemTools::EscapeQuotes(value)); + return this->AddString(cmEscapeQuotes(value)); } return this->AddString(value ? value : ""); } diff --git a/Source/cmCoreTryCompile.cxx b/Source/cmCoreTryCompile.cxx index d2a4148..e286ed7 100644 --- a/Source/cmCoreTryCompile.cxx +++ b/Source/cmCoreTryCompile.cxx @@ -238,7 +238,7 @@ int cmCoreTryCompile::TryCompileCode(std::vector const& argv, } else if (doing == DoingLinkOptions) { linkOptions.push_back(argv[i]); } else if (doing == DoingLinkLibraries) { - libsToLink += "\"" + cmSystemTools::TrimWhitespace(argv[i]) + "\" "; + libsToLink += "\"" + cmTrimWhitespace(argv[i]) + "\" "; if (cmTarget* tgt = this->Makefile->FindTargetToUse(argv[i])) { switch (tgt->GetType()) { case cmStateEnums::SHARED_LIBRARY: diff --git a/Source/cmFileAPICodemodel.cxx b/Source/cmFileAPICodemodel.cxx index e9ee7f5..4eda9fe 100644 --- a/Source/cmFileAPICodemodel.cxx +++ b/Source/cmFileAPICodemodel.cxx @@ -21,6 +21,7 @@ #include "cmStateDirectory.h" #include "cmStateSnapshot.h" #include "cmStateTypes.h" +#include "cmStringAlgorithms.h" #include "cmSystemTools.h" #include "cmTarget.h" #include "cmTargetDepend.h" @@ -1273,11 +1274,11 @@ Json::Value Target::DumpLinkCommandFragments() lg->GetTargetFlags(&linkLineComputer, this->Config, linkLibs, linkLanguageFlags, linkFlags, frameworkPath, linkPath, this->GT); - linkLanguageFlags = cmSystemTools::TrimWhitespace(linkLanguageFlags); - linkFlags = cmSystemTools::TrimWhitespace(linkFlags); - frameworkPath = cmSystemTools::TrimWhitespace(frameworkPath); - linkPath = cmSystemTools::TrimWhitespace(linkPath); - linkLibs = cmSystemTools::TrimWhitespace(linkLibs); + linkLanguageFlags = cmTrimWhitespace(linkLanguageFlags); + linkFlags = cmTrimWhitespace(linkFlags); + frameworkPath = cmTrimWhitespace(frameworkPath); + linkPath = cmTrimWhitespace(linkPath); + linkLibs = cmTrimWhitespace(linkLibs); if (!linkLanguageFlags.empty()) { linkFragments.append( diff --git a/Source/cmGeneratorTarget.cxx b/Source/cmGeneratorTarget.cxx index 7340bc2..41471e8 100644 --- a/Source/cmGeneratorTarget.cxx +++ b/Source/cmGeneratorTarget.cxx @@ -3410,8 +3410,7 @@ std::vector> cmGeneratorTarget::GetLinkOptions( cmSystemTools::ParseUnixCommandLine( value.c_str() + LINKER_SHELL.length(), linkerOptions); } else { - linkerOptions = - cmSystemTools::tokenize(value.substr(LINKER.length()), ","); + linkerOptions = cmTokenize(value.substr(LINKER.length()), ","); } if (linkerOptions.empty() || diff --git a/Source/cmGetFilenameComponentCommand.cxx b/Source/cmGetFilenameComponentCommand.cxx index fc82535..c948b2a 100644 --- a/Source/cmGetFilenameComponentCommand.cxx +++ b/Source/cmGetFilenameComponentCommand.cxx @@ -4,6 +4,7 @@ #include "cmMakefile.h" #include "cmStateTypes.h" +#include "cmStringAlgorithms.h" #include "cmSystemTools.h" class cmExecutionStatus; @@ -64,7 +65,7 @@ bool cmGetFilenameComponentCommand::InitialPass( // First assume the path to the program was specified with no // arguments and with no quoting or escaping for spaces. // Only bother doing this if there is non-whitespace. - if (!cmSystemTools::TrimWhitespace(filename).empty()) { + if (!cmTrimWhitespace(filename).empty()) { result = cmSystemTools::FindProgram(filename); } diff --git a/Source/cmGlobalNinjaGenerator.cxx b/Source/cmGlobalNinjaGenerator.cxx index 0b68966..9914d15 100644 --- a/Source/cmGlobalNinjaGenerator.cxx +++ b/Source/cmGlobalNinjaGenerator.cxx @@ -383,7 +383,7 @@ void cmGlobalNinjaGenerator::WriteVariable(std::ostream& os, } // Do not add a variable if the value is empty. - std::string val = cmSystemTools::TrimWhitespace(value); + std::string val = cmTrimWhitespace(value); if (val.empty()) { return; } @@ -528,7 +528,7 @@ bool cmGlobalNinjaGenerator::FindMakeProgram(cmMakefile* mf) cmSystemTools::SetFatalErrorOccured(); return false; } - this->NinjaVersion = cmSystemTools::TrimWhitespace(version); + this->NinjaVersion = cmTrimWhitespace(version); this->CheckNinjaFeatures(); } return true; diff --git a/Source/cmGlobalVisualStudio10Generator.cxx b/Source/cmGlobalVisualStudio10Generator.cxx index 4a3cadd..720b6c5 100644 --- a/Source/cmGlobalVisualStudio10Generator.cxx +++ b/Source/cmGlobalVisualStudio10Generator.cxx @@ -325,7 +325,7 @@ bool cmGlobalVisualStudio10Generator::SetGeneratorToolset( bool cmGlobalVisualStudio10Generator::ParseGeneratorToolset( std::string const& ts, cmMakefile* mf) { - std::vector const fields = cmSystemTools::tokenize(ts, ","); + std::vector const fields = cmTokenize(ts, ","); std::vector::const_iterator fi = fields.begin(); if (fi == fields.end()) { return true; diff --git a/Source/cmGlobalVisualStudio7Generator.cxx b/Source/cmGlobalVisualStudio7Generator.cxx index bead0e3..ca80d3b 100644 --- a/Source/cmGlobalVisualStudio7Generator.cxx +++ b/Source/cmGlobalVisualStudio7Generator.cxx @@ -518,9 +518,9 @@ void cmGlobalVisualStudio7Generator::WriteSLNGlobalSections( const std::string::size_type posEqual = itPair.find('='); if (posEqual != std::string::npos) { const std::string key = - cmSystemTools::TrimWhitespace(itPair.substr(0, posEqual)); + cmTrimWhitespace(itPair.substr(0, posEqual)); const std::string value = - cmSystemTools::TrimWhitespace(itPair.substr(posEqual + 1)); + cmTrimWhitespace(itPair.substr(posEqual + 1)); fout << "\t\t" << key << " = " << value << "\n"; if (key == "SolutionGuid") { addGuid = false; diff --git a/Source/cmGlobalXCodeGenerator.cxx b/Source/cmGlobalXCodeGenerator.cxx index 8f4ae62..f675c8e 100644 --- a/Source/cmGlobalXCodeGenerator.cxx +++ b/Source/cmGlobalXCodeGenerator.cxx @@ -2945,8 +2945,7 @@ cmXCodeObject* cmGlobalXCodeGenerator::CreateOrGetPBXGroup( if (it != this->TargetGroup.end()) { tgroup = it->second; } else { - std::vector tgt_folders = - cmSystemTools::tokenize(target, "/"); + std::vector tgt_folders = cmTokenize(target, "/"); std::string curr_tgt_folder; for (std::vector::size_type i = 0; i < tgt_folders.size(); i++) { @@ -2980,8 +2979,7 @@ cmXCodeObject* cmGlobalXCodeGenerator::CreateOrGetPBXGroup( if (sg->GetFullName() != sg->GetName()) { std::string curr_folder = target; curr_folder += "/"; - for (auto const& folder : - cmSystemTools::tokenize(sg->GetFullName(), "\\")) { + for (auto const& folder : cmTokenize(sg->GetFullName(), "\\")) { curr_folder += folder; std::map::iterator i_folder = this->GroupNameMap.find(curr_folder); diff --git a/Source/cmJsonObjects.cxx b/Source/cmJsonObjects.cxx index 2423faf..953333c 100644 --- a/Source/cmJsonObjects.cxx +++ b/Source/cmJsonObjects.cxx @@ -20,6 +20,7 @@ #include "cmStateDirectory.h" #include "cmStateSnapshot.h" #include "cmStateTypes.h" +#include "cmStringAlgorithms.h" #include "cmSystemTools.h" #include "cmTarget.h" #include "cmTest.h" @@ -541,19 +542,19 @@ static Json::Value DumpTarget(cmGeneratorTarget* target, lg->GetTargetFlags(&linkLineComputer, config, linkLibs, linkLanguageFlags, linkFlags, frameworkPath, linkPath, target); - linkLibs = cmSystemTools::TrimWhitespace(linkLibs); - linkFlags = cmSystemTools::TrimWhitespace(linkFlags); - linkLanguageFlags = cmSystemTools::TrimWhitespace(linkLanguageFlags); - frameworkPath = cmSystemTools::TrimWhitespace(frameworkPath); - linkPath = cmSystemTools::TrimWhitespace(linkPath); + linkLibs = cmTrimWhitespace(linkLibs); + linkFlags = cmTrimWhitespace(linkFlags); + linkLanguageFlags = cmTrimWhitespace(linkLanguageFlags); + frameworkPath = cmTrimWhitespace(frameworkPath); + linkPath = cmTrimWhitespace(linkPath); - if (!cmSystemTools::TrimWhitespace(linkLibs).empty()) { + if (!cmTrimWhitespace(linkLibs).empty()) { result[kLINK_LIBRARIES_KEY] = linkLibs; } - if (!cmSystemTools::TrimWhitespace(linkFlags).empty()) { + if (!cmTrimWhitespace(linkFlags).empty()) { result[kLINK_FLAGS_KEY] = linkFlags; } - if (!cmSystemTools::TrimWhitespace(linkLanguageFlags).empty()) { + if (!cmTrimWhitespace(linkLanguageFlags).empty()) { result[kLINK_LANGUAGE_FLAGS_KEY] = linkLanguageFlags; } if (!frameworkPath.empty()) { diff --git a/Source/cmListCommand.cxx b/Source/cmListCommand.cxx index 8c14596..1f748ca 100644 --- a/Source/cmListCommand.cxx +++ b/Source/cmListCommand.cxx @@ -855,7 +855,7 @@ bool cmListCommand::HandleTransformCommand( { "STRIP", 0, [&command](const std::string& s) -> std::string { if (command.Selector->InSelection(s)) { - return cmSystemTools::TrimWhitespace(s); + return cmTrimWhitespace(s); } return s; diff --git a/Source/cmMakefile.cxx b/Source/cmMakefile.cxx index 8188ffa..3d42b69 100644 --- a/Source/cmMakefile.cxx +++ b/Source/cmMakefile.cxx @@ -2166,8 +2166,7 @@ cmSourceGroup* cmMakefile::GetOrCreateSourceGroup(const std::string& name) if (delimiter == nullptr) { delimiter = "\\"; } - return this->GetOrCreateSourceGroup( - cmSystemTools::tokenize(name, delimiter)); + return this->GetOrCreateSourceGroup(cmTokenize(name, delimiter)); } /** @@ -2659,7 +2658,7 @@ MessageType cmMakefile::ExpandVariablesInStringOld( if (const char* val = this->GetDefinition(var)) { // Store the value in the output escaping as requested. if (escapeQuotes) { - source.append(cmSystemTools::EscapeQuotes(val)); + source.append(cmEscapeQuotes(val)); } else { source.append(val); } @@ -2823,7 +2822,7 @@ MessageType cmMakefile::ExpandVariablesInStringNew( // Get the string we're meant to append to. if (value) { if (escapeQuotes) { - varresult = cmSystemTools::EscapeQuotes(value); + varresult = cmEscapeQuotes(value); } else { varresult = value; } @@ -2949,7 +2948,7 @@ MessageType cmMakefile::ExpandVariablesInStringNew( } if (escapeQuotes) { - varresult = cmSystemTools::EscapeQuotes(varresult); + varresult = cmEscapeQuotes(varresult); } // Skip over the variable. result.append(last, in - last); diff --git a/Source/cmSourceGroupCommand.cxx b/Source/cmSourceGroupCommand.cxx index ffdd0ce..0f69c84 100644 --- a/Source/cmSourceGroupCommand.cxx +++ b/Source/cmSourceGroupCommand.cxx @@ -21,7 +21,7 @@ const std::string kSourceGroupOptionName = ""; std::vector tokenizePath(const std::string& path) { - return cmSystemTools::tokenize(path, "\\/"); + return cmTokenize(path, "\\/"); } std::string getFullFilePath(const std::string& currentPath, diff --git a/Source/cmStringAlgorithms.cxx b/Source/cmStringAlgorithms.cxx index 5deb9b0..5867a44 100644 --- a/Source/cmStringAlgorithms.cxx +++ b/Source/cmStringAlgorithms.cxx @@ -5,6 +5,59 @@ #include #include +std::string cmTrimWhitespace(cm::string_view str) +{ + auto start = str.begin(); + while (start != str.end() && cmIsSpace(*start)) { + ++start; + } + if (start == str.end()) { + return std::string(); + } + auto stop = str.end() - 1; + while (cmIsSpace(*stop)) { + --stop; + } + return std::string(start, stop + 1); +} + +std::string cmEscapeQuotes(cm::string_view str) +{ + std::string result; + result.reserve(str.size()); + for (const char ch : str) { + if (ch == '"') { + result += '\\'; + } + result += ch; + } + return result; +} + +std::vector cmTokenize(cm::string_view str, cm::string_view sep) +{ + std::vector tokens; + cm::string_view::size_type tokend = 0; + + do { + cm::string_view::size_type tokstart = str.find_first_not_of(sep, tokend); + if (tokstart == cm::string_view::npos) { + break; // no more tokens + } + tokend = str.find_first_of(sep, tokstart); + if (tokend == cm::string_view::npos) { + tokens.emplace_back(str.substr(tokstart)); + } else { + tokens.emplace_back(str.substr(tokstart, tokend - tokstart)); + } + } while (tokend != cm::string_view::npos); + + if (tokens.empty()) { + tokens.emplace_back(); + } + return tokens; +} + namespace { template inline void MakeDigits(cm::string_view& view, char (&digits)[N], diff --git a/Source/cmStringAlgorithms.h b/Source/cmStringAlgorithms.h index cdb494f..1898649 100644 --- a/Source/cmStringAlgorithms.h +++ b/Source/cmStringAlgorithms.h @@ -7,6 +7,7 @@ #include "cmRange.h" #include "cm_string_view.hxx" +#include #include #include #include @@ -31,6 +32,18 @@ private: std::string const Test_; }; +/** Returns true if the character @a ch is a whitespace character. **/ +inline bool cmIsSpace(char ch) +{ + return ((ch & 0x80) == 0) && std::isspace(ch); +} + +/** Returns a string that has whitespace removed from the start and the end. */ +std::string cmTrimWhitespace(cm::string_view str); + +/** Escape quotes in a string. */ +std::string cmEscapeQuotes(cm::string_view str); + /** Joins elements of a range with separator into a single string. */ template std::string cmJoin(Range const& rng, cm::string_view separator) @@ -49,6 +62,9 @@ std::string cmJoin(Range const& rng, cm::string_view separator) return os.str(); } +/** Extract tokens that are separated by any of the characters in @a sep. */ +std::vector cmTokenize(cm::string_view str, cm::string_view sep); + /** Concatenate string pieces into a single string. */ std::string cmCatViews(std::initializer_list views); diff --git a/Source/cmSystemTools.cxx b/Source/cmSystemTools.cxx index 5f4e1fc..aed787e 100644 --- a/Source/cmSystemTools.cxx +++ b/Source/cmSystemTools.cxx @@ -84,11 +84,6 @@ cmSystemTools::OutputCallback s_StdoutCallback; } // namespace -static bool cm_isspace(char c) -{ - return ((c & 0x80) == 0) && isspace(c); -} - #if !defined(HAVE_ENVIRON_NOT_REQUIRE_PROTOTYPE) // For GetEnvironmentVariables # if defined(_WIN32) @@ -177,19 +172,6 @@ void cmSystemTools::ExpandRegistryValues(std::string& source, } #endif -std::string cmSystemTools::EscapeQuotes(cm::string_view str) -{ - std::string result; - result.reserve(str.size()); - for (const char ch : str) { - if (ch == '"') { - result += '\\'; - } - result += ch; - } - return result; -} - std::string cmSystemTools::HelpFileName(cm::string_view str) { std::string name(str); @@ -198,22 +180,6 @@ std::string cmSystemTools::HelpFileName(cm::string_view str) return name; } -std::string cmSystemTools::TrimWhitespace(cm::string_view str) -{ - auto start = str.begin(); - while (start != str.end() && cm_isspace(*start)) { - ++start; - } - if (start == str.end()) { - return std::string(); - } - auto stop = str.end() - 1; - while (cm_isspace(*stop)) { - --stop; - } - return std::string(start, stop + 1); -} - void cmSystemTools::Error(const std::string& m) { std::string message = "CMake Error: " + m; @@ -396,7 +362,7 @@ void cmSystemTools::ParseWindowsCommandLine(const char* command, } else { arg.append(backslashes, '\\'); backslashes = 0; - if (cm_isspace(*c)) { + if (cmIsSpace(*c)) { if (in_quotes) { arg.append(1, *c); } else if (in_argument) { @@ -2882,31 +2848,6 @@ bool cmSystemTools::RepeatedRemoveDirectory(const std::string& dir) return false; } -std::vector cmSystemTools::tokenize(const std::string& str, - const std::string& sep) -{ - std::vector tokens; - std::string::size_type tokend = 0; - - do { - std::string::size_type tokstart = str.find_first_not_of(sep, tokend); - if (tokstart == std::string::npos) { - break; // no more tokens - } - tokend = str.find_first_of(sep, tokstart); - if (tokend == std::string::npos) { - tokens.push_back(str.substr(tokstart)); - } else { - tokens.push_back(str.substr(tokstart, tokend - tokstart)); - } - } while (tokend != std::string::npos); - - if (tokens.empty()) { - tokens.emplace_back(); - } - return tokens; -} - bool cmSystemTools::StringToLong(const char* str, long* value) { errno = 0; diff --git a/Source/cmSystemTools.h b/Source/cmSystemTools.h index ac1aa80..d3fcb64 100644 --- a/Source/cmSystemTools.h +++ b/Source/cmSystemTools.h @@ -77,17 +77,9 @@ public: static void ExpandRegistryValues(std::string& source, KeyWOW64 view = KeyWOW64_Default); - //! Escape quotes in a string. - static std::string EscapeQuotes(cm::string_view str); - /** Map help document name to file name. */ static std::string HelpFileName(cm::string_view); - /** - * Returns a string that has whitespace removed from the start and the end. - */ - static std::string TrimWhitespace(cm::string_view str); - using MessageCallback = std::function; /** * Set the function used by GUIs to display error messages @@ -508,10 +500,6 @@ public: /** Remove a directory; repeat a few times in case of locked files. */ static bool RepeatedRemoveDirectory(const std::string& dir); - /** Tokenize a string */ - static std::vector tokenize(const std::string& str, - const std::string& sep); - /** Convert string to long. Expected that the whole string is an integer */ static bool StringToLong(const char* str, long* value); static bool StringToULong(const char* str, unsigned long* value); diff --git a/Source/cmVSSetupHelper.cxx b/Source/cmVSSetupHelper.cxx index c78361e..20f5e2f 100644 --- a/Source/cmVSSetupHelper.cxx +++ b/Source/cmVSSetupHelper.cxx @@ -2,6 +2,7 @@ file Copyright.txt or https://cmake.org/licensing for details. */ #include "cmVSSetupHelper.h" +#include "cmStringAlgorithms.h" #include "cmSystemTools.h" #include "cmsys/Encoding.hxx" #include "cmsys/FStream.hxx" @@ -195,7 +196,7 @@ bool cmVSSetupAPIHelper::GetVSInstanceInfo( if (!fin || !cmSystemTools::GetLineFromStream(fin, vcToolsVersion)) { return false; } - vcToolsVersion = cmSystemTools::TrimWhitespace(vcToolsVersion); + vcToolsVersion = cmTrimWhitespace(vcToolsVersion); std::string const vcToolsDir = vcRoot + "/VC/Tools/MSVC/" + vcToolsVersion; if (!cmSystemTools::FileIsDirectory(vcToolsDir)) { return false; diff --git a/Source/cmVisualStudioGeneratorOptions.cxx b/Source/cmVisualStudioGeneratorOptions.cxx index e1b0c70..6c28996 100644 --- a/Source/cmVisualStudioGeneratorOptions.cxx +++ b/Source/cmVisualStudioGeneratorOptions.cxx @@ -193,7 +193,7 @@ void cmVisualStudioGeneratorOptions::FixCudaCodeGeneration() std::string arch_name = arch[0]; std::vector codes; if (!code.empty()) { - codes = cmSystemTools::tokenize(code[0], ","); + codes = cmTokenize(code[0], ","); } if (codes.empty()) { codes.push_back(arch_name); @@ -220,7 +220,7 @@ void cmVisualStudioGeneratorOptions::FixCudaCodeGeneration() cmSystemTools::ReplaceString(entry, "]", ""); cmSystemTools::ReplaceString(entry, "\"", ""); - std::vector codes = cmSystemTools::tokenize(entry, ","); + std::vector codes = cmTokenize(entry, ","); if (codes.size() >= 2) { auto gencode_arch = cm::cbegin(codes); for (auto ci = gencode_arch + 1; ci != cm::cend(codes); ++ci) { diff --git a/Source/cmVisualStudioSlnParser.cxx b/Source/cmVisualStudioSlnParser.cxx index 3e7e142..9eaee11 100644 --- a/Source/cmVisualStudioSlnParser.cxx +++ b/Source/cmVisualStudioSlnParser.cxx @@ -463,7 +463,7 @@ bool cmVisualStudioSlnParser::ParseImpl(std::istream& input, cmSlnData& output, if (!this->ParseBOM(input, line, state)) return false; do { - line = cmSystemTools::TrimWhitespace(line); + line = cmTrimWhitespace(line); if (line.empty()) continue; ParsedLine parsedLine; @@ -579,9 +579,9 @@ bool cmVisualStudioSlnParser::ParseKeyValuePair(const std::string& line, return true; } const std::string& key = line.substr(0, idxEqualSign); - parsedLine.SetTag(cmSystemTools::TrimWhitespace(key)); + parsedLine.SetTag(cmTrimWhitespace(key)); const std::string& value = line.substr(idxEqualSign + 1); - parsedLine.AddValue(cmSystemTools::TrimWhitespace(value)); + parsedLine.AddValue(cmTrimWhitespace(value)); return true; } @@ -590,18 +590,17 @@ bool cmVisualStudioSlnParser::ParseTag(const std::string& fullTag, { size_t idxLeftParen = fullTag.find('('); if (idxLeftParen == fullTag.npos) { - parsedLine.SetTag(cmSystemTools::TrimWhitespace(fullTag)); + parsedLine.SetTag(cmTrimWhitespace(fullTag)); return true; } - parsedLine.SetTag( - cmSystemTools::TrimWhitespace(fullTag.substr(0, idxLeftParen))); + parsedLine.SetTag(cmTrimWhitespace(fullTag.substr(0, idxLeftParen))); size_t idxRightParen = fullTag.rfind(')'); if (idxRightParen == fullTag.npos) { this->LastResult.SetError(ResultErrorInputStructure, state.GetCurrentLine()); return false; } - const std::string& arg = cmSystemTools::TrimWhitespace( + const std::string& arg = cmTrimWhitespace( fullTag.substr(idxLeftParen + 1, idxRightParen - idxLeftParen - 1)); if (arg.front() == '"') { if (arg.back() != '"') { @@ -618,7 +617,7 @@ bool cmVisualStudioSlnParser::ParseTag(const std::string& fullTag, bool cmVisualStudioSlnParser::ParseValue(const std::string& value, ParsedLine& parsedLine) { - const std::string& trimmed = cmSystemTools::TrimWhitespace(value); + const std::string& trimmed = cmTrimWhitespace(value); if (trimmed.empty()) parsedLine.AddValue(trimmed); else if (trimmed.front() == '"' && trimmed.back() == '"') ----------------------------------------------------------------------- Summary of changes: Help/variable/CMAKE_MESSAGE_INDENT.rst | 2 +- Source/CPack/IFW/cmCPackIFWInstaller.cxx | 3 +- Source/CPack/WiX/cmCMakeToWixPath.cxx | 4 +- Source/CPack/WiX/cmWIXAccessControlList.cxx | 7 ++-- Source/cmCommandArgumentParserHelper.cxx | 7 ++-- Source/cmCoreTryCompile.cxx | 2 +- Source/cmFileAPICodemodel.cxx | 11 +++--- Source/cmGeneratorTarget.cxx | 3 +- Source/cmGetFilenameComponentCommand.cxx | 3 +- Source/cmGlobalNinjaGenerator.cxx | 4 +- Source/cmGlobalVisualStudio10Generator.cxx | 2 +- Source/cmGlobalVisualStudio7Generator.cxx | 4 +- Source/cmGlobalXCodeGenerator.cxx | 6 +-- Source/cmJsonObjects.cxx | 17 ++++---- Source/cmListCommand.cxx | 2 +- Source/cmMakefile.cxx | 9 ++--- Source/cmSourceGroupCommand.cxx | 2 +- Source/cmStringAlgorithms.cxx | 53 +++++++++++++++++++++++++ Source/cmStringAlgorithms.h | 16 ++++++++ Source/cmSystemTools.cxx | 61 +---------------------------- Source/cmSystemTools.h | 12 ------ Source/cmVSSetupHelper.cxx | 3 +- Source/cmVisualStudioGeneratorOptions.cxx | 4 +- Source/cmVisualStudioSlnParser.cxx | 15 ++++--- Tests/CMakeLib/testStringAlgorithms.cxx | 37 +++++++++++++++++ 25 files changed, 162 insertions(+), 127 deletions(-) hooks/post-receive -- CMake From kwrobot at kitware.com Wed Aug 7 12:00:33 2019 From: kwrobot at kitware.com (Kitware Robot) Date: Wed, 7 Aug 2019 12:00:33 -0400 (EDT) Subject: [Cmake-commits] CMake branch, master, updated. v3.15.1-615-gbbf4a57 Message-ID: <20190807160033.71FEA113B59@public.kitware.com> This is an automated email from the git hooks/post-receive script. It was generated because a ref change was pushed to the repository containing the project "CMake". The branch, master has been updated via bbf4a5771f8113ce5b88968c4dd3def2fbcd9354 (commit) via dd53122be5b142e97ac02d1dec62719db29bc39e (commit) via 7ed84b1e8fc9a5bb7a7fe0b0b1a6077b2498d6c7 (commit) via 18b0330b86cae2771a54021e390f157a097c8a99 (commit) from ddb1759b3e2b5c1b2c56734cd2ae0fa6dcf3a815 (commit) Those revisions listed above that are new to this repository have not appeared on any other notification email; so we list those revisions in full, below. - Log ----------------------------------------------------------------- https://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=bbf4a5771f8113ce5b88968c4dd3def2fbcd9354 commit bbf4a5771f8113ce5b88968c4dd3def2fbcd9354 Merge: dd53122 18b0330 Author: Brad King AuthorDate: Wed Aug 7 15:45:02 2019 +0000 Commit: Kitware Robot CommitDate: Wed Aug 7 11:54:53 2019 -0400 Merge topic 'tidy_inefficient_string' 18b0330b86 clang-tidy: Enable performance-inefficient-string-concatenation Acked-by: Kitware Robot Merge-request: !3648 https://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=dd53122be5b142e97ac02d1dec62719db29bc39e commit dd53122be5b142e97ac02d1dec62719db29bc39e Merge: ddb1759 7ed84b1 Author: Brad King AuthorDate: Wed Aug 7 15:44:52 2019 +0000 Commit: Kitware Robot CommitDate: Wed Aug 7 11:52:57 2019 -0400 Merge topic 'FindPython-virtual-env' 7ed84b1e8f FindPython: ensure virtual environments are correctly handled Acked-by: Kitware Robot Merge-request: !3649 https://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=7ed84b1e8fc9a5bb7a7fe0b0b1a6077b2498d6c7 commit 7ed84b1e8fc9a5bb7a7fe0b0b1a6077b2498d6c7 Author: Marc Chevrier AuthorDate: Sat Aug 3 16:24:20 2019 +0200 Commit: Marc Chevrier CommitDate: Mon Aug 5 18:20:29 2019 +0200 FindPython: ensure virtual environments are correctly handled Fixes: #19525 diff --git a/Modules/FindPython.cmake b/Modules/FindPython.cmake index 6a9decb..2056e93 100644 --- a/Modules/FindPython.cmake +++ b/Modules/FindPython.cmake @@ -237,6 +237,12 @@ Hints ``NEVER`` to select preferably the interpreter from the virtual environment. + .. note:: + + If the component ``Development`` is requested, it is **strongly** + recommended to also include the component ``Interpreter`` to get expected + result. + Commands ^^^^^^^^ diff --git a/Modules/FindPython/Support.cmake b/Modules/FindPython/Support.cmake index 8faec03..90a8264 100644 --- a/Modules/FindPython/Support.cmake +++ b/Modules/FindPython/Support.cmake @@ -241,6 +241,85 @@ function (_PYTHON_GET_NAMES _PYTHON_PGN_NAMES) set (${_PYTHON_PGN_NAMES} ${names} PARENT_SCOPE) endfunction() +function (_PYTHON_GET_CONFIG_VAR _PYTHON_PGCV_VALUE NAME) + unset (${_PYTHON_PGCV_VALUE} PARENT_SCOPE) + + if (NOT NAME MATCHES "^(PREFIX|ABIFLAGS|CONFIGDIR|INCLUDES|LIBS)$") + return() + endif() + + if (_${_PYTHON_PREFIX}_CONFIG) + set (config_flag "--${NAME}") + string (TOLOWER "${config_flag}" config_flag) + execute_process (COMMAND "${_${_PYTHON_PREFIX}_CONFIG}" ${config_flag} + RESULT_VARIABLE _result + OUTPUT_VARIABLE _values + ERROR_QUIET + OUTPUT_STRIP_TRAILING_WHITESPACE) + if (_result) + unset (_values) + else() + if (NAME STREQUAL "INCLUDES") + # do some clean-up + string (REGEX MATCHALL "-I[^ ]+" _values "${_values}") + string (REPLACE "-I" "" _values "${_values}") + list (REMOVE_DUPLICATES _values) + endif() + endif() + endif() + + if (${_PYTHON_PREFIX}_EXECUTABLE AND NOT CMAKE_CROSSCOMPILING) + if (NAME STREQUAL "PREFIX") + execute_process (COMMAND "${${_PYTHON_PREFIX}_EXECUTABLE}" -c "import sys; from distutils import sysconfig; sys.stdout.write(';'.join([sysconfig.PREFIX,sysconfig.EXEC_PREFIX,sysconfig.BASE_EXEC_PREFIX]))" + RESULT_VARIABLE _result + OUTPUT_VARIABLE _values + ERROR_QUIET + OUTPUT_STRIP_TRAILING_WHITESPACE) + if (_result) + unset (_values) + else() + list (REMOVE_DUPLICATES _values) + endif() + elseif (NAME STREQUAL "INCLUDES") + execute_process (COMMAND "${${_PYTHON_PREFIX}_EXECUTABLE}" -c "import sys; from distutils import sysconfig; sys.stdout.write(';'.join([sysconfig.get_python_inc(plat_specific=True),sysconfig.get_python_inc(plat_specific=False)]))" + RESULT_VARIABLE _result + OUTPUT_VARIABLE _values + ERROR_QUIET + OUTPUT_STRIP_TRAILING_WHITESPACE) + if (_result) + unset (_values) + endif() + else() + set (config_flag "${NAME}") + if (NAME STREQUAL "CONFIGDIR") + set (config_flag "LIBPL") + endif() + execute_process (COMMAND "${${_PYTHON_PREFIX}_EXECUTABLE}" -c "import sys; from distutils import sysconfig; sys.stdout.write(sysconfig.get_config_var('${config_flag}'))" + RESULT_VARIABLE _result + OUTPUT_VARIABLE _values + ERROR_QUIET + OUTPUT_STRIP_TRAILING_WHITESPACE) + if (_result) + unset (_values) + endif() + endif() + endif() + + if (NOT _values OR _values STREQUAL "None") + return() + endif() + + if (NAME STREQUAL "LIBS") + # do some clean-up + string (REGEX MATCHALL "-[l][^ ]+" _values "${_values}") + # remove elements relative to python library itself + list (FILTER _values EXCLUDE REGEX "-lpython") + list (REMOVE_DUPLICATES _values) + endif() + + set (${_PYTHON_PGCV_VALUE} "${_values}" PARENT_SCOPE) +endfunction() + function (_PYTHON_VALIDATE_INTERPRETER) if (NOT ${_PYTHON_PREFIX}_EXECUTABLE) @@ -1147,114 +1226,90 @@ if ("Development" IN_LIST ${_PYTHON_PREFIX}_FIND_COMPONENTS endif() endif() - # if python interpreter is found, use its location and version to ensure consistency - # between interpreter and development environment - unset (_${_PYTHON_PREFIX}_PREFIX) - unset (_${_PYTHON_PREFIX}_EXEC_PREFIX) - unset (_${_PYTHON_PREFIX}_BASE_EXEC_PREFIX) - if (${_PYTHON_PREFIX}_Interpreter_FOUND) - execute_process (COMMAND "${${_PYTHON_PREFIX}_EXECUTABLE}" -c - "import sys; from distutils import sysconfig; sys.stdout.write(sysconfig.EXEC_PREFIX)" - RESULT_VARIABLE _${_PYTHON_PREFIX}_RESULT - OUTPUT_VARIABLE _${_PYTHON_PREFIX}_EXEC_PREFIX - ERROR_QUIET - OUTPUT_STRIP_TRAILING_WHITESPACE) - if (_${_PYTHON_PREFIX}_RESULT) - unset (_${_PYTHON_PREFIX}_EXEC_PREFIX) + # if python interpreter is found, use it to ensure consistency + # between interpreter and development environment. + # If not, try to locate a compatible config tool + if (NOT ${_PYTHON_PREFIX}_Interpreter_FOUND OR CMAKE_CROSSCOMPILING) + set (_${_PYTHON_PREFIX}_HINTS "${${_PYTHON_PREFIX}_ROOT_DIR}" ENV ${_PYTHON_PREFIX}_ROOT_DIR) + unset (_${_PYTHON_PREFIX}_VIRTUALENV_PATHS) + if (_${_PYTHON_PREFIX}_FIND_VIRTUALENV MATCHES "^(FIRST|ONLY)$") + set (_${_PYTHON_PREFIX}_VIRTUALENV_PATHS ENV VIRTUAL_ENV) endif() + unset (_${_PYTHON_PREFIX}_FRAMEWORK_PATHS) - if (NOT ${_PYTHON_PREFIX}_FIND_VIRTUALENV STREQUAL "STANDARD") - execute_process (COMMAND "${${_PYTHON_PREFIX}_EXECUTABLE}" -c - "import sys; from distutils import sysconfig; sys.stdout.write(sysconfig.BASE_EXEC_PREFIX)" - RESULT_VARIABLE _${_PYTHON_PREFIX}_RESULT - OUTPUT_VARIABLE _${_PYTHON_PREFIX}_BASE_EXEC_PREFIX - ERROR_QUIET - OUTPUT_STRIP_TRAILING_WHITESPACE) - if (_${_PYTHON_PREFIX}_RESULT) - unset (_${_PYTHON_PREFIX}_BASE_EXEC_PREFIX) - endif() - endif() - endif() - set (_${_PYTHON_PREFIX}_BASE_HINTS "${_${_PYTHON_PREFIX}_EXEC_PREFIX}" "${_${_PYTHON_PREFIX}_BASE_EXEC_PREFIX}" "${${_PYTHON_PREFIX}_ROOT_DIR}" ENV ${_PYTHON_PREFIX}_ROOT_DIR) - set (_${_PYTHON_PREFIX}_HINTS ${_${_PYTHON_PREFIX}_BASE_HINTS}) + if (_${_PYTHON_PREFIX}_FIND_STRATEGY STREQUAL "LOCATION") + set (_${_PYTHON_PREFIX}_CONFIG_NAMES) - if (_${_PYTHON_PREFIX}_FIND_STRATEGY STREQUAL "LOCATION") - set (_${_PYTHON_PREFIX}_CONFIG_NAMES) + foreach (_${_PYTHON_PREFIX}_VERSION IN LISTS _${_PYTHON_PREFIX}_FIND_VERSIONS) + _python_get_names (_${_PYTHON_PREFIX}_VERSION_NAMES VERSION ${_${_PYTHON_PREFIX}_VERSION} POSIX CONFIG) + list (APPEND _${_PYTHON_PREFIX}_CONFIG_NAMES ${_${_PYTHON_PREFIX}_VERSION_NAMES}) - foreach (_${_PYTHON_PREFIX}_VERSION IN LISTS _${_PYTHON_PREFIX}_FIND_VERSIONS) - _python_get_names (_${_PYTHON_PREFIX}_VERSION_NAMES VERSION ${_${_PYTHON_PREFIX}_VERSION} POSIX CONFIG) - list (APPEND _${_PYTHON_PREFIX}_CONFIG_NAMES ${_${_PYTHON_PREFIX}_VERSION_NAMES}) - endforeach() - - find_program (_${_PYTHON_PREFIX}_CONFIG - NAMES ${_${_PYTHON_PREFIX}_CONFIG_NAMES} - NAMES_PER_DIR - HINTS ${_${_PYTHON_PREFIX}_HINTS} - PATH_SUFFIXES bin) + # Framework Paths + _python_get_frameworks (_${_PYTHON_PREFIX}_VERSION_PATHS ${_${_PYTHON_PREFIX}_VERSION}) + list (APPEND _${_PYTHON_PREFIX}_FRAMEWORK_PATHS ${_${_PYTHON_PREFIX}_VERSION_PATHS}) + endforeach() - if (_${_PYTHON_PREFIX}_CONFIG) - execute_process (COMMAND "${_${_PYTHON_PREFIX}_CONFIG}" --abiflags - RESULT_VARIABLE _${_PYTHON_PREFIX}_RESULT - OUTPUT_VARIABLE __${_PYTHON_PREFIX}_ABIFLAGS - ERROR_QUIET - OUTPUT_STRIP_TRAILING_WHITESPACE) - if (_${_PYTHON_PREFIX}_RESULT) - # assume ABI is not supported - set (__${_PYTHON_PREFIX}_ABIFLAGS "") - endif() - if (DEFINED _${_PYTHON_PREFIX}_FIND_ABI AND NOT __${_PYTHON_PREFIX}_ABIFLAGS IN_LIST _${_PYTHON_PREFIX}_ABIFLAGS) - # Wrong ABI - unset (_${_PYTHON_PREFIX}_CONFIG CACHE) + # Apple frameworks handling + if (CMAKE_HOST_APPLE AND _${_PYTHON_PREFIX}_FIND_FRAMEWORK STREQUAL "FIRST") + find_program (${_PYTHON_PREFIX}_CONFIG + NAMES ${_${_PYTHON_PREFIX}_CONFIG_NAMES} + NAMES_PER_DIR + HINTS ${_${_PYTHON_PREFIX}_HINTS} + PATHS ${_${_PYTHON_PREFIX}_VIRTUALENV_PATHS} + ${_${_PYTHON_PREFIX}_FRAMEWORK_PATHS} + PATH_SUFFIXES bin + NO_CMAKE_PATH + NO_CMAKE_ENVIRONMENT_PATH + NO_SYSTEM_ENVIRONMENT_PATH + NO_CMAKE_SYSTEM_PATH) endif() - endif() - if (_${_PYTHON_PREFIX}_CONFIG AND DEFINED CMAKE_LIBRARY_ARCHITECTURE) - # check that config tool match library architecture - execute_process (COMMAND "${_${_PYTHON_PREFIX}_CONFIG}" --configdir - RESULT_VARIABLE _${_PYTHON_PREFIX}_RESULT - OUTPUT_VARIABLE _${_PYTHON_PREFIX}_CONFIGDIR - ERROR_QUIET - OUTPUT_STRIP_TRAILING_WHITESPACE) - if (_${_PYTHON_PREFIX}_RESULT) - unset (_${_PYTHON_PREFIX}_CONFIG CACHE) - else() - string(FIND "${_${_PYTHON_PREFIX}_CONFIGDIR}" "${CMAKE_LIBRARY_ARCHITECTURE}" _${_PYTHON_PREFIX}_RESULT) - if (_${_PYTHON_PREFIX}_RESULT EQUAL -1) - unset (_${_PYTHON_PREFIX}_CONFIG CACHE) - endif() - endif() - endif() - else() - foreach (_${_PYTHON_PREFIX}_VERSION IN LISTS _${_PYTHON_PREFIX}_FIND_VERSIONS) - # try to use pythonX.Y-config tool - _python_get_names (_${_PYTHON_PREFIX}_CONFIG_NAMES VERSION ${_${_PYTHON_PREFIX}_VERSION} POSIX CONFIG) find_program (_${_PYTHON_PREFIX}_CONFIG NAMES ${_${_PYTHON_PREFIX}_CONFIG_NAMES} NAMES_PER_DIR HINTS ${_${_PYTHON_PREFIX}_HINTS} + PATHS ${_${_PYTHON_PREFIX}_VIRTUALENV_PATHS} PATH_SUFFIXES bin) - unset (_${_PYTHON_PREFIX}_CONFIG_NAMES) - if (NOT _${_PYTHON_PREFIX}_CONFIG) - continue() + # Apple frameworks handling + if (CMAKE_HOST_APPLE AND _${_PYTHON_PREFIX}_FIND_FRAMEWORK STREQUAL "LAST") + find_program (_${_PYTHON_PREFIX}_CONFIG + NAMES ${_${_PYTHON_PREFIX}_CONFIG_NAMES} + NAMES_PER_DIR + PATHS ${_${_PYTHON_PREFIX}_FRAMEWORK_PATHS} + PATH_SUFFIXES bin + NO_DEFAULT_PATH) endif() - execute_process (COMMAND "${_${_PYTHON_PREFIX}_CONFIG}" --abiflags - RESULT_VARIABLE _${_PYTHON_PREFIX}_RESULT - OUTPUT_VARIABLE __${_PYTHON_PREFIX}_ABIFLAGS - ERROR_QUIET - OUTPUT_STRIP_TRAILING_WHITESPACE) - if (_${_PYTHON_PREFIX}_RESULT) - # assume ABI is not supported - set (__${_PYTHON_PREFIX}_ABIFLAGS "") + if (_${_PYTHON_PREFIX}_CONFIG) + execute_process (COMMAND "${_${_PYTHON_PREFIX}_CONFIG}" --help + RESULT_VARIABLE _${_PYTHON_PREFIX}_RESULT + OUTPUT_VARIABLE __${_PYTHON_PREFIX}_HELP + ERROR_QUIET + OUTPUT_STRIP_TRAILING_WHITESPACE) + if (_${_PYTHON_PREFIX}_RESULT) + # assume config tool is not usable + unset (_${_PYTHON_PREFIX}_CONFIG CACHE) + endif() endif() - if (DEFINED _${_PYTHON_PREFIX}_FIND_ABI AND NOT __${_PYTHON_PREFIX}_ABIFLAGS IN_LIST _${_PYTHON_PREFIX}_ABIFLAGS) - # Wrong ABI - unset (_${_PYTHON_PREFIX}_CONFIG CACHE) - continue() + + if (_${_PYTHON_PREFIX}_CONFIG) + execute_process (COMMAND "${_${_PYTHON_PREFIX}_CONFIG}" --abiflags + RESULT_VARIABLE _${_PYTHON_PREFIX}_RESULT + OUTPUT_VARIABLE __${_PYTHON_PREFIX}_ABIFLAGS + ERROR_QUIET + OUTPUT_STRIP_TRAILING_WHITESPACE) + if (_${_PYTHON_PREFIX}_RESULT) + # assume ABI is not supported + set (__${_PYTHON_PREFIX}_ABIFLAGS "") + endif() + if (DEFINED _${_PYTHON_PREFIX}_FIND_ABI AND NOT __${_PYTHON_PREFIX}_ABIFLAGS IN_LIST _${_PYTHON_PREFIX}_ABIFLAGS) + # Wrong ABI + unset (_${_PYTHON_PREFIX}_CONFIG CACHE) + endif() endif() - if (DEFINED CMAKE_LIBRARY_ARCHITECTURE) + if (_${_PYTHON_PREFIX}_CONFIG AND DEFINED CMAKE_LIBRARY_ARCHITECTURE) # check that config tool match library architecture execute_process (COMMAND "${_${_PYTHON_PREFIX}_CONFIG}" --configdir RESULT_VARIABLE _${_PYTHON_PREFIX}_RESULT @@ -1263,62 +1318,132 @@ if ("Development" IN_LIST ${_PYTHON_PREFIX}_FIND_COMPONENTS OUTPUT_STRIP_TRAILING_WHITESPACE) if (_${_PYTHON_PREFIX}_RESULT) unset (_${_PYTHON_PREFIX}_CONFIG CACHE) + else() + string(FIND "${_${_PYTHON_PREFIX}_CONFIGDIR}" "${CMAKE_LIBRARY_ARCHITECTURE}" _${_PYTHON_PREFIX}_RESULT) + if (_${_PYTHON_PREFIX}_RESULT EQUAL -1) + unset (_${_PYTHON_PREFIX}_CONFIG CACHE) + endif() + endif() + endif() + else() + foreach (_${_PYTHON_PREFIX}_VERSION IN LISTS _${_PYTHON_PREFIX}_FIND_VERSIONS) + # try to use pythonX.Y-config tool + _python_get_names (_${_PYTHON_PREFIX}_CONFIG_NAMES VERSION ${_${_PYTHON_PREFIX}_VERSION} POSIX CONFIG) + + # Framework Paths + _python_get_frameworks (_${_PYTHON_PREFIX}_FRAMEWORK_PATHS ${_${_PYTHON_PREFIX}_VERSION}) + + # Apple frameworks handling + if (CMAKE_HOST_APPLE AND _${_PYTHON_PREFIX}_FIND_FRAMEWORK STREQUAL "FIRST") + find_program (${_PYTHON_PREFIX}_CONFIG + NAMES ${_${_PYTHON_PREFIX}_CONFIG_NAMES} + NAMES_PER_DIR + HINTS ${_${_PYTHON_PREFIX}_HINTS} + PATHS ${_${_PYTHON_PREFIX}_VIRTUALENV_PATHS} + ${_${_PYTHON_PREFIX}_FRAMEWORK_PATHS} + PATH_SUFFIXES bin + NO_CMAKE_PATH + NO_CMAKE_ENVIRONMENT_PATH + NO_SYSTEM_ENVIRONMENT_PATH + NO_CMAKE_SYSTEM_PATH) + endif() + + find_program (_${_PYTHON_PREFIX}_CONFIG + NAMES ${_${_PYTHON_PREFIX}_CONFIG_NAMES} + NAMES_PER_DIR + HINTS ${_${_PYTHON_PREFIX}_HINTS} + PATHS ${_${_PYTHON_PREFIX}_VIRTUALENV_PATHS} + PATH_SUFFIXES bin) + + # Apple frameworks handling + if (CMAKE_HOST_APPLE AND _${_PYTHON_PREFIX}_FIND_FRAMEWORK STREQUAL "LAST") + find_program (_${_PYTHON_PREFIX}_CONFIG + NAMES ${_${_PYTHON_PREFIX}_CONFIG_NAMES} + NAMES_PER_DIR + PATHS ${_${_PYTHON_PREFIX}_FRAMEWORK_PATHS} + PATH_SUFFIXES bin + NO_DEFAULT_PATH) + endif() + + unset (_${_PYTHON_PREFIX}_CONFIG_NAMES) + + if (_${_PYTHON_PREFIX}_CONFIG) + execute_process (COMMAND "${_${_PYTHON_PREFIX}_CONFIG}" --help + RESULT_VARIABLE _${_PYTHON_PREFIX}_RESULT + OUTPUT_VARIABLE __${_PYTHON_PREFIX}_HELP + ERROR_QUIET + OUTPUT_STRIP_TRAILING_WHITESPACE) + if (_${_PYTHON_PREFIX}_RESULT) + # assume config tool is not usable + unset (_${_PYTHON_PREFIX}_CONFIG CACHE) + endif() + endif() + + if (NOT _${_PYTHON_PREFIX}_CONFIG) continue() endif() - string(FIND "${_${_PYTHON_PREFIX}_CONFIGDIR}" "${CMAKE_LIBRARY_ARCHITECTURE}" _${_PYTHON_PREFIX}_RESULT) - if (_${_PYTHON_PREFIX}_RESULT EQUAL -1) + + execute_process (COMMAND "${_${_PYTHON_PREFIX}_CONFIG}" --abiflags + RESULT_VARIABLE _${_PYTHON_PREFIX}_RESULT + OUTPUT_VARIABLE __${_PYTHON_PREFIX}_ABIFLAGS + ERROR_QUIET + OUTPUT_STRIP_TRAILING_WHITESPACE) + if (_${_PYTHON_PREFIX}_RESULT) + # assume ABI is not supported + set (__${_PYTHON_PREFIX}_ABIFLAGS "") + endif() + if (DEFINED _${_PYTHON_PREFIX}_FIND_ABI AND NOT __${_PYTHON_PREFIX}_ABIFLAGS IN_LIST _${_PYTHON_PREFIX}_ABIFLAGS) + # Wrong ABI unset (_${_PYTHON_PREFIX}_CONFIG CACHE) continue() endif() - endif() - if (_${_PYTHON_PREFIX}_CONFIG) - break() - endif() - endforeach() - endif() + if (_${_PYTHON_PREFIX}_CONFIG AND DEFINED CMAKE_LIBRARY_ARCHITECTURE) + # check that config tool match library architecture + execute_process (COMMAND "${_${_PYTHON_PREFIX}_CONFIG}" --configdir + RESULT_VARIABLE _${_PYTHON_PREFIX}_RESULT + OUTPUT_VARIABLE _${_PYTHON_PREFIX}_CONFIGDIR + ERROR_QUIET + OUTPUT_STRIP_TRAILING_WHITESPACE) + if (_${_PYTHON_PREFIX}_RESULT) + unset (_${_PYTHON_PREFIX}_CONFIG CACHE) + continue() + endif() + string(FIND "${_${_PYTHON_PREFIX}_CONFIGDIR}" "${CMAKE_LIBRARY_ARCHITECTURE}" _${_PYTHON_PREFIX}_RESULT) + if (_${_PYTHON_PREFIX}_RESULT EQUAL -1) + unset (_${_PYTHON_PREFIX}_CONFIG CACHE) + continue() + endif() + endif() - if (_${_PYTHON_PREFIX}_CONFIG) - # retrieve root install directory - execute_process (COMMAND "${_${_PYTHON_PREFIX}_CONFIG}" --prefix - RESULT_VARIABLE _${_PYTHON_PREFIX}_RESULT - OUTPUT_VARIABLE _${_PYTHON_PREFIX}_PREFIX - ERROR_QUIET - OUTPUT_STRIP_TRAILING_WHITESPACE) - if (_${_PYTHON_PREFIX}_RESULT) - # python-config is not usable - unset (_${_PYTHON_PREFIX}_CONFIG CACHE) + if (_${_PYTHON_PREFIX}_CONFIG) + break() + endif() + endforeach() endif() endif() - if (_${_PYTHON_PREFIX}_CONFIG) + if ((${_PYTHON_PREFIX}_Interpreter_FOUND AND NOT CMAKE_CROSSCOMPILING) OR _${_PYTHON_PREFIX}_CONFIG) + # retrieve root install directory + _python_get_config_var (_${_PYTHON_PREFIX}_PREFIX PREFIX) + # enforce current ABI - execute_process (COMMAND "${_${_PYTHON_PREFIX}_CONFIG}" --abiflags - RESULT_VARIABLE _${_PYTHON_PREFIX}_RESULT - OUTPUT_VARIABLE _${_PYTHON_PREFIX}_ABIFLAGS - ERROR_QUIET - OUTPUT_STRIP_TRAILING_WHITESPACE) - if (_${_PYTHON_PREFIX}_RESULT) - # assume ABI is not supported - set (_${_PYTHON_PREFIX}_ABIFLAGS "") - endif() + _python_get_config_var (_${_PYTHON_PREFIX}_ABIFLAGS ABIFLAGS) set (_${_PYTHON_PREFIX}_HINTS "${_${_PYTHON_PREFIX}_PREFIX}") # retrieve library ## compute some paths and artifact names - string (REGEX REPLACE "^.+python([0-9.]+)[a-z]*-config" "\\1" _${_PYTHON_PREFIX}_CONFIG_VERSION "${_${_PYTHON_PREFIX}_CONFIG}") - _python_get_path_suffixes (_${_PYTHON_PREFIX}_PATH_SUFFIXES VERSION ${_${_PYTHON_PREFIX}_CONFIG_VERSION} LIBRARY) - _python_get_names (_${_PYTHON_PREFIX}_LIB_NAMES VERSION ${_${_PYTHON_PREFIX}_CONFIG_VERSION} POSIX LIBRARY) - - execute_process (COMMAND "${_${_PYTHON_PREFIX}_CONFIG}" --configdir - RESULT_VARIABLE _${_PYTHON_PREFIX}_RESULT - OUTPUT_VARIABLE _${_PYTHON_PREFIX}_CONFIGDIR - ERROR_QUIET - OUTPUT_STRIP_TRAILING_WHITESPACE) - if (NOT _${_PYTHON_PREFIX}_RESULT) - list (APPEND _${_PYTHON_PREFIX}_HINTS "${_${_PYTHON_PREFIX}_CONFIGDIR}") + if (_${_PYTHON_PREFIX}_CONFIG) + string (REGEX REPLACE "^.+python([0-9.]+)[a-z]*-config" "\\1" _${_PYTHON_PREFIX}_LIB_VERSION "${_${_PYTHON_PREFIX}_CONFIG}") + else() + set (_${_PYTHON_PREFIX}_LIB_VERSION "${${_PYTHON_PREFIX}_VERSION_MAJOR}.${${_PYTHON_PREFIX}_VERSION_MINOR}") endif() + _python_get_path_suffixes (_${_PYTHON_PREFIX}_PATH_SUFFIXES VERSION ${_${_PYTHON_PREFIX}_LIB_VERSION} LIBRARY) + _python_get_names (_${_PYTHON_PREFIX}_LIB_NAMES VERSION ${_${_PYTHON_PREFIX}_LIB_VERSION} POSIX LIBRARY) + + _python_get_config_var (_${_PYTHON_PREFIX}_CONFIGDIR CONFIGDIR) + list (APPEND _${_PYTHON_PREFIX}_HINTS "${_${_PYTHON_PREFIX}_CONFIGDIR}") list (APPEND _${_PYTHON_PREFIX}_HINTS "${${_PYTHON_PREFIX}_ROOT_DIR}" ENV ${_PYTHON_PREFIX}_ROOT_DIR) @@ -1344,28 +1469,23 @@ if ("Development" IN_LIST ${_PYTHON_PREFIX}_FIND_COMPONENTS endif() # retrieve include directory - execute_process (COMMAND "${_${_PYTHON_PREFIX}_CONFIG}" --includes - RESULT_VARIABLE _${_PYTHON_PREFIX}_RESULT - OUTPUT_VARIABLE _${_PYTHON_PREFIX}_FLAGS - ERROR_QUIET - OUTPUT_STRIP_TRAILING_WHITESPACE) - if (NOT _${_PYTHON_PREFIX}_RESULT) - # retrieve include directory - string (REGEX MATCHALL "-I[^ ]+" _${_PYTHON_PREFIX}_INCLUDE_DIRS "${_${_PYTHON_PREFIX}_FLAGS}") - string (REPLACE "-I" "" _${_PYTHON_PREFIX}_INCLUDE_DIRS "${_${_PYTHON_PREFIX}_INCLUDE_DIRS}") - list (REMOVE_DUPLICATES _${_PYTHON_PREFIX}_INCLUDE_DIRS) + _python_get_config_var (_${_PYTHON_PREFIX}_INCLUDE_DIRS INCLUDES) - find_path (${_PYTHON_PREFIX}_INCLUDE_DIR - NAMES Python.h - HINTS ${_${_PYTHON_PREFIX}_INCLUDE_DIRS} - NO_SYSTEM_ENVIRONMENT_PATH - NO_CMAKE_SYSTEM_PATH) - endif() + find_path (${_PYTHON_PREFIX}_INCLUDE_DIR + NAMES Python.h + HINTS ${_${_PYTHON_PREFIX}_INCLUDE_DIRS} + NO_SYSTEM_ENVIRONMENT_PATH + NO_CMAKE_SYSTEM_PATH) endif() - # Rely on HINTS and standard paths if config tool failed to locate artifacts + # Rely on HINTS and standard paths if interpreter or config tool failed to locate artifacts if (NOT ${_PYTHON_PREFIX}_LIBRARY_RELEASE OR NOT ${_PYTHON_PREFIX}_INCLUDE_DIR) - set (_${_PYTHON_PREFIX}_HINTS ${_${_PYTHON_PREFIX}_BASE_HINTS}) + set (_${_PYTHON_PREFIX}_HINTS "${${_PYTHON_PREFIX}_ROOT_DIR}" ENV ${_PYTHON_PREFIX}_ROOT_DIR) + + unset (_${_PYTHON_PREFIX}_VIRTUALENV_PATHS) + if (_${_PYTHON_PREFIX}_FIND_VIRTUALENV MATCHES "^(FIRST|ONLY)$") + set (_${_PYTHON_PREFIX}_VIRTUALENV_PATHS ENV VIRTUAL_ENV) + endif() if (_${_PYTHON_PREFIX}_FIND_STRATEGY STREQUAL "LOCATION") unset (_${_PYTHON_PREFIX}_LIB_NAMES) @@ -1399,7 +1519,8 @@ if ("Development" IN_LIST ${_PYTHON_PREFIX}_FIND_COMPONENTS NAMES ${_${_PYTHON_PREFIX}_LIB_NAMES} NAMES_PER_DIR HINTS ${_${_PYTHON_PREFIX}_HINTS} - PATHS ${_${_PYTHON_PREFIX}_FRAMEWORK_PATHS} + PATHS ${_${_PYTHON_PREFIX}_VIRTUALENV_PATHS} + ${_${_PYTHON_PREFIX}_FRAMEWORK_PATHS} PATH_SUFFIXES ${_${_PYTHON_PREFIX}_PATH_SUFFIXES} NO_CMAKE_PATH NO_CMAKE_ENVIRONMENT_PATH @@ -1412,7 +1533,8 @@ if ("Development" IN_LIST ${_PYTHON_PREFIX}_FIND_COMPONENTS NAMES ${_${_PYTHON_PREFIX}_LIB_NAMES} NAMES_PER_DIR HINTS ${_${_PYTHON_PREFIX}_HINTS} - PATHS ${_${_PYTHON_PREFIX}_REGISTRY_PATHS} + PATHS ${_${_PYTHON_PREFIX}_VIRTUALENV_PATHS} + ${_${_PYTHON_PREFIX}_REGISTRY_PATHS} PATH_SUFFIXES ${_${_PYTHON_PREFIX}_PATH_SUFFIXES} NO_SYSTEM_ENVIRONMENT_PATH NO_CMAKE_SYSTEM_PATH) @@ -1423,6 +1545,7 @@ if ("Development" IN_LIST ${_PYTHON_PREFIX}_FIND_COMPONENTS NAMES ${_${_PYTHON_PREFIX}_LIB_NAMES} NAMES_PER_DIR HINTS ${_${_PYTHON_PREFIX}_HINTS} + PATHS ${_${_PYTHON_PREFIX}_VIRTUALENV_PATHS} PATH_SUFFIXES ${_${_PYTHON_PREFIX}_PATH_SUFFIXES} NO_SYSTEM_ENVIRONMENT_PATH NO_CMAKE_SYSTEM_PATH) @@ -1474,7 +1597,8 @@ if ("Development" IN_LIST ${_PYTHON_PREFIX}_FIND_COMPONENTS NAMES ${_${_PYTHON_PREFIX}_LIB_NAMES_DEBUG} NAMES_PER_DIR HINTS ${_${_PYTHON_PREFIX}_HINTS} - PATHS ${_${_PYTHON_PREFIX}_REGISTRY_PATHS} + PATHS ${_${_PYTHON_PREFIX}_VIRTUALENV_PATHS} + ${_${_PYTHON_PREFIX}_REGISTRY_PATHS} PATH_SUFFIXES lib libs NO_SYSTEM_ENVIRONMENT_PATH NO_CMAKE_SYSTEM_PATH) @@ -1484,7 +1608,8 @@ if ("Development" IN_LIST ${_PYTHON_PREFIX}_FIND_COMPONENTS NAMES ${_${_PYTHON_PREFIX}_LIB_NAMES_DEBUG} NAMES_PER_DIR HINTS ${_${_PYTHON_PREFIX}_HINTS} - PATHS ${__${_PYTHON_PREFIX}_REGISTRY_PATHS} + PATHS ${_${_PYTHON_PREFIX}_VIRTUALENV_PATHS} + ${__${_PYTHON_PREFIX}_REGISTRY_PATHS} PATH_SUFFIXES lib libs) # extract version from library name @@ -1510,7 +1635,8 @@ if ("Development" IN_LIST ${_PYTHON_PREFIX}_FIND_COMPONENTS NAMES ${_${_PYTHON_PREFIX}_LIB_NAMES} NAMES_PER_DIR HINTS ${_${_PYTHON_PREFIX}_HINTS} - PATHS ${_${_PYTHON_PREFIX}_FRAMEWORK_PATHS} + PATHS ${_${_PYTHON_PREFIX}_VIRTUALENV_PATHS} + ${_${_PYTHON_PREFIX}_FRAMEWORK_PATHS} PATH_SUFFIXES ${_${_PYTHON_PREFIX}_PATH_SUFFIXES} NO_CMAKE_PATH NO_CMAKE_ENVIRONMENT_PATH @@ -1523,7 +1649,8 @@ if ("Development" IN_LIST ${_PYTHON_PREFIX}_FIND_COMPONENTS NAMES ${_${_PYTHON_PREFIX}_LIB_NAMES} NAMES_PER_DIR HINTS ${_${_PYTHON_PREFIX}_HINTS} - PATHS ${_${_PYTHON_PREFIX}_REGISTRY_PATHS} + PATHS ${_${_PYTHON_PREFIX}_VIRTUALENV_PATHS} + ${_${_PYTHON_PREFIX}_REGISTRY_PATHS} PATH_SUFFIXES ${_${_PYTHON_PREFIX}_PATH_SUFFIXES} NO_SYSTEM_ENVIRONMENT_PATH NO_CMAKE_SYSTEM_PATH) @@ -1534,6 +1661,7 @@ if ("Development" IN_LIST ${_PYTHON_PREFIX}_FIND_COMPONENTS NAMES ${_${_PYTHON_PREFIX}_LIB_NAMES} NAMES_PER_DIR HINTS ${_${_PYTHON_PREFIX}_HINTS} + PATHS ${_${_PYTHON_PREFIX}_VIRTUALENV_PATHS} PATH_SUFFIXES ${_${_PYTHON_PREFIX}_PATH_SUFFIXES} NO_SYSTEM_ENVIRONMENT_PATH NO_CMAKE_SYSTEM_PATH) @@ -1575,7 +1703,8 @@ if ("Development" IN_LIST ${_PYTHON_PREFIX}_FIND_COMPONENTS NAMES ${_${_PYTHON_PREFIX}_LIB_NAMES_DEBUG} NAMES_PER_DIR HINTS ${_${_PYTHON_PREFIX}_HINTS} - PATHS ${_${_PYTHON_PREFIX}_REGISTRY_PATHS} + PATHS ${_${_PYTHON_PREFIX}_VIRTUALENV_PATHS} + ${_${_PYTHON_PREFIX}_REGISTRY_PATHS} PATH_SUFFIXES lib libs NO_SYSTEM_ENVIRONMENT_PATH NO_CMAKE_SYSTEM_PATH) @@ -1585,7 +1714,8 @@ if ("Development" IN_LIST ${_PYTHON_PREFIX}_FIND_COMPONENTS NAMES ${_${_PYTHON_PREFIX}_LIB_NAMES_DEBUG} NAMES_PER_DIR HINTS ${_${_PYTHON_PREFIX}_HINTS} - PATHS ${__${_PYTHON_PREFIX}_REGISTRY_PATHS} + PATHS ${_${_PYTHON_PREFIX}_VIRTUALENV_PATHS} + ${__${_PYTHON_PREFIX}_REGISTRY_PATHS} PATH_SUFFIXES lib libs) endif() endif() @@ -1623,20 +1753,6 @@ if ("Development" IN_LIST ${_PYTHON_PREFIX}_FIND_COMPONENTS if (${_PYTHON_PREFIX}_LIBRARY_RELEASE OR ${_PYTHON_PREFIX}_LIBRARY_DEBUG) unset (_${_PYTHON_PREFIX}_INCLUDE_HINTS) - if (${_PYTHON_PREFIX}_EXECUTABLE) - # pick up include directory from configuration - execute_process (COMMAND "${${_PYTHON_PREFIX}_EXECUTABLE}" -c - "import sys; import sysconfig; sys.stdout.write(sysconfig.get_path('include'))" - RESULT_VARIABLE _${_PYTHON_PREFIX}_RESULT - OUTPUT_VARIABLE _${_PYTHON_PREFIX}_PATH - ERROR_QUIET - OUTPUT_STRIP_TRAILING_WHITESPACE) - if (NOT _${_PYTHON_PREFIX}_RESULT) - file (TO_CMAKE_PATH "${_${_PYTHON_PREFIX}_PATH}" _${_PYTHON_PREFIX}_PATH) - list (APPEND _${_PYTHON_PREFIX}_INCLUDE_HINTS "${_${_PYTHON_PREFIX}_PATH}") - endif() - endif() - foreach (_${_PYTHON_PREFIX}_LIB IN ITEMS ${_PYTHON_PREFIX}_LIBRARY_RELEASE ${_PYTHON_PREFIX}_LIBRARY_DEBUG) if (${_${_PYTHON_PREFIX}_LIB}) # Use the library's install prefix as a hint @@ -1664,7 +1780,8 @@ if ("Development" IN_LIST ${_PYTHON_PREFIX}_FIND_COMPONENTS find_path (${_PYTHON_PREFIX}_INCLUDE_DIR NAMES Python.h HINTS ${_${_PYTHON_PREFIX}_INCLUDE_HINTS} ${_${_PYTHON_PREFIX}_HINTS} - PATHS ${_${_PYTHON_PREFIX}_FRAMEWORK_PATHS} + PATHS ${_${_PYTHON_PREFIX}_VIRTUALENV_PATHS} + ${_${_PYTHON_PREFIX}_FRAMEWORK_PATHS} PATH_SUFFIXES ${_${_PYTHON_PREFIX}_PATH_SUFFIXES} NO_CMAKE_PATH NO_CMAKE_ENVIRONMENT_PATH @@ -1676,7 +1793,8 @@ if ("Development" IN_LIST ${_PYTHON_PREFIX}_FIND_COMPONENTS find_path (${_PYTHON_PREFIX}_INCLUDE_DIR NAMES Python.h HINTS ${_${_PYTHON_PREFIX}_INCLUDE_HINTS} ${_${_PYTHON_PREFIX}_HINTS} - PATHS ${_${_PYTHON_PREFIX}_REGISTRY_PATHS} + PATHS ${_${_PYTHON_PREFIX}_VIRTUALENV_PATHS} + ${_${_PYTHON_PREFIX}_REGISTRY_PATHS} PATH_SUFFIXES ${_${_PYTHON_PREFIX}_PATH_SUFFIXES} NO_SYSTEM_ENVIRONMENT_PATH NO_CMAKE_SYSTEM_PATH) @@ -1697,7 +1815,8 @@ if ("Development" IN_LIST ${_PYTHON_PREFIX}_FIND_COMPONENTS find_path (${_PYTHON_PREFIX}_INCLUDE_DIR NAMES Python.h HINTS ${_${_PYTHON_PREFIX}_INCLUDE_HINTS} ${_${_PYTHON_PREFIX}_HINTS} - PATHS ${__${_PYTHON_PREFIX}_FRAMEWORK_PATHS} + PATHS ${_${_PYTHON_PREFIX}_VIRTUALENV_PATHS} + ${__${_PYTHON_PREFIX}_FRAMEWORK_PATHS} ${__${_PYTHON_PREFIX}_REGISTRY_PATHS} PATH_SUFFIXES ${_${_PYTHON_PREFIX}_PATH_SUFFIXES} NO_SYSTEM_ENVIRONMENT_PATH @@ -1896,20 +2015,10 @@ if(_${_PYTHON_PREFIX}_CMAKE_ROLE STREQUAL "PROJECT") endif() endif() - if (_${_PYTHON_PREFIX}_CONFIG AND _${_PYTHON_PREFIX}_LIBRARY_TYPE STREQUAL "STATIC") + if (_${_PYTHON_PREFIX}_LIBRARY_TYPE STREQUAL "STATIC") # extend link information with dependent libraries - execute_process (COMMAND "${_${_PYTHON_PREFIX}_CONFIG}" --ldflags - RESULT_VARIABLE _${_PYTHON_PREFIX}_RESULT - OUTPUT_VARIABLE _${_PYTHON_PREFIX}_FLAGS - ERROR_QUIET - OUTPUT_STRIP_TRAILING_WHITESPACE) - if (NOT _${_PYTHON_PREFIX}_RESULT) - string (REGEX MATCHALL "-[Ll][^ ]+" _${_PYTHON_PREFIX}_LINK_LIBRARIES "${_${_PYTHON_PREFIX}_FLAGS}") - # remove elements relative to python library itself - list (FILTER _${_PYTHON_PREFIX}_LINK_LIBRARIES EXCLUDE REGEX "-lpython") - foreach (_${_PYTHON_PREFIX}_DIR IN LISTS ${_PYTHON_PREFIX}_LIBRARY_DIRS) - list (FILTER _${_PYTHON_PREFIX}_LINK_LIBRARIES EXCLUDE REGEX "-L${${_PYTHON_PREFIX}_DIR}") - endforeach() + _python_get_config_var (_${_PYTHON_PREFIX}_LINK_LIBRARIES LIBS) + if (_${_PYTHON_PREFIX}_LINK_LIBRARIES) set_property (TARGET ${__name} PROPERTY INTERFACE_LINK_LIBRARIES ${_${_PYTHON_PREFIX}_LINK_LIBRARIES}) endif() diff --git a/Modules/FindPython2.cmake b/Modules/FindPython2.cmake index 8372ce7..82878ea 100644 --- a/Modules/FindPython2.cmake +++ b/Modules/FindPython2.cmake @@ -193,6 +193,12 @@ Hints ``NEVER`` to select preferably the interpreter from the virtual environment. + .. note:: + + If the component ``Development`` is requested, it is **strongly** + recommended to also include the component ``Interpreter`` to get expected + result. + Commands ^^^^^^^^ diff --git a/Modules/FindPython3.cmake b/Modules/FindPython3.cmake index c8d9f24..417a789 100644 --- a/Modules/FindPython3.cmake +++ b/Modules/FindPython3.cmake @@ -234,6 +234,12 @@ Hints ``NEVER`` to select preferably the interpreter from the virtual environment. + .. note:: + + If the component ``Development`` is requested, it is **strongly** + recommended to also include the component ``Interpreter`` to get expected + result. + Commands ^^^^^^^^ https://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=18b0330b86cae2771a54021e390f157a097c8a99 commit 18b0330b86cae2771a54021e390f157a097c8a99 Author: Sebastian Holtermann AuthorDate: Sat Aug 3 13:20:31 2019 +0200 Commit: Sebastian Holtermann CommitDate: Mon Aug 5 17:21:00 2019 +0200 clang-tidy: Enable performance-inefficient-string-concatenation Enables the clang-tidy test performance-inefficient-string-concatenation and replaces all inefficient string concatenations with `cmStrCat`. Closes: #19555 diff --git a/.clang-tidy b/.clang-tidy index 57e571a..2b7c9ae 100644 --- a/.clang-tidy +++ b/.clang-tidy @@ -22,7 +22,6 @@ modernize-*,\ -modernize-use-transparent-functors,\ -modernize-use-using,\ performance-*,\ --performance-inefficient-string-concatenation,\ readability-*,\ -readability-function-size,\ -readability-identifier-naming,\ diff --git a/Source/CTest/cmCTestBuildHandler.cxx b/Source/CTest/cmCTestBuildHandler.cxx index 407e9f8..b98a4e3 100644 --- a/Source/CTest/cmCTestBuildHandler.cxx +++ b/Source/CTest/cmCTestBuildHandler.cxx @@ -385,11 +385,8 @@ int cmCTestBuildHandler::ProcessHandler() if (this->CTest->GetCTestConfiguration("SourceDirectory").size() > 20) { std::string srcdir = this->CTest->GetCTestConfiguration("SourceDirectory") + "/"; - std::string srcdirrep; for (cc = srcdir.size() - 2; cc > 0; cc--) { if (srcdir[cc] == '/') { - srcdirrep = srcdir.substr(cc); - srcdirrep = "/..." + srcdirrep; srcdir = srcdir.substr(0, cc + 1); break; } @@ -399,11 +396,8 @@ int cmCTestBuildHandler::ProcessHandler() if (this->CTest->GetCTestConfiguration("BuildDirectory").size() > 20) { std::string bindir = this->CTest->GetCTestConfiguration("BuildDirectory") + "/"; - std::string bindirrep; for (cc = bindir.size() - 2; cc > 0; cc--) { if (bindir[cc] == '/') { - bindirrep = bindir.substr(cc); - bindirrep = "/..." + bindirrep; bindir = bindir.substr(0, cc + 1); break; } diff --git a/Source/CTest/cmCTestLaunch.cxx b/Source/CTest/cmCTestLaunch.cxx index bbf490e..739cc58 100644 --- a/Source/CTest/cmCTestLaunch.cxx +++ b/Source/CTest/cmCTestLaunch.cxx @@ -494,9 +494,9 @@ void cmCTestLaunch::DumpFileToXML(cmXMLElement& e3, const char* tag, continue; } if (this->Match(line, this->RegexWarningSuppress)) { - line = "[CTest: warning suppressed] " + line; + line = cmStrCat("[CTest: warning suppressed] ", line); } else if (this->Match(line, this->RegexWarning)) { - line = "[CTest: warning matched] " + line; + line = cmStrCat("[CTest: warning matched] ", line); } e4.Content(sep); e4.Content(line); diff --git a/Source/CTest/cmCTestScriptHandler.cxx b/Source/CTest/cmCTestScriptHandler.cxx index f8d9f1b..4288b25 100644 --- a/Source/CTest/cmCTestScriptHandler.cxx +++ b/Source/CTest/cmCTestScriptHandler.cxx @@ -30,6 +30,7 @@ #include "cmState.h" #include "cmStateDirectory.h" #include "cmStateSnapshot.h" +#include "cmStringAlgorithms.h" #include "cmSystemTools.h" #include "cmake.h" @@ -663,8 +664,8 @@ int cmCTestScriptHandler::PerformExtraUpdates() fullCommand, &output, &output, &retVal, cvsArgs[0].c_str(), this->HandlerVerbose, cmDuration::zero() /*this->TimeOut*/); if (!res || retVal != 0) { - cmSystemTools::Error("Unable to perform extra updates:\n" + eu + - "\nWith output:\n" + output); + cmSystemTools::Error(cmStrCat("Unable to perform extra updates:\n", eu, + "\nWith output:\n", output)); return 0; } } @@ -934,7 +935,7 @@ bool cmCTestScriptHandler::TryToRemoveBinaryDirectoryOnce( continue; } - std::string fullPath = directoryPath + std::string("/") + path; + std::string fullPath = cmStrCat(directoryPath, "/", path); bool isDirectory = cmSystemTools::FileIsDirectory(fullPath) && !cmSystemTools::FileIsSymlink(fullPath); diff --git a/Source/CTest/cmCTestSubmitHandler.cxx b/Source/CTest/cmCTestSubmitHandler.cxx index 2c6ff83..17ef350 100644 --- a/Source/CTest/cmCTestSubmitHandler.cxx +++ b/Source/CTest/cmCTestSubmitHandler.cxx @@ -225,7 +225,7 @@ bool cmCTestSubmitHandler::SubmitUsingHTTP( std::string local_file = file; bool initialize_cdash_buildid = false; if (!cmSystemTools::FileExists(local_file)) { - local_file = localprefix + "/" + file; + local_file = cmStrCat(localprefix, "/", file); // If this file exists within the local Testing directory we assume // that it will be associated with the current build in CDash. initialize_cdash_buildid = true; @@ -237,9 +237,9 @@ bool cmCTestSubmitHandler::SubmitUsingHTTP( << remote_file << std::endl; std::string ofile = cmSystemTools::EncodeURL(remote_file); - std::string upload_as = url + - ((url.find('?') == std::string::npos) ? '?' : '&') + - "FileName=" + ofile; + std::string upload_as = + cmStrCat(url, ((url.find('?') == std::string::npos) ? '?' : '&'), + "FileName=", ofile); if (initialize_cdash_buildid) { // Provide extra arguments to CDash so that it can initialize and diff --git a/Source/CTest/cmParseCoberturaCoverage.cxx b/Source/CTest/cmParseCoberturaCoverage.cxx index 848a034..e0186c9 100644 --- a/Source/CTest/cmParseCoberturaCoverage.cxx +++ b/Source/CTest/cmParseCoberturaCoverage.cxx @@ -2,6 +2,7 @@ #include "cmCTest.h" #include "cmCTestCoverageHandler.h" +#include "cmStringAlgorithms.h" #include "cmSystemTools.h" #include "cmXMLParser.h" @@ -75,7 +76,7 @@ protected: // Check if this is a path that is relative to our source or // binary directories. for (std::string const& filePath : FilePaths) { - finalpath = filePath + "/" + filename; + finalpath = cmStrCat(filePath, "/", filename); if (cmSystemTools::FileExists(finalpath)) { this->CurFileName = finalpath; break; @@ -86,7 +87,7 @@ protected: cmsys::ifstream fin(this->CurFileName.c_str()); if (this->CurFileName.empty() || !fin) { this->CurFileName = - this->Coverage.BinaryDir + "/" + atts[tagCount + 1]; + cmStrCat(this->Coverage.BinaryDir, "/", atts[tagCount + 1]); fin.open(this->CurFileName.c_str()); if (!fin) { cmCTestOptionalLog(this->CTest, HANDLER_VERBOSE_OUTPUT, diff --git a/Source/cmBinUtilsLinuxELFLinker.cxx b/Source/cmBinUtilsLinuxELFLinker.cxx index 86846cb..6316a29 100644 --- a/Source/cmBinUtilsLinuxELFLinker.cxx +++ b/Source/cmBinUtilsLinuxELFLinker.cxx @@ -8,6 +8,7 @@ #include "cmMakefile.h" #include "cmMessageType.h" #include "cmRuntimeDependencyArchive.h" +#include "cmStringAlgorithms.h" #include "cmSystemTools.h" #include @@ -151,7 +152,7 @@ bool cmBinUtilsLinuxELFLinker::ResolveDependency( std::string& path, bool& resolved) { for (auto const& searchPath : searchPaths) { - path = searchPath + '/' + name; + path = cmStrCat(searchPath, '/', name); if (cmSystemTools::PathExists(path)) { resolved = true; return true; @@ -159,7 +160,7 @@ bool cmBinUtilsLinuxELFLinker::ResolveDependency( } for (auto const& searchPath : this->Archive->GetSearchDirectories()) { - path = searchPath + '/' + name; + path = cmStrCat(searchPath, '/', name); if (cmSystemTools::PathExists(path)) { std::ostringstream warning; warning << "Dependency " << name << " found in search directory:\n " diff --git a/Source/cmBinUtilsWindowsPELinker.cxx b/Source/cmBinUtilsWindowsPELinker.cxx index 31602c4..5a9ad66 100644 --- a/Source/cmBinUtilsWindowsPELinker.cxx +++ b/Source/cmBinUtilsWindowsPELinker.cxx @@ -6,6 +6,7 @@ #include "cmBinUtilsWindowsPEDumpbinGetRuntimeDependenciesTool.h" #include "cmBinUtilsWindowsPEObjdumpGetRuntimeDependenciesTool.h" #include "cmRuntimeDependencyArchive.h" +#include "cmStringAlgorithms.h" #include "cmSystemTools.h" #include @@ -110,7 +111,7 @@ bool cmBinUtilsWindowsPELinker::ResolveDependency(std::string const& name, dirs.insert(dirs.begin(), origin); for (auto const& searchPath : dirs) { - path = searchPath + '/' + name; + path = cmStrCat(searchPath, '/', name); if (cmSystemTools::PathExists(path)) { resolved = true; return true; diff --git a/Source/cmComputeLinkInformation.cxx b/Source/cmComputeLinkInformation.cxx index 5f46631..4aa18f2 100644 --- a/Source/cmComputeLinkInformation.cxx +++ b/Source/cmComputeLinkInformation.cxx @@ -1754,7 +1754,7 @@ void cmComputeLinkInformation::GetRPath(std::vector& runtimeDirs, cmSystemTools::IsSubDirectory(d, topBinaryDir)) { d = cmSystemTools::RelativePath(targetOutputDir, d); if (!d.empty()) { - d = originToken + "/" + d; + d = cmStrCat(originToken, "/", d); } else { d = originToken; } diff --git a/Source/cmCoreTryCompile.cxx b/Source/cmCoreTryCompile.cxx index d2a4148..edd8d46 100644 --- a/Source/cmCoreTryCompile.cxx +++ b/Source/cmCoreTryCompile.cxx @@ -514,7 +514,7 @@ int cmCoreTryCompile::TryCompileCode(std::vector const& argv, for (std::string const& li : testLangs) { projectLangs += " " + li; std::string rulesOverrideBase = "CMAKE_USER_MAKE_RULES_OVERRIDE"; - std::string rulesOverrideLang = rulesOverrideBase + "_" + li; + std::string rulesOverrideLang = cmStrCat(rulesOverrideBase, "_", li); if (const char* rulesOverridePath = this->Makefile->GetDefinition(rulesOverrideLang)) { fprintf(fout, "set(%s \"%s\")\n", rulesOverrideLang.c_str(), @@ -574,7 +574,8 @@ int cmCoreTryCompile::TryCompileCode(std::vector const& argv, std::string const cfg = !tcConfig.empty() ? cmSystemTools::UpperCase(tcConfig) : cfgDefault; for (std::string const& li : testLangs) { - std::string const langFlagsCfg = "CMAKE_" + li + "_FLAGS_" + cfg; + std::string const langFlagsCfg = + cmStrCat("CMAKE_", li, "_FLAGS_", cfg); const char* flagsCfg = this->Makefile->GetDefinition(langFlagsCfg); fprintf(fout, "set(%s %s)\n", langFlagsCfg.c_str(), cmOutputConverter::EscapeForCMake(flagsCfg ? flagsCfg : "") diff --git a/Source/cmExportInstallFileGenerator.cxx b/Source/cmExportInstallFileGenerator.cxx index ab4a62b..4bc2d1b 100644 --- a/Source/cmExportInstallFileGenerator.cxx +++ b/Source/cmExportInstallFileGenerator.cxx @@ -412,7 +412,7 @@ void cmExportInstallFileGenerator::SetImportLocationProperty( std::vector objects; itgen->GetInstallObjectNames(config, objects); for (std::string& obj : objects) { - obj = value + obj; + obj = cmStrCat(value, obj); } // Store the property. diff --git a/Source/cmExtraCodeBlocksGenerator.cxx b/Source/cmExtraCodeBlocksGenerator.cxx index f47744b..4146db8 100644 --- a/Source/cmExtraCodeBlocksGenerator.cxx +++ b/Source/cmExtraCodeBlocksGenerator.cxx @@ -16,6 +16,7 @@ #include "cmRange.h" #include "cmSourceFile.h" #include "cmStateTypes.h" +#include "cmStringAlgorithms.h" #include "cmSystemTools.h" #include "cmXMLWriter.h" #include "cmake.h" @@ -178,18 +179,18 @@ void Tree::BuildUnitImpl(cmXMLWriter& xml, { for (std::string const& f : files) { xml.StartElement("Unit"); - xml.Attribute("filename", fsPath + path + "/" + f); + xml.Attribute("filename", cmStrCat(fsPath, path, "/", f)); xml.StartElement("Option"); xml.Attribute("virtualFolder", - "CMake Files\\" + virtualFolderPath + path + "\\"); + cmStrCat("CMake Files\\", virtualFolderPath, path, "\\")); xml.EndElement(); xml.EndElement(); } for (Tree const& folder : folders) { - folder.BuildUnitImpl(xml, virtualFolderPath + path + "\\", - fsPath + path + "/"); + folder.BuildUnitImpl(xml, cmStrCat(virtualFolderPath, path, "\\"), + cmStrCat(fsPath, path, "/")); } } diff --git a/Source/cmExtraCodeLiteGenerator.cxx b/Source/cmExtraCodeLiteGenerator.cxx index 30b3f0d..70e9a36 100644 --- a/Source/cmExtraCodeLiteGenerator.cxx +++ b/Source/cmExtraCodeLiteGenerator.cxx @@ -9,6 +9,7 @@ #include "cmMakefile.h" #include "cmSourceFile.h" #include "cmStateTypes.h" +#include "cmStringAlgorithms.h" #include "cmSystemTools.h" #include "cmXMLWriter.h" #include "cmake.h" @@ -121,7 +122,7 @@ std::vector cmExtraCodeLiteGenerator::CreateProjectsByTarget( cmStateEnums::TargetType type = lt->GetType(); std::string const& outputDir = lg->GetCurrentBinaryDirectory(); std::string targetName = lt->GetName(); - std::string filename = outputDir + "/" + targetName + ".project"; + std::string filename = cmStrCat(outputDir, "/", targetName, ".project"); retval.push_back(targetName); // Make the project file relative to the workspace std::string relafilename = @@ -131,7 +132,7 @@ std::vector cmExtraCodeLiteGenerator::CreateProjectsByTarget( case cmStateEnums::SHARED_LIBRARY: case cmStateEnums::STATIC_LIBRARY: case cmStateEnums::MODULE_LIBRARY: - visualname = "lib" + visualname; + visualname = cmStrCat("lib", visualname); CM_FALLTHROUGH; case cmStateEnums::EXECUTABLE: xml->StartElement("Project"); @@ -161,7 +162,7 @@ std::vector cmExtraCodeLiteGenerator::CreateProjectsByProjectMaps( std::string const& outputDir = it.second[0]->GetCurrentBinaryDirectory(); std::string projectName = it.second[0]->GetProjectName(); retval.push_back(projectName); - std::string filename = outputDir + "/" + projectName + ".project"; + std::string filename = cmStrCat(outputDir, "/", projectName, ".project"); // Make the project file relative to the workspace filename = cmSystemTools::RelativePath(this->WorkspacePath, filename); diff --git a/Source/cmExtraSublimeTextGenerator.cxx b/Source/cmExtraSublimeTextGenerator.cxx index 71c8fcd..67773e0 100644 --- a/Source/cmExtraSublimeTextGenerator.cxx +++ b/Source/cmExtraSublimeTextGenerator.cxx @@ -17,6 +17,7 @@ #include "cmMessageType.h" #include "cmSourceFile.h" #include "cmStateTypes.h" +#include "cmStringAlgorithms.h" #include "cmSystemTools.h" #include "cmake.h" @@ -266,7 +267,7 @@ void cmExtraSublimeTextGenerator::AppendTarget( R"((^|[ ])-[DIOUWfgs][^= ]+(=\"[^"]+\"|=[^"][^ ]+)?)"; flagRegex.compile(regexString); std::string workString = - flagsString + " " + definesString + " " + includesString; + cmStrCat(flagsString, " ", definesString, " ", includesString); while (flagRegex.find(workString)) { std::string::size_type start = flagRegex.start(); if (workString[start] == ' ') { diff --git a/Source/cmFLTKWrapUICommand.cxx b/Source/cmFLTKWrapUICommand.cxx index b7a2b27..ccd6be9 100644 --- a/Source/cmFLTKWrapUICommand.cxx +++ b/Source/cmFLTKWrapUICommand.cxx @@ -8,6 +8,7 @@ #include "cmMakefile.h" #include "cmRange.h" #include "cmSourceFile.h" +#include "cmStringAlgorithms.h" #include "cmSystemTools.h" class cmExecutionStatus; @@ -66,18 +67,15 @@ bool cmFLTKWrapUICommand::InitialPass(std::vector const& args, // if we should use the source GUI // to generate .cxx and .h files if (!curr || !curr->GetPropertyAsBool("WRAP_EXCLUDE")) { - std::string outName = outputDirectory; - outName += "/"; - outName += cmSystemTools::GetFilenameWithoutExtension(arg); - std::string hname = outName; - hname += ".h"; - std::string origname = cdir + "/" + arg; + std::string outName = cmStrCat( + outputDirectory, "/", cmSystemTools::GetFilenameWithoutExtension(arg)); + std::string hname = cmStrCat(outName, ".h"); + std::string origname = cmStrCat(cdir, "/", arg); // add starting depends std::vector depends; depends.push_back(origname); depends.push_back(fluid_exe); - std::string cxxres = outName; - cxxres += ".cxx"; + std::string cxxres = cmStrCat(outName, ".cxx"); cmCustomCommandLine commandLine; commandLine.push_back(fluid_exe); diff --git a/Source/cmFileAPI.cxx b/Source/cmFileAPI.cxx index 2594287..aee42d7 100644 --- a/Source/cmFileAPI.cxx +++ b/Source/cmFileAPI.cxx @@ -94,7 +94,7 @@ void cmFileAPI::RemoveOldReplyFiles() std::vector files = this->LoadDir(reply_dir); for (std::string const& f : files) { if (this->ReplyFiles.find(f) == this->ReplyFiles.end()) { - std::string file = reply_dir + "/" + f; + std::string file = cmStrCat(reply_dir, "/", f); cmSystemTools::RemoveFile(file); } } diff --git a/Source/cmFileCopier.cxx b/Source/cmFileCopier.cxx index 4f1a158..71493bb 100644 --- a/Source/cmFileCopier.cxx +++ b/Source/cmFileCopier.cxx @@ -7,6 +7,7 @@ #include "cmFileCommand.h" #include "cmFileTimes.h" #include "cmMakefile.h" +#include "cmStringAlgorithms.h" #include "cmSystemTools.h" #include "cmsys/Directory.hxx" #include "cmsys/Glob.hxx" @@ -490,7 +491,7 @@ bool cmFileCopier::InstallSymlinkChain(std::string& fromFile, while (cmSystemTools::ReadSymlink(fromFile, newFromFile)) { if (!cmSystemTools::FileIsFullPath(newFromFile)) { std::string fromFilePath = cmSystemTools::GetFilenamePath(fromFile); - newFromFile = fromFilePath + "/" + newFromFile; + newFromFile = cmStrCat(fromFilePath, "/", newFromFile); } std::string symlinkTarget = cmSystemTools::GetFilenameName(newFromFile); @@ -520,7 +521,7 @@ bool cmFileCopier::InstallSymlinkChain(std::string& fromFile, } fromFile = newFromFile; - toFile = toFilePath + "/" + symlinkTarget; + toFile = cmStrCat(toFilePath, "/", symlinkTarget); } return true; diff --git a/Source/cmGeneratorExpressionNode.cxx b/Source/cmGeneratorExpressionNode.cxx index 14dc7b8..f78c72e 100644 --- a/Source/cmGeneratorExpressionNode.cxx +++ b/Source/cmGeneratorExpressionNode.cxx @@ -1441,7 +1441,7 @@ static const struct TargetObjectsNode : public cmGeneratorExpressionNode } for (std::string& o : objects) { - o = obj_dir + o; + o = cmStrCat(obj_dir, o); } } diff --git a/Source/cmGhsMultiTargetGenerator.cxx b/Source/cmGhsMultiTargetGenerator.cxx index 997595b..00ebbb5 100644 --- a/Source/cmGhsMultiTargetGenerator.cxx +++ b/Source/cmGhsMultiTargetGenerator.cxx @@ -18,6 +18,7 @@ #include "cmStateDirectory.h" #include "cmStateSnapshot.h" #include "cmStateTypes.h" +#include "cmStringAlgorithms.h" #include "cmSystemTools.h" #include "cmTarget.h" @@ -442,12 +443,12 @@ void cmGhsMultiTargetGenerator::WriteCustomCommandsHelper( // This command was specified as a path to a file in the // current directory. Add a leading "./" so it can run // without the current directory being in the search path. - cmd = "./" + cmd; + cmd = cmStrCat("./", cmd); } cmd = this->LocalGenerator->ConvertToOutputFormat( cmd, cmOutputConverter::SHELL); if (useCall) { - cmd = "call " + cmd; + cmd = cmStrCat("call ", cmd); } ccg.AppendArguments(c, cmd); cmdLines.push_back(std::move(cmd)); diff --git a/Source/cmGlobalGhsMultiGenerator.cxx b/Source/cmGlobalGhsMultiGenerator.cxx index 7cfbea6..9f3dab7 100644 --- a/Source/cmGlobalGhsMultiGenerator.cxx +++ b/Source/cmGlobalGhsMultiGenerator.cxx @@ -11,6 +11,7 @@ #include "cmMakefile.h" #include "cmState.h" #include "cmStateTypes.h" +#include "cmStringAlgorithms.h" #include "cmSystemTools.h" #include "cmVersion.h" #include "cmake.h" @@ -418,17 +419,17 @@ void cmGlobalGhsMultiGenerator::WriteTargets(cmLocalGenerator* root) } // create target build file - std::string name = target->GetName() + ".tgt" + FILE_EXTENSION; - std::string fname = rootBinaryDir + "/" + name; + std::string name = cmStrCat(target->GetName(), ".tgt", FILE_EXTENSION); + std::string fname = cmStrCat(rootBinaryDir, "/", name); cmGeneratedFileStream fbld(fname); fbld.SetCopyIfDifferent(true); this->WriteFileHeader(fbld); GhsMultiGpj::WriteGpjTag(GhsMultiGpj::PROJECT, fbld); std::vector build; if (ComputeTargetBuildOrder(target, build)) { - std::string message = "The inter-target dependency graph for target [" + - target->GetName() + "] had a cycle.\n"; - cmSystemTools::Error(message); + cmSystemTools::Error( + cmStrCat("The inter-target dependency graph for target [", + target->GetName(), "] had a cycle.\n")); } else { for (auto& tgt : build) { WriteProjectLine(fbld, tgt, root, rootBinaryDir); diff --git a/Source/cmGlobalNinjaGenerator.cxx b/Source/cmGlobalNinjaGenerator.cxx index 0b68966..c3c44be 100644 --- a/Source/cmGlobalNinjaGenerator.cxx +++ b/Source/cmGlobalNinjaGenerator.cxx @@ -1731,8 +1731,9 @@ int cmcmd_cmake_ninja_depends(std::vector::const_iterator argBeg, if (arg_lang == "Fortran") { info = cmcmd_cmake_ninja_depends_fortran(arg_tdi, arg_pp); } else { - cmSystemTools::Error("-E cmake_ninja_depends does not understand the " + - arg_lang + " language"); + cmSystemTools::Error( + cmStrCat("-E cmake_ninja_depends does not understand the ", arg_lang, + " language")); return 1; } @@ -1786,8 +1787,9 @@ std::unique_ptr cmcmd_cmake_ninja_depends_fortran( cmsys::ifstream tdif(arg_tdi.c_str(), std::ios::in | std::ios::binary); Json::Reader reader; if (!reader.parse(tdif, tdio, false)) { - cmSystemTools::Error("-E cmake_ninja_depends failed to parse " + - arg_tdi + reader.getFormattedErrorMessages()); + cmSystemTools::Error( + cmStrCat("-E cmake_ninja_depends failed to parse ", arg_tdi, + reader.getFormattedErrorMessages())); return nullptr; } } @@ -1866,8 +1868,9 @@ bool cmGlobalNinjaGenerator::WriteDyndepFile( cmsys::ifstream ddif(arg_ddi.c_str(), std::ios::in | std::ios::binary); Json::Reader reader; if (!reader.parse(ddif, ddio, false)) { - cmSystemTools::Error("-E cmake_ninja_dyndep failed to parse " + arg_ddi + - reader.getFormattedErrorMessages()); + cmSystemTools::Error(cmStrCat("-E cmake_ninja_dyndep failed to parse ", + arg_ddi, + reader.getFormattedErrorMessages())); return false; } @@ -1894,14 +1897,14 @@ bool cmGlobalNinjaGenerator::WriteDyndepFile( // Populate the module map with those provided by linked targets first. for (std::string const& linked_target_dir : linked_target_dirs) { std::string const ltmn = - linked_target_dir + "/" + arg_lang + "Modules.json"; + cmStrCat(linked_target_dir, "/", arg_lang, "Modules.json"); Json::Value ltm; cmsys::ifstream ltmf(ltmn.c_str(), std::ios::in | std::ios::binary); Json::Reader reader; if (ltmf && !reader.parse(ltmf, ltm, false)) { - cmSystemTools::Error("-E cmake_ninja_dyndep failed to parse " + - linked_target_dir + - reader.getFormattedErrorMessages()); + cmSystemTools::Error(cmStrCat("-E cmake_ninja_dyndep failed to parse ", + linked_target_dir, + reader.getFormattedErrorMessages())); return false; } if (ltm.isObject()) { @@ -2005,8 +2008,9 @@ int cmcmd_cmake_ninja_dyndep(std::vector::const_iterator argBeg, cmsys::ifstream tdif(arg_tdi.c_str(), std::ios::in | std::ios::binary); Json::Reader reader; if (!reader.parse(tdif, tdio, false)) { - cmSystemTools::Error("-E cmake_ninja_dyndep failed to parse " + arg_tdi + - reader.getFormattedErrorMessages()); + cmSystemTools::Error(cmStrCat("-E cmake_ninja_dyndep failed to parse ", + arg_tdi, + reader.getFormattedErrorMessages())); return 1; } } diff --git a/Source/cmGlobalXCodeGenerator.cxx b/Source/cmGlobalXCodeGenerator.cxx index 8f4ae62..c46856a 100644 --- a/Source/cmGlobalXCodeGenerator.cxx +++ b/Source/cmGlobalXCodeGenerator.cxx @@ -2993,7 +2993,7 @@ cmXCodeObject* cmGlobalXCodeGenerator::CreateOrGetPBXGroup( } else { tgroup = i_folder->second; } - curr_folder = curr_folder + "\\"; + curr_folder += "\\"; } return tgroup; } diff --git a/Source/cmInstallDirectoryGenerator.cxx b/Source/cmInstallDirectoryGenerator.cxx index c8ebc8c..9357a5c 100644 --- a/Source/cmInstallDirectoryGenerator.cxx +++ b/Source/cmInstallDirectoryGenerator.cxx @@ -6,6 +6,7 @@ #include "cmInstallType.h" #include "cmLocalGenerator.h" #include "cmMakefile.h" +#include "cmStringAlgorithms.h" #include "cmSystemTools.h" #include @@ -74,7 +75,7 @@ void cmInstallDirectoryGenerator::GenerateScriptForConfig( cmMakefile const& mf = *this->LocalGenerator->GetMakefile(); for (std::string& d : dirs) { if (!cmSystemTools::FileIsFullPath(d)) { - d = mf.GetCurrentSourceDirectory() + "/" + d; + d = cmStrCat(mf.GetCurrentSourceDirectory(), "/", d); } } diff --git a/Source/cmInstallTargetGenerator.cxx b/Source/cmInstallTargetGenerator.cxx index a61239e..4e0be5e 100644 --- a/Source/cmInstallTargetGenerator.cxx +++ b/Source/cmInstallTargetGenerator.cxx @@ -20,6 +20,7 @@ #include "cmOutputConverter.h" #include "cmPolicies.h" #include "cmStateTypes.h" +#include "cmStringAlgorithms.h" #include "cmSystemTools.h" #include "cmTarget.h" #include "cmake.h" @@ -369,7 +370,7 @@ void cmInstallTargetGenerator::GetInstallObjectNames( { this->Target->GetTargetObjectNames(config, objects); for (std::string& o : objects) { - o = computeInstallObjectDir(this->Target, config) + "/" + o; + o = cmStrCat(computeInstallObjectDir(this->Target, config), "/", o); } } diff --git a/Source/cmJsonObjects.cxx b/Source/cmJsonObjects.cxx index 2423faf..dc5f477 100644 --- a/Source/cmJsonObjects.cxx +++ b/Source/cmJsonObjects.cxx @@ -20,6 +20,7 @@ #include "cmStateDirectory.h" #include "cmStateSnapshot.h" #include "cmStateTypes.h" +#include "cmStringAlgorithms.h" #include "cmSystemTools.h" #include "cmTarget.h" #include "cmTest.h" @@ -500,9 +501,9 @@ static Json::Value DumpTarget(cmGeneratorTarget* target, if (!dest.empty() && cmSystemTools::FileIsFullPath(dest)) { installPath = dest; } else { - std::string installPrefix = - target->Makefile->GetSafeDefinition("CMAKE_INSTALL_PREFIX"); - installPath = installPrefix + '/' + dest; + installPath = cmStrCat( + target->Makefile->GetSafeDefinition("CMAKE_INSTALL_PREFIX"), '/', + dest); } installPaths.append(installPath); diff --git a/Source/cmLinkLineComputer.cxx b/Source/cmLinkLineComputer.cxx index 4430f97..5e3c790 100644 --- a/Source/cmLinkLineComputer.cxx +++ b/Source/cmLinkLineComputer.cxx @@ -11,6 +11,7 @@ #include "cmOutputConverter.h" #include "cmStateDirectory.h" #include "cmStateTypes.h" +#include "cmStringAlgorithms.h" #include "cmSystemTools.h" cmLinkLineComputer::cmLinkLineComputer(cmOutputConverter* outputConverter, @@ -115,16 +116,17 @@ std::string cmLinkLineComputer::ComputeLinkPath( type = cmStateEnums::ImportLibraryArtifact; } - linkPath += " " + libPathFlag + - item.Target->GetDirectory(cli.GetConfig(), type) + - libPathTerminator + " "; + linkPath += cmStrCat(" ", libPathFlag, + item.Target->GetDirectory(cli.GetConfig(), type), + libPathTerminator, " "); } } } for (std::string const& libDir : cli.GetDirectories()) { - linkPath += " " + libPathFlag + this->ConvertToOutputForExisting(libDir) + - libPathTerminator + " "; + linkPath += + cmStrCat(" ", libPathFlag, this->ConvertToOutputForExisting(libDir), + libPathTerminator, " "); } return linkPath; diff --git a/Source/cmListCommand.cxx b/Source/cmListCommand.cxx index 8c14596..29c17fa 100644 --- a/Source/cmListCommand.cxx +++ b/Source/cmListCommand.cxx @@ -1189,8 +1189,8 @@ bool cmListCommand::HandleSortCommand(std::vector const& args) const std::string option = args[argumentIndex++]; if (option == "COMPARE") { if (sortCompare != cmStringSorter::Compare::UNINITIALIZED) { - std::string error = messageHint + "option \"" + option + - "\" has been specified multiple times."; + std::string error = cmStrCat(messageHint, "option \"", option, + "\" has been specified multiple times."); this->SetError(error); return false; } @@ -1201,23 +1201,22 @@ bool cmListCommand::HandleSortCommand(std::vector const& args) } else if (argument == "FILE_BASENAME") { sortCompare = cmStringSorter::Compare::FILE_BASENAME; } else { - std::string error = messageHint + "value \"" + argument + - "\" for option \"" + option + "\" is invalid."; + std::string error = + cmStrCat(messageHint, "value \"", argument, "\" for option \"", + option, "\" is invalid."); this->SetError(error); return false; } } else { - std::string error = - messageHint + "missing argument for option \"" + option + "\"."; - this->SetError(error); + this->SetError(cmStrCat(messageHint, "missing argument for option \"", + option, "\".")); return false; } } else if (option == "CASE") { if (sortCaseSensitivity != cmStringSorter::CaseSensitivity::UNINITIALIZED) { - std::string error = messageHint + "option \"" + option + - "\" has been specified multiple times."; - this->SetError(error); + this->SetError(cmStrCat(messageHint, "option \"", option, + "\" has been specified multiple times.")); return false; } if (argumentIndex < args.size()) { @@ -1227,23 +1226,21 @@ bool cmListCommand::HandleSortCommand(std::vector const& args) } else if (argument == "INSENSITIVE") { sortCaseSensitivity = cmStringSorter::CaseSensitivity::INSENSITIVE; } else { - std::string error = messageHint + "value \"" + argument + - "\" for option \"" + option + "\" is invalid."; - this->SetError(error); + this->SetError(cmStrCat(messageHint, "value \"", argument, + "\" for option \"", option, + "\" is invalid.")); return false; } } else { - std::string error = - messageHint + "missing argument for option \"" + option + "\"."; - this->SetError(error); + this->SetError(cmStrCat(messageHint, "missing argument for option \"", + option, "\".")); return false; } } else if (option == "ORDER") { if (sortOrder != cmStringSorter::Order::UNINITIALIZED) { - std::string error = messageHint + "option \"" + option + - "\" has been specified multiple times."; - this->SetError(error); + this->SetError(cmStrCat(messageHint, "option \"", option, + "\" has been specified multiple times.")); return false; } if (argumentIndex < args.size()) { @@ -1253,21 +1250,19 @@ bool cmListCommand::HandleSortCommand(std::vector const& args) } else if (argument == "DESCENDING") { sortOrder = cmStringSorter::Order::DESCENDING; } else { - std::string error = messageHint + "value \"" + argument + - "\" for option \"" + option + "\" is invalid."; - this->SetError(error); + this->SetError(cmStrCat(messageHint, "value \"", argument, + "\" for option \"", option, + "\" is invalid.")); return false; } } else { - std::string error = - messageHint + "missing argument for option \"" + option + "\"."; - this->SetError(error); + this->SetError(cmStrCat(messageHint, "missing argument for option \"", + option, "\".")); return false; } } else { - std::string error = - messageHint + "option \"" + option + "\" is unknown."; - this->SetError(error); + this->SetError( + cmStrCat(messageHint, "option \"", option, "\" is unknown.")); return false; } } diff --git a/Source/cmLocalGenerator.cxx b/Source/cmLocalGenerator.cxx index 28ae82e..3deaeb0 100644 --- a/Source/cmLocalGenerator.cxx +++ b/Source/cmLocalGenerator.cxx @@ -1912,7 +1912,7 @@ void cmLocalGenerator::AddCompilerRequirementFlag( // for which a flag is defined. for (; stdIt < defaultStdIt; ++stdIt) { std::string option_flag = - "CMAKE_" + lang + *stdIt + "_" + type + "_COMPILE_OPTION"; + cmStrCat("CMAKE_", lang, *stdIt, "_", type, "_COMPILE_OPTION"); if (const char* opt = target->Target->GetMakefile()->GetDefinition(option_flag)) { diff --git a/Source/cmLocalUnixMakefileGenerator3.cxx b/Source/cmLocalUnixMakefileGenerator3.cxx index 713c985..c6b63ba 100644 --- a/Source/cmLocalUnixMakefileGenerator3.cxx +++ b/Source/cmLocalUnixMakefileGenerator3.cxx @@ -963,7 +963,7 @@ void cmLocalUnixMakefileGenerator3::AppendCustomCommand( // This command was specified as a path to a file in the // current directory. Add a leading "./" so it can run // without the current directory being in the search path. - cmd = "./" + cmd; + cmd = cmStrCat("./", cmd); } std::string launcher; @@ -1017,18 +1017,16 @@ void cmLocalUnixMakefileGenerator3::AppendCustomCommand( std::string::size_type rcurly = cmd.find('}'); if (rcurly == std::string::npos || rcurly > lcurly) { // The first curly is a left curly. Use the hack. - std::string hack_cmd = cmd.substr(0, lcurly); - hack_cmd += "{{}"; - hack_cmd += cmd.substr(lcurly + 1); - cmd = hack_cmd; + cmd = + cmStrCat(cmd.substr(0, lcurly), "{{}", cmd.substr(lcurly + 1)); } } } if (launcher.empty()) { if (useCall) { - cmd = "call " + cmd; + cmd = cmStrCat("call ", cmd); } else if (this->IsNMake() && cmd[0] == '"') { - cmd = "echo >nul && " + cmd; + cmd = cmStrCat("echo >nul && ", cmd); } } commands1.push_back(std::move(cmd)); diff --git a/Source/cmMakefileExecutableTargetGenerator.cxx b/Source/cmMakefileExecutableTargetGenerator.cxx index a7f2a97..19c667e 100644 --- a/Source/cmMakefileExecutableTargetGenerator.cxx +++ b/Source/cmMakefileExecutableTargetGenerator.cxx @@ -26,6 +26,7 @@ #include "cmStateDirectory.h" #include "cmStateSnapshot.h" #include "cmStateTypes.h" +#include "cmStringAlgorithms.h" #include "cmSystemTools.h" cmMakefileExecutableTargetGenerator::cmMakefileExecutableTargetGenerator( @@ -243,7 +244,7 @@ void cmMakefileExecutableTargetGenerator::WriteDeviceExecutableRule( // Expand placeholders in the commands. rulePlaceholderExpander->SetTargetImpLib(targetOutputReal); for (std::string& real_link_command : real_link_commands) { - real_link_command = launcher + real_link_command; + real_link_command = cmStrCat(launcher, real_link_command); rulePlaceholderExpander->ExpandRuleVariables(this->LocalGenerator, real_link_command, vars); } @@ -612,7 +613,7 @@ void cmMakefileExecutableTargetGenerator::WriteExecutableRule(bool relink) // Expand placeholders in the commands. rulePlaceholderExpander->SetTargetImpLib(targetOutPathImport); for (std::string& real_link_command : real_link_commands) { - real_link_command = launcher + real_link_command; + real_link_command = cmStrCat(launcher, real_link_command); rulePlaceholderExpander->ExpandRuleVariables(this->LocalGenerator, real_link_command, vars); } diff --git a/Source/cmMakefileLibraryTargetGenerator.cxx b/Source/cmMakefileLibraryTargetGenerator.cxx index bdde4b8..8d342f3 100644 --- a/Source/cmMakefileLibraryTargetGenerator.cxx +++ b/Source/cmMakefileLibraryTargetGenerator.cxx @@ -26,6 +26,7 @@ #include "cmStateDirectory.h" #include "cmStateSnapshot.h" #include "cmStateTypes.h" +#include "cmStringAlgorithms.h" #include "cmSystemTools.h" cmMakefileLibraryTargetGenerator::cmMakefileLibraryTargetGenerator( @@ -373,7 +374,7 @@ void cmMakefileLibraryTargetGenerator::WriteDeviceLibraryRules( // Expand placeholders. for (std::string& real_link_command : real_link_commands) { - real_link_command = launcher + real_link_command; + real_link_command = cmStrCat(launcher, real_link_command); rulePlaceholderExpander->ExpandRuleVariables(this->LocalGenerator, real_link_command, vars); } @@ -891,7 +892,7 @@ void cmMakefileLibraryTargetGenerator::WriteLibraryRules( // Expand placeholders. for (std::string& real_link_command : real_link_commands) { - real_link_command = launcher + real_link_command; + real_link_command = cmStrCat(launcher, real_link_command); rulePlaceholderExpander->ExpandRuleVariables(this->LocalGenerator, real_link_command, vars); } diff --git a/Source/cmMakefileTargetGenerator.cxx b/Source/cmMakefileTargetGenerator.cxx index 008248c..7b26324 100644 --- a/Source/cmMakefileTargetGenerator.cxx +++ b/Source/cmMakefileTargetGenerator.cxx @@ -806,7 +806,7 @@ void cmMakefileTargetGenerator::WriteObjectBuildFile( // Expand placeholders in the commands. for (std::string& compileCommand : compileCommands) { - compileCommand = launcher + compileCommand; + compileCommand = cmStrCat(launcher, compileCommand); rulePlaceholderExpander->ExpandRuleVariables(this->LocalGenerator, compileCommand, vars); } diff --git a/Source/cmNinjaNormalTargetGenerator.cxx b/Source/cmNinjaNormalTargetGenerator.cxx index cd84c03..865ae7d 100644 --- a/Source/cmNinjaNormalTargetGenerator.cxx +++ b/Source/cmNinjaNormalTargetGenerator.cxx @@ -228,7 +228,7 @@ void cmNinjaNormalTargetGenerator::WriteDeviceLinkRule(bool useResponseFile) // Rule for linking library/executable. std::vector linkCmds = this->ComputeDeviceLinkCmd(); for (std::string& linkCmd : linkCmds) { - linkCmd = launcher + linkCmd; + linkCmd = cmStrCat(launcher, linkCmd); rulePlaceholderExpander->ExpandRuleVariables(this->GetLocalGenerator(), linkCmd, vars); } @@ -367,7 +367,7 @@ void cmNinjaNormalTargetGenerator::WriteLinkRule(bool useResponseFile) // Rule for linking library/executable. std::vector linkCmds = this->ComputeLinkCmd(); for (std::string& linkCmd : linkCmds) { - linkCmd = launcher + linkCmd; + linkCmd = cmStrCat(launcher, linkCmd); rulePlaceholderExpander->ExpandRuleVariables(this->GetLocalGenerator(), linkCmd, vars); } diff --git a/Source/cmNinjaTargetGenerator.cxx b/Source/cmNinjaTargetGenerator.cxx index 8b0a6ba..c3459be 100644 --- a/Source/cmNinjaTargetGenerator.cxx +++ b/Source/cmNinjaTargetGenerator.cxx @@ -553,7 +553,7 @@ void cmNinjaTargetGenerator::WriteCompileRule(const std::string& lang) } for (std::string& i : ppCmds) { - i = launcher + i; + i = cmStrCat(launcher, i); rulePlaceholderExpander->ExpandRuleVariables(this->GetLocalGenerator(), i, ppVars); } @@ -770,7 +770,7 @@ void cmNinjaTargetGenerator::WriteCompileRule(const std::string& lang) } for (std::string& i : compileCmds) { - i = launcher + i; + i = cmStrCat(launcher, i); rulePlaceholderExpander->ExpandRuleVariables(this->GetLocalGenerator(), i, vars); } diff --git a/Source/cmOutputRequiredFilesCommand.cxx b/Source/cmOutputRequiredFilesCommand.cxx index a66af5a..587e21c 100644 --- a/Source/cmOutputRequiredFilesCommand.cxx +++ b/Source/cmOutputRequiredFilesCommand.cxx @@ -215,10 +215,8 @@ protected: if (cmSystemTools::FileExists(cxxFile)) { found = true; } - for (std::string path : this->IncludeDirectories) { - path = path + "/"; - path = path + cxxFile; - if (cmSystemTools::FileExists(path)) { + for (std::string const& path : this->IncludeDirectories) { + if (cmSystemTools::FileExists(cmStrCat(path, "/", cxxFile))) { found = true; } } @@ -227,10 +225,8 @@ protected: if (cmSystemTools::FileExists(cxxFile)) { found = true; } - for (std::string path : this->IncludeDirectories) { - path = path + "/"; - path = path + cxxFile; - if (cmSystemTools::FileExists(path)) { + for (std::string const& path : this->IncludeDirectories) { + if (cmSystemTools::FileExists(cmStrCat(path, "/", cxxFile))) { found = true; } } @@ -240,10 +236,8 @@ protected: if (cmSystemTools::FileExists(cxxFile)) { found = true; } - for (std::string path : this->IncludeDirectories) { - path = path + "/"; - path = path + cxxFile; - if (cmSystemTools::FileExists(path)) { + for (std::string const& path : this->IncludeDirectories) { + if (cmSystemTools::FileExists(cmStrCat(path, "/", cxxFile))) { found = true; } } @@ -253,10 +247,8 @@ protected: if (cmSystemTools::FileExists(cxxFile)) { found = true; } - for (std::string path : this->IncludeDirectories) { - path = path + "/"; - path = path + cxxFile; - if (cmSystemTools::FileExists(path)) { + for (std::string const& path : this->IncludeDirectories) { + if (cmSystemTools::FileExists(cmStrCat(path, "/", cxxFile))) { found = true; } } @@ -340,9 +332,9 @@ protected: // try to guess which include path to use for (std::string incpath : this->IncludeDirectories) { if (!incpath.empty() && incpath.back() != '/') { - incpath = incpath + "/"; + incpath += "/"; } - incpath = incpath + path; + incpath += path; if (srcFile->GetFullPath() == incpath) { // set the path to the guessed path info->FullPath = incpath; @@ -421,9 +413,9 @@ protected: for (std::string path : this->IncludeDirectories) { if (!path.empty() && path.back() != '/') { - path = path + "/"; + path += "/"; } - path = path + fname; + path += fname; if (cmSystemTools::FileExists(path, true) && !cmSystemTools::FileIsDirectory(path)) { std::string fp = cmSystemTools::CollapseFullPath(path); @@ -486,9 +478,7 @@ bool cmOutputRequiredFilesCommand::InitialPass( // write them out FILE* fout = cmsys::SystemTools::Fopen(this->OutputFile, "w"); if (!fout) { - std::string err = "Can not open output file: "; - err += this->OutputFile; - this->SetError(err); + this->SetError(cmStrCat("Can not open output file: ", this->OutputFile)); return false; } std::set visited; diff --git a/Source/cmRST.cxx b/Source/cmRST.cxx index a329f7d..1f9aae8 100644 --- a/Source/cmRST.cxx +++ b/Source/cmRST.cxx @@ -342,7 +342,7 @@ void cmRST::OutputMarkupLines(bool inlineMarkup) { for (auto line : this->MarkupLines) { if (!line.empty()) { - line = " " + line; + line = cmStrCat(" ", line); } this->OutputLine(line, inlineMarkup); } diff --git a/Source/cmSourceGroupCommand.cxx b/Source/cmSourceGroupCommand.cxx index ffdd0ce..bb9aace 100644 --- a/Source/cmSourceGroupCommand.cxx +++ b/Source/cmSourceGroupCommand.cxx @@ -56,7 +56,7 @@ bool rootIsPrefix(const std::string& root, { for (std::string const& file : files) { if (!cmHasPrefix(file, root)) { - error = "ROOT: " + root + " is not a prefix of file: " + file; + error = cmStrCat("ROOT: ", root, " is not a prefix of file: ", file); return false; } } @@ -94,7 +94,7 @@ bool addFilesToItsSourceGroups(const std::string& root, std::vector tokenizedPath; if (!prefix.empty()) { - tokenizedPath = tokenizePath(prefix + '/' + sgFilesPath); + tokenizedPath = tokenizePath(cmStrCat(prefix, '/', sgFilesPath)); } else { tokenizedPath = tokenizePath(sgFilesPath); } diff --git a/Source/cmSystemTools.cxx b/Source/cmSystemTools.cxx index 5f4e1fc..6aeba54 100644 --- a/Source/cmSystemTools.cxx +++ b/Source/cmSystemTools.cxx @@ -835,7 +835,7 @@ std::string cmSystemTools::FileExistsInParentDirectories( cmSystemTools::ConvertToUnixSlashes(dir); std::string prevDir; while (dir != prevDir) { - std::string path = dir + "/" + file; + std::string path = cmStrCat(dir, "/", file); if (cmSystemTools::FileExists(path)) { return path; } diff --git a/Source/cmTargetIncludeDirectoriesCommand.cxx b/Source/cmTargetIncludeDirectoriesCommand.cxx index d6918c0..d099349 100644 --- a/Source/cmTargetIncludeDirectoriesCommand.cxx +++ b/Source/cmTargetIncludeDirectoriesCommand.cxx @@ -9,6 +9,7 @@ #include "cmListFileCache.h" #include "cmMakefile.h" #include "cmMessageType.h" +#include "cmStringAlgorithms.h" #include "cmSystemTools.h" #include "cmTarget.h" @@ -39,9 +40,9 @@ std::string cmTargetIncludeDirectoriesCommand::Join( for (std::string const& it : content) { if (cmSystemTools::FileIsFullPath(it) || cmGeneratorExpression::Find(it) == 0) { - dirs += sep + it; + dirs += cmStrCat(sep, it); } else { - dirs += sep + prefix + it; + dirs += cmStrCat(sep, prefix, it); } sep = ";"; } diff --git a/Source/cmUuid.cxx b/Source/cmUuid.cxx index 51ecbd1..0dc6ca7 100644 --- a/Source/cmUuid.cxx +++ b/Source/cmUuid.cxx @@ -114,14 +114,12 @@ std::string cmUuid::BinaryToString(const unsigned char* input) const std::string cmUuid::ByteToHex(unsigned char byte) const { - std::string result; + std::string result(" "); for (int i = 0; i < 2; ++i) { unsigned char rest = byte % 16; byte /= 16; - char c = (rest < 0xA) ? char('0' + rest) : char('a' + (rest - 0xA)); - - result = c + result; + result.at(1 - i) = c; } return result; diff --git a/Source/cmake.cxx b/Source/cmake.cxx index a81b7e4..3cc6776 100644 --- a/Source/cmake.cxx +++ b/Source/cmake.cxx @@ -808,8 +808,8 @@ void cmake::SetArgs(const std::vector& args) kdevError = "\nThe KDevelop3 generator is not supported anymore."; } - cmSystemTools::Error("Could not create named generator " + value + - kdevError); + cmSystemTools::Error( + cmStrCat("Could not create named generator ", value, kdevError)); this->PrintGeneratorList(); return; } ----------------------------------------------------------------------- Summary of changes: .clang-tidy | 1 - Modules/FindPython.cmake | 6 + Modules/FindPython/Support.cmake | 479 +++++++++++++++---------- Modules/FindPython2.cmake | 6 + Modules/FindPython3.cmake | 6 + Source/CTest/cmCTestBuildHandler.cxx | 6 - Source/CTest/cmCTestLaunch.cxx | 4 +- Source/CTest/cmCTestScriptHandler.cxx | 7 +- Source/CTest/cmCTestSubmitHandler.cxx | 8 +- Source/CTest/cmParseCoberturaCoverage.cxx | 5 +- Source/cmBinUtilsLinuxELFLinker.cxx | 5 +- Source/cmBinUtilsWindowsPELinker.cxx | 3 +- Source/cmComputeLinkInformation.cxx | 2 +- Source/cmCoreTryCompile.cxx | 5 +- Source/cmExportInstallFileGenerator.cxx | 2 +- Source/cmExtraCodeBlocksGenerator.cxx | 9 +- Source/cmExtraCodeLiteGenerator.cxx | 7 +- Source/cmExtraSublimeTextGenerator.cxx | 3 +- Source/cmFLTKWrapUICommand.cxx | 14 +- Source/cmFileAPI.cxx | 2 +- Source/cmFileCopier.cxx | 5 +- Source/cmGeneratorExpressionNode.cxx | 2 +- Source/cmGhsMultiTargetGenerator.cxx | 5 +- Source/cmGlobalGhsMultiGenerator.cxx | 11 +- Source/cmGlobalNinjaGenerator.cxx | 28 +- Source/cmGlobalXCodeGenerator.cxx | 2 +- Source/cmInstallDirectoryGenerator.cxx | 3 +- Source/cmInstallTargetGenerator.cxx | 3 +- Source/cmJsonObjects.cxx | 6 +- Source/cmLinkLineComputer.cxx | 12 +- Source/cmListCommand.cxx | 51 ++- Source/cmLocalGenerator.cxx | 2 +- Source/cmLocalUnixMakefileGenerator3.cxx | 12 +- Source/cmMakefileExecutableTargetGenerator.cxx | 5 +- Source/cmMakefileLibraryTargetGenerator.cxx | 5 +- Source/cmMakefileTargetGenerator.cxx | 2 +- Source/cmNinjaNormalTargetGenerator.cxx | 4 +- Source/cmNinjaTargetGenerator.cxx | 4 +- Source/cmOutputRequiredFilesCommand.cxx | 36 +- Source/cmRST.cxx | 2 +- Source/cmSourceGroupCommand.cxx | 4 +- Source/cmSystemTools.cxx | 2 +- Source/cmTargetIncludeDirectoriesCommand.cxx | 5 +- Source/cmUuid.cxx | 6 +- Source/cmake.cxx | 4 +- 45 files changed, 461 insertions(+), 340 deletions(-) hooks/post-receive -- CMake From kwrobot at kitware.com Wed Aug 7 12:50:33 2019 From: kwrobot at kitware.com (Kitware Robot) Date: Wed, 7 Aug 2019 12:50:33 -0400 (EDT) Subject: [Cmake-commits] CMake branch, release, updated. v3.15.1-20-gdfac85b Message-ID: <20190807165033.2BC8A11200B@public.kitware.com> This is an automated email from the git hooks/post-receive script. It was generated because a ref change was pushed to the repository containing the project "CMake". The branch, release has been updated via dfac85bb114c0fcc632592fb5818d5fecb963285 (commit) via 18ce372e0febc58e24e42e21e59f5688f3875864 (commit) from 1c7a4f93ddc258e059933ec873bca02deee54f47 (commit) Those revisions listed above that are new to this repository have not appeared on any other notification email; so we list those revisions in full, below. - Log ----------------------------------------------------------------- ----------------------------------------------------------------------- Summary of changes: Help/release/3.15.rst | 7 +++++++ 1 file changed, 7 insertions(+) hooks/post-receive -- CMake From kwrobot at kitware.com Wed Aug 7 12:50:32 2019 From: kwrobot at kitware.com (Kitware Robot) Date: Wed, 7 Aug 2019 12:50:32 -0400 (EDT) Subject: [Cmake-commits] CMake branch, master, updated. v3.15.1-619-gd3d7e2c Message-ID: <20190807165033.0A58D10F1EF@public.kitware.com> This is an automated email from the git hooks/post-receive script. It was generated because a ref change was pushed to the repository containing the project "CMake". The branch, master has been updated via d3d7e2c6d0b28db8f95613de8d700983f577fe2b (commit) via 4d7fc099024fa58c3955de5583ffcdacc9324ec2 (commit) via dfac85bb114c0fcc632592fb5818d5fecb963285 (commit) via 18ce372e0febc58e24e42e21e59f5688f3875864 (commit) from bbf4a5771f8113ce5b88968c4dd3def2fbcd9354 (commit) Those revisions listed above that are new to this repository have not appeared on any other notification email; so we list those revisions in full, below. - Log ----------------------------------------------------------------- https://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=d3d7e2c6d0b28db8f95613de8d700983f577fe2b commit d3d7e2c6d0b28db8f95613de8d700983f577fe2b Merge: 4d7fc09 dfac85b Author: Brad King AuthorDate: Wed Aug 7 12:43:57 2019 -0400 Commit: Brad King CommitDate: Wed Aug 7 12:43:57 2019 -0400 Merge branch 'release-3.15' https://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=4d7fc099024fa58c3955de5583ffcdacc9324ec2 commit 4d7fc099024fa58c3955de5583ffcdacc9324ec2 Merge: bbf4a57 18ce372 Author: Brad King AuthorDate: Wed Aug 7 16:43:29 2019 +0000 Commit: Kitware Robot CommitDate: Wed Aug 7 12:43:39 2019 -0400 Merge topic 'doc-relnotes-3.15' 18ce372e0f Help: Add 3.15.2 release notes Acked-by: Kitware Robot Merge-request: !3664 ----------------------------------------------------------------------- Summary of changes: Help/release/3.15.rst | 7 +++++++ 1 file changed, 7 insertions(+) hooks/post-receive -- CMake From kwrobot at kitware.com Wed Aug 7 13:40:34 2019 From: kwrobot at kitware.com (Kitware Robot) Date: Wed, 7 Aug 2019 13:40:34 -0400 (EDT) Subject: [Cmake-commits] CMake branch, master, updated. v3.15.1-621-g114c52f Message-ID: <20190807174037.1700D1031DF@public.kitware.com> This is an automated email from the git hooks/post-receive script. It was generated because a ref change was pushed to the repository containing the project "CMake". The branch, master has been updated via 114c52fa5b890092e1409c232c97733a8c04d5bf (commit) via 40bbe50e23c06232ccf1c49589dde5dd84e1ac31 (commit) from d3d7e2c6d0b28db8f95613de8d700983f577fe2b (commit) Those revisions listed above that are new to this repository have not appeared on any other notification email; so we list those revisions in full, below. - Log ----------------------------------------------------------------- https://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=114c52fa5b890092e1409c232c97733a8c04d5bf commit 114c52fa5b890092e1409c232c97733a8c04d5bf Merge: d3d7e2c 40bbe50 Author: Brad King AuthorDate: Wed Aug 7 13:35:14 2019 -0400 Commit: Brad King CommitDate: Wed Aug 7 13:35:14 2019 -0400 Merge branch 'release-3.15' ----------------------------------------------------------------------- Summary of changes: hooks/post-receive -- CMake From kwrobot at kitware.com Wed Aug 7 13:40:37 2019 From: kwrobot at kitware.com (Kitware Robot) Date: Wed, 7 Aug 2019 13:40:37 -0400 (EDT) Subject: [Cmake-commits] CMake branch, release, updated. v3.15.1-21-g40bbe50 Message-ID: <20190807174037.B76FCA475F@public.kitware.com> This is an automated email from the git hooks/post-receive script. It was generated because a ref change was pushed to the repository containing the project "CMake". The branch, release has been updated via 40bbe50e23c06232ccf1c49589dde5dd84e1ac31 (commit) from dfac85bb114c0fcc632592fb5818d5fecb963285 (commit) Those revisions listed above that are new to this repository have not appeared on any other notification email; so we list those revisions in full, below. - Log ----------------------------------------------------------------- ----------------------------------------------------------------------- Summary of changes: Source/CMakeVersion.cmake | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) hooks/post-receive -- CMake From kwrobot at kitware.com Wed Aug 7 14:10:29 2019 From: kwrobot at kitware.com (Kitware Robot) Date: Wed, 7 Aug 2019 14:10:29 -0400 (EDT) Subject: [Cmake-commits] CMake annotated tag, v3.15.2, created. v3.15.2 Message-ID: <20190807181029.B07E0AAE72@public.kitware.com> This is an automated email from the git hooks/post-receive script. It was generated because a ref change was pushed to the repository containing the project "CMake". The annotated tag, v3.15.2 has been created at ecfdfbe8e4c9bc9e180e6a168165c9bdccc73d6a (tag) tagging 40bbe50e23c06232ccf1c49589dde5dd84e1ac31 (commit) replaces v3.15.1 tagged by Brad King on Wed Aug 7 13:36:08 2019 -0400 - Log ----------------------------------------------------------------- CMake 3.15.2 -----BEGIN PGP SIGNATURE----- iQJKBAABCgA0FiEExsJlMku+vcNQtRPQLSzvEDSSFoQFAl1LDAgWHGJyYWQua2lu Z0BraXR3YXJlLmNvbQAKCRAtLO8QNJIWhFgFD/9DACPPsHPynWaJ77rzLYdzU7r2 3Ucwk5aMHiAQnN4Y8z6CVdIYVmLJj/x/xpSTSpvkE8ZRiXSmvjfAdnN+0sWwHn8H uvcbe7SkUz3cP2X4hlyoj3n8srK4Mfc8TLwj2GOmOBLtE5T9zp7i1bBEkLgRvSrg GUbXbsKWO977FIVG/jihsz9oktFJRKs/YYNP02hQH6OjPCgS28YeDY4z1jZnZc81 5KYws5wzX6a/xMpAVP1m+dPTEELQBO7zU6u6l3UdvonUrQVaPjcK5Yhfdf4rC0mr p0ZatPBkAevfwmbpzhfk2U4V2wvEjWWWJpouU9V2wCTn6P9+6cpIu6IsD9qsdQ8E +lhE4W5/729Uz4fSaf1sLH/m8B7H3p2errnb5AimUqBQvYwqeugd0K54TFHNgtVY Bq7ra/y4iHupRd1ex6PCYVP0DohukroulYo+VzSMFJL6gbrlzu10lcC/cUrzXTQx QLAiVrhXcFNSt3o6AQoWov3bcncnFWjy+cr4/aWRxWrdb3DuqkRE+vljaQZx76WB vS9SGM6udt3ZtRggmEgw05Q9DO4KFuFqG/pT9H34/AMrrHtcWxBuGi+RWmhQKo7F sYQaoPmDdrw7aZU9ikI5LX7uZDLUBqbQnJaFq1Jyr7g/XGQ8Z2Vv81tqEWnwszyM e+OBgrCEz0/eNx/oag== =2QXL -----END PGP SIGNATURE----- Brad King (17): Swift: Restore support for enabling with INTERFACE libraries Merge branch 'swift-with-interface-libs' into release-3.15 VS: Fix mapping of `-Qspectre-` flag Merge branch 'vs-spectre-off' into release-3.15 source_group: Fix regression in relative FILES Merge branch 'source_group-tree-files' into release-3.15 clang: Restore support for clang-cl on non-Windows hosts Merge branch 'clang-cl-non-windows' into release-3.15 fileapi: Fix codemodel target install destination for cross-dir rules Merge branch 'fileapi-install-generators' into release-3.15 clang: Work around toolchain file use of internal CMake variables Merge branch 'clang-frontend-variant' into release-3.15 Merge branch 'find_package-prefer-config-not-found' into release-3.15 Merge branch 'FindGLEW-macOS' into release-3.15 Help: Add 3.15.2 release notes Merge branch 'doc-relnotes-3.15' into release-3.15 CMake 3.15.2 Claudio Fantacci (3): FindGLEW: Fix macOS library suffix selection FindGLEW: Add required OpenGL dependency in macOS FindGLEW: Fix typo in verbose log message Cristian Adam (1): find_package: Fix prefer-config mode to not fail on missing optional package ----------------------------------------------------------------------- hooks/post-receive -- CMake From kwrobot at kitware.com Thu Aug 8 00:00:21 2019 From: kwrobot at kitware.com (Kitware Robot) Date: Thu, 8 Aug 2019 00:00:21 -0400 (EDT) Subject: [Cmake-commits] CMake branch, master, updated. v3.15.2-601-g38a5b02 Message-ID: <20190808040021.80A5811E3F0@public.kitware.com> This is an automated email from the git hooks/post-receive script. It was generated because a ref change was pushed to the repository containing the project "CMake". The branch, master has been updated via 38a5b0203fe116268afbdb8d82fc8d89c3b213f2 (commit) from 114c52fa5b890092e1409c232c97733a8c04d5bf (commit) Those revisions listed above that are new to this repository have not appeared on any other notification email; so we list those revisions in full, below. - Log ----------------------------------------------------------------- https://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=38a5b0203fe116268afbdb8d82fc8d89c3b213f2 commit 38a5b0203fe116268afbdb8d82fc8d89c3b213f2 Author: Kitware Robot AuthorDate: Thu Aug 8 00:01:08 2019 -0400 Commit: Kitware Robot CommitDate: Thu Aug 8 00:01:08 2019 -0400 CMake Nightly Date Stamp diff --git a/Source/CMakeVersion.cmake b/Source/CMakeVersion.cmake index 96e5ee5..d731b2e 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 15) -set(CMake_VERSION_PATCH 20190807) +set(CMake_VERSION_PATCH 20190808) #set(CMake_VERSION_RC 0) set(CMake_VERSION_IS_DIRTY 0) ----------------------------------------------------------------------- Summary of changes: Source/CMakeVersion.cmake | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) hooks/post-receive -- CMake From kwrobot at kitware.com Thu Aug 8 23:59:43 2019 From: kwrobot at kitware.com (Kitware Robot) Date: Thu, 8 Aug 2019 23:59:43 -0400 (EDT) Subject: [Cmake-commits] CMake branch, master, updated. v3.15.2-602-g242435a Message-ID: <20190809035943.100CD11EB14@public.kitware.com> This is an automated email from the git hooks/post-receive script. It was generated because a ref change was pushed to the repository containing the project "CMake". The branch, master has been updated via 242435a9c891bda62880b77d6d612a8975f11059 (commit) from 38a5b0203fe116268afbdb8d82fc8d89c3b213f2 (commit) Those revisions listed above that are new to this repository have not appeared on any other notification email; so we list those revisions in full, below. - Log ----------------------------------------------------------------- https://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=242435a9c891bda62880b77d6d612a8975f11059 commit 242435a9c891bda62880b77d6d612a8975f11059 Author: Kitware Robot AuthorDate: Fri Aug 9 00:01:06 2019 -0400 Commit: Kitware Robot CommitDate: Fri Aug 9 00:01:06 2019 -0400 CMake Nightly Date Stamp diff --git a/Source/CMakeVersion.cmake b/Source/CMakeVersion.cmake index d731b2e..1a93578 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 15) -set(CMake_VERSION_PATCH 20190808) +set(CMake_VERSION_PATCH 20190809) #set(CMake_VERSION_RC 0) set(CMake_VERSION_IS_DIRTY 0) ----------------------------------------------------------------------- Summary of changes: Source/CMakeVersion.cmake | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) hooks/post-receive -- CMake From kwrobot at kitware.com Fri Aug 9 10:29:33 2019 From: kwrobot at kitware.com (Kitware Robot) Date: Fri, 9 Aug 2019 10:29:33 -0400 (EDT) Subject: [Cmake-commits] CMake branch, master, updated. v3.15.2-606-g1a901ed Message-ID: <20190809142933.B02A1111C00@public.kitware.com> This is an automated email from the git hooks/post-receive script. It was generated because a ref change was pushed to the repository containing the project "CMake". The branch, master has been updated via 1a901ed09e27387f14d419adb407e7964d176f37 (commit) via 8bd5e5f181f2f458681dd1435f96b180c3b095dc (commit) via e45187d525a129d2903f44cfbc4dc3210905757d (commit) via 5558070d5265c9a8c15efb64787eaadbd3adb60f (commit) from 242435a9c891bda62880b77d6d612a8975f11059 (commit) Those revisions listed above that are new to this repository have not appeared on any other notification email; so we list those revisions in full, below. - Log ----------------------------------------------------------------- https://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=1a901ed09e27387f14d419adb407e7964d176f37 commit 1a901ed09e27387f14d419adb407e7964d176f37 Merge: 8bd5e5f e45187d Author: Brad King AuthorDate: Fri Aug 9 14:27:39 2019 +0000 Commit: Kitware Robot CommitDate: Fri Aug 9 10:28:45 2019 -0400 Merge topic 'fphsa-components-space' e45187d525 FPHSA: Remove extra space in module components report Acked-by: Kitware Robot Acked-by: Alex Turbov Merge-request: !3655 https://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=8bd5e5f181f2f458681dd1435f96b180c3b095dc commit 8bd5e5f181f2f458681dd1435f96b180c3b095dc Merge: 242435a 5558070 Author: Brad King AuthorDate: Fri Aug 9 14:26:18 2019 +0000 Commit: Kitware Robot CommitDate: Fri Aug 9 10:26:33 2019 -0400 Merge topic 'execution-status' 5558070d52 cmExecutionStatus: Remove function Clear Acked-by: Kitware Robot Merge-request: !3654 https://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=e45187d525a129d2903f44cfbc4dc3210905757d commit e45187d525a129d2903f44cfbc4dc3210905757d Author: Sylvain Joubert AuthorDate: Tue Aug 6 12:42:06 2019 +0200 Commit: Sylvain Joubert CommitDate: Tue Aug 6 12:42:06 2019 +0200 FPHSA: Remove extra space in module components report diff --git a/Modules/FindPackageHandleStandardArgs.cmake b/Modules/FindPackageHandleStandardArgs.cmake index 1722d6a..a2999fc 100644 --- a/Modules/FindPackageHandleStandardArgs.cmake +++ b/Modules/FindPackageHandleStandardArgs.cmake @@ -264,14 +264,14 @@ function(FIND_PACKAGE_HANDLE_STANDARD_ARGS _NAME _FIRST_ARG) if(${_NAME}_${comp}_FOUND) if(NOT DEFINED FOUND_COMPONENTS_MSG) - set(FOUND_COMPONENTS_MSG "found components: ") + set(FOUND_COMPONENTS_MSG "found components:") endif() string(APPEND FOUND_COMPONENTS_MSG " ${comp}") else() if(NOT DEFINED MISSING_COMPONENTS_MSG) - set(MISSING_COMPONENTS_MSG "missing components: ") + set(MISSING_COMPONENTS_MSG "missing components:") endif() string(APPEND MISSING_COMPONENTS_MSG " ${comp}") diff --git a/Tests/RunCMake/FindBoost/CMakePackage-stdout.txt b/Tests/RunCMake/FindBoost/CMakePackage-stdout.txt index 0a67488..ebd7232 100644 --- a/Tests/RunCMake/FindBoost/CMakePackage-stdout.txt +++ b/Tests/RunCMake/FindBoost/CMakePackage-stdout.txt @@ -1,2 +1,2 @@ -- Found Boost: [^ -]* \(found suitable version "1\.12345", minimum required is "1\.12345"\) found components: date_time +]* \(found suitable version "1\.12345", minimum required is "1\.12345"\) found components: date_time diff --git a/Tests/RunCMake/FindBoost/LegacyVars-LowercaseTargetPrefix-stdout.txt b/Tests/RunCMake/FindBoost/LegacyVars-LowercaseTargetPrefix-stdout.txt index a781dce..1175425 100644 --- a/Tests/RunCMake/FindBoost/LegacyVars-LowercaseTargetPrefix-stdout.txt +++ b/Tests/RunCMake/FindBoost/LegacyVars-LowercaseTargetPrefix-stdout.txt @@ -1,5 +1,5 @@ -- Found Boost: [^ -]* \(found suitable version "1\.70\.42", minimum required is "1\.70"\) found components: date_time python37 mpi_python2 * +]* \(found suitable version "1\.70\.42", minimum required is "1\.70"\) found components: date_time python37 mpi_python2 * -- Boost_FOUND: TRUE -- Boost_INCLUDE_DIRS: [^ ]*/Tests/RunCMake/FindBoost/CMakePackage[^/]*/include diff --git a/Tests/RunCMake/FindBoost/LegacyVars-TargetsDefined-stdout.txt b/Tests/RunCMake/FindBoost/LegacyVars-TargetsDefined-stdout.txt index a4e9c6a..101d60e 100644 --- a/Tests/RunCMake/FindBoost/LegacyVars-TargetsDefined-stdout.txt +++ b/Tests/RunCMake/FindBoost/LegacyVars-TargetsDefined-stdout.txt @@ -1,5 +1,5 @@ -- Found Boost: [^ -]* \(found suitable version "1\.70\.42", minimum required is "1\.70"\) found components: date_time python37 mpi_python2 * +]* \(found suitable version "1\.70\.42", minimum required is "1\.70"\) found components: date_time python37 mpi_python2 * -- Boost_FOUND: TRUE -- Boost_INCLUDE_DIRS: [^ ]*/Tests/RunCMake/FindBoost/CMakePackage[^/]*/include diff --git a/Tests/RunCMake/FindBoost/MissingTarget-stdout.txt b/Tests/RunCMake/FindBoost/MissingTarget-stdout.txt index 8e9d684..9853c01 100644 --- a/Tests/RunCMake/FindBoost/MissingTarget-stdout.txt +++ b/Tests/RunCMake/FindBoost/MissingTarget-stdout.txt @@ -1,5 +1,5 @@ -- Found Boost: [^ -]* \(found suitable version "1\.70\.42", minimum required is "1\.70"\) found components: date_time * +]* \(found suitable version "1\.70\.42", minimum required is "1\.70"\) found components: date_time * -- Boost_FOUND: TRUE -- Boost_INCLUDE_DIRS: [^ ]*/Tests/RunCMake/FindBoost/CMakePackage_MissingTarget/include https://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=5558070d5265c9a8c15efb64787eaadbd3adb60f commit 5558070d5265c9a8c15efb64787eaadbd3adb60f Author: Regina Pfeifer AuthorDate: Tue Aug 6 10:05:27 2019 +0200 Commit: Regina Pfeifer CommitDate: Tue Aug 6 10:05:27 2019 +0200 cmExecutionStatus: Remove function Clear diff --git a/Source/cmExecutionStatus.h b/Source/cmExecutionStatus.h index bcacc2f..654922c 100644 --- a/Source/cmExecutionStatus.h +++ b/Source/cmExecutionStatus.h @@ -22,15 +22,6 @@ public: { } - void Clear() - { - this->Error = "unknown error."; - this->ReturnInvoked = false; - this->BreakInvoked = false; - this->ContinueInvoked = false; - this->NestedError = false; - } - cmMakefile& GetMakefile() { return this->Makefile; } void SetError(std::string const& e) { this->Error = e; } diff --git a/Source/cmForEachCommand.cxx b/Source/cmForEachCommand.cxx index 1d961be..a565786 100644 --- a/Source/cmForEachCommand.cxx +++ b/Source/cmForEachCommand.cxx @@ -74,9 +74,8 @@ bool cmForEachFunctionBlocker::Replay( // set the variable to the loop value mf.AddDefinition(this->Args[0], arg); // Invoke all the functions that were collected in the block. - cmExecutionStatus status(mf); for (cmListFileFunction const& func : functions) { - status.Clear(); + cmExecutionStatus status(mf); mf.ExecuteCommand(func, status); if (status.GetReturnInvoked()) { inStatus.SetReturnInvoked(); diff --git a/Source/cmIfCommand.cxx b/Source/cmIfCommand.cxx index c5cfd8c..7b49ae7 100644 --- a/Source/cmIfCommand.cxx +++ b/Source/cmIfCommand.cxx @@ -61,7 +61,6 @@ bool cmIfFunctionBlocker::Replay(std::vector functions, { cmMakefile& mf = inStatus.GetMakefile(); // execute the functions for the true parts of the if statement - cmExecutionStatus status(mf); int scopeDepth = 0; for (cmListFileFunction const& func : functions) { // keep track of scope depth @@ -147,7 +146,7 @@ bool cmIfFunctionBlocker::Replay(std::vector functions, // should we execute? else if (!this->IsBlocking) { - status.Clear(); + cmExecutionStatus status(mf); mf.ExecuteCommand(func, status); if (status.GetReturnInvoked()) { inStatus.SetReturnInvoked(); ----------------------------------------------------------------------- Summary of changes: Modules/FindPackageHandleStandardArgs.cmake | 4 ++-- Source/cmExecutionStatus.h | 9 --------- Source/cmForEachCommand.cxx | 3 +-- Source/cmIfCommand.cxx | 3 +-- Tests/RunCMake/FindBoost/CMakePackage-stdout.txt | 2 +- .../FindBoost/LegacyVars-LowercaseTargetPrefix-stdout.txt | 2 +- Tests/RunCMake/FindBoost/LegacyVars-TargetsDefined-stdout.txt | 2 +- Tests/RunCMake/FindBoost/MissingTarget-stdout.txt | 2 +- 8 files changed, 8 insertions(+), 19 deletions(-) hooks/post-receive -- CMake From kwrobot at kitware.com Fri Aug 9 10:39:26 2019 From: kwrobot at kitware.com (Kitware Robot) Date: Fri, 9 Aug 2019 10:39:26 -0400 (EDT) Subject: [Cmake-commits] CMake branch, master, updated. v3.15.2-613-g1263b08 Message-ID: <20190809143926.34013111C00@public.kitware.com> This is an automated email from the git hooks/post-receive script. It was generated because a ref change was pushed to the repository containing the project "CMake". The branch, master has been updated via 1263b0884bbad60b4f21d70a59a11647d30d54a8 (commit) via 7891f69c67122eca2cba9f2c58fa0f1d49eba9bc (commit) via 6f3c429ee82eda7fccf70de32d6f8cba4079e94e (commit) via 1a47d368d8925c8c7e3a8afc75f9592058cce100 (commit) via ca2923110c9999c5cd538a91ec61b10d0b336c48 (commit) via d02a99d9d3aa8d8f33efbd3255c78d6b87a99a22 (commit) via 2171f6ec0ea3ca373db94bc55d8b7db999de97cc (commit) from 1a901ed09e27387f14d419adb407e7964d176f37 (commit) Those revisions listed above that are new to this repository have not appeared on any other notification email; so we list those revisions in full, below. - Log ----------------------------------------------------------------- https://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=1263b0884bbad60b4f21d70a59a11647d30d54a8 commit 1263b0884bbad60b4f21d70a59a11647d30d54a8 Merge: 7891f69 1a47d36 Author: Brad King AuthorDate: Fri Aug 9 14:31:20 2019 +0000 Commit: Kitware Robot CommitDate: Fri Aug 9 10:37:25 2019 -0400 Merge topic 'cmDefinitions_cleanups' 1a47d368d8 cmDefinitions: Cleanups and optimizations Acked-by: Kitware Robot Merge-request: !3666 https://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=7891f69c67122eca2cba9f2c58fa0f1d49eba9bc commit 7891f69c67122eca2cba9f2c58fa0f1d49eba9bc Merge: 6f3c429 ca29231 Author: Brad King AuthorDate: Fri Aug 9 14:29:22 2019 +0000 Commit: Kitware Robot CommitDate: Fri Aug 9 10:33:00 2019 -0400 Merge topic 'autogen_cmStrCat' ca2923110c Autogen: Modernize to use cmStrCat for string concatenation d02a99d9d3 Autogen: Modernize code to use cm::string_view for the info writer Acked-by: Kitware Robot Merge-request: !3663 https://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=6f3c429ee82eda7fccf70de32d6f8cba4079e94e commit 6f3c429ee82eda7fccf70de32d6f8cba4079e94e Merge: 1a901ed 2171f6e Author: Brad King AuthorDate: Fri Aug 9 14:28:15 2019 +0000 Commit: Kitware Robot CommitDate: Fri Aug 9 10:30:45 2019 -0400 Merge topic 'soname-darwin' 2171f6ec0e Swift: correct SONAME flag for Darwin targets Acked-by: Kitware Robot Merge-request: !3640 https://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=1a47d368d8925c8c7e3a8afc75f9592058cce100 commit 1a47d368d8925c8c7e3a8afc75f9592058cce100 Author: Sebastian Holtermann AuthorDate: Thu Aug 8 13:50:47 2019 +0200 Commit: Sebastian Holtermann CommitDate: Thu Aug 8 14:12:43 2019 +0200 cmDefinitions: Cleanups and optimizations In cmDefinitions: - sort methods in source code by static or not static - use `std::unordered_set` instead of `std::set` for duplications tests. diff --git a/Source/cmDefinitions.cxx b/Source/cmDefinitions.cxx index 42e70d6..cc38d84 100644 --- a/Source/cmDefinitions.cxx +++ b/Source/cmDefinitions.cxx @@ -2,8 +2,11 @@ file Copyright.txt or https://cmake.org/licensing for details. */ #include "cmDefinitions.h" +#include "cm_string_view.hxx" + #include -#include +#include +#include #include cmDefinitions::Def cmDefinitions::NoDef; @@ -14,7 +17,7 @@ cmDefinitions::Def const& cmDefinitions::GetInternal(const std::string& key, { assert(begin != end); { - MapType::iterator it = begin->Map.find(key); + auto it = begin->Map.find(key); if (it != begin->Map.end()) { it->second.Used = true; return it->second; @@ -56,33 +59,10 @@ bool cmDefinitions::HasKey(const std::string& key, StackIter begin, return false; } -void cmDefinitions::Set(const std::string& key, cm::string_view value) -{ - this->Map[key] = Def(value); -} - -void cmDefinitions::Unset(const std::string& key) -{ - this->Map[key] = Def(); -} - -std::vector cmDefinitions::UnusedKeys() const -{ - std::vector keys; - keys.reserve(this->Map.size()); - // Consider local definitions. - for (auto const& mi : this->Map) { - if (!mi.second.Used) { - keys.push_back(mi.first); - } - } - return keys; -} - cmDefinitions cmDefinitions::MakeClosure(StackIter begin, StackIter end) { cmDefinitions closure; - std::set undefined; + std::unordered_set undefined; for (StackIter it = begin; it != end; ++it) { // Consider local definitions. for (auto const& mi : it->Map) { @@ -92,7 +72,7 @@ cmDefinitions cmDefinitions::MakeClosure(StackIter begin, StackIter end) if (mi.second.Exists) { closure.Map.insert(mi); } else { - undefined.insert(mi.first); + undefined.emplace(mi.first); } } } @@ -104,13 +84,13 @@ std::vector cmDefinitions::ClosureKeys(StackIter begin, StackIter end) { std::vector defined; - std::set bound; + std::unordered_set bound; for (StackIter it = begin; it != end; ++it) { defined.reserve(defined.size() + it->Map.size()); for (auto const& mi : it->Map) { // Use this key if it is not already set or unset. - if (bound.insert(mi.first).second && mi.second.Exists) { + if (bound.emplace(mi.first).second && mi.second.Exists) { defined.push_back(mi.first); } } @@ -118,3 +98,26 @@ std::vector cmDefinitions::ClosureKeys(StackIter begin, return defined; } + +void cmDefinitions::Set(const std::string& key, cm::string_view value) +{ + this->Map[key] = Def(value); +} + +void cmDefinitions::Unset(const std::string& key) +{ + this->Map[key] = Def(); +} + +std::vector cmDefinitions::UnusedKeys() const +{ + std::vector keys; + keys.reserve(this->Map.size()); + // Consider local definitions. + for (auto const& mi : this->Map) { + if (!mi.second.Used) { + keys.push_back(mi.first); + } + } + return keys; +} diff --git a/Source/cmDefinitions.h b/Source/cmDefinitions.h index 4d8810a..787471a 100644 --- a/Source/cmDefinitions.h +++ b/Source/cmDefinitions.h @@ -25,6 +25,8 @@ class cmDefinitions typedef cmLinkedTree::iterator StackIter; public: + // -- Static member functions + static const std::string* Get(const std::string& key, StackIter begin, StackIter end); @@ -32,18 +34,21 @@ public: static bool HasKey(const std::string& key, StackIter begin, StackIter end); + static std::vector ClosureKeys(StackIter begin, StackIter end); + + static cmDefinitions MakeClosure(StackIter begin, StackIter end); + + // -- Member functions + /** Set a value associated with a key. */ void Set(const std::string& key, cm::string_view value); /** Unset a definition. */ void Unset(const std::string& key); + /** List of unused keys. */ std::vector UnusedKeys() const; - static std::vector ClosureKeys(StackIter begin, StackIter end); - - static cmDefinitions MakeClosure(StackIter begin, StackIter end); - private: /** String with existence boolean. */ struct Def @@ -61,8 +66,7 @@ private: }; static Def NoDef; - typedef std::unordered_map MapType; - MapType Map; + std::unordered_map Map; static Def const& GetInternal(const std::string& key, StackIter begin, StackIter end, bool raise); https://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=ca2923110c9999c5cd538a91ec61b10d0b336c48 commit ca2923110c9999c5cd538a91ec61b10d0b336c48 Author: Sebastian Holtermann AuthorDate: Tue Aug 6 10:40:49 2019 +0200 Commit: Sebastian Holtermann CommitDate: Wed Aug 7 19:48:02 2019 +0200 Autogen: Modernize to use cmStrCat for string concatenation diff --git a/Source/cmQtAutoGen.cxx b/Source/cmQtAutoGen.cxx index 712e22c..3026b33 100644 --- a/Source/cmQtAutoGen.cxx +++ b/Source/cmQtAutoGen.cxx @@ -353,9 +353,8 @@ bool cmQtAutoGen::RccLister::list(std::string const& qrcFile, // Log command if (verbose) { - std::string msg = "Running command:\n"; - msg += QuotedCommand(cmd); - msg += '\n'; + std::string msg = + cmStrCat("Running command:\n", QuotedCommand(cmd), '\n'); cmSystemTools::Stdout(msg); } diff --git a/Source/cmQtAutoGenGlobalInitializer.cxx b/Source/cmQtAutoGenGlobalInitializer.cxx index f172b77..ca5a587 100644 --- a/Source/cmQtAutoGenGlobalInitializer.cxx +++ b/Source/cmQtAutoGenGlobalInitializer.cxx @@ -1,8 +1,6 @@ /* Distributed under the OSI-approved BSD 3-Clause License. See accompanying file Copyright.txt or https://cmake.org/licensing for details. */ #include "cmQtAutoGenGlobalInitializer.h" -#include "cmQtAutoGen.h" -#include "cmQtAutoGenInitializer.h" #include "cmCustomCommandLines.h" #include "cmDuration.h" @@ -11,15 +9,18 @@ #include "cmMakefile.h" #include "cmMessageType.h" #include "cmProcessOutput.h" +#include "cmQtAutoGen.h" +#include "cmQtAutoGenInitializer.h" #include "cmState.h" #include "cmStateTypes.h" +#include "cmStringAlgorithms.h" #include "cmSystemTools.h" #include "cmTarget.h" -#include - #include "cm_memory.hxx" +#include + cmQtAutoGenGlobalInitializer::Keywords::Keywords() : AUTOMOC("AUTOMOC") , AUTOUIC("AUTOUIC") @@ -119,23 +120,17 @@ cmQtAutoGenGlobalInitializer::cmQtAutoGenGlobalInitializer( bool const uicDisabled = (uic && !uicAvailable); bool const rccDisabled = (rcc && !rccAvailable); if (mocDisabled || uicDisabled || rccDisabled) { - std::string msg = "AUTOGEN: No valid Qt version found for target "; - msg += target->GetName(); - msg += ". "; - msg += cmQtAutoGen::Tools(mocDisabled, uicDisabled, rccDisabled); - msg += " disabled. Consider adding:\n"; - { - std::string version = (qtVersion.second == 0) - ? std::string("") - : std::to_string(qtVersion.second); - std::string comp = uicDisabled ? "Widgets" : "Core"; - msg += " find_package(Qt"; - msg += version; - msg += " COMPONENTS "; - msg += comp; - msg += ")\n"; - } - msg += "to your CMakeLists.txt file."; + cmAlphaNum version = (qtVersion.second == 0) + ? cmAlphaNum("") + : cmAlphaNum(qtVersion.second); + cmAlphaNum component = uicDisabled ? "Widgets" : "Core"; + + std::string const msg = cmStrCat( + "AUTOGEN: No valid Qt version found for target ", + target->GetName(), ". ", + cmQtAutoGen::Tools(mocDisabled, uicDisabled, rccDisabled), + " disabled. Consider adding:\n", " find_package(Qt", version, + " COMPONENTS ", component, ")\n", "to your CMakeLists.txt file."); target->Makefile->IssueMessage(MessageType::AUTHOR_WARNING, msg); } if (mocIsValid || uicIsValid || rccIsValid) { diff --git a/Source/cmQtAutoGenInitializer.cxx b/Source/cmQtAutoGenInitializer.cxx index 7e72fd6..360df25 100644 --- a/Source/cmQtAutoGenInitializer.cxx +++ b/Source/cmQtAutoGenInitializer.cxx @@ -716,14 +716,13 @@ bool cmQtAutoGenInitializer::InitScanFiles() if (muf.MocIt || muf.UicIt) { // Search for the default header file and a private header std::string const& srcPath = muf.SF->GetFullPath(); - std::string basePath = cmQtAutoGen::SubDirPrefix(srcPath); - basePath += cmSystemTools::GetFilenameWithoutLastExtension(srcPath); + std::string basePath = + cmStrCat(cmQtAutoGen::SubDirPrefix(srcPath), + cmSystemTools::GetFilenameWithoutLastExtension(srcPath)); for (auto const& suffix : suffixes) { std::string const suffixedPath = basePath + suffix; for (auto const& ext : exts) { - std::string fullPath = suffixedPath; - fullPath += '.'; - fullPath += ext; + std::string fullPath = cmStrCat(suffixedPath, '.', ext); auto constexpr locationKind = cmSourceFileLocationKind::Known; cmSourceFile* sf = makefile->GetSource(fullPath, locationKind); @@ -828,9 +827,8 @@ bool cmQtAutoGenInitializer::InitScanFiles() this->AutogenTarget.DependFiles.insert(muf->RealPath); } } else if (this->CMP0071Warn) { - std::string msg; - msg += cmPolicies::GetPolicyWarning(cmPolicies::CMP0071); - msg += '\n'; + std::string msg = + cmStrCat(cmPolicies::GetPolicyWarning(cmPolicies::CMP0071), '\n'); std::string property; if (this->Moc.Enabled && this->Uic.Enabled) { property = kw.SKIP_AUTOGEN; @@ -883,18 +881,10 @@ bool cmQtAutoGenInitializer::InitScanFiles() for (Qrc& qrc : this->Rcc.Qrcs) { qrc.PathChecksum = fpathCheckSum.getPart(qrc.QrcFile); // RCC output file name + qrc.RccFile = cmStrCat(this->Dir.Build + "/", qrc.PathChecksum, + "/qrc_", qrc.QrcName, ".cpp"); { - std::string rccFile = this->Dir.Build + "/"; - rccFile += qrc.PathChecksum; - rccFile += "/qrc_"; - rccFile += qrc.QrcName; - rccFile += ".cpp"; - qrc.RccFile = std::move(rccFile); - } - { - std::string base = this->Dir.Info; - base += "/RCC"; - base += qrc.QrcName; + std::string base = cmStrCat(this->Dir.Info, "/RCC", qrc.QrcName); if (!qrc.Unique) { base += qrc.PathChecksum; } @@ -927,8 +917,7 @@ bool cmQtAutoGenInitializer::InitScanFiles() // Replace '-' with '_'. The former is not valid for symbol names. std::replace(name.begin(), name.end(), '-', '_'); if (!qrc.Unique) { - name += "_"; - name += qrc.PathChecksum; + name += cmStrCat("_", qrc.PathChecksum); } std::vector nameOpts; nameOpts.emplace_back("-name"); @@ -1152,8 +1141,8 @@ bool cmQtAutoGenInitializer::InitRccTargets() currentLine.push_back("$"); commandLines.push_back(std::move(currentLine)); } - std::string ccComment = "Automatic RCC for "; - ccComment += FileProjectRelativePath(makefile, qrc.QrcFile); + std::string ccComment = cmStrCat( + "Automatic RCC for ", FileProjectRelativePath(makefile, qrc.QrcFile)); if (qrc.Generated || this->Rcc.GlobalTarget) { // Create custom rcc target @@ -1221,9 +1210,8 @@ bool cmQtAutoGenInitializer::SetupCustomTargets() { // Create info directory on demand if (!cmSystemTools::MakeDirectory(this->Dir.Info)) { - std::string emsg = ("AutoGen: Could not create directory: "); - emsg += Quoted(this->Dir.Info); - cmSystemTools::Error(emsg); + cmSystemTools::Error(cmStrCat("AutoGen: Could not create directory: ", + Quoted(this->Dir.Info))); return false; } @@ -1306,10 +1294,8 @@ bool cmQtAutoGenInitializer::SetupWriteAutogenInfo() } if (muf->MocIt || muf->UicIt) { headers.emplace_back(muf->RealPath); - std::string flags; - flags += muf->MocIt ? 'M' : 'm'; - flags += muf->UicIt ? 'U' : 'u'; - headersFlags.emplace_back(std::move(flags)); + headersFlags.emplace_back( + cmStrCat(muf->MocIt ? "M" : "m", muf->UicIt ? "U" : "u")); } } } @@ -1318,14 +1304,13 @@ bool cmQtAutoGenInitializer::SetupWriteAutogenInfo() cmFilePathChecksum const fpathCheckSum(makefile); std::unordered_set emitted; for (std::string const& hdr : headers) { - std::string basePath = fpathCheckSum.getPart(hdr); - basePath += "/moc_"; - basePath += cmSystemTools::GetFilenameWithoutLastExtension(hdr); - for (unsigned int ii = 1; ii != 1024; ++ii) { + std::string basePath = + cmStrCat(fpathCheckSum.getPart(hdr), "/moc_", + cmSystemTools::GetFilenameWithoutLastExtension(hdr)); + for (int ii = 1; ii != 1024; ++ii) { std::string path = basePath; if (ii > 1) { - path += '_'; - path += std::to_string(ii); + path += cmStrCat("_", ii); } path += ".cpp"; if (emitted.emplace(path).second) { @@ -1364,10 +1349,8 @@ bool cmQtAutoGenInitializer::SetupWriteAutogenInfo() } if (muf->MocIt || muf->UicIt) { sources.emplace_back(muf->RealPath); - std::string flags; - flags += muf->MocIt ? 'M' : 'm'; - flags += muf->UicIt ? 'U' : 'u'; - sourcesFlags.emplace_back(std::move(flags)); + sourcesFlags.emplace_back( + cmStrCat(muf->MocIt ? "M" : "m", muf->UicIt ? "U" : "u")); } } } @@ -1421,9 +1404,8 @@ bool cmQtAutoGenInitializer::SetupWriteAutogenInfo() ofs.WriteStrings("AM_UIC_SEARCH_PATHS", this->Uic.SearchPaths); } } else { - std::string err = "AutoGen: Could not write file "; - err += this->AutogenTarget.InfoFile; - cmSystemTools::Error(err); + cmSystemTools::Error(cmStrCat("AutoGen: Could not write file ", + this->AutogenTarget.InfoFile)); return false; } @@ -1462,9 +1444,8 @@ bool cmQtAutoGenInitializer::SetupWriteRccInfo() ofs.WriteStrings("ARCC_OPTIONS", qrc.Options); ofs.WriteStrings("ARCC_INPUTS", qrc.Resources); } else { - std::string err = "AutoRcc: Could not write file "; - err += qrc.InfoFile; - cmSystemTools::Error(err); + cmSystemTools::Error( + cmStrCat("AutoRcc: Could not write file ", qrc.InfoFile)); return false; } } @@ -1519,13 +1500,10 @@ bool cmQtAutoGenInitializer::AddToSourceGroup(std::string const& fileName, if (!groupName.empty()) { sourceGroup = makefile->GetOrCreateSourceGroup(groupName); if (sourceGroup == nullptr) { - std::string err; - err += genNameUpper; - err += " error in "; - err += property; - err += ": Could not find or create the source group "; - err += cmQtAutoGen::Quoted(groupName); - cmSystemTools::Error(err); + cmSystemTools::Error( + cmStrCat(genNameUpper, " error in ", property, + ": Could not find or create the source group ", + cmQtAutoGen::Quoted(groupName))); return false; } } @@ -1617,12 +1595,8 @@ bool cmQtAutoGenInitializer::GetQtExecutable(GenVarsT& genVars, bool ignoreMissingTarget) const { auto print_err = [this, &genVars](std::string const& err) { - std::string msg = genVars.GenNameUpper; - msg += " for target "; - msg += this->Target->GetName(); - msg += ": "; - msg += err; - cmSystemTools::Error(msg); + cmSystemTools::Error(cmStrCat(genVars.GenNameUpper, " for target ", + this->Target->GetName(), ": ", err)); }; // Custom executable @@ -1682,11 +1656,8 @@ bool cmQtAutoGenInitializer::GetQtExecutable(GenVarsT& genVars, std::make_shared(); return true; } - std::string err = "Could not find "; - err += executable; - err += " executable target "; - err += targetName; - print_err(err); + print_err(cmStrCat("Could not find ", executable, " executable target ", + targetName)); return false; } } diff --git a/Source/cmQtAutoGenerator.cxx b/Source/cmQtAutoGenerator.cxx index 2516d84..0ad87b1 100644 --- a/Source/cmQtAutoGenerator.cxx +++ b/Source/cmQtAutoGenerator.cxx @@ -1,17 +1,17 @@ /* Distributed under the OSI-approved BSD 3-Clause License. See accompanying file Copyright.txt or https://cmake.org/licensing for details. */ #include "cmQtAutoGenerator.h" -#include "cmQtAutoGen.h" - -#include "cmsys/FStream.hxx" #include "cm_memory.hxx" +#include "cmsys/FStream.hxx" #include "cmGlobalGenerator.h" #include "cmMakefile.h" +#include "cmQtAutoGen.h" #include "cmState.h" #include "cmStateDirectory.h" #include "cmStateSnapshot.h" +#include "cmStringAlgorithms.h" #include "cmSystemTools.h" #include "cmake.h" @@ -60,19 +60,13 @@ void cmQtAutoGenerator::Logger::SetColorOutput(bool value) std::string cmQtAutoGenerator::Logger::HeadLine(std::string const& title) { - std::string head = title; - head += '\n'; - head.append(head.size() - 1, '-'); - head += '\n'; - return head; + return cmStrCat(title, "\n", std::string(title.size(), '-'), "\n"); } void cmQtAutoGenerator::Logger::Info(GenT genType, std::string const& message) const { - std::string msg = GeneratorName(genType); - msg += ": "; - msg += message; + std::string msg = cmStrCat(GeneratorName(genType), ": ", message); if (msg.back() != '\n') { msg.push_back('\n'); } @@ -110,19 +104,13 @@ void cmQtAutoGenerator::Logger::WarningFile(GenT genType, std::string const& filename, std::string const& message) const { - std::string msg = " "; - msg += Quoted(filename); - msg.push_back('\n'); - // Message - msg += message; - Warning(genType, msg); + Warning(genType, cmStrCat(" ", Quoted(filename), "\n", message)); } void cmQtAutoGenerator::Logger::Error(GenT genType, std::string const& message) const { - std::string msg; - msg += HeadLine(GeneratorName(genType) + " error"); + std::string msg = HeadLine(GeneratorName(genType) + " error"); // Message msg += message; if (msg.back() != '\n') { @@ -139,12 +127,7 @@ void cmQtAutoGenerator::Logger::ErrorFile(GenT genType, std::string const& filename, std::string const& message) const { - std::string emsg = " "; - emsg += Quoted(filename); - emsg += '\n'; - // Message - emsg += message; - Error(genType, emsg); + Error(genType, cmStrCat(" ", Quoted(filename), '\n', message)); } void cmQtAutoGenerator::Logger::ErrorCommand( @@ -280,10 +263,8 @@ bool cmQtAutoGenerator::Run(std::string const& infoFile, InfoFile_ = infoFile; cmSystemTools::ConvertToUnixSlashes(InfoFile_); if (!InfoFileTime_.Load(InfoFile_)) { - std::string msg = "AutoGen: The info file "; - msg += Quoted(InfoFile_); - msg += " is not readable\n"; - cmSystemTools::Stderr(msg); + cmSystemTools::Stderr(cmStrCat("AutoGen: The info file ", + Quoted(InfoFile_), " is not readable\n")); return false; } InfoDir_ = cmSystemTools::GetFilenamePath(infoFile); diff --git a/Source/cmQtAutoMocUic.cxx b/Source/cmQtAutoMocUic.cxx index 0801c24..e693816 100644 --- a/Source/cmQtAutoMocUic.cxx +++ b/Source/cmQtAutoMocUic.cxx @@ -302,10 +302,9 @@ void cmQtAutoMocUic::JobMocPredefsT::Process() } // Execute command if (!RunProcess(GenT::MOC, result, cmd, reason.get())) { - std::string msg = "The content generation command for "; - msg += Quoted(predefsFileRel); - msg += " failed.\n"; - msg += result.ErrorMessage; + std::string msg = + cmStrCat("The content generation command for ", + Quoted(predefsFileRel), " failed.\n", result.ErrorMessage); LogCommandError(GenT::MOC, msg, cmd, result.StdOut); return; } @@ -314,9 +313,8 @@ void cmQtAutoMocUic::JobMocPredefsT::Process() // (Re)write predefs file only on demand if (cmQtAutoGenerator::FileDiffers(predefsFileAbs, result.StdOut)) { if (!cmQtAutoGenerator::FileWrite(predefsFileAbs, result.StdOut)) { - std::string msg = "Writing "; - msg += Quoted(predefsFileRel); - msg += " failed."; + std::string msg = + cmStrCat("Writing ", Quoted(predefsFileRel), " failed."); LogFileError(GenT::MOC, predefsFileAbs, msg); return; } @@ -326,9 +324,8 @@ void cmQtAutoMocUic::JobMocPredefsT::Process() Log().Info(GenT::MOC, "Touching " + Quoted(predefsFileRel)); } if (!cmSystemTools::Touch(predefsFileAbs, false)) { - std::string msg = "Touching "; - msg += Quoted(predefsFileAbs); - msg += " failed."; + std::string msg = + cmStrCat("Touching ", Quoted(predefsFileAbs), " failed."); LogFileError(GenT::MOC, predefsFileAbs, msg); return; } @@ -663,13 +660,11 @@ bool cmQtAutoMocUic::JobEvaluateT::MocEvalSource( if (!sourceIncludesDotMoc && !parseData.Macro.empty() && !(relaxedMode && sourceIncludesMocUnderscore)) { { - std::string emsg = "The file contains a "; - emsg += Quoted(parseData.Macro); - emsg += " macro, but does not include "; - emsg += Quoted(sourceBase + ".moc"); - emsg += "!\nConsider to\n - add #include \""; - emsg += sourceBase; - emsg += ".moc\"\n - enable SKIP_AUTOMOC for this file"; + std::string emsg = + cmStrCat("The file contains a ", Quoted(parseData.Macro), + " macro, but does not include ", Quoted(sourceBase + ".moc"), + "!\nConsider to\n - add #include \"", sourceBase, + ".moc\"\n - enable SKIP_AUTOMOC for this file"); LogFileError(GenT::MOC, sourceFile.FileName, emsg); } return false; @@ -700,18 +695,14 @@ bool cmQtAutoMocUic::JobEvaluateT::MocEvalSource( // used. This is for KDE4 compatibility. { // Issue a warning - std::string msg = "The file contains a "; - msg += Quoted(parseData.Macro); - msg += " macro, but does not include "; - msg += Quoted(sourceBase + ".moc"); - msg += ".\nInstead it includes "; - msg += Quoted(incKey.Key); - msg += ".\nRunning moc on the source\n "; - msg += Quoted(sourceFile.FileName); - msg += "!\nBetter include "; - msg += Quoted(sourceBase + ".moc"); - msg += " for compatibility with regular mode.\n"; - msg += "This is a CMAKE_AUTOMOC_RELAXED_MODE warning.\n"; + std::string msg = cmStrCat( + "The file contains a ", Quoted(parseData.Macro), + " macro, but does not include ", Quoted(sourceBase + ".moc"), + ".\nInstead it includes ", Quoted(incKey.Key), + ".\nRunning moc on the source\n ", Quoted(sourceFile.FileName), + "!\nBetter include ", Quoted(sourceBase + ".moc"), + " for compatibility with regular mode.\n", + "This is a CMAKE_AUTOMOC_RELAXED_MODE warning.\n"); Log().WarningFile(GenT::MOC, sourceFile.FileName, msg); } // Create mapping @@ -764,28 +755,22 @@ bool cmQtAutoMocUic::JobEvaluateT::MocEvalSource( } // Issue a warning if (ownMoc && parseData.Macro.empty()) { - std::string msg = "The file includes the moc file "; - msg += Quoted(incKey.Key); - msg += ", but does not contain a\n"; - msg += MocConst().MacrosString(); - msg += " macro.\nRunning moc on the header\n "; - msg += Quoted(header->FileName); - msg += "!\nBetter include "; - msg += Quoted("moc_" + incKey.Base + ".cpp"); - msg += " for a compatibility with regular mode.\n"; - msg += "This is a CMAKE_AUTOMOC_RELAXED_MODE warning.\n"; + std::string msg = cmStrCat( + "The file includes the moc file ", Quoted(incKey.Key), + ", but does not contain a\n", MocConst().MacrosString(), + " macro.\nRunning moc on the header\n ", Quoted(header->FileName), + "!\nBetter include ", Quoted("moc_" + incKey.Base + ".cpp"), + " for a compatibility with regular mode.\n", + "This is a CMAKE_AUTOMOC_RELAXED_MODE warning.\n"); Log().WarningFile(GenT::MOC, sourceFile.FileName, msg); } else { - std::string msg = "The file includes the moc file "; - msg += Quoted(incKey.Key); - msg += " instead of "; - msg += Quoted("moc_" + incKey.Base + ".cpp"); - msg += ".\nRunning moc on the header\n "; - msg += Quoted(header->FileName); - msg += "!\nBetter include "; - msg += Quoted("moc_" + incKey.Base + ".cpp"); - msg += " for compatibility with regular mode.\n"; - msg += "This is a CMAKE_AUTOMOC_RELAXED_MODE warning.\n"; + std::string msg = cmStrCat( + "The file includes the moc file ", Quoted(incKey.Key), + " instead of ", Quoted("moc_" + incKey.Base + ".cpp"), + ".\nRunning moc on the header\n ", Quoted(header->FileName), + "!\nBetter include ", Quoted("moc_" + incKey.Base + ".cpp"), + " for compatibility with regular mode.\n", + "This is a CMAKE_AUTOMOC_RELAXED_MODE warning.\n"); Log().WarningFile(GenT::MOC, sourceFile.FileName, msg); } // Create mapping @@ -811,11 +796,9 @@ bool cmQtAutoMocUic::JobEvaluateT::MocEvalSource( } // Accept but issue a warning if moc isn't required if (parseData.Macro.empty()) { - std::string msg = "The file includes the moc file "; - msg += Quoted(incKey.Key); - msg += ", but does not contain a "; - msg += MocConst().MacrosString(); - msg += " macro."; + std::string msg = cmStrCat( + "The file includes the moc file ", Quoted(incKey.Key), + ", but does not contain a ", MocConst().MacrosString(), " macro."); Log().WarningFile(GenT::MOC, sourceFile.FileName, msg); } // Create mapping @@ -841,9 +824,7 @@ cmQtAutoMocUic::JobEvaluateT::MocFindIncludedHeader( } // Search in include directories for (std::string const& path : MocConst().IncludePaths) { - std::string testPath = path; - testPath += '/'; - testPath += includeBase; + std::string testPath = cmStrCat(path, '/', includeBase); SourceFileHandleT res = MocFindHeader(testPath); if (res) { return res; @@ -893,10 +874,9 @@ std::string cmQtAutoMocUic::JobEvaluateT::MocMessageTestHeaders( { std::ostringstream res; { - std::string exts = ".{"; - exts += cmJoin(BaseConst().HeaderExtensions, ","); - exts += '}'; - // Compose result string + std::string exts = + cmStrCat(".{", cmJoin(BaseConst().HeaderExtensions, ","), + '}'); // Compose result string res << " " << fileBase << exts << '\n'; for (std::string const& path : MocConst().IncludePaths) { res << " " << path << '/' << fileBase << exts << '\n'; @@ -914,9 +894,8 @@ bool cmQtAutoMocUic::JobEvaluateT::MocRegisterIncluded( if (handle) { // Check if the output file would be generated from different source files if (handle->SourceFile != sourceFileHandle) { - std::string msg = "The source files\n "; - msg += Quoted(includerFileHandle->FileName); - msg += '\n'; + std::string msg = cmStrCat("The source files\n ", + Quoted(includerFileHandle->FileName), '\n'); for (auto const& item : handle->IncluderFiles) { msg += " "; msg += Quoted(item->FileName); @@ -1020,9 +999,8 @@ bool cmQtAutoMocUic::JobEvaluateT::UicRegisterMapping( MappingHandleT const& handle = it->second; if (handle->SourceFile != uiFileHandle) { // The output file already gets generated - from a different .ui file! - std::string msg = "The source files\n "; - msg += Quoted(includerFileHandle->FileName); - msg += '\n'; + std::string msg = cmStrCat("The source files\n ", + Quoted(includerFileHandle->FileName), '\n'); for (auto const& item : handle->IncluderFiles) { msg += " "; msg += Quoted(item->FileName); @@ -1063,8 +1041,7 @@ cmQtAutoMocUic::JobEvaluateT::UicFindIncludedUi( std::string const& sourceFile, std::string const& sourceDir, IncludeKeyT const& incKey) const { - std::string searchFileName = incKey.Base; - searchFileName += ".ui"; + std::string searchFileName = cmStrCat(incKey.Base, ".ui"); // Collect search paths list std::vector testFiles; { @@ -1074,26 +1051,17 @@ cmQtAutoMocUic::JobEvaluateT::UicFindIncludedUi( // Vicinity of the source testFiles.emplace_back(sourceDir + searchFileName); if (!incKey.Dir.empty()) { - std::string path = sourceDir; - path += incKey.Dir; - path += searchFileName; - testFiles.emplace_back(path); + testFiles.emplace_back(cmStrCat(sourceDir, incKey.Dir, searchFileName)); } // AUTOUIC search paths if (!searchPaths.empty()) { for (std::string const& sPath : searchPaths) { - std::string path = sPath; - path += '/'; - path += searchFileName; - testFiles.emplace_back(std::move(path)); + testFiles.emplace_back(cmStrCat(sPath, '/', searchFileName)); } if (!incKey.Dir.empty()) { for (std::string const& sPath : searchPaths) { - std::string path = sPath; - path += '/'; - path += incKey.Dir; - path += searchFileName; - testFiles.emplace_back(std::move(path)); + testFiles.emplace_back( + cmStrCat(sPath, '/', incKey.Dir, searchFileName)); } } } @@ -1118,11 +1086,10 @@ cmQtAutoMocUic::JobEvaluateT::UicFindIncludedUi( // Log error { - std::string msg = "The file includes the uic file "; - msg += Quoted(incKey.Key); - msg += ",\nbut the user interface file "; - msg += Quoted(searchFileName); - msg += "\ncould not be found in the following locations\n"; + std::string msg = + cmStrCat("The file includes the uic file ", Quoted(incKey.Key), + ",\nbut the user interface file ", Quoted(searchFileName), + "\ncould not be found in the following locations\n"); for (std::string const& testFile : testFiles) { msg += " "; msg += Quoted(testFile); @@ -1418,10 +1385,9 @@ void cmQtAutoMocUic::JobMocT::Process() } } else { // Moc command failed - std::string msg = "The moc process failed to compile\n "; - msg += Quoted(sourceFile); - msg += "\ninto\n "; - msg += Quoted(outputFile); + std::string msg = + cmStrCat("The moc process failed to compile\n ", Quoted(sourceFile), + "\ninto\n ", Quoted(outputFile)); if (Mapping->IncluderFiles.empty()) { msg += ".\n"; } else { @@ -1467,11 +1433,9 @@ void cmQtAutoMocUic::JobUicT::Process() } } else { // Uic command failed - std::string msg = "The uic process failed to compile\n "; - msg += Quoted(sourceFile); - msg += "\ninto\n "; - msg += Quoted(outputFile); - msg += "\nincluded by\n"; + std::string msg = + cmStrCat("The uic process failed to compile\n ", Quoted(sourceFile), + "\ninto\n ", Quoted(outputFile), "\nincluded by\n"); for (auto const& item : Mapping->IncluderFiles) { msg += " "; msg += Quoted(item->FileName); @@ -1564,12 +1528,8 @@ bool cmQtAutoMocUic::Init(cmMakefile* makefile) if (length >= 2) { std::string::const_iterator itBeg = value.begin() + (pos + 1); std::string::const_iterator itEnd = itBeg + (length - 2); - { - std::string subValue(itBeg, itEnd); - std::vector list; - cmSystemTools::ExpandListArgument(subValue, list); - lists.push_back(std::move(list)); - } + lists.emplace_back( + cmSystemTools::ExpandedListArgument(std::string(itBeg, itEnd))); } pos += length; pos += ListSep.size(); @@ -1580,9 +1540,7 @@ bool cmQtAutoMocUic::Init(cmMakefile* makefile) auto InfoGetConfig = [makefile, this](const char* key) -> std::string { const char* valueConf = nullptr; { - std::string keyConf = key; - keyConf += '_'; - keyConf += InfoConfig(); + std::string keyConf = cmStrCat(key, '_', InfoConfig()); valueConf = makefile->GetDefinition(keyConf); } if (valueConf == nullptr) { @@ -1653,9 +1611,9 @@ bool cmQtAutoMocUic::Init(cmMakefile* makefile) return LogInfoError("CMake executable file name missing."); } if (!BaseConst_.CMakeExecutableTime.Load(BaseConst_.CMakeExecutable)) { - std::string error = "The CMake executable "; - error += Quoted(BaseConst_.CMakeExecutable); - error += " does not exist."; + std::string error = + cmStrCat("The CMake executable ", Quoted(BaseConst_.CMakeExecutable), + " does not exist."); return LogInfoError(error); } BaseConst_.ParseCacheFile = InfoGetConfig("AM_PARSE_CACHE_FILE"); @@ -1684,9 +1642,9 @@ bool cmQtAutoMocUic::Init(cmMakefile* makefile) MocConst_.Enabled = true; // Load the executable file time if (!MocConst_.ExecutableTime.Load(MocConst_.Executable)) { - std::string error = "The moc executable "; - error += Quoted(MocConst_.Executable); - error += " does not exist."; + std::string error = + cmStrCat("The moc executable ", Quoted(MocConst_.Executable), + " does not exist."); return LogInfoError(error); } for (std::string& sfl : InfoGetList("AM_MOC_SKIP")) { @@ -1752,9 +1710,9 @@ bool cmQtAutoMocUic::Init(cmMakefile* makefile) UicConst_.Enabled = true; // Load the executable file time if (!UicConst_.ExecutableTime.Load(UicConst_.Executable)) { - std::string error = "The uic executable "; - error += Quoted(UicConst_.Executable); - error += " does not exist."; + std::string error = + cmStrCat("The uic executable ", Quoted(UicConst_.Executable), + " does not exist."); return LogInfoError(error); } for (std::string& sfl : InfoGetList("AM_UIC_SKIP")) { diff --git a/Source/cmQtAutoRcc.cxx b/Source/cmQtAutoRcc.cxx index 59f632d..c75b2ca 100644 --- a/Source/cmQtAutoRcc.cxx +++ b/Source/cmQtAutoRcc.cxx @@ -36,9 +36,7 @@ bool cmQtAutoRcc::Init(cmMakefile* makefile) this](std::string const& key) -> std::string { const char* valueConf = nullptr; { - std::string keyConf = key; - keyConf += '_'; - keyConf += InfoConfig(); + std::string keyConf = cmStrCat(key, '_', InfoConfig()); valueConf = makefile->GetDefinition(keyConf); } if (valueConf == nullptr) { @@ -82,9 +80,8 @@ bool cmQtAutoRcc::Init(cmMakefile* makefile) // - Rcc executable RccExecutable_ = InfoGet("ARCC_RCC_EXECUTABLE"); if (!RccExecutableTime_.Load(RccExecutable_)) { - std::string error = "The rcc executable "; - error += Quoted(RccExecutable_); - error += " does not exist."; + std::string error = cmStrCat("The rcc executable ", Quoted(RccExecutable_), + " does not exist."); return LogInfoError(error); } RccListOptions_ = InfoGetList("ARCC_RCC_LIST_OPTIONS"); @@ -179,10 +176,8 @@ bool cmQtAutoRcc::Process() std::string cmQtAutoRcc::MultiConfigOutput() const { static std::string const suffix = "_CMAKE_"; - std::string res; - res += RccPathChecksum_; - res += '/'; - res += AppendFilenameSuffix(RccFileName_, suffix); + std::string res = cmStrCat(RccPathChecksum_, '/', + AppendFilenameSuffix(RccFileName_, suffix)); return res; } @@ -273,9 +268,7 @@ bool cmQtAutoRcc::SettingsFileWrite() Log().Info(GenT::RCC, "Writing settings file " + Quoted(SettingsFile_)); } // Write settings file - std::string content = "rcc:"; - content += SettingsString_; - content += '\n'; + std::string content = cmStrCat("rcc:", SettingsString_, '\n'); std::string error; if (!FileWrite(SettingsFile_, content, &error)) { Log().ErrorFile(GenT::RCC, SettingsFile_, @@ -403,10 +396,9 @@ bool cmQtAutoRcc::TestInfoFile() // Test if the rcc output file is older than the info file if (RccFileTime_.Older(InfoFileTime())) { if (Log().Verbose()) { - std::string reason = "Touching "; - reason += Quoted(RccFileOutput_); - reason += " because it is older than "; - reason += Quoted(InfoFile()); + std::string reason = + cmStrCat("Touching ", Quoted(RccFileOutput_), + " because it is older than ", Quoted(InfoFile())); Log().Info(GenT::RCC, reason); } // Touch build file @@ -457,10 +449,9 @@ bool cmQtAutoRcc::GenerateRcc() if (!result || (retVal != 0)) { // rcc process failed { - std::string err = "The rcc process failed to compile\n "; - err += Quoted(QrcFile_); - err += "\ninto\n "; - err += Quoted(RccFileOutput_); + std::string err = + cmStrCat("The rcc process failed to compile\n ", Quoted(QrcFile_), + "\ninto\n ", Quoted(RccFileOutput_)); Log().ErrorCommand(GenT::RCC, err, cmd, rccStdOut + rccStdErr); } cmSystemTools::RemoveFile(RccFileOutput_); @@ -482,12 +473,10 @@ bool cmQtAutoRcc::GenerateWrapper() // Generate a wrapper source file on demand if (IsMultiConfig()) { // Wrapper file content - std::string content; - content += "// This is an autogenerated configuration wrapper file.\n"; - content += "// Changes will be overwritten.\n"; - content += "#include <"; - content += MultiConfigOutput(); - content += ">\n"; + std::string content = + cmStrCat("// This is an autogenerated configuration wrapper file.\n", + "// Changes will be overwritten.\n", "#include <", + MultiConfigOutput(), ">\n"); // Compare with existing file content bool fileDiffers = true; https://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=d02a99d9d3aa8d8f33efbd3255c78d6b87a99a22 commit d02a99d9d3aa8d8f33efbd3255c78d6b87a99a22 Author: Sebastian Holtermann AuthorDate: Tue Aug 6 10:32:07 2019 +0200 Commit: Sebastian Holtermann CommitDate: Wed Aug 7 18:01:32 2019 +0200 Autogen: Modernize code to use cm::string_view for the info writer diff --git a/Source/cmQtAutoGenInitializer.cxx b/Source/cmQtAutoGenInitializer.cxx index da6094d..7e72fd6 100644 --- a/Source/cmQtAutoGenInitializer.cxx +++ b/Source/cmQtAutoGenInitializer.cxx @@ -156,30 +156,27 @@ std::string cmQtAutoGenInitializer::InfoWriter::ListJoin(IT it_begin, return res; } -std::string cmQtAutoGenInitializer::InfoWriter::ConfigKey( - const char* key, std::string const& config) +inline std::string cmQtAutoGenInitializer::InfoWriter::ConfigKey( + cm::string_view key, std::string const& config) { - std::string ckey = key; - ckey += '_'; - ckey += config; - return ckey; + return cmStrCat(key, "_", config); } -void cmQtAutoGenInitializer::InfoWriter::Write(const char* key, +void cmQtAutoGenInitializer::InfoWriter::Write(cm::string_view key, std::string const& value) { Ofs_ << "set(" << key << " " << cmOutputConverter::EscapeForCMake(value) << ")\n"; }; -void cmQtAutoGenInitializer::InfoWriter::WriteUInt(const char* key, +void cmQtAutoGenInitializer::InfoWriter::WriteUInt(cm::string_view key, unsigned int value) { Ofs_ << "set(" << key << " " << value << ")\n"; }; template -void cmQtAutoGenInitializer::InfoWriter::WriteStrings(const char* key, +void cmQtAutoGenInitializer::InfoWriter::WriteStrings(cm::string_view key, C const& container) { Ofs_ << "set(" << key << " \"" @@ -187,31 +184,29 @@ void cmQtAutoGenInitializer::InfoWriter::WriteStrings(const char* key, } void cmQtAutoGenInitializer::InfoWriter::WriteConfig( - const char* key, std::map const& map) + cm::string_view key, std::map const& map) { for (auto const& item : map) { - Write(ConfigKey(key, item.first).c_str(), item.second); + Write(ConfigKey(key, item.first), item.second); } }; template void cmQtAutoGenInitializer::InfoWriter::WriteConfigStrings( - const char* key, std::map const& map) + cm::string_view key, std::map const& map) { for (auto const& item : map) { - WriteStrings(ConfigKey(key, item.first).c_str(), item.second); + WriteStrings(ConfigKey(key, item.first), item.second); } } void cmQtAutoGenInitializer::InfoWriter::WriteNestedLists( - const char* key, std::vector> const& lists) + cm::string_view key, std::vector> const& lists) { std::vector seplist; - for (const std::vector& list : lists) { - std::string blist = "{"; - blist += ListJoin(list.begin(), list.end()); - blist += "}"; - seplist.push_back(std::move(blist)); + seplist.reserve(lists.size()); + for (std::vector const& list : lists) { + seplist.push_back(cmStrCat("{", ListJoin(list.begin(), list.end()), "}")); } Write(key, cmJoin(seplist, cmQtAutoGen::ListSep)); }; diff --git a/Source/cmQtAutoGenInitializer.h b/Source/cmQtAutoGenInitializer.h index eb0d35e..7d72cad 100644 --- a/Source/cmQtAutoGenInitializer.h +++ b/Source/cmQtAutoGenInitializer.h @@ -6,6 +6,7 @@ #include "cmConfigure.h" // IWYU pragma: keep #include "cmGeneratedFileStream.h" #include "cmQtAutoGen.h" +#include "cm_string_view.hxx" #include #include @@ -85,24 +86,24 @@ public: /// @return True if the file is open explicit operator bool() const { return static_cast(Ofs_); } - void Write(const char* text) { Ofs_ << text; } - void Write(const char* key, std::string const& value); - void WriteUInt(const char* key, unsigned int value); + void Write(cm::string_view text) { Ofs_ << text; } + void Write(cm::string_view, std::string const& value); + void WriteUInt(cm::string_view, unsigned int value); template - void WriteStrings(const char* key, C const& container); - void WriteConfig(const char* key, + void WriteStrings(cm::string_view, C const& container); + void WriteConfig(cm::string_view, std::map const& map); template - void WriteConfigStrings(const char* key, + void WriteConfigStrings(cm::string_view, std::map const& map); - void WriteNestedLists(const char* key, + void WriteNestedLists(cm::string_view, std::vector> const& lists); private: template static std::string ListJoin(IT it_begin, IT it_end); - static std::string ConfigKey(const char* key, std::string const& config); + static std::string ConfigKey(cm::string_view, std::string const& config); private: cmGeneratedFileStream Ofs_; https://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=2171f6ec0ea3ca373db94bc55d8b7db999de97cc commit 2171f6ec0ea3ca373db94bc55d8b7db999de97cc Author: Saleem Abdulrasool AuthorDate: Fri Aug 2 10:10:21 2019 -0700 Commit: Saleem Abdulrasool CommitDate: Mon Aug 5 17:29:41 2019 -0700 Swift: correct SONAME flag for Darwin targets Adjust the build rules for Swift to fix the SONAME handling for Darwin. diff --git a/Modules/CMakeSwiftInformation.cmake b/Modules/CMakeSwiftInformation.cmake index 58b0813..54e441c 100644 --- a/Modules/CMakeSwiftInformation.cmake +++ b/Modules/CMakeSwiftInformation.cmake @@ -18,7 +18,9 @@ if(CMAKE_Swift_COMPILER_ID) endif() set(CMAKE_INCLUDE_FLAG_Swift "-I ") -if(NOT CMAKE_SYSTEM_NAME STREQUAL Windows AND NOT CMAKE_SYSTEM_NAME STREQUAL Darwin) +if(CMAKE_SYSTEM_NAME STREQUAL Darwin) + set(CMAKE_SHARED_LIBRARY_SONAME_Swift_FLAG "-Xlinker -install_name -Xlinker ") +elseif(NOT CMAKE_SYSTEM_NAME STREQUAL Windows) set(CMAKE_SHARED_LIBRARY_SONAME_Swift_FLAG "-Xlinker -soname -Xlinker ") endif() ----------------------------------------------------------------------- Summary of changes: Modules/CMakeSwiftInformation.cmake | 4 +- Source/cmDefinitions.cxx | 61 ++++++----- Source/cmDefinitions.h | 16 +-- Source/cmQtAutoGen.cxx | 5 +- Source/cmQtAutoGenGlobalInitializer.cxx | 37 +++---- Source/cmQtAutoGenInitializer.cxx | 132 +++++++++-------------- Source/cmQtAutoGenInitializer.h | 17 +-- Source/cmQtAutoGenerator.cxx | 39 ++----- Source/cmQtAutoMocUic.cxx | 186 +++++++++++++------------------- Source/cmQtAutoRcc.cxx | 43 +++----- 10 files changed, 219 insertions(+), 321 deletions(-) hooks/post-receive -- CMake From kwrobot at kitware.com Fri Aug 9 10:49:27 2019 From: kwrobot at kitware.com (Kitware Robot) Date: Fri, 9 Aug 2019 10:49:27 -0400 (EDT) Subject: [Cmake-commits] CMake branch, master, updated. v3.15.2-619-g1996e01 Message-ID: <20190809144928.0086310F3B7@public.kitware.com> This is an automated email from the git hooks/post-receive script. It was generated because a ref change was pushed to the repository containing the project "CMake". The branch, master has been updated via 1996e0157826903f27f73825a01f83d53dc8fba4 (commit) via a7a5f376bcd7465c888801251e4f0175ef3a1c36 (commit) via b66b7464ab09420f150daaec7571da31dc361cc0 (commit) via 2b785875fbc9815b1fc528a90cf008a2b13f0084 (commit) via 9703c65718689e56bfa100f1965b6a83af87e090 (commit) via 64f987c174691982e1f01eadb2c76693ea674e52 (commit) from 1263b0884bbad60b4f21d70a59a11647d30d54a8 (commit) Those revisions listed above that are new to this repository have not appeared on any other notification email; so we list those revisions in full, below. - Log ----------------------------------------------------------------- https://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=1996e0157826903f27f73825a01f83d53dc8fba4 commit 1996e0157826903f27f73825a01f83d53dc8fba4 Merge: 1263b08 a7a5f37 Author: Brad King AuthorDate: Fri Aug 9 14:33:20 2019 +0000 Commit: Kitware Robot CommitDate: Fri Aug 9 10:39:36 2019 -0400 Merge topic 'cmFileCommand-refactoring' a7a5f376bc cmFileCommand: Use cmSubcommandTable b66b7464ab Introduce cmSubcommandTable 2b785875fb cmFileCommand: turn into free function 9703c65718 cmFileCommand: put subcommands in unnamed namespace 64f987c174 cmFileCommand: port to cmExecutionStatus Acked-by: Kitware Robot Merge-request: !3657 diff --cc Source/cmFileCopier.cxx index 71493bb,1ea824f..62f132d --- a/Source/cmFileCopier.cxx +++ b/Source/cmFileCopier.cxx @@@ -3,11 -3,10 +3,11 @@@ #include "cmFileCopier.h" + #include "cmExecutionStatus.h" #include "cmFSPermissions.h" - #include "cmFileCommand.h" #include "cmFileTimes.h" #include "cmMakefile.h" +#include "cmStringAlgorithms.h" #include "cmSystemTools.h" #include "cmsys/Directory.hxx" #include "cmsys/Glob.hxx" https://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=a7a5f376bcd7465c888801251e4f0175ef3a1c36 commit a7a5f376bcd7465c888801251e4f0175ef3a1c36 Author: Regina Pfeifer AuthorDate: Tue Aug 6 15:05:43 2019 +0200 Commit: Regina Pfeifer CommitDate: Tue Aug 6 17:21:52 2019 +0200 cmFileCommand: Use cmSubcommandTable diff --git a/Source/cmFileCommand.cxx b/Source/cmFileCommand.cxx index 3292dc0..ec03191 100644 --- a/Source/cmFileCommand.cxx +++ b/Source/cmFileCommand.cxx @@ -41,6 +41,7 @@ #include "cmRuntimeDependencyArchive.h" #include "cmState.h" #include "cmStringAlgorithms.h" +#include "cmSubcommandTable.h" #include "cmSystemTools.h" #include "cmTimestamp.h" #include "cm_sys_stat.h" @@ -87,8 +88,8 @@ std::string fix_file_url_windows(const std::string& url) } #endif -bool HandleWriteCommand(std::vector const& args, bool append, - cmExecutionStatus& status) +bool HandleWriteImpl(std::vector const& args, bool append, + cmExecutionStatus& status) { std::vector::const_iterator i = args.begin(); @@ -157,6 +158,18 @@ bool HandleWriteCommand(std::vector const& args, bool append, return true; } +bool HandleWriteCommand(std::vector const& args, + cmExecutionStatus& status) +{ + return HandleWriteImpl(args, false, status); +} + +bool HandleAppendCommand(std::vector const& args, + cmExecutionStatus& status) +{ + return HandleWriteImpl(args, true, status); +} + bool HandleReadCommand(std::vector const& args, cmExecutionStatus& status) { @@ -648,8 +661,8 @@ bool HandleStringsCommand(std::vector const& args, return true; } -bool HandleGlobCommand(std::vector const& args, bool recurse, - cmExecutionStatus& status) +bool HandleGlobImpl(std::vector const& args, bool recurse, + cmExecutionStatus& status) { // File commands has at least one argument assert(args.size() > 1); @@ -836,6 +849,18 @@ bool HandleGlobCommand(std::vector const& args, bool recurse, return true; } +bool HandleGlobCommand(std::vector const& args, + cmExecutionStatus& status) +{ + return HandleGlobImpl(args, false, status); +} + +bool HandleGlobRecurseCommand(std::vector const& args, + cmExecutionStatus& status) +{ + return HandleGlobImpl(args, true, status); +} + bool HandleMakeDirectoryCommand(std::vector const& args, cmExecutionStatus& status) { @@ -868,8 +893,8 @@ bool HandleMakeDirectoryCommand(std::vector const& args, return true; } -bool HandleTouchCommand(std::vector const& args, bool create, - cmExecutionStatus& status) +bool HandleTouchImpl(std::vector const& args, bool create, + cmExecutionStatus& status) { // File command has at least one argument assert(args.size() > 1); @@ -898,6 +923,18 @@ bool HandleTouchCommand(std::vector const& args, bool create, return true; } +bool HandleTouchCommand(std::vector const& args, + cmExecutionStatus& status) +{ + return HandleTouchImpl(args, true, status); +} + +bool HandleTouchNocreateCommand(std::vector const& args, + cmExecutionStatus& status) +{ + return HandleTouchImpl(args, false, status); +} + bool HandleDifferentCommand(std::vector const& args, cmExecutionStatus& status) { @@ -1296,8 +1333,8 @@ bool HandleRename(std::vector const& args, return true; } -bool HandleRemove(std::vector const& args, bool recurse, - cmExecutionStatus& status) +bool HandleRemoveImpl(std::vector const& args, bool recurse, + cmExecutionStatus& status) { std::string message; @@ -1327,6 +1364,18 @@ bool HandleRemove(std::vector const& args, bool recurse, return true; } +bool HandleRemove(std::vector const& args, + cmExecutionStatus& status) +{ + return HandleRemoveImpl(args, false, status); +} + +bool HandleRemoveRecurse(std::vector const& args, + cmExecutionStatus& status) +{ + return HandleRemoveImpl(args, true, status); +} + std::string ToNativePath(const std::string& path) { const auto& outPath = cmSystemTools::ConvertToOutputPath(path); @@ -1344,8 +1393,9 @@ std::string ToCMakePath(const std::string& path) return temp; } -bool HandleCMakePathCommand(std::vector const& args, - bool nativePath, cmExecutionStatus& status) +bool HandlePathCommand(std::vector const& args, + std::string (*convert)(std::string const&), + cmExecutionStatus& status) { if (args.size() != 3) { status.SetError("FILE([TO_CMAKE_PATH|TO_NATIVE_PATH] path result) must be " @@ -1359,12 +1409,23 @@ bool HandleCMakePathCommand(std::vector const& args, #endif std::vector path = cmSystemTools::SplitString(args[1], pathSep); - std::string value = cmJoin( - cmMakeRange(path).transform(nativePath ? ToNativePath : ToCMakePath), ";"); + std::string value = cmJoin(cmMakeRange(path).transform(convert), ";"); status.GetMakefile().AddDefinition(args[2], value); return true; } +bool HandleCMakePathCommand(std::vector const& args, + cmExecutionStatus& status) +{ + return HandlePathCommand(args, ToCMakePath, status); +} + +bool HandleNativePathCommand(std::vector const& args, + cmExecutionStatus& status) +{ + return HandlePathCommand(args, ToNativePath, status); +} + #if defined(CMAKE_BUILD_WITH_CMAKE) // Stuff for curl download/upload @@ -2777,109 +2838,51 @@ bool cmFileCommand(std::vector const& args, status.SetError("must be called with at least two arguments."); return false; } - std::string const& subCommand = args[0]; - if (subCommand == "WRITE") { - return HandleWriteCommand(args, false, status); - } - if (subCommand == "APPEND") { - return HandleWriteCommand(args, true, status); - } - if (subCommand == "DOWNLOAD") { - return HandleDownloadCommand(args, status); - } - if (subCommand == "UPLOAD") { - return HandleUploadCommand(args, status); - } - if (subCommand == "READ") { - return HandleReadCommand(args, status); - } - if (subCommand == "MD5" || subCommand == "SHA1" || subCommand == "SHA224" || - subCommand == "SHA256" || subCommand == "SHA384" || - subCommand == "SHA512" || subCommand == "SHA3_224" || - subCommand == "SHA3_256" || subCommand == "SHA3_384" || - subCommand == "SHA3_512") { - return HandleHashCommand(args, status); - } - if (subCommand == "STRINGS") { - return HandleStringsCommand(args, status); - } - if (subCommand == "GLOB") { - return HandleGlobCommand(args, false, status); - } - if (subCommand == "GLOB_RECURSE") { - return HandleGlobCommand(args, true, status); - } - if (subCommand == "MAKE_DIRECTORY") { - return HandleMakeDirectoryCommand(args, status); - } - if (subCommand == "RENAME") { - return HandleRename(args, status); - } - if (subCommand == "REMOVE") { - return HandleRemove(args, false, status); - } - if (subCommand == "REMOVE_RECURSE") { - return HandleRemove(args, true, status); - } - if (subCommand == "COPY") { - return HandleCopyCommand(args, status); - } - if (subCommand == "INSTALL") { - return HandleInstallCommand(args, status); - } - if (subCommand == "DIFFERENT") { - return HandleDifferentCommand(args, status); - } - if (subCommand == "RPATH_CHANGE" || subCommand == "CHRPATH") { - return HandleRPathChangeCommand(args, status); - } - if (subCommand == "RPATH_CHECK") { - return HandleRPathCheckCommand(args, status); - } - if (subCommand == "RPATH_REMOVE") { - return HandleRPathRemoveCommand(args, status); - } - if (subCommand == "READ_ELF") { - return HandleReadElfCommand(args, status); - } - if (subCommand == "RELATIVE_PATH") { - return HandleRelativePathCommand(args, status); - } - if (subCommand == "TO_CMAKE_PATH") { - return HandleCMakePathCommand(args, false, status); - } - if (subCommand == "TO_NATIVE_PATH") { - return HandleCMakePathCommand(args, true, status); - } - if (subCommand == "TOUCH") { - return HandleTouchCommand(args, true, status); - } - if (subCommand == "TOUCH_NOCREATE") { - return HandleTouchCommand(args, false, status); - } - if (subCommand == "TIMESTAMP") { - return HandleTimestampCommand(args, status); - } - if (subCommand == "GENERATE") { - return HandleGenerateCommand(args, status); - } - if (subCommand == "LOCK") { - return HandleLockCommand(args, status); - } - if (subCommand == "SIZE") { - return HandleSizeCommand(args, status); - } - if (subCommand == "READ_SYMLINK") { - return HandleReadSymlinkCommand(args, status); - } - if (subCommand == "CREATE_LINK") { - return HandleCreateLinkCommand(args, status); - } - if (subCommand == "GET_RUNTIME_DEPENDENCIES") { - return HandleGetRuntimeDependenciesCommand(args, status); - } - std::string e = "does not recognize sub-command " + subCommand; - status.SetError(e); - return false; + static cmSubcommandTable const subcommand{ + { "WRITE"_s, HandleWriteCommand }, + { "APPEND"_s, HandleAppendCommand }, + { "DOWNLOAD"_s, HandleDownloadCommand }, + { "UPLOAD"_s, HandleUploadCommand }, + { "READ"_s, HandleReadCommand }, + { "MD5"_s, HandleHashCommand }, + { "SHA1"_s, HandleHashCommand }, + { "SHA224"_s, HandleHashCommand }, + { "SHA256"_s, HandleHashCommand }, + { "SHA384"_s, HandleHashCommand }, + { "SHA512"_s, HandleHashCommand }, + { "SHA3_224"_s, HandleHashCommand }, + { "SHA3_256"_s, HandleHashCommand }, + { "SHA3_384"_s, HandleHashCommand }, + { "SHA3_512"_s, HandleHashCommand }, + { "STRINGS"_s, HandleStringsCommand }, + { "GLOB"_s, HandleGlobCommand }, + { "GLOB_RECURSE"_s, HandleGlobRecurseCommand }, + { "MAKE_DIRECTORY"_s, HandleMakeDirectoryCommand }, + { "RENAME"_s, HandleRename }, + { "REMOVE"_s, HandleRemove }, + { "REMOVE_RECURSE"_s, HandleRemoveRecurse }, + { "COPY"_s, HandleCopyCommand }, + { "INSTALL"_s, HandleInstallCommand }, + { "DIFFERENT"_s, HandleDifferentCommand }, + { "RPATH_CHANGE"_s, HandleRPathChangeCommand }, + { "CHRPATH"_s, HandleRPathChangeCommand }, + { "RPATH_CHECK"_s, HandleRPathCheckCommand }, + { "RPATH_REMOVE"_s, HandleRPathRemoveCommand }, + { "READ_ELF"_s, HandleReadElfCommand }, + { "RELATIVE_PATH"_s, HandleRelativePathCommand }, + { "TO_CMAKE_PATH"_s, HandleCMakePathCommand }, + { "TO_NATIVE_PATH"_s, HandleNativePathCommand }, + { "TOUCH"_s, HandleTouchCommand }, + { "TOUCH_NOCREATE"_s, HandleTouchNocreateCommand }, + { "TIMESTAMP"_s, HandleTimestampCommand }, + { "GENERATE"_s, HandleGenerateCommand }, + { "LOCK"_s, HandleLockCommand }, + { "SIZE"_s, HandleSizeCommand }, + { "READ_SYMLINK"_s, HandleReadSymlinkCommand }, + { "CREATE_LINK"_s, HandleCreateLinkCommand }, + { "GET_RUNTIME_DEPENDENCIES"_s, HandleGetRuntimeDependenciesCommand }, + }; + + return subcommand(args[0], args, status); } https://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=b66b7464ab09420f150daaec7571da31dc361cc0 commit b66b7464ab09420f150daaec7571da31dc361cc0 Author: Regina Pfeifer AuthorDate: Sun Apr 7 22:14:52 2019 +0200 Commit: Regina Pfeifer CommitDate: Tue Aug 6 17:21:52 2019 +0200 Introduce cmSubcommandTable diff --git a/Source/CMakeLists.txt b/Source/CMakeLists.txt index b1f4ca5..ee82ff5 100644 --- a/Source/CMakeLists.txt +++ b/Source/CMakeLists.txt @@ -639,6 +639,8 @@ set(SRCS cmStringReplaceHelper.cxx cmStringCommand.cxx cmStringCommand.h + cmSubcommandTable.cxx + cmSubcommandTable.h cmSubdirCommand.cxx cmSubdirCommand.h cmSubdirDependsCommand.cxx diff --git a/Source/cmSubcommandTable.cxx b/Source/cmSubcommandTable.cxx new file mode 100644 index 0000000..f6194f8 --- /dev/null +++ b/Source/cmSubcommandTable.cxx @@ -0,0 +1,31 @@ +/* Distributed under the OSI-approved BSD 3-Clause License. See accompanying + file Copyright.txt or https://cmake.org/licensing for details. */ +#include "cmSubcommandTable.h" + +#include + +#include "cmExecutionStatus.h" +#include "cmStringAlgorithms.h" + +cmSubcommandTable::cmSubcommandTable(std::initializer_list init) + : Impl(init.begin(), init.end()) +{ + std::sort(this->Impl.begin(), this->Impl.end(), + [](Elem const& left, Elem const& right) { + return left.first < right.first; + }); +} + +bool cmSubcommandTable::operator()(cm::string_view key, + std::vector const& args, + cmExecutionStatus& status) const +{ + auto const it = std::lower_bound( + this->Impl.begin(), this->Impl.end(), key, + [](Elem const& elem, cm::string_view k) { return elem.first < k; }); + if (it != this->Impl.end() && it->first == key) { + return it->second(args, status); + } + status.SetError(cmStrCat("does not recognize sub-command ", key)); + return false; +} diff --git a/Source/cmSubcommandTable.h b/Source/cmSubcommandTable.h new file mode 100644 index 0000000..21342bb --- /dev/null +++ b/Source/cmSubcommandTable.h @@ -0,0 +1,36 @@ +/* Distributed under the OSI-approved BSD 3-Clause License. See accompanying + file Copyright.txt or https://cmake.org/licensing for details. */ +#ifndef cmSubcommandTable_h +#define cmSubcommandTable_h + +#include "cmConfigure.h" // IWYU pragma: keep + +#include "cm_static_string_view.hxx" +#include "cm_string_view.hxx" + +#include +#include +#include +#include + +class cmExecutionStatus; + +class cmSubcommandTable +{ +public: + using Command = bool (*)(std::vector const&, + cmExecutionStatus&); + + using Elem = std::pair; + using InitElem = std::pair; + + cmSubcommandTable(std::initializer_list init); + + bool operator()(cm::string_view key, std::vector const& args, + cmExecutionStatus& status) const; + +private: + std::vector Impl; +}; + +#endif diff --git a/bootstrap b/bootstrap index 06e11b5..c97a5d4 100755 --- a/bootstrap +++ b/bootstrap @@ -426,6 +426,7 @@ CMAKE_CXX_SOURCES="\ cmStringAlgorithms \ cmStringReplaceHelper \ cmStringCommand \ + cmSubcommandTable \ cmSubdirCommand \ cmSystemTools \ cmTarget \ https://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=2b785875fbc9815b1fc528a90cf008a2b13f0084 commit 2b785875fbc9815b1fc528a90cf008a2b13f0084 Author: Regina Pfeifer AuthorDate: Tue Aug 6 12:25:12 2019 +0200 Commit: Regina Pfeifer CommitDate: Tue Aug 6 12:25:12 2019 +0200 cmFileCommand: turn into free function diff --git a/Source/cmCommands.cxx b/Source/cmCommands.cxx index f351ff8..a9be445 100644 --- a/Source/cmCommands.cxx +++ b/Source/cmCommands.cxx @@ -128,7 +128,7 @@ void GetScriptingCommands(cmState* state) cm::make_unique()); state->AddBuiltinCommand("execute_process", cm::make_unique()); - state->AddBuiltinCommand("file", cm::make_unique()); + state->AddBuiltinCommand("file", cmFileCommand); state->AddBuiltinCommand("find_file", cm::make_unique()); state->AddBuiltinCommand("find_library", cm::make_unique()); diff --git a/Source/cmFileCommand.cxx b/Source/cmFileCommand.cxx index 652e3c5..3292dc0 100644 --- a/Source/cmFileCommand.cxx +++ b/Source/cmFileCommand.cxx @@ -2770,8 +2770,8 @@ bool HandleGetRuntimeDependenciesCommand(std::vector const& args, } // namespace -bool cmFileCommand::InitialPass(std::vector const& args, - cmExecutionStatus& status) +bool cmFileCommand(std::vector const& args, + cmExecutionStatus& status) { if (args.size() < 2) { status.SetError("must be called with at least two arguments."); diff --git a/Source/cmFileCommand.h b/Source/cmFileCommand.h index b564540..8c9b219 100644 --- a/Source/cmFileCommand.h +++ b/Source/cmFileCommand.h @@ -8,33 +8,9 @@ #include #include -#include "cm_memory.hxx" - -#include "cmCommand.h" - class cmExecutionStatus; -/** \class cmFileCommand - * \brief Command for manipulation of files - * - */ -class cmFileCommand : public cmCommand -{ -public: - /** - * This is a virtual constructor for the command. - */ - std::unique_ptr Clone() override - { - return cm::make_unique(); - } - - /** - * This is called when the command is first encountered in - * the CMakeLists.txt file. - */ - bool InitialPass(std::vector const& args, - cmExecutionStatus& status) override; -}; +bool cmFileCommand(std::vector const& args, + cmExecutionStatus& status); #endif https://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=9703c65718689e56bfa100f1965b6a83af87e090 commit 9703c65718689e56bfa100f1965b6a83af87e090 Author: Daniel Pfeifer AuthorDate: Mon Jan 9 00:08:33 2017 +0100 Commit: Regina Pfeifer CommitDate: Tue Aug 6 12:21:04 2019 +0200 cmFileCommand: put subcommands in unnamed namespace diff --git a/Source/cmFileCommand.cxx b/Source/cmFileCommand.cxx index 5971846..652e3c5 100644 --- a/Source/cmFileCommand.cxx +++ b/Source/cmFileCommand.cxx @@ -60,10 +60,12 @@ # include #endif +namespace { + #if defined(_WIN32) // libcurl doesn't support file:// urls for unicode filenames on Windows. // Convert string from UTF-8 to ACP if this is a file:// URL. -static std::string fix_file_url_windows(const std::string& url) +std::string fix_file_url_windows(const std::string& url) { std::string ret = url; if (strncmp(url.c_str(), "file://", 7) == 0) { @@ -85,123 +87,8 @@ static std::string fix_file_url_windows(const std::string& url) } #endif -// cmLibraryCommand -bool cmFileCommand::InitialPass(std::vector const& args, - cmExecutionStatus& status) -{ - if (args.size() < 2) { - status.SetError("must be called with at least two arguments."); - return false; - } - std::string const& subCommand = args[0]; - if (subCommand == "WRITE") { - return this->HandleWriteCommand(args, false, status); - } - if (subCommand == "APPEND") { - return this->HandleWriteCommand(args, true, status); - } - if (subCommand == "DOWNLOAD") { - return this->HandleDownloadCommand(args, status); - } - if (subCommand == "UPLOAD") { - return this->HandleUploadCommand(args, status); - } - if (subCommand == "READ") { - return this->HandleReadCommand(args, status); - } - if (subCommand == "MD5" || subCommand == "SHA1" || subCommand == "SHA224" || - subCommand == "SHA256" || subCommand == "SHA384" || - subCommand == "SHA512" || subCommand == "SHA3_224" || - subCommand == "SHA3_256" || subCommand == "SHA3_384" || - subCommand == "SHA3_512") { - return this->HandleHashCommand(args, status); - } - if (subCommand == "STRINGS") { - return this->HandleStringsCommand(args, status); - } - if (subCommand == "GLOB") { - return this->HandleGlobCommand(args, false, status); - } - if (subCommand == "GLOB_RECURSE") { - return this->HandleGlobCommand(args, true, status); - } - if (subCommand == "MAKE_DIRECTORY") { - return this->HandleMakeDirectoryCommand(args, status); - } - if (subCommand == "RENAME") { - return this->HandleRename(args, status); - } - if (subCommand == "REMOVE") { - return this->HandleRemove(args, false, status); - } - if (subCommand == "REMOVE_RECURSE") { - return this->HandleRemove(args, true, status); - } - if (subCommand == "COPY") { - return this->HandleCopyCommand(args, status); - } - if (subCommand == "INSTALL") { - return this->HandleInstallCommand(args, status); - } - if (subCommand == "DIFFERENT") { - return this->HandleDifferentCommand(args, status); - } - if (subCommand == "RPATH_CHANGE" || subCommand == "CHRPATH") { - return this->HandleRPathChangeCommand(args, status); - } - if (subCommand == "RPATH_CHECK") { - return this->HandleRPathCheckCommand(args, status); - } - if (subCommand == "RPATH_REMOVE") { - return this->HandleRPathRemoveCommand(args, status); - } - if (subCommand == "READ_ELF") { - return this->HandleReadElfCommand(args, status); - } - if (subCommand == "RELATIVE_PATH") { - return this->HandleRelativePathCommand(args, status); - } - if (subCommand == "TO_CMAKE_PATH") { - return this->HandleCMakePathCommand(args, false, status); - } - if (subCommand == "TO_NATIVE_PATH") { - return this->HandleCMakePathCommand(args, true, status); - } - if (subCommand == "TOUCH") { - return this->HandleTouchCommand(args, true, status); - } - if (subCommand == "TOUCH_NOCREATE") { - return this->HandleTouchCommand(args, false, status); - } - if (subCommand == "TIMESTAMP") { - return this->HandleTimestampCommand(args, status); - } - if (subCommand == "GENERATE") { - return this->HandleGenerateCommand(args, status); - } - if (subCommand == "LOCK") { - return this->HandleLockCommand(args, status); - } - if (subCommand == "SIZE") { - return this->HandleSizeCommand(args, status); - } - if (subCommand == "READ_SYMLINK") { - return this->HandleReadSymlinkCommand(args, status); - } - if (subCommand == "CREATE_LINK") { - return this->HandleCreateLinkCommand(args, status); - } - if (subCommand == "GET_RUNTIME_DEPENDENCIES") { - return this->HandleGetRuntimeDependenciesCommand(args, status); - } - - std::string e = "does not recognize sub-command " + subCommand; - status.SetError(e); - return false; -} - -bool cmFileCommand::HandleWriteCommand(std::vector const& args, - bool append, cmExecutionStatus& status) +bool HandleWriteCommand(std::vector const& args, bool append, + cmExecutionStatus& status) { std::vector::const_iterator i = args.begin(); @@ -270,8 +157,8 @@ bool cmFileCommand::HandleWriteCommand(std::vector const& args, return true; } -bool cmFileCommand::HandleReadCommand(std::vector const& args, - cmExecutionStatus& status) +bool HandleReadCommand(std::vector const& args, + cmExecutionStatus& status) { if (args.size() < 3) { status.SetError("READ must be called with at least two additional " @@ -372,8 +259,8 @@ bool cmFileCommand::HandleReadCommand(std::vector const& args, return true; } -bool cmFileCommand::HandleHashCommand(std::vector const& args, - cmExecutionStatus& status) +bool HandleHashCommand(std::vector const& args, + cmExecutionStatus& status) { #if defined(CMAKE_BUILD_WITH_CMAKE) if (args.size() != 3) { @@ -404,8 +291,8 @@ bool cmFileCommand::HandleHashCommand(std::vector const& args, #endif } -bool cmFileCommand::HandleStringsCommand(std::vector const& args, - cmExecutionStatus& status) +bool HandleStringsCommand(std::vector const& args, + cmExecutionStatus& status) { if (args.size() < 3) { status.SetError("STRINGS requires a file name and output variable"); @@ -761,8 +648,8 @@ bool cmFileCommand::HandleStringsCommand(std::vector const& args, return true; } -bool cmFileCommand::HandleGlobCommand(std::vector const& args, - bool recurse, cmExecutionStatus& status) +bool HandleGlobCommand(std::vector const& args, bool recurse, + cmExecutionStatus& status) { // File commands has at least one argument assert(args.size() > 1); @@ -949,8 +836,8 @@ bool cmFileCommand::HandleGlobCommand(std::vector const& args, return true; } -bool cmFileCommand::HandleMakeDirectoryCommand( - std::vector const& args, cmExecutionStatus& status) +bool HandleMakeDirectoryCommand(std::vector const& args, + cmExecutionStatus& status) { // File command has at least one argument assert(args.size() > 1); @@ -981,8 +868,8 @@ bool cmFileCommand::HandleMakeDirectoryCommand( return true; } -bool cmFileCommand::HandleTouchCommand(std::vector const& args, - bool create, cmExecutionStatus& status) +bool HandleTouchCommand(std::vector const& args, bool create, + cmExecutionStatus& status) { // File command has at least one argument assert(args.size() > 1); @@ -1011,8 +898,8 @@ bool cmFileCommand::HandleTouchCommand(std::vector const& args, return true; } -bool cmFileCommand::HandleDifferentCommand( - std::vector const& args, cmExecutionStatus& status) +bool HandleDifferentCommand(std::vector const& args, + cmExecutionStatus& status) { /* FILE(DIFFERENT FILES ) @@ -1065,15 +952,15 @@ bool cmFileCommand::HandleDifferentCommand( return true; } -bool cmFileCommand::HandleCopyCommand(std::vector const& args, - cmExecutionStatus& status) +bool HandleCopyCommand(std::vector const& args, + cmExecutionStatus& status) { cmFileCopier copier(status); return copier.Run(args); } -bool cmFileCommand::HandleRPathChangeCommand( - std::vector const& args, cmExecutionStatus& status) +bool HandleRPathChangeCommand(std::vector const& args, + cmExecutionStatus& status) { // Evaluate arguments. std::string file; @@ -1163,8 +1050,8 @@ bool cmFileCommand::HandleRPathChangeCommand( return success; } -bool cmFileCommand::HandleRPathRemoveCommand( - std::vector const& args, cmExecutionStatus& status) +bool HandleRPathRemoveCommand(std::vector const& args, + cmExecutionStatus& status) { // Evaluate arguments. std::string file; @@ -1223,8 +1110,8 @@ bool cmFileCommand::HandleRPathRemoveCommand( return success; } -bool cmFileCommand::HandleRPathCheckCommand( - std::vector const& args, cmExecutionStatus& status) +bool HandleRPathCheckCommand(std::vector const& args, + cmExecutionStatus& status) { // Evaluate arguments. std::string file; @@ -1274,8 +1161,8 @@ bool cmFileCommand::HandleRPathCheckCommand( return true; } -bool cmFileCommand::HandleReadElfCommand(std::vector const& args, - cmExecutionStatus& status) +bool HandleReadElfCommand(std::vector const& args, + cmExecutionStatus& status) { if (args.size() < 4) { status.SetError("READ_ELF must be called with at least three additional " @@ -1335,15 +1222,15 @@ bool cmFileCommand::HandleReadElfCommand(std::vector const& args, #endif } -bool cmFileCommand::HandleInstallCommand(std::vector const& args, - cmExecutionStatus& status) +bool HandleInstallCommand(std::vector const& args, + cmExecutionStatus& status) { cmFileInstaller installer(status); return installer.Run(args); } -bool cmFileCommand::HandleRelativePathCommand( - std::vector const& args, cmExecutionStatus& status) +bool HandleRelativePathCommand(std::vector const& args, + cmExecutionStatus& status) { if (args.size() != 4) { status.SetError("RELATIVE_PATH called with incorrect number of arguments"); @@ -1373,8 +1260,8 @@ bool cmFileCommand::HandleRelativePathCommand( return true; } -bool cmFileCommand::HandleRename(std::vector const& args, - cmExecutionStatus& status) +bool HandleRename(std::vector const& args, + cmExecutionStatus& status) { if (args.size() != 3) { status.SetError("RENAME given incorrect number of arguments."); @@ -1409,8 +1296,8 @@ bool cmFileCommand::HandleRename(std::vector const& args, return true; } -bool cmFileCommand::HandleRemove(std::vector const& args, - bool recurse, cmExecutionStatus& status) +bool HandleRemove(std::vector const& args, bool recurse, + cmExecutionStatus& status) { std::string message; @@ -1440,7 +1327,6 @@ bool cmFileCommand::HandleRemove(std::vector const& args, return true; } -namespace { std::string ToNativePath(const std::string& path) { const auto& outPath = cmSystemTools::ConvertToOutputPath(path); @@ -1457,11 +1343,9 @@ std::string ToCMakePath(const std::string& path) cmSystemTools::ConvertToUnixSlashes(temp); return temp; } -} -bool cmFileCommand::HandleCMakePathCommand( - std::vector const& args, bool nativePath, - cmExecutionStatus& status) +bool HandleCMakePathCommand(std::vector const& args, + bool nativePath, cmExecutionStatus& status) { if (args.size() != 3) { status.SetError("FILE([TO_CMAKE_PATH|TO_NATIVE_PATH] path result) must be " @@ -1486,8 +1370,6 @@ bool cmFileCommand::HandleCMakePathCommand( // Stuff for curl download/upload typedef std::vector cmFileCommandVectorOfChar; -namespace { - size_t cmWriteToFileCallback(void* ptr, size_t size, size_t nmemb, void* data) { int realsize = static_cast(size * nmemb); @@ -1538,11 +1420,10 @@ size_t cmFileCommandCurlDebugCallback(CURL*, curl_infotype type, char* chPtr, class cURLProgressHelper { public: - cURLProgressHelper(cmFileCommand* fc, const char* text) + cURLProgressHelper(cmMakefile* mf, const char* text) + : Makefile(mf) + , Text(text) { - this->CurrentPercentage = -1; - this->FileCommand = fc; - this->Text = text; } bool UpdatePercentage(double value, double total, std::string& status) @@ -1569,11 +1450,11 @@ public: return updated; } - cmFileCommand* GetFileCommand() { return this->FileCommand; } + cmMakefile* GetMakefile() { return this->Makefile; } private: - long CurrentPercentage; - cmFileCommand* FileCommand; + long CurrentPercentage = -1; + cmMakefile* Makefile; std::string Text; }; @@ -1587,8 +1468,7 @@ int cmFileDownloadProgressCallback(void* clientp, double dltotal, double dlnow, std::string status; if (helper->UpdatePercentage(dlnow, dltotal, status)) { - cmFileCommand* fc = helper->GetFileCommand(); - cmMakefile* mf = fc->GetMakefile(); + cmMakefile* mf = helper->GetMakefile(); mf->DisplayStatus(status, -1); } @@ -1605,16 +1485,12 @@ int cmFileUploadProgressCallback(void* clientp, double dltotal, double dlnow, std::string status; if (helper->UpdatePercentage(ulnow, ultotal, status)) { - cmFileCommand* fc = helper->GetFileCommand(); - cmMakefile* mf = fc->GetMakefile(); + cmMakefile* mf = helper->GetMakefile(); mf->DisplayStatus(status, -1); } return 0; } -} - -namespace { class cURLEasyGuard { @@ -1639,7 +1515,7 @@ public: private: ::CURL* Easy; }; -} + #endif #define check_curl_result(result, errstr) \ @@ -1652,8 +1528,8 @@ private: } \ } while (false) -bool cmFileCommand::HandleDownloadCommand(std::vector const& args, - cmExecutionStatus& status) +bool HandleDownloadCommand(std::vector const& args, + cmExecutionStatus& status) { #if defined(CMAKE_BUILD_WITH_CMAKE) std::vector::const_iterator i = args.begin(); @@ -1930,7 +1806,7 @@ bool cmFileCommand::HandleDownloadCommand(std::vector const& args, // scope intentionally, rather than inside the "if(showProgress)" // block... // - cURLProgressHelper helper(this, "download"); + cURLProgressHelper helper(&status.GetMakefile(), "download"); if (showProgress) { res = ::curl_easy_setopt(curl, CURLOPT_NOPROGRESS, 0); @@ -2021,8 +1897,8 @@ bool cmFileCommand::HandleDownloadCommand(std::vector const& args, #endif } -bool cmFileCommand::HandleUploadCommand(std::vector const& args, - cmExecutionStatus& status) +bool HandleUploadCommand(std::vector const& args, + cmExecutionStatus& status) { #if defined(CMAKE_BUILD_WITH_CMAKE) if (args.size() < 3) { @@ -2201,7 +2077,7 @@ bool cmFileCommand::HandleUploadCommand(std::vector const& args, // scope intentionally, rather than inside the "if(showProgress)" // block... // - cURLProgressHelper helper(this, "upload"); + cURLProgressHelper helper(&status.GetMakefile(), "upload"); if (showProgress) { res = ::curl_easy_setopt(curl, CURLOPT_NOPROGRESS, 0); @@ -2293,11 +2169,10 @@ bool cmFileCommand::HandleUploadCommand(std::vector const& args, #endif } -void cmFileCommand::AddEvaluationFile(const std::string& inputName, - const std::string& outputExpr, - const std::string& condition, - bool inputIsContent, - cmExecutionStatus& status) +void AddEvaluationFile(const std::string& inputName, + const std::string& outputExpr, + const std::string& condition, bool inputIsContent, + cmExecutionStatus& status) { cmListFileBacktrace lfbt = status.GetMakefile().GetBacktrace(); @@ -2313,8 +2188,8 @@ void cmFileCommand::AddEvaluationFile(const std::string& inputName, inputName, std::move(outputCge), std::move(conditionCge), inputIsContent); } -bool cmFileCommand::HandleGenerateCommand(std::vector const& args, - cmExecutionStatus& status) +bool HandleGenerateCommand(std::vector const& args, + cmExecutionStatus& status) { if (args.size() < 5) { status.SetError("Incorrect arguments to GENERATE subcommand."); @@ -2349,12 +2224,12 @@ bool cmFileCommand::HandleGenerateCommand(std::vector const& args, } std::string input = args[4]; - this->AddEvaluationFile(input, output, condition, inputIsContent, status); + AddEvaluationFile(input, output, condition, inputIsContent, status); return true; } -bool cmFileCommand::HandleLockCommand(std::vector const& args, - cmExecutionStatus& status) +bool HandleLockCommand(std::vector const& args, + cmExecutionStatus& status) { #if defined(CMAKE_BUILD_WITH_CMAKE) // Default values @@ -2515,8 +2390,8 @@ bool cmFileCommand::HandleLockCommand(std::vector const& args, #endif } -bool cmFileCommand::HandleTimestampCommand( - std::vector const& args, cmExecutionStatus& status) +bool HandleTimestampCommand(std::vector const& args, + cmExecutionStatus& status) { if (args.size() < 3) { status.SetError("sub-command TIMESTAMP requires at least two arguments."); @@ -2558,8 +2433,8 @@ bool cmFileCommand::HandleTimestampCommand( return true; } -bool cmFileCommand::HandleSizeCommand(std::vector const& args, - cmExecutionStatus& status) +bool HandleSizeCommand(std::vector const& args, + cmExecutionStatus& status) { if (args.size() != 3) { std::ostringstream e; @@ -2587,8 +2462,8 @@ bool cmFileCommand::HandleSizeCommand(std::vector const& args, return true; } -bool cmFileCommand::HandleReadSymlinkCommand( - std::vector const& args, cmExecutionStatus& status) +bool HandleReadSymlinkCommand(std::vector const& args, + cmExecutionStatus& status) { if (args.size() != 3) { std::ostringstream e; @@ -2614,8 +2489,8 @@ bool cmFileCommand::HandleReadSymlinkCommand( return true; } -bool cmFileCommand::HandleCreateLinkCommand( - std::vector const& args, cmExecutionStatus& status) +bool HandleCreateLinkCommand(std::vector const& args, + cmExecutionStatus& status) { if (args.size() < 3) { status.SetError("CREATE_LINK must be called with at least two additional " @@ -2724,8 +2599,8 @@ bool cmFileCommand::HandleCreateLinkCommand( return true; } -bool cmFileCommand::HandleGetRuntimeDependenciesCommand( - std::vector const& args, cmExecutionStatus& status) +bool HandleGetRuntimeDependenciesCommand(std::vector const& args, + cmExecutionStatus& status) { static const std::set supportedPlatforms = { "Windows", "Linux", "Darwin" }; @@ -2811,7 +2686,7 @@ bool cmFileCommand::HandleGetRuntimeDependenciesCommand( } cmRuntimeDependencyArchive archive( - this, parsedArgs.Directories, parsedArgs.BundleExecutable, + status, parsedArgs.Directories, parsedArgs.BundleExecutable, parsedArgs.PreIncludeRegexes, parsedArgs.PreExcludeRegexes, parsedArgs.PostIncludeRegexes, parsedArgs.PostExcludeRegexes); if (!archive.Prepare()) { @@ -2892,3 +2767,119 @@ bool cmFileCommand::HandleGetRuntimeDependenciesCommand( } return true; } + +} // namespace + +bool cmFileCommand::InitialPass(std::vector const& args, + cmExecutionStatus& status) +{ + if (args.size() < 2) { + status.SetError("must be called with at least two arguments."); + return false; + } + std::string const& subCommand = args[0]; + if (subCommand == "WRITE") { + return HandleWriteCommand(args, false, status); + } + if (subCommand == "APPEND") { + return HandleWriteCommand(args, true, status); + } + if (subCommand == "DOWNLOAD") { + return HandleDownloadCommand(args, status); + } + if (subCommand == "UPLOAD") { + return HandleUploadCommand(args, status); + } + if (subCommand == "READ") { + return HandleReadCommand(args, status); + } + if (subCommand == "MD5" || subCommand == "SHA1" || subCommand == "SHA224" || + subCommand == "SHA256" || subCommand == "SHA384" || + subCommand == "SHA512" || subCommand == "SHA3_224" || + subCommand == "SHA3_256" || subCommand == "SHA3_384" || + subCommand == "SHA3_512") { + return HandleHashCommand(args, status); + } + if (subCommand == "STRINGS") { + return HandleStringsCommand(args, status); + } + if (subCommand == "GLOB") { + return HandleGlobCommand(args, false, status); + } + if (subCommand == "GLOB_RECURSE") { + return HandleGlobCommand(args, true, status); + } + if (subCommand == "MAKE_DIRECTORY") { + return HandleMakeDirectoryCommand(args, status); + } + if (subCommand == "RENAME") { + return HandleRename(args, status); + } + if (subCommand == "REMOVE") { + return HandleRemove(args, false, status); + } + if (subCommand == "REMOVE_RECURSE") { + return HandleRemove(args, true, status); + } + if (subCommand == "COPY") { + return HandleCopyCommand(args, status); + } + if (subCommand == "INSTALL") { + return HandleInstallCommand(args, status); + } + if (subCommand == "DIFFERENT") { + return HandleDifferentCommand(args, status); + } + if (subCommand == "RPATH_CHANGE" || subCommand == "CHRPATH") { + return HandleRPathChangeCommand(args, status); + } + if (subCommand == "RPATH_CHECK") { + return HandleRPathCheckCommand(args, status); + } + if (subCommand == "RPATH_REMOVE") { + return HandleRPathRemoveCommand(args, status); + } + if (subCommand == "READ_ELF") { + return HandleReadElfCommand(args, status); + } + if (subCommand == "RELATIVE_PATH") { + return HandleRelativePathCommand(args, status); + } + if (subCommand == "TO_CMAKE_PATH") { + return HandleCMakePathCommand(args, false, status); + } + if (subCommand == "TO_NATIVE_PATH") { + return HandleCMakePathCommand(args, true, status); + } + if (subCommand == "TOUCH") { + return HandleTouchCommand(args, true, status); + } + if (subCommand == "TOUCH_NOCREATE") { + return HandleTouchCommand(args, false, status); + } + if (subCommand == "TIMESTAMP") { + return HandleTimestampCommand(args, status); + } + if (subCommand == "GENERATE") { + return HandleGenerateCommand(args, status); + } + if (subCommand == "LOCK") { + return HandleLockCommand(args, status); + } + if (subCommand == "SIZE") { + return HandleSizeCommand(args, status); + } + if (subCommand == "READ_SYMLINK") { + return HandleReadSymlinkCommand(args, status); + } + if (subCommand == "CREATE_LINK") { + return HandleCreateLinkCommand(args, status); + } + if (subCommand == "GET_RUNTIME_DEPENDENCIES") { + return HandleGetRuntimeDependenciesCommand(args, status); + } + + std::string e = "does not recognize sub-command " + subCommand; + status.SetError(e); + return false; +} diff --git a/Source/cmFileCommand.h b/Source/cmFileCommand.h index e33c576..b564540 100644 --- a/Source/cmFileCommand.h +++ b/Source/cmFileCommand.h @@ -35,71 +35,6 @@ public: */ bool InitialPass(std::vector const& args, cmExecutionStatus& status) override; - -protected: - bool HandleRename(std::vector const& args, - cmExecutionStatus& status); - bool HandleRemove(std::vector const& args, bool recurse, - cmExecutionStatus& status); - bool HandleWriteCommand(std::vector const& args, bool append, - cmExecutionStatus& status); - bool HandleReadCommand(std::vector const& args, - cmExecutionStatus& status); - bool HandleHashCommand(std::vector const& args, - cmExecutionStatus& status); - bool HandleStringsCommand(std::vector const& args, - cmExecutionStatus& status); - bool HandleGlobCommand(std::vector const& args, bool recurse, - cmExecutionStatus& status); - bool HandleTouchCommand(std::vector const& args, bool create, - cmExecutionStatus& status); - bool HandleMakeDirectoryCommand(std::vector const& args, - cmExecutionStatus& status); - - bool HandleRelativePathCommand(std::vector const& args, - cmExecutionStatus& status); - bool HandleCMakePathCommand(std::vector const& args, - bool nativePath, cmExecutionStatus& status); - bool HandleReadElfCommand(std::vector const& args, - cmExecutionStatus& status); - bool HandleRPathChangeCommand(std::vector const& args, - cmExecutionStatus& status); - bool HandleRPathCheckCommand(std::vector const& args, - cmExecutionStatus& status); - bool HandleRPathRemoveCommand(std::vector const& args, - cmExecutionStatus& status); - bool HandleDifferentCommand(std::vector const& args, - cmExecutionStatus& status); - - bool HandleCopyCommand(std::vector const& args, - cmExecutionStatus& status); - bool HandleInstallCommand(std::vector const& args, - cmExecutionStatus& status); - bool HandleDownloadCommand(std::vector const& args, - cmExecutionStatus& status); - bool HandleUploadCommand(std::vector const& args, - cmExecutionStatus& status); - - bool HandleTimestampCommand(std::vector const& args, - cmExecutionStatus& status); - bool HandleGenerateCommand(std::vector const& args, - cmExecutionStatus& status); - bool HandleLockCommand(std::vector const& args, - cmExecutionStatus& status); - bool HandleSizeCommand(std::vector const& args, - cmExecutionStatus& status); - bool HandleReadSymlinkCommand(std::vector const& args, - cmExecutionStatus& status); - bool HandleCreateLinkCommand(std::vector const& args, - cmExecutionStatus& status); - bool HandleGetRuntimeDependenciesCommand( - std::vector const& args, cmExecutionStatus& status); - -private: - void AddEvaluationFile(const std::string& inputName, - const std::string& outputExpr, - const std::string& condition, bool inputIsContent, - cmExecutionStatus& status); }; #endif diff --git a/Source/cmRuntimeDependencyArchive.cxx b/Source/cmRuntimeDependencyArchive.cxx index 45aff69..ca85287 100644 --- a/Source/cmRuntimeDependencyArchive.cxx +++ b/Source/cmRuntimeDependencyArchive.cxx @@ -6,7 +6,7 @@ #include "cmBinUtilsLinuxELFLinker.h" #include "cmBinUtilsMacOSMachOLinker.h" #include "cmBinUtilsWindowsPELinker.h" -#include "cmCommand.h" +#include "cmExecutionStatus.h" #include "cmMakefile.h" #include "cmStateTypes.h" #include "cmSystemTools.h" @@ -108,13 +108,13 @@ static cmsys::RegularExpression TransformCompile(const std::string& str) } cmRuntimeDependencyArchive::cmRuntimeDependencyArchive( - cmCommand* command, std::vector searchDirectories, + cmExecutionStatus& status, std::vector searchDirectories, std::string bundleExecutable, const std::vector& preIncludeRegexes, const std::vector& preExcludeRegexes, const std::vector& postIncludeRegexes, const std::vector& postExcludeRegexes) - : Command(command) + : Status(status) , SearchDirectories(std::move(searchDirectories)) , BundleExecutable(std::move(bundleExecutable)) , PreIncludeRegexes(preIncludeRegexes.size()) @@ -190,7 +190,7 @@ bool cmRuntimeDependencyArchive::GetRuntimeDependencies( void cmRuntimeDependencyArchive::SetError(const std::string& e) { - this->Command->SetError(e); + this->Status.SetError(e); } std::string cmRuntimeDependencyArchive::GetBundleExecutable() @@ -361,7 +361,7 @@ void cmRuntimeDependencyArchive::AddUnresolvedPath(const std::string& name) cmMakefile* cmRuntimeDependencyArchive::GetMakefile() { - return this->Command->GetMakefile(); + return &this->Status.GetMakefile(); } const std::map>& diff --git a/Source/cmRuntimeDependencyArchive.h b/Source/cmRuntimeDependencyArchive.h index 67efec7..e063121 100644 --- a/Source/cmRuntimeDependencyArchive.h +++ b/Source/cmRuntimeDependencyArchive.h @@ -14,14 +14,14 @@ #include #include -class cmCommand; +class cmExecutionStatus; class cmMakefile; class cmRuntimeDependencyArchive { public: explicit cmRuntimeDependencyArchive( - cmCommand* command, std::vector searchDirectories, + cmExecutionStatus& status, std::vector searchDirectories, std::string bundleExecutable, const std::vector& preIncludeRegexes, const std::vector& preExcludeRegexes, @@ -51,7 +51,7 @@ public: const std::set& GetUnresolvedPaths(); private: - cmCommand* Command; + cmExecutionStatus& Status; std::unique_ptr Linker; std::string GetRuntimeDependenciesTool; https://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=64f987c174691982e1f01eadb2c76693ea674e52 commit 64f987c174691982e1f01eadb2c76693ea674e52 Author: Daniel Pfeifer AuthorDate: Sun Jan 8 23:47:29 2017 +0100 Commit: Regina Pfeifer CommitDate: Tue Aug 6 11:42:25 2019 +0200 cmFileCommand: port to cmExecutionStatus diff --git a/Source/cmFileCommand.cxx b/Source/cmFileCommand.cxx index 22f0d1f..5971846 100644 --- a/Source/cmFileCommand.cxx +++ b/Source/cmFileCommand.cxx @@ -25,6 +25,7 @@ #include "cmAlgorithms.h" #include "cmArgumentParser.h" #include "cmCryptoHash.h" +#include "cmExecutionStatus.h" #include "cmFileCopier.h" #include "cmFileInstaller.h" #include "cmFileLockPool.h" @@ -86,121 +87,121 @@ static std::string fix_file_url_windows(const std::string& url) // cmLibraryCommand bool cmFileCommand::InitialPass(std::vector const& args, - cmExecutionStatus&) + cmExecutionStatus& status) { if (args.size() < 2) { - this->SetError("must be called with at least two arguments."); + status.SetError("must be called with at least two arguments."); return false; } std::string const& subCommand = args[0]; if (subCommand == "WRITE") { - return this->HandleWriteCommand(args, false); + return this->HandleWriteCommand(args, false, status); } if (subCommand == "APPEND") { - return this->HandleWriteCommand(args, true); + return this->HandleWriteCommand(args, true, status); } if (subCommand == "DOWNLOAD") { - return this->HandleDownloadCommand(args); + return this->HandleDownloadCommand(args, status); } if (subCommand == "UPLOAD") { - return this->HandleUploadCommand(args); + return this->HandleUploadCommand(args, status); } if (subCommand == "READ") { - return this->HandleReadCommand(args); + return this->HandleReadCommand(args, status); } if (subCommand == "MD5" || subCommand == "SHA1" || subCommand == "SHA224" || subCommand == "SHA256" || subCommand == "SHA384" || subCommand == "SHA512" || subCommand == "SHA3_224" || subCommand == "SHA3_256" || subCommand == "SHA3_384" || subCommand == "SHA3_512") { - return this->HandleHashCommand(args); + return this->HandleHashCommand(args, status); } if (subCommand == "STRINGS") { - return this->HandleStringsCommand(args); + return this->HandleStringsCommand(args, status); } if (subCommand == "GLOB") { - return this->HandleGlobCommand(args, false); + return this->HandleGlobCommand(args, false, status); } if (subCommand == "GLOB_RECURSE") { - return this->HandleGlobCommand(args, true); + return this->HandleGlobCommand(args, true, status); } if (subCommand == "MAKE_DIRECTORY") { - return this->HandleMakeDirectoryCommand(args); + return this->HandleMakeDirectoryCommand(args, status); } if (subCommand == "RENAME") { - return this->HandleRename(args); + return this->HandleRename(args, status); } if (subCommand == "REMOVE") { - return this->HandleRemove(args, false); + return this->HandleRemove(args, false, status); } if (subCommand == "REMOVE_RECURSE") { - return this->HandleRemove(args, true); + return this->HandleRemove(args, true, status); } if (subCommand == "COPY") { - return this->HandleCopyCommand(args); + return this->HandleCopyCommand(args, status); } if (subCommand == "INSTALL") { - return this->HandleInstallCommand(args); + return this->HandleInstallCommand(args, status); } if (subCommand == "DIFFERENT") { - return this->HandleDifferentCommand(args); + return this->HandleDifferentCommand(args, status); } if (subCommand == "RPATH_CHANGE" || subCommand == "CHRPATH") { - return this->HandleRPathChangeCommand(args); + return this->HandleRPathChangeCommand(args, status); } if (subCommand == "RPATH_CHECK") { - return this->HandleRPathCheckCommand(args); + return this->HandleRPathCheckCommand(args, status); } if (subCommand == "RPATH_REMOVE") { - return this->HandleRPathRemoveCommand(args); + return this->HandleRPathRemoveCommand(args, status); } if (subCommand == "READ_ELF") { - return this->HandleReadElfCommand(args); + return this->HandleReadElfCommand(args, status); } if (subCommand == "RELATIVE_PATH") { - return this->HandleRelativePathCommand(args); + return this->HandleRelativePathCommand(args, status); } if (subCommand == "TO_CMAKE_PATH") { - return this->HandleCMakePathCommand(args, false); + return this->HandleCMakePathCommand(args, false, status); } if (subCommand == "TO_NATIVE_PATH") { - return this->HandleCMakePathCommand(args, true); + return this->HandleCMakePathCommand(args, true, status); } if (subCommand == "TOUCH") { - return this->HandleTouchCommand(args, true); + return this->HandleTouchCommand(args, true, status); } if (subCommand == "TOUCH_NOCREATE") { - return this->HandleTouchCommand(args, false); + return this->HandleTouchCommand(args, false, status); } if (subCommand == "TIMESTAMP") { - return this->HandleTimestampCommand(args); + return this->HandleTimestampCommand(args, status); } if (subCommand == "GENERATE") { - return this->HandleGenerateCommand(args); + return this->HandleGenerateCommand(args, status); } if (subCommand == "LOCK") { - return this->HandleLockCommand(args); + return this->HandleLockCommand(args, status); } if (subCommand == "SIZE") { - return this->HandleSizeCommand(args); + return this->HandleSizeCommand(args, status); } if (subCommand == "READ_SYMLINK") { - return this->HandleReadSymlinkCommand(args); + return this->HandleReadSymlinkCommand(args, status); } if (subCommand == "CREATE_LINK") { - return this->HandleCreateLinkCommand(args); + return this->HandleCreateLinkCommand(args, status); } if (subCommand == "GET_RUNTIME_DEPENDENCIES") { - return this->HandleGetRuntimeDependenciesCommand(args); + return this->HandleGetRuntimeDependenciesCommand(args, status); } std::string e = "does not recognize sub-command " + subCommand; - this->SetError(e); + status.SetError(e); return false; } bool cmFileCommand::HandleWriteCommand(std::vector const& args, - bool append) + bool append, cmExecutionStatus& status) { std::vector::const_iterator i = args.begin(); @@ -208,16 +209,16 @@ bool cmFileCommand::HandleWriteCommand(std::vector const& args, std::string fileName = *i; if (!cmsys::SystemTools::FileIsFullPath(*i)) { - fileName = this->Makefile->GetCurrentSourceDirectory(); + fileName = status.GetMakefile().GetCurrentSourceDirectory(); fileName += "/" + *i; } i++; - if (!this->Makefile->CanIWriteThisFile(fileName)) { + if (!status.GetMakefile().CanIWriteThisFile(fileName)) { std::string e = "attempted to write a file: " + fileName + " into a source directory."; - this->SetError(e); + status.SetError(e); cmSystemTools::SetFatalErrorOccured(); return false; } @@ -249,7 +250,7 @@ bool cmFileCommand::HandleWriteCommand(std::vector const& args, error += cmSystemTools::GetLastSystemError(); error += "):\n "; error += fileName; - this->SetError(error); + status.SetError(error); return false; } std::string message = cmJoin(cmMakeRange(i, args.end()), std::string()); @@ -259,7 +260,7 @@ bool cmFileCommand::HandleWriteCommand(std::vector const& args, error += cmSystemTools::GetLastSystemError(); error += "):\n "; error += fileName; - this->SetError(error); + status.SetError(error); return false; } file.close(); @@ -269,11 +270,12 @@ bool cmFileCommand::HandleWriteCommand(std::vector const& args, return true; } -bool cmFileCommand::HandleReadCommand(std::vector const& args) +bool cmFileCommand::HandleReadCommand(std::vector const& args, + cmExecutionStatus& status) { if (args.size() < 3) { - this->SetError("READ must be called with at least two additional " - "arguments"); + status.SetError("READ must be called with at least two additional " + "arguments"); return false; } @@ -296,7 +298,7 @@ bool cmFileCommand::HandleReadCommand(std::vector const& args) std::string fileName = fileNameArg; if (!cmsys::SystemTools::FileIsFullPath(fileName)) { - fileName = this->Makefile->GetCurrentSourceDirectory(); + fileName = status.GetMakefile().GetCurrentSourceDirectory(); fileName += "/" + fileNameArg; } @@ -314,7 +316,7 @@ bool cmFileCommand::HandleReadCommand(std::vector const& args) error += cmSystemTools::GetLastSystemError(); error += "):\n "; error += fileName; - this->SetError(error); + status.SetError(error); return false; } @@ -366,17 +368,18 @@ bool cmFileCommand::HandleReadCommand(std::vector const& args) } } } - this->Makefile->AddDefinition(variable, output); + status.GetMakefile().AddDefinition(variable, output); return true; } -bool cmFileCommand::HandleHashCommand(std::vector const& args) +bool cmFileCommand::HandleHashCommand(std::vector const& args, + cmExecutionStatus& status) { #if defined(CMAKE_BUILD_WITH_CMAKE) if (args.size() != 3) { std::ostringstream e; e << args[0] << " requires a file name and output variable"; - this->SetError(e.str()); + status.SetError(e.str()); return false; } @@ -384,34 +387,35 @@ bool cmFileCommand::HandleHashCommand(std::vector const& args) if (hash) { std::string out = hash->HashFile(args[1]); if (!out.empty()) { - this->Makefile->AddDefinition(args[2], out); + status.GetMakefile().AddDefinition(args[2], out); return true; } std::ostringstream e; e << args[0] << " failed to read file \"" << args[1] << "\": " << cmSystemTools::GetLastSystemError(); - this->SetError(e.str()); + status.SetError(e.str()); } return false; #else std::ostringstream e; e << args[0] << " not available during bootstrap"; - this->SetError(e.str()); + status.SetError(e.str()); return false; #endif } -bool cmFileCommand::HandleStringsCommand(std::vector const& args) +bool cmFileCommand::HandleStringsCommand(std::vector const& args, + cmExecutionStatus& status) { if (args.size() < 3) { - this->SetError("STRINGS requires a file name and output variable"); + status.SetError("STRINGS requires a file name and output variable"); return false; } // Get the file to read. std::string fileName = args[1]; if (!cmsys::SystemTools::FileIsFullPath(fileName)) { - fileName = this->Makefile->GetCurrentSourceDirectory(); + fileName = status.GetMakefile().GetCurrentSourceDirectory(); fileName += "/" + args[1]; } @@ -478,7 +482,7 @@ bool cmFileCommand::HandleStringsCommand(std::vector const& args) std::ostringstream e; e << "STRINGS option LIMIT_INPUT value \"" << args[i] << "\" is not an unsigned integer."; - this->SetError(e.str()); + status.SetError(e.str()); return false; } arg_mode = arg_none; @@ -488,7 +492,7 @@ bool cmFileCommand::HandleStringsCommand(std::vector const& args) std::ostringstream e; e << "STRINGS option LIMIT_OUTPUT value \"" << args[i] << "\" is not an unsigned integer."; - this->SetError(e.str()); + status.SetError(e.str()); return false; } arg_mode = arg_none; @@ -498,7 +502,7 @@ bool cmFileCommand::HandleStringsCommand(std::vector const& args) std::ostringstream e; e << "STRINGS option LIMIT_COUNT value \"" << args[i] << "\" is not an unsigned integer."; - this->SetError(e.str()); + status.SetError(e.str()); return false; } limit_count = count; @@ -509,7 +513,7 @@ bool cmFileCommand::HandleStringsCommand(std::vector const& args) std::ostringstream e; e << "STRINGS option LENGTH_MINIMUM value \"" << args[i] << "\" is not an unsigned integer."; - this->SetError(e.str()); + status.SetError(e.str()); return false; } minlen = len; @@ -520,7 +524,7 @@ bool cmFileCommand::HandleStringsCommand(std::vector const& args) std::ostringstream e; e << "STRINGS option LENGTH_MAXIMUM value \"" << args[i] << "\" is not an unsigned integer."; - this->SetError(e.str()); + status.SetError(e.str()); return false; } maxlen = len; @@ -530,7 +534,7 @@ bool cmFileCommand::HandleStringsCommand(std::vector const& args) std::ostringstream e; e << "STRINGS option REGEX value \"" << args[i] << "\" could not be compiled."; - this->SetError(e.str()); + status.SetError(e.str()); return false; } have_regex = true; @@ -549,21 +553,22 @@ bool cmFileCommand::HandleStringsCommand(std::vector const& args) } else { std::ostringstream e; e << "STRINGS option ENCODING \"" << args[i] << "\" not recognized."; - this->SetError(e.str()); + status.SetError(e.str()); return false; } arg_mode = arg_none; } else { std::ostringstream e; e << "STRINGS given unknown argument \"" << args[i] << "\""; - this->SetError(e.str()); + status.SetError(e.str()); return false; } } if (hex_conversion_enabled) { // TODO: should work without temp file, but just on a memory buffer - std::string binaryFileName = this->Makefile->GetCurrentBinaryDirectory(); + std::string binaryFileName = + status.GetMakefile().GetCurrentBinaryDirectory(); binaryFileName += "/CMakeFiles"; binaryFileName += "/FileCommandStringsBinaryFile"; if (cmHexFileConverter::TryConvert(fileName, binaryFileName)) { @@ -580,7 +585,7 @@ bool cmFileCommand::HandleStringsCommand(std::vector const& args) if (!fin) { std::ostringstream e; e << "STRINGS file \"" << fileName << "\" cannot be read."; - this->SetError(e.str()); + status.SetError(e.str()); return false; } @@ -752,12 +757,12 @@ bool cmFileCommand::HandleStringsCommand(std::vector const& args) } // Save the output in a makefile variable. - this->Makefile->AddDefinition(outVar, output); + status.GetMakefile().AddDefinition(outVar, output); return true; } bool cmFileCommand::HandleGlobCommand(std::vector const& args, - bool recurse) + bool recurse, cmExecutionStatus& status) { // File commands has at least one argument assert(args.size() > 1); @@ -772,10 +777,10 @@ bool cmFileCommand::HandleGlobCommand(std::vector const& args, g.SetRecurse(recurse); bool explicitFollowSymlinks = false; - cmPolicies::PolicyStatus status = - this->Makefile->GetPolicyStatus(cmPolicies::CMP0009); + cmPolicies::PolicyStatus policyStatus = + status.GetMakefile().GetPolicyStatus(cmPolicies::CMP0009); if (recurse) { - switch (status) { + switch (policyStatus) { case cmPolicies::REQUIRED_IF_USED: case cmPolicies::REQUIRED_ALWAYS: case cmPolicies::NEW: @@ -793,7 +798,7 @@ bool cmFileCommand::HandleGlobCommand(std::vector const& args, bool warnConfigureLate = false; bool warnFollowedSymlinks = false; const cmake::WorkingMode workingMode = - this->Makefile->GetCMakeInstance()->GetWorkingMode(); + status.GetMakefile().GetCMakeInstance()->GetWorkingMode(); while (i != args.end()) { if (*i == "LIST_DIRECTORIES") { ++i; // skip LIST_DIRECTORIES @@ -805,12 +810,12 @@ bool cmFileCommand::HandleGlobCommand(std::vector const& args, g.SetListDirs(false); g.SetRecurseListDirs(false); } else { - this->SetError("LIST_DIRECTORIES missing bool value."); + status.SetError("LIST_DIRECTORIES missing bool value."); return false; } ++i; } else { - this->SetError("LIST_DIRECTORIES missing bool value."); + status.SetError("LIST_DIRECTORIES missing bool value."); return false; } } else if (*i == "FOLLOW_SYMLINKS") { @@ -819,7 +824,7 @@ bool cmFileCommand::HandleGlobCommand(std::vector const& args, explicitFollowSymlinks = true; g.RecurseThroughSymlinksOn(); if (i == args.end()) { - this->SetError( + status.SetError( "GLOB_RECURSE requires a glob expression after FOLLOW_SYMLINKS."); return false; } @@ -827,25 +832,26 @@ bool cmFileCommand::HandleGlobCommand(std::vector const& args, } else if (*i == "RELATIVE") { ++i; // skip RELATIVE if (i == args.end()) { - this->SetError("GLOB requires a directory after the RELATIVE tag."); + status.SetError("GLOB requires a directory after the RELATIVE tag."); return false; } g.SetRelative(i->c_str()); ++i; if (i == args.end()) { - this->SetError("GLOB requires a glob expression after the directory."); + status.SetError( + "GLOB requires a glob expression after the directory."); return false; } } else if (*i == "CONFIGURE_DEPENDS") { // Generated build system depends on glob results if (!configureDepends && warnConfigureLate) { - this->Makefile->IssueMessage( + status.GetMakefile().IssueMessage( MessageType::AUTHOR_WARNING, "CONFIGURE_DEPENDS flag was given after a glob expression was " "already evaluated."); } if (workingMode != cmake::NORMAL_MODE) { - this->Makefile->IssueMessage( + status.GetMakefile().IssueMessage( MessageType::FATAL_ERROR, "CONFIGURE_DEPENDS is invalid for script and find package modes."); return false; @@ -853,14 +859,14 @@ bool cmFileCommand::HandleGlobCommand(std::vector const& args, configureDepends = true; ++i; if (i == args.end()) { - this->SetError( + status.SetError( "GLOB requires a glob expression after CONFIGURE_DEPENDS."); return false; } } else { std::string expr = *i; if (!cmsys::SystemTools::FileIsFullPath(*i)) { - expr = this->Makefile->GetCurrentSourceDirectory(); + expr = status.GetMakefile().GetCurrentSourceDirectory(); // Handle script mode if (!expr.empty()) { expr += "/" + *i; @@ -876,12 +882,12 @@ bool cmFileCommand::HandleGlobCommand(std::vector const& args, bool shouldExit = false; for (cmsys::Glob::Message const& globMessage : globMessages) { if (globMessage.type == cmsys::Glob::cyclicRecursion) { - this->Makefile->IssueMessage( + status.GetMakefile().IssueMessage( MessageType::AUTHOR_WARNING, "Cyclic recursion detected while globbing for '" + *i + "':\n" + globMessage.content); } else { - this->Makefile->IssueMessage( + status.GetMakefile().IssueMessage( MessageType::FATAL_ERROR, "Error has occurred while globbing for '" + *i + "' - " + globMessage.content); @@ -905,11 +911,11 @@ bool cmFileCommand::HandleGlobCommand(std::vector const& args, std::sort(foundFiles.begin(), foundFiles.end()); foundFiles.erase(std::unique(foundFiles.begin(), foundFiles.end()), foundFiles.end()); - this->Makefile->GetCMakeInstance()->AddGlobCacheEntry( + status.GetMakefile().GetCMakeInstance()->AddGlobCacheEntry( recurse, (recurse ? g.GetRecurseListDirs() : g.GetListDirs()), (recurse ? g.GetRecurseThroughSymlinks() : false), (g.GetRelative() ? g.GetRelative() : ""), expr, foundFiles, variable, - this->Makefile->GetBacktrace()); + status.GetMakefile().GetBacktrace()); } else { warnConfigureLate = true; } @@ -917,7 +923,7 @@ bool cmFileCommand::HandleGlobCommand(std::vector const& args, } } - switch (status) { + switch (policyStatus) { case cmPolicies::REQUIRED_IF_USED: case cmPolicies::REQUIRED_ALWAYS: case cmPolicies::NEW: @@ -930,7 +936,7 @@ bool cmFileCommand::HandleGlobCommand(std::vector const& args, // Possibly unexpected old behavior *and* we actually traversed // symlinks without being explicitly asked to: warn the author. if (warnFollowedSymlinks) { - this->Makefile->IssueMessage( + status.GetMakefile().IssueMessage( MessageType::AUTHOR_WARNING, cmPolicies::GetPolicyWarning(cmPolicies::CMP0009)); } @@ -939,12 +945,12 @@ bool cmFileCommand::HandleGlobCommand(std::vector const& args, std::sort(files.begin(), files.end()); files.erase(std::unique(files.begin(), files.end()), files.end()); - this->Makefile->AddDefinition(variable, cmJoin(files, ";")); + status.GetMakefile().AddDefinition(variable, cmJoin(files, ";")); return true; } bool cmFileCommand::HandleMakeDirectoryCommand( - std::vector const& args) + std::vector const& args, cmExecutionStatus& status) { // File command has at least one argument assert(args.size() > 1); @@ -955,20 +961,20 @@ bool cmFileCommand::HandleMakeDirectoryCommand( { const std::string* cdir = &arg; if (!cmsys::SystemTools::FileIsFullPath(arg)) { - expr = this->Makefile->GetCurrentSourceDirectory(); + expr = status.GetMakefile().GetCurrentSourceDirectory(); expr += "/" + arg; cdir = &expr; } - if (!this->Makefile->CanIWriteThisFile(*cdir)) { + if (!status.GetMakefile().CanIWriteThisFile(*cdir)) { std::string e = "attempted to create a directory: " + *cdir + " into a source directory."; - this->SetError(e); + status.SetError(e); cmSystemTools::SetFatalErrorOccured(); return false; } if (!cmSystemTools::MakeDirectory(*cdir)) { std::string error = "problem creating directory: " + *cdir; - this->SetError(error); + status.SetError(error); return false; } } @@ -976,7 +982,7 @@ bool cmFileCommand::HandleMakeDirectoryCommand( } bool cmFileCommand::HandleTouchCommand(std::vector const& args, - bool create) + bool create, cmExecutionStatus& status) { // File command has at least one argument assert(args.size() > 1); @@ -986,19 +992,19 @@ bool cmFileCommand::HandleTouchCommand(std::vector const& args, { std::string tfile = arg; if (!cmsys::SystemTools::FileIsFullPath(tfile)) { - tfile = this->Makefile->GetCurrentSourceDirectory(); + tfile = status.GetMakefile().GetCurrentSourceDirectory(); tfile += "/" + arg; } - if (!this->Makefile->CanIWriteThisFile(tfile)) { + if (!status.GetMakefile().CanIWriteThisFile(tfile)) { std::string e = "attempted to touch a file: " + tfile + " in a source directory."; - this->SetError(e); + status.SetError(e); cmSystemTools::SetFatalErrorOccured(); return false; } if (!cmSystemTools::Touch(tfile, create)) { std::string error = "problem touching file: " + tfile; - this->SetError(error); + status.SetError(error); return false; } } @@ -1006,7 +1012,7 @@ bool cmFileCommand::HandleTouchCommand(std::vector const& args, } bool cmFileCommand::HandleDifferentCommand( - std::vector const& args) + std::vector const& args, cmExecutionStatus& status) { /* FILE(DIFFERENT FILES ) @@ -1039,34 +1045,35 @@ bool cmFileCommand::HandleDifferentCommand( } else { std::ostringstream e; e << "DIFFERENT given unknown argument " << args[i]; - this->SetError(e.str()); + status.SetError(e.str()); return false; } } if (!var) { - this->SetError("DIFFERENT not given result variable name."); + status.SetError("DIFFERENT not given result variable name."); return false; } if (!file_lhs || !file_rhs) { - this->SetError("DIFFERENT not given FILES option with two file names."); + status.SetError("DIFFERENT not given FILES option with two file names."); return false; } // Compare the files. const char* result = cmSystemTools::FilesDiffer(file_lhs, file_rhs) ? "1" : "0"; - this->Makefile->AddDefinition(var, result); + status.GetMakefile().AddDefinition(var, result); return true; } -bool cmFileCommand::HandleCopyCommand(std::vector const& args) +bool cmFileCommand::HandleCopyCommand(std::vector const& args, + cmExecutionStatus& status) { - cmFileCopier copier(this); + cmFileCopier copier(status); return copier.Run(args); } bool cmFileCommand::HandleRPathChangeCommand( - std::vector const& args) + std::vector const& args, cmExecutionStatus& status) { // Evaluate arguments. std::string file; @@ -1102,26 +1109,26 @@ bool cmFileCommand::HandleRPathChangeCommand( } else { std::ostringstream e; e << "RPATH_CHANGE given unknown argument " << args[i]; - this->SetError(e.str()); + status.SetError(e.str()); return false; } } if (file.empty()) { - this->SetError("RPATH_CHANGE not given FILE option."); + status.SetError("RPATH_CHANGE not given FILE option."); return false; } if (!oldRPath) { - this->SetError("RPATH_CHANGE not given OLD_RPATH option."); + status.SetError("RPATH_CHANGE not given OLD_RPATH option."); return false; } if (!newRPath) { - this->SetError("RPATH_CHANGE not given NEW_RPATH option."); + status.SetError("RPATH_CHANGE not given NEW_RPATH option."); return false; } if (!cmSystemTools::FileExists(file, true)) { std::ostringstream e; e << "RPATH_CHANGE given FILE \"" << file << "\" that does not exist."; - this->SetError(e.str()); + status.SetError(e.str()); return false; } bool success = true; @@ -1139,7 +1146,7 @@ bool cmFileCommand::HandleRPathChangeCommand( << " " << file << "\n" << emsg; /* clang-format on */ - this->SetError(e.str()); + status.SetError(e.str()); success = false; } if (success) { @@ -1149,7 +1156,7 @@ bool cmFileCommand::HandleRPathChangeCommand( message += "\" to \""; message += newRPath; message += "\""; - this->Makefile->DisplayStatus(message, -1); + status.GetMakefile().DisplayStatus(message, -1); } ft.Store(file); } @@ -1157,7 +1164,7 @@ bool cmFileCommand::HandleRPathChangeCommand( } bool cmFileCommand::HandleRPathRemoveCommand( - std::vector const& args) + std::vector const& args, cmExecutionStatus& status) { // Evaluate arguments. std::string file; @@ -1176,18 +1183,18 @@ bool cmFileCommand::HandleRPathRemoveCommand( } else { std::ostringstream e; e << "RPATH_REMOVE given unknown argument " << args[i]; - this->SetError(e.str()); + status.SetError(e.str()); return false; } } if (file.empty()) { - this->SetError("RPATH_REMOVE not given FILE option."); + status.SetError("RPATH_REMOVE not given FILE option."); return false; } if (!cmSystemTools::FileExists(file, true)) { std::ostringstream e; e << "RPATH_REMOVE given FILE \"" << file << "\" that does not exist."; - this->SetError(e.str()); + status.SetError(e.str()); return false; } bool success = true; @@ -1201,7 +1208,7 @@ bool cmFileCommand::HandleRPathRemoveCommand( << " " << file << "\n" << emsg; /* clang-format on */ - this->SetError(e.str()); + status.SetError(e.str()); success = false; } if (success) { @@ -1209,7 +1216,7 @@ bool cmFileCommand::HandleRPathRemoveCommand( std::string message = "Removed runtime path from \""; message += file; message += "\""; - this->Makefile->DisplayStatus(message, -1); + status.GetMakefile().DisplayStatus(message, -1); } ft.Store(file); } @@ -1217,7 +1224,7 @@ bool cmFileCommand::HandleRPathRemoveCommand( } bool cmFileCommand::HandleRPathCheckCommand( - std::vector const& args) + std::vector const& args, cmExecutionStatus& status) { // Evaluate arguments. std::string file; @@ -1243,16 +1250,16 @@ bool cmFileCommand::HandleRPathCheckCommand( } else { std::ostringstream e; e << "RPATH_CHECK given unknown argument " << args[i]; - this->SetError(e.str()); + status.SetError(e.str()); return false; } } if (file.empty()) { - this->SetError("RPATH_CHECK not given FILE option."); + status.SetError("RPATH_CHECK not given FILE option."); return false; } if (!rpath) { - this->SetError("RPATH_CHECK not given RPATH option."); + status.SetError("RPATH_CHECK not given RPATH option."); return false; } @@ -1267,11 +1274,12 @@ bool cmFileCommand::HandleRPathCheckCommand( return true; } -bool cmFileCommand::HandleReadElfCommand(std::vector const& args) +bool cmFileCommand::HandleReadElfCommand(std::vector const& args, + cmExecutionStatus& status) { if (args.size() < 4) { - this->SetError("READ_ELF must be called with at least three additional " - "arguments."); + status.SetError("READ_ELF must be called with at least three additional " + "arguments."); return false; } @@ -1293,7 +1301,7 @@ bool cmFileCommand::HandleReadElfCommand(std::vector const& args) if (!cmSystemTools::FileExists(fileNameArg, true)) { std::ostringstream e; e << "READ_ELF given FILE \"" << fileNameArg << "\" that does not exist."; - this->SetError(e.str()); + status.SetError(e.str()); return false; } @@ -1304,14 +1312,14 @@ bool cmFileCommand::HandleReadElfCommand(std::vector const& args) if (cmELF::StringEntry const* se_rpath = elf.GetRPath()) { std::string rpath(se_rpath->Value); std::replace(rpath.begin(), rpath.end(), ':', ';'); - this->Makefile->AddDefinition(arguments.RPath, rpath); + status.GetMakefile().AddDefinition(arguments.RPath, rpath); } } if (!arguments.RunPath.empty()) { if (cmELF::StringEntry const* se_runpath = elf.GetRunPath()) { std::string runpath(se_runpath->Value); std::replace(runpath.begin(), runpath.end(), ':', ';'); - this->Makefile->AddDefinition(arguments.RunPath, runpath); + status.GetMakefile().AddDefinition(arguments.RunPath, runpath); } } @@ -1319,25 +1327,26 @@ bool cmFileCommand::HandleReadElfCommand(std::vector const& args) #else std::string error = "ELF parser not available on this platform."; if (arguments.Error.empty()) { - this->SetError(error); + status.SetError(error); return false; } - this->Makefile->AddDefinition(arguments.Error, error); + status.GetMakefile().AddDefinition(arguments.Error, error); return true; #endif } -bool cmFileCommand::HandleInstallCommand(std::vector const& args) +bool cmFileCommand::HandleInstallCommand(std::vector const& args, + cmExecutionStatus& status) { - cmFileInstaller installer(this); + cmFileInstaller installer(status); return installer.Run(args); } bool cmFileCommand::HandleRelativePathCommand( - std::vector const& args) + std::vector const& args, cmExecutionStatus& status) { if (args.size() != 4) { - this->SetError("RELATIVE_PATH called with incorrect number of arguments"); + status.SetError("RELATIVE_PATH called with incorrect number of arguments"); return false; } @@ -1349,37 +1358,38 @@ bool cmFileCommand::HandleRelativePathCommand( std::string errstring = "RELATIVE_PATH must be passed a full path to the directory: " + directoryName; - this->SetError(errstring); + status.SetError(errstring); return false; } if (!cmSystemTools::FileIsFullPath(fileName)) { std::string errstring = "RELATIVE_PATH must be passed a full path to the file: " + fileName; - this->SetError(errstring); + status.SetError(errstring); return false; } std::string res = cmSystemTools::RelativePath(directoryName, fileName); - this->Makefile->AddDefinition(outVar, res); + status.GetMakefile().AddDefinition(outVar, res); return true; } -bool cmFileCommand::HandleRename(std::vector const& args) +bool cmFileCommand::HandleRename(std::vector const& args, + cmExecutionStatus& status) { if (args.size() != 3) { - this->SetError("RENAME given incorrect number of arguments."); + status.SetError("RENAME given incorrect number of arguments."); return false; } // Compute full path for old and new names. std::string oldname = args[1]; if (!cmsys::SystemTools::FileIsFullPath(oldname)) { - oldname = this->Makefile->GetCurrentSourceDirectory(); + oldname = status.GetMakefile().GetCurrentSourceDirectory(); oldname += "/" + args[1]; } std::string newname = args[2]; if (!cmsys::SystemTools::FileIsFullPath(newname)) { - newname = this->Makefile->GetCurrentSourceDirectory(); + newname = status.GetMakefile().GetCurrentSourceDirectory(); newname += "/" + args[2]; } @@ -1393,14 +1403,14 @@ bool cmFileCommand::HandleRename(std::vector const& args) << " " << newname << "\n" << "because: " << err << "\n"; /* clang-format on */ - this->SetError(e.str()); + status.SetError(e.str()); return false; } return true; } bool cmFileCommand::HandleRemove(std::vector const& args, - bool recurse) + bool recurse, cmExecutionStatus& status) { std::string message; @@ -1411,12 +1421,12 @@ bool cmFileCommand::HandleRemove(std::vector const& args, std::string fileName = arg; if (fileName.empty()) { std::string const r = recurse ? "REMOVE_RECURSE" : "REMOVE"; - this->Makefile->IssueMessage(MessageType::AUTHOR_WARNING, - "Ignoring empty file name in " + r + "."); + status.GetMakefile().IssueMessage( + MessageType::AUTHOR_WARNING, "Ignoring empty file name in " + r + "."); continue; } if (!cmsys::SystemTools::FileIsFullPath(fileName)) { - fileName = this->Makefile->GetCurrentSourceDirectory(); + fileName = status.GetMakefile().GetCurrentSourceDirectory(); fileName += "/" + arg; } @@ -1450,11 +1460,12 @@ std::string ToCMakePath(const std::string& path) } bool cmFileCommand::HandleCMakePathCommand( - std::vector const& args, bool nativePath) + std::vector const& args, bool nativePath, + cmExecutionStatus& status) { if (args.size() != 3) { - this->SetError("FILE([TO_CMAKE_PATH|TO_NATIVE_PATH] path result) must be " - "called with exactly three arguments."); + status.SetError("FILE([TO_CMAKE_PATH|TO_NATIVE_PATH] path result) must be " + "called with exactly three arguments."); return false; } #if defined(_WIN32) && !defined(__CYGWIN__) @@ -1466,7 +1477,7 @@ bool cmFileCommand::HandleCMakePathCommand( std::string value = cmJoin( cmMakeRange(path).transform(nativePath ? ToNativePath : ToCMakePath), ";"); - this->Makefile->AddDefinition(args[2], value); + status.GetMakefile().AddDefinition(args[2], value); return true; } @@ -1636,17 +1647,18 @@ private: if (result != CURLE_OK) { \ std::string e(errstr); \ e += ::curl_easy_strerror(result); \ - this->SetError(e); \ + status.SetError(e); \ return false; \ } \ } while (false) -bool cmFileCommand::HandleDownloadCommand(std::vector const& args) +bool cmFileCommand::HandleDownloadCommand(std::vector const& args, + cmExecutionStatus& status) { #if defined(CMAKE_BUILD_WITH_CMAKE) std::vector::const_iterator i = args.begin(); if (args.size() < 3) { - this->SetError("DOWNLOAD must be called with at least three arguments."); + status.SetError("DOWNLOAD must be called with at least three arguments."); return false; } ++i; // Get rid of subcommand @@ -1659,11 +1671,12 @@ bool cmFileCommand::HandleDownloadCommand(std::vector const& args) long inactivity_timeout = 0; std::string logVar; std::string statusVar; - bool tls_verify = this->Makefile->IsOn("CMAKE_TLS_VERIFY"); - const char* cainfo = this->Makefile->GetDefinition("CMAKE_TLS_CAINFO"); - std::string netrc_level = this->Makefile->GetSafeDefinition("CMAKE_NETRC"); + bool tls_verify = status.GetMakefile().IsOn("CMAKE_TLS_VERIFY"); + const char* cainfo = status.GetMakefile().GetDefinition("CMAKE_TLS_CAINFO"); + std::string netrc_level = + status.GetMakefile().GetSafeDefinition("CMAKE_NETRC"); std::string netrc_file = - this->Makefile->GetSafeDefinition("CMAKE_NETRC_FILE"); + status.GetMakefile().GetSafeDefinition("CMAKE_NETRC_FILE"); std::string expectedHash; std::string hashMatchMSG; std::unique_ptr hash; @@ -1678,7 +1691,7 @@ bool cmFileCommand::HandleDownloadCommand(std::vector const& args) if (i != args.end()) { timeout = atol(i->c_str()); } else { - this->SetError("DOWNLOAD missing time for TIMEOUT."); + status.SetError("DOWNLOAD missing time for TIMEOUT."); return false; } } else if (*i == "INACTIVITY_TIMEOUT") { @@ -1686,20 +1699,20 @@ bool cmFileCommand::HandleDownloadCommand(std::vector const& args) if (i != args.end()) { inactivity_timeout = atol(i->c_str()); } else { - this->SetError("DOWNLOAD missing time for INACTIVITY_TIMEOUT."); + status.SetError("DOWNLOAD missing time for INACTIVITY_TIMEOUT."); return false; } } else if (*i == "LOG") { ++i; if (i == args.end()) { - this->SetError("DOWNLOAD missing VAR for LOG."); + status.SetError("DOWNLOAD missing VAR for LOG."); return false; } logVar = *i; } else if (*i == "STATUS") { ++i; if (i == args.end()) { - this->SetError("DOWNLOAD missing VAR for STATUS."); + status.SetError("DOWNLOAD missing VAR for STATUS."); return false; } statusVar = *i; @@ -1708,7 +1721,7 @@ bool cmFileCommand::HandleDownloadCommand(std::vector const& args) if (i != args.end()) { tls_verify = cmSystemTools::IsOn(*i); } else { - this->SetError("TLS_VERIFY missing bool value."); + status.SetError("TLS_VERIFY missing bool value."); return false; } } else if (*i == "TLS_CAINFO") { @@ -1716,7 +1729,7 @@ bool cmFileCommand::HandleDownloadCommand(std::vector const& args) if (i != args.end()) { cainfo = i->c_str(); } else { - this->SetError("TLS_CAFILE missing file value."); + status.SetError("TLS_CAFILE missing file value."); return false; } } else if (*i == "NETRC_FILE") { @@ -1724,7 +1737,7 @@ bool cmFileCommand::HandleDownloadCommand(std::vector const& args) if (i != args.end()) { netrc_file = *i; } else { - this->SetError("DOWNLOAD missing file value for NETRC_FILE."); + status.SetError("DOWNLOAD missing file value for NETRC_FILE."); return false; } } else if (*i == "NETRC") { @@ -1732,13 +1745,13 @@ bool cmFileCommand::HandleDownloadCommand(std::vector const& args) if (i != args.end()) { netrc_level = *i; } else { - this->SetError("DOWNLOAD missing level value for NETRC."); + status.SetError("DOWNLOAD missing level value for NETRC."); return false; } } else if (*i == "EXPECTED_MD5") { ++i; if (i == args.end()) { - this->SetError("DOWNLOAD missing sum value for EXPECTED_MD5."); + status.SetError("DOWNLOAD missing sum value for EXPECTED_MD5."); return false; } hash = cm::make_unique(cmCryptoHash::AlgoMD5); @@ -1749,7 +1762,7 @@ bool cmFileCommand::HandleDownloadCommand(std::vector const& args) } else if (*i == "EXPECTED_HASH") { ++i; if (i == args.end()) { - this->SetError("DOWNLOAD missing ALGO=value for EXPECTED_HASH."); + status.SetError("DOWNLOAD missing ALGO=value for EXPECTED_HASH."); return false; } std::string::size_type pos = i->find("="); @@ -1757,7 +1770,7 @@ bool cmFileCommand::HandleDownloadCommand(std::vector const& args) std::string err = "DOWNLOAD EXPECTED_HASH expects ALGO=value but got: "; err += *i; - this->SetError(err); + status.SetError(err); return false; } std::string algo = i->substr(0, pos); @@ -1766,21 +1779,21 @@ bool cmFileCommand::HandleDownloadCommand(std::vector const& args) if (!hash) { std::string err = "DOWNLOAD EXPECTED_HASH given unknown ALGO: "; err += algo; - this->SetError(err); + status.SetError(err); return false; } hashMatchMSG = algo + " hash"; } else if (*i == "USERPWD") { ++i; if (i == args.end()) { - this->SetError("DOWNLOAD missing string for USERPWD."); + status.SetError("DOWNLOAD missing string for USERPWD."); return false; } userpwd = *i; } else if (*i == "HTTPHEADER") { ++i; if (i == args.end()) { - this->SetError("DOWNLOAD missing string for HTTPHEADER."); + status.SetError("DOWNLOAD missing string for HTTPHEADER."); return false; } curl_headers.push_back(*i); @@ -1788,7 +1801,7 @@ bool cmFileCommand::HandleDownloadCommand(std::vector const& args) // Do not return error for compatibility reason. std::string err = "Unexpected argument: "; err += *i; - this->Makefile->IssueMessage(MessageType::AUTHOR_WARNING, err); + status.GetMakefile().IssueMessage(MessageType::AUTHOR_WARNING, err); } ++i; } @@ -1806,7 +1819,7 @@ bool cmFileCommand::HandleDownloadCommand(std::vector const& args) if (!statusVar.empty()) { std::ostringstream result; result << 0 << ";\"" << msg; - this->Makefile->AddDefinition(statusVar, result.str()); + status.GetMakefile().AddDefinition(statusVar, result.str()); } return true; } @@ -1819,13 +1832,13 @@ bool cmFileCommand::HandleDownloadCommand(std::vector const& args) std::string errstring = "DOWNLOAD error: cannot create directory '" + dir + "' - Specify file by full path name and verify that you " "have directory creation and file write privileges."; - this->SetError(errstring); + status.SetError(errstring); return false; } cmsys::ofstream fout(file.c_str(), std::ios::binary); if (!fout) { - this->SetError("DOWNLOAD cannot open file for write."); + status.SetError("DOWNLOAD cannot open file for write."); return false; } @@ -1837,7 +1850,7 @@ bool cmFileCommand::HandleDownloadCommand(std::vector const& args) ::curl_global_init(CURL_GLOBAL_DEFAULT); curl = ::curl_easy_init(); if (!curl) { - this->SetError("DOWNLOAD error initializing curl."); + status.SetError("DOWNLOAD error initializing curl."); return false; } @@ -1871,7 +1884,7 @@ bool cmFileCommand::HandleDownloadCommand(std::vector const& args) // command arg comes first std::string const& cainfo_err = cmCurlSetCAInfo(curl, cainfo); if (!cainfo_err.empty()) { - this->SetError(cainfo_err); + status.SetError(cainfo_err); return false; } @@ -1881,7 +1894,7 @@ bool cmFileCommand::HandleDownloadCommand(std::vector const& args) std::string const& netrc_option_err = cmCurlSetNETRCOption(curl, netrc_level, netrc_file); if (!netrc_option_err.empty()) { - this->SetError(netrc_option_err); + status.SetError(netrc_option_err); return false; } @@ -1955,7 +1968,7 @@ bool cmFileCommand::HandleDownloadCommand(std::vector const& args) std::ostringstream result; result << static_cast(res) << ";\"" << ::curl_easy_strerror(res) << "\""; - this->Makefile->AddDefinition(statusVar, result.str()); + status.GetMakefile().AddDefinition(statusVar, result.str()); } ::curl_global_cleanup(); @@ -1970,7 +1983,7 @@ bool cmFileCommand::HandleDownloadCommand(std::vector const& args) if (hash) { std::string actualHash = hash->HashFile(file); if (actualHash.empty()) { - this->SetError("DOWNLOAD cannot compute hash on downloaded file"); + status.SetError("DOWNLOAD cannot compute hash on downloaded file"); return false; } @@ -1984,34 +1997,36 @@ bool cmFileCommand::HandleDownloadCommand(std::vector const& args) << ::curl_easy_strerror(res) << "\"]" << std::endl; if (!statusVar.empty() && res == 0) { - std::string status = "1;HASH mismatch: " - "expected: " + - expectedHash + " actual: " + actualHash; - this->Makefile->AddDefinition(statusVar, status); + status.GetMakefile().AddDefinition(statusVar, + "1;HASH mismatch: " + "expected: " + + expectedHash + + " actual: " + actualHash); } - this->SetError(oss.str()); + status.SetError(oss.str()); return false; } } if (!logVar.empty()) { chunkDebug.push_back(0); - this->Makefile->AddDefinition(logVar, chunkDebug.data()); + status.GetMakefile().AddDefinition(logVar, chunkDebug.data()); } return true; #else - this->SetError("DOWNLOAD not supported by bootstrap cmake."); + status.SetError("DOWNLOAD not supported by bootstrap cmake."); return false; #endif } -bool cmFileCommand::HandleUploadCommand(std::vector const& args) +bool cmFileCommand::HandleUploadCommand(std::vector const& args, + cmExecutionStatus& status) { #if defined(CMAKE_BUILD_WITH_CMAKE) if (args.size() < 3) { - this->SetError("UPLOAD must be called with at least three arguments."); + status.SetError("UPLOAD must be called with at least three arguments."); return false; } std::vector::const_iterator i = args.begin(); @@ -2027,9 +2042,10 @@ bool cmFileCommand::HandleUploadCommand(std::vector const& args) std::string statusVar; bool showProgress = false; std::string userpwd; - std::string netrc_level = this->Makefile->GetSafeDefinition("CMAKE_NETRC"); + std::string netrc_level = + status.GetMakefile().GetSafeDefinition("CMAKE_NETRC"); std::string netrc_file = - this->Makefile->GetSafeDefinition("CMAKE_NETRC_FILE"); + status.GetMakefile().GetSafeDefinition("CMAKE_NETRC_FILE"); std::vector curl_headers; @@ -2039,7 +2055,7 @@ bool cmFileCommand::HandleUploadCommand(std::vector const& args) if (i != args.end()) { timeout = atol(i->c_str()); } else { - this->SetError("UPLOAD missing time for TIMEOUT."); + status.SetError("UPLOAD missing time for TIMEOUT."); return false; } } else if (*i == "INACTIVITY_TIMEOUT") { @@ -2047,20 +2063,20 @@ bool cmFileCommand::HandleUploadCommand(std::vector const& args) if (i != args.end()) { inactivity_timeout = atol(i->c_str()); } else { - this->SetError("UPLOAD missing time for INACTIVITY_TIMEOUT."); + status.SetError("UPLOAD missing time for INACTIVITY_TIMEOUT."); return false; } } else if (*i == "LOG") { ++i; if (i == args.end()) { - this->SetError("UPLOAD missing VAR for LOG."); + status.SetError("UPLOAD missing VAR for LOG."); return false; } logVar = *i; } else if (*i == "STATUS") { ++i; if (i == args.end()) { - this->SetError("UPLOAD missing VAR for STATUS."); + status.SetError("UPLOAD missing VAR for STATUS."); return false; } statusVar = *i; @@ -2071,7 +2087,7 @@ bool cmFileCommand::HandleUploadCommand(std::vector const& args) if (i != args.end()) { netrc_file = *i; } else { - this->SetError("UPLOAD missing file value for NETRC_FILE."); + status.SetError("UPLOAD missing file value for NETRC_FILE."); return false; } } else if (*i == "NETRC") { @@ -2079,20 +2095,20 @@ bool cmFileCommand::HandleUploadCommand(std::vector const& args) if (i != args.end()) { netrc_level = *i; } else { - this->SetError("UPLOAD missing level value for NETRC."); + status.SetError("UPLOAD missing level value for NETRC."); return false; } } else if (*i == "USERPWD") { ++i; if (i == args.end()) { - this->SetError("UPLOAD missing string for USERPWD."); + status.SetError("UPLOAD missing string for USERPWD."); return false; } userpwd = *i; } else if (*i == "HTTPHEADER") { ++i; if (i == args.end()) { - this->SetError("UPLOAD missing string for HTTPHEADER."); + status.SetError("UPLOAD missing string for HTTPHEADER."); return false; } curl_headers.push_back(*i); @@ -2100,7 +2116,7 @@ bool cmFileCommand::HandleUploadCommand(std::vector const& args) // Do not return error for compatibility reason. std::string err = "Unexpected argument: "; err += *i; - this->Makefile->IssueMessage(MessageType::AUTHOR_WARNING, err); + status.GetMakefile().IssueMessage(MessageType::AUTHOR_WARNING, err); } ++i; @@ -2112,7 +2128,7 @@ bool cmFileCommand::HandleUploadCommand(std::vector const& args) if (!fin) { std::string errStr = "UPLOAD cannot open file '"; errStr += filename + "' for reading."; - this->SetError(errStr); + status.SetError(errStr); return false; } @@ -2126,7 +2142,7 @@ bool cmFileCommand::HandleUploadCommand(std::vector const& args) ::curl_global_init(CURL_GLOBAL_DEFAULT); curl = ::curl_easy_init(); if (!curl) { - this->SetError("UPLOAD error initializing curl."); + status.SetError("UPLOAD error initializing curl."); fclose(fin); return false; } @@ -2220,7 +2236,7 @@ bool cmFileCommand::HandleUploadCommand(std::vector const& args) std::string const& netrc_option_err = cmCurlSetNETRCOption(curl, netrc_level, netrc_file); if (!netrc_option_err.empty()) { - this->SetError(netrc_option_err); + status.SetError(netrc_option_err); return false; } @@ -2242,7 +2258,7 @@ bool cmFileCommand::HandleUploadCommand(std::vector const& args) std::ostringstream result; result << static_cast(res) << ";\"" << ::curl_easy_strerror(res) << "\""; - this->Makefile->AddDefinition(statusVar, result.str()); + status.GetMakefile().AddDefinition(statusVar, result.str()); } ::curl_global_cleanup(); @@ -2267,12 +2283,12 @@ bool cmFileCommand::HandleUploadCommand(std::vector const& args) log += "\n"; } - this->Makefile->AddDefinition(logVar, log); + status.GetMakefile().AddDefinition(logVar, log); } return true; #else - this->SetError("UPLOAD not supported by bootstrap cmake."); + status.SetError("UPLOAD not supported by bootstrap cmake."); return false; #endif } @@ -2280,9 +2296,10 @@ bool cmFileCommand::HandleUploadCommand(std::vector const& args) void cmFileCommand::AddEvaluationFile(const std::string& inputName, const std::string& outputExpr, const std::string& condition, - bool inputIsContent) + bool inputIsContent, + cmExecutionStatus& status) { - cmListFileBacktrace lfbt = this->Makefile->GetBacktrace(); + cmListFileBacktrace lfbt = status.GetMakefile().GetBacktrace(); cmGeneratorExpression outputGe(lfbt); std::unique_ptr outputCge = @@ -2292,50 +2309,52 @@ void cmFileCommand::AddEvaluationFile(const std::string& inputName, std::unique_ptr conditionCge = conditionGe.Parse(condition); - this->Makefile->AddEvaluationFile(inputName, std::move(outputCge), - std::move(conditionCge), inputIsContent); + status.GetMakefile().AddEvaluationFile( + inputName, std::move(outputCge), std::move(conditionCge), inputIsContent); } -bool cmFileCommand::HandleGenerateCommand(std::vector const& args) +bool cmFileCommand::HandleGenerateCommand(std::vector const& args, + cmExecutionStatus& status) { if (args.size() < 5) { - this->SetError("Incorrect arguments to GENERATE subcommand."); + status.SetError("Incorrect arguments to GENERATE subcommand."); return false; } if (args[1] != "OUTPUT") { - this->SetError("Incorrect arguments to GENERATE subcommand."); + status.SetError("Incorrect arguments to GENERATE subcommand."); return false; } std::string condition; if (args.size() > 5) { if (args[5] != "CONDITION") { - this->SetError("Incorrect arguments to GENERATE subcommand."); + status.SetError("Incorrect arguments to GENERATE subcommand."); return false; } if (args.size() != 7) { - this->SetError("Incorrect arguments to GENERATE subcommand."); + status.SetError("Incorrect arguments to GENERATE subcommand."); return false; } condition = args[6]; if (condition.empty()) { - this->SetError("CONDITION of sub-command GENERATE must not be empty if " - "specified."); + status.SetError("CONDITION of sub-command GENERATE must not be empty if " + "specified."); return false; } } std::string output = args[2]; const bool inputIsContent = args[3] != "INPUT"; if (inputIsContent && args[3] != "CONTENT") { - this->SetError("Incorrect arguments to GENERATE subcommand."); + status.SetError("Incorrect arguments to GENERATE subcommand."); return false; } std::string input = args[4]; - this->AddEvaluationFile(input, output, condition, inputIsContent); + this->AddEvaluationFile(input, output, condition, inputIsContent, status); return true; } -bool cmFileCommand::HandleLockCommand(std::vector const& args) +bool cmFileCommand::HandleLockCommand(std::vector const& args, + cmExecutionStatus& status) { #if defined(CMAKE_BUILD_WITH_CMAKE) // Default values @@ -2353,7 +2372,7 @@ bool cmFileCommand::HandleLockCommand(std::vector const& args) // Parse arguments if (args.size() < 2) { - this->Makefile->IssueMessage( + status.GetMakefile().IssueMessage( MessageType::FATAL_ERROR, "sub-command LOCK requires at least two arguments."); return false; @@ -2369,7 +2388,7 @@ bool cmFileCommand::HandleLockCommand(std::vector const& args) ++i; const char* merr = "expected FUNCTION, FILE or PROCESS after GUARD"; if (i >= args.size()) { - this->Makefile->IssueMessage(MessageType::FATAL_ERROR, merr); + status.GetMakefile().IssueMessage(MessageType::FATAL_ERROR, merr); return false; } if (args[i] == "FUNCTION") { @@ -2381,14 +2400,14 @@ bool cmFileCommand::HandleLockCommand(std::vector const& args) } else { std::ostringstream e; e << merr << ", but got:\n \"" << args[i] << "\"."; - this->Makefile->IssueMessage(MessageType::FATAL_ERROR, e.str()); + status.GetMakefile().IssueMessage(MessageType::FATAL_ERROR, e.str()); return false; } } else if (args[i] == "RESULT_VARIABLE") { ++i; if (i >= args.size()) { - this->Makefile->IssueMessage( + status.GetMakefile().IssueMessage( MessageType::FATAL_ERROR, "expected variable name after RESULT_VARIABLE"); return false; @@ -2397,8 +2416,8 @@ bool cmFileCommand::HandleLockCommand(std::vector const& args) } else if (args[i] == "TIMEOUT") { ++i; if (i >= args.size()) { - this->Makefile->IssueMessage(MessageType::FATAL_ERROR, - "expected timeout value after TIMEOUT"); + status.GetMakefile().IssueMessage( + MessageType::FATAL_ERROR, "expected timeout value after TIMEOUT"); return false; } long scanned; @@ -2406,7 +2425,7 @@ bool cmFileCommand::HandleLockCommand(std::vector const& args) scanned < 0) { std::ostringstream e; e << "TIMEOUT value \"" << args[i] << "\" is not an unsigned integer."; - this->Makefile->IssueMessage(MessageType::FATAL_ERROR, e.str()); + status.GetMakefile().IssueMessage(MessageType::FATAL_ERROR, e.str()); return false; } timeout = static_cast(scanned); @@ -2414,7 +2433,7 @@ bool cmFileCommand::HandleLockCommand(std::vector const& args) std::ostringstream e; e << "expected DIRECTORY, RELEASE, GUARD, RESULT_VARIABLE or TIMEOUT\n"; e << "but got: \"" << args[i] << "\"."; - this->Makefile->IssueMessage(MessageType::FATAL_ERROR, e.str()); + status.GetMakefile().IssueMessage(MessageType::FATAL_ERROR, e.str()); return false; } } @@ -2424,7 +2443,7 @@ bool cmFileCommand::HandleLockCommand(std::vector const& args) } if (!cmsys::SystemTools::FileIsFullPath(path)) { - path = this->Makefile->GetCurrentSourceDirectory() + "/" + path; + path = status.GetMakefile().GetCurrentSourceDirectory() + "/" + path; } // Unify path (remove '//', '/../', ...) @@ -2436,7 +2455,7 @@ bool cmFileCommand::HandleLockCommand(std::vector const& args) std::ostringstream e; e << "directory\n \"" << parentDir << "\"\ncreation failed "; e << "(check permissions)."; - this->Makefile->IssueMessage(MessageType::FATAL_ERROR, e.str()); + status.GetMakefile().IssueMessage(MessageType::FATAL_ERROR, e.str()); cmSystemTools::SetFatalErrorOccured(); return false; } @@ -2444,7 +2463,7 @@ bool cmFileCommand::HandleLockCommand(std::vector const& args) if (!file) { std::ostringstream e; e << "file\n \"" << path << "\"\ncreation failed (check permissions)."; - this->Makefile->IssueMessage(MessageType::FATAL_ERROR, e.str()); + status.GetMakefile().IssueMessage(MessageType::FATAL_ERROR, e.str()); cmSystemTools::SetFatalErrorOccured(); return false; } @@ -2452,7 +2471,7 @@ bool cmFileCommand::HandleLockCommand(std::vector const& args) // Actual lock/unlock cmFileLockPool& lockPool = - this->Makefile->GetGlobalGenerator()->GetFileLockPool(); + status.GetMakefile().GetGlobalGenerator()->GetFileLockPool(); cmFileLockResult fileLockResult(cmFileLockResult::MakeOk()); if (release) { @@ -2479,32 +2498,32 @@ bool cmFileCommand::HandleLockCommand(std::vector const& args) if (resultVariable.empty() && !fileLockResult.IsOk()) { std::ostringstream e; e << "error locking file\n \"" << path << "\"\n" << result << "."; - this->Makefile->IssueMessage(MessageType::FATAL_ERROR, e.str()); + status.GetMakefile().IssueMessage(MessageType::FATAL_ERROR, e.str()); cmSystemTools::SetFatalErrorOccured(); return false; } if (!resultVariable.empty()) { - this->Makefile->AddDefinition(resultVariable, result); + status.GetMakefile().AddDefinition(resultVariable, result); } return true; #else static_cast(args); - this->SetError("sub-command LOCK not implemented in bootstrap cmake"); + status.SetError("sub-command LOCK not implemented in bootstrap cmake"); return false; #endif } bool cmFileCommand::HandleTimestampCommand( - std::vector const& args) + std::vector const& args, cmExecutionStatus& status) { if (args.size() < 3) { - this->SetError("sub-command TIMESTAMP requires at least two arguments."); + status.SetError("sub-command TIMESTAMP requires at least two arguments."); return false; } if (args.size() > 5) { - this->SetError("sub-command TIMESTAMP takes at most four arguments."); + status.SetError("sub-command TIMESTAMP takes at most four arguments."); return false; } @@ -2526,7 +2545,7 @@ bool cmFileCommand::HandleTimestampCommand( } else { std::string e = " TIMESTAMP sub-command does not recognize option " + args[argsIndex] + "."; - this->SetError(e); + status.SetError(e); return false; } } @@ -2534,17 +2553,18 @@ bool cmFileCommand::HandleTimestampCommand( cmTimestamp timestamp; std::string result = timestamp.FileModificationTime(filename.c_str(), formatString, utcFlag); - this->Makefile->AddDefinition(outputVariable, result); + status.GetMakefile().AddDefinition(outputVariable, result); return true; } -bool cmFileCommand::HandleSizeCommand(std::vector const& args) +bool cmFileCommand::HandleSizeCommand(std::vector const& args, + cmExecutionStatus& status) { if (args.size() != 3) { std::ostringstream e; e << args[0] << " requires a file name and output variable"; - this->SetError(e.str()); + status.SetError(e.str()); return false; } @@ -2557,23 +2577,23 @@ bool cmFileCommand::HandleSizeCommand(std::vector const& args) if (!cmSystemTools::FileExists(filename, true)) { std::ostringstream e; e << "SIZE requested of path that is not readable:\n " << filename; - this->SetError(e.str()); + status.SetError(e.str()); return false; } - this->Makefile->AddDefinition( + status.GetMakefile().AddDefinition( outputVariable, std::to_string(cmSystemTools::FileLength(filename))); return true; } bool cmFileCommand::HandleReadSymlinkCommand( - std::vector const& args) + std::vector const& args, cmExecutionStatus& status) { if (args.size() != 3) { std::ostringstream e; e << args[0] << " requires a file name and output variable"; - this->SetError(e.str()); + status.SetError(e.str()); return false; } @@ -2585,21 +2605,21 @@ bool cmFileCommand::HandleReadSymlinkCommand( std::ostringstream e; e << "READ_SYMLINK requested of path that is not a symlink:\n " << filename; - this->SetError(e.str()); + status.SetError(e.str()); return false; } - this->Makefile->AddDefinition(outputVariable, result); + status.GetMakefile().AddDefinition(outputVariable, result); return true; } bool cmFileCommand::HandleCreateLinkCommand( - std::vector const& args) + std::vector const& args, cmExecutionStatus& status) { if (args.size() < 3) { - this->SetError("CREATE_LINK must be called with at least two additional " - "arguments"); + status.SetError("CREATE_LINK must be called with at least two additional " + "arguments"); return false; } @@ -2624,7 +2644,7 @@ bool cmFileCommand::HandleCreateLinkCommand( parser.Parse(cmMakeRange(args).advance(3), &unconsumedArgs); if (!unconsumedArgs.empty()) { - this->SetError("unknown argument: \"" + unconsumedArgs.front() + '\"'); + status.SetError("unknown argument: \"" + unconsumedArgs.front() + '\"'); return false; } @@ -2635,10 +2655,10 @@ bool cmFileCommand::HandleCreateLinkCommand( if (fileName == newFileName) { result = "CREATE_LINK cannot use same file and newfile"; if (!arguments.Result.empty()) { - this->Makefile->AddDefinition(arguments.Result, result); + status.GetMakefile().AddDefinition(arguments.Result, result); return true; } - this->SetError(result); + status.SetError(result); return false; } @@ -2646,10 +2666,10 @@ bool cmFileCommand::HandleCreateLinkCommand( if (!arguments.Symbolic && !cmSystemTools::FileExists(fileName)) { result = "Cannot hard link \'" + fileName + "\' as it does not exist."; if (!arguments.Result.empty()) { - this->Makefile->AddDefinition(arguments.Result, result); + status.GetMakefile().AddDefinition(arguments.Result, result); return true; } - this->SetError(result); + status.SetError(result); return false; } @@ -2663,10 +2683,10 @@ bool cmFileCommand::HandleCreateLinkCommand( << cmSystemTools::GetLastSystemError() << "\n"; if (!arguments.Result.empty()) { - this->Makefile->AddDefinition(arguments.Result, e.str()); + status.GetMakefile().AddDefinition(arguments.Result, e.str()); return true; } - this->SetError(e.str()); + status.SetError(e.str()); return false; } @@ -2693,45 +2713,46 @@ bool cmFileCommand::HandleCreateLinkCommand( result = "0"; } else if (arguments.Result.empty()) { // The operation failed and the result is not reported in a variable. - this->SetError(result); + status.SetError(result); return false; } if (!arguments.Result.empty()) { - this->Makefile->AddDefinition(arguments.Result, result); + status.GetMakefile().AddDefinition(arguments.Result, result); } return true; } bool cmFileCommand::HandleGetRuntimeDependenciesCommand( - std::vector const& args) + std::vector const& args, cmExecutionStatus& status) { static const std::set supportedPlatforms = { "Windows", "Linux", "Darwin" }; std::string platform = - this->Makefile->GetSafeDefinition("CMAKE_HOST_SYSTEM_NAME"); + status.GetMakefile().GetSafeDefinition("CMAKE_HOST_SYSTEM_NAME"); if (!supportedPlatforms.count(platform)) { std::ostringstream e; e << "GET_RUNTIME_DEPENDENCIES is not supported on system \"" << platform << "\""; - this->SetError(e.str()); + status.SetError(e.str()); cmSystemTools::SetFatalErrorOccured(); return false; } - if (this->Makefile->GetState()->GetMode() == cmState::Project) { - this->Makefile->IssueMessage(MessageType::AUTHOR_WARNING, - "You have used file(GET_RUNTIME_DEPENDENCIES)" - " in project mode. This is probably not what " - "you intended to do. Instead, please consider" - " using it in an install(CODE) or " - "install(SCRIPT) command. For example:" - "\n install(CODE [[" - "\n file(GET_RUNTIME_DEPENDENCIES" - "\n # ..." - "\n )" - "\n ]])"); + if (status.GetMakefile().GetState()->GetMode() == cmState::Project) { + status.GetMakefile().IssueMessage( + MessageType::AUTHOR_WARNING, + "You have used file(GET_RUNTIME_DEPENDENCIES)" + " in project mode. This is probably not what " + "you intended to do. Instead, please consider" + " using it in an install(CODE) or " + "install(SCRIPT) command. For example:" + "\n install(CODE [[" + "\n file(GET_RUNTIME_DEPENDENCIES" + "\n # ..." + "\n )" + "\n ]])"); } struct Arguments @@ -2776,7 +2797,7 @@ bool cmFileCommand::HandleGetRuntimeDependenciesCommand( if (argIt != unrecognizedArguments.end()) { std::ostringstream e; e << "Unrecognized argument: \"" << *argIt << "\""; - this->SetError(e.str()); + status.SetError(e.str()); cmSystemTools::SetFatalErrorOccured(); return false; } @@ -2784,7 +2805,7 @@ bool cmFileCommand::HandleGetRuntimeDependenciesCommand( if (argIt != keywordsMissingValues.end()) { std::ostringstream e; e << "Keyword missing value: " << *argIt; - this->SetError(e.str()); + status.SetError(e.str()); cmSystemTools::SetFatalErrorOccured(); return false; } @@ -2826,14 +2847,14 @@ bool cmFileCommand::HandleGetRuntimeDependenciesCommand( std::string varName = parsedArgs.ConflictingDependenciesPrefix + "_" + val.first; std::string pathsStr = cmJoin(paths, ";"); - this->Makefile->AddDefinition(varName, pathsStr); + status.GetMakefile().AddDefinition(varName, pathsStr); } else { std::ostringstream e; e << "Multiple conflicting paths found for " << val.first << ":"; for (auto const& path : val.second) { e << "\n " << path; } - this->SetError(e.str()); + status.SetError(e.str()); cmSystemTools::SetFatalErrorOccured(); return false; } @@ -2848,7 +2869,7 @@ bool cmFileCommand::HandleGetRuntimeDependenciesCommand( assert(it != archive.GetUnresolvedPaths().end()); std::ostringstream e; e << "Could not resolve file " << *it; - this->SetError(e.str()); + status.SetError(e.str()); cmSystemTools::SetFatalErrorOccured(); return false; } @@ -2856,15 +2877,17 @@ bool cmFileCommand::HandleGetRuntimeDependenciesCommand( if (!parsedArgs.ResolvedDependenciesVar.empty()) { std::string val = cmJoin(deps, ";"); - this->Makefile->AddDefinition(parsedArgs.ResolvedDependenciesVar, val); + status.GetMakefile().AddDefinition(parsedArgs.ResolvedDependenciesVar, + val); } if (!parsedArgs.UnresolvedDependenciesVar.empty()) { std::string val = cmJoin(unresolvedDeps, ";"); - this->Makefile->AddDefinition(parsedArgs.UnresolvedDependenciesVar, val); + status.GetMakefile().AddDefinition(parsedArgs.UnresolvedDependenciesVar, + val); } if (!parsedArgs.ConflictingDependenciesPrefix.empty()) { std::string val = cmJoin(conflictingDeps, ";"); - this->Makefile->AddDefinition( + status.GetMakefile().AddDefinition( parsedArgs.ConflictingDependenciesPrefix + "_FILENAMES", val); } return true; diff --git a/Source/cmFileCommand.h b/Source/cmFileCommand.h index d4b980e..e33c576 100644 --- a/Source/cmFileCommand.h +++ b/Source/cmFileCommand.h @@ -37,43 +37,69 @@ public: cmExecutionStatus& status) override; protected: - bool HandleRename(std::vector const& args); - bool HandleRemove(std::vector const& args, bool recurse); - bool HandleWriteCommand(std::vector const& args, bool append); - bool HandleReadCommand(std::vector const& args); - bool HandleHashCommand(std::vector const& args); - bool HandleStringsCommand(std::vector const& args); - bool HandleGlobCommand(std::vector const& args, bool recurse); - bool HandleTouchCommand(std::vector const& args, bool create); - bool HandleMakeDirectoryCommand(std::vector const& args); + bool HandleRename(std::vector const& args, + cmExecutionStatus& status); + bool HandleRemove(std::vector const& args, bool recurse, + cmExecutionStatus& status); + bool HandleWriteCommand(std::vector const& args, bool append, + cmExecutionStatus& status); + bool HandleReadCommand(std::vector const& args, + cmExecutionStatus& status); + bool HandleHashCommand(std::vector const& args, + cmExecutionStatus& status); + bool HandleStringsCommand(std::vector const& args, + cmExecutionStatus& status); + bool HandleGlobCommand(std::vector const& args, bool recurse, + cmExecutionStatus& status); + bool HandleTouchCommand(std::vector const& args, bool create, + cmExecutionStatus& status); + bool HandleMakeDirectoryCommand(std::vector const& args, + cmExecutionStatus& status); - bool HandleRelativePathCommand(std::vector const& args); + bool HandleRelativePathCommand(std::vector const& args, + cmExecutionStatus& status); bool HandleCMakePathCommand(std::vector const& args, - bool nativePath); - bool HandleReadElfCommand(std::vector const& args); - bool HandleRPathChangeCommand(std::vector const& args); - bool HandleRPathCheckCommand(std::vector const& args); - bool HandleRPathRemoveCommand(std::vector const& args); - bool HandleDifferentCommand(std::vector const& args); + bool nativePath, cmExecutionStatus& status); + bool HandleReadElfCommand(std::vector const& args, + cmExecutionStatus& status); + bool HandleRPathChangeCommand(std::vector const& args, + cmExecutionStatus& status); + bool HandleRPathCheckCommand(std::vector const& args, + cmExecutionStatus& status); + bool HandleRPathRemoveCommand(std::vector const& args, + cmExecutionStatus& status); + bool HandleDifferentCommand(std::vector const& args, + cmExecutionStatus& status); - bool HandleCopyCommand(std::vector const& args); - bool HandleInstallCommand(std::vector const& args); - bool HandleDownloadCommand(std::vector const& args); - bool HandleUploadCommand(std::vector const& args); + bool HandleCopyCommand(std::vector const& args, + cmExecutionStatus& status); + bool HandleInstallCommand(std::vector const& args, + cmExecutionStatus& status); + bool HandleDownloadCommand(std::vector const& args, + cmExecutionStatus& status); + bool HandleUploadCommand(std::vector const& args, + cmExecutionStatus& status); - bool HandleTimestampCommand(std::vector const& args); - bool HandleGenerateCommand(std::vector const& args); - bool HandleLockCommand(std::vector const& args); - bool HandleSizeCommand(std::vector const& args); - bool HandleReadSymlinkCommand(std::vector const& args); - bool HandleCreateLinkCommand(std::vector const& args); + bool HandleTimestampCommand(std::vector const& args, + cmExecutionStatus& status); + bool HandleGenerateCommand(std::vector const& args, + cmExecutionStatus& status); + bool HandleLockCommand(std::vector const& args, + cmExecutionStatus& status); + bool HandleSizeCommand(std::vector const& args, + cmExecutionStatus& status); + bool HandleReadSymlinkCommand(std::vector const& args, + cmExecutionStatus& status); + bool HandleCreateLinkCommand(std::vector const& args, + cmExecutionStatus& status); bool HandleGetRuntimeDependenciesCommand( - std::vector const& args); + std::vector const& args, cmExecutionStatus& status); private: void AddEvaluationFile(const std::string& inputName, const std::string& outputExpr, - const std::string& condition, bool inputIsContent); + const std::string& condition, bool inputIsContent, + cmExecutionStatus& status); }; #endif diff --git a/Source/cmFileCopier.cxx b/Source/cmFileCopier.cxx index 4f1a158..1ea824f 100644 --- a/Source/cmFileCopier.cxx +++ b/Source/cmFileCopier.cxx @@ -3,8 +3,8 @@ #include "cmFileCopier.h" +#include "cmExecutionStatus.h" #include "cmFSPermissions.h" -#include "cmFileCommand.h" #include "cmFileTimes.h" #include "cmMakefile.h" #include "cmSystemTools.h" @@ -20,9 +20,9 @@ using namespace cmFSPermissions; -cmFileCopier::cmFileCopier(cmFileCommand* command, const char* name) - : FileCommand(command) - , Makefile(command->GetMakefile()) +cmFileCopier::cmFileCopier(cmExecutionStatus& status, const char* name) + : Status(status) + , Makefile(&status.GetMakefile()) , Name(name) , Always(false) , MatchlessFiles(true) @@ -91,7 +91,7 @@ bool cmFileCopier::SetPermissions(const std::string& toFile, if (!cmSystemTools::SetPermissions(toFile, permissions)) { std::ostringstream e; e << this->Name << " cannot set permissions on \"" << toFile << "\""; - this->FileCommand->SetError(e.str()); + this->Status.SetError(e.str()); return false; } } @@ -105,7 +105,7 @@ bool cmFileCopier::CheckPermissions(std::string const& arg, if (!cmFSPermissions::stringToModeT(arg, permissions)) { std::ostringstream e; e << this->Name << " given invalid permission \"" << arg << "\"."; - this->FileCommand->SetError(e.str()); + this->Status.SetError(e.str()); return false; } return true; @@ -121,7 +121,7 @@ bool cmFileCopier::ReportMissing(const std::string& fromFile) // The input file does not exist and installation is not optional. std::ostringstream e; e << this->Name << " cannot find \"" << fromFile << "\"."; - this->FileCommand->SetError(e.str()); + this->Status.SetError(e.str()); return false; } @@ -129,7 +129,7 @@ void cmFileCopier::NotBeforeMatch(std::string const& arg) { std::ostringstream e; e << "option " << arg << " may not appear before PATTERN or REGEX."; - this->FileCommand->SetError(e.str()); + this->Status.SetError(e.str()); this->Doing = DoingError; } @@ -137,7 +137,7 @@ void cmFileCopier::NotAfterMatch(std::string const& arg) { std::ostringstream e; e << "option " << arg << " may not appear after PATTERN or REGEX."; - this->FileCommand->SetError(e.str()); + this->Status.SetError(e.str()); this->Doing = DoingError; } @@ -174,7 +174,7 @@ bool cmFileCopier::GetDefaultDirectoryPermissions(mode_t** mode) cmSystemTools::ExpandListArgument(default_dir_install_permissions, items); for (const auto& arg : items) { if (!this->CheckPermissions(arg, **mode)) { - this->FileCommand->SetError( + this->Status.SetError( " Set with CMAKE_INSTALL_DEFAULT_DIRECTORY_PERMISSIONS variable."); return false; } @@ -194,7 +194,7 @@ bool cmFileCopier::Parse(std::vector const& args) if (!this->CheckKeyword(args[i]) && !this->CheckValue(args[i])) { std::ostringstream e; e << "called with unknown argument \"" << args[i] << "\"."; - this->FileCommand->SetError(e.str()); + this->Status.SetError(e.str()); return false; } @@ -208,7 +208,7 @@ bool cmFileCopier::Parse(std::vector const& args) if (this->Destination.empty()) { std::ostringstream e; e << this->Name << " given no DESTINATION"; - this->FileCommand->SetError(e.str()); + this->Status.SetError(e.str()); return false; } @@ -341,7 +341,7 @@ bool cmFileCopier::CheckValue(std::string const& arg) } else { std::ostringstream e; e << "could not compile PATTERN \"" << arg << "\"."; - this->FileCommand->SetError(e.str()); + this->Status.SetError(e.str()); this->Doing = DoingError; } } break; @@ -353,7 +353,7 @@ bool cmFileCopier::CheckValue(std::string const& arg) } else { std::ostringstream e; e << "could not compile REGEX \"" << arg << "\"."; - this->FileCommand->SetError(e.str()); + this->Status.SetError(e.str()); this->Doing = DoingError; } break; @@ -396,8 +396,8 @@ bool cmFileCopier::Run(std::vector const& args) file += "/"; file += f; } else if (!this->FilesFromDir.empty()) { - this->FileCommand->SetError("option FILES_FROM_DIR requires all files " - "to be specified as relative paths."); + this->Status.SetError("option FILES_FROM_DIR requires all files " + "to be specified as relative paths."); return false; } else { file = f; @@ -446,7 +446,7 @@ bool cmFileCopier::Install(const std::string& fromFile, if (fromFile.empty()) { std::ostringstream e; e << "INSTALL encountered an empty string input file name."; - this->FileCommand->SetError(e.str()); + this->Status.SetError(e.str()); return false; } @@ -514,7 +514,7 @@ bool cmFileCopier::InstallSymlinkChain(std::string& fromFile, if (!cmSystemTools::CreateSymlink(symlinkTarget, toFile)) { std::ostringstream e; e << this->Name << " cannot create symlink \"" << toFile << "\"."; - this->FileCommand->SetError(e.str()); + this->Status.SetError(e.str()); return false; } } @@ -535,7 +535,7 @@ bool cmFileCopier::InstallSymlink(const std::string& fromFile, std::ostringstream e; e << this->Name << " cannot read symlink \"" << fromFile << "\" to duplicate at \"" << toFile << "\"."; - this->FileCommand->SetError(e.str()); + this->Status.SetError(e.str()); return false; } @@ -566,7 +566,7 @@ bool cmFileCopier::InstallSymlink(const std::string& fromFile, std::ostringstream e; e << this->Name << " cannot duplicate symlink \"" << fromFile << "\" at \"" << toFile << "\"."; - this->FileCommand->SetError(e.str()); + this->Status.SetError(e.str()); return false; } } @@ -595,7 +595,7 @@ bool cmFileCopier::InstallFile(const std::string& fromFile, std::ostringstream e; e << this->Name << " cannot copy file \"" << fromFile << "\" to \"" << toFile << "\"."; - this->FileCommand->SetError(e.str()); + this->Status.SetError(e.str()); return false; } @@ -611,7 +611,7 @@ bool cmFileCopier::InstallFile(const std::string& fromFile, std::ostringstream e; e << this->Name << " cannot set modification time on \"" << toFile << "\""; - this->FileCommand->SetError(e.str()); + this->Status.SetError(e.str()); return false; } } @@ -648,7 +648,7 @@ bool cmFileCopier::InstallDirectory(const std::string& source, std::ostringstream e; e << this->Name << " cannot make directory \"" << destination << "\": " << cmSystemTools::GetLastSystemError(); - this->FileCommand->SetError(e.str()); + this->Status.SetError(e.str()); return false; } diff --git a/Source/cmFileCopier.h b/Source/cmFileCopier.h index a79a60b..263a365 100644 --- a/Source/cmFileCopier.h +++ b/Source/cmFileCopier.h @@ -12,19 +12,19 @@ #include #include -class cmFileCommand; +class cmExecutionStatus; class cmMakefile; // File installation helper class. struct cmFileCopier { - cmFileCopier(cmFileCommand* command, const char* name = "COPY"); + cmFileCopier(cmExecutionStatus& status, const char* name = "COPY"); virtual ~cmFileCopier(); bool Run(std::vector const& args); protected: - cmFileCommand* FileCommand; + cmExecutionStatus& Status; cmMakefile* Makefile; const char* Name; bool Always; diff --git a/Source/cmFileInstaller.cxx b/Source/cmFileInstaller.cxx index 9378439..d28ef41 100644 --- a/Source/cmFileInstaller.cxx +++ b/Source/cmFileInstaller.cxx @@ -3,8 +3,8 @@ #include "cmFileInstaller.h" +#include "cmExecutionStatus.h" #include "cmFSPermissions.h" -#include "cmFileCommand.h" #include "cmMakefile.h" #include "cmSystemTools.h" @@ -14,8 +14,8 @@ using namespace cmFSPermissions; -cmFileInstaller::cmFileInstaller(cmFileCommand* command) - : cmFileCopier(command, "INSTALL") +cmFileInstaller::cmFileInstaller(cmExecutionStatus& status) + : cmFileCopier(status, "INSTALL") , InstallType(cmInstallType_FILES) , Optional(false) , MessageAlways(false) @@ -111,19 +111,19 @@ bool cmFileInstaller::Parse(std::vector const& args) if (!this->Rename.empty()) { if (!this->FilesFromDir.empty()) { - this->FileCommand->SetError("INSTALL option RENAME may not be " - "combined with FILES_FROM_DIR."); + this->Status.SetError("INSTALL option RENAME may not be " + "combined with FILES_FROM_DIR."); return false; } if (this->InstallType != cmInstallType_FILES && this->InstallType != cmInstallType_PROGRAMS) { - this->FileCommand->SetError("INSTALL option RENAME may be used " - "only with FILES or PROGRAMS."); + this->Status.SetError("INSTALL option RENAME may be used " + "only with FILES or PROGRAMS."); return false; } if (this->Files.size() > 1) { - this->FileCommand->SetError("INSTALL option RENAME may be used " - "only with one file."); + this->Status.SetError("INSTALL option RENAME may be used " + "only with one file."); return false; } } @@ -134,9 +134,9 @@ bool cmFileInstaller::Parse(std::vector const& args) if (((this->MessageAlways ? 1 : 0) + (this->MessageLazy ? 1 : 0) + (this->MessageNever ? 1 : 0)) > 1) { - this->FileCommand->SetError("INSTALL options MESSAGE_ALWAYS, " - "MESSAGE_LAZY, and MESSAGE_NEVER " - "are mutually exclusive."); + this->Status.SetError("INSTALL options MESSAGE_ALWAYS, " + "MESSAGE_LAZY, and MESSAGE_NEVER " + "are mutually exclusive."); return false; } @@ -213,7 +213,7 @@ bool cmFileInstaller::CheckKeyword(std::string const& arg) e << "INSTALL called with old-style " << arg << " argument. " << "This script was generated with an older version of CMake. " << "Re-run this cmake version on your build tree."; - this->FileCommand->SetError(e.str()); + this->Status.SetError(e.str()); this->Doing = DoingError; } else { return this->cmFileCopier::CheckKeyword(arg); @@ -257,7 +257,7 @@ bool cmFileInstaller::GetTargetTypeFromString(const std::string& stype) } else { std::ostringstream e; e << "Option TYPE given unknown value \"" << stype << "\"."; - this->FileCommand->SetError(e.str()); + this->Status.SetError(e.str()); return false; } return true; @@ -269,8 +269,8 @@ bool cmFileInstaller::HandleInstallDestination() // allow for / to be a valid destination if (destination.size() < 2 && destination != "/") { - this->FileCommand->SetError("called with inappropriate arguments. " - "No DESTINATION provided or ."); + this->Status.SetError("called with inappropriate arguments. " + "No DESTINATION provided or ."); return false; } @@ -300,7 +300,7 @@ bool cmFileInstaller::HandleInstallDestination() if (relative) { // This is relative path on unix or windows. Since we are doing // destdir, this case does not make sense. - this->FileCommand->SetError( + this->Status.SetError( "called with relative DESTINATION. This " "does not make sense when using DESTDIR. Specify " "absolute path or remove DESTDIR environment variable."); @@ -315,7 +315,7 @@ bool cmFileInstaller::HandleInstallDestination() "absolute path or remove DESTDIR environment variable." "\nDESTINATION=\n"; message += destination; - this->FileCommand->SetError(message); + this->Status.SetError(message); return false; } } @@ -335,14 +335,14 @@ bool cmFileInstaller::HandleInstallDestination() if (!cmSystemTools::MakeDirectory(destination, default_dir_mode)) { std::string errstring = "cannot create directory: " + destination + ". Maybe need administrative privileges."; - this->FileCommand->SetError(errstring); + this->Status.SetError(errstring); return false; } } if (!cmSystemTools::FileIsDirectory(destination)) { std::string errstring = "INSTALL destination: " + destination + " is not a directory."; - this->FileCommand->SetError(errstring); + this->Status.SetError(errstring); return false; } } diff --git a/Source/cmFileInstaller.h b/Source/cmFileInstaller.h index 312529a..fd883ea 100644 --- a/Source/cmFileInstaller.h +++ b/Source/cmFileInstaller.h @@ -12,11 +12,11 @@ #include #include -class cmFileCommand; +class cmExecutionStatus; struct cmFileInstaller : public cmFileCopier { - cmFileInstaller(cmFileCommand* command); + cmFileInstaller(cmExecutionStatus& status); ~cmFileInstaller() override; protected: ----------------------------------------------------------------------- Summary of changes: Source/CMakeLists.txt | 2 + Source/cmCommands.cxx | 2 +- Source/cmFileCommand.cxx | 829 +++++++++++++++++----------------- Source/cmFileCommand.h | 67 +-- Source/cmFileCopier.cxx | 46 +- Source/cmFileCopier.h | 6 +- Source/cmFileInstaller.cxx | 40 +- Source/cmFileInstaller.h | 4 +- Source/cmRuntimeDependencyArchive.cxx | 10 +- Source/cmRuntimeDependencyArchive.h | 6 +- Source/cmSubcommandTable.cxx | 31 ++ Source/cmSubcommandTable.h | 36 ++ bootstrap | 1 + 13 files changed, 552 insertions(+), 528 deletions(-) create mode 100644 Source/cmSubcommandTable.cxx create mode 100644 Source/cmSubcommandTable.h hooks/post-receive -- CMake From kwrobot at kitware.com Sat Aug 10 00:02:42 2019 From: kwrobot at kitware.com (Kitware Robot) Date: Sat, 10 Aug 2019 00:02:42 -0400 (EDT) Subject: [Cmake-commits] CMake branch, master, updated. v3.15.2-620-g32a7605 Message-ID: <20190810040242.D0415125834@public.kitware.com> This is an automated email from the git hooks/post-receive script. It was generated because a ref change was pushed to the repository containing the project "CMake". The branch, master has been updated via 32a7605e69e3faf56bf51da1641a7ae897d23826 (commit) from 1996e0157826903f27f73825a01f83d53dc8fba4 (commit) Those revisions listed above that are new to this repository have not appeared on any other notification email; so we list those revisions in full, below. - Log ----------------------------------------------------------------- https://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=32a7605e69e3faf56bf51da1641a7ae897d23826 commit 32a7605e69e3faf56bf51da1641a7ae897d23826 Author: Kitware Robot AuthorDate: Sat Aug 10 00:01:11 2019 -0400 Commit: Kitware Robot CommitDate: Sat Aug 10 00:01:11 2019 -0400 CMake Nightly Date Stamp diff --git a/Source/CMakeVersion.cmake b/Source/CMakeVersion.cmake index 1a93578..341bd9d 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 15) -set(CMake_VERSION_PATCH 20190809) +set(CMake_VERSION_PATCH 20190810) #set(CMake_VERSION_RC 0) set(CMake_VERSION_IS_DIRTY 0) ----------------------------------------------------------------------- Summary of changes: Source/CMakeVersion.cmake | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) hooks/post-receive -- CMake From kwrobot at kitware.com Sun Aug 11 00:02:08 2019 From: kwrobot at kitware.com (Kitware Robot) Date: Sun, 11 Aug 2019 00:02:08 -0400 (EDT) Subject: [Cmake-commits] CMake branch, master, updated. v3.15.2-621-g70c56b8 Message-ID: <20190811040208.2CD66102DEE@public.kitware.com> This is an automated email from the git hooks/post-receive script. It was generated because a ref change was pushed to the repository containing the project "CMake". The branch, master has been updated via 70c56b856c2341837613a4f5e55b32b857a02456 (commit) from 32a7605e69e3faf56bf51da1641a7ae897d23826 (commit) Those revisions listed above that are new to this repository have not appeared on any other notification email; so we list those revisions in full, below. - Log ----------------------------------------------------------------- https://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=70c56b856c2341837613a4f5e55b32b857a02456 commit 70c56b856c2341837613a4f5e55b32b857a02456 Author: Kitware Robot AuthorDate: Sun Aug 11 00:01:08 2019 -0400 Commit: Kitware Robot CommitDate: Sun Aug 11 00:01:08 2019 -0400 CMake Nightly Date Stamp diff --git a/Source/CMakeVersion.cmake b/Source/CMakeVersion.cmake index 341bd9d..93f3e63 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 15) -set(CMake_VERSION_PATCH 20190810) +set(CMake_VERSION_PATCH 20190811) #set(CMake_VERSION_RC 0) set(CMake_VERSION_IS_DIRTY 0) ----------------------------------------------------------------------- Summary of changes: Source/CMakeVersion.cmake | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) hooks/post-receive -- CMake From kwrobot at kitware.com Mon Aug 12 00:01:34 2019 From: kwrobot at kitware.com (Kitware Robot) Date: Mon, 12 Aug 2019 00:01:34 -0400 (EDT) Subject: [Cmake-commits] CMake branch, master, updated. v3.15.2-622-g42c9937 Message-ID: <20190812040134.A297A101D81@public.kitware.com> This is an automated email from the git hooks/post-receive script. It was generated because a ref change was pushed to the repository containing the project "CMake". The branch, master has been updated via 42c993742d8f92c54043363909803a2242f111d3 (commit) from 70c56b856c2341837613a4f5e55b32b857a02456 (commit) Those revisions listed above that are new to this repository have not appeared on any other notification email; so we list those revisions in full, below. - Log ----------------------------------------------------------------- https://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=42c993742d8f92c54043363909803a2242f111d3 commit 42c993742d8f92c54043363909803a2242f111d3 Author: Kitware Robot AuthorDate: Mon Aug 12 00:01:06 2019 -0400 Commit: Kitware Robot CommitDate: Mon Aug 12 00:01:06 2019 -0400 CMake Nightly Date Stamp diff --git a/Source/CMakeVersion.cmake b/Source/CMakeVersion.cmake index 93f3e63..9900889 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 15) -set(CMake_VERSION_PATCH 20190811) +set(CMake_VERSION_PATCH 20190812) #set(CMake_VERSION_RC 0) set(CMake_VERSION_IS_DIRTY 0) ----------------------------------------------------------------------- Summary of changes: Source/CMakeVersion.cmake | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) hooks/post-receive -- CMake From kwrobot at kitware.com Tue Aug 13 00:00:59 2019 From: kwrobot at kitware.com (Kitware Robot) Date: Tue, 13 Aug 2019 00:00:59 -0400 (EDT) Subject: [Cmake-commits] CMake branch, master, updated. v3.15.2-623-g7d194f7 Message-ID: <20190813040059.F08CAE36D1@public.kitware.com> This is an automated email from the git hooks/post-receive script. It was generated because a ref change was pushed to the repository containing the project "CMake". The branch, master has been updated via 7d194f7d8331a127e0b2b921dc6bc0abfe21a0f5 (commit) from 42c993742d8f92c54043363909803a2242f111d3 (commit) Those revisions listed above that are new to this repository have not appeared on any other notification email; so we list those revisions in full, below. - Log ----------------------------------------------------------------- https://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=7d194f7d8331a127e0b2b921dc6bc0abfe21a0f5 commit 7d194f7d8331a127e0b2b921dc6bc0abfe21a0f5 Author: Kitware Robot AuthorDate: Tue Aug 13 00:01:05 2019 -0400 Commit: Kitware Robot CommitDate: Tue Aug 13 00:01:05 2019 -0400 CMake Nightly Date Stamp diff --git a/Source/CMakeVersion.cmake b/Source/CMakeVersion.cmake index 9900889..40a4ee6 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 15) -set(CMake_VERSION_PATCH 20190812) +set(CMake_VERSION_PATCH 20190813) #set(CMake_VERSION_RC 0) set(CMake_VERSION_IS_DIRTY 0) ----------------------------------------------------------------------- Summary of changes: Source/CMakeVersion.cmake | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) hooks/post-receive -- CMake From kwrobot at kitware.com Tue Aug 13 10:00:52 2019 From: kwrobot at kitware.com (Kitware Robot) Date: Tue, 13 Aug 2019 10:00:52 -0400 (EDT) Subject: [Cmake-commits] CMake branch, master, updated. v3.15.2-638-g7099d11 Message-ID: <20190813140052.B34C7113D65@public.kitware.com> This is an automated email from the git hooks/post-receive script. It was generated because a ref change was pushed to the repository containing the project "CMake". The branch, master has been updated via 7099d113aed4789848a69869befb068e6fadafcc (commit) via dabd16926b52d9bd3ddb96edc515ff7ce7f1b4d5 (commit) via f952d9c2573cd243e89f466ec79e9b7dbad9fd06 (commit) via 17b66165f651b20792b13a35b3a1a985d9b1505e (commit) via 9ab15fa74aeec42adef00aae8c4ee5a5ffabdf70 (commit) via 9e9766d85cc81ba22819dec2d543da2565f2c04b (commit) via d4d5053c308662b529c9a578258b18a54fdce6e5 (commit) via fe921edd49f6acc37570f51f8ead3158069dfda4 (commit) via 54e9d38c28d0073f2cc5d690adb5c993e7793c97 (commit) via ad0e44a18b1e54bcfac38100a13e6ce169d03099 (commit) via 27090096ef3dc572515c23e2ec92e5ee19432950 (commit) via 62659100aa4ad25fabf07797ace186f11463237e (commit) via 9ba0bf60c6a1dc0904c40575efd69bba580b0902 (commit) via a233e4e7d9c157cae0098762d8a7add463fb3492 (commit) via 8f1d22c2d9922e55565c3cd51b91bb3a6c33ffdc (commit) from 7d194f7d8331a127e0b2b921dc6bc0abfe21a0f5 (commit) Those revisions listed above that are new to this repository have not appeared on any other notification email; so we list those revisions in full, below. - Log ----------------------------------------------------------------- https://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=7099d113aed4789848a69869befb068e6fadafcc commit 7099d113aed4789848a69869befb068e6fadafcc Merge: dabd169 8f1d22c Author: Kyle Edwards AuthorDate: Tue Aug 13 13:57:49 2019 +0000 Commit: Kitware Robot CommitDate: Tue Aug 13 09:58:03 2019 -0400 Merge topic 'support_CMAKE_CUDA_RESOLVE_DEVICE_SYMBOLS' 8f1d22c2d9 CUDA: Support CMAKE_CUDA_RESOLVE_DEVICE_SYMBOLS global variable Acked-by: Kitware Robot Merge-request: !3636 https://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=dabd16926b52d9bd3ddb96edc515ff7ce7f1b4d5 commit dabd16926b52d9bd3ddb96edc515ff7ce7f1b4d5 Merge: f952d9c a233e4e Author: Kyle Edwards AuthorDate: Tue Aug 13 13:55:50 2019 +0000 Commit: Kitware Robot CommitDate: Tue Aug 13 09:56:47 2019 -0400 Merge topic 'cuda_separable_compilation_determined_by_compiler_id' a233e4e7d9 CUDA: Compilers can now state they don't require a device linking step Acked-by: Kitware Robot Merge-request: !3659 https://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=f952d9c2573cd243e89f466ec79e9b7dbad9fd06 commit f952d9c2573cd243e89f466ec79e9b7dbad9fd06 Merge: 17b6616 9ba0bf6 Author: Kyle Edwards AuthorDate: Tue Aug 13 13:54:31 2019 +0000 Commit: Kitware Robot CommitDate: Tue Aug 13 09:55:09 2019 -0400 Merge topic 'free-command-a' 9ba0bf60c6 cmA*Command: Turn into free functions Acked-by: Kitware Robot Merge-request: !3660 diff --cc Source/cmCommands.cxx index 8c62c30,9e3341d..8565e1c --- a/Source/cmCommands.cxx +++ b/Source/cmCommands.cxx @@@ -301,13 -294,12 +294,12 @@@ void GetProjectCommands(cmState* state cm::make_unique()); state->AddBuiltinCommand("try_run", cm::make_unique()); -#if defined(CMAKE_BUILD_WITH_CMAKE) +#if !defined(CMAKE_BOOTSTRAP) state->AddBuiltinCommand("add_compile_definitions", - cm::make_unique()); - state->AddBuiltinCommand("add_compile_options", - cm::make_unique()); + cmAddCompileDefinitionsCommand); + state->AddBuiltinCommand("add_compile_options", cmAddCompileOptionsCommand); state->AddBuiltinCommand("aux_source_directory", - cm::make_unique()); + cmAuxSourceDirectoryCommand); state->AddBuiltinCommand("export", cm::make_unique()); state->AddBuiltinCommand("fltk_wrap_ui", cm::make_unique()); https://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=17b66165f651b20792b13a35b3a1a985d9b1505e commit 17b66165f651b20792b13a35b3a1a985d9b1505e Merge: 9ab15fa 6265910 Author: Kyle Edwards AuthorDate: Tue Aug 13 13:53:21 2019 +0000 Commit: Kitware Robot CommitDate: Tue Aug 13 09:53:47 2019 -0400 Merge topic 'strcat-localgenerator' 62659100aa cmLocalGenerator: Use cmStrCat Acked-by: Kitware Robot Acked-by: Sebastian Holtermann Merge-request: !3671 https://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=9ab15fa74aeec42adef00aae8c4ee5a5ffabdf70 commit 9ab15fa74aeec42adef00aae8c4ee5a5ffabdf70 Merge: 9e9766d 2709009 Author: Kyle Edwards AuthorDate: Tue Aug 13 13:52:05 2019 +0000 Commit: Kitware Robot CommitDate: Tue Aug 13 09:52:23 2019 -0400 Merge topic 'cmRemoveQuotes' 27090096ef cmStringAlgorithms: Add cmRemoveQuotes Acked-by: Kitware Robot Merge-request: !3665 https://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=9e9766d85cc81ba22819dec2d543da2565f2c04b commit 9e9766d85cc81ba22819dec2d543da2565f2c04b Merge: 7d194f7 d4d5053 Author: Kyle Edwards AuthorDate: Tue Aug 13 13:50:26 2019 +0000 Commit: Kitware Robot CommitDate: Tue Aug 13 09:50:42 2019 -0400 Merge topic 'cmake-bootstrap-def' d4d5053c30 Refactor: Finish replacing CMAKE_BUILD_WITH_CMAKE with CMAKE_BOOTSTRAP fe921edd49 Utilities/Scripts: Remove temporary CMAKE_BOOTSTRAP conversion script 54e9d38c28 Refactor: Convert all instances of CMAKE_BUILD_WITH_CMAKE to CMAKE_BOOTSTRAP ad0e44a18b Utilities/Scripts: Add temporary CMAKE_BOOTSTRAP conversion script Acked-by: Kitware Robot Merge-request: !3662 https://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=d4d5053c308662b529c9a578258b18a54fdce6e5 commit d4d5053c308662b529c9a578258b18a54fdce6e5 Author: Kyle Edwards AuthorDate: Thu Aug 8 11:40:41 2019 -0400 Commit: Kyle Edwards CommitDate: Fri Aug 9 10:42:02 2019 -0400 Refactor: Finish replacing CMAKE_BUILD_WITH_CMAKE with CMAKE_BOOTSTRAP Remove -DCMAKE_BUILD_WITH_CMAKE from Source/CMakeLists.txt. Remove CMAKE_BOOTSTRAP from bootstrap's cmConfigure.h. Add -DCMAKE_BOOTSTRAP to all bootstrap sources, and remove the Unix specialization of CMAKE_BOOTSTRAP in libuv (a review of the libuv code suggests that this will not have an effect on the Windows build.) diff --git a/Source/CMakeLists.txt b/Source/CMakeLists.txt index ee82ff5..7cd07a8 100644 --- a/Source/CMakeLists.txt +++ b/Source/CMakeLists.txt @@ -95,9 +95,6 @@ include_directories( ${CMake_HAIKU_INCLUDE_DIRS} ) -# let cmake know it is supposed to use it -add_definitions(-DCMAKE_BUILD_WITH_CMAKE) - # Check if we can build the ELF parser. if(CMAKE_USE_ELF_PARSER) set(ELF_SRCS cmELF.h cmELF.cxx) diff --git a/bootstrap b/bootstrap index c97a5d4..4581239 100755 --- a/bootstrap +++ b/bootstrap @@ -1362,7 +1362,6 @@ cmake_report cmConfigure.h${_tmp} "#define CMAKE_BOOTSTRAP_BINARY_DIR \"${CMAKE_ cmake_report cmConfigure.h${_tmp} "#define CMake_DEFAULT_RECURSION_LIMIT 400" cmake_report cmConfigure.h${_tmp} "#define CMAKE_BIN_DIR \"/bootstrap-not-insalled\"" cmake_report cmConfigure.h${_tmp} "#define CMAKE_DATA_DIR \"/bootstrap-not-insalled\"" -cmake_report cmConfigure.h${_tmp} "#define CMAKE_BOOTSTRAP" cmake_report cmConfigure.h${_tmp} "#define CM_FALLTHROUGH" # Regenerate configured headers @@ -1408,7 +1407,6 @@ if ${cmake_system_mingw}; then uv_c_flags="${uv_c_flags} -DWIN32_LEAN_AND_MEAN -D_WIN32_WINNT=0x0600" libs="${libs} -lws2_32 -lpsapi -liphlpapi -lshell32 -luserenv -lole32 -loleaut32" else - uv_c_flags="${uv_c_flags} -DCMAKE_BOOTSTRAP" case "${cmake_system}" in *AIX*) uv_c_flags="${uv_c_flags} -D_ALL_SOURCE -D_XOPEN_SOURCE=500 -D_LINUX_SOURCE_COMPAT" @@ -1469,11 +1467,13 @@ cmake_cxx_flags_SystemTools=" -DKWSYS_CXX_HAS_UTIMES=${KWSYS_CXX_HAS_UTIMES} " cmake_c_flags="${cmake_c_flags} \ + -DCMAKE_BOOTSTRAP \ -I`cmake_escape \"${cmake_bootstrap_dir}\"` \ -I`cmake_escape \"${cmake_source_dir}/Source\"` \ -I`cmake_escape \"${cmake_source_dir}/Source/LexerParser\"` \ -I`cmake_escape \"${cmake_source_dir}/Utilities\"`" cmake_cxx_flags="${cmake_cxx_flags} \ + -DCMAKE_BOOTSTRAP \ -I`cmake_escape \"${cmake_bootstrap_dir}\"` \ -I`cmake_escape \"${cmake_source_dir}/Source\"` \ -I`cmake_escape \"${cmake_source_dir}/Source/LexerParser\"` \ https://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=fe921edd49f6acc37570f51f8ead3158069dfda4 commit fe921edd49f6acc37570f51f8ead3158069dfda4 Author: Kyle Edwards AuthorDate: Thu Aug 8 10:53:58 2019 -0400 Commit: Kyle Edwards CommitDate: Fri Aug 9 10:42:02 2019 -0400 Utilities/Scripts: Remove temporary CMAKE_BOOTSTRAP conversion script diff --git a/Utilities/Scripts/cmake-bootstrap-def.sh b/Utilities/Scripts/cmake-bootstrap-def.sh deleted file mode 100755 index 09feded..0000000 --- a/Utilities/Scripts/cmake-bootstrap-def.sh +++ /dev/null @@ -1,7 +0,0 @@ -#!/bin/sh - -sed -i -e 's/!defined(CMAKE_BUILD_WITH_CMAKE)/defined(CMAKE_BOOTSTRAP)/g' \ - -e 's/defined(CMAKE_BUILD_WITH_CMAKE)/!defined(CMAKE_BOOTSTRAP)/g' \ - -e 's/ifndef CMAKE_BUILD_WITH_CMAKE/ifdef CMAKE_BOOTSTRAP/g' \ - -e 's/ifdef CMAKE_BUILD_WITH_CMAKE/ifndef CMAKE_BOOTSTRAP/g' \ - $(git ls-files Source) https://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=54e9d38c28d0073f2cc5d690adb5c993e7793c97 commit 54e9d38c28d0073f2cc5d690adb5c993e7793c97 Author: Kitware Robot AuthorDate: Fri Aug 9 10:41:44 2019 -0400 Commit: Kyle Edwards CommitDate: Fri Aug 9 10:41:44 2019 -0400 Refactor: Convert all instances of CMAKE_BUILD_WITH_CMAKE to CMAKE_BOOTSTRAP diff --git a/Source/CPack/cpack.cxx b/Source/CPack/cpack.cxx index 89c3b1c..ae56adb 100644 --- a/Source/CPack/cpack.cxx +++ b/Source/CPack/cpack.cxx @@ -11,7 +11,7 @@ #include #include -#if defined(_WIN32) && defined(CMAKE_BUILD_WITH_CMAKE) +#if defined(_WIN32) && !defined(CMAKE_BOOTSTRAP) # include "cmsys/ConsoleBuf.hxx" #endif @@ -100,7 +100,7 @@ void cpackProgressCallback(const std::string& message, float /*unused*/) int main(int argc, char const* const* argv) { cmSystemTools::EnsureStdPipes(); -#if defined(_WIN32) && defined(CMAKE_BUILD_WITH_CMAKE) +#if defined(_WIN32) && !defined(CMAKE_BOOTSTRAP) // Replace streambuf so we can output Unicode to console cmsys::ConsoleBuf::Manager consoleOut(std::cout); consoleOut.SetUTF8Pipes(); diff --git a/Source/CTest/cmCTestRunTest.cxx b/Source/CTest/cmCTestRunTest.cxx index 65cf646..fb91322 100644 --- a/Source/CTest/cmCTestRunTest.cxx +++ b/Source/CTest/cmCTestRunTest.cxx @@ -689,7 +689,7 @@ bool cmCTestRunTest::ForkProcess(cmDuration testTimeOut, bool explicitTimeout, this->TestProcess->SetTimeout(timeout); -#ifdef CMAKE_BUILD_WITH_CMAKE +#ifndef CMAKE_BOOTSTRAP cmSystemTools::SaveRestoreEnvironment sre; #endif diff --git a/Source/CTest/cmCTestScriptHandler.cxx b/Source/CTest/cmCTestScriptHandler.cxx index 4288b25..58f88be 100644 --- a/Source/CTest/cmCTestScriptHandler.cxx +++ b/Source/CTest/cmCTestScriptHandler.cxx @@ -495,7 +495,7 @@ void cmCTestScriptHandler::SleepInSeconds(unsigned int secondsToWait) int cmCTestScriptHandler::RunConfigurationScript( const std::string& total_script_arg, bool pscope) { -#ifdef CMAKE_BUILD_WITH_CMAKE +#ifndef CMAKE_BOOTSTRAP cmSystemTools::SaveRestoreEnvironment sre; #endif diff --git a/Source/cmArchiveWrite.h b/Source/cmArchiveWrite.h index 9ea88d3..e90a603 100644 --- a/Source/cmArchiveWrite.h +++ b/Source/cmArchiveWrite.h @@ -9,7 +9,7 @@ #include #include -#if !defined(CMAKE_BUILD_WITH_CMAKE) +#if defined(CMAKE_BOOTSTRAP) # error "cmArchiveWrite not allowed during bootstrap build!" #endif diff --git a/Source/cmCTest.cxx b/Source/cmCTest.cxx index 026250d..c0ca73b 100644 --- a/Source/cmCTest.cxx +++ b/Source/cmCTest.cxx @@ -2423,7 +2423,7 @@ int cmCTest::RunCMakeAndTest(std::string* output) cmCTestBuildAndTestHandler* handler = this->GetBuildAndTestHandler(); int retv = handler->ProcessHandler(); *output = handler->GetOutput(); -#ifdef CMAKE_BUILD_WITH_CMAKE +#ifndef CMAKE_BOOTSTRAP cmDynamicLoader::FlushCache(); #endif if (retv != 0) { diff --git a/Source/cmCommands.cxx b/Source/cmCommands.cxx index a9be445..8c62c30 100644 --- a/Source/cmCommands.cxx +++ b/Source/cmCommands.cxx @@ -84,7 +84,7 @@ #include "cmUnsetCommand.h" #include "cmWhileCommand.h" -#if defined(CMAKE_BUILD_WITH_CMAKE) +#if !defined(CMAKE_BOOTSTRAP) # include "cmAddCompileOptionsCommand.h" # include "cmAddLinkOptionsCommand.h" # include "cmAuxSourceDirectoryCommand.h" @@ -210,7 +210,7 @@ void GetScriptingCommands(cmState* state) "WHILE ENDWHILE structure. Or its arguments did not " "match the opening WHILE command."); -#if defined(CMAKE_BUILD_WITH_CMAKE) +#if !defined(CMAKE_BOOTSTRAP) state->AddBuiltinCommand( "cmake_host_system_information", cm::make_unique()); @@ -301,7 +301,7 @@ void GetProjectCommands(cmState* state) cm::make_unique()); state->AddBuiltinCommand("try_run", cm::make_unique()); -#if defined(CMAKE_BUILD_WITH_CMAKE) +#if !defined(CMAKE_BOOTSTRAP) state->AddBuiltinCommand("add_compile_definitions", cm::make_unique()); state->AddBuiltinCommand("add_compile_options", diff --git a/Source/cmFileCommand.cxx b/Source/cmFileCommand.cxx index ec03191..fd319f6 100644 --- a/Source/cmFileCommand.cxx +++ b/Source/cmFileCommand.cxx @@ -47,7 +47,7 @@ #include "cm_sys_stat.h" #include "cmake.h" -#if defined(CMAKE_BUILD_WITH_CMAKE) +#if !defined(CMAKE_BOOTSTRAP) # include "cmCurl.h" # include "cmFileLockResult.h" # include "cm_curl.h" @@ -275,7 +275,7 @@ bool HandleReadCommand(std::vector const& args, bool HandleHashCommand(std::vector const& args, cmExecutionStatus& status) { -#if defined(CMAKE_BUILD_WITH_CMAKE) +#if !defined(CMAKE_BOOTSTRAP) if (args.size() != 3) { std::ostringstream e; e << args[0] << " requires a file name and output variable"; @@ -1426,7 +1426,7 @@ bool HandleNativePathCommand(std::vector const& args, return HandlePathCommand(args, ToNativePath, status); } -#if defined(CMAKE_BUILD_WITH_CMAKE) +#if !defined(CMAKE_BOOTSTRAP) // Stuff for curl download/upload typedef std::vector cmFileCommandVectorOfChar; @@ -1592,7 +1592,7 @@ private: bool HandleDownloadCommand(std::vector const& args, cmExecutionStatus& status) { -#if defined(CMAKE_BUILD_WITH_CMAKE) +#if !defined(CMAKE_BOOTSTRAP) std::vector::const_iterator i = args.begin(); if (args.size() < 3) { status.SetError("DOWNLOAD must be called with at least three arguments."); @@ -1961,7 +1961,7 @@ bool HandleDownloadCommand(std::vector const& args, bool HandleUploadCommand(std::vector const& args, cmExecutionStatus& status) { -#if defined(CMAKE_BUILD_WITH_CMAKE) +#if !defined(CMAKE_BOOTSTRAP) if (args.size() < 3) { status.SetError("UPLOAD must be called with at least three arguments."); return false; @@ -2292,7 +2292,7 @@ bool HandleGenerateCommand(std::vector const& args, bool HandleLockCommand(std::vector const& args, cmExecutionStatus& status) { -#if defined(CMAKE_BUILD_WITH_CMAKE) +#if !defined(CMAKE_BOOTSTRAP) // Default values bool directory = false; bool release = false; diff --git a/Source/cmGeneratedFileStream.cxx b/Source/cmGeneratedFileStream.cxx index 2f47788..7475e9f 100644 --- a/Source/cmGeneratedFileStream.cxx +++ b/Source/cmGeneratedFileStream.cxx @@ -6,14 +6,14 @@ #include "cmSystemTools.h" -#if defined(CMAKE_BUILD_WITH_CMAKE) +#if !defined(CMAKE_BOOTSTRAP) # include "cm_codecvt.hxx" # include "cm_zlib.h" #endif cmGeneratedFileStream::cmGeneratedFileStream(Encoding encoding) { -#ifdef CMAKE_BUILD_WITH_CMAKE +#ifndef CMAKE_BOOTSTRAP if (encoding != codecvt::None) { imbue(std::locale(getloc(), new codecvt(encoding))); } @@ -32,7 +32,7 @@ cmGeneratedFileStream::cmGeneratedFileStream(std::string const& name, cmSystemTools::Error("Cannot open file for write: " + this->TempName); cmSystemTools::ReportLastSystemError(""); } -#ifdef CMAKE_BUILD_WITH_CMAKE +#ifndef CMAKE_BOOTSTRAP if (encoding != codecvt::None) { imbue(std::locale(getloc(), new codecvt(encoding))); } @@ -169,7 +169,7 @@ bool cmGeneratedFileStreamBase::Close() return replaced; } -#ifdef CMAKE_BUILD_WITH_CMAKE +#ifndef CMAKE_BOOTSTRAP int cmGeneratedFileStreamBase::CompressFile(std::string const& oldname, std::string const& newname) { diff --git a/Source/cmGeneratorTarget.cxx b/Source/cmGeneratorTarget.cxx index 03fc5ae..c07d7af 100644 --- a/Source/cmGeneratorTarget.cxx +++ b/Source/cmGeneratorTarget.cxx @@ -2526,7 +2526,7 @@ void cmGeneratorTarget::ComputeModuleDefinitionInfo( info.WindowsExportAllSymbols = this->Makefile->IsOn("CMAKE_SUPPORT_WINDOWS_EXPORT_ALL_SYMBOLS") && this->GetPropertyAsBool("WINDOWS_EXPORT_ALL_SYMBOLS"); -#if defined(_WIN32) && defined(CMAKE_BUILD_WITH_CMAKE) +#if defined(_WIN32) && !defined(CMAKE_BOOTSTRAP) info.DefFileGenerated = info.WindowsExportAllSymbols || info.Sources.size() > 1; #else diff --git a/Source/cmGlobalGenerator.cxx b/Source/cmGlobalGenerator.cxx index 88da5eb..5d51414 100644 --- a/Source/cmGlobalGenerator.cxx +++ b/Source/cmGlobalGenerator.cxx @@ -44,7 +44,7 @@ #include "cmWorkingDirectory.h" #include "cmake.h" -#if defined(CMAKE_BUILD_WITH_CMAKE) +#if !defined(CMAKE_BOOTSTRAP) # include "cmCryptoHash.h" # include "cmQtAutoGenGlobalInitializer.h" # include "cm_jsoncpp_value.h" @@ -114,7 +114,7 @@ cmGlobalGenerator::~cmGlobalGenerator() this->ClearGeneratorMembers(); } -#if defined(CMAKE_BUILD_WITH_CMAKE) +#if !defined(CMAKE_BOOTSTRAP) Json::Value cmGlobalGenerator::GetJson() const { Json::Value generator = Json::objectValue; @@ -1547,7 +1547,7 @@ bool cmGlobalGenerator::ComputeTargetDepends() bool cmGlobalGenerator::QtAutoGen() { -#ifdef CMAKE_BUILD_WITH_CMAKE +#ifndef CMAKE_BOOTSTRAP cmQtAutoGenGlobalInitializer initializer(this->LocalGenerators); return initializer.generate(); #else @@ -2829,7 +2829,7 @@ std::set const& cmGlobalGenerator::GetDirectoryContent( void cmGlobalGenerator::AddRuleHash(const std::vector& outputs, std::string const& content) { -#if defined(CMAKE_BUILD_WITH_CMAKE) +#if !defined(CMAKE_BOOTSTRAP) // Ignore if there are no outputs. if (outputs.empty()) { return; @@ -2859,7 +2859,7 @@ void cmGlobalGenerator::AddRuleHash(const std::vector& outputs, void cmGlobalGenerator::CheckRuleHashes() { -#if defined(CMAKE_BUILD_WITH_CMAKE) +#if !defined(CMAKE_BOOTSTRAP) std::string home = this->GetCMakeInstance()->GetHomeOutputDirectory(); std::string pfile = home; pfile += "/CMakeFiles"; @@ -2963,7 +2963,7 @@ void cmGlobalGenerator::WriteSummary(cmGeneratorTarget* target) file += "/Labels.txt"; std::string json_file = dir + "/Labels.json"; -#ifdef CMAKE_BUILD_WITH_CMAKE +#ifndef CMAKE_BOOTSTRAP // Check whether labels are enabled for this target. const char* targetLabels = target->GetProperty("LABELS"); const char* directoryLabels = diff --git a/Source/cmGlobalGenerator.h b/Source/cmGlobalGenerator.h index ea40ebc..830974d 100644 --- a/Source/cmGlobalGenerator.h +++ b/Source/cmGlobalGenerator.h @@ -25,7 +25,7 @@ #include "cmTargetDepend.h" #include "cm_codecvt.hxx" -#if defined(CMAKE_BUILD_WITH_CMAKE) +#if !defined(CMAKE_BOOTSTRAP) # include "cmFileLockPool.h" # include "cm_jsoncpp_value.h" #endif @@ -109,7 +109,7 @@ public: return codecvt::None; } -#if defined(CMAKE_BUILD_WITH_CMAKE) +#if !defined(CMAKE_BOOTSTRAP) /** Get a JSON object describing the generator. */ virtual Json::Value GetJson() const; #endif @@ -462,7 +462,7 @@ public: const std::set& GetFilenameTargetDepends( cmSourceFile* sf) const; -#if defined(CMAKE_BUILD_WITH_CMAKE) +#if !defined(CMAKE_BOOTSTRAP) cmFileLockPool& GetFileLockPool() { return FileLockPool; } #endif @@ -665,7 +665,7 @@ private: mutable std::map> FilenameTargetDepends; -#if defined(CMAKE_BUILD_WITH_CMAKE) +#if !defined(CMAKE_BOOTSTRAP) // Pool of file locks cmFileLockPool FileLockPool; #endif diff --git a/Source/cmGlobalVisualStudio7Generator.cxx b/Source/cmGlobalVisualStudio7Generator.cxx index ca80d3b..cd1ff61 100644 --- a/Source/cmGlobalVisualStudio7Generator.cxx +++ b/Source/cmGlobalVisualStudio7Generator.cxx @@ -256,7 +256,7 @@ cmLocalGenerator* cmGlobalVisualStudio7Generator::CreateLocalGenerator( return lg; } -#if defined(CMAKE_BUILD_WITH_CMAKE) +#if !defined(CMAKE_BOOTSTRAP) Json::Value cmGlobalVisualStudio7Generator::GetJson() const { Json::Value generator = this->cmGlobalVisualStudioGenerator::GetJson(); diff --git a/Source/cmGlobalVisualStudio7Generator.h b/Source/cmGlobalVisualStudio7Generator.h index f004afb..9b84732 100644 --- a/Source/cmGlobalVisualStudio7Generator.h +++ b/Source/cmGlobalVisualStudio7Generator.h @@ -23,7 +23,7 @@ public: //! Create a local generator appropriate to this Global Generator cmLocalGenerator* CreateLocalGenerator(cmMakefile* mf) override; -#if defined(CMAKE_BUILD_WITH_CMAKE) +#if !defined(CMAKE_BOOTSTRAP) Json::Value GetJson() const override; #endif diff --git a/Source/cmGlobalXCodeGenerator.cxx b/Source/cmGlobalXCodeGenerator.cxx index 029b976..e3cafe3 100644 --- a/Source/cmGlobalXCodeGenerator.cxx +++ b/Source/cmGlobalXCodeGenerator.cxx @@ -38,12 +38,12 @@ struct cmLinkImplementation; -#if defined(CMAKE_BUILD_WITH_CMAKE) && defined(__APPLE__) +#if !defined(CMAKE_BOOTSTRAP) && defined(__APPLE__) # define HAVE_APPLICATION_SERVICES # include #endif -#if defined(CMAKE_BUILD_WITH_CMAKE) +#if !defined(CMAKE_BOOTSTRAP) # include "cmXMLParser.h" // parse the xml file storing the installed version of Xcode on @@ -188,7 +188,7 @@ cmGlobalGenerator* cmGlobalXCodeGenerator::Factory::CreateGlobalGenerator( if (name != GetActualName()) { return nullptr; } -#if defined(CMAKE_BUILD_WITH_CMAKE) +#if !defined(CMAKE_BOOTSTRAP) cmXcodeVersionParser parser; std::string versionFile; { diff --git a/Source/cmIncludeGuardCommand.cxx b/Source/cmIncludeGuardCommand.cxx index 3b126b0..e560910 100644 --- a/Source/cmIncludeGuardCommand.cxx +++ b/Source/cmIncludeGuardCommand.cxx @@ -21,7 +21,7 @@ enum IncludeGuardScope std::string GetIncludeGuardVariableName(std::string const& filePath) { std::string result = "__INCGUARD_"; -#ifdef CMAKE_BUILD_WITH_CMAKE +#ifndef CMAKE_BOOTSTRAP result += cmSystemTools::ComputeStringMD5(filePath); #else result += cmSystemTools::MakeCidentifier(filePath); diff --git a/Source/cmInstallCommand.cxx b/Source/cmInstallCommand.cxx index 5349a9d..76dafd9 100644 --- a/Source/cmInstallCommand.cxx +++ b/Source/cmInstallCommand.cxx @@ -1268,7 +1268,7 @@ bool cmInstallCommand::HandleDirectoryMode( bool cmInstallCommand::HandleExportAndroidMKMode( std::vector const& args) { -#ifdef CMAKE_BUILD_WITH_CMAKE +#ifndef CMAKE_BOOTSTRAP // This is the EXPORT mode. cmInstallCommandArguments ica(this->DefaultComponentName); diff --git a/Source/cmInstallExportGenerator.cxx b/Source/cmInstallExportGenerator.cxx index f5bedab..af06b9d 100644 --- a/Source/cmInstallExportGenerator.cxx +++ b/Source/cmInstallExportGenerator.cxx @@ -7,7 +7,7 @@ #include #include -#ifdef CMAKE_BUILD_WITH_CMAKE +#ifndef CMAKE_BOOTSTRAP # include "cmExportInstallAndroidMKGenerator.h" #endif #include "cmExportInstallFileGenerator.h" @@ -31,7 +31,7 @@ cmInstallExportGenerator::cmInstallExportGenerator( , LocalGenerator(nullptr) { if (android) { -#ifdef CMAKE_BUILD_WITH_CMAKE +#ifndef CMAKE_BOOTSTRAP this->EFGen = new cmExportInstallAndroidMKGenerator(this); #endif } else { diff --git a/Source/cmLocalGenerator.cxx b/Source/cmLocalGenerator.cxx index 3deaeb0..3db7cf6 100644 --- a/Source/cmLocalGenerator.cxx +++ b/Source/cmLocalGenerator.cxx @@ -29,7 +29,7 @@ #include "cmake.h" #include "cmsys/RegularExpression.hxx" -#if defined(CMAKE_BUILD_WITH_CMAKE) +#if !defined(CMAKE_BOOTSTRAP) # define CM_LG_ENCODE_OBJECT_NAMES # include "cmCryptoHash.h" #endif diff --git a/Source/cmLocalGenerator.h b/Source/cmLocalGenerator.h index f0c6806..455e491 100644 --- a/Source/cmLocalGenerator.h +++ b/Source/cmLocalGenerator.h @@ -461,7 +461,7 @@ private: void ComputeObjectMaxPath(); }; -#if defined(CMAKE_BUILD_WITH_CMAKE) +#if !defined(CMAKE_BOOTSTRAP) bool cmLocalGeneratorCheckObjectName(std::string& objName, std::string::size_type dir_len, std::string::size_type max_total_len); diff --git a/Source/cmLocalUnixMakefileGenerator3.cxx b/Source/cmLocalUnixMakefileGenerator3.cxx index c6b63ba..cfad31a 100644 --- a/Source/cmLocalUnixMakefileGenerator3.cxx +++ b/Source/cmLocalUnixMakefileGenerator3.cxx @@ -40,7 +40,7 @@ // Include dependency scanners for supported languages. Only the // C/C++ scanner is needed for bootstrapping CMake. #include "cmDependsC.h" -#ifdef CMAKE_BUILD_WITH_CMAKE +#ifndef CMAKE_BOOTSTRAP # include "cmDependsFortran.h" # include "cmDependsJava.h" #endif @@ -1477,7 +1477,7 @@ bool cmLocalUnixMakefileGenerator3::ScanDependencies( // TODO: Handle RC (resource files) dependencies correctly. scanner = cm::make_unique(this, targetDir, lang, &validDeps); } -#ifdef CMAKE_BUILD_WITH_CMAKE +#ifndef CMAKE_BOOTSTRAP else if (lang == "Fortran") { ruleFileStream << "# Note that incremental build could trigger " << "a call to cmake_copy_f90_mod on each re-build\n"; diff --git a/Source/cmMakefile.cxx b/Source/cmMakefile.cxx index 86a002f..f6f4737 100644 --- a/Source/cmMakefile.cxx +++ b/Source/cmMakefile.cxx @@ -47,7 +47,7 @@ #include "cmConfigure.h" // IWYU pragma: keep -#ifdef CMAKE_BUILD_WITH_CMAKE +#ifndef CMAKE_BOOTSTRAP # include "cmVariableWatch.h" #endif @@ -97,7 +97,7 @@ cmMakefile::cmMakefile(cmGlobalGenerator* globalGenerator, // cmListFileCache in the top level if necessary. this->CheckCMP0000 = false; -#if defined(CMAKE_BUILD_WITH_CMAKE) +#if !defined(CMAKE_BOOTSTRAP) this->AddSourceGroup("", "^.*$"); this->AddSourceGroup("Source Files", CM_SOURCE_REGEX); this->AddSourceGroup("Header Files", CM_HEADER_REGEX); @@ -1425,7 +1425,7 @@ void cmMakefile::PushFunctionScope(std::string const& fileName, this->PushLoopBlockBarrier(); -#if defined(CMAKE_BUILD_WITH_CMAKE) +#if !defined(CMAKE_BOOTSTRAP) this->GetGlobalGenerator()->GetFileLockPool().PushFunctionScope(); #endif @@ -1442,7 +1442,7 @@ void cmMakefile::PopFunctionScope(bool reportError) this->PopFunctionBlockerBarrier(reportError); -#if defined(CMAKE_BUILD_WITH_CMAKE) +#if !defined(CMAKE_BOOTSTRAP) this->GetGlobalGenerator()->GetFileLockPool().PopFunctionScope(); #endif @@ -1497,7 +1497,7 @@ public: this->Snapshot = this->GG->GetCMakeInstance()->GetCurrentSnapshot(); this->GG->GetCMakeInstance()->SetCurrentSnapshot(this->Snapshot); this->GG->SetCurrentMakefile(mf); -#if defined(CMAKE_BUILD_WITH_CMAKE) +#if !defined(CMAKE_BOOTSTRAP) this->GG->GetFileLockPool().PushFileScope(); #endif } @@ -1506,7 +1506,7 @@ public: { this->Makefile->PopFunctionBlockerBarrier(this->ReportError); this->Makefile->PopSnapshot(this->ReportError); -#if defined(CMAKE_BUILD_WITH_CMAKE) +#if !defined(CMAKE_BOOTSTRAP) this->GG->GetFileLockPool().PopFileScope(); #endif this->GG->SetCurrentMakefile(this->CurrentMakefile); @@ -1800,7 +1800,7 @@ void cmMakefile::AddDefinition(const std::string& name, cm::string_view value) } this->StateSnapshot.SetDefinition(name, value); -#ifdef CMAKE_BUILD_WITH_CMAKE +#ifndef CMAKE_BOOTSTRAP cmVariableWatch* vv = this->GetVariableWatch(); if (vv) { vv->VariableAccessed(name, cmVariableWatch::VARIABLE_MODIFIED_ACCESS, @@ -1921,7 +1921,7 @@ void cmMakefile::RemoveDefinition(const std::string& name) this->LogUnused("unsetting", name); } this->StateSnapshot.RemoveDefinition(name); -#ifdef CMAKE_BUILD_WITH_CMAKE +#ifndef CMAKE_BOOTSTRAP cmVariableWatch* vv = this->GetVariableWatch(); if (vv) { vv->VariableAccessed(name, cmVariableWatch::VARIABLE_REMOVED_ACCESS, @@ -2079,7 +2079,7 @@ cmSourceFile* cmMakefile::GetSourceFileWithOutput( return nullptr; } -#if defined(CMAKE_BUILD_WITH_CMAKE) +#if !defined(CMAKE_BOOTSTRAP) cmSourceGroup* cmMakefile::GetSourceGroup( const std::vector& name) const { @@ -2460,7 +2460,7 @@ bool cmMakefile::IsDefinitionSet(const std::string& name) const if (!def) { def = this->GetState()->GetInitializedCacheValue(name); } -#ifdef CMAKE_BUILD_WITH_CMAKE +#ifndef CMAKE_BOOTSTRAP if (cmVariableWatch* vv = this->GetVariableWatch()) { if (!def) { vv->VariableAccessed( @@ -2477,7 +2477,7 @@ const std::string* cmMakefile::GetDef(const std::string& name) const if (!def) { def = this->GetState()->GetInitializedCacheValue(name); } -#ifdef CMAKE_BUILD_WITH_CMAKE +#ifndef CMAKE_BOOTSTRAP cmVariableWatch* vv = this->GetVariableWatch(); if (vv && !this->SuppressSideEffects) { bool const watch_function_executed = @@ -3327,7 +3327,7 @@ void cmMakefile::AddTargetObject(std::string const& tgtName, cmSourceFile* sf = this->GetOrCreateSource(objFile, true); sf->SetObjectLibrary(tgtName); sf->SetProperty("EXTERNAL_OBJECT", "1"); -#if defined(CMAKE_BUILD_WITH_CMAKE) +#if !defined(CMAKE_BOOTSTRAP) this->SourceGroups[this->ObjectLibrariesSourceGroupIndex].AddGroupFile( sf->GetFullPath()); #endif @@ -3509,7 +3509,7 @@ cmGlobalGenerator* cmMakefile::GetGlobalGenerator() const return this->GlobalGenerator; } -#ifdef CMAKE_BUILD_WITH_CMAKE +#ifndef CMAKE_BOOTSTRAP cmVariableWatch* cmMakefile::GetVariableWatch() const { if (this->GetCMakeInstance() && @@ -3931,14 +3931,14 @@ void cmMakefile::PushScope() this->GetState()->CreateVariableScopeSnapshot(this->StateSnapshot); this->PushLoopBlockBarrier(); -#if defined(CMAKE_BUILD_WITH_CMAKE) +#if !defined(CMAKE_BOOTSTRAP) this->GetGlobalGenerator()->GetFileLockPool().PushFunctionScope(); #endif } void cmMakefile::PopScope() { -#if defined(CMAKE_BUILD_WITH_CMAKE) +#if !defined(CMAKE_BOOTSTRAP) this->GetGlobalGenerator()->GetFileLockPool().PopFunctionScope(); #endif @@ -3962,7 +3962,7 @@ void cmMakefile::RaiseScope(const std::string& var, const char* varDef) return; } -#ifdef CMAKE_BUILD_WITH_CMAKE +#ifndef CMAKE_BOOTSTRAP cmVariableWatch* vv = this->GetVariableWatch(); if (vv) { vv->VariableAccessed(var, cmVariableWatch::VARIABLE_MODIFIED_ACCESS, diff --git a/Source/cmMakefile.h b/Source/cmMakefile.h index 4d61c05..a6d1757 100644 --- a/Source/cmMakefile.h +++ b/Source/cmMakefile.h @@ -30,7 +30,7 @@ #include "cmStringAlgorithms.h" #include "cmTarget.h" -#if defined(CMAKE_BUILD_WITH_CMAKE) +#if !defined(CMAKE_BOOTSTRAP) # include "cmSourceGroup.h" #endif @@ -503,7 +503,7 @@ public: */ bool CanIWriteThisFile(std::string const& fileName) const; -#if defined(CMAKE_BUILD_WITH_CMAKE) +#if !defined(CMAKE_BOOTSTRAP) /** * Get the vector source groups. */ @@ -649,7 +649,7 @@ public: * Get the variable watch. This is used to determine when certain variables * are accessed. */ -#ifdef CMAKE_BUILD_WITH_CMAKE +#ifndef CMAKE_BOOTSTRAP cmVariableWatch* GetVariableWatch() const; #endif @@ -945,7 +945,7 @@ protected: // Track the value of the computed DEFINITIONS property. std::string DefineFlagsOrig; -#if defined(CMAKE_BUILD_WITH_CMAKE) +#if !defined(CMAKE_BOOTSTRAP) std::vector SourceGroups; size_t ObjectLibrariesSourceGroupIndex; #endif diff --git a/Source/cmMakefileExecutableTargetGenerator.cxx b/Source/cmMakefileExecutableTargetGenerator.cxx index 19c667e..31ee4fa 100644 --- a/Source/cmMakefileExecutableTargetGenerator.cxx +++ b/Source/cmMakefileExecutableTargetGenerator.cxx @@ -83,7 +83,7 @@ void cmMakefileExecutableTargetGenerator::WriteRuleFiles() void cmMakefileExecutableTargetGenerator::WriteDeviceExecutableRule( bool relink) { -#ifdef CMAKE_BUILD_WITH_CMAKE +#ifndef CMAKE_BOOTSTRAP const bool requiresDeviceLinking = requireDeviceLinking( *this->GeneratorTarget, *this->LocalGenerator, this->ConfigName); if (!requiresDeviceLinking) { diff --git a/Source/cmMakefileLibraryTargetGenerator.cxx b/Source/cmMakefileLibraryTargetGenerator.cxx index 8d342f3..4621da4 100644 --- a/Source/cmMakefileLibraryTargetGenerator.cxx +++ b/Source/cmMakefileLibraryTargetGenerator.cxx @@ -236,7 +236,7 @@ void cmMakefileLibraryTargetGenerator::WriteFrameworkRules(bool relink) void cmMakefileLibraryTargetGenerator::WriteDeviceLibraryRules( const std::string& linkRuleVar, bool relink) { -#ifdef CMAKE_BUILD_WITH_CMAKE +#ifndef CMAKE_BOOTSTRAP // TODO: Merge the methods that call this method to avoid // code duplication. std::vector commands; diff --git a/Source/cmMessenger.cxx b/Source/cmMessenger.cxx index 07d011e..af83478 100644 --- a/Source/cmMessenger.cxx +++ b/Source/cmMessenger.cxx @@ -6,7 +6,7 @@ #include "cmStringAlgorithms.h" #include "cmSystemTools.h" -#if defined(CMAKE_BUILD_WITH_CMAKE) +#if !defined(CMAKE_BOOTSTRAP) # include "cmsys/SystemInformation.hxx" #endif @@ -106,7 +106,7 @@ void displayMessage(MessageType t, std::ostringstream& msg) // Add a terminating blank line. msg << "\n"; -#if defined(CMAKE_BUILD_WITH_CMAKE) +#if !defined(CMAKE_BOOTSTRAP) // Add a C++ stack trace to internal errors. if (t == MessageType::INTERNAL_ERROR) { std::string stack = cmsys::SystemInformation::GetProgramStack(0, 0); diff --git a/Source/cmRuntimeDependencyArchive.cxx b/Source/cmRuntimeDependencyArchive.cxx index ca85287..37a87e5 100644 --- a/Source/cmRuntimeDependencyArchive.cxx +++ b/Source/cmRuntimeDependencyArchive.cxx @@ -13,7 +13,7 @@ #if defined(_WIN32) # include "cmGlobalGenerator.h" -# ifdef CMAKE_BUILD_WITH_CMAKE +# ifndef CMAKE_BOOTSTRAP # include "cmGlobalVisualStudioVersionedGenerator.h" # endif # include "cmVSSetupHelper.h" @@ -36,7 +36,7 @@ static void AddVisualStudioPath(std::vector& paths, // If generating for the VS IDE, use the same instance. std::string vsloc; bool found = false; -# ifdef CMAKE_BUILD_WITH_CMAKE +# ifndef CMAKE_BOOTSTRAP if (gg->GetName().find(prefix) == 0) { cmGlobalVisualStudioVersionedGenerator* vsgen = static_cast(gg); diff --git a/Source/cmStringCommand.cxx b/Source/cmStringCommand.cxx index 8b3b1e3..46d9459 100644 --- a/Source/cmStringCommand.cxx +++ b/Source/cmStringCommand.cxx @@ -113,7 +113,7 @@ bool cmStringCommand::InitialPass(std::vector const& args, bool cmStringCommand::HandleHashCommand(std::vector const& args) { -#if defined(CMAKE_BUILD_WITH_CMAKE) +#if !defined(CMAKE_BOOTSTRAP) if (args.size() != 3) { std::ostringstream e; e << args[0] << " requires an output variable and an input string"; @@ -878,7 +878,7 @@ bool cmStringCommand::HandleTimestampCommand( bool cmStringCommand::HandleUuidCommand(std::vector const& args) { -#if defined(CMAKE_BUILD_WITH_CMAKE) +#if !defined(CMAKE_BOOTSTRAP) unsigned int argsIndex = 1; if (args.size() < 2) { diff --git a/Source/cmSystemTools.cxx b/Source/cmSystemTools.cxx index 7baf5ed..785e221 100644 --- a/Source/cmSystemTools.cxx +++ b/Source/cmSystemTools.cxx @@ -9,7 +9,7 @@ #include "cmStringAlgorithms.h" #include "cm_uv.h" -#if defined(CMAKE_BUILD_WITH_CMAKE) +#if !defined(CMAKE_BOOTSTRAP) # include "cmArchiveWrite.h" # include "cmLocale.h" # include "cm_libarchive.h" @@ -21,7 +21,7 @@ # endif #endif -#if defined(CMAKE_BUILD_WITH_CMAKE) +#if !defined(CMAKE_BOOTSTRAP) # include "cmCryptoHash.h" #endif @@ -93,7 +93,7 @@ extern char** environ; # endif #endif -#if defined(CMAKE_BUILD_WITH_CMAKE) +#if !defined(CMAKE_BOOTSTRAP) static std::string cm_archive_entry_pathname(struct archive_entry* entry) { # if cmsys_STL_HAS_WSTRING @@ -944,7 +944,7 @@ bool cmSystemTools::RenameFile(const std::string& oldname, std::string cmSystemTools::ComputeFileHash(const std::string& source, cmCryptoHash::Algo algo) { -#if defined(CMAKE_BUILD_WITH_CMAKE) +#if !defined(CMAKE_BOOTSTRAP) cmCryptoHash hash(algo); return hash.HashFile(source); #else @@ -957,7 +957,7 @@ std::string cmSystemTools::ComputeFileHash(const std::string& source, std::string cmSystemTools::ComputeStringMD5(const std::string& input) { -#if defined(CMAKE_BUILD_WITH_CMAKE) +#if !defined(CMAKE_BOOTSTRAP) cmCryptoHash md5(cmCryptoHash::AlgoMD5); return md5.HashString(input); #else @@ -973,7 +973,7 @@ std::string cmSystemTools::ComputeCertificateThumbprint( { std::string thumbprint; -#if defined(CMAKE_BUILD_WITH_CMAKE) && defined(_WIN32) +#if !defined(CMAKE_BOOTSTRAP) && defined(_WIN32) BYTE* certData = NULL; CRYPT_INTEGER_BLOB cryptBlob; HCERTSTORE certStore = NULL; @@ -1331,7 +1331,7 @@ std::string cmSystemTools::ForceToRelativePath(std::string const& local_path, return relative; } -#ifdef CMAKE_BUILD_WITH_CMAKE +#ifndef CMAKE_BOOTSTRAP bool cmSystemTools::UnsetEnv(const char* value) { # if !defined(HAVE_UNSETENV) @@ -1396,7 +1396,7 @@ void cmSystemTools::EnableVSConsoleOutput() // output and allow it to be captured on the fly. cmSystemTools::PutEnv("vsconsoleoutput=1"); -# ifdef CMAKE_BUILD_WITH_CMAKE +# ifndef CMAKE_BOOTSTRAP // VS sets an environment variable to tell MS tools like "cl" to report // output through a backdoor pipe instead of stdout/stderr. Unset the // environment variable to close this backdoor for any path of process @@ -1418,7 +1418,7 @@ bool cmSystemTools::CreateTar(const std::string& outFileName, std::string const& mtime, std::string const& format) { -#if defined(CMAKE_BUILD_WITH_CMAKE) +#if !defined(CMAKE_BOOTSTRAP) std::string cwd = cmSystemTools::GetCurrentWorkingDirectory(); cmsys::ofstream fout(outFileName.c_str(), std::ios::out | std::ios::binary); if (!fout) { @@ -1472,7 +1472,7 @@ bool cmSystemTools::CreateTar(const std::string& outFileName, #endif } -#if defined(CMAKE_BUILD_WITH_CMAKE) +#if !defined(CMAKE_BOOTSTRAP) namespace { # define BSDTAR_FILESIZE_PRINTF "%lu" # define BSDTAR_FILESIZE_TYPE unsigned long @@ -1768,7 +1768,7 @@ bool cmSystemTools::ExtractTar(const std::string& outFileName, const std::vector& files, bool verbose) { -#if defined(CMAKE_BUILD_WITH_CMAKE) +#if !defined(CMAKE_BOOTSTRAP) return extract_tar(outFileName, files, verbose, true); #else (void)outFileName; @@ -1782,7 +1782,7 @@ bool cmSystemTools::ListTar(const std::string& outFileName, const std::vector& files, bool verbose) { -#if defined(CMAKE_BUILD_WITH_CMAKE) +#if !defined(CMAKE_BOOTSTRAP) return extract_tar(outFileName, files, verbose, false); #else (void)outFileName; @@ -2111,7 +2111,7 @@ void cmSystemTools::FindCMakeResources(const char* argv0) cmSystemToolsCMakeCommand = exe_dir; cmSystemToolsCMakeCommand += "/cmake"; cmSystemToolsCMakeCommand += cmSystemTools::GetExecutableExtension(); -#ifndef CMAKE_BUILD_WITH_CMAKE +#ifdef CMAKE_BOOTSTRAP // The bootstrap cmake does not provide the other tools, // so use the directory where they are about to be built. exe_dir = CMAKE_BOOTSTRAP_BINARY_DIR "/bin"; @@ -2141,7 +2141,7 @@ void cmSystemTools::FindCMakeResources(const char* argv0) cmSystemToolsCMClDepsCommand.clear(); } -#ifdef CMAKE_BUILD_WITH_CMAKE +#ifndef CMAKE_BOOTSTRAP // Install tree has // - "/cmake" // - "" diff --git a/Source/cmSystemTools.h b/Source/cmSystemTools.h index d3fcb64..4f76b00 100644 --- a/Source/cmSystemTools.h +++ b/Source/cmSystemTools.h @@ -387,7 +387,7 @@ public: static std::string ForceToRelativePath(std::string const& local_path, std::string const& remote_path); -#ifdef CMAKE_BUILD_WITH_CMAKE +#ifndef CMAKE_BOOTSTRAP /** Remove an environment variable */ static bool UnsetEnv(const char* value); diff --git a/Source/cmTimestamp.cxx b/Source/cmTimestamp.cxx index da5d21e..0915986 100644 --- a/Source/cmTimestamp.cxx +++ b/Source/cmTimestamp.cxx @@ -109,7 +109,7 @@ time_t cmTimestamp::CreateUtcTimeTFromTm(struct tm& tm) const time_t result = mktime(&tm); -# ifdef CMAKE_BUILD_WITH_CMAKE +# ifndef CMAKE_BOOTSTRAP if (tz_was_set) { cmSystemTools::PutEnv(tz_old); } else { diff --git a/Source/cmUVHandlePtr.cxx b/Source/cmUVHandlePtr.cxx index db67463..97c27cb 100644 --- a/Source/cmUVHandlePtr.cxx +++ b/Source/cmUVHandlePtr.cxx @@ -122,7 +122,7 @@ uv_handle_ptr_::operator T*() const return this->handle.get(); } -#ifdef CMAKE_BUILD_WITH_CMAKE +#ifndef CMAKE_BOOTSTRAP template <> struct uv_handle_deleter { @@ -230,7 +230,7 @@ int uv_timer_ptr::start(uv_timer_cb cb, uint64_t timeout, uint64_t repeat) return uv_timer_start(*this, cb, timeout, repeat); } -#ifdef CMAKE_BUILD_WITH_CMAKE +#ifndef CMAKE_BOOTSTRAP uv_tty_ptr::operator uv_stream_t*() const { return reinterpret_cast(handle.get()); @@ -259,7 +259,7 @@ UV_HANDLE_PTR_INSTANTIATE_EXPLICIT(process) UV_HANDLE_PTR_INSTANTIATE_EXPLICIT(timer) -#ifdef CMAKE_BUILD_WITH_CMAKE +#ifndef CMAKE_BOOTSTRAP UV_HANDLE_PTR_INSTANTIATE_EXPLICIT(async) UV_HANDLE_PTR_INSTANTIATE_EXPLICIT(tty) diff --git a/Source/cmUnsetCommand.cxx b/Source/cmUnsetCommand.cxx index 0e903c7..3eb293a 100644 --- a/Source/cmUnsetCommand.cxx +++ b/Source/cmUnsetCommand.cxx @@ -24,7 +24,7 @@ bool cmUnsetCommand::InitialPass(std::vector const& args, // what is the variable name auto const& envVarName = variable.substr(4, variable.size() - 5); -#ifdef CMAKE_BUILD_WITH_CMAKE +#ifndef CMAKE_BOOTSTRAP cmSystemTools::UnsetEnv(envVarName.c_str()); #endif return true; diff --git a/Source/cm_codecvt.hxx b/Source/cm_codecvt.hxx index 2df3961..2060584 100644 --- a/Source/cm_codecvt.hxx +++ b/Source/cm_codecvt.hxx @@ -18,7 +18,7 @@ public: ANSI }; -#ifdef CMAKE_BUILD_WITH_CMAKE +#ifndef CMAKE_BOOTSTRAP codecvt(Encoding e); diff --git a/Source/cmake.cxx b/Source/cmake.cxx index 3cc6776..a126d62 100644 --- a/Source/cmake.cxx +++ b/Source/cmake.cxx @@ -31,7 +31,7 @@ #include "cm_string_view.hxx" #include "cm_sys_stat.h" -#if defined(CMAKE_BUILD_WITH_CMAKE) +#if !defined(CMAKE_BOOTSTRAP) # include "cm_jsoncpp_writer.h" # include "cmFileAPI.h" @@ -40,11 +40,11 @@ # include #endif -#if defined(CMAKE_BUILD_WITH_CMAKE) +#if !defined(CMAKE_BOOTSTRAP) # define CMAKE_USE_ECLIPSE #endif -#if defined(__MINGW32__) && !defined(CMAKE_BUILD_WITH_CMAKE) +#if defined(__MINGW32__) && defined(CMAKE_BOOTSTRAP) # define CMAKE_BOOT_MINGW #endif @@ -72,7 +72,7 @@ # include "cmGlobalWatcomWMakeGenerator.h" #endif #include "cmGlobalUnixMakefileGenerator3.h" -#if defined(CMAKE_BUILD_WITH_CMAKE) +#if !defined(CMAKE_BOOTSTRAP) # include "cmGlobalNinjaGenerator.h" #endif #include "cmExtraCodeLiteGenerator.h" @@ -92,7 +92,7 @@ #endif #if defined(__APPLE__) -# if defined(CMAKE_BUILD_WITH_CMAKE) +# if !defined(CMAKE_BOOTSTRAP) # include "cmGlobalXCodeGenerator.h" # define CMAKE_USE_XCODE 1 @@ -115,7 +115,7 @@ namespace { -#if defined(CMAKE_BUILD_WITH_CMAKE) +#if !defined(CMAKE_BOOTSTRAP) typedef std::unordered_map JsonValueMapType; #endif @@ -134,7 +134,7 @@ static void cmWarnUnusedCliWarning(const std::string& variable, int /*unused*/, cmake::cmake(Role role, cmState::Mode mode) : FileTimeCache(cm::make_unique()) -#ifdef CMAKE_BUILD_WITH_CMAKE +#ifndef CMAKE_BOOTSTRAP , VariableWatch(cm::make_unique()) #endif , State(cm::make_unique()) @@ -203,7 +203,7 @@ cmake::~cmake() cmDeleteAll(this->Generators); } -#if defined(CMAKE_BUILD_WITH_CMAKE) +#if !defined(CMAKE_BOOTSTRAP) Json::Value cmake::ReportVersionJson() const { Json::Value version = Json::objectValue; @@ -262,7 +262,7 @@ Json::Value cmake::ReportCapabilitiesJson() const std::string cmake::ReportCapabilities() const { std::string result; -#if defined(CMAKE_BUILD_WITH_CMAKE) +#if !defined(CMAKE_BOOTSTRAP) Json::FastWriter writer; result = writer.write(this->ReportCapabilitiesJson()); #else @@ -968,7 +968,7 @@ int cmake::AddCMakePaths() this->AddCacheEntry("CMAKE_COMMAND", cmSystemTools::GetCMakeCommand().c_str(), "Path to CMake executable.", cmStateEnums::INTERNAL); -#ifdef CMAKE_BUILD_WITH_CMAKE +#ifndef CMAKE_BOOTSTRAP this->AddCacheEntry( "CMAKE_CTEST_COMMAND", cmSystemTools::GetCTestCommand().c_str(), "Path to ctest program executable.", cmStateEnums::INTERNAL); @@ -994,7 +994,7 @@ int cmake::AddCMakePaths() void cmake::AddDefaultExtraGenerators() { -#if defined(CMAKE_BUILD_WITH_CMAKE) +#if !defined(CMAKE_BOOTSTRAP) this->ExtraGenerators.push_back(cmExtraCodeBlocksGenerator::GetFactory()); this->ExtraGenerators.push_back(cmExtraCodeLiteGenerator::GetFactory()); this->ExtraGenerators.push_back(cmExtraSublimeTextGenerator::GetFactory()); @@ -1521,7 +1521,7 @@ int cmake::ActualConfigure() this->TruncateOutputLog("CMakeError.log"); } -#if defined(CMAKE_BUILD_WITH_CMAKE) +#if !defined(CMAKE_BOOTSTRAP) this->FileAPI = cm::make_unique(this); this->FileAPI->ReadQueries(); #endif @@ -1789,7 +1789,7 @@ int cmake::Generate() // for the Visual Studio and Xcode generators.) this->SaveCache(this->GetHomeOutputDirectory()); -#if defined(CMAKE_BUILD_WITH_CMAKE) +#if !defined(CMAKE_BOOTSTRAP) this->FileAPI->WriteReplies(); #endif @@ -1895,7 +1895,7 @@ void cmake::AddDefaultGenerators() this->Generators.push_back(cmGlobalMinGWMakefileGenerator::NewFactory()); #endif this->Generators.push_back(cmGlobalUnixMakefileGenerator3::NewFactory()); -#if defined(CMAKE_BUILD_WITH_CMAKE) +#if !defined(CMAKE_BOOTSTRAP) # if defined(__linux__) || defined(_WIN32) this->Generators.push_back(cmGlobalGhsMultiGenerator::NewFactory()); # endif @@ -2054,7 +2054,7 @@ std::vector cmake::GetGeneratorsDocumentation() void cmake::PrintGeneratorList() { -#ifdef CMAKE_BUILD_WITH_CMAKE +#ifndef CMAKE_BOOTSTRAP cmDocumentation doc; auto generators = this->GetGeneratorsDocumentation(); doc.AppendSection("Generators", generators); @@ -2285,7 +2285,7 @@ void cmake::MarkCliAsUsed(const std::string& variable) void cmake::GenerateGraphViz(const std::string& fileName) const { -#ifdef CMAKE_BUILD_WITH_CMAKE +#ifndef CMAKE_BOOTSTRAP cmGraphVizWriter gvWriter(this->GetGlobalGenerator()); std::string settingsFile = this->GetHomeOutputDirectory(); @@ -2744,7 +2744,7 @@ bool cmake::Open(const std::string& dir, bool dryRun) void cmake::WatchUnusedCli(const std::string& var) { -#ifdef CMAKE_BUILD_WITH_CMAKE +#ifndef CMAKE_BOOTSTRAP this->VariableWatch->AddWatch(var, cmWarnUnusedCliWarning, this); if (this->UsedCliVariables.find(var) == this->UsedCliVariables.end()) { this->UsedCliVariables[var] = false; @@ -2754,7 +2754,7 @@ void cmake::WatchUnusedCli(const std::string& var) void cmake::UnwatchUnusedCli(const std::string& var) { -#ifdef CMAKE_BUILD_WITH_CMAKE +#ifndef CMAKE_BOOTSTRAP this->VariableWatch->RemoveWatch(var, cmWarnUnusedCliWarning); this->UsedCliVariables.erase(var); #endif @@ -2762,7 +2762,7 @@ void cmake::UnwatchUnusedCli(const std::string& var) void cmake::RunCheckForUnusedVariables() { -#ifdef CMAKE_BUILD_WITH_CMAKE +#ifndef CMAKE_BOOTSTRAP bool haveUnused = false; std::ostringstream msg; msg << "Manually-specified variables were not used by the project:"; diff --git a/Source/cmake.h b/Source/cmake.h index 92494ae..4c73519 100644 --- a/Source/cmake.h +++ b/Source/cmake.h @@ -20,7 +20,7 @@ #include "cmStateSnapshot.h" #include "cmStateTypes.h" -#if defined(CMAKE_BUILD_WITH_CMAKE) +#if !defined(CMAKE_BOOTSTRAP) # include "cm_jsoncpp_value.h" #endif @@ -145,7 +145,7 @@ public: cmake(cmake const&) = delete; cmake& operator=(cmake const&) = delete; -#if defined(CMAKE_BUILD_WITH_CMAKE) +#if !defined(CMAKE_BOOTSTRAP) Json::Value ReportVersionJson() const; Json::Value ReportCapabilitiesJson() const; #endif @@ -334,7 +334,7 @@ public: //! this is called by generators to update the progress void UpdateProgress(const std::string& msg, float prog); -#if defined(CMAKE_BUILD_WITH_CMAKE) +#if !defined(CMAKE_BOOTSTRAP) //! Get the variable watch object cmVariableWatch* GetVariableWatch() { return this->VariableWatch.get(); } #endif @@ -570,7 +570,7 @@ private: std::string GraphVizFile; InstalledFilesMap InstalledFiles; -#if defined(CMAKE_BUILD_WITH_CMAKE) +#if !defined(CMAKE_BOOTSTRAP) std::unique_ptr VariableWatch; std::unique_ptr FileAPI; #endif diff --git a/Source/cmakemain.cxx b/Source/cmakemain.cxx index 10a6825..522f9a4 100644 --- a/Source/cmakemain.cxx +++ b/Source/cmakemain.cxx @@ -12,7 +12,7 @@ #include "cmake.h" #include "cmcmd.h" -#ifdef CMAKE_BUILD_WITH_CMAKE +#ifndef CMAKE_BOOTSTRAP # include "cmDocumentation.h" # include "cmDynamicLoader.h" #endif @@ -20,7 +20,7 @@ #include "cm_uv.h" #include "cmsys/Encoding.hxx" -#if defined(_WIN32) && defined(CMAKE_BUILD_WITH_CMAKE) +#if defined(_WIN32) && !defined(CMAKE_BOOTSTRAP) # include "cmsys/ConsoleBuf.hxx" #endif @@ -33,7 +33,7 @@ #include namespace { -#ifdef CMAKE_BUILD_WITH_CMAKE +#ifndef CMAKE_BOOTSTRAP const char* cmDocumentationName[][2] = { { nullptr, " cmake - Cross-Platform Makefile Generator." }, { nullptr, nullptr } @@ -156,7 +156,7 @@ int do_cmake(int ac, char const* const* av) return 1; } -#ifdef CMAKE_BUILD_WITH_CMAKE +#ifndef CMAKE_BOOTSTRAP cmDocumentation doc; doc.addCMakeStandardDocSections(); if (doc.CheckOptions(ac, av)) { @@ -339,7 +339,7 @@ int extract_job_number(int& index, char const* current, char const* next, int do_build(int ac, char const* const* av) { -#ifndef CMAKE_BUILD_WITH_CMAKE +#ifdef CMAKE_BOOTSTRAP std::cerr << "This cmake does not support --build\n"; return -1; #else @@ -503,7 +503,7 @@ int do_build(int ac, char const* const* av) int do_install(int ac, char const* const* av) { -#ifndef CMAKE_BUILD_WITH_CMAKE +#ifdef CMAKE_BOOTSTRAP std::cerr << "This cmake does not support --install\n"; return -1; #else @@ -624,7 +624,7 @@ int do_install(int ac, char const* const* av) int do_open(int ac, char const* const* av) { -#ifndef CMAKE_BUILD_WITH_CMAKE +#ifdef CMAKE_BOOTSTRAP std::cerr << "This cmake does not support --open\n"; return -1; #else @@ -669,7 +669,7 @@ int do_open(int ac, char const* const* av) int main(int ac, char const* const* av) { cmSystemTools::EnsureStdPipes(); -#if defined(_WIN32) && defined(CMAKE_BUILD_WITH_CMAKE) +#if defined(_WIN32) && !defined(CMAKE_BOOTSTRAP) // Replace streambuf so we can output Unicode to console cmsys::ConsoleBuf::Manager consoleOut(std::cout); consoleOut.SetUTF8Pipes(); @@ -699,7 +699,7 @@ int main(int ac, char const* const* av) } } int ret = do_cmake(ac, av); -#ifdef CMAKE_BUILD_WITH_CMAKE +#ifndef CMAKE_BOOTSTRAP cmDynamicLoader::FlushCache(); #endif uv_loop_close(uv_default_loop()); diff --git a/Source/cmcmd.cxx b/Source/cmcmd.cxx index aecc978..69d5fcd 100644 --- a/Source/cmcmd.cxx +++ b/Source/cmcmd.cxx @@ -19,18 +19,18 @@ #include "cmVersion.h" #include "cmake.h" -#if defined(CMAKE_BUILD_WITH_CMAKE) +#if !defined(CMAKE_BOOTSTRAP) # include "cmDependsFortran.h" // For -E cmake_copy_f90_mod callback. # include "cmServer.h" # include "cmServerConnection.h" #endif -#if defined(CMAKE_BUILD_WITH_CMAKE) && defined(_WIN32) +#if !defined(CMAKE_BOOTSTRAP) && defined(_WIN32) # include "bindexplib.h" # include "cmsys/ConsoleBuf.hxx" #endif -#if defined(CMAKE_BUILD_WITH_CMAKE) && defined(_WIN32) && !defined(__CYGWIN__) +#if !defined(CMAKE_BOOTSTRAP) && defined(_WIN32) && !defined(__CYGWIN__) # include "cmVisualStudioWCEPlatformParser.h" #endif @@ -61,7 +61,7 @@ void CMakeCommandUsage(const char* program) { std::ostringstream errorStream; -#ifdef CMAKE_BUILD_WITH_CMAKE +#ifndef CMAKE_BOOTSTRAP /* clang-format off */ errorStream << "cmake version " << cmVersion::GetCMakeVersion() << "\n"; @@ -561,7 +561,7 @@ int cmcmd::ExecuteCMakeCommand(std::vector const& args) return 0; } -#if defined(_WIN32) && defined(CMAKE_BUILD_WITH_CMAKE) +#if defined(_WIN32) && !defined(CMAKE_BOOTSTRAP) else if (args[1] == "__create_def") { if (args.size() < 4) { std::cerr @@ -654,7 +654,7 @@ int cmcmd::ExecuteCMakeCommand(std::vector const& args) return 1; } -#if defined(CMAKE_BUILD_WITH_CMAKE) +#if !defined(CMAKE_BOOTSTRAP) if (args[1] == "environment") { for (auto const& env : cmSystemTools::GetEnvironmentVariables()) { std::cout << env << std::endl; @@ -994,7 +994,7 @@ int cmcmd::ExecuteCMakeCommand(std::vector const& args) return cmcmd::ExecuteLinkScript(args); } -#ifdef CMAKE_BUILD_WITH_CMAKE +#ifndef CMAKE_BOOTSTRAP // Internal CMake ninja dependency scanning support. if (args[1] == "cmake_ninja_depends") { return cmcmd_cmake_ninja_depends(args.begin() + 2, args.end()); @@ -1029,7 +1029,7 @@ int cmcmd::ExecuteCMakeCommand(std::vector const& args) return cmcmd::ExecuteEchoColor(args); } -#ifdef CMAKE_BUILD_WITH_CMAKE +#ifndef CMAKE_BOOTSTRAP if ((args[1] == "cmake_autogen") && (args.size() >= 4)) { cmQtAutoMocUic autoGen; std::string const& infoDir = args[2]; @@ -1210,7 +1210,7 @@ int cmcmd::ExecuteCMakeCommand(std::vector const& args) return 1; } } -#if defined(CMAKE_BUILD_WITH_CMAKE) +#if !defined(CMAKE_BOOTSTRAP) cmConnection* conn; if (isDebug) { conn = new cmServerStdIoConnection; @@ -1231,7 +1231,7 @@ int cmcmd::ExecuteCMakeCommand(std::vector const& args) return 1; } -#if defined(CMAKE_BUILD_WITH_CMAKE) +#if !defined(CMAKE_BOOTSTRAP) // Internal CMake Fortran module support. if (args[1] == "cmake_copy_f90_mod" && args.size() >= 4) { return cmDependsFortran::CopyModule(args) ? 0 : 1; @@ -1547,7 +1547,7 @@ int cmcmd::ExecuteLinkScript(std::vector const& args) int cmcmd::WindowsCEEnvironment(const char* version, const std::string& name) { -#if defined(CMAKE_BUILD_WITH_CMAKE) && defined(_WIN32) && !defined(__CYGWIN__) +#if !defined(CMAKE_BOOTSTRAP) && defined(_WIN32) && !defined(__CYGWIN__) cmVisualStudioWCEPlatformParser parser(name.c_str()); parser.ParseVersion(version); if (parser.Found()) { @@ -1605,7 +1605,7 @@ private: // still works. int cmcmd::VisualStudioLink(std::vector const& args, int type) { -#if defined(_WIN32) && defined(CMAKE_BUILD_WITH_CMAKE) +#if defined(_WIN32) && !defined(CMAKE_BOOTSTRAP) // Replace streambuf so we output in the system codepage. CMake is set up // to output in Unicode (see SetUTF8Pipes) but the Visual Studio linker // outputs using the system codepage so we need to change behavior when diff --git a/Source/ctest.cxx b/Source/ctest.cxx index 3b3630f..77a84fd 100644 --- a/Source/ctest.cxx +++ b/Source/ctest.cxx @@ -8,7 +8,7 @@ #include "cmSystemTools.h" #include "cmsys/Encoding.hxx" -#if defined(_WIN32) && defined(CMAKE_BUILD_WITH_CMAKE) +#if defined(_WIN32) && !defined(CMAKE_BOOTSTRAP) # include "cmsys/ConsoleBuf.hxx" #endif #include @@ -144,7 +144,7 @@ static const char* cmDocumentationOptions[][2] = { int main(int argc, char const* const* argv) { cmSystemTools::EnsureStdPipes(); -#if defined(_WIN32) && defined(CMAKE_BUILD_WITH_CMAKE) +#if defined(_WIN32) && !defined(CMAKE_BOOTSTRAP) // Replace streambuf so we can output Unicode to console cmsys::ConsoleBuf::Manager consoleOut(std::cout); consoleOut.SetUTF8Pipes(); https://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=ad0e44a18b1e54bcfac38100a13e6ce169d03099 commit ad0e44a18b1e54bcfac38100a13e6ce169d03099 Author: Kyle Edwards AuthorDate: Wed Aug 7 10:32:50 2019 -0400 Commit: Kyle Edwards CommitDate: Fri Aug 9 10:40:36 2019 -0400 Utilities/Scripts: Add temporary CMAKE_BOOTSTRAP conversion script diff --git a/Utilities/Scripts/cmake-bootstrap-def.sh b/Utilities/Scripts/cmake-bootstrap-def.sh new file mode 100755 index 0000000..09feded --- /dev/null +++ b/Utilities/Scripts/cmake-bootstrap-def.sh @@ -0,0 +1,7 @@ +#!/bin/sh + +sed -i -e 's/!defined(CMAKE_BUILD_WITH_CMAKE)/defined(CMAKE_BOOTSTRAP)/g' \ + -e 's/defined(CMAKE_BUILD_WITH_CMAKE)/!defined(CMAKE_BOOTSTRAP)/g' \ + -e 's/ifndef CMAKE_BUILD_WITH_CMAKE/ifdef CMAKE_BOOTSTRAP/g' \ + -e 's/ifdef CMAKE_BUILD_WITH_CMAKE/ifndef CMAKE_BOOTSTRAP/g' \ + $(git ls-files Source) https://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=27090096ef3dc572515c23e2ec92e5ee19432950 commit 27090096ef3dc572515c23e2ec92e5ee19432950 Author: Sebastian Holtermann AuthorDate: Thu Aug 8 13:33:58 2019 +0200 Commit: Sebastian Holtermann CommitDate: Fri Aug 9 12:20:50 2019 +0200 cmStringAlgorithms: Add cmRemoveQuotes - Add `cmRemoveQuotes` function to cmStringAlgorithms - Remove unused removeQuotes inline functions diff --git a/Source/cmGlobalGenerator.cxx b/Source/cmGlobalGenerator.cxx index 88da5eb..6cb0b5c 100644 --- a/Source/cmGlobalGenerator.cxx +++ b/Source/cmGlobalGenerator.cxx @@ -2270,14 +2270,6 @@ bool cmGlobalGenerator::NameResolvesToFramework( return false; } -inline std::string removeQuotes(const std::string& s) -{ - if (s.front() == '\"' && s.back() == '\"') { - return s.substr(1, s.size() - 2); - } - return s; -} - bool cmGlobalGenerator::CheckCMP0037(std::string const& targetName, std::string const& reason) const { diff --git a/Source/cmStringAlgorithms.cxx b/Source/cmStringAlgorithms.cxx index 5867a44..eca761b 100644 --- a/Source/cmStringAlgorithms.cxx +++ b/Source/cmStringAlgorithms.cxx @@ -21,6 +21,20 @@ std::string cmTrimWhitespace(cm::string_view str) return std::string(start, stop + 1); } +std::string cmRemoveQuotes(cm::string_view str) +{ + // We process only strings that have two quotes at least. + // Also front() and back() are only defined behavior on non empty strings. + if (str.size() >= 2 && // + str.front() == '"' && // + str.back() == '"') { + // Remove a quote from the front and back + str.remove_prefix(1); + str.remove_suffix(1); + } + return std::string(str); +} + std::string cmEscapeQuotes(cm::string_view str) { std::string result; diff --git a/Source/cmStringAlgorithms.h b/Source/cmStringAlgorithms.h index 1898649..44b01b8 100644 --- a/Source/cmStringAlgorithms.h +++ b/Source/cmStringAlgorithms.h @@ -41,6 +41,9 @@ inline bool cmIsSpace(char ch) /** Returns a string that has whitespace removed from the start and the end. */ std::string cmTrimWhitespace(cm::string_view str); +/** Returns a string that has quotes removed from the start and the end. */ +std::string cmRemoveQuotes(cm::string_view str); + /** Escape quotes in a string. */ std::string cmEscapeQuotes(cm::string_view str); diff --git a/Source/cmake.cxx b/Source/cmake.cxx index 3cc6776..45c5fff 100644 --- a/Source/cmake.cxx +++ b/Source/cmake.cxx @@ -2270,14 +2270,6 @@ void cmake::TruncateOutputLog(const char* fname) } } -inline std::string removeQuotes(const std::string& s) -{ - if (s.front() == '\"' && s.back() == '\"') { - return s.substr(1, s.size() - 2); - } - return s; -} - void cmake::MarkCliAsUsed(const std::string& variable) { this->UsedCliVariables[variable] = true; diff --git a/Tests/CMakeLib/testStringAlgorithms.cxx b/Tests/CMakeLib/testStringAlgorithms.cxx index 55d2a8f..f833502 100644 --- a/Tests/CMakeLib/testStringAlgorithms.cxx +++ b/Tests/CMakeLib/testStringAlgorithms.cxx @@ -51,6 +51,29 @@ int testStringAlgorithms(int /*unused*/, char* /*unused*/ []) } // ---------------------------------------------------------------------- + // Test cmRemoveQuotes + { + auto test = [&assert_string](cm::string_view source, + cm::string_view expected, + cm::string_view title) { + assert_string(cmRemoveQuotes(source), expected, title); + }; + + test("", "", "cmRemoveQuotes empty"); + test("\"", "\"", "cmRemoveQuotes single quote"); + test("\"\"", "", "cmRemoveQuotes double quote"); + test("\"a", "\"a", "cmRemoveQuotes quote char"); + test("\"ab", "\"ab", "cmRemoveQuotes quote char char"); + test("a\"", "a\"", "cmRemoveQuotes char quote"); + test("ab\"", "ab\"", "cmRemoveQuotes char char quote"); + test("a", "a", "cmRemoveQuotes single char"); + test("ab", "ab", "cmRemoveQuotes two chars"); + test("abc", "abc", "cmRemoveQuotes three chars"); + test("\"abc\"", "abc", "cmRemoveQuotes quoted chars"); + test("\"\"abc\"\"", "\"abc\"", "cmRemoveQuotes quoted quoted chars"); + } + + // ---------------------------------------------------------------------- // Test cmEscapeQuotes { assert_string(cmEscapeQuotes("plain"), "plain", "cmEscapeQuotes plain"); https://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=62659100aa4ad25fabf07797ace186f11463237e commit 62659100aa4ad25fabf07797ace186f11463237e Author: Regina Pfeifer AuthorDate: Fri Aug 9 10:58:00 2019 +0200 Commit: Regina Pfeifer CommitDate: Fri Aug 9 10:58:00 2019 +0200 cmLocalGenerator: Use cmStrCat Grep for '[A-Z]_";' to find places that could benefit from cmStrCat. diff --git a/Source/cmLocalGenerator.cxx b/Source/cmLocalGenerator.cxx index 3deaeb0..ae1b6d2 100644 --- a/Source/cmLocalGenerator.cxx +++ b/Source/cmLocalGenerator.cxx @@ -745,12 +745,10 @@ std::string cmLocalGenerator::GetIncludeFlags( OutputFormat shellFormat = forResponseFile ? RESPONSE : SHELL; std::ostringstream includeFlags; - std::string flagVar = "CMAKE_INCLUDE_FLAG_"; - flagVar += lang; - std::string const& includeFlag = this->Makefile->GetSafeDefinition(flagVar); - flagVar = "CMAKE_INCLUDE_FLAG_SEP_"; - flagVar += lang; - const char* sep = this->Makefile->GetDefinition(flagVar); + std::string const& includeFlag = + this->Makefile->GetSafeDefinition(cmStrCat("CMAKE_INCLUDE_FLAG_", lang)); + const char* sep = + this->Makefile->GetDefinition(cmStrCat("CMAKE_INCLUDE_FLAG_SEP_", lang)); bool quotePaths = false; if (this->Makefile->GetDefinition("CMAKE_QUOTE_INCLUDE_PATHS")) { quotePaths = true; @@ -767,23 +765,16 @@ std::string cmLocalGenerator::GetIncludeFlags( // Support special system include flag if it is available and the // normal flag is repeated for each directory. - std::string sysFlagVar = "CMAKE_INCLUDE_SYSTEM_FLAG_"; - sysFlagVar += lang; const char* sysIncludeFlag = nullptr; if (repeatFlag) { - sysIncludeFlag = this->Makefile->GetDefinition(sysFlagVar); + sysIncludeFlag = this->Makefile->GetDefinition( + cmStrCat("CMAKE_INCLUDE_SYSTEM_FLAG_", lang)); } - std::string fwSearchFlagVar = "CMAKE_"; - fwSearchFlagVar += lang; - fwSearchFlagVar += "_FRAMEWORK_SEARCH_FLAG"; - const char* fwSearchFlag = this->Makefile->GetDefinition(fwSearchFlagVar); - - std::string sysFwSearchFlagVar = "CMAKE_"; - sysFwSearchFlagVar += lang; - sysFwSearchFlagVar += "_SYSTEM_FRAMEWORK_SEARCH_FLAG"; - const char* sysFwSearchFlag = - this->Makefile->GetDefinition(sysFwSearchFlagVar); + const char* fwSearchFlag = this->Makefile->GetDefinition( + cmStrCat("CMAKE_", lang, "_FRAMEWORK_SEARCH_FLAG")); + const char* sysFwSearchFlag = this->Makefile->GetDefinition( + cmStrCat("CMAKE_", lang, "_SYSTEM_FRAMEWORK_SEARCH_FLAG")); bool flagUsed = false; std::set emitted; @@ -793,9 +784,8 @@ std::string cmLocalGenerator::GetIncludeFlags( for (std::string const& i : includes) { if (fwSearchFlag && *fwSearchFlag && this->Makefile->IsOn("APPLE") && cmSystemTools::IsPathToFramework(i)) { - std::string frameworkDir = i; - frameworkDir += "/../"; - frameworkDir = cmSystemTools::CollapseFullPath(frameworkDir); + std::string const frameworkDir = + cmSystemTools::CollapseFullPath(cmStrCat(i, "/../")); if (emitted.insert(frameworkDir).second) { if (sysFwSearchFlag && target && target->IsSystemIncludeDirectory(i, config, lang)) { @@ -963,10 +953,8 @@ std::vector> cmLocalGenerator::GetIncludeDirectoriesImplicit( // These are intended to simulate additional implicit include directories. std::vector userStandardDirs; { - std::string key = "CMAKE_"; - key += lang; - key += "_STANDARD_INCLUDE_DIRECTORIES"; - std::string const value = this->Makefile->GetSafeDefinition(key); + std::string const value = this->Makefile->GetSafeDefinition( + cmStrCat("CMAKE_", lang, "_STANDARD_INCLUDE_DIRECTORIES")); cmSystemTools::ExpandListArgument(value, userStandardDirs); for (std::string& usd : userStandardDirs) { cmSystemTools::ConvertToUnixSlashes(usd); @@ -989,10 +977,9 @@ std::vector> cmLocalGenerator::GetIncludeDirectoriesImplicit( // * 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)) { + const char* value = this->Makefile->GetDefinition( + cmStrCat("CMAKE_", lang, "_IMPLICIT_INCLUDE_DIRECTORIES")); + if (value != nullptr) { size_t const impDirVecOldSize = impDirVec.size(); cmSystemTools::ExpandListArgument(value, impDirVec); // FIXME: Use cmRange with 'advance()' when it supports non-const. @@ -1210,9 +1197,8 @@ void cmLocalGenerator::GetTargetFlags( linkFlags += " "; } if (!buildType.empty()) { - std::string configLinkFlags = "LINK_FLAGS_"; - configLinkFlags += buildType; - targetLinkFlags = target->GetProperty(configLinkFlags); + targetLinkFlags = + target->GetProperty(cmStrCat("LINK_FLAGS_", buildType)); if (targetLinkFlags) { linkFlags += targetLinkFlags; linkFlags += " "; @@ -1234,9 +1220,8 @@ void cmLocalGenerator::GetTargetFlags( this->Makefile->GetSafeDefinition("CMAKE_EXE_LINKER_FLAGS"); linkFlags += " "; if (!buildType.empty()) { - std::string build = "CMAKE_EXE_LINKER_FLAGS_"; - build += buildType; - linkFlags += this->Makefile->GetSafeDefinition(build); + linkFlags += this->Makefile->GetSafeDefinition( + cmStrCat("CMAKE_EXE_LINKER_FLAGS_", buildType)); linkFlags += " "; } if (linkLanguage.empty()) { @@ -1257,11 +1242,8 @@ void cmLocalGenerator::GetTargetFlags( } if (target->IsExecutableWithExports()) { - std::string exportFlagVar = "CMAKE_EXE_EXPORTS_"; - exportFlagVar += linkLanguage; - exportFlagVar += "_FLAG"; - - linkFlags += this->Makefile->GetSafeDefinition(exportFlagVar); + linkFlags += this->Makefile->GetSafeDefinition( + cmStrCat("CMAKE_EXE_EXPORTS_", linkLanguage, "_FLAG")); linkFlags += " "; } } @@ -1293,9 +1275,8 @@ void cmLocalGenerator::GetTargetFlags( linkFlags += " "; } if (!buildType.empty()) { - std::string configLinkFlags = "LINK_FLAGS_"; - configLinkFlags += buildType; - targetLinkFlags = target->GetProperty(configLinkFlags); + targetLinkFlags = + target->GetProperty(cmStrCat("LINK_FLAGS_", buildType)); if (targetLinkFlags) { linkFlags += targetLinkFlags; linkFlags += " "; @@ -1470,20 +1451,12 @@ void cmLocalGenerator::OutputLinkLibraries( } // Add standard libraries for this language. - std::string standardLibsVar = "CMAKE_"; - standardLibsVar += cli.GetLinkLanguage(); - standardLibsVar += "_STANDARD_LIBRARIES"; - std::string stdLibString; - if (const char* stdLibs = this->Makefile->GetDefinition(standardLibsVar)) { - stdLibString = stdLibs; - } + std::string stdLibString = this->Makefile->GetSafeDefinition( + cmStrCat("CMAKE_", cli.GetLinkLanguage(), "_STANDARD_LIBRARIES")); // Append the framework search path flags. - std::string fwSearchFlagVar = "CMAKE_"; - fwSearchFlagVar += linkLanguage; - fwSearchFlagVar += "_FRAMEWORK_SEARCH_FLAG"; - std::string fwSearchFlag = - this->Makefile->GetSafeDefinition(fwSearchFlagVar); + std::string fwSearchFlag = this->Makefile->GetSafeDefinition( + cmStrCat("CMAKE_", linkLanguage, "_FRAMEWORK_SEARCH_FLAG")); frameworkPath = linkLineComputer->ComputeFrameworkPath(cli, fwSearchFlag); linkPath = @@ -1538,10 +1511,8 @@ std::string cmLocalGenerator::GetLinkLibsCMP0065( } if (add_shlib_flags) { - std::string linkFlagsVar = "CMAKE_SHARED_LIBRARY_LINK_"; - linkFlagsVar += linkLanguage; - linkFlagsVar += "_FLAGS"; - linkFlags = this->Makefile->GetSafeDefinition(linkFlagsVar); + linkFlags = this->Makefile->GetSafeDefinition( + cmStrCat("CMAKE_SHARED_LIBRARY_LINK_", linkLanguage, "_FLAGS")); } } return linkFlags; @@ -1599,10 +1570,8 @@ void cmLocalGenerator::AddLanguageFlags(std::string& flags, const std::string& config) { // Add language-specific flags. - std::string flagsVar = "CMAKE_"; - flagsVar += lang; - flagsVar += "_FLAGS"; - this->AddConfigVariableFlags(flags, flagsVar, config); + this->AddConfigVariableFlags(flags, cmStrCat("CMAKE_", lang, "_FLAGS"), + config); // Add MSVC runtime library flags. This is activated by the presence // of a default selection whether or not it is overridden by a property. @@ -1773,10 +1742,9 @@ void cmLocalGenerator::AddSharedFlags(std::string& flags, // Add flags for dealing with shared libraries for this language. if (shared) { - flagsVar = "CMAKE_SHARED_LIBRARY_"; - flagsVar += lang; - flagsVar += "_FLAGS"; - this->AppendFlags(flags, this->Makefile->GetDefinition(flagsVar)); + this->AppendFlags(flags, + this->Makefile->GetDefinition( + cmStrCat("CMAKE_SHARED_LIBRARY_", lang, "_FLAGS"))); } } @@ -2065,9 +2033,7 @@ bool cmLocalGenerator::GetShouldUseOldFlags(bool shared, std::string originalFlags = this->GlobalGenerator->GetSharedLibFlagsForLanguage(lang); if (shared) { - std::string flagsVar = "CMAKE_SHARED_LIBRARY_"; - flagsVar += lang; - flagsVar += "_FLAGS"; + std::string flagsVar = cmStrCat("CMAKE_SHARED_LIBRARY_", lang, "_FLAGS"); std::string const& flags = this->Makefile->GetSafeDefinition(flagsVar); if (flags != originalFlags) { @@ -2106,16 +2072,12 @@ void cmLocalGenerator::AddPositionIndependentFlags(std::string& flags, std::string picFlags; if (targetType == cmStateEnums::EXECUTABLE) { - std::string flagsVar = "CMAKE_"; - flagsVar += lang; - flagsVar += "_COMPILE_OPTIONS_PIE"; - picFlags = this->Makefile->GetSafeDefinition(flagsVar); + picFlags = this->Makefile->GetSafeDefinition( + cmStrCat("CMAKE_", lang, "_COMPILE_OPTIONS_PIE")); } if (picFlags.empty()) { - std::string flagsVar = "CMAKE_"; - flagsVar += lang; - flagsVar += "_COMPILE_OPTIONS_PIC"; - picFlags = this->Makefile->GetSafeDefinition(flagsVar); + picFlags = this->Makefile->GetSafeDefinition( + cmStrCat("CMAKE_", lang, "_COMPILE_OPTIONS_PIC")); } if (!picFlags.empty()) { std::vector options; @@ -2356,10 +2318,8 @@ void cmLocalGenerator::JoinDefines(const std::set& defines, // Lookup the define flag for the current language. std::string dflag = "-D"; if (!lang.empty()) { - std::string defineFlagVar = "CMAKE_"; - defineFlagVar += lang; - defineFlagVar += "_DEFINE_FLAG"; - const char* df = this->Makefile->GetDefinition(defineFlagVar); + const char* df = + this->Makefile->GetDefinition(cmStrCat("CMAKE_", lang, "_DEFINE_FLAG")); if (df && *df) { dflag = df; } @@ -2405,11 +2365,9 @@ void cmLocalGenerator::AppendFeatureOptions(std::string& flags, const std::string& lang, const char* feature) { - std::string optVar = "CMAKE_"; - optVar += lang; - optVar += "_COMPILE_OPTIONS_"; - optVar += feature; - if (const char* optionList = this->Makefile->GetDefinition(optVar)) { + const char* optionList = this->Makefile->GetDefinition( + cmStrCat("CMAKE_", lang, "_COMPILE_OPTIONS_", feature)); + if (optionList != nullptr) { std::vector options; cmSystemTools::ExpandListArgument(optionList, options); for (std::string const& o : options) { @@ -2762,10 +2720,8 @@ std::string cmLocalGenerator::GetObjectFileNameWithoutTarget( if (!replaceExt) { std::string lang = source.GetLanguage(); if (!lang.empty()) { - std::string repVar = "CMAKE_"; - repVar += lang; - repVar += "_OUTPUT_EXTENSION_REPLACE"; - replaceExt = this->Makefile->IsOn(repVar); + replaceExt = this->Makefile->IsOn( + cmStrCat("CMAKE_", lang, "_OUTPUT_EXTENSION_REPLACE")); } } https://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=9ba0bf60c6a1dc0904c40575efd69bba580b0902 commit 9ba0bf60c6a1dc0904c40575efd69bba580b0902 Author: Regina Pfeifer AuthorDate: Tue Aug 6 23:10:04 2019 +0200 Commit: Regina Pfeifer CommitDate: Wed Aug 7 10:16:32 2019 +0200 cmA*Command: Turn into free functions Ref: #19499 diff --git a/Source/cmAddCompileDefinitionsCommand.cxx b/Source/cmAddCompileDefinitionsCommand.cxx index 0474819..b00a4a7 100644 --- a/Source/cmAddCompileDefinitionsCommand.cxx +++ b/Source/cmAddCompileDefinitionsCommand.cxx @@ -2,19 +2,15 @@ file Copyright.txt or https://cmake.org/licensing for details. */ #include "cmAddCompileDefinitionsCommand.h" +#include "cmExecutionStatus.h" #include "cmMakefile.h" -class cmExecutionStatus; - -bool cmAddCompileDefinitionsCommand::InitialPass( - std::vector const& args, cmExecutionStatus&) +bool cmAddCompileDefinitionsCommand(std::vector const& args, + cmExecutionStatus& status) { - if (args.empty()) { - return true; - } - + cmMakefile& mf = status.GetMakefile(); for (std::string const& i : args) { - this->Makefile->AddCompileDefinition(i); + mf.AddCompileDefinition(i); } return true; } diff --git a/Source/cmAddCompileDefinitionsCommand.h b/Source/cmAddCompileDefinitionsCommand.h index 5f90ed9..4bd621c 100644 --- a/Source/cmAddCompileDefinitionsCommand.h +++ b/Source/cmAddCompileDefinitionsCommand.h @@ -8,29 +8,9 @@ #include #include -#include "cm_memory.hxx" - -#include "cmCommand.h" - class cmExecutionStatus; -class cmAddCompileDefinitionsCommand : public cmCommand -{ -public: - /** - * This is a virtual constructor for the command. - */ - std::unique_ptr Clone() override - { - return cm::make_unique(); - } - - /** - * This is called when the command is first encountered in - * the CMakeLists.txt file. - */ - bool InitialPass(std::vector const& args, - cmExecutionStatus& status) override; -}; +bool cmAddCompileDefinitionsCommand(std::vector const& args, + cmExecutionStatus& status); #endif diff --git a/Source/cmAddCompileOptionsCommand.cxx b/Source/cmAddCompileOptionsCommand.cxx index 412fb38..8ccb512 100644 --- a/Source/cmAddCompileOptionsCommand.cxx +++ b/Source/cmAddCompileOptionsCommand.cxx @@ -2,19 +2,15 @@ file Copyright.txt or https://cmake.org/licensing for details. */ #include "cmAddCompileOptionsCommand.h" +#include "cmExecutionStatus.h" #include "cmMakefile.h" -class cmExecutionStatus; - -bool cmAddCompileOptionsCommand::InitialPass( - std::vector const& args, cmExecutionStatus&) +bool cmAddCompileOptionsCommand(std::vector const& args, + cmExecutionStatus& status) { - if (args.empty()) { - return true; - } - + cmMakefile& mf = status.GetMakefile(); for (std::string const& i : args) { - this->Makefile->AddCompileOption(i); + mf.AddCompileOption(i); } return true; } diff --git a/Source/cmAddCompileOptionsCommand.h b/Source/cmAddCompileOptionsCommand.h index b34b7fc..b172412 100644 --- a/Source/cmAddCompileOptionsCommand.h +++ b/Source/cmAddCompileOptionsCommand.h @@ -8,29 +8,9 @@ #include #include -#include "cm_memory.hxx" - -#include "cmCommand.h" - class cmExecutionStatus; -class cmAddCompileOptionsCommand : public cmCommand -{ -public: - /** - * This is a virtual constructor for the command. - */ - std::unique_ptr Clone() override - { - return cm::make_unique(); - } - - /** - * This is called when the command is first encountered in - * the CMakeLists.txt file. - */ - bool InitialPass(std::vector const& args, - cmExecutionStatus& status) override; -}; +bool cmAddCompileOptionsCommand(std::vector const& args, + cmExecutionStatus& status); #endif diff --git a/Source/cmAddCustomCommandCommand.cxx b/Source/cmAddCustomCommandCommand.cxx index 6eb38bd..e502a64 100644 --- a/Source/cmAddCustomCommandCommand.cxx +++ b/Source/cmAddCustomCommandCommand.cxx @@ -8,6 +8,7 @@ #include "cmCustomCommand.h" #include "cmCustomCommandLines.h" +#include "cmExecutionStatus.h" #include "cmGlobalGenerator.h" #include "cmMakefile.h" #include "cmMessageType.h" @@ -16,21 +17,22 @@ #include "cmSystemTools.h" #include "cmTarget.h" -class cmExecutionStatus; +static bool cmAddCustomCommandCommandCheckOutputs( + const std::vector& outputs, cmExecutionStatus& status); -// cmAddCustomCommandCommand -bool cmAddCustomCommandCommand::InitialPass( - std::vector const& args, cmExecutionStatus&) +bool cmAddCustomCommandCommand(std::vector const& args, + cmExecutionStatus& status) { /* Let's complain at the end of this function about the lack of a particular arg. For the moment, let's say that COMMAND, and either TARGET or SOURCE are required. */ if (args.size() < 4) { - this->SetError("called with wrong number of arguments."); + status.SetError("called with wrong number of arguments."); return false; } + cmMakefile& mf = status.GetMakefile(); std::string source, target, main_dependency, working, depfile, job_pool; std::string comment_buffer; const char* comment = nullptr; @@ -167,9 +169,9 @@ bool cmAddCustomCommandCommand::InitialPass( doing = doing_comment; } else if (copy == keyDEPFILE) { doing = doing_depfile; - if (this->Makefile->GetGlobalGenerator()->GetName() != "Ninja") { - this->SetError("Option DEPFILE not supported by " + - this->Makefile->GetGlobalGenerator()->GetName()); + if (mf.GetGlobalGenerator()->GetName() != "Ninja") { + status.SetError("Option DEPFILE not supported by " + + mf.GetGlobalGenerator()->GetName()); return false; } } else if (copy == keyJOB_POOL) { @@ -192,7 +194,7 @@ bool cmAddCustomCommandCommand::InitialPass( // and later references "${CMAKE_CURRENT_SOURCE_DIR}/out.txt". // This is fairly obscure so we can wait for someone to // complain. - filename = this->Makefile->GetCurrentBinaryDirectory(); + filename = mf.GetCurrentBinaryDirectory(); filename += "/"; } filename += copy; @@ -269,7 +271,7 @@ bool cmAddCustomCommandCommand::InitialPass( comment = comment_buffer.c_str(); break; default: - this->SetError("Wrong syntax. Unknown type of argument."); + status.SetError("Wrong syntax. Unknown type of argument."); return false; } } @@ -284,31 +286,31 @@ bool cmAddCustomCommandCommand::InitialPass( // At this point we could complain about the lack of arguments. For // the moment, let's say that COMMAND, TARGET are always required. if (output.empty() && target.empty()) { - this->SetError("Wrong syntax. A TARGET or OUTPUT must be specified."); + status.SetError("Wrong syntax. A TARGET or OUTPUT must be specified."); return false; } if (source.empty() && !target.empty() && !output.empty()) { - this->SetError( + status.SetError( "Wrong syntax. A TARGET and OUTPUT can not both be specified."); return false; } if (append && output.empty()) { - this->SetError("given APPEND option with no OUTPUT."); + status.SetError("given APPEND option with no OUTPUT."); return false; } // Make sure the output names and locations are safe. - if (!this->CheckOutputs(output) || !this->CheckOutputs(outputs) || - !this->CheckOutputs(byproducts)) { + if (!cmAddCustomCommandCommandCheckOutputs(output, status) || + !cmAddCustomCommandCommandCheckOutputs(outputs, status) || + !cmAddCustomCommandCommandCheckOutputs(byproducts, status)) { return false; } // Check for an append request. if (append) { // Lookup an existing command. - if (cmSourceFile* sf = - this->Makefile->GetSourceFileWithOutput(output[0])) { + if (cmSourceFile* sf = mf.GetSourceFileWithOutput(output[0])) { if (cmCustomCommand* cc = sf->GetCustomCommand()) { cc->AppendCommands(commandLines); cc->AppendDepends(depends); @@ -321,12 +323,12 @@ bool cmAddCustomCommandCommand::InitialPass( std::ostringstream e; e << "given APPEND option with output\n\"" << output[0] << "\"\nwhich is not already a custom command output."; - this->SetError(e.str()); + status.SetError(e.str()); return false; } if (uses_terminal && !job_pool.empty()) { - this->SetError("JOB_POOL is shadowed by USES_TERMINAL."); + status.SetError("JOB_POOL is shadowed by USES_TERMINAL."); return false; } @@ -335,22 +337,21 @@ bool cmAddCustomCommandCommand::InitialPass( if (source.empty() && output.empty()) { // Source is empty, use the target. std::vector no_depends; - this->Makefile->AddCustomCommandToTarget( - target, byproducts, no_depends, commandLines, cctype, comment, - working.c_str(), escapeOldStyle, uses_terminal, depfile, job_pool, - command_expand_lists); + mf.AddCustomCommandToTarget(target, byproducts, no_depends, commandLines, + cctype, comment, working.c_str(), + escapeOldStyle, uses_terminal, depfile, + job_pool, command_expand_lists); } else if (target.empty()) { // Target is empty, use the output. - this->Makefile->AddCustomCommandToOutput( - output, byproducts, depends, main_dependency, commandLines, comment, - working.c_str(), false, escapeOldStyle, uses_terminal, - command_expand_lists, depfile, job_pool); + mf.AddCustomCommandToOutput(output, byproducts, depends, main_dependency, + commandLines, comment, working.c_str(), false, + escapeOldStyle, uses_terminal, + command_expand_lists, depfile, job_pool); // Add implicit dependency scanning requests if any were given. if (!implicit_depends.empty()) { bool okay = false; - if (cmSourceFile* sf = - this->Makefile->GetSourceFileWithOutput(output[0])) { + if (cmSourceFile* sf = mf.GetSourceFileWithOutput(output[0])) { if (cmCustomCommand* cc = sf->GetCustomCommand()) { okay = true; cc->SetImplicitDepends(implicit_depends); @@ -360,21 +361,21 @@ bool cmAddCustomCommandCommand::InitialPass( std::ostringstream e; e << "could not locate source file with a custom command producing \"" << output[0] << "\" even though this command tried to create it!"; - this->SetError(e.str()); + status.SetError(e.str()); return false; } } } else if (!byproducts.empty()) { - this->SetError("BYPRODUCTS may not be specified with SOURCE signatures"); + status.SetError("BYPRODUCTS may not be specified with SOURCE signatures"); return false; } else if (uses_terminal) { - this->SetError("USES_TERMINAL may not be used with SOURCE signatures"); + status.SetError("USES_TERMINAL may not be used with SOURCE signatures"); return false; } else { bool issueMessage = true; std::ostringstream e; MessageType messageType = MessageType::AUTHOR_WARNING; - switch (this->Makefile->GetPolicyStatus(cmPolicies::CMP0050)) { + switch (mf.GetPolicyStatus(cmPolicies::CMP0050)) { case cmPolicies::WARN: e << cmPolicies::GetPolicyWarning(cmPolicies::CMP0050) << "\n"; break; @@ -391,30 +392,31 @@ bool cmAddCustomCommandCommand::InitialPass( if (issueMessage) { e << "The SOURCE signatures of add_custom_command are no longer " "supported."; - this->Makefile->IssueMessage(messageType, e.str()); + mf.IssueMessage(messageType, e.str()); if (messageType == MessageType::FATAL_ERROR) { return false; } } // Use the old-style mode for backward compatibility. - this->Makefile->AddCustomCommandOldStyle(target, outputs, depends, source, - commandLines, comment); + mf.AddCustomCommandOldStyle(target, outputs, depends, source, commandLines, + comment); } return true; } -bool cmAddCustomCommandCommand::CheckOutputs( - const std::vector& outputs) +bool cmAddCustomCommandCommandCheckOutputs( + const std::vector& outputs, cmExecutionStatus& status) { + cmMakefile& mf = status.GetMakefile(); for (std::string const& o : outputs) { // Make sure the file will not be generated into the source // directory during an out of source build. - if (!this->Makefile->CanIWriteThisFile(o)) { + if (!mf.CanIWriteThisFile(o)) { std::string e = "attempted to have a file \"" + o + "\" in a source directory as an output of custom command."; - this->SetError(e); + status.SetError(e); cmSystemTools::SetFatalErrorOccured(); return false; } @@ -425,7 +427,7 @@ bool cmAddCustomCommandCommand::CheckOutputs( std::ostringstream msg; msg << "called with OUTPUT containing a \"" << o[pos] << "\". This character is not allowed."; - this->SetError(msg.str()); + status.SetError(msg.str()); return false; } } diff --git a/Source/cmAddCustomCommandCommand.h b/Source/cmAddCustomCommandCommand.h index 931aeab..4f8c58f 100644 --- a/Source/cmAddCustomCommandCommand.h +++ b/Source/cmAddCustomCommandCommand.h @@ -8,38 +8,9 @@ #include #include -#include "cm_memory.hxx" - -#include "cmCommand.h" - class cmExecutionStatus; -/** \class cmAddCustomCommandCommand - * \brief cmAddCustomCommandCommand defines a new command (rule) that can - * be executed within the build process - * - */ - -class cmAddCustomCommandCommand : public cmCommand -{ -public: - /** - * This is a virtual constructor for the command. - */ - std::unique_ptr Clone() override - { - return cm::make_unique(); - } - - /** - * This is called when the command is first encountered in - * the CMakeLists.txt file. - */ - bool InitialPass(std::vector const& args, - cmExecutionStatus& status) override; - -protected: - bool CheckOutputs(const std::vector& outputs); -}; +bool cmAddCustomCommandCommand(std::vector const& args, + cmExecutionStatus& status); #endif diff --git a/Source/cmAddCustomTargetCommand.cxx b/Source/cmAddCustomTargetCommand.cxx index 0ecd5f5..f812ab5 100644 --- a/Source/cmAddCustomTargetCommand.cxx +++ b/Source/cmAddCustomTargetCommand.cxx @@ -6,6 +6,7 @@ #include #include "cmCustomCommandLines.h" +#include "cmExecutionStatus.h" #include "cmGeneratorExpression.h" #include "cmGlobalGenerator.h" #include "cmMakefile.h" @@ -14,17 +15,15 @@ #include "cmSystemTools.h" #include "cmTarget.h" -class cmExecutionStatus; - -// cmAddCustomTargetCommand -bool cmAddCustomTargetCommand::InitialPass( - std::vector const& args, cmExecutionStatus&) +bool cmAddCustomTargetCommand(std::vector const& args, + cmExecutionStatus& status) { if (args.empty()) { - this->SetError("called with incorrect number of arguments"); + status.SetError("called with incorrect number of arguments"); return false; } + cmMakefile& mf = status.GetMakefile(); std::string const& targetName = args[0]; // Check the target name. @@ -33,7 +32,7 @@ bool cmAddCustomTargetCommand::InitialPass( e << "called with invalid target name \"" << targetName << "\". Target names may not contain a slash. " << "Use ADD_CUSTOM_COMMAND to generate files."; - this->SetError(e.str()); + status.SetError(e.str()); return false; } @@ -122,7 +121,7 @@ bool cmAddCustomTargetCommand::InitialPass( case doing_byproducts: { std::string filename; if (!cmSystemTools::FileIsFullPath(copy)) { - filename = this->Makefile->GetCurrentBinaryDirectory(); + filename = mf.GetCurrentBinaryDirectory(); filename += "/"; } filename += copy; @@ -145,7 +144,7 @@ bool cmAddCustomTargetCommand::InitialPass( job_pool = copy; break; default: - this->SetError("Wrong syntax. Unknown type of argument."); + status.SetError("Wrong syntax. Unknown type of argument."); return false; } } @@ -156,7 +155,7 @@ bool cmAddCustomTargetCommand::InitialPass( std::ostringstream msg; msg << "called with target name containing a \"" << targetName[pos] << "\". This character is not allowed."; - this->SetError(msg.str()); + status.SetError(msg.str()); return false; } @@ -168,8 +167,7 @@ bool cmAddCustomTargetCommand::InitialPass( if (nameOk) { nameOk = targetName.find(':') == std::string::npos; } - if (!nameOk && - !this->Makefile->CheckCMP0037(targetName, cmStateEnums::UTILITY)) { + if (!nameOk && !mf.CheckCMP0037(targetName, cmStateEnums::UTILITY)) { return false; } @@ -182,39 +180,37 @@ bool cmAddCustomTargetCommand::InitialPass( // Enforce name uniqueness. { std::string msg; - if (!this->Makefile->EnforceUniqueName(targetName, msg, true)) { - this->SetError(msg); + if (!mf.EnforceUniqueName(targetName, msg, true)) { + status.SetError(msg); return false; } } if (commandLines.empty() && !byproducts.empty()) { - this->Makefile->IssueMessage( - MessageType::FATAL_ERROR, - "BYPRODUCTS may not be specified without any COMMAND"); + mf.IssueMessage(MessageType::FATAL_ERROR, + "BYPRODUCTS may not be specified without any COMMAND"); return true; } if (commandLines.empty() && uses_terminal) { - this->Makefile->IssueMessage( - MessageType::FATAL_ERROR, - "USES_TERMINAL may not be specified without any COMMAND"); + mf.IssueMessage(MessageType::FATAL_ERROR, + "USES_TERMINAL may not be specified without any COMMAND"); return true; } if (commandLines.empty() && command_expand_lists) { - this->Makefile->IssueMessage( + mf.IssueMessage( MessageType::FATAL_ERROR, "COMMAND_EXPAND_LISTS may not be specified without any COMMAND"); return true; } if (uses_terminal && !job_pool.empty()) { - this->SetError("JOB_POOL is shadowed by USES_TERMINAL."); + status.SetError("JOB_POOL is shadowed by USES_TERMINAL."); return false; } // Add the utility target to the makefile. bool escapeOldStyle = !verbatim; - cmTarget* target = this->Makefile->AddUtilityCommand( + cmTarget* target = mf.AddUtilityCommand( targetName, cmMakefile::TargetOrigin::Project, excludeFromAll, working_directory.c_str(), byproducts, depends, commandLines, escapeOldStyle, comment, uses_terminal, command_expand_lists, job_pool); diff --git a/Source/cmAddCustomTargetCommand.h b/Source/cmAddCustomTargetCommand.h index db577bc..e23ef9f 100644 --- a/Source/cmAddCustomTargetCommand.h +++ b/Source/cmAddCustomTargetCommand.h @@ -8,36 +8,9 @@ #include #include -#include "cm_memory.hxx" - -#include "cmCommand.h" - class cmExecutionStatus; -/** \class cmAddCustomTargetCommand - * \brief Command that adds a target to the build system. - * - * cmAddCustomTargetCommand adds an extra target to the build system. - * This is useful when you would like to add special - * targets like "install,", "clean," and so on. - */ -class cmAddCustomTargetCommand : public cmCommand -{ -public: - /** - * This is a virtual constructor for the command. - */ - std::unique_ptr Clone() override - { - return cm::make_unique(); - } - - /** - * This is called when the command is first encountered in - * the CMakeLists.txt file. - */ - bool InitialPass(std::vector const& args, - cmExecutionStatus& status) override; -}; +bool cmAddCustomTargetCommand(std::vector const& args, + cmExecutionStatus& status); #endif diff --git a/Source/cmAddDefinitionsCommand.cxx b/Source/cmAddDefinitionsCommand.cxx index 62e57a3..0b10aee 100644 --- a/Source/cmAddDefinitionsCommand.cxx +++ b/Source/cmAddDefinitionsCommand.cxx @@ -2,21 +2,15 @@ file Copyright.txt or https://cmake.org/licensing for details. */ #include "cmAddDefinitionsCommand.h" +#include "cmExecutionStatus.h" #include "cmMakefile.h" -class cmExecutionStatus; - -// cmAddDefinitionsCommand -bool cmAddDefinitionsCommand::InitialPass(std::vector const& args, - cmExecutionStatus&) +bool cmAddDefinitionsCommand(std::vector const& args, + cmExecutionStatus& status) { - // it is OK to have no arguments - if (args.empty()) { - return true; - } - + cmMakefile& mf = status.GetMakefile(); for (std::string const& i : args) { - this->Makefile->AddDefineFlag(i); + mf.AddDefineFlag(i); } return true; } diff --git a/Source/cmAddDefinitionsCommand.h b/Source/cmAddDefinitionsCommand.h index 0e32c83..a67f095 100644 --- a/Source/cmAddDefinitionsCommand.h +++ b/Source/cmAddDefinitionsCommand.h @@ -8,35 +8,9 @@ #include #include -#include "cm_memory.hxx" - -#include "cmCommand.h" - class cmExecutionStatus; -/** \class cmAddDefinitionsCommand - * \brief Specify a list of compiler defines - * - * cmAddDefinitionsCommand specifies a list of compiler defines. These defines - * will be added to the compile command. - */ -class cmAddDefinitionsCommand : public cmCommand -{ -public: - /** - * This is a virtual constructor for the command. - */ - std::unique_ptr Clone() override - { - return cm::make_unique(); - } - - /** - * This is called when the command is first encountered in - * the CMakeLists.txt file. - */ - bool InitialPass(std::vector const& args, - cmExecutionStatus& status) override; -}; +bool cmAddDefinitionsCommand(std::vector const& args, + cmExecutionStatus& status); #endif diff --git a/Source/cmAddDependenciesCommand.cxx b/Source/cmAddDependenciesCommand.cxx index 4956a47..0ddbda8 100644 --- a/Source/cmAddDependenciesCommand.cxx +++ b/Source/cmAddDependenciesCommand.cxx @@ -4,34 +4,33 @@ #include +#include "cmExecutionStatus.h" #include "cmMakefile.h" #include "cmMessageType.h" #include "cmRange.h" #include "cmTarget.h" -class cmExecutionStatus; - -// cmDependenciesCommand -bool cmAddDependenciesCommand::InitialPass( - std::vector const& args, cmExecutionStatus&) +bool cmAddDependenciesCommand(std::vector const& args, + cmExecutionStatus& status) { if (args.size() < 2) { - this->SetError("called with incorrect number of arguments"); + status.SetError("called with incorrect number of arguments"); return false; } + cmMakefile& mf = status.GetMakefile(); std::string const& target_name = args[0]; - if (this->Makefile->IsAlias(target_name)) { + if (mf.IsAlias(target_name)) { std::ostringstream e; e << "Cannot add target-level dependencies to alias target \"" << target_name << "\".\n"; - this->Makefile->IssueMessage(MessageType::FATAL_ERROR, e.str()); + mf.IssueMessage(MessageType::FATAL_ERROR, e.str()); } - if (cmTarget* target = this->Makefile->FindTargetToUse(target_name)) { + if (cmTarget* target = mf.FindTargetToUse(target_name)) { // skip over target_name for (std::string const& arg : cmMakeRange(args).advance(1)) { - target->AddUtility(arg, this->Makefile); + target->AddUtility(arg, &mf); } } else { std::ostringstream e; @@ -41,7 +40,7 @@ bool cmAddDependenciesCommand::InitialPass( << "by the add_executable, add_library, or add_custom_target commands. " << "If you want to add file-level dependencies see the DEPENDS option " << "of the add_custom_target and add_custom_command commands."; - this->Makefile->IssueMessage(MessageType::FATAL_ERROR, e.str()); + mf.IssueMessage(MessageType::FATAL_ERROR, e.str()); } return true; diff --git a/Source/cmAddDependenciesCommand.h b/Source/cmAddDependenciesCommand.h index ce912d3..0c60e3a 100644 --- a/Source/cmAddDependenciesCommand.h +++ b/Source/cmAddDependenciesCommand.h @@ -8,34 +8,9 @@ #include #include -#include "cm_memory.hxx" - -#include "cmCommand.h" - class cmExecutionStatus; -/** \class cmAddDependenciesCommand - * \brief Add a dependency to a target - * - * cmAddDependenciesCommand adds a dependency to a target - */ -class cmAddDependenciesCommand : public cmCommand -{ -public: - /** - * This is a virtual constructor for the command. - */ - std::unique_ptr Clone() override - { - return cm::make_unique(); - } - - /** - * This is called when the command is first encountered in - * the CMakeLists.txt file. - */ - bool InitialPass(std::vector const& args, - cmExecutionStatus& status) override; -}; +bool cmAddDependenciesCommand(std::vector const& args, + cmExecutionStatus& status); #endif diff --git a/Source/cmAddExecutableCommand.cxx b/Source/cmAddExecutableCommand.cxx index 5685fdf..59d6be3 100644 --- a/Source/cmAddExecutableCommand.cxx +++ b/Source/cmAddExecutableCommand.cxx @@ -4,22 +4,22 @@ #include +#include "cmExecutionStatus.h" #include "cmGeneratorExpression.h" #include "cmGlobalGenerator.h" #include "cmMakefile.h" #include "cmStateTypes.h" #include "cmTarget.h" -class cmExecutionStatus; - -// cmExecutableCommand -bool cmAddExecutableCommand::InitialPass(std::vector const& args, - cmExecutionStatus&) +bool cmAddExecutableCommand(std::vector const& args, + cmExecutionStatus& status) { if (args.empty()) { - this->SetError("called with incorrect number of arguments"); + status.SetError("called with incorrect number of arguments"); return false; } + + cmMakefile& mf = status.GetMakefile(); std::vector::const_iterator s = args.begin(); std::string const& exename = *s; @@ -61,59 +61,58 @@ bool cmAddExecutableCommand::InitialPass(std::vector const& args, if (nameOk && !importTarget && !isAlias) { nameOk = exename.find(':') == std::string::npos; } - if (!nameOk && - !this->Makefile->CheckCMP0037(exename, cmStateEnums::EXECUTABLE)) { + if (!nameOk && !mf.CheckCMP0037(exename, cmStateEnums::EXECUTABLE)) { return false; } // Special modifiers are not allowed with IMPORTED signature. if (importTarget && (use_win32 || use_macbundle || excludeFromAll)) { if (use_win32) { - this->SetError("may not be given WIN32 for an IMPORTED target."); + status.SetError("may not be given WIN32 for an IMPORTED target."); } else if (use_macbundle) { - this->SetError("may not be given MACOSX_BUNDLE for an IMPORTED target."); + status.SetError( + "may not be given MACOSX_BUNDLE for an IMPORTED target."); } else // if(excludeFromAll) { - this->SetError( + status.SetError( "may not be given EXCLUDE_FROM_ALL for an IMPORTED target."); } return false; } if (isAlias) { if (!cmGeneratorExpression::IsValidTargetName(exename)) { - this->SetError("Invalid name for ALIAS: " + exename); + status.SetError("Invalid name for ALIAS: " + exename); return false; } if (excludeFromAll) { - this->SetError("EXCLUDE_FROM_ALL with ALIAS makes no sense."); + status.SetError("EXCLUDE_FROM_ALL with ALIAS makes no sense."); return false; } if (importTarget || importGlobal) { - this->SetError("IMPORTED with ALIAS is not allowed."); + status.SetError("IMPORTED with ALIAS is not allowed."); return false; } if (args.size() != 3) { std::ostringstream e; e << "ALIAS requires exactly one target argument."; - this->SetError(e.str()); + status.SetError(e.str()); return false; } std::string const& aliasedName = *s; - if (this->Makefile->IsAlias(aliasedName)) { + if (mf.IsAlias(aliasedName)) { std::ostringstream e; e << "cannot create ALIAS target \"" << exename << "\" because target \"" << aliasedName << "\" is itself an ALIAS."; - this->SetError(e.str()); + status.SetError(e.str()); return false; } - cmTarget* aliasedTarget = - this->Makefile->FindTargetToUse(aliasedName, true); + cmTarget* aliasedTarget = mf.FindTargetToUse(aliasedName, true); if (!aliasedTarget) { std::ostringstream e; e << "cannot create ALIAS target \"" << exename << "\" because target \"" << aliasedName << "\" does not already exist."; - this->SetError(e.str()); + status.SetError(e.str()); return false; } cmStateEnums::TargetType type = aliasedTarget->GetType(); @@ -121,7 +120,7 @@ bool cmAddExecutableCommand::InitialPass(std::vector const& args, std::ostringstream e; e << "cannot create ALIAS target \"" << exename << "\" because target \"" << aliasedName << "\" is not an executable."; - this->SetError(e.str()); + status.SetError(e.str()); return false; } if (aliasedTarget->IsImported() && @@ -129,42 +128,40 @@ bool cmAddExecutableCommand::InitialPass(std::vector const& args, std::ostringstream e; e << "cannot create ALIAS target \"" << exename << "\" because target \"" << aliasedName << "\" is imported but not globally visible."; - this->SetError(e.str()); + status.SetError(e.str()); return false; } - this->Makefile->AddAlias(exename, aliasedName); + mf.AddAlias(exename, aliasedName); return true; } // Handle imported target creation. if (importTarget) { // Make sure the target does not already exist. - if (this->Makefile->FindTargetToUse(exename)) { + if (mf.FindTargetToUse(exename)) { std::ostringstream e; e << "cannot create imported target \"" << exename << "\" because another target with the same name already exists."; - this->SetError(e.str()); + status.SetError(e.str()); return false; } // Create the imported target. - this->Makefile->AddImportedTarget(exename, cmStateEnums::EXECUTABLE, - importGlobal); + mf.AddImportedTarget(exename, cmStateEnums::EXECUTABLE, importGlobal); return true; } // Enforce name uniqueness. { std::string msg; - if (!this->Makefile->EnforceUniqueName(exename, msg)) { - this->SetError(msg); + if (!mf.EnforceUniqueName(exename, msg)) { + status.SetError(msg); return false; } } std::vector srclists(s, args.end()); - cmTarget* tgt = - this->Makefile->AddExecutable(exename, srclists, excludeFromAll); + cmTarget* tgt = mf.AddExecutable(exename, srclists, excludeFromAll); if (use_win32) { tgt->SetProperty("WIN32_EXECUTABLE", "ON"); } diff --git a/Source/cmAddExecutableCommand.h b/Source/cmAddExecutableCommand.h index ec57c3f..f7bc273 100644 --- a/Source/cmAddExecutableCommand.h +++ b/Source/cmAddExecutableCommand.h @@ -8,35 +8,9 @@ #include #include -#include "cm_memory.hxx" - -#include "cmCommand.h" - class cmExecutionStatus; -/** \class cmExecutablesCommand - * \brief Defines a list of executables to build. - * - * cmExecutablesCommand defines a list of executable (i.e., test) - * programs to create. - */ -class cmAddExecutableCommand : public cmCommand -{ -public: - /** - * This is a virtual constructor for the command. - */ - std::unique_ptr Clone() override - { - return cm::make_unique(); - } - - /** - * This is called when the command is first encountered in - * the CMakeLists.txt file. - */ - bool InitialPass(std::vector const& args, - cmExecutionStatus& status) override; -}; +bool cmAddExecutableCommand(std::vector const& args, + cmExecutionStatus& status); #endif diff --git a/Source/cmAddLibraryCommand.cxx b/Source/cmAddLibraryCommand.cxx index ad12e89..626b7c9 100644 --- a/Source/cmAddLibraryCommand.cxx +++ b/Source/cmAddLibraryCommand.cxx @@ -5,6 +5,7 @@ #include #include "cmAlgorithms.h" +#include "cmExecutionStatus.h" #include "cmGeneratorExpression.h" #include "cmGlobalGenerator.h" #include "cmMakefile.h" @@ -14,21 +15,19 @@ #include "cmSystemTools.h" #include "cmTarget.h" -class cmExecutionStatus; - -// cmLibraryCommand -bool cmAddLibraryCommand::InitialPass(std::vector const& args, - cmExecutionStatus&) +bool cmAddLibraryCommand(std::vector const& args, + cmExecutionStatus& status) { if (args.empty()) { - this->SetError("called with incorrect number of arguments"); + status.SetError("called with incorrect number of arguments"); return false; } + + cmMakefile& mf = status.GetMakefile(); // Library type defaults to value of BUILD_SHARED_LIBS, if it exists, // otherwise it defaults to static library. cmStateEnums::TargetType type = cmStateEnums::SHARED_LIBRARY; - if (cmSystemTools::IsOff( - this->Makefile->GetDefinition("BUILD_SHARED_LIBS"))) { + if (cmSystemTools::IsOff(mf.GetDefinition("BUILD_SHARED_LIBS"))) { type = cmStateEnums::STATIC_LIBRARY; } bool excludeFromAll = false; @@ -52,7 +51,7 @@ bool cmAddLibraryCommand::InitialPass(std::vector const& args, if (type == cmStateEnums::INTERFACE_LIBRARY) { std::ostringstream e; e << "INTERFACE library specified with conflicting STATIC type."; - this->SetError(e.str()); + status.SetError(e.str()); return false; } ++s; @@ -62,7 +61,7 @@ bool cmAddLibraryCommand::InitialPass(std::vector const& args, if (type == cmStateEnums::INTERFACE_LIBRARY) { std::ostringstream e; e << "INTERFACE library specified with conflicting SHARED type."; - this->SetError(e.str()); + status.SetError(e.str()); return false; } ++s; @@ -72,7 +71,7 @@ bool cmAddLibraryCommand::InitialPass(std::vector const& args, if (type == cmStateEnums::INTERFACE_LIBRARY) { std::ostringstream e; e << "INTERFACE library specified with conflicting MODULE type."; - this->SetError(e.str()); + status.SetError(e.str()); return false; } ++s; @@ -82,7 +81,7 @@ bool cmAddLibraryCommand::InitialPass(std::vector const& args, if (type == cmStateEnums::INTERFACE_LIBRARY) { std::ostringstream e; e << "INTERFACE library specified with conflicting OBJECT type."; - this->SetError(e.str()); + status.SetError(e.str()); return false; } ++s; @@ -92,7 +91,7 @@ bool cmAddLibraryCommand::InitialPass(std::vector const& args, if (type == cmStateEnums::INTERFACE_LIBRARY) { std::ostringstream e; e << "INTERFACE library specified with conflicting UNKNOWN type."; - this->SetError(e.str()); + status.SetError(e.str()); return false; } ++s; @@ -102,7 +101,7 @@ bool cmAddLibraryCommand::InitialPass(std::vector const& args, if (type == cmStateEnums::INTERFACE_LIBRARY) { std::ostringstream e; e << "INTERFACE library specified with conflicting ALIAS type."; - this->SetError(e.str()); + status.SetError(e.str()); return false; } ++s; @@ -111,19 +110,19 @@ bool cmAddLibraryCommand::InitialPass(std::vector const& args, if (haveSpecifiedType) { std::ostringstream e; e << "INTERFACE library specified with conflicting/multiple types."; - this->SetError(e.str()); + status.SetError(e.str()); return false; } if (isAlias) { std::ostringstream e; e << "INTERFACE library specified with conflicting ALIAS type."; - this->SetError(e.str()); + status.SetError(e.str()); return false; } if (excludeFromAll) { std::ostringstream e; e << "INTERFACE library may not be used with EXCLUDE_FROM_ALL."; - this->SetError(e.str()); + status.SetError(e.str()); return false; } ++s; @@ -133,7 +132,7 @@ bool cmAddLibraryCommand::InitialPass(std::vector const& args, if (type == cmStateEnums::INTERFACE_LIBRARY) { std::ostringstream e; e << "INTERFACE library may not be used with EXCLUDE_FROM_ALL."; - this->SetError(e.str()); + status.SetError(e.str()); return false; } ++s; @@ -147,7 +146,7 @@ bool cmAddLibraryCommand::InitialPass(std::vector const& args, } else if (type == cmStateEnums::INTERFACE_LIBRARY && *s == "GLOBAL") { std::ostringstream e; e << "GLOBAL option may only be used with IMPORTED libraries."; - this->SetError(e.str()); + status.SetError(e.str()); return false; } else { break; @@ -158,13 +157,13 @@ bool cmAddLibraryCommand::InitialPass(std::vector const& args, if (s != args.end()) { std::ostringstream e; e << "INTERFACE library requires no source arguments."; - this->SetError(e.str()); + status.SetError(e.str()); return false; } if (importGlobal && !importTarget) { std::ostringstream e; e << "INTERFACE library specified as GLOBAL, but not as IMPORTED."; - this->SetError(e.str()); + status.SetError(e.str()); return false; } } @@ -175,47 +174,46 @@ bool cmAddLibraryCommand::InitialPass(std::vector const& args, if (nameOk && !importTarget && !isAlias) { nameOk = libName.find(':') == std::string::npos; } - if (!nameOk && !this->Makefile->CheckCMP0037(libName, type)) { + if (!nameOk && !mf.CheckCMP0037(libName, type)) { return false; } if (isAlias) { if (!cmGeneratorExpression::IsValidTargetName(libName)) { - this->SetError("Invalid name for ALIAS: " + libName); + status.SetError("Invalid name for ALIAS: " + libName); return false; } if (excludeFromAll) { - this->SetError("EXCLUDE_FROM_ALL with ALIAS makes no sense."); + status.SetError("EXCLUDE_FROM_ALL with ALIAS makes no sense."); return false; } if (importTarget || importGlobal) { - this->SetError("IMPORTED with ALIAS is not allowed."); + status.SetError("IMPORTED with ALIAS is not allowed."); return false; } if (args.size() != 3) { std::ostringstream e; e << "ALIAS requires exactly one target argument."; - this->SetError(e.str()); + status.SetError(e.str()); return false; } std::string const& aliasedName = *s; - if (this->Makefile->IsAlias(aliasedName)) { + if (mf.IsAlias(aliasedName)) { std::ostringstream e; e << "cannot create ALIAS target \"" << libName << "\" because target \"" << aliasedName << "\" is itself an ALIAS."; - this->SetError(e.str()); + status.SetError(e.str()); return false; } - cmTarget* aliasedTarget = - this->Makefile->FindTargetToUse(aliasedName, true); + cmTarget* aliasedTarget = mf.FindTargetToUse(aliasedName, true); if (!aliasedTarget) { std::ostringstream e; e << "cannot create ALIAS target \"" << libName << "\" because target \"" << aliasedName << "\" does not already " "exist."; - this->SetError(e.str()); + status.SetError(e.str()); return false; } cmStateEnums::TargetType aliasedType = aliasedTarget->GetType(); @@ -229,7 +227,7 @@ bool cmAddLibraryCommand::InitialPass(std::vector const& args, std::ostringstream e; e << "cannot create ALIAS target \"" << libName << "\" because target \"" << aliasedName << "\" is not a library."; - this->SetError(e.str()); + status.SetError(e.str()); return false; } if (aliasedTarget->IsImported() && @@ -237,15 +235,15 @@ bool cmAddLibraryCommand::InitialPass(std::vector const& args, std::ostringstream e; e << "cannot create ALIAS target \"" << libName << "\" because target \"" << aliasedName << "\" is imported but not globally visible."; - this->SetError(e.str()); + status.SetError(e.str()); return false; } - this->Makefile->AddAlias(libName, aliasedName); + mf.AddAlias(libName, aliasedName); return true; } if (importTarget && excludeFromAll) { - this->SetError("excludeFromAll with IMPORTED target makes no sense."); + status.SetError("excludeFromAll with IMPORTED target makes no sense."); return false; } @@ -255,14 +253,13 @@ bool cmAddLibraryCommand::InitialPass(std::vector const& args, yet its linker language. */ if ((type == cmStateEnums::SHARED_LIBRARY || type == cmStateEnums::MODULE_LIBRARY) && - !this->Makefile->GetState()->GetGlobalPropertyAsBool( - "TARGET_SUPPORTS_SHARED_LIBS")) { + !mf.GetState()->GetGlobalPropertyAsBool("TARGET_SUPPORTS_SHARED_LIBS")) { std::ostringstream w; w << "ADD_LIBRARY called with " << (type == cmStateEnums::SHARED_LIBRARY ? "SHARED" : "MODULE") << " option but the target platform does not support dynamic linking. " "Building a STATIC library instead. This may lead to problems."; - this->Makefile->IssueMessage(MessageType::AUTHOR_WARNING, w.str()); + mf.IssueMessage(MessageType::AUTHOR_WARNING, w.str()); type = cmStateEnums::STATIC_LIBRARY; } @@ -270,14 +267,13 @@ bool cmAddLibraryCommand::InitialPass(std::vector const& args, if (importTarget) { // The IMPORTED signature requires a type to be specified explicitly. if (!haveSpecifiedType) { - this->SetError("called with IMPORTED argument but no library type."); + status.SetError("called with IMPORTED argument but no library type."); return false; } if (type == cmStateEnums::OBJECT_LIBRARY) { std::string reason; - if (!this->Makefile->GetGlobalGenerator()->HasKnownObjectFileLocation( - &reason)) { - this->Makefile->IssueMessage( + if (!mf.GetGlobalGenerator()->HasKnownObjectFileLocation(&reason)) { + mf.IssueMessage( MessageType::FATAL_ERROR, "The OBJECT library type may not be used for IMPORTED libraries" + reason + "."); @@ -288,28 +284,28 @@ bool cmAddLibraryCommand::InitialPass(std::vector const& args, if (!cmGeneratorExpression::IsValidTargetName(libName)) { std::ostringstream e; e << "Invalid name for IMPORTED INTERFACE library target: " << libName; - this->SetError(e.str()); + status.SetError(e.str()); return false; } } // Make sure the target does not already exist. - if (this->Makefile->FindTargetToUse(libName)) { + if (mf.FindTargetToUse(libName)) { std::ostringstream e; e << "cannot create imported target \"" << libName << "\" because another target with the same name already exists."; - this->SetError(e.str()); + status.SetError(e.str()); return false; } // Create the imported target. - this->Makefile->AddImportedTarget(libName, type, importGlobal); + mf.AddImportedTarget(libName, type, importGlobal); return true; } // A non-imported target may not have UNKNOWN type. if (type == cmStateEnums::UNKNOWN_LIBRARY) { - this->Makefile->IssueMessage( + mf.IssueMessage( MessageType::FATAL_ERROR, "The UNKNOWN library type may be used only for IMPORTED libraries."); return true; @@ -318,8 +314,8 @@ bool cmAddLibraryCommand::InitialPass(std::vector const& args, // Enforce name uniqueness. { std::string msg; - if (!this->Makefile->EnforceUniqueName(libName, msg)) { - this->SetError(msg); + if (!mf.EnforceUniqueName(libName, msg)) { + status.SetError(msg); return false; } } @@ -331,17 +327,17 @@ bool cmAddLibraryCommand::InitialPass(std::vector const& args, libName.find("::") != std::string::npos) { std::ostringstream e; e << "Invalid name for INTERFACE library target: " << libName; - this->SetError(e.str()); + status.SetError(e.str()); return false; } - this->Makefile->AddLibrary(libName, type, srclists, excludeFromAll); + mf.AddLibrary(libName, type, srclists, excludeFromAll); return true; } cmAppend(srclists, s, args.end()); - this->Makefile->AddLibrary(libName, type, srclists, excludeFromAll); + mf.AddLibrary(libName, type, srclists, excludeFromAll); return true; } diff --git a/Source/cmAddLibraryCommand.h b/Source/cmAddLibraryCommand.h index 56dab41..609449c 100644 --- a/Source/cmAddLibraryCommand.h +++ b/Source/cmAddLibraryCommand.h @@ -8,35 +8,9 @@ #include #include -#include "cm_memory.hxx" - -#include "cmCommand.h" - class cmExecutionStatus; -/** \class cmLibrarysCommand - * \brief Defines a list of executables to build. - * - * cmLibrarysCommand defines a list of executable (i.e., test) - * programs to create. - */ -class cmAddLibraryCommand : public cmCommand -{ -public: - /** - * This is a virtual constructor for the command. - */ - std::unique_ptr Clone() override - { - return cm::make_unique(); - } - - /** - * This is called when the command is first encountered in - * the CMakeLists.txt file. - */ - bool InitialPass(std::vector const& args, - cmExecutionStatus& status) override; -}; +bool cmAddLibraryCommand(std::vector const& args, + cmExecutionStatus& status); #endif diff --git a/Source/cmAddLinkOptionsCommand.cxx b/Source/cmAddLinkOptionsCommand.cxx index 10ebd12..7ed31bd 100644 --- a/Source/cmAddLinkOptionsCommand.cxx +++ b/Source/cmAddLinkOptionsCommand.cxx @@ -2,19 +2,15 @@ file Copyright.txt or https://cmake.org/licensing for details. */ #include "cmAddLinkOptionsCommand.h" +#include "cmExecutionStatus.h" #include "cmMakefile.h" -class cmExecutionStatus; - -bool cmAddLinkOptionsCommand::InitialPass(std::vector const& args, - cmExecutionStatus&) +bool cmAddLinkOptionsCommand(std::vector const& args, + cmExecutionStatus& status) { - if (args.empty()) { - return true; - } - + cmMakefile& mf = status.GetMakefile(); for (std::string const& i : args) { - this->Makefile->AddLinkOption(i); + mf.AddLinkOption(i); } return true; } diff --git a/Source/cmAddLinkOptionsCommand.h b/Source/cmAddLinkOptionsCommand.h index 8e46be6..466fc32 100644 --- a/Source/cmAddLinkOptionsCommand.h +++ b/Source/cmAddLinkOptionsCommand.h @@ -8,29 +8,9 @@ #include #include -#include "cm_memory.hxx" - -#include "cmCommand.h" - class cmExecutionStatus; -class cmAddLinkOptionsCommand : public cmCommand -{ -public: - /** - * This is a virtual constructor for the command. - */ - std::unique_ptr Clone() override - { - return cm::make_unique(); - } - - /** - * This is called when the command is first encountered in - * the CMakeLists.txt file. - */ - bool InitialPass(std::vector const& args, - cmExecutionStatus& status) override; -}; +bool cmAddLinkOptionsCommand(std::vector const& args, + cmExecutionStatus& status); #endif diff --git a/Source/cmAddSubDirectoryCommand.cxx b/Source/cmAddSubDirectoryCommand.cxx index 7947188..50c682f 100644 --- a/Source/cmAddSubDirectoryCommand.cxx +++ b/Source/cmAddSubDirectoryCommand.cxx @@ -5,21 +5,20 @@ #include #include +#include "cmExecutionStatus.h" #include "cmMakefile.h" #include "cmRange.h" #include "cmSystemTools.h" -class cmExecutionStatus; - -// cmAddSubDirectoryCommand -bool cmAddSubDirectoryCommand::InitialPass( - std::vector const& args, cmExecutionStatus&) +bool cmAddSubDirectoryCommand(std::vector const& args, + cmExecutionStatus& status) { if (args.empty()) { - this->SetError("called with incorrect number of arguments"); + status.SetError("called with incorrect number of arguments"); return false; } + cmMakefile& mf = status.GetMakefile(); // store the binpath std::string const& srcArg = args.front(); std::string binArg; @@ -35,7 +34,7 @@ bool cmAddSubDirectoryCommand::InitialPass( if (binArg.empty()) { binArg = arg; } else { - this->SetError("called with incorrect number of arguments"); + status.SetError("called with incorrect number of arguments"); return false; } } @@ -46,7 +45,7 @@ bool cmAddSubDirectoryCommand::InitialPass( if (cmSystemTools::FileIsFullPath(srcArg)) { srcPath = srcArg; } else { - srcPath = this->Makefile->GetCurrentSourceDirectory(); + srcPath = mf.GetCurrentSourceDirectory(); srcPath += "/"; srcPath += srcArg; } @@ -54,7 +53,7 @@ bool cmAddSubDirectoryCommand::InitialPass( std::string error = "given source \""; error += srcArg; error += "\" which is not an existing directory."; - this->SetError(error); + status.SetError(error); return false; } srcPath = cmSystemTools::CollapseFullPath(srcPath); @@ -65,22 +64,22 @@ bool cmAddSubDirectoryCommand::InitialPass( // No binary directory was specified. If the source directory is // not a subdirectory of the current directory then it is an // error. - if (!cmSystemTools::IsSubDirectory( - srcPath, this->Makefile->GetCurrentSourceDirectory())) { + if (!cmSystemTools::IsSubDirectory(srcPath, + mf.GetCurrentSourceDirectory())) { std::ostringstream e; e << "not given a binary directory but the given source directory " << "\"" << srcPath << "\" is not a subdirectory of \"" - << this->Makefile->GetCurrentSourceDirectory() << "\". " + << mf.GetCurrentSourceDirectory() << "\". " << "When specifying an out-of-tree source a binary directory " << "must be explicitly specified."; - this->SetError(e.str()); + status.SetError(e.str()); return false; } // Remove the CurrentDirectory from the srcPath and replace it // with the CurrentOutputDirectory. - const std::string& src = this->Makefile->GetCurrentSourceDirectory(); - const std::string& bin = this->Makefile->GetCurrentBinaryDirectory(); + const std::string& src = mf.GetCurrentSourceDirectory(); + const std::string& bin = mf.GetCurrentBinaryDirectory(); size_t srcLen = src.length(); size_t binLen = bin.length(); if (srcLen > 0 && src.back() == '/') { @@ -96,7 +95,7 @@ bool cmAddSubDirectoryCommand::InitialPass( if (cmSystemTools::FileIsFullPath(binArg)) { binPath = binArg; } else { - binPath = this->Makefile->GetCurrentBinaryDirectory(); + binPath = mf.GetCurrentBinaryDirectory(); binPath += "/"; binPath += binArg; } @@ -104,7 +103,7 @@ bool cmAddSubDirectoryCommand::InitialPass( binPath = cmSystemTools::CollapseFullPath(binPath); // Add the subdirectory using the computed full paths. - this->Makefile->AddSubDirectory(srcPath, binPath, excludeFromAll, true); + mf.AddSubDirectory(srcPath, binPath, excludeFromAll, true); return true; } diff --git a/Source/cmAddSubDirectoryCommand.h b/Source/cmAddSubDirectoryCommand.h index 664334e..87da840 100644 --- a/Source/cmAddSubDirectoryCommand.h +++ b/Source/cmAddSubDirectoryCommand.h @@ -8,36 +8,9 @@ #include #include -#include "cm_memory.hxx" - -#include "cmCommand.h" - class cmExecutionStatus; -/** \class cmAddSubDirectoryCommand - * \brief Specify a subdirectory to build - * - * cmAddSubDirectoryCommand specifies a subdirectory to process - * by CMake. CMake will descend - * into the specified source directory and process any CMakeLists.txt found. - */ -class cmAddSubDirectoryCommand : public cmCommand -{ -public: - /** - * This is a virtual constructor for the command. - */ - std::unique_ptr Clone() override - { - return cm::make_unique(); - } - - /** - * This is called when the command is first encountered in - * the CMakeLists.txt file. - */ - bool InitialPass(std::vector const& args, - cmExecutionStatus& status) override; -}; +bool cmAddSubDirectoryCommand(std::vector const& args, + cmExecutionStatus& status); #endif diff --git a/Source/cmAddTestCommand.cxx b/Source/cmAddTestCommand.cxx index b0c462b..7904bf5 100644 --- a/Source/cmAddTestCommand.cxx +++ b/Source/cmAddTestCommand.cxx @@ -4,34 +4,36 @@ #include +#include "cmExecutionStatus.h" #include "cmMakefile.h" #include "cmTest.h" #include "cmTestGenerator.h" -class cmExecutionStatus; +static bool cmAddTestCommandHandleNameMode( + std::vector const& args, cmExecutionStatus& status); -// cmExecutableCommand -bool cmAddTestCommand::InitialPass(std::vector const& args, - cmExecutionStatus&) +bool cmAddTestCommand(std::vector const& args, + cmExecutionStatus& status) { if (!args.empty() && args[0] == "NAME") { - return this->HandleNameMode(args); + return cmAddTestCommandHandleNameMode(args, status); } // First argument is the name of the test Second argument is the name of // the executable to run (a target or external program) Remaining arguments // are the arguments to pass to the executable if (args.size() < 2) { - this->SetError("called with incorrect number of arguments"); + status.SetError("called with incorrect number of arguments"); return false; } + cmMakefile& mf = status.GetMakefile(); // Collect the command with arguments. std::vector command(args.begin() + 1, args.end()); // Create the test but add a generator only the first time it is // seen. This preserves behavior from before test generators. - cmTest* test = this->Makefile->GetTest(args[0]); + cmTest* test = mf.GetTest(args[0]); if (test) { // If the test was already added by a new-style signature do not // allow it to be duplicated. @@ -39,20 +41,21 @@ bool cmAddTestCommand::InitialPass(std::vector const& args, std::ostringstream e; e << " given test name \"" << args[0] << "\" which already exists in this directory."; - this->SetError(e.str()); + status.SetError(e.str()); return false; } } else { - test = this->Makefile->CreateTest(args[0]); + test = mf.CreateTest(args[0]); test->SetOldStyle(true); - this->Makefile->AddTestGenerator(new cmTestGenerator(test)); + mf.AddTestGenerator(new cmTestGenerator(test)); } test->SetCommand(command); return true; } -bool cmAddTestCommand::HandleNameMode(std::vector const& args) +bool cmAddTestCommandHandleNameMode(std::vector const& args, + cmExecutionStatus& status) { std::string name; std::vector configurations; @@ -73,25 +76,25 @@ bool cmAddTestCommand::HandleNameMode(std::vector const& args) for (unsigned int i = 1; i < args.size(); ++i) { if (args[i] == "COMMAND") { if (!command.empty()) { - this->SetError(" may be given at most one COMMAND."); + status.SetError(" may be given at most one COMMAND."); return false; } doing = DoingCommand; } else if (args[i] == "CONFIGURATIONS") { if (!configurations.empty()) { - this->SetError(" may be given at most one set of CONFIGURATIONS."); + status.SetError(" may be given at most one set of CONFIGURATIONS."); return false; } doing = DoingConfigs; } else if (args[i] == "WORKING_DIRECTORY") { if (!working_directory.empty()) { - this->SetError(" may be given at most one WORKING_DIRECTORY."); + status.SetError(" may be given at most one WORKING_DIRECTORY."); return false; } doing = DoingWorkingDirectory; } else if (args[i] == "COMMAND_EXPAND_LISTS") { if (command_expand_lists) { - this->SetError(" may be given at most one COMMAND_EXPAND_LISTS."); + status.SetError(" may be given at most one COMMAND_EXPAND_LISTS."); return false; } command_expand_lists = true; @@ -109,41 +112,43 @@ bool cmAddTestCommand::HandleNameMode(std::vector const& args) } else { std::ostringstream e; e << " given unknown argument:\n " << args[i] << "\n"; - this->SetError(e.str()); + status.SetError(e.str()); return false; } } // Require a test name. if (name.empty()) { - this->SetError(" must be given non-empty NAME."); + status.SetError(" must be given non-empty NAME."); return false; } // Require a command. if (command.empty()) { - this->SetError(" must be given non-empty COMMAND."); + status.SetError(" must be given non-empty COMMAND."); return false; } + cmMakefile& mf = status.GetMakefile(); + // Require a unique test name within the directory. - if (this->Makefile->GetTest(name)) { + if (mf.GetTest(name)) { std::ostringstream e; e << " given test NAME \"" << name << "\" which already exists in this directory."; - this->SetError(e.str()); + status.SetError(e.str()); return false; } // Add the test. - cmTest* test = this->Makefile->CreateTest(name); + cmTest* test = mf.CreateTest(name); test->SetOldStyle(false); test->SetCommand(command); if (!working_directory.empty()) { test->SetProperty("WORKING_DIRECTORY", working_directory.c_str()); } test->SetCommandExpandLists(command_expand_lists); - this->Makefile->AddTestGenerator(new cmTestGenerator(test, configurations)); + mf.AddTestGenerator(new cmTestGenerator(test, configurations)); return true; } diff --git a/Source/cmAddTestCommand.h b/Source/cmAddTestCommand.h index 3d37d2b..5877547 100644 --- a/Source/cmAddTestCommand.h +++ b/Source/cmAddTestCommand.h @@ -8,37 +8,9 @@ #include #include -#include "cm_memory.hxx" - -#include "cmCommand.h" - class cmExecutionStatus; -/** \class cmAddTestCommand - * \brief Add a test to the lists of tests to run. - * - * cmAddTestCommand adds a test to the list of tests to run . - */ -class cmAddTestCommand : public cmCommand -{ -public: - /** - * This is a virtual constructor for the command. - */ - std::unique_ptr Clone() override - { - return cm::make_unique(); - } - - /** - * This is called when the command is first encountered in - * the CMakeLists.txt file. - */ - bool InitialPass(std::vector const& args, - cmExecutionStatus& status) override; - -private: - bool HandleNameMode(std::vector const& args); -}; +bool cmAddTestCommand(std::vector const& args, + cmExecutionStatus& status); #endif diff --git a/Source/cmAuxSourceDirectoryCommand.cxx b/Source/cmAuxSourceDirectoryCommand.cxx index 45c6411..83199b4 100644 --- a/Source/cmAuxSourceDirectoryCommand.cxx +++ b/Source/cmAuxSourceDirectoryCommand.cxx @@ -7,28 +7,27 @@ #include #include +#include "cmExecutionStatus.h" #include "cmMakefile.h" #include "cmSourceFile.h" #include "cmStringAlgorithms.h" #include "cmSystemTools.h" #include "cmake.h" -class cmExecutionStatus; - -// cmAuxSourceDirectoryCommand -bool cmAuxSourceDirectoryCommand::InitialPass( - std::vector const& args, cmExecutionStatus&) +bool cmAuxSourceDirectoryCommand(std::vector const& args, + cmExecutionStatus& status) { if (args.size() != 2) { - this->SetError("called with incorrect number of arguments"); + status.SetError("called with incorrect number of arguments"); return false; } + cmMakefile& mf = status.GetMakefile(); std::string sourceListValue; std::string const& templateDirectory = args[0]; std::string tdir; if (!cmSystemTools::FileIsFullPath(templateDirectory)) { - tdir = this->Makefile->GetCurrentSourceDirectory(); + tdir = mf.GetCurrentSourceDirectory(); tdir += "/"; tdir += templateDirectory; } else { @@ -36,7 +35,7 @@ bool cmAuxSourceDirectoryCommand::InitialPass( } // was the list already populated - const char* def = this->Makefile->GetDefinition(args[1]); + const char* def = mf.GetDefinition(args[1]); if (def) { sourceListValue = def; } @@ -55,14 +54,14 @@ bool cmAuxSourceDirectoryCommand::InitialPass( std::string ext = file.substr(dotpos + 1); std::string base = file.substr(0, dotpos); // Process only source files - auto cm = this->Makefile->GetCMakeInstance(); + auto cm = mf.GetCMakeInstance(); if (!base.empty() && cm->IsSourceExtension(ext)) { std::string fullname = templateDirectory; fullname += "/"; fullname += file; // add the file as a class file so // depends can be done - cmSourceFile* sf = this->Makefile->GetOrCreateSource(fullname); + cmSourceFile* sf = mf.GetOrCreateSource(fullname); sf->SetProperty("ABSTRACT", "0"); files.push_back(std::move(fullname)); } @@ -74,6 +73,6 @@ bool cmAuxSourceDirectoryCommand::InitialPass( sourceListValue += ";"; } sourceListValue += cmJoin(files, ";"); - this->Makefile->AddDefinition(args[1], sourceListValue); + mf.AddDefinition(args[1], sourceListValue); return true; } diff --git a/Source/cmAuxSourceDirectoryCommand.h b/Source/cmAuxSourceDirectoryCommand.h index 973a464..ae26092 100644 --- a/Source/cmAuxSourceDirectoryCommand.h +++ b/Source/cmAuxSourceDirectoryCommand.h @@ -8,38 +8,9 @@ #include #include -#include "cm_memory.hxx" - -#include "cmCommand.h" - class cmExecutionStatus; -/** \class cmAuxSourceDirectoryCommand - * \brief Specify auxiliary source code directories. - * - * cmAuxSourceDirectoryCommand specifies source code directories - * that must be built as part of this build process. This directories - * are not recursively processed like the SUBDIR command (cmSubdirCommand). - * A side effect of this command is to create a subdirectory in the build - * directory structure. - */ -class cmAuxSourceDirectoryCommand : public cmCommand -{ -public: - /** - * This is a virtual constructor for the command. - */ - std::unique_ptr Clone() override - { - return cm::make_unique(); - } - - /** - * This is called when the command is first encountered in - * the CMakeLists.txt file. - */ - bool InitialPass(std::vector const& args, - cmExecutionStatus& status) override; -}; +bool cmAuxSourceDirectoryCommand(std::vector const& args, + cmExecutionStatus& status); #endif diff --git a/Source/cmCommands.cxx b/Source/cmCommands.cxx index f351ff8..9e3341d 100644 --- a/Source/cmCommands.cxx +++ b/Source/cmCommands.cxx @@ -233,21 +233,14 @@ void GetScriptingCommands(cmState* state) void GetProjectCommands(cmState* state) { - state->AddBuiltinCommand("add_custom_command", - cm::make_unique()); - state->AddBuiltinCommand("add_custom_target", - cm::make_unique()); - state->AddBuiltinCommand("add_definitions", - cm::make_unique()); - state->AddBuiltinCommand("add_dependencies", - cm::make_unique()); - state->AddBuiltinCommand("add_executable", - cm::make_unique()); - state->AddBuiltinCommand("add_library", - cm::make_unique()); - state->AddBuiltinCommand("add_subdirectory", - cm::make_unique()); - state->AddBuiltinCommand("add_test", cm::make_unique()); + state->AddBuiltinCommand("add_custom_command", cmAddCustomCommandCommand); + state->AddBuiltinCommand("add_custom_target", cmAddCustomTargetCommand); + state->AddBuiltinCommand("add_definitions", cmAddDefinitionsCommand); + state->AddBuiltinCommand("add_dependencies", cmAddDependenciesCommand); + state->AddBuiltinCommand("add_executable", cmAddExecutableCommand); + state->AddBuiltinCommand("add_library", cmAddLibraryCommand); + state->AddBuiltinCommand("add_subdirectory", cmAddSubDirectoryCommand); + state->AddBuiltinCommand("add_test", cmAddTestCommand); state->AddBuiltinCommand("build_command", cm::make_unique()); state->AddBuiltinCommand("create_test_sourcelist", cm::make_unique()); @@ -303,11 +296,10 @@ void GetProjectCommands(cmState* state) #if defined(CMAKE_BUILD_WITH_CMAKE) state->AddBuiltinCommand("add_compile_definitions", - cm::make_unique()); - state->AddBuiltinCommand("add_compile_options", - cm::make_unique()); + cmAddCompileDefinitionsCommand); + state->AddBuiltinCommand("add_compile_options", cmAddCompileOptionsCommand); state->AddBuiltinCommand("aux_source_directory", - cm::make_unique()); + cmAuxSourceDirectoryCommand); state->AddBuiltinCommand("export", cm::make_unique()); state->AddBuiltinCommand("fltk_wrap_ui", cm::make_unique()); @@ -316,8 +308,7 @@ void GetProjectCommands(cmState* state) cm::make_unique()); state->AddBuiltinCommand("install_programs", cm::make_unique()); - state->AddBuiltinCommand("add_link_options", - cm::make_unique()); + state->AddBuiltinCommand("add_link_options", cmAddLinkOptionsCommand); state->AddBuiltinCommand("link_libraries", cm::make_unique()); state->AddBuiltinCommand("target_link_options", https://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=a233e4e7d9c157cae0098762d8a7add463fb3492 commit a233e4e7d9c157cae0098762d8a7add463fb3492 Author: Robert Maynard AuthorDate: Tue Aug 6 15:04:59 2019 -0400 Commit: Robert Maynard CommitDate: Tue Aug 6 15:44:15 2019 -0400 CUDA: Compilers can now state they don't require a device linking step diff --git a/Help/prop_tgt/CUDA_RESOLVE_DEVICE_SYMBOLS.rst b/Help/prop_tgt/CUDA_RESOLVE_DEVICE_SYMBOLS.rst index ef74ae2..dae960f 100644 --- a/Help/prop_tgt/CUDA_RESOLVE_DEVICE_SYMBOLS.rst +++ b/Help/prop_tgt/CUDA_RESOLVE_DEVICE_SYMBOLS.rst @@ -1,12 +1,16 @@ CUDA_RESOLVE_DEVICE_SYMBOLS --------------------------- -CUDA only: Enables device linking for the specific library target - -If set this will enable device linking on the library target. Normally -device linking is deferred until a shared library or executable is generated, -allowing for multiple static libraries to resolve device symbols at the same -time when they are used by a shared library or executable. +CUDA only: Enables device linking for the specific library target where +required. + +If set, this will tell the required compilers to enable device linking +on the library target. Device linking is an additional link step +required by some CUDA compilers when :prop_tgt:`CUDA_SEPARABLE_COMPILATION` is +enabled. Normally device linking is deferred until a shared library or +executable is generated, allowing for multiple static libraries to resolve +device symbols at the same time when they are used by a shared library or +executable. By default static library targets have this property is disabled, while shared, module, and executable targets have this property enabled. diff --git a/Modules/CMakeCUDAInformation.cmake b/Modules/CMakeCUDAInformation.cmake index 43ae989..b0d80d1 100644 --- a/Modules/CMakeCUDAInformation.cmake +++ b/Modules/CMakeCUDAInformation.cmake @@ -171,7 +171,8 @@ if(NOT CMAKE_CUDA_LINK_EXECUTABLE) " -o ${__IMPLICT_LINKS}") endif() -if(CMAKE_CUDA_COMPILER_VERSION VERSION_GREATER_EQUAL "8.0.0") +if( CMAKE_CUDA_COMPILER_ID STREQUAL "NVIDIA" AND + CMAKE_CUDA_COMPILER_VERSION VERSION_GREATER_EQUAL "8.0.0") set(_CMAKE_CUDA_EXTRA_DEVICE_LINK_FLAGS "-Wno-deprecated-gpu-targets") else() set(_CMAKE_CUDA_EXTRA_DEVICE_LINK_FLAGS "") diff --git a/Modules/Compiler/NVIDIA-CUDA.cmake b/Modules/Compiler/NVIDIA-CUDA.cmake index c0ccb71..b59deda 100644 --- a/Modules/Compiler/NVIDIA-CUDA.cmake +++ b/Modules/Compiler/NVIDIA-CUDA.cmake @@ -1,3 +1,4 @@ +set(CMAKE_CUDA_COMPILER_HAS_DEVICE_LINK_PHASE True) set(CMAKE_CUDA_VERBOSE_FLAG "-v") set(CMAKE_CUDA_VERBOSE_COMPILE_FLAG "-Xcompiler=-v") diff --git a/Source/cmLinkLineDeviceComputer.cxx b/Source/cmLinkLineDeviceComputer.cxx index 656907a..7cacb24 100644 --- a/Source/cmLinkLineDeviceComputer.cxx +++ b/Source/cmLinkLineDeviceComputer.cxx @@ -13,6 +13,7 @@ #include "cmGeneratorTarget.h" #include "cmGlobalGenerator.h" #include "cmLocalGenerator.h" +#include "cmMakefile.h" #include "cmStateDirectory.h" #include "cmStateSnapshot.h" #include "cmStateTypes.h" @@ -156,6 +157,10 @@ bool requireDeviceLinking(cmGeneratorTarget& target, cmLocalGenerator& lg, return false; } + if (!lg.GetMakefile()->IsOn("CMAKE_CUDA_COMPILER_HAS_DEVICE_LINK_PHASE")) { + return false; + } + if (const char* resolveDeviceSymbols = target.GetProperty("CUDA_RESOLVE_DEVICE_SYMBOLS")) { // If CUDA_RESOLVE_DEVICE_SYMBOLS has been explicitly set we need https://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=8f1d22c2d9922e55565c3cd51b91bb3a6c33ffdc commit 8f1d22c2d9922e55565c3cd51b91bb3a6c33ffdc Author: Robert Maynard AuthorDate: Wed Jul 31 20:11:08 2019 -0400 Commit: Robert Maynard CommitDate: Tue Aug 6 09:55:40 2019 -0400 CUDA: Support CMAKE_CUDA_RESOLVE_DEVICE_SYMBOLS global variable diff --git a/Help/manual/cmake-variables.7.rst b/Help/manual/cmake-variables.7.rst index 432d7fc..4e5140e 100644 --- a/Help/manual/cmake-variables.7.rst +++ b/Help/manual/cmake-variables.7.rst @@ -353,6 +353,7 @@ Variables that Control the Build /variable/CMAKE_COMPILE_PDB_OUTPUT_DIRECTORY_CONFIG /variable/CMAKE_CONFIG_POSTFIX /variable/CMAKE_CUDA_SEPARABLE_COMPILATION + /variable/CMAKE_CUDA_RESOLVE_DEVICE_SYMBOLS /variable/CMAKE_DEBUG_POSTFIX /variable/CMAKE_ENABLE_EXPORTS /variable/CMAKE_EXE_LINKER_FLAGS diff --git a/Help/release/dev/cuda-CMAKE_CUDA_RESOLVE_DEVICE_SYMBOLS.rst b/Help/release/dev/cuda-CMAKE_CUDA_RESOLVE_DEVICE_SYMBOLS.rst new file mode 100644 index 0000000..f21fddf --- /dev/null +++ b/Help/release/dev/cuda-CMAKE_CUDA_RESOLVE_DEVICE_SYMBOLS.rst @@ -0,0 +1,6 @@ +cuda-CMAKE_CUDA_RESOLVE_DEVICE_SYMBOLS +-------------------------------------- + +* Variable :variable:`CMAKE_CUDA_RESOLVE_DEVICE_SYMBOLS` has been + introduced to optionally initialize the + :prop_tgt:`CUDA_RESOLVE_DEVICE_SYMBOLS` target property. diff --git a/Help/variable/CMAKE_CUDA_RESOLVE_DEVICE_SYMBOLS.rst b/Help/variable/CMAKE_CUDA_RESOLVE_DEVICE_SYMBOLS.rst new file mode 100644 index 0000000..fc835cd --- /dev/null +++ b/Help/variable/CMAKE_CUDA_RESOLVE_DEVICE_SYMBOLS.rst @@ -0,0 +1,6 @@ +CMAKE_CUDA_RESOLVE_DEVICE_SYMBOLS +--------------------------------- + +Default value for :prop_tgt:`CUDA_RESOLVE_DEVICE_SYMBOLS` target +property. This variable is used to initialize the property on each target as +it is created. diff --git a/Source/cmTarget.cxx b/Source/cmTarget.cxx index beccfce..96cfe5e 100644 --- a/Source/cmTarget.cxx +++ b/Source/cmTarget.cxx @@ -342,6 +342,7 @@ cmTarget::cmTarget(std::string const& name, cmStateEnums::TargetType type, initProp("CUDA_EXTENSIONS"); initProp("CUDA_COMPILER_LAUNCHER"); initProp("CUDA_SEPARABLE_COMPILATION"); + initProp("CUDA_RESOLVE_DEVICE_SYMBOLS"); initProp("LINK_SEARCH_START_STATIC"); initProp("LINK_SEARCH_END_STATIC"); initProp("FOLDER"); diff --git a/Tests/CudaOnly/DontResolveDeviceSymbols/CMakeLists.txt b/Tests/CudaOnly/DontResolveDeviceSymbols/CMakeLists.txt index 6190089..6e3697f 100644 --- a/Tests/CudaOnly/DontResolveDeviceSymbols/CMakeLists.txt +++ b/Tests/CudaOnly/DontResolveDeviceSymbols/CMakeLists.txt @@ -27,12 +27,12 @@ endif() string(APPEND CMAKE_CUDA_FLAGS " -gencode arch=compute_30,code=[compute_30] -gencode arch=compute_50,code=\\\"compute_50\\\"") set(CMAKE_CXX_STANDARD 11) set(CMAKE_CUDA_STANDARD 11) +set(CMAKE_CUDA_RESOLVE_DEVICE_SYMBOLS OFF) add_library(CUDANoDeviceResolve SHARED file1.cu) set_target_properties(CUDANoDeviceResolve PROPERTIES CUDA_SEPARABLE_COMPILATION ON - CUDA_RESOLVE_DEVICE_SYMBOLS OFF POSITION_INDEPENDENT_CODE ON) if(MSVC) target_link_options(CUDANoDeviceResolve PRIVATE "/FORCE:UNRESOLVED") ----------------------------------------------------------------------- Summary of changes: Help/manual/cmake-variables.7.rst | 1 + Help/prop_tgt/CUDA_RESOLVE_DEVICE_SYMBOLS.rst | 16 ++- .../dev/cuda-CMAKE_CUDA_RESOLVE_DEVICE_SYMBOLS.rst | 6 + .../variable/CMAKE_CUDA_RESOLVE_DEVICE_SYMBOLS.rst | 6 + Modules/CMakeCUDAInformation.cmake | 3 +- Modules/Compiler/NVIDIA-CUDA.cmake | 1 + Source/CMakeLists.txt | 3 - Source/CPack/cpack.cxx | 4 +- Source/CTest/cmCTestRunTest.cxx | 2 +- Source/CTest/cmCTestScriptHandler.cxx | 2 +- Source/cmAddCompileDefinitionsCommand.cxx | 14 +- Source/cmAddCompileDefinitionsCommand.h | 24 +--- Source/cmAddCompileOptionsCommand.cxx | 14 +- Source/cmAddCompileOptionsCommand.h | 24 +--- Source/cmAddCustomCommandCommand.cxx | 84 ++++++------ Source/cmAddCustomCommandCommand.h | 33 +---- Source/cmAddCustomTargetCommand.cxx | 42 +++--- Source/cmAddCustomTargetCommand.h | 31 +---- Source/cmAddDefinitionsCommand.cxx | 16 +-- Source/cmAddDefinitionsCommand.h | 30 +---- Source/cmAddDependenciesCommand.cxx | 21 ++- Source/cmAddDependenciesCommand.h | 29 +---- Source/cmAddExecutableCommand.cxx | 59 ++++----- Source/cmAddExecutableCommand.h | 30 +---- Source/cmAddLibraryCommand.cxx | 100 +++++++-------- Source/cmAddLibraryCommand.h | 30 +---- Source/cmAddLinkOptionsCommand.cxx | 14 +- Source/cmAddLinkOptionsCommand.h | 24 +--- Source/cmAddSubDirectoryCommand.cxx | 33 +++-- Source/cmAddSubDirectoryCommand.h | 31 +---- Source/cmAddTestCommand.cxx | 49 +++---- Source/cmAddTestCommand.h | 32 +---- Source/cmArchiveWrite.h | 2 +- Source/cmAuxSourceDirectoryCommand.cxx | 21 ++- Source/cmAuxSourceDirectoryCommand.h | 33 +---- Source/cmCTest.cxx | 2 +- Source/cmCommands.cxx | 39 +++--- Source/cmFileCommand.cxx | 12 +- Source/cmGeneratedFileStream.cxx | 8 +- Source/cmGeneratorTarget.cxx | 2 +- Source/cmGlobalGenerator.cxx | 20 +-- Source/cmGlobalGenerator.h | 8 +- Source/cmGlobalVisualStudio7Generator.cxx | 2 +- Source/cmGlobalVisualStudio7Generator.h | 2 +- Source/cmGlobalXCodeGenerator.cxx | 6 +- Source/cmIncludeGuardCommand.cxx | 2 +- Source/cmInstallCommand.cxx | 2 +- Source/cmInstallExportGenerator.cxx | 4 +- Source/cmLinkLineDeviceComputer.cxx | 5 + Source/cmLocalGenerator.cxx | 142 +++++++-------------- Source/cmLocalGenerator.h | 2 +- Source/cmLocalUnixMakefileGenerator3.cxx | 4 +- Source/cmMakefile.cxx | 32 ++--- Source/cmMakefile.h | 8 +- Source/cmMakefileExecutableTargetGenerator.cxx | 2 +- Source/cmMakefileLibraryTargetGenerator.cxx | 2 +- Source/cmMessenger.cxx | 4 +- Source/cmRuntimeDependencyArchive.cxx | 4 +- Source/cmStringAlgorithms.cxx | 14 ++ Source/cmStringAlgorithms.h | 3 + Source/cmStringCommand.cxx | 4 +- Source/cmSystemTools.cxx | 28 ++-- Source/cmSystemTools.h | 2 +- Source/cmTarget.cxx | 1 + Source/cmTimestamp.cxx | 2 +- Source/cmUVHandlePtr.cxx | 6 +- Source/cmUnsetCommand.cxx | 2 +- Source/cm_codecvt.hxx | 2 +- Source/cmake.cxx | 46 +++---- Source/cmake.h | 8 +- Source/cmakemain.cxx | 18 +-- Source/cmcmd.cxx | 24 ++-- Source/ctest.cxx | 4 +- Tests/CMakeLib/testStringAlgorithms.cxx | 23 ++++ .../DontResolveDeviceSymbols/CMakeLists.txt | 2 +- bootstrap | 4 +- 76 files changed, 518 insertions(+), 853 deletions(-) create mode 100644 Help/release/dev/cuda-CMAKE_CUDA_RESOLVE_DEVICE_SYMBOLS.rst create mode 100644 Help/variable/CMAKE_CUDA_RESOLVE_DEVICE_SYMBOLS.rst hooks/post-receive -- CMake From kwrobot at kitware.com Tue Aug 13 10:10:45 2019 From: kwrobot at kitware.com (Kitware Robot) Date: Tue, 13 Aug 2019 10:10:45 -0400 (EDT) Subject: [Cmake-commits] CMake branch, master, updated. v3.15.2-643-gfb56ac9 Message-ID: <20190813141045.70082E36D1@public.kitware.com> This is an automated email from the git hooks/post-receive script. It was generated because a ref change was pushed to the repository containing the project "CMake". The branch, master has been updated via fb56ac9209f368712284a3705c0d52ba6f55b6ed (commit) via 39d2ce4a71c7c337060bdbe68e3ac20178789300 (commit) via 689be6235e5be32e8ee8e37801dde1fb1c5add2a (commit) via 6bc77966ad7cce3f12d35e64bcda4be56094b2ca (commit) via 5729580376da53c5665e4e3a043834ad6c7ed706 (commit) from 7099d113aed4789848a69869befb068e6fadafcc (commit) Those revisions listed above that are new to this repository have not appeared on any other notification email; so we list those revisions in full, below. - Log ----------------------------------------------------------------- https://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=fb56ac9209f368712284a3705c0d52ba6f55b6ed commit fb56ac9209f368712284a3705c0d52ba6f55b6ed Merge: 39d2ce4 6bc7796 Author: Kyle Edwards AuthorDate: Tue Aug 13 14:06:44 2019 +0000 Commit: Kitware Robot CommitDate: Tue Aug 13 10:07:09 2019 -0400 Merge topic 'retry-directory-delete' 6bc77966ad Retry removing directories on Windows 5729580376 Use registry setting for removal retry count and delay Acked-by: Kitware Robot Merge-request: !3667 https://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=39d2ce4a71c7c337060bdbe68e3ac20178789300 commit 39d2ce4a71c7c337060bdbe68e3ac20178789300 Merge: 7099d11 689be62 Author: Kyle Edwards AuthorDate: Tue Aug 13 14:05:26 2019 +0000 Commit: Kitware Robot CommitDate: Tue Aug 13 10:05:40 2019 -0400 Merge topic 'per-language-link-library-flag' 689be6235e Generator: support per-language link library flag Acked-by: Kitware Robot Merge-request: !3668 https://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=689be6235e5be32e8ee8e37801dde1fb1c5add2a commit 689be6235e5be32e8ee8e37801dde1fb1c5add2a Author: Saleem Abdulrasool AuthorDate: Thu Aug 8 09:31:42 2019 -0700 Commit: Saleem Abdulrasool CommitDate: Fri Aug 9 08:16:29 2019 -0700 Generator: support per-language link library flag This enables the use of MSVC and Swift on Windows in a single project. MSVC uses no flag to indicate linked libraries while Swift uses `-l`. Add support for a language specific link library flag which takes precedence over the global `CMAKE_LINK_LIBRARY_FLAG` which preserves compatibility with earlier releases. diff --git a/Help/manual/cmake-variables.7.rst b/Help/manual/cmake-variables.7.rst index 432d7fc..22ea877 100644 --- a/Help/manual/cmake-variables.7.rst +++ b/Help/manual/cmake-variables.7.rst @@ -383,6 +383,7 @@ Variables that Control the Build /variable/CMAKE_LANG_CPPCHECK /variable/CMAKE_LANG_CPPLINT /variable/CMAKE_LANG_INCLUDE_WHAT_YOU_USE + /variable/CMAKE_LANG_LINK_LIBRARY_FLAG /variable/CMAKE_LANG_VISIBILITY_PRESET /variable/CMAKE_LIBRARY_OUTPUT_DIRECTORY /variable/CMAKE_LIBRARY_OUTPUT_DIRECTORY_CONFIG diff --git a/Help/release/dev/per-lang-link-library-flag.rst b/Help/release/dev/per-lang-link-library-flag.rst new file mode 100644 index 0000000..ca1181d --- /dev/null +++ b/Help/release/dev/per-lang-link-library-flag.rst @@ -0,0 +1,7 @@ +per-lang-link-library-flag +-------------------------- + +* The new :variable:`CMAKE__LINK_LIBRARY_FLAG` flag allows you to now + control the flag used to specify linking to a library on a per-language basis. + This is useful for mixed-language projects where the different drivers may use + different flags. diff --git a/Help/variable/CMAKE_LANG_LINK_LIBRARY_FLAG.rst b/Help/variable/CMAKE_LANG_LINK_LIBRARY_FLAG.rst new file mode 100644 index 0000000..d7bb0d8 --- /dev/null +++ b/Help/variable/CMAKE_LANG_LINK_LIBRARY_FLAG.rst @@ -0,0 +1,7 @@ +CMAKE__LINK_LIBRARY_FLAG +------------------------------ + +Flag to be used to link a library into a shared library or executable. + +This flag will be used to specify a library to link to a shared library or an +executable for the specific language. On most compilers this is ``-l``. diff --git a/Modules/CMakeSwiftInformation.cmake b/Modules/CMakeSwiftInformation.cmake index 54e441c..cb161a6 100644 --- a/Modules/CMakeSwiftInformation.cmake +++ b/Modules/CMakeSwiftInformation.cmake @@ -36,6 +36,7 @@ set(CMAKE_Swift_DEFINE_FLAG -D) set(CMAKE_Swift_FRAMEWORK_SEARCH_FLAG "-F ") set(CMAKE_Swift_LIBRARY_PATH_FLAG "-L ") set(CMAKE_Swift_LIBRARY_PATH_TERMINATOR "") +set(CMAKE_Swift_LINK_LIBRARY_FLAG "-l") set(CMAKE_Swift_LINKER_WRAPPER_FLAG "-Xlinker" " ") set(CMAKE_Swift_RESPONSE_FILE_LINK_FLAG @) diff --git a/Source/cmComputeLinkInformation.cxx b/Source/cmComputeLinkInformation.cxx index 4aa18f2..0741f8b 100644 --- a/Source/cmComputeLinkInformation.cxx +++ b/Source/cmComputeLinkInformation.cxx @@ -285,8 +285,13 @@ cmComputeLinkInformation::cmComputeLinkInformation( } // Get options needed to link libraries. - this->LibLinkFlag = - this->Makefile->GetSafeDefinition("CMAKE_LINK_LIBRARY_FLAG"); + if (const char* flag = this->Makefile->GetDefinition( + "CMAKE_" + this->LinkLanguage + "_LINK_LIBRARY_FLAG")) { + this->LibLinkFlag = flag; + } else { + this->LibLinkFlag = + this->Makefile->GetSafeDefinition("CMAKE_LINK_LIBRARY_FLAG"); + } this->LibLinkFileFlag = this->Makefile->GetSafeDefinition("CMAKE_LINK_LIBRARY_FILE_FLAG"); this->LibLinkSuffix = https://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=6bc77966ad7cce3f12d35e64bcda4be56094b2ca commit 6bc77966ad7cce3f12d35e64bcda4be56094b2ca Author: Kasper Laudrup AuthorDate: Thu Aug 8 15:30:17 2019 +0200 Commit: Kasper Laudrup CommitDate: Thu Aug 8 15:59:02 2019 +0200 Retry removing directories on Windows On Windows removing a directory can fail if other processes have a handle to it. This has been "solved" with a retry hack when moving directories, so use the same hack when removing directories. diff --git a/Source/cmFileCommand.cxx b/Source/cmFileCommand.cxx index 22f0d1f..ef26a99 100644 --- a/Source/cmFileCommand.cxx +++ b/Source/cmFileCommand.cxx @@ -1422,7 +1422,7 @@ bool cmFileCommand::HandleRemove(std::vector const& args, if (cmSystemTools::FileIsDirectory(fileName) && !cmSystemTools::FileIsSymlink(fileName) && recurse) { - cmSystemTools::RemoveADirectory(fileName); + cmSystemTools::RepeatedRemoveDirectory(fileName); } else { cmSystemTools::RemoveFile(fileName); } https://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=5729580376da53c5665e4e3a043834ad6c7ed706 commit 5729580376da53c5665e4e3a043834ad6c7ed706 Author: Kasper Laudrup AuthorDate: Thu Aug 8 15:28:51 2019 +0200 Commit: Kasper Laudrup CommitDate: Thu Aug 8 15:59:02 2019 +0200 Use registry setting for removal retry count and delay Instead of hardcoding the amount of retries and the time to sleep between them when removing directories on Windows, use the setting potentially present in the registry instead. This setting is already used when retrying moving directories. diff --git a/Source/cmSystemTools.cxx b/Source/cmSystemTools.cxx index 7baf5ed..a168b33 100644 --- a/Source/cmSystemTools.cxx +++ b/Source/cmSystemTools.cxx @@ -2838,14 +2838,20 @@ bool cmSystemTools::CheckRPath(std::string const& file, bool cmSystemTools::RepeatedRemoveDirectory(const std::string& dir) { +#ifdef _WIN32 // Windows sometimes locks files temporarily so try a few times. - for (int i = 0; i < 10; ++i) { + WindowsFileRetry retry = cmSystemTools::GetWindowsFileRetry(); + + for (unsigned int i = 0; i < retry.Count; ++i) { if (cmSystemTools::RemoveADirectory(dir)) { return true; } - cmSystemTools::Delay(100); + cmSystemTools::Delay(retry.Delay); } return false; +#else + return cmSystemTools::RemoveADirectory(dir); +#endif } bool cmSystemTools::StringToLong(const char* str, long* value) ----------------------------------------------------------------------- Summary of changes: Help/manual/cmake-variables.7.rst | 1 + Help/release/dev/per-lang-link-library-flag.rst | 7 +++++++ Help/variable/CMAKE_LANG_LINK_LIBRARY_FLAG.rst | 7 +++++++ Modules/CMakeSwiftInformation.cmake | 1 + Source/cmComputeLinkInformation.cxx | 9 +++++++-- Source/cmFileCommand.cxx | 2 +- Source/cmSystemTools.cxx | 10 ++++++++-- 7 files changed, 32 insertions(+), 5 deletions(-) create mode 100644 Help/release/dev/per-lang-link-library-flag.rst create mode 100644 Help/variable/CMAKE_LANG_LINK_LIBRARY_FLAG.rst hooks/post-receive -- CMake From kwrobot at kitware.com Wed Aug 14 00:00:26 2019 From: kwrobot at kitware.com (Kitware Robot) Date: Wed, 14 Aug 2019 00:00:26 -0400 (EDT) Subject: [Cmake-commits] CMake branch, master, updated. v3.15.2-644-g0312b6d Message-ID: <20190814040026.8119911040D@public.kitware.com> This is an automated email from the git hooks/post-receive script. It was generated because a ref change was pushed to the repository containing the project "CMake". The branch, master has been updated via 0312b6d522cfa0b72ef755a1bee9785383a9a6a4 (commit) from fb56ac9209f368712284a3705c0d52ba6f55b6ed (commit) Those revisions listed above that are new to this repository have not appeared on any other notification email; so we list those revisions in full, below. - Log ----------------------------------------------------------------- https://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=0312b6d522cfa0b72ef755a1bee9785383a9a6a4 commit 0312b6d522cfa0b72ef755a1bee9785383a9a6a4 Author: Kitware Robot AuthorDate: Wed Aug 14 00:01:07 2019 -0400 Commit: Kitware Robot CommitDate: Wed Aug 14 00:01:07 2019 -0400 CMake Nightly Date Stamp diff --git a/Source/CMakeVersion.cmake b/Source/CMakeVersion.cmake index 40a4ee6..ef3fd9c 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 15) -set(CMake_VERSION_PATCH 20190813) +set(CMake_VERSION_PATCH 20190814) #set(CMake_VERSION_RC 0) set(CMake_VERSION_IS_DIRTY 0) ----------------------------------------------------------------------- Summary of changes: Source/CMakeVersion.cmake | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) hooks/post-receive -- CMake From kwrobot at kitware.com Wed Aug 14 23:59:52 2019 From: kwrobot at kitware.com (Kitware Robot) Date: Wed, 14 Aug 2019 23:59:52 -0400 (EDT) Subject: [Cmake-commits] CMake branch, master, updated. v3.15.2-645-g789e585 Message-ID: <20190815035952.EDD14E5515@public.kitware.com> This is an automated email from the git hooks/post-receive script. It was generated because a ref change was pushed to the repository containing the project "CMake". The branch, master has been updated via 789e585ad9417bcc5bc4ebb68550ae3024742048 (commit) from 0312b6d522cfa0b72ef755a1bee9785383a9a6a4 (commit) Those revisions listed above that are new to this repository have not appeared on any other notification email; so we list those revisions in full, below. - Log ----------------------------------------------------------------- https://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=789e585ad9417bcc5bc4ebb68550ae3024742048 commit 789e585ad9417bcc5bc4ebb68550ae3024742048 Author: Kitware Robot AuthorDate: Thu Aug 15 00:01:06 2019 -0400 Commit: Kitware Robot CommitDate: Thu Aug 15 00:01:06 2019 -0400 CMake Nightly Date Stamp diff --git a/Source/CMakeVersion.cmake b/Source/CMakeVersion.cmake index ef3fd9c..7888789 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 15) -set(CMake_VERSION_PATCH 20190814) +set(CMake_VERSION_PATCH 20190815) #set(CMake_VERSION_RC 0) set(CMake_VERSION_IS_DIRTY 0) ----------------------------------------------------------------------- Summary of changes: Source/CMakeVersion.cmake | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) hooks/post-receive -- CMake From kwrobot at kitware.com Thu Aug 15 23:59:20 2019 From: kwrobot at kitware.com (Kitware Robot) Date: Thu, 15 Aug 2019 23:59:20 -0400 (EDT) Subject: [Cmake-commits] CMake branch, master, updated. v3.15.2-646-g6f1781c Message-ID: <20190816035920.1233D11E481@public.kitware.com> This is an automated email from the git hooks/post-receive script. It was generated because a ref change was pushed to the repository containing the project "CMake". The branch, master has been updated via 6f1781c63ad58c3c84987dce7eee36668ed2ba57 (commit) from 789e585ad9417bcc5bc4ebb68550ae3024742048 (commit) Those revisions listed above that are new to this repository have not appeared on any other notification email; so we list those revisions in full, below. - Log ----------------------------------------------------------------- https://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=6f1781c63ad58c3c84987dce7eee36668ed2ba57 commit 6f1781c63ad58c3c84987dce7eee36668ed2ba57 Author: Kitware Robot AuthorDate: Fri Aug 16 00:01:06 2019 -0400 Commit: Kitware Robot CommitDate: Fri Aug 16 00:01:06 2019 -0400 CMake Nightly Date Stamp diff --git a/Source/CMakeVersion.cmake b/Source/CMakeVersion.cmake index 7888789..53c1559 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 15) -set(CMake_VERSION_PATCH 20190815) +set(CMake_VERSION_PATCH 20190816) #set(CMake_VERSION_RC 0) set(CMake_VERSION_IS_DIRTY 0) ----------------------------------------------------------------------- Summary of changes: Source/CMakeVersion.cmake | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) hooks/post-receive -- CMake From kwrobot at kitware.com Fri Aug 16 14:58:58 2019 From: kwrobot at kitware.com (Kitware Robot) Date: Fri, 16 Aug 2019 14:58:58 -0400 (EDT) Subject: [Cmake-commits] CMake branch, master, updated. v3.15.2-652-g2beed5a Message-ID: <20190816185858.9B091FB5A4@public.kitware.com> This is an automated email from the git hooks/post-receive script. It was generated because a ref change was pushed to the repository containing the project "CMake". The branch, master has been updated via 2beed5a4ef66f415f4efa327a8c479395d262e52 (commit) via dcf2beb7dec757b7e28eba43fb7f2d5498bded39 (commit) via 2f6495e24e57cd4a03f38e615cc60177e89afb96 (commit) via f4f3c68926492e5660c4e66d5cdcf2298619c1b9 (commit) via ff42dec89143c3b8027c9768c2910ca270ddd951 (commit) via 935fbe0b0454163678bc4ef19e1bee95a7a31b4d (commit) from 6f1781c63ad58c3c84987dce7eee36668ed2ba57 (commit) Those revisions listed above that are new to this repository have not appeared on any other notification email; so we list those revisions in full, below. - Log ----------------------------------------------------------------- https://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=2beed5a4ef66f415f4efa327a8c479395d262e52 commit 2beed5a4ef66f415f4efa327a8c479395d262e52 Merge: dcf2beb 2f6495e Author: Kyle Edwards AuthorDate: Fri Aug 16 18:50:52 2019 +0000 Commit: Kitware Robot CommitDate: Fri Aug 16 14:51:03 2019 -0400 Merge topic 'cmExpandList' 2f6495e24e cmSystemTools: Remove ExpandListArgument methods f4f3c68926 Source code: Use cmExpandList instead of cmSystemTools::ExpandListArgument ff42dec891 cmStringAlgorithms: Add cmExpandList functions Acked-by: Kitware Robot Merge-request: !3682 https://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=dcf2beb7dec757b7e28eba43fb7f2d5498bded39 commit dcf2beb7dec757b7e28eba43fb7f2d5498bded39 Merge: 6f1781c 935fbe0 Author: Kyle Edwards AuthorDate: Fri Aug 16 18:49:13 2019 +0000 Commit: Kitware Robot CommitDate: Fri Aug 16 14:49:28 2019 -0400 Merge topic 'cmStringAlgorithms_ulong' 935fbe0b04 cmStringAlgorithms: Add cmStrToLong and cmStrToULong Acked-by: Kitware Robot Merge-request: !3681 diff --cc Source/cmSystemTools.cxx index ee60f16,f1a652d..9341f83 --- a/Source/cmSystemTools.cxx +++ b/Source/cmSystemTools.cxx @@@ -2846,36 -2843,11 +2846,14 @@@ bool cmSystemTools::RepeatedRemoveDirec if (cmSystemTools::RemoveADirectory(dir)) { return true; } - cmSystemTools::Delay(100); + cmSystemTools::Delay(retry.Delay); } return false; +#else + return cmSystemTools::RemoveADirectory(dir); +#endif } - bool cmSystemTools::StringToLong(const char* str, long* value) - { - errno = 0; - char* endp; - *value = strtol(str, &endp, 10); - return (*endp == '\0') && (endp != str) && (errno == 0); - } - - bool cmSystemTools::StringToULong(const char* str, unsigned long* value) - { - errno = 0; - char* endp; - while (isspace(*str)) { - ++str; - } - if (*str == '-') { - return false; - } - *value = strtoul(str, &endp, 10); - return (*endp == '\0') && (endp != str) && (errno == 0); - } - std::string cmSystemTools::EncodeURL(std::string const& in, bool escapeSlashes) { std::string out; https://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=2f6495e24e57cd4a03f38e615cc60177e89afb96 commit 2f6495e24e57cd4a03f38e615cc60177e89afb96 Author: Sebastian Holtermann AuthorDate: Sun Aug 11 12:06:19 2019 +0200 Commit: Sebastian Holtermann CommitDate: Wed Aug 14 16:33:20 2019 +0200 cmSystemTools: Remove ExpandListArgument methods diff --git a/Source/cmSystemTools.cxx b/Source/cmSystemTools.cxx index ee60f16..7d9b3b9 100644 --- a/Source/cmSystemTools.cxx +++ b/Source/cmSystemTools.cxx @@ -1089,79 +1089,6 @@ void cmSystemTools::GlobDirs(const std::string& path, } } -void cmSystemTools::ExpandListArgument(cm::string_view arg, - std::vector& argsOut, - bool emptyArgs) -{ - // If argument is empty, it is an empty list. - if (!emptyArgs && arg.empty()) { - return; - } - - // if there are no ; in the name then just copy the current string - if (arg.find(';') == cm::string_view::npos) { - argsOut.emplace_back(arg); - return; - } - - std::string newArg; - // Break the string at non-escaped semicolons not nested in []. - int squareNesting = 0; - cm::string_view::iterator last = arg.begin(); - cm::string_view::iterator const cend = arg.end(); - for (cm::string_view::iterator c = last; c != cend; ++c) { - switch (*c) { - case '\\': { - // We only want to allow escaping of semicolons. Other - // escapes should not be processed here. - cm::string_view::iterator cnext = c + 1; - if ((cnext != cend) && *cnext == ';') { - newArg.append(last, c); - // Skip over the escape character - last = cnext; - c = cnext; - } - } break; - case '[': { - ++squareNesting; - } break; - case ']': { - --squareNesting; - } break; - case ';': { - // Break the string here if we are not nested inside square - // brackets. - if (squareNesting == 0) { - newArg.append(last, c); - // Skip over the semicolon - last = c + 1; - if (!newArg.empty() || emptyArgs) { - // Add the last argument if the string is not empty. - argsOut.push_back(newArg); - newArg.clear(); - } - } - } break; - default: { - // Just append this character. - } break; - } - } - newArg.append(last, cend); - if (!newArg.empty() || emptyArgs) { - // Add the last argument if the string is not empty. - argsOut.push_back(std::move(newArg)); - } -} - -std::vector cmSystemTools::ExpandedListArgument( - cm::string_view arg, bool emptyArgs) -{ - std::vector argsOut; - ExpandListArgument(arg, argsOut, emptyArgs); - return argsOut; -} - bool cmSystemTools::SimpleGlob(const std::string& glob, std::vector& files, int type /* = 0 */) diff --git a/Source/cmSystemTools.h b/Source/cmSystemTools.h index 99610eb..c713783 100644 --- a/Source/cmSystemTools.h +++ b/Source/cmSystemTools.h @@ -29,49 +29,6 @@ public: typedef cmProcessOutput::Encoding Encoding; /** - * Expand the ; separated string @a arg into multiple arguments. - * All found arguments are appended to @a argsOut. - */ - static void ExpandListArgument(cm::string_view arg, - std::vector& argsOut, - bool emptyArgs = false); - - /** - * Expand out any arguments in the string range [@a first, @a last) that have - * ; separated strings into multiple arguments. All found arguments are - * appended to @a argsOut. - */ - template - static void ExpandLists(InputIt first, InputIt last, - std::vector& argsOut) - { - for (; first != last; ++first) { - cmExpandList(*first, argsOut); - } - } - - /** - * Same as ExpandListArgument but a new vector is created containing - * the expanded arguments from the string @a arg. - */ - static std::vector ExpandedListArgument(cm::string_view arg, - bool emptyArgs = false); - - /** - * Same as ExpandList but a new vector is created containing the expanded - * versions of all arguments in the string range [@a first, @a last). - */ - template - static std::vector ExpandedLists(InputIt first, InputIt last) - { - std::vector argsOut; - for (; first != last; ++first) { - ExpandListArgument(*first, argsOut); - } - return argsOut; - } - - /** * Look for and replace registry values in a string */ static void ExpandRegistryValues(std::string& source, https://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=f4f3c68926492e5660c4e66d5cdcf2298619c1b9 commit f4f3c68926492e5660c4e66d5cdcf2298619c1b9 Author: Sebastian Holtermann AuthorDate: Sun Aug 11 11:56:59 2019 +0200 Commit: Sebastian Holtermann CommitDate: Wed Aug 14 16:33:20 2019 +0200 Source code: Use cmExpandList instead of cmSystemTools::ExpandListArgument diff --git a/Source/CPack/IFW/cmCPackIFWCommon.cxx b/Source/CPack/IFW/cmCPackIFWCommon.cxx index 1e72641..5b1ccbd 100644 --- a/Source/CPack/IFW/cmCPackIFWCommon.cxx +++ b/Source/CPack/IFW/cmCPackIFWCommon.cxx @@ -5,6 +5,7 @@ #include "cmCPackGenerator.h" #include "cmCPackIFWGenerator.h" #include "cmCPackLog.h" // IWYU pragma: keep +#include "cmStringAlgorithms.h" #include "cmSystemTools.h" #include "cmTimestamp.h" #include "cmVersionConfig.h" @@ -78,7 +79,7 @@ void cmCPackIFWCommon::ExpandListArgument( const std::string& arg, std::map& argsOut) { std::vector args; - cmSystemTools::ExpandListArgument(arg, args, false); + cmExpandList(arg, args, false); if (args.empty()) { return; } @@ -100,7 +101,7 @@ void cmCPackIFWCommon::ExpandListArgument( const std::string& arg, std::multimap& argsOut) { std::vector args; - cmSystemTools::ExpandListArgument(arg, args, false); + cmExpandList(arg, args, false); if (args.empty()) { return; } diff --git a/Source/CPack/IFW/cmCPackIFWGenerator.cxx b/Source/CPack/IFW/cmCPackIFWGenerator.cxx index c1b6eea..76eb760 100644 --- a/Source/CPack/IFW/cmCPackIFWGenerator.cxx +++ b/Source/CPack/IFW/cmCPackIFWGenerator.cxx @@ -11,6 +11,7 @@ #include "cmCPackLog.h" // IWYU pragma: keep #include "cmDuration.h" #include "cmGeneratedFileStream.h" +#include "cmStringAlgorithms.h" #include "cmSystemTools.h" #include @@ -292,14 +293,14 @@ int cmCPackIFWGenerator::InitializeInternal() // Additional packages dirs this->PkgsDirsVector.clear(); if (const char* dirs = this->GetOption("CPACK_IFW_PACKAGES_DIRECTORIES")) { - cmSystemTools::ExpandListArgument(dirs, this->PkgsDirsVector); + cmExpandList(dirs, this->PkgsDirsVector); } // Additional repositories dirs this->RepoDirsVector.clear(); if (const char* dirs = this->GetOption("CPACK_IFW_REPOSITORIES_DIRECTORIES")) { - cmSystemTools::ExpandListArgument(dirs, this->RepoDirsVector); + cmExpandList(dirs, this->RepoDirsVector); } // Installer @@ -317,7 +318,7 @@ int cmCPackIFWGenerator::InitializeInternal() // Repositories if (const char* RepoAllStr = this->GetOption("CPACK_IFW_REPOSITORIES_ALL")) { std::vector RepoAllVector; - cmSystemTools::ExpandListArgument(RepoAllStr, RepoAllVector); + cmExpandList(RepoAllStr, RepoAllVector); for (std::string const& r : RepoAllVector) { this->GetRepository(r); } diff --git a/Source/CPack/IFW/cmCPackIFWInstaller.cxx b/Source/CPack/IFW/cmCPackIFWInstaller.cxx index f130e05..5313dd0 100644 --- a/Source/CPack/IFW/cmCPackIFWInstaller.cxx +++ b/Source/CPack/IFW/cmCPackIFWInstaller.cxx @@ -245,8 +245,7 @@ void cmCPackIFWInstaller::ConfigureFromOptions() if (const char* optIFW_PACKAGE_RESOURCES = this->GetOption("CPACK_IFW_PACKAGE_RESOURCES")) { this->Resources.clear(); - cmSystemTools::ExpandListArgument(optIFW_PACKAGE_RESOURCES, - this->Resources); + cmExpandList(optIFW_PACKAGE_RESOURCES, this->Resources); } } diff --git a/Source/CPack/IFW/cmCPackIFWPackage.cxx b/Source/CPack/IFW/cmCPackIFWPackage.cxx index a1a52b1..7407c49 100644 --- a/Source/CPack/IFW/cmCPackIFWPackage.cxx +++ b/Source/CPack/IFW/cmCPackIFWPackage.cxx @@ -8,6 +8,7 @@ #include "cmCPackIFWInstaller.h" #include "cmCPackLog.h" // IWYU pragma: keep #include "cmGeneratedFileStream.h" +#include "cmStringAlgorithms.h" #include "cmSystemTools.h" #include "cmTimestamp.h" #include "cmXMLWriter.h" @@ -196,7 +197,7 @@ int cmCPackIFWPackage::ConfigureFromComponent(cmCPackComponent* component) // User interfaces if (const char* option = this->GetOption(prefix + "USER_INTERFACES")) { this->UserInterfaces.clear(); - cmSystemTools::ExpandListArgument(option, this->UserInterfaces); + cmExpandList(option, this->UserInterfaces); } // CMake dependencies @@ -209,7 +210,7 @@ int cmCPackIFWPackage::ConfigureFromComponent(cmCPackComponent* component) // Licenses if (const char* option = this->GetOption(prefix + "LICENSES")) { this->Licenses.clear(); - cmSystemTools::ExpandListArgument(option, this->Licenses); + cmExpandList(option, this->Licenses); if (this->Licenses.size() % 2 != 0) { cmCPackIFWLogger( WARNING, @@ -281,13 +282,13 @@ int cmCPackIFWPackage::ConfigureFromGroup(cmCPackComponentGroup* group) // User interfaces if (const char* option = this->GetOption(prefix + "USER_INTERFACES")) { this->UserInterfaces.clear(); - cmSystemTools::ExpandListArgument(option, this->UserInterfaces); + cmExpandList(option, this->UserInterfaces); } // Licenses if (const char* option = this->GetOption(prefix + "LICENSES")) { this->Licenses.clear(); - cmSystemTools::ExpandListArgument(option, this->Licenses); + cmExpandList(option, this->Licenses); if (this->Licenses.size() % 2 != 0) { cmCPackIFWLogger( WARNING, @@ -398,18 +399,18 @@ int cmCPackIFWPackage::ConfigureFromPrefix(const std::string& prefix) this->Translations.clear(); } else if (const char* value = this->GetOption(option)) { this->Translations.clear(); - cmSystemTools::ExpandListArgument(value, this->Translations); + cmExpandList(value, this->Translations); } // QtIFW dependencies std::vector deps; option = prefix + "DEPENDS"; if (const char* value = this->GetOption(option)) { - cmSystemTools::ExpandListArgument(value, deps); + cmExpandList(value, deps); } option = prefix + "DEPENDENCIES"; if (const char* value = this->GetOption(option)) { - cmSystemTools::ExpandListArgument(value, deps); + cmExpandList(value, deps); } for (std::string const& d : deps) { DependenceStruct dep(d); @@ -431,7 +432,7 @@ int cmCPackIFWPackage::ConfigureFromPrefix(const std::string& prefix) this->AlienAutoDependOn.clear(); } else if (const char* value = this->GetOption(option)) { std::vector depsOn; - cmSystemTools::ExpandListArgument(value, depsOn); + cmExpandList(value, depsOn); for (std::string const& d : depsOn) { DependenceStruct dep(d); if (this->Generator->Packages.count(dep.Name)) { @@ -488,7 +489,7 @@ int cmCPackIFWPackage::ConfigureFromPrefix(const std::string& prefix) this->Replaces.clear(); } else if (const char* value = this->GetOption(option)) { this->Replaces.clear(); - cmSystemTools::ExpandListArgument(value, this->Replaces); + cmExpandList(value, this->Replaces); } // Requires admin rights diff --git a/Source/CPack/WiX/cmCPackWIXGenerator.cxx b/Source/CPack/WiX/cmCPackWIXGenerator.cxx index fa64d79..458a335 100644 --- a/Source/CPack/WiX/cmCPackWIXGenerator.cxx +++ b/Source/CPack/WiX/cmCPackWIXGenerator.cxx @@ -7,6 +7,7 @@ #include "cmCryptoHash.h" #include "cmGeneratedFileStream.h" #include "cmInstalledFile.h" +#include "cmStringAlgorithms.h" #include "cmSystemTools.h" #include "cmUuid.h" #include @@ -226,7 +227,7 @@ bool cmCPackWIXGenerator::InitializeWiXConfiguration() const char* patchFilePath = GetOption("CPACK_WIX_PATCH_FILE"); if (patchFilePath) { std::vector patchFilePaths; - cmSystemTools::ExpandListArgument(patchFilePath, patchFilePaths); + cmExpandList(patchFilePath, patchFilePaths); for (std::string const& p : patchFilePaths) { if (!this->Patch->LoadFragments(p)) { @@ -300,7 +301,7 @@ void cmCPackWIXGenerator::AppendUserSuppliedExtraSources() if (!cpackWixExtraSources) return; - cmSystemTools::ExpandListArgument(cpackWixExtraSources, this->WixSources); + cmExpandList(cpackWixExtraSources, this->WixSources); } void cmCPackWIXGenerator::AppendUserSuppliedExtraObjects(std::ostream& stream) @@ -311,8 +312,7 @@ void cmCPackWIXGenerator::AppendUserSuppliedExtraObjects(std::ostream& stream) std::vector expandedExtraObjects; - cmSystemTools::ExpandListArgument(cpackWixExtraObjects, - expandedExtraObjects); + cmExpandList(cpackWixExtraObjects, expandedExtraObjects); for (std::string const& obj : expandedExtraObjects) { stream << " " << QuotePath(obj); @@ -664,8 +664,7 @@ bool cmCPackWIXGenerator::AddComponentsToFeature( std::vector cpackPackageExecutablesList; const char* cpackPackageExecutables = GetOption("CPACK_PACKAGE_EXECUTABLES"); if (cpackPackageExecutables) { - cmSystemTools::ExpandListArgument(cpackPackageExecutables, - cpackPackageExecutablesList); + cmExpandList(cpackPackageExecutables, cpackPackageExecutablesList); if (cpackPackageExecutablesList.size() % 2 != 0) { cmCPackLogger( cmCPackLog::LOG_ERROR, @@ -680,8 +679,7 @@ bool cmCPackWIXGenerator::AddComponentsToFeature( const char* cpackPackageDesktopLinks = GetOption("CPACK_CREATE_DESKTOP_LINKS"); if (cpackPackageDesktopLinks) { - cmSystemTools::ExpandListArgument(cpackPackageDesktopLinks, - cpackPackageDesktopLinksList); + cmExpandList(cpackPackageDesktopLinks, cpackPackageDesktopLinksList); } AddDirectoryAndFileDefinitions( @@ -1137,7 +1135,7 @@ void cmCPackWIXGenerator::CollectExtensions(std::string const& variableName, return; std::vector list; - cmSystemTools::ExpandListArgument(variableContent, list); + cmExpandList(variableContent, list); extensions.insert(list.begin(), list.end()); } @@ -1149,7 +1147,7 @@ void cmCPackWIXGenerator::AddCustomFlags(std::string const& variableName, return; std::vector list; - cmSystemTools::ExpandListArgument(variableContent, list); + cmExpandList(variableContent, list); for (std::string const& i : list) { stream << " " << QuotePath(i); diff --git a/Source/CPack/cmCPackBundleGenerator.cxx b/Source/CPack/cmCPackBundleGenerator.cxx index 3a476f4..213ce92 100644 --- a/Source/CPack/cmCPackBundleGenerator.cxx +++ b/Source/CPack/cmCPackBundleGenerator.cxx @@ -6,6 +6,7 @@ #include #include "cmCPackLog.h" +#include "cmStringAlgorithms.h" #include "cmSystemTools.h" cmCPackBundleGenerator::cmCPackBundleGenerator() = default; @@ -206,7 +207,7 @@ int cmCPackBundleGenerator::SignBundle(const std::string& src_dir) : ""; std::vector relFiles; - cmSystemTools::ExpandListArgument(sign_files, relFiles); + cmExpandList(sign_files, relFiles); // sign the files supplied by the user, ie. frameworks. for (auto const& file : relFiles) { diff --git a/Source/CPack/cmCPackDebGenerator.cxx b/Source/CPack/cmCPackDebGenerator.cxx index cfb5efd..06b9876 100644 --- a/Source/CPack/cmCPackDebGenerator.cxx +++ b/Source/CPack/cmCPackDebGenerator.cxx @@ -8,6 +8,7 @@ #include "cmCPackLog.h" #include "cmCryptoHash.h" #include "cmGeneratedFileStream.h" +#include "cmStringAlgorithms.h" #include "cmSystemTools.h" #include "cm_sys_stat.h" @@ -378,7 +379,7 @@ bool DebGenerator::generateControlTar(std::string const& md5Filename) const control_tar.ClearPermissions(); std::vector controlExtraList; - cmSystemTools::ExpandListArgument(ControlExtra, controlExtraList); + cmExpandList(ControlExtra, controlExtraList); for (std::string const& i : controlExtraList) { std::string filenamename = cmsys::SystemTools::GetFilenameName(i); std::string localcopy = WorkDir + "/" + filenamename; diff --git a/Source/CPack/cmCPackDragNDropGenerator.cxx b/Source/CPack/cmCPackDragNDropGenerator.cxx index 7a3742b..85faa61 100644 --- a/Source/CPack/cmCPackDragNDropGenerator.cxx +++ b/Source/CPack/cmCPackDragNDropGenerator.cxx @@ -6,6 +6,7 @@ #include "cmCPackLog.h" #include "cmDuration.h" #include "cmGeneratedFileStream.h" +#include "cmStringAlgorithms.h" #include "cmSystemTools.h" #include "cmsys/FStream.hxx" @@ -128,8 +129,7 @@ int cmCPackDragNDropGenerator::InitializeInternal() } std::vector languages; - cmSystemTools::ExpandListArgument( - this->GetOption("CPACK_DMG_SLA_LANGUAGES"), languages); + cmExpandList(this->GetOption("CPACK_DMG_SLA_LANGUAGES"), languages); if (languages.empty()) { cmCPackLogger(cmCPackLog::LOG_ERROR, "CPACK_DMG_SLA_LANGUAGES set but empty" << std::endl); @@ -527,7 +527,7 @@ int cmCPackDragNDropGenerator::CreateDMG(const std::string& src_dir, std::vector languages; if (!oldStyle) { - cmSystemTools::ExpandListArgument(cpack_dmg_languages, languages); + cmExpandList(cpack_dmg_languages, languages); } cmGeneratedFileStream ofs(sla_r); diff --git a/Source/CPack/cmCPackFreeBSDGenerator.cxx b/Source/CPack/cmCPackFreeBSDGenerator.cxx index 9fdafa4..b90a27c 100644 --- a/Source/CPack/cmCPackFreeBSDGenerator.cxx +++ b/Source/CPack/cmCPackFreeBSDGenerator.cxx @@ -6,6 +6,7 @@ #include "cmCPackArchiveGenerator.h" #include "cmCPackLog.h" #include "cmGeneratedFileStream.h" +#include "cmStringAlgorithms.h" #include "cmSystemTools.h" // Needed for ::open() and ::stat() @@ -228,8 +229,7 @@ void cmCPackFreeBSDGenerator::write_manifest_fields( "desc", var_lookup("CPACK_FREEBSD_PACKAGE_DESCRIPTION")); manifest << ManifestKeyValue("www", var_lookup("CPACK_FREEBSD_PACKAGE_WWW")); std::vector licenses; - cmSystemTools::ExpandListArgument( - var_lookup("CPACK_FREEBSD_PACKAGE_LICENSE"), licenses); + cmExpandList(var_lookup("CPACK_FREEBSD_PACKAGE_LICENSE"), licenses); std::string licenselogic("single"); if (licenses.empty()) { cmSystemTools::SetFatalErrorOccured(); @@ -239,13 +239,11 @@ void cmCPackFreeBSDGenerator::write_manifest_fields( manifest << ManifestKeyValue("licenselogic", licenselogic); manifest << (ManifestKeyListValue("licenses") << licenses); std::vector categories; - cmSystemTools::ExpandListArgument( - var_lookup("CPACK_FREEBSD_PACKAGE_CATEGORIES"), categories); + cmExpandList(var_lookup("CPACK_FREEBSD_PACKAGE_CATEGORIES"), categories); manifest << (ManifestKeyListValue("categories") << categories); manifest << ManifestKeyValue("prefix", var_lookup("CMAKE_INSTALL_PREFIX")); std::vector deps; - cmSystemTools::ExpandListArgument(var_lookup("CPACK_FREEBSD_PACKAGE_DEPS"), - deps); + cmExpandList(var_lookup("CPACK_FREEBSD_PACKAGE_DEPS"), deps); if (!deps.empty()) { manifest << (ManifestKeyDepsValue("deps") << deps); } diff --git a/Source/CPack/cmCPackGenerator.cxx b/Source/CPack/cmCPackGenerator.cxx index 3fd124b..e31787c 100644 --- a/Source/CPack/cmCPackGenerator.cxx +++ b/Source/CPack/cmCPackGenerator.cxx @@ -212,7 +212,7 @@ int cmCPackGenerator::InstallProject() this->GetOption("CPACK_INSTALL_DEFAULT_DIRECTORY_PERMISSIONS"); if (default_dir_install_permissions && *default_dir_install_permissions) { std::vector items; - cmSystemTools::ExpandListArgument(default_dir_install_permissions, items); + cmExpandList(default_dir_install_permissions, items); for (const auto& arg : items) { if (!cmFSPermissions::stringToModeT(arg, default_dir_mode_v)) { cmCPackLogger(cmCPackLog::LOG_ERROR, @@ -275,7 +275,7 @@ int cmCPackGenerator::InstallProjectViaInstallCommands( tempInstallDirectoryEnv += tempInstallDirectory; cmSystemTools::PutEnv(tempInstallDirectoryEnv); std::vector installCommandsVector; - cmSystemTools::ExpandListArgument(installCommands, installCommandsVector); + cmExpandList(installCommands, installCommandsVector); for (std::string const& ic : installCommandsVector) { cmCPackLogger(cmCPackLog::LOG_VERBOSE, "Execute: " << ic << std::endl); std::string output; @@ -312,8 +312,7 @@ int cmCPackGenerator::InstallProjectViaInstalledDirectories( const char* cpackIgnoreFiles = this->GetOption("CPACK_IGNORE_FILES"); if (cpackIgnoreFiles) { std::vector ignoreFilesRegexString; - cmSystemTools::ExpandListArgument(cpackIgnoreFiles, - ignoreFilesRegexString); + cmExpandList(cpackIgnoreFiles, ignoreFilesRegexString); for (std::string const& ifr : ignoreFilesRegexString) { cmCPackLogger(cmCPackLog::LOG_VERBOSE, "Create ignore files regex for: " << ifr << std::endl); @@ -324,8 +323,7 @@ int cmCPackGenerator::InstallProjectViaInstalledDirectories( this->GetOption("CPACK_INSTALLED_DIRECTORIES"); if (installDirectories && *installDirectories) { std::vector installDirectoriesVector; - cmSystemTools::ExpandListArgument(installDirectories, - installDirectoriesVector); + cmExpandList(installDirectories, installDirectoriesVector); if (installDirectoriesVector.size() % 2 != 0) { cmCPackLogger( cmCPackLog::LOG_ERROR, @@ -466,7 +464,7 @@ int cmCPackGenerator::InstallProjectViaInstallScript( cmCPackLogger(cmCPackLog::LOG_OUTPUT, "- Install scripts: " << cmakeScripts << std::endl); std::vector cmakeScriptsVector; - cmSystemTools::ExpandListArgument(cmakeScripts, cmakeScriptsVector); + cmExpandList(cmakeScripts, cmakeScriptsVector); for (std::string const& installScript : cmakeScriptsVector) { cmCPackLogger(cmCPackLog::LOG_OUTPUT, @@ -531,7 +529,7 @@ int cmCPackGenerator::InstallProjectViaInstallCMakeProjects( return 0; } std::vector cmakeProjectsVector; - cmSystemTools::ExpandListArgument(cmakeProjects, cmakeProjectsVector); + cmExpandList(cmakeProjects, cmakeProjectsVector); std::vector::iterator it; for (it = cmakeProjectsVector.begin(); it != cmakeProjectsVector.end(); ++it) { @@ -576,7 +574,7 @@ int cmCPackGenerator::InstallProjectViaInstallCMakeProjects( const char* installTypes = this->GetOption(installTypesVar); if (installTypes && *installTypes) { std::vector installTypesVector; - cmSystemTools::ExpandListArgument(installTypes, installTypesVector); + cmExpandList(installTypes, installTypesVector); for (std::string const& installType : installTypesVector) { project.InstallationTypes.push_back( this->GetInstallationType(project.ProjectName, installType)); @@ -588,7 +586,7 @@ int cmCPackGenerator::InstallProjectViaInstallCMakeProjects( "CPACK_COMPONENTS_" + cmSystemTools::UpperCase(project.Component); const char* components = this->GetOption(componentsVar); if (components && *components) { - cmSystemTools::ExpandListArgument(components, componentsVector); + cmExpandList(components, componentsVector); for (std::string const& comp : componentsVector) { project.Components.push_back( this->GetComponent(project.ProjectName, comp)); @@ -1505,7 +1503,7 @@ cmCPackComponent* cmCPackGenerator::GetComponent( const char* installTypes = this->GetOption(macroPrefix + "_INSTALL_TYPES"); if (installTypes && *installTypes) { std::vector installTypesVector; - cmSystemTools::ExpandListArgument(installTypes, installTypesVector); + cmExpandList(installTypes, installTypesVector); for (std::string const& installType : installTypesVector) { component->InstallationTypes.push_back( this->GetInstallationType(projectName, installType)); @@ -1516,7 +1514,7 @@ cmCPackComponent* cmCPackGenerator::GetComponent( const char* depends = this->GetOption(macroPrefix + "_DEPENDS"); if (depends && *depends) { std::vector dependsVector; - cmSystemTools::ExpandListArgument(depends, dependsVector); + cmExpandList(depends, dependsVector); for (std::string const& depend : dependsVector) { cmCPackComponent* child = GetComponent(projectName, depend); component->Dependencies.push_back(child); diff --git a/Source/CPack/cmCPackNSISGenerator.cxx b/Source/CPack/cmCPackNSISGenerator.cxx index 87c36fa..cfa34dc 100644 --- a/Source/CPack/cmCPackNSISGenerator.cxx +++ b/Source/CPack/cmCPackNSISGenerator.cxx @@ -7,6 +7,7 @@ #include "cmCPackLog.h" #include "cmDuration.h" #include "cmGeneratedFileStream.h" +#include "cmStringAlgorithms.h" #include "cmSystemTools.h" #include "cmsys/Directory.hxx" @@ -459,8 +460,7 @@ int cmCPackNSISGenerator::InitializeInternal() "CPACK_CREATE_DESKTOP_LINKS: " << cpackPackageDeskTopLinks << std::endl); - cmSystemTools::ExpandListArgument(cpackPackageDeskTopLinks, - cpackPackageDesktopLinksVector); + cmExpandList(cpackPackageDeskTopLinks, cpackPackageDesktopLinksVector); for (std::string const& cpdl : cpackPackageDesktopLinksVector) { cmCPackLogger(cmCPackLog::LOG_DEBUG, "CPACK_CREATE_DESKTOP_LINKS: " << cpdl << std::endl); @@ -479,8 +479,7 @@ int cmCPackNSISGenerator::InitializeInternal() "The cpackPackageExecutables: " << cpackPackageExecutables << "." << std::endl); std::vector cpackPackageExecutablesVector; - cmSystemTools::ExpandListArgument(cpackPackageExecutables, - cpackPackageExecutablesVector); + cmExpandList(cpackPackageExecutables, cpackPackageExecutablesVector); if (cpackPackageExecutablesVector.size() % 2 != 0) { cmCPackLogger( cmCPackLog::LOG_ERROR, @@ -536,7 +535,7 @@ void cmCPackNSISGenerator::CreateMenuLinks(std::ostream& str, cmCPackLogger(cmCPackLog::LOG_DEBUG, "The cpackMenuLinks: " << cpackMenuLinks << "." << std::endl); std::vector cpackMenuLinksVector; - cmSystemTools::ExpandListArgument(cpackMenuLinks, cpackMenuLinksVector); + cmExpandList(cpackMenuLinks, cpackMenuLinksVector); if (cpackMenuLinksVector.size() % 2 != 0) { cmCPackLogger( cmCPackLog::LOG_ERROR, diff --git a/Source/CPack/cmCPackOSXX11Generator.cxx b/Source/CPack/cmCPackOSXX11Generator.cxx index 41470c9..7cc48f4 100644 --- a/Source/CPack/cmCPackOSXX11Generator.cxx +++ b/Source/CPack/cmCPackOSXX11Generator.cxx @@ -8,6 +8,7 @@ #include "cmCPackLog.h" #include "cmDuration.h" #include "cmGeneratedFileStream.h" +#include "cmStringAlgorithms.h" #include "cmSystemTools.h" #include "cm_sys_stat.h" @@ -29,8 +30,7 @@ int cmCPackOSXX11Generator::PackageFiles() std::ostringstream str; std::ostringstream deleteStr; std::vector cpackPackageExecutablesVector; - cmSystemTools::ExpandListArgument(cpackPackageExecutables, - cpackPackageExecutablesVector); + cmExpandList(cpackPackageExecutables, cpackPackageExecutablesVector); if (cpackPackageExecutablesVector.size() % 2 != 0) { cmCPackLogger( cmCPackLog::LOG_ERROR, diff --git a/Source/CPack/cpack.cxx b/Source/CPack/cpack.cxx index ae56adb..3cf0c10 100644 --- a/Source/CPack/cpack.cxx +++ b/Source/CPack/cpack.cxx @@ -25,6 +25,7 @@ #include "cmMakefile.h" #include "cmState.h" #include "cmStateSnapshot.h" +#include "cmStringAlgorithms.h" #include "cmSystemTools.h" #include "cmake.h" @@ -332,7 +333,7 @@ int main(int argc, char const* const* argv) "CPack generator not specified" << std::endl); } else { std::vector generatorsVector; - cmSystemTools::ExpandListArgument(genList, generatorsVector); + cmExpandList(genList, generatorsVector); for (std::string const& gen : generatorsVector) { cmMakefile::ScopePushPop raii(&globalMF); cmMakefile* mf = &globalMF; diff --git a/Source/CTest/cmCTestBuildHandler.cxx b/Source/CTest/cmCTestBuildHandler.cxx index b98a4e3..bc7c155 100644 --- a/Source/CTest/cmCTestBuildHandler.cxx +++ b/Source/CTest/cmCTestBuildHandler.cxx @@ -247,13 +247,11 @@ void cmCTestBuildHandler::PopulateCustomVectors(cmMakefile* mf) // Record the user-specified custom warning rules. if (const char* customWarningMatchers = mf->GetDefinition("CTEST_CUSTOM_WARNING_MATCH")) { - cmSystemTools::ExpandListArgument(customWarningMatchers, - this->ReallyCustomWarningMatches); + cmExpandList(customWarningMatchers, this->ReallyCustomWarningMatches); } if (const char* customWarningExceptions = mf->GetDefinition("CTEST_CUSTOM_WARNING_EXCEPTION")) { - cmSystemTools::ExpandListArgument(customWarningExceptions, - this->ReallyCustomWarningExceptions); + cmExpandList(customWarningExceptions, this->ReallyCustomWarningExceptions); } } diff --git a/Source/CTest/cmCTestConfigureCommand.cxx b/Source/CTest/cmCTestConfigureCommand.cxx index 74a932a..eb7ecb5 100644 --- a/Source/CTest/cmCTestConfigureCommand.cxx +++ b/Source/CTest/cmCTestConfigureCommand.cxx @@ -6,6 +6,7 @@ #include "cmCTestConfigureHandler.h" #include "cmGlobalGenerator.h" #include "cmMakefile.h" +#include "cmStringAlgorithms.h" #include "cmSystemTools.h" #include "cmake.h" @@ -25,7 +26,7 @@ cmCTestGenericHandler* cmCTestConfigureCommand::InitializeHandler() std::vector options; if (this->Values[ctc_OPTIONS]) { - cmSystemTools::ExpandListArgument(this->Values[ctc_OPTIONS], options); + cmExpandList(this->Values[ctc_OPTIONS], options); } if (this->CTest->GetCTestConfiguration("BuildDirectory").empty()) { diff --git a/Source/CTest/cmCTestGIT.cxx b/Source/CTest/cmCTestGIT.cxx index 093017c..e330e22 100644 --- a/Source/CTest/cmCTestGIT.cxx +++ b/Source/CTest/cmCTestGIT.cxx @@ -212,7 +212,7 @@ bool cmCTestGIT::UpdateByFetchAndReset() bool cmCTestGIT::UpdateByCustom(std::string const& custom) { std::vector git_custom_command; - cmSystemTools::ExpandListArgument(custom, git_custom_command, true); + cmExpandList(custom, git_custom_command, true); std::vector git_custom; git_custom.reserve(git_custom_command.size() + 1); for (std::string const& i : git_custom_command) { diff --git a/Source/CTest/cmCTestP4.cxx b/Source/CTest/cmCTestP4.cxx index 2eb8dba..80eb8d9 100644 --- a/Source/CTest/cmCTestP4.cxx +++ b/Source/CTest/cmCTestP4.cxx @@ -7,6 +7,7 @@ #include "cmCTestVC.h" #include "cmProcessTools.h" #include "cmRange.h" +#include "cmStringAlgorithms.h" #include "cmSystemTools.h" #include "cmsys/RegularExpression.hxx" @@ -460,7 +461,7 @@ bool cmCTestP4::LoadModifications() bool cmCTestP4::UpdateCustom(const std::string& custom) { std::vector p4_custom_command; - cmSystemTools::ExpandListArgument(custom, p4_custom_command, true); + cmExpandList(custom, p4_custom_command, true); std::vector p4_custom; p4_custom.reserve(p4_custom_command.size() + 1); diff --git a/Source/CTest/cmCTestScriptHandler.cxx b/Source/CTest/cmCTestScriptHandler.cxx index 58f88be..1c40a58 100644 --- a/Source/CTest/cmCTestScriptHandler.cxx +++ b/Source/CTest/cmCTestScriptHandler.cxx @@ -544,7 +544,7 @@ int cmCTestScriptHandler::RunCurrentScript() // set any environment variables if (!this->CTestEnv.empty()) { std::vector envArgs; - cmSystemTools::ExpandListArgument(this->CTestEnv, envArgs); + cmExpandList(this->CTestEnv, envArgs); cmSystemTools::AppendEnv(envArgs); } @@ -651,7 +651,7 @@ int cmCTestScriptHandler::PerformExtraUpdates() command = this->UpdateCmd; for (std::string const& eu : this->ExtraUpdates) { std::vector cvsArgs; - cmSystemTools::ExpandListArgument(eu, cvsArgs); + cmExpandList(eu, cvsArgs); if (cvsArgs.size() == 2) { std::string fullCommand = command; fullCommand += " update "; @@ -795,7 +795,7 @@ int cmCTestScriptHandler::RunConfigurationDashboard() // run ctest, it may be more than one command in here std::vector ctestCommands; - cmSystemTools::ExpandListArgument(this->CTestCmd, ctestCommands); + cmExpandList(this->CTestCmd, ctestCommands); // for each variable/argument do a putenv for (std::string const& ctestCommand : ctestCommands) { command = ctestCommand; diff --git a/Source/CTest/cmCTestSubmitCommand.cxx b/Source/CTest/cmCTestSubmitCommand.cxx index 58c0a1b..ec1e9bb 100644 --- a/Source/CTest/cmCTestSubmitCommand.cxx +++ b/Source/CTest/cmCTestSubmitCommand.cxx @@ -7,6 +7,7 @@ #include "cmCommand.h" #include "cmMakefile.h" #include "cmMessageType.h" +#include "cmStringAlgorithms.h" #include "cmSystemTools.h" #include @@ -68,7 +69,7 @@ cmCTestGenericHandler* cmCTestSubmitCommand::InitializeHandler() this->Makefile->GetDefinition("CTEST_NOTES_FILES"); if (notesFilesVariable) { std::vector notesFiles; - cmSystemTools::ExpandListArgument(notesFilesVariable, notesFiles); + cmExpandList(notesFilesVariable, notesFiles); this->CTest->GenerateNotesFile(notesFiles); } @@ -76,7 +77,7 @@ cmCTestGenericHandler* cmCTestSubmitCommand::InitializeHandler() this->Makefile->GetDefinition("CTEST_EXTRA_SUBMIT_FILES"); if (extraFilesVariable) { std::vector extraFiles; - cmSystemTools::ExpandListArgument(extraFilesVariable, extraFiles); + cmExpandList(extraFilesVariable, extraFiles); if (!this->CTest->SubmitExtraFiles(extraFiles)) { this->SetError("problem submitting extra files."); return nullptr; diff --git a/Source/CTest/cmCTestSubmitHandler.cxx b/Source/CTest/cmCTestSubmitHandler.cxx index 17ef350..051daa0 100644 --- a/Source/CTest/cmCTestSubmitHandler.cxx +++ b/Source/CTest/cmCTestSubmitHandler.cxx @@ -156,7 +156,7 @@ bool cmCTestSubmitHandler::SubmitUsingHTTP( ::curl_global_init(CURL_GLOBAL_ALL); std::string curlopt(this->CTest->GetCTestConfiguration("CurlOptions")); std::vector args; - cmSystemTools::ExpandListArgument(curlopt, args); + cmExpandList(curlopt, args); bool verifyPeerOff = false; bool verifyHostOff = false; for (std::string const& arg : args) { @@ -500,7 +500,7 @@ int cmCTestSubmitHandler::HandleCDashUploadFile(std::string const& file, curl.SetQuiet(this->Quiet); std::string curlopt(this->CTest->GetCTestConfiguration("CurlOptions")); std::vector args; - cmSystemTools::ExpandListArgument(curlopt, args); + cmExpandList(curlopt, args); curl.SetCurlOptions(args); curl.SetTimeOutSeconds(SUBMIT_TIMEOUT_IN_SECONDS_DEFAULT); curl.SetHttpHeaders(this->HttpHeaders); diff --git a/Source/CTest/cmCTestTestHandler.cxx b/Source/CTest/cmCTestTestHandler.cxx index 67c24ca..bc56e8e 100644 --- a/Source/CTest/cmCTestTestHandler.cxx +++ b/Source/CTest/cmCTestTestHandler.cxx @@ -2180,7 +2180,7 @@ bool cmCTestTestHandler::SetTestsProperties( if (key == "_BACKTRACE_TRIPLES") { std::vector triples; // allow empty args in the triples - cmSystemTools::ExpandListArgument(val, triples, true); + cmExpandList(val, triples, true); // Ensure we have complete triples otherwise the data is corrupt. if (triples.size() % 3 == 0) { @@ -2210,32 +2210,32 @@ bool cmCTestTestHandler::SetTestsProperties( rt.Disabled = cmSystemTools::IsOn(val); } if (key == "ATTACHED_FILES") { - cmSystemTools::ExpandListArgument(val, rt.AttachedFiles); + cmExpandList(val, rt.AttachedFiles); } if (key == "ATTACHED_FILES_ON_FAIL") { - cmSystemTools::ExpandListArgument(val, rt.AttachOnFail); + cmExpandList(val, rt.AttachOnFail); } if (key == "RESOURCE_LOCK") { std::vector lval; - cmSystemTools::ExpandListArgument(val, lval); + cmExpandList(val, lval); rt.LockedResources.insert(lval.begin(), lval.end()); } if (key == "FIXTURES_SETUP") { std::vector lval; - cmSystemTools::ExpandListArgument(val, lval); + cmExpandList(val, lval); rt.FixturesSetup.insert(lval.begin(), lval.end()); } if (key == "FIXTURES_CLEANUP") { std::vector lval; - cmSystemTools::ExpandListArgument(val, lval); + cmExpandList(val, lval); rt.FixturesCleanup.insert(lval.begin(), lval.end()); } if (key == "FIXTURES_REQUIRED") { std::vector lval; - cmSystemTools::ExpandListArgument(val, lval); + cmExpandList(val, lval); rt.FixturesRequired.insert(lval.begin(), lval.end()); } @@ -2247,21 +2247,21 @@ bool cmCTestTestHandler::SetTestsProperties( rt.Cost = static_cast(atof(val.c_str())); } if (key == "REQUIRED_FILES") { - cmSystemTools::ExpandListArgument(val, rt.RequiredFiles); + cmExpandList(val, rt.RequiredFiles); } if (key == "RUN_SERIAL") { rt.RunSerial = cmSystemTools::IsOn(val); } if (key == "FAIL_REGULAR_EXPRESSION") { std::vector lval; - cmSystemTools::ExpandListArgument(val, lval); + cmExpandList(val, lval); for (std::string const& cr : lval) { rt.ErrorRegularExpressions.emplace_back(cr, cr); } } if (key == "SKIP_REGULAR_EXPRESSION") { std::vector lval; - cmSystemTools::ExpandListArgument(val, lval); + cmExpandList(val, lval); for (std::string const& cr : lval) { rt.SkipRegularExpressions.emplace_back(cr, cr); } @@ -2282,14 +2282,14 @@ bool cmCTestTestHandler::SetTestsProperties( } } if (key == "DEPENDS") { - cmSystemTools::ExpandListArgument(val, rt.Depends); + cmExpandList(val, rt.Depends); } if (key == "ENVIRONMENT") { - cmSystemTools::ExpandListArgument(val, rt.Environment); + cmExpandList(val, rt.Environment); } if (key == "LABELS") { std::vector Labels; - cmSystemTools::ExpandListArgument(val, Labels); + cmExpandList(val, Labels); rt.Labels.insert(rt.Labels.end(), Labels.begin(), Labels.end()); // sort the array std::sort(rt.Labels.begin(), rt.Labels.end()); @@ -2310,7 +2310,7 @@ bool cmCTestTestHandler::SetTestsProperties( } if (key == "PASS_REGULAR_EXPRESSION") { std::vector lval; - cmSystemTools::ExpandListArgument(val, lval); + cmExpandList(val, lval); for (std::string const& cr : lval) { rt.RequiredRegularExpressions.emplace_back(cr, cr); } @@ -2320,7 +2320,7 @@ bool cmCTestTestHandler::SetTestsProperties( } if (key == "TIMEOUT_AFTER_MATCH") { std::vector propArgs; - cmSystemTools::ExpandListArgument(val, propArgs); + cmExpandList(val, propArgs); if (propArgs.size() != 2) { cmCTestLog(this->CTest, WARNING, "TIMEOUT_AFTER_MATCH expects two arguments, found " @@ -2328,7 +2328,7 @@ bool cmCTestTestHandler::SetTestsProperties( } else { rt.AlternateTimeout = cmDuration(atof(propArgs[0].c_str())); std::vector lval; - cmSystemTools::ExpandListArgument(propArgs[1], lval); + cmExpandList(propArgs[1], lval); for (std::string const& cr : lval) { rt.TimeoutRegularExpressions.emplace_back(cr, cr); } @@ -2371,7 +2371,7 @@ bool cmCTestTestHandler::SetDirectoryProperties( if (cwd == rt.Directory) { if (key == "LABELS") { std::vector DirectoryLabels; - cmSystemTools::ExpandListArgument(val, DirectoryLabels); + cmExpandList(val, DirectoryLabels); rt.Labels.insert(rt.Labels.end(), DirectoryLabels.begin(), DirectoryLabels.end()); diff --git a/Source/CursesDialog/cmCursesCacheEntryComposite.cxx b/Source/CursesDialog/cmCursesCacheEntryComposite.cxx index c1dd591..4341bf4 100644 --- a/Source/CursesDialog/cmCursesCacheEntryComposite.cxx +++ b/Source/CursesDialog/cmCursesCacheEntryComposite.cxx @@ -11,6 +11,7 @@ #include "cmCursesWidget.h" #include "cmState.h" #include "cmStateTypes.h" +#include "cmStringAlgorithms.h" #include "cmSystemTools.h" #include "cmake.h" @@ -71,7 +72,7 @@ cmCursesCacheEntryComposite::cmCursesCacheEntryComposite( new cmCursesOptionsWidget(this->EntryWidth, 1, 1, 1); this->Entry = ow; std::vector options; - cmSystemTools::ExpandListArgument(stringsProp, options); + cmExpandList(stringsProp, options); for (auto const& opt : options) { ow->AddOption(opt); } diff --git a/Source/cmCTest.cxx b/Source/cmCTest.cxx index c0ca73b..5d38d96 100644 --- a/Source/cmCTest.cxx +++ b/Source/cmCTest.cxx @@ -1454,7 +1454,7 @@ void cmCTest::AddSiteProperties(cmXMLWriter& xml) xml.StartElement("Labels"); std::string l = labels; std::vector args; - cmSystemTools::ExpandListArgument(l, args); + cmExpandList(l, args); for (std::string const& i : args) { xml.Element("Label", i); } @@ -1487,7 +1487,7 @@ std::vector cmCTest::GetLabelsForSubprojects() std::string labelsForSubprojects = this->GetCTestConfiguration("LabelsForSubprojects"); std::vector subprojects; - cmSystemTools::ExpandListArgument(labelsForSubprojects, subprojects); + cmExpandList(labelsForSubprojects, subprojects); // sort the array std::sort(subprojects.begin(), subprojects.end()); @@ -2565,7 +2565,7 @@ void cmCTest::PopulateCustomVector(cmMakefile* mf, const std::string& def, cmCTestLog(this, DEBUG, "PopulateCustomVector: " << def << std::endl); vec.clear(); - cmSystemTools::ExpandListArgument(dval, vec); + cmExpandList(dval, vec); for (std::string const& it : vec) { cmCTestLog(this, DEBUG, " -- " << it << std::endl); diff --git a/Source/cmCacheManager.cxx b/Source/cmCacheManager.cxx index e8fc350..8ebab0a 100644 --- a/Source/cmCacheManager.cxx +++ b/Source/cmCacheManager.cxx @@ -14,6 +14,7 @@ #include "cmMessageType.h" #include "cmMessenger.h" #include "cmState.h" +#include "cmStringAlgorithms.h" #include "cmSystemTools.h" #include "cmVersion.h" @@ -552,7 +553,7 @@ void cmCacheManager::AddCacheEntry(const std::string& key, const char* value, if (type == cmStateEnums::FILEPATH || type == cmStateEnums::PATH) { if (e.Value.find(';') != std::string::npos) { std::vector paths; - cmSystemTools::ExpandListArgument(e.Value, paths); + cmExpandList(e.Value, paths); const char* sep = ""; e.Value = ""; for (std::string& i : paths) { diff --git a/Source/cmComputeLinkDepends.cxx b/Source/cmComputeLinkDepends.cxx index f8b78b4..a187f99 100644 --- a/Source/cmComputeLinkDepends.cxx +++ b/Source/cmComputeLinkDepends.cxx @@ -12,7 +12,6 @@ #include "cmRange.h" #include "cmStateTypes.h" #include "cmStringAlgorithms.h" -#include "cmSystemTools.h" #include "cmTarget.h" #include "cmake.h" @@ -439,7 +438,7 @@ void cmComputeLinkDepends::AddVarLinkEntries(int depender_index, // _LIB_DEPENDS. The variable contains a semicolon-separated // list. The list contains link-type;item pairs and just items. std::vector deplist; - cmSystemTools::ExpandListArgument(value, deplist); + cmExpandList(value, deplist); // Look for entries meant for this configuration. std::vector actual_libs; diff --git a/Source/cmComputeLinkInformation.cxx b/Source/cmComputeLinkInformation.cxx index 0741f8b..5f5317c 100644 --- a/Source/cmComputeLinkInformation.cxx +++ b/Source/cmComputeLinkInformation.cxx @@ -551,7 +551,7 @@ void cmComputeLinkInformation::AddImplicitLinkInfo(std::string const& lang) libVar += "_IMPLICIT_LINK_LIBRARIES"; if (const char* libs = this->Makefile->GetDefinition(libVar)) { std::vector libsVec; - cmSystemTools::ExpandListArgument(libs, libsVec); + cmExpandList(libs, libsVec); for (std::string const& i : libsVec) { if (this->ImplicitLinkLibs.find(i) == this->ImplicitLinkLibs.end()) { this->AddItem(i, nullptr); @@ -566,7 +566,7 @@ void cmComputeLinkInformation::AddImplicitLinkInfo(std::string const& lang) dirVar += "_IMPLICIT_LINK_DIRECTORIES"; if (const char* dirs = this->Makefile->GetDefinition(dirVar)) { std::vector dirsVec; - cmSystemTools::ExpandListArgument(dirs, dirsVec); + cmExpandList(dirs, dirsVec); this->OrderLinkerSearchPath->AddLanguageDirectories(dirsVec); } } @@ -811,7 +811,7 @@ void cmComputeLinkInformation::ComputeItemParserInfo() if (const char* linkSuffixes = mf->GetDefinition("CMAKE_EXTRA_LINK_EXTENSIONS")) { std::vector linkSuffixVec; - cmSystemTools::ExpandListArgument(linkSuffixes, linkSuffixVec); + cmExpandList(linkSuffixes, linkSuffixVec); for (std::string const& i : linkSuffixVec) { this->AddLinkExtension(i.c_str(), LinkUnknown); } @@ -819,7 +819,7 @@ void cmComputeLinkInformation::ComputeItemParserInfo() if (const char* sharedSuffixes = mf->GetDefinition("CMAKE_EXTRA_SHARED_LIBRARY_SUFFIXES")) { std::vector sharedSuffixVec; - cmSystemTools::ExpandListArgument(sharedSuffixes, sharedSuffixVec); + cmExpandList(sharedSuffixes, sharedSuffixVec); for (std::string const& i : sharedSuffixVec) { this->AddLinkExtension(i.c_str(), LinkShared); } @@ -1288,7 +1288,7 @@ void cmComputeLinkInformation::ComputeFrameworkInfo() // Get platform-wide implicit directories. if (const char* implicitLinks = this->Makefile->GetDefinition( "CMAKE_PLATFORM_IMPLICIT_LINK_FRAMEWORK_DIRECTORIES")) { - cmSystemTools::ExpandListArgument(implicitLinks, implicitDirVec); + cmExpandList(implicitLinks, implicitDirVec); } // Get language-specific implicit directories. @@ -1297,7 +1297,7 @@ void cmComputeLinkInformation::ComputeFrameworkInfo() implicitDirVar += "_IMPLICIT_LINK_FRAMEWORK_DIRECTORIES"; if (const char* implicitDirs = this->Makefile->GetDefinition(implicitDirVar)) { - cmSystemTools::ExpandListArgument(implicitDirs, implicitDirVec); + cmExpandList(implicitDirs, implicitDirVec); } this->FrameworkPathsEmmitted.insert(implicitDirVec.begin(), @@ -1516,7 +1516,7 @@ void cmComputeLinkInformation::LoadImplicitLinkInfo() // Get platform-wide implicit directories. if (const char* implicitLinks = (this->Makefile->GetDefinition( "CMAKE_PLATFORM_IMPLICIT_LINK_DIRECTORIES"))) { - cmSystemTools::ExpandListArgument(implicitLinks, implicitDirVec); + cmExpandList(implicitLinks, implicitDirVec); } // Append library architecture to all implicit platform directories @@ -1534,7 +1534,7 @@ void cmComputeLinkInformation::LoadImplicitLinkInfo() implicitDirVar += "_IMPLICIT_LINK_DIRECTORIES"; if (const char* implicitDirs = this->Makefile->GetDefinition(implicitDirVar)) { - cmSystemTools::ExpandListArgument(implicitDirs, implicitDirVec); + cmExpandList(implicitDirs, implicitDirVec); } // Store implicit link directories. @@ -1547,7 +1547,7 @@ void cmComputeLinkInformation::LoadImplicitLinkInfo() implicitLibVar += "_IMPLICIT_LINK_LIBRARIES"; if (const char* implicitLibs = this->Makefile->GetDefinition(implicitLibVar)) { - cmSystemTools::ExpandListArgument(implicitLibs, implicitLibVec); + cmExpandList(implicitLibs, implicitLibVec); } // Store implicit link libraries. @@ -1562,7 +1562,7 @@ void cmComputeLinkInformation::LoadImplicitLinkInfo() // Get platform specific rpath link directories if (const char* rpathDirs = (this->Makefile->GetDefinition("CMAKE_PLATFORM_RUNTIME_PATH"))) { - cmSystemTools::ExpandListArgument(rpathDirs, this->RuntimeLinkDirs); + cmExpandList(rpathDirs, this->RuntimeLinkDirs); } } @@ -1669,7 +1669,7 @@ static void cmCLI_ExpandListUnique(const char* str, std::set& emitted) { std::vector tmp; - cmSystemTools::ExpandListArgument(str, tmp); + cmExpandList(str, tmp); for (std::string const& i : tmp) { if (emitted.insert(i).second) { out.push_back(i); diff --git a/Source/cmConditionEvaluator.cxx b/Source/cmConditionEvaluator.cxx index 5b88807..3a53067 100644 --- a/Source/cmConditionEvaluator.cxx +++ b/Source/cmConditionEvaluator.cxx @@ -670,7 +670,7 @@ bool cmConditionEvaluator::HandleLevel2(cmArgumentList& newArgs, if (def2) { std::vector list; - cmSystemTools::ExpandListArgument(def2, list, true); + cmExpandList(def2, list, true); result = std::find(list.begin(), list.end(), def) != list.end(); } diff --git a/Source/cmCoreTryCompile.cxx b/Source/cmCoreTryCompile.cxx index 85ff0a6..c0c4a25 100644 --- a/Source/cmCoreTryCompile.cxx +++ b/Source/cmCoreTryCompile.cxx @@ -234,7 +234,7 @@ int cmCoreTryCompile::TryCompileCode(std::vector const& argv, } else if (doing == DoingCMakeFlags) { cmakeFlags.push_back(argv[i]); } else if (doing == DoingCompileDefinitions) { - cmSystemTools::ExpandListArgument(argv[i], compileDefs); + cmExpandList(argv[i], compileDefs); } else if (doing == DoingLinkOptions) { linkOptions.push_back(argv[i]); } else if (doing == DoingLinkLibraries) { @@ -676,7 +676,7 @@ int cmCoreTryCompile::TryCompileCode(std::vector const& argv, if (const char* varListStr = this->Makefile->GetDefinition( kCMAKE_TRY_COMPILE_PLATFORM_VARIABLES)) { std::vector varList; - cmSystemTools::ExpandListArgument(varListStr, varList); + cmExpandList(varListStr, varList); vars.insert(varList.begin(), varList.end()); } diff --git a/Source/cmCustomCommandGenerator.cxx b/Source/cmCustomCommandGenerator.cxx index 758a69a..20f0ef2 100644 --- a/Source/cmCustomCommandGenerator.cxx +++ b/Source/cmCustomCommandGenerator.cxx @@ -10,6 +10,7 @@ #include "cmLocalGenerator.h" #include "cmMakefile.h" #include "cmStateTypes.h" +#include "cmStringAlgorithms.h" #include "cmSystemTools.h" #include @@ -35,7 +36,7 @@ cmCustomCommandGenerator::cmCustomCommandGenerator(cmCustomCommand const& cc, this->GE->Parse(clarg); std::string parsed_arg = cge->Evaluate(this->LG, this->Config); if (this->CC.GetCommandExpandLists()) { - cmAppend(argv, cmSystemTools::ExpandedListArgument(parsed_arg)); + cmAppend(argv, cmExpandedList(parsed_arg)); } else { argv.push_back(std::move(parsed_arg)); } @@ -54,8 +55,8 @@ cmCustomCommandGenerator::cmCustomCommandGenerator(cmCustomCommand const& cc, std::vector depends = this->CC.GetDepends(); for (std::string const& d : depends) { std::unique_ptr cge = this->GE->Parse(d); - std::vector result = cmSystemTools::ExpandedListArgument( - cge->Evaluate(this->LG, this->Config)); + std::vector result = + cmExpandedList(cge->Evaluate(this->LG, this->Config)); for (std::string& it : result) { if (cmSystemTools::FileIsFullPath(it)) { it = cmSystemTools::CollapseFullPath(it); @@ -108,8 +109,7 @@ void cmCustomCommandGenerator::FillEmulatorsWithArguments() continue; } - cmSystemTools::ExpandListArgument(emulator_property, - this->EmulatorsWithArguments[c]); + cmExpandList(emulator_property, this->EmulatorsWithArguments[c]); } } } diff --git a/Source/cmDepends.cxx b/Source/cmDepends.cxx index ed76dbf..6623d94 100644 --- a/Source/cmDepends.cxx +++ b/Source/cmDepends.cxx @@ -7,6 +7,7 @@ #include "cmGeneratedFileStream.h" #include "cmLocalGenerator.h" #include "cmMakefile.h" +#include "cmStringAlgorithms.h" #include "cmSystemTools.h" #include "cmsys/FStream.hxx" @@ -30,7 +31,7 @@ bool cmDepends::Write(std::ostream& makeDepends, std::ostream& internalDepends) { std::string const srcLang = "CMAKE_DEPENDS_CHECK_" + this->Language; cmMakefile* mf = this->LocalGenerator->GetMakefile(); - cmSystemTools::ExpandListArgument(mf->GetSafeDefinition(srcLang), pairs); + cmExpandList(mf->GetSafeDefinition(srcLang), pairs); } for (std::vector::iterator si = pairs.begin(); si != pairs.end();) { @@ -241,7 +242,7 @@ void cmDepends::SetIncludePathFromLanguage(const std::string& lang) cmMakefile* mf = this->LocalGenerator->GetMakefile(); includePath = mf->GetDefinition(includePathVar); if (includePath) { - cmSystemTools::ExpandListArgument(includePath, this->IncludePath); + cmExpandList(includePath, this->IncludePath); } else { // Fallback to the old directory level variable if no per-target var: includePathVar = "CMAKE_"; @@ -249,7 +250,7 @@ void cmDepends::SetIncludePathFromLanguage(const std::string& lang) includePathVar += "_INCLUDE_PATH"; includePath = mf->GetDefinition(includePathVar); if (includePath) { - cmSystemTools::ExpandListArgument(includePath, this->IncludePath); + cmExpandList(includePath, this->IncludePath); } } } diff --git a/Source/cmDependsC.cxx b/Source/cmDependsC.cxx index dc49c18..6eefe82 100644 --- a/Source/cmDependsC.cxx +++ b/Source/cmDependsC.cxx @@ -9,6 +9,7 @@ #include "cmFileTime.h" #include "cmLocalGenerator.h" #include "cmMakefile.h" +#include "cmStringAlgorithms.h" #include "cmSystemTools.h" #define INCLUDE_REGEX_LINE \ @@ -391,7 +392,7 @@ void cmDependsC::SetupTransforms() std::vector transformRules; cmMakefile* mf = this->LocalGenerator->GetMakefile(); if (const char* xform = mf->GetDefinition("CMAKE_INCLUDE_TRANSFORMS")) { - cmSystemTools::ExpandListArgument(xform, transformRules, true); + cmExpandList(xform, transformRules, true); } for (std::string const& tr : transformRules) { this->ParseTransform(tr); diff --git a/Source/cmDependsFortran.cxx b/Source/cmDependsFortran.cxx index 764ba30..63d1c4d 100644 --- a/Source/cmDependsFortran.cxx +++ b/Source/cmDependsFortran.cxx @@ -82,7 +82,7 @@ cmDependsFortran::cmDependsFortran(cmLocalGenerator* lg) cmMakefile* mf = this->LocalGenerator->GetMakefile(); if (const char* c_defines = mf->GetDefinition("CMAKE_TARGET_DEFINITIONS_Fortran")) { - cmSystemTools::ExpandListArgument(c_defines, definitions); + cmExpandList(c_defines, definitions); } // translate i.e. FOO=BAR to FOO and add it to the list of defined @@ -254,7 +254,7 @@ void cmDependsFortran::LocateModules() std::vector infoFiles; if (const char* infoFilesValue = mf->GetDefinition("CMAKE_TARGET_LINKED_INFO_FILES")) { - cmSystemTools::ExpandListArgument(infoFilesValue, infoFiles); + cmExpandList(infoFilesValue, infoFiles); } for (std::string const& i : infoFiles) { std::string targetDir = cmSystemTools::GetFilenamePath(i); diff --git a/Source/cmExportBuildAndroidMKGenerator.cxx b/Source/cmExportBuildAndroidMKGenerator.cxx index 5edf7ca..22cc0bc 100644 --- a/Source/cmExportBuildAndroidMKGenerator.cxx +++ b/Source/cmExportBuildAndroidMKGenerator.cxx @@ -145,7 +145,7 @@ void cmExportBuildAndroidMKGenerator::GenerateInterfaceProperties( } else if (property.first == "INTERFACE_INCLUDE_DIRECTORIES") { std::string includes = property.second; std::vector includeList; - cmSystemTools::ExpandListArgument(includes, includeList); + cmExpandList(includes, includeList); os << "LOCAL_EXPORT_C_INCLUDES := "; std::string end; for (std::string const& i : includeList) { @@ -156,7 +156,7 @@ void cmExportBuildAndroidMKGenerator::GenerateInterfaceProperties( } else if (property.first == "INTERFACE_LINK_OPTIONS") { os << "LOCAL_EXPORT_LDFLAGS := "; std::vector linkFlagsList; - cmSystemTools::ExpandListArgument(property.second, linkFlagsList); + cmExpandList(property.second, linkFlagsList); os << cmJoin(linkFlagsList, " ") << "\n"; } else { os << "# " << property.first << " " << (property.second) << "\n"; diff --git a/Source/cmExportFileGenerator.cxx b/Source/cmExportFileGenerator.cxx index 87f9b4c..35d8668 100644 --- a/Source/cmExportFileGenerator.cxx +++ b/Source/cmExportFileGenerator.cxx @@ -500,7 +500,7 @@ void getPropertyContents(cmGeneratorTarget const* tgt, const std::string& prop, return; } std::vector content; - cmSystemTools::ExpandListArgument(p, content); + cmExpandList(p, content); ifaceProperties.insert(content.begin(), content.end()); } @@ -1207,7 +1207,7 @@ bool cmExportFileGenerator::PopulateExportProperties( auto& targetProperties = gte->Target->GetProperties(); if (const char* exportProperties = targetProperties.GetPropertyValue("EXPORT_PROPERTIES")) { - for (auto& prop : cmSystemTools::ExpandedListArgument(exportProperties)) { + for (auto& prop : cmExpandedList(exportProperties)) { /* Black list reserved properties */ if (cmHasLiteralPrefix(prop, "IMPORTED_") || cmHasLiteralPrefix(prop, "INTERFACE_")) { diff --git a/Source/cmExportTryCompileFileGenerator.cxx b/Source/cmExportTryCompileFileGenerator.cxx index a3c9802..f77fd3a 100644 --- a/Source/cmExportTryCompileFileGenerator.cxx +++ b/Source/cmExportTryCompileFileGenerator.cxx @@ -9,7 +9,7 @@ #include "cmLocalGenerator.h" #include "cmMakefile.h" #include "cmStateTypes.h" -#include "cmSystemTools.h" +#include "cmStringAlgorithms.h" #include "cmTarget.h" #include @@ -104,7 +104,7 @@ void cmExportTryCompileFileGenerator::PopulateProperties( this->FindTargets(p, target, std::string(), emitted); std::vector depends; - cmSystemTools::ExpandListArgument(evalResult, depends); + cmExpandList(evalResult, depends); for (std::string const& li : depends) { cmGeneratorTarget* tgt = target->GetLocalGenerator()->FindGeneratorTargetToUse(li); diff --git a/Source/cmExtraCodeBlocksGenerator.cxx b/Source/cmExtraCodeBlocksGenerator.cxx index 4146db8..d13e3ce 100644 --- a/Source/cmExtraCodeBlocksGenerator.cxx +++ b/Source/cmExtraCodeBlocksGenerator.cxx @@ -571,15 +571,13 @@ void cmExtraCodeBlocksGenerator::AppendTarget( std::string systemIncludeDirs = makefile->GetSafeDefinition( "CMAKE_EXTRA_GENERATOR_CXX_SYSTEM_INCLUDE_DIRS"); if (!systemIncludeDirs.empty()) { - cmAppend(allIncludeDirs, - cmSystemTools::ExpandedListArgument(systemIncludeDirs)); + cmAppend(allIncludeDirs, cmExpandedList(systemIncludeDirs)); } systemIncludeDirs = makefile->GetSafeDefinition( "CMAKE_EXTRA_GENERATOR_C_SYSTEM_INCLUDE_DIRS"); if (!systemIncludeDirs.empty()) { - cmAppend(allIncludeDirs, - cmSystemTools::ExpandedListArgument(systemIncludeDirs)); + cmAppend(allIncludeDirs, cmExpandedList(systemIncludeDirs)); } std::vector::const_iterator end = diff --git a/Source/cmExtraEclipseCDT4Generator.cxx b/Source/cmExtraEclipseCDT4Generator.cxx index 06709f1..9ac355c 100644 --- a/Source/cmExtraEclipseCDT4Generator.cxx +++ b/Source/cmExtraEclipseCDT4Generator.cxx @@ -21,6 +21,7 @@ #include "cmSourceGroup.h" #include "cmState.h" #include "cmStateTypes.h" +#include "cmStringAlgorithms.h" #include "cmSystemTools.h" #include "cmXMLWriter.h" #include "cmake.h" @@ -416,7 +417,7 @@ void cmExtraEclipseCDT4Generator::CreateProjectFile() if (const char* extraNaturesProp = mf->GetState()->GetGlobalProperty("ECLIPSE_EXTRA_NATURES")) { std::vector extraNatures; - cmSystemTools::ExpandListArgument(extraNaturesProp, extraNatures); + cmExpandList(extraNaturesProp, extraNatures); for (std::string const& n : extraNatures) { xml.Element("nature", n); } @@ -803,7 +804,7 @@ void cmExtraEclipseCDT4Generator::CreateCProjectFile() const if (this->CEnabled && cDefs) { // Expand the list. std::vector defs; - cmSystemTools::ExpandListArgument(cDefs, defs, true); + cmExpandList(cDefs, defs, true); // the list must contain only definition-value pairs: if ((defs.size() % 2) == 0) { @@ -836,7 +837,7 @@ void cmExtraEclipseCDT4Generator::CreateCProjectFile() const if (this->CXXEnabled && cxxDefs) { // Expand the list. std::vector defs; - cmSystemTools::ExpandListArgument(cxxDefs, defs, true); + cmExpandList(cxxDefs, defs, true); // the list must contain only definition-value pairs: if ((defs.size() % 2) == 0) { @@ -887,7 +888,7 @@ void cmExtraEclipseCDT4Generator::CreateCProjectFile() const std::string systemIncludeDirs = mf->GetSafeDefinition("CMAKE_EXTRA_GENERATOR_C_SYSTEM_INCLUDE_DIRS"); std::vector dirs; - cmSystemTools::ExpandListArgument(systemIncludeDirs, dirs); + cmExpandList(systemIncludeDirs, dirs); this->AppendIncludeDirectories(xml, dirs, emmited); } compiler = mf->GetSafeDefinition("CMAKE_CXX_COMPILER"); @@ -895,7 +896,7 @@ void cmExtraEclipseCDT4Generator::CreateCProjectFile() const std::string systemIncludeDirs = mf->GetSafeDefinition("CMAKE_EXTRA_GENERATOR_CXX_SYSTEM_INCLUDE_DIRS"); std::vector dirs; - cmSystemTools::ExpandListArgument(systemIncludeDirs, dirs); + cmExpandList(systemIncludeDirs, dirs); this->AppendIncludeDirectories(xml, dirs, emmited); } diff --git a/Source/cmExtraSublimeTextGenerator.cxx b/Source/cmExtraSublimeTextGenerator.cxx index 67773e0..0c258f7 100644 --- a/Source/cmExtraSublimeTextGenerator.cxx +++ b/Source/cmExtraSublimeTextGenerator.cxx @@ -135,7 +135,7 @@ void cmExtraSublimeTextGenerator::CreateNewProjectFile( fout << "\n\t]"; std::string systemName = mf->GetSafeDefinition("CMAKE_SYSTEM_NAME"); std::vector tokens; - cmSystemTools::ExpandListArgument(this->EnvSettings, tokens); + cmExpandList(this->EnvSettings, tokens); if (!this->EnvSettings.empty()) { fout << ","; diff --git a/Source/cmFileCopier.cxx b/Source/cmFileCopier.cxx index 62f132d..1d66050 100644 --- a/Source/cmFileCopier.cxx +++ b/Source/cmFileCopier.cxx @@ -172,7 +172,7 @@ bool cmFileCopier::GetDefaultDirectoryPermissions(mode_t** mode) "CMAKE_INSTALL_DEFAULT_DIRECTORY_PERMISSIONS"); if (default_dir_install_permissions && *default_dir_install_permissions) { std::vector items; - cmSystemTools::ExpandListArgument(default_dir_install_permissions, items); + cmExpandList(default_dir_install_permissions, items); for (const auto& arg : items) { if (!this->CheckPermissions(arg, **mode)) { this->Status.SetError( diff --git a/Source/cmFindCommon.cxx b/Source/cmFindCommon.cxx index a5937a0..102ed4c 100644 --- a/Source/cmFindCommon.cxx +++ b/Source/cmFindCommon.cxx @@ -9,6 +9,7 @@ #include "cmAlgorithms.h" #include "cmMakefile.h" +#include "cmStringAlgorithms.h" #include "cmSystemTools.h" cmFindCommon::PathGroup cmFindCommon::PathGroup::All("ALL"); @@ -195,7 +196,7 @@ void cmFindCommon::RerootPaths(std::vector& paths) // Construct the list of path roots with no trailing slashes. std::vector roots; if (rootPath) { - cmSystemTools::ExpandListArgument(rootPath, roots); + cmExpandList(rootPath, roots); } if (sysrootCompile) { roots.emplace_back(sysrootCompile); @@ -261,7 +262,7 @@ void cmFindCommon::GetIgnoredPaths(std::vector& ignore) continue; } - cmSystemTools::ExpandListArgument(ignorePath, ignore); + cmExpandList(ignorePath, ignore); } for (std::string& i : ignore) { diff --git a/Source/cmFindLibraryCommand.cxx b/Source/cmFindLibraryCommand.cxx index 73d602d..dc160b5 100644 --- a/Source/cmFindLibraryCommand.cxx +++ b/Source/cmFindLibraryCommand.cxx @@ -13,6 +13,7 @@ #include "cmMakefile.h" #include "cmState.h" #include "cmStateTypes.h" +#include "cmStringAlgorithms.h" #include "cmSystemTools.h" class cmExecutionStatus; @@ -237,8 +238,8 @@ cmFindLibraryHelper::cmFindLibraryHelper(cmMakefile* mf) this->Makefile->GetRequiredDefinition("CMAKE_FIND_LIBRARY_PREFIXES"); std::string const& suffixes_list = this->Makefile->GetRequiredDefinition("CMAKE_FIND_LIBRARY_SUFFIXES"); - cmSystemTools::ExpandListArgument(prefixes_list, this->Prefixes, true); - cmSystemTools::ExpandListArgument(suffixes_list, this->Suffixes, true); + cmExpandList(prefixes_list, this->Prefixes, true); + cmExpandList(suffixes_list, this->Suffixes, true); this->RegexFromList(this->PrefixRegexStr, this->Prefixes); this->RegexFromList(this->SuffixRegexStr, this->Suffixes); diff --git a/Source/cmFindPackageCommand.cxx b/Source/cmFindPackageCommand.cxx index 0159ca5..d5207fa 100644 --- a/Source/cmFindPackageCommand.cxx +++ b/Source/cmFindPackageCommand.cxx @@ -498,7 +498,7 @@ bool cmFindPackageCommand::InitialPass(std::vector const& args, // NEW behavior is to honor the _ROOT variables. std::string const rootVar = this->Name + "_ROOT"; if (const char* pkgRoot = this->Makefile->GetDefinition(rootVar)) { - cmSystemTools::ExpandListArgument(pkgRoot, rootPaths, false); + cmExpandList(pkgRoot, rootPaths, false); } cmSystemTools::GetPath(rootPaths, rootVar.c_str()); } break; @@ -1099,7 +1099,7 @@ void cmFindPackageCommand::AppendToFoundProperty(bool found) if (foundProp && *foundProp) { std::string tmp = foundProp; - cmSystemTools::ExpandListArgument(tmp, foundContents, false); + cmExpandList(tmp, foundContents, false); std::vector::iterator nameIt = std::find(foundContents.begin(), foundContents.end(), this->Name); if (nameIt != foundContents.end()) { @@ -1113,7 +1113,7 @@ void cmFindPackageCommand::AppendToFoundProperty(bool found) if (notFoundProp && *notFoundProp) { std::string tmp = notFoundProp; - cmSystemTools::ExpandListArgument(tmp, notFoundContents, false); + cmExpandList(tmp, notFoundContents, false); std::vector::iterator nameIt = std::find(notFoundContents.begin(), notFoundContents.end(), this->Name); if (nameIt != notFoundContents.end()) { diff --git a/Source/cmForEachCommand.cxx b/Source/cmForEachCommand.cxx index a565786..9c6f1b4 100644 --- a/Source/cmForEachCommand.cxx +++ b/Source/cmForEachCommand.cxx @@ -17,6 +17,7 @@ #include "cmMakefile.h" #include "cmMessageType.h" #include "cmRange.h" +#include "cmStringAlgorithms.h" #include "cmSystemTools.h" class cmForEachFunctionBlocker : public cmFunctionBlocker @@ -195,7 +196,7 @@ bool cmForEachCommand::HandleInMode(std::vector const& args) } else if (doing == DoingLists) { const char* value = this->Makefile->GetDefinition(args[i]); if (value && *value) { - cmSystemTools::ExpandListArgument(value, fb->Args, true); + cmExpandList(value, fb->Args, true); } } else { std::ostringstream e; diff --git a/Source/cmGeneratorExpression.cxx b/Source/cmGeneratorExpression.cxx index 4d3a005..133a72b 100644 --- a/Source/cmGeneratorExpression.cxx +++ b/Source/cmGeneratorExpression.cxx @@ -13,6 +13,7 @@ #include "cmGeneratorExpressionEvaluator.h" #include "cmGeneratorExpressionLexer.h" #include "cmGeneratorExpressionParser.h" +#include "cmStringAlgorithms.h" #include "cmSystemTools.h" cmGeneratorExpression::cmGeneratorExpression(cmListFileBacktrace backtrace) @@ -294,7 +295,7 @@ void cmGeneratorExpression::Split(const std::string& input, preGenex = input.substr(startPos + 1, pos - startPos - 1); } if (!part.empty()) { - cmSystemTools::ExpandListArgument(part, output); + cmExpandList(part, output); } } pos += 2; @@ -327,7 +328,7 @@ void cmGeneratorExpression::Split(const std::string& input, lastPos = pos; } if (lastPos < input.size()) { - cmSystemTools::ExpandListArgument(input.substr(lastPos), output); + cmExpandList(input.substr(lastPos), output); } } diff --git a/Source/cmGeneratorExpressionNode.cxx b/Source/cmGeneratorExpressionNode.cxx index f78c72e..53bc3cd 100644 --- a/Source/cmGeneratorExpressionNode.cxx +++ b/Source/cmGeneratorExpressionNode.cxx @@ -281,11 +281,11 @@ static const struct InListNode : public cmGeneratorExpressionNode case cmPolicies::WARN: if (parameters.front().empty()) { check = true; - cmSystemTools::ExpandListArgument(parameters[1], checkValues, true); + cmExpandList(parameters[1], checkValues, true); } CM_FALLTHROUGH; case cmPolicies::OLD: - cmSystemTools::ExpandListArgument(parameters[1], values); + cmExpandList(parameters[1], values); if (check && values != checkValues) { std::ostringstream e; e << cmPolicies::GetPolicyWarning(cmPolicies::CMP0085) @@ -302,7 +302,7 @@ static const struct InListNode : public cmGeneratorExpressionNode case cmPolicies::REQUIRED_IF_USED: case cmPolicies::REQUIRED_ALWAYS: case cmPolicies::NEW: - cmSystemTools::ExpandListArgument(parameters[1], values, true); + cmExpandList(parameters[1], values, true); break; } @@ -348,7 +348,7 @@ static const struct FilterNode : public cmGeneratorExpressionNode } std::vector values, result; - cmSystemTools::ExpandListArgument(parameters.front(), values, true); + cmExpandList(parameters.front(), values, true); std::copy_if(values.cbegin(), values.cend(), std::back_inserter(result), [&re, exclude](std::string const& input) { @@ -377,7 +377,7 @@ static const struct RemoveDuplicatesNode : public cmGeneratorExpressionNode } std::vector values; - cmSystemTools::ExpandListArgument(parameters.front(), values, true); + cmExpandList(parameters.front(), values, true); auto valuesEnd = cmRemoveDuplicates(values); auto valuesBegin = values.cbegin(); @@ -914,8 +914,7 @@ static const struct ConfigurationTestNode : public cmGeneratorExpressionNode mapProp += cmSystemTools::UpperCase(context->Config); if (const char* mapValue = context->CurrentTarget->GetProperty(mapProp)) { - cmSystemTools::ExpandListArgument(cmSystemTools::UpperCase(mapValue), - mappedConfigs); + cmExpandList(cmSystemTools::UpperCase(mapValue), mappedConfigs); return std::find(mappedConfigs.begin(), mappedConfigs.end(), cmSystemTools::UpperCase(parameters.front())) != mappedConfigs.end() @@ -943,7 +942,7 @@ static const struct JoinNode : public cmGeneratorExpressionNode cmGeneratorExpressionDAGChecker* /*dagChecker*/) const override { std::vector list; - cmSystemTools::ExpandListArgument(parameters.front(), list); + cmExpandList(parameters.front(), list); return cmJoin(list, parameters[1]); } } joinNode; @@ -1421,7 +1420,7 @@ static const struct TargetObjectsNode : public cmGeneratorExpressionNode const char* imp = nullptr; std::string suffix; if (gt->Target->GetMappedConfig(context->Config, &loc, &imp, suffix)) { - cmSystemTools::ExpandListArgument(loc, objects); + cmExpandList(loc, objects); } context->HadContextSensitiveCondition = true; } else { @@ -1499,8 +1498,7 @@ static const struct CompileFeaturesNode : public cmGeneratorExpressionNode reportError(context, content->GetOriginalExpression(), error); return std::string(); } - cmSystemTools::ExpandListArgument(featuresKnown, - availableFeatures[lang]); + cmExpandList(featuresKnown, availableFeatures[lang]); } } @@ -2216,7 +2214,7 @@ static const struct ShellPathNode : public cmGeneratorExpressionNode cmGeneratorExpressionDAGChecker* /*dagChecker*/) const override { std::vector listIn; - cmSystemTools::ExpandListArgument(parameters.front(), listIn); + cmExpandList(parameters.front(), listIn); if (listIn.empty()) { reportError(context, content->GetOriginalExpression(), "\"\" is not an absolute path."); diff --git a/Source/cmGeneratorTarget.cxx b/Source/cmGeneratorTarget.cxx index c07d7af..9412d82 100644 --- a/Source/cmGeneratorTarget.cxx +++ b/Source/cmGeneratorTarget.cxx @@ -241,10 +241,9 @@ EvaluatedTargetPropertyEntry EvaluateTargetPropertyEntry( cmGeneratorTarget::TargetPropertyEntry* entry) { EvaluatedTargetPropertyEntry ee(entry->LinkImplItem, entry->GetBacktrace()); - cmSystemTools::ExpandListArgument( - entry->Evaluate(thisTarget->GetLocalGenerator(), config, false, thisTarget, - dagChecker, lang), - ee.Values); + cmExpandList(entry->Evaluate(thisTarget->GetLocalGenerator(), config, false, + thisTarget, dagChecker, lang), + ee.Values); if (entry->GetHadContextSensitiveCondition()) { ee.ContextDependent = true; } @@ -723,10 +722,9 @@ void handleSystemIncludesDep(cmLocalGenerator* lg, if (const char* dirs = depTgt->GetProperty("INTERFACE_SYSTEM_INCLUDE_DIRECTORIES")) { cmGeneratorExpression ge; - cmSystemTools::ExpandListArgument( - ge.Parse(dirs)->Evaluate(lg, config, false, headTarget, depTgt, - dagChecker, language), - result); + cmExpandList(ge.Parse(dirs)->Evaluate(lg, config, false, headTarget, + depTgt, dagChecker, language), + result); } if (!depTgt->IsImported() || excludeImported) { return; @@ -735,10 +733,9 @@ void handleSystemIncludesDep(cmLocalGenerator* lg, if (const char* dirs = depTgt->GetProperty("INTERFACE_INCLUDE_DIRECTORIES")) { cmGeneratorExpression ge; - cmSystemTools::ExpandListArgument( - ge.Parse(dirs)->Evaluate(lg, config, false, headTarget, depTgt, - dagChecker, language), - result); + cmExpandList(ge.Parse(dirs)->Evaluate(lg, config, false, headTarget, + depTgt, dagChecker, language), + result); } } } @@ -1114,10 +1111,9 @@ bool cmGeneratorTarget::IsSystemIncludeDirectory( std::vector result; for (std::string const& it : this->Target->GetSystemIncludeDirectories()) { cmGeneratorExpression ge; - cmSystemTools::ExpandListArgument( - ge.Parse(it)->Evaluate(this->LocalGenerator, config, false, this, - &dagChecker, language), - result); + cmExpandList(ge.Parse(it)->Evaluate(this->LocalGenerator, config, false, + this, &dagChecker, language), + result); } std::vector const& deps = @@ -1282,7 +1278,7 @@ void AddInterfaceEntries(cmGeneratorTarget const* headTarget, cmGeneratorExpressionContext context( headTarget->GetLocalGenerator(), config, false, headTarget, headTarget, true, lib.Backtrace, lang); - cmSystemTools::ExpandListArgument( + cmExpandList( lib.Target->EvaluateInterfaceProperty(prop, &context, dagChecker), ee.Values); ee.ContextDependent = context.HadContextSensitiveCondition; @@ -1311,10 +1307,9 @@ void AddObjectEntries(cmGeneratorTarget const* headTarget, cge->SetEvaluateForBuildsystem(true); EvaluatedTargetPropertyEntry ee(lib, lib.Backtrace); - cmSystemTools::ExpandListArgument( - cge->Evaluate(headTarget->GetLocalGenerator(), config, false, - headTarget, dagChecker), - ee.Values); + cmExpandList(cge->Evaluate(headTarget->GetLocalGenerator(), config, + false, headTarget, dagChecker), + ee.Values); if (cge->GetHadContextSensitiveCondition()) { ee.ContextDependent = true; } @@ -1407,7 +1402,7 @@ std::vector> cmGeneratorTarget::GetSourceFilePaths( cmStringRange sourceEntries = this->Target->GetSourceEntries(); for (std::string const& entry : sourceEntries) { std::vector items; - cmSystemTools::ExpandListArgument(entry, items); + cmExpandList(entry, items); for (std::string const& item : items) { if (cmHasLiteralPrefix(item, "$') { @@ -1423,7 +1418,7 @@ std::vector> cmGeneratorTarget::GetSourceFilePaths( const char* debugProp = this->Makefile->GetDefinition("CMAKE_DEBUG_TARGET_PROPERTIES"); if (debugProp) { - cmSystemTools::ExpandListArgument(debugProp, debugProperties); + cmExpandList(debugProp, debugProperties); } bool debugSources = !this->DebugSourcesDone && @@ -2557,10 +2552,9 @@ void cmGeneratorTarget::GetAutoUicOptions(std::vector& result, cmGeneratorExpressionDAGChecker dagChecker(this, "AUTOUIC_OPTIONS", nullptr, nullptr); - cmSystemTools::ExpandListArgument( - ge.Parse(prop)->Evaluate(this->LocalGenerator, config, false, this, - &dagChecker), - result); + cmExpandList(ge.Parse(prop)->Evaluate(this->LocalGenerator, config, false, + this, &dagChecker), + result); } void processILibs(const std::string& config, @@ -2688,7 +2682,7 @@ void cmTargetTraceDependencies::Trace() // Queue dependencies added explicitly by the user. if (const char* additionalDeps = sf->GetProperty("OBJECT_DEPENDS")) { std::vector objDeps; - cmSystemTools::ExpandListArgument(additionalDeps, objDeps); + cmExpandList(additionalDeps, objDeps); for (std::string& objDep : objDeps) { if (cmSystemTools::FileIsFullPath(objDep)) { objDep = cmSystemTools::CollapseFullPath(objDep); @@ -2909,7 +2903,7 @@ void cmGeneratorTarget::GetAppleArchs(const std::string& config, archs = this->GetProperty("OSX_ARCHITECTURES"); } if (archs) { - cmSystemTools::ExpandListArgument(std::string(archs), archVec); + cmExpandList(std::string(archs), archVec); } } @@ -3074,7 +3068,7 @@ std::vector> cmGeneratorTarget::GetIncludeDirectories( const char* debugProp = this->Makefile->GetDefinition("CMAKE_DEBUG_TARGET_PROPERTIES"); if (debugProp) { - cmSystemTools::ExpandListArgument(debugProp, debugProperties); + cmExpandList(debugProp, debugProperties); } bool debugIncludes = !this->DebugIncludesDone && @@ -3185,7 +3179,7 @@ std::vector> cmGeneratorTarget::GetCompileOptions( const char* debugProp = this->Makefile->GetDefinition("CMAKE_DEBUG_TARGET_PROPERTIES"); if (debugProp) { - cmSystemTools::ExpandListArgument(debugProp, debugProperties); + cmExpandList(debugProp, debugProperties); } bool debugOptions = !this->DebugCompileOptionsDone && @@ -3232,7 +3226,7 @@ std::vector> cmGeneratorTarget::GetCompileFeatures( const char* debugProp = this->Makefile->GetDefinition("CMAKE_DEBUG_TARGET_PROPERTIES"); if (debugProp) { - cmSystemTools::ExpandListArgument(debugProp, debugProperties); + cmExpandList(debugProp, debugProperties); } bool debugFeatures = !this->DebugCompileFeaturesDone && @@ -3281,7 +3275,7 @@ std::vector> cmGeneratorTarget::GetCompileDefinitions( const char* debugProp = this->Makefile->GetDefinition("CMAKE_DEBUG_TARGET_PROPERTIES"); if (debugProp) { - cmSystemTools::ExpandListArgument(debugProp, debugProperties); + cmExpandList(debugProp, debugProperties); } bool debugDefines = !this->DebugCompileDefinitionsDone && @@ -3356,7 +3350,7 @@ std::vector> cmGeneratorTarget::GetLinkOptions( const char* debugProp = this->Makefile->GetDefinition("CMAKE_DEBUG_TARGET_PROPERTIES"); if (debugProp) { - cmSystemTools::ExpandListArgument(debugProp, debugProperties); + cmExpandList(debugProp, debugProperties); } bool debugOptions = !this->DebugLinkOptionsDone && @@ -3382,7 +3376,7 @@ std::vector> cmGeneratorTarget::GetLinkOptions( const std::string wrapper(this->Makefile->GetSafeDefinition( "CMAKE_" + language + "_LINKER_WRAPPER_FLAG")); std::vector wrapperFlag; - cmSystemTools::ExpandListArgument(wrapper, wrapperFlag); + cmExpandList(wrapper, wrapperFlag); const std::string wrapperSep(this->Makefile->GetSafeDefinition( "CMAKE_" + language + "_LINKER_WRAPPER_FLAG_SEP")); bool concatFlagAndArgs = true; @@ -3504,7 +3498,7 @@ std::vector> cmGeneratorTarget::GetStaticLibraryLinkOptions( std::vector entries; if (const char* linkOptions = this->GetProperty("STATIC_LIBRARY_OPTIONS")) { std::vector options; - cmSystemTools::ExpandListArgument(linkOptions, options); + cmExpandList(linkOptions, options); for (const auto& option : options) { std::unique_ptr entry( CreateTargetPropertyEntry(option)); @@ -3614,7 +3608,7 @@ std::vector> cmGeneratorTarget::GetLinkDirectories( const char* debugProp = this->Makefile->GetDefinition("CMAKE_DEBUG_TARGET_PROPERTIES"); if (debugProp) { - cmSystemTools::ExpandListArgument(debugProp, debugProperties); + cmExpandList(debugProp, debugProperties); } bool debugDirectories = !this->DebugLinkDirectoriesDone && @@ -3660,7 +3654,7 @@ std::vector> cmGeneratorTarget::GetLinkDepends( std::vector entries; if (const char* linkDepends = this->GetProperty("LINK_DEPENDS")) { std::vector depends; - cmSystemTools::ExpandListArgument(linkDepends, depends); + cmExpandList(linkDepends, depends); for (const auto& depend : depends) { std::unique_ptr entry( CreateTargetPropertyEntry(depend)); @@ -4214,7 +4208,7 @@ void cmGeneratorTarget::ConstructSourceFileFlags() const // Process public headers to mark the source files. if (const char* files = this->GetProperty("PUBLIC_HEADER")) { std::vector relFiles; - cmSystemTools::ExpandListArgument(files, relFiles); + cmExpandList(files, relFiles); for (std::string const& relFile : relFiles) { if (cmSourceFile* sf = this->Makefile->GetSource(relFile)) { SourceFileFlags& flags = this->SourceFlagsMap[sf]; @@ -4228,7 +4222,7 @@ void cmGeneratorTarget::ConstructSourceFileFlags() const // precedence if a file is listed in both. if (const char* files = this->GetProperty("PRIVATE_HEADER")) { std::vector relFiles; - cmSystemTools::ExpandListArgument(files, relFiles); + cmExpandList(files, relFiles); for (std::string const& relFile : relFiles) { if (cmSourceFile* sf = this->Makefile->GetSource(relFile)) { SourceFileFlags& flags = this->SourceFlagsMap[sf]; @@ -4241,7 +4235,7 @@ void cmGeneratorTarget::ConstructSourceFileFlags() const // Mark sources listed as resources. if (const char* files = this->GetProperty("RESOURCE")) { std::vector relFiles; - cmSystemTools::ExpandListArgument(files, relFiles); + cmExpandList(files, relFiles); for (std::string const& relFile : relFiles) { if (cmSourceFile* sf = this->Makefile->GetSource(relFile)) { SourceFileFlags& flags = this->SourceFlagsMap[sf]; @@ -4270,7 +4264,7 @@ cmGeneratorTarget::GetCompatibleInterfaces(std::string const& config) const #define CM_READ_COMPATIBLE_INTERFACE(X, x) \ if (const char* prop = li->GetProperty("COMPATIBLE_INTERFACE_" #X)) { \ std::vector props; \ - cmSystemTools::ExpandListArgument(prop, props); \ + cmExpandList(prop, props); \ compat.Props##x.insert(props.begin(), props.end()); \ } CM_READ_COMPATIBLE_INTERFACE(BOOL, Bool) @@ -4384,7 +4378,7 @@ void checkPropertyConsistency(cmGeneratorTarget const* depender, } std::vector props; - cmSystemTools::ExpandListArgument(prop, props); + cmExpandList(prop, props); std::string pdir = cmSystemTools::GetCMakeRoot(); pdir += "/Help/prop_tgt/"; @@ -5115,7 +5109,7 @@ void cmGeneratorTarget::ReportPropertyOrigin( const char* debugProp = this->Target->GetMakefile()->GetDefinition( "CMAKE_DEBUG_TARGET_PROPERTIES"); if (debugProp) { - cmSystemTools::ExpandListArgument(debugProp, debugProperties); + cmExpandList(debugProp, debugProperties); } bool debugOrigin = !this->DebugCompatiblePropertiesDone[p] && @@ -5167,10 +5161,9 @@ void cmGeneratorTarget::ExpandLinkItems( } std::vector libs; std::unique_ptr cge = ge.Parse(value); - cmSystemTools::ExpandListArgument(cge->Evaluate(this->LocalGenerator, config, - false, headTarget, this, - &dagChecker), - libs); + cmExpandList(cge->Evaluate(this->LocalGenerator, config, false, headTarget, + this, &dagChecker), + libs); this->LookupLinkItems(libs, cge->GetBacktrace(), items); hadHeadSensitiveCondition = cge->GetHadHeadSensitiveCondition(); } @@ -5747,12 +5740,12 @@ const cmLinkInterface* cmGeneratorTarget::GetImportLinkInterface( if (!iface.AllDone) { iface.AllDone = true; iface.Multiplicity = info->Multiplicity; - cmSystemTools::ExpandListArgument(info->Languages, iface.Languages); + cmExpandList(info->Languages, iface.Languages); this->ExpandLinkItems(info->LibrariesProp, info->Libraries, config, headTarget, usage_requirements_only, iface.Libraries, iface.HadHeadSensitiveCondition); std::vector deps; - cmSystemTools::ExpandListArgument(info->SharedDeps, deps); + cmExpandList(info->SharedDeps, deps); this->LookupLinkItems(deps, cmListFileBacktrace(), iface.SharedDeps); } @@ -6041,7 +6034,7 @@ void cmGeneratorTarget::GetObjectLibrariesCMP0026( cmStringRange rng = this->Target->GetSourceEntries(); for (std::string const& entry : rng) { std::vector files; - cmSystemTools::ExpandListArgument(entry, files); + cmExpandList(entry, files); for (std::string const& li : files) { if (cmHasLiteralPrefix(li, "$') { std::string objLibName = li.substr(17, li.size() - 18); @@ -6255,7 +6248,7 @@ void cmGeneratorTarget::ComputeLinkImplementationLibraries( std::unique_ptr const cge = ge.Parse(*le); std::string const& evaluated = cge->Evaluate(this->LocalGenerator, config, false, head, &dagChecker); - cmSystemTools::ExpandListArgument(evaluated, llibs); + cmExpandList(evaluated, llibs); if (cge->GetHadHeadSensitiveCondition()) { impl.HadHeadSensitiveCondition = true; } diff --git a/Source/cmGhsMultiTargetGenerator.cxx b/Source/cmGhsMultiTargetGenerator.cxx index 00ebbb5..47c731b 100644 --- a/Source/cmGhsMultiTargetGenerator.cxx +++ b/Source/cmGhsMultiTargetGenerator.cxx @@ -469,7 +469,7 @@ void cmGhsMultiTargetGenerator::WriteSourceProperty( const char* prop = sf->GetProperty(propName); if (prop) { std::vector list; - cmSystemTools::ExpandListArgument(prop, list); + cmExpandList(prop, list); for (auto& p : list) { fout << " " << propFlag << p << std::endl; } diff --git a/Source/cmGlobalGenerator.cxx b/Source/cmGlobalGenerator.cxx index 4db5ca8..86fcae0 100644 --- a/Source/cmGlobalGenerator.cxx +++ b/Source/cmGlobalGenerator.cxx @@ -1149,7 +1149,7 @@ void cmGlobalGenerator::SetLanguageEnabledMaps(const std::string& l, std::string("CMAKE_") + std::string(l) + std::string("_IGNORE_EXTENSIONS"); std::string ignoreExts = mf->GetSafeDefinition(ignoreExtensionsVar); std::vector extensionList; - cmSystemTools::ExpandListArgument(ignoreExts, extensionList); + cmExpandList(ignoreExts, extensionList); for (std::string const& i : extensionList) { this->IgnoreExtensions[i] = true; } @@ -1162,7 +1162,7 @@ void cmGlobalGenerator::FillExtensionToLanguageMap(const std::string& l, std::string("_SOURCE_FILE_EXTENSIONS"); const std::string& exts = mf->GetSafeDefinition(extensionsVar); std::vector extensionList; - cmSystemTools::ExpandListArgument(exts, extensionList); + cmExpandList(exts, extensionList); for (std::string const& i : extensionList) { this->ExtensionToLanguage[i] = l; } @@ -1622,8 +1622,7 @@ void cmGlobalGenerator::FinalizeTargetCompileInfo() std::string const& standardIncludesStr = mf->GetSafeDefinition(standardIncludesVar); std::vector standardIncludesVec; - cmSystemTools::ExpandListArgument(standardIncludesStr, - standardIncludesVec); + cmExpandList(standardIncludesStr, standardIncludesVec); standardIncludesSet.insert(standardIncludesVec.begin(), standardIncludesVec.end()); } @@ -1734,7 +1733,7 @@ void cmGlobalGenerator::CheckTargetProperties() std::string incDirs = cmGeneratorExpression::Preprocess( incDirProp, cmGeneratorExpression::StripAllGeneratorExpressions); - cmSystemTools::ExpandListArgument(incDirs, incs); + cmExpandList(incDirs, incs); for (std::string const& incDir : incs) { if (incDir.size() > 9 && cmSystemTools::IsNOTFOUND(incDir.c_str())) { @@ -2977,7 +2976,7 @@ void cmGlobalGenerator::WriteSummary(cmGeneratorTarget* target) // List the target-wide labels. All sources in the target get // these labels. if (targetLabels) { - cmSystemTools::ExpandListArgument(targetLabels, labels); + cmExpandList(targetLabels, labels); if (!labels.empty()) { fout << "# Target labels\n"; for (std::string const& l : labels) { @@ -2992,12 +2991,11 @@ void cmGlobalGenerator::WriteSummary(cmGeneratorTarget* target) std::vector cmakeDirectoryLabelsList; if (directoryLabels) { - cmSystemTools::ExpandListArgument(directoryLabels, directoryLabelsList); + cmExpandList(directoryLabels, directoryLabelsList); } if (cmakeDirectoryLabels) { - cmSystemTools::ExpandListArgument(cmakeDirectoryLabels, - cmakeDirectoryLabelsList); + cmExpandList(cmakeDirectoryLabels, cmakeDirectoryLabelsList); } if (!directoryLabelsList.empty() || !cmakeDirectoryLabelsList.empty()) { @@ -3034,7 +3032,7 @@ void cmGlobalGenerator::WriteSummary(cmGeneratorTarget* target) if (const char* svalue = sf->GetProperty("LABELS")) { labels.clear(); Json::Value& lj_source_labels = lj_source["labels"] = Json::arrayValue; - cmSystemTools::ExpandListArgument(svalue, labels); + cmExpandList(svalue, labels); for (std::string const& label : labels) { fout << " " << label << "\n"; lj_source_labels.append(label); diff --git a/Source/cmGlobalGhsMultiGenerator.cxx b/Source/cmGlobalGhsMultiGenerator.cxx index 9f3dab7..4db829f 100644 --- a/Source/cmGlobalGhsMultiGenerator.cxx +++ b/Source/cmGlobalGhsMultiGenerator.cxx @@ -625,7 +625,7 @@ void cmGlobalGhsMultiGenerator::WriteMacros(std::ostream& fout, this->GetCMakeInstance()->GetCacheDefinition("GHS_GPJ_MACROS"); if (nullptr != ghsGpjMacros) { std::vector expandedList; - cmSystemTools::ExpandListArgument(std::string(ghsGpjMacros), expandedList); + cmExpandList(std::string(ghsGpjMacros), expandedList); for (std::string const& arg : expandedList) { fout << "macro " << arg << std::endl; } diff --git a/Source/cmGlobalVisualStudio71Generator.cxx b/Source/cmGlobalVisualStudio71Generator.cxx index 8e67fad..e0d86ca 100644 --- a/Source/cmGlobalVisualStudio71Generator.cxx +++ b/Source/cmGlobalVisualStudio71Generator.cxx @@ -201,7 +201,7 @@ void cmGlobalVisualStudio71Generator::WriteProjectConfigurations( if (target.GetProperty("EXTERNAL_MSPROJECT")) { if (const char* m = target.GetProperty("MAP_IMPORTED_CONFIG_" + cmSystemTools::UpperCase(i))) { - cmSystemTools::ExpandListArgument(m, mapConfig); + cmExpandList(m, mapConfig); if (!mapConfig.empty()) { dstConfig = mapConfig[0].c_str(); } diff --git a/Source/cmGlobalVisualStudio7Generator.cxx b/Source/cmGlobalVisualStudio7Generator.cxx index cd1ff61..45b66ae 100644 --- a/Source/cmGlobalVisualStudio7Generator.cxx +++ b/Source/cmGlobalVisualStudio7Generator.cxx @@ -512,8 +512,7 @@ void cmGlobalVisualStudio7Generator::WriteSLNGlobalSections( } fout << "\tGlobalSection(" << name << ") = " << sectionType << "\n"; std::vector keyValuePairs; - cmSystemTools::ExpandListArgument(root->GetMakefile()->GetProperty(it), - keyValuePairs); + cmExpandList(root->GetMakefile()->GetProperty(it), keyValuePairs); for (std::string const& itPair : keyValuePairs) { const std::string::size_type posEqual = itPair.find('='); if (posEqual != std::string::npos) { diff --git a/Source/cmGlobalVisualStudio8Generator.cxx b/Source/cmGlobalVisualStudio8Generator.cxx index cc6e421..275be96 100644 --- a/Source/cmGlobalVisualStudio8Generator.cxx +++ b/Source/cmGlobalVisualStudio8Generator.cxx @@ -250,7 +250,7 @@ void cmGlobalVisualStudio8Generator::WriteProjectConfigurations( if (target.GetProperty("EXTERNAL_MSPROJECT")) { if (const char* m = target.GetProperty("MAP_IMPORTED_CONFIG_" + cmSystemTools::UpperCase(i))) { - cmSystemTools::ExpandListArgument(m, mapConfig); + cmExpandList(m, mapConfig); if (!mapConfig.empty()) { dstConfig = mapConfig[0].c_str(); } diff --git a/Source/cmGlobalXCodeGenerator.cxx b/Source/cmGlobalXCodeGenerator.cxx index e3cafe3..19e64e4 100644 --- a/Source/cmGlobalXCodeGenerator.cxx +++ b/Source/cmGlobalXCodeGenerator.cxx @@ -882,7 +882,7 @@ cmXCodeObject* cmGlobalXCodeGenerator::CreateXCodeSourceFile( if (extraFileAttributes) { // Expand the list of attributes. std::vector attributes; - cmSystemTools::ExpandListArgument(extraFileAttributes, attributes); + cmExpandList(extraFileAttributes, attributes); // Store the attributes. for (const auto& attribute : attributes) { @@ -2482,10 +2482,8 @@ cmXCodeObject* cmGlobalXCodeGenerator::CreateUtilityTarget( std::string cmGlobalXCodeGenerator::AddConfigurations(cmXCodeObject* target, cmGeneratorTarget* gtgt) { - std::vector const configVector = - cmSystemTools::ExpandedListArgument( - this->CurrentMakefile->GetRequiredDefinition( - "CMAKE_CONFIGURATION_TYPES")); + std::vector const configVector = cmExpandedList( + this->CurrentMakefile->GetRequiredDefinition("CMAKE_CONFIGURATION_TYPES")); cmXCodeObject* configlist = this->CreateObject(cmXCodeObject::XCConfigurationList); cmXCodeObject* buildConfigurations = @@ -3223,8 +3221,7 @@ void cmGlobalXCodeGenerator::ComputeArchitectures(cmMakefile* mf) const char* osxArch = mf->GetDefinition("CMAKE_OSX_ARCHITECTURES"); const char* sysroot = mf->GetDefinition("CMAKE_OSX_SYSROOT"); if (osxArch && sysroot) { - cmSystemTools::ExpandListArgument(std::string(osxArch), - this->Architectures); + cmExpandList(std::string(osxArch), this->Architectures); } if (this->Architectures.empty()) { @@ -3627,7 +3624,7 @@ void cmGlobalXCodeGenerator::AppendDefines(BuildObjectListOrString& defs, // Expand the list of definitions. std::vector defines; - cmSystemTools::ExpandListArgument(defines_list, defines); + cmExpandList(defines_list, defines); // Store the definitions in the string. this->AppendDefines(defs, defines, dflag); diff --git a/Source/cmGraphVizWriter.cxx b/Source/cmGraphVizWriter.cxx index 9befb78..7d0ef83 100644 --- a/Source/cmGraphVizWriter.cxx +++ b/Source/cmGraphVizWriter.cxx @@ -15,6 +15,7 @@ #include "cmMakefile.h" #include "cmState.h" #include "cmStateSnapshot.h" +#include "cmStringAlgorithms.h" #include "cmSystemTools.h" #include "cmTarget.h" #include "cmake.h" @@ -234,8 +235,7 @@ void cmGraphVizWriter::ReadSettings( this->TargetsToIgnoreRegex.clear(); if (!ignoreTargetsRegexes.empty()) { std::vector ignoreTargetsRegExVector; - cmSystemTools::ExpandListArgument(ignoreTargetsRegexes, - ignoreTargetsRegExVector); + cmExpandList(ignoreTargetsRegexes, ignoreTargetsRegExVector); for (std::string const& currentRegexString : ignoreTargetsRegExVector) { cmsys::RegularExpression currentRegex; if (!currentRegex.compile(currentRegexString)) { diff --git a/Source/cmIDEOptions.cxx b/Source/cmIDEOptions.cxx index 7b992d7..e80aa8e 100644 --- a/Source/cmIDEOptions.cxx +++ b/Source/cmIDEOptions.cxx @@ -8,7 +8,7 @@ #include "cmAlgorithms.h" #include "cmIDEFlagTable.h" -#include "cmSystemTools.h" +#include "cmStringAlgorithms.h" cmIDEOptions::cmIDEOptions() { @@ -166,7 +166,7 @@ void cmIDEOptions::AddDefines(std::string const& defines) { if (!defines.empty()) { // Expand the list of definitions. - cmSystemTools::ExpandListArgument(defines, this->Defines); + cmExpandList(defines, this->Defines); } } void cmIDEOptions::AddDefines(const std::vector& defines) @@ -188,7 +188,7 @@ void cmIDEOptions::AddIncludes(std::string const& includes) { if (!includes.empty()) { // Expand the list of includes. - cmSystemTools::ExpandListArgument(includes, this->Includes); + cmExpandList(includes, this->Includes); } } void cmIDEOptions::AddIncludes(const std::vector& includes) diff --git a/Source/cmInstallCommand.cxx b/Source/cmInstallCommand.cxx index 76dafd9..51689a2 100644 --- a/Source/cmInstallCommand.cxx +++ b/Source/cmInstallCommand.cxx @@ -673,7 +673,7 @@ bool cmInstallCommand::HandleTargetsMode(std::vector const& args) const char* files = target.GetProperty("PRIVATE_HEADER"); if ((files) && (*files)) { std::vector relFiles; - cmSystemTools::ExpandListArgument(files, relFiles); + cmExpandList(files, relFiles); std::vector absFiles; if (!this->MakeFilesFullPath("PRIVATE_HEADER", relFiles, absFiles)) { return false; @@ -688,7 +688,7 @@ bool cmInstallCommand::HandleTargetsMode(std::vector const& args) files = target.GetProperty("PUBLIC_HEADER"); if ((files) && (*files)) { std::vector relFiles; - cmSystemTools::ExpandListArgument(files, relFiles); + cmExpandList(files, relFiles); std::vector absFiles; if (!this->MakeFilesFullPath("PUBLIC_HEADER", relFiles, absFiles)) { return false; @@ -703,7 +703,7 @@ bool cmInstallCommand::HandleTargetsMode(std::vector const& args) files = target.GetProperty("RESOURCE"); if ((files) && (*files)) { std::vector relFiles; - cmSystemTools::ExpandListArgument(files, relFiles); + cmExpandList(files, relFiles); std::vector absFiles; if (!this->MakeFilesFullPath("RESOURCE", relFiles, absFiles)) { return false; diff --git a/Source/cmInstallDirectoryGenerator.cxx b/Source/cmInstallDirectoryGenerator.cxx index 9357a5c..1d8210c 100644 --- a/Source/cmInstallDirectoryGenerator.cxx +++ b/Source/cmInstallDirectoryGenerator.cxx @@ -67,8 +67,7 @@ void cmInstallDirectoryGenerator::GenerateScriptForConfig( cmGeneratorExpression ge; for (std::string const& d : this->Directories) { std::unique_ptr cge = ge.Parse(d); - cmSystemTools::ExpandListArgument( - cge->Evaluate(this->LocalGenerator, config), dirs); + cmExpandList(cge->Evaluate(this->LocalGenerator, config), dirs); } // Make sure all dirs have absolute paths. diff --git a/Source/cmInstallFilesGenerator.cxx b/Source/cmInstallFilesGenerator.cxx index e8e82cc..c4048d4 100644 --- a/Source/cmInstallFilesGenerator.cxx +++ b/Source/cmInstallFilesGenerator.cxx @@ -4,7 +4,7 @@ #include "cmGeneratorExpression.h" #include "cmInstallType.h" -#include "cmSystemTools.h" +#include "cmStringAlgorithms.h" #include @@ -85,8 +85,7 @@ void cmInstallFilesGenerator::GenerateScriptForConfig( cmGeneratorExpression ge; for (std::string const& f : this->Files) { std::unique_ptr cge = ge.Parse(f); - cmSystemTools::ExpandListArgument( - cge->Evaluate(this->LocalGenerator, config), files); + cmExpandList(cge->Evaluate(this->LocalGenerator, config), files); } this->AddFilesInstallRule(os, config, indent, files); } diff --git a/Source/cmInstalledFile.cxx b/Source/cmInstalledFile.cxx index 537b4ec..9b481a2 100644 --- a/Source/cmInstalledFile.cxx +++ b/Source/cmInstalledFile.cxx @@ -5,6 +5,7 @@ #include "cmAlgorithms.h" #include "cmListFileCache.h" #include "cmMakefile.h" +#include "cmStringAlgorithms.h" #include "cmSystemTools.h" #include @@ -107,5 +108,5 @@ void cmInstalledFile::GetPropertyAsList(const std::string& prop, this->GetProperty(prop, value); list.clear(); - cmSystemTools::ExpandListArgument(value, list); + cmExpandList(value, list); } diff --git a/Source/cmLDConfigLDConfigTool.cxx b/Source/cmLDConfigLDConfigTool.cxx index 586ea96..d5cc621 100644 --- a/Source/cmLDConfigLDConfigTool.cxx +++ b/Source/cmLDConfigLDConfigTool.cxx @@ -4,6 +4,7 @@ #include "cmLDConfigLDConfigTool.h" #include "cmMakefile.h" #include "cmRuntimeDependencyArchive.h" +#include "cmStringAlgorithms.h" #include "cmSystemTools.h" #include "cmUVProcessChain.h" @@ -33,7 +34,7 @@ bool cmLDConfigLDConfigTool::GetLDConfigPaths(std::vector& paths) } std::vector ldConfigCommand; - cmSystemTools::ExpandListArgument(ldConfigPath, ldConfigCommand); + cmExpandList(ldConfigPath, ldConfigCommand); ldConfigCommand.emplace_back("-v"); ldConfigCommand.emplace_back("-N"); // Don't rebuild the cache. ldConfigCommand.emplace_back("-X"); // Don't update links. diff --git a/Source/cmListCommand.cxx b/Source/cmListCommand.cxx index 868f564..cbb1d3a 100644 --- a/Source/cmListCommand.cxx +++ b/Source/cmListCommand.cxx @@ -119,7 +119,7 @@ bool cmListCommand::GetList(std::vector& list, return true; } // expand the variable into a list - cmSystemTools::ExpandListArgument(listString, list, true); + cmExpandList(listString, list, true); // if no empty elements then just return if (std::find(list.begin(), list.end(), std::string()) == list.end()) { return true; @@ -132,7 +132,7 @@ bool cmListCommand::GetList(std::vector& list, // ExpandListArgument without the true which will remove // empty values list.clear(); - cmSystemTools::ExpandListArgument(listString, list); + cmExpandList(listString, list); std::string warn = cmPolicies::GetPolicyWarning(cmPolicies::CMP0007); warn += " List has value = ["; warn += listString; @@ -145,7 +145,7 @@ bool cmListCommand::GetList(std::vector& list, // ExpandListArgument without the true which will remove // empty values list.clear(); - cmSystemTools::ExpandListArgument(listString, list); + cmExpandList(listString, list); return true; case cmPolicies::NEW: return true; diff --git a/Source/cmListFileCache.cxx b/Source/cmListFileCache.cxx index df0d00c..7ef475a 100644 --- a/Source/cmListFileCache.cxx +++ b/Source/cmListFileCache.cxx @@ -7,6 +7,7 @@ #include "cmMessenger.h" #include "cmState.h" #include "cmStateDirectory.h" +#include "cmStringAlgorithms.h" #include "cmSystemTools.h" #include @@ -483,7 +484,7 @@ std::vector> ExpandListWithBacktrace( { std::vector> result; std::vector tmp; - cmSystemTools::ExpandListArgument(list, tmp); + cmExpandList(list, tmp); result.reserve(tmp.size()); for (std::string& i : tmp) { result.emplace_back(std::move(i), bt); diff --git a/Source/cmLocalGenerator.cxx b/Source/cmLocalGenerator.cxx index 228495b..c3cfc5f 100644 --- a/Source/cmLocalGenerator.cxx +++ b/Source/cmLocalGenerator.cxx @@ -311,7 +311,7 @@ void cmLocalGenerator::GenerateTestFiles() this->Makefile->GetProperty("TEST_INCLUDE_FILES"); if (testIncludeFiles) { std::vector includesList; - cmSystemTools::ExpandListArgument(testIncludeFiles, includesList); + cmExpandList(testIncludeFiles, includesList); for (std::string const& i : includesList) { fout << "include(\"" << i << "\")" << std::endl; } @@ -902,7 +902,7 @@ void cmLocalGenerator::AddCompileOptions(std::string& flags, std::string isJMCEnabled = cge->Evaluate(this, config); if (cmSystemTools::IsOn(isJMCEnabled)) { std::vector optVec; - cmSystemTools::ExpandListArgument(jmc, optVec); + cmExpandList(jmc, optVec); this->AppendCompileOptions(flags, optVec); } } @@ -955,7 +955,7 @@ std::vector> cmLocalGenerator::GetIncludeDirectoriesImplicit( { std::string const value = this->Makefile->GetSafeDefinition( cmStrCat("CMAKE_", lang, "_STANDARD_INCLUDE_DIRECTORIES")); - cmSystemTools::ExpandListArgument(value, userStandardDirs); + cmExpandList(value, userStandardDirs); for (std::string& usd : userStandardDirs) { cmSystemTools::ConvertToUnixSlashes(usd); } @@ -981,7 +981,7 @@ std::vector> cmLocalGenerator::GetIncludeDirectoriesImplicit( cmStrCat("CMAKE_", lang, "_IMPLICIT_INCLUDE_DIRECTORIES")); if (value != nullptr) { size_t const impDirVecOldSize = impDirVec.size(); - cmSystemTools::ExpandListArgument(value, impDirVec); + cmExpandList(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]); @@ -1778,7 +1778,7 @@ void cmLocalGenerator::AddCompilerRequirementFlag( if (const char* opt = target->Target->GetMakefile()->GetDefinition(option_flag)) { std::vector optVec; - cmSystemTools::ExpandListArgument(opt, optVec); + cmExpandList(opt, optVec); for (std::string const& i : optVec) { this->AppendFlagEscape(flags, i); } @@ -1807,7 +1807,7 @@ void cmLocalGenerator::AddCompilerRequirementFlag( this->IssueMessage(MessageType::FATAL_ERROR, e.str()); } else { std::vector optVec; - cmSystemTools::ExpandListArgument(opt, optVec); + cmExpandList(opt, optVec); for (std::string const& i : optVec) { this->AppendFlagEscape(flags, i); } @@ -1868,7 +1868,7 @@ void cmLocalGenerator::AddCompilerRequirementFlag( std::string const& opt = target->Target->GetMakefile()->GetRequiredDefinition(option_flag); std::vector optVec; - cmSystemTools::ExpandListArgument(opt, optVec); + cmExpandList(opt, optVec); for (std::string const& i : optVec) { this->AppendFlagEscape(flags, i); } @@ -1885,7 +1885,7 @@ void cmLocalGenerator::AddCompilerRequirementFlag( if (const char* opt = target->Target->GetMakefile()->GetDefinition(option_flag)) { std::vector optVec; - cmSystemTools::ExpandListArgument(opt, optVec); + cmExpandList(opt, optVec); for (std::string const& i : optVec) { this->AppendFlagEscape(flags, i); } @@ -2081,7 +2081,7 @@ void cmLocalGenerator::AddPositionIndependentFlags(std::string& flags, } if (!picFlags.empty()) { std::vector options; - cmSystemTools::ExpandListArgument(picFlags, options); + cmExpandList(picFlags, options); for (std::string const& o : options) { this->AppendFlagEscape(flags, o); } @@ -2153,7 +2153,7 @@ void cmLocalGenerator::AppendIPOLinkerFlags(std::string& flags, } std::vector flagsList; - cmSystemTools::ExpandListArgument(rawFlagsList, flagsList); + cmExpandList(rawFlagsList, flagsList); for (std::string const& o : flagsList) { this->AppendFlagEscape(flags, o); } @@ -2189,7 +2189,7 @@ void cmLocalGenerator::AppendPositionIndependentLinkerFlags( } std::vector flagsList; - cmSystemTools::ExpandListArgument(pieFlags, flagsList); + cmExpandList(pieFlags, flagsList); for (const auto& flag : flagsList) { this->AppendFlagEscape(flags, flag); } @@ -2206,7 +2206,7 @@ void cmLocalGenerator::AppendCompileOptions(std::string& options, // Expand the list of options. std::vector options_vec; - cmSystemTools::ExpandListArgument(options_list, options_vec); + cmExpandList(options_list, options_vec); this->AppendCompileOptions(options, options_vec, regex); } @@ -2241,7 +2241,7 @@ void cmLocalGenerator::AppendIncludeDirectories( // Expand the list of includes. std::vector includes_vec; - cmSystemTools::ExpandListArgument(includes_list, includes_vec); + cmExpandList(includes_list, includes_vec); this->AppendIncludeDirectories(includes, includes_vec, sourceFile); } @@ -2369,7 +2369,7 @@ void cmLocalGenerator::AppendFeatureOptions(std::string& flags, cmStrCat("CMAKE_", lang, "_COMPILE_OPTIONS_", feature)); if (optionList != nullptr) { std::vector options; - cmSystemTools::ExpandListArgument(optionList, options); + cmExpandList(optionList, options); for (std::string const& o : options) { this->AppendFlagEscape(flags, o); } diff --git a/Source/cmLocalNinjaGenerator.cxx b/Source/cmLocalNinjaGenerator.cxx index 248f4a6..ec35551 100644 --- a/Source/cmLocalNinjaGenerator.cxx +++ b/Source/cmLocalNinjaGenerator.cxx @@ -25,6 +25,7 @@ #include "cmSourceFile.h" #include "cmState.h" #include "cmStateTypes.h" +#include "cmStringAlgorithms.h" #include "cmSystemTools.h" #include "cmake.h" #include "cmsys/FStream.hxx" @@ -222,7 +223,7 @@ void cmLocalNinjaGenerator::WritePools(std::ostream& os) cmGlobalNinjaGenerator::WriteComment( os, "Pools defined by global property JOB_POOLS"); std::vector pools; - cmSystemTools::ExpandListArgument(jobpools, pools); + cmExpandList(jobpools, pools); for (std::string const& pool : pools) { const std::string::size_type eq = pool.find('='); unsigned int jobs; @@ -613,7 +614,7 @@ void cmLocalNinjaGenerator::AdditionalCleanFiles() { cmGeneratorExpression ge; auto cge = ge.Parse(prop_value); - cmSystemTools::ExpandListArgument( + cmExpandList( cge->Evaluate(this, this->Makefile->GetSafeDefinition("CMAKE_BUILD_TYPE")), cleanFiles); diff --git a/Source/cmLocalUnixMakefileGenerator3.cxx b/Source/cmLocalUnixMakefileGenerator3.cxx index cfad31a..a089682 100644 --- a/Source/cmLocalUnixMakefileGenerator3.cxx +++ b/Source/cmLocalUnixMakefileGenerator3.cxx @@ -1102,7 +1102,7 @@ void cmLocalUnixMakefileGenerator3::AppendDirectoryCleanCommand( this->Makefile->GetProperty("ADDITIONAL_CLEAN_FILES")) { cmGeneratorExpression ge; std::unique_ptr cge = ge.Parse(prop_value); - cmSystemTools::ExpandListArgument( + cmExpandList( cge->Evaluate(this, this->Makefile->GetSafeDefinition("CMAKE_BUILD_TYPE")), cleanFiles); @@ -1466,8 +1466,7 @@ bool cmLocalUnixMakefileGenerator3::ScanDependencies( // for each language we need to scan, scan it std::vector langs; - cmSystemTools::ExpandListArgument( - mf->GetSafeDefinition("CMAKE_DEPENDS_LANGUAGES"), langs); + cmExpandList(mf->GetSafeDefinition("CMAKE_DEPENDS_LANGUAGES"), langs); for (std::string const& lang : langs) { // construct the checker // Create the scanner for this language @@ -1512,7 +1511,7 @@ void cmLocalUnixMakefileGenerator3::CheckMultipleOutputs(bool verbose) // Convert the string to a list and preserve empty entries. std::vector pairs; - cmSystemTools::ExpandListArgument(pairs_string, pairs, true); + cmExpandList(pairs_string, pairs, true); for (std::vector::const_iterator i = pairs.begin(); i != pairs.end() && (i + 1) != pairs.end();) { const std::string& depender = *i++; @@ -1744,7 +1743,7 @@ void cmLocalUnixMakefileGenerator3::ClearDependencies(cmMakefile* mf, return; } std::vector files; - cmSystemTools::ExpandListArgument(infoDef, files); + cmExpandList(infoDef, files); // Each depend information file corresponds to a target. Clear the // dependencies for that target. @@ -1912,11 +1911,11 @@ void cmLocalUnixMakefileGenerator3::WriteDependLanguageInfo( std::vector transformRules; if (const char* xform = this->Makefile->GetProperty("IMPLICIT_DEPENDS_INCLUDE_TRANSFORM")) { - cmSystemTools::ExpandListArgument(xform, transformRules); + cmExpandList(xform, transformRules); } if (const char* xform = target->GetProperty("IMPLICIT_DEPENDS_INCLUDE_TRANSFORM")) { - cmSystemTools::ExpandListArgument(xform, transformRules); + cmExpandList(xform, transformRules); } if (!transformRules.empty()) { cmakefileStream << "set(CMAKE_INCLUDE_TRANSFORMS\n"; diff --git a/Source/cmLocalVisualStudio7Generator.cxx b/Source/cmLocalVisualStudio7Generator.cxx index 8154f3e..3d76396 100644 --- a/Source/cmLocalVisualStudio7Generator.cxx +++ b/Source/cmLocalVisualStudio7Generator.cxx @@ -1526,7 +1526,7 @@ cmLocalVisualStudio7GeneratorFCInfo::cmLocalVisualStudio7GeneratorFCInfo( // Check for extra object-file dependencies. if (const char* deps = sf.GetProperty("OBJECT_DEPENDS")) { std::vector depends; - cmSystemTools::ExpandListArgument(deps, depends); + cmExpandList(deps, depends); const char* sep = ""; for (std::vector::iterator j = depends.begin(); j != depends.end(); ++j) { diff --git a/Source/cmMakefile.cxx b/Source/cmMakefile.cxx index f6f4737..657c3bf 100644 --- a/Source/cmMakefile.cxx +++ b/Source/cmMakefile.cxx @@ -1349,7 +1349,7 @@ bool cmMakefile::ParseDefineFlag(std::string const& def, bool remove) if (const char* cdefs = this->GetProperty("COMPILE_DEFINITIONS")) { // Expand the list. std::vector defs; - cmSystemTools::ExpandListArgument(cdefs, defs); + cmExpandList(cdefs, defs); // Recompose the list without the definition. std::vector::const_iterator defEnd = @@ -1837,7 +1837,7 @@ void cmMakefile::AddCacheDefinition(const std::string& name, const char* value, std::vector files; nvalue = value ? value : ""; - cmSystemTools::ExpandListArgument(nvalue, files); + cmExpandList(nvalue, files); nvalue.clear(); for (cc = 0; cc < files.size(); cc++) { if (!cmSystemTools::IsOff(files[cc])) { @@ -1953,7 +1953,7 @@ void cmMakefile::AddGlobalLinkInformation(cmTarget& target) if (const char* linkLibsProp = this->GetProperty("LINK_LIBRARIES")) { std::vector linkLibs; - cmSystemTools::ExpandListArgument(linkLibsProp, linkLibs); + cmExpandList(linkLibsProp, linkLibs); for (std::vector::iterator j = linkLibs.begin(); j != linkLibs.end(); ++j) { @@ -2281,7 +2281,7 @@ void cmMakefile::ExpandVariablesCMP0019() if (const char* linkLibsProp = this->GetProperty("LINK_LIBRARIES")) { std::vector linkLibs; - cmSystemTools::ExpandListArgument(linkLibsProp, linkLibs); + cmExpandList(linkLibsProp, linkLibs); for (std::vector::iterator l = linkLibs.begin(); l != linkLibs.end(); ++l) { @@ -3050,7 +3050,7 @@ std::string cmMakefile::GetConfigurations(std::vector& configs, if (this->GetGlobalGenerator()->IsMultiConfig()) { if (const char* configTypes = this->GetDefinition("CMAKE_CONFIGURATION_TYPES")) { - cmSystemTools::ExpandListArgument(configTypes, configs); + cmExpandList(configTypes, configs); } return ""; } @@ -3167,7 +3167,7 @@ bool cmMakefile::ExpandArguments(std::vector const& inArgs, if (i.Delim == cmListFileArgument::Quoted) { outArgs.push_back(value); } else { - cmSystemTools::ExpandListArgument(value, outArgs); + cmExpandList(value, outArgs); } } return !cmSystemTools::GetFatalErrorOccured(); @@ -3200,7 +3200,7 @@ bool cmMakefile::ExpandArguments( outArgs.emplace_back(value, true); } else { std::vector stringArgs; - cmSystemTools::ExpandListArgument(value, stringArgs); + cmExpandList(value, stringArgs); for (std::string const& stringArg : stringArgs) { outArgs.emplace_back(stringArg, false); } @@ -3558,7 +3558,7 @@ std::string cmMakefile::GetModulesFile(const std::string& filename, const char* cmakeModulePath = this->GetDefinition("CMAKE_MODULE_PATH"); if (cmakeModulePath) { std::vector modulePath; - cmSystemTools::ExpandListArgument(cmakeModulePath, modulePath); + cmExpandList(cmakeModulePath, modulePath); // Look through the possible module directories. for (std::string itempl : modulePath) { @@ -3883,7 +3883,7 @@ void cmMakefile::AddCMakeDependFilesFromUser() { std::vector deps; if (const char* deps_str = this->GetProperty("CMAKE_CONFIGURE_DEPENDS")) { - cmSystemTools::ExpandListArgument(deps_str, deps); + cmExpandList(deps_str, deps); } for (std::string const& dep : deps) { if (cmSystemTools::FileIsFullPath(dep)) { @@ -4378,7 +4378,7 @@ bool cmMakefile::AddRequiredTargetFeature(cmTarget* target, } std::vector availableFeatures; - cmSystemTools::ExpandListArgument(features, availableFeatures); + cmExpandList(features, availableFeatures); if (std::find(availableFeatures.begin(), availableFeatures.end(), feature) == availableFeatures.end()) { std::ostringstream e; @@ -4648,31 +4648,31 @@ void cmMakefile::CheckNeededCxxLanguage(const std::string& feature, if (const char* propCxx98 = this->GetDefinition("CMAKE_CXX98_COMPILE_FEATURES")) { std::vector props; - cmSystemTools::ExpandListArgument(propCxx98, props); + cmExpandList(propCxx98, props); needCxx98 = std::find(props.begin(), props.end(), feature) != props.end(); } if (const char* propCxx11 = this->GetDefinition("CMAKE_CXX11_COMPILE_FEATURES")) { std::vector props; - cmSystemTools::ExpandListArgument(propCxx11, props); + cmExpandList(propCxx11, props); needCxx11 = std::find(props.begin(), props.end(), feature) != props.end(); } if (const char* propCxx14 = this->GetDefinition("CMAKE_CXX14_COMPILE_FEATURES")) { std::vector props; - cmSystemTools::ExpandListArgument(propCxx14, props); + cmExpandList(propCxx14, props); needCxx14 = std::find(props.begin(), props.end(), feature) != props.end(); } if (const char* propCxx17 = this->GetDefinition("CMAKE_CXX17_COMPILE_FEATURES")) { std::vector props; - cmSystemTools::ExpandListArgument(propCxx17, props); + cmExpandList(propCxx17, props); needCxx17 = std::find(props.begin(), props.end(), feature) != props.end(); } if (const char* propCxx20 = this->GetDefinition("CMAKE_CXX20_COMPILE_FEATURES")) { std::vector props; - cmSystemTools::ExpandListArgument(propCxx20, props); + cmExpandList(propCxx20, props); needCxx20 = std::find(props.begin(), props.end(), feature) != props.end(); } } @@ -4772,19 +4772,19 @@ void cmMakefile::CheckNeededCLanguage(const std::string& feature, if (const char* propC90 = this->GetDefinition("CMAKE_C90_COMPILE_FEATURES")) { std::vector props; - cmSystemTools::ExpandListArgument(propC90, props); + cmExpandList(propC90, props); needC90 = std::find(props.begin(), props.end(), feature) != props.end(); } if (const char* propC99 = this->GetDefinition("CMAKE_C99_COMPILE_FEATURES")) { std::vector props; - cmSystemTools::ExpandListArgument(propC99, props); + cmExpandList(propC99, props); needC99 = std::find(props.begin(), props.end(), feature) != props.end(); } if (const char* propC11 = this->GetDefinition("CMAKE_C11_COMPILE_FEATURES")) { std::vector props; - cmSystemTools::ExpandListArgument(propC11, props); + cmExpandList(propC11, props); needC11 = std::find(props.begin(), props.end(), feature) != props.end(); } } diff --git a/Source/cmMakefileExecutableTargetGenerator.cxx b/Source/cmMakefileExecutableTargetGenerator.cxx index 31ee4fa..1335f13 100644 --- a/Source/cmMakefileExecutableTargetGenerator.cxx +++ b/Source/cmMakefileExecutableTargetGenerator.cxx @@ -165,7 +165,7 @@ void cmMakefileExecutableTargetGenerator::WriteDeviceExecutableRule( const std::string linkRuleVar = "CMAKE_CUDA_DEVICE_LINK_EXECUTABLE"; const std::string linkRule = this->GetLinkRule(linkRuleVar); std::vector commands1; - cmSystemTools::ExpandListArgument(linkRule, real_link_commands); + cmExpandList(linkRule, real_link_commands); bool useResponseFileForObjects = this->CheckUseResponseFileForObjects(linkLanguage); @@ -488,7 +488,7 @@ void cmMakefileExecutableTargetGenerator::WriteExecutableRule(bool relink) linkLanguage, this->ConfigName); std::string linkRule = this->GetLinkRule(linkRuleVar); std::vector commands1; - cmSystemTools::ExpandListArgument(linkRule, real_link_commands); + cmExpandList(linkRule, real_link_commands); if (this->GeneratorTarget->IsExecutableWithExports()) { // If a separate rule for creating an import library is specified // add it now. @@ -496,7 +496,7 @@ void cmMakefileExecutableTargetGenerator::WriteExecutableRule(bool relink) implibRuleVar += linkLanguage; implibRuleVar += "_CREATE_IMPORT_LIBRARY"; if (const char* rule = this->Makefile->GetDefinition(implibRuleVar)) { - cmSystemTools::ExpandListArgument(rule, real_link_commands); + cmExpandList(rule, real_link_commands); } } diff --git a/Source/cmMakefileLibraryTargetGenerator.cxx b/Source/cmMakefileLibraryTargetGenerator.cxx index 4621da4..eb0c30c 100644 --- a/Source/cmMakefileLibraryTargetGenerator.cxx +++ b/Source/cmMakefileLibraryTargetGenerator.cxx @@ -370,7 +370,7 @@ void cmMakefileLibraryTargetGenerator::WriteDeviceLibraryRules( // Construct the main link rule and expand placeholders. rulePlaceholderExpander->SetTargetImpLib(targetOutputReal); std::string linkRule = this->GetLinkRule(linkRuleVar); - cmSystemTools::ExpandListArgument(linkRule, real_link_commands); + cmExpandList(linkRule, real_link_commands); // Expand placeholders. for (std::string& real_link_command : real_link_commands) { @@ -650,7 +650,7 @@ void cmMakefileLibraryTargetGenerator::WriteLibraryRules( arCreateVar, linkLanguage, this->ConfigName); if (const char* rule = this->Makefile->GetDefinition(arCreateVar)) { - cmSystemTools::ExpandListArgument(rule, archiveCreateCommands); + cmExpandList(rule, archiveCreateCommands); } std::string arAppendVar = "CMAKE_"; arAppendVar += linkLanguage; @@ -660,7 +660,7 @@ void cmMakefileLibraryTargetGenerator::WriteLibraryRules( arAppendVar, linkLanguage, this->ConfigName); if (const char* rule = this->Makefile->GetDefinition(arAppendVar)) { - cmSystemTools::ExpandListArgument(rule, archiveAppendCommands); + cmExpandList(rule, archiveAppendCommands); } std::string arFinishVar = "CMAKE_"; arFinishVar += linkLanguage; @@ -670,7 +670,7 @@ void cmMakefileLibraryTargetGenerator::WriteLibraryRules( arFinishVar, linkLanguage, this->ConfigName); if (const char* rule = this->Makefile->GetDefinition(arFinishVar)) { - cmSystemTools::ExpandListArgument(rule, archiveFinishCommands); + cmExpandList(rule, archiveFinishCommands); } } @@ -880,7 +880,7 @@ void cmMakefileLibraryTargetGenerator::WriteLibraryRules( } else { // Get the set of commands. std::string linkRule = this->GetLinkRule(linkRuleVar); - cmSystemTools::ExpandListArgument(linkRule, real_link_commands); + cmExpandList(linkRule, real_link_commands); if (this->GeneratorTarget->GetPropertyAsBool("LINK_WHAT_YOU_USE") && (this->GeneratorTarget->GetType() == cmStateEnums::SHARED_LIBRARY)) { std::string cmakeCommand = this->LocalGenerator->ConvertToOutputFormat( diff --git a/Source/cmMakefileTargetGenerator.cxx b/Source/cmMakefileTargetGenerator.cxx index 7b26324..6a79615 100644 --- a/Source/cmMakefileTargetGenerator.cxx +++ b/Source/cmMakefileTargetGenerator.cxx @@ -159,10 +159,9 @@ void cmMakefileTargetGenerator::WriteTargetBuildRules() std::vector files; cmGeneratorExpression ge; std::unique_ptr cge = ge.Parse(prop_value); - cmSystemTools::ExpandListArgument( - cge->Evaluate(this->LocalGenerator, config, false, this->GeneratorTarget, - nullptr, nullptr), - files); + cmExpandList(cge->Evaluate(this->LocalGenerator, config, false, + this->GeneratorTarget, nullptr, nullptr), + files); return files; }; @@ -680,12 +679,12 @@ void cmMakefileTargetGenerator::WriteObjectBuildFile( } const std::string& compileRule = this->Makefile->GetRequiredDefinition(cmdVar); - cmSystemTools::ExpandListArgument(compileRule, compileCommands); + cmExpandList(compileRule, compileCommands); } else { const std::string cmdVar = "CMAKE_" + lang + "_COMPILE_OBJECT"; const std::string& compileRule = this->Makefile->GetRequiredDefinition(cmdVar); - cmSystemTools::ExpandListArgument(compileRule, compileCommands); + cmExpandList(compileRule, compileCommands); } if (this->Makefile->IsOn("CMAKE_EXPORT_COMPILE_COMMANDS") && @@ -783,7 +782,7 @@ void cmMakefileTargetGenerator::WriteObjectBuildFile( // goes to the beginning of the command line. if (!compileCommands.empty() && !compilerLauncher.empty()) { std::vector args; - cmSystemTools::ExpandListArgument(compilerLauncher, args, true); + cmExpandList(compilerLauncher, args, true); if (!args.empty()) { args[0] = this->LocalGenerator->ConvertToOutputFormat( args[0], cmOutputConverter::SHELL); @@ -822,7 +821,7 @@ void cmMakefileTargetGenerator::WriteObjectBuildFile( std::vector outputs(1, relativeObj); if (const char* extra_outputs_str = source.GetProperty("OBJECT_OUTPUTS")) { // Register these as extra files to clean. - cmSystemTools::ExpandListArgument(extra_outputs_str, outputs); + cmExpandList(extra_outputs_str, outputs); this->CleanFiles.insert(outputs.begin() + 1, outputs.end()); } @@ -860,7 +859,7 @@ void cmMakefileTargetGenerator::WriteObjectBuildFile( if (const char* preprocessRule = this->Makefile->GetDefinition(preprocessRuleVar)) { std::vector preprocessCommands; - cmSystemTools::ExpandListArgument(preprocessRule, preprocessCommands); + cmExpandList(preprocessRule, preprocessCommands); std::string shellObjI = this->LocalGenerator->ConvertToOutputFormat( objI, cmOutputConverter::SHELL); @@ -907,7 +906,7 @@ void cmMakefileTargetGenerator::WriteObjectBuildFile( if (const char* assemblyRule = this->Makefile->GetDefinition(assemblyRuleVar)) { std::vector assemblyCommands; - cmSystemTools::ExpandListArgument(assemblyRule, assemblyCommands); + cmExpandList(assemblyRule, assemblyCommands); std::string shellObjS = this->LocalGenerator->ConvertToOutputFormat( objS, cmOutputConverter::SHELL); @@ -1182,7 +1181,7 @@ void cmMakefileTargetGenerator::WriteObjectDependRules( // shared between the object file and dependency scanning rule. depends.push_back(source.GetFullPath()); if (const char* objectDeps = source.GetProperty("OBJECT_DEPENDS")) { - cmSystemTools::ExpandListArgument(objectDeps, depends); + cmExpandList(objectDeps, depends); } } diff --git a/Source/cmMessageCommand.cxx b/Source/cmMessageCommand.cxx index 66d3c88..dec32fa 100644 --- a/Source/cmMessageCommand.cxx +++ b/Source/cmMessageCommand.cxx @@ -104,10 +104,9 @@ bool cmMessageCommand::InitialPass(std::vector const& args, // Check if any indentation has requested: // `CMAKE_MESSAGE_INDENT` is a list of "padding" pieces // to be joined and prepended to the message lines. - auto indent = - cmJoin(cmSystemTools::ExpandedListArgument( - this->Makefile->GetSafeDefinition("CMAKE_MESSAGE_INDENT")), - ""); + auto indent = cmJoin(cmExpandedList(this->Makefile->GetSafeDefinition( + "CMAKE_MESSAGE_INDENT")), + ""); // Make every line of the `message` indented // NOTE Can't reuse `cmDocumentationFormatter::PrintPreformatted` // here cuz it appends `\n` to the EOM ;-( diff --git a/Source/cmNinjaNormalTargetGenerator.cxx b/Source/cmNinjaNormalTargetGenerator.cxx index 865ae7d..4ebeb60 100644 --- a/Source/cmNinjaNormalTargetGenerator.cxx +++ b/Source/cmNinjaNormalTargetGenerator.cxx @@ -440,12 +440,12 @@ std::vector cmNinjaNormalTargetGenerator::ComputeDeviceLinkCmd() case cmStateEnums::MODULE_LIBRARY: { const std::string cudaLinkCmd( this->GetMakefile()->GetDefinition("CMAKE_CUDA_DEVICE_LINK_LIBRARY")); - cmSystemTools::ExpandListArgument(cudaLinkCmd, linkCmds); + cmExpandList(cudaLinkCmd, linkCmds); } break; case cmStateEnums::EXECUTABLE: { const std::string cudaLinkCmd(this->GetMakefile()->GetDefinition( "CMAKE_CUDA_DEVICE_LINK_EXECUTABLE")); - cmSystemTools::ExpandListArgument(cudaLinkCmd, linkCmds); + cmExpandList(cudaLinkCmd, linkCmds); } break; default: break; @@ -474,7 +474,7 @@ std::vector cmNinjaNormalTargetGenerator::ComputeLinkCmd() linkCmdStr += rule; } } - cmSystemTools::ExpandListArgument(linkCmdStr, linkCmds); + cmExpandList(linkCmdStr, linkCmds); if (this->GetGeneratorTarget()->GetPropertyAsBool("LINK_WHAT_YOU_USE")) { std::string cmakeCommand = this->GetLocalGenerator()->ConvertToOutputFormat( @@ -510,7 +510,7 @@ std::vector cmNinjaNormalTargetGenerator::ComputeLinkCmd() linkCmdVar, this->TargetLinkLanguage, this->GetConfigName()); std::string const& linkCmd = mf->GetRequiredDefinition(linkCmdVar); - cmSystemTools::ExpandListArgument(linkCmd, linkCmds); + cmExpandList(linkCmd, linkCmds); } { std::string linkCmdVar = "CMAKE_"; @@ -521,7 +521,7 @@ std::vector cmNinjaNormalTargetGenerator::ComputeLinkCmd() linkCmdVar, this->TargetLinkLanguage, this->GetConfigName()); std::string const& linkCmd = mf->GetRequiredDefinition(linkCmdVar); - cmSystemTools::ExpandListArgument(linkCmd, linkCmds); + cmExpandList(linkCmd, linkCmds); } #ifdef __APPLE__ // On macOS ranlib truncates the fractional part of the static archive diff --git a/Source/cmNinjaTargetGenerator.cxx b/Source/cmNinjaTargetGenerator.cxx index c3459be..64b2bf6 100644 --- a/Source/cmNinjaTargetGenerator.cxx +++ b/Source/cmNinjaTargetGenerator.cxx @@ -548,8 +548,7 @@ void cmNinjaTargetGenerator::WriteCompileRule(const std::string& lang) // Lookup the explicit preprocessing rule. std::string ppVar = "CMAKE_" + lang; ppVar += "_PREPROCESS_SOURCE"; - cmSystemTools::ExpandListArgument( - this->GetMakefile()->GetRequiredDefinition(ppVar), ppCmds); + cmExpandList(this->GetMakefile()->GetRequiredDefinition(ppVar), ppCmds); } for (std::string& i : ppCmds) { @@ -686,11 +685,11 @@ void cmNinjaTargetGenerator::WriteCompileRule(const std::string& lang) cmdVar = "CMAKE_CUDA_COMPILE_WHOLE_COMPILATION"; } const std::string& compileCmd = mf->GetRequiredDefinition(cmdVar); - cmSystemTools::ExpandListArgument(compileCmd, compileCmds); + cmExpandList(compileCmd, compileCmds); } else { const std::string cmdVar = "CMAKE_" + lang + "_COMPILE_OBJECT"; const std::string& compileCmd = mf->GetRequiredDefinition(cmdVar); - cmSystemTools::ExpandListArgument(compileCmd, compileCmds); + cmExpandList(compileCmd, compileCmds); } // See if we need to use a compiler launcher like ccache or distcc @@ -754,7 +753,7 @@ void cmNinjaTargetGenerator::WriteCompileRule(const std::string& lang) // goes to the beginning of the command line. if (!compileCmds.empty() && !compilerLauncher.empty()) { std::vector args; - cmSystemTools::ExpandListArgument(compilerLauncher, args, true); + cmExpandList(compilerLauncher, args, true); if (!args.empty()) { args[0] = this->LocalGenerator->ConvertToOutputFormat( args[0], cmOutputConverter::SHELL); @@ -998,8 +997,7 @@ void cmNinjaTargetGenerator::WriteObjectBuildStatement( objBuild.ExplicitDeps.push_back(sourceFileName); if (const char* objectDeps = source->GetProperty("OBJECT_DEPENDS")) { - std::vector depList = - cmSystemTools::ExpandedListArgument(objectDeps); + std::vector depList = cmExpandedList(objectDeps); for (std::string& odi : depList) { if (cmSystemTools::FileIsFullPath(odi)) { odi = cmSystemTools::CollapseFullPath(odi); @@ -1152,7 +1150,7 @@ void cmNinjaTargetGenerator::WriteObjectBuildStatement( if (const char* objectOutputs = source->GetProperty("OBJECT_OUTPUTS")) { cmNinjaBuild build("phony"); build.Comment = "Additional output files."; - build.Outputs = cmSystemTools::ExpandedListArgument(objectOutputs); + build.Outputs = cmExpandedList(objectOutputs); std::transform(build.Outputs.begin(), build.Outputs.end(), build.Outputs.begin(), MapToNinjaPath()); build.ExplicitDeps = objBuild.Outputs; @@ -1301,12 +1299,12 @@ void cmNinjaTargetGenerator::ExportObjectCompileCommand( } const std::string& compileCmd = this->GetMakefile()->GetRequiredDefinition(cmdVar); - cmSystemTools::ExpandListArgument(compileCmd, compileCmds); + cmExpandList(compileCmd, compileCmds); } else { const std::string cmdVar = "CMAKE_" + language + "_COMPILE_OBJECT"; const std::string& compileCmd = this->GetMakefile()->GetRequiredDefinition(cmdVar); - cmSystemTools::ExpandListArgument(compileCmd, compileCmds); + cmExpandList(compileCmd, compileCmds); } std::unique_ptr rulePlaceholderExpander( @@ -1333,11 +1331,10 @@ void cmNinjaTargetGenerator::AdditionalCleanFiles() { cmGeneratorExpression ge; auto cge = ge.Parse(prop_value); - cmSystemTools::ExpandListArgument( - cge->Evaluate(lg, - this->Makefile->GetSafeDefinition("CMAKE_BUILD_TYPE"), - false, this->GeneratorTarget, nullptr, nullptr), - cleanFiles); + cmExpandList(cge->Evaluate( + lg, this->Makefile->GetSafeDefinition("CMAKE_BUILD_TYPE"), + false, this->GeneratorTarget, nullptr, nullptr), + cleanFiles); } std::string const& binaryDir = lg->GetCurrentBinaryDirectory(); cmGlobalNinjaGenerator* gg = lg->GetGlobalNinjaGenerator(); diff --git a/Source/cmOutputConverter.cxx b/Source/cmOutputConverter.cxx index da7f8bc..bf516e3 100644 --- a/Source/cmOutputConverter.cxx +++ b/Source/cmOutputConverter.cxx @@ -9,6 +9,7 @@ #include #include "cmState.h" +#include "cmStringAlgorithms.h" #include "cmSystemTools.h" cmOutputConverter::cmOutputConverter(cmStateSnapshot const& snapshot) @@ -153,7 +154,7 @@ cmOutputConverter::FortranFormat cmOutputConverter::GetFortranFormat( { FortranFormat format = FortranFormatNone; if (!value.empty()) { - for (std::string const& fi : cmSystemTools::ExpandedListArgument(value)) { + for (std::string const& fi : cmExpandedList(value)) { if (fi == "FIXED") { format = FortranFormatFixed; } diff --git a/Source/cmOutputRequiredFilesCommand.cxx b/Source/cmOutputRequiredFilesCommand.cxx index 587e21c..de47ce0 100644 --- a/Source/cmOutputRequiredFilesCommand.cxx +++ b/Source/cmOutputRequiredFilesCommand.cxx @@ -123,7 +123,7 @@ public: incDirProp, cmGeneratorExpression::StripAllGeneratorExpressions); std::vector includes; - cmSystemTools::ExpandListArgument(incDirs, includes); + cmExpandList(incDirs, includes); for (std::string& path : includes) { this->Makefile->ExpandVariablesInString(path); diff --git a/Source/cmParseArgumentsCommand.cxx b/Source/cmParseArgumentsCommand.cxx index 04fa0fb..0e1b94e 100644 --- a/Source/cmParseArgumentsCommand.cxx +++ b/Source/cmParseArgumentsCommand.cxx @@ -161,17 +161,17 @@ bool cmParseArgumentsCommand::InitialPass(std::vector const& args, // the second argument is a (cmake) list of options without argument std::vector list; - cmSystemTools::ExpandListArgument(*argIter++, list); + cmExpandList(*argIter++, list); parser.Bind(list, options, duplicateKey); // the third argument is a (cmake) list of single argument options list.clear(); - cmSystemTools::ExpandListArgument(*argIter++, list); + cmExpandList(*argIter++, list); parser.Bind(list, singleValArgs, duplicateKey); // the fourth argument is a (cmake) list of multi argument options list.clear(); - cmSystemTools::ExpandListArgument(*argIter++, list); + cmExpandList(*argIter++, list); parser.Bind(list, multiValArgs, duplicateKey); list.clear(); @@ -179,7 +179,7 @@ bool cmParseArgumentsCommand::InitialPass(std::vector const& args, // Flatten ;-lists in the arguments into a single list as was done // by the original function(CMAKE_PARSE_ARGUMENTS). for (; argIter != argEnd; ++argIter) { - cmSystemTools::ExpandListArgument(*argIter, list); + cmExpandList(*argIter, list); } } else { // in the PARSE_ARGV move read the arguments from ARGC and ARGV# diff --git a/Source/cmQtAutoGenInitializer.cxx b/Source/cmQtAutoGenInitializer.cxx index 360df25..f9b76cd 100644 --- a/Source/cmQtAutoGenInitializer.cxx +++ b/Source/cmQtAutoGenInitializer.cxx @@ -392,7 +392,7 @@ bool cmQtAutoGenInitializer::InitCustomTargets() this->Target->GetSafeProperty("AUTOGEN_TARGET_DEPENDS"); if (!deps.empty()) { std::vector extraDeps; - cmSystemTools::ExpandListArgument(deps, extraDeps); + cmExpandList(deps, extraDeps); for (std::string const& depName : extraDeps) { // Allow target and file dependencies auto* depTarget = makefile->FindTargetToUse(depName); @@ -543,7 +543,7 @@ bool cmQtAutoGenInitializer::InitUic() std::string const usp = this->Target->GetSafeProperty("AUTOUIC_SEARCH_PATHS"); if (!usp.empty()) { - cmSystemTools::ExpandListArgument(usp, this->Uic.SearchPaths); + cmExpandList(usp, this->Uic.SearchPaths); std::string const& srcDir = makefile->GetCurrentSourceDirectory(); for (std::string& path : this->Uic.SearchPaths) { path = cmSystemTools::CollapseFullPath(path, srcDir); @@ -689,7 +689,7 @@ bool cmQtAutoGenInitializer::InitScanFiles() { std::string const opts = sf->GetSafeProperty(kw.AUTORCC_OPTIONS); if (!opts.empty()) { - cmSystemTools::ExpandListArgument(opts, qrc.Options); + cmExpandList(opts, qrc.Options); } } this->Rcc.Qrcs.push_back(std::move(qrc)); @@ -808,7 +808,7 @@ bool cmQtAutoGenInitializer::InitScanFiles() if (!uicOpts.empty()) { this->Uic.FileFiles.push_back(std::move(realPath)); std::vector optsVec; - cmSystemTools::ExpandListArgument(uicOpts, optsVec); + cmExpandList(uicOpts, optsVec); this->Uic.FileOptions.push_back(std::move(optsVec)); } } else { @@ -862,8 +862,8 @@ bool cmQtAutoGenInitializer::InitScanFiles() const bool modernQt = (this->QtVersion.Major >= 5); // Target rcc options std::vector optionsTarget; - cmSystemTools::ExpandListArgument( - this->Target->GetSafeProperty(kw.AUTORCC_OPTIONS), optionsTarget); + cmExpandList(this->Target->GetSafeProperty(kw.AUTORCC_OPTIONS), + optionsTarget); // Check if file name is unique for (Qrc& qrc : this->Rcc.Qrcs) { diff --git a/Source/cmQtAutoMocUic.cxx b/Source/cmQtAutoMocUic.cxx index e693816..38e259b 100644 --- a/Source/cmQtAutoMocUic.cxx +++ b/Source/cmQtAutoMocUic.cxx @@ -1511,7 +1511,7 @@ bool cmQtAutoMocUic::Init(cmMakefile* makefile) }; auto InfoGetList = [makefile](const char* key) -> std::vector { std::vector list; - cmSystemTools::ExpandListArgument(makefile->GetSafeDefinition(key), list); + cmExpandList(makefile->GetSafeDefinition(key), list); return list; }; auto InfoGetLists = @@ -1528,8 +1528,7 @@ bool cmQtAutoMocUic::Init(cmMakefile* makefile) if (length >= 2) { std::string::const_iterator itBeg = value.begin() + (pos + 1); std::string::const_iterator itEnd = itBeg + (length - 2); - lists.emplace_back( - cmSystemTools::ExpandedListArgument(std::string(itBeg, itEnd))); + lists.emplace_back(cmExpandedList(std::string(itBeg, itEnd))); } pos += length; pos += ListSep.size(); @@ -1551,7 +1550,7 @@ bool cmQtAutoMocUic::Init(cmMakefile* makefile) auto InfoGetConfigList = [&InfoGetConfig](const char* key) -> std::vector { std::vector list; - cmSystemTools::ExpandListArgument(InfoGetConfig(key), list); + cmExpandList(InfoGetConfig(key), list); return list; }; auto LogInfoError = [this](std::string const& msg) -> bool { diff --git a/Source/cmQtAutoRcc.cxx b/Source/cmQtAutoRcc.cxx index c75b2ca..ea3cad9 100644 --- a/Source/cmQtAutoRcc.cxx +++ b/Source/cmQtAutoRcc.cxx @@ -29,7 +29,7 @@ bool cmQtAutoRcc::Init(cmMakefile* makefile) auto InfoGetList = [makefile](std::string const& key) -> std::vector { std::vector list; - cmSystemTools::ExpandListArgument(makefile->GetSafeDefinition(key), list); + cmExpandList(makefile->GetSafeDefinition(key), list); return list; }; auto InfoGetConfig = [makefile, @@ -47,7 +47,7 @@ bool cmQtAutoRcc::Init(cmMakefile* makefile) auto InfoGetConfigList = [&InfoGetConfig](std::string const& key) -> std::vector { std::vector list; - cmSystemTools::ExpandListArgument(InfoGetConfig(key), list); + cmExpandList(InfoGetConfig(key), list); return list; }; auto LogInfoError = [this](std::string const& msg) -> bool { diff --git a/Source/cmRemoveCommand.cxx b/Source/cmRemoveCommand.cxx index d0ee4d4..4ba21fa 100644 --- a/Source/cmRemoveCommand.cxx +++ b/Source/cmRemoveCommand.cxx @@ -3,7 +3,7 @@ #include "cmRemoveCommand.h" #include "cmMakefile.h" -#include "cmSystemTools.h" +#include "cmStringAlgorithms.h" class cmExecutionStatus; @@ -25,13 +25,12 @@ bool cmRemoveCommand::InitialPass(std::vector const& args, } // expand the variable - std::vector const varArgsExpanded = - cmSystemTools::ExpandedListArgument(cacheValue); + std::vector const varArgsExpanded = cmExpandedList(cacheValue); // expand the args // check for REMOVE(VAR v1 v2 ... vn) std::vector const argsExpanded = - cmSystemTools::ExpandedLists(args.begin() + 1, args.end()); + cmExpandedLists(args.begin() + 1, args.end()); // now create the new value std::string value; diff --git a/Source/cmRuntimeDependencyArchive.cxx b/Source/cmRuntimeDependencyArchive.cxx index 37a87e5..1b3f387 100644 --- a/Source/cmRuntimeDependencyArchive.cxx +++ b/Source/cmRuntimeDependencyArchive.cxx @@ -9,6 +9,7 @@ #include "cmExecutionStatus.h" #include "cmMakefile.h" #include "cmStateTypes.h" +#include "cmStringAlgorithms.h" #include "cmSystemTools.h" #if defined(_WIN32) @@ -217,7 +218,7 @@ bool cmRuntimeDependencyArchive::GetGetRuntimeDependenciesCommand( std::string toolCommand = this->GetMakefile()->GetSafeDefinition( "CMAKE_GET_RUNTIME_DEPENDENCIES_COMMAND"); if (!toolCommand.empty()) { - cmSystemTools::ExpandListArgument(toolCommand, command); + cmExpandList(toolCommand, command); return true; } diff --git a/Source/cmSearchPath.cxx b/Source/cmSearchPath.cxx index 879cc95..affff54 100644 --- a/Source/cmSearchPath.cxx +++ b/Source/cmSearchPath.cxx @@ -79,7 +79,7 @@ void cmSearchPath::AddCMakePath(const std::string& variable) // Get a path from a CMake variable. if (const char* value = this->FC->Makefile->GetDefinition(variable)) { std::vector expanded; - cmSystemTools::ExpandListArgument(value, expanded); + cmExpandList(value, expanded); for (std::string const& p : expanded) { this->AddPathInternal( @@ -104,7 +104,7 @@ void cmSearchPath::AddCMakePrefixPath(const std::string& variable) // Get a path from a CMake variable. if (const char* value = this->FC->Makefile->GetDefinition(variable)) { std::vector expanded; - cmSystemTools::ExpandListArgument(value, expanded); + cmExpandList(value, expanded); this->AddPrefixPaths( expanded, this->FC->Makefile->GetCurrentSourceDirectory().c_str()); diff --git a/Source/cmSystemTools.h b/Source/cmSystemTools.h index 4f76b00..99610eb 100644 --- a/Source/cmSystemTools.h +++ b/Source/cmSystemTools.h @@ -46,7 +46,7 @@ public: std::vector& argsOut) { for (; first != last; ++first) { - cmSystemTools::ExpandListArgument(*first, argsOut); + cmExpandList(*first, argsOut); } } @@ -66,7 +66,7 @@ public: { std::vector argsOut; for (; first != last; ++first) { - cmSystemTools::ExpandListArgument(*first, argsOut); + ExpandListArgument(*first, argsOut); } return argsOut; } diff --git a/Source/cmTarget.cxx b/Source/cmTarget.cxx index bf2419a..61b8702 100644 --- a/Source/cmTarget.cxx +++ b/Source/cmTarget.cxx @@ -89,7 +89,7 @@ const char* cmTargetPropertyComputer::GetSources( const char* sep = ""; for (std::string const& entry : entries) { std::vector files; - cmSystemTools::ExpandListArgument(entry, files); + cmExpandList(entry, files); for (std::string const& file : files) { if (cmHasLiteralPrefix(file, "$') { @@ -501,7 +501,7 @@ cmTarget::cmTarget(std::string const& name, cmStateEnums::TargetType type, const std::string genName = mf->GetGlobalGenerator()->GetName(); if (cmHasLiteralPrefix(genName, "Visual Studio")) { std::vector props; - cmSystemTools::ExpandListArgument(globals, props); + cmExpandList(globals, props); const std::string vsGlobal = "VS_GLOBAL_"; for (const std::string& i : props) { // split NAME=VALUE @@ -744,7 +744,7 @@ public: bool operator()(std::string const& entry) { std::vector files; - cmSystemTools::ExpandListArgument(entry, files); + cmExpandList(entry, files); std::vector locations; locations.reserve(files.size()); std::transform(files.begin(), files.end(), std::back_inserter(locations), @@ -1899,7 +1899,7 @@ bool cmTarget::GetMappedConfig(std::string const& desired_config, std::string mapProp = "MAP_IMPORTED_CONFIG_"; mapProp += config_upper; if (const char* mapValue = this->GetProperty(mapProp)) { - cmSystemTools::ExpandListArgument(mapValue, mappedConfigs, true); + cmExpandList(mapValue, mappedConfigs, true); } } @@ -1986,7 +1986,7 @@ bool cmTarget::GetMappedConfig(std::string const& desired_config, if (!*loc && !*imp) { std::vector availableConfigs; if (const char* iconfigs = this->GetProperty("IMPORTED_CONFIGURATIONS")) { - cmSystemTools::ExpandListArgument(iconfigs, availableConfigs); + cmExpandList(iconfigs, availableConfigs); } for (std::vector::const_iterator aci = availableConfigs.begin(); diff --git a/Source/cmTestGenerator.cxx b/Source/cmTestGenerator.cxx index 916784c..75cb413 100644 --- a/Source/cmTestGenerator.cxx +++ b/Source/cmTestGenerator.cxx @@ -15,6 +15,7 @@ #include "cmPropertyMap.h" #include "cmRange.h" #include "cmStateTypes.h" +#include "cmStringAlgorithms.h" #include "cmSystemTools.h" #include "cmTest.h" @@ -83,7 +84,7 @@ void cmTestGenerator::GenerateScriptForConfig(std::ostream& os, // Expand arguments if COMMAND_EXPAND_LISTS is set if (this->Test->GetCommandExpandLists()) { - argv = cmSystemTools::ExpandedLists(argv.begin(), argv.end()); + argv = cmExpandedLists(argv.begin(), argv.end()); // Expanding lists on an empty command may have left it empty if (argv.empty()) { argv.emplace_back(); @@ -102,7 +103,7 @@ void cmTestGenerator::GenerateScriptForConfig(std::ostream& os, const char* emulator = target->GetProperty("CROSSCOMPILING_EMULATOR"); if (emulator != nullptr && *emulator) { std::vector emulatorWithArgs; - cmSystemTools::ExpandListArgument(emulator, emulatorWithArgs); + cmExpandList(emulator, emulatorWithArgs); std::string emulatorExe(emulatorWithArgs[0]); cmSystemTools::ConvertToUnixSlashes(emulatorExe); os << cmOutputConverter::EscapeForCMake(emulatorExe) << " "; diff --git a/Source/cmTryRunCommand.cxx b/Source/cmTryRunCommand.cxx index ed944ac..5cc4795 100644 --- a/Source/cmTryRunCommand.cxx +++ b/Source/cmTryRunCommand.cxx @@ -11,6 +11,7 @@ #include "cmRange.h" #include "cmState.h" #include "cmStateTypes.h" +#include "cmStringAlgorithms.h" #include "cmSystemTools.h" #include "cmake.h" @@ -170,7 +171,7 @@ void cmTryRunCommand::RunExecutable(const std::string& runArgs, this->Makefile->GetSafeDefinition("CMAKE_CROSSCOMPILING_EMULATOR"); if (!emulator.empty()) { std::vector emulatorWithArgs; - cmSystemTools::ExpandListArgument(emulator, emulatorWithArgs); + cmExpandList(emulator, emulatorWithArgs); finalCommand += cmSystemTools::ConvertToRunCommandPath(emulatorWithArgs[0]); finalCommand += " "; diff --git a/Source/cmVisualStudio10TargetGenerator.cxx b/Source/cmVisualStudio10TargetGenerator.cxx index ed6e4d9..0e4b0af 100644 --- a/Source/cmVisualStudio10TargetGenerator.cxx +++ b/Source/cmVisualStudio10TargetGenerator.cxx @@ -750,7 +750,7 @@ void cmVisualStudio10TargetGenerator::WritePackageReferences(Elem& e0) std::vector packageReferences; if (const char* vsPackageReferences = this->GeneratorTarget->GetProperty("VS_PACKAGE_REFERENCES")) { - cmSystemTools::ExpandListArgument(vsPackageReferences, packageReferences); + cmExpandList(vsPackageReferences, packageReferences); } if (!packageReferences.empty()) { Elem e1(e0, "ItemGroup"); @@ -777,7 +777,7 @@ void cmVisualStudio10TargetGenerator::WriteDotNetReferences(Elem& e0) std::vector references; if (const char* vsDotNetReferences = this->GeneratorTarget->GetProperty("VS_DOTNET_REFERENCES")) { - cmSystemTools::ExpandListArgument(vsDotNetReferences, references); + cmExpandList(vsDotNetReferences, references); } cmPropertyMap const& props = this->GeneratorTarget->Target->GetProperties(); for (auto const& i : props.GetList()) { @@ -854,7 +854,7 @@ void cmVisualStudio10TargetGenerator::WriteImports(Elem& e0) this->GeneratorTarget->Target->GetProperty("VS_PROJECT_IMPORT"); if (imports) { std::vector argsSplit; - cmSystemTools::ExpandListArgument(std::string(imports), argsSplit, false); + cmExpandList(std::string(imports), argsSplit, false); for (auto& path : argsSplit) { if (!cmsys::SystemTools::FileIsFullPath(path)) { path = this->Makefile->GetCurrentSourceDirectory() + "/" + path; @@ -1074,7 +1074,7 @@ void cmVisualStudio10TargetGenerator::WriteWinRTReferences(Elem& e0) std::vector references; if (const char* vsWinRTReferences = this->GeneratorTarget->GetProperty("VS_WINRT_REFERENCES")) { - cmSystemTools::ExpandListArgument(vsWinRTReferences, references); + cmExpandList(vsWinRTReferences, references); } if (this->GlobalGenerator->TargetsWindowsPhone() && @@ -4027,7 +4027,7 @@ void cmVisualStudio10TargetGenerator::WriteSDKReferences(Elem& e0) std::unique_ptr spe1; if (const char* vsSDKReferences = this->GeneratorTarget->GetProperty("VS_SDK_REFERENCES")) { - cmSystemTools::ExpandListArgument(vsSDKReferences, sdkReferences); + cmExpandList(vsSDKReferences, sdkReferences); spe1 = cm::make_unique(e0, "ItemGroup"); for (std::string const& ri : sdkReferences) { Elem(*spe1, "SDKReference").Attribute("Include", ri); diff --git a/Source/cmXCodeScheme.cxx b/Source/cmXCodeScheme.cxx index c33bb7e..a565a9c 100644 --- a/Source/cmXCodeScheme.cxx +++ b/Source/cmXCodeScheme.cxx @@ -218,7 +218,7 @@ void cmXCodeScheme::WriteLaunchAction(cmXMLWriter& xout, if (const char* argList = this->Target->GetTarget()->GetProperty("XCODE_SCHEME_ARGUMENTS")) { std::vector arguments; - cmSystemTools::ExpandListArgument(argList, arguments); + cmExpandList(argList, arguments); if (!arguments.empty()) { xout.StartElement("CommandLineArguments"); @@ -239,7 +239,7 @@ void cmXCodeScheme::WriteLaunchAction(cmXMLWriter& xout, if (const char* envList = this->Target->GetTarget()->GetProperty("XCODE_SCHEME_ENVIRONMENT")) { std::vector envs; - cmSystemTools::ExpandListArgument(envList, envs); + cmExpandList(envList, envs); if (!envs.empty()) { xout.StartElement("EnvironmentVariables"); diff --git a/Source/cmake.cxx b/Source/cmake.cxx index af73c8d..440a7b1 100644 --- a/Source/cmake.cxx +++ b/Source/cmake.cxx @@ -530,7 +530,7 @@ bool cmake::FindPackage(const std::vector& args) } else if (mode == "COMPILE") { std::string includes = mf->GetSafeDefinition("PACKAGE_INCLUDE_DIRS"); std::vector includeDirs; - cmSystemTools::ExpandListArgument(includes, includeDirs); + cmExpandList(includes, includeDirs); gg->CreateGenerationObjects(); cmLocalGenerator* lg = gg->LocalGenerators[0]; @@ -547,7 +547,7 @@ bool cmake::FindPackage(const std::vector& args) std::string libs = mf->GetSafeDefinition("PACKAGE_LIBRARIES"); std::vector libList; - cmSystemTools::ExpandListArgument(libs, libList); + cmExpandList(libs, libList); for (std::string const& lib : libList) { tgt->AddLinkLibrary(*mf, lib, GENERAL_LibraryType); } @@ -1251,7 +1251,7 @@ struct SaveCacheEntry int cmake::HandleDeleteCacheVariables(const std::string& var) { std::vector argsSplit; - cmSystemTools::ExpandListArgument(std::string(var), argsSplit, true); + cmExpandList(std::string(var), argsSplit, true); // erase the property to avoid infinite recursion this->State->SetGlobalProperty("__CMAKE_DELETE_CACHE_CHANGE_VARS_", ""); if (this->State->GetIsInTryCompile()) { @@ -2159,7 +2159,7 @@ int cmake::CheckBuildSystem() // If any byproduct of makefile generation is missing we must re-run. std::vector products; if (const char* productStr = mf.GetDefinition("CMAKE_MAKEFILE_PRODUCTS")) { - cmSystemTools::ExpandListArgument(productStr, products); + cmExpandList(productStr, products); } for (std::string const& p : products) { if (!(cmSystemTools::FileExists(p) || cmSystemTools::FileIsSymlink(p))) { @@ -2178,8 +2178,8 @@ int cmake::CheckBuildSystem() const char* dependsStr = mf.GetDefinition("CMAKE_MAKEFILE_DEPENDS"); const char* outputsStr = mf.GetDefinition("CMAKE_MAKEFILE_OUTPUTS"); if (dependsStr && outputsStr) { - cmSystemTools::ExpandListArgument(dependsStr, depends); - cmSystemTools::ExpandListArgument(outputsStr, outputs); + cmExpandList(dependsStr, depends); + cmExpandList(outputsStr, outputs); } if (depends.empty() || outputs.empty()) { // Not enough information was provided to do the test. Just rerun. @@ -2555,7 +2555,7 @@ std::vector cmake::GetDebugConfigs() if (const char* config_list = this->State->GetGlobalProperty("DEBUG_CONFIGURATIONS")) { // Expand the specified list and convert to upper-case. - cmSystemTools::ExpandListArgument(config_list, configs); + cmExpandList(config_list, configs); std::transform(configs.begin(), configs.end(), configs.begin(), cmSystemTools::UpperCase); } diff --git a/Source/cmcmd.cxx b/Source/cmcmd.cxx index 69d5fcd..ba2788e 100644 --- a/Source/cmcmd.cxx +++ b/Source/cmcmd.cxx @@ -175,7 +175,7 @@ static int HandleIWYU(const std::string& runCmd, // Construct the iwyu command line by taking what was given // and adding all the arguments we give to the compiler. std::vector iwyu_cmd; - cmSystemTools::ExpandListArgument(runCmd, iwyu_cmd, true); + cmExpandList(runCmd, iwyu_cmd, true); cmAppend(iwyu_cmd, orig_cmd.begin() + 1, orig_cmd.end()); // Run the iwyu command line. Capture its stderr and hide its stdout. // Ignore its return code because the tool always returns non-zero. @@ -204,8 +204,7 @@ static int HandleTidy(const std::string& runCmd, const std::string& sourceFile, // automatically skip over the compiler itself and extract the // options. int ret; - std::vector tidy_cmd = - cmSystemTools::ExpandedListArgument(runCmd, true); + std::vector tidy_cmd = cmExpandedList(runCmd, true); tidy_cmd.push_back(sourceFile); tidy_cmd.emplace_back("--"); cmAppend(tidy_cmd, orig_cmd); @@ -266,7 +265,7 @@ static int HandleCppLint(const std::string& runCmd, { // Construct the cpplint command line. std::vector cpplint_cmd; - cmSystemTools::ExpandListArgument(runCmd, cpplint_cmd, true); + cmExpandList(runCmd, cpplint_cmd, true); cpplint_cmd.push_back(sourceFile); // Run the cpplint command line. Capture its output. @@ -295,7 +294,7 @@ static int HandleCppCheck(const std::string& runCmd, { // Construct the cpplint command line. std::vector cppcheck_cmd; - cmSystemTools::ExpandListArgument(runCmd, cppcheck_cmd, true); + cmExpandList(runCmd, cppcheck_cmd, true); // extract all the -D, -U, and -I options from the compile line for (auto const& opt : orig_cmd) { if (opt.size() > 2) { @@ -408,7 +407,7 @@ int cmcmd::HandleCoCompileCommands(std::vector const& args) if (cmHasLiteralPrefix(arg, "--source=")) { sourceFile = arg.substr(9); } else if (cmHasLiteralPrefix(arg, "--launcher=")) { - cmSystemTools::ExpandListArgument(arg.substr(11), launchers, true); + cmExpandList(arg.substr(11), launchers, true); } else { // if it was not a co-compiler or --source/--launcher then error std::cerr << "__run_co_compile given unknown argument: " << arg https://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=ff42dec89143c3b8027c9768c2910ca270ddd951 commit ff42dec89143c3b8027c9768c2910ca270ddd951 Author: Sebastian Holtermann AuthorDate: Sun Aug 11 11:36:39 2019 +0200 Commit: Sebastian Holtermann CommitDate: Wed Aug 14 16:29:11 2019 +0200 cmStringAlgorithms: Add cmExpandList functions diff --git a/Source/cmStringAlgorithms.cxx b/Source/cmStringAlgorithms.cxx index eca761b..c77fde3 100644 --- a/Source/cmStringAlgorithms.cxx +++ b/Source/cmStringAlgorithms.cxx @@ -72,6 +72,77 @@ std::vector cmTokenize(cm::string_view str, cm::string_view sep) return tokens; } +void cmExpandList(cm::string_view arg, std::vector& argsOut, + bool emptyArgs) +{ + // If argument is empty, it is an empty list. + if (!emptyArgs && arg.empty()) { + return; + } + + // if there are no ; in the name then just copy the current string + if (arg.find(';') == cm::string_view::npos) { + argsOut.emplace_back(arg); + return; + } + + std::string newArg; + // Break the string at non-escaped semicolons not nested in []. + int squareNesting = 0; + cm::string_view::iterator last = arg.begin(); + cm::string_view::iterator const cend = arg.end(); + for (cm::string_view::iterator c = last; c != cend; ++c) { + switch (*c) { + case '\\': { + // We only want to allow escaping of semicolons. Other + // escapes should not be processed here. + cm::string_view::iterator cnext = c + 1; + if ((cnext != cend) && *cnext == ';') { + newArg.append(last, c); + // Skip over the escape character + last = cnext; + c = cnext; + } + } break; + case '[': { + ++squareNesting; + } break; + case ']': { + --squareNesting; + } break; + case ';': { + // Break the string here if we are not nested inside square + // brackets. + if (squareNesting == 0) { + newArg.append(last, c); + // Skip over the semicolon + last = c + 1; + if (!newArg.empty() || emptyArgs) { + // Add the last argument if the string is not empty. + argsOut.push_back(newArg); + newArg.clear(); + } + } + } break; + default: { + // Just append this character. + } break; + } + } + newArg.append(last, cend); + if (!newArg.empty() || emptyArgs) { + // Add the last argument if the string is not empty. + argsOut.push_back(std::move(newArg)); + } +} + +std::vector cmExpandedList(cm::string_view arg, bool emptyArgs) +{ + std::vector argsOut; + cmExpandList(arg, argsOut, emptyArgs); + return argsOut; +} + namespace { template inline void MakeDigits(cm::string_view& view, char (&digits)[N], diff --git a/Source/cmStringAlgorithms.h b/Source/cmStringAlgorithms.h index 44b01b8..52d187c 100644 --- a/Source/cmStringAlgorithms.h +++ b/Source/cmStringAlgorithms.h @@ -68,6 +68,48 @@ std::string cmJoin(Range const& rng, cm::string_view separator) /** Extract tokens that are separated by any of the characters in @a sep. */ std::vector cmTokenize(cm::string_view str, cm::string_view sep); +/** + * Expand the ; separated string @a arg into multiple arguments. + * All found arguments are appended to @a argsOut. + */ +void cmExpandList(cm::string_view arg, std::vector& argsOut, + bool emptyArgs = false); + +/** + * Expand out any arguments in the string range [@a first, @a last) that have + * ; separated strings into multiple arguments. All found arguments are + * appended to @a argsOut. + */ +template +void cmExpandLists(InputIt first, InputIt last, + std::vector& argsOut) +{ + for (; first != last; ++first) { + ExpandList(*first, argsOut); + } +} + +/** + * Same as cmExpandList but a new vector is created containing + * the expanded arguments from the string @a arg. + */ +std::vector cmExpandedList(cm::string_view arg, + bool emptyArgs = false); + +/** + * Same as cmExpandList but a new vector is created containing the expanded + * versions of all arguments in the string range [@a first, @a last). + */ +template +std::vector cmExpandedLists(InputIt first, InputIt last) +{ + std::vector argsOut; + for (; first != last; ++first) { + cmExpandList(*first, argsOut); + } + return argsOut; +} + /** Concatenate string pieces into a single string. */ std::string cmCatViews(std::initializer_list views); https://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=935fbe0b0454163678bc4ef19e1bee95a7a31b4d commit 935fbe0b0454163678bc4ef19e1bee95a7a31b4d Author: Sebastian Holtermann AuthorDate: Sat Aug 10 13:37:34 2019 +0200 Commit: Sebastian Holtermann CommitDate: Sat Aug 10 14:39:03 2019 +0200 cmStringAlgorithms: Add cmStrToLong and cmStrToULong This adds the following functions to cmStringAlgorithms: - `cmStrToLong`: moved from `cmSystemTools::StringToLong` - `cmStrToULong`: moved from `cmSystemTools::StringToULong` Overloads of the given functions for `std::string` are added as well. diff --git a/Source/CTest/cmCTestMultiProcessHandler.cxx b/Source/CTest/cmCTestMultiProcessHandler.cxx index 42534f7..ae965ea 100644 --- a/Source/CTest/cmCTestMultiProcessHandler.cxx +++ b/Source/CTest/cmCTestMultiProcessHandler.cxx @@ -10,6 +10,7 @@ #include "cmDuration.h" #include "cmListFileCache.h" #include "cmRange.h" +#include "cmStringAlgorithms.h" #include "cmSystemTools.h" #include "cmWorkingDirectory.h" @@ -110,8 +111,7 @@ void cmCTestMultiProcessHandler::SetTestLoad(unsigned long load) std::string fake_load_value; if (cmSystemTools::GetEnv("__CTEST_FAKE_LOAD_AVERAGE_FOR_TESTING", fake_load_value)) { - if (!cmSystemTools::StringToULong(fake_load_value.c_str(), - &this->FakeLoadForTesting)) { + if (!cmStrToULong(fake_load_value, &this->FakeLoadForTesting)) { cmSystemTools::Error("Failed to parse fake load value: " + fake_load_value); } diff --git a/Source/CTest/cmCTestSubmitHandler.cxx b/Source/CTest/cmCTestSubmitHandler.cxx index 17ef350..f97d7eb 100644 --- a/Source/CTest/cmCTestSubmitHandler.cxx +++ b/Source/CTest/cmCTestSubmitHandler.cxx @@ -529,8 +529,7 @@ int cmCTestSubmitHandler::HandleCDashUploadFile(std::string const& file, auto retryDelay = std::chrono::seconds(0); if (!retryDelayString.empty()) { unsigned long retryDelayValue = 0; - if (!cmSystemTools::StringToULong(retryDelayString.c_str(), - &retryDelayValue)) { + if (!cmStrToULong(retryDelayString, &retryDelayValue)) { cmCTestLog(this->CTest, WARNING, "Invalid value for 'RETRY_DELAY' : " << retryDelayString << std::endl); @@ -540,7 +539,7 @@ int cmCTestSubmitHandler::HandleCDashUploadFile(std::string const& file, } unsigned long retryCount = 0; if (!retryCountString.empty()) { - if (!cmSystemTools::StringToULong(retryCountString.c_str(), &retryCount)) { + if (!cmStrToULong(retryCountString, &retryCount)) { cmCTestLog(this->CTest, WARNING, "Invalid value for 'RETRY_DELAY' : " << retryCountString << std::endl); diff --git a/Source/CTest/cmCTestTestCommand.cxx b/Source/CTest/cmCTestTestCommand.cxx index cfd5e3d..24de5b4 100644 --- a/Source/CTest/cmCTestTestCommand.cxx +++ b/Source/CTest/cmCTestTestCommand.cxx @@ -7,7 +7,7 @@ #include "cmCTestTestHandler.h" #include "cmDuration.h" #include "cmMakefile.h" -#include "cmSystemTools.h" +#include "cmStringAlgorithms.h" #include #include @@ -110,15 +110,14 @@ cmCTestGenericHandler* cmCTestTestCommand::InitializeHandler() unsigned long testLoad; const char* ctestTestLoad = this->Makefile->GetDefinition("CTEST_TEST_LOAD"); if (this->Values[ctt_TEST_LOAD] && *this->Values[ctt_TEST_LOAD]) { - if (!cmSystemTools::StringToULong(this->Values[ctt_TEST_LOAD], - &testLoad)) { + if (!cmStrToULong(this->Values[ctt_TEST_LOAD], &testLoad)) { testLoad = 0; cmCTestLog(this->CTest, WARNING, "Invalid value for 'TEST_LOAD' : " << this->Values[ctt_TEST_LOAD] << std::endl); } } else if (ctestTestLoad && *ctestTestLoad) { - if (!cmSystemTools::StringToULong(ctestTestLoad, &testLoad)) { + if (!cmStrToULong(ctestTestLoad, &testLoad)) { testLoad = 0; cmCTestLog(this->CTest, WARNING, "Invalid value for 'CTEST_TEST_LOAD' : " << ctestTestLoad diff --git a/Source/CTest/cmCTestTestHandler.cxx b/Source/CTest/cmCTestTestHandler.cxx index 67c24ca..17e7822 100644 --- a/Source/CTest/cmCTestTestHandler.cxx +++ b/Source/CTest/cmCTestTestHandler.cxx @@ -2193,8 +2193,7 @@ bool cmCTestTestHandler::SetTestsProperties( cmListFileContext fc; fc.FilePath = triples[i - 3]; long line = 0; - if (!cmSystemTools::StringToLong(triples[i - 2].c_str(), - &line)) { + if (!cmStrToLong(triples[i - 2], &line)) { line = 0; } fc.Line = line; diff --git a/Source/cmCTest.cxx b/Source/cmCTest.cxx index 026250d..7ea8083 100644 --- a/Source/cmCTest.cxx +++ b/Source/cmCTest.cxx @@ -754,7 +754,7 @@ bool cmCTest::UpdateCTestConfiguration() std::string const& testLoad = this->GetCTestConfiguration("TestLoad"); if (!testLoad.empty()) { unsigned long load; - if (cmSystemTools::StringToULong(testLoad.c_str(), &load)) { + if (cmStrToULong(testLoad, &load)) { this->SetTestLoad(load); } else { cmCTestLog(this, WARNING, @@ -1854,7 +1854,7 @@ bool cmCTest::HandleCommandLineArguments(size_t& i, } i++; long repeat = 1; - if (!cmSystemTools::StringToLong(args[i].c_str(), &repeat)) { + if (!cmStrToLong(args[i], &repeat)) { errormsg = "'--repeat-until-fail' given non-integer value '" + args[i] + "'"; return false; @@ -1868,7 +1868,7 @@ bool cmCTest::HandleCommandLineArguments(size_t& i, if (this->CheckArgument(arg, "--test-load") && i < args.size() - 1) { i++; unsigned long load; - if (cmSystemTools::StringToULong(args[i].c_str(), &load)) { + if (cmStrToULong(args[i], &load)) { this->SetTestLoad(load); } else { cmCTestLog(this, WARNING, @@ -1942,7 +1942,7 @@ bool cmCTest::HandleCommandLineArguments(size_t& i, i < args.size() - 1) { i++; long outputSize; - if (cmSystemTools::StringToLong(args[i].c_str(), &outputSize)) { + if (cmStrToLong(args[i], &outputSize)) { this->Impl->TestHandler.SetTestOutputSizePassed(int(outputSize)); } else { cmCTestLog(this, WARNING, @@ -1954,7 +1954,7 @@ bool cmCTest::HandleCommandLineArguments(size_t& i, i < args.size() - 1) { i++; long outputSize; - if (cmSystemTools::StringToLong(args[i].c_str(), &outputSize)) { + if (cmStrToLong(args[i], &outputSize)) { this->Impl->TestHandler.SetTestOutputSizeFailed(int(outputSize)); } else { cmCTestLog(this, WARNING, diff --git a/Source/cmFileCommand.cxx b/Source/cmFileCommand.cxx index ec03191..db73926 100644 --- a/Source/cmFileCommand.cxx +++ b/Source/cmFileCommand.cxx @@ -2357,8 +2357,7 @@ bool HandleLockCommand(std::vector const& args, return false; } long scanned; - if (!cmSystemTools::StringToLong(args[i].c_str(), &scanned) || - scanned < 0) { + if (!cmStrToLong(args[i], &scanned) || scanned < 0) { std::ostringstream e; e << "TIMEOUT value \"" << args[i] << "\" is not an unsigned integer."; status.GetMakefile().IssueMessage(MessageType::FATAL_ERROR, e.str()); diff --git a/Source/cmGlobalNinjaGenerator.cxx b/Source/cmGlobalNinjaGenerator.cxx index addb0c7..29caa16 100644 --- a/Source/cmGlobalNinjaGenerator.cxx +++ b/Source/cmGlobalNinjaGenerator.cxx @@ -560,7 +560,7 @@ void cmGlobalNinjaGenerator::CheckNinjaFeatures() if (pos != std::string::npos) { const char* fv = &this->NinjaVersion[pos + k_DYNDEP_.size()]; unsigned long dyndep = 0; - cmSystemTools::StringToULong(fv, &dyndep); + cmStrToULong(fv, &dyndep); if (dyndep == 1) { this->NinjaSupportsDyndeps = true; } diff --git a/Source/cmParseArgumentsCommand.cxx b/Source/cmParseArgumentsCommand.cxx index 04fa0fb..df9407d 100644 --- a/Source/cmParseArgumentsCommand.cxx +++ b/Source/cmParseArgumentsCommand.cxx @@ -131,7 +131,7 @@ bool cmParseArgumentsCommand::InitialPass(std::vector const& args, } parseFromArgV = true; argIter++; // move past PARSE_ARGV - if (!cmSystemTools::StringToULong(argIter->c_str(), &argvStart)) { + if (!cmStrToULong(*argIter, &argvStart)) { this->Makefile->IssueMessage(MessageType::FATAL_ERROR, "PARSE_ARGV index '" + *argIter + "' is not an unsigned integer"); @@ -185,7 +185,7 @@ bool cmParseArgumentsCommand::InitialPass(std::vector const& args, // in the PARSE_ARGV move read the arguments from ARGC and ARGV# std::string argc = this->Makefile->GetSafeDefinition("ARGC"); unsigned long count; - if (!cmSystemTools::StringToULong(argc.c_str(), &count)) { + if (!cmStrToULong(argc, &count)) { this->Makefile->IssueMessage(MessageType::FATAL_ERROR, "PARSE_ARGV called with ARGC='" + argc + "' that is not an unsigned integer"); diff --git a/Source/cmPolicies.cxx b/Source/cmPolicies.cxx index 51a61dc..d33cd32 100644 --- a/Source/cmPolicies.cxx +++ b/Source/cmPolicies.cxx @@ -34,7 +34,7 @@ static bool stringToId(const char* input, cmPolicies::PolicyID& pid) } } long id; - if (!cmSystemTools::StringToLong(input + 3, &id)) { + if (!cmStrToLong(input + 3, &id)) { return false; } if (id >= cmPolicies::CMPCOUNT) { diff --git a/Source/cmQtAutoGenInitializer.cxx b/Source/cmQtAutoGenInitializer.cxx index 360df25..d6bef6b 100644 --- a/Source/cmQtAutoGenInitializer.cxx +++ b/Source/cmQtAutoGenInitializer.cxx @@ -243,7 +243,7 @@ bool cmQtAutoGenInitializer::InitCustomTargets() this->Verbosity = makefile->GetSafeDefinition("CMAKE_AUTOGEN_VERBOSE"); if (!this->Verbosity.empty()) { unsigned long iVerb = 0; - if (!cmSystemTools::StringToULong(this->Verbosity.c_str(), &iVerb)) { + if (!cmStrToULong(this->Verbosity, &iVerb)) { // Non numeric verbosity this->Verbosity = cmSystemTools::IsOn(this->Verbosity) ? "1" : "0"; } @@ -1523,7 +1523,7 @@ void cmQtAutoGenInitializer::AddCleanFile(std::string const& fileName) static unsigned int CharPtrToUInt(const char* const input) { unsigned long tmp = 0; - if (input != nullptr && cmSystemTools::StringToULong(input, &tmp)) { + if (input != nullptr && cmStrToULong(input, &tmp)) { return static_cast(tmp); } return 0; diff --git a/Source/cmQtAutoGenerator.cxx b/Source/cmQtAutoGenerator.cxx index 0ad87b1..996b2bc 100644 --- a/Source/cmQtAutoGenerator.cxx +++ b/Source/cmQtAutoGenerator.cxx @@ -22,7 +22,7 @@ cmQtAutoGenerator::Logger::Logger() std::string verbose; if (cmSystemTools::GetEnv("VERBOSE", verbose) && !verbose.empty()) { unsigned long iVerbose = 0; - if (cmSystemTools::StringToULong(verbose.c_str(), &iVerbose)) { + if (cmStrToULong(verbose, &iVerbose)) { SetVerbosity(static_cast(iVerbose)); } else { // Non numeric verbosity @@ -46,7 +46,7 @@ cmQtAutoGenerator::Logger::~Logger() = default; void cmQtAutoGenerator::Logger::RaiseVerbosity(std::string const& value) { unsigned long verbosity = 0; - if (cmSystemTools::StringToULong(value.c_str(), &verbosity)) { + if (cmStrToULong(value, &verbosity)) { if (this->Verbosity_ < verbosity) { this->Verbosity_ = static_cast(verbosity); } diff --git a/Source/cmQtAutoMocUic.cxx b/Source/cmQtAutoMocUic.cxx index e693816..6f3b2c6 100644 --- a/Source/cmQtAutoMocUic.cxx +++ b/Source/cmQtAutoMocUic.cxx @@ -1582,7 +1582,7 @@ bool cmQtAutoMocUic::Init(cmMakefile* makefile) BaseConst_.MultiConfig = InfoGetBool("AM_MULTI_CONFIG"); { unsigned long num = 1; - if (cmSystemTools::StringToULong(InfoGet("AM_PARALLEL").c_str(), &num)) { + if (cmStrToULong(InfoGet("AM_PARALLEL"), &num)) { num = std::max(num, 1); num = std::min(num, ParallelMax); } @@ -1630,8 +1630,7 @@ bool cmQtAutoMocUic::Init(cmMakefile* makefile) // - Qt environment { unsigned long qtv = BaseConst_.QtVersionMajor; - if (cmSystemTools::StringToULong(InfoGet("AM_QT_VERSION_MAJOR").c_str(), - &qtv)) { + if (cmStrToULong(InfoGet("AM_QT_VERSION_MAJOR"), &qtv)) { BaseConst_.QtVersionMajor = static_cast(qtv); } } diff --git a/Source/cmStringAlgorithms.cxx b/Source/cmStringAlgorithms.cxx index 5867a44..0703e55 100644 --- a/Source/cmStringAlgorithms.cxx +++ b/Source/cmStringAlgorithms.cxx @@ -4,6 +4,8 @@ #include #include +#include +#include std::string cmTrimWhitespace(cm::string_view str) { @@ -124,3 +126,35 @@ std::string cmCatViews(std::initializer_list views) } return result; } + +bool cmStrToLong(const char* str, long* value) +{ + errno = 0; + char* endp; + *value = strtol(str, &endp, 10); + return (*endp == '\0') && (endp != str) && (errno == 0); +} + +bool cmStrToLong(std::string const& str, long* value) +{ + return cmStrToLong(str.c_str(), value); +} + +bool cmStrToULong(const char* str, unsigned long* value) +{ + errno = 0; + char* endp; + while (cmIsSpace(*str)) { + ++str; + } + if (*str == '-') { + return false; + } + *value = strtoul(str, &endp, 10); + return (*endp == '\0') && (endp != str) && (errno == 0); +} + +bool cmStrToULong(std::string const& str, unsigned long* value) +{ + return cmStrToULong(str.c_str(), value); +} diff --git a/Source/cmStringAlgorithms.h b/Source/cmStringAlgorithms.h index 1898649..3656619 100644 --- a/Source/cmStringAlgorithms.h +++ b/Source/cmStringAlgorithms.h @@ -190,4 +190,13 @@ inline void cmStripSuffixIfExists(std::string& str, cm::string_view suffix) } } +/** Converts a string to long. Expects that the whole string is an integer. */ +bool cmStrToLong(const char* str, long* value); +bool cmStrToLong(std::string const& str, long* value); + +/** Converts a string to unsigned long. Expects that the whole string is an + * integer */ +bool cmStrToULong(const char* str, unsigned long* value); +bool cmStrToULong(std::string const& str, unsigned long* value); + #endif diff --git a/Source/cmStringCommand.cxx b/Source/cmStringCommand.cxx index 8b3b1e3..1af4204 100644 --- a/Source/cmStringCommand.cxx +++ b/Source/cmStringCommand.cxx @@ -736,7 +736,7 @@ bool cmStringCommand::HandleRepeatCommand(std::vector const& args) } unsigned long times; - if (!cmSystemTools::StringToULong(args[ArgPos::TIMES].c_str(), ×)) { + if (!cmStrToULong(args[ArgPos::TIMES], ×)) { this->Makefile->IssueMessage(MessageType::FATAL_ERROR, "repeat count is not a positive number."); return true; diff --git a/Source/cmSystemTools.cxx b/Source/cmSystemTools.cxx index 7baf5ed..f1a652d 100644 --- a/Source/cmSystemTools.cxx +++ b/Source/cmSystemTools.cxx @@ -2848,28 +2848,6 @@ bool cmSystemTools::RepeatedRemoveDirectory(const std::string& dir) return false; } -bool cmSystemTools::StringToLong(const char* str, long* value) -{ - errno = 0; - char* endp; - *value = strtol(str, &endp, 10); - return (*endp == '\0') && (endp != str) && (errno == 0); -} - -bool cmSystemTools::StringToULong(const char* str, unsigned long* value) -{ - errno = 0; - char* endp; - while (isspace(*str)) { - ++str; - } - if (*str == '-') { - return false; - } - *value = strtoul(str, &endp, 10); - return (*endp == '\0') && (endp != str) && (errno == 0); -} - std::string cmSystemTools::EncodeURL(std::string const& in, bool escapeSlashes) { std::string out; diff --git a/Source/cmSystemTools.h b/Source/cmSystemTools.h index d3fcb64..0c941cb 100644 --- a/Source/cmSystemTools.h +++ b/Source/cmSystemTools.h @@ -500,10 +500,6 @@ public: /** Remove a directory; repeat a few times in case of locked files. */ static bool RepeatedRemoveDirectory(const std::string& dir); - /** Convert string to long. Expected that the whole string is an integer */ - static bool StringToLong(const char* str, long* value); - static bool StringToULong(const char* str, unsigned long* value); - /** Encode a string as a URL. */ static std::string EncodeURL(std::string const& in, bool escapeSlashes = true); diff --git a/Source/cmakemain.cxx b/Source/cmakemain.cxx index 10a6825..c96ccc7 100644 --- a/Source/cmakemain.cxx +++ b/Source/cmakemain.cxx @@ -321,7 +321,7 @@ int extract_job_number(int& index, char const* current, char const* next, unsigned long numJobs = 0; if (jobString.empty()) { jobs = cmake::DEFAULT_BUILD_PARALLEL_LEVEL; - } else if (cmSystemTools::StringToULong(jobString.c_str(), &numJobs)) { + } else if (cmStrToULong(jobString, &numJobs)) { if (numJobs == 0) { std::cerr << "The value requires a positive integer argument.\n\n"; @@ -439,7 +439,7 @@ int do_build(int ac, char const* const* av) jobs = cmake::DEFAULT_BUILD_PARALLEL_LEVEL; } else { unsigned long numJobs = 0; - if (cmSystemTools::StringToULong(parallel.c_str(), &numJobs)) { + if (cmStrToULong(parallel, &numJobs)) { if (numJobs == 0) { std::cerr << "The CMAKE_BUILD_PARALLEL_LEVEL environment variable " "requires a positive integer argument.\n\n"; diff --git a/Tests/CMakeLib/testStringAlgorithms.cxx b/Tests/CMakeLib/testStringAlgorithms.cxx index 55d2a8f..3b18d0d 100644 --- a/Tests/CMakeLib/testStringAlgorithms.cxx +++ b/Tests/CMakeLib/testStringAlgorithms.cxx @@ -167,5 +167,40 @@ int testStringAlgorithms(int /*unused*/, char* /*unused*/ []) assert_ok(!cmHasLiteralSuffix(str, "ab"), "cmHasLiteralPrefix string not"); } + // ---------------------------------------------------------------------- + // Test cmStrToLong + { + long value; + assert_ok(cmStrToLong("1", &value) && value == 1, + "cmStrToLong parses a positive decimal integer."); + assert_ok(cmStrToLong(" 1", &value) && value == 1, + "cmStrToLong parses a decimal integer after whitespace."); + + assert_ok(cmStrToLong("-1", &value) && value == -1, + "cmStrToLong parses a negative decimal integer."); + assert_ok( + cmStrToLong(" -1", &value) && value == -1, + "cmStrToLong parses a negative decimal integer after whitespace."); + + assert_ok(!cmStrToLong("1x", &value), + "cmStrToLong rejects trailing content."); + } + + // ---------------------------------------------------------------------- + // Test cmStrToULong + { + unsigned long value; + assert_ok(cmStrToULong("1", &value) && value == 1, + "cmStrToULong parses a decimal integer."); + assert_ok(cmStrToULong(" 1", &value) && value == 1, + "cmStrToULong parses a decimal integer after whitespace."); + assert_ok(!cmStrToULong("-1", &value), + "cmStrToULong rejects a negative number."); + assert_ok(!cmStrToULong(" -1", &value), + "cmStrToULong rejects a negative number after whitespace."); + assert_ok(!cmStrToULong("1x", &value), + "cmStrToULong rejects trailing content."); + } + return failed; } diff --git a/Tests/CMakeLib/testSystemTools.cxx b/Tests/CMakeLib/testSystemTools.cxx index 121e639..0a757df 100644 --- a/Tests/CMakeLib/testSystemTools.cxx +++ b/Tests/CMakeLib/testSystemTools.cxx @@ -94,21 +94,5 @@ int testSystemTools(int /*unused*/, char* /*unused*/ []) cmPassed("cmSystemTools::strverscmp working"); } - // ---------------------------------------------------------------------- - // Test cmSystemTools::StringToULong - { - unsigned long value; - cmAssert(cmSystemTools::StringToULong("1", &value) && value == 1, - "StringToULong parses a decimal integer."); - cmAssert(cmSystemTools::StringToULong(" 1", &value) && value == 1, - "StringToULong parses a decimal integer after whitespace."); - cmAssert(!cmSystemTools::StringToULong("-1", &value), - "StringToULong rejects a negative number."); - cmAssert(!cmSystemTools::StringToULong(" -1", &value), - "StringToULong rejects a negative number after whitespace."); - cmAssert(!cmSystemTools::StringToULong("1x", &value), - "StringToULong rejects trailing content."); - } - return failed; } ----------------------------------------------------------------------- Summary of changes: Source/CPack/IFW/cmCPackIFWCommon.cxx | 5 +- Source/CPack/IFW/cmCPackIFWGenerator.cxx | 7 +- Source/CPack/IFW/cmCPackIFWInstaller.cxx | 3 +- Source/CPack/IFW/cmCPackIFWPackage.cxx | 19 ++-- Source/CPack/WiX/cmCPackWIXGenerator.cxx | 18 ++-- Source/CPack/cmCPackBundleGenerator.cxx | 3 +- Source/CPack/cmCPackDebGenerator.cxx | 3 +- Source/CPack/cmCPackDragNDropGenerator.cxx | 6 +- Source/CPack/cmCPackFreeBSDGenerator.cxx | 10 +- Source/CPack/cmCPackGenerator.cxx | 22 ++--- Source/CPack/cmCPackNSISGenerator.cxx | 9 +- Source/CPack/cmCPackOSXX11Generator.cxx | 4 +- Source/CPack/cpack.cxx | 3 +- Source/CTest/cmCTestBuildHandler.cxx | 6 +- Source/CTest/cmCTestConfigureCommand.cxx | 3 +- Source/CTest/cmCTestGIT.cxx | 2 +- Source/CTest/cmCTestMultiProcessHandler.cxx | 4 +- Source/CTest/cmCTestP4.cxx | 3 +- Source/CTest/cmCTestScriptHandler.cxx | 6 +- Source/CTest/cmCTestSubmitCommand.cxx | 5 +- Source/CTest/cmCTestSubmitHandler.cxx | 9 +- Source/CTest/cmCTestTestCommand.cxx | 7 +- Source/CTest/cmCTestTestHandler.cxx | 37 ++++---- .../CursesDialog/cmCursesCacheEntryComposite.cxx | 3 +- Source/cmCTest.cxx | 16 ++-- Source/cmCacheManager.cxx | 3 +- Source/cmComputeLinkDepends.cxx | 3 +- Source/cmComputeLinkInformation.cxx | 22 ++--- Source/cmConditionEvaluator.cxx | 2 +- Source/cmCoreTryCompile.cxx | 4 +- Source/cmCustomCommandGenerator.cxx | 10 +- Source/cmDepends.cxx | 7 +- Source/cmDependsC.cxx | 3 +- Source/cmDependsFortran.cxx | 4 +- Source/cmExportBuildAndroidMKGenerator.cxx | 4 +- Source/cmExportFileGenerator.cxx | 4 +- Source/cmExportTryCompileFileGenerator.cxx | 4 +- Source/cmExtraCodeBlocksGenerator.cxx | 6 +- Source/cmExtraEclipseCDT4Generator.cxx | 11 ++- Source/cmExtraSublimeTextGenerator.cxx | 2 +- Source/cmFileCommand.cxx | 3 +- Source/cmFileCopier.cxx | 2 +- Source/cmFindCommon.cxx | 5 +- Source/cmFindLibraryCommand.cxx | 5 +- Source/cmFindPackageCommand.cxx | 6 +- Source/cmForEachCommand.cxx | 3 +- Source/cmGeneratorExpression.cxx | 5 +- Source/cmGeneratorExpressionNode.cxx | 22 ++--- Source/cmGeneratorTarget.cxx | 97 +++++++++---------- Source/cmGhsMultiTargetGenerator.cxx | 2 +- Source/cmGlobalGenerator.cxx | 18 ++-- Source/cmGlobalGhsMultiGenerator.cxx | 2 +- Source/cmGlobalNinjaGenerator.cxx | 2 +- Source/cmGlobalVisualStudio71Generator.cxx | 2 +- Source/cmGlobalVisualStudio7Generator.cxx | 3 +- Source/cmGlobalVisualStudio8Generator.cxx | 2 +- Source/cmGlobalXCodeGenerator.cxx | 13 +-- Source/cmGraphVizWriter.cxx | 4 +- Source/cmIDEOptions.cxx | 6 +- Source/cmInstallCommand.cxx | 6 +- Source/cmInstallDirectoryGenerator.cxx | 3 +- Source/cmInstallFilesGenerator.cxx | 5 +- Source/cmInstalledFile.cxx | 3 +- Source/cmLDConfigLDConfigTool.cxx | 3 +- Source/cmListCommand.cxx | 6 +- Source/cmListFileCache.cxx | 3 +- Source/cmLocalGenerator.cxx | 28 +++--- Source/cmLocalNinjaGenerator.cxx | 5 +- Source/cmLocalUnixMakefileGenerator3.cxx | 13 ++- Source/cmLocalVisualStudio7Generator.cxx | 2 +- Source/cmMakefile.cxx | 36 +++---- Source/cmMakefileExecutableTargetGenerator.cxx | 6 +- Source/cmMakefileLibraryTargetGenerator.cxx | 10 +- Source/cmMakefileTargetGenerator.cxx | 21 ++--- Source/cmMessageCommand.cxx | 7 +- Source/cmNinjaNormalTargetGenerator.cxx | 10 +- Source/cmNinjaTargetGenerator.cxx | 27 +++--- Source/cmOutputConverter.cxx | 3 +- Source/cmOutputRequiredFilesCommand.cxx | 2 +- Source/cmParseArgumentsCommand.cxx | 12 +-- Source/cmPolicies.cxx | 2 +- Source/cmQtAutoGenInitializer.cxx | 16 ++-- Source/cmQtAutoGenerator.cxx | 4 +- Source/cmQtAutoMocUic.cxx | 12 +-- Source/cmQtAutoRcc.cxx | 4 +- Source/cmRemoveCommand.cxx | 7 +- Source/cmRuntimeDependencyArchive.cxx | 3 +- Source/cmSearchPath.cxx | 4 +- Source/cmStringAlgorithms.cxx | 105 +++++++++++++++++++++ Source/cmStringAlgorithms.h | 51 ++++++++++ Source/cmStringCommand.cxx | 2 +- Source/cmSystemTools.cxx | 95 ------------------- Source/cmSystemTools.h | 47 --------- Source/cmTarget.cxx | 10 +- Source/cmTestGenerator.cxx | 5 +- Source/cmTryRunCommand.cxx | 3 +- Source/cmVisualStudio10TargetGenerator.cxx | 10 +- Source/cmXCodeScheme.cxx | 4 +- Source/cmake.cxx | 14 +-- Source/cmakemain.cxx | 4 +- Source/cmcmd.cxx | 11 +-- Tests/CMakeLib/testStringAlgorithms.cxx | 35 +++++++ Tests/CMakeLib/testSystemTools.cxx | 16 ---- 103 files changed, 597 insertions(+), 582 deletions(-) hooks/post-receive -- CMake From kwrobot at kitware.com Fri Aug 16 15:38:55 2019 From: kwrobot at kitware.com (Kitware Robot) Date: Fri, 16 Aug 2019 15:38:55 -0400 (EDT) Subject: [Cmake-commits] CMake branch, master, updated. v3.15.2-654-g7a92fb7 Message-ID: <20190816193855.120EF102BC1@public.kitware.com> This is an automated email from the git hooks/post-receive script. It was generated because a ref change was pushed to the repository containing the project "CMake". The branch, master has been updated via 7a92fb7bf675005b7d77dc6fdb157409dace52f9 (commit) via cea253a38bb33beb64c7b36c7c75929453ec8749 (commit) from 2beed5a4ef66f415f4efa327a8c479395d262e52 (commit) Those revisions listed above that are new to this repository have not appeared on any other notification email; so we list those revisions in full, below. - Log ----------------------------------------------------------------- https://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=7a92fb7bf675005b7d77dc6fdb157409dace52f9 commit 7a92fb7bf675005b7d77dc6fdb157409dace52f9 Merge: 2beed5a cea253a Author: Kyle Edwards AuthorDate: Fri Aug 16 19:37:08 2019 +0000 Commit: Kitware Robot CommitDate: Fri Aug 16 15:37:20 2019 -0400 Merge topic 'clang-llvm-rc' cea253a38b Clang: Fall back to llvm-rc when rc is unavailable Acked-by: Kitware Robot Acked-by: Ben Boeckel Merge-request: !3687 https://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=cea253a38bb33beb64c7b36c7c75929453ec8749 commit cea253a38bb33beb64c7b36c7c75929453ec8749 Author: Gregory Mitrano AuthorDate: Tue Aug 13 00:00:06 2019 -0400 Commit: Gregory Mitrano CommitDate: Wed Aug 14 00:20:39 2019 -0400 Clang: Fall back to llvm-rc when rc is unavailable This change modifies how CMAKE_RC_COMPILER is configured to improve the out-of-box experience for developers using Clang on Windows. The previous behavior was to require the user to explicitly specify the resource compiler when CMake was called. The new behavior is to automatically attempt to locate the MSVC rc binary and use that if it's found. If rc is not available, CMake will now fall back to Clang's llvm-rc binary. With this change in place, trivial C/C++ programs can be generated with Ninja and Clang on Windows without running into errors about a missing resource compiler. Fixes: #19318 diff --git a/Modules/Platform/Windows-Clang.cmake b/Modules/Platform/Windows-Clang.cmake index b317da6..728e0b9 100644 --- a/Modules/Platform/Windows-Clang.cmake +++ b/Modules/Platform/Windows-Clang.cmake @@ -99,6 +99,21 @@ if("x${CMAKE_C_SIMULATE_ID}" STREQUAL "xMSVC" "or clang-cl as both C and C++ compilers.") endif() + if(NOT CMAKE_RC_COMPILER_INIT) + # Check if rc is already in the path + # This may happen in cases where the user is already in a visual studio environment when CMake is invoked + find_program(__RC_COMPILER_PATH NAMES rc) + + # Default to rc if it's available, otherwise fall back to llvm-rc + if(__RC_COMPILER_PATH) + set(CMAKE_RC_COMPILER_INIT rc) + else() + set(CMAKE_RC_COMPILER_INIT llvm-rc) + endif() + + unset(__RC_COMPILER_PATH CACHE) + endif() + if ( "x${CMAKE_CXX_COMPILER_FRONTEND_VARIANT}" STREQUAL "xMSVC" OR "x${CMAKE_C_COMPILER_FRONTEND_VARIANT}" STREQUAL "xMSVC" ) include(Platform/Windows-MSVC) ----------------------------------------------------------------------- Summary of changes: Modules/Platform/Windows-Clang.cmake | 15 +++++++++++++++ 1 file changed, 15 insertions(+) hooks/post-receive -- CMake From kwrobot at kitware.com Fri Aug 16 23:58:45 2019 From: kwrobot at kitware.com (Kitware Robot) Date: Fri, 16 Aug 2019 23:58:45 -0400 (EDT) Subject: [Cmake-commits] CMake branch, master, updated. v3.15.2-655-g3430144 Message-ID: <20190817035845.B22BF102A65@public.kitware.com> This is an automated email from the git hooks/post-receive script. It was generated because a ref change was pushed to the repository containing the project "CMake". The branch, master has been updated via 34301441b963a2d7e02b4a4355a6634b3bbb7977 (commit) from 7a92fb7bf675005b7d77dc6fdb157409dace52f9 (commit) Those revisions listed above that are new to this repository have not appeared on any other notification email; so we list those revisions in full, below. - Log ----------------------------------------------------------------- https://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=34301441b963a2d7e02b4a4355a6634b3bbb7977 commit 34301441b963a2d7e02b4a4355a6634b3bbb7977 Author: Kitware Robot AuthorDate: Sat Aug 17 00:01:07 2019 -0400 Commit: Kitware Robot CommitDate: Sat Aug 17 00:01:07 2019 -0400 CMake Nightly Date Stamp diff --git a/Source/CMakeVersion.cmake b/Source/CMakeVersion.cmake index 53c1559..6ecab33 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 15) -set(CMake_VERSION_PATCH 20190816) +set(CMake_VERSION_PATCH 20190817) #set(CMake_VERSION_RC 0) set(CMake_VERSION_IS_DIRTY 0) ----------------------------------------------------------------------- Summary of changes: Source/CMakeVersion.cmake | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) hooks/post-receive -- CMake From kwrobot at kitware.com Sat Aug 17 23:58:10 2019 From: kwrobot at kitware.com (Kitware Robot) Date: Sat, 17 Aug 2019 23:58:10 -0400 (EDT) Subject: [Cmake-commits] CMake branch, master, updated. v3.15.2-656-g06e32a0 Message-ID: <20190818035810.F1E0AF99C9@public.kitware.com> This is an automated email from the git hooks/post-receive script. It was generated because a ref change was pushed to the repository containing the project "CMake". The branch, master has been updated via 06e32a089df03c158eaee7525de3ac1be25d8136 (commit) from 34301441b963a2d7e02b4a4355a6634b3bbb7977 (commit) Those revisions listed above that are new to this repository have not appeared on any other notification email; so we list those revisions in full, below. - Log ----------------------------------------------------------------- https://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=06e32a089df03c158eaee7525de3ac1be25d8136 commit 06e32a089df03c158eaee7525de3ac1be25d8136 Author: Kitware Robot AuthorDate: Sun Aug 18 00:01:05 2019 -0400 Commit: Kitware Robot CommitDate: Sun Aug 18 00:01:05 2019 -0400 CMake Nightly Date Stamp diff --git a/Source/CMakeVersion.cmake b/Source/CMakeVersion.cmake index 6ecab33..c9971d3 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 15) -set(CMake_VERSION_PATCH 20190817) +set(CMake_VERSION_PATCH 20190818) #set(CMake_VERSION_RC 0) set(CMake_VERSION_IS_DIRTY 0) ----------------------------------------------------------------------- Summary of changes: Source/CMakeVersion.cmake | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) hooks/post-receive -- CMake From kwrobot at kitware.com Mon Aug 19 00:02:47 2019 From: kwrobot at kitware.com (Kitware Robot) Date: Mon, 19 Aug 2019 00:02:47 -0400 (EDT) Subject: [Cmake-commits] CMake branch, master, updated. v3.15.2-657-g1958c78 Message-ID: <20190819040247.15BA7FE61B@public.kitware.com> This is an automated email from the git hooks/post-receive script. It was generated because a ref change was pushed to the repository containing the project "CMake". The branch, master has been updated via 1958c78fe1d600e1d1d4cde480907ac6fcad4a1e (commit) from 06e32a089df03c158eaee7525de3ac1be25d8136 (commit) Those revisions listed above that are new to this repository have not appeared on any other notification email; so we list those revisions in full, below. - Log ----------------------------------------------------------------- https://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=1958c78fe1d600e1d1d4cde480907ac6fcad4a1e commit 1958c78fe1d600e1d1d4cde480907ac6fcad4a1e Author: Kitware Robot AuthorDate: Mon Aug 19 00:01:07 2019 -0400 Commit: Kitware Robot CommitDate: Mon Aug 19 00:01:07 2019 -0400 CMake Nightly Date Stamp diff --git a/Source/CMakeVersion.cmake b/Source/CMakeVersion.cmake index c9971d3..9a76073 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 15) -set(CMake_VERSION_PATCH 20190818) +set(CMake_VERSION_PATCH 20190819) #set(CMake_VERSION_RC 0) set(CMake_VERSION_IS_DIRTY 0) ----------------------------------------------------------------------- Summary of changes: Source/CMakeVersion.cmake | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) hooks/post-receive -- CMake From kwrobot at kitware.com Mon Aug 19 13:32:27 2019 From: kwrobot at kitware.com (Kitware Robot) Date: Mon, 19 Aug 2019 13:32:27 -0400 (EDT) Subject: [Cmake-commits] CMake branch, master, updated. v3.15.2-659-gc41c792 Message-ID: <20190819173227.7C7FDF9E47@public.kitware.com> This is an automated email from the git hooks/post-receive script. It was generated because a ref change was pushed to the repository containing the project "CMake". The branch, master has been updated via c41c79285b5ebb7dd914a6e714aa553bb5078641 (commit) via 5480f65ab1c7b7ffae624f9b7596b36370aa8c9b (commit) from 1958c78fe1d600e1d1d4cde480907ac6fcad4a1e (commit) Those revisions listed above that are new to this repository have not appeared on any other notification email; so we list those revisions in full, below. - Log ----------------------------------------------------------------- https://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=c41c79285b5ebb7dd914a6e714aa553bb5078641 commit c41c79285b5ebb7dd914a6e714aa553bb5078641 Merge: 1958c78 5480f65 Author: Kyle Edwards AuthorDate: Mon Aug 19 17:25:07 2019 +0000 Commit: Kitware Robot CommitDate: Mon Aug 19 13:25:16 2019 -0400 Merge topic 'swift-import-library-location' 5480f65ab1 Swift: honour `IMPLIB_LOCATION` property Acked-by: Kitware Robot Acked-by: Ben Boeckel Merge-request: !3686 https://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=5480f65ab1c7b7ffae624f9b7596b36370aa8c9b commit 5480f65ab1c7b7ffae624f9b7596b36370aa8c9b Author: Saleem Abdulrasool AuthorDate: Sun Aug 11 22:27:46 2019 -0700 Commit: Saleem Abdulrasool CommitDate: Sun Aug 11 22:29:49 2019 -0700 Swift: honour `IMPLIB_LOCATION` property The rules did not account for the import library location (through ``) and instead would always write the import library to the default location (next to the shared library/executable). This prevented the use of `CMAKE_RUNTIME_OUTPUT_LOCATION` and `CMAKE_ARCHIVE_OUTPUT_LOCATION`. diff --git a/Modules/CMakeSwiftInformation.cmake b/Modules/CMakeSwiftInformation.cmake index 54e441c..bf3ca40 100644 --- a/Modules/CMakeSwiftInformation.cmake +++ b/Modules/CMakeSwiftInformation.cmake @@ -64,8 +64,12 @@ if(NOT CMAKE_Swift_NUM_THREADS MATCHES "^[0-9]+$") cmake_host_system_information(RESULT CMAKE_Swift_NUM_THREADS QUERY NUMBER_OF_LOGICAL_CORES) endif() +if(CMAKE_SYSTEM_NAME STREQUAL Windows) + set(CMAKE_Swift_IMPLIB_LINKER_FLAGS "-Xlinker -implib:") +endif() + if(NOT CMAKE_Swift_CREATE_SHARED_LIBRARY) - set(CMAKE_Swift_CREATE_SHARED_LIBRARY " -output-file-map -incremental -num-threads ${CMAKE_Swift_NUM_THREADS} -emit-library -o -module-name -module-link-name -emit-module -emit-module-path -emit-dependencies ") + set(CMAKE_Swift_CREATE_SHARED_LIBRARY " -output-file-map -incremental -num-threads ${CMAKE_Swift_NUM_THREADS} -emit-library -o -module-name -module-link-name -emit-module -emit-module-path -emit-dependencies ${CMAKE_Swift_IMPLIB_LINKER_FLAGS} ") endif() if(NOT CMAKE_Swift_CREATE_SHARED_MODULE) @@ -73,7 +77,7 @@ if(NOT CMAKE_Swift_CREATE_SHARED_MODULE) endif() if(NOT CMAKE_Swift_LINK_EXECUTABLE) - set(CMAKE_Swift_LINK_EXECUTABLE " -output-file-map -incremental -num-threads ${CMAKE_Swift_NUM_THREADS} -emit-executable -o -emit-module -emit-module-path -emit-dependencies ") + set(CMAKE_Swift_LINK_EXECUTABLE " -output-file-map -incremental -num-threads ${CMAKE_Swift_NUM_THREADS} -emit-executable -o -emit-module -emit-module-path -emit-dependencies ${CMAKE_Swift_IMPLIB_LINKER_FLAGS} ") endif() if(NOT CMAKE_Swift_CREATE_STATIC_LIBRARY) ----------------------------------------------------------------------- Summary of changes: Modules/CMakeSwiftInformation.cmake | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) hooks/post-receive -- CMake From kwrobot at kitware.com Mon Aug 19 15:02:28 2019 From: kwrobot at kitware.com (Kitware Robot) Date: Mon, 19 Aug 2019 15:02:28 -0400 (EDT) Subject: [Cmake-commits] CMake branch, master, updated. v3.15.2-665-ge977867 Message-ID: <20190819190228.6421FA2C8C@public.kitware.com> This is an automated email from the git hooks/post-receive script. It was generated because a ref change was pushed to the repository containing the project "CMake". The branch, master has been updated via e977867a1245309b7fbd0e3faaff26c68087f491 (commit) via 265b23e5c23ada4f801a5d972c7937e6cf75644e (commit) via 29488892e5c1cb2406d14389589e03c2d03006cf (commit) via 47937219ee04d0a2006a199dc7bcd6fa23caf4d8 (commit) via ff7f8b81d14f306374346e56af38f19e03ff93ee (commit) via ea0294c281b27b4aff968d94dda98989b0f16e39 (commit) from c41c79285b5ebb7dd914a6e714aa553bb5078641 (commit) Those revisions listed above that are new to this repository have not appeared on any other notification email; so we list those revisions in full, below. - Log ----------------------------------------------------------------- https://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=e977867a1245309b7fbd0e3faaff26c68087f491 commit e977867a1245309b7fbd0e3faaff26c68087f491 Merge: 265b23e 4793721 Author: Brad King AuthorDate: Mon Aug 19 18:55:58 2019 +0000 Commit: Kitware Robot CommitDate: Mon Aug 19 14:56:14 2019 -0400 Merge topic 'solaris_clang' 47937219ee Solaris: Add support for Clang compiler Acked-by: Kitware Robot Merge-request: !3672 https://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=265b23e5c23ada4f801a5d972c7937e6cf75644e commit 265b23e5c23ada4f801a5d972c7937e6cf75644e Merge: 2948889 ff7f8b8 Author: Brad King AuthorDate: Mon Aug 19 14:54:29 2019 -0400 Commit: Brad King CommitDate: Mon Aug 19 14:54:29 2019 -0400 Merge branch 'release-3.15' https://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=29488892e5c1cb2406d14389589e03c2d03006cf commit 29488892e5c1cb2406d14389589e03c2d03006cf Merge: c41c792 ea0294c Author: Brad King AuthorDate: Mon Aug 19 18:53:10 2019 +0000 Commit: Kitware Robot CommitDate: Mon Aug 19 14:53:20 2019 -0400 Merge topic 'msvc-runtime-library-flang' ea0294c281 Flang: Implement MSVC runtime library abstraction Acked-by: Kitware Robot Merge-request: !3674 https://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=47937219ee04d0a2006a199dc7bcd6fa23caf4d8 commit 47937219ee04d0a2006a199dc7bcd6fa23caf4d8 Author: Libor Bukata AuthorDate: Fri Aug 9 13:33:35 2019 +0200 Commit: Brad King CommitDate: Fri Aug 9 12:53:05 2019 -0400 Solaris: Add support for Clang compiler Inspired-by: Rainer Orth Fixes: #19456 diff --git a/Help/release/dev/solaris_clang.rst b/Help/release/dev/solaris_clang.rst new file mode 100644 index 0000000..0b023ee --- /dev/null +++ b/Help/release/dev/solaris_clang.rst @@ -0,0 +1,4 @@ +solaris_clang +------------- + +* The ``Clang`` compiler is now supported on ``Solaris``. diff --git a/Modules/Platform/SunOS-Clang-C.cmake b/Modules/Platform/SunOS-Clang-C.cmake new file mode 100644 index 0000000..f06eb8f --- /dev/null +++ b/Modules/Platform/SunOS-Clang-C.cmake @@ -0,0 +1 @@ +include(Platform/SunOS-GNU-C) diff --git a/Modules/Platform/SunOS-Clang-CXX.cmake b/Modules/Platform/SunOS-Clang-CXX.cmake new file mode 100644 index 0000000..869182c --- /dev/null +++ b/Modules/Platform/SunOS-Clang-CXX.cmake @@ -0,0 +1 @@ +include(Platform/SunOS-GNU-CXX) ----------------------------------------------------------------------- Summary of changes: Help/release/dev/solaris_clang.rst | 4 ++++ Modules/Platform/SunOS-Clang-C.cmake | 1 + Modules/Platform/SunOS-Clang-CXX.cmake | 1 + Modules/Platform/Windows-Flang-Fortran.cmake | 5 +++++ Tests/MSVCRuntimeLibrary/Fortran/CMakeLists.txt | 16 ++++++++++++---- 5 files changed, 23 insertions(+), 4 deletions(-) create mode 100644 Help/release/dev/solaris_clang.rst create mode 100644 Modules/Platform/SunOS-Clang-C.cmake create mode 100644 Modules/Platform/SunOS-Clang-CXX.cmake hooks/post-receive -- CMake From kwrobot at kitware.com Mon Aug 19 15:02:28 2019 From: kwrobot at kitware.com (Kitware Robot) Date: Mon, 19 Aug 2019 15:02:28 -0400 (EDT) Subject: [Cmake-commits] CMake branch, release, updated. v3.15.2-2-gff7f8b8 Message-ID: <20190819190228.A5F251025B1@public.kitware.com> This is an automated email from the git hooks/post-receive script. It was generated because a ref change was pushed to the repository containing the project "CMake". The branch, release has been updated via ff7f8b81d14f306374346e56af38f19e03ff93ee (commit) via ea0294c281b27b4aff968d94dda98989b0f16e39 (commit) from 40bbe50e23c06232ccf1c49589dde5dd84e1ac31 (commit) Those revisions listed above that are new to this repository have not appeared on any other notification email; so we list those revisions in full, below. - Log ----------------------------------------------------------------- ----------------------------------------------------------------------- Summary of changes: Modules/Platform/Windows-Flang-Fortran.cmake | 5 +++++ Tests/MSVCRuntimeLibrary/Fortran/CMakeLists.txt | 16 ++++++++++++---- 2 files changed, 17 insertions(+), 4 deletions(-) hooks/post-receive -- CMake From kwrobot at kitware.com Mon Aug 19 15:12:23 2019 From: kwrobot at kitware.com (Kitware Robot) Date: Mon, 19 Aug 2019 15:12:23 -0400 (EDT) Subject: [Cmake-commits] CMake branch, master, updated. v3.15.2-675-ge374682 Message-ID: <20190819191223.CBE09A2C8C@public.kitware.com> This is an automated email from the git hooks/post-receive script. It was generated because a ref change was pushed to the repository containing the project "CMake". The branch, master has been updated via e3746821dfc37c8514c934e1e5d62d0ec99adc9f (commit) via 5f7386dd19c27690a1187a69f0861faf51899264 (commit) via 0b8524baa68944ee148c8b48b4ee937ab315175d (commit) via 0f914b7f26b80163c86cd07959d0f32912ce2fcc (commit) via da26b3be8948471dd2320d1e44af9eb5dfaa0f6a (commit) via f1c529c4fbea1963f7df92597a350e066319a1e1 (commit) via 3b6c62be238f48b23d7dad302702f723dc5ef89c (commit) via 20e580be010e95a1668eb00728c39ab9dea9e2e5 (commit) via 5b7650216b92b89e0dd083191ad1178aefbb6a9f (commit) via 4d83e47c054ceb1d3b9a7ae5f2f385e1632675c6 (commit) from e977867a1245309b7fbd0e3faaff26c68087f491 (commit) Those revisions listed above that are new to this repository have not appeared on any other notification email; so we list those revisions in full, below. - Log ----------------------------------------------------------------- https://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=e3746821dfc37c8514c934e1e5d62d0ec99adc9f commit e3746821dfc37c8514c934e1e5d62d0ec99adc9f Merge: 5f7386d 4d83e47 Author: Brad King AuthorDate: Mon Aug 19 19:08:11 2019 +0000 Commit: Kitware Robot CommitDate: Mon Aug 19 15:08:22 2019 -0400 Merge topic 'swift-mode-flags' 4d83e47c05 Swift: define `CMAKE_Swift_FLAGS` correctly Acked-by: Kitware Robot Acked-by: Ben Boeckel Merge-request: !3684 https://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=5f7386dd19c27690a1187a69f0861faf51899264 commit 5f7386dd19c27690a1187a69f0861faf51899264 Merge: 0b8524b da26b3b Author: Brad King AuthorDate: Mon Aug 19 19:05:34 2019 +0000 Commit: Kitware Robot CommitDate: Mon Aug 19 15:06:47 2019 -0400 Merge topic 'string-literal-append' da26b3be89 avoid adding multiple consecutive string literals to std::string Acked-by: Kitware Robot Merge-request: !3698 https://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=0b8524baa68944ee148c8b48b4ee937ab315175d commit 0b8524baa68944ee148c8b48b4ee937ab315175d Merge: 0f914b7 f1c529c Author: Brad King AuthorDate: Mon Aug 19 19:04:09 2019 +0000 Commit: Kitware Robot CommitDate: Mon Aug 19 15:05:27 2019 -0400 Merge topic 'cmCryptoHash_string_view' f1c529c4fb cmCryptoHash: Accept cm::string_view input Acked-by: Kitware Robot Merge-request: !3697 https://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=0f914b7f26b80163c86cd07959d0f32912ce2fcc commit 0f914b7f26b80163c86cd07959d0f32912ce2fcc Merge: e977867 3b6c62b Author: Brad King AuthorDate: Mon Aug 19 19:03:41 2019 +0000 Commit: Kitware Robot CommitDate: Mon Aug 19 15:03:53 2019 -0400 Merge topic 'cmStringAlgorithms_IsOn' 3b6c62be23 cmSystemTools: Remove IsInternallyOn, IsNOTFOUND, IsOn, IsOff 20e580be01 Source sweep: Use cmIsOn instead of cmSystemTools::IsOn 5b7650216b cmStringAlgorithms: Add cmIsInternallyOn, cmIsNOTFOUND, cmIsOn, cmIsOff Acked-by: Kitware Robot Merge-request: !3691 https://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=da26b3be8948471dd2320d1e44af9eb5dfaa0f6a commit da26b3be8948471dd2320d1e44af9eb5dfaa0f6a Author: Rolf Eike Beer AuthorDate: Sun Aug 18 14:22:11 2019 +0200 Commit: Rolf Eike Beer CommitDate: Sun Aug 18 14:22:11 2019 +0200 avoid adding multiple consecutive string literals to std::string While at it change some single character additions to be of type char. diff --git a/Source/CTest/cmCTestCoverageHandler.cxx b/Source/CTest/cmCTestCoverageHandler.cxx index 54fe612..2a68544 100644 --- a/Source/CTest/cmCTestCoverageHandler.cxx +++ b/Source/CTest/cmCTestCoverageHandler.cxx @@ -2223,8 +2223,7 @@ int cmCTestCoverageHandler::GetLabelId(std::string const& label) void cmCTestCoverageHandler::LoadLabels() { std::string fileList = this->CTest->GetBinaryDir(); - fileList += "/CMakeFiles"; - fileList += "/TargetDirectories.txt"; + fileList += "/CMakeFiles/TargetDirectories.txt"; cmCTestOptionalLog(this->CTest, HANDLER_VERBOSE_OUTPUT, " target directory list [" << fileList << "]\n", this->Quiet); diff --git a/Source/CTest/cmCTestLaunch.cxx b/Source/CTest/cmCTestLaunch.cxx index 739cc58..4708a71 100644 --- a/Source/CTest/cmCTestLaunch.cxx +++ b/Source/CTest/cmCTestLaunch.cxx @@ -283,8 +283,7 @@ void cmCTestLaunch::LoadLabels() // Labels are listed in per-target files. std::string fname = this->OptionBuildDir; - fname += "/CMakeFiles"; - fname += "/"; + fname += "/CMakeFiles/"; fname += this->OptionTargetName; fname += ".dir/Labels.txt"; diff --git a/Source/cmCacheManager.cxx b/Source/cmCacheManager.cxx index 8ebab0a..37cc5fd 100644 --- a/Source/cmCacheManager.cxx +++ b/Source/cmCacheManager.cxx @@ -27,8 +27,7 @@ cmCacheManager::cmCacheManager() void cmCacheManager::CleanCMakeFiles(const std::string& path) { std::string glob = path; - glob += "/CMakeFiles"; - glob += "/*.cmake"; + glob += "/CMakeFiles/*.cmake"; cmsys::Glob globIt; globIt.FindFiles(glob); std::vector files = globIt.GetFiles(); diff --git a/Source/cmCoreTryCompile.cxx b/Source/cmCoreTryCompile.cxx index c0c4a25..e5e1ecf 100644 --- a/Source/cmCoreTryCompile.cxx +++ b/Source/cmCoreTryCompile.cxx @@ -411,8 +411,7 @@ int cmCoreTryCompile::TryCompileCode(std::vector const& argv, // compute the binary dir when TRY_COMPILE is called with a src file // signature if (this->SrcFileSignature) { - this->BinaryDirectory += "/CMakeFiles"; - this->BinaryDirectory += "/CMakeTmp"; + this->BinaryDirectory += "/CMakeFiles/CMakeTmp"; } else { // only valid for srcfile signatures if (!compileDefs.empty()) { diff --git a/Source/cmFileCommand.cxx b/Source/cmFileCommand.cxx index 87e97dd..7f300a3 100644 --- a/Source/cmFileCommand.cxx +++ b/Source/cmFileCommand.cxx @@ -469,8 +469,7 @@ bool HandleStringsCommand(std::vector const& args, // TODO: should work without temp file, but just on a memory buffer std::string binaryFileName = status.GetMakefile().GetCurrentBinaryDirectory(); - binaryFileName += "/CMakeFiles"; - binaryFileName += "/FileCommandStringsBinaryFile"; + binaryFileName += "/CMakeFiles/FileCommandStringsBinaryFile"; if (cmHexFileConverter::TryConvert(fileName, binaryFileName)) { fileName = binaryFileName; } diff --git a/Source/cmGeneratorTarget.cxx b/Source/cmGeneratorTarget.cxx index 9412d82..d4f2da8 100644 --- a/Source/cmGeneratorTarget.cxx +++ b/Source/cmGeneratorTarget.cxx @@ -6442,8 +6442,7 @@ bool cmGeneratorTarget::NeedImportLibraryName(std::string const& config) const std::string cmGeneratorTarget::GetSupportDirectory() const { std::string dir = this->LocalGenerator->GetCurrentBinaryDirectory(); - dir += "/CMakeFiles"; - dir += "/"; + dir += "/CMakeFiles/"; dir += this->GetName(); #if defined(__VMS) dir += "_dir"; diff --git a/Source/cmGlobalGenerator.cxx b/Source/cmGlobalGenerator.cxx index 86fcae0..5e5ec4e 100644 --- a/Source/cmGlobalGenerator.cxx +++ b/Source/cmGlobalGenerator.cxx @@ -522,7 +522,7 @@ void cmGlobalGenerator::EnableLanguage( if (!this->ConfiguredFilesPath.empty()) { rootBin = this->ConfiguredFilesPath; } - rootBin += "/"; + rootBin += '/'; rootBin += cmVersion::GetCMakeVersion(); // set the dir for parent files so they can be used by modules @@ -1278,8 +1278,7 @@ void cmGlobalGenerator::Configure() const char* logs[] = { "CMakeOutput.log", "CMakeError.log", nullptr }; for (const char** log = logs; *log; ++log) { std::string f = this->CMakeInstance->GetHomeOutputDirectory(); - f += "/CMakeFiles"; - f += "/"; + f += "/CMakeFiles/"; f += *log; if (cmSystemTools::FileExists(f)) { msg << "\nSee also \"" << f << "\"."; @@ -2853,8 +2852,7 @@ void cmGlobalGenerator::CheckRuleHashes() #if !defined(CMAKE_BOOTSTRAP) std::string home = this->GetCMakeInstance()->GetHomeOutputDirectory(); std::string pfile = home; - pfile += "/CMakeFiles"; - pfile += "/CMakeRuleHashes.txt"; + pfile += "/CMakeFiles/CMakeRuleHashes.txt"; this->CheckRuleHashes(pfile, home); this->WriteRuleHashes(pfile); #endif @@ -2931,8 +2929,7 @@ void cmGlobalGenerator::WriteSummary() { // Record all target directories in a central location. std::string fname = this->CMakeInstance->GetHomeOutputDirectory(); - fname += "/CMakeFiles"; - fname += "/TargetDirectories.txt"; + fname += "/CMakeFiles/TargetDirectories.txt"; cmGeneratedFileStream fout(fname); for (cmLocalGenerator* lg : this->LocalGenerators) { diff --git a/Source/cmGlobalUnixMakefileGenerator3.cxx b/Source/cmGlobalUnixMakefileGenerator3.cxx index 35af0e1..bd10d86 100644 --- a/Source/cmGlobalUnixMakefileGenerator3.cxx +++ b/Source/cmGlobalUnixMakefileGenerator3.cxx @@ -147,9 +147,7 @@ void cmGlobalUnixMakefileGenerator3::Generate() } for (cmLocalGenerator* lg : this->LocalGenerators) { std::string markFileName = lg->GetCurrentBinaryDirectory(); - markFileName += "/"; - markFileName += "/CMakeFiles"; - markFileName += "/progress.marks"; + markFileName += "/CMakeFiles/progress.marks"; cmGeneratedFileStream markFile(markFileName); markFile << this->CountProgressMarksInAll(lg) << "\n"; } @@ -198,8 +196,7 @@ void cmGlobalUnixMakefileGenerator3::WriteMainMakefile2() // see if the build system must be regenerated. std::string makefileName = this->GetCMakeInstance()->GetHomeOutputDirectory(); - makefileName += "/CMakeFiles"; - makefileName += "/Makefile2"; + makefileName += "/CMakeFiles/Makefile2"; cmGeneratedFileStream makefileStream(makefileName, false, this->GetMakefileEncoding()); if (!makefileStream) { @@ -258,8 +255,7 @@ void cmGlobalUnixMakefileGenerator3::WriteMainCMakefile() // see if the build system must be regenerated. std::string cmakefileName = this->GetCMakeInstance()->GetHomeOutputDirectory(); - cmakefileName += "/CMakeFiles"; - cmakefileName += "/Makefile.cmake"; + cmakefileName += "/CMakeFiles/Makefile.cmake"; cmGeneratedFileStream cmakefileStream(cmakefileName); if (!cmakefileStream) { return; @@ -320,8 +316,7 @@ void cmGlobalUnixMakefileGenerator3::WriteMainCMakefile() // Build the path to the cache check file. std::string check = this->GetCMakeInstance()->GetHomeOutputDirectory(); - check += "/CMakeFiles"; - check += "/cmake.check_cache"; + check += "/CMakeFiles/cmake.check_cache"; // Set the corresponding makefile in the cmake file. cmakefileStream << "# The corresponding makefile is:\n" @@ -352,8 +347,7 @@ void cmGlobalUnixMakefileGenerator3::WriteMainCMakefile() for (cmLocalGenerator* localGen : this->LocalGenerators) { lg = static_cast(localGen); tmpStr = lg->GetCurrentBinaryDirectory(); - tmpStr += "/CMakeFiles"; - tmpStr += "/CMakeDirectoryInformation.cmake"; + tmpStr += "/CMakeFiles/CMakeDirectoryInformation.cmake"; cmakefileStream << " \"" << lg->MaybeConvertToRelativePath(binDir, tmpStr) << "\"\n"; diff --git a/Source/cmGlobalVisualStudio10Generator.cxx b/Source/cmGlobalVisualStudio10Generator.cxx index 720b6c5..02d25fb 100644 --- a/Source/cmGlobalVisualStudio10Generator.cxx +++ b/Source/cmGlobalVisualStudio10Generator.cxx @@ -1038,8 +1038,7 @@ std::string cmGlobalVisualStudio10Generator::GenerateRuleFile( // The VS 10 generator needs to create the .rule files on disk. // Hide them away under the CMakeFiles directory. std::string ruleDir = this->GetCMakeInstance()->GetHomeOutputDirectory(); - ruleDir += "/CMakeFiles"; - ruleDir += "/"; + ruleDir += "/CMakeFiles/"; ruleDir += cmSystemTools::ComputeStringMD5( cmSystemTools::GetFilenamePath(output).c_str()); std::string ruleFile = ruleDir + "/"; diff --git a/Source/cmGlobalXCodeGenerator.cxx b/Source/cmGlobalXCodeGenerator.cxx index 19e64e4..5f3f100 100644 --- a/Source/cmGlobalXCodeGenerator.cxx +++ b/Source/cmGlobalXCodeGenerator.cxx @@ -1399,8 +1399,7 @@ void cmGlobalXCodeGenerator::ForceLinkerLanguage(cmGeneratorTarget* gtgt) // language. cmMakefile* mf = gtgt->Target->GetMakefile(); std::string fname = gtgt->GetLocalGenerator()->GetCurrentBinaryDirectory(); - fname += "/CMakeFiles"; - fname += "/"; + fname += "/CMakeFiles/"; fname += gtgt->GetName(); fname += "-CMakeForceLinker"; fname += "."; @@ -3701,8 +3700,7 @@ std::string cmGlobalXCodeGenerator::ComputeInfoPListLocation( cmGeneratorTarget* target) { std::string plist = target->GetLocalGenerator()->GetCurrentBinaryDirectory(); - plist += "/CMakeFiles"; - plist += "/"; + plist += "/CMakeFiles/"; plist += target->GetName(); plist += ".dir/Info.plist"; return plist; diff --git a/Source/cmInstallExportGenerator.cxx b/Source/cmInstallExportGenerator.cxx index af06b9d..d4562de 100644 --- a/Source/cmInstallExportGenerator.cxx +++ b/Source/cmInstallExportGenerator.cxx @@ -57,8 +57,7 @@ void cmInstallExportGenerator::ComputeTempDir() // Choose a temporary directory in which to generate the import // files to be installed. this->TempDir = this->LocalGenerator->GetCurrentBinaryDirectory(); - this->TempDir += "/CMakeFiles"; - this->TempDir += "/Export"; + this->TempDir += "/CMakeFiles/Export"; if (this->Destination.empty()) { return; } diff --git a/Source/cmInstallTargetGenerator.cxx b/Source/cmInstallTargetGenerator.cxx index 4e0be5e..ed1c80a 100644 --- a/Source/cmInstallTargetGenerator.cxx +++ b/Source/cmInstallTargetGenerator.cxx @@ -88,8 +88,7 @@ void cmInstallTargetGenerator::GenerateScriptForConfig( if (this->Target->NeedRelinkBeforeInstall(config)) { fromDirConfig = this->Target->GetLocalGenerator()->GetCurrentBinaryDirectory(); - fromDirConfig += "/CMakeFiles"; - fromDirConfig += "/CMakeRelink.dir/"; + fromDirConfig += "/CMakeFiles/CMakeRelink.dir/"; } else { cmStateEnums::ArtifactType artifact = this->ImportLibrary ? cmStateEnums::ImportLibraryArtifact diff --git a/Source/cmLocalUnixMakefileGenerator3.cxx b/Source/cmLocalUnixMakefileGenerator3.cxx index a089682..0638e54 100644 --- a/Source/cmLocalUnixMakefileGenerator3.cxx +++ b/Source/cmLocalUnixMakefileGenerator3.cxx @@ -428,8 +428,7 @@ void cmLocalUnixMakefileGenerator3::WriteLocalMakefileTargets( void cmLocalUnixMakefileGenerator3::WriteDirectoryInformationFile() { std::string infoFileName = this->GetCurrentBinaryDirectory(); - infoFileName += "/CMakeFiles"; - infoFileName += "/CMakeDirectoryInformation.cmake"; + infoFileName += "/CMakeFiles/CMakeDirectoryInformation.cmake"; // Open the output file. cmGeneratedFileStream infoFileStream(infoFileName); @@ -1345,8 +1344,7 @@ bool cmLocalUnixMakefileGenerator3::UpdateDependencies( bool needRescanDirInfo = false; { std::string dirInfoFile = this->GetCurrentBinaryDirectory(); - dirInfoFile += "/CMakeFiles"; - dirInfoFile += "/CMakeDirectoryInformation.cmake"; + dirInfoFile += "/CMakeFiles/CMakeDirectoryInformation.cmake"; int result; if (!ftc->Compare(internalDependFile, dirInfoFile, &result) || result < 0) { @@ -1411,8 +1409,7 @@ bool cmLocalUnixMakefileGenerator3::ScanDependencies( bool haveDirectoryInfo = false; { std::string dirInfoFile = this->GetCurrentBinaryDirectory(); - dirInfoFile += "/CMakeFiles"; - dirInfoFile += "/CMakeDirectoryInformation.cmake"; + dirInfoFile += "/CMakeFiles/CMakeDirectoryInformation.cmake"; if (mf->ReadListFile(dirInfoFile) && !cmSystemTools::GetErrorOccuredFlag()) { haveDirectoryInfo = true; @@ -1641,8 +1638,7 @@ void cmLocalUnixMakefileGenerator3::WriteLocalAllRules( progCmd << this->ConvertToOutputFormat( cmSystemTools::CollapseFullPath(progressDir), cmOutputConverter::SHELL); - std::string progressFile = "/CMakeFiles"; - progressFile += "/progress.marks"; + std::string progressFile = "/CMakeFiles/progress.marks"; std::string progressFileNameFull = this->ConvertToFullPath(progressFile); progCmd << " " << this->ConvertToOutputFormat( @@ -1650,8 +1646,7 @@ void cmLocalUnixMakefileGenerator3::WriteLocalAllRules( cmOutputConverter::SHELL); commands.push_back(progCmd.str()); } - std::string mf2Dir = "CMakeFiles/"; - mf2Dir += "Makefile2"; + std::string mf2Dir = "CMakeFiles/Makefile2"; commands.push_back(this->GetRecursiveMakeCall(mf2Dir, recursiveTarget)); this->CreateCDCommand(commands, this->GetBinaryDirectory(), this->GetCurrentBinaryDirectory()); diff --git a/Source/cmLocalVisualStudio7Generator.cxx b/Source/cmLocalVisualStudio7Generator.cxx index 3d76396..893e14e 100644 --- a/Source/cmLocalVisualStudio7Generator.cxx +++ b/Source/cmLocalVisualStudio7Generator.cxx @@ -98,8 +98,7 @@ void cmLocalVisualStudio7Generator::FixGlobalTargets() force_commands.push_back(force_command); std::string no_main_dependency; std::string force = this->GetCurrentBinaryDirectory(); - force += "/CMakeFiles"; - force += "/"; + force += "/CMakeFiles/"; force += l->GetName(); force += "_force"; if (cmSourceFile* file = this->Makefile->AddCustomCommandToOutput( @@ -147,8 +146,7 @@ void cmLocalVisualStudio7Generator::WriteStampFiles() std::string stampName = this->GetCurrentBinaryDirectory(); stampName += "/CMakeFiles"; cmSystemTools::MakeDirectory(stampName.c_str()); - stampName += "/"; - stampName += "generate.stamp"; + stampName += "/generate.stamp"; cmsys::ofstream stamp(stampName.c_str()); stamp << "# CMake generation timestamp file for this directory.\n"; diff --git a/Source/cmMakefile.cxx b/Source/cmMakefile.cxx index 657c3bf..36d9bb6 100644 --- a/Source/cmMakefile.cxx +++ b/Source/cmMakefile.cxx @@ -1182,8 +1182,7 @@ cmTarget* cmMakefile::AddUtilityCommand( // Store the custom command in the target. if (!commandLines.empty() || !depends.empty()) { std::string force = this->GetCurrentBinaryDirectory(); - force += "/CMakeFiles"; - force += "/"; + force += "/CMakeFiles/"; force += utilityName; std::vector forced; forced.push_back(force); diff --git a/Source/cmMakefileExecutableTargetGenerator.cxx b/Source/cmMakefileExecutableTargetGenerator.cxx index 1335f13..097ce45 100644 --- a/Source/cmMakefileExecutableTargetGenerator.cxx +++ b/Source/cmMakefileExecutableTargetGenerator.cxx @@ -297,14 +297,13 @@ void cmMakefileExecutableTargetGenerator::WriteExecutableRule(bool relink) if (this->GeneratorTarget->IsAppBundleOnApple()) { this->OSXBundleGenerator->CreateAppBundle(targetNames.Output, outpath); } - outpath += "/"; + outpath += '/'; std::string outpathImp; if (relink) { outpath = this->Makefile->GetCurrentBinaryDirectory(); - outpath += "/CMakeFiles"; - outpath += "/CMakeRelink.dir"; + outpath += "/CMakeFiles/CMakeRelink.dir"; cmSystemTools::MakeDirectory(outpath); - outpath += "/"; + outpath += '/'; if (!targetNames.ImportLibrary.empty()) { outpathImp = outpath; } @@ -314,7 +313,7 @@ void cmMakefileExecutableTargetGenerator::WriteExecutableRule(bool relink) outpathImp = this->GeneratorTarget->GetDirectory( this->ConfigName, cmStateEnums::ImportLibraryArtifact); cmSystemTools::MakeDirectory(outpathImp); - outpathImp += "/"; + outpathImp += '/'; } } @@ -325,7 +324,7 @@ void cmMakefileExecutableTargetGenerator::WriteExecutableRule(bool relink) std::string pdbOutputPath = this->GeneratorTarget->GetPDBDirectory(this->ConfigName); cmSystemTools::MakeDirectory(pdbOutputPath); - pdbOutputPath += "/"; + pdbOutputPath += '/'; std::string targetFullPath = outpath + targetNames.Output; std::string targetFullPathReal = outpath + targetNames.Real; diff --git a/Source/cmMakefileLibraryTargetGenerator.cxx b/Source/cmMakefileLibraryTargetGenerator.cxx index eb0c30c..45c74cb 100644 --- a/Source/cmMakefileLibraryTargetGenerator.cxx +++ b/Source/cmMakefileLibraryTargetGenerator.cxx @@ -465,30 +465,29 @@ void cmMakefileLibraryTargetGenerator::WriteLibraryRules( outpath = this->GeneratorTarget->GetDirectory(this->ConfigName); this->OSXBundleGenerator->CreateFramework(this->TargetNames.Output, outpath); - outpath += "/"; + outpath += '/'; } else if (this->GeneratorTarget->IsCFBundleOnApple()) { outpath = this->GeneratorTarget->GetDirectory(this->ConfigName); this->OSXBundleGenerator->CreateCFBundle(this->TargetNames.Output, outpath); - outpath += "/"; + outpath += '/'; } else if (relink) { outpath = this->Makefile->GetCurrentBinaryDirectory(); - outpath += "/CMakeFiles"; - outpath += "/CMakeRelink.dir"; + outpath += "/CMakeFiles/CMakeRelink.dir"; cmSystemTools::MakeDirectory(outpath); - outpath += "/"; + outpath += '/'; if (!this->TargetNames.ImportLibrary.empty()) { outpathImp = outpath; } } else { outpath = this->GeneratorTarget->GetDirectory(this->ConfigName); cmSystemTools::MakeDirectory(outpath); - outpath += "/"; + outpath += '/'; if (!this->TargetNames.ImportLibrary.empty()) { outpathImp = this->GeneratorTarget->GetDirectory( this->ConfigName, cmStateEnums::ImportLibraryArtifact); cmSystemTools::MakeDirectory(outpathImp); - outpathImp += "/"; + outpathImp += '/'; } } diff --git a/Source/cmNinjaUtilityTargetGenerator.cxx b/Source/cmNinjaUtilityTargetGenerator.cxx index 1225cbd..8fca4c0 100644 --- a/Source/cmNinjaUtilityTargetGenerator.cxx +++ b/Source/cmNinjaUtilityTargetGenerator.cxx @@ -37,8 +37,7 @@ void cmNinjaUtilityTargetGenerator::Generate() cmGeneratorTarget* genTarget = this->GetGeneratorTarget(); std::string utilCommandName = lg->GetCurrentBinaryDirectory(); - utilCommandName += "/CMakeFiles"; - utilCommandName += "/"; + utilCommandName += "/CMakeFiles/"; utilCommandName += this->GetTargetName() + ".util"; utilCommandName = this->ConvertToNinjaPath(utilCommandName); diff --git a/Source/cmQtAutoGenInitializer.cxx b/Source/cmQtAutoGenInitializer.cxx index 3218076..850aac4 100644 --- a/Source/cmQtAutoGenInitializer.cxx +++ b/Source/cmQtAutoGenInitializer.cxx @@ -294,11 +294,9 @@ bool cmQtAutoGenInitializer::InitCustomTargets() // Info directory this->Dir.Info = cbd; - this->Dir.Info += "/CMakeFiles"; - this->Dir.Info += '/'; + this->Dir.Info += "/CMakeFiles/"; this->Dir.Info += this->Target->GetName(); - this->Dir.Info += "_autogen"; - this->Dir.Info += ".dir"; + this->Dir.Info += "_autogen.dir"; cmSystemTools::ConvertToUnixSlashes(this->Dir.Info); // Build directory diff --git a/Source/cmTryRunCommand.cxx b/Source/cmTryRunCommand.cxx index 5cc4795..0847b9b 100644 --- a/Source/cmTryRunCommand.cxx +++ b/Source/cmTryRunCommand.cxx @@ -215,8 +215,7 @@ void cmTryRunCommand::DoNotRunExecutable(const std::string& runArgs, // removed at the end of TRY_RUN and the user can run it manually // on the target platform. std::string copyDest = this->Makefile->GetHomeOutputDirectory(); - copyDest += "/CMakeFiles"; - copyDest += "/"; + copyDest += "/CMakeFiles/"; copyDest += cmSystemTools::GetFilenameWithoutExtension(this->OutputFile); copyDest += "-"; copyDest += this->RunResultVariable; https://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=f1c529c4fbea1963f7df92597a350e066319a1e1 commit f1c529c4fbea1963f7df92597a350e066319a1e1 Author: Sebastian Holtermann AuthorDate: Sun Aug 18 13:58:04 2019 +0200 Commit: Sebastian Holtermann CommitDate: Sun Aug 18 14:17:50 2019 +0200 cmCryptoHash: Accept cm::string_view input diff --git a/Source/cmCryptoHash.cxx b/Source/cmCryptoHash.cxx index 5e919af..f9f9581 100644 --- a/Source/cmCryptoHash.cxx +++ b/Source/cmCryptoHash.cxx @@ -6,8 +6,6 @@ #include "cm_rhash.h" #include "cmsys/FStream.hxx" -#include - #include "cm_memory.hxx" static unsigned int const cmCryptoHashAlgoToId[] = { @@ -46,36 +44,36 @@ cmCryptoHash::~cmCryptoHash() rhash_free(this->CTX); } -std::unique_ptr cmCryptoHash::New(const char* algo) +std::unique_ptr cmCryptoHash::New(cm::string_view algo) { - if (strcmp(algo, "MD5") == 0) { + if (algo == "MD5") { return cm::make_unique(AlgoMD5); } - if (strcmp(algo, "SHA1") == 0) { + if (algo == "SHA1") { return cm::make_unique(AlgoSHA1); } - if (strcmp(algo, "SHA224") == 0) { + if (algo == "SHA224") { return cm::make_unique(AlgoSHA224); } - if (strcmp(algo, "SHA256") == 0) { + if (algo == "SHA256") { return cm::make_unique(AlgoSHA256); } - if (strcmp(algo, "SHA384") == 0) { + if (algo == "SHA384") { return cm::make_unique(AlgoSHA384); } - if (strcmp(algo, "SHA512") == 0) { + if (algo == "SHA512") { return cm::make_unique(AlgoSHA512); } - if (strcmp(algo, "SHA3_224") == 0) { + if (algo == "SHA3_224") { return cm::make_unique(AlgoSHA3_224); } - if (strcmp(algo, "SHA3_256") == 0) { + if (algo == "SHA3_256") { return cm::make_unique(AlgoSHA3_256); } - if (strcmp(algo, "SHA3_384") == 0) { + if (algo == "SHA3_384") { return cm::make_unique(AlgoSHA3_384); } - if (strcmp(algo, "SHA3_512") == 0) { + if (algo == "SHA3_512") { return cm::make_unique(AlgoSHA3_512); } return std::unique_ptr(nullptr); @@ -106,6 +104,7 @@ std::string cmCryptoHash::ByteHashToString( '8', '9', 'a', 'b', 'c', 'd', 'e', 'f' }; std::string res; + res.reserve(hash.size() * 2); for (unsigned char v : hash) { res.push_back(hex[v >> 4]); res.push_back(hex[v & 0xF]); @@ -113,12 +112,10 @@ std::string cmCryptoHash::ByteHashToString( return res; } -std::vector cmCryptoHash::ByteHashString( - const std::string& input) +std::vector cmCryptoHash::ByteHashString(cm::string_view input) { this->Initialize(); - this->Append(reinterpret_cast(input.c_str()), - static_cast(input.size())); + this->Append(input); return this->Finalize(); } @@ -156,7 +153,7 @@ std::vector cmCryptoHash::ByteHashFile(const std::string& file) return std::vector(); } -std::string cmCryptoHash::HashString(const std::string& input) +std::string cmCryptoHash::HashString(cm::string_view input) { return ByteHashToString(this->ByteHashString(input)); } @@ -176,9 +173,9 @@ void cmCryptoHash::Append(void const* buf, size_t sz) rhash_update(this->CTX, buf, sz); } -void cmCryptoHash::Append(std::string const& str) +void cmCryptoHash::Append(cm::string_view input) { - this->Append(str.c_str(), str.size()); + rhash_update(this->CTX, input.data(), input.size()); } std::vector cmCryptoHash::Finalize() diff --git a/Source/cmCryptoHash.h b/Source/cmCryptoHash.h index c7d3377..681f5cc 100644 --- a/Source/cmCryptoHash.h +++ b/Source/cmCryptoHash.h @@ -5,6 +5,8 @@ #include "cmConfigure.h" // IWYU pragma: keep +#include "cm_string_view.hxx" + #include #include #include @@ -42,7 +44,7 @@ public: /// SHA3_224, SHA3_256, SHA3_384, SHA3_512 /// @return A valid auto pointer if algo is supported or /// an invalid/NULL pointer otherwise - static std::unique_ptr New(const char* algo); + static std::unique_ptr New(cm::string_view algo); /// @brief Converts a hex character to its binary value (4 bits) /// @arg input Hex character [0-9a-fA-F]. @@ -55,7 +57,7 @@ public: /// @brief Calculates a binary hash from string input data /// @return Binary hash vector - std::vector ByteHashString(const std::string& input); + std::vector ByteHashString(cm::string_view input); /// @brief Calculates a binary hash from file content /// @see ByteHashString() @@ -65,7 +67,7 @@ public: /// @brief Calculates a hash string from string input data /// @return Sequence of hex characters pairs for each byte of the binary hash - std::string HashString(const std::string& input); + std::string HashString(cm::string_view input); /// @brief Calculates a hash string from file content /// @see HashString() @@ -75,7 +77,7 @@ public: void Initialize(); void Append(void const*, size_t); - void Append(std::string const& str); + void Append(cm::string_view input); std::vector Finalize(); std::string FinalizeHex(); diff --git a/Source/cmFileCommand.cxx b/Source/cmFileCommand.cxx index 87e97dd..91e9a7b 100644 --- a/Source/cmFileCommand.cxx +++ b/Source/cmFileCommand.cxx @@ -283,7 +283,7 @@ bool HandleHashCommand(std::vector const& args, return false; } - std::unique_ptr hash(cmCryptoHash::New(args[0].c_str())); + std::unique_ptr hash(cmCryptoHash::New(args[0])); if (hash) { std::string out = hash->HashFile(args[1]); if (!out.empty()) { @@ -1712,7 +1712,7 @@ bool HandleDownloadCommand(std::vector const& args, } std::string algo = i->substr(0, pos); expectedHash = cmSystemTools::LowerCase(i->substr(pos + 1)); - hash = std::unique_ptr(cmCryptoHash::New(algo.c_str())); + hash = std::unique_ptr(cmCryptoHash::New(algo)); if (!hash) { std::string err = "DOWNLOAD EXPECTED_HASH given unknown ALGO: "; err += algo; diff --git a/Source/cmStringCommand.cxx b/Source/cmStringCommand.cxx index 41d48ed..5bff0e5 100644 --- a/Source/cmStringCommand.cxx +++ b/Source/cmStringCommand.cxx @@ -121,7 +121,7 @@ bool cmStringCommand::HandleHashCommand(std::vector const& args) return false; } - std::unique_ptr hash(cmCryptoHash::New(args[0].c_str())); + std::unique_ptr hash(cmCryptoHash::New(args[0])); if (hash) { std::string out = hash->HashString(args[2]); this->Makefile->AddDefinition(args[1], out); https://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=3b6c62be238f48b23d7dad302702f723dc5ef89c commit 3b6c62be238f48b23d7dad302702f723dc5ef89c Author: Sebastian Holtermann AuthorDate: Sat Aug 17 11:32:01 2019 +0200 Commit: Sebastian Holtermann CommitDate: Sat Aug 17 12:14:14 2019 +0200 cmSystemTools: Remove IsInternallyOn, IsNOTFOUND, IsOn, IsOff The removes the following methods from cmSystemTools: - `IsInternallyOn` - `IsNOTFOUND` - `IsOn` - `IsOff` diff --git a/Source/cmSystemTools.cxx b/Source/cmSystemTools.cxx index a133459..3461e67 100644 --- a/Source/cmSystemTools.cxx +++ b/Source/cmSystemTools.cxx @@ -250,85 +250,6 @@ void cmSystemTools::ReportLastSystemError(const char* msg) cmSystemTools::Error(m); } -bool cmSystemTools::IsInternallyOn(cm::string_view val) -{ - return (val.size() == 4) && // - (val[0] == 'I' || val[0] == 'i') && // - (val[1] == '_') && // - (val[2] == 'O' || val[2] == 'o') && // - (val[3] == 'N' || val[3] == 'n'); -} - -bool cmSystemTools::IsOn(cm::string_view val) -{ - switch (val.size()) { - case 1: - return val[0] == '1' || val[0] == 'Y' || val[0] == 'y'; - case 2: - return // - (val[0] == 'O' || val[0] == 'o') && // - (val[1] == 'N' || val[1] == 'n'); - case 3: - return // - (val[0] == 'Y' || val[0] == 'y') && // - (val[1] == 'E' || val[1] == 'e') && // - (val[2] == 'S' || val[2] == 's'); - case 4: - return // - (val[0] == 'T' || val[0] == 't') && // - (val[1] == 'R' || val[1] == 'r') && // - (val[2] == 'U' || val[2] == 'u') && // - (val[3] == 'E' || val[3] == 'e'); - default: - break; - } - - return false; -} - -bool cmSystemTools::IsNOTFOUND(cm::string_view val) -{ - return (val == "NOTFOUND") || cmHasLiteralSuffix(val, "-NOTFOUND"); -} - -bool cmSystemTools::IsOff(cm::string_view val) -{ - switch (val.size()) { - case 0: - return true; - case 1: - return val[0] == '0' || val[0] == 'N' || val[0] == 'n'; - case 2: - return // - (val[0] == 'N' || val[0] == 'n') && // - (val[1] == 'O' || val[1] == 'o'); - case 3: - return // - (val[0] == 'O' || val[0] == 'o') && // - (val[1] == 'F' || val[1] == 'f') && // - (val[2] == 'F' || val[2] == 'f'); - case 5: - return // - (val[0] == 'F' || val[0] == 'f') && // - (val[1] == 'A' || val[1] == 'a') && // - (val[2] == 'L' || val[2] == 'l') && // - (val[3] == 'S' || val[3] == 's') && // - (val[4] == 'E' || val[4] == 'e'); - case 6: - return // - (val[0] == 'I' || val[0] == 'i') && // - (val[1] == 'G' || val[1] == 'g') && // - (val[2] == 'N' || val[2] == 'n') && // - (val[3] == 'O' || val[3] == 'o') && // - (val[4] == 'R' || val[4] == 'r') && // - (val[5] == 'E' || val[5] == 'e'); - default: - break; - } - - return cmSystemTools::IsNOTFOUND(val); -} - void cmSystemTools::ParseWindowsCommandLine(const char* command, std::vector& args) { diff --git a/Source/cmSystemTools.h b/Source/cmSystemTools.h index 9ccbbc5..953a358 100644 --- a/Source/cmSystemTools.h +++ b/Source/cmSystemTools.h @@ -94,50 +94,6 @@ public: cmSystemTools::s_ErrorOccured = false; } - /** - * Does a string indicates that CMake/CPack/CTest internally - * forced this value. This is not the same as On, but this - * may be considered as "internally switched on". - */ - static bool IsInternallyOn(cm::string_view val); - static inline bool IsInternallyOn(const char* val) - { - if (!val) { - return false; - } - return IsInternallyOn(cm::string_view(val)); - } - - /** - * Does a string indicate a true or on value? This is not the same as ifdef. - */ - static bool IsOn(cm::string_view val); - inline static bool IsOn(const char* val) - { - if (!val) { - return false; - } - return IsOn(cm::string_view(val)); - } - - /** - * Does a string indicate a false or off value ? Note that this is - * not the same as !IsOn(...) because there are a number of - * ambiguous values such as "/usr/local/bin" a path will result in - * IsON and IsOff both returning false. Note that the special path - * NOTFOUND, *-NOTFOUND or IGNORE will cause IsOff to return true. - */ - static bool IsOff(cm::string_view val); - inline static bool IsOff(const char* val) - { - if (!val) { - return true; - } - return IsOff(cm::string_view(val)); - } - - //! Return true if value is NOTFOUND or ends in -NOTFOUND. - static bool IsNOTFOUND(cm::string_view val); //! Return true if the path is a framework static bool IsPathToFramework(const std::string& value); https://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=20e580be010e95a1668eb00728c39ab9dea9e2e5 commit 20e580be010e95a1668eb00728c39ab9dea9e2e5 Author: Sebastian Holtermann AuthorDate: Sat Aug 17 11:04:11 2019 +0200 Commit: Sebastian Holtermann CommitDate: Sat Aug 17 12:14:14 2019 +0200 Source sweep: Use cmIsOn instead of cmSystemTools::IsOn This replaces invocations of - `cmSystemTools::IsInternallyOn` with `cmIsInternallyOn` - `cmSystemTools::IsNOTFOUND` with `cmIsNOTFOUND` - `cmSystemTools::IsOn` with `cmIsOn` - `cmSystemTools::IsOff` with `cmIsOff` diff --git a/Source/CPack/IFW/cmCPackIFWGenerator.cxx b/Source/CPack/IFW/cmCPackIFWGenerator.cxx index 76eb760..f0fb37a 100644 --- a/Source/CPack/IFW/cmCPackIFWGenerator.cxx +++ b/Source/CPack/IFW/cmCPackIFWGenerator.cxx @@ -254,7 +254,7 @@ int cmCPackIFWGenerator::InitializeInternal() // Look 'binarycreator' executable (needs) const char* BinCreatorStr = this->GetOption(BinCreatorOpt); - if (!BinCreatorStr || cmSystemTools::IsNOTFOUND(BinCreatorStr)) { + if (!BinCreatorStr || cmIsNOTFOUND(BinCreatorStr)) { this->BinCreator.clear(); } else { this->BinCreator = BinCreatorStr; @@ -271,7 +271,7 @@ int cmCPackIFWGenerator::InitializeInternal() // Look 'repogen' executable (optional) const char* RepoGenStr = this->GetOption(RepoGenOpt); - if (!RepoGenStr || cmSystemTools::IsNOTFOUND(RepoGenStr)) { + if (!RepoGenStr || cmIsNOTFOUND(RepoGenStr)) { this->RepoGen.clear(); } else { this->RepoGen = RepoGenStr; @@ -325,10 +325,10 @@ int cmCPackIFWGenerator::InitializeInternal() } if (const char* ifwDownloadAll = this->GetOption("CPACK_IFW_DOWNLOAD_ALL")) { - this->OnlineOnly = cmSystemTools::IsOn(ifwDownloadAll); + this->OnlineOnly = cmIsOn(ifwDownloadAll); } else if (const char* cpackDownloadAll = this->GetOption("CPACK_DOWNLOAD_ALL")) { - this->OnlineOnly = cmSystemTools::IsOn(cpackDownloadAll); + this->OnlineOnly = cmIsOn(cpackDownloadAll); } else { this->OnlineOnly = false; } diff --git a/Source/CPack/WiX/cmCPackWIXGenerator.cxx b/Source/CPack/WiX/cmCPackWIXGenerator.cxx index 458a335..51d284f 100644 --- a/Source/CPack/WiX/cmCPackWIXGenerator.cxx +++ b/Source/CPack/WiX/cmCPackWIXGenerator.cxx @@ -238,7 +238,7 @@ bool cmCPackWIXGenerator::InitializeWiXConfiguration() // if install folder is supposed to be set absolutely, the default // component guid "*" cannot be used - if (cmSystemTools::IsOn(GetOption("CPACK_WIX_SKIP_PROGRAM_FOLDER"))) { + if (cmIsOn(GetOption("CPACK_WIX_SKIP_PROGRAM_FOLDER"))) { this->ComponentGuidType = cmWIXSourceWriter::CMAKE_GENERATED_GUID; } @@ -582,7 +582,7 @@ bool cmCPackWIXGenerator::CreateWiXSourceFiles() std::string cmCPackWIXGenerator::GetRootFolderId() const { - if (cmSystemTools::IsOn(GetOption("CPACK_WIX_SKIP_PROGRAM_FOLDER"))) { + if (cmIsOn(GetOption("CPACK_WIX_SKIP_PROGRAM_FOLDER"))) { return ""; } diff --git a/Source/CPack/cmCPackDebGenerator.cxx b/Source/CPack/cmCPackDebGenerator.cxx index 06b9876..7c2f21a 100644 --- a/Source/CPack/cmCPackDebGenerator.cxx +++ b/Source/CPack/cmCPackDebGenerator.cxx @@ -440,7 +440,7 @@ cmCPackDebGenerator::~cmCPackDebGenerator() = default; int cmCPackDebGenerator::InitializeInternal() { this->SetOptionIfNotSet("CPACK_PACKAGING_INSTALL_PREFIX", "/usr"); - if (cmSystemTools::IsOff(this->GetOption("CPACK_SET_DESTDIR"))) { + if (cmIsOff(this->GetOption("CPACK_SET_DESTDIR"))) { this->SetOption("CPACK_SET_DESTDIR", "I_ON"); } return this->Superclass::InitializeInternal(); diff --git a/Source/CPack/cmCPackExternalGenerator.cxx b/Source/CPack/cmCPackExternalGenerator.cxx index b4c7a5a..5dc6ace 100644 --- a/Source/CPack/cmCPackExternalGenerator.cxx +++ b/Source/CPack/cmCPackExternalGenerator.cxx @@ -5,6 +5,7 @@ #include "cmCPackComponentGroup.h" #include "cmCPackLog.h" #include "cmMakefile.h" +#include "cmStringAlgorithms.h" #include "cmSystemTools.h" #include "cm_jsoncpp_value.h" @@ -149,8 +150,7 @@ int cmCPackExternalGenerator::InstallCMakeProject( bool cmCPackExternalGenerator::StagingEnabled() const { - return !cmSystemTools::IsOff( - this->GetOption("CPACK_EXTERNAL_ENABLE_STAGING")); + return !cmIsOff(this->GetOption("CPACK_EXTERNAL_ENABLE_STAGING")); } cmCPackExternalGenerator::cmCPackExternalVersionGenerator:: @@ -208,8 +208,7 @@ int cmCPackExternalGenerator::cmCPackExternalVersionGenerator::WriteToJSON( if (defaultDirectoryPermissions && *defaultDirectoryPermissions) { root["defaultDirectoryPermissions"] = defaultDirectoryPermissions; } - if (cmSystemTools::IsInternallyOn( - this->Parent->GetOption("CPACK_SET_DESTDIR"))) { + if (cmIsInternallyOn(this->Parent->GetOption("CPACK_SET_DESTDIR"))) { root["setDestdir"] = true; root["packagingInstallPrefix"] = this->Parent->GetOption("CPACK_PACKAGING_INSTALL_PREFIX"); @@ -217,8 +216,7 @@ int cmCPackExternalGenerator::cmCPackExternalVersionGenerator::WriteToJSON( root["setDestdir"] = false; } - root["stripFiles"] = - !cmSystemTools::IsOff(this->Parent->GetOption("CPACK_STRIP_FILES")); + root["stripFiles"] = !cmIsOff(this->Parent->GetOption("CPACK_STRIP_FILES")); root["warnOnAbsoluteInstallDestination"] = this->Parent->IsOn("CPACK_WARN_ON_ABSOLUTE_INSTALL_DESTINATION"); root["errorOnAbsoluteInstallDestination"] = diff --git a/Source/CPack/cmCPackGenerator.cxx b/Source/CPack/cmCPackGenerator.cxx index e31787c..f3de53c 100644 --- a/Source/CPack/cmCPackGenerator.cxx +++ b/Source/CPack/cmCPackGenerator.cxx @@ -180,8 +180,8 @@ int cmCPackGenerator::InstallProject() std::string bareTempInstallDirectory = this->GetOption("CPACK_TEMPORARY_INSTALL_DIRECTORY"); std::string tempInstallDirectoryStr = bareTempInstallDirectory; - bool setDestDir = cmSystemTools::IsOn(this->GetOption("CPACK_SET_DESTDIR")) | - cmSystemTools::IsInternallyOn(this->GetOption("CPACK_SET_DESTDIR")); + bool setDestDir = cmIsOn(this->GetOption("CPACK_SET_DESTDIR")) | + cmIsInternallyOn(this->GetOption("CPACK_SET_DESTDIR")); if (!setDestDir) { tempInstallDirectoryStr += this->GetPackagingInstallPrefix(); } @@ -750,7 +750,7 @@ int cmCPackGenerator::InstallCMakeProject( // CPACK_PACKAGING_INSTALL_PREFIX // I know this is tricky and awkward but it's the price for // CPACK_SET_DESTDIR backward compatibility. - if (cmSystemTools::IsInternallyOn(this->GetOption("CPACK_SET_DESTDIR"))) { + if (cmIsInternallyOn(this->GetOption("CPACK_SET_DESTDIR"))) { this->SetOption("CPACK_INSTALL_PREFIX", this->GetOption("CPACK_PACKAGING_INSTALL_PREFIX")); } @@ -826,7 +826,7 @@ int cmCPackGenerator::InstallCMakeProject( // strip on TRUE, ON, 1, one or several file names, but not on // FALSE, OFF, 0 and an empty string - if (!cmSystemTools::IsOff(this->GetOption("CPACK_STRIP_FILES"))) { + if (!cmIsOff(this->GetOption("CPACK_STRIP_FILES"))) { mf.AddDefinition("CMAKE_INSTALL_DO_STRIP", "1"); } // Remember the list of files before installation @@ -977,8 +977,7 @@ int cmCPackGenerator::DoPackage() return 0; } - if (cmSystemTools::IsOn( - this->GetOption("CPACK_REMOVE_TOPLEVEL_DIRECTORY"))) { + if (cmIsOn(this->GetOption("CPACK_REMOVE_TOPLEVEL_DIRECTORY"))) { const char* toplevelDirectory = this->GetOption("CPACK_TOPLEVEL_DIRECTORY"); if (cmSystemTools::FileExists(toplevelDirectory)) { @@ -1028,8 +1027,7 @@ int cmCPackGenerator::DoPackage() "Remove old package file" << std::endl); cmSystemTools::RemoveFile(tempPackageFileName); } - if (cmSystemTools::IsOn( - this->GetOption("CPACK_INCLUDE_TOPLEVEL_DIRECTORY"))) { + if (cmIsOn(this->GetOption("CPACK_INCLUDE_TOPLEVEL_DIRECTORY"))) { tempDirectory = this->GetOption("CPACK_TOPLEVEL_DIRECTORY"); } @@ -1153,14 +1151,14 @@ bool cmCPackGenerator::IsSet(const std::string& name) const bool cmCPackGenerator::IsOn(const std::string& name) const { - return cmSystemTools::IsOn(GetOption(name)); + return cmIsOn(GetOption(name)); } bool cmCPackGenerator::IsSetToOff(const std::string& op) const { const char* ret = this->MakefileMap->GetDefinition(op); if (ret && *ret) { - return cmSystemTools::IsOff(ret); + return cmIsOff(ret); } return false; } @@ -1474,7 +1472,7 @@ cmCPackComponent* cmCPackGenerator::GetComponent( component->IsRequired = this->IsOn(macroPrefix + "_REQUIRED"); component->IsDisabledByDefault = this->IsOn(macroPrefix + "_DISABLED"); component->IsDownloaded = this->IsOn(macroPrefix + "_DOWNLOADED") || - cmSystemTools::IsOn(this->GetOption("CPACK_DOWNLOAD_ALL")); + cmIsOn(this->GetOption("CPACK_DOWNLOAD_ALL")); const char* archiveFile = this->GetOption(macroPrefix + "_ARCHIVE_FILE"); if (archiveFile && *archiveFile) { diff --git a/Source/CPack/cmCPackNSISGenerator.cxx b/Source/CPack/cmCPackNSISGenerator.cxx index cfa34dc..961a9d4 100644 --- a/Source/CPack/cmCPackNSISGenerator.cxx +++ b/Source/CPack/cmCPackNSISGenerator.cxx @@ -275,7 +275,7 @@ int cmCPackNSISGenerator::PackageFiles() if (anyDownloadedComponents) { defines += "!define CPACK_USES_DOWNLOAD\n"; - if (cmSystemTools::IsOn(this->GetOption("CPACK_ADD_REMOVE"))) { + if (cmIsOn(this->GetOption("CPACK_ADD_REMOVE"))) { defines += "!define CPACK_NSIS_ADD_REMOVE\n"; } } @@ -322,8 +322,7 @@ int cmCPackNSISGenerator::PackageFiles() int cmCPackNSISGenerator::InitializeInternal() { - if (cmSystemTools::IsOn( - this->GetOption("CPACK_INCLUDE_TOPLEVEL_DIRECTORY"))) { + if (cmIsOn(this->GetOption("CPACK_INCLUDE_TOPLEVEL_DIRECTORY"))) { cmCPackLogger( cmCPackLog::LOG_WARNING, "NSIS Generator cannot work with CPACK_INCLUDE_TOPLEVEL_DIRECTORY set. " @@ -721,8 +720,7 @@ std::string cmCPackNSISGenerator::CreateComponentDescription( // size of the installed component. std::string zipListFileName = this->GetOption("CPACK_TEMPORARY_DIRECTORY"); zipListFileName += "/winZip.filelist"; - bool needQuotesInFile = - cmSystemTools::IsOn(this->GetOption("CPACK_ZIP_NEED_QUOTES")); + bool needQuotesInFile = cmIsOn(this->GetOption("CPACK_ZIP_NEED_QUOTES")); unsigned long totalSize = 0; { // the scope is needed for cmGeneratedFileStream cmGeneratedFileStream out(zipListFileName); diff --git a/Source/CPack/cmCPackRPMGenerator.cxx b/Source/CPack/cmCPackRPMGenerator.cxx index 33ab62b..9ffebf5 100644 --- a/Source/CPack/cmCPackRPMGenerator.cxx +++ b/Source/CPack/cmCPackRPMGenerator.cxx @@ -12,6 +12,7 @@ #include "cmCPackComponentGroup.h" #include "cmCPackGenerator.h" #include "cmCPackLog.h" +#include "cmStringAlgorithms.h" #include "cmSystemTools.h" cmCPackRPMGenerator::cmCPackRPMGenerator() = default; @@ -21,7 +22,7 @@ cmCPackRPMGenerator::~cmCPackRPMGenerator() = default; int cmCPackRPMGenerator::InitializeInternal() { this->SetOptionIfNotSet("CPACK_PACKAGING_INSTALL_PREFIX", "/usr"); - if (cmSystemTools::IsOff(this->GetOption("CPACK_SET_DESTDIR"))) { + if (cmIsOff(this->GetOption("CPACK_SET_DESTDIR"))) { this->SetOption("CPACK_SET_DESTDIR", "I_ON"); } /* Replace space in CPACK_PACKAGE_NAME in order to avoid diff --git a/Source/CTest/cmCTestBuildHandler.cxx b/Source/CTest/cmCTestBuildHandler.cxx index bc7c155..2365a66 100644 --- a/Source/CTest/cmCTestBuildHandler.cxx +++ b/Source/CTest/cmCTestBuildHandler.cxx @@ -326,7 +326,7 @@ int cmCTestBuildHandler::ProcessHandler() std::string const& useLaunchers = this->CTest->GetCTestConfiguration("UseLaunchers"); - this->UseCTestLaunch = cmSystemTools::IsOn(useLaunchers); + this->UseCTestLaunch = cmIsOn(useLaunchers); // Create a last build log cmGeneratedFileStream ofs; diff --git a/Source/CTest/cmCTestGIT.cxx b/Source/CTest/cmCTestGIT.cxx index e330e22..b832018 100644 --- a/Source/CTest/cmCTestGIT.cxx +++ b/Source/CTest/cmCTestGIT.cxx @@ -270,7 +270,7 @@ bool cmCTestGIT::UpdateImpl() std::string init_submodules = this->CTest->GetCTestConfiguration("GITInitSubmodules"); - if (cmSystemTools::IsOn(init_submodules)) { + if (cmIsOn(init_submodules)) { char const* git_submodule_init[] = { git, "submodule", "init", nullptr }; ret = this->RunChild(git_submodule_init, &submodule_out, &submodule_err, top_dir.c_str()); diff --git a/Source/CTest/cmCTestSubmitHandler.cxx b/Source/CTest/cmCTestSubmitHandler.cxx index 414a20d..a30999b 100644 --- a/Source/CTest/cmCTestSubmitHandler.cxx +++ b/Source/CTest/cmCTestSubmitHandler.cxx @@ -280,7 +280,7 @@ bool cmCTestSubmitHandler::SubmitUsingHTTP( upload_as += "&MD5="; - if (cmSystemTools::IsOn(this->GetOption("InternalTest"))) { + if (cmIsOn(this->GetOption("InternalTest"))) { upload_as += "bad_md5sum"; } else { upload_as += @@ -517,7 +517,7 @@ int cmCTestSubmitHandler::HandleCDashUploadFile(std::string const& file, "Only http and https are supported for CDASH_UPLOAD\n"); return -1; } - bool internalTest = cmSystemTools::IsOn(this->GetOption("InternalTest")); + bool internalTest = cmIsOn(this->GetOption("InternalTest")); // Get RETRY_COUNT and RETRY_DELAY values if they were set. std::string retryDelayString = this->GetOption("RetryDelay") == nullptr diff --git a/Source/CTest/cmCTestTestHandler.cxx b/Source/CTest/cmCTestTestHandler.cxx index a3c480a..797d47e 100644 --- a/Source/CTest/cmCTestTestHandler.cxx +++ b/Source/CTest/cmCTestTestHandler.cxx @@ -512,8 +512,8 @@ bool cmCTestTestHandler::ProcessOptions() { // Update internal data structure from generic one this->SetTestsToRunInformation(this->GetOption("TestsToRunInformation")); - this->SetUseUnion(cmSystemTools::IsOn(this->GetOption("UseUnion"))); - if (cmSystemTools::IsOn(this->GetOption("ScheduleRandom"))) { + this->SetUseUnion(cmIsOn(this->GetOption("UseUnion"))); + if (cmIsOn(this->GetOption("ScheduleRandom"))) { this->CTest->SetScheduleType("Random"); } if (this->GetOption("ParallelLevel")) { @@ -553,7 +553,7 @@ bool cmCTestTestHandler::ProcessOptions() if (val) { this->ExcludeFixtureCleanupRegExp = val; } - this->SetRerunFailed(cmSystemTools::IsOn(this->GetOption("RerunFailed"))); + this->SetRerunFailed(cmIsOn(this->GetOption("RerunFailed"))); return true; } @@ -2203,10 +2203,10 @@ bool cmCTestTestHandler::SetTestsProperties( } } if (key == "WILL_FAIL") { - rt.WillFail = cmSystemTools::IsOn(val); + rt.WillFail = cmIsOn(val); } if (key == "DISABLED") { - rt.Disabled = cmSystemTools::IsOn(val); + rt.Disabled = cmIsOn(val); } if (key == "ATTACHED_FILES") { cmExpandList(val, rt.AttachedFiles); @@ -2249,7 +2249,7 @@ bool cmCTestTestHandler::SetTestsProperties( cmExpandList(val, rt.RequiredFiles); } if (key == "RUN_SERIAL") { - rt.RunSerial = cmSystemTools::IsOn(val); + rt.RunSerial = cmIsOn(val); } if (key == "FAIL_REGULAR_EXPRESSION") { std::vector lval; @@ -2272,7 +2272,7 @@ bool cmCTestTestHandler::SetTestsProperties( } } if (key == "PROCESSOR_AFFINITY") { - rt.WantAffinity = cmSystemTools::IsOn(val); + rt.WantAffinity = cmIsOn(val); } if (key == "SKIP_RETURN_CODE") { rt.SkipReturnCode = atoi(val.c_str()); diff --git a/Source/CTest/cmCTestVC.cxx b/Source/CTest/cmCTestVC.cxx index eea41cf..773886d 100644 --- a/Source/CTest/cmCTestVC.cxx +++ b/Source/CTest/cmCTestVC.cxx @@ -3,6 +3,7 @@ #include "cmCTestVC.h" #include "cmCTest.h" +#include "cmStringAlgorithms.h" #include "cmSystemTools.h" #include "cmXMLWriter.h" @@ -152,8 +153,7 @@ bool cmCTestVC::Update() // if update version only is on then do not actually update, // just note the current version and finish - if (!cmSystemTools::IsOn( - this->CTest->GetCTestConfiguration("UpdateVersionOnly"))) { + if (!cmIsOn(this->CTest->GetCTestConfiguration("UpdateVersionOnly"))) { result = this->NoteOldRevision() && result; this->Log << "--- Begin Update ---\n"; result = this->UpdateImpl() && result; diff --git a/Source/CursesDialog/cmCursesCacheEntryComposite.cxx b/Source/CursesDialog/cmCursesCacheEntryComposite.cxx index 4341bf4..f7e3920 100644 --- a/Source/CursesDialog/cmCursesCacheEntryComposite.cxx +++ b/Source/CursesDialog/cmCursesCacheEntryComposite.cxx @@ -50,7 +50,7 @@ cmCursesCacheEntryComposite::cmCursesCacheEntryComposite( switch (cm->GetState()->GetCacheEntryType(key)) { case cmStateEnums::BOOL: this->Entry = new cmCursesBoolWidget(this->EntryWidth, 1, 1, 1); - if (cmSystemTools::IsOn(value)) { + if (cmIsOn(value)) { static_cast(this->Entry)->SetValueAsBool(true); } else { static_cast(this->Entry)->SetValueAsBool(false); diff --git a/Source/CursesDialog/cmCursesMainForm.cxx b/Source/CursesDialog/cmCursesMainForm.cxx index 028e852..9ac80b8 100644 --- a/Source/CursesDialog/cmCursesMainForm.cxx +++ b/Source/CursesDialog/cmCursesMainForm.cxx @@ -13,6 +13,7 @@ #include "cmCursesWidget.h" #include "cmState.h" #include "cmStateTypes.h" +#include "cmStringAlgorithms.h" #include "cmSystemTools.h" #include "cmVersion.h" #include "cmake.h" @@ -696,7 +697,7 @@ void cmCursesMainForm::FixValue(cmStateEnums::CacheEntryType type, cmSystemTools::ConvertToUnixSlashes(out); } if (type == cmStateEnums::BOOL) { - if (cmSystemTools::IsOff(out)) { + if (cmIsOff(out)) { out = "OFF"; } else { out = "ON"; diff --git a/Source/QtDialog/QCMake.cxx b/Source/QtDialog/QCMake.cxx index f357f90..ece3307 100644 --- a/Source/QtDialog/QCMake.cxx +++ b/Source/QtDialog/QCMake.cxx @@ -7,6 +7,7 @@ #include "cmExternalMakefileProjectGenerator.h" #include "cmState.h" +#include "cmStringAlgorithms.h" #include "cmSystemTools.h" #ifdef Q_OS_WIN @@ -312,7 +313,7 @@ QCMakePropertyList QCMake::properties() const prop.Advanced = state->GetCacheEntryPropertyAsBool(key, "ADVANCED"); if (t == cmStateEnums::BOOL) { prop.Type = QCMakeProperty::BOOL; - prop.Value = cmSystemTools::IsOn(cachedValue); + prop.Value = cmIsOn(cachedValue); } else if (t == cmStateEnums::PATH) { prop.Type = QCMakeProperty::PATH; } else if (t == cmStateEnums::FILEPATH) { diff --git a/Source/cmAddLibraryCommand.cxx b/Source/cmAddLibraryCommand.cxx index 626b7c9..46fc61d 100644 --- a/Source/cmAddLibraryCommand.cxx +++ b/Source/cmAddLibraryCommand.cxx @@ -12,7 +12,7 @@ #include "cmMessageType.h" #include "cmState.h" #include "cmStateTypes.h" -#include "cmSystemTools.h" +#include "cmStringAlgorithms.h" #include "cmTarget.h" bool cmAddLibraryCommand(std::vector const& args, @@ -27,7 +27,7 @@ bool cmAddLibraryCommand(std::vector const& args, // Library type defaults to value of BUILD_SHARED_LIBS, if it exists, // otherwise it defaults to static library. cmStateEnums::TargetType type = cmStateEnums::SHARED_LIBRARY; - if (cmSystemTools::IsOff(mf.GetDefinition("BUILD_SHARED_LIBS"))) { + if (cmIsOff(mf.GetDefinition("BUILD_SHARED_LIBS"))) { type = cmStateEnums::STATIC_LIBRARY; } bool excludeFromAll = false; diff --git a/Source/cmCPluginAPI.cxx b/Source/cmCPluginAPI.cxx index 80ca898..d06ec20 100644 --- a/Source/cmCPluginAPI.cxx +++ b/Source/cmCPluginAPI.cxx @@ -608,7 +608,7 @@ int CCONV cmSourceFileGetPropertyAsBool(void* arg, const char* prop) if (cmSourceFile* rsf = sf->RealSourceFile) { return rsf->GetPropertyAsBool(prop) ? 1 : 0; } - return cmSystemTools::IsOn(cmSourceFileGetProperty(arg, prop)) ? 1 : 0; + return cmIsOn(cmSourceFileGetProperty(arg, prop)) ? 1 : 0; } void CCONV cmSourceFileSetProperty(void* arg, const char* prop, diff --git a/Source/cmCTest.cxx b/Source/cmCTest.cxx index 4a5d2ce..e7a16b5 100644 --- a/Source/cmCTest.cxx +++ b/Source/cmCTest.cxx @@ -323,12 +323,11 @@ cmCTest::cmCTest() { std::string envValue; if (cmSystemTools::GetEnv("CTEST_OUTPUT_ON_FAILURE", envValue)) { - this->Impl->OutputTestOutputOnTestFailure = - !cmSystemTools::IsOff(envValue); + this->Impl->OutputTestOutputOnTestFailure = !cmIsOff(envValue); } envValue.clear(); if (cmSystemTools::GetEnv("CTEST_PROGRESS_OUTPUT", envValue)) { - this->Impl->TestProgressOutput = !cmSystemTools::IsOff(envValue); + this->Impl->TestProgressOutput = !cmIsOff(envValue); } this->Impl->Parts[PartStart].SetName("Start"); @@ -763,7 +762,7 @@ bool cmCTest::UpdateCTestConfiguration() } if (this->Impl->ProduceXML) { this->Impl->CompressXMLFiles = - cmSystemTools::IsOn(this->GetCTestConfiguration("CompressSubmission")); + cmIsOn(this->GetCTestConfiguration("CompressSubmission")); } return true; } @@ -2001,7 +2000,7 @@ bool cmCTest::HandleCommandLineArguments(size_t& i, if (this->CheckArgument(arg, "--interactive-debug-mode") && i < args.size() - 1) { i++; - this->Impl->InteractiveDebugMode = cmSystemTools::IsOn(args[i]); + this->Impl->InteractiveDebugMode = cmIsOn(args[i]); } if (this->CheckArgument(arg, "--submit-index") && i < args.size() - 1) { i++; diff --git a/Source/cmCacheManager.cxx b/Source/cmCacheManager.cxx index 8ebab0a..17d4b74 100644 --- a/Source/cmCacheManager.cxx +++ b/Source/cmCacheManager.cxx @@ -616,7 +616,7 @@ void cmCacheManager::CacheIterator::SetValue(const char* value) bool cmCacheManager::CacheIterator::GetValueAsBool() const { - return cmSystemTools::IsOn(this->GetEntry().Value); + return cmIsOn(this->GetEntry().Value); } std::vector cmCacheManager::CacheEntry::GetPropertyList() const @@ -696,7 +696,7 @@ bool cmCacheManager::CacheIterator::GetPropertyAsBool( const std::string& prop) const { if (const char* value = this->GetProperty(prop)) { - return cmSystemTools::IsOn(value); + return cmIsOn(value); } return false; } diff --git a/Source/cmComputeLinkInformation.cxx b/Source/cmComputeLinkInformation.cxx index 5f5317c..4273383 100644 --- a/Source/cmComputeLinkInformation.cxx +++ b/Source/cmComputeLinkInformation.cxx @@ -480,7 +480,7 @@ bool cmComputeLinkInformation::Compute() // Restore the target link type so the correct system runtime // libraries are found. const char* lss = this->Target->GetProperty("LINK_SEARCH_END_STATIC"); - if (cmSystemTools::IsOn(lss)) { + if (cmIsOn(lss)) { this->SetCurrentLinkType(LinkStatic); } else { this->SetCurrentLinkType(this->StartLinkType); @@ -787,7 +787,7 @@ void cmComputeLinkInformation::ComputeLinkTypeInfo() // Lookup the starting link type from the target (linked statically?). const char* lss = this->Target->GetProperty("LINK_SEARCH_START_STATIC"); - this->StartLinkType = cmSystemTools::IsOn(lss) ? LinkStatic : LinkShared; + this->StartLinkType = cmIsOn(lss) ? LinkStatic : LinkShared; this->CurrentLinkType = this->StartLinkType; } diff --git a/Source/cmConditionEvaluator.cxx b/Source/cmConditionEvaluator.cxx index 3a53067..3de3253 100644 --- a/Source/cmConditionEvaluator.cxx +++ b/Source/cmConditionEvaluator.cxx @@ -220,10 +220,10 @@ bool cmConditionEvaluator::GetBooleanValue( } // Check named constants. - if (cmSystemTools::IsOn(arg.c_str())) { + if (cmIsOn(arg.GetValue())) { return true; } - if (cmSystemTools::IsOff(arg.c_str())) { + if (cmIsOff(arg.GetValue())) { return false; } @@ -239,7 +239,7 @@ bool cmConditionEvaluator::GetBooleanValue( // Check definition. const char* def = this->GetDefinitionIfUnquoted(arg); - return !cmSystemTools::IsOff(def); + return !cmIsOff(def); } //========================================================================= @@ -256,14 +256,14 @@ bool cmConditionEvaluator::GetBooleanValueOld( return true; } const char* def = this->GetDefinitionIfUnquoted(arg); - return !cmSystemTools::IsOff(def); + return !cmIsOff(def); } // Old GetVariableOrNumber behavior. const char* def = this->GetDefinitionIfUnquoted(arg); if (!def && atoi(arg.c_str())) { def = arg.c_str(); } - return !cmSystemTools::IsOff(def); + return !cmIsOff(def); } //========================================================================= diff --git a/Source/cmExtraCodeBlocksGenerator.cxx b/Source/cmExtraCodeBlocksGenerator.cxx index d13e3ce..79ecf45 100644 --- a/Source/cmExtraCodeBlocksGenerator.cxx +++ b/Source/cmExtraCodeBlocksGenerator.cxx @@ -235,7 +235,7 @@ void cmExtraCodeBlocksGenerator::CreateNewProjectFile( // Also we can disable external (outside the project) files by setting ON // CMAKE_CODEBLOCKS_EXCLUDE_EXTERNAL_FILES variable. const bool excludeExternal = - cmSystemTools::IsOn(it.second[0]->GetMakefile()->GetSafeDefinition( + cmIsOn(it.second[0]->GetMakefile()->GetSafeDefinition( "CMAKE_CODEBLOCKS_EXCLUDE_EXTERNAL_FILES")); if (!splitted.empty() && (!excludeExternal || (relative.find("..") == std::string::npos)) && @@ -381,7 +381,7 @@ void cmExtraCodeBlocksGenerator::CreateNewProjectFile( // Do not add this file if it has ".." in relative path and // if CMAKE_CODEBLOCKS_EXCLUDE_EXTERNAL_FILES variable is on. const bool excludeExternal = - cmSystemTools::IsOn(lg->GetMakefile()->GetSafeDefinition( + cmIsOn(lg->GetMakefile()->GetSafeDefinition( "CMAKE_CODEBLOCKS_EXCLUDE_EXTERNAL_FILES")); if (excludeExternal && (relative.find("..") != std::string::npos)) { diff --git a/Source/cmExtraSublimeTextGenerator.cxx b/Source/cmExtraSublimeTextGenerator.cxx index 0c258f7..6c17279 100644 --- a/Source/cmExtraSublimeTextGenerator.cxx +++ b/Source/cmExtraSublimeTextGenerator.cxx @@ -445,7 +445,7 @@ bool cmExtraSublimeTextGenerator::Open(const std::string& bindir, if (!sublExecutable) { return false; } - if (cmSystemTools::IsNOTFOUND(sublExecutable)) { + if (cmIsNOTFOUND(sublExecutable)) { return false; } diff --git a/Source/cmFileCommand.cxx b/Source/cmFileCommand.cxx index 87e97dd..f618002 100644 --- a/Source/cmFileCommand.cxx +++ b/Source/cmFileCommand.cxx @@ -703,10 +703,10 @@ bool HandleGlobImpl(std::vector const& args, bool recurse, if (*i == "LIST_DIRECTORIES") { ++i; // skip LIST_DIRECTORIES if (i != args.end()) { - if (cmSystemTools::IsOn(*i)) { + if (cmIsOn(*i)) { g.SetListDirs(true); g.SetRecurseListDirs(true); - } else if (cmSystemTools::IsOff(*i)) { + } else if (cmIsOff(*i)) { g.SetListDirs(false); g.SetRecurseListDirs(false); } else { @@ -1656,7 +1656,7 @@ bool HandleDownloadCommand(std::vector const& args, } else if (*i == "TLS_VERIFY") { ++i; if (i != args.end()) { - tls_verify = cmSystemTools::IsOn(*i); + tls_verify = cmIsOn(*i); } else { status.SetError("TLS_VERIFY missing bool value."); return false; diff --git a/Source/cmFileInstaller.cxx b/Source/cmFileInstaller.cxx index d28ef41..6a95b92 100644 --- a/Source/cmFileInstaller.cxx +++ b/Source/cmFileInstaller.cxx @@ -6,6 +6,7 @@ #include "cmExecutionStatus.h" #include "cmFSPermissions.h" #include "cmMakefile.h" +#include "cmStringAlgorithms.h" #include "cmSystemTools.h" #include "cm_sys_stat.h" @@ -28,7 +29,7 @@ cmFileInstaller::cmFileInstaller(cmExecutionStatus& status) // Check whether to copy files always or only if they have changed. std::string install_always; if (cmSystemTools::GetEnv("CMAKE_INSTALL_ALWAYS", install_always)) { - this->Always = cmSystemTools::IsOn(install_always); + this->Always = cmIsOn(install_always); } // Get the current manifest. this->Manifest = diff --git a/Source/cmFindBase.cxx b/Source/cmFindBase.cxx index b1ccc83..9bacfc4 100644 --- a/Source/cmFindBase.cxx +++ b/Source/cmFindBase.cxx @@ -324,7 +324,7 @@ bool cmFindBase::CheckForVariableInCache() this->Makefile->GetDefinition(this->VariableName)) { cmState* state = this->Makefile->GetState(); const char* cacheEntry = state->GetCacheEntryValue(this->VariableName); - bool found = !cmSystemTools::IsNOTFOUND(cacheValue); + bool found = !cmIsNOTFOUND(cacheValue); bool cached = cacheEntry != nullptr; if (found) { // If the user specifies the entry on the command line without a diff --git a/Source/cmFindCommon.cxx b/Source/cmFindCommon.cxx index 102ed4c..c5209c4 100644 --- a/Source/cmFindCommon.cxx +++ b/Source/cmFindCommon.cxx @@ -161,7 +161,7 @@ void cmFindCommon::SelectDefaultSearchModes() for (auto& path : search_paths) { const char* def = this->Makefile->GetDefinition(path.second); if (def) { - path.first = !cmSystemTools::IsOn(def); + path.first = !cmIsOn(def); } } } diff --git a/Source/cmFindPackageCommand.cxx b/Source/cmFindPackageCommand.cxx index d5207fa..ae93eff 100644 --- a/Source/cmFindPackageCommand.cxx +++ b/Source/cmFindPackageCommand.cxx @@ -194,7 +194,7 @@ bool cmFindPackageCommand::InitialPass(std::vector const& args, // priority over the deprecated CMAKE_FIND_PACKAGE_NO_PACKAGE_REGISTRY if (const char* def = this->Makefile->GetDefinition("CMAKE_FIND_USE_PACKAGE_REGISTRY")) { - this->NoUserRegistry = !cmSystemTools::IsOn(def); + this->NoUserRegistry = !cmIsOn(def); } else if (this->Makefile->IsOn("CMAKE_FIND_PACKAGE_NO_PACKAGE_REGISTRY")) { this->NoUserRegistry = true; } @@ -752,7 +752,7 @@ bool cmFindPackageCommand::HandlePackageMode( // Try to load the config file if the directory is known bool fileFound = false; if (this->UseConfigFiles) { - if (!cmSystemTools::IsOff(def)) { + if (!cmIsOff(def)) { // Get the directory from the variable value. std::string dir = def; cmSystemTools::ConvertToUnixSlashes(dir); @@ -772,7 +772,7 @@ bool cmFindPackageCommand::HandlePackageMode( } // Search for the config file if it is not already found. - if (cmSystemTools::IsOff(def) || !fileFound) { + if (cmIsOff(def) || !fileFound) { fileFound = this->FindConfig(); } @@ -1148,8 +1148,7 @@ void cmFindPackageCommand::AppendSuccessInformation() const char* upperResult = this->Makefile->GetDefinition(upperFound); const char* result = this->Makefile->GetDefinition(found); - bool packageFound = - ((cmSystemTools::IsOn(result)) || (cmSystemTools::IsOn(upperResult))); + bool packageFound = ((cmIsOn(result)) || (cmIsOn(upperResult))); this->AppendToFoundProperty(packageFound); diff --git a/Source/cmGeneratorExpressionNode.cxx b/Source/cmGeneratorExpressionNode.cxx index 53bc3cd..9f761ed 100644 --- a/Source/cmGeneratorExpressionNode.cxx +++ b/Source/cmGeneratorExpressionNode.cxx @@ -169,7 +169,7 @@ static const struct BoolNode : public cmGeneratorExpressionNode const GeneratorExpressionContent* /*content*/, cmGeneratorExpressionDAGChecker* /*dagChecker*/) const override { - return !cmSystemTools::IsOff(parameters.front()) ? "1" : "0"; + return !cmIsOff(parameters.front()) ? "1" : "0"; } } boolNode; diff --git a/Source/cmGeneratorTarget.cxx b/Source/cmGeneratorTarget.cxx index 9412d82..dfd7833 100644 --- a/Source/cmGeneratorTarget.cxx +++ b/Source/cmGeneratorTarget.cxx @@ -825,7 +825,7 @@ bool cmGeneratorTarget::IsIPOEnabled(std::string const& lang, std::string const& config) const { const char* feature = "INTERPROCEDURAL_OPTIMIZATION"; - const bool result = cmSystemTools::IsOn(this->GetFeature(feature, config)); + const bool result = cmIsOn(this->GetFeature(feature, config)); if (!result) { // 'INTERPROCEDURAL_OPTIMIZATION' is off, no need to check policies @@ -1972,7 +1972,7 @@ bool cmGeneratorTarget::MacOSXUseInstallNameDir() const const char* build_with_install_name = this->GetProperty("BUILD_WITH_INSTALL_NAME_DIR"); if (build_with_install_name) { - return cmSystemTools::IsOn(build_with_install_name); + return cmIsOn(build_with_install_name); } cmPolicies::PolicyStatus cmp0068 = this->GetPolicyStatusCMP0068(); @@ -3033,7 +3033,7 @@ void processIncludeDirectories( } } - if (!cmSystemTools::IsOff(entryInclude)) { + if (!cmIsOff(entryInclude)) { cmSystemTools::ConvertToUnixSlashes(entryInclude); } @@ -4608,7 +4608,7 @@ bool getTypedProperty(cmGeneratorTarget const* tgt, } const char* value = tgt->GetProperty(prop); - return cmSystemTools::IsOn(genexInterpreter->Evaluate(value, prop)); + return cmIsOn(genexInterpreter->Evaluate(value, prop)); } template <> @@ -4726,7 +4726,7 @@ std::pair consistentProperty(const char* lhs, switch (t) { case BoolType: { - bool same = cmSystemTools::IsOn(lhs) == cmSystemTools::IsOn(rhs); + bool same = cmIsOn(lhs) == cmIsOn(rhs); return std::make_pair(same, same ? lhs : nullptr); } case StringType: @@ -4757,7 +4757,7 @@ std::pair consistentProperty(const std::string& lhs, switch (t) { case BoolType: { - bool same = cmSystemTools::IsOn(lhs) == cmSystemTools::IsOn(rhs); + bool same = cmIsOn(lhs) == cmIsOn(rhs); return std::make_pair(same, same ? lhs : null_ptr); } case StringType: @@ -5868,10 +5868,10 @@ void cmGeneratorTarget::ComputeImportInfo(std::string const& desired_config, std::string soProp = "IMPORTED_NO_SONAME"; soProp += suffix; if (const char* config_no_soname = this->GetProperty(soProp)) { - info.NoSOName = cmSystemTools::IsOn(config_no_soname); + info.NoSOName = cmIsOn(config_no_soname); } else if (const char* no_soname = this->GetProperty("IMPORTED_NO_SONAME")) { - info.NoSOName = cmSystemTools::IsOn(no_soname); + info.NoSOName = cmIsOn(no_soname); } } diff --git a/Source/cmGetFilenameComponentCommand.cxx b/Source/cmGetFilenameComponentCommand.cxx index c948b2a..d56af3d 100644 --- a/Source/cmGetFilenameComponentCommand.cxx +++ b/Source/cmGetFilenameComponentCommand.cxx @@ -22,7 +22,7 @@ bool cmGetFilenameComponentCommand::InitialPass( // already, if so use that value if (args.size() >= 4 && args.back() == "CACHE") { const char* cacheValue = this->Makefile->GetDefinition(args.front()); - if (cacheValue && !cmSystemTools::IsNOTFOUND(cacheValue)) { + if (cacheValue && !cmIsNOTFOUND(cacheValue)) { return true; } } diff --git a/Source/cmGhsMultiTargetGenerator.cxx b/Source/cmGhsMultiTargetGenerator.cxx index 47c731b..fc9ae01 100644 --- a/Source/cmGhsMultiTargetGenerator.cxx +++ b/Source/cmGhsMultiTargetGenerator.cxx @@ -561,10 +561,8 @@ void cmGhsMultiTargetGenerator::WriteSources(std::ostream& fout_proj) for (auto& sg : groupFilesList) { std::ostream* fout; bool useProjectFile = - cmSystemTools::IsOn( - this->GeneratorTarget->GetProperty("GHS_NO_SOURCE_GROUP_FILE")) || - cmSystemTools::IsOn( - this->Makefile->GetDefinition("CMAKE_GHS_NO_SOURCE_GROUP_FILE")); + cmIsOn(this->GeneratorTarget->GetProperty("GHS_NO_SOURCE_GROUP_FILE")) || + cmIsOn(this->Makefile->GetDefinition("CMAKE_GHS_NO_SOURCE_GROUP_FILE")); if (useProjectFile || sg.empty()) { fout = &fout_proj; } else { @@ -740,8 +738,7 @@ bool cmGhsMultiTargetGenerator::DetermineIfIntegrityApp() { const char* p = this->GeneratorTarget->GetProperty("ghs_integrity_app"); if (p) { - return cmSystemTools::IsOn( - this->GeneratorTarget->GetProperty("ghs_integrity_app")); + return cmIsOn(this->GeneratorTarget->GetProperty("ghs_integrity_app")); } std::vector sources; this->GeneratorTarget->GetSourceFiles(sources, this->ConfigName); diff --git a/Source/cmGlobalGenerator.cxx b/Source/cmGlobalGenerator.cxx index 86fcae0..d91fe6e 100644 --- a/Source/cmGlobalGenerator.cxx +++ b/Source/cmGlobalGenerator.cxx @@ -186,15 +186,15 @@ std::string cmGlobalGenerator::SelectMakeProgram( const std::string& inMakeProgram, const std::string& makeDefault) const { std::string makeProgram = inMakeProgram; - if (cmSystemTools::IsOff(makeProgram)) { + if (cmIsOff(makeProgram)) { const char* makeProgramCSTR = this->CMakeInstance->GetCacheDefinition("CMAKE_MAKE_PROGRAM"); - if (cmSystemTools::IsOff(makeProgramCSTR)) { + if (cmIsOff(makeProgramCSTR)) { makeProgram = makeDefault; } else { makeProgram = makeProgramCSTR; } - if (cmSystemTools::IsOff(makeProgram) && !makeProgram.empty()) { + if (cmIsOff(makeProgram) && !makeProgram.empty()) { makeProgram = "CMAKE_MAKE_PROGRAM-NOTFOUND"; } } @@ -300,7 +300,7 @@ bool cmGlobalGenerator::CheckTargetsForMissingSources() const if (target->GetType() == cmStateEnums::TargetType::GLOBAL_TARGET || target->GetType() == cmStateEnums::TargetType::INTERFACE_LIBRARY || target->GetType() == cmStateEnums::TargetType::UTILITY || - cmSystemTools::IsOn(target->GetProperty("ghs_integrity_app"))) { + cmIsOn(target->GetProperty("ghs_integrity_app"))) { continue; } @@ -382,14 +382,14 @@ bool cmGlobalGenerator::FindMakeProgram(cmMakefile* mf) return false; } if (!mf->GetDefinition("CMAKE_MAKE_PROGRAM") || - cmSystemTools::IsOff(mf->GetDefinition("CMAKE_MAKE_PROGRAM"))) { + cmIsOff(mf->GetDefinition("CMAKE_MAKE_PROGRAM"))) { std::string setMakeProgram = mf->GetModulesFile(this->FindMakeProgramFile); if (!setMakeProgram.empty()) { mf->ReadListFile(setMakeProgram); } } if (!mf->GetDefinition("CMAKE_MAKE_PROGRAM") || - cmSystemTools::IsOff(mf->GetDefinition("CMAKE_MAKE_PROGRAM"))) { + cmIsOff(mf->GetDefinition("CMAKE_MAKE_PROGRAM"))) { std::ostringstream err; err << "CMake was unable to find a build program corresponding to \"" << this->GetName() << "\". CMAKE_MAKE_PROGRAM is not set. You " @@ -771,8 +771,7 @@ void cmGlobalGenerator::EnableLanguage( compilerEnv += "_COMPILER_ENV_VAR"; std::ostringstream noCompiler; const char* compilerFile = mf->GetDefinition(compilerName); - if (!compilerFile || !*compilerFile || - cmSystemTools::IsNOTFOUND(compilerFile)) { + if (!compilerFile || !*compilerFile || cmIsNOTFOUND(compilerFile)) { /* clang-format off */ noCompiler << "No " << compilerName << " could be found.\n" @@ -1709,8 +1708,7 @@ void cmGlobalGenerator::CheckTargetProperties() continue; } for (auto const& lib : target.second.GetOriginalLinkLibraries()) { - if (lib.first.size() > 9 && - cmSystemTools::IsNOTFOUND(lib.first.c_str())) { + if (lib.first.size() > 9 && cmIsNOTFOUND(lib.first)) { std::string varName = lib.first.substr(0, lib.first.size() - 9); if (state->GetCacheEntryPropertyAsBool(varName, "ADVANCED")) { varName += " (ADVANCED)"; @@ -1736,7 +1734,7 @@ void cmGlobalGenerator::CheckTargetProperties() cmExpandList(incDirs, incs); for (std::string const& incDir : incs) { - if (incDir.size() > 9 && cmSystemTools::IsNOTFOUND(incDir.c_str())) { + if (incDir.size() > 9 && cmIsNOTFOUND(incDir)) { std::string varName = incDir.substr(0, incDir.size() - 9); if (state->GetCacheEntryPropertyAsBool(varName, "ADVANCED")) { varName += " (ADVANCED)"; @@ -2356,7 +2354,7 @@ void cmGlobalGenerator::AddGlobalTarget_Package( } else { const char* noPackageAll = mf->GetDefinition("CMAKE_SKIP_PACKAGE_ALL_DEPENDENCY"); - if (!noPackageAll || cmSystemTools::IsOff(noPackageAll)) { + if (!noPackageAll || cmIsOff(noPackageAll)) { gti.Depends.emplace_back(this->GetAllTargetName()); } } @@ -2525,7 +2523,7 @@ void cmGlobalGenerator::AddGlobalTarget_Install( } else { const char* noall = mf->GetDefinition("CMAKE_SKIP_INSTALL_ALL_DEPENDENCY"); - if (!noall || cmSystemTools::IsOff(noall)) { + if (!noall || cmIsOff(noall)) { gti.Depends.emplace_back(this->GetAllTargetName()); } } @@ -2608,7 +2606,7 @@ bool cmGlobalGenerator::UseFolderProperty() const // If this property is defined, let the setter turn this on or off... // if (prop) { - return cmSystemTools::IsOn(prop); + return cmIsOn(prop); } // By default, this feature is OFF, since it is not supported in the diff --git a/Source/cmGlobalGhsMultiGenerator.cxx b/Source/cmGlobalGhsMultiGenerator.cxx index 4db829f..5aae546 100644 --- a/Source/cmGlobalGhsMultiGenerator.cxx +++ b/Source/cmGlobalGhsMultiGenerator.cxx @@ -139,8 +139,7 @@ bool cmGlobalGhsMultiGenerator::SetGeneratorPlatform(std::string const& p, /* check if OS location has been updated by platform scripts */ std::string platform = mf->GetSafeDefinition("GHS_TARGET_PLATFORM"); std::string osdir = mf->GetSafeDefinition("GHS_OS_DIR"); - if (cmSystemTools::IsOff(osdir.c_str()) && - platform.find("integrity") != std::string::npos) { + if (cmIsOff(osdir) && platform.find("integrity") != std::string::npos) { if (!this->CMakeInstance->GetIsInTryCompile()) { /* required OS location is not found */ std::string m = @@ -151,8 +150,7 @@ bool cmGlobalGhsMultiGenerator::SetGeneratorPlatform(std::string const& p, } osdir = "GHS_OS_DIR-NOT-SPECIFIED"; } else if (!this->CMakeInstance->GetIsInTryCompile() && - cmSystemTools::IsOff(this->OsDir) && - !cmSystemTools::IsOff(osdir)) { + cmIsOff(this->OsDir) && !cmIsOff(osdir)) { /* OS location was updated by auto-selection */ std::string m = "Green Hills MULTI: GHS_OS_DIR not specified; found \""; m += osdir; @@ -164,8 +162,7 @@ bool cmGlobalGhsMultiGenerator::SetGeneratorPlatform(std::string const& p, // Determine GHS_BSP_NAME std::string bspName = mf->GetSafeDefinition("GHS_BSP_NAME"); - if (cmSystemTools::IsOff(bspName.c_str()) && - platform.find("integrity") != std::string::npos) { + if (cmIsOff(bspName) && platform.find("integrity") != std::string::npos) { bspName = "sim" + arch; /* write back the calculate name for next time */ mf->AddCacheDefinition("GHS_BSP_NAME", bspName.c_str(), @@ -335,18 +332,18 @@ void cmGlobalGhsMultiGenerator::WriteTopLevelProject(std::ostream& fout, // Specify BSP option if supplied by user const char* bspName = this->GetCMakeInstance()->GetCacheDefinition("GHS_BSP_NAME"); - if (!cmSystemTools::IsOff(bspName)) { + if (!cmIsOff(bspName)) { fout << " -bsp " << bspName << std::endl; } // Specify OS DIR if supplied by user // -- not all platforms require this entry in the project file - if (!cmSystemTools::IsOff(this->OsDir.c_str())) { + if (!cmIsOff(this->OsDir)) { const char* osDirOption = this->GetCMakeInstance()->GetCacheDefinition("GHS_OS_DIR_OPTION"); std::replace(this->OsDir.begin(), this->OsDir.end(), '\\', '/'); fout << " "; - if (cmSystemTools::IsOff(osDirOption)) { + if (cmIsOff(osDirOption)) { fout << ""; } else { fout << osDirOption; @@ -470,7 +467,7 @@ void cmGlobalGhsMultiGenerator::WriteAllTarget( if (t->GetType() == cmStateEnums::INTERFACE_LIBRARY) { continue; } - if (!cmSystemTools::IsOn(t->GetProperty("EXCLUDE_FROM_ALL"))) { + if (!cmIsOn(t->GetProperty("EXCLUDE_FROM_ALL"))) { defaultTargets.push_back(t); } } diff --git a/Source/cmGlobalUnixMakefileGenerator3.cxx b/Source/cmGlobalUnixMakefileGenerator3.cxx index 35af0e1..3b2b926 100644 --- a/Source/cmGlobalUnixMakefileGenerator3.cxx +++ b/Source/cmGlobalUnixMakefileGenerator3.cxx @@ -22,6 +22,7 @@ #include "cmState.h" #include "cmStateDirectory.h" #include "cmStateTypes.h" +#include "cmStringAlgorithms.h" #include "cmSystemTools.h" #include "cmTargetDepend.h" #include "cmake.h" @@ -697,7 +698,7 @@ void cmGlobalUnixMakefileGenerator3::WriteConvenienceRules2( if (const char* tgtMsg = this->GetCMakeInstance()->GetState()->GetGlobalProperty( "TARGET_MESSAGES")) { - targetMessages = cmSystemTools::IsOn(tgtMsg); + targetMessages = cmIsOn(tgtMsg); } if (targetMessages) { diff --git a/Source/cmGlobalVisualStudio7Generator.cxx b/Source/cmGlobalVisualStudio7Generator.cxx index 45b66ae..7136746 100644 --- a/Source/cmGlobalVisualStudio7Generator.cxx +++ b/Source/cmGlobalVisualStudio7Generator.cxx @@ -667,8 +667,7 @@ std::set cmGlobalVisualStudio7Generator::IsPartOfDefaultBuild( cmGeneratorExpression ge; std::unique_ptr cge = ge.Parse(propertyValue); - if (cmSystemTools::IsOn( - cge->Evaluate(target->GetLocalGenerator(), i))) { + if (cmIsOn(cge->Evaluate(target->GetLocalGenerator(), i))) { activeConfigs.insert(i); } } @@ -684,7 +683,7 @@ std::set cmGlobalVisualStudio7Generator::IsPartOfDefaultBuild( for (std::string const& i : configs) { const char* propertyValue = target->GetFeature("EXCLUDE_FROM_DEFAULT_BUILD", i); - if (cmSystemTools::IsOff(propertyValue)) { + if (cmIsOff(propertyValue)) { activeConfigs.insert(i); } } diff --git a/Source/cmGlobalVisualStudio8Generator.cxx b/Source/cmGlobalVisualStudio8Generator.cxx index 275be96..20deafe 100644 --- a/Source/cmGlobalVisualStudio8Generator.cxx +++ b/Source/cmGlobalVisualStudio8Generator.cxx @@ -299,7 +299,7 @@ bool cmGlobalVisualStudio8Generator::DeployInhibited( cmGeneratorExpression ge; std::unique_ptr cge = ge.Parse(propStr); std::string prop = cge->Evaluate(target.LocalGenerator, config); - rVal = cmSystemTools::IsOn(prop); + rVal = cmIsOn(prop); } return rVal; } diff --git a/Source/cmGlobalVisualStudioGenerator.cxx b/Source/cmGlobalVisualStudioGenerator.cxx index ba541a9..5c057c6 100644 --- a/Source/cmGlobalVisualStudioGenerator.cxx +++ b/Source/cmGlobalVisualStudioGenerator.cxx @@ -487,7 +487,7 @@ bool cmGlobalVisualStudioGenerator::FindMakeProgram(cmMakefile* mf) // Visual Studio generators know how to lookup their build tool // directly instead of needing a helper module to do it, so we // do not actually need to put CMAKE_MAKE_PROGRAM into the cache. - if (cmSystemTools::IsOff(mf->GetDefinition("CMAKE_MAKE_PROGRAM"))) { + if (cmIsOff(mf->GetDefinition("CMAKE_MAKE_PROGRAM"))) { mf->AddDefinition("CMAKE_MAKE_PROGRAM", this->GetVSMakeProgram()); } return true; diff --git a/Source/cmGlobalXCodeGenerator.cxx b/Source/cmGlobalXCodeGenerator.cxx index 19e64e4..3346c92 100644 --- a/Source/cmGlobalXCodeGenerator.cxx +++ b/Source/cmGlobalXCodeGenerator.cxx @@ -240,7 +240,7 @@ bool cmGlobalXCodeGenerator::FindMakeProgram(cmMakefile* mf) // The Xcode generator knows how to lookup its build tool // directly instead of needing a helper module to do it, so we // do not actually need to put CMAKE_MAKE_PROGRAM into the cache. - if (cmSystemTools::IsOff(mf->GetDefinition("CMAKE_MAKE_PROGRAM"))) { + if (cmIsOff(mf->GetDefinition("CMAKE_MAKE_PROGRAM"))) { mf->AddDefinition("CMAKE_MAKE_PROGRAM", this->GetXcodeBuildCommand()); } return true; @@ -1774,8 +1774,7 @@ void cmGlobalXCodeGenerator::AddPositionIndependentLinkAttribute( } buildSettings->AddAttribute( - "LD_NO_PIE", - this->CreateString(cmSystemTools::IsOn(PICValue) ? "NO" : "YES")); + "LD_NO_PIE", this->CreateString(cmIsOn(PICValue) ? "NO" : "YES")); } void cmGlobalXCodeGenerator::CreateBuildSettings(cmGeneratorTarget* gtgt, @@ -3738,7 +3737,7 @@ bool cmGlobalXCodeGenerator::UseEffectivePlatformName(cmMakefile* mf) const return mf->PlatformIsAppleEmbedded(); } - return cmSystemTools::IsOn(epnValue); + return cmIsOn(epnValue); } bool cmGlobalXCodeGenerator::ShouldStripResourcePath(cmMakefile*) const diff --git a/Source/cmIncludeDirectoryCommand.cxx b/Source/cmIncludeDirectoryCommand.cxx index 62e2abd..eb10aa8 100644 --- a/Source/cmIncludeDirectoryCommand.cxx +++ b/Source/cmIncludeDirectoryCommand.cxx @@ -9,6 +9,7 @@ #include "cmAlgorithms.h" #include "cmGeneratorExpression.h" #include "cmMakefile.h" +#include "cmStringAlgorithms.h" #include "cmSystemTools.h" class cmExecutionStatus; @@ -116,7 +117,7 @@ void cmIncludeDirectoryCommand::NormalizeInclude(std::string& inc) return; } - if (!cmSystemTools::IsOff(inc)) { + if (!cmIsOff(inc)) { cmSystemTools::ConvertToUnixSlashes(inc); if (!cmSystemTools::FileIsFullPath(inc)) { diff --git a/Source/cmInstalledFile.cxx b/Source/cmInstalledFile.cxx index 9b481a2..1e6c385 100644 --- a/Source/cmInstalledFile.cxx +++ b/Source/cmInstalledFile.cxx @@ -6,7 +6,6 @@ #include "cmListFileCache.h" #include "cmMakefile.h" #include "cmStringAlgorithms.h" -#include "cmSystemTools.h" #include @@ -98,7 +97,7 @@ bool cmInstalledFile::GetPropertyAsBool(const std::string& prop) const { std::string value; bool isSet = this->GetProperty(prop, value); - return isSet && cmSystemTools::IsOn(value); + return isSet && cmIsOn(value); } void cmInstalledFile::GetPropertyAsList(const std::string& prop, diff --git a/Source/cmLinkLineDeviceComputer.cxx b/Source/cmLinkLineDeviceComputer.cxx index 7cacb24..53b68eb 100644 --- a/Source/cmLinkLineDeviceComputer.cxx +++ b/Source/cmLinkLineDeviceComputer.cxx @@ -18,7 +18,6 @@ #include "cmStateSnapshot.h" #include "cmStateTypes.h" #include "cmStringAlgorithms.h" -#include "cmSystemTools.h" class cmOutputConverter; @@ -165,12 +164,12 @@ bool requireDeviceLinking(cmGeneratorTarget& target, cmLocalGenerator& lg, target.GetProperty("CUDA_RESOLVE_DEVICE_SYMBOLS")) { // If CUDA_RESOLVE_DEVICE_SYMBOLS has been explicitly set we need // to honor the value no matter what it is. - return cmSystemTools::IsOn(resolveDeviceSymbols); + return cmIsOn(resolveDeviceSymbols); } if (const char* separableCompilation = target.GetProperty("CUDA_SEPARABLE_COMPILATION")) { - if (cmSystemTools::IsOn(separableCompilation)) { + if (cmIsOn(separableCompilation)) { bool doDeviceLinking = false; switch (target.GetType()) { case cmStateEnums::SHARED_LIBRARY: diff --git a/Source/cmLocalGenerator.cxx b/Source/cmLocalGenerator.cxx index c3cfc5f..159791e 100644 --- a/Source/cmLocalGenerator.cxx +++ b/Source/cmLocalGenerator.cxx @@ -900,7 +900,7 @@ void cmLocalGenerator::AddCompileOptions(std::string& flags, std::unique_ptr cge = ge.Parse(jmcExprGen); std::string isJMCEnabled = cge->Evaluate(this, config); - if (cmSystemTools::IsOn(isJMCEnabled)) { + if (cmIsOn(isJMCEnabled)) { std::vector optVec; cmExpandList(jmc, optVec); this->AppendCompileOptions(flags, optVec); @@ -1254,8 +1254,7 @@ void cmLocalGenerator::GetTargetFlags( frameworkPath, linkPath); } - if (cmSystemTools::IsOn( - this->Makefile->GetDefinition("BUILD_SHARED_LIBS"))) { + if (cmIsOn(this->Makefile->GetDefinition("BUILD_SHARED_LIBS"))) { std::string sFlagVar = std::string("CMAKE_SHARED_BUILD_") + linkLanguage + std::string("_FLAGS"); linkFlags += this->Makefile->GetSafeDefinition(sFlagVar); @@ -1763,7 +1762,7 @@ void cmLocalGenerator::AddCompilerRequirementFlag( std::string extProp = lang + "_EXTENSIONS"; bool ext = true; if (const char* extPropValue = target->GetProperty(extProp)) { - if (cmSystemTools::IsOff(extPropValue)) { + if (cmIsOff(extPropValue)) { ext = false; } } @@ -2174,10 +2173,10 @@ void cmLocalGenerator::AppendPositionIndependentLinkerFlags( return; } - const std::string mode = cmSystemTools::IsOn(PICValue) ? "PIE" : "NO_PIE"; + const std::string mode = cmIsOn(PICValue) ? "PIE" : "NO_PIE"; std::string supported = "CMAKE_" + lang + "_LINK_" + mode + "_SUPPORTED"; - if (cmSystemTools::IsOff(this->Makefile->GetDefinition(supported))) { + if (cmIsOff(this->Makefile->GetDefinition(supported))) { return; } @@ -2266,7 +2265,7 @@ void cmLocalGenerator::AppendIncludeDirectories( std::string inc = include; - if (!cmSystemTools::IsOff(inc)) { + if (!cmIsOff(inc)) { cmSystemTools::ConvertToUnixSlashes(inc); } diff --git a/Source/cmLocalUnixMakefileGenerator3.cxx b/Source/cmLocalUnixMakefileGenerator3.cxx index a089682..e0b6467 100644 --- a/Source/cmLocalUnixMakefileGenerator3.cxx +++ b/Source/cmLocalUnixMakefileGenerator3.cxx @@ -853,7 +853,7 @@ void cmLocalUnixMakefileGenerator3::AppendRuleDepend( // it is specifically enabled by the user or project. const char* nodep = this->Makefile->GetDefinition("CMAKE_SKIP_RULE_DEPENDENCY"); - if (!nodep || cmSystemTools::IsOff(nodep)) { + if (!nodep || cmIsOff(nodep)) { depends.emplace_back(ruleFileName); } } @@ -1423,7 +1423,7 @@ bool cmLocalUnixMakefileGenerator3::ScanDependencies( if (haveDirectoryInfo) { // Test whether we need to force Unix paths. if (const char* force = mf->GetDefinition("CMAKE_FORCE_UNIX_PATHS")) { - if (!cmSystemTools::IsOff(force)) { + if (!cmIsOff(force)) { cmSystemTools::SetForceUnixPaths(true); } } @@ -1689,7 +1689,7 @@ void cmLocalUnixMakefileGenerator3::WriteLocalAllRules( depends.clear(); const char* noall = this->Makefile->GetDefinition("CMAKE_SKIP_INSTALL_ALL_DEPENDENCY"); - if (!noall || cmSystemTools::IsOff(noall)) { + if (!noall || cmIsOff(noall)) { // Drive the build before installing. depends.emplace_back("all"); } else if (regenerate) { diff --git a/Source/cmMakefile.cxx b/Source/cmMakefile.cxx index 657c3bf..5ebd053 100644 --- a/Source/cmMakefile.cxx +++ b/Source/cmMakefile.cxx @@ -1840,7 +1840,7 @@ void cmMakefile::AddCacheDefinition(const std::string& name, const char* value, cmExpandList(nvalue, files); nvalue.clear(); for (cc = 0; cc < files.size(); cc++) { - if (!cmSystemTools::IsOff(files[cc])) { + if (!cmIsOff(files[cc])) { files[cc] = cmSystemTools::CollapseFullPath(files[cc]); } if (cc > 0) { @@ -2324,7 +2324,7 @@ void cmMakefile::ExpandVariablesCMP0019() bool cmMakefile::IsOn(const std::string& name) const { const char* value = this->GetDefinition(name); - return cmSystemTools::IsOn(value); + return cmIsOn(value); } bool cmMakefile::IsSet(const std::string& name) const @@ -2338,7 +2338,7 @@ bool cmMakefile::IsSet(const std::string& name) const return false; } - if (cmSystemTools::IsNOTFOUND(value)) { + if (cmIsNOTFOUND(value)) { return false; } @@ -3650,7 +3650,7 @@ void cmMakefile::ConfigureString(const std::string& input, std::string& output, // Replace #cmakedefine instances. if (this->cmDefineRegex.find(line)) { const char* def = this->GetDefinition(this->cmDefineRegex.match(2)); - if (!cmSystemTools::IsOff(def)) { + if (!cmIsOff(def)) { const std::string indentation = this->cmDefineRegex.match(1); cmSystemTools::ReplaceString(line, "#" + indentation + "cmakedefine", "#" + indentation + "define"); @@ -3666,7 +3666,7 @@ void cmMakefile::ConfigureString(const std::string& input, std::string& output, cmSystemTools::ReplaceString(line, "#" + indentation + "cmakedefine01", "#" + indentation + "define"); output += line; - if (!cmSystemTools::IsOff(def)) { + if (!cmIsOff(def)) { output += " 1"; } else { output += " 0"; @@ -3830,7 +3830,7 @@ const char* cmMakefile::GetProperty(const std::string& prop, bool chain) const bool cmMakefile::GetPropertyAsBool(const std::string& prop) const { - return cmSystemTools::IsOn(this->GetProperty(prop)); + return cmIsOn(this->GetProperty(prop)); } std::vector cmMakefile::GetPropertyKeys() const @@ -4220,7 +4220,7 @@ bool cmMakefile::PolicyOptionalWarningEnabled(std::string const& var) { // Check for an explicit CMAKE_POLICY_WARNING_CMP setting. if (const char* val = this->GetDefinition(var)) { - return cmSystemTools::IsOn(val); + return cmIsOn(val); } // Enable optional policy warnings with --debug-output, --trace, // or --trace-expand. diff --git a/Source/cmMakefileTargetGenerator.cxx b/Source/cmMakefileTargetGenerator.cxx index 6a79615..f35df32 100644 --- a/Source/cmMakefileTargetGenerator.cxx +++ b/Source/cmMakefileTargetGenerator.cxx @@ -49,7 +49,7 @@ cmMakefileTargetGenerator::cmMakefileTargetGenerator(cmGeneratorTarget* target) this->NoRuleMessages = false; if (const char* ruleStatus = cm->GetState()->GetGlobalProperty("RULE_MESSAGES")) { - this->NoRuleMessages = cmSystemTools::IsOff(ruleStatus); + this->NoRuleMessages = cmIsOff(ruleStatus); } MacOSXContentGenerator = new MacOSXContentGeneratorType(this); } @@ -186,7 +186,7 @@ void cmMakefileTargetGenerator::WriteTargetBuildRules() // add custom commands to the clean rules? const char* clean_no_custom = this->Makefile->GetProperty("CLEAN_NO_CUSTOM"); - bool clean = cmSystemTools::IsOff(clean_no_custom); + bool clean = cmIsOff(clean_no_custom); // First generate the object rule files. Save a list of all object // files for this target. @@ -1528,7 +1528,7 @@ bool cmMakefileTargetGenerator::CheckUseResponseFileForObjects( "CMAKE_" + l + "_USE_RESPONSE_FILE_FOR_OBJECTS"; if (const char* val = this->Makefile->GetDefinition(responseVar)) { if (*val) { - return cmSystemTools::IsOn(val); + return cmIsOn(val); } } @@ -1567,7 +1567,7 @@ bool cmMakefileTargetGenerator::CheckUseResponseFileForLibraries( "CMAKE_" + l + "_USE_RESPONSE_FILE_FOR_LIBRARIES"; if (const char* val = this->Makefile->GetDefinition(responseVar)) { if (*val) { - return cmSystemTools::IsOn(val); + return cmIsOn(val); } } diff --git a/Source/cmOptionCommand.cxx b/Source/cmOptionCommand.cxx index 3724ba7..a30f487 100644 --- a/Source/cmOptionCommand.cxx +++ b/Source/cmOptionCommand.cxx @@ -11,7 +11,6 @@ #include "cmStateSnapshot.h" #include "cmStateTypes.h" #include "cmStringAlgorithms.h" -#include "cmSystemTools.h" class cmExecutionStatus; @@ -67,7 +66,7 @@ bool cmOptionCommand::InitialPass(std::vector const& args, if (args.size() == 3) { initialValue = args[2]; } - bool init = cmSystemTools::IsOn(initialValue); + bool init = cmIsOn(initialValue); this->Makefile->AddCacheDefinition(args[0], init ? "ON" : "OFF", args[1].c_str(), cmStateEnums::BOOL); diff --git a/Source/cmQtAutoGenGlobalInitializer.cxx b/Source/cmQtAutoGenGlobalInitializer.cxx index ca5a587..21de8c6 100644 --- a/Source/cmQtAutoGenGlobalInitializer.cxx +++ b/Source/cmQtAutoGenGlobalInitializer.cxx @@ -49,8 +49,7 @@ cmQtAutoGenGlobalInitializer::cmQtAutoGenGlobalInitializer( { cmMakefile* makefile = localGen->GetMakefile(); // Detect global autogen target name - if (cmSystemTools::IsOn( - makefile->GetSafeDefinition("CMAKE_GLOBAL_AUTOGEN_TARGET"))) { + if (cmIsOn(makefile->GetSafeDefinition("CMAKE_GLOBAL_AUTOGEN_TARGET"))) { std::string targetName = makefile->GetSafeDefinition("CMAKE_GLOBAL_AUTOGEN_TARGET_NAME"); if (targetName.empty()) { @@ -61,8 +60,7 @@ cmQtAutoGenGlobalInitializer::cmQtAutoGenGlobalInitializer( } // Detect global autorcc target name - if (cmSystemTools::IsOn( - makefile->GetSafeDefinition("CMAKE_GLOBAL_AUTORCC_TARGET"))) { + if (cmIsOn(makefile->GetSafeDefinition("CMAKE_GLOBAL_AUTORCC_TARGET"))) { std::string targetName = makefile->GetSafeDefinition("CMAKE_GLOBAL_AUTORCC_TARGET_NAME"); if (targetName.empty()) { diff --git a/Source/cmQtAutoGenInitializer.cxx b/Source/cmQtAutoGenInitializer.cxx index 3218076..8aa5f20 100644 --- a/Source/cmQtAutoGenInitializer.cxx +++ b/Source/cmQtAutoGenInitializer.cxx @@ -245,7 +245,7 @@ bool cmQtAutoGenInitializer::InitCustomTargets() unsigned long iVerb = 0; if (!cmStrToULong(this->Verbosity, &iVerb)) { // Non numeric verbosity - this->Verbosity = cmSystemTools::IsOn(this->Verbosity) ? "1" : "0"; + this->Verbosity = cmIsOn(this->Verbosity) ? "1" : "0"; } } @@ -407,8 +407,7 @@ bool cmQtAutoGenInitializer::InitCustomTargets() // CMAKE_AUTOMOC_RELAXED_MODE deprecation warning if (this->Moc.Enabled) { - if (cmSystemTools::IsOn( - makefile->GetDefinition("CMAKE_AUTOMOC_RELAXED_MODE"))) { + if (cmIsOn(makefile->GetDefinition("CMAKE_AUTOMOC_RELAXED_MODE"))) { std::string msg = "AUTOMOC: CMAKE_AUTOMOC_RELAXED_MODE is " "deprecated an will be removed in the future. "; msg += "Consider disabling it and converting the target "; diff --git a/Source/cmQtAutoGenerator.cxx b/Source/cmQtAutoGenerator.cxx index 996b2bc..0e8fa9a 100644 --- a/Source/cmQtAutoGenerator.cxx +++ b/Source/cmQtAutoGenerator.cxx @@ -26,7 +26,7 @@ cmQtAutoGenerator::Logger::Logger() SetVerbosity(static_cast(iVerbose)); } else { // Non numeric verbosity - SetVerbose(cmSystemTools::IsOn(verbose)); + SetVerbose(cmIsOn(verbose)); } } } @@ -34,7 +34,7 @@ cmQtAutoGenerator::Logger::Logger() std::string colorEnv; cmSystemTools::GetEnv("COLOR", colorEnv); if (!colorEnv.empty()) { - SetColorOutput(cmSystemTools::IsOn(colorEnv)); + SetColorOutput(cmIsOn(colorEnv)); } else { SetColorOutput(true); } diff --git a/Source/cmSetPropertyCommand.cxx b/Source/cmSetPropertyCommand.cxx index e9343c7..9192c11 100644 --- a/Source/cmSetPropertyCommand.cxx +++ b/Source/cmSetPropertyCommand.cxx @@ -11,6 +11,7 @@ #include "cmRange.h" #include "cmSourceFile.h" #include "cmState.h" +#include "cmStringAlgorithms.h" #include "cmSystemTools.h" #include "cmTarget.h" #include "cmTest.h" @@ -331,8 +332,8 @@ bool cmSetPropertyCommand::HandleTest(cmTest* test) bool cmSetPropertyCommand::HandleCacheMode() { if (this->PropertyName == "ADVANCED") { - if (!this->Remove && !cmSystemTools::IsOn(this->PropertyValue) && - !cmSystemTools::IsOff(this->PropertyValue)) { + if (!this->Remove && !cmIsOn(this->PropertyValue) && + !cmIsOff(this->PropertyValue)) { std::ostringstream e; e << "given non-boolean value \"" << this->PropertyValue << R"(" for CACHE property "ADVANCED". )"; diff --git a/Source/cmSetSourceFilesPropertiesCommand.cxx b/Source/cmSetSourceFilesPropertiesCommand.cxx index 9388e7c..8e3217f 100644 --- a/Source/cmSetSourceFilesPropertiesCommand.cxx +++ b/Source/cmSetSourceFilesPropertiesCommand.cxx @@ -4,7 +4,7 @@ #include "cmMakefile.h" #include "cmSourceFile.h" -#include "cmSystemTools.h" +#include "cmStringAlgorithms.h" class cmExecutionStatus; @@ -87,7 +87,7 @@ bool cmSetSourceFilesPropertiesCommand::RunCommand( propertyPairs.push_back(*j); if (*j == "GENERATED") { ++j; - if (j != propend && cmSystemTools::IsOn(*j)) { + if (j != propend && cmIsOn(*j)) { generated = true; } } else { diff --git a/Source/cmSiteNameCommand.cxx b/Source/cmSiteNameCommand.cxx index 9f041bc..61ede29 100644 --- a/Source/cmSiteNameCommand.cxx +++ b/Source/cmSiteNameCommand.cxx @@ -6,6 +6,7 @@ #include "cmMakefile.h" #include "cmStateTypes.h" +#include "cmStringAlgorithms.h" #include "cmSystemTools.h" class cmExecutionStatus; @@ -50,7 +51,7 @@ bool cmSiteNameCommand::InitialPass(std::vector const& args, } #else // try to find the hostname for this computer - if (!cmSystemTools::IsOff(hostname_cmd)) { + if (!cmIsOff(hostname_cmd)) { std::string host; cmSystemTools::RunSingleCommand(hostname_cmd, &host, nullptr, nullptr, nullptr, cmSystemTools::OUTPUT_NONE); diff --git a/Source/cmSourceFile.cxx b/Source/cmSourceFile.cxx index d05fb68..3f52e64 100644 --- a/Source/cmSourceFile.cxx +++ b/Source/cmSourceFile.cxx @@ -11,6 +11,7 @@ #include "cmMessageType.h" #include "cmProperty.h" #include "cmState.h" +#include "cmStringAlgorithms.h" #include "cmSystemTools.h" #include "cmake.h" @@ -242,7 +243,7 @@ void cmSourceFile::SetProperty(const std::string& prop, const char* value) // Update IsGenerated flag if (prop == propGENERATED) { - this->IsGenerated = cmSystemTools::IsOn(value); + this->IsGenerated = cmIsOn(value); } } @@ -316,7 +317,7 @@ const char* cmSourceFile::GetSafeProperty(const std::string& prop) const bool cmSourceFile::GetPropertyAsBool(const std::string& prop) const { - return cmSystemTools::IsOn(this->GetProperty(prop)); + return cmIsOn(this->GetProperty(prop)); } cmCustomCommand* cmSourceFile::GetCustomCommand() diff --git a/Source/cmState.cxx b/Source/cmState.cxx index 1ea72e1..07f4dec 100644 --- a/Source/cmState.cxx +++ b/Source/cmState.cxx @@ -598,7 +598,7 @@ const char* cmState::GetGlobalProperty(const std::string& prop) bool cmState::GetGlobalPropertyAsBool(const std::string& prop) { - return cmSystemTools::IsOn(this->GetGlobalProperty(prop)); + return cmIsOn(this->GetGlobalProperty(prop)); } void cmState::SetSourceDirectory(std::string const& sourceDirectory) diff --git a/Source/cmStateDirectory.cxx b/Source/cmStateDirectory.cxx index 3f70ed3..df96bd3 100644 --- a/Source/cmStateDirectory.cxx +++ b/Source/cmStateDirectory.cxx @@ -662,7 +662,7 @@ const char* cmStateDirectory::GetProperty(const std::string& prop, bool cmStateDirectory::GetPropertyAsBool(const std::string& prop) const { - return cmSystemTools::IsOn(this->GetProperty(prop)); + return cmIsOn(this->GetProperty(prop)); } std::vector cmStateDirectory::GetPropertyKeys() const diff --git a/Source/cmStateSnapshot.cxx b/Source/cmStateSnapshot.cxx index 110ec56..121923d 100644 --- a/Source/cmStateSnapshot.cxx +++ b/Source/cmStateSnapshot.cxx @@ -328,7 +328,7 @@ void cmStateSnapshot::SetDefaultDefinitions() #if defined(__CYGWIN__) std::string legacy; if (cmSystemTools::GetEnv("CMAKE_LEGACY_CYGWIN_WIN32", legacy) && - cmSystemTools::IsOn(legacy.c_str())) { + cmIsOn(legacy.c_str())) { this->SetDefinition("WIN32", "1"); this->SetDefinition("CMAKE_HOST_WIN32", "1"); } diff --git a/Source/cmTarget.cxx b/Source/cmTarget.cxx index 61b8702..9b002ee 100644 --- a/Source/cmTarget.cxx +++ b/Source/cmTarget.cxx @@ -1191,7 +1191,7 @@ void cmTarget::SetProperty(const std::string& prop, const char* value) impl->SourceBacktraces.push_back(lfbt); } } else if (prop == propIMPORTED_GLOBAL) { - if (!cmSystemTools::IsOn(value)) { + if (!cmIsOn(value)) { std::ostringstream e; e << "IMPORTED_GLOBAL property can't be set to FALSE on targets (\"" << impl->Name << "\")\n"; @@ -1671,7 +1671,7 @@ const char* cmTarget::GetSafeProperty(const std::string& prop) const bool cmTarget::GetPropertyAsBool(const std::string& prop) const { - return cmSystemTools::IsOn(this->GetProperty(prop)); + return cmIsOn(this->GetProperty(prop)); } cmPropertyMap const& cmTarget::GetProperties() const diff --git a/Source/cmTest.cxx b/Source/cmTest.cxx index 01f2b96..d5c61c1 100644 --- a/Source/cmTest.cxx +++ b/Source/cmTest.cxx @@ -5,7 +5,7 @@ #include "cmMakefile.h" #include "cmProperty.h" #include "cmState.h" -#include "cmSystemTools.h" +#include "cmStringAlgorithms.h" cmTest::cmTest(cmMakefile* mf) : CommandExpandLists(false) @@ -47,7 +47,7 @@ const char* cmTest::GetProperty(const std::string& prop) const bool cmTest::GetPropertyAsBool(const std::string& prop) const { - return cmSystemTools::IsOn(this->GetProperty(prop)); + return cmIsOn(this->GetProperty(prop)); } void cmTest::SetProperty(const std::string& prop, const char* value) diff --git a/Source/cmVisualStudio10TargetGenerator.cxx b/Source/cmVisualStudio10TargetGenerator.cxx index 0e4b0af..08378eb 100644 --- a/Source/cmVisualStudio10TargetGenerator.cxx +++ b/Source/cmVisualStudio10TargetGenerator.cxx @@ -838,7 +838,7 @@ void cmVisualStudio10TargetGenerator::WriteDotNetReference( const char* privateReference = "True"; if (const char* value = this->GeneratorTarget->GetProperty( "VS_DOTNET_REFERENCES_COPY_LOCAL")) { - if (cmSystemTools::IsOff(value)) { + if (cmIsOff(value)) { privateReference = "False"; } } @@ -1948,11 +1948,11 @@ void cmVisualStudio10TargetGenerator::WriteExtraSource(Elem& e1, const std::string& enableDebug = cge->Evaluate(this->LocalGenerator, this->Configurations[i]); if (!enableDebug.empty()) { - e2.WritePlatformConfigTag( - "EnableDebuggingInformation", - "'$(Configuration)|$(Platform)'=='" + this->Configurations[i] + - "|" + this->Platform + "'", - cmSystemTools::IsOn(enableDebug) ? "true" : "false"); + e2.WritePlatformConfigTag("EnableDebuggingInformation", + "'$(Configuration)|$(Platform)'=='" + + this->Configurations[i] + "|" + + this->Platform + "'", + cmIsOn(enableDebug) ? "true" : "false"); } } } @@ -1969,7 +1969,7 @@ void cmVisualStudio10TargetGenerator::WriteExtraSource(Elem& e1, "DisableOptimizations", "'$(Configuration)|$(Platform)'=='" + this->Configurations[i] + "|" + this->Platform + "'", - (cmSystemTools::IsOn(disableOptimizations) ? "true" : "false")); + (cmIsOn(disableOptimizations) ? "true" : "false")); } } } @@ -2743,7 +2743,7 @@ bool cmVisualStudio10TargetGenerator::ComputeClOptions( } } if (const char* winRT = clOptions.GetFlag("CompileAsWinRT")) { - if (cmSystemTools::IsOn(winRT)) { + if (cmIsOn(winRT)) { this->TargetCompileAsWinRT = true; } } @@ -3273,9 +3273,9 @@ void cmVisualStudio10TargetGenerator::WriteManifestOptions( if (dpiAware) { if (!strcmp(dpiAware, "PerMonitor")) { e2.Element("EnableDpiAwareness", "PerMonitorHighDPIAware"); - } else if (cmSystemTools::IsOn(dpiAware)) { + } else if (cmIsOn(dpiAware)) { e2.Element("EnableDpiAwareness", "true"); - } else if (cmSystemTools::IsOff(dpiAware)) { + } else if (cmIsOff(dpiAware)) { e2.Element("EnableDpiAwareness", "false"); } else { cmSystemTools::Error("Bad parameter for VS_DPI_AWARE: " + diff --git a/Source/cmake.cxx b/Source/cmake.cxx index 440a7b1..1625931 100644 --- a/Source/cmake.cxx +++ b/Source/cmake.cxx @@ -1365,18 +1365,16 @@ int cmake::Configure() // so we cannot rely on command line options alone. Always ensure our // messenger is in sync with the cache. const char* value = this->State->GetCacheEntryValue("CMAKE_WARN_DEPRECATED"); - this->Messenger->SetSuppressDeprecatedWarnings(value && - cmSystemTools::IsOff(value)); + this->Messenger->SetSuppressDeprecatedWarnings(value && cmIsOff(value)); value = this->State->GetCacheEntryValue("CMAKE_ERROR_DEPRECATED"); - this->Messenger->SetDeprecatedWarningsAsErrors(cmSystemTools::IsOn(value)); + this->Messenger->SetDeprecatedWarningsAsErrors(cmIsOn(value)); value = this->State->GetCacheEntryValue("CMAKE_SUPPRESS_DEVELOPER_WARNINGS"); - this->Messenger->SetSuppressDevWarnings(cmSystemTools::IsOn(value)); + this->Messenger->SetSuppressDevWarnings(cmIsOn(value)); value = this->State->GetCacheEntryValue("CMAKE_SUPPRESS_DEVELOPER_ERRORS"); - this->Messenger->SetDevWarningsAsErrors(value && - cmSystemTools::IsOff(value)); + this->Messenger->SetDevWarningsAsErrors(value && cmIsOff(value)); int ret = this->ActualConfigure(); const char* delCacheVars = @@ -1804,15 +1802,13 @@ void cmake::AddCacheEntry(const std::string& key, const char* value, this->UnwatchUnusedCli(key); if (key == "CMAKE_WARN_DEPRECATED") { - this->Messenger->SetSuppressDeprecatedWarnings( - value && cmSystemTools::IsOff(value)); + this->Messenger->SetSuppressDeprecatedWarnings(value && cmIsOff(value)); } else if (key == "CMAKE_ERROR_DEPRECATED") { - this->Messenger->SetDeprecatedWarningsAsErrors(cmSystemTools::IsOn(value)); + this->Messenger->SetDeprecatedWarningsAsErrors(cmIsOn(value)); } else if (key == "CMAKE_SUPPRESS_DEVELOPER_WARNINGS") { - this->Messenger->SetSuppressDevWarnings(cmSystemTools::IsOn(value)); + this->Messenger->SetSuppressDevWarnings(cmIsOn(value)); } else if (key == "CMAKE_SUPPRESS_DEVELOPER_ERRORS") { - this->Messenger->SetDevWarningsAsErrors(value && - cmSystemTools::IsOff(value)); + this->Messenger->SetDevWarningsAsErrors(value && cmIsOff(value)); } } @@ -2626,7 +2622,7 @@ int cmake::Build(int jobs, const std::string& dir, const char* cachedVerbose = this->State->GetCacheEntryValue("CMAKE_VERBOSE_MAKEFILE"); - if (cmSystemTools::IsOn(cachedVerbose)) { + if (cmIsOn(cachedVerbose)) { verbose = true; } diff --git a/Source/cmcmd.cxx b/Source/cmcmd.cxx index ba2788e..9b8689f 100644 --- a/Source/cmcmd.cxx +++ b/Source/cmcmd.cxx @@ -945,8 +945,7 @@ int cmcmd::ExecuteCMakeCommand(std::vector const& args) if (args.size() >= 9 && args[8].length() >= 8 && args[8].substr(0, 8) == "--color=") { // Enable or disable color based on the switch value. - color = - (args[8].size() == 8 || cmSystemTools::IsOn(args[8].substr(8))); + color = (args[8].size() == 8 || cmIsOn(args[8].substr(8))); } } else { // Support older signature for existing makefiles: @@ -1411,7 +1410,7 @@ int cmcmd::ExecuteEchoColor(std::vector const& args) // Enable or disable color based on the switch value. std::string value = arg.substr(9); if (!value.empty()) { - enabled = cmSystemTools::IsOn(value); + enabled = cmIsOn(value); } } else if (cmHasLiteralPrefix(arg, "--progress-dir=")) { progressDir = arg.substr(15); @@ -1463,7 +1462,7 @@ int cmcmd::ExecuteLinkScript(std::vector const& args) bool verbose = false; if (args.size() >= 4) { if (args[3].find("--verbose=") == 0) { - if (!cmSystemTools::IsOff(args[3].substr(10))) { + if (!cmIsOff(args[3].substr(10))) { verbose = true; } } https://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=5b7650216b92b89e0dd083191ad1178aefbb6a9f commit 5b7650216b92b89e0dd083191ad1178aefbb6a9f Author: Sebastian Holtermann AuthorDate: Sat Aug 17 10:58:50 2019 +0200 Commit: Sebastian Holtermann CommitDate: Sat Aug 17 10:58:50 2019 +0200 cmStringAlgorithms: Add cmIsInternallyOn, cmIsNOTFOUND, cmIsOn, cmIsOff This adds the following functions to cmStringAlgorithms: - `cmIsInternallyOn` - `cmIsNOTFOUND` - `cmIsOn` - `cmIsOff` The implementations were copied from the equivalent functions in cmSystemTools. diff --git a/Source/cmStringAlgorithms.cxx b/Source/cmStringAlgorithms.cxx index 9f067e2..c686aa0 100644 --- a/Source/cmStringAlgorithms.cxx +++ b/Source/cmStringAlgorithms.cxx @@ -212,6 +212,85 @@ std::string cmCatViews(std::initializer_list views) return result; } +bool cmIsInternallyOn(cm::string_view val) +{ + return (val.size() == 4) && // + (val[0] == 'I' || val[0] == 'i') && // + (val[1] == '_') && // + (val[2] == 'O' || val[2] == 'o') && // + (val[3] == 'N' || val[3] == 'n'); +} + +bool cmIsNOTFOUND(cm::string_view val) +{ + return (val == "NOTFOUND") || cmHasLiteralSuffix(val, "-NOTFOUND"); +} + +bool cmIsOn(cm::string_view val) +{ + switch (val.size()) { + case 1: + return val[0] == '1' || val[0] == 'Y' || val[0] == 'y'; + case 2: + return // + (val[0] == 'O' || val[0] == 'o') && // + (val[1] == 'N' || val[1] == 'n'); + case 3: + return // + (val[0] == 'Y' || val[0] == 'y') && // + (val[1] == 'E' || val[1] == 'e') && // + (val[2] == 'S' || val[2] == 's'); + case 4: + return // + (val[0] == 'T' || val[0] == 't') && // + (val[1] == 'R' || val[1] == 'r') && // + (val[2] == 'U' || val[2] == 'u') && // + (val[3] == 'E' || val[3] == 'e'); + default: + break; + } + + return false; +} + +bool cmIsOff(cm::string_view val) +{ + switch (val.size()) { + case 0: + return true; + case 1: + return val[0] == '0' || val[0] == 'N' || val[0] == 'n'; + case 2: + return // + (val[0] == 'N' || val[0] == 'n') && // + (val[1] == 'O' || val[1] == 'o'); + case 3: + return // + (val[0] == 'O' || val[0] == 'o') && // + (val[1] == 'F' || val[1] == 'f') && // + (val[2] == 'F' || val[2] == 'f'); + case 5: + return // + (val[0] == 'F' || val[0] == 'f') && // + (val[1] == 'A' || val[1] == 'a') && // + (val[2] == 'L' || val[2] == 'l') && // + (val[3] == 'S' || val[3] == 's') && // + (val[4] == 'E' || val[4] == 'e'); + case 6: + return // + (val[0] == 'I' || val[0] == 'i') && // + (val[1] == 'G' || val[1] == 'g') && // + (val[2] == 'N' || val[2] == 'n') && // + (val[3] == 'O' || val[3] == 'o') && // + (val[4] == 'R' || val[4] == 'r') && // + (val[5] == 'E' || val[5] == 'e'); + default: + break; + } + + return cmIsNOTFOUND(val); +} + bool cmStrToLong(const char* str, long* value) { errno = 0; diff --git a/Source/cmStringAlgorithms.h b/Source/cmStringAlgorithms.h index 223d712..5b8b878 100644 --- a/Source/cmStringAlgorithms.h +++ b/Source/cmStringAlgorithms.h @@ -180,6 +180,51 @@ std::string cmWrap(char prefix, Range const& rng, char suffix, sep); } +/** + * Does a string indicates that CMake/CPack/CTest internally + * forced this value. This is not the same as On, but this + * may be considered as "internally switched on". + */ +bool cmIsInternallyOn(cm::string_view val); +inline bool cmIsInternallyOn(const char* val) +{ + if (!val) { + return false; + } + return cmIsInternallyOn(cm::string_view(val)); +} + +/** Return true if value is NOTFOUND or ends in -NOTFOUND. */ +bool cmIsNOTFOUND(cm::string_view val); + +/** + * Does a string indicate a true or ON value? This is not the same as ifdef. + */ +bool cmIsOn(cm::string_view val); +inline bool cmIsOn(const char* val) +{ + if (!val) { + return false; + } + return cmIsOn(cm::string_view(val)); +} + +/** + * Does a string indicate a false or off value ? Note that this is + * not the same as !IsOn(...) because there are a number of + * ambiguous values such as "/usr/local/bin" a path will result in + * IsON and IsOff both returning false. Note that the special path + * NOTFOUND, *-NOTFOUND or IGNORE will cause IsOff to return true. + */ +bool cmIsOff(cm::string_view val); +inline bool cmIsOff(const char* val) +{ + if (!val) { + return true; + } + return cmIsOff(cm::string_view(val)); +} + /** Returns true if string @a str starts with the character @a prefix. */ inline bool cmHasPrefix(cm::string_view str, char prefix) { https://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=4d83e47c054ceb1d3b9a7ae5f2f385e1632675c6 commit 4d83e47c054ceb1d3b9a7ae5f2f385e1632675c6 Author: Saleem Abdulrasool AuthorDate: Sun Aug 11 17:57:16 2019 -0700 Commit: Saleem Abdulrasool CommitDate: Sun Aug 11 17:59:52 2019 -0700 Swift: define `CMAKE_Swift_FLAGS` correctly Invoke `cmake_initialize_per_config_variable` to ensure that build type flags are properly initialised. diff --git a/Modules/CMakeSwiftInformation.cmake b/Modules/CMakeSwiftInformation.cmake index 54e441c..6dd614b 100644 --- a/Modules/CMakeSwiftInformation.cmake +++ b/Modules/CMakeSwiftInformation.cmake @@ -55,6 +55,8 @@ set(CMAKE_Swift_FLAGS_RELEASE_INIT "-O") set(CMAKE_Swift_FLAGS_RELWITHDEBINFO_INIT "-O -g") set(CMAKE_Swift_FLAGS_MINSIZEREL_INIT "-Osize") +cmake_initialize_per_config_variable(CMAKE_Swift_FLAGS "Swift Compiler Flags") + # NOTE(compnerd) we do not have an object compile rule since we build the objects as part of the link step if(NOT CMAKE_Swift_COMPILE_OBJECT) set(CMAKE_Swift_COMPILE_OBJECT ":") ----------------------------------------------------------------------- Summary of changes: Modules/CMakeSwiftInformation.cmake | 2 + Source/CPack/IFW/cmCPackIFWGenerator.cxx | 8 +-- Source/CPack/WiX/cmCPackWIXGenerator.cxx | 4 +- Source/CPack/cmCPackDebGenerator.cxx | 2 +- Source/CPack/cmCPackExternalGenerator.cxx | 10 ++- Source/CPack/cmCPackGenerator.cxx | 20 +++--- Source/CPack/cmCPackNSISGenerator.cxx | 8 +-- Source/CPack/cmCPackRPMGenerator.cxx | 3 +- Source/CTest/cmCTestBuildHandler.cxx | 2 +- Source/CTest/cmCTestCoverageHandler.cxx | 3 +- Source/CTest/cmCTestGIT.cxx | 2 +- Source/CTest/cmCTestLaunch.cxx | 3 +- Source/CTest/cmCTestSubmitHandler.cxx | 4 +- Source/CTest/cmCTestTestHandler.cxx | 14 ++-- Source/CTest/cmCTestVC.cxx | 4 +- .../CursesDialog/cmCursesCacheEntryComposite.cxx | 2 +- Source/CursesDialog/cmCursesMainForm.cxx | 3 +- Source/QtDialog/QCMake.cxx | 3 +- Source/cmAddLibraryCommand.cxx | 4 +- Source/cmCPluginAPI.cxx | 2 +- Source/cmCTest.cxx | 9 ++- Source/cmCacheManager.cxx | 7 +- Source/cmComputeLinkInformation.cxx | 4 +- Source/cmConditionEvaluator.cxx | 10 +-- Source/cmCoreTryCompile.cxx | 3 +- Source/cmCryptoHash.cxx | 37 +++++----- Source/cmCryptoHash.h | 10 +-- Source/cmExtraCodeBlocksGenerator.cxx | 4 +- Source/cmExtraSublimeTextGenerator.cxx | 2 +- Source/cmFileCommand.cxx | 13 ++-- Source/cmFileInstaller.cxx | 3 +- Source/cmFindBase.cxx | 2 +- Source/cmFindCommon.cxx | 2 +- Source/cmFindPackageCommand.cxx | 9 ++- Source/cmGeneratorExpressionNode.cxx | 2 +- Source/cmGeneratorTarget.cxx | 19 +++--- Source/cmGetFilenameComponentCommand.cxx | 2 +- Source/cmGhsMultiTargetGenerator.cxx | 9 +-- Source/cmGlobalGenerator.cxx | 37 +++++----- Source/cmGlobalGhsMultiGenerator.cxx | 17 ++--- Source/cmGlobalUnixMakefileGenerator3.cxx | 19 ++---- Source/cmGlobalVisualStudio10Generator.cxx | 3 +- Source/cmGlobalVisualStudio7Generator.cxx | 5 +- Source/cmGlobalVisualStudio8Generator.cxx | 2 +- Source/cmGlobalVisualStudioGenerator.cxx | 2 +- Source/cmGlobalXCodeGenerator.cxx | 13 ++-- Source/cmIncludeDirectoryCommand.cxx | 3 +- Source/cmInstallExportGenerator.cxx | 3 +- Source/cmInstallTargetGenerator.cxx | 3 +- Source/cmInstalledFile.cxx | 3 +- Source/cmLinkLineDeviceComputer.cxx | 5 +- Source/cmLocalGenerator.cxx | 13 ++-- Source/cmLocalUnixMakefileGenerator3.cxx | 21 +++--- Source/cmLocalVisualStudio7Generator.cxx | 6 +- Source/cmMakefile.cxx | 17 +++-- Source/cmMakefileExecutableTargetGenerator.cxx | 11 ++- Source/cmMakefileLibraryTargetGenerator.cxx | 13 ++-- Source/cmMakefileTargetGenerator.cxx | 8 +-- Source/cmNinjaUtilityTargetGenerator.cxx | 3 +- Source/cmOptionCommand.cxx | 3 +- Source/cmQtAutoGenGlobalInitializer.cxx | 6 +- Source/cmQtAutoGenInitializer.cxx | 11 ++- Source/cmQtAutoGenerator.cxx | 4 +- Source/cmSetPropertyCommand.cxx | 5 +- Source/cmSetSourceFilesPropertiesCommand.cxx | 4 +- Source/cmSiteNameCommand.cxx | 3 +- Source/cmSourceFile.cxx | 5 +- Source/cmState.cxx | 2 +- Source/cmStateDirectory.cxx | 2 +- Source/cmStateSnapshot.cxx | 2 +- Source/cmStringAlgorithms.cxx | 79 ++++++++++++++++++++++ Source/cmStringAlgorithms.h | 45 ++++++++++++ Source/cmStringCommand.cxx | 2 +- Source/cmSystemTools.cxx | 79 ---------------------- Source/cmSystemTools.h | 44 ------------ Source/cmTarget.cxx | 4 +- Source/cmTest.cxx | 4 +- Source/cmTryRunCommand.cxx | 3 +- Source/cmVisualStudio10TargetGenerator.cxx | 20 +++--- Source/cmake.cxx | 22 +++--- Source/cmcmd.cxx | 7 +- 81 files changed, 380 insertions(+), 433 deletions(-) hooks/post-receive -- CMake From kwrobot at kitware.com Tue Aug 20 00:02:14 2019 From: kwrobot at kitware.com (Kitware Robot) Date: Tue, 20 Aug 2019 00:02:14 -0400 (EDT) Subject: [Cmake-commits] CMake branch, master, updated. v3.15.2-676-g6cf8883 Message-ID: <20190820040214.8C29E10308D@public.kitware.com> This is an automated email from the git hooks/post-receive script. It was generated because a ref change was pushed to the repository containing the project "CMake". The branch, master has been updated via 6cf8883a8577514dac3774b7cc9251fe90fa85d7 (commit) from e3746821dfc37c8514c934e1e5d62d0ec99adc9f (commit) Those revisions listed above that are new to this repository have not appeared on any other notification email; so we list those revisions in full, below. - Log ----------------------------------------------------------------- https://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=6cf8883a8577514dac3774b7cc9251fe90fa85d7 commit 6cf8883a8577514dac3774b7cc9251fe90fa85d7 Author: Kitware Robot AuthorDate: Tue Aug 20 00:00:20 2019 -0400 Commit: Kitware Robot CommitDate: Tue Aug 20 00:00:20 2019 -0400 CMake Nightly Date Stamp diff --git a/Source/CMakeVersion.cmake b/Source/CMakeVersion.cmake index 9a76073..05e2f7b 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 15) -set(CMake_VERSION_PATCH 20190819) +set(CMake_VERSION_PATCH 20190820) #set(CMake_VERSION_RC 0) set(CMake_VERSION_IS_DIRTY 0) ----------------------------------------------------------------------- Summary of changes: Source/CMakeVersion.cmake | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) hooks/post-receive -- CMake From kwrobot at kitware.com Tue Aug 20 09:02:02 2019 From: kwrobot at kitware.com (Kitware Robot) Date: Tue, 20 Aug 2019 09:02:02 -0400 (EDT) Subject: [Cmake-commits] CMake branch, release, updated. v3.15.2-4-gfeec57e Message-ID: <20190820130202.3CA4711E2B1@public.kitware.com> This is an automated email from the git hooks/post-receive script. It was generated because a ref change was pushed to the repository containing the project "CMake". The branch, release has been updated via feec57e8001a2116434f48bb9628c100cd3b2c1a (commit) via 154c5f794980605fd9456d794650c6e49635a177 (commit) from ff7f8b81d14f306374346e56af38f19e03ff93ee (commit) Those revisions listed above that are new to this repository have not appeared on any other notification email; so we list those revisions in full, below. - Log ----------------------------------------------------------------- ----------------------------------------------------------------------- Summary of changes: Source/CursesDialog/cmCursesOptionsWidget.cxx | 3 +++ 1 file changed, 3 insertions(+) hooks/post-receive -- CMake From kwrobot at kitware.com Tue Aug 20 09:02:02 2019 From: kwrobot at kitware.com (Kitware Robot) Date: Tue, 20 Aug 2019 09:02:02 -0400 (EDT) Subject: [Cmake-commits] CMake branch, master, updated. v3.15.2-680-g3d840ac Message-ID: <20190820130202.1111711D6EC@public.kitware.com> This is an automated email from the git hooks/post-receive script. It was generated because a ref change was pushed to the repository containing the project "CMake". The branch, master has been updated via 3d840ac939cc062203b8908b5144d45768ba041c (commit) via 4aff5a0ffa71854f078b39451f097ddf7e7a878a (commit) via feec57e8001a2116434f48bb9628c100cd3b2c1a (commit) via 154c5f794980605fd9456d794650c6e49635a177 (commit) from 6cf8883a8577514dac3774b7cc9251fe90fa85d7 (commit) Those revisions listed above that are new to this repository have not appeared on any other notification email; so we list those revisions in full, below. - Log ----------------------------------------------------------------- https://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=3d840ac939cc062203b8908b5144d45768ba041c commit 3d840ac939cc062203b8908b5144d45768ba041c Merge: 4aff5a0 feec57e Author: Brad King AuthorDate: Tue Aug 20 08:58:19 2019 -0400 Commit: Brad King CommitDate: Tue Aug 20 08:58:19 2019 -0400 Merge branch 'release-3.15' https://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=4aff5a0ffa71854f078b39451f097ddf7e7a878a commit 4aff5a0ffa71854f078b39451f097ddf7e7a878a Merge: 6cf8883 154c5f7 Author: Brad King AuthorDate: Tue Aug 20 12:57:28 2019 +0000 Commit: Kitware Robot CommitDate: Tue Aug 20 08:57:37 2019 -0400 Merge topic 'ccmake-crash-on-empty-strings-property' 154c5f7949 ccmake: handle cache entries with empty STRINGS property Acked-by: Kitware Robot Merge-request: !3678 ----------------------------------------------------------------------- Summary of changes: Source/CursesDialog/cmCursesOptionsWidget.cxx | 3 +++ 1 file changed, 3 insertions(+) hooks/post-receive -- CMake From kwrobot at kitware.com Tue Aug 20 09:22:00 2019 From: kwrobot at kitware.com (Kitware Robot) Date: Tue, 20 Aug 2019 09:22:00 -0400 (EDT) Subject: [Cmake-commits] CMake branch, master, updated. v3.15.2-697-ga0c8405 Message-ID: <20190820132200.B41691C6A@public.kitware.com> This is an automated email from the git hooks/post-receive script. It was generated because a ref change was pushed to the repository containing the project "CMake". The branch, master has been updated via a0c8405d681d504f5d96489c2b5d44f10a29c6ed (commit) via b80417f0fd1491d1c0f5d57019b47d4c13729545 (commit) via 8c1d3e3b79fb921bfada3b19e6bb4115da4a4e6e (commit) via 7432297ca081dbac34f939298db020c2ea4e2b32 (commit) via f4fc0667ae406c8f6b4c3e22a73ae4a7a075404b (commit) via 6f6a32a0f601688da24e1737509a0b6e1ed4f63f (commit) via 6a35d630dce6e9da6115cc4acb3393ce62a017ad (commit) via 61d4d990d620815fac62ccbb28cf522703dde923 (commit) via a36731c63460a41caae596b6dcbc75771a810549 (commit) via df9cdf629c5211282dcab2e4751f69032e25a244 (commit) via 442c0f0d463d8f08a6c47b371cdb13a9ec4cea41 (commit) via bc64401c3d9355f3c8fd6a205b8ef9d24a795204 (commit) via 49ce4d6ff4e70026ab1da6da91d7965ef61863ab (commit) via 82332f81bbb0609bf521d29c36b3ecf1566be892 (commit) via d56a4b16ca6f09d099c2ec832b11708f9b4b9819 (commit) via 3c94069660112f841df3bae66891e05bfc7bad00 (commit) via 9460501ad7353e6eecdf42d56568c1f909f64e27 (commit) from 3d840ac939cc062203b8908b5144d45768ba041c (commit) Those revisions listed above that are new to this repository have not appeared on any other notification email; so we list those revisions in full, below. - Log ----------------------------------------------------------------- https://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=a0c8405d681d504f5d96489c2b5d44f10a29c6ed commit a0c8405d681d504f5d96489c2b5d44f10a29c6ed Merge: b80417f 3c94069 Author: Brad King AuthorDate: Tue Aug 20 13:18:41 2019 +0000 Commit: Kitware Robot CommitDate: Tue Aug 20 09:20:49 2019 -0400 Merge topic 'trace-redirect' 3c94069660 Add --trace-redirect parameter to redirect trace output to a file Acked-by: Kitware Robot Merge-request: !3645 https://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=b80417f0fd1491d1c0f5d57019b47d4c13729545 commit b80417f0fd1491d1c0f5d57019b47d4c13729545 Merge: 8c1d3e3 6f6a32a Author: Brad King AuthorDate: Tue Aug 20 13:16:35 2019 +0000 Commit: Kitware Robot CommitDate: Tue Aug 20 09:19:22 2019 -0400 Merge topic 'cmake-tutorial' 6f6a32a0f6 Tutorial: Improve Step 9 6a35d630dc Tutorial: Improve Step 8 61d4d990d6 Tutorial: Improve Step 7 a36731c634 Tutorial: Improve Step 6 df9cdf629c Tutorial: Improve Step 5 442c0f0d46 Tutorial: Improve Step 4 bc64401c3d Tutorial: Improve Step 3 49ce4d6ff4 Tutorial: Improve Step 2 ... Acked-by: Kitware Robot Merge-request: !3528 https://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=8c1d3e3b79fb921bfada3b19e6bb4115da4a4e6e commit 8c1d3e3b79fb921bfada3b19e6bb4115da4a4e6e Merge: 7432297 f4fc066 Author: Brad King AuthorDate: Tue Aug 20 13:15:32 2019 +0000 Commit: Kitware Robot CommitDate: Tue Aug 20 09:17:18 2019 -0400 Merge topic 'find_openacc_targets' f4fc0667ae FindOpenACC: Provide import targets and OpenACC__OPTIONS variable 9460501ad7 FindOpenACC: Provide a Fortran snippet that compiles with gfortran Acked-by: Kitware Robot Merge-request: !3670 https://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=7432297ca081dbac34f939298db020c2ea4e2b32 commit 7432297ca081dbac34f939298db020c2ea4e2b32 Merge: 3d840ac d56a4b1 Author: Brad King AuthorDate: Tue Aug 20 13:15:16 2019 +0000 Commit: Kitware Robot CommitDate: Tue Aug 20 09:15:36 2019 -0400 Merge topic 'help-full' d56a4b16ca Help: Restore installation of top-level index Acked-by: Kitware Robot Merge-request: !3701 https://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=f4fc0667ae406c8f6b4c3e22a73ae4a7a075404b commit f4fc0667ae406c8f6b4c3e22a73ae4a7a075404b Author: Robert Maynard AuthorDate: Tue Jul 30 11:01:57 2019 -0400 Commit: Brad King CommitDate: Mon Aug 19 15:20:38 2019 -0400 FindOpenACC: Provide import targets and OpenACC__OPTIONS variable Previously the FindOpenACC module had issues where the contents of OpenACC__FLAGS could not be used with target_compile_options when it contained multiple compiler flags. diff --git a/Modules/FindOpenACC.cmake b/Modules/FindOpenACC.cmake index 1f0238e..743e0e2 100644 --- a/Modules/FindOpenACC.cmake +++ b/Modules/FindOpenACC.cmake @@ -22,6 +22,14 @@ project, where ```` is one of C, CXX, or Fortran: Variable indicating if OpenACC support for ```` was detected. ``OpenACC__FLAGS`` OpenACC compiler flags for ````, separated by spaces. +``OpenACC__OPTIONS`` + OpenACC compiler flags for ````, as a list. Suitable for usage + with target_compile_options or target_link_options. + +Additionally, the module provides :prop_tgt:`IMPORTED` targets: + +``OpenACC::OpenACC_`` + Target for using OpenACC from ````. The module will also try to provide the OpenACC version variables: @@ -239,6 +247,9 @@ foreach (LANG IN ITEMS C CXX Fortran) if(NOT DEFINED OpenACC_${LANG}_FLAGS) _OPENACC_GET_FLAGS("${LANG}" OpenACC_${LANG}_FLAGS) endif() + if(NOT DEFINED OpenACC_${LANG}_OPTIONS) + separate_arguments(OpenACC_${LANG}_OPTIONS NATIVE_COMMAND "${OpenACC_${LANG}_FLAGS}") + endif() _OPENACC_GET_SPEC_DATE("${LANG}" OpenACC_${LANG}_SPEC_DATE) _OPENACC_SET_VERSION_BY_SPEC_DATE("${LANG}") @@ -249,6 +260,23 @@ foreach (LANG IN ITEMS C CXX Fortran) endif() endforeach() +foreach (LANG IN ITEMS C CXX Fortran) + if(OpenACC_${LANG}_FOUND AND NOT TARGET OpenACC::OpenACC_${LANG}) + add_library(OpenACC::OpenACC_${LANG} INTERFACE IMPORTED) + endif() + if(OpenACC_${LANG}_LIBRARIES) + set_property(TARGET OpenACC::OpenACC_${LANG} PROPERTY + INTERFACE_LINK_LIBRARIES "${OpenACC_${LANG}_LIBRARIES}") + endif() + if(OpenACC_${LANG}_FLAGS) + set_property(TARGET OpenACC::OpenACC_${LANG} PROPERTY + INTERFACE_COMPILE_OPTIONS "$<$:${OpenACC_${LANG}_OPTIONS}>") + set_property(TARGET OpenACC::OpenACC_${LANG} PROPERTY + INTERFACE_LINK_OPTIONS "$<$:${OpenACC_${LANG}_OPTIONS}>") + unset(_OpenACC_${LANG}_OPTIONS) + endif() +endforeach() + unset(OpenACC_C_CXX_TEST_SOURCE) unset(OpenACC_Fortran_TEST_SOURCE) unset(OpenACC_C_CXX_CHECK_VERSION_SOURCE) diff --git a/Tests/CMakeLists.txt b/Tests/CMakeLists.txt index 5b8f255..febcd7a 100644 --- a/Tests/CMakeLists.txt +++ b/Tests/CMakeLists.txt @@ -1409,6 +1409,7 @@ ${CMake_SOURCE_DIR}/Utilities/Release/push.bash --dir dev -- '${CMake_BUILD_NIGH LibXml2 LTTngUST ODBC + OpenACC OpenCL OpenGL OpenMP diff --git a/Tests/FindOpenACC/CMakeLists.txt b/Tests/FindOpenACC/CMakeLists.txt new file mode 100644 index 0000000..ef7de65 --- /dev/null +++ b/Tests/FindOpenACC/CMakeLists.txt @@ -0,0 +1,20 @@ + +set(langs C CXX) +if(NOT CMAKE_GENERATOR STREQUAL "Ninja") + list(APPEND langs Fortran) +endif() + +foreach(lang IN LISTS langs) + if(CMAKE_${lang}_COMPILER) + add_test(NAME FindOpenACC.Test${lang} COMMAND + ${CMAKE_CTEST_COMMAND} -C $ + --build-and-test + "${CMake_SOURCE_DIR}/Tests/FindOpenACC/${lang}Test" + "${CMake_BINARY_DIR}/Tests/FindOpenACC/${lang}Test" + ${build_generator_args} + --build-project TestFindOpenACC + --build-options ${build_options} + --test-command ${CMAKE_CTEST_COMMAND} -V -C $ + ) + endif() +endforeach() diff --git a/Tests/FindOpenACC/CTest/CMakeLists.txt b/Tests/FindOpenACC/CTest/CMakeLists.txt new file mode 100644 index 0000000..c8d0968 --- /dev/null +++ b/Tests/FindOpenACC/CTest/CMakeLists.txt @@ -0,0 +1,13 @@ +cmake_minimum_required(VERSION 3.14) +project(VerifyFindOpenAcc C) + +set(CMAKE_C_STANDARD 11) + +find_package(OpenACC REQUIRED) + +add_executable(UsesOpenACC main.c) +target_link_libraries(UsesOpenACC PRIVATE OpenACC::OpenACC_C) + +add_executable(UsesOpenACCVars main.c) +target_link_options(UsesOpenACCVars PRIVATE ${OpenACC_C_OPTIONS}) +target_compile_options(UsesOpenACCVars PRIVATE ${OpenACC_C_OPTIONS}) diff --git a/Tests/FindOpenACC/CTest/main.c b/Tests/FindOpenACC/CTest/main.c new file mode 100644 index 0000000..53b6cae --- /dev/null +++ b/Tests/FindOpenACC/CTest/main.c @@ -0,0 +1,44 @@ +#include +#include + +void vecaddgpu(float* r, float* a, float* b, int n) +{ +#pragma acc kernels loop present(r, a, b) + for (int i = 0; i < n; ++i) + r[i] = a[i] + b[i]; +} + +int main() +{ + int n = 100000; /* vector length */ + float* a; /* input vector 1 */ + float* b; /* input vector 2 */ + float* r; /* output vector */ + float* e; /* expected output values */ + int i, errs; + + a = (float*)malloc(n * sizeof(float)); + b = (float*)malloc(n * sizeof(float)); + r = (float*)malloc(n * sizeof(float)); + e = (float*)malloc(n * sizeof(float)); + for (i = 0; i < n; ++i) { + a[i] = (float)(i + 1); + b[i] = (float)(1000 * i); + } +/* compute on the GPU */ +#pragma acc data copyin(a [0:n], b [0:n]) copyout(r [0:n]) + { + vecaddgpu(r, a, b, n); + } + /* compute on the host to compare */ + for (i = 0; i < n; ++i) + e[i] = a[i] + b[i]; + /* compare results */ + errs = 0; + for (i = 0; i < n; ++i) { + if (r[i] != e[i]) { + ++errs; + } + } + return errs; +} diff --git a/Tests/FindOpenACC/CXXTest/CMakeLists.txt b/Tests/FindOpenACC/CXXTest/CMakeLists.txt new file mode 100644 index 0000000..a6caf7b --- /dev/null +++ b/Tests/FindOpenACC/CXXTest/CMakeLists.txt @@ -0,0 +1,13 @@ +cmake_minimum_required(VERSION 3.14) +project(VerifyFindOpenAcc CXX) + +set(CMAKE_CXX_STANDARD 11) + +find_package(OpenACC REQUIRED) + +add_executable(UsesOpenACC main.cxx) +target_link_libraries(UsesOpenACC PRIVATE OpenACC::OpenACC_CXX) + +add_executable(UsesOpenACCVars main.cxx) +target_link_options(UsesOpenACCVars PRIVATE ${OpenACC_CXX_OPTIONS}) +target_compile_options(UsesOpenACCVars PRIVATE ${OpenACC_CXX_OPTIONS}) diff --git a/Tests/FindOpenACC/CXXTest/main.cxx b/Tests/FindOpenACC/CXXTest/main.cxx new file mode 100644 index 0000000..7369045 --- /dev/null +++ b/Tests/FindOpenACC/CXXTest/main.cxx @@ -0,0 +1,43 @@ + +#include + +void vecaddgpu(float* r, float* a, float* b, std::size_t n) +{ +#pragma acc kernels loop present(r, a, b) + for (std::size_t i = 0; i < n; ++i) + r[i] = a[i] + b[i]; +} + +int main(int, char* []) +{ + const std::size_t n = 100000; /* vector length */ + std::vector a(n); /* input vector 1 */ + std::vector b(n); /* input vector 2 */ + std::vector r(n); /* output vector */ + std::vector e(n); /* expected output values */ + + for (std::size_t i = 0; i < n; ++i) { + a[i] = static_cast(i + 1); + b[i] = static_cast(1000 * i); + } + + /* compute on the GPU */ + auto a_ptr = a.data(); + auto b_ptr = b.data(); + auto r_ptr = r.data(); +#pragma acc data copyin(a_ptr [0:n], b_ptr [0:n]) copyout(r_ptr [0:n]) + { + vecaddgpu(r_ptr, a_ptr, b_ptr, n); + } + /* compute on the host to compare */ + for (std::size_t i = 0; i < n; ++i) + e[i] = a[i] + b[i]; + /* compare results */ + int errs = 0; + for (std::size_t i = 0; i < n; ++i) { + if (r[i] != e[i]) { + ++errs; + } + } + return errs; +} diff --git a/Tests/FindOpenACC/FortranTest/CMakeLists.txt b/Tests/FindOpenACC/FortranTest/CMakeLists.txt new file mode 100644 index 0000000..12e3503 --- /dev/null +++ b/Tests/FindOpenACC/FortranTest/CMakeLists.txt @@ -0,0 +1,11 @@ +cmake_minimum_required(VERSION 3.14) +project(VerifyFindOpenAcc Fortran) + +find_package(OpenACC REQUIRED) + +add_executable(UsesOpenACC main.f90) +target_link_libraries(UsesOpenACC PRIVATE OpenACC::OpenACC_Fortran) + +add_executable(UsesOpenACCVars main.f90) +target_link_options(UsesOpenACCVars PRIVATE ${OpenACC_Fortran_OPTIONS}) +target_compile_options(UsesOpenACCVars PRIVATE ${OpenACC_Fortran_OPTIONS}) diff --git a/Tests/FindOpenACC/FortranTest/main.f90 b/Tests/FindOpenACC/FortranTest/main.f90 new file mode 100644 index 0000000..2ff1ba0 --- /dev/null +++ b/Tests/FindOpenACC/FortranTest/main.f90 @@ -0,0 +1,9 @@ +program t +integer(4) a(10000) +a = [ (1+i,i=1,10000) ] +!$acc kernels +do i = 1, 10000 + if (a(i)/3000*3000.eq.a(i)) print *," located ",i,a(i),i.gt.5000,a(i)/5.0 +end do +!$acc end kernels +end https://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=6f6a32a0f601688da24e1737509a0b6e1ed4f63f commit 6f6a32a0f601688da24e1737509a0b6e1ed4f63f Author: Betsy McPhail AuthorDate: Thu Jul 18 15:40:25 2019 -0400 Commit: Brad King CommitDate: Mon Aug 19 11:49:05 2019 -0400 Tutorial: Improve Step 9 * Move USE_MYMATH from configured header to target_compile_definitions diff --git a/Help/guide/tutorial/Complete/MathFunctions/CMakeLists.txt b/Help/guide/tutorial/Complete/MathFunctions/CMakeLists.txt index 3dbf287..dfa84c9 100644 --- a/Help/guide/tutorial/Complete/MathFunctions/CMakeLists.txt +++ b/Help/guide/tutorial/Complete/MathFunctions/CMakeLists.txt @@ -13,6 +13,8 @@ target_include_directories(MathFunctions option(USE_MYMATH "Use tutorial provided math implementation" ON) if(USE_MYMATH) + target_compile_definitions(MathFunctions PRIVATE "USE_MYMATH") + # first we add the executable that generates the table add_executable(MakeTable MakeTable.cxx) target_link_libraries(MakeTable tutorial_compiler_flags) @@ -35,14 +37,12 @@ if(USE_MYMATH) ${CMAKE_CURRENT_BINARY_DIR} ) + # state that SqrtLibrary need PIC when the default is shared libraries set_target_properties(SqrtLibrary PROPERTIES POSITION_INDEPENDENT_CODE ${BUILD_SHARED_LIBS} ) target_link_libraries(SqrtLibrary PUBLIC tutorial_compiler_flags) - - - target_compile_definitions(MathFunctions PRIVATE "USE_MYMATH") target_link_libraries(MathFunctions PRIVATE SqrtLibrary) endif() diff --git a/Help/guide/tutorial/MultiPackage/MathFunctions/CMakeLists.txt b/Help/guide/tutorial/MultiPackage/MathFunctions/CMakeLists.txt index 483e20c..a2df2a7 100644 --- a/Help/guide/tutorial/MultiPackage/MathFunctions/CMakeLists.txt +++ b/Help/guide/tutorial/MultiPackage/MathFunctions/CMakeLists.txt @@ -13,6 +13,8 @@ target_include_directories(MathFunctions option(USE_MYMATH "Use tutorial provided math implementation" ON) if(USE_MYMATH) + target_compile_definitions(MathFunctions PRIVATE "USE_MYMATH") + # first we add the executable that generates the table add_executable(MakeTable MakeTable.cxx) @@ -34,6 +36,7 @@ if(USE_MYMATH) ${CMAKE_CURRENT_BINARY_DIR} ) + # state that SqrtLibrary need PIC when the default is shared libraries set_target_properties(SqrtLibrary PROPERTIES POSITION_INDEPENDENT_CODE ${BUILD_SHARED_LIBS} ) @@ -41,8 +44,6 @@ if(USE_MYMATH) target_link_libraries(MathFunctions PRIVATE SqrtLibrary) endif() -target_compile_definitions(MathFunctions PRIVATE "$<$:USE_MYMATH>") - # define the symbol stating we are using the declspec(dllexport) when # building on windows target_compile_definitions(MathFunctions PRIVATE "EXPORTING_MYMATH") diff --git a/Help/guide/tutorial/MultiPackage/tutorial.cxx b/Help/guide/tutorial/MultiPackage/tutorial.cxx index ddc6364..f97805b 100644 --- a/Help/guide/tutorial/MultiPackage/tutorial.cxx +++ b/Help/guide/tutorial/MultiPackage/tutorial.cxx @@ -1,6 +1,5 @@ // A simple program that computes the square root of a number #include -#include #include #include "MathFunctions.h" diff --git a/Help/guide/tutorial/Step10/MathFunctions/CMakeLists.txt b/Help/guide/tutorial/Step10/MathFunctions/CMakeLists.txt index 57555d3..e0c0621 100644 --- a/Help/guide/tutorial/Step10/MathFunctions/CMakeLists.txt +++ b/Help/guide/tutorial/Step10/MathFunctions/CMakeLists.txt @@ -11,6 +11,8 @@ target_include_directories(MathFunctions option(USE_MYMATH "Use tutorial provided math implementation" ON) if(USE_MYMATH) + target_compile_definitions(MathFunctions PRIVATE "USE_MYMATH") + # first we add the executable that generates the table add_executable(MakeTable MakeTable.cxx) @@ -37,8 +39,6 @@ if(USE_MYMATH) POSITION_INDEPENDENT_CODE ${BUILD_SHARED_LIBS} ) - target_compile_definitions(MathFunctions PRIVATE "USE_MYMATH") - target_link_libraries(MathFunctions PRIVATE SqrtLibrary) endif() diff --git a/Help/guide/tutorial/Step11/MathFunctions/CMakeLists.txt b/Help/guide/tutorial/Step11/MathFunctions/CMakeLists.txt index df9f4df..e6cb8ba 100644 --- a/Help/guide/tutorial/Step11/MathFunctions/CMakeLists.txt +++ b/Help/guide/tutorial/Step11/MathFunctions/CMakeLists.txt @@ -11,6 +11,8 @@ target_include_directories(MathFunctions option(USE_MYMATH "Use tutorial provided math implementation" ON) if(USE_MYMATH) + target_compile_definitions(MathFunctions PRIVATE "USE_MYMATH") + # first we add the executable that generates the table add_executable(MakeTable MakeTable.cxx) target_link_libraries(MakeTable tutorial_compiler_flags) @@ -33,13 +35,12 @@ if(USE_MYMATH) ${CMAKE_CURRENT_BINARY_DIR} ) + # state that SqrtLibrary need PIC when the default is shared libraries set_target_properties(SqrtLibrary PROPERTIES POSITION_INDEPENDENT_CODE ${BUILD_SHARED_LIBS} ) target_link_libraries(SqrtLibrary PUBLIC tutorial_compiler_flags) - - target_compile_definitions(MathFunctions PRIVATE "USE_MYMATH") target_link_libraries(MathFunctions PRIVATE SqrtLibrary) endif() diff --git a/Help/guide/tutorial/Step11/tutorial.cxx b/Help/guide/tutorial/Step11/tutorial.cxx index a3a2bdc..a4f44d5 100644 --- a/Help/guide/tutorial/Step11/tutorial.cxx +++ b/Help/guide/tutorial/Step11/tutorial.cxx @@ -1,5 +1,4 @@ // A simple program that computes the square root of a number -#include #include #include diff --git a/Help/guide/tutorial/Step9/CMakeLists.txt b/Help/guide/tutorial/Step9/CMakeLists.txt index f437053..d5f1cc8 100644 --- a/Help/guide/tutorial/Step9/CMakeLists.txt +++ b/Help/guide/tutorial/Step9/CMakeLists.txt @@ -10,7 +10,8 @@ set(CMAKE_CXX_STANDARD_REQUIRED True) # should we use our own math functions option(USE_MYMATH "Use tutorial provided math implementation" ON) -# configure a header file to pass the version number only +# configure a header file to pass some of the CMake settings +# to the source code configure_file(TutorialConfig.h.in TutorialConfig.h) # add the MathFunctions library diff --git a/Help/guide/tutorial/Step9/MathFunctions/CMakeLists.txt b/Help/guide/tutorial/Step9/MathFunctions/CMakeLists.txt index b40b464..50f0701 100644 --- a/Help/guide/tutorial/Step9/MathFunctions/CMakeLists.txt +++ b/Help/guide/tutorial/Step9/MathFunctions/CMakeLists.txt @@ -22,10 +22,6 @@ target_include_directories(MathFunctions PRIVATE ${CMAKE_CURRENT_BINARY_DIR} ) -# use compile definitions to state if we have enabled USE_MYMATH -# and that anything that links to use will get this define -target_compile_definitions(MathFunctions INTERFACE "USE_MYMATH") - # install rules install(TARGETS MathFunctions DESTINATION lib) install(FILES MathFunctions.h DESTINATION include) diff --git a/Help/guide/tutorial/Step9/TutorialConfig.h.in b/Help/guide/tutorial/Step9/TutorialConfig.h.in index 8cd2fc9..e23f521 100644 --- a/Help/guide/tutorial/Step9/TutorialConfig.h.in +++ b/Help/guide/tutorial/Step9/TutorialConfig.h.in @@ -1,3 +1,4 @@ -// the configured version number +// the configured options and settings for Tutorial #define Tutorial_VERSION_MAJOR @Tutorial_VERSION_MAJOR@ #define Tutorial_VERSION_MINOR @Tutorial_VERSION_MINOR@ +#cmakedefine USE_MYMATH diff --git a/Help/guide/tutorial/Step9/tutorial.cxx b/Help/guide/tutorial/Step9/tutorial.cxx index 779fbca..b3c6a4f 100644 --- a/Help/guide/tutorial/Step9/tutorial.cxx +++ b/Help/guide/tutorial/Step9/tutorial.cxx @@ -1,7 +1,6 @@ // A simple program that computes the square root of a number #include #include -#include #include #include "TutorialConfig.h" diff --git a/Help/guide/tutorial/index.rst b/Help/guide/tutorial/index.rst index f6fd580..d858c25 100644 --- a/Help/guide/tutorial/index.rst +++ b/Help/guide/tutorial/index.rst @@ -645,7 +645,6 @@ The first step is to update the starting section of the top-level .. literalinclude:: Step10/CMakeLists.txt :language: cmake - :start-after: set(CMAKE_CXX_STANDARD 14) :end-before: # add the binary tree Now that we have made MathFunctions always be used, we will need to update @@ -658,7 +657,7 @@ The end result is that ``MathFunctions/CMakeLists.txt`` should look like: .. literalinclude:: Step10/MathFunctions/CMakeLists.txt :language: cmake - :lines: 1-40,46- + :lines: 1-36,42- Next, update ``MathFunctions/mysqrt.cxx`` to use the ``mathfunctions`` and ``detail`` namespaces: @@ -671,6 +670,7 @@ uses ``USE_MYMATH``: #. Always include ``MathFunctions.h`` #. Always use ``mathfunctions::sqrt`` +#. Don't include cmath Finally, update ``MathFunctions/MathFunctions.h`` to use dll export defines: @@ -683,9 +683,14 @@ library that has position enabled code. The solution to this is to explicitly set the ``POSITION_INDEPENDENT_CODE`` target property of SqrtLibrary to be True no matter the build type. +.. literalinclude:: Step10/MathFunctions/CMakeLists.txt + :language: cmake + :lines: 37-42 + **Exercise**: We modified ``MathFunctions.h`` to use dll export defines. Using CMake documentation can you find a helper module to simplify this? + Adding Generator Expressions (Step 10) ====================================== https://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=6a35d630dce6e9da6115cc4acb3393ce62a017ad commit 6a35d630dce6e9da6115cc4acb3393ce62a017ad Author: Betsy McPhail AuthorDate: Thu Jul 18 15:40:25 2019 -0400 Commit: Brad King CommitDate: Mon Aug 19 11:49:05 2019 -0400 Tutorial: Improve Step 8 * Remove comments from CTestConfig.cmake * Update directions diff --git a/Help/guide/tutorial/Complete/CTestConfig.cmake b/Help/guide/tutorial/Complete/CTestConfig.cmake new file mode 100644 index 0000000..73efdb1 --- /dev/null +++ b/Help/guide/tutorial/Complete/CTestConfig.cmake @@ -0,0 +1,7 @@ +set(CTEST_PROJECT_NAME "CMakeTutorial") +set(CTEST_NIGHTLY_START_TIME "00:00:00 EST") + +set(CTEST_DROP_METHOD "http") +set(CTEST_DROP_SITE "my.cdash.org") +set(CTEST_DROP_LOCATION "/submit.php?project=CMakeTutorial") +set(CTEST_DROP_SITE_CDASH TRUE) diff --git a/Help/guide/tutorial/Step10/CMakeLists.txt b/Help/guide/tutorial/Step10/CMakeLists.txt index 6a59104..34ae70c 100644 --- a/Help/guide/tutorial/Step10/CMakeLists.txt +++ b/Help/guide/tutorial/Step10/CMakeLists.txt @@ -38,7 +38,7 @@ install(FILES "${PROJECT_BINARY_DIR}/TutorialConfig.h" ) # enable testing -enable_testing() +include(CTest) # does the application run add_test(NAME Runs COMMAND Tutorial 25) diff --git a/Help/guide/tutorial/Step10/CTestConfig.cmake b/Help/guide/tutorial/Step10/CTestConfig.cmake new file mode 100644 index 0000000..73efdb1 --- /dev/null +++ b/Help/guide/tutorial/Step10/CTestConfig.cmake @@ -0,0 +1,7 @@ +set(CTEST_PROJECT_NAME "CMakeTutorial") +set(CTEST_NIGHTLY_START_TIME "00:00:00 EST") + +set(CTEST_DROP_METHOD "http") +set(CTEST_DROP_SITE "my.cdash.org") +set(CTEST_DROP_LOCATION "/submit.php?project=CMakeTutorial") +set(CTEST_DROP_SITE_CDASH TRUE) diff --git a/Help/guide/tutorial/Step11/CTestConfig.cmake b/Help/guide/tutorial/Step11/CTestConfig.cmake new file mode 100644 index 0000000..73efdb1 --- /dev/null +++ b/Help/guide/tutorial/Step11/CTestConfig.cmake @@ -0,0 +1,7 @@ +set(CTEST_PROJECT_NAME "CMakeTutorial") +set(CTEST_NIGHTLY_START_TIME "00:00:00 EST") + +set(CTEST_DROP_METHOD "http") +set(CTEST_DROP_SITE "my.cdash.org") +set(CTEST_DROP_LOCATION "/submit.php?project=CMakeTutorial") +set(CTEST_DROP_SITE_CDASH TRUE) diff --git a/Help/guide/tutorial/Step8/CMakeLists.txt b/Help/guide/tutorial/Step8/CMakeLists.txt index 2859049..19b9913 100644 --- a/Help/guide/tutorial/Step8/CMakeLists.txt +++ b/Help/guide/tutorial/Step8/CMakeLists.txt @@ -50,7 +50,7 @@ set_tests_properties(Usage # define a function to simplify adding tests function(do_test target arg result) -add_test(NAME Comp${arg} COMMAND ${target} ${arg}) + add_test(NAME Comp${arg} COMMAND ${target} ${arg}) set_tests_properties(Comp${arg} PROPERTIES PASS_REGULAR_EXPRESSION ${result} ) diff --git a/Help/guide/tutorial/Step9/CTestConfig.cmake b/Help/guide/tutorial/Step9/CTestConfig.cmake index 7a927ac..73efdb1 100644 --- a/Help/guide/tutorial/Step9/CTestConfig.cmake +++ b/Help/guide/tutorial/Step9/CTestConfig.cmake @@ -1,11 +1,3 @@ -## This file should be placed in the root directory of your project. -## Then modify the CMakeLists.txt file in the root directory of your -## project to incorporate the testing dashboard. -## -## # The following are required to submit to the CDash dashboard: -## ENABLE_TESTING() -## INCLUDE(CTest) - set(CTEST_PROJECT_NAME "CMakeTutorial") set(CTEST_NIGHTLY_START_TIME "00:00:00 EST") diff --git a/Help/guide/tutorial/index.rst b/Help/guide/tutorial/index.rst index 22f3527..f6fd580 100644 --- a/Help/guide/tutorial/index.rst +++ b/Help/guide/tutorial/index.rst @@ -578,10 +578,9 @@ Adding Support for a Dashboard (Step 8) ======================================= Adding support for submitting our test results to a dashboard is very easy. We -already defined a number of tests for our project in the earlier steps of this -tutorial. We just have to run those tests and submit them to a dashboard. To -include support for dashboards we include the CTest module in our top-level -``CMakeLists.txt``. +already defined a number of tests for our project in `Testing Support`_. Now we +just have to run those tests and submit them to a dashboard. To include support +for dashboards we include the CTest module in our top-level ``CMakeLists.txt``. Replace: @@ -600,21 +599,25 @@ With: The CTest module will automatically call ``enable_testing()``, so we can remove it from our CMake files. -We will also need to create a ``CTestConfig.cmake`` file where we can specify -the name of the project and where to submit the dashboard. +We will also need to create a ``CTestConfig.cmake`` file in the top-level +directory where we can specify the name of the project and where to submit the +dashboard. .. literalinclude:: Step9/CTestConfig.cmake :language: cmake CTest will read in this file when it runs. To create a simple dashboard you can run **cmake** or **cmake-gui** to configure the project, but do not build it -yet. Instead, change directory to the binary tree, and then run: +yet. Instead, change directory to the binary tree, and then run:: -.. code-block:: console + ctest [-VV] ?D Experimental + +Remember, for multi-config generators (e.g. Visual Studio), the configuration +type must be specified:: - 'ctest [-VV] ?D Experimental' + ctest [-VV] -C Debug ?D Experimental -On Windows, build the EXPERIMENTAL target. +Or, from an IDE, build the ``Experimental`` target. Ctest will build and test the project and submit the results to the Kitware public dashboard. The results of your dashboard will be uploaded to Kitware's https://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=61d4d990d620815fac62ccbb28cf522703dde923 commit 61d4d990d620815fac62ccbb28cf522703dde923 Author: Betsy McPhail AuthorDate: Thu Jul 18 15:40:25 2019 -0400 Commit: Brad King CommitDate: Mon Aug 19 11:49:05 2019 -0400 Tutorial: Improve Step 7 * Update directions diff --git a/Help/guide/tutorial/Step7/CMakeLists.txt b/Help/guide/tutorial/Step7/CMakeLists.txt index 78fee2f..c3b375a 100644 --- a/Help/guide/tutorial/Step7/CMakeLists.txt +++ b/Help/guide/tutorial/Step7/CMakeLists.txt @@ -28,7 +28,7 @@ target_link_libraries(Tutorial PUBLIC ${EXTRA_LIBS}) # so that we will find TutorialConfig.h target_include_directories(Tutorial PUBLIC "${PROJECT_BINARY_DIR}" - ) + ) # add the install targets install(TARGETS Tutorial DESTINATION bin) diff --git a/Help/guide/tutorial/index.rst b/Help/guide/tutorial/index.rst index 6327c3d..22f3527 100644 --- a/Help/guide/tutorial/index.rst +++ b/Help/guide/tutorial/index.rst @@ -541,28 +541,37 @@ That is all there is to it. We start by including ``InstallRequiredSystemLibraries``. This module will include any runtime libraries that are needed by the project for the current platform. Next we set some CPack variables to where we have stored the license and version -information for this project. The version information makes use of the -variables we set earlier in this tutorial. Finally we include the CPack -module which will use these variables and some other properties of the system -you are on to setup an installer. +information for this project. The version information was set earlier in this +tutorial and the ``license.txt`` has been included in the top-level source +directory for this step. + +Finally we include the CPack module which will use these variables and some +other properties of the current system to setup an installer. The next step is to build the project in the usual manner and then run -CPack on it. To build a binary distribution you would run: +CPack on it. To build a binary distribution, from the binary directory run: .. code-block:: console cpack +To specify the generator, use the ``-G`` option. For multi-config builds, use +``-C`` to specify the configuration. For example: + +.. code-block:: console + + cpack -G ZIP -C Debug + To create a source distribution you would type: .. code-block:: console - cpack -C CPackSourceConfig.cmake + cpack --config CPackSourceConfig.cmake Alternatively, run ``make package`` or right click the ``Package`` target and ``Build Project`` from an IDE. -Run the installer executable found in the binary directory. Then run the +Run the installer found in the binary directory. Then run the installed executable and verify that it works. Adding Support for a Dashboard (Step 8) https://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=a36731c63460a41caae596b6dcbc75771a810549 commit a36731c63460a41caae596b6dcbc75771a810549 Author: Betsy McPhail AuthorDate: Fri Jul 26 12:46:08 2019 -0400 Commit: Brad King CommitDate: Mon Aug 19 11:49:05 2019 -0400 Tutorial: Improve Step 6 * Print message when using the table * Remove duplicated comment * Remove HAVE_LOG and HAVE_EXP checks, use generated table instead diff --git a/Help/guide/tutorial/Complete/MathFunctions/CMakeLists.txt b/Help/guide/tutorial/Complete/MathFunctions/CMakeLists.txt index 9a3a03c..3dbf287 100644 --- a/Help/guide/tutorial/Complete/MathFunctions/CMakeLists.txt +++ b/Help/guide/tutorial/Complete/MathFunctions/CMakeLists.txt @@ -43,10 +43,6 @@ if(USE_MYMATH) target_compile_definitions(MathFunctions PRIVATE "USE_MYMATH") - if(HAVE_LOG AND HAVE_EXP) - target_compile_definitions(SqrtLibrary - PRIVATE "HAVE_LOG" "HAVE_EXP") - endif() target_link_libraries(MathFunctions PRIVATE SqrtLibrary) endif() diff --git a/Help/guide/tutorial/Complete/MathFunctions/mysqrt.cxx b/Help/guide/tutorial/Complete/MathFunctions/mysqrt.cxx index 386e146..ff37312 100644 --- a/Help/guide/tutorial/Complete/MathFunctions/mysqrt.cxx +++ b/Help/guide/tutorial/Complete/MathFunctions/mysqrt.cxx @@ -4,8 +4,6 @@ // include the generated table #include "Table.h" -#include - namespace mathfunctions { namespace detail { // a hack square root calculation using simple operations @@ -15,20 +13,13 @@ double mysqrt(double x) return 0; } - // if we have both log and exp then use them -#if defined(HAVE_LOG) && defined(HAVE_EXP) - double result = exp(log(x) * 0.5); - std::cout << "Computing sqrt of " << x << " to be " << result - << " using log and exp" << std::endl; -#else // use the table to help find an initial value double result = x; if (x >= 1 && x < 10) { + std::cout << "Use the table to help find an initial value " << std::endl; result = sqrtTable[static_cast(x)]; } - // if we have both log and exp then use them - // do ten iterations for (int i = 0; i < 10; ++i) { if (result <= 0) { @@ -38,7 +29,7 @@ double mysqrt(double x) result = result + 0.5 * delta / result; std::cout << "Computing sqrt of " << x << " to be " << result << std::endl; } -#endif + return result; } } diff --git a/Help/guide/tutorial/MultiPackage/MathFunctions/CMakeLists.txt b/Help/guide/tutorial/MultiPackage/MathFunctions/CMakeLists.txt index 63c0f5f..483e20c 100644 --- a/Help/guide/tutorial/MultiPackage/MathFunctions/CMakeLists.txt +++ b/Help/guide/tutorial/MultiPackage/MathFunctions/CMakeLists.txt @@ -13,12 +13,6 @@ target_include_directories(MathFunctions option(USE_MYMATH "Use tutorial provided math implementation" ON) if(USE_MYMATH) - # does this system provide the log and exp functions? - include(CheckSymbolExists) - set(CMAKE_REQUIRED_LIBRARIES "m") - check_symbol_exists(log "math.h" HAVE_LOG) - check_symbol_exists(exp "math.h" HAVE_EXP) - # first we add the executable that generates the table add_executable(MakeTable MakeTable.cxx) @@ -44,10 +38,6 @@ if(USE_MYMATH) POSITION_INDEPENDENT_CODE ${BUILD_SHARED_LIBS} ) - target_compile_definitions(SqrtLibrary PRIVATE - "$<$:HAVE_LOG>" - "$<$:HAVE_EXP>" - ) target_link_libraries(MathFunctions PRIVATE SqrtLibrary) endif() diff --git a/Help/guide/tutorial/MultiPackage/MathFunctions/mysqrt.cxx b/Help/guide/tutorial/MultiPackage/MathFunctions/mysqrt.cxx index 386e146..4c212b3 100644 --- a/Help/guide/tutorial/MultiPackage/MathFunctions/mysqrt.cxx +++ b/Help/guide/tutorial/MultiPackage/MathFunctions/mysqrt.cxx @@ -4,8 +4,6 @@ // include the generated table #include "Table.h" -#include - namespace mathfunctions { namespace detail { // a hack square root calculation using simple operations @@ -15,12 +13,6 @@ double mysqrt(double x) return 0; } - // if we have both log and exp then use them -#if defined(HAVE_LOG) && defined(HAVE_EXP) - double result = exp(log(x) * 0.5); - std::cout << "Computing sqrt of " << x << " to be " << result - << " using log and exp" << std::endl; -#else // use the table to help find an initial value double result = x; if (x >= 1 && x < 10) { @@ -38,7 +30,7 @@ double mysqrt(double x) result = result + 0.5 * delta / result; std::cout << "Computing sqrt of " << x << " to be " << result << std::endl; } -#endif + return result; } } diff --git a/Help/guide/tutorial/Step10/MathFunctions/CMakeLists.txt b/Help/guide/tutorial/Step10/MathFunctions/CMakeLists.txt index 7b6d4d4..57555d3 100644 --- a/Help/guide/tutorial/Step10/MathFunctions/CMakeLists.txt +++ b/Help/guide/tutorial/Step10/MathFunctions/CMakeLists.txt @@ -39,17 +39,6 @@ if(USE_MYMATH) target_compile_definitions(MathFunctions PRIVATE "USE_MYMATH") - # does this system provide the log and exp functions? - include(CheckSymbolExists) - set(CMAKE_REQUIRED_LIBRARIES "m") - check_symbol_exists(log "math.h" HAVE_LOG) - check_symbol_exists(exp "math.h" HAVE_EXP) - - if(HAVE_LOG AND HAVE_EXP) - target_compile_definitions(SqrtLibrary - PRIVATE "HAVE_LOG" "HAVE_EXP") - endif() - target_link_libraries(MathFunctions PRIVATE SqrtLibrary) endif() diff --git a/Help/guide/tutorial/Step10/MathFunctions/mysqrt.cxx b/Help/guide/tutorial/Step10/MathFunctions/mysqrt.cxx index 386e146..ff37312 100644 --- a/Help/guide/tutorial/Step10/MathFunctions/mysqrt.cxx +++ b/Help/guide/tutorial/Step10/MathFunctions/mysqrt.cxx @@ -4,8 +4,6 @@ // include the generated table #include "Table.h" -#include - namespace mathfunctions { namespace detail { // a hack square root calculation using simple operations @@ -15,20 +13,13 @@ double mysqrt(double x) return 0; } - // if we have both log and exp then use them -#if defined(HAVE_LOG) && defined(HAVE_EXP) - double result = exp(log(x) * 0.5); - std::cout << "Computing sqrt of " << x << " to be " << result - << " using log and exp" << std::endl; -#else // use the table to help find an initial value double result = x; if (x >= 1 && x < 10) { + std::cout << "Use the table to help find an initial value " << std::endl; result = sqrtTable[static_cast(x)]; } - // if we have both log and exp then use them - // do ten iterations for (int i = 0; i < 10; ++i) { if (result <= 0) { @@ -38,7 +29,7 @@ double mysqrt(double x) result = result + 0.5 * delta / result; std::cout << "Computing sqrt of " << x << " to be " << result << std::endl; } -#endif + return result; } } diff --git a/Help/guide/tutorial/Step11/MathFunctions/CMakeLists.txt b/Help/guide/tutorial/Step11/MathFunctions/CMakeLists.txt index 55a40d3..df9f4df 100644 --- a/Help/guide/tutorial/Step11/MathFunctions/CMakeLists.txt +++ b/Help/guide/tutorial/Step11/MathFunctions/CMakeLists.txt @@ -40,10 +40,6 @@ if(USE_MYMATH) target_link_libraries(SqrtLibrary PUBLIC tutorial_compiler_flags) target_compile_definitions(MathFunctions PRIVATE "USE_MYMATH") - if(HAVE_LOG AND HAVE_EXP) - target_compile_definitions(SqrtLibrary - PRIVATE "HAVE_LOG" "HAVE_EXP") - endif() target_link_libraries(MathFunctions PRIVATE SqrtLibrary) endif() diff --git a/Help/guide/tutorial/Step11/MathFunctions/mysqrt.cxx b/Help/guide/tutorial/Step11/MathFunctions/mysqrt.cxx index 436f96d..ff37312 100644 --- a/Help/guide/tutorial/Step11/MathFunctions/mysqrt.cxx +++ b/Help/guide/tutorial/Step11/MathFunctions/mysqrt.cxx @@ -4,8 +4,6 @@ // include the generated table #include "Table.h" -#include - namespace mathfunctions { namespace detail { // a hack square root calculation using simple operations @@ -15,20 +13,13 @@ double mysqrt(double x) return 0; } - // if we have both log and exp then use them -#if defined(HAVE_LOG) && defined(HAVE_EXP) - double result = exp(log(x) * 0.5); - std::cout << "Computing sqrt of " << x << " to be " << result - << " using log and exp" << std::endl; -#else // use the table to help find an initial value double result = x; if (x >= 1 && x < 10) { + std::cout << "Use the table to help find an initial value " << std::endl; result = sqrtTable[static_cast(x)]; } - // if we have both log and exp then use them - // do ten iterations for (int i = 0; i < 10; ++i) { if (result <= 0) { diff --git a/Help/guide/tutorial/Step7/MathFunctions/CMakeLists.txt b/Help/guide/tutorial/Step7/MathFunctions/CMakeLists.txt index 8cc3ae3..9ede4b3 100644 --- a/Help/guide/tutorial/Step7/MathFunctions/CMakeLists.txt +++ b/Help/guide/tutorial/Step7/MathFunctions/CMakeLists.txt @@ -24,17 +24,6 @@ target_include_directories(MathFunctions PRIVATE ${CMAKE_CURRENT_BINARY_DIR} ) -# does this system provide the log and exp functions? -include(CheckSymbolExists) -set(CMAKE_REQUIRED_LIBRARIES "m") -check_symbol_exists(log "math.h" HAVE_LOG) -check_symbol_exists(exp "math.h" HAVE_EXP) - -if(HAVE_LOG AND HAVE_EXP) - target_compile_definitions(MathFunctions - PRIVATE "HAVE_LOG" "HAVE_EXP") -endif() - # install rules install(TARGETS MathFunctions DESTINATION lib) install(FILES MathFunctions.h DESTINATION include) diff --git a/Help/guide/tutorial/Step7/MathFunctions/mysqrt.cxx b/Help/guide/tutorial/Step7/MathFunctions/mysqrt.cxx index eade98c..2ae60c6 100644 --- a/Help/guide/tutorial/Step7/MathFunctions/mysqrt.cxx +++ b/Help/guide/tutorial/Step7/MathFunctions/mysqrt.cxx @@ -4,8 +4,6 @@ // include the generated table #include "Table.h" -#include - // a hack square root calculation using simple operations double mysqrt(double x) { @@ -16,6 +14,7 @@ double mysqrt(double x) // use the table to help find an initial value double result = x; if (x >= 1 && x < 10) { + std::cout << "Use the table to help find an initial value " << std::endl; result = sqrtTable[static_cast(x)]; } diff --git a/Help/guide/tutorial/Step8/MathFunctions/CMakeLists.txt b/Help/guide/tutorial/Step8/MathFunctions/CMakeLists.txt index 8cc3ae3..9ede4b3 100644 --- a/Help/guide/tutorial/Step8/MathFunctions/CMakeLists.txt +++ b/Help/guide/tutorial/Step8/MathFunctions/CMakeLists.txt @@ -24,17 +24,6 @@ target_include_directories(MathFunctions PRIVATE ${CMAKE_CURRENT_BINARY_DIR} ) -# does this system provide the log and exp functions? -include(CheckSymbolExists) -set(CMAKE_REQUIRED_LIBRARIES "m") -check_symbol_exists(log "math.h" HAVE_LOG) -check_symbol_exists(exp "math.h" HAVE_EXP) - -if(HAVE_LOG AND HAVE_EXP) - target_compile_definitions(MathFunctions - PRIVATE "HAVE_LOG" "HAVE_EXP") -endif() - # install rules install(TARGETS MathFunctions DESTINATION lib) install(FILES MathFunctions.h DESTINATION include) diff --git a/Help/guide/tutorial/Step8/MathFunctions/mysqrt.cxx b/Help/guide/tutorial/Step8/MathFunctions/mysqrt.cxx index 2b1d889..2ae60c6 100644 --- a/Help/guide/tutorial/Step8/MathFunctions/mysqrt.cxx +++ b/Help/guide/tutorial/Step8/MathFunctions/mysqrt.cxx @@ -4,8 +4,6 @@ // include the generated table #include "Table.h" -#include - // a hack square root calculation using simple operations double mysqrt(double x) { @@ -13,20 +11,13 @@ double mysqrt(double x) return 0; } - // if we have both log and exp then use them -#if defined(HAVE_LOG) && defined(HAVE_EXP) - double result = exp(log(x) * 0.5); - std::cout << "Computing sqrt of " << x << " to be " << result - << " using log and exp" << std::endl; -#else // use the table to help find an initial value double result = x; if (x >= 1 && x < 10) { + std::cout << "Use the table to help find an initial value " << std::endl; result = sqrtTable[static_cast(x)]; } - // if we have both log and exp then use them - // do ten iterations for (int i = 0; i < 10; ++i) { if (result <= 0) { @@ -36,6 +27,6 @@ double mysqrt(double x) result = result + 0.5 * delta / result; std::cout << "Computing sqrt of " << x << " to be " << result << std::endl; } -#endif + return result; } diff --git a/Help/guide/tutorial/Step9/MathFunctions/CMakeLists.txt b/Help/guide/tutorial/Step9/MathFunctions/CMakeLists.txt index b4d337b..b40b464 100644 --- a/Help/guide/tutorial/Step9/MathFunctions/CMakeLists.txt +++ b/Help/guide/tutorial/Step9/MathFunctions/CMakeLists.txt @@ -26,17 +26,6 @@ target_include_directories(MathFunctions # and that anything that links to use will get this define target_compile_definitions(MathFunctions INTERFACE "USE_MYMATH") -# does this system provide the log and exp functions? -include(CheckSymbolExists) -set(CMAKE_REQUIRED_LIBRARIES "m") -check_symbol_exists(log "math.h" HAVE_LOG) -check_symbol_exists(exp "math.h" HAVE_EXP) - -if(HAVE_LOG AND HAVE_EXP) - target_compile_definitions(MathFunctions - PRIVATE "HAVE_LOG" "HAVE_EXP") -endif() - # install rules install(TARGETS MathFunctions DESTINATION lib) install(FILES MathFunctions.h DESTINATION include) diff --git a/Help/guide/tutorial/Step9/MathFunctions/mysqrt.cxx b/Help/guide/tutorial/Step9/MathFunctions/mysqrt.cxx index 2b1d889..2ae60c6 100644 --- a/Help/guide/tutorial/Step9/MathFunctions/mysqrt.cxx +++ b/Help/guide/tutorial/Step9/MathFunctions/mysqrt.cxx @@ -4,8 +4,6 @@ // include the generated table #include "Table.h" -#include - // a hack square root calculation using simple operations double mysqrt(double x) { @@ -13,20 +11,13 @@ double mysqrt(double x) return 0; } - // if we have both log and exp then use them -#if defined(HAVE_LOG) && defined(HAVE_EXP) - double result = exp(log(x) * 0.5); - std::cout << "Computing sqrt of " << x << " to be " << result - << " using log and exp" << std::endl; -#else // use the table to help find an initial value double result = x; if (x >= 1 && x < 10) { + std::cout << "Use the table to help find an initial value " << std::endl; result = sqrtTable[static_cast(x)]; } - // if we have both log and exp then use them - // do ten iterations for (int i = 0; i < 10; ++i) { if (result <= 0) { @@ -36,6 +27,6 @@ double mysqrt(double x) result = result + 0.5 * delta / result; std::cout << "Computing sqrt of " << x << " to be " << result << std::endl; } -#endif + return result; } diff --git a/Help/guide/tutorial/index.rst b/Help/guide/tutorial/index.rst index 2aaca77..6327c3d 100644 --- a/Help/guide/tutorial/index.rst +++ b/Help/guide/tutorial/index.rst @@ -450,27 +450,29 @@ this step. Adding a Custom Command and Generated File (Step 6) =================================================== -In this section, we will add a generated source file into the build process -of an application. For this example, we will create a table of precomputed -square roots as part of the build process, and then compile that -table into our application. +Suppose, for the purpose of this tutorial, we decide that we never want to use +the platform ``log`` and ``exp`` functions and instead would like to +generate a table of precomputed values to use in the ``mysqrt`` function. +In this section, we will create the table as part of the build process, +and then compile that table into our application. -To accomplish this, we first need a program that will generate the table. In -the MathFunctions subdirectory a new source file named ``MakeTable.cxx`` will -do just that. +First, let's remove the check for the ``log`` and ``exp`` functions in +MathFunctions/CMakeLists. Then remove the check for ``HAVE_LOG`` and +``HAVE_EXP`` from ``mysqrt.cxx``. At the same time, we can remove +:code:`#include `. -.. literalinclude:: Step7/MathFunctions/MakeTable.cxx - :language: c++ +In the MathFunctions subdirectory, a new source file named ``MakeTable.cxx`` +has been provided to generate the table. -Note that the table is produced as valid C++ code and that the output filename -is passed in as an argument. +After reviewing the file, we can see that the table is produced as valid C++ +code and that the output filename is passed in as an argument. -The next step is to add the appropriate commands to MathFunctions' CMakeLists +The next step is to add the appropriate commands to MathFunctions CMakeLists file to build the MakeTable executable and then run it as part of the build process. A few commands are needed to accomplish this. -First, the executable for ``MakeTable`` is added as any other executable would -be added. +First, at the top of MathFunctions/CMakeLists, the executable for ``MakeTable`` +is added as any other executable would be added. .. literalinclude:: Step7/MathFunctions/CMakeLists.txt :language: cmake @@ -509,10 +511,14 @@ Now let's use the generated table. First, modify ``mysqrt.cxx`` to include :start-after: // a hack square root calculation using simple operations Run **cmake** or **cmake-gui** to configure the project and then build it -with your chosen build tool. When this project is built it will first build -the ``MakeTable`` executable. It will then run ``MakeTable`` to produce -``Table.h``. Finally, it will compile ``mysqrt.cxx`` which includes -``Table.h`` to produce the MathFunctions library. +with your chosen build tool. + +When this project is built it will first build the ``MakeTable`` executable. +It will then run ``MakeTable`` to produce ``Table.h``. Finally, it will +compile ``mysqrt.cxx`` which includes ``Table.h`` to produce the MathFunctions +library. + +Run the Tutorial executable and verify that it is using the table. Building an Installer (Step 7) ============================== https://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=df9cdf629c5211282dcab2e4751f69032e25a244 commit df9cdf629c5211282dcab2e4751f69032e25a244 Author: Betsy McPhail AuthorDate: Tue Jul 9 19:28:57 2019 -0400 Commit: Brad King CommitDate: Mon Aug 19 11:49:05 2019 -0400 Tutorial: Improve Step 5 * Updated output message * Use 'target_compile_definitions' for HAVE_LOG and HAVE_EXP Previously, the change from using TutorialConfig.h to target_compile_definitions happened without explanation as part of Step 8. diff --git a/Help/guide/tutorial/Complete/MathFunctions/CMakeLists.txt b/Help/guide/tutorial/Complete/MathFunctions/CMakeLists.txt index c12955d..9a3a03c 100644 --- a/Help/guide/tutorial/Complete/MathFunctions/CMakeLists.txt +++ b/Help/guide/tutorial/Complete/MathFunctions/CMakeLists.txt @@ -13,12 +13,6 @@ target_include_directories(MathFunctions option(USE_MYMATH "Use tutorial provided math implementation" ON) if(USE_MYMATH) - # does this system provide the log and exp functions? - include(CheckSymbolExists) - set(CMAKE_REQUIRED_LIBRARIES "m") - check_symbol_exists(log "math.h" HAVE_LOG) - check_symbol_exists(exp "math.h" HAVE_EXP) - # first we add the executable that generates the table add_executable(MakeTable MakeTable.cxx) target_link_libraries(MakeTable tutorial_compiler_flags) diff --git a/Help/guide/tutorial/Complete/MathFunctions/mysqrt.cxx b/Help/guide/tutorial/Complete/MathFunctions/mysqrt.cxx index 96d9421..386e146 100644 --- a/Help/guide/tutorial/Complete/MathFunctions/mysqrt.cxx +++ b/Help/guide/tutorial/Complete/MathFunctions/mysqrt.cxx @@ -18,8 +18,8 @@ double mysqrt(double x) // if we have both log and exp then use them #if defined(HAVE_LOG) && defined(HAVE_EXP) double result = exp(log(x) * 0.5); - std::cout << "Computing sqrt of " << x << " to be " << result << " using log" - << std::endl; + std::cout << "Computing sqrt of " << x << " to be " << result + << " using log and exp" << std::endl; #else // use the table to help find an initial value double result = x; diff --git a/Help/guide/tutorial/MultiPackage/MathFunctions/mysqrt.cxx b/Help/guide/tutorial/MultiPackage/MathFunctions/mysqrt.cxx index 96d9421..386e146 100644 --- a/Help/guide/tutorial/MultiPackage/MathFunctions/mysqrt.cxx +++ b/Help/guide/tutorial/MultiPackage/MathFunctions/mysqrt.cxx @@ -18,8 +18,8 @@ double mysqrt(double x) // if we have both log and exp then use them #if defined(HAVE_LOG) && defined(HAVE_EXP) double result = exp(log(x) * 0.5); - std::cout << "Computing sqrt of " << x << " to be " << result << " using log" - << std::endl; + std::cout << "Computing sqrt of " << x << " to be " << result + << " using log and exp" << std::endl; #else // use the table to help find an initial value double result = x; diff --git a/Help/guide/tutorial/Step10/MathFunctions/CMakeLists.txt b/Help/guide/tutorial/Step10/MathFunctions/CMakeLists.txt index 0ef67f1..7b6d4d4 100644 --- a/Help/guide/tutorial/Step10/MathFunctions/CMakeLists.txt +++ b/Help/guide/tutorial/Step10/MathFunctions/CMakeLists.txt @@ -11,12 +11,6 @@ target_include_directories(MathFunctions option(USE_MYMATH "Use tutorial provided math implementation" ON) if(USE_MYMATH) - # does this system provide the log and exp functions? - include(CheckSymbolExists) - set(CMAKE_REQUIRED_LIBRARIES "m") - check_symbol_exists(log "math.h" HAVE_LOG) - check_symbol_exists(exp "math.h" HAVE_EXP) - # first we add the executable that generates the table add_executable(MakeTable MakeTable.cxx) @@ -43,6 +37,19 @@ if(USE_MYMATH) POSITION_INDEPENDENT_CODE ${BUILD_SHARED_LIBS} ) + target_compile_definitions(MathFunctions PRIVATE "USE_MYMATH") + + # does this system provide the log and exp functions? + include(CheckSymbolExists) + set(CMAKE_REQUIRED_LIBRARIES "m") + check_symbol_exists(log "math.h" HAVE_LOG) + check_symbol_exists(exp "math.h" HAVE_EXP) + + if(HAVE_LOG AND HAVE_EXP) + target_compile_definitions(SqrtLibrary + PRIVATE "HAVE_LOG" "HAVE_EXP") + endif() + target_link_libraries(MathFunctions PRIVATE SqrtLibrary) endif() diff --git a/Help/guide/tutorial/Step10/MathFunctions/mysqrt.cxx b/Help/guide/tutorial/Step10/MathFunctions/mysqrt.cxx index 96d9421..386e146 100644 --- a/Help/guide/tutorial/Step10/MathFunctions/mysqrt.cxx +++ b/Help/guide/tutorial/Step10/MathFunctions/mysqrt.cxx @@ -18,8 +18,8 @@ double mysqrt(double x) // if we have both log and exp then use them #if defined(HAVE_LOG) && defined(HAVE_EXP) double result = exp(log(x) * 0.5); - std::cout << "Computing sqrt of " << x << " to be " << result << " using log" - << std::endl; + std::cout << "Computing sqrt of " << x << " to be " << result + << " using log and exp" << std::endl; #else // use the table to help find an initial value double result = x; diff --git a/Help/guide/tutorial/Step11/MathFunctions/CMakeLists.txt b/Help/guide/tutorial/Step11/MathFunctions/CMakeLists.txt index daaaa55..55a40d3 100644 --- a/Help/guide/tutorial/Step11/MathFunctions/CMakeLists.txt +++ b/Help/guide/tutorial/Step11/MathFunctions/CMakeLists.txt @@ -11,12 +11,6 @@ target_include_directories(MathFunctions option(USE_MYMATH "Use tutorial provided math implementation" ON) if(USE_MYMATH) - # does this system provide the log and exp functions? - include(CheckSymbolExists) - set(CMAKE_REQUIRED_LIBRARIES "m") - check_symbol_exists(log "math.h" HAVE_LOG) - check_symbol_exists(exp "math.h" HAVE_EXP) - # first we add the executable that generates the table add_executable(MakeTable MakeTable.cxx) target_link_libraries(MakeTable tutorial_compiler_flags) diff --git a/Help/guide/tutorial/Step11/MathFunctions/mysqrt.cxx b/Help/guide/tutorial/Step11/MathFunctions/mysqrt.cxx index 96d9421..436f96d 100644 --- a/Help/guide/tutorial/Step11/MathFunctions/mysqrt.cxx +++ b/Help/guide/tutorial/Step11/MathFunctions/mysqrt.cxx @@ -18,8 +18,8 @@ double mysqrt(double x) // if we have both log and exp then use them #if defined(HAVE_LOG) && defined(HAVE_EXP) double result = exp(log(x) * 0.5); - std::cout << "Computing sqrt of " << x << " to be " << result << " using log" - << std::endl; + std::cout << "Computing sqrt of " << x << " to be " << result + << " using log and exp" << std::endl; #else // use the table to help find an initial value double result = x; @@ -38,7 +38,7 @@ double mysqrt(double x) result = result + 0.5 * delta / result; std::cout << "Computing sqrt of " << x << " to be " << result << std::endl; } -#endif + return result; } } diff --git a/Help/guide/tutorial/Step6/CMakeLists.txt b/Help/guide/tutorial/Step6/CMakeLists.txt index 2bb0859..c3b375a 100644 --- a/Help/guide/tutorial/Step6/CMakeLists.txt +++ b/Help/guide/tutorial/Step6/CMakeLists.txt @@ -10,12 +10,6 @@ set(CMAKE_CXX_STANDARD_REQUIRED True) # should we use our own math functions option(USE_MYMATH "Use tutorial provided math implementation" ON) -# does this system provide the log and exp functions? -include(CheckSymbolExists) -set(CMAKE_REQUIRED_LIBRARIES "m") -check_symbol_exists(log "math.h" HAVE_LOG) -check_symbol_exists(exp "math.h" HAVE_EXP) - # configure a header file to pass some of the CMake settings # to the source code configure_file(TutorialConfig.h.in TutorialConfig.h) diff --git a/Help/guide/tutorial/Step6/MathFunctions/CMakeLists.txt b/Help/guide/tutorial/Step6/MathFunctions/CMakeLists.txt index def1140..4bf6024 100644 --- a/Help/guide/tutorial/Step6/MathFunctions/CMakeLists.txt +++ b/Help/guide/tutorial/Step6/MathFunctions/CMakeLists.txt @@ -2,13 +2,21 @@ add_library(MathFunctions mysqrt.cxx) # state that anybody linking to us needs to include the current source dir # to find MathFunctions.h, while we don't. -# state that we depend on Tutorial_BINARY_DIR but consumers don't, as the -# TutorialConfig.h include is an implementation detail target_include_directories(MathFunctions INTERFACE ${CMAKE_CURRENT_SOURCE_DIR} - PRIVATE ${Tutorial_BINARY_DIR} ) +# does this system provide the log and exp functions? +include(CheckSymbolExists) +set(CMAKE_REQUIRED_LIBRARIES "m") +check_symbol_exists(log "math.h" HAVE_LOG) +check_symbol_exists(exp "math.h" HAVE_EXP) + +if(HAVE_LOG AND HAVE_EXP) + target_compile_definitions(MathFunctions + PRIVATE "HAVE_LOG" "HAVE_EXP") +endif() + # install rules install(TARGETS MathFunctions DESTINATION lib) install(FILES MathFunctions.h DESTINATION include) diff --git a/Help/guide/tutorial/Step6/MathFunctions/mysqrt.cxx b/Help/guide/tutorial/Step6/MathFunctions/mysqrt.cxx index b9ad20a..3f23245 100644 --- a/Help/guide/tutorial/Step6/MathFunctions/mysqrt.cxx +++ b/Help/guide/tutorial/Step6/MathFunctions/mysqrt.cxx @@ -1,5 +1,4 @@ #include "MathFunctions.h" -#include "TutorialConfig.h" #include #include @@ -14,8 +13,8 @@ double mysqrt(double x) // if we have both log and exp then use them #if defined(HAVE_LOG) && defined(HAVE_EXP) double result = exp(log(x) * 0.5); - std::cout << "Computing sqrt of " << x << " to be " << result << " using log" - << std::endl; + std::cout << "Computing sqrt of " << x << " to be " << result + << " using log and exp" << std::endl; #else double result = x; diff --git a/Help/guide/tutorial/Step6/TutorialConfig.h.in b/Help/guide/tutorial/Step6/TutorialConfig.h.in index e97ce24..e23f521 100644 --- a/Help/guide/tutorial/Step6/TutorialConfig.h.in +++ b/Help/guide/tutorial/Step6/TutorialConfig.h.in @@ -2,7 +2,3 @@ #define Tutorial_VERSION_MAJOR @Tutorial_VERSION_MAJOR@ #define Tutorial_VERSION_MINOR @Tutorial_VERSION_MINOR@ #cmakedefine USE_MYMATH - -// does the platform provide exp and log functions? -#cmakedefine HAVE_LOG -#cmakedefine HAVE_EXP diff --git a/Help/guide/tutorial/Step7/CMakeLists.txt b/Help/guide/tutorial/Step7/CMakeLists.txt index dada2d3..78fee2f 100644 --- a/Help/guide/tutorial/Step7/CMakeLists.txt +++ b/Help/guide/tutorial/Step7/CMakeLists.txt @@ -10,12 +10,6 @@ set(CMAKE_CXX_STANDARD_REQUIRED True) # should we use our own math functions option(USE_MYMATH "Use tutorial provided math implementation" ON) -# does this system provide the log and exp functions? -include(CheckSymbolExists) -set(CMAKE_REQUIRED_LIBRARIES "m") -check_symbol_exists(log "math.h" HAVE_LOG) -check_symbol_exists(exp "math.h" HAVE_EXP) - # configure a header file to pass some of the CMake settings # to the source code configure_file(TutorialConfig.h.in TutorialConfig.h) diff --git a/Help/guide/tutorial/Step7/MathFunctions/CMakeLists.txt b/Help/guide/tutorial/Step7/MathFunctions/CMakeLists.txt index 3c3a816..8cc3ae3 100644 --- a/Help/guide/tutorial/Step7/MathFunctions/CMakeLists.txt +++ b/Help/guide/tutorial/Step7/MathFunctions/CMakeLists.txt @@ -21,10 +21,20 @@ add_library(MathFunctions # state that we depend on our binary dir to find Table.h target_include_directories(MathFunctions INTERFACE ${CMAKE_CURRENT_SOURCE_DIR} - PRIVATE ${Tutorial_BINARY_DIR} - ${CMAKE_CURRENT_BINARY_DIR} + PRIVATE ${CMAKE_CURRENT_BINARY_DIR} ) +# does this system provide the log and exp functions? +include(CheckSymbolExists) +set(CMAKE_REQUIRED_LIBRARIES "m") +check_symbol_exists(log "math.h" HAVE_LOG) +check_symbol_exists(exp "math.h" HAVE_EXP) + +if(HAVE_LOG AND HAVE_EXP) + target_compile_definitions(MathFunctions + PRIVATE "HAVE_LOG" "HAVE_EXP") +endif() + # install rules install(TARGETS MathFunctions DESTINATION lib) install(FILES MathFunctions.h DESTINATION include) diff --git a/Help/guide/tutorial/Step7/MathFunctions/mysqrt.cxx b/Help/guide/tutorial/Step7/MathFunctions/mysqrt.cxx index 5272f56..eade98c 100644 --- a/Help/guide/tutorial/Step7/MathFunctions/mysqrt.cxx +++ b/Help/guide/tutorial/Step7/MathFunctions/mysqrt.cxx @@ -1,5 +1,4 @@ #include "MathFunctions.h" -#include "TutorialConfig.h" #include // include the generated table diff --git a/Help/guide/tutorial/Step7/TutorialConfig.h.in b/Help/guide/tutorial/Step7/TutorialConfig.h.in index e97ce24..e23f521 100644 --- a/Help/guide/tutorial/Step7/TutorialConfig.h.in +++ b/Help/guide/tutorial/Step7/TutorialConfig.h.in @@ -2,7 +2,3 @@ #define Tutorial_VERSION_MAJOR @Tutorial_VERSION_MAJOR@ #define Tutorial_VERSION_MINOR @Tutorial_VERSION_MINOR@ #cmakedefine USE_MYMATH - -// does the platform provide exp and log functions? -#cmakedefine HAVE_LOG -#cmakedefine HAVE_EXP diff --git a/Help/guide/tutorial/Step8/CMakeLists.txt b/Help/guide/tutorial/Step8/CMakeLists.txt index 4d62cd1..2859049 100644 --- a/Help/guide/tutorial/Step8/CMakeLists.txt +++ b/Help/guide/tutorial/Step8/CMakeLists.txt @@ -10,12 +10,6 @@ set(CMAKE_CXX_STANDARD_REQUIRED True) # should we use our own math functions option(USE_MYMATH "Use tutorial provided math implementation" ON) -# does this system provide the log and exp functions? -include(CheckSymbolExists) -set(CMAKE_REQUIRED_LIBRARIES "m") -check_symbol_exists(log "math.h" HAVE_LOG) -check_symbol_exists(exp "math.h" HAVE_EXP) - # configure a header file to pass some of the CMake settings # to the source code configure_file(TutorialConfig.h.in TutorialConfig.h) diff --git a/Help/guide/tutorial/Step8/MathFunctions/CMakeLists.txt b/Help/guide/tutorial/Step8/MathFunctions/CMakeLists.txt index 3c3a816..8cc3ae3 100644 --- a/Help/guide/tutorial/Step8/MathFunctions/CMakeLists.txt +++ b/Help/guide/tutorial/Step8/MathFunctions/CMakeLists.txt @@ -21,10 +21,20 @@ add_library(MathFunctions # state that we depend on our binary dir to find Table.h target_include_directories(MathFunctions INTERFACE ${CMAKE_CURRENT_SOURCE_DIR} - PRIVATE ${Tutorial_BINARY_DIR} - ${CMAKE_CURRENT_BINARY_DIR} + PRIVATE ${CMAKE_CURRENT_BINARY_DIR} ) +# does this system provide the log and exp functions? +include(CheckSymbolExists) +set(CMAKE_REQUIRED_LIBRARIES "m") +check_symbol_exists(log "math.h" HAVE_LOG) +check_symbol_exists(exp "math.h" HAVE_EXP) + +if(HAVE_LOG AND HAVE_EXP) + target_compile_definitions(MathFunctions + PRIVATE "HAVE_LOG" "HAVE_EXP") +endif() + # install rules install(TARGETS MathFunctions DESTINATION lib) install(FILES MathFunctions.h DESTINATION include) diff --git a/Help/guide/tutorial/Step8/MathFunctions/mysqrt.cxx b/Help/guide/tutorial/Step8/MathFunctions/mysqrt.cxx index 5b862fb..2b1d889 100644 --- a/Help/guide/tutorial/Step8/MathFunctions/mysqrt.cxx +++ b/Help/guide/tutorial/Step8/MathFunctions/mysqrt.cxx @@ -1,5 +1,4 @@ #include "MathFunctions.h" -#include "TutorialConfig.h" #include // include the generated table @@ -17,8 +16,8 @@ double mysqrt(double x) // if we have both log and exp then use them #if defined(HAVE_LOG) && defined(HAVE_EXP) double result = exp(log(x) * 0.5); - std::cout << "Computing sqrt of " << x << " to be " << result << " using log" - << std::endl; + std::cout << "Computing sqrt of " << x << " to be " << result + << " using log and exp" << std::endl; #else // use the table to help find an initial value double result = x; diff --git a/Help/guide/tutorial/Step8/TutorialConfig.h.in b/Help/guide/tutorial/Step8/TutorialConfig.h.in index e97ce24..e23f521 100644 --- a/Help/guide/tutorial/Step8/TutorialConfig.h.in +++ b/Help/guide/tutorial/Step8/TutorialConfig.h.in @@ -2,7 +2,3 @@ #define Tutorial_VERSION_MAJOR @Tutorial_VERSION_MAJOR@ #define Tutorial_VERSION_MINOR @Tutorial_VERSION_MINOR@ #cmakedefine USE_MYMATH - -// does the platform provide exp and log functions? -#cmakedefine HAVE_LOG -#cmakedefine HAVE_EXP diff --git a/Help/guide/tutorial/Step9/CMakeLists.txt b/Help/guide/tutorial/Step9/CMakeLists.txt index f88976f..f437053 100644 --- a/Help/guide/tutorial/Step9/CMakeLists.txt +++ b/Help/guide/tutorial/Step9/CMakeLists.txt @@ -10,12 +10,6 @@ set(CMAKE_CXX_STANDARD_REQUIRED True) # should we use our own math functions option(USE_MYMATH "Use tutorial provided math implementation" ON) -# does this system provide the log and exp functions? -include(CheckSymbolExists) -set(CMAKE_REQUIRED_LIBRARIES "m") -check_symbol_exists(log "math.h" HAVE_LOG) -check_symbol_exists(exp "math.h" HAVE_EXP) - # configure a header file to pass the version number only configure_file(TutorialConfig.h.in TutorialConfig.h) diff --git a/Help/guide/tutorial/Step9/MathFunctions/CMakeLists.txt b/Help/guide/tutorial/Step9/MathFunctions/CMakeLists.txt index c8cd1dd..b4d337b 100644 --- a/Help/guide/tutorial/Step9/MathFunctions/CMakeLists.txt +++ b/Help/guide/tutorial/Step9/MathFunctions/CMakeLists.txt @@ -26,6 +26,12 @@ target_include_directories(MathFunctions # and that anything that links to use will get this define target_compile_definitions(MathFunctions INTERFACE "USE_MYMATH") +# does this system provide the log and exp functions? +include(CheckSymbolExists) +set(CMAKE_REQUIRED_LIBRARIES "m") +check_symbol_exists(log "math.h" HAVE_LOG) +check_symbol_exists(exp "math.h" HAVE_EXP) + if(HAVE_LOG AND HAVE_EXP) target_compile_definitions(MathFunctions PRIVATE "HAVE_LOG" "HAVE_EXP") diff --git a/Help/guide/tutorial/Step9/MathFunctions/mysqrt.cxx b/Help/guide/tutorial/Step9/MathFunctions/mysqrt.cxx index 8b82141..2b1d889 100644 --- a/Help/guide/tutorial/Step9/MathFunctions/mysqrt.cxx +++ b/Help/guide/tutorial/Step9/MathFunctions/mysqrt.cxx @@ -16,8 +16,8 @@ double mysqrt(double x) // if we have both log and exp then use them #if defined(HAVE_LOG) && defined(HAVE_EXP) double result = exp(log(x) * 0.5); - std::cout << "Computing sqrt of " << x << " to be " << result << " using log" - << std::endl; + std::cout << "Computing sqrt of " << x << " to be " << result + << " using log and exp" << std::endl; #else // use the table to help find an initial value double result = x; diff --git a/Help/guide/tutorial/index.rst b/Help/guide/tutorial/index.rst index 9118c4f..2aaca77 100644 --- a/Help/guide/tutorial/index.rst +++ b/Help/guide/tutorial/index.rst @@ -371,43 +371,81 @@ tutorial assume that they are not common. If the platform has ``log`` and ``exp`` then we will use them to compute the square root in the ``mysqrt`` function. We first test for the availability of these functions using the ``CheckSymbolExists.cmake`` macro in the top-level -CMakeLists file as follows: +CMakeLists. We're going to use the new defines in ``TutorialConfig.h.in``, +so be sure to set them before that file is configured. -.. literalinclude:: Step6/CMakeLists.txt +.. literalinclude:: Step6/MathFunctions/CMakeLists.txt :language: cmake :start-after: # does this system provide the log and exp functions? - :end-before: # configure a header file to pass some of the CMake settings + :end-before: if(HAVE_LOG AND HAVE_EXP) Now let's add these defines to ``TutorialConfig.h.in`` so that we can use them from ``mysqrt.cxx``: -.. literalinclude:: Step6/TutorialConfig.h.in - :language: c - :start-after: // does the platform provide exp and log functions? +.. code-block:: console -Finally, in the ``mysqrt`` function we can provide an alternate implementation -based on ``log`` and ``exp`` if they are available on the system using the -following code: + // does the platform provide exp and log functions? + #cmakedefine HAVE_LOG + #cmakedefine HAVE_EXP + +Modify ``mysqrt.cxx`` to include cmath. Next, in that same file in the +``mysqrt`` function we can provide an alternate implementation based on +``log`` and ``exp`` if they are available on the system using the following +code (don't forget the ``#endif`` before returning the result!): .. literalinclude:: Step6/MathFunctions/mysqrt.cxx :language: c++ :start-after: // if we have both log and exp then use them - :end-before: #else + :end-before: // do ten iterations Run **cmake** or **cmake-gui** to configure the project and then build it -with your chosen build tool. +with your chosen build tool and run the Tutorial executable. + +You will notice that we're not using ``log`` and ``exp``, even if we think they +should be available. We should realize quickly that we have forgotten to include +``TutorialConfig.h`` in ``mysqrt.cxx``. + +We will also need to update MathFunctions/CMakeLists so ``mysqrt.cxx`` knows +where this file is located: + + +.. code-block:: cmake + + target_include_directories(MathFunctions + INTERFACE ${CMAKE_CURRENT_SOURCE_DIR} + PRIVATE ${CMAKE_BINARY_DIR} + ) + +After making this update, go ahead and build the project again and run the built +Tutorial executable. If ``log`` and ``exp`` are still not being used, open the +generated ``TutorialConfig.h`` file from the build directory. Maybe they aren't +available on the current system? + +Which function gives better results now, sqrt or mysqrt? + +Specify Compile Definition +-------------------------- -You will notice that even though ``HAVE_LOG`` and ``HAVE_EXP`` are both -defined ``mysqrt`` isn't using them. We should realize quickly that we have -forgotten to include ``TutorialConfig.h`` in ``mysqrt.cxx``. +Is there a better place for us to save the ``HAVE_LOG`` and ``HAVE_EXP`` values +other than in ``TutorialConfig.h``? Let's try to use +``target_compile_definitions``. -After making this update, go ahead and build the project again. +First, remove the defines from ``TutorialConfig.h.in``. We no longer need to +include ``TutorialConfig.h`` from ``mysqrt.cxx`` or the extra include in +MathFunctions/CMakeLists. -Run the built Tutorial executable. Which function gives better results now, -Step1?s sqrt or Step5?s mysqrt? +Next, we can move the check for ``HAVE_LOG`` and ``HAVE_EXP`` to +MathFunctions/CMakeLists and then add specify those values as ``PRIVATE`` +compile definitions. + +.. literalinclude:: Step6/MathFunctions/CMakeLists.txt + :language: cmake + :start-after: # does this system provide the log and exp functions? + :end-before: # install rules -**Exercise**: Is there a better place for us to save the ``HAVE_LOG`` and -``HAVE_EXP`` values other than in ``TutorialConfig.h``? +After making these updates, go ahead and build the project again. Run the +built Tutorial executable and verify that the results are same as earlier in +this step. Adding a Custom Command and Generated File (Step 6) =================================================== https://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=442c0f0d463d8f08a6c47b371cdb13a9ec4cea41 commit 442c0f0d463d8f08a6c47b371cdb13a9ec4cea41 Author: Betsy McPhail AuthorDate: Thu Jul 18 15:40:25 2019 -0400 Commit: Brad King CommitDate: Mon Aug 19 11:49:05 2019 -0400 Tutorial: Improve Step 4 * Clarify directions diff --git a/Help/guide/tutorial/index.rst b/Help/guide/tutorial/index.rst index cbeec4d..9118c4f 100644 --- a/Help/guide/tutorial/index.rst +++ b/Help/guide/tutorial/index.rst @@ -293,17 +293,17 @@ Now we can start adding install rules and testing support to our project. Install Rules ------------- -The install rules are fairly simple for MathFunctions we want to install the +The install rules are fairly simple: for MathFunctions we want to install the library and header file and for the application we want to install the executable and configured header. -So to ``MathFunctions/CMakeLists.txt`` we add: +So to the end of ``MathFunctions/CMakeLists.txt`` we add: .. literalinclude:: Step5/MathFunctions/CMakeLists.txt :language: cmake :start-after: # install rules -And the to top-level ``CMakeLists.txt`` we add: +And to the end of the top-level ``CMakeLists.txt`` we add: .. literalinclude:: Step5/CMakeLists.txt :language: cmake @@ -314,21 +314,25 @@ That is all that is needed to create a basic local install of the tutorial. Run **cmake** or **cmake-gui** to configure the project and then build it with your chosen build tool. Run the install step by typing -``cmake --install .`` or from the command line, or build the ``INSTALL`` -target from an IDE. This will install the appropriate header files, libraries, -and executables. +``cmake --install .`` (introduced in 3.15, older versions of CMake must use +``make install``) from the command line, or build the ``INSTALL`` target from +an IDE. This will install the appropriate header files, libraries, and +executables. -Verify that the installed Tutorial runs. Note: The CMake variable -``CMAKE_INSTALL_PREFIX`` is used to determine the root of where the files will -be installed. If using ``cmake --install`` a custom installation directory can -be given via ``--prefix`` argument. +The CMake variable ``CMAKE_INSTALL_PREFIX`` is used to determine the root of +where the files will be installed. If using ``cmake --install`` a custom +installation directory can be given via ``--prefix`` argument. For +multi-configuration tools, use the ``--config`` argument to specify the +configuration. + +Verify that the installed Tutorial runs. Testing Support --------------- Next let's test our application. At the end of the top-level CMakeLists file we -can add a number of basic tests to verify that the application is -working correctly. +can enable testing and then add a number of basic tests to verify that the +application is working correctly. .. literalinclude:: Step5/CMakeLists.txt :language: cmake @@ -339,7 +343,7 @@ otherwise crash, and has a zero return value. This is the basic form of a CTest test. The next test makes use of the ``PASS_REGULAR_EXPRESSION`` test property to -verify that the output of the test contains certain strings, in this case: +verify that the output of the test contains certain strings. In this case, verifying that the the usage message is printed when an incorrect number of arguments are provided. @@ -349,7 +353,11 @@ invocation of ``do_test``, another test is added to the project with a name, input, and expected results based on the passed arguments. Rebuild the application and then cd to the binary directory and run -``ctest -N`` and ``ctest -VV``. +``ctest -N`` and ``ctest -VV``. For multi-config generators (e.g. Visual +Studio), the configuration type must be specified. To run tests in Debug mode, +for example, use ``ctest -C Debug -VV`` from the build directory (not the +Debug subdirectory!). Alternatively, build the ``RUN_TESTS`` target from the +IDE. Adding System Introspection (Step 5) ==================================== https://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=bc64401c3d9355f3c8fd6a205b8ef9d24a795204 commit bc64401c3d9355f3c8fd6a205b8ef9d24a795204 Author: Betsy McPhail AuthorDate: Tue Jul 9 13:36:53 2019 -0400 Commit: Brad King CommitDate: Mon Aug 19 11:49:05 2019 -0400 Tutorial: Improve Step 3 * Move `option(USE_MYMATH...` to the same location in all CMakeLists files diff --git a/Help/guide/tutorial/Step6/CMakeLists.txt b/Help/guide/tutorial/Step6/CMakeLists.txt index 175f99f..2bb0859 100644 --- a/Help/guide/tutorial/Step6/CMakeLists.txt +++ b/Help/guide/tutorial/Step6/CMakeLists.txt @@ -7,15 +7,15 @@ project(Tutorial VERSION 1.0) set(CMAKE_CXX_STANDARD 11) set(CMAKE_CXX_STANDARD_REQUIRED True) +# should we use our own math functions +option(USE_MYMATH "Use tutorial provided math implementation" ON) + # does this system provide the log and exp functions? include(CheckSymbolExists) set(CMAKE_REQUIRED_LIBRARIES "m") check_symbol_exists(log "math.h" HAVE_LOG) check_symbol_exists(exp "math.h" HAVE_EXP) -# should we use our own math functions -option(USE_MYMATH "Use tutorial provided math implementation" ON) - # configure a header file to pass some of the CMake settings # to the source code configure_file(TutorialConfig.h.in TutorialConfig.h) diff --git a/Help/guide/tutorial/Step7/CMakeLists.txt b/Help/guide/tutorial/Step7/CMakeLists.txt index d1c0d1f..dada2d3 100644 --- a/Help/guide/tutorial/Step7/CMakeLists.txt +++ b/Help/guide/tutorial/Step7/CMakeLists.txt @@ -7,15 +7,15 @@ project(Tutorial VERSION 1.0) set(CMAKE_CXX_STANDARD 11) set(CMAKE_CXX_STANDARD_REQUIRED True) +# should we use our own math functions +option(USE_MYMATH "Use tutorial provided math implementation" ON) + # does this system provide the log and exp functions? include(CheckSymbolExists) set(CMAKE_REQUIRED_LIBRARIES "m") check_symbol_exists(log "math.h" HAVE_LOG) check_symbol_exists(exp "math.h" HAVE_EXP) -# should we use our own math functions -option(USE_MYMATH "Use tutorial provided math implementation" ON) - # configure a header file to pass some of the CMake settings # to the source code configure_file(TutorialConfig.h.in TutorialConfig.h) diff --git a/Help/guide/tutorial/Step8/CMakeLists.txt b/Help/guide/tutorial/Step8/CMakeLists.txt index d8e9145..4d62cd1 100644 --- a/Help/guide/tutorial/Step8/CMakeLists.txt +++ b/Help/guide/tutorial/Step8/CMakeLists.txt @@ -7,15 +7,15 @@ project(Tutorial VERSION 1.0) set(CMAKE_CXX_STANDARD 11) set(CMAKE_CXX_STANDARD_REQUIRED True) +# should we use our own math functions +option(USE_MYMATH "Use tutorial provided math implementation" ON) + # does this system provide the log and exp functions? include(CheckSymbolExists) set(CMAKE_REQUIRED_LIBRARIES "m") check_symbol_exists(log "math.h" HAVE_LOG) check_symbol_exists(exp "math.h" HAVE_EXP) -# should we use our own math functions -option(USE_MYMATH "Use tutorial provided math implementation" ON) - # configure a header file to pass some of the CMake settings # to the source code configure_file(TutorialConfig.h.in TutorialConfig.h) diff --git a/Help/guide/tutorial/Step9/CMakeLists.txt b/Help/guide/tutorial/Step9/CMakeLists.txt index 62bf1c8..f88976f 100644 --- a/Help/guide/tutorial/Step9/CMakeLists.txt +++ b/Help/guide/tutorial/Step9/CMakeLists.txt @@ -7,15 +7,15 @@ project(Tutorial VERSION 1.0) set(CMAKE_CXX_STANDARD 11) set(CMAKE_CXX_STANDARD_REQUIRED True) +# should we use our own math functions +option(USE_MYMATH "Use tutorial provided math implementation" ON) + # does this system provide the log and exp functions? include(CheckSymbolExists) set(CMAKE_REQUIRED_LIBRARIES "m") check_symbol_exists(log "math.h" HAVE_LOG) check_symbol_exists(exp "math.h" HAVE_EXP) -# should we use our own math functions -option(USE_MYMATH "Use tutorial provided math implementation" ON) - # configure a header file to pass the version number only configure_file(TutorialConfig.h.in TutorialConfig.h) diff --git a/Help/guide/tutorial/index.rst b/Help/guide/tutorial/index.rst index d893090..cbeec4d 100644 --- a/Help/guide/tutorial/index.rst +++ b/Help/guide/tutorial/index.rst @@ -253,12 +253,14 @@ requirements are: - ``target_include_directories`` - ``target_link_libraries`` -First up is MathFunctions. We first state that anybody linking to MathFunctions -needs to include the current source directory, while MathFunctions itself -doesn't. So this can become an ``INTERFACE`` usage requirement. +Let's refactor our code from `Adding a Library (Step 2)`_ to use the modern +CMake approach of usage requirements. We first state that anybody linking to +MathFunctions needs to include the current source directory, while +MathFunctions itself doesn't. So this can become an ``INTERFACE`` usage +requirement. Remember ``INTERFACE`` means things that consumers require but the producer -doesn't. Update ``MathFunctions/CMakeLists.txt`` with: +doesn't. Add the following lines to the end of ``MathFunctions/CMakeLists.txt``: .. literalinclude:: Step4/MathFunctions/CMakeLists.txt :language: cmake @@ -266,7 +268,18 @@ doesn't. Update ``MathFunctions/CMakeLists.txt`` with: Now that we've specified usage requirements for MathFunctions we can safely remove our uses of the ``EXTRA_INCLUDES`` variable from the top-level -CMakeLists. +CMakeLists, here: + +.. literalinclude:: Step4/CMakeLists.txt + :language: cmake + :start-after: # add the MathFunctions library + :end-before: # add the executable + +And here: + +.. literalinclude:: Step4/CMakeLists.txt + :language: cmake + :start-after: # so that we will find TutorialConfig.h Once this is done, run **cmake** or **cmake-gui** to configure the project and then build it with your chosen build tool or by using ``cmake --build .`` @@ -355,7 +368,7 @@ CMakeLists file as follows: .. literalinclude:: Step6/CMakeLists.txt :language: cmake :start-after: # does this system provide the log and exp functions? - :end-before: # should we use our own math functions + :end-before: # configure a header file to pass some of the CMake settings Now let's add these defines to ``TutorialConfig.h.in`` so that we can use them from ``mysqrt.cxx``: https://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=49ce4d6ff4e70026ab1da6da91d7965ef61863ab commit 49ce4d6ff4e70026ab1da6da91d7965ef61863ab Author: Betsy McPhail AuthorDate: Mon Jul 1 20:58:32 2019 -0400 Commit: Brad King CommitDate: Mon Aug 19 11:49:05 2019 -0400 Tutorial: Improve Step 2 * Fix typo in #include * Remove CMakeLists file that users should create * Clarify which files users are expected to create * Highlight the importance of configuring TutorialConfig.h.in after the MY_MATH option has been set diff --git a/Help/guide/tutorial/Complete/CMakeLists.txt b/Help/guide/tutorial/Complete/CMakeLists.txt index 26073bd..eca79d9 100644 --- a/Help/guide/tutorial/Complete/CMakeLists.txt +++ b/Help/guide/tutorial/Complete/CMakeLists.txt @@ -37,7 +37,7 @@ add_subdirectory(MathFunctions) # add the executable add_executable(Tutorial tutorial.cxx) -target_link_libraries(Tutorial MathFunctions) +target_link_libraries(Tutorial PUBLIC MathFunctions) # add the binary tree to the search path for include files # so that we will find TutorialConfig.h diff --git a/Help/guide/tutorial/Complete/TutorialConfig.h.in b/Help/guide/tutorial/Complete/TutorialConfig.h.in index 8cd2fc9..7e4d7fa 100644 --- a/Help/guide/tutorial/Complete/TutorialConfig.h.in +++ b/Help/guide/tutorial/Complete/TutorialConfig.h.in @@ -1,3 +1,3 @@ -// the configured version number +// the configured options and settings for Tutorial #define Tutorial_VERSION_MAJOR @Tutorial_VERSION_MAJOR@ #define Tutorial_VERSION_MINOR @Tutorial_VERSION_MINOR@ diff --git a/Help/guide/tutorial/MultiPackage/CMakeLists.txt b/Help/guide/tutorial/MultiPackage/CMakeLists.txt index f588820..01d417a 100644 --- a/Help/guide/tutorial/MultiPackage/CMakeLists.txt +++ b/Help/guide/tutorial/MultiPackage/CMakeLists.txt @@ -29,7 +29,7 @@ add_subdirectory(MathFunctions) # add the executable add_executable(Tutorial tutorial.cxx) -target_link_libraries(Tutorial MathFunctions) +target_link_libraries(Tutorial PUBLIC MathFunctions) # add the binary tree to the search path for include files # so that we will find TutorialConfig.h diff --git a/Help/guide/tutorial/Step10/CMakeLists.txt b/Help/guide/tutorial/Step10/CMakeLists.txt index d163936..6a59104 100644 --- a/Help/guide/tutorial/Step10/CMakeLists.txt +++ b/Help/guide/tutorial/Step10/CMakeLists.txt @@ -23,7 +23,7 @@ add_subdirectory(MathFunctions) # add the executable add_executable(Tutorial tutorial.cxx) -target_link_libraries(Tutorial MathFunctions) +target_link_libraries(Tutorial PUBLIC MathFunctions) # add the binary tree to the search path for include files # so that we will find TutorialConfig.h diff --git a/Help/guide/tutorial/Step10/MathFunctions/CMakeLists.txt b/Help/guide/tutorial/Step10/MathFunctions/CMakeLists.txt index aafd090..0ef67f1 100644 --- a/Help/guide/tutorial/Step10/MathFunctions/CMakeLists.txt +++ b/Help/guide/tutorial/Step10/MathFunctions/CMakeLists.txt @@ -43,12 +43,6 @@ if(USE_MYMATH) POSITION_INDEPENDENT_CODE ${BUILD_SHARED_LIBS} ) - target_compile_definitions(MathFunctions PRIVATE "USE_MYMATH") - if(HAVE_LOG AND HAVE_EXP) - target_compile_definitions(SqrtLibrary - PRIVATE "HAVE_LOG" "HAVE_EXP") - endif() - target_link_libraries(MathFunctions PRIVATE SqrtLibrary) endif() diff --git a/Help/guide/tutorial/Step10/TutorialConfig.h.in b/Help/guide/tutorial/Step10/TutorialConfig.h.in index 8cd2fc9..7e4d7fa 100644 --- a/Help/guide/tutorial/Step10/TutorialConfig.h.in +++ b/Help/guide/tutorial/Step10/TutorialConfig.h.in @@ -1,3 +1,3 @@ -// the configured version number +// the configured options and settings for Tutorial #define Tutorial_VERSION_MAJOR @Tutorial_VERSION_MAJOR@ #define Tutorial_VERSION_MINOR @Tutorial_VERSION_MINOR@ diff --git a/Help/guide/tutorial/Step11/CMakeLists.txt b/Help/guide/tutorial/Step11/CMakeLists.txt index 5ca2444..4763951 100644 --- a/Help/guide/tutorial/Step11/CMakeLists.txt +++ b/Help/guide/tutorial/Step11/CMakeLists.txt @@ -31,7 +31,7 @@ add_subdirectory(MathFunctions) # add the executable add_executable(Tutorial tutorial.cxx) -target_link_libraries(Tutorial MathFunctions) +target_link_libraries(Tutorial PUBLIC MathFunctions) # add the binary tree to the search path for include files # so that we will find TutorialConfig.h diff --git a/Help/guide/tutorial/Step11/TutorialConfig.h.in b/Help/guide/tutorial/Step11/TutorialConfig.h.in index 8cd2fc9..7e4d7fa 100644 --- a/Help/guide/tutorial/Step11/TutorialConfig.h.in +++ b/Help/guide/tutorial/Step11/TutorialConfig.h.in @@ -1,3 +1,3 @@ -// the configured version number +// the configured options and settings for Tutorial #define Tutorial_VERSION_MAJOR @Tutorial_VERSION_MAJOR@ #define Tutorial_VERSION_MINOR @Tutorial_VERSION_MINOR@ diff --git a/Help/guide/tutorial/Step2/MathFunctions/CMakeLists.txt b/Help/guide/tutorial/Step2/MathFunctions/CMakeLists.txt deleted file mode 100644 index 8b443a6..0000000 --- a/Help/guide/tutorial/Step2/MathFunctions/CMakeLists.txt +++ /dev/null @@ -1 +0,0 @@ -add_library(MathFunctions mysqrt.cxx) diff --git a/Help/guide/tutorial/Step2/MathFunctions/mysqrt.cxx b/Help/guide/tutorial/Step2/MathFunctions/mysqrt.cxx index 7d9379e..1e4d97a 100644 --- a/Help/guide/tutorial/Step2/MathFunctions/mysqrt.cxx +++ b/Help/guide/tutorial/Step2/MathFunctions/mysqrt.cxx @@ -1,4 +1,3 @@ -#include "MathFunctions.h" #include // a hack square root calculation using simple operations diff --git a/Help/guide/tutorial/Step3/CMakeLists.txt b/Help/guide/tutorial/Step3/CMakeLists.txt index 4d7a6e7..1c12816 100644 --- a/Help/guide/tutorial/Step3/CMakeLists.txt +++ b/Help/guide/tutorial/Step3/CMakeLists.txt @@ -14,7 +14,7 @@ option(USE_MYMATH "Use tutorial provided math implementation" ON) # to the source code configure_file(TutorialConfig.h.in TutorialConfig.h) -# add the MathFunctions library? +# add the MathFunctions library if(USE_MYMATH) add_subdirectory(MathFunctions) list(APPEND EXTRA_LIBS MathFunctions) @@ -24,7 +24,7 @@ endif() # add the executable add_executable(Tutorial tutorial.cxx) -target_link_libraries(Tutorial ${EXTRA_LIBS}) +target_link_libraries(Tutorial PUBLIC ${EXTRA_LIBS}) # add the binary tree to the search path for include files # so that we will find TutorialConfig.h diff --git a/Help/guide/tutorial/Step4/CMakeLists.txt b/Help/guide/tutorial/Step4/CMakeLists.txt index 0f24549..38e9b1f 100644 --- a/Help/guide/tutorial/Step4/CMakeLists.txt +++ b/Help/guide/tutorial/Step4/CMakeLists.txt @@ -14,7 +14,7 @@ option(USE_MYMATH "Use tutorial provided math implementation" ON) # to the source code configure_file(TutorialConfig.h.in TutorialConfig.h) -# add the MathFunctions library? +# add the MathFunctions library if(USE_MYMATH) add_subdirectory(MathFunctions) list(APPEND EXTRA_LIBS MathFunctions) diff --git a/Help/guide/tutorial/Step5/CMakeLists.txt b/Help/guide/tutorial/Step5/CMakeLists.txt index 59e575f..c3b375a 100644 --- a/Help/guide/tutorial/Step5/CMakeLists.txt +++ b/Help/guide/tutorial/Step5/CMakeLists.txt @@ -14,7 +14,7 @@ option(USE_MYMATH "Use tutorial provided math implementation" ON) # to the source code configure_file(TutorialConfig.h.in TutorialConfig.h) -# add the MathFunctions library? +# add the MathFunctions library if(USE_MYMATH) add_subdirectory(MathFunctions) list(APPEND EXTRA_LIBS MathFunctions) diff --git a/Help/guide/tutorial/Step6/CMakeLists.txt b/Help/guide/tutorial/Step6/CMakeLists.txt index fe4728a..175f99f 100644 --- a/Help/guide/tutorial/Step6/CMakeLists.txt +++ b/Help/guide/tutorial/Step6/CMakeLists.txt @@ -20,7 +20,7 @@ option(USE_MYMATH "Use tutorial provided math implementation" ON) # to the source code configure_file(TutorialConfig.h.in TutorialConfig.h) -# add the MathFunctions library? +# add the MathFunctions library if(USE_MYMATH) add_subdirectory(MathFunctions) list(APPEND EXTRA_LIBS MathFunctions) diff --git a/Help/guide/tutorial/Step7/CMakeLists.txt b/Help/guide/tutorial/Step7/CMakeLists.txt index b251aaf..d1c0d1f 100644 --- a/Help/guide/tutorial/Step7/CMakeLists.txt +++ b/Help/guide/tutorial/Step7/CMakeLists.txt @@ -20,7 +20,7 @@ option(USE_MYMATH "Use tutorial provided math implementation" ON) # to the source code configure_file(TutorialConfig.h.in TutorialConfig.h) -# add the MathFunctions library? +# add the MathFunctions library if(USE_MYMATH) add_subdirectory(MathFunctions) list(APPEND EXTRA_LIBS MathFunctions) diff --git a/Help/guide/tutorial/Step8/CMakeLists.txt b/Help/guide/tutorial/Step8/CMakeLists.txt index 0c91dab..d8e9145 100644 --- a/Help/guide/tutorial/Step8/CMakeLists.txt +++ b/Help/guide/tutorial/Step8/CMakeLists.txt @@ -20,7 +20,7 @@ option(USE_MYMATH "Use tutorial provided math implementation" ON) # to the source code configure_file(TutorialConfig.h.in TutorialConfig.h) -# add the MathFunctions library? +# add the MathFunctions library if(USE_MYMATH) add_subdirectory(MathFunctions) list(APPEND EXTRA_LIBS MathFunctions) diff --git a/Help/guide/tutorial/Step9/CMakeLists.txt b/Help/guide/tutorial/Step9/CMakeLists.txt index 5822f89..62bf1c8 100644 --- a/Help/guide/tutorial/Step9/CMakeLists.txt +++ b/Help/guide/tutorial/Step9/CMakeLists.txt @@ -19,7 +19,7 @@ option(USE_MYMATH "Use tutorial provided math implementation" ON) # configure a header file to pass the version number only configure_file(TutorialConfig.h.in TutorialConfig.h) -# add the MathFunctions library? +# add the MathFunctions library if(USE_MYMATH) add_subdirectory(MathFunctions) list(APPEND EXTRA_LIBS MathFunctions) diff --git a/Help/guide/tutorial/index.rst b/Help/guide/tutorial/index.rst index df65123..d893090 100644 --- a/Help/guide/tutorial/index.rst +++ b/Help/guide/tutorial/index.rst @@ -145,18 +145,22 @@ then use this library instead of the standard square root function provided by the compiler. For this tutorial we will put the library into a subdirectory -called MathFunctions. It will have the following one line CMakeLists file: +called MathFunctions. This directory already contains a header file, +``MathFunctions.h``, and a source file ``mysqrt.cxx``. The source file has one +function called ``mysqrt`` that provides similar functionality to the +compiler's ``sqrt`` function. -.. literalinclude:: Step2/MathFunctions/CMakeLists.txt +Add the following one line ``CMakeLists.txt`` file to the MathFunctions +directory: + +.. literalinclude:: Step3/MathFunctions/CMakeLists.txt :language: cmake -The source file ``mysqrt.cxx`` has one function called ``mysqrt`` that -provides similar functionality to the compiler?s ``sqrt`` function. To make use -of the new library we add an ``add_subdirectory`` call in the top-level -CMakeLists file so that the library will get built. We add the new library to -the executable, and add MathFunctions as an include directory so that the -``mqsqrt.h`` header file can be found. The last few lines of the top-level -CMakeLists file now look like: +To make use of the new library we will add an ``add_subdirectory`` call in the +top-level CMakeLists file so that the library will get built. We add the new +library to the executable, and add MathFunctions as an include directory so +that the ``mqsqrt.h`` header file can be found. The last few lines of the +top-level CMakeLists file should now look like: .. code-block:: cmake @@ -166,7 +170,7 @@ CMakeLists file now look like: # add the executable add_executable(Tutorial tutorial.cxx) - target_link_libraries(Tutorial MathFunctions) + target_link_libraries(Tutorial PUBLIC MathFunctions) # add the binary tree to the search path for include files # so that we will find TutorialConfig.h @@ -183,12 +187,12 @@ file. .. literalinclude:: Step3/CMakeLists.txt :language: cmake :start-after: # should we use our own math functions - :end-before: # configure a header file to pass some of the CMake settings + :end-before: # add the MathFunctions library -This will show up in the CMake GUI and ccmake with a default value of ON -that can be changed by the user. This setting will be stored in the cache so -that the user does not need to set the value each time they run CMake on this -build directory. +This option will be displayed in the CMake GUI and ccmake with a default +value of ON that can be changed by the user. This setting will be stored in +the cache so that the user does not need to set the value each time they run +CMake on a build directory. The next change is to make building and linking the MathFunctions library conditional. To do this we change the end of the top-level CMakeLists file to @@ -196,22 +200,24 @@ look like the following: .. literalinclude:: Step3/CMakeLists.txt :language: cmake - :start-after: # add the MathFunctions library? + :start-after: # add the MathFunctions library -Note the use of the variables ``EXTRA_LIBS`` and ``EXTRA_INCLUDES`` to collect -up any optional libraries to later be linked into the executable. This is a -classic approach when dealing with many optional components, we will cover the -modern approach in the next step. +Note the use of the variable ``EXTRA_LIBS`` to collect up any optional +libraries to later be linked into the executable. The variable +``EXTRA_INCLUDES`` is used similarly for optional header files. This is a +classic approach when dealing with many optional components, we will cover +the modern approach in the next step. The corresponding changes to the source code are fairly straightforward. First, -include the MathFunctions header if we need it: +in ``tutorial.cxx``, include the MathFunctions header if we need it: .. literalinclude:: Step3/tutorial.cxx :language: c++ :start-after: // should we include the MathFunctions header :end-before: int main -Then make which square root function is used dependent on ``USE_MYMATH``: +Then, in the same file, make which square root function is used dependent on +``USE_MYMATH``: .. literalinclude:: Step3/tutorial.cxx :language: c++ @@ -225,10 +231,14 @@ Since the source code now requires ``USE_MYMATH`` we can add it to :language: c :lines: 4 +**Exercise**: Why is it important that we configure ``TutorialConfig.h.in`` +after the option for ``USE_MYMATH``? What would happen if we inverted the two? + Run **cmake** or **cmake-gui** to configure the project and then build it with your chosen build tool. Then run the built Tutorial executable. -Which function gives better results, Step1?s sqrt or Step2?s mysqrt? +Use ccmake or the CMake GUI to update the value of ``USE_MYMATH``. Rebuild and +run the tutorial again. Which function gives better results, sqrt or mysqrt? Adding Usage Requirements for Library (Step 3) ============================================== @@ -375,10 +385,6 @@ After making this update, go ahead and build the project again. Run the built Tutorial executable. Which function gives better results now, Step1?s sqrt or Step5?s mysqrt? -**Exercise**: Why is it important that we configure ``TutorialConfig.h.in`` -after the checks for ``HAVE_LOG`` and ``HAVE_EXP``? What would happen if we -inverted the two? - **Exercise**: Is there a better place for us to save the ``HAVE_LOG`` and ``HAVE_EXP`` values other than in ``TutorialConfig.h``? https://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=82332f81bbb0609bf521d29c36b3ecf1566be892 commit 82332f81bbb0609bf521d29c36b3ecf1566be892 Author: Betsy McPhail AuthorDate: Tue Jul 9 13:21:40 2019 -0400 Commit: Brad King CommitDate: Mon Aug 19 11:48:58 2019 -0400 Tutorial: Improve Step 1 * Update minimum required version to 3.10 * Use VERSION argument to project command rather than separate variables * Replace `endif(USE_MYMATH)` with more modern `endif()` * Simplify the call to 'configure_file()' * Add comments to tutorial.cxx to use as anchors in documentation * Remove CMakeLists and TutorialConfig.h.in files that users should create. Consequently, remove Step1 from CMake tests. diff --git a/Help/guide/tutorial/Complete/CMakeLists.txt b/Help/guide/tutorial/Complete/CMakeLists.txt index 4541392..26073bd 100644 --- a/Help/guide/tutorial/Complete/CMakeLists.txt +++ b/Help/guide/tutorial/Complete/CMakeLists.txt @@ -1,5 +1,7 @@ cmake_minimum_required(VERSION 3.15) -project(Tutorial) + +# set the project name and version +project(Tutorial VERSION 1.0) add_library(tutorial_compiler_flags INTERFACE) target_compile_features(tutorial_compiler_flags INTERFACE cxx_std_11) @@ -13,10 +15,6 @@ target_compile_options(tutorial_compiler_flags INTERFACE "$<${msvc_cxx}:$>" ) -# set the version number -set(Tutorial_VERSION_MAJOR 1) -set(Tutorial_VERSION_MINOR 0) - # control where the static and shared libraries are built so that on windows # we don't need to tinker with the path to run the executable set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY "${PROJECT_BINARY_DIR}") @@ -32,10 +30,7 @@ elseif(UNIX) endif() # configure a header file to pass the version number only -configure_file( - "${PROJECT_SOURCE_DIR}/TutorialConfig.h.in" - "${PROJECT_BINARY_DIR}/TutorialConfig.h" - ) +configure_file(TutorialConfig.h.in TutorialConfig.h) # add the MathFunctions library add_subdirectory(MathFunctions) diff --git a/Help/guide/tutorial/Complete/tutorial.cxx b/Help/guide/tutorial/Complete/tutorial.cxx index 4451cbd..586d183 100644 --- a/Help/guide/tutorial/Complete/tutorial.cxx +++ b/Help/guide/tutorial/Complete/tutorial.cxx @@ -15,10 +15,11 @@ int main(int argc, char* argv[]) return 1; } - double inputValue = std::stod(argv[1]); + // convert input to double + const double inputValue = std::stod(argv[1]); + // calculate square root const double outputValue = mathfunctions::sqrt(inputValue); - std::cout << "The square root of " << inputValue << " is " << outputValue << std::endl; return 0; diff --git a/Help/guide/tutorial/Consumer/CMakeLists.txt b/Help/guide/tutorial/Consumer/CMakeLists.txt index 4033b4d..a0e4598 100644 --- a/Help/guide/tutorial/Consumer/CMakeLists.txt +++ b/Help/guide/tutorial/Consumer/CMakeLists.txt @@ -1,4 +1,4 @@ -cmake_minimum_required(VERSION 3.3) +cmake_minimum_required(VERSION 3.10) if(NOT DEFINED CMAKE_CXX_STANDARD) set(CMAKE_CXX_STANDARD 11) diff --git a/Help/guide/tutorial/MultiPackage/CMakeLists.txt b/Help/guide/tutorial/MultiPackage/CMakeLists.txt index bea611c..f588820 100644 --- a/Help/guide/tutorial/MultiPackage/CMakeLists.txt +++ b/Help/guide/tutorial/MultiPackage/CMakeLists.txt @@ -1,12 +1,11 @@ -cmake_minimum_required(VERSION 3.3) -project(Tutorial) +cmake_minimum_required(VERSION 3.10) + +# set the project name and version +project(Tutorial VERSION 1.0) set(CMAKE_CXX_STANDARD 11) set(CMAKE_CXX_STANDARD_REQUIRED True) -# set the version number -set(Tutorial_VERSION_MAJOR 1) -set(Tutorial_VERSION_MINOR 0) # control where the static and shared libraries are built so that on windows # we don't need to tinker with the path to run the executable @@ -23,10 +22,7 @@ elseif(UNIX) endif() # configure a header file to pass the version number only -configure_file( - "${PROJECT_SOURCE_DIR}/TutorialConfig.h.in" - "${PROJECT_BINARY_DIR}/TutorialConfig.h" - ) +configure_file(TutorialConfig.h.in TutorialConfig.h) # add the MathFunctions library add_subdirectory(MathFunctions) diff --git a/Help/guide/tutorial/MultiPackage/tutorial.cxx b/Help/guide/tutorial/MultiPackage/tutorial.cxx index 4451cbd..ddc6364 100644 --- a/Help/guide/tutorial/MultiPackage/tutorial.cxx +++ b/Help/guide/tutorial/MultiPackage/tutorial.cxx @@ -15,6 +15,7 @@ int main(int argc, char* argv[]) return 1; } + // convert input to double double inputValue = std::stod(argv[1]); const double outputValue = mathfunctions::sqrt(inputValue); diff --git a/Help/guide/tutorial/Step1/CMakeLists.txt b/Help/guide/tutorial/Step1/CMakeLists.txt deleted file mode 100644 index 141f0c2..0000000 --- a/Help/guide/tutorial/Step1/CMakeLists.txt +++ /dev/null @@ -1,3 +0,0 @@ -project(Tutorial) - -add_executable(Tutorial tutorial.cxx) diff --git a/Help/guide/tutorial/Step1/TutorialConfig.h.in b/Help/guide/tutorial/Step1/TutorialConfig.h.in deleted file mode 100644 index 7e4d7fa..0000000 --- a/Help/guide/tutorial/Step1/TutorialConfig.h.in +++ /dev/null @@ -1,3 +0,0 @@ -// the configured options and settings for Tutorial -#define Tutorial_VERSION_MAJOR @Tutorial_VERSION_MAJOR@ -#define Tutorial_VERSION_MINOR @Tutorial_VERSION_MINOR@ diff --git a/Help/guide/tutorial/Step1/tutorial.cxx b/Help/guide/tutorial/Step1/tutorial.cxx index f8dd0c6..08323bf 100644 --- a/Help/guide/tutorial/Step1/tutorial.cxx +++ b/Help/guide/tutorial/Step1/tutorial.cxx @@ -11,9 +11,11 @@ int main(int argc, char* argv[]) return 1; } - double inputValue = atof(argv[1]); + // convert input to double + const double inputValue = atof(argv[1]); - double outputValue = sqrt(inputValue); + // calculate square root + const double outputValue = sqrt(inputValue); std::cout << "The square root of " << inputValue << " is " << outputValue << std::endl; return 0; diff --git a/Help/guide/tutorial/Step10/CMakeLists.txt b/Help/guide/tutorial/Step10/CMakeLists.txt index 25bc0c1..d163936 100644 --- a/Help/guide/tutorial/Step10/CMakeLists.txt +++ b/Help/guide/tutorial/Step10/CMakeLists.txt @@ -1,13 +1,12 @@ -cmake_minimum_required(VERSION 3.3) -project(Tutorial) +cmake_minimum_required(VERSION 3.10) +# set the project name and version +project(Tutorial VERSION 1.0) + +# specify the C++ standard set(CMAKE_CXX_STANDARD 11) set(CMAKE_CXX_STANDARD_REQUIRED True) -# Set the version number -set(Tutorial_VERSION_MAJOR 1) -set(Tutorial_VERSION_MINOR 0) - # control where the static and shared libraries are built so that on windows # we don't need to tinker with the path to run the executable set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY "${PROJECT_BINARY_DIR}") @@ -17,10 +16,7 @@ set(CMAKE_RUNTIME_OUTPUT_DIRECTORY "${PROJECT_BINARY_DIR}") option(BUILD_SHARED_LIBS "Build using shared libraries" ON) # configure a header file to pass the version number only -configure_file( - "${PROJECT_SOURCE_DIR}/TutorialConfig.h.in" - "${PROJECT_BINARY_DIR}/TutorialConfig.h" - ) +configure_file(TutorialConfig.h.in TutorialConfig.h) # add the MathFunctions library add_subdirectory(MathFunctions) diff --git a/Help/guide/tutorial/Step10/tutorial.cxx b/Help/guide/tutorial/Step10/tutorial.cxx index 42eaab9..37a0333 100644 --- a/Help/guide/tutorial/Step10/tutorial.cxx +++ b/Help/guide/tutorial/Step10/tutorial.cxx @@ -16,7 +16,8 @@ int main(int argc, char* argv[]) return 1; } - double inputValue = std::stod(argv[1]); + // convert input to double + const double inputValue = std::stod(argv[1]); const double outputValue = mathfunctions::sqrt(inputValue); diff --git a/Help/guide/tutorial/Step11/CMakeLists.txt b/Help/guide/tutorial/Step11/CMakeLists.txt index e54bdde..5ca2444 100644 --- a/Help/guide/tutorial/Step11/CMakeLists.txt +++ b/Help/guide/tutorial/Step11/CMakeLists.txt @@ -1,5 +1,7 @@ cmake_minimum_required(VERSION 3.15) -project(Tutorial) + +# set the project name and version +project(Tutorial VERSION 1.0) add_library(tutorial_compiler_flags INTERFACE) target_compile_features(tutorial_compiler_flags INTERFACE cxx_std_11) @@ -13,10 +15,6 @@ target_compile_options(tutorial_compiler_flags INTERFACE "$<${msvc_cxx}:$>" ) -# set the version number -set(Tutorial_VERSION_MAJOR 1) -set(Tutorial_VERSION_MINOR 0) - # control where the static and shared libraries are built so that on windows # we don't need to tinker with the path to run the executable set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY "${PROJECT_BINARY_DIR}") @@ -26,10 +24,7 @@ set(CMAKE_RUNTIME_OUTPUT_DIRECTORY "${PROJECT_BINARY_DIR}") option(BUILD_SHARED_LIBS "Build using shared libraries" ON) # configure a header file to pass the version number only -configure_file( - "${PROJECT_SOURCE_DIR}/TutorialConfig.h.in" - "${PROJECT_BINARY_DIR}/TutorialConfig.h" - ) +configure_file(TutorialConfig.h.in TutorialConfig.h) # add the MathFunctions library add_subdirectory(MathFunctions) diff --git a/Help/guide/tutorial/Step11/tutorial.cxx b/Help/guide/tutorial/Step11/tutorial.cxx index 6acafd2..a3a2bdc 100644 --- a/Help/guide/tutorial/Step11/tutorial.cxx +++ b/Help/guide/tutorial/Step11/tutorial.cxx @@ -16,7 +16,8 @@ int main(int argc, char* argv[]) return 1; } - double inputValue = std::stod(argv[1]); + // convert input to double + const double inputValue = std::stod(argv[1]); const double outputValue = mathfunctions::sqrt(inputValue); diff --git a/Help/guide/tutorial/Step2/CMakeLists.txt b/Help/guide/tutorial/Step2/CMakeLists.txt index 059b89a..7aa59e9 100644 --- a/Help/guide/tutorial/Step2/CMakeLists.txt +++ b/Help/guide/tutorial/Step2/CMakeLists.txt @@ -1,19 +1,15 @@ -cmake_minimum_required(VERSION 3.3) -project(Tutorial) +cmake_minimum_required(VERSION 3.10) +# set the project name and version +project(Tutorial VERSION 1.0) + +# specify the C++ standard set(CMAKE_CXX_STANDARD 11) set(CMAKE_CXX_STANDARD_REQUIRED True) -# set the version number -set(Tutorial_VERSION_MAJOR 1) -set(Tutorial_VERSION_MINOR 0) - # configure a header file to pass some of the CMake settings # to the source code -configure_file( - "${PROJECT_SOURCE_DIR}/TutorialConfig.h.in" - "${PROJECT_BINARY_DIR}/TutorialConfig.h" - ) +configure_file(TutorialConfig.h.in TutorialConfig.h) # add the executable add_executable(Tutorial tutorial.cxx) diff --git a/Help/guide/tutorial/Step2/tutorial.cxx b/Help/guide/tutorial/Step2/tutorial.cxx index f2ab446..53b0810 100644 --- a/Help/guide/tutorial/Step2/tutorial.cxx +++ b/Help/guide/tutorial/Step2/tutorial.cxx @@ -15,9 +15,11 @@ int main(int argc, char* argv[]) return 1; } - double inputValue = std::stod(argv[1]); + // convert input to double + const double inputValue = std::stod(argv[1]); - double outputValue = sqrt(inputValue); + // calculate square root + const double outputValue = sqrt(inputValue); std::cout << "The square root of " << inputValue << " is " << outputValue << std::endl; return 0; diff --git a/Help/guide/tutorial/Step3/CMakeLists.txt b/Help/guide/tutorial/Step3/CMakeLists.txt index 9804abf..4d7a6e7 100644 --- a/Help/guide/tutorial/Step3/CMakeLists.txt +++ b/Help/guide/tutorial/Step3/CMakeLists.txt @@ -1,29 +1,25 @@ -cmake_minimum_required(VERSION 3.3) -project(Tutorial) +cmake_minimum_required(VERSION 3.10) +# set the project name and version +project(Tutorial VERSION 1.0) + +# specify the C++ standard set(CMAKE_CXX_STANDARD 11) set(CMAKE_CXX_STANDARD_REQUIRED True) # should we use our own math functions option(USE_MYMATH "Use tutorial provided math implementation" ON) -# set the version number -set(Tutorial_VERSION_MAJOR 1) -set(Tutorial_VERSION_MINOR 0) - # configure a header file to pass some of the CMake settings # to the source code -configure_file( - "${PROJECT_SOURCE_DIR}/TutorialConfig.h.in" - "${PROJECT_BINARY_DIR}/TutorialConfig.h" - ) +configure_file(TutorialConfig.h.in TutorialConfig.h) # add the MathFunctions library? if(USE_MYMATH) add_subdirectory(MathFunctions) list(APPEND EXTRA_LIBS MathFunctions) list(APPEND EXTRA_INCLUDES "${PROJECT_SOURCE_DIR}/MathFunctions") -endif(USE_MYMATH) +endif() # add the executable add_executable(Tutorial tutorial.cxx) diff --git a/Help/guide/tutorial/Step3/tutorial.cxx b/Help/guide/tutorial/Step3/tutorial.cxx index 8156a9c..b3c6a4f 100644 --- a/Help/guide/tutorial/Step3/tutorial.cxx +++ b/Help/guide/tutorial/Step3/tutorial.cxx @@ -20,13 +20,14 @@ int main(int argc, char* argv[]) return 1; } - double inputValue = std::stod(argv[1]); + // convert input to double + const double inputValue = std::stod(argv[1]); // which square root function should we use? #ifdef USE_MYMATH - double outputValue = mysqrt(inputValue); + const double outputValue = mysqrt(inputValue); #else - double outputValue = sqrt(inputValue); + const double outputValue = sqrt(inputValue); #endif std::cout << "The square root of " << inputValue << " is " << outputValue diff --git a/Help/guide/tutorial/Step4/CMakeLists.txt b/Help/guide/tutorial/Step4/CMakeLists.txt index 0ae2648..0f24549 100644 --- a/Help/guide/tutorial/Step4/CMakeLists.txt +++ b/Help/guide/tutorial/Step4/CMakeLists.txt @@ -1,28 +1,24 @@ -cmake_minimum_required(VERSION 3.3) -project(Tutorial) +cmake_minimum_required(VERSION 3.10) +# set the project name and version +project(Tutorial VERSION 1.0) + +# specify the C++ standard set(CMAKE_CXX_STANDARD 11) set(CMAKE_CXX_STANDARD_REQUIRED True) # should we use our own math functions option(USE_MYMATH "Use tutorial provided math implementation" ON) -# set the version number -set(Tutorial_VERSION_MAJOR 1) -set(Tutorial_VERSION_MINOR 0) - # configure a header file to pass some of the CMake settings # to the source code -configure_file( - "${PROJECT_SOURCE_DIR}/TutorialConfig.h.in" - "${PROJECT_BINARY_DIR}/TutorialConfig.h" - ) +configure_file(TutorialConfig.h.in TutorialConfig.h) # add the MathFunctions library? if(USE_MYMATH) add_subdirectory(MathFunctions) list(APPEND EXTRA_LIBS MathFunctions) -endif(USE_MYMATH) +endif() # add the executable add_executable(Tutorial tutorial.cxx) diff --git a/Help/guide/tutorial/Step4/tutorial.cxx b/Help/guide/tutorial/Step4/tutorial.cxx index 8156a9c..b3c6a4f 100644 --- a/Help/guide/tutorial/Step4/tutorial.cxx +++ b/Help/guide/tutorial/Step4/tutorial.cxx @@ -20,13 +20,14 @@ int main(int argc, char* argv[]) return 1; } - double inputValue = std::stod(argv[1]); + // convert input to double + const double inputValue = std::stod(argv[1]); // which square root function should we use? #ifdef USE_MYMATH - double outputValue = mysqrt(inputValue); + const double outputValue = mysqrt(inputValue); #else - double outputValue = sqrt(inputValue); + const double outputValue = sqrt(inputValue); #endif std::cout << "The square root of " << inputValue << " is " << outputValue diff --git a/Help/guide/tutorial/Step5/CMakeLists.txt b/Help/guide/tutorial/Step5/CMakeLists.txt index dac9b45..59e575f 100644 --- a/Help/guide/tutorial/Step5/CMakeLists.txt +++ b/Help/guide/tutorial/Step5/CMakeLists.txt @@ -1,22 +1,18 @@ -cmake_minimum_required(VERSION 3.3) -project(Tutorial) +cmake_minimum_required(VERSION 3.10) +# set the project name and version +project(Tutorial VERSION 1.0) + +# specify the C++ standard set(CMAKE_CXX_STANDARD 11) set(CMAKE_CXX_STANDARD_REQUIRED True) # should we use our own math functions option(USE_MYMATH "Use tutorial provided math implementation" ON) -# set the version number -set(Tutorial_VERSION_MAJOR 1) -set(Tutorial_VERSION_MINOR 0) - # configure a header file to pass some of the CMake settings # to the source code -configure_file( - "${PROJECT_SOURCE_DIR}/TutorialConfig.h.in" - "${PROJECT_BINARY_DIR}/TutorialConfig.h" - ) +configure_file(TutorialConfig.h.in TutorialConfig.h) # add the MathFunctions library? if(USE_MYMATH) diff --git a/Help/guide/tutorial/Step5/tutorial.cxx b/Help/guide/tutorial/Step5/tutorial.cxx index 8156a9c..b3c6a4f 100644 --- a/Help/guide/tutorial/Step5/tutorial.cxx +++ b/Help/guide/tutorial/Step5/tutorial.cxx @@ -20,13 +20,14 @@ int main(int argc, char* argv[]) return 1; } - double inputValue = std::stod(argv[1]); + // convert input to double + const double inputValue = std::stod(argv[1]); // which square root function should we use? #ifdef USE_MYMATH - double outputValue = mysqrt(inputValue); + const double outputValue = mysqrt(inputValue); #else - double outputValue = sqrt(inputValue); + const double outputValue = sqrt(inputValue); #endif std::cout << "The square root of " << inputValue << " is " << outputValue diff --git a/Help/guide/tutorial/Step6/CMakeLists.txt b/Help/guide/tutorial/Step6/CMakeLists.txt index 1465e46..fe4728a 100644 --- a/Help/guide/tutorial/Step6/CMakeLists.txt +++ b/Help/guide/tutorial/Step6/CMakeLists.txt @@ -1,13 +1,12 @@ -cmake_minimum_required(VERSION 3.3) -project(Tutorial) +cmake_minimum_required(VERSION 3.10) +# set the project name and version +project(Tutorial VERSION 1.0) + +# specify the C++ standard set(CMAKE_CXX_STANDARD 11) set(CMAKE_CXX_STANDARD_REQUIRED True) -# set the version number -set(Tutorial_VERSION_MAJOR 1) -set(Tutorial_VERSION_MINOR 0) - # does this system provide the log and exp functions? include(CheckSymbolExists) set(CMAKE_REQUIRED_LIBRARIES "m") @@ -19,10 +18,7 @@ option(USE_MYMATH "Use tutorial provided math implementation" ON) # configure a header file to pass some of the CMake settings # to the source code -configure_file( - "${PROJECT_SOURCE_DIR}/TutorialConfig.h.in" - "${PROJECT_BINARY_DIR}/TutorialConfig.h" - ) +configure_file(TutorialConfig.h.in TutorialConfig.h) # add the MathFunctions library? if(USE_MYMATH) diff --git a/Help/guide/tutorial/Step6/tutorial.cxx b/Help/guide/tutorial/Step6/tutorial.cxx index 8156a9c..b3c6a4f 100644 --- a/Help/guide/tutorial/Step6/tutorial.cxx +++ b/Help/guide/tutorial/Step6/tutorial.cxx @@ -20,13 +20,14 @@ int main(int argc, char* argv[]) return 1; } - double inputValue = std::stod(argv[1]); + // convert input to double + const double inputValue = std::stod(argv[1]); // which square root function should we use? #ifdef USE_MYMATH - double outputValue = mysqrt(inputValue); + const double outputValue = mysqrt(inputValue); #else - double outputValue = sqrt(inputValue); + const double outputValue = sqrt(inputValue); #endif std::cout << "The square root of " << inputValue << " is " << outputValue diff --git a/Help/guide/tutorial/Step7/CMakeLists.txt b/Help/guide/tutorial/Step7/CMakeLists.txt index a1efa77..b251aaf 100644 --- a/Help/guide/tutorial/Step7/CMakeLists.txt +++ b/Help/guide/tutorial/Step7/CMakeLists.txt @@ -1,13 +1,12 @@ -cmake_minimum_required(VERSION 3.3) -project(Tutorial) +cmake_minimum_required(VERSION 3.10) +# set the project name and version +project(Tutorial VERSION 1.0) + +# specify the C++ standard set(CMAKE_CXX_STANDARD 11) set(CMAKE_CXX_STANDARD_REQUIRED True) -# set the version number -set(Tutorial_VERSION_MAJOR 1) -set(Tutorial_VERSION_MINOR 0) - # does this system provide the log and exp functions? include(CheckSymbolExists) set(CMAKE_REQUIRED_LIBRARIES "m") @@ -19,16 +18,13 @@ option(USE_MYMATH "Use tutorial provided math implementation" ON) # configure a header file to pass some of the CMake settings # to the source code -configure_file( - "${PROJECT_SOURCE_DIR}/TutorialConfig.h.in" - "${PROJECT_BINARY_DIR}/TutorialConfig.h" - ) +configure_file(TutorialConfig.h.in TutorialConfig.h) # add the MathFunctions library? if(USE_MYMATH) add_subdirectory(MathFunctions) list(APPEND EXTRA_LIBS MathFunctions) -endif(USE_MYMATH) +endif() # add the executable add_executable(Tutorial tutorial.cxx) diff --git a/Help/guide/tutorial/Step7/tutorial.cxx b/Help/guide/tutorial/Step7/tutorial.cxx index 8156a9c..b3c6a4f 100644 --- a/Help/guide/tutorial/Step7/tutorial.cxx +++ b/Help/guide/tutorial/Step7/tutorial.cxx @@ -20,13 +20,14 @@ int main(int argc, char* argv[]) return 1; } - double inputValue = std::stod(argv[1]); + // convert input to double + const double inputValue = std::stod(argv[1]); // which square root function should we use? #ifdef USE_MYMATH - double outputValue = mysqrt(inputValue); + const double outputValue = mysqrt(inputValue); #else - double outputValue = sqrt(inputValue); + const double outputValue = sqrt(inputValue); #endif std::cout << "The square root of " << inputValue << " is " << outputValue diff --git a/Help/guide/tutorial/Step8/CMakeLists.txt b/Help/guide/tutorial/Step8/CMakeLists.txt index a0316a0..0c91dab 100644 --- a/Help/guide/tutorial/Step8/CMakeLists.txt +++ b/Help/guide/tutorial/Step8/CMakeLists.txt @@ -1,13 +1,12 @@ -cmake_minimum_required(VERSION 3.3) -project(Tutorial) +cmake_minimum_required(VERSION 3.10) +# set the project name and version +project(Tutorial VERSION 1.0) + +# specify the C++ standard set(CMAKE_CXX_STANDARD 11) set(CMAKE_CXX_STANDARD_REQUIRED True) -# set the version number -set(Tutorial_VERSION_MAJOR 1) -set(Tutorial_VERSION_MINOR 0) - # does this system provide the log and exp functions? include(CheckSymbolExists) set(CMAKE_REQUIRED_LIBRARIES "m") @@ -19,16 +18,13 @@ option(USE_MYMATH "Use tutorial provided math implementation" ON) # configure a header file to pass some of the CMake settings # to the source code -configure_file( - "${PROJECT_SOURCE_DIR}/TutorialConfig.h.in" - "${PROJECT_BINARY_DIR}/TutorialConfig.h" - ) +configure_file(TutorialConfig.h.in TutorialConfig.h) # add the MathFunctions library? if(USE_MYMATH) add_subdirectory(MathFunctions) list(APPEND EXTRA_LIBS MathFunctions) -endif(USE_MYMATH) +endif() # add the executable add_executable(Tutorial tutorial.cxx) diff --git a/Help/guide/tutorial/Step8/tutorial.cxx b/Help/guide/tutorial/Step8/tutorial.cxx index 8156a9c..b3c6a4f 100644 --- a/Help/guide/tutorial/Step8/tutorial.cxx +++ b/Help/guide/tutorial/Step8/tutorial.cxx @@ -20,13 +20,14 @@ int main(int argc, char* argv[]) return 1; } - double inputValue = std::stod(argv[1]); + // convert input to double + const double inputValue = std::stod(argv[1]); // which square root function should we use? #ifdef USE_MYMATH - double outputValue = mysqrt(inputValue); + const double outputValue = mysqrt(inputValue); #else - double outputValue = sqrt(inputValue); + const double outputValue = sqrt(inputValue); #endif std::cout << "The square root of " << inputValue << " is " << outputValue diff --git a/Help/guide/tutorial/Step9/CMakeLists.txt b/Help/guide/tutorial/Step9/CMakeLists.txt index e610b99..5822f89 100644 --- a/Help/guide/tutorial/Step9/CMakeLists.txt +++ b/Help/guide/tutorial/Step9/CMakeLists.txt @@ -1,13 +1,12 @@ -cmake_minimum_required(VERSION 3.3) -project(Tutorial) +cmake_minimum_required(VERSION 3.10) +# set the project name and version +project(Tutorial VERSION 1.0) + +# specify the C++ standard set(CMAKE_CXX_STANDARD 11) set(CMAKE_CXX_STANDARD_REQUIRED True) -# set the version number -set(Tutorial_VERSION_MAJOR 1) -set(Tutorial_VERSION_MINOR 0) - # does this system provide the log and exp functions? include(CheckSymbolExists) set(CMAKE_REQUIRED_LIBRARIES "m") @@ -18,10 +17,7 @@ check_symbol_exists(exp "math.h" HAVE_EXP) option(USE_MYMATH "Use tutorial provided math implementation" ON) # configure a header file to pass the version number only -configure_file( - "${PROJECT_SOURCE_DIR}/TutorialConfig.h.in" - "${PROJECT_BINARY_DIR}/TutorialConfig.h" - ) +configure_file(TutorialConfig.h.in TutorialConfig.h) # add the MathFunctions library? if(USE_MYMATH) diff --git a/Help/guide/tutorial/Step9/tutorial.cxx b/Help/guide/tutorial/Step9/tutorial.cxx index 3286bc8..779fbca 100644 --- a/Help/guide/tutorial/Step9/tutorial.cxx +++ b/Help/guide/tutorial/Step9/tutorial.cxx @@ -21,13 +21,14 @@ int main(int argc, char* argv[]) return 1; } - double inputValue = std::stod(argv[1]); + // convert input to double + const double inputValue = std::stod(argv[1]); // which square root function should we use? #ifdef USE_MYMATH - double outputValue = mysqrt(inputValue); + const double outputValue = mysqrt(inputValue); #else - double outputValue = sqrt(inputValue); + const double outputValue = sqrt(inputValue); #endif std::cout << "The square root of " << inputValue << " is " << outputValue diff --git a/Help/guide/tutorial/index.rst b/Help/guide/tutorial/index.rst index 068499e..df65123 100644 --- a/Help/guide/tutorial/index.rst +++ b/Help/guide/tutorial/index.rst @@ -5,33 +5,38 @@ CMake Tutorial .. contents:: -This tutorial provides a step-by-step guide that covers common build +The CMake tutorial provides a step-by-step guide that covers common build system issues that CMake helps address. Seeing how various topics all -work together in an example project can be very helpful. This tutorial -can be found in the ``Help/guide/tutorial`` directory of the CMake -source code tree. Each topic has its own subdirectory containing code -that may be used as a starting point for that step. The tutorial -examples are progressive so that each step provides the complete +work together in an example project can be very helpful. The tutorial +documentation and source code for examples can be found in the +``Help/guide/tutorial`` directory of the CMake source code tree. Each step has +its own subdirectory containing code that may be used as a starting point. The +tutorial examples are progressive so that each step provides the complete solution for the previous step. A Basic Starting Point (Step 1) =============================== The most basic project is an executable built from source code files. -For simple projects, a two line CMakeLists file is all that is required. -This will be the starting point for our tutorial. The CMakeLists file -looks like: +For simple projects, a three line CMakeLists file is all that is required. +This will be the starting point for our tutorial. Create a ``CMakeLists.txt`` +file in the ``Step1`` directory that looks like: + +.. code-block:: cmake + + cmake_minimum_required(VERSION 3.10) + + # set the project name + project(Tutorial) + + # add the executable + add_executable(Tutorial tutorial.cxx) -.. literalinclude:: Step1/CMakeLists.txt - :language: cmake Note that this example uses lower case commands in the CMakeLists file. Upper, lower, and mixed case commands are supported by CMake. The source -code for ``tutorial.cxx`` will compute the square root of a number and -the first version of it is very simple, as follows: - -.. literalinclude:: Step1/tutorial.cxx - :language: c++ +code for ``tutorial.cxx`` is provided in the ``Step1`` directory and can be +used to compute the square root of a number. Adding a Version Number and Configured Header File -------------------------------------------------- @@ -40,55 +45,70 @@ The first feature we will add is to provide our executable and project with a version number. While we could do this exclusively in the source code, using CMakeLists provides more flexibility. -To add a version number we modify the CMakeLists file as follows: +First, modify the CMakeLists file to set the version number. + +.. literalinclude:: Step2/CMakeLists.txt + :language: cmake + :end-before: # specify the C++ standard + +Then, configure a header file to pass the version number to the source +code: .. literalinclude:: Step2/CMakeLists.txt :language: cmake - :start-after: # set the version number - :end-before: # configure a header file + :start-after: # to the source code + :end-before: # add the executable Since the configured file will be written into the binary tree, we must add that directory to the list of paths to search for include -files. +files. Add the following lines to the end of the CMakeLists file: .. literalinclude:: Step2/CMakeLists.txt :language: cmake :start-after: # so that we will find TutorialConfig.h -We then create a ``TutorialConfig.h.in`` file in the source tree with the -following contents: +Using your favorite editor, create ``TutorialConfig.h.in`` in the source +directory with the following contents: -.. literalinclude:: Step1/TutorialConfig.h.in +.. literalinclude:: Step2/TutorialConfig.h.in :language: cmake When CMake configures this header file the values for ``@Tutorial_VERSION_MAJOR@`` and ``@Tutorial_VERSION_MINOR@`` will be -replaced by the values from the CMakeLists file. Next we modify -``tutorial.cxx`` to include the configured header file and to make use of the -version numbers. The updated source code is listed below. +replaced. + +Next modify ``tutorial.cxx`` to include the configured header file, +``TutorialConfig.h``. + +Finally, let's print out the version number by updating ``tutorial.cxx`` as +follows: .. literalinclude:: Step2/tutorial.cxx :language: c++ - :start-after: // report version - :end-before: return 1; - -The main changes are the inclusion of the ``TutorialConfig.h`` header -file and printing out a version number as part of the usage message. + :start-after: { + :end-before: // convert input to double Specify the C++ Standard ------------------------- -Next let's add some C++11 features to our project. We will need to explicitly -state in the CMake code that it should use the correct flags. The easiest way -to enable C++11 support for CMake is by using the ``CMAKE_CXX_STANDARD`` -variable. +Next let's add some C++11 features to our project by replacing ``atof`` with +``std::stod`` in ``tutorial.cxx``. At the same time, remove +``#include ``. -First, replace ``atof`` with ``std::stod`` in ``tutorial.cxx``. +.. literalinclude:: Step2/tutorial.cxx + :language: c++ + :start-after: // convert input to double + :end-before: // calculate square root -Then, set the ``CMAKE_CXX_STANDARD`` variable in the CMakeLists file. +We will need to explicitly state in the CMake code that it should use the +correct flags. The easiest way to enable support for a specific C++ standard +in CMake is by using the ``CMAKE_CXX_STANDARD`` variable. For this tutorial, +set the ``CMAKE_CXX_STANDARD`` variable in the CMakeLists file to 11 and +``CMAKE_CXX_STANDARD_REQUIRED`` to True: -Which variable can we set in the CMakeLists file to treat the -``CMAKE_CXX_STANDARD`` value as a requirement? +.. literalinclude:: Step2/CMakeLists.txt + :language: cmake + :end-before: # configure a header file to pass some of the CMake settings Build and Test -------------- @@ -96,8 +116,19 @@ Build and Test Run **cmake** or **cmake-gui** to configure the project and then build it with your chosen build tool. -cd to the directory where Tutorial was built (likely the make directory or -a Debug or Release build configuration subdirectory) and run these commands: +For example, from the command line we could navigate to the +``Help/guide/tutorial`` directory of the CMake source code tree and run the +following commands: + +.. code-block:: console + + mkdir Step1_build + cd Step1_build + cmake ../Step1 + cmake --build . + +Navigate to the directory where Tutorial was built (likely the make directory +or a Debug or Release build configuration subdirectory) and run these commands: .. code-block:: console @@ -152,7 +183,7 @@ file. .. literalinclude:: Step3/CMakeLists.txt :language: cmake :start-after: # should we use our own math functions - :end-before: # set the version number + :end-before: # configure a header file to pass some of the CMake settings This will show up in the CMake GUI and ccmake with a default value of ON that can be changed by the user. This setting will be stored in the cache so @@ -531,7 +562,7 @@ The first step is to update the starting section of the top-level .. literalinclude:: Step10/CMakeLists.txt :language: cmake - :start-after: set(Tutorial_VERSION_MINOR + :start-after: set(CMAKE_CXX_STANDARD 14) :end-before: # add the binary tree Now that we have made MathFunctions always be used, we will need to update @@ -609,14 +640,14 @@ So the following code: .. literalinclude:: Step10/CMakeLists.txt :language: cmake - :start-after: project(Tutorial) - :end-before: # Set the version number + :start-after: project(Tutorial VERSION 1.0) + :end-before: # control where the static and shared libraries are built so that on windows Would be replaced with: .. literalinclude:: Step11/CMakeLists.txt :language: cmake - :start-after: project(Tutorial) + :start-after: project(Tutorial VERSION 1.0) :end-before: # add compiler warning flags just when building this project via @@ -629,7 +660,7 @@ below: .. literalinclude:: Step11/CMakeLists.txt :language: cmake :start-after: # the BUILD_INTERFACE genex - :end-before: # set the version number + :end-before: # control where the static and shared libraries are built so that on windows Looking at this we see that the warning flags are encapsulated inside a ``BUILD_INTERFACE`` condition. This is done so that consumers of our installed diff --git a/Tests/CMakeLists.txt b/Tests/CMakeLists.txt index 5b8f255..0354666 100644 --- a/Tests/CMakeLists.txt +++ b/Tests/CMakeLists.txt @@ -1597,7 +1597,7 @@ ${CMake_SOURCE_DIR}/Utilities/Release/push.bash --dir dev -- '${CMake_BUILD_NIGH endfunction() if(NOT CMake_TEST_EXTERNAL_CMAKE) - foreach(STP RANGE 1 11) + foreach(STP RANGE 2 11) add_tutorial_test(Step${STP} TRUE) endforeach() add_tutorial_test(Complete TRUE) @@ -2129,8 +2129,8 @@ ${CMake_SOURCE_DIR}/Utilities/Release/push.bash --dir dev -- '${CMake_BUILD_NIGH macro(add_test_VSWinCE name generator systemName systemVersion generatorPlatform) # TODO: Fix the tutorial to make it work in cross compile # currently the MakeTable is build for target and can not be used on the host - # This happens in part 5 so we build only part 1-4 of the tutorial - foreach(STP RANGE 1 4) + # This happens in part 5 so we build only through part 4 of the tutorial. + foreach(STP RANGE 2 4) add_test(NAME "TutorialStep${STP}.${name}" COMMAND ${CMAKE_CTEST_COMMAND} --build-and-test "${CMake_SOURCE_DIR}/Help/guide/tutorial/Step${STP}" https://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=d56a4b16ca6f09d099c2ec832b11708f9b4b9819 commit d56a4b16ca6f09d099c2ec832b11708f9b4b9819 Author: Brad King AuthorDate: Mon Aug 19 11:41:32 2019 -0400 Commit: Brad King CommitDate: Mon Aug 19 11:41:32 2019 -0400 Help: Restore installation of top-level index We removed installation of `Help/index.rst` in commit d2fde94809 (Help: Add infrastructure for guide-level documentation, 2019-05-30), but the file is required for `--help-full` to work. Restore installation of the file and update it to avoid referencing the `Help/guide` directory in its toctree during processing by `cmRST`. diff --git a/CMakeLists.txt b/CMakeLists.txt index 75ac8bf..5e3d39d 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -813,7 +813,7 @@ if(NOT CMake_TEST_EXTERNAL_CMAKE) PATTERN "*.sh*" PERMISSIONS OWNER_READ OWNER_EXECUTE OWNER_WRITE GROUP_READ GROUP_EXECUTE WORLD_READ WORLD_EXECUTE - REGEX "Help/(dev|guide|index.rst)($|/)" EXCLUDE + REGEX "Help/(dev|guide)($|/)" EXCLUDE ) # Install auxiliary files integrating with other tools. diff --git a/Help/index.rst b/Help/index.rst index cf1d2f1..cc6cee6 100644 --- a/Help/index.rst +++ b/Help/index.rst @@ -44,13 +44,15 @@ Reference Manuals /manual/cmake-variables.7 /manual/cpack-generators.7 -Guides -###### +.. only:: not man -.. toctree:: - :maxdepth: 1 + Guides + ###### + + .. toctree:: + :maxdepth: 1 - /guide/tutorial/index + /guide/tutorial/index .. only:: html or text https://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=3c94069660112f841df3bae66891e05bfc7bad00 commit 3c94069660112f841df3bae66891e05bfc7bad00 Author: Igor Ivanov AuthorDate: Sat Aug 10 11:41:53 2019 +0300 Commit: Igor Ivanov CommitDate: Sat Aug 10 11:41:53 2019 +0300 Add --trace-redirect parameter to redirect trace output to a file diff --git a/Help/manual/cmake.1.rst b/Help/manual/cmake.1.rst index 68d88e7..26ef904 100644 --- a/Help/manual/cmake.1.rst +++ b/Help/manual/cmake.1.rst @@ -238,6 +238,9 @@ Options Multiple options are allowed. +``--trace-redirect=`` + Put cmake in trace mode and redirect trace output to a file instead of stderr. + ``--warn-uninitialized`` Warn about uninitialized values. diff --git a/Help/release/dev/trace-redirect.rst b/Help/release/dev/trace-redirect.rst new file mode 100644 index 0000000..410021e --- /dev/null +++ b/Help/release/dev/trace-redirect.rst @@ -0,0 +1,6 @@ +trace-redirect +-------------- + +* :manual:`cmake(1)` gained a ``--trace-redirect=`` command line option + that can be used to redirect ``--trace`` output to a file instead + of ``stderr``. diff --git a/Source/cmMakefile.cxx b/Source/cmMakefile.cxx index 015453a..ea42289 100644 --- a/Source/cmMakefile.cxx +++ b/Source/cmMakefile.cxx @@ -23,6 +23,7 @@ #include "cmExpandedCommandArgument.h" // IWYU pragma: keep #include "cmFileLockPool.h" #include "cmFunctionBlocker.h" +#include "cmGeneratedFileStream.h" #include "cmGeneratorExpression.h" #include "cmGeneratorExpressionEvaluationFile.h" #include "cmGlobalGenerator.h" @@ -321,7 +322,13 @@ void cmMakefile::PrintCommandTrace(const cmListFileFunction& lff) const msg << " "; } msg << ")"; - cmSystemTools::Message(msg.str()); + + auto& f = this->GetCMakeInstance()->GetTraceFile(); + if (f) { + f << msg.str() << '\n'; + } else { + cmSystemTools::Message(msg.str()); + } } // Helper class to make sure the call stack is valid. diff --git a/Source/cmake.cxx b/Source/cmake.cxx index a81b7e4..98dfd21 100644 --- a/Source/cmake.cxx +++ b/Source/cmake.cxx @@ -140,6 +140,7 @@ cmake::cmake(Role role, cmState::Mode mode) , State(cm::make_unique()) , Messenger(cm::make_unique()) { + this->TraceFile.close(); this->State->SetMode(mode); this->CurrentSnapshot = this->State->CreateBaseSnapshot(); @@ -740,6 +741,11 @@ void cmake::SetArgs(const std::vector& args) cmSystemTools::ConvertToUnixSlashes(file); this->AddTraceSource(file); this->SetTrace(true); + } else if (arg.find("--trace-redirect=", 0) == 0) { + std::string file = arg.substr(strlen("--trace-redirect=")); + cmSystemTools::ConvertToUnixSlashes(file); + this->SetTraceFile(file); + this->SetTrace(true); } else if (arg.find("--trace", 0) == 0) { std::cout << "Running with trace output on.\n"; this->SetTrace(true); @@ -870,6 +876,20 @@ cmake::LogLevel cmake::StringToLogLevel(const std::string& levelStr) return (it != levels.cend()) ? it->second : LogLevel::LOG_UNDEFINED; } +void cmake::SetTraceFile(const std::string& file) +{ + this->TraceFile.close(); + this->TraceFile.open(file.c_str()); + if (!this->TraceFile) { + std::stringstream ss; + ss << "Error opening trace file " << file << ": " + << cmSystemTools::GetLastSystemError(); + cmSystemTools::Error(ss.str()); + return; + } + std::cout << "Trace will be written to " << file << "\n"; +} + void cmake::SetDirectoriesFromFile(const std::string& arg) { // Check if the argument refers to a CMakeCache.txt or diff --git a/Source/cmake.h b/Source/cmake.h index 92494ae..fdcf50f 100644 --- a/Source/cmake.h +++ b/Source/cmake.h @@ -13,6 +13,7 @@ #include #include +#include "cmGeneratedFileStream.h" #include "cmInstalledFile.h" #include "cmListFileCache.h" #include "cmMessageType.h" @@ -401,6 +402,9 @@ public: { return this->TraceOnlyThisSources; } + cmGeneratedFileStream& GetTraceFile() { return this->TraceFile; } + void SetTraceFile(std::string const& file); + bool GetWarnUninitialized() { return this->WarnUninitialized; } void SetWarnUninitialized(bool b) { this->WarnUninitialized = b; } bool GetWarnUnused() { return this->WarnUnused; } @@ -547,6 +551,7 @@ private: bool DebugOutput = false; bool Trace = false; bool TraceExpand = false; + cmGeneratedFileStream TraceFile; bool WarnUninitialized = false; bool WarnUnused = false; bool WarnUnusedCli = true; diff --git a/Source/cmakemain.cxx b/Source/cmakemain.cxx index 10a6825..1fe6439 100644 --- a/Source/cmakemain.cxx +++ b/Source/cmakemain.cxx @@ -80,6 +80,8 @@ const char* cmDocumentationOptions[][2] = { { "--trace-expand", "Put cmake in trace mode with variable expansion." }, { "--trace-source=", "Trace only this CMake file/module. Multiple options allowed." }, + { "--trace-redirect=", + "Redirect trace output to a file instead of stderr." }, { "--warn-uninitialized", "Warn about uninitialized values." }, { "--warn-unused-vars", "Warn about unused variables." }, { "--no-warn-unused-cli", "Don't warn about command line options." }, diff --git a/Tests/RunCMake/CommandLine/RunCMakeTest.cmake b/Tests/RunCMake/CommandLine/RunCMakeTest.cmake index 4e19871..dd49423 100644 --- a/Tests/RunCMake/CommandLine/RunCMakeTest.cmake +++ b/Tests/RunCMake/CommandLine/RunCMakeTest.cmake @@ -484,6 +484,14 @@ set(RunCMake_TEST_OPTIONS --trace-expand --warn-uninitialized) run_cmake(trace-expand-warn-uninitialized) unset(RunCMake_TEST_OPTIONS) +set(RunCMake_TEST_OPTIONS --trace-redirect=${RunCMake_BINARY_DIR}/redirected.trace) +run_cmake(trace-redirect) +unset(RunCMake_TEST_OPTIONS) + +set(RunCMake_TEST_OPTIONS --trace-redirect=/no/such/file.txt) +run_cmake(trace-redirect-nofile) +unset(RunCMake_TEST_OPTIONS) + set(RunCMake_TEST_OPTIONS -Wno-deprecated --warn-uninitialized) run_cmake(warn-uninitialized) unset(RunCMake_TEST_OPTIONS) diff --git a/Tests/RunCMake/CommandLine/trace-redirect-check.cmake b/Tests/RunCMake/CommandLine/trace-redirect-check.cmake new file mode 100644 index 0000000..1ee0e0d --- /dev/null +++ b/Tests/RunCMake/CommandLine/trace-redirect-check.cmake @@ -0,0 +1,13 @@ +file(READ ${RunCMake_SOURCE_DIR}/trace-stderr.txt expected_content) +string(REGEX REPLACE "\n+$" "" expected_content "${expected_content}") + +file(READ ${RunCMake_BINARY_DIR}/redirected.trace actual_content) +string(REGEX REPLACE "\r\n" "\n" actual_content "${actual_content}") +string(REGEX REPLACE "\n+$" "" actual_content "${actual_content}") +if(NOT "${actual_content}" MATCHES "${expected_content}") + set(RunCMake_TEST_FAILED + "Trace file content does not match that expected." + "Expected to match:\n${expected_content}\n" + "Actual content:\n${actual_content}\n" + ) +endif() diff --git a/Tests/RunCMake/CommandLine/trace-redirect-nofile-result.txt b/Tests/RunCMake/CommandLine/trace-redirect-nofile-result.txt new file mode 100644 index 0000000..d00491f --- /dev/null +++ b/Tests/RunCMake/CommandLine/trace-redirect-nofile-result.txt @@ -0,0 +1 @@ +1 diff --git a/Tests/RunCMake/CommandLine/trace-redirect-nofile-stderr.txt b/Tests/RunCMake/CommandLine/trace-redirect-nofile-stderr.txt new file mode 100644 index 0000000..edb0c8e --- /dev/null +++ b/Tests/RunCMake/CommandLine/trace-redirect-nofile-stderr.txt @@ -0,0 +1 @@ +^CMake Error: Error opening trace file /no/such/file.txt: .+$ diff --git a/Tests/RunCMake/CommandLine/trace-redirect-nofile.cmake b/Tests/RunCMake/CommandLine/trace-redirect-nofile.cmake new file mode 100644 index 0000000..e69de29 diff --git a/Tests/RunCMake/CommandLine/trace-redirect-stdout.txt b/Tests/RunCMake/CommandLine/trace-redirect-stdout.txt new file mode 100644 index 0000000..775f2b5 --- /dev/null +++ b/Tests/RunCMake/CommandLine/trace-redirect-stdout.txt @@ -0,0 +1 @@ +^.*Trace will be written to .+redirected.trace.*$ diff --git a/Tests/RunCMake/CommandLine/trace-redirect.cmake b/Tests/RunCMake/CommandLine/trace-redirect.cmake new file mode 100644 index 0000000..e69de29 https://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=9460501ad7353e6eecdf42d56568c1f909f64e27 commit 9460501ad7353e6eecdf42d56568c1f909f64e27 Author: Robert Maynard AuthorDate: Fri Aug 9 14:49:34 2019 -0400 Commit: Robert Maynard CommitDate: Fri Aug 9 14:54:16 2019 -0400 FindOpenACC: Provide a Fortran snippet that compiles with gfortran The original Fortran snippet would fail to compile with the error message of: ``` return 0; 1 Error: Alternate RETURN statement at (1) is only allowed within a SUBROUTINE ``` We solve this by removing the early termination logic. diff --git a/Modules/FindOpenACC.cmake b/Modules/FindOpenACC.cmake index dc8321d..1f0238e 100644 --- a/Modules/FindOpenACC.cmake +++ b/Modules/FindOpenACC.cmake @@ -60,9 +60,7 @@ int main(){ set(OpenACC_Fortran_TEST_SOURCE " program test -#ifdef _OPENACC - return 0; -#else +#ifndef _OPENACC breaks_on_purpose #endif endprogram test ----------------------------------------------------------------------- Summary of changes: CMakeLists.txt | 2 +- Help/guide/tutorial/Complete/CMakeLists.txt | 15 +- Help/guide/tutorial/Complete/CTestConfig.cmake | 7 + .../tutorial/Complete/MathFunctions/CMakeLists.txt | 14 +- .../tutorial/Complete/MathFunctions/mysqrt.cxx | 13 +- Help/guide/tutorial/Complete/TutorialConfig.h.in | 2 +- Help/guide/tutorial/Complete/tutorial.cxx | 5 +- Help/guide/tutorial/Consumer/CMakeLists.txt | 2 +- Help/guide/tutorial/MultiPackage/CMakeLists.txt | 16 +- .../MultiPackage/MathFunctions/CMakeLists.txt | 13 +- .../tutorial/MultiPackage/MathFunctions/mysqrt.cxx | 10 +- Help/guide/tutorial/MultiPackage/tutorial.cxx | 2 +- Help/guide/tutorial/Step1/CMakeLists.txt | 3 - Help/guide/tutorial/Step1/TutorialConfig.h.in | 3 - Help/guide/tutorial/Step1/tutorial.cxx | 6 +- Help/guide/tutorial/Step10/CMakeLists.txt | 20 +- Help/guide/tutorial/Step10/CTestConfig.cmake | 7 + .../tutorial/Step10/MathFunctions/CMakeLists.txt | 12 +- .../guide/tutorial/Step10/MathFunctions/mysqrt.cxx | 13 +- Help/guide/tutorial/Step10/TutorialConfig.h.in | 2 +- Help/guide/tutorial/Step10/tutorial.cxx | 3 +- Help/guide/tutorial/Step11/CMakeLists.txt | 15 +- Help/guide/tutorial/Step11/CTestConfig.cmake | 7 + .../tutorial/Step11/MathFunctions/CMakeLists.txt | 13 +- .../guide/tutorial/Step11/MathFunctions/mysqrt.cxx | 13 +- Help/guide/tutorial/Step11/TutorialConfig.h.in | 2 +- Help/guide/tutorial/Step11/tutorial.cxx | 4 +- Help/guide/tutorial/Step2/CMakeLists.txt | 16 +- .../tutorial/Step2/MathFunctions/CMakeLists.txt | 1 - Help/guide/tutorial/Step2/MathFunctions/mysqrt.cxx | 1 - Help/guide/tutorial/Step2/tutorial.cxx | 6 +- Help/guide/tutorial/Step3/CMakeLists.txt | 22 +- Help/guide/tutorial/Step3/tutorial.cxx | 7 +- Help/guide/tutorial/Step4/CMakeLists.txt | 20 +- Help/guide/tutorial/Step4/tutorial.cxx | 7 +- Help/guide/tutorial/Step5/CMakeLists.txt | 18 +- Help/guide/tutorial/Step5/tutorial.cxx | 7 +- Help/guide/tutorial/Step6/CMakeLists.txt | 24 +- .../tutorial/Step6/MathFunctions/CMakeLists.txt | 14 +- Help/guide/tutorial/Step6/MathFunctions/mysqrt.cxx | 5 +- Help/guide/tutorial/Step6/TutorialConfig.h.in | 4 - Help/guide/tutorial/Step6/tutorial.cxx | 7 +- Help/guide/tutorial/Step7/CMakeLists.txt | 28 +- .../tutorial/Step7/MathFunctions/CMakeLists.txt | 3 +- Help/guide/tutorial/Step7/MathFunctions/mysqrt.cxx | 4 +- Help/guide/tutorial/Step7/TutorialConfig.h.in | 4 - Help/guide/tutorial/Step7/tutorial.cxx | 7 +- Help/guide/tutorial/Step8/CMakeLists.txt | 28 +- .../tutorial/Step8/MathFunctions/CMakeLists.txt | 3 +- Help/guide/tutorial/Step8/MathFunctions/mysqrt.cxx | 14 +- Help/guide/tutorial/Step8/TutorialConfig.h.in | 4 - Help/guide/tutorial/Step8/tutorial.cxx | 7 +- Help/guide/tutorial/Step9/CMakeLists.txt | 27 +- Help/guide/tutorial/Step9/CTestConfig.cmake | 8 - .../tutorial/Step9/MathFunctions/CMakeLists.txt | 9 - Help/guide/tutorial/Step9/MathFunctions/mysqrt.cxx | 13 +- Help/guide/tutorial/Step9/TutorialConfig.h.in | 3 +- Help/guide/tutorial/Step9/tutorial.cxx | 8 +- Help/guide/tutorial/index.rst | 411 +++++++++++++-------- Help/index.rst | 12 +- Help/manual/cmake.1.rst | 3 + Help/release/dev/trace-redirect.rst | 6 + Modules/FindOpenACC.cmake | 32 +- Source/cmMakefile.cxx | 9 +- Source/cmake.cxx | 20 + Source/cmake.h | 5 + Source/cmakemain.cxx | 2 + Tests/CMakeLists.txt | 7 +- Tests/FindOpenACC/CMakeLists.txt | 20 + Tests/FindOpenACC/CTest/CMakeLists.txt | 13 + Tests/FindOpenACC/CTest/main.c | 44 +++ Tests/FindOpenACC/CXXTest/CMakeLists.txt | 13 + Tests/FindOpenACC/CXXTest/main.cxx | 43 +++ Tests/FindOpenACC/FortranTest/CMakeLists.txt | 11 + Tests/FindOpenACC/FortranTest/main.f90 | 9 + Tests/RunCMake/CommandLine/RunCMakeTest.cmake | 8 + .../CommandLine/trace-redirect-check.cmake | 13 + .../trace-redirect-nofile-result.txt} | 0 .../CommandLine/trace-redirect-nofile-stderr.txt | 1 + .../CommandLine/trace-redirect-nofile.cmake} | 0 .../RunCMake/CommandLine/trace-redirect-stdout.txt | 1 + .../CommandLine/trace-redirect.cmake} | 0 82 files changed, 719 insertions(+), 517 deletions(-) create mode 100644 Help/guide/tutorial/Complete/CTestConfig.cmake delete mode 100644 Help/guide/tutorial/Step1/CMakeLists.txt delete mode 100644 Help/guide/tutorial/Step1/TutorialConfig.h.in create mode 100644 Help/guide/tutorial/Step10/CTestConfig.cmake create mode 100644 Help/guide/tutorial/Step11/CTestConfig.cmake delete mode 100644 Help/guide/tutorial/Step2/MathFunctions/CMakeLists.txt create mode 100644 Help/release/dev/trace-redirect.rst create mode 100644 Tests/FindOpenACC/CMakeLists.txt create mode 100644 Tests/FindOpenACC/CTest/CMakeLists.txt create mode 100644 Tests/FindOpenACC/CTest/main.c create mode 100644 Tests/FindOpenACC/CXXTest/CMakeLists.txt create mode 100644 Tests/FindOpenACC/CXXTest/main.cxx create mode 100644 Tests/FindOpenACC/FortranTest/CMakeLists.txt create mode 100644 Tests/FindOpenACC/FortranTest/main.f90 create mode 100644 Tests/RunCMake/CommandLine/trace-redirect-check.cmake copy Tests/RunCMake/{while/MissingArgument-result.txt => CommandLine/trace-redirect-nofile-result.txt} (100%) create mode 100644 Tests/RunCMake/CommandLine/trace-redirect-nofile-stderr.txt copy Tests/{Wrapping/vtkIncluded.cxx => RunCMake/CommandLine/trace-redirect-nofile.cmake} (100%) create mode 100644 Tests/RunCMake/CommandLine/trace-redirect-stdout.txt copy Tests/{Wrapping/vtkIncluded.cxx => RunCMake/CommandLine/trace-redirect.cmake} (100%) hooks/post-receive -- CMake From kwrobot at kitware.com Tue Aug 20 09:41:57 2019 From: kwrobot at kitware.com (Kitware Robot) Date: Tue, 20 Aug 2019 09:41:57 -0400 (EDT) Subject: [Cmake-commits] CMake branch, master, updated. v3.15.2-699-gee692e8 Message-ID: <20190820134157.D63C1A93D1@public.kitware.com> This is an automated email from the git hooks/post-receive script. It was generated because a ref change was pushed to the repository containing the project "CMake". The branch, master has been updated via ee692e8fdba5bb3c02d2f248a139e87cf10fef56 (commit) via ccefe9798d2f51c97a198c7016e593f9537515fc (commit) from a0c8405d681d504f5d96489c2b5d44f10a29c6ed (commit) Those revisions listed above that are new to this repository have not appeared on any other notification email; so we list those revisions in full, below. - Log ----------------------------------------------------------------- https://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=ee692e8fdba5bb3c02d2f248a139e87cf10fef56 commit ee692e8fdba5bb3c02d2f248a139e87cf10fef56 Merge: a0c8405 ccefe97 Author: Craig Scott AuthorDate: Tue Aug 20 13:32:25 2019 +0000 Commit: Kitware Robot CommitDate: Tue Aug 20 09:32:42 2019 -0400 Merge topic 'ctest_coverage_help_typo' ccefe9798d Help: Fix typo in ctest_coverage synopsis Acked-by: Kitware Robot Merge-request: !3706 https://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=ccefe9798d2f51c97a198c7016e593f9537515fc commit ccefe9798d2f51c97a198c7016e593f9537515fc Author: Sylvain Joubert AuthorDate: Tue Aug 20 10:23:44 2019 +0200 Commit: Sylvain Joubert CommitDate: Tue Aug 20 10:23:44 2019 +0200 Help: Fix typo in ctest_coverage synopsis diff --git a/Help/command/ctest_coverage.rst b/Help/command/ctest_coverage.rst index 8d27b9c..d50f634 100644 --- a/Help/command/ctest_coverage.rst +++ b/Help/command/ctest_coverage.rst @@ -8,7 +8,7 @@ Perform the :ref:`CTest Coverage Step` as a :ref:`Dashboard Client`. ctest_coverage([BUILD ] [APPEND] [LABELS