diff options
114 files changed, 698 insertions, 480 deletions
diff --git a/Help/command/project.rst b/Help/command/project.rst index 688e56c..a95012d 100644 --- a/Help/command/project.rst +++ b/Help/command/project.rst @@ -31,9 +31,9 @@ Further variables are set by the optional arguments described in the following. If any of these arguments is not used, then the corresponding variables are set to the empty string. -If the variable :variable:`CMAKE_PROJECT_<PROJECT-NAME>_INCLUDE` exists, -the file pointed to by that variable will be included as the last step of the -project command. +If the variable :variable:`CMAKE_PROJECT_<PROJECT-NAME>_INCLUDE` +or :variable:`CMAKE_PROJECT_INCLUDE` exists, the file pointed to by that +variable will be included as the last step of the project command. Options ^^^^^^^ diff --git a/Help/manual/cmake-generator-expressions.7.rst b/Help/manual/cmake-generator-expressions.7.rst index 8cb0fe7..f93de53 100644 --- a/Help/manual/cmake-generator-expressions.7.rst +++ b/Help/manual/cmake-generator-expressions.7.rst @@ -86,8 +86,10 @@ String Comparisons ``$<EQUAL:value1,value2>`` ``1`` if ``value1`` and ``value2`` are numerically equal, else ``0``. ``$<IN_LIST:string,list>`` - ``1`` if ``string`` is member of the comma-separated ``list``, else ``0``. + ``1`` if ``string`` is member of the semicolon-separated ``list``, else ``0``. Uses case-sensitive comparisons. +``$<REMOVE_DUPLICATES:list>`` + Removes duplicated items in the given ``list``. ``$<VERSION_LESS:v1,v2>`` ``1`` if ``v1`` is a version less than ``v2``, else ``0``. ``$<VERSION_GREATER:v1,v2>`` diff --git a/Help/manual/cmake-variables.7.rst b/Help/manual/cmake-variables.7.rst index 48d7550..e1584ef 100644 --- a/Help/manual/cmake-variables.7.rst +++ b/Help/manual/cmake-variables.7.rst @@ -195,6 +195,7 @@ Variables that Change Behavior /variable/CMAKE_POLICY_WARNING_CMPNNNN /variable/CMAKE_PREFIX_PATH /variable/CMAKE_PROGRAM_PATH + /variable/CMAKE_PROJECT_INCLUDE /variable/CMAKE_PROJECT_PROJECT-NAME_INCLUDE /variable/CMAKE_SKIP_INSTALL_ALL_DEPENDENCY /variable/CMAKE_STAGING_PREFIX 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/Help/release/dev/project-include.rst b/Help/release/dev/project-include.rst new file mode 100644 index 0000000..659e933 --- /dev/null +++ b/Help/release/dev/project-include.rst @@ -0,0 +1,5 @@ +cmake_project_include +--------------------- + +* A variable :variable:`CMAKE_PROJECT_INCLUDE` was added to allow injection + of custom code into the project without knowing the project name a priori. diff --git a/Help/variable/CMAKE_PROJECT_INCLUDE.rst b/Help/variable/CMAKE_PROJECT_INCLUDE.rst new file mode 100644 index 0000000..7de767a --- /dev/null +++ b/Help/variable/CMAKE_PROJECT_INCLUDE.rst @@ -0,0 +1,6 @@ +CMAKE_PROJECT_INCLUDE +--------------------- + +A CMake language file or module to be included by the :command:`project` +command. This is intended for injecting custom code into project +builds without modifying their source. diff --git a/Modules/CMakeASM_NASMInformation.cmake b/Modules/CMakeASM_NASMInformation.cmake index 1e3c608..cb793e7 100644 --- a/Modules/CMakeASM_NASMInformation.cmake +++ b/Modules/CMakeASM_NASMInformation.cmake @@ -28,7 +28,9 @@ if(NOT CMAKE_ASM_NASM_OBJECT_FORMAT) endif() endif() -set(CMAKE_ASM_NASM_COMPILE_OBJECT "<CMAKE_ASM_NASM_COMPILER> <INCLUDES> <FLAGS> -f ${CMAKE_ASM_NASM_OBJECT_FORMAT} -o <OBJECT> <SOURCE>") +if(NOT CMAKE_ASM_NASM_COMPILE_OBJECT) + set(CMAKE_ASM_NASM_COMPILE_OBJECT "<CMAKE_ASM_NASM_COMPILER> <INCLUDES> <FLAGS> -f ${CMAKE_ASM_NASM_OBJECT_FORMAT} -o <OBJECT> <SOURCE>") +endif() # Load the generic ASMInformation file: set(ASM_DIALECT "_NASM") diff --git a/Modules/CMakeFindDependencyMacro.cmake b/Modules/CMakeFindDependencyMacro.cmake index ab22701..bcdfbeb 100644 --- a/Modules/CMakeFindDependencyMacro.cmake +++ b/Modules/CMakeFindDependencyMacro.cmake @@ -31,35 +31,33 @@ CMakeFindDependencyMacro #]=======================================================================] macro(find_dependency dep) - if (NOT ${dep}_FOUND) - set(cmake_fd_quiet_arg) - if(${CMAKE_FIND_PACKAGE_NAME}_FIND_QUIETLY) - set(cmake_fd_quiet_arg QUIET) - endif() - set(cmake_fd_required_arg) - if(${CMAKE_FIND_PACKAGE_NAME}_FIND_REQUIRED) - set(cmake_fd_required_arg REQUIRED) - endif() + set(cmake_fd_quiet_arg) + if(${CMAKE_FIND_PACKAGE_NAME}_FIND_QUIETLY) + set(cmake_fd_quiet_arg QUIET) + endif() + set(cmake_fd_required_arg) + if(${CMAKE_FIND_PACKAGE_NAME}_FIND_REQUIRED) + set(cmake_fd_required_arg REQUIRED) + endif() - get_property(cmake_fd_alreadyTransitive GLOBAL PROPERTY - _CMAKE_${dep}_TRANSITIVE_DEPENDENCY - ) + get_property(cmake_fd_alreadyTransitive GLOBAL PROPERTY + _CMAKE_${dep}_TRANSITIVE_DEPENDENCY + ) - find_package(${dep} ${ARGN} - ${cmake_fd_quiet_arg} - ${cmake_fd_required_arg} - ) + find_package(${dep} ${ARGN} + ${cmake_fd_quiet_arg} + ${cmake_fd_required_arg} + ) - if(NOT DEFINED cmake_fd_alreadyTransitive OR cmake_fd_alreadyTransitive) - set_property(GLOBAL PROPERTY _CMAKE_${dep}_TRANSITIVE_DEPENDENCY TRUE) - endif() + if(NOT DEFINED cmake_fd_alreadyTransitive OR cmake_fd_alreadyTransitive) + set_property(GLOBAL PROPERTY _CMAKE_${dep}_TRANSITIVE_DEPENDENCY TRUE) + endif() - if (NOT ${dep}_FOUND) - set(${CMAKE_FIND_PACKAGE_NAME}_NOT_FOUND_MESSAGE "${CMAKE_FIND_PACKAGE_NAME} could not be found because dependency ${dep} could not be found.") - set(${CMAKE_FIND_PACKAGE_NAME}_FOUND False) - return() - endif() - set(cmake_fd_required_arg) - set(cmake_fd_quiet_arg) + if (NOT ${dep}_FOUND) + set(${CMAKE_FIND_PACKAGE_NAME}_NOT_FOUND_MESSAGE "${CMAKE_FIND_PACKAGE_NAME} could not be found because dependency ${dep} could not be found.") + set(${CMAKE_FIND_PACKAGE_NAME}_FOUND False) + return() endif() + set(cmake_fd_required_arg) + set(cmake_fd_quiet_arg) endmacro() 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 7906a0b..3ba392e 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 20190401) +set(CMake_VERSION_PATCH 20190404) #set(CMake_VERSION_RC 1) diff --git a/Source/CPack/cpack.cxx b/Source/CPack/cpack.cxx index da9575b..3ceb824 100644 --- a/Source/CPack/cpack.cxx +++ b/Source/CPack/cpack.cxx @@ -82,7 +82,7 @@ int cpackDefinitionArgument(const char* argument, const char* cValue, return 0; } std::string key = value.substr(0, pos); - value = value.c_str() + pos + 1; + value = value.substr(pos + 1); def->Map[key] = value; cmCPack_Log(def->Log, cmCPackLog::LOG_DEBUG, "Set CPack variable: " << key << " to \"" << value << "\"" diff --git a/Source/CTest/cmCTestBuildAndTestHandler.h b/Source/CTest/cmCTestBuildAndTestHandler.h index 5e6d0aa..2d47b15 100644 --- a/Source/CTest/cmCTestBuildAndTestHandler.h +++ b/Source/CTest/cmCTestBuildAndTestHandler.h @@ -44,7 +44,7 @@ public: void Initialize() override; protected: - ///! Run CMake and build a test and then run it as a single test. + //! Run CMake and build a test and then run it as a single test. int RunCMakeAndTest(std::string* output); int RunCMake(std::string* outstring, std::ostringstream& out, std::string& cmakeOutString, cmake* cm); diff --git a/Source/CTest/cmCTestBuildHandler.cxx b/Source/CTest/cmCTestBuildHandler.cxx index 8ea9a83..8480309 100644 --- a/Source/CTest/cmCTestBuildHandler.cxx +++ b/Source/CTest/cmCTestBuildHandler.cxx @@ -387,7 +387,7 @@ int cmCTestBuildHandler::ProcessHandler() std::string srcdirrep; for (cc = srcdir.size() - 2; cc > 0; cc--) { if (srcdir[cc] == '/') { - srcdirrep = srcdir.c_str() + cc; + srcdirrep = srcdir.substr(cc); srcdirrep = "/..." + srcdirrep; srcdir = srcdir.substr(0, cc + 1); break; @@ -401,7 +401,7 @@ int cmCTestBuildHandler::ProcessHandler() std::string bindirrep; for (cc = bindir.size() - 2; cc > 0; cc--) { if (bindir[cc] == '/') { - bindirrep = bindir.c_str() + cc; + bindirrep = bindir.substr(cc); bindirrep = "/..." + bindirrep; bindir = bindir.substr(0, cc + 1); break; diff --git a/Source/CTest/cmCTestGIT.cxx b/Source/CTest/cmCTestGIT.cxx index 11cd005..9d9761c 100644 --- a/Source/CTest/cmCTestGIT.cxx +++ b/Source/CTest/cmCTestGIT.cxx @@ -547,7 +547,7 @@ private: { // Look for header fields that we need. if (cmHasLiteralPrefix(this->Line, "commit ")) { - this->Rev.Rev = this->Line.c_str() + 7; + this->Rev.Rev = this->Line.substr(7); } else if (cmHasLiteralPrefix(this->Line, "author ")) { Person author; this->ParsePerson(this->Line.c_str() + 7, author); diff --git a/Source/CTest/cmCTestLaunch.cxx b/Source/CTest/cmCTestLaunch.cxx index 5e66e05..a96513e 100644 --- a/Source/CTest/cmCTestLaunch.cxx +++ b/Source/CTest/cmCTestLaunch.cxx @@ -308,7 +308,7 @@ void cmCTestLaunch::LoadLabels() if (line[0] == ' ') { // Label lines appear indented by one space. if (inTarget || inSource) { - this->Labels.insert(line.c_str() + 1); + this->Labels.insert(line.substr(1)); } } else if (!this->OptionSource.empty() && !inSource) { // Non-indented lines specify a source file name. The first one diff --git a/Source/CTest/cmCTestMemCheckHandler.h b/Source/CTest/cmCTestMemCheckHandler.h index 8880dac..746d72c 100644 --- a/Source/CTest/cmCTestMemCheckHandler.h +++ b/Source/CTest/cmCTestMemCheckHandler.h @@ -114,7 +114,7 @@ private: // this type of checker void InitializeResultsVectors(); - ///! Initialize memory checking subsystem. + //! Initialize memory checking subsystem. bool InitializeMemoryChecking(); /** @@ -143,11 +143,11 @@ private: void PostProcessTest(cmCTestTestResult& res, int test); void PostProcessBoundsCheckerTest(cmCTestTestResult& res, int test); - ///! append MemoryTesterOutputFile to the test log + //! append MemoryTesterOutputFile to the test log void AppendMemTesterOutput(cmCTestTestHandler::cmCTestTestResult& res, std::string const& filename); - ///! generate the output filename for the given test index + //! generate the output filename for the given test index void TestOutputFileNames(int test, std::vector<std::string>& files); }; diff --git a/Source/CTest/cmCTestSVN.cxx b/Source/CTest/cmCTestSVN.cxx index b7a4e4c..04749b7 100644 --- a/Source/CTest/cmCTestSVN.cxx +++ b/Source/CTest/cmCTestSVN.cxx @@ -515,7 +515,7 @@ private: if (path.size() > this->SVN->SourceDirectory.size() && strncmp(path.c_str(), this->SVN->SourceDirectory.c_str(), this->SVN->SourceDirectory.size()) == 0) { - local_path = path.c_str() + this->SVN->SourceDirectory.size() + 1; + local_path = path.substr(this->SVN->SourceDirectory.size() + 1); } else { local_path = path; } @@ -554,7 +554,7 @@ std::string cmCTestSVN::SVNInfo::BuildLocalPath(std::string const& path) const // Add path with base prefix removed if (path.size() > this->Base.size() && strncmp(path.c_str(), this->Base.c_str(), this->Base.size()) == 0) { - local_path += (path.c_str() + this->Base.size()); + local_path += path.substr(this->Base.size()); } else { local_path += path; } diff --git a/Source/CTest/cmCTestTestHandler.cxx b/Source/CTest/cmCTestTestHandler.cxx index c9783e4..0ed56c8 100644 --- a/Source/CTest/cmCTestTestHandler.cxx +++ b/Source/CTest/cmCTestTestHandler.cxx @@ -2265,8 +2265,8 @@ bool cmCTestTestHandler::SetTestsProperties( size_t pos = val.find_first_of('='); if (pos != std::string::npos) { std::string mKey = val.substr(0, pos); - const char* mVal = val.c_str() + pos + 1; - rt.Measurements[mKey] = mVal; + std::string mVal = val.substr(pos + 1); + rt.Measurements[mKey] = std::move(mVal); } else { rt.Measurements[val] = "1"; } diff --git a/Source/CTest/cmCTestTestHandler.h b/Source/CTest/cmCTestTestHandler.h index 17d5f3f..7f3f5e4 100644 --- a/Source/CTest/cmCTestTestHandler.h +++ b/Source/CTest/cmCTestTestHandler.h @@ -59,7 +59,7 @@ public: */ void PopulateCustomVectors(cmMakefile* mf) override; - ///! Control the use of the regular expresisons, call these methods to turn + //! Control the use of the regular expresisons, call these methods to turn /// them on void UseIncludeRegExp(); void UseExcludeRegExp(); @@ -78,7 +78,7 @@ public: this->CustomMaximumFailedTestOutputSize = n; } - ///! pass the -I argument down + //! pass the -I argument down void SetTestsToRunInformation(const char*); cmCTestTestHandler(); 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/cmCacheManager.h b/Source/cmCacheManager.h index 0c70ed2..65f22f7 100644 --- a/Source/cmCacheManager.h +++ b/Source/cmCacheManager.h @@ -93,33 +93,33 @@ public: CacheEntry& GetEntry() { return this->Position->second; } }; - ///! return an iterator to iterate through the cache map + //! return an iterator to iterate through the cache map cmCacheManager::CacheIterator NewIterator() { return CacheIterator(*this); } - ///! Load a cache for given makefile. Loads from path/CMakeCache.txt. + //! Load a cache for given makefile. Loads from path/CMakeCache.txt. bool LoadCache(const std::string& path, bool internal, std::set<std::string>& excludes, std::set<std::string>& includes); - ///! Save cache for given makefile. Saves to output path/CMakeCache.txt + //! Save cache for given makefile. Saves to output path/CMakeCache.txt bool SaveCache(const std::string& path, cmMessenger* messenger); - ///! Delete the cache given + //! Delete the cache given bool DeleteCache(const std::string& path); - ///! Print the cache to a stream + //! Print the cache to a stream void PrintCache(std::ostream&) const; - ///! Get the iterator for an entry with a given key. + //! Get the iterator for an entry with a given key. cmCacheManager::CacheIterator GetCacheIterator(const char* key = nullptr); - ///! Remove an entry from the cache + //! Remove an entry from the cache void RemoveCacheEntry(const std::string& key); - ///! Get the number of entries in the cache + //! Get the number of entries in the cache int GetSize() { return static_cast<int>(this->Cache.size()); } - ///! Get a value from the cache given a key + //! Get a value from the cache given a key const std::string* GetInitializedCacheValue(const std::string& key) const; const char* GetCacheEntryValue(const std::string& key) @@ -197,14 +197,14 @@ public: unsigned int GetCacheMinorVersion() const { return this->CacheMinorVersion; } protected: - ///! Add an entry into the cache + //! Add an entry into the cache void AddCacheEntry(const std::string& key, const char* value, const char* helpString, cmStateEnums::CacheEntryType type); - ///! Get a cache entry object for a key + //! Get a cache entry object for a key CacheEntry* GetCacheEntry(const std::string& key); - ///! Clean out the CMakeFiles directory if no CMakeCache.txt + //! Clean out the CMakeFiles directory if no CMakeCache.txt void CleanCMakeFiles(const std::string& path); // Cache version info diff --git a/Source/cmCallVisualStudioMacro.cxx b/Source/cmCallVisualStudioMacro.cxx index ee5feee..2f6cf64 100644 --- a/Source/cmCallVisualStudioMacro.cxx +++ b/Source/cmCallVisualStudioMacro.cxx @@ -35,8 +35,8 @@ static bool LogErrorsAsMessages; # endif # endif -///! Use ReportHRESULT to make a cmSystemTools::Message after calling -///! a COM method that may have failed. +//! Use ReportHRESULT to make a cmSystemTools::Message after calling +//! a COM method that may have failed. # define ReportHRESULT(hr, context) \ if (FAILED(hr)) { \ if (LogErrorsAsMessages) { \ @@ -50,7 +50,7 @@ static bool LogErrorsAsMessages; } \ } -///! Using the given instance of Visual Studio, call the named macro +//! Using the given instance of Visual Studio, call the named macro HRESULT InstanceCallMacro(IDispatch* vsIDE, const std::string& macro, const std::string& args) { @@ -133,7 +133,7 @@ HRESULT InstanceCallMacro(IDispatch* vsIDE, const std::string& macro, return hr; } -///! Get the Solution object from the IDE object +//! Get the Solution object from the IDE object HRESULT GetSolutionObject(IDispatch* vsIDE, IDispatchPtr& vsSolution) { HRESULT hr = E_POINTER; @@ -176,7 +176,7 @@ HRESULT GetSolutionObject(IDispatch* vsIDE, IDispatchPtr& vsSolution) return hr; } -///! Get the FullName property from the Solution object +//! Get the FullName property from the Solution object HRESULT GetSolutionFullName(IDispatch* vsSolution, std::string& fullName) { HRESULT hr = E_POINTER; @@ -220,7 +220,7 @@ HRESULT GetSolutionFullName(IDispatch* vsSolution, std::string& fullName) return hr; } -///! Get the FullName property from the Solution object, given the IDE object +//! Get the FullName property from the Solution object, given the IDE object HRESULT GetIDESolutionFullName(IDispatch* vsIDE, std::string& fullName) { IDispatchPtr vsSolution; @@ -235,8 +235,8 @@ HRESULT GetIDESolutionFullName(IDispatch* vsIDE, std::string& fullName) return hr; } -///! Get all running objects from the Windows running object table. -///! Save them in a map by their display names. +//! Get all running objects from the Windows running object table. +//! Save them in a map by their display names. HRESULT GetRunningInstances(std::map<std::string, IUnknownPtr>& mrot) { // mrot == Map of the Running Object Table @@ -292,8 +292,8 @@ HRESULT GetRunningInstances(std::map<std::string, IUnknownPtr>& mrot) return hr; } -///! Do the two file names refer to the same Visual Studio solution? Or are -///! we perhaps looking for any and all solutions? +//! Do the two file names refer to the same Visual Studio solution? Or are +//! we perhaps looking for any and all solutions? bool FilesSameSolution(const std::string& slnFile, const std::string& slnName) { if (slnFile == "ALL" || slnName == "ALL") { @@ -310,9 +310,9 @@ bool FilesSameSolution(const std::string& slnFile, const std::string& slnName) return s1 == s2; } -///! Find instances of Visual Studio with the given solution file -///! open. Pass "ALL" for slnFile to gather all running instances -///! of Visual Studio. +//! Find instances of Visual Studio with the given solution file +//! open. Pass "ALL" for slnFile to gather all running instances +//! of Visual Studio. HRESULT FindVisualStudioInstances(const std::string& slnFile, std::vector<IDispatchPtr>& instances) { @@ -384,8 +384,8 @@ int cmCallVisualStudioMacro::GetNumberOfRunningVisualStudioInstances( return count; } -///! Get all running objects from the Windows running object table. -///! Save them in a map by their display names. +//! Get all running objects from the Windows running object table. +//! Save them in a map by their display names. int cmCallVisualStudioMacro::CallMacro(const std::string& slnFile, const std::string& macro, const std::string& args, diff --git a/Source/cmCallVisualStudioMacro.h b/Source/cmCallVisualStudioMacro.h index fdc9e66..9b5b3a8 100644 --- a/Source/cmCallVisualStudioMacro.h +++ b/Source/cmCallVisualStudioMacro.h @@ -16,16 +16,16 @@ class cmCallVisualStudioMacro { public: - ///! Call the named macro in instances of Visual Studio with the - ///! given solution file open. Pass "ALL" for slnFile to call the - ///! macro in each Visual Studio instance. + //! Call the named macro in instances of Visual Studio with the + //! given solution file open. Pass "ALL" for slnFile to call the + //! macro in each Visual Studio instance. static int CallMacro(const std::string& slnFile, const std::string& macro, const std::string& args, const bool logErrorsAsMessages); - ///! Count the number of running instances of Visual Studio with the - ///! given solution file open. Pass "ALL" for slnFile to count all - ///! running Visual Studio instances. + //! Count the number of running instances of Visual Studio with the + //! given solution file open. Pass "ALL" for slnFile to count all + //! running Visual Studio instances. static int GetNumberOfRunningVisualStudioInstances( const std::string& slnFile); 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/cmDependsFortran.cxx b/Source/cmDependsFortran.cxx index 3f036a9..178e18b 100644 --- a/Source/cmDependsFortran.cxx +++ b/Source/cmDependsFortran.cxx @@ -295,7 +295,7 @@ void cmDependsFortran::MatchRemoteModules(std::istream& fin, // They do not include the ".mod" extension. mod += ".mod"; } - this->ConsiderModule(mod.c_str() + 1, stampDir); + this->ConsiderModule(mod.substr(1), stampDir); } } else if (line == "provides") { doing_provides = true; 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/cmDependsJavaParserHelper.cxx b/Source/cmDependsJavaParserHelper.cxx index 792db48..12d875d 100644 --- a/Source/cmDependsJavaParserHelper.cxx +++ b/Source/cmDependsJavaParserHelper.cxx @@ -5,6 +5,7 @@ #include "cmDependsJavaLexer.h" #include "cmSystemTools.h" +#include "cm_string_view.hxx" #include "cmsys/FStream.hxx" #include <iostream> #include <stdio.h> @@ -298,14 +299,10 @@ void cmDependsJavaParserHelper::Error(const char* str) unsigned long pos = static_cast<unsigned long>(this->InputBufferPos); fprintf(stderr, "JPError: %s (%lu / Line: %d)\n", str, pos, this->CurrentLine); - int cc; - std::cerr << "String: ["; - for (cc = 0; - cc < 30 && *(this->InputBuffer.c_str() + this->InputBufferPos + cc); - cc++) { - std::cerr << *(this->InputBuffer.c_str() + this->InputBufferPos + cc); - } - std::cerr << "]" << std::endl; + std::cerr << "String: [" + << cm::string_view{ this->InputBuffer }.substr( + this->InputBufferPos, 30) + << "]" << std::endl; } void cmDependsJavaParserHelper::UpdateCombine(const char* str1, diff --git a/Source/cmExternalMakefileProjectGenerator.h b/Source/cmExternalMakefileProjectGenerator.h index 4438f28..a472a06 100644 --- a/Source/cmExternalMakefileProjectGenerator.h +++ b/Source/cmExternalMakefileProjectGenerator.h @@ -31,13 +31,13 @@ public: virtual void EnableLanguage(std::vector<std::string> const& languages, cmMakefile*, bool optional); - ///! set the global generator which will generate the makefiles + //! set the global generator which will generate the makefiles virtual void SetGlobalGenerator(cmGlobalGenerator* generator) { this->GlobalGenerator = generator; } - ///! Return the list of global generators supported by this extra generator + //! Return the list of global generators supported by this extra generator const std::vector<std::string>& GetSupportedGlobalGenerators() const { return this->SupportedGlobalGenerators; @@ -49,7 +49,7 @@ public: static std::string CreateFullGeneratorName( const std::string& globalGenerator, const std::string& extraGenerator); - ///! Generate the project files, the Makefiles have already been generated + //! Generate the project files, the Makefiles have already been generated virtual void Generate() = 0; void SetName(const std::string& n) { Name = n; } @@ -59,9 +59,9 @@ public: bool dryRun); protected: - ///! Contains the names of the global generators support by this generator. + //! Contains the names of the global generators support by this generator. std::vector<std::string> SupportedGlobalGenerators; - ///! the global generator which creates the makefiles + //! the global generator which creates the makefiles const cmGlobalGenerator* GlobalGenerator = nullptr; std::string Name; diff --git a/Source/cmFileInstaller.cxx b/Source/cmFileInstaller.cxx index f3544c1..d4f76fd 100644 --- a/Source/cmFileInstaller.cxx +++ b/Source/cmFileInstaller.cxx @@ -319,7 +319,7 @@ bool cmFileInstaller::HandleInstallDestination() return false; } } - destination = sdestdir + (destination.c_str() + skip); + destination = sdestdir + destination.substr(skip); this->DestDirLength = int(sdestdir.size()); } 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/cmGeneratorExpressionNode.cxx b/Source/cmGeneratorExpressionNode.cxx index 50413c8..19d2b3a 100644 --- a/Source/cmGeneratorExpressionNode.cxx +++ b/Source/cmGeneratorExpressionNode.cxx @@ -15,6 +15,7 @@ #include "cmMessageType.h" #include "cmOutputConverter.h" #include "cmPolicies.h" +#include "cmRange.h" #include "cmState.h" #include "cmStateSnapshot.h" #include "cmStateTypes.h" @@ -326,6 +327,34 @@ static const struct InListNode : public cmGeneratorExpressionNode } } inListNode; +static const struct RemoveDuplicatesNode : public cmGeneratorExpressionNode +{ + RemoveDuplicatesNode() {} // NOLINT(modernize-use-equals-default) + + int NumExpectedParameters() const override { return 1; } + + std::string Evaluate( + const std::vector<std::string>& parameters, + cmGeneratorExpressionContext* context, + const GeneratorExpressionContent* content, + cmGeneratorExpressionDAGChecker* /*dagChecker*/) const override + { + if (parameters.size() != 1) { + reportError( + context, content->GetOriginalExpression(), + "$<REMOVE_DUPLICATES:...> expression requires one parameter"); + } + + std::vector<std::string> values; + cmSystemTools::ExpandListArgument(parameters.front(), values, true); + + auto valuesEnd = cmRemoveDuplicates(values); + auto valuesBegin = values.cbegin(); + return cmJoin(cmMakeRange(valuesBegin, valuesEnd), ";"); + } + +} removeDuplicatesNode; + static const struct TargetExistsNode : public cmGeneratorExpressionNode { TargetExistsNode() {} // NOLINT(modernize-use-equals-default) @@ -2158,6 +2187,7 @@ const cmGeneratorExpressionNode* cmGeneratorExpressionNode::GetNode( { "STREQUAL", &strEqualNode }, { "EQUAL", &equalNode }, { "IN_LIST", &inListNode }, + { "REMOVE_DUPLICATES", &removeDuplicatesNode }, { "LOWER_CASE", &lowerCaseNode }, { "UPPER_CASE", &upperCaseNode }, { "MAKE_C_IDENTIFIER", &makeCIdentifierNode }, diff --git a/Source/cmGeneratorTarget.h b/Source/cmGeneratorTarget.h index bc966e1..3f2025e 100644 --- a/Source/cmGeneratorTarget.h +++ b/Source/cmGeneratorTarget.h @@ -69,9 +69,9 @@ public: std::string GetExportName() const; std::vector<std::string> GetPropertyKeys() const; - ///! Might return a nullptr if the property is not set or invalid + //! Might return a nullptr if the property is not set or invalid const char* GetProperty(const std::string& prop) const; - ///! Always returns a valid pointer + //! Always returns a valid pointer const char* GetSafeProperty(const std::string& prop) const; bool GetPropertyAsBool(const std::string& prop) const; void GetSourceFiles(std::vector<cmSourceFile*>& files, @@ -602,7 +602,7 @@ public: pdb output directory is given. */ std::string GetPDBDirectory(const std::string& config) const; - ///! Return the preferred linker language for this target + //! Return the preferred linker language for this target std::string GetLinkerLanguage(const std::string& config) const; /** Does this target have a GNU implib to convert to MS format? */ diff --git a/Source/cmGlobVerificationManager.h b/Source/cmGlobVerificationManager.h index f7146be..48606d3 100644 --- a/Source/cmGlobVerificationManager.h +++ b/Source/cmGlobVerificationManager.h @@ -22,11 +22,11 @@ class cmGlobVerificationManager { protected: - ///! Save verification script for given makefile. - ///! Saves to output <path>/<CMakeFilesDirectory>/VerifyGlobs.cmake + //! Save verification script for given makefile. + //! Saves to output <path>/<CMakeFilesDirectory>/VerifyGlobs.cmake bool SaveVerificationScript(const std::string& path); - ///! Add an entry into the glob cache + //! Add an entry into the glob cache void AddCacheEntry(bool recurse, bool listDirectories, bool followSymlinks, const std::string& relative, const std::string& expression, @@ -34,13 +34,13 @@ protected: const std::string& variable, const cmListFileBacktrace& bt); - ///! Clear the glob cache for state reset. + //! Clear the glob cache for state reset. void Reset(); - ///! Check targets should be written in generated build system. + //! Check targets should be written in generated build system. bool DoWriteVerifyTarget() const; - ///! Get the paths to the generated script and stamp files + //! Get the paths to the generated script and stamp files std::string const& GetVerifyScript() const { return this->VerifyScript; } std::string const& GetVerifyStamp() const { return this->VerifyStamp; } diff --git a/Source/cmGlobalBorlandMakefileGenerator.cxx b/Source/cmGlobalBorlandMakefileGenerator.cxx index 281d371..51d681d 100644 --- a/Source/cmGlobalBorlandMakefileGenerator.cxx +++ b/Source/cmGlobalBorlandMakefileGenerator.cxx @@ -34,7 +34,7 @@ void cmGlobalBorlandMakefileGenerator::EnableLanguage( this->cmGlobalUnixMakefileGenerator3::EnableLanguage(l, mf, optional); } -///! Create a local generator appropriate to this Global Generator +//! Create a local generator appropriate to this Global Generator cmLocalGenerator* cmGlobalBorlandMakefileGenerator::CreateLocalGenerator( cmMakefile* mf) { diff --git a/Source/cmGlobalBorlandMakefileGenerator.h b/Source/cmGlobalBorlandMakefileGenerator.h index 02d0d5f..ee7de70 100644 --- a/Source/cmGlobalBorlandMakefileGenerator.h +++ b/Source/cmGlobalBorlandMakefileGenerator.h @@ -22,7 +22,7 @@ public: cmGlobalBorlandMakefileGenerator>(); } - ///! Get the name for the generator. + //! Get the name for the generator. std::string GetName() const override { return cmGlobalBorlandMakefileGenerator::GetActualName(); @@ -32,7 +32,7 @@ public: /** Get the documentation entry for this generator. */ static void GetDocumentation(cmDocumentationEntry& entry); - ///! Create a local generator appropriate to this Global Generator + //! Create a local generator appropriate to this Global Generator cmLocalGenerator* CreateLocalGenerator(cmMakefile* mf) override; /** diff --git a/Source/cmGlobalGenerator.h b/Source/cmGlobalGenerator.h index 17eb340..88c586a 100644 --- a/Source/cmGlobalGenerator.h +++ b/Source/cmGlobalGenerator.h @@ -86,13 +86,13 @@ struct GeneratedMakeCommand class cmGlobalGenerator { public: - ///! Free any memory allocated with the GlobalGenerator + //! Free any memory allocated with the GlobalGenerator cmGlobalGenerator(cmake* cm); virtual ~cmGlobalGenerator(); virtual cmLocalGenerator* CreateLocalGenerator(cmMakefile* mf); - ///! Get the name for this generator + //! Get the name for this generator virtual std::string GetName() const { return "Generic"; } /** Check whether the given name matches the current generator. */ @@ -236,7 +236,7 @@ public: const std::string& native, bool ignoreErrors); - ///! Get the CMake instance + //! Get the CMake instance cmake* GetCMakeInstance() const { return this->CMakeInstance; } void SetConfiguredFilesPath(cmGlobalGenerator* gen); @@ -261,7 +261,7 @@ public: void AddMakefile(cmMakefile* mf); - ///! Set an generator for an "external makefile based project" + //! Set an generator for an "external makefile based project" void SetExternalMakefileProjectGenerator( cmExternalMakefileProjectGenerator* extraGenerator); @@ -290,19 +290,19 @@ public: bool GetForceUnixPaths() const { return this->ForceUnixPaths; } bool GetToolSupportsColor() const { return this->ToolSupportsColor; } - ///! return the language for the given extension + //! return the language for the given extension std::string GetLanguageFromExtension(const char* ext) const; - ///! is an extension to be ignored + //! is an extension to be ignored bool IgnoreFile(const char* ext) const; - ///! What is the preference for linkers and this language (None or Preferred) + //! What is the preference for linkers and this language (None or Preferred) int GetLinkerPreference(const std::string& lang) const; - ///! What is the object file extension for a given source file? + //! What is the object file extension for a given source file? std::string GetLanguageOutputExtension(cmSourceFile const&) const; - ///! What is the configurations directory variable called? + //! What is the configurations directory variable called? virtual const char* GetCMakeCFGIntDir() const { return "."; } - ///! expand CFGIntDir for a configuration + //! expand CFGIntDir for a configuration virtual std::string ExpandCFGIntDir(const std::string& str, const std::string& config) const; @@ -318,7 +318,7 @@ public: */ virtual bool FindMakeProgram(cmMakefile*); - ///! Find a target by name by searching the local generators. + //! Find a target by name by searching the local generators. cmTarget* FindTarget(const std::string& name, bool excludeAliases = false) const; diff --git a/Source/cmGlobalGhsMultiGenerator.h b/Source/cmGlobalGhsMultiGenerator.h index f8df6ef..ae27806 100644 --- a/Source/cmGlobalGhsMultiGenerator.h +++ b/Source/cmGlobalGhsMultiGenerator.h @@ -34,13 +34,13 @@ public: return new cmGlobalGeneratorSimpleFactory<cmGlobalGhsMultiGenerator>(); } - ///! create the correct local generator + //! create the correct local generator cmLocalGenerator* CreateLocalGenerator(cmMakefile* mf) override; /// @return the name of this generator. static std::string GetActualName() { return "Green Hills MULTI"; } - ///! Get the name for this generator + //! Get the name for this generator std::string GetName() const override { return GetActualName(); } /// Overloaded methods. @see cmGlobalGenerator::GetDocumentation() diff --git a/Source/cmGlobalJOMMakefileGenerator.h b/Source/cmGlobalJOMMakefileGenerator.h index 341b2dd..df3aec9 100644 --- a/Source/cmGlobalJOMMakefileGenerator.h +++ b/Source/cmGlobalJOMMakefileGenerator.h @@ -20,7 +20,7 @@ public: { return new cmGlobalGeneratorSimpleFactory<cmGlobalJOMMakefileGenerator>(); } - ///! Get the name for the generator. + //! Get the name for the generator. std::string GetName() const override { return cmGlobalJOMMakefileGenerator::GetActualName(); diff --git a/Source/cmGlobalMSYSMakefileGenerator.h b/Source/cmGlobalMSYSMakefileGenerator.h index 23dbc5e..d6e4847 100644 --- a/Source/cmGlobalMSYSMakefileGenerator.h +++ b/Source/cmGlobalMSYSMakefileGenerator.h @@ -19,7 +19,7 @@ public: return new cmGlobalGeneratorSimpleFactory<cmGlobalMSYSMakefileGenerator>(); } - ///! Get the name for the generator. + //! Get the name for the generator. virtual std::string GetName() const { return cmGlobalMSYSMakefileGenerator::GetActualName(); diff --git a/Source/cmGlobalMinGWMakefileGenerator.h b/Source/cmGlobalMinGWMakefileGenerator.h index a994c92..15297e3 100644 --- a/Source/cmGlobalMinGWMakefileGenerator.h +++ b/Source/cmGlobalMinGWMakefileGenerator.h @@ -19,7 +19,7 @@ public: return new cmGlobalGeneratorSimpleFactory< cmGlobalMinGWMakefileGenerator>(); } - ///! Get the name for the generator. + //! Get the name for the generator. virtual std::string GetName() const { return cmGlobalMinGWMakefileGenerator::GetActualName(); diff --git a/Source/cmGlobalNMakeMakefileGenerator.h b/Source/cmGlobalNMakeMakefileGenerator.h index 1fc2f9c..2fdf1ce 100644 --- a/Source/cmGlobalNMakeMakefileGenerator.h +++ b/Source/cmGlobalNMakeMakefileGenerator.h @@ -21,7 +21,7 @@ public: return new cmGlobalGeneratorSimpleFactory< cmGlobalNMakeMakefileGenerator>(); } - ///! Get the name for the generator. + //! Get the name for the generator. std::string GetName() const override { return cmGlobalNMakeMakefileGenerator::GetActualName(); diff --git a/Source/cmGlobalUnixMakefileGenerator3.cxx b/Source/cmGlobalUnixMakefileGenerator3.cxx index 3381c81..9d64924 100644 --- a/Source/cmGlobalUnixMakefileGenerator3.cxx +++ b/Source/cmGlobalUnixMakefileGenerator3.cxx @@ -57,7 +57,7 @@ void cmGlobalUnixMakefileGenerator3::EnableLanguage( } } -///! Create a local generator appropriate to this Global Generator +//! Create a local generator appropriate to this Global Generator cmLocalGenerator* cmGlobalUnixMakefileGenerator3::CreateLocalGenerator( cmMakefile* mf) { diff --git a/Source/cmGlobalUnixMakefileGenerator3.h b/Source/cmGlobalUnixMakefileGenerator3.h index 496104d..e919d38 100644 --- a/Source/cmGlobalUnixMakefileGenerator3.h +++ b/Source/cmGlobalUnixMakefileGenerator3.h @@ -67,7 +67,7 @@ public: cmGlobalUnixMakefileGenerator3>(); } - ///! Get the name for the generator. + //! Get the name for the generator. std::string GetName() const override { return cmGlobalUnixMakefileGenerator3::GetActualName(); diff --git a/Source/cmGlobalVisualStudio10Generator.cxx b/Source/cmGlobalVisualStudio10Generator.cxx index 26fd62b..4fa89d0 100644 --- a/Source/cmGlobalVisualStudio10Generator.cxx +++ b/Source/cmGlobalVisualStudio10Generator.cxx @@ -509,7 +509,7 @@ std::string cmGlobalVisualStudio10Generator::SelectWindowsCEToolset() const return ""; } -///! Create a local generator appropriate to this Global Generator +//! Create a local generator appropriate to this Global Generator cmLocalGenerator* cmGlobalVisualStudio10Generator::CreateLocalGenerator( cmMakefile* mf) { diff --git a/Source/cmGlobalVisualStudio10Generator.h b/Source/cmGlobalVisualStudio10Generator.h index 26db929..2f532a6 100644 --- a/Source/cmGlobalVisualStudio10Generator.h +++ b/Source/cmGlobalVisualStudio10Generator.h @@ -29,7 +29,7 @@ public: std::vector<std::string> const& makeOptions = std::vector<std::string>()) override; - ///! create the correct local generator + //! create the correct local generator cmLocalGenerator* CreateLocalGenerator(cmMakefile* mf) override; /** diff --git a/Source/cmGlobalVisualStudio7Generator.cxx b/Source/cmGlobalVisualStudio7Generator.cxx index c694902..d7630e4 100644 --- a/Source/cmGlobalVisualStudio7Generator.cxx +++ b/Source/cmGlobalVisualStudio7Generator.cxx @@ -248,7 +248,7 @@ cmGlobalVisualStudio7Generator::GenerateBuildCommand( return makeCommands; } -///! Create a local generator appropriate to this Global Generator +//! Create a local generator appropriate to this Global Generator cmLocalGenerator* cmGlobalVisualStudio7Generator::CreateLocalGenerator( cmMakefile* mf) { diff --git a/Source/cmGlobalVisualStudio7Generator.h b/Source/cmGlobalVisualStudio7Generator.h index 954d1d3..1e76383 100644 --- a/Source/cmGlobalVisualStudio7Generator.h +++ b/Source/cmGlobalVisualStudio7Generator.h @@ -20,7 +20,7 @@ class cmGlobalVisualStudio7Generator : public cmGlobalVisualStudioGenerator public: ~cmGlobalVisualStudio7Generator(); - ///! Create a local generator appropriate to this Global Generator + //! Create a local generator appropriate to this Global Generator cmLocalGenerator* CreateLocalGenerator(cmMakefile* mf) override; #if defined(CMAKE_BUILD_WITH_CMAKE) @@ -64,7 +64,7 @@ public: */ virtual void OutputSLNFile(); - ///! Lookup a stored GUID or compute one deterministically. + //! Lookup a stored GUID or compute one deterministically. std::string GetGUID(std::string const& name); /** Append the subdirectory for the given configuration. */ @@ -73,7 +73,7 @@ public: const std::string& suffix, std::string& dir) override; - ///! What is the configurations directory variable called? + //! What is the configurations directory variable called? const char* GetCMakeCFGIntDir() const override { return "$(ConfigurationName)"; diff --git a/Source/cmGlobalVisualStudio8Generator.h b/Source/cmGlobalVisualStudio8Generator.h index 75f4778..352bc3c 100644 --- a/Source/cmGlobalVisualStudio8Generator.h +++ b/Source/cmGlobalVisualStudio8Generator.h @@ -13,7 +13,7 @@ class cmGlobalVisualStudio8Generator : public cmGlobalVisualStudio71Generator { public: - ///! Get the name for the generator. + //! Get the name for the generator. std::string GetName() const override { return this->Name; } /** Get the name of the main stamp list file. */ diff --git a/Source/cmGlobalWatcomWMakeGenerator.h b/Source/cmGlobalWatcomWMakeGenerator.h index c96dc72..3ca5e7d 100644 --- a/Source/cmGlobalWatcomWMakeGenerator.h +++ b/Source/cmGlobalWatcomWMakeGenerator.h @@ -29,7 +29,7 @@ public: { return new cmGlobalGeneratorSimpleFactory<cmGlobalWatcomWMakeGenerator>(); } - ///! Get the name for the generator. + //! Get the name for the generator. std::string GetName() const override { return cmGlobalWatcomWMakeGenerator::GetActualName(); diff --git a/Source/cmGlobalXCodeGenerator.cxx b/Source/cmGlobalXCodeGenerator.cxx index ad1a636..2fc6121 100644 --- a/Source/cmGlobalXCodeGenerator.cxx +++ b/Source/cmGlobalXCodeGenerator.cxx @@ -389,7 +389,7 @@ cmGlobalXCodeGenerator::GenerateBuildCommand( return { std::move(makeCommand) }; } -///! Create a local generator appropriate to this Global Generator +//! Create a local generator appropriate to this Global Generator cmLocalGenerator* cmGlobalXCodeGenerator::CreateLocalGenerator(cmMakefile* mf) { return new cmLocalXCodeGenerator(this, mf); @@ -1800,6 +1800,10 @@ void cmGlobalXCodeGenerator::CreateBuildSettings(cmGeneratorTarget* gtgt, this->CurrentLocalGenerator->AddLanguageFlags(flags, gtgt, lang, configName); + if (gtgt->IsIPOEnabled(lang, configName)) { + this->CurrentLocalGenerator->AppendFeatureOptions(flags, lang, "IPO"); + } + // Add shared-library flags if needed. this->CurrentLocalGenerator->AddCMP0018Flags(flags, gtgt, lang, configName); diff --git a/Source/cmGlobalXCodeGenerator.h b/Source/cmGlobalXCodeGenerator.h index 8daa95b..71446f9 100644 --- a/Source/cmGlobalXCodeGenerator.h +++ b/Source/cmGlobalXCodeGenerator.h @@ -36,7 +36,7 @@ public: unsigned int version_number); static cmGlobalGeneratorFactory* NewFactory(); - ///! Get the name for the generator. + //! Get the name for the generator. std::string GetName() const override { return cmGlobalXCodeGenerator::GetActualName(); @@ -46,7 +46,7 @@ public: /** Get the documentation entry for this generator. */ static void GetDocumentation(cmDocumentationEntry& entry); - ///! Create a local generator appropriate to this Global Generator + //! Create a local generator appropriate to this Global Generator cmLocalGenerator* CreateLocalGenerator(cmMakefile* mf) override; /** @@ -81,9 +81,9 @@ public: bool FindMakeProgram(cmMakefile*) override; - ///! What is the configurations directory variable called? + //! What is the configurations directory variable called? const char* GetCMakeCFGIntDir() const override; - ///! expand CFGIntDir + //! expand CFGIntDir std::string ExpandCFGIntDir(const std::string& str, const std::string& config) const override; diff --git a/Source/cmLoadCommandCommand.cxx b/Source/cmLoadCommandCommand.cxx index cd71518..69751b6 100644 --- a/Source/cmLoadCommandCommand.cxx +++ b/Source/cmLoadCommandCommand.cxx @@ -33,7 +33,7 @@ public: this->info.CAPI = &cmStaticCAPI; } - ///! clean up any memory allocated by the plugin + //! clean up any memory allocated by the plugin ~cmLoadedCommand() override; /** diff --git a/Source/cmLocalGenerator.cxx b/Source/cmLocalGenerator.cxx index 2c145e0..6337f07 100644 --- a/Source/cmLocalGenerator.cxx +++ b/Source/cmLocalGenerator.cxx @@ -1258,6 +1258,10 @@ void cmLocalGenerator::GetTargetCompileFlags(cmGeneratorTarget* target, // Add language-specific flags. this->AddLanguageFlags(flags, target, lang, config); + if (target->IsIPOEnabled(lang, config)) { + this->AppendFeatureOptions(flags, lang, "IPO"); + } + this->AddArchitectureFlags(flags, target, lang, config); if (lang == "Fortran") { @@ -1515,9 +1519,8 @@ void cmLocalGenerator::AddLanguageFlags(std::string& flags, flagsVar += "_FLAGS"; this->AddConfigVariableFlags(flags, flagsVar, config); - if (target->IsIPOEnabled(lang, config)) { - this->AppendFeatureOptions(flags, lang, "IPO"); - } + // Placeholder for possible future per-target flags. + static_cast<void>(target); } void cmLocalGenerator::AddLanguageFlagsForLinking( @@ -1534,6 +1537,10 @@ void cmLocalGenerator::AddLanguageFlagsForLinking( } this->AddLanguageFlags(flags, target, lang, config); + + if (target->IsIPOEnabled(lang, config)) { + this->AppendFeatureOptions(flags, lang, "IPO"); + } } cmGeneratorTarget* cmLocalGenerator::FindGeneratorTargetToUse( @@ -2266,7 +2273,7 @@ void cmLocalGenerator::JoinDefines(const std::set<std::string>& defines, def += define.substr(0, eq); if (eq != std::string::npos) { def += "="; - def += this->EscapeForShell(define.c_str() + eq + 1, true); + def += this->EscapeForShell(define.substr(eq + 1), true); } } definesString += itemSeparator; diff --git a/Source/cmLocalGenerator.h b/Source/cmLocalGenerator.h index de12190..67e3c58 100644 --- a/Source/cmLocalGenerator.h +++ b/Source/cmLocalGenerator.h @@ -76,13 +76,13 @@ public: bool IsRootMakefile() const; - ///! Get the makefile for this generator + //! Get the makefile for this generator cmMakefile* GetMakefile() { return this->Makefile; } - ///! Get the makefile for this generator, const version + //! Get the makefile for this generator, const version const cmMakefile* GetMakefile() const { return this->Makefile; } - ///! Get the GlobalGenerator this is associated with + //! Get the GlobalGenerator this is associated with cmGlobalGenerator* GetGlobalGenerator() { return this->GlobalGenerator; } const cmGlobalGenerator* GetGlobalGenerator() const { @@ -118,7 +118,7 @@ public: void AddCompilerRequirementFlag(std::string& flags, cmGeneratorTarget const* target, const std::string& lang); - ///! Append flags to a string. + //! Append flags to a string. virtual void AppendFlags(std::string& flags, const std::string& newFlags) const; virtual void AppendFlags(std::string& flags, const char* newFlags) const; @@ -131,7 +131,7 @@ public: cmGeneratorTarget* target, const std::string& config, const std::string& lang); - ///! Get the include flags for the current makefile and language + //! Get the include flags for the current makefile and language std::string GetIncludeFlags(const std::vector<std::string>& includes, cmGeneratorTarget* target, const std::string& lang, @@ -403,7 +403,7 @@ public: const std::string& prop); protected: - ///! put all the libraries for a target on into the given stream + //! put all the libraries for a target on into the given stream void OutputLinkLibraries(cmComputeLinkInformation* pcli, cmLinkLineComputer* linkLineComputer, std::string& linkLibraries, 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/cmLocalVisualStudio10Generator.h b/Source/cmLocalVisualStudio10Generator.h index a4150b9..5c6400e 100644 --- a/Source/cmLocalVisualStudio10Generator.h +++ b/Source/cmLocalVisualStudio10Generator.h @@ -21,7 +21,7 @@ class cmMakefile; class cmLocalVisualStudio10Generator : public cmLocalVisualStudio7Generator { public: - ///! Set cache only and recurse to false by default. + //! Set cache only and recurse to false by default. cmLocalVisualStudio10Generator(cmGlobalGenerator* gg, cmMakefile* mf); virtual ~cmLocalVisualStudio10Generator(); diff --git a/Source/cmLocalVisualStudio7Generator.cxx b/Source/cmLocalVisualStudio7Generator.cxx index e519d78..7ba3471 100644 --- a/Source/cmLocalVisualStudio7Generator.cxx +++ b/Source/cmLocalVisualStudio7Generator.cxx @@ -662,14 +662,7 @@ void cmLocalVisualStudio7Generator::WriteConfiguration( langForClCompile = linkLanguage; if (langForClCompile == "C" || langForClCompile == "CXX" || langForClCompile == "Fortran") { - std::string baseFlagVar = "CMAKE_"; - baseFlagVar += langForClCompile; - baseFlagVar += "_FLAGS"; - flags = this->Makefile->GetRequiredDefinition(baseFlagVar); - std::string flagVar = - baseFlagVar + std::string("_") + cmSystemTools::UpperCase(configName); - flags += " "; - flags += this->Makefile->GetRequiredDefinition(flagVar); + this->AddLanguageFlags(flags, target, langForClCompile, configName); } // set the correct language if (linkLanguage == "C") { diff --git a/Source/cmLocalVisualStudio7Generator.h b/Source/cmLocalVisualStudio7Generator.h index b093e6f..ce8eceb 100644 --- a/Source/cmLocalVisualStudio7Generator.h +++ b/Source/cmLocalVisualStudio7Generator.h @@ -43,7 +43,7 @@ public: class cmLocalVisualStudio7Generator : public cmLocalVisualStudioGenerator { public: - ///! Set cache only and recurse to false by default. + //! Set cache only and recurse to false by default. cmLocalVisualStudio7Generator(cmGlobalGenerator* gg, cmMakefile* mf); virtual ~cmLocalVisualStudio7Generator(); diff --git a/Source/cmLocalXCodeGenerator.h b/Source/cmLocalXCodeGenerator.h index 5c22dcf..42de20b 100644 --- a/Source/cmLocalXCodeGenerator.h +++ b/Source/cmLocalXCodeGenerator.h @@ -24,7 +24,7 @@ class cmSourceFile; class cmLocalXCodeGenerator : public cmLocalGenerator { public: - ///! Set cache only and recurse to false by default. + //! Set cache only and recurse to false by default. cmLocalXCodeGenerator(cmGlobalGenerator* gg, cmMakefile* mf); ~cmLocalXCodeGenerator() override; diff --git a/Source/cmMakefile.h b/Source/cmMakefile.h index 88b4c2f..8cc14f3 100644 --- a/Source/cmMakefile.h +++ b/Source/cmMakefile.h @@ -257,7 +257,7 @@ public: * can be used in CMake to refer to lists, directories, etc. */ void AddDefinition(const std::string& name, const char* value); - ///! Add a definition to this makefile and the global cmake cache. + //! Add a definition to this makefile and the global cmake cache. void AddCacheDefinition(const std::string& name, const char* value, const char* doc, cmStateEnums::CacheEntryType type, bool force = false); @@ -272,7 +272,7 @@ public: * for cache entries, and will only affect the current makefile. */ void RemoveDefinition(const std::string& name); - ///! Remove a definition from the cache. + //! Remove a definition from the cache. void RemoveCacheDefinition(const std::string& name); /** @@ -548,7 +548,7 @@ public: { return this->ListFiles; } - ///! When the file changes cmake will be re-run from the build system. + //! When the file changes cmake will be re-run from the build system. void AddCMakeDependFile(const std::string& file) { this->ListFiles.push_back(file); @@ -626,7 +626,7 @@ public: bool ExecuteCommand(const cmListFileFunction& lff, cmExecutionStatus& status); - ///! Enable support for named language, if nil then all languages are + //! Enable support for named language, if nil then all languages are /// enabled. void EnableLanguage(std::vector<std::string> const& languages, bool optional); @@ -641,7 +641,7 @@ public: cmVariableWatch* GetVariableWatch() const; #endif - ///! Display progress or status message. + //! Display progress or status message. void DisplayStatus(const std::string&, float) const; /** @@ -677,7 +677,7 @@ public: */ cmSourceFile* GetSourceFileWithOutput(const std::string& outName) const; - ///! Add a new cmTest to the list of tests for this makefile. + //! Add a new cmTest to the list of tests for this makefile. cmTest* CreateTest(const std::string& testName); /** Get a cmTest pointer for a given test name, if the name is @@ -701,7 +701,7 @@ public: std::string GetModulesFile(const std::string& name, bool& system) const; - ///! Set/Get a property of this directory + //! Set/Get a property of this directory void SetProperty(const std::string& prop, const char* value); void AppendProperty(const std::string& prop, const char* value, bool asString = false); @@ -710,7 +710,7 @@ public: bool GetPropertyAsBool(const std::string& prop) const; std::vector<std::string> GetPropertyKeys() const; - ///! Initialize a makefile from its parent + //! Initialize a makefile from its parent void InitializeFromParent(cmMakefile* parent); void AddInstallGenerator(cmInstallGenerator* g) diff --git a/Source/cmOutputConverter.h b/Source/cmOutputConverter.h index 6438c7b..deca767 100644 --- a/Source/cmOutputConverter.h +++ b/Source/cmOutputConverter.h @@ -27,7 +27,7 @@ public: std::string ConvertDirectorySeparatorsForShell( const std::string& source) const; - ///! for existing files convert to output path and short path if spaces + //! for existing files convert to output path and short path if spaces std::string ConvertToOutputForExisting(const std::string& remote, OutputFormat format = SHELL) const; diff --git a/Source/cmPolicies.cxx b/Source/cmPolicies.cxx index 0a234c5..61b2fda 100644 --- a/Source/cmPolicies.cxx +++ b/Source/cmPolicies.cxx @@ -299,7 +299,7 @@ bool cmPolicies::GetPolicyID(const char* id, cmPolicies::PolicyID& pid) return stringToId(id, pid); } -///! return a warning string for a given policy +//! return a warning string for a given policy std::string cmPolicies::GetPolicyWarning(cmPolicies::PolicyID id) { std::ostringstream msg; @@ -333,7 +333,7 @@ std::string cmPolicies::GetPolicyDeprecatedWarning(cmPolicies::PolicyID id) return msg.str(); } -///! return an error string for when a required policy is unspecified +//! return an error string for when a required policy is unspecified std::string cmPolicies::GetRequiredPolicyError(cmPolicies::PolicyID id) { std::ostringstream error; @@ -359,7 +359,7 @@ std::string cmPolicies::GetRequiredPolicyError(cmPolicies::PolicyID id) return error.str(); } -///! Get the default status for a policy +//! Get the default status for a policy cmPolicies::PolicyStatus cmPolicies::GetPolicyStatus( cmPolicies::PolicyID /*unused*/) { diff --git a/Source/cmPolicies.h b/Source/cmPolicies.h index 7677186..02a6295 100644 --- a/Source/cmPolicies.h +++ b/Source/cmPolicies.h @@ -332,27 +332,27 @@ public: CMPCOUNT }; - ///! convert a string policy ID into a number + //! convert a string policy ID into a number static bool GetPolicyID(const char* id, /* out */ cmPolicies::PolicyID& pid); - ///! Get the default status for a policy + //! Get the default status for a policy static cmPolicies::PolicyStatus GetPolicyStatus(cmPolicies::PolicyID id); - ///! Set a policy level for this listfile + //! Set a policy level for this listfile static bool ApplyPolicyVersion(cmMakefile* mf, std::string const& version_min, std::string const& version_max); static bool ApplyPolicyVersion(cmMakefile* mf, unsigned int majorVer, unsigned int minorVer, unsigned int patchVer); - ///! return a warning string for a given policy + //! return a warning string for a given policy static std::string GetPolicyWarning(cmPolicies::PolicyID id); static std::string GetPolicyDeprecatedWarning(cmPolicies::PolicyID id); - ///! return an error string for when a required policy is unspecified + //! return an error string for when a required policy is unspecified static std::string GetRequiredPolicyError(cmPolicies::PolicyID id); - ///! return an error string for when a required policy is unspecified + //! return an error string for when a required policy is unspecified static std::string GetRequiredAlwaysPolicyError(cmPolicies::PolicyID id); /** Represent a set of policy values. */ diff --git a/Source/cmProjectCommand.cxx b/Source/cmProjectCommand.cxx index 2fe9fe8..de5d1ed 100644 --- a/Source/cmProjectCommand.cxx +++ b/Source/cmProjectCommand.cxx @@ -319,21 +319,41 @@ bool cmProjectCommand::InitialPass(std::vector<std::string> const& args, languages.emplace_back("CXX"); } this->Makefile->EnableLanguage(languages, false); - std::string extraInclude = "CMAKE_PROJECT_" + projectName + "_INCLUDE"; - const char* include = this->Makefile->GetDefinition(extraInclude); - if (include) { - bool readit = this->Makefile->ReadDependentFile(include); - if (!readit && !cmSystemTools::GetFatalErrorOccured()) { - std::string m = "could not find file:\n" - " "; - m += include; - this->SetError(m); - return false; - } + + if (!this->IncludeByVariable("CMAKE_PROJECT_INCLUDE")) { + return false; + } + + if (!this->IncludeByVariable("CMAKE_PROJECT_" + projectName + "_INCLUDE")) { + return false; } + return true; } +bool cmProjectCommand::IncludeByVariable(const std::string& variable) +{ + const char* include = this->Makefile->GetDefinition(variable); + if (!include) { + return true; + } + + const bool readit = this->Makefile->ReadDependentFile(include); + if (readit) { + return true; + } + + if (cmSystemTools::GetFatalErrorOccured()) { + return true; + } + + std::string m = "could not find file:\n" + " "; + m += include; + this->SetError(m); + return false; +} + void cmProjectCommand::TopLevelCMakeVarCondSet(const char* const name, const char* const value) { diff --git a/Source/cmProjectCommand.h b/Source/cmProjectCommand.h index 365d448..f1d03e7 100644 --- a/Source/cmProjectCommand.h +++ b/Source/cmProjectCommand.h @@ -36,6 +36,7 @@ public: cmExecutionStatus& status) override; private: + bool IncludeByVariable(const std::string& variable); void TopLevelCMakeVarCondSet(const char* name, const char* value); }; diff --git a/Source/cmSourceFile.h b/Source/cmSourceFile.h index d579018..edad4c7 100644 --- a/Source/cmSourceFile.h +++ b/Source/cmSourceFile.h @@ -44,13 +44,13 @@ public: cmCustomCommand const* GetCustomCommand() const; void SetCustomCommand(cmCustomCommand* cc); - ///! Set/Get a property of this source file + //! Set/Get a property of this source file void SetProperty(const std::string& prop, const char* value); void AppendProperty(const std::string& prop, const char* value, bool asString = false); - ///! Might return a nullptr if the property is not set or invalid + //! Might return a nullptr if the property is not set or invalid const char* GetProperty(const std::string& prop) const; - ///! Always returns a valid pointer + //! Always returns a valid pointer const char* GetSafeProperty(const std::string& prop) const; bool GetPropertyAsBool(const std::string& prop) const; @@ -58,7 +58,7 @@ public: command like get_property or get_source_file_property. */ const char* GetPropertyForUser(const std::string& prop); - ///! Checks is the GENERATED property is set and true + //! Checks is the GENERATED property is set and true /// @return Equivalent to GetPropertyAsBool("GENERATED") bool GetIsGenerated() const { return this->IsGenerated; } diff --git a/Source/cmState.h b/Source/cmState.h index 190eafc..6abe71c 100644 --- a/Source/cmState.h +++ b/Source/cmState.h @@ -107,7 +107,7 @@ public: void RemoveCacheEntryProperty(std::string const& key, std::string const& propertyName); - ///! Break up a line like VAR:type="value" into var, type and value + //! Break up a line like VAR:type="value" into var, type and value static bool ParseCacheEntry(const std::string& entry, std::string& var, std::string& value, cmStateEnums::CacheEntryType& type); diff --git a/Source/cmSystemTools.h b/Source/cmSystemTools.h index 0b75025..a8b2d37 100644 --- a/Source/cmSystemTools.h +++ b/Source/cmSystemTools.h @@ -45,7 +45,7 @@ public: static void ExpandRegistryValues(std::string& source, KeyWOW64 view = KeyWOW64_Default); - ///! Escape quotes in a string. + //! Escape quotes in a string. static std::string EscapeQuotes(const std::string& str); /** Map help document name to file name. */ @@ -78,11 +78,11 @@ public: using OutputCallback = std::function<void(std::string const&)>; - ///! Send a string to stdout + //! Send a string to stdout static void Stdout(const std::string& s); static void SetStdoutCallback(OutputCallback f); - ///! Send a string to stderr + //! Send a string to stderr static void Stderr(const std::string& s); static void SetStderrCallback(OutputCallback f); @@ -90,25 +90,25 @@ public: static void SetInterruptCallback(InterruptCallback f); static bool GetInterruptFlag(); - ///! Return true if there was an error at any point. + //! Return true if there was an error at any point. static bool GetErrorOccuredFlag() { return cmSystemTools::s_ErrorOccured || cmSystemTools::s_FatalErrorOccured || GetInterruptFlag(); } - ///! If this is set to true, cmake stops processing commands. + //! If this is set to true, cmake stops processing commands. static void SetFatalErrorOccured() { cmSystemTools::s_FatalErrorOccured = true; } static void SetErrorOccured() { cmSystemTools::s_ErrorOccured = true; } - ///! Return true if there was an error at any point. + //! Return true if there was an error at any point. static bool GetFatalErrorOccured() { return cmSystemTools::s_FatalErrorOccured || GetInterruptFlag(); } - ///! Set the error occurred flag and fatal error back to false + //! Set the error occurred flag and fatal error back to false static void ResetErrorOccuredFlag() { cmSystemTools::s_FatalErrorOccured = false; @@ -138,9 +138,9 @@ public: static bool IsOff(const char* val); static bool IsOff(const std::string& val); - ///! Return true if value is NOTFOUND or ends in -NOTFOUND. + //! Return true if value is NOTFOUND or ends in -NOTFOUND. static bool IsNOTFOUND(const char* value); - ///! Return true if the path is a framework + //! Return true if the path is a framework static bool IsPathToFramework(const std::string& value); static bool DoesFileExistWithExtensions( @@ -177,14 +177,14 @@ public: static bool RenameFile(const std::string& oldname, const std::string& newname); - ///! Compute the hash of a file + //! Compute the hash of a file static std::string ComputeFileHash(const std::string& source, cmCryptoHash::Algo algo); /** Compute the md5sum of a string. */ static std::string ComputeStringMD5(const std::string& input); - ///! Get the SHA thumbprint for a certificate file + //! Get the SHA thumbprint for a certificate file static std::string ComputeCertificateThumbprint(const std::string& source); /** diff --git a/Source/cmTarget.cxx b/Source/cmTarget.cxx index 38bff1b..dc9b6d2 100644 --- a/Source/cmTarget.cxx +++ b/Source/cmTarget.cxx @@ -34,7 +34,7 @@ #include "cmTargetPropertyComputer.h" #include "cmake.h" -///! Append all elements from the second container to the first container +//! Append all elements from the second container to the first container template <class C, class R> static inline void CApp(C& container, R const& range) { diff --git a/Source/cmTarget.h b/Source/cmTarget.h index 5d90ba7..0ac5ca7 100644 --- a/Source/cmTarget.h +++ b/Source/cmTarget.h @@ -59,22 +59,22 @@ public: cmTarget& operator=(cmTarget const&) = delete; cmTarget& operator=(cmTarget&&) noexcept; - ///! Return the type of target. + //! Return the type of target. cmStateEnums::TargetType GetType() const; - ///! Get the cmMakefile that owns this target. + //! Get the cmMakefile that owns this target. cmMakefile* GetMakefile() const; - ///! Return the global generator. + //! Return the global generator. cmGlobalGenerator* GetGlobalGenerator() const; - ///! Set/Get the name of the target + //! Set/Get the name of the target const std::string& GetName() const; - ///! Get the policy map + //! Get the policy map cmPolicies::PolicyMap const& GetPolicyMap() const; - ///! Get policy status + //! Get policy status cmPolicies::PolicyStatus GetPolicyStatus(cmPolicies::PolicyID policy) const; #define DECLARE_TARGET_POLICY(POLICY) \ @@ -87,30 +87,30 @@ public: #undef DECLARE_TARGET_POLICY - ///! Get the list of the PRE_BUILD custom commands for this target + //! Get the list of the PRE_BUILD custom commands for this target std::vector<cmCustomCommand> const& GetPreBuildCommands() const; void AddPreBuildCommand(cmCustomCommand const& cmd); - ///! Get the list of the PRE_LINK custom commands for this target + //! Get the list of the PRE_LINK custom commands for this target std::vector<cmCustomCommand> const& GetPreLinkCommands() const; void AddPreLinkCommand(cmCustomCommand const& cmd); - ///! Get the list of the POST_BUILD custom commands for this target + //! Get the list of the POST_BUILD custom commands for this target std::vector<cmCustomCommand> const& GetPostBuildCommands() const; void AddPostBuildCommand(cmCustomCommand const& cmd); - ///! Add sources to the target. + //! Add sources to the target. void AddSources(std::vector<std::string> const& srcs); void AddTracedSources(std::vector<std::string> const& srcs); cmSourceFile* AddSourceCMP0049(const std::string& src); cmSourceFile* AddSource(const std::string& src, bool before = false); - ///! how we identify a library, by name and type + //! how we identify a library, by name and type typedef std::pair<std::string, cmTargetLinkLibraryType> LibraryID; typedef std::vector<LibraryID> LinkLibraryVectorType; LinkLibraryVectorType const& GetOriginalLinkLibraries() const; - ///! Clear the dependency information recorded for this target, if any. + //! Clear the dependency information recorded for this target, if any. void ClearDependencyInformation(cmMakefile& mf); void AddLinkLibrary(cmMakefile& mf, const std::string& lib, @@ -159,23 +159,23 @@ public: * commands. It is not a full path nor does it have an extension. */ void AddUtility(std::string const& name, cmMakefile* mf = nullptr); - ///! Get the utilities used by this target + //! Get the utilities used by this target std::set<BT<std::string>> const& GetUtilities() const; - ///! Set/Get a property of this target file + //! Set/Get a property of this target file void SetProperty(const std::string& prop, const char* value); void AppendProperty(const std::string& prop, const char* value, bool asString = false); - ///! Might return a nullptr if the property is not set or invalid + //! Might return a nullptr if the property is not set or invalid const char* GetProperty(const std::string& prop) const; - ///! Always returns a valid pointer + //! Always returns a valid pointer const char* GetSafeProperty(const std::string& prop) const; bool GetPropertyAsBool(const std::string& prop) const; void CheckProperty(const std::string& prop, cmMakefile* context) const; const char* GetComputedProperty(const std::string& prop, cmMessenger* messenger, cmListFileBacktrace const& context) const; - ///! Get all properties + //! Get all properties cmPropertyMap const& GetProperties() const; bool IsImported() const; @@ -184,16 +184,16 @@ public: bool GetMappedConfig(std::string const& desired_config, const char** loc, const char** imp, std::string& suffix) const; - ///! Return whether this target is an executable with symbol exports enabled. + //! Return whether this target is an executable with symbol exports enabled. bool IsExecutableWithExports() const; - ///! Return whether this target is a shared library Framework on Apple. + //! Return whether this target is a shared library Framework on Apple. bool IsFrameworkOnApple() const; - ///! Return whether this target is an executable Bundle on Apple. + //! Return whether this target is an executable Bundle on Apple. bool IsAppBundleOnApple() const; - ///! Get a backtrace from the creation of the target. + //! Get a backtrace from the creation of the target. cmListFileBacktrace const& GetBacktrace() const; void InsertInclude(std::string const& entry, cmListFileBacktrace const& bt, diff --git a/Source/cmTargetPropertyComputer.h b/Source/cmTargetPropertyComputer.h index 97e4fba..efbf95f 100644 --- a/Source/cmTargetPropertyComputer.h +++ b/Source/cmTargetPropertyComputer.h @@ -81,7 +81,7 @@ private: context)) { return nullptr; } - const char* configName = prop.c_str() + 9; + std::string configName = prop.substr(9); return ComputeLocation(tgt, configName); } diff --git a/Source/cmTest.h b/Source/cmTest.h index d4839d1..88dc730 100644 --- a/Source/cmTest.h +++ b/Source/cmTest.h @@ -26,14 +26,14 @@ public: cmTest(cmMakefile* mf); ~cmTest(); - ///! Set the test name + //! Set the test name void SetName(const std::string& name); std::string GetName() const { return this->Name; } void SetCommand(std::vector<std::string> const& command); std::vector<std::string> const& GetCommand() const { return this->Command; } - ///! Set/Get a property of this source file + //! Set/Get a property of this source file void SetProperty(const std::string& prop, const char* value); void AppendProperty(const std::string& prop, const char* value, bool asString = false); diff --git a/Source/cmVisualStudio10TargetGenerator.cxx b/Source/cmVisualStudio10TargetGenerator.cxx index 8804e6c..5195957 100644 --- a/Source/cmVisualStudio10TargetGenerator.cxx +++ b/Source/cmVisualStudio10TargetGenerator.cxx @@ -2540,14 +2540,8 @@ bool cmVisualStudio10TargetGenerator::ComputeClOptions( } this->LangForClCompile = langForClCompile; if (!langForClCompile.empty()) { - std::string baseFlagVar = "CMAKE_"; - baseFlagVar += langForClCompile; - baseFlagVar += "_FLAGS"; - flags = this->Makefile->GetRequiredDefinition(baseFlagVar); - std::string flagVar = - baseFlagVar + "_" + cmSystemTools::UpperCase(configName); - flags += " "; - flags += this->Makefile->GetRequiredDefinition(flagVar); + this->LocalGenerator->AddLanguageFlags(flags, this->GeneratorTarget, + langForClCompile, configName); this->LocalGenerator->AddCompileOptions(flags, this->GeneratorTarget, langForClCompile, configName); } 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/Source/cmake.h b/Source/cmake.h index 8d22f34..8b4b396 100644 --- a/Source/cmake.h +++ b/Source/cmake.h @@ -162,7 +162,7 @@ public: int Configure(); int ActualConfigure(); - ///! Break up a line like VAR:type="value" into var, type and value + //! Break up a line like VAR:type="value" into var, type and value static bool ParseCacheEntry(const std::string& entry, std::string& var, std::string& value, cmStateEnums::CacheEntryType& type); @@ -176,40 +176,40 @@ public: bool DeleteCache(const std::string& path); void PreLoadCMakeFiles(); - ///! Create a GlobalGenerator + //! Create a GlobalGenerator cmGlobalGenerator* CreateGlobalGenerator(const std::string& name); - ///! Return the global generator assigned to this instance of cmake + //! Return the global generator assigned to this instance of cmake cmGlobalGenerator* GetGlobalGenerator() { return this->GlobalGenerator; } - ///! Return the global generator assigned to this instance of cmake, const + //! Return the global generator assigned to this instance of cmake, const const cmGlobalGenerator* GetGlobalGenerator() const { return this->GlobalGenerator; } - ///! Return the full path to where the CMakeCache.txt file should be. + //! Return the full path to where the CMakeCache.txt file should be. static std::string FindCacheFile(const std::string& binaryDir); - ///! Return the global generator assigned to this instance of cmake + //! Return the global generator assigned to this instance of cmake void SetGlobalGenerator(cmGlobalGenerator*); - ///! Get the names of the current registered generators + //! Get the names of the current registered generators void GetRegisteredGenerators(std::vector<GeneratorInfo>& generators, bool includeNamesWithPlatform = true) const; - ///! Set the name of the selected generator-specific instance. + //! Set the name of the selected generator-specific instance. void SetGeneratorInstance(std::string const& instance) { this->GeneratorInstance = instance; } - ///! Set the name of the selected generator-specific platform. + //! Set the name of the selected generator-specific platform. void SetGeneratorPlatform(std::string const& ts) { this->GeneratorPlatform = ts; } - ///! Set the name of the selected generator-specific toolset. + //! Set the name of the selected generator-specific toolset. void SetGeneratorToolset(std::string const& ts) { this->GeneratorToolset = ts; @@ -244,7 +244,7 @@ public: * Given a variable name, return its value (as a string). */ const char* GetCacheDefinition(const std::string&) const; - ///! Add an entry into the cache + //! Add an entry into the cache void AddCacheEntry(const std::string& key, const char* value, const char* helpString, int type); @@ -263,14 +263,14 @@ public: */ int GetSystemInformation(std::vector<std::string>&); - ///! Parse command line arguments + //! Parse command line arguments void SetArgs(const std::vector<std::string>& args); - ///! Is this cmake running as a result of a TRY_COMPILE command + //! Is this cmake running as a result of a TRY_COMPILE command bool GetIsInTryCompile() const; void SetIsInTryCompile(bool b); - ///! Parse command line arguments that might set cache values + //! Parse command line arguments that might set cache values bool SetCacheArgs(const std::vector<std::string>&); using ProgressCallbackType = std::function<void(const std::string&, float)>; @@ -283,24 +283,24 @@ public: */ void SetProgressCallback(ProgressCallbackType f); - ///! this is called by generators to update the progress + //! this is called by generators to update the progress void UpdateProgress(const std::string& msg, float prog); #if defined(CMAKE_BUILD_WITH_CMAKE) - ///! Get the variable watch object + //! Get the variable watch object cmVariableWatch* GetVariableWatch() { return this->VariableWatch; } #endif std::vector<cmDocumentationEntry> GetGeneratorsDocumentation(); - ///! Set/Get a property of this target file + //! Set/Get a property of this target file void SetProperty(const std::string& prop, const char* value); void AppendProperty(const std::string& prop, const char* value, bool asString = false); const char* GetProperty(const std::string& prop); bool GetPropertyAsBool(const std::string& prop); - ///! Get or create an cmInstalledFile instance and return a pointer to it + //! Get or create an cmInstalledFile instance and return a pointer to it cmInstalledFile* GetOrCreateInstalledFile(cmMakefile* mf, const std::string& name); @@ -311,13 +311,13 @@ public: return this->InstalledFiles; } - ///! Do all the checks before running configure + //! Do all the checks before running configure int DoPreConfigureChecks(); void SetWorkingMode(WorkingMode mode) { this->CurrentWorkingMode = mode; } WorkingMode GetWorkingMode() { return this->CurrentWorkingMode; } - ///! Debug the try compile stuff by not deleting the files + //! Debug the try compile stuff by not deleting the files bool GetDebugTryCompile() { return this->DebugTryCompile; } void DebugTryCompileOn() { this->DebugTryCompile = true; } @@ -423,13 +423,13 @@ public: MessageType t, std::string const& text, cmListFileBacktrace const& backtrace = cmListFileBacktrace()) const; - ///! run the --build option + //! run the --build option int Build(int jobs, const std::string& dir, const std::vector<std::string>& targets, const std::string& config, const std::vector<std::string>& nativeOptions, bool clean, bool verbose); - ///! run the --open option + //! run the --open option bool Open(const std::string& dir, bool dryRun); void UnwatchUnusedCli(const std::string& var); @@ -462,12 +462,12 @@ protected: std::string GeneratorPlatform; std::string GeneratorToolset; - ///! read in a cmake list file to initialize the cache + //! read in a cmake list file to initialize the cache void ReadListFile(const std::vector<std::string>& args, const std::string& path); bool FindPackage(const std::vector<std::string>& args); - ///! Check if CMAKE_CACHEFILE_DIR is set. If it is not, delete the log file. + //! Check if CMAKE_CACHEFILE_DIR is set. If it is not, delete the log file. /// If it is set, truncate it to 50kb void TruncateOutputLog(const char* fname); diff --git a/Source/cmcmd.cxx b/Source/cmcmd.cxx index 8d63971..cf9f064 100644 --- a/Source/cmcmd.cxx +++ b/Source/cmcmd.cxx @@ -368,7 +368,7 @@ struct CoCompileJob }; // called when args[0] == "__run_co_compile" -int cmcmd::HandleCoCompileCommands(std::vector<std::string>& args) +int cmcmd::HandleCoCompileCommands(std::vector<std::string> const& args) { std::vector<CoCompileJob> jobs; std::string sourceFile; // store --source= @@ -381,8 +381,7 @@ int cmcmd::HandleCoCompileCommands(std::vector<std::string>& args) std::vector<std::string> orig_cmd; bool doing_options = true; - for (std::string::size_type i = 2; i < args.size(); ++i) { - std::string const& arg = args[i]; + for (std::string const& arg : cmMakeRange(args).advance(2)) { // if the arg is -- then the rest of the args after // go into orig_cmd if (arg == "--") { @@ -466,7 +465,7 @@ int cmcmd::HandleCoCompileCommands(std::vector<std::string>& args) return ret; } -int cmcmd::ExecuteCMakeCommand(std::vector<std::string>& args) +int cmcmd::ExecuteCMakeCommand(std::vector<std::string> const& args) { // IF YOU ADD A NEW COMMAND, DOCUMENT IT ABOVE and in cmakemain.cxx if (args.size() > 1) { @@ -482,9 +481,9 @@ int cmcmd::ExecuteCMakeCommand(std::vector<std::string>& args) } // If error occurs we want to continue copying next files. bool return_value = false; - for (std::string::size_type cc = 2; cc < args.size() - 1; cc++) { - if (!cmsys::SystemTools::CopyFileAlways(args[cc], args.back())) { - std::cerr << "Error copying file \"" << args[cc] << "\" to \"" + for (auto const& arg : cmMakeRange(args).advance(2).retreat(1)) { + if (!cmsys::SystemTools::CopyFileAlways(arg, args.back())) { + std::cerr << "Error copying file \"" << arg << "\" to \"" << args.back() << "\".\n"; return_value = true; } @@ -504,9 +503,9 @@ int cmcmd::ExecuteCMakeCommand(std::vector<std::string>& args) } // If error occurs we want to continue copying next files. bool return_value = false; - for (std::string::size_type cc = 2; cc < args.size() - 1; cc++) { - if (!cmSystemTools::CopyFileIfDifferent(args[cc], args.back())) { - std::cerr << "Error copying file (if different) from \"" << args[cc] + for (auto const& arg : cmMakeRange(args).advance(2).retreat(1)) { + if (!cmSystemTools::CopyFileIfDifferent(arg, args.back())) { + std::cerr << "Error copying file (if different) from \"" << arg << "\" to \"" << args.back() << "\".\n"; return_value = true; } @@ -518,10 +517,10 @@ int cmcmd::ExecuteCMakeCommand(std::vector<std::string>& args) if (args[1] == "copy_directory" && args.size() > 3) { // If error occurs we want to continue copying next files. bool return_value = false; - for (std::string::size_type cc = 2; cc < args.size() - 1; cc++) { - if (!cmSystemTools::CopyADirectory(args[cc], args.back())) { - std::cerr << "Error copying directory from \"" << args[cc] - << "\" to \"" << args.back() << "\".\n"; + for (auto const& arg : cmMakeRange(args).advance(2).retreat(1)) { + if (!cmSystemTools::CopyADirectory(arg, args.back())) { + std::cerr << "Error copying directory from \"" << arg << "\" to \"" + << args.back() << "\".\n"; return_value = true; } } @@ -614,13 +613,13 @@ int cmcmd::ExecuteCMakeCommand(std::vector<std::string>& args) } if (args[1] == "env") { - std::vector<std::string>::const_iterator ai = args.begin() + 2; - std::vector<std::string>::const_iterator ae = args.end(); + auto ai = args.cbegin() + 2; + auto ae = args.cend(); for (; ai != ae; ++ai) { std::string const& a = *ai; if (cmHasLiteralPrefix(a, "--unset=")) { // Unset environment variable. - cmSystemTools::UnPutEnv(a.c_str() + 8); + cmSystemTools::UnPutEnv(a.substr(8)); } else if (!a.empty() && a[0] == '-') { // Environment variable and command names cannot start in '-', // so this must be an unknown option. @@ -654,10 +653,8 @@ int cmcmd::ExecuteCMakeCommand(std::vector<std::string>& args) #if defined(CMAKE_BUILD_WITH_CMAKE) if (args[1] == "environment") { - std::vector<std::string> env = cmSystemTools::GetEnvironmentVariables(); - std::vector<std::string>::iterator it; - for (it = env.begin(); it != env.end(); ++it) { - std::cout << *it << std::endl; + for (auto const& env : cmSystemTools::GetEnvironmentVariables()) { + std::cout << env << std::endl; } return 0; } @@ -666,9 +663,9 @@ int cmcmd::ExecuteCMakeCommand(std::vector<std::string>& args) if (args[1] == "make_directory" && args.size() > 2) { // If error occurs we want to continue copying next files. bool return_value = false; - for (std::string::size_type cc = 2; cc < args.size(); cc++) { - if (!cmSystemTools::MakeDirectory(args[cc])) { - std::cerr << "Error creating directory \"" << args[cc] << "\".\n"; + for (auto const& arg : cmMakeRange(args).advance(2)) { + if (!cmSystemTools::MakeDirectory(arg)) { + std::cerr << "Error creating directory \"" << arg << "\".\n"; return_value = true; } } @@ -687,14 +684,14 @@ int cmcmd::ExecuteCMakeCommand(std::vector<std::string>& args) // Remove file if (args[1] == "remove" && args.size() > 2) { bool force = false; - for (std::string::size_type cc = 2; cc < args.size(); cc++) { - if (args[cc] == "\\-f" || args[cc] == "-f") { + for (auto const& arg : cmMakeRange(args).advance(2)) { + if (arg == "\\-f" || arg == "-f") { force = true; } else { // Complain if the file could not be removed, still exists, // and the -f option was not given. - if (!cmSystemTools::RemoveFile(args[cc]) && !force && - cmSystemTools::FileExists(args[cc])) { + if (!cmSystemTools::RemoveFile(arg) && !force && + cmSystemTools::FileExists(arg)) { return 1; } } @@ -704,10 +701,10 @@ int cmcmd::ExecuteCMakeCommand(std::vector<std::string>& args) // Touch file if (args[1] == "touch" && args.size() > 2) { - for (std::string::size_type cc = 2; cc < args.size(); cc++) { - if (!cmSystemTools::Touch(args[cc], true)) { + for (auto const& arg : cmMakeRange(args).advance(2)) { + if (!cmSystemTools::Touch(arg, true)) { std::cerr << "cmake -E touch: failed to update \""; - std::cerr << args[cc] << "\".\n"; + std::cerr << arg << "\".\n"; return 1; } } @@ -716,10 +713,10 @@ int cmcmd::ExecuteCMakeCommand(std::vector<std::string>& args) // Touch file if (args[1] == "touch_nocreate" && args.size() > 2) { - for (std::string::size_type cc = 2; cc < args.size(); cc++) { - if (!cmSystemTools::Touch(args[cc], false)) { + for (auto const& arg : cmMakeRange(args).advance(2)) { + if (!cmSystemTools::Touch(arg, false)) { std::cerr << "cmake -E touch_nocreate: failed to update \""; - std::cerr << args[cc] << "\".\n"; + std::cerr << arg << "\".\n"; return 1; } } @@ -744,15 +741,15 @@ int cmcmd::ExecuteCMakeCommand(std::vector<std::string>& args) // Sleep command if (args[1] == "sleep" && args.size() > 2) { double total = 0; - for (size_t i = 2; i < args.size(); ++i) { + for (auto const& arg : cmMakeRange(args).advance(2)) { double num = 0.0; char unit; char extra; - int n = sscanf(args[i].c_str(), "%lg%c%c", &num, &unit, &extra); + int n = sscanf(arg.c_str(), "%lg%c%c", &num, &unit, &extra); if ((n == 1 || (n == 2 && unit == 's')) && num >= 0) { total += num; } else { - std::cerr << "Unknown sleep time format \"" << args[i] << "\".\n"; + std::cerr << "Unknown sleep time format \"" << arg << "\".\n"; return 1; } } @@ -1047,8 +1044,7 @@ int cmcmd::ExecuteCMakeCommand(std::vector<std::string>& args) std::string mtime; std::string format; bool doing_options = true; - for (std::string::size_type cc = 4; cc < args.size(); cc++) { - std::string const& arg = args[cc]; + for (auto const& arg : cmMakeRange(args).advance(4)) { if (doing_options && cmHasLiteralPrefix(arg, "--")) { if (arg == "--") { doing_options = false; @@ -1180,17 +1176,15 @@ int cmcmd::ExecuteCMakeCommand(std::vector<std::string>& args) bool isDebug = false; std::string pipe; - for (size_t i = 2; i < args.size(); ++i) { - const std::string& a = args[i]; - - if (a == "--experimental") { + for (auto const& arg : cmMakeRange(args).advance(2)) { + if (arg == "--experimental") { supportExperimental = true; - } else if (a == "--debug") { + } else if (arg == "--debug") { pipe.clear(); isDebug = true; - } else if (a.substr(0, pipePrefix.size()) == pipePrefix) { + } else if (arg.substr(0, pipePrefix.size()) == pipePrefix) { isDebug = false; - pipe = a.substr(pipePrefix.size()); + pipe = arg.substr(pipePrefix.size()); if (pipe.empty()) { cmSystemTools::Error("No pipe given after --pipe="); return 2; @@ -1262,15 +1256,15 @@ int cmcmd::ExecuteCMakeCommand(std::vector<std::string>& args) return 1; } -int cmcmd::HashSumFile(std::vector<std::string>& args, cmCryptoHash::Algo algo) +int cmcmd::HashSumFile(std::vector<std::string> const& args, + cmCryptoHash::Algo algo) { if (args.size() < 3) { return -1; } int retval = 0; - for (std::string::size_type cc = 2; cc < args.size(); cc++) { - const char* filename = args[cc].c_str(); + for (auto const& filename : cmMakeRange(args).advance(2)) { // Cannot compute sum of a directory if (cmSystemTools::FileIsDirectory(filename)) { std::cerr << "Error: " << filename << " is a directory" << std::endl; @@ -1289,7 +1283,7 @@ int cmcmd::HashSumFile(std::vector<std::string>& args, cmCryptoHash::Algo algo) return retval; } -int cmcmd::SymlinkLibrary(std::vector<std::string>& args) +int cmcmd::SymlinkLibrary(std::vector<std::string> const& args) { int result = 0; std::string realName = args[2]; @@ -1313,7 +1307,7 @@ int cmcmd::SymlinkLibrary(std::vector<std::string>& args) return result; } -int cmcmd::SymlinkExecutable(std::vector<std::string>& args) +int cmcmd::SymlinkExecutable(std::vector<std::string> const& args) { int result = 0; std::string const& realName = args[2]; @@ -1387,7 +1381,7 @@ static void cmcmdProgressReport(std::string const& dir, std::string const& num) } } -int cmcmd::ExecuteEchoColor(std::vector<std::string>& args) +int cmcmd::ExecuteEchoColor(std::vector<std::string> const& args) { // The arguments are // args[0] == <cmake-executable> @@ -1397,55 +1391,54 @@ int cmcmd::ExecuteEchoColor(std::vector<std::string>& args) int color = cmsysTerminal_Color_Normal; bool newline = true; std::string progressDir; - for (unsigned int i = 2; i < args.size(); ++i) { - if (args[i].find("--switch=") == 0) { + for (auto const& arg : cmMakeRange(args).advance(2)) { + if (arg.find("--switch=") == 0) { // Enable or disable color based on the switch value. - std::string value = args[i].substr(9); + std::string value = arg.substr(9); if (!value.empty()) { enabled = cmSystemTools::IsOn(value); } - } else if (cmHasLiteralPrefix(args[i], "--progress-dir=")) { - progressDir = args[i].substr(15); - } else if (cmHasLiteralPrefix(args[i], "--progress-num=")) { + } else if (cmHasLiteralPrefix(arg, "--progress-dir=")) { + progressDir = arg.substr(15); + } else if (cmHasLiteralPrefix(arg, "--progress-num=")) { if (!progressDir.empty()) { - std::string const& progressNum = args[i].substr(15); + std::string const& progressNum = arg.substr(15); cmcmdProgressReport(progressDir, progressNum); } - } else if (args[i] == "--normal") { + } else if (arg == "--normal") { color = cmsysTerminal_Color_Normal; - } else if (args[i] == "--black") { + } else if (arg == "--black") { color = cmsysTerminal_Color_ForegroundBlack; - } else if (args[i] == "--red") { + } else if (arg == "--red") { color = cmsysTerminal_Color_ForegroundRed; - } else if (args[i] == "--green") { + } else if (arg == "--green") { color = cmsysTerminal_Color_ForegroundGreen; - } else if (args[i] == "--yellow") { + } else if (arg == "--yellow") { color = cmsysTerminal_Color_ForegroundYellow; - } else if (args[i] == "--blue") { + } else if (arg == "--blue") { color = cmsysTerminal_Color_ForegroundBlue; - } else if (args[i] == "--magenta") { + } else if (arg == "--magenta") { color = cmsysTerminal_Color_ForegroundMagenta; - } else if (args[i] == "--cyan") { + } else if (arg == "--cyan") { color = cmsysTerminal_Color_ForegroundCyan; - } else if (args[i] == "--white") { + } else if (arg == "--white") { color = cmsysTerminal_Color_ForegroundWhite; - } else if (args[i] == "--bold") { + } else if (arg == "--bold") { color |= cmsysTerminal_Color_ForegroundBold; - } else if (args[i] == "--no-newline") { + } else if (arg == "--no-newline") { newline = false; - } else if (args[i] == "--newline") { + } else if (arg == "--newline") { newline = true; } else { // Color is enabled. Print with the current color. - cmSystemTools::MakefileColorEcho(color, args[i].c_str(), newline, - enabled); + cmSystemTools::MakefileColorEcho(color, arg.c_str(), newline, enabled); } } return 0; } -int cmcmd::ExecuteLinkScript(std::vector<std::string>& args) +int cmcmd::ExecuteLinkScript(std::vector<std::string> const& args) { // The arguments are // args[0] == <cmake-executable> @@ -1658,9 +1651,9 @@ std::ostream& operator<<(std::ostream& stream, return stream; } -static bool RunCommand(const char* comment, std::vector<std::string>& command, - bool verbose, NumberFormat exitFormat, - int* retCodeOut = nullptr, +static bool RunCommand(const char* comment, + std::vector<std::string> const& command, bool verbose, + NumberFormat exitFormat, int* retCodeOut = nullptr, bool (*retCodeOkay)(int) = nullptr) { if (verbose) { diff --git a/Source/cmcmd.h b/Source/cmcmd.h index d1e03d0..69a7ecb 100644 --- a/Source/cmcmd.h +++ b/Source/cmcmd.h @@ -16,18 +16,18 @@ public: * Execute commands during the build process. Supports options such * as echo, remove file etc. */ - static int ExecuteCMakeCommand(std::vector<std::string>&); + static int ExecuteCMakeCommand(std::vector<std::string> const&); protected: - static int HandleCoCompileCommands(std::vector<std::string>& args); - static int HashSumFile(std::vector<std::string>& args, + static int HandleCoCompileCommands(std::vector<std::string> const& args); + static int HashSumFile(std::vector<std::string> const& args, cmCryptoHash::Algo algo); - static int SymlinkLibrary(std::vector<std::string>& args); - static int SymlinkExecutable(std::vector<std::string>& args); + static int SymlinkLibrary(std::vector<std::string> const& args); + static int SymlinkExecutable(std::vector<std::string> const& args); static bool SymlinkInternal(std::string const& file, std::string const& link); - static int ExecuteEchoColor(std::vector<std::string>& args); - static int ExecuteLinkScript(std::vector<std::string>& args); + static int ExecuteEchoColor(std::vector<std::string> const& args); + static int ExecuteLinkScript(std::vector<std::string> const& args); static int WindowsCEEnvironment(const char* version, const std::string& name); static int VisualStudioLink(std::vector<std::string> const& args, int type); diff --git a/Tests/CMakeOnly/CMakeLists.txt b/Tests/CMakeOnly/CMakeLists.txt index f40524f..57f0cf8 100644 --- a/Tests/CMakeOnly/CMakeLists.txt +++ b/Tests/CMakeOnly/CMakeLists.txt @@ -56,6 +56,12 @@ add_test(CMakeOnly.ProjectInclude ${CMAKE_CMAKE_COMMAND} -P ${CMAKE_CURRENT_BINARY_DIR}/Test.cmake ) +add_test(CMakeOnly.ProjectIncludeAny ${CMAKE_CMAKE_COMMAND} + -DTEST=ProjectIncludeAny + -DCMAKE_ARGS=-DCMAKE_PROJECT_INCLUDE=${CMAKE_CURRENT_SOURCE_DIR}/ProjectInclude/include.cmake + -P ${CMAKE_CURRENT_BINARY_DIR}/Test.cmake + ) + include(CMakeParseArguments) function(add_major_test module) diff --git a/Tests/CMakeOnly/ProjectInclude/CMakeLists.txt b/Tests/CMakeOnly/ProjectInclude/CMakeLists.txt index a9abb4a..ffce488 100644 --- a/Tests/CMakeOnly/ProjectInclude/CMakeLists.txt +++ b/Tests/CMakeOnly/ProjectInclude/CMakeLists.txt @@ -1,4 +1,4 @@ -project(ProjectInclude) +project(ProjectInclude LANGUAGES NONE) if(NOT AUTO_INCLUDE) message(FATAL_ERROR "include file not found") endif() diff --git a/Tests/CMakeOnly/ProjectIncludeAny/CMakeLists.txt b/Tests/CMakeOnly/ProjectIncludeAny/CMakeLists.txt new file mode 100644 index 0000000..ffce488 --- /dev/null +++ b/Tests/CMakeOnly/ProjectIncludeAny/CMakeLists.txt @@ -0,0 +1,4 @@ +project(ProjectInclude LANGUAGES NONE) +if(NOT AUTO_INCLUDE) + message(FATAL_ERROR "include file not found") +endif() 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**) diff --git a/Tests/Module/FindDependency/CMakeLists.txt b/Tests/Module/FindDependency/CMakeLists.txt index dcb998a..06d7dce 100644 --- a/Tests/Module/FindDependency/CMakeLists.txt +++ b/Tests/Module/FindDependency/CMakeLists.txt @@ -6,6 +6,8 @@ set(CMAKE_PREFIX_PATH "${CMAKE_CURRENT_SOURCE_DIR}/packages") find_package(Pack1 REQUIRED) find_package(Pack4 4.3 EXACT REQUIRED) +find_package(Pack7 REQUIRED) +find_package(Pack8 REQUIRED) add_executable(FindDependency main.cpp) -target_link_libraries(FindDependency Pack1::Lib Pack4::Lib) +target_link_libraries(FindDependency Pack1::Lib Pack4::Lib Pack8::Lib) diff --git a/Tests/Module/FindDependency/main.cpp b/Tests/Module/FindDependency/main.cpp index 1df4cb5..4ee460f 100644 --- a/Tests/Module/FindDependency/main.cpp +++ b/Tests/Module/FindDependency/main.cpp @@ -23,6 +23,18 @@ # error Expected HAVE_PACK6 #endif +#ifndef HAVE_PACK7 +# error Expected HAVE_PACK7 +#endif + +#ifndef HAVE_PACK7_COMP1 +# error Expected HAVE_PACK7_COMP1 +#endif + +#ifndef HAVE_PACK8 +# error Expected HAVE_PACK8 +#endif + int main(int argc, char** argv) { return 0; diff --git a/Tests/Module/FindDependency/packages/Pack7/Pack7Config.cmake b/Tests/Module/FindDependency/packages/Pack7/Pack7Config.cmake new file mode 100644 index 0000000..9df1345 --- /dev/null +++ b/Tests/Module/FindDependency/packages/Pack7/Pack7Config.cmake @@ -0,0 +1,14 @@ +if(NOT Pack7_FOUND) + set(Pack7_FOUND 1) + add_library(Pack7::Pack7 INTERFACE IMPORTED) + set_property(TARGET Pack7::Pack7 PROPERTY INTERFACE_COMPILE_DEFINITIONS HAVE_PACK7) +endif() + +foreach(module ${Pack7_FIND_COMPONENTS}) + if(module STREQUAL "Comp1") + add_library(Pack7::Comp1 INTERFACE IMPORTED) + set_property(TARGET Pack7::Comp1 PROPERTY INTERFACE_COMPILE_DEFINITIONS HAVE_PACK7_COMP1) + set_property(TARGET Pack7::Comp1 PROPERTY INTERFACE_LINK_LIBRARIES Pack7::Pack7) + set(Pack7_Comp1_FOUND 1) + endif() +endforeach() diff --git a/Tests/Module/FindDependency/packages/Pack8/Pack8Config.cmake b/Tests/Module/FindDependency/packages/Pack8/Pack8Config.cmake new file mode 100644 index 0000000..d7ca054 --- /dev/null +++ b/Tests/Module/FindDependency/packages/Pack8/Pack8Config.cmake @@ -0,0 +1,7 @@ +include(CMakeFindDependencyMacro) + +find_dependency(Pack7 REQUIRED COMPONENTS Comp1) + +add_library(Pack8::Lib INTERFACE IMPORTED) +set_property(TARGET Pack8::Lib PROPERTY INTERFACE_COMPILE_DEFINITIONS HAVE_PACK8) +set_property(TARGET Pack8::Lib PROPERTY INTERFACE_LINK_LIBRARIES Pack7::Comp1) diff --git a/Tests/RunCMake/GeneratorExpression/REMOVE_DUPLICATES-1-check.cmake b/Tests/RunCMake/GeneratorExpression/REMOVE_DUPLICATES-1-check.cmake new file mode 100644 index 0000000..e127711 --- /dev/null +++ b/Tests/RunCMake/GeneratorExpression/REMOVE_DUPLICATES-1-check.cmake @@ -0,0 +1,6 @@ +file(READ "${RunCMake_TEST_BINARY_DIR}/REMOVE_DUPLICATES-generated.txt" content) + +set(expected "1") +if(NOT content STREQUAL expected) + set(RunCMake_TEST_FAILED "actual content:\n [[${content}]]\nbut expected:\n [[${expected}]]") +endif() diff --git a/Tests/RunCMake/GeneratorExpression/REMOVE_DUPLICATES-1.cmake b/Tests/RunCMake/GeneratorExpression/REMOVE_DUPLICATES-1.cmake new file mode 100644 index 0000000..53934af --- /dev/null +++ b/Tests/RunCMake/GeneratorExpression/REMOVE_DUPLICATES-1.cmake @@ -0,0 +1,3 @@ +cmake_policy(VERSION 3.11) + +file(GENERATE OUTPUT "REMOVE_DUPLICATES-generated.txt" CONTENT "$<REMOVE_DUPLICATES:1>") diff --git a/Tests/RunCMake/GeneratorExpression/REMOVE_DUPLICATES-2-check.cmake b/Tests/RunCMake/GeneratorExpression/REMOVE_DUPLICATES-2-check.cmake new file mode 100644 index 0000000..e127711 --- /dev/null +++ b/Tests/RunCMake/GeneratorExpression/REMOVE_DUPLICATES-2-check.cmake @@ -0,0 +1,6 @@ +file(READ "${RunCMake_TEST_BINARY_DIR}/REMOVE_DUPLICATES-generated.txt" content) + +set(expected "1") +if(NOT content STREQUAL expected) + set(RunCMake_TEST_FAILED "actual content:\n [[${content}]]\nbut expected:\n [[${expected}]]") +endif() diff --git a/Tests/RunCMake/GeneratorExpression/REMOVE_DUPLICATES-2.cmake b/Tests/RunCMake/GeneratorExpression/REMOVE_DUPLICATES-2.cmake new file mode 100644 index 0000000..a8aca6e --- /dev/null +++ b/Tests/RunCMake/GeneratorExpression/REMOVE_DUPLICATES-2.cmake @@ -0,0 +1,3 @@ +cmake_policy(VERSION 3.11) + +file(GENERATE OUTPUT "REMOVE_DUPLICATES-generated.txt" CONTENT "$<REMOVE_DUPLICATES:1$<SEMICOLON>1>") diff --git a/Tests/RunCMake/GeneratorExpression/REMOVE_DUPLICATES-3-check.cmake b/Tests/RunCMake/GeneratorExpression/REMOVE_DUPLICATES-3-check.cmake new file mode 100644 index 0000000..e3055ce --- /dev/null +++ b/Tests/RunCMake/GeneratorExpression/REMOVE_DUPLICATES-3-check.cmake @@ -0,0 +1,6 @@ +file(READ "${RunCMake_TEST_BINARY_DIR}/REMOVE_DUPLICATES-generated.txt" content) + +set(expected "2;1") +if(NOT content STREQUAL expected) + set(RunCMake_TEST_FAILED "actual content:\n [[${content}]]\nbut expected:\n [[${expected}]]") +endif() diff --git a/Tests/RunCMake/GeneratorExpression/REMOVE_DUPLICATES-3.cmake b/Tests/RunCMake/GeneratorExpression/REMOVE_DUPLICATES-3.cmake new file mode 100644 index 0000000..ee2dd3e --- /dev/null +++ b/Tests/RunCMake/GeneratorExpression/REMOVE_DUPLICATES-3.cmake @@ -0,0 +1,3 @@ +cmake_policy(VERSION 3.11) + +file(GENERATE OUTPUT "REMOVE_DUPLICATES-generated.txt" CONTENT "$<REMOVE_DUPLICATES:2$<SEMICOLON>1>") diff --git a/Tests/RunCMake/GeneratorExpression/REMOVE_DUPLICATES-4-check.cmake b/Tests/RunCMake/GeneratorExpression/REMOVE_DUPLICATES-4-check.cmake new file mode 100644 index 0000000..e3055ce --- /dev/null +++ b/Tests/RunCMake/GeneratorExpression/REMOVE_DUPLICATES-4-check.cmake @@ -0,0 +1,6 @@ +file(READ "${RunCMake_TEST_BINARY_DIR}/REMOVE_DUPLICATES-generated.txt" content) + +set(expected "2;1") +if(NOT content STREQUAL expected) + set(RunCMake_TEST_FAILED "actual content:\n [[${content}]]\nbut expected:\n [[${expected}]]") +endif() diff --git a/Tests/RunCMake/GeneratorExpression/REMOVE_DUPLICATES-4.cmake b/Tests/RunCMake/GeneratorExpression/REMOVE_DUPLICATES-4.cmake new file mode 100644 index 0000000..557bc28 --- /dev/null +++ b/Tests/RunCMake/GeneratorExpression/REMOVE_DUPLICATES-4.cmake @@ -0,0 +1,3 @@ +cmake_policy(VERSION 3.11) + +file(GENERATE OUTPUT "REMOVE_DUPLICATES-generated.txt" CONTENT "$<REMOVE_DUPLICATES:2$<SEMICOLON>1$<SEMICOLON>2>") diff --git a/Tests/RunCMake/GeneratorExpression/REMOVE_DUPLICATES-empty-check.cmake b/Tests/RunCMake/GeneratorExpression/REMOVE_DUPLICATES-empty-check.cmake new file mode 100644 index 0000000..f779d48 --- /dev/null +++ b/Tests/RunCMake/GeneratorExpression/REMOVE_DUPLICATES-empty-check.cmake @@ -0,0 +1,6 @@ +file(READ "${RunCMake_TEST_BINARY_DIR}/REMOVE_DUPLICATES-generated.txt" content) + +set(expected "") +if(NOT content STREQUAL expected) + set(RunCMake_TEST_FAILED "actual content:\n [[${content}]]\nbut expected:\n [[${expected}]]") +endif() diff --git a/Tests/RunCMake/GeneratorExpression/REMOVE_DUPLICATES-empty.cmake b/Tests/RunCMake/GeneratorExpression/REMOVE_DUPLICATES-empty.cmake new file mode 100644 index 0000000..3b9d674 --- /dev/null +++ b/Tests/RunCMake/GeneratorExpression/REMOVE_DUPLICATES-empty.cmake @@ -0,0 +1,3 @@ +cmake_policy(VERSION 3.11) + +file(GENERATE OUTPUT "REMOVE_DUPLICATES-generated.txt" CONTENT "$<REMOVE_DUPLICATES:>") diff --git a/Tests/RunCMake/GeneratorExpression/RunCMakeTest.cmake b/Tests/RunCMake/GeneratorExpression/RunCMakeTest.cmake index 8a5604c..63c12a9 100644 --- a/Tests/RunCMake/GeneratorExpression/RunCMakeTest.cmake +++ b/Tests/RunCMake/GeneratorExpression/RunCMakeTest.cmake @@ -53,6 +53,11 @@ run_cmake(TARGET_GENEX_EVAL) run_cmake(GENEX_EVAL-recursion1) run_cmake(GENEX_EVAL-recursion2) run_cmake(GENEX_EVAL) +run_cmake(REMOVE_DUPLICATES-empty) +run_cmake(REMOVE_DUPLICATES-1) +run_cmake(REMOVE_DUPLICATES-2) +run_cmake(REMOVE_DUPLICATES-3) +run_cmake(REMOVE_DUPLICATES-4) run_cmake(ImportedTarget-TARGET_BUNDLE_DIR) run_cmake(ImportedTarget-TARGET_BUNDLE_CONTENT_DIR) |