diff options
42 files changed, 156 insertions, 131 deletions
diff --git a/Help/envvar/CMAKE_LANG_IMPLICIT_LINK_DIRECTORIES_EXCLUDE.rst b/Help/envvar/CMAKE_LANG_IMPLICIT_LINK_DIRECTORIES_EXCLUDE.rst new file mode 100644 index 0000000..36c79fa --- /dev/null +++ b/Help/envvar/CMAKE_LANG_IMPLICIT_LINK_DIRECTORIES_EXCLUDE.rst @@ -0,0 +1,13 @@ +CMAKE_<LANG>_IMPLICIT_LINK_DIRECTORIES_EXCLUDE +---------------------------------------------- + +.. versionadded:: 3.27 + +.. include:: ENV_VAR.txt + +A :ref:`semicolon-separated list <CMake Language Lists>` of directories +to exclude from the :variable:`CMAKE_<LANG>_IMPLICIT_LINK_DIRECTORIES` +variable when it is automatically detected from the ``<LANG>`` compiler. + +This may be used to work around misconfigured compiler drivers that pass +extraneous implicit link directories to their linker. diff --git a/Help/manual/cmake-env-variables.7.rst b/Help/manual/cmake-env-variables.7.rst index f7ae94d..197e56e 100644 --- a/Help/manual/cmake-env-variables.7.rst +++ b/Help/manual/cmake-env-variables.7.rst @@ -50,6 +50,7 @@ Environment Variables that Control the Build /envvar/CMAKE_GENERATOR_TOOLSET /envvar/CMAKE_INSTALL_MODE /envvar/CMAKE_LANG_COMPILER_LAUNCHER + /envvar/CMAKE_LANG_IMPLICIT_LINK_DIRECTORIES_EXCLUDE /envvar/CMAKE_LANG_LINKER_LAUNCHER /envvar/CMAKE_MSVCIDE_RUN_PATH /envvar/CMAKE_NO_VERBOSE diff --git a/Help/variable/CMAKE_LANG_IMPLICIT_LINK_DIRECTORIES.rst b/Help/variable/CMAKE_LANG_IMPLICIT_LINK_DIRECTORIES.rst index 081c4da..7e008df 100644 --- a/Help/variable/CMAKE_LANG_IMPLICIT_LINK_DIRECTORIES.rst +++ b/Help/variable/CMAKE_LANG_IMPLICIT_LINK_DIRECTORIES.rst @@ -6,9 +6,14 @@ Implicit linker search path detected for language ``<LANG>``. Compilers typically pass directories containing language runtime libraries and default library search paths when they invoke a linker. These paths are implicit linker search directories for the compiler's -language. For each language enabled by the :command:`project` or +language. + +For each language enabled by the :command:`project` or :command:`enable_language` command, CMake automatically detects these directories and reports the results in this variable. +The :envvar:`CMAKE_<LANG>_IMPLICIT_LINK_DIRECTORIES_EXCLUDE` environment +variable may be set to exclude specific directories from the automatically +detected results. When linking to a static library, CMake adds the implicit link directories from this variable for each language used in the static library (except diff --git a/Modules/CMakeASMCompiler.cmake.in b/Modules/CMakeASMCompiler.cmake.in index 8a1718b..1efd9f5 100644 --- a/Modules/CMakeASMCompiler.cmake.in +++ b/Modules/CMakeASMCompiler.cmake.in @@ -17,6 +17,6 @@ set(CMAKE_ASM@ASM_DIALECT@_COMPILER_ENV_VAR "@_CMAKE_ASM_COMPILER_ENV_VAR@") set(CMAKE_ASM@ASM_DIALECT@_IGNORE_EXTENSIONS h;H;o;O;obj;OBJ;def;DEF;rc;RC) set(CMAKE_ASM@ASM_DIALECT@_LINKER_PREFERENCE 0) -set(CMAKE_ASM@ASM_DIALECT@_LINKER_DEPFILE_SUPPORTED "@CMAKE_ASM_LINKER_DEPFILE_SUPPORTED@") +set(CMAKE_ASM@ASM_DIALECT@_LINKER_DEPFILE_SUPPORTED @CMAKE_ASM_LINKER_DEPFILE_SUPPORTED@) @CMAKE_ASM_COMPILER_CUSTOM_CODE@ diff --git a/Modules/CMakeCCompiler.cmake.in b/Modules/CMakeCCompiler.cmake.in index cf3a242..2f0b774 100644 --- a/Modules/CMakeCCompiler.cmake.in +++ b/Modules/CMakeCCompiler.cmake.in @@ -39,7 +39,7 @@ set(CMAKE_C_COMPILER_ID_RUN 1) set(CMAKE_C_SOURCE_FILE_EXTENSIONS c;m) set(CMAKE_C_IGNORE_EXTENSIONS h;H;o;O;obj;OBJ;def;DEF;rc;RC) set(CMAKE_C_LINKER_PREFERENCE 10) -set(CMAKE_C_LINKER_DEPFILE_SUPPORTED "@CMAKE_C_LINKER_DEPFILE_SUPPORTED@") +set(CMAKE_C_LINKER_DEPFILE_SUPPORTED @CMAKE_C_LINKER_DEPFILE_SUPPORTED@) # Save compiler ABI information. set(CMAKE_C_SIZEOF_DATA_PTR "@CMAKE_C_SIZEOF_DATA_PTR@") diff --git a/Modules/CMakeCUDACompiler.cmake.in b/Modules/CMakeCUDACompiler.cmake.in index 3d7d552..3c28c28 100644 --- a/Modules/CMakeCUDACompiler.cmake.in +++ b/Modules/CMakeCUDACompiler.cmake.in @@ -30,7 +30,7 @@ set(CMAKE_CUDA_COMPILER_ID_RUN 1) set(CMAKE_CUDA_SOURCE_FILE_EXTENSIONS cu) set(CMAKE_CUDA_LINKER_PREFERENCE 15) set(CMAKE_CUDA_LINKER_PREFERENCE_PROPAGATES 1) -set(CMAKE_CUDA_LINKER_DEPFILE_SUPPORTED "@CMAKE_CUDA_LINKER_DEPFILE_SUPPORTED@") +set(CMAKE_CUDA_LINKER_DEPFILE_SUPPORTED @CMAKE_CUDA_LINKER_DEPFILE_SUPPORTED@) set(CMAKE_CUDA_SIZEOF_DATA_PTR "@CMAKE_CUDA_SIZEOF_DATA_PTR@") set(CMAKE_CUDA_COMPILER_ABI "@CMAKE_CUDA_COMPILER_ABI@") diff --git a/Modules/CMakeCXXCompiler.cmake.in b/Modules/CMakeCXXCompiler.cmake.in index 2052e7f..8b6f82b 100644 --- a/Modules/CMakeCXXCompiler.cmake.in +++ b/Modules/CMakeCXXCompiler.cmake.in @@ -50,7 +50,7 @@ endforeach() set(CMAKE_CXX_LINKER_PREFERENCE 30) set(CMAKE_CXX_LINKER_PREFERENCE_PROPAGATES 1) -set(CMAKE_CXX_LINKER_DEPFILE_SUPPORTED "@CMAKE_CXX_LINKER_DEPFILE_SUPPORTED@") +set(CMAKE_CXX_LINKER_DEPFILE_SUPPORTED @CMAKE_CXX_LINKER_DEPFILE_SUPPORTED@) # Save compiler ABI information. set(CMAKE_CXX_SIZEOF_DATA_PTR "@CMAKE_CXX_SIZEOF_DATA_PTR@") diff --git a/Modules/CMakeDetermineCompilerABI.cmake b/Modules/CMakeDetermineCompilerABI.cmake index 3fd54cc..d665cd1 100644 --- a/Modules/CMakeDetermineCompilerABI.cmake +++ b/Modules/CMakeDetermineCompilerABI.cmake @@ -181,6 +181,10 @@ function(CMAKE_DETERMINE_COMPILER_ABI lang src) endif() endif() + if(DEFINED ENV{CMAKE_${lang}_IMPLICIT_LINK_DIRECTORIES_EXCLUDE}) + list(REMOVE_ITEM implicit_dirs $ENV{CMAKE_${lang}_IMPLICIT_LINK_DIRECTORIES_EXCLUDE}) + endif() + set(CMAKE_${lang}_IMPLICIT_LINK_LIBRARIES "${implicit_libs}" PARENT_SCOPE) set(CMAKE_${lang}_IMPLICIT_LINK_DIRECTORIES "${implicit_dirs}" PARENT_SCOPE) set(CMAKE_${lang}_IMPLICIT_LINK_FRAMEWORK_DIRECTORIES "${implicit_fwks}" PARENT_SCOPE) diff --git a/Modules/CMakeFortranCompiler.cmake.in b/Modules/CMakeFortranCompiler.cmake.in index a7caf2b..6a2be28 100644 --- a/Modules/CMakeFortranCompiler.cmake.in +++ b/Modules/CMakeFortranCompiler.cmake.in @@ -29,7 +29,7 @@ set(CMAKE_Fortran_COMPILER_ID_RUN 1) set(CMAKE_Fortran_SOURCE_FILE_EXTENSIONS f;F;fpp;FPP;f77;F77;f90;F90;for;For;FOR;f95;F95;f03;F03;f08;F08@CMAKE_Fortran_VENDOR_SOURCE_FILE_EXTENSIONS@) set(CMAKE_Fortran_IGNORE_EXTENSIONS h;H;o;O;obj;OBJ;def;DEF;rc;RC) set(CMAKE_Fortran_LINKER_PREFERENCE 20) -set(CMAKE_Fortran_LINKER_DEPFILE_SUPPORTED "@CMAKE_Fortran_LINKER_DEPFILE_SUPPORTED@") +set(CMAKE_Fortran_LINKER_DEPFILE_SUPPORTED @CMAKE_Fortran_LINKER_DEPFILE_SUPPORTED@) if(UNIX) set(CMAKE_Fortran_OUTPUT_EXTENSION .o) else() diff --git a/Modules/CMakeHIPCompiler.cmake.in b/Modules/CMakeHIPCompiler.cmake.in index 32c1223..c94153b 100644 --- a/Modules/CMakeHIPCompiler.cmake.in +++ b/Modules/CMakeHIPCompiler.cmake.in @@ -26,7 +26,7 @@ set(CMAKE_HIP_COMPILER_ID_RUN 1) set(CMAKE_HIP_SOURCE_FILE_EXTENSIONS hip) set(CMAKE_HIP_LINKER_PREFERENCE 90) set(CMAKE_HIP_LINKER_PREFERENCE_PROPAGATES 1) -set(CMAKE_HIP_LINKER_DEPFILE_SUPPORTED "@CMAKE_HIP_LINKER_DEPFILE_SUPPORTED@") +set(CMAKE_HIP_LINKER_DEPFILE_SUPPORTED @CMAKE_HIP_LINKER_DEPFILE_SUPPORTED@) set(CMAKE_HIP_SIZEOF_DATA_PTR "@CMAKE_HIP_SIZEOF_DATA_PTR@") set(CMAKE_HIP_COMPILER_ABI "@CMAKE_HIP_COMPILER_ABI@") diff --git a/Modules/CMakeOBJCCompiler.cmake.in b/Modules/CMakeOBJCCompiler.cmake.in index 0ceb804..de73645 100644 --- a/Modules/CMakeOBJCCompiler.cmake.in +++ b/Modules/CMakeOBJCCompiler.cmake.in @@ -37,7 +37,7 @@ set(CMAKE_OBJC_COMPILER_ID_RUN 1) set(CMAKE_OBJC_SOURCE_FILE_EXTENSIONS m) set(CMAKE_OBJC_IGNORE_EXTENSIONS h;H;o;O) set(CMAKE_OBJC_LINKER_PREFERENCE 5) -set(CMAKE_OBJC_LINKER_DEPFILE_SUPPORTED "@CMAKE_OBJC_LINKER_DEPFILE_SUPPORTED@") +set(CMAKE_OBJC_LINKER_DEPFILE_SUPPORTED @CMAKE_OBJC_LINKER_DEPFILE_SUPPORTED@) foreach (lang C CXX OBJCXX) foreach(extension IN LISTS CMAKE_OBJC_SOURCE_FILE_EXTENSIONS) diff --git a/Modules/CMakeOBJCXXCompiler.cmake.in b/Modules/CMakeOBJCXXCompiler.cmake.in index f087ec3..94d24ff 100644 --- a/Modules/CMakeOBJCXXCompiler.cmake.in +++ b/Modules/CMakeOBJCXXCompiler.cmake.in @@ -54,7 +54,7 @@ endforeach() set(CMAKE_OBJCXX_LINKER_PREFERENCE 25) set(CMAKE_OBJCXX_LINKER_PREFERENCE_PROPAGATES 1) -set(CMAKE_OBJCXX_LINKER_DEPFILE_SUPPORTED "@CMAKE_OBJCXX_LINKER_DEPFILE_SUPPORTED@") +set(CMAKE_OBJCXX_LINKER_DEPFILE_SUPPORTED @CMAKE_OBJCXX_LINKER_DEPFILE_SUPPORTED@) # Save compiler ABI information. set(CMAKE_OBJCXX_SIZEOF_DATA_PTR "@CMAKE_OBJCXX_SIZEOF_DATA_PTR@") diff --git a/Modules/Compiler/Clang-HIP.cmake b/Modules/Compiler/Clang-HIP.cmake index 7e3c99c..92925f1 100644 --- a/Modules/Compiler/Clang-HIP.cmake +++ b/Modules/Compiler/Clang-HIP.cmake @@ -1,13 +1,5 @@ include(Compiler/Clang) -# -# For now, deactivate globally linker dependency file support because -# HIP compiler is based on Clang which provides support of other languages -# -foreach (lang IN ITEMS "C" "CXX" "OBJC" "OBJCXX" "Fortran" "ASM") - set(CMAKE_${lang}_LINKER_DEPFILE_SUPPORTED FALSE) -endforeach() - __compiler_clang(HIP) __compiler_clang_cxx_standards(HIP) diff --git a/Modules/Compiler/GNU.cmake b/Modules/Compiler/GNU.cmake index f140208..251e05a 100644 --- a/Modules/Compiler/GNU.cmake +++ b/Modules/Compiler/GNU.cmake @@ -53,7 +53,7 @@ macro(__compiler_gnu lang) endif() # define flags for linker depfile generation - if (NOT DEFINED CMAKE_${lang}_LINKER_DEPFILE_SUPPORTED) + if(NOT DEFINED CMAKE_${lang}_LINKER_DEPFILE_SUPPORTED) ## Ensure ninja tool is recent enough... if(CMAKE_GENERATOR MATCHES "^Ninja") # Ninja 1.10 or upper is required @@ -71,7 +71,7 @@ macro(__compiler_gnu lang) if (NOT DEFINED CMAKE_${lang}_LINKER_DEPFILE_SUPPORTED) ## check if this feature is supported by the linker - execute_process(COMMAND "${CMAKE_LINKER}" --help + execute_process(COMMAND "${CMAKE_${lang}_COMPILER}" -Wl,--help OUTPUT_VARIABLE _linker_capabilities ERROR_VARIABLE _linker_capabilities) if(_linker_capabilities MATCHES "--dependency-file") @@ -82,6 +82,7 @@ macro(__compiler_gnu lang) unset(_linker_capabilities) endif() endif() + if (CMAKE_${lang}_LINKER_DEPFILE_SUPPORTED) set(CMAKE_${lang}_LINKER_DEPFILE_FLAGS "LINKER:--dependency-file,<DEP_FILE>") set(CMAKE_${lang}_LINKER_DEPFILE_FORMAT gcc) diff --git a/Modules/Platform/Windows-IntelLLVM.cmake b/Modules/Platform/Windows-IntelLLVM.cmake index 43f5874..eac3f0a 100644 --- a/Modules/Platform/Windows-IntelLLVM.cmake +++ b/Modules/Platform/Windows-IntelLLVM.cmake @@ -54,6 +54,7 @@ macro(__windows_compiler_intel lang) "${_CMAKE_VS_LINK_EXE}<CMAKE_${lang}_COMPILER> ${CMAKE_CL_NOLOGO} <CMAKE_${lang}_LINK_FLAGS> <OBJECTS> ${CMAKE_START_TEMP_FILE} <LINK_FLAGS> <LINK_LIBRARIES> /link /out:<TARGET> /implib:<TARGET_IMPLIB> /pdb:<TARGET_PDB> /version:<TARGET_VERSION_MAJOR>.<TARGET_VERSION_MINOR>${_PLATFORM_LINK_FLAGS} ${CMAKE_END_TEMP_FILE}") set(CMAKE_${lang}_CREATE_SHARED_LIBRARY "${_CMAKE_VS_LINK_DLL}<CMAKE_${lang}_COMPILER> ${CMAKE_CL_NOLOGO} <CMAKE_${lang}_LINK_FLAGS> <OBJECTS> ${CMAKE_START_TEMP_FILE} -LD <LINK_FLAGS> <LINK_LIBRARIES> -link /out:<TARGET> /implib:<TARGET_IMPLIB> /pdb:<TARGET_PDB> /version:<TARGET_VERSION_MAJOR>.<TARGET_VERSION_MINOR>${_PLATFORM_LINK_FLAGS} ${CMAKE_END_TEMP_FILE}") + set(CMAKE_${lang}_CREATE_SHARED_MODULE ${CMAKE_${lang}_CREATE_SHARED_LIBRARY}) if (NOT "${lang}" STREQUAL "Fortran" OR CMAKE_${lang}_COMPILER_VERSION VERSION_GREATER_EQUAL 2022.1) # The Fortran driver does not support -fuse-ld=llvm-lib before compiler version 2022.1 set(CMAKE_${lang}_CREATE_STATIC_LIBRARY diff --git a/Source/CMakeVersion.cmake b/Source/CMakeVersion.cmake index 823fb81..95f4095 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 26) -set(CMake_VERSION_PATCH 20230525) +set(CMake_VERSION_PATCH 20230530) #set(CMake_VERSION_RC 0) set(CMake_VERSION_IS_DIRTY 0) diff --git a/Source/cmCMakeLanguageCommand.cxx b/Source/cmCMakeLanguageCommand.cxx index 68e658c..c7e9209 100644 --- a/Source/cmCMakeLanguageCommand.cxx +++ b/Source/cmCMakeLanguageCommand.cxx @@ -303,7 +303,7 @@ bool cmCMakeLanguageCommandSET_DEPENDENCY_PROVIDER( state->SetDependencyProvider({ parsedArgs.Command, methods }); state->SetGlobalProperty( fcmasProperty, - supportsFetchContentMakeAvailableSerial ? parsedArgs.Command.c_str() : ""); + supportsFetchContentMakeAvailableSerial ? parsedArgs.Command : ""); return true; } diff --git a/Source/cmCPluginAPI.cxx b/Source/cmCPluginAPI.cxx index abec968..c2c5bdb 100644 --- a/Source/cmCPluginAPI.cxx +++ b/Source/cmCPluginAPI.cxx @@ -615,7 +615,11 @@ static void CCONV cmSourceFileSetProperty(void* arg, const char* prop, { cmCPluginAPISourceFile* sf = static_cast<cmCPluginAPISourceFile*>(arg); if (cmSourceFile* rsf = sf->RealSourceFile) { - rsf->SetProperty(prop, value); + if (value == nullptr) { + rsf->SetProperty(prop, nullptr); + } else { + rsf->SetProperty(prop, value); + } } else if (prop) { if (!value) { value = "NOTFOUND"; diff --git a/Source/cmCacheManager.cxx b/Source/cmCacheManager.cxx index d95dcc4..8633de1 100644 --- a/Source/cmCacheManager.cxx +++ b/Source/cmCacheManager.cxx @@ -84,7 +84,7 @@ bool cmCacheManager::LoadCache(const std::string& path, bool internal, continue; } } - e.SetProperty("HELPSTRING", helpString.c_str()); + e.SetProperty("HELPSTRING", helpString); if (cmState::ParseCacheEntry(realbuffer, entryKey, e.Value, e.Type)) { if (excludes.find(entryKey) == excludes.end()) { // Load internal values if internal is set. @@ -102,7 +102,7 @@ bool cmCacheManager::LoadCache(const std::string& path, bool internal, " loaded from external file. " "To change this value edit this file: ", path, "/CMakeCache.txt"); - e.SetProperty("HELPSTRING", helpString.c_str()); + e.SetProperty("HELPSTRING", helpString); } if (!this->ReadPropertyEntry(entryKey, e)) { e.Initialized = true; @@ -186,11 +186,11 @@ bool cmCacheManager::ReadPropertyEntry(const std::string& entryKey, std::string key = entryKey.substr(0, entryKey.size() - plen); if (auto* entry = this->GetCacheEntry(key)) { // Store this property on its entry. - entry->SetProperty(p, e.Value.c_str()); + entry->SetProperty(p, e.Value); } else { // Create an entry and store the property. CacheEntry& ne = this->Cache[key]; - ne.SetProperty(p, e.Value.c_str()); + ne.SetProperty(p, e.Value); } return true; } @@ -541,10 +541,11 @@ void cmCacheManager::AddCacheEntry(const std::string& key, cmValue value, cmSystemTools::ConvertToUnixSlashes(e.Value); } } - e.SetProperty("HELPSTRING", - helpString - ? helpString - : "(This variable does not exist and should not be used)"); + e.SetProperty( + "HELPSTRING", + helpString ? std::string{ helpString } + : std::string{ + "(This variable does not exist and should not be used)" }); } void cmCacheManager::CacheEntry::SetValue(cmValue value) @@ -580,12 +581,12 @@ bool cmCacheManager::CacheEntry::GetPropertyAsBool( } void cmCacheManager::CacheEntry::SetProperty(const std::string& prop, - const char* value) + const std::string& value) { if (prop == "TYPE") { - this->Type = cmState::StringToCacheEntryType(value ? value : "STRING"); + this->Type = cmState::StringToCacheEntryType(value); } else if (prop == "VALUE") { - this->Value = value ? value : ""; + this->Value = value; } else { this->Properties.SetProperty(prop, value); } @@ -593,7 +594,19 @@ void cmCacheManager::CacheEntry::SetProperty(const std::string& prop, void cmCacheManager::CacheEntry::SetProperty(const std::string& p, bool v) { - this->SetProperty(p, v ? "ON" : "OFF"); + this->SetProperty(p, v ? std::string{ "ON" } : std::string{ "OFF" }); +} + +void cmCacheManager::CacheEntry::SetProperty(const std::string& prop, + std::nullptr_t) +{ + if (prop == "TYPE") { + this->Type = cmState::StringToCacheEntryType("STRING"); + } else if (prop == "VALUE") { + this->Value = ""; + } else { + this->Properties.SetProperty(prop, cmValue{ nullptr }); + } } void cmCacheManager::CacheEntry::AppendProperty(const std::string& prop, diff --git a/Source/cmCacheManager.h b/Source/cmCacheManager.h index bc3fb51..a2da0b5 100644 --- a/Source/cmCacheManager.h +++ b/Source/cmCacheManager.h @@ -39,8 +39,9 @@ class cmCacheManager std::vector<std::string> GetPropertyList() const; cmValue GetProperty(const std::string& property) const; bool GetPropertyAsBool(const std::string& property) const; - void SetProperty(const std::string& property, const char* value); + void SetProperty(const std::string& property, const std::string& value); void SetProperty(const std::string& property, bool value); + void SetProperty(const std::string& property, std::nullptr_t); void AppendProperty(const std::string& property, const std::string& value, bool asString = false); @@ -127,7 +128,7 @@ public: std::string const& value) { if (auto* entry = this->GetCacheEntry(key)) { - entry->SetProperty(propName, value.c_str()); + entry->SetProperty(propName, value); } } diff --git a/Source/cmFindPackageCommand.cxx b/Source/cmFindPackageCommand.cxx index 98b085c..1c2a937 100644 --- a/Source/cmFindPackageCommand.cxx +++ b/Source/cmFindPackageCommand.cxx @@ -1804,11 +1804,11 @@ void cmFindPackageCommand::AppendToFoundProperty(const bool found) notFoundContents.push_back(this->Name); } - this->Makefile->GetState()->SetGlobalProperty( - "PACKAGES_FOUND", foundContents.to_string().c_str()); + this->Makefile->GetState()->SetGlobalProperty("PACKAGES_FOUND", + foundContents.to_string()); - this->Makefile->GetState()->SetGlobalProperty( - "PACKAGES_NOT_FOUND", notFoundContents.to_string().c_str()); + this->Makefile->GetState()->SetGlobalProperty("PACKAGES_NOT_FOUND", + notFoundContents.to_string()); } void cmFindPackageCommand::AppendSuccessInformation() @@ -1845,7 +1845,7 @@ void cmFindPackageCommand::AppendSuccessInformation() cmStrCat(this->VersionExact ? "==" : ">=", ' ', this->Version); } this->Makefile->GetState()->SetGlobalProperty(versionInfoPropName, - versionInfo.c_str()); + versionInfo); if (this->Required) { std::string const requiredInfoPropName = cmStrCat("_CMAKE_", this->Name, "_TYPE"); diff --git a/Source/cmGlobalGenerator.cxx b/Source/cmGlobalGenerator.cxx index 5d0f8b2..22d5aeb 100644 --- a/Source/cmGlobalGenerator.cxx +++ b/Source/cmGlobalGenerator.cxx @@ -268,7 +268,7 @@ void cmGlobalGenerator::ResolveLanguageCompiler(const std::string& lang, changeVars += ";"; changeVars += *cname; this->GetCMakeInstance()->GetState()->SetGlobalProperty( - "__CMAKE_DELETE_CACHE_CHANGE_VARS_", changeVars.c_str()); + "__CMAKE_DELETE_CACHE_CHANGE_VARS_", changeVars); } } } diff --git a/Source/cmMakefile.cxx b/Source/cmMakefile.cxx index 01afc44..585924d 100644 --- a/Source/cmMakefile.cxx +++ b/Source/cmMakefile.cxx @@ -4044,10 +4044,6 @@ int cmMakefile::ConfigureFile(const std::string& infile, return res; } -void cmMakefile::SetProperty(const std::string& prop, const char* value) -{ - this->StateSnapshot.GetDirectory().SetProperty(prop, value, this->Backtrace); -} void cmMakefile::SetProperty(const std::string& prop, cmValue value) { this->StateSnapshot.GetDirectory().SetProperty(prop, value, this->Backtrace); diff --git a/Source/cmMakefile.h b/Source/cmMakefile.h index d1f5be5..6fdadab 100644 --- a/Source/cmMakefile.h +++ b/Source/cmMakefile.h @@ -425,7 +425,7 @@ public: */ void SetIncludeRegularExpression(const std::string& regex) { - this->SetProperty("INCLUDE_REGULAR_EXPRESSION", regex.c_str()); + this->SetProperty("INCLUDE_REGULAR_EXPRESSION", regex); } const std::string& GetIncludeRegularExpression() const { @@ -801,8 +801,11 @@ public: std::string& debugBuffer) const; //! Set/Get a property of this directory - void SetProperty(const std::string& prop, const char* value); void SetProperty(const std::string& prop, cmValue value); + void SetProperty(const std::string& prop, std::nullptr_t) + { + this->SetProperty(prop, cmValue{ nullptr }); + } void SetProperty(const std::string& prop, const std::string& value) { this->SetProperty(prop, cmValue(value)); diff --git a/Source/cmPropertyMap.cxx b/Source/cmPropertyMap.cxx index b15000f..568a3d2 100644 --- a/Source/cmPropertyMap.cxx +++ b/Source/cmPropertyMap.cxx @@ -10,14 +10,9 @@ void cmPropertyMap::Clear() this->Map_.clear(); } -void cmPropertyMap::SetProperty(const std::string& name, const char* value) +void cmPropertyMap::SetProperty(const std::string& name, std::nullptr_t) { - if (!value) { - this->Map_.erase(name); - return; - } - - this->Map_[name] = value; + this->Map_.erase(name); } void cmPropertyMap::SetProperty(const std::string& name, cmValue value) { diff --git a/Source/cmPropertyMap.h b/Source/cmPropertyMap.h index f50b65e..23b50a5 100644 --- a/Source/cmPropertyMap.h +++ b/Source/cmPropertyMap.h @@ -4,6 +4,7 @@ #include "cmConfigure.h" // IWYU pragma: keep +#include <cstddef> #include <string> #include <unordered_map> #include <utility> @@ -25,7 +26,7 @@ public: // -- Properties //! Set the property value - void SetProperty(const std::string& name, const char* value); + void SetProperty(const std::string& name, std::nullptr_t); void SetProperty(const std::string& name, cmValue value); void SetProperty(const std::string& name, const std::string& value) { diff --git a/Source/cmSourceFile.cxx b/Source/cmSourceFile.cxx index 6224d0e..3403745 100644 --- a/Source/cmSourceFile.cxx +++ b/Source/cmSourceFile.cxx @@ -278,8 +278,7 @@ bool cmSourceFile::Matches(cmSourceFileLocation const& loc) return this->Location.Matches(loc); } -template <typename ValueType> -void cmSourceFile::StoreProperty(const std::string& prop, ValueType value) +void cmSourceFile::SetProperty(const std::string& prop, cmValue value) { if (prop == propINCLUDE_DIRECTORIES) { this->IncludeDirectories.clear(); @@ -304,15 +303,6 @@ void cmSourceFile::StoreProperty(const std::string& prop, ValueType value) } } -void cmSourceFile::SetProperty(const std::string& prop, const char* value) -{ - this->StoreProperty(prop, value); -} -void cmSourceFile::SetProperty(const std::string& prop, cmValue value) -{ - this->StoreProperty(prop, value); -} - void cmSourceFile::AppendProperty(const std::string& prop, const std::string& value, bool asString) { diff --git a/Source/cmSourceFile.h b/Source/cmSourceFile.h index 9308af4..3f070a7 100644 --- a/Source/cmSourceFile.h +++ b/Source/cmSourceFile.h @@ -4,6 +4,7 @@ #include "cmConfigure.h" // IWYU pragma: keep +#include <cstddef> #include <memory> #include <string> #include <vector> @@ -41,8 +42,11 @@ public: void SetCustomCommand(std::unique_ptr<cmCustomCommand> cc); //! Set/Get a property of this source file - void SetProperty(const std::string& prop, const char* value); void SetProperty(const std::string& prop, cmValue value); + void SetProperty(const std::string& prop, std::nullptr_t) + { + this->SetProperty(prop, cmValue{ nullptr }); + } void SetProperty(const std::string& prop, const std::string& value) { this->SetProperty(prop, cmValue(value)); diff --git a/Source/cmState.cxx b/Source/cmState.cxx index bbafc92..a72f830 100644 --- a/Source/cmState.cxx +++ b/Source/cmState.cxx @@ -564,7 +564,8 @@ void cmState::RemoveUserDefinedCommands() this->ScriptedCommands.clear(); } -void cmState::SetGlobalProperty(const std::string& prop, const char* value) +void cmState::SetGlobalProperty(const std::string& prop, + const std::string& value) { this->GlobalProperties.SetProperty(prop, value); } @@ -583,10 +584,10 @@ cmValue cmState::GetGlobalProperty(const std::string& prop) { if (prop == "CACHE_VARIABLES") { std::vector<std::string> cacheKeys = this->GetCacheEntryKeys(); - this->SetGlobalProperty("CACHE_VARIABLES", cmJoin(cacheKeys, ";").c_str()); + this->SetGlobalProperty("CACHE_VARIABLES", cmJoin(cacheKeys, ";")); } else if (prop == "COMMANDS") { std::vector<std::string> commands = this->GetCommandNames(); - this->SetGlobalProperty("COMMANDS", cmJoin(commands, ";").c_str()); + this->SetGlobalProperty("COMMANDS", cmJoin(commands, ";")); } else if (prop == "IN_TRY_COMPILE") { this->SetGlobalProperty( "IN_TRY_COMPILE", @@ -597,10 +598,10 @@ cmValue cmState::GetGlobalProperty(const std::string& prop) } else if (prop == "ENABLED_LANGUAGES") { std::string langs; langs = cmJoin(this->EnabledLanguages, ";"); - this->SetGlobalProperty("ENABLED_LANGUAGES", langs.c_str()); + this->SetGlobalProperty("ENABLED_LANGUAGES", langs); } else if (prop == "CMAKE_ROLE") { std::string mode = this->GetModeString(); - this->SetGlobalProperty("CMAKE_ROLE", mode.c_str()); + this->SetGlobalProperty("CMAKE_ROLE", mode); } #define STRING_LIST_ELEMENT(F) ";" #F if (prop == "CMAKE_C_KNOWN_FEATURES") { diff --git a/Source/cmState.h b/Source/cmState.h index 0a42df0..d9d2c21 100644 --- a/Source/cmState.h +++ b/Source/cmState.h @@ -194,7 +194,7 @@ public: void RemoveUserDefinedCommands(); std::vector<std::string> GetCommandNames() const; - void SetGlobalProperty(const std::string& prop, const char* value); + void SetGlobalProperty(const std::string& prop, const std::string& value); void SetGlobalProperty(const std::string& prop, cmValue value); void AppendGlobalProperty(const std::string& prop, const std::string& value, bool asString = false); diff --git a/Source/cmStateDirectory.cxx b/Source/cmStateDirectory.cxx index 20e4604..6e6fcbd 100644 --- a/Source/cmStateDirectory.cxx +++ b/Source/cmStateDirectory.cxx @@ -271,9 +271,8 @@ void cmStateDirectory::ClearLinkDirectories() this->Snapshot_.Position->LinkDirectoriesPosition); } -template <typename ValueType> -void cmStateDirectory::StoreProperty(const std::string& prop, ValueType value, - cmListFileBacktrace const& lfbt) +void cmStateDirectory::SetProperty(const std::string& prop, cmValue value, + cmListFileBacktrace const& lfbt) { if (prop == "INCLUDE_DIRECTORIES") { if (!value) { @@ -319,17 +318,6 @@ void cmStateDirectory::StoreProperty(const std::string& prop, ValueType value, this->DirectoryState->Properties.SetProperty(prop, value); } -void cmStateDirectory::SetProperty(const std::string& prop, const char* value, - cmListFileBacktrace const& lfbt) -{ - this->StoreProperty(prop, value, lfbt); -} -void cmStateDirectory::SetProperty(const std::string& prop, cmValue value, - cmListFileBacktrace const& lfbt) -{ - this->StoreProperty(prop, value, lfbt); -} - void cmStateDirectory::AppendProperty(const std::string& prop, const std::string& value, bool asString, cmListFileBacktrace const& lfbt) diff --git a/Source/cmStateDirectory.h b/Source/cmStateDirectory.h index 8c6b09d..55cc716 100644 --- a/Source/cmStateDirectory.h +++ b/Source/cmStateDirectory.h @@ -5,6 +5,7 @@ #include "cmConfigure.h" // IWYU pragma: keep +#include <cstddef> #include <string> #include <vector> @@ -57,10 +58,13 @@ public: void SetLinkDirectories(BT<std::string> const& vecs); void ClearLinkDirectories(); - void SetProperty(const std::string& prop, const char* value, - cmListFileBacktrace const& lfbt); void SetProperty(const std::string& prop, cmValue value, cmListFileBacktrace const& lfbt); + void SetProperty(const std::string& prop, std::nullptr_t, + cmListFileBacktrace const& lfbt) + { + this->SetProperty(prop, cmValue{ nullptr }, lfbt); + } void AppendProperty(const std::string& prop, const std::string& value, bool asString, cmListFileBacktrace const& lfbt); cmValue GetProperty(const std::string& prop) const; diff --git a/Source/cmTarget.cxx b/Source/cmTarget.cxx index 0fbe430..b55554d 100644 --- a/Source/cmTarget.cxx +++ b/Source/cmTarget.cxx @@ -1810,26 +1810,7 @@ MAKE_PROP(INTERFACE_LINK_LIBRARIES_DIRECT_EXCLUDE); #undef MAKE_PROP } -namespace { -// to workaround bug on GCC/AIX -// Define a template to force conversion to std::string -template <typename ValueType> -std::string ConvertToString(ValueType value); - -template <> -std::string ConvertToString<const char*>(const char* value) -{ - return std::string(value); -} -template <> -std::string ConvertToString<cmValue>(cmValue value) -{ - return std::string(*value); -} -} - -template <typename ValueType> -void cmTarget::StoreProperty(const std::string& prop, ValueType value) +void cmTarget::SetProperty(const std::string& prop, cmValue value) { if (prop == propMANUALLY_ADDED_DEPENDENCIES) { this->impl->Makefile->IssueMessage( @@ -1975,7 +1956,7 @@ void cmTarget::StoreProperty(const std::string& prop, ValueType value) std::string reusedFrom = reusedTarget->GetSafeProperty(prop); if (reusedFrom.empty()) { - reusedFrom = ConvertToString(value); + reusedFrom = *value; } this->impl->Properties.SetProperty(prop, reusedFrom); @@ -2091,15 +2072,6 @@ void cmTarget::AppendProperty(const std::string& prop, } } -void cmTarget::SetProperty(const std::string& prop, const char* value) -{ - this->StoreProperty(prop, value); -} -void cmTarget::SetProperty(const std::string& prop, cmValue value) -{ - this->StoreProperty(prop, value); -} - template <typename ValueType> void cmTargetInternals::AddDirectoryToFileSet(cmTarget* self, std::string const& fileSetName, diff --git a/Source/cmTarget.h b/Source/cmTarget.h index 24f6fcd..5fe5a28 100644 --- a/Source/cmTarget.h +++ b/Source/cmTarget.h @@ -180,8 +180,11 @@ public: std::set<BT<std::pair<std::string, bool>>> const& GetUtilities() const; //! Set/Get a property of this target file - void SetProperty(const std::string& prop, const char* value); void SetProperty(const std::string& prop, cmValue value); + void SetProperty(const std::string& prop, std::nullptr_t) + { + this->SetProperty(prop, cmValue{ nullptr }); + } void SetProperty(const std::string& prop, const std::string& value) { this->SetProperty(prop, cmValue(value)); diff --git a/Source/cmTest.cxx b/Source/cmTest.cxx index e6ed01b..b0d9c2d 100644 --- a/Source/cmTest.cxx +++ b/Source/cmTest.cxx @@ -52,10 +52,6 @@ bool cmTest::GetPropertyAsBool(const std::string& prop) const return cmIsOn(this->GetProperty(prop)); } -void cmTest::SetProperty(const std::string& prop, const char* value) -{ - this->Properties.SetProperty(prop, value); -} void cmTest::SetProperty(const std::string& prop, cmValue value) { this->Properties.SetProperty(prop, value); diff --git a/Source/cmTest.h b/Source/cmTest.h index 1c14310..8b50b87 100644 --- a/Source/cmTest.h +++ b/Source/cmTest.h @@ -4,6 +4,7 @@ #include "cmConfigure.h" // IWYU pragma: keep +#include <cstddef> #include <string> #include <vector> @@ -34,8 +35,11 @@ public: std::vector<std::string> const& GetCommand() const { return this->Command; } //! Set/Get a property of this source file - void SetProperty(const std::string& prop, const char* value); void SetProperty(const std::string& prop, cmValue value); + void SetProperty(const std::string& prop, std::nullptr_t) + { + this->SetProperty(prop, cmValue{ nullptr }); + } void SetProperty(const std::string& prop, const std::string& value) { this->SetProperty(prop, cmValue(value)); diff --git a/Source/cmake.cxx b/Source/cmake.cxx index 284c5e7..c5b467d 100644 --- a/Source/cmake.cxx +++ b/Source/cmake.cxx @@ -3261,10 +3261,6 @@ void cmake::GenerateGraphViz(const std::string& fileName) const #endif } -void cmake::SetProperty(const std::string& prop, const char* value) -{ - this->State->SetGlobalProperty(prop, value); -} void cmake::SetProperty(const std::string& prop, cmValue value) { this->State->SetGlobalProperty(prop, value); diff --git a/Source/cmake.h b/Source/cmake.h index 0f8f642..955ec4f 100644 --- a/Source/cmake.h +++ b/Source/cmake.h @@ -404,8 +404,11 @@ public: std::vector<cmDocumentationEntry> GetGeneratorsDocumentation(); //! Set/Get a property of this target file - void SetProperty(const std::string& prop, const char* value); void SetProperty(const std::string& prop, cmValue value); + void SetProperty(const std::string& prop, std::nullptr_t) + { + this->SetProperty(prop, cmValue{ nullptr }); + } void SetProperty(const std::string& prop, const std::string& value) { this->SetProperty(prop, cmValue(value)); diff --git a/Source/kwsys/SystemInformation.cxx b/Source/kwsys/SystemInformation.cxx index 20e2edb..7f8485e 100644 --- a/Source/kwsys/SystemInformation.cxx +++ b/Source/kwsys/SystemInformation.cxx @@ -3453,6 +3453,10 @@ bool SystemInformationImplementation::RetrieveInformationFromCpuInfoFile() fileSize++; } fclose(fd); + if (fileSize < 2) { + std::cout << "No data in /proc/cpuinfo" << std::endl; + return false; + } buffer.resize(fileSize - 2); // Number of logical CPUs (combination of multiple processors, multi-core // and SMT) diff --git a/Tests/RunCMake/ParseImplicitLinkInfo/ExcludeDirs.cmake b/Tests/RunCMake/ParseImplicitLinkInfo/ExcludeDirs.cmake new file mode 100644 index 0000000..6cece68 --- /dev/null +++ b/Tests/RunCMake/ParseImplicitLinkInfo/ExcludeDirs.cmake @@ -0,0 +1,10 @@ +include("${info}") +list(GET INFO_CMAKE_C_IMPLICIT_LINK_DIRECTORIES -1 last_dir) +set(ENV{CMAKE_C_IMPLICIT_LINK_DIRECTORIES_EXCLUDE} "${last_dir}") +enable_language(C) +message(STATUS "INFO_CMAKE_C_IMPLICIT_LINK_DIRECTORIES=[${INFO_CMAKE_C_IMPLICIT_LINK_DIRECTORIES}]") +message(STATUS "ENV{CMAKE_C_IMPLICIT_LINK_DIRECTORIES_EXCLUDE}=[$ENV{CMAKE_C_IMPLICIT_LINK_DIRECTORIES_EXCLUDE}]") +message(STATUS "CMAKE_C_IMPLICIT_LINK_DIRECTORIES=[${CMAKE_C_IMPLICIT_LINK_DIRECTORIES}]") +if("${last_dir}" IN_LIST CMAKE_C_IMPLICIT_LINK_DIRECTORIES) + message(FATAL_ERROR "${last_dir} was not excluded!") +endif() diff --git a/Tests/RunCMake/ParseImplicitLinkInfo/Inspect.cmake b/Tests/RunCMake/ParseImplicitLinkInfo/Inspect.cmake new file mode 100644 index 0000000..42e1c67 --- /dev/null +++ b/Tests/RunCMake/ParseImplicitLinkInfo/Inspect.cmake @@ -0,0 +1,12 @@ +enable_language(C) + +set(info "") +foreach(var + CMAKE_C_IMPLICIT_LINK_DIRECTORIES + ) + if(DEFINED ${var}) + string(APPEND info "set(INFO_${var} \"${${var}}\")\n") + endif() +endforeach() + +file(WRITE "${CMAKE_CURRENT_BINARY_DIR}/info.cmake" "${info}") diff --git a/Tests/RunCMake/ParseImplicitLinkInfo/RunCMakeTest.cmake b/Tests/RunCMake/ParseImplicitLinkInfo/RunCMakeTest.cmake index 713e2e7..c7655d2 100644 --- a/Tests/RunCMake/ParseImplicitLinkInfo/RunCMakeTest.cmake +++ b/Tests/RunCMake/ParseImplicitLinkInfo/RunCMakeTest.cmake @@ -1,3 +1,11 @@ include(RunCMake) run_cmake(ParseImplicitLinkInfo) + +run_cmake(Inspect) +set(info "${RunCMake_BINARY_DIR}/Inspect-build/info.cmake") +include("${info}") + +if(INFO_CMAKE_C_IMPLICIT_LINK_DIRECTORIES MATCHES ";") + run_cmake_with_options(ExcludeDirs "-Dinfo=${RunCMake_BINARY_DIR}/Inspect-build/info.cmake") +endif() |