summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--.gitlab/ci/configure_macos_common.cmake2
-rw-r--r--.gitlab/ci/configure_windows_common.cmake1
-rw-r--r--Help/command/if.rst11
-rw-r--r--Help/command/list.rst15
-rw-r--r--Help/manual/cmake-properties.7.rst1
-rw-r--r--Help/manual/cmake-variables.7.rst1
-rw-r--r--Help/manual/cmake.1.rst14
-rw-r--r--Help/policy/CMP0028.rst2
-rw-r--r--Help/policy/CMP0126.rst3
-rw-r--r--Help/prop_tgt/LINK_LIBRARIES_ONLY_TARGETS.rst55
-rw-r--r--Help/release/dev/FindGLUT-include-dirs.rst7
-rw-r--r--Help/release/dev/filter-debug-find.rst10
-rw-r--r--Help/release/dev/link-only-targets.rst7
-rw-r--r--Help/variable/CMAKE_LINK_LIBRARIES_ONLY_TARGETS.rst10
-rw-r--r--Modules/CMakeDetermineCompilerId.cmake8
-rw-r--r--Modules/FetchContent.cmake2
-rw-r--r--Modules/FindBoost.cmake33
-rw-r--r--Modules/FindGLUT.cmake65
-rw-r--r--Modules/FindGSL.cmake2
-rw-r--r--Modules/GoogleTestAddTests.cmake7
-rw-r--r--Modules/Internal/CPack/CPackFreeBSD.cmake2
-rw-r--r--Source/CMakeVersion.cmake2
-rw-r--r--Source/CPack/cmCPackFreeBSDGenerator.cxx143
-rw-r--r--Source/cmExportTryCompileFileGenerator.cxx10
-rw-r--r--Source/cmFindCommon.cxx6
-rw-r--r--Source/cmFindCommon.h3
-rw-r--r--Source/cmFindLibraryCommand.cxx3
-rw-r--r--Source/cmFindPackageCommand.cxx14
-rw-r--r--Source/cmFindPackageCommand.h2
-rw-r--r--Source/cmFindPathCommand.cxx3
-rw-r--r--Source/cmFindProgramCommand.cxx3
-rw-r--r--Source/cmGeneratorTarget.cxx277
-rw-r--r--Source/cmGeneratorTarget.h17
-rw-r--r--Source/cmGlobalGenerator.cxx15
-rw-r--r--Source/cmGlobalGenerator.h1
-rw-r--r--Source/cmLocalGenerator.h5
-rw-r--r--Source/cmLocalVisualStudio7Generator.cxx12
-rw-r--r--Source/cmLocalVisualStudioGenerator.cxx17
-rw-r--r--Source/cmLocalVisualStudioGenerator.h7
-rw-r--r--Source/cmTarget.cxx31
-rw-r--r--Source/cmTarget.h2
-rw-r--r--Source/cmVisualStudio10TargetGenerator.cxx29
-rw-r--r--Source/cmake.cxx51
-rw-r--r--Source/cmake.h9
-rw-r--r--Source/cmakemain.cxx4
-rw-r--r--Tests/CudaOnly/ExportPTX/CMakeLists.txt1
-rw-r--r--Tests/CudaOnly/ExportPTX/kernelA.cu4
-rw-r--r--Tests/CudaOnly/ExportPTX/kernelB.cu3
-rw-r--r--Tests/RunCMake/CMP0028/CMP0028-NEW-iface-stderr.txt6
-rw-r--r--Tests/RunCMake/CMP0028/CMP0028-NEW-stderr.txt6
-rw-r--r--Tests/RunCMake/CMakeLists.txt2
-rw-r--r--Tests/RunCMake/GeneratorToolset/VsNormal-stdout.txt2
-rw-r--r--Tests/RunCMake/LinkItemValidation/CMP0028-NEW-iface-result.txt (renamed from Tests/RunCMake/CMP0028/CMP0028-NEW-iface-result.txt)0
-rw-r--r--Tests/RunCMake/LinkItemValidation/CMP0028-NEW-iface-stderr.txt12
-rw-r--r--Tests/RunCMake/LinkItemValidation/CMP0028-NEW-iface.cmake (renamed from Tests/RunCMake/CMP0028/CMP0028-NEW-iface.cmake)0
-rw-r--r--Tests/RunCMake/LinkItemValidation/CMP0028-NEW-result.txt (renamed from Tests/RunCMake/CMP0028/CMP0028-NEW-result.txt)0
-rw-r--r--Tests/RunCMake/LinkItemValidation/CMP0028-NEW-stderr.txt12
-rw-r--r--Tests/RunCMake/LinkItemValidation/CMP0028-NEW.cmake (renamed from Tests/RunCMake/CMP0028/CMP0028-NEW.cmake)0
-rw-r--r--Tests/RunCMake/LinkItemValidation/CMP0028-OLD-iface-result.txt (renamed from Tests/RunCMake/CMP0028/CMP0028-OLD-iface-result.txt)0
-rw-r--r--Tests/RunCMake/LinkItemValidation/CMP0028-OLD-iface-stderr.txt (renamed from Tests/RunCMake/CMP0028/CMP0028-OLD-iface-stderr.txt)0
-rw-r--r--Tests/RunCMake/LinkItemValidation/CMP0028-OLD-iface.cmake (renamed from Tests/RunCMake/CMP0028/CMP0028-OLD-iface.cmake)0
-rw-r--r--Tests/RunCMake/LinkItemValidation/CMP0028-OLD-result.txt (renamed from Tests/RunCMake/CMP0028/CMP0028-OLD-result.txt)0
-rw-r--r--Tests/RunCMake/LinkItemValidation/CMP0028-OLD-stderr.txt (renamed from Tests/RunCMake/CMP0028/CMP0028-OLD-stderr.txt)0
-rw-r--r--Tests/RunCMake/LinkItemValidation/CMP0028-OLD.cmake (renamed from Tests/RunCMake/CMP0028/CMP0028-OLD.cmake)0
-rw-r--r--Tests/RunCMake/LinkItemValidation/CMP0028-WARN-iface-result.txt (renamed from Tests/RunCMake/CMP0028/CMP0028-WARN-iface-result.txt)0
-rw-r--r--Tests/RunCMake/LinkItemValidation/CMP0028-WARN-iface-stderr.txt (renamed from Tests/RunCMake/CMP0028/CMP0028-WARN-iface-stderr.txt)16
-rw-r--r--Tests/RunCMake/LinkItemValidation/CMP0028-WARN-iface.cmake (renamed from Tests/RunCMake/CMP0028/CMP0028-WARN-iface.cmake)0
-rw-r--r--Tests/RunCMake/LinkItemValidation/CMP0028-WARN-result.txt (renamed from Tests/RunCMake/CMP0028/CMP0028-WARN-result.txt)0
-rw-r--r--Tests/RunCMake/LinkItemValidation/CMP0028-WARN-stderr.txt (renamed from Tests/RunCMake/CMP0028/CMP0028-WARN-stderr.txt)16
-rw-r--r--Tests/RunCMake/LinkItemValidation/CMP0028-WARN.cmake (renamed from Tests/RunCMake/CMP0028/CMP0028-WARN.cmake)0
-rw-r--r--Tests/RunCMake/LinkItemValidation/CMakeLists.txt (renamed from Tests/RunCMake/CMP0028/CMakeLists.txt)3
-rw-r--r--Tests/RunCMake/LinkItemValidation/OnlyTargets-result.txt1
-rw-r--r--Tests/RunCMake/LinkItemValidation/OnlyTargets-stderr.txt40
-rw-r--r--Tests/RunCMake/LinkItemValidation/OnlyTargets.cmake56
-rw-r--r--Tests/RunCMake/LinkItemValidation/RunCMakeTest.cmake (renamed from Tests/RunCMake/CMP0028/RunCMakeTest.cmake)2
-rw-r--r--Tests/RunCMake/LinkItemValidation/empty.cpp (renamed from Tests/RunCMake/CMP0028/empty.cpp)0
-rw-r--r--Tests/RunCMake/LinkItemValidation/main.c4
-rw-r--r--Tests/RunCMake/TargetPropertyGeneratorExpressions/LinkImplementationCycle4-stderr.txt4
-rw-r--r--Tests/RunCMake/TargetPropertyGeneratorExpressions/LinkImplementationCycle5-stderr.txt4
-rw-r--r--Tests/RunCMake/TargetPropertyGeneratorExpressions/LinkImplementationCycle6-stderr.txt4
-rw-r--r--Tests/RunCMake/find_file/FromPATHEnvDebugVar-stderr.txt25
-rw-r--r--Tests/RunCMake/find_file/FromPATHEnvDebugVar-stdout-cygwin.txt9
-rw-r--r--Tests/RunCMake/find_file/FromPATHEnvDebugVar-stdout-msys.txt9
-rw-r--r--Tests/RunCMake/find_file/FromPATHEnvDebugVar-stdout-windows.txt9
-rw-r--r--Tests/RunCMake/find_file/FromPATHEnvDebugVar-stdout.txt9
-rw-r--r--Tests/RunCMake/find_file/FromPATHEnvDebugVar.cmake24
-rw-r--r--Tests/RunCMake/find_file/RunCMakeTest.cmake2
-rw-r--r--Tests/RunCMake/find_library/FromPATHEnvDebugVar-stderr.txt28
-rw-r--r--Tests/RunCMake/find_library/FromPATHEnvDebugVar-stdout-cygwin.txt6
-rw-r--r--Tests/RunCMake/find_library/FromPATHEnvDebugVar-stdout-msys.txt6
-rw-r--r--Tests/RunCMake/find_library/FromPATHEnvDebugVar-stdout-windows.txt6
-rw-r--r--Tests/RunCMake/find_library/FromPATHEnvDebugVar-stdout.txt6
-rw-r--r--Tests/RunCMake/find_library/FromPATHEnvDebugVar.cmake35
-rw-r--r--Tests/RunCMake/find_library/RunCMakeTest.cmake2
-rw-r--r--Tests/RunCMake/find_package/FromPATHEnvDebugPkg-stderr.txt21
-rw-r--r--Tests/RunCMake/find_package/FromPATHEnvDebugPkg-stdout.txt9
-rw-r--r--Tests/RunCMake/find_package/FromPATHEnvDebugPkg.cmake31
-rw-r--r--Tests/RunCMake/find_package/MissingConfigDebugPkg-stderr.txt20
-rw-r--r--Tests/RunCMake/find_package/MissingConfigDebugPkg.cmake2
-rw-r--r--Tests/RunCMake/find_package/RunCMakeTest.cmake3
-rw-r--r--Tests/RunCMake/find_path/FromPATHEnvDebugVar-stderr.txt27
-rw-r--r--Tests/RunCMake/find_path/FromPATHEnvDebugVar-stdout-cygwin.txt9
-rw-r--r--Tests/RunCMake/find_path/FromPATHEnvDebugVar-stdout-msys.txt9
-rw-r--r--Tests/RunCMake/find_path/FromPATHEnvDebugVar-stdout-windows.txt9
-rw-r--r--Tests/RunCMake/find_path/FromPATHEnvDebugVar-stdout.txt9
-rw-r--r--Tests/RunCMake/find_path/FromPATHEnvDebugVar.cmake35
-rw-r--r--Tests/RunCMake/find_path/RunCMakeTest.cmake2
-rw-r--r--Tests/RunCMake/find_program/EnvAndHintsDebugVar-stderr.txt28
-rw-r--r--Tests/RunCMake/find_program/EnvAndHintsDebugVar-stdout.txt4
-rw-r--r--Tests/RunCMake/find_program/EnvAndHintsDebugVar.cmake31
-rw-r--r--Tests/RunCMake/find_program/RunCMakeTest.cmake2
-rw-r--r--Tests/RunCMake/list/LIST-nonexistent.cmake45
-rw-r--r--Tests/RunCMake/list/RunCMakeTest.cmake3
-rw-r--r--Tests/RunCMake/target_link_libraries/CMP0079-link-NEW-bogus-stderr.txt14
-rw-r--r--Tests/RunCMake/target_link_libraries/ConfigCase-stderr.txt32
115 files changed, 1458 insertions, 185 deletions
diff --git a/.gitlab/ci/configure_macos_common.cmake b/.gitlab/ci/configure_macos_common.cmake
index 37cd51c..e78c9ce 100644
--- a/.gitlab/ci/configure_macos_common.cmake
+++ b/.gitlab/ci/configure_macos_common.cmake
@@ -2,7 +2,7 @@
# detect that Java is available and working, but a test machine then not have a
# working Java installed. To work around this, just act as if Java is not
# available on any CI machine.
-set(CMake_TEST_Java 0 CACHE FILEPATH "")
+set(CMake_TEST_Java OFF CACHE BOOL "")
# Qt binaries get placed inside the source directory, which causes them to not
# be included in the install-time rpath, but we still want them in the
diff --git a/.gitlab/ci/configure_windows_common.cmake b/.gitlab/ci/configure_windows_common.cmake
index 45250ac..112846a 100644
--- a/.gitlab/ci/configure_windows_common.cmake
+++ b/.gitlab/ci/configure_windows_common.cmake
@@ -1,4 +1,5 @@
set(BUILD_QtDialog ON CACHE BOOL "")
set(CMAKE_PREFIX_PATH "$ENV{CI_PROJECT_DIR}/.gitlab/qt" CACHE STRING "")
+set(CMake_TEST_Java OFF CACHE BOOL "")
include("${CMAKE_CURRENT_LIST_DIR}/configure_common.cmake")
diff --git a/Help/command/if.rst b/Help/command/if.rst
index 5dba13e..6957142 100644
--- a/Help/command/if.rst
+++ b/Help/command/if.rst
@@ -126,7 +126,16 @@ Existence Checks
``if(DEFINED <name>|CACHE{<name>}|ENV{<name>})``
True if a variable, cache variable or environment variable
with given ``<name>`` is defined. The value of the variable
- does not matter. Note that macro arguments are not variables.
+ does not matter. Note the following caveats:
+
+ * Macro arguments are not variables.
+ * It is not possible to test directly whether a `<name>` is a non-cache
+ variable. The expression ``if(DEFINED someName)`` will evaluate to true
+ if either a cache or non-cache variable ``someName`` exists. In
+ comparison, the expression ``if(DEFINED CACHE{someName})`` will only
+ evaluate to true if a cache variable ``someName`` exists. Both expressions
+ need to be tested if you need to know whether a non-cache variable exists:
+ ``if(DEFINED someName AND NOT DEFINED CACHE{someName})``.
.. versionadded:: 3.14
Added support for ``CACHE{<name>}`` variables.
diff --git a/Help/command/list.rst b/Help/command/list.rst
index 9b49cb4..33c4f80 100644
--- a/Help/command/list.rst
+++ b/Help/command/list.rst
@@ -128,7 +128,9 @@ Modification
list(APPEND <list> [<element> ...])
-Appends elements to the list.
+Appends elements to the list. If no variable named ``<list>`` exists in the
+current scope its value is treated as empty and the elements are appended to
+that empty list.
.. _FILTER:
@@ -150,7 +152,12 @@ For more information on regular expressions look under
list(INSERT <list> <element_index> <element> [<element> ...])
-Inserts elements to the list to the specified location.
+Inserts elements to the list to the specified index. It is an
+error to specify an out-of-range index. Valid indexes are 0 to `N`
+where `N` is the length of the list, inclusive. An empty list
+has length 0. If no variable named ``<list>`` exists in the
+current scope its value is treated as empty and the elements are
+inserted in that empty list.
.. _POP_BACK:
@@ -186,7 +193,9 @@ to the given variables and then remove the first `N` values from
.. versionadded:: 3.15
-Insert elements to the 0th position in the list.
+Insert elements to the 0th position in the list. If no variable named
+``<list>`` exists in the current scope its value is treated as empty and
+the elements are prepended to that empty list.
.. _REMOVE_ITEM:
diff --git a/Help/manual/cmake-properties.7.rst b/Help/manual/cmake-properties.7.rst
index 73e57d1..ddb917a 100644
--- a/Help/manual/cmake-properties.7.rst
+++ b/Help/manual/cmake-properties.7.rst
@@ -305,6 +305,7 @@ Properties on Targets
/prop_tgt/LINK_INTERFACE_MULTIPLICITY
/prop_tgt/LINK_INTERFACE_MULTIPLICITY_CONFIG
/prop_tgt/LINK_LIBRARIES
+ /prop_tgt/LINK_LIBRARIES_ONLY_TARGETS
/prop_tgt/LINK_OPTIONS
/prop_tgt/LINK_SEARCH_END_STATIC
/prop_tgt/LINK_SEARCH_START_STATIC
diff --git a/Help/manual/cmake-variables.7.rst b/Help/manual/cmake-variables.7.rst
index 13704c5..51b092f 100644
--- a/Help/manual/cmake-variables.7.rst
+++ b/Help/manual/cmake-variables.7.rst
@@ -221,6 +221,7 @@ Variables that Change Behavior
/variable/CMAKE_INSTALL_PREFIX_INITIALIZED_TO_DEFAULT
/variable/CMAKE_LIBRARY_PATH
/variable/CMAKE_LINK_DIRECTORIES_BEFORE
+ /variable/CMAKE_LINK_LIBRARIES_ONLY_TARGETS
/variable/CMAKE_MFC_FLAG
/variable/CMAKE_MAXIMUM_RECURSION_DEPTH
/variable/CMAKE_MESSAGE_CONTEXT
diff --git a/Help/manual/cmake.1.rst b/Help/manual/cmake.1.rst
index e23ddd8..04e2eda 100644
--- a/Help/manual/cmake.1.rst
+++ b/Help/manual/cmake.1.rst
@@ -250,6 +250,20 @@ Options
See also the :variable:`CMAKE_FIND_DEBUG_MODE` variable for debugging
a more local part of the project.
+``--debug-find=<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.
+
+ 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
+ comma-separated list.
+
+ Like ``--debug-find``, but limiting scope to the specified variable names.
+
``--trace``
Put cmake in trace mode.
diff --git a/Help/policy/CMP0028.rst b/Help/policy/CMP0028.rst
index ab38229..dcd39d8 100644
--- a/Help/policy/CMP0028.rst
+++ b/Help/policy/CMP0028.rst
@@ -13,6 +13,8 @@ on disk. Previously, if a target was not found with a matching name, the name
was considered to refer to a file on disk. This can lead to confusing error
messages if there is a typo in what should be a target name.
+See also the :prop_tgt:`LINK_LIBRARIES_ONLY_TARGETS` target property.
+
The ``OLD`` behavior for this policy is to search for targets, then files on
disk, even if the search term contains double-colons. The ``NEW`` behavior
for this policy is to issue a ``FATAL_ERROR`` if a link dependency contains
diff --git a/Help/policy/CMP0126.rst b/Help/policy/CMP0126.rst
index 1b69957..a389512 100644
--- a/Help/policy/CMP0126.rst
+++ b/Help/policy/CMP0126.rst
@@ -14,6 +14,9 @@ current scope in the following situations:
This can occur when the variable was set on the command line using a form
like ``cmake -DMYVAR=blah`` instead of ``cmake -DMYVAR:STRING=blah``.
+* The ``FORCE`` or ``INTERNAL`` keywords were used when setting the cache
+ variable.
+
Note that the ``NEW`` behavior has an important difference to the similar
``NEW`` behavior of policy :policy:`CMP0077`. The :command:`set(CACHE)`
command always sets the cache variable if it did not exist previously,
diff --git a/Help/prop_tgt/LINK_LIBRARIES_ONLY_TARGETS.rst b/Help/prop_tgt/LINK_LIBRARIES_ONLY_TARGETS.rst
new file mode 100644
index 0000000..78fbb02
--- /dev/null
+++ b/Help/prop_tgt/LINK_LIBRARIES_ONLY_TARGETS.rst
@@ -0,0 +1,55 @@
+LINK_LIBRARIES_ONLY_TARGETS
+---------------------------
+
+.. versionadded:: 3.23
+
+Enforce that link items that can be target names are actually existing targets.
+
+Set this property to a true value to enable additional checks on the contents
+of the :prop_tgt:`LINK_LIBRARIES` and :prop_tgt:`INTERFACE_LINK_LIBRARIES`
+target properties, typically populated by :command:`target_link_libraries`.
+CMake will verify that link items that might be target names actually name
+existing targets. An item is considered a possible target name if:
+
+* it does not contain a ``/`` or ``\``, and
+* it does not start in ``-``, and
+* (for historical reasons) it does not start in ``$`` or `````.
+
+This property is initialized by the value of the
+:variable:`CMAKE_LINK_LIBRARIES_ONLY_TARGETS` variable when a non-imported
+target is created. The property may be explicitly enabled on an imported
+target to check its link interface.
+
+For example, the following code:
+
+.. code-block:: cmake
+
+ set(CMAKE_LINK_LIBRARIES_ONLY_TARGETS ON)
+ add_executable(myLib STATIC myLib.c)
+ add_executable(myExe myExe.c)
+ target_link_libraries(myExe PRIVATE miLib) # typo for myLib
+
+will produce a CMake-time error that ``miLib`` is not a target.
+
+In order to link toolchain-provided libraries by name while still
+enforcing ``LINK_LIBRARIES_ONLY_TARGETS``, use an
+:ref:`imported <Imported Targets>`
+:ref:`Interface Library <Interface Libraries>` with the
+:prop_tgt:`IMPORTED_LIBNAME` target property:
+
+.. code-block:: cmake
+
+ add_library(toolchain::m INTERFACE IMPORTED)
+ set_property(TARGET toolchain::m PROPERTY IMPORTED_LIBNAME "m")
+ target_link_libraries(myExe PRIVATE toolchain::m)
+
+See also policy :policy:`CMP0028`.
+
+.. note::
+
+ If :prop_tgt:`INTERFACE_LINK_LIBRARIES` contains generator expressions,
+ its actual list of link items may depend on the type and properties of
+ the consuming target. In such cases CMake may not always detect names
+ of missing targets that only appear for specific consumers.
+ A future version of CMake with improved heuristics may start triggering
+ errors on projects accepted by previous versions of CMake.
diff --git a/Help/release/dev/FindGLUT-include-dirs.rst b/Help/release/dev/FindGLUT-include-dirs.rst
new file mode 100644
index 0000000..9528892
--- /dev/null
+++ b/Help/release/dev/FindGLUT-include-dirs.rst
@@ -0,0 +1,7 @@
+FindGLUT-include-dirs
+---------------------
+
+* The :module:`FindGLUT` module now provides the ``GLUT_INCLUDE_DIRS``
+ result variable to conform with naming conventions documented in the
+ :manual:`cmake-developer(7)` manual. This supersedes the legacy
+ ``GLUT_INCLUDE_DIR`` variable.
diff --git a/Help/release/dev/filter-debug-find.rst b/Help/release/dev/filter-debug-find.rst
new file mode 100644
index 0000000..8bdb61e
--- /dev/null
+++ b/Help/release/dev/filter-debug-find.rst
@@ -0,0 +1,10 @@
+filter-debug-find
+-----------------
+
+* The :manual:`cmake(1)` command line tool's gained a
+ ``--debug-find-pkg=`` option to enable debug messages under specific
+ :command:`find_package` calls.
+
+* The :manual:`cmake(1)` command line tool gained a ``--debug-find-var=``
+ option to enable debug messages for ``find_*`` calls that use specific
+ result variables.
diff --git a/Help/release/dev/link-only-targets.rst b/Help/release/dev/link-only-targets.rst
new file mode 100644
index 0000000..7901a25
--- /dev/null
+++ b/Help/release/dev/link-only-targets.rst
@@ -0,0 +1,7 @@
+link-only-targets
+-----------------
+
+* The :variable:`CMAKE_LINK_LIBRARIES_ONLY_TARGETS` variable and
+ corresponding :prop_tgt:`LINK_LIBRARIES_ONLY_TARGETS` target
+ property were added to optionally require that all link items
+ that can be target names are actually names of existing targets.
diff --git a/Help/variable/CMAKE_LINK_LIBRARIES_ONLY_TARGETS.rst b/Help/variable/CMAKE_LINK_LIBRARIES_ONLY_TARGETS.rst
new file mode 100644
index 0000000..513c3d0
--- /dev/null
+++ b/Help/variable/CMAKE_LINK_LIBRARIES_ONLY_TARGETS.rst
@@ -0,0 +1,10 @@
+CMAKE_LINK_LIBRARIES_ONLY_TARGETS
+---------------------------------
+
+.. versionadded:: 3.23
+
+Set this variable to initialize the :prop_tgt:`LINK_LIBRARIES_ONLY_TARGETS`
+property of non-imported targets when they are created. Setting it to true
+enables an additional check that all items named by
+:command:`target_link_libraries` that can be target names are actually names
+of existing targets. See the target property documentation for details.
diff --git a/Modules/CMakeDetermineCompilerId.cmake b/Modules/CMakeDetermineCompilerId.cmake
index b7119a8..3ea146c 100644
--- a/Modules/CMakeDetermineCompilerId.cmake
+++ b/Modules/CMakeDetermineCompilerId.cmake
@@ -341,15 +341,13 @@ Id flags: ${testflags} ${CMAKE_${lang}_COMPILER_ID_FLAGS_ALWAYS}
set(id_cl "$(CLToolExe)")
elseif(CMAKE_VS_PLATFORM_TOOLSET MATCHES "v[0-9]+_clang_.*")
set(id_cl clang.exe)
- # Executable names have been chosen according documentation
- # URL: (https://software.intel.com/content/www/us/en/develop/documentation/get-started-with-dpcpp-compiler/top.html#top_GUID-A9B4C91D-97AC-450D-9742-9D895BC8AEE1)
elseif(CMAKE_VS_PLATFORM_TOOLSET MATCHES "Intel")
if(CMAKE_VS_PLATFORM_TOOLSET MATCHES "DPC\\+\\+ Compiler")
set(id_cl dpcpp.exe)
- elseif(CMAKE_VS_PLATFORM_TOOLSET MATCHES "C\\+\\+ Compiler 2021")
- set(id_cl icx.exe)
- elseif(CMAKE_VS_PLATFORM_TOOLSET MATCHES "C\\+\\+ Compiler")
+ elseif(CMAKE_VS_PLATFORM_TOOLSET MATCHES "C\\+\\+ Compiler ([8-9]\\.|1[0-9]\\.|XE)")
set(id_cl icl.exe)
+ elseif(CMAKE_VS_PLATFORM_TOOLSET MATCHES "C\\+\\+ Compiler")
+ set(id_cl icx.exe)
endif()
else()
set(id_cl cl.exe)
diff --git a/Modules/FetchContent.cmake b/Modules/FetchContent.cmake
index be75689..691d4ac 100644
--- a/Modules/FetchContent.cmake
+++ b/Modules/FetchContent.cmake
@@ -43,7 +43,7 @@ dependencies and then ensuring they are populated with a separate call:
URL_HASH MD5=5588a7b18261c20068beabfb4f530b87
)
- FetchContent_MakeAvailable(googletest secret_sauce)
+ FetchContent_MakeAvailable(googletest myCompanyIcons)
The :command:`FetchContent_MakeAvailable` command ensures the named
dependencies have been populated, either by an earlier call or by populating
diff --git a/Modules/FindBoost.cmake b/Modules/FindBoost.cmake
index b63f010..91d4eee 100644
--- a/Modules/FindBoost.cmake
+++ b/Modules/FindBoost.cmake
@@ -390,7 +390,7 @@ cmake_policy(SET CMP0102 NEW) # if mark_as_advanced(non_cache_var)
function(_boost_get_existing_target component target_var)
set(names "${component}")
- if(component MATCHES "^([a-z_]*)(python|numpy)([1-9])\\.?([0-9])?$")
+ if(component MATCHES "^([a-z_]*)(python|numpy)([1-9])\\.?([0-9]+)?$")
# handle pythonXY and numpyXY versioned components and also python X.Y, mpi_python etc.
list(APPEND names
"${CMAKE_MATCH_1}${CMAKE_MATCH_2}" # python
@@ -407,7 +407,7 @@ function(_boost_get_existing_target component target_var)
if(TARGET "${prefix}::${name}")
# The target may be an INTERFACE library that wraps around a single other
# target for compatibility. Unwrap this layer so we can extract real info.
- if("${name}" MATCHES "^(python|numpy|mpi_python)([1-9])([0-9])$")
+ if("${name}" MATCHES "^(python|numpy|mpi_python)([1-9])([0-9]+)$")
set(name_nv "${CMAKE_MATCH_1}")
if(TARGET "${prefix}::${name_nv}")
get_property(type TARGET "${prefix}::${name}" PROPERTY TYPE)
@@ -430,7 +430,7 @@ endfunction()
function(_boost_get_canonical_target_name component target_var)
string(TOLOWER "${component}" component)
- if(component MATCHES "^([a-z_]*)(python|numpy)([1-9])\\.?([0-9])?$")
+ if(component MATCHES "^([a-z_]*)(python|numpy)([1-9])\\.?([0-9]+)?$")
# handle pythonXY and numpyXY versioned components and also python X.Y, mpi_python etc.
set(${target_var} "Boost::${CMAKE_MATCH_1}${CMAKE_MATCH_2}" PARENT_SCOPE)
else()
@@ -1004,7 +1004,7 @@ function(_Boost_COMPONENT_DEPENDENCIES component _ret)
# against the new release.
# Handle Python version suffixes
- if(component MATCHES "^(python|mpi_python|numpy)([0-9][0-9]?|[0-9]\\.[0-9])\$")
+ if(component MATCHES "^(python|mpi_python|numpy)([0-9][0-9]?|[0-9]\\.[0-9]+)\$")
set(component "${CMAKE_MATCH_1}")
set(component_python_version "${CMAKE_MATCH_2}")
endif()
@@ -1350,7 +1350,7 @@ function(_Boost_COMPONENT_DEPENDENCIES component _ret)
set(_Boost_TIMER_DEPENDENCIES chrono)
set(_Boost_WAVE_DEPENDENCIES filesystem serialization thread chrono date_time atomic)
set(_Boost_WSERIALIZATION_DEPENDENCIES serialization)
- else()
+ elseif(Boost_VERSION_STRING VERSION_LESS 1.78.0)
set(_Boost_CONTRACT_DEPENDENCIES thread chrono)
set(_Boost_COROUTINE_DEPENDENCIES context)
set(_Boost_FIBER_DEPENDENCIES context)
@@ -1365,7 +1365,22 @@ function(_Boost_COMPONENT_DEPENDENCIES component _ret)
set(_Boost_TIMER_DEPENDENCIES chrono)
set(_Boost_WAVE_DEPENDENCIES filesystem serialization thread chrono atomic)
set(_Boost_WSERIALIZATION_DEPENDENCIES serialization)
- if(Boost_VERSION_STRING VERSION_GREATER_EQUAL 1.78.0 AND NOT Boost_NO_WARN_NEW_VERSIONS)
+ else()
+ set(_Boost_CONTRACT_DEPENDENCIES thread chrono)
+ set(_Boost_COROUTINE_DEPENDENCIES context)
+ set(_Boost_FIBER_DEPENDENCIES context)
+ set(_Boost_IOSTREAMS_DEPENDENCIES regex)
+ set(_Boost_JSON_DEPENDENCIES container)
+ set(_Boost_LOG_DEPENDENCIES log_setup filesystem thread regex chrono atomic)
+ set(_Boost_MATH_DEPENDENCIES math_c99 math_c99f math_c99l math_tr1 math_tr1f math_tr1l)
+ set(_Boost_MPI_DEPENDENCIES serialization)
+ set(_Boost_MPI_PYTHON_DEPENDENCIES python${component_python_version} mpi serialization)
+ set(_Boost_NUMPY_DEPENDENCIES python${component_python_version})
+ set(_Boost_THREAD_DEPENDENCIES chrono atomic)
+ set(_Boost_TIMER_DEPENDENCIES chrono)
+ set(_Boost_WAVE_DEPENDENCIES filesystem serialization thread chrono atomic)
+ set(_Boost_WSERIALIZATION_DEPENDENCIES serialization)
+ if(Boost_VERSION_STRING VERSION_GREATER_EQUAL 1.79.0 AND NOT Boost_NO_WARN_NEW_VERSIONS)
message(WARNING "New Boost version may have incorrect or missing dependencies and imported targets")
endif()
endif()
@@ -1393,7 +1408,7 @@ endfunction()
#
function(_Boost_COMPONENT_HEADERS component _hdrs)
# Handle Python version suffixes
- if(component MATCHES "^(python|mpi_python|numpy)([0-9][0-9]?|[0-9]\\.[0-9])\$")
+ if(component MATCHES "^(python|mpi_python|numpy)([0-9]+|[0-9]\\.[0-9]+)\$")
set(component "${CMAKE_MATCH_1}")
set(component_python_version "${CMAKE_MATCH_2}")
endif()
@@ -1638,7 +1653,7 @@ else()
# _Boost_COMPONENT_HEADERS. See the instructions at the top of
# _Boost_COMPONENT_DEPENDENCIES.
set(_Boost_KNOWN_VERSIONS ${Boost_ADDITIONAL_VERSIONS}
- "1.77.0" "1.77" "1.76.0" "1.76" "1.75.0" "1.75" "1.74.0" "1.74"
+ "1.78.0" "1.78" "1.77.0" "1.77" "1.76.0" "1.76" "1.75.0" "1.75" "1.74.0" "1.74"
"1.73.0" "1.73" "1.72.0" "1.72" "1.71.0" "1.71" "1.70.0" "1.70" "1.69.0" "1.69"
"1.68.0" "1.68" "1.67.0" "1.67" "1.66.0" "1.66" "1.65.1" "1.65.0" "1.65"
"1.64.0" "1.64" "1.63.0" "1.63" "1.62.0" "1.62" "1.61.0" "1.61" "1.60.0" "1.60"
@@ -2150,7 +2165,7 @@ foreach(COMPONENT ${Boost_FIND_COMPONENTS})
if(${COMPONENT} MATCHES "^(python|mpi_python|numpy)([0-9])\$")
set(COMPONENT_UNVERSIONED "${CMAKE_MATCH_1}")
set(COMPONENT_PYTHON_VERSION_MAJOR "${CMAKE_MATCH_2}")
- elseif(${COMPONENT} MATCHES "^(python|mpi_python|numpy)([0-9])\\.?([0-9])\$")
+ elseif(${COMPONENT} MATCHES "^(python|mpi_python|numpy)([0-9])\\.?([0-9]+)\$")
set(COMPONENT_UNVERSIONED "${CMAKE_MATCH_1}")
set(COMPONENT_PYTHON_VERSION_MAJOR "${CMAKE_MATCH_2}")
set(COMPONENT_PYTHON_VERSION_MINOR "${CMAKE_MATCH_3}")
diff --git a/Modules/FindGLUT.cmake b/Modules/FindGLUT.cmake
index dd0975d..80cd3a0 100644
--- a/Modules/FindGLUT.cmake
+++ b/Modules/FindGLUT.cmake
@@ -20,24 +20,48 @@ This module defines the :prop_tgt:`IMPORTED` targets:
Result Variables
^^^^^^^^^^^^^^^^
-This module sets the following variables:
+This module defines the following variables:
-::
+``GLUT_FOUND``
+ True if ``glut`` was found.
- GLUT_INCLUDE_DIR, where to find GL/glut.h, etc.
- GLUT_LIBRARIES, the libraries to link against
- GLUT_FOUND, If false, do not try to use GLUT.
+``GLUT_INCLUDE_DIRS``
+ .. versionadded:: 3.23
-Also defined, but not for general use are:
+ Where to find GL/glut.h, etc.
-::
+``GLUT_LIBRARIES``
+ List of libraries for using ``glut``.
- GLUT_glut_LIBRARY = the full path to the glut library.
- GLUT_Xmu_LIBRARY = the full path to the Xmu library.
- GLUT_Xi_LIBRARY = the full path to the Xi Library.
+Cache Variables
+^^^^^^^^^^^^^^^
-.. versionadded:: 3.13
- Debug and Release variants are found separately.
+This module may set the following variables depending on platform.
+These variables may optionally be set to help this module find the
+correct files, but clients should not use these as results:
+
+``GLUT_INCLUDE_DIR``
+ The full path to the directory containing ``GL/glut.h``,
+ not including ``GL/``.
+
+``GLUT_glut_LIBRARY``
+ The full path to the glut library.
+
+``GLUT_Xmu_LIBRARY``
+ The full path to the Xmu library.
+
+``GLUT_Xi_LIBRARY``
+ The full path to the Xi Library.
+
+Obsolete Variables
+^^^^^^^^^^^^^^^^^^
+
+The following variables may also be provided, for backwards compatibility:
+
+``GLUT_INCLUDE_DIR``
+ This is one of above `Cache Variables`_, but prior to CMake 3.23 was
+ also a result variable. Prefer to use ``GLUT_INCLUDE_DIRS`` instead
+ in CMake 3.23 and above.
#]=======================================================================]
include(${CMAKE_CURRENT_LIST_DIR}/SelectLibraryConfigurations.cmake)
@@ -71,6 +95,9 @@ find_package(PkgConfig)
if(PKG_CONFIG_FOUND)
pkg_check_modules(GLUT glut)
if(GLUT_FOUND)
+ # GLUT_INCLUDE_DIRS is now the official result variable, but
+ # older versions of CMake only provided GLUT_INCLUDE_DIR.
+ set(GLUT_INCLUDE_DIR "${GLUT_INCLUDE_DIRS}")
_add_glut_target_simple()
FIND_PACKAGE_HANDLE_STANDARD_ARGS(GLUT REQUIRED_VARS GLUT_FOUND)
return()
@@ -80,6 +107,7 @@ endif()
if(WIN32)
find_path( GLUT_INCLUDE_DIR NAMES GL/glut.h
PATHS ${GLUT_ROOT_PATH}/include )
+ mark_as_advanced(GLUT_INCLUDE_DIR)
find_library( GLUT_glut_LIBRARY_RELEASE NAMES glut glut32 freeglut
PATHS
${OPENGL_LIBRARY_DIR}
@@ -94,6 +122,7 @@ if(WIN32)
select_library_configurations(GLUT_glut)
elseif(APPLE)
find_path(GLUT_INCLUDE_DIR glut.h ${OPENGL_LIBRARY_DIR})
+ mark_as_advanced(GLUT_INCLUDE_DIR)
find_library(GLUT_glut_LIBRARY GLUT DOC "GLUT library for OSX")
find_library(GLUT_cocoa_LIBRARY Cocoa DOC "Cocoa framework for OSX")
mark_as_advanced(GLUT_glut_LIBRARY GLUT_cocoa_LIBRARY)
@@ -150,16 +179,17 @@ else()
/opt/graphics/OpenGL/contrib/libglut
${_GLUT_INC_DIR}
)
+ mark_as_advanced(GLUT_INCLUDE_DIR)
find_library( GLUT_glut_LIBRARY glut
/usr/openwin/lib
${_GLUT_glut_LIB_DIR}
)
+ mark_as_advanced(GLUT_glut_LIBRARY)
unset(_GLUT_INC_DIR)
unset(_GLUT_glut_LIB_DIR)
endif()
-mark_as_advanced(GLUT_glut_LIBRARY)
FIND_PACKAGE_HANDLE_STANDARD_ARGS(GLUT REQUIRED_VARS GLUT_glut_LIBRARY GLUT_INCLUDE_DIR)
@@ -169,6 +199,9 @@ if (GLUT_FOUND)
set( GLUT_LIBRARIES
${GLUT_glut_LIBRARY}
)
+ set(GLUT_INCLUDE_DIRS
+ ${GLUT_INCLUDE_DIR}
+ )
foreach(v GLUT_Xmu_LIBRARY GLUT_Xi_LIBRARY GLUT_cocoa_LIBRARY)
if(${v})
list(APPEND GLUT_LIBRARIES ${${v}})
@@ -178,7 +211,7 @@ if (GLUT_FOUND)
if(NOT TARGET GLUT::GLUT)
add_library(GLUT::GLUT UNKNOWN IMPORTED)
set_target_properties(GLUT::GLUT PROPERTIES
- INTERFACE_INCLUDE_DIRECTORIES "${GLUT_INCLUDE_DIR}")
+ INTERFACE_INCLUDE_DIRECTORIES "${GLUT_INCLUDE_DIRS}")
if(GLUT_glut_LIBRARY MATCHES "/([^/]+)\\.framework$")
set(_glut_glut "${GLUT_glut_LIBRARY}/${CMAKE_MATCH_1}")
if(EXISTS "${_glut_glut}.tbd")
@@ -225,7 +258,5 @@ if (GLUT_FOUND)
#The following deprecated settings are for backwards compatibility with CMake1.4
set (GLUT_LIBRARY ${GLUT_LIBRARIES})
- set (GLUT_INCLUDE_PATH ${GLUT_INCLUDE_DIR})
+ set (GLUT_INCLUDE_PATH ${GLUT_INCLUDE_DIRS})
endif()
-
-mark_as_advanced(GLUT_INCLUDE_DIR)
diff --git a/Modules/FindGSL.cmake b/Modules/FindGSL.cmake
index 3d4e7f9..485735a 100644
--- a/Modules/FindGSL.cmake
+++ b/Modules/FindGSL.cmake
@@ -139,7 +139,7 @@ if( NOT GSL_VERSION )
# 2. If gsl-config is not available, try looking in gsl/gsl_version.h
if( NOT GSL_VERSION AND EXISTS "${GSL_INCLUDE_DIRS}/gsl/gsl_version.h" )
file( STRINGS "${GSL_INCLUDE_DIRS}/gsl/gsl_version.h" gsl_version_h_contents REGEX "define GSL_VERSION" )
- string( REGEX REPLACE ".*([0-9]\\.[0-9][0-9]?).*" "\\1" GSL_VERSION ${gsl_version_h_contents} )
+ string( REGEX REPLACE ".*define[ ]+GSL_VERSION[ ]+\"([^\"]*)\".*" "\\1" GSL_VERSION ${gsl_version_h_contents} )
endif()
# might also try scraping the directory name for a regex match "gsl-X.X"
diff --git a/Modules/GoogleTestAddTests.cmake b/Modules/GoogleTestAddTests.cmake
index 6b3bf34..dffbc46 100644
--- a/Modules/GoogleTestAddTests.cmake
+++ b/Modules/GoogleTestAddTests.cmake
@@ -80,9 +80,14 @@ function(gtest_discover_tests_impl)
)
if(NOT ${result} EQUAL 0)
string(REPLACE "\n" "\n " output "${output}")
+ if(_TEST_EXECUTOR)
+ set(path "${_TEST_EXECUTOR} ${_TEST_EXECUTABLE}")
+ else()
+ set(path "${_TEST_EXECUTABLE}")
+ endif()
message(FATAL_ERROR
"Error running test executable.\n"
- " Path: '${_TEST_EXECUTABLE}'\n"
+ " Path: '${path}'\n"
" Result: ${result}\n"
" Output:\n"
" ${output}\n"
diff --git a/Modules/Internal/CPack/CPackFreeBSD.cmake b/Modules/Internal/CPack/CPackFreeBSD.cmake
index ae40532..c35089c 100644
--- a/Modules/Internal/CPack/CPackFreeBSD.cmake
+++ b/Modules/Internal/CPack/CPackFreeBSD.cmake
@@ -34,7 +34,7 @@ function(_cpack_freebsd_fallback_var OUTPUT_VAR_NAME)
endif()
endforeach()
if(NOT VALUE)
- message(WARNING "Variable ${OUTPUT_VAR_NAME} could not be given a fallback value from any variable ${FALLBACK_VAR_NAMES}.")
+ message(WARNING "Variable ${OUTPUT_VAR_NAME} could not be given a fallback value from (any of) ${FALLBACK_VAR_NAMES}.")
endif()
endfunction()
diff --git a/Source/CMakeVersion.cmake b/Source/CMakeVersion.cmake
index 297e2d2..86535b6 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 22)
-set(CMake_VERSION_PATCH 20211215)
+set(CMake_VERSION_PATCH 20211222)
#set(CMake_VERSION_RC 0)
set(CMake_VERSION_IS_DIRTY 0)
diff --git a/Source/CPack/cmCPackFreeBSDGenerator.cxx b/Source/CPack/cmCPackFreeBSDGenerator.cxx
index fcd5753..b5d41fc 100644
--- a/Source/CPack/cmCPackFreeBSDGenerator.cxx
+++ b/Source/CPack/cmCPackFreeBSDGenerator.cxx
@@ -21,8 +21,15 @@
#include <sys/stat.h>
+// Suffix used to tell libpkg what compression to use
+static const char FreeBSDPackageCompression[] = "txz";
+// Resulting package file-suffix, for < 1.17 and >= 1.17 versions of libpkg
+static const char FreeBSDPackageSuffix_10[] = ".txz";
+static const char FreeBSDPackageSuffix_17[] = ".pkg";
+
cmCPackFreeBSDGenerator::cmCPackFreeBSDGenerator()
- : cmCPackArchiveGenerator(cmArchiveWrite::CompressXZ, "paxr", ".txz")
+ : cmCPackArchiveGenerator(cmArchiveWrite::CompressXZ, "paxr",
+ FreeBSDPackageSuffix_17)
{
}
@@ -35,6 +42,56 @@ int cmCPackFreeBSDGenerator::InitializeInternal()
cmCPackFreeBSDGenerator::~cmCPackFreeBSDGenerator() = default;
+// This is a wrapper for struct pkg_create and pkg_create()
+//
+// Instantiate this class with suitable parameters, then
+// check isValid() to check if it's ok. Afterwards, call
+// Create() to do the actual work. This will leave a package
+// in the given `output_dir`.
+//
+// This wrapper cleans up the struct pkg_create.
+class PkgCreate
+{
+public:
+ PkgCreate()
+ : d(nullptr)
+ {
+ }
+ PkgCreate(const std::string& output_dir, const std::string& toplevel_dir,
+ const std::string& manifest_name)
+ : d(pkg_create_new())
+ , manifest(manifest_name)
+
+ {
+ if (d) {
+ pkg_create_set_format(d, FreeBSDPackageCompression);
+ pkg_create_set_compression_level(d, 0); // Explicitly set default
+ pkg_create_set_overwrite(d, false);
+ pkg_create_set_rootdir(d, toplevel_dir.c_str());
+ pkg_create_set_output_dir(d, output_dir.c_str());
+ }
+ }
+ ~PkgCreate()
+ {
+ if (d)
+ pkg_create_free(d);
+ }
+
+ bool isValid() const { return d; }
+
+ bool Create()
+ {
+ if (!isValid())
+ return false;
+ int r = pkg_create(d, manifest.c_str(), nullptr, false);
+ return r == 0;
+ }
+
+private:
+ struct pkg_create* d;
+ std::string manifest;
+};
+
// This is a wrapper, for use only in stream-based output,
// that will output a string in UCL escaped fashion (in particular,
// quotes and backslashes are escaped). The list of characters
@@ -271,7 +328,7 @@ void write_manifest_files(cmGeneratedFileStream& s,
s << "\"files\": {\n";
for (std::string const& file : files) {
s << " \"/" << cmSystemTools::RelativePath(toplevel, file) << "\": \""
- << "<sha256>"
+ << "<sha256>" // this gets replaced by libpkg by the actual SHA256
<< "\",\n";
}
s << " },\n";
@@ -281,11 +338,10 @@ int cmCPackFreeBSDGenerator::PackageFiles()
{
if (!this->ReadListFile("Internal/CPack/CPackFreeBSD.cmake")) {
cmCPackLogger(cmCPackLog::LOG_ERROR,
- "Error while execution CPackFreeBSD.cmake" << std::endl);
+ "Error while executing CPackFreeBSD.cmake" << std::endl);
return 0;
}
- std::vector<std::string>::const_iterator fileIt;
cmWorkingDirectory wd(toplevel);
files.erase(std::remove_if(files.begin(), files.end(), ignore_file),
@@ -317,20 +373,85 @@ int cmCPackFreeBSDGenerator::PackageFiles()
ONE_PACKAGE_PER_COMPONENT);
}
+ // There should be one name in the packageFileNames (already, see comment
+ // in cmCPackGenerator::DoPackage(), which holds what CPack guesses
+ // will be the package filename. libpkg does something else, though,
+ // so update the single filename to what we know will be right.
+ if (this->packageFileNames.size() == 1) {
+ std::string currentPackage = this->packageFileNames[0];
+ auto lastSlash = currentPackage.rfind('/');
+
+ // If there is a pathname, preserve that; libpkg will write out
+ // a file with the package name and version as specified in the
+ // manifest, so we look those up (again). lastSlash is the slash
+ // itself, we need that as path separator to the calculated package name.
+ std::string actualPackage =
+ ((lastSlash != std::string::npos)
+ ? std::string(currentPackage, 0, lastSlash + 1)
+ : std::string()) +
+ var_lookup("CPACK_FREEBSD_PACKAGE_NAME") + '-' +
+ var_lookup("CPACK_FREEBSD_PACKAGE_VERSION") + FreeBSDPackageSuffix_17;
+
+ this->packageFileNames.clear();
+ this->packageFileNames.emplace_back(actualPackage);
+ }
+
+ if (!pkg_initialized() && pkg_init(NULL, NULL) != EPKG_OK) {
+ cmCPackLogger(cmCPackLog::LOG_ERROR,
+ "Can not initialize FreeBSD libpkg." << std::endl);
+ return 0;
+ }
+
std::string output_dir = cmSystemTools::CollapseFullPath("../", toplevel);
- pkg_create_from_manifest(output_dir.c_str(), ::TXZ, toplevel.c_str(),
- manifestname.c_str(), nullptr);
+ PkgCreate package(output_dir, toplevel, manifestname);
+ if (package.isValid()) {
+ if (!package.Create()) {
+ cmCPackLogger(cmCPackLog::LOG_ERROR,
+ "Error during pkg_create()" << std::endl);
+ return 0;
+ }
+ } else {
+ cmCPackLogger(cmCPackLog::LOG_ERROR,
+ "Error before pkg_create()" << std::endl);
+ return 0;
+ }
- std::string broken_suffix =
- cmStrCat('-', var_lookup("CPACK_TOPLEVEL_TAG"), ".txz");
+ // Specifically looking for packages suffixed with the TAG, either extension
+ std::string broken_suffix_10 =
+ cmStrCat('-', var_lookup("CPACK_TOPLEVEL_TAG"), FreeBSDPackageSuffix_10);
+ std::string broken_suffix_17 =
+ cmStrCat('-', var_lookup("CPACK_TOPLEVEL_TAG"), FreeBSDPackageSuffix_17);
for (std::string& name : packageFileNames) {
cmCPackLogger(cmCPackLog::LOG_DEBUG, "Packagefile " << name << std::endl);
- if (cmHasSuffix(name, broken_suffix)) {
- name.replace(name.size() - broken_suffix.size(), std::string::npos,
- ".txz");
+ if (cmHasSuffix(name, broken_suffix_10)) {
+ name.replace(name.size() - broken_suffix_10.size(), std::string::npos,
+ FreeBSDPackageSuffix_10);
+ break;
+ }
+ if (cmHasSuffix(name, broken_suffix_17)) {
+ name.replace(name.size() - broken_suffix_17.size(), std::string::npos,
+ FreeBSDPackageSuffix_17);
break;
}
}
+ // If the name uses a *new* style name, which doesn't exist, but there
+ // is an *old* style name, then use that instead. This indicates we used
+ // an older libpkg, which still creates .txz instead of .pkg files.
+ for (std::string& name : packageFileNames) {
+ if (cmHasSuffix(name, FreeBSDPackageSuffix_17) &&
+ !cmSystemTools::FileExists(name)) {
+ const std::string badSuffix(FreeBSDPackageSuffix_17);
+ const std::string goodSuffix(FreeBSDPackageSuffix_10);
+ std::string repairedName(name);
+ repairedName.replace(repairedName.size() - badSuffix.size(),
+ std::string::npos, goodSuffix);
+ if (cmSystemTools::FileExists(repairedName)) {
+ name = repairedName;
+ cmCPackLogger(cmCPackLog::LOG_DEBUG,
+ "Repaired packagefile " << name << std::endl);
+ }
+ }
+ }
return 1;
}
diff --git a/Source/cmExportTryCompileFileGenerator.cxx b/Source/cmExportTryCompileFileGenerator.cxx
index 4fe92c6..db9b05b 100644
--- a/Source/cmExportTryCompileFileGenerator.cxx
+++ b/Source/cmExportTryCompileFileGenerator.cxx
@@ -107,10 +107,16 @@ void cmExportTryCompileFileGenerator::PopulateProperties(
const cmGeneratorTarget* target, ImportPropertyMap& properties,
std::set<cmGeneratorTarget const*>& emitted)
{
+ // Look through all non-special properties.
std::vector<std::string> props = target->GetPropertyKeys();
+ // Include special properties that might be relevant here.
+ props.emplace_back("INTERFACE_LINK_LIBRARIES");
for (std::string const& p : props) {
-
- properties[p] = *target->GetProperty(p);
+ cmValue v = target->GetProperty(p);
+ if (!v) {
+ continue;
+ }
+ properties[p] = *v;
if (cmHasLiteralPrefix(p, "IMPORTED_LINK_INTERFACE_LIBRARIES") ||
cmHasLiteralPrefix(p, "IMPORTED_LINK_DEPENDENT_LIBRARIES") ||
diff --git a/Source/cmFindCommon.cxx b/Source/cmFindCommon.cxx
index 70d59c2..7631583 100644
--- a/Source/cmFindCommon.cxx
+++ b/Source/cmFindCommon.cxx
@@ -77,6 +77,12 @@ bool cmFindCommon::ComputeIfDebugModeWanted()
this->Makefile->GetCMakeInstance()->GetDebugFindOutput();
}
+bool cmFindCommon::ComputeIfDebugModeWanted(std::string const& var)
+{
+ return this->ComputeIfDebugModeWanted() ||
+ this->Makefile->GetCMakeInstance()->GetDebugFindOutput(var);
+}
+
void cmFindCommon::InitializeSearchPathGroups()
{
std::vector<PathLabel>* labels;
diff --git a/Source/cmFindCommon.h b/Source/cmFindCommon.h
index f84242e..1a49aff 100644
--- a/Source/cmFindCommon.h
+++ b/Source/cmFindCommon.h
@@ -99,8 +99,9 @@ protected:
void SelectDefaultSearchModes();
/** The `InitialPass` functions of the child classes should set
- this->DebugMode to the result of this. */
+ this->DebugMode to the result of these. */
bool ComputeIfDebugModeWanted();
+ bool ComputeIfDebugModeWanted(std::string const& var);
// Path arguments prior to path manipulation routines
std::vector<std::string> UserHintsArgs;
diff --git a/Source/cmFindLibraryCommand.cxx b/Source/cmFindLibraryCommand.cxx
index ff04bab..1c4039b 100644
--- a/Source/cmFindLibraryCommand.cxx
+++ b/Source/cmFindLibraryCommand.cxx
@@ -32,13 +32,14 @@ cmFindLibraryCommand::cmFindLibraryCommand(cmExecutionStatus& status)
// cmFindLibraryCommand
bool cmFindLibraryCommand::InitialPass(std::vector<std::string> const& argsIn)
{
- this->DebugMode = this->ComputeIfDebugModeWanted();
this->CMakePathName = "LIBRARY";
if (!this->ParseArguments(argsIn)) {
return false;
}
+ this->DebugMode = this->ComputeIfDebugModeWanted(this->VariableName);
+
if (this->AlreadyDefined) {
this->NormalizeFindResult();
return true;
diff --git a/Source/cmFindPackageCommand.cxx b/Source/cmFindPackageCommand.cxx
index 694eb0f..6d788e4 100644
--- a/Source/cmFindPackageCommand.cxx
+++ b/Source/cmFindPackageCommand.cxx
@@ -33,6 +33,7 @@
#include "cmSystemTools.h"
#include "cmValue.h"
#include "cmVersion.h"
+#include "cmake.h"
#if defined(__HAIKU__)
# include <FindDirectory.h>
@@ -144,9 +145,6 @@ bool cmFindPackageCommand::InitialPass(std::vector<std::string> const& args)
this->RequiredCMakeVersion = CMake_VERSION_ENCODE(v[0], v[1], v[2]);
}
- this->DebugMode = this->ComputeIfDebugModeWanted();
- this->DebugBuffer.clear();
-
// Lookup target architecture, if any.
if (cmValue arch =
this->Makefile->GetDefinition("CMAKE_LIBRARY_ARCHITECTURE")) {
@@ -236,6 +234,10 @@ bool cmFindPackageCommand::InitialPass(std::vector<std::string> const& args)
// Always search directly in a generated path.
this->SearchPathSuffixes.emplace_back();
+ // Process debug mode
+ this->DebugMode = this->ComputeIfDebugModeWanted(this->Name);
+ this->DebugBuffer.clear();
+
// Parse the arguments.
enum Doing
{
@@ -619,6 +621,12 @@ bool cmFindPackageCommand::InitialPass(std::vector<std::string> const& args)
return loadedPackage;
}
+bool cmFindPackageCommand::ComputeIfDebugModeWanted(std::string const& var)
+{
+ return this->ComputeIfDebugModeWanted() ||
+ this->Makefile->GetCMakeInstance()->GetDebugFindPkgOutput(var);
+}
+
bool cmFindPackageCommand::FindPackageUsingModuleMode()
{
bool foundModule = false;
diff --git a/Source/cmFindPackageCommand.h b/Source/cmFindPackageCommand.h
index edf32d4..9d6eddf 100644
--- a/Source/cmFindPackageCommand.h
+++ b/Source/cmFindPackageCommand.h
@@ -40,6 +40,7 @@ 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
@@ -120,6 +121,7 @@ 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/cmFindPathCommand.cxx b/Source/cmFindPathCommand.cxx
index 3d21167..a0a8570 100644
--- a/Source/cmFindPathCommand.cxx
+++ b/Source/cmFindPathCommand.cxx
@@ -29,13 +29,14 @@ cmFindPathCommand::cmFindPathCommand(cmExecutionStatus& status)
// cmFindPathCommand
bool cmFindPathCommand::InitialPass(std::vector<std::string> const& argsIn)
{
- this->DebugMode = this->ComputeIfDebugModeWanted();
this->CMakePathName = "INCLUDE";
if (!this->ParseArguments(argsIn)) {
return false;
}
+ this->DebugMode = this->ComputeIfDebugModeWanted(this->VariableName);
+
if (this->AlreadyDefined) {
this->NormalizeFindResult();
return true;
diff --git a/Source/cmFindProgramCommand.cxx b/Source/cmFindProgramCommand.cxx
index 9a4b063..780b256 100644
--- a/Source/cmFindProgramCommand.cxx
+++ b/Source/cmFindProgramCommand.cxx
@@ -177,13 +177,14 @@ cmFindProgramCommand::cmFindProgramCommand(cmExecutionStatus& status)
// cmFindProgramCommand
bool cmFindProgramCommand::InitialPass(std::vector<std::string> const& argsIn)
{
- this->DebugMode = this->ComputeIfDebugModeWanted();
+
this->CMakePathName = "PROGRAM";
// call cmFindBase::ParseArguments
if (!this->ParseArguments(argsIn)) {
return false;
}
+ this->DebugMode = this->ComputeIfDebugModeWanted(this->VariableName);
if (this->AlreadyDefined) {
this->NormalizeFindResult();
diff --git a/Source/cmGeneratorTarget.cxx b/Source/cmGeneratorTarget.cxx
index c54bd15..421e136 100644
--- a/Source/cmGeneratorTarget.cxx
+++ b/Source/cmGeneratorTarget.cxx
@@ -2687,7 +2687,6 @@ public:
: Config(std::move(config))
, Languages(languages)
, HeadTarget(head)
- , Target(target)
, SecondPass(secondPass)
{
this->Visited.insert(target);
@@ -2696,36 +2695,6 @@ public:
void Visit(cmLinkItem const& item)
{
if (!item.Target) {
- if (item.AsStr().find("::") != std::string::npos) {
- bool noMessage = false;
- MessageType messageType = MessageType::FATAL_ERROR;
- std::ostringstream e;
- switch (this->Target->GetLocalGenerator()->GetPolicyStatus(
- cmPolicies::CMP0028)) {
- case cmPolicies::WARN: {
- e << cmPolicies::GetPolicyWarning(cmPolicies::CMP0028) << "\n";
- messageType = MessageType::AUTHOR_WARNING;
- } break;
- case cmPolicies::OLD:
- noMessage = true;
- break;
- case cmPolicies::REQUIRED_IF_USED:
- case cmPolicies::REQUIRED_ALWAYS:
- case cmPolicies::NEW:
- // Issue the fatal message.
- break;
- }
-
- if (!noMessage) {
- e << "Target \"" << this->Target->GetName()
- << "\" links to target \"" << item.AsStr()
- << "\" but the target was not found. Perhaps a find_package() "
- "call is missing for an IMPORTED target, or an ALIAS target is "
- "missing?";
- this->Target->GetLocalGenerator()->GetCMakeInstance()->IssueMessage(
- messageType, e.str(), this->Target->GetBacktrace());
- }
- }
return;
}
if (!this->Visited.insert(item.Target).second) {
@@ -2758,7 +2727,6 @@ private:
std::string Config;
std::unordered_set<std::string>& Languages;
cmGeneratorTarget const* HeadTarget;
- const cmGeneratorTarget* Target;
std::set<cmGeneratorTarget const*> Visited;
bool SecondPass;
bool HadLinkLanguageSensitiveCondition = false;
@@ -6277,6 +6245,139 @@ cmComputeLinkInformation* cmGeneratorTarget::GetLinkInformation(
return i->second.get();
}
+void cmGeneratorTarget::CheckLinkLibraries() const
+{
+ bool linkLibrariesOnlyTargets =
+ this->GetPropertyAsBool("LINK_LIBRARIES_ONLY_TARGETS");
+
+ // Evaluate the link interface of this target if needed for extra checks.
+ if (linkLibrariesOnlyTargets) {
+ std::vector<std::string> const& configs =
+ this->Makefile->GetGeneratorConfigs(cmMakefile::IncludeEmptyConfig);
+ for (std::string const& config : configs) {
+ this->GetLinkInterfaceLibraries(config, this, LinkInterfaceFor::Link);
+ }
+ }
+
+ // Check link the implementation for each generated configuration.
+ for (auto const& hmp : this->LinkImplMap) {
+ HeadToLinkImplementationMap const& hm = hmp.second;
+ // There could be several entries used when computing the pre-CMP0022
+ // default link interface. Check only the entry for our own link impl.
+ auto const hmi = hm.find(this);
+ if (hmi == hm.end() || !hmi->second.LibrariesDone) {
+ continue;
+ }
+ for (cmLinkImplItem const& item : hmi->second.Libraries) {
+ if (!this->VerifyLinkItemColons(LinkItemRole::Implementation, item)) {
+ return;
+ }
+ if (linkLibrariesOnlyTargets &&
+ !this->VerifyLinkItemIsTarget(LinkItemRole::Implementation, item)) {
+ return;
+ }
+ }
+ }
+
+ // Check link the interface for each generated combination of
+ // configuration and consuming head target. We should not need to
+ // consider LinkInterfaceUsageRequirementsOnlyMap because its entries
+ // should be a subset of LinkInterfaceMap (with LINK_ONLY left out).
+ for (auto const& hmp : this->LinkInterfaceMap) {
+ for (auto const& hmi : hmp.second) {
+ if (!hmi.second.LibrariesDone) {
+ continue;
+ }
+ for (cmLinkItem const& item : hmi.second.Libraries) {
+ if (!this->VerifyLinkItemColons(LinkItemRole::Interface, item)) {
+ return;
+ }
+ if (linkLibrariesOnlyTargets &&
+ !this->VerifyLinkItemIsTarget(LinkItemRole::Interface, item)) {
+ return;
+ }
+ }
+ }
+ }
+}
+
+namespace {
+cm::string_view missingTargetPossibleReasons =
+ "Possible reasons include:\n"
+ " * There is a typo in the target name.\n"
+ " * A find_package call is missing for an IMPORTED target.\n"
+ " * An ALIAS target is missing.\n"_s;
+}
+
+bool cmGeneratorTarget::VerifyLinkItemColons(LinkItemRole role,
+ cmLinkItem const& item) const
+{
+ if (item.Target || item.AsStr().find("::") == std::string::npos) {
+ return true;
+ }
+ MessageType messageType = MessageType::FATAL_ERROR;
+ std::string e;
+ switch (this->GetLocalGenerator()->GetPolicyStatus(cmPolicies::CMP0028)) {
+ case cmPolicies::WARN: {
+ e = cmStrCat(cmPolicies::GetPolicyWarning(cmPolicies::CMP0028), "\n");
+ messageType = MessageType::AUTHOR_WARNING;
+ } break;
+ case cmPolicies::OLD:
+ return true;
+ case cmPolicies::REQUIRED_IF_USED:
+ case cmPolicies::REQUIRED_ALWAYS:
+ case cmPolicies::NEW:
+ // Issue the fatal message.
+ break;
+ }
+
+ if (role == LinkItemRole::Implementation) {
+ e = cmStrCat(e, "Target \"", this->GetName(), "\" links to");
+ } else {
+ e = cmStrCat(e, "The link interface of target \"", this->GetName(),
+ "\" contains");
+ }
+ e =
+ cmStrCat(e, ":\n ", item.AsStr(), "\n", "but the target was not found. ",
+ missingTargetPossibleReasons);
+ cmListFileBacktrace backtrace = item.Backtrace;
+ if (backtrace.Empty()) {
+ backtrace = this->GetBacktrace();
+ }
+ this->GetLocalGenerator()->GetCMakeInstance()->IssueMessage(messageType, e,
+ backtrace);
+ return false;
+}
+
+bool cmGeneratorTarget::VerifyLinkItemIsTarget(LinkItemRole role,
+ cmLinkItem const& item) const
+{
+ if (item.Target) {
+ return true;
+ }
+ std::string const& str = item.AsStr();
+ if (!str.empty() &&
+ (str[0] == '-' || str[0] == '$' || str[0] == '`' ||
+ str.find_first_of("/\\") != std::string::npos)) {
+ return true;
+ }
+
+ std::string e = cmStrCat("Target \"", this->GetName(),
+ "\" has LINK_LIBRARIES_ONLY_TARGETS enabled, but ",
+ role == LinkItemRole::Implementation
+ ? "it links to"
+ : "its link interface contains",
+ ":\n ", item.AsStr(), "\nwhich is not a target. ",
+ missingTargetPossibleReasons);
+ cmListFileBacktrace backtrace = item.Backtrace;
+ if (backtrace.Empty()) {
+ backtrace = this->GetBacktrace();
+ }
+ this->LocalGenerator->GetCMakeInstance()->IssueMessage(
+ MessageType::FATAL_ERROR, e, backtrace);
+ return false;
+}
+
void cmGeneratorTarget::GetTargetVersion(int& major, int& minor) const
{
int patch;
@@ -6553,14 +6654,13 @@ cm::optional<cmLinkItem> cmGeneratorTarget::LookupLinkItem(
}
void cmGeneratorTarget::ExpandLinkItems(std::string const& prop,
- std::string const& value,
+ cmBTStringRange entries,
std::string const& config,
cmGeneratorTarget const* headTarget,
LinkInterfaceFor interfaceFor,
cmLinkInterface& iface) const
{
// Keep this logic in sync with ComputeLinkImplementationLibraries.
- cmGeneratorExpression ge;
cmGeneratorExpressionDAGChecker dagChecker(this, prop, nullptr, nullptr);
// The $<LINK_ONLY> expression may be in a link interface to specify
// private link dependencies that are otherwise excluded from usage
@@ -6568,39 +6668,46 @@ void cmGeneratorTarget::ExpandLinkItems(std::string const& prop,
if (interfaceFor == LinkInterfaceFor::Usage) {
dagChecker.SetTransitivePropertiesOnly();
}
- std::vector<std::string> libs;
- std::unique_ptr<cmCompiledGeneratorExpression> cge = ge.Parse(value);
- cge->SetEvaluateForBuildsystem(true);
- cmExpandList(cge->Evaluate(this->LocalGenerator, config, headTarget,
- &dagChecker, this, headTarget->LinkerLanguage),
- libs);
cmMakefile const* mf = this->LocalGenerator->GetMakefile();
LookupLinkItemScope scope{ this->LocalGenerator };
- for (std::string const& lib : libs) {
- if (cm::optional<cmLinkItem> maybeItem =
- this->LookupLinkItem(lib, cge->GetBacktrace(), &scope)) {
- cmLinkItem item = std::move(*maybeItem);
-
- if (!item.Target) {
- // Report explicitly linked object files separately.
- std::string const& maybeObj = item.AsStr();
- if (cmSystemTools::FileIsFullPath(maybeObj)) {
- cmSourceFile const* sf =
- mf->GetSource(maybeObj, cmSourceFileLocationKind::Known);
- if (sf && sf->GetPropertyAsBool("EXTERNAL_OBJECT")) {
- iface.Objects.emplace_back(std::move(item));
- continue;
+ for (BT<std::string> const& entry : entries) {
+ cmGeneratorExpression ge(entry.Backtrace);
+ std::unique_ptr<cmCompiledGeneratorExpression> cge = ge.Parse(entry.Value);
+ cge->SetEvaluateForBuildsystem(true);
+ std::vector<std::string> libs = cmExpandedList(
+ cge->Evaluate(this->LocalGenerator, config, headTarget, &dagChecker,
+ this, headTarget->LinkerLanguage));
+ for (std::string const& lib : libs) {
+ if (cm::optional<cmLinkItem> maybeItem =
+ this->LookupLinkItem(lib, cge->GetBacktrace(), &scope)) {
+ cmLinkItem item = std::move(*maybeItem);
+
+ if (!item.Target) {
+ // Report explicitly linked object files separately.
+ std::string const& maybeObj = item.AsStr();
+ if (cmSystemTools::FileIsFullPath(maybeObj)) {
+ cmSourceFile const* sf =
+ mf->GetSource(maybeObj, cmSourceFileLocationKind::Known);
+ if (sf && sf->GetPropertyAsBool("EXTERNAL_OBJECT")) {
+ iface.Objects.emplace_back(std::move(item));
+ continue;
+ }
}
}
- }
- iface.Libraries.emplace_back(std::move(item));
+ iface.Libraries.emplace_back(std::move(item));
+ }
+ }
+ if (cge->GetHadHeadSensitiveCondition()) {
+ iface.HadHeadSensitiveCondition = true;
+ }
+ if (cge->GetHadContextSensitiveCondition()) {
+ iface.HadContextSensitiveCondition = true;
+ }
+ if (cge->GetHadLinkLanguageSensitiveCondition()) {
+ iface.HadLinkLanguageSensitiveCondition = true;
}
}
- iface.HadHeadSensitiveCondition = cge->GetHadHeadSensitiveCondition();
- iface.HadContextSensitiveCondition = cge->GetHadContextSensitiveCondition();
- iface.HadLinkLanguageSensitiveCondition =
- cge->GetHadLinkLanguageSensitiveCondition();
}
cmLinkInterface const* cmGeneratorTarget::GetLinkInterface(
@@ -7105,8 +7212,18 @@ void cmGeneratorTarget::ComputeLinkInterfaceLibraries(
if (explicitLibraries) {
// The interface libraries have been explicitly set.
- this->ExpandLinkItems(linkIfaceProp, *explicitLibraries, config,
- headTarget, interfaceFor, iface);
+ if (cmp0022NEW) {
+ // The explicitLibraries came from INTERFACE_LINK_LIBRARIES.
+ // Use its special representation directly to get backtraces.
+ this->ExpandLinkItems(linkIfaceProp,
+ this->Target->GetLinkInterfaceEntries(), config,
+ headTarget, interfaceFor, iface);
+ } else {
+ std::vector<BT<std::string>> entries;
+ entries.emplace_back(*explicitLibraries);
+ this->ExpandLinkItems(linkIfaceProp, cmMakeRange(entries), config,
+ headTarget, interfaceFor, iface);
+ }
}
// If the link interface is explicit, do not fall back to the link impl.
@@ -7126,7 +7243,9 @@ void cmGeneratorTarget::ComputeLinkInterfaceLibraries(
cmLinkInterface ifaceNew;
static const std::string newProp = "INTERFACE_LINK_LIBRARIES";
if (cmValue newExplicitLibraries = this->GetProperty(newProp)) {
- this->ExpandLinkItems(newProp, *newExplicitLibraries, config,
+ std::vector<BT<std::string>> entries;
+ entries.emplace_back(*newExplicitLibraries);
+ this->ExpandLinkItems(linkIfaceProp, cmMakeRange(entries), config,
headTarget, interfaceFor, ifaceNew);
}
if (ifaceNew.Libraries != iface.Libraries) {
@@ -7266,10 +7385,11 @@ const cmLinkInterface* cmGeneratorTarget::GetImportLinkInterface(
cmOptionalLinkInterface& iface = hm[headTarget];
if (!iface.AllDone) {
iface.AllDone = true;
+ iface.LibrariesDone = true;
iface.Multiplicity = info->Multiplicity;
cmExpandList(info->Languages, iface.Languages);
- this->ExpandLinkItems(info->LibrariesProp, info->Libraries, config,
- headTarget, interfaceFor, iface);
+ this->ExpandLinkItems(info->LibrariesProp, cmMakeRange(info->Libraries),
+ config, headTarget, interfaceFor, iface);
std::vector<std::string> deps = cmExpandedList(info->SharedDeps);
LookupLinkItemScope scope{ this->LocalGenerator };
for (std::string const& dep : deps) {
@@ -7340,23 +7460,26 @@ void cmGeneratorTarget::ComputeImportInfo(std::string const& desired_config,
// Get the link interface.
{
- std::string linkProp = "INTERFACE_LINK_LIBRARIES";
- cmValue propertyLibs = this->GetProperty(linkProp);
-
- if (this->GetType() != cmStateEnums::INTERFACE_LIBRARY) {
- if (!propertyLibs) {
- linkProp = cmStrCat("IMPORTED_LINK_INTERFACE_LIBRARIES", suffix);
- propertyLibs = this->GetProperty(linkProp);
+ // Use the INTERFACE_LINK_LIBRARIES special representation directly
+ // to get backtraces.
+ cmBTStringRange entries = this->Target->GetLinkInterfaceEntries();
+ if (!entries.empty()) {
+ info.LibrariesProp = "INTERFACE_LINK_LIBRARIES";
+ for (BT<std::string> const& entry : entries) {
+ info.Libraries.emplace_back(entry);
}
-
+ } else if (this->GetType() != cmStateEnums::INTERFACE_LIBRARY) {
+ std::string linkProp =
+ cmStrCat("IMPORTED_LINK_INTERFACE_LIBRARIES", suffix);
+ cmValue propertyLibs = this->GetProperty(linkProp);
if (!propertyLibs) {
linkProp = "IMPORTED_LINK_INTERFACE_LIBRARIES";
propertyLibs = this->GetProperty(linkProp);
}
- }
- if (propertyLibs) {
- info.LibrariesProp = linkProp;
- info.Libraries = *propertyLibs;
+ if (propertyLibs) {
+ info.LibrariesProp = linkProp;
+ info.Libraries.emplace_back(*propertyLibs);
+ }
}
}
if (this->GetType() == cmStateEnums::INTERFACE_LIBRARY) {
diff --git a/Source/cmGeneratorTarget.h b/Source/cmGeneratorTarget.h
index 76458bd..71212c4 100644
--- a/Source/cmGeneratorTarget.h
+++ b/Source/cmGeneratorTarget.h
@@ -16,6 +16,7 @@
#include <cm/optional>
+#include "cmAlgorithms.h"
#include "cmLinkItem.h"
#include "cmListFileCache.h"
#include "cmPolicies.h"
@@ -83,6 +84,10 @@ public:
cmComputeLinkInformation* GetLinkInformation(
const std::string& config) const;
+ // Perform validation checks on memoized link structures.
+ // Call this after generation is complete.
+ void CheckLinkLibraries() const;
+
cmStateEnums::TargetType GetType() const;
const std::string& GetName() const;
std::string GetExportName() const;
@@ -974,6 +979,14 @@ private:
cmLinkImplementation const* GetLinkImplementation(const std::string& config,
bool secondPass) const;
+ enum class LinkItemRole
+ {
+ Implementation,
+ Interface,
+ };
+ bool VerifyLinkItemIsTarget(LinkItemRole role, cmLinkItem const& item) const;
+ bool VerifyLinkItemColons(LinkItemRole role, cmLinkItem const& item) const;
+
// Cache import information from properties for each configuration.
struct ImportInfo
{
@@ -985,7 +998,7 @@ private:
std::string ImportLibrary;
std::string LibName;
std::string Languages;
- std::string Libraries;
+ std::vector<BT<std::string>> Libraries;
std::string LibrariesProp;
std::string SharedDeps;
};
@@ -1047,7 +1060,7 @@ private:
bool IsLinkLookupScope(std::string const& n,
cmLocalGenerator const*& lg) const;
- void ExpandLinkItems(std::string const& prop, std::string const& value,
+ void ExpandLinkItems(std::string const& prop, cmBTStringRange entries,
std::string const& config,
const cmGeneratorTarget* headTarget,
LinkInterfaceFor interfaceFor,
diff --git a/Source/cmGlobalGenerator.cxx b/Source/cmGlobalGenerator.cxx
index 0a2e7b5..6433681 100644
--- a/Source/cmGlobalGenerator.cxx
+++ b/Source/cmGlobalGenerator.cxx
@@ -328,6 +328,18 @@ bool cmGlobalGenerator::CheckTargetsForMissingSources() const
return failed;
}
+void cmGlobalGenerator::CheckTargetLinkLibraries() const
+{
+ for (const auto& generator : this->LocalGenerators) {
+ for (const auto& gt : generator->GetGeneratorTargets()) {
+ gt->CheckLinkLibraries();
+ }
+ for (const auto& gt : generator->GetOwnedImportedGeneratorTargets()) {
+ gt->CheckLinkLibraries();
+ }
+ }
+}
+
bool cmGlobalGenerator::CheckTargetsForType() const
{
if (!this->GetLanguageEnabled("Swift")) {
@@ -1606,6 +1618,9 @@ void cmGlobalGenerator::Generate()
this->ExtraGenerator->Generate();
}
+ // Perform validation checks on memoized link structures.
+ this->CheckTargetLinkLibraries();
+
if (!this->CMP0042WarnTargets.empty()) {
std::ostringstream w;
w << cmPolicies::GetPolicyWarning(cmPolicies::CMP0042) << "\n";
diff --git a/Source/cmGlobalGenerator.h b/Source/cmGlobalGenerator.h
index 96696aa..2406798 100644
--- a/Source/cmGlobalGenerator.h
+++ b/Source/cmGlobalGenerator.h
@@ -684,6 +684,7 @@ private:
virtual void ForceLinkerLanguages();
+ void CheckTargetLinkLibraries() const;
bool CheckTargetsForMissingSources() const;
bool CheckTargetsForType() const;
bool CheckTargetsForPchCompilePdb() const;
diff --git a/Source/cmLocalGenerator.h b/Source/cmLocalGenerator.h
index c73cd62..115a54a 100644
--- a/Source/cmLocalGenerator.h
+++ b/Source/cmLocalGenerator.h
@@ -193,6 +193,11 @@ public:
return this->GeneratorTargets;
}
+ const GeneratorTargetVector& GetOwnedImportedGeneratorTargets() const
+ {
+ return this->OwnedImportedGeneratorTargets;
+ }
+
void AddGeneratorTarget(std::unique_ptr<cmGeneratorTarget> gt);
void AddImportedGeneratorTarget(cmGeneratorTarget* gt);
void AddOwnedImportedGeneratorTarget(std::unique_ptr<cmGeneratorTarget> gt);
diff --git a/Source/cmLocalVisualStudio7Generator.cxx b/Source/cmLocalVisualStudio7Generator.cxx
index dc9dcc7..fd13c0b 100644
--- a/Source/cmLocalVisualStudio7Generator.cxx
+++ b/Source/cmLocalVisualStudio7Generator.cxx
@@ -570,7 +570,16 @@ public:
this->First = true;
this->Stream << "\t\t\t<Tool\n\t\t\t\tName=\"" << tool << "\"";
}
- void Finish() { this->Stream << (this->First ? "" : "\"") << "/>\n"; }
+ void Finish()
+ {
+ // If any commands were generated, finish constructing them.
+ if (!this->First) {
+ std::string finishScript = this->LG->FinishConstructScript(IsCSharp::No);
+ this->Stream << this->LG->EscapeForXML(finishScript) << "\"";
+ }
+
+ this->Stream << "/>\n";
+ }
void Write(std::vector<cmCustomCommand> const& ccs)
{
for (cmCustomCommand const& command : ccs) {
@@ -1808,6 +1817,7 @@ void cmLocalVisualStudio7Generator::WriteCustomRule(
if (this->FortranProject) {
cmSystemTools::ReplaceString(script, "$(Configuration)", config);
}
+ script += this->FinishConstructScript(IsCSharp::No);
/* clang-format off */
fout << "\t\t\t\t\t<Tool\n"
<< "\t\t\t\t\tName=\"" << customTool << "\"\n"
diff --git a/Source/cmLocalVisualStudioGenerator.cxx b/Source/cmLocalVisualStudioGenerator.cxx
index ee7e77f..a21293b 100644
--- a/Source/cmLocalVisualStudioGenerator.cxx
+++ b/Source/cmLocalVisualStudioGenerator.cxx
@@ -243,3 +243,20 @@ std::string cmLocalVisualStudioGenerator::ConstructScript(
return script;
}
+
+std::string cmLocalVisualStudioGenerator::FinishConstructScript(
+ IsCSharp isCSharp, const std::string& newline)
+{
+ bool useLocal = this->CustomCommandUseLocal();
+
+ // Store the script in a string.
+ std::string script;
+
+ if (useLocal && isCSharp == IsCSharp::Yes) {
+ // This label is not provided by MSBuild for C# projects.
+ script += newline;
+ script += this->GetReportErrorLabel();
+ }
+
+ return script;
+}
diff --git a/Source/cmLocalVisualStudioGenerator.h b/Source/cmLocalVisualStudioGenerator.h
index 91fb6b0..82a62cf 100644
--- a/Source/cmLocalVisualStudioGenerator.h
+++ b/Source/cmLocalVisualStudioGenerator.h
@@ -31,8 +31,15 @@ public:
virtual ~cmLocalVisualStudioGenerator();
/** Construct a script from the given list of command lines. */
+ enum class IsCSharp
+ {
+ No,
+ Yes
+ };
std::string ConstructScript(cmCustomCommandGenerator const& ccg,
const std::string& newline = "\n");
+ std::string FinishConstructScript(IsCSharp isCSharp,
+ const std::string& newline = "\n");
/** Label to which to jump in a batch file after a failed step in a
sequence of custom commands. */
diff --git a/Source/cmTarget.cxx b/Source/cmTarget.cxx
index f384463..c5703a1 100644
--- a/Source/cmTarget.cxx
+++ b/Source/cmTarget.cxx
@@ -200,6 +200,7 @@ public:
std::vector<BT<std::string>> LinkOptionsEntries;
std::vector<BT<std::string>> LinkDirectoriesEntries;
std::vector<BT<std::string>> LinkImplementationPropertyEntries;
+ std::vector<BT<std::string>> LinkInterfacePropertyEntries;
std::vector<BT<std::string>> HeaderSetsEntries;
std::vector<BT<std::string>> InterfaceHeaderSetsEntries;
std::vector<std::pair<cmTarget::TLLSignature, cmListFileContext>>
@@ -470,6 +471,9 @@ cmTarget::cmTarget(std::string const& name, cmStateEnums::TargetType type,
initProp(property);
}
}
+ if (!this->IsImported()) {
+ initProp("LINK_LIBRARIES_ONLY_TARGETS");
+ }
}
// Save the backtrace of target construction.
@@ -1118,6 +1122,11 @@ cmBTStringRange cmTarget::GetLinkImplementationEntries() const
return cmMakeRange(this->impl->LinkImplementationPropertyEntries);
}
+cmBTStringRange cmTarget::GetLinkInterfaceEntries() const
+{
+ return cmMakeRange(this->impl->LinkInterfacePropertyEntries);
+}
+
cmBTStringRange cmTarget::GetHeaderSetsEntries() const
{
return cmMakeRange(this->impl->HeaderSetsEntries);
@@ -1161,6 +1170,7 @@ MAKE_PROP(HEADER_DIRS);
MAKE_PROP(HEADER_SET);
MAKE_PROP(HEADER_SETS);
MAKE_PROP(INTERFACE_HEADER_SETS);
+MAKE_PROP(INTERFACE_LINK_LIBRARIES);
#undef MAKE_PROP
}
@@ -1286,6 +1296,12 @@ void cmTarget::StoreProperty(const std::string& prop, ValueType value)
cmListFileBacktrace lfbt = this->impl->Makefile->GetBacktrace();
this->impl->LinkImplementationPropertyEntries.emplace_back(value, lfbt);
}
+ } else if (prop == propINTERFACE_LINK_LIBRARIES) {
+ this->impl->LinkInterfacePropertyEntries.clear();
+ if (value) {
+ cmListFileBacktrace lfbt = this->impl->Makefile->GetBacktrace();
+ this->impl->LinkInterfacePropertyEntries.emplace_back(value, lfbt);
+ }
} else if (prop == propSOURCES) {
this->impl->SourceEntries.clear();
if (value) {
@@ -1539,6 +1555,11 @@ void cmTarget::AppendProperty(const std::string& prop,
cmListFileBacktrace lfbt = this->impl->Makefile->GetBacktrace();
this->impl->LinkImplementationPropertyEntries.emplace_back(value, lfbt);
}
+ } else if (prop == propINTERFACE_LINK_LIBRARIES) {
+ if (!value.empty()) {
+ cmListFileBacktrace lfbt = this->impl->Makefile->GetBacktrace();
+ this->impl->LinkInterfacePropertyEntries.emplace_back(value, lfbt);
+ }
} else if (prop == "SOURCES") {
cmListFileBacktrace lfbt = this->impl->Makefile->GetBacktrace();
this->impl->SourceEntries.emplace_back(value, lfbt);
@@ -1848,6 +1869,7 @@ cmValue cmTarget::GetProperty(const std::string& prop) const
propHEADER_SET,
propHEADER_SETS,
propINTERFACE_HEADER_SETS,
+ propINTERFACE_LINK_LIBRARIES,
};
if (specialProps.count(prop)) {
if (prop == propC_STANDARD || prop == propCXX_STANDARD ||
@@ -1868,6 +1890,15 @@ cmValue cmTarget::GetProperty(const std::string& prop) const
output = cmJoin(this->impl->LinkImplementationPropertyEntries, ";");
return cmValue(output);
}
+ if (prop == propINTERFACE_LINK_LIBRARIES) {
+ if (this->impl->LinkInterfacePropertyEntries.empty()) {
+ return nullptr;
+ }
+
+ static std::string output;
+ output = cmJoin(this->impl->LinkInterfacePropertyEntries, ";");
+ return cmValue(output);
+ }
// the type property returns what type the target is
if (prop == propTYPE) {
return cmValue(cmState::GetTargetTypeName(this->GetType()));
diff --git a/Source/cmTarget.h b/Source/cmTarget.h
index c4314a4..1173f49 100644
--- a/Source/cmTarget.h
+++ b/Source/cmTarget.h
@@ -265,6 +265,8 @@ public:
cmBTStringRange GetLinkImplementationEntries() const;
+ cmBTStringRange GetLinkInterfaceEntries() const;
+
cmBTStringRange GetHeaderSetsEntries() const;
cmBTStringRange GetInterfaceHeaderSetsEntries() const;
diff --git a/Source/cmVisualStudio10TargetGenerator.cxx b/Source/cmVisualStudio10TargetGenerator.cxx
index ddfe24d..84044e4 100644
--- a/Source/cmVisualStudio10TargetGenerator.cxx
+++ b/Source/cmVisualStudio10TargetGenerator.cxx
@@ -1711,6 +1711,11 @@ void cmVisualStudio10TargetGenerator::WriteCustomRule(
}
}
}
+ cmLocalVisualStudioGenerator::IsCSharp isCSharp =
+ (this->ProjectType == VsProjectType::csproj)
+ ? cmLocalVisualStudioGenerator::IsCSharp::Yes
+ : cmLocalVisualStudioGenerator::IsCSharp::No;
+ script += lg->FinishConstructScript(isCSharp);
if (this->ProjectType == VsProjectType::csproj) {
std::string name = "CustomCommand_" + c + "_" +
cmSystemTools::ComputeStringMD5(sourcePath);
@@ -3385,6 +3390,8 @@ bool cmVisualStudio10TargetGenerator::ComputeCudaOptions(
this->LocalGenerator, Options::CudaCompiler, gg->GetCudaFlagTable());
Options& cudaOptions = *pOptions;
+ auto cudaVersion = this->GlobalGenerator->GetPlatformToolsetCudaString();
+
// Get compile flags for CUDA in this directory.
std::string flags;
this->LocalGenerator->AddLanguageFlags(flags, this->GeneratorTarget, "CUDA",
@@ -3420,7 +3427,22 @@ bool cmVisualStudio10TargetGenerator::ComputeCudaOptions(
// to not have the source file extension at all
cudaOptions.AddFlag("CompileOut", "$(IntDir)%(Filename).ptx");
notPtx = false;
+
+ if (cmSystemTools::VersionCompare(cmSystemTools::OP_GREATER_EQUAL,
+ cudaVersion, "9.0") &&
+ cmSystemTools::VersionCompare(cmSystemTools::OP_LESS, cudaVersion,
+ "11.5")) {
+ // The DriverApi flag before 11.5 ( verified back to 9.0 ) which controls
+ // PTX compilation doesn't propagate user defines causing
+ // target_compile_definitions to behave differently for VS +
+ // PTX compared to other generators so we patch the rules
+ // to normalize behavior
+ cudaOptions.AddFlag("DriverApiCommandLineTemplate",
+ "%(BaseCommandLineTemplate) [CompileOut] [FastMath] "
+ "[Defines] \"%(FullPath)\"");
+ }
}
+
if (notPtx &&
cmSystemTools::VersionCompareGreaterEq(
"8.0", this->GlobalGenerator->GetPlatformToolsetCudaString())) {
@@ -4426,6 +4448,13 @@ void cmVisualStudio10TargetGenerator::WriteEvent(
stdPipesUTF8 = stdPipesUTF8 || cc.GetStdPipesUTF8();
}
}
+ if (!script.empty()) {
+ cmLocalVisualStudioGenerator::IsCSharp isCSharp =
+ (this->ProjectType == VsProjectType::csproj)
+ ? cmLocalVisualStudioGenerator::IsCSharp::Yes
+ : cmLocalVisualStudioGenerator::IsCSharp::No;
+ script += lg->FinishConstructScript(isCSharp);
+ }
comment = cmVS10EscapeComment(comment);
if (this->ProjectType != VsProjectType::csproj) {
Elem e2(e1, name);
diff --git a/Source/cmake.cxx b/Source/cmake.cxx
index 9efdb54..2a3ef9b 100644
--- a/Source/cmake.cxx
+++ b/Source/cmake.cxx
@@ -968,7 +968,34 @@ void cmake::SetArgs(const std::vector<std::string>& args)
"--debug-find", CommandArgument::Values::Zero,
[](std::string const&, cmake* state) -> bool {
std::cout << "Running with debug output on for the `find` commands.\n";
- state->SetDebugFindOutputOn(true);
+ state->SetDebugFindOutput(true);
+ return true;
+ } },
+ CommandArgument{
+ "--debug-find-pkg", "Provide a package argument for --debug-find-pkg",
+ CommandArgument::Values::One, CommandArgument::RequiresSeparator::Yes,
+ [](std::string const& value, cmake* state) -> bool {
+ std::vector<std::string> find_pkgs(cmTokenize(value, ","));
+ std::cout << "Running with debug output on for the 'find' commands "
+ "for package(s)";
+ for (auto const& v : find_pkgs) {
+ std::cout << " " << v;
+ state->SetDebugFindOutputPkgs(v);
+ }
+ std::cout << ".\n";
+ return true;
+ } },
+ CommandArgument{
+ "--debug-find-var", CommandArgument::Values::One,
+ CommandArgument::RequiresSeparator::Yes,
+ [](std::string const& value, cmake* state) -> bool {
+ std::vector<std::string> find_vars(cmTokenize(value, ","));
+ std::cout << "Running with debug output on for the variable(s)";
+ for (auto const& v : find_vars) {
+ std::cout << " " << v;
+ state->SetDebugFindOutputVars(v);
+ }
+ std::cout << ".\n";
return true;
} },
CommandArgument{ "--trace-expand", CommandArgument::Values::Zero,
@@ -1325,7 +1352,7 @@ void cmake::SetArgs(const std::vector<std::string>& args)
this->DebugTryCompileOn();
}
if (expandedPreset->DebugFind == true) {
- this->SetDebugFindOutputOn(true);
+ this->SetDebugFindOutput(true);
}
}
#endif
@@ -3619,6 +3646,26 @@ void cmake::SetDeprecatedWarningsAsErrors(bool b)
cmStateEnums::INTERNAL);
}
+void cmake::SetDebugFindOutputPkgs(std::string const& args)
+{
+ this->DebugFindPkgs.emplace(args);
+}
+
+void cmake::SetDebugFindOutputVars(std::string const& args)
+{
+ this->DebugFindVars.emplace(args);
+}
+
+bool cmake::GetDebugFindOutput(std::string const& var) const
+{
+ return this->DebugFindVars.count(var);
+}
+
+bool cmake::GetDebugFindPkgOutput(std::string const& pkg) const
+{
+ return this->DebugFindPkgs.count(pkg);
+}
+
#if !defined(CMAKE_BOOTSTRAP)
cmMakefileProfilingData& cmake::GetProfilingOutput()
{
diff --git a/Source/cmake.h b/Source/cmake.h
index 3f2b2ed..a356e65 100644
--- a/Source/cmake.h
+++ b/Source/cmake.h
@@ -486,7 +486,11 @@ public:
//! Do we want debug output from the find commands during the cmake run.
bool GetDebugFindOutput() const { return this->DebugFindOutput; }
- void SetDebugFindOutputOn(bool b) { this->DebugFindOutput = b; }
+ bool GetDebugFindOutput(std::string const& var) const;
+ bool GetDebugFindPkgOutput(std::string const& var) const;
+ void SetDebugFindOutput(bool b) { this->DebugFindOutput = b; }
+ void SetDebugFindOutputPkgs(std::string const& args);
+ void SetDebugFindOutputVars(std::string const& args);
//! Do we want trace output during the cmake run.
bool GetTrace() const { return this->Trace; }
@@ -704,6 +708,9 @@ private:
std::vector<std::string> TraceOnlyThisSources;
+ std::set<std::string> DebugFindPkgs;
+ std::set<std::string> DebugFindVars;
+
LogLevel MessageLogLevel = LogLevel::LOG_STATUS;
bool LogLevelWasSetViaCLI = false;
bool LogContext = false;
diff --git a/Source/cmakemain.cxx b/Source/cmakemain.cxx
index 61d4ae4..00aafdc 100644
--- a/Source/cmakemain.cxx
+++ b/Source/cmakemain.cxx
@@ -90,6 +90,10 @@ const char* cmDocumentationOptions[][2] = {
"useful on one try_compile at a time." },
{ "--debug-output", "Put cmake in a debug mode." },
{ "--debug-find", "Put cmake find in a debug mode." },
+ { "--debug-find-pkg=<pkg-name>[,...]",
+ "Limit cmake debug-find to the comma-separated list of packages" },
+ { "--debug-find-var=<var-name>[,...]",
+ "Limit cmake debug-find to the comma-separated list of result variables" },
{ "--trace", "Put cmake in trace mode." },
{ "--trace-expand", "Put cmake in trace mode with variable expansion." },
{ "--trace-format=<human|json-v1>", "Set the output format of the trace." },
diff --git a/Tests/CudaOnly/ExportPTX/CMakeLists.txt b/Tests/CudaOnly/ExportPTX/CMakeLists.txt
index f1667af..e97274d 100644
--- a/Tests/CudaOnly/ExportPTX/CMakeLists.txt
+++ b/Tests/CudaOnly/ExportPTX/CMakeLists.txt
@@ -11,6 +11,7 @@ list(SUBLIST CMAKE_CUDA_ARCHITECTURES 0 1 CMAKE_CUDA_ARCHITECTURES)
string(APPEND CMAKE_CUDA_ARCHITECTURES "-virtual")
add_library(CudaPTX OBJECT kernelA.cu kernelB.cu)
+target_compile_definitions(CudaPTX PRIVATE "CUDA_PTX_COMPILATION")
set_property(TARGET CudaPTX PROPERTY CUDA_PTX_COMPILATION ON)
#Test ObjectFiles with file(GENERATE)
diff --git a/Tests/CudaOnly/ExportPTX/kernelA.cu b/Tests/CudaOnly/ExportPTX/kernelA.cu
index fbe0d26..8967298 100644
--- a/Tests/CudaOnly/ExportPTX/kernelA.cu
+++ b/Tests/CudaOnly/ExportPTX/kernelA.cu
@@ -1,4 +1,8 @@
+#ifndef CUDA_PTX_COMPILATION
+# error "CUDA_PTX_COMPILATION define not provided"
+#endif
+
__global__ void kernelA(float* r, float* x, float* y, float* z, int size)
{
for (int i = threadIdx.x; i < size; i += blockDim.x) {
diff --git a/Tests/CudaOnly/ExportPTX/kernelB.cu b/Tests/CudaOnly/ExportPTX/kernelB.cu
index 11872e4..be4613a 100644
--- a/Tests/CudaOnly/ExportPTX/kernelB.cu
+++ b/Tests/CudaOnly/ExportPTX/kernelB.cu
@@ -1,4 +1,7 @@
+#ifndef CUDA_PTX_COMPILATION
+# error "CUDA_PTX_COMPILATION define not provided"
+#endif
__global__ void kernelB(float* r, float* x, float* y, float* z, int size)
{
diff --git a/Tests/RunCMake/CMP0028/CMP0028-NEW-iface-stderr.txt b/Tests/RunCMake/CMP0028/CMP0028-NEW-iface-stderr.txt
deleted file mode 100644
index e2108f4..0000000
--- a/Tests/RunCMake/CMP0028/CMP0028-NEW-iface-stderr.txt
+++ /dev/null
@@ -1,6 +0,0 @@
-CMake Error at CMP0028-NEW-iface.cmake:6 \(add_library\):
- Target "foo" links to target "External::Library" but the target was not
- found. Perhaps a find_package\(\) call is missing for an IMPORTED target, or
- an ALIAS target is missing\?
-Call Stack \(most recent call first\):
- CMakeLists.txt:3 \(include\)
diff --git a/Tests/RunCMake/CMP0028/CMP0028-NEW-stderr.txt b/Tests/RunCMake/CMP0028/CMP0028-NEW-stderr.txt
deleted file mode 100644
index 711ad0e..0000000
--- a/Tests/RunCMake/CMP0028/CMP0028-NEW-stderr.txt
+++ /dev/null
@@ -1,6 +0,0 @@
-CMake Error at CMP0028-NEW.cmake:4 \(add_library\):
- Target "foo" links to target "External::Library" but the target was not
- found. Perhaps a find_package\(\) call is missing for an IMPORTED target, or
- an ALIAS target is missing\?
-Call Stack \(most recent call first\):
- CMakeLists.txt:3 \(include\)
diff --git a/Tests/RunCMake/CMakeLists.txt b/Tests/RunCMake/CMakeLists.txt
index dec147b..f0457a8 100644
--- a/Tests/RunCMake/CMakeLists.txt
+++ b/Tests/RunCMake/CMakeLists.txt
@@ -94,7 +94,6 @@ add_RunCMake_test(CMP0019)
add_RunCMake_test(CMP0022)
add_RunCMake_test(CMP0026)
add_RunCMake_test(CMP0027)
-add_RunCMake_test(CMP0028)
add_RunCMake_test(CMP0037)
add_RunCMake_test(CMP0038)
add_RunCMake_test(CMP0039)
@@ -329,6 +328,7 @@ add_RunCMake_test(GoogleTest) # Note: does not actually depend on Google Test
add_RunCMake_test(Graphviz)
add_RunCMake_test(TargetPropertyGeneratorExpressions)
add_RunCMake_test(Languages)
+add_RunCMake_test(LinkItemValidation)
add_RunCMake_test(LinkStatic)
if(CMAKE_CXX_COMPILER_ID MATCHES "^(Cray|PGI|NVHPC|XL|XLClang|Fujitsu|FujitsuClang)$")
add_RunCMake_test(MetaCompileFeatures)
diff --git a/Tests/RunCMake/GeneratorToolset/VsNormal-stdout.txt b/Tests/RunCMake/GeneratorToolset/VsNormal-stdout.txt
index 25fa3bf..cfcb448 100644
--- a/Tests/RunCMake/GeneratorToolset/VsNormal-stdout.txt
+++ b/Tests/RunCMake/GeneratorToolset/VsNormal-stdout.txt
@@ -1,2 +1,2 @@
-- CMAKE_VS_PLATFORM_NAME='[^']+'
--- CMAKE_VS_PLATFORM_TOOLSET='v[0-9]+'
+-- CMAKE_VS_PLATFORM_TOOLSET='v[0-9]+|Intel[^']+C\+\+ Compiler[^']*'
diff --git a/Tests/RunCMake/CMP0028/CMP0028-NEW-iface-result.txt b/Tests/RunCMake/LinkItemValidation/CMP0028-NEW-iface-result.txt
index d00491f..d00491f 100644
--- a/Tests/RunCMake/CMP0028/CMP0028-NEW-iface-result.txt
+++ b/Tests/RunCMake/LinkItemValidation/CMP0028-NEW-iface-result.txt
diff --git a/Tests/RunCMake/LinkItemValidation/CMP0028-NEW-iface-stderr.txt b/Tests/RunCMake/LinkItemValidation/CMP0028-NEW-iface-stderr.txt
new file mode 100644
index 0000000..111d1f0
--- /dev/null
+++ b/Tests/RunCMake/LinkItemValidation/CMP0028-NEW-iface-stderr.txt
@@ -0,0 +1,12 @@
+CMake Error at CMP0028-NEW-iface\.cmake:5 \(target_link_libraries\):
+ The link interface of target "iface" contains:
+
+ External::Library
+
+ but the target was not found. Possible reasons include:
+(
+ \*[^
+]+)*
+
+Call Stack \(most recent call first\):
+ CMakeLists\.txt:[0-9]+ \(include\)
diff --git a/Tests/RunCMake/CMP0028/CMP0028-NEW-iface.cmake b/Tests/RunCMake/LinkItemValidation/CMP0028-NEW-iface.cmake
index 1a71433..1a71433 100644
--- a/Tests/RunCMake/CMP0028/CMP0028-NEW-iface.cmake
+++ b/Tests/RunCMake/LinkItemValidation/CMP0028-NEW-iface.cmake
diff --git a/Tests/RunCMake/CMP0028/CMP0028-NEW-result.txt b/Tests/RunCMake/LinkItemValidation/CMP0028-NEW-result.txt
index d00491f..d00491f 100644
--- a/Tests/RunCMake/CMP0028/CMP0028-NEW-result.txt
+++ b/Tests/RunCMake/LinkItemValidation/CMP0028-NEW-result.txt
diff --git a/Tests/RunCMake/LinkItemValidation/CMP0028-NEW-stderr.txt b/Tests/RunCMake/LinkItemValidation/CMP0028-NEW-stderr.txt
new file mode 100644
index 0000000..17b25de
--- /dev/null
+++ b/Tests/RunCMake/LinkItemValidation/CMP0028-NEW-stderr.txt
@@ -0,0 +1,12 @@
+CMake Error at CMP0028-NEW\.cmake:5 \(target_link_libraries\):
+ Target "foo" links to:
+
+ External::Library
+
+ but the target was not found. Possible reasons include:
+(
+ \*[^
+]+)*
+
+Call Stack \(most recent call first\):
+ CMakeLists\.txt:[0-9]+ \(include\)
diff --git a/Tests/RunCMake/CMP0028/CMP0028-NEW.cmake b/Tests/RunCMake/LinkItemValidation/CMP0028-NEW.cmake
index a0a6ae8..a0a6ae8 100644
--- a/Tests/RunCMake/CMP0028/CMP0028-NEW.cmake
+++ b/Tests/RunCMake/LinkItemValidation/CMP0028-NEW.cmake
diff --git a/Tests/RunCMake/CMP0028/CMP0028-OLD-iface-result.txt b/Tests/RunCMake/LinkItemValidation/CMP0028-OLD-iface-result.txt
index 573541a..573541a 100644
--- a/Tests/RunCMake/CMP0028/CMP0028-OLD-iface-result.txt
+++ b/Tests/RunCMake/LinkItemValidation/CMP0028-OLD-iface-result.txt
diff --git a/Tests/RunCMake/CMP0028/CMP0028-OLD-iface-stderr.txt b/Tests/RunCMake/LinkItemValidation/CMP0028-OLD-iface-stderr.txt
index b7a0755..b7a0755 100644
--- a/Tests/RunCMake/CMP0028/CMP0028-OLD-iface-stderr.txt
+++ b/Tests/RunCMake/LinkItemValidation/CMP0028-OLD-iface-stderr.txt
diff --git a/Tests/RunCMake/CMP0028/CMP0028-OLD-iface.cmake b/Tests/RunCMake/LinkItemValidation/CMP0028-OLD-iface.cmake
index d7bd60e..d7bd60e 100644
--- a/Tests/RunCMake/CMP0028/CMP0028-OLD-iface.cmake
+++ b/Tests/RunCMake/LinkItemValidation/CMP0028-OLD-iface.cmake
diff --git a/Tests/RunCMake/CMP0028/CMP0028-OLD-result.txt b/Tests/RunCMake/LinkItemValidation/CMP0028-OLD-result.txt
index 573541a..573541a 100644
--- a/Tests/RunCMake/CMP0028/CMP0028-OLD-result.txt
+++ b/Tests/RunCMake/LinkItemValidation/CMP0028-OLD-result.txt
diff --git a/Tests/RunCMake/CMP0028/CMP0028-OLD-stderr.txt b/Tests/RunCMake/LinkItemValidation/CMP0028-OLD-stderr.txt
index 586a876..586a876 100644
--- a/Tests/RunCMake/CMP0028/CMP0028-OLD-stderr.txt
+++ b/Tests/RunCMake/LinkItemValidation/CMP0028-OLD-stderr.txt
diff --git a/Tests/RunCMake/CMP0028/CMP0028-OLD.cmake b/Tests/RunCMake/LinkItemValidation/CMP0028-OLD.cmake
index d4a870b..d4a870b 100644
--- a/Tests/RunCMake/CMP0028/CMP0028-OLD.cmake
+++ b/Tests/RunCMake/LinkItemValidation/CMP0028-OLD.cmake
diff --git a/Tests/RunCMake/CMP0028/CMP0028-WARN-iface-result.txt b/Tests/RunCMake/LinkItemValidation/CMP0028-WARN-iface-result.txt
index 573541a..573541a 100644
--- a/Tests/RunCMake/CMP0028/CMP0028-WARN-iface-result.txt
+++ b/Tests/RunCMake/LinkItemValidation/CMP0028-WARN-iface-result.txt
diff --git a/Tests/RunCMake/CMP0028/CMP0028-WARN-iface-stderr.txt b/Tests/RunCMake/LinkItemValidation/CMP0028-WARN-iface-stderr.txt
index 0c5c653..bb6a16e 100644
--- a/Tests/RunCMake/CMP0028/CMP0028-WARN-iface-stderr.txt
+++ b/Tests/RunCMake/LinkItemValidation/CMP0028-WARN-iface-stderr.txt
@@ -1,11 +1,17 @@
-CMake Warning \(dev\) at CMP0028-WARN-iface.cmake:4 \(add_library\):
+CMake Warning \(dev\) at CMP0028-WARN-iface\.cmake:3 \(target_link_libraries\):
Policy CMP0028 is not set: Double colon in target name means ALIAS or
IMPORTED target. Run "cmake --help-policy CMP0028" for policy details.
Use the cmake_policy command to set the policy and suppress this warning.
- Target "foo" links to target "External::Library" but the target was not
- found. Perhaps a find_package\(\) call is missing for an IMPORTED target, or
- an ALIAS target is missing\?
+ The link interface of target "iface" contains:
+
+ External::Library
+
+ but the target was not found. Possible reasons include:
+(
+ \*[^
+]+)*
+
Call Stack \(most recent call first\):
- CMakeLists.txt:3 \(include\)
+ CMakeLists\.txt:[0-9]+ \(include\)
This warning is for project developers. Use -Wno-dev to suppress it.
diff --git a/Tests/RunCMake/CMP0028/CMP0028-WARN-iface.cmake b/Tests/RunCMake/LinkItemValidation/CMP0028-WARN-iface.cmake
index 9270023..9270023 100644
--- a/Tests/RunCMake/CMP0028/CMP0028-WARN-iface.cmake
+++ b/Tests/RunCMake/LinkItemValidation/CMP0028-WARN-iface.cmake
diff --git a/Tests/RunCMake/CMP0028/CMP0028-WARN-result.txt b/Tests/RunCMake/LinkItemValidation/CMP0028-WARN-result.txt
index 573541a..573541a 100644
--- a/Tests/RunCMake/CMP0028/CMP0028-WARN-result.txt
+++ b/Tests/RunCMake/LinkItemValidation/CMP0028-WARN-result.txt
diff --git a/Tests/RunCMake/CMP0028/CMP0028-WARN-stderr.txt b/Tests/RunCMake/LinkItemValidation/CMP0028-WARN-stderr.txt
index 41d7560..c0cb5b0 100644
--- a/Tests/RunCMake/CMP0028/CMP0028-WARN-stderr.txt
+++ b/Tests/RunCMake/LinkItemValidation/CMP0028-WARN-stderr.txt
@@ -1,11 +1,17 @@
-CMake Warning \(dev\) at CMP0028-WARN.cmake:2 \(add_library\):
+CMake Warning \(dev\) at CMP0028-WARN\.cmake:3 \(target_link_libraries\):
Policy CMP0028 is not set: Double colon in target name means ALIAS or
IMPORTED target. Run "cmake --help-policy CMP0028" for policy details.
Use the cmake_policy command to set the policy and suppress this warning.
- Target "foo" links to target "External::Library" but the target was not
- found. Perhaps a find_package\(\) call is missing for an IMPORTED target, or
- an ALIAS target is missing\?
+ Target "foo" links to:
+
+ External::Library
+
+ but the target was not found. Possible reasons include:
+(
+ \*[^
+]+)*
+
Call Stack \(most recent call first\):
- CMakeLists.txt:3 \(include\)
+ CMakeLists\.txt:[0-9]+ \(include\)
This warning is for project developers. Use -Wno-dev to suppress it.
diff --git a/Tests/RunCMake/CMP0028/CMP0028-WARN.cmake b/Tests/RunCMake/LinkItemValidation/CMP0028-WARN.cmake
index 70a6cc6..70a6cc6 100644
--- a/Tests/RunCMake/CMP0028/CMP0028-WARN.cmake
+++ b/Tests/RunCMake/LinkItemValidation/CMP0028-WARN.cmake
diff --git a/Tests/RunCMake/CMP0028/CMakeLists.txt b/Tests/RunCMake/LinkItemValidation/CMakeLists.txt
index 4f867df..185cd91 100644
--- a/Tests/RunCMake/CMP0028/CMakeLists.txt
+++ b/Tests/RunCMake/LinkItemValidation/CMakeLists.txt
@@ -1,3 +1,6 @@
cmake_minimum_required(VERSION 2.8.12)
+if(NOT RunCMake_TEST MATCHES "^CMP0028")
+ cmake_minimum_required(VERSION 3.22)
+endif()
project(${RunCMake_TEST} CXX)
include(${RunCMake_TEST}.cmake NO_POLICY_SCOPE) # policy used at end of dir
diff --git a/Tests/RunCMake/LinkItemValidation/OnlyTargets-result.txt b/Tests/RunCMake/LinkItemValidation/OnlyTargets-result.txt
new file mode 100644
index 0000000..d00491f
--- /dev/null
+++ b/Tests/RunCMake/LinkItemValidation/OnlyTargets-result.txt
@@ -0,0 +1 @@
+1
diff --git a/Tests/RunCMake/LinkItemValidation/OnlyTargets-stderr.txt b/Tests/RunCMake/LinkItemValidation/OnlyTargets-stderr.txt
new file mode 100644
index 0000000..bbb0170
--- /dev/null
+++ b/Tests/RunCMake/LinkItemValidation/OnlyTargets-stderr.txt
@@ -0,0 +1,40 @@
+^CMake Error at OnlyTargets\.cmake:11 \(target_link_libraries\):
+ Target "exe" has LINK_LIBRARIES_ONLY_TARGETS enabled, but it links to:
+
+ non_target_in_exe
+
+ which is not a target\. Possible reasons include:
+(
+ \*[^
+]+)*
+
+Call Stack \(most recent call first\):
+ CMakeLists\.txt:[0-9]+ \(include\)
++
+CMake Error at OnlyTargets\.cmake:21 \(target_link_libraries\):
+ Target "iface" has LINK_LIBRARIES_ONLY_TARGETS enabled, but its link
+ interface contains:
+
+ non_target_in_iface
+
+ which is not a target\. Possible reasons include:
+(
+ \*[^
+]+)*
+
+Call Stack \(most recent call first\):
+ CMakeLists\.txt:[0-9]+ \(include\)
++
+CMake Error at OnlyTargets\.cmake:30 \(target_link_libraries\):
+ Target "iface_imported_checked" has LINK_LIBRARIES_ONLY_TARGETS enabled,
+ but its link interface contains:
+
+ non_target_in_iface_imported_checked
+
+ which is not a target\. Possible reasons include:
+(
+ \*[^
+]+)*
+
+Call Stack \(most recent call first\):
+ CMakeLists\.txt:[0-9]+ \(include\)
diff --git a/Tests/RunCMake/LinkItemValidation/OnlyTargets.cmake b/Tests/RunCMake/LinkItemValidation/OnlyTargets.cmake
new file mode 100644
index 0000000..9417318
--- /dev/null
+++ b/Tests/RunCMake/LinkItemValidation/OnlyTargets.cmake
@@ -0,0 +1,56 @@
+enable_language(C)
+
+set(CMAKE_LINK_LIBRARIES_ONLY_TARGETS 1)
+
+# Use imported interface library to name toolchain-provided libraries.
+add_library(toolchain::m INTERFACE IMPORTED)
+set_property(TARGET toolchain::m PROPERTY IMPORTED_LIBNAME "m")
+
+# Linking directly warns.
+add_executable(exe main.c)
+target_link_libraries(exe PRIVATE
+ -lflag_in_exe # accepted
+ /abs/path/in_exe # accepted
+ rel/path/in_exe # accepted
+ toolchain::m # accepted
+ non_target_in_exe # rejected
+ )
+
+# Link interfaces warn.
+add_library(iface INTERFACE)
+target_link_libraries(iface INTERFACE
+ -lflag_in_iface # accepted
+ /abs/path/in_iface # accepted
+ rel/path/in_iface # accepted
+ non_target_in_iface # rejected
+ )
+
+# Imported target link interfaces warn if explicitly enabled.
+add_library(iface_imported_checked INTERFACE IMPORTED)
+target_link_libraries(iface_imported_checked INTERFACE
+ -lflag_iface_imported_checked # accepted
+ /abs/path/in_iface_imported_checked # accepted
+ rel/path/in_iface_imported_checked # accepted
+ non_target_in_iface_imported_checked # rejected
+ )
+set_property(TARGET iface_imported_checked PROPERTY LINK_LIBRARIES_ONLY_TARGETS 1)
+
+# Linking directly does not warn if explicitly disabled.
+add_executable(exe_not_checked main.c)
+target_link_libraries(exe_not_checked PRIVATE
+ non_target_in_exe_not_checked
+ )
+set_property(TARGET exe_not_checked PROPERTY LINK_LIBRARIES_ONLY_TARGETS 0)
+
+# Link interfaces do not warn if explicitly disabled.
+add_library(iface_not_checked INTERFACE)
+target_link_libraries(iface_not_checked INTERFACE
+ non_target_in_iface_not_checked
+ )
+set_property(TARGET iface_not_checked PROPERTY LINK_LIBRARIES_ONLY_TARGETS 0)
+
+# Imported target link interfaces do not warn if not explicitly enabled.
+add_library(iface_imported_default INTERFACE IMPORTED)
+target_link_libraries(iface_imported_default INTERFACE
+ non_target_in_iface_imported_default
+ )
diff --git a/Tests/RunCMake/CMP0028/RunCMakeTest.cmake b/Tests/RunCMake/LinkItemValidation/RunCMakeTest.cmake
index 0c72ca2..c423f6a 100644
--- a/Tests/RunCMake/CMP0028/RunCMakeTest.cmake
+++ b/Tests/RunCMake/LinkItemValidation/RunCMakeTest.cmake
@@ -6,3 +6,5 @@ run_cmake(CMP0028-WARN)
run_cmake(CMP0028-NEW-iface)
run_cmake(CMP0028-OLD-iface)
run_cmake(CMP0028-WARN-iface)
+
+run_cmake(OnlyTargets)
diff --git a/Tests/RunCMake/CMP0028/empty.cpp b/Tests/RunCMake/LinkItemValidation/empty.cpp
index e69de29..e69de29 100644
--- a/Tests/RunCMake/CMP0028/empty.cpp
+++ b/Tests/RunCMake/LinkItemValidation/empty.cpp
diff --git a/Tests/RunCMake/LinkItemValidation/main.c b/Tests/RunCMake/LinkItemValidation/main.c
new file mode 100644
index 0000000..8488f4e
--- /dev/null
+++ b/Tests/RunCMake/LinkItemValidation/main.c
@@ -0,0 +1,4 @@
+int main(void)
+{
+ return 0;
+}
diff --git a/Tests/RunCMake/TargetPropertyGeneratorExpressions/LinkImplementationCycle4-stderr.txt b/Tests/RunCMake/TargetPropertyGeneratorExpressions/LinkImplementationCycle4-stderr.txt
index 5cfeb0a..d56b199 100644
--- a/Tests/RunCMake/TargetPropertyGeneratorExpressions/LinkImplementationCycle4-stderr.txt
+++ b/Tests/RunCMake/TargetPropertyGeneratorExpressions/LinkImplementationCycle4-stderr.txt
@@ -1,4 +1,4 @@
-CMake Error:
+^CMake Error at LinkImplementationCycle4.cmake:[0-9]+ \(target_link_libraries\):
Error evaluating generator expression:
\$<TARGET_PROPERTY:INTERFACE_INCLUDE_DIRECTORIES>
@@ -6,3 +6,5 @@ CMake Error:
\$<TARGET_PROPERTY:...> expression in link libraries evaluation depends on
target property which is transitive over the link libraries, creating a
recursion.
+Call Stack \(most recent call first\):
+ CMakeLists.txt:[0-9]+ \(include\)
diff --git a/Tests/RunCMake/TargetPropertyGeneratorExpressions/LinkImplementationCycle5-stderr.txt b/Tests/RunCMake/TargetPropertyGeneratorExpressions/LinkImplementationCycle5-stderr.txt
index 5cfeb0a..cf4e6d7 100644
--- a/Tests/RunCMake/TargetPropertyGeneratorExpressions/LinkImplementationCycle5-stderr.txt
+++ b/Tests/RunCMake/TargetPropertyGeneratorExpressions/LinkImplementationCycle5-stderr.txt
@@ -1,4 +1,4 @@
-CMake Error:
+^CMake Error at LinkImplementationCycle5.cmake:[0-9]+ \(set_property\):
Error evaluating generator expression:
\$<TARGET_PROPERTY:INTERFACE_INCLUDE_DIRECTORIES>
@@ -6,3 +6,5 @@ CMake Error:
\$<TARGET_PROPERTY:...> expression in link libraries evaluation depends on
target property which is transitive over the link libraries, creating a
recursion.
+Call Stack \(most recent call first\):
+ CMakeLists.txt:[0-9]+ \(include\)
diff --git a/Tests/RunCMake/TargetPropertyGeneratorExpressions/LinkImplementationCycle6-stderr.txt b/Tests/RunCMake/TargetPropertyGeneratorExpressions/LinkImplementationCycle6-stderr.txt
index 5cfeb0a..93cb573 100644
--- a/Tests/RunCMake/TargetPropertyGeneratorExpressions/LinkImplementationCycle6-stderr.txt
+++ b/Tests/RunCMake/TargetPropertyGeneratorExpressions/LinkImplementationCycle6-stderr.txt
@@ -1,4 +1,4 @@
-CMake Error:
+^CMake Error at LinkImplementationCycle6.cmake:[0-9]+ \(target_link_libraries\):
Error evaluating generator expression:
\$<TARGET_PROPERTY:INTERFACE_INCLUDE_DIRECTORIES>
@@ -6,3 +6,5 @@ CMake Error:
\$<TARGET_PROPERTY:...> expression in link libraries evaluation depends on
target property which is transitive over the link libraries, creating a
recursion.
+Call Stack \(most recent call first\):
+ CMakeLists.txt:[0-9]+ \(include\)
diff --git a/Tests/RunCMake/find_file/FromPATHEnvDebugVar-stderr.txt b/Tests/RunCMake/find_file/FromPATHEnvDebugVar-stderr.txt
new file mode 100644
index 0000000..38ed98c
--- /dev/null
+++ b/Tests/RunCMake/find_file/FromPATHEnvDebugVar-stderr.txt
@@ -0,0 +1,25 @@
+ find_file called with the following settings:.*
+ VAR: PrefixInPATH_File
+ NAMES: "PrefixInPATH.h"
+ Documentation.*
+ Framework.*
+ AppBundle.*
+ CMAKE_FIND_USE_CMAKE_PATH: 1
+ CMAKE_FIND_USE_CMAKE_ENVIRONMENT_PATH: 1
+ CMAKE_FIND_USE_SYSTEM_ENVIRONMENT_PATH: 0
+ CMAKE_FIND_USE_CMAKE_SYSTEM_PATH: 1
+
+ find_file considered the following locations:.*
+ The item was not found.*
+ find_file called with the following settings:.*
+ VAR: PrefixInPATH_File
+ NAMES: "PrefixInPATH.h"
+ Documentation.*
+ Framework.*
+ AppBundle.*
+ CMAKE_FIND_USE_CMAKE_PATH: 1
+ CMAKE_FIND_USE_CMAKE_ENVIRONMENT_PATH: 1
+ CMAKE_FIND_USE_SYSTEM_ENVIRONMENT_PATH: 0
+ CMAKE_FIND_USE_CMAKE_SYSTEM_PATH: 1
+
+ find_file considered the following locations:.*
diff --git a/Tests/RunCMake/find_file/FromPATHEnvDebugVar-stdout-cygwin.txt b/Tests/RunCMake/find_file/FromPATHEnvDebugVar-stdout-cygwin.txt
new file mode 100644
index 0000000..6912bdf
--- /dev/null
+++ b/Tests/RunCMake/find_file/FromPATHEnvDebugVar-stdout-cygwin.txt
@@ -0,0 +1,9 @@
+-- PrefixInPATH_File='PrefixInPATH_File-NOTFOUND'
+-- PrefixInPATH_File='.*/Tests/RunCMake/find_file/include/PrefixInPATH.h'
+-- PrefixInPATH_File='.*/Tests/RunCMake/find_file/include/PrefixInPATH.h'
+-- PrefixInPATH_File='PrefixInPATH_File-NOTFOUND'
+-- PrefixInPATH_File='PrefixInPATH_File-NOTFOUND'
+-- PrefixInPATH_File='PrefixInPATH_File-NOTFOUND'
+-- PrefixInPATH_File='PrefixInPATH_File-NOTFOUND'
+-- PrefixInPATH_File='PrefixInPATH_File-NOTFOUND'
+-- PrefixInPATH_File='PrefixInPATH_File-NOTFOUND'
diff --git a/Tests/RunCMake/find_file/FromPATHEnvDebugVar-stdout-msys.txt b/Tests/RunCMake/find_file/FromPATHEnvDebugVar-stdout-msys.txt
new file mode 100644
index 0000000..6912bdf
--- /dev/null
+++ b/Tests/RunCMake/find_file/FromPATHEnvDebugVar-stdout-msys.txt
@@ -0,0 +1,9 @@
+-- PrefixInPATH_File='PrefixInPATH_File-NOTFOUND'
+-- PrefixInPATH_File='.*/Tests/RunCMake/find_file/include/PrefixInPATH.h'
+-- PrefixInPATH_File='.*/Tests/RunCMake/find_file/include/PrefixInPATH.h'
+-- PrefixInPATH_File='PrefixInPATH_File-NOTFOUND'
+-- PrefixInPATH_File='PrefixInPATH_File-NOTFOUND'
+-- PrefixInPATH_File='PrefixInPATH_File-NOTFOUND'
+-- PrefixInPATH_File='PrefixInPATH_File-NOTFOUND'
+-- PrefixInPATH_File='PrefixInPATH_File-NOTFOUND'
+-- PrefixInPATH_File='PrefixInPATH_File-NOTFOUND'
diff --git a/Tests/RunCMake/find_file/FromPATHEnvDebugVar-stdout-windows.txt b/Tests/RunCMake/find_file/FromPATHEnvDebugVar-stdout-windows.txt
new file mode 100644
index 0000000..6912bdf
--- /dev/null
+++ b/Tests/RunCMake/find_file/FromPATHEnvDebugVar-stdout-windows.txt
@@ -0,0 +1,9 @@
+-- PrefixInPATH_File='PrefixInPATH_File-NOTFOUND'
+-- PrefixInPATH_File='.*/Tests/RunCMake/find_file/include/PrefixInPATH.h'
+-- PrefixInPATH_File='.*/Tests/RunCMake/find_file/include/PrefixInPATH.h'
+-- PrefixInPATH_File='PrefixInPATH_File-NOTFOUND'
+-- PrefixInPATH_File='PrefixInPATH_File-NOTFOUND'
+-- PrefixInPATH_File='PrefixInPATH_File-NOTFOUND'
+-- PrefixInPATH_File='PrefixInPATH_File-NOTFOUND'
+-- PrefixInPATH_File='PrefixInPATH_File-NOTFOUND'
+-- PrefixInPATH_File='PrefixInPATH_File-NOTFOUND'
diff --git a/Tests/RunCMake/find_file/FromPATHEnvDebugVar-stdout.txt b/Tests/RunCMake/find_file/FromPATHEnvDebugVar-stdout.txt
new file mode 100644
index 0000000..27a83ad
--- /dev/null
+++ b/Tests/RunCMake/find_file/FromPATHEnvDebugVar-stdout.txt
@@ -0,0 +1,9 @@
+-- PrefixInPATH_File='PrefixInPATH_File-NOTFOUND'
+-- PrefixInPATH_File='.*/Tests/RunCMake/find_file/include/PrefixInPATH.h'
+-- PrefixInPATH_File='PrefixInPATH_File-NOTFOUND'
+-- PrefixInPATH_File='PrefixInPATH_File-NOTFOUND'
+-- PrefixInPATH_File='PrefixInPATH_File-NOTFOUND'
+-- PrefixInPATH_File='PrefixInPATH_File-NOTFOUND'
+-- PrefixInPATH_File='PrefixInPATH_File-NOTFOUND'
+-- PrefixInPATH_File='PrefixInPATH_File-NOTFOUND'
+-- PrefixInPATH_File='PrefixInPATH_File-NOTFOUND'
diff --git a/Tests/RunCMake/find_file/FromPATHEnvDebugVar.cmake b/Tests/RunCMake/find_file/FromPATHEnvDebugVar.cmake
new file mode 100644
index 0000000..9f058dd
--- /dev/null
+++ b/Tests/RunCMake/find_file/FromPATHEnvDebugVar.cmake
@@ -0,0 +1,24 @@
+set(ENV_PATH "$ENV{PATH}")
+foreach(path "/does_not_exist" "/include" "")
+ unset(PrefixInPATH_File CACHE)
+ set(ENV{PATH} "${CMAKE_CURRENT_SOURCE_DIR}${path}")
+ find_file(PrefixInPATH_File NAMES PrefixInPATH.h)
+ message(STATUS "PrefixInPATH_File='${PrefixInPATH_File}'")
+endforeach()
+
+set(CMAKE_FIND_USE_SYSTEM_ENVIRONMENT_PATH OFF)
+foreach(path "/does_not_exist" "/include" "")
+ unset(PrefixInPATH_File CACHE)
+ set(ENV{PATH} "${CMAKE_CURRENT_SOURCE_DIR}${path}")
+ find_file(PrefixInPATH_File NAMES PrefixInPATH.h)
+ message(STATUS "PrefixInPATH_File='${PrefixInPATH_File}'")
+endforeach()
+
+set(CMAKE_FIND_USE_SYSTEM_ENVIRONMENT_PATH ON)
+foreach(path "/does_not_exist" "/include" "")
+ unset(PrefixInPATH_File CACHE)
+ set(ENV{PATH} "${CMAKE_CURRENT_SOURCE_DIR}${path}")
+ find_file(PrefixInPATH_File NAMES PrefixInPATH.h NO_SYSTEM_ENVIRONMENT_PATH)
+ message(STATUS "PrefixInPATH_File='${PrefixInPATH_File}'")
+endforeach()
+set(ENV{PATH} "${ENV_PATH}")
diff --git a/Tests/RunCMake/find_file/RunCMakeTest.cmake b/Tests/RunCMake/find_file/RunCMakeTest.cmake
index 95f55a5..c5cd5fa 100644
--- a/Tests/RunCMake/find_file/RunCMakeTest.cmake
+++ b/Tests/RunCMake/find_file/RunCMakeTest.cmake
@@ -5,3 +5,5 @@ run_cmake(FromPrefixPath)
run_cmake(PrefixInPATH)
run_cmake(Required)
run_cmake(NO_CACHE)
+
+run_cmake_with_options(FromPATHEnvDebugVar --debug-find-var=PrefixInPATH_File)
diff --git a/Tests/RunCMake/find_library/FromPATHEnvDebugVar-stderr.txt b/Tests/RunCMake/find_library/FromPATHEnvDebugVar-stderr.txt
new file mode 100644
index 0000000..a690eec
--- /dev/null
+++ b/Tests/RunCMake/find_library/FromPATHEnvDebugVar-stderr.txt
@@ -0,0 +1,28 @@
+ find_library called with the following settings:.*
+ VAR: CREATED_LIBRARY
+ NAMES: \"created\"
+ \"created_no_exist\"
+ Documentation.*
+ Framework.*
+ AppBundle.*
+ CMAKE_FIND_USE_CMAKE_PATH: 1
+ CMAKE_FIND_USE_CMAKE_ENVIRONMENT_PATH: 1
+ CMAKE_FIND_USE_SYSTEM_ENVIRONMENT_PATH: 0
+ CMAKE_FIND_USE_CMAKE_SYSTEM_PATH: 1
+
+ find_library considered the following locations:.*
+ The item was not found.*
+ find_library called with the following settings:.*
+ VAR: CREATED_LIBRARY
+ NAMES: \"created\"
+ Documentation.*
+ Framework.*
+ AppBundle.*
+ CMAKE_FIND_USE_CMAKE_PATH: 1
+ CMAKE_FIND_USE_CMAKE_ENVIRONMENT_PATH: 1
+ CMAKE_FIND_USE_SYSTEM_ENVIRONMENT_PATH: 1
+ CMAKE_FIND_USE_CMAKE_SYSTEM_PATH: 1
+
+ find_library considered the following locations:.*
+ The item was found at.*
+.*lib/libcreated.a
diff --git a/Tests/RunCMake/find_library/FromPATHEnvDebugVar-stdout-cygwin.txt b/Tests/RunCMake/find_library/FromPATHEnvDebugVar-stdout-cygwin.txt
new file mode 100644
index 0000000..48f36cc
--- /dev/null
+++ b/Tests/RunCMake/find_library/FromPATHEnvDebugVar-stdout-cygwin.txt
@@ -0,0 +1,6 @@
+-- CREATED_LIBRARY='CREATED_LIBRARY-NOTFOUND'
+-- CREATED_LIBRARY='[^']*/Tests/RunCMake/find_library/FromPATHEnvDebugVar-build/lib/libcreated.a'
+-- CREATED_LIBRARY='[^']*/Tests/RunCMake/find_library/FromPATHEnvDebugVar-build/lib/libcreated.a'
+-- CREATED_LIBRARY='CREATED_LIBRARY-NOTFOUND'
+-- CREATED_LIBRARY='CREATED_LIBRARY-NOTFOUND'
+-- CREATED_LIBRARY='CREATED_LIBRARY-NOTFOUND'
diff --git a/Tests/RunCMake/find_library/FromPATHEnvDebugVar-stdout-msys.txt b/Tests/RunCMake/find_library/FromPATHEnvDebugVar-stdout-msys.txt
new file mode 100644
index 0000000..48f36cc
--- /dev/null
+++ b/Tests/RunCMake/find_library/FromPATHEnvDebugVar-stdout-msys.txt
@@ -0,0 +1,6 @@
+-- CREATED_LIBRARY='CREATED_LIBRARY-NOTFOUND'
+-- CREATED_LIBRARY='[^']*/Tests/RunCMake/find_library/FromPATHEnvDebugVar-build/lib/libcreated.a'
+-- CREATED_LIBRARY='[^']*/Tests/RunCMake/find_library/FromPATHEnvDebugVar-build/lib/libcreated.a'
+-- CREATED_LIBRARY='CREATED_LIBRARY-NOTFOUND'
+-- CREATED_LIBRARY='CREATED_LIBRARY-NOTFOUND'
+-- CREATED_LIBRARY='CREATED_LIBRARY-NOTFOUND'
diff --git a/Tests/RunCMake/find_library/FromPATHEnvDebugVar-stdout-windows.txt b/Tests/RunCMake/find_library/FromPATHEnvDebugVar-stdout-windows.txt
new file mode 100644
index 0000000..48f36cc
--- /dev/null
+++ b/Tests/RunCMake/find_library/FromPATHEnvDebugVar-stdout-windows.txt
@@ -0,0 +1,6 @@
+-- CREATED_LIBRARY='CREATED_LIBRARY-NOTFOUND'
+-- CREATED_LIBRARY='[^']*/Tests/RunCMake/find_library/FromPATHEnvDebugVar-build/lib/libcreated.a'
+-- CREATED_LIBRARY='[^']*/Tests/RunCMake/find_library/FromPATHEnvDebugVar-build/lib/libcreated.a'
+-- CREATED_LIBRARY='CREATED_LIBRARY-NOTFOUND'
+-- CREATED_LIBRARY='CREATED_LIBRARY-NOTFOUND'
+-- CREATED_LIBRARY='CREATED_LIBRARY-NOTFOUND'
diff --git a/Tests/RunCMake/find_library/FromPATHEnvDebugVar-stdout.txt b/Tests/RunCMake/find_library/FromPATHEnvDebugVar-stdout.txt
new file mode 100644
index 0000000..d6d13fb
--- /dev/null
+++ b/Tests/RunCMake/find_library/FromPATHEnvDebugVar-stdout.txt
@@ -0,0 +1,6 @@
+-- CREATED_LIBRARY='CREATED_LIBRARY-NOTFOUND'
+-- CREATED_LIBRARY='[^']*/Tests/RunCMake/find_library/FromPATHEnvDebugVar-build/lib/libcreated.a'
+-- CREATED_LIBRARY='CREATED_LIBRARY-NOTFOUND'
+-- CREATED_LIBRARY='CREATED_LIBRARY-NOTFOUND'
+-- CREATED_LIBRARY='CREATED_LIBRARY-NOTFOUND'
+-- CREATED_LIBRARY='CREATED_LIBRARY-NOTFOUND'
diff --git a/Tests/RunCMake/find_library/FromPATHEnvDebugVar.cmake b/Tests/RunCMake/find_library/FromPATHEnvDebugVar.cmake
new file mode 100644
index 0000000..c24e640
--- /dev/null
+++ b/Tests/RunCMake/find_library/FromPATHEnvDebugVar.cmake
@@ -0,0 +1,35 @@
+list(APPEND CMAKE_FIND_LIBRARY_PREFIXES lib)
+list(APPEND CMAKE_FIND_LIBRARY_SUFFIXES .a)
+set(ENV_PATH "$ENV{PATH}")
+file(MAKE_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/lib)
+file(WRITE "${CMAKE_CURRENT_BINARY_DIR}/lib/libcreated.a" "created")
+
+set(CMAKE_FIND_DEBUG_MODE 1)
+set(CMAKE_FIND_USE_SYSTEM_ENVIRONMENT_PATH OFF)
+
+set(ENV{PATH} "${CMAKE_CURRENT_BINARY_DIR}/lib")
+find_library(CREATED_LIBRARY NAMES created created_no_exist)
+
+set(CMAKE_FIND_USE_SYSTEM_ENVIRONMENT_PATH ON)
+
+set(ENV{PATH} "${CMAKE_CURRENT_BINARY_DIR}/lib")
+find_library(CREATED_LIBRARY NAMES created)
+set(CMAKE_FIND_DEBUG_MODE 0)
+
+
+foreach(path "/does_not_exist" "/lib" "")
+ unset(CREATED_LIBRARY CACHE)
+ set(ENV{PATH} "${CMAKE_CURRENT_BINARY_DIR}${path}")
+ find_library(CREATED_LIBRARY NAMES created)
+ message(STATUS "CREATED_LIBRARY='${CREATED_LIBRARY}'")
+endforeach()
+
+set(CMAKE_FIND_USE_SYSTEM_ENVIRONMENT_PATH OFF)
+foreach(path "/does_not_exist" "/lib" "")
+ unset(CREATED_LIBRARY CACHE)
+ set(ENV{PATH} "${CMAKE_CURRENT_BINARY_DIR}${path}")
+ find_library(CREATED_LIBRARY NAMES created)
+ message(STATUS "CREATED_LIBRARY='${CREATED_LIBRARY}'")
+endforeach()
+set(CMAKE_FIND_USE_SYSTEM_ENVIRONMENT_PATH ON)
+set(ENV{PATH} "${ENV_PATH}")
diff --git a/Tests/RunCMake/find_library/RunCMakeTest.cmake b/Tests/RunCMake/find_library/RunCMakeTest.cmake
index ad02c82..eaaecf0 100644
--- a/Tests/RunCMake/find_library/RunCMakeTest.cmake
+++ b/Tests/RunCMake/find_library/RunCMakeTest.cmake
@@ -12,3 +12,5 @@ run_cmake(Required)
run_cmake(NO_CACHE)
run_cmake_script(FromScriptMode "-DTEMP_DIR=${RunCMake_BINARY_DIR}/FromScriptMode-temp")
+
+run_cmake_with_options(FromPATHEnvDebugVar --debug-find-var=CREATED_LIBRARY)
diff --git a/Tests/RunCMake/find_package/FromPATHEnvDebugPkg-stderr.txt b/Tests/RunCMake/find_package/FromPATHEnvDebugPkg-stderr.txt
new file mode 100644
index 0000000..94ed178
--- /dev/null
+++ b/Tests/RunCMake/find_package/FromPATHEnvDebugPkg-stderr.txt
@@ -0,0 +1,21 @@
+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
diff --git a/Tests/RunCMake/find_package/FromPATHEnvDebugPkg-stdout.txt b/Tests/RunCMake/find_package/FromPATHEnvDebugPkg-stdout.txt
new file mode 100644
index 0000000..31e4dd2
--- /dev/null
+++ b/Tests/RunCMake/find_package/FromPATHEnvDebugPkg-stdout.txt
@@ -0,0 +1,9 @@
+-- Resolved_FOUND='0'
+-- Resolved_FOUND='0'
+-- Resolved_FOUND='0'
+-- Resolved_FOUND='0'
+-- Resolved_FOUND='0'
+-- Resolved_FOUND='0'
+-- Resolved_FOUND='0'
+-- Resolved_FOUND='0'
+-- Resolved_FOUND='0'
diff --git a/Tests/RunCMake/find_package/FromPATHEnvDebugPkg.cmake b/Tests/RunCMake/find_package/FromPATHEnvDebugPkg.cmake
new file mode 100644
index 0000000..0ed8a12
--- /dev/null
+++ b/Tests/RunCMake/find_package/FromPATHEnvDebugPkg.cmake
@@ -0,0 +1,31 @@
+set(ENV_PATH "$ENV{PATH}")
+
+set(ENV{PATH} "${CMAKE_CURRENT_SOURCE_DIR}/PackageRoot")
+find_package(Resolved QUIET)
+
+foreach(path "/does_not_exist" "/PackageRoot" "")
+ unset(ResolvedA_FOUND CACHE)
+ set(ResolvedA_DIR "")
+ set(ENV{PATH} "${CMAKE_CURRENT_SOURCE_DIR}${path}")
+ find_package(ResolvedA QUIET)
+ message(STATUS "Resolved_FOUND='${ResolvedA_FOUND}'")
+endforeach()
+
+set(CMAKE_FIND_USE_SYSTEM_ENVIRONMENT_PATH OFF)
+foreach(path "/does_not_exist" "/PackageRoot" "")
+ unset(Resolved_FOUND CACHE)
+ set(Resolved_DIR "")
+ set(ENV{PATH} "${CMAKE_CURRENT_SOURCE_DIR}${path}")
+ find_package(ResolvedB QUIET)
+ message(STATUS "Resolved_FOUND='${ResolvedB_FOUND}'")
+endforeach()
+
+set(CMAKE_FIND_USE_SYSTEM_ENVIRONMENT_PATH ON)
+foreach(path "/does_not_exist" "/PackageRoot" "")
+ unset(Resolved_FOUND CACHE)
+ set(Resolved_DIR "")
+ set(ENV{PATH} "${CMAKE_CURRENT_SOURCE_DIR}${path}")
+ find_package(ResolvedC NO_SYSTEM_ENVIRONMENT_PATH QUIET)
+ message(STATUS "Resolved_FOUND='${ResolvedC_FOUND}'")
+endforeach()
+set(ENV{PATH} "${ENV_PATH}")
diff --git a/Tests/RunCMake/find_package/MissingConfigDebugPkg-stderr.txt b/Tests/RunCMake/find_package/MissingConfigDebugPkg-stderr.txt
new file mode 100644
index 0000000..54cf14b
--- /dev/null
+++ b/Tests/RunCMake/find_package/MissingConfigDebugPkg-stderr.txt
@@ -0,0 +1,20 @@
+ <PackageName>_ROOT CMake variable.*
+ CMAKE_PREFIX_PATH variable.*
+ CMAKE_FRAMEWORK_PATH and CMAKE_APPBUNDLE_PATH variables.*
+ Env variable NotHere_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.*
+ CMake User Package Registry.*
+ CMake variables defined in the Platform file.*
+ CMake System Package Registry.*
+ Paths specified by the find_package PATHS option.*
+.*
+ .*NotHereConfig.cmake
+ .*nothere-config.cmake
+.*
+CMake Warning at MissingConfigDebugPkg.cmake:2 \(message\):
+ This warning must be reachable.
+Call Stack \(most recent call first\):
+ CMakeLists.txt:3 \(include\)$
diff --git a/Tests/RunCMake/find_package/MissingConfigDebugPkg.cmake b/Tests/RunCMake/find_package/MissingConfigDebugPkg.cmake
new file mode 100644
index 0000000..238e7e4
--- /dev/null
+++ b/Tests/RunCMake/find_package/MissingConfigDebugPkg.cmake
@@ -0,0 +1,2 @@
+find_package(NotHere CONFIG)
+message(WARNING "This warning must be reachable.")
diff --git a/Tests/RunCMake/find_package/RunCMakeTest.cmake b/Tests/RunCMake/find_package/RunCMakeTest.cmake
index ad9757d..2bace98 100644
--- a/Tests/RunCMake/find_package/RunCMakeTest.cmake
+++ b/Tests/RunCMake/find_package/RunCMakeTest.cmake
@@ -49,3 +49,6 @@ 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/find_path/FromPATHEnvDebugVar-stderr.txt b/Tests/RunCMake/find_path/FromPATHEnvDebugVar-stderr.txt
new file mode 100644
index 0000000..088efd5
--- /dev/null
+++ b/Tests/RunCMake/find_path/FromPATHEnvDebugVar-stderr.txt
@@ -0,0 +1,27 @@
+ find_path called with the following settings:.*
+ VAR: PATH_IN_ENV_PATH
+ NAMES: \"PrefixInPATH\.h\"
+ Documentation.*
+ Framework.*
+ AppBundle.*
+ CMAKE_FIND_USE_CMAKE_PATH: 1
+ CMAKE_FIND_USE_CMAKE_ENVIRONMENT_PATH: 1
+ CMAKE_FIND_USE_SYSTEM_ENVIRONMENT_PATH: 0
+ CMAKE_FIND_USE_CMAKE_SYSTEM_PATH: 1
+
+ find_path considered the following locations:.*
+ The item was not found.*
+ find_path called with the following settings:.*
+ VAR: PATH_IN_ENV_PATH
+ NAMES: \"PrefixInPATH\.h\"
+ Documentation.*
+ Framework.*
+ AppBundle.*
+ CMAKE_FIND_USE_CMAKE_PATH: 1
+ CMAKE_FIND_USE_CMAKE_ENVIRONMENT_PATH: 1
+ CMAKE_FIND_USE_SYSTEM_ENVIRONMENT_PATH: 1
+ CMAKE_FIND_USE_CMAKE_SYSTEM_PATH: 1
+
+ find_path considered the following locations:.*
+ The item was found at.*
+.*include/PrefixInPATH.*
diff --git a/Tests/RunCMake/find_path/FromPATHEnvDebugVar-stdout-cygwin.txt b/Tests/RunCMake/find_path/FromPATHEnvDebugVar-stdout-cygwin.txt
new file mode 100644
index 0000000..a502d78
--- /dev/null
+++ b/Tests/RunCMake/find_path/FromPATHEnvDebugVar-stdout-cygwin.txt
@@ -0,0 +1,9 @@
+-- PATH_IN_ENV_PATH='PATH_IN_ENV_PATH_A-NOTFOUND'
+-- PATH_IN_ENV_PATH='.*/Tests/RunCMake/find_path/include'
+-- PATH_IN_ENV_PATH='.*/Tests/RunCMake/find_path/include'
+-- PATH_IN_ENV_PATH='PATH_IN_ENV_PATH_A-NOTFOUND'
+-- PATH_IN_ENV_PATH='PATH_IN_ENV_PATH_A-NOTFOUND'
+-- PATH_IN_ENV_PATH='PATH_IN_ENV_PATH_A-NOTFOUND'
+-- PATH_IN_ENV_PATH=''
+-- PATH_IN_ENV_PATH=''
+-- PATH_IN_ENV_PATH=''
diff --git a/Tests/RunCMake/find_path/FromPATHEnvDebugVar-stdout-msys.txt b/Tests/RunCMake/find_path/FromPATHEnvDebugVar-stdout-msys.txt
new file mode 100644
index 0000000..a502d78
--- /dev/null
+++ b/Tests/RunCMake/find_path/FromPATHEnvDebugVar-stdout-msys.txt
@@ -0,0 +1,9 @@
+-- PATH_IN_ENV_PATH='PATH_IN_ENV_PATH_A-NOTFOUND'
+-- PATH_IN_ENV_PATH='.*/Tests/RunCMake/find_path/include'
+-- PATH_IN_ENV_PATH='.*/Tests/RunCMake/find_path/include'
+-- PATH_IN_ENV_PATH='PATH_IN_ENV_PATH_A-NOTFOUND'
+-- PATH_IN_ENV_PATH='PATH_IN_ENV_PATH_A-NOTFOUND'
+-- PATH_IN_ENV_PATH='PATH_IN_ENV_PATH_A-NOTFOUND'
+-- PATH_IN_ENV_PATH=''
+-- PATH_IN_ENV_PATH=''
+-- PATH_IN_ENV_PATH=''
diff --git a/Tests/RunCMake/find_path/FromPATHEnvDebugVar-stdout-windows.txt b/Tests/RunCMake/find_path/FromPATHEnvDebugVar-stdout-windows.txt
new file mode 100644
index 0000000..a502d78
--- /dev/null
+++ b/Tests/RunCMake/find_path/FromPATHEnvDebugVar-stdout-windows.txt
@@ -0,0 +1,9 @@
+-- PATH_IN_ENV_PATH='PATH_IN_ENV_PATH_A-NOTFOUND'
+-- PATH_IN_ENV_PATH='.*/Tests/RunCMake/find_path/include'
+-- PATH_IN_ENV_PATH='.*/Tests/RunCMake/find_path/include'
+-- PATH_IN_ENV_PATH='PATH_IN_ENV_PATH_A-NOTFOUND'
+-- PATH_IN_ENV_PATH='PATH_IN_ENV_PATH_A-NOTFOUND'
+-- PATH_IN_ENV_PATH='PATH_IN_ENV_PATH_A-NOTFOUND'
+-- PATH_IN_ENV_PATH=''
+-- PATH_IN_ENV_PATH=''
+-- PATH_IN_ENV_PATH=''
diff --git a/Tests/RunCMake/find_path/FromPATHEnvDebugVar-stdout.txt b/Tests/RunCMake/find_path/FromPATHEnvDebugVar-stdout.txt
new file mode 100644
index 0000000..0d2389d
--- /dev/null
+++ b/Tests/RunCMake/find_path/FromPATHEnvDebugVar-stdout.txt
@@ -0,0 +1,9 @@
+-- PATH_IN_ENV_PATH='PATH_IN_ENV_PATH_A-NOTFOUND'
+-- PATH_IN_ENV_PATH='.*/Tests/RunCMake/find_path/include'
+-- PATH_IN_ENV_PATH='PATH_IN_ENV_PATH_A-NOTFOUND'
+-- PATH_IN_ENV_PATH='PATH_IN_ENV_PATH_A-NOTFOUND'
+-- PATH_IN_ENV_PATH='PATH_IN_ENV_PATH_A-NOTFOUND'
+-- PATH_IN_ENV_PATH='PATH_IN_ENV_PATH_A-NOTFOUND'
+-- PATH_IN_ENV_PATH=''
+-- PATH_IN_ENV_PATH=''
+-- PATH_IN_ENV_PATH=''
diff --git a/Tests/RunCMake/find_path/FromPATHEnvDebugVar.cmake b/Tests/RunCMake/find_path/FromPATHEnvDebugVar.cmake
new file mode 100644
index 0000000..4c83151
--- /dev/null
+++ b/Tests/RunCMake/find_path/FromPATHEnvDebugVar.cmake
@@ -0,0 +1,35 @@
+set(ENV_PATH "$ENV{PATH}")
+
+set(CMAKE_FIND_USE_SYSTEM_ENVIRONMENT_PATH OFF)
+
+set(ENV{PATH} "${CMAKE_CURRENT_SOURCE_DIR}/include")
+find_path(PATH_IN_ENV_PATH NAMES PrefixInPATH.h)
+
+set(CMAKE_FIND_USE_SYSTEM_ENVIRONMENT_PATH ON)
+find_path(PATH_IN_ENV_PATH NAMES PrefixInPATH.h)
+
+
+foreach(path "/does_not_exist" "/include" "")
+ unset(PATH_IN_ENV_PATH_A CACHE)
+ set(ENV{PATH} "${CMAKE_CURRENT_SOURCE_DIR}${path}")
+ find_path(PATH_IN_ENV_PATH_A NAMES PrefixInPATH.h)
+ message(STATUS "PATH_IN_ENV_PATH='${PATH_IN_ENV_PATH_A}'")
+endforeach()
+
+set(CMAKE_FIND_USE_SYSTEM_ENVIRONMENT_PATH OFF)
+foreach(path "/does_not_exist" "/include" "")
+ unset(PATH_IN_ENV_PATH_A CACHE)
+ set(ENV{PATH} "${CMAKE_CURRENT_SOURCE_DIR}${path}")
+ find_path(PATH_IN_ENV_PATH_A NAMES PrefixInPATH.h)
+ message(STATUS "PATH_IN_ENV_PATH='${PATH_IN_ENV_PATH_A}'")
+endforeach()
+
+set(CMAKE_FIND_USE_SYSTEM_ENVIRONMENT_PATH ON)
+foreach(path "/does_not_exist" "/include" "")
+ unset(PATH_IN_ENV_PATH_A CACHE)
+ set(ENV{PATH} "${CMAKE_CURRENT_SOURCE_DIR}${path}")
+ find_path(PATH_IN_ENV_PAT_H_A NAMES PrefixInPATH.h NO_SYSTEM_ENVIRONMENT_PATH)
+ message(STATUS "PATH_IN_ENV_PATH='${PATH_IN_ENV_PATH_A}'")
+endforeach()
+
+set(ENV{PATH} "${ENV_PATH}")
diff --git a/Tests/RunCMake/find_path/RunCMakeTest.cmake b/Tests/RunCMake/find_path/RunCMakeTest.cmake
index 90ee768..5b52f90 100644
--- a/Tests/RunCMake/find_path/RunCMakeTest.cmake
+++ b/Tests/RunCMake/find_path/RunCMakeTest.cmake
@@ -9,3 +9,5 @@ run_cmake(NO_CACHE)
if(APPLE)
run_cmake(FrameworksWithSubdirs)
endif()
+
+run_cmake_with_options(FromPATHEnvDebugVar --debug-find-var=PATH_IN_ENV_PATH)
diff --git a/Tests/RunCMake/find_program/EnvAndHintsDebugVar-stderr.txt b/Tests/RunCMake/find_program/EnvAndHintsDebugVar-stderr.txt
new file mode 100644
index 0000000..8951345
--- /dev/null
+++ b/Tests/RunCMake/find_program/EnvAndHintsDebugVar-stderr.txt
@@ -0,0 +1,28 @@
+ find_program called with the following settings:.*
+ VAR: PROG
+ NAMES: \"testAandB\"
+ Documentation.*
+ Framework.*
+ AppBundle.*
+ CMAKE_FIND_USE_CMAKE_PATH: 1
+ CMAKE_FIND_USE_CMAKE_ENVIRONMENT_PATH: 1
+ CMAKE_FIND_USE_SYSTEM_ENVIRONMENT_PATH: 1
+ CMAKE_FIND_USE_CMAKE_SYSTEM_PATH: 1
+
+ find_program considered the following locations:.*
+ The item was found at.*
+.*testAandB
+.*
+ find_program called with the following settings:.*
+ VAR: PROG
+ NAMES: \"testAandB\"
+ Documentation.*
+ Framework.*
+ AppBundle.*
+ CMAKE_FIND_USE_CMAKE_PATH: 1
+ CMAKE_FIND_USE_CMAKE_ENVIRONMENT_PATH: 1
+ CMAKE_FIND_USE_SYSTEM_ENVIRONMENT_PATH: 0
+ CMAKE_FIND_USE_CMAKE_SYSTEM_PATH: 1
+
+ find_program considered the following locations:.*
+ The item was not found.*
diff --git a/Tests/RunCMake/find_program/EnvAndHintsDebugVar-stdout.txt b/Tests/RunCMake/find_program/EnvAndHintsDebugVar-stdout.txt
new file mode 100644
index 0000000..0051636
--- /dev/null
+++ b/Tests/RunCMake/find_program/EnvAndHintsDebugVar-stdout.txt
@@ -0,0 +1,4 @@
+-- PROG='[^']*/Tests/RunCMake/find_program/A/testAandB'
+-- PROG='PROG-NOTFOUND'
+-- PROG='[^']*/Tests/RunCMake/find_program/B/testAandB'
+-- PROG='[^']*/Tests/RunCMake/find_program/A/testAandB'
diff --git a/Tests/RunCMake/find_program/EnvAndHintsDebugVar.cmake b/Tests/RunCMake/find_program/EnvAndHintsDebugVar.cmake
new file mode 100644
index 0000000..2978fea
--- /dev/null
+++ b/Tests/RunCMake/find_program/EnvAndHintsDebugVar.cmake
@@ -0,0 +1,31 @@
+
+set(ENV_PATH "$ENV{PATH}")
+set(ENV{PATH} ${CMAKE_CURRENT_SOURCE_DIR}/A)
+find_program(PROG
+ NAMES testAandB
+ )
+message(STATUS "PROG='${PROG}'")
+unset(PROG CACHE)
+
+set(CMAKE_FIND_USE_SYSTEM_ENVIRONMENT_PATH OFF)
+find_program(PROG
+ NAMES testAandB
+ )
+message(STATUS "PROG='${PROG}'")
+unset(PROG CACHE)
+
+find_program(PROG_A
+ NAMES testAandB
+ HINTS ${CMAKE_CURRENT_SOURCE_DIR}/B ${CMAKE_CURRENT_SOURCE_DIR}/A
+ )
+message(STATUS "PROG='${PROG_A}'")
+unset(PROG_A CACHE)
+set(ENV{PATH} "${ENV_PATH}")
+
+find_program(PROG_A
+ NAMES testAandB
+ HINTS ${CMAKE_CURRENT_SOURCE_DIR}/A ${CMAKE_CURRENT_SOURCE_DIR}/B
+ )
+message(STATUS "PROG='${PROG_A}'")
+unset(PROG_A CACHE)
+set(ENV{PATH} "${ENV_PATH}")
diff --git a/Tests/RunCMake/find_program/RunCMakeTest.cmake b/Tests/RunCMake/find_program/RunCMakeTest.cmake
index 34edc19..2a1dae4 100644
--- a/Tests/RunCMake/find_program/RunCMakeTest.cmake
+++ b/Tests/RunCMake/find_program/RunCMakeTest.cmake
@@ -27,3 +27,5 @@ endif()
if(APPLE)
run_cmake(BundleSpaceInName)
endif()
+
+run_cmake_with_options(EnvAndHintsDebugVar --debug-find-var=PROG)
diff --git a/Tests/RunCMake/list/LIST-nonexistent.cmake b/Tests/RunCMake/list/LIST-nonexistent.cmake
new file mode 100644
index 0000000..ee88548
--- /dev/null
+++ b/Tests/RunCMake/list/LIST-nonexistent.cmake
@@ -0,0 +1,45 @@
+# Various list operations should treat non-existent variables as empty
+# - APPEND
+# - PREPEND
+# - INSERT (only valid index is 0)
+set(nex_l0 "")
+list(APPEND nex_l0 a)
+list(APPEND nex_l0 b)
+if(NOT nex_l0 STREQUAL "a;b")
+ message(FATAL_ERROR "a;b expected, got ${nex_l0}")
+endif()
+
+unset(nex_l1)
+list(APPEND nex_l1 c)
+list(APPEND nex_l1 d)
+if(NOT nex_l1 STREQUAL "c;d")
+ message(FATAL_ERROR "c;d expected, got ${nex_l1}")
+endif()
+
+set(nex_l2 "")
+list(PREPEND nex_l2 E)
+list(PREPEND nex_l2 f)
+if(NOT nex_l2 STREQUAL "f;E")
+ message(FATAL_ERROR "f;E expected, got ${nex_l2}")
+endif()
+
+unset(nex_l3)
+list(PREPEND nex_l3 hi)
+list(PREPEND nex_l3 G)
+if(NOT nex_l3 STREQUAL "G;hi")
+ message(FATAL_ERROR "G;hi expected, got ${nex_l3}")
+endif()
+
+set(nex_l4 "")
+list(INSERT nex_l4 0 j)
+list(INSERT nex_l4 0 kl)
+if(NOT nex_l4 STREQUAL "kl;j")
+ message(FATAL_ERROR "kl;j expected, got ${nex_l4}")
+endif()
+
+unset(nex_l5)
+list(INSERT nex_l5 0 M)
+list(INSERT nex_l5 0 noP)
+if(NOT nex_l5 STREQUAL "noP;M")
+ message(FATAL_ERROR "noP;M expected, got ${nex_l5}")
+endif()
diff --git a/Tests/RunCMake/list/RunCMakeTest.cmake b/Tests/RunCMake/list/RunCMakeTest.cmake
index eb43ee0..adfe255 100644
--- a/Tests/RunCMake/list/RunCMakeTest.cmake
+++ b/Tests/RunCMake/list/RunCMakeTest.cmake
@@ -116,3 +116,6 @@ run_cmake(POP_FRONT-NoArgs)
# Successful tests
run_cmake(POP_BACK)
run_cmake(POP_FRONT)
+
+# Nonexistent variables treated as empty
+run_cmake(LIST-nonexistent)
diff --git a/Tests/RunCMake/target_link_libraries/CMP0079-link-NEW-bogus-stderr.txt b/Tests/RunCMake/target_link_libraries/CMP0079-link-NEW-bogus-stderr.txt
index 9e38bec..488ae8d 100644
--- a/Tests/RunCMake/target_link_libraries/CMP0079-link-NEW-bogus-stderr.txt
+++ b/Tests/RunCMake/target_link_libraries/CMP0079-link-NEW-bogus-stderr.txt
@@ -1,6 +1,12 @@
-^CMake Error at CMP0079-link-NEW-bogus.cmake:[0-9]+ \(add_executable\):
- Target "top" links to target "::@\(0xdeadbeef\)" but the target was not
- found. Perhaps a find_package\(\) call is missing for an IMPORTED target, or
- an ALIAS target is missing\?
+^CMake Error at CMP0079-link-NEW-bogus\.cmake:6 \(set_property\):
+ Target "top" links to:
+
+ ::@\(0xdeadbeef\)
+
+ but the target was not found. Possible reasons include:
+(
+ \*[^
+]+)*
+
Call Stack \(most recent call first\):
CMakeLists\.txt:[0-9]+ \(include\)
diff --git a/Tests/RunCMake/target_link_libraries/ConfigCase-stderr.txt b/Tests/RunCMake/target_link_libraries/ConfigCase-stderr.txt
index 953c972..ad48fd0 100644
--- a/Tests/RunCMake/target_link_libraries/ConfigCase-stderr.txt
+++ b/Tests/RunCMake/target_link_libraries/ConfigCase-stderr.txt
@@ -1,13 +1,25 @@
-^CMake Error at ConfigCase.cmake:[0-9]+ \(add_library\):
- Target "impl" links to target "config::impl-Debug" but the target was not
- found. Perhaps a find_package\(\) call is missing for an IMPORTED target, or
- an ALIAS target is missing\?
+^CMake Error at ConfigCase\.cmake:4 \(target_link_libraries\):
+ The link interface of target "iface" contains:
+
+ config::iface-Debug
+
+ but the target was not found. Possible reasons include:
+(
+ \*[^
+]+)*
+
Call Stack \(most recent call first\):
- CMakeLists.txt:[0-9]+ \(include\)
+ CMakeLists\.txt:[0-9]+ \(include\)
+
-CMake Error at ConfigCase.cmake:[0-9]+ \(add_library\):
- Target "impl" links to target "config::iface-Debug" but the target was not
- found. Perhaps a find_package\(\) call is missing for an IMPORTED target, or
- an ALIAS target is missing\?
+CMake Error at ConfigCase\.cmake:6 \(target_link_libraries\):
+ Target "impl" links to:
+
+ config::impl-Debug
+
+ but the target was not found. Possible reasons include:
+(
+ \*[^
+]+)*
+
Call Stack \(most recent call first\):
- CMakeLists.txt:[0-9]+ \(include\)
+ CMakeLists\.txt:[0-9]+ \(include\)