summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--.gitlab-ci.yml16
-rwxr-xr-x.gitlab/ci/clang.ps110
-rwxr-xr-x.gitlab/ci/cmake.ps16
-rwxr-xr-x.gitlab/ci/cmake.sh8
-rw-r--r--Help/command/add_custom_command.rst10
-rw-r--r--Help/command/add_custom_target.rst5
-rw-r--r--Help/command/find_package.rst27
-rw-r--r--Help/command/target_sources.rst2
-rw-r--r--Help/manual/cmake-policies.7.rst1
-rw-r--r--Help/policy/CMP0154.rst53
-rw-r--r--Help/release/dev/fileset-private-dep.rst7
-rw-r--r--Help/variable/CMAKE_SIZEOF_VOID_P.rst4
-rw-r--r--Modules/FindJNI.cmake153
-rw-r--r--Modules/FindJava.cmake19
-rw-r--r--Modules/Platform/Apple-Clang.cmake4
-rw-r--r--Modules/Platform/Apple-GNU.cmake3
-rw-r--r--Source/CMakeVersion.cmake2
-rw-r--r--Source/cmGlobalNinjaGenerator.cxx14
-rw-r--r--Source/cmGlobalNinjaGenerator.h6
-rw-r--r--Source/cmNinjaTargetGenerator.cxx94
-rw-r--r--Source/cmNinjaTargetGenerator.h2
-rw-r--r--Source/cmPolicies.h9
-rw-r--r--Source/cmTarget.cxx5
-rw-r--r--Source/cmTarget.h2
-rw-r--r--Tests/RunCMake/CMakeLists.txt3
-rw-r--r--Tests/RunCMake/NinjaPrivateDeps/CMP0154-NEW-Build-EmptyFileSet-Source-check.cmake3
-rw-r--r--Tests/RunCMake/NinjaPrivateDeps/CMP0154-NEW-Build-EmptyFileSet-check.cmake3
-rw-r--r--Tests/RunCMake/NinjaPrivateDeps/CMP0154-NEW-Build-NoFileSet-Source-check.cmake3
-rw-r--r--Tests/RunCMake/NinjaPrivateDeps/CMP0154-NEW-Build-PrivateFileSet-Source-check.cmake3
-rw-r--r--Tests/RunCMake/NinjaPrivateDeps/CMP0154-NEW-Build-PrivateFileSet-check.cmake3
-rw-r--r--Tests/RunCMake/NinjaPrivateDeps/CMP0154-NEW-Build-PublicFileSet-Source-check.cmake3
-rw-r--r--Tests/RunCMake/NinjaPrivateDeps/CMP0154-NEW.cmake2
-rw-r--r--Tests/RunCMake/NinjaPrivateDeps/CMP0154-OLD-Build-EmptyFileSet-Source-check.cmake3
-rw-r--r--Tests/RunCMake/NinjaPrivateDeps/CMP0154-OLD-Build-PrivateFileSet-Source-check.cmake3
-rw-r--r--Tests/RunCMake/NinjaPrivateDeps/CMP0154-OLD.cmake2
-rw-r--r--Tests/RunCMake/NinjaPrivateDeps/CMP0154-common.cmake45
-rw-r--r--Tests/RunCMake/NinjaPrivateDeps/CMakeLists.txt3
-rw-r--r--Tests/RunCMake/NinjaPrivateDeps/RunCMakeTest.cmake30
-rw-r--r--Tests/RunCMake/NinjaPrivateDeps/header.h.in0
-rw-r--r--Tests/RunCMake/NinjaPrivateDeps/hello.cpp6
-rw-r--r--Tests/RunCMake/NinjaPrivateDeps/hello_lib.cpp8
-rw-r--r--Tests/RunCMake/NinjaPrivateDeps/hello_lib.h1
-rw-r--r--Tests/RunCMake/NinjaPrivateDeps/source.cpp.in0
-rw-r--r--Tests/RunCMake/TargetPolicies/PolicyList-stderr.txt1
44 files changed, 453 insertions, 134 deletions
diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml
index 7a66494..39a73a3 100644
--- a/.gitlab-ci.yml
+++ b/.gitlab-ci.yml
@@ -1157,7 +1157,7 @@ t:windows-borland5.8:
variables:
CMAKE_CI_JOB_NIGHTLY: "true"
-t:windows-clang16.0-cl-ninja:
+t:windows-clang17.0-cl-ninja:
extends:
- .windows_clang_ninja
- .cmake_test_windows_external
@@ -1169,10 +1169,10 @@ t:windows-clang16.0-cl-ninja:
needs:
- t:windows-vs2022-x64-ninja
variables:
- CMAKE_CI_BUILD_NAME: windows_clang16.0_cl_ninja
+ CMAKE_CI_BUILD_NAME: windows_clang17.0_cl_ninja
CMAKE_CI_JOB_NIGHTLY: "true"
-t:windows-clang16.0-cl-nmake:
+t:windows-clang17.0-cl-nmake:
extends:
- .windows_clang_nmake
- .cmake_test_windows_external
@@ -1184,10 +1184,10 @@ t:windows-clang16.0-cl-nmake:
needs:
- t:windows-vs2022-x64-ninja
variables:
- CMAKE_CI_BUILD_NAME: windows_clang16.0_cl_nmake
+ CMAKE_CI_BUILD_NAME: windows_clang17.0_cl_nmake
CMAKE_CI_JOB_NIGHTLY: "true"
-t:windows-clang16.0-gnu-ninja:
+t:windows-clang17.0-gnu-ninja:
extends:
- .windows_clang_ninja
- .cmake_test_windows_external
@@ -1199,10 +1199,10 @@ t:windows-clang16.0-gnu-ninja:
needs:
- t:windows-vs2022-x64-ninja
variables:
- CMAKE_CI_BUILD_NAME: windows_clang16.0_gnu_ninja
+ CMAKE_CI_BUILD_NAME: windows_clang17.0_gnu_ninja
CMAKE_CI_JOB_NIGHTLY: "true"
-t:windows-clang16.0-gnu-nmake:
+t:windows-clang17.0-gnu-nmake:
extends:
- .windows_clang_nmake
- .cmake_test_windows_external
@@ -1214,7 +1214,7 @@ t:windows-clang16.0-gnu-nmake:
needs:
- t:windows-vs2022-x64-ninja
variables:
- CMAKE_CI_BUILD_NAME: windows_clang16.0_gnu_nmake
+ CMAKE_CI_BUILD_NAME: windows_clang17.0_gnu_nmake
CMAKE_CI_JOB_NIGHTLY: "true"
t:windows-intel2021.9.0-ninja:
diff --git a/.gitlab/ci/clang.ps1 b/.gitlab/ci/clang.ps1
index 1fc8d8e..e455ebc 100755
--- a/.gitlab/ci/clang.ps1
+++ b/.gitlab/ci/clang.ps1
@@ -1,10 +1,10 @@
$erroractionpreference = "stop"
-if ("$env:CMAKE_CI_BUILD_NAME".Contains("clang16.0")) {
- # LLVM/Clang 16.0
- # https://github.com/llvm/llvm-project/releases/tag/llvmorg-16.0.0
- $filename = "llvm-16.0.0-win-x86_64-1"
- $sha256sum = "13F48356BA5892A82E8BB25EB283FDDAA8F23A0F209B6BF6525D2C5E1285B950"
+if ("$env:CMAKE_CI_BUILD_NAME".Contains("clang17.0")) {
+ # LLVM/Clang 17.0.1
+ # https://github.com/llvm/llvm-project/releases/tag/llvmorg-17.0.1
+ $filename = "llvm-17.0.1-win-x86_64-1"
+ $sha256sum = "803F5D7291219BE60D2EE69CE8882341F94A8707A214DED190614895B6996F55"
} else {
throw ('unknown CMAKE_CI_BUILD_NAME: ' + "$env:CMAKE_CI_BUILD_NAME")
}
diff --git a/.gitlab/ci/cmake.ps1 b/.gitlab/ci/cmake.ps1
index 3efb67a..f6b5cc7 100755
--- a/.gitlab/ci/cmake.ps1
+++ b/.gitlab/ci/cmake.ps1
@@ -1,12 +1,12 @@
$erroractionpreference = "stop"
-$version = "3.24.1"
+$version = "3.27.6"
if ("$env:PROCESSOR_ARCHITECTURE" -eq "AMD64") {
- $sha256sum = "C1B17431A16337D517F7BA78C7067B6F143A12686CB8087F3DD32F3FA45F5AAE"
+ $sha256sum = "F013A0CCA091AA953F9A60A99292EC7A20AE3F9CEB05CB5C08EBE164097C526F"
$platform = "windows-x86_64"
} elseif ("$env:PROCESSOR_ARCHITECTURE" -eq "ARM64") {
- $sha256sum = "D94683F3B0E63F6EF194C621194F6E26F3735EDA70750395E0F2BBEE4023FB95"
+ $sha256sum = "980B7E532D77BFB4E5814C76403242C503019F1C0699440220CF2D527C8FF350"
$platform = "windows-arm64"
} else {
throw ('unknown PROCESSOR_ARCHITECTURE: ' + "$env:PROCESSOR_ARCHITECTURE")
diff --git a/.gitlab/ci/cmake.sh b/.gitlab/ci/cmake.sh
index 137da06..21da466b 100755
--- a/.gitlab/ci/cmake.sh
+++ b/.gitlab/ci/cmake.sh
@@ -2,22 +2,22 @@
set -e
-readonly version="3.24.1"
+readonly version="3.27.6"
case "$(uname -s)-$(uname -m)" in
Linux-x86_64)
shatool="sha256sum"
- sha256sum="827bf068cfaa23a9fb95f990c9f8a7ed8f2caeb3af62b5c0a2fed7a8dd6dde3e"
+ sha256sum="26373a283daa8490d772dc8a179450cd6d391cb2a9db8d4242fe09e361efc42e"
platform="linux-x86_64"
;;
Linux-aarch64)
shatool="sha256sum"
- sha256sum="d50c40135df667ed659f8e4eb7cf7d53421250304f7b3e1a70af9cf3d0f2ab18"
+ sha256sum="811e5040ad7f3fb4924a875373d2a1a174a01400233a81a638a989157438a5e3"
platform="linux-aarch64"
;;
Darwin-*)
shatool="shasum -a 256"
- sha256sum="71bb8db69826d74c395a3c3bbf8b773dbe9f54a2c7331266ba70da303e9c97a1"
+ sha256sum="a66b497289ab8c769b601d93833448eaae985beb762993837a51a79916d12f23"
platform="macos-universal"
;;
*)
diff --git a/Help/command/add_custom_command.rst b/Help/command/add_custom_command.rst
index 1fcf06c..5fe4326 100644
--- a/Help/command/add_custom_command.rst
+++ b/Help/command/add_custom_command.rst
@@ -87,6 +87,11 @@ The options are:
:ref:`Target-dependent expressions <Target-Dependent Queries>` are not
permitted.
+ .. versionchanged:: 3.28
+ In targets using :ref:`file sets`, custom command byproducts are now
+ considered private unless they are listed in a non-private file set.
+ See policy :policy:`CMP0154`.
+
``COMMAND``
Specify the command-line(s) to execute at build time.
If more than one ``COMMAND`` is specified they will be executed in order,
@@ -270,6 +275,11 @@ The options are:
:ref:`Target-dependent expressions <Target-Dependent Queries>` are not
permitted.
+ .. versionchanged:: 3.28
+ In targets using :ref:`file sets`, custom command outputs are now
+ considered private unless they are listed in a non-private file set.
+ See policy :policy:`CMP0154`.
+
``USES_TERMINAL``
.. versionadded:: 3.2
diff --git a/Help/command/add_custom_target.rst b/Help/command/add_custom_target.rst
index ef0c8d9..0385a93 100644
--- a/Help/command/add_custom_target.rst
+++ b/Help/command/add_custom_target.rst
@@ -63,6 +63,11 @@ The options are:
:ref:`Target-dependent expressions <Target-Dependent Queries>` are not
permitted.
+ .. versionchanged:: 3.28
+ In custom targets using :ref:`file sets`, byproducts are now
+ considered private unless they are listed in a non-private file set.
+ See policy :policy:`CMP0154`.
+
``COMMAND``
Specify the command-line(s) to execute at build time.
If more than one ``COMMAND`` is specified they will be executed in order,
diff --git a/Help/command/find_package.rst b/Help/command/find_package.rst
index b0b6fe1..9a007fa 100644
--- a/Help/command/find_package.rst
+++ b/Help/command/find_package.rst
@@ -323,18 +323,27 @@ containing a configuration file:
In all cases the ``<name>`` is treated as case-insensitive and corresponds
to any of the names specified (``<PackageName>`` or names given by ``NAMES``).
-Paths with ``lib/<arch>`` are enabled if the
-:variable:`CMAKE_LIBRARY_ARCHITECTURE` variable is set. ``lib*`` includes one
-or more of the values ``lib64``, ``lib32``, ``libx32`` or ``lib`` (searched in
-that order).
+If at least one compiled language has been enabled, the architecture-specific
+``lib/<arch>`` and ``lib*`` directories may be searched based on the compiler's
+target architecture, in the following order:
-* Paths with ``lib64`` are searched on 64 bit platforms if the
+``lib/<arch>``
+ Searched if the :variable:`CMAKE_LIBRARY_ARCHITECTURE` variable is set.
+
+``lib64``
+ Searched on 64 bit platforms (:variable:`CMAKE_SIZEOF_VOID_P` is 8) and the
:prop_gbl:`FIND_LIBRARY_USE_LIB64_PATHS` property is set to ``TRUE``.
-* Paths with ``lib32`` are searched on 32 bit platforms if the
+
+``lib32``
+ Searched on 32 bit platforms (:variable:`CMAKE_SIZEOF_VOID_P` is 4) and the
:prop_gbl:`FIND_LIBRARY_USE_LIB32_PATHS` property is set to ``TRUE``.
-* Paths with ``libx32`` are searched on platforms using the x32 ABI
+
+``libx32``
+ Searched on platforms using the x32 ABI
if the :prop_gbl:`FIND_LIBRARY_USE_LIBX32_PATHS` property is set to ``TRUE``.
-* The ``lib`` path is always searched.
+
+``lib``
+ Always searched.
.. versionchanged:: 3.24
On ``Windows`` platform, it is possible to include registry queries as part
@@ -346,7 +355,7 @@ that order).
``REGISTRY_VIEW`` can be specified to manage ``Windows`` registry queries
specified as part of ``PATHS`` and ``HINTS``.
-.. include:: FIND_XXX_REGISTRY_VIEW.txt
+ .. include:: FIND_XXX_REGISTRY_VIEW.txt
If ``PATH_SUFFIXES`` is specified, the suffixes are appended to each
(``W``) or (``U``) directory entry one-by-one.
diff --git a/Help/command/target_sources.rst b/Help/command/target_sources.rst
index 4a8eda2..86bf7fb 100644
--- a/Help/command/target_sources.rst
+++ b/Help/command/target_sources.rst
@@ -60,6 +60,8 @@ expressions to ensure the sources are correctly assigned to the target.
See the :manual:`cmake-buildsystem(7)` manual for more on defining
buildsystem properties.
+.. _`File Sets`:
+
File Sets
^^^^^^^^^
diff --git a/Help/manual/cmake-policies.7.rst b/Help/manual/cmake-policies.7.rst
index a018aff..dff4f34 100644
--- a/Help/manual/cmake-policies.7.rst
+++ b/Help/manual/cmake-policies.7.rst
@@ -57,6 +57,7 @@ Policies Introduced by CMake 3.28
.. toctree::
:maxdepth: 1
+ CMP0154: Generated files are private by default in targets using file sets. </policy/CMP0154>
CMP0153: The exec_program command should not be called. </policy/CMP0153>
CMP0152: file(REAL_PATH) resolves symlinks before collapsing ../ components. </policy/CMP0152>
diff --git a/Help/policy/CMP0154.rst b/Help/policy/CMP0154.rst
new file mode 100644
index 0000000..cb93d41
--- /dev/null
+++ b/Help/policy/CMP0154.rst
@@ -0,0 +1,53 @@
+CMP0154
+-------
+
+.. versionadded:: 3.28
+
+Generated files are private by default in targets using :ref:`file sets`.
+
+CMake 3.27 and below assume that any file generated as an output or byproduct
+of :command:`add_custom_command` or :command:`add_custom_target` may be a
+public header file meant for inclusion by dependents' source files. This
+requires :ref:`Ninja Generators` to add conservative order-only dependencies
+that prevent a target's source files from compiling before custom commands
+from the target's dependencies are finished, even if those custom commands
+only produce sources private to their own target.
+
+:ref:`File Sets`, introduced by CMake 3.23, provide a way to express the
+visibility of generated header files. CMake 3.28 and above prefer to
+assume that, in targets using file sets, generated files are private to
+their own target by default. Generated public headers must be specified
+as members of a ``PUBLIC`` (or ``INTERFACE``) ``FILE_SET``, typically of
+type ``HEADERS``. With this information, :ref:`Ninja Generators` may omit
+the above-mentioned conservative dependencies and produce more efficient
+build graphs.
+
+This policy provides compatibility for projects using file sets in targets
+with generated header files that have not been updated. Such projects
+should be updated to express generated public headers in a file set.
+For example:
+
+.. code-block:: cmake
+
+ add_custom_command(
+ OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/foo.h
+ ...
+ )
+ target_sources(foo
+ PUBLIC FILE_SET HEADERS
+ BASE_DIRS ${CMAKE_CURRENT_BINARY_DIR}
+ FILES ${CMAKE_CURRENT_BINARY_DIR}/foo.h
+ )
+
+The ``OLD`` behavior for this policy is to assume generated files are
+public, even in targets using file sets, and for :ref:`Ninja Generators`
+to produce conservative build graphs. The ``NEW`` behavior for this
+policy is to assume generated files are private in targets using file sets,
+and for :ref:`Ninja Generators` to produce more efficient build graphs.
+
+This policy was introduced in CMake version 3.28. Use the
+:command:`cmake_policy` command to set it to ``OLD`` or ``NEW`` explicitly.
+Unlike many policies, CMake version |release| does *not* warn
+when this policy is not set and simply uses ``OLD`` behavior.
+
+.. include:: DEPRECATED.txt
diff --git a/Help/release/dev/fileset-private-dep.rst b/Help/release/dev/fileset-private-dep.rst
new file mode 100644
index 0000000..5ffb036
--- /dev/null
+++ b/Help/release/dev/fileset-private-dep.rst
@@ -0,0 +1,7 @@
+fileset-private-dep
+-------------------
+
+* Generated files, in targets using :ref:`file sets`, are now considered
+ private by default. Generated public headers must be specified using
+ file sets. This allows :ref:`Ninja Generators` to produce more
+ efficient build graphs. See policy :policy:`CMP0154`.
diff --git a/Help/variable/CMAKE_SIZEOF_VOID_P.rst b/Help/variable/CMAKE_SIZEOF_VOID_P.rst
index f5464d1..0c1fd7a 100644
--- a/Help/variable/CMAKE_SIZEOF_VOID_P.rst
+++ b/Help/variable/CMAKE_SIZEOF_VOID_P.rst
@@ -4,5 +4,5 @@ CMAKE_SIZEOF_VOID_P
Size of a ``void`` pointer.
This is set to the size of a pointer on the target machine, and is determined
-by a try compile. If a 64-bit size is found, then the library search
-path is modified to look for 64-bit libraries first.
+when a compiled language is enabled. If a 64-bit size is found, then the
+library search path is modified to look for 64-bit libraries first.
diff --git a/Modules/FindJNI.cmake b/Modules/FindJNI.cmake
index e7050a3..abc76cf 100644
--- a/Modules/FindJNI.cmake
+++ b/Modules/FindJNI.cmake
@@ -136,76 +136,76 @@ endif()
# Expand {libarch} occurrences to java_libarch subdirectory(-ies) and set ${_var}
macro(java_append_library_directories _var)
- # Determine java arch-specific library subdir
- # Mostly based on openjdk/jdk/make/common/shared/Platform.gmk as of openjdk
- # 1.6.0_18 + icedtea patches. However, it would be much better to base the
- # guess on the first part of the GNU config.guess platform triplet.
- if(CMAKE_SYSTEM_PROCESSOR STREQUAL "x86_64")
- if(CMAKE_LIBRARY_ARCHITECTURE STREQUAL "x86_64-linux-gnux32")
- set(_java_libarch "x32" "amd64" "i386")
- else()
- set(_java_libarch "amd64" "i386")
- endif()
- elseif(CMAKE_SYSTEM_PROCESSOR MATCHES "^i.86$")
- set(_java_libarch "i386")
- elseif(CMAKE_SYSTEM_PROCESSOR MATCHES "^aarch64")
- set(_java_libarch "arm64" "aarch64")
- elseif(CMAKE_SYSTEM_PROCESSOR MATCHES "^alpha")
- set(_java_libarch "alpha")
- elseif(CMAKE_SYSTEM_PROCESSOR MATCHES "^arm")
- # Subdir is "arm" for both big-endian (arm) and little-endian (armel).
- set(_java_libarch "arm" "aarch32")
- elseif(CMAKE_SYSTEM_PROCESSOR MATCHES "^mips")
- # mips* machines are bi-endian mostly so processor does not tell
- # endianness of the underlying system.
- set(_java_libarch "${CMAKE_SYSTEM_PROCESSOR}"
- "mips" "mipsel" "mipseb" "mipsr6" "mipsr6el"
- "mips64" "mips64el" "mips64r6" "mips64r6el"
- "mipsn32" "mipsn32el" "mipsn32r6" "mipsn32r6el")
- elseif(CMAKE_SYSTEM_PROCESSOR MATCHES "^(powerpc|ppc)64le")
- set(_java_libarch "ppc64" "ppc64le")
- elseif(CMAKE_SYSTEM_PROCESSOR MATCHES "^(powerpc|ppc)64")
- set(_java_libarch "ppc64" "ppc")
- elseif(CMAKE_SYSTEM_PROCESSOR MATCHES "^(powerpc|ppc)")
- set(_java_libarch "ppc" "ppc64")
- elseif(CMAKE_SYSTEM_PROCESSOR MATCHES "^sparc")
- # Both flavors can run on the same processor
- set(_java_libarch "${CMAKE_SYSTEM_PROCESSOR}" "sparc" "sparcv9")
- elseif(CMAKE_SYSTEM_PROCESSOR MATCHES "^(parisc|hppa)")
- set(_java_libarch "parisc" "parisc64")
- elseif(CMAKE_SYSTEM_PROCESSOR MATCHES "^s390")
- # s390 binaries can run on s390x machines
- set(_java_libarch "${CMAKE_SYSTEM_PROCESSOR}" "s390" "s390x")
- elseif(CMAKE_SYSTEM_PROCESSOR MATCHES "^sh")
- set(_java_libarch "sh")
+ # Determine java arch-specific library subdir
+ # Mostly based on openjdk/jdk/make/common/shared/Platform.gmk as of openjdk
+ # 1.6.0_18 + icedtea patches. However, it would be much better to base the
+ # guess on the first part of the GNU config.guess platform triplet.
+ if(CMAKE_SYSTEM_PROCESSOR STREQUAL "x86_64")
+ if(CMAKE_LIBRARY_ARCHITECTURE STREQUAL "x86_64-linux-gnux32")
+ set(_java_libarch "x32" "amd64" "i386")
else()
- set(_java_libarch "${CMAKE_SYSTEM_PROCESSOR}")
+ set(_java_libarch "amd64" "i386")
endif()
+ elseif(CMAKE_SYSTEM_PROCESSOR MATCHES "^i.86$")
+ set(_java_libarch "i386")
+ elseif(CMAKE_SYSTEM_PROCESSOR MATCHES "^aarch64")
+ set(_java_libarch "arm64" "aarch64")
+ elseif(CMAKE_SYSTEM_PROCESSOR MATCHES "^alpha")
+ set(_java_libarch "alpha")
+ elseif(CMAKE_SYSTEM_PROCESSOR MATCHES "^arm")
+ # Subdir is "arm" for both big-endian (arm) and little-endian (armel).
+ set(_java_libarch "arm" "aarch32")
+ elseif(CMAKE_SYSTEM_PROCESSOR MATCHES "^mips")
+ # mips* machines are bi-endian mostly so processor does not tell
+ # endianness of the underlying system.
+ set(_java_libarch "${CMAKE_SYSTEM_PROCESSOR}"
+ "mips" "mipsel" "mipseb" "mipsr6" "mipsr6el"
+ "mips64" "mips64el" "mips64r6" "mips64r6el"
+ "mipsn32" "mipsn32el" "mipsn32r6" "mipsn32r6el")
+ elseif(CMAKE_SYSTEM_PROCESSOR MATCHES "^(powerpc|ppc)64le")
+ set(_java_libarch "ppc64" "ppc64le")
+ elseif(CMAKE_SYSTEM_PROCESSOR MATCHES "^(powerpc|ppc)64")
+ set(_java_libarch "ppc64" "ppc")
+ elseif(CMAKE_SYSTEM_PROCESSOR MATCHES "^(powerpc|ppc)")
+ set(_java_libarch "ppc" "ppc64")
+ elseif(CMAKE_SYSTEM_PROCESSOR MATCHES "^sparc")
+ # Both flavors can run on the same processor
+ set(_java_libarch "${CMAKE_SYSTEM_PROCESSOR}" "sparc" "sparcv9")
+ elseif(CMAKE_SYSTEM_PROCESSOR MATCHES "^(parisc|hppa)")
+ set(_java_libarch "parisc" "parisc64")
+ elseif(CMAKE_SYSTEM_PROCESSOR MATCHES "^s390")
+ # s390 binaries can run on s390x machines
+ set(_java_libarch "${CMAKE_SYSTEM_PROCESSOR}" "s390" "s390x")
+ elseif(CMAKE_SYSTEM_PROCESSOR MATCHES "^sh")
+ set(_java_libarch "sh")
+ else()
+ set(_java_libarch "${CMAKE_SYSTEM_PROCESSOR}")
+ endif()
- # Append default list architectures if CMAKE_SYSTEM_PROCESSOR was empty or
- # system is non-Linux (where the code above has not been well tested)
- if(NOT _java_libarch OR NOT (CMAKE_SYSTEM_NAME MATCHES "Linux"))
- list(APPEND _java_libarch "i386" "amd64" "ppc")
- endif()
+ # Append default list architectures if CMAKE_SYSTEM_PROCESSOR was empty or
+ # system is non-Linux (where the code above has not been well tested)
+ if(NOT _java_libarch OR NOT (CMAKE_SYSTEM_NAME MATCHES "Linux"))
+ list(APPEND _java_libarch "i386" "amd64" "ppc")
+ endif()
- # Sometimes ${CMAKE_SYSTEM_PROCESSOR} is added to the list to prefer
- # current value to a hardcoded list. Remove possible duplicates.
- list(REMOVE_DUPLICATES _java_libarch)
-
- foreach(_path ${ARGN})
- if(_path MATCHES "{libarch}")
- foreach(_libarch ${_java_libarch})
- string(REPLACE "{libarch}" "${_libarch}" _newpath "${_path}")
- if(EXISTS ${_newpath})
- list(APPEND ${_var} "${_newpath}")
- endif()
- endforeach()
- else()
- if(EXISTS ${_path})
- list(APPEND ${_var} "${_path}")
- endif()
+ # Sometimes ${CMAKE_SYSTEM_PROCESSOR} is added to the list to prefer
+ # current value to a hardcoded list. Remove possible duplicates.
+ list(REMOVE_DUPLICATES _java_libarch)
+
+ foreach(_path ${ARGN})
+ if(_path MATCHES "{libarch}")
+ foreach(_libarch IN LISTS _java_libarch)
+ string(REPLACE "{libarch}" "${_libarch}" _newpath "${_path}")
+ if(EXISTS ${_newpath})
+ list(APPEND ${_var} "${_newpath}")
endif()
- endforeach()
+ endforeach()
+ else()
+ if(EXISTS ${_path})
+ list(APPEND ${_var} "${_path}")
+ endif()
+ endif()
+ endforeach()
endmacro()
include(${CMAKE_CURRENT_LIST_DIR}/CMakeFindJavaCommon.cmake)
@@ -235,13 +235,12 @@ endif()
if (WIN32)
set (_JNI_HINTS)
macro (_JNI_GET_INSTALLED_VERSIONS _KIND)
- execute_process(COMMAND REG QUERY "HKLM\\SOFTWARE\\JavaSoft\\${_KIND}"
- RESULT_VARIABLE _JAVA_RESULT
- OUTPUT_VARIABLE _JAVA_VERSIONS
- ERROR_QUIET)
- if (NOT _JAVA_RESULT)
- string (REGEX MATCHALL "HKEY_LOCAL_MACHINE\\\\SOFTWARE\\\\JavaSoft\\\\${_KIND}\\\\[0-9._]+" _JNI_VERSIONS "${_JAVA_VERSIONS}")
- string (REGEX REPLACE "HKEY_LOCAL_MACHINE\\\\SOFTWARE\\\\JavaSoft\\\\${_KIND}\\\\([0-9._]+)" "\\1" _JNI_VERSIONS "${_JNI_VERSIONS}")
+ cmake_host_system_information(RESULT _JNI_VERSIONS
+ QUERY WINDOWS_REGISTRY "HKLM/SOFTWARE/JavaSoft/${_KIND}"
+ SUBKEYS)
+ if (_JNI_VERSIONS)
+ string (REGEX MATCHALL "[0-9._]+" _JNI_VERSIONS "${_JNI_VERSIONS}")
+ string (REGEX REPLACE "([0-9._]+)" "\\1" _JNI_VERSIONS "${_JNI_VERSIONS}")
if (_JNI_VERSIONS)
# sort versions. Most recent first
list (SORT _JNI_VERSIONS COMPARE NATURAL ORDER DESCENDING)
@@ -340,7 +339,7 @@ JAVA_APPEND_LIBRARY_DIRECTORIES(JAVA_AWT_LIBRARY_DIRECTORIES
)
set(JAVA_JVM_LIBRARY_DIRECTORIES)
-foreach(dir ${JAVA_AWT_LIBRARY_DIRECTORIES})
+foreach(dir IN LISTS JAVA_AWT_LIBRARY_DIRECTORIES)
list(APPEND JAVA_JVM_LIBRARY_DIRECTORIES
"${dir}"
"${dir}/client"
@@ -365,14 +364,14 @@ JAVA_APPEND_LIBRARY_DIRECTORIES(JAVA_AWT_INCLUDE_DIRECTORIES
${_JNI_JAVA_INCLUDE_TRIES}
)
-foreach(JAVA_PROG "${JAVA_RUNTIME}" "${JAVA_COMPILE}" "${JAVA_ARCHIVE}")
+foreach(JAVA_PROG IN ITEMS "${JAVA_RUNTIME}" "${JAVA_COMPILE}" "${JAVA_ARCHIVE}")
get_filename_component(jpath "${JAVA_PROG}" PATH)
- foreach(JAVA_INC_PATH ../include ../java/include ../share/java/include)
+ foreach(JAVA_INC_PATH IN ITEMS ../include ../java/include ../share/java/include)
if(EXISTS ${jpath}/${JAVA_INC_PATH})
list(APPEND JAVA_AWT_INCLUDE_DIRECTORIES "${jpath}/${JAVA_INC_PATH}")
endif()
endforeach()
- foreach(JAVA_LIB_PATH
+ foreach(JAVA_LIB_PATH IN ITEMS
../lib ../jre/lib ../jre/lib/i386
../java/lib ../java/jre/lib ../java/jre/lib/i386
../share/java/lib ../share/java/jre/lib ../share/java/jre/lib/i386)
@@ -429,7 +428,7 @@ set(_JNI_NORMAL_JAWT
PATHS ${JAVA_AWT_LIBRARY_DIRECTORIES}
)
-foreach(search ${_JNI_SEARCHES})
+foreach(search IN LISTS _JNI_SEARCHES)
if(JVM IN_LIST JNI_FIND_COMPONENTS)
find_library(JAVA_JVM_LIBRARY ${_JNI_${search}_JVM}
DOC "Java Virtual Machine library"
diff --git a/Modules/FindJava.cmake b/Modules/FindJava.cmake
index e8fb120..74e424b 100644
--- a/Modules/FindJava.cmake
+++ b/Modules/FindJava.cmake
@@ -90,13 +90,12 @@ if(_JAVA_HOME)
endif()
if (WIN32)
macro (_JAVA_GET_INSTALLED_VERSIONS _KIND)
- execute_process(COMMAND REG QUERY "HKLM\\SOFTWARE\\JavaSoft\\${_KIND}"
- RESULT_VARIABLE _JAVA_RESULT
- OUTPUT_VARIABLE _JAVA_VERSIONS
- ERROR_QUIET)
- if (NOT _JAVA_RESULT)
- string (REGEX MATCHALL "HKEY_LOCAL_MACHINE\\\\SOFTWARE\\\\JavaSoft\\\\${_KIND}\\\\[0-9._]+" _JAVA_VERSIONS "${_JAVA_VERSIONS}")
- string (REGEX REPLACE "HKEY_LOCAL_MACHINE\\\\SOFTWARE\\\\JavaSoft\\\\${_KIND}\\\\([0-9._]+)" "\\1" _JAVA_VERSIONS "${_JAVA_VERSIONS}")
+ cmake_host_system_information(RESULT _JAVA_VERSIONS
+ QUERY WINDOWS_REGISTRY "HKLM/SOFTWARE/JavaSoft/${_KIND}"
+ SUBKEYS)
+ if (_JAVA_VERSIONS)
+ string (REGEX MATCHALL "[0-9._]+" _JAVA_VERSIONS "${_JAVA_VERSIONS}")
+ string (REGEX REPLACE "([0-9._]+)" "\\1" _JAVA_VERSIONS "${_JAVA_VERSIONS}")
if (_JAVA_VERSIONS)
# sort versions. Most recent first
list (SORT _JAVA_VERSIONS COMPARE NATURAL ORDER DESCENDING)
@@ -221,7 +220,7 @@ if(Java_JAVA_EXECUTABLE)
unset(_java_var)
set(Java_VERSION "${Java_VERSION_MAJOR}")
if(NOT "x${Java_VERSION}" STREQUAL "x")
- foreach(_java_c MINOR PATCH TWEAK)
+ foreach(_java_c IN ITEMS "MINOR" "PATCH" "TWEAK")
if(NOT "x${Java_VERSION_${_java_c}}" STREQUAL "x")
string(APPEND Java_VERSION ".${Java_VERSION_${_java_c}}")
else()
@@ -274,7 +273,7 @@ find_program(Java_JARSIGNER_EXECUTABLE
include(${CMAKE_CURRENT_LIST_DIR}/FindPackageHandleStandardArgs.cmake)
if(Java_FIND_COMPONENTS)
set(_JAVA_REQUIRED_VARS)
- foreach(component ${Java_FIND_COMPONENTS})
+ foreach(component IN LISTS Java_FIND_COMPONENTS)
# User just want to execute some Java byte-compiled
If(component STREQUAL "Runtime")
list(APPEND _JAVA_REQUIRED_VARS Java_JAVA_EXECUTABLE)
@@ -316,7 +315,7 @@ if(Java_FIND_COMPONENTS)
VERSION_VAR Java_VERSION
)
if(Java_FOUND)
- foreach(component ${Java_FIND_COMPONENTS})
+ foreach(component IN LISTS Java_FIND_COMPONENTS)
set(Java_${component}_FOUND TRUE)
endforeach()
endif()
diff --git a/Modules/Platform/Apple-Clang.cmake b/Modules/Platform/Apple-Clang.cmake
index 4d7546a..57b3910 100644
--- a/Modules/Platform/Apple-Clang.cmake
+++ b/Modules/Platform/Apple-Clang.cmake
@@ -14,6 +14,10 @@ macro(__apple_compiler_clang lang)
if(NOT CMAKE_${lang}_COMPILER_VERSION VERSION_LESS 3.2)
set(CMAKE_${lang}_SYSTEM_FRAMEWORK_SEARCH_FLAG "-iframework ")
endif()
+
+ set(CMAKE_${lang}_LINK_LIBRARY_USING_FRAMEWORK "-framework <LIBRARY>")
+ set(CMAKE_${lang}_LINK_LIBRARY_USING_FRAMEWORK_SUPPORTED TRUE)
+
if(_CMAKE_OSX_SYSROOT_PATH MATCHES "/iPhoneOS")
set(CMAKE_${lang}_OSX_DEPLOYMENT_TARGET_FLAG "-miphoneos-version-min=")
elseif(_CMAKE_OSX_SYSROOT_PATH MATCHES "/iPhoneSimulator")
diff --git a/Modules/Platform/Apple-GNU.cmake b/Modules/Platform/Apple-GNU.cmake
index 9572736..823c790 100644
--- a/Modules/Platform/Apple-GNU.cmake
+++ b/Modules/Platform/Apple-GNU.cmake
@@ -14,6 +14,9 @@ macro(__apple_compiler_gnu lang)
if(NOT CMAKE_${lang}_COMPILER_VERSION VERSION_LESS 4.3)
set(CMAKE_${lang}_SYSTEM_FRAMEWORK_SEARCH_FLAG "-iframework ")
endif()
+
+ set(CMAKE_${lang}_LINK_LIBRARY_USING_FRAMEWORK "-framework <LIBRARY>")
+ set(CMAKE_${lang}_LINK_LIBRARY_USING_FRAMEWORK_SUPPORTED TRUE)
endmacro()
macro(cmake_gnu_set_sysroot_flag lang)
diff --git a/Source/CMakeVersion.cmake b/Source/CMakeVersion.cmake
index bbeb289..954fead 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 27)
-set(CMake_VERSION_PATCH 20230921)
+set(CMake_VERSION_PATCH 20230922)
#set(CMake_VERSION_RC 0)
set(CMake_VERSION_IS_DIRTY 0)
diff --git a/Source/cmGlobalNinjaGenerator.cxx b/Source/cmGlobalNinjaGenerator.cxx
index 30305a1..7368a6a 100644
--- a/Source/cmGlobalNinjaGenerator.cxx
+++ b/Source/cmGlobalNinjaGenerator.cxx
@@ -1278,6 +1278,13 @@ std::string cmGlobalNinjaGenerator::OrderDependsTargetForTarget(
return cmStrCat("cmake_object_order_depends_target_", target->GetName());
}
+std::string cmGlobalNinjaGenerator::OrderDependsTargetForTargetPrivate(
+ cmGeneratorTarget const* target, const std::string& config) const
+{
+ return cmStrCat(this->OrderDependsTargetForTarget(target, config),
+ "_private");
+}
+
void cmGlobalNinjaGenerator::AppendTargetOutputs(
cmGeneratorTarget const* target, cmNinjaDeps& outputs,
const std::string& config, cmNinjaTargetDepends depends) const
@@ -3176,3 +3183,10 @@ std::string cmGlobalNinjaMultiGenerator::OrderDependsTargetForTarget(
return cmStrCat("cmake_object_order_depends_target_", target->GetName(), '_',
cmSystemTools::UpperCase(config));
}
+
+std::string cmGlobalNinjaMultiGenerator::OrderDependsTargetForTargetPrivate(
+ cmGeneratorTarget const* target, const std::string& config) const
+{
+ return cmStrCat(this->OrderDependsTargetForTarget(target, config),
+ "_private");
+}
diff --git a/Source/cmGlobalNinjaGenerator.h b/Source/cmGlobalNinjaGenerator.h
index c43e27c..56a922c 100644
--- a/Source/cmGlobalNinjaGenerator.h
+++ b/Source/cmGlobalNinjaGenerator.h
@@ -349,6 +349,9 @@ public:
virtual std::string OrderDependsTargetForTarget(
cmGeneratorTarget const* target, const std::string& config) const;
+ virtual std::string OrderDependsTargetForTargetPrivate(
+ cmGeneratorTarget const* target, const std::string& config) const;
+
void AppendTargetOutputs(cmGeneratorTarget const* target,
cmNinjaDeps& outputs, const std::string& config,
cmNinjaTargetDepends depends) const;
@@ -738,6 +741,9 @@ public:
std::string OrderDependsTargetForTarget(
cmGeneratorTarget const* target, const std::string& config) const override;
+ std::string OrderDependsTargetForTargetPrivate(
+ cmGeneratorTarget const* target, const std::string& config) const override;
+
protected:
bool OpenBuildFileStreams() override;
void CloseBuildFileStreams() override;
diff --git a/Source/cmNinjaTargetGenerator.cxx b/Source/cmNinjaTargetGenerator.cxx
index 6187543..193cc0f 100644
--- a/Source/cmNinjaTargetGenerator.cxx
+++ b/Source/cmNinjaTargetGenerator.cxx
@@ -38,6 +38,7 @@
#include "cmNinjaNormalTargetGenerator.h"
#include "cmNinjaUtilityTargetGenerator.h"
#include "cmOutputConverter.h"
+#include "cmPolicies.h"
#include "cmRange.h"
#include "cmRulePlaceholderExpander.h"
#include "cmSourceFile.h"
@@ -169,6 +170,13 @@ std::string cmNinjaTargetGenerator::OrderDependsTargetForTarget(
this->GeneratorTarget, config);
}
+std::string cmNinjaTargetGenerator::OrderDependsTargetForTargetPrivate(
+ const std::string& config)
+{
+ return this->GetGlobalGenerator()->OrderDependsTargetForTargetPrivate(
+ this->GeneratorTarget, config);
+}
+
// TODO: Most of the code is picked up from
// void cmMakefileExecutableTargetGenerator::WriteExecutableRule(bool relink),
// void cmMakefileTargetGenerator::WriteTargetLanguageFlags()
@@ -1020,6 +1028,45 @@ void cmNinjaTargetGenerator::WriteObjectBuildStatements(
cmStrCat("Order-only phony target for ", this->GetTargetName());
build.Outputs.push_back(this->OrderDependsTargetForTarget(config));
+ // Gather order-only dependencies on custom command outputs.
+ std::vector<std::string> ccouts;
+ std::vector<std::string> ccouts_private;
+ bool usePrivateGeneratedSources = false;
+ if (this->GeneratorTarget->Target->HasFileSets()) {
+ switch (this->GetGeneratorTarget()->GetPolicyStatusCMP0154()) {
+ case cmPolicies::WARN:
+ case cmPolicies::OLD:
+ break;
+ case cmPolicies::REQUIRED_ALWAYS:
+ case cmPolicies::REQUIRED_IF_USED:
+ case cmPolicies::NEW:
+ usePrivateGeneratedSources = true;
+ break;
+ }
+ }
+ for (cmCustomCommand const* cc : customCommands) {
+ cmCustomCommandGenerator ccg(*cc, config, this->GetLocalGenerator());
+ const std::vector<std::string>& ccoutputs = ccg.GetOutputs();
+ const std::vector<std::string>& ccbyproducts = ccg.GetByproducts();
+ ccouts.insert(ccouts.end(), ccoutputs.begin(), ccoutputs.end());
+ ccouts.insert(ccouts.end(), ccbyproducts.begin(), ccbyproducts.end());
+ if (usePrivateGeneratedSources) {
+ auto it = ccouts.begin();
+ while (it != ccouts.end()) {
+ cmFileSet const* fileset =
+ this->GeneratorTarget->GetFileSetForSource(
+ config, this->Makefile->GetOrCreateGeneratedSource(*it));
+ if (fileset &&
+ fileset->GetVisibility() != cmFileSetVisibility::Private) {
+ ++it;
+ } else {
+ ccouts_private.push_back(*it);
+ it = ccouts.erase(it);
+ }
+ }
+ }
+ }
+
cmNinjaDeps& orderOnlyDeps = build.OrderOnlyDeps;
this->GetLocalGenerator()->AppendTargetDepends(
this->GeneratorTarget, orderOnlyDeps, config, fileConfig,
@@ -1029,17 +1076,8 @@ void cmNinjaTargetGenerator::WriteObjectBuildStatements(
cm::append(orderOnlyDeps, this->Configs[config].ExtraFiles);
// Add order-only dependencies on custom command outputs.
- for (cmCustomCommand const* cc : customCommands) {
- cmCustomCommandGenerator ccg(*cc, config, this->GetLocalGenerator());
- const std::vector<std::string>& ccoutputs = ccg.GetOutputs();
- const std::vector<std::string>& ccbyproducts = ccg.GetByproducts();
- std::transform(ccoutputs.begin(), ccoutputs.end(),
- std::back_inserter(orderOnlyDeps),
- this->MapToNinjaPath());
- std::transform(ccbyproducts.begin(), ccbyproducts.end(),
- std::back_inserter(orderOnlyDeps),
- this->MapToNinjaPath());
- }
+ std::transform(ccouts.begin(), ccouts.end(),
+ std::back_inserter(orderOnlyDeps), this->MapToNinjaPath());
std::sort(orderOnlyDeps.begin(), orderOnlyDeps.end());
orderOnlyDeps.erase(
@@ -1060,8 +1098,32 @@ void cmNinjaTargetGenerator::WriteObjectBuildStatements(
this->GetGlobalGenerator()->WriteBuild(this->GetImplFileStream(fileConfig),
build);
- }
+ // Add order-only dependencies on custom command outputs that are
+ // private to this target.
+ this->HasPrivateGeneratedSources = !ccouts_private.empty();
+ if (this->HasPrivateGeneratedSources) {
+ cmNinjaBuild buildPrivate("phony");
+ cmNinjaDeps& orderOnlyDepsPrivate = buildPrivate.OrderOnlyDeps;
+ orderOnlyDepsPrivate.push_back(
+ this->OrderDependsTargetForTarget(config));
+
+ buildPrivate.Outputs.push_back(
+ this->OrderDependsTargetForTargetPrivate(config));
+
+ std::transform(ccouts_private.begin(), ccouts_private.end(),
+ std::back_inserter(orderOnlyDepsPrivate),
+ this->MapToNinjaPath());
+
+ std::sort(orderOnlyDepsPrivate.begin(), orderOnlyDepsPrivate.end());
+ orderOnlyDepsPrivate.erase(
+ std::unique(orderOnlyDepsPrivate.begin(), orderOnlyDepsPrivate.end()),
+ orderOnlyDepsPrivate.end());
+
+ this->GetGlobalGenerator()->WriteBuild(
+ this->GetImplFileStream(fileConfig), buildPrivate);
+ }
+ }
{
std::vector<cmSourceFile const*> objectSources;
this->GeneratorTarget->GetObjectSources(objectSources, config);
@@ -1388,7 +1450,13 @@ void cmNinjaTargetGenerator::WriteObjectBuildStatement(
this->MapToNinjaPath());
}
- objBuild.OrderOnlyDeps.push_back(this->OrderDependsTargetForTarget(config));
+ if (this->HasPrivateGeneratedSources) {
+ objBuild.OrderOnlyDeps.push_back(
+ this->OrderDependsTargetForTargetPrivate(config));
+ } else {
+ objBuild.OrderOnlyDeps.push_back(
+ this->OrderDependsTargetForTarget(config));
+ }
// If the source file is GENERATED and does not have a custom command
// (either attached to this source file or another one), assume that one of
diff --git a/Source/cmNinjaTargetGenerator.h b/Source/cmNinjaTargetGenerator.h
index d41d86e..3f56113 100644
--- a/Source/cmNinjaTargetGenerator.h
+++ b/Source/cmNinjaTargetGenerator.h
@@ -81,6 +81,7 @@ protected:
bool CompileWithDefines(std::string const& lang) const;
std::string OrderDependsTargetForTarget(const std::string& config);
+ std::string OrderDependsTargetForTargetPrivate(const std::string& config);
std::string ComputeOrderDependsForTarget();
@@ -228,6 +229,7 @@ protected:
private:
cmLocalNinjaGenerator* LocalGenerator;
+ bool HasPrivateGeneratedSources = false;
struct ScanningFiles
{
diff --git a/Source/cmPolicies.h b/Source/cmPolicies.h
index 26c141d..e894073 100644
--- a/Source/cmPolicies.h
+++ b/Source/cmPolicies.h
@@ -465,7 +465,11 @@ class cmMakefile;
"file(REAL_PATH) resolves symlinks before collapsing ../ components.", 3, \
28, 0, cmPolicies::WARN) \
SELECT(POLICY, CMP0153, "The exec_program command should not be called.", \
- 3, 28, 0, cmPolicies::WARN)
+ 3, 28, 0, cmPolicies::WARN) \
+ SELECT( \
+ POLICY, CMP0154, \
+ "Generated files are private by default in targets using file sets.", 3, \
+ 28, 0, cmPolicies::WARN)
#define CM_SELECT_ID(F, A1, A2, A3, A4, A5, A6) F(A1)
#define CM_FOR_EACH_POLICY_ID(POLICY) \
@@ -503,7 +507,8 @@ class cmMakefile;
F(CMP0113) \
F(CMP0119) \
F(CMP0131) \
- F(CMP0142)
+ F(CMP0142) \
+ F(CMP0154)
#define CM_FOR_EACH_CUSTOM_COMMAND_POLICY(F) \
F(CMP0116) \
diff --git a/Source/cmTarget.cxx b/Source/cmTarget.cxx
index ace93e8..abbf29e 100644
--- a/Source/cmTarget.cxx
+++ b/Source/cmTarget.cxx
@@ -3201,6 +3201,11 @@ std::vector<std::string> cmTarget::GetAllInterfaceFileSets() const
return result;
}
+bool cmTarget::HasFileSets() const
+{
+ return !this->impl->FileSets.empty();
+}
+
bool cmTargetInternals::CheckImportedLibName(std::string const& prop,
std::string const& value) const
{
diff --git a/Source/cmTarget.h b/Source/cmTarget.h
index b77ea0c..584856a 100644
--- a/Source/cmTarget.h
+++ b/Source/cmTarget.h
@@ -321,6 +321,8 @@ public:
static std::string GetFileSetsPropertyName(const std::string& type);
static std::string GetInterfaceFileSetsPropertyName(const std::string& type);
+ bool HasFileSets() const;
+
private:
template <typename ValueType>
void StoreProperty(const std::string& prop, ValueType value);
diff --git a/Tests/RunCMake/CMakeLists.txt b/Tests/RunCMake/CMakeLists.txt
index 111f542..2eccb2a 100644
--- a/Tests/RunCMake/CMakeLists.txt
+++ b/Tests/RunCMake/CMakeLists.txt
@@ -242,6 +242,9 @@ if(CMAKE_GENERATOR MATCHES "Ninja")
add_RunCMake_test(NinjaMultiConfig)
set_property(TEST RunCMake.NinjaMultiConfig APPEND
PROPERTY LABELS "CUDA")
+ add_RunCMake_test(NinjaPrivateDeps
+ -DCMAKE_C_OUTPUT_EXTENSION=${CMAKE_C_OUTPUT_EXTENSION}
+ -DRunCMake_GENERATOR_IS_MULTI_CONFIG=${_isMultiConfig})
endif()
add_RunCMake_test(CTest)
diff --git a/Tests/RunCMake/NinjaPrivateDeps/CMP0154-NEW-Build-EmptyFileSet-Source-check.cmake b/Tests/RunCMake/NinjaPrivateDeps/CMP0154-NEW-Build-EmptyFileSet-Source-check.cmake
new file mode 100644
index 0000000..7658930
--- /dev/null
+++ b/Tests/RunCMake/NinjaPrivateDeps/CMP0154-NEW-Build-EmptyFileSet-Source-check.cmake
@@ -0,0 +1,3 @@
+if (EXISTS ${RunCMake_TEST_BINARY_DIR}/empty.cpp)
+ set(RunCMake_TEST_FAILED "Compiled source generated before compilation of consumers.")
+endif()
diff --git a/Tests/RunCMake/NinjaPrivateDeps/CMP0154-NEW-Build-EmptyFileSet-check.cmake b/Tests/RunCMake/NinjaPrivateDeps/CMP0154-NEW-Build-EmptyFileSet-check.cmake
new file mode 100644
index 0000000..3287a65
--- /dev/null
+++ b/Tests/RunCMake/NinjaPrivateDeps/CMP0154-NEW-Build-EmptyFileSet-check.cmake
@@ -0,0 +1,3 @@
+if (NOT EXISTS ${RunCMake_TEST_BINARY_DIR}/empty.cpp)
+ set(RunCMake_TEST_FAILED "Compiled source did not generate.")
+endif()
diff --git a/Tests/RunCMake/NinjaPrivateDeps/CMP0154-NEW-Build-NoFileSet-Source-check.cmake b/Tests/RunCMake/NinjaPrivateDeps/CMP0154-NEW-Build-NoFileSet-Source-check.cmake
new file mode 100644
index 0000000..9e99ed8
--- /dev/null
+++ b/Tests/RunCMake/NinjaPrivateDeps/CMP0154-NEW-Build-NoFileSet-Source-check.cmake
@@ -0,0 +1,3 @@
+if (NOT EXISTS ${RunCMake_TEST_BINARY_DIR}/none.cpp)
+ set(RunCMake_TEST_FAILED "Private source dependency used for target without filesets.")
+endif()
diff --git a/Tests/RunCMake/NinjaPrivateDeps/CMP0154-NEW-Build-PrivateFileSet-Source-check.cmake b/Tests/RunCMake/NinjaPrivateDeps/CMP0154-NEW-Build-PrivateFileSet-Source-check.cmake
new file mode 100644
index 0000000..dd814c9
--- /dev/null
+++ b/Tests/RunCMake/NinjaPrivateDeps/CMP0154-NEW-Build-PrivateFileSet-Source-check.cmake
@@ -0,0 +1,3 @@
+if (EXISTS ${RunCMake_TEST_BINARY_DIR}/private.h)
+ set(RunCMake_TEST_FAILED "Private header generated before compilation.")
+endif()
diff --git a/Tests/RunCMake/NinjaPrivateDeps/CMP0154-NEW-Build-PrivateFileSet-check.cmake b/Tests/RunCMake/NinjaPrivateDeps/CMP0154-NEW-Build-PrivateFileSet-check.cmake
new file mode 100644
index 0000000..357b8c0
--- /dev/null
+++ b/Tests/RunCMake/NinjaPrivateDeps/CMP0154-NEW-Build-PrivateFileSet-check.cmake
@@ -0,0 +1,3 @@
+if (NOT EXISTS ${RunCMake_TEST_BINARY_DIR}/private.h)
+ set(RunCMake_TEST_FAILED "Private header generated before compilation.")
+endif()
diff --git a/Tests/RunCMake/NinjaPrivateDeps/CMP0154-NEW-Build-PublicFileSet-Source-check.cmake b/Tests/RunCMake/NinjaPrivateDeps/CMP0154-NEW-Build-PublicFileSet-Source-check.cmake
new file mode 100644
index 0000000..cfceb7a
--- /dev/null
+++ b/Tests/RunCMake/NinjaPrivateDeps/CMP0154-NEW-Build-PublicFileSet-Source-check.cmake
@@ -0,0 +1,3 @@
+if (NOT EXISTS ${RunCMake_TEST_BINARY_DIR}/public.h)
+ set(RunCMake_TEST_FAILED "Public header did not generate before compilation.")
+endif()
diff --git a/Tests/RunCMake/NinjaPrivateDeps/CMP0154-NEW.cmake b/Tests/RunCMake/NinjaPrivateDeps/CMP0154-NEW.cmake
new file mode 100644
index 0000000..3330269
--- /dev/null
+++ b/Tests/RunCMake/NinjaPrivateDeps/CMP0154-NEW.cmake
@@ -0,0 +1,2 @@
+cmake_policy(SET CMP0154 NEW)
+include(CMP0154-common.cmake)
diff --git a/Tests/RunCMake/NinjaPrivateDeps/CMP0154-OLD-Build-EmptyFileSet-Source-check.cmake b/Tests/RunCMake/NinjaPrivateDeps/CMP0154-OLD-Build-EmptyFileSet-Source-check.cmake
new file mode 100644
index 0000000..8ee1ad4
--- /dev/null
+++ b/Tests/RunCMake/NinjaPrivateDeps/CMP0154-OLD-Build-EmptyFileSet-Source-check.cmake
@@ -0,0 +1,3 @@
+if (NOT EXISTS ${RunCMake_TEST_BINARY_DIR}/empty.cpp)
+ set(RunCMake_TEST_FAILED "Policy CMP0154 set to OLD but using new behavior compiled sources.")
+endif()
diff --git a/Tests/RunCMake/NinjaPrivateDeps/CMP0154-OLD-Build-PrivateFileSet-Source-check.cmake b/Tests/RunCMake/NinjaPrivateDeps/CMP0154-OLD-Build-PrivateFileSet-Source-check.cmake
new file mode 100644
index 0000000..25c23d7
--- /dev/null
+++ b/Tests/RunCMake/NinjaPrivateDeps/CMP0154-OLD-Build-PrivateFileSet-Source-check.cmake
@@ -0,0 +1,3 @@
+if (NOT EXISTS ${RunCMake_TEST_BINARY_DIR}/private.h)
+ set(RunCMake_TEST_FAILED "Policy CMP0154 set to OLD but using new behavior private headers.")
+endif()
diff --git a/Tests/RunCMake/NinjaPrivateDeps/CMP0154-OLD.cmake b/Tests/RunCMake/NinjaPrivateDeps/CMP0154-OLD.cmake
new file mode 100644
index 0000000..691530c
--- /dev/null
+++ b/Tests/RunCMake/NinjaPrivateDeps/CMP0154-OLD.cmake
@@ -0,0 +1,2 @@
+cmake_policy(SET CMP0154 OLD)
+include(CMP0154-common.cmake)
diff --git a/Tests/RunCMake/NinjaPrivateDeps/CMP0154-common.cmake b/Tests/RunCMake/NinjaPrivateDeps/CMP0154-common.cmake
new file mode 100644
index 0000000..a9e6d20
--- /dev/null
+++ b/Tests/RunCMake/NinjaPrivateDeps/CMP0154-common.cmake
@@ -0,0 +1,45 @@
+enable_language(CXX)
+
+function(copy_file file dest)
+ add_custom_command(
+ OUTPUT ${CMAKE_BINARY_DIR}/${dest}
+ COMMAND ${CMAKE_COMMAND} -E copy
+ ${CMAKE_SOURCE_DIR}/${file} ${CMAKE_BINARY_DIR}/${dest}
+ )
+endfunction()
+
+copy_file(header.h.in private.h)
+copy_file(header.h.in public.h)
+copy_file(source.cpp.in empty.cpp)
+copy_file(source.cpp.in none.cpp)
+
+add_library(HelloLib_PrivateFileSet STATIC hello_lib.cpp)
+target_sources(HelloLib_PrivateFileSet
+ PRIVATE FILE_SET HEADERS
+ BASE_DIRS ${CMAKE_BINARY_DIR}
+ FILES ${CMAKE_BINARY_DIR}/private.h
+)
+
+add_library(HelloLib_PublicFileSet STATIC hello_lib.cpp)
+target_sources(HelloLib_PublicFileSet
+ PUBLIC FILE_SET HEADERS
+ BASE_DIRS ${CMAKE_BINARY_DIR}
+ FILES ${CMAKE_BINARY_DIR}/public.h
+)
+
+add_library(HelloLib_EmptyFileSet STATIC hello_lib.cpp empty.cpp)
+target_sources(HelloLib_EmptyFileSet
+ PUBLIC FILE_SET HEADERS
+)
+
+add_library(HelloLib_NoFileSet STATIC hello_lib.cpp none.cpp)
+
+function(hello_executable name)
+ add_executable(Hello_${name} hello.cpp)
+ target_link_libraries(Hello_${name} PRIVATE HelloLib_${name})
+endfunction()
+
+hello_executable(PrivateFileSet)
+hello_executable(PublicFileSet)
+hello_executable(EmptyFileSet)
+hello_executable(NoFileSet)
diff --git a/Tests/RunCMake/NinjaPrivateDeps/CMakeLists.txt b/Tests/RunCMake/NinjaPrivateDeps/CMakeLists.txt
new file mode 100644
index 0000000..54a4d62
--- /dev/null
+++ b/Tests/RunCMake/NinjaPrivateDeps/CMakeLists.txt
@@ -0,0 +1,3 @@
+cmake_minimum_required(VERSION 3.26)
+project(${RunCMake_TEST} NONE)
+include(${RunCMake_TEST}.cmake)
diff --git a/Tests/RunCMake/NinjaPrivateDeps/RunCMakeTest.cmake b/Tests/RunCMake/NinjaPrivateDeps/RunCMakeTest.cmake
new file mode 100644
index 0000000..e821185
--- /dev/null
+++ b/Tests/RunCMake/NinjaPrivateDeps/RunCMakeTest.cmake
@@ -0,0 +1,30 @@
+include(RunCMake)
+
+function(compile_source test target)
+ if (RunCMake_GENERATOR_IS_MULTI_CONFIG)
+ set(config "Debug/")
+ endif()
+ set(RunCMake_TEST_BINARY_DIR ${RunCMake_BINARY_DIR}/${test}-build)
+ set(RunCMake_TEST_NO_CLEAN 1)
+ run_cmake_command(${test}-Build-${target}-Source ${CMAKE_COMMAND} --build .
+ --target CMakeFiles/Hello_${target}.dir/${config}hello.cpp${CMAKE_C_OUTPUT_EXTENSION})
+endfunction()
+
+function(compile_target test target)
+ set(RunCMake_TEST_BINARY_DIR ${RunCMake_BINARY_DIR}/${test}-build)
+ set(RunCMake_TEST_NO_CLEAN 1)
+ run_cmake_command(${test}-Build-${target} ${CMAKE_COMMAND} --build .
+ --target Hello_${target})
+endfunction()
+
+run_cmake(CMP0154-OLD)
+compile_source(CMP0154-OLD PrivateFileSet)
+compile_source(CMP0154-OLD EmptyFileSet)
+
+run_cmake(CMP0154-NEW)
+compile_source(CMP0154-NEW PrivateFileSet)
+compile_target(CMP0154-NEW PrivateFileSet)
+compile_source(CMP0154-NEW PublicFileSet)
+compile_source(CMP0154-NEW NoFileSet)
+compile_source(CMP0154-NEW EmptyFileSet)
+compile_target(CMP0154-NEW EmptyFileSet)
diff --git a/Tests/RunCMake/NinjaPrivateDeps/header.h.in b/Tests/RunCMake/NinjaPrivateDeps/header.h.in
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/Tests/RunCMake/NinjaPrivateDeps/header.h.in
diff --git a/Tests/RunCMake/NinjaPrivateDeps/hello.cpp b/Tests/RunCMake/NinjaPrivateDeps/hello.cpp
new file mode 100644
index 0000000..34fabe9
--- /dev/null
+++ b/Tests/RunCMake/NinjaPrivateDeps/hello.cpp
@@ -0,0 +1,6 @@
+#include "hello_lib.h"
+
+int main()
+{
+ say_hello();
+}
diff --git a/Tests/RunCMake/NinjaPrivateDeps/hello_lib.cpp b/Tests/RunCMake/NinjaPrivateDeps/hello_lib.cpp
new file mode 100644
index 0000000..d67113f
--- /dev/null
+++ b/Tests/RunCMake/NinjaPrivateDeps/hello_lib.cpp
@@ -0,0 +1,8 @@
+#include "hello_lib.h"
+
+#include <iostream>
+
+void say_hello()
+{
+ std::cout << "hello" << std::endl;
+}
diff --git a/Tests/RunCMake/NinjaPrivateDeps/hello_lib.h b/Tests/RunCMake/NinjaPrivateDeps/hello_lib.h
new file mode 100644
index 0000000..3b4775f
--- /dev/null
+++ b/Tests/RunCMake/NinjaPrivateDeps/hello_lib.h
@@ -0,0 +1 @@
+void say_hello();
diff --git a/Tests/RunCMake/NinjaPrivateDeps/source.cpp.in b/Tests/RunCMake/NinjaPrivateDeps/source.cpp.in
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/Tests/RunCMake/NinjaPrivateDeps/source.cpp.in
diff --git a/Tests/RunCMake/TargetPolicies/PolicyList-stderr.txt b/Tests/RunCMake/TargetPolicies/PolicyList-stderr.txt
index 0d8e4c9..7e91b76 100644
--- a/Tests/RunCMake/TargetPolicies/PolicyList-stderr.txt
+++ b/Tests/RunCMake/TargetPolicies/PolicyList-stderr.txt
@@ -37,6 +37,7 @@
\* CMP0119
\* CMP0131
\* CMP0142
+ \* CMP0154
Call Stack \(most recent call first\):
CMakeLists.txt:3 \(include\)