diff options
49 files changed, 531 insertions, 125 deletions
diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index a2b3ec3..6fdb606 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -237,7 +237,7 @@ t:fedora37-makefiles-nospace: CMAKE_CI_BUILD_NAME: fedora37_makefiles_nospace CMAKE_CI_JOB_NIGHTLY: "true" -t:nvhpc22.9-ninja: +t:nvhpc22.11-ninja: extends: - .nvhpc_ninja - .cmake_test_linux_release @@ -295,6 +295,16 @@ t:cuda11.6-clang: variables: CMAKE_CI_NO_MR: "true" +t:cuda11.8-minimal-ninja: + extends: + - .cuda11.8_minimal_nvidia + - .cmake_test_linux_release + - .linux_x86_64_tags_cuda + - .run_dependent + - .needs_centos6_x86_64 + variables: + CMAKE_CI_NO_MR: "true" + t:hip4.2-radeon: extends: - .hip4.2_radeon @@ -325,6 +335,26 @@ t:linux-gcc-cxx-modules-ninja-multi: variables: CMAKE_CI_JOB_NIGHTLY: "true" +t:linux-clang-cxx-modules-ninja: + extends: + - .clang_cxx_modules_ninja + - .cmake_test_linux_release + - .linux_x86_64_tags + - .run_dependent + - .needs_centos6_x86_64 + variables: + CMAKE_CI_JOB_NIGHTLY: "true" + +t:linux-clang-cxx-modules-ninja-multi: + extends: + - .clang_cxx_modules_ninja_multi + - .cmake_test_linux_release + - .linux_x86_64_tags + - .run_dependent + - .needs_centos6_x86_64 + variables: + CMAKE_CI_JOB_NIGHTLY: "true" + b:fedora37-ninja: extends: - .fedora37_ninja diff --git a/.gitlab/ci/configure_cuda11.8_minimal_nvidia.cmake b/.gitlab/ci/configure_cuda11.8_minimal_nvidia.cmake new file mode 100644 index 0000000..519699b --- /dev/null +++ b/.gitlab/ci/configure_cuda11.8_minimal_nvidia.cmake @@ -0,0 +1,3 @@ +set(CMake_TEST_CUDA "NVIDIA" CACHE STRING "") + +include("${CMAKE_CURRENT_LIST_DIR}/configure_external_test.cmake") diff --git a/.gitlab/ci/configure_linux_clang_cxx_modules_ninja.cmake b/.gitlab/ci/configure_linux_clang_cxx_modules_ninja.cmake new file mode 100644 index 0000000..43bccdb --- /dev/null +++ b/.gitlab/ci/configure_linux_clang_cxx_modules_ninja.cmake @@ -0,0 +1,4 @@ +set(CMake_TEST_MODULE_COMPILATION "named,partitions,internal_partitions,export_bmi,install_bmi,shared" CACHE STRING "") +set(CMake_TEST_MODULE_COMPILATION_RULES "${CMAKE_CURRENT_LIST_DIR}/cxx_modules_rules_clang.cmake" CACHE STRING "") + +include("${CMAKE_CURRENT_LIST_DIR}/configure_external_test.cmake") diff --git a/.gitlab/ci/configure_linux_clang_cxx_modules_ninja_multi.cmake b/.gitlab/ci/configure_linux_clang_cxx_modules_ninja_multi.cmake new file mode 100644 index 0000000..43bccdb --- /dev/null +++ b/.gitlab/ci/configure_linux_clang_cxx_modules_ninja_multi.cmake @@ -0,0 +1,4 @@ +set(CMake_TEST_MODULE_COMPILATION "named,partitions,internal_partitions,export_bmi,install_bmi,shared" CACHE STRING "") +set(CMake_TEST_MODULE_COMPILATION_RULES "${CMAKE_CURRENT_LIST_DIR}/cxx_modules_rules_clang.cmake" CACHE STRING "") + +include("${CMAKE_CURRENT_LIST_DIR}/configure_external_test.cmake") diff --git a/.gitlab/ci/cxx_modules_rules_clang.cmake b/.gitlab/ci/cxx_modules_rules_clang.cmake new file mode 100644 index 0000000..9d75880 --- /dev/null +++ b/.gitlab/ci/cxx_modules_rules_clang.cmake @@ -0,0 +1,16 @@ +set(CMake_TEST_CXXModules_UUID "a246741c-d067-4019-a8fb-3d16b0c9d1d3") + +set(CMAKE_EXPERIMENTAL_CXX_MODULE_DYNDEP 1) +string(CONCAT CMAKE_EXPERIMENTAL_CXX_SCANDEP_SOURCE + "${CMAKE_CXX_COMPILER_CLANG_SCAN_DEPS}" + " -format=p1689 --p1689-targeted-file-name=<SOURCE> --p1689-targeted-output=<OBJECT> --" + " <DEFINES> <INCLUDES> <FLAGS> -x c++ <SOURCE>" + " > <DYNDEP_FILE>") +# No support for `-MF` discovered dependencies in `clang-scan-deps`. +set(CMAKE_EXPERIMENTAL_CXX_SCANDEP_DEPFILE_FORMAT "none") +set(CMAKE_EXPERIMENTAL_CXX_MODULE_MAP_FORMAT "clang") +set(CMAKE_EXPERIMENTAL_CXX_MODULE_MAP_FLAG "@<MODULE_MAP_FILE>") + +# Default to C++ extensions being off. Clang's modules support have trouble +# with extensions right now. +set(CMAKE_CXX_EXTENSIONS OFF) diff --git a/.gitlab/ci/docker/clang_cxx_modules/Dockerfile b/.gitlab/ci/docker/clang_cxx_modules/Dockerfile new file mode 100644 index 0000000..4e58125 --- /dev/null +++ b/.gitlab/ci/docker/clang_cxx_modules/Dockerfile @@ -0,0 +1,13 @@ +FROM fedora:37 +MAINTAINER Ben Boeckel <ben.boeckel@kitware.com> + +# Install build dependencies for packages. +COPY install_deps.sh /root/install_deps.sh +RUN sh /root/install_deps.sh + +COPY install_llvm.sh /root/install_llvm.sh +RUN sh /root/install_llvm.sh + +# Install build dependencies for CMake's CI. +COPY install_cmake_deps.sh /root/install_cmake_deps.sh +RUN sh /root/install_cmake_deps.sh diff --git a/.gitlab/ci/docker/clang_cxx_modules/install_cmake_deps.sh b/.gitlab/ci/docker/clang_cxx_modules/install_cmake_deps.sh new file mode 100755 index 0000000..465e125 --- /dev/null +++ b/.gitlab/ci/docker/clang_cxx_modules/install_cmake_deps.sh @@ -0,0 +1,7 @@ +#!/bin/sh + +set -e + +dnf install -y --setopt=install_weak_deps=False \ + file git-core +dnf clean all diff --git a/.gitlab/ci/docker/clang_cxx_modules/install_deps.sh b/.gitlab/ci/docker/clang_cxx_modules/install_deps.sh new file mode 100755 index 0000000..c1957c3 --- /dev/null +++ b/.gitlab/ci/docker/clang_cxx_modules/install_deps.sh @@ -0,0 +1,7 @@ +#!/bin/sh + +set -e + +dnf install -y --setopt=install_weak_deps=False \ + gcc-c++ cmake ninja-build +dnf clean all diff --git a/.gitlab/ci/docker/clang_cxx_modules/install_llvm.sh b/.gitlab/ci/docker/clang_cxx_modules/install_llvm.sh new file mode 100755 index 0000000..09d0106 --- /dev/null +++ b/.gitlab/ci/docker/clang_cxx_modules/install_llvm.sh @@ -0,0 +1,39 @@ +#!/bin/sh + +set -e + +readonly revision="p1689r5-cmake-ci-20221201" # ae3b5489585b60a2b7f090ebb9e1e8729b811253 +readonly tarball="https://github.com/mathstuf/llvm-project/archive/$revision.tar.gz" + +readonly workdir="$HOME/llvm" +readonly srcdir="$workdir/llvm" +readonly builddir="$workdir/build" + +mkdir -p "$workdir" +cd "$workdir" +curl -L "$tarball" > "llvm-$revision.tar.gz" +tar xf "llvm-$revision.tar.gz" +mv "llvm-project-$revision" "$srcdir" +mkdir -p "$builddir" +cd "$builddir" +cmake -GNinja \ + -DCMAKE_BUILD_TYPE=Release \ + -DBUILD_SHARED_LIBS=ON \ + -DLLVM_ENABLE_BINDINGS=OFF \ + -DLLVM_INCLUDE_BENCHMARKS=OFF \ + -DLLVM_INCLUDE_DOCS=OFF \ + -DLLVM_INCLUDE_EXAMPLES=OFF \ + -DLLVM_INCLUDE_RUNTIMES=OFF \ + -DLLVM_INCLUDE_TESTS=OFF \ + -DLLVM_INCLUDE_UTILS=OFF \ + -DLLVM_TARGETS_TO_BUILD=X86 \ + -DLLVM_TOOL_CLANG_BUILD=ON \ + -DLLVM_USE_SYMLINKS=ON \ + "-DLLVM_EXTERNAL_CLANG_SOURCE_DIR=$srcdir/clang" \ + -DLLVM_PARALLEL_LINK_JOBS=1 \ + -DCLANG_BUILD_TOOLS=ON \ + "-DCMAKE_INSTALL_PREFIX=/opt/llvm-p1689" \ + "$srcdir/llvm" +ninja +ninja install/strip +rm -rf "$workdir" diff --git a/.gitlab/ci/docker/cuda11.8-minimal/Dockerfile b/.gitlab/ci/docker/cuda11.8-minimal/Dockerfile new file mode 100644 index 0000000..02e096e --- /dev/null +++ b/.gitlab/ci/docker/cuda11.8-minimal/Dockerfile @@ -0,0 +1,5 @@ +FROM nvidia/cuda:11.8.0-devel-ubuntu20.04 +MAINTAINER Robert Maynard <rmaynard@nvidia.com> + +COPY install_deps.sh /root/install_deps.sh +RUN sh /root/install_deps.sh diff --git a/.gitlab/ci/docker/cuda11.8-minimal/install_deps.sh b/.gitlab/ci/docker/cuda11.8-minimal/install_deps.sh new file mode 100755 index 0000000..55f4ce5 --- /dev/null +++ b/.gitlab/ci/docker/cuda11.8-minimal/install_deps.sh @@ -0,0 +1,26 @@ +#!/bin/sh + +set -e + +apt-get update + +# Install dependency without interaction. +env DEBIAN_FRONTEND=noninteractive \ + TZ=America/New_York \ + apt-get install -y \ + tzdata + +# Install development tools. +apt-get install -y \ + g++ \ + curl \ + git + +# Reduce to minimal subset of libraries by removing static libraries +mkdir /tmp/cuda_required +mv /usr/local/cuda/lib64/libcuda* /tmp/cuda_required/ +rm -f /usr/local/cuda/lib64/*static.a +mv /tmp/cuda_required/libcuda* /usr/local/cuda/lib64/ +rmdir /tmp/cuda_required + +apt-get clean diff --git a/.gitlab/ci/docker/nvhpc22.9/Dockerfile b/.gitlab/ci/docker/nvhpc22.11/Dockerfile index 90e7d12..52f4f8e 100644 --- a/.gitlab/ci/docker/nvhpc22.9/Dockerfile +++ b/.gitlab/ci/docker/nvhpc22.11/Dockerfile @@ -1,5 +1,5 @@ # https://catalog.ngc.nvidia.com/orgs/nvidia/containers/nvhpc/tags -FROM nvcr.io/nvidia/nvhpc:22.9-devel-cuda_multi-ubuntu22.04 +FROM nvcr.io/nvidia/nvhpc:22.11-devel-cuda_multi-ubuntu22.04 MAINTAINER Brad King <brad.king@kitware.com> COPY install_deps.sh /root/install_deps.sh diff --git a/.gitlab/ci/docker/nvhpc22.9/install_deps.sh b/.gitlab/ci/docker/nvhpc22.11/install_deps.sh index 51ee410..51ee410 100755 --- a/.gitlab/ci/docker/nvhpc22.9/install_deps.sh +++ b/.gitlab/ci/docker/nvhpc22.11/install_deps.sh diff --git a/.gitlab/ci/post_build.sh b/.gitlab/ci/post_build.sh new file mode 100755 index 0000000..0edd9f6 --- /dev/null +++ b/.gitlab/ci/post_build.sh @@ -0,0 +1,18 @@ +#!/bin/bash + +set -e + +quietly() { + readonly log="/tmp/quietly-$RANDOM.log" + if ! "$@" >"$log" 2>&1; then + ret=$? + cat "$log" + rm -f "$log" + exit $ret + fi + rm -f "$log" +} + +if test -r ".gitlab/ci/post_build_${CMAKE_CONFIGURATION}.sh"; then + source ".gitlab/ci/post_build_${CMAKE_CONFIGURATION}.sh" +fi diff --git a/.gitlab/ci/pre_build.sh b/.gitlab/ci/pre_build.sh new file mode 100755 index 0000000..7ff6a69 --- /dev/null +++ b/.gitlab/ci/pre_build.sh @@ -0,0 +1,18 @@ +#!/bin/bash + +set -e + +quietly() { + readonly log="/tmp/quietly-$RANDOM.log" + if ! "$@" >"$log" 2>&1; then + ret=$? + cat "$log" + rm -f "$log" + exit $ret + fi + rm -f "$log" +} + +if test -r ".gitlab/ci/pre_build_${CMAKE_CONFIGURATION}.sh"; then + source ".gitlab/ci/pre_build_${CMAKE_CONFIGURATION}.sh" +fi diff --git a/.gitlab/ci/env_fedora37_tidy.sh b/.gitlab/ci/pre_build_fedora37_tidy.sh index f9f08a3..7580ef1 100644 --- a/.gitlab/ci/env_fedora37_tidy.sh +++ b/.gitlab/ci/pre_build_fedora37_tidy.sh @@ -1,7 +1,9 @@ cmake \ + -G Ninja \ -S Utilities/ClangTidyModule \ -B Utilities/ClangTidyModule/build \ -DCMAKE_BUILD_TYPE=Release \ - -DRUN_TESTS=ON + -DRUN_TESTS=ON \ + -DCMAKE_CXX_COMPILER_LAUNCHER=sccache cmake --build Utilities/ClangTidyModule/build ctest --test-dir Utilities/ClangTidyModule/build --output-on-failure diff --git a/.gitlab/os-linux.yml b/.gitlab/os-linux.yml index decf1b1..cf671ef 100644 --- a/.gitlab/os-linux.yml +++ b/.gitlab/os-linux.yml @@ -258,7 +258,7 @@ ### NVHPC Compiler .nvhpc: - image: "kitware/cmake:ci-nvhpc22.9-x86_64-2022-11-22" + image: "kitware/cmake:ci-nvhpc22.11-x86_64-2022-12-06" variables: CMAKE_ARCH: x86_64 @@ -331,6 +331,21 @@ CMAKE_CONFIGURATION: cuda11.6_clang CTEST_NO_WARNINGS_ALLOWED: 1 +.cuda11.8_minimal: + image: "kitware/cmake:ci-cuda11.8-minimal-x86_64-2022-12-06" + + variables: + GIT_CLONE_PATH: "$CI_BUILDS_DIR/cmake ci" + CMAKE_ARCH: x86_64 + CTEST_LABELS: "CUDA" + CMAKE_CUDA_ARCHITECTURES_NATIVE_CLAMP: 1 + +.cuda11.8_minimal_nvidia: + extends: .cuda11.8_minimal + variables: + CMAKE_CONFIGURATION: cuda11.8_minimal_nvidia + CTEST_NO_WARNINGS_ALLOWED: 1 + ### HIP builds .hip4.2: @@ -372,6 +387,28 @@ CMAKE_CONFIGURATION: linux_gcc_cxx_modules_ninja_multi CMAKE_GENERATOR: "Ninja Multi-Config" +.clang_cxx_modules_x86_64: + image: "kitware/cmake:ci-clang_cxx_modules-x86_64-2022-12-02" + + variables: + GIT_CLONE_PATH: "$CI_BUILDS_DIR/cmake ci" + CMAKE_ARCH: x86_64 + CC: "/opt/llvm-p1689/bin/clang" + CXX: "/opt/llvm-p1689/bin/clang++" + +.clang_cxx_modules_ninja: + extends: .clang_cxx_modules_x86_64 + + variables: + CMAKE_CONFIGURATION: linux_clang_cxx_modules_ninja + +.clang_cxx_modules_ninja_multi: + extends: .clang_cxx_modules_x86_64 + + variables: + CMAKE_CONFIGURATION: linux_clang_cxx_modules_ninja_multi + CMAKE_GENERATOR: "Ninja Multi-Config" + ## Tags .linux_x86_64_tags: @@ -465,8 +502,10 @@ - .gitlab/ci/sccache.sh - sccache --start-server - sccache --show-stats + - .gitlab/ci/pre_build.sh - "$LAUNCHER ctest -VV -S .gitlab/ci/ctest_configure.cmake" - "$LAUNCHER ctest -VV -S .gitlab/ci/ctest_build.cmake" + - .gitlab/ci/post_build.sh - sccache --show-stats interruptible: true diff --git a/Help/command/add_subdirectory.rst b/Help/command/add_subdirectory.rst index 13cae10..8640eeb 100644 --- a/Help/command/add_subdirectory.rst +++ b/Help/command/add_subdirectory.rst @@ -36,7 +36,7 @@ the dependency. If the ``SYSTEM`` argument is provided, the :prop_dir:`SYSTEM` directory property of the subdirectory will be set to true. This property is -used to initialize the :prop_tgt:`SYSTEM` property of each target -created in that subdirectory. The include directories of targets with -:prop_tgt:`SYSTEM` set to true will be treated as ``SYSTEM`` when +used to initialize the :prop_tgt:`SYSTEM` property of each non-imported +target created in that subdirectory. The include directories of targets +with :prop_tgt:`SYSTEM` set to true will be treated as ``SYSTEM`` when compiling consumers. diff --git a/Help/dev/experimental.rst b/Help/dev/experimental.rst index 794a686..fbbad30 100644 --- a/Help/dev/experimental.rst +++ b/Help/dev/experimental.rst @@ -102,9 +102,9 @@ For compilers that generate module maps, tell CMake as follows: set(CMAKE_EXPERIMENTAL_CXX_MODULE_MAP_FLAG "${compiler_flags_for_module_map} -fmodule-mapper=<MODULE_MAP_FILE>") -Currently, the only supported formats are ``gcc`` and ``msvc``. The ``gcc`` -format is described in the GCC documentation, but the relevant section for the -purposes of CMake is: +Currently, the only supported formats are, ``clang``, ``gcc``, and ``msvc``. +The ``gcc`` format is described in the GCC documentation, but the relevant +section for the purposes of CMake is: A mapping file consisting of space-separated module-name, filename pairs, one per line. Only the mappings for the direct imports and any @@ -119,6 +119,9 @@ The ``msvc`` format is a response file containing flags required to compile any module interfaces properly as well as find any required files to satisfy ``import`` statements as required for Microsoft's Visual Studio toolchains. +Similarly, the ``clang`` format is a response file containing flags using +Clang's module flags. + .. _`D1483r1`: https://mathstuf.fedorapeople.org/fortran-modules/fortran-modules.html .. _`P1689r5`: http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2022/p1689r5.html .. _`cxx-modules-sandbox`: https://github.com/mathstuf/cxx-modules-sandbox diff --git a/Help/prop_dir/SYSTEM.rst b/Help/prop_dir/SYSTEM.rst index 4f923b7..ad4ace1 100644 --- a/Help/prop_dir/SYSTEM.rst +++ b/Help/prop_dir/SYSTEM.rst @@ -4,7 +4,7 @@ SYSTEM .. versionadded:: 3.25 This directory property is used to initialize the :prop_tgt:`SYSTEM` -target property for targets created in that directory. It is set to -true by :command:`add_subdirectory` and +target property for non-imported targets created in that directory. +It is set to true by :command:`add_subdirectory` and :command:`FetchContent_Declare` when the ``SYSTEM`` option is given as an argument to those commands. diff --git a/Help/prop_tgt/SYSTEM.rst b/Help/prop_tgt/SYSTEM.rst index a267738..6399d24 100644 --- a/Help/prop_tgt/SYSTEM.rst +++ b/Help/prop_tgt/SYSTEM.rst @@ -18,5 +18,5 @@ then their :prop_tgt:`INTERFACE_INCLUDE_DIRECTORIES` will not be treated as ``SYSTEM``, regardless of the value of the :prop_tgt:`IMPORTED_NO_SYSTEM` property. -This target property is initialized from the :prop_dir:`SYSTEM` -directory property when the target is created. +For non-imported targets, this target property is initialized from +the :prop_dir:`SYSTEM` directory property when the target is created. diff --git a/Modules/CheckSymbolExists.cmake b/Modules/CheckSymbolExists.cmake index 0d44d56..722d50f 100644 --- a/Modules/CheckSymbolExists.cmake +++ b/Modules/CheckSymbolExists.cmake @@ -136,7 +136,7 @@ int main(int argc, char** argv) ${_CSE_CHECK_NON_MACRO}") endif() string(APPEND _CSE_SOURCE " -}") +}\n") unset(_CSE_CHECK_NON_MACRO) if(NOT CMAKE_REQUIRED_QUIET) diff --git a/Modules/Compiler/Clang-FindBinUtils.cmake b/Modules/Compiler/Clang-FindBinUtils.cmake index 125ae78..daf0371 100644 --- a/Modules/Compiler/Clang-FindBinUtils.cmake +++ b/Modules/Compiler/Clang-FindBinUtils.cmake @@ -43,3 +43,14 @@ find_program(CMAKE_${_CMAKE_PROCESSING_LANGUAGE}_COMPILER_RANLIB NAMES DOC "Generate index for LLVM archive" ) mark_as_advanced(CMAKE_${_CMAKE_PROCESSING_LANGUAGE}_COMPILER_RANLIB) + +# clang-scan-deps +find_program(CMAKE_${_CMAKE_PROCESSING_LANGUAGE}_COMPILER_CLANG_SCAN_DEPS NAMES + "${_CMAKE_TOOLCHAIN_PREFIX}clang-scan-deps-${__version_x_y}" + "${_CMAKE_TOOLCHAIN_PREFIX}clang-scan-deps-${__version_x}" + "${_CMAKE_TOOLCHAIN_PREFIX}clang-scan-deps" + HINTS ${__clang_hints} + NO_CMAKE_PATH NO_CMAKE_ENVIRONMENT_PATH + DOC "`clang-scan-deps` dependency scanner" +) +mark_as_advanced(CMAKE_${_CMAKE_PROCESSING_LANGUAGE}_COMPILER_CLANG_SCAN_DEPS) diff --git a/Modules/FetchContent.cmake b/Modules/FetchContent.cmake index 80554d0..c9f1a09 100644 --- a/Modules/FetchContent.cmake +++ b/Modules/FetchContent.cmake @@ -1425,6 +1425,9 @@ function(__FetchContent_directPopulate contentName) set(options QUIET + # SYSTEM has no meaning for ExternalProject, it is only used by us in + # FetchContent_MakeAvailable(). We need to parse and discard it here. + SYSTEM ) set(oneValueArgs SUBBUILD_DIR diff --git a/Modules/FindOpenSSL.cmake b/Modules/FindOpenSSL.cmake index f66ffcf..78b1919 100644 --- a/Modules/FindOpenSSL.cmake +++ b/Modules/FindOpenSSL.cmake @@ -112,11 +112,31 @@ The following variables may be set to control search behavior: #]=======================================================================] macro(_OpenSSL_test_and_find_dependencies ssl_library crypto_library) + unset(_OpenSSL_extra_static_deps) if((CMAKE_SYSTEM_NAME STREQUAL "Linux") AND (("${ssl_library}" MATCHES "\\${CMAKE_STATIC_LIBRARY_SUFFIX}$") OR ("${crypto_library}" MATCHES "\\${CMAKE_STATIC_LIBRARY_SUFFIX}$"))) set(_OpenSSL_has_dependencies TRUE) - find_package(Threads) + unset(_OpenSSL_has_dependency_zlib) + if(_OPENSSL_LIBRARIES) + unset(_OpenSSL_has_dependency_dl) + foreach(_OPENSSL_DEP_LIB IN LISTS _OPENSSL_LIBRARIES) + if (_OPENSSL_DEP_LIB STREQUAL "ssl" OR _OPENSSL_DEP_LIB STREQUAL "crypto") + # ignoring: these are the targets + elseif(_OPENSSL_DEP_LIB STREQUAL CMAKE_DL_LIBS) + set(_OpenSSL_has_dependency_dl TRUE) + elseif(_OPENSSL_DEP_LIB STREQUAL "z") + find_package(ZLIB) + set(_OpenSSL_has_dependency_zlib TRUE) + else() + list(APPEND _OpenSSL_extra_static_deps "${_OPENSSL_DEP_LIB}") + endif() + endforeach() + unset(_OPENSSL_DEP_LIB) + else() + set(_OpenSSL_has_dependency_dl TRUE) + find_package(Threads) + endif() else() set(_OpenSSL_has_dependencies FALSE) endif() @@ -126,14 +146,25 @@ function(_OpenSSL_add_dependencies libraries_var) if(CMAKE_THREAD_LIBS_INIT) list(APPEND ${libraries_var} ${CMAKE_THREAD_LIBS_INIT}) endif() - list(APPEND ${libraries_var} ${CMAKE_DL_LIBS}) + if(_OpenSSL_has_dependency_zlib) + list(APPEND ${libraries_var} ${ZLIB_LIBRARY}) + endif() + if(_OpenSSL_has_dependency_dl) + list(APPEND ${libraries_var} ${CMAKE_DL_LIBS}) + endif() + list(APPEND ${libraries_var} ${_OpenSSL_extra_static_deps}) set(${libraries_var} ${${libraries_var}} PARENT_SCOPE) endfunction() function(_OpenSSL_target_add_dependencies target) if(_OpenSSL_has_dependencies) - set_property( TARGET ${target} APPEND PROPERTY INTERFACE_LINK_LIBRARIES Threads::Threads ) - set_property( TARGET ${target} APPEND PROPERTY INTERFACE_LINK_LIBRARIES ${CMAKE_DL_LIBS} ) + set_property( TARGET ${target} APPEND PROPERTY INTERFACE_LINK_LIBRARIES Threads::Threads ${_OpenSSL_extra_static_deps}) + if(_OpenSSL_has_dependency_dl) + set_property( TARGET ${target} APPEND PROPERTY INTERFACE_LINK_LIBRARIES ${CMAKE_DL_LIBS} ) + endif() + if(_OpenSSL_has_dependency_zlib) + set_property( TARGET ${target} APPEND PROPERTY INTERFACE_LINK_LIBRARIES ZLIB::ZLIB ) + endif() endif() if(WIN32 AND OPENSSL_USE_STATIC_LIBS) if(WINCE) @@ -719,3 +750,6 @@ endif() unset(_OPENSSL_FIND_PATH_SUFFIX) unset(_OPENSSL_NAME_POSTFIX) +unset(_OpenSSL_extra_static_deps) +unset(_OpenSSL_has_dependency_dl) +unset(_OpenSSL_has_dependency_zlib) diff --git a/Source/CMakeVersion.cmake b/Source/CMakeVersion.cmake index c3c47ae..f74a79f 100644 --- a/Source/CMakeVersion.cmake +++ b/Source/CMakeVersion.cmake @@ -1,7 +1,7 @@ # CMake version number components. set(CMake_VERSION_MAJOR 3) set(CMake_VERSION_MINOR 25) -set(CMake_VERSION_PATCH 20221202) +set(CMake_VERSION_PATCH 20221207) #set(CMake_VERSION_RC 0) set(CMake_VERSION_IS_DIRTY 0) diff --git a/Source/cmCxxModuleMapper.cxx b/Source/cmCxxModuleMapper.cxx index 84691c9..ca4ffdf 100644 --- a/Source/cmCxxModuleMapper.cxx +++ b/Source/cmCxxModuleMapper.cxx @@ -28,6 +28,38 @@ cm::optional<std::string> CxxModuleLocations::BmiGeneratorPathForModule( namespace { +std::string CxxModuleMapContentClang(CxxModuleLocations const& loc, + cmScanDepInfo const& obj) +{ + std::stringstream mm; + + // Clang's command line only supports a single output. If more than one is + // expected, we cannot make a useful module map file. + if (obj.Provides.size() > 1) { + return {}; + } + + // A series of flags which tell the compiler where to look for modules. + + for (auto const& p : obj.Provides) { + if (auto bmi_loc = loc.BmiGeneratorPathForModule(p.LogicalName)) { + // Force the TU to be considered a C++ module source file regardless of + // extension. + mm << "-x c++-module\n"; + + mm << "-fsave-std-c++-module-file=" << *bmi_loc << '\n'; + break; + } + } + for (auto const& r : obj.Requires) { + if (auto bmi_loc = loc.BmiGeneratorPathForModule(r.LogicalName)) { + mm << "-fmodule-file=" << *bmi_loc << '\n'; + } + } + + return mm.str(); +} + std::string CxxModuleMapContentGcc(CxxModuleLocations const& loc, cmScanDepInfo const& obj) { @@ -179,6 +211,8 @@ cm::static_string_view CxxModuleMapExtension( { if (format) { switch (*format) { + case CxxModuleMapFormat::Clang: + return ".pcm"_s; case CxxModuleMapFormat::Gcc: return ".gcm"_s; case CxxModuleMapFormat::Msvc: @@ -297,6 +331,8 @@ std::string CxxModuleMapContent(CxxModuleMapFormat format, CxxModuleUsage const& usages) { switch (format) { + case CxxModuleMapFormat::Clang: + return CxxModuleMapContentClang(loc, obj); case CxxModuleMapFormat::Gcc: return CxxModuleMapContentGcc(loc, obj); case CxxModuleMapFormat::Msvc: diff --git a/Source/cmCxxModuleMapper.h b/Source/cmCxxModuleMapper.h index 8526a07..9271978 100644 --- a/Source/cmCxxModuleMapper.h +++ b/Source/cmCxxModuleMapper.h @@ -17,6 +17,7 @@ enum class CxxModuleMapFormat { + Clang, Gcc, Msvc, }; diff --git a/Source/cmGeneratorTarget.cxx b/Source/cmGeneratorTarget.cxx index 123b5e6..7ecdd87 100644 --- a/Source/cmGeneratorTarget.cxx +++ b/Source/cmGeneratorTarget.cxx @@ -4669,7 +4669,8 @@ void cmGeneratorTarget::GetLinkOptions(std::vector<std::string>& result, std::vector<BT<std::string>> cmGeneratorTarget::GetLinkOptions( std::string const& config, std::string const& language) const { - ConfigAndLanguage cacheKey(config, language); + ConfigAndLanguage cacheKey( + config, cmStrCat(language, this->IsDeviceLink() ? "-device" : "")); { auto it = this->LinkOptionsCache.find(cacheKey); if (it != this->LinkOptionsCache.end()) { @@ -4955,7 +4956,8 @@ void cmGeneratorTarget::GetLinkDirectories(std::vector<std::string>& result, std::vector<BT<std::string>> cmGeneratorTarget::GetLinkDirectories( std::string const& config, std::string const& language) const { - ConfigAndLanguage cacheKey(config, language); + ConfigAndLanguage cacheKey( + config, cmStrCat(language, this->IsDeviceLink() ? "-device" : "")); { auto it = this->LinkDirectoriesCache.find(cacheKey); if (it != this->LinkDirectoriesCache.end()) { diff --git a/Source/cmGlobalNinjaGenerator.cxx b/Source/cmGlobalNinjaGenerator.cxx index 75c347e..cfe4c7c 100644 --- a/Source/cmGlobalNinjaGenerator.cxx +++ b/Source/cmGlobalNinjaGenerator.cxx @@ -2571,6 +2571,8 @@ bool cmGlobalNinjaGenerator::WriteDyndepFile( cm::optional<CxxModuleMapFormat> modmap_fmt; if (arg_modmapfmt.empty()) { // nothing to do. + } else if (arg_modmapfmt == "clang") { + modmap_fmt = CxxModuleMapFormat::Clang; } else if (arg_modmapfmt == "gcc") { modmap_fmt = CxxModuleMapFormat::Gcc; } else if (arg_modmapfmt == "msvc") { diff --git a/Source/cmNinjaTargetGenerator.cxx b/Source/cmNinjaTargetGenerator.cxx index f2f719d..0807a98 100644 --- a/Source/cmNinjaTargetGenerator.cxx +++ b/Source/cmNinjaTargetGenerator.cxx @@ -561,9 +561,12 @@ cmNinjaRule GetScanRule( // Scanning always uses a depfile for preprocessor dependencies. if (deptype == "msvc"_s) { rule.DepType = deptype; - rule.DepFile = ""; + rule.DepFile.clear(); + } else if (deptype == "none"_s) { + rule.DepType.clear(); // no deps= for multiple outputs + rule.DepFile.clear(); } else { - rule.DepType = ""; // no deps= for multiple outputs + rule.DepType.clear(); // no deps= for multiple outputs rule.DepFile = "$DEP_FILE"; } diff --git a/Source/cmQtAutoMocUic.cxx b/Source/cmQtAutoMocUic.cxx index 4753e61..683c18f 100644 --- a/Source/cmQtAutoMocUic.cxx +++ b/Source/cmQtAutoMocUic.cxx @@ -1981,6 +1981,9 @@ void cmQtAutoMocUicT::JobCompileMocT::Process() std::string const& sourceFile = this->Mapping->SourceFile->FileName; std::string const& outputFile = this->Mapping->OutputFile; + // Remove output file in case the case of the source file has changed + cmSystemTools::RemoveFile(outputFile); + // Compose moc command std::vector<std::string> cmd; { diff --git a/Source/cmSearchPath.cxx b/Source/cmSearchPath.cxx index 6c53b85..44f37cb 100644 --- a/Source/cmSearchPath.cxx +++ b/Source/cmSearchPath.cxx @@ -179,12 +179,27 @@ void cmSearchPath::AddPrefixPaths(const std::vector<std::string>& paths, cmValue arch = this->FC->Makefile->GetDefinition("CMAKE_LIBRARY_ARCHITECTURE"); if (cmNonempty(arch)) { + std::string archNoUnknown = arch; + auto unknownAtPos = archNoUnknown.find("-unknown-"); + bool foundUnknown = unknownAtPos != std::string::npos; + if (foundUnknown) { + // Replace "-unknown-" with "-". + archNoUnknown.replace(unknownAtPos, 9, "-"); + } if (this->FC->Makefile->IsDefinitionSet("CMAKE_SYSROOT") && this->FC->Makefile->IsDefinitionSet( "CMAKE_PREFIX_LIBRARY_ARCHITECTURE")) { + if (foundUnknown) { + this->AddPathInternal(cmStrCat('/', archNoUnknown, dir, subdir), + cmStrCat('/', archNoUnknown, prefix), base); + } this->AddPathInternal(cmStrCat('/', *arch, dir, subdir), cmStrCat('/', *arch, prefix), base); } else { + if (foundUnknown) { + this->AddPathInternal(cmStrCat(dir, subdir, '/', archNoUnknown), + prefix, base); + } this->AddPathInternal(cmStrCat(dir, subdir, '/', *arch), prefix, base); } diff --git a/Source/cmStringAlgorithms.cxx b/Source/cmStringAlgorithms.cxx index e559cfa..66bf383 100644 --- a/Source/cmStringAlgorithms.cxx +++ b/Source/cmStringAlgorithms.cxx @@ -203,25 +203,45 @@ cmAlphaNum::cmAlphaNum(double val) MakeDigits(this->View_, this->Digits_, "%g", val); } -std::string cmCatViews(cm::optional<std::string>&& first, - std::initializer_list<cm::string_view> views) +std::string cmCatViews( + std::initializer_list<std::pair<cm::string_view, std::string*>> views) { std::size_t totalSize = 0; - for (cm::string_view const& view : views) { - totalSize += view.size(); + std::string* rvalueString = nullptr; + std::size_t rvalueStringLength = 0; + std::size_t rvalueStringOffset = 0; + for (auto const& view : views) { + // Find the rvalue string with the largest capacity. + if (view.second && + (!rvalueString || + view.second->capacity() > rvalueString->capacity())) { + rvalueString = view.second; + rvalueStringLength = rvalueString->length(); + rvalueStringOffset = totalSize; + } + totalSize += view.first.size(); } std::string result; std::string::size_type initialLen = 0; - if (first) { - totalSize += first->length(); - initialLen = first->length(); - result = std::move(*first); + if (rvalueString && rvalueString->capacity() >= totalSize) { + result = std::move(*rvalueString); + } else { + rvalueString = nullptr; } result.resize(totalSize); + if (rvalueString && rvalueStringOffset > 0) { + std::copy_backward(result.begin(), result.begin() + rvalueStringLength, + result.begin() + rvalueStringOffset + + rvalueStringLength); + } std::string::iterator sit = result.begin() + initialLen; - for (cm::string_view const& view : views) { - sit = std::copy_n(view.data(), view.size(), sit); + for (auto const& view : views) { + if (rvalueString && view.second == rvalueString) { + sit += rvalueStringLength; + } else { + sit = std::copy_n(view.first.data(), view.first.size(), sit); + } } return result; } diff --git a/Source/cmStringAlgorithms.h b/Source/cmStringAlgorithms.h index bff2eda..9ea7491 100644 --- a/Source/cmStringAlgorithms.h +++ b/Source/cmStringAlgorithms.h @@ -12,7 +12,6 @@ #include <utility> #include <vector> -#include <cm/optional> #include <cm/string_view> #include "cmRange.h" @@ -147,8 +146,8 @@ std::vector<std::string> cmExpandedLists(InputIt first, InputIt last) } /** Concatenate string pieces into a single string. */ -std::string cmCatViews(cm::optional<std::string>&& first, - std::initializer_list<cm::string_view> views); +std::string cmCatViews( + std::initializer_list<std::pair<cm::string_view, std::string*>> views); /** Utility class for cmStrCat. */ class cmAlphaNum @@ -162,6 +161,10 @@ public: : View_(str) { } + cmAlphaNum(std::string&& str) + : RValueString_(&str) + { + } cmAlphaNum(const char* str) : View_(str) { @@ -184,45 +187,34 @@ public: { } - cm::string_view View() const { return this->View_; } + cm::string_view View() const + { + if (this->RValueString_) { + return *this->RValueString_; + } + return this->View_; + } + + std::string* RValueString() const { return this->RValueString_; } private: + std::string* RValueString_ = nullptr; cm::string_view View_; char Digits_[32]; }; -template <typename A, typename B, typename... AV> -class cmStrCatHelper -{ -public: - static std::string Compute(cmAlphaNum const& a, cmAlphaNum const& b, - AV const&... args) - { - return cmCatViews( - cm::nullopt, - { a.View(), b.View(), static_cast<cmAlphaNum const&>(args).View()... }); - } -}; - -template <typename B, typename... AV> -class cmStrCatHelper<std::string, B, AV...> -{ -public: - static std::string Compute(std::string&& a, cmAlphaNum const& b, - AV const&... args) - { - return cmCatViews( - std::move(a), - { b.View(), static_cast<cmAlphaNum const&>(args).View()... }); - } -}; - /** Concatenate string pieces and numbers into a single string. */ template <typename A, typename B, typename... AV> inline std::string cmStrCat(A&& a, B&& b, AV&&... args) { - return cmStrCatHelper<A, B, AV...>::Compute( - std::forward<A>(a), std::forward<B>(b), std::forward<AV>(args)...); + static auto const makePair = + [](const cmAlphaNum& arg) -> std::pair<cm::string_view, std::string*> { + return { arg.View(), arg.RValueString() }; + }; + + return cmCatViews({ makePair(std::forward<A>(a)), + makePair(std::forward<B>(b)), + makePair(std::forward<AV>(args))... }); } /** Joins wrapped elements of a range with separator into a single string. */ @@ -233,10 +225,13 @@ std::string cmWrap(cm::string_view prefix, Range const& rng, if (rng.empty()) { return std::string(); } - return cmCatViews( - cm::nullopt, - { prefix, cmJoin(rng, cmCatViews(cm::nullopt, { suffix, sep, prefix })), - suffix }); + return cmCatViews({ { prefix, nullptr }, + { cmJoin(rng, + cmCatViews({ { suffix, nullptr }, + { sep, nullptr }, + { prefix, nullptr } })), + nullptr }, + { suffix, nullptr } }); } /** Joins wrapped elements of a range with separator into a single string. */ diff --git a/Source/cmTargetIncludeDirectoriesCommand.cxx b/Source/cmTargetIncludeDirectoriesCommand.cxx index cb83873..7a2dd09 100644 --- a/Source/cmTargetIncludeDirectoriesCommand.cxx +++ b/Source/cmTargetIncludeDirectoriesCommand.cxx @@ -100,8 +100,7 @@ bool cmTargetIncludeDirectoriesCommand(std::vector<std::string> const& args, { return TargetIncludeDirectoriesImpl(status).HandleArguments( args, "INCLUDE_DIRECTORIES", - static_cast<TargetIncludeDirectoriesImpl::ArgumentFlags>( - TargetIncludeDirectoriesImpl::PROCESS_BEFORE | + TargetIncludeDirectoriesImpl::PROCESS_BEFORE | TargetIncludeDirectoriesImpl::PROCESS_AFTER | - TargetIncludeDirectoriesImpl::PROCESS_SYSTEM)); + TargetIncludeDirectoriesImpl::PROCESS_SYSTEM); } diff --git a/Source/cmTargetPropCommandBase.cxx b/Source/cmTargetPropCommandBase.cxx index 391b954..8d2ff71 100644 --- a/Source/cmTargetPropCommandBase.cxx +++ b/Source/cmTargetPropCommandBase.cxx @@ -23,7 +23,7 @@ void cmTargetPropCommandBase::SetError(std::string const& e) bool cmTargetPropCommandBase::HandleArguments( std::vector<std::string> const& args, const std::string& prop, - ArgumentFlags flags) + unsigned int flags) { if (args.size() < 2) { this->SetError("called with incorrect number of arguments"); diff --git a/Source/cmTargetPropCommandBase.h b/Source/cmTargetPropCommandBase.h index 487beb4..ac50b4d 100644 --- a/Source/cmTargetPropCommandBase.h +++ b/Source/cmTargetPropCommandBase.h @@ -29,8 +29,7 @@ public: }; bool HandleArguments(std::vector<std::string> const& args, - const std::string& prop, - ArgumentFlags flags = NO_FLAGS); + const std::string& prop, unsigned int flags = NO_FLAGS); protected: std::string Property; diff --git a/Source/cmakemain.cxx b/Source/cmakemain.cxx index a155787..1e02412 100644 --- a/Source/cmakemain.cxx +++ b/Source/cmakemain.cxx @@ -311,6 +311,11 @@ int do_cmake(int ac, char const* const* av) } return 1; // failed to parse } + // Only in script mode do we stop parsing instead + // of preferring the last mode flag provided + if (arg == "--" && workingMode == cmake::SCRIPT_MODE) { + break; + } } if (!matched) { parsedArgs.emplace_back(av[i]); diff --git a/Tests/CMakeLib/testStringAlgorithms.cxx b/Tests/CMakeLib/testStringAlgorithms.cxx index f73e62a..cb5f886 100644 --- a/Tests/CMakeLib/testStringAlgorithms.cxx +++ b/Tests/CMakeLib/testStringAlgorithms.cxx @@ -149,13 +149,23 @@ int testStringAlgorithms(int /*unused*/, char* /*unused*/ []) { std::string val; std::string expect; - val.reserve(120 * cmStrLen("cmStrCat move")); + val.reserve(50 * cmStrLen("cmStrCat move ") + 1); auto data = val.data(); + auto capacity = val.capacity(); + bool moved = true; for (int i = 0; i < 100; i++) { - val = cmStrCat(std::move(val), "cmStrCat move"); - expect += "cmStrCat move"; + if (i % 2 == 0) { + val = cmStrCat(std::move(val), "move "); + expect += "move "; + } else { + val = cmStrCat("cmStrCat ", std::move(val)); + expect = "cmStrCat " + std::move(expect); + } + if (val.data() != data || val.capacity() != capacity) { + moved = false; + } } - assert_ok((val.data() == data), "cmStrCat move"); + assert_ok(moved, "cmStrCat move"); assert_string(val, expect, "cmStrCat move"); } diff --git a/Tests/RunCMake/CMakeLists.txt b/Tests/RunCMake/CMakeLists.txt index 0fe4919..78615d9 100644 --- a/Tests/RunCMake/CMakeLists.txt +++ b/Tests/RunCMake/CMakeLists.txt @@ -760,8 +760,11 @@ add_RunCMake_test(install -DNO_NAMELINK=${NO_NAMELINK} -DCYGWIN=${CYGWIN} -DMSYS set_property(TEST RunCMake.install APPEND PROPERTY LABELS "ISPC") +if(DEFINED CMake_COMPILER_FORCES_NEW_DTAGS) + list(APPEND file-GET_RUNTIME_DEPENDENCIES_ARGS + -DCMake_COMPILER_FORCES_NEW_DTAGS=${CMake_COMPILER_FORCES_NEW_DTAGS}) +endif() add_RunCMake_test(file-GET_RUNTIME_DEPENDENCIES - -DCMAKE_C_COMPILER_ID=${CMAKE_C_COMPILER_ID} -DCMake_INSTALL_NAME_TOOL_BUG=${CMake_INSTALL_NAME_TOOL_BUG} ) diff --git a/Tests/RunCMake/CXXModules/examples/cxx-modules-find-bmi.cmake b/Tests/RunCMake/CXXModules/examples/cxx-modules-find-bmi.cmake index 91f3995..88d50db 100644 --- a/Tests/RunCMake/CXXModules/examples/cxx-modules-find-bmi.cmake +++ b/Tests/RunCMake/CXXModules/examples/cxx-modules-find-bmi.cmake @@ -1,6 +1,6 @@ function (check_for_bmi prefix destination name) set(found 0) - foreach (ext IN ITEMS gcm ifc) + foreach (ext IN ITEMS gcm ifc pcm) if (EXISTS "${prefix}/${destination}/${name}.${ext}") set(found 1) break () diff --git a/Tests/RunCMake/CommandLine/P_P_in_arbitrary_args-stdout.txt b/Tests/RunCMake/CommandLine/P_P_in_arbitrary_args-stdout.txt new file mode 100644 index 0000000..95304ab --- /dev/null +++ b/Tests/RunCMake/CommandLine/P_P_in_arbitrary_args-stdout.txt @@ -0,0 +1,10 @@ +^-- CMAKE_ARGC='6' +-- CMAKE_ARGV1='-P' +-- CMAKE_ARGV2='[^']*/Tests/RunCMake/CommandLine/P_arbitrary_args.cmake' +-- CMAKE_ARGV3='--' +-- CMAKE_ARGV4='-P' +-- CMAKE_ARGV5='[^']*/Tests/RunCMake/CommandLine/non_existing.cmake' +-- CMAKE_ARGV6='' +-- CMAKE_ARGV7='' +-- CMAKE_ARGV8='' +-- CMAKE_ARGV9=''$ diff --git a/Tests/RunCMake/CommandLine/RunCMakeTest.cmake b/Tests/RunCMake/CommandLine/RunCMakeTest.cmake index 9f342bb..480ad09 100644 --- a/Tests/RunCMake/CommandLine/RunCMakeTest.cmake +++ b/Tests/RunCMake/CommandLine/RunCMakeTest.cmake @@ -55,6 +55,7 @@ run_cmake_command(P_no-arg ${CMAKE_COMMAND} -P) run_cmake_command(P_no-file ${CMAKE_COMMAND} -P nosuchscriptfile.cmake) run_cmake_command(P_args ${CMAKE_COMMAND} -P "${RunCMake_SOURCE_DIR}/P_args.cmake" relative/path "${RunCMake_SOURCE_DIR}") run_cmake_command(P_arbitrary_args ${CMAKE_COMMAND} -P "${RunCMake_SOURCE_DIR}/P_arbitrary_args.cmake" -- -DFOO -S -B --fresh --version) +run_cmake_command(P_P_in_arbitrary_args ${CMAKE_COMMAND} -P "${RunCMake_SOURCE_DIR}/P_arbitrary_args.cmake" -- -P "${RunCMake_SOURCE_DIR}/non_existing.cmake") run_cmake_command(P_fresh ${CMAKE_COMMAND} -P "${RunCMake_SOURCE_DIR}/P_fresh.cmake" --fresh) run_cmake_command(build-no-dir diff --git a/Tests/RunCMake/file-GET_RUNTIME_DEPENDENCIES/RunCMakeTest.cmake b/Tests/RunCMake/file-GET_RUNTIME_DEPENDENCIES/RunCMakeTest.cmake index 75bfc07..43b406b 100644 --- a/Tests/RunCMake/file-GET_RUNTIME_DEPENDENCIES/RunCMakeTest.cmake +++ b/Tests/RunCMake/file-GET_RUNTIME_DEPENDENCIES/RunCMakeTest.cmake @@ -59,7 +59,7 @@ elseif(CMAKE_HOST_SYSTEM_NAME STREQUAL "Linux") set(ENV{LDFLAGS} "${new_ldflags}") endif() - if(NOT CMAKE_C_COMPILER_ID MATCHES "^XL") + if(NOT CMake_COMPILER_FORCES_NEW_DTAGS) run_install_test(linux) run_install_test(linux-parent-rpath-propagation) run_install_test(file-filter) diff --git a/Utilities/ClangTidyModule/StringConcatenationUseCmstrcatCheck.cxx b/Utilities/ClangTidyModule/StringConcatenationUseCmstrcatCheck.cxx index df14c83..e282d23 100644 --- a/Utilities/ClangTidyModule/StringConcatenationUseCmstrcatCheck.cxx +++ b/Utilities/ClangTidyModule/StringConcatenationUseCmstrcatCheck.cxx @@ -156,7 +156,8 @@ void StringConcatenationUseCmstrcatCheck::issueCorrection( ExprNode = *It; StringRef LastToken = Lexer::getSourceText( - CharSourceRange::getTokenRange(ExprNode->getArg(1)->getSourceRange()), + CharSourceRange::getTokenRange( + ExprNode->getArg(1)->getSourceRange().getEnd()), Result.Context->getSourceManager(), Result.Context->getLangOpts()); FixIts.push_back(FixItHint::CreateInsertion( ExprNode->getEndLoc().getLocWithOffset(LastToken.str().size()), ")")); diff --git a/Utilities/ClangTidyModule/Tests/cmake-string-concatenation-use-cmstrcat-fixit.cxx b/Utilities/ClangTidyModule/Tests/cmake-string-concatenation-use-cmstrcat-fixit.cxx index 79aecd4..dd1e6c4 100644 --- a/Utilities/ClangTidyModule/Tests/cmake-string-concatenation-use-cmstrcat-fixit.cxx +++ b/Utilities/ClangTidyModule/Tests/cmake-string-concatenation-use-cmstrcat-fixit.cxx @@ -1,4 +1,5 @@ #include <string> +#include <utility> template <typename... Args> std::string cmStrCat(Args&&... args) @@ -24,6 +25,9 @@ void test1() concat = cmStrCat(concat, " and this is a string literal"); concat = cmStrCat(concat, 'o'); concat = cmStrCat(concat, b, " and this is a string literal ", 'o', b); + + std::pair<std::string, std::string> p; + concat = cmStrCat(p.first, p.second); } // No correction needed diff --git a/Utilities/ClangTidyModule/Tests/cmake-string-concatenation-use-cmstrcat-stdout.txt b/Utilities/ClangTidyModule/Tests/cmake-string-concatenation-use-cmstrcat-stdout.txt index 3cfdef8..83b8d83 100644 --- a/Utilities/ClangTidyModule/Tests/cmake-string-concatenation-use-cmstrcat-stdout.txt +++ b/Utilities/ClangTidyModule/Tests/cmake-string-concatenation-use-cmstrcat-stdout.txt @@ -1,113 +1,124 @@ -cmake-string-concatenation-use-cmstrcat.cxx:16:12: warning: use cmStrCat() instead of string concatenation [cmake-string-concatenation-use-cmstrcat] +cmake-string-concatenation-use-cmstrcat.cxx:17:12: warning: use cmStrCat() instead of string concatenation [cmake-string-concatenation-use-cmstrcat] concat = a + b; ^ ~ cmStrCat( , ) -cmake-string-concatenation-use-cmstrcat.cxx:16:12: note: FIX-IT applied suggested code changes -cmake-string-concatenation-use-cmstrcat.cxx:16:14: note: FIX-IT applied suggested code changes +cmake-string-concatenation-use-cmstrcat.cxx:17:12: note: FIX-IT applied suggested code changes +cmake-string-concatenation-use-cmstrcat.cxx:17:14: note: FIX-IT applied suggested code changes concat = a + b; ^ -cmake-string-concatenation-use-cmstrcat.cxx:16:17: note: FIX-IT applied suggested code changes +cmake-string-concatenation-use-cmstrcat.cxx:17:17: note: FIX-IT applied suggested code changes concat = a + b; ^ -cmake-string-concatenation-use-cmstrcat.cxx:17:12: warning: use cmStrCat() instead of string concatenation [cmake-string-concatenation-use-cmstrcat] +cmake-string-concatenation-use-cmstrcat.cxx:18:12: warning: use cmStrCat() instead of string concatenation [cmake-string-concatenation-use-cmstrcat] concat = a + " and this is a string literal"; ^ ~ cmStrCat( , ) -cmake-string-concatenation-use-cmstrcat.cxx:17:12: note: FIX-IT applied suggested code changes -cmake-string-concatenation-use-cmstrcat.cxx:17:14: note: FIX-IT applied suggested code changes +cmake-string-concatenation-use-cmstrcat.cxx:18:12: note: FIX-IT applied suggested code changes +cmake-string-concatenation-use-cmstrcat.cxx:18:14: note: FIX-IT applied suggested code changes concat = a + " and this is a string literal"; ^ -cmake-string-concatenation-use-cmstrcat.cxx:17:47: note: FIX-IT applied suggested code changes +cmake-string-concatenation-use-cmstrcat.cxx:18:47: note: FIX-IT applied suggested code changes concat = a + " and this is a string literal"; ^ -cmake-string-concatenation-use-cmstrcat.cxx:18:12: warning: use cmStrCat() instead of string concatenation [cmake-string-concatenation-use-cmstrcat] +cmake-string-concatenation-use-cmstrcat.cxx:19:12: warning: use cmStrCat() instead of string concatenation [cmake-string-concatenation-use-cmstrcat] concat = a + 'O'; ^ ~ cmStrCat( , ) -cmake-string-concatenation-use-cmstrcat.cxx:18:12: note: FIX-IT applied suggested code changes -cmake-string-concatenation-use-cmstrcat.cxx:18:14: note: FIX-IT applied suggested code changes +cmake-string-concatenation-use-cmstrcat.cxx:19:12: note: FIX-IT applied suggested code changes +cmake-string-concatenation-use-cmstrcat.cxx:19:14: note: FIX-IT applied suggested code changes concat = a + 'O'; ^ -cmake-string-concatenation-use-cmstrcat.cxx:18:19: note: FIX-IT applied suggested code changes +cmake-string-concatenation-use-cmstrcat.cxx:19:19: note: FIX-IT applied suggested code changes concat = a + 'O'; ^ -cmake-string-concatenation-use-cmstrcat.cxx:19:12: warning: use cmStrCat() instead of string concatenation [cmake-string-concatenation-use-cmstrcat] +cmake-string-concatenation-use-cmstrcat.cxx:20:12: warning: use cmStrCat() instead of string concatenation [cmake-string-concatenation-use-cmstrcat] concat = "This is a string literal" + b; ^ ~ cmStrCat( , ) -cmake-string-concatenation-use-cmstrcat.cxx:19:12: note: FIX-IT applied suggested code changes -cmake-string-concatenation-use-cmstrcat.cxx:19:39: note: FIX-IT applied suggested code changes +cmake-string-concatenation-use-cmstrcat.cxx:20:12: note: FIX-IT applied suggested code changes +cmake-string-concatenation-use-cmstrcat.cxx:20:39: note: FIX-IT applied suggested code changes concat = "This is a string literal" + b; ^ -cmake-string-concatenation-use-cmstrcat.cxx:19:42: note: FIX-IT applied suggested code changes +cmake-string-concatenation-use-cmstrcat.cxx:20:42: note: FIX-IT applied suggested code changes concat = "This is a string literal" + b; ^ -cmake-string-concatenation-use-cmstrcat.cxx:20:12: warning: use cmStrCat() instead of string concatenation [cmake-string-concatenation-use-cmstrcat] +cmake-string-concatenation-use-cmstrcat.cxx:21:12: warning: use cmStrCat() instead of string concatenation [cmake-string-concatenation-use-cmstrcat] concat = 'O' + a; ^ ~ cmStrCat( , ) -cmake-string-concatenation-use-cmstrcat.cxx:20:12: note: FIX-IT applied suggested code changes -cmake-string-concatenation-use-cmstrcat.cxx:20:16: note: FIX-IT applied suggested code changes +cmake-string-concatenation-use-cmstrcat.cxx:21:12: note: FIX-IT applied suggested code changes +cmake-string-concatenation-use-cmstrcat.cxx:21:16: note: FIX-IT applied suggested code changes concat = 'O' + a; ^ -cmake-string-concatenation-use-cmstrcat.cxx:20:19: note: FIX-IT applied suggested code changes +cmake-string-concatenation-use-cmstrcat.cxx:21:19: note: FIX-IT applied suggested code changes concat = 'O' + a; ^ -cmake-string-concatenation-use-cmstrcat.cxx:21:12: warning: use cmStrCat() instead of string concatenation [cmake-string-concatenation-use-cmstrcat] +cmake-string-concatenation-use-cmstrcat.cxx:22:12: warning: use cmStrCat() instead of string concatenation [cmake-string-concatenation-use-cmstrcat] concat = a + " and this is a string literal" + 'O' + b; ^ ~ ~ ~ cmStrCat( , , , ) -cmake-string-concatenation-use-cmstrcat.cxx:21:12: note: FIX-IT applied suggested code changes -cmake-string-concatenation-use-cmstrcat.cxx:21:14: note: FIX-IT applied suggested code changes +cmake-string-concatenation-use-cmstrcat.cxx:22:12: note: FIX-IT applied suggested code changes +cmake-string-concatenation-use-cmstrcat.cxx:22:14: note: FIX-IT applied suggested code changes concat = a + " and this is a string literal" + 'O' + b; ^ -cmake-string-concatenation-use-cmstrcat.cxx:21:48: note: FIX-IT applied suggested code changes +cmake-string-concatenation-use-cmstrcat.cxx:22:48: note: FIX-IT applied suggested code changes concat = a + " and this is a string literal" + 'O' + b; ^ -cmake-string-concatenation-use-cmstrcat.cxx:21:54: note: FIX-IT applied suggested code changes +cmake-string-concatenation-use-cmstrcat.cxx:22:54: note: FIX-IT applied suggested code changes concat = a + " and this is a string literal" + 'O' + b; ^ -cmake-string-concatenation-use-cmstrcat.cxx:21:57: note: FIX-IT applied suggested code changes +cmake-string-concatenation-use-cmstrcat.cxx:22:57: note: FIX-IT applied suggested code changes concat = a + " and this is a string literal" + 'O' + b; ^ -cmake-string-concatenation-use-cmstrcat.cxx:23:10: warning: use cmStrCat() instead of string append [cmake-string-concatenation-use-cmstrcat] +cmake-string-concatenation-use-cmstrcat.cxx:24:10: warning: use cmStrCat() instead of string append [cmake-string-concatenation-use-cmstrcat] concat += b; ^~ = cmStrCat(concat, ) -cmake-string-concatenation-use-cmstrcat.cxx:23:10: note: FIX-IT applied suggested code changes -cmake-string-concatenation-use-cmstrcat.cxx:23:14: note: FIX-IT applied suggested code changes +cmake-string-concatenation-use-cmstrcat.cxx:24:10: note: FIX-IT applied suggested code changes +cmake-string-concatenation-use-cmstrcat.cxx:24:14: note: FIX-IT applied suggested code changes concat += b; ^ -cmake-string-concatenation-use-cmstrcat.cxx:24:10: warning: use cmStrCat() instead of string append [cmake-string-concatenation-use-cmstrcat] +cmake-string-concatenation-use-cmstrcat.cxx:25:10: warning: use cmStrCat() instead of string append [cmake-string-concatenation-use-cmstrcat] concat += " and this is a string literal"; ^~ = cmStrCat(concat, ) -cmake-string-concatenation-use-cmstrcat.cxx:24:10: note: FIX-IT applied suggested code changes -cmake-string-concatenation-use-cmstrcat.cxx:24:44: note: FIX-IT applied suggested code changes +cmake-string-concatenation-use-cmstrcat.cxx:25:10: note: FIX-IT applied suggested code changes +cmake-string-concatenation-use-cmstrcat.cxx:25:44: note: FIX-IT applied suggested code changes concat += " and this is a string literal"; ^ -cmake-string-concatenation-use-cmstrcat.cxx:25:10: warning: use cmStrCat() instead of string append [cmake-string-concatenation-use-cmstrcat] +cmake-string-concatenation-use-cmstrcat.cxx:26:10: warning: use cmStrCat() instead of string append [cmake-string-concatenation-use-cmstrcat] concat += 'o'; ^~ = cmStrCat(concat, ) -cmake-string-concatenation-use-cmstrcat.cxx:25:10: note: FIX-IT applied suggested code changes -cmake-string-concatenation-use-cmstrcat.cxx:25:16: note: FIX-IT applied suggested code changes +cmake-string-concatenation-use-cmstrcat.cxx:26:10: note: FIX-IT applied suggested code changes +cmake-string-concatenation-use-cmstrcat.cxx:26:16: note: FIX-IT applied suggested code changes concat += 'o'; ^ -cmake-string-concatenation-use-cmstrcat.cxx:26:10: warning: use cmStrCat() instead of string append [cmake-string-concatenation-use-cmstrcat] +cmake-string-concatenation-use-cmstrcat.cxx:27:10: warning: use cmStrCat() instead of string append [cmake-string-concatenation-use-cmstrcat] concat += b + " and this is a string literal " + 'o' + b; ^~ ~ ~ ~ = cmStrCat(concat, , , , ) -cmake-string-concatenation-use-cmstrcat.cxx:26:10: note: FIX-IT applied suggested code changes -cmake-string-concatenation-use-cmstrcat.cxx:26:15: note: FIX-IT applied suggested code changes +cmake-string-concatenation-use-cmstrcat.cxx:27:10: note: FIX-IT applied suggested code changes +cmake-string-concatenation-use-cmstrcat.cxx:27:15: note: FIX-IT applied suggested code changes concat += b + " and this is a string literal " + 'o' + b; ^ -cmake-string-concatenation-use-cmstrcat.cxx:26:50: note: FIX-IT applied suggested code changes +cmake-string-concatenation-use-cmstrcat.cxx:27:50: note: FIX-IT applied suggested code changes concat += b + " and this is a string literal " + 'o' + b; ^ -cmake-string-concatenation-use-cmstrcat.cxx:26:56: note: FIX-IT applied suggested code changes +cmake-string-concatenation-use-cmstrcat.cxx:27:56: note: FIX-IT applied suggested code changes concat += b + " and this is a string literal " + 'o' + b; ^ -cmake-string-concatenation-use-cmstrcat.cxx:26:59: note: FIX-IT applied suggested code changes +cmake-string-concatenation-use-cmstrcat.cxx:27:59: note: FIX-IT applied suggested code changes concat += b + " and this is a string literal " + 'o' + b; ^ +cmake-string-concatenation-use-cmstrcat.cxx:30:12: warning: use cmStrCat() instead of string concatenation [cmake-string-concatenation-use-cmstrcat] + concat = p.first + p.second; + ^ ~ + cmStrCat( , ) +cmake-string-concatenation-use-cmstrcat.cxx:30:12: note: FIX-IT applied suggested code changes +cmake-string-concatenation-use-cmstrcat.cxx:30:20: note: FIX-IT applied suggested code changes + concat = p.first + p.second; + ^ +cmake-string-concatenation-use-cmstrcat.cxx:30:30: note: FIX-IT applied suggested code changes + concat = p.first + p.second; + ^ diff --git a/Utilities/ClangTidyModule/Tests/cmake-string-concatenation-use-cmstrcat.cxx b/Utilities/ClangTidyModule/Tests/cmake-string-concatenation-use-cmstrcat.cxx index 13a20ac..b088ca3 100644 --- a/Utilities/ClangTidyModule/Tests/cmake-string-concatenation-use-cmstrcat.cxx +++ b/Utilities/ClangTidyModule/Tests/cmake-string-concatenation-use-cmstrcat.cxx @@ -1,4 +1,5 @@ #include <string> +#include <utility> template <typename... Args> std::string cmStrCat(Args&&... args) @@ -24,6 +25,9 @@ void test1() concat += " and this is a string literal"; concat += 'o'; concat += b + " and this is a string literal " + 'o' + b; + + std::pair<std::string, std::string> p; + concat = p.first + p.second; } // No correction needed |