summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--.clang-tidy2
-rw-r--r--.gitignore3
-rw-r--r--.gitlab-ci.yml56
-rw-r--r--.gitlab/ci/configure_fedora35_clang_analyzer.cmake1
-rw-r--r--.gitlab/ci/configure_fedora35_tidy.cmake3
-rw-r--r--.gitlab/ci/configure_fedora36_asan.cmake (renamed from .gitlab/ci/configure_fedora35_asan.cmake)2
-rw-r--r--.gitlab/ci/configure_fedora36_clang_analyzer.cmake1
-rw-r--r--.gitlab/ci/configure_fedora36_common.cmake (renamed from .gitlab/ci/configure_fedora35_common.cmake)0
-rw-r--r--.gitlab/ci/configure_fedora36_makefiles.cmake (renamed from .gitlab/ci/configure_fedora35_makefiles.cmake)0
-rw-r--r--.gitlab/ci/configure_fedora36_ninja.cmake (renamed from .gitlab/ci/configure_fedora35_ninja.cmake)2
-rw-r--r--.gitlab/ci/configure_fedora36_ninja_multi.cmake (renamed from .gitlab/ci/configure_fedora35_ninja_multi.cmake)0
-rw-r--r--.gitlab/ci/configure_fedora36_sphinx.cmake (renamed from .gitlab/ci/configure_fedora35_sphinx.cmake)0
-rw-r--r--.gitlab/ci/configure_fedora36_sphinx_package.cmake (renamed from .gitlab/ci/configure_fedora35_sphinx_package.cmake)0
-rw-r--r--.gitlab/ci/configure_fedora36_tidy.cmake3
-rw-r--r--.gitlab/ci/ctest_memcheck_fedora36_asan.lsan.supp (renamed from .gitlab/ci/ctest_memcheck_fedora35_asan.lsan.supp)0
-rwxr-xr-x.gitlab/ci/docker/debian10/install_rvm.sh1
-rw-r--r--.gitlab/ci/docker/fedora36/Dockerfile (renamed from .gitlab/ci/docker/fedora35/Dockerfile)4
-rwxr-xr-x.gitlab/ci/docker/fedora36/install_deps.sh (renamed from .gitlab/ci/docker/fedora35/install_deps.sh)0
-rwxr-xr-x.gitlab/ci/docker/fedora36/install_ispc.sh (renamed from .gitlab/ci/docker/fedora35/install_ispc.sh)0
-rwxr-xr-x.gitlab/ci/docker/fedora36/install_rvm.sh (renamed from .gitlab/ci/docker/fedora35/install_rvm.sh)6
-rw-r--r--.gitlab/ci/env_fedora35_makefiles.cmake2
-rw-r--r--.gitlab/ci/env_fedora36_asan.sh (renamed from .gitlab/ci/env_fedora35_asan.sh)0
-rw-r--r--.gitlab/ci/env_fedora36_clang_analyzer.sh (renamed from .gitlab/ci/env_fedora35_clang_analyzer.sh)0
-rw-r--r--.gitlab/ci/env_fedora36_makefiles.cmake2
-rw-r--r--.gitlab/os-linux.yml58
-rw-r--r--.gitlab/upload.yml4
-rw-r--r--CTestCustom.cmake.in1
-rw-r--r--Help/command/cmake_language.rst263
-rw-r--r--Help/command/find_package.rst3
-rw-r--r--Help/manual/cmake-generator-expressions.7.rst8
-rw-r--r--Help/release/dev/LLVMFlang-compiler.rst6
-rw-r--r--Help/release/dev/dependency-providers.rst9
-rw-r--r--Help/variable/CMAKE_COMPILER_IS_GNUCC.rst6
-rw-r--r--Help/variable/CMAKE_COMPILER_IS_GNUCXX.rst6
-rw-r--r--Help/variable/CMAKE_COMPILER_IS_GNUG77.rst6
-rw-r--r--Help/variable/CMAKE_LANG_COMPILER_ID.rst3
-rw-r--r--Modules/CMakeDetermineFortranCompiler.cmake1
-rw-r--r--Modules/CMakeFortranCompilerId.F.in7
-rw-r--r--Modules/CPackComponent.cmake18
-rw-r--r--Modules/Compiler/LLVMFlang-Fortran.cmake13
-rw-r--r--Modules/FetchContent.cmake239
-rw-r--r--Modules/FindVulkan.cmake87
-rw-r--r--Source/CMakeLists.txt1
-rw-r--r--Source/CMakeVersion.cmake2
-rw-r--r--Source/CPack/IFW/cmCPackIFWGenerator.cxx2
-rw-r--r--Source/CPack/IFW/cmCPackIFWRepository.cxx3
-rw-r--r--Source/CPack/cmCPackDebGenerator.cxx2
-rw-r--r--Source/CTest/cmCTestBZR.cxx17
-rw-r--r--Source/CTest/cmCTestBinPacker.cxx6
-rw-r--r--Source/CTest/cmCTestCVS.cxx7
-rw-r--r--Source/CTest/cmCTestCoverageHandler.cxx2
-rw-r--r--Source/CTest/cmCTestGIT.cxx13
-rw-r--r--Source/CTest/cmCTestHG.cxx10
-rw-r--r--Source/CTest/cmCTestMemCheckHandler.cxx3
-rw-r--r--Source/CTest/cmCTestP4.cxx23
-rw-r--r--Source/CTest/cmCTestSVN.cxx12
-rw-r--r--Source/CTest/cmCTestSubmitHandler.cxx19
-rw-r--r--Source/CTest/cmCTestTestHandler.cxx3
-rw-r--r--Source/CTest/cmCTestVC.cxx2
-rw-r--r--Source/CursesDialog/cmCursesMainForm.cxx4
-rw-r--r--Source/QtDialog/QCMakeCacheView.cxx7
-rw-r--r--Source/cmArchiveWrite.cxx1
-rw-r--r--Source/cmArchiveWrite.h2
-rw-r--r--Source/cmCMakeLanguageCommand.cxx93
-rw-r--r--Source/cmCTest.cxx37
-rw-r--r--Source/cmConditionEvaluator.cxx49
-rw-r--r--Source/cmCoreTryCompile.cxx14
-rw-r--r--Source/cmCryptoHash.cxx8
-rw-r--r--Source/cmDependencyProvider.h38
-rw-r--r--Source/cmDependsFortran.cxx2
-rw-r--r--Source/cmELF.cxx3
-rw-r--r--Source/cmExtraEclipseCDT4Generator.cxx2
-rw-r--r--Source/cmFileAPI.cxx2
-rw-r--r--Source/cmFileCommand.cxx8
-rw-r--r--Source/cmFileCopier.cxx10
-rw-r--r--Source/cmFileCopier.h23
-rw-r--r--Source/cmFileInstaller.cxx9
-rw-r--r--Source/cmFileInstaller.h14
-rw-r--r--Source/cmFindPackageCommand.cxx75
-rw-r--r--Source/cmFindPackageCommand.h5
-rw-r--r--Source/cmForEachCommand.cxx4
-rw-r--r--Source/cmFortranParser.h3
-rw-r--r--Source/cmGeneratedFileStream.cxx3
-rw-r--r--Source/cmGeneratorExpression.cxx5
-rw-r--r--Source/cmGeneratorExpression.h10
-rw-r--r--Source/cmGeneratorExpressionContext.cxx4
-rw-r--r--Source/cmGeneratorExpressionContext.h8
-rw-r--r--Source/cmGeneratorExpressionNode.cxx10
-rw-r--r--Source/cmGeneratorExpressionParser.cxx1
-rw-r--r--Source/cmGeneratorExpressionParser.h2
-rw-r--r--Source/cmGeneratorTarget.cxx19
-rw-r--r--Source/cmGeneratorTarget.h28
-rw-r--r--Source/cmGetPropertyCommand.cxx2
-rw-r--r--Source/cmGlobalGenerator.cxx10
-rw-r--r--Source/cmGraphVizWriter.cxx12
-rw-r--r--Source/cmGraphVizWriter.h24
-rw-r--r--Source/cmInstallDirectoryGenerator.cxx1
-rw-r--r--Source/cmInstallDirectoryGenerator.h2
-rw-r--r--Source/cmInstallExportGenerator.cxx1
-rw-r--r--Source/cmInstallExportGenerator.h2
-rw-r--r--Source/cmInstallFilesGenerator.cxx1
-rw-r--r--Source/cmInstallFilesGenerator.h2
-rw-r--r--Source/cmInstallScriptGenerator.cxx1
-rw-r--r--Source/cmInstallScriptGenerator.h2
-rw-r--r--Source/cmInstallTargetGenerator.cxx1
-rw-r--r--Source/cmInstallTargetGenerator.h2
-rw-r--r--Source/cmLinkLineComputer.cxx4
-rw-r--r--Source/cmLinkLineComputer.h8
-rw-r--r--Source/cmListCommand.cxx19
-rw-r--r--Source/cmListFileCache.cxx3
-rw-r--r--Source/cmListFileCache.h12
-rw-r--r--Source/cmLoadCacheCommand.cxx2
-rw-r--r--Source/cmMakefile.cxx16
-rw-r--r--Source/cmMakefile.h4
-rw-r--r--Source/cmMakefileLibraryTargetGenerator.cxx4
-rw-r--r--Source/cmMakefileProfilingData.cxx4
-rw-r--r--Source/cmMathCommand.cxx4
-rw-r--r--Source/cmOSXBundleGenerator.cxx1
-rw-r--r--Source/cmOSXBundleGenerator.h2
-rw-r--r--Source/cmOutputConverter.cxx1
-rw-r--r--Source/cmOutputConverter.h2
-rw-r--r--Source/cmPolicies.cxx4
-rw-r--r--Source/cmProcessTools.cxx8
-rw-r--r--Source/cmProjectCommand.cxx4
-rw-r--r--Source/cmRST.cxx5
-rw-r--r--Source/cmRST.h10
-rw-r--r--Source/cmScriptGenerator.cxx2
-rw-r--r--Source/cmScriptGenerator.h4
-rw-r--r--Source/cmState.cxx9
-rw-r--r--Source/cmState.h25
-rw-r--r--Source/cmSystemTools.cxx10
-rw-r--r--Source/cmTargetDepend.h9
-rw-r--r--Source/cmTargetIncludeDirectoriesCommand.cxx2
-rw-r--r--Source/cmTest.cxx3
-rw-r--r--Source/cmTest.h2
-rw-r--r--Source/cmTimestamp.cxx2
-rw-r--r--Source/cmTransformDepfile.cxx4
-rw-r--r--Source/cmUuid.cxx23
-rw-r--r--Source/cmXMLWriter.cxx4
-rw-r--r--Source/cmXMLWriter.h8
-rw-r--r--Source/cmake.cxx2
-rw-r--r--Source/cmakemain.cxx4
-rw-r--r--Source/cmcmd.cxx6
-rw-r--r--Tests/CMakeLib/run_compile_commands.cxx2
-rw-r--r--Tests/FindVulkan/Test/CMakeLists.txt23
-rw-r--r--Tests/FindVulkan/Test/main-MoltenVK.cxx16
-rw-r--r--Tests/RunCMake/CMakeLists.txt1
-rw-r--r--Tests/RunCMake/CTestResourceAllocation/ctresalloc.cxx3
-rw-r--r--Tests/RunCMake/DependencyProviders/AfterProject-result.txt1
-rw-r--r--Tests/RunCMake/DependencyProviders/AfterProject-stderr.txt6
-rw-r--r--Tests/RunCMake/DependencyProviders/BeforeProject-result.txt1
-rw-r--r--Tests/RunCMake/DependencyProviders/BeforeProject-stderr.txt6
-rw-r--r--Tests/RunCMake/DependencyProviders/Bypass-stdout.txt7
-rw-r--r--Tests/RunCMake/DependencyProviders/Bypass.cmake1
-rw-r--r--Tests/RunCMake/DependencyProviders/CMakeLists.txt13
-rw-r--r--Tests/RunCMake/DependencyProviders/ConfigFiles/SomeDepConfig.cmake2
-rw-r--r--Tests/RunCMake/DependencyProviders/FetchContentSerial-stdout.txt7
-rw-r--r--Tests/RunCMake/DependencyProviders/FetchContentSerial.cmake1
-rw-r--r--Tests/RunCMake/DependencyProviders/FindPackage-stdout.txt7
-rw-r--r--Tests/RunCMake/DependencyProviders/FindPackage.cmake1
-rw-r--r--Tests/RunCMake/DependencyProviders/NoCommand-result.txt1
-rw-r--r--Tests/RunCMake/DependencyProviders/NoCommand-stderr.txt3
-rw-r--r--Tests/RunCMake/DependencyProviders/NoCommandOrMethods-stdout.txt3
-rw-r--r--Tests/RunCMake/DependencyProviders/NoCommandOrMethods.cmake3
-rw-r--r--Tests/RunCMake/DependencyProviders/NoMethods-result.txt1
-rw-r--r--Tests/RunCMake/DependencyProviders/NoMethods-stderr.txt2
-rw-r--r--Tests/RunCMake/DependencyProviders/PassThroughProvider-stdout.txt7
-rw-r--r--Tests/RunCMake/DependencyProviders/PassThroughProvider.cmake1
-rw-r--r--Tests/RunCMake/DependencyProviders/ProjectIncludeAfter-result.txt1
-rw-r--r--Tests/RunCMake/DependencyProviders/ProjectIncludeAfter-stderr.txt6
-rw-r--r--Tests/RunCMake/DependencyProviders/ProjectIncludeBefore-result.txt1
-rw-r--r--Tests/RunCMake/DependencyProviders/ProjectIncludeBefore-stderr.txt6
-rw-r--r--Tests/RunCMake/DependencyProviders/Recurse-stdout.txt7
-rw-r--r--Tests/RunCMake/DependencyProviders/Recurse.cmake8
-rw-r--r--Tests/RunCMake/DependencyProviders/RedirectFetchContentSerial-result.txt1
-rw-r--r--Tests/RunCMake/DependencyProviders/RedirectFetchContentSerial-stderr.txt11
-rw-r--r--Tests/RunCMake/DependencyProviders/RedirectFetchContentSerial-stdout.txt5
-rw-r--r--Tests/RunCMake/DependencyProviders/RedirectFetchContentSerial.cmake1
-rw-r--r--Tests/RunCMake/DependencyProviders/RedirectFindPackage-stdout.txt7
-rw-r--r--Tests/RunCMake/DependencyProviders/RedirectFindPackage.cmake1
-rw-r--r--Tests/RunCMake/DependencyProviders/RunCMakeTest.cmake73
-rw-r--r--Tests/RunCMake/DependencyProviders/ToolchainFile-result.txt1
-rw-r--r--Tests/RunCMake/DependencyProviders/ToolchainFile-stderr.txt6
-rw-r--r--Tests/RunCMake/DependencyProviders/set_provider.cmake64
-rw-r--r--Tests/RunCMake/DependencyProviders/try_methods.cmake12
185 files changed, 1556 insertions, 529 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,\
diff --git a/.gitignore b/.gitignore
index be848fb..5bd9113 100644
--- a/.gitignore
+++ b/.gitignore
@@ -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/command/cmake_language.rst b/Help/command/cmake_language.rst
index 2859f6b..e49862f 100644
--- a/Help/command/cmake_language.rst
+++ b/Help/command/cmake_language.rst
@@ -13,6 +13,7 @@ Synopsis
cmake_language(`CALL`_ <command> [<arg>...])
cmake_language(`EVAL`_ CODE <code>...)
cmake_language(`DEFER`_ <options>... CALL <command> [<arg>...])
+ cmake_language(`SET_DEPENDENCY_PROVIDER`_ <command> SUPPORTED_METHODS <methods>...)
Introduction
^^^^^^^^^^^^
@@ -225,3 +226,265 @@ also prints::
Immediate Message
Deferred Message 1
Deferred Message 2
+
+
+.. _SET_DEPENDENCY_PROVIDER:
+.. _dependency_providers:
+
+Dependency Providers
+^^^^^^^^^^^^^^^^^^^^
+
+.. versionadded:: 3.24
+
+.. code-block:: cmake
+
+ cmake_language(SET_DEPENDENCY_PROVIDER <command>
+ SUPPORTED_METHODS <methods>...)
+
+When a call is made to :command:`find_package` or
+:command:`FetchContent_MakeAvailable`, the call may be forwarded to a
+dependency provider which then has the opportunity to fulfill the request.
+If the request is for one of the ``<methods>`` specified when the provider
+was set, CMake calls the provider's ``<command>`` with a set of
+method-specific arguments. If the provider does not fulfill the request,
+or if the provider doesn't support the request's method, or no provider
+is set, the built-in :command:`find_package` or
+:command:`FetchContent_MakeAvailable` implementation is used to fulfill
+the request in the usual way.
+
+One or more of the following values can be specified for the ``<methods>``
+when setting the provider:
+
+``FIND_PACKAGE``
+ The provider command accepts :command:`find_package` requests.
+
+``FETCHCONTENT_MAKEAVAILABLE_SERIAL``
+ The provider command accepts :command:`FetchContent_MakeAvailable`
+ requests. It expects each dependency to be fed to the provider command
+ one at a time, not the whole list in one go.
+
+Only one provider can be set at any point in time. If a provider is already
+set when ``cmake_language(SET_DEPENDENCY_PROVIDER)`` is called, the new
+provider replaces the previously set one. The specified ``<command>`` must
+already exist when ``cmake_language(SET_DEPENDENCY_PROVIDER)`` is called.
+As a special case, providing an empty string for the ``<command>`` and no
+``<methods>`` will discard any previously set provider.
+
+The dependency provider can only be set while processing one of the files
+specified by the :variable:`CMAKE_PROJECT_TOP_LEVEL_INCLUDES` variable.
+Thus, dependency providers can only be set as part of the first call to
+:command:`project`. Calling ``cmake_language(SET_DEPENDENCY_PROVIDER)``
+outside of that context will result in an error.
+
+.. note::
+ The choice of dependency provider should always be under the user's control.
+ As a convenience, a project may choose to provide a file that users can
+ list in their :variable:`CMAKE_PROJECT_TOP_LEVEL_INCLUDES` variable, but
+ the use of such a file should always be the user's choice.
+
+Provider commands
+"""""""""""""""""
+
+Providers define a single ``<command>`` to accept requests. The name of
+the command should be specific to that provider, not something overly
+generic that another provider might also use. This enables users to compose
+different providers in their own custom provider. The recommended form is
+``xxx_provide_dependency()``, where ``xxx`` is the provider-specific part
+(e.g. ``vcpkg_provide_dependency()``, ``conan_provide_dependency()``,
+``ourcompany_provide_dependency()``, and so on).
+
+.. code-block:: cmake
+
+ xxx_provide_dependency(<method> [<method-specific-args>...])
+
+Because some methods expect certain variables to be set in the calling scope,
+the provider command should typically be implemented as a macro rather than a
+function. This ensures it does not introduce a new variable scope.
+
+The arguments CMake passes to the dependency provider depend on the type of
+request. The first argument is always the method, and it will only ever
+be one of the ``<methods>`` that was specified when setting the provider.
+
+``FIND_PACKAGE``
+ The ``<method-specific-args>`` will be everything passed to the
+ :command:`find_package` call that requested the dependency. The first of
+ these ``<method-specific-args>`` will therefore always be the name of the
+ dependency. Dependency names are case-sensitive for this method because
+ :command:`find_package` treats them case-sensitively too.
+
+ If the provider command fulfills the request, it must set the same variable
+ that :command:`find_package` expects to be set. For a dependency named
+ ``depName``, the provider must set ``depName_FOUND`` to true if it fulfilled
+ the request. If the provider returns without setting this variable, CMake
+ will assume the request was not fulfilled and will fall back to the
+ built-in implementation.
+
+ If the provider needs to call the built-in :command:`find_package`
+ implementation as part of its processing, it can do so by including the
+ ``BYPASS_PROVIDER`` keyword as one of the arguments.
+
+``FETCHCONTENT_MAKEAVAILABE_SERIAL``
+ The ``<method-specific-args>`` will be everything passed to the
+ :command:`FetchContent_Declare` call that corresponds to the requested
+ dependency, with the following exceptions:
+
+ * If ``SOURCE_DIR`` or ``BINARY_DIR`` were not part of the original
+ declared arguments, they will be added with their default values.
+ * If :variable:`FETCHCONTENT_TRY_FIND_PACKAGE_MODE` is set to ``NEVER``,
+ any ``FIND_PACKAGE_ARGS`` will be omitted.
+ * The ``OVERRIDE_FIND_PACKAGE`` keyword is always omitted.
+
+ The first of the ``<method-specific-args>`` will always be the name of the
+ dependency. Dependency names are case-insensitive for this method because
+ :module:`FetchContent` also treats them case-insensitively.
+
+ If the provider fulfills the request, it should call
+ :command:`FetchContent_SetPopulated`, passing the name of the dependency as
+ the first argument. The ``SOURCE_DIR`` and ``BINARY_DIR`` arguments to that
+ command should only be given if the provider makes the dependency's source
+ and build directories available in exactly the same way as the built-in
+ :command:`FetchContent_MakeAvailable` command.
+
+ If the provider returns without calling :command:`FetchContent_SetPopulated`
+ for the named dependency, CMake will assume the request was not fulfilled
+ and will fall back to the built-in implementation.
+
+ Note that empty arguments may be significant for this method (e.g. an empty
+ string following a ``GIT_SUBMODULES`` keyword). Therefore, if forwarding
+ these arguments on to another command, extra care must be taken to avoid such
+ arguments being silently dropped.
+
+ If ``FETCHCONTENT_SOURCE_DIR_<uppercaseDepName>`` is set, then the
+ dependency provider will never see requests for the ``<depName>`` dependency
+ for this method. When the user sets such a variable, they are explicitly
+ overriding where to get that dependency from and are taking on the
+ responsibility that their overriding version meets any requirements for that
+ dependency and is compatible with whatever else in the project uses it.
+ Depending on the value of :variable:`FETCHCONTENT_TRY_FIND_PACKAGE_MODE`
+ and whether the ``OVERRIDE_FIND_PACKAGE`` option was given to
+ :command:`FetchContent_Declare`, having
+ ``FETCHCONTENT_SOURCE_DIR_<uppercaseDepName>`` set may also prevent the
+ dependency provider from seeing requests for a ``find_package(depName)``
+ call too.
+
+Provider Examples
+"""""""""""""""""
+
+This first example only intercepts :command:`find_package` calls. The
+provider command runs an external tool which copies the relevant artifacts
+into a provider-specific directory, if that tool knows about the dependency.
+It then relies on the built-in implementation to then find those artifacts.
+:command:`FetchContent_MakeAvailable` calls would not go through the provider.
+
+.. code-block:: cmake
+ :caption: mycomp_provider.cmake
+
+ # Always ensure we have the policy settings this provider expects
+ cmake_minimum_required(VERSION 3.24)
+
+ set(MYCOMP_PROVIDER_INSTALL_DIR ${CMAKE_BINARY_DIR}/mycomp_packages
+ CACHE PATH "The directory this provider installs packages to"
+ )
+ # Tell the built-in implementation to look in our area first, unless
+ # the find_package() call uses NO_..._PATH options to exclude it
+ list(APPEND CMAKE_MODULE_PATH ${MYCOMP_PROVIDER_INSTALL_DIR}/cmake)
+ list(APPEND CMAKE_PREFIX_PATH ${MYCOMP_PROVIDER_INSTALL_DIR})
+
+ macro(mycomp_provide_dependency method package_name)
+ execute_process(
+ COMMAND some_tool ${package_name} --installdir ${MYCOMP_PROVIDER_INSTALL_DIR}
+ COMMAND_ERROR_IS_FATAL ANY
+ )
+ endmacro()
+
+ cmake_language(
+ SET_DEPENDENCY_PROVIDER mycomp_provide_dependency
+ SUPPORTED_METHODS FIND_PACKAGE
+ )
+
+The user would then typically use the above file like so::
+
+ cmake -DCMAKE_PROJECT_TOP_LEVEL_INCLUDES=/path/to/mycomp_provider.cmake ...
+
+The next example demonstrates a provider that accepts both methods, but
+only handles one specific dependency. It enforces providing Google Test
+using :module:`FetchContent`, but leaves all other dependencies to be
+fulfilled by CMake's built-in implementation. It accepts a few different
+names, which demonstrates one way of working around projects that hard-code
+an unusual or undesirable way of adding this particular dependency to the
+build. The example also demonstrates how to use the :command:`list` command
+to preserve variables that may be overwritten by a call to
+:command:`FetchContent_MakeAvailable`.
+
+.. code-block:: cmake
+ :caption: mycomp_provider.cmake
+
+ cmake_minimum_required(VERSION 3.24)
+
+ # Because we declare this very early, it will take precedence over any
+ # details the project might declare later for the same thing
+ include(FetchContent)
+ FetchContent_Declare(
+ googletest
+ GIT_REPOSITORY https://github.com/google/googletest.git
+ GIT_TAG e2239ee6043f73722e7aa812a459f54a28552929 # release-1.11.0
+ )
+
+ # Both FIND_PACKAGE and FETCHCONTENT_MAKEAVAILABLE_SERIAL methods provide
+ # the package or dependency name as the first method-specific argument.
+ macro(mycomp_provide_dependency method dep_name)
+ if("${dep_name}" MATCHES "^(gtest|googletest)$")
+ # Save our current command arguments in case we are called recursively
+ list(APPEND mycomp_provider_args ${method} ${dep_name})
+
+ # This will forward to the built-in FetchContent implementation,
+ # which detects a recursive call for the same thing and avoids calling
+ # the provider again if dep_name is the same as the current call.
+ FetchContent_MakeAvailable(googletest)
+
+ # Restore our command arguments
+ list(POP_BACK mycomp_provider_args dep_name method)
+
+ # Tell the caller we fulfilled the request
+ if("${method}" STREQUAL "FIND_PACKAGE")
+ # We need to set this if we got here from a find_package() call
+ # since we used a different method to fulfill the request.
+ # This example assumes projects only use the gtest targets,
+ # not any of the variables the FindGTest module may define.
+ set(${dep_name}_FOUND TRUE)
+ elseif(NOT "${dep_name}" STREQUAL "googletest")
+ # We used the same method, but were given a different name to the
+ # one we populated with. Tell the caller about the name it used.
+ FetchContent_SetPopulated(${dep_name}
+ SOURCE_DIR "${googletest_SOURCE_DIR}"
+ BINARY_DIR "${googletest_BINARY_DIR}"
+ )
+ endif()
+ endif()
+ endmacro()
+
+ cmake_language(
+ SET_DEPENDENCY_PROVIDER mycomp_provide_dependency
+ SUPPORTED_METHODS
+ FIND_PACKAGE
+ FETCHCONTENT_MAKEAVAILABLE_SERIAL
+ )
+
+The final example demonstrates how to modify arguments to a
+:command:`find_package` call. It forces all such calls to have the
+``QUIET`` keyword. It uses the ``BYPASS_PROVIDER`` keyword to prevent
+calling the provider command recursively for the same dependency.
+
+.. code-block:: cmake
+ :caption: mycomp_provider.cmake
+
+ cmake_minimum_required(VERSION 3.24)
+
+ macro(mycomp_provide_dependency method)
+ find_package(${ARGN} BYPASS_PROVIDER QUIET)
+ endmacro()
+
+ cmake_language(
+ SET_DEPENDENCY_PROVIDER mycomp_provide_dependency
+ SUPPORTED_METHODS FIND_PACKAGE
+ )
diff --git a/Help/command/find_package.rst b/Help/command/find_package.rst
index a7d7d00..a4dad21 100644
--- a/Help/command/find_package.rst
+++ b/Help/command/find_package.rst
@@ -12,7 +12,8 @@ find_package
.. contents::
Find a package (usually provided by something external to the project),
-and load its package-specific details.
+and load its package-specific details. Calls to this command can also
+be intercepted by :ref:`dependency providers <dependency_providers>`.
Search Modes
^^^^^^^^^^^^
diff --git a/Help/manual/cmake-generator-expressions.7.rst b/Help/manual/cmake-generator-expressions.7.rst
index 22c14df..848a133 100644
--- a/Help/manual/cmake-generator-expressions.7.rst
+++ b/Help/manual/cmake-generator-expressions.7.rst
@@ -197,6 +197,8 @@ Variable Queries
.. genex:: $<HIP_COMPILER_ID:compiler_ids>
+ .. versionadded:: 3.21
+
where ``compiler_ids`` is a comma-separated list.
``1`` if the CMake's compiler id of the HIP compiler matches any one
of the entries in ``compiler_ids``, otherwise ``0``.
@@ -249,6 +251,8 @@ Variable Queries
.. genex:: $<HIP_COMPILER_VERSION:version>
+ .. versionadded:: 3.21
+
``1`` if the version of the HIP compiler matches ``version``, otherwise ``0``.
See also the :variable:`CMAKE_<LANG>_COMPILER_VERSION` variable.
@@ -716,6 +720,8 @@ Variable Queries
.. genex:: $<HIP_COMPILER_ID>
+ .. versionadded:: 3.21
+
The CMake's compiler id of the HIP compiler used.
See also the :variable:`CMAKE_<LANG>_COMPILER_ID` variable.
@@ -762,6 +768,8 @@ Variable Queries
.. genex:: $<HIP_COMPILER_VERSION>
+ .. versionadded:: 3.21
+
The version of the HIP compiler used.
See also the :variable:`CMAKE_<LANG>_COMPILER_VERSION` variable.
diff --git a/Help/release/dev/LLVMFlang-compiler.rst b/Help/release/dev/LLVMFlang-compiler.rst
new file mode 100644
index 0000000..1d29449
--- /dev/null
+++ b/Help/release/dev/LLVMFlang-compiler.rst
@@ -0,0 +1,6 @@
+LLVMFlang-compiler
+------------------
+
+* LLVM's `flang`_ Fortran compiler is now supported, with compiler id ``LLVMFlang``.
+
+.. _`flang`: https://github.com/llvm/llvm-project/tree/main/flang
diff --git a/Help/release/dev/dependency-providers.rst b/Help/release/dev/dependency-providers.rst
new file mode 100644
index 0000000..8b2cf06
--- /dev/null
+++ b/Help/release/dev/dependency-providers.rst
@@ -0,0 +1,9 @@
+dependency-providers
+--------------------
+
+* The :command:`cmake_language` command gained a new
+ ``SET_DEPENDENCY_PROVIDER`` sub-command. When a dependency provider is set,
+ calls to :command:`find_package` and :command:`FetchContent_MakeAvailable`
+ can be redirected through a custom command, which can choose to fulfill the
+ request directly, modify how the request is processed, or leave it to be
+ fulfilled by the built-in implementation. See :ref:`dependency_providers`.
diff --git a/Help/variable/CMAKE_COMPILER_IS_GNUCC.rst b/Help/variable/CMAKE_COMPILER_IS_GNUCC.rst
index 91cf848..4b799c0 100644
--- a/Help/variable/CMAKE_COMPILER_IS_GNUCC.rst
+++ b/Help/variable/CMAKE_COMPILER_IS_GNUCC.rst
@@ -1,7 +1,7 @@
CMAKE_COMPILER_IS_GNUCC
-----------------------
-.. versionadded:: 3.7
-
True if the ``C`` compiler is GNU.
-Use :variable:`CMAKE_C_COMPILER_ID <CMAKE_<LANG>_COMPILER_ID>` instead.
+
+This variable is deprecated. Use
+:variable:`CMAKE_C_COMPILER_ID <CMAKE_<LANG>_COMPILER_ID>` instead.
diff --git a/Help/variable/CMAKE_COMPILER_IS_GNUCXX.rst b/Help/variable/CMAKE_COMPILER_IS_GNUCXX.rst
index e67718a..29069d2 100644
--- a/Help/variable/CMAKE_COMPILER_IS_GNUCXX.rst
+++ b/Help/variable/CMAKE_COMPILER_IS_GNUCXX.rst
@@ -1,7 +1,7 @@
CMAKE_COMPILER_IS_GNUCXX
------------------------
-.. versionadded:: 3.7
-
True if the C++ (``CXX``) compiler is GNU.
-Use :variable:`CMAKE_CXX_COMPILER_ID <CMAKE_<LANG>_COMPILER_ID>` instead.
+
+This variable is deprecated. Use
+:variable:`CMAKE_CXX_COMPILER_ID <CMAKE_<LANG>_COMPILER_ID>` instead.
diff --git a/Help/variable/CMAKE_COMPILER_IS_GNUG77.rst b/Help/variable/CMAKE_COMPILER_IS_GNUG77.rst
index f69c01a..05303dc 100644
--- a/Help/variable/CMAKE_COMPILER_IS_GNUG77.rst
+++ b/Help/variable/CMAKE_COMPILER_IS_GNUG77.rst
@@ -1,7 +1,7 @@
CMAKE_COMPILER_IS_GNUG77
------------------------
-.. versionadded:: 3.7
-
True if the ``Fortran`` compiler is GNU.
-Use :variable:`CMAKE_Fortran_COMPILER_ID <CMAKE_<LANG>_COMPILER_ID>` instead.
+
+This variable is deprecated. Use
+:variable:`CMAKE_Fortran_COMPILER_ID <CMAKE_<LANG>_COMPILER_ID>` instead.
diff --git a/Help/variable/CMAKE_LANG_COMPILER_ID.rst b/Help/variable/CMAKE_LANG_COMPILER_ID.rst
index cd7d5cd..6a0a1d9 100644
--- a/Help/variable/CMAKE_LANG_COMPILER_ID.rst
+++ b/Help/variable/CMAKE_LANG_COMPILER_ID.rst
@@ -18,7 +18,8 @@ include:
Clang = LLVM Clang (clang.llvm.org)
Cray = Cray Compiler (cray.com)
Embarcadero, Borland = Embarcadero (embarcadero.com)
- Flang = Flang LLVM Fortran Compiler
+ Flang = Classic Flang Fortran Compiler (https://github.com/flang-compiler/flang)
+ LLVMFlang = LLVM Flang Fortran Compiler (https://github.com/llvm/llvm-project/tree/main/flang)
Fujitsu = Fujitsu HPC compiler (Trad mode)
FujitsuClang = Fujitsu HPC compiler (Clang mode)
G95 = G95 Fortran (g95.org)
diff --git a/Modules/CMakeDetermineFortranCompiler.cmake b/Modules/CMakeDetermineFortranCompiler.cmake
index 1c4b6ea..650c87a 100644
--- a/Modules/CMakeDetermineFortranCompiler.cmake
+++ b/Modules/CMakeDetermineFortranCompiler.cmake
@@ -91,6 +91,7 @@ else()
set(_Fortran_COMPILER_NAMES_Absoft af95 af90 af77)
set(_Fortran_COMPILER_NAMES_PGI pgf95 pgfortran pgf90 pgf77)
set(_Fortran_COMPILER_NAMES_Flang flang)
+ set(_Fortran_COMPILER_NAMES_LLVMFlang flang)
set(_Fortran_COMPILER_NAMES_PathScale pathf2003 pathf95 pathf90)
set(_Fortran_COMPILER_NAMES_XL xlf)
set(_Fortran_COMPILER_NAMES_VisualAge xlf95 xlf90 xlf)
diff --git a/Modules/CMakeFortranCompilerId.F.in b/Modules/CMakeFortranCompilerId.F.in
index 969c841..f5c2ab5 100644
--- a/Modules/CMakeFortranCompilerId.F.in
+++ b/Modules/CMakeFortranCompilerId.F.in
@@ -154,6 +154,13 @@
# if defined(__FLANG_PATCHLEVEL__)
# define COMPILER_VERSION_PATCH DEC(__FLANG_PATCHLEVEL__)
# endif
+#elif defined(__flang__)
+ PRINT *, 'INFO:compiler[LLVMFlang]'
+# define COMPILER_VERSION_MAJOR DEC(__flang_major__)
+# define COMPILER_VERSION_MINOR DEC(__flang_minor__)
+# if defined(__flang_patchlevel__)
+# define COMPILER_VERSION_PATCH DEC(__flang_patchlevel__)
+# endif
#elif defined(_AIX) || defined(__AIX) || defined(__AIX__) || defined(__aix) || defined(__aix__)
PRINT *, 'INFO:compiler[VisualAge]'
#elif defined(__hpux) || defined(__hpux__)
diff --git a/Modules/CPackComponent.cmake b/Modules/CPackComponent.cmake
index 1f8c38c..8ca9f28 100644
--- a/Modules/CPackComponent.cmake
+++ b/Modules/CPackComponent.cmake
@@ -327,32 +327,34 @@ OS X.
if(NOT CPackComponent_CMake_INCLUDED)
set(CPackComponent_CMake_INCLUDED 1)
-# Macro that appends a SET command for the given variable name (var)
-# to the macro named strvar, but only if the variable named "var"
+# Function that appends a SET command for the given variable name (var)
+# to the string named strvar, but only if the variable named "var"
# has been defined. The string will eventually be appended to a CPack
# configuration file.
-macro(cpack_append_variable_set_command var strvar)
+function(cpack_append_variable_set_command var strvar)
if (DEFINED ${var})
string(APPEND ${strvar} "set(${var}")
foreach(APPENDVAL ${${var}})
string(APPEND ${strvar} " ${APPENDVAL}")
endforeach()
string(APPEND ${strvar} ")\n")
+ set(${strvar} "${${strvar}}" PARENT_SCOPE)
endif ()
-endmacro()
+endfunction()
-# Macro that appends a SET command for the given variable name (var)
-# to the macro named strvar, but only if the variable named "var"
+# Function that appends a SET command for the given variable name (var)
+# to the string named strvar, but only if the variable named "var"
# has been defined and is a string. The string will eventually be
# appended to a CPack configuration file.
-macro(cpack_append_string_variable_set_command var strvar)
+function(cpack_append_string_variable_set_command var strvar)
if (DEFINED ${var})
list(LENGTH ${var} CPACK_APP_VALUE_LEN)
if(${CPACK_APP_VALUE_LEN} EQUAL 1)
string(APPEND ${strvar} "set(${var} \"${${var}}\")\n")
endif()
+ set(${strvar} "${${strvar}}" PARENT_SCOPE)
endif ()
-endmacro()
+endfunction()
# Macro that appends a SET command for the given list variable name (var)
# to the macro named strvar, but only if the variable named "var"
diff --git a/Modules/Compiler/LLVMFlang-Fortran.cmake b/Modules/Compiler/LLVMFlang-Fortran.cmake
new file mode 100644
index 0000000..7e9ba5e
--- /dev/null
+++ b/Modules/Compiler/LLVMFlang-Fortran.cmake
@@ -0,0 +1,13 @@
+set(CMAKE_Fortran_SUBMODULE_SEP "-")
+set(CMAKE_Fortran_SUBMODULE_EXT ".mod")
+
+set(CMAKE_Fortran_PREPROCESS_SOURCE
+ "<CMAKE_Fortran_COMPILER> -cpp <DEFINES> <INCLUDES> <FLAGS> -E <SOURCE> > <PREPROCESSED_SOURCE>")
+
+set(CMAKE_Fortran_FORMAT_FIXED_FLAG "-ffixed-form")
+set(CMAKE_Fortran_FORMAT_FREE_FLAG "-ffree-form")
+
+set(CMAKE_Fortran_MODDIR_FLAG "-module-dir")
+
+set(CMAKE_Fortran_COMPILE_OPTIONS_PREPROCESS_ON "-cpp")
+set(CMAKE_Fortran_COMPILE_OPTIONS_PREPROCESS_OFF "-nocpp")
diff --git a/Modules/FetchContent.cmake b/Modules/FetchContent.cmake
index a342aa7..5ca296e 100644
--- a/Modules/FetchContent.cmake
+++ b/Modules/FetchContent.cmake
@@ -193,6 +193,11 @@ Commands
``OVERRIDE_FIND_PACKAGE`` cannot be used when ``FIND_PACKAGE_ARGS`` is
given.
+ :ref:`dependency_providers` discusses another way that
+ :command:`FetchContent_MakeAvailable` calls can be redirected.
+ ``FIND_PACKAGE_ARGS`` is intended for project control, whereas
+ dependency providers allow users to override project behavior.
+
``OVERRIDE_FIND_PACKAGE``
When a ``FetchContent_Declare(<name> ...)`` call includes this option,
subsequent calls to ``find_package(<name> ...)`` will ensure that
@@ -204,6 +209,13 @@ Commands
satisfy the package requirements of the latter. ``FIND_PACKAGE_ARGS``
cannot be used when ``OVERRIDE_FIND_PACKAGE`` is given.
+ If a :ref:`dependency provider <dependency_providers>` has been set
+ and the project calls :command:`find_package` for the ``<name>``
+ dependency, ``OVERRIDE_FIND_PACKAGE`` will not prevent the provider
+ from seeing that call. Dependency providers always have the opportunity
+ to intercept any direct call to :command:`find_package`, except if that
+ call contains the ``BYPASS_PROVIDER`` option.
+
.. command:: FetchContent_MakeAvailable
.. versionadded:: 3.14
@@ -217,17 +229,35 @@ Commands
:command:`FetchContent_Declare` for each dependency, and the first such call
will control how that dependency will be made available, as described below.
- .. versionadded:: 3.24
- If permitted, :command:`find_package(<name> [<args>...]) <find_package>`
- will be called, where ``<args>...`` may be provided by the
- ``FIND_PACKAGE_ARGS`` option in :command:`FetchContent_Declare`.
- The value of the :variable:`FETCHCONTENT_TRY_FIND_PACKAGE_MODE` variable
- at the time :command:`FetchContent_Declare` was called determines whether
- ``FetchContent_MakeAvailable()`` can call :command:`find_package`.
+ If ``<lowercaseName>_SOURCE_DIR`` is not set:
+
+ * .. versionadded:: 3.24
+
+ If a :ref:`dependency provider <dependency_providers>` is set, call the
+ provider's command with ``FETCHCONTENT_MAKEAVAILABLE_SERIAL`` as the
+ first argument, followed by the arguments of the first call to
+ :command:`FetchContent_Declare` for ``<name>``. If ``SOURCE_DIR`` or
+ ``BINARY_DIR`` were not part of the original declared arguments, they
+ will be added with their default values.
+ If :variable:`FETCHCONTENT_TRY_FIND_PACKAGE_MODE` was set to ``NEVER``
+ when the details were declared, any ``FIND_PACKAGE_ARGS`` will be
+ omitted. The ``OVERRIDE_FIND_PACKAGE`` keyword is also always omitted.
+ If the provider fulfilled the request, ``FetchContent_MakeAvailable()``
+ will consider that dependency handled, skip the remaining steps below
+ and move on to the next dependency in the list.
+
+ * .. versionadded:: 3.24
- If :command:`find_package` was unsuccessful or was not allowed to be called,
- ``FetchContent_MakeAvailable()`` then uses the following logic to make the
- dependency available:
+ If permitted, :command:`find_package(<name> [<args>...]) <find_package>`
+ will be called, where ``<args>...`` may be provided by the
+ ``FIND_PACKAGE_ARGS`` option in :command:`FetchContent_Declare`.
+ The value of the :variable:`FETCHCONTENT_TRY_FIND_PACKAGE_MODE` variable
+ at the time :command:`FetchContent_Declare` was called determines whether
+ ``FetchContent_MakeAvailable()`` can call :command:`find_package`.
+
+ If the dependency was not satisfied by a provider or a
+ :command:`find_package` call, ``FetchContent_MakeAvailable()`` then uses
+ the following logic to make the dependency available:
* If the dependency has already been populated earlier in this run, set
the ``<lowercaseName>_POPULATED``, ``<lowercaseName>_SOURCE_DIR`` and
@@ -468,7 +498,7 @@ Commands
When using saved content details, a call to
:command:`FetchContent_MakeAvailable` or :command:`FetchContent_Populate`
records information in global properties which can be queried at any time.
- This information includes the source and binary directories associated with
+ This information may include the source and binary directories associated with
the content and also whether or not the content population has been processed
during the current configure run.
@@ -488,6 +518,8 @@ Commands
set the same variables as a call to
:command:`FetchContent_MakeAvailable(name) <FetchContent_MakeAvailable>` or
:command:`FetchContent_Populate(name) <FetchContent_Populate>`.
+ Note that the ``SOURCE_DIR`` and ``BINARY_DIR`` values can be empty if the
+ call is fulfilled by a :ref:`dependency provider <dependency_providers>`.
This command is rarely needed when using
:command:`FetchContent_MakeAvailable`. It is more commonly used as part of
@@ -511,6 +543,33 @@ Commands
add_subdirectory(${depname_SOURCE_DIR} ${depname_BINARY_DIR})
endif()
+.. command:: FetchContent_SetPopulated
+
+ .. versionadded:: 3.24
+
+ .. note::
+ This command should only be called by
+ :ref:`dependency providers <dependency_providers>`. Calling it in any
+ other context is unsupported and future CMake versions may halt with a
+ fatal error in such cases.
+
+ .. code-block:: cmake
+
+ FetchContent_SetPopulated(
+ <name>
+ [SOURCE_DIR <srcDir>]
+ [BINARY_DIR <binDir>]
+ )
+
+ If a provider command fulfills a ``FETCHCONTENT_MAKEAVAILABLE_SERIAL``
+ request, it must call this function before returning. The ``SOURCE_DIR``
+ and ``BINARY_DIR`` arguments can be used to specify the values that
+ :command:`FetchContent_GetProperties` should return for its corresponding
+ arguments. Only provide ``SOURCE_DIR`` and ``BINARY_DIR`` if they have
+ the same meaning as if they had been populated by the built-in
+ :command:`FetchContent_MakeAvailable` implementation.
+
+
Variables
^^^^^^^^^
@@ -588,7 +647,7 @@ A number of cache variables can influence the behavior where details from a
behavior if ``FETCHCONTENT_TRY_FIND_PACKAGE_MODE`` is not set.
``ALWAYS``
- :command:`find_package` will be called by
+ :command:`find_package` can be called by
:command:`FetchContent_MakeAvailable` regardless of whether the
:command:`FetchContent_Declare` call included a ``FIND_PACKAGE_ARGS``
keyword or not. If no ``FIND_PACKAGE_ARGS`` keyword was given, the
@@ -1099,14 +1158,26 @@ function(FetchContent_Declare contentName)
endif()
set(options "")
- set(oneValueArgs SVN_REPOSITORY)
+ set(oneValueArgs
+ BINARY_DIR
+ SOURCE_DIR
+ SVN_REPOSITORY
+ )
set(multiValueArgs "")
cmake_parse_arguments(PARSE_ARGV 1 ARG
"${options}" "${oneValueArgs}" "${multiValueArgs}")
- unset(srcDirSuffix)
- unset(svnRepoArgs)
+ string(TOLOWER ${contentName} contentNameLower)
+
+ if(NOT ARG_BINARY_DIR)
+ set(ARG_BINARY_DIR "${FETCHCONTENT_BASE_DIR}/${contentNameLower}-build")
+ endif()
+
+ if(NOT ARG_SOURCE_DIR)
+ set(ARG_SOURCE_DIR "${FETCHCONTENT_BASE_DIR}/${contentNameLower}-src")
+ endif()
+
if(ARG_SVN_REPOSITORY)
# Add a hash of the svn repository URL to the source dir. This works
# around the problem where if the URL changes, the download would
@@ -1116,25 +1187,21 @@ function(FetchContent_Declare contentName)
# problem on windows due to path length limits).
string(SHA1 urlSHA ${ARG_SVN_REPOSITORY})
string(SUBSTRING ${urlSHA} 0 7 urlSHA)
- set(srcDirSuffix "-${urlSHA}")
- set(svnRepoArgs SVN_REPOSITORY ${ARG_SVN_REPOSITORY})
+ string(APPEND ARG_SOURCE_DIR "-${urlSHA}")
+ list(PREPEND ARG_UNPARSED_ARGUMENTS SVN_REPOSITORY "${ARG_SVN_REPOSITORY}")
endif()
- string(TOLOWER ${contentName} contentNameLower)
+ list(PREPEND ARG_UNPARSED_ARGUMENTS
+ SOURCE_DIR "${ARG_SOURCE_DIR}"
+ BINARY_DIR "${ARG_BINARY_DIR}"
+ )
set(__argsQuoted)
foreach(__item IN LISTS ARG_UNPARSED_ARGUMENTS)
string(APPEND __argsQuoted " [==[${__item}]==]")
endforeach()
- cmake_language(EVAL CODE "
- __FetchContent_declareDetails(
- ${contentNameLower}
- SOURCE_DIR \"${FETCHCONTENT_BASE_DIR}/${contentNameLower}-src${srcDirSuffix}\"
- BINARY_DIR \"${FETCHCONTENT_BASE_DIR}/${contentNameLower}-build\"
- \${svnRepoArgs}
- # List these last so they can override things we set above
- ${__argsQuoted}
- )"
+ cmake_language(EVAL CODE
+ "__FetchContent_declareDetails(${contentNameLower} ${__argsQuoted})"
)
endfunction()
@@ -1145,11 +1212,11 @@ endfunction()
# The setter also records the source and binary dirs used.
#=======================================================================
-# Internal use, projects must not call this directly. It is intended
-# for use by things like the FetchContent_Populate() function to
-# record when FetchContent_Populate() is called for a particular
-# content name.
-function(__FetchContent_setPopulated contentName)
+# Semi-internal use. Projects must not call this directly. Dependency
+# providers must call it if they satisfy a request made with the
+# FETCHCONTENT_MAKEAVAILABLE_SERIAL method (that is the only permitted
+# place to call it outside of the FetchContent module).
+function(FetchContent_SetPopulated contentName)
cmake_parse_arguments(PARSE_ARGV 1 arg
""
@@ -1165,10 +1232,18 @@ function(__FetchContent_setPopulated contentName)
set(propertyName "${prefix}_sourceDir")
define_property(GLOBAL PROPERTY ${propertyName})
+ if("${arg_SOURCE_DIR}" STREQUAL "")
+ # Don't discard a previously provided SOURCE_DIR
+ get_property(arg_SOURCE_DIR GLOBAL PROPERTY ${propertyName})
+ endif()
set_property(GLOBAL PROPERTY ${propertyName} "${arg_SOURCE_DIR}")
set(propertyName "${prefix}_binaryDir")
define_property(GLOBAL PROPERTY ${propertyName})
+ if("${arg_BINARY_DIR}" STREQUAL "")
+ # Don't discard a previously provided BINARY_DIR
+ get_property(arg_BINARY_DIR GLOBAL PROPERTY ${propertyName})
+ endif()
set_property(GLOBAL PROPERTY ${propertyName} "${arg_BINARY_DIR}")
set(propertyName "${prefix}_populated")
@@ -1480,7 +1555,8 @@ function(FetchContent_Populate contentName)
if(${contentNameLower}_POPULATED)
if("${${contentNameLower}_SOURCE_DIR}" STREQUAL "")
message(FATAL_ERROR
- "Content ${contentName} already populated by find_package()"
+ "Content ${contentName} already populated by find_package() or a "
+ "dependency provider"
)
else()
message(FATAL_ERROR
@@ -1584,7 +1660,7 @@ function(FetchContent_Populate contentName)
)
endif()
- __FetchContent_setPopulated(
+ FetchContent_SetPopulated(
${contentName}
SOURCE_DIR "${${contentNameLower}_SOURCE_DIR}"
BINARY_DIR "${${contentNameLower}_BINARY_DIR}"
@@ -1654,22 +1730,98 @@ endfunction()
# calls will be available to the caller.
macro(FetchContent_MakeAvailable)
+ get_property(__cmake_providerCommand GLOBAL PROPERTY
+ __FETCHCONTENT_MAKEAVAILABLE_SERIAL_PROVIDER
+ )
foreach(__cmake_contentName IN ITEMS ${ARGV})
string(TOLOWER ${__cmake_contentName} __cmake_contentNameLower)
# If user specified FETCHCONTENT_SOURCE_DIR_... for this dependency, that
- # overrides everything else and we shouldn't try to use find_package().
+ # overrides everything else and we shouldn't try to use find_package() or
+ # a dependency provider.
string(TOUPPER ${__cmake_contentName} __cmake_contentNameUpper)
if("${FETCHCONTENT_SOURCE_DIR_${__cmake_contentNameUpper}}" STREQUAL "")
+ # Dependency provider gets first opportunity, but prevent infinite
+ # recursion if we are called again for the same thing
+ if(NOT "${__cmake_providerCommand}" STREQUAL "" AND
+ NOT DEFINED __cmake_fcProvider_${__cmake_contentNameLower})
+ message(VERBOSE
+ "Trying FETCHCONTENT_MAKEAVAILABLE_SERIAL dependency provider for "
+ "${__cmake_contentName}"
+ )
+ # It's still valid if there are no saved details. The project may have
+ # been written to assume a dependency provider is always set and will
+ # provide dependencies without having any declared details for them.
+ __FetchContent_getSavedDetails(${__cmake_contentName} __cmake_contentDetails)
+ set(__cmake_providerArgs
+ "FETCHCONTENT_MAKEAVAILABLE_SERIAL"
+ "${__cmake_contentName}"
+ )
+ # Empty arguments must be preserved because of things like
+ # GIT_SUBMODULES (see CMP0097)
+ foreach(__cmake_item IN LISTS __cmake_contentDetails)
+ string(APPEND __cmake_providerArgs " [==[${__cmake_item}]==]")
+ endforeach()
+
+ # This property might be defined but empty. As long as it is defined,
+ # find_package() can be called.
+ get_property(__cmake_addfpargs GLOBAL PROPERTY
+ _FetchContent_${contentNameLower}_find_package_args
+ DEFINED
+ )
+ if(__cmake_addfpargs)
+ get_property(__cmake_fpargs GLOBAL PROPERTY
+ _FetchContent_${contentNameLower}_find_package_args
+ )
+ string(APPEND __cmake_providerArgs " FIND_PACKAGE_ARGS")
+ foreach(__cmake_item IN LISTS __cmake_fpargs)
+ string(APPEND __cmake_providerArgs " [==[${__cmake_item}]==]")
+ endforeach()
+ endif()
+
+ # Calling the provider could lead to FetchContent_MakeAvailable() being
+ # called for a nested dependency. That nested call may occur in the
+ # current variable scope. We have to save and restore the variables we
+ # need preserved.
+ list(APPEND __cmake_fcCurrentVarsStack
+ ${__cmake_contentName}
+ ${__cmake_contentNameLower}
+ )
+
+ set(__cmake_fcProvider_${__cmake_contentNameLower} YES)
+ cmake_language(EVAL CODE "${__cmake_providerCommand}(${__cmake_providerArgs})")
+ unset(__cmake_fcProvider_${__cmake_contentNameLower})
+
+ list(POP_BACK __cmake_fcCurrentVarsStack
+ __cmake_contentNameLower
+ __cmake_contentName
+ )
+
+ unset(__cmake_providerArgs)
+ unset(__cmake_addfpargs)
+ unset(__cmake_fpargs)
+ unset(__cmake_item)
+ unset(__cmake_contentDetails)
+
+ FetchContent_GetProperties(${__cmake_contentName})
+ if(${__cmake_contentNameLower}_POPULATED)
+ continue()
+ endif()
+ endif()
+
# Check if we've been asked to try find_package() first, even if we
# have already populated this dependency. If we previously tried to
# use find_package() for this and it succeeded, those things might
# no longer be in scope, so we have to do it again.
- set(__cmake_fpArgsPropName "_FetchContent_${__cmake_contentNameLower}_find_package_args")
- get_property(__cmake_haveFpArgs GLOBAL PROPERTY ${__cmake_fpArgsPropName} DEFINED)
+ get_property(__cmake_haveFpArgs GLOBAL PROPERTY
+ _FetchContent_${__cmake_contentNameLower}_find_package_args DEFINED
+ )
if(__cmake_haveFpArgs)
+ unset(__cmake_haveFpArgs)
message(VERBOSE "Trying find_package(${__cmake_contentName} ...) before FetchContent")
- get_property(__cmake_fpArgs GLOBAL PROPERTY ${__cmake_fpArgsPropName})
+ get_property(__cmake_fpArgs GLOBAL PROPERTY
+ _FetchContent_${__cmake_contentNameLower}_find_package_args
+ )
# This call could lead to FetchContent_MakeAvailable() being called for
# a nested dependency and it may occur in the current variable scope.
@@ -1683,15 +1835,16 @@ macro(FetchContent_MakeAvailable)
__cmake_contentNameLower
__cmake_contentName
)
+ unset(__cmake_fpArgs)
if(${__cmake_contentName}_FOUND)
- set(${__cmake_contentNameLower}_SOURCE_DIR "")
- set(${__cmake_contentNameLower}_BINARY_DIR "")
- set(${__cmake_contentNameLower}_POPULATED TRUE)
- __FetchContent_setPopulated(${__cmake_contentName})
+ FetchContent_SetPopulated(${__cmake_contentName})
+ FetchContent_GetProperties(${__cmake_contentName})
continue()
endif()
endif()
+ else()
+ unset(__cmake_haveFpArgs)
endif()
FetchContent_GetProperties(${__cmake_contentName})
@@ -1731,5 +1884,7 @@ macro(FetchContent_MakeAvailable)
# clear local variables to prevent leaking into the caller's scope
unset(__cmake_contentName)
unset(__cmake_contentNameLower)
+ unset(__cmake_contentNameUpper)
+ unset(__cmake_providerCommand)
endmacro()
diff --git a/Modules/FindVulkan.cmake b/Modules/FindVulkan.cmake
index 7a32c2f..8b322ed 100644
--- a/Modules/FindVulkan.cmake
+++ b/Modules/FindVulkan.cmake
@@ -17,6 +17,7 @@ Optional COMPONENTS
This module respects several optional COMPONENTS: ``glslc``,
``glslangValidator``, ``glslang``, ``shaderc_combined`` and ``SPIRV-Tools``.
+On macOS, an additional component ``MoltenVK`` is available.
There are corresponding import targets for each of these flags.
IMPORTED Targets
@@ -63,6 +64,12 @@ This module defines :prop_tgt:`IMPORTED` targets if Vulkan has been found:
Defined if SDK has the Khronos library to process SPIR-V modules
(SPIRV-Tools).
+``Vulkan::MoltenVK``
+ .. versionadded:: 3.24
+
+ Defined if SDK has the Khronos library which implement a subset of Vulkan API
+ over Apple Metal graphics framework. (MoltenVK).
+
Result Variables
^^^^^^^^^^^^^^^^
@@ -98,6 +105,10 @@ This module defines the following variables:
.. versionadded:: 3.24
True, if the SDK has the SPIRV-Tools library.
+``Vulkan_MoltenVK_FOUND``
+ .. versionadded:: 3.24
+
+ True, if the SDK has the MoltenVK library.
The module will also defines these cache variables:
@@ -121,6 +132,10 @@ The module will also defines these cache variables:
.. versionadded:: 3.24
Path to the SPIRV-Tools library.
+``Vulkan_MoltenVK_LIBRARY``
+ .. versionadded:: 3.24
+
+ Path to the MoltenVK library.
Hints
^^^^^
@@ -181,6 +196,28 @@ else()
"$ENV{VULKAN_SDK}/lib"
)
endif()
+if(APPLE AND DEFINED ENV{VULKAN_SDK})
+ cmake_path(SET _MoltenVK_path NORMALIZE "$ENV{VULKAN_SDK}/../MoltenVK")
+ if(EXISTS "${_MoltenVK_path}")
+ list(APPEND _Vulkan_hint_include_search_paths
+ "${_MoltenVK_path}/include"
+ )
+ if(CMAKE_SYSTEM_NAME STREQUAL "iOS")
+ list(APPEND _Vulkan_hint_library_search_paths
+ "${_MoltenVK_path}/dylib/iOS"
+ )
+ elseif(CMAKE_SYSTEM_NAME STREQUAL "tvOS")
+ list(APPEND _Vulkan_hint_library_search_paths
+ "${_MoltenVK_path}/dylib/tvOS"
+ )
+ else()
+ list(APPEND _Vulkan_hint_library_search_paths
+ "${_MoltenVK_path}/dylib/macOS"
+ )
+ endif()
+ endif()
+ unset(_MoltenVK_path)
+endif()
find_path(Vulkan_INCLUDE_DIR
NAMES vulkan/vulkan.h
@@ -323,6 +360,20 @@ if(SPIRV-Tools IN_LIST Vulkan_FIND_COMPONENTS)
${_Vulkan_hint_library_search_paths})
mark_as_advanced(Vulkan_SPIRV-Tools_DEBUG_LIBRARY)
endif()
+if(MoltenVK IN_LIST Vulkan_FIND_COMPONENTS)
+ find_library(Vulkan_MoltenVK_LIBRARY
+ NAMES MoltenVK
+ HINTS
+ ${_Vulkan_hint_library_search_paths})
+ mark_as_advanced(Vulkan_MoltenVK_LIBRARY)
+
+ find_path(Vulkan_MoltenVK_INCLUDE_DIR
+ NAMES MoltenVK/mvk_vulkan.h
+ HINTS
+ ${_Vulkan_hint_include_search_paths}
+ )
+ mark_as_advanced(Vulkan_MoltenVK_INCLUDE_DIR)
+endif()
if(Vulkan_GLSLC_EXECUTABLE)
set(Vulkan_glslc_FOUND TRUE)
@@ -387,6 +438,12 @@ _Vulkan_set_library_component_found(glslang
_Vulkan_set_library_component_found(shaderc_combined)
_Vulkan_set_library_component_found(SPIRV-Tools)
+if(Vulkan_MoltenVK_INCLUDE_DIR AND Vulkan_MoltenVK_LIBRARY)
+ set(Vulkan_MoltenVK_FOUND TRUE)
+else()
+ set(Vulkan_MoltenVK_FOUND FALSE)
+endif()
+
set(Vulkan_LIBRARIES ${Vulkan_LIBRARY})
set(Vulkan_INCLUDE_DIRS ${Vulkan_INCLUDE_DIR})
@@ -409,6 +466,25 @@ if(Vulkan_INCLUDE_DIR)
endif()
endif()
+if(Vulkan_MoltenVK_FOUND)
+ set(Vulkan_MoltenVK_VERSION "")
+ if(Vulkan_MoltenVK_INCLUDE_DIR)
+ set(VK_MVK_MOLTENVK_H ${Vulkan_MoltenVK_INCLUDE_DIR}/MoltenVK/vk_mvk_moltenvk.h)
+ if(EXISTS ${VK_MVK_MOLTENVK_H})
+ file(STRINGS ${VK_MVK_MOLTENVK_H} _Vulkan_MoltenVK_VERSION_MAJOR REGEX "^#define MVK_VERSION_MAJOR ")
+ string(REGEX MATCHALL "[0-9]+" _Vulkan_MoltenVK_VERSION_MAJOR "${_Vulkan_MoltenVK_VERSION_MAJOR}")
+ file(STRINGS ${VK_MVK_MOLTENVK_H} _Vulkan_MoltenVK_VERSION_MINOR REGEX "^#define MVK_VERSION_MINOR ")
+ string(REGEX MATCHALL "[0-9]+" _Vulkan_MoltenVK_VERSION_MINOR "${_Vulkan_MoltenVK_VERSION_MINOR}")
+ file(STRINGS ${VK_MVK_MOLTENVK_H} _Vulkan_MoltenVK_VERSION_PATCH REGEX "^#define MVK_VERSION_PATCH ")
+ string(REGEX MATCHALL "[0-9]+" _Vulkan_MoltenVK_VERSION_PATCH "${_Vulkan_MoltenVK_VERSION_PATCH}")
+ set(Vulkan_MoltenVK_VERSION "${_Vulkan_MoltenVK_VERSION_MAJOR}.${_Vulkan_MoltenVK_VERSION_MINOR}.${_Vulkan_MoltenVK_VERSION_PATCH}")
+ unset(_Vulkan_MoltenVK_VERSION_MAJOR)
+ unset(_Vulkan_MoltenVK_VERSION_MINOR)
+ unset(_Vulkan_MoltenVK_VERSION_PATCH)
+ endif()
+ endif()
+endif()
+
include(${CMAKE_CURRENT_LIST_DIR}/FindPackageHandleStandardArgs.cmake)
find_package_handle_standard_args(Vulkan
REQUIRED_VARS
@@ -649,6 +725,17 @@ if(Vulkan_FOUND)
endif()
endif()
+if(Vulkan_MoltenVK_FOUND)
+ if(Vulkan_MoltenVK_LIBRARY AND NOT TARGET Vulkan::MoltenVK)
+ add_library(Vulkan::MoltenVK SHARED IMPORTED)
+ set_target_properties(Vulkan::MoltenVK
+ PROPERTIES
+ INTERFACE_INCLUDE_DIRECTORIES "${Vulkan_MoltenVK_INCLUDE_DIR}"
+ IMPORTED_LOCATION "${Vulkan_MoltenVK_LIBRARY}"
+ )
+ endif()
+endif()
+
unset(_Vulkan_library_name)
unset(_Vulkan_hint_include_search_paths)
unset(_Vulkan_hint_executable_search_paths)
diff --git a/Source/CMakeLists.txt b/Source/CMakeLists.txt
index 2deaaaa..95b07cb 100644
--- a/Source/CMakeLists.txt
+++ b/Source/CMakeLists.txt
@@ -199,6 +199,7 @@ set(SRCS
cmCustomCommandTypes.h
cmDefinitions.cxx
cmDefinitions.h
+ cmDependencyProvider.h
cmDepends.cxx
cmDepends.h
cmDependsC.cxx
diff --git a/Source/CMakeVersion.cmake b/Source/CMakeVersion.cmake
index 3b258cd..b832307 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 20220524)
+set(CMake_VERSION_PATCH 20220526)
#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/cmCMakeLanguageCommand.cxx b/Source/cmCMakeLanguageCommand.cxx
index 27d8cb8..7d05e88 100644
--- a/Source/cmCMakeLanguageCommand.cxx
+++ b/Source/cmCMakeLanguageCommand.cxx
@@ -13,11 +13,14 @@
#include <cm/string_view>
#include <cmext/string_view>
+#include "cmArgumentParser.h"
+#include "cmDependencyProvider.h"
#include "cmExecutionStatus.h"
#include "cmGlobalGenerator.h"
#include "cmListFileCache.h"
#include "cmMakefile.h"
#include "cmRange.h"
+#include "cmState.h"
#include "cmStringAlgorithms.h"
#include "cmSystemTools.h"
@@ -215,6 +218,91 @@ bool cmCMakeLanguageCommandEVAL(std::vector<cmListFileArgument> const& args,
return makefile.ReadListFileAsString(
code, cmStrCat(context.FilePath, ":", context.Line, ":EVAL"));
}
+
+bool cmCMakeLanguageCommandSET_DEPENDENCY_PROVIDER(
+ std::vector<std::string> const& args, cmExecutionStatus& status)
+{
+ cmState* state = status.GetMakefile().GetState();
+ if (!state->InTopLevelIncludes()) {
+ return FatalError(
+ status,
+ "Dependency providers can only be set as part of the first call to "
+ "project(). More specifically, cmake_language(SET_DEPENDENCY_PROVIDER) "
+ "can only be called while the first project() command processes files "
+ "listed in CMAKE_PROJECT_TOP_LEVEL_INCLUDES.");
+ }
+
+ struct SetProviderArgs
+ {
+ std::string Command;
+ std::vector<std::string> Methods;
+ };
+
+ auto const ArgsParser =
+ cmArgumentParser<SetProviderArgs>()
+ .Bind("SET_DEPENDENCY_PROVIDER"_s, &SetProviderArgs::Command)
+ .Bind("SUPPORTED_METHODS"_s, &SetProviderArgs::Methods);
+
+ std::vector<std::string> unparsed;
+ auto parsedArgs = ArgsParser.Parse(args, &unparsed);
+
+ if (!unparsed.empty()) {
+ return FatalError(
+ status, cmStrCat("Unrecognized keyword: \"", unparsed.front(), "\""));
+ }
+
+ // We store the command that FetchContent_MakeAvailable() can call in a
+ // global (but considered internal) property. If the provider doesn't
+ // support this method, we set this property to an empty string instead.
+ // This simplifies the logic in FetchContent_MakeAvailable() and doesn't
+ // require us to define a new internal command or sub-command.
+ std::string fcmasProperty = "__FETCHCONTENT_MAKEAVAILABLE_SERIAL_PROVIDER";
+
+ if (parsedArgs.Command.empty()) {
+ if (!parsedArgs.Methods.empty()) {
+ return FatalError(status,
+ "Must specify a non-empty command name when provider "
+ "methods are given");
+ }
+ state->ClearDependencyProvider();
+ state->SetGlobalProperty(fcmasProperty, "");
+ return true;
+ }
+
+ cmState::Command command = state->GetCommand(parsedArgs.Command);
+ if (!command) {
+ return FatalError(status,
+ cmStrCat("Command \"", parsedArgs.Command,
+ "\" is not a defined command"));
+ }
+
+ if (parsedArgs.Methods.empty()) {
+ return FatalError(status, "Must specify at least one provider method");
+ }
+
+ bool supportsFetchContentMakeAvailableSerial = false;
+ std::vector<cmDependencyProvider::Method> methods;
+ for (auto const& method : parsedArgs.Methods) {
+ if (method == "FIND_PACKAGE") {
+ methods.emplace_back(cmDependencyProvider::Method::FindPackage);
+ } else if (method == "FETCHCONTENT_MAKEAVAILABLE_SERIAL") {
+ supportsFetchContentMakeAvailableSerial = true;
+ methods.emplace_back(
+ cmDependencyProvider::Method::FetchContentMakeAvailableSerial);
+ } else {
+ return FatalError(
+ status,
+ cmStrCat("Unknown dependency provider method \"", method, "\""));
+ }
+ }
+
+ state->SetDependencyProvider({ parsedArgs.Command, methods });
+ state->SetGlobalProperty(
+ fcmasProperty,
+ supportsFetchContentMakeAvailableSerial ? parsedArgs.Command.c_str() : "");
+
+ return true;
+}
}
bool cmCMakeLanguageCommand(std::vector<cmListFileArgument> const& args,
@@ -246,6 +334,11 @@ bool cmCMakeLanguageCommand(std::vector<cmListFileArgument> const& args,
return FatalError(status, "called with incorrect number of arguments");
}
+ if (expArgs[expArg] == "SET_DEPENDENCY_PROVIDER"_s) {
+ finishArgs();
+ return cmCMakeLanguageCommandSET_DEPENDENCY_PROVIDER(expArgs, status);
+ }
+
cm::optional<Defer> maybeDefer;
if (expArgs[expArg] == "DEFER"_s) {
++expArg; // Consume "DEFER".
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/cmDependencyProvider.h b/Source/cmDependencyProvider.h
new file mode 100644
index 0000000..a6670b4
--- /dev/null
+++ b/Source/cmDependencyProvider.h
@@ -0,0 +1,38 @@
+/* Distributed under the OSI-approved BSD 3-Clause License. See accompanying
+file Copyright.txt or https://cmake.org/licensing for details. */
+#pragma once
+
+#include "cmConfigure.h" // IWYU pragma: keep
+
+#include <algorithm>
+#include <string>
+#include <utility>
+#include <vector>
+
+class cmDependencyProvider
+{
+public:
+ enum class Method
+ {
+ FindPackage,
+ FetchContentMakeAvailableSerial,
+ };
+
+ cmDependencyProvider(std::string command, std::vector<Method> methods)
+ : Command(std::move(command))
+ , Methods(std::move(methods))
+ {
+ }
+
+ std::string const& GetCommand() const { return this->Command; }
+ std::vector<Method> const& GetMethods() const { return this->Methods; }
+ bool SupportsMethod(Method method) const
+ {
+ return std::find(this->Methods.begin(), this->Methods.end(), method) !=
+ this->Methods.end();
+ }
+
+private:
+ std::string Command;
+ std::vector<Method> Methods;
+};
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/cmFindPackageCommand.cxx b/Source/cmFindPackageCommand.cxx
index 6586c69..e41d5e4 100644
--- a/Source/cmFindPackageCommand.cxx
+++ b/Source/cmFindPackageCommand.cxx
@@ -23,6 +23,7 @@
#include "cmsys/String.h"
#include "cmAlgorithms.h"
+#include "cmDependencyProvider.h"
#include "cmListFileCache.h"
#include "cmMakefile.h"
#include "cmMessageType.h"
@@ -238,6 +239,8 @@ bool cmFindPackageCommand::InitialPass(std::vector<std::string> const& args)
const char* components_sep = "";
std::set<std::string> requiredComponents;
std::set<std::string> optionalComponents;
+ std::vector<std::pair<std::string, const char*>> componentVarDefs;
+ bool bypassProvider = false;
// Always search directly in a generated path.
this->SearchPathSuffixes.emplace_back();
@@ -268,6 +271,9 @@ bool cmFindPackageCommand::InitialPass(std::vector<std::string> const& args)
if (args[i] == "QUIET") {
this->Quiet = true;
doing = DoingNone;
+ } else if (args[i] == "BYPASS_PROVIDER") {
+ bypassProvider = true;
+ doing = DoingNone;
} else if (args[i] == "EXACT") {
this->VersionExact = true;
doing = DoingNone;
@@ -356,7 +362,7 @@ bool cmFindPackageCommand::InitialPass(std::vector<std::string> const& args)
}
std::string req_var = this->Name + "_FIND_REQUIRED_" + args[i];
- this->AddFindDefinition(req_var, isRequired);
+ componentVarDefs.emplace_back(req_var, isRequired);
// Append to the list of required components.
components += components_sep;
@@ -408,7 +414,7 @@ bool cmFindPackageCommand::InitialPass(std::vector<std::string> const& args)
return false;
}
- // Maybe choose one mode exclusively.
+ // Check and eliminate search modes not allowed by the args provided
this->UseFindModules = configArgs.empty();
this->UseConfigFiles = moduleArgs.empty();
if (!this->UseFindModules && !this->UseConfigFiles) {
@@ -543,6 +549,48 @@ bool cmFindPackageCommand::InitialPass(std::vector<std::string> const& args)
return true;
}
+ // Now choose what method(s) we will use to satisfy the request. Note that
+ // we still want all the above checking of arguments, etc. regardless of the
+ // method used. This will ensure ill-formed arguments are caught earlier,
+ // before things like dependency providers need to deal with them.
+
+ // A dependency provider (if set) gets first look before other methods.
+ // We do this before modifying the package root path stack because a
+ // provider might use methods that ignore that.
+ cmState* state = this->Makefile->GetState();
+ cmState::Command providerCommand = state->GetDependencyProviderCommand(
+ cmDependencyProvider::Method::FindPackage);
+ if (bypassProvider) {
+ if (this->DebugMode && providerCommand) {
+ this->DebugMessage(
+ "BYPASS_PROVIDER given, skipping dependency provider");
+ }
+ } else if (providerCommand) {
+ if (this->DebugMode) {
+ this->DebugMessage(cmStrCat("Trying dependency provider command: ",
+ state->GetDependencyProvider()->GetCommand(),
+ "()"));
+ }
+ std::vector<cmListFileArgument> listFileArgs(args.size() + 1);
+ listFileArgs[0] =
+ cmListFileArgument("FIND_PACKAGE", cmListFileArgument::Unquoted, 0);
+ std::transform(args.begin(), args.end(), listFileArgs.begin() + 1,
+ [](const std::string& arg) {
+ return cmListFileArgument(arg,
+ cmListFileArgument::Bracket, 0);
+ });
+ if (!providerCommand(listFileArgs, this->Status)) {
+ return false;
+ }
+ if (this->Makefile->IsOn(cmStrCat(this->Name, "_FOUND"))) {
+ if (this->DebugMode) {
+ this->DebugMessage("Package was found by the dependency provider");
+ }
+ this->AppendSuccessInformation();
+ return true;
+ }
+ }
+
{
// Allocate a PACKAGE_ROOT_PATH for the current find_package call.
this->Makefile->FindPackageRootPathStack.emplace_back();
@@ -573,7 +621,7 @@ bool cmFindPackageCommand::InitialPass(std::vector<std::string> const& args)
}
}
- this->SetModuleVariables(components);
+ this->SetModuleVariables(components, componentVarDefs);
// See if we have been told to delegate to FetchContent or some other
// redirected config package first. We have to check all names that
@@ -697,6 +745,12 @@ bool cmFindPackageCommand::InitialPass(std::vector<std::string> const& args)
this->AppendSuccessInformation();
+ // Restore original state of "_FIND_" variables set in SetModuleVariables()
+ this->RestoreFindDefinitions();
+
+ // Pop the package stack
+ this->Makefile->FindPackageRootPathStack.pop_back();
+
if (!this->DebugBuffer.empty()) {
this->DebugMessage(this->DebugBuffer);
}
@@ -778,13 +832,18 @@ void cmFindPackageCommand::SetVersionVariables(
addDefinition(prefix + "_COUNT", buf);
}
-void cmFindPackageCommand::SetModuleVariables(const std::string& components)
+void cmFindPackageCommand::SetModuleVariables(
+ const std::string& components,
+ const std::vector<std::pair<std::string, const char*>>& componentVarDefs)
{
this->AddFindDefinition("CMAKE_FIND_PACKAGE_NAME", this->Name);
- // Store the list of components.
+ // Store the list of components and associated variable definitions
std::string components_var = this->Name + "_FIND_COMPONENTS";
this->AddFindDefinition(components_var, components);
+ for (const auto& varDef : componentVarDefs) {
+ this->AddFindDefinition(varDef.first, varDef.second);
+ }
if (this->Quiet) {
// Tell the module that is about to be read that it should find
@@ -1388,12 +1447,6 @@ void cmFindPackageCommand::AppendSuccessInformation()
this->Makefile->GetState()->SetGlobalProperty(requiredInfoPropName,
"REQUIRED");
}
-
- // Restore original state of "_FIND_" variables we set.
- this->RestoreFindDefinitions();
-
- // Pop the package stack
- this->Makefile->FindPackageRootPathStack.pop_back();
}
inline std::size_t collectPathsForDebug(std::string& buffer,
diff --git a/Source/cmFindPackageCommand.h b/Source/cmFindPackageCommand.h
index 902fa32..80fd8f8 100644
--- a/Source/cmFindPackageCommand.h
+++ b/Source/cmFindPackageCommand.h
@@ -9,6 +9,7 @@
#include <map>
#include <set>
#include <string>
+#include <utility>
#include <vector>
#include <cm/string_view>
@@ -97,7 +98,9 @@ private:
const std::string& prefix, const std::string& version, unsigned int count,
unsigned int major, unsigned int minor, unsigned int patch,
unsigned int tweak);
- void SetModuleVariables(const std::string& components);
+ void SetModuleVariables(
+ const std::string& components,
+ const std::vector<std::pair<std::string, const char*>>& componentVarDefs);
bool FindModule(bool& found);
void AddFindDefinition(const std::string& var, cm::string_view value);
void RestoreFindDefinitions();
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..9d61de9 100644
--- a/Source/cmGlobalGenerator.cxx
+++ b/Source/cmGlobalGenerator.cxx
@@ -690,6 +690,7 @@ void cmGlobalGenerator::EnableLanguage(
}
// One-time includes of user-provided project setup files
+ mf->GetState()->SetInTopLevelIncludes(true);
std::string includes =
mf->GetSafeDefinition("CMAKE_PROJECT_TOP_LEVEL_INCLUDES");
std::vector<std::string> includesList = cmExpandedList(includes);
@@ -700,22 +701,26 @@ void cmGlobalGenerator::EnableLanguage(
cmSystemTools::Error(
"CMAKE_PROJECT_TOP_LEVEL_INCLUDES file does not exist: " +
setupFile);
+ mf->GetState()->SetInTopLevelIncludes(false);
return;
}
if (cmSystemTools::FileIsDirectory(absSetupFile)) {
cmSystemTools::Error(
"CMAKE_PROJECT_TOP_LEVEL_INCLUDES file is a directory: " +
setupFile);
+ mf->GetState()->SetInTopLevelIncludes(false);
return;
}
if (!mf->ReadListFile(absSetupFile)) {
cmSystemTools::Error(
"Failed reading CMAKE_PROJECT_TOP_LEVEL_INCLUDES file: " +
setupFile);
+ mf->GetState()->SetInTopLevelIncludes(false);
return;
}
}
}
+ mf->GetState()->SetInTopLevelIncludes(false);
// Check that the languages are supported by the generator and its
// native build tool found above.
@@ -1152,7 +1157,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/cmState.cxx b/Source/cmState.cxx
index f1144e1..b753373 100644
--- a/Source/cmState.cxx
+++ b/Source/cmState.cxx
@@ -1072,3 +1072,12 @@ bool cmState::ParseCacheEntry(const std::string& entry, std::string& var,
return flag;
}
+
+cmState::Command cmState::GetDependencyProviderCommand(
+ cmDependencyProvider::Method method) const
+{
+ return (this->DependencyProvider &&
+ this->DependencyProvider->SupportsMethod(method))
+ ? this->GetCommand(this->DependencyProvider->GetCommand())
+ : Command{};
+}
diff --git a/Source/cmState.h b/Source/cmState.h
index ee133fc..2d0c521 100644
--- a/Source/cmState.h
+++ b/Source/cmState.h
@@ -8,11 +8,16 @@
#include <memory>
#include <set>
#include <string>
+#include <type_traits>
#include <unordered_map>
#include <unordered_set>
+#include <utility>
#include <vector>
+#include <cm/optional>
+
#include "cmDefinitions.h"
+#include "cmDependencyProvider.h"
#include "cmLinkedTree.h"
#include "cmPolicies.h"
#include "cmProperty.h"
@@ -227,6 +232,24 @@ public:
ProjectKind GetProjectKind() const;
+ void ClearDependencyProvider() { this->DependencyProvider.reset(); }
+ void SetDependencyProvider(cmDependencyProvider provider)
+ {
+ this->DependencyProvider = std::move(provider);
+ }
+ cm::optional<cmDependencyProvider> const& GetDependencyProvider() const
+ {
+ return this->DependencyProvider;
+ }
+ Command GetDependencyProviderCommand(
+ cmDependencyProvider::Method method) const;
+
+ void SetInTopLevelIncludes(bool inTopLevelIncludes)
+ {
+ this->ProcessingTopLevelIncludes = inTopLevelIncludes;
+ }
+ bool InTopLevelIncludes() const { return this->ProcessingTopLevelIncludes; }
+
private:
friend class cmake;
void AddCacheEntry(const std::string& key, const char* value,
@@ -288,4 +311,6 @@ private:
bool NinjaMulti = false;
Mode StateMode = Unknown;
ProjectKind StateProjectKind = ProjectKind::Normal;
+ cm::optional<cmDependencyProvider> DependencyProvider;
+ bool ProcessingTopLevelIncludes = false;
};
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/FindVulkan/Test/CMakeLists.txt b/Tests/FindVulkan/Test/CMakeLists.txt
index a492daa..42543ac 100644
--- a/Tests/FindVulkan/Test/CMakeLists.txt
+++ b/Tests/FindVulkan/Test/CMakeLists.txt
@@ -3,28 +3,37 @@ cmake_policy(SET CMP0091 NEW)
project(TestFindVulkan C CXX)
include(CTest)
+set(components
+ glslang
+ shaderc_combined
+ SPIRV-Tools
+)
+if(APPLE)
+ list(APPEND components MoltenVK)
+endif()
find_package(Vulkan REQUIRED
- COMPONENTS
- glslang
- shaderc_combined
- SPIRV-Tools)
+ COMPONENTS ${components})
add_executable(test_tgt main.c)
target_link_libraries(test_tgt Vulkan::Vulkan)
+target_compile_features(test_tgt PRIVATE cxx_std_11)
add_test(NAME test_tgt COMMAND test_tgt)
add_executable(test_var main.c)
target_include_directories(test_var PRIVATE ${Vulkan_INCLUDE_DIRS})
target_link_libraries(test_var PRIVATE ${Vulkan_LIBRARIES})
+target_compile_features(test_var PRIVATE cxx_std_11)
add_test(NAME test_var COMMAND test_var)
add_executable(test_tgt_dl main-dynamicVulkanLoading.cpp)
target_link_libraries(test_tgt_dl Vulkan::Headers ${CMAKE_DL_LIBS})
+target_compile_features(test_tgt_dl PRIVATE cxx_std_11)
add_test(NAME test_tgt_dl COMMAND test_tgt_dl)
add_executable(test_var_dl main-dynamicVulkanLoading.cpp)
target_include_directories(test_var_dl PRIVATE ${Vulkan_INCLUDE_DIRS})
target_link_libraries(test_var_dl ${CMAKE_DL_LIBS})
+target_compile_features(test_var_dl PRIVATE cxx_std_11)
add_test(NAME test_var_dl COMMAND test_var_dl)
add_executable(test_tgt_glslang main-glslang.cxx)
@@ -60,6 +69,12 @@ if(NOT SPIRV-Tools_debug_location)
MSVC_RUNTIME_LIBRARY "MultiThreadedDLL")
endif()
+if(APPLE)
+ add_executable(test_tgt_MoltenVK main-MoltenVK.cxx)
+ target_link_libraries(test_tgt_MoltenVK Vulkan::MoltenVK)
+ add_test(NAME test_tgt_MoltenVK COMMAND test_tgt_MoltenVK)
+endif()
+
if(Vulkan_GLSLC_EXECUTABLE)
add_test(NAME test_glslc
COMMAND ${CMAKE_COMMAND}
diff --git a/Tests/FindVulkan/Test/main-MoltenVK.cxx b/Tests/FindVulkan/Test/main-MoltenVK.cxx
new file mode 100644
index 0000000..3156979
--- /dev/null
+++ b/Tests/FindVulkan/Test/main-MoltenVK.cxx
@@ -0,0 +1,16 @@
+#include <iostream>
+
+#include <MoltenVK/vk_mvk_moltenvk.h>
+
+int main()
+{
+ char mvk_version[256];
+ char vk_version[256];
+ vkGetVersionStringsMVK(mvk_version, sizeof(mvk_version), vk_version,
+ sizeof(vk_version));
+
+ std::cout << "MoltenVK version: " << mvk_version << std::endl;
+ std::cout << "Vulkan version: " << vk_version << std::endl;
+
+ return 0;
+}
diff --git a/Tests/RunCMake/CMakeLists.txt b/Tests/RunCMake/CMakeLists.txt
index 4fe6ac1..da91e64 100644
--- a/Tests/RunCMake/CMakeLists.txt
+++ b/Tests/RunCMake/CMakeLists.txt
@@ -461,6 +461,7 @@ add_RunCMake_test(message)
add_RunCMake_test(option)
add_RunCMake_test(project -DCMake_TEST_RESOURCES=${CMake_TEST_RESOURCES})
add_RunCMake_test(project_injected)
+add_RunCMake_test(DependencyProviders)
add_RunCMake_test(return)
add_RunCMake_test(separate_arguments)
add_RunCMake_test(set_property)
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/DependencyProviders/AfterProject-result.txt b/Tests/RunCMake/DependencyProviders/AfterProject-result.txt
new file mode 100644
index 0000000..d00491f
--- /dev/null
+++ b/Tests/RunCMake/DependencyProviders/AfterProject-result.txt
@@ -0,0 +1 @@
+1
diff --git a/Tests/RunCMake/DependencyProviders/AfterProject-stderr.txt b/Tests/RunCMake/DependencyProviders/AfterProject-stderr.txt
new file mode 100644
index 0000000..7bee23c
--- /dev/null
+++ b/Tests/RunCMake/DependencyProviders/AfterProject-stderr.txt
@@ -0,0 +1,6 @@
+CMake Error at set_provider\.cmake:[0-9]+ \(cmake_language\):
+ cmake_language Dependency providers can only be set as part of the first
+ call to project\(\)\. More specifically,
+ cmake_language\(SET_DEPENDENCY_PROVIDER\) can only be called while the first
+ project\(\) command processes files listed in
+ CMAKE_PROJECT_TOP_LEVEL_INCLUDES\.
diff --git a/Tests/RunCMake/DependencyProviders/BeforeProject-result.txt b/Tests/RunCMake/DependencyProviders/BeforeProject-result.txt
new file mode 100644
index 0000000..d00491f
--- /dev/null
+++ b/Tests/RunCMake/DependencyProviders/BeforeProject-result.txt
@@ -0,0 +1 @@
+1
diff --git a/Tests/RunCMake/DependencyProviders/BeforeProject-stderr.txt b/Tests/RunCMake/DependencyProviders/BeforeProject-stderr.txt
new file mode 100644
index 0000000..7bee23c
--- /dev/null
+++ b/Tests/RunCMake/DependencyProviders/BeforeProject-stderr.txt
@@ -0,0 +1,6 @@
+CMake Error at set_provider\.cmake:[0-9]+ \(cmake_language\):
+ cmake_language Dependency providers can only be set as part of the first
+ call to project\(\)\. More specifically,
+ cmake_language\(SET_DEPENDENCY_PROVIDER\) can only be called while the first
+ project\(\) command processes files listed in
+ CMAKE_PROJECT_TOP_LEVEL_INCLUDES\.
diff --git a/Tests/RunCMake/DependencyProviders/Bypass-stdout.txt b/Tests/RunCMake/DependencyProviders/Bypass-stdout.txt
new file mode 100644
index 0000000..b0c7e6e
--- /dev/null
+++ b/Tests/RunCMake/DependencyProviders/Bypass-stdout.txt
@@ -0,0 +1,7 @@
+-- Before cmake_language
+-- After cmake_language
+-- Forwarding find_package\(SomeDep\)
+-- Provider invoked for method FIND_PACKAGE with args: QUIET;REQUIRED
+-- SomeDepConfig\.cmake was used
+-- Leaving provider
+-- Configuring done
diff --git a/Tests/RunCMake/DependencyProviders/Bypass.cmake b/Tests/RunCMake/DependencyProviders/Bypass.cmake
new file mode 100644
index 0000000..883087e
--- /dev/null
+++ b/Tests/RunCMake/DependencyProviders/Bypass.cmake
@@ -0,0 +1 @@
+find_package(SomeDep QUIET REQUIRED)
diff --git a/Tests/RunCMake/DependencyProviders/CMakeLists.txt b/Tests/RunCMake/DependencyProviders/CMakeLists.txt
new file mode 100644
index 0000000..3552604
--- /dev/null
+++ b/Tests/RunCMake/DependencyProviders/CMakeLists.txt
@@ -0,0 +1,13 @@
+cmake_minimum_required(VERSION 3.23...3.24)
+
+if(DEFINED include_before_project)
+ include("${include_before_project}")
+endif()
+
+project(${RunCMake_TEST} NONE)
+
+if(DEFINED include_after_project)
+ include("${include_after_project}")
+endif()
+
+include(${RunCMake_TEST}.cmake OPTIONAL)
diff --git a/Tests/RunCMake/DependencyProviders/ConfigFiles/SomeDepConfig.cmake b/Tests/RunCMake/DependencyProviders/ConfigFiles/SomeDepConfig.cmake
new file mode 100644
index 0000000..e04eefe
--- /dev/null
+++ b/Tests/RunCMake/DependencyProviders/ConfigFiles/SomeDepConfig.cmake
@@ -0,0 +1,2 @@
+message(STATUS "SomeDepConfig.cmake was used")
+set(SomeDep_FOUND TRUE)
diff --git a/Tests/RunCMake/DependencyProviders/FetchContentSerial-stdout.txt b/Tests/RunCMake/DependencyProviders/FetchContentSerial-stdout.txt
new file mode 100644
index 0000000..fa4a794
--- /dev/null
+++ b/Tests/RunCMake/DependencyProviders/FetchContentSerial-stdout.txt
@@ -0,0 +1,7 @@
+-- Before cmake_language
+-- After cmake_language
+-- AThing_FOUND = 0
+-- Intercepted FetchContent_MakeAvailable\(SomeDep\)
+-- Provider invoked for method FETCHCONTENT_MAKEAVAILABLE_SERIAL with args: SOURCE_DIR;.*/Tests/RunCMake/DependencyProviders;BINARY_DIR;.*/Tests/RunCMake/DependencyProviders/FetchContentSerial-build/_deps/somedep-build;SOURCE_SUBDIR;DoesNotExist
+-- FetchContent_MakeAvailable\(\) succeeded
+-- Configuring done
diff --git a/Tests/RunCMake/DependencyProviders/FetchContentSerial.cmake b/Tests/RunCMake/DependencyProviders/FetchContentSerial.cmake
new file mode 100644
index 0000000..cbd3010
--- /dev/null
+++ b/Tests/RunCMake/DependencyProviders/FetchContentSerial.cmake
@@ -0,0 +1 @@
+include(try_methods.cmake)
diff --git a/Tests/RunCMake/DependencyProviders/FindPackage-stdout.txt b/Tests/RunCMake/DependencyProviders/FindPackage-stdout.txt
new file mode 100644
index 0000000..19c88b9
--- /dev/null
+++ b/Tests/RunCMake/DependencyProviders/FindPackage-stdout.txt
@@ -0,0 +1,7 @@
+-- Before cmake_language
+-- After cmake_language
+-- Intercepted find_package\(AThing\)
+-- Provider invoked for method FIND_PACKAGE with args: QUIET
+-- AThing_FOUND = TRUE
+-- FetchContent_MakeAvailable\(\) succeeded
+-- Configuring done
diff --git a/Tests/RunCMake/DependencyProviders/FindPackage.cmake b/Tests/RunCMake/DependencyProviders/FindPackage.cmake
new file mode 100644
index 0000000..cbd3010
--- /dev/null
+++ b/Tests/RunCMake/DependencyProviders/FindPackage.cmake
@@ -0,0 +1 @@
+include(try_methods.cmake)
diff --git a/Tests/RunCMake/DependencyProviders/NoCommand-result.txt b/Tests/RunCMake/DependencyProviders/NoCommand-result.txt
new file mode 100644
index 0000000..d00491f
--- /dev/null
+++ b/Tests/RunCMake/DependencyProviders/NoCommand-result.txt
@@ -0,0 +1 @@
+1
diff --git a/Tests/RunCMake/DependencyProviders/NoCommand-stderr.txt b/Tests/RunCMake/DependencyProviders/NoCommand-stderr.txt
new file mode 100644
index 0000000..a43222f
--- /dev/null
+++ b/Tests/RunCMake/DependencyProviders/NoCommand-stderr.txt
@@ -0,0 +1,3 @@
+CMake Error at set_provider\.cmake:[0-9]+ \(cmake_language\):
+ cmake_language Must specify a non-empty command name when provider methods
+ are given
diff --git a/Tests/RunCMake/DependencyProviders/NoCommandOrMethods-stdout.txt b/Tests/RunCMake/DependencyProviders/NoCommandOrMethods-stdout.txt
new file mode 100644
index 0000000..c53435b
--- /dev/null
+++ b/Tests/RunCMake/DependencyProviders/NoCommandOrMethods-stdout.txt
@@ -0,0 +1,3 @@
+-- Before cmake_language
+-- After cmake_language
+-- AThing_FOUND = 0
diff --git a/Tests/RunCMake/DependencyProviders/NoCommandOrMethods.cmake b/Tests/RunCMake/DependencyProviders/NoCommandOrMethods.cmake
new file mode 100644
index 0000000..bde0cf8
--- /dev/null
+++ b/Tests/RunCMake/DependencyProviders/NoCommandOrMethods.cmake
@@ -0,0 +1,3 @@
+# Force the provider to be invoked
+find_package(AThing QUIET)
+message(STATUS "AThing_FOUND = ${AThing_FOUND}")
diff --git a/Tests/RunCMake/DependencyProviders/NoMethods-result.txt b/Tests/RunCMake/DependencyProviders/NoMethods-result.txt
new file mode 100644
index 0000000..d00491f
--- /dev/null
+++ b/Tests/RunCMake/DependencyProviders/NoMethods-result.txt
@@ -0,0 +1 @@
+1
diff --git a/Tests/RunCMake/DependencyProviders/NoMethods-stderr.txt b/Tests/RunCMake/DependencyProviders/NoMethods-stderr.txt
new file mode 100644
index 0000000..6968851
--- /dev/null
+++ b/Tests/RunCMake/DependencyProviders/NoMethods-stderr.txt
@@ -0,0 +1,2 @@
+CMake Error at set_provider\.cmake:[0-9]+ \(cmake_language\):
+ cmake_language Must specify at least one provider method
diff --git a/Tests/RunCMake/DependencyProviders/PassThroughProvider-stdout.txt b/Tests/RunCMake/DependencyProviders/PassThroughProvider-stdout.txt
new file mode 100644
index 0000000..0c9303a
--- /dev/null
+++ b/Tests/RunCMake/DependencyProviders/PassThroughProvider-stdout.txt
@@ -0,0 +1,7 @@
+-- Before cmake_language
+-- After cmake_language
+-- Null provider called
+-- Provider invoked for method FIND_PACKAGE with args: AThing;QUIET
+-- AThing_FOUND = 0
+-- Null provider called
+-- Provider invoked for method FETCHCONTENT_MAKEAVAILABLE_SERIAL with args: SomeDep;SOURCE_DIR;.*/Tests/RunCMake/DependencyProviders;BINARY_DIR;.*/Tests/RunCMake/DependencyProviders/PassThroughProvider-build/_deps/somedep-build;SOURCE_SUBDIR;DoesNotExist
diff --git a/Tests/RunCMake/DependencyProviders/PassThroughProvider.cmake b/Tests/RunCMake/DependencyProviders/PassThroughProvider.cmake
new file mode 100644
index 0000000..cbd3010
--- /dev/null
+++ b/Tests/RunCMake/DependencyProviders/PassThroughProvider.cmake
@@ -0,0 +1 @@
+include(try_methods.cmake)
diff --git a/Tests/RunCMake/DependencyProviders/ProjectIncludeAfter-result.txt b/Tests/RunCMake/DependencyProviders/ProjectIncludeAfter-result.txt
new file mode 100644
index 0000000..d00491f
--- /dev/null
+++ b/Tests/RunCMake/DependencyProviders/ProjectIncludeAfter-result.txt
@@ -0,0 +1 @@
+1
diff --git a/Tests/RunCMake/DependencyProviders/ProjectIncludeAfter-stderr.txt b/Tests/RunCMake/DependencyProviders/ProjectIncludeAfter-stderr.txt
new file mode 100644
index 0000000..7bee23c
--- /dev/null
+++ b/Tests/RunCMake/DependencyProviders/ProjectIncludeAfter-stderr.txt
@@ -0,0 +1,6 @@
+CMake Error at set_provider\.cmake:[0-9]+ \(cmake_language\):
+ cmake_language Dependency providers can only be set as part of the first
+ call to project\(\)\. More specifically,
+ cmake_language\(SET_DEPENDENCY_PROVIDER\) can only be called while the first
+ project\(\) command processes files listed in
+ CMAKE_PROJECT_TOP_LEVEL_INCLUDES\.
diff --git a/Tests/RunCMake/DependencyProviders/ProjectIncludeBefore-result.txt b/Tests/RunCMake/DependencyProviders/ProjectIncludeBefore-result.txt
new file mode 100644
index 0000000..d00491f
--- /dev/null
+++ b/Tests/RunCMake/DependencyProviders/ProjectIncludeBefore-result.txt
@@ -0,0 +1 @@
+1
diff --git a/Tests/RunCMake/DependencyProviders/ProjectIncludeBefore-stderr.txt b/Tests/RunCMake/DependencyProviders/ProjectIncludeBefore-stderr.txt
new file mode 100644
index 0000000..7bee23c
--- /dev/null
+++ b/Tests/RunCMake/DependencyProviders/ProjectIncludeBefore-stderr.txt
@@ -0,0 +1,6 @@
+CMake Error at set_provider\.cmake:[0-9]+ \(cmake_language\):
+ cmake_language Dependency providers can only be set as part of the first
+ call to project\(\)\. More specifically,
+ cmake_language\(SET_DEPENDENCY_PROVIDER\) can only be called while the first
+ project\(\) command processes files listed in
+ CMAKE_PROJECT_TOP_LEVEL_INCLUDES\.
diff --git a/Tests/RunCMake/DependencyProviders/Recurse-stdout.txt b/Tests/RunCMake/DependencyProviders/Recurse-stdout.txt
new file mode 100644
index 0000000..2c2035a
--- /dev/null
+++ b/Tests/RunCMake/DependencyProviders/Recurse-stdout.txt
@@ -0,0 +1,7 @@
+-- Before cmake_language
+-- After cmake_language
+-- Intercepted FetchContent_MakeAvailable\(SomeDep\)
+-- Provider invoked for method FETCHCONTENT_MAKEAVAILABLE_SERIAL with args: SOURCE_DIR;.*/Tests/RunCMake/DependencyProviders/Recurse-build/_deps/somedep-src;BINARY_DIR;.*/Tests/RunCMake/DependencyProviders/Recurse-build/_deps/somedep-build;DOWNLOAD_COMMAND;.*/cmake(\.exe)?;-E;echo;Download command called
+.*Download command called
+.*-- Should now be handled
+-- Configuring done
diff --git a/Tests/RunCMake/DependencyProviders/Recurse.cmake b/Tests/RunCMake/DependencyProviders/Recurse.cmake
new file mode 100644
index 0000000..3a79d9c
--- /dev/null
+++ b/Tests/RunCMake/DependencyProviders/Recurse.cmake
@@ -0,0 +1,8 @@
+include(FetchContent)
+
+set(FETCHCONTENT_QUIET NO)
+
+FetchContent_Declare(SomeDep
+ DOWNLOAD_COMMAND ${CMAKE_COMMAND} -E echo "Download command called"
+)
+FetchContent_MakeAvailable(SomeDep)
diff --git a/Tests/RunCMake/DependencyProviders/RedirectFetchContentSerial-result.txt b/Tests/RunCMake/DependencyProviders/RedirectFetchContentSerial-result.txt
new file mode 100644
index 0000000..d00491f
--- /dev/null
+++ b/Tests/RunCMake/DependencyProviders/RedirectFetchContentSerial-result.txt
@@ -0,0 +1 @@
+1
diff --git a/Tests/RunCMake/DependencyProviders/RedirectFetchContentSerial-stderr.txt b/Tests/RunCMake/DependencyProviders/RedirectFetchContentSerial-stderr.txt
new file mode 100644
index 0000000..047a64b
--- /dev/null
+++ b/Tests/RunCMake/DependencyProviders/RedirectFetchContentSerial-stderr.txt
@@ -0,0 +1,11 @@
+CMake Error at set_provider\.cmake:[0-9]+ \(find_package\):
+ Could not find a package configuration file provided by "SomeDep" with any
+ of the following names:
+
+ SomeDepConfig\.cmake
+ somedep-config\.cmake
+
+ Add the installation prefix of "SomeDep" to CMAKE_PREFIX_PATH or set
+ "SomeDep_DIR" to a directory containing one of the above files\. If
+ "SomeDep" provides a separate development package or SDK, be sure it has
+ been installed\.
diff --git a/Tests/RunCMake/DependencyProviders/RedirectFetchContentSerial-stdout.txt b/Tests/RunCMake/DependencyProviders/RedirectFetchContentSerial-stdout.txt
new file mode 100644
index 0000000..a293324
--- /dev/null
+++ b/Tests/RunCMake/DependencyProviders/RedirectFetchContentSerial-stdout.txt
@@ -0,0 +1,5 @@
+-- Before cmake_language
+-- After cmake_language
+-- AThing_FOUND = 0
+-- Redirecting FetchContent_MakeAvailable\(SomeDep\) to find_package\(\)
+-- Provider invoked for method FETCHCONTENT_MAKEAVAILABLE_SERIAL with args: SOURCE_DIR;.*/Tests/RunCMake/DependencyProviders;BINARY_DIR;.*/Tests/RunCMake/DependencyProviders/RedirectFetchContentSerial-build/_deps/somedep-build;SOURCE_SUBDIR;DoesNotExist
diff --git a/Tests/RunCMake/DependencyProviders/RedirectFetchContentSerial.cmake b/Tests/RunCMake/DependencyProviders/RedirectFetchContentSerial.cmake
new file mode 100644
index 0000000..cbd3010
--- /dev/null
+++ b/Tests/RunCMake/DependencyProviders/RedirectFetchContentSerial.cmake
@@ -0,0 +1 @@
+include(try_methods.cmake)
diff --git a/Tests/RunCMake/DependencyProviders/RedirectFindPackage-stdout.txt b/Tests/RunCMake/DependencyProviders/RedirectFindPackage-stdout.txt
new file mode 100644
index 0000000..23e751d
--- /dev/null
+++ b/Tests/RunCMake/DependencyProviders/RedirectFindPackage-stdout.txt
@@ -0,0 +1,7 @@
+-- Before cmake_language
+-- After cmake_language
+-- Redirecting find_package\(AThing\) to FetchContent_MakeAvailable\(\)
+-- Provider invoked for method FIND_PACKAGE with args: QUIET
+-- AThing_FOUND = TRUE
+-- FetchContent_MakeAvailable\(\) succeeded
+-- Configuring done
diff --git a/Tests/RunCMake/DependencyProviders/RedirectFindPackage.cmake b/Tests/RunCMake/DependencyProviders/RedirectFindPackage.cmake
new file mode 100644
index 0000000..cbd3010
--- /dev/null
+++ b/Tests/RunCMake/DependencyProviders/RedirectFindPackage.cmake
@@ -0,0 +1 @@
+include(try_methods.cmake)
diff --git a/Tests/RunCMake/DependencyProviders/RunCMakeTest.cmake b/Tests/RunCMake/DependencyProviders/RunCMakeTest.cmake
new file mode 100644
index 0000000..42893d2
--- /dev/null
+++ b/Tests/RunCMake/DependencyProviders/RunCMakeTest.cmake
@@ -0,0 +1,73 @@
+include(RunCMake)
+
+run_cmake_with_options(BeforeProject
+ -D "include_before_project=set_provider.cmake"
+ -D "provider_command=null_provider"
+ -D "provider_methods=find_package"
+)
+run_cmake_with_options(AfterProject
+ -D "include_after_project=set_provider.cmake"
+ -D "provider_command=null_provider"
+ -D "provider_methods=find_package"
+)
+run_cmake_with_options(ProjectIncludeBefore
+ -D "CMAKE_PROJECT_INCLUDE_BEFORE=set_provider.cmake"
+ -D "provider_command=null_provider"
+ -D "provider_methods=find_package"
+)
+run_cmake_with_options(ProjectIncludeAfter
+ -D "CMAKE_PROJECT_INCLUDE=set_provider.cmake"
+ -D "provider_command=null_provider"
+ -D "provider_methods=find_package"
+)
+run_cmake_with_options(ToolchainFile
+ -D "CMAKE_TOOLCHAIN_FILE=set_provider.cmake"
+ -D "provider_command=null_provider"
+ -D "provider_methods=find_package"
+)
+run_cmake_with_options(NoCommand
+ -D "CMAKE_PROJECT_TOP_LEVEL_INCLUDES=set_provider.cmake"
+ -D "provider_methods=find_package"
+)
+run_cmake_with_options(NoMethods
+ -D "CMAKE_PROJECT_TOP_LEVEL_INCLUDES=set_provider.cmake"
+ -D "provider_command=null_provider"
+)
+run_cmake_with_options(NoCommandOrMethods
+ -D "CMAKE_PROJECT_TOP_LEVEL_INCLUDES=set_provider.cmake"
+)
+run_cmake_with_options(PassThroughProvider
+ -D "CMAKE_PROJECT_TOP_LEVEL_INCLUDES=set_provider.cmake"
+ -D "provider_command=null_provider"
+ -D "provider_methods=FIND_PACKAGE\\;FETCHCONTENT_MAKEAVAILABLE_SERIAL"
+)
+run_cmake_with_options(FindPackage
+ -D "CMAKE_PROJECT_TOP_LEVEL_INCLUDES=set_provider.cmake"
+ -D "provider_command=find_package_provider"
+ -D "provider_methods=FIND_PACKAGE"
+)
+run_cmake_with_options(RedirectFindPackage
+ -D "CMAKE_PROJECT_TOP_LEVEL_INCLUDES=set_provider.cmake"
+ -D "provider_command=redirect_find_package_provider"
+ -D "provider_methods=FIND_PACKAGE"
+)
+run_cmake_with_options(FetchContentSerial
+ -D "CMAKE_PROJECT_TOP_LEVEL_INCLUDES=set_provider.cmake"
+ -D "provider_command=FetchContentSerial_provider"
+ -D "provider_methods=FETCHCONTENT_MAKEAVAILABLE_SERIAL"
+)
+run_cmake_with_options(RedirectFetchContentSerial
+ -D "CMAKE_PROJECT_TOP_LEVEL_INCLUDES=set_provider.cmake"
+ -D "provider_command=redirect_FetchContentSerial_provider"
+ -D "provider_methods=FETCHCONTENT_MAKEAVAILABLE_SERIAL"
+)
+run_cmake_with_options(Bypass
+ -D "CMAKE_PROJECT_TOP_LEVEL_INCLUDES=set_provider.cmake"
+ -D "provider_command=forward_find_package"
+ -D "provider_methods=FIND_PACKAGE"
+)
+run_cmake_with_options(Recurse
+ -D "CMAKE_PROJECT_TOP_LEVEL_INCLUDES=set_provider.cmake"
+ -D "provider_command=recurse_FetchContent"
+ -D "provider_methods=FETCHCONTENT_MAKEAVAILABLE_SERIAL"
+)
diff --git a/Tests/RunCMake/DependencyProviders/ToolchainFile-result.txt b/Tests/RunCMake/DependencyProviders/ToolchainFile-result.txt
new file mode 100644
index 0000000..d00491f
--- /dev/null
+++ b/Tests/RunCMake/DependencyProviders/ToolchainFile-result.txt
@@ -0,0 +1 @@
+1
diff --git a/Tests/RunCMake/DependencyProviders/ToolchainFile-stderr.txt b/Tests/RunCMake/DependencyProviders/ToolchainFile-stderr.txt
new file mode 100644
index 0000000..7bee23c
--- /dev/null
+++ b/Tests/RunCMake/DependencyProviders/ToolchainFile-stderr.txt
@@ -0,0 +1,6 @@
+CMake Error at set_provider\.cmake:[0-9]+ \(cmake_language\):
+ cmake_language Dependency providers can only be set as part of the first
+ call to project\(\)\. More specifically,
+ cmake_language\(SET_DEPENDENCY_PROVIDER\) can only be called while the first
+ project\(\) command processes files listed in
+ CMAKE_PROJECT_TOP_LEVEL_INCLUDES\.
diff --git a/Tests/RunCMake/DependencyProviders/set_provider.cmake b/Tests/RunCMake/DependencyProviders/set_provider.cmake
new file mode 100644
index 0000000..6e82b8f
--- /dev/null
+++ b/Tests/RunCMake/DependencyProviders/set_provider.cmake
@@ -0,0 +1,64 @@
+include(FetchContent)
+
+macro(null_provider method)
+ message(STATUS "Null provider called")
+ message(STATUS "Provider invoked for method ${method} with args: ${ARGN}")
+endmacro()
+
+macro(find_package_provider method package_name)
+ message(STATUS "Intercepted find_package(${package_name})")
+ message(STATUS "Provider invoked for method ${method} with args: ${ARGN}")
+ set(${package_name}_FOUND TRUE)
+endmacro()
+
+macro(FetchContentSerial_provider method dep_name)
+ message(STATUS "Intercepted FetchContent_MakeAvailable(${dep_name})")
+ message(STATUS "Provider invoked for method ${method} with args: ${ARGN}")
+ FetchContent_SetPopulated(${dep_name})
+endmacro()
+
+macro(redirect_find_package_provider method package_name)
+ message(STATUS "Redirecting find_package(${package_name}) to FetchContent_MakeAvailable()")
+ message(STATUS "Provider invoked for method ${method} with args: ${ARGN}")
+ FetchContent_Declare(${package_name}
+ SOURCE_DIR ${CMAKE_CURRENT_LIST_DIR}
+ SOURCE_SUBDIR DoesNotExist
+ )
+ FetchContent_MakeAvailable(${package_name})
+ set(${package_name}_FOUND TRUE)
+endmacro()
+
+macro(redirect_FetchContentSerial_provider method dep_name)
+ message(STATUS "Redirecting FetchContent_MakeAvailable(${dep_name}) to find_package()")
+ message(STATUS "Provider invoked for method ${method} with args: ${ARGN}")
+ find_package(${dep_name} NO_DEFAULT_PATH
+ PATHS ${CMAKE_CURRENT_LIST_DIR}/Finders
+ REQUIRED
+ )
+ FetchContent_SetPopulated(${dep_name})
+endmacro()
+
+macro(forward_find_package method package_name)
+ message(STATUS "Forwarding find_package(${package_name})")
+ message(STATUS "Provider invoked for method ${method} with args: ${ARGN}")
+ find_package(${package_name}
+ BYPASS_PROVIDER
+ PATHS ${CMAKE_CURRENT_LIST_DIR}/ConfigFiles
+ ${ARGN}
+ )
+ message(STATUS "Leaving provider")
+endmacro()
+
+macro(recurse_FetchContent method dep_name)
+ message(STATUS "Intercepted FetchContent_MakeAvailable(${dep_name})")
+ message(STATUS "Provider invoked for method ${method} with args: ${ARGN}")
+ FetchContent_MakeAvailable(${dep_name})
+ message(STATUS "Should now be handled")
+endmacro()
+
+message(STATUS "Before cmake_language")
+cmake_language(
+ SET_DEPENDENCY_PROVIDER ${provider_command}
+ SUPPORTED_METHODS ${provider_methods}
+)
+message(STATUS "After cmake_language")
diff --git a/Tests/RunCMake/DependencyProviders/try_methods.cmake b/Tests/RunCMake/DependencyProviders/try_methods.cmake
new file mode 100644
index 0000000..652c32d
--- /dev/null
+++ b/Tests/RunCMake/DependencyProviders/try_methods.cmake
@@ -0,0 +1,12 @@
+# Force the provider to be invoked for each method
+find_package(AThing QUIET)
+message(STATUS "AThing_FOUND = ${AThing_FOUND}")
+
+# These declared details should always succeed when used
+include(FetchContent)
+FetchContent_Declare(SomeDep
+ SOURCE_DIR ${CMAKE_CURRENT_LIST_DIR}
+ SOURCE_SUBDIR DoesNotExist
+)
+FetchContent_MakeAvailable(SomeDep)
+message(STATUS "FetchContent_MakeAvailable() succeeded")