diff options
83 files changed, 336 insertions, 303 deletions
diff --git a/.clang-format b/.clang-format index cba23d6..813a84d 100644 --- a/.clang-format +++ b/.clang-format @@ -1,5 +1,5 @@ --- -# This configuration requires clang-format version 6.0 exactly. +# This configuration requires clang-format version 15 exactly. BasedOnStyle: Mozilla AlignOperands: false AllowShortFunctionsOnASingleLine: InlineOnly diff --git a/.gitattributes b/.gitattributes index 43ad3b7..96a1166 100644 --- a/.gitattributes +++ b/.gitattributes @@ -4,7 +4,7 @@ .editorconfig export-ignore # Custom attribute to mark sources as using our C code style. -[attr]our-c-style whitespace=tab-in-indent format.clang-format=6.0 +[attr]our-c-style whitespace=tab-in-indent format.clang-format=15 # Custom attribute to mark sources as generated. # Do not perform whitespace checks. Do not format. diff --git a/Help/dev/source.rst b/Help/dev/source.rst index f488b3e..68ca743 100644 --- a/Help/dev/source.rst +++ b/Help/dev/source.rst @@ -9,7 +9,7 @@ See documentation on `CMake Development`_ for more information. C++ Code Style ============== -We use `clang-format`_ version **6.0** to define our style for C++ code in +We use `clang-format`_ version **15** to define our style for C++ code in the CMake source tree. See the `.clang-format`_ configuration file for our style settings. Use the `Utilities/Scripts/clang-format.bash`_ script to format source code. It automatically runs ``clang-format`` on the set of diff --git a/Help/guide/tutorial/Adding Export Configuration.rst b/Help/guide/tutorial/Adding Export Configuration.rst index eb14f42..6c83276 100644 --- a/Help/guide/tutorial/Adding Export Configuration.rst +++ b/Help/guide/tutorial/Adding Export Configuration.rst @@ -102,7 +102,7 @@ but prepended with a ``PACKAGE_`` prefix. :end-before: # generate the version file The :command:`write_basic_package_version_file` is next. This command writes -a file which is used by the "find_package" document the version and +a file which is used by :command:`find_package`, documenting the version and compatibility of the desired package. Here, we use the ``Tutorial_VERSION_*`` variables and say that it is compatible with ``AnyNewerVersion``, which denotes that this version or any higher one are compatible with the requested @@ -133,8 +133,8 @@ the following to the bottom of the top level ``CMakeLists.txt``: :caption: CMakeLists.txt :name: CMakeLists.txt-export :language: cmake - :start-after: # needs to be after the install(TARGETS ) command + :start-after: # needs to be after the install(TARGETS) command -With this export call we now generate a ``Targets.cmake``, allowing the +With this export call we now generate a ``MathFunctionsTargets.cmake``, allowing the configured ``MathFunctionsConfig.cmake`` in the build directory to be used by other projects, without needing it to be installed. diff --git a/Help/guide/tutorial/Installing and Testing.rst b/Help/guide/tutorial/Installing and Testing.rst index aa3fb74..7a59fcb 100644 --- a/Help/guide/tutorial/Installing and Testing.rst +++ b/Help/guide/tutorial/Installing and Testing.rst @@ -1,8 +1,6 @@ Step 5: Installing and Testing ============================== -.. _`Tutorial Testing Support`: - Exercise 1 - Install Rules ^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -154,6 +152,8 @@ are similar. To the end of the top-level ``CMakeLists.txt`` we add: That is all that is needed to create a basic local install of the tutorial. +.. _`Tutorial Testing Support`: + Exercise 2 - Testing Support ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ diff --git a/Help/guide/tutorial/Selecting Static or Shared Libraries.rst b/Help/guide/tutorial/Selecting Static or Shared Libraries.rst index 1c49c23..7befe1d 100644 --- a/Help/guide/tutorial/Selecting Static or Shared Libraries.rst +++ b/Help/guide/tutorial/Selecting Static or Shared Libraries.rst @@ -65,7 +65,7 @@ At this point, if you build everything, you may notice that linking fails as we are combining a static library without position independent code with a library that has position independent code. The solution to this is to explicitly set the :prop_tgt:`POSITION_INDEPENDENT_CODE` target property of -SqrtLibrary to be ``True`` no matter the build type. +SqrtLibrary to be ``True`` when building shared libraries. .. literalinclude:: Step11/MathFunctions/CMakeLists.txt :caption: MathFunctions/CMakeLists.txt diff --git a/Help/guide/tutorial/Step12/CMakeLists.txt b/Help/guide/tutorial/Step12/CMakeLists.txt index 220ed4b..1d8b5a6 100644 --- a/Help/guide/tutorial/Step12/CMakeLists.txt +++ b/Help/guide/tutorial/Step12/CMakeLists.txt @@ -94,7 +94,7 @@ install(EXPORT MathFunctionsTargets ) include(CMakePackageConfigHelpers) -# generate the config file that is includes the exports +# generate the config file that includes the exports configure_package_config_file(${CMAKE_CURRENT_SOURCE_DIR}/Config.cmake.in "${CMAKE_CURRENT_BINARY_DIR}/MathFunctionsConfig.cmake" INSTALL_DESTINATION "lib/cmake/example" @@ -116,7 +116,7 @@ install(FILES ) # generate the export targets for the build tree -# needs to be after the install(TARGETS ) command +# needs to be after the install(TARGETS) command export(EXPORT MathFunctionsTargets FILE "${CMAKE_CURRENT_BINARY_DIR}/MathFunctionsTargets.cmake" ) diff --git a/Help/guide/tutorial/Step5/CMakeLists.txt b/Help/guide/tutorial/Step5/CMakeLists.txt index c894917..279ddf9 100644 --- a/Help/guide/tutorial/Step5/CMakeLists.txt +++ b/Help/guide/tutorial/Step5/CMakeLists.txt @@ -61,4 +61,4 @@ target_include_directories(Tutorial PUBLIC # Hint: Use the PASS_REGULAR_EXPRESSION property with "4 is 2" # TODO 9: Add more tests. Create a function called do_test to avoid copy + -# paste. Test the following values: 4, 9, 5, 7, 25, -25 and 0.00001. +# paste. Test the following values: 4, 9, 5, 7, 25, -25 and 0.0001. diff --git a/Help/release/3.25.rst b/Help/release/3.25.rst index dea8de8..2d04741 100644 --- a/Help/release/3.25.rst +++ b/Help/release/3.25.rst @@ -253,3 +253,7 @@ Changes made since CMake 3.25.0 include the following. * CUDA language level 20 (corresponding to C++20) is now supported with NVCC 12.0 and above. + +* On Windows, the ``icpx`` compiler now provided by Intel oneAPI 2023.0 + and above is no longer selected because its GNU-like command-line is + not yet supported by CMake. diff --git a/Modules/CMakeCCompilerABI.c b/Modules/CMakeCCompilerABI.c index f0ee21a..63596be 100644 --- a/Modules/CMakeCCompilerABI.c +++ b/Modules/CMakeCCompilerABI.c @@ -9,7 +9,8 @@ #include "CMakeCompilerABI.h" #ifdef __CLASSIC_C__ -int main(argc, argv) int argc; +int main(argc, argv) +int argc; char* argv[]; #else int main(int argc, char* argv[]) diff --git a/Modules/FindLibLZMA.cmake b/Modules/FindLibLZMA.cmake index c298bab..1b3929b 100644 --- a/Modules/FindLibLZMA.cmake +++ b/Modules/FindLibLZMA.cmake @@ -117,7 +117,7 @@ if (LIBLZMA_FOUND) if(NOT TARGET LibLZMA::LibLZMA) add_library(LibLZMA::LibLZMA UNKNOWN IMPORTED) set_target_properties(LibLZMA::LibLZMA PROPERTIES - INTERFACE_INCLUDE_DIRECTORIES ${LIBLZMA_INCLUDE_DIR} + INTERFACE_INCLUDE_DIRECTORIES "${LIBLZMA_INCLUDE_DIR}" IMPORTED_LINK_INTERFACE_LANGUAGES C) if(LIBLZMA_LIBRARY_RELEASE) diff --git a/Modules/TestForANSIStreamHeaders.cxx b/Modules/TestForANSIStreamHeaders.cxx index d314d58..0ae9723 100644 --- a/Modules/TestForANSIStreamHeaders.cxx +++ b/Modules/TestForANSIStreamHeaders.cxx @@ -1,6 +1,6 @@ #include <iostream> -int main(int, char* []) +int main(int, char*[]) { return 0; } diff --git a/Modules/TestForAnsiForScope.cxx b/Modules/TestForAnsiForScope.cxx index 4bc2c67..1632cae 100644 --- a/Modules/TestForAnsiForScope.cxx +++ b/Modules/TestForAnsiForScope.cxx @@ -1,4 +1,4 @@ -int main(int, char* []) +int main(int, char*[]) { int i; for (int i = 0; i < 1; ++i) diff --git a/Modules/TestForSSTREAM.cxx b/Modules/TestForSSTREAM.cxx index 83a75e4..59f13a3 100644 --- a/Modules/TestForSSTREAM.cxx +++ b/Modules/TestForSSTREAM.cxx @@ -1,5 +1,5 @@ #include <sstream> -int main(int, char* []) +int main(int, char*[]) { std::ostringstream os; os << "12345"; diff --git a/Modules/TestForSTDNamespace.cxx b/Modules/TestForSTDNamespace.cxx index 62951ff..b537d44 100644 --- a/Modules/TestForSTDNamespace.cxx +++ b/Modules/TestForSTDNamespace.cxx @@ -1,5 +1,5 @@ #include <list> -int main(int, char* []) +int main(int, char*[]) { std::list<int>(); return 0; diff --git a/Source/CMakeVersion.cmake b/Source/CMakeVersion.cmake index 5a7e54b..464b1e7 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 20230118) +set(CMake_VERSION_PATCH 20230119) #set(CMake_VERSION_RC 0) set(CMake_VERSION_IS_DIRTY 0) diff --git a/Source/CPack/cmCPackGenerator.h b/Source/CPack/cmCPackGenerator.h index 65156ab..8078d9f 100644 --- a/Source/CPack/cmCPackGenerator.h +++ b/Source/CPack/cmCPackGenerator.h @@ -344,8 +344,14 @@ private: #define cmCPackTypeMacro(klass, superclass) \ using Superclass = superclass; \ - const char* GetNameOfClass() override { return #klass; } \ - static cmCPackGenerator* CreateGenerator() { return new klass; } \ + const char* GetNameOfClass() override \ + { \ + return #klass; \ + } \ + static cmCPackGenerator* CreateGenerator() \ + { \ + return new klass; \ + } \ class cmCPackTypeMacro_UseTrailingSemicolon #define cmCPackLogger(logType, msg) \ diff --git a/Source/CTest/cmCTestBuildHandler.cxx b/Source/CTest/cmCTestBuildHandler.cxx index 66c30c0..c6387ab 100644 --- a/Source/CTest/cmCTestBuildHandler.cxx +++ b/Source/CTest/cmCTestBuildHandler.cxx @@ -671,10 +671,10 @@ bool cmCTestBuildHandler::IsLaunchedWarningFile(const char* fname) cmHasLiteralSuffix(fname, ".xml")); } -//###################################################################### -//###################################################################### -//###################################################################### -//###################################################################### +// ###################################################################### +// ###################################################################### +// ###################################################################### +// ###################################################################### class cmCTestBuildHandler::LaunchHelper { @@ -963,10 +963,10 @@ int cmCTestBuildHandler::RunMakeCommand(const std::string& command, return result; } -//###################################################################### -//###################################################################### -//###################################################################### -//###################################################################### +// ###################################################################### +// ###################################################################### +// ###################################################################### +// ###################################################################### void cmCTestBuildHandler::ProcessBuffer(const char* data, size_t length, size_t& tick, size_t tick_len, diff --git a/Source/cmArchiveWrite.cxx b/Source/cmArchiveWrite.cxx index f29983c..e992b4b 100644 --- a/Source/cmArchiveWrite.cxx +++ b/Source/cmArchiveWrite.cxx @@ -68,7 +68,7 @@ public: ~Entry() { archive_entry_free(this->Object); } Entry(const Entry&) = delete; Entry& operator=(const Entry&) = delete; - operator struct archive_entry*() { return this->Object; } + operator struct archive_entry *() { return this->Object; } }; struct cmArchiveWrite::Callback diff --git a/Source/cmCPluginAPI.h b/Source/cmCPluginAPI.h index 0d8a366..13a93b7 100644 --- a/Source/cmCPluginAPI.h +++ b/Source/cmCPluginAPI.h @@ -201,7 +201,7 @@ typedef const char*(CCONV* CM_DOC_FUNCTION)(); /* NOLINTNEXTLINE(modernize-use-using) */ typedef int(CCONV* CM_INITIAL_PASS_FUNCTION)(void* info, void* mf, int argc, - char* []); + char*[]); /* NOLINTNEXTLINE(modernize-use-using) */ typedef void(CCONV* CM_FINAL_PASS_FUNCTION)(void* info, void* mf); diff --git a/Source/cmCTest.cxx b/Source/cmCTest.cxx index 72cd8cd..5899a61 100644 --- a/Source/cmCTest.cxx +++ b/Source/cmCTest.cxx @@ -1066,10 +1066,10 @@ int cmCTest::GetTestModelFromString(const std::string& str) return cmCTest::EXPERIMENTAL; } -//###################################################################### -//###################################################################### -//###################################################################### -//###################################################################### +// ###################################################################### +// ###################################################################### +// ###################################################################### +// ###################################################################### int cmCTest::RunMakeCommand(const std::string& command, std::string& output, int* retVal, const char* dir, cmDuration timeout, @@ -1185,10 +1185,10 @@ int cmCTest::RunMakeCommand(const std::string& command, std::string& output, return result; } -//###################################################################### -//###################################################################### -//###################################################################### -//###################################################################### +// ###################################################################### +// ###################################################################### +// ###################################################################### +// ###################################################################### int cmCTest::RunTest(std::vector<const char*> argv, std::string* output, int* retVal, std::ostream* log, cmDuration testTimeOut, diff --git a/Source/cmComputeLinkInformation.cxx b/Source/cmComputeLinkInformation.cxx index cd0a1dc..ad8fb8b 100644 --- a/Source/cmComputeLinkInformation.cxx +++ b/Source/cmComputeLinkInformation.cxx @@ -30,7 +30,7 @@ #include "cmValue.h" #include "cmake.h" -//#define CM_COMPUTE_LINK_INFO_DEBUG +// #define CM_COMPUTE_LINK_INFO_DEBUG /* Notes about linking on various platforms: diff --git a/Source/cmCoreTryCompile.cxx b/Source/cmCoreTryCompile.cxx index 2084b33..618c794 100644 --- a/Source/cmCoreTryCompile.cxx +++ b/Source/cmCoreTryCompile.cxx @@ -39,12 +39,14 @@ constexpr size_t lang_property_start = 0; constexpr size_t lang_property_size = 4; constexpr size_t pie_property_start = 4; constexpr size_t pie_property_size = 2; +/* clang-format off */ #define SETUP_LANGUAGE(name, lang) \ static const std::string name[lang_property_size + pie_property_size + 1] = \ { "CMAKE_" #lang "_COMPILER_EXTERNAL_TOOLCHAIN", \ "CMAKE_" #lang "_COMPILER_TARGET", \ "CMAKE_" #lang "_LINK_NO_PIE_SUPPORTED", \ "CMAKE_" #lang "_PIE_SUPPORTED", "" } +/* clang-format on */ // NOLINTNEXTLINE(bugprone-suspicious-missing-comma) SETUP_LANGUAGE(c_properties, C); diff --git a/Source/cmExtraEclipseCDT4Generator.cxx b/Source/cmExtraEclipseCDT4Generator.cxx index ba4b326..a07acdc 100644 --- a/Source/cmExtraEclipseCDT4Generator.cxx +++ b/Source/cmExtraEclipseCDT4Generator.cxx @@ -67,7 +67,7 @@ cmExtraEclipseCDT4Generator::GetFactory() if (factory.GetSupportedGlobalGenerators().empty()) { // TODO: Verify if __CYGWIN__ should be checked. -//#if defined(_WIN32) && !defined(__CYGWIN__) +// #if defined(_WIN32) && !defined(__CYGWIN__) #if defined(_WIN32) factory.AddSupportedGlobalGenerator("NMake Makefiles"); factory.AddSupportedGlobalGenerator("MinGW Makefiles"); diff --git a/Source/cmGeneratorTarget.cxx b/Source/cmGeneratorTarget.cxx index 430e4a0..30aa99b 100644 --- a/Source/cmGeneratorTarget.cxx +++ b/Source/cmGeneratorTarget.cxx @@ -572,12 +572,7 @@ std::string cmGeneratorTarget::GetFilePrefix( cmValue prefix = this->GetFilePrefixInternal(config, artifact); return prefix ? *prefix : std::string(); } - - std::string prefix; - std::string suffix; - std::string base; - this->GetFullNameInternal(config, artifact, prefix, base, suffix); - return prefix; + return this->GetFullNameInternalComponents(config, artifact).prefix; } std::string cmGeneratorTarget::GetFileSuffix( const std::string& config, cmStateEnums::ArtifactType artifact) const @@ -586,12 +581,7 @@ std::string cmGeneratorTarget::GetFileSuffix( cmValue suffix = this->GetFileSuffixInternal(config, artifact); return suffix ? *suffix : std::string(); } - - std::string prefix; - std::string suffix; - std::string base; - this->GetFullNameInternal(config, artifact, prefix, base, suffix); - return suffix; + return this->GetFullNameInternalComponents(config, artifact).suffix; } std::string cmGeneratorTarget::GetFilePostfix(const std::string& config) const @@ -755,6 +745,8 @@ void cmGeneratorTarget::ClearSourcesCache() this->PrecompileHeadersCache.clear(); this->LinkOptionsCache.clear(); this->LinkDirectoriesCache.clear(); + this->RuntimeBinaryFullNameCache.clear(); + this->ImportLibraryFullNameCache.clear(); } void cmGeneratorTarget::ClearLinkInterfaceCache() @@ -2180,23 +2172,21 @@ std::set<std::string> cmGeneratorTarget::GetAllConfigCompileLanguages() const std::string cmGeneratorTarget::GetCompilePDBName( const std::string& config) const { - std::string prefix; - std::string base; - std::string suffix; - this->GetFullNameInternal(config, cmStateEnums::RuntimeBinaryArtifact, - prefix, base, suffix); - // Check for a per-configuration output directory target property. std::string configUpper = cmSystemTools::UpperCase(config); std::string configProp = cmStrCat("COMPILE_PDB_NAME_", configUpper); cmValue config_name = this->GetProperty(configProp); if (cmNonempty(config_name)) { - return prefix + *config_name + ".pdb"; + NameComponents const& components = GetFullNameInternalComponents( + config, cmStateEnums::RuntimeBinaryArtifact); + return components.prefix + *config_name + ".pdb"; } cmValue name = this->GetProperty("COMPILE_PDB_NAME"); if (cmNonempty(name)) { - return prefix + *name + ".pdb"; + NameComponents const& components = GetFullNameInternalComponents( + config, cmStateEnums::RuntimeBinaryArtifact); + return components.prefix + *name + ".pdb"; } return ""; @@ -2939,11 +2929,11 @@ void cmGeneratorTarget::ComputeLinkClosure(const std::string& config, } } -void cmGeneratorTarget::GetFullNameComponents( - std::string& prefix, std::string& base, std::string& suffix, - const std::string& config, cmStateEnums::ArtifactType artifact) const +cmGeneratorTarget::NameComponents const& +cmGeneratorTarget::GetFullNameComponents( + std::string const& config, cmStateEnums::ArtifactType artifact) const { - this->GetFullNameInternal(config, artifact, prefix, base, suffix); + return this->GetFullNameInternalComponents(config, artifact); } std::string cmGeneratorTarget::BuildBundleDirectory( @@ -5261,32 +5251,33 @@ cmGeneratorTarget::Names cmGeneratorTarget::GetLibraryNames( } // Get the components of the library name. - std::string prefix; - std::string suffix; - this->GetFullNameInternal(config, cmStateEnums::RuntimeBinaryArtifact, - prefix, targetNames.Base, suffix); + NameComponents const& components = this->GetFullNameInternalComponents( + config, cmStateEnums::RuntimeBinaryArtifact); // The library name. - targetNames.Output = prefix + targetNames.Base + suffix; + targetNames.Base = components.base; + targetNames.Output = + components.prefix + targetNames.Base + components.suffix; if (this->IsFrameworkOnApple()) { - targetNames.Real = prefix; + targetNames.Real = components.prefix; if (!this->Makefile->PlatformIsAppleEmbedded()) { targetNames.Real += "Versions/"; targetNames.Real += this->GetFrameworkVersion(); targetNames.Real += "/"; } - targetNames.Real += targetNames.Base + suffix; - targetNames.SharedObject = targetNames.Real + suffix; + targetNames.Real += targetNames.Base + components.suffix; + targetNames.SharedObject = targetNames.Real + components.suffix; } else { // The library's soname. - this->ComputeVersionedName(targetNames.SharedObject, prefix, - targetNames.Base, suffix, targetNames.Output, - soversion); + this->ComputeVersionedName(targetNames.SharedObject, components.prefix, + targetNames.Base, components.suffix, + targetNames.Output, soversion); // The library's real name on disk. - this->ComputeVersionedName(targetNames.Real, prefix, targetNames.Base, - suffix, targetNames.Output, version); + this->ComputeVersionedName(targetNames.Real, components.prefix, + targetNames.Base, components.suffix, + targetNames.Output, version); } // The import library name. @@ -5330,17 +5321,17 @@ cmGeneratorTarget::Names cmGeneratorTarget::GetExecutableNames( #endif // Get the components of the executable name. - std::string prefix; - std::string suffix; - this->GetFullNameInternal(config, cmStateEnums::RuntimeBinaryArtifact, - prefix, targetNames.Base, suffix); + NameComponents const& components = this->GetFullNameInternalComponents( + config, cmStateEnums::RuntimeBinaryArtifact); // The executable name. - targetNames.Output = prefix + targetNames.Base + suffix; + targetNames.Base = components.base; + targetNames.Output = + components.prefix + targetNames.Base + components.suffix; // The executable's real name on disk. #if defined(__CYGWIN__) - targetNames.Real = prefix + targetNames.Base; + targetNames.Real = components.prefix + targetNames.Base; #else targetNames.Real = targetNames.Output; #endif @@ -5349,7 +5340,7 @@ cmGeneratorTarget::Names cmGeneratorTarget::GetExecutableNames( targetNames.Real += *version; } #if defined(__CYGWIN__) - targetNames.Real += suffix; + targetNames.Real += components.suffix; #endif // The import library name. @@ -5365,11 +5356,9 @@ cmGeneratorTarget::Names cmGeneratorTarget::GetExecutableNames( std::string cmGeneratorTarget::GetFullNameInternal( const std::string& config, cmStateEnums::ArtifactType artifact) const { - std::string prefix; - std::string base; - std::string suffix; - this->GetFullNameInternal(config, artifact, prefix, base, suffix); - return prefix + base + suffix; + NameComponents const& components = + this->GetFullNameInternalComponents(config, artifact); + return components.prefix + components.base + components.suffix; } std::string cmGeneratorTarget::ImportedGetLocation( @@ -5387,19 +5376,27 @@ std::string cmGeneratorTarget::GetFullNameImported( this->Target->ImportedGetFullPath(config, artifact)); } -void cmGeneratorTarget::GetFullNameInternal( - const std::string& config, cmStateEnums::ArtifactType artifact, - std::string& outPrefix, std::string& outBase, std::string& outSuffix) const +cmGeneratorTarget::NameComponents const& +cmGeneratorTarget::GetFullNameInternalComponents( + std::string const& config, cmStateEnums::ArtifactType artifact) const { + assert(artifact == cmStateEnums::RuntimeBinaryArtifact || + artifact == cmStateEnums::ImportLibraryArtifact); + FullNameCache& cache = artifact == cmStateEnums::RuntimeBinaryArtifact + ? RuntimeBinaryFullNameCache + : ImportLibraryFullNameCache; + auto search = cache.find(config); + if (search != cache.end()) { + return search->second; + } // Use just the target name for non-main target types. if (this->GetType() != cmStateEnums::STATIC_LIBRARY && this->GetType() != cmStateEnums::SHARED_LIBRARY && this->GetType() != cmStateEnums::MODULE_LIBRARY && this->GetType() != cmStateEnums::EXECUTABLE) { - outPrefix.clear(); - outBase = this->GetName(); - outSuffix.clear(); - return; + NameComponents components; + components.base = this->GetName(); + return cache.emplace(config, std::move(components)).first->second; } const bool isImportedLibraryArtifact = @@ -5408,12 +5405,14 @@ void cmGeneratorTarget::GetFullNameInternal( // Return an empty name for the import library if this platform // does not support import libraries. if (isImportedLibraryArtifact && !this->NeedImportLibraryName(config)) { - outPrefix.clear(); - outBase.clear(); - outSuffix.clear(); - return; + return cache.emplace(config, NameComponents()).first->second; } + NameComponents parts; + std::string& outPrefix = parts.prefix; + std::string& outBase = parts.base; + std::string& outSuffix = parts.suffix; + // retrieve prefix and suffix std::string ll = this->GetLinkerLanguage(config); cmValue targetPrefix = this->GetFilePrefixInternal(config, artifact, ll); @@ -5474,6 +5473,8 @@ void cmGeneratorTarget::GetFullNameInternal( // Append the suffix. outSuffix = targetSuffix ? *targetSuffix : ""; + + return cache.emplace(config, std::move(parts)).first->second; } std::string cmGeneratorTarget::GetLinkerLanguage( @@ -5509,11 +5510,8 @@ std::string cmGeneratorTarget::GetPDBOutputName( std::string cmGeneratorTarget::GetPDBName(const std::string& config) const { - std::string prefix; - std::string base; - std::string suffix; - this->GetFullNameInternal(config, cmStateEnums::RuntimeBinaryArtifact, - prefix, base, suffix); + NameComponents const& parts = this->GetFullNameInternalComponents( + config, cmStateEnums::RuntimeBinaryArtifact); std::vector<std::string> props; std::string configUpper = cmSystemTools::UpperCase(config); @@ -5527,11 +5525,10 @@ std::string cmGeneratorTarget::GetPDBName(const std::string& config) const for (std::string const& p : props) { if (cmValue outName = this->GetProperty(p)) { - base = *outName; - break; + return parts.prefix + *outName + ".pdb"; } } - return prefix + base + ".pdb"; + return parts.prefix + parts.base + ".pdb"; } std::string cmGeneratorTarget::GetObjectDirectory( diff --git a/Source/cmGeneratorTarget.h b/Source/cmGeneratorTarget.h index 7fa662d..dd10c64 100644 --- a/Source/cmGeneratorTarget.h +++ b/Source/cmGeneratorTarget.h @@ -348,10 +348,16 @@ public: /** Get the soname of the target. Allowed only for a shared library. */ std::string GetSOName(const std::string& config) const; - void GetFullNameComponents(std::string& prefix, std::string& base, - std::string& suffix, const std::string& config, - cmStateEnums::ArtifactType artifact = - cmStateEnums::RuntimeBinaryArtifact) const; + struct NameComponents + { + std::string prefix; + std::string base; + std::string suffix; + }; + NameComponents const& GetFullNameComponents( + std::string const& config, + cmStateEnums::ArtifactType artifact = + cmStateEnums::RuntimeBinaryArtifact) const; /** Append to @a base the bundle directory hierarchy up to a certain @a level * and return it. */ @@ -940,10 +946,14 @@ private: std::string GetFullNameInternal(const std::string& config, cmStateEnums::ArtifactType artifact) const; - void GetFullNameInternal(const std::string& config, - cmStateEnums::ArtifactType artifact, - std::string& outPrefix, std::string& outBase, - std::string& outSuffix) const; + + using FullNameCache = std::map<std::string, NameComponents>; + + mutable FullNameCache RuntimeBinaryFullNameCache; + mutable FullNameCache ImportLibraryFullNameCache; + + NameComponents const& GetFullNameInternalComponents( + std::string const& config, cmStateEnums::ArtifactType artifact) const; mutable std::string LinkerLanguage; using LinkClosureMapType = std::map<std::string, LinkClosure>; diff --git a/Source/cmGlobalNinjaGenerator.cxx b/Source/cmGlobalNinjaGenerator.cxx index c24b1e3..a1eadb9 100644 --- a/Source/cmGlobalNinjaGenerator.cxx +++ b/Source/cmGlobalNinjaGenerator.cxx @@ -8,6 +8,7 @@ #include <cstdio> #include <functional> #include <sstream> +#include <tuple> #include <utility> #include <cm/iterator> @@ -584,7 +585,7 @@ void cmGlobalNinjaGenerator::Generate() } for (auto& it : this->Configs) { - it.second.TargetDependsClosures.clear(); + it.second.TargetDependsClosureLocalOutputs.clear(); } this->InitOutputPathPrefix(); @@ -1360,70 +1361,85 @@ void cmGlobalNinjaGenerator::AppendTargetDependsClosure( cmGeneratorTarget const* target, cmNinjaDeps& outputs, const std::string& config, const std::string& fileConfig, bool genexOutput) { - cmNinjaOuts outs; - this->AppendTargetDependsClosure(target, outs, config, fileConfig, - genexOutput, true); - cm::append(outputs, outs); -} + struct Entry + { + Entry(cmGeneratorTarget const* target_, std::string config_, + std::string fileConfig_) + : target(target_) + , config(std::move(config_)) + , fileConfig(std::move(fileConfig_)) + { + } -void cmGlobalNinjaGenerator::AppendTargetDependsClosure( - cmGeneratorTarget const* target, cmNinjaOuts& outputs, - const std::string& config, const std::string& fileConfig, bool genexOutput, - bool omit_self) -{ + bool operator<(Entry const& other) const + { + return std::tie(target, config, fileConfig) < + std::tie(other.target, other.config, other.fileConfig); + } - // try to locate the target in the cache - ByConfig::TargetDependsClosureKey key{ - target, - config, - genexOutput, + cmGeneratorTarget const* target; + std::string config; + std::string fileConfig; }; - auto find = this->Configs[fileConfig].TargetDependsClosures.lower_bound(key); - - if (find == this->Configs[fileConfig].TargetDependsClosures.end() || - find->first != key) { - // We now calculate the closure outputs by inspecting the dependent - // targets recursively. - // For that we have to distinguish between a local result set that is only - // relevant for filling the cache entries properly isolated and a global - // result set that is relevant for the result of the top level call to - // AppendTargetDependsClosure. - cmNinjaOuts this_outs; // this will be the new cache entry - - for (auto const& dep_target : this->GetTargetDirectDepends(target)) { + + cmNinjaOuts outputSet; + std::vector<Entry> stack; + stack.emplace_back(target, config, fileConfig); + std::set<Entry> seen = { stack.back() }; + + do { + Entry entry = std::move(stack.back()); + stack.pop_back(); + + // generate the outputs of the target itself, if applicable + if (entry.target != target) { + // try to locate the target in the cache + ByConfig::TargetDependsClosureKey localCacheKey{ + entry.target, + entry.config, + genexOutput, + }; + auto& configs = this->Configs[entry.fileConfig]; + auto lb = + configs.TargetDependsClosureLocalOutputs.lower_bound(localCacheKey); + + if (lb == configs.TargetDependsClosureLocalOutputs.end() || + lb->first != localCacheKey) { + cmNinjaDeps outs; + this->AppendTargetOutputs(entry.target, outs, entry.config, + DependOnTargetArtifact); + configs.TargetDependsClosureLocalOutputs.emplace_hint( + lb, localCacheKey, outs); + for (auto& value : outs) { + outputSet.emplace(std::move(value)); + } + } else { + outputSet.insert(lb->second.begin(), lb->second.end()); + } + } + + // push next dependencies + for (const auto& dep_target : this->GetTargetDirectDepends(entry.target)) { if (!dep_target->IsInBuildSystem()) { continue; } - if (!this->IsSingleConfigUtility(target) && + if (!this->IsSingleConfigUtility(entry.target) && !this->IsSingleConfigUtility(dep_target) && this->EnableCrossConfigBuild() && !dep_target.IsCross() && !genexOutput) { continue; } - if (dep_target.IsCross()) { - this->AppendTargetDependsClosure(dep_target, this_outs, fileConfig, - fileConfig, genexOutput, false); - } else { - this->AppendTargetDependsClosure(dep_target, this_outs, config, - fileConfig, genexOutput, false); + auto emplaceRes = seen.emplace( + dep_target, dep_target.IsCross() ? entry.fileConfig : entry.config, + entry.fileConfig); + if (emplaceRes.second) { + stack.emplace_back(*emplaceRes.first); } } - find = this->Configs[fileConfig].TargetDependsClosures.emplace_hint( - find, key, std::move(this_outs)); - } - - // now fill the outputs of the final result from the newly generated cache - // entry - outputs.insert(find->second.begin(), find->second.end()); - - // finally generate the outputs of the target itself, if applicable - cmNinjaDeps outs; - if (!omit_self) { - this->AppendTargetOutputs(target, outs, config, DependOnTargetArtifact); - } - outputs.insert(outs.begin(), outs.end()); + } while (!stack.empty()); + cm::append(outputs, outputSet); } void cmGlobalNinjaGenerator::AddTargetAlias(const std::string& alias, diff --git a/Source/cmGlobalNinjaGenerator.h b/Source/cmGlobalNinjaGenerator.h index 775e792..2b6d1cd 100644 --- a/Source/cmGlobalNinjaGenerator.h +++ b/Source/cmGlobalNinjaGenerator.h @@ -354,11 +354,6 @@ public: const std::string& config, const std::string& fileConfig, bool genexOutput); - void AppendTargetDependsClosure(cmGeneratorTarget const* target, - cmNinjaOuts& outputs, - const std::string& config, - const std::string& fileConfig, - bool genexOutput, bool omit_self); void AppendDirectoryForConfig(const std::string& prefix, const std::string& config, @@ -615,7 +610,8 @@ private: bool GenexOutput; }; - std::map<TargetDependsClosureKey, cmNinjaOuts> TargetDependsClosures; + std::map<TargetDependsClosureKey, cmNinjaDeps> + TargetDependsClosureLocalOutputs; TargetAliasMap TargetAliases; diff --git a/Source/cmGlobalVisualStudio10Generator.cxx b/Source/cmGlobalVisualStudio10Generator.cxx index 192663d..a7a47ef 100644 --- a/Source/cmGlobalVisualStudio10Generator.cxx +++ b/Source/cmGlobalVisualStudio10Generator.cxx @@ -773,9 +773,9 @@ std::string cmGlobalVisualStudio10Generator::FindMSBuildCommand() std::string mskey; // Search in standard location. - mskey = cmStrCat( - R"(HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\MSBuild\ToolsVersions\)", - this->GetToolsVersion(), ";MSBuildToolsPath"); + mskey = + cmStrCat(R"(HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\MSBuild\ToolsVersions\)", + this->GetToolsVersion(), ";MSBuildToolsPath"); if (cmSystemTools::ReadRegistryValue(mskey, msbuild, cmSystemTools::KeyWOW64_32)) { cmSystemTools::ConvertToUnixSlashes(msbuild); diff --git a/Source/cmGlobalVisualStudio7Generator.cxx b/Source/cmGlobalVisualStudio7Generator.cxx index c375d60..d483135 100644 --- a/Source/cmGlobalVisualStudio7Generator.cxx +++ b/Source/cmGlobalVisualStudio7Generator.cxx @@ -168,9 +168,9 @@ std::string cmGlobalVisualStudio7Generator::FindDevEnvCommand() } // Search where VS15Preview places it. - vskey = cmStrCat( - R"(HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\VisualStudio\SxS\VS7;)", - this->GetIDEVersion()); + vskey = + cmStrCat(R"(HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\VisualStudio\SxS\VS7;)", + this->GetIDEVersion()); if (cmSystemTools::ReadRegistryValue(vskey, vscmd, cmSystemTools::KeyWOW64_32)) { cmSystemTools::ConvertToUnixSlashes(vscmd); diff --git a/Source/cmGlobalXCodeGenerator.cxx b/Source/cmGlobalXCodeGenerator.cxx index f19dfd5..5f28fc6 100644 --- a/Source/cmGlobalXCodeGenerator.cxx +++ b/Source/cmGlobalXCodeGenerator.cxx @@ -2516,10 +2516,8 @@ void cmGlobalXCodeGenerator::CreateBuildSettings(cmGeneratorTarget* gtgt, } // Get the product name components. - std::string pnprefix; - std::string pnbase; - std::string pnsuffix; - gtgt->GetFullNameComponents(pnprefix, pnbase, pnsuffix, configName); + cmGeneratorTarget::NameComponents const& components = + gtgt->GetFullNameComponents(configName); cmValue version = gtgt->GetProperty("VERSION"); cmValue soversion = gtgt->GetProperty("SOVERSION"); @@ -2534,8 +2532,8 @@ void cmGlobalXCodeGenerator::CreateBuildSettings(cmGeneratorTarget* gtgt, version = soversion; } - std::string realName = pnbase; - std::string soName = pnbase; + std::string realName = components.base; + std::string soName = components.base; if (version && soversion) { realName += "."; realName += *version; @@ -2565,15 +2563,15 @@ void cmGlobalXCodeGenerator::CreateBuildSettings(cmGeneratorTarget* gtgt, gtgt->GetType() == cmStateEnums::SHARED_LIBRARY || gtgt->GetType() == cmStateEnums::MODULE_LIBRARY || gtgt->GetType() == cmStateEnums::EXECUTABLE) { - + std::string prefix = components.prefix; if (gtgt->IsFrameworkOnApple() || gtgt->IsCFBundleOnApple()) { - pnprefix = ""; + prefix = ""; } buildSettings->AddAttribute("EXECUTABLE_PREFIX", - this->CreateString(pnprefix)); + this->CreateString(prefix)); buildSettings->AddAttribute("EXECUTABLE_SUFFIX", - this->CreateString(pnsuffix)); + this->CreateString(components.suffix)); } // Store the product name for all target types. diff --git a/Source/cmJSONHelpers.h b/Source/cmJSONHelpers.h index 48decbc..f7151b5 100644 --- a/Source/cmJSONHelpers.h +++ b/Source/cmJSONHelpers.h @@ -36,26 +36,24 @@ struct cmJSONHelperBuilder Object& Bind(const cm::string_view& name, M U::*member, F func, bool required = true) { - return this->BindPrivate(name, - [func, member](T& out, const Json::Value* value, - CallState&&... state) -> E { - return func(out.*member, value, - std::forward(state)...); - }, - required); + return this->BindPrivate( + name, + [func, member](T& out, const Json::Value* value, CallState&&... state) + -> E { return func(out.*member, value, std::forward(state)...); }, + required); } template <typename M, typename F> Object& Bind(const cm::string_view& name, std::nullptr_t, F func, bool required = true) { - return this->BindPrivate(name, - [func](T& /*out*/, const Json::Value* value, - CallState&&... state) -> E { - M dummy; - return func(dummy, value, - std::forward(state)...); - }, - required); + return this->BindPrivate( + name, + [func](T& /*out*/, const Json::Value* value, + CallState&&... state) -> E { + M dummy; + return func(dummy, value, std::forward(state)...); + }, + required); } template <typename F> Object& Bind(const cm::string_view& name, F func, bool required = true) diff --git a/Source/cmNinjaNormalTargetGenerator.cxx b/Source/cmNinjaNormalTargetGenerator.cxx index 6ec1781..b8f851f 100644 --- a/Source/cmNinjaNormalTargetGenerator.cxx +++ b/Source/cmNinjaNormalTargetGenerator.cxx @@ -1228,16 +1228,14 @@ void cmNinjaNormalTargetGenerator::WriteLinkStatement( if (!this->SetMsvcTargetPdbVariable(vars, config)) { // It is common to place debug symbols at a specific place, // so we need a plain target name in the rule available. - std::string prefix; - std::string base; - std::string suffix; - gt->GetFullNameComponents(prefix, base, suffix, config); + cmGeneratorTarget::NameComponents const& components = + gt->GetFullNameComponents(config); std::string dbg_suffix = ".dbg"; // TODO: Where to document? if (cmValue d = mf->GetDefinition("CMAKE_DEBUG_SYMBOL_SUFFIX")) { dbg_suffix = *d; } - vars["TARGET_PDB"] = base + suffix + dbg_suffix; + vars["TARGET_PDB"] = components.base + components.suffix + dbg_suffix; } const std::string objPath = diff --git a/Source/cmRange.h b/Source/cmRange.h index 30af7d2..85cb8ea 100644 --- a/Source/cmRange.h +++ b/Source/cmRange.h @@ -76,9 +76,9 @@ class TransformIterator { public: using iterator_category = std::bidirectional_iterator_tag; - using value_type = - typename std::remove_cv<typename std::remove_reference<decltype( - std::declval<UnaryFunction>()(*std::declval<Iter>()))>::type>::type; + using value_type = typename std::remove_cv< + typename std::remove_reference<decltype(std::declval<UnaryFunction>()( + *std::declval<Iter>()))>::type>::type; using difference_type = typename std::iterator_traits<Iter>::difference_type; using pointer = value_type const*; using reference = value_type const&; diff --git a/Source/cmSetPropertyCommand.cxx b/Source/cmSetPropertyCommand.cxx index 521cf63..de1e3b0 100644 --- a/Source/cmSetPropertyCommand.cxx +++ b/Source/cmSetPropertyCommand.cxx @@ -619,10 +619,9 @@ bool HandleSource(cmSourceFile* sf, const std::string& propertyName, if (propertyName == "GENERATED") { SetPropertyCommand::PropertyOp op = (remove) ? SetPropertyCommand::PropertyOp::Remove - : (appendAsString) - ? SetPropertyCommand::PropertyOp::AppendAsString - : (appendMode) ? SetPropertyCommand::PropertyOp::Append - : SetPropertyCommand::PropertyOp::Set; + : (appendAsString) ? SetPropertyCommand::PropertyOp::AppendAsString + : (appendMode) ? SetPropertyCommand::PropertyOp::Append + : SetPropertyCommand::PropertyOp::Set; return SetPropertyCommand::HandleAndValidateSourceFilePropertyGENERATED( sf, propertyValue, op); } diff --git a/Source/cmSystemTools.cxx b/Source/cmSystemTools.cxx index f94c4d3..0b29b0d 100644 --- a/Source/cmSystemTools.cxx +++ b/Source/cmSystemTools.cxx @@ -3044,7 +3044,7 @@ static cm::optional<bool> SetRPathELF(std::string const& file, { auto adjustCallback = [newRPath](cm::optional<std::string>& outRPath, const std::string& inRPath, - const char* /*se_name*/, std::string * + const char* /*se_name*/, std::string* /*emsg*/) -> bool { if (inRPath != newRPath) { outRPath = newRPath; diff --git a/Tests/CMakeGUI/CatchShow.h b/Tests/CMakeGUI/CatchShow.h index 0254c15..7d370b6 100644 --- a/Tests/CMakeGUI/CatchShow.h +++ b/Tests/CMakeGUI/CatchShow.h @@ -30,12 +30,13 @@ void CatchShow::setCallback(F&& func) this->m_callback = [this, func](QObject* obj) { auto* d = qobject_cast<T*>(obj); if (d) { - QMetaObject::invokeMethod(obj, - [this, func, d]() { - ++this->m_count; - func(d); - }, - Qt::QueuedConnection); + QMetaObject::invokeMethod( + obj, + [this, func, d]() { + ++this->m_count; + func(d); + }, + Qt::QueuedConnection); } }; } diff --git a/Tests/CMakeLib/testArgumentParser.cxx b/Tests/CMakeLib/testArgumentParser.cxx index e044794..2647fef 100644 --- a/Tests/CMakeLib/testArgumentParser.cxx +++ b/Tests/CMakeLib/testArgumentParser.cxx @@ -365,7 +365,7 @@ bool testArgumentParserStaticBool() } // namespace -int testArgumentParser(int /*unused*/, char* /*unused*/ []) +int testArgumentParser(int /*unused*/, char* /*unused*/[]) { if (!testArgumentParserDynamic()) { std::cout << "While executing testArgumentParserDynamic().\n"; diff --git a/Tests/CMakeLib/testCMExtAlgorithm.cxx b/Tests/CMakeLib/testCMExtAlgorithm.cxx index b8319c3..c909f24 100644 --- a/Tests/CMakeLib/testCMExtAlgorithm.cxx +++ b/Tests/CMakeLib/testCMExtAlgorithm.cxx @@ -110,7 +110,7 @@ void testAppend() } } -int testCMExtAlgorithm(int /*unused*/, char* /*unused*/ []) +int testCMExtAlgorithm(int /*unused*/, char* /*unused*/[]) { testAppend(); diff --git a/Tests/CMakeLib/testCMExtEnumSet.cxx b/Tests/CMakeLib/testCMExtEnumSet.cxx index dbb0a54..ecf6d11 100644 --- a/Tests/CMakeLib/testCMExtEnumSet.cxx +++ b/Tests/CMakeLib/testCMExtEnumSet.cxx @@ -203,7 +203,7 @@ void testEdition() } } -int testCMExtEnumSet(int /*unused*/, char* /*unused*/ []) +int testCMExtEnumSet(int /*unused*/, char* /*unused*/[]) { testDeclaration(); testIteration(); diff --git a/Tests/CMakeLib/testCMExtMemory.cxx b/Tests/CMakeLib/testCMExtMemory.cxx index d8932ce..0143515 100644 --- a/Tests/CMakeLib/testCMExtMemory.cxx +++ b/Tests/CMakeLib/testCMExtMemory.cxx @@ -55,7 +55,7 @@ bool testReferenceCast() } } -int testCMExtMemory(int /*unused*/, char* /*unused*/ []) +int testCMExtMemory(int /*unused*/, char* /*unused*/[]) { if (!testReferenceCast()) { return 1; diff --git a/Tests/CMakeLib/testCMFilesystemPath.cxx b/Tests/CMakeLib/testCMFilesystemPath.cxx index 579ba99..52cb43a 100644 --- a/Tests/CMakeLib/testCMFilesystemPath.cxx +++ b/Tests/CMakeLib/testCMFilesystemPath.cxx @@ -969,7 +969,7 @@ bool testNonMemberFunctions() } } -int testCMFilesystemPath(int /*unused*/, char* /*unused*/ []) +int testCMFilesystemPath(int /*unused*/, char* /*unused*/[]) { int result = 0; diff --git a/Tests/CMakeLib/testCTestBinPacker.cxx b/Tests/CMakeLib/testCTestBinPacker.cxx index 772f417..038ceea 100644 --- a/Tests/CMakeLib/testCTestBinPacker.cxx +++ b/Tests/CMakeLib/testCTestBinPacker.cxx @@ -275,7 +275,7 @@ static bool TestExpectedPackResult(const ExpectedPackResult& expected) return true; } -int testCTestBinPacker(int /*unused*/, char* /*unused*/ []) +int testCTestBinPacker(int /*unused*/, char* /*unused*/[]) { int retval = 0; diff --git a/Tests/CMakeLib/testCTestResourceGroups.cxx b/Tests/CMakeLib/testCTestResourceGroups.cxx index 776d65d..b68301f 100644 --- a/Tests/CMakeLib/testCTestResourceGroups.cxx +++ b/Tests/CMakeLib/testCTestResourceGroups.cxx @@ -127,7 +127,7 @@ static bool TestExpectedParseResult(const ExpectedParseResult& expected) return true; } -int testCTestResourceGroups(int /*unused*/, char* /*unused*/ []) +int testCTestResourceGroups(int /*unused*/, char* /*unused*/[]) { int retval = 0; diff --git a/Tests/CMakeLib/testFindPackageCommand.cxx b/Tests/CMakeLib/testFindPackageCommand.cxx index bfd429f..30749be 100644 --- a/Tests/CMakeLib/testFindPackageCommand.cxx +++ b/Tests/CMakeLib/testFindPackageCommand.cxx @@ -14,7 +14,7 @@ std::cout << "FAILED: " << (m) << "\n"; \ failed = 1 -int testFindPackageCommand(int /*unused*/, char* /*unused*/ []) +int testFindPackageCommand(int /*unused*/, char* /*unused*/[]) { int failed = 0; diff --git a/Tests/CMakeLib/testGeneratedFileStream.cxx b/Tests/CMakeLib/testGeneratedFileStream.cxx index de44a0b..ad1c9e5 100644 --- a/Tests/CMakeLib/testGeneratedFileStream.cxx +++ b/Tests/CMakeLib/testGeneratedFileStream.cxx @@ -10,7 +10,7 @@ std::cout << "FAILED: " << (m1) << (m2) << "\n"; \ failed = 1 -int testGeneratedFileStream(int /*unused*/, char* /*unused*/ []) +int testGeneratedFileStream(int /*unused*/, char* /*unused*/[]) { int failed = 0; cmGeneratedFileStream gm; diff --git a/Tests/CMakeLib/testJSONHelpers.cxx b/Tests/CMakeLib/testJSONHelpers.cxx index 2cd3f75..053c163 100644 --- a/Tests/CMakeLib/testJSONHelpers.cxx +++ b/Tests/CMakeLib/testJSONHelpers.cxx @@ -457,7 +457,7 @@ bool testRequired() } } -int testJSONHelpers(int /*unused*/, char* /*unused*/ []) +int testJSONHelpers(int /*unused*/, char* /*unused*/[]) { if (!testInt()) { return 1; diff --git a/Tests/CMakeLib/testOptional.cxx b/Tests/CMakeLib/testOptional.cxx index 2007fff..785f031 100644 --- a/Tests/CMakeLib/testOptional.cxx +++ b/Tests/CMakeLib/testOptional.cxx @@ -760,7 +760,7 @@ static bool testMemoryRange(std::vector<Event>& expected) return true; } -int testOptional(int /*unused*/, char* /*unused*/ []) +int testOptional(int /*unused*/, char* /*unused*/[]) { int retval = 0; diff --git a/Tests/CMakeLib/testRange.cxx b/Tests/CMakeLib/testRange.cxx index 4efe98e..36c1e18 100644 --- a/Tests/CMakeLib/testRange.cxx +++ b/Tests/CMakeLib/testRange.cxx @@ -15,7 +15,7 @@ } \ } while (false) -int testRange(int /*unused*/, char* /*unused*/ []) +int testRange(int /*unused*/, char* /*unused*/[]) { std::vector<int> const testData = { 1, 2, 3, 4, 5, 6, 7, 8, 9, 10 }; diff --git a/Tests/CMakeLib/testString.cxx b/Tests/CMakeLib/testString.cxx index 5a9cad1..af34a2f 100644 --- a/Tests/CMakeLib/testString.cxx +++ b/Tests/CMakeLib/testString.cxx @@ -1163,7 +1163,7 @@ static bool testStability() return true; } -int testString(int /*unused*/, char* /*unused*/ []) +int testString(int /*unused*/, char* /*unused*/[]) { if (!testConstructDefault()) { return 1; diff --git a/Tests/CMakeLib/testStringAlgorithms.cxx b/Tests/CMakeLib/testStringAlgorithms.cxx index cb5f886..1bb23df 100644 --- a/Tests/CMakeLib/testStringAlgorithms.cxx +++ b/Tests/CMakeLib/testStringAlgorithms.cxx @@ -14,7 +14,7 @@ #include "cmStringAlgorithms.h" -int testStringAlgorithms(int /*unused*/, char* /*unused*/ []) +int testStringAlgorithms(int /*unused*/, char* /*unused*/[]) { int failed = 0; diff --git a/Tests/CMakeLib/testSystemTools.cxx b/Tests/CMakeLib/testSystemTools.cxx index 92f5275..754205e 100644 --- a/Tests/CMakeLib/testSystemTools.cxx +++ b/Tests/CMakeLib/testSystemTools.cxx @@ -25,7 +25,7 @@ } \ } while (false) -int testSystemTools(int /*unused*/, char* /*unused*/ []) +int testSystemTools(int /*unused*/, char* /*unused*/[]) { int failed = 0; // ---------------------------------------------------------------------- diff --git a/Tests/CMakeLib/testUTF8.cxx b/Tests/CMakeLib/testUTF8.cxx index 1bf88cf..fc0b539 100644 --- a/Tests/CMakeLib/testUTF8.cxx +++ b/Tests/CMakeLib/testUTF8.cxx @@ -164,7 +164,7 @@ static bool is_invalid(const char* s) return true; } -int testUTF8(int /*unused*/, char* /*unused*/ []) +int testUTF8(int /*unused*/, char* /*unused*/[]) { int result = 0; for (test_utf8_entry const* e = good_entry; e->n; ++e) { diff --git a/Tests/CMakeLib/testUVRAII.cxx b/Tests/CMakeLib/testUVRAII.cxx index fd88e24..0bdd44c 100644 --- a/Tests/CMakeLib/testUVRAII.cxx +++ b/Tests/CMakeLib/testUVRAII.cxx @@ -30,8 +30,7 @@ static bool testAsyncShutdown() std::thread([&] { std::this_thread::sleep_for(std::chrono::seconds(2)); signal.send(); - }) - .detach(); + }).detach(); if (uv_run(&Loop, UV_RUN_DEFAULT) != 0) { std::cerr << "Unclean exit state in testAsyncDtor" << std::endl; diff --git a/Tests/CMakeLib/testUVStreambuf.cxx b/Tests/CMakeLib/testUVStreambuf.cxx index 760fa29..f9ed6af 100644 --- a/Tests/CMakeLib/testUVStreambuf.cxx +++ b/Tests/CMakeLib/testUVStreambuf.cxx @@ -404,12 +404,13 @@ static bool testUVStreambufRead( << std::endl; goto end; } - uv_timer_start(timer, - [](uv_timer_t* handle) { - auto buf = static_cast<cmUVStreambuf*>(handle->data); - buf->close(); - }, - 0, 0); + uv_timer_start( + timer, + [](uv_timer_t* handle) { + auto buf = static_cast<cmUVStreambuf*>(handle->data); + buf->close(); + }, + 0, 0); if ((readLen = inputBuf.sgetn(inputData.data(), 128)) != 0) { std::cout << "sgetn() returned " << readLen << ", should be 0" << std::endl; diff --git a/Tests/CMakeLib/testVisualStudioSlnParser.cxx b/Tests/CMakeLib/testVisualStudioSlnParser.cxx index 7fdba9a..c1bf3d4 100644 --- a/Tests/CMakeLib/testVisualStudioSlnParser.cxx +++ b/Tests/CMakeLib/testVisualStudioSlnParser.cxx @@ -27,7 +27,7 @@ static bool parsedRight(cmVisualStudioSlnParser& parser, return false; } -int testVisualStudioSlnParser(int, char* []) +int testVisualStudioSlnParser(int, char*[]) { cmVisualStudioSlnParser parser; diff --git a/Tests/CMakeLib/testXMLParser.cxx b/Tests/CMakeLib/testXMLParser.cxx index 8617cc1..32ee3ec 100644 --- a/Tests/CMakeLib/testXMLParser.cxx +++ b/Tests/CMakeLib/testXMLParser.cxx @@ -4,7 +4,7 @@ #include "cmXMLParser.h" -int testXMLParser(int /*unused*/, char* /*unused*/ []) +int testXMLParser(int /*unused*/, char* /*unused*/[]) { // TODO: Derive from parser and check attributes. cmXMLParser parser; diff --git a/Tests/CMakeLib/testXMLSafe.cxx b/Tests/CMakeLib/testXMLSafe.cxx index dc62eb9..f0bd9c9 100644 --- a/Tests/CMakeLib/testXMLSafe.cxx +++ b/Tests/CMakeLib/testXMLSafe.cxx @@ -25,7 +25,7 @@ static test_pair const pairs[] = { { nullptr, nullptr } }; -int testXMLSafe(int /*unused*/, char* /*unused*/ []) +int testXMLSafe(int /*unused*/, char* /*unused*/[]) { int result = 0; for (test_pair const* p = pairs; p->in; ++p) { diff --git a/Tests/CompileFeatures/cxx_attribute_deprecated.cpp b/Tests/CompileFeatures/cxx_attribute_deprecated.cpp index 8faeca8..5482db8 100644 --- a/Tests/CompileFeatures/cxx_attribute_deprecated.cpp +++ b/Tests/CompileFeatures/cxx_attribute_deprecated.cpp @@ -1,5 +1,8 @@ -[[deprecated]] int foo() { return 0; } +[[deprecated]] int foo() +{ + return 0; +} int someFunc() { diff --git a/Tests/CompileFeatures/cxx_attributes.cpp b/Tests/CompileFeatures/cxx_attributes.cpp index 1434317..543a3f5 100644 --- a/Tests/CompileFeatures/cxx_attributes.cpp +++ b/Tests/CompileFeatures/cxx_attributes.cpp @@ -1,5 +1,5 @@ -void unusedFunc[[noreturn]]() +void unusedFunc [[noreturn]] () { throw 1; } diff --git a/Tests/Cuda/SeparableCompCXXOnly/main.cpp b/Tests/Cuda/SeparableCompCXXOnly/main.cpp index 8135246..ed913ff 100644 --- a/Tests/Cuda/SeparableCompCXXOnly/main.cpp +++ b/Tests/Cuda/SeparableCompCXXOnly/main.cpp @@ -1,5 +1,5 @@ -int main(int, char const* []) +int main(int, char const*[]) { return 0; } diff --git a/Tests/FindOpenACC/CXXTest/main.cxx b/Tests/FindOpenACC/CXXTest/main.cxx index 7369045..14b912b 100644 --- a/Tests/FindOpenACC/CXXTest/main.cxx +++ b/Tests/FindOpenACC/CXXTest/main.cxx @@ -8,7 +8,7 @@ void vecaddgpu(float* r, float* a, float* b, std::size_t n) r[i] = a[i] + b[i]; } -int main(int, char* []) +int main(int, char*[]) { const std::size_t n = 100000; /* vector length */ std::vector<float> a(n); /* input vector 1 */ diff --git a/Tests/QtAutogen/Complex/calwidget.cpp b/Tests/QtAutogen/Complex/calwidget.cpp index f58b182..202ed49 100644 --- a/Tests/QtAutogen/Complex/calwidget.cpp +++ b/Tests/QtAutogen/Complex/calwidget.cpp @@ -433,4 +433,4 @@ QComboBox* Window::createColorComboBox() return comboBox; } -//#include "moc_calwidget.cpp" +// #include "moc_calwidget.cpp" diff --git a/Tests/RunCMake/CXXModules/examples/internal-partitions/importable.cxx b/Tests/RunCMake/CXXModules/examples/internal-partitions/importable.cxx index b872ae9..3b3d313 100644 --- a/Tests/RunCMake/CXXModules/examples/internal-partitions/importable.cxx +++ b/Tests/RunCMake/CXXModules/examples/internal-partitions/importable.cxx @@ -1,5 +1,5 @@ export module importable; -import : internal_partition; +import :internal_partition; #include "internal-partitions_export.h" diff --git a/Tests/RunCMake/CXXModules/examples/internal-partitions/partition.cxx b/Tests/RunCMake/CXXModules/examples/internal-partitions/partition.cxx index b15f53c..c828612 100644 --- a/Tests/RunCMake/CXXModules/examples/internal-partitions/partition.cxx +++ b/Tests/RunCMake/CXXModules/examples/internal-partitions/partition.cxx @@ -1,4 +1,4 @@ -module importable : internal_partition; +module importable:internal_partition; int from_partition() { diff --git a/Tests/RunCMake/CXXModules/examples/partitions/importable.cxx b/Tests/RunCMake/CXXModules/examples/partitions/importable.cxx index d0ac2f4..fbd5f90 100644 --- a/Tests/RunCMake/CXXModules/examples/partitions/importable.cxx +++ b/Tests/RunCMake/CXXModules/examples/partitions/importable.cxx @@ -1,5 +1,5 @@ export module importable; -export import : partition; +export import :partition; #include "partitions_export.h" diff --git a/Tests/RunCMake/CXXModules/examples/partitions/partition.cxx b/Tests/RunCMake/CXXModules/examples/partitions/partition.cxx index a47a4fd..20131cf 100644 --- a/Tests/RunCMake/CXXModules/examples/partitions/partition.cxx +++ b/Tests/RunCMake/CXXModules/examples/partitions/partition.cxx @@ -1,4 +1,4 @@ -export module importable : partition; +export module importable:partition; #include "partitions_export.h" diff --git a/Tests/RunCMake/CXXModules/sources/module-internal-part-impl.cxx b/Tests/RunCMake/CXXModules/sources/module-internal-part-impl.cxx index be77b0d..cab19ec 100644 --- a/Tests/RunCMake/CXXModules/sources/module-internal-part-impl.cxx +++ b/Tests/RunCMake/CXXModules/sources/module-internal-part-impl.cxx @@ -1,6 +1,6 @@ #ifdef _MSC_VER // Only MSVC supports this pattern. -module M : internal_part; +module M:internal_part; #else module M; #endif diff --git a/Tests/RunCMake/CXXModules/sources/module-internal-part.cxx b/Tests/RunCMake/CXXModules/sources/module-internal-part.cxx index fa82afb..0dc749f 100644 --- a/Tests/RunCMake/CXXModules/sources/module-internal-part.cxx +++ b/Tests/RunCMake/CXXModules/sources/module-internal-part.cxx @@ -1,3 +1,3 @@ -module M : internal_part; +module M:internal_part; int i(); diff --git a/Tests/RunCMake/CXXModules/sources/module-part-impl.cxx b/Tests/RunCMake/CXXModules/sources/module-part-impl.cxx index 46d5d9f..f3b6ba8 100644 --- a/Tests/RunCMake/CXXModules/sources/module-part-impl.cxx +++ b/Tests/RunCMake/CXXModules/sources/module-part-impl.cxx @@ -1,11 +1,11 @@ #ifdef _MSC_VER // Only MSVC supports this pattern. -module M : part; +module M:part; #else module M; #endif -import M : internal_part; +import M:internal_part; int p() { diff --git a/Tests/RunCMake/CXXModules/sources/module-part.cxx b/Tests/RunCMake/CXXModules/sources/module-part.cxx index 137c16f..307781b 100644 --- a/Tests/RunCMake/CXXModules/sources/module-part.cxx +++ b/Tests/RunCMake/CXXModules/sources/module-part.cxx @@ -1,3 +1,3 @@ -export module M : part; +export module M:part; int p(); diff --git a/Tests/RunCMake/CXXModules/sources/module.cxx b/Tests/RunCMake/CXXModules/sources/module.cxx index a631354..37eedeb 100644 --- a/Tests/RunCMake/CXXModules/sources/module.cxx +++ b/Tests/RunCMake/CXXModules/sources/module.cxx @@ -1,5 +1,5 @@ export module M; -export import M : part; -import M : internal_part; +export import M:part; +import M:internal_part; int f(); diff --git a/Tests/RunCMake/CommandLine/cmake_depends/test.c b/Tests/RunCMake/CommandLine/cmake_depends/test.c index 92c056f..5b42255 100644 --- a/Tests/RunCMake/CommandLine/cmake_depends/test.c +++ b/Tests/RunCMake/CommandLine/cmake_depends/test.c @@ -1,2 +1,3 @@ #include "test.h" + #include "test_UTF-16LE.h" diff --git a/Tests/RunCMake/GenEx-TARGET_FILE/OUTPUT_NAME-recursion-stderr.txt b/Tests/RunCMake/GenEx-TARGET_FILE/OUTPUT_NAME-recursion-stderr.txt index 013c4f2..9af0573 100644 --- a/Tests/RunCMake/GenEx-TARGET_FILE/OUTPUT_NAME-recursion-stderr.txt +++ b/Tests/RunCMake/GenEx-TARGET_FILE/OUTPUT_NAME-recursion-stderr.txt @@ -1,5 +1,5 @@ CMake Error at OUTPUT_NAME-recursion.cmake:[0-9]+ \(add_executable\): - Target 'empty2' OUTPUT_NAME depends on itself. + Target 'empty1' OUTPUT_NAME depends on itself. Call Stack \(most recent call first\): CMakeLists.txt:3 \(include\) diff --git a/Tests/StringFileTest/StringFile.cxx b/Tests/StringFileTest/StringFile.cxx index c890e8e..073e30c 100644 --- a/Tests/StringFileTest/StringFile.cxx +++ b/Tests/StringFileTest/StringFile.cxx @@ -3,7 +3,7 @@ #include "OutputFile.h" -int main(int, char* []) +int main(int, char*[]) { int res = 0; diff --git a/Tests/SystemInformation/DumpInformation.cxx b/Tests/SystemInformation/DumpInformation.cxx index e50db40..913e4c4 100644 --- a/Tests/SystemInformation/DumpInformation.cxx +++ b/Tests/SystemInformation/DumpInformation.cxx @@ -53,7 +53,7 @@ void cmDumpInformationPrintFile(const char* name, FILE* fout) } } -int main(int, char* []) +int main(int, char*[]) { const char* files[] = { DumpInformation_BINARY_DIR "/SystemInformation.out", diff --git a/Tests/VSWinStorePhone/Direct3DApp1/BasicTimer.h b/Tests/VSWinStorePhone/Direct3DApp1/BasicTimer.h index 56bd398..ccbbcda 100644 --- a/Tests/VSWinStorePhone/Direct3DApp1/BasicTimer.h +++ b/Tests/VSWinStorePhone/Direct3DApp1/BasicTimer.h @@ -52,13 +52,19 @@ public: // Update(). property float Total { - float get() { return m_total; } + float get() + { + return m_total; + } } // Duration in seconds between the previous two calls to Update(). property float Delta { - float get() { return m_delta; } + float get() + { + return m_delta; + } } private: diff --git a/Tests/Wrapping/Wrap.c b/Tests/Wrapping/Wrap.c index e8fb8a5..30ac173 100644 --- a/Tests/Wrapping/Wrap.c +++ b/Tests/Wrapping/Wrap.c @@ -1,7 +1,8 @@ #include <stdio.h> #ifdef __CLASSIC_C__ -int main(argc, argv) int argc; +int main(argc, argv) +int argc; char** argv; #else int main(int argc, const char* argv[]) diff --git a/Utilities/.gitattributes b/Utilities/.gitattributes index f799e88..c43b55d 100644 --- a/Utilities/.gitattributes +++ b/Utilities/.gitattributes @@ -5,4 +5,4 @@ SetupForDevelopment.sh export-ignore # Do not format third-party sources. /KWIML/** -format.clang-format /cm*/** -format.clang-format -/cmcurl/curltest.c format.clang-format=6.0 +/cmcurl/curltest.c format.clang-format=15 diff --git a/Utilities/Scripts/clang-format.bash b/Utilities/Scripts/clang-format.bash index 9b38a5b..27ed40f 100755 --- a/Utilities/Scripts/clang-format.bash +++ b/Utilities/Scripts/clang-format.bash @@ -78,7 +78,7 @@ test "$#" = 0 || die "$usage" # Find a default tool. tools=' - clang-format-6.0 + clang-format-15 clang-format ' if test "x$clang_format" = "x"; then @@ -96,8 +96,8 @@ if ! type -p "$clang_format" >/dev/null; then exit 1 fi -if ! "$clang_format" --version | grep 'clang-format version 6\.0' >/dev/null 2>/dev/null; then - echo "clang-format version 6.0 is required (exactly)" +if ! "$clang_format" --version | grep 'clang-format version 15' >/dev/null 2>/dev/null; then + echo "clang-format version 15 is required (exactly)" exit 1 fi @@ -116,7 +116,7 @@ $git_ls | # Select sources with our attribute. git check-attr --stdin format.clang-format | - sed -n '/: format\.clang-format: \(set\|6\.0\)$/ {s/:[^:]*:[^:]*$//p}' | + sed -n '/: format\.clang-format: \(set\|15\)$/ {s/:[^:]*:[^:]*$//p}' | # Update sources in-place. xargs -d '\n' "$clang_format" -i diff --git a/Utilities/std/cm/bits/string_view.cxx b/Utilities/std/cm/bits/string_view.cxx index 5381fe6..af5ae78 100644 --- a/Utilities/std/cm/bits/string_view.cxx +++ b/Utilities/std/cm/bits/string_view.cxx @@ -82,8 +82,8 @@ int string_view::compare(size_type pos1, size_type count1, const char* s, return substr(pos1, count1).compare(string_view(s, count2)); } -string_view::size_type string_view::find(string_view v, size_type pos) const - noexcept +string_view::size_type string_view::find(string_view v, + size_type pos) const noexcept { for (; pos + v.size_ <= size_; ++pos) { if (std::char_traits<char>::compare(data_ + pos, v.data_, v.size_) == 0) { @@ -109,8 +109,8 @@ string_view::size_type string_view::find(const char* s, size_type pos) const return find(string_view(s), pos); } -string_view::size_type string_view::rfind(string_view v, size_type pos) const - noexcept +string_view::size_type string_view::rfind(string_view v, + size_type pos) const noexcept { if (size_ >= v.size_) { for (pos = std::min(pos, size_ - v.size_) + 1; pos > 0;) { @@ -151,8 +151,8 @@ string_view::size_type string_view::find_first_of(string_view v, return npos; } -string_view::size_type string_view::find_first_of(char c, size_type pos) const - noexcept +string_view::size_type string_view::find_first_of(char c, + size_type pos) const noexcept { return find_first_of(string_view(&c, 1), pos); } @@ -183,8 +183,8 @@ string_view::size_type string_view::find_last_of(string_view v, return npos; } -string_view::size_type string_view::find_last_of(char c, size_type pos) const - noexcept +string_view::size_type string_view::find_last_of(char c, + size_type pos) const noexcept { return find_last_of(string_view(&c, 1), pos); } @@ -201,9 +201,8 @@ string_view::size_type string_view::find_last_of(const char* s, return find_last_of(string_view(s), pos); } -string_view::size_type string_view::find_first_not_of(string_view v, - size_type pos) const - noexcept +string_view::size_type string_view::find_first_not_of( + string_view v, size_type pos) const noexcept { for (; pos < size_; ++pos) { if (!traits_type::find(v.data_, v.size_, data_[pos])) { @@ -213,9 +212,8 @@ string_view::size_type string_view::find_first_not_of(string_view v, return npos; } -string_view::size_type string_view::find_first_not_of(char c, - size_type pos) const - noexcept +string_view::size_type string_view::find_first_not_of( + char c, size_type pos) const noexcept { return find_first_not_of(string_view(&c, 1), pos); } @@ -233,9 +231,8 @@ string_view::size_type string_view::find_first_not_of(const char* s, return find_first_not_of(string_view(s), pos); } -string_view::size_type string_view::find_last_not_of(string_view v, - size_type pos) const - noexcept +string_view::size_type string_view::find_last_not_of( + string_view v, size_type pos) const noexcept { if (size_ > 0) { for (pos = std::min(pos, size_ - 1) + 1; pos > 0;) { @@ -248,9 +245,8 @@ string_view::size_type string_view::find_last_not_of(string_view v, return npos; } -string_view::size_type string_view::find_last_not_of(char c, - size_type pos) const - noexcept +string_view::size_type string_view::find_last_not_of( + char c, size_type pos) const noexcept { return find_last_not_of(string_view(&c, 1), pos); } diff --git a/Utilities/std/cm/string_view b/Utilities/std/cm/string_view index 35cf5d9..320e1e7 100644 --- a/Utilities/std/cm/string_view +++ b/Utilities/std/cm/string_view @@ -157,8 +157,8 @@ public: size_type count) const; size_type find_first_not_of(const char* s, size_type pos = 0) const; - size_type find_last_not_of(string_view v, size_type pos = npos) const - noexcept; + size_type find_last_not_of(string_view v, + size_type pos = npos) const noexcept; size_type find_last_not_of(char c, size_type pos = npos) const noexcept; size_type find_last_not_of(const char* s, size_type pos, size_type count) const; diff --git a/Utilities/std/cmext/iterator b/Utilities/std/cmext/iterator index 83d7890..eba10dd 100644 --- a/Utilities/std/cmext/iterator +++ b/Utilities/std/cmext/iterator @@ -39,10 +39,10 @@ using is_input_range = std::is_pointer<Range>::value || std::is_array<Range>::value>; #else - cm::bool_constant<cm::is_input_iterator<decltype( - std::begin(std::declval<const Range>()))>::value && - cm::is_input_iterator<decltype( - std::end(std::declval<const Range>()))>::value>; + cm::bool_constant<cm::is_input_iterator<decltype(std::begin( + std::declval<const Range>()))>::value && + cm::is_input_iterator<decltype(std::end( + std::declval<const Range>()))>::value>; #endif } // namespace cm |