diff options
74 files changed, 413 insertions, 162 deletions
diff --git a/Help/release/dev/CTestCoverageCollectGCOV-compress-opts.rst b/Help/release/dev/CTestCoverageCollectGCOV-compress-opts.rst new file mode 100644 index 0000000..eb8532d --- /dev/null +++ b/Help/release/dev/CTestCoverageCollectGCOV-compress-opts.rst @@ -0,0 +1,7 @@ +CTestCoverageCollectGCOV-compress-opts +-------------------------------------- + +* The :module:`CTestCoverageCollectGCOV` module + :command:`ctest_coverage_collect_gcov` function gained a + ``TARBALL_COMPRESSION`` option to control compression of the + tarball of collected results. diff --git a/Help/release/dev/FPHSA-handle_components.rst b/Help/release/dev/FPHSA-handle_components.rst new file mode 100644 index 0000000..39907c4 --- /dev/null +++ b/Help/release/dev/FPHSA-handle_components.rst @@ -0,0 +1,5 @@ +FPHSA-handle_components +----------------------- + +* The :module:`FindPackageHandleStandardArgs` module option ``REQUIRED_VARS`` + is now optional if ``HANDLE_COMPONENTS`` is specified. diff --git a/Help/variable/CTEST_NIGHTLY_START_TIME.rst b/Help/variable/CTEST_NIGHTLY_START_TIME.rst index bc80276..90841f9 100644 --- a/Help/variable/CTEST_NIGHTLY_START_TIME.rst +++ b/Help/variable/CTEST_NIGHTLY_START_TIME.rst @@ -1,5 +1,9 @@ CTEST_NIGHTLY_START_TIME ------------------------ -Specify the CTest ``NightlyStartTime`` setting -in a :manual:`ctest(1)` dashboard client script. +Specify the CTest ``NightlyStartTime`` setting in a :manual:`ctest(1)` +dashboard client script. + +Note that this variable must always be set for a nightly build in a +dashboard script. It is needed so that nightly builds can be properly grouped +together in CDash. diff --git a/Modules/CTestCoverageCollectGCOV.cmake b/Modules/CTestCoverageCollectGCOV.cmake index b498086..b1268be 100644 --- a/Modules/CTestCoverageCollectGCOV.cmake +++ b/Modules/CTestCoverageCollectGCOV.cmake @@ -37,6 +37,17 @@ After generating this tar file, it can be sent to CDash for display with the upload to CDash. Relative paths will be interpreted with respect to the top-level build directory. + ``TARBALL_COMPRESSION <option>`` Specify a compression algorithm for the + ``TARBALL`` data file. Using this option reduces the size of the data file + before it is submitted to CDash. ``<option>`` must be one of ``GZIP``, + ``BZIP2``, ``XZ``, ``ZSTD``, ``FROM_EXT``, or an expression that CMake + evaluates as ``FALSE``. The default value is ``BZIP2``. + + If ``FROM_EXT`` is specified, the resulting file will be compressed based on + the file extension of the ``<tarfile>`` (i.e. ``.tar.gz`` will use ``GZIP`` + compression). File extensions that will produce compressed output include + ``.tar.gz``, ``.tgz``, ``.tar.bzip2``, ``.tbz``, ``.tar.xz``, and ``.txz``. + ``SOURCE <source_dir>`` Specify the top-level source directory for the build. Default is the value of :variable:`CTEST_SOURCE_DIRECTORY`. @@ -68,7 +79,7 @@ After generating this tar file, it can be sent to CDash for display with the function(ctest_coverage_collect_gcov) set(options QUIET GLOB DELETE) - set(oneValueArgs TARBALL SOURCE BUILD GCOV_COMMAND) + set(oneValueArgs TARBALL SOURCE BUILD GCOV_COMMAND TARBALL_COMPRESSION) set(multiValueArgs GCOV_OPTIONS) cmake_parse_arguments(GCOV "${options}" "${oneValueArgs}" "${multiValueArgs}" "" ${ARGN} ) @@ -91,6 +102,13 @@ function(ctest_coverage_collect_gcov) else() set(gcov_command "${GCOV_GCOV_COMMAND}") endif() + if(NOT DEFINED GCOV_TARBALL_COMPRESSION) + set(GCOV_TARBALL_COMPRESSION "BZIP2") + elseif( GCOV_TARBALL_COMPRESSION AND + NOT GCOV_TARBALL_COMPRESSION MATCHES "^(GZIP|BZIP2|XZ|ZSTD|FROM_EXT)$") + message(FATAL_ERROR "TARBALL_COMPRESSION must be one of OFF, GZIP, " + "BZIP2, XZ, ZSTD, or FROM_EXT for ctest_coverage_collect_gcov") + endif() # run gcov on each gcda file in the binary tree set(gcda_files) set(label_files) @@ -270,14 +288,38 @@ ${label_files} ${uncovered_files_for_tar} ") - if (GCOV_QUIET) - set(tar_opts "cfj") - else() - set(tar_opts "cvfj") + # Prepare tar command line arguments + + set(tar_opts "") + # Select data compression mode + if( GCOV_TARBALL_COMPRESSION STREQUAL "FROM_EXT") + if( GCOV_TARBALL MATCHES [[\.(tgz|tar.gz)$]] ) + string(APPEND tar_opts "z") + elseif( GCOV_TARBALL MATCHES [[\.(txz|tar.xz)$]] ) + string(APPEND tar_opts "J") + elseif( GCOV_TARBALL MATCHES [[\.(tbz|tar.bz)$]] ) + string(APPEND tar_opts "j") + endif() + elseif(GCOV_TARBALL_COMPRESSION STREQUAL "GZIP") + string(APPEND tar_opts "z") + elseif(GCOV_TARBALL_COMPRESSION STREQUAL "XZ") + string(APPEND tar_opts "J") + elseif(GCOV_TARBALL_COMPRESSION STREQUAL "BZIP2") + string(APPEND tar_opts "j") + elseif(GCOV_TARBALL_COMPRESSION STREQUAL "ZSTD") + set(zstd_tar_opt "--zstd") + endif() + # Verbosity options + if(NOT GCOV_QUIET AND NOT tar_opts MATCHES v) + string(APPEND tar_opts "v") endif() + # Prepend option 'c' specifying 'create' + string(PREPEND tar_opts "c") + # Append option 'f' so that the next argument is the filename + string(APPEND tar_opts "f") execute_process(COMMAND - ${CMAKE_COMMAND} -E tar ${tar_opts} ${GCOV_TARBALL} + ${CMAKE_COMMAND} -E tar ${tar_opts} ${GCOV_TARBALL} ${zstd_tar_opt} "--mtime=1970-01-01 0:0:0 UTC" "--format=gnutar" --files-from=${coverage_dir}/coverage_file_list.txt diff --git a/Modules/FindPackageHandleStandardArgs.cmake b/Modules/FindPackageHandleStandardArgs.cmake index a078049..4fb0825 100644 --- a/Modules/FindPackageHandleStandardArgs.cmake +++ b/Modules/FindPackageHandleStandardArgs.cmake @@ -57,7 +57,8 @@ valid filepaths. These may be named in the generated failure message asking the user to set the missing variable values. Therefore these should typically be cache entries such as ``FOO_LIBRARY`` and not output - variables like ``FOO_LIBRARIES``. + variables like ``FOO_LIBRARIES``. This option is mandatory if + ``HANDLE_COMPONENTS`` is not specified. ``VERSION_VAR <version-var>`` Specify the name of a variable that holds the version of the package @@ -257,7 +258,7 @@ function(FIND_PACKAGE_HANDLE_STANDARD_ARGS _NAME _FIRST_ARG) set(FPHSA_VERSION_VAR ${_NAME}_VERSION) endif() - if(NOT FPHSA_REQUIRED_VARS) + if(NOT FPHSA_REQUIRED_VARS AND NOT FPHSA_HANDLE_COMPONENTS) message(FATAL_ERROR "No REQUIRED_VARS specified for FIND_PACKAGE_HANDLE_STANDARD_ARGS()") endif() endif() @@ -283,7 +284,9 @@ function(FIND_PACKAGE_HANDLE_STANDARD_ARGS _NAME _FIRST_ARG) set(FPHSA_FAIL_MESSAGE "Could NOT find ${_NAME}") endif() - list(GET FPHSA_REQUIRED_VARS 0 _FIRST_REQUIRED_VAR) + if (FPHSA_REQUIRED_VARS) + list(GET FPHSA_REQUIRED_VARS 0 _FIRST_REQUIRED_VAR) + endif() string(TOUPPER ${_NAME} _NAME_UPPER) string(TOLOWER ${_NAME} _NAME_LOWER) @@ -440,7 +443,17 @@ function(FIND_PACKAGE_HANDLE_STANDARD_ARGS _NAME _FIRST_ARG) _FPHSA_HANDLE_FAILURE_CONFIG_MODE() else() if(NOT VERSION_OK) - _FPHSA_FAILURE_MESSAGE("${FPHSA_FAIL_MESSAGE}: ${VERSION_MSG} (found ${${_FIRST_REQUIRED_VAR}})") + set(RESULT_MSG) + if (_FIRST_REQUIRED_VAR) + string (APPEND RESULT_MSG "found ${${_FIRST_REQUIRED_VAR}}") + endif() + if (COMPONENT_MSG) + if (RESULT_MSG) + string (APPEND RESULT_MSG ", ") + endif() + string (APPEND RESULT_MSG "${FOUND_COMPONENTS_MSG}") + endif() + _FPHSA_FAILURE_MESSAGE("${FPHSA_FAIL_MESSAGE}: ${VERSION_MSG} (${RESULT_MSG})") else() _FPHSA_FAILURE_MESSAGE("${FPHSA_FAIL_MESSAGE} (missing:${MISSING_VARS}) ${VERSION_MSG}") endif() diff --git a/Source/CMakeLists.txt b/Source/CMakeLists.txt index 564e647..ec473d2 100644 --- a/Source/CMakeLists.txt +++ b/Source/CMakeLists.txt @@ -698,7 +698,6 @@ set(SRCS cmWriteFileCommand.cxx cmWriteFileCommand.h - cm_static_string_view.hxx cm_get_date.h cm_get_date.c cm_utf8.h diff --git a/Source/CMakeVersion.cmake b/Source/CMakeVersion.cmake index 4c8f6d4..254d02b 100644 --- a/Source/CMakeVersion.cmake +++ b/Source/CMakeVersion.cmake @@ -1,7 +1,7 @@ # CMake version number components. set(CMake_VERSION_MAJOR 3) set(CMake_VERSION_MINOR 17) -set(CMake_VERSION_PATCH 20200430) +set(CMake_VERSION_PATCH 20200504) #set(CMake_VERSION_RC 0) set(CMake_VERSION_IS_DIRTY 0) diff --git a/Source/CPack/cmCPackDebGenerator.cxx b/Source/CPack/cmCPackDebGenerator.cxx index 8eca2ff..3d5fe6b 100644 --- a/Source/CPack/cmCPackDebGenerator.cxx +++ b/Source/CPack/cmCPackDebGenerator.cxx @@ -135,16 +135,17 @@ void DebGenerator::generateDebianBinaryFile() const { // debian-binary file const std::string dbfilename = WorkDir + "/debian-binary"; - cmGeneratedFileStream out(dbfilename); - out << "2.0"; - out << std::endl; // required for valid debian package + cmGeneratedFileStream out; + out.Open(dbfilename, false, true); + out << "2.0\n"; // required for valid debian package } void DebGenerator::generateControlFile() const { std::string ctlfilename = WorkDir + "/control"; - cmGeneratedFileStream out(ctlfilename); + cmGeneratedFileStream out; + out.Open(ctlfilename, false, true); for (auto const& kv : ControlValues) { out << kv.first << ": " << kv.second << "\n"; } @@ -156,8 +157,7 @@ void DebGenerator::generateControlFile() const totalSize += cmSystemTools::FileLength(file); } } - out << "Installed-Size: " << (totalSize + 1023) / 1024 << "\n"; - out << std::endl; + out << "Installed-Size: " << (totalSize + 1023) / 1024 << "\n\n"; } bool DebGenerator::generateDataTar() const @@ -248,7 +248,8 @@ std::string DebGenerator::generateMD5File() const { std::string md5filename = WorkDir + "/md5sums"; - cmGeneratedFileStream out(md5filename); + cmGeneratedFileStream out; + out.Open(md5filename, false, true); std::string topLevelWithTrailingSlash = cmStrCat(TemporaryDir, '/'); for (std::string const& file : PackageFiles) { @@ -757,15 +758,17 @@ int cmCPackDebGenerator::createDeb() const bool gen_shibs = this->IsOn("CPACK_DEBIAN_PACKAGE_GENERATE_SHLIBS") && debian_pkg_shlibs && *debian_pkg_shlibs; if (gen_shibs) { - cmGeneratedFileStream out(shlibsfilename); + cmGeneratedFileStream out; + out.Open(shlibsfilename, false, true); out << debian_pkg_shlibs; - out << std::endl; + out << '\n'; } const std::string postinst = strGenWDIR + "/postinst"; const std::string postrm = strGenWDIR + "/postrm"; if (this->IsOn("GEN_CPACK_DEBIAN_GENERATE_POSTINST")) { - cmGeneratedFileStream out(postinst); + cmGeneratedFileStream out; + out.Open(postinst, false, true); out << "#!/bin/sh\n\n" "set -e\n\n" "if [ \"$1\" = \"configure\" ]; then\n" @@ -773,7 +776,8 @@ int cmCPackDebGenerator::createDeb() "fi\n"; } if (this->IsOn("GEN_CPACK_DEBIAN_GENERATE_POSTRM")) { - cmGeneratedFileStream out(postrm); + cmGeneratedFileStream out; + out.Open(postrm, false, true); out << "#!/bin/sh\n\n" "set -e\n\n" "if [ \"$1\" = \"remove\" ]; then\n" diff --git a/Source/CTest/cmCTestBuildCommand.cxx b/Source/CTest/cmCTestBuildCommand.cxx index d1b7701..44fdc29 100644 --- a/Source/CTest/cmCTestBuildCommand.cxx +++ b/Source/CTest/cmCTestBuildCommand.cxx @@ -5,7 +5,7 @@ #include <cstring> #include <sstream> -#include "cm_static_string_view.hxx" +#include <cmext/string_view> #include "cmCTest.h" #include "cmCTestBuildHandler.h" diff --git a/Source/CTest/cmCTestConfigureCommand.cxx b/Source/CTest/cmCTestConfigureCommand.cxx index 3854710..f42c3f1 100644 --- a/Source/CTest/cmCTestConfigureCommand.cxx +++ b/Source/CTest/cmCTestConfigureCommand.cxx @@ -6,7 +6,7 @@ #include <sstream> #include <vector> -#include "cm_static_string_view.hxx" +#include <cmext/string_view> #include "cmCTest.h" #include "cmCTestConfigureHandler.h" diff --git a/Source/CTest/cmCTestCoverageCommand.cxx b/Source/CTest/cmCTestCoverageCommand.cxx index e335923..7432d08 100644 --- a/Source/CTest/cmCTestCoverageCommand.cxx +++ b/Source/CTest/cmCTestCoverageCommand.cxx @@ -5,8 +5,7 @@ #include <set> #include <cmext/algorithm> - -#include "cm_static_string_view.hxx" +#include <cmext/string_view> #include "cmCTest.h" #include "cmCTestCoverageHandler.h" diff --git a/Source/CTest/cmCTestHandlerCommand.cxx b/Source/CTest/cmCTestHandlerCommand.cxx index b1034c9..a755632 100644 --- a/Source/CTest/cmCTestHandlerCommand.cxx +++ b/Source/CTest/cmCTestHandlerCommand.cxx @@ -7,7 +7,7 @@ #include <cstring> #include <sstream> -#include "cm_static_string_view.hxx" +#include <cmext/string_view> #include "cmCTest.h" #include "cmCTestGenericHandler.h" diff --git a/Source/CTest/cmCTestMemCheckCommand.cxx b/Source/CTest/cmCTestMemCheckCommand.cxx index 39dec6d..d0e2974 100644 --- a/Source/CTest/cmCTestMemCheckCommand.cxx +++ b/Source/CTest/cmCTestMemCheckCommand.cxx @@ -2,7 +2,7 @@ file Copyright.txt or https://cmake.org/licensing for details. */ #include "cmCTestMemCheckCommand.h" -#include "cm_static_string_view.hxx" +#include <cmext/string_view> #include "cmCTest.h" #include "cmCTestMemCheckHandler.h" diff --git a/Source/CTest/cmCTestSubmitCommand.cxx b/Source/CTest/cmCTestSubmitCommand.cxx index 5b2f2e6..279216e 100644 --- a/Source/CTest/cmCTestSubmitCommand.cxx +++ b/Source/CTest/cmCTestSubmitCommand.cxx @@ -9,8 +9,7 @@ #include <cm/memory> #include <cm/vector> #include <cmext/algorithm> - -#include "cm_static_string_view.hxx" +#include <cmext/string_view> #include "cmCTest.h" #include "cmCTestSubmitHandler.h" diff --git a/Source/CTest/cmCTestTestCommand.cxx b/Source/CTest/cmCTestTestCommand.cxx index 6b317cb..c71b409 100644 --- a/Source/CTest/cmCTestTestCommand.cxx +++ b/Source/CTest/cmCTestTestCommand.cxx @@ -6,7 +6,7 @@ #include <cstdlib> #include <sstream> -#include "cm_static_string_view.hxx" +#include <cmext/string_view> #include "cmCTest.h" #include "cmCTestGenericHandler.h" diff --git a/Source/CTest/cmCTestTestHandler.cxx b/Source/CTest/cmCTestTestHandler.cxx index e6b3f36..8fc5cd6 100644 --- a/Source/CTest/cmCTestTestHandler.cxx +++ b/Source/CTest/cmCTestTestHandler.cxx @@ -20,13 +20,13 @@ #include <cm/memory> #include <cm/string_view> #include <cmext/algorithm> +#include <cmext/string_view> #include "cmsys/FStream.hxx" #include <cmsys/Base64.h> #include <cmsys/Directory.hxx> #include <cmsys/RegularExpression.hxx> -#include "cm_static_string_view.hxx" #include "cm_utf8.h" #include "cmCTest.h" diff --git a/Source/CTest/cmCTestUploadCommand.cxx b/Source/CTest/cmCTestUploadCommand.cxx index eaef1ca..f86ee0d 100644 --- a/Source/CTest/cmCTestUploadCommand.cxx +++ b/Source/CTest/cmCTestUploadCommand.cxx @@ -6,8 +6,7 @@ #include <sstream> #include <cm/vector> - -#include "cm_static_string_view.hxx" +#include <cmext/string_view> #include "cmCTest.h" #include "cmCTestUploadHandler.h" diff --git a/Source/Checks/cm_cxx_features.cmake b/Source/Checks/cm_cxx_features.cmake index 358c5c5..50ccc7c 100644 --- a/Source/Checks/cm_cxx_features.cmake +++ b/Source/Checks/cm_cxx_features.cmake @@ -32,6 +32,8 @@ function(cm_check_cxx_feature name) string(REGEX REPLACE "[^\n]*libhugetlbfs [^\n]*: WARNING[^\n]*" "" check_output "${check_output}") # Filter out xcodebuild warnings. string(REGEX REPLACE "[^\n]* xcodebuild\\[[0-9]*:[0-9]*\\] warning: [^\n]*" "" check_output "${check_output}") + # Filter out icpc warnings + string(REGEX REPLACE "[^\n]*icpc: command line warning #10121: overriding [^\n]*" "" check_output "${check_output}") # Filter out ld warnings. string(REGEX REPLACE "[^\n]*ld: warning: [^\n]*" "" check_output "${check_output}") # If using the feature causes warnings, treat it as broken/unavailable. diff --git a/Source/cmArgumentParser.h b/Source/cmArgumentParser.h index 9426537..5d2dfa2 100644 --- a/Source/cmArgumentParser.h +++ b/Source/cmArgumentParser.h @@ -12,8 +12,7 @@ #include <vector> #include <cm/string_view> - -#include "cm_static_string_view.hxx" +#include <cmext/string_view> namespace ArgumentParser { diff --git a/Source/cmCTest.cxx b/Source/cmCTest.cxx index c2b2a09..2a0ddba1 100644 --- a/Source/cmCTest.cxx +++ b/Source/cmCTest.cxx @@ -19,6 +19,7 @@ #include <cm/memory> #include <cm/string_view> #include <cmext/algorithm> +#include <cmext/string_view> #include "cmsys/Base64.h" #include "cmsys/Directory.hxx" @@ -36,8 +37,6 @@ # include <unistd.h> // IWYU pragma: keep #endif -#include "cm_static_string_view.hxx" - #include "cmCTestBuildAndTestHandler.h" #include "cmCTestBuildHandler.h" #include "cmCTestConfigureHandler.h" diff --git a/Source/cmCommandArgumentParserHelper.cxx b/Source/cmCommandArgumentParserHelper.cxx index 379836a..0516d26 100644 --- a/Source/cmCommandArgumentParserHelper.cxx +++ b/Source/cmCommandArgumentParserHelper.cxx @@ -69,8 +69,7 @@ const char* cmCommandArgumentParserHelper::ExpandSpecialVariable( return ""; } if (strcmp(key, "CACHE") == 0) { - if (const std::string* c = - this->Makefile->GetState()->GetInitializedCacheValue(var)) { + if (cmProp c = this->Makefile->GetState()->GetInitializedCacheValue(var)) { if (this->EscapeQuotes) { return this->AddString(cmEscapeQuotes(*c)); } diff --git a/Source/cmCommonTargetGenerator.cxx b/Source/cmCommonTargetGenerator.cxx index 6c1a476..5414409 100644 --- a/Source/cmCommonTargetGenerator.cxx +++ b/Source/cmCommonTargetGenerator.cxx @@ -77,7 +77,7 @@ void cmCommonTargetGenerator::AppendFortranFormatFlags( cmOutputConverter::FortranFormat format = cmOutputConverter::GetFortranFormat(srcfmt); if (format == cmOutputConverter::FortranFormatNone) { - const std::string tgtfmt = + std::string const& tgtfmt = this->GeneratorTarget->GetSafeProperty("Fortran_FORMAT"); format = cmOutputConverter::GetFortranFormat(tgtfmt); } diff --git a/Source/cmConfigureFileCommand.cxx b/Source/cmConfigureFileCommand.cxx index bac9337..5b3045d 100644 --- a/Source/cmConfigureFileCommand.cxx +++ b/Source/cmConfigureFileCommand.cxx @@ -5,8 +5,7 @@ #include <set> #include <cm/string_view> - -#include "cm_static_string_view.hxx" +#include <cmext/string_view> #include "cmExecutionStatus.h" #include "cmMakefile.h" diff --git a/Source/cmCoreTryCompile.cxx b/Source/cmCoreTryCompile.cxx index dc2df14..4e2caed 100644 --- a/Source/cmCoreTryCompile.cxx +++ b/Source/cmCoreTryCompile.cxx @@ -8,9 +8,9 @@ #include <sstream> #include <utility> -#include "cmsys/Directory.hxx" +#include <cmext/string_view> -#include "cm_static_string_view.hxx" +#include "cmsys/Directory.hxx" #include "cmExportTryCompileFileGenerator.h" #include "cmGlobalGenerator.h" diff --git a/Source/cmExecuteProcessCommand.cxx b/Source/cmExecuteProcessCommand.cxx index 08a0f7e..9c53bdf 100644 --- a/Source/cmExecuteProcessCommand.cxx +++ b/Source/cmExecuteProcessCommand.cxx @@ -10,11 +10,10 @@ #include <vector> #include <cmext/algorithm> +#include <cmext/string_view> #include "cmsys/Process.h" -#include "cm_static_string_view.hxx" - #include "cmArgumentParser.h" #include "cmExecutionStatus.h" #include "cmMakefile.h" diff --git a/Source/cmExportCommand.cxx b/Source/cmExportCommand.cxx index ad632ee..9f8a821 100644 --- a/Source/cmExportCommand.cxx +++ b/Source/cmExportCommand.cxx @@ -8,11 +8,10 @@ #include <cm/memory> #include <cmext/algorithm> +#include <cmext/string_view> #include "cmsys/RegularExpression.hxx" -#include "cm_static_string_view.hxx" - #include "cmArgumentParser.h" #include "cmExecutionStatus.h" #include "cmExportBuildAndroidMKGenerator.h" diff --git a/Source/cmExtraEclipseCDT4Generator.cxx b/Source/cmExtraEclipseCDT4Generator.cxx index b65f097..80d61c3 100644 --- a/Source/cmExtraEclipseCDT4Generator.cxx +++ b/Source/cmExtraEclipseCDT4Generator.cxx @@ -243,8 +243,7 @@ void cmExtraEclipseCDT4Generator::AddEnvVar(std::ostream& out, const bool envVarSet = cmSystemTools::GetEnv(envVar, envVarValue); std::string cacheEntryName = cmStrCat("CMAKE_ECLIPSE_ENVVAR_", envVar); - const std::string* cacheValue = - lg.GetState()->GetInitializedCacheValue(cacheEntryName); + cmProp cacheValue = lg.GetState()->GetInitializedCacheValue(cacheEntryName); // now we have both, decide which one to use std::string valueToUse; diff --git a/Source/cmFileCommand.cxx b/Source/cmFileCommand.cxx index 4ec128e..161bbe8 100644 --- a/Source/cmFileCommand.cxx +++ b/Source/cmFileCommand.cxx @@ -17,13 +17,13 @@ #include <cm/memory> #include <cmext/algorithm> +#include <cmext/string_view> #include "cmsys/FStream.hxx" #include "cmsys/Glob.hxx" #include "cmsys/RegularExpression.hxx" #include "cm_kwiml.h" -#include "cm_static_string_view.hxx" #include "cm_sys_stat.h" #include "cmAlgorithms.h" diff --git a/Source/cmForEachCommand.cxx b/Source/cmForEachCommand.cxx index 82c5223..32e7892 100644 --- a/Source/cmForEachCommand.cxx +++ b/Source/cmForEachCommand.cxx @@ -18,8 +18,7 @@ #include <cm/memory> #include <cm/string_view> - -#include "cm_static_string_view.hxx" +#include <cmext/string_view> #include "cmExecutionStatus.h" #include "cmFunctionBlocker.h" diff --git a/Source/cmFunctionCommand.cxx b/Source/cmFunctionCommand.cxx index a4c9072..b6f58bd 100644 --- a/Source/cmFunctionCommand.cxx +++ b/Source/cmFunctionCommand.cxx @@ -7,8 +7,7 @@ #include <cm/memory> #include <cm/string_view> #include <cmext/algorithm> - -#include "cm_static_string_view.hxx" +#include <cmext/string_view> #include "cmExecutionStatus.h" #include "cmFunctionBlocker.h" diff --git a/Source/cmGeneratorExpressionDAGChecker.cxx b/Source/cmGeneratorExpressionDAGChecker.cxx index b4ba1a1..4f379cd 100644 --- a/Source/cmGeneratorExpressionDAGChecker.cxx +++ b/Source/cmGeneratorExpressionDAGChecker.cxx @@ -7,8 +7,7 @@ #include <utility> #include <cm/string_view> - -#include "cm_static_string_view.hxx" +#include <cmext/string_view> #include "cmGeneratorExpressionContext.h" #include "cmGeneratorExpressionEvaluator.h" diff --git a/Source/cmGeneratorExpressionNode.cxx b/Source/cmGeneratorExpressionNode.cxx index 68f466f..e3de2d8 100644 --- a/Source/cmGeneratorExpressionNode.cxx +++ b/Source/cmGeneratorExpressionNode.cxx @@ -17,12 +17,11 @@ #include <cm/string_view> #include <cm/vector> #include <cmext/algorithm> +#include <cmext/string_view> #include "cmsys/RegularExpression.hxx" #include "cmsys/String.h" -#include "cm_static_string_view.hxx" - #include "cmAlgorithms.h" #include "cmGeneratorExpression.h" #include "cmGeneratorExpressionContext.h" diff --git a/Source/cmGeneratorTarget.cxx b/Source/cmGeneratorTarget.cxx index 509df93..62427f6 100644 --- a/Source/cmGeneratorTarget.cxx +++ b/Source/cmGeneratorTarget.cxx @@ -18,11 +18,10 @@ #include <cm/memory> #include <cm/string_view> #include <cmext/algorithm> +#include <cmext/string_view> #include "cmsys/RegularExpression.hxx" -#include "cm_static_string_view.hxx" - #include "cmAlgorithms.h" #include "cmComputeLinkInformation.h" #include "cmCustomCommand.h" @@ -388,14 +387,16 @@ cmProp cmGeneratorTarget::GetProperty(const std::string& prop) const return this->Target->GetProperty(prop); } -const char* cmGeneratorTarget::GetSafeProperty(const std::string& prop) const +std::string const& cmGeneratorTarget::GetSafeProperty( + std::string const& prop) const { cmProp ret = this->GetProperty(prop); - if (!ret) { - return ""; + if (ret) { + return *ret; } - return ret->c_str(); + static std::string const s_empty; + return s_empty; } const char* cmGeneratorTarget::GetOutputTargetType( @@ -3988,7 +3989,8 @@ std::string cmGeneratorTarget::GetPchUseCompileOptions( const std::string useOptVar = cmStrCat(language, "_COMPILE_OPTIONS_USE_PCH"); - const std::string useOptionListProperty = this->GetSafeProperty(useOptVar); + std::string const& useOptionListProperty = + this->GetSafeProperty(useOptVar); useOptionList = cmStrCat( useOptionList, ";", diff --git a/Source/cmGeneratorTarget.h b/Source/cmGeneratorTarget.h index dc98407..2ef7b43 100644 --- a/Source/cmGeneratorTarget.h +++ b/Source/cmGeneratorTarget.h @@ -80,7 +80,7 @@ public: //! Might return a nullptr if the property is not set or invalid cmProp GetProperty(const std::string& prop) const; //! Always returns a valid pointer - const char* GetSafeProperty(const std::string& prop) const; + std::string const& GetSafeProperty(std::string const& prop) const; bool GetPropertyAsBool(const std::string& prop) const; void GetSourceFiles(std::vector<cmSourceFile*>& files, const std::string& config) const; diff --git a/Source/cmGlobalGenerator.cxx b/Source/cmGlobalGenerator.cxx index 2664fb0..de6a649 100644 --- a/Source/cmGlobalGenerator.cxx +++ b/Source/cmGlobalGenerator.cxx @@ -232,7 +232,7 @@ void cmGlobalGenerator::ResolveLanguageCompiler(const std::string& lang, if (!optional && (path.empty() || !cmSystemTools::FileExists(path))) { return; } - const std::string* cname = + cmProp cname = this->GetCMakeInstance()->GetState()->GetInitializedCacheValue(langComp); std::string changeVars; if (cname && !optional) { @@ -384,9 +384,9 @@ bool cmGlobalGenerator::CheckTargetsForPchCompilePdb() const } } - const std::string reuseFrom = + std::string const& reuseFrom = target->GetSafeProperty("PRECOMPILE_HEADERS_REUSE_FROM"); - const std::string compilePdb = + std::string const& compilePdb = target->GetSafeProperty("COMPILE_PDB_NAME"); if (!reuseFrom.empty() && reuseFrom != compilePdb) { @@ -2057,9 +2057,8 @@ void cmGlobalGenerator::AddMakefile(std::unique_ptr<cmMakefile> mf) // update progress // estimate how many lg there will be - const std::string* numGenC = - this->CMakeInstance->GetState()->GetInitializedCacheValue( - "CMAKE_NUMBER_OF_MAKEFILES"); + cmProp numGenC = this->CMakeInstance->GetState()->GetInitializedCacheValue( + "CMAKE_NUMBER_OF_MAKEFILES"); if (!numGenC) { // If CMAKE_NUMBER_OF_MAKEFILES is not set diff --git a/Source/cmGlobalXCodeGenerator.cxx b/Source/cmGlobalXCodeGenerator.cxx index 77fa6fa..cda3338 100644 --- a/Source/cmGlobalXCodeGenerator.cxx +++ b/Source/cmGlobalXCodeGenerator.cxx @@ -808,7 +808,7 @@ cmXCodeObject* cmGlobalXCodeGenerator::CreateXCodeSourceFile( // Add flags from target and source file properties. std::string flags; - const std::string srcfmt = sf->GetSafeProperty("Fortran_FORMAT"); + std::string const& srcfmt = sf->GetSafeProperty("Fortran_FORMAT"); switch (cmOutputConverter::GetFortranFormat(srcfmt)) { case cmOutputConverter::FortranFormatFixed: flags = "-fixed " + flags; @@ -2289,7 +2289,7 @@ void cmGlobalXCodeGenerator::CreateBuildSettings(cmGeneratorTarget* gtgt, // Add Fortran source format attribute if property is set. const char* format = nullptr; - const std::string tgtfmt = gtgt->GetSafeProperty("Fortran_FORMAT"); + std::string const& tgtfmt = gtgt->GetSafeProperty("Fortran_FORMAT"); switch (cmOutputConverter::GetFortranFormat(tgtfmt)) { case cmOutputConverter::FortranFormatFixed: format = "fixed"; @@ -2416,7 +2416,7 @@ void cmGlobalXCodeGenerator::CreateBuildSettings(cmGeneratorTarget* gtgt, std::string attribute = prop.substr(16); this->FilterConfigurationAttribute(configName, attribute); if (!attribute.empty()) { - const std::string pr = gtgt->GetSafeProperty(prop); + std::string const& pr = gtgt->GetSafeProperty(prop); std::string processed = cmGeneratorExpression::Evaluate( pr, this->CurrentLocalGenerator, configName); buildSettings->AddAttribute(attribute, diff --git a/Source/cmIfCommand.cxx b/Source/cmIfCommand.cxx index 290e064..5808f90 100644 --- a/Source/cmIfCommand.cxx +++ b/Source/cmIfCommand.cxx @@ -7,8 +7,7 @@ #include <cm/memory> #include <cm/string_view> - -#include "cm_static_string_view.hxx" +#include <cmext/string_view> #include "cmConditionEvaluator.h" #include "cmExecutionStatus.h" diff --git a/Source/cmInstallCommand.cxx b/Source/cmInstallCommand.cxx index c9b22b6..ac57bc2 100644 --- a/Source/cmInstallCommand.cxx +++ b/Source/cmInstallCommand.cxx @@ -8,11 +8,10 @@ #include <utility> #include <cm/memory> +#include <cmext/string_view> #include "cmsys/Glob.hxx" -#include "cm_static_string_view.hxx" - #include "cmArgumentParser.h" #include "cmExecutionStatus.h" #include "cmExportSet.h" diff --git a/Source/cmInstallCommandArguments.cxx b/Source/cmInstallCommandArguments.cxx index 31ba63f..a034689 100644 --- a/Source/cmInstallCommandArguments.cxx +++ b/Source/cmInstallCommandArguments.cxx @@ -4,7 +4,7 @@ #include <utility> -#include "cm_static_string_view.hxx" +#include <cmext/string_view> #include "cmRange.h" #include "cmSystemTools.h" diff --git a/Source/cmListCommand.cxx b/Source/cmListCommand.cxx index 1d82dfc..edec613 100644 --- a/Source/cmListCommand.cxx +++ b/Source/cmListCommand.cxx @@ -17,11 +17,10 @@ #include <cm/memory> #include <cmext/algorithm> +#include <cmext/string_view> #include "cmsys/RegularExpression.hxx" -#include "cm_static_string_view.hxx" - #include "cmAlgorithms.h" #include "cmExecutionStatus.h" #include "cmGeneratorExpression.h" diff --git a/Source/cmLocalGenerator.cxx b/Source/cmLocalGenerator.cxx index a2208e5..b862449 100644 --- a/Source/cmLocalGenerator.cxx +++ b/Source/cmLocalGenerator.cxx @@ -2670,7 +2670,8 @@ void cmLocalGenerator::AddPchDependencies(cmGeneratorTarget* target) std::string dest_file = to_file; - const std::string prefix = target->GetSafeProperty("PREFIX"); + std::string const& prefix = + target->GetSafeProperty("PREFIX"); if (!prefix.empty()) { dest_file = cmStrCat(to_dir, prefix, *ReuseFrom, extension); diff --git a/Source/cmMacroCommand.cxx b/Source/cmMacroCommand.cxx index 0b0d9ac..c88b343 100644 --- a/Source/cmMacroCommand.cxx +++ b/Source/cmMacroCommand.cxx @@ -8,8 +8,7 @@ #include <cm/memory> #include <cm/string_view> #include <cmext/algorithm> - -#include "cm_static_string_view.hxx" +#include <cmext/string_view> #include "cmExecutionStatus.h" #include "cmFunctionBlocker.h" diff --git a/Source/cmMakefile.cxx b/Source/cmMakefile.cxx index 028b0f5..6c46353 100644 --- a/Source/cmMakefile.cxx +++ b/Source/cmMakefile.cxx @@ -18,13 +18,13 @@ #include <cm/optional> #include <cm/vector> #include <cmext/algorithm> +#include <cmext/string_view> #include "cmsys/FStream.hxx" #include "cmsys/RegularExpression.hxx" #include "cm_jsoncpp_value.h" #include "cm_jsoncpp_writer.h" -#include "cm_static_string_view.hxx" #include "cm_sys_stat.h" #include "cmCommandArgumentParserHelper.h" @@ -1880,8 +1880,7 @@ void cmMakefile::AddCacheDefinition(const std::string& name, const char* value, cmStateEnums::CacheEntryType type, bool force) { - const std::string* existingValue = - this->GetState()->GetInitializedCacheValue(name); + cmProp existingValue = this->GetState()->GetInitializedCacheValue(name); // must be outside the following if() to keep it alive long enough std::string nvalue; @@ -2682,7 +2681,7 @@ const std::string& cmMakefile::GetRequiredDefinition( bool cmMakefile::IsDefinitionSet(const std::string& name) const { - const std::string* def = this->StateSnapshot.GetDefinition(name); + cmProp def = this->StateSnapshot.GetDefinition(name); if (!def) { def = this->GetState()->GetInitializedCacheValue(name); } @@ -2699,7 +2698,7 @@ bool cmMakefile::IsDefinitionSet(const std::string& name) const const std::string* cmMakefile::GetDef(const std::string& name) const { - const std::string* def = this->StateSnapshot.GetDefinition(name); + cmProp def = this->StateSnapshot.GetDefinition(name); if (!def) { def = this->GetState()->GetInitializedCacheValue(name); } diff --git a/Source/cmMessageCommand.cxx b/Source/cmMessageCommand.cxx index bf8183b..c7bb9a7 100644 --- a/Source/cmMessageCommand.cxx +++ b/Source/cmMessageCommand.cxx @@ -6,8 +6,7 @@ #include <utility> #include <cm/string_view> - -#include "cm_static_string_view.hxx" +#include <cmext/string_view> #include "cmExecutionStatus.h" #include "cmMakefile.h" diff --git a/Source/cmQtAutoGenGlobalInitializer.cxx b/Source/cmQtAutoGenGlobalInitializer.cxx index 18b135d..a32f3e7 100644 --- a/Source/cmQtAutoGenGlobalInitializer.cxx +++ b/Source/cmQtAutoGenGlobalInitializer.cxx @@ -95,11 +95,11 @@ cmQtAutoGenGlobalInitializer::cmQtAutoGenGlobalInitializer( bool const uic = target->GetPropertyAsBool(kw().AUTOUIC); bool const rcc = target->GetPropertyAsBool(kw().AUTORCC); if (moc || uic || rcc) { - std::string const mocExec = + std::string const& mocExec = target->GetSafeProperty(kw().AUTOMOC_EXECUTABLE); - std::string const uicExec = + std::string const& uicExec = target->GetSafeProperty(kw().AUTOUIC_EXECUTABLE); - std::string const rccExec = + std::string const& rccExec = target->GetSafeProperty(kw().AUTORCC_EXECUTABLE); // We support Qt4, Qt5 and Qt6 diff --git a/Source/cmQtAutoGenInitializer.cxx b/Source/cmQtAutoGenInitializer.cxx index fa523cc..235ee38 100644 --- a/Source/cmQtAutoGenInitializer.cxx +++ b/Source/cmQtAutoGenInitializer.cxx @@ -440,7 +440,8 @@ bool cmQtAutoGenInitializer::InitCustomTargets() // Autogen target parallel processing { - std::string prop = this->GenTarget->GetSafeProperty("AUTOGEN_PARALLEL"); + std::string const& prop = + this->GenTarget->GetSafeProperty("AUTOGEN_PARALLEL"); if (prop.empty() || (prop == "AUTO")) { // Autodetect number of CPUs this->AutogenTarget.Parallel = GetParallelCPUCount(); @@ -471,7 +472,7 @@ bool cmQtAutoGenInitializer::InitCustomTargets() this->AutogenTarget.DependOrigin = this->GenTarget->GetPropertyAsBool("AUTOGEN_ORIGIN_DEPENDS"); - std::string const deps = + std::string const& deps = this->GenTarget->GetSafeProperty("AUTOGEN_TARGET_DEPENDS"); if (!deps.empty()) { for (std::string const& depName : cmExpandedList(deps)) { @@ -654,7 +655,7 @@ bool cmQtAutoGenInitializer::InitUic() { // Uic search paths { - std::string const usp = + std::string const& usp = this->GenTarget->GetSafeProperty("AUTOUIC_SEARCH_PATHS"); if (!usp.empty()) { this->Uic.SearchPaths = @@ -1794,7 +1795,7 @@ bool cmQtAutoGenInitializer::GetQtExecutable(GenVarsT& genVars, // Custom executable { std::string const prop = cmStrCat(genVars.GenNameUpper, "_EXECUTABLE"); - std::string const val = this->GenTarget->Target->GetSafeProperty(prop); + std::string const& val = this->GenTarget->Target->GetSafeProperty(prop); if (!val.empty()) { // Evaluate generator expression { diff --git a/Source/cmServerProtocol.cxx b/Source/cmServerProtocol.cxx index 10e6317..f6154eb 100644 --- a/Source/cmServerProtocol.cxx +++ b/Source/cmServerProtocol.cxx @@ -26,6 +26,8 @@ #include "cmSystemTools.h" #include "cmake.h" +using cmProp = const std::string*; // just to silence IWYU + // Get rid of some windows macros: #undef max @@ -562,7 +564,7 @@ cmServerResponse cmServerProtocol1::ProcessConfigure( if (cm->LoadCache(buildDir)) { // build directory has been set up before - const std::string* cachedSourceDir = + cmProp cachedSourceDir = cm->GetState()->GetInitializedCacheValue("CMAKE_HOME_DIRECTORY"); if (!cachedSourceDir) { return request.ReportError("No CMAKE_HOME_DIRECTORY found in cache."); @@ -572,7 +574,7 @@ cmServerResponse cmServerProtocol1::ProcessConfigure( cm->SetHomeDirectory(sourceDir); } - const std::string* cachedGenerator = + cmProp cachedGenerator = cm->GetState()->GetInitializedCacheValue("CMAKE_GENERATOR"); if (cachedGenerator) { if (gg && gg->GetName() != *cachedGenerator) { diff --git a/Source/cmState.cxx b/Source/cmState.cxx index 2e748d3..df013f4 100644 --- a/Source/cmState.cxx +++ b/Source/cmState.cxx @@ -155,8 +155,7 @@ std::string cmState::GetSafeCacheEntryValue(std::string const& key) const return std::string(); } -const std::string* cmState::GetInitializedCacheValue( - std::string const& key) const +cmProp cmState::GetInitializedCacheValue(std::string const& key) const { return this->CacheManager->GetInitializedCacheValue(key); } diff --git a/Source/cmState.h b/Source/cmState.h index e3fbfdc..e966935 100644 --- a/Source/cmState.h +++ b/Source/cmState.h @@ -92,7 +92,7 @@ public: std::vector<std::string> GetCacheEntryKeys() const; cmProp GetCacheEntryValue(std::string const& key) const; std::string GetSafeCacheEntryValue(std::string const& key) const; - const std::string* GetInitializedCacheValue(std::string const& key) const; + cmProp GetInitializedCacheValue(std::string const& key) const; cmStateEnums::CacheEntryType GetCacheEntryType(std::string const& key) const; void SetCacheEntryValue(std::string const& key, std::string const& value); void SetCacheValue(std::string const& key, std::string const& value); diff --git a/Source/cmString.hxx b/Source/cmString.hxx index 9e91986..87bfdff 100644 --- a/Source/cmString.hxx +++ b/Source/cmString.hxx @@ -16,8 +16,7 @@ #include <utility> #include <cm/string_view> - -#include "cm_static_string_view.hxx" +#include <cmext/string_view> namespace cm { diff --git a/Source/cmStringCommand.cxx b/Source/cmStringCommand.cxx index 7662204..a7c21cc 100644 --- a/Source/cmStringCommand.cxx +++ b/Source/cmStringCommand.cxx @@ -11,11 +11,10 @@ #include <memory> #include <cm/iterator> +#include <cmext/string_view> #include "cmsys/RegularExpression.hxx" -#include "cm_static_string_view.hxx" - #include "cmCryptoHash.h" #include "cmExecutionStatus.h" #include "cmGeneratorExpression.h" diff --git a/Source/cmSubcommandTable.h b/Source/cmSubcommandTable.h index 65eb8c7..7deaaed 100644 --- a/Source/cmSubcommandTable.h +++ b/Source/cmSubcommandTable.h @@ -11,8 +11,7 @@ #include <vector> #include <cm/string_view> - -#include "cm_static_string_view.hxx" +#include <cmext/string_view> class cmExecutionStatus; diff --git a/Source/cmTarget.cxx b/Source/cmTarget.cxx index 955a5cc..a776398 100644 --- a/Source/cmTarget.cxx +++ b/Source/cmTarget.cxx @@ -1789,13 +1789,15 @@ cmProp cmTarget::GetProperty(const std::string& prop) const return retVal; } -const char* cmTarget::GetSafeProperty(const std::string& prop) const +std::string const& cmTarget::GetSafeProperty(std::string const& prop) const { cmProp ret = this->GetProperty(prop); - if (!ret) { - return ""; + if (ret) { + return *ret; } - return ret->c_str(); + + static std::string const s_empty; + return s_empty; } bool cmTarget::GetPropertyAsBool(const std::string& prop) const diff --git a/Source/cmTarget.h b/Source/cmTarget.h index ddc3b9b..8fecd41 100644 --- a/Source/cmTarget.h +++ b/Source/cmTarget.h @@ -174,7 +174,7 @@ public: //! Might return a nullptr if the property is not set or invalid cmProp GetProperty(const std::string& prop) const; //! Always returns a valid pointer - const char* GetSafeProperty(const std::string& prop) const; + std::string const& GetSafeProperty(std::string const& prop) const; bool GetPropertyAsBool(const std::string& prop) const; void CheckProperty(const std::string& prop, cmMakefile* context) const; cmProp GetComputedProperty(const std::string& prop, cmMessenger* messenger, diff --git a/Source/cmVisualStudio10TargetGenerator.cxx b/Source/cmVisualStudio10TargetGenerator.cxx index 9c2b302..2b20a00 100644 --- a/Source/cmVisualStudio10TargetGenerator.cxx +++ b/Source/cmVisualStudio10TargetGenerator.cxx @@ -909,7 +909,7 @@ void cmVisualStudio10TargetGenerator::WriteDotNetReferenceCustomTags( void cmVisualStudio10TargetGenerator::WriteDotNetDocumentationFile(Elem& e0) { - std::string const documentationFile = + std::string const& documentationFile = this->GeneratorTarget->GetSafeProperty("VS_DOTNET_DOCUMENTATION_FILE"); if (this->ProjectType == csproj && !documentationFile.empty()) { diff --git a/Source/cmWhileCommand.cxx b/Source/cmWhileCommand.cxx index 26e7c75..0d8e894 100644 --- a/Source/cmWhileCommand.cxx +++ b/Source/cmWhileCommand.cxx @@ -7,8 +7,7 @@ #include <cm/memory> #include <cm/string_view> - -#include "cm_static_string_view.hxx" +#include <cmext/string_view> #include "cmConditionEvaluator.h" #include "cmExecutionStatus.h" diff --git a/Source/cmXCodeScheme.cxx b/Source/cmXCodeScheme.cxx index aab367a..9ac1457 100644 --- a/Source/cmXCodeScheme.cxx +++ b/Source/cmXCodeScheme.cxx @@ -405,8 +405,9 @@ void cmXCodeScheme::WriteBuildableReference(cmXMLWriter& xout, void cmXCodeScheme::WriteCustomWorkingDirectory( cmXMLWriter& xout, const std::string& configuration) { - std::string propertyValue = this->Target->GetTarget()->GetSafeProperty( - "XCODE_SCHEME_WORKING_DIRECTORY"); + std::string const& propertyValue = + this->Target->GetTarget()->GetSafeProperty( + "XCODE_SCHEME_WORKING_DIRECTORY"); if (propertyValue.empty()) { xout.Attribute("useCustomWorkingDirectory", "NO"); } else { diff --git a/Source/cmake.cxx b/Source/cmake.cxx index d81f975..057d54d 100644 --- a/Source/cmake.cxx +++ b/Source/cmake.cxx @@ -19,12 +19,12 @@ #endif #include <cmext/algorithm> +#include <cmext/string_view> #include "cmsys/FStream.hxx" #include "cmsys/Glob.hxx" #include "cmsys/RegularExpression.hxx" -#include "cm_static_string_view.hxx" #include "cm_sys_stat.h" #include "cmCommands.h" @@ -315,8 +315,7 @@ bool cmake::SetCacheArgs(const std::vector<std::string>& args) bool haveValue = false; std::string cachedValue; if (this->WarnUnusedCli) { - if (const std::string* v = - this->State->GetInitializedCacheValue(var)) { + if (cmProp v = this->State->GetInitializedCacheValue(var)) { haveValue = true; cachedValue = *v; } @@ -1531,9 +1530,8 @@ int cmake::ActualConfigure() // no generator specified on the command line if (!this->GlobalGenerator) { - const std::string* genName = - this->State->GetInitializedCacheValue("CMAKE_GENERATOR"); - const std::string* extraGenName = + cmProp genName = this->State->GetInitializedCacheValue("CMAKE_GENERATOR"); + cmProp extraGenName = this->State->GetInitializedCacheValue("CMAKE_EXTRA_GENERATOR"); if (genName) { std::string fullName = @@ -1556,8 +1554,7 @@ int cmake::ActualConfigure() } } - const std::string* genName = - this->State->GetInitializedCacheValue("CMAKE_GENERATOR"); + cmProp genName = this->State->GetInitializedCacheValue("CMAKE_GENERATOR"); if (genName) { if (!this->GlobalGenerator->MatchesGeneratorName(*genName)) { std::string message = @@ -1579,7 +1576,7 @@ int cmake::ActualConfigure() cmStateEnums::INTERNAL); } - if (const std::string* instance = + if (cmProp instance = this->State->GetInitializedCacheValue("CMAKE_GENERATOR_INSTANCE")) { if (this->GeneratorInstanceSet && this->GeneratorInstance != *instance) { std::string message = @@ -1596,7 +1593,7 @@ int cmake::ActualConfigure() "Generator instance identifier.", cmStateEnums::INTERNAL); } - if (const std::string* platformName = + if (cmProp platformName = this->State->GetInitializedCacheValue("CMAKE_GENERATOR_PLATFORM")) { if (this->GeneratorPlatformSet && this->GeneratorPlatform != *platformName) { @@ -1614,7 +1611,7 @@ int cmake::ActualConfigure() "Name of generator platform.", cmStateEnums::INTERNAL); } - if (const std::string* tsName = + if (cmProp tsName = this->State->GetInitializedCacheValue("CMAKE_GENERATOR_TOOLSET")) { if (this->GeneratorToolsetSet && this->GeneratorToolset != *tsName) { std::string message = @@ -1985,7 +1982,7 @@ std::string cmake::StripExtension(const std::string& file) const const char* cmake::GetCacheDefinition(const std::string& name) const { - const std::string* p = this->State->GetInitializedCacheValue(name); + cmProp p = this->State->GetInitializedCacheValue(name); return p ? p->c_str() : nullptr; } @@ -2192,7 +2189,7 @@ void cmake::PrintGeneratorList() void cmake::UpdateConversionPathTable() { // Update the path conversion table with any specified file: - const std::string* tablepath = + cmProp tablepath = this->State->GetInitializedCacheValue("CMAKE_PATH_TRANSLATION_FILE"); if (tablepath) { @@ -2836,7 +2833,7 @@ bool cmake::Open(const std::string& dir, bool dryRun) std::cerr << "Error: could not find CMAKE_GENERATOR in Cache\n"; return false; } - const std::string* extraGenName = + cmProp extraGenName = this->State->GetInitializedCacheValue("CMAKE_EXTRA_GENERATOR"); std::string fullName = cmExternalMakefileProjectGenerator::CreateFullGeneratorName( diff --git a/Tests/CMakeLib/testArgumentParser.cxx b/Tests/CMakeLib/testArgumentParser.cxx index 20f98c2..965690c 100644 --- a/Tests/CMakeLib/testArgumentParser.cxx +++ b/Tests/CMakeLib/testArgumentParser.cxx @@ -7,8 +7,7 @@ #include <vector> #include <cm/string_view> - -#include "cm_static_string_view.hxx" +#include <cmext/string_view> #include "cmArgumentParser.h" diff --git a/Tests/CMakeLib/testString.cxx b/Tests/CMakeLib/testString.cxx index 48d2590..ad800cf 100644 --- a/Tests/CMakeLib/testString.cxx +++ b/Tests/CMakeLib/testString.cxx @@ -12,8 +12,7 @@ #include <utility> #include <cm/string_view> - -#include "cm_static_string_view.hxx" +#include <cmext/string_view> #include "cmString.hxx" diff --git a/Tests/CMakeLists.txt b/Tests/CMakeLists.txt index f44a209..3e16ab6 100644 --- a/Tests/CMakeLists.txt +++ b/Tests/CMakeLists.txt @@ -2695,9 +2695,6 @@ ${CMake_SOURCE_DIR}/Utilities/Release/push.bash --dir dev -- '${CMake_BUILD_NIGH -S "${CMake_BINARY_DIR}/Tests/CTestCoverageCollectGCOV/test.cmake" -VV --output-log "${CMake_BINARY_DIR}/Tests/CTestCoverageCollectGCOV/testOut.log" ) - set_tests_properties(CTestCoverageCollectGCOV PROPERTIES - PASS_REGULAR_EXPRESSION - "PASSED with correct output.*Testing/CoverageInfo/main.cpp.gcov") set_property(TEST CTestCoverageCollectGCOV PROPERTY ENVIRONMENT CTEST_PARALLEL_LEVEL=) configure_file( diff --git a/Tests/CTestCoverageCollectGCOV/test.cmake.in b/Tests/CTestCoverageCollectGCOV/test.cmake.in index 2c98876..1818888 100644 --- a/Tests/CTestCoverageCollectGCOV/test.cmake.in +++ b/Tests/CTestCoverageCollectGCOV/test.cmake.in @@ -3,13 +3,15 @@ set(CTEST_SOURCE_DIRECTORY "@CMake_SOURCE_DIR@/Tests/CTestCoverageCollectGCOV/Te set(CTEST_BINARY_DIRECTORY "@CMake_BINARY_DIR@/Tests/CTestCoverageCollectGCOV/TestProject") set(CTEST_CMAKE_GENERATOR "@CMAKE_GENERATOR@") -ctest_empty_binary_directory(${CTEST_BINARY_DIRECTORY}) - ctest_start(Experimental) ctest_configure() ctest_build() ctest_test() +#------------------------------------------------------------------------------# +# Common setup for all tests. +#------------------------------------------------------------------------------# + list(APPEND CTEST_CUSTOM_COVERAGE_EXCLUDE "/foo/something" "/3rdparty/" @@ -17,15 +19,118 @@ list(APPEND CTEST_CUSTOM_COVERAGE_EXCLUDE "/CMakeFiles/" ) list(APPEND CTEST_EXTRA_COVERAGE_GLOB "*.cpp") - include(CTestCoverageCollectGCOV) +set(expected_out + CMakeFiles/myexecutable.dir/Labels.json + Testing/CoverageInfo/data.json + Testing/CoverageInfo/extra.cpp.gcov + Testing/CoverageInfo/main.cpp.gcov + uncovered/extra/uncovered1.cpp + uncovered/uncovered2.cpp +) + +#------------------------------------------------------------------------------# +# Test 1: with standard arguments +#------------------------------------------------------------------------------# + +set(tar_file ${CTEST_BINARY_DIRECTORY}/gcov.tbz) +ctest_coverage_collect_gcov( + TARBALL "${tar_file}" + SOURCE "${CTEST_SOURCE_DIRECTORY}" + BUILD "${CTEST_BINARY_DIRECTORY}" + GCOV_COMMAND "${CMAKE_COMMAND}" + GCOV_OPTIONS -P "@CMake_SOURCE_DIR@/Tests/CTestCoverageCollectGCOV/fakegcov.cmake") +file(REMOVE_RECURSE "${CTEST_BINARY_DIRECTORY}/uncovered") + +execute_process(COMMAND + ${CMAKE_COMMAND} -E tar tf ${tar_file} + OUTPUT_VARIABLE out + WORKING_DIRECTORY ${CMAKE_CURRENT_LIST_DIR} + OUTPUT_STRIP_TRAILING_WHITESPACE +) + +string(REPLACE "\n" ";" out "${out}") +list(SORT out) + +if("${out}" STREQUAL "${expected_out}") + message("PASSED with correct output: ${out}") +else() + message(FATAL_ERROR "FAILED: expected:\n${expected_out}\nGot:\n${out}") +endif() + +#------------------------------------------------------------------------------# +# Test 2: with optional argument: TARBALL_COMPRESSION "GZIP" +#------------------------------------------------------------------------------# + +set(tar_file ${CTEST_BINARY_DIRECTORY}/gcov.tgz) +ctest_coverage_collect_gcov( + TARBALL "${tar_file}" + TARBALL_COMPRESSION "GZIP" + SOURCE "${CTEST_SOURCE_DIRECTORY}" + BUILD "${CTEST_BINARY_DIRECTORY}" + GCOV_COMMAND "${CMAKE_COMMAND}" + GCOV_OPTIONS -P "@CMake_SOURCE_DIR@/Tests/CTestCoverageCollectGCOV/fakegcov.cmake") +file(REMOVE_RECURSE "${CTEST_BINARY_DIRECTORY}/uncovered") + +execute_process(COMMAND + ${CMAKE_COMMAND} -E tar tf ${tar_file} + OUTPUT_VARIABLE out + WORKING_DIRECTORY ${CMAKE_CURRENT_LIST_DIR} + OUTPUT_STRIP_TRAILING_WHITESPACE +) + +string(REPLACE "\n" ";" out "${out}") +list(SORT out) + +if("${out}" STREQUAL "${expected_out}") + message("PASSED with correct output: ${out}") +else() + message(FATAL_ERROR "FAILED: expected:\n${expected_out}\nGot:\n${out}") +endif() + +#------------------------------------------------------------------------------# +# Test 3: with optional argument: TARBALL_COMPRESSION "FROM_EXT" +#------------------------------------------------------------------------------# + +set(tar_file ${CTEST_BINARY_DIRECTORY}/gcov.txz) +ctest_coverage_collect_gcov( + TARBALL "${tar_file}" + TARBALL_COMPRESSION "FROM_EXT" + SOURCE "${CTEST_SOURCE_DIRECTORY}" + BUILD "${CTEST_BINARY_DIRECTORY}" + GCOV_COMMAND "${CMAKE_COMMAND}" + GCOV_OPTIONS -P "@CMake_SOURCE_DIR@/Tests/CTestCoverageCollectGCOV/fakegcov.cmake") +file(REMOVE_RECURSE "${CTEST_BINARY_DIRECTORY}/uncovered") + +execute_process(COMMAND + ${CMAKE_COMMAND} -E tar tf ${tar_file} + OUTPUT_VARIABLE out + WORKING_DIRECTORY ${CMAKE_CURRENT_LIST_DIR} + OUTPUT_STRIP_TRAILING_WHITESPACE +) + +string(REPLACE "\n" ";" out "${out}") +list(SORT out) + +if("${out}" STREQUAL "${expected_out}") + message("PASSED with correct output: ${out}") +else() + message(FATAL_ERROR "FAILED: expected:\n${expected_out}\nGot:\n${out}") +endif() + +#------------------------------------------------------------------------------# +# Test 4: with optional argument: TARBALL_COMPRESSION "FALSE" +#------------------------------------------------------------------------------# + set(tar_file ${CTEST_BINARY_DIRECTORY}/gcov.tar) ctest_coverage_collect_gcov( TARBALL "${tar_file}" + TARBALL_COMPRESSION "FALSE" SOURCE "${CTEST_SOURCE_DIRECTORY}" BUILD "${CTEST_BINARY_DIRECTORY}" GCOV_COMMAND "${CMAKE_COMMAND}" GCOV_OPTIONS -P "@CMake_SOURCE_DIR@/Tests/CTestCoverageCollectGCOV/fakegcov.cmake") +file(REMOVE_RECURSE "${CTEST_BINARY_DIRECTORY}/uncovered") execute_process(COMMAND ${CMAKE_COMMAND} -E tar tf ${tar_file} @@ -37,15 +142,36 @@ execute_process(COMMAND string(REPLACE "\n" ";" out "${out}") list(SORT out) -set(expected_out - CMakeFiles/myexecutable.dir/Labels.json - Testing/CoverageInfo/data.json - Testing/CoverageInfo/extra.cpp.gcov - Testing/CoverageInfo/main.cpp.gcov - uncovered/extra/uncovered1.cpp - uncovered/uncovered2.cpp +if("${out}" STREQUAL "${expected_out}") + message("PASSED with correct output: ${out}") +else() + message(FATAL_ERROR "FAILED: expected:\n${expected_out}\nGot:\n${out}") +endif() + +#------------------------------------------------------------------------------# +# Test 5: with optional argument: TARBALL_COMPRESSION "ZSTD" +#------------------------------------------------------------------------------# + +set(tar_file ${CTEST_BINARY_DIRECTORY}/gcov.zstd) +ctest_coverage_collect_gcov( + TARBALL "${tar_file}" + TARBALL_COMPRESSION "ZSTD" + SOURCE "${CTEST_SOURCE_DIRECTORY}" + BUILD "${CTEST_BINARY_DIRECTORY}" + GCOV_COMMAND "${CMAKE_COMMAND}" + GCOV_OPTIONS -P "@CMake_SOURCE_DIR@/Tests/CTestCoverageCollectGCOV/fakegcov.cmake") +file(REMOVE_RECURSE "${CTEST_BINARY_DIRECTORY}/uncovered") + +execute_process(COMMAND + ${CMAKE_COMMAND} -E tar tf ${tar_file} + OUTPUT_VARIABLE out + WORKING_DIRECTORY ${CMAKE_CURRENT_LIST_DIR} + OUTPUT_STRIP_TRAILING_WHITESPACE ) +string(REPLACE "\n" ";" out "${out}") +list(SORT out) + if("${out}" STREQUAL "${expected_out}") message("PASSED with correct output: ${out}") else() diff --git a/Tests/RunCMake/FPHSA/FindUseComponents.cmake b/Tests/RunCMake/FPHSA/FindUseComponents.cmake new file mode 100644 index 0000000..4168f1d --- /dev/null +++ b/Tests/RunCMake/FPHSA/FindUseComponents.cmake @@ -0,0 +1,15 @@ +# pseudo find_module + +if (UseComponents_REQUIRE_VARS) + set(FOOBAR TRUE) + set(REQUIRED_VARS REQUIRED_VARS FOOBAR) +endif() + +set (UseComponents_Comp1_FOUND TRUE) +set (UseComponents_Comp2_FOUND TRUE) +set (UseComponents_Comp3_FOUND FALSE) + +include(FindPackageHandleStandardArgs) +find_package_handle_standard_args(UseComponents ${REQUIRED_VARS} + VERSION_VAR Pseudo_VERSION + HANDLE_COMPONENTS) diff --git a/Tests/RunCMake/FPHSA/RunCMakeTest.cmake b/Tests/RunCMake/FPHSA/RunCMakeTest.cmake index 286915d..8e39090 100644 --- a/Tests/RunCMake/FPHSA/RunCMakeTest.cmake +++ b/Tests/RunCMake/FPHSA/RunCMakeTest.cmake @@ -47,3 +47,11 @@ run_cmake(custom_message_1) set(RunCMake_TEST_OPTIONS "-DCMAKE_MODULE_PATH=${CMAKE_CURRENT_LIST_DIR}" "-DCONFIG_MODE=TRUE") run_cmake(custom_message_2) run_cmake(custom_message_3) + +# check handling of components +set(RunCMake_TEST_OPTIONS "-DCMAKE_MODULE_PATH=${CMAKE_CURRENT_LIST_DIR}" "-DUseComponents_VERSION=1.2.3.4") +run_cmake(required_components) +run_cmake(required_and_optional_components) +run_cmake(all_optional_components) +list(APPEND RunCMake_TEST_OPTIONS "-DUseComponents_REQUIRE_VARS=TRUE") +run_cmake(required_components_with_vars) diff --git a/Tests/RunCMake/FPHSA/all_optional_components.cmake b/Tests/RunCMake/FPHSA/all_optional_components.cmake new file mode 100644 index 0000000..f4d8b5e --- /dev/null +++ b/Tests/RunCMake/FPHSA/all_optional_components.cmake @@ -0,0 +1,14 @@ +find_package(UseComponents OPTIONAL_COMPONENTS Comp1 Comp2 Comp3) + +if (NOT UseComponents_FOUND) + message (FATAL_ERROR "package UseComponents Not Found.") +endif() +if (NOT UseComponents_Comp1_FOUND) + message (FATAL_ERROR "package UseComponents, component Comp1 not found.") +endif() +if (NOT UseComponents_Comp2_FOUND) + message (FATAL_ERROR "package UseComponents, component Comp2 not found.") +endif() +if (UseComponents_Comp3_FOUND) + message (FATAL_ERROR "package UseComponents, component Comp2 unexpectedly found.") +endif() diff --git a/Tests/RunCMake/FPHSA/required_and_optional_components.cmake b/Tests/RunCMake/FPHSA/required_and_optional_components.cmake new file mode 100644 index 0000000..836dcac --- /dev/null +++ b/Tests/RunCMake/FPHSA/required_and_optional_components.cmake @@ -0,0 +1,14 @@ +find_package(UseComponents COMPONENTS Comp1 Comp2 OPTIONAL_COMPONENTS Comp3) + +if (NOT UseComponents_FOUND) + message (FATAL_ERROR "package UseComponents Not Found.") +endif() +if (NOT UseComponents_Comp1_FOUND) + message (FATAL_ERROR "package UseComponents, component Comp1 not found.") +endif() +if (NOT UseComponents_Comp2_FOUND) + message (FATAL_ERROR "package UseComponents, component Comp2 not found.") +endif() +if (UseComponents_Comp3_FOUND) + message (FATAL_ERROR "package UseComponents, component Comp2 unexpectedly found.") +endif() diff --git a/Tests/RunCMake/FPHSA/required_components.cmake b/Tests/RunCMake/FPHSA/required_components.cmake new file mode 100644 index 0000000..0dd8e9c --- /dev/null +++ b/Tests/RunCMake/FPHSA/required_components.cmake @@ -0,0 +1,11 @@ +find_package(UseComponents COMPONENTS Comp1 Comp2) + +if (NOT UseComponents_FOUND) + message (FATAL_ERROR "package UseComponents Not Found.") +endif() +if (NOT UseComponents_Comp1_FOUND) + message (FATAL_ERROR "package UseComponents, component Comp1 Not Found.") +endif() +if (NOT UseComponents_Comp2_FOUND) + message (FATAL_ERROR "package UseComponents, component Comp2 Not Found.") +endif() diff --git a/Tests/RunCMake/FPHSA/required_components_with_vars.cmake b/Tests/RunCMake/FPHSA/required_components_with_vars.cmake new file mode 100644 index 0000000..842ef15 --- /dev/null +++ b/Tests/RunCMake/FPHSA/required_components_with_vars.cmake @@ -0,0 +1 @@ +include ("required_components.cmake") diff --git a/Tests/RunCMake/ctest_start/NoStartTimeNightly-result.txt b/Tests/RunCMake/ctest_start/NoStartTimeNightly-result.txt new file mode 100644 index 0000000..b57e2de --- /dev/null +++ b/Tests/RunCMake/ctest_start/NoStartTimeNightly-result.txt @@ -0,0 +1 @@ +(-1|255) diff --git a/Tests/RunCMake/ctest_start/NoStartTimeNightly-stderr.txt b/Tests/RunCMake/ctest_start/NoStartTimeNightly-stderr.txt new file mode 100644 index 0000000..79756eb --- /dev/null +++ b/Tests/RunCMake/ctest_start/NoStartTimeNightly-stderr.txt @@ -0,0 +1,4 @@ +^WARNING: No nightly start time found please set in CTestConfig\.cmake or DartConfig\.cmake +CMake Error at [^ +]*/Tests/RunCMake/ctest_start/NoStartTimeNightly/test\.cmake:[0-9]+ \(ctest_start\): + ctest_start unknown error\.$ diff --git a/Tests/RunCMake/ctest_start/RunCMakeTest.cmake b/Tests/RunCMake/ctest_start/RunCMakeTest.cmake index da85b39..f11f1ec 100644 --- a/Tests/RunCMake/ctest_start/RunCMakeTest.cmake +++ b/Tests/RunCMake/ctest_start/RunCMakeTest.cmake @@ -48,6 +48,8 @@ run_ctest_start(TooManyArgs Experimental ${RunCMake_BINARY_DIR}/TooManyArgs-build ${RunCMake_BINARY_DIR}/TooManyArgs-build ${RunCMake_BINARY_DIR}/TooManyArgs-build) +run_ctest_start(NoStartTimeExperimental Experimental) +run_ctest_start(NoStartTimeNightly Nightly) function(run_ConfigInBuild) set(RunCMake_TEST_BINARY_DIR ${RunCMake_BINARY_DIR}/ConfigInBuild-build) diff --git a/Tests/RunCMake/ctest_start/test.cmake.in b/Tests/RunCMake/ctest_start/test.cmake.in index 8cd3cff..4063ece 100644 --- a/Tests/RunCMake/ctest_start/test.cmake.in +++ b/Tests/RunCMake/ctest_start/test.cmake.in @@ -8,7 +8,9 @@ set(CTEST_CMAKE_GENERATOR "@RunCMake_GENERATOR@") set(CTEST_CMAKE_GENERATOR_PLATFORM "@RunCMake_GENERATOR_PLATFORM@") set(CTEST_CMAKE_GENERATOR_TOOLSET "@RunCMake_GENERATOR_TOOLSET@") set(CTEST_BUILD_CONFIGURATION "$ENV{CMAKE_CONFIG_TYPE}") -set(CTEST_NIGHTLY_START_TIME "01:00:00 UTC") +if(NOT "@CASE_NAME@" MATCHES "^NoStartTime") + set(CTEST_NIGHTLY_START_TIME "01:00:00 UTC") +endif() function(setup_tests) ctest_start(${ctest_start_args}) diff --git a/Utilities/std/CMakeLists.txt b/Utilities/std/CMakeLists.txt index a72abb7..17a7aaa 100644 --- a/Utilities/std/CMakeLists.txt +++ b/Utilities/std/CMakeLists.txt @@ -9,6 +9,7 @@ set(SRCS cm/bits/string_view.cxx cm/optional cm/shared_mutex cm/string_view - cm/utility) + cm/utility + cmext/string_view) add_library(cmstd STATIC ${SRCS}) diff --git a/Source/cm_static_string_view.hxx b/Utilities/std/cmext/string_view index 708ac95..ad52b11 100644 --- a/Source/cm_static_string_view.hxx +++ b/Utilities/std/cmext/string_view @@ -1,9 +1,10 @@ +// -*-c++-*- +// vim: set ft=cpp: + /* Distributed under the OSI-approved BSD 3-Clause License. See accompanying file Copyright.txt or https://cmake.org/licensing for details. */ -#ifndef cm_static_string_view_hxx -#define cm_static_string_view_hxx - -#include "cmConfigure.h" // IWYU pragma: keep +#ifndef cmext_string_view +#define cmext_string_view #include <cstddef> |