summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--Help/command/export.rst131
-rw-r--r--Help/command/if.rst23
-rw-r--r--Help/guide/importing-exporting/MathFunctionsComponents/Config.cmake.in4
-rw-r--r--Help/manual/cmake-packages.7.rst4
-rw-r--r--Help/manual/cmake-presets.7.rst28
-rw-r--r--Help/manual/cmake-variables.7.rst1
-rw-r--r--Help/manual/cmake.1.rst30
-rw-r--r--Help/release/3.23.rst5
-rw-r--r--Help/variable/CMAKE_GENERATOR_INSTANCE.rst27
-rw-r--r--Help/variable/CMAKE_PLATFORM_NO_VERSIONED_SONAME.rst14
-rw-r--r--Help/variable/MSVC_TOOLSET_VERSION.rst1
-rw-r--r--Modules/FindGLUT.cmake3
-rw-r--r--Modules/FindHDF5.cmake4
-rw-r--r--Modules/FindMatlab.cmake2
-rw-r--r--Modules/FortranCInterface.cmake9
-rw-r--r--Modules/FortranCInterface/Detect.cmake10
-rw-r--r--Modules/GoogleTestAddTests.cmake41
-rw-r--r--Modules/Platform/Windows-Clang.cmake1
-rw-r--r--Modules/Platform/Windows-Intel-C.cmake2
-rw-r--r--Modules/Platform/Windows-Intel-CXX.cmake2
-rw-r--r--Modules/Platform/Windows-IntelLLVM.cmake2
-rw-r--r--Source/cmBuildOptions.h18
-rw-r--r--Source/cmExportFileGenerator.cxx5
-rw-r--r--Source/cmExportFileGenerator.h3
-rw-r--r--Source/cmExportInstallFileGenerator.cxx3
-rw-r--r--Source/cmFindCommon.cxx3
-rw-r--r--Source/cmFindPackageCommand.cxx67
-rw-r--r--Source/cmFindPackageCommand.h2
-rw-r--r--Source/cmGlobalVisualStudio10Generator.cxx2
-rw-r--r--Source/cmInstallCommand.cxx2
-rw-r--r--Source/cmMakefile.cxx19
-rw-r--r--Source/cmMakefile.h14
-rw-r--r--Source/cmTarget.cxx16
-rw-r--r--Source/cmTarget.h7
-rw-r--r--Source/cmTargetLinkLibrariesCommand.cxx240
-rw-r--r--Source/cmake.cxx3
-rw-r--r--Source/cmake.h2
-rw-r--r--Source/cmakemain.cxx2
-rw-r--r--Tests/CMakeCommands/target_link_libraries/cmp0022/CMakeLists.txt10
-rw-r--r--Tests/CudaOnly/SeparateCompilationPTX/CMakeLists.txt2
-rw-r--r--Tests/RunCMake/CMakeLists.txt3
-rw-r--r--Tests/RunCMake/CMakePresets/Debug-stderr.txt3
-rw-r--r--Tests/RunCMake/GoogleTest/GoogleTest-discovery-check-test-list.cmake6
-rw-r--r--Tests/RunCMake/GoogleTest/GoogleTest-discovery-flush-script-check-list.cmake5
-rw-r--r--Tests/RunCMake/GoogleTest/GoogleTestDiscoveryFlushScript.cmake14
-rw-r--r--Tests/RunCMake/GoogleTest/GoogleTestDiscoveryTestList.cmake14
-rw-r--r--Tests/RunCMake/GoogleTest/RunCMakeTest.cmake54
-rw-r--r--Tests/RunCMake/GoogleTest/flush_script_test.cpp19
-rw-r--r--Tests/RunCMake/GoogleTest/test_list_test.cpp18
-rw-r--r--Tests/RunCMake/find_package/FromPATHEnv-stderr.txt100
-rw-r--r--Tests/RunCMake/find_package/FromPATHEnv.cmake5
-rw-r--r--Tests/RunCMake/find_package/FromPATHEnvDebugPkg-stderr.txt101
-rw-r--r--Tests/RunCMake/find_package/FromPATHEnvDebugPkg.cmake5
-rw-r--r--Tests/RunCMake/find_package/ModuleModeDebugPkg-stderr.txt128
-rw-r--r--Tests/RunCMake/find_package/ModuleModeDebugPkg.cmake2
-rw-r--r--Tests/RunCMake/find_package/ModuleModeDebugPkg/FindBar.cmake2
-rw-r--r--Tests/RunCMake/find_package/ModuleModeDebugPkg/FindFoo.cmake6
-rw-r--r--Tests/RunCMake/find_package/RunCMakeTest.cmake6
-rw-r--r--Tests/RunCMake/if/AndOr-stdout.txt1
-rw-r--r--Tests/RunCMake/if/AndOr.cmake6
-rw-r--r--Tests/RunCMake/if/RunCMakeTest.cmake2
-rw-r--r--Tests/RunCMake/install/EXPORT-TargetTwice-check.cmake19
-rw-r--r--Tests/RunCMake/install/EXPORT-TargetTwice-pkg1.txt5
-rw-r--r--Tests/RunCMake/install/EXPORT-TargetTwice-pkg2.txt5
-rw-r--r--Tests/RunCMake/install/EXPORT-TargetTwice.cmake17
-rw-r--r--Tests/RunCMake/install/RunCMakeTest.cmake1
66 files changed, 973 insertions, 338 deletions
diff --git a/Help/command/export.rst b/Help/command/export.rst
index e8a1fa70e4..dc6964524a 100644
--- a/Help/command/export.rst
+++ b/Help/command/export.rst
@@ -1,44 +1,62 @@
export
------
-Export targets from the build tree for use by outside projects.
+Export targets or packages for outside projects to use them directly
+from the current project's build tree, without installation.
+
+See the :command:`install(EXPORT)` command to export targets from an
+install tree.
+
+Synopsis
+^^^^^^^^
+
+.. parsed-literal::
+
+ export(`TARGETS`_ <target>... [...])
+ export(`EXPORT`_ <export-name> [...])
+ export(`PACKAGE`_ <PackageName>)
+
+Exporting Targets
+^^^^^^^^^^^^^^^^^
+
+.. _`export(TARGETS)`:
+.. _TARGETS:
.. code-block:: cmake
- export(EXPORT <export-name> [NAMESPACE <namespace>] [FILE <filename>])
+ export(TARGETS <target>... [NAMESPACE <namespace>]
+ [APPEND] FILE <filename> [EXPORT_LINK_INTERFACE_LIBRARIES])
Creates a file ``<filename>`` that may be included by outside projects to
-import targets from the current project's build tree. This is useful
-during cross-compiling to build utility executables that can run on
-the host platform in one project and then import them into another
-project being compiled for the target platform. If the ``NAMESPACE``
-option is given the ``<namespace>`` string will be prepended to all target
-names written to the file.
-
-Target installations are associated with the export ``<export-name>``
-using the ``EXPORT`` option of the :command:`install(TARGETS)` command.
+import targets named by ``<target>...`` from the current project's build tree.
+This is useful during cross-compiling to build utility executables that can
+run on the host platform in one project and then import them into another
+project being compiled for the target platform.
The file created by this command is specific to the build tree and
should never be installed. See the :command:`install(EXPORT)` command to
-export targets from an installation tree.
+export targets from an install tree.
-The properties set on the generated IMPORTED targets will have the
-same values as the final values of the input TARGETS.
+The options are:
-.. code-block:: cmake
+``NAMESPACE <namespace>``
+ Prepend the ``<namespace>`` string to all target names written to the file.
- export(TARGETS [target1 [target2 [...]]] [NAMESPACE <namespace>]
- [APPEND] FILE <filename> [EXPORT_LINK_INTERFACE_LIBRARIES])
+``APPEND``
+ Append to the file instead of overwriting it. This can be used to
+ incrementally export multiple targets to the same file.
+
+``EXPORT_LINK_INTERFACE_LIBRARIES``
+ Include the contents of the properties named with the pattern
+ ``(IMPORTED_)?LINK_INTERFACE_LIBRARIES(_<CONFIG>)?``
+ in the export, even when policy :policy:`CMP0022` is NEW. This is useful
+ to support consumers using CMake versions older than 2.8.12.
-This signature is similar to the ``EXPORT`` signature, but targets are listed
-explicitly rather than specified as an export-name. If the APPEND option is
-given the generated code will be appended to the file instead of overwriting it.
-The EXPORT_LINK_INTERFACE_LIBRARIES keyword, if present, causes the
-contents of the properties matching
-``(IMPORTED_)?LINK_INTERFACE_LIBRARIES(_<CONFIG>)?`` to be exported, when
-policy CMP0022 is NEW. If a library target is included in the export
-but a target to which it links is not included the behavior is
-unspecified.
+This signature requires all targets to be listed explicitly. If a library
+target is included in the export, but a target to which it links is not
+included, the behavior is unspecified. See the `export(EXPORT)`_ signature
+to automatically export the same targets from the build tree as
+:command:`install(EXPORT)` would from an install tree.
.. note::
@@ -49,6 +67,50 @@ unspecified.
transitive usage requirements of other targets that link to the
object libraries in their implementation.
+Exporting Targets to Android.mk
+"""""""""""""""""""""""""""""""
+
+.. code-block:: cmake
+
+ export(TARGETS <target>... ANDROID_MK <filename>)
+
+.. versionadded:: 3.7
+
+This signature exports cmake built targets to the android ndk build system
+by creating an ``Android.mk`` file that references the prebuilt targets. The
+Android NDK supports the use of prebuilt libraries, both static and shared.
+This allows cmake to build the libraries of a project and make them available
+to an ndk build system complete with transitive dependencies, include flags
+and defines required to use the libraries. The signature takes a list of
+targets and puts them in the ``Android.mk`` file specified by the
+``<filename>`` given. This signature can only be used if policy
+:policy:`CMP0022` is NEW for all targets given. A error will be issued if
+that policy is set to OLD for one of the targets.
+
+Exporting Targets matching install(EXPORT)
+^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
+
+.. _`export(EXPORT)`:
+.. _EXPORT:
+
+.. code-block:: cmake
+
+ export(EXPORT <export-name> [NAMESPACE <namespace>] [FILE <filename>])
+
+Creates a file ``<filename>`` that may be included by outside projects to
+import targets from the current project's build tree. This is the same
+as the `export(TARGETS)`_ signature, except that the targets are not
+explicitly listed. Instead, it exports the targets associated with
+the installation export ``<export-name>``. Target installations may be
+associated with the export ``<export-name>`` using the ``EXPORT`` option
+of the :command:`install(TARGETS)` command.
+
+Exporting Packages
+^^^^^^^^^^^^^^^^^^
+
+.. _`export(PACKAGE)`:
+.. _PACKAGE:
+
.. code-block:: cmake
export(PACKAGE <PackageName>)
@@ -74,20 +136,3 @@ registry.
outside the source and build trees. Set the
:variable:`CMAKE_EXPORT_PACKAGE_REGISTRY` variable to add build directories
to the CMake user package registry.
-
-.. code-block:: cmake
-
- export(TARGETS [target1 [target2 [...]]] [ANDROID_MK <filename>])
-
-.. versionadded:: 3.7
-
-This signature exports cmake built targets to the android ndk build system
-by creating an Android.mk file that references the prebuilt targets. The
-Android NDK supports the use of prebuilt libraries, both static and shared.
-This allows cmake to build the libraries of a project and make them available
-to an ndk build system complete with transitive dependencies, include flags
-and defines required to use the libraries. The signature takes a list of
-targets and puts them in the Android.mk file specified by the ``<filename>``
-given. This signature can only be used if policy CMP0022 is NEW for all
-targets given. A error will be issued if that policy is set to OLD for one
-of the targets.
diff --git a/Help/command/if.rst b/Help/command/if.rst
index a729b1e1c1..4f955db0e9 100644
--- a/Help/command/if.rst
+++ b/Help/command/if.rst
@@ -38,14 +38,21 @@ The following syntax applies to the ``condition`` argument of
the ``if``, ``elseif`` and :command:`while` clauses.
Compound conditions are evaluated in the following order of precedence:
-Innermost parentheses are evaluated first. Next come unary tests such
-as `EXISTS`_, `COMMAND`_, and `DEFINED`_. Then binary tests such as
-`EQUAL`_, `LESS`_, `LESS_EQUAL`_, `GREATER`_, `GREATER_EQUAL`_,
-`STREQUAL`_, `STRLESS`_, `STRLESS_EQUAL`_, `STRGREATER`_,
-`STRGREATER_EQUAL`_, `VERSION_EQUAL`_, `VERSION_LESS`_,
-`VERSION_LESS_EQUAL`_, `VERSION_GREATER`_, `VERSION_GREATER_EQUAL`_,
-and `MATCHES`_. Then the boolean operators in the order `NOT`_, `AND`_,
-and finally `OR`_.
+
+1. Parentheses.
+
+2. Unary tests such as `EXISTS`_, `COMMAND`_, and `DEFINED`_.
+
+3. Binary tests such as `EQUAL`_, `LESS`_, `LESS_EQUAL`_, `GREATER`_,
+ `GREATER_EQUAL`_, `STREQUAL`_, `STRLESS`_, `STRLESS_EQUAL`_,
+ `STRGREATER`_, `STRGREATER_EQUAL`_, `VERSION_EQUAL`_, `VERSION_LESS`_,
+ `VERSION_LESS_EQUAL`_, `VERSION_GREATER`_, `VERSION_GREATER_EQUAL`_,
+ and `MATCHES`_.
+
+4. Unary logical operator `NOT`_.
+
+5. Binary logical operators `AND`_ and `OR`_, from left to right,
+ without any short-circuit.
Basic Expressions
"""""""""""""""""
diff --git a/Help/guide/importing-exporting/MathFunctionsComponents/Config.cmake.in b/Help/guide/importing-exporting/MathFunctionsComponents/Config.cmake.in
index 09f6c358e3..a535969e30 100644
--- a/Help/guide/importing-exporting/MathFunctionsComponents/Config.cmake.in
+++ b/Help/guide/importing-exporting/MathFunctionsComponents/Config.cmake.in
@@ -1,9 +1,9 @@
@PACKAGE_INIT@
-set(_supported_components Addition SquareRoot)
+set(_MathFunctions_supported_components Addition SquareRoot)
foreach(_comp ${MathFunctions_FIND_COMPONENTS})
- if (NOT _comp IN_LIST _supported_components)
+ if (NOT _comp IN_LIST _MathFunctions_supported_components)
set(MathFunctions_FOUND False)
set(MathFunctions_NOT_FOUND_MESSAGE "Unsupported component: ${_comp}")
endif()
diff --git a/Help/manual/cmake-packages.7.rst b/Help/manual/cmake-packages.7.rst
index 5c109ff672..ed85dc4ea7 100644
--- a/Help/manual/cmake-packages.7.rst
+++ b/Help/manual/cmake-packages.7.rst
@@ -446,10 +446,10 @@ be true. This can be tested with logic in the package configuration file:
include("${CMAKE_CURRENT_LIST_DIR}/ClimbingStatsTargets.cmake")
include("${CMAKE_CURRENT_LIST_DIR}/ClimbingStatsMacros.cmake")
- set(_supported_components Plot Table)
+ set(_ClimbingStats_supported_components Plot Table)
foreach(_comp ${ClimbingStats_FIND_COMPONENTS})
- if (NOT ";${_supported_components};" MATCHES ";${_comp};")
+ if (NOT ";${_ClimbingStats_supported_components};" MATCHES ";${_comp};")
set(ClimbingStats_FOUND False)
set(ClimbingStats_NOT_FOUND_MESSAGE "Unsupported component: ${_comp}")
endif()
diff --git a/Help/manual/cmake-presets.7.rst b/Help/manual/cmake-presets.7.rst
index 31bd9c0fde..69d05433cc 100644
--- a/Help/manual/cmake-presets.7.rst
+++ b/Help/manual/cmake-presets.7.rst
@@ -479,9 +479,10 @@ that may contain the following fields:
An optional string that specifies the package resolve mode. This is
allowed in preset files specifying version ``4`` or above.
- This field overwrites the ``--resolve-package-references`` command line
- parameter. If there are no targets that define package references, this
- option does nothing. Valid values are:
+ Package references are used to define dependencies to packages from
+ external package managers. Currently only NuGet in combination with the
+ Visual Studio generator is supported. If there are no targets that define
+ package references, this option does nothing. Valid values are:
``on``
@@ -498,17 +499,16 @@ that may contain the following fields:
.. note::
- If this setting is not specified in a preset, CMake will instead
- use the setting specified by the ``--resolve-package-references``
- command line parameter. If the command line parameter is not
- provided either, an environment-specific cache variable will be
- evaluated to decide, if package restoration should be performed.
-
- When using the Visual Studio generator, package references are
- defined using the :prop_tgt:`VS_PACKAGE_REFERENCES` property.
- Package references are restored using NuGet. It can be disabled
- by setting the ``CMAKE_VS_NUGET_PACKAGE_RESTORE`` variable to
- ``OFF``. This can also be done from within a configure preset.
+ The command line parameter ``--resolve-package-references`` will take
+ priority over this setting. If the command line parameter is not provided
+ and this setting is not specified, an environment-specific cache variable
+ will be evaluated to decide, if package restoration should be performed.
+
+ When using the Visual Studio generator, package references are defined
+ using the :prop_tgt:`VS_PACKAGE_REFERENCES` property. Package references
+ are restored using NuGet. It can be disabled by setting the
+ ``CMAKE_VS_NUGET_PACKAGE_RESTORE`` variable to ``OFF``. This can also be
+ done from within a configure preset.
``verbose``
diff --git a/Help/manual/cmake-variables.7.rst b/Help/manual/cmake-variables.7.rst
index 59566b50a4..4df02370a9 100644
--- a/Help/manual/cmake-variables.7.rst
+++ b/Help/manual/cmake-variables.7.rst
@@ -472,6 +472,7 @@ Variables that Control the Build
/variable/CMAKE_PCH_INSTANTIATE_TEMPLATES
/variable/CMAKE_PDB_OUTPUT_DIRECTORY
/variable/CMAKE_PDB_OUTPUT_DIRECTORY_CONFIG
+ /variable/CMAKE_PLATFORM_NO_VERSIONED_SONAME
/variable/CMAKE_POSITION_INDEPENDENT_CODE
/variable/CMAKE_RUNTIME_OUTPUT_DIRECTORY
/variable/CMAKE_RUNTIME_OUTPUT_DIRECTORY_CONFIG
diff --git a/Help/manual/cmake.1.rst b/Help/manual/cmake.1.rst
index c2b4d68e7b..f7d4f6b6d0 100644
--- a/Help/manual/cmake.1.rst
+++ b/Help/manual/cmake.1.rst
@@ -250,16 +250,17 @@ Options
See also the :variable:`CMAKE_FIND_DEBUG_MODE` variable for debugging
a more local part of the project.
-``--debug-find=<pkg>[,...]``
+``--debug-find-pkg=<pkg>[,...]``
Put cmake find commands in a debug mode when running under calls
- to ``find_package(<pkg>)``, where ``<pkg>`` is an entry in the given
- comma-separated list of case-sensitive package names.
+ to :command:`find_package(\<pkg\>) <find_package>`, where ``<pkg>``
+ is an entry in the given comma-separated list of case-sensitive package
+ names.
Like ``--debug-find``, but limiting scope to the specified packages.
``--debug-find-var=<var>[,...]``
Put cmake find commands in a debug mode when called with ``<var>``
- as the return variable, where ``<var>`` is an entry in the given
+ as the result variable, where ``<var>`` is an entry in the given
comma-separated list.
Like ``--debug-find``, but limiting scope to the specified variable names.
@@ -466,21 +467,20 @@ following options:
``--resolve-package-references=<on|off|only>``
.. versionadded:: 3.23
- Resolve remote package references (e.g. NuGet packages) before build.
- When set to ``on`` (default), packages will be restored before building a
- target. When set to ``only``, the packages will be restored, but no build
- will be performed. When set to ``off``, no packages will be restored.
+ Resolve remote package references from external package managers (e.g. NuGet)
+ before build. When set to ``on`` (default), packages will be restored before
+ building a target. When set to ``only``, the packages will be restored, but no
+ build will be performed. When set to ``off``, no packages will be restored.
- If the target does not define any package references, this option does
- nothing.
+ If the target does not define any package references, this option does nothing.
This setting can be specified in a build preset (using
- ``resolvePackageReferences``). In this case, the command line option will
- be ignored.
+ ``resolvePackageReferences``). The preset setting will be ignored, if this
+ command line option is specified.
- If the no command line parameter or preset option is not provided, an
- environment-specific cache variable will be evaluated to decide, if package
- restoration should be performed.
+ If no command line parameter or preset option are provided, an environment-
+ specific cache variable will be evaluated to decide, if package restoration
+ should be performed.
When using the Visual Studio generator, package references are defined
using the :prop_tgt:`VS_PACKAGE_REFERENCES` property. Package references
diff --git a/Help/release/3.23.rst b/Help/release/3.23.rst
index cce936b4c9..b2928db757 100644
--- a/Help/release/3.23.rst
+++ b/Help/release/3.23.rst
@@ -19,7 +19,10 @@ Presets
which allows the files to include other files.
* :manual:`cmake-presets(7)` gained support for specifying the
- ``resolvePackageReferences`` command line option in a build preset.
+ ``resolvePackageReferences`` command line option in a build preset to control
+ restoration behavior of package references from external package managers.
+ Currently this is only supported by the Visual Studio generator to support
+ restoring packages from NuGet. Other generators ignore this option.
Generators
----------
diff --git a/Help/variable/CMAKE_GENERATOR_INSTANCE.rst b/Help/variable/CMAKE_GENERATOR_INSTANCE.rst
index 6a35f17786..6bfabe0515 100644
--- a/Help/variable/CMAKE_GENERATOR_INSTANCE.rst
+++ b/Help/variable/CMAKE_GENERATOR_INSTANCE.rst
@@ -39,16 +39,33 @@ The ``key=value`` pairs form a comma-separated list of options to
specify details of the instance selection.
Supported pairs are:
-``version=<major>.<minor>.<MMMDD>.<BBB>``
+``version=<major>.<minor>.<date>.<build>``
.. versionadded:: 3.23
- Specify the 4-component VS Build Version.
+ Specify the 4-component VS Build Version, a.k.a. Build Number.
+ The components are:
+
+ ``<major>.<minor>``
+
+ The VS major and minor version numbers.
+ These are the same as the release version numbers.
+
+ ``<date>``
+
+ A build date in the format ``MMMDD``, where ``MMM`` is a month index
+ since an epoch used by Microsoft, and ``DD`` is a day in that month.
+
+ ``<build>``
+
+ A build index on the day represented by ``<date>``.
+
+ The build number is reported by ``vswhere`` as ``installationVersion``.
+ For example, VS 16.11.10 has build number ``16.11.32126.315``.
.. versionadded:: 3.23
- A portable VS instance may be specified that is not known to the
- Visual Studio Installer tool. The ``location`` and ``version=``
- values must both be provided.
+ A portable VS instance, which is not known to the Visual Studio Installer,
+ may be specified by providing both ``location`` and ``version=``.
If the value of ``CMAKE_GENERATOR_INSTANCE`` is not specified explicitly
by the user or a toolchain file, CMake queries the Visual Studio Installer
diff --git a/Help/variable/CMAKE_PLATFORM_NO_VERSIONED_SONAME.rst b/Help/variable/CMAKE_PLATFORM_NO_VERSIONED_SONAME.rst
new file mode 100644
index 0000000000..bf15fc85ea
--- /dev/null
+++ b/Help/variable/CMAKE_PLATFORM_NO_VERSIONED_SONAME.rst
@@ -0,0 +1,14 @@
+CMAKE_PLATFORM_NO_VERSIONED_SONAME
+----------------------------------
+
+.. versionadded:: 3.1
+
+This variable is used to globally control whether the
+:prop_tgt:`VERSION` and :prop_tgt:`SOVERSION` target
+properties should be used for shared libraries.
+When set to true, adding version information to each
+shared library target is disabled.
+
+By default this variable is set only on platforms where
+CMake knows it is needed. On other platforms, the
+specified properties will be used for shared libraries.
diff --git a/Help/variable/MSVC_TOOLSET_VERSION.rst b/Help/variable/MSVC_TOOLSET_VERSION.rst
index c642a9f1d7..59479af69f 100644
--- a/Help/variable/MSVC_TOOLSET_VERSION.rst
+++ b/Help/variable/MSVC_TOOLSET_VERSION.rst
@@ -17,6 +17,7 @@ Known toolset version numbers are::
140 = VS 2015 (14.0)
141 = VS 2017 (15.0)
142 = VS 2019 (16.0)
+ 143 = VS 2022 (17.0)
Compiler versions newer than those known to CMake will be reported
as the latest known toolset version.
diff --git a/Modules/FindGLUT.cmake b/Modules/FindGLUT.cmake
index 80cd3a0f37..fe274de0da 100644
--- a/Modules/FindGLUT.cmake
+++ b/Modules/FindGLUT.cmake
@@ -79,6 +79,9 @@ function(_add_glut_target_simple)
if(GLUT_LIBRARIES)
target_link_libraries(GLUT::GLUT INTERFACE ${GLUT_LIBRARIES})
endif()
+ if(GLUT_LIBRARY_DIRS)
+ target_link_directories(GLUT::GLUT INTERFACE ${GLUT_LIBRARY_DIRS})
+ endif()
if(GLUT_LDFLAGS)
target_link_options(GLUT::GLUT INTERFACE ${GLUT_LDFLAGS})
endif()
diff --git a/Modules/FindHDF5.cmake b/Modules/FindHDF5.cmake
index 9123d56292..40ed9a92c8 100644
--- a/Modules/FindHDF5.cmake
+++ b/Modules/FindHDF5.cmake
@@ -242,7 +242,7 @@ function(_HDF5_test_regular_compiler_C success version is_parallel)
COPY_FILE ${scratch_directory}/compiler_has_h5_c
)
endif()
- if(${success})
+ if(${success} AND EXISTS ${scratch_directory}/compiler_has_h5_c)
file(STRINGS ${scratch_directory}/compiler_has_h5_c INFO_STRINGS
REGEX "^INFO:"
)
@@ -290,7 +290,7 @@ function(_HDF5_test_regular_compiler_CXX success version is_parallel)
COPY_FILE ${scratch_directory}/compiler_has_h5_cxx
)
endif()
- if(${success})
+ if(${success} AND EXISTS ${scratch_directory}/compiler_has_h5_cxx)
file(STRINGS ${scratch_directory}/compiler_has_h5_cxx INFO_STRINGS
REGEX "^INFO:"
)
diff --git a/Modules/FindMatlab.cmake b/Modules/FindMatlab.cmake
index 0ca593e98f..f0e991b333 100644
--- a/Modules/FindMatlab.cmake
+++ b/Modules/FindMatlab.cmake
@@ -1353,7 +1353,7 @@ function(_Matlab_get_version_from_root matlab_root matlab_or_mcr matlab_known_ve
${versioninfo_string}
)
- if(CMAKE_MATCH_1 MATCHES "(([0-9])\\.([0-9]))[\\.0-9]*")
+ if(CMAKE_MATCH_1 MATCHES "(([0-9]+)\\.([0-9]+))[\\.0-9]*")
set(_matlab_version_tmp "${CMAKE_MATCH_1}")
endif()
endif()
diff --git a/Modules/FortranCInterface.cmake b/Modules/FortranCInterface.cmake
index 733c7232c7..53df01a9d3 100644
--- a/Modules/FortranCInterface.cmake
+++ b/Modules/FortranCInterface.cmake
@@ -343,6 +343,14 @@ function(FortranCInterface_VERIFY)
set(_desc "Verifying Fortran/${lang} Compiler Compatibility")
message(CHECK_START "${_desc}")
+ # Perform verification with only one architecture.
+ # FIXME: Add try_compile whole-project option to forward architectures.
+ if(CMAKE_OSX_ARCHITECTURES MATCHES "^([^;]+)(;|$)")
+ set(_FortranCInterface_OSX_ARCH "-DCMAKE_OSX_ARCHITECTURES=${CMAKE_MATCH_1}")
+ else()
+ set(_FortranCInterface_OSX_ARCH "")
+ endif()
+
cmake_policy(GET CMP0056 _FortranCInterface_CMP0056)
if(_FortranCInterface_CMP0056 STREQUAL "NEW")
set(_FortranCInterface_EXE_LINKER_FLAGS "-DCMAKE_EXE_LINKER_FLAGS:STRING=${CMAKE_EXE_LINKER_FLAGS}")
@@ -365,6 +373,7 @@ function(FortranCInterface_VERIFY)
"-DCMAKE_C_FLAGS_RELEASE:STRING=${CMAKE_C_FLAGS_RELEASE}"
"-DCMAKE_CXX_FLAGS_RELEASE:STRING=${CMAKE_CXX_FLAGS_RELEASE}"
"-DCMAKE_Fortran_FLAGS_RELEASE:STRING=${CMAKE_Fortran_FLAGS_RELEASE}"
+ ${_FortranCInterface_OSX_ARCH}
${_FortranCInterface_EXE_LINKER_FLAGS}
OUTPUT_VARIABLE _output)
file(WRITE "${FortranCInterface_BINARY_DIR}/Verify${lang}/output.txt" "${_output}")
diff --git a/Modules/FortranCInterface/Detect.cmake b/Modules/FortranCInterface/Detect.cmake
index 4d3cb005a7..72e5544907 100644
--- a/Modules/FortranCInterface/Detect.cmake
+++ b/Modules/FortranCInterface/Detect.cmake
@@ -28,6 +28,14 @@ unset(FortranCInterface_VERIFIED_CXX CACHE)
set(_result)
+# Perform detection with only one architecture so that
+# the info strings are not repeated.
+if(CMAKE_OSX_ARCHITECTURES MATCHES "^([^;]+)(;|$)")
+ set(_FortranCInterface_OSX_ARCH "-DCMAKE_OSX_ARCHITECTURES=${CMAKE_MATCH_1}")
+else()
+ set(_FortranCInterface_OSX_ARCH "")
+endif()
+
cmake_policy(GET CMP0056 _FortranCInterface_CMP0056)
if(_FortranCInterface_CMP0056 STREQUAL "NEW")
set(_FortranCInterface_EXE_LINKER_FLAGS "-DCMAKE_EXE_LINKER_FLAGS:STRING=${CMAKE_EXE_LINKER_FLAGS}")
@@ -48,11 +56,13 @@ try_compile(FortranCInterface_COMPILED
"-DCMAKE_Fortran_FLAGS:STRING=${CMAKE_Fortran_FLAGS}"
"-DCMAKE_C_FLAGS_RELEASE:STRING=${CMAKE_C_FLAGS_RELEASE}"
"-DCMAKE_Fortran_FLAGS_RELEASE:STRING=${CMAKE_Fortran_FLAGS_RELEASE}"
+ ${_FortranCInterface_OSX_ARCH}
${_FortranCInterface_EXE_LINKER_FLAGS}
OUTPUT_VARIABLE FortranCInterface_OUTPUT)
set(FortranCInterface_COMPILED ${FortranCInterface_COMPILED})
unset(FortranCInterface_COMPILED CACHE)
unset(_FortranCInterface_EXE_LINKER_FLAGS)
+unset(_FortranCInterface_OSX_ARCH)
# Locate the sample project executable.
set(FortranCInterface_EXE)
diff --git a/Modules/GoogleTestAddTests.cmake b/Modules/GoogleTestAddTests.cmake
index cef2e8a407..2bd0cc9ef3 100644
--- a/Modules/GoogleTestAddTests.cmake
+++ b/Modules/GoogleTestAddTests.cmake
@@ -9,7 +9,7 @@ set(flush_tests_MODE WRITE)
# Flushes script to ${_CTEST_FILE}
macro(flush_script)
file(${flush_tests_MODE} "${_CTEST_FILE}" "${script}")
- set(flush_tests_MODE APPEND)
+ set(flush_tests_MODE APPEND PARENT_SCOPE)
set(script "")
endmacro()
@@ -20,24 +20,22 @@ macro(flush_tests_buffer)
set(tests_buffer "")
endmacro()
-macro(add_command NAME TEST_NAME)
- set(_args "")
- foreach(_arg ${ARGN})
- if(_arg MATCHES "[^-./:a-zA-Z0-9_]")
- string(APPEND _args " [==[${_arg}]==]")
+function(add_command NAME TEST_NAME)
+ set(args "")
+ foreach(arg ${ARGN})
+ if(arg MATCHES "[^-./:a-zA-Z0-9_]")
+ string(APPEND args " [==[${arg}]==]")
else()
- string(APPEND _args " ${_arg}")
+ string(APPEND args " ${arg}")
endif()
endforeach()
- string(APPEND script "${NAME}(${TEST_NAME} ${_args})\n")
- string(LENGTH "${script}" _script_len)
- if(${_script_len} GREATER "50000")
+ string(APPEND script "${NAME}(${TEST_NAME} ${args})\n")
+ string(LENGTH "${script}" script_len)
+ if(${script_len} GREATER "50000")
flush_script()
endif()
- # Unsets macro local variables to prevent leakage outside of this macro.
- unset(_args)
- unset(_script_len)
-endmacro()
+ set(script "${script}" PARENT_SCOPE)
+endfunction()
function(generate_testname_guards OUTPUT OPEN_GUARD_VAR CLOSE_GUARD_VAR)
set(open_guard "[=[")
@@ -164,7 +162,6 @@ function(gtest_discover_tests_impl)
endif()
string(CONFIGURE "${test_name_template}" testname)
- # sanitize test name for further processing downstream
# unescape []
if(open_sb)
string(REPLACE "${open_sb}" "[" testname "${testname}")
@@ -172,13 +169,9 @@ function(gtest_discover_tests_impl)
if(close_sb)
string(REPLACE "${close_sb}" "]" testname "${testname}")
endif()
- # escape \
- string(REPLACE [[\]] [[\\]] testname "${testname}")
- # escape $
- string(REPLACE [[$]] [[\$]] testname "${testname}")
set(guarded_testname "${open_guard}${testname}${close_guard}")
- # ...and add to script
+ # add to script
add_command(add_test
"${guarded_testname}"
${_TEST_EXECUTOR}
@@ -199,14 +192,14 @@ function(gtest_discover_tests_impl)
"${guarded_testname}"
PROPERTIES
WORKING_DIRECTORY "${_TEST_WORKING_DIR}"
- SKIP_REGULAR_EXPRESSION "\\\\[ SKIPPED \\\\]"
+ SKIP_REGULAR_EXPRESSION "\\[ SKIPPED \\]"
${properties}
)
- # possibly unbalanced square brackets render lists invalid so skip such tests in _TEST_LIST
+ # possibly unbalanced square brackets render lists invalid so skip such tests in ${_TEST_LIST}
if(NOT "${testname}" MATCHES [=[(\[|\])]=])
# escape ;
- string(REPLACE [[;]] [[\;]] testname "${testname}")
+ string(REPLACE [[;]] [[\\;]] testname "${testname}")
list(APPEND tests_buffer "${testname}")
list(LENGTH tests_buffer tests_buffer_length)
if(${tests_buffer_length} GREATER "250")
@@ -221,7 +214,7 @@ function(gtest_discover_tests_impl)
# Create a list of all discovered tests, which users may use to e.g. set
# properties on the tests
flush_tests_buffer()
- add_command(set "" ${_TEST_LIST} ${tests})
+ add_command(set "" ${_TEST_LIST} "${tests}")
# Write CTest script
flush_script()
diff --git a/Modules/Platform/Windows-Clang.cmake b/Modules/Platform/Windows-Clang.cmake
index c4d6fd8fcc..e7e975d117 100644
--- a/Modules/Platform/Windows-Clang.cmake
+++ b/Modules/Platform/Windows-Clang.cmake
@@ -101,6 +101,7 @@ macro(__windows_compiler_clang_gnu lang)
string(APPEND CMAKE_${lang}_FLAGS_RELWITHDEBINFO_INIT " -O2 -g -DNDEBUG -Xclang -gcodeview ${__ADDED_FLAGS}")
endif()
set(CMAKE_INCLUDE_SYSTEM_FLAG_${lang} "-isystem ")
+ set(CMAKE_${lang}_LINKER_SUPPORTS_PDB ON)
set(CMAKE_PCH_EXTENSION .pch)
set(CMAKE_PCH_PROLOGUE "#pragma clang system_header")
diff --git a/Modules/Platform/Windows-Intel-C.cmake b/Modules/Platform/Windows-Intel-C.cmake
index 152b27c30d..e4d9b93ee4 100644
--- a/Modules/Platform/Windows-Intel-C.cmake
+++ b/Modules/Platform/Windows-Intel-C.cmake
@@ -1,7 +1,7 @@
include(Platform/Windows-Intel)
__windows_compiler_intel(C)
-set(CMAKE_DEPFILE_FLAGS_C "-QMMD -QMT <DEP_TARGET> -QMF <DEP_FILE>")
+set(CMAKE_DEPFILE_FLAGS_C "-QMD -QMT <DEP_TARGET> -QMF <DEP_FILE>")
set(CMAKE_C_DEPFILE_FORMAT gcc)
if(CMAKE_GENERATOR MATCHES "^Ninja")
diff --git a/Modules/Platform/Windows-Intel-CXX.cmake b/Modules/Platform/Windows-Intel-CXX.cmake
index ce33ae186a..6adbb6e193 100644
--- a/Modules/Platform/Windows-Intel-CXX.cmake
+++ b/Modules/Platform/Windows-Intel-CXX.cmake
@@ -2,7 +2,7 @@ include(Platform/Windows-Intel)
set(_COMPILE_CXX " /TP")
__windows_compiler_intel(CXX)
-set(CMAKE_DEPFILE_FLAGS_CXX "-QMMD -QMT <DEP_TARGET> -QMF <DEP_FILE>")
+set(CMAKE_DEPFILE_FLAGS_CXX "-QMD -QMT <DEP_TARGET> -QMF <DEP_FILE>")
set(CMAKE_CXX_DEPFILE_FORMAT gcc)
if(CMAKE_GENERATOR MATCHES "^Ninja")
diff --git a/Modules/Platform/Windows-IntelLLVM.cmake b/Modules/Platform/Windows-IntelLLVM.cmake
index 4687beecc3..f24dcdb1c0 100644
--- a/Modules/Platform/Windows-IntelLLVM.cmake
+++ b/Modules/Platform/Windows-IntelLLVM.cmake
@@ -25,6 +25,6 @@ macro(__windows_compiler_intel lang)
"<CMAKE_${lang}_COMPILER> ${CMAKE_CL_NOLOGO} <CMAKE_${lang}_LINK_FLAGS> <OBJECTS> ${CMAKE_START_TEMP_FILE} -fuse-ld=llvm-lib -o <TARGET> -link <LINK_FLAGS> <LINK_LIBRARIES> ${CMAKE_END_TEMP_FILE}")
endif()
- set(CMAKE_DEPFILE_FLAGS_${lang} "-QMMD -QMT <DEP_TARGET> -QMF <DEP_FILE>")
+ set(CMAKE_DEPFILE_FLAGS_${lang} "-QMD -QMT <DEP_TARGET> -QMF <DEP_FILE>")
set(CMAKE_${lang}_DEPFILE_FORMAT gcc)
endmacro()
diff --git a/Source/cmBuildOptions.h b/Source/cmBuildOptions.h
index 58baeef759..aa3184e879 100644
--- a/Source/cmBuildOptions.h
+++ b/Source/cmBuildOptions.h
@@ -7,20 +7,20 @@
/** \brief Defines how to resolve packages **/
enum class PackageResolveMode
{
- /** \brief Defines behavior based on cache variable (e.g.
+ /** \brief Behavior is defined by preset or cache variable (e.g.
CMAKE_VS_NUGET_PACKAGE_RESTORE). This is the default. **/
- FromCacheVariable,
+ Default,
- /** \brief Ignore behavior defined by cache variable and forces packages to
- be resolved prior to build. **/
+ /** \brief Ignore behavior defined by preset or cache variable and forces
+ packages to be resolved prior to build. **/
Force,
- /** \brief Ignore behavior defined by cache variable and forces packages to
- be resolved, but skip the actual build. **/
+ /** \brief Ignore behavior defined by preset or cache variable and forces
+ packages to be resolved, but skip the actual build. **/
OnlyResolve,
- /** \brief Ignore behavior defined by cache variable and dont resolve any
- packages **/
+ /** \brief Ignore behavior defined by preset or cache variable and don't
+ resolve any packages **/
Disable
};
@@ -40,5 +40,5 @@ public:
bool Clean = false;
bool Fast = false;
- PackageResolveMode ResolveMode = PackageResolveMode::FromCacheVariable;
+ PackageResolveMode ResolveMode = PackageResolveMode::Default;
};
diff --git a/Source/cmExportFileGenerator.cxx b/Source/cmExportFileGenerator.cxx
index 2d80f0ed8b..b46b933fbd 100644
--- a/Source/cmExportFileGenerator.cxx
+++ b/Source/cmExportFileGenerator.cxx
@@ -375,7 +375,8 @@ void cmExportFileGenerator::PopulateSourcesInterface(
void cmExportFileGenerator::PopulateIncludeDirectoriesInterface(
cmGeneratorTarget const* target,
cmGeneratorExpression::PreprocessContext preprocessRule,
- ImportPropertyMap& properties, std::vector<std::string>& missingTargets)
+ ImportPropertyMap& properties, std::vector<std::string>& missingTargets,
+ cmTargetExport const& te)
{
assert(preprocessRule == cmGeneratorExpression::InstallInterface);
@@ -385,7 +386,7 @@ void cmExportFileGenerator::PopulateIncludeDirectoriesInterface(
cmGeneratorExpression ge;
std::string dirs = cmGeneratorExpression::Preprocess(
- cmJoin(target->Target->GetInstallIncludeDirectoriesEntries(), ";"),
+ cmJoin(target->Target->GetInstallIncludeDirectoriesEntries(te), ";"),
preprocessRule, true);
this->ReplaceInstallPrefix(dirs);
std::unique_ptr<cmCompiledGeneratorExpression> cge = ge.Parse(dirs);
diff --git a/Source/cmExportFileGenerator.h b/Source/cmExportFileGenerator.h
index 58752470bc..d50f7e88df 100644
--- a/Source/cmExportFileGenerator.h
+++ b/Source/cmExportFileGenerator.h
@@ -148,7 +148,8 @@ protected:
void PopulateIncludeDirectoriesInterface(
cmGeneratorTarget const* target,
cmGeneratorExpression::PreprocessContext preprocessRule,
- ImportPropertyMap& properties, std::vector<std::string>& missingTargets);
+ ImportPropertyMap& properties, std::vector<std::string>& missingTargets,
+ cmTargetExport const& te);
void PopulateSourcesInterface(
cmGeneratorTarget const* target,
cmGeneratorExpression::PreprocessContext preprocessRule,
diff --git a/Source/cmExportInstallFileGenerator.cxx b/Source/cmExportInstallFileGenerator.cxx
index 2dd8b8fe27..f232440259 100644
--- a/Source/cmExportInstallFileGenerator.cxx
+++ b/Source/cmExportInstallFileGenerator.cxx
@@ -90,7 +90,8 @@ bool cmExportInstallFileGenerator::GenerateMainFile(std::ostream& os)
ImportPropertyMap properties;
this->PopulateIncludeDirectoriesInterface(
- gt, cmGeneratorExpression::InstallInterface, properties, missingTargets);
+ gt, cmGeneratorExpression::InstallInterface, properties, missingTargets,
+ *te);
this->PopulateSourcesInterface(gt, cmGeneratorExpression::InstallInterface,
properties, missingTargets);
this->PopulateInterfaceProperty("INTERFACE_SYSTEM_INCLUDE_DIRECTORIES", gt,
diff --git a/Source/cmFindCommon.cxx b/Source/cmFindCommon.cxx
index 1bb98ea7fe..7106e4b3ad 100644
--- a/Source/cmFindCommon.cxx
+++ b/Source/cmFindCommon.cxx
@@ -73,7 +73,8 @@ void cmFindCommon::DebugMessage(std::string const& msg) const
bool cmFindCommon::ComputeIfDebugModeWanted()
{
- return this->Makefile->IsOn("CMAKE_FIND_DEBUG_MODE") ||
+ return this->Makefile->GetDebugFindPkgMode() ||
+ this->Makefile->IsOn("CMAKE_FIND_DEBUG_MODE") ||
this->Makefile->GetCMakeInstance()->GetDebugFindOutput();
}
diff --git a/Source/cmFindPackageCommand.cxx b/Source/cmFindPackageCommand.cxx
index fac0e08eee..f55d838a59 100644
--- a/Source/cmFindPackageCommand.cxx
+++ b/Source/cmFindPackageCommand.cxx
@@ -33,7 +33,6 @@
#include "cmSystemTools.h"
#include "cmValue.h"
#include "cmVersion.h"
-#include "cmake.h"
#if defined(__HAIKU__)
# include <FindDirectory.h>
@@ -235,8 +234,8 @@ bool cmFindPackageCommand::InitialPass(std::vector<std::string> const& args)
this->SearchPathSuffixes.emplace_back();
// Process debug mode
- this->DebugMode = this->ComputeIfDebugModeWanted(this->Name);
- this->DebugBuffer.clear();
+ cmMakefile::DebugFindPkgRAII debugFindPkgRAII(this->Makefile, this->Name);
+ this->DebugMode = this->ComputeIfDebugModeWanted();
// Parse the arguments.
enum Doing
@@ -609,22 +608,15 @@ bool cmFindPackageCommand::InitialPass(std::vector<std::string> const& args)
loadedPackage = true;
}
}
-
- if (this->DebugMode) {
- this->DebugMessage(this->DebugBuffer);
- this->DebugBuffer.clear();
- }
}
this->AppendSuccessInformation();
- return loadedPackage;
-}
+ if (!this->DebugBuffer.empty()) {
+ this->DebugMessage(this->DebugBuffer);
+ }
-bool cmFindPackageCommand::ComputeIfDebugModeWanted(std::string const& var)
-{
- return this->ComputeIfDebugModeWanted() ||
- this->Makefile->GetCMakeInstance()->GetDebugFindPkgOutput(var);
+ return loadedPackage;
}
bool cmFindPackageCommand::FindPackageUsingModuleMode()
@@ -794,22 +786,21 @@ void cmFindPackageCommand::RestoreFindDefinitions()
bool cmFindPackageCommand::FindModule(bool& found)
{
- std::string module = cmStrCat("Find", this->Name, ".cmake");
+ std::string moduleFileName = cmStrCat("Find", this->Name, ".cmake");
bool system = false;
- std::string debugBuffer =
- cmStrCat("find_package considered the following paths for ", this->Name,
- ".cmake\n");
+ std::string debugBuffer = cmStrCat(
+ "find_package considered the following paths for ", moduleFileName, ":\n");
std::string mfile = this->Makefile->GetModulesFile(
- module, system, this->DebugMode, debugBuffer);
+ moduleFileName, system, this->DebugMode, debugBuffer);
if (this->DebugMode) {
if (mfile.empty()) {
- debugBuffer = cmStrCat(debugBuffer, "The file was not found.");
+ debugBuffer = cmStrCat(debugBuffer, "The file was not found.\n");
} else {
debugBuffer =
cmStrCat(debugBuffer, "The file was found at\n ", mfile, "\n");
}
- this->DebugBuffer = cmStrCat(this->DebugBuffer, debugBuffer, "\n");
+ this->DebugBuffer = cmStrCat(this->DebugBuffer, debugBuffer);
}
if (!mfile.empty()) {
@@ -953,11 +944,6 @@ bool cmFindPackageCommand::HandlePackageMode(
result = false;
}
- if (this->DebugMode) {
- this->DebugMessage(this->DebugBuffer);
- this->DebugBuffer.clear();
- }
-
// package not found
if (result && !found) {
// warn if package required or neither quiet nor in config mode
@@ -1123,7 +1109,8 @@ bool cmFindPackageCommand::FindConfig()
if (this->DebugMode) {
this->DebugBuffer = cmStrCat(this->DebugBuffer,
"find_package considered the following "
- "locations for the Config module:\n");
+ "locations for ",
+ this->Name, "'s Config module:\n");
}
// Search for frameworks.
@@ -1315,7 +1302,7 @@ inline std::size_t collectPathsForDebug(std::string& buffer,
{
const auto& paths = searchPath.GetPaths();
if (paths.empty()) {
- buffer += " none";
+ buffer += " none\n";
return 0;
}
for (std::size_t i = startIndex; i < paths.size(); i++) {
@@ -1375,7 +1362,7 @@ void cmFindPackageCommand::FillPrefixesPackageRoot()
std::string debugBuffer = "<PackageName>_ROOT CMake variable "
"[CMAKE_FIND_USE_PACKAGE_ROOT_PATH].\n";
collectPathsForDebug(debugBuffer, paths);
- this->DebugBuffer = cmStrCat(this->DebugBuffer, debugBuffer, "\n");
+ this->DebugBuffer = cmStrCat(this->DebugBuffer, debugBuffer);
}
}
@@ -1398,7 +1385,7 @@ void cmFindPackageCommand::FillPrefixesCMakeEnvironment()
paths.AddEnvPath("CMAKE_PREFIX_PATH");
if (this->DebugMode) {
debugBuffer = cmStrCat(debugBuffer,
- "\nCMAKE_PREFIX_PATH env variable "
+ "CMAKE_PREFIX_PATH env variable "
"[CMAKE_FIND_USE_CMAKE_ENVIRONMENT_PATH].\n");
debugOffset = collectPathsForDebug(debugBuffer, paths, debugOffset);
}
@@ -1408,10 +1395,10 @@ void cmFindPackageCommand::FillPrefixesCMakeEnvironment()
if (this->DebugMode) {
debugBuffer =
cmStrCat(debugBuffer,
- "\nCMAKE_FRAMEWORK_PATH and CMAKE_APPBUNDLE_PATH env "
+ "CMAKE_FRAMEWORK_PATH and CMAKE_APPBUNDLE_PATH env "
"variables [CMAKE_FIND_USE_CMAKE_ENVIRONMENT_PATH].\n");
collectPathsForDebug(debugBuffer, paths, debugOffset);
- this->DebugBuffer = cmStrCat(this->DebugBuffer, debugBuffer, "\n");
+ this->DebugBuffer = cmStrCat(this->DebugBuffer, debugBuffer);
}
}
@@ -1432,10 +1419,10 @@ void cmFindPackageCommand::FillPrefixesCMakeVariable()
if (this->DebugMode) {
debugBuffer =
cmStrCat(debugBuffer,
- "\nCMAKE_FRAMEWORK_PATH and CMAKE_APPBUNDLE_PATH variables "
+ "CMAKE_FRAMEWORK_PATH and CMAKE_APPBUNDLE_PATH variables "
"[CMAKE_FIND_USE_CMAKE_PATH].\n");
collectPathsForDebug(debugBuffer, paths, debugOffset);
- this->DebugBuffer = cmStrCat(this->DebugBuffer, debugBuffer, "\n");
+ this->DebugBuffer = cmStrCat(this->DebugBuffer, debugBuffer);
}
}
@@ -1460,7 +1447,7 @@ void cmFindPackageCommand::FillPrefixesSystemEnvironment()
std::string debugBuffer = "Standard system environment variables "
"[CMAKE_FIND_USE_SYSTEM_ENVIRONMENT_PATH].\n";
collectPathsForDebug(debugBuffer, paths);
- this->DebugBuffer = cmStrCat(this->DebugBuffer, debugBuffer, "\n");
+ this->DebugBuffer = cmStrCat(this->DebugBuffer, debugBuffer);
}
}
@@ -1490,7 +1477,7 @@ void cmFindPackageCommand::FillPrefixesUserRegistry()
"CMake User Package Registry [CMAKE_FIND_USE_PACKAGE_REGISTRY].\n";
collectPathsForDebug(debugBuffer,
this->LabeledPaths[PathLabel::UserRegistry]);
- this->DebugBuffer = cmStrCat(this->DebugBuffer, debugBuffer, "\n");
+ this->DebugBuffer = cmStrCat(this->DebugBuffer, debugBuffer);
}
}
@@ -1510,7 +1497,7 @@ void cmFindPackageCommand::FillPrefixesSystemRegistry()
"[CMAKE_FIND_PACKAGE_NO_SYSTEM_PACKAGE_REGISTRY].\n";
collectPathsForDebug(debugBuffer,
this->LabeledPaths[PathLabel::SystemRegistry]);
- this->DebugBuffer = cmStrCat(this->DebugBuffer, debugBuffer, "\n");
+ this->DebugBuffer = cmStrCat(this->DebugBuffer, debugBuffer);
}
}
@@ -1689,7 +1676,7 @@ void cmFindPackageCommand::FillPrefixesCMakeSystemVariable()
std::string debugBuffer = "CMake variables defined in the Platform file "
"[CMAKE_FIND_USE_CMAKE_SYSTEM_PATH].\n";
collectPathsForDebug(debugBuffer, paths);
- this->DebugBuffer = cmStrCat(this->DebugBuffer, debugBuffer, "\n");
+ this->DebugBuffer = cmStrCat(this->DebugBuffer, debugBuffer);
}
}
@@ -1704,7 +1691,7 @@ void cmFindPackageCommand::FillPrefixesUserGuess()
std::string debugBuffer =
"Paths specified by the find_package PATHS option.\n";
collectPathsForDebug(debugBuffer, paths);
- this->DebugBuffer = cmStrCat(this->DebugBuffer, debugBuffer, "\n");
+ this->DebugBuffer = cmStrCat(this->DebugBuffer, debugBuffer);
}
}
@@ -1719,7 +1706,7 @@ void cmFindPackageCommand::FillPrefixesUserHints()
std::string debugBuffer =
"Paths specified by the find_package HINTS option.\n";
collectPathsForDebug(debugBuffer, paths);
- this->DebugBuffer = cmStrCat(this->DebugBuffer, debugBuffer, "\n");
+ this->DebugBuffer = cmStrCat(this->DebugBuffer, debugBuffer);
}
}
diff --git a/Source/cmFindPackageCommand.h b/Source/cmFindPackageCommand.h
index 439d93415c..f921bb0a7f 100644
--- a/Source/cmFindPackageCommand.h
+++ b/Source/cmFindPackageCommand.h
@@ -40,7 +40,6 @@ class cmSearchPath;
class cmFindPackageCommand : public cmFindCommon
{
public:
- using cmFindCommon::ComputeIfDebugModeWanted;
/*! A sorting order strategy to be applied to recovered package folders (see
* FIND_PACKAGE_SORT_ORDER)*/
enum /*class*/ SortOrderType
@@ -121,7 +120,6 @@ private:
bool ReadListFile(const std::string& f, PolicyScopeRule psr);
void StoreVersionFound();
- bool ComputeIfDebugModeWanted(std::string const& var);
void ComputePrefixes();
void FillPrefixesPackageRoot();
void FillPrefixesCMakeEnvironment();
diff --git a/Source/cmGlobalVisualStudio10Generator.cxx b/Source/cmGlobalVisualStudio10Generator.cxx
index a96f6f0cd5..db54b86fdc 100644
--- a/Source/cmGlobalVisualStudio10Generator.cxx
+++ b/Source/cmGlobalVisualStudio10Generator.cxx
@@ -1222,7 +1222,7 @@ cmGlobalVisualStudio10Generator::GenerateBuildCommand(
"Studio 2017 and later. You have to manually restore the "
"packages using NuGet before building the project.");
restorePackages = false;
- } else if (restoreMode == PackageResolveMode::FromCacheVariable) {
+ } else if (restoreMode == PackageResolveMode::Default) {
// Decide if a restore is performed, based on a cache variable.
if (cmValue cached =
this->CMakeInstance->GetState()->GetCacheEntryValue(
diff --git a/Source/cmInstallCommand.cxx b/Source/cmInstallCommand.cxx
index 52a411b350..a77b26b6d7 100644
--- a/Source/cmInstallCommand.cxx
+++ b/Source/cmInstallCommand.cxx
@@ -760,7 +760,7 @@ bool HandleTargetsMode(std::vector<std::string> const& args,
te->FileSetGenerators[gen->GetFileSet()] = gen.get();
}
target.AddInstallIncludeDirectories(
- cmMakeRange(includesArgs.GetIncludeDirs()));
+ *te, cmMakeRange(includesArgs.GetIncludeDirs()));
te->NamelinkOnly = namelinkOnly;
helper.Makefile->GetGlobalGenerator()
->GetExportSets()[exports]
diff --git a/Source/cmMakefile.cxx b/Source/cmMakefile.cxx
index 68e61bb166..94d3be61f8 100644
--- a/Source/cmMakefile.cxx
+++ b/Source/cmMakefile.cxx
@@ -4519,3 +4519,22 @@ cmMakefile::MacroPushPop::~MacroPushPop()
{
this->Makefile->PopMacroScope(this->ReportError);
}
+
+cmMakefile::DebugFindPkgRAII::DebugFindPkgRAII(cmMakefile* mf,
+ std::string const& pkg)
+ : Makefile(mf)
+ , OldValue(this->Makefile->DebugFindPkg)
+{
+ this->Makefile->DebugFindPkg =
+ this->Makefile->GetCMakeInstance()->GetDebugFindPkgOutput(pkg);
+}
+
+cmMakefile::DebugFindPkgRAII::~DebugFindPkgRAII()
+{
+ this->Makefile->DebugFindPkg = this->OldValue;
+}
+
+bool cmMakefile::GetDebugFindPkgMode() const
+{
+ return this->DebugFindPkg;
+}
diff --git a/Source/cmMakefile.h b/Source/cmMakefile.h
index 85988b8e0e..f4256972be 100644
--- a/Source/cmMakefile.h
+++ b/Source/cmMakefile.h
@@ -931,6 +931,18 @@ public:
// searches
std::deque<std::vector<std::string>> FindPackageRootPathStack;
+ class DebugFindPkgRAII
+ {
+ cmMakefile* Makefile;
+ bool OldValue;
+
+ public:
+ DebugFindPkgRAII(cmMakefile* mf, std::string const& pkg);
+ ~DebugFindPkgRAII();
+ };
+
+ bool GetDebugFindPkgMode() const;
+
void MaybeWarnCMP0074(std::string const& pkg);
void MaybeWarnUninitialized(std::string const& variable,
const char* sourceFilename) const;
@@ -1104,6 +1116,8 @@ private:
std::vector<BT<GeneratorAction>> GeneratorActions;
bool GeneratorActionsInvoked = false;
+ bool DebugFindPkg = false;
+
bool CheckSystemVars;
bool CheckCMP0000;
std::set<std::string> WarnedCMP0074;
diff --git a/Source/cmTarget.cxx b/Source/cmTarget.cxx
index 87fce92d23..605905537b 100644
--- a/Source/cmTarget.cxx
+++ b/Source/cmTarget.cxx
@@ -192,7 +192,8 @@ public:
cmTarget::LinkLibraryVectorType OriginalLinkLibraries;
std::map<std::string, BTs<std::string>> LanguageStandardProperties;
std::vector<BT<std::string>> IncludeDirectoriesEntries;
- std::vector<std::string> InstallIncludeDirectoriesEntries;
+ std::map<cmTargetExport const*, std::vector<std::string>>
+ InstallIncludeDirectoriesEntries;
std::vector<BT<std::string>> CompileOptionsEntries;
std::vector<BT<std::string>> CompileFeaturesEntries;
std::vector<BT<std::string>> CompileDefinitionsEntries;
@@ -1079,15 +1080,18 @@ std::set<std::string> const& cmTarget::GetSystemIncludeDirectories() const
return this->impl->SystemIncludeDirectories;
}
-void cmTarget::AddInstallIncludeDirectories(cmStringRange const& incs)
+void cmTarget::AddInstallIncludeDirectories(cmTargetExport const& te,
+ cmStringRange const& incs)
{
- std::copy(incs.begin(), incs.end(),
- std::back_inserter(this->impl->InstallIncludeDirectoriesEntries));
+ std::copy(
+ incs.begin(), incs.end(),
+ std::back_inserter(this->impl->InstallIncludeDirectoriesEntries[&te]));
}
-cmStringRange cmTarget::GetInstallIncludeDirectoriesEntries() const
+cmStringRange cmTarget::GetInstallIncludeDirectoriesEntries(
+ cmTargetExport const& te) const
{
- return cmMakeRange(this->impl->InstallIncludeDirectoriesEntries);
+ return cmMakeRange(this->impl->InstallIncludeDirectoriesEntries[&te]);
}
cmBTStringRange cmTarget::GetIncludeDirectoriesEntries() const
diff --git a/Source/cmTarget.h b/Source/cmTarget.h
index 18e39c76c5..0cdd2fc3e7 100644
--- a/Source/cmTarget.h
+++ b/Source/cmTarget.h
@@ -27,6 +27,7 @@ class cmListFileContext;
class cmMakefile;
class cmPropertyMap;
class cmSourceFile;
+class cmTargetExport;
class cmTargetInternals;
template <typename T>
@@ -237,8 +238,10 @@ public:
void AddSystemIncludeDirectories(std::set<std::string> const& incs);
std::set<std::string> const& GetSystemIncludeDirectories() const;
- void AddInstallIncludeDirectories(cmStringRange const& incs);
- cmStringRange GetInstallIncludeDirectoriesEntries() const;
+ void AddInstallIncludeDirectories(cmTargetExport const& te,
+ cmStringRange const& incs);
+ cmStringRange GetInstallIncludeDirectoriesEntries(
+ cmTargetExport const& te) const;
BTs<std::string> const* GetLanguageStandardProperty(
const std::string& propertyName) const;
diff --git a/Source/cmTargetLinkLibrariesCommand.cxx b/Source/cmTargetLinkLibrariesCommand.cxx
index e15c9418ac..94fcdd931c 100644
--- a/Source/cmTargetLinkLibrariesCommand.cxx
+++ b/Source/cmTargetLinkLibrariesCommand.cxx
@@ -2,11 +2,14 @@
file Copyright.txt or https://cmake.org/licensing for details. */
#include "cmTargetLinkLibrariesCommand.h"
+#include <cassert>
#include <memory>
#include <sstream>
#include <unordered_set>
#include <utility>
+#include <cm/optional>
+
#include "cmExecutionStatus.h"
#include "cmGeneratorExpression.h"
#include "cmGlobalGenerator.h"
@@ -178,123 +181,156 @@ bool cmTargetLinkLibrariesCommand(std::vector<std::string> const& args,
// specification if the keyword is encountered as the first argument.
ProcessingState currentProcessingState = ProcessingLinkLibraries;
+ // Accumulate consectuive non-keyword arguments into one entry in
+ // order to handle unquoted generator expressions containing ';'.
+ cm::optional<std::string> currentEntry;
+ auto processCurrentEntry = [&]() -> bool {
+ if (currentEntry) {
+ assert(!haveLLT);
+ if (!tll.HandleLibrary(currentProcessingState, *currentEntry,
+ GENERAL_LibraryType)) {
+ return false;
+ }
+ currentEntry = cm::nullopt;
+ }
+ return true;
+ };
+ auto extendCurrentEntry = [&currentEntry](std::string const& arg) {
+ if (currentEntry) {
+ currentEntry = cmStrCat(*currentEntry, ';', arg);
+ } else {
+ currentEntry = arg;
+ }
+ };
+
+ // Keep this list in sync with the keyword dispatch below.
+ static std::unordered_set<std::string> const keywords{
+ "LINK_INTERFACE_LIBRARIES",
+ "INTERFACE",
+ "LINK_PUBLIC",
+ "PUBLIC",
+ "LINK_PRIVATE",
+ "PRIVATE",
+ "debug",
+ "optimized",
+ "general",
+ };
+
// Add libraries, note that there is an optional prefix
// of debug and optimized that can be used.
for (unsigned int i = 1; i < args.size(); ++i) {
- if (args[i] == "LINK_INTERFACE_LIBRARIES") {
- currentProcessingState = ProcessingPlainLinkInterface;
- if (i != 1) {
- mf.IssueMessage(
- MessageType::FATAL_ERROR,
- "The LINK_INTERFACE_LIBRARIES option must appear as the second "
- "argument, just after the target name.");
- return true;
- }
- } else if (args[i] == "INTERFACE") {
- if (i != 1 &&
- currentProcessingState != ProcessingKeywordPrivateInterface &&
- currentProcessingState != ProcessingKeywordPublicInterface &&
- currentProcessingState != ProcessingKeywordLinkInterface) {
- mf.IssueMessage(
- MessageType::FATAL_ERROR,
- "The INTERFACE, PUBLIC or PRIVATE option must appear as the second "
- "argument, just after the target name.");
- return true;
- }
- currentProcessingState = ProcessingKeywordLinkInterface;
- } else if (args[i] == "LINK_PUBLIC") {
- if (i != 1 &&
- currentProcessingState != ProcessingPlainPrivateInterface &&
- currentProcessingState != ProcessingPlainPublicInterface) {
- mf.IssueMessage(
- MessageType::FATAL_ERROR,
- "The LINK_PUBLIC or LINK_PRIVATE option must appear as the second "
- "argument, just after the target name.");
- return true;
- }
- currentProcessingState = ProcessingPlainPublicInterface;
- } else if (args[i] == "PUBLIC") {
- if (i != 1 &&
- currentProcessingState != ProcessingKeywordPrivateInterface &&
- currentProcessingState != ProcessingKeywordPublicInterface &&
- currentProcessingState != ProcessingKeywordLinkInterface) {
- mf.IssueMessage(
- MessageType::FATAL_ERROR,
- "The INTERFACE, PUBLIC or PRIVATE option must appear as the second "
- "argument, just after the target name.");
- return true;
- }
- currentProcessingState = ProcessingKeywordPublicInterface;
- } else if (args[i] == "LINK_PRIVATE") {
- if (i != 1 && currentProcessingState != ProcessingPlainPublicInterface &&
- currentProcessingState != ProcessingPlainPrivateInterface) {
- mf.IssueMessage(
- MessageType::FATAL_ERROR,
- "The LINK_PUBLIC or LINK_PRIVATE option must appear as the second "
- "argument, just after the target name.");
- return true;
- }
- currentProcessingState = ProcessingPlainPrivateInterface;
- } else if (args[i] == "PRIVATE") {
- if (i != 1 &&
- currentProcessingState != ProcessingKeywordPrivateInterface &&
- currentProcessingState != ProcessingKeywordPublicInterface &&
- currentProcessingState != ProcessingKeywordLinkInterface) {
- mf.IssueMessage(
- MessageType::FATAL_ERROR,
- "The INTERFACE, PUBLIC or PRIVATE option must appear as the second "
- "argument, just after the target name.");
- return true;
- }
- currentProcessingState = ProcessingKeywordPrivateInterface;
- } else if (args[i] == "debug") {
- if (haveLLT) {
- LinkLibraryTypeSpecifierWarning(mf, llt, DEBUG_LibraryType);
- }
- llt = DEBUG_LibraryType;
- haveLLT = true;
- } else if (args[i] == "optimized") {
- if (haveLLT) {
- LinkLibraryTypeSpecifierWarning(mf, llt, OPTIMIZED_LibraryType);
+ if (keywords.count(args[i])) {
+ // A keyword argument terminates any preceding accumulated entry.
+ if (!processCurrentEntry()) {
+ return false;
}
- llt = OPTIMIZED_LibraryType;
- haveLLT = true;
- } else if (args[i] == "general") {
- if (haveLLT) {
- LinkLibraryTypeSpecifierWarning(mf, llt, GENERAL_LibraryType);
+
+ // Process this keyword argument.
+ if (args[i] == "LINK_INTERFACE_LIBRARIES") {
+ currentProcessingState = ProcessingPlainLinkInterface;
+ if (i != 1) {
+ mf.IssueMessage(
+ MessageType::FATAL_ERROR,
+ "The LINK_INTERFACE_LIBRARIES option must appear as the "
+ "second argument, just after the target name.");
+ return true;
+ }
+ } else if (args[i] == "INTERFACE") {
+ if (i != 1 &&
+ currentProcessingState != ProcessingKeywordPrivateInterface &&
+ currentProcessingState != ProcessingKeywordPublicInterface &&
+ currentProcessingState != ProcessingKeywordLinkInterface) {
+ mf.IssueMessage(MessageType::FATAL_ERROR,
+ "The INTERFACE, PUBLIC or PRIVATE option must "
+ "appear as the second argument, just after the "
+ "target name.");
+ return true;
+ }
+ currentProcessingState = ProcessingKeywordLinkInterface;
+ } else if (args[i] == "LINK_PUBLIC") {
+ if (i != 1 &&
+ currentProcessingState != ProcessingPlainPrivateInterface &&
+ currentProcessingState != ProcessingPlainPublicInterface) {
+ mf.IssueMessage(
+ MessageType::FATAL_ERROR,
+ "The LINK_PUBLIC or LINK_PRIVATE option must appear as the "
+ "second argument, just after the target name.");
+ return true;
+ }
+ currentProcessingState = ProcessingPlainPublicInterface;
+ } else if (args[i] == "PUBLIC") {
+ if (i != 1 &&
+ currentProcessingState != ProcessingKeywordPrivateInterface &&
+ currentProcessingState != ProcessingKeywordPublicInterface &&
+ currentProcessingState != ProcessingKeywordLinkInterface) {
+ mf.IssueMessage(MessageType::FATAL_ERROR,
+ "The INTERFACE, PUBLIC or PRIVATE option must "
+ "appear as the second argument, just after the "
+ "target name.");
+ return true;
+ }
+ currentProcessingState = ProcessingKeywordPublicInterface;
+ } else if (args[i] == "LINK_PRIVATE") {
+ if (i != 1 &&
+ currentProcessingState != ProcessingPlainPublicInterface &&
+ currentProcessingState != ProcessingPlainPrivateInterface) {
+ mf.IssueMessage(
+ MessageType::FATAL_ERROR,
+ "The LINK_PUBLIC or LINK_PRIVATE option must appear as the "
+ "second argument, just after the target name.");
+ return true;
+ }
+ currentProcessingState = ProcessingPlainPrivateInterface;
+ } else if (args[i] == "PRIVATE") {
+ if (i != 1 &&
+ currentProcessingState != ProcessingKeywordPrivateInterface &&
+ currentProcessingState != ProcessingKeywordPublicInterface &&
+ currentProcessingState != ProcessingKeywordLinkInterface) {
+ mf.IssueMessage(MessageType::FATAL_ERROR,
+ "The INTERFACE, PUBLIC or PRIVATE option must "
+ "appear as the second argument, just after the "
+ "target name.");
+ return true;
+ }
+ currentProcessingState = ProcessingKeywordPrivateInterface;
+ } else if (args[i] == "debug") {
+ if (haveLLT) {
+ LinkLibraryTypeSpecifierWarning(mf, llt, DEBUG_LibraryType);
+ }
+ llt = DEBUG_LibraryType;
+ haveLLT = true;
+ } else if (args[i] == "optimized") {
+ if (haveLLT) {
+ LinkLibraryTypeSpecifierWarning(mf, llt, OPTIMIZED_LibraryType);
+ }
+ llt = OPTIMIZED_LibraryType;
+ haveLLT = true;
+ } else if (args[i] == "general") {
+ if (haveLLT) {
+ LinkLibraryTypeSpecifierWarning(mf, llt, GENERAL_LibraryType);
+ }
+ llt = GENERAL_LibraryType;
+ haveLLT = true;
}
- llt = GENERAL_LibraryType;
- haveLLT = true;
} else if (haveLLT) {
// The link type was specified by the previous argument.
haveLLT = false;
+ assert(!currentEntry);
if (!tll.HandleLibrary(currentProcessingState, args[i], llt)) {
return false;
}
- } else {
- // Lookup old-style cache entry if type is unspecified. So if you
- // do a target_link_libraries(foo optimized bar) it will stay optimized
- // and not use the lookup. As there may be the case where someone has
- // specified that a library is both debug and optimized. (this check is
- // only there for backwards compatibility when mixing projects built
- // with old versions of CMake and new)
llt = GENERAL_LibraryType;
- std::string linkType = cmStrCat(args[0], "_LINK_TYPE");
- cmValue linkTypeString = mf.GetDefinition(linkType);
- if (linkTypeString) {
- if (*linkTypeString == "debug") {
- llt = DEBUG_LibraryType;
- }
- if (*linkTypeString == "optimized") {
- llt = OPTIMIZED_LibraryType;
- }
- }
- if (!tll.HandleLibrary(currentProcessingState, args[i], llt)) {
- return false;
- }
+ } else {
+ // Accumulate this argument in the current entry.
+ extendCurrentEntry(args[i]);
}
}
+ // Process the last accumulated entry, if any.
+ if (!processCurrentEntry()) {
+ return false;
+ }
+
// Make sure the last argument was not a library type specifier.
if (haveLLT) {
mf.IssueMessage(MessageType::FATAL_ERROR,
diff --git a/Source/cmake.cxx b/Source/cmake.cxx
index 8d27eb0023..d80c4bc6e7 100644
--- a/Source/cmake.cxx
+++ b/Source/cmake.cxx
@@ -3376,7 +3376,8 @@ int cmake::Build(int jobs, std::string dir, std::vector<std::string> targets,
buildOptions.Clean = *expandedPreset->CleanFirst;
}
- if (expandedPreset->ResolvePackageReferences) {
+ if (buildOptions.ResolveMode == PackageResolveMode::Default &&
+ expandedPreset->ResolvePackageReferences) {
buildOptions.ResolveMode = *expandedPreset->ResolvePackageReferences;
}
diff --git a/Source/cmake.h b/Source/cmake.h
index 1187be571e..97444b8660 100644
--- a/Source/cmake.h
+++ b/Source/cmake.h
@@ -488,7 +488,7 @@ public:
//! Do we want debug output from the find commands during the cmake run.
bool GetDebugFindOutput() const { return this->DebugFindOutput; }
bool GetDebugFindOutput(std::string const& var) const;
- bool GetDebugFindPkgOutput(std::string const& var) const;
+ bool GetDebugFindPkgOutput(std::string const& pkg) const;
void SetDebugFindOutput(bool b) { this->DebugFindOutput = b; }
void SetDebugFindOutputPkgs(std::string const& args);
void SetDebugFindOutputVars(std::string const& args);
diff --git a/Source/cmakemain.cxx b/Source/cmakemain.cxx
index f3d5536fd5..0554c3e3e0 100644
--- a/Source/cmakemain.cxx
+++ b/Source/cmakemain.cxx
@@ -447,7 +447,7 @@ int do_build(int ac, char const* const* av)
bool cleanFirst = false;
bool foundClean = false;
bool foundNonClean = false;
- PackageResolveMode resolveMode = PackageResolveMode::FromCacheVariable;
+ PackageResolveMode resolveMode = PackageResolveMode::Default;
bool verbose = cmSystemTools::HasEnv("VERBOSE");
std::string presetName;
bool listPresets = false;
diff --git a/Tests/CMakeCommands/target_link_libraries/cmp0022/CMakeLists.txt b/Tests/CMakeCommands/target_link_libraries/cmp0022/CMakeLists.txt
index 83103cf383..ca6309be69 100644
--- a/Tests/CMakeCommands/target_link_libraries/cmp0022/CMakeLists.txt
+++ b/Tests/CMakeCommands/target_link_libraries/cmp0022/CMakeLists.txt
@@ -1,3 +1,4 @@
+cmake_policy(SET CMP0028 NEW)
include(GenerateExportHeader)
set(CMAKE_INCLUDE_CURRENT_DIR ON)
@@ -17,6 +18,15 @@ assert_property(cmp0022ifacelib INTERFACE_LINK_LIBRARIES "")
add_executable(cmp0022exe cmp0022exe.cpp)
target_link_libraries(cmp0022exe cmp0022lib)
+# Test adding unquoted genex with ';' to LINK_LIBRARIES and INTERFACE_LINK_LIBRARIES.
+target_link_libraries(cmp0022lib
+ PUBLIC $<0:imp::missing1;imp::missing2>
+ PRIVATE $<0:imp::missing3;imp::missing4>
+ INTERFACE $<0:imp::missing5;imp::missing6>
+ )
+assert_property(cmp0022lib INTERFACE_LINK_LIBRARIES "cmp0022ifacelib;$<0:imp::missing1;imp::missing2>;$<0:imp::missing5;imp::missing6>")
+assert_property(cmp0022lib LINK_LIBRARIES "cmp0022ifacelib;$<0:imp::missing1;imp::missing2>;$<0:imp::missing3;imp::missing4>")
+
add_library(staticlib1 STATIC staticlib1.cpp)
generate_export_header(staticlib1)
add_library(staticlib2 STATIC staticlib2.cpp)
diff --git a/Tests/CudaOnly/SeparateCompilationPTX/CMakeLists.txt b/Tests/CudaOnly/SeparateCompilationPTX/CMakeLists.txt
index 273f95578f..2dd95c8a84 100644
--- a/Tests/CudaOnly/SeparateCompilationPTX/CMakeLists.txt
+++ b/Tests/CudaOnly/SeparateCompilationPTX/CMakeLists.txt
@@ -1,5 +1,5 @@
cmake_minimum_required(VERSION 3.19)
-project (SeparateCompPTX CUDA)
+project (SeparateCompilationPTX CUDA)
#Goal for this example:
# How to generate PTX files with RDC enabled
diff --git a/Tests/RunCMake/CMakeLists.txt b/Tests/RunCMake/CMakeLists.txt
index 1d7e632a1e..6087021684 100644
--- a/Tests/RunCMake/CMakeLists.txt
+++ b/Tests/RunCMake/CMakeLists.txt
@@ -84,7 +84,8 @@ endif()
# Test MSVC for older host CMake versions, and test
# WIN32/CMAKE_C_COMPILER_ID to fix check on Intel for Windows.
-if(MSVC OR (WIN32 AND CMAKE_C_COMPILER_ID MATCHES "MSVC|Intel"))
+if(MSVC OR (WIN32 AND CMAKE_C_COMPILER_ID MATCHES "MSVC|Intel")
+ OR (WIN32 AND CMAKE_C_COMPILER_ID MATCHES "Clang" AND CMAKE_C_SIMULATE_ID MATCHES "MSVC"))
set(LINKER_SUPPORTS_PDB 1)
else()
set(LINKER_SUPPORTS_PDB 0)
diff --git a/Tests/RunCMake/CMakePresets/Debug-stderr.txt b/Tests/RunCMake/CMakePresets/Debug-stderr.txt
index 7fdb8b3773..d30dc58310 100644
--- a/Tests/RunCMake/CMakePresets/Debug-stderr.txt
+++ b/Tests/RunCMake/CMakePresets/Debug-stderr.txt
@@ -1 +1,2 @@
- find_package considered the following locations for the Config module:
+ find_package considered the following locations for
+ ThisPackageHopefullyDoesNotExist's Config module:
diff --git a/Tests/RunCMake/GoogleTest/GoogleTest-discovery-check-test-list.cmake b/Tests/RunCMake/GoogleTest/GoogleTest-discovery-check-test-list.cmake
new file mode 100644
index 0000000000..94169e7312
--- /dev/null
+++ b/Tests/RunCMake/GoogleTest/GoogleTest-discovery-check-test-list.cmake
@@ -0,0 +1,6 @@
+list(LENGTH test_list_test_TESTS LIST_SIZE)
+set(EXPECTED_SIZE 2)
+if(NOT LIST_SIZE EQUAL ${EXPECTED_SIZE})
+ message("TEST_LIST should have ${EXPECTED_SIZE} elements but it has ${LIST_SIZE}")
+ message("The unexpected list: [${test_list_test_TESTS}]")
+endif()
diff --git a/Tests/RunCMake/GoogleTest/GoogleTest-discovery-flush-script-check-list.cmake b/Tests/RunCMake/GoogleTest/GoogleTest-discovery-flush-script-check-list.cmake
new file mode 100644
index 0000000000..1ae222fd0a
--- /dev/null
+++ b/Tests/RunCMake/GoogleTest/GoogleTest-discovery-flush-script-check-list.cmake
@@ -0,0 +1,5 @@
+list(LENGTH flush_script_test_TESTS LIST_SIZE)
+set(EXPECTED_LIST_SIZE 4)
+if(NOT LIST_SIZE EQUAL ${EXPECTED_LIST_SIZE})
+ message("TEST_LIST should have ${EXPECTED_LIST_SIZE} elements but it has ${LIST_SIZE}")
+endif()
diff --git a/Tests/RunCMake/GoogleTest/GoogleTestDiscoveryFlushScript.cmake b/Tests/RunCMake/GoogleTest/GoogleTestDiscoveryFlushScript.cmake
new file mode 100644
index 0000000000..2c138c7b40
--- /dev/null
+++ b/Tests/RunCMake/GoogleTest/GoogleTestDiscoveryFlushScript.cmake
@@ -0,0 +1,14 @@
+enable_language(CXX)
+include(GoogleTest)
+
+enable_testing()
+
+include(xcode_sign_adhoc.cmake)
+
+add_executable(flush_script_test flush_script_test.cpp)
+xcode_sign_adhoc(flush_script_test)
+gtest_discover_tests(
+ flush_script_test
+)
+set_property(DIRECTORY APPEND PROPERTY TEST_INCLUDE_FILES
+ ${CMAKE_CURRENT_SOURCE_DIR}/GoogleTest-discovery-flush-script-check-list.cmake)
diff --git a/Tests/RunCMake/GoogleTest/GoogleTestDiscoveryTestList.cmake b/Tests/RunCMake/GoogleTest/GoogleTestDiscoveryTestList.cmake
new file mode 100644
index 0000000000..5f4f859b3b
--- /dev/null
+++ b/Tests/RunCMake/GoogleTest/GoogleTestDiscoveryTestList.cmake
@@ -0,0 +1,14 @@
+enable_language(CXX)
+include(GoogleTest)
+
+enable_testing()
+
+include(xcode_sign_adhoc.cmake)
+
+add_executable(test_list_test test_list_test.cpp)
+xcode_sign_adhoc(test_list_test)
+gtest_discover_tests(
+ test_list_test
+)
+set_property(DIRECTORY APPEND PROPERTY TEST_INCLUDE_FILES
+ ${CMAKE_CURRENT_SOURCE_DIR}/GoogleTest-discovery-check-test-list.cmake)
diff --git a/Tests/RunCMake/GoogleTest/RunCMakeTest.cmake b/Tests/RunCMake/GoogleTest/RunCMakeTest.cmake
index 33a4b4353d..695f562fb4 100644
--- a/Tests/RunCMake/GoogleTest/RunCMakeTest.cmake
+++ b/Tests/RunCMake/GoogleTest/RunCMakeTest.cmake
@@ -236,6 +236,58 @@ function(run_GoogleTest_discovery_multi_config)
endfunction()
+function(run_GoogleTest_discovery_test_list DISCOVERY_MODE)
+ # Use a single build tree for a few tests without cleaning.
+ set(RunCMake_TEST_BINARY_DIR ${RunCMake_BINARY_DIR}/GoogleTest-discovery-test-list-build)
+ set(RunCMake_TEST_NO_CLEAN 1)
+ if(NOT RunCMake_GENERATOR_IS_MULTI_CONFIG)
+ set(RunCMake_TEST_OPTIONS -DCMAKE_BUILD_TYPE=Debug)
+ endif()
+ file(REMOVE_RECURSE "${RunCMake_TEST_BINARY_DIR}")
+ file(MAKE_DIRECTORY "${RunCMake_TEST_BINARY_DIR}")
+
+ run_cmake_with_options(GoogleTestDiscoveryTestList -DCMAKE_GTEST_DISCOVER_TESTS_DISCOVERY_MODE=${DISCOVERY_MODE})
+
+ run_cmake_command(GoogleTest-discovery-test-list-build
+ ${CMAKE_COMMAND}
+ --build .
+ --config Debug
+ --target test_list_test
+ )
+
+ run_cmake_command(GoogleTest-discovery-test-list-test
+ ${CMAKE_CTEST_COMMAND}
+ -C Debug
+ --no-label-summary
+ )
+endfunction()
+
+function(run_GoogleTest_discovery_flush_script DISCOVERY_MODE)
+ # Use a single build tree for a few tests without cleaning.
+ set(RunCMake_TEST_BINARY_DIR ${RunCMake_BINARY_DIR}/GoogleTest-discovery-flush-script-build)
+ set(RunCMake_TEST_NO_CLEAN 1)
+ if(NOT RunCMake_GENERATOR_IS_MULTI_CONFIG)
+ set(RunCMake_TEST_OPTIONS -DCMAKE_BUILD_TYPE=Debug)
+ endif()
+ file(REMOVE_RECURSE "${RunCMake_TEST_BINARY_DIR}")
+ file(MAKE_DIRECTORY "${RunCMake_TEST_BINARY_DIR}")
+
+ run_cmake_with_options(GoogleTestDiscoveryFlushScript -DCMAKE_GTEST_DISCOVER_TESTS_DISCOVERY_MODE=${DISCOVERY_MODE})
+
+ run_cmake_command(GoogleTest-discovery-flush-script-build
+ ${CMAKE_COMMAND}
+ --build .
+ --config Debug
+ --target flush_script_test
+ )
+
+ run_cmake_command(GoogleTest-discovery-flush-script-test
+ ${CMAKE_CTEST_COMMAND}
+ -C Debug
+ --no-label-summary
+ )
+endfunction()
+
foreach(DISCOVERY_MODE POST_BUILD PRE_TEST)
message("Testing ${DISCOVERY_MODE} discovery mode via CMAKE_GTEST_DISCOVER_TESTS_DISCOVERY_MODE global override...")
run_GoogleTest(${DISCOVERY_MODE})
@@ -246,6 +298,8 @@ foreach(DISCOVERY_MODE POST_BUILD PRE_TEST)
NOT "${DISCOVERY_MODE};${RunCMake_GENERATOR}" MATCHES "^POST_BUILD;Visual Studio 9")
run_GoogleTest_discovery_arg_change(${DISCOVERY_MODE})
endif()
+ run_GoogleTest_discovery_test_list(${DISCOVERY_MODE})
+ run_GoogleTest_discovery_flush_script(${DISCOVERY_MODE})
endforeach()
if(RunCMake_GENERATOR_IS_MULTI_CONFIG)
diff --git a/Tests/RunCMake/GoogleTest/flush_script_test.cpp b/Tests/RunCMake/GoogleTest/flush_script_test.cpp
new file mode 100644
index 0000000000..9473bb5de8
--- /dev/null
+++ b/Tests/RunCMake/GoogleTest/flush_script_test.cpp
@@ -0,0 +1,19 @@
+#include <iostream>
+#include <string>
+
+int main(int argc, char** argv)
+{
+ // Note: GoogleTest.cmake doesn't actually depend on Google Test as such;
+ // it only requires that we produces output in the expected format when
+ // invoked with --gtest_list_tests. Thus, we fake that here. This allows us
+ // to test the module without actually needing Google Test.
+ if (argc > 1 && std::string(argv[1]) == "--gtest_list_tests") {
+ std::cout << "flush_script_test.\n";
+ const size_t flushThreshold = 50000;
+ const size_t testCaseNum = 4;
+ std::string testName(flushThreshold / (testCaseNum - 1), 'T');
+ for (size_t i = 0; i < testCaseNum; ++i)
+ std::cout << " " << testName.c_str() << "\n";
+ }
+ return 0;
+}
diff --git a/Tests/RunCMake/GoogleTest/test_list_test.cpp b/Tests/RunCMake/GoogleTest/test_list_test.cpp
new file mode 100644
index 0000000000..c9f9512895
--- /dev/null
+++ b/Tests/RunCMake/GoogleTest/test_list_test.cpp
@@ -0,0 +1,18 @@
+#include <iostream>
+#include <string>
+
+int main(int argc, char** argv)
+{
+ // Note: GoogleTest.cmake doesn't actually depend on Google Test as such;
+ // it only requires that we produces output in the expected format when
+ // invoked with --gtest_list_tests. Thus, we fake that here. This allows us
+ // to test the module without actually needing Google Test.
+ if (argc > 1 && std::string(argv[1]) == "--gtest_list_tests") {
+ std::cout << "test_list_test/test.\n";
+ std::cout << " case/0 # GetParam() = \"semicolon;\"\n";
+ std::cout << " case/1 # GetParam() = 'osb['\n";
+ std::cout << " case/2 # GetParam() = 'csb]'\n";
+ std::cout << " case/3 # GetParam() = 'S p a c e s'\n";
+ }
+ return 0;
+}
diff --git a/Tests/RunCMake/find_package/FromPATHEnv-stderr.txt b/Tests/RunCMake/find_package/FromPATHEnv-stderr.txt
index b35f05ea1b..691d7f0610 100644
--- a/Tests/RunCMake/find_package/FromPATHEnv-stderr.txt
+++ b/Tests/RunCMake/find_package/FromPATHEnv-stderr.txt
@@ -1,20 +1,80 @@
-CMake Debug Log at FromPATHEnv.cmake:5 \(find_package\):
- find_package considered the following paths for Resolved.cmake.*
-.*/Modules/FindResolved.cmake.*
- The file was not found.*
- <PackageName>_ROOT CMake variable.*
- CMAKE_PREFIX_PATH variable.*
- CMAKE_FRAMEWORK_PATH and CMAKE_APPBUNDLE_PATH variables.*
- Env variable Resolved_DIR.*
- CMAKE_PREFIX_PATH env variable.*
- Paths specified by the find_package HINTS option.*
- Standard system environment variables.*
-.*Tests/RunCMake/find_package/PackageRoot.*
- CMake User Package Registry.*
- CMake variables defined in the Platform file.*
- CMake System Package Registry.*
- Paths specified by the find_package PATHS option.*
- find_package considered the following locations for the Config module:.*
-.*Tests/RunCMake/find_package/PackageRoot/ResolvedConfig\.cmake.*
- The file was found at.*
-.*Tests/RunCMake/find_package/PackageRoot/ResolvedConfig\.cmake
+^CMake Debug Log at FromPATHEnv.cmake:[0-9]+ \(find_package\):
+ find_package considered the following paths for FindResolved.cmake:
+
+ [^
+]*/Modules/FindResolved.cmake
+
+ The file was not found.
+
+ <PackageName>_ROOT CMake variable \[CMAKE_FIND_USE_PACKAGE_ROOT_PATH\].
+
+ none
+
+ CMAKE_PREFIX_PATH variable \[CMAKE_FIND_USE_CMAKE_PATH\].
+
+ none
+
+ CMAKE_FRAMEWORK_PATH and CMAKE_APPBUNDLE_PATH variables
+ \[CMAKE_FIND_USE_CMAKE_PATH\].
+
+ none
+
+ Env variable Resolved_DIR \[CMAKE_FIND_USE_CMAKE_ENVIRONMENT_PATH\].
+
+ none
+
+ CMAKE_PREFIX_PATH env variable \[CMAKE_FIND_USE_CMAKE_ENVIRONMENT_PATH\].
+(
+ [^
+]+)+
+
+ CMAKE_FRAMEWORK_PATH and CMAKE_APPBUNDLE_PATH env variables
+ \[CMAKE_FIND_USE_CMAKE_ENVIRONMENT_PATH\].
+(
+ [^
+]+)+
+
+ Paths specified by the find_package HINTS option.
+
+ none
+
+ Standard system environment variables
+ \[CMAKE_FIND_USE_SYSTEM_ENVIRONMENT_PATH\].
+
+ [^
+]*/Tests/RunCMake/find_package/PackageRoot
+
+ CMake User Package Registry \[CMAKE_FIND_USE_PACKAGE_REGISTRY\].
+(
+ [^
+]+)+
+
+ CMake variables defined in the Platform file
+ \[CMAKE_FIND_USE_CMAKE_SYSTEM_PATH\].
+(
+ [^
+]+)+
+
+ CMake System Package Registry
+ \[CMAKE_FIND_PACKAGE_NO_SYSTEM_PACKAGE_REGISTRY\].
+(
+ [^
+]+)+
+
+ Paths specified by the find_package PATHS option.
+
+ none
+
+ find_package considered the following locations for Resolved's Config
+ module:
+
+ [^
+]*/Tests/RunCMake/find_package/PackageRoot/ResolvedConfig.cmake
+
+ The file was found at
+
+ [^
+]*/Tests/RunCMake/find_package/PackageRoot/ResolvedConfig.cmake
+
+Call Stack \(most recent call first\):
+ CMakeLists.txt:[0-9]+ \(include\)$
diff --git a/Tests/RunCMake/find_package/FromPATHEnv.cmake b/Tests/RunCMake/find_package/FromPATHEnv.cmake
index ceb79b6829..9158d4b7c8 100644
--- a/Tests/RunCMake/find_package/FromPATHEnv.cmake
+++ b/Tests/RunCMake/find_package/FromPATHEnv.cmake
@@ -1,4 +1,7 @@
set(ENV_PATH "$ENV{PATH}")
+set(ENV_CMAKE_PREFIX_PATH "$ENV{CMAKE_PREFIX_PATH}")
+
+set(ENV{CMAKE_PREFIX_PATH} "")
set(CMAKE_FIND_DEBUG_MODE ON)
set(ENV{PATH} "${CMAKE_CURRENT_SOURCE_DIR}/PackageRoot")
@@ -30,4 +33,6 @@ foreach(path "/does_not_exist" "/PackageRoot" "")
find_package(Resolved NO_SYSTEM_ENVIRONMENT_PATH QUIET)
message(STATUS "Resolved_FOUND='${Resolved_FOUND}'")
endforeach()
+
+set(ENV{CMAKE_PREFIX_PATH} "${ENV_CMAKE_PREFIX_PATH}")
set(ENV{PATH} "${ENV_PATH}")
diff --git a/Tests/RunCMake/find_package/FromPATHEnvDebugPkg-stderr.txt b/Tests/RunCMake/find_package/FromPATHEnvDebugPkg-stderr.txt
index 94ed178b63..ef5ec335ff 100644
--- a/Tests/RunCMake/find_package/FromPATHEnvDebugPkg-stderr.txt
+++ b/Tests/RunCMake/find_package/FromPATHEnvDebugPkg-stderr.txt
@@ -1,21 +1,80 @@
-CMake Debug Log at FromPATHEnvDebugPkg.cmake:4 \(find_package\):
- find_package considered the following paths for Resolved.cmake.*
-.*/Modules/FindResolved.cmake.*
- The file was not found.*
- <PackageName>_ROOT CMake variable.*
- CMAKE_PREFIX_PATH variable.*
- CMAKE_FRAMEWORK_PATH and CMAKE_APPBUNDLE_PATH variables.*
- Env variable Resolved_DIR.*
- CMAKE_PREFIX_PATH env variable.*
- CMAKE_FRAMEWORK_PATH and CMAKE_APPBUNDLE_PATH env variables.*
- Paths specified by the find_package HINTS option.*
- Standard system environment variables.*
-.*Tests/RunCMake/find_package/PackageRoot.*
- CMake User Package Registry.*
- CMake variables defined in the Platform file.*
- CMake System Package Registry.*
- Paths specified by the find_package PATHS option.*
- find_package considered the following locations for the Config module:.*
-.*Tests/RunCMake/find_package/PackageRoot/ResolvedConfig\.cmake.*
- The file was found at.*
-.*Tests/RunCMake/find_package/PackageRoot/ResolvedConfig\.cmake
+^CMake Debug Log at FromPATHEnvDebugPkg.cmake:[0-9]+ \(find_package\):
+ find_package considered the following paths for FindResolved.cmake:
+
+ [^
+]*/Modules/FindResolved.cmake
+
+ The file was not found.
+
+ <PackageName>_ROOT CMake variable \[CMAKE_FIND_USE_PACKAGE_ROOT_PATH\].
+
+ none
+
+ CMAKE_PREFIX_PATH variable \[CMAKE_FIND_USE_CMAKE_PATH\].
+
+ none
+
+ CMAKE_FRAMEWORK_PATH and CMAKE_APPBUNDLE_PATH variables
+ \[CMAKE_FIND_USE_CMAKE_PATH\].
+
+ none
+
+ Env variable Resolved_DIR \[CMAKE_FIND_USE_CMAKE_ENVIRONMENT_PATH\].
+
+ none
+
+ CMAKE_PREFIX_PATH env variable \[CMAKE_FIND_USE_CMAKE_ENVIRONMENT_PATH\].
+(
+ [^
+]+)+
+
+ CMAKE_FRAMEWORK_PATH and CMAKE_APPBUNDLE_PATH env variables
+ \[CMAKE_FIND_USE_CMAKE_ENVIRONMENT_PATH\].
+(
+ [^
+]+)+
+
+ Paths specified by the find_package HINTS option.
+
+ none
+
+ Standard system environment variables
+ \[CMAKE_FIND_USE_SYSTEM_ENVIRONMENT_PATH\].
+
+ [^
+]*/Tests/RunCMake/find_package/PackageRoot
+
+ CMake User Package Registry \[CMAKE_FIND_USE_PACKAGE_REGISTRY\].
+(
+ [^
+]+)+
+
+ CMake variables defined in the Platform file
+ \[CMAKE_FIND_USE_CMAKE_SYSTEM_PATH\].
+(
+ [^
+]+)+
+
+ CMake System Package Registry
+ \[CMAKE_FIND_PACKAGE_NO_SYSTEM_PACKAGE_REGISTRY\].
+(
+ [^
+]+)+
+
+ Paths specified by the find_package PATHS option.
+
+ none
+
+ find_package considered the following locations for Resolved's Config
+ module:
+
+ [^
+]*/Tests/RunCMake/find_package/PackageRoot/ResolvedConfig.cmake
+
+ The file was found at
+
+ [^
+]*/Tests/RunCMake/find_package/PackageRoot/ResolvedConfig.cmake
+
+Call Stack \(most recent call first\):
+ CMakeLists.txt:[0-9]+ \(include\)$
diff --git a/Tests/RunCMake/find_package/FromPATHEnvDebugPkg.cmake b/Tests/RunCMake/find_package/FromPATHEnvDebugPkg.cmake
index 0ed8a12e38..72b03e6b2f 100644
--- a/Tests/RunCMake/find_package/FromPATHEnvDebugPkg.cmake
+++ b/Tests/RunCMake/find_package/FromPATHEnvDebugPkg.cmake
@@ -1,4 +1,7 @@
set(ENV_PATH "$ENV{PATH}")
+set(ENV_CMAKE_PREFIX_PATH "$ENV{CMAKE_PREFIX_PATH}")
+
+set(ENV{CMAKE_PREFIX_PATH} "")
set(ENV{PATH} "${CMAKE_CURRENT_SOURCE_DIR}/PackageRoot")
find_package(Resolved QUIET)
@@ -28,4 +31,6 @@ foreach(path "/does_not_exist" "/PackageRoot" "")
find_package(ResolvedC NO_SYSTEM_ENVIRONMENT_PATH QUIET)
message(STATUS "Resolved_FOUND='${ResolvedC_FOUND}'")
endforeach()
+
+set(ENV{CMAKE_PREFIX_PATH} "${ENV_CMAKE_PREFIX_PATH}")
set(ENV{PATH} "${ENV_PATH}")
diff --git a/Tests/RunCMake/find_package/ModuleModeDebugPkg-stderr.txt b/Tests/RunCMake/find_package/ModuleModeDebugPkg-stderr.txt
new file mode 100644
index 0000000000..e4fd7c5a59
--- /dev/null
+++ b/Tests/RunCMake/find_package/ModuleModeDebugPkg-stderr.txt
@@ -0,0 +1,128 @@
+^CMake Debug Log at ModuleModeDebugPkg/FindFoo.cmake:[0-9]+ \(find_program\):
+ find_program called with the following settings:
+
+ VAR: FOO_EXE
+ NAMES: "ModuleModeDebugPkgFooExe"
+ Documentation: Path to a program.
+ Framework
+ Only Search Frameworks: 0
+ Search Frameworks Last: 0
+ Search Frameworks First: [01]
+ AppBundle
+ Only Search AppBundle: 0
+ Search AppBundle Last: 0
+ Search AppBundle First: [01]
+ NO_DEFAULT_PATH Enabled
+
+ find_program considered the following locations:
+
+ The item was not found.
+
+Call Stack \(most recent call first\):
+ ModuleModeDebugPkg.cmake:[0-9]+ \(find_package\)
+ CMakeLists.txt:[0-9]+ \(include\)
++
+CMake Debug Log at ModuleModeDebugPkg/FindFoo.cmake:[0-9]+ \(find_library\):
+ find_library called with the following settings:
+
+ VAR: FOO_LIB
+ NAMES: "ModuleModeDebugPkgFooLib"
+ Documentation: Path to a library.
+ Framework
+ Only Search Frameworks: 0
+ Search Frameworks Last: 0
+ Search Frameworks First: [01]
+ AppBundle
+ Only Search AppBundle: 0
+ Search AppBundle Last: 0
+ Search AppBundle First: [01]
+ NO_DEFAULT_PATH Enabled
+
+ find_library considered the following locations:
+
+ The item was not found.
+
+Call Stack \(most recent call first\):
+ ModuleModeDebugPkg.cmake:[0-9]+ \(find_package\)
+ CMakeLists.txt:[0-9]+ \(include\)
++
+CMake Debug Log at ModuleModeDebugPkg/FindFoo.cmake:[0-9]+ \(find_path\):
+ find_path called with the following settings:
+
+ VAR: FOO_PATH
+ NAMES: "ModuleModeDebugPkgFoo.h"
+ Documentation: Path to a file.
+ Framework
+ Only Search Frameworks: 0
+ Search Frameworks Last: 0
+ Search Frameworks First: [01]
+ AppBundle
+ Only Search AppBundle: 0
+ Search AppBundle Last: 0
+ Search AppBundle First: [01]
+ NO_DEFAULT_PATH Enabled
+
+ find_path considered the following locations:
+
+ The item was not found.
+
+Call Stack \(most recent call first\):
+ ModuleModeDebugPkg.cmake:[0-9]+ \(find_package\)
+ CMakeLists.txt:[0-9]+ \(include\)
++
+CMake Debug Log at ModuleModeDebugPkg/FindFoo.cmake:[0-9]+ \(find_file\):
+ find_file called with the following settings:
+
+ VAR: FOO_FILE
+ NAMES: "ModuleModeDebugPkgFoo.h"
+ Documentation: Path to a file.
+ Framework
+ Only Search Frameworks: 0
+ Search Frameworks Last: 0
+ Search Frameworks First: [01]
+ AppBundle
+ Only Search AppBundle: 0
+ Search AppBundle Last: 0
+ Search AppBundle First: [01]
+ NO_DEFAULT_PATH Enabled
+
+ find_file considered the following locations:
+
+ The item was not found.
+
+Call Stack \(most recent call first\):
+ ModuleModeDebugPkg.cmake:[0-9]+ \(find_package\)
+ CMakeLists.txt:[0-9]+ \(include\)
++
+FindBar processed here.
++
+CMake Debug Log at ModuleModeDebugPkg/FindFoo.cmake:[0-9]+ \(find_package\):
+ Paths specified by the find_package HINTS option.
+
+ none
+
+ Paths specified by the find_package PATHS option.
+
+ none
+
+ find_package considered the following locations for Zot's Config module:
+
+ The file was not found.
+
+Call Stack \(most recent call first\):
+ ModuleModeDebugPkg.cmake:[0-9]+ \(find_package\)
+ CMakeLists.txt:[0-9]+ \(include\)
++
+CMake Debug Log at ModuleModeDebugPkg.cmake:[0-9]+ \(find_package\):
+ find_package considered the following paths for FindFoo.cmake:
+
+ [^
+]*/Modules/FindFoo.cmake
+
+ The file was found at
+
+ [^
+]*/Tests/RunCMake/find_package/ModuleModeDebugPkg/FindFoo.cmake
+
+Call Stack \(most recent call first\):
+ CMakeLists.txt:[0-9]+ \(include\)$
diff --git a/Tests/RunCMake/find_package/ModuleModeDebugPkg.cmake b/Tests/RunCMake/find_package/ModuleModeDebugPkg.cmake
new file mode 100644
index 0000000000..d9cac094b8
--- /dev/null
+++ b/Tests/RunCMake/find_package/ModuleModeDebugPkg.cmake
@@ -0,0 +1,2 @@
+list(APPEND CMAKE_MODULE_PATH ${CMAKE_CURRENT_SOURCE_DIR}/ModuleModeDebugPkg)
+find_package(Foo)
diff --git a/Tests/RunCMake/find_package/ModuleModeDebugPkg/FindBar.cmake b/Tests/RunCMake/find_package/ModuleModeDebugPkg/FindBar.cmake
new file mode 100644
index 0000000000..0711118f70
--- /dev/null
+++ b/Tests/RunCMake/find_package/ModuleModeDebugPkg/FindBar.cmake
@@ -0,0 +1,2 @@
+message("FindBar processed here.\n")
+find_program(BAR_EXE NAMES ModuleModeDebugPkgBarExe NO_DEFAULT_PATH)
diff --git a/Tests/RunCMake/find_package/ModuleModeDebugPkg/FindFoo.cmake b/Tests/RunCMake/find_package/ModuleModeDebugPkg/FindFoo.cmake
new file mode 100644
index 0000000000..23a15b4114
--- /dev/null
+++ b/Tests/RunCMake/find_package/ModuleModeDebugPkg/FindFoo.cmake
@@ -0,0 +1,6 @@
+find_program(FOO_EXE NAMES ModuleModeDebugPkgFooExe NO_DEFAULT_PATH)
+find_library(FOO_LIB NAMES ModuleModeDebugPkgFooLib NO_DEFAULT_PATH)
+find_path(FOO_PATH NAMES ModuleModeDebugPkgFoo.h NO_DEFAULT_PATH)
+find_file(FOO_FILE NAMES ModuleModeDebugPkgFoo.h NO_DEFAULT_PATH)
+find_package(Bar) # not included
+find_package(Zot NO_MODULE NO_DEFAULT_PATH) # is included
diff --git a/Tests/RunCMake/find_package/RunCMakeTest.cmake b/Tests/RunCMake/find_package/RunCMakeTest.cmake
index 037502f623..5f4c6cbd4f 100644
--- a/Tests/RunCMake/find_package/RunCMakeTest.cmake
+++ b/Tests/RunCMake/find_package/RunCMakeTest.cmake
@@ -4,6 +4,7 @@ run_cmake(CMP0074-WARN)
run_cmake(CMP0074-OLD)
run_cmake(ComponentRequiredAndOptional)
run_cmake(FromPATHEnv)
+run_cmake_with_options(FromPATHEnvDebugPkg --debug-find-pkg=Resolved)
run_cmake(FromPrefixPath)
run_cmake(MissingNormal)
run_cmake(MissingNormalForceRequired)
@@ -15,10 +16,12 @@ run_cmake(MissingModule)
run_cmake(MissingModuleRequired)
run_cmake(MissingConfig)
run_cmake(MissingConfigDebug)
+run_cmake_with_options(MissingConfigDebugPkg --debug-find-pkg=NotHere)
run_cmake(MissingConfigOneName)
run_cmake(MissingConfigRequired)
run_cmake(MissingConfigVersion)
run_cmake(MixedModeOptions)
+run_cmake_with_options(ModuleModeDebugPkg --debug-find-pkg=Foo,Zot)
run_cmake(PackageRoot)
run_cmake(PackageRootNestedConfig)
run_cmake(PackageRootNestedModule)
@@ -51,6 +54,3 @@ if(UNIX
)
run_cmake(SetFoundResolved)
endif()
-
-run_cmake_with_options(MissingConfigDebugPkg --debug-find-pkg=NotHere)
-run_cmake_with_options(FromPATHEnvDebugPkg --debug-find-pkg=Resolved)
diff --git a/Tests/RunCMake/if/AndOr-stdout.txt b/Tests/RunCMake/if/AndOr-stdout.txt
new file mode 100644
index 0000000000..9fd395bd2a
--- /dev/null
+++ b/Tests/RunCMake/if/AndOr-stdout.txt
@@ -0,0 +1 @@
+-- OR and AND correctly evaluated left to right
diff --git a/Tests/RunCMake/if/AndOr.cmake b/Tests/RunCMake/if/AndOr.cmake
new file mode 100644
index 0000000000..847d6f270a
--- /dev/null
+++ b/Tests/RunCMake/if/AndOr.cmake
@@ -0,0 +1,6 @@
+# AND and OR are the same precedence
+if(1 OR 0 AND 0) # equivalent to ((1 OR 0) AND 0)
+ message(FATAL_ERROR "AND incorrectly evaluated before OR")
+else()
+ message(STATUS "OR and AND correctly evaluated left to right")
+endif()
diff --git a/Tests/RunCMake/if/RunCMakeTest.cmake b/Tests/RunCMake/if/RunCMakeTest.cmake
index 6baa840592..de9cb5775f 100644
--- a/Tests/RunCMake/if/RunCMakeTest.cmake
+++ b/Tests/RunCMake/if/RunCMakeTest.cmake
@@ -17,3 +17,5 @@ run_cmake(IncompleteMatchesFail)
run_cmake(TestNameThatExists)
run_cmake(TestNameThatDoesNotExist)
+
+run_cmake_script(AndOr)
diff --git a/Tests/RunCMake/install/EXPORT-TargetTwice-check.cmake b/Tests/RunCMake/install/EXPORT-TargetTwice-check.cmake
new file mode 100644
index 0000000000..97677cad48
--- /dev/null
+++ b/Tests/RunCMake/install/EXPORT-TargetTwice-check.cmake
@@ -0,0 +1,19 @@
+set(pkg1_cmake "${RunCMake_TEST_BINARY_DIR}/CMakeFiles/Export/pkg1/pkg1.cmake")
+file(STRINGS "${pkg1_cmake}" pkg1_includes REGEX INTERFACE_INCLUDE_DIRECTORIES)
+set(pkg1_expect [[INTERFACE_INCLUDE_DIRECTORIES "\${_IMPORT_PREFIX}/pkg1/inc"]])
+if(NOT pkg1_includes MATCHES "${pkg1_expect}")
+ set(RunCMake_TEST_FAILED "pkg1 has unexpected INTERFACE_INCLUDE_DIRECTORIES line:
+ ${pkg1_includes}
+It does not match:
+ ${pkg1_expect}")
+endif()
+
+set(pkg2_cmake "${RunCMake_TEST_BINARY_DIR}/CMakeFiles/Export/pkg2/pkg2.cmake")
+file(STRINGS "${pkg2_cmake}" pkg2_includes REGEX INTERFACE_INCLUDE_DIRECTORIES)
+set(pkg2_expect [[INTERFACE_INCLUDE_DIRECTORIES "\${_IMPORT_PREFIX}/pkg2/inc"]])
+if(NOT pkg2_includes MATCHES "${pkg2_expect}")
+ set(RunCMake_TEST_FAILED "pkg2 has unexpected INTERFACE_INCLUDE_DIRECTORIES line:
+ ${pkg2_includes}
+It does not match:
+ ${pkg2_expect}")
+endif()
diff --git a/Tests/RunCMake/install/EXPORT-TargetTwice-pkg1.txt b/Tests/RunCMake/install/EXPORT-TargetTwice-pkg1.txt
new file mode 100644
index 0000000000..592f79c688
--- /dev/null
+++ b/Tests/RunCMake/install/EXPORT-TargetTwice-pkg1.txt
@@ -0,0 +1,5 @@
+.+
+set_target_properties\(pkg1::foo PROPERTIES
+.+INTERFACE_INCLUDE_DIRECTORIES "\${_IMPORT_PREFIX}/pkg1/inc"
+\)
+.+
diff --git a/Tests/RunCMake/install/EXPORT-TargetTwice-pkg2.txt b/Tests/RunCMake/install/EXPORT-TargetTwice-pkg2.txt
new file mode 100644
index 0000000000..ebfc43e344
--- /dev/null
+++ b/Tests/RunCMake/install/EXPORT-TargetTwice-pkg2.txt
@@ -0,0 +1,5 @@
+.+
+set_target_properties\(pkg2::foo PROPERTIES
+.+INTERFACE_INCLUDE_DIRECTORIES "\${_IMPORT_PREFIX}/pkg2/inc"
+\)
+.+
diff --git a/Tests/RunCMake/install/EXPORT-TargetTwice.cmake b/Tests/RunCMake/install/EXPORT-TargetTwice.cmake
new file mode 100644
index 0000000000..cac4ff2adc
--- /dev/null
+++ b/Tests/RunCMake/install/EXPORT-TargetTwice.cmake
@@ -0,0 +1,17 @@
+enable_language(C)
+
+add_library(foo STATIC empty.c)
+
+install(TARGETS foo
+ EXPORT pkg1
+ ARCHIVE DESTINATION pkg1/lib
+ INCLUDES DESTINATION pkg1/inc
+ )
+install(EXPORT pkg1 DESTINATION pkg1)
+
+install(TARGETS foo
+ EXPORT pkg2
+ ARCHIVE DESTINATION pkg2/lib
+ INCLUDES DESTINATION pkg2/inc
+ )
+install(EXPORT pkg2 DESTINATION pkg2)
diff --git a/Tests/RunCMake/install/RunCMakeTest.cmake b/Tests/RunCMake/install/RunCMakeTest.cmake
index f79a3ea745..7c12d4a315 100644
--- a/Tests/RunCMake/install/RunCMakeTest.cmake
+++ b/Tests/RunCMake/install/RunCMakeTest.cmake
@@ -82,6 +82,7 @@ run_cmake(EXPORT-OldIFace)
run_cmake(EXPORT-UnknownExport)
run_cmake(EXPORT-NamelinkOnly)
run_cmake(EXPORT-SeparateNamelink)
+run_cmake(EXPORT-TargetTwice)
run_cmake(CMP0062-OLD)
run_cmake(CMP0062-NEW)
run_cmake(CMP0062-WARN)