diff options
Diffstat (limited to 'Source')
-rw-r--r-- | Source/CMakeVersion.cmake | 2 | ||||
-rw-r--r-- | Source/cmCxxModuleMapper.cxx | 36 | ||||
-rw-r--r-- | Source/cmCxxModuleMapper.h | 1 | ||||
-rw-r--r-- | Source/cmGeneratorTarget.cxx | 6 | ||||
-rw-r--r-- | Source/cmGlobalNinjaGenerator.cxx | 2 | ||||
-rw-r--r-- | Source/cmNinjaTargetGenerator.cxx | 7 | ||||
-rw-r--r-- | Source/cmQtAutoMocUic.cxx | 3 | ||||
-rw-r--r-- | Source/cmSearchPath.cxx | 15 | ||||
-rw-r--r-- | Source/cmStringAlgorithms.cxx | 40 | ||||
-rw-r--r-- | Source/cmStringAlgorithms.h | 67 | ||||
-rw-r--r-- | Source/cmTargetIncludeDirectoriesCommand.cxx | 5 | ||||
-rw-r--r-- | Source/cmTargetPropCommandBase.cxx | 2 | ||||
-rw-r--r-- | Source/cmTargetPropCommandBase.h | 3 | ||||
-rw-r--r-- | Source/cmakemain.cxx | 5 |
14 files changed, 137 insertions, 57 deletions
diff --git a/Source/CMakeVersion.cmake b/Source/CMakeVersion.cmake index c3c47ae..f74a79f 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 25) -set(CMake_VERSION_PATCH 20221202) +set(CMake_VERSION_PATCH 20221207) #set(CMake_VERSION_RC 0) set(CMake_VERSION_IS_DIRTY 0) diff --git a/Source/cmCxxModuleMapper.cxx b/Source/cmCxxModuleMapper.cxx index 84691c9..ca4ffdf 100644 --- a/Source/cmCxxModuleMapper.cxx +++ b/Source/cmCxxModuleMapper.cxx @@ -28,6 +28,38 @@ cm::optional<std::string> CxxModuleLocations::BmiGeneratorPathForModule( namespace { +std::string CxxModuleMapContentClang(CxxModuleLocations const& loc, + cmScanDepInfo const& obj) +{ + std::stringstream mm; + + // Clang's command line only supports a single output. If more than one is + // expected, we cannot make a useful module map file. + if (obj.Provides.size() > 1) { + return {}; + } + + // A series of flags which tell the compiler where to look for modules. + + for (auto const& p : obj.Provides) { + if (auto bmi_loc = loc.BmiGeneratorPathForModule(p.LogicalName)) { + // Force the TU to be considered a C++ module source file regardless of + // extension. + mm << "-x c++-module\n"; + + mm << "-fsave-std-c++-module-file=" << *bmi_loc << '\n'; + break; + } + } + for (auto const& r : obj.Requires) { + if (auto bmi_loc = loc.BmiGeneratorPathForModule(r.LogicalName)) { + mm << "-fmodule-file=" << *bmi_loc << '\n'; + } + } + + return mm.str(); +} + std::string CxxModuleMapContentGcc(CxxModuleLocations const& loc, cmScanDepInfo const& obj) { @@ -179,6 +211,8 @@ cm::static_string_view CxxModuleMapExtension( { if (format) { switch (*format) { + case CxxModuleMapFormat::Clang: + return ".pcm"_s; case CxxModuleMapFormat::Gcc: return ".gcm"_s; case CxxModuleMapFormat::Msvc: @@ -297,6 +331,8 @@ std::string CxxModuleMapContent(CxxModuleMapFormat format, CxxModuleUsage const& usages) { switch (format) { + case CxxModuleMapFormat::Clang: + return CxxModuleMapContentClang(loc, obj); case CxxModuleMapFormat::Gcc: return CxxModuleMapContentGcc(loc, obj); case CxxModuleMapFormat::Msvc: diff --git a/Source/cmCxxModuleMapper.h b/Source/cmCxxModuleMapper.h index 8526a07..9271978 100644 --- a/Source/cmCxxModuleMapper.h +++ b/Source/cmCxxModuleMapper.h @@ -17,6 +17,7 @@ enum class CxxModuleMapFormat { + Clang, Gcc, Msvc, }; diff --git a/Source/cmGeneratorTarget.cxx b/Source/cmGeneratorTarget.cxx index 123b5e6..7ecdd87 100644 --- a/Source/cmGeneratorTarget.cxx +++ b/Source/cmGeneratorTarget.cxx @@ -4669,7 +4669,8 @@ void cmGeneratorTarget::GetLinkOptions(std::vector<std::string>& result, std::vector<BT<std::string>> cmGeneratorTarget::GetLinkOptions( std::string const& config, std::string const& language) const { - ConfigAndLanguage cacheKey(config, language); + ConfigAndLanguage cacheKey( + config, cmStrCat(language, this->IsDeviceLink() ? "-device" : "")); { auto it = this->LinkOptionsCache.find(cacheKey); if (it != this->LinkOptionsCache.end()) { @@ -4955,7 +4956,8 @@ void cmGeneratorTarget::GetLinkDirectories(std::vector<std::string>& result, std::vector<BT<std::string>> cmGeneratorTarget::GetLinkDirectories( std::string const& config, std::string const& language) const { - ConfigAndLanguage cacheKey(config, language); + ConfigAndLanguage cacheKey( + config, cmStrCat(language, this->IsDeviceLink() ? "-device" : "")); { auto it = this->LinkDirectoriesCache.find(cacheKey); if (it != this->LinkDirectoriesCache.end()) { diff --git a/Source/cmGlobalNinjaGenerator.cxx b/Source/cmGlobalNinjaGenerator.cxx index 75c347e..cfe4c7c 100644 --- a/Source/cmGlobalNinjaGenerator.cxx +++ b/Source/cmGlobalNinjaGenerator.cxx @@ -2571,6 +2571,8 @@ bool cmGlobalNinjaGenerator::WriteDyndepFile( cm::optional<CxxModuleMapFormat> modmap_fmt; if (arg_modmapfmt.empty()) { // nothing to do. + } else if (arg_modmapfmt == "clang") { + modmap_fmt = CxxModuleMapFormat::Clang; } else if (arg_modmapfmt == "gcc") { modmap_fmt = CxxModuleMapFormat::Gcc; } else if (arg_modmapfmt == "msvc") { diff --git a/Source/cmNinjaTargetGenerator.cxx b/Source/cmNinjaTargetGenerator.cxx index f2f719d..0807a98 100644 --- a/Source/cmNinjaTargetGenerator.cxx +++ b/Source/cmNinjaTargetGenerator.cxx @@ -561,9 +561,12 @@ cmNinjaRule GetScanRule( // Scanning always uses a depfile for preprocessor dependencies. if (deptype == "msvc"_s) { rule.DepType = deptype; - rule.DepFile = ""; + rule.DepFile.clear(); + } else if (deptype == "none"_s) { + rule.DepType.clear(); // no deps= for multiple outputs + rule.DepFile.clear(); } else { - rule.DepType = ""; // no deps= for multiple outputs + rule.DepType.clear(); // no deps= for multiple outputs rule.DepFile = "$DEP_FILE"; } diff --git a/Source/cmQtAutoMocUic.cxx b/Source/cmQtAutoMocUic.cxx index 4753e61..683c18f 100644 --- a/Source/cmQtAutoMocUic.cxx +++ b/Source/cmQtAutoMocUic.cxx @@ -1981,6 +1981,9 @@ void cmQtAutoMocUicT::JobCompileMocT::Process() std::string const& sourceFile = this->Mapping->SourceFile->FileName; std::string const& outputFile = this->Mapping->OutputFile; + // Remove output file in case the case of the source file has changed + cmSystemTools::RemoveFile(outputFile); + // Compose moc command std::vector<std::string> cmd; { diff --git a/Source/cmSearchPath.cxx b/Source/cmSearchPath.cxx index 6c53b85..44f37cb 100644 --- a/Source/cmSearchPath.cxx +++ b/Source/cmSearchPath.cxx @@ -179,12 +179,27 @@ void cmSearchPath::AddPrefixPaths(const std::vector<std::string>& paths, cmValue arch = this->FC->Makefile->GetDefinition("CMAKE_LIBRARY_ARCHITECTURE"); if (cmNonempty(arch)) { + std::string archNoUnknown = arch; + auto unknownAtPos = archNoUnknown.find("-unknown-"); + bool foundUnknown = unknownAtPos != std::string::npos; + if (foundUnknown) { + // Replace "-unknown-" with "-". + archNoUnknown.replace(unknownAtPos, 9, "-"); + } if (this->FC->Makefile->IsDefinitionSet("CMAKE_SYSROOT") && this->FC->Makefile->IsDefinitionSet( "CMAKE_PREFIX_LIBRARY_ARCHITECTURE")) { + if (foundUnknown) { + this->AddPathInternal(cmStrCat('/', archNoUnknown, dir, subdir), + cmStrCat('/', archNoUnknown, prefix), base); + } this->AddPathInternal(cmStrCat('/', *arch, dir, subdir), cmStrCat('/', *arch, prefix), base); } else { + if (foundUnknown) { + this->AddPathInternal(cmStrCat(dir, subdir, '/', archNoUnknown), + prefix, base); + } this->AddPathInternal(cmStrCat(dir, subdir, '/', *arch), prefix, base); } diff --git a/Source/cmStringAlgorithms.cxx b/Source/cmStringAlgorithms.cxx index e559cfa..66bf383 100644 --- a/Source/cmStringAlgorithms.cxx +++ b/Source/cmStringAlgorithms.cxx @@ -203,25 +203,45 @@ cmAlphaNum::cmAlphaNum(double val) MakeDigits(this->View_, this->Digits_, "%g", val); } -std::string cmCatViews(cm::optional<std::string>&& first, - std::initializer_list<cm::string_view> views) +std::string cmCatViews( + std::initializer_list<std::pair<cm::string_view, std::string*>> views) { std::size_t totalSize = 0; - for (cm::string_view const& view : views) { - totalSize += view.size(); + std::string* rvalueString = nullptr; + std::size_t rvalueStringLength = 0; + std::size_t rvalueStringOffset = 0; + for (auto const& view : views) { + // Find the rvalue string with the largest capacity. + if (view.second && + (!rvalueString || + view.second->capacity() > rvalueString->capacity())) { + rvalueString = view.second; + rvalueStringLength = rvalueString->length(); + rvalueStringOffset = totalSize; + } + totalSize += view.first.size(); } std::string result; std::string::size_type initialLen = 0; - if (first) { - totalSize += first->length(); - initialLen = first->length(); - result = std::move(*first); + if (rvalueString && rvalueString->capacity() >= totalSize) { + result = std::move(*rvalueString); + } else { + rvalueString = nullptr; } result.resize(totalSize); + if (rvalueString && rvalueStringOffset > 0) { + std::copy_backward(result.begin(), result.begin() + rvalueStringLength, + result.begin() + rvalueStringOffset + + rvalueStringLength); + } std::string::iterator sit = result.begin() + initialLen; - for (cm::string_view const& view : views) { - sit = std::copy_n(view.data(), view.size(), sit); + for (auto const& view : views) { + if (rvalueString && view.second == rvalueString) { + sit += rvalueStringLength; + } else { + sit = std::copy_n(view.first.data(), view.first.size(), sit); + } } return result; } diff --git a/Source/cmStringAlgorithms.h b/Source/cmStringAlgorithms.h index bff2eda..9ea7491 100644 --- a/Source/cmStringAlgorithms.h +++ b/Source/cmStringAlgorithms.h @@ -12,7 +12,6 @@ #include <utility> #include <vector> -#include <cm/optional> #include <cm/string_view> #include "cmRange.h" @@ -147,8 +146,8 @@ std::vector<std::string> cmExpandedLists(InputIt first, InputIt last) } /** Concatenate string pieces into a single string. */ -std::string cmCatViews(cm::optional<std::string>&& first, - std::initializer_list<cm::string_view> views); +std::string cmCatViews( + std::initializer_list<std::pair<cm::string_view, std::string*>> views); /** Utility class for cmStrCat. */ class cmAlphaNum @@ -162,6 +161,10 @@ public: : View_(str) { } + cmAlphaNum(std::string&& str) + : RValueString_(&str) + { + } cmAlphaNum(const char* str) : View_(str) { @@ -184,45 +187,34 @@ public: { } - cm::string_view View() const { return this->View_; } + cm::string_view View() const + { + if (this->RValueString_) { + return *this->RValueString_; + } + return this->View_; + } + + std::string* RValueString() const { return this->RValueString_; } private: + std::string* RValueString_ = nullptr; cm::string_view View_; char Digits_[32]; }; -template <typename A, typename B, typename... AV> -class cmStrCatHelper -{ -public: - static std::string Compute(cmAlphaNum const& a, cmAlphaNum const& b, - AV const&... args) - { - return cmCatViews( - cm::nullopt, - { a.View(), b.View(), static_cast<cmAlphaNum const&>(args).View()... }); - } -}; - -template <typename B, typename... AV> -class cmStrCatHelper<std::string, B, AV...> -{ -public: - static std::string Compute(std::string&& a, cmAlphaNum const& b, - AV const&... args) - { - return cmCatViews( - std::move(a), - { b.View(), static_cast<cmAlphaNum const&>(args).View()... }); - } -}; - /** Concatenate string pieces and numbers into a single string. */ template <typename A, typename B, typename... AV> inline std::string cmStrCat(A&& a, B&& b, AV&&... args) { - return cmStrCatHelper<A, B, AV...>::Compute( - std::forward<A>(a), std::forward<B>(b), std::forward<AV>(args)...); + static auto const makePair = + [](const cmAlphaNum& arg) -> std::pair<cm::string_view, std::string*> { + return { arg.View(), arg.RValueString() }; + }; + + return cmCatViews({ makePair(std::forward<A>(a)), + makePair(std::forward<B>(b)), + makePair(std::forward<AV>(args))... }); } /** Joins wrapped elements of a range with separator into a single string. */ @@ -233,10 +225,13 @@ std::string cmWrap(cm::string_view prefix, Range const& rng, if (rng.empty()) { return std::string(); } - return cmCatViews( - cm::nullopt, - { prefix, cmJoin(rng, cmCatViews(cm::nullopt, { suffix, sep, prefix })), - suffix }); + return cmCatViews({ { prefix, nullptr }, + { cmJoin(rng, + cmCatViews({ { suffix, nullptr }, + { sep, nullptr }, + { prefix, nullptr } })), + nullptr }, + { suffix, nullptr } }); } /** Joins wrapped elements of a range with separator into a single string. */ diff --git a/Source/cmTargetIncludeDirectoriesCommand.cxx b/Source/cmTargetIncludeDirectoriesCommand.cxx index cb83873..7a2dd09 100644 --- a/Source/cmTargetIncludeDirectoriesCommand.cxx +++ b/Source/cmTargetIncludeDirectoriesCommand.cxx @@ -100,8 +100,7 @@ bool cmTargetIncludeDirectoriesCommand(std::vector<std::string> const& args, { return TargetIncludeDirectoriesImpl(status).HandleArguments( args, "INCLUDE_DIRECTORIES", - static_cast<TargetIncludeDirectoriesImpl::ArgumentFlags>( - TargetIncludeDirectoriesImpl::PROCESS_BEFORE | + TargetIncludeDirectoriesImpl::PROCESS_BEFORE | TargetIncludeDirectoriesImpl::PROCESS_AFTER | - TargetIncludeDirectoriesImpl::PROCESS_SYSTEM)); + TargetIncludeDirectoriesImpl::PROCESS_SYSTEM); } diff --git a/Source/cmTargetPropCommandBase.cxx b/Source/cmTargetPropCommandBase.cxx index 391b954..8d2ff71 100644 --- a/Source/cmTargetPropCommandBase.cxx +++ b/Source/cmTargetPropCommandBase.cxx @@ -23,7 +23,7 @@ void cmTargetPropCommandBase::SetError(std::string const& e) bool cmTargetPropCommandBase::HandleArguments( std::vector<std::string> const& args, const std::string& prop, - ArgumentFlags flags) + unsigned int flags) { if (args.size() < 2) { this->SetError("called with incorrect number of arguments"); diff --git a/Source/cmTargetPropCommandBase.h b/Source/cmTargetPropCommandBase.h index 487beb4..ac50b4d 100644 --- a/Source/cmTargetPropCommandBase.h +++ b/Source/cmTargetPropCommandBase.h @@ -29,8 +29,7 @@ public: }; bool HandleArguments(std::vector<std::string> const& args, - const std::string& prop, - ArgumentFlags flags = NO_FLAGS); + const std::string& prop, unsigned int flags = NO_FLAGS); protected: std::string Property; diff --git a/Source/cmakemain.cxx b/Source/cmakemain.cxx index a155787..1e02412 100644 --- a/Source/cmakemain.cxx +++ b/Source/cmakemain.cxx @@ -311,6 +311,11 @@ int do_cmake(int ac, char const* const* av) } return 1; // failed to parse } + // Only in script mode do we stop parsing instead + // of preferring the last mode flag provided + if (arg == "--" && workingMode == cmake::SCRIPT_MODE) { + break; + } } if (!matched) { parsedArgs.emplace_back(av[i]); |