diff options
133 files changed, 1507 insertions, 932 deletions
diff --git a/.clang-tidy b/.clang-tidy index 7b8d200..a86f39a 100644 --- a/.clang-tidy +++ b/.clang-tidy @@ -7,7 +7,6 @@ bugprone-*,\ -bugprone-misplaced-widening-cast,\ -bugprone-narrowing-conversions,\ -bugprone-too-small-loop-variable,\ -google-readability-casting,\ misc-*,\ -misc-no-recursion,\ -misc-non-private-member-variables-in-classes,\ @@ -24,6 +23,7 @@ readability-*,\ -readability-convert-member-functions-to-static,\ -readability-function-cognitive-complexity,\ -readability-function-size,\ +-readability-identifier-length,\ -readability-identifier-naming,\ -readability-implicit-bool-conversion,\ -readability-inconsistent-declaration-parameter-name,\ @@ -1,3 +1,6 @@ +# Common build directories +build*/ + # Exclude MacOS Finder files. .DS_Store diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 44ea456..2d72170 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -55,7 +55,7 @@ p:source-package: p:doc-package: extends: - - .fedora35_sphinx_package + - .fedora36_sphinx_package - .cmake_prep_doc_linux - .linux_builder_tags_qt - .cmake_doc_artifacts @@ -103,16 +103,16 @@ l:iwyu-debian10: - .linux_builder_tags - .run_automatically -l:tidy-fedora35: +l:tidy-fedora36: extends: - - .fedora35_tidy + - .fedora36_tidy - .cmake_build_linux - .linux_builder_tags_qt - .run_automatically -l:sphinx-fedora35: +l:sphinx-fedora36: extends: - - .fedora35_sphinx + - .fedora36_sphinx - .cmake_build_linux - .linux_builder_tags_qt - .run_automatically @@ -120,9 +120,9 @@ l:sphinx-fedora35: CMAKE_CI_JOB_CONTINUOUS: "true" CMAKE_CI_JOB_HELP: "true" -l:clang-analyzer-fedora35: +l:clang-analyzer-fedora36: extends: - - .fedora35_clang_analyzer + - .fedora36_clang_analyzer - .cmake_build_linux - .linux_builder_tags_qt - .run_automatically @@ -191,17 +191,17 @@ t:debian10-makefiles-clang: variables: CMAKE_CI_JOB_NIGHTLY: "true" -t:fedora35-makefiles: +t:fedora36-makefiles: extends: - - .fedora35_makefiles + - .fedora36_makefiles - .cmake_test_linux_release - .linux_builder_tags_qt - .run_dependent - .needs_centos6_x86_64 -t:fedora35-makefiles-nospace: +t:fedora36-makefiles-nospace: extends: - - .fedora35_makefiles + - .fedora36_makefiles - .cmake_test_linux_release - .linux_builder_tags_qt - .cmake_junit_artifacts @@ -209,7 +209,7 @@ t:fedora35-makefiles-nospace: - .needs_centos6_x86_64 variables: GIT_CLONE_PATH: "$CI_BUILDS_DIR/cmake-ci" - CMAKE_CI_BUILD_NAME: fedora35_makefiles_nospace + CMAKE_CI_BUILD_NAME: fedora36_makefiles_nospace CMAKE_CI_JOB_NIGHTLY: "true" t:cuda9.2-nvidia: @@ -270,9 +270,9 @@ t:hip4.2-radeon: variables: CMAKE_CI_NO_MR: "true" -b:fedora35-ninja: +b:fedora36-ninja: extends: - - .fedora35_ninja + - .fedora36_ninja - .cmake_build_linux - .cmake_build_artifacts - .linux_builder_tags_qt @@ -289,31 +289,31 @@ b:debian10-makefiles-inplace: variables: CMAKE_CI_JOB_NIGHTLY: "true" -t:fedora35-ninja: +t:fedora36-ninja: extends: - - .fedora35_ninja + - .fedora36_ninja - .cmake_test_linux - .linux_builder_tags_x11 - .cmake_test_artifacts - .run_dependent dependencies: - - b:fedora35-ninja + - b:fedora36-ninja needs: - - b:fedora35-ninja + - b:fedora36-ninja variables: CMAKE_CI_JOB_CONTINUOUS: "true" -t:fedora35-ninja-multi: +t:fedora36-ninja-multi: extends: - - .fedora35_ninja_multi + - .fedora36_ninja_multi - .cmake_test_linux_external - .linux_builder_tags_qt - .cmake_junit_artifacts - .run_dependent dependencies: - - t:fedora35-ninja + - t:fedora36-ninja needs: - - t:fedora35-ninja + - t:fedora36-ninja t:intel2016-makefiles: extends: @@ -634,9 +634,9 @@ u:linux-aarch64-package: ## Sanitizer builds -b:fedora35-asan: +b:fedora36-asan: extends: - - .fedora35_asan + - .fedora36_asan - .cmake_build_linux - .cmake_build_artifacts - .linux_builder_tags_qt @@ -644,16 +644,16 @@ b:fedora35-asan: variables: CMAKE_CI_JOB_NIGHTLY: "true" -t:fedora35-asan: +t:fedora36-asan: extends: - - .fedora35_asan + - .fedora36_asan - .cmake_memcheck_linux - .linux_builder_tags_qt - .run_dependent dependencies: - - b:fedora35-asan + - b:fedora36-asan needs: - - b:fedora35-asan + - b:fedora36-asan variables: CMAKE_CI_JOB_NIGHTLY: "true" diff --git a/.gitlab/ci/configure_fedora35_clang_analyzer.cmake b/.gitlab/ci/configure_fedora35_clang_analyzer.cmake deleted file mode 100644 index 761a323..0000000 --- a/.gitlab/ci/configure_fedora35_clang_analyzer.cmake +++ /dev/null @@ -1 +0,0 @@ -include("${CMAKE_CURRENT_LIST_DIR}/configure_fedora35_common.cmake") diff --git a/.gitlab/ci/configure_fedora35_tidy.cmake b/.gitlab/ci/configure_fedora35_tidy.cmake deleted file mode 100644 index 752d241..0000000 --- a/.gitlab/ci/configure_fedora35_tidy.cmake +++ /dev/null @@ -1,3 +0,0 @@ -set(CMake_RUN_CLANG_TIDY ON CACHE BOOL "") - -include("${CMAKE_CURRENT_LIST_DIR}/configure_fedora35_common.cmake") diff --git a/.gitlab/ci/configure_fedora35_asan.cmake b/.gitlab/ci/configure_fedora36_asan.cmake index 84fefad..51977d9 100644 --- a/.gitlab/ci/configure_fedora35_asan.cmake +++ b/.gitlab/ci/configure_fedora36_asan.cmake @@ -1,4 +1,4 @@ set(CMAKE_C_FLAGS "-fsanitize=address" CACHE STRING "") set(CMAKE_CXX_FLAGS "-fsanitize=address" CACHE STRING "") -include("${CMAKE_CURRENT_LIST_DIR}/configure_fedora35_common.cmake") +include("${CMAKE_CURRENT_LIST_DIR}/configure_fedora36_common.cmake") diff --git a/.gitlab/ci/configure_fedora36_clang_analyzer.cmake b/.gitlab/ci/configure_fedora36_clang_analyzer.cmake new file mode 100644 index 0000000..456936b --- /dev/null +++ b/.gitlab/ci/configure_fedora36_clang_analyzer.cmake @@ -0,0 +1 @@ +include("${CMAKE_CURRENT_LIST_DIR}/configure_fedora36_common.cmake") diff --git a/.gitlab/ci/configure_fedora35_common.cmake b/.gitlab/ci/configure_fedora36_common.cmake index 4484e26..4484e26 100644 --- a/.gitlab/ci/configure_fedora35_common.cmake +++ b/.gitlab/ci/configure_fedora36_common.cmake diff --git a/.gitlab/ci/configure_fedora35_makefiles.cmake b/.gitlab/ci/configure_fedora36_makefiles.cmake index 9dc5ca9..9dc5ca9 100644 --- a/.gitlab/ci/configure_fedora35_makefiles.cmake +++ b/.gitlab/ci/configure_fedora36_makefiles.cmake diff --git a/.gitlab/ci/configure_fedora35_ninja.cmake b/.gitlab/ci/configure_fedora36_ninja.cmake index e6143b7..7e33513 100644 --- a/.gitlab/ci/configure_fedora35_ninja.cmake +++ b/.gitlab/ci/configure_fedora36_ninja.cmake @@ -8,4 +8,4 @@ set(CMAKE_CXX_FLAGS_RELEASE "-O3" CACHE STRING "") # Cover compilation with C++11 only and not higher standards. set(CMAKE_CXX_STANDARD "11" CACHE STRING "") -include("${CMAKE_CURRENT_LIST_DIR}/configure_fedora35_common.cmake") +include("${CMAKE_CURRENT_LIST_DIR}/configure_fedora36_common.cmake") diff --git a/.gitlab/ci/configure_fedora35_ninja_multi.cmake b/.gitlab/ci/configure_fedora36_ninja_multi.cmake index efb4b84..efb4b84 100644 --- a/.gitlab/ci/configure_fedora35_ninja_multi.cmake +++ b/.gitlab/ci/configure_fedora36_ninja_multi.cmake diff --git a/.gitlab/ci/configure_fedora35_sphinx.cmake b/.gitlab/ci/configure_fedora36_sphinx.cmake index 90d159b..90d159b 100644 --- a/.gitlab/ci/configure_fedora35_sphinx.cmake +++ b/.gitlab/ci/configure_fedora36_sphinx.cmake diff --git a/.gitlab/ci/configure_fedora35_sphinx_package.cmake b/.gitlab/ci/configure_fedora36_sphinx_package.cmake index e839de8..e839de8 100644 --- a/.gitlab/ci/configure_fedora35_sphinx_package.cmake +++ b/.gitlab/ci/configure_fedora36_sphinx_package.cmake diff --git a/.gitlab/ci/configure_fedora36_tidy.cmake b/.gitlab/ci/configure_fedora36_tidy.cmake new file mode 100644 index 0000000..38414d3 --- /dev/null +++ b/.gitlab/ci/configure_fedora36_tidy.cmake @@ -0,0 +1,3 @@ +set(CMake_RUN_CLANG_TIDY ON CACHE BOOL "") + +include("${CMAKE_CURRENT_LIST_DIR}/configure_fedora36_common.cmake") diff --git a/.gitlab/ci/ctest_memcheck_fedora35_asan.lsan.supp b/.gitlab/ci/ctest_memcheck_fedora36_asan.lsan.supp index 8ec1a03..8ec1a03 100644 --- a/.gitlab/ci/ctest_memcheck_fedora35_asan.lsan.supp +++ b/.gitlab/ci/ctest_memcheck_fedora36_asan.lsan.supp diff --git a/.gitlab/ci/docker/debian10/install_rvm.sh b/.gitlab/ci/docker/debian10/install_rvm.sh index 75c5adc..0ebc746 100755 --- a/.gitlab/ci/docker/debian10/install_rvm.sh +++ b/.gitlab/ci/docker/debian10/install_rvm.sh @@ -14,6 +14,7 @@ gpg2 --keyserver hkps://keyserver.ubuntu.com \ curl -sSL https://get.rvm.io | bash -s stable +# keep version in sync with `env_debian*_ninja.sh` /usr/local/rvm/bin/rvm install ruby-2.7.0 tar -C /usr/local -cf /root/rvm.tar rvm diff --git a/.gitlab/ci/docker/fedora35/Dockerfile b/.gitlab/ci/docker/fedora36/Dockerfile index d1614b4..cf6ded9 100644 --- a/.gitlab/ci/docker/fedora35/Dockerfile +++ b/.gitlab/ci/docker/fedora36/Dockerfile @@ -1,10 +1,10 @@ -FROM fedora:35 as rvm-build +FROM fedora:36 as rvm-build MAINTAINER Ben Boeckel <ben.boeckel@kitware.com> COPY install_rvm.sh /root/install_rvm.sh RUN sh /root/install_rvm.sh -FROM fedora:35 +FROM fedora:36 MAINTAINER Ben Boeckel <ben.boeckel@kitware.com> COPY install_deps.sh /root/install_deps.sh diff --git a/.gitlab/ci/docker/fedora35/install_deps.sh b/.gitlab/ci/docker/fedora36/install_deps.sh index 13c70e6..13c70e6 100755 --- a/.gitlab/ci/docker/fedora35/install_deps.sh +++ b/.gitlab/ci/docker/fedora36/install_deps.sh diff --git a/.gitlab/ci/docker/fedora35/install_ispc.sh b/.gitlab/ci/docker/fedora36/install_ispc.sh index fdc14b5..fdc14b5 100755 --- a/.gitlab/ci/docker/fedora35/install_ispc.sh +++ b/.gitlab/ci/docker/fedora36/install_ispc.sh diff --git a/.gitlab/ci/docker/fedora35/install_rvm.sh b/.gitlab/ci/docker/fedora36/install_rvm.sh index fca5104..0011f87 100755 --- a/.gitlab/ci/docker/fedora35/install_rvm.sh +++ b/.gitlab/ci/docker/fedora36/install_rvm.sh @@ -13,9 +13,7 @@ dnf install --setopt=install_weak_deps=False -y \ curl -sSL https://get.rvm.io | bash -s stable -# This is intentionally an older version. -# If updating, the associated `env_fedora*_makefiles.cmake` file needs updated -# as well. -/usr/local/rvm/bin/rvm install ruby-2.7.0 +# keep version in sync with `env_fedora*_makefiles.cmake` +/usr/local/rvm/bin/rvm install ruby-3.0.4 tar -C /usr/local -cf /root/rvm.tar rvm diff --git a/.gitlab/ci/env_fedora35_makefiles.cmake b/.gitlab/ci/env_fedora35_makefiles.cmake deleted file mode 100644 index aa84e23..0000000 --- a/.gitlab/ci/env_fedora35_makefiles.cmake +++ /dev/null @@ -1,2 +0,0 @@ -set(ENV{MY_RUBY_HOME} "/usr/local/rvm/rubies/ruby-2.7.0") -set(ENV{PATH} "/usr/lib64/mpich/bin:$ENV{PATH}") diff --git a/.gitlab/ci/env_fedora35_asan.sh b/.gitlab/ci/env_fedora36_asan.sh index e976486..e976486 100644 --- a/.gitlab/ci/env_fedora35_asan.sh +++ b/.gitlab/ci/env_fedora36_asan.sh diff --git a/.gitlab/ci/env_fedora35_clang_analyzer.sh b/.gitlab/ci/env_fedora36_clang_analyzer.sh index d732c0b..d732c0b 100644 --- a/.gitlab/ci/env_fedora35_clang_analyzer.sh +++ b/.gitlab/ci/env_fedora36_clang_analyzer.sh diff --git a/.gitlab/ci/env_fedora36_makefiles.cmake b/.gitlab/ci/env_fedora36_makefiles.cmake new file mode 100644 index 0000000..2bcb6d0 --- /dev/null +++ b/.gitlab/ci/env_fedora36_makefiles.cmake @@ -0,0 +1,2 @@ +set(ENV{MY_RUBY_HOME} "/usr/local/rvm/rubies/ruby-3.0.4") +set(ENV{PATH} "/usr/lib64/mpich/bin:$ENV{PATH}") diff --git a/.gitlab/os-linux.yml b/.gitlab/os-linux.yml index f9af14f..a822d94 100644 --- a/.gitlab/os-linux.yml +++ b/.gitlab/os-linux.yml @@ -5,7 +5,7 @@ ### Release .linux_prep_source: - image: "fedora:35" + image: "fedora:36" variables: GIT_CLONE_PATH: "$CI_BUILDS_DIR/cmake ci" @@ -68,8 +68,8 @@ ### Fedora -.fedora35: - image: "kitware/cmake:ci-fedora35-x86_64-2022-04-22" +.fedora36: + image: "kitware/cmake:ci-fedora36-x86_64-2022-05-17" variables: GIT_CLONE_PATH: "$CI_BUILDS_DIR/cmake ci/long file name for testing purposes" @@ -77,37 +77,37 @@ #### Lint builds -.fedora35_tidy: - extends: .fedora35 +.fedora36_tidy: + extends: .fedora36 variables: - CMAKE_CONFIGURATION: fedora35_tidy + CMAKE_CONFIGURATION: fedora36_tidy CTEST_NO_WARNINGS_ALLOWED: 1 CMAKE_CI_NO_INSTALL: 1 -.fedora35_clang_analyzer: - extends: .fedora35 +.fedora36_clang_analyzer: + extends: .fedora36 variables: - CMAKE_CONFIGURATION: fedora35_clang_analyzer + CMAKE_CONFIGURATION: fedora36_clang_analyzer CMAKE_CI_BUILD_TYPE: Debug CTEST_NO_WARNINGS_ALLOWED: 1 CMAKE_CI_NO_INSTALL: 1 -.fedora35_sphinx: - extends: .fedora35 +.fedora36_sphinx: + extends: .fedora36 variables: - CMAKE_CONFIGURATION: fedora35_sphinx + CMAKE_CONFIGURATION: fedora36_sphinx CTEST_NO_WARNINGS_ALLOWED: 1 CTEST_SOURCE_SUBDIRECTORY: "Utilities/Sphinx" CMAKE_CI_NO_INSTALL: 1 -.fedora35_sphinx_package: - extends: .fedora35 +.fedora36_sphinx_package: + extends: .fedora36 variables: - CMAKE_CONFIGURATION: fedora35_sphinx_package + CMAKE_CONFIGURATION: fedora36_sphinx_package CTEST_SOURCE_SUBDIRECTORY: "Utilities/Sphinx" #### Build and test @@ -137,27 +137,27 @@ CMAKE_CI_NO_INSTALL: 1 CTEST_NO_WARNINGS_ALLOWED: 1 -.fedora35_ninja: - extends: .fedora35 +.fedora36_ninja: + extends: .fedora36 variables: - CMAKE_CONFIGURATION: fedora35_ninja + CMAKE_CONFIGURATION: fedora36_ninja CMAKE_CI_BUILD_TYPE: Release CTEST_NO_WARNINGS_ALLOWED: 1 -.fedora35_ninja_multi: - extends: .fedora35 +.fedora36_ninja_multi: + extends: .fedora36 variables: - CMAKE_CONFIGURATION: fedora35_ninja_multi + CMAKE_CONFIGURATION: fedora36_ninja_multi CTEST_NO_WARNINGS_ALLOWED: 1 CMAKE_GENERATOR: "Ninja Multi-Config" -.fedora35_makefiles: - extends: .fedora35 +.fedora36_makefiles: + extends: .fedora36 variables: - CMAKE_CONFIGURATION: fedora35_makefiles + CMAKE_CONFIGURATION: fedora36_makefiles CTEST_NO_WARNINGS_ALLOWED: 1 CMAKE_GENERATOR: "Unix Makefiles" @@ -189,13 +189,13 @@ CTEST_MEMORYCHECK_TYPE: AddressSanitizer CTEST_MEMORYCHECK_SANITIZER_OPTIONS: "" -.fedora35_asan: +.fedora36_asan: extends: - - .fedora35 + - .fedora36 - .fedora_asan_addon variables: - CMAKE_CONFIGURATION: fedora35_asan + CMAKE_CONFIGURATION: fedora36_asan ### Intel Compiler @@ -389,7 +389,7 @@ .cmake_codespell_linux: stage: build - extends: .fedora35 + extends: .fedora36 script: - codespell interruptible: true @@ -532,7 +532,7 @@ .cmake_org_help: stage: build extends: - - .fedora35 + - .fedora36 - .linux_builder_tags - .cmake_org_help_artifacts script: diff --git a/.gitlab/upload.yml b/.gitlab/upload.yml index d831c3e..38d40a9 100644 --- a/.gitlab/upload.yml +++ b/.gitlab/upload.yml @@ -1,7 +1,7 @@ # Steps for uploading artifacts .rsync_upload_package: - image: "fedora:35" + image: "fedora:36" stage: upload tags: - cmake @@ -21,7 +21,7 @@ .rsync_upload_help: stage: upload - image: "fedora:35" + image: "fedora:36" tags: - cmake - docker diff --git a/CTestCustom.cmake.in b/CTestCustom.cmake.in index 093c1d8..49026a3 100644 --- a/CTestCustom.cmake.in +++ b/CTestCustom.cmake.in @@ -98,6 +98,7 @@ list(APPEND CTEST_CUSTOM_WARNING_EXCEPTION "nghttp2/lib/.*:[0-9]+:[0-9]+: warning: Value stored to '[^']+' is never read" "zstd/lib/.*:[0-9]+:[0-9]+: warning: Assigned value is garbage or undefined" "zstd/lib/.*:[0-9]+:[0-9]+: warning: Dereference of null pointer" + "zstd/lib/.*:[0-9]+:[0-9]+: warning: The right operand of .* is a garbage value due to array index out of bounds" ) if(NOT "@CMAKE_GENERATOR@" MATCHES "Xcode") diff --git a/Help/release/dev/pkgconfig-static-libs.rst b/Help/release/dev/pkgconfig-static-libs.rst new file mode 100644 index 0000000..8f7ab0e --- /dev/null +++ b/Help/release/dev/pkgconfig-static-libs.rst @@ -0,0 +1,7 @@ +pkgconfig-static-libs +--------------------- + +* The :module:`FindPkgConfig` module learned to find static libraries + in addition to the default search for shared libraries. + :command:`pkg_check_modules` gained a ``STATIC_TARGET`` option + to make the imported target reference static libraries. diff --git a/Modules/ExternalProject.cmake b/Modules/ExternalProject.cmake index 707de88..e19b7c9 100644 --- a/Modules/ExternalProject.cmake +++ b/Modules/ExternalProject.cmake @@ -244,9 +244,9 @@ External Project Definition .. versionadded:: 3.11 Specify whether the ``.netrc`` file is to be used for operation. - If this option is not specified, the value of the :variable:`CMAKE_NETRC` - variable will be used instead (see :command:`file(DOWNLOAD)`) - Valid levels are: + If this option is not specified, the value of the + :variable:`CMAKE_NETRC` variable will be used instead + (see :command:`file(DOWNLOAD)`). Valid levels are: ``IGNORED`` The ``.netrc`` file is ignored. @@ -386,8 +386,9 @@ External Project Definition override the default strategy. This variable should not be set by a project, it is intended for the user to set. It is primarily intended for use in continuous integration scripts to ensure that when history - is rewritten on a remote branch, the build doesn't end up with unintended - changes or failed builds resulting from conflicts during rebase operations. + is rewritten on a remote branch, the build doesn't end up with + unintended changes or failed builds resulting from conflicts during + rebase operations. *Subversion* ``SVN_REPOSITORY <url>`` @@ -527,7 +528,8 @@ External Project Definition :manual:`CMake Options <cmake(1)>`). .. versionadded:: 3.3 - Arguments may use :manual:`generator expressions <cmake-generator-expressions(7)>`. + Arguments may use + :manual:`generator expressions <cmake-generator-expressions(7)>`. ``CMAKE_CACHE_ARGS <arg>...`` This is an alternate way of specifying cache variables where command line @@ -538,7 +540,8 @@ External Project Definition using the :manual:`cmake -C <cmake(1)>` command line option. .. versionadded:: 3.3 - Arguments may use :manual:`generator expressions <cmake-generator-expressions(7)>`. + Arguments may use + :manual:`generator expressions <cmake-generator-expressions(7)>`. ``CMAKE_CACHE_DEFAULT_ARGS <arg>...`` .. versionadded:: 3.2 @@ -551,7 +554,7 @@ External Project Definition build directory or re-uses previous build contents. .. versionadded:: 3.15 - If the CMake generator is the ``Green Hills MULTI`` and not overridden then + If the CMake generator is the ``Green Hills MULTI`` and not overridden, the original project's settings for the GHS toolset and target system customization cache variables are propagated into the external project. @@ -1017,9 +1020,9 @@ control needed to implement such step-level capabilities. .. versionadded:: 3.19 If :policy:`CMP0114` is set to ``NEW``, step targets are fully responsible - for holding the custom commands implementing their steps. The primary target - created by ``ExternalProject_Add`` depends on the step targets, and the - step targets depend on each other. The target-level dependencies match + for holding the custom commands implementing their steps. The primary + target created by ``ExternalProject_Add`` depends on the step targets, and + the step targets depend on each other. The target-level dependencies match the file-level dependencies used by the custom commands for each step. The targets for steps created with :command:`ExternalProject_Add_Step`'s ``INDEPENDENT`` option do not depend on the external targets specified @@ -1031,16 +1034,16 @@ control needed to implement such step-level capabilities. * A deprecated ``NO_DEPENDS`` option may be specified immediately after the ``<name>`` and before the first step. - If the ``NO_DEPENDS`` option is specified, the step target will not depend on - the dependencies of the external project (i.e. on any dependencies of the + If the ``NO_DEPENDS`` option is specified, the step target will not depend + on the dependencies of the external project (i.e. on any dependencies of the ``<name>`` custom target created by :command:`ExternalProject_Add`). This is - usually safe for the ``download``, ``update`` and ``patch`` steps, since they - do not typically require that the dependencies are updated and built. Using - ``NO_DEPENDS`` for any of the other pre-defined steps, however, may break - parallel builds. Only use ``NO_DEPENDS`` where it is certain that the named - steps genuinely do not have dependencies. For custom steps, consider whether - or not the custom commands require the dependencies to be configured, built - and installed. + usually safe for the ``download``, ``update`` and ``patch`` steps, since + they do not typically require that the dependencies are updated and built. + Using ``NO_DEPENDS`` for any of the other pre-defined steps, however, may + break parallel builds. Only use ``NO_DEPENDS`` where it is certain that the + named steps genuinely do not have dependencies. For custom steps, consider + whether or not the custom commands require the dependencies to be + configured, built and installed. * The ``INDEPENDENT_STEP_TARGETS`` option for :command:`ExternalProject_Add`, or the ``EP_INDEPENDENT_STEP_TARGETS`` directory property, tells the @@ -1190,7 +1193,13 @@ macro(_ep_get_hash_regex out_var) set(${out_var} "^(${${out_var}})=([0-9A-Fa-f]+)$") endmacro() -function(_ep_parse_arguments f keywords name ns args) +function(_ep_parse_arguments + f + keywords + name + ns + args +) # Transfer the arguments to this function into target properties for the # new custom target we just added so that we can set up all the build steps # correctly based on target properties. @@ -1206,7 +1215,8 @@ function(_ep_parse_arguments f keywords name ns args) set(is_value 1) if(arg MATCHES "^[A-Z][A-Z0-9_][A-Z0-9_]+$" AND - NOT (("x${arg}x" STREQUAL "x${key}x") AND ("x${key}x" STREQUAL "xCOMMANDx")) AND + NOT (("x${arg}x" STREQUAL "x${key}x") AND + ("x${key}x" STREQUAL "xCOMMANDx")) AND NOT arg MATCHES "^(TRUE|FALSE)$") if(arg IN_LIST keywords) set(is_value 0) @@ -1229,7 +1239,9 @@ function(_ep_parse_arguments f keywords name ns args) endif() else() # Missing Keyword - message(AUTHOR_WARNING "value '${arg}' with no previous keyword in ${f}") + message(AUTHOR_WARNING + "value '${arg}' with no previous keyword in ${f}" + ) endif() else() set(key "${arg}") @@ -1238,63 +1250,31 @@ function(_ep_parse_arguments f keywords name ns args) endfunction() -define_property(DIRECTORY PROPERTY "EP_BASE" INHERITED - BRIEF_DOCS "Base directory for External Project storage." - FULL_DOCS - "See documentation of the ExternalProject_Add() function in the " - "ExternalProject module." - ) - -define_property(DIRECTORY PROPERTY "EP_PREFIX" INHERITED - BRIEF_DOCS "Top prefix for External Project storage." - FULL_DOCS - "See documentation of the ExternalProject_Add() function in the " - "ExternalProject module." - ) - -define_property(DIRECTORY PROPERTY "EP_STEP_TARGETS" INHERITED - BRIEF_DOCS - "List of ExternalProject steps that automatically get corresponding targets" - FULL_DOCS - "These targets will be dependent on the main target dependencies. " - "See documentation of the ExternalProject_Add_StepTargets() function in the " - "ExternalProject module." - ) - -define_property(DIRECTORY PROPERTY "EP_INDEPENDENT_STEP_TARGETS" INHERITED - BRIEF_DOCS - "List of ExternalProject steps that automatically get corresponding targets" - FULL_DOCS - "These targets will not be dependent on the main target dependencies. " - "See documentation of the ExternalProject_Add_StepTargets() function in the " - "ExternalProject module." - ) - -define_property(DIRECTORY PROPERTY "EP_UPDATE_DISCONNECTED" INHERITED - BRIEF_DOCS "Never update automatically from the remote repo." - FULL_DOCS - "See documentation of the ExternalProject_Add() function in the " - "ExternalProject module." - ) +define_property(DIRECTORY PROPERTY "EP_BASE" INHERITED) +define_property(DIRECTORY PROPERTY "EP_PREFIX" INHERITED) +define_property(DIRECTORY PROPERTY "EP_STEP_TARGETS" INHERITED) +define_property(DIRECTORY PROPERTY "EP_INDEPENDENT_STEP_TARGETS" INHERITED) +define_property(DIRECTORY PROPERTY "EP_UPDATE_DISCONNECTED" INHERITED) function(_ep_write_gitclone_script - script_filename - source_dir - git_EXECUTABLE - git_repository - git_tag - git_remote_name - init_submodules - git_submodules_recurse - git_submodules - git_shallow - git_progress - git_config - src_name - work_dir - gitclone_infofile - gitclone_stampfile - tls_verify) + script_filename + source_dir + git_EXECUTABLE + git_repository + git_tag + git_remote_name + init_submodules + git_submodules_recurse + git_submodules + git_shallow + git_progress + git_config + src_name + work_dir + gitclone_infofile + gitclone_stampfile + tls_verify +) if(NOT GIT_VERSION_STRING VERSION_LESS 1.8.5) # Use `git checkout <tree-ish> --` to avoid ambiguity with a local path. @@ -1309,7 +1289,8 @@ function(_ep_write_gitclone_script message(FATAL_ERROR "Tag for git checkout should not be empty.") endif() - if(GIT_VERSION_STRING VERSION_LESS 2.20 OR 2.21 VERSION_LESS_EQUAL GIT_VERSION_STRING) + if(GIT_VERSION_STRING VERSION_LESS 2.20 OR + 2.21 VERSION_LESS_EQUAL GIT_VERSION_STRING) set(git_clone_options "--no-checkout") else() set(git_clone_options) @@ -1337,7 +1318,8 @@ function(_ep_write_gitclone_script # disable cert checking if explicitly told not to do it if(NOT "x${tls_verify}" STREQUAL "x" AND NOT tls_verify) set(git_options - -c http.sslVerify=false) + -c http.sslVerify=false + ) endif() string (REPLACE ";" " " git_options "${git_options}") @@ -1349,15 +1331,16 @@ function(_ep_write_gitclone_script endfunction() function(_ep_write_hgclone_script - script_filename - source_dir - hg_EXECUTABLE - hg_repository - hg_tag - src_name - work_dir - hgclone_infofile - hgclone_stampfile) + script_filename + source_dir + hg_EXECUTABLE + hg_repository + hg_tag + src_name + work_dir + hgclone_infofile + hgclone_stampfile +) if("${hg_tag}" STREQUAL "") message(FATAL_ERROR "Tag for hg checkout should not be empty.") @@ -1372,16 +1355,17 @@ endfunction() function(_ep_write_gitupdate_script - script_filename - git_EXECUTABLE - git_tag - git_remote_name - init_submodules - git_submodules_recurse - git_submodules - git_repository - work_dir - git_update_strategy) + script_filename + git_EXECUTABLE + git_tag + git_remote_name + init_submodules + git_submodules_recurse + git_submodules + git_repository + work_dir + git_update_strategy +) if("${git_tag}" STREQUAL "") message(FATAL_ERROR "Tag for git checkout should not be empty.") @@ -1403,20 +1387,20 @@ function(_ep_write_gitupdate_script endfunction() function(_ep_write_downloadfile_script - script_filename - REMOTE - LOCAL - timeout - inactivity_timeout - no_progress - hash - tls_verify - tls_cainfo - userpwd - http_headers - netrc - netrc_file) - + script_filename + REMOTE + LOCAL + timeout + inactivity_timeout + no_progress + hash + tls_verify + tls_cainfo + userpwd + http_headers + netrc + netrc_file +) if(timeout) set(TIMEOUT_ARGS TIMEOUT ${timeout}) set(TIMEOUT_MSG "${timeout} seconds") @@ -1499,9 +1483,8 @@ function(_ep_write_downloadfile_script set(HTTP_HEADERS_ARGS "") if(NOT http_headers STREQUAL "") foreach(header ${http_headers}) - set( - HTTP_HEADERS_ARGS - "HTTPHEADER \"${header}\"\n ${HTTP_HEADERS_ARGS}" + string(PREPEND HTTP_HEADERS_ARGS + "HTTPHEADER \"${header}\"\n " ) endforeach() endif() @@ -1519,13 +1502,17 @@ function(_ep_write_downloadfile_script # * USERPWD_ARGS # * HTTP_HEADERS_ARGS configure_file( - "${CMAKE_CURRENT_FUNCTION_LIST_DIR}/ExternalProject/download.cmake.in" - "${script_filename}" - @ONLY + "${CMAKE_CURRENT_FUNCTION_LIST_DIR}/ExternalProject/download.cmake.in" + "${script_filename}" + @ONLY ) endfunction() -function(_ep_write_verifyfile_script script_filename LOCAL hash) +function(_ep_write_verifyfile_script + script_filename + LOCAL + hash +) _ep_get_hash_regex(_ep_hash_regex) if("${hash}" MATCHES "${_ep_hash_regex}") set(ALGO "${CMAKE_MATCH_1}") @@ -1540,17 +1527,23 @@ function(_ep_write_verifyfile_script script_filename LOCAL hash) # * EXPECT_VALUE # * LOCAL configure_file( - "${CMAKE_CURRENT_FUNCTION_LIST_DIR}/ExternalProject/verify.cmake.in" - "${script_filename}" - @ONLY + "${CMAKE_CURRENT_FUNCTION_LIST_DIR}/ExternalProject/verify.cmake.in" + "${script_filename}" + @ONLY ) endfunction() -function(_ep_write_extractfile_script script_filename name filename directory options) +function(_ep_write_extractfile_script + script_filename + name + filename + directory options +) set(args "") - if(filename MATCHES "(\\.|=)(7z|tar\\.bz2|tar\\.gz|tar\\.xz|tbz2|tgz|txz|zip)$") + if(filename MATCHES + "(\\.|=)(7z|tar\\.bz2|tar\\.gz|tar\\.xz|tbz2|tgz|txz|zip)$") set(args xfz) endif() @@ -1559,8 +1552,10 @@ function(_ep_write_extractfile_script script_filename name filename directory op endif() if(args STREQUAL "") - message(SEND_ERROR "error: do not know how to extract '${filename}' -- known types are .7z, .tar, .tar.bz2, .tar.gz, .tar.xz, .tbz2, .tgz, .txz and .zip") - return() + message(FATAL_ERROR + "Do not know how to extract '${filename}' -- known types are: " + ".7z, .tar, .tar.bz2, .tar.gz, .tar.xz, .tbz2, .tgz, .txz and .zip" + ) endif() configure_file( @@ -1604,7 +1599,8 @@ function(_ep_set_directories name) get_property(have_binary_dir TARGET ${name} PROPERTY _EP_BINARY_DIR SET) if(have_binary_dir) message(FATAL_ERROR - "External project ${name} has both BINARY_DIR and BUILD_IN_SOURCE!") + "External project ${name} has both BINARY_DIR and BUILD_IN_SOURCE!" + ) endif() endif() set(top "${CMAKE_CURRENT_BINARY_DIR}") @@ -1640,7 +1636,8 @@ function(_ep_set_directories name) set_property(TARGET ${name} PROPERTY _EP_SOURCE_SUBDIR "") elseif(IS_ABSOLUTE "${source_subdir}") message(FATAL_ERROR - "External project ${name} has non-relative SOURCE_SUBDIR!") + "External project ${name} has non-relative SOURCE_SUBDIR!" + ) else() # Prefix with a slash so that when appended to the source directory, it # behaves as expected. @@ -1650,9 +1647,13 @@ function(_ep_set_directories name) if(build_in_source) get_property(source_dir TARGET ${name} PROPERTY _EP_SOURCE_DIR) if(source_subdir) - set_property(TARGET ${name} PROPERTY _EP_BINARY_DIR "${source_dir}/${source_subdir}") + set_property(TARGET ${name} PROPERTY + _EP_BINARY_DIR "${source_dir}/${source_subdir}" + ) else() - set_property(TARGET ${name} PROPERTY _EP_BINARY_DIR "${source_dir}") + set_property(TARGET ${name} PROPERTY + _EP_BINARY_DIR "${source_dir}" + ) endif() endif() @@ -1679,7 +1680,16 @@ macro(_ep_replace_location_tags target_name) set(vars ${ARGN}) foreach(var ${vars}) if(${var}) - foreach(dir SOURCE_DIR SOURCE_SUBDIR BINARY_DIR INSTALL_DIR TMP_DIR DOWNLOAD_DIR DOWNLOADED_FILE LOG_DIR) + foreach(dir + SOURCE_DIR + SOURCE_SUBDIR + BINARY_DIR + INSTALL_DIR + TMP_DIR + DOWNLOAD_DIR + DOWNLOADED_FILE + LOG_DIR + ) get_property(val TARGET ${target_name} PROPERTY _EP_${dir}) string(REPLACE "<${dir}>" "${val}" ${var} "${${var}}") endforeach() @@ -1688,7 +1698,11 @@ macro(_ep_replace_location_tags target_name) endmacro() -function(_ep_command_line_to_initial_cache var args force) +function(_ep_command_line_to_initial_cache + var + args + force +) set(script_initial_cache "") set(regex "^([^:]+):([^=]+)=(.*)$") set(setArg "") @@ -1701,7 +1715,9 @@ function(_ep_command_line_to_initial_cache var args force) set(line "${CMAKE_MATCH_1}") if(NOT "${setArg}" STREQUAL "") # This is required to build up lists in variables, or complete an entry - string(APPEND setArg "${accumulator}\" CACHE ${type} \"Initial cache\" ${forceArg})") + string(APPEND setArg + "${accumulator}\" CACHE ${type} \"Initial cache\" ${forceArg})" + ) string(APPEND script_initial_cache "\n${setArg}") set(accumulator "") set(setArg "") @@ -1721,14 +1737,20 @@ function(_ep_command_line_to_initial_cache var args force) endforeach() # Catch the final line of the args if(NOT "${setArg}" STREQUAL "") - string(APPEND setArg "${accumulator}\" CACHE ${type} \"Initial cache\" ${forceArg})") + string(APPEND setArg + "${accumulator}\" CACHE ${type} \"Initial cache\" ${forceArg})" + ) string(APPEND script_initial_cache "\n${setArg}") endif() set(${var} ${script_initial_cache} PARENT_SCOPE) endfunction() -function(_ep_write_initial_cache target_name script_filename script_initial_cache) +function(_ep_write_initial_cache + target_name + script_filename + script_initial_cache +) # Write out values into an initial cache, that will be passed to CMake with -C # Replace location tags. _ep_replace_location_tags(${target_name} script_initial_cache) @@ -1756,7 +1778,10 @@ function(ExternalProject_Get_Property name) endfunction() -function(_ep_get_configure_command_id name cfg_cmd_id_var) +function(_ep_get_configure_command_id + name + cfg_cmd_id_var +) get_target_property(cmd ${name} _EP_CONFIGURE_COMMAND) if(cmd STREQUAL "") @@ -1782,7 +1807,11 @@ function(_ep_get_configure_command_id name cfg_cmd_id_var) endfunction() -function(_ep_get_build_command name step cmd_var) +function(_ep_get_build_command + name + step + cmd_var +) set(cmd "") set(args) _ep_get_configure_command_id(${name} cfg_cmd_id) @@ -1820,8 +1849,10 @@ function(_ep_get_build_command name step cmd_var) # BUILD_COMMAND to change the default command instead, but for # compatibility honor the value. set(config ${CMAKE_CFG_INTDIR}) - message(AUTHOR_WARNING "CMAKE_CFG_INTDIR should not be set by project code.\n" - "To get a non-default build command, use the BUILD_COMMAND option.") + message(AUTHOR_WARNING + "CMAKE_CFG_INTDIR should not be set by project code.\n" + "To get a non-default build command, use the BUILD_COMMAND option." + ) else() set(config $<CONFIG>) endif() @@ -1869,7 +1900,11 @@ function(_ep_get_build_command name step cmd_var) set(${cmd_var} "${cmd}" PARENT_SCOPE) endfunction() -function(_ep_write_log_script name step cmd_var) +function(_ep_write_log_script + name + step + cmd_var +) ExternalProject_Get_Property(${name} log_dir) ExternalProject_Get_Property(${name} stamp_dir) set(command "${${cmd_var}}") @@ -1936,15 +1971,29 @@ endif() endif() endforeach() string(APPEND code "set(command \"${cmd}\")${code_execute_process}") - file(GENERATE OUTPUT "${stamp_dir}/${name}-${step}-$<CONFIG>-impl.cmake" CONTENT "${code}") - set(command ${CMAKE_COMMAND} "-Dmake=\${make}" "-Dconfig=\${config}" -P ${stamp_dir}/${name}-${step}-$<CONFIG>-impl.cmake) + file(GENERATE + OUTPUT "${stamp_dir}/${name}-${step}-$<CONFIG>-impl.cmake" + CONTENT "${code}" + ) + set(command + ${CMAKE_COMMAND} + "-Dmake=\${make}" + "-Dconfig=\${config}" + -P ${stamp_dir}/${name}-${step}-$<CONFIG>-impl.cmake + ) endif() # Wrap the command in a script to log output to files. set(script ${stamp_dir}/${name}-${step}-$<CONFIG>.cmake) set(logbase ${log_dir}/${name}-${step}) - get_property(log_merged TARGET ${name} PROPERTY _EP_LOG_MERGED_STDOUTERR) - get_property(log_output_on_failure TARGET ${name} PROPERTY _EP_LOG_OUTPUT_ON_FAILURE) + get_property(log_merged + TARGET ${name} + PROPERTY _EP_LOG_MERGED_STDOUTERR + ) + get_property(log_output_on_failure + TARGET ${name} + PROPERTY _EP_LOG_OUTPUT_ON_FAILURE + ) if (log_merged) set(stdout_log "${logbase}.log") set(stderr_log "${logbase}.log") @@ -1965,7 +2014,7 @@ execute_process( RESULT_VARIABLE result OUTPUT_FILE \"\${stdout_log}\" ERROR_FILE \"\${stderr_log}\" - ) +) macro(read_up_to_max_size log_file output_var) file(SIZE \${log_file} determined_size) set(max_size 10240) @@ -2032,7 +2081,11 @@ function(_ep_get_configuration_subdir_suffix suffix_var) endfunction() -function(_ep_get_step_stampfile name step stampfile_var) +function(_ep_get_step_stampfile + name + step + stampfile_var +) ExternalProject_Get_Property(${name} stamp_dir) _ep_get_configuration_subdir_suffix(cfgdir) @@ -2042,7 +2095,10 @@ function(_ep_get_step_stampfile name step stampfile_var) endfunction() -function(_ep_get_complete_stampfile name stampfile_var) +function(_ep_get_complete_stampfile + name + stampfile_var +) set(cmf_dir ${CMAKE_CURRENT_BINARY_DIR}/CMakeFiles) _ep_get_configuration_subdir_suffix(cfgdir) set(stampfile "${cmf_dir}${cfgdir}/${name}-complete") @@ -2051,7 +2107,11 @@ function(_ep_get_complete_stampfile name stampfile_var) endfunction() -function(_ep_step_add_target name step no_deps) +function(_ep_step_add_target + name + step + no_deps +) if(TARGET ${name}-${step}) return() endif() @@ -2063,16 +2123,20 @@ function(_ep_step_add_target name step no_deps) # we need CMP0113 NEW behavior. cmake_policy(SET CMP0113 NEW) endif() - add_custom_target(${name}-${step} - DEPENDS ${stamp_file}) + add_custom_target(${name}-${step} DEPENDS ${stamp_file}) cmake_policy(POP) - set_property(TARGET ${name}-${step} PROPERTY _EP_IS_EXTERNAL_PROJECT_STEP 1) - set_property(TARGET ${name}-${step} PROPERTY LABELS ${name}) - set_property(TARGET ${name}-${step} PROPERTY FOLDER "ExternalProjectTargets/${name}") + set_target_properties(${name}-${step} PROPERTIES + _EP_IS_EXTERNAL_PROJECT_STEP 1 + LABELS "${name}" + FOLDER "ExternalProjectTargets/${name}" + ) if(cmp0114 STREQUAL "NEW") # Add target-level dependencies for the step. - get_property(exclude_from_main TARGET ${name} PROPERTY _EP_${step}_EXCLUDE_FROM_MAIN) + get_property(exclude_from_main + TARGET ${name} + PROPERTY _EP_${step}_EXCLUDE_FROM_MAIN + ) if(NOT exclude_from_main) add_dependencies(${name} ${name}-${step}) endif() @@ -2082,7 +2146,9 @@ function(_ep_step_add_target name step no_deps) get_property(independent TARGET ${name} PROPERTY _EP_${step}_INDEPENDENT) else() if(no_deps AND "${step}" MATCHES "^(configure|build|install|test)$") - message(AUTHOR_WARNING "Using NO_DEPENDS for \"${step}\" step might break parallel builds") + message(AUTHOR_WARNING + "Using NO_DEPENDS for \"${step}\" step might break parallel builds" + ) endif() set(independent ${no_deps}) endif() @@ -2097,12 +2163,25 @@ function(_ep_step_add_target name step no_deps) endfunction() -function(_ep_step_add_target_dependencies name step node) - get_property(dependees TARGET ${name} PROPERTY _EP_${node}_INTERNAL_DEPENDEES) +function(_ep_step_add_target_dependencies + name + step + node +) + get_property(dependees + TARGET ${name} + PROPERTY _EP_${node}_INTERNAL_DEPENDEES + ) list(REMOVE_DUPLICATES dependees) foreach(dependee IN LISTS dependees) - get_property(exclude_from_main TARGET ${name} PROPERTY _EP_${step}_EXCLUDE_FROM_MAIN) - get_property(dependee_dependers TARGET ${name} PROPERTY _EP_${dependee}_INTERNAL_DEPENDERS) + get_property(exclude_from_main + TARGET ${name} + PROPERTY _EP_${step}_EXCLUDE_FROM_MAIN + ) + get_property(dependee_dependers + TARGET ${name} + PROPERTY _EP_${dependee}_INTERNAL_DEPENDERS + ) if(exclude_from_main OR dependee_dependers MATCHES ";") # The step on which our step target depends itself has # dependents in multiple targes. It needs a step target too @@ -2119,8 +2198,15 @@ function(_ep_step_add_target_dependencies name step node) endfunction() -function(_ep_step_add_target_dependents name step node) - get_property(dependers TARGET ${name} PROPERTY _EP_${node}_INTERNAL_DEPENDERS) +function(_ep_step_add_target_dependents + name + step + node +) + get_property(dependers + TARGET ${name} + PROPERTY _EP_${node}_INTERNAL_DEPENDERS + ) list(REMOVE_DUPLICATES dependers) foreach(depender IN LISTS dependers) if(TARGET ${name}-${depender}) @@ -2147,7 +2233,7 @@ function(ExternalProject_Add_StepTargets name) "The 'NO_DEPENDS' option is no longer allowed. " "It has been superseded by the per-step 'INDEPENDENT' option. " "See policy CMP0114." - ) + ) endif() elseif(cmp0114 STREQUAL "") cmake_policy(GET_WARNING CMP0114 _cmp0114_warning) @@ -2155,11 +2241,11 @@ function(ExternalProject_Add_StepTargets name) "ExternalProject target '${name}' would depend on the targets for " "step(s) '${steps}' under policy CMP0114, but this is being left out " "for compatibility since the policy is not set." - ) + ) if(no_deps) - string(APPEND _cmp0114_warning - " Also, the NO_DEPENDS option is deprecated in favor of policy CMP0114." - ) + string(APPEND _cmp0114_warning " " + "Also, the NO_DEPENDS option is deprecated in favor of policy CMP0114." + ) endif() message(AUTHOR_WARNING "${_cmp0114_warning}") endif() @@ -2188,38 +2274,60 @@ function(ExternalProject_Add_Step name step) LOG USES_TERMINAL ) - _ep_parse_arguments(ExternalProject_Add_Step "${keywords}" - ${name} _EP_${step}_ "${ARGN}") + _ep_parse_arguments( + ExternalProject_Add_Step + "${keywords}" + ${name} + _EP_${step}_ + "${ARGN}" + ) - get_property(independent TARGET ${name} PROPERTY _EP_${step}_INDEPENDENT) + get_property(independent + TARGET ${name} + PROPERTY _EP_${step}_INDEPENDENT + ) if(independent STREQUAL "") set(independent FALSE) - set_property(TARGET ${name} PROPERTY _EP_${step}_INDEPENDENT "${independent}") + set_property(TARGET ${name} PROPERTY + _EP_${step}_INDEPENDENT "${independent}" + ) endif() - get_property(exclude_from_main TARGET ${name} PROPERTY _EP_${step}_EXCLUDE_FROM_MAIN) + get_property(exclude_from_main + TARGET ${name} + PROPERTY _EP_${step}_EXCLUDE_FROM_MAIN + ) if(NOT exclude_from_main) add_custom_command(APPEND OUTPUT ${complete_stamp_file} DEPENDS ${stamp_file} - ) + ) endif() # Steps depending on this step. get_property(dependers TARGET ${name} PROPERTY _EP_${step}_DEPENDERS) - set_property(TARGET ${name} APPEND PROPERTY _EP_${step}_INTERNAL_DEPENDERS ${dependers}) + set_property(TARGET ${name} APPEND PROPERTY + _EP_${step}_INTERNAL_DEPENDERS ${dependers} + ) foreach(depender IN LISTS dependers) - set_property(TARGET ${name} APPEND PROPERTY _EP_${depender}_INTERNAL_DEPENDEES ${step}) + set_property(TARGET ${name} APPEND PROPERTY + _EP_${depender}_INTERNAL_DEPENDEES ${step} + ) _ep_get_step_stampfile(${name} ${depender} depender_stamp_file) add_custom_command(APPEND OUTPUT ${depender_stamp_file} DEPENDS ${stamp_file} - ) + ) if(cmp0114 STREQUAL "NEW" AND NOT independent) - get_property(dep_independent TARGET ${name} PROPERTY _EP_${depender}_INDEPENDENT) + get_property(dep_independent + TARGET ${name} + PROPERTY _EP_${depender}_INDEPENDENT + ) if(dep_independent) - message(FATAL_ERROR "ExternalProject '${name}' step '${depender}' is marked INDEPENDENT " - "but depends on step '${step}' that is not marked INDEPENDENT.") + message(FATAL_ERROR + "ExternalProject '${name}' step '${depender}' is marked INDEPENDENT " + "but depends on step '${step}' that is not marked INDEPENDENT." + ) endif() endif() endforeach() @@ -2232,16 +2340,25 @@ function(ExternalProject_Add_Step name step) # Dependencies on steps. get_property(dependees TARGET ${name} PROPERTY _EP_${step}_DEPENDEES) - set_property(TARGET ${name} APPEND PROPERTY _EP_${step}_INTERNAL_DEPENDEES ${dependees}) + set_property(TARGET ${name} APPEND PROPERTY + _EP_${step}_INTERNAL_DEPENDEES ${dependees} + ) foreach(dependee IN LISTS dependees) - set_property(TARGET ${name} APPEND PROPERTY _EP_${dependee}_INTERNAL_DEPENDERS ${step}) + set_property(TARGET ${name} APPEND PROPERTY + _EP_${dependee}_INTERNAL_DEPENDERS ${step} + ) _ep_get_step_stampfile(${name} ${dependee} dependee_stamp_file) list(APPEND depends ${dependee_stamp_file}) if(cmp0114 STREQUAL "NEW" AND independent) - get_property(dep_independent TARGET ${name} PROPERTY _EP_${dependee}_INDEPENDENT) + get_property(dep_independent + TARGET ${name} + PROPERTY _EP_${dependee}_INDEPENDENT + ) if(NOT dep_independent) - message(FATAL_ERROR "ExternalProject '${name}' step '${step}' is marked INDEPENDENT " - "but depends on step '${dependee}' that is not marked INDEPENDENT.") + message(FATAL_ERROR + "ExternalProject '${name}' step '${step}' is marked INDEPENDENT " + "but depends on step '${dependee}' that is not marked INDEPENDENT." + ) endif() endif() endforeach() @@ -2253,25 +2370,47 @@ function(ExternalProject_Add_Step name step) else() set(comment "No ${step} step for '${name}'") endif() - get_property(work_dir TARGET ${name} PROPERTY _EP_${step}_WORKING_DIRECTORY) + get_property(work_dir + TARGET ${name} + PROPERTY _EP_${step}_WORKING_DIRECTORY + ) # Replace list separators. - get_property(sep TARGET ${name} PROPERTY _EP_LIST_SEPARATOR) + get_property(sep + TARGET ${name} + PROPERTY _EP_LIST_SEPARATOR + ) if(sep AND command) string(REPLACE "${sep}" "\\;" command "${command}") endif() # Replace location tags. - _ep_replace_location_tags(${name} comment command work_dir byproducts) + _ep_replace_location_tags( + ${name} + comment + command + work_dir + byproducts + ) # Custom comment? - get_property(comment_set TARGET ${name} PROPERTY _EP_${step}_COMMENT SET) + get_property(comment_set + TARGET ${name} + PROPERTY _EP_${step}_COMMENT + SET + ) if(comment_set) - get_property(comment TARGET ${name} PROPERTY _EP_${step}_COMMENT) + get_property(comment + TARGET ${name} + PROPERTY _EP_${step}_COMMENT + ) endif() # Uses terminal? - get_property(uses_terminal TARGET ${name} PROPERTY _EP_${step}_USES_TERMINAL) + get_property(uses_terminal + TARGET ${name} + PROPERTY _EP_${step}_USES_TERMINAL + ) if(uses_terminal) set(uses_terminal USES_TERMINAL) else() @@ -2279,7 +2418,10 @@ function(ExternalProject_Add_Step name step) endif() # Run every time? - get_property(always TARGET ${name} PROPERTY _EP_${step}_ALWAYS) + get_property(always + TARGET ${name} + PROPERTY _EP_${step}_ALWAYS + ) if(always) set_property(SOURCE ${stamp_file} PROPERTY SYMBOLIC 1) set(touch) @@ -2287,7 +2429,9 @@ function(ExternalProject_Add_Step name step) get_property(_isMultiConfig GLOBAL PROPERTY GENERATOR_IS_MULTI_CONFIG) if(_isMultiConfig) foreach(cfg ${CMAKE_CONFIGURATION_TYPES}) - string(REPLACE "/${CMAKE_CFG_INTDIR}" "/${cfg}" stamp_file_config "${stamp_file}") + string(REPLACE "/${CMAKE_CFG_INTDIR}" "/${cfg}" + stamp_file_config "${stamp_file}" + ) file(REMOVE ${stamp_file_config}) endforeach() else() @@ -2332,9 +2476,15 @@ function(ExternalProject_Add_Step name step) set_property(TARGET ${name} APPEND PROPERTY _EP_STEPS ${step}) # Add custom "step target"? - get_property(step_targets TARGET ${name} PROPERTY _EP_STEP_TARGETS) + get_property(step_targets + TARGET ${name} + PROPERTY _EP_STEP_TARGETS + ) if(NOT step_targets) - get_property(step_targets DIRECTORY PROPERTY EP_STEP_TARGETS) + get_property(step_targets + DIRECTORY + PROPERTY EP_STEP_TARGETS + ) endif() foreach(st ${step_targets}) if("${st}" STREQUAL "${step}") @@ -2343,31 +2493,43 @@ function(ExternalProject_Add_Step name step) endif() endforeach() - get_property(independent_step_targets TARGET ${name} PROPERTY _EP_INDEPENDENT_STEP_TARGETS) + get_property(independent_step_targets + TARGET ${name} PROPERTY + _EP_INDEPENDENT_STEP_TARGETS + ) if(NOT independent_step_targets) - get_property(independent_step_targets DIRECTORY PROPERTY EP_INDEPENDENT_STEP_TARGETS) + get_property(independent_step_targets + DIRECTORY + PROPERTY EP_INDEPENDENT_STEP_TARGETS + ) endif() if(cmp0114 STREQUAL "NEW") if(independent_step_targets) message(FATAL_ERROR - "ExternalProject '${name}' option 'INDEPENDENT_STEP_TARGETS' is set to\n" - " ${independent_step_targets}\n" + "ExternalProject '${name}' option 'INDEPENDENT_STEP_TARGETS' is set to" + "\n ${independent_step_targets}\n" "but the option is no longer allowed. " "It has been superseded by the per-step 'INDEPENDENT' option. " "See policy CMP0114." - ) + ) endif() else() if(independent_step_targets AND cmp0114 STREQUAL "") - get_property(warned TARGET ${name} PROPERTY _EP_CMP0114_WARNED_INDEPENDENT_STEP_TARGETS) + get_property(warned + TARGET ${name} + PROPERTY _EP_CMP0114_WARNED_INDEPENDENT_STEP_TARGETS + ) if(NOT warned) - set_property(TARGET ${name} PROPERTY _EP_CMP0114_WARNED_INDEPENDENT_STEP_TARGETS 1) + set_property(TARGET ${name} PROPERTY + _EP_CMP0114_WARNED_INDEPENDENT_STEP_TARGETS 1 + ) cmake_policy(GET_WARNING CMP0114 _cmp0114_warning) - string(APPEND _cmp0114_warning "\n" - "ExternalProject '${name}' option INDEPENDENT_STEP_TARGETS is set to\n" - " ${independent_step_targets}\n" + string(APPEND _cmp0114_warning + "\n" + "ExternalProject '${name}' option INDEPENDENT_STEP_TARGETS is set to" + "\n ${independent_step_targets}\n" "but the option is deprecated in favor of policy CMP0114." - ) + ) message(AUTHOR_WARNING "${_cmp0114_warning}") endif() endif() @@ -2386,33 +2548,51 @@ function(ExternalProject_Add_StepDependencies name step) # Sanity checks on "name" and "step". if(NOT TARGET ${name}) - message(FATAL_ERROR "Cannot find target \"${name}\". Perhaps it has not yet been created using ExternalProject_Add.") + message(FATAL_ERROR + "Cannot find target \"${name}\". Perhaps it has not yet been created " + "using ExternalProject_Add." + ) endif() get_property(type TARGET ${name} PROPERTY TYPE) if(NOT type STREQUAL "UTILITY") - message(FATAL_ERROR "Target \"${name}\" was not generated by ExternalProject_Add.") + message(FATAL_ERROR + "Target \"${name}\" was not generated by ExternalProject_Add." + ) endif() get_property(is_ep TARGET ${name} PROPERTY _EP_IS_EXTERNAL_PROJECT) if(NOT is_ep) - message(FATAL_ERROR "Target \"${name}\" was not generated by ExternalProject_Add.") + message(FATAL_ERROR + "Target \"${name}\" was not generated by ExternalProject_Add." + ) endif() get_property(steps TARGET ${name} PROPERTY _EP_STEPS) list(FIND steps ${step} is_step) if(is_step LESS 0) - message(FATAL_ERROR "External project \"${name}\" does not have a step \"${step}\".") + message(FATAL_ERROR + "External project \"${name}\" does not have a step \"${step}\"." + ) endif() if(TARGET ${name}-${step}) get_property(type TARGET ${name}-${step} PROPERTY TYPE) if(NOT type STREQUAL "UTILITY") - message(FATAL_ERROR "Target \"${name}-${step}\" was not generated by ExternalProject_Add_StepTargets.") + message(FATAL_ERROR + "Target \"${name}-${step}\" was not generated by " + "ExternalProject_Add_StepTargets." + ) endif() - get_property(is_ep_step TARGET ${name}-${step} PROPERTY _EP_IS_EXTERNAL_PROJECT_STEP) + get_property(is_ep_step + TARGET ${name}-${step} + PROPERTY _EP_IS_EXTERNAL_PROJECT_STEP + ) if(NOT is_ep_step) - message(FATAL_ERROR "Target \"${name}-${step}\" was not generated by ExternalProject_Add_StepTargets.") + message(FATAL_ERROR + "Target \"${name}-${step}\" was not generated by " + "ExternalProject_Add_StepTargets." + ) endif() endif() @@ -2422,7 +2602,8 @@ function(ExternalProject_Add_StepDependencies name step) foreach(dep ${dependencies}) add_custom_command(APPEND OUTPUT ${stamp_file} - DEPENDS ${dep}) + DEPENDS ${dep} + ) if(TARGET ${name}-${step}) foreach(dep ${dependencies}) add_dependencies(${name}-${step} ${dep}) @@ -2455,14 +2636,21 @@ function(_ep_is_dir_empty dir empty_var) endfunction() function(_ep_get_git_submodules_recurse git_submodules_recurse) - # Checks for GIT_SUBMODULES_RECURSE property - # Default is ON, which sets git_submodules_recurse output variable to "--recursive" - # Otherwise, the output variable is set to an empty value "" - get_property(git_submodules_recurse_set TARGET ${name} PROPERTY _EP_GIT_SUBMODULES_RECURSE SET) + # Checks for GIT_SUBMODULES_RECURSE property. Default is ON, which sets + # git_submodules_recurse output variable to "--recursive". Otherwise, the + # output variable is set to an empty value "". + get_property(git_submodules_recurse_set + TARGET ${name} + PROPERTY _EP_GIT_SUBMODULES_RECURSE + SET + ) if(NOT git_submodules_recurse_set) set(recurseFlag "--recursive") else() - get_property(git_submodules_recurse_value TARGET ${name} PROPERTY _EP_GIT_SUBMODULES_RECURSE) + get_property(git_submodules_recurse_value + TARGET ${name} + PROPERTY _EP_GIT_SUBMODULES_RECURSE + ) if(git_submodules_recurse_value) set(recurseFlag "--recursive") else() @@ -2473,13 +2661,21 @@ function(_ep_get_git_submodules_recurse git_submodules_recurse) # The git submodule update '--recursive' flag requires git >= v1.6.5 if(recurseFlag AND GIT_VERSION_STRING VERSION_LESS 1.6.5) - message(FATAL_ERROR "error: git version 1.6.5 or later required for --recursive flag with 'git submodule ...': GIT_VERSION_STRING='${GIT_VERSION_STRING}'") + message(FATAL_ERROR + "git version 1.6.5 or later required for --recursive flag with " + "'git submodule ...': GIT_VERSION_STRING='${GIT_VERSION_STRING}'" + ) endif() endfunction() function(_ep_add_download_command name) - ExternalProject_Get_Property(${name} source_dir stamp_dir download_dir tmp_dir) + ExternalProject_Get_Property(${name} + source_dir + stamp_dir + download_dir + tmp_dir + ) get_property(cmd_set TARGET ${name} PROPERTY _EP_DOWNLOAD_COMMAND SET) get_property(cmd TARGET ${name} PROPERTY _EP_DOWNLOAD_COMMAND) @@ -2517,7 +2713,14 @@ function(_ep_add_download_command name) get_filename_component(src_name "${source_dir}" NAME) get_filename_component(work_dir "${source_dir}" PATH) set(comment "Performing download step (CVS checkout) for '${name}'") - set(cmd ${CVS_EXECUTABLE} -d ${cvs_repository} -q co ${cvs_tag} -d ${src_name} ${cvs_module}) + set(cmd + ${CVS_EXECUTABLE} + -d ${cvs_repository} + -q + co ${cvs_tag} + -d ${src_name} + ${cvs_module} + ) elseif(svn_repository) set(method svn) @@ -2530,7 +2733,10 @@ function(_ep_add_download_command name) get_property(svn_username TARGET ${name} PROPERTY _EP_SVN_USERNAME) get_property(svn_password TARGET ${name} PROPERTY _EP_SVN_PASSWORD) get_property(svn_trust_cert TARGET ${name} PROPERTY _EP_SVN_TRUST_CERT) - get_property(uses_terminal TARGET ${name} PROPERTY _EP_USES_TERMINAL_DOWNLOAD) + get_property(uses_terminal + TARGET ${name} + PROPERTY _EP_USES_TERMINAL_DOWNLOAD + ) if(uses_terminal) set(svn_interactive_args "") else() @@ -2550,9 +2756,16 @@ function(_ep_add_download_command name) if(svn_trust_cert) set(svn_trust_cert_args --trust-server-cert) endif() - set(cmd ${Subversion_SVN_EXECUTABLE} co ${svn_repository} ${svn_revision} - ${svn_interactive_args} ${svn_trust_cert_args} ${svn_user_pw_args} - ${src_name}) + set(cmd + ${Subversion_SVN_EXECUTABLE} + co + ${svn_repository} + ${svn_revision} + ${svn_interactive_args} + ${svn_trust_cert_args} + ${svn_user_pw_args} + ${src_name} + ) elseif(git_repository) set(method git) @@ -2573,7 +2786,10 @@ function(_ep_add_download_command name) endif() set(git_init_submodules TRUE) - get_property(git_submodules_set TARGET ${name} PROPERTY _EP_GIT_SUBMODULES SET) + get_property(git_submodules_set + TARGET ${name} + PROPERTY _EP_GIT_SUBMODULES SET + ) if(git_submodules_set) get_property(git_submodules TARGET ${name} PROPERTY _EP_GIT_SUBMODULES) if(git_submodules STREQUAL "" AND _EP_CMP0097 STREQUAL "NEW") @@ -2622,10 +2838,25 @@ CMP0097=${_EP_CMP0097} # create a cmake script to invoke as download command. # The script will delete the source directory and then call git clone. # - _ep_write_gitclone_script(${tmp_dir}/${name}-gitclone.cmake ${source_dir} - ${GIT_EXECUTABLE} ${git_repository} ${git_tag} ${git_remote_name} ${git_init_submodules} "${git_submodules_recurse}" "${git_submodules}" "${git_shallow}" "${git_progress}" "${git_config}" ${src_name} ${work_dir} - ${stamp_dir}/${name}-gitinfo.txt ${stamp_dir}/${name}-gitclone-lastrun.txt "${tls_verify}" - ) + _ep_write_gitclone_script( + ${tmp_dir}/${name}-gitclone.cmake + ${source_dir} + ${GIT_EXECUTABLE} + ${git_repository} + ${git_tag} + ${git_remote_name} + ${git_init_submodules} + "${git_submodules_recurse}" + "${git_submodules}" + "${git_shallow}" + "${git_progress}" + "${git_config}" + ${src_name} + ${work_dir} + ${stamp_dir}/${name}-gitinfo.txt + ${stamp_dir}/${name}-gitclone-lastrun.txt + "${tls_verify}" + ) set(comment "Performing download step (git clone) for '${name}'") set(cmd ${CMAKE_COMMAND} -P ${tmp_dir}/${name}-gitclone.cmake) @@ -2656,10 +2887,17 @@ CMP0097=${_EP_CMP0097} # create a cmake script to invoke as download command. # The script will delete the source directory and then call hg clone. # - _ep_write_hgclone_script(${tmp_dir}/${name}-hgclone.cmake ${source_dir} - ${HG_EXECUTABLE} ${hg_repository} ${hg_tag} ${src_name} ${work_dir} - ${stamp_dir}/${name}-hginfo.txt ${stamp_dir}/${name}-hgclone-lastrun.txt - ) + _ep_write_hgclone_script( + ${tmp_dir}/${name}-hgclone.cmake + ${source_dir} + ${HG_EXECUTABLE} + ${hg_repository} + ${hg_tag} + ${src_name} + ${work_dir} + ${stamp_dir}/${name}-hginfo.txt + ${stamp_dir}/${name}-hgclone-lastrun.txt + ) set(comment "Performing download step (hg clone) for '${name}'") set(cmd ${CMAKE_COMMAND} -P ${tmp_dir}/${name}-hgclone.cmake) @@ -2671,13 +2909,21 @@ CMP0097=${_EP_CMP0097} if(hash AND NOT "${hash}" MATCHES "${_ep_hash_regex}") _ep_get_hash_algos(_ep_hash_algos) list(JOIN _ep_hash_algos "|" _ep_hash_algos) - message(FATAL_ERROR "URL_HASH is set to\n ${hash}\n" - "but must be ALGO=value where ALGO is\n ${_ep_hash_algos}\n" - "and value is a hex string.") + message(FATAL_ERROR + "URL_HASH is set to\n" + " ${hash}\n" + "but must be ALGO=value where ALGO is\n" + " ${_ep_hash_algos}\n" + "and value is a hex string." + ) endif() get_property(md5 TARGET ${name} PROPERTY _EP_URL_MD5) if(md5 AND NOT "MD5=${md5}" MATCHES "${_ep_hash_regex}") - message(FATAL_ERROR "URL_MD5 is set to\n ${md5}\nbut must be a hex string.") + message(FATAL_ERROR + "URL_MD5 is set to\n" + " ${md5}\n" + "but must be a hex string." + ) endif() if(md5 AND NOT hash) set(hash "MD5=${md5}") @@ -2691,7 +2937,9 @@ hash=${hash} if(NOT "${url_list_length}" STREQUAL "1") foreach(entry ${url}) if(NOT "${entry}" MATCHES "^[a-z]+://") - message(FATAL_ERROR "At least one entry of URL is a path (invalid in a list)") + message(FATAL_ERROR + "At least one entry of URL is a path (invalid in a list)" + ) endif() endforeach() if("x${fname}" STREQUAL "x") @@ -2702,17 +2950,23 @@ hash=${hash} if(IS_DIRECTORY "${url}") get_filename_component(abs_dir "${url}" ABSOLUTE) set(comment "Performing download step (DIR copy) for '${name}'") - set(cmd ${CMAKE_COMMAND} -E rm -rf ${source_dir} - COMMAND ${CMAKE_COMMAND} -E copy_directory ${abs_dir} ${source_dir}) + set(cmd + ${CMAKE_COMMAND} -E rm -rf ${source_dir} + COMMAND ${CMAKE_COMMAND} -E copy_directory ${abs_dir} ${source_dir} + ) else() - get_property(no_extract TARGET "${name}" PROPERTY _EP_DOWNLOAD_NO_EXTRACT) + get_property(no_extract + TARGET "${name}" + PROPERTY _EP_DOWNLOAD_NO_EXTRACT + ) string(APPEND extra_repo_info "no_extract=${no_extract}\n") if("${url}" MATCHES "^[a-z]+://") # TODO: Should download and extraction be different steps? if("x${fname}" STREQUAL "x") set(fname "${url}") endif() - if("${fname}" MATCHES [[([^/\?#]+(\.|=)(7z|tar|tar\.bz2|tar\.gz|tar\.xz|tbz2|tgz|txz|zip))([/?#].*)?$]]) + set(ext_regex [[7z|tar|tar\.bz2|tar\.gz|tar\.xz|tbz2|tgz|txz|zip]]) + if("${fname}" MATCHES "([^/\\?#]+(\\.|=)(${ext_regex}))([/?#].*)?$") set(fname "${CMAKE_MATCH_1}") elseif(no_extract) get_filename_component(fname "${fname}" NAME) @@ -2727,8 +2981,14 @@ hash=${hash} string(REPLACE ";" "-" fname "${fname}") set(file ${download_dir}/${fname}) get_property(timeout TARGET ${name} PROPERTY _EP_TIMEOUT) - get_property(inactivity_timeout TARGET ${name} PROPERTY _EP_INACTIVITY_TIMEOUT) - get_property(no_progress TARGET ${name} PROPERTY _EP_DOWNLOAD_NO_PROGRESS) + get_property(inactivity_timeout + TARGET ${name} + PROPERTY _EP_INACTIVITY_TIMEOUT + ) + get_property(no_progress + TARGET ${name} + PROPERTY _EP_DOWNLOAD_NO_PROGRESS + ) get_property(tls_verify TARGET ${name} PROPERTY _EP_TLS_VERIFY) get_property(tls_cainfo TARGET ${name} PROPERTY _EP_TLS_CAINFO) get_property(netrc TARGET ${name} PROPERTY _EP_NETRC) @@ -2752,15 +3012,18 @@ hash=${hash} "${netrc}" "${netrc_file}" ) - set(cmd ${CMAKE_COMMAND} -P "${download_script}" - COMMAND) + set(cmd + ${CMAKE_COMMAND} -P "${download_script}" + COMMAND + ) if (no_extract) set(steps "download and verify") else () set(steps "download, verify and extract") endif () set(comment "Performing download step (${steps}) for '${name}'") - file(WRITE "${stamp_dir}/verify-${name}.cmake" "") # already verified by 'download_script' + # already verified by 'download_script' + file(WRITE "${stamp_dir}/verify-${name}.cmake" "") # Rather than adding everything to the RepositoryInfo.txt file, it is # more robust to just depend on the download script. That way, we will @@ -2781,7 +3044,9 @@ hash=${hash} ) endif() list(APPEND cmd ${CMAKE_COMMAND} -P ${stamp_dir}/verify-${name}.cmake) - get_target_property(extract_timestamp ${name} _EP_DOWNLOAD_EXTRACT_TIMESTAMP) + get_target_property(extract_timestamp ${name} + _EP_DOWNLOAD_EXTRACT_TIMESTAMP + ) if(no_extract) if(NOT extract_timestamp STREQUAL "extract_timestamp-NOTFOUND") message(FATAL_ERROR @@ -2825,14 +3090,16 @@ hash=${hash} "${source_dir}" "${options}" ) - list(APPEND cmd COMMAND ${CMAKE_COMMAND} -P ${stamp_dir}/extract-${name}.cmake) + list(APPEND cmd + COMMAND ${CMAKE_COMMAND} -P ${stamp_dir}/extract-${name}.cmake + ) endif () endif() else() set(method source_dir) _ep_is_dir_empty("${source_dir}" empty) if(${empty}) - message(SEND_ERROR + message(FATAL_ERROR "No download info given for '${name}' and its source directory:\n" " ${source_dir}\n" "is not an existing non-empty directory. Please specify one of:\n" @@ -2843,7 +3110,7 @@ hash=${hash} " * SVN_REPOSITORY\n" " * HG_REPOSITORY\n" " * CVS_REPOSITORY and CVS_MODULE" - ) + ) endif() endif() @@ -2858,15 +3125,20 @@ hash=${hash} @ONLY ) - get_property(log TARGET ${name} PROPERTY _EP_LOG_DOWNLOAD) + get_property(log + TARGET ${name} + PROPERTY _EP_LOG_DOWNLOAD + ) if(log) set(log LOG 1) else() set(log "") endif() - get_property(uses_terminal TARGET ${name} PROPERTY - _EP_USES_TERMINAL_DOWNLOAD) + get_property(uses_terminal + TARGET ${name} + PROPERTY _EP_USES_TERMINAL_DOWNLOAD + ) if(uses_terminal) set(uses_terminal USES_TERMINAL 1) else() @@ -2887,16 +3159,26 @@ hash=${hash} DEPENDEES mkdir ${log} ${uses_terminal} - )" + )" ) endfunction() function(_ep_get_update_disconnected var name) - get_property(update_disconnected_set TARGET ${name} PROPERTY _EP_UPDATE_DISCONNECTED SET) + get_property(update_disconnected_set + TARGET ${name} + PROPERTY _EP_UPDATE_DISCONNECTED + SET + ) if(update_disconnected_set) - get_property(update_disconnected TARGET ${name} PROPERTY _EP_UPDATE_DISCONNECTED) + get_property(update_disconnected + TARGET ${name} + PROPERTY _EP_UPDATE_DISCONNECTED + ) else() - get_property(update_disconnected DIRECTORY PROPERTY EP_UPDATE_DISCONNECTED) + get_property(update_disconnected + DIRECTORY + PROPERTY EP_UPDATE_DISCONNECTED + ) endif() set(${var} "${update_disconnected}" PARENT_SCOPE) endfunction() @@ -2957,8 +3239,14 @@ function(_ep_add_update_command name) if(svn_trust_cert) set(svn_trust_cert_args --trust-server-cert) endif() - set(cmd ${Subversion_SVN_EXECUTABLE} up ${svn_revision} - ${svn_interactive_args} ${svn_trust_cert_args} ${svn_user_pw_args}) + set(cmd + ${Subversion_SVN_EXECUTABLE} + up + ${svn_revision} + ${svn_interactive_args} + ${svn_trust_cert_args} + ${svn_user_pw_args} + ) set(always 1) elseif(git_repository) # FetchContent gives us these directly, so don't try to recompute them @@ -2971,25 +3259,43 @@ function(_ep_add_update_command name) endif() set(work_dir ${source_dir}) set(comment "Performing update step for '${name}'") - get_property(git_tag TARGET ${name} PROPERTY _EP_GIT_TAG) + + get_property(git_tag + TARGET ${name} + PROPERTY _EP_GIT_TAG + ) if(NOT git_tag) set(git_tag "master") endif() - get_property(git_remote_name TARGET ${name} PROPERTY _EP_GIT_REMOTE_NAME) + + get_property(git_remote_name + TARGET ${name} + PROPERTY _EP_GIT_REMOTE_NAME + ) if(NOT git_remote_name) set(git_remote_name "origin") endif() set(git_init_submodules TRUE) - get_property(git_submodules_set TARGET ${name} PROPERTY _EP_GIT_SUBMODULES SET) + get_property(git_submodules_set + TARGET ${name} + PROPERTY _EP_GIT_SUBMODULES + SET + ) if(git_submodules_set) - get_property(git_submodules TARGET ${name} PROPERTY _EP_GIT_SUBMODULES) + get_property(git_submodules + TARGET ${name} + PROPERTY _EP_GIT_SUBMODULES + ) if(git_submodules STREQUAL "" AND _EP_CMP0097 STREQUAL "NEW") set(git_init_submodules FALSE) endif() endif() - get_property(git_update_strategy TARGET ${name} PROPERTY _EP_GIT_REMOTE_UPDATE_STRATEGY) + get_property(git_update_strategy + TARGET ${name} + PROPERTY _EP_GIT_REMOTE_UPDATE_STRATEGY + ) if(NOT git_update_strategy) set(git_update_strategy "${CMAKE_EP_GIT_REMOTE_UPDATE_STRATEGY}") endif() @@ -2998,7 +3304,10 @@ function(_ep_add_update_command name) endif() set(strategies CHECKOUT REBASE REBASE_CHECKOUT) if(NOT git_update_strategy IN_LIST strategies) - message(FATAL_ERROR "'${git_update_strategy}' is not one of the supported strategies: ${strategies}") + message(FATAL_ERROR + "'${git_update_strategy}' is not one of the supported strategies: " + "${strategies}" + ) endif() _ep_get_git_submodules_recurse(git_submodules_recurse) @@ -3023,32 +3332,48 @@ function(_ep_add_update_command name) endif() set(work_dir ${source_dir}) set(comment "Performing update step (hg pull) for '${name}'") - get_property(hg_tag TARGET ${name} PROPERTY _EP_HG_TAG) + + get_property(hg_tag + TARGET ${name} + PROPERTY _EP_HG_TAG + ) if(NOT hg_tag) set(hg_tag "tip") endif() + if("${HG_VERSION_STRING}" STREQUAL "2.1") - message(WARNING "Mercurial 2.1 does not distinguish an empty pull from a failed pull: - http://mercurial.selenic.com/wiki/UpgradeNotes#A2.1.1:_revert_pull_return_code_change.2C_compile_issue_on_OS_X + set(notesAnchor + "#A2.1.1:_revert_pull_return_code_change.2C_compile_issue_on_OS_X" + ) + message(WARNING +"Mercurial 2.1 does not distinguish an empty pull from a failed pull: + http://mercurial.selenic.com/wiki/UpgradeNotes${notesAnchor} http://thread.gmane.org/gmane.comp.version-control.mercurial.devel/47656 Update to Mercurial >= 2.1.1. ") endif() - set(cmd ${HG_EXECUTABLE} pull + + set(cmd + ${HG_EXECUTABLE} pull COMMAND ${HG_EXECUTABLE} update ${hg_tag} - ) + ) set(always 1) endif() - get_property(log TARGET ${name} PROPERTY _EP_LOG_UPDATE) + get_property(log + TARGET ${name} + PROPERTY _EP_LOG_UPDATE + ) if(log) set(log LOG 1) else() set(log "") endif() - get_property(uses_terminal TARGET ${name} PROPERTY - _EP_USES_TERMINAL_UPDATE) + get_property(uses_terminal + TARGET ${name} + PROPERTY _EP_USES_TERMINAL_UPDATE + ) if(uses_terminal) set(uses_terminal USES_TERMINAL 1) else() @@ -3070,7 +3395,7 @@ Update to Mercurial >= 2.1.1. DEPENDEES download ${log} ${uses_terminal} - )" + )" ) endfunction() @@ -3088,14 +3413,20 @@ function(_ep_add_patch_command name) set(work_dir ${source_dir}) endif() - get_property(log TARGET ${name} PROPERTY _EP_LOG_PATCH) + get_property(log + TARGET ${name} + PROPERTY _EP_LOG_PATCH + ) if(log) set(log LOG 1) else() set(log "") endif() - get_property(uses_terminal TARGET ${name} PROPERTY _EP_USES_TERMINAL_PATCH) + get_property(uses_terminal + TARGET ${name} + PROPERTY _EP_USES_TERMINAL_PATCH + ) if(uses_terminal) set(uses_terminal USES_TERMINAL 1) else() @@ -3121,18 +3452,27 @@ function(_ep_add_patch_command name) DEPENDEES \${patch_dep} ${log} ${uses_terminal} - )" + )" ) endfunction() function(_ep_get_file_deps var name) set(file_deps) - get_property(deps TARGET ${name} PROPERTY _EP_DEPENDS) + get_property(deps + TARGET ${name} + PROPERTY _EP_DEPENDS + ) foreach(dep IN LISTS deps) - get_property(dep_type TARGET ${dep} PROPERTY TYPE) + get_property(dep_type + TARGET ${dep} + PROPERTY TYPE + ) if(dep_type STREQUAL "UTILITY") - get_property(is_ep TARGET ${dep} PROPERTY _EP_IS_EXTERNAL_PROJECT) + get_property(is_ep + TARGET ${dep} + PROPERTY _EP_IS_EXTERNAL_PROJECT + ) if(is_ep) _ep_get_step_stampfile(${dep} "done" done_stamp_file) list(APPEND file_deps ${done_stamp_file}) @@ -3144,9 +3484,16 @@ function(_ep_get_file_deps var name) endfunction() function(_ep_extract_configure_command var name) - get_property(cmd_set TARGET ${name} PROPERTY _EP_CONFIGURE_COMMAND SET) + get_property(cmd_set + TARGET ${name} + PROPERTY _EP_CONFIGURE_COMMAND + SET + ) if(cmd_set) - get_property(cmd TARGET ${name} PROPERTY _EP_CONFIGURE_COMMAND) + get_property(cmd + TARGET ${name} + PROPERTY _EP_CONFIGURE_COMMAND + ) else() get_target_property(cmake_command ${name} _EP_CMAKE_COMMAND) if(cmake_command) @@ -3155,13 +3502,22 @@ function(_ep_extract_configure_command var name) set(cmd "${CMAKE_COMMAND}") endif() - get_property(cmake_args TARGET ${name} PROPERTY _EP_CMAKE_ARGS) + get_property(cmake_args + TARGET ${name} + PROPERTY _EP_CMAKE_ARGS + ) list(APPEND cmd ${cmake_args}) # If there are any CMAKE_CACHE_ARGS or CMAKE_CACHE_DEFAULT_ARGS, # write an initial cache and use it - get_property(cmake_cache_args TARGET ${name} PROPERTY _EP_CMAKE_CACHE_ARGS) - get_property(cmake_cache_default_args TARGET ${name} PROPERTY _EP_CMAKE_CACHE_DEFAULT_ARGS) + get_property(cmake_cache_args + TARGET ${name} + PROPERTY _EP_CMAKE_CACHE_ARGS + ) + get_property(cmake_cache_default_args + TARGET ${name} + PROPERTY _EP_CMAKE_CACHE_DEFAULT_ARGS + ) set(has_cmake_cache_args 0) if(NOT "${cmake_cache_args}" STREQUAL "") @@ -3173,10 +3529,18 @@ function(_ep_extract_configure_command var name) set(has_cmake_cache_default_args 1) endif() - get_target_property(cmake_generator ${name} _EP_CMAKE_GENERATOR) - get_target_property(cmake_generator_instance ${name} _EP_CMAKE_GENERATOR_INSTANCE) - get_target_property(cmake_generator_platform ${name} _EP_CMAKE_GENERATOR_PLATFORM) - get_target_property(cmake_generator_toolset ${name} _EP_CMAKE_GENERATOR_TOOLSET) + get_target_property(cmake_generator ${name} + _EP_CMAKE_GENERATOR + ) + get_target_property(cmake_generator_instance ${name} + _EP_CMAKE_GENERATOR_INSTANCE + ) + get_target_property(cmake_generator_platform ${name} + _EP_CMAKE_GENERATOR_PLATFORM + ) + get_target_property(cmake_generator_toolset ${name} + _EP_CMAKE_GENERATOR_TOOLSET + ) if(cmake_generator) list(APPEND cmd "-G${cmake_generator}") if(cmake_generator_platform) @@ -3186,7 +3550,9 @@ function(_ep_extract_configure_command var name) list(APPEND cmd "-T${cmake_generator_toolset}") endif() if(cmake_generator_instance) - list(APPEND cmd "-DCMAKE_GENERATOR_INSTANCE:INTERNAL=${cmake_generator_instance}") + list(APPEND cmd + "-DCMAKE_GENERATOR_INSTANCE:INTERNAL=${cmake_generator_instance}" + ) endif() else() if(CMAKE_EXTRA_GENERATOR) @@ -3195,49 +3561,72 @@ function(_ep_extract_configure_command var name) list(APPEND cmd "-G${CMAKE_GENERATOR}") if("${CMAKE_GENERATOR}" MATCHES "Green Hills MULTI") set(has_cmake_cache_default_args 1) - set(cmake_cache_default_args ${cmake_cache_default_args} + list(APPEND cmake_cache_default_args "-DGHS_TARGET_PLATFORM:STRING=${GHS_TARGET_PLATFORM}" "-DGHS_PRIMARY_TARGET:STRING=${GHS_PRIMARY_TARGET}" "-DGHS_TOOLSET_ROOT:STRING=${GHS_TOOLSET_ROOT}" "-DGHS_OS_ROOT:STRING=${GHS_OS_ROOT}" "-DGHS_OS_DIR:STRING=${GHS_OS_DIR}" - "-DGHS_BSP_NAME:STRING=${GHS_BSP_NAME}") + "-DGHS_BSP_NAME:STRING=${GHS_BSP_NAME}" + ) endif() endif() if(cmake_generator_platform) - message(FATAL_ERROR "Option CMAKE_GENERATOR_PLATFORM not allowed without CMAKE_GENERATOR.") + message(FATAL_ERROR + "Option CMAKE_GENERATOR_PLATFORM not allowed without " + "CMAKE_GENERATOR." + ) endif() if(CMAKE_GENERATOR_PLATFORM) list(APPEND cmd "-A${CMAKE_GENERATOR_PLATFORM}") endif() if(cmake_generator_toolset) - message(FATAL_ERROR "Option CMAKE_GENERATOR_TOOLSET not allowed without CMAKE_GENERATOR.") + message(FATAL_ERROR + "Option CMAKE_GENERATOR_TOOLSET not allowed without CMAKE_GENERATOR." + ) endif() if(CMAKE_GENERATOR_TOOLSET) list(APPEND cmd "-T${CMAKE_GENERATOR_TOOLSET}") endif() if(cmake_generator_instance) - message(FATAL_ERROR "Option CMAKE_GENERATOR_INSTANCE not allowed without CMAKE_GENERATOR.") + message(FATAL_ERROR + "Option CMAKE_GENERATOR_INSTANCE not allowed without CMAKE_GENERATOR." + ) endif() if(CMAKE_GENERATOR_INSTANCE) - list(APPEND cmd "-DCMAKE_GENERATOR_INSTANCE:INTERNAL=${CMAKE_GENERATOR_INSTANCE}") + list(APPEND cmd + "-DCMAKE_GENERATOR_INSTANCE:INTERNAL=${CMAKE_GENERATOR_INSTANCE}" + ) endif() endif() if(has_cmake_cache_args OR has_cmake_cache_default_args) set(_ep_cache_args_script "<TMP_DIR>/${name}-cache-$<CONFIG>.cmake") if(has_cmake_cache_args) - _ep_command_line_to_initial_cache(script_initial_cache_force "${cmake_cache_args}" 1) + _ep_command_line_to_initial_cache( + script_initial_cache_force + "${cmake_cache_args}" + 1 + ) endif() if(has_cmake_cache_default_args) - _ep_command_line_to_initial_cache(script_initial_cache_default "${cmake_cache_default_args}" 0) + _ep_command_line_to_initial_cache( + script_initial_cache_default + "${cmake_cache_default_args}" + 0 + ) endif() - _ep_write_initial_cache(${name} "${_ep_cache_args_script}" "${script_initial_cache_force}${script_initial_cache_default}") + _ep_write_initial_cache( + ${name} + "${_ep_cache_args_script}" + "${script_initial_cache_force}${script_initial_cache_default}" + ) list(APPEND cmd "-C${_ep_cache_args_script}") _ep_replace_location_tags(${name} _ep_cache_args_script) set(_ep_cache_args_script "${_ep_cache_args_script}" - PARENT_SCOPE) + PARENT_SCOPE + ) endif() list(APPEND cmd "<SOURCE_DIR><SOURCE_SUBDIR>") @@ -3251,8 +3640,10 @@ function(_ep_add_configure_command name) ExternalProject_Get_Property(${name} binary_dir tmp_dir) set(file_deps) - get_property(configure_handled_by_build TARGET ${name} - PROPERTY _EP_CONFIGURE_HANDLED_BY_BUILD) + get_property(configure_handled_by_build + TARGET ${name} + PROPERTY _EP_CONFIGURE_HANDLED_BY_BUILD + ) if(NOT configure_handled_by_build) # Depend on other external projects (file-level) _ep_get_file_deps(file_deps ${name}) @@ -3272,15 +3663,20 @@ function(_ep_add_configure_command name) list(APPEND file_deps ${tmp_dir}/${name}-cfgcmd.txt) list(APPEND file_deps ${_ep_cache_args_script}) - get_property(log TARGET ${name} PROPERTY _EP_LOG_CONFIGURE) + get_property(log + TARGET ${name} + PROPERTY _EP_LOG_CONFIGURE + ) if(log) set(log LOG 1) else() set(log "") endif() - get_property(uses_terminal TARGET ${name} PROPERTY - _EP_USES_TERMINAL_CONFIGURE) + get_property(uses_terminal + TARGET ${name} + PROPERTY _EP_USES_TERMINAL_CONFIGURE + ) if(uses_terminal) set(uses_terminal USES_TERMINAL 1) else() @@ -3300,7 +3696,7 @@ function(_ep_add_configure_command name) DEPENDS \${file_deps} ${log} ${uses_terminal} - )" + )" ) endfunction() @@ -3309,43 +3705,63 @@ function(_ep_add_build_command name) ExternalProject_Get_Property(${name} binary_dir) set(file_deps) - get_property(configure_handled_by_build TARGET ${name} - PROPERTY _EP_CONFIGURE_HANDLED_BY_BUILD) + get_property(configure_handled_by_build + TARGET ${name} + PROPERTY _EP_CONFIGURE_HANDLED_BY_BUILD + ) if(configure_handled_by_build) # Depend on other external projects (file-level) _ep_get_file_deps(file_deps ${name}) endif() - get_property(cmd_set TARGET ${name} PROPERTY _EP_BUILD_COMMAND SET) + get_property(cmd_set + TARGET ${name} + PROPERTY _EP_BUILD_COMMAND + SET + ) if(cmd_set) - get_property(cmd TARGET ${name} PROPERTY _EP_BUILD_COMMAND) + get_property(cmd + TARGET ${name} + PROPERTY _EP_BUILD_COMMAND + ) else() _ep_get_build_command(${name} BUILD cmd) endif() - get_property(log TARGET ${name} PROPERTY _EP_LOG_BUILD) + get_property(log + TARGET ${name} + PROPERTY _EP_LOG_BUILD + ) if(log) set(log LOG 1) else() set(log "") endif() - get_property(uses_terminal TARGET ${name} PROPERTY - _EP_USES_TERMINAL_BUILD) + get_property(uses_terminal + TARGET ${name} + PROPERTY _EP_USES_TERMINAL_BUILD + ) if(uses_terminal) set(uses_terminal USES_TERMINAL 1) else() set(uses_terminal "") endif() - get_property(build_always TARGET ${name} PROPERTY _EP_BUILD_ALWAYS) + get_property(build_always + TARGET ${name} + PROPERTY _EP_BUILD_ALWAYS + ) if(build_always) set(always 1) else() set(always 0) endif() - get_property(build_byproducts TARGET ${name} PROPERTY _EP_BUILD_BYPRODUCTS) + get_property(build_byproducts + TARGET ${name} + PROPERTY _EP_BUILD_BYPRODUCTS + ) set(__cmdQuoted) foreach(__item IN LISTS cmd) @@ -3362,7 +3778,7 @@ function(_ep_add_build_command name) ALWAYS \${always} ${log} ${uses_terminal} - )" + )" ) endfunction() @@ -3370,22 +3786,34 @@ endfunction() function(_ep_add_install_command name) ExternalProject_Get_Property(${name} binary_dir) - get_property(cmd_set TARGET ${name} PROPERTY _EP_INSTALL_COMMAND SET) + get_property(cmd_set + TARGET ${name} + PROPERTY _EP_INSTALL_COMMAND + SET + ) if(cmd_set) - get_property(cmd TARGET ${name} PROPERTY _EP_INSTALL_COMMAND) + get_property(cmd + TARGET ${name} + PROPERTY _EP_INSTALL_COMMAND + ) else() _ep_get_build_command(${name} INSTALL cmd) endif() - get_property(log TARGET ${name} PROPERTY _EP_LOG_INSTALL) + get_property(log + TARGET ${name} + PROPERTY _EP_LOG_INSTALL + ) if(log) set(log LOG 1) else() set(log "") endif() - get_property(uses_terminal TARGET ${name} PROPERTY - _EP_USES_TERMINAL_INSTALL) + get_property(uses_terminal + TARGET ${name} + PROPERTY _EP_USES_TERMINAL_INSTALL + ) if(uses_terminal) set(uses_terminal USES_TERMINAL 1) else() @@ -3404,7 +3832,7 @@ function(_ep_add_install_command name) DEPENDEES build ${log} ${uses_terminal} - )" + )" ) endfunction() @@ -3422,7 +3850,10 @@ function(_ep_add_test_command name) # if(cmd_set OR before OR after OR exclude) if(cmd_set) - get_property(cmd TARGET ${name} PROPERTY _EP_TEST_COMMAND) + get_property(cmd + TARGET ${name} + PROPERTY _EP_TEST_COMMAND + ) else() _ep_get_build_command(${name} TEST cmd) endif() @@ -3445,15 +3876,20 @@ function(_ep_add_test_command name) set(exclude_args "") endif() - get_property(log TARGET ${name} PROPERTY _EP_LOG_TEST) + get_property(log + TARGET ${name} + PROPERTY _EP_LOG_TEST + ) if(log) set(log LOG 1) else() set(log "") endif() - get_property(uses_terminal TARGET ${name} PROPERTY - _EP_USES_TERMINAL_TEST) + get_property(uses_terminal + TARGET ${name} + PROPERTY _EP_USES_TERMINAL_TEST + ) if(uses_terminal) set(uses_terminal USES_TERMINAL 1) else() @@ -3474,7 +3910,7 @@ function(_ep_add_test_command name) ${exclude_args} ${log} ${uses_terminal} - )" + )" ) endif() endfunction() @@ -3483,11 +3919,12 @@ endfunction() function(ExternalProject_Add name) cmake_policy(GET CMP0097 _EP_CMP0097 PARENT_SCOPE # undocumented, do not use outside of CMake - ) + ) cmake_policy(GET CMP0114 cmp0114 PARENT_SCOPE # undocumented, do not use outside of CMake - ) - if(CMAKE_XCODE_BUILD_SYSTEM VERSION_GREATER_EQUAL 12 AND NOT cmp0114 STREQUAL "NEW") + ) + if(CMAKE_XCODE_BUILD_SYSTEM VERSION_GREATER_EQUAL 12 AND + NOT cmp0114 STREQUAL "NEW") message(AUTHOR_WARNING "Policy CMP0114 is not set to NEW. " "In order to support the Xcode \"new build system\", " @@ -3496,12 +3933,12 @@ function(ExternalProject_Add name) "Since CMake is generating for the Xcode \"new build system\", " "ExternalProject_Add will use policy CMP0114's NEW behavior anyway, " "but the generated build system may not match what the project intends." - ) + ) set(cmp0114 "NEW") endif() cmake_policy(GET CMP0135 _EP_CMP0135 PARENT_SCOPE # undocumented, do not use outside of CMake - ) + ) _ep_get_configuration_subdir_suffix(cfgdir) @@ -3520,11 +3957,12 @@ function(ExternalProject_Add name) # argument was passed, we explicitly set it for the target. add_custom_target(${name} ALL DEPENDS ${complete_stamp_file}) cmake_policy(POP) - set_property(TARGET ${name} PROPERTY _EP_IS_EXTERNAL_PROJECT 1) - set_property(TARGET ${name} PROPERTY LABELS ${name}) - set_property(TARGET ${name} PROPERTY FOLDER "ExternalProjectTargets/${name}") - - set_property(TARGET ${name} PROPERTY _EP_CMP0114 "${cmp0114}") + set_target_properties(${name} PROPERTIES + _EP_IS_EXTERNAL_PROJECT 1 + LABELS ${name} + FOLDER "ExternalProjectTargets/${name}" + _EP_CMP0114 "${cmp0114}" + ) set(keywords # @@ -3657,13 +4095,22 @@ function(ExternalProject_Add name) # LIST_SEPARATOR ) - _ep_parse_arguments(ExternalProject_Add "${keywords}" ${name} _EP_ "${ARGN}") + _ep_parse_arguments( + ExternalProject_Add + "${keywords}" + ${name} + _EP_ + "${ARGN}" + ) _ep_set_directories(${name}) _ep_get_step_stampfile(${name} "done" done_stamp_file) _ep_get_step_stampfile(${name} "install" install_stamp_file) # Set the EXCLUDE_FROM_ALL target property if required. - get_property(exclude_from_all TARGET ${name} PROPERTY _EP_EXCLUDE_FROM_ALL) + get_property(exclude_from_all + TARGET ${name} + PROPERTY _EP_EXCLUDE_FROM_ALL + ) if(exclude_from_all) set_property(TARGET ${name} PROPERTY EXCLUDE_FROM_ALL TRUE) endif() @@ -3690,11 +4137,13 @@ function(ExternalProject_Add name) COMMAND ${CMAKE_COMMAND} -E touch ${done_stamp_file} DEPENDS ${install_stamp_file} VERBATIM - ) - + ) # Depend on other external projects (target-level). - get_property(deps TARGET ${name} PROPERTY _EP_DEPENDS) + get_property(deps + TARGET ${name} + PROPERTY _EP_DEPENDS + ) foreach(arg IN LISTS deps) add_dependencies(${name} ${arg}) endforeach() diff --git a/Modules/FindPkgConfig.cmake b/Modules/FindPkgConfig.cmake index ab8af3e..854e0e1 100644 --- a/Modules/FindPkgConfig.cmake +++ b/Modules/FindPkgConfig.cmake @@ -143,7 +143,9 @@ macro(_pkgconfig_invoke _pkglist _prefix _varname _regexp) string(REGEX REPLACE "${_regexp}" " " _pkgconfig_invoke_result "${_pkgconfig_invoke_result}") endif() - separate_arguments(_pkgconfig_invoke_result) + # pkg-config can represent "spaces within an argument" by backslash-escaping the space. + # UNIX_COMMAND mode treats backslash-escaped spaces as "not a space that delimits arguments". + separate_arguments(_pkgconfig_invoke_result UNIX_COMMAND "${_pkgconfig_invoke_result}") #message(STATUS " ${_varname} ... ${_pkgconfig_invoke_result}") set(_pkgconfig_${_varname} ${_pkgconfig_invoke_result}) @@ -167,13 +169,14 @@ macro(_pkgconfig_invoke_dyn _pkglist _prefix _varname cleanup_regexp) endmacro() # Splits given arguments into options and a package list -macro(_pkgconfig_parse_options _result _is_req _is_silent _no_cmake_path _no_cmake_environment_path _imp_target _imp_target_global) +macro(_pkgconfig_parse_options _result _is_req _is_silent _no_cmake_path _no_cmake_environment_path _imp_target _imp_target_global _static_target) set(${_is_req} 0) set(${_is_silent} 0) set(${_no_cmake_path} 0) set(${_no_cmake_environment_path} 0) set(${_imp_target} 0) set(${_imp_target_global} 0) + set(${_static_target} 0) if(DEFINED PKG_CONFIG_USE_CMAKE_PREFIX_PATH) if(NOT PKG_CONFIG_USE_CMAKE_PREFIX_PATH) set(${_no_cmake_path} 1) @@ -203,6 +206,9 @@ macro(_pkgconfig_parse_options _result _is_req _is_silent _no_cmake_path _no_cma if (_pkg STREQUAL "GLOBAL") set(${_imp_target_global} 1) endif() + if (_pkg STREQUAL "STATIC_TARGET") + set(${_static_target} 1) + endif() endforeach() if (${_imp_target_global} AND NOT ${_imp_target}) @@ -215,6 +221,7 @@ macro(_pkgconfig_parse_options _result _is_req _is_silent _no_cmake_path _no_cma list(REMOVE_ITEM ${_result} "NO_CMAKE_PATH") list(REMOVE_ITEM ${_result} "NO_CMAKE_ENVIRONMENT_PATH") list(REMOVE_ITEM ${_result} "IMPORTED_TARGET") + list(REMOVE_ITEM ${_result} "STATIC_TARGET") list(REMOVE_ITEM ${_result} "GLOBAL") endmacro() @@ -246,7 +253,7 @@ endfunction() # scan the LDFLAGS returned by pkg-config for library directories and # libraries, figure out the absolute paths of that libraries in the # given directories -function(_pkg_find_libs _prefix _no_cmake_path _no_cmake_environment_path) +function(_pkg_find_libs _prefix _no_cmake_path _no_cmake_environment_path _static) unset(_libs) unset(_find_opts) @@ -259,9 +266,23 @@ function(_pkg_find_libs _prefix _no_cmake_path _no_cmake_environment_path) list(APPEND _find_opts "NO_CMAKE_ENVIRONMENT_PATH") endif() + if(_static) + set(var_prefix ${_prefix}_STATIC) + set(pkgcfg_lib_prefix pkgcfg_static_lib_${_prefix}) + # reconfigure library prefixes/suffixes so that only static libraries can be found + set(CMAKE_FIND_LIBRARY_PREFIXES "${CMAKE_STATIC_LIBRARY_PREFIX}") + set(CMAKE_FIND_LIBRARY_SUFFIXES "${CMAKE_STATIC_LIBRARY_SUFFIX}") + else() + set(var_prefix ${_prefix}) + set(pkgcfg_lib_prefix pkgcfg_lib_${_prefix}) + # reconfigure library prefixes/suffixes so that only dynamic libraries can be found + set(CMAKE_FIND_LIBRARY_PREFIXES "${CMAKE_SHARED_LIBRARY_PREFIX}") + set(CMAKE_FIND_LIBRARY_SUFFIXES "${CMAKE_SHARED_LIBRARY_SUFFIX}") + endif() + unset(_search_paths) unset(_next_is_framework) - foreach (flag IN LISTS ${_prefix}_LDFLAGS) + foreach (flag IN LISTS ${var_prefix}_LDFLAGS) if (_next_is_framework) list(APPEND _libs "-framework ${flag}") unset(_next_is_framework) @@ -280,61 +301,78 @@ function(_pkg_find_libs _prefix _no_cmake_path _no_cmake_environment_path) continue() endif() + set(lib_var_name ${pkgcfg_lib_prefix}_${_pkg_search}) + if(_search_paths) # Firstly search in -L paths - find_library(pkgcfg_lib_${_prefix}_${_pkg_search} + find_library(${lib_var_name} NAMES ${_pkg_search} HINTS ${_search_paths} NO_DEFAULT_PATH) endif() - find_library(pkgcfg_lib_${_prefix}_${_pkg_search} + find_library(${lib_var_name} NAMES ${_pkg_search} ${_find_opts}) - mark_as_advanced(pkgcfg_lib_${_prefix}_${_pkg_search}) - if(pkgcfg_lib_${_prefix}_${_pkg_search}) - list(APPEND _libs "${pkgcfg_lib_${_prefix}_${_pkg_search}}") + + mark_as_advanced(${lib_var_name}) + if(${lib_var_name}) + list(APPEND _libs "${${lib_var_name}}") else() list(APPEND _libs ${_pkg_search}) endif() endforeach() - set(${_prefix}_LINK_LIBRARIES "${_libs}" PARENT_SCOPE) + set(${var_prefix}_LINK_LIBRARIES "${_libs}" PARENT_SCOPE) endfunction() # create an imported target from all the information returned by pkg-config -function(_pkg_create_imp_target _prefix _imp_target_global) - if (NOT TARGET PkgConfig::${_prefix}) +function(_pkg_create_imp_target _prefix _imp_target_global _var_qualifier) + set(tgt PkgConfig::${_prefix}) + set(var_prefix ${_prefix}${_var_qualifier}) + + if (NOT TARGET ${tgt}) if(${_imp_target_global}) set(_global_opt "GLOBAL") else() unset(_global_opt) endif() - add_library(PkgConfig::${_prefix} INTERFACE IMPORTED ${_global_opt}) + add_library(${tgt} INTERFACE IMPORTED ${_global_opt}) - if(${_prefix}_INCLUDE_DIRS) - set_property(TARGET PkgConfig::${_prefix} PROPERTY - INTERFACE_INCLUDE_DIRECTORIES "${${_prefix}_INCLUDE_DIRS}") + if(${var_prefix}_INCLUDE_DIRS) + set_property(TARGET ${tgt} PROPERTY + INTERFACE_INCLUDE_DIRECTORIES "${${var_prefix}_INCLUDE_DIRS}") endif() - if(${_prefix}_LINK_LIBRARIES) - set_property(TARGET PkgConfig::${_prefix} PROPERTY - INTERFACE_LINK_LIBRARIES "${${_prefix}_LINK_LIBRARIES}") + if(${var_prefix}_LINK_LIBRARIES) + set_property(TARGET ${tgt} PROPERTY + INTERFACE_LINK_LIBRARIES "${${var_prefix}_LINK_LIBRARIES}") endif() - if(${_prefix}_LDFLAGS_OTHER) - set_property(TARGET PkgConfig::${_prefix} PROPERTY - INTERFACE_LINK_OPTIONS "${${_prefix}_LDFLAGS_OTHER}") + if(${var_prefix}_LDFLAGS_OTHER) + set_property(TARGET ${tgt} PROPERTY + INTERFACE_LINK_OPTIONS "${${var_prefix}_LDFLAGS_OTHER}") endif() - if(${_prefix}_CFLAGS_OTHER) - set_property(TARGET PkgConfig::${_prefix} PROPERTY - INTERFACE_COMPILE_OPTIONS "${${_prefix}_CFLAGS_OTHER}") + if(${var_prefix}_CFLAGS_OTHER) + set_property(TARGET ${tgt} PROPERTY + INTERFACE_COMPILE_OPTIONS "${${var_prefix}_CFLAGS_OTHER}") endif() endif() endfunction() # recalculate the dynamic output # this is a macro and not a function so the result of _pkg_find_libs is automatically propagated -macro(_pkg_recalculate _prefix _no_cmake_path _no_cmake_environment_path _imp_target _imp_target_global) - _pkg_find_libs(${_prefix} ${_no_cmake_path} ${_no_cmake_environment_path}) +macro(_pkg_recalculate _prefix _no_cmake_path _no_cmake_environment_path _imp_target _imp_target_global _static_target) + # populate unqualified (shared) series of variables + _pkg_find_libs("${_prefix}" ${_no_cmake_path} ${_no_cmake_environment_path} FALSE) + # populate STATIC_ series of variables + _pkg_find_libs("${_prefix}" ${_no_cmake_path} ${_no_cmake_environment_path} TRUE) + if(${_imp_target}) - _pkg_create_imp_target(${_prefix} ${_imp_target_global}) + if (${_static_target}) + set(var_qualifier "_STATIC") + else() + set(var_qualifier "") + endif() + # create unqualified target, sourced from whichever series of variables is preferred. + # default: source target from unqualified (shared) variables. otherwise STATIC_ variables + _pkg_create_imp_target("${_prefix}" ${_imp_target_global} "${var_qualifier}") endif() endmacro() @@ -503,7 +541,7 @@ function(_pkgconfig_extract_isystem _prefix) endfunction() ### -macro(_pkg_check_modules_internal _is_required _is_silent _no_cmake_path _no_cmake_environment_path _imp_target _imp_target_global _prefix) +macro(_pkg_check_modules_internal _is_required _is_silent _no_cmake_path _no_cmake_environment_path _imp_target _imp_target_global _static_target _prefix) _pkgconfig_unset(${_prefix}_FOUND) _pkgconfig_unset(${_prefix}_VERSION) _pkgconfig_unset(${_prefix}_PREFIX) @@ -639,20 +677,21 @@ macro(_pkg_check_modules_internal _is_required _is_silent _no_cmake_path _no_cma _pkgconfig_invoke_dyn("${_pkg_check_modules_packages}" "${_prefix}" LIBRARY_DIRS "(^| )-L" --libs-only-L ) _pkgconfig_invoke_dyn("${_pkg_check_modules_packages}" "${_prefix}" LDFLAGS "" --libs ) _pkgconfig_invoke_dyn("${_pkg_check_modules_packages}" "${_prefix}" LDFLAGS_OTHER "" --libs-only-other ) - - if (APPLE AND "-framework" IN_LIST ${_prefix}_LDFLAGS_OTHER) - _pkgconfig_extract_frameworks("${_prefix}") - endif() - _pkgconfig_invoke_dyn("${_pkg_check_modules_packages}" "${_prefix}" INCLUDE_DIRS "(^| )(-I|-isystem ?)" --cflags-only-I ) _pkgconfig_invoke_dyn("${_pkg_check_modules_packages}" "${_prefix}" CFLAGS "" --cflags ) _pkgconfig_invoke_dyn("${_pkg_check_modules_packages}" "${_prefix}" CFLAGS_OTHER "" --cflags-only-other ) - if (${_prefix}_CFLAGS_OTHER MATCHES "-isystem") - _pkgconfig_extract_isystem("${_prefix}") - endif () + foreach (qualifier IN ITEMS "" "_STATIC") + set(qual_prefix ${_prefix}${qualifier}) + if (APPLE AND "-framework" IN_LIST ${qual_prefix}_LDFLAGS_OTHER) + _pkgconfig_extract_frameworks("${qual_prefix}") + endif() + if (${qual_prefix}_CFLAGS_OTHER MATCHES "-isystem") + _pkgconfig_extract_isystem("${qual_prefix}") + endif () + endforeach() - _pkg_recalculate("${_prefix}" ${_no_cmake_path} ${_no_cmake_environment_path} ${_imp_target} ${_imp_target_global}) + _pkg_recalculate("${_prefix}" ${_no_cmake_path} ${_no_cmake_environment_path} ${_imp_target} ${_imp_target_global} ${_static_target}) endif() _pkg_restore_path_internal() @@ -676,7 +715,7 @@ endmacro() [REQUIRED] [QUIET] [NO_CMAKE_PATH] [NO_CMAKE_ENVIRONMENT_PATH] - [IMPORTED_TARGET [GLOBAL]] + [IMPORTED_TARGET [GLOBAL] [STATIC_TARGET]] <moduleSpec> [<moduleSpec>...]) When the ``REQUIRED`` argument is given, the command will fail with an error @@ -707,6 +746,13 @@ endmacro() The ``GLOBAL`` argument will make the imported target available in global scope. + .. versionadded:: 3.24 + The ``STATIC_TARGET`` argument will make the + imported target reference the static libraries + reported in ``<XXX>_STATIC_LINK_LIBRARIES``. + Without this option, the imported target + references the ``<XXX>_LINK_LIBRARIES``. + .. versionadded:: 3.15 Non-library linker options reported by ``pkg-config`` are stored in the :prop_tgt:`INTERFACE_LINK_OPTIONS` target property. @@ -738,6 +784,10 @@ endmacro() only the libraries (without the '-l') ``<XXX>_LINK_LIBRARIES`` the libraries and their absolute paths + ``<XXX>_STATIC_LINK_LIBRARIES`` + .. versionadded:: 3.24 + + static libraries and their absolute paths ``<XXX>_LIBRARY_DIRS`` the paths of the libraries (without the '-L') ``<XXX>_LDFLAGS`` @@ -819,12 +869,12 @@ endmacro() XRENDER_STATIC_LIBRARIES=Xrender;X11;pthread;Xau;Xdmcp #]========================================] macro(pkg_check_modules _prefix _module0) - _pkgconfig_parse_options(_pkg_modules _pkg_is_required _pkg_is_silent _no_cmake_path _no_cmake_environment_path _imp_target _imp_target_global "${_module0}" ${ARGN}) + _pkgconfig_parse_options(_pkg_modules _pkg_is_required _pkg_is_silent _no_cmake_path _no_cmake_environment_path _imp_target _imp_target_global _static_target "${_module0}" ${ARGN}) # check cached value if (NOT DEFINED __pkg_config_checked_${_prefix} OR __pkg_config_checked_${_prefix} LESS ${PKG_CONFIG_VERSION} OR NOT ${_prefix}_FOUND OR (NOT "${ARGN}" STREQUAL "" AND NOT "${__pkg_config_arguments_${_prefix}}" STREQUAL "${_module0};${ARGN}") OR ( "${ARGN}" STREQUAL "" AND NOT "${__pkg_config_arguments_${_prefix}}" STREQUAL "${_module0}")) - _pkg_check_modules_internal("${_pkg_is_required}" "${_pkg_is_silent}" ${_no_cmake_path} ${_no_cmake_environment_path} ${_imp_target} ${_imp_target_global} "${_prefix}" ${_pkg_modules}) + _pkg_check_modules_internal("${_pkg_is_required}" "${_pkg_is_silent}" ${_no_cmake_path} ${_no_cmake_environment_path} ${_imp_target} ${_imp_target_global} ${_static_target} "${_prefix}" ${_pkg_modules}) _pkgconfig_set(__pkg_config_checked_${_prefix} ${PKG_CONFIG_VERSION}) if (${_prefix}_FOUND) @@ -832,7 +882,7 @@ macro(pkg_check_modules _prefix _module0) endif() else() if (${_prefix}_FOUND) - _pkg_recalculate("${_prefix}" ${_no_cmake_path} ${_no_cmake_environment_path} ${_imp_target} ${_imp_target_global}) + _pkg_recalculate("${_prefix}" ${_no_cmake_path} ${_no_cmake_environment_path} ${_imp_target} ${_imp_target_global} ${_static_target}) endif() endif() endmacro() @@ -866,7 +916,7 @@ endmacro() pkg_search_module (BAR libxml-2.0 libxml2 libxml>=2) #]========================================] macro(pkg_search_module _prefix _module0) - _pkgconfig_parse_options(_pkg_modules_alt _pkg_is_required _pkg_is_silent _no_cmake_path _no_cmake_environment_path _imp_target _imp_target_global "${_module0}" ${ARGN}) + _pkgconfig_parse_options(_pkg_modules_alt _pkg_is_required _pkg_is_silent _no_cmake_path _no_cmake_environment_path _imp_target _imp_target_global _static_target "${_module0}" ${ARGN}) # check cached value if (NOT DEFINED __pkg_config_checked_${_prefix} OR __pkg_config_checked_${_prefix} LESS ${PKG_CONFIG_VERSION} OR NOT ${_prefix}_FOUND) set(_pkg_modules_found 0) @@ -878,7 +928,7 @@ macro(pkg_search_module _prefix _module0) # iterate through all modules and stop at the first working one. foreach(_pkg_alt ${_pkg_modules_alt}) if(NOT _pkg_modules_found) - _pkg_check_modules_internal(0 1 ${_no_cmake_path} ${_no_cmake_environment_path} ${_imp_target} ${_imp_target_global} "${_prefix}" "${_pkg_alt}") + _pkg_check_modules_internal(0 1 ${_no_cmake_path} ${_no_cmake_environment_path} ${_imp_target} ${_imp_target_global} ${_static_target} "${_prefix}" "${_pkg_alt}") endif() if (${_prefix}_FOUND) @@ -895,7 +945,7 @@ macro(pkg_search_module _prefix _module0) _pkgconfig_set(__pkg_config_checked_${_prefix} ${PKG_CONFIG_VERSION}) elseif (${_prefix}_FOUND) - _pkg_recalculate("${_prefix}" ${_no_cmake_path} ${_no_cmake_environment_path} ${_imp_target} ${_imp_target_global}) + _pkg_recalculate("${_prefix}" ${_no_cmake_path} ${_no_cmake_environment_path} ${_imp_target} ${_imp_target_global} ${_static_target}) endif() endmacro() diff --git a/Source/CMakeVersion.cmake b/Source/CMakeVersion.cmake index d9bd717..3b258cd 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 23) -set(CMake_VERSION_PATCH 20220522) +set(CMake_VERSION_PATCH 20220524) #set(CMake_VERSION_RC 0) set(CMake_VERSION_IS_DIRTY 0) diff --git a/Source/CPack/IFW/cmCPackIFWGenerator.cxx b/Source/CPack/IFW/cmCPackIFWGenerator.cxx index 9ca7a69..9dd8fe3 100644 --- a/Source/CPack/IFW/cmCPackIFWGenerator.cxx +++ b/Source/CPack/IFW/cmCPackIFWGenerator.cxx @@ -468,7 +468,7 @@ std::string cmCPackIFWGenerator::GetComponentInstallDirNameSuffix( const std::string suffix = "/data"; if (this->componentPackageMethod == this->ONE_PACKAGE) { - return std::string(prefix + this->GetRootPackageName() + suffix); + return cmStrCat(prefix, this->GetRootPackageName(), suffix); } return prefix + diff --git a/Source/CPack/IFW/cmCPackIFWRepository.cxx b/Source/CPack/IFW/cmCPackIFWRepository.cxx index f25d2d2..46fc57f 100644 --- a/Source/CPack/IFW/cmCPackIFWRepository.cxx +++ b/Source/CPack/IFW/cmCPackIFWRepository.cxx @@ -116,13 +116,12 @@ public: cmCPackeIFWUpdatesPatcher(cmCPackIFWRepository* r, cmXMLWriter& x) : repository(r) , xout(x) - , patched(false) { } cmCPackIFWRepository* repository; cmXMLWriter& xout; - bool patched; + bool patched = false; protected: void StartElement(const std::string& name, const char** atts) override diff --git a/Source/CPack/cmCPackDebGenerator.cxx b/Source/CPack/cmCPackDebGenerator.cxx index 8e5e637..a3b9434 100644 --- a/Source/CPack/cmCPackDebGenerator.cxx +++ b/Source/CPack/cmCPackDebGenerator.cxx @@ -707,7 +707,7 @@ bool cmCPackDebGenerator::createDebPackages() &cmCPackDebGenerator::createDbgsymDDeb) && retval; } - return int(retval); + return static_cast<int>(retval); } bool cmCPackDebGenerator::createDeb() diff --git a/Source/CTest/cmCTestBZR.cxx b/Source/CTest/cmCTestBZR.cxx index 0fe4ff4..81a866a 100644 --- a/Source/CTest/cmCTestBZR.cxx +++ b/Source/CTest/cmCTestBZR.cxx @@ -88,7 +88,6 @@ class cmCTestBZR::InfoParser : public cmCTestVC::LineParser public: InfoParser(cmCTestBZR* bzr, const char* prefix) : BZR(bzr) - , CheckOutFound(false) { this->SetLog(&bzr->Log, prefix); this->RegexCheckOut.compile("checkout of branch: *([^\t\r\n]+)$"); @@ -97,7 +96,7 @@ public: private: cmCTestBZR* BZR; - bool CheckOutFound; + bool CheckOutFound = false; cmsys::RegularExpression RegexCheckOut; cmsys::RegularExpression RegexParent; bool ProcessLine() override @@ -255,26 +254,26 @@ private: this->BZR->DoRevision(this->Rev, this->Changes); } else if (!this->CData.empty() && (name == "file" || name == "directory")) { - this->CurChange.Path.assign(&this->CData[0], this->CData.size()); + this->CurChange.Path.assign(this->CData.data(), this->CData.size()); cmSystemTools::ConvertToUnixSlashes(this->CurChange.Path); this->Changes.push_back(this->CurChange); } else if (!this->CData.empty() && name == "symlink") { // symlinks have an arobase at the end in the log - this->CurChange.Path.assign(&this->CData[0], this->CData.size() - 1); + this->CurChange.Path.assign(this->CData.data(), this->CData.size() - 1); cmSystemTools::ConvertToUnixSlashes(this->CurChange.Path); this->Changes.push_back(this->CurChange); } else if (!this->CData.empty() && name == "committer") { - this->Rev.Author.assign(&this->CData[0], this->CData.size()); + this->Rev.Author.assign(this->CData.data(), this->CData.size()); if (this->EmailRegex.find(this->Rev.Author)) { this->Rev.Author = this->EmailRegex.match(1); this->Rev.EMail = this->EmailRegex.match(2); } } else if (!this->CData.empty() && name == "timestamp") { - this->Rev.Date.assign(&this->CData[0], this->CData.size()); + this->Rev.Date.assign(this->CData.data(), this->CData.size()); } else if (!this->CData.empty() && name == "message") { - this->Rev.Log.assign(&this->CData[0], this->CData.size()); + this->Rev.Log.assign(this->CData.data(), this->CData.size()); } else if (!this->CData.empty() && name == "revno") { - this->Rev.Rev.assign(&this->CData[0], this->CData.size()); + this->Rev.Rev.assign(this->CData.data(), this->CData.size()); } this->CData.clear(); } @@ -389,7 +388,7 @@ bool cmCTestBZR::UpdateImpl() // For some reason bzr uses stderr to display the update status. OutputLogger out(this->Log, "pull-out> "); UpdateParser err(this, "pull-err> "); - return this->RunUpdateCommand(&bzr_update[0], &out, &err); + return this->RunUpdateCommand(bzr_update.data(), &out, &err); } bool cmCTestBZR::LoadRevisions() diff --git a/Source/CTest/cmCTestBinPacker.cxx b/Source/CTest/cmCTestBinPacker.cxx index e21b14d..6eb45fa 100644 --- a/Source/CTest/cmCTestBinPacker.cxx +++ b/Source/CTest/cmCTestBinPacker.cxx @@ -34,7 +34,7 @@ namespace { * more combinations can be tried. */ template <typename AllocationStrategy> -static bool AllocateCTestResources( +bool AllocateCTestResources( const std::map<std::string, cmCTestResourceAllocator::Resource>& resources, const std::vector<std::string>& resourcesSorted, std::size_t currentIndex, std::vector<cmCTestBinPackerAllocation*>& allocations) @@ -82,7 +82,7 @@ static bool AllocateCTestResources( } template <typename AllocationStrategy> -static bool AllocateCTestResources( +bool AllocateCTestResources( const std::map<std::string, cmCTestResourceAllocator::Resource>& resources, std::vector<cmCTestBinPackerAllocation>& allocations) { @@ -108,7 +108,7 @@ static bool AllocateCTestResources( // Do the actual allocation return AllocateCTestResources<AllocationStrategy>( - resources, resourcesSorted, std::size_t(0), allocationsPtr); + resources, resourcesSorted, static_cast<std::size_t>(0), allocationsPtr); } class RoundRobinAllocationStrategy diff --git a/Source/CTest/cmCTestCVS.cxx b/Source/CTest/cmCTestCVS.cxx index 1209e06..87ab762 100644 --- a/Source/CTest/cmCTestCVS.cxx +++ b/Source/CTest/cmCTestCVS.cxx @@ -101,7 +101,7 @@ bool cmCTestCVS::UpdateImpl() UpdateParser out(this, "up-out> "); UpdateParser err(this, "up-err> "); - return this->RunUpdateCommand(&cvs_update[0], &out, &err); + return this->RunUpdateCommand(cvs_update.data(), &out, &err); } class cmCTestCVS::LogParser : public cmCTestVC::LineParser @@ -111,7 +111,6 @@ public: LogParser(cmCTestCVS* cvs, const char* prefix, std::vector<Revision>& revs) : CVS(cvs) , Revisions(revs) - , Section(SectionHeader) { this->SetLog(&cvs->Log, prefix); this->RegexRevision.compile("^revision +([^ ]*) *$"); @@ -131,7 +130,7 @@ private: SectionRevisions, SectionEnd }; - SectionType Section; + SectionType Section = SectionHeader; Revision Rev; bool ProcessLine() override @@ -259,7 +258,7 @@ void cmCTestCVS::WriteXMLDirectory(cmXMLWriter& xml, std::string const& path, revisions.resize(2, this->Unknown); // Write the entry for this file with these revisions. - File f(fi.second, &revisions[0], &revisions[1]); + File f(fi.second, revisions.data(), revisions.data() + 1); this->WriteXMLEntry(xml, path, fi.first, full, f); } xml.EndElement(); // Directory diff --git a/Source/CTest/cmCTestCoverageHandler.cxx b/Source/CTest/cmCTestCoverageHandler.cxx index aef58c5..f7c6a9c 100644 --- a/Source/CTest/cmCTestCoverageHandler.cxx +++ b/Source/CTest/cmCTestCoverageHandler.cxx @@ -2210,7 +2210,7 @@ int cmCTestCoverageHandler::GetLabelId(std::string const& label) { auto i = this->LabelIdMap.find(label); if (i == this->LabelIdMap.end()) { - int n = int(this->Labels.size()); + int n = static_cast<int>(this->Labels.size()); this->Labels.push_back(label); LabelIdMapType::value_type entry(label, n); i = this->LabelIdMap.insert(entry).first; diff --git a/Source/CTest/cmCTestGIT.cxx b/Source/CTest/cmCTestGIT.cxx index 56f805c..b2fb069 100644 --- a/Source/CTest/cmCTestGIT.cxx +++ b/Source/CTest/cmCTestGIT.cxx @@ -176,7 +176,7 @@ bool cmCTestGIT::UpdateByFetchAndReset() // Fetch upstream refs. OutputLogger fetch_out(this->Log, "fetch-out> "); OutputLogger fetch_err(this->Log, "fetch-err> "); - if (!this->RunUpdateCommand(&git_fetch[0], &fetch_out, &fetch_err)) { + if (!this->RunUpdateCommand(git_fetch.data(), &fetch_out, &fetch_err)) { return false; } @@ -225,7 +225,7 @@ bool cmCTestGIT::UpdateByCustom(std::string const& custom) OutputLogger custom_out(this->Log, "custom-out> "); OutputLogger custom_err(this->Log, "custom-err> "); - return this->RunUpdateCommand(&git_custom[0], &custom_out, &custom_err); + return this->RunUpdateCommand(git_custom.data(), &custom_out, &custom_err); } bool cmCTestGIT::UpdateInternal() @@ -332,7 +332,6 @@ public: DiffParser(cmCTestGIT* git, const char* prefix) : LineParser('\0', false) , GIT(git) - , DiffField(DiffFieldNone) { this->SetLog(&git->Log, prefix); } @@ -349,7 +348,7 @@ protected: DiffFieldSrc, DiffFieldDst }; - DiffFieldType DiffField; + DiffFieldType DiffField = DiffFieldNone; Change CurChange; void DiffReset() @@ -454,7 +453,6 @@ class cmCTestGIT::CommitParser : public cmCTestGIT::DiffParser public: CommitParser(cmCTestGIT* git, const char* prefix) : DiffParser(git, prefix) - , Section(SectionHeader) { this->Separator = SectionSep[this->Section]; } @@ -469,7 +467,7 @@ private: SectionCount }; static char const SectionSep[SectionCount]; - SectionType Section; + SectionType Section = SectionHeader; Revision Rev; struct Person @@ -537,7 +535,8 @@ private: void NextSection() { - this->Section = SectionType((this->Section + 1) % SectionCount); + this->Section = + static_cast<SectionType>((this->Section + 1) % SectionCount); this->Separator = SectionSep[this->Section]; if (this->Section == SectionHeader) { this->GIT->DoRevision(this->Rev, this->Changes); diff --git a/Source/CTest/cmCTestHG.cxx b/Source/CTest/cmCTestHG.cxx index 5f4581e..97b01ba 100644 --- a/Source/CTest/cmCTestHG.cxx +++ b/Source/CTest/cmCTestHG.cxx @@ -157,7 +157,7 @@ bool cmCTestHG::UpdateImpl() OutputLogger out(this->Log, "update-out> "); OutputLogger err(this->Log, "update-err> "); - return this->RunUpdateCommand(&hg_update[0], &out, &err); + return this->RunUpdateCommand(hg_update.data(), &out, &err); } class cmCTestHG::LogParser @@ -213,13 +213,13 @@ private: if (name == "logentry") { this->HG->DoRevision(this->Rev, this->Changes); } else if (!this->CData.empty() && name == "author") { - this->Rev.Author.assign(&this->CData[0], this->CData.size()); + this->Rev.Author.assign(this->CData.data(), this->CData.size()); } else if (!this->CData.empty() && name == "email") { - this->Rev.EMail.assign(&this->CData[0], this->CData.size()); + this->Rev.EMail.assign(this->CData.data(), this->CData.size()); } else if (!this->CData.empty() && name == "date") { - this->Rev.Date.assign(&this->CData[0], this->CData.size()); + this->Rev.Date.assign(this->CData.data(), this->CData.size()); } else if (!this->CData.empty() && name == "msg") { - this->Rev.Log.assign(&this->CData[0], this->CData.size()); + this->Rev.Log.assign(this->CData.data(), this->CData.size()); } else if (!this->CData.empty() && name == "files") { std::vector<std::string> paths = this->SplitCData(); for (std::string const& path : paths) { diff --git a/Source/CTest/cmCTestMemCheckHandler.cxx b/Source/CTest/cmCTestMemCheckHandler.cxx index 2d8276a..788845b 100644 --- a/Source/CTest/cmCTestMemCheckHandler.cxx +++ b/Source/CTest/cmCTestMemCheckHandler.cxx @@ -1207,7 +1207,8 @@ bool cmCTestMemCheckHandler::ProcessMemCheckCudaOutput( if (failure >= 0) { ostr << "<b>" << this->ResultStrings[failure] << "</b> "; - if (results.empty() || unsigned(failure) > results.size() - 1) { + if (results.empty() || + static_cast<unsigned>(failure) > results.size() - 1) { results.push_back(1); } else { results[failure]++; diff --git a/Source/CTest/cmCTestP4.cxx b/Source/CTest/cmCTestP4.cxx index 50c9c16..0e67c41 100644 --- a/Source/CTest/cmCTestP4.cxx +++ b/Source/CTest/cmCTestP4.cxx @@ -118,7 +118,6 @@ class cmCTestP4::DiffParser : public cmCTestVC::LineParser public: DiffParser(cmCTestP4* p4, const char* prefix) : P4(p4) - , AlreadyNotified(false) { this->SetLog(&this->P4->Log, prefix); this->RegexDiff.compile("^==== (.*)#[0-9]+ - (.*)"); @@ -126,7 +125,7 @@ public: private: cmCTestP4* P4; - bool AlreadyNotified; + bool AlreadyNotified = false; std::string CurrentPath; cmsys::RegularExpression RegexDiff; @@ -161,7 +160,7 @@ cmCTestP4::User cmCTestP4::GetUserData(const std::string& username) UserParser out(this, "users-out> "); OutputLogger err(this->Log, "users-err> "); - this->RunChild(&p4_users[0], &out, &err); + this->RunChild(p4_users.data(), &out, &err); // The user should now be added to the map. Search again. it = this->Users.find(username); @@ -193,7 +192,6 @@ public: DescribeParser(cmCTestP4* p4, const char* prefix) : LineParser('\n', false) , P4(p4) - , Section(SectionHeader) { this->SetLog(&this->P4->Log, prefix); this->RegexHeader.compile("^Change ([0-9]+) by (.+)@(.+) on (.*)$"); @@ -216,7 +214,7 @@ private: SectionDiff, SectionCount }; - SectionType Section; + SectionType Section = SectionHeader; Revision Rev; bool ProcessLine() override @@ -250,7 +248,8 @@ private: this->Rev = Revision(); } - this->Section = SectionType((this->Section + 1) % SectionCount); + this->Section = + static_cast<SectionType>((this->Section + 1) % SectionCount); } void DoHeaderLine() @@ -354,7 +353,7 @@ std::string cmCTestP4::GetWorkingRevision() IdentifyParser out(this, "p4_changes-out> ", rev); OutputLogger err(this->Log, "p4_changes-err> "); - bool result = this->RunChild(&p4_identify[0], &out, &err); + bool result = this->RunChild(p4_identify.data(), &out, &err); // If there was a problem contacting the server return "<unknown>" if (!result) { @@ -418,7 +417,7 @@ bool cmCTestP4::LoadRevisions() OutputLogger err(this->Log, "p4_changes-err> "); this->ChangeLists.clear(); - this->RunChild(&p4_changes[0], &out, &err); + this->RunChild(p4_changes.data(), &out, &err); if (this->ChangeLists.empty()) { return true; @@ -435,7 +434,7 @@ bool cmCTestP4::LoadRevisions() DescribeParser outDescribe(this, "p4_describe-out> "); OutputLogger errDescribe(this->Log, "p4_describe-err> "); - this->RunChild(&p4_describe[0], &outDescribe, &errDescribe); + this->RunChild(p4_describe.data(), &outDescribe, &errDescribe); } return true; } @@ -455,7 +454,7 @@ bool cmCTestP4::LoadModifications() DiffParser out(this, "p4_diff-out> "); OutputLogger err(this->Log, "p4_diff-err> "); - this->RunChild(&p4_diff[0], &out, &err); + this->RunChild(p4_diff.data(), &out, &err); return true; } @@ -473,7 +472,7 @@ bool cmCTestP4::UpdateCustom(const std::string& custom) OutputLogger custom_out(this->Log, "p4_customsync-out> "); OutputLogger custom_err(this->Log, "p4_customsync-err> "); - return this->RunUpdateCommand(&p4_custom[0], &custom_out, &custom_err); + return this->RunUpdateCommand(p4_custom.data(), &custom_out, &custom_err); } bool cmCTestP4::UpdateImpl() @@ -523,5 +522,5 @@ bool cmCTestP4::UpdateImpl() OutputLogger out(this->Log, "p4_sync-out> "); OutputLogger err(this->Log, "p4_sync-err> "); - return this->RunUpdateCommand(&p4_sync[0], &out, &err); + return this->RunUpdateCommand(p4_sync.data(), &out, &err); } diff --git a/Source/CTest/cmCTestSVN.cxx b/Source/CTest/cmCTestSVN.cxx index 4692dbd..4c98fdf 100644 --- a/Source/CTest/cmCTestSVN.cxx +++ b/Source/CTest/cmCTestSVN.cxx @@ -286,9 +286,9 @@ bool cmCTestSVN::RunSVNCommand(std::vector<char const*> const& parameters, args.push_back(nullptr); if (strcmp(parameters[0], "update") == 0) { - return this->RunUpdateCommand(&args[0], out, err); + return this->RunUpdateCommand(args.data(), out, err); } - return this->RunChild(&args[0], out, err); + return this->RunChild(args.data(), out, err); } class cmCTestSVN::LogParser @@ -353,16 +353,16 @@ private: if (name == "logentry") { this->SVN->DoRevisionSVN(this->Rev, this->Changes); } else if (!this->CData.empty() && name == "path") { - std::string orig_path(&this->CData[0], this->CData.size()); + std::string orig_path(this->CData.data(), this->CData.size()); std::string new_path = this->SVNRepo.BuildLocalPath(orig_path); this->CurChange.Path.assign(new_path); this->Changes.push_back(this->CurChange); } else if (!this->CData.empty() && name == "author") { - this->Rev.Author.assign(&this->CData[0], this->CData.size()); + this->Rev.Author.assign(this->CData.data(), this->CData.size()); } else if (!this->CData.empty() && name == "date") { - this->Rev.Date.assign(&this->CData[0], this->CData.size()); + this->Rev.Date.assign(this->CData.data(), this->CData.size()); } else if (!this->CData.empty() && name == "msg") { - this->Rev.Log.assign(&this->CData[0], this->CData.size()); + this->Rev.Log.assign(this->CData.data(), this->CData.size()); } this->CData.clear(); } diff --git a/Source/CTest/cmCTestSubmitHandler.cxx b/Source/CTest/cmCTestSubmitHandler.cxx index fae5e30..da085a6 100644 --- a/Source/CTest/cmCTestSubmitHandler.cxx +++ b/Source/CTest/cmCTestSubmitHandler.cxx @@ -56,7 +56,7 @@ private: { std::string val; if (!this->CurrentValue.empty()) { - val.assign(&this->CurrentValue[0], this->CurrentValue.size()); + val.assign(this->CurrentValue.data(), this->CurrentValue.size()); } return val; } @@ -124,7 +124,7 @@ void cmCTestSubmitHandler::Initialize() { // We submit all available parts by default. for (cmCTest::Part p = cmCTest::PartStart; p != cmCTest::PartCount; - p = cmCTest::Part(p + 1)) { + p = static_cast<cmCTest::Part>(p + 1)) { this->SubmitPart[p] = true; } this->HasWarnings = false; @@ -730,15 +730,15 @@ int cmCTestSubmitHandler::ProcessHandler() return -1; } - if (getenv("HTTP_PROXY")) { + if (char const* proxy = getenv("HTTP_PROXY")) { this->HTTPProxyType = 1; - this->HTTPProxy = getenv("HTTP_PROXY"); + this->HTTPProxy = proxy; if (getenv("HTTP_PROXY_PORT")) { this->HTTPProxy += ":"; this->HTTPProxy += getenv("HTTP_PROXY_PORT"); } - if (getenv("HTTP_PROXY_TYPE")) { - std::string type = getenv("HTTP_PROXY_TYPE"); + if (char const* proxy_type = getenv("HTTP_PROXY_TYPE")) { + std::string type = proxy_type; // HTTP/SOCKS4/SOCKS5 if (type == "HTTP") { this->HTTPProxyType = 1; @@ -810,7 +810,7 @@ int cmCTestSubmitHandler::ProcessHandler() // Query parts for files to submit. for (cmCTest::Part p = cmCTest::PartStart; p != cmCTest::PartCount; - p = cmCTest::Part(p + 1)) { + p = static_cast<cmCTest::Part>(p + 1)) { // Skip parts we are not submitting. if (!this->SubmitPart[p]) { continue; @@ -894,9 +894,8 @@ void cmCTestSubmitHandler::SelectParts(std::set<cmCTest::Part> const& parts) { // Check whether each part is selected. for (cmCTest::Part p = cmCTest::PartStart; p != cmCTest::PartCount; - p = cmCTest::Part(p + 1)) { - this->SubmitPart[p] = - (std::set<cmCTest::Part>::const_iterator(parts.find(p)) != parts.end()); + p = static_cast<cmCTest::Part>(p + 1)) { + this->SubmitPart[p] = parts.find(p) != parts.end(); } } diff --git a/Source/CTest/cmCTestTestHandler.cxx b/Source/CTest/cmCTestTestHandler.cxx index 696a5ea..248533a 100644 --- a/Source/CTest/cmCTestTestHandler.cxx +++ b/Source/CTest/cmCTestTestHandler.cxx @@ -586,7 +586,8 @@ void cmCTestTestHandler::LogTestSummary(const std::vector<std::string>& passed, { std::size_t total = passed.size() + failed.size(); - float percent = float(passed.size()) * 100.0f / float(total); + float percent = + static_cast<float>(passed.size()) * 100.0f / static_cast<float>(total); if (!failed.empty() && percent > 99) { percent = 99; } diff --git a/Source/CTest/cmCTestVC.cxx b/Source/CTest/cmCTestVC.cxx index d5711c5..609ccba 100644 --- a/Source/CTest/cmCTestVC.cxx +++ b/Source/CTest/cmCTestVC.cxx @@ -66,7 +66,7 @@ bool cmCTestVC::InitialCheckout(const std::string& command) this->Log << "--- Begin Initial Checkout ---\n"; OutputLogger out(this->Log, "co-out> "); OutputLogger err(this->Log, "co-err> "); - bool result = this->RunChild(&vc_co[0], &out, &err, parent.c_str()); + bool result = this->RunChild(vc_co.data(), &out, &err, parent.c_str()); this->Log << "--- End Initial Checkout ---\n"; if (!result) { cmCTestLog(this->CTest, ERROR_MESSAGE, diff --git a/Source/CursesDialog/cmCursesMainForm.cxx b/Source/CursesDialog/cmCursesMainForm.cxx index 8381e86..5a8e40f 100644 --- a/Source/CursesDialog/cmCursesMainForm.cxx +++ b/Source/CursesDialog/cmCursesMainForm.cxx @@ -617,7 +617,7 @@ void cmCursesMainForm::FillCacheManagerFromUI() cmValue existingValue = this->CMakeInstance->GetState()->GetCacheEntryValue(cacheKey); if (existingValue) { - std::string oldValue = *existingValue; + std::string const& oldValue = *existingValue; std::string newValue = entry.Entry->GetValue(); std::string fixedOldValue; std::string fixedNewValue; @@ -973,7 +973,7 @@ void cmCursesMainForm::JumpToCacheEntry(const char* astr) } } } - if (size_t(findex) >= 3 * this->NumberOfVisibleEntries - 1) { + if (static_cast<size_t>(findex) >= 3 * this->NumberOfVisibleEntries - 1) { set_current_field(this->Form, this->Fields[2]); } else if (new_page(this->Fields[findex + 1])) { form_driver(this->Form, REQ_NEXT_PAGE); diff --git a/Source/QtDialog/QCMakeCacheView.cxx b/Source/QtDialog/QCMakeCacheView.cxx index 994df78..f79d6fc 100644 --- a/Source/QtDialog/QCMakeCacheView.cxx +++ b/Source/QtDialog/QCMakeCacheView.cxx @@ -66,7 +66,6 @@ class QCMakeAdvancedFilter : public QSortFilterProxyModel public: QCMakeAdvancedFilter(QObject* o) : QSortFilterProxyModel(o) - , ShowAdvanced(false) { } @@ -78,7 +77,7 @@ public: bool showAdvanced() const { return this->ShowAdvanced; } protected: - bool ShowAdvanced; + bool ShowAdvanced = false; bool filterAcceptsRow(int row, const QModelIndex& p) const override { @@ -304,7 +303,7 @@ void QCMakeCacheModel::setProperties(const QCMakePropertyList& props) int num = props2.size(); for (int i = 0; i < num; i++) { - QCMakeProperty prop = props2[i]; + QCMakeProperty const& prop = props2[i]; QList<QStandardItem*> items; items.append(new QStandardItem()); items.append(new QStandardItem()); @@ -326,7 +325,7 @@ void QCMakeCacheModel::setProperties(const QCMakePropertyList& props) int num = props2.size(); for (int i = 0; i < num; i++) { - QCMakeProperty prop = props2[i]; + QCMakeProperty const& prop = props2[i]; QList<QStandardItem*> items; items.append(new QStandardItem()); items.append(new QStandardItem()); diff --git a/Source/cmArchiveWrite.cxx b/Source/cmArchiveWrite.cxx index cfde37c..f29983c 100644 --- a/Source/cmArchiveWrite.cxx +++ b/Source/cmArchiveWrite.cxx @@ -92,7 +92,6 @@ cmArchiveWrite::cmArchiveWrite(std::ostream& os, Compress c, : Stream(os) , Archive(archive_write_new()) , Disk(archive_read_disk_new()) - , Verbose(false) , Format(format) { // Upstream fixed an issue with their integer parsing in 3.4.0 diff --git a/Source/cmArchiveWrite.h b/Source/cmArchiveWrite.h index 260bd20..b9fa3d7 100644 --- a/Source/cmArchiveWrite.h +++ b/Source/cmArchiveWrite.h @@ -156,7 +156,7 @@ private: std::ostream& Stream; struct archive* Archive; struct archive* Disk; - bool Verbose; + bool Verbose = false; std::string Format; std::string Error; std::string MTime; diff --git a/Source/cmCTest.cxx b/Source/cmCTest.cxx index 710b4d7..9638a72 100644 --- a/Source/cmCTest.cxx +++ b/Source/cmCTest.cxx @@ -322,7 +322,7 @@ std::string cmCTest::DecodeURL(const std::string& in) for (const char* c = in.c_str(); *c; ++c) { if (*c == '%' && isxdigit(*(c + 1)) && isxdigit(*(c + 2))) { char buf[3] = { *(c + 1), *(c + 2), 0 }; - out.append(1, char(strtoul(buf, nullptr, 16))); + out.append(1, static_cast<char>(strtoul(buf, nullptr, 16))); c += 2; } else { out.append(1, *c); @@ -357,7 +357,7 @@ cmCTest::cmCTest() this->Impl->Parts[PartDone].SetName("Done"); // Fill the part name-to-id map. - for (Part p = PartStart; p != PartCount; p = Part(p + 1)) { + for (Part p = PartStart; p != PartCount; p = static_cast<Part>(p + 1)) { this->Impl ->PartMap[cmSystemTools::LowerCase(this->Impl->Parts[p].GetName())] = p; } @@ -643,7 +643,7 @@ bool cmCTest::InitializeFromCommand(cmCTestStartCommand* command) std::string src_dir = this->GetCTestConfiguration("SourceDirectory"); std::string bld_dir = this->GetCTestConfiguration("BuildDirectory"); this->Impl->BuildID = ""; - for (Part p = PartStart; p != PartCount; p = Part(p + 1)) { + for (Part p = PartStart; p != PartCount; p = static_cast<Part>(p + 1)) { this->Impl->Parts[p].SubmitFiles.clear(); } @@ -797,7 +797,7 @@ int cmCTest::GetTestModel() const bool cmCTest::SetTest(const std::string& ttype, bool report) { if (cmSystemTools::LowerCase(ttype) == "all") { - for (Part p = PartStart; p != PartCount; p = Part(p + 1)) { + for (Part p = PartStart; p != PartCount; p = static_cast<Part>(p + 1)) { this->Impl->Parts[p].Enable(); } return true; @@ -935,7 +935,8 @@ int cmCTest::ProcessSteps() bool notest = true; int update_count = 0; - for (Part p = PartStart; notest && p != PartCount; p = Part(p + 1)) { + for (Part p = PartStart; notest && p != PartCount; + p = static_cast<Part>(p + 1)) { notest = !this->Impl->Parts[p]; } if (this->Impl->Parts[PartUpdate] && @@ -1672,16 +1673,16 @@ std::string cmCTest::Base64EncodeFile(std::string const& file) #endif ); std::vector<char> file_buffer(len + 1); - ifs.read(&file_buffer[0], len); + ifs.read(file_buffer.data(), len); ifs.close(); std::vector<char> encoded_buffer((len * 3) / 2 + 5); size_t const rlen = cmsysBase64_Encode( - reinterpret_cast<unsigned char*>(&file_buffer[0]), len, - reinterpret_cast<unsigned char*>(&encoded_buffer[0]), 1); + reinterpret_cast<unsigned char*>(file_buffer.data()), len, + reinterpret_cast<unsigned char*>(encoded_buffer.data()), 1); - return std::string(&encoded_buffer[0], rlen); + return std::string(encoded_buffer.data(), rlen); } bool cmCTest::SubmitExtraFiles(std::vector<std::string> const& files) @@ -2019,7 +2020,8 @@ bool cmCTest::HandleCommandLineArguments(size_t& i, i++; long outputSize; if (cmStrToLong(args[i], &outputSize)) { - this->Impl->TestHandler.SetTestOutputSizePassed(int(outputSize)); + this->Impl->TestHandler.SetTestOutputSizePassed( + static_cast<int>(outputSize)); } else { cmCTestLog(this, WARNING, "Invalid value for '--test-output-size-passed': " << args[i] @@ -2030,7 +2032,8 @@ bool cmCTest::HandleCommandLineArguments(size_t& i, i++; long outputSize; if (cmStrToLong(args[i], &outputSize)) { - this->Impl->TestHandler.SetTestOutputSizeFailed(int(outputSize)); + this->Impl->TestHandler.SetTestOutputSizeFailed( + static_cast<int>(outputSize)); } else { cmCTestLog(this, WARNING, "Invalid value for '--test-output-size-failed': " << args[i] @@ -2801,7 +2804,7 @@ bool cmCTest::HandleTestActionArgument(const char* ctestExec, size_t& i, const std::vector<std::string>& args) { bool success = true; - std::string arg = args[i]; + std::string const& arg = args[i]; if (this->CheckArgument(arg, "-T"_s, "--test-action") && (i < args.size() - 1)) { this->Impl->ProduceXML = true; @@ -2833,7 +2836,7 @@ bool cmCTest::HandleTestModelArgument(const char* ctestExec, size_t& i, const std::vector<std::string>& args) { bool success = true; - std::string arg = args[i]; + std::string const& arg = args[i]; if (this->CheckArgument(arg, "-M"_s, "--test-model") && (i < args.size() - 1)) { i++; @@ -3729,7 +3732,7 @@ bool cmCTest::CompressString(std::string& str) strm.avail_in = static_cast<uInt>(str.size()); strm.next_in = in; strm.avail_out = outSize; - strm.next_out = &out[0]; + strm.next_out = out.data(); ret = deflate(&strm, Z_FINISH); if (ret != Z_STREAM_END) { @@ -3743,10 +3746,10 @@ bool cmCTest::CompressString(std::string& str) // Now base64 encode the resulting binary string std::vector<unsigned char> base64EncodedBuffer((outSize * 3) / 2); - size_t rlen = - cmsysBase64_Encode(&out[0], strm.total_out, &base64EncodedBuffer[0], 1); + size_t rlen = cmsysBase64_Encode(out.data(), strm.total_out, + base64EncodedBuffer.data(), 1); - str.assign(reinterpret_cast<char*>(&base64EncodedBuffer[0]), rlen); + str.assign(reinterpret_cast<char*>(base64EncodedBuffer.data()), rlen); return true; } diff --git a/Source/cmConditionEvaluator.cxx b/Source/cmConditionEvaluator.cxx index 8e479c5..141c4eb 100644 --- a/Source/cmConditionEvaluator.cxx +++ b/Source/cmConditionEvaluator.cxx @@ -95,7 +95,8 @@ struct cmRt2CtSelector<Comp> std::string bool2string(bool const value) { - return std::string(std::size_t(1), static_cast<char>('0' + int(value))); + return std::string(static_cast<std::size_t>(1), + static_cast<char>('0' + static_cast<int>(value))); } bool looksLikeSpecialVariable(const std::string& var, @@ -141,15 +142,17 @@ public: { this->current = std::next(this->current); this->next = - std::next(this->current, difference_type(this->current != args.end())); + std::next(this->current, + static_cast<difference_type>(this->current != args.end())); return *this; } private: CurrentAndNextIter(base_t& args) : current(args.begin()) - , next(std::next(this->current, - difference_type(this->current != args.end()))) + , next( + std::next(this->current, + static_cast<difference_type>(this->current != args.end()))) { } }; @@ -167,19 +170,21 @@ public: { this->current = std::next(this->current); this->next = - std::next(this->current, difference_type(this->current != args.end())); - this->nextnext = - std::next(this->next, difference_type(this->next != args.end())); + std::next(this->current, + static_cast<difference_type>(this->current != args.end())); + this->nextnext = std::next( + this->next, static_cast<difference_type>(this->next != args.end())); return *this; } private: CurrentAndTwoMoreIter(base_t& args) : current(args.begin()) - , next(std::next(this->current, - difference_type(this->current != args.end()))) - , nextnext( - std::next(this->next, difference_type(this->next != args.end()))) + , next( + std::next(this->current, + static_cast<difference_type>(this->current != args.end()))) + , nextnext(std::next( + this->next, static_cast<difference_type>(this->next != args.end()))) { } }; @@ -526,9 +531,6 @@ bool cmConditionEvaluator::HandleLevel0(cmArgumentList& newArgs, bool cmConditionEvaluator::HandleLevel1(cmArgumentList& newArgs, std::string&, MessageType&) { - const auto policy64IsOld = this->Policy64Status == cmPolicies::OLD || - this->Policy64Status == cmPolicies::WARN; - for (auto args = newArgs.make2ArgsIterator(); args.current != newArgs.end(); args.advance(newArgs)) { @@ -580,7 +582,8 @@ bool cmConditionEvaluator::HandleLevel1(cmArgumentList& newArgs, std::string&, // does a command exist else if (this->IsKeyword(keyCOMMAND, *args.current)) { newArgs.ReduceOneArg( - bool(this->Makefile.GetState()->GetCommand(args.next->GetValue())), + static_cast<bool>( + this->Makefile.GetState()->GetCommand(args.next->GetValue())), args); } // does a policy exist @@ -591,8 +594,9 @@ bool cmConditionEvaluator::HandleLevel1(cmArgumentList& newArgs, std::string&, } // does a target exist else if (this->IsKeyword(keyTARGET, *args.current)) { - newArgs.ReduceOneArg( - bool(this->Makefile.FindTargetToUse(args.next->GetValue())), args); + newArgs.ReduceOneArg(static_cast<bool>(this->Makefile.FindTargetToUse( + args.next->GetValue())), + args); } // is a variable defined else if (this->IsKeyword(keyDEFINED, *args.current)) { @@ -607,7 +611,8 @@ bool cmConditionEvaluator::HandleLevel1(cmArgumentList& newArgs, std::string&, else if (looksLikeSpecialVariable(var, "CACHE"_s, varNameLen)) { const auto cache = args.next->GetValue().substr(6, varNameLen - 7); - result = bool(this->Makefile.GetState()->GetCacheEntryValue(cache)); + result = static_cast<bool>( + this->Makefile.GetState()->GetCacheEntryValue(cache)); } else { @@ -617,11 +622,13 @@ bool cmConditionEvaluator::HandleLevel1(cmArgumentList& newArgs, std::string&, } // does a test exist else if (this->IsKeyword(keyTEST, *args.current)) { - if (policy64IsOld) { + if (this->Policy64Status == cmPolicies::OLD || + this->Policy64Status == cmPolicies::WARN) { continue; } - newArgs.ReduceOneArg(bool(this->Makefile.GetTest(args.next->GetValue())), - args); + newArgs.ReduceOneArg( + static_cast<bool>(this->Makefile.GetTest(args.next->GetValue())), + args); } } return true; diff --git a/Source/cmCoreTryCompile.cxx b/Source/cmCoreTryCompile.cxx index caa413b..1e84a0b 100644 --- a/Source/cmCoreTryCompile.cxx +++ b/Source/cmCoreTryCompile.cxx @@ -32,11 +32,7 @@ class LanguageStandardState { public: LanguageStandardState(std::string&& lang) - : IsEnabled(false) - , DidStandard(false) - , DidStandardRequired(false) - , DidExtensions(false) - , StandardFlag(lang + "_STANDARD") + : StandardFlag(lang + "_STANDARD") , RequiredFlag(lang + "_STANDARD_REQUIRED") , ExtensionFlag(lang + "_EXTENSIONS") { @@ -154,10 +150,10 @@ public: } private: - bool IsEnabled; - bool DidStandard; - bool DidStandardRequired; - bool DidExtensions; + bool IsEnabled = false; + bool DidStandard = false; + bool DidStandardRequired = false; + bool DidExtensions = false; std::string StandardFlag; std::string RequiredFlag; diff --git a/Source/cmCryptoHash.cxx b/Source/cmCryptoHash.cxx index b331862..ff9ab0f 100644 --- a/Source/cmCryptoHash.cxx +++ b/Source/cmCryptoHash.cxx @@ -83,15 +83,15 @@ std::unique_ptr<cmCryptoHash> cmCryptoHash::New(cm::string_view algo) bool cmCryptoHash::IntFromHexDigit(char input, char& output) { if (input >= '0' && input <= '9') { - output = char(input - '0'); + output = static_cast<char>(input - '0'); return true; } if (input >= 'a' && input <= 'f') { - output = char(input - 'a' + 0xA); + output = static_cast<char>(input - 'a' + 0xA); return true; } if (input >= 'A' && input <= 'F') { - output = char(input - 'A' + 0xA); + output = static_cast<char>(input - 'A' + 0xA); return true; } return false; @@ -182,7 +182,7 @@ void cmCryptoHash::Append(cm::string_view input) std::vector<unsigned char> cmCryptoHash::Finalize() { std::vector<unsigned char> hash(rhash_get_digest_size(this->Id), 0); - rhash_final(this->CTX, &hash[0]); + rhash_final(this->CTX, hash.data()); return hash; } diff --git a/Source/cmDependsFortran.cxx b/Source/cmDependsFortran.cxx index d5e54ae..ac93c90 100644 --- a/Source/cmDependsFortran.cxx +++ b/Source/cmDependsFortran.cxx @@ -478,7 +478,7 @@ bool cmDependsFortran::CopyModule(const std::vector<std::string>& args) // when the interface described in the module does not. std::string mod = args[2]; - std::string stamp = args[3]; + std::string const& stamp = args[3]; std::string compilerId; if (args.size() >= 5) { compilerId = args[4]; diff --git a/Source/cmELF.cxx b/Source/cmELF.cxx index 66f1733..8aea753 100644 --- a/Source/cmELF.cxx +++ b/Source/cmELF.cxx @@ -83,7 +83,6 @@ public: : External(external) , Stream(std::move(fin)) , ByteOrder(order) - , ELFType(cmELF::FileTypeInvalid) { // In most cases the processor-specific byte order will match that // of the target execution environment. If we choose wrong here @@ -150,7 +149,7 @@ protected: ByteOrderType ByteOrder; // The ELF file type. - cmELF::FileType ELFType; + cmELF::FileType ELFType = cmELF::FileTypeInvalid; // The ELF architecture. std::uint16_t Machine; diff --git a/Source/cmExtraEclipseCDT4Generator.cxx b/Source/cmExtraEclipseCDT4Generator.cxx index d9d5a4b..ba4b326 100644 --- a/Source/cmExtraEclipseCDT4Generator.cxx +++ b/Source/cmExtraEclipseCDT4Generator.cxx @@ -737,7 +737,7 @@ void cmExtraEclipseCDT4Generator::CreateCProjectFile() const // exclude source directory from output search path // - only if not named the same as an output directory if (!cmSystemTools::FileIsDirectory( - std::string(this->HomeOutputDirectory + "/" + p))) { + cmStrCat(this->HomeOutputDirectory, '/', p))) { excludeFromOut += p + "/|"; } } diff --git a/Source/cmFileAPI.cxx b/Source/cmFileAPI.cxx index c1df992..7f8374d 100644 --- a/Source/cmFileAPI.cxx +++ b/Source/cmFileAPI.cxx @@ -417,7 +417,7 @@ const char* cmFileAPI::ObjectKindName(ObjectKind kind) "toolchains", // "__test" // }; - return objectKindNames[size_t(kind)]; + return objectKindNames[static_cast<size_t>(kind)]; } std::string cmFileAPI::ObjectName(Object const& o) diff --git a/Source/cmFileCommand.cxx b/Source/cmFileCommand.cxx index e4728ac..26006d8 100644 --- a/Source/cmFileCommand.cxx +++ b/Source/cmFileCommand.cxx @@ -285,7 +285,7 @@ bool HandleStringsCommand(std::vector<std::string> const& args, } // Get the variable in which to store the results. - std::string outVar = args[2]; + std::string const& outVar = args[2]; // Parse the options. enum @@ -1610,8 +1610,8 @@ size_t cmWriteToMemoryCallback(void* ptr, size_t size, size_t nmemb, return realsize; } -size_t cmFileCommandCurlDebugCallback(CURL*, curl_infotype type, char* chPtr, - size_t size, void* data) +int cmFileCommandCurlDebugCallback(CURL*, curl_infotype type, char* chPtr, + size_t size, void* data) { cmFileCommandVectorOfChar& vec = *static_cast<cmFileCommandVectorOfChar*>(data); @@ -1870,7 +1870,7 @@ bool HandleDownloadCommand(std::vector<std::string> const& args, } std::string algo = i->substr(0, pos); expectedHash = cmSystemTools::LowerCase(i->substr(pos + 1)); - hash = std::unique_ptr<cmCryptoHash>(cmCryptoHash::New(algo)); + hash = cmCryptoHash::New(algo); if (!hash) { std::string err = cmStrCat("DOWNLOAD EXPECTED_HASH given unknown ALGO: ", algo); diff --git a/Source/cmFileCopier.cxx b/Source/cmFileCopier.cxx index 63a4274..1667807 100644 --- a/Source/cmFileCopier.cxx +++ b/Source/cmFileCopier.cxx @@ -27,16 +27,6 @@ cmFileCopier::cmFileCopier(cmExecutionStatus& status, const char* name) : Status(status) , Makefile(&status.GetMakefile()) , Name(name) - , Always(false) - , MatchlessFiles(true) - , FilePermissions(0) - , DirPermissions(0) - , CurrentMatchRule(nullptr) - , UseGivenPermissionsFile(false) - , UseGivenPermissionsDir(false) - , UseSourcePermissions(true) - , FollowSymlinkChain(false) - , Doing(DoingNone) { } diff --git a/Source/cmFileCopier.h b/Source/cmFileCopier.h index ee9872d..1fd2062 100644 --- a/Source/cmFileCopier.h +++ b/Source/cmFileCopier.h @@ -28,15 +28,15 @@ protected: cmExecutionStatus& Status; cmMakefile* Makefile; const char* Name; - bool Always; + bool Always = false; cmFileTimeCache FileTimes; // Whether to install a file not matching any expression. - bool MatchlessFiles; + bool MatchlessFiles = true; // Permissions for files and directories installed by this object. - mode_t FilePermissions; - mode_t DirPermissions; + mode_t FilePermissions = 0; + mode_t DirPermissions = 0; // Properties set by pattern and regex match rules. struct MatchProperties @@ -85,17 +85,15 @@ protected: virtual void ReportCopy(const std::string&, Type, bool) {} virtual bool ReportMissing(const std::string& fromFile); - MatchRule* CurrentMatchRule; - bool UseGivenPermissionsFile; - bool UseGivenPermissionsDir; - bool UseSourcePermissions; - bool FollowSymlinkChain; + MatchRule* CurrentMatchRule = nullptr; + bool UseGivenPermissionsFile = false; + bool UseGivenPermissionsDir = false; + bool UseSourcePermissions = true; + bool FollowSymlinkChain = false; std::string Destination; std::string FilesFromDir; std::vector<std::string> Files; - int Doing; - virtual bool Parse(std::vector<std::string> const& args); enum { DoingNone, @@ -110,6 +108,9 @@ protected: DoingPermissionsMatch, DoingLast1 }; + int Doing = DoingNone; + + virtual bool Parse(std::vector<std::string> const& args); virtual bool CheckKeyword(std::string const& arg); virtual bool CheckValue(std::string const& arg); diff --git a/Source/cmFileInstaller.cxx b/Source/cmFileInstaller.cxx index 9bfbd13..5cfb2cf 100644 --- a/Source/cmFileInstaller.cxx +++ b/Source/cmFileInstaller.cxx @@ -23,13 +23,6 @@ using namespace cmFSPermissions; cmFileInstaller::cmFileInstaller(cmExecutionStatus& status) : cmFileCopier(status, "INSTALL") - , InstallType(cmInstallType_FILES) - , InstallMode(cmInstallMode::COPY) - , Optional(false) - , MessageAlways(false) - , MessageLazy(false) - , MessageNever(false) - , DestDirLength(0) { // Installation does not use source permissions by default. this->UseSourcePermissions = false; @@ -440,7 +433,7 @@ bool cmFileInstaller::HandleInstallDestination() } } destination = sdestdir + destination.substr(skip); - this->DestDirLength = int(sdestdir.size()); + this->DestDirLength = static_cast<int>(sdestdir.size()); } // check if default dir creation permissions were set diff --git a/Source/cmFileInstaller.h b/Source/cmFileInstaller.h index 3f6bd45..0b6f15d 100644 --- a/Source/cmFileInstaller.h +++ b/Source/cmFileInstaller.h @@ -19,13 +19,13 @@ struct cmFileInstaller : public cmFileCopier ~cmFileInstaller() override; protected: - cmInstallType InstallType; - cmInstallMode InstallMode; - bool Optional; - bool MessageAlways; - bool MessageLazy; - bool MessageNever; - int DestDirLength; + cmInstallType InstallType = cmInstallType_FILES; + cmInstallMode InstallMode = cmInstallMode::COPY; + bool Optional = false; + bool MessageAlways = false; + bool MessageLazy = false; + bool MessageNever = false; + int DestDirLength = 0; std::string Rename; std::string Manifest; diff --git a/Source/cmForEachCommand.cxx b/Source/cmForEachCommand.cxx index dcb3626..da82675 100644 --- a/Source/cmForEachCommand.cxx +++ b/Source/cmForEachCommand.cxx @@ -460,8 +460,8 @@ bool cmForEachCommand(std::vector<std::string> const& args, // in the `fb->Args` vector. The first item is the iteration variable // name... const std::size_t iter_cnt = 2u + - int(start < stop) * (stop - start) / std::abs(step) + - int(start > stop) * (start - stop) / std::abs(step); + static_cast<int>(start < stop) * (stop - start) / std::abs(step) + + static_cast<int>(start > stop) * (start - stop) / std::abs(step); fb->Args.resize(iter_cnt); fb->Args.front() = args.front(); auto cc = start; diff --git a/Source/cmFortranParser.h b/Source/cmFortranParser.h index 70fe537..542b98c 100644 --- a/Source/cmFortranParser.h +++ b/Source/cmFortranParser.h @@ -123,13 +123,12 @@ struct cmFortranFile : File(file) , Buffer(buffer) , Directory(std::move(dir)) - , LastCharWasNewline(false) { } FILE* File; YY_BUFFER_STATE Buffer; std::string Directory; - bool LastCharWasNewline; + bool LastCharWasNewline = false; }; struct cmFortranCompiler diff --git a/Source/cmGeneratedFileStream.cxx b/Source/cmGeneratedFileStream.cxx index a52e66a..b529b8f 100644 --- a/Source/cmGeneratedFileStream.cxx +++ b/Source/cmGeneratedFileStream.cxx @@ -44,7 +44,8 @@ cmGeneratedFileStream::cmGeneratedFileStream(std::string const& name, #endif if (encoding == codecvt::UTF8_WITH_BOM) { // Write the BOM encoding header into the file - char magic[] = { char(0xEF), char(0xBB), char(0xBF) }; + char magic[] = { static_cast<char>(0xEF), static_cast<char>(0xBB), + static_cast<char>(0xBF) }; this->write(magic, 3); } } diff --git a/Source/cmGeneratorExpression.cxx b/Source/cmGeneratorExpression.cxx index 840f511..f988e54 100644 --- a/Source/cmGeneratorExpression.cxx +++ b/Source/cmGeneratorExpression.cxx @@ -100,11 +100,6 @@ cmCompiledGeneratorExpression::cmCompiledGeneratorExpression( cmListFileBacktrace backtrace, std::string input) : Backtrace(std::move(backtrace)) , Input(std::move(input)) - , EvaluateForBuildsystem(false) - , Quiet(false) - , HadContextSensitiveCondition(false) - , HadHeadSensitiveCondition(false) - , HadLinkLanguageSensitiveCondition(false) { cmGeneratorExpressionLexer l; std::vector<cmGeneratorExpressionToken> tokens = l.Tokenize(this->Input); diff --git a/Source/cmGeneratorExpression.h b/Source/cmGeneratorExpression.h index 03be782..188993f 100644 --- a/Source/cmGeneratorExpression.h +++ b/Source/cmGeneratorExpression.h @@ -161,8 +161,8 @@ private: std::vector<std::unique_ptr<cmGeneratorExpressionEvaluator>> Evaluators; const std::string Input; bool NeedsEvaluation; - bool EvaluateForBuildsystem; - bool Quiet; + bool EvaluateForBuildsystem = false; + bool Quiet = false; mutable std::set<cmGeneratorTarget*> DependTargets; mutable std::set<cmGeneratorTarget const*> AllTargetsSeen; @@ -171,9 +171,9 @@ private: std::map<std::string, std::string>> MaxLanguageStandard; mutable std::string Output; - mutable bool HadContextSensitiveCondition; - mutable bool HadHeadSensitiveCondition; - mutable bool HadLinkLanguageSensitiveCondition; + mutable bool HadContextSensitiveCondition = false; + mutable bool HadHeadSensitiveCondition = false; + mutable bool HadLinkLanguageSensitiveCondition = false; mutable std::set<cmGeneratorTarget const*> SourceSensitiveTargets; }; diff --git a/Source/cmGeneratorExpressionContext.cxx b/Source/cmGeneratorExpressionContext.cxx index 42cbe2a..8076887 100644 --- a/Source/cmGeneratorExpressionContext.cxx +++ b/Source/cmGeneratorExpressionContext.cxx @@ -16,10 +16,6 @@ cmGeneratorExpressionContext::cmGeneratorExpressionContext( , HeadTarget(headTarget) , CurrentTarget(currentTarget) , Quiet(quiet) - , HadError(false) - , HadContextSensitiveCondition(false) - , HadHeadSensitiveCondition(false) - , HadLinkLanguageSensitiveCondition(false) , EvaluateForBuildsystem(evaluateForBuildsystem) { } diff --git a/Source/cmGeneratorExpressionContext.h b/Source/cmGeneratorExpressionContext.h index 22e7463..21e3961 100644 --- a/Source/cmGeneratorExpressionContext.h +++ b/Source/cmGeneratorExpressionContext.h @@ -36,9 +36,9 @@ struct cmGeneratorExpressionContext // directly or indirectly in the property. cmGeneratorTarget const* CurrentTarget; bool Quiet; - bool HadError; - bool HadContextSensitiveCondition; - bool HadHeadSensitiveCondition; - bool HadLinkLanguageSensitiveCondition; + bool HadError = false; + bool HadContextSensitiveCondition = false; + bool HadHeadSensitiveCondition = false; + bool HadLinkLanguageSensitiveCondition = false; bool EvaluateForBuildsystem; }; diff --git a/Source/cmGeneratorExpressionNode.cxx b/Source/cmGeneratorExpressionNode.cxx index 26ffd4b..beb623f 100644 --- a/Source/cmGeneratorExpressionNode.cxx +++ b/Source/cmGeneratorExpressionNode.cxx @@ -413,7 +413,7 @@ static const struct TargetExistsNode : public cmGeneratorExpressionNode return std::string(); } - std::string targetName = parameters.front(); + std::string const& targetName = parameters.front(); if (targetName.empty() || !cmGeneratorExpression::IsValidTargetName(targetName)) { reportError(context, content->GetOriginalExpression(), @@ -445,7 +445,7 @@ static const struct TargetNameIfExistsNode : public cmGeneratorExpressionNode return std::string(); } - std::string targetName = parameters.front(); + std::string const& targetName = parameters.front(); if (targetName.empty() || !cmGeneratorExpression::IsValidTargetName(targetName)) { reportError(context, content->GetOriginalExpression(), @@ -1759,7 +1759,7 @@ static const struct TargetObjectsNode : public cmGeneratorExpressionNode const GeneratorExpressionContent* content, cmGeneratorExpressionDAGChecker* /*dagChecker*/) const override { - std::string tgtName = parameters.front(); + std::string const& tgtName = parameters.front(); cmGeneratorTarget* gt = context->LG->FindGeneratorTargetToUse(tgtName); if (!gt) { std::ostringstream e; @@ -1847,7 +1847,7 @@ static const struct TargetRuntimeDllsNode : public cmGeneratorExpressionNode const GeneratorExpressionContent* content, cmGeneratorExpressionDAGChecker* /*dagChecker*/) const override { - std::string tgtName = parameters.front(); + std::string const& tgtName = parameters.front(); cmGeneratorTarget* gt = context->LG->FindGeneratorTargetToUse(tgtName); if (!gt) { std::ostringstream e; @@ -2396,7 +2396,7 @@ protected: cmGeneratorExpressionDAGChecker* dagChecker) const { // Lookup the referenced target. - std::string name = parameters.front(); + std::string const& name = parameters.front(); if (!cmGeneratorExpression::IsValidTargetName(name)) { ::reportError(context, content->GetOriginalExpression(), diff --git a/Source/cmGeneratorExpressionParser.cxx b/Source/cmGeneratorExpressionParser.cxx index 794c1a1..bbee4d5 100644 --- a/Source/cmGeneratorExpressionParser.cxx +++ b/Source/cmGeneratorExpressionParser.cxx @@ -15,7 +15,6 @@ cmGeneratorExpressionParser::cmGeneratorExpressionParser( std::vector<cmGeneratorExpressionToken> tokens) : Tokens(std::move(tokens)) - , NestingLevel(0) { } diff --git a/Source/cmGeneratorExpressionParser.h b/Source/cmGeneratorExpressionParser.h index efaef3e..63273e4 100644 --- a/Source/cmGeneratorExpressionParser.h +++ b/Source/cmGeneratorExpressionParser.h @@ -26,5 +26,5 @@ private: std::vector<cmGeneratorExpressionToken>::const_iterator it; const std::vector<cmGeneratorExpressionToken> Tokens; - unsigned int NestingLevel; + unsigned int NestingLevel = 0; }; diff --git a/Source/cmGeneratorTarget.cxx b/Source/cmGeneratorTarget.cxx index d852b48..8ed7f10 100644 --- a/Source/cmGeneratorTarget.cxx +++ b/Source/cmGeneratorTarget.cxx @@ -335,20 +335,6 @@ EvaluatedTargetPropertyEntries EvaluateTargetPropertyEntries( cmGeneratorTarget::cmGeneratorTarget(cmTarget* t, cmLocalGenerator* lg) : Target(t) - , FortranModuleDirectoryCreated(false) - , SourceFileFlagsConstructed(false) - , PolicyWarnedCMP0022(false) - , PolicyReportedCMP0069(false) - , DebugIncludesDone(false) - , DebugCompileOptionsDone(false) - , DebugCompileFeaturesDone(false) - , DebugCompileDefinitionsDone(false) - , DebugLinkOptionsDone(false) - , DebugLinkDirectoriesDone(false) - , DebugPrecompileHeadersDone(false) - , DebugSourcesDone(false) - , UtilityItemsDone(false) - , SourcesAreContextDependent(Tribool::Indeterminate) { this->Makefile = this->Target->GetMakefile(); this->LocalGenerator = lg; @@ -2775,15 +2761,14 @@ cmGeneratorTarget::LinkClosure const* cmGeneratorTarget::GetLinkClosure( class cmTargetSelectLinker { - int Preference; + int Preference = 0; cmGeneratorTarget const* Target; cmGlobalGenerator* GG; std::set<std::string> Preferred; public: cmTargetSelectLinker(cmGeneratorTarget const* target) - : Preference(0) - , Target(target) + : Target(target) { this->GG = this->Target->GetLocalGenerator()->GetGlobalGenerator(); } diff --git a/Source/cmGeneratorTarget.h b/Source/cmGeneratorTarget.h index b927848..6bce7d2 100644 --- a/Source/cmGeneratorTarget.h +++ b/Source/cmGeneratorTarget.h @@ -881,7 +881,7 @@ private: std::string CreateFortranModuleDirectory( std::string const& working_dir) const; - mutable bool FortranModuleDirectoryCreated; + mutable bool FortranModuleDirectoryCreated = false; mutable std::string FortranModuleDirectory; friend class cmTargetTraceDependencies; @@ -906,7 +906,7 @@ private: mutable std::string ExportMacro; void ConstructSourceFileFlags() const; - mutable bool SourceFileFlagsConstructed; + mutable bool SourceFileFlagsConstructed = false; mutable std::map<cmSourceFile const*, SourceFileFlags> SourceFlagsMap; mutable std::map<std::string, bool> DebugCompatiblePropertiesDone; @@ -1143,24 +1143,24 @@ private: mutable OutputNameMapType OutputNameMap; mutable std::set<cmLinkItem> UtilityItems; cmPolicies::PolicyMap PolicyMap; - mutable bool PolicyWarnedCMP0022; - mutable bool PolicyReportedCMP0069; - mutable bool DebugIncludesDone; - mutable bool DebugCompileOptionsDone; - mutable bool DebugCompileFeaturesDone; - mutable bool DebugCompileDefinitionsDone; - mutable bool DebugLinkOptionsDone; - mutable bool DebugLinkDirectoriesDone; - mutable bool DebugPrecompileHeadersDone; - mutable bool DebugSourcesDone; - mutable bool UtilityItemsDone; + mutable bool PolicyWarnedCMP0022 = false; + mutable bool PolicyReportedCMP0069 = false; + mutable bool DebugIncludesDone = false; + mutable bool DebugCompileOptionsDone = false; + mutable bool DebugCompileFeaturesDone = false; + mutable bool DebugCompileDefinitionsDone = false; + mutable bool DebugLinkOptionsDone = false; + mutable bool DebugLinkDirectoriesDone = false; + mutable bool DebugPrecompileHeadersDone = false; + mutable bool DebugSourcesDone = false; + mutable bool UtilityItemsDone = false; enum class Tribool { False = 0x0, True = 0x1, Indeterminate = 0x2 }; - mutable Tribool SourcesAreContextDependent; + mutable Tribool SourcesAreContextDependent = Tribool::Indeterminate; bool ComputePDBOutputDir(const std::string& kind, const std::string& config, std::string& out) const; diff --git a/Source/cmGetPropertyCommand.cxx b/Source/cmGetPropertyCommand.cxx index 4a25311..943ce1d 100644 --- a/Source/cmGetPropertyCommand.cxx +++ b/Source/cmGetPropertyCommand.cxx @@ -71,7 +71,7 @@ bool cmGetPropertyCommand(std::vector<std::string> const& args, } // The cmake variable in which to store the result. - const std::string variable = args[0]; + std::string const& variable = args[0]; std::string name; std::string propertyName; diff --git a/Source/cmGlobalGenerator.cxx b/Source/cmGlobalGenerator.cxx index 3831546..4d636e4 100644 --- a/Source/cmGlobalGenerator.cxx +++ b/Source/cmGlobalGenerator.cxx @@ -1152,7 +1152,10 @@ std::string cmGlobalGenerator::GetLanguageFromExtension(const char* ext) const { // if there is an extension and it starts with . then move past the // . because the extensions are not stored with a . in the map - if (ext && *ext == '.') { + if (!ext) { + return ""; + } + if (*ext == '.') { ++ext; } auto const it = this->ExtensionToLanguage.find(ext); diff --git a/Source/cmGraphVizWriter.cxx b/Source/cmGraphVizWriter.cxx index ab18e2a..2bb438d 100644 --- a/Source/cmGraphVizWriter.cxx +++ b/Source/cmGraphVizWriter.cxx @@ -109,18 +109,6 @@ cmGraphVizWriter::cmGraphVizWriter(std::string const& fileName, , GraphHeader("node [\n fontsize = \"12\"\n];") , GraphNodePrefix("node") , GlobalGenerator(globalGenerator) - , NextNodeId(0) - , GenerateForExecutables(true) - , GenerateForStaticLibs(true) - , GenerateForSharedLibs(true) - , GenerateForModuleLibs(true) - , GenerateForInterfaceLibs(true) - , GenerateForObjectLibs(true) - , GenerateForUnknownLibs(true) - , GenerateForCustomTargets(false) - , GenerateForExternals(true) - , GeneratePerTarget(true) - , GenerateDependers(true) { } diff --git a/Source/cmGraphVizWriter.h b/Source/cmGraphVizWriter.h index 0912fc8..24dbe52 100644 --- a/Source/cmGraphVizWriter.h +++ b/Source/cmGraphVizWriter.h @@ -119,19 +119,19 @@ private: cmGlobalGenerator const* GlobalGenerator; - int NextNodeId; + int NextNodeId = 0; // maps from the actual item names to node names in dot: std::map<std::string, std::string> NodeNames; - bool GenerateForExecutables; - bool GenerateForStaticLibs; - bool GenerateForSharedLibs; - bool GenerateForModuleLibs; - bool GenerateForInterfaceLibs; - bool GenerateForObjectLibs; - bool GenerateForUnknownLibs; - bool GenerateForCustomTargets; - bool GenerateForExternals; - bool GeneratePerTarget; - bool GenerateDependers; + bool GenerateForExecutables = true; + bool GenerateForStaticLibs = true; + bool GenerateForSharedLibs = true; + bool GenerateForModuleLibs = true; + bool GenerateForInterfaceLibs = true; + bool GenerateForObjectLibs = true; + bool GenerateForUnknownLibs = true; + bool GenerateForCustomTargets = false; + bool GenerateForExternals = true; + bool GeneratePerTarget = true; + bool GenerateDependers = true; }; diff --git a/Source/cmInstallDirectoryGenerator.cxx b/Source/cmInstallDirectoryGenerator.cxx index 8462b99..d358763 100644 --- a/Source/cmInstallDirectoryGenerator.cxx +++ b/Source/cmInstallDirectoryGenerator.cxx @@ -20,7 +20,6 @@ cmInstallDirectoryGenerator::cmInstallDirectoryGenerator( bool optional, cmListFileBacktrace backtrace) : cmInstallGenerator(dest, configurations, component, message, exclude_from_all, false, std::move(backtrace)) - , LocalGenerator(nullptr) , Directories(dirs) , FilePermissions(std::move(file_permissions)) , DirPermissions(std::move(dir_permissions)) diff --git a/Source/cmInstallDirectoryGenerator.h b/Source/cmInstallDirectoryGenerator.h index 419fd8c..7deb9ba 100644 --- a/Source/cmInstallDirectoryGenerator.h +++ b/Source/cmInstallDirectoryGenerator.h @@ -42,7 +42,7 @@ protected: void AddDirectoryInstallRule(std::ostream& os, const std::string& config, Indent indent, std::vector<std::string> const& dirs); - cmLocalGenerator* LocalGenerator; + cmLocalGenerator* LocalGenerator = nullptr; std::vector<std::string> const Directories; std::string const FilePermissions; std::string const DirPermissions; diff --git a/Source/cmInstallExportGenerator.cxx b/Source/cmInstallExportGenerator.cxx index f1ac656..8a48aa2 100644 --- a/Source/cmInstallExportGenerator.cxx +++ b/Source/cmInstallExportGenerator.cxx @@ -32,7 +32,6 @@ cmInstallExportGenerator::cmInstallExportGenerator( , FileName(std::move(filename)) , Namespace(std::move(name_space)) , ExportOld(exportOld) - , LocalGenerator(nullptr) { if (android) { #ifndef CMAKE_BOOTSTRAP diff --git a/Source/cmInstallExportGenerator.h b/Source/cmInstallExportGenerator.h index dc07d36..02fe1fa 100644 --- a/Source/cmInstallExportGenerator.h +++ b/Source/cmInstallExportGenerator.h @@ -65,7 +65,7 @@ protected: std::string const FileName; std::string const Namespace; bool const ExportOld; - cmLocalGenerator* LocalGenerator; + cmLocalGenerator* LocalGenerator = nullptr; std::string TempDir; std::string MainImportFile; diff --git a/Source/cmInstallFilesGenerator.cxx b/Source/cmInstallFilesGenerator.cxx index 378b9fc..18a852b 100644 --- a/Source/cmInstallFilesGenerator.cxx +++ b/Source/cmInstallFilesGenerator.cxx @@ -19,7 +19,6 @@ cmInstallFilesGenerator::cmInstallFilesGenerator( bool optional, cmListFileBacktrace backtrace) : cmInstallGenerator(dest, configurations, component, message, exclude_from_all, false, std::move(backtrace)) - , LocalGenerator(nullptr) , Files(files) , FilePermissions(std::move(file_permissions)) , Rename(std::move(rename)) diff --git a/Source/cmInstallFilesGenerator.h b/Source/cmInstallFilesGenerator.h index 2276ab8..53076b3 100644 --- a/Source/cmInstallFilesGenerator.h +++ b/Source/cmInstallFilesGenerator.h @@ -44,7 +44,7 @@ protected: Indent indent, std::vector<std::string> const& files); - cmLocalGenerator* LocalGenerator; + cmLocalGenerator* LocalGenerator = nullptr; std::vector<std::string> const Files; std::string const FilePermissions; std::string const Rename; diff --git a/Source/cmInstallScriptGenerator.cxx b/Source/cmInstallScriptGenerator.cxx index bec98b6..a5625fe 100644 --- a/Source/cmInstallScriptGenerator.cxx +++ b/Source/cmInstallScriptGenerator.cxx @@ -20,7 +20,6 @@ cmInstallScriptGenerator::cmInstallScriptGenerator( std::move(backtrace)) , Script(std::move(script)) , Code(code) - , AllowGenex(false) { // We need per-config actions if the script has generator expressions. if (cmGeneratorExpression::Find(this->Script) != std::string::npos) { diff --git a/Source/cmInstallScriptGenerator.h b/Source/cmInstallScriptGenerator.h index 2cf6a4b..c3a7058 100644 --- a/Source/cmInstallScriptGenerator.h +++ b/Source/cmInstallScriptGenerator.h @@ -41,5 +41,5 @@ protected: std::string const Script; bool const Code; cmLocalGenerator* LocalGenerator; - bool AllowGenex; + bool AllowGenex = false; }; diff --git a/Source/cmInstallTargetGenerator.cxx b/Source/cmInstallTargetGenerator.cxx index ae11afc..16c5002 100644 --- a/Source/cmInstallTargetGenerator.cxx +++ b/Source/cmInstallTargetGenerator.cxx @@ -50,7 +50,6 @@ cmInstallTargetGenerator::cmInstallTargetGenerator( : cmInstallGenerator(dest, configurations, component, message, exclude_from_all, false, std::move(backtrace)) , TargetName(std::move(targetName)) - , Target(nullptr) , FilePermissions(std::move(file_permissions)) , ImportLibrary(implib) , Optional(optional) diff --git a/Source/cmInstallTargetGenerator.h b/Source/cmInstallTargetGenerator.h index 6173f2c..3fc4b59 100644 --- a/Source/cmInstallTargetGenerator.h +++ b/Source/cmInstallTargetGenerator.h @@ -118,7 +118,7 @@ protected: void IssueCMP0095Warning(const std::string& unescapedRpath); std::string const TargetName; - cmGeneratorTarget* Target; + cmGeneratorTarget* Target = nullptr; std::string const FilePermissions; NamelinkModeType NamelinkMode; bool const ImportLibrary; diff --git a/Source/cmLinkLineComputer.cxx b/Source/cmLinkLineComputer.cxx index 290642b..b1e9e56 100644 --- a/Source/cmLinkLineComputer.cxx +++ b/Source/cmLinkLineComputer.cxx @@ -18,10 +18,6 @@ cmLinkLineComputer::cmLinkLineComputer(cmOutputConverter* outputConverter, cmStateDirectory const& stateDir) : StateDir(stateDir) , OutputConverter(outputConverter) - , ForResponse(false) - , UseWatcomQuote(false) - , UseNinjaMulti(false) - , Relink(false) { } diff --git a/Source/cmLinkLineComputer.h b/Source/cmLinkLineComputer.h index a1dafc4..9fb222c 100644 --- a/Source/cmLinkLineComputer.h +++ b/Source/cmLinkLineComputer.h @@ -67,8 +67,8 @@ protected: cmStateDirectory StateDir; cmOutputConverter* OutputConverter; - bool ForResponse; - bool UseWatcomQuote; - bool UseNinjaMulti; - bool Relink; + bool ForResponse = false; + bool UseWatcomQuote = false; + bool UseNinjaMulti = false; + bool Relink = false; }; diff --git a/Source/cmListCommand.cxx b/Source/cmListCommand.cxx index 56345df..d412534 100644 --- a/Source/cmListCommand.cxx +++ b/Source/cmListCommand.cxx @@ -229,7 +229,7 @@ bool HandleAppendCommand(std::vector<std::string> const& args, // If `listString` or `args` is empty, no need to append `;`, // then index is going to be `1` and points to the end-of-string ";" auto const offset = - std::string::size_type(listString.empty() || args.empty()); + static_cast<std::string::size_type>(listString.empty() || args.empty()); listString += &";"[offset] + cmJoin(cmMakeRange(args).advance(2), ";"); makefile.AddDefinition(listName, listString); @@ -255,7 +255,7 @@ bool HandlePrependCommand(std::vector<std::string> const& args, // If `listString` or `args` is empty, no need to append `;`, // then `offset` is going to be `1` and points to the end-of-string ";" auto const offset = - std::string::size_type(listString.empty() || args.empty()); + static_cast<std::string::size_type>(listString.empty() || args.empty()); listString.insert(0, cmJoin(cmMakeRange(args).advance(2), ";") + &";"[offset]); @@ -1199,7 +1199,7 @@ bool HandleSortCommand(std::vector<std::string> const& args, const std::string messageHint = "sub-command SORT "; while (argumentIndex < args.size()) { - const std::string option = args[argumentIndex++]; + std::string const& option = args[argumentIndex++]; if (option == "COMPARE") { if (sortCompare != cmStringSorter::Compare::UNINITIALIZED) { std::string error = cmStrCat(messageHint, "option \"", option, @@ -1208,7 +1208,7 @@ bool HandleSortCommand(std::vector<std::string> const& args, return false; } if (argumentIndex < args.size()) { - const std::string argument = args[argumentIndex++]; + std::string const& argument = args[argumentIndex++]; if (argument == "STRING") { sortCompare = cmStringSorter::Compare::STRING; } else if (argument == "FILE_BASENAME") { @@ -1235,7 +1235,7 @@ bool HandleSortCommand(std::vector<std::string> const& args, return false; } if (argumentIndex < args.size()) { - const std::string argument = args[argumentIndex++]; + std::string const& argument = args[argumentIndex++]; if (argument == "SENSITIVE") { sortCaseSensitivity = cmStringSorter::CaseSensitivity::SENSITIVE; } else if (argument == "INSENSITIVE") { @@ -1259,7 +1259,7 @@ bool HandleSortCommand(std::vector<std::string> const& args, return false; } if (argumentIndex < args.size()) { - const std::string argument = args[argumentIndex++]; + std::string const& argument = args[argumentIndex++]; if (argument == "ASCENDING") { sortOrder = cmStringSorter::Order::ASCENDING; } else if (argument == "DESCENDING") { @@ -1346,7 +1346,7 @@ bool HandleSublistCommand(std::vector<std::string> const& args, using size_type = decltype(varArgsExpanded)::size_type; - if (start < 0 || size_type(start) >= varArgsExpanded.size()) { + if (start < 0 || static_cast<size_type>(start) >= varArgsExpanded.size()) { status.SetError(cmStrCat("begin index: ", start, " is out of range 0 - ", varArgsExpanded.size() - 1)); return false; @@ -1357,9 +1357,10 @@ bool HandleSublistCommand(std::vector<std::string> const& args, } const size_type end = - (length == -1 || size_type(start + length) > varArgsExpanded.size()) + (length == -1 || + static_cast<size_type>(start + length) > varArgsExpanded.size()) ? varArgsExpanded.size() - : size_type(start + length); + : static_cast<size_type>(start + length); std::vector<std::string> sublist(varArgsExpanded.begin() + start, varArgsExpanded.begin() + end); status.GetMakefile().AddDefinition(variableName, cmJoin(sublist, ";")); diff --git a/Source/cmListFileCache.cxx b/Source/cmListFileCache.cxx index 5133521..4485ac6 100644 --- a/Source/cmListFileCache.cxx +++ b/Source/cmListFileCache.cxx @@ -36,7 +36,7 @@ struct cmListFileParser cmListFile* ListFile; cmListFileBacktrace Backtrace; cmMessenger* Messenger; - const char* FileName; + const char* FileName = nullptr; cmListFileLexer* Lexer; std::string FunctionName; long FunctionLine; @@ -55,7 +55,6 @@ cmListFileParser::cmListFileParser(cmListFile* lf, cmListFileBacktrace lfbt, : ListFile(lf) , Backtrace(std::move(lfbt)) , Messenger(messenger) - , FileName(nullptr) , Lexer(cmListFileLexer_New()) { } diff --git a/Source/cmListFileCache.h b/Source/cmListFileCache.h index f7c2509..0553989 100644 --- a/Source/cmListFileCache.h +++ b/Source/cmListFileCache.h @@ -110,16 +110,22 @@ public: cm::optional<std::string> DeferId; cmListFileContext() = default; - cmListFileContext(cmListFileContext&& /*other*/) = default; + // This move constructor is marked `noexcept` yet `clang-tidy` 14 reports it + // as being able to throw an exception. Suppress the warning as there doesn't + // seem to be any way for this to happen given the member types. + // NOLINTNEXTLINE(bugprone-exception-escape) + cmListFileContext(cmListFileContext&& /*other*/) noexcept = default; cmListFileContext(const cmListFileContext& /*other*/) = default; cmListFileContext& operator=(const cmListFileContext& /*other*/) = default; #if __cplusplus >= 201703L || (defined(_MSVC_LANG) && _MSVC_LANG >= 201703L) - cmListFileContext& operator=(cmListFileContext&& /*other*/) = default; + cmListFileContext& operator=(cmListFileContext&& /*other*/) noexcept = + default; #else // The move assignment operators for several STL classes did not become // noexcept until C++17, which causes some tools to warn about this move // assignment operator throwing an exception when it shouldn't. - cmListFileContext& operator=(cmListFileContext&& /*other*/) = delete; + cmListFileContext& operator=(cmListFileContext&& /*other*/) noexcept = + delete; #endif cmListFileContext(std::string name, std::string filePath, long line) diff --git a/Source/cmLoadCacheCommand.cxx b/Source/cmLoadCacheCommand.cxx index d49e711..9981c05 100644 --- a/Source/cmLoadCacheCommand.cxx +++ b/Source/cmLoadCacheCommand.cxx @@ -106,7 +106,7 @@ static bool ReadWithPrefix(std::vector<std::string> const& args, } // Prepare the table of variables to read. - std::string const prefix = args[2]; + std::string const& prefix = args[2]; std::set<std::string> const variablesToRead(args.begin() + 3, args.end()); // Read the cache file. diff --git a/Source/cmMakefile.cxx b/Source/cmMakefile.cxx index 91d7ac5..b5df459 100644 --- a/Source/cmMakefile.cxx +++ b/Source/cmMakefile.cxx @@ -478,8 +478,8 @@ public: private: cmMakefile* Makefile; bool NoPolicyScope; - bool CheckCMP0011; - bool ReportError; + bool CheckCMP0011 = false; + bool ReportError = true; void EnforceCMP0011(); }; @@ -488,8 +488,6 @@ cmMakefile::IncludeScope::IncludeScope(cmMakefile* mf, bool noPolicyScope) : Makefile(mf) , NoPolicyScope(noPolicyScope) - , CheckCMP0011(false) - , ReportError(true) { this->Makefile->Backtrace = this->Makefile->Backtrace.Push( cmListFileContext::FromListFilePath(filenametoread)); @@ -623,7 +621,6 @@ class cmMakefile::ListFileScope public: ListFileScope(cmMakefile* mf, std::string const& filenametoread) : Makefile(mf) - , ReportError(true) { this->Makefile->Backtrace = this->Makefile->Backtrace.Push( cmListFileContext::FromListFilePath(filenametoread)); @@ -650,7 +647,7 @@ public: private: cmMakefile* Makefile; - bool ReportError; + bool ReportError = true; }; class cmMakefile::DeferScope @@ -1536,7 +1533,6 @@ class cmMakefile::BuildsystemFileScope public: BuildsystemFileScope(cmMakefile* mf) : Makefile(mf) - , ReportError(true) { std::string currentStart = cmStrCat(this->Makefile->StateSnapshot.GetDirectory().GetCurrentSource(), @@ -1578,7 +1574,7 @@ private: cmGlobalGenerator* GG; cmMakefile* CurrentMakefile; cmStateSnapshot Snapshot; - bool ReportError; + bool ReportError = true; }; void cmMakefile::Configure() @@ -4511,7 +4507,7 @@ void cmMakefile::RecordPolicies(cmPolicies::PolicyMap& pm) const /* Record the setting of every policy. */ using PolicyID = cmPolicies::PolicyID; for (PolicyID pid = cmPolicies::CMP0000; pid != cmPolicies::CMPCOUNT; - pid = PolicyID(pid + 1)) { + pid = static_cast<PolicyID>(pid + 1)) { pm.Set(pid, this->GetPolicyStatus(pid)); } } @@ -4538,7 +4534,6 @@ cmMakefile::FunctionPushPop::FunctionPushPop(cmMakefile* mf, const std::string& fileName, cmPolicies::PolicyMap const& pm) : Makefile(mf) - , ReportError(true) { this->Makefile->PushFunctionScope(fileName, pm); } @@ -4552,7 +4547,6 @@ cmMakefile::MacroPushPop::MacroPushPop(cmMakefile* mf, const std::string& fileName, const cmPolicies::PolicyMap& pm) : Makefile(mf) - , ReportError(true) { this->Makefile->PushMacroScope(fileName, pm); } diff --git a/Source/cmMakefile.h b/Source/cmMakefile.h index c8e1e83..e7b9716 100644 --- a/Source/cmMakefile.h +++ b/Source/cmMakefile.h @@ -833,7 +833,7 @@ public: private: cmMakefile* Makefile; - bool ReportError; + bool ReportError = true; }; class MacroPushPop @@ -850,7 +850,7 @@ public: private: cmMakefile* Makefile; - bool ReportError; + bool ReportError = true; }; void PushFunctionScope(std::string const& fileName, diff --git a/Source/cmMakefileLibraryTargetGenerator.cxx b/Source/cmMakefileLibraryTargetGenerator.cxx index 66031db..21b91e0 100644 --- a/Source/cmMakefileLibraryTargetGenerator.cxx +++ b/Source/cmMakefileLibraryTargetGenerator.cxx @@ -929,7 +929,9 @@ void cmMakefileLibraryTargetGenerator::WriteLibraryRules( } // Compute the list of outputs. - std::vector<std::string> outputs(1, targetFullPathReal); + std::vector<std::string> outputs; + outputs.reserve(3); + outputs.push_back(targetFullPathReal); if (this->TargetNames.SharedObject != this->TargetNames.Real) { outputs.push_back(targetFullPathSO); } diff --git a/Source/cmMakefileProfilingData.cxx b/Source/cmMakefileProfilingData.cxx index 337f78b..1cd97c9 100644 --- a/Source/cmMakefileProfilingData.cxx +++ b/Source/cmMakefileProfilingData.cxx @@ -60,7 +60,7 @@ void cmMakefileProfilingData::StartEntry(const cmListFileFunction& lff, v["ph"] = "B"; v["name"] = lff.LowerCaseName(); v["cat"] = "cmake"; - v["ts"] = Json::Value::UInt64( + v["ts"] = static_cast<Json::Value::UInt64>( std::chrono::duration_cast<std::chrono::microseconds>( std::chrono::steady_clock::now().time_since_epoch()) .count()); @@ -98,7 +98,7 @@ void cmMakefileProfilingData::StopEntry() cmsys::SystemInformation info; Json::Value v; v["ph"] = "E"; - v["ts"] = Json::Value::UInt64( + v["ts"] = static_cast<Json::Value::UInt64>( std::chrono::duration_cast<std::chrono::microseconds>( std::chrono::steady_clock::now().time_since_epoch()) .count()); diff --git a/Source/cmMathCommand.cxx b/Source/cmMathCommand.cxx index df9ebcf..1c0ff13 100644 --- a/Source/cmMathCommand.cxx +++ b/Source/cmMathCommand.cxx @@ -57,10 +57,10 @@ bool HandleExprCommand(std::vector<std::string> const& args, if (argumentIndex < args.size()) { const std::string messageHint = "sub-command EXPR "; - const std::string option = args[argumentIndex++]; + std::string const& option = args[argumentIndex++]; if (option == "OUTPUT_FORMAT") { if (argumentIndex < args.size()) { - const std::string argument = args[argumentIndex++]; + std::string const& argument = args[argumentIndex++]; if (argument == "DECIMAL") { outputFormat = NumericFormat::DECIMAL; } else if (argument == "HEXADECIMAL") { diff --git a/Source/cmOSXBundleGenerator.cxx b/Source/cmOSXBundleGenerator.cxx index 7eea4b2..674735b 100644 --- a/Source/cmOSXBundleGenerator.cxx +++ b/Source/cmOSXBundleGenerator.cxx @@ -18,7 +18,6 @@ cmOSXBundleGenerator::cmOSXBundleGenerator(cmGeneratorTarget* target) : GT(target) , Makefile(target->Target->GetMakefile()) , LocalGenerator(target->GetLocalGenerator()) - , MacContentFolders(nullptr) { if (this->MustSkip()) { return; diff --git a/Source/cmOSXBundleGenerator.h b/Source/cmOSXBundleGenerator.h index a3b6f98..c33b087 100644 --- a/Source/cmOSXBundleGenerator.h +++ b/Source/cmOSXBundleGenerator.h @@ -65,5 +65,5 @@ private: cmGeneratorTarget* GT; cmMakefile* Makefile; cmLocalGenerator* LocalGenerator; - std::set<std::string>* MacContentFolders; + std::set<std::string>* MacContentFolders = nullptr; }; diff --git a/Source/cmOutputConverter.cxx b/Source/cmOutputConverter.cxx index e62e0cd..6883535 100644 --- a/Source/cmOutputConverter.cxx +++ b/Source/cmOutputConverter.cxx @@ -29,7 +29,6 @@ bool PathEqOrSubDir(std::string const& a, std::string const& b) cmOutputConverter::cmOutputConverter(cmStateSnapshot const& snapshot) : StateSnapshot(snapshot) - , LinkScriptShell(false) { assert(this->StateSnapshot.IsValid()); this->ComputeRelativePathTopSource(); diff --git a/Source/cmOutputConverter.h b/Source/cmOutputConverter.h index d19bccc..6e1bfe3 100644 --- a/Source/cmOutputConverter.h +++ b/Source/cmOutputConverter.h @@ -138,7 +138,7 @@ private: static bool Shell_ArgumentNeedsQuotes(cm::string_view in, int flags); static std::string Shell_GetArgument(cm::string_view in, int flags); - bool LinkScriptShell; + bool LinkScriptShell = false; // The top-most directories for relative path conversion. Both the // source and destination location of a relative path conversion diff --git a/Source/cmPolicies.cxx b/Source/cmPolicies.cxx index e31de1c..03ae44e 100644 --- a/Source/cmPolicies.cxx +++ b/Source/cmPolicies.cxx @@ -43,7 +43,7 @@ static bool stringToId(const char* input, cmPolicies::PolicyID& pid) if (id >= cmPolicies::CMPCOUNT) { return false; } - pid = cmPolicies::PolicyID(id); + pid = static_cast<cmPolicies::PolicyID>(id); return true; } @@ -279,7 +279,7 @@ bool cmPolicies::ApplyPolicyVersion(cmMakefile* mf, unsigned int majorVer, // now loop over all the policies and set them as appropriate std::vector<cmPolicies::PolicyID> ancientPolicies; for (PolicyID pid = cmPolicies::CMP0000; pid != cmPolicies::CMPCOUNT; - pid = PolicyID(pid + 1)) { + pid = static_cast<PolicyID>(pid + 1)) { if (isPolicyNewerThan(pid, majorVer, minorVer, patchVer)) { if (cmPolicies::GetPolicyStatus(pid) == cmPolicies::REQUIRED_ALWAYS) { ancientPolicies.push_back(pid); diff --git a/Source/cmProcessTools.cxx b/Source/cmProcessTools.cxx index 9ebf5b7..9e7854b 100644 --- a/Source/cmProcessTools.cxx +++ b/Source/cmProcessTools.cxx @@ -21,12 +21,12 @@ void cmProcessTools::RunProcess(struct cmsysProcess_s* cp, OutputParser* out, (p = cmsysProcess_WaitForData(cp, &data, &length, nullptr))) { if (out && p == cmsysProcess_Pipe_STDOUT) { processOutput.DecodeText(data, length, strdata, 1); - if (!out->Process(strdata.c_str(), int(strdata.size()))) { + if (!out->Process(strdata.c_str(), static_cast<int>(strdata.size()))) { out = nullptr; } } else if (err && p == cmsysProcess_Pipe_STDERR) { processOutput.DecodeText(data, length, strdata, 2); - if (!err->Process(strdata.c_str(), int(strdata.size()))) { + if (!err->Process(strdata.c_str(), static_cast<int>(strdata.size()))) { err = nullptr; } } @@ -34,13 +34,13 @@ void cmProcessTools::RunProcess(struct cmsysProcess_s* cp, OutputParser* out, if (out) { processOutput.DecodeText(std::string(), strdata, 1); if (!strdata.empty()) { - out->Process(strdata.c_str(), int(strdata.size())); + out->Process(strdata.c_str(), static_cast<int>(strdata.size())); } } if (err) { processOutput.DecodeText(std::string(), strdata, 2); if (!strdata.empty()) { - err->Process(strdata.c_str(), int(strdata.size())); + err->Process(strdata.c_str(), static_cast<int>(strdata.size())); } } cmsysProcess_WaitForExit(cp, nullptr); diff --git a/Source/cmProjectCommand.cxx b/Source/cmProjectCommand.cxx index 04d99c9..4b65fb9 100644 --- a/Source/cmProjectCommand.cxx +++ b/Source/cmProjectCommand.cxx @@ -242,9 +242,9 @@ bool cmProjectCommand(std::vector<std::string> const& args, const int vc = std::sscanf(version.c_str(), "%u.%u.%u.%u", &v[0], &v[1], &v[2], &v[3]); for (auto i = 0u; i < MAX_VERSION_COMPONENTS; ++i) { - if (int(i) < vc) { + if (static_cast<int>(i) < vc) { std::snprintf(vb[i], maxIntLength, "%u", v[i]); - version_string += &"."[std::size_t(i == 0)]; + version_string += &"."[static_cast<std::size_t>(i == 0)]; version_string += vb[i]; version_components[i] = vb[i]; } else { diff --git a/Source/cmRST.cxx b/Source/cmRST.cxx index 1e4dedd..fa9d4cc 100644 --- a/Source/cmRST.cxx +++ b/Source/cmRST.cxx @@ -19,11 +19,6 @@ cmRST::cmRST(std::ostream& os, std::string docroot) : OS(os) , DocRoot(std::move(docroot)) - , IncludeDepth(0) - , OutputLinePending(false) - , LastLineEndedInColonColon(false) - , Markup(MarkupNone) - , Directive(DirectiveNone) , CMakeDirective("^.. (cmake:)?(" "command|envvar|genex|variable" ")::[ \t]+([^ \t\n]+)$") diff --git a/Source/cmRST.h b/Source/cmRST.h index 156b20a..ea4ef22 100644 --- a/Source/cmRST.h +++ b/Source/cmRST.h @@ -69,11 +69,11 @@ private: std::ostream& OS; std::string DocRoot; - int IncludeDepth; - bool OutputLinePending; - bool LastLineEndedInColonColon; - MarkupType Markup; - DirectiveType Directive; + int IncludeDepth = 0; + bool OutputLinePending = false; + bool LastLineEndedInColonColon = false; + MarkupType Markup = MarkupNone; + DirectiveType Directive = DirectiveNone; cmsys::RegularExpression CMakeDirective; cmsys::RegularExpression CMakeModuleDirective; cmsys::RegularExpression ParsedLiteralDirective; diff --git a/Source/cmScriptGenerator.cxx b/Source/cmScriptGenerator.cxx index 437b938..166ee56 100644 --- a/Source/cmScriptGenerator.cxx +++ b/Source/cmScriptGenerator.cxx @@ -12,8 +12,6 @@ cmScriptGenerator::cmScriptGenerator(std::string config_var, std::vector<std::string> configurations) : RuntimeConfigVariable(std::move(config_var)) , Configurations(std::move(configurations)) - , ConfigurationTypes(nullptr) - , ActionsPerConfig(false) { } diff --git a/Source/cmScriptGenerator.h b/Source/cmScriptGenerator.h index 46d794c..3d7b350 100644 --- a/Source/cmScriptGenerator.h +++ b/Source/cmScriptGenerator.h @@ -78,12 +78,12 @@ protected: // Information used during generation. std::string ConfigurationName; - std::vector<std::string> const* ConfigurationTypes; + std::vector<std::string> const* ConfigurationTypes = nullptr; // True if the subclass needs to generate an explicit rule for each // configuration. False if the subclass only generates one rule for // all enabled configurations. - bool ActionsPerConfig; + bool ActionsPerConfig = false; private: void GenerateScriptActionsOnce(std::ostream& os, Indent indent); diff --git a/Source/cmSystemTools.cxx b/Source/cmSystemTools.cxx index 527175d..512a5fa 100644 --- a/Source/cmSystemTools.cxx +++ b/Source/cmSystemTools.cxx @@ -1995,7 +1995,7 @@ int cmSystemTools::WaitForLine(cmsysProcess* process, std::string& line, --length; } if (length > 0) { - line.append(&out[0], length); + line.append(out.data(), length); } out.erase(out.begin(), outiter + 1); return cmsysProcess_Pipe_STDOUT; @@ -2013,7 +2013,7 @@ int cmSystemTools::WaitForLine(cmsysProcess* process, std::string& line, --length; } if (length > 0) { - line.append(&err[0], length); + line.append(err.data(), length); } err.erase(err.begin(), erriter + 1); return cmsysProcess_Pipe_STDERR; @@ -2057,12 +2057,12 @@ int cmSystemTools::WaitForLine(cmsysProcess* process, std::string& line, erriter = err.begin() + size; } if (!out.empty()) { - line.append(&out[0], outiter - out.begin()); + line.append(out.data(), outiter - out.begin()); out.erase(out.begin(), out.end()); return cmsysProcess_Pipe_STDOUT; } if (!err.empty()) { - line.append(&err[0], erriter - err.begin()); + line.append(err.data(), erriter - err.begin()); err.erase(err.begin(), err.end()); return cmsysProcess_Pipe_STDERR; } @@ -3149,7 +3149,7 @@ static cm::optional<bool> RemoveRPathELF(std::string const& file, } return false; } - if (!f.write(&bytes[0], bytes.size())) { + if (!f.write(bytes.data(), bytes.size())) { if (emsg) { *emsg = "Error replacing DYNAMIC table header."; } diff --git a/Source/cmTargetDepend.h b/Source/cmTargetDepend.h index 9027409..4ff5eb4 100644 --- a/Source/cmTargetDepend.h +++ b/Source/cmTargetDepend.h @@ -18,17 +18,14 @@ class cmTargetDepend // The set order depends only on the Target, so we use // mutable members to achieve a map with set syntax. - mutable bool Link; - mutable bool Util; - mutable bool Cross; + mutable bool Link = false; + mutable bool Util = false; + mutable bool Cross = false; mutable cmListFileBacktrace Backtrace; public: cmTargetDepend(cmGeneratorTarget const* t) : Target(t) - , Link(false) - , Util(false) - , Cross(false) { } operator cmGeneratorTarget const*() const { return this->Target; } diff --git a/Source/cmTargetIncludeDirectoriesCommand.cxx b/Source/cmTargetIncludeDirectoriesCommand.cxx index f31501e..b4b4319 100644 --- a/Source/cmTargetIncludeDirectoriesCommand.cxx +++ b/Source/cmTargetIncludeDirectoriesCommand.cxx @@ -99,7 +99,7 @@ bool cmTargetIncludeDirectoriesCommand(std::vector<std::string> const& args, { return TargetIncludeDirectoriesImpl(status).HandleArguments( args, "INCLUDE_DIRECTORIES", - TargetIncludeDirectoriesImpl::ArgumentFlags( + static_cast<TargetIncludeDirectoriesImpl::ArgumentFlags>( TargetIncludeDirectoriesImpl::PROCESS_BEFORE | TargetIncludeDirectoriesImpl::PROCESS_AFTER | TargetIncludeDirectoriesImpl::PROCESS_SYSTEM)); diff --git a/Source/cmTest.cxx b/Source/cmTest.cxx index 7c0f9e7..e6ed01b 100644 --- a/Source/cmTest.cxx +++ b/Source/cmTest.cxx @@ -8,8 +8,7 @@ #include "cmValue.h" cmTest::cmTest(cmMakefile* mf) - : CommandExpandLists(false) - , Backtrace(mf->GetBacktrace()) + : Backtrace(mf->GetBacktrace()) { this->Makefile = mf; this->OldStyle = true; diff --git a/Source/cmTest.h b/Source/cmTest.h index 85978da..1c14310 100644 --- a/Source/cmTest.h +++ b/Source/cmTest.h @@ -64,7 +64,7 @@ private: cmPropertyMap Properties; std::string Name; std::vector<std::string> Command; - bool CommandExpandLists; + bool CommandExpandLists = false; bool OldStyle; diff --git a/Source/cmTimestamp.cxx b/Source/cmTimestamp.cxx index e2b6c20..677fdb6 100644 --- a/Source/cmTimestamp.cxx +++ b/Source/cmTimestamp.cxx @@ -50,7 +50,7 @@ std::string cmTimestamp::CurrentTime(const std::string& formatString, // SOURCE_DATE_EPOCH has only a resolution in the seconds range microseconds = 0; } - if (currentTimeT == time_t(-1)) { + if (currentTimeT == static_cast<time_t>(-1)) { return std::string(); } diff --git a/Source/cmTransformDepfile.cxx b/Source/cmTransformDepfile.cxx index 81a6507..12c121f 100644 --- a/Source/cmTransformDepfile.cxx +++ b/Source/cmTransformDepfile.cxx @@ -89,7 +89,9 @@ void WriteMSBuildAdditionalInputs(cmsys::ofstream& fout, } // Write a UTF-8 BOM so MSBuild knows the encoding when reading the file. - static const char utf8bom[] = { char(0xEF), char(0xBB), char(0xBF) }; + static const char utf8bom[] = { static_cast<char>(0xEF), + static_cast<char>(0xBB), + static_cast<char>(0xBF) }; fout.write(utf8bom, sizeof(utf8bom)); // Write the format expected by MSBuild CustomBuild AdditionalInputs. diff --git a/Source/cmUuid.cxx b/Source/cmUuid.cxx index 2513303..6688668 100644 --- a/Source/cmUuid.cxx +++ b/Source/cmUuid.cxx @@ -17,10 +17,10 @@ std::string cmUuid::FromMd5(std::vector<unsigned char> const& uuidNamespace, cmCryptoHash md5(cmCryptoHash::AlgoMD5); md5.Initialize(); - md5.Append(&hashInput[0], hashInput.size()); + md5.Append(hashInput.data(), hashInput.size()); std::vector<unsigned char> digest = md5.Finalize(); - return this->FromDigest(&digest[0], 3); + return this->FromDigest(digest.data(), 3); } std::string cmUuid::FromSha1(std::vector<unsigned char> const& uuidNamespace, @@ -31,10 +31,10 @@ std::string cmUuid::FromSha1(std::vector<unsigned char> const& uuidNamespace, cmCryptoHash sha1(cmCryptoHash::AlgoSHA1); sha1.Initialize(); - sha1.Append(&hashInput[0], hashInput.size()); + sha1.Append(hashInput.data(), hashInput.size()); std::vector<unsigned char> digest = sha1.Finalize(); - return this->FromDigest(&digest[0], 5); + return this->FromDigest(digest.data(), 5); } void cmUuid::CreateHashInput(std::vector<unsigned char> const& uuidNamespace, @@ -46,7 +46,7 @@ void cmUuid::CreateHashInput(std::vector<unsigned char> const& uuidNamespace, if (!name.empty()) { output.resize(output.size() + name.size()); - memcpy(&output[0] + uuidNamespace.size(), name.c_str(), name.size()); + memcpy(output.data() + uuidNamespace.size(), name.c_str(), name.size()); } } @@ -59,7 +59,7 @@ std::string cmUuid::FromDigest(const unsigned char* digest, memcpy(uuid, digest, 16); uuid[6] &= 0xF; - uuid[6] |= byte_t(version << 4); + uuid[6] |= static_cast<byte_t>(version << 4); uuid[8] &= 0x3F; uuid[8] |= 0x80; @@ -118,7 +118,8 @@ std::string cmUuid::ByteToHex(unsigned char byte) const for (int i = 0; i < 2; ++i) { unsigned char rest = byte % 16; byte /= 16; - char c = (rest < 0xA) ? char('0' + rest) : char('a' + (rest - 0xA)); + char c = (rest < 0xA) ? static_cast<char>('0' + rest) + : static_cast<char>('a' + (rest - 0xA)); result.at(1 - i) = c; } @@ -143,7 +144,7 @@ bool cmUuid::StringToBinaryImpl(std::string const& input, return false; } - output.push_back(char(c1 << 4 | c2)); + output.push_back(static_cast<char>(c1 << 4 | c2)); } return true; @@ -152,15 +153,15 @@ bool cmUuid::StringToBinaryImpl(std::string const& input, bool cmUuid::IntFromHexDigit(char input, char& output) const { if (input >= '0' && input <= '9') { - output = char(input - '0'); + output = static_cast<char>(input - '0'); return true; } if (input >= 'a' && input <= 'f') { - output = char(input - 'a' + 0xA); + output = static_cast<char>(input - 'a' + 0xA); return true; } if (input >= 'A' && input <= 'F') { - output = char(input - 'A' + 0xA); + output = static_cast<char>(input - 'A' + 0xA); return true; } return false; diff --git a/Source/cmXMLWriter.cxx b/Source/cmXMLWriter.cxx index 0811bd0..e4ad9b4 100644 --- a/Source/cmXMLWriter.cxx +++ b/Source/cmXMLWriter.cxx @@ -10,10 +10,6 @@ cmXMLWriter::cmXMLWriter(std::ostream& output, std::size_t level) : Output(output) , IndentationElement(1, '\t') , Level(level) - , Indent(0) - , ElementOpen(false) - , BreakAttrib(false) - , IsContent(false) { } diff --git a/Source/cmXMLWriter.h b/Source/cmXMLWriter.h index 6e8eeb7..49fc864 100644 --- a/Source/cmXMLWriter.h +++ b/Source/cmXMLWriter.h @@ -124,10 +124,10 @@ private: std::stack<std::string, std::vector<std::string>> Elements; std::string IndentationElement; std::size_t Level; - std::size_t Indent; - bool ElementOpen; - bool BreakAttrib; - bool IsContent; + std::size_t Indent = 0; + bool ElementOpen = false; + bool BreakAttrib = false; + bool IsContent = false; }; class cmXMLElement; // IWYU pragma: keep diff --git a/Source/cmake.cxx b/Source/cmake.cxx index 6d99a3c..d9ae75a 100644 --- a/Source/cmake.cxx +++ b/Source/cmake.cxx @@ -2551,7 +2551,7 @@ void cmake::AddCacheEntry(const std::string& key, cmValue value, const char* helpString, int type) { this->State->AddCacheEntry(key, value, helpString, - cmStateEnums::CacheEntryType(type)); + static_cast<cmStateEnums::CacheEntryType>(type)); this->UnwatchUnusedCli(key); if (key == "CMAKE_WARN_DEPRECATED"_s) { diff --git a/Source/cmakemain.cxx b/Source/cmakemain.cxx index 19b922b..97c275e 100644 --- a/Source/cmakemain.cxx +++ b/Source/cmakemain.cxx @@ -409,7 +409,7 @@ int extract_job_number(std::string const& command, } else if (numJobs > INT_MAX) { std::cerr << "The <jobs> value is too large.\n\n"; } else { - jobs = int(numJobs); + jobs = static_cast<int>(numJobs); } } else { std::cerr << "'" << command << "' invalid number '" << jobString @@ -594,7 +594,7 @@ int do_build(int ac, char const* const* av) "is too large.\n\n"; dir.clear(); } else { - jobs = int(numJobs); + jobs = static_cast<int>(numJobs); } } else { std::cerr << "'CMAKE_BUILD_PARALLEL_LEVEL' environment variable\n" diff --git a/Source/cmcmd.cxx b/Source/cmcmd.cxx index df740c9..9ab39f1 100644 --- a/Source/cmcmd.cxx +++ b/Source/cmcmd.cxx @@ -2069,8 +2069,8 @@ class cmVSLink { int Type; bool Verbose; - bool Incremental; - bool LinkGeneratesManifest; + bool Incremental = false; + bool LinkGeneratesManifest = true; std::vector<std::string> LinkCommand; std::vector<std::string> UserManifests; std::string LinkerManifestFile; @@ -2085,8 +2085,6 @@ public: cmVSLink(int type, bool verbose) : Type(type) , Verbose(verbose) - , Incremental(false) - , LinkGeneratesManifest(true) { } bool Parse(std::vector<std::string>::const_iterator argBeg, diff --git a/Tests/CMakeLib/run_compile_commands.cxx b/Tests/CMakeLib/run_compile_commands.cxx index 0ebe00e..0585774 100644 --- a/Tests/CMakeLib/run_compile_commands.cxx +++ b/Tests/CMakeLib/run_compile_commands.cxx @@ -115,7 +115,7 @@ private: void Next() { - this->C = char(this->Input.get()); + this->C = static_cast<char>(this->Input.get()); if (this->Input.bad()) { this->ErrorExit("Unexpected end of file."); } diff --git a/Tests/RunCMake/CTestResourceAllocation/ctresalloc.cxx b/Tests/RunCMake/CTestResourceAllocation/ctresalloc.cxx index daf8a2d..5c6c8d8 100644 --- a/Tests/RunCMake/CTestResourceAllocation/ctresalloc.cxx +++ b/Tests/RunCMake/CTestResourceAllocation/ctresalloc.cxx @@ -89,7 +89,8 @@ static int doWrite(int argc, char const* const* argv) return 1; } int resourceGroupCount = std::atoi(resourceGroupCountEnv); - if (resourceGroups.size() != std::size_t(resourceGroupCount)) { + if (resourceGroups.size() != + static_cast<std::size_t>(resourceGroupCount)) { std::cout << "CTEST_RESOURCE_GROUP_COUNT does not match expected resource groups" << std::endl diff --git a/Tests/RunCMake/FindPkgConfig/FindPkgConfig_IMPORTED_TARGET.cmake b/Tests/RunCMake/FindPkgConfig/FindPkgConfig_IMPORTED_TARGET.cmake index d697fc6..04286cc 100644 --- a/Tests/RunCMake/FindPkgConfig/FindPkgConfig_IMPORTED_TARGET.cmake +++ b/Tests/RunCMake/FindPkgConfig/FindPkgConfig_IMPORTED_TARGET.cmake @@ -1,40 +1,59 @@ -cmake_minimum_required(VERSION 3.12) +cmake_minimum_required(VERSION 3.17) project(FindPkgConfig_IMPORTED_TARGET C) -find_package(PkgConfig REQUIRED) -pkg_check_modules(NCURSES IMPORTED_TARGET QUIET ncurses) +set(shared_lib_prefix "") +set(shared_lib_suffix ".lib") +set(static_lib_prefix "lib") +set(static_lib_suffix ".a") -message(STATUS "source: ${CMAKE_CURRENT_SOURCE_DIR} bin ${CMAKE_CURRENT_BINARY_DIR}") +set(CMAKE_SHARED_LIBRARY_PREFIX ${shared_lib_prefix}) +set(CMAKE_SHARED_LIBRARY_SUFFIX ${shared_lib_suffix}) +set(CMAKE_STATIC_LIBRARY_PREFIX ${static_lib_prefix}) +set(CMAKE_STATIC_LIBRARY_SUFFIX ${static_lib_suffix}) -if (NCURSES_FOUND) - set(tgt PkgConfig::NCURSES) - if (NOT TARGET ${tgt}) - message(FATAL_ERROR "FindPkgConfig found ncurses, but did not create an imported target for it") - endif () - set(prop_found FALSE) - foreach (prop IN ITEMS INTERFACE_INCLUDE_DIRECTORIES INTERFACE_LINK_LIBRARIES INTERFACE_COMPILE_OPTIONS) - get_target_property(value ${tgt} ${prop}) - if (value) - message(STATUS "Found property ${prop} on target: ${value}") - set(prop_found TRUE) +find_package(PkgConfig REQUIRED) + +# to test multiple variations, we must pick unique prefix names (same-named targets are cached for re-use) +set(prefix_uniquifiers 0 1) +# whether to apply STATIC_TARGET argument +set(static_target_args "" STATIC_TARGET) +foreach (prefix_uniquifier static_target_arg IN ZIP_LISTS prefix_uniquifiers static_target_args) + set(prefix "NCURSES${prefix_uniquifier}") + message(STATUS "static_target_arg: ${static_target_arg}") + pkg_check_modules(${prefix} IMPORTED_TARGET QUIET ${static_target_arg} ncurses) + + message(STATUS "source: ${CMAKE_CURRENT_SOURCE_DIR} bin ${CMAKE_CURRENT_BINARY_DIR}") + + if (${prefix}_FOUND) + set(tgt PkgConfig::${prefix}) + message(STATUS "Verifying target \"${tgt}\"") + if (NOT TARGET ${tgt}) + message(FATAL_ERROR "FindPkgConfig found ncurses, but did not create an imported target for it") endif () - endforeach () - if (NOT prop_found) - message(FATAL_ERROR "target ${tgt} found, but it has no properties") + set(prop_found FALSE) + foreach (prop IN ITEMS INTERFACE_INCLUDE_DIRECTORIES INTERFACE_LINK_LIBRARIES INTERFACE_COMPILE_OPTIONS) + get_target_property(value ${tgt} ${prop}) + if (value) + message(STATUS "Found property ${prop} on target: ${value}") + set(prop_found TRUE) + endif () + endforeach () + if (NOT prop_found) + message(FATAL_ERROR "target ${tgt} found, but it has no properties") + endif () + else () + message(STATUS "skipping test; ncurses not found") endif () -else () - message(STATUS "skipping test; ncurses not found") -endif () - +endforeach () # Setup for the remaining package tests below set(PKG_CONFIG_USE_CMAKE_PREFIX_PATH) set(fakePkgDir ${CMAKE_CURRENT_BINARY_DIR}/pc-fakepackage) foreach(i 1 2) set(pname cmakeinternalfakepackage${i}) - file(WRITE ${fakePkgDir}/lib/lib${pname}.a "") - file(WRITE ${fakePkgDir}/lib/${pname}.lib "") + file(WRITE ${fakePkgDir}/lib/${static_lib_prefix}${pname}${static_lib_suffix} "") + file(WRITE ${fakePkgDir}/lib/${shared_lib_prefix}${pname}${shared_lib_suffix} "") file(WRITE ${fakePkgDir}/lib/pkgconfig/${pname}.pc "Name: CMakeInternalFakePackage${i} Description: Dummy package (${i}) for FindPkgConfig IMPORTED_TARGET test @@ -49,12 +68,15 @@ set(ENV{PKG_CONFIG_PATH} ${fakePkgDir}/lib/pkgconfig) # find targets in subdir and check their visibility add_subdirectory(target_subdir) -if (TARGET PkgConfig::FakePackage1_dir) - message(FATAL_ERROR "imported target PkgConfig::FakePackage1_dir is visible outside it's directory") + +set(tgt PkgConfig::FakePackage1_dir) +if (TARGET ${tgt}) + message(FATAL_ERROR "imported target \"${tgt}\" is visible outside its directory") endif() -if (NOT TARGET PkgConfig::FakePackage1_global) - message(FATAL_ERROR "imported target PkgConfig::FakePackage1_global is not visible outside it's directory") +set(tgt PkgConfig::FakePackage1_global) +if (NOT TARGET ${tgt}) + message(FATAL_ERROR "imported target \"${tgt}\" is not visible outside its directory") endif() # And now do the same for the NO_CMAKE_ENVIRONMENT_PATH - ENV{CMAKE_PREFIX_PATH} @@ -63,35 +85,52 @@ unset(CMAKE_PREFIX_PATH) unset(ENV{CMAKE_PREFIX_PATH}) set(ENV{CMAKE_PREFIX_PATH} ${fakePkgDir}) -pkg_check_modules(FakePackage2 REQUIRED QUIET IMPORTED_TARGET cmakeinternalfakepackage2) -if (NOT TARGET PkgConfig::FakePackage2) - message(FATAL_ERROR "No import target for fake package 2 with prefix path") -endif() -# check that 2 library entries exist -list(LENGTH FakePackage2_LINK_LIBRARIES fp2_nlibs) -if (NOT fp2_nlibs EQUAL 2) - message(FATAL_ERROR "FakePackage2_LINK_LIBRARIES has ${fp2_nlibs} entries but should have exactly 2") -endif() - -# check that the full library path is also returned -list(GET FakePackage2_LINK_LIBRARIES 0 fp2_lib0) -if (NOT fp2_lib0 STREQUAL "${fakePkgDir}/lib/libcmakeinternalfakepackage2.a") - message(FATAL_ERROR "FakePackage2_LINK_LIBRARIES has bad content on first run: ${FakePackage2_LINK_LIBRARIES}") -endif() - -# check that the library that couldn't be found still shows up -list(GET FakePackage2_LINK_LIBRARIES 1 fp2_lib1) -if (NOT fp2_lib1 STREQUAL "cmakeinternalfakepackage2-doesnotexist") - message(FATAL_ERROR "FakePackage2_LINK_LIBRARIES has bad content on first run: ${FakePackage2_LINK_LIBRARIES}") -endif() +# to test multiple variations, we must pick unique prefix names (same-named targets are cached for re-use) +set(prefix_uniquifiers 0 1) +# whether to apply STATIC_TARGET argument +set(static_target_args "" STATIC_TARGET) +# whether target properties are populated from the unqualified (i.e. shared library) series of vars, or the STATIC_ series of vars +set(target_var_qualifiers "" STATIC_) +set(lib_types shared static) +foreach (prefix_uniquifier static_target_arg target_var_qualifier lib_type IN ZIP_LISTS prefix_uniquifiers static_target_args target_var_qualifiers lib_types) + set(prefix "FakePackage2${prefix_uniquifier}") + set(tgt "PkgConfig::${prefix}") + pkg_check_modules(${prefix} REQUIRED QUIET IMPORTED_TARGET ${static_target_arg} cmakeinternalfakepackage2) -# the information in *_LINK_LIBRARIES is not cached, so ensure is also is present on second run -unset(FakePackage2_LINK_LIBRARIES) -pkg_check_modules(FakePackage2 REQUIRED QUIET IMPORTED_TARGET cmakeinternalfakepackage2) -if (NOT FakePackage2_LINK_LIBRARIES STREQUAL "${fakePkgDir}/lib/libcmakeinternalfakepackage2.a;cmakeinternalfakepackage2-doesnotexist") - message(FATAL_ERROR "FakePackage2_LINK_LIBRARIES has bad content on second run: ${FakePackage2_LINK_LIBRARIES}") -endif() + message(STATUS "Verifying library path resolution for lib type \"${lib_type}\"") + if (NOT TARGET ${tgt}) + message(FATAL_ERROR "No import target for fake package 2 with prefix path") + endif() + + set(link_libraries_var ${prefix}_${target_var_qualifier}LINK_LIBRARIES) + # check that 2 library entries exist + list(LENGTH ${link_libraries_var} fp2_nlibs) + if (NOT fp2_nlibs EQUAL 2) + message(FATAL_ERROR "${link_libraries_var} has ${fp2_nlibs} entries but should have exactly 2") + endif() + + set(lib_leafname ${${lib_type}_lib_prefix}cmakeinternalfakepackage2${${lib_type}_lib_suffix}) + message(STATUS "Expecting library leafname \"${lib_leafname}\"") + # check that the full library path is also returned + list(GET ${link_libraries_var} 0 fp2_lib0) + if (NOT fp2_lib0 STREQUAL "${fakePkgDir}/lib/${lib_leafname}") + message(FATAL_ERROR "${link_libraries_var} has bad content on first run: ${${link_libraries_var}}") + endif() + + # check that the library that couldn't be found still shows up + list(GET ${link_libraries_var} 1 fp2_lib1) + if (NOT fp2_lib1 STREQUAL "cmakeinternalfakepackage2-doesnotexist") + message(FATAL_ERROR "${link_libraries_var} has bad content on first run: ${${link_libraries_var}}") + endif() + + # the information in *_LINK_LIBRARIES is not cached, so ensure is also is present on second run + unset(${link_libraries_var}) + pkg_check_modules(${prefix} REQUIRED QUIET IMPORTED_TARGET ${static_target_arg} cmakeinternalfakepackage2) + if (NOT ${link_libraries_var} STREQUAL "${fakePkgDir}/lib/${lib_leafname};cmakeinternalfakepackage2-doesnotexist") + message(FATAL_ERROR "${link_libraries_var} has bad content on second run: ${${link_libraries_var}}") + endif() +endforeach() set(pname fakelinkoptionspackage) file(WRITE ${fakePkgDir}/lib/pkgconfig/${pname}.pc @@ -104,10 +143,13 @@ Cflags: -I/special -isystem /other -isystem/more -DA-isystem/foo set(expected_link_options -e dummy_main) pkg_check_modules(FakeLinkOptionsPackage REQUIRED QUIET IMPORTED_TARGET fakelinkoptionspackage) -if (NOT TARGET PkgConfig::FakeLinkOptionsPackage) + +set(tgt PkgConfig::FakeLinkOptionsPackage) +message(STATUS "Verifying target \"${tgt}\"") +if (NOT TARGET ${tgt}) message(FATAL_ERROR "No import target for fake link options package") endif() -get_target_property(link_options PkgConfig::FakeLinkOptionsPackage INTERFACE_LINK_OPTIONS) +get_target_property(link_options ${tgt} INTERFACE_LINK_OPTIONS) if (NOT link_options STREQUAL expected_link_options) message(FATAL_ERROR "Additional link options not present in INTERFACE_LINK_OPTIONS property\n" @@ -115,7 +157,7 @@ if (NOT link_options STREQUAL expected_link_options) ) endif() -get_target_property(inc_dirs PkgConfig::FakeLinkOptionsPackage INTERFACE_INCLUDE_DIRECTORIES) +get_target_property(inc_dirs ${tgt} INTERFACE_INCLUDE_DIRECTORIES) set(expected_inc_dirs "/special" "/other" "/more") if (NOT inc_dirs STREQUAL expected_inc_dirs) @@ -125,7 +167,7 @@ if (NOT inc_dirs STREQUAL expected_inc_dirs) ) endif () -get_target_property(c_opts PkgConfig::FakeLinkOptionsPackage INTERFACE_COMPILE_OPTIONS) +get_target_property(c_opts ${tgt} INTERFACE_COMPILE_OPTIONS) set(expected_c_opts "-DA-isystem/foo") # this is an invalid option, but a good testcase if (NOT c_opts STREQUAL expected_c_opts) message(FATAL_ERROR diff --git a/Tests/RunCMake/FindPkgConfig/FindPkgConfig_LIBRARY_PATH-stdout.txt b/Tests/RunCMake/FindPkgConfig/FindPkgConfig_LIBRARY_PATH-stdout.txt index 6615d80..8966ac3 100644 --- a/Tests/RunCMake/FindPkgConfig/FindPkgConfig_LIBRARY_PATH-stdout.txt +++ b/Tests/RunCMake/FindPkgConfig/FindPkgConfig_LIBRARY_PATH-stdout.txt @@ -1,3 +1,6 @@ -- ZOT_LIBRARIES='zot' --- ZOT_LINK_LIBRARIES='[^']*/Tests/RunCMake/FindPkgConfig/FindPkgConfig_LIBRARY_PATH-build/zot/lib/prefix-zot-suffix' --- ZOT_LDFLAGS='-L[^']*/Tests/RunCMake/FindPkgConfig/FindPkgConfig_LIBRARY_PATH-build/zot/lib;-lzot' +-- ZOT_LINK_LIBRARIES='[^']*/Tests/RunCMake/FindPkgConfig/FindPkgConfig_LIBRARY_PATH-build/root/lib/dyprefix-zot-dysuffix' +-- ZOT_LDFLAGS='-L[^']*/Tests/RunCMake/FindPkgConfig/FindPkgConfig_LIBRARY_PATH-build/root/lib;-lzot' +-- ZOT_STATIC_LIBRARIES='zot' +-- ZOT_STATIC_LINK_LIBRARIES='[^']*/Tests/RunCMake/FindPkgConfig/FindPkgConfig_LIBRARY_PATH-build/root/lib/stprefix-zot-stsuffix' +-- ZOT_STATIC_LDFLAGS='-L[^']*/Tests/RunCMake/FindPkgConfig/FindPkgConfig_LIBRARY_PATH-build/root/lib;-lzot' diff --git a/Tests/RunCMake/FindPkgConfig/FindPkgConfig_LIBRARY_PATH.cmake b/Tests/RunCMake/FindPkgConfig/FindPkgConfig_LIBRARY_PATH.cmake index 9f654b5..536addc 100644 --- a/Tests/RunCMake/FindPkgConfig/FindPkgConfig_LIBRARY_PATH.cmake +++ b/Tests/RunCMake/FindPkgConfig/FindPkgConfig_LIBRARY_PATH.cmake @@ -1,29 +1,47 @@ find_package(PkgConfig REQUIRED) -file(WRITE "${CMAKE_CURRENT_BINARY_DIR}/zot/lib/pkgconfig/zot.pc" " -prefix=${CMAKE_CURRENT_BINARY_DIR}/zot +set(ROOT "${CMAKE_CURRENT_BINARY_DIR}/root") +string(REPLACE " " "\\ " ESCAPED_ROOT "${ROOT}") +set(LIB_DIR "${ROOT}/lib") +set(PKGCONFIG_DIR "${LIB_DIR}/pkgconfig") + +file(WRITE "${PKGCONFIG_DIR}/zot.pc" " +prefix=${ESCAPED_ROOT} libdir=\${prefix}/lib Name: Zot -Description: Dummy packaget to test LIBRARY_DIR support +Description: Dummy package to test LIBRARY_DIR support Version: 1.0 Libs: -L\${libdir} -lzot ") +set(shared_lib_prefix "dyprefix-") +set(shared_lib_suffix "-dysuffix") +set(static_lib_prefix "stprefix-") +set(static_lib_suffix "-stsuffix") + +set(CMAKE_SHARED_LIBRARY_PREFIX ${shared_lib_prefix}) +set(CMAKE_SHARED_LIBRARY_SUFFIX ${shared_lib_suffix}) +set(CMAKE_STATIC_LIBRARY_PREFIX ${static_lib_prefix}) +set(CMAKE_STATIC_LIBRARY_SUFFIX ${static_lib_suffix}) + # Create a "library" file to find in libdir. -set(CMAKE_FIND_LIBRARY_PREFIXES "prefix-") -set(CMAKE_FIND_LIBRARY_SUFFIXES "-suffix") -file(WRITE "${CMAKE_CURRENT_BINARY_DIR}/zot/lib/prefix-zot-suffix") +foreach(variant shared static) + file(WRITE "${LIB_DIR}/${${variant}_lib_prefix}zot${${variant}_lib_suffix}") +endforeach() # 'pkg-config --libs' drops -L flags in PKG_CONFIG_SYSTEM_LIBRARY_PATH by default. -set(ENV{PKG_CONFIG_SYSTEM_LIBRARY_PATH} "${CMAKE_CURRENT_BINARY_DIR}/zot/lib") +set(ENV{PKG_CONFIG_SYSTEM_LIBRARY_PATH} "${LIB_DIR}") # 'pkgconf --libs' also drops -L flags in LIBRARY_PATH by default. -set(ENV{LIBRARY_PATH} "${CMAKE_CURRENT_BINARY_DIR}/zot/lib") +set(ENV{LIBRARY_PATH} "${LIB_DIR}") -set(ENV{PKG_CONFIG_PATH} "${CMAKE_CURRENT_BINARY_DIR}/zot/lib/pkgconfig") +set(ENV{PKG_CONFIG_PATH} "${PKGCONFIG_DIR}") pkg_check_modules(ZOT REQUIRED zot) message(STATUS "ZOT_LIBRARIES='${ZOT_LIBRARIES}'") message(STATUS "ZOT_LINK_LIBRARIES='${ZOT_LINK_LIBRARIES}'") message(STATUS "ZOT_LDFLAGS='${ZOT_LDFLAGS}'") +message(STATUS "ZOT_STATIC_LIBRARIES='${ZOT_STATIC_LIBRARIES}'") +message(STATUS "ZOT_STATIC_LINK_LIBRARIES='${ZOT_STATIC_LINK_LIBRARIES}'") +message(STATUS "ZOT_STATIC_LDFLAGS='${ZOT_STATIC_LDFLAGS}'") diff --git a/Tests/RunCMake/FindPkgConfig/FindPkgConfig_LINK_LIBRARIES-stdout.txt b/Tests/RunCMake/FindPkgConfig/FindPkgConfig_LINK_LIBRARIES-stdout.txt new file mode 100644 index 0000000..edf0262 --- /dev/null +++ b/Tests/RunCMake/FindPkgConfig/FindPkgConfig_LINK_LIBRARIES-stdout.txt @@ -0,0 +1,6 @@ +-- IMM_LIBRARIES='imm' +-- IMM_LINK_LIBRARIES='[^']*/Tests/RunCMake/FindPkgConfig/FindPkgConfig_LINK_LIBRARIES-build/root/lib/dyprefix-imm-dysuffix' +-- IMM_LDFLAGS='-L[^']*/Tests/RunCMake/FindPkgConfig/FindPkgConfig_LINK_LIBRARIES-build/root/lib;-limm' +-- IMM_STATIC_LIBRARIES='imm;trns' +-- IMM_STATIC_LINK_LIBRARIES='[^']*/Tests/RunCMake/FindPkgConfig/FindPkgConfig_LINK_LIBRARIES-build/root/lib/stprefix-imm-stsuffix;[^']*/Tests/RunCMake/FindPkgConfig/FindPkgConfig_LINK_LIBRARIES-build/root/lib/stprefix-trns-stsuffix' +-- IMM_STATIC_LDFLAGS='-L[^']*/Tests/RunCMake/FindPkgConfig/FindPkgConfig_LINK_LIBRARIES-build/root/lib;-limm;-ltrns' diff --git a/Tests/RunCMake/FindPkgConfig/FindPkgConfig_LINK_LIBRARIES.cmake b/Tests/RunCMake/FindPkgConfig/FindPkgConfig_LINK_LIBRARIES.cmake new file mode 100644 index 0000000..bf4ee1e --- /dev/null +++ b/Tests/RunCMake/FindPkgConfig/FindPkgConfig_LINK_LIBRARIES.cmake @@ -0,0 +1,53 @@ +find_package(PkgConfig REQUIRED) + +set(ROOT "${CMAKE_CURRENT_BINARY_DIR}/root") +string(REPLACE " " "\\ " ESCAPED_ROOT "${ROOT}") +set(LIB_DIR "${ROOT}/lib") +set(PKGCONFIG_DIR "${LIB_DIR}/pkgconfig") + +file(WRITE "${PKGCONFIG_DIR}/imm.pc" " +prefix=${ESCAPED_ROOT} +libdir=\${prefix}/lib + +Name: Immediate +Description: Dummy package to test *LINK_LIBRARIES support +Version: 1.0 +Libs: -L\${libdir} -limm +Libs.private: -ltrns +") +file(WRITE "${PKGCONFIG_DIR}/trns.pc" " +prefix=${ESCAPED_ROOT} +libdir=\${prefix}/lib + +Name: Transitive +Description: Dummy package to test *LINK_LIBRARIES support +Version: 1.0 +Libs: -L\${libdir} -ltrns +") + +set(shared_lib_prefix "dyprefix-") +set(shared_lib_suffix "-dysuffix") +set(static_lib_prefix "stprefix-") +set(static_lib_suffix "-stsuffix") + +set(CMAKE_SHARED_LIBRARY_PREFIX ${shared_lib_prefix}) +set(CMAKE_SHARED_LIBRARY_SUFFIX ${shared_lib_suffix}) +set(CMAKE_STATIC_LIBRARY_PREFIX ${static_lib_prefix}) +set(CMAKE_STATIC_LIBRARY_SUFFIX ${static_lib_suffix}) + +# Create "library" files to find in libdir. +foreach(lib imm trns) + foreach(variant shared static) + file(WRITE "${LIB_DIR}/${${variant}_lib_prefix}${lib}${${variant}_lib_suffix}") + endforeach() +endforeach() + +set(ENV{PKG_CONFIG_PATH} "${PKGCONFIG_DIR}") +pkg_check_modules(IMM REQUIRED imm) + +message(STATUS "IMM_LIBRARIES='${IMM_LIBRARIES}'") +message(STATUS "IMM_LINK_LIBRARIES='${IMM_LINK_LIBRARIES}'") +message(STATUS "IMM_LDFLAGS='${IMM_LDFLAGS}'") +message(STATUS "IMM_STATIC_LIBRARIES='${IMM_STATIC_LIBRARIES}'") +message(STATUS "IMM_STATIC_LINK_LIBRARIES='${IMM_STATIC_LINK_LIBRARIES}'") +message(STATUS "IMM_STATIC_LDFLAGS='${IMM_STATIC_LDFLAGS}'") diff --git a/Tests/RunCMake/FindPkgConfig/FindPkgConfig_extract_frameworks_target.cmake b/Tests/RunCMake/FindPkgConfig/FindPkgConfig_extract_frameworks_target.cmake index 5501d9f..6c838a9 100644 --- a/Tests/RunCMake/FindPkgConfig/FindPkgConfig_extract_frameworks_target.cmake +++ b/Tests/RunCMake/FindPkgConfig/FindPkgConfig_extract_frameworks_target.cmake @@ -1,3 +1,5 @@ +cmake_minimum_required(VERSION 3.17) + # Prepare environment to reuse bletch.pc file(TO_NATIVE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/pc-bletch/lib/pkgconfig" PC_PATH) if(UNIX) @@ -6,24 +8,41 @@ endif() set(ENV{PKG_CONFIG_PATH} "${PC_PATH}") find_package(PkgConfig REQUIRED) -pkg_check_modules(Bletch IMPORTED_TARGET REQUIRED bletch-framework) - -if (Bletch_LDFLAGS_OTHER) - message(SEND_ERROR "Bletch_LDFLAGS_OTHER should be empty, but is '${Bletch_LDFLAGS_OTHER}'") -endif () -if (NOT Bletch_LINK_LIBRARIES STREQUAL "-framework foo;-framework bar;bletch;-framework baz") - message(SEND_ERROR "Bletch_LINK_LIBRARIES has wrong value '${Bletch_LINK_LIBRARIES}'") -endif () +# to test multiple variations, we must pick unique prefix names (same-named targets are cached for re-use) +set(prefix_uniquifiers 0 1) +# whether to apply STATIC_TARGET argument +set(static_target_args "" STATIC_TARGET) +# whether target properties are populated from the unqualified (i.e. shared library) series of vars, or the STATIC_ series of vars +set(target_var_qualifiers "" STATIC_) +foreach (prefix_uniquifier static_target_arg target_var_qualifier IN ZIP_LISTS prefix_uniquifiers static_target_args target_var_qualifiers) + set(prefix "Bletch${prefix_uniquifier}") + set(tgt "PkgConfig::${prefix}") + pkg_check_modules(${prefix} IMPORTED_TARGET REQUIRED ${static_target_arg} bletch-framework) + foreach (prop IN ITEMS INTERFACE_INCLUDE_DIRECTORIES INTERFACE_LINK_OPTIONS INTERFACE_COMPILE_OPTIONS) + get_target_property(prop_value ${tgt} ${prop}) + if (prop_value) + message(SEND_ERROR "target property ${prop} should not be set, but is '${prop_value}'") + endif () + endforeach () -foreach (prop IN ITEMS INTERFACE_INCLUDE_DIRECTORIES INTERFACE_LINK_OPTIONS INTERFACE_COMPILE_OPTIONS) - get_target_property(prop_value PkgConfig::Bletch ${prop}) - if (prop_value) - message(SEND_ERROR "target property ${prop} should not be set, but is '${prop_value}'") + # there is 1 target yet 2 series of variables. + # if STATIC_TARGET is set, then the target will follow the STATIC_ qualified series of variables + # (otherwise will follow the unqualified series of variables). + get_target_property(prop_value ${tgt} INTERFACE_LINK_LIBRARIES) + if (NOT prop_value STREQUAL ${prefix}_${target_var_qualifier}LINK_LIBRARIES) + message(SEND_ERROR "target property INTERFACE_LINK_LIBRARIES has wrong value '${prop_value}'") endif () -endforeach () -get_target_property(prop_value PkgConfig::Bletch INTERFACE_LINK_LIBRARIES) -if (NOT prop_value STREQUAL Bletch_LINK_LIBRARIES) - message(SEND_ERROR "target property INTERFACE_LINK_LIBRARIES has wrong value '${prop_value}'") -endif () + foreach (var_qualifier IN ITEMS "" STATIC_) + set (ldflags_var ${prefix}_${var_qualifier}LDFLAGS_OTHER) + if (${ldflags_var}) + message(SEND_ERROR "${ldflags_var} should be empty, but is '${${ldflags_var}}'") + endif () + + set (linklibs_var ${prefix}_${var_qualifier}LINK_LIBRARIES) + if (NOT ${linklibs_var} STREQUAL "-framework foo;-framework bar;bletch;-framework baz") + message(SEND_ERROR "${linklibs_var} has wrong value '${${linklibs_var}}'") + endif () + endforeach() +endforeach() diff --git a/Tests/RunCMake/FindPkgConfig/RunCMakeTest.cmake b/Tests/RunCMake/FindPkgConfig/RunCMakeTest.cmake index f36d1eb..f89b3b3 100644 --- a/Tests/RunCMake/FindPkgConfig/RunCMakeTest.cmake +++ b/Tests/RunCMake/FindPkgConfig/RunCMakeTest.cmake @@ -29,11 +29,9 @@ if (PKG_CONFIG_FOUND) run_cmake(FindPkgConfig_GET_VARIABLE_PKGCONFIG_PATH) run_cmake(FindPkgConfig_cache_variables) run_cmake(FindPkgConfig_IMPORTED_TARGET) + run_cmake(FindPkgConfig_LINK_LIBRARIES) run_cmake(FindPkgConfig_VERSION_OPERATORS) run_cmake(FindPkgConfig_GET_MATCHING_MODULE_NAME) run_cmake(FindPkgConfig_empty_target) - - if(NOT RunCMake_BINARY_DIR MATCHES " ") - run_cmake(FindPkgConfig_LIBRARY_PATH) - endif() + run_cmake(FindPkgConfig_LIBRARY_PATH) endif () |