diff options
28 files changed, 202 insertions, 132 deletions
diff --git a/Help/release/dev/allow-aliasing-unkown-import-targets.rst b/Help/release/dev/allow-aliasing-unkown-import-targets.rst new file mode 100644 index 0000000..aa5da0c --- /dev/null +++ b/Help/release/dev/allow-aliasing-unkown-import-targets.rst @@ -0,0 +1,5 @@ +allow-aliasing-unkown-import-targets +------------------------------------ + +* :command:`add_library` command ``ALIAS`` option learned to support + import libraries of the ``UNKNOWN`` type. diff --git a/Modules/Compiler/AppleClang-C.cmake b/Modules/Compiler/AppleClang-C.cmake index a48adec..2794f52 100644 --- a/Modules/Compiler/AppleClang-C.cmake +++ b/Modules/Compiler/AppleClang-C.cmake @@ -4,12 +4,15 @@ __compiler_clang(C) if(NOT CMAKE_C_COMPILER_VERSION VERSION_LESS 4.0) set(CMAKE_C90_STANDARD_COMPILE_OPTION "-std=c90") set(CMAKE_C90_EXTENSION_COMPILE_OPTION "-std=gnu90") + set(CMAKE_C90_STANDARD__HAS_FULL_SUPPORT ON) set(CMAKE_C99_STANDARD_COMPILE_OPTION "-std=c99") set(CMAKE_C99_EXTENSION_COMPILE_OPTION "-std=gnu99") + set(CMAKE_C99_STANDARD__HAS_FULL_SUPPORT ON) set(CMAKE_C11_STANDARD_COMPILE_OPTION "-std=c11") set(CMAKE_C11_EXTENSION_COMPILE_OPTION "-std=gnu11") + set(CMAKE_C11_STANDARD__HAS_FULL_SUPPORT ON) endif() __compiler_check_default_language_standard(C 4.0 99) diff --git a/Modules/Compiler/CMakeCommonCompilerMacros.cmake b/Modules/Compiler/CMakeCommonCompilerMacros.cmake index ad464c7..9c62e10 100644 --- a/Modules/Compiler/CMakeCommonCompilerMacros.cmake +++ b/Modules/Compiler/CMakeCommonCompilerMacros.cmake @@ -65,13 +65,28 @@ endmacro() macro(cmake_record_c_compile_features) set(_result 0) if(_result EQUAL 0 AND DEFINED CMAKE_C11_STANDARD_COMPILE_OPTION) - _record_compiler_features_c(11) + if(CMAKE_C11_STANDARD__HAS_FULL_SUPPORT) + _has_compiler_features_c(11) + else() + _record_compiler_features_c(11) + endif() + unset(CMAKE_C11_STANDARD__HAS_FULL_SUPPORT) endif() if(_result EQUAL 0 AND DEFINED CMAKE_C99_STANDARD_COMPILE_OPTION) - _record_compiler_features_c(99) + if(CMAKE_C99_STANDARD__HAS_FULL_SUPPORT) + _has_compiler_features_c(99) + else() + _record_compiler_features_c(99) + endif() + unset(CMAKE_C99_STANDARD__HAS_FULL_SUPPORT) endif() if(_result EQUAL 0 AND DEFINED CMAKE_C90_STANDARD_COMPILE_OPTION) - _record_compiler_features_c(90) + if(CMAKE_C90_STANDARD__HAS_FULL_SUPPORT) + _has_compiler_features_c(90) + else() + _record_compiler_features_c(90) + endif() + unset(CMAKE_C90_STANDARD__HAS_FULL_SUPPORT) endif() endmacro() diff --git a/Modules/Compiler/Clang-C.cmake b/Modules/Compiler/Clang-C.cmake index a07ae40..ff51d30 100644 --- a/Modules/Compiler/Clang-C.cmake +++ b/Modules/Compiler/Clang-C.cmake @@ -10,12 +10,15 @@ if(NOT CMAKE_C_COMPILER_VERSION VERSION_LESS 3.4) if(NOT "x${CMAKE_C_SIMULATE_ID}" STREQUAL "xMSVC") set(CMAKE_C90_STANDARD_COMPILE_OPTION "-std=c90") set(CMAKE_C90_EXTENSION_COMPILE_OPTION "-std=gnu90") + set(CMAKE_C90_STANDARD__HAS_FULL_SUPPORT ON) set(CMAKE_C99_STANDARD_COMPILE_OPTION "-std=c99") set(CMAKE_C99_EXTENSION_COMPILE_OPTION "-std=gnu99") + set(CMAKE_C99_STANDARD__HAS_FULL_SUPPORT ON) set(CMAKE_C11_STANDARD_COMPILE_OPTION "-std=c11") set(CMAKE_C11_EXTENSION_COMPILE_OPTION "-std=gnu11") + set(CMAKE_C11_STANDARD__HAS_FULL_SUPPORT ON) else() # clang-cl doesn't have any of these set(CMAKE_C90_STANDARD_COMPILE_OPTION "") diff --git a/Modules/Compiler/Cray-C.cmake b/Modules/Compiler/Cray-C.cmake index d34154c..9340948 100644 --- a/Modules/Compiler/Cray-C.cmake +++ b/Modules/Compiler/Cray-C.cmake @@ -10,11 +10,14 @@ string(APPEND CMAKE_C_FLAGS_RELEASE_INIT " -DNDEBUG") if (CMAKE_C_COMPILER_VERSION VERSION_GREATER_EQUAL 8.1) set(CMAKE_C90_STANDARD_COMPILE_OPTION -h noc99,conform) set(CMAKE_C90_EXTENSION_COMPILE_OPTION -h noc99,gnu) + set(CMAKE_C90_STANDARD__HAS_FULL_SUPPORT ON) set(CMAKE_C99_STANDARD_COMPILE_OPTION -h c99,conform) set(CMAKE_C99_EXTENSION_COMPILE_OPTION -h c99,gnu) + set(CMAKE_C99_STANDARD__HAS_FULL_SUPPORT ON) if (CMAKE_C_COMPILER_VERSION VERSION_GREATER_EQUAL 8.5) set(CMAKE_C11_STANDARD_COMPILE_OPTION -h std=c11,conform) set(CMAKE_C11_EXTENSION_COMPILE_OPTION -h std=c11,gnu) + set(CMAKE_C11_STANDARD__HAS_FULL_SUPPORT ON) endif () endif () diff --git a/Modules/Compiler/GNU-C.cmake b/Modules/Compiler/GNU-C.cmake index f072c54..ca286b3 100644 --- a/Modules/Compiler/GNU-C.cmake +++ b/Modules/Compiler/GNU-C.cmake @@ -10,13 +10,16 @@ elseif (NOT CMAKE_C_COMPILER_VERSION VERSION_LESS 3.4) endif() if (NOT CMAKE_C_COMPILER_VERSION VERSION_LESS 3.4) + set(CMAKE_C90_STANDARD__HAS_FULL_SUPPORT ON) set(CMAKE_C99_STANDARD_COMPILE_OPTION "-std=c99") set(CMAKE_C99_EXTENSION_COMPILE_OPTION "-std=gnu99") + set(CMAKE_C99_STANDARD__HAS_FULL_SUPPORT ON) endif() if (NOT CMAKE_C_COMPILER_VERSION VERSION_LESS 4.7) set(CMAKE_C11_STANDARD_COMPILE_OPTION "-std=c11") set(CMAKE_C11_EXTENSION_COMPILE_OPTION "-std=gnu11") + set(CMAKE_C11_STANDARD__HAS_FULL_SUPPORT ON) elseif (NOT CMAKE_C_COMPILER_VERSION VERSION_LESS 4.6) set(CMAKE_C11_STANDARD_COMPILE_OPTION "-std=c1x") set(CMAKE_C11_EXTENSION_COMPILE_OPTION "-std=gnu1x") diff --git a/Modules/Compiler/Intel-C.cmake b/Modules/Compiler/Intel-C.cmake index 4e4af29..e9e59a2 100644 --- a/Modules/Compiler/Intel-C.cmake +++ b/Modules/Compiler/Intel-C.cmake @@ -12,13 +12,16 @@ if("x${CMAKE_C_SIMULATE_ID}" STREQUAL "xMSVC") if (NOT CMAKE_C_COMPILER_VERSION VERSION_LESS 16.0.0) set(CMAKE_C11_STANDARD_COMPILE_OPTION "-Qstd=c11") set(CMAKE_C11_EXTENSION_COMPILE_OPTION "-Qstd=c11") + set(CMAKE_C11_STANDARD__HAS_FULL_SUPPORT ON) endif() if (NOT CMAKE_C_COMPILER_VERSION VERSION_LESS 12.0) set(CMAKE_C90_STANDARD_COMPILE_OPTION "-Qstd=c89") set(CMAKE_C90_EXTENSION_COMPILE_OPTION "-Qstd=c89") + set(CMAKE_C90_STANDARD__HAS_FULL_SUPPORT ON) set(CMAKE_C99_STANDARD_COMPILE_OPTION "-Qstd=c99") set(CMAKE_C99_EXTENSION_COMPILE_OPTION "-Qstd=c99") + set(CMAKE_C99_STANDARD__HAS_FULL_SUPPORT ON) endif() else() @@ -26,13 +29,16 @@ else() if (NOT CMAKE_C_COMPILER_VERSION VERSION_LESS 15.0.0) set(CMAKE_C11_STANDARD_COMPILE_OPTION "-std=c11") set(CMAKE_C11_EXTENSION_COMPILE_OPTION "-std=gnu11") + set(CMAKE_C11_STANDARD__HAS_FULL_SUPPORT ON) endif() if (NOT CMAKE_C_COMPILER_VERSION VERSION_LESS 12.0) set(CMAKE_C90_STANDARD_COMPILE_OPTION "-std=c89") set(CMAKE_C90_EXTENSION_COMPILE_OPTION "-std=gnu89") + set(CMAKE_C90_STANDARD__HAS_FULL_SUPPORT ON) set(CMAKE_C99_STANDARD_COMPILE_OPTION "-std=c99") set(CMAKE_C99_EXTENSION_COMPILE_OPTION "-std=gnu99") + set(CMAKE_C99_STANDARD__HAS_FULL_SUPPORT ON) endif() endif() diff --git a/Modules/Compiler/PGI-C.cmake b/Modules/Compiler/PGI-C.cmake index 3b3848a..c39dbe5 100644 --- a/Modules/Compiler/PGI-C.cmake +++ b/Modules/Compiler/PGI-C.cmake @@ -6,11 +6,14 @@ string(APPEND CMAKE_C_FLAGS_RELEASE_INIT " -DNDEBUG") if (CMAKE_C_COMPILER_VERSION VERSION_GREATER_EQUAL 12.10) set(CMAKE_C90_STANDARD_COMPILE_OPTION -c89) set(CMAKE_C90_EXTENSION_COMPILE_OPTION -c89) + set(CMAKE_C90_STANDARD__HAS_FULL_SUPPORT ON) set(CMAKE_C99_STANDARD_COMPILE_OPTION -c99) set(CMAKE_C99_EXTENSION_COMPILE_OPTION -c99) + set(CMAKE_C99_STANDARD__HAS_FULL_SUPPORT ON) if (CMAKE_C_COMPILER_VERSION VERSION_GREATER_EQUAL 15.3) set(CMAKE_C11_STANDARD_COMPILE_OPTION -c11) set(CMAKE_C11_EXTENSION_COMPILE_OPTION -c11) + set(CMAKE_C11_STANDARD__HAS_FULL_SUPPORT ON) endif () endif () diff --git a/Modules/Compiler/SunPro-C.cmake b/Modules/Compiler/SunPro-C.cmake index c4aba8e..7e962b8 100644 --- a/Modules/Compiler/SunPro-C.cmake +++ b/Modules/Compiler/SunPro-C.cmake @@ -39,10 +39,13 @@ set(CMAKE_C_LINKER_WRAPPER_FLAG_SEP ",") if (CMAKE_C_COMPILER_VERSION VERSION_GREATER_EQUAL 5.13) set(CMAKE_C90_STANDARD_COMPILE_OPTION "-std=c89") set(CMAKE_C90_EXTENSION_COMPILE_OPTION "-std=c89") + set(CMAKE_C90_STANDARD__HAS_FULL_SUPPORT ON) set(CMAKE_C99_STANDARD_COMPILE_OPTION "-std=c99") set(CMAKE_C99_EXTENSION_COMPILE_OPTION "-std=c99") + set(CMAKE_C99_STANDARD__HAS_FULL_SUPPORT ON) set(CMAKE_C11_STANDARD_COMPILE_OPTION "-std=c11") set(CMAKE_C11_EXTENSION_COMPILE_OPTION "-std=c11") + set(CMAKE_C11_STANDARD__HAS_FULL_SUPPORT ON) elseif (CMAKE_C_COMPILER_VERSION VERSION_GREATER_EQUAL 5.11) set(CMAKE_C90_STANDARD_COMPILE_OPTION "") set(CMAKE_C90_EXTENSION_COMPILE_OPTION "") diff --git a/Modules/Compiler/XL-C.cmake b/Modules/Compiler/XL-C.cmake index 6fc9728..2077bda 100644 --- a/Modules/Compiler/XL-C.cmake +++ b/Modules/Compiler/XL-C.cmake @@ -9,11 +9,14 @@ string(APPEND CMAKE_C_FLAGS_INIT " -qthreaded") if (CMAKE_C_COMPILER_VERSION VERSION_GREATER_EQUAL 10.1) set(CMAKE_C90_STANDARD_COMPILE_OPTION "-qlanglvl=stdc89") set(CMAKE_C90_EXTENSION_COMPILE_OPTION "-qlanglvl=extc89") + set(CMAKE_C90_STANDARD__HAS_FULL_SUPPORT ON) set(CMAKE_C99_STANDARD_COMPILE_OPTION "-qlanglvl=stdc99") set(CMAKE_C99_EXTENSION_COMPILE_OPTION "-qlanglvl=extc99") + set(CMAKE_C99_STANDARD__HAS_FULL_SUPPORT ON) if (CMAKE_C_COMPILER_VERSION VERSION_GREATER_EQUAL 12.1) set(CMAKE_C11_STANDARD_COMPILE_OPTION "-qlanglvl=extc1x") set(CMAKE_C11_EXTENSION_COMPILE_OPTION "-qlanglvl=extc1x") + set(CMAKE_C11_STANDARD__HAS_FULL_SUPPORT ON) endif () endif() diff --git a/Modules/Compiler/XLClang-C.cmake b/Modules/Compiler/XLClang-C.cmake index 8e8fcf2..54c18a6 100644 --- a/Modules/Compiler/XLClang-C.cmake +++ b/Modules/Compiler/XLClang-C.cmake @@ -4,13 +4,16 @@ __compiler_xlclang(C) if (CMAKE_C_COMPILER_VERSION VERSION_GREATER_EQUAL 13.1.1) set(CMAKE_C90_STANDARD_COMPILE_OPTION "-std=c89") set(CMAKE_C90_EXTENSION_COMPILE_OPTION "-std=gnu89") + set(CMAKE_C90_STANDARD__HAS_FULL_SUPPORT ON) set(CMAKE_C99_STANDARD_COMPILE_OPTION "-std=c99") set(CMAKE_C99_EXTENSION_COMPILE_OPTION "-std=gnu99") + set(CMAKE_C99_STANDARD__HAS_FULL_SUPPORT ON) set(CMAKE_C11_STANDARD_COMPILE_OPTION "-qlanglvl=extc1x") set(CMAKE_C11_EXTENSION_COMPILE_OPTION "-qlanglvl=extc1x") if (CMAKE_C_COMPILER_VERSION VERSION_GREATER_EQUAL 13.1.2) set(CMAKE_C11_STANDARD_COMPILE_OPTION "-std=c11") set(CMAKE_C11_EXTENSION_COMPILE_OPTION "-std=gnu11") + set(CMAKE_C11_STANDARD__HAS_FULL_SUPPORT ON) endif () endif() diff --git a/Modules/Internal/FeatureTesting.cmake b/Modules/Internal/FeatureTesting.cmake index b9c20ec..f7b3e96 100644 --- a/Modules/Internal/FeatureTesting.cmake +++ b/Modules/Internal/FeatureTesting.cmake @@ -88,3 +88,14 @@ macro(_record_compiler_features_cxx std) endif() unset(lang_level_has_features) endmacro() + +macro(_has_compiler_features lang level compile_flags feature_list) + # presume all known features are supported + get_property(known_features GLOBAL PROPERTY CMAKE_${lang}${level}_KNOWN_FEATURES) + list(APPEND ${feature_list} ${known_features}) +endmacro() + +macro(_has_compiler_features_c std) + list(APPEND CMAKE_C${std}_COMPILE_FEATURES c_std_${std}) + _has_compiler_features(C ${std} "${CMAKE_C${std}_STANDARD_COMPILE_OPTION}" CMAKE_C${std}_COMPILE_FEATURES) +endmacro() diff --git a/Source/CMakeVersion.cmake b/Source/CMakeVersion.cmake index 0d0ef6a..7906a0b 100644 --- a/Source/CMakeVersion.cmake +++ b/Source/CMakeVersion.cmake @@ -1,5 +1,5 @@ # CMake version number components. set(CMake_VERSION_MAJOR 3) set(CMake_VERSION_MINOR 14) -set(CMake_VERSION_PATCH 20190331) +set(CMake_VERSION_PATCH 20190401) #set(CMake_VERSION_RC 1) diff --git a/Source/cmAddLibraryCommand.cxx b/Source/cmAddLibraryCommand.cxx index 5149333..adf4464 100644 --- a/Source/cmAddLibraryCommand.cxx +++ b/Source/cmAddLibraryCommand.cxx @@ -222,7 +222,9 @@ bool cmAddLibraryCommand::InitialPass(std::vector<std::string> const& args, aliasedType != cmStateEnums::STATIC_LIBRARY && aliasedType != cmStateEnums::MODULE_LIBRARY && aliasedType != cmStateEnums::OBJECT_LIBRARY && - aliasedType != cmStateEnums::INTERFACE_LIBRARY) { + aliasedType != cmStateEnums::INTERFACE_LIBRARY && + !(aliasedType == cmStateEnums::UNKNOWN_LIBRARY && + aliasedTarget->IsImported())) { std::ostringstream e; e << "cannot create ALIAS target \"" << libName << "\" because target \"" << aliasedName << "\" is not a library."; diff --git a/Source/cmDepends.cxx b/Source/cmDepends.cxx index efadaf1..ed76dbf 100644 --- a/Source/cmDepends.cxx +++ b/Source/cmDepends.cxx @@ -2,6 +2,7 @@ file Copyright.txt or https://cmake.org/licensing for details. */ #include "cmDepends.h" +#include "cmFileTime.h" #include "cmFileTimeCache.h" #include "cmGeneratedFileStream.h" #include "cmLocalGenerator.h" @@ -10,22 +11,15 @@ #include "cmsys/FStream.hxx" #include <sstream> -#include <string.h> #include <utility> cmDepends::cmDepends(cmLocalGenerator* lg, std::string targetDir) : LocalGenerator(lg) , TargetDirectory(std::move(targetDir)) - , Dependee(new char[MaxPath]) - , Depender(new char[MaxPath]) { } -cmDepends::~cmDepends() -{ - delete[] this->Dependee; - delete[] this->Depender; -} +cmDepends::~cmDepends() = default; bool cmDepends::Write(std::ostream& makeDepends, std::ostream& internalDepends) { @@ -67,7 +61,7 @@ bool cmDepends::Finalize(std::ostream& /*unused*/, std::ostream& /*unused*/) bool cmDepends::Check(const std::string& makeFile, const std::string& internalFile, - std::map<std::string, DependencyVector>& validDeps) + DependencyMap& validDeps) { // Check whether dependencies must be regenerated. bool okay = true; @@ -76,9 +70,9 @@ bool cmDepends::Check(const std::string& makeFile, // Clear all dependencies so they will be regenerated. this->Clear(makeFile); cmSystemTools::RemoveFile(internalFile); + this->FileTimeCache->Remove(internalFile); okay = false; } - return okay; } @@ -107,48 +101,62 @@ bool cmDepends::WriteDependencies(const std::set<std::string>& /*unused*/, return false; } -bool cmDepends::CheckDependencies( - std::istream& internalDepends, const std::string& internalDependsFileName, - std::map<std::string, DependencyVector>& validDeps) +bool cmDepends::CheckDependencies(std::istream& internalDepends, + const std::string& internalDependsFileName, + DependencyMap& validDeps) { + // Read internal depends file time + cmFileTime internalDependsTime; + if (!this->FileTimeCache->Load(internalDependsFileName, + internalDependsTime)) { + return false; + } + // Parse dependencies from the stream. If any dependee is missing // or newer than the depender then dependencies should be // regenerated. bool okay = true; bool dependerExists = false; - DependencyVector* currentDependencies = nullptr; - while (internalDepends.getline(this->Dependee, this->MaxPath)) { - if (this->Dependee[0] == 0 || this->Dependee[0] == '#' || - this->Dependee[0] == '\r') { + std::string line; + line.reserve(1024); + std::string depender; + std::string dependee; + cmFileTime dependerTime; + cmFileTime dependeeTime; + std::vector<std::string>* currentDependencies = nullptr; + + while (std::getline(internalDepends, line)) { + // Check if this an empty or a comment line + if (line.empty() || line.front() == '#') { continue; } - size_t len = internalDepends.gcount() - 1; - if (this->Dependee[len - 1] == '\r') { - len--; - this->Dependee[len] = 0; + // Drop carriage return character at the end + if (line.back() == '\r') { + line.pop_back(); + if (line.empty()) { + continue; + } } - if (this->Dependee[0] != ' ') { - memcpy(this->Depender, this->Dependee, len + 1); - // Calling FileExists() for the depender here saves in many cases 50% - // of the calls to FileExists() further down in the loop. E.g. for - // kdelibs/khtml this reduces the number of calls from 184k down to 92k, - // or the time for cmake -E cmake_depends from 0.3 s down to 0.21 s. - dependerExists = cmSystemTools::FileExists(this->Depender); + // Check if this a depender line + if (line.front() != ' ') { + depender = line; + dependerExists = this->FileTimeCache->Load(depender, dependerTime); // If we erase validDeps[this->Depender] by overwriting it with an empty // vector, we lose dependencies for dependers that have multiple // entries. No need to initialize the entry, std::map will do so on first // access. - currentDependencies = &validDeps[this->Depender]; + currentDependencies = &validDeps[depender]; continue; } - /* - // Parse the dependency line. - if(!this->ParseDependency(line.c_str())) - { - continue; - } - */ + + // This is a dependee line + dependee = line.substr(1); + + // Add dependee to depender's list + if (currentDependencies != nullptr) { + currentDependencies->push_back(dependee); + } // Dependencies must be regenerated // * if the dependee does not exist @@ -156,13 +164,8 @@ bool cmDepends::CheckDependencies( // * if the depender does not exist, but the dependee is newer than the // depends file bool regenerate = false; - const std::string dependee(this->Dependee + 1); - const std::string depender(this->Depender); - if (currentDependencies != nullptr) { - currentDependencies->push_back(dependee); - } - - if (!cmSystemTools::FileExists(dependee)) { + bool dependeeExists = this->FileTimeCache->Load(dependee, dependeeTime); + if (!dependeeExists) { // The dependee does not exist. regenerate = true; @@ -173,44 +176,38 @@ bool cmDepends::CheckDependencies( << depender << "\"." << std::endl; cmSystemTools::Stdout(msg.str()); } - } else { - if (dependerExists) { - // The dependee and depender both exist. Compare file times. - int result = 0; - if ((!this->FileTimeCache->Compare(depender, dependee, &result) || - result < 0)) { - // The depender is older than the dependee. - regenerate = true; - - // Print verbose output. - if (this->Verbose) { - std::ostringstream msg; - msg << "Dependee \"" << dependee << "\" is newer than depender \"" - << depender << "\"." << std::endl; - cmSystemTools::Stdout(msg.str()); - } + } else if (dependerExists) { + // The dependee and depender both exist. Compare file times. + if (dependerTime.Older(dependeeTime)) { + // The depender is older than the dependee. + regenerate = true; + + // Print verbose output. + if (this->Verbose) { + std::ostringstream msg; + msg << "Dependee \"" << dependee << "\" is newer than depender \"" + << depender << "\"." << std::endl; + cmSystemTools::Stdout(msg.str()); } - } else { - // The dependee exists, but the depender doesn't. Regenerate if the - // internalDepends file is older than the dependee. - int result = 0; - if ((!this->FileTimeCache->Compare(internalDependsFileName, dependee, - &result) || - result < 0)) { - // The depends-file is older than the dependee. - regenerate = true; - - // Print verbose output. - if (this->Verbose) { - std::ostringstream msg; - msg << "Dependee \"" << dependee - << "\" is newer than depends file \"" - << internalDependsFileName << "\"." << std::endl; - cmSystemTools::Stdout(msg.str()); - } + } + } else { + // The dependee exists, but the depender doesn't. Regenerate if the + // internalDepends file is older than the dependee. + if (internalDependsTime.Older(dependeeTime)) { + // The depends-file is older than the dependee. + regenerate = true; + + // Print verbose output. + if (this->Verbose) { + std::ostringstream msg; + msg << "Dependee \"" << dependee + << "\" is newer than depends file \"" << internalDependsFileName + << "\"." << std::endl; + cmSystemTools::Stdout(msg.str()); } } } + if (regenerate) { // Dependencies must be regenerated. okay = false; @@ -218,13 +215,14 @@ bool cmDepends::CheckDependencies( // Remove the information of this depender from the map, it needs // to be rescanned if (currentDependencies != nullptr) { - validDeps.erase(this->Depender); + validDeps.erase(depender); currentDependencies = nullptr; } // Remove the depender to be sure it is rebuilt. if (dependerExists) { cmSystemTools::RemoveFile(depender); + this->FileTimeCache->Remove(depender); dependerExists = false; } } diff --git a/Source/cmDepends.h b/Source/cmDepends.h index fc6571d..b7475f0 100644 --- a/Source/cmDepends.h +++ b/Source/cmDepends.h @@ -8,7 +8,6 @@ #include <iosfwd> #include <map> #include <set> -#include <stddef.h> #include <string> #include <vector> @@ -25,6 +24,9 @@ class cmLocalGenerator; class cmDepends { public: + typedef std::map<std::string, std::vector<std::string>> DependencyMap; + +public: /** Instances need to know the build directory name and the relative path from the build directory to the target file. */ cmDepends(cmLocalGenerator* lg = nullptr, std::string targetDir = ""); @@ -56,17 +58,13 @@ public: /** Write dependencies for the target file. */ bool Write(std::ostream& makeDepends, std::ostream& internalDepends); - class DependencyVector : public std::vector<std::string> - { - }; - /** Check dependencies for the target file. Returns true if dependencies are okay and false if they must be generated. If they must be generated Clear has already been called to wipe out the old dependencies. Dependencies which are still valid will be stored in validDeps. */ bool Check(const std::string& makeFile, const std::string& internalFile, - std::map<std::string, DependencyVector>& validDeps); + DependencyMap& validDeps); /** Clear dependencies for the target file so they will be regenerated. */ void Clear(const std::string& file); @@ -85,9 +83,9 @@ protected: // Check dependencies for the target file in the given stream. // Return false if dependencies must be regenerated and true // otherwise. - virtual bool CheckDependencies( - std::istream& internalDepends, const std::string& internalDependsFileName, - std::map<std::string, DependencyVector>& validDeps); + virtual bool CheckDependencies(std::istream& internalDepends, + const std::string& internalDependsFileName, + DependencyMap& validDeps); // Finalize the dependency information for the target. virtual bool Finalize(std::ostream& makeDepends, @@ -105,10 +103,6 @@ protected: // The full path to the target's build directory. std::string TargetDirectory; - size_t MaxPath = 16384; - char* Dependee; - char* Depender; - // The include file search path. std::vector<std::string> IncludePath; diff --git a/Source/cmDependsC.cxx b/Source/cmDependsC.cxx index 7b78767..dc49c18 100644 --- a/Source/cmDependsC.cxx +++ b/Source/cmDependsC.cxx @@ -21,9 +21,8 @@ cmDependsC::cmDependsC() = default; -cmDependsC::cmDependsC( - cmLocalGenerator* lg, const std::string& targetDir, const std::string& lang, - const std::map<std::string, DependencyVector>* validDeps) +cmDependsC::cmDependsC(cmLocalGenerator* lg, const std::string& targetDir, + const std::string& lang, const DependencyMap* validDeps) : cmDepends(lg, targetDir) , ValidDeps(validDeps) { @@ -102,8 +101,7 @@ bool cmDependsC::WriteDependencies(const std::set<std::string>& sources, this->LocalGenerator->MaybeConvertToRelativePath(binDir, obj); if (this->ValidDeps != nullptr) { - std::map<std::string, DependencyVector>::const_iterator tmpIt = - this->ValidDeps->find(obj_i); + auto const tmpIt = this->ValidDeps->find(obj_i); if (tmpIt != this->ValidDeps->end()) { dependencies.insert(tmpIt->second.begin(), tmpIt->second.end()); haveDeps = true; diff --git a/Source/cmDependsC.h b/Source/cmDependsC.h index eee5ae1..3fc839e 100644 --- a/Source/cmDependsC.h +++ b/Source/cmDependsC.h @@ -27,8 +27,7 @@ public: relative path from the build directory to the target file. */ cmDependsC(); cmDependsC(cmLocalGenerator* lg, const std::string& targetDir, - const std::string& lang, - const std::map<std::string, DependencyVector>* validDeps); + const std::string& lang, const DependencyMap* validDeps); /** Virtual destructor to cleanup subclasses properly. */ ~cmDependsC() override; @@ -81,7 +80,7 @@ public: }; protected: - const std::map<std::string, DependencyVector>* ValidDeps = nullptr; + const DependencyMap* ValidDeps = nullptr; std::set<std::string> Encountered; std::queue<UnscannedEntry> Unscanned; diff --git a/Source/cmDependsJava.cxx b/Source/cmDependsJava.cxx index 2485e15..b17b2ba 100644 --- a/Source/cmDependsJava.cxx +++ b/Source/cmDependsJava.cxx @@ -24,8 +24,7 @@ bool cmDependsJava::WriteDependencies(const std::set<std::string>& sources, bool cmDependsJava::CheckDependencies( std::istream& /*internalDepends*/, - const std::string& /*internalDependsFileName*/, - std::map<std::string, DependencyVector>& /*validDeps*/) + const std::string& /*internalDependsFileName*/, DependencyMap& /*validDeps*/) { return true; } diff --git a/Source/cmDependsJava.h b/Source/cmDependsJava.h index 109ef13..dd671a1 100644 --- a/Source/cmDependsJava.h +++ b/Source/cmDependsJava.h @@ -8,7 +8,6 @@ #include "cmDepends.h" #include <iosfwd> -#include <map> #include <set> #include <string> @@ -33,9 +32,9 @@ protected: bool WriteDependencies(const std::set<std::string>& sources, const std::string& file, std::ostream& makeDepends, std::ostream& internalDepends) override; - bool CheckDependencies( - std::istream& internalDepends, const std::string& internalDependsFileName, - std::map<std::string, DependencyVector>& validDeps) override; + bool CheckDependencies(std::istream& internalDepends, + const std::string& internalDependsFileName, + DependencyMap& validDeps) override; }; #endif diff --git a/Source/cmFileTime.h b/Source/cmFileTime.h index 4c8e556..d4de4e0 100644 --- a/Source/cmFileTime.h +++ b/Source/cmFileTime.h @@ -50,7 +50,7 @@ public: * @brief Compare file modification times. * @return -1, 0, +1 for this older, same, or newer than ftm. */ - int Compare(cmFileTime const& ftm) + int Compare(cmFileTime const& ftm) const { NSC const diff = this->NS - ftm.NS; if (diff == 0) { diff --git a/Source/cmFileTimeCache.cxx b/Source/cmFileTimeCache.cxx index 1fff6a9..24d6bf6 100644 --- a/Source/cmFileTimeCache.cxx +++ b/Source/cmFileTimeCache.cxx @@ -14,8 +14,8 @@ bool cmFileTimeCache::Load(std::string const& fileName, cmFileTime& fileTime) { // Use the stored time if available. { - auto fit = this->FileTimes.find(fileName); - if (fit != this->FileTimes.end()) { + auto fit = this->Cache.find(fileName); + if (fit != this->Cache.end()) { fileTime = fit->second; return true; } @@ -25,10 +25,15 @@ bool cmFileTimeCache::Load(std::string const& fileName, cmFileTime& fileTime) return false; } // Store file time in cache - this->FileTimes[fileName] = fileTime; + this->Cache[fileName] = fileTime; return true; } +bool cmFileTimeCache::Remove(std::string const& fileName) +{ + return (this->Cache.erase(fileName) != 0); +} + bool cmFileTimeCache::Compare(std::string const& f1, std::string const& f2, int* result) { diff --git a/Source/cmFileTimeCache.h b/Source/cmFileTimeCache.h index a47904c..4f1a3a2 100644 --- a/Source/cmFileTimeCache.h +++ b/Source/cmFileTimeCache.h @@ -5,7 +5,7 @@ #include "cmConfigure.h" // IWYU pragma: keep -#include "cmFileTime.h" +#include "cmFileTime.h" // IWYU pragma: keep #include <string> #include <unordered_map> @@ -28,6 +28,12 @@ public: bool Load(std::string const& fileName, cmFileTime& fileTime); /** + * @brief Removes a file time from the cache + * @return true if the file was found in the cache and removed + */ + bool Remove(std::string const& fileName); + + /** * @brief Compare file modification times. * @return true for successful comparison and false for error. * @@ -44,8 +50,7 @@ public: bool DifferS(std::string const& f1, std::string const& f2); private: - typedef std::unordered_map<std::string, cmFileTime> FileTimeMap; - FileTimeMap FileTimes; + std::unordered_map<std::string, cmFileTime> Cache; }; #endif diff --git a/Source/cmLocalUnixMakefileGenerator3.cxx b/Source/cmLocalUnixMakefileGenerator3.cxx index f6ee9fc..bece12e 100644 --- a/Source/cmLocalUnixMakefileGenerator3.cxx +++ b/Source/cmLocalUnixMakefileGenerator3.cxx @@ -1313,7 +1313,7 @@ bool cmLocalUnixMakefileGenerator3::UpdateDependencies( // The build.make file may have explicit dependencies for the object // files but these will not affect the scanning process so they need // not be considered. - std::map<std::string, cmDepends::DependencyVector> validDependencies; + cmDepends::DependencyMap validDependencies; bool needRescanDependencies = false; if (!needRescanDirInfo) { cmDependsC checker; @@ -1353,8 +1353,7 @@ bool cmLocalUnixMakefileGenerator3::UpdateDependencies( bool cmLocalUnixMakefileGenerator3::ScanDependencies( std::string const& targetDir, std::string const& dependFile, - std::string const& internalDependFile, - std::map<std::string, cmDepends::DependencyVector>& validDeps) + std::string const& internalDependFile, cmDepends::DependencyMap& validDeps) { // Read the directory information file. cmMakefile* mf = this->Makefile; diff --git a/Source/cmLocalUnixMakefileGenerator3.h b/Source/cmLocalUnixMakefileGenerator3.h index ba882da..7a0ea98 100644 --- a/Source/cmLocalUnixMakefileGenerator3.h +++ b/Source/cmLocalUnixMakefileGenerator3.h @@ -143,8 +143,7 @@ public: // File pairs for implicit dependency scanning. The key of the map // is the depender and the value is the explicit dependee. - struct ImplicitDependFileMap - : public std::map<std::string, cmDepends::DependencyVector> + struct ImplicitDependFileMap : public cmDepends::DependencyMap { }; struct ImplicitDependLanguageMap @@ -230,10 +229,10 @@ protected: const char* filename = nullptr); // Helper methods for dependency updates. - bool ScanDependencies( - std::string const& targetDir, std::string const& dependFile, - std::string const& internalDependFile, - std::map<std::string, cmDepends::DependencyVector>& validDeps); + bool ScanDependencies(std::string const& targetDir, + std::string const& dependFile, + std::string const& internalDependFile, + cmDepends::DependencyMap& validDeps); void CheckMultipleOutputs(bool verbose); private: diff --git a/Source/cmake.cxx b/Source/cmake.cxx index 8c1a359..fc24ac0 100644 --- a/Source/cmake.cxx +++ b/Source/cmake.cxx @@ -710,6 +710,7 @@ void cmake::SetArgs(const std::vector<std::string>& args) this->GraphVizFile = path; if (this->GraphVizFile.empty()) { cmSystemTools::Error("No file specified for --graphviz"); + return; } } else if (arg.find("--debug-trycompile", 0) == 0) { std::cout << "debug trycompile on\n"; @@ -797,9 +798,9 @@ void cmake::SetArgs(const std::vector<std::string>& args) cmSystemTools::Error("Could not create named generator " + value + kdevError); this->PrintGeneratorList(); - } else { - this->SetGlobalGenerator(gen); + return; } + this->SetGlobalGenerator(gen); } // no option assume it is the path to the source or an existing build else { diff --git a/Tests/IncludeDirectories/TargetIncludeDirectories/CMakeLists.txt b/Tests/IncludeDirectories/TargetIncludeDirectories/CMakeLists.txt index 5b99ea7..a9edf9a 100644 --- a/Tests/IncludeDirectories/TargetIncludeDirectories/CMakeLists.txt +++ b/Tests/IncludeDirectories/TargetIncludeDirectories/CMakeLists.txt @@ -17,7 +17,8 @@ create_header(bing) create_header(bung) create_header(arguments) create_header(list) -create_header(target) +create_header(target1) +create_header(target2) set(CMAKE_INCLUDE_CURRENT_DIR ON) @@ -69,14 +70,23 @@ set_property(TARGET lib4 APPEND PROPERTY INCLUDE_DIRECTORIES "${CMAKE_CURRENT_BI set_property(TARGET lib4 APPEND PROPERTY INTERFACE_INCLUDE_DIRECTORIES "${CMAKE_CURRENT_BINARY_DIR}/foh;$<TARGET_PROPERTY:lib3,INTERFACE_INCLUDE_DIRECTORIES>") add_library(somelib::withcolons UNKNOWN IMPORTED) -set_property(TARGET somelib::withcolons PROPERTY IMPORTED_LOCATION "${CMAKE_CURRENT_BINARY_DIR}/target") -set_property(TARGET somelib::withcolons PROPERTY INTERFACE_INCLUDE_DIRECTORIES "${CMAKE_CURRENT_BINARY_DIR}/target") +set_property(TARGET somelib::withcolons PROPERTY IMPORTED_LOCATION "${CMAKE_CURRENT_BINARY_DIR}/target1") +set_property(TARGET somelib::withcolons PROPERTY INTERFACE_INCLUDE_DIRECTORIES "${CMAKE_CURRENT_BINARY_DIR}/target1") set_property(TARGET TargetIncludeDirectories APPEND PROPERTY INCLUDE_DIRECTORIES "$<TARGET_PROPERTY:somelib::withcolons,INTERFACE_INCLUDE_DIRECTORIES>" ) +add_library(somelib_aliased UNKNOWN IMPORTED GLOBAL) +set_property(TARGET somelib_aliased PROPERTY INTERFACE_INCLUDE_DIRECTORIES "${CMAKE_CURRENT_BINARY_DIR}/target2") +add_library(somelib::withcolons2 ALIAS somelib_aliased) + +set_property(TARGET TargetIncludeDirectories + APPEND PROPERTY INCLUDE_DIRECTORIES + "$<TARGET_PROPERTY:somelib::withcolons2,INTERFACE_INCLUDE_DIRECTORIES>" +) + add_custom_target(test_custom_target "some_bogus_custom_tool" $<TARGET_PROPERTY:TargetIncludeDirectories,COMPILE_DEFINITIONS> diff --git a/Tests/IncludeDirectories/TargetIncludeDirectories/main.cpp b/Tests/IncludeDirectories/TargetIncludeDirectories/main.cpp index 2ee05e2..541ef92 100644 --- a/Tests/IncludeDirectories/TargetIncludeDirectories/main.cpp +++ b/Tests/IncludeDirectories/TargetIncludeDirectories/main.cpp @@ -10,7 +10,8 @@ #include "foo.h" #include "list.h" #include "prefix_foo_bar_bat.h" -#include "target.h" +#include "target1.h" +#include "target2.h" #include "ting.h" int main(int, char**) |