Merge branch 'release-3.23'
diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml
index efd15b3..baa04e5 100644
--- a/.gitlab-ci.yml
+++ b/.gitlab-ci.yml
@@ -59,7 +59,7 @@
- .cmake_doc_artifacts
- .run_only_for_package
-.u:source-package:
+u:source-package:
extends:
- .rsync_upload_binary
- .run_only_for_package
@@ -77,7 +77,7 @@
- .cmake_org_help
- .run_only_for_continuous_master
-.u:help:master:
+u:help:master:
extends:
- .rsync_upload_help
- .run_only_for_continuous_master
@@ -93,7 +93,7 @@
- .cmake_org_help
- .run_only_for_continuous_stage
-.u:help:stage:
+u:help:stage:
extends:
- .rsync_upload_help
- .run_only_for_continuous_stage
@@ -293,6 +293,17 @@
- .cmake_build_artifacts
- .linux_builder_tags_qt
- .run_manually
+ variables:
+ CMAKE_CI_JOB_CONTINUOUS: "true"
+
+b:debian10-makefiles-inplace:
+ extends:
+ - .debian10_makefiles_inplace
+ - .cmake_build_linux_standalone
+ - .linux_builder_tags
+ - .run_manually
+ variables:
+ CMAKE_CI_JOB_NIGHTLY: "true"
t:fedora35-ninja:
extends:
@@ -305,6 +316,8 @@
- b:fedora35-ninja
needs:
- b:fedora35-ninja
+ variables:
+ CMAKE_CI_JOB_CONTINUOUS: "true"
t:fedora35-ninja-multi:
extends:
@@ -514,6 +527,27 @@
CMAKE_CI_BUILD_NAME: intel2021.2.0_makefiles
CMAKE_CI_INTELCOMPILER_IMAGE_TAG: 2021.2.0-el8
+t:intel2021.3.0-makefiles:
+ extends:
+ - .cmake_test_linux_intelclassic_makefiles
+ variables:
+ CMAKE_CI_BUILD_NAME: intel2021.3.0_makefiles
+ CMAKE_CI_INTELCOMPILER_IMAGE_TAG: 2021.3.0-el8
+
+t:intel2021.4.0-makefiles:
+ extends:
+ - .cmake_test_linux_intelclassic_makefiles
+ variables:
+ CMAKE_CI_BUILD_NAME: intel2021.4.0_makefiles
+ CMAKE_CI_INTELCOMPILER_IMAGE_TAG: 2021.4.0-el8
+
+t:intel2021.5.0-makefiles:
+ extends:
+ - .cmake_test_linux_intelclassic_makefiles
+ variables:
+ CMAKE_CI_BUILD_NAME: intel2021.5.0_makefiles
+ CMAKE_CI_INTELCOMPILER_IMAGE_TAG: 2022.0.2-el8
+
t:oneapi2021.1.1-makefiles:
extends:
- .cmake_test_linux_inteloneapi_makefiles
@@ -535,6 +569,27 @@
CMAKE_CI_BUILD_NAME: oneapi2021.2.0_makefiles
CMAKE_CI_INTELCOMPILER_IMAGE_TAG: 2021.2.0-el8
+t:oneapi2021.3.0-makefiles:
+ extends:
+ - .cmake_test_linux_inteloneapi_makefiles
+ variables:
+ CMAKE_CI_BUILD_NAME: oneapi2021.3.0_makefiles
+ CMAKE_CI_INTELCOMPILER_IMAGE_TAG: 2021.3.0-el8
+
+t:oneapi2021.4.0-makefiles:
+ extends:
+ - .cmake_test_linux_inteloneapi_makefiles
+ variables:
+ CMAKE_CI_BUILD_NAME: oneapi2021.4.0_makefiles
+ CMAKE_CI_INTELCOMPILER_IMAGE_TAG: 2021.4.0-el8
+
+t:oneapi2022.0.2-makefiles:
+ extends:
+ - .cmake_test_linux_inteloneapi_makefiles
+ variables:
+ CMAKE_CI_BUILD_NAME: oneapi2022.0.2_makefiles
+ CMAKE_CI_INTELCOMPILER_IMAGE_TAG: 2022.0.2-el8
+
b:linux-x86_64-package:
extends:
- .linux_package
@@ -548,7 +603,7 @@
needs:
- p:doc-package
-.u:linux-x86_64-package:
+u:linux-x86_64-package:
extends:
- .rsync_upload_binary
- .run_only_for_package
@@ -572,7 +627,7 @@
needs:
- p:doc-package
-.u:linux-aarch64-package:
+u:linux-aarch64-package:
extends:
- .rsync_upload_binary
- .run_only_for_package
@@ -713,7 +768,7 @@
needs:
- p:doc-package
-.u:macos-package:
+u:macos-package:
extends:
- .rsync_upload_binary
- .run_only_for_package
@@ -736,7 +791,7 @@
needs:
- p:doc-package
-.u:macos10.10-package:
+u:macos10.10-package:
extends:
- .rsync_upload_binary
- .run_only_for_package
@@ -853,6 +908,66 @@
variables:
CMAKE_CI_JOB_NIGHTLY: "true"
+t:windows-clang13.0-cl-ninja:
+ extends:
+ - .windows_clang_ninja
+ - .cmake_test_windows_clang
+ - .windows_tags_concurrent
+ - .cmake_junit_artifacts
+ - .run_dependent
+ dependencies:
+ - t:windows-vs2022-x64-ninja
+ needs:
+ - t:windows-vs2022-x64-ninja
+ variables:
+ CMAKE_CI_BUILD_NAME: windows_clang13.0_cl_ninja
+ CMAKE_CI_JOB_NIGHTLY: "true"
+
+t:windows-clang13.0-cl-nmake:
+ extends:
+ - .windows_clang_nmake
+ - .cmake_test_windows_clang
+ - .windows_tags_concurrent
+ - .cmake_junit_artifacts
+ - .run_dependent
+ dependencies:
+ - t:windows-vs2022-x64-ninja
+ needs:
+ - t:windows-vs2022-x64-ninja
+ variables:
+ CMAKE_CI_BUILD_NAME: windows_clang13.0_cl_nmake
+ CMAKE_CI_JOB_NIGHTLY: "true"
+
+t:windows-clang13.0-gnu-ninja:
+ extends:
+ - .windows_clang_ninja
+ - .cmake_test_windows_clang
+ - .windows_tags_concurrent
+ - .cmake_junit_artifacts
+ - .run_dependent
+ dependencies:
+ - t:windows-vs2022-x64-ninja
+ needs:
+ - t:windows-vs2022-x64-ninja
+ variables:
+ CMAKE_CI_BUILD_NAME: windows_clang13.0_gnu_ninja
+ CMAKE_CI_JOB_NIGHTLY: "true"
+
+t:windows-clang13.0-gnu-nmake:
+ extends:
+ - .windows_clang_nmake
+ - .cmake_test_windows_clang
+ - .windows_tags_concurrent
+ - .cmake_junit_artifacts
+ - .run_dependent
+ dependencies:
+ - t:windows-vs2022-x64-ninja
+ needs:
+ - t:windows-vs2022-x64-ninja
+ variables:
+ CMAKE_CI_BUILD_NAME: windows_clang13.0_gnu_nmake
+ CMAKE_CI_JOB_NIGHTLY: "true"
+
t:windows-msvc-v71-nmake:
extends:
- .windows_msvc_v71_nmake
diff --git a/.gitlab/ci/clang.ps1 b/.gitlab/ci/clang.ps1
new file mode 100755
index 0000000..25d64ba
--- /dev/null
+++ b/.gitlab/ci/clang.ps1
@@ -0,0 +1,37 @@
+$erroractionpreference = "stop"
+
+if ("$env:CMAKE_CI_BUILD_NAME".Contains("clang13.0")) {
+ # LLVM/Clang 13.0
+ # https://github.com/llvm/llvm-project/releases/tag/llvmorg-13.0.0
+ $filename = "llvm-13.0.0-win-x86_64-1"
+ $sha256sum = "F1B7CE360DACBC9776D7F84BE714766D60CF3D47492AFE34C45D574D1C597264"
+} else {
+ throw ('unknown CMAKE_CI_BUILD_NAME: ' + "$env:CMAKE_CI_BUILD_NAME")
+}
+$tarball = "$filename.zip"
+
+$outdir = $pwd.Path
+$outdir = "$outdir\.gitlab"
+$ProgressPreference = 'SilentlyContinue'
+# This URL is only visible inside of Kitware's network. See above filename table.
+Invoke-WebRequest -Uri "https://cmake.org/files/dependencies/internal/$tarball" -OutFile "$outdir\$tarball"
+$hash = Get-FileHash "$outdir\$tarball" -Algorithm SHA256
+if ($hash.Hash -ne $sha256sum) {
+ exit 1
+}
+
+Add-Type -AssemblyName System.IO.Compression.FileSystem
+[System.IO.Compression.ZipFile]::ExtractToDirectory("$outdir\$tarball", "$outdir")
+Move-Item -Path "$outdir\$filename" -Destination "$outdir\llvm"
+
+$bin = "$outdir\llvm\bin"
+$null = New-Item -ItemType HardLink -Path "$bin\clang++.exe" -Target "$bin\clang.exe"
+$null = New-Item -ItemType HardLink -Path "$bin\clang-cl.exe" -Target "$bin\clang.exe"
+$null = New-Item -ItemType HardLink -Path "$bin\clang-cpp.exe" -Target "$bin\clang.exe"
+$null = New-Item -ItemType HardLink -Path "$bin\ld.lld.exe" -Target "$bin\lld.exe"
+$null = New-Item -ItemType HardLink -Path "$bin\ld64.lld.exe" -Target "$bin\lld.exe"
+$null = New-Item -ItemType HardLink -Path "$bin\lld-link.exe" -Target "$bin\lld.exe"
+$null = New-Item -ItemType HardLink -Path "$bin\llvm-lib.exe" -Target "$bin\llvm-ar.exe"
+$null = New-Item -ItemType HardLink -Path "$bin\llvm-ranlib.exe" -Target "$bin\llvm-ar.exe"
+$null = New-Item -ItemType HardLink -Path "$bin\llvm-objcopy.exe" -Target "$bin\llvm-strip.exe"
+Clear-Variable -Name bin
diff --git a/.gitlab/ci/configure_common.cmake b/.gitlab/ci/configure_common.cmake
index a711f3b..ed3d18d 100644
--- a/.gitlab/ci/configure_common.cmake
+++ b/.gitlab/ci/configure_common.cmake
@@ -1,4 +1,11 @@
-set(CTEST_USE_LAUNCHERS "ON" CACHE BOOL "")
+if("$ENV{CMAKE_CI_BOOTSTRAP}")
+ # Launchers do not work during bootstrap: no ctest available.
+ set(CTEST_USE_LAUNCHERS "OFF" CACHE BOOL "")
+ # We configure by bootstrapping, so skip the BootstrapTest.
+ set(CMAKE_SKIP_BOOTSTRAP_TEST ON CACHE BOOL "")
+else()
+ set(CTEST_USE_LAUNCHERS "ON" CACHE BOOL "")
+endif()
# We run the install right after the build. Avoid rerunning it when installing.
set(CMAKE_SKIP_INSTALL_ALL_DEPENDENCY "ON" CACHE BOOL "")
diff --git a/.gitlab/ci/configure_debian10_aarch64_ninja.cmake b/.gitlab/ci/configure_debian10_aarch64_ninja.cmake
index 8e03eef..5431ab7 100644
--- a/.gitlab/ci/configure_debian10_aarch64_ninja.cmake
+++ b/.gitlab/ci/configure_debian10_aarch64_ninja.cmake
@@ -1,3 +1,8 @@
+set(CMake_TEST_CTestUpdate_BZR "ON" CACHE BOOL "")
+set(CMake_TEST_CTestUpdate_CVS "ON" CACHE BOOL "")
+set(CMake_TEST_CTestUpdate_GIT "ON" CACHE BOOL "")
+set(CMake_TEST_CTestUpdate_HG "ON" CACHE BOOL "")
+set(CMake_TEST_CTestUpdate_SVN "ON" CACHE BOOL "")
set(CMake_TEST_FindALSA "ON" CACHE BOOL "")
set(CMake_TEST_FindBLAS "All;static=1;Generic" CACHE STRING "")
set(CMake_TEST_FindBoost "ON" CACHE BOOL "")
diff --git a/.gitlab/ci/configure_debian10_makefiles_inplace.cmake b/.gitlab/ci/configure_debian10_makefiles_inplace.cmake
new file mode 100644
index 0000000..33f0db0
--- /dev/null
+++ b/.gitlab/ci/configure_debian10_makefiles_inplace.cmake
@@ -0,0 +1 @@
+include("${CMAKE_CURRENT_LIST_DIR}/configure_common.cmake")
diff --git a/.gitlab/ci/configure_debian10_ninja.cmake b/.gitlab/ci/configure_debian10_ninja.cmake
index d50ab1f..8cf3835 100644
--- a/.gitlab/ci/configure_debian10_ninja.cmake
+++ b/.gitlab/ci/configure_debian10_ninja.cmake
@@ -1,3 +1,12 @@
+set(CMake_TEST_CTestUpdate_BZR "ON" CACHE BOOL "")
+set(CMake_TEST_CTestUpdate_CVS "ON" CACHE BOOL "")
+set(CMake_TEST_CTestUpdate_GIT "ON" CACHE BOOL "")
+set(CMake_TEST_CTestUpdate_HG "ON" CACHE BOOL "")
+set(CMake_TEST_CTestUpdate_SVN "ON" CACHE BOOL "")
+if (NOT "$ENV{CMAKE_CI_NIGHTLY}" STREQUAL "")
+ set(CMake_TEST_CTestUpdate_P4 "ON" CACHE BOOL "")
+endif()
+
set(CMake_TEST_FindALSA "ON" CACHE BOOL "")
set(CMake_TEST_FindBLAS "All;static=1;Generic" CACHE STRING "")
set(CMake_TEST_FindBoost "ON" CACHE BOOL "")
@@ -68,4 +77,8 @@
set(CMake_TEST_Qt5 "ON" CACHE BOOL "")
set(CMake_TEST_UseSWIG "ON" CACHE BOOL "")
+if (NOT "$ENV{SWIFTC}" STREQUAL "")
+ set(CMAKE_Swift_COMPILER "$ENV{SWIFTC}" CACHE FILEPATH "")
+endif()
+
include("${CMAKE_CURRENT_LIST_DIR}/configure_external_test.cmake")
diff --git a/.gitlab/ci/configure_fedora35_makefiles.cmake b/.gitlab/ci/configure_fedora35_makefiles.cmake
index a482378..91ed55b 100644
--- a/.gitlab/ci/configure_fedora35_makefiles.cmake
+++ b/.gitlab/ci/configure_fedora35_makefiles.cmake
@@ -1,3 +1,11 @@
+set(CMake_TEST_CTestUpdate_BZR "ON" CACHE BOOL "")
+set(CMake_TEST_CTestUpdate_GIT "ON" CACHE BOOL "")
+set(CMake_TEST_CTestUpdate_HG "ON" CACHE BOOL "")
+set(CMake_TEST_CTestUpdate_SVN "ON" CACHE BOOL "")
+if (NOT "$ENV{CMAKE_CI_NIGHTLY}" STREQUAL "")
+ set(CMake_TEST_CTestUpdate_P4 "ON" CACHE BOOL "")
+endif()
+
set(CMake_TEST_FindALSA "ON" CACHE BOOL "")
set(CMake_TEST_FindBLAS "All;static=1;Generic" CACHE STRING "")
set(CMake_TEST_FindBoost "ON" CACHE BOOL "")
diff --git a/.gitlab/ci/configure_windows_borland_common.cmake b/.gitlab/ci/configure_windows_borland_common.cmake
index 6d66a05..55dce1d 100644
--- a/.gitlab/ci/configure_windows_borland_common.cmake
+++ b/.gitlab/ci/configure_windows_borland_common.cmake
@@ -1,2 +1,5 @@
+set(CMake_TEST_Java OFF CACHE BOOL "")
+
set(configure_no_sccache 1)
+
include("${CMAKE_CURRENT_LIST_DIR}/configure_external_test.cmake")
diff --git a/.gitlab/ci/configure_windows_clang_common.cmake b/.gitlab/ci/configure_windows_clang_common.cmake
new file mode 100644
index 0000000..55dce1d
--- /dev/null
+++ b/.gitlab/ci/configure_windows_clang_common.cmake
@@ -0,0 +1,5 @@
+set(CMake_TEST_Java OFF CACHE BOOL "")
+
+set(configure_no_sccache 1)
+
+include("${CMAKE_CURRENT_LIST_DIR}/configure_external_test.cmake")
diff --git a/.gitlab/ci/configure_windows_clang_ninja.cmake b/.gitlab/ci/configure_windows_clang_ninja.cmake
new file mode 100644
index 0000000..ba19834
--- /dev/null
+++ b/.gitlab/ci/configure_windows_clang_ninja.cmake
@@ -0,0 +1 @@
+include("${CMAKE_CURRENT_LIST_DIR}/configure_windows_clang_common.cmake")
diff --git a/.gitlab/ci/configure_windows_clang_nmake.cmake b/.gitlab/ci/configure_windows_clang_nmake.cmake
new file mode 100644
index 0000000..ba19834
--- /dev/null
+++ b/.gitlab/ci/configure_windows_clang_nmake.cmake
@@ -0,0 +1 @@
+include("${CMAKE_CURRENT_LIST_DIR}/configure_windows_clang_common.cmake")
diff --git a/.gitlab/ci/configure_windows_openwatcom_common.cmake b/.gitlab/ci/configure_windows_openwatcom_common.cmake
index 6d66a05..55dce1d 100644
--- a/.gitlab/ci/configure_windows_openwatcom_common.cmake
+++ b/.gitlab/ci/configure_windows_openwatcom_common.cmake
@@ -1,2 +1,5 @@
+set(CMake_TEST_Java OFF CACHE BOOL "")
+
set(configure_no_sccache 1)
+
include("${CMAKE_CURRENT_LIST_DIR}/configure_external_test.cmake")
diff --git a/.gitlab/ci/ctest_build.cmake b/.gitlab/ci/ctest_build.cmake
index e7a0985..4bb2924 100644
--- a/.gitlab/ci/ctest_build.cmake
+++ b/.gitlab/ci/ctest_build.cmake
@@ -37,7 +37,7 @@
"Found ${num_warnings} warnings (treating as fatal).")
endif ()
-if (NOT "$ENV{CMake_SKIP_INSTALL}")
+if (NOT "$ENV{CMAKE_CI_NO_INSTALL}")
ctest_build(APPEND
TARGET install
RETURN_VALUE install_result)
diff --git a/.gitlab/ci/ctest_test_external.cmake b/.gitlab/ci/ctest_standalone.cmake
similarity index 94%
rename from .gitlab/ci/ctest_test_external.cmake
rename to .gitlab/ci/ctest_standalone.cmake
index 48e910b..9199693 100644
--- a/.gitlab/ci/ctest_test_external.cmake
+++ b/.gitlab/ci/ctest_standalone.cmake
@@ -6,6 +6,14 @@
set(cmake_args
-C "${CMAKE_CURRENT_LIST_DIR}/configure_$ENV{CMAKE_CONFIGURATION}.cmake")
+include(ProcessorCount)
+ProcessorCount(nproc)
+if (NOT "$ENV{CTEST_MAX_PARALLELISM}" STREQUAL "")
+ if (nproc GREATER "$ENV{CTEST_MAX_PARALLELISM}")
+ set(nproc "$ENV{CTEST_MAX_PARALLELISM}")
+ endif ()
+endif ()
+
# Create an entry in CDash.
ctest_start("${ctest_model}" GROUP "${ctest_group}")
@@ -15,6 +23,10 @@
set(CTEST_UPDATE_COMMAND "${GIT_EXECUTABLE}")
ctest_update()
+if("$ENV{CMAKE_CI_BOOTSTRAP}")
+ set(CTEST_CONFIGURE_COMMAND "\"${CTEST_SOURCE_DIRECTORY}/bootstrap\" --parallel=${nproc}")
+endif()
+
# Configure the project.
ctest_configure(
OPTIONS "${cmake_args}"
@@ -33,14 +45,6 @@
"Failed to configure")
endif ()
-include(ProcessorCount)
-ProcessorCount(nproc)
-if (NOT "$ENV{CTEST_MAX_PARALLELISM}" STREQUAL "")
- if (nproc GREATER "$ENV{CTEST_MAX_PARALLELISM}")
- set(nproc "$ENV{CTEST_MAX_PARALLELISM}")
- endif ()
-endif ()
-
if (CTEST_CMAKE_GENERATOR STREQUAL "Unix Makefiles")
set(CTEST_BUILD_FLAGS "-j${nproc} -l${nproc}")
elseif (CTEST_CMAKE_GENERATOR MATCHES "Ninja")
diff --git a/.gitlab/ci/docker/debian10-aarch64/install_deps.sh b/.gitlab/ci/docker/debian10-aarch64/install_deps.sh
index d5c5e22..21f0b16 100755
--- a/.gitlab/ci/docker/debian10-aarch64/install_deps.sh
+++ b/.gitlab/ci/docker/debian10-aarch64/install_deps.sh
@@ -25,6 +25,7 @@
# Packages needed to test CTest.
apt-get install -y \
+ bzr bzr-xmloutput \
cvs \
subversion \
mercurial
diff --git a/.gitlab/ci/docker/debian10/install_deps.sh b/.gitlab/ci/docker/debian10/install_deps.sh
index d3d6b67..1c112dd 100755
--- a/.gitlab/ci/docker/debian10/install_deps.sh
+++ b/.gitlab/ci/docker/debian10/install_deps.sh
@@ -25,10 +25,15 @@
# Packages needed to test CTest.
apt-get install -y \
+ bzr bzr-xmloutput \
cvs \
subversion \
mercurial
+# Install swift runtime deps.
+apt-get install -y \
+ libncurses5
+
# Packages needed to test find modules.
apt-get install -y \
alsa-utils \
@@ -86,7 +91,16 @@
apt-get install -y \
libmono-system-windows-forms4.0-cil
curl -L -O https://github.com/IronLanguages/ironpython2/releases/download/ipy-2.7.10/ironpython_2.7.10.deb
+echo 'e1aceec1d49ffa66e9059a52168a734999dcccc50164a60e2936649cae698f3e ironpython_2.7.10.deb' > ironpython.sha256sum
+sha256sum --check ironpython.sha256sum
dpkg -i ironpython_2.7.10.deb
-rm ironpython_2.7.10.deb
+rm ironpython_2.7.10.deb ironpython.sha256sum
+
+# Perforce
+curl -L -O https://www.perforce.com/downloads/perforce/r21.2/bin.linux26x86_64/helix-core-server.tgz
+echo '72620c55e9389705582506d6f3388005fb4f674888a00a12a51edc2ae37823b3 helix-core-server.tgz' > helix.sha256sum
+sha256sum --check helix.sha256sum
+tar -C /usr/local/bin -xvzf helix-core-server.tgz -- p4 p4d
+rm helix-core-server.tgz helix.sha256sum
apt-get clean
diff --git a/.gitlab/ci/docker/fedora35/install_deps.sh b/.gitlab/ci/docker/fedora35/install_deps.sh
index 30214af..038000c 100755
--- a/.gitlab/ci/docker/fedora35/install_deps.sh
+++ b/.gitlab/ci/docker/fedora35/install_deps.sh
@@ -38,6 +38,7 @@
# Packages needed to test CTest.
dnf install --setopt=install_weak_deps=False -y \
+ breezy \
subversion \
mercurial
@@ -106,3 +107,10 @@
python2 get-pip.py
rm get-pip.py
pip2.7 install numpy
+
+# Perforce
+curl -L -O https://www.perforce.com/downloads/perforce/r21.2/bin.linux26x86_64/helix-core-server.tgz
+echo '72620c55e9389705582506d6f3388005fb4f674888a00a12a51edc2ae37823b3 helix-core-server.tgz' > helix.sha256sum
+sha256sum --check helix.sha256sum
+tar -C /usr/local/bin -xvzf helix-core-server.tgz -- p4 p4d
+rm helix-core-server.tgz
diff --git a/.gitlab/ci/env_debian10_ninja.cmake b/.gitlab/ci/env_debian10_ninja.cmake
deleted file mode 100644
index ec252b4..0000000
--- a/.gitlab/ci/env_debian10_ninja.cmake
+++ /dev/null
@@ -1 +0,0 @@
-set(ENV{MY_RUBY_HOME} "/usr/local/rvm/rubies/ruby-2.7.0")
diff --git a/.gitlab/ci/env_debian10_ninja.sh b/.gitlab/ci/env_debian10_ninja.sh
new file mode 100644
index 0000000..67d900c
--- /dev/null
+++ b/.gitlab/ci/env_debian10_ninja.sh
@@ -0,0 +1,11 @@
+export MY_RUBY_HOME="/usr/local/rvm/rubies/ruby-2.7.0"
+
+if test -z "$CI_MERGE_REQUEST_ID"; then
+ curl -L -O "https://download.swift.org/swift-5.5.3-release/ubuntu1804/swift-5.5.3-RELEASE/swift-5.5.3-RELEASE-ubuntu18.04.tar.gz"
+ echo '910634e2d97e14c43ed1f29caeb57fd01d10c2ff88cebb79baee1016b52c7492 swift-5.5.3-RELEASE-ubuntu18.04.tar.gz' > swift.sha256sum
+ sha256sum --check swift.sha256sum
+ mkdir /opt/swift
+ tar xzf swift-5.5.3-RELEASE-ubuntu18.04.tar.gz -C /opt/swift --strip-components=2
+ rm swift-5.5.3-RELEASE-ubuntu18.04.tar.gz swift.sha256sum
+ export SWIFTC="/opt/swift/bin/swiftc"
+fi
diff --git a/.gitlab/ci/env_windows_clang_common.cmake b/.gitlab/ci/env_windows_clang_common.cmake
new file mode 100644
index 0000000..fdd668f
--- /dev/null
+++ b/.gitlab/ci/env_windows_clang_common.cmake
@@ -0,0 +1,7 @@
+if("$ENV{CMAKE_CI_BUILD_NAME}" MATCHES "(^|_)gnu(_|$)")
+ set(ENV{CC} clang)
+ set(ENV{CXX} clang++)
+else()
+ set(ENV{CC} clang-cl)
+ set(ENV{CXX} clang-cl)
+endif()
diff --git a/.gitlab/ci/env_windows_clang_ninja.cmake b/.gitlab/ci/env_windows_clang_ninja.cmake
new file mode 100644
index 0000000..f3834a2
--- /dev/null
+++ b/.gitlab/ci/env_windows_clang_ninja.cmake
@@ -0,0 +1 @@
+include("${CMAKE_CURRENT_LIST_DIR}/env_windows_clang_common.cmake")
diff --git a/.gitlab/ci/env_windows_clang_nmake.cmake b/.gitlab/ci/env_windows_clang_nmake.cmake
new file mode 100644
index 0000000..f3834a2
--- /dev/null
+++ b/.gitlab/ci/env_windows_clang_nmake.cmake
@@ -0,0 +1 @@
+include("${CMAKE_CURRENT_LIST_DIR}/env_windows_clang_common.cmake")
diff --git a/.gitlab/ci/gitlab_ci.cmake b/.gitlab/ci/gitlab_ci.cmake
index 697162c..080c93b 100644
--- a/.gitlab/ci/gitlab_ci.cmake
+++ b/.gitlab/ci/gitlab_ci.cmake
@@ -5,7 +5,11 @@
# Set up the source and build paths.
set(CTEST_SOURCE_DIRECTORY "$ENV{CI_PROJECT_DIR}")
-set(CTEST_BINARY_DIRECTORY "${CTEST_SOURCE_DIRECTORY}/build")
+if("$ENV{CMAKE_CI_INPLACE}")
+ set(CTEST_BINARY_DIRECTORY "${CTEST_SOURCE_DIRECTORY}")
+else()
+ set(CTEST_BINARY_DIRECTORY "${CTEST_SOURCE_DIRECTORY}/build")
+endif()
if (NOT "$ENV{CTEST_SOURCE_SUBDIRECTORY}" STREQUAL "")
string(APPEND CTEST_SOURCE_DIRECTORY "/$ENV{CTEST_SOURCE_SUBDIRECTORY}")
endif ()
diff --git a/.gitlab/os-linux.yml b/.gitlab/os-linux.yml
index ddcd0d3..30b4fc3 100644
--- a/.gitlab/os-linux.yml
+++ b/.gitlab/os-linux.yml
@@ -45,7 +45,7 @@
### Debian
.debian10:
- image: "kitware/cmake:ci-debian10-x86_64-2021-11-18"
+ image: "kitware/cmake:ci-debian10-x86_64-2022-02-25"
variables:
GIT_CLONE_PATH: "$CI_BUILDS_DIR/cmake ci"
@@ -57,10 +57,10 @@
variables:
CMAKE_CONFIGURATION: debian10_iwyu
CTEST_NO_WARNINGS_ALLOWED: 1
- CMake_SKIP_INSTALL: 1
+ CMAKE_CI_NO_INSTALL: 1
.debian10_aarch64:
- image: "kitware/cmake:ci-debian10-aarch64-2021-11-18"
+ image: "kitware/cmake:ci-debian10-aarch64-2022-02-21"
variables:
GIT_CLONE_PATH: "$CI_BUILDS_DIR/cmake ci"
@@ -69,7 +69,7 @@
### Fedora
.fedora35:
- image: "kitware/cmake:ci-fedora35-x86_64-2022-02-01"
+ image: "kitware/cmake:ci-fedora35-x86_64-2022-02-21"
variables:
GIT_CLONE_PATH: "$CI_BUILDS_DIR/cmake ci/long file name for testing purposes"
@@ -83,7 +83,7 @@
variables:
CMAKE_CONFIGURATION: fedora35_tidy
CTEST_NO_WARNINGS_ALLOWED: 1
- CMake_SKIP_INSTALL: 1
+ CMAKE_CI_NO_INSTALL: 1
.fedora35_clang_analyzer:
extends: .fedora35
@@ -92,7 +92,7 @@
CMAKE_CONFIGURATION: fedora35_clang_analyzer
CMAKE_CI_BUILD_TYPE: Debug
CTEST_NO_WARNINGS_ALLOWED: 1
- CMake_SKIP_INSTALL: 1
+ CMAKE_CI_NO_INSTALL: 1
.fedora35_sphinx:
extends: .fedora35
@@ -101,7 +101,7 @@
CMAKE_CONFIGURATION: fedora35_sphinx
CTEST_NO_WARNINGS_ALLOWED: 1
CTEST_SOURCE_SUBDIRECTORY: "Utilities/Sphinx"
- CMake_SKIP_INSTALL: 1
+ CMAKE_CI_NO_INSTALL: 1
.fedora35_sphinx_package:
extends: .fedora35
@@ -126,6 +126,17 @@
CMAKE_CONFIGURATION: debian10_aarch64_ninja
CTEST_NO_WARNINGS_ALLOWED: 1
+.debian10_makefiles_inplace:
+ extends: .debian10
+
+ variables:
+ CMAKE_CONFIGURATION: debian10_makefiles_inplace
+ CMAKE_GENERATOR: "Unix Makefiles"
+ CMAKE_CI_BOOTSTRAP: 1
+ CMAKE_CI_INPLACE: 1
+ CMAKE_CI_NO_INSTALL: 1
+ CTEST_NO_WARNINGS_ALLOWED: 1
+
.fedora35_ninja:
extends: .fedora35
@@ -216,6 +227,7 @@
GIT_CLONE_PATH: "$CI_BUILDS_DIR/cmake ci"
CMAKE_ARCH: x86_64
CTEST_LABELS: "CUDA"
+ CMAKE_CUDA_ARCHITECTURES_NATIVE_CLAMP: 1
.cuda9.2_nvidia:
extends: .cuda9.2
@@ -231,6 +243,7 @@
GIT_CLONE_PATH: "$CI_BUILDS_DIR/cmake ci"
CMAKE_ARCH: x86_64
CTEST_LABELS: "CUDA"
+ CMAKE_CUDA_ARCHITECTURES_NATIVE_CLAMP: 1
.cuda10.2_nvidia:
extends: .cuda10.2
@@ -253,6 +266,7 @@
GIT_CLONE_PATH: "$CI_BUILDS_DIR/cmake ci"
CMAKE_ARCH: x86_64
CTEST_LABELS: "CUDA"
+ CMAKE_CUDA_ARCHITECTURES_NATIVE_CLAMP: 1
.cuda11.6_nvidia:
extends: .cuda11.6
@@ -451,6 +465,19 @@
interruptible: true
+.cmake_build_linux_standalone:
+ stage: build
+
+ script:
+ - *before_script_linux
+ - .gitlab/ci/sccache.sh
+ - sccache --start-server
+ - sccache --show-stats
+ - "$LAUNCHER ctest --output-on-failure -V -S .gitlab/ci/ctest_standalone.cmake"
+ - sccache --show-stats
+
+ interruptible: true
+
.cmake_test_linux_release:
stage: test-ext
@@ -462,7 +489,7 @@
- .gitlab/ci/sccache.sh
- sccache --start-server
- sccache --show-stats
- - "$LAUNCHER build/install/bin/ctest --output-on-failure -V -S .gitlab/ci/ctest_test_external.cmake"
+ - "$LAUNCHER build/install/bin/ctest --output-on-failure -V -S .gitlab/ci/ctest_standalone.cmake"
- sccache --show-stats
interruptible: true
@@ -475,7 +502,7 @@
- .gitlab/ci/sccache.sh
- sccache --start-server
- sccache --show-stats
- - "$LAUNCHER build/install/bin/ctest --output-on-failure -V -S .gitlab/ci/ctest_test_external.cmake"
+ - "$LAUNCHER build/install/bin/ctest --output-on-failure -V -S .gitlab/ci/ctest_standalone.cmake"
- sccache --show-stats
interruptible: true
diff --git a/.gitlab/os-macos.yml b/.gitlab/os-macos.yml
index b0844cb..e89dba8 100644
--- a/.gitlab/os-macos.yml
+++ b/.gitlab/os-macos.yml
@@ -52,7 +52,7 @@
variables:
CMAKE_CONFIGURATION: macos_package
CTEST_NO_WARNINGS_ALLOWED: 1
- CMake_SKIP_INSTALL: 1
+ CMAKE_CI_NO_INSTALL: 1
.macos10.10_package:
extends: .macos_build
@@ -60,7 +60,7 @@
variables:
CMAKE_CONFIGURATION: macos10.10_package
CTEST_NO_WARNINGS_ALLOWED: 1
- CMake_SKIP_INSTALL: 1
+ CMAKE_CI_NO_INSTALL: 1
### External testing
@@ -182,7 +182,7 @@
# Allow the server to already be running.
- "sccache --start-server || :"
- sccache --show-stats
- - "$LAUNCHER build/install/CMake.app/Contents/bin/ctest --output-on-failure -V -S .gitlab/ci/ctest_test_external.cmake"
+ - "$LAUNCHER build/install/CMake.app/Contents/bin/ctest --output-on-failure -V -S .gitlab/ci/ctest_standalone.cmake"
- sccache --show-stats
interruptible: true
diff --git a/.gitlab/os-windows.yml b/.gitlab/os-windows.yml
index aa971f8..3532765 100644
--- a/.gitlab/os-windows.yml
+++ b/.gitlab/os-windows.yml
@@ -87,6 +87,14 @@
variables:
CMAKE_CONFIGURATION: windows_borland5.8
+.windows_ninja:
+ extends: .windows
+
+ variables:
+ CMAKE_GENERATOR: "Ninja"
+ CMAKE_CI_BUILD_TYPE: Release
+ CMAKE_CI_NIGHTLY_IGNORE_DEPS: "true"
+
.windows_nmake:
extends: .windows
@@ -119,6 +127,22 @@
variables:
CMAKE_CONFIGURATION: windows_vs2022_x64_jom
+.windows_clang_ninja:
+ extends:
+ - .windows_ninja
+ - .windows_vcvarsall_vs2022_x64
+
+ variables:
+ CMAKE_CONFIGURATION: windows_clang_ninja
+
+.windows_clang_nmake:
+ extends:
+ - .windows_nmake
+ - .windows_vcvarsall_vs2022_x64
+
+ variables:
+ CMAKE_CONFIGURATION: windows_clang_nmake
+
.windows_msvc_v71_nmake:
extends: .windows_nmake
@@ -226,7 +250,7 @@
stage: test-ext
script:
- - build/install/bin/ctest --output-on-failure -V -S .gitlab/ci/ctest_test_external.cmake
+ - build/install/bin/ctest --output-on-failure -V -S .gitlab/ci/ctest_standalone.cmake
interruptible: true
@@ -235,7 +259,7 @@
script:
- Invoke-Expression -Command .gitlab/ci/vcvarsall.ps1
- - build/install/bin/ctest --output-on-failure -V -S .gitlab/ci/ctest_test_external.cmake
+ - build/install/bin/ctest --output-on-failure -V -S .gitlab/ci/ctest_standalone.cmake
interruptible: true
@@ -247,7 +271,7 @@
- $pwdpath = $pwd.Path
- Set-Item -Force -Path "env:PATH" -Value "$pwdpath\.gitlab\jom;$env:PATH"
- Invoke-Expression -Command .gitlab/ci/vcvarsall.ps1
- - build/install/bin/ctest --output-on-failure -V -S .gitlab/ci/ctest_test_external.cmake
+ - build/install/bin/ctest --output-on-failure -V -S .gitlab/ci/ctest_standalone.cmake
interruptible: true
@@ -258,7 +282,21 @@
- Invoke-Expression -Command .gitlab/ci/borland.ps1
- $pwdpath = $pwd.Path
- Set-Item -Force -Path "env:PATH" -Value "$pwdpath\.gitlab\bcc\bin;$env:PATH"
- - build/install/bin/ctest --output-on-failure -V -S .gitlab/ci/ctest_test_external.cmake
+ - build/install/bin/ctest --output-on-failure -V -S .gitlab/ci/ctest_standalone.cmake
+
+ interruptible: true
+
+.cmake_test_windows_clang:
+ stage: test-ext
+
+ script:
+ - $pwdpath = $pwd.Path
+ - powershell -File ".gitlab/ci/ninja.ps1"
+ - Set-Item -Force -Path "env:PATH" -Value "$pwdpath\.gitlab;$env:PATH"
+ - Invoke-Expression -Command .gitlab/ci/clang.ps1
+ - Invoke-Expression -Command .gitlab/ci/vcvarsall.ps1
+ - Set-Item -Force -Path "env:PATH" -Value "$pwdpath\.gitlab\llvm\bin;$env:PATH"
+ - build/install/bin/ctest --output-on-failure -V -S .gitlab/ci/ctest_standalone.cmake
interruptible: true
@@ -268,7 +306,7 @@
script:
- Invoke-Expression -Command .gitlab/ci/msvc.ps1
- Invoke-Expression -Command .gitlab/ci/vcvarsall.ps1
- - build/install/bin/ctest --output-on-failure -V -S .gitlab/ci/ctest_test_external.cmake
+ - build/install/bin/ctest --output-on-failure -V -S .gitlab/ci/ctest_standalone.cmake
interruptible: true
@@ -283,6 +321,6 @@
- Set-Item -Force -Path "env:EDPATH" -Value "$pwdpath\.gitlab\watcom\eddat"
- Set-Item -Force -Path "env:WATCOM" -Value "$pwdpath\.gitlab\watcom"
- Set-Item -Force -Path "env:WLINKTMP" -Value "."
- - build/install/bin/ctest --output-on-failure -V -S .gitlab/ci/ctest_test_external.cmake
+ - build/install/bin/ctest --output-on-failure -V -S .gitlab/ci/ctest_standalone.cmake
interruptible: true
diff --git a/.gitlab/rules.yml b/.gitlab/rules.yml
index a871b8f..9302da4 100644
--- a/.gitlab/rules.yml
+++ b/.gitlab/rules.yml
@@ -52,6 +52,8 @@
when: on_success
- if: '$CMAKE_CI_JOB_NIGHTLY == "true"'
when: never
+ - if: '$CMAKE_CI_PROJECT_CONTINUOUS_BRANCH != null && $CI_COMMIT_BRANCH != null && $CMAKE_CI_PROJECT_CONTINUOUS_BRANCH == $CI_COMMIT_BRANCH && $CMAKE_CI_JOB_CONTINUOUS == "true"'
+ when: on_success
- if: '($CMAKE_CI_NO_MR == "true" && $CI_MERGE_REQUEST_ID)'
when: never
- if: '$CI_MERGE_REQUEST_ID'
diff --git a/Auxiliary/vim/syntax/cmake.vim b/Auxiliary/vim/syntax/cmake.vim
index d5361bd..c53d094 100644
--- a/Auxiliary/vim/syntax/cmake.vim
+++ b/Auxiliary/vim/syntax/cmake.vim
@@ -381,6 +381,7 @@
\ VS_JUST_MY_CODE_DEBUGGING
\ VS_KEYWORD
\ VS_MOBILE_EXTENSIONS_VERSION
+ \ VS_NO_COMPILE_BATCHING
\ VS_NO_SOLUTION_DEPLOY
\ VS_PACKAGE_REFERENCES
\ VS_PLATFORM_TOOLSET
@@ -704,6 +705,7 @@
\ CMAKE_CODEBLOCKS_COMPILER_ID
\ CMAKE_CODEBLOCKS_EXCLUDE_EXTERNAL_FILES
\ CMAKE_CODELITE_USE_TARGETS
+ \ CMAKE_COLOR_DIAGNOSTICS
\ CMAKE_COLOR_MAKEFILE
\ CMAKE_COMMAND
\ CMAKE_COMPILER_2005
@@ -1572,6 +1574,7 @@
\ CTEST_CUSTOM_MAXIMUM_NUMBER_OF_ERRORS
\ CTEST_CUSTOM_MAXIMUM_NUMBER_OF_WARNINGS
\ CTEST_CUSTOM_MAXIMUM_PASSED_TEST_OUTPUT_SIZE
+ \ CTEST_CUSTOM_TEST_OUTPUT_TRUNCATION
\ CTEST_CUSTOM_MEMCHECK_IGNORE
\ CTEST_CUSTOM_POST_MEMCHECK
\ CTEST_CUSTOM_POST_TEST
diff --git a/CMakeLists.txt b/CMakeLists.txt
index b2ab30e..9de5338 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -1,7 +1,7 @@
# Distributed under the OSI-approved BSD 3-Clause License. See accompanying
# file Copyright.txt or https://cmake.org/licensing for details.
-cmake_minimum_required(VERSION 3.1...3.21 FATAL_ERROR)
+cmake_minimum_required(VERSION 3.13...3.22 FATAL_ERROR)
set(CMAKE_USER_MAKE_RULES_OVERRIDE_C ${CMAKE_CURRENT_SOURCE_DIR}/Source/Modules/OverrideC.cmake)
set(CMAKE_USER_MAKE_RULES_OVERRIDE_CXX ${CMAKE_CURRENT_SOURCE_DIR}/Source/Modules/OverrideCXX.cmake)
@@ -606,25 +606,40 @@
set(ZLIB_INCLUDE_DIR ${CMAKE_ZLIB_INCLUDES})
set(ZLIB_LIBRARY ${CMAKE_ZLIB_LIBRARIES})
add_definitions(-DLIBARCHIVE_STATIC)
- set(ENABLE_MBEDTLS OFF CACHE INTERNAL "Enable use of mbed TLS")
- set(ENABLE_NETTLE OFF CACHE INTERNAL "Enable use of Nettle")
- set(ENABLE_OPENSSL ${CMAKE_USE_OPENSSL} CACHE INTERNAL "Enable use of OpenSSL")
- set(ENABLE_LIBB2 OFF CACHE INTERNAL "Enable the use of the system LIBB2 library if found")
- set(ENABLE_LZMA ON CACHE INTERNAL "Enable the use of the system LZMA library if found")
- set(ENABLE_LZ4 OFF CACHE INTERNAL "Enable the use of the system LZ4 library if found")
- set(ENABLE_LZO OFF CACHE INTERNAL "Enable the use of the system LZO library if found")
- set(ENABLE_ZLIB ON CACHE INTERNAL "Enable the use of the system ZLIB library if found")
- set(ENABLE_BZip2 ON CACHE INTERNAL "Enable the use of the system BZip2 library if found")
- set(ENABLE_ZSTD ON CACHE INTERNAL "Enable the use of the system zstd library if found")
- set(ENABLE_LIBXML2 OFF CACHE INTERNAL "Enable the use of the system libxml2 library if found")
- set(ENABLE_EXPAT OFF CACHE INTERNAL "Enable the use of the system EXPAT library if found")
- set(ENABLE_PCREPOSIX OFF CACHE INTERNAL "Enable the use of the system PCREPOSIX library if found")
- set(ENABLE_LibGCC OFF CACHE INTERNAL "Enable the use of the system LibGCC library if found")
- set(ENABLE_XATTR OFF CACHE INTERNAL "Enable extended attribute support")
- set(ENABLE_ACL OFF CACHE INTERNAL "Enable ACL support")
- set(ENABLE_ICONV OFF CACHE INTERNAL "Enable iconv support")
- set(ENABLE_CNG OFF CACHE INTERNAL "Enable the use of CNG(Crypto Next Generation)")
- SET(POSIX_REGEX_LIB "" CACHE INTERNAL "Choose what library should provide POSIX regular expression support")
+ set(ENABLE_MBEDTLS OFF)
+ set(ENABLE_NETTLE OFF)
+ if(DEFINED CMAKE_USE_OPENSSL)
+ set(ENABLE_OPENSSL "${CMAKE_USE_OPENSSL}")
+ else()
+ set(ENABLE_OPENSSL OFF)
+ endif()
+ set(ENABLE_LIBB2 OFF)
+ set(ENABLE_LZ4 OFF)
+ set(ENABLE_LZO OFF)
+ set(ENABLE_LZMA ON)
+ set(ENABLE_ZSTD ON)
+ set(ENABLE_ZLIB ON)
+ set(ENABLE_BZip2 ON)
+ set(ENABLE_LIBXML2 OFF)
+ set(ENABLE_EXPAT OFF)
+ set(ENABLE_PCREPOSIX OFF)
+ set(ENABLE_LibGCC OFF)
+ set(ENABLE_CNG OFF)
+ set(ENABLE_TAR OFF)
+ set(ENABLE_TAR_SHARED OFF)
+ set(ENABLE_CPIO OFF)
+ set(ENABLE_CPIO_SHARED OFF)
+ set(ENABLE_CAT OFF)
+ set(ENABLE_CAT_SHARED OFF)
+ set(ENABLE_XATTR OFF)
+ set(ENABLE_ACL OFF)
+ set(ENABLE_ICONV OFF)
+ set(ENABLE_TEST OFF)
+ set(ENABLE_COVERAGE OFF)
+ set(ENABLE_INSTALL OFF)
+ set(POSIX_REGEX_LIB "" CACHE INTERNAL "libarchive: No POSIX regular expression support")
+ set(ENABLE_SAFESEH "" CACHE INTERNAL "libarchive: No /SAFESEH linker flag")
+ set(WINDOWS_VERSION "WIN7" CACHE INTERNAL "libarchive: Set Windows version to use (Windows only)")
add_subdirectory(Utilities/cmlibarchive)
CMAKE_SET_TARGET_FOLDER(cmlibarchive "Utilities/3rdParty")
set(CMAKE_TAR_LIBRARIES cmlibarchive ${BZIP2_LIBRARIES})
diff --git a/Help/command/ctest_test.rst b/Help/command/ctest_test.rst
index 6a9a6a0..11ebdbd 100644
--- a/Help/command/ctest_test.rst
+++ b/Help/command/ctest_test.rst
@@ -172,8 +172,9 @@
affected. Summary info detailing the percentage of passing tests is also
unaffected by the ``QUIET`` option.
-See also the :variable:`CTEST_CUSTOM_MAXIMUM_PASSED_TEST_OUTPUT_SIZE`
-and :variable:`CTEST_CUSTOM_MAXIMUM_FAILED_TEST_OUTPUT_SIZE` variables.
+See also the :variable:`CTEST_CUSTOM_MAXIMUM_PASSED_TEST_OUTPUT_SIZE`,
+:variable:`CTEST_CUSTOM_MAXIMUM_FAILED_TEST_OUTPUT_SIZE` and
+:variable:`CTEST_CUSTOM_TEST_OUTPUT_TRUNCATION` variables.
.. _`Additional Test Measurements`:
diff --git a/Help/command/file.rst b/Help/command/file.rst
index 799b6ff..2769577 100644
--- a/Help/command/file.rst
+++ b/Help/command/file.rst
@@ -1128,6 +1128,18 @@
Historical short-hand for ``EXPECTED_HASH MD5=<value>``. It is an error to
specify this if ``DOWNLOAD`` is not given a ``<file>``.
+``RANGE_START <value>``
+ .. versionadded:: 3.24
+
+ Offset of the start of the range in file in bytes. Could be omitted to
+ download up to the specified ``RANGE_END``.
+
+``RANGE_END <value>``
+ .. versionadded:: 3.24
+
+ Offset of the end of the range in file in bytes. Could be omitted to
+ download everything from the specified ``RANGE_START`` to the end of file.
+
Locking
^^^^^^^
diff --git a/Help/command/find_package.rst b/Help/command/find_package.rst
index 5acefad..e43b7bd 100644
--- a/Help/command/find_package.rst
+++ b/Help/command/find_package.rst
@@ -79,7 +79,8 @@
find_package(<PackageName> [version] [EXACT] [QUIET] [MODULE]
[REQUIRED] [[COMPONENTS] [components...]]
[OPTIONAL_COMPONENTS components...]
- [NO_POLICY_SCOPE])
+ [NO_POLICY_SCOPE]
+ [GLOBAL])
The basic signature is supported by both Module and Config modes.
The ``MODULE`` keyword implies that only Module mode can be used to find
@@ -115,6 +116,11 @@
should find all components, no components or some well-defined subset of the
available components.
+Specifying the ``GLOBAL`` keyword will promote all imported targets to
+a global scope in the importing project. Alternatively this functionality
+can be enabled by setting the variable
+:variable:`CMAKE_FIND_PACKAGE_TARGETS_GLOBAL`
+
.. _FIND_PACKAGE_VERSION_FORMAT:
The ``[version]`` argument requests a version with which the package found
diff --git a/Help/envvar/CMAKE_COLOR_DIAGNOSTICS.rst b/Help/envvar/CMAKE_COLOR_DIAGNOSTICS.rst
new file mode 100644
index 0000000..d3d0aa9
--- /dev/null
+++ b/Help/envvar/CMAKE_COLOR_DIAGNOSTICS.rst
@@ -0,0 +1,9 @@
+CMAKE_COLOR_DIAGNOSTICS
+-----------------------
+
+.. versionadded:: 3.24
+
+.. include:: ENV_VAR.txt
+
+Specifies a default value for the :variable:`CMAKE_COLOR_DIAGNOSTICS` variable
+when there is no explicit value given on the first run.
diff --git a/Help/manual/cmake-env-variables.7.rst b/Help/manual/cmake-env-variables.7.rst
index 0799fdd..fc14262 100644
--- a/Help/manual/cmake-env-variables.7.rst
+++ b/Help/manual/cmake-env-variables.7.rst
@@ -31,6 +31,7 @@
/envvar/CMAKE_APPLE_SILICON_PROCESSOR
/envvar/CMAKE_BUILD_PARALLEL_LEVEL
/envvar/CMAKE_BUILD_TYPE
+ /envvar/CMAKE_COLOR_DIAGNOSTICS
/envvar/CMAKE_CONFIGURATION_TYPES
/envvar/CMAKE_CONFIG_TYPE
/envvar/CMAKE_EXPORT_COMPILE_COMMANDS
diff --git a/Help/manual/cmake-generator-expressions.7.rst b/Help/manual/cmake-generator-expressions.7.rst
index df13dd0..b79cf3a 100644
--- a/Help/manual/cmake-generator-expressions.7.rst
+++ b/Help/manual/cmake-generator-expressions.7.rst
@@ -1113,6 +1113,234 @@
property, perhaps via the :command:`target_link_libraries` command,
to specify private link dependencies without other usage requirements.
+.. genex:: $<LINK_LIBRARY:feature,library-list>
+
+ .. versionadded:: 3.24
+
+ Manage how libraries are specified during the link step.
+ This expression may be used to specify how to link libraries in a target.
+ For example:
+
+ .. code-block:: cmake
+
+ add_library(lib1 STATIC ...)
+ add_library(lib2 ...)
+ target_link_libraries(lib2 PRIVATE "$<LINK_LIBRARY:load_archive,lib1>")
+
+ This specify to use the ``lib1`` target with feature ``load_archive`` for
+ linking target ``lib2``. The feature must have be defined by
+ :variable:`CMAKE_<LANG>_LINK_LIBRARY_USING_<FEATURE>` variable or, if
+ :variable:`CMAKE_<LANG>_LINK_LIBRARY_USING_<FEATURE>_SUPPORTED` is false,
+ by :variable:`CMAKE_LINK_LIBRARY_USING_<FEATURE>` variable.
+
+ .. note::
+
+ The evaluation of this generator expression will use, for the following
+ variables, the values defined at the level of the creation of the target:
+
+ * :variable:`CMAKE_<LANG>_LINK_LIBRARY_USING_<FEATURE>_SUPPORTED`
+ * :variable:`CMAKE_<LANG>_LINK_LIBRARY_USING_<FEATURE>`
+ * :variable:`CMAKE_LINK_LIBRARY_USING_<FEATURE>_SUPPORTED`
+ * :variable:`CMAKE_LINK_LIBRARY_USING_<FEATURE>`
+
+ This expression can only be used to specify link libraries (i.e. part of
+ :command:`link_libraries` or :command:`target_link_libraries` commands and
+ :prop_tgt:`LINK_LIBRARIES` or :prop_tgt:`INTERFACE_LINK_LIBRARIES` target
+ properties).
+
+ .. note::
+
+ If this expression appears in the :prop_tgt:`INTERFACE_LINK_LIBRARIES`
+ property of a target, it will be included in the imported target generated
+ by :command:`install(EXPORT)` command. It is the responsibility of the
+ environment consuming this import to define the link feature used by this
+ expression.
+
+ The ``library-list`` argument can hold CMake targets or external libraries.
+ Any CMake target of type :ref:`OBJECT <Object Libraries>` or
+ :ref:`INTERFACE <Interface Libraries>` will be ignored by this expression and
+ will be handled in the standard way.
+
+ Each target or external library involved in the link step must have only one
+ kind of feature (the absence of feature is also incompatible with any
+ feature). For example:
+
+ .. code-block:: cmake
+
+ add_library(lib1 ...)
+
+ add_library(lib2 ...)
+ target_link_libraries(lib2 PUBLIC "$<LINK_LIBRARY:feature1,lib1>")
+
+ add_library(lib3 ...)
+ target_link_libraries(lib3 PRIVATE lib1 lib2)
+ # an error will be raised here because lib1 has two different features
+
+ To resolve such incompatibilities, the :prop_tgt:`LINK_LIBRARY_OVERRIDE`
+ and :prop_tgt:`LINK_LIBRARY_OVERRIDE_<LIBRARY>` target properties can be
+ used.
+
+ .. note::
+
+ This expression does not guarantee that the list of specified libraries
+ will be kept grouped. So, to manage constructs like ``start-group`` and
+ ``end-group``, as supported by ``GNU ld``, the :genex:`LINK_GROUP`
+ generator expression can be used.
+
+ CMake pre-defines some features of general interest:
+
+ .. include:: ../variable/LINK_LIBRARY_PREDEFINED_FEATURES.txt
+
+.. genex:: $<LINK_GROUP:feature,library-list>
+
+ .. versionadded:: 3.24
+
+ Manage the grouping of libraries during the link step.
+ This expression may be used to specify how to kept groups of libraries during
+ the link of a target.
+ For example:
+
+ .. code-block:: cmake
+
+ add_library(lib1 STATIC ...)
+ add_library(lib2 ...)
+ target_link_libraries(lib2 PRIVATE "$<LINK_GROUP:cross_refs,lib1,external>")
+
+ This specify to use the ``lib1`` target and ``external`` library with the
+ group feature ``cross_refs`` for linking target ``lib2``. The feature must
+ have be defined by :variable:`CMAKE_<LANG>_LINK_GROUP_USING_<FEATURE>`
+ variable or, if :variable:`CMAKE_<LANG>_LINK_GROUP_USING_<FEATURE>_SUPPORTED`
+ is false, by :variable:`CMAKE_LINK_GROUP_USING_<FEATURE>` variable.
+
+ .. note::
+
+ The evaluation of this generator expression will use, for the following
+ variables, the values defined at the level of the creation of the target:
+
+ * :variable:`CMAKE_<LANG>_LINK_GROUP_USING_<FEATURE>_SUPPORTED`
+ * :variable:`CMAKE_<LANG>_LINK_GROUP_USING_<FEATURE>`
+ * :variable:`CMAKE_LINK_GROUP_USING_<FEATURE>_SUPPORTED`
+ * :variable:`CMAKE_LINK_GROUP_USING_<FEATURE>`
+
+ This expression can only be used to specify link libraries (i.e. part of
+ :command:`link_libraries` or :command:`target_link_libraries` commands and
+ :prop_tgt:`LINK_LIBRARIES` or :prop_tgt:`INTERFACE_LINK_LIBRARIES` target
+ properties).
+
+ .. note::
+
+ If this expression appears in the :prop_tgt:`INTERFACE_LINK_LIBRARIES`
+ property of a target, it will be included in the imported target generated
+ by :command:`install(EXPORT)` command. It is the responsibility of the
+ environment consuming this import to define the link feature used by this
+ expression.
+
+ The ``library-list`` argument can hold CMake targets or external libraries.
+ Any CMake target of type :ref:`OBJECT <Object Libraries>` or
+ :ref:`INTERFACE <Interface Libraries>` will be ignored by this expression and
+ will be handled in the standard way.
+
+ .. note::
+
+ This expression is compatible with the :genex:`LINK_LIBRARY` generator
+ expression. The libraries involved in a group can be specified using the
+ :genex:`LINK_LIBRARY` generator expression.
+
+ Each target or external library involved in the link step can be part of
+ different groups as far as these groups use the same feature, so mixing
+ different group features for the same target or library is forbidden. The
+ different groups will be part of the link step.
+
+ .. code-block:: cmake
+
+ add_library(lib1 ...)
+ add_library(lib2 ...)
+
+ add_library(lib3 ...)
+ target_link_libraries(lib3 PUBLIC "$<LINK_GROUP:feature1,lib1,lib2>")
+
+ add_library(lib4 ...)
+ target_link_libraries(lib4 PRIVATE "$<LINK_GROUP:feature1,lib1,lib3>")
+ # lib4 will be linked with the groups {lib1,lib2} and {lib1,lib3}
+
+ add_library(lib5 ...)
+ target_link_libraries(lib5 PRIVATE "$<LINK_GROUP:feature2,lib1,lib3>")
+ # an error will be raised here because lib1 is part of two groups with
+ # different features
+
+ When a target or an external library is involved in the link step as part of
+ a group and also as standalone, any occurrence of the standalone link item
+ will be replaced by the group or groups it belong to.
+
+ .. code-block:: cmake
+
+ add_library(lib1 ...)
+ add_library(lib2 ...)
+
+ add_library(lib3 ...)
+ target_link_libraries(lib3 PUBLIC lib1)
+
+ add_library(lib4 ...)
+ target_link_libraries(lib4 PRIVATE lib3 "$<LINK_GROUP:feature1,lib1,lib2>")
+ # lib4 will only be linked with lib3 and the group {lib1,lib2}
+
+ This example will be "re-written" by CMake in the following form:
+
+ .. code-block:: cmake
+
+ add_library(lib1 ...)
+ add_library(lib2 ...)
+
+ add_library(lib3 ...)
+ target_link_libraries(lib3 PUBLIC "$<LINK_GROUP:feature1,lib1,lib2>")
+
+ add_library(lib4 ...)
+ target_link_libraries(lib4 PRIVATE lib3 "$<LINK_GROUP:feature1,lib1,lib2>")
+ # lib4 will only be linked with lib3 and the group {lib1,lib2}
+
+ Be aware that the precedence of the group over the standalone link item can
+ result in some circular dependency between groups, which will raise an
+ error because circular dependencies are not allowed for groups.
+
+ .. code-block:: cmake
+
+ add_library(lib1A ...)
+ add_library(lib1B ...)
+
+ add_library(lib2A ...)
+ add_library(lib2B ...)
+
+ target_link_libraries(lib1A PUBLIC lib2A)
+ target_link_libraries(lib2B PUBLIC lib1B)
+
+ add_library(lib ...)
+ target_link_libraries(lib3 PRIVATE "$<LINK_GROUP:feat,lib1A,lib1B>"
+ "$<LINK_GROUP:feat,lib2A,lib2B>")
+
+ This example will be "re-written" by CMake in the following form:
+
+ .. code-block:: cmake
+
+ add_library(lib1A ...)
+ add_library(lib1B ...)
+
+ add_library(lib2A ...)
+ add_library(lib2B ...)
+
+ target_link_libraries(lib1A PUBLIC "$<LINK_GROUP:feat,lib2A,lib2B>")
+ target_link_libraries(lib2B PUBLIC "$<LINK_GROUP:feat,lib1A,lib1B>")
+
+ add_library(lib ...)
+ target_link_libraries(lib3 PRIVATE "$<LINK_GROUP:feat,lib1A,lib1B>"
+ "$<LINK_GROUP:feat,lib2A,lib2B>")
+
+ So, we have a circular dependency between groups ``{lib1A,lib1B}`` and
+ ``{lib2A,lib2B}``.
+
+ CMake pre-defines some features of general interest:
+
+ .. include:: ../variable/LINK_GROUP_PREDEFINED_FEATURES.txt
+
.. genex:: $<INSTALL_INTERFACE:...>
Content of ``...`` when the property is exported using :command:`install(EXPORT)`,
diff --git a/Help/manual/cmake-policies.7.rst b/Help/manual/cmake-policies.7.rst
index 0939a82..dfc5de6 100644
--- a/Help/manual/cmake-policies.7.rst
+++ b/Help/manual/cmake-policies.7.rst
@@ -52,6 +52,14 @@
functions.
+Policies Introduced by CMake 3.24
+=================================
+
+.. toctree::
+ :maxdepth: 1
+
+ CMP0130: while() diagnoses condition evaluation errors. </policy/CMP0130>
+
Policies Introduced by CMake 3.23
=================================
diff --git a/Help/manual/cmake-presets.7.rst b/Help/manual/cmake-presets.7.rst
index 03bb5aa..c8d24f2 100644
--- a/Help/manual/cmake-presets.7.rst
+++ b/Help/manual/cmake-presets.7.rst
@@ -42,7 +42,7 @@
``version``
A required integer representing the version of the JSON schema.
- The supported versions are ``1``, ``2``, ``3``, and ``4``.
+ The supported versions are ``1``, ``2``, ``3``, ``4``, and ``5``.
``cmakeMinimumRequired``
@@ -715,6 +715,12 @@
bytes. Equivalent to passing ``--test-output-size-failed`` on the
command line.
+ ``testOutputTruncation``
+
+ An optional string specifying the test output truncation mode. Equivalent
+ to passing ``--test-output-truncation`` on the command line."
+ This is allowed in preset files specifying version ``5`` or above.
+
``maxTestNameWidth``
An optional integer specifying the maximum width of a test name to
diff --git a/Help/manual/cmake-properties.7.rst b/Help/manual/cmake-properties.7.rst
index f4efd3c..65f9248 100644
--- a/Help/manual/cmake-properties.7.rst
+++ b/Help/manual/cmake-properties.7.rst
@@ -308,6 +308,8 @@
/prop_tgt/LINK_INTERFACE_MULTIPLICITY_CONFIG
/prop_tgt/LINK_LIBRARIES
/prop_tgt/LINK_LIBRARIES_ONLY_TARGETS
+ /prop_tgt/LINK_LIBRARY_OVERRIDE
+ /prop_tgt/LINK_LIBRARY_OVERRIDE_LIBRARY
/prop_tgt/LINK_OPTIONS
/prop_tgt/LINK_SEARCH_END_STATIC
/prop_tgt/LINK_SEARCH_START_STATIC
@@ -402,6 +404,7 @@
/prop_tgt/VS_JUST_MY_CODE_DEBUGGING
/prop_tgt/VS_KEYWORD
/prop_tgt/VS_MOBILE_EXTENSIONS_VERSION
+ /prop_tgt/VS_NO_COMPILE_BATCHING
/prop_tgt/VS_NO_SOLUTION_DEPLOY
/prop_tgt/VS_PACKAGE_REFERENCES
/prop_tgt/VS_PLATFORM_TOOLSET
diff --git a/Help/manual/cmake-variables.7.rst b/Help/manual/cmake-variables.7.rst
index 4df0237..8d20ae2 100644
--- a/Help/manual/cmake-variables.7.rst
+++ b/Help/manual/cmake-variables.7.rst
@@ -172,6 +172,7 @@
/variable/CMAKE_CODEBLOCKS_COMPILER_ID
/variable/CMAKE_CODEBLOCKS_EXCLUDE_EXTERNAL_FILES
/variable/CMAKE_CODELITE_USE_TARGETS
+ /variable/CMAKE_COLOR_DIAGNOSTICS
/variable/CMAKE_COLOR_MAKEFILE
/variable/CMAKE_CONFIGURATION_TYPES
/variable/CMAKE_DEPENDS_IN_PROJECT_ONLY
@@ -197,6 +198,7 @@
/variable/CMAKE_FIND_PACKAGE_NO_SYSTEM_PACKAGE_REGISTRY
/variable/CMAKE_FIND_PACKAGE_PREFER_CONFIG
/variable/CMAKE_FIND_PACKAGE_RESOLVE_SYMLINKS
+ /variable/CMAKE_FIND_PACKAGE_TARGETS_GLOBAL
/variable/CMAKE_FIND_PACKAGE_WARN_NO_MODULE
/variable/CMAKE_FIND_ROOT_PATH
/variable/CMAKE_FIND_ROOT_PATH_MODE_INCLUDE
@@ -437,7 +439,11 @@
/variable/CMAKE_LANG_CPPCHECK
/variable/CMAKE_LANG_CPPLINT
/variable/CMAKE_LANG_INCLUDE_WHAT_YOU_USE
+ /variable/CMAKE_LANG_LINK_LIBRARY_USING_FEATURE
+ /variable/CMAKE_LANG_LINK_LIBRARY_USING_FEATURE_SUPPORTED
/variable/CMAKE_LANG_LINKER_LAUNCHER
+ /variable/CMAKE_LANG_LINK_GROUP_USING_FEATURE
+ /variable/CMAKE_LANG_LINK_GROUP_USING_FEATURE_SUPPORTED
/variable/CMAKE_LANG_LINK_LIBRARY_FILE_FLAG
/variable/CMAKE_LANG_LINK_LIBRARY_FLAG
/variable/CMAKE_LANG_LINK_WHAT_YOU_USE_FLAG
@@ -447,9 +453,13 @@
/variable/CMAKE_LIBRARY_PATH_FLAG
/variable/CMAKE_LINK_DEF_FILE_FLAG
/variable/CMAKE_LINK_DEPENDS_NO_SHARED
+ /variable/CMAKE_LINK_GROUP_USING_FEATURE
+ /variable/CMAKE_LINK_GROUP_USING_FEATURE_SUPPORTED
/variable/CMAKE_LINK_INTERFACE_LIBRARIES
/variable/CMAKE_LINK_LIBRARY_FILE_FLAG
/variable/CMAKE_LINK_LIBRARY_FLAG
+ /variable/CMAKE_LINK_LIBRARY_USING_FEATURE
+ /variable/CMAKE_LINK_LIBRARY_USING_FEATURE_SUPPORTED
/variable/CMAKE_LINK_WHAT_YOU_USE
/variable/CMAKE_LINK_WHAT_YOU_USE_CHECK
/variable/CMAKE_MACOSX_BUNDLE
@@ -633,6 +643,7 @@
/variable/CTEST_CUSTOM_MAXIMUM_NUMBER_OF_ERRORS
/variable/CTEST_CUSTOM_MAXIMUM_NUMBER_OF_WARNINGS
/variable/CTEST_CUSTOM_MAXIMUM_PASSED_TEST_OUTPUT_SIZE
+ /variable/CTEST_CUSTOM_TEST_OUTPUT_TRUNCATION
/variable/CTEST_CUSTOM_MEMCHECK_IGNORE
/variable/CTEST_CUSTOM_POST_MEMCHECK
/variable/CTEST_CUSTOM_POST_TEST
diff --git a/Help/manual/cmake.1.rst b/Help/manual/cmake.1.rst
index 18bdc5f..e93cbe5 100644
--- a/Help/manual/cmake.1.rst
+++ b/Help/manual/cmake.1.rst
@@ -326,7 +326,8 @@
"cmd": "add_executable",
"args": ["foo", "bar"],
"time": 1579512535.9687231,
- "frame": 2
+ "frame": 2,
+ "global_frame": 4
}
The members are:
@@ -336,7 +337,13 @@
was called.
``line``
- The line in ``file`` of the function call.
+ The line in ``file`` where the function call begins.
+
+ ``line_end``
+ If the function call spans multiple lines, this field will
+ be set to the line where the function call ends. If the function
+ calls spans a single line, this field will be unset. This field
+ was added in minor version 2 of the ``json-v1`` format.
``defer``
Optional member that is present when the function call was deferred
@@ -353,7 +360,13 @@
Timestamp (seconds since epoch) of the function call.
``frame``
- Stack frame depth of the function that was called.
+ Stack frame depth of the function that was called, within the
+ context of the ``CMakeLists.txt`` being processed currently.
+
+ ``global_frame``
+ Stack frame depth of the function that was called, tracked globally
+ across all ``CMakeLists.txt`` files involved in the trace. This field
+ was added in minor version 2 of the ``json-v1`` format.
Additionally, the first JSON document outputted contains the
``version`` key for the current major and minor version of the
@@ -365,7 +378,7 @@
{
"version": {
"major": 1,
- "minor": 1
+ "minor": 2
}
}
@@ -673,11 +686,17 @@
``true`` if cmake supports server-mode and ``false`` otherwise.
Always false since CMake 3.20.
-``cat <files>...``
+``cat [--] <files>...``
.. versionadded:: 3.18
Concatenate files and print on the standard output.
+ .. versionadded:: 3.24
+ Added support for the double dash argument ``--``. This basic implementation
+ of ``cat`` does not support any options, so using a option starting with
+ ``-`` will result in an error. Use ``--`` to indicate the end of options, in
+ case a file starts with ``-``.
+
``chdir <dir> <cmd> [<arg>...]``
Change the current working directory and run a command.
@@ -746,11 +765,16 @@
``echo_append [<string>...]``
Displays arguments as text but no new line.
-``env [--unset=NAME]... [NAME=VALUE]... COMMAND [ARG]...``
+``env [--unset=NAME ...] [NAME=VALUE ...] [--] <command> [<arg>...]``
.. versionadded:: 3.1
Run command in a modified environment.
+ .. versionadded:: 3.24
+ Added support for the double dash argument ``--``. Use ``--`` to stop
+ interpreting options/environment variables and treat the next argument as
+ the command, even if it start with ``-`` or contains a ``=``.
+
``environment``
Display the current environment variables.
@@ -843,16 +867,16 @@
Rename a file or directory (on one volume). If file with the ``<newname>`` name
already exists, then it will be silently replaced.
-``rm [-rRf] <file> <dir>...``
+``rm [-rRf] [--] <file|dir>...``
.. versionadded:: 3.17
Remove the files ``<file>`` or directories ``<dir>``.
-
Use ``-r`` or ``-R`` to remove directories and their contents recursively.
If any of the listed files/directories do not exist, the command returns a
non-zero exit code, but no message is logged. The ``-f`` option changes
the behavior to return a zero exit code (i.e. success) in such
- situations instead.
+ situations instead. Use ``--`` to stop interpreting options and treat all
+ remaining arguments as paths, even if they start with ``-``.
``server``
Launch :manual:`cmake-server(7)` mode.
diff --git a/Help/manual/ctest.1.rst b/Help/manual/ctest.1.rst
index 1e7b077..82e27b8 100644
--- a/Help/manual/ctest.1.rst
+++ b/Help/manual/ctest.1.rst
@@ -362,6 +362,10 @@
``--test-output-size-failed <size>``
Limit the output for failed tests to ``<size>`` bytes.
+``--test-output-truncation <mode>``
+ Truncate 'tail' (default), 'middle' or 'head' of test output once maximum
+ output size is reached.
+
``--overwrite``
Overwrite CTest configuration option.
diff --git a/Help/manual/presets/example.json b/Help/manual/presets/example.json
index 873c4ad..be5c791 100644
--- a/Help/manual/presets/example.json
+++ b/Help/manual/presets/example.json
@@ -1,5 +1,5 @@
{
- "version": 4,
+ "version": 5,
"cmakeMinimumRequired": {
"major": 3,
"minor": 23,
diff --git a/Help/manual/presets/schema.json b/Help/manual/presets/schema.json
index 12f8b5e..c96405c 100644
--- a/Help/manual/presets/schema.json
+++ b/Help/manual/presets/schema.json
@@ -57,6 +57,21 @@
"include": { "$ref": "#/definitions/include"}
},
"additionalProperties": false
+ },
+ {
+ "properties": {
+ "version": {
+ "const": 5,
+ "description": "A required integer representing the version of the JSON schema."
+ },
+ "cmakeMinimumRequired": { "$ref": "#/definitions/cmakeMinimumRequired"},
+ "vendor": { "$ref": "#/definitions/vendor" },
+ "configurePresets": { "$ref": "#/definitions/configurePresetsV3"},
+ "buildPresets": { "$ref": "#/definitions/buildPresetsV4"},
+ "testPresets": { "$ref": "#/definitions/testPresetsV5"},
+ "include": { "$ref": "#/definitions/include"}
+ },
+ "additionalProperties": false
}
],
"required": [
@@ -673,6 +688,28 @@
"additionalProperties": false
}
},
+ "testPresetsItemsV5": {
+ "type": "array",
+ "description": "An optional array of test preset objects. Used to specify arguments to ctest. Available in version 5 and higher.",
+ "items": {
+ "type": "object",
+ "properties": {
+ "output": {
+ "type": "object",
+ "description": "An optional object specifying output options.",
+ "properties": {
+ "testOutputTruncation": {
+ "type": "string",
+ "description": "An optional string specifying the test output truncation mode. Equivalent to passing --test-output-truncation on the command line. Must be one of the following values: \"tail\", \"middle\", or \"head\".",
+ "enum": [
+ "tail", "middle", "head"
+ ]
+ }
+ }
+ }
+ }
+ }
+ },
"testPresetsItemsV3": {
"type": "array",
"description": "An optional array of test preset objects. Used to specify arguments to ctest. Available in version 3 and higher.",
@@ -821,8 +858,7 @@
"type": "integer",
"description": "An optional integer specifying the maximum width of a test name to output. Equivalent to passing --max-width on the command line."
}
- },
- "additionalProperties": false
+ }
},
"filter": {
"type": "object",
@@ -998,6 +1034,39 @@
]
}
},
+ "testPresetsV5": {
+ "type": "array",
+ "description": "An optional array of test preset objects. Used to specify arguments to ctest. Available in version 5 and higher.",
+ "allOf": [
+ { "$ref": "#/definitions/testPresetsItemsV2" },
+ { "$ref": "#/definitions/testPresetsItemsV3" },
+ { "$ref": "#/definitions/testPresetsItemsV5" }
+ ],
+ "items": {
+ "type": "object",
+ "properties": {
+ "name": {},
+ "hidden": {},
+ "inherits": {},
+ "configurePreset": {},
+ "vendor": {},
+ "displayName": {},
+ "description": {},
+ "inheritConfigureEnvironment": {},
+ "environment": {},
+ "configuration": {},
+ "overwriteConfigurationFile": {},
+ "output": {},
+ "filter": {},
+ "execution": {},
+ "condition": {}
+ },
+ "required": [
+ "name"
+ ],
+ "additionalProperties": false
+ }
+ },
"testPresetsV3": {
"type": "array",
"description": "An optional array of test preset objects. Used to specify arguments to ctest. Available in version 3 and higher.",
diff --git a/Help/policy/CMP0130.rst b/Help/policy/CMP0130.rst
new file mode 100644
index 0000000..0dd5623
--- /dev/null
+++ b/Help/policy/CMP0130.rst
@@ -0,0 +1,32 @@
+CMP0130
+-------
+
+.. versionadded:: 3.24
+
+:command:`while` diagnoses condition evaluation errors.
+
+CMake 3.23 and below accidentally tolerated errors encountered while
+evaluating the condition passed to the :command:`while` command
+(but not the :command:`if` command). For example, the code
+
+.. code-block:: cmake
+
+ set(paren "(")
+ while(${paren})
+ endwhile()
+
+creates an unbalanced parenthesis during condition evaluation.
+
+CMake 3.24 and above prefer to diagnose such errors. This policy
+provides compatibility for projects that have not been updated to
+fix their condition errors.
+
+The ``OLD`` behavior for this policy is to ignore errors in
+:command:`while` conditions. The ``NEW`` behavior for this
+policy is to diagnose errors in :command:`while` conditions.
+
+This policy was introduced in CMake version 3.24. CMake version |release|
+warns when the policy is not set and uses ``OLD`` behavior. Use the
+:command:`cmake_policy` command to set it to ``OLD`` or ``NEW`` explicitly.
+
+.. include:: DEPRECATED.txt
diff --git a/Help/prop_test/ENVIRONMENT_MODIFICATION.rst b/Help/prop_test/ENVIRONMENT_MODIFICATION.rst
index a80651a..ad3e190 100644
--- a/Help/prop_test/ENVIRONMENT_MODIFICATION.rst
+++ b/Help/prop_test/ENVIRONMENT_MODIFICATION.rst
@@ -19,17 +19,19 @@
to its state from the rest of the CTest execution.
- ``set``: Replaces the current value of ``MYVAR`` with ``VALUE``.
- ``unset``: Unsets the current value of ``MYVAR``.
- - ``string_append``: Appends ``VALUE`` to the current value of ``MYVAR``.
- - ``string_prepend``: Prepends ``VALUE`` to the current value of ``MYVAR``.
- - ``path_list_append``: Appends ``VALUE`` to the current value of ``MYVAR``
- using the host platform's path list separator (``;`` on Windows and ``:``
- elsewhere).
- - ``path_list_prepend``: Prepends ``VALUE`` to the current value of
+ - ``string_append``: Appends singular ``VALUE`` to the current value of
+ ``MYVAR``.
+ - ``string_prepend``: Prepends singular ``VALUE`` to the current value of
+ ``MYVAR``.
+ - ``path_list_append``: Appends singular ``VALUE`` to the current value of
``MYVAR`` using the host platform's path list separator (``;`` on Windows
and ``:`` elsewhere).
- - ``cmake_list_append``: Appends ``VALUE`` to the current value of ``MYVAR``
- using ``;`` as the separator.
- - ``cmake_list_prepend``: Prepends ``VALUE`` to the current value of
+ - ``path_list_prepend``: Prepends singular ``VALUE`` to the current value of
+ ``MYVAR`` using the host platform's path list separator (``;`` on Windows
+ and ``:`` elsewhere).
+ - ``cmake_list_append``: Appends singular ``VALUE`` to the current value of
+ ``MYVAR`` using ``;`` as the separator.
+ - ``cmake_list_prepend``: Prepends singular ``VALUE`` to the current value of
``MYVAR`` using ``;`` as the separator.
Unrecognized ``OP`` values will result in the test failing before it is
diff --git a/Help/prop_tgt/CUDA_ARCHITECTURES.rst b/Help/prop_tgt/CUDA_ARCHITECTURES.rst
index 191f78f..05c2599 100644
--- a/Help/prop_tgt/CUDA_ARCHITECTURES.rst
+++ b/Help/prop_tgt/CUDA_ARCHITECTURES.rst
@@ -34,6 +34,11 @@
Compile for all supported major real architectures, and the highest
major virtual architecture.
+``native``
+ .. versionadded:: 3.24
+
+ Compile for the architecture(s) of the host's GPU(s).
+
Examples
^^^^^^^^
diff --git a/Help/prop_tgt/LINK_LIBRARY_OVERRIDE.rst b/Help/prop_tgt/LINK_LIBRARY_OVERRIDE.rst
new file mode 100644
index 0000000..81a2a4a
--- /dev/null
+++ b/Help/prop_tgt/LINK_LIBRARY_OVERRIDE.rst
@@ -0,0 +1,54 @@
+LINK_LIBRARY_OVERRIDE
+---------------------
+
+.. versionadded:: 3.24
+
+To resolve incompatible features introduced by :genex:`LINK_LIBRARY` generator
+expression, this property offers the possibility to override, per ``link-item``
+(``CMake`` target or external library) involved in the link step, any defined
+features with a new one.
+
+This property takes a :ref:`;-list <CMake Language Lists>` of override
+declarations which have the following format:
+
+::
+
+ feature[,link-item]*
+
+For the list of ``link-item`` (``CMake`` target or external library) specified,
+the feature ``feature`` will be used in place of any declared feature. For
+example:
+
+.. code-block:: cmake
+
+ add_library(lib1 ...)
+ target_link_libraries(lib1 PUBLIC "$<LINK_LIBRARY:feature1,external>")
+
+ add_library(lib2 ...)
+ target_link_libraries(lib2 PUBLIC "$<LINK_LIBRARY:feature2,lib1>")
+
+ add_library(lib3 ...)
+ target_link_libraries(lib3 PRIVATE lib1 lib2)
+ # Here, lib1 has two different features which prevents to link lib3
+ # So, define LINK_LIBRARY_OVERRIDE property to ensure correct link
+ set_property(TARGET lib3 PROPERTY LINK_LIBRARY_OVERRIDE "feature2,lib1,external")
+ # The lib1 and external will be used with FEATURE2 to link lib3
+
+It is also possible to override any feature with the pre-defined feature
+``DEFAULT`` to get the standard behavior (i.e. no feature):
+
+.. code-block:: cmake
+
+ set_property(TARGET lib3 PROPERTY LINK_LIBRARY_OVERRIDE "DEFAULT,lib1"
+ "feature2,external")
+ # The lib1 will be used without any feature and external will use feature2 to link lib3
+
+Contents of ``LINK_LIBRARY_OVERRIDE`` may use
+:manual:`generator expressions <cmake-generator-expressions(7)>`.
+
+See also :prop_tgt:`LINK_LIBRARY_OVERRIDE_<LIBRARY>` target property for
+a per linked target oriented approach to override features.
+
+For more information about features, see
+:variable:`CMAKE_<LANG>_LINK_LIBRARY_USING_<FEATURE>`
+and :variable:`CMAKE_LINK_LIBRARY_USING_<FEATURE>` variables.
diff --git a/Help/prop_tgt/LINK_LIBRARY_OVERRIDE_LIBRARY.rst b/Help/prop_tgt/LINK_LIBRARY_OVERRIDE_LIBRARY.rst
new file mode 100644
index 0000000..112f614
--- /dev/null
+++ b/Help/prop_tgt/LINK_LIBRARY_OVERRIDE_LIBRARY.rst
@@ -0,0 +1,45 @@
+LINK_LIBRARY_OVERRIDE_<LIBRARY>
+-------------------------------
+
+.. versionadded:: 3.24
+
+To resolve incompatible features introduced by :genex:`LINK_LIBRARY` generator
+expression, this property offers the possibility to override, for a
+``link-item`` (``CMake`` target or external library) involved in the link step,
+any defined features with a new one.
+
+This property takes a ``feature`` name which will be applied to the
+``link-item`` specified by ``<LIBRARY>`` suffix property. For example:
+
+.. code-block:: cmake
+
+ add_library(lib1 ...)
+ target_link_libraries(lib1 PUBLIC "$<LINK_LIBRARY:feature1,external>")
+
+ add_library(lib2 ...)
+ target_link_libraries(lib2 PUBLIC "$<LINK_LIBRARY:feature2,lib1>")
+
+ add_library(lib3 ...)
+ target_link_libraries(lib3 PRIVATE lib1 lib2)
+ # Here, lib1 has two different features which prevents to link lib3
+ # So, define LINK_LIBRARY_OVERRIDE_lib1 property to ensure correct link
+ set_property(TARGET lib3 PROPERTY LINK_LIBRARY_OVERRIDE_lib1 feature2)
+ # The lib1 will be used with feature2 to link lib3
+
+It is also possible to override any feature with the pre-defined feature
+``DEFAULT`` to get the standard behavior (i.e. no feature):
+
+.. code-block:: cmake
+
+ set_property(TARGET lib3 PROPERTY LINK_LIBRARY_OVERRIDE_lib1 DEFAULT)
+ # The lib1 will be used without any feature to link lib3
+
+Contents of ``LINK_LIBRARY_OVERRIDE_<LIBRARY>`` may use
+:manual:`generator expressions <cmake-generator-expressions(7)>`.
+
+This property takes precedence over :prop_tgt:`LINK_LIBRARY_OVERRIDE`
+target property.
+
+For more information about features, see
+:variable:`CMAKE_<LANG>_LINK_LIBRARY_USING_<FEATURE>`
+and :variable:`CMAKE_LINK_LIBRARY_USING_<FEATURE>` variables.
diff --git a/Help/prop_tgt/VS_NO_COMPILE_BATCHING.rst b/Help/prop_tgt/VS_NO_COMPILE_BATCHING.rst
new file mode 100644
index 0000000..f8a9fa6
--- /dev/null
+++ b/Help/prop_tgt/VS_NO_COMPILE_BATCHING.rst
@@ -0,0 +1,21 @@
+VS_NO_COMPILE_BATCHING
+----------------------
+
+.. versionadded:: 3.24
+
+Turn off compile batching for the target. Usually MSBuild calls the compiler
+with multiple c/cpp files and compiler starts subprocesses for each file to
+make the build parallel. If you want compiler to be invoked with one file at
+a time set VS_NO_COMPILE_BATCHING to ON. If this flag is set MSBuild will call
+compiler with one c/cpp file at a time. Useful when you want to use tool that
+replaces the compiler, for example some build caching tool.
+
+Example
+^^^^^^^
+
+This shows setting the variable for the target foo.
+
+.. code-block:: cmake
+
+ add_library(foo SHARED foo.cpp)
+ set_property(TARGET foo PROPERTY VS_NO_COMPILE_BATCHING ON)
diff --git a/Help/release/dev/0-sample-topic.rst b/Help/release/dev/0-sample-topic.rst
new file mode 100644
index 0000000..e4cc01e
--- /dev/null
+++ b/Help/release/dev/0-sample-topic.rst
@@ -0,0 +1,7 @@
+0-sample-topic
+--------------
+
+* This is a sample release note for the change in a topic.
+ Developers should add similar notes for each topic branch
+ making a noteworthy change. Each document should be named
+ and titled to match the topic name to avoid merge conflicts.
diff --git a/Help/release/dev/Apple-link-framework.rst b/Help/release/dev/Apple-link-framework.rst
new file mode 100644
index 0000000..e194c15
--- /dev/null
+++ b/Help/release/dev/Apple-link-framework.rst
@@ -0,0 +1,11 @@
+Apple-link-framework
+--------------------
+
+* The :genex:`LINK_LIBRARY` generator expression gained the ability to link
+ frameworks in various ways when targeting ``Apple`` platforms. The following
+ new features were added:
+
+ * ``FRAMEWORK``
+ * ``NEEDED_FRAMEWORK``
+ * ``REEXPORT_FRAMEWORK``
+ * ``WEAK_FRAMEWORK``
diff --git a/Help/release/dev/Apple-link-library.rst b/Help/release/dev/Apple-link-library.rst
new file mode 100644
index 0000000..ec4e3b6
--- /dev/null
+++ b/Help/release/dev/Apple-link-library.rst
@@ -0,0 +1,10 @@
+Apple-link-library
+------------------
+
+* The :genex:`LINK_LIBRARY` generator expression gained the ability to link
+ libraries in various ways when targeting ``Apple`` platforms. The following
+ new features were added:
+
+ * ``NEEDED_LIBRARY``
+ * ``REEXPORT_LIBRARY``
+ * ``WEAK_LIBRARY``
diff --git a/Help/release/dev/Genex-LINK_GROUP.rst b/Help/release/dev/Genex-LINK_GROUP.rst
new file mode 100644
index 0000000..aa9e318
--- /dev/null
+++ b/Help/release/dev/Genex-LINK_GROUP.rst
@@ -0,0 +1,8 @@
+Genex-LINK_GROUP
+----------------
+
+* The :genex:`LINK_GROUP` generator expression was added to manage the grouping
+ of libraries during the link step. The variables
+ :variable:`CMAKE_<LANG>_LINK_GROUP_USING_<FEATURE>` and
+ :variable:`CMAKE_LINK_GROUP_USING_<FEATURE>` are used to define features
+ usable by the :genex:`LINK_GROUP` generator expression.
diff --git a/Help/release/dev/Genex-LINK_LIBRARY.rst b/Help/release/dev/Genex-LINK_LIBRARY.rst
new file mode 100644
index 0000000..fe44dbc
--- /dev/null
+++ b/Help/release/dev/Genex-LINK_LIBRARY.rst
@@ -0,0 +1,11 @@
+Genex-LINK_LIBRARY
+------------------
+
+* The :genex:`LINK_LIBRARY` generator expression was added to manage how
+ libraries are specified during the link step. The variables
+ :variable:`CMAKE_<LANG>_LINK_LIBRARY_USING_<FEATURE>` and
+ :variable:`CMAKE_LINK_LIBRARY_USING_<FEATURE>` are used to define features
+ usable by the :genex:`LINK_LIBRARY` generator expression. Moreover, the
+ :prop_tgt:`LINK_LIBRARY_OVERRIDE` and
+ :prop_tgt:`LINK_LIBRARY_OVERRIDE_<LIBRARY>` target properties are available
+ to resolve incompatible features.
diff --git a/Help/release/dev/LINK_LIBRARY-WHOLE_ARCHIVE.rst b/Help/release/dev/LINK_LIBRARY-WHOLE_ARCHIVE.rst
new file mode 100644
index 0000000..abaf3a9
--- /dev/null
+++ b/Help/release/dev/LINK_LIBRARY-WHOLE_ARCHIVE.rst
@@ -0,0 +1,14 @@
+LINK_LIBRARY-WHOLE_ARCHIVE
+--------------------------
+
+* The :genex:`LINK_LIBRARY` generator expression gained the feature
+ ``WHOLE_ARCHIVE`` to force load of all members in a static library. This
+ feature is supported on the following target platforms:
+
+ * all ``Apple`` variants
+ * ``Linux``
+ * all ``BSD`` variants
+ * ``SunOS``
+ * ``Windows``
+ * ``CYGWIN``
+ * ``MSYS``
diff --git a/Help/release/dev/cmcmd-end-of-options-delimiter.rst b/Help/release/dev/cmcmd-end-of-options-delimiter.rst
new file mode 100644
index 0000000..bc9cc21
--- /dev/null
+++ b/Help/release/dev/cmcmd-end-of-options-delimiter.rst
@@ -0,0 +1,7 @@
+cmcmd-end-of-options-delimiter
+------------------------------
+
+* The :manual:`cmake(1)` ``-E`` commands ``cat`` and ``env`` learned to respect
+ a double dash (``--``) argument that acts as a delimiter indicating the end of
+ options. Any following arguments are treated as operands/positional arguments,
+ even if they begin with a dash ``-`` character.
diff --git a/Help/release/dev/color-diagnostics.rst b/Help/release/dev/color-diagnostics.rst
new file mode 100644
index 0000000..8e0e225
--- /dev/null
+++ b/Help/release/dev/color-diagnostics.rst
@@ -0,0 +1,10 @@
+color-diagnostics
+-----------------
+
+* The :variable:`CMAKE_COLOR_DIAGNOSTICS` variable was added to control
+ color diagnostics generated by compilers. This variable also controls
+ color buildsystem messages with :ref:`Makefile Generators`, replacing
+ :variable:`CMAKE_COLOR_MAKEFILE`.
+
+ The :envvar:`CMAKE_COLOR_DIAGNOSTICS` environment was added to set
+ a default value for :variable:`CMAKE_COLOR_DIAGNOSTICS`.
diff --git a/Help/release/dev/cpack-zstd-parallel.rst b/Help/release/dev/cpack-zstd-parallel.rst
new file mode 100644
index 0000000..da22625
--- /dev/null
+++ b/Help/release/dev/cpack-zstd-parallel.rst
@@ -0,0 +1,6 @@
+cpack-zstd-parallel
+-------------------
+
+* CPack now supports the :variable:`CPACK_THREADS` option for ``zstd``
+ compression when compiled with libarchive 3.6 or higher. It is
+ supported by official CMake binaries available on ``cmake.org``.
diff --git a/Help/release/dev/cuda-arch-native.rst b/Help/release/dev/cuda-arch-native.rst
new file mode 100644
index 0000000..f44a668
--- /dev/null
+++ b/Help/release/dev/cuda-arch-native.rst
@@ -0,0 +1,7 @@
+cuda-arch-native
+----------------
+
+* The :variable:`CMAKE_CUDA_ARCHITECTURES` variable and associated
+ :prop_tgt:`CUDA_ARCHITECTURES` target property now support the
+ special ``native`` value to compile for the architectures(s)
+ of the host's GPU(s).
diff --git a/Help/release/dev/file-download-range.rst b/Help/release/dev/file-download-range.rst
new file mode 100644
index 0000000..194100d
--- /dev/null
+++ b/Help/release/dev/file-download-range.rst
@@ -0,0 +1,6 @@
+file-download-range
+-------------------
+
+* Add the fields ``RANGE_START`` and ``RANGE_END`` to ``file(DOWNLOAD)``.
+ Those fields provide a convenient way to specify the range, passed to the
+ libcurl, which can be useful for downloading parts of big binary files.
diff --git a/Help/release/dev/find_package-global-imported.rst b/Help/release/dev/find_package-global-imported.rst
new file mode 100644
index 0000000..b32d18d
--- /dev/null
+++ b/Help/release/dev/find_package-global-imported.rst
@@ -0,0 +1,9 @@
+find_package-global-imported
+----------------------------
+
+* The :command:`find_package` command gained a `GLOBAL` option that
+ allows for the promotion of imported targets to global scope fur the
+ duration of the :command:`find_package` call.
+
+* Adds support for :variable:`CMAKE_FIND_PACKAGE_TARGETS_GLOBAL` to
+ toggle behavior of the :command:`find_package` command's new GLOBAL option
diff --git a/Help/release/dev/findzlib-static.rst b/Help/release/dev/findzlib-static.rst
new file mode 100644
index 0000000..35855f6
--- /dev/null
+++ b/Help/release/dev/findzlib-static.rst
@@ -0,0 +1,5 @@
+findzlib-static
+---------------
+
+* The :module:`FindZLIB` learned a new ``ZLIB_USE_STATIC_LIBS`` variable to
+ search only for static libraries.
diff --git a/Help/release/dev/ghs_predefined_targets.rst b/Help/release/dev/ghs_predefined_targets.rst
new file mode 100644
index 0000000..eeca5a9
--- /dev/null
+++ b/Help/release/dev/ghs_predefined_targets.rst
@@ -0,0 +1,6 @@
+ghs_predefined_targets
+----------------------
+
+* A new predefined target `RERUN_CMAKE` is added for
+ :generator:`Green Hills MULTI` generator to easily rerun
+ CMake if any CMake files were updated.
diff --git a/Help/release/dev/rescan-static-libraries.rst b/Help/release/dev/rescan-static-libraries.rst
new file mode 100644
index 0000000..1ab3485
--- /dev/null
+++ b/Help/release/dev/rescan-static-libraries.rst
@@ -0,0 +1,5 @@
+rescan-static-libraries
+-----------------------
+
+* The :genex:`LINK_GROUP` generator expression gained the ability to manage
+ circular references between static libraries by using ``RESCAN`` feature.
diff --git a/Help/release/dev/trace-global-frame.rst b/Help/release/dev/trace-global-frame.rst
new file mode 100644
index 0000000..fdc4b5c
--- /dev/null
+++ b/Help/release/dev/trace-global-frame.rst
@@ -0,0 +1,8 @@
+trace-global-frame
+------------------
+
+* Add the field ``global_frame`` to the json-v1 trace format. This
+ frame tracks the depth of the call stack globally across all
+ ``CMakeLists.txt`` files involved in the trace, and will let tools
+ reconstruct stack traces that span from the top-level ``CMakeLists.txt``
+ file of the project.
diff --git a/Help/release/dev/trace-line-end.rst b/Help/release/dev/trace-line-end.rst
new file mode 100644
index 0000000..beade4b
--- /dev/null
+++ b/Help/release/dev/trace-line-end.rst
@@ -0,0 +1,7 @@
+trace-line-end
+--------------
+
+* Add the field ``line_end`` to the json-v1 trace format. This
+ field tells you the line in file ``file`` at which the function
+ call ends. Tools can use this new field, together with ``line``
+ and ``file``, to map traces to lines of CMake source code.
diff --git a/Help/release/dev/vs_buildcache_support.rst b/Help/release/dev/vs_buildcache_support.rst
new file mode 100644
index 0000000..bdda675
--- /dev/null
+++ b/Help/release/dev/vs_buildcache_support.rst
@@ -0,0 +1,6 @@
+vs_buildcache_support
+---------------------
+
+* The :prop_tgt:`VS_NO_COMPILE_BATCHING` target property was added to
+ tell :ref:`Visual Studio Generators` whether to disable compiler parallelism
+ and call the compiler with one c/cpp file at a time.
diff --git a/Help/release/dev/while-errors.rst b/Help/release/dev/while-errors.rst
new file mode 100644
index 0000000..c39e6e8
--- /dev/null
+++ b/Help/release/dev/while-errors.rst
@@ -0,0 +1,5 @@
+while-errors
+------------
+
+* The :command:`while` command now diagnoses errors during condition
+ evaluation. See policy :policy:`CMP0130`.
diff --git a/Help/release/index.rst b/Help/release/index.rst
index ee677a3..ad33705 100644
--- a/Help/release/index.rst
+++ b/Help/release/index.rst
@@ -7,6 +7,8 @@
This file should include the adjacent "dev.txt" file
in development versions but not in release versions.
+.. include:: dev.txt
+
Releases
========
diff --git a/Help/variable/CMAKE_COLOR_DIAGNOSTICS.rst b/Help/variable/CMAKE_COLOR_DIAGNOSTICS.rst
new file mode 100644
index 0000000..a72c9e1
--- /dev/null
+++ b/Help/variable/CMAKE_COLOR_DIAGNOSTICS.rst
@@ -0,0 +1,37 @@
+CMAKE_COLOR_DIAGNOSTICS
+-----------------------
+
+.. versionadded:: 3.24
+
+Enable color diagnostics throughout.
+
+This variable uses three states: ``ON``, ``OFF`` and not defined.
+
+When not defined:
+
+* :ref:`Makefile Generators` initialize the :variable:`CMAKE_COLOR_MAKEFILE`
+ variable to ``ON``. It controls color buildsystem messages.
+
+* GNU/Clang compilers are not invoked with any color diagnostics flag.
+
+When ``ON``:
+
+* :ref:`Makefile Generators` produce color buildsystem messages by default.
+ :variable:`CMAKE_COLOR_MAKEFILE` is not initialized, but may be
+ explicitly set to ``OFF`` to disable color buildsystem messages.
+
+* GNU/Clang compilers are invoked with a flag enabling color diagnostics
+ (``-fcolor-diagnostics``).
+
+When ``OFF``:
+
+* :ref:`Makefile Generators` do not produce color buildsystem messages by
+ default. :variable:`CMAKE_COLOR_MAKEFILE` is not initialized, but may be
+ explicitly set to ``ON`` to enable color buildsystem messages.
+
+* GNU/Clang compilers are invoked with a flag disabling color diagnostics
+ (``-fno-color-diagnostics``).
+
+If the :envvar:`CMAKE_COLOR_DIAGNOSTICS` environment variable is set, its
+value is used. Otherwise, ``CMAKE_COLOR_DIAGNOSTICS`` is not defined by
+default.
diff --git a/Help/variable/CMAKE_FIND_PACKAGE_TARGETS_GLOBAL.rst b/Help/variable/CMAKE_FIND_PACKAGE_TARGETS_GLOBAL.rst
new file mode 100644
index 0000000..58efccf
--- /dev/null
+++ b/Help/variable/CMAKE_FIND_PACKAGE_TARGETS_GLOBAL.rst
@@ -0,0 +1,10 @@
+CMAKE_FIND_PACKAGE_TARGETS_GLOBAL
+---------------------------------
+
+Setting to ``TRUE`` promotes all :prop_tgt:`IMPORTED` targets discoverd
+by :command:`find_package` to a ``GLOBAL`` scope.
+
+
+Setting this to ``TRUE`` is akin to specifying ``GLOBAL``
+as an argument to :command:`find_package`.
+Default value is ``OFF``.
diff --git a/Help/variable/CMAKE_LANG_LINK_GROUP_USING_FEATURE.rst b/Help/variable/CMAKE_LANG_LINK_GROUP_USING_FEATURE.rst
new file mode 100644
index 0000000..f2ef843
--- /dev/null
+++ b/Help/variable/CMAKE_LANG_LINK_GROUP_USING_FEATURE.rst
@@ -0,0 +1,27 @@
+CMAKE_<LANG>_LINK_GROUP_USING_<FEATURE>
+---------------------------------------
+
+.. versionadded:: 3.24
+
+This variable defines, for the specified ``<FEATURE>`` and the linker language
+``<LANG>``, the expression expected by the linker when libraries are specified
+using :genex:`LINK_GROUP` generator expression.
+
+.. note::
+
+ * Feature names can contain Latin letters, digits and undercores.
+ * Feature names defined in all uppercase are reserved to CMake.
+
+See also the associated variable
+:variable:`CMAKE_<LANG>_LINK_GROUP_USING_<FEATURE>_SUPPORTED` and
+:variable:`CMAKE_LINK_GROUP_USING_<FEATURE>` variable for the definition of
+features independent from the link language.
+
+.. include:: CMAKE_LINK_GROUP_USING_FEATURE.txt
+
+Predefined Features
+^^^^^^^^^^^^^^^^^^^
+
+CMake pre-defines some features of general interest:
+
+.. include:: LINK_GROUP_PREDEFINED_FEATURES.txt
diff --git a/Help/variable/CMAKE_LANG_LINK_GROUP_USING_FEATURE_SUPPORTED.rst b/Help/variable/CMAKE_LANG_LINK_GROUP_USING_FEATURE_SUPPORTED.rst
new file mode 100644
index 0000000..533eee7
--- /dev/null
+++ b/Help/variable/CMAKE_LANG_LINK_GROUP_USING_FEATURE_SUPPORTED.rst
@@ -0,0 +1,13 @@
+CMAKE_<LANG>_LINK_GROUP_USING_<FEATURE>_SUPPORTED
+-------------------------------------------------
+
+.. versionadded:: 3.24
+
+Set to ``TRUE`` if the ``<FEATURE>``, as defined by variable
+:variable:`CMAKE_<LANG>_LINK_GROUP_USING_<FEATURE>`, is supported for the
+linker language ``<LANG>``.
+
+.. note::
+
+ This variable is evaluated before the more generic variable
+ :variable:`CMAKE_LINK_GROUP_USING_<FEATURE>_SUPPORTED`.
diff --git a/Help/variable/CMAKE_LANG_LINK_LIBRARY_USING_FEATURE.rst b/Help/variable/CMAKE_LANG_LINK_LIBRARY_USING_FEATURE.rst
new file mode 100644
index 0000000..220ae99
--- /dev/null
+++ b/Help/variable/CMAKE_LANG_LINK_LIBRARY_USING_FEATURE.rst
@@ -0,0 +1,27 @@
+CMAKE_<LANG>_LINK_LIBRARY_USING_<FEATURE>
+-----------------------------------------
+
+.. versionadded:: 3.24
+
+This variable defines, for the specified ``<FEATURE>`` and the linker language
+``<LANG>``, the expression expected by the linker when libraries are specified
+using :genex:`LINK_LIBRARY` generator expression.
+
+.. note::
+
+ * Feature names can contain Latin letters, digits and undercores.
+ * Feature names defined in all uppercase are reserved to CMake.
+
+See also the associated variable
+:variable:`CMAKE_<LANG>_LINK_LIBRARY_USING_<FEATURE>_SUPPORTED` and
+:variable:`CMAKE_LINK_LIBRARY_USING_<FEATURE>` variable for the definition of
+features independent from the link language.
+
+.. include:: CMAKE_LINK_LIBRARY_USING_FEATURE.txt
+
+Predefined Features
+^^^^^^^^^^^^^^^^^^^
+
+CMake pre-defines some features of general interest:
+
+.. include:: LINK_LIBRARY_PREDEFINED_FEATURES.txt
diff --git a/Help/variable/CMAKE_LANG_LINK_LIBRARY_USING_FEATURE_SUPPORTED.rst b/Help/variable/CMAKE_LANG_LINK_LIBRARY_USING_FEATURE_SUPPORTED.rst
new file mode 100644
index 0000000..e595bc7
--- /dev/null
+++ b/Help/variable/CMAKE_LANG_LINK_LIBRARY_USING_FEATURE_SUPPORTED.rst
@@ -0,0 +1,13 @@
+CMAKE_<LANG>_LINK_LIBRARY_USING_<FEATURE>_SUPPORTED
+---------------------------------------------------
+
+.. versionadded:: 3.24
+
+Set to ``TRUE`` if the ``<FEATURE>``, as defined by variable
+:variable:`CMAKE_<LANG>_LINK_LIBRARY_USING_<FEATURE>`, is supported for the
+linker language ``<LANG>``.
+
+.. note::
+
+ This variable is evaluated before the more generic variable
+ :variable:`CMAKE_LINK_LIBRARY_USING_<FEATURE>_SUPPORTED`.
diff --git a/Help/variable/CMAKE_LINK_GROUP_USING_FEATURE.rst b/Help/variable/CMAKE_LINK_GROUP_USING_FEATURE.rst
new file mode 100644
index 0000000..fad1837
--- /dev/null
+++ b/Help/variable/CMAKE_LINK_GROUP_USING_FEATURE.rst
@@ -0,0 +1,32 @@
+CMAKE_LINK_GROUP_USING_<FEATURE>
+--------------------------------
+
+.. versionadded:: 3.24
+
+This variable defines, for the specified ``<FEATURE>``, the expression expected
+by the linker when libraries are specified using :genex:`LINK_GROUP` generator
+expression.
+
+.. note::
+
+ * Feature names can contain Latin letters, digits and undercores.
+ * Feature names defined in all uppercase are reserved to CMake.
+
+See also the associated variable
+:variable:`CMAKE_LINK_GROUP_USING_<FEATURE>_SUPPORTED` and
+:variable:`CMAKE_<LANG>_LINK_GROUP_USING_<FEATURE>` variable for the definition
+of features dependent from the link language.
+
+This variable will be used by :genex:`LINK_GROUP` generator expression if,
+for the linker language, the variable
+:variable:`CMAKE_<LANG>_LINK_GROUP_USING_<FEATURE>_SUPPORTED` is false or not
+set.
+
+.. include:: CMAKE_LINK_GROUP_USING_FEATURE.txt
+
+Predefined Features
+^^^^^^^^^^^^^^^^^^^
+
+CMake pre-defines some features of general interest:
+
+.. include:: LINK_GROUP_PREDEFINED_FEATURES.txt
diff --git a/Help/variable/CMAKE_LINK_GROUP_USING_FEATURE.txt b/Help/variable/CMAKE_LINK_GROUP_USING_FEATURE.txt
new file mode 100644
index 0000000..ecd9cb5
--- /dev/null
+++ b/Help/variable/CMAKE_LINK_GROUP_USING_FEATURE.txt
@@ -0,0 +1,54 @@
+
+It must contain two elements.
+
+::
+
+ <PREFIX> <SUFFIX>
+
+``<PREFIX>`` and ``<SUFFIX>`` will be used to encapsulate the list of
+libraries.
+
+For the elements of this variable, the ``LINKER:`` prefix can be used:
+
+ .. include:: ../command/LINK_OPTIONS_LINKER.txt
+ :start-line: 3
+
+Examples
+^^^^^^^^
+
+Solving cross-references between two static libraries
+"""""""""""""""""""""""""""""""""""""""""""""""""""""
+
+A common need is the capability to search repeatedly in a group of static
+libraries until no new undefined references are created. This capability is
+offered by different environments but with a specific syntax:
+
+.. code-block:: cmake
+
+ set(CMAKE_C_LINK_GROUP_USING_cross_refs_SUPPORTED TRUE)
+ if(CMAKE_C_COMPILER_ID STREQUAL "GNU"
+ AND CMAKE_SYSTEM_NAME STREQUAL "Linux")
+ set(CMAKE_C_LINK_GROUP_USING_cross_refs "LINKER:--start-group"
+ "LINKER:--end-group")
+ elseif(CMAKE_C_COMPILER_ID STREQUAL "SunPro"
+ AND CMAKE_SYSTEM_NAME STREQUAL "SunOS")
+ set(CMAKE_C_LINK_GROUP_USING_cross_refs "LINKER:-z,rescan-start"
+ "LINKER:-z,rescan-end")
+ else()
+ # feature not yet supported for the other environments
+ set(CMAKE_C_LINK_GROUP_USING_cross_refs_SUPPORTED FALSE)
+ endif()
+
+ add_library(lib1 STATIC ...)
+
+ add_library(lib3 SHARED ...)
+ if(CMAKE_C_LINK_GROUP_USING_cross_refs_SUPPORTED)
+ target_link_libraries(lib3 PRIVATE "$<LINK_GROUP:cross_refs,lib1,external>")
+ else()
+ target_link_libraries(lib3 PRIVATE lib1 external)
+ endif()
+
+CMake will generate the following link expressions:
+
+* ``GNU``: ``-Wl,--start-group /path/to/lib1.a -lexternal -Wl,--end-group``
+* ``SunPro``: ``-Wl,-z,rescan-start /path/to/lib1.a -lexternal -Wl,-z,rescan-end``
diff --git a/Help/variable/CMAKE_LINK_GROUP_USING_FEATURE_SUPPORTED.rst b/Help/variable/CMAKE_LINK_GROUP_USING_FEATURE_SUPPORTED.rst
new file mode 100644
index 0000000..249ccbc
--- /dev/null
+++ b/Help/variable/CMAKE_LINK_GROUP_USING_FEATURE_SUPPORTED.rst
@@ -0,0 +1,14 @@
+CMAKE_LINK_GROUP_USING_<FEATURE>_SUPPORTED
+------------------------------------------
+
+.. versionadded:: 3.24
+
+Set to ``TRUE`` if the ``<FEATURE>``, as defined by variable
+:variable:`CMAKE_LINK_GROUP_USING_<FEATURE>`, is supported regardless the
+linker language.
+
+.. note::
+
+ This variable is evaluated if, and only if, the variable
+ :variable:`CMAKE_<LANG>_LINK_GROUP_USING_<FEATURE>_SUPPORTED` evaluates to
+ ``FALSE``.
diff --git a/Help/variable/CMAKE_LINK_LIBRARY_USING_FEATURE.rst b/Help/variable/CMAKE_LINK_LIBRARY_USING_FEATURE.rst
new file mode 100644
index 0000000..05de570
--- /dev/null
+++ b/Help/variable/CMAKE_LINK_LIBRARY_USING_FEATURE.rst
@@ -0,0 +1,32 @@
+CMAKE_LINK_LIBRARY_USING_<FEATURE>
+----------------------------------
+
+.. versionadded:: 3.24
+
+This variable defines, for the specified ``FEATURE``, the expression expected
+by the linker, regardless the linker language, when libraries are specified
+using :genex:`LINK_LIBRARY` generator expression.
+
+.. note::
+
+ * Feature names can contain Latin letters, digits and undercores.
+ * Feature names defined in all uppercase are reserved to CMake.
+
+See also the associated variable
+:variable:`CMAKE_LINK_LIBRARY_USING_<FEATURE>_SUPPORTED` and
+:variable:`CMAKE_<LANG>_LINK_LIBRARY_USING_<FEATURE>` variable for the
+definition of features dependent from the link language.
+
+This variable will be used by :genex:`LINK_LIBRARY` generator expression if,
+for the linker language, the variable
+:variable:`CMAKE_<LANG>_LINK_LIBRARY_USING_<FEATURE>_SUPPORTED` is false or not
+set.
+
+.. include:: CMAKE_LINK_LIBRARY_USING_FEATURE.txt
+
+Predefined Features
+^^^^^^^^^^^^^^^^^^^
+
+CMake pre-defines some features of general interest:
+
+.. include:: LINK_LIBRARY_PREDEFINED_FEATURES.txt
diff --git a/Help/variable/CMAKE_LINK_LIBRARY_USING_FEATURE.txt b/Help/variable/CMAKE_LINK_LIBRARY_USING_FEATURE.txt
new file mode 100644
index 0000000..ec293d3
--- /dev/null
+++ b/Help/variable/CMAKE_LINK_LIBRARY_USING_FEATURE.txt
@@ -0,0 +1,112 @@
+
+It can contain one or three elements.
+
+::
+
+ [<PREFIX>] <LIBRARY_EXPRESSION> [<SUFFIX>]
+
+When ``<PREFIX>`` and/or ``<SUFFIX>`` are specified, they encapsulate the list
+of libraries.
+
+.. note::
+
+ Even if ``<PREFIX>`` and ``<SUFFIX>`` are specified, there is not guarantee
+ that the list of specified libraries, as part of :genex:`LINK_LIBRARY`
+ generator expression, will be kept grouped. So, constructs like
+ ``start-group`` and ``end-group``, as supported by ``GNU ld``, cannot be
+ used.
+
+``<LIBRARY_EXPRESSION>`` is used to specify the decoration for each
+library. For that purpose, the patterns ``<LIBRARY>``, ``<LINK_ITEM>``, and
+``<LIB_ITEM>`` are available:
+
+* ``<LIBRARY>`` is expanded to the library as computed by CMake.
+* ``<LINK_ITEM>`` is expanded to the same expression as if the library was
+ specified in the standard way.
+* ``<LIB_ITEM>`` is equivalent to ``<LIBRARY>`` for CMake targets and is
+ expanded to the item specified by the user for external libraries.
+
+Moreover, it is possible to have different decorations for paths (CMake targets
+and external libraries specified with absolute paths) and other items specified
+by name. For that purpose, ``PATH{}`` and ``NAME{}`` wrappers can be used.
+
+For all three elements of this variable, the ``LINKER:`` prefix can be used:
+
+ .. include:: ../command/LINK_OPTIONS_LINKER.txt
+ :start-line: 3
+
+Examples
+^^^^^^^^
+
+Loading a whole static library
+""""""""""""""""""""""""""""""
+
+A common need is the capability to load a whole static library. This capability
+is offered by various environments but with a specific syntax:
+
+.. code-block:: cmake
+
+ set(CMAKE_C_LINK_LIBRARY_USING_load_archive_SUPPORTED TRUE)
+ if(CMAKE_C_COMPILER_ID STREQUAL "AppleClang")
+ set(CMAKE_C_LINK_LIBRARY_USING_load_archive "-force_load <LIB_ITEM>")
+ elseif(CMAKE_C_COMPILER_ID STREQUAL "GNU"
+ AND CMAKE_SYSTEM_NAME STREQUAL "Linux")
+ set(CMAKE_C_LINK_LIBRARY_USING_load_archive "LINKER:--push-state,--whole-archive"
+ "<LINK_ITEM>"
+ "LINKER:--pop-state")
+ elseif(CMAKE_C_COMPILER_ID STREQUAL "MSVC")
+ set(CMAKE_C_LINK_LIBRARY_USING_load_archive "/WHOLEARCHIVE:<LIBRARY>")
+ else()
+ # feature not yet supported for the other environments
+ set(CMAKE_C_LINK_LIBRARY_USING_load_archive_SUPPORTED FALSE)
+ endif()
+
+ add_library(lib1 STATIC ...)
+
+ add_library(lib2 SHARED ...)
+ if(CMAKE_C_LINK_LIBRARY_USING_load_archive_SUPPORTED)
+ target_link_libraries(lib2 PRIVATE
+ "$<LINK_LIBRARY:load_archive,lib1,$<IF:$<LINK_LANG_AND_ID:C,Clang>,libexternal.a,external>>")
+ else()
+ target_link_libraries(lib2 PRIVATE lib1 external)
+ endif()
+
+CMake will generate the following link expressions:
+
+* ``Clang``: ``-force_load /path/to/lib1.a -force_load libexternal.a``
+* ``GNU``: ``-Wl,--whole-archive /path/to/lib1.a -lexternal -Wl,--no-whole-archive``
+* ``MSVC``: ``/WHOLEARCHIVE:/path/to/lib1.lib /WHOLEARCHIVE:external.lib``
+
+CMake will ensure, when possible, that ``<PREFIX>`` and ``<SUFFIX>`` are
+not repeated for each library.
+
+In case of ``Clang``, the pattern ``<LIB_ITEM>`` is used because we need to
+specify the library as defined by the user, not the name computed by CMake
+(in that case ``external``).
+
+Linking a library as weak
+"""""""""""""""""""""""""
+
+On MacOS, it is possible to link a library in weak mode (the library and all
+references are marked as weak imports), but different flags must be used for a
+library specified by path and by name. This constraint by be solved by using
+``PATH{}`` and ``NAME{}`` wrappers:
+
+.. code-block:: cmake
+
+ if (CMAKE_C_COMPILER_ID STREQUAL "AppleClang")
+ set(CMAKE_LINK_LIBRARY_USING_weak_library
+ "PATH{-weak_library <LIBRARY>}NAME{LINKER:-weak-l<LIB_ITEM>}")
+ set(CMAKE_LINK_LIBRARY_USING_weak_library_SUPPORTED TRUE)
+ endif()
+
+ add_library(lib SHARED ...)
+ add_executable(main ...)
+ if(CMAKE_LINK_LIBRARY_USING_weak_library_SUPPORTED)
+ target_link_libraries(main PRIVATE "$<LINK_LIBRARY:weak_library,lib,external>")
+ else()
+ target_link_libraries(main PRIVATE lib external)
+ endif()
+
+CMake will generate the following link expression:
+``-weak_library /path/to/lib -Xlinker -weak-lexternal``
diff --git a/Help/variable/CMAKE_LINK_LIBRARY_USING_FEATURE_SUPPORTED.rst b/Help/variable/CMAKE_LINK_LIBRARY_USING_FEATURE_SUPPORTED.rst
new file mode 100644
index 0000000..42b75fc
--- /dev/null
+++ b/Help/variable/CMAKE_LINK_LIBRARY_USING_FEATURE_SUPPORTED.rst
@@ -0,0 +1,14 @@
+CMAKE_LINK_LIBRARY_USING_<FEATURE>_SUPPORTED
+--------------------------------------------
+
+.. versionadded:: 3.24
+
+Set to ``TRUE`` if the ``<FEATURE>``, as defined by variable
+:variable:`CMAKE_LINK_LIBRARY_USING_<FEATURE>`, is supported regardless the
+linker language.
+
+.. note::
+
+ This variable is evaluated if, and only if, the variable
+ :variable:`CMAKE_<LANG>_LINK_LIBRARY_USING_<FEATURE>_SUPPORTED` evaluates to
+ ``FALSE``.
diff --git a/Help/variable/CTEST_CUSTOM_MAXIMUM_FAILED_TEST_OUTPUT_SIZE.rst b/Help/variable/CTEST_CUSTOM_MAXIMUM_FAILED_TEST_OUTPUT_SIZE.rst
index 7e7d431..007cfe0 100644
--- a/Help/variable/CTEST_CUSTOM_MAXIMUM_FAILED_TEST_OUTPUT_SIZE.rst
+++ b/Help/variable/CTEST_CUSTOM_MAXIMUM_FAILED_TEST_OUTPUT_SIZE.rst
@@ -3,7 +3,8 @@
When saving a failing test's output, this is the maximum size, in bytes, that
will be collected by the :command:`ctest_test` command. Defaults to 307200
-(300 KiB).
+(300 KiB). See :variable:`CTEST_CUSTOM_TEST_OUTPUT_TRUNCATION` for possible
+truncation modes.
If a test's output contains the literal string "CTEST_FULL_OUTPUT",
the output will not be truncated and may exceed the maximum size.
diff --git a/Help/variable/CTEST_CUSTOM_MAXIMUM_PASSED_TEST_OUTPUT_SIZE.rst b/Help/variable/CTEST_CUSTOM_MAXIMUM_PASSED_TEST_OUTPUT_SIZE.rst
index 64367f9..8545fc4 100644
--- a/Help/variable/CTEST_CUSTOM_MAXIMUM_PASSED_TEST_OUTPUT_SIZE.rst
+++ b/Help/variable/CTEST_CUSTOM_MAXIMUM_PASSED_TEST_OUTPUT_SIZE.rst
@@ -3,7 +3,8 @@
When saving a passing test's output, this is the maximum size, in bytes, that
will be collected by the :command:`ctest_test` command. Defaults to 1024
-(1 KiB).
+(1 KiB). See :variable:`CTEST_CUSTOM_TEST_OUTPUT_TRUNCATION` for possible
+truncation modes.
If a test's output contains the literal string "CTEST_FULL_OUTPUT",
the output will not be truncated and may exceed the maximum size.
diff --git a/Help/variable/CTEST_CUSTOM_TEST_OUTPUT_TRUNCATION.rst b/Help/variable/CTEST_CUSTOM_TEST_OUTPUT_TRUNCATION.rst
new file mode 100644
index 0000000..2d4219e
--- /dev/null
+++ b/Help/variable/CTEST_CUSTOM_TEST_OUTPUT_TRUNCATION.rst
@@ -0,0 +1,12 @@
+CTEST_CUSTOM_TEST_OUTPUT_TRUNCATION
+-----------------------------------
+
+.. versionadded:: 3.24
+
+Set the test output truncation mode in case a maximum size is configured
+via the :variable:`CTEST_CUSTOM_MAXIMUM_PASSED_TEST_OUTPUT_SIZE` or
+:variable:`CTEST_CUSTOM_MAXIMUM_FAILED_TEST_OUTPUT_SIZE` variables.
+By default the ``tail`` of the output will be truncated. Other possible
+values are ``middle`` and ``head``.
+
+.. include:: CTEST_CUSTOM_XXX.txt
diff --git a/Help/variable/LINK_GROUP_PREDEFINED_FEATURES.txt b/Help/variable/LINK_GROUP_PREDEFINED_FEATURES.txt
new file mode 100644
index 0000000..7c5b458
--- /dev/null
+++ b/Help/variable/LINK_GROUP_PREDEFINED_FEATURES.txt
@@ -0,0 +1,22 @@
+**Circular references with static libraries**
+
+Some linkers are one-pass only so to handle circular references between
+static libraries, the following feature can be used:
+
+``RESCAN``
+ The specified static libraries are searched repeatedly until no
+ new undefined references are created. Normally, an static library is searched
+ only once in the order that it is specified on the command line. If a symbol
+ in that library is needed to resolve an undefined symbol referred to by an
+ object in an library that appears later on the command line, the linker would
+ not be able to resolve that reference. By grouping the static libraries, they
+ all be searched repeatedly until all possible references are resolved (use
+ linker options ``--start-group`` and ``--end-group`` or, on ``SunOS``,
+ ``-z rescan-start`` and ``-z rescan-end``).
+
+ Using this feature has a significant performance cost. It is best to use it
+ only when there are unavoidable circular references between two or more static
+ libraries.
+
+ This feature is available on ``Linux`` and ``SunOS`` platforms as well as
+ ``Windows`` when ``GNU`` toolchain is used.
diff --git a/Help/variable/LINK_LIBRARY_PREDEFINED_FEATURES.txt b/Help/variable/LINK_LIBRARY_PREDEFINED_FEATURES.txt
new file mode 100644
index 0000000..e4fa0ed8
--- /dev/null
+++ b/Help/variable/LINK_LIBRARY_PREDEFINED_FEATURES.txt
@@ -0,0 +1,88 @@
+**Features available in all environments**
+
+``DEFAULT``
+ This feature enables default link expression. This is mainly
+ useful with :prop_tgt:`LINK_LIBRARY_OVERRIDE` and
+ :prop_tgt:`LINK_LIBRARY_OVERRIDE_<LIBRARY>` target properties.
+
+**Features available for a subset of environments**
+
+``WHOLE_ARCHIVE``
+ Force load of all members in a static library.
+
+ Target platforms supported: all ``Apple`` variants, ``Linux``, all ``BSD``
+ variants, ``SunOS``, ``Windows``, ``CYGWIN``, and ``MSYS``.
+
+ Platform-specific notes:
+
+ * On Apple platforms, the library must be specified as a CMake target name, a
+ library file name (such as ``libfoo.a``), or a library file path (such as
+ ``/path/to/libfoo.a``). It cannot be specified as a plain library name
+ (such as ``foo``, where ``foo`` is not CMake target), due to a limitation
+ in the Apple linker.
+ * On Windows platforms, for ``MSVC`` or MSVC-like toolchains, the version
+ must be greater than ``1900``.
+
+**Features available in Apple environments**
+
+It is assumed that the linker used is the one provided by `XCode` or is
+compatible with it.
+
+Framework support
+
+``FRAMEWORK``
+ This option tells the linker to search for the specified
+ framework (use linker option ``-framework``).
+``NEEDED_FRAMEWORK``
+ This is the same as the ``FRAMEWORK`` feature but means
+ to really link with the framework even if no symbols are used from it (use
+ linker option ``-needed_framework``).
+``REEXPORT_FRAMEWORK``
+ This is the same as the ``FRAMEWORK`` feature but
+ also specifies that all symbols in that framework should be available to
+ clients linking to the library being created (use linker option
+ ``-reexport_framework``).
+``WEAK_FRAMEWORK``
+ This is the same as the ``FRAMEWORK`` feature but forces
+ the framework and all references to it to be marked as weak imports (use
+ linker option ``-weak_framework``).
+
+Features for framework linking have a special handling in CMake: the
+framework can be specified as a CMake framework target or file path. In the
+first case, the target must have the :prop_tgt:`FRAMEWORK` target property set
+as ``TRUE`` to enable framework handling. In the later case, if the path
+includes a directory part, this one will be specified as framework search path
+at link step.
+
+.. code-block:: cmake
+
+ add_library(lib SHARED ...)
+ target_link_libraries(lib PRIVATE "$<LINK_LIBRARY:NEEDED_FRAMEWORK,/path/to/my_framework>")
+
+ # at link step we will have:
+ # -F/path/to -needed_framework my_framework
+
+.. note::
+
+ The expected formats for the file path, with optional parts specified as
+ ``()?``, are:
+
+ * (/path/to/)?FwName(.framework)?
+ * (/path/to/)?FwName.framework/FwName
+ * (/path/to/)?FwName.framework/Versions/\*/FwName
+
+Library support
+
+``NEEDED_LIBRARY``
+ This is the same as specifying a link item (target or
+ library) but means to really link with the item even if no symbols are used
+ from it (use linker option ``-needed_library`` or ``-needed-l``).
+``REEXPORT_LIBRARY``
+ This is the same as specifying a link item (target or
+ library) but also specifies that all symbols in that item should be available
+ to clients linking to the library being created (use linker option
+ ``-reexport_library`` or ``-reexport-l``).
+``WEAK_LIBRARY``
+ This is the same as specifying a link item (target or
+ library) but forces the item and all references to it to be marked as weak
+ imports (use linker option ``-weak_library`` or ``-weak-l``).
diff --git a/Modules/CMakeCUDACompiler.cmake.in b/Modules/CMakeCUDACompiler.cmake.in
index 9f2e213..57d595a 100644
--- a/Modules/CMakeCUDACompiler.cmake.in
+++ b/Modules/CMakeCUDACompiler.cmake.in
@@ -55,6 +55,7 @@
set(CMAKE_CUDA_ARCHITECTURES_ALL "@CMAKE_CUDA_ARCHITECTURES_ALL@")
set(CMAKE_CUDA_ARCHITECTURES_ALL_MAJOR "@CMAKE_CUDA_ARCHITECTURES_ALL_MAJOR@")
+set(CMAKE_CUDA_ARCHITECTURES_NATIVE "@CMAKE_CUDA_ARCHITECTURES_NATIVE@")
set(CMAKE_CUDA_TOOLKIT_INCLUDE_DIRECTORIES "@CMAKE_CUDA_TOOLKIT_INCLUDE_DIRECTORIES@")
diff --git a/Modules/CMakeCUDACompilerABI.cu b/Modules/CMakeCUDACompilerABI.cu
index 449a079..8463e86 100644
--- a/Modules/CMakeCUDACompilerABI.cu
+++ b/Modules/CMakeCUDACompilerABI.cu
@@ -2,6 +2,10 @@
# error "A C or C++ compiler has been selected for CUDA"
#endif
+#include <cstdio>
+
+#include <cuda_runtime.h>
+
#include "CMakeCompilerABI.h"
int main(int argc, char* argv[])
@@ -13,6 +17,31 @@
#if defined(ABI_ID)
require += info_abi[argc];
#endif
- (void)argv;
- return require;
+ static_cast<void>(argv);
+
+ int count = 0;
+ if (cudaGetDeviceCount(&count) != cudaSuccess || count == 0) {
+ std::fprintf(stderr, "No CUDA devices found.\n");
+ return -1;
+ }
+
+ int found = 0;
+ const char* sep = "";
+ for (int device = 0; device < count; ++device) {
+ cudaDeviceProp prop;
+ if (cudaGetDeviceProperties(&prop, device) == cudaSuccess) {
+ std::printf("%s%d%d", sep, prop.major, prop.minor);
+ sep = ";";
+ found = 1;
+ }
+ }
+
+ if (!found) {
+ std::fprintf(stderr, "No CUDA architecture detected from any devices.\n");
+ // Convince the compiler that the non-zero return value depends
+ // on the info strings so they are not optimized out.
+ return require ? -1 : 1;
+ }
+
+ return 0;
}
diff --git a/Modules/CMakeDetermineCUDACompiler.cmake b/Modules/CMakeDetermineCUDACompiler.cmake
index 2649441..f68c4b2 100644
--- a/Modules/CMakeDetermineCUDACompiler.cmake
+++ b/Modules/CMakeDetermineCUDACompiler.cmake
@@ -249,7 +249,8 @@
set(CMAKE_CUDA_COMPILER_TOOLKIT_VERSION "${CMAKE_MATCH_1}")
endif()
- # Make the all and all-major architecture information available.
+ # Make the all, all-major, and native architecture information available.
+ # FIXME(#23161): Defer architecture detection until compiler testing.
include(${CMAKE_ROOT}/Modules/CUDA/architectures.cmake)
endif()
@@ -272,6 +273,7 @@
endif()
endif()
+ # FIXME(#23161): Defer architecture testing until compiler testing.
if(DEFINED CMAKE_CUDA_ARCHITECTURES)
if(CMAKE_CUDA_ARCHITECTURES MATCHES "^(all|all-major)$")
# For sufficiently new NVCC we can just use the all and all-major flags.
@@ -289,6 +291,17 @@
set(architectures_test ${CMAKE_CUDA_ARCHITECTURES_ALL_MAJOR})
endif()
endif()
+ elseif(CMAKE_CUDA_ARCHITECTURES STREQUAL "native")
+ # For sufficiently new NVCC we can just use the 'native' value directly.
+ # For VS we don't test since we can't find nvcc this early (see #23161).
+ if(CMAKE_CUDA_COMPILER_ID STREQUAL "NVIDIA" AND CMAKE_CUDA_COMPILER_TOOLKIT_VERSION VERSION_GREATER_EQUAL 11.6)
+ string(APPEND nvcc_test_flags " -arch=${CMAKE_CUDA_ARCHITECTURES}")
+ set(architectures_tested "${CMAKE_CUDA_ARCHITECTURES}")
+ elseif(CMAKE_GENERATOR MATCHES "Visual Studio")
+ set(architectures_tested "${CMAKE_CUDA_ARCHITECTURES}")
+ else()
+ set(architectures_test ${_CUDA_ARCHITECTURES_NATIVE})
+ endif()
elseif(CMAKE_CUDA_ARCHITECTURES OR "${CMAKE_CUDA_ARCHITECTURES}" STREQUAL "")
# Explicit architectures. Test them during detection.
set(architectures_explicit TRUE)
@@ -346,6 +359,7 @@
# We now know the version, so make the architecture variables available.
set(CMAKE_CUDA_COMPILER_TOOLKIT_VERSION ${CMAKE_CUDA_COMPILER_VERSION})
+ # FIXME(#23161): Defer architecture detection until compiler testing.
include(${CMAKE_ROOT}/Modules/CUDA/architectures.cmake)
endif()
@@ -633,7 +647,7 @@
message(FATAL_ERROR "Failed to detect a default CUDA architecture.\n\nCompiler output:\n${CMAKE_CUDA_COMPILER_PRODUCED_OUTPUT}")
endif()
endif()
-elseif(CMAKE_CUDA_ARCHITECTURES AND NOT "${architectures_tested}" MATCHES "^(all|all-major)$")
+elseif(CMAKE_CUDA_ARCHITECTURES AND NOT "${architectures_tested}" MATCHES "^(all|all-major|native)$")
# Sort since order mustn't matter.
list(SORT architectures_detected)
list(SORT architectures_tested)
diff --git a/Modules/CMakeDetermineCompilerABI.cmake b/Modules/CMakeDetermineCompilerABI.cmake
index 8191d81..82a6d21 100644
--- a/Modules/CMakeDetermineCompilerABI.cmake
+++ b/Modules/CMakeDetermineCompilerABI.cmake
@@ -26,6 +26,14 @@
if(DEFINED CMAKE_${lang}_VERBOSE_COMPILE_FLAG)
set(COMPILE_DEFINITIONS "${CMAKE_${lang}_VERBOSE_COMPILE_FLAG}")
endif()
+ if(lang STREQUAL "CUDA")
+ if(CMAKE_CUDA_ARCHITECTURES STREQUAL "native")
+ # We are about to detect the native architectures, so we do
+ # not yet know them. Use all architectures during detection.
+ set(CMAKE_CUDA_ARCHITECTURES "all")
+ endif()
+ set(CMAKE_CUDA_RUNTIME_LIBRARY "Static")
+ endif()
if(NOT "x${CMAKE_${lang}_COMPILER_ID}" STREQUAL "xMSVC")
# Avoid adding our own platform standard libraries for compilers
# from which we might detect implicit link libraries.
diff --git a/Modules/CMakeDetermineCompilerId.cmake b/Modules/CMakeDetermineCompilerId.cmake
index 5670509..0317f34 100644
--- a/Modules/CMakeDetermineCompilerId.cmake
+++ b/Modules/CMakeDetermineCompilerId.cmake
@@ -495,7 +495,7 @@
if(CMAKE_VS_PLATFORM_NAME STREQUAL x64)
set(cuda_target "<TargetMachinePlatform>64</TargetMachinePlatform>")
endif()
- if(CMAKE_CUDA_ARCHITECTURES AND NOT CMAKE_CUDA_ARCHITECTURES MATCHES "^(all|all-major)$")
+ if(CMAKE_CUDA_ARCHITECTURES AND NOT CMAKE_CUDA_ARCHITECTURES MATCHES "^(all|all-major|native)$")
foreach(arch ${CMAKE_CUDA_ARCHITECTURES})
string(REGEX MATCH "[0-9]+" arch_name "${arch}")
string(APPEND cuda_codegen "compute_${arch_name},sm_${arch_name};")
diff --git a/Modules/CMakeGenericSystem.cmake b/Modules/CMakeGenericSystem.cmake
index 649b6f7..e2925dc 100644
--- a/Modules/CMakeGenericSystem.cmake
+++ b/Modules/CMakeGenericSystem.cmake
@@ -24,6 +24,12 @@
set(CMAKE_FIND_LIBRARY_PREFIXES "lib")
set(CMAKE_FIND_LIBRARY_SUFFIXES ".so" ".a")
+# Define feature "DEFAULT" as supported. This special feature generates the
+# default option to link a library
+# This feature is intended to be used in LINK_LIBRARY_OVERRIDE and
+# LINK_LIBRARY_OVERRIDE_<LIBRARY> target properties
+set(CMAKE_LINK_LIBRARY_USING_DEFAULT_SUPPORTED TRUE)
+
set(CMAKE_AUTOGEN_ORIGIN_DEPENDS ON)
set(CMAKE_AUTOMOC_COMPILER_PREDEFINES ON)
if(NOT DEFINED CMAKE_AUTOMOC_PATH_PREFIX)
@@ -41,11 +47,16 @@
set(CMAKE_VERBOSE_MAKEFILE FALSE CACHE BOOL "If this value is on, makefiles will be generated without the .SILENT directive, and all commands will be echoed to the console during the make. This is useful for debugging only. With Visual Studio IDE projects all commands are done without /nologo.")
+if(DEFINED ENV{CMAKE_COLOR_DIAGNOSTICS} AND NOT DEFINED CACHE{CMAKE_COLOR_DIAGNOSTICS})
+ set(CMAKE_COLOR_DIAGNOSTICS $ENV{CMAKE_COLOR_DIAGNOSTICS} CACHE BOOL "Enable colored diagnostics throughout.")
+endif()
+
if(CMAKE_GENERATOR MATCHES "Make")
- set(CMAKE_COLOR_MAKEFILE ON CACHE BOOL
- "Enable/Disable color output during build."
- )
+ if(NOT DEFINED CMAKE_COLOR_DIAGNOSTICS)
+ set(CMAKE_COLOR_MAKEFILE ON CACHE BOOL "Enable/Disable color output during build.")
+ endif()
mark_as_advanced(CMAKE_COLOR_MAKEFILE)
+
if(DEFINED CMAKE_RULE_MESSAGES)
set_property(GLOBAL PROPERTY RULE_MESSAGES ${CMAKE_RULE_MESSAGES})
endif()
diff --git a/Modules/CMakeTestCUDACompiler.cmake b/Modules/CMakeTestCUDACompiler.cmake
index 25a3653..ea07482 100644
--- a/Modules/CMakeTestCUDACompiler.cmake
+++ b/Modules/CMakeTestCUDACompiler.cmake
@@ -21,6 +21,51 @@
# The compiler worked so skip dedicated test below.
set(CMAKE_CUDA_COMPILER_WORKS TRUE)
message(STATUS "Check for working CUDA compiler: ${CMAKE_CUDA_COMPILER} - skipped")
+
+ # Run the test binary to detect the native architectures.
+ execute_process(COMMAND "${CMAKE_PLATFORM_INFO_DIR}/CMakeDetermineCompilerABI_CUDA.bin"
+ RESULT_VARIABLE _CUDA_ARCHS_RESULT
+ OUTPUT_VARIABLE _CUDA_ARCHS_OUTPUT
+ ERROR_VARIABLE _CUDA_ARCHS_OUTPUT
+ OUTPUT_STRIP_TRAILING_WHITESPACE
+ )
+ if(_CUDA_ARCHS_RESULT EQUAL 0)
+ if("$ENV{CMAKE_CUDA_ARCHITECTURES_NATIVE_CLAMP}")
+ # Undocumented hook used by CMake's CI.
+ # Clamp native architecture to version range supported by this CUDA.
+ list(GET CMAKE_CUDA_ARCHITECTURES_ALL 0 _CUDA_ARCH_MIN)
+ list(GET CMAKE_CUDA_ARCHITECTURES_ALL -1 _CUDA_ARCH_MAX)
+ set(CMAKE_CUDA_ARCHITECTURES_NATIVE "")
+ foreach(_CUDA_ARCH IN LISTS _CUDA_ARCHS_OUTPUT)
+ if(_CUDA_ARCH LESS _CUDA_ARCH_MIN)
+ set(_CUDA_ARCH "${_CUDA_ARCH_MIN}")
+ endif()
+ if(_CUDA_ARCH GREATER _CUDA_ARCH_MAX)
+ set(_CUDA_ARCH "${_CUDA_ARCH_MAX}")
+ endif()
+ list(APPEND CMAKE_CUDA_ARCHITECTURES_NATIVE ${_CUDA_ARCH})
+ endforeach()
+ unset(_CUDA_ARCH)
+ unset(_CUDA_ARCH_MIN)
+ unset(_CUDA_ARCH_MAX)
+ else()
+ set(CMAKE_CUDA_ARCHITECTURES_NATIVE "${_CUDA_ARCHS_OUTPUT}")
+ endif()
+ list(REMOVE_DUPLICATES CMAKE_CUDA_ARCHITECTURES_NATIVE)
+ else()
+ if(NOT _CUDA_ARCHS_RESULT MATCHES "[0-9]+")
+ set(_CUDA_ARCHS_STATUS " (${_CUDA_ARCHS_RESULT})")
+ else()
+ set(_CUDA_ARCHS_STATUS "")
+ endif()
+ string(REPLACE "\n" "\n " _CUDA_ARCHS_OUTPUT " ${_CUDA_ARCHS_OUTPUT}")
+ file(APPEND ${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeError.log
+ "Detecting the CUDA native architecture(s) failed with "
+ "the following output:\n${_CUDA_ARCHS_OUTPUT}\n\n")
+ endif()
+ unset(_CUDA_ARCHS_EXE)
+ unset(_CUDA_ARCHS_RESULT)
+ unset(_CUDA_ARCHS_OUTPUT)
endif()
# This file is used by EnableLanguage in cmGlobalGenerator to
diff --git a/Modules/CPack.cmake b/Modules/CPack.cmake
index 6650f7c..5a22be5 100644
--- a/Modules/CPack.cmake
+++ b/Modules/CPack.cmake
@@ -304,15 +304,26 @@
By default ``CPACK_THREADS`` is set to ``1``.
- Currently only ``xz`` compression *may* take advantage of multiple cores.
+ The following compression methods may take advantage of multiple cores:
+
+ ``xz``
+ Supported if CMake is built with a ``liblzma`` that supports
+ parallel compression.
+
+ .. versionadded:: 3.21
+
+ Official CMake binaries available on ``cmake.org`` now ship
+ with a ``liblzma`` that supports parallel compression.
+ Older versions did not.
+
+ ``zstd``
+ .. versionadded:: 3.24
+
+ Supported if CMake is built with libarchive 3.6 or higher.
+ Official CMake binaries available on ``cmake.org`` support it.
+
Other compression methods ignore this value and use only one thread.
- .. versionadded:: 3.21
-
- Official CMake binaries available on ``cmake.org`` now ship
- with a ``liblzma`` that supports parallel compression.
- Older versions did not.
-
Variables for Source Package Generators
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
diff --git a/Modules/CUDA/architectures.cmake b/Modules/CUDA/architectures.cmake
index fa3a5a1..9b1f2b5 100644
--- a/Modules/CUDA/architectures.cmake
+++ b/Modules/CUDA/architectures.cmake
@@ -44,3 +44,63 @@
AND (NOT CMAKE_CUDA_COMPILER_ID STREQUAL "Clang"))
list(APPEND CMAKE_CUDA_ARCHITECTURES_ALL 87)
endif()
+
+# FIXME(#23161): Detect architectures early since we test them during
+# compiler detection. We already have code to detect them later during
+# compiler testing, so we should not need to do this here.
+if(NOT CMAKE_GENERATOR MATCHES "Visual Studio")
+ set(_CUDA_ARCHS_EXE "${CMAKE_PLATFORM_INFO_DIR}/CMakeDetermineCUDACompilerArchs.bin")
+ execute_process(
+ COMMAND "${_CUDA_NVCC_EXECUTABLE}" -o "${_CUDA_ARCHS_EXE}" --cudart=static "${CMAKE_ROOT}/Modules/CMakeCUDACompilerABI.cu"
+ RESULT_VARIABLE _CUDA_ARCHS_RESULT
+ OUTPUT_VARIABLE _CUDA_ARCHS_OUTPUT
+ ERROR_VARIABLE _CUDA_ARCHS_OUTPUT
+ )
+ if(_CUDA_ARCHS_RESULT EQUAL 0)
+ execute_process(
+ COMMAND "${_CUDA_ARCHS_EXE}"
+ RESULT_VARIABLE _CUDA_ARCHS_RESULT
+ OUTPUT_VARIABLE _CUDA_ARCHS_OUTPUT
+ ERROR_VARIABLE _CUDA_ARCHS_OUTPUT
+ OUTPUT_STRIP_TRAILING_WHITESPACE
+ )
+ endif()
+ if(_CUDA_ARCHS_RESULT EQUAL 0)
+ if("$ENV{CMAKE_CUDA_ARCHITECTURES_NATIVE_CLAMP}")
+ # Undocumented hook used by CMake's CI.
+ # Clamp native architecture to version range supported by this CUDA.
+ list(GET CMAKE_CUDA_ARCHITECTURES_ALL 0 _CUDA_ARCH_MIN)
+ list(GET CMAKE_CUDA_ARCHITECTURES_ALL -1 _CUDA_ARCH_MAX)
+ set(_CUDA_ARCHITECTURES_NATIVE "")
+ foreach(_CUDA_ARCH IN LISTS _CUDA_ARCHS_OUTPUT)
+ if(_CUDA_ARCH LESS _CUDA_ARCH_MIN)
+ set(_CUDA_ARCH "${_CUDA_ARCH_MIN}")
+ endif()
+ if(_CUDA_ARCH GREATER _CUDA_ARCH_MAX)
+ set(_CUDA_ARCH "${_CUDA_ARCH_MAX}")
+ endif()
+ list(APPEND _CUDA_ARCHITECTURES_NATIVE ${_CUDA_ARCH})
+ endforeach()
+ unset(_CUDA_ARCH)
+ unset(_CUDA_ARCH_MIN)
+ unset(_CUDA_ARCH_MAX)
+ else()
+ set(_CUDA_ARCHITECTURES_NATIVE "${_CUDA_ARCHS_OUTPUT}")
+ endif()
+ list(REMOVE_DUPLICATES _CUDA_ARCHITECTURES_NATIVE)
+ else()
+ if (NOT _CUDA_ARCHS_RESULT MATCHES "[0-9]+")
+ set(_CUDA_ARCHS_STATUS " (${_CUDA_ARCHS_RESULT})")
+ else()
+ set(_CUDA_ARCHS_STATUS "")
+ endif()
+ string(REPLACE "\n" "\n " _CUDA_ARCHS_OUTPUT " ${_CUDA_ARCHS_OUTPUT}")
+ file(APPEND ${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeError.log
+ "Detecting the CUDA native architecture(s) failed with "
+ "the following output:\n${_CUDA_ARCHS_OUTPUT}\n\n")
+ set(_CUDA_ARCHS_OUTPUT "")
+ endif()
+ unset(_CUDA_ARCHS_EXE)
+ unset(_CUDA_ARCHS_RESULT)
+ unset(_CUDA_ARCHS_OUTPUT)
+endif()
diff --git a/Modules/Compiler/Clang.cmake b/Modules/Compiler/Clang.cmake
index f885eb0..df115d3 100644
--- a/Modules/Compiler/Clang.cmake
+++ b/Modules/Compiler/Clang.cmake
@@ -114,6 +114,12 @@
endif()
set(CMAKE_${lang}_COMPILE_OPTIONS_USE_PCH -Xclang -include-pch -Xclang <PCH_FILE> -Xclang -include -Xclang <PCH_HEADER>)
set(CMAKE_${lang}_COMPILE_OPTIONS_CREATE_PCH -Xclang -emit-pch -Xclang -include -Xclang <PCH_HEADER> -x ${__pch_header_${lang}})
+
+ # '-fcolor-diagnostics' introduced since Clang 2.6
+ if(CMAKE_${lang}_COMPILER_VERSION VERSION_GREATER_EQUAL 2.6)
+ set(CMAKE_${lang}_COMPILE_OPTIONS_COLOR_DIAGNOSTICS "-fcolor-diagnostics")
+ set(CMAKE_${lang}_COMPILE_OPTIONS_COLOR_DIAGNOSTICS_OFF "-fno-color-diagnostics")
+ endif()
endmacro()
endif()
diff --git a/Modules/Compiler/GNU.cmake b/Modules/Compiler/GNU.cmake
index 928e726..2eef532 100644
--- a/Modules/Compiler/GNU.cmake
+++ b/Modules/Compiler/GNU.cmake
@@ -119,4 +119,11 @@
set(CMAKE_${lang}_COMPILE_OPTIONS_USE_PCH -include <PCH_HEADER>)
set(CMAKE_${lang}_COMPILE_OPTIONS_CREATE_PCH -x ${__pch_header_${lang}} -include <PCH_HEADER>)
endif()
+
+ # '-fdiagnostics-color=always' introduced since GCC 4.9
+ # https://gcc.gnu.org/gcc-4.9/changes.html
+ if(CMAKE_${lang}_COMPILER_VERSION VERSION_GREATER_EQUAL 4.9)
+ set(CMAKE_${lang}_COMPILE_OPTIONS_COLOR_DIAGNOSTICS "-fdiagnostics-color=always")
+ set(CMAKE_${lang}_COMPILE_OPTIONS_COLOR_DIAGNOSTICS_OFF "-fno-diagnostics-color")
+ endif()
endmacro()
diff --git a/Modules/Compiler/SunPro-C.cmake b/Modules/Compiler/SunPro-C.cmake
index c98656f..7a406ac 100644
--- a/Modules/Compiler/SunPro-C.cmake
+++ b/Modules/Compiler/SunPro-C.cmake
@@ -33,8 +33,13 @@
set(CMAKE_${type}_LINK_DYNAMIC_C_FLAGS "-Bdynamic")
endforeach()
-set(CMAKE_C_LINKER_WRAPPER_FLAG "-Qoption" "ld" " ")
-set(CMAKE_C_LINKER_WRAPPER_FLAG_SEP ",")
+if (CMAKE_C_COMPILER_VERSION VERSION_GREATER_EQUAL "5.12")
+ set(CMAKE_C_LINKER_WRAPPER_FLAG "-Qoption" "ld" " ")
+ set(CMAKE_C_LINKER_WRAPPER_FLAG_SEP ",")
+else()
+ set(CMAKE_C_LINKER_WRAPPER_FLAG "-Wl,")
+ set(CMAKE_C_LINKER_WRAPPER_FLAG_SEP ",")
+endif()
if (CMAKE_C_COMPILER_VERSION VERSION_GREATER_EQUAL 5.13)
set(CMAKE_C90_STANDARD_COMPILE_OPTION "-std=c89")
diff --git a/Modules/ExternalProject.cmake b/Modules/ExternalProject.cmake
index 7f16fdc..42cb7a0 100644
--- a/Modules/ExternalProject.cmake
+++ b/Modules/ExternalProject.cmake
@@ -353,6 +353,10 @@
When ``GIT_REMOTE_UPDATE_STRATEGY`` is not present, this is the
default strategy unless the default has been overridden with
``CMAKE_EP_GIT_REMOTE_UPDATE_STRATEGY`` (see below).
+ Note that if the branch specified in ``GIT_TAG`` is different to
+ the upstream branch currently being tracked, it is not safe to
+ perform a rebase. In that situation, ``REBASE`` will silently be
+ treated as ``CHECKOUT`` instead.
``REBASE_CHECKOUT``
Same as ``REBASE`` except if the rebase fails, an annotated tag will
diff --git a/Modules/ExternalProject/gitupdate.cmake.in b/Modules/ExternalProject/gitupdate.cmake.in
index 0de2372..7896f62 100644
--- a/Modules/ExternalProject/gitupdate.cmake.in
+++ b/Modules/ExternalProject/gitupdate.cmake.in
@@ -128,7 +128,7 @@
else()
execute_process(
- COMMAND "@git_EXECUTABLE@" for-each-ref "--format='%(upstream:short)'" "${current_branch}"
+ COMMAND "@git_EXECUTABLE@" for-each-ref "--format=%(upstream:short)" "${current_branch}"
WORKING_DIRECTORY "@work_dir@"
OUTPUT_VARIABLE upstream_branch
OUTPUT_STRIP_TRAILING_WHITESPACE
diff --git a/Modules/FindX11.cmake b/Modules/FindX11.cmake
index fd5ee53..8e5a5f1 100644
--- a/Modules/FindX11.cmake
+++ b/Modules/FindX11.cmake
@@ -31,8 +31,11 @@
X11_xcb_INCLUDE_PATH, X11_xcb_LIB, X11_xcb_FOUND, X11::xcb
X11_X11_xcb_INCLUDE_PATH, X11_X11_xcb_LIB, X11_X11_xcb_FOUND, X11::X11_xcb
X11_xcb_icccm_INCLUDE_PATH, X11_xcb_icccm_LIB, X11_xcb_icccm_FOUND, X11::xcb_icccm
+ X11_xcb_randr_INCLUDE_PATH, X11_xcb_randr_LIB, X11_xcb_randr_FOUND, X11::xcb_randr
X11_xcb_util_INCLUDE_PATH, X11_xcb_util_LIB, X11_xcb_util_FOUND, X11::xcb_util
X11_xcb_xfixes_INCLUDE_PATH, X11_xcb_xfixes_LIB, X11_xcb_xfixes_FOUND, X11::xcb_xfixes
+ X11_xcb_xtest_INCLUDE_PATH, X11_xcb_xtest_LIB, X11_xcb_xtest_FOUND, X11::xcb_xtest
+ X11_xcb_keysyms_INCLUDE_PATH, X11_xcb_keysyms_LIB,X11_xcb_keysyms_FOUND,X11::xcb_keysyms
X11_xcb_xkb_INCLUDE_PATH, X11_xcb_xkb_LIB, X11_xcb_xkb_FOUND, X11::xcb_xkb
X11_Xcomposite_INCLUDE_PATH, X11_Xcomposite_LIB, X11_Xcomposite_FOUND, X11::Xcomposite
X11_Xcursor_INCLUDE_PATH, X11_Xcursor_LIB, X11_Xcursor_FOUND, X11::Xcursor
@@ -82,6 +85,9 @@
.. versionadded:: 3.19
Added the ``Xaw``, ``xcb_util``, and ``xcb_xfixes`` libraries.
+.. versionadded:: 3.24
+ Added the ``xcb_randr``, ``xcb_xtext``, and ``xcb_keysyms`` libraries.
+
#]=======================================================================]
if (UNIX)
@@ -127,8 +133,11 @@
find_path(X11_xcb_INCLUDE_PATH xcb/xcb.h ${X11_INC_SEARCH_PATH})
find_path(X11_X11_xcb_INCLUDE_PATH X11/Xlib-xcb.h ${X11_INC_SEARCH_PATH})
find_path(X11_xcb_icccm_INCLUDE_PATH xcb/xcb_icccm.h ${X11_INC_SEARCH_PATH})
+ find_path(X11_xcb_randr_INCLUDE_PATH xcb/randr.h ${X11_INC_SEARCH_PATH})
find_path(X11_xcb_util_INCLUDE_PATH xcb/xcb_aux.h ${X11_INC_SEARCH_PATH})
find_path(X11_xcb_xfixes_INCLUDE_PATH xcb/xfixes.h ${X11_INC_SEARCH_PATH})
+ find_path(X11_xcb_xtest_INCLUDE_PATH xcb/xtest.h ${X11_INC_SEARCH_PATH})
+ find_path(X11_xcb_keysyms_INCLUDE_PATH xcb/xcb_keysyms.h ${X11_INC_SEARCH_PATH})
find_path(X11_Xcomposite_INCLUDE_PATH X11/extensions/Xcomposite.h ${X11_INC_SEARCH_PATH})
find_path(X11_Xcursor_INCLUDE_PATH X11/Xcursor/Xcursor.h ${X11_INC_SEARCH_PATH})
find_path(X11_Xdamage_INCLUDE_PATH X11/extensions/Xdamage.h ${X11_INC_SEARCH_PATH})
@@ -180,8 +189,11 @@
find_library(X11_xcb_LIB xcb ${X11_LIB_SEARCH_PATH})
find_library(X11_X11_xcb_LIB X11-xcb ${X11_LIB_SEARCH_PATH})
find_library(X11_xcb_icccm_LIB xcb-icccm ${X11_LIB_SEARCH_PATH})
+ find_library(X11_xcb_randr_LIB xcb-randr ${X11_LIB_SEARCH_PATH})
find_library(X11_xcb_util_LIB xcb-util ${X11_LIB_SEARCH_PATH})
find_library(X11_xcb_xfixes_LIB xcb-xfixes ${X11_LIB_SEARCH_PATH})
+ find_library(X11_xcb_xtest_LIB xcb-xtest ${X11_LIB_SEARCH_PATH})
+ find_library(X11_xcb_keysyms_LIB xcb-keysyms ${X11_LIB_SEARCH_PATH})
find_library(X11_xcb_xkb_LIB xcb-xkb ${X11_LIB_SEARCH_PATH})
find_library(X11_Xcomposite_LIB Xcomposite ${X11_LIB_SEARCH_PATH})
find_library(X11_Xcursor_LIB Xcursor ${X11_LIB_SEARCH_PATH})
@@ -281,6 +293,10 @@
set(X11_xcb_icccm_FOUND TRUE)
endif ()
+ if (X11_xcb_randr_LIB AND X11_xcb_randr_INCLUDE_PATH)
+ set(X11_xcb_randr_FOUND TRUE)
+ endif ()
+
if (X11_xcb_util_LIB AND X11_xcb_util_INCLUDE_PATH)
set(X11_xcb_util_FOUND TRUE)
endif ()
@@ -289,6 +305,14 @@
set(X11_xcb_xfixes_FOUND TRUE)
endif ()
+ if (X11_xcb_xtest_LIB)
+ set(X11_xcb_xtest_FOUND TRUE)
+ endif ()
+
+ if (X11_xcb_keysyms_LIB)
+ set(X11_xcb_keysyms_FOUND TRUE)
+ endif ()
+
if (X11_xcb_xkb_LIB)
set(X11_xcb_xkb_FOUND TRUE)
endif ()
@@ -600,6 +624,13 @@
INTERFACE_LINK_LIBRARIES "X11::xcb")
endif ()
+ if (X11_xcb_randr_FOUND AND NOT TARGET X11::xcb_randr)
+ add_library(X11::xcb_randr UNKNOWN IMPORTED)
+ set_target_properties(X11::xcb_randr PROPERTIES
+ IMPORTED_LOCATION "${X11_xcb_randr_LIB}"
+ INTERFACE_LINK_LIBRARIES "X11::xcb")
+ endif ()
+
if (X11_xcb_util_FOUND AND NOT TARGET X11::xcb_util)
add_library(X11::xcb_util UNKNOWN IMPORTED)
set_target_properties(X11::xcb_util PROPERTIES
@@ -614,6 +645,20 @@
INTERFACE_LINK_LIBRARIES "X11::xcb")
endif ()
+ if (X11_xcb_xtest_FOUND AND NOT TARGET X11::xcb_xtest)
+ add_library(X11::xcb_xtest UNKNOWN IMPORTED)
+ set_target_properties(X11::xcb_xtest PROPERTIES
+ IMPORTED_LOCATION "${X11_xcb_xtest_LIB}"
+ INTERFACE_LINK_LIBRARIES "X11::xcb")
+ endif ()
+
+ if (X11_xcb_keysyms_FOUND AND NOT TARGET X11::xcb_keysyms)
+ add_library(X11::xcb_keysyms UNKNOWN IMPORTED)
+ set_target_properties(X11::xcb_keysyms PROPERTIES
+ IMPORTED_LOCATION "${X11_xcb_keysyms_LIB}"
+ INTERFACE_LINK_LIBRARIES "X11::xcb")
+ endif ()
+
if (X11_xcb_xkb_FOUND AND NOT TARGET X11::xcb_xkb)
add_library(X11::xcb_xkb UNKNOWN IMPORTED)
set_target_properties(X11::xcb_xkb PROPERTIES
@@ -830,10 +875,16 @@
X11_xcb_INCLUDE_PATH
X11_xcb_icccm_LIB
X11_xcb_icccm_INCLUDE_PATH
+ X11_xcb_randr_LIB
+ X11_xcb_randr_INCLUDE_PATH
X11_xcb_util_LIB
X11_xcb_util_INCLUDE_PATH
X11_xcb_xfixes_LIB
X11_xcb_xfixes_INCLUDE_PATH
+ X11_xcb_xtest_LIB
+ X11_xcb_xtest_INCLUDE_PATH
+ X11_xcb_keysyms_LIB
+ X11_xcb_keysyms_INCLUDE_PATH
X11_xcb_xkb_LIB
X11_X11_xcb_LIB
X11_X11_xcb_INCLUDE_PATH
diff --git a/Modules/FindZLIB.cmake b/Modules/FindZLIB.cmake
index 5778b03..4af842a 100644
--- a/Modules/FindZLIB.cmake
+++ b/Modules/FindZLIB.cmake
@@ -53,6 +53,11 @@
A user may set ``ZLIB_ROOT`` to a zlib installation root to tell this
module where to look.
+
+.. versionadded:: 3.24
+ Set ``ZLIB_USE_STATIC_LIBS`` to ``ON`` to look for static libraries.
+ Default is ``OFF``.
+
#]=======================================================================]
set(_ZLIB_SEARCHES)
@@ -72,8 +77,8 @@
unset(_ZLIB_x86)
list(APPEND _ZLIB_SEARCHES _ZLIB_SEARCH_NORMAL)
-set(ZLIB_NAMES z zlib zdll zlib1 zlibstatic)
-set(ZLIB_NAMES_DEBUG zd zlibd zdlld zlibd1 zlib1d zlibstaticd)
+set(ZLIB_NAMES z zlib zdll zlib1 zlibstatic zlibstat zlibvc)
+set(ZLIB_NAMES_DEBUG zd zlibd zdlld zlibd1 zlib1d zlibstaticd zlibstatd zlibvcd)
# Try each search configuration.
foreach(search ${_ZLIB_SEARCHES})
@@ -82,11 +87,26 @@
# Allow ZLIB_LIBRARY to be set manually, as the location of the zlib library
if(NOT ZLIB_LIBRARY)
+ # Support preference of static libs by adjusting CMAKE_FIND_LIBRARY_SUFFIXES
+ if(ZLIB_USE_STATIC_LIBS)
+ set(_zlib_ORIG_CMAKE_FIND_LIBRARY_SUFFIXES ${CMAKE_FIND_LIBRARY_SUFFIXES})
+ if(WIN32)
+ set(CMAKE_FIND_LIBRARY_SUFFIXES .lib .a ${CMAKE_FIND_LIBRARY_SUFFIXES})
+ else()
+ set(CMAKE_FIND_LIBRARY_SUFFIXES .a)
+ endif()
+ endif()
+
foreach(search ${_ZLIB_SEARCHES})
find_library(ZLIB_LIBRARY_RELEASE NAMES ${ZLIB_NAMES} NAMES_PER_DIR ${${search}} PATH_SUFFIXES lib)
find_library(ZLIB_LIBRARY_DEBUG NAMES ${ZLIB_NAMES_DEBUG} NAMES_PER_DIR ${${search}} PATH_SUFFIXES lib)
endforeach()
+ # Restore the original find library ordering
+ if(ZLIB_USE_STATIC_LIBS)
+ set(CMAKE_FIND_LIBRARY_SUFFIXES ${_zlib_ORIG_CMAKE_FIND_LIBRARY_SUFFIXES})
+ endif()
+
include(${CMAKE_CURRENT_LIST_DIR}/SelectLibraryConfigurations.cmake)
select_library_configurations(ZLIB)
endif()
diff --git a/Modules/Internal/CPack/CPackRPM.cmake b/Modules/Internal/CPack/CPackRPM.cmake
index c72bf6d..cd631b8 100644
--- a/Modules/Internal/CPack/CPackRPM.cmake
+++ b/Modules/Internal/CPack/CPackRPM.cmake
@@ -790,7 +790,7 @@
set(FALLBACK_VAR_NAMES ${ARGN})
foreach(variable_name IN LISTS FALLBACK_VAR_NAMES)
- if(${variable_name})
+ if(DEFINED ${variable_name})
set(${OUTPUT_VAR_NAME} "${${variable_name}}" PARENT_SCOPE)
break()
endif()
diff --git a/Modules/Platform/CYGWIN-GNU.cmake b/Modules/Platform/CYGWIN-GNU.cmake
index b81bd4d..ef64012 100644
--- a/Modules/Platform/CYGWIN-GNU.cmake
+++ b/Modules/Platform/CYGWIN-GNU.cmake
@@ -14,6 +14,34 @@
set(CMAKE_GNULD_IMAGE_VERSION
"-Wl,--major-image-version,<TARGET_VERSION_MAJOR>,--minor-image-version,<TARGET_VERSION_MINOR>")
set(CMAKE_GENERATOR_RC windres)
+
+
+# Features for LINK_LIBRARY generator expression
+## check linker capabilities
+if(NOT DEFINED _CMAKE_LINKER_PUSHPOP_STATE_SUPPORTED)
+ execute_process(COMMAND "${CMAKE_LINKER}" --help
+ OUTPUT_VARIABLE __linker_help
+ ERROR_VARIABLE __linker_help)
+ if(__linker_help MATCHES "--push-state" AND __linker_help MATCHES "--pop-state")
+ set(_CMAKE_LINKER_PUSHPOP_STATE_SUPPORTED TRUE CACHE INTERNAL "linker supports push/pop state")
+ else()
+ set(_CMAKE_LINKER_PUSHPOP_STATE_SUPPORTED FALSE CACHE INTERNAL "linker supports push/pop state")
+ endif()
+ unset(__linker_help)
+endif()
+## WHOLE_ARCHIVE: Force loading all members of an archive
+if(_CMAKE_LINKER_PUSHPOP_STATE_SUPPORTED)
+ set(CMAKE_LINK_LIBRARY_USING_WHOLE_ARCHIVE "LINKER:--push-state,--whole-archive"
+ "<LINK_ITEM>"
+ "LINKER:--pop-state")
+else()
+ set(CMAKE_LINK_LIBRARY_USING_WHOLE_ARCHIVE "LINKER:--whole-archive"
+ "<LINK_ITEM>"
+ "LINKER:--no-whole-archive")
+endif()
+set(CMAKE_LINK_LIBRARY_USING_WHOLE_ARCHIVE_SUPPORTED TRUE)
+
+
macro(__cygwin_compiler_gnu lang)
# Binary link rules.
set(CMAKE_${lang}_CREATE_SHARED_MODULE
diff --git a/Modules/Platform/Darwin.cmake b/Modules/Platform/Darwin.cmake
index 839dc81..ec88a37 100644
--- a/Modules/Platform/Darwin.cmake
+++ b/Modules/Platform/Darwin.cmake
@@ -103,11 +103,38 @@
set(CMAKE_${lang}_CREATE_MACOSX_FRAMEWORK
"<CMAKE_${lang}_COMPILER> <LANGUAGE_COMPILE_FLAGS> <CMAKE_SHARED_LIBRARY_CREATE_${lang}_FLAGS> <LINK_FLAGS> -o <TARGET> <SONAME_FLAG> <TARGET_INSTALLNAME_DIR><TARGET_SONAME> <OBJECTS> <LINK_LIBRARIES>")
- # Set default framework search path flag for languages known to use a
- # preprocessor that may find headers in frameworks.
- set(CMAKE_${lang}_FRAMEWORK_SEARCH_FLAG -F)
+# Set default framework search path flag for languages known to use a
+# preprocessor that may find headers in frameworks.
+set(CMAKE_${lang}_FRAMEWORK_SEARCH_FLAG -F)
endforeach()
+# Defines LINK_LIBRARY features for frameworks
+set(CMAKE_LINK_LIBRARY_USING_FRAMEWORK "LINKER:-framework,<LIBRARY>")
+set(CMAKE_LINK_LIBRARY_USING_FRAMEWORK_SUPPORTED TRUE)
+
+set(CMAKE_LINK_LIBRARY_USING_NEEDED_FRAMEWORK "LINKER:-needed_framework,<LIBRARY>")
+set(CMAKE_LINK_LIBRARY_USING_NEEDED_FRAMEWORK_SUPPORTED TRUE)
+
+set(CMAKE_LINK_LIBRARY_USING_REEXPORT_FRAMEWORK "LINKER:-reexport_framework,<LIBRARY>")
+set(CMAKE_LINK_LIBRARY_USING_REEXPORT_FRAMEWORK_SUPPORTED TRUE)
+
+set(CMAKE_LINK_LIBRARY_USING_WEAK_FRAMEWORK "LINKER:-weak_framework,<LIBRARY>")
+set(CMAKE_LINK_LIBRARY_USING_WEAK_FRAMEWORK_SUPPORTED TRUE)
+
+# Defines LINK_LIBRARY features for libraries
+set(CMAKE_LINK_LIBRARY_USING_NEEDED_LIBRARY "PATH{LINKER:-needed_library <LIBRARY>}NAME{LINKER:-needed-l<LIB_ITEM>}")
+set(CMAKE_LINK_LIBRARY_USING_NEEDED_LIBRARY_SUPPORTED TRUE)
+
+set(CMAKE_LINK_LIBRARY_USING_REEXPORT_LIBRARY "PATH{LINKER:-reexport_library <LIBRARY>}NAME{LINKER:-reexport-l<LIB_ITEM>}")
+set(CMAKE_LINK_LIBRARY_USING_REEXPORT_LIBRARY_SUPPORTED TRUE)
+
+set(CMAKE_LINK_LIBRARY_USING_WEAK_LIBRARY "PATH{LINKER:-weak_library <LIBRARY>}NAME{LINKER:-weak-l<LIB_ITEM>}")
+set(CMAKE_LINK_LIBRARY_USING_WEAK_LIBRARY_SUPPORTED TRUE)
+
+# Defines LINK_LIBRARY feature to Force loading of all members of an archive
+set(CMAKE_LINK_LIBRARY_USING_WHOLE_ARCHIVE "LINKER:-force_load <LIB_ITEM>")
+set(CMAKE_LINK_LIBRARY_USING_WHOLE_ARCHIVE_SUPPORTED TRUE)
+
# default to searching for frameworks first
if(NOT DEFINED CMAKE_FIND_FRAMEWORK)
set(CMAKE_FIND_FRAMEWORK FIRST)
diff --git a/Modules/Platform/FreeBSD.cmake b/Modules/Platform/FreeBSD.cmake
index 4a4c00d..4c8cb6a 100644
--- a/Modules/Platform/FreeBSD.cmake
+++ b/Modules/Platform/FreeBSD.cmake
@@ -26,4 +26,31 @@
set(CMAKE_${type}_LINK_DYNAMIC_C_FLAGS "-Wl,-Bdynamic")
endforeach()
+
+# Features for LINK_LIBRARY generator expression
+## check linker capabilities
+if(NOT DEFINED _CMAKE_LINKER_PUSHPOP_STATE_SUPPORTED)
+ execute_process(COMMAND "${CMAKE_LINKER}" --help
+ OUTPUT_VARIABLE __linker_help
+ ERROR_VARIABLE __linker_help)
+ if(__linker_help MATCHES "--push-state" AND __linker_help MATCHES "--pop-state")
+ set(_CMAKE_LINKER_PUSHPOP_STATE_SUPPORTED TRUE CACHE INTERNAL "linker supports push/pop state")
+ else()
+ set(_CMAKE_LINKER_PUSHPOP_STATE_SUPPORTED FALSE CACHE INTERNAL "linker supports push/pop state")
+ endif()
+ unset(__linker_help)
+endif()
+## WHOLE_ARCHIVE: Force loading all members of an archive
+if(_CMAKE_LINKER_PUSHPOP_STATE_SUPPORTED)
+ set(CMAKE_LINK_LIBRARY_USING_WHOLE_ARCHIVE "LINKER:--push-state,--whole-archive"
+ "<LINK_ITEM>"
+ "LINKER:--pop-state")
+else()
+ set(CMAKE_LINK_LIBRARY_USING_WHOLE_ARCHIVE "LINKER:--whole-archive"
+ "<LINK_ITEM>"
+ "LINKER:--no-whole-archive")
+endif()
+set(CMAKE_LINK_LIBRARY_USING_WHOLE_ARCHIVE_SUPPORTED TRUE)
+
+
include(Platform/UnixPaths)
diff --git a/Modules/Platform/GHS-MULTI.cmake b/Modules/Platform/GHS-MULTI.cmake
index 60a15c4..5b28f29 100644
--- a/Modules/Platform/GHS-MULTI.cmake
+++ b/Modules/Platform/GHS-MULTI.cmake
@@ -13,5 +13,3 @@
set(CMAKE_FIND_LIBRARY_PREFIXES "")
set(CMAKE_FIND_LIBRARY_SUFFIXES ".a")
-
-include(Platform/WindowsPaths)
diff --git a/Modules/Platform/Linux.cmake b/Modules/Platform/Linux.cmake
index b5d5464..a7e58ab 100644
--- a/Modules/Platform/Linux.cmake
+++ b/Modules/Platform/Linux.cmake
@@ -19,6 +19,39 @@
set(CMAKE_${type}_LINK_DYNAMIC_C_FLAGS "-Wl,-Bdynamic")
endforeach()
+
+# Features for LINK_LIBRARY generator expression
+## check linker capabilities
+if(NOT DEFINED _CMAKE_LINKER_PUSHPOP_STATE_SUPPORTED)
+ execute_process(COMMAND "${CMAKE_LINKER}" --help
+ OUTPUT_VARIABLE __linker_help
+ ERROR_VARIABLE __linker_help)
+ if(__linker_help MATCHES "--push-state" AND __linker_help MATCHES "--pop-state")
+ set(_CMAKE_LINKER_PUSHPOP_STATE_SUPPORTED TRUE CACHE INTERNAL "linker supports push/pop state")
+ else()
+ set(_CMAKE_LINKER_PUSHPOP_STATE_SUPPORTED FALSE CACHE INTERNAL "linker supports push/pop state")
+ endif()
+ unset(__linker_help)
+endif()
+## WHOLE_ARCHIVE: Force loading all members of an archive
+if(_CMAKE_LINKER_PUSHPOP_STATE_SUPPORTED)
+ set(CMAKE_LINK_LIBRARY_USING_WHOLE_ARCHIVE "LINKER:--push-state,--whole-archive"
+ "<LINK_ITEM>"
+ "LINKER:--pop-state")
+else()
+ set(CMAKE_LINK_LIBRARY_USING_WHOLE_ARCHIVE "LINKER:--whole-archive"
+ "<LINK_ITEM>"
+ "LINKER:--no-whole-archive")
+endif()
+set(CMAKE_LINK_LIBRARY_USING_WHOLE_ARCHIVE_SUPPORTED TRUE)
+
+# Features for LINK_GROUP generator expression
+## RESCAN: request the linker to rescan static libraries until there is
+## no pending undefined symbols
+set(CMAKE_LINK_GROUP_USING_RESCAN "LINKER:--start-group" "LINKER:--end-group")
+set(CMAKE_LINK_GROUP_USING_RESCAN_SUPPORTED TRUE)
+
+
# Debian policy requires that shared libraries be installed without
# executable permission. Fedora policy requires that shared libraries
# be installed with the executable permission. Since the native tools
diff --git a/Modules/Platform/NetBSD.cmake b/Modules/Platform/NetBSD.cmake
index d99cb4a..8774159 100644
--- a/Modules/Platform/NetBSD.cmake
+++ b/Modules/Platform/NetBSD.cmake
@@ -12,4 +12,31 @@
set(CMAKE_SHARED_LIBRARY_SONAME_C_FLAG "-Wl,-soname,")
set(CMAKE_EXE_EXPORTS_C_FLAG "-Wl,--export-dynamic")
+
+# Features for LINK_LIBRARY generator expression
+## check linker capabilities
+if(NOT DEFINED _CMAKE_LINKER_PUSHPOP_STATE_SUPPORTED)
+ execute_process(COMMAND "${CMAKE_LINKER}" --help
+ OUTPUT_VARIABLE __linker_help
+ ERROR_VARIABLE __linker_help)
+ if(__linker_help MATCHES "--push-state" AND __linker_help MATCHES "--pop-state")
+ set(_CMAKE_LINKER_PUSHPOP_STATE_SUPPORTED TRUE CACHE INTERNAL "linker supports push/pop state")
+ else()
+ set(_CMAKE_LINKER_PUSHPOP_STATE_SUPPORTED FALSE CACHE INTERNAL "linker supports push/pop state")
+ endif()
+ unset(__linker_help)
+endif()
+## WHOLE_ARCHIVE: Force loading all members of an archive
+if(_CMAKE_LINKER_PUSHPOP_STATE_SUPPORTED)
+ set(CMAKE_LINK_LIBRARY_USING_WHOLE_ARCHIVE "LINKER:--push-state,--whole-archive"
+ "<LINK_ITEM>"
+ "LINKER:--pop-state")
+else()
+ set(CMAKE_LINK_LIBRARY_USING_WHOLE_ARCHIVE "LINKER:--whole-archive"
+ "<LINK_ITEM>"
+ "LINKER:--no-whole-archive")
+endif()
+set(CMAKE_LINK_LIBRARY_USING_WHOLE_ARCHIVE_SUPPORTED TRUE)
+
+
include(Platform/UnixPaths)
diff --git a/Modules/Platform/SunOS.cmake b/Modules/Platform/SunOS.cmake
index 78eccf7..b8a302c 100644
--- a/Modules/Platform/SunOS.cmake
+++ b/Modules/Platform/SunOS.cmake
@@ -7,6 +7,30 @@
set(CMAKE_SHARED_LIBRARY_RUNTIME_C_FLAG_SEP ":")
endif()
+
+# Features for LINK_LIBRARY generator expression
+## WHOLE_ARCHIVE: Force loading all members of an archive
+if (CMAKE_SYSTEM_VERSION VERSION_GREATER "5.10")
+ set(CMAKE_LINK_LIBRARY_USING_WHOLE_ARCHIVE "LINKER:--whole-archive"
+ "<LINK_ITEM>"
+ "LINKER:--no-whole-archive")
+else()
+ set(CMAKE_LINK_LIBRARY_USING_WHOLE_ARCHIVE "LINKER:-z,allextract"
+ "<LINK_ITEM>"
+ "LINKER:-z,defaultextract")
+endif()
+set(CMAKE_LINK_LIBRARY_USING_WHOLE_ARCHIVE_SUPPORTED TRUE)
+
+
+# Features for LINK_GROUP generator expression
+if (CMAKE_SYSTEM_VERSION VERSION_GREATER "5.9")
+ ## RESCAN: request the linker to rescan static libraries until there is
+ ## no pending undefined symbols
+ set(CMAKE_LINK_GROUP_USING_RESCAN "LINKER:-z,rescan-start" "LINKER:-z,rescan-end")
+ set(CMAKE_LINK_GROUP_USING_RESCAN_SUPPORTED TRUE)
+endif()
+
+
include(Platform/UnixPaths)
list(APPEND CMAKE_SYSTEM_PREFIX_PATH
diff --git a/Modules/Platform/Windows-Clang.cmake b/Modules/Platform/Windows-Clang.cmake
index e7e975d..7600c8d 100644
--- a/Modules/Platform/Windows-Clang.cmake
+++ b/Modules/Platform/Windows-Clang.cmake
@@ -113,6 +113,13 @@
string(TOLOWER "${CMAKE_BUILD_TYPE}" BUILD_TYPE_LOWER)
set(CMAKE_${lang}_STANDARD_LIBRARIES_INIT "-lkernel32 -luser32 -lgdi32 -lwinspool -lshell32 -lole32 -loleaut32 -luuid -lcomdlg32 -ladvapi32 -loldnames")
+ # Features for LINK_LIBRARY generator expression
+ if(MSVC_VERSION GREATER "1900")
+ ## WHOLE_ARCHIVE: Force loading all members of an archive
+ set(CMAKE_${lang}_LINK_LIBRARY_USING_WHOLE_ARCHIVE "LINKER:/WHOLEARCHIVE:<LIBRARY>")
+ set(CMAKE_${lang}_LINK_LIBRARY_USING_WHOLE_ARCHIVE_SUPPORTED TRUE)
+ endif()
+
enable_language(RC)
endmacro()
diff --git a/Modules/Platform/Windows-GNU.cmake b/Modules/Platform/Windows-GNU.cmake
index 51dc146..b464169 100644
--- a/Modules/Platform/Windows-GNU.cmake
+++ b/Modules/Platform/Windows-GNU.cmake
@@ -44,6 +44,39 @@
set(__WINDOWS_GNU_LD_RESPONSE 0)
endif()
+
+# Features for LINK_LIBRARY generator expression
+## check linker capabilities
+if(NOT DEFINED _CMAKE_LINKER_PUSHPOP_STATE_SUPPORTED)
+ execute_process(COMMAND "${CMAKE_LINKER}" --help
+ OUTPUT_VARIABLE __linker_help
+ ERROR_VARIABLE __linker_help)
+ if(__linker_help MATCHES "--push-state" AND __linker_help MATCHES "--pop-state")
+ set(_CMAKE_LINKER_PUSHPOP_STATE_SUPPORTED TRUE CACHE INTERNAL "linker supports push/pop state")
+ else()
+ set(_CMAKE_LINKER_PUSHPOP_STATE_SUPPORTED FALSE CACHE INTERNAL "linker supports push/pop state")
+ endif()
+ unset(__linker_help)
+endif()
+## WHOLE_ARCHIVE: Force loading all members of an archive
+if(_CMAKE_LINKER_PUSHPOP_STATE_SUPPORTED)
+ set(CMAKE_LINK_LIBRARY_USING_WHOLE_ARCHIVE "LINKER:--push-state,--whole-archive"
+ "<LINK_ITEM>"
+ "LINKER:--pop-state")
+else()
+ set(CMAKE_LINK_LIBRARY_USING_WHOLE_ARCHIVE "LINKER:--whole-archive"
+ "<LINK_ITEM>"
+ "LINKER:--no-whole-archive")
+endif()
+set(CMAKE_LINK_LIBRARY_USING_WHOLE_ARCHIVE_SUPPORTED TRUE)
+
+# Features for LINK_GROUP generator expression
+## RESCAN: request the linker to rescan static libraries until there is
+## no pending undefined symbols
+set(CMAKE_LINK_GROUP_USING_RESCAN "LINKER:--start-group" "LINKER:--end-group")
+set(CMAKE_LINK_GROUP_USING_RESCAN_SUPPORTED TRUE)
+
+
macro(__windows_compiler_gnu lang)
# Create archiving rules to support large object file lists for static libraries.
diff --git a/Modules/Platform/Windows-MSVC.cmake b/Modules/Platform/Windows-MSVC.cmake
index b2cc6f4..e74ec9e 100644
--- a/Modules/Platform/Windows-MSVC.cmake
+++ b/Modules/Platform/Windows-MSVC.cmake
@@ -331,6 +331,15 @@
endif()
unset(__WINDOWS_MSVC_CMP0091)
+
+# Features for LINK_LIBRARY generator expression
+if(MSVC_VERSION GREATER "1900")
+ ## WHOLE_ARCHIVE: Force loading all members of an archive
+ set(CMAKE_LINK_LIBRARY_USING_WHOLE_ARCHIVE "/WHOLEARCHIVE:<LIBRARY>")
+ set(CMAKE_LINK_LIBRARY_USING_WHOLE_ARCHIVE_SUPPORTED TRUE)
+endif()
+
+
macro(__windows_compiler_msvc lang)
if(NOT MSVC_VERSION LESS 1400)
# for 2005 make sure the manifest is put in the dll with mt
diff --git a/Source/CMakeLists.txt b/Source/CMakeLists.txt
index ddcdd7e..d6e0096 100644
--- a/Source/CMakeLists.txt
+++ b/Source/CMakeLists.txt
@@ -358,6 +358,8 @@
cmLocalCommonGenerator.h
cmLocalGenerator.cxx
cmLocalGenerator.h
+ cmPlaceholderExpander.cxx
+ cmPlaceholderExpander.h
cmRulePlaceholderExpander.cxx
cmRulePlaceholderExpander.h
cmLocalUnixMakefileGenerator3.cxx
diff --git a/Source/CMakeVersion.cmake b/Source/CMakeVersion.cmake
index 7801e24..fc6fc5f 100644
--- a/Source/CMakeVersion.cmake
+++ b/Source/CMakeVersion.cmake
@@ -1,8 +1,8 @@
# CMake version number components.
set(CMake_VERSION_MAJOR 3)
set(CMake_VERSION_MINOR 23)
-set(CMake_VERSION_PATCH 0)
-set(CMake_VERSION_RC 4)
+set(CMake_VERSION_PATCH 20220322)
+#set(CMake_VERSION_RC 0)
set(CMake_VERSION_IS_DIRTY 0)
# Start with the full version number used in tags. It has no dev info.
diff --git a/Source/CTest/cmCTestMemCheckHandler.cxx b/Source/CTest/cmCTestMemCheckHandler.cxx
index 6bb8e79..2d8276a 100644
--- a/Source/CTest/cmCTestMemCheckHandler.cxx
+++ b/Source/CTest/cmCTestMemCheckHandler.cxx
@@ -371,7 +371,8 @@
}
this->CleanTestOutput(
memcheckstr,
- static_cast<size_t>(this->CustomMaximumFailedTestOutputSize));
+ static_cast<size_t>(this->CustomMaximumFailedTestOutputSize),
+ this->TestOutputTruncation);
this->WriteTestResultHeader(xml, result);
xml.StartElement("Results");
int memoryErrors = 0;
diff --git a/Source/CTest/cmCTestRunTest.cxx b/Source/CTest/cmCTestRunTest.cxx
index 6cd3b09..2a2cb1c 100644
--- a/Source/CTest/cmCTestRunTest.cxx
+++ b/Source/CTest/cmCTestRunTest.cxx
@@ -277,7 +277,8 @@
static_cast<size_t>(
this->TestResult.Status == cmCTestTestHandler::COMPLETED
? this->TestHandler->CustomMaximumPassedTestOutputSize
- : this->TestHandler->CustomMaximumFailedTestOutputSize));
+ : this->TestHandler->CustomMaximumFailedTestOutputSize),
+ this->TestHandler->TestOutputTruncation);
}
this->TestResult.Reason = reason;
if (this->TestHandler->LogFile) {
@@ -694,6 +695,14 @@
<< " command: " << testCommand << std::endl);
// Print any test-specific env vars in verbose mode
+ if (!this->TestProperties->Directory.empty()) {
+ cmCTestLog(this->CTest, HANDLER_VERBOSE_OUTPUT,
+ this->Index << ": "
+ << "Working Directory: "
+ << this->TestProperties->Directory << std::endl);
+ }
+
+ // Print any test-specific env vars in verbose mode
if (!this->TestProperties->Environment.empty()) {
cmCTestLog(this->CTest, HANDLER_VERBOSE_OUTPUT,
this->Index << ": "
diff --git a/Source/CTest/cmCTestTestHandler.cxx b/Source/CTest/cmCTestTestHandler.cxx
index 5a3a8d0..a794e3d 100644
--- a/Source/CTest/cmCTestTestHandler.cxx
+++ b/Source/CTest/cmCTestTestHandler.cxx
@@ -281,6 +281,7 @@
this->CustomMaximumPassedTestOutputSize = 1 * 1024;
this->CustomMaximumFailedTestOutputSize = 300 * 1024;
+ this->TestOutputTruncation = cmCTestTypes::TruncationMode::Tail;
this->MemCheck = false;
@@ -325,6 +326,7 @@
this->CustomPostTest.clear();
this->CustomMaximumPassedTestOutputSize = 1 * 1024;
this->CustomMaximumFailedTestOutputSize = 300 * 1024;
+ this->TestOutputTruncation = cmCTestTypes::TruncationMode::Tail;
this->TestsToRun.clear();
@@ -358,6 +360,11 @@
this->CTest->PopulateCustomInteger(
mf, "CTEST_CUSTOM_MAXIMUM_FAILED_TEST_OUTPUT_SIZE",
this->CustomMaximumFailedTestOutputSize);
+
+ cmValue dval = mf->GetDefinition("CTEST_CUSTOM_TEST_OUTPUT_TRUNCATION");
+ if (dval) {
+ this->SetTestOutputTruncation(dval);
+ }
}
int cmCTestTestHandler::PreProcessHandler()
@@ -2076,6 +2083,20 @@
this->ExcludeRegExp = arg;
}
+bool cmCTestTestHandler::SetTestOutputTruncation(const std::string& mode)
+{
+ if (mode == "tail") {
+ this->TestOutputTruncation = cmCTestTypes::TruncationMode::Tail;
+ } else if (mode == "middle") {
+ this->TestOutputTruncation = cmCTestTypes::TruncationMode::Middle;
+ } else if (mode == "head") {
+ this->TestOutputTruncation = cmCTestTypes::TruncationMode::Head;
+ } else {
+ return false;
+ }
+ return true;
+}
+
void cmCTestTestHandler::SetTestsToRunInformation(cmValue in)
{
if (!in) {
@@ -2094,41 +2115,58 @@
}
}
-void cmCTestTestHandler::CleanTestOutput(std::string& output, size_t length)
+void cmCTestTestHandler::CleanTestOutput(std::string& output, size_t length,
+ cmCTestTypes::TruncationMode truncate)
{
if (!length || length >= output.size() ||
output.find("CTEST_FULL_OUTPUT") != std::string::npos) {
return;
}
- // Truncate at given length but do not break in the middle of a multi-byte
- // UTF-8 encoding.
+ // Advance n bytes in string delimited by begin/end but do not break in the
+ // middle of a multi-byte UTF-8 encoding.
+ auto utf8_advance = [](char const* const begin, char const* const end,
+ size_t n) -> const char* {
+ char const* const stop = begin + n;
+ char const* current = begin;
+ while (current < stop) {
+ unsigned int ch;
+ if (const char* next = cm_utf8_decode_character(current, end, &ch)) {
+ if (next > stop) {
+ break;
+ }
+ current = next;
+ } else // Bad byte will be handled by cmXMLWriter.
+ {
+ ++current;
+ }
+ }
+ return current;
+ };
+
+ // Truncation message.
+ const std::string msg =
+ "\n[This part of the test output was removed since it "
+ "exceeds the threshold of " +
+ std::to_string(length) + " bytes.]\n";
+
char const* const begin = output.c_str();
char const* const end = begin + output.size();
- char const* const truncate = begin + length;
- char const* current = begin;
- while (current < truncate) {
- unsigned int ch;
- if (const char* next = cm_utf8_decode_character(current, end, &ch)) {
- if (next > truncate) {
- break;
- }
- current = next;
- } else // Bad byte will be handled by cmXMLWriter.
- {
- ++current;
- }
- }
- output.erase(current - begin);
- // Append truncation message.
- std::ostringstream msg;
- msg << "...\n"
- "The rest of the test output was removed since it exceeds the "
- "threshold "
- "of "
- << length << " bytes.\n";
- output += msg.str();
+ // Erase head, middle or tail of output.
+ if (truncate == cmCTestTypes::TruncationMode::Head) {
+ char const* current = utf8_advance(begin, end, output.size() - length);
+ output.erase(0, current - begin);
+ output.insert(0, msg + "...");
+ } else if (truncate == cmCTestTypes::TruncationMode::Middle) {
+ char const* current = utf8_advance(begin, end, length / 2);
+ output.erase(current - begin, output.size() - length);
+ output.insert(current - begin, "..." + msg + "...");
+ } else { // default or "tail"
+ char const* current = utf8_advance(begin, end, length);
+ output.erase(current - begin);
+ output += ("..." + msg);
+ }
}
bool cmCTestTestHandler::SetTestsProperties(
diff --git a/Source/CTest/cmCTestTestHandler.h b/Source/CTest/cmCTestTestHandler.h
index 135e764..d0049da 100644
--- a/Source/CTest/cmCTestTestHandler.h
+++ b/Source/CTest/cmCTestTestHandler.h
@@ -19,6 +19,7 @@
#include "cmCTest.h"
#include "cmCTestGenericHandler.h"
#include "cmCTestResourceSpec.h"
+#include "cmCTestTypes.h"
#include "cmDuration.h"
#include "cmListFileCache.h"
#include "cmValue.h"
@@ -32,6 +33,7 @@
*/
class cmCTestTestHandler : public cmCTestGenericHandler
{
+ friend class cmCTest;
friend class cmCTestRunTest;
friend class cmCTestMultiProcessHandler;
@@ -80,6 +82,9 @@
this->CustomMaximumFailedTestOutputSize = n;
}
+ //! Set test output truncation mode. Return false if unknown mode.
+ bool SetTestOutputTruncation(const std::string& mode);
+
//! pass the -I argument down
void SetTestsToRunInformation(cmValue);
@@ -242,8 +247,9 @@
void AttachFile(cmXMLWriter& xml, std::string const& file,
std::string const& name);
- //! Clean test output to specified length
- void CleanTestOutput(std::string& output, size_t length);
+ //! Clean test output to specified length and truncation mode
+ void CleanTestOutput(std::string& output, size_t length,
+ cmCTestTypes::TruncationMode truncate);
cmDuration ElapsedTestingTime;
@@ -258,6 +264,7 @@
bool MemCheck;
int CustomMaximumPassedTestOutputSize;
int CustomMaximumFailedTestOutputSize;
+ cmCTestTypes::TruncationMode TestOutputTruncation;
int MaxIndex;
public:
diff --git a/Source/CTest/cmCTestTypes.h b/Source/CTest/cmCTestTypes.h
new file mode 100644
index 0000000..843d27a
--- /dev/null
+++ b/Source/CTest/cmCTestTypes.h
@@ -0,0 +1,16 @@
+/* Distributed under the OSI-approved BSD 3-Clause License. See accompanying
+ file Copyright.txt or https://cmake.org/licensing for details. */
+
+#pragma once
+
+#include "cmConfigure.h" // IWYU pragma: keep
+
+namespace cmCTestTypes {
+
+enum class TruncationMode
+{ // Test output truncation mode
+ Tail,
+ Middle,
+ Head
+};
+}
diff --git a/Source/CursesDialog/form/frm_driver.c b/Source/CursesDialog/form/frm_driver.c
index 112ab08..9cbb12f 100644
--- a/Source/CursesDialog/form/frm_driver.c
+++ b/Source/CursesDialog/form/frm_driver.c
@@ -1456,7 +1456,7 @@
|
| Description : Place the cursor after the last non-pad character in
| the field. If the field occupies the last position in
-| the buffer, the cursos is positioned on the last
+| the buffer, the cursor is positioned on the last
| character.
|
| Return Values : E_OK - success
diff --git a/Source/cmAddExecutableCommand.cxx b/Source/cmAddExecutableCommand.cxx
index 9dd8a19..16a8965 100644
--- a/Source/cmAddExecutableCommand.cxx
+++ b/Source/cmAddExecutableCommand.cxx
@@ -54,6 +54,10 @@
}
}
+ if (importTarget && !importGlobal) {
+ importGlobal = mf.IsImportedTargetGlobalScope();
+ }
+
bool nameOk = cmGeneratorExpression::IsValidTargetName(exename) &&
!cmGlobalGenerator::IsReservedTarget(exename);
diff --git a/Source/cmAddLibraryCommand.cxx b/Source/cmAddLibraryCommand.cxx
index a5d1f6a..29fc09b 100644
--- a/Source/cmAddLibraryCommand.cxx
+++ b/Source/cmAddLibraryCommand.cxx
@@ -131,6 +131,10 @@
}
}
+ if (importTarget && !importGlobal) {
+ importGlobal = mf.IsImportedTargetGlobalScope();
+ }
+
if (type == cmStateEnums::INTERFACE_LIBRARY) {
if (importGlobal && !importTarget) {
status.SetError(
diff --git a/Source/cmArchiveWrite.cxx b/Source/cmArchiveWrite.cxx
index 9e0d80c..cfde37c 100644
--- a/Source/cmArchiveWrite.cxx
+++ b/Source/cmArchiveWrite.cxx
@@ -95,6 +95,19 @@
, Verbose(false)
, Format(format)
{
+ // Upstream fixed an issue with their integer parsing in 3.4.0
+ // which would cause spurious errors to be raised from `strtoull`.
+
+ if (numThreads < 1) {
+ int upperLimit = (numThreads == 0) ? std::numeric_limits<int>::max()
+ : std::abs(numThreads);
+
+ numThreads =
+ cm::clamp<int>(std::thread::hardware_concurrency(), 1, upperLimit);
+ }
+
+ std::string sNumThreads = std::to_string(numThreads);
+
switch (c) {
case CompressNone:
if (archive_write_add_filter_none(this->Archive) != ARCHIVE_OK) {
@@ -150,36 +163,23 @@
return;
}
- {
#if ARCHIVE_VERSION_NUMBER >= 3004000
- // Upstream fixed an issue with their integer parsing in 3.4.0
- // which would cause spurious errors to be raised from `strtoull`.
-
- if (numThreads < 1) {
- int upperLimit = (numThreads == 0) ? std::numeric_limits<int>::max()
- : std::abs(numThreads);
-
- numThreads =
- cm::clamp<int>(std::thread::hardware_concurrency(), 1, upperLimit);
- }
# ifdef _AIX
- // FIXME: Using more than 2 threads creates an empty archive.
- // Enforce this limit pending further investigation.
- numThreads = std::min(numThreads, 2);
-# endif
-
- std::string sNumThreads = std::to_string(numThreads);
-
- if (archive_write_set_filter_option(this->Archive, "xz", "threads",
- sNumThreads.c_str()) !=
- ARCHIVE_OK) {
- this->Error = cmStrCat("archive_compressor_xz_options: ",
- cm_archive_error_string(this->Archive));
- return;
- }
-#endif
+ // FIXME: Using more than 2 threads creates an empty archive.
+ // Enforce this limit pending further investigation.
+ if (numThreads > 2) {
+ numThreads = 2;
+ sNumThreads = std::to_string(numThreads);
}
+# endif
+ if (archive_write_set_filter_option(this->Archive, "xz", "threads",
+ sNumThreads.c_str()) != ARCHIVE_OK) {
+ this->Error = cmStrCat("archive_compressor_xz_options: ",
+ cm_archive_error_string(this->Archive));
+ return;
+ }
+#endif
break;
case CompressZstd:
@@ -188,6 +188,15 @@
cm_archive_error_string(this->Archive));
return;
}
+
+#if ARCHIVE_VERSION_NUMBER >= 3006000
+ if (archive_write_set_filter_option(this->Archive, "zstd", "threads",
+ sNumThreads.c_str()) != ARCHIVE_OK) {
+ this->Error = cmStrCat("archive_compressor_zstd_options: ",
+ cm_archive_error_string(this->Archive));
+ return;
+ }
+#endif
break;
}
diff --git a/Source/cmCMakeLanguageCommand.cxx b/Source/cmCMakeLanguageCommand.cxx
index 789c78d..27d8cb8 100644
--- a/Source/cmCMakeLanguageCommand.cxx
+++ b/Source/cmCMakeLanguageCommand.cxx
@@ -84,7 +84,8 @@
for (size_t i = startArg; i < args.size(); ++i) {
funcArgs.emplace_back(args[i].Value, args[i].Delim, context.Line);
}
- cmListFileFunction func{ callCommand, context.Line, std::move(funcArgs) };
+ cmListFileFunction func{ callCommand, context.Line, context.Line,
+ std::move(funcArgs) };
if (defer) {
if (defer->Id.empty()) {
diff --git a/Source/cmCMakePresetsGraph.cxx b/Source/cmCMakePresetsGraph.cxx
index dc14831..478c175 100644
--- a/Source/cmCMakePresetsGraph.cxx
+++ b/Source/cmCMakePresetsGraph.cxx
@@ -781,6 +781,8 @@
parentOutput.MaxPassedTestOutputSize);
InheritOptionalValue(output.MaxFailedTestOutputSize,
parentOutput.MaxFailedTestOutputSize);
+ InheritOptionalValue(output.TestOutputTruncation,
+ parentOutput.TestOutputTruncation);
InheritOptionalValue(output.MaxTestNameWidth,
parentOutput.MaxTestNameWidth);
} else {
@@ -1035,6 +1037,9 @@
"support.";
case ReadFileResult::CYCLIC_INCLUDE:
return "Cyclic include among preset files";
+ case ReadFileResult::TEST_OUTPUT_TRUNCATION_UNSUPPORTED:
+ return "File version must be 5 or higher for testOutputTruncation "
+ "preset support.";
}
return "Unknown error";
diff --git a/Source/cmCMakePresetsGraph.h b/Source/cmCMakePresetsGraph.h
index 9d6c61a..f1f8662 100644
--- a/Source/cmCMakePresetsGraph.h
+++ b/Source/cmCMakePresetsGraph.h
@@ -14,6 +14,8 @@
#include <cm/optional>
+#include "CTest/cmCTestTypes.h"
+
enum class PackageResolveMode;
class cmCMakePresetsGraph
@@ -47,6 +49,7 @@
CONDITION_UNSUPPORTED,
TOOLCHAIN_FILE_UNSUPPORTED,
CYCLIC_INCLUDE,
+ TEST_OUTPUT_TRUNCATION_UNSUPPORTED,
};
enum class ArchToolsetStrategy
@@ -226,6 +229,7 @@
cm::optional<bool> SubprojectSummary;
cm::optional<int> MaxPassedTestOutputSize;
cm::optional<int> MaxFailedTestOutputSize;
+ cm::optional<cmCTestTypes::TruncationMode> TestOutputTruncation;
cm::optional<int> MaxTestNameWidth;
};
diff --git a/Source/cmCMakePresetsGraphReadJSON.cxx b/Source/cmCMakePresetsGraphReadJSON.cxx
index 85cf5be..e68f0fa 100644
--- a/Source/cmCMakePresetsGraphReadJSON.cxx
+++ b/Source/cmCMakePresetsGraphReadJSON.cxx
@@ -33,7 +33,7 @@
using ArchToolsetStrategy = cmCMakePresetsGraph::ArchToolsetStrategy;
constexpr int MIN_VERSION = 1;
-constexpr int MAX_VERSION = 4;
+constexpr int MAX_VERSION = 5;
struct CMakeVersion
{
@@ -568,6 +568,11 @@
return ReadFileResult::CONDITION_UNSUPPORTED;
}
+ // Support for TestOutputTruncation added in version 5.
+ if (v < 5 && preset.Output) {
+ return ReadFileResult::TEST_OUTPUT_TRUNCATION_UNSUPPORTED;
+ }
+
this->TestPresetOrder.push_back(preset.Name);
}
diff --git a/Source/cmCMakePresetsGraphReadJSONTestPresets.cxx b/Source/cmCMakePresetsGraphReadJSONTestPresets.cxx
index 4d6474a..43eccfe 100644
--- a/Source/cmCMakePresetsGraphReadJSONTestPresets.cxx
+++ b/Source/cmCMakePresetsGraphReadJSONTestPresets.cxx
@@ -16,6 +16,8 @@
#include "cmCMakePresetsGraphInternal.h"
#include "cmJSONHelpers.h"
+#include "CTest/cmCTestTypes.h"
+
namespace {
using ReadFileResult = cmCMakePresetsGraph::ReadFileResult;
using TestPreset = cmCMakePresetsGraph::TestPreset;
@@ -55,6 +57,40 @@
ReadFileResult>(ReadFileResult::READ_OK,
TestPresetOutputVerbosityHelper);
+ReadFileResult TestPresetOutputTruncationHelper(
+ cmCTestTypes::TruncationMode& out, const Json::Value* value)
+{
+ if (!value) {
+ out = cmCTestTypes::TruncationMode::Tail;
+ return ReadFileResult::READ_OK;
+ }
+
+ if (!value->isString()) {
+ return ReadFileResult::INVALID_PRESET;
+ }
+
+ if (value->asString() == "tail") {
+ out = cmCTestTypes::TruncationMode::Tail;
+ return ReadFileResult::READ_OK;
+ }
+
+ if (value->asString() == "middle") {
+ out = cmCTestTypes::TruncationMode::Middle;
+ return ReadFileResult::READ_OK;
+ }
+
+ if (value->asString() == "head") {
+ out = cmCTestTypes::TruncationMode::Head;
+ return ReadFileResult::READ_OK;
+ }
+
+ return ReadFileResult::INVALID_PRESET;
+}
+
+auto const TestPresetOptionalTruncationHelper =
+ cmJSONOptionalHelper<cmCTestTypes::TruncationMode, ReadFileResult>(
+ ReadFileResult::READ_OK, TestPresetOutputTruncationHelper);
+
auto const TestPresetOptionalOutputHelper =
cmJSONOptionalHelper<TestPreset::OutputOptions, ReadFileResult>(
ReadFileResult::READ_OK,
@@ -83,6 +119,9 @@
.Bind("maxFailedTestOutputSize"_s,
&TestPreset::OutputOptions::MaxFailedTestOutputSize,
cmCMakePresetsGraphInternal::PresetOptionalIntHelper, false)
+ .Bind("testOutputTruncation"_s,
+ &TestPreset::OutputOptions::TestOutputTruncation,
+ TestPresetOptionalTruncationHelper, false)
.Bind("maxTestNameWidth"_s, &TestPreset::OutputOptions::MaxTestNameWidth,
cmCMakePresetsGraphInternal::PresetOptionalIntHelper, false));
diff --git a/Source/cmCPluginAPI.cxx b/Source/cmCPluginAPI.cxx
index 1b11f20..abec968 100644
--- a/Source/cmCPluginAPI.cxx
+++ b/Source/cmCPluginAPI.cxx
@@ -432,7 +432,7 @@
lffArgs.emplace_back(args[i], cmListFileArgument::Quoted, 0);
}
- cmListFileFunction lff{ name, 0, std::move(lffArgs) };
+ cmListFileFunction lff{ name, 0, 0, std::move(lffArgs) };
cmExecutionStatus status(*mf);
return mf->ExecuteCommand(lff, status);
}
diff --git a/Source/cmCTest.cxx b/Source/cmCTest.cxx
index a1e920e..710b4d7 100644
--- a/Source/cmCTest.cxx
+++ b/Source/cmCTest.cxx
@@ -2036,6 +2036,13 @@
"Invalid value for '--test-output-size-failed': " << args[i]
<< "\n");
}
+ } else if (this->CheckArgument(arg, "--test-output-truncation"_s) &&
+ i < args.size() - 1) {
+ i++;
+ if (!this->Impl->TestHandler.SetTestOutputTruncation(args[i])) {
+ errormsg = "Invalid value for '--test-output-truncation': " + args[i];
+ return false;
+ }
} else if (this->CheckArgument(arg, "-N"_s, "--show-only")) {
this->Impl->ShowOnly = true;
} else if (cmHasLiteralPrefix(arg, "--show-only=")) {
@@ -2464,6 +2471,11 @@
*expandedPreset->Output->MaxFailedTestOutputSize);
}
+ if (expandedPreset->Output->TestOutputTruncation) {
+ this->Impl->TestHandler.TestOutputTruncation =
+ *expandedPreset->Output->TestOutputTruncation;
+ }
+
if (expandedPreset->Output->MaxTestNameWidth) {
this->Impl->MaxTestNameWidth = *expandedPreset->Output->MaxTestNameWidth;
}
diff --git a/Source/cmComputeLinkDepends.cxx b/Source/cmComputeLinkDepends.cxx
index 370ddff..a4dc01b 100644
--- a/Source/cmComputeLinkDepends.cxx
+++ b/Source/cmComputeLinkDepends.cxx
@@ -11,13 +11,18 @@
#include <utility>
#include <cm/memory>
+#include <cm/string_view>
+#include <cmext/string_view>
#include "cmComputeComponentGraph.h"
+#include "cmGeneratorExpression.h"
+#include "cmGeneratorExpressionDAGChecker.h"
#include "cmGeneratorTarget.h"
#include "cmGlobalGenerator.h"
#include "cmListFileCache.h"
#include "cmLocalGenerator.h"
#include "cmMakefile.h"
+#include "cmMessageType.h"
#include "cmRange.h"
#include "cmStateTypes.h"
#include "cmStringAlgorithms.h"
@@ -174,8 +179,62 @@
*/
+namespace {
+// LINK_LIBRARY helpers
+const auto LL_BEGIN = "<LINK_LIBRARY:"_s;
+const auto LL_END = "</LINK_LIBRARY:"_s;
+
+inline std::string ExtractFeature(std::string const& item)
+{
+ return item.substr(LL_BEGIN.length(),
+ item.find('>', LL_BEGIN.length()) - LL_BEGIN.length());
+}
+
+bool IsFeatureSupported(cmMakefile* makefile, std::string const& linkLanguage,
+ std::string const& feature)
+{
+ auto featureSupported = cmStrCat(
+ "CMAKE_", linkLanguage, "_LINK_LIBRARY_USING_", feature, "_SUPPORTED");
+ if (makefile->GetDefinition(featureSupported).IsOn()) {
+ return true;
+ }
+
+ featureSupported =
+ cmStrCat("CMAKE_LINK_LIBRARY_USING_", feature, "_SUPPORTED");
+ return makefile->GetDefinition(featureSupported).IsOn();
+}
+
+// LINK_GROUP helpers
+const auto LG_BEGIN = "<LINK_GROUP:"_s;
+const auto LG_END = "</LINK_GROUP:"_s;
+
+inline std::string ExtractGroupFeature(std::string const& item)
+{
+ return item.substr(LG_BEGIN.length(),
+ item.find(':', LG_BEGIN.length()) - LG_BEGIN.length());
+}
+
+bool IsGroupFeatureSupported(cmMakefile* makefile,
+ std::string const& linkLanguage,
+ std::string const& feature)
+{
+ auto featureSupported = cmStrCat(
+ "CMAKE_", linkLanguage, "_LINK_GROUP_USING_", feature, "_SUPPORTED");
+ if (makefile->GetDefinition(featureSupported).IsOn()) {
+ return true;
+ }
+
+ featureSupported =
+ cmStrCat("CMAKE_LINK_GROUP_USING_", feature, "_SUPPORTED");
+ return makefile->GetDefinition(featureSupported).IsOn();
+}
+}
+
+const std::string cmComputeLinkDepends::LinkEntry::DEFAULT = "DEFAULT";
+
cmComputeLinkDepends::cmComputeLinkDepends(const cmGeneratorTarget* target,
- const std::string& config)
+ const std::string& config,
+ const std::string& linkLanguage)
{
// Store context information.
this->Target = target;
@@ -183,6 +242,50 @@
this->GlobalGenerator =
this->Target->GetLocalGenerator()->GetGlobalGenerator();
this->CMakeInstance = this->GlobalGenerator->GetCMakeInstance();
+ this->LinkLanguage = linkLanguage;
+
+ // target oriented feature override property takes precedence over
+ // global override property
+ cm::string_view lloPrefix = "LINK_LIBRARY_OVERRIDE_"_s;
+ auto const& keys = this->Target->GetPropertyKeys();
+ std::for_each(
+ keys.cbegin(), keys.cend(),
+ [this, &lloPrefix, &config, &linkLanguage](std::string const& key) {
+ if (cmHasPrefix(key, lloPrefix)) {
+ if (cmValue feature = this->Target->GetProperty(key)) {
+ if (!feature->empty() && key.length() > lloPrefix.length()) {
+ auto item = key.substr(lloPrefix.length());
+ cmGeneratorExpressionDAGChecker dag{ this->Target->GetBacktrace(),
+ this->Target,
+ "LINK_LIBRARY_OVERRIDE",
+ nullptr, nullptr };
+ auto overrideFeature = cmGeneratorExpression::Evaluate(
+ feature, this->Target->GetLocalGenerator(), config, this->Target,
+ &dag, this->Target, linkLanguage);
+ this->LinkLibraryOverride.emplace(item, overrideFeature);
+ }
+ }
+ }
+ });
+ // global override property
+ if (cmValue linkLibraryOverride =
+ this->Target->GetProperty("LINK_LIBRARY_OVERRIDE")) {
+ cmGeneratorExpressionDAGChecker dag{ target->GetBacktrace(), target,
+ "LINK_LIBRARY_OVERRIDE", nullptr,
+ nullptr };
+ auto overrideValue = cmGeneratorExpression::Evaluate(
+ linkLibraryOverride, target->GetLocalGenerator(), config, target, &dag,
+ target, linkLanguage);
+
+ auto overrideList = cmTokenize(overrideValue, ","_s);
+ if (overrideList.size() >= 2) {
+ auto const& feature = overrideList.front();
+ for_each(overrideList.cbegin() + 1, overrideList.cend(),
+ [this, &feature](std::string const& item) {
+ this->LinkLibraryOverride.emplace(item, feature);
+ });
+ }
+ }
// The configuration being linked.
this->HasConfig = !config.empty();
@@ -234,6 +337,11 @@
// Infer dependencies of targets for which they were not known.
this->InferDependencies();
+ // finalize groups dependencies
+ // All dependencies which are raw items must be replaced by the group
+ // it belongs to, if any.
+ this->UpdateGroupDependencies();
+
// Cleanup the constraint graph.
this->CleanConstraintGraph();
@@ -248,8 +356,21 @@
this->DisplayConstraintGraph();
}
+ // Compute the DAG of strongly connected components. The algorithm
+ // used by cmComputeComponentGraph should identify the components in
+ // the same order in which the items were originally discovered in
+ // the BFS. This should preserve the original order when no
+ // constraints disallow it.
+ this->CCG =
+ cm::make_unique<cmComputeComponentGraph>(this->EntryConstraintGraph);
+ this->CCG->Compute();
+
+ if (!this->CheckCircularDependencies()) {
+ return this->FinalLinkEntries;
+ }
+
// Compute the final ordering.
- this->OrderLinkEntires();
+ this->OrderLinkEntries();
// Compute the final set of link entries.
// Iterate in reverse order so we can keep only the last occurrence
@@ -273,6 +394,29 @@
// Reverse the resulting order since we iterated in reverse.
std::reverse(this->FinalLinkEntries.begin(), this->FinalLinkEntries.end());
+ // Expand group items
+ if (!this->GroupItems.empty()) {
+ for (const auto& group : this->GroupItems) {
+ const LinkEntry& groupEntry = this->EntryList[group.first];
+ auto it = this->FinalLinkEntries.begin();
+ while (true) {
+ it = std::find_if(it, this->FinalLinkEntries.end(),
+ [&groupEntry](const LinkEntry& entry) -> bool {
+ return groupEntry.Item == entry.Item;
+ });
+ if (it == this->FinalLinkEntries.end()) {
+ break;
+ }
+ it->Item.Value = "</LINK_GROUP>";
+ for (auto i = group.second.rbegin(); i != group.second.rend(); ++i) {
+ it = this->FinalLinkEntries.insert(it, this->EntryList[*i]);
+ }
+ it = this->FinalLinkEntries.insert(it, groupEntry);
+ it->Item.Value = "<LINK_GROUP>";
+ }
+ }
+ }
+
// Display the final set.
if (this->DebugMode) {
this->DisplayFinalEntries();
@@ -281,76 +425,91 @@
return this->FinalLinkEntries;
}
-std::map<cmLinkItem, int>::iterator cmComputeLinkDepends::AllocateLinkEntry(
- cmLinkItem const& item)
+std::string const& cmComputeLinkDepends::GetCurrentFeature(
+ std::string const& item, std::string const& defaultFeature) const
+{
+ auto it = this->LinkLibraryOverride.find(item);
+ return it == this->LinkLibraryOverride.end() ? defaultFeature : it->second;
+}
+
+std::pair<std::map<cmLinkItem, int>::iterator, bool>
+cmComputeLinkDepends::AllocateLinkEntry(cmLinkItem const& item)
{
std::map<cmLinkItem, int>::value_type index_entry(
item, static_cast<int>(this->EntryList.size()));
- auto lei = this->LinkEntryIndex.insert(index_entry).first;
- this->EntryList.emplace_back();
- this->InferredDependSets.emplace_back();
- this->EntryConstraintGraph.emplace_back();
+ auto lei = this->LinkEntryIndex.insert(index_entry);
+ if (lei.second) {
+ this->EntryList.emplace_back();
+ this->InferredDependSets.emplace_back();
+ this->EntryConstraintGraph.emplace_back();
+ }
return lei;
}
-int cmComputeLinkDepends::AddLinkEntry(cmLinkItem const& item)
+std::pair<int, bool> cmComputeLinkDepends::AddLinkEntry(cmLinkItem const& item,
+ int groupIndex)
{
+ // Allocate a spot for the item entry.
+ auto lei = this->AllocateLinkEntry(item);
+
// Check if the item entry has already been added.
- auto lei = this->LinkEntryIndex.find(item);
- if (lei != this->LinkEntryIndex.end()) {
+ if (!lei.second) {
// Yes. We do not need to follow the item's dependencies again.
- return lei->second;
+ return { lei.first->second, false };
}
- // Allocate a spot for the item entry.
- lei = this->AllocateLinkEntry(item);
-
// Initialize the item entry.
- int index = lei->second;
+ int index = lei.first->second;
LinkEntry& entry = this->EntryList[index];
entry.Item = BT<std::string>(item.AsStr(), item.Backtrace);
entry.Target = item.Target;
- entry.IsFlag = (!entry.Target && entry.Item.Value[0] == '-' &&
- entry.Item.Value[1] != 'l' &&
- entry.Item.Value.substr(0, 10) != "-framework");
+ if (!entry.Target && entry.Item.Value[0] == '-' &&
+ entry.Item.Value[1] != 'l' &&
+ entry.Item.Value.substr(0, 10) != "-framework") {
+ entry.Kind = LinkEntry::Flag;
+ } else if (cmHasPrefix(entry.Item.Value, LG_BEGIN) &&
+ cmHasSuffix(entry.Item.Value, '>')) {
+ entry.Kind = LinkEntry::Group;
+ }
- // If the item has dependencies queue it to follow them.
- if (entry.Target) {
- // Target dependencies are always known. Follow them.
- BFSEntry qe = { index, nullptr };
- this->BFSQueue.push(qe);
- } else {
- // Look for an old-style <item>_LIB_DEPENDS variable.
- std::string var = cmStrCat(entry.Item.Value, "_LIB_DEPENDS");
- if (cmValue val = this->Makefile->GetDefinition(var)) {
- // The item dependencies are known. Follow them.
- BFSEntry qe = { index, val->c_str() };
+ if (entry.Kind != LinkEntry::Group) {
+ // If the item has dependencies queue it to follow them.
+ if (entry.Target) {
+ // Target dependencies are always known. Follow them.
+ BFSEntry qe = { index, groupIndex, nullptr };
this->BFSQueue.push(qe);
- } else if (!entry.IsFlag) {
- // The item dependencies are not known. We need to infer them.
- this->InferredDependSets[index].Initialized = true;
+ } else {
+ // Look for an old-style <item>_LIB_DEPENDS variable.
+ std::string var = cmStrCat(entry.Item.Value, "_LIB_DEPENDS");
+ if (cmValue val = this->Makefile->GetDefinition(var)) {
+ // The item dependencies are known. Follow them.
+ BFSEntry qe = { index, groupIndex, val->c_str() };
+ this->BFSQueue.push(qe);
+ } else if (entry.Kind != LinkEntry::Flag) {
+ // The item dependencies are not known. We need to infer them.
+ this->InferredDependSets[index].Initialized = true;
+ }
}
}
- return index;
+ return { index, true };
}
void cmComputeLinkDepends::AddLinkObject(cmLinkItem const& item)
{
+ // Allocate a spot for the item entry.
+ auto lei = this->AllocateLinkEntry(item);
+
// Check if the item entry has already been added.
- auto lei = this->LinkEntryIndex.find(item);
- if (lei != this->LinkEntryIndex.end()) {
+ if (!lei.second) {
return;
}
- // Allocate a spot for the item entry.
- lei = this->AllocateLinkEntry(item);
-
// Initialize the item entry.
- int index = lei->second;
+ int index = lei.first->second;
LinkEntry& entry = this->EntryList[index];
entry.Item = BT<std::string>(item.AsStr(), item.Backtrace);
- entry.IsObject = true;
+ entry.Kind = LinkEntry::Object;
// Record explicitly linked object files separately.
this->ObjectEntries.emplace_back(index);
@@ -359,8 +518,8 @@
void cmComputeLinkDepends::FollowLinkEntry(BFSEntry qe)
{
// Get this entry representation.
- int depender_index = qe.Index;
- LinkEntry const& entry = this->EntryList[depender_index];
+ int depender_index = qe.GroupIndex == -1 ? qe.Index : qe.GroupIndex;
+ LinkEntry const& entry = this->EntryList[qe.Index];
// Follow the item's dependencies.
if (entry.Target) {
@@ -423,25 +582,24 @@
void cmComputeLinkDepends::HandleSharedDependency(SharedDepEntry const& dep)
{
- // Check if the target already has an entry.
- auto lei = this->LinkEntryIndex.find(dep.Item);
- if (lei == this->LinkEntryIndex.end()) {
- // Allocate a spot for the item entry.
- lei = this->AllocateLinkEntry(dep.Item);
+ // Allocate a spot for the item entry.
+ auto lei = this->AllocateLinkEntry(dep.Item);
+ int index = lei.first->second;
+ // Check if the target does not already has an entry.
+ if (lei.second) {
// Initialize the item entry.
- LinkEntry& entry = this->EntryList[lei->second];
+ LinkEntry& entry = this->EntryList[index];
entry.Item = BT<std::string>(dep.Item.AsStr(), dep.Item.Backtrace);
entry.Target = dep.Item.Target;
// This item was added specifically because it is a dependent
// shared library. It may get special treatment
// in cmComputeLinkInformation.
- entry.IsSharedDep = true;
+ entry.Kind = LinkEntry::SharedDep;
}
// Get the link entry for this target.
- int index = lei->second;
LinkEntry& entry = this->EntryList[index];
// This shared library dependency must follow the item that listed
@@ -541,6 +699,11 @@
{
// Track inferred dependency sets implied by this list.
std::map<int, DependSet> dependSets;
+ std::string feature = LinkEntry::DEFAULT;
+
+ bool inGroup = false;
+ std::pair<int, bool> groupIndex{ -1, false };
+ std::vector<int> groupItems;
// Loop over the libraries linked directly by the depender.
for (T const& l : libs) {
@@ -551,35 +714,233 @@
continue;
}
- // Add a link entry for this item.
- int dependee_index = this->AddLinkEntry(l);
-
- // The dependee must come after the depender.
- if (depender_index >= 0) {
- this->EntryConstraintGraph[depender_index].emplace_back(
- dependee_index, false, false, cmListFileBacktrace());
- } else {
- // This is a direct dependency of the target being linked.
- this->OriginalEntries.push_back(dependee_index);
+ if (cmHasPrefix(item.AsStr(), LL_BEGIN) &&
+ cmHasSuffix(item.AsStr(), '>')) {
+ feature = ExtractFeature(item.AsStr());
+ // emit a warning if an undefined feature is used as part of
+ // an imported target
+ if (depender_index >= 0) {
+ const auto& depender = this->EntryList[depender_index];
+ if (depender.Target != nullptr && depender.Target->IsImported() &&
+ !IsFeatureSupported(this->Makefile, this->LinkLanguage, feature)) {
+ this->CMakeInstance->IssueMessage(
+ MessageType::AUTHOR_ERROR,
+ cmStrCat("The 'IMPORTED' target '", depender.Target->GetName(),
+ "' uses the generator-expression '$<LINK_LIBRARY>' with "
+ "the feature '",
+ feature,
+ "', which is undefined or unsupported.\nDid you miss to "
+ "define it by setting variables \"CMAKE_",
+ this->LinkLanguage, "_LINK_LIBRARY_USING_", feature,
+ "\" and \"CMAKE_", this->LinkLanguage,
+ "_LINK_LIBRARY_USING_", feature, "_SUPPORTED\"?"),
+ this->Target->GetBacktrace());
+ }
+ }
+ continue;
+ }
+ if (cmHasPrefix(item.AsStr(), LL_END) && cmHasSuffix(item.AsStr(), '>')) {
+ feature = LinkEntry::DEFAULT;
+ continue;
}
- // Update the inferred dependencies for earlier items.
- for (auto& dependSet : dependSets) {
- // Add this item to the inferred dependencies of other items.
- // Target items are never inferred dependees because unknown
- // items are outside libraries that should not be depending on
- // targets.
- if (!this->EntryList[dependee_index].Target &&
- !this->EntryList[dependee_index].IsFlag &&
- dependee_index != dependSet.first) {
- dependSet.second.insert(dependee_index);
+ if (cmHasPrefix(item.AsStr(), LG_BEGIN) &&
+ cmHasSuffix(item.AsStr(), '>')) {
+ groupIndex = this->AddLinkEntry(item);
+ if (groupIndex.second) {
+ LinkEntry& entry = this->EntryList[groupIndex.first];
+ entry.Feature = ExtractGroupFeature(item.AsStr());
+ }
+ inGroup = true;
+ if (depender_index >= 0) {
+ this->EntryConstraintGraph[depender_index].emplace_back(
+ groupIndex.first, false, false, cmListFileBacktrace());
+ } else {
+ // This is a direct dependency of the target being linked.
+ this->OriginalEntries.push_back(groupIndex.first);
+ }
+ continue;
+ }
+
+ int dependee_index;
+
+ if (cmHasPrefix(item.AsStr(), LG_END) && cmHasSuffix(item.AsStr(), '>')) {
+ dependee_index = groupIndex.first;
+ if (groupIndex.second) {
+ this->GroupItems.emplace(groupIndex.first, groupItems);
+ }
+ inGroup = false;
+ groupIndex = std::make_pair(-1, false);
+ groupItems.clear();
+ continue;
+ }
+
+ if (depender_index >= 0 && inGroup) {
+ const auto& depender = this->EntryList[depender_index];
+ const auto& groupFeature = this->EntryList[groupIndex.first].Feature;
+ if (depender.Target != nullptr && depender.Target->IsImported() &&
+ !IsGroupFeatureSupported(this->Makefile, this->LinkLanguage,
+ groupFeature)) {
+ this->CMakeInstance->IssueMessage(
+ MessageType::AUTHOR_ERROR,
+ cmStrCat("The 'IMPORTED' target '", depender.Target->GetName(),
+ "' uses the generator-expression '$<LINK_GROUP>' with "
+ "the feature '",
+ groupFeature,
+ "', which is undefined or unsupported.\nDid you miss to "
+ "define it by setting variables \"CMAKE_",
+ this->LinkLanguage, "_LINK_GROUP_USING_", groupFeature,
+ "\" and \"CMAKE_", this->LinkLanguage, "_LINK_GROUP_USING_",
+ groupFeature, "_SUPPORTED\"?"),
+ this->Target->GetBacktrace());
}
}
- // If this item needs to have dependencies inferred, do so.
- if (this->InferredDependSets[dependee_index].Initialized) {
- // Make sure an entry exists to hold the set for the item.
- dependSets[dependee_index];
+ // Add a link entry for this item.
+ auto ale = this->AddLinkEntry(item, groupIndex.first);
+ dependee_index = ale.first;
+ LinkEntry& entry = this->EntryList[dependee_index];
+ auto const& itemFeature =
+ this->GetCurrentFeature(entry.Item.Value, feature);
+ if (inGroup && ale.second && entry.Target != nullptr &&
+ (entry.Target->GetType() == cmStateEnums::TargetType::OBJECT_LIBRARY ||
+ entry.Target->GetType() ==
+ cmStateEnums::TargetType::INTERFACE_LIBRARY)) {
+ const auto& groupFeature = this->EntryList[groupIndex.first].Feature;
+ this->CMakeInstance->IssueMessage(
+ MessageType::AUTHOR_WARNING,
+ cmStrCat(
+ "The feature '", groupFeature,
+ "', specified as part of a generator-expression "
+ "'$",
+ LG_BEGIN, groupFeature, ">', will not be applied to the ",
+ (entry.Target->GetType() == cmStateEnums::TargetType::OBJECT_LIBRARY
+ ? "OBJECT"
+ : "INTERFACE"),
+ " library '", entry.Item.Value, "'."),
+ this->Target->GetBacktrace());
+ }
+ if (itemFeature != LinkEntry::DEFAULT) {
+ if (ale.second) {
+ // current item not yet defined
+ if (entry.Target != nullptr &&
+ (entry.Target->GetType() ==
+ cmStateEnums::TargetType::OBJECT_LIBRARY ||
+ entry.Target->GetType() ==
+ cmStateEnums::TargetType::INTERFACE_LIBRARY)) {
+ this->CMakeInstance->IssueMessage(
+ MessageType::AUTHOR_WARNING,
+ cmStrCat("The feature '", feature,
+ "', specified as part of a generator-expression "
+ "'$",
+ LL_BEGIN, feature, ">', will not be applied to the ",
+ (entry.Target->GetType() ==
+ cmStateEnums::TargetType::OBJECT_LIBRARY
+ ? "OBJECT"
+ : "INTERFACE"),
+ " library '", entry.Item.Value, "'."),
+ this->Target->GetBacktrace());
+ } else {
+ entry.Feature = itemFeature;
+ }
+ }
+ }
+
+ bool supportedItem = entry.Target == nullptr ||
+ (entry.Target->GetType() != cmStateEnums::TargetType::OBJECT_LIBRARY &&
+ entry.Target->GetType() != cmStateEnums::TargetType::INTERFACE_LIBRARY);
+
+ if (supportedItem) {
+ if (inGroup) {
+ const auto& currentFeature = this->EntryList[groupIndex.first].Feature;
+ for (const auto& g : this->GroupItems) {
+ const auto& groupFeature = this->EntryList[g.first].Feature;
+ if (groupFeature == currentFeature) {
+ continue;
+ }
+ if (std::find(g.second.cbegin(), g.second.cend(), dependee_index) !=
+ g.second.cend()) {
+ this->CMakeInstance->IssueMessage(
+ MessageType::FATAL_ERROR,
+ cmStrCat("Impossible to link target '", this->Target->GetName(),
+ "' because the link item '", entry.Item.Value,
+ "', specified with the group feature '", currentFeature,
+ '\'', ", has already occurred with the feature '",
+ groupFeature, '\'', ", which is not allowed."),
+ this->Target->GetBacktrace());
+ continue;
+ }
+ }
+ }
+ if (entry.Feature != itemFeature) {
+ // incompatibles features occurred
+ this->CMakeInstance->IssueMessage(
+ MessageType::FATAL_ERROR,
+ cmStrCat("Impossible to link target '", this->Target->GetName(),
+ "' because the link item '", entry.Item.Value,
+ "', specified ",
+ (itemFeature == LinkEntry::DEFAULT
+ ? "without any feature or 'DEFAULT' feature"
+ : cmStrCat("with the feature '", itemFeature, '\'')),
+ ", has already occurred ",
+ (entry.Feature == LinkEntry::DEFAULT
+ ? "without any feature or 'DEFAULT' feature"
+ : cmStrCat("with the feature '", entry.Feature, '\'')),
+ ", which is not allowed."),
+ this->Target->GetBacktrace());
+ }
+ }
+
+ if (inGroup) {
+ // store item index for dependencies handling
+ groupItems.push_back(dependee_index);
+ } else {
+ std::vector<int> indexes;
+ bool entryHandled = false;
+ // search any occurrence of the library in already defined groups
+ for (const auto& group : this->GroupItems) {
+ for (auto index : group.second) {
+ if (entry.Item.Value == this->EntryList[index].Item.Value) {
+ indexes.push_back(group.first);
+ entryHandled = true;
+ break;
+ }
+ }
+ }
+ if (!entryHandled) {
+ indexes.push_back(dependee_index);
+ }
+
+ for (auto index : indexes) {
+ // The dependee must come after the depender.
+ if (depender_index >= 0) {
+ this->EntryConstraintGraph[depender_index].emplace_back(
+ index, false, false, cmListFileBacktrace());
+ } else {
+ // This is a direct dependency of the target being linked.
+ this->OriginalEntries.push_back(index);
+ }
+
+ // Update the inferred dependencies for earlier items.
+ for (auto& dependSet : dependSets) {
+ // Add this item to the inferred dependencies of other items.
+ // Target items are never inferred dependees because unknown
+ // items are outside libraries that should not be depending on
+ // targets.
+ if (!this->EntryList[index].Target &&
+ this->EntryList[index].Kind != LinkEntry::Flag &&
+ this->EntryList[index].Kind != LinkEntry::Group &&
+ dependee_index != dependSet.first) {
+ dependSet.second.insert(index);
+ }
+ }
+
+ // If this item needs to have dependencies inferred, do so.
+ if (this->InferredDependSets[index].Initialized) {
+ // Make sure an entry exists to hold the set for the item.
+ dependSets[index];
+ }
+ }
}
}
@@ -642,6 +1003,36 @@
}
}
+void cmComputeLinkDepends::UpdateGroupDependencies()
+{
+ if (this->GroupItems.empty()) {
+ return;
+ }
+
+ // Walks through all entries of the constraint graph to replace dependencies
+ // over raw items by the group it belongs to, if any.
+ for (auto& edgeList : this->EntryConstraintGraph) {
+ for (auto& edge : edgeList) {
+ int index = edge;
+ if (this->EntryList[index].Kind == LinkEntry::Group ||
+ this->EntryList[index].Kind == LinkEntry::Flag ||
+ this->EntryList[index].Kind == LinkEntry::Object) {
+ continue;
+ }
+ // search the item in the defined groups
+ for (const auto& groupItems : this->GroupItems) {
+ auto pos = std::find(groupItems.second.cbegin(),
+ groupItems.second.cend(), index);
+ if (pos != groupItems.second.cend()) {
+ // replace lib dependency by the group it belongs to
+ edge = cmGraphEdge{ groupItems.first, false, false,
+ cmListFileBacktrace() };
+ }
+ }
+ }
+ }
+}
+
void cmComputeLinkDepends::CleanConstraintGraph()
{
for (cmGraphEdgeList& edgeList : this->EntryConstraintGraph) {
@@ -655,6 +1046,76 @@
}
}
+bool cmComputeLinkDepends::CheckCircularDependencies() const
+{
+ std::vector<NodeList> const& components = this->CCG->GetComponents();
+ int nc = static_cast<int>(components.size());
+ for (int c = 0; c < nc; ++c) {
+ // Get the current component.
+ NodeList const& nl = components[c];
+
+ // Skip trivial components.
+ if (nl.size() < 2) {
+ continue;
+ }
+
+ // no group must be evolved
+ bool cycleDetected = false;
+ for (int ni : nl) {
+ if (this->EntryList[ni].Kind == LinkEntry::Group) {
+ cycleDetected = true;
+ break;
+ }
+ }
+ if (!cycleDetected) {
+ continue;
+ }
+
+ // Construct the error message.
+ auto formatItem = [](LinkEntry const& entry) -> std::string {
+ if (entry.Kind == LinkEntry::Group) {
+ auto items =
+ entry.Item.Value.substr(entry.Item.Value.find(':', 12) + 1);
+ items.pop_back();
+ std::replace(items.begin(), items.end(), '|', ',');
+ return cmStrCat("group \"", ExtractGroupFeature(entry.Item.Value),
+ ":{", items, "}\"");
+ }
+ return cmStrCat('"', entry.Item.Value, '"');
+ };
+
+ std::ostringstream e;
+ e << "The inter-target dependency graph, for the target \""
+ << this->Target->GetName()
+ << "\", contains the following strongly connected component "
+ "(cycle):\n";
+ std::vector<int> const& cmap = this->CCG->GetComponentMap();
+ for (int i : nl) {
+ // Get the depender.
+ LinkEntry const& depender = this->EntryList[i];
+
+ // Describe the depender.
+ e << " " << formatItem(depender) << "\n";
+
+ // List its dependencies that are inside the component.
+ EdgeList const& el = this->EntryConstraintGraph[i];
+ for (cmGraphEdge const& ni : el) {
+ int j = ni;
+ if (cmap[j] == c) {
+ LinkEntry const& dependee = this->EntryList[j];
+ e << " depends on " << formatItem(dependee) << "\n";
+ }
+ }
+ }
+ this->CMakeInstance->IssueMessage(MessageType::FATAL_ERROR, e.str(),
+ this->Target->GetBacktrace());
+
+ return false;
+ }
+
+ return true;
+}
+
void cmComputeLinkDepends::DisplayConstraintGraph()
{
// Display the graph nodes and their edges.
@@ -667,17 +1128,8 @@
fprintf(stderr, "%s\n", e.str().c_str());
}
-void cmComputeLinkDepends::OrderLinkEntires()
+void cmComputeLinkDepends::OrderLinkEntries()
{
- // Compute the DAG of strongly connected components. The algorithm
- // used by cmComputeComponentGraph should identify the components in
- // the same order in which the items were originally discovered in
- // the BFS. This should preserve the original order when no
- // constraints disallow it.
- this->CCG =
- cm::make_unique<cmComputeComponentGraph>(this->EntryConstraintGraph);
- this->CCG->Compute();
-
// The component graph is guaranteed to be acyclic. Start a DFS
// from every entry to compute a topological order for the
// components.
@@ -867,12 +1319,23 @@
void cmComputeLinkDepends::DisplayFinalEntries()
{
fprintf(stderr, "target [%s] links to:\n", this->Target->GetName().c_str());
+ char space[] = " ";
+ int count = 2;
for (LinkEntry const& lei : this->FinalLinkEntries) {
- if (lei.Target) {
- fprintf(stderr, " target [%s]\n", lei.Target->GetName().c_str());
+ if (lei.Kind == LinkEntry::Group) {
+ fprintf(stderr, " %s group",
+ lei.Item.Value == "<LINK_GROUP>" ? "start" : "end");
+ count = lei.Item.Value == "<LINK_GROUP>" ? 4 : 2;
+ } else if (lei.Target) {
+ fprintf(stderr, "%*starget [%s]", count, space,
+ lei.Target->GetName().c_str());
} else {
- fprintf(stderr, " item [%s]\n", lei.Item.Value.c_str());
+ fprintf(stderr, "%*sitem [%s]", count, space, lei.Item.Value.c_str());
}
+ if (lei.Feature != LinkEntry::DEFAULT) {
+ fprintf(stderr, ", feature [%s]", lei.Feature.c_str());
+ }
+ fprintf(stderr, "\n");
}
fprintf(stderr, "\n");
}
diff --git a/Source/cmComputeLinkDepends.h b/Source/cmComputeLinkDepends.h
index 72316f1..8cc916a 100644
--- a/Source/cmComputeLinkDepends.h
+++ b/Source/cmComputeLinkDepends.h
@@ -9,6 +9,7 @@
#include <queue>
#include <set>
#include <string>
+#include <utility>
#include <vector>
#include "cmGraphAdjacencyList.h"
@@ -29,7 +30,8 @@
{
public:
cmComputeLinkDepends(cmGeneratorTarget const* target,
- const std::string& config);
+ const std::string& config,
+ const std::string& linkLanguage);
~cmComputeLinkDepends();
cmComputeLinkDepends(const cmComputeLinkDepends&) = delete;
@@ -38,11 +40,32 @@
// Basic information about each link item.
struct LinkEntry
{
+ LinkEntry() = default;
+ LinkEntry(BT<std::string> item, cmGeneratorTarget const* target = nullptr)
+ : Item(std::move(item))
+ , Target(target)
+ {
+ }
+
+ static const std::string DEFAULT;
+
+ enum EntryKind
+ {
+ Library,
+ Object,
+ SharedDep,
+ Flag,
+ // The following member is for the management of items specified
+ // through genex $<LINK_GROUP:...>
+ Group
+ };
+
BT<std::string> Item;
cmGeneratorTarget const* Target = nullptr;
- bool IsSharedDep = false;
- bool IsFlag = false;
- bool IsObject = false;
+ EntryKind Kind = Library;
+ // The following member is for the management of items specified
+ // through genex $<LINK_LIBRARY:...>
+ std::string Feature = std::string(DEFAULT);
};
using EntryVector = std::vector<LinkEntry>;
@@ -60,12 +83,18 @@
cmMakefile* Makefile;
cmGlobalGenerator const* GlobalGenerator;
cmake* CMakeInstance;
+ std::string LinkLanguage;
std::string Config;
EntryVector FinalLinkEntries;
+ std::map<std::string, std::string> LinkLibraryOverride;
- std::map<cmLinkItem, int>::iterator AllocateLinkEntry(
+ std::string const& GetCurrentFeature(
+ std::string const& item, std::string const& defaultFeature) const;
+
+ std::pair<std::map<cmLinkItem, int>::iterator, bool> AllocateLinkEntry(
cmLinkItem const& item);
- int AddLinkEntry(cmLinkItem const& item);
+ std::pair<int, bool> AddLinkEntry(cmLinkItem const& item,
+ int groupIndex = -1);
void AddLinkObject(cmLinkItem const& item);
void AddVarLinkEntries(int depender_index, const char* value);
void AddDirectLinkEntries();
@@ -78,10 +107,14 @@
std::vector<LinkEntry> EntryList;
std::map<cmLinkItem, int> LinkEntryIndex;
+ // map storing, for each group, the list of items
+ std::map<int, std::vector<int>> GroupItems;
+
// BFS of initial dependencies.
struct BFSEntry
{
int Index;
+ int GroupIndex;
const char* LibDepends;
};
std::queue<BFSEntry> BFSQueue;
@@ -114,16 +147,20 @@
std::vector<DependSetList> InferredDependSets;
void InferDependencies();
+ // To finalize dependencies over groups in place of raw items
+ void UpdateGroupDependencies();
+
// Ordering constraint graph adjacency list.
using NodeList = cmGraphNodeList;
using EdgeList = cmGraphEdgeList;
using Graph = cmGraphAdjacencyList;
Graph EntryConstraintGraph;
void CleanConstraintGraph();
+ bool CheckCircularDependencies() const;
void DisplayConstraintGraph();
// Ordering algorithm.
- void OrderLinkEntires();
+ void OrderLinkEntries();
std::vector<char> ComponentVisited;
std::vector<int> ComponentOrder;
diff --git a/Source/cmComputeLinkInformation.cxx b/Source/cmComputeLinkInformation.cxx
index 2ff91fe..67214f1 100644
--- a/Source/cmComputeLinkInformation.cxx
+++ b/Source/cmComputeLinkInformation.cxx
@@ -8,7 +8,9 @@
#include <utility>
#include <cm/memory>
+#include <cm/optional>
#include <cmext/algorithm>
+#include <cmext/string_view>
#include "cmComputeLinkDepends.h"
#include "cmGeneratorTarget.h"
@@ -18,7 +20,7 @@
#include "cmMakefile.h"
#include "cmMessageType.h"
#include "cmOrderDirectories.h"
-#include "cmOutputConverter.h"
+#include "cmPlaceholderExpander.h"
#include "cmPolicies.h"
#include "cmState.h"
#include "cmStateTypes.h"
@@ -344,6 +346,29 @@
this->LinkWithRuntimePath = this->Makefile->IsOn(var);
}
+ // Define some Feature descriptors to handle standard library and object link
+ if (!this->GetLibLinkFileFlag().empty()) {
+ this->LibraryFeatureDescriptors.emplace(
+ "__CMAKE_LINK_LIBRARY",
+ LibraryFeatureDescriptor{
+ "__CMAKE_LINK_LIBRARY",
+ cmStrCat(this->GetLibLinkFileFlag(), "<LIBRARY>") });
+ }
+ if (!this->GetObjLinkFileFlag().empty()) {
+ this->LibraryFeatureDescriptors.emplace(
+ "__CMAKE_LINK_OBJECT",
+ LibraryFeatureDescriptor{
+ "__CMAKE_LINK_OBJECT",
+ cmStrCat(this->GetObjLinkFileFlag(), "<LIBRARY>") });
+ }
+ if (!this->LoaderFlag->empty()) {
+ // Define a Feature descriptor for the link of an executable with exports
+ this->LibraryFeatureDescriptors.emplace(
+ "__CMAKE_LINK_EXECUTABLE",
+ LibraryFeatureDescriptor{ "__CMAKE_LINK_EXECUTABLE",
+ cmStrCat(this->LoaderFlag, "<LIBRARY>") });
+ }
+
// Check the platform policy for missing soname case.
this->NoSONameUsesPath =
this->Makefile->IsOn("CMAKE_PLATFORM_USES_PATH_WHEN_NO_SONAME");
@@ -409,6 +434,10 @@
cmComputeLinkInformation::~cmComputeLinkInformation() = default;
+namespace {
+const std::string& DEFAULT = cmComputeLinkDepends::LinkEntry::DEFAULT;
+}
+
void cmComputeLinkInformation::AppendValues(
std::string& result, std::vector<BT<std::string>>& values)
{
@@ -510,17 +539,67 @@
}
// Compute the ordered link line items.
- cmComputeLinkDepends cld(this->Target, this->Config);
+ cmComputeLinkDepends cld(this->Target, this->Config, this->LinkLanguage);
cld.SetOldLinkDirMode(this->OldLinkDirMode);
cmComputeLinkDepends::EntryVector const& linkEntries = cld.Compute();
+ FeatureDescriptor const* currentFeature = nullptr;
// Add the link line items.
for (cmComputeLinkDepends::LinkEntry const& linkEntry : linkEntries) {
- if (linkEntry.IsSharedDep) {
- this->AddSharedDepItem(linkEntry.Item, linkEntry.Target);
+ if (linkEntry.Kind == cmComputeLinkDepends::LinkEntry::Group) {
+ const auto& groupFeature = this->GetGroupFeature(linkEntry.Feature);
+ if (groupFeature.Supported) {
+ this->Items.emplace_back(
+ BT<std::string>{ linkEntry.Item.Value == "<LINK_GROUP>"
+ ? groupFeature.Prefix
+ : groupFeature.Suffix,
+ linkEntry.Item.Backtrace },
+ ItemIsPath::No);
+ }
+ continue;
+ }
+
+ if (currentFeature != nullptr &&
+ linkEntry.Feature != currentFeature->Name) {
+ // emit feature suffix, if any
+ if (!currentFeature->Suffix.empty()) {
+ this->Items.emplace_back(
+ BT<std::string>{ currentFeature->Suffix,
+ this->Items.back().Value.Backtrace },
+ ItemIsPath::No);
+ }
+ currentFeature = nullptr;
+ }
+
+ if (linkEntry.Feature != DEFAULT &&
+ (currentFeature == nullptr ||
+ linkEntry.Feature != currentFeature->Name)) {
+ if (!this->AddLibraryFeature(linkEntry.Feature)) {
+ continue;
+ }
+ currentFeature = this->FindLibraryFeature(linkEntry.Feature);
+ // emit feature prefix, if any
+ if (!currentFeature->Prefix.empty()) {
+ this->Items.emplace_back(
+ BT<std::string>{ currentFeature->Prefix, linkEntry.Item.Backtrace },
+ ItemIsPath::No);
+ }
+ }
+
+ if (linkEntry.Kind == cmComputeLinkDepends::LinkEntry::SharedDep) {
+ this->AddSharedDepItem(linkEntry);
} else {
- this->AddItem(linkEntry.Item, linkEntry.Target,
- linkEntry.IsObject ? ItemIsObject::Yes : ItemIsObject::No);
+ this->AddItem(linkEntry);
+ }
+ }
+
+ if (currentFeature != nullptr) {
+ // emit feature suffix, if any
+ if (!currentFeature->Suffix.empty()) {
+ this->Items.emplace_back(
+ BT<std::string>{ currentFeature->Suffix,
+ this->Items.back().Value.Backtrace },
+ ItemIsPath::No);
}
}
@@ -576,6 +655,373 @@
return true;
}
+namespace {
+void FinalizeFeatureFormat(std::string& format, const std::string& activeTag,
+ const std::string& otherTag)
+{
+ auto pos = format.find(otherTag);
+ if (pos != std::string::npos) {
+ format.erase(pos, format.find('}', pos) - pos + 1);
+ }
+ pos = format.find(activeTag);
+ if (pos != std::string::npos) {
+ format.erase(pos, activeTag.length());
+ pos = format.find('}', pos);
+ if (pos != std::string::npos) {
+ format.erase(pos, 1);
+ }
+ }
+}
+
+bool IsValidFeatureFormat(const std::string& format)
+{
+ return format.find("<LIBRARY>") != std::string::npos ||
+ format.find("<LIB_ITEM>") != std::string::npos ||
+ format.find("<LINK_ITEM>") != std::string::npos;
+}
+
+class FeaturePlaceHolderExpander : public cmPlaceholderExpander
+{
+public:
+ FeaturePlaceHolderExpander(const std::string* library,
+ const std::string* libItem = nullptr,
+ const std::string* linkItem = nullptr)
+ : Library(library)
+ , LibItem(libItem)
+ , LinkItem(linkItem)
+ {
+ }
+
+private:
+ std::string ExpandVariable(std::string const& variable) override
+ {
+ if (this->Library != nullptr && variable == "LIBRARY") {
+ return *this->Library;
+ }
+ if (this->LibItem != nullptr && variable == "LIB_ITEM") {
+ return *this->LibItem;
+ }
+ if (this->LinkItem != nullptr && variable == "LINK_ITEM") {
+ return *this->LinkItem;
+ }
+
+ return variable;
+ }
+
+ const std::string* Library = nullptr;
+ const std::string* LibItem = nullptr;
+ const std::string* LinkItem = nullptr;
+};
+}
+
+cmComputeLinkInformation::FeatureDescriptor::FeatureDescriptor(
+ std::string name, std::string itemFormat)
+ : Name(std::move(name))
+ , Supported(true)
+ , ItemPathFormat(std::move(itemFormat))
+ , ItemNameFormat(this->ItemPathFormat)
+{
+}
+cmComputeLinkInformation::FeatureDescriptor::FeatureDescriptor(
+ std::string name, std::string itemPathFormat, std::string itemNameFormat)
+ : Name(std::move(name))
+ , Supported(true)
+ , ItemPathFormat(std::move(itemPathFormat))
+ , ItemNameFormat(std::move(itemNameFormat))
+{
+}
+cmComputeLinkInformation::FeatureDescriptor::FeatureDescriptor(
+ std::string name, std::string prefix, std::string itemPathFormat,
+ std::string itemNameFormat, std::string suffix)
+ : Name(std::move(name))
+ , Supported(true)
+ , Prefix(std::move(prefix))
+ , Suffix(std::move(suffix))
+ , ItemPathFormat(std::move(itemPathFormat))
+ , ItemNameFormat(std::move(itemNameFormat))
+{
+}
+cmComputeLinkInformation::FeatureDescriptor::FeatureDescriptor(
+ std::string name, std::string prefix, std::string suffix, bool)
+ : Name(std::move(name))
+ , Supported(true)
+ , Prefix(std::move(prefix))
+ , Suffix(std::move(suffix))
+{
+}
+
+std::string cmComputeLinkInformation::FeatureDescriptor::GetDecoratedItem(
+ std::string const& library, ItemIsPath isPath) const
+{
+ auto format =
+ isPath == ItemIsPath::Yes ? this->ItemPathFormat : this->ItemNameFormat;
+
+ // replace <LIBRARY>, <LIB_ITEM> and <LINK_ITEM> patterns with library path
+ FeaturePlaceHolderExpander expander(&library, &library, &library);
+ return expander.ExpandVariables(format);
+}
+std::string cmComputeLinkInformation::FeatureDescriptor::GetDecoratedItem(
+ std::string const& library, std::string const& libItem,
+ std::string const& linkItem, ItemIsPath isPath) const
+{
+ auto format =
+ isPath == ItemIsPath::Yes ? this->ItemPathFormat : this->ItemNameFormat;
+
+ // replace <LIBRARY>, <LIB_ITEM> and <LINK_ITEM> patterns
+ FeaturePlaceHolderExpander expander(&library, &libItem, &linkItem);
+ return expander.ExpandVariables(format);
+}
+
+cmComputeLinkInformation::LibraryFeatureDescriptor::LibraryFeatureDescriptor(
+ std::string name, std::string itemFormat)
+ : FeatureDescriptor(std::move(name), std::move(itemFormat))
+{
+}
+cmComputeLinkInformation::LibraryFeatureDescriptor::LibraryFeatureDescriptor(
+ std::string name, std::string itemPathFormat, std::string itemNameFormat)
+ : FeatureDescriptor(std::move(name), std::move(itemPathFormat),
+ std::move(itemNameFormat))
+{
+}
+cmComputeLinkInformation::LibraryFeatureDescriptor::LibraryFeatureDescriptor(
+ std::string name, std::string prefix, std::string itemPathFormat,
+ std::string itemNameFormat, std::string suffix)
+ : FeatureDescriptor(std::move(name), std::move(prefix),
+ std::move(itemPathFormat), std::move(itemNameFormat),
+ std::move(suffix))
+{
+}
+
+bool cmComputeLinkInformation::AddLibraryFeature(std::string const& feature)
+{
+ auto it = this->LibraryFeatureDescriptors.find(feature);
+ if (it != this->LibraryFeatureDescriptors.end()) {
+ return it->second.Supported;
+ }
+
+ auto featureName =
+ cmStrCat("CMAKE_", this->LinkLanguage, "_LINK_LIBRARY_USING_", feature);
+ cmValue featureSupported =
+ this->Makefile->GetDefinition(cmStrCat(featureName, "_SUPPORTED"));
+ if (!featureSupported.IsOn()) {
+ featureName = cmStrCat("CMAKE_LINK_LIBRARY_USING_", feature);
+ featureSupported =
+ this->Makefile->GetDefinition(cmStrCat(featureName, "_SUPPORTED"));
+ }
+ if (!featureSupported.IsOn()) {
+ this->LibraryFeatureDescriptors.emplace(feature, FeatureDescriptor{});
+
+ this->CMakeInstance->IssueMessage(
+ MessageType::FATAL_ERROR,
+ cmStrCat(
+ "Feature '", feature,
+ "', specified through generator-expression '$<LINK_LIBRARY>' to "
+ "link target '",
+ this->Target->GetName(), "', is not supported for the '",
+ this->LinkLanguage, "' link language."),
+ this->Target->GetBacktrace());
+
+ return false;
+ }
+
+ cmValue langFeature = this->Makefile->GetDefinition(featureName);
+ if (!langFeature) {
+ this->LibraryFeatureDescriptors.emplace(feature, FeatureDescriptor{});
+
+ this->CMakeInstance->IssueMessage(
+ MessageType::FATAL_ERROR,
+ cmStrCat(
+ "Feature '", feature,
+ "', specified through generator-expression '$<LINK_LIBRARY>' to "
+ "link target '",
+ this->Target->GetName(), "', is not defined for the '",
+ this->LinkLanguage, "' link language."),
+ this->Target->GetBacktrace());
+
+ return false;
+ }
+
+ auto items =
+ cmExpandListWithBacktrace(langFeature, this->Target->GetBacktrace(), true);
+
+ if ((items.size() == 1 && !IsValidFeatureFormat(items.front().Value)) ||
+ (items.size() == 3 && !IsValidFeatureFormat(items[1].Value))) {
+ this->LibraryFeatureDescriptors.emplace(feature, FeatureDescriptor{});
+ this->CMakeInstance->IssueMessage(
+ MessageType::FATAL_ERROR,
+ cmStrCat("Feature '", feature, "', specified by variable '", featureName,
+ "', is malformed (\"<LIBRARY>\", \"<LIB_ITEM>\", or "
+ "\"<LINK_ITEM>\" patterns "
+ "are missing) and cannot be used to link target '",
+ this->Target->GetName(), "'."),
+ this->Target->GetBacktrace());
+
+ return false;
+ }
+
+ // now, handle possible "PATH{}" and "NAME{}" patterns
+ if (items.size() == 1) {
+ items.push_back(items.front());
+ FinalizeFeatureFormat(items[0].Value, "PATH{", "NAME{");
+ FinalizeFeatureFormat(items[1].Value, "NAME{", "PATH{");
+ } else if (items.size() == 3) {
+ items.insert(items.begin() + 1, items[1]);
+ FinalizeFeatureFormat(items[1].Value, "PATH{", "NAME{");
+ FinalizeFeatureFormat(items[2].Value, "NAME{", "PATH{");
+ } else {
+ this->LibraryFeatureDescriptors.emplace(feature, FeatureDescriptor{});
+ this->CMakeInstance->IssueMessage(
+ MessageType::FATAL_ERROR,
+ cmStrCat("Feature '", feature, "', specified by variable '", featureName,
+ "', is malformed (wrong number of elements) and cannot be used "
+ "to link target '",
+ this->Target->GetName(), "'."),
+ this->Target->GetBacktrace());
+
+ return false;
+ }
+ if ((items.size() == 2 && !IsValidFeatureFormat(items[0].Value)) ||
+ (items.size() == 4 && !IsValidFeatureFormat(items[1].Value))) {
+ // PATH{} has wrong format
+ this->LibraryFeatureDescriptors.emplace(feature, FeatureDescriptor{});
+ this->CMakeInstance->IssueMessage(
+ MessageType::FATAL_ERROR,
+ cmStrCat("Feature '", feature, "', specified by variable '", featureName,
+ "', is malformed (\"<LIBRARY>\", \"<LIB_ITEM>\", or "
+ "\"<LINK_ITEM>\" patterns "
+ "are missing for \"PATH{}\" alternative) and cannot be used to "
+ "link target '",
+ this->Target->GetName(), "'."),
+ this->Target->GetBacktrace());
+
+ return false;
+ }
+ if ((items.size() == 2 && !IsValidFeatureFormat(items[1].Value)) ||
+ (items.size() == 4 && !IsValidFeatureFormat(items[2].Value))) {
+ // NAME{} has wrong format
+ this->LibraryFeatureDescriptors.emplace(feature, FeatureDescriptor{});
+ this->CMakeInstance->IssueMessage(
+ MessageType::FATAL_ERROR,
+ cmStrCat("Feature '", feature, "', specified by variable '", featureName,
+ "', is malformed (\"<LIBRARY>\", \"<LIB_ITEM>\", or "
+ "\"<LINK_ITEM>\" patterns "
+ "are missing for \"NAME{}\" alternative) and cannot be used to "
+ "link target '",
+ this->Target->GetName(), "'."),
+ this->Target->GetBacktrace());
+
+ return false;
+ }
+
+ // replace LINKER: pattern
+ this->Target->ResolveLinkerWrapper(items, this->LinkLanguage, true);
+
+ if (items.size() == 2) {
+ this->LibraryFeatureDescriptors.emplace(
+ feature,
+ LibraryFeatureDescriptor{ feature, items[0].Value, items[1].Value });
+ } else {
+ this->LibraryFeatureDescriptors.emplace(
+ feature,
+ LibraryFeatureDescriptor{ feature, items[0].Value, items[1].Value,
+ items[2].Value, items[3].Value });
+ }
+
+ return true;
+}
+
+cmComputeLinkInformation::FeatureDescriptor const&
+cmComputeLinkInformation::GetLibraryFeature(std::string const& feature) const
+{
+ return this->LibraryFeatureDescriptors.find(feature)->second;
+}
+cmComputeLinkInformation::FeatureDescriptor const*
+cmComputeLinkInformation::FindLibraryFeature(std::string const& feature) const
+{
+ auto it = this->LibraryFeatureDescriptors.find(feature);
+ if (it == this->LibraryFeatureDescriptors.end()) {
+ return nullptr;
+ }
+
+ return &it->second;
+}
+
+cmComputeLinkInformation::GroupFeatureDescriptor::GroupFeatureDescriptor(
+ std::string name, std::string prefix, std::string suffix)
+ : FeatureDescriptor(std::move(name), std::move(prefix), std::move(suffix),
+ true)
+{
+}
+
+cmComputeLinkInformation::FeatureDescriptor const&
+cmComputeLinkInformation::GetGroupFeature(std::string const& feature)
+{
+ auto it = this->GroupFeatureDescriptors.find(feature);
+ if (it != this->GroupFeatureDescriptors.end()) {
+ return it->second;
+ }
+
+ auto featureName =
+ cmStrCat("CMAKE_", this->LinkLanguage, "_LINK_GROUP_USING_", feature);
+ cmValue featureSupported =
+ this->Makefile->GetDefinition(cmStrCat(featureName, "_SUPPORTED"));
+ if (!featureSupported.IsOn()) {
+ featureName = cmStrCat("CMAKE_LINK_GROUP_USING_", feature);
+ featureSupported =
+ this->Makefile->GetDefinition(cmStrCat(featureName, "_SUPPORTED"));
+ }
+ if (!featureSupported.IsOn()) {
+ this->CMakeInstance->IssueMessage(
+ MessageType::FATAL_ERROR,
+ cmStrCat("Feature '", feature,
+ "', specified through generator-expression '$<LINK_GROUP>' to "
+ "link target '",
+ this->Target->GetName(), "', is not supported for the '",
+ this->LinkLanguage, "' link language."),
+ this->Target->GetBacktrace());
+ return this->GroupFeatureDescriptors.emplace(feature, FeatureDescriptor{})
+ .first->second;
+ }
+
+ cmValue langFeature = this->Makefile->GetDefinition(featureName);
+ if (!langFeature) {
+ this->CMakeInstance->IssueMessage(
+ MessageType::FATAL_ERROR,
+ cmStrCat("Feature '", feature,
+ "', specified through generator-expression '$<LINK_GROUP>' to "
+ "link target '",
+ this->Target->GetName(), "', is not defined for the '",
+ this->LinkLanguage, "' link language."),
+ this->Target->GetBacktrace());
+ return this->GroupFeatureDescriptors.emplace(feature, FeatureDescriptor{})
+ .first->second;
+ }
+
+ auto items =
+ cmExpandListWithBacktrace(langFeature, this->Target->GetBacktrace(), true);
+
+ // replace LINKER: pattern
+ this->Target->ResolveLinkerWrapper(items, this->LinkLanguage, true);
+
+ if (items.size() == 2) {
+ return this->GroupFeatureDescriptors
+ .emplace(
+ feature,
+ GroupFeatureDescriptor{ feature, items[0].Value, items[1].Value })
+ .first->second;
+ }
+
+ this->CMakeInstance->IssueMessage(
+ MessageType::FATAL_ERROR,
+ cmStrCat("Feature '", feature, "', specified by variable '", featureName,
+ "', is malformed (wrong number of elements) and cannot be used "
+ "to link target '",
+ this->Target->GetName(), "'."),
+ this->Target->GetBacktrace());
+ return this->GroupFeatureDescriptors.emplace(feature, FeatureDescriptor{})
+ .first->second;
+}
+
void cmComputeLinkInformation::AddImplicitLinkInfo()
{
// The link closure lists all languages whose implicit info is needed.
@@ -610,7 +1056,7 @@
std::vector<std::string> libsVec = cmExpandedList(*runtimeLinkOptions);
for (std::string const& i : libsVec) {
if (!cm::contains(this->ImplicitLinkLibs, i)) {
- this->AddItem(i, nullptr);
+ this->AddItem({ i });
}
}
}
@@ -625,7 +1071,7 @@
std::vector<std::string> libsVec = cmExpandedList(*libs);
for (std::string const& i : libsVec) {
if (!cm::contains(this->ImplicitLinkLibs, i)) {
- this->AddItem(i, nullptr);
+ this->AddItem({ i });
}
}
}
@@ -639,10 +1085,11 @@
}
}
-void cmComputeLinkInformation::AddItem(BT<std::string> const& item,
- cmGeneratorTarget const* tgt,
- ItemIsObject isObject)
+void cmComputeLinkInformation::AddItem(LinkEntry const& entry)
{
+ cmGeneratorTarget const* tgt = entry.Target;
+ BT<std::string> const& item = entry.Item;
+
// Compute the proper name to use to link this library.
const std::string& config = this->Config;
bool impexe = (tgt && tgt->IsExecutableWithExports());
@@ -657,28 +1104,27 @@
if (impexe && this->LoaderFlag) {
// This link item is an executable that may provide symbols
// used by this target. A special flag is needed on this
- // platform. Add it now.
- std::string linkItem = this->LoaderFlag;
+ // platform. Add it now using a special feature.
cmStateEnums::ArtifactType artifact = tgt->HasImportLibrary(config)
? cmStateEnums::ImportLibraryArtifact
: cmStateEnums::RuntimeBinaryArtifact;
-
std::string exe = tgt->GetFullPath(config, artifact, true);
- linkItem += exe;
- this->Items.emplace_back(BT<std::string>(linkItem, item.Backtrace),
- ItemIsPath::Yes, ItemIsObject::No, tgt);
+ this->Items.emplace_back(
+ BT<std::string>(exe, item.Backtrace), ItemIsPath::Yes, tgt,
+ this->FindLibraryFeature(entry.Feature == DEFAULT
+ ? "__CMAKE_LINK_EXECUTABLE"
+ : entry.Feature));
this->Depends.push_back(std::move(exe));
} else if (tgt->GetType() == cmStateEnums::INTERFACE_LIBRARY) {
// Add the interface library as an item so it can be considered as part
// of COMPATIBLE_INTERFACE_ enforcement. The generators will ignore
// this for the actual link line.
- this->Items.emplace_back(std::string(), ItemIsPath::No, ItemIsObject::No,
- tgt);
+ this->Items.emplace_back(std::string(), ItemIsPath::No, tgt);
// Also add the item the interface specifies to be used in its place.
std::string const& libName = tgt->GetImportedLibName(config);
if (!libName.empty()) {
- this->AddItem(BT<std::string>(libName, item.Backtrace), nullptr);
+ this->AddItem(BT<std::string>(libName, item.Backtrace));
}
} else if (tgt->GetType() == cmStateEnums::OBJECT_LIBRARY) {
// Ignore object library!
@@ -706,7 +1152,9 @@
this->Depends.push_back(lib.Value);
}
- this->AddTargetItem(lib, tgt);
+ LinkEntry libEntry{ entry };
+ libEntry.Item = lib;
+ this->AddTargetItem(libEntry);
this->AddLibraryRuntimeInfo(lib.Value, tgt);
if (tgt && tgt->GetType() == cmStateEnums::SHARED_LIBRARY &&
this->Target->IsDLLPlatform()) {
@@ -715,30 +1163,34 @@
}
} else {
// This is not a CMake target. Use the name given.
- if (cmSystemTools::FileIsFullPath(item.Value)) {
- if (cmSystemTools::IsPathToFramework(item.Value) &&
- this->Makefile->IsOn("APPLE")) {
- // This is a framework.
- this->AddFrameworkItem(item.Value);
- } else if (cmSystemTools::FileIsDirectory(item.Value)) {
+ if (cmHasSuffix(entry.Feature, "FRAMEWORK"_s) ||
+ (entry.Feature == DEFAULT &&
+ cmSystemTools::IsPathToFramework(item.Value) &&
+ this->Makefile->IsOn("APPLE"))) {
+ // This is a framework.
+ this->AddFrameworkItem(entry);
+ } else if (cmSystemTools::FileIsFullPath(item.Value)) {
+ if (cmSystemTools::FileIsDirectory(item.Value)) {
// This is a directory.
this->DropDirectoryItem(item);
} else {
// Use the full path given to the library file.
this->Depends.push_back(item.Value);
- this->AddFullItem(item, isObject);
+ this->AddFullItem(entry);
this->AddLibraryRuntimeInfo(item.Value);
}
} else {
// This is a library or option specified by the user.
- this->AddUserItem(item, true);
+ this->AddUserItem(entry, true);
}
}
}
-void cmComputeLinkInformation::AddSharedDepItem(BT<std::string> const& item,
- const cmGeneratorTarget* tgt)
+void cmComputeLinkInformation::AddSharedDepItem(LinkEntry const& entry)
{
+ BT<std::string> const& item = entry.Item;
+ const cmGeneratorTarget* tgt = entry.Target;
+
// Record dependencies on DLLs.
if (tgt && tgt->GetType() == cmStateEnums::SHARED_LIBRARY &&
this->Target->IsDLLPlatform() &&
@@ -776,7 +1228,7 @@
// If in linking mode, just link to the shared library.
if (this->SharedDependencyMode == SharedDepModeLink) {
- this->AddItem(item, tgt);
+ this->AddItem(entry);
return;
}
@@ -1058,8 +1510,7 @@
}
}
-void cmComputeLinkInformation::AddTargetItem(BT<std::string> const& item,
- cmGeneratorTarget const* target)
+void cmComputeLinkInformation::AddTargetItem(LinkEntry const& entry)
{
// This is called to handle a link item that is a full path to a target.
// If the target is not a static library make sure the link type is
@@ -1067,6 +1518,9 @@
// shared and static libraries but static-mode can handle only
// static libraries. If a previous user item changed the link type
// to static we need to make sure it is back to shared.
+ BT<std::string> const& item = entry.Item;
+ cmGeneratorTarget const* target = entry.Target;
+
if (target->GetType() != cmStateEnums::STATIC_LIBRARY) {
this->SetCurrentLinkType(LinkShared);
}
@@ -1079,7 +1533,7 @@
// Handle case of an imported shared library with no soname.
if (this->NoSONameUsesPath &&
target->IsImportedSharedLibWithoutSOName(this->Config)) {
- this->AddSharedLibNoSOName(item.Value);
+ this->AddSharedLibNoSOName(entry);
return;
}
@@ -1091,20 +1545,54 @@
this->OldLinkDirItems.push_back(item.Value);
}
- // Now add the full path to the library.
- this->Items.emplace_back(item, ItemIsPath::Yes, ItemIsObject::No, target);
+ if (target->IsFrameworkOnApple() && this->GlobalGenerator->IsXcode() &&
+ entry.Feature == DEFAULT) {
+ // ensure FRAMEWORK feature is loaded
+ this->AddLibraryFeature("FRAMEWORK");
+ }
+
+ if (cmHasSuffix(entry.Feature, "FRAMEWORK"_s) &&
+ target->IsFrameworkOnApple() && !this->GlobalGenerator->IsXcode()) {
+ // Add the framework directory and the framework item itself
+ auto fwItems = this->GlobalGenerator->SplitFrameworkPath(item.Value, true);
+ if (!fwItems) {
+ this->CMakeInstance->IssueMessage(
+ MessageType::FATAL_ERROR,
+ cmStrCat("Could not parse framework path \"", item.Value,
+ "\" linked by target ", this->Target->GetName(), '.'),
+ item.Backtrace);
+ return;
+ }
+ if (!fwItems->first.empty()) {
+ // Add the directory portion to the framework search path.
+ this->AddFrameworkPath(fwItems->first);
+ }
+ this->Items.emplace_back(fwItems->second, ItemIsPath::Yes, target,
+ this->FindLibraryFeature(entry.Feature));
+ } else {
+ // Now add the full path to the library.
+ this->Items.emplace_back(
+ item, ItemIsPath::Yes, target,
+ this->FindLibraryFeature(
+ entry.Feature == DEFAULT
+ ? (target->IsFrameworkOnApple() && this->GlobalGenerator->IsXcode()
+ ? "FRAMEWORK"
+ : "__CMAKE_LINK_LIBRARY")
+ : entry.Feature));
+ }
}
-void cmComputeLinkInformation::AddFullItem(BT<std::string> const& item,
- ItemIsObject isObject)
+void cmComputeLinkInformation::AddFullItem(LinkEntry const& entry)
{
+ BT<std::string> const& item = entry.Item;
+
// Check for the implicit link directory special case.
- if (this->CheckImplicitDirItem(item.Value)) {
+ if (this->CheckImplicitDirItem(entry)) {
return;
}
// Check for case of shared library with no builtin soname.
- if (this->NoSONameUsesPath && this->CheckSharedLibNoSOName(item.Value)) {
+ if (this->NoSONameUsesPath && this->CheckSharedLibNoSOName(entry)) {
return;
}
@@ -1116,7 +1604,7 @@
generator.find("Xcode") != std::string::npos)) {
std::string file = cmSystemTools::GetFilenameName(item.Value);
if (!this->ExtractAnyLibraryName.find(file)) {
- this->HandleBadFullItem(item.Value, file);
+ this->HandleBadFullItem(entry, file);
return;
}
}
@@ -1147,11 +1635,20 @@
}
// Now add the full path to the library.
- this->Items.emplace_back(item, ItemIsPath::Yes, isObject);
+ this->Items.emplace_back(
+ item, ItemIsPath::Yes, nullptr,
+ this->FindLibraryFeature(
+ entry.Feature == DEFAULT
+ ? (entry.Kind == cmComputeLinkDepends::LinkEntry::Object
+ ? "__CMAKE_LINK_OBJECT"
+ : "__CMAKE_LINK_LIBRARY")
+ : entry.Feature));
}
-bool cmComputeLinkInformation::CheckImplicitDirItem(std::string const& item)
+bool cmComputeLinkInformation::CheckImplicitDirItem(LinkEntry const& entry)
{
+ BT<std::string> const& item = entry.Item;
+
// We only switch to a pathless item if the link type may be
// enforced. Fortunately only platforms that support link types
// seem to have magic per-architecture implicit link directories.
@@ -1160,7 +1657,7 @@
}
// Check if this item is in an implicit link directory.
- std::string dir = cmSystemTools::GetFilenamePath(item);
+ std::string dir = cmSystemTools::GetFilenamePath(item.Value);
if (!cm::contains(this->ImplicitLinkDirs, dir)) {
// Only libraries in implicit link directories are converted to
// pathless items.
@@ -1169,7 +1666,7 @@
// Only apply the policy below if the library file is one that can
// be found by the linker.
- std::string file = cmSystemTools::GetFilenameName(item);
+ std::string file = cmSystemTools::GetFilenameName(item.Value);
if (!this->ExtractAnyLibraryName.find(file)) {
return false;
}
@@ -1179,10 +1676,10 @@
case cmPolicies::WARN:
if (this->CMP0060Warn) {
// Print the warning at most once for this item.
- std::string const& wid = "CMP0060-WARNING-GIVEN-" + item;
+ std::string const& wid = "CMP0060-WARNING-GIVEN-" + item.Value;
if (!this->CMakeInstance->GetPropertyAsBool(wid)) {
this->CMakeInstance->SetProperty(wid, "1");
- this->CMP0060WarnItems.insert(item);
+ this->CMP0060WarnItems.insert(item.Value);
}
}
CM_FALLTHROUGH;
@@ -1200,15 +1697,17 @@
// directory then just report the file name without the directory
// portion. This will allow the system linker to locate the proper
// library for the architecture at link time.
- this->AddUserItem(file, false);
+ LinkEntry fileEntry{ entry };
+ fileEntry.Item = file;
+ this->AddUserItem(fileEntry, false);
// Make sure the link directory ordering will find the library.
- this->OrderLinkerSearchPath->AddLinkLibrary(item);
+ this->OrderLinkerSearchPath->AddLinkLibrary(item.Value);
return true;
}
-void cmComputeLinkInformation::AddUserItem(BT<std::string> const& item,
+void cmComputeLinkInformation::AddUserItem(LinkEntry const& entry,
bool pathNotKnown)
{
// This is called to handle a link item that does not match a CMake
@@ -1219,8 +1718,10 @@
// foo ==> -lfoo
// libfoo.a ==> -Wl,-Bstatic -lfoo
- // Pass flags through untouched.
+ BT<std::string> const& item = entry.Item;
+
if (item.Value[0] == '-' || item.Value[0] == '$' || item.Value[0] == '`') {
+ // Pass flags through untouched.
// if this is a -l option then we might need to warn about
// CMP0003 so put it in OldUserFlagItems, if it is not a -l
// or -Wl,-l (-framework -pthread), then allow it without a
@@ -1305,9 +1806,20 @@
}
// Create an option to ask the linker to search for the library.
- std::string out = cmStrCat(this->LibLinkFlag, lib, this->LibLinkSuffix);
- this->Items.emplace_back(BT<std::string>(out, item.Backtrace),
- ItemIsPath::No);
+ auto out = cmStrCat(this->LibLinkFlag, lib, this->LibLinkSuffix);
+
+ if (entry.Feature != DEFAULT) {
+ auto const& feature = this->GetLibraryFeature(entry.Feature);
+ this->Items.emplace_back(
+ BT<std::string>(
+ feature.GetDecoratedItem(cmStrCat(lib, this->LibLinkSuffix),
+ item.Value, out, ItemIsPath::No),
+ item.Backtrace),
+ ItemIsPath::No);
+ } else {
+ this->Items.emplace_back(BT<std::string>(out, item.Backtrace),
+ ItemIsPath::No);
+ }
// Here we could try to find the library the linker will find and
// add a runtime information entry for it. It would probably not be
@@ -1315,10 +1827,14 @@
// specification.
}
-void cmComputeLinkInformation::AddFrameworkItem(std::string const& item)
+void cmComputeLinkInformation::AddFrameworkItem(LinkEntry const& entry)
{
+ std::string const& item = entry.Item.Value;
+
// Try to separate the framework name and path.
- if (!this->SplitFramework.find(item)) {
+ auto fwItems =
+ this->GlobalGenerator->SplitFrameworkPath(item, entry.Feature != DEFAULT);
+ if (!fwItems) {
std::ostringstream e;
e << "Could not parse framework path \"" << item << "\" "
<< "linked by target " << this->Target->GetName() << ".";
@@ -1326,26 +1842,36 @@
return;
}
- std::string fw_path = this->SplitFramework.match(1);
- std::string fw = this->SplitFramework.match(2);
- std::string full_fw = cmStrCat(fw_path, '/', fw, ".framework/", fw);
+ std::string fw_path = std::move(fwItems->first);
+ std::string fw = std::move(fwItems->second);
+ std::string full_fw = cmStrCat(fw, ".framework/", fw);
- // Add the directory portion to the framework search path.
- this->AddFrameworkPath(fw_path);
+ if (!fw_path.empty()) {
+ full_fw = cmStrCat(fw_path, '/', full_fw);
+ // Add the directory portion to the framework search path.
+ this->AddFrameworkPath(fw_path);
+ }
// add runtime information
this->AddLibraryRuntimeInfo(full_fw);
+ if (entry.Feature == DEFAULT) {
+ // ensure FRAMEWORK feature is loaded
+ this->AddLibraryFeature("FRAMEWORK");
+ }
+
if (this->GlobalGenerator->IsXcode()) {
// Add framework path - it will be handled by Xcode after it's added to
// "Link Binary With Libraries" build phase
- this->Items.emplace_back(item, ItemIsPath::Yes);
+ this->Items.emplace_back(item, ItemIsPath::Yes, nullptr,
+ this->FindLibraryFeature(entry.Feature == DEFAULT
+ ? "FRAMEWORK"
+ : entry.Feature));
} else {
- // Add the item using the -framework option.
- this->Items.emplace_back(std::string("-framework"), ItemIsPath::No);
- cmOutputConverter converter(this->Makefile->GetStateSnapshot());
- fw = converter.EscapeForShell(fw);
- this->Items.emplace_back(fw, ItemIsPath::No);
+ this->Items.emplace_back(fw, ItemIsPath::Yes, nullptr,
+ this->FindLibraryFeature(entry.Feature == DEFAULT
+ ? "FRAMEWORK"
+ : entry.Feature));
}
}
@@ -1355,10 +1881,10 @@
// user.
this->CMakeInstance->IssueMessage(
MessageType::WARNING,
- cmStrCat(
- "Target \"", this->Target->GetName(),
- "\" requests linking to directory \"", item.Value,
- "\". Targets may link only to libraries. CMake is dropping the item."),
+ cmStrCat("Target \"", this->Target->GetName(),
+ "\" requests linking to directory \"", item.Value,
+ "\". Targets may link only to libraries. CMake is dropping "
+ "the item."),
item.Backtrace);
}
@@ -1378,9 +1904,6 @@
this->FrameworkPathsEmitted.insert(implicitDirVec.begin(),
implicitDirVec.end());
-
- // Regular expression to extract a framework path and name.
- this->SplitFramework.compile("(.*)/(.*)\\.framework$");
}
void cmComputeLinkInformation::AddFrameworkPath(std::string const& p)
@@ -1390,42 +1913,44 @@
}
}
-bool cmComputeLinkInformation::CheckSharedLibNoSOName(std::string const& item)
+bool cmComputeLinkInformation::CheckSharedLibNoSOName(LinkEntry const& entry)
{
// This platform will use the path to a library as its soname if the
// library is given via path and was not built with an soname. If
// this is a shared library that might be the case.
- std::string file = cmSystemTools::GetFilenameName(item);
+ std::string file = cmSystemTools::GetFilenameName(entry.Item.Value);
if (this->ExtractSharedLibraryName.find(file)) {
// If we can guess the soname fairly reliably then assume the
// library has one. Otherwise assume the library has no builtin
// soname.
std::string soname;
- if (!cmSystemTools::GuessLibrarySOName(item, soname)) {
- this->AddSharedLibNoSOName(item);
+ if (!cmSystemTools::GuessLibrarySOName(entry.Item.Value, soname)) {
+ this->AddSharedLibNoSOName(entry);
return true;
}
}
return false;
}
-void cmComputeLinkInformation::AddSharedLibNoSOName(std::string const& item)
+void cmComputeLinkInformation::AddSharedLibNoSOName(LinkEntry const& entry)
{
// We have a full path to a shared library with no soname. We need
// to ask the linker to locate the item because otherwise the path
// we give to it will be embedded in the target linked. Then at
// runtime the dynamic linker will search for the library using the
// path instead of just the name.
- std::string file = cmSystemTools::GetFilenameName(item);
- this->AddUserItem(file, false);
+ LinkEntry fileEntry{ entry };
+ fileEntry.Item = cmSystemTools::GetFilenameName(entry.Item.Value);
+ this->AddUserItem(fileEntry, false);
// Make sure the link directory ordering will find the library.
- this->OrderLinkerSearchPath->AddLinkLibrary(item);
+ this->OrderLinkerSearchPath->AddLinkLibrary(entry.Item.Value);
}
-void cmComputeLinkInformation::HandleBadFullItem(std::string const& item,
+void cmComputeLinkInformation::HandleBadFullItem(LinkEntry const& entry,
std::string const& file)
{
+ std::string const& item = entry.Item.Value;
// Do not depend on things that do not exist.
auto i = std::find(this->Depends.begin(), this->Depends.end(), item);
if (i != this->Depends.end()) {
@@ -1435,7 +1960,9 @@
// Tell the linker to search for the item and provide the proper
// path for it. Do not contribute to any CMP0003 warning (do not
// put in OldLinkDirItems or OldUserFlagItems).
- this->AddUserItem(file, false);
+ LinkEntry fileEntry{ entry };
+ fileEntry.Item = file;
+ this->AddUserItem(fileEntry, false);
this->OrderLinkerSearchPath->AddLinkLibrary(item);
// Produce any needed message.
@@ -1781,8 +2308,8 @@
// Add directories explicitly specified by user
std::string build_rpath;
if (this->Target->GetBuildRPATH(this->Config, build_rpath)) {
- // This will not resolve entries to use $ORIGIN, the user is expected to
- // do that if necessary.
+ // This will not resolve entries to use $ORIGIN, the user is expected
+ // to do that if necessary.
cmCLI_ExpandListUnique(build_rpath, runtimeDirs, emitted);
}
}
diff --git a/Source/cmComputeLinkInformation.h b/Source/cmComputeLinkInformation.h
index 0315540..a4ada1f 100644
--- a/Source/cmComputeLinkInformation.h
+++ b/Source/cmComputeLinkInformation.h
@@ -5,6 +5,7 @@
#include "cmConfigure.h" // IWYU pragma: keep
#include <iosfwd>
+#include <map>
#include <memory>
#include <set>
#include <string>
@@ -13,6 +14,7 @@
#include "cmsys/RegularExpression.hxx"
+#include "cmComputeLinkDepends.h"
#include "cmListFileCache.h"
#include "cmValue.h"
@@ -27,6 +29,9 @@
*/
class cmComputeLinkInformation
{
+private:
+ class FeatureDescriptor;
+
public:
cmComputeLinkInformation(cmGeneratorTarget const* target,
const std::string& config);
@@ -42,28 +47,38 @@
Yes,
};
- enum class ItemIsObject
- {
- No,
- Yes,
- };
-
struct Item
{
- Item() = default;
Item(BT<std::string> v, ItemIsPath isPath,
- ItemIsObject isObject = ItemIsObject::No,
- cmGeneratorTarget const* target = nullptr)
+ cmGeneratorTarget const* target = nullptr,
+ FeatureDescriptor const* feature = nullptr)
: Value(std::move(v))
, IsPath(isPath)
- , IsObject(isObject)
, Target(target)
+ , Feature(feature)
{
}
BT<std::string> Value;
- ItemIsPath IsPath = ItemIsPath::Yes;
- ItemIsObject IsObject = ItemIsObject::No;
+ ItemIsPath IsPath = ItemIsPath::No;
cmGeneratorTarget const* Target = nullptr;
+
+ bool HasFeature() const { return this->Feature != nullptr; }
+ const std::string& GetFeatureName() const
+ {
+ return HasFeature() ? this->Feature->Name
+ : cmComputeLinkDepends::LinkEntry::DEFAULT;
+ }
+
+ BT<std::string> GetFormattedItem(std::string const& path) const
+ {
+ return { (this->Feature != nullptr)
+ ? this->Feature->GetDecoratedItem(path, this->IsPath)
+ : path,
+ Value.Backtrace };
+ }
+
+ private:
+ FeatureDescriptor const* Feature = nullptr;
};
using ItemVector = std::vector<Item>;
void AppendValues(std::string& result, std::vector<BT<std::string>>& values);
@@ -104,10 +119,10 @@
const cmGeneratorTarget* GetTarget() { return this->Target; }
private:
- void AddItem(BT<std::string> const& item, const cmGeneratorTarget* tgt,
- ItemIsObject isObject = ItemIsObject::No);
- void AddSharedDepItem(BT<std::string> const& item,
- cmGeneratorTarget const* tgt);
+ using LinkEntry = cmComputeLinkDepends::LinkEntry;
+
+ void AddItem(LinkEntry const& entry);
+ void AddSharedDepItem(LinkEntry const& entry);
void AddRuntimeDLL(cmGeneratorTarget const* tgt);
// Output information.
@@ -181,22 +196,20 @@
std::string NoCaseExpression(std::string const& str);
// Handling of link items.
- void AddTargetItem(BT<std::string> const& item,
- const cmGeneratorTarget* target);
- void AddFullItem(BT<std::string> const& item, ItemIsObject isObject);
- bool CheckImplicitDirItem(std::string const& item);
- void AddUserItem(BT<std::string> const& item, bool pathNotKnown);
- void AddFrameworkItem(std::string const& item);
+ void AddTargetItem(LinkEntry const& entry);
+ void AddFullItem(LinkEntry const& entry);
+ bool CheckImplicitDirItem(LinkEntry const& entry);
+ void AddUserItem(LinkEntry const& entry, bool pathNotKnown);
+ void AddFrameworkItem(LinkEntry const& entry);
void DropDirectoryItem(BT<std::string> const& item);
- bool CheckSharedLibNoSOName(std::string const& item);
- void AddSharedLibNoSOName(std::string const& item);
- void HandleBadFullItem(std::string const& item, std::string const& file);
+ bool CheckSharedLibNoSOName(LinkEntry const& entry);
+ void AddSharedLibNoSOName(LinkEntry const& entry);
+ void HandleBadFullItem(LinkEntry const& entry, std::string const& file);
// Framework info.
void ComputeFrameworkInfo();
void AddFrameworkPath(std::string const& p);
std::set<std::string> FrameworkPathsEmitted;
- cmsys::RegularExpression SplitFramework;
// Linker search path computation.
std::unique_ptr<cmOrderDirectories> OrderLinkerSearchPath;
@@ -237,4 +250,61 @@
void AddLibraryRuntimeInfo(std::string const& fullPath,
const cmGeneratorTarget* target);
void AddLibraryRuntimeInfo(std::string const& fullPath);
+
+ class FeatureDescriptor
+ {
+ public:
+ FeatureDescriptor() = default;
+
+ const std::string Name;
+ const bool Supported = false;
+ const std::string Prefix;
+ const std::string Suffix;
+ std::string GetDecoratedItem(std::string const& library,
+ ItemIsPath isPath) const;
+ std::string GetDecoratedItem(std::string const& library,
+ std::string const& linkItem,
+ std::string const& defaultValue,
+ ItemIsPath isPath) const;
+
+ protected:
+ FeatureDescriptor(std::string name, std::string itemFormat);
+ FeatureDescriptor(std::string name, std::string itemPathFormat,
+ std::string itemNameFormat);
+ FeatureDescriptor(std::string name, std::string prefix,
+ std::string itemPathFormat, std::string itemNameFormat,
+ std::string suffix);
+
+ FeatureDescriptor(std::string name, std::string prefix, std::string suffix,
+ bool isGroup);
+
+ private:
+ std::string ItemPathFormat;
+ std::string ItemNameFormat;
+ };
+
+ class LibraryFeatureDescriptor : public FeatureDescriptor
+ {
+ public:
+ LibraryFeatureDescriptor(std::string name, std::string itemFormat);
+ LibraryFeatureDescriptor(std::string name, std::string itemPathFormat,
+ std::string itemNameFormat);
+ LibraryFeatureDescriptor(std::string name, std::string prefix,
+ std::string itemPathFormat,
+ std::string itemNameFormat, std::string suffix);
+ };
+ std::map<std::string, FeatureDescriptor> LibraryFeatureDescriptors;
+ bool AddLibraryFeature(std::string const& feature);
+ FeatureDescriptor const& GetLibraryFeature(std::string const& feature) const;
+ FeatureDescriptor const* FindLibraryFeature(
+ std::string const& feature) const;
+
+ class GroupFeatureDescriptor : public FeatureDescriptor
+ {
+ public:
+ GroupFeatureDescriptor(std::string name, std::string prefix,
+ std::string suffix);
+ };
+ std::map<std::string, FeatureDescriptor> GroupFeatureDescriptors;
+ FeatureDescriptor const& GetGroupFeature(std::string const& feature);
};
diff --git a/Source/cmExportFileGenerator.cxx b/Source/cmExportFileGenerator.cxx
index b46b933..a21e614 100644
--- a/Source/cmExportFileGenerator.cxx
+++ b/Source/cmExportFileGenerator.cxx
@@ -934,13 +934,13 @@
// Isolate the file policy level.
// Support CMake versions as far back as 2.6 but also support using NEW
- // policy settings for up to CMake 3.21 (this upper limit may be reviewed
+ // policy settings for up to CMake 3.22 (this upper limit may be reviewed
// and increased from time to time). This reduces the opportunity for CMake
// warnings when an older export file is later used with newer CMake
// versions.
/* clang-format off */
os << "cmake_policy(PUSH)\n"
- << "cmake_policy(VERSION 2.6...3.21)\n";
+ << "cmake_policy(VERSION 2.6...3.22)\n";
/* clang-format on */
}
diff --git a/Source/cmFileCommand.cxx b/Source/cmFileCommand.cxx
index da2f15f..09e5015 100644
--- a/Source/cmFileCommand.cxx
+++ b/Source/cmFileCommand.cxx
@@ -15,6 +15,7 @@
#include <vector>
#include <cm/memory>
+#include <cm/optional>
#include <cm/string_view>
#include <cmext/algorithm>
#include <cmext/string_view>
@@ -1778,6 +1779,7 @@
std::string userpwd;
std::vector<std::string> curl_headers;
+ std::vector<std::pair<std::string, cm::optional<std::string>>> curl_ranges;
while (i != args.end()) {
if (*i == "TIMEOUT") {
@@ -1890,6 +1892,27 @@
return false;
}
curl_headers.push_back(*i);
+ } else if (*i == "RANGE_START") {
+ ++i;
+ if (i == args.end()) {
+ status.SetError("DOWNLOAD missing value for RANGE_START.");
+ return false;
+ }
+ curl_ranges.emplace_back(*i, cm::nullopt);
+ } else if (*i == "RANGE_END") {
+ ++i;
+ if (curl_ranges.empty()) {
+ curl_ranges.emplace_back("0", *i);
+ } else {
+ auto& last_range = curl_ranges.back();
+ if (!last_range.second.has_value()) {
+ last_range.second = *i;
+ } else {
+ status.SetError("Multiple RANGE_END values is provided without "
+ "the corresponding RANGE_START.");
+ return false;
+ }
+ }
} else if (file.empty()) {
file = *i;
} else {
@@ -1899,6 +1922,7 @@
}
++i;
}
+
// Can't calculate hash if we don't save the file.
// TODO Incrementally calculate hash in the write callback as the file is
// being downloaded so this check can be relaxed.
@@ -1984,6 +2008,13 @@
check_curl_result(res, "DOWNLOAD cannot set TLS/SSL Verify off: ");
}
+ for (const auto& range : curl_ranges) {
+ std::string curl_range = range.first + '-' +
+ (range.second.has_value() ? range.second.value() : "");
+ res = ::curl_easy_setopt(curl, CURLOPT_RANGE, curl_range.c_str());
+ check_curl_result(res, "DOWNLOAD cannot set range: ");
+ }
+
// check to see if a CAINFO file has been specified
// command arg comes first
std::string const& cainfo_err = cmCurlSetCAInfo(curl, cainfo);
diff --git a/Source/cmFindPackageCommand.cxx b/Source/cmFindPackageCommand.cxx
index f55d838..18457a7 100644
--- a/Source/cmFindPackageCommand.cxx
+++ b/Source/cmFindPackageCommand.cxx
@@ -262,6 +262,9 @@
} else if (args[i] == "EXACT") {
this->VersionExact = true;
doing = DoingNone;
+ } else if (args[i] == "GLOBAL") {
+ this->GlobalScope = true;
+ doing = DoingNone;
} else if (args[i] == "MODULE") {
moduleArgs.insert(i);
doing = DoingNone;
@@ -364,6 +367,12 @@
}
}
+ if (!this->GlobalScope) {
+ cmValue value(
+ this->Makefile->GetDefinition("CMAKE_FIND_PACKAGE_TARGETS_GLOBAL"));
+ this->GlobalScope = value.IsOn();
+ }
+
std::vector<std::string> doubledComponents;
std::set_intersection(requiredComponents.begin(), requiredComponents.end(),
optionalComponents.begin(), optionalComponents.end(),
@@ -1200,6 +1209,11 @@
PolicyScopeRule psr)
{
const bool noPolicyScope = !this->PolicyScope || psr == NoPolicyScope;
+
+ using ITScope = cmMakefile::ImportedTargetScope;
+ ITScope scope = this->GlobalScope ? ITScope::Global : ITScope::Local;
+ cmMakefile::SetGlobalTargetImportScope globScope(this->Makefile, scope);
+
if (this->Makefile->ReadDependentFile(f, noPolicyScope)) {
return true;
}
diff --git a/Source/cmFindPackageCommand.h b/Source/cmFindPackageCommand.h
index f921bb0..b9f19e4 100644
--- a/Source/cmFindPackageCommand.h
+++ b/Source/cmFindPackageCommand.h
@@ -199,6 +199,7 @@
bool UseLibx32Paths = false;
bool UseRealPath = false;
bool PolicyScope = true;
+ bool GlobalScope = false;
std::string LibraryArchitecture;
std::vector<std::string> Names;
std::vector<std::string> Configs;
diff --git a/Source/cmGeneratorExpressionDAGChecker.cxx b/Source/cmGeneratorExpressionDAGChecker.cxx
index d4b02a5..d35d428 100644
--- a/Source/cmGeneratorExpressionDAGChecker.cxx
+++ b/Source/cmGeneratorExpressionDAGChecker.cxx
@@ -167,7 +167,7 @@
cm::string_view property(this->Top()->Property);
return property == "LINK_DIRECTORIES"_s || property == "LINK_OPTIONS"_s ||
- property == "LINK_DEPENDS"_s;
+ property == "LINK_DEPENDS"_s || property == "LINK_LIBRARY_OVERRIDE"_s;
}
bool cmGeneratorExpressionDAGChecker::EvaluatingLinkOptionsExpression() const
diff --git a/Source/cmGeneratorExpressionNode.cxx b/Source/cmGeneratorExpressionNode.cxx
index 396e9c9..db043ec 100644
--- a/Source/cmGeneratorExpressionNode.cxx
+++ b/Source/cmGeneratorExpressionNode.cxx
@@ -1198,6 +1198,152 @@
}
} linkLanguageAndIdNode;
+static const struct LinkLibraryNode : public cmGeneratorExpressionNode
+{
+ LinkLibraryNode() {} // NOLINT(modernize-use-equals-default)
+
+ int NumExpectedParameters() const override { return OneOrMoreParameters; }
+
+ std::string Evaluate(
+ const std::vector<std::string>& parameters,
+ cmGeneratorExpressionContext* context,
+ const GeneratorExpressionContent* content,
+ cmGeneratorExpressionDAGChecker* dagChecker) const override
+ {
+ if (!context->HeadTarget || !dagChecker ||
+ !dagChecker->EvaluatingLinkLibraries()) {
+ reportError(context, content->GetOriginalExpression(),
+ "$<LINK_LIBRARY:...> may only be used with binary targets "
+ "to specify link libraries.");
+ return std::string();
+ }
+
+ std::vector<std::string> list;
+ cmExpandLists(parameters.begin(), parameters.end(), list);
+ if (list.empty()) {
+ reportError(
+ context, content->GetOriginalExpression(),
+ "$<LINK_LIBRARY:...> expects a feature name as first argument.");
+ return std::string();
+ }
+ if (list.size() == 1) {
+ // no libraries specified, ignore this genex
+ return std::string();
+ }
+
+ static cmsys::RegularExpression featureNameValidator("^[A-Za-z0-9_]+$");
+ auto const& feature = list.front();
+ if (!featureNameValidator.find(feature)) {
+ reportError(context, content->GetOriginalExpression(),
+ cmStrCat("The feature name '", feature,
+ "' contains invalid characters."));
+ return std::string();
+ }
+
+ const auto LL_BEGIN = cmStrCat("<LINK_LIBRARY:", feature, '>');
+ const auto LL_END = cmStrCat("</LINK_LIBRARY:", feature, '>');
+
+ // filter out $<LINK_LIBRARY:..> tags with same feature
+ // and raise an error for any different feature
+ cm::erase_if(list, [&](const std::string& item) -> bool {
+ return item == LL_BEGIN || item == LL_END;
+ });
+ auto it =
+ std::find_if(list.cbegin() + 1, list.cend(),
+ [&feature](const std::string& item) -> bool {
+ return cmHasPrefix(item, "<LINK_LIBRARY:"_s) &&
+ item.substr(14, item.find('>', 14) - 14) != feature;
+ });
+ if (it != list.cend()) {
+ reportError(
+ context, content->GetOriginalExpression(),
+ "$<LINK_LIBRARY:...> with different features cannot be nested.");
+ return std::string();
+ }
+ // $<LINK_GROUP:...> must not appear as part of $<LINK_LIBRARY:...>
+ it = std::find_if(list.cbegin() + 1, list.cend(),
+ [](const std::string& item) -> bool {
+ return cmHasPrefix(item, "<LINK_GROUP:"_s);
+ });
+ if (it != list.cend()) {
+ reportError(context, content->GetOriginalExpression(),
+ "$<LINK_GROUP:...> cannot be nested inside a "
+ "$<LINK_LIBRARY:...> expression.");
+ return std::string();
+ }
+
+ list.front() = LL_BEGIN;
+ list.push_back(LL_END);
+
+ return cmJoin(list, ";"_s);
+ }
+} linkLibraryNode;
+
+static const struct LinkGroupNode : public cmGeneratorExpressionNode
+{
+ LinkGroupNode() {} // NOLINT(modernize-use-equals-default)
+
+ int NumExpectedParameters() const override { return OneOrMoreParameters; }
+
+ std::string Evaluate(
+ const std::vector<std::string>& parameters,
+ cmGeneratorExpressionContext* context,
+ const GeneratorExpressionContent* content,
+ cmGeneratorExpressionDAGChecker* dagChecker) const override
+ {
+ if (!context->HeadTarget || !dagChecker ||
+ !dagChecker->EvaluatingLinkLibraries()) {
+ reportError(context, content->GetOriginalExpression(),
+ "$<LINK_GROUP:...> may only be used with binary targets "
+ "to specify group of link libraries.");
+ return std::string();
+ }
+
+ std::vector<std::string> list;
+ cmExpandLists(parameters.begin(), parameters.end(), list);
+ if (list.empty()) {
+ reportError(
+ context, content->GetOriginalExpression(),
+ "$<LINK_GROUP:...> expects a feature name as first argument.");
+ return std::string();
+ }
+ // $<LINK_GROUP:..> cannot be nested
+ if (std::find_if(list.cbegin(), list.cend(),
+ [](const std::string& item) -> bool {
+ return cmHasPrefix(item, "<LINK_GROUP"_s);
+ }) != list.cend()) {
+ reportError(context, content->GetOriginalExpression(),
+ "$<LINK_GROUP:...> cannot be nested.");
+ return std::string();
+ }
+ if (list.size() == 1) {
+ // no libraries specified, ignore this genex
+ return std::string();
+ }
+
+ static cmsys::RegularExpression featureNameValidator("^[A-Za-z0-9_]+$");
+ auto const& feature = list.front();
+ if (!featureNameValidator.find(feature)) {
+ reportError(context, content->GetOriginalExpression(),
+ cmStrCat("The feature name '", feature,
+ "' contains invalid characters."));
+ return std::string();
+ }
+
+ const auto LG_BEGIN = cmStrCat(
+ "<LINK_GROUP:", feature, ':',
+ cmJoin(cmRange<decltype(list.cbegin())>(list.cbegin() + 1, list.cend()),
+ "|"_s),
+ '>');
+ const auto LG_END = cmStrCat("</LINK_GROUP:", feature, '>');
+
+ list.front() = LG_BEGIN;
+ list.push_back(LG_END);
+
+ return cmJoin(list, ";"_s);
+ }
+} linkGroupNode;
+
static const struct HostLinkNode : public cmGeneratorExpressionNode
{
HostLinkNode() {} // NOLINT(modernize-use-equals-default)
@@ -2668,6 +2814,8 @@
{ "COMPILE_LANGUAGE", &languageNode },
{ "LINK_LANG_AND_ID", &linkLanguageAndIdNode },
{ "LINK_LANGUAGE", &linkLanguageNode },
+ { "LINK_LIBRARY", &linkLibraryNode },
+ { "LINK_GROUP", &linkGroupNode },
{ "HOST_LINK", &hostLinkNode },
{ "DEVICE_LINK", &deviceLinkNode },
{ "SHELL_PATH", &shellPathNode }
diff --git a/Source/cmGeneratorTarget.cxx b/Source/cmGeneratorTarget.cxx
index 63cf2ec..ab3ed12 100644
--- a/Source/cmGeneratorTarget.cxx
+++ b/Source/cmGeneratorTarget.cxx
@@ -2047,7 +2047,11 @@
} else if (ext == "appxmanifest") {
kind = SourceKindAppManifest;
} else if (ext == "manifest") {
- kind = SourceKindManifest;
+ if (sf->GetPropertyAsBool("VS_DEPLOYMENT_CONTENT")) {
+ kind = SourceKindExtra;
+ } else {
+ kind = SourceKindManifest;
+ }
} else if (ext == "pfx") {
kind = SourceKindCertificate;
} else if (ext == "xaml") {
@@ -3463,6 +3467,23 @@
property =
*this->Makefile->GetDefinition("CMAKE_CUDA_ARCHITECTURES_ALL_MAJOR");
}
+ } else if (property == "native") {
+ cmValue native =
+ this->Makefile->GetDefinition("CMAKE_CUDA_ARCHITECTURES_NATIVE");
+ if (native.IsEmpty()) {
+ this->Makefile->IssueMessage(
+ MessageType::FATAL_ERROR,
+ "CUDA_ARCHITECTURES is set to \"native\", but no GPU was detected.");
+ }
+ if (compiler == "NVIDIA" &&
+ cmSystemTools::VersionCompare(
+ cmSystemTools::OP_GREATER_EQUAL,
+ this->Makefile->GetDefinition("CMAKE_CUDA_COMPILER_VERSION"),
+ "11.6")) {
+ flags = cmStrCat(flags, " -arch=", property);
+ return;
+ }
+ property = *native;
}
struct CudaArchitecture
@@ -4623,7 +4644,8 @@
}
std::vector<BT<std::string>>& cmGeneratorTarget::ResolveLinkerWrapper(
- std::vector<BT<std::string>>& result, const std::string& language) const
+ std::vector<BT<std::string>>& result, const std::string& language,
+ bool joinItems) const
{
// replace "LINKER:" prefixed elements by actual linker wrapper
const std::string wrapper(this->Makefile->GetSafeDefinition(
@@ -4682,7 +4704,14 @@
std::vector<BT<std::string>> options = wrapOptions(
linkerOptions, bt, wrapperFlag, wrapperSep, concatFlagAndArgs);
- result.insert(entry, options.begin(), options.end());
+ if (joinItems) {
+ result.insert(entry,
+ cmJoin(cmRange<decltype(options.cbegin())>(
+ options.cbegin(), options.cend()),
+ " "_s));
+ } else {
+ result.insert(entry, options.begin(), options.end());
+ }
}
return result;
}
@@ -6329,7 +6358,8 @@
bool cmGeneratorTarget::VerifyLinkItemColons(LinkItemRole role,
cmLinkItem const& item) const
{
- if (item.Target || item.AsStr().find("::") == std::string::npos) {
+ if (item.Target || cmHasPrefix(item.AsStr(), "<LINK_GROUP:"_s) ||
+ item.AsStr().find("::") == std::string::npos) {
return true;
}
MessageType messageType = MessageType::FATAL_ERROR;
@@ -6375,7 +6405,9 @@
std::string const& str = item.AsStr();
if (!str.empty() &&
(str[0] == '-' || str[0] == '$' || str[0] == '`' ||
- str.find_first_of("/\\") != std::string::npos)) {
+ str.find_first_of("/\\") != std::string::npos ||
+ cmHasPrefix(str, "<LINK_LIBRARY:"_s) ||
+ cmHasPrefix(str, "<LINK_GROUP:"_s))) {
return true;
}
diff --git a/Source/cmGeneratorTarget.h b/Source/cmGeneratorTarget.h
index 45639c0..3e30913 100644
--- a/Source/cmGeneratorTarget.h
+++ b/Source/cmGeneratorTarget.h
@@ -513,7 +513,8 @@
std::string const& config, std::string const& language) const;
std::vector<BT<std::string>>& ResolveLinkerWrapper(
- std::vector<BT<std::string>>& result, const std::string& language) const;
+ std::vector<BT<std::string>>& result, const std::string& language,
+ bool joinItems = false) const;
void GetStaticLibraryLinkOptions(std::vector<std::string>& result,
const std::string& config,
diff --git a/Source/cmGhsMultiTargetGenerator.cxx b/Source/cmGhsMultiTargetGenerator.cxx
index 47cefae..a7796c9 100644
--- a/Source/cmGhsMultiTargetGenerator.cxx
+++ b/Source/cmGhsMultiTargetGenerator.cxx
@@ -36,11 +36,6 @@
static_cast<cmLocalGhsMultiGenerator*>(target->GetLocalGenerator()))
, Makefile(target->Target->GetMakefile())
, Name(target->GetName())
-#ifdef _WIN32
- , CmdWindowsShell(true)
-#else
- , CmdWindowsShell(false)
-#endif
{
// Store the configuration name that is being used
if (cmValue config = this->Makefile->GetDefinition("CMAKE_BUILD_TYPE")) {
@@ -112,12 +107,6 @@
return;
}
- // Tell the global generator the name of the project file
- this->GeneratorTarget->Target->SetProperty("GENERATOR_FILE_NAME",
- this->Name);
- this->GeneratorTarget->Target->SetProperty(
- "GENERATOR_FILE_NAME_EXT", GhsMultiGpj::GetGpjTag(this->TagType));
-
this->GenerateTarget();
}
@@ -126,7 +115,14 @@
// Open the target file in copy-if-different mode.
std::string fproj =
cmStrCat(this->LocalGenerator->GetCurrentBinaryDirectory(), '/',
- this->Name, cmGlobalGhsMultiGenerator::FILE_EXTENSION);
+ this->LocalGenerator->GetTargetDirectory(this->GeneratorTarget),
+ '/', this->Name, cmGlobalGhsMultiGenerator::FILE_EXTENSION);
+
+ // Tell the global generator the name of the project file
+ this->GeneratorTarget->Target->SetProperty("GENERATOR_FILE_NAME", fproj);
+ this->GeneratorTarget->Target->SetProperty(
+ "GENERATOR_FILE_NAME_EXT", GhsMultiGpj::GetGpjTag(this->TagType));
+
cmGeneratedFileStream fout(fproj);
fout.SetCopyIfDifferent(true);
@@ -160,10 +156,16 @@
{
std::string outpath;
+ /* Determine paths from the target project file to where the output artifacts
+ * need to be located.
+ */
if (this->TagType != GhsMultiGpj::SUBPROJECT) {
// set target binary file destination
- outpath = this->GeneratorTarget->GetDirectory(config);
- outpath = this->LocalGenerator->MaybeRelativeToCurBinDir(outpath);
+ std::string binpath = cmStrCat(
+ this->LocalGenerator->GetCurrentBinaryDirectory(), '/',
+ this->LocalGenerator->GetTargetDirectory(this->GeneratorTarget));
+ outpath = cmSystemTools::RelativePath(
+ binpath, this->GeneratorTarget->GetDirectory(config));
/* clang-format off */
fout << " :binDirRelative=\"" << outpath << "\"\n"
" -o \"" << this->TargetNameReal << "\"\n";
@@ -171,7 +173,7 @@
}
// set target object file destination
- outpath = this->LocalGenerator->GetTargetDirectory(this->GeneratorTarget);
+ outpath = ".";
fout << " :outputDirRelative=\"" << outpath << "\"\n";
}
@@ -187,6 +189,7 @@
language, config);
this->LocalGenerator->AddVisibilityPresetFlags(
flags, this->GeneratorTarget, language);
+ this->LocalGenerator->AddColorDiagnosticsFlags(flags, language);
// Append old-style preprocessor definition flags.
if (this->Makefile->GetDefineFlags() != " ") {
@@ -316,19 +319,37 @@
void cmGhsMultiTargetGenerator::WriteBuildEvents(std::ostream& fout)
{
- this->WriteBuildEventsHelper(
- fout, this->GeneratorTarget->GetPreBuildCommands(),
- std::string("prebuild"), std::string("preexecShell"));
+ this->WriteBuildEventsHelper(fout,
+ this->GeneratorTarget->GetPreBuildCommands(),
+ std::string("prebuild"),
+#ifdef _WIN32
+ std::string("preexecShell")
+#else
+ std::string("preexec")
+#endif
+ );
if (this->TagType != GhsMultiGpj::CUSTOM_TARGET) {
- this->WriteBuildEventsHelper(
- fout, this->GeneratorTarget->GetPreLinkCommands(),
- std::string("prelink"), std::string("preexecShell"));
+ this->WriteBuildEventsHelper(fout,
+ this->GeneratorTarget->GetPreLinkCommands(),
+ std::string("prelink"),
+#ifdef _WIN32
+ std::string("preexecShell")
+#else
+ std::string("preexec")
+#endif
+ );
}
- this->WriteBuildEventsHelper(
- fout, this->GeneratorTarget->GetPostBuildCommands(),
- std::string("postbuild"), std::string("postexecShell"));
+ this->WriteBuildEventsHelper(fout,
+ this->GeneratorTarget->GetPostBuildCommands(),
+ std::string("postbuild"),
+#ifdef _WIN32
+ std::string("postexecShell")
+#else
+ std::string("postexec")
+#endif
+ );
}
void cmGhsMultiTargetGenerator::WriteBuildEventsHelper(
@@ -336,6 +357,13 @@
std::string const& name, std::string const& cmd)
{
int cmdcount = 0;
+#ifdef _WIN32
+ std::string fext = ".bat";
+ std::string shell;
+#else
+ std::string fext = ".sh";
+ std::string shell = "/bin/sh ";
+#endif
for (cmCustomCommand const& cc : ccv) {
cmCustomCommandGenerator ccg(cc, this->ConfigName, this->LocalGenerator);
@@ -343,14 +371,14 @@
std::string fname =
cmStrCat(this->LocalGenerator->GetCurrentBinaryDirectory(), '/',
this->LocalGenerator->GetTargetDirectory(this->GeneratorTarget),
- '/', this->Name, '_', name, cmdcount++,
- this->CmdWindowsShell ? ".bat" : ".sh");
+ '/', this->Name, '_', name, cmdcount++, fext);
+
cmGeneratedFileStream f(fname);
f.SetCopyIfDifferent(true);
this->WriteCustomCommandsHelper(f, ccg);
f.Close();
if (this->TagType != GhsMultiGpj::CUSTOM_TARGET) {
- fout << " :" << cmd << "=\"" << fname << "\"\n";
+ fout << " :" << cmd << "=\"" << shell << fname << "\"\n";
} else {
fout << fname << "\n :outputName=\"" << fname << ".rule\"\n";
}
@@ -409,15 +437,15 @@
//
bool useCall = false;
- if (this->CmdWindowsShell) {
- std::string suffix;
- if (cmd.size() > 4) {
- suffix = cmSystemTools::LowerCase(cmd.substr(cmd.size() - 4));
- if (suffix == ".bat" || suffix == ".cmd") {
- useCall = true;
- }
+#ifdef _WIN32
+ std::string suffix;
+ if (cmd.size() > 4) {
+ suffix = cmSystemTools::LowerCase(cmd.substr(cmd.size() - 4));
+ if (suffix == ".bat" || suffix == ".cmd") {
+ useCall = true;
}
}
+#endif
cmSystemTools::ReplaceString(cmd, "/./", "/");
// Convert the command to a relative path only if the current
@@ -555,11 +583,12 @@
// Open the filestream in copy-if-different mode.
std::string gname = sg;
cmsys::SystemTools::ReplaceString(gname, "\\", "_");
- std::string lpath = cmStrCat(
- this->LocalGenerator->GetTargetDirectory(this->GeneratorTarget), '/',
- gname, cmGlobalGhsMultiGenerator::FILE_EXTENSION);
+ std::string lpath =
+ cmStrCat(gname, cmGlobalGhsMultiGenerator::FILE_EXTENSION);
std::string fpath = cmStrCat(
- this->LocalGenerator->GetCurrentBinaryDirectory(), '/', lpath);
+ this->LocalGenerator->GetCurrentBinaryDirectory(), '/',
+ this->LocalGenerator->GetTargetDirectory(this->GeneratorTarget), '/',
+ lpath);
cmGeneratedFileStream* f = new cmGeneratedFileStream(fpath);
f->SetCopyIfDifferent(true);
gfiles.push_back(f);
@@ -645,6 +674,11 @@
}
}
int cmdcount = 0;
+#ifdef _WIN32
+ std::string fext = ".bat";
+#else
+ std::string fext = ".sh";
+#endif
for (auto& sf : customCommands) {
const cmCustomCommand* cc = sf->GetCustomCommand();
cmCustomCommandGenerator ccg(*cc, this->ConfigName,
@@ -655,8 +689,8 @@
this->LocalGenerator->GetCurrentBinaryDirectory(), '/',
this->LocalGenerator->GetTargetDirectory(this->GeneratorTarget),
'/', this->Name, "_cc", cmdcount++, '_',
- (sf->GetLocation()).GetName(),
- this->CmdWindowsShell ? ".bat" : ".sh");
+ (sf->GetLocation()).GetName(), fext);
+
cmGeneratedFileStream f(fname);
f.SetCopyIfDifferent(true);
this->WriteCustomCommandsHelper(f, ccg);
diff --git a/Source/cmGhsMultiTargetGenerator.h b/Source/cmGhsMultiTargetGenerator.h
index e9d7537..9289a72 100644
--- a/Source/cmGhsMultiTargetGenerator.h
+++ b/Source/cmGhsMultiTargetGenerator.h
@@ -78,6 +78,5 @@
std::string TargetNameReal;
GhsMultiGpj::Types TagType;
std::string const Name;
- std::string ConfigName; /* CMAKE_BUILD_TYPE */
- bool const CmdWindowsShell; /* custom commands run in cmd.exe or /bin/sh */
+ std::string ConfigName; /* CMAKE_BUILD_TYPE */
};
diff --git a/Source/cmGlobalGenerator.cxx b/Source/cmGlobalGenerator.cxx
index 156ecce..baa54e5 100644
--- a/Source/cmGlobalGenerator.cxx
+++ b/Source/cmGlobalGenerator.cxx
@@ -19,6 +19,7 @@
#include "cmsys/Directory.hxx"
#include "cmsys/FStream.hxx"
+#include "cmsys/RegularExpression.hxx"
#if defined(_WIN32) && !defined(__CYGWIN__)
# include <windows.h>
@@ -2522,6 +2523,47 @@
return false;
}
+// If the file has no extension it's either a raw executable or might
+// be a direct reference to a binary within a framework (bad practice!).
+// This is where we change the path to point to the framework directory.
+// .tbd files also can be located in SDK frameworks (they are
+// placeholders for actual libraries shipped with the OS)
+cm::optional<std::pair<std::string, std::string>>
+cmGlobalGenerator::SplitFrameworkPath(const std::string& path,
+ bool extendedFormat) const
+{
+ // Check for framework structure:
+ // (/path/to/)?FwName.framework
+ // or (/path/to/)?FwName.framework/FwName(.tbd)?
+ // or (/path/to/)?FwName.framework/Versions/*/FwName(.tbd)?
+ static cmsys::RegularExpression frameworkPath(
+ "((.+)/)?(.+)\\.framework(/Versions/[^/]+)?(/(.+))?$");
+
+ auto ext = cmSystemTools::GetFilenameLastExtension(path);
+ if ((ext.empty() || ext == ".tbd" || ext == ".framework") &&
+ frameworkPath.find(path)) {
+ auto name = frameworkPath.match(3);
+ auto libname =
+ cmSystemTools::GetFilenameWithoutExtension(frameworkPath.match(6));
+ if (!libname.empty() && name != libname) {
+ return cm::nullopt;
+ }
+ return std::pair<std::string, std::string>{ frameworkPath.match(2), name };
+ }
+
+ if (extendedFormat) {
+ // path format can be more flexible: (/path/to/)?fwName(.framework)?
+ auto fwDir = cmSystemTools::GetParentDirectory(path);
+ auto name = cmSystemTools::GetFilenameLastExtension(path) == ".framework"
+ ? cmSystemTools::GetFilenameWithoutExtension(path)
+ : cmSystemTools::GetFilenameName(path);
+
+ return std::pair<std::string, std::string>{ fwDir, name };
+ }
+
+ return cm::nullopt;
+}
+
bool cmGlobalGenerator::CheckCMP0037(std::string const& targetName,
std::string const& reason) const
{
diff --git a/Source/cmGlobalGenerator.h b/Source/cmGlobalGenerator.h
index a43d4a6..a4b2ae3 100644
--- a/Source/cmGlobalGenerator.h
+++ b/Source/cmGlobalGenerator.h
@@ -367,6 +367,13 @@
/** Determine if a name resolves to a framework on disk or a built target
that is a framework. */
bool NameResolvesToFramework(const std::string& libname) const;
+ /** Split a framework path to the directory and name of the framework
+ * returns std::nullopt if the path does not match with framework format
+ * when extendedFormat is true, required format is relaxed (i.e. extension
+ * `.framework' is optional). Used when FRAMEWORK link feature is
+ * specified */
+ cm::optional<std::pair<std::string, std::string>> SplitFrameworkPath(
+ const std::string& path, bool extendedFormat = false) const;
cmMakefile* FindMakefile(const std::string& start_dir) const;
cmLocalGenerator* FindLocalGenerator(cmDirectoryId const& id) const;
diff --git a/Source/cmGlobalGhsMultiGenerator.cxx b/Source/cmGlobalGhsMultiGenerator.cxx
index 5e51dd2..f405a04 100644
--- a/Source/cmGlobalGhsMultiGenerator.cxx
+++ b/Source/cmGlobalGhsMultiGenerator.cxx
@@ -2,14 +2,19 @@
file Copyright.txt or https://cmake.org/licensing for details. */
#include "cmGlobalGhsMultiGenerator.h"
+#include <algorithm>
+#include <functional>
#include <map>
-#include <ostream>
+#include <sstream>
#include <utility>
#include <cm/memory>
#include <cm/string>
#include <cmext/algorithm>
+#include <cmext/memory>
+#include "cmCustomCommand.h"
+#include "cmCustomCommandLines.h"
#include "cmDocumentationEntry.h"
#include "cmGeneratedFileStream.h"
#include "cmGeneratorTarget.h"
@@ -18,10 +23,13 @@
#include "cmLocalGhsMultiGenerator.h"
#include "cmMakefile.h"
#include "cmMessageType.h"
+#include "cmPolicies.h"
+#include "cmSourceFile.h"
#include "cmState.h"
#include "cmStateTypes.h"
#include "cmStringAlgorithms.h"
#include "cmSystemTools.h"
+#include "cmTarget.h"
#include "cmValue.h"
#include "cmVersion.h"
#include "cmake.h"
@@ -32,6 +40,8 @@
#elif defined(_WIN32)
const char* cmGlobalGhsMultiGenerator::DEFAULT_BUILD_PROGRAM = "gbuild.exe";
#endif
+const char* cmGlobalGhsMultiGenerator::CHECK_BUILD_SYSTEM_TARGET =
+ "RERUN_CMAKE";
cmGlobalGhsMultiGenerator::cmGlobalGhsMultiGenerator(cmake* cm)
: cmGlobalGenerator(cm)
@@ -279,7 +289,7 @@
{
this->WriteFileHeader(fout);
this->WriteMacros(fout, root);
- this->WriteHighLevelDirectives(root, fout);
+ this->WriteHighLevelDirectives(fout, root);
GhsMultiGpj::WriteGpjTag(GhsMultiGpj::PROJECT, fout);
fout << "# Top Level Project File\n";
@@ -308,9 +318,13 @@
}
void cmGlobalGhsMultiGenerator::WriteSubProjects(std::ostream& fout,
- std::string& all_target)
+ bool filterPredefined)
{
- fout << "CMakeFiles/" << all_target << " [Project]\n";
+ std::set<std::string> predefinedTargets;
+ predefinedTargets.insert(this->GetInstallTargetName());
+ predefinedTargets.insert(this->GetAllTargetName());
+ predefinedTargets.insert(std::string(CHECK_BUILD_SYSTEM_TARGET));
+
// All known targets
for (cmGeneratorTarget const* target : this->ProjectTargets) {
if (target->GetType() == cmStateEnums::INTERFACE_LIBRARY ||
@@ -320,8 +334,13 @@
target->GetName() != this->GetInstallTargetName())) {
continue;
}
- fout << "CMakeFiles/" << target->GetName() + ".tgt" + FILE_EXTENSION
- << " [Project]\n";
+ /* Check if the current target is a predefined CMake target */
+ bool predefinedTarget =
+ predefinedTargets.find(target->GetName()) != predefinedTargets.end();
+ if ((filterPredefined && predefinedTarget) ||
+ (!filterPredefined && !predefinedTarget)) {
+ fout << target->GetName() + ".tgt" + FILE_EXTENSION << " [Project]\n";
+ }
}
}
@@ -329,36 +348,22 @@
std::ostream& fout, cmGeneratorTarget const* target,
std::string& rootBinaryDir)
{
- cmValue projName = target->GetProperty("GENERATOR_FILE_NAME");
+ cmValue projFile = target->GetProperty("GENERATOR_FILE_NAME");
cmValue projType = target->GetProperty("GENERATOR_FILE_NAME_EXT");
- if (projName && projType) {
- cmLocalGenerator* lg = target->GetLocalGenerator();
- std::string dir = lg->GetCurrentBinaryDirectory();
- dir = cmSystemTools::ForceToRelativePath(rootBinaryDir, dir);
- if (dir == ".") {
- dir.clear();
- } else {
- if (dir.back() != '/') {
- dir += "/";
- }
- }
+ /* If either value is not valid then this particular target is an
+ * unsupported target type and should be skipped.
+ */
+ if (projFile && projType) {
+ std::string path = cmSystemTools::RelativePath(rootBinaryDir, projFile);
- std::string projFile = dir + *projName + FILE_EXTENSION;
- fout << projFile;
+ fout << path;
fout << ' ' << *projType << '\n';
- } else {
- /* Should never happen */
- std::string message =
- "The project file for target [" + target->GetName() + "] is missing.\n";
- cmSystemTools::Error(message);
- fout << "{comment} " << target->GetName() << " [missing project file]\n";
}
}
void cmGlobalGhsMultiGenerator::WriteTargets(cmLocalGenerator* root)
{
- std::string rootBinaryDir =
- cmStrCat(root->GetCurrentBinaryDirectory(), "/CMakeFiles");
+ std::string rootBinaryDir = root->GetCurrentBinaryDirectory();
// All known targets
for (cmGeneratorTarget const* target : this->ProjectTargets) {
@@ -391,62 +396,6 @@
}
}
-void cmGlobalGhsMultiGenerator::WriteAllTarget(
- cmLocalGenerator* root, std::vector<cmLocalGenerator*>& generators,
- std::string& all_target)
-{
- this->ProjectTargets.clear();
-
- // create target build file
- all_target = root->GetProjectName() + "." + this->GetAllTargetName() +
- ".tgt" + FILE_EXTENSION;
- std::string fname =
- root->GetCurrentBinaryDirectory() + "/CMakeFiles/" + all_target;
- cmGeneratedFileStream fbld(fname);
- fbld.SetCopyIfDifferent(true);
- this->WriteFileHeader(fbld);
- GhsMultiGpj::WriteGpjTag(GhsMultiGpj::PROJECT, fbld);
-
- // Collect all targets under this root generator and the transitive
- // closure of their dependencies.
- TargetDependSet projectTargets;
- TargetDependSet originalTargets;
- this->GetTargetSets(projectTargets, originalTargets, root, generators);
- OrderedTargetDependSet sortedProjectTargets(projectTargets, "");
- std::vector<cmGeneratorTarget const*> defaultTargets;
- for (cmGeneratorTarget const* t : sortedProjectTargets) {
- /* save list of all targets in sorted order */
- this->ProjectTargets.push_back(t);
- }
- for (cmGeneratorTarget const* t : sortedProjectTargets) {
- if (!t->IsInBuildSystem()) {
- continue;
- }
- if (!this->IsExcluded(t->GetLocalGenerator(), t)) {
- defaultTargets.push_back(t);
- }
- }
- std::vector<cmGeneratorTarget const*> build;
- if (this->ComputeTargetBuildOrder(defaultTargets, build)) {
- std::string message = "The inter-target dependency graph for project [" +
- root->GetProjectName() + "] had a cycle.\n";
- cmSystemTools::Error(message);
- } else {
- // determine the targets for ALL target
- std::string rootBinaryDir =
- cmStrCat(root->GetCurrentBinaryDirectory(), "/CMakeFiles");
- for (cmGeneratorTarget const* target : build) {
- if (target->GetType() == cmStateEnums::INTERFACE_LIBRARY ||
- target->GetType() == cmStateEnums::MODULE_LIBRARY ||
- target->GetType() == cmStateEnums::SHARED_LIBRARY) {
- continue;
- }
- this->WriteProjectLine(fbld, target, rootBinaryDir);
- }
- }
- fbld.Close();
-}
-
void cmGlobalGhsMultiGenerator::Generate()
{
std::string fname;
@@ -476,18 +425,36 @@
this->WriteFileHeader(ftarget);
this->WriteCustomTargetBOD(ftarget);
ftarget.Close();
+
+ // create the stamp file when running CMake
+ if (!this->StampFile.empty()) {
+ cmGeneratedFileStream fstamp(this->StampFile);
+ fstamp.SetCopyIfDifferent(false);
+ fstamp.Close();
+ }
}
void cmGlobalGhsMultiGenerator::OutputTopLevelProject(
cmLocalGenerator* root, std::vector<cmLocalGenerator*>& generators)
{
std::string fname;
- std::string all_target;
if (generators.empty()) {
return;
}
+ // Collect all targets under this root generator and the transitive
+ // closure of their dependencies.
+ TargetDependSet projectTargets;
+ TargetDependSet originalTargets;
+ this->GetTargetSets(projectTargets, originalTargets, root, generators);
+ OrderedTargetDependSet sortedProjectTargets(projectTargets, "");
+ this->ProjectTargets.clear();
+ for (cmGeneratorTarget const* t : sortedProjectTargets) {
+ /* save list of all targets in sorted order */
+ this->ProjectTargets.push_back(t);
+ }
+
/* Name top-level projects as filename.top.gpj to avoid name clashes
* with target projects. This avoid the issue where the project has
* the same name as the executable target.
@@ -498,11 +465,9 @@
cmGeneratedFileStream top(fname);
top.SetCopyIfDifferent(true);
this->WriteTopLevelProject(top, root);
-
- this->WriteAllTarget(root, generators, all_target);
this->WriteTargets(root);
-
- this->WriteSubProjects(top, all_target);
+ this->WriteSubProjects(top, true);
+ this->WriteSubProjects(top, false);
top.Close();
}
@@ -510,59 +475,62 @@
cmGlobalGhsMultiGenerator::GenerateBuildCommand(
const std::string& makeProgram, const std::string& projectName,
const std::string& projectDir, std::vector<std::string> const& targetNames,
- const std::string& /*config*/, int jobs, bool /*verbose*/,
+ const std::string& /*config*/, int jobs, bool verbose,
const cmBuildOptions& /*buildOptions*/,
std::vector<std::string> const& makeOptions)
{
- GeneratedMakeCommand makeCommand = {};
- std::string gbuild;
- if (cmValue gbuildCached =
- this->CMakeInstance->GetCacheDefinition("CMAKE_MAKE_PROGRAM")) {
- gbuild = *gbuildCached;
- }
- makeCommand.Add(this->SelectMakeProgram(makeProgram, gbuild));
+ GeneratedMakeCommand makeCommand;
+
+ makeCommand.Add(this->SelectMakeProgram(makeProgram));
if (jobs != cmake::NO_BUILD_PARALLEL_LEVEL) {
- makeCommand.Add("-parallel");
- if (jobs != cmake::DEFAULT_BUILD_PARALLEL_LEVEL) {
- makeCommand.Add(std::to_string(jobs));
+ if (jobs == cmake::DEFAULT_BUILD_PARALLEL_LEVEL) {
+ makeCommand.Add("-parallel");
+ } else {
+ makeCommand.Add(std::string("-parallel=") + std::to_string(jobs));
}
}
- makeCommand.Add(makeOptions.begin(), makeOptions.end());
-
- /* determine which top-project file to use */
+ /* determine the top-project file in the project directory */
std::string proj = projectName + ".top" + FILE_EXTENSION;
std::vector<std::string> files;
cmSystemTools::Glob(projectDir, ".*\\.top\\.gpj", files);
if (!files.empty()) {
- /* if multiple top-projects are found in build directory
- * then prefer projectName top-project.
- */
- if (!cm::contains(files, proj)) {
- proj = files.at(0);
- }
+ /* use the real top-level project in the directory */
+ proj = files.at(0);
}
-
makeCommand.Add("-top", proj);
+
+ /* determine targets to build */
+ bool build_all = false;
if (!targetNames.empty()) {
- if (cm::contains(targetNames, "clean")) {
- makeCommand.Add("-clean");
- } else {
- for (const auto& tname : targetNames) {
- if (!tname.empty()) {
+ for (const auto& tname : targetNames) {
+ if (!tname.empty()) {
+ if (tname == "clean") {
+ makeCommand.Add("-clean");
+ } else {
makeCommand.Add(tname + ".tgt.gpj");
}
+ } else {
+ build_all = true;
}
}
} else {
+ build_all = true;
+ }
+
+ if (build_all) {
/* transform name to default build */;
- std::string all = proj;
- all.replace(all.end() - 7, all.end(),
- std::string(this->GetAllTargetName()) + ".tgt.gpj");
+ std::string all = std::string(this->GetAllTargetName()) + ".tgt.gpj";
makeCommand.Add(all);
}
- return { makeCommand };
+
+ if (verbose) {
+ makeCommand.Add("-commands");
+ }
+ makeCommand.Add(makeOptions.begin(), makeOptions.end());
+
+ return { std::move(makeCommand) };
}
void cmGlobalGhsMultiGenerator::WriteMacros(std::ostream& fout,
@@ -579,7 +547,7 @@
}
void cmGlobalGhsMultiGenerator::WriteHighLevelDirectives(
- cmLocalGenerator* root, std::ostream& fout)
+ std::ostream& fout, cmLocalGenerator* root)
{
/* put primary target and customization files into project file */
cmValue const tgt = root->GetMakefile()->GetDefinition("GHS_PRIMARY_TARGET");
@@ -681,3 +649,147 @@
/* already complete */
return false;
}
+
+bool cmGlobalGhsMultiGenerator::AddCheckTarget()
+{
+ // Skip the target if no regeneration is to be done.
+ if (this->GlobalSettingIsOn("CMAKE_SUPPRESS_REGENERATION")) {
+ return false;
+ }
+
+ // Get the generators.
+ std::vector<std::unique_ptr<cmLocalGenerator>> const& generators =
+ this->LocalGenerators;
+ auto& lg =
+ cm::static_reference_cast<cmLocalGhsMultiGenerator>(generators[0]);
+
+ // The name of the output file for the custom command.
+ this->StampFile = lg.GetBinaryDirectory() + std::string("/CMakeFiles/") +
+ CHECK_BUILD_SYSTEM_TARGET;
+
+ // Add a custom rule to re-run CMake if any input files changed.
+ {
+ // Collect the input files used to generate all targets in this
+ // project.
+ std::vector<std::string> listFiles;
+ for (const auto& gen : generators) {
+ cm::append(listFiles, gen->GetMakefile()->GetListFiles());
+ }
+
+ // Add the cache file.
+ listFiles.push_back(cmStrCat(
+ this->GetCMakeInstance()->GetHomeOutputDirectory(), "/CMakeCache.txt"));
+
+ // Print not implemented warning.
+ if (this->GetCMakeInstance()->DoWriteGlobVerifyTarget()) {
+ std::ostringstream msg;
+ msg << "Any pre-check scripts, such as those generated for file(GLOB "
+ "CONFIGURE_DEPENDS), will not be run by gbuild.";
+ this->GetCMakeInstance()->IssueMessage(MessageType::AUTHOR_WARNING,
+ msg.str());
+ }
+
+ // Sort the list of input files and remove duplicates.
+ std::sort(listFiles.begin(), listFiles.end(), std::less<std::string>());
+ auto newEnd = std::unique(listFiles.begin(), listFiles.end());
+ listFiles.erase(newEnd, listFiles.end());
+
+ // Create a rule to re-run CMake and create output file.
+ std::string argS = cmStrCat("-S", lg.GetSourceDirectory());
+ std::string argB = cmStrCat("-B", lg.GetBinaryDirectory());
+ cmCustomCommandLines commandLines = cmMakeSingleCommandLine(
+ { cmSystemTools::GetCMakeCommand(), argS, argB });
+
+ /* Create the target(Exclude from ALL_BUILD).
+ *
+ * The build tool, currently, does not support rereading the project files
+ * if they get updated. So do not run this target as part of ALL_BUILD.
+ */
+ auto cc = cm::make_unique<cmCustomCommand>();
+ cmTarget* tgt =
+ lg.AddUtilityCommand(CHECK_BUILD_SYSTEM_TARGET, true, std::move(cc));
+ auto ptr = cm::make_unique<cmGeneratorTarget>(tgt, &lg);
+ auto* gt = ptr.get();
+ lg.AddGeneratorTarget(std::move(ptr));
+
+ // Add the rule.
+ cc = cm::make_unique<cmCustomCommand>();
+ cc->SetOutputs(this->StampFile);
+ cc->SetDepends(listFiles);
+ cc->SetCommandLines(commandLines);
+ cc->SetComment("Checking Build System");
+ cc->SetCMP0116Status(cmPolicies::NEW);
+ cc->SetEscapeOldStyle(false);
+ cc->SetStdPipesUTF8(true);
+
+ if (cmSourceFile* file =
+ lg.AddCustomCommandToOutput(std::move(cc), true)) {
+ gt->AddSource(file->ResolveFullPath());
+ } else {
+ cmSystemTools::Error("Error adding rule for " + this->StampFile);
+ }
+ // Organize in the "predefined targets" folder:
+ if (this->UseFolderProperty()) {
+ tgt->SetProperty("FOLDER", this->GetPredefinedTargetsFolder());
+ }
+ }
+
+ return true;
+}
+
+void cmGlobalGhsMultiGenerator::AddAllTarget()
+{
+ // Add a special target that depends on ALL projects for easy build
+ // of one configuration only.
+ for (auto const& it : this->ProjectMap) {
+ std::vector<cmLocalGenerator*> const& gen = it.second;
+ // add the ALL_BUILD to the first local generator of each project
+ if (!gen.empty()) {
+ // Use no actual command lines so that the target itself is not
+ // considered always out of date.
+ auto cc = cm::make_unique<cmCustomCommand>();
+ cc->SetCMP0116Status(cmPolicies::NEW);
+ cc->SetEscapeOldStyle(false);
+ cc->SetComment("Build all projects");
+ cmTarget* allBuild = gen[0]->AddUtilityCommand(this->GetAllTargetName(),
+ true, std::move(cc));
+
+ gen[0]->AddGeneratorTarget(
+ cm::make_unique<cmGeneratorTarget>(allBuild, gen[0]));
+
+ // Organize in the "predefined targets" folder:
+ if (this->UseFolderProperty()) {
+ allBuild->SetProperty("FOLDER", this->GetPredefinedTargetsFolder());
+ }
+
+ // Now make all targets depend on the ALL_BUILD target
+ for (cmLocalGenerator const* i : gen) {
+ for (const auto& tgt : i->GetGeneratorTargets()) {
+ // Skip global or imported targets
+ if (tgt->GetType() == cmStateEnums::GLOBAL_TARGET ||
+ tgt->IsImported()) {
+ continue;
+ }
+ // Skip Exclude From All Targets
+ if (!this->IsExcluded(gen[0], tgt.get())) {
+ allBuild->AddUtility(tgt->GetName(), false);
+ }
+ }
+ }
+ }
+ }
+}
+
+void cmGlobalGhsMultiGenerator::AddExtraIDETargets()
+{
+ // Add a special target that depends on ALL projects.
+ this->AddAllTarget();
+
+ /* Add Custom Target to check if CMake needs to be rerun.
+ *
+ * The build tool, currently, does not support rereading the project files
+ * if they get updated. So do not make the other targets dependent on this
+ * check.
+ */
+ this->AddCheckTarget();
+}
diff --git a/Source/cmGlobalGhsMultiGenerator.h b/Source/cmGlobalGhsMultiGenerator.h
index 26ea3c7..aa68d3b 100644
--- a/Source/cmGlobalGhsMultiGenerator.h
+++ b/Source/cmGlobalGhsMultiGenerator.h
@@ -81,8 +81,6 @@
// Write the common disclaimer text at the top of each build file.
void WriteFileHeader(std::ostream& fout);
- const char* GetInstallTargetName() const override { return "install"; }
-
protected:
void Generate() override;
std::vector<GeneratedMakeCommand> GenerateBuildCommand(
@@ -92,6 +90,7 @@
const cmBuildOptions& buildOptions = cmBuildOptions(),
std::vector<std::string> const& makeOptions =
std::vector<std::string>()) override;
+ void AddExtraIDETargets() override;
private:
void GetToolset(cmMakefile* mf, std::string& tsd, const std::string& ts);
@@ -101,20 +100,21 @@
std::vector<cmLocalGenerator*>& generators);
void WriteTopLevelProject(std::ostream& fout, cmLocalGenerator* root);
void WriteMacros(std::ostream& fout, cmLocalGenerator* root);
- void WriteHighLevelDirectives(cmLocalGenerator* root, std::ostream& fout);
- void WriteSubProjects(std::ostream& fout, std::string& all_target);
+ void WriteHighLevelDirectives(std::ostream& fout, cmLocalGenerator* root);
+ void WriteSubProjects(std::ostream& fout, bool filterPredefined);
void WriteTargets(cmLocalGenerator* root);
void WriteProjectLine(std::ostream& fout, cmGeneratorTarget const* target,
std::string& rootBinaryDir);
void WriteCustomRuleBOD(std::ostream& fout);
void WriteCustomTargetBOD(std::ostream& fout);
- void WriteAllTarget(cmLocalGenerator* root,
- std::vector<cmLocalGenerator*>& generators,
- std::string& all_target);
+ bool AddCheckTarget();
+ void AddAllTarget();
+ std::string StampFile;
static std::string TrimQuotes(std::string str);
static const char* DEFAULT_BUILD_PROGRAM;
+ static const char* CHECK_BUILD_SYSTEM_TARGET;
bool ComputeTargetBuildOrder(cmGeneratorTarget const* tgt,
std::vector<cmGeneratorTarget const*>& build);
diff --git a/Source/cmGlobalNinjaGenerator.cxx b/Source/cmGlobalNinjaGenerator.cxx
index 4245037..bbc9c54 100644
--- a/Source/cmGlobalNinjaGenerator.cxx
+++ b/Source/cmGlobalNinjaGenerator.cxx
@@ -2495,8 +2495,7 @@
snapshot.GetDirectory().SetCurrentBinary(dir_cur_bld);
auto mfd = cm::make_unique<cmMakefile>(this, snapshot);
auto lgd = this->CreateLocalGenerator(mfd.get());
- lgd->SetRelativePathTopSource(dir_top_src);
- lgd->SetRelativePathTopBinary(dir_top_bld);
+ lgd->SetRelativePathTop(dir_top_src, dir_top_bld);
this->Makefiles.push_back(std::move(mfd));
this->LocalGenerators.push_back(std::move(lgd));
}
diff --git a/Source/cmGlobalVisualStudio10Generator.cxx b/Source/cmGlobalVisualStudio10Generator.cxx
index db54b86..35448ee 100644
--- a/Source/cmGlobalVisualStudio10Generator.cxx
+++ b/Source/cmGlobalVisualStudio10Generator.cxx
@@ -1286,6 +1286,14 @@
return makeCommands;
}
+bool cmGlobalVisualStudio10Generator::IsInSolution(
+ const cmGeneratorTarget* gt) const
+{
+ return gt->IsInBuildSystem() &&
+ !(this->Version >= cmGlobalVisualStudioGenerator::VSVersion::VS16 &&
+ gt->GetName() == CMAKE_CHECK_BUILD_SYSTEM_TARGET);
+}
+
bool cmGlobalVisualStudio10Generator::Find64BitTools(cmMakefile* mf)
{
if (this->DefaultPlatformToolset == "v100") {
diff --git a/Source/cmGlobalVisualStudio10Generator.h b/Source/cmGlobalVisualStudio10Generator.h
index 4977a84..2203f71 100644
--- a/Source/cmGlobalVisualStudio10Generator.h
+++ b/Source/cmGlobalVisualStudio10Generator.h
@@ -118,6 +118,8 @@
return this->WindowsTargetPlatformVersion;
}
+ bool IsInSolution(const cmGeneratorTarget* gt) const override;
+
/** Return true if building for WindowsCE */
bool TargetsWindowsCE() const override { return this->SystemIsWindowsCE; }
diff --git a/Source/cmGlobalVisualStudio7Generator.cxx b/Source/cmGlobalVisualStudio7Generator.cxx
index 134937e..1c10fb3 100644
--- a/Source/cmGlobalVisualStudio7Generator.cxx
+++ b/Source/cmGlobalVisualStudio7Generator.cxx
@@ -359,7 +359,7 @@
// loop over again and write out configurations for each target
// in the solution
for (cmGeneratorTarget const* target : projectTargets) {
- if (!target->IsInBuildSystem()) {
+ if (!this->IsInSolution(target)) {
continue;
}
cmValue expath = target->GetProperty("EXTERNAL_MSPROJECT");
@@ -396,7 +396,7 @@
VisualStudioFolders.clear();
for (cmGeneratorTarget const* target : projectTargets) {
- if (!target->IsInBuildSystem()) {
+ if (!this->IsInSolution(target)) {
continue;
}
bool written = false;
@@ -458,22 +458,6 @@
}
}
-void cmGlobalVisualStudio7Generator::WriteTargetDepends(
- std::ostream& fout, OrderedTargetDependSet const& projectTargets)
-{
- for (cmGeneratorTarget const* target : projectTargets) {
- if (!target->IsInBuildSystem()) {
- continue;
- }
- cmValue vcprojName = target->GetProperty("GENERATOR_FILE_NAME");
- if (vcprojName) {
- std::string dir =
- target->GetLocalGenerator()->GetCurrentSourceDirectory();
- this->WriteProjectDepends(fout, *vcprojName, dir, target);
- }
- }
-}
-
void cmGlobalVisualStudio7Generator::WriteFolders(std::ostream& fout)
{
cm::string_view const prefix = "CMAKE_FOLDER_GUID_";
diff --git a/Source/cmGlobalVisualStudio7Generator.h b/Source/cmGlobalVisualStudio7Generator.h
index 33f1063..a55cf45 100644
--- a/Source/cmGlobalVisualStudio7Generator.h
+++ b/Source/cmGlobalVisualStudio7Generator.h
@@ -148,8 +148,6 @@
virtual void WriteTargetsToSolution(
std::ostream& fout, cmLocalGenerator* root,
OrderedTargetDependSet const& projectTargets);
- virtual void WriteTargetDepends(
- std::ostream& fout, OrderedTargetDependSet const& projectTargets);
virtual void WriteTargetConfigurations(
std::ostream& fout, std::vector<std::string> const& configs,
OrderedTargetDependSet const& projectTargets);
diff --git a/Source/cmGlobalVisualStudio8Generator.cxx b/Source/cmGlobalVisualStudio8Generator.cxx
index dbd2de9..323ee67 100644
--- a/Source/cmGlobalVisualStudio8Generator.cxx
+++ b/Source/cmGlobalVisualStudio8Generator.cxx
@@ -392,7 +392,7 @@
TargetDependSet const& unordered = this->GetTargetDirectDepends(gt);
OrderedTargetDependSet depends(unordered, std::string());
for (cmTargetDepend const& i : depends) {
- if (!i->IsInBuildSystem()) {
+ if (!this->IsInSolution(i)) {
continue;
}
std::string guid = this->GetGUID(i->GetName());
diff --git a/Source/cmGlobalVisualStudioGenerator.cxx b/Source/cmGlobalVisualStudioGenerator.cxx
index 141b5eb..cddaaa4 100644
--- a/Source/cmGlobalVisualStudioGenerator.cxx
+++ b/Source/cmGlobalVisualStudioGenerator.cxx
@@ -837,6 +837,12 @@
return languages.size() == 1 && *languages.begin() == "Fortran";
}
+bool cmGlobalVisualStudioGenerator::IsInSolution(
+ const cmGeneratorTarget* gt) const
+{
+ return gt->IsInBuildSystem();
+}
+
bool cmGlobalVisualStudioGenerator::TargetCompare::operator()(
cmGeneratorTarget const* l, cmGeneratorTarget const* r) const
{
diff --git a/Source/cmGlobalVisualStudioGenerator.h b/Source/cmGlobalVisualStudioGenerator.h
index cb1b14b..4f5f100 100644
--- a/Source/cmGlobalVisualStudioGenerator.h
+++ b/Source/cmGlobalVisualStudioGenerator.h
@@ -98,6 +98,9 @@
// return true if target is fortran only
bool TargetIsFortranOnly(const cmGeneratorTarget* gt);
+ // return true if target should be included in solution.
+ virtual bool IsInSolution(const cmGeneratorTarget* gt) const;
+
/** Get the top-level registry key for this VS version. */
std::string GetRegistryBase();
diff --git a/Source/cmGlobalXCodeGenerator.cxx b/Source/cmGlobalXCodeGenerator.cxx
index 203addd..1e6624e 100644
--- a/Source/cmGlobalXCodeGenerator.cxx
+++ b/Source/cmGlobalXCodeGenerator.cxx
@@ -1154,47 +1154,25 @@
return sourcecode;
}
-// If the file has no extension it's either a raw executable or might
-// be a direct reference to a binary within a framework (bad practice!).
-// This is where we change the path to point to the framework directory.
-// .tbd files also can be located in SDK frameworks (they are
-// placeholders for actual libraries shipped with the OS)
-std::string GetLibraryOrFrameworkPath(const std::string& path)
+} // anonymous
+
+// Extracts the framework directory, if path matches the framework syntax
+// otherwise returns the path untouched
+std::string cmGlobalXCodeGenerator::GetLibraryOrFrameworkPath(
+ const std::string& path) const
{
- auto ext = cmSystemTools::GetFilenameLastExtension(path);
- if (ext.empty() || ext == ".tbd") {
- auto name = cmSystemTools::GetFilenameWithoutExtension(path);
- // Check for iOS framework structure:
- // FwName.framework/FwName (and also on macOS where FwName lib is a
- // symlink)
- auto parentDir = cmSystemTools::GetParentDirectory(path);
- auto parentName = cmSystemTools::GetFilenameWithoutExtension(parentDir);
- ext = cmSystemTools::GetFilenameLastExtension(parentDir);
- if (ext == ".framework" && name == parentName) {
- return parentDir;
- }
- // Check for macOS framework structure:
- // FwName.framework/Versions/*/FwName
- std::vector<std::string> components;
- cmSystemTools::SplitPath(path, components);
- if (components.size() > 3 &&
- components[components.size() - 3] == "Versions") {
- ext = cmSystemTools::GetFilenameLastExtension(
- components[components.size() - 4]);
- parentName = cmSystemTools::GetFilenameWithoutExtension(
- components[components.size() - 4]);
- if (ext == ".framework" && name == parentName) {
- components.erase(components.begin() + components.size() - 3,
- components.end());
- return cmSystemTools::JoinPath(components);
- }
+ auto fwItems = this->SplitFrameworkPath(path);
+ if (fwItems) {
+ if (fwItems->first.empty()) {
+ return cmStrCat(fwItems->second, ".framework");
+ } else {
+ return cmStrCat(fwItems->first, '/', fwItems->second, ".framework");
}
}
+
return path;
}
-} // anonymous
-
cmXCodeObject* cmGlobalXCodeGenerator::CreateXCodeFileReferenceFromPath(
const std::string& fullpath, cmGeneratorTarget* target,
const std::string& lang, cmSourceFile* sf)
@@ -1217,7 +1195,7 @@
ext = ext.substr(1);
}
if (fileType.empty()) {
- path = GetLibraryOrFrameworkPath(path);
+ path = this->GetLibraryOrFrameworkPath(path);
ext = cmSystemTools::GetFilenameLastExtension(path);
if (!ext.empty()) {
ext = ext.substr(1);
@@ -3541,13 +3519,14 @@
} else {
linkDir = libItem->Value.Value;
}
- linkDir = GetLibraryOrFrameworkPath(linkDir);
- bool isFramework = cmSystemTools::IsPathToFramework(linkDir);
- linkDir = cmSystemTools::GetParentDirectory(linkDir);
- if (isFramework) {
- if (std::find(frameworkSearchPaths.begin(), frameworkSearchPaths.end(),
- linkDir) == frameworkSearchPaths.end()) {
- frameworkSearchPaths.push_back(linkDir);
+ if (cmHasSuffix(libItem->GetFeatureName(), "FRAMEWORK"_s)) {
+ auto fwItems = this->SplitFrameworkPath(linkDir, true);
+ if (fwItems && !fwItems->first.empty()) {
+ linkDir = std::move(fwItems->first);
+ if (std::find(frameworkSearchPaths.begin(), frameworkSearchPaths.end(),
+ linkDir) == frameworkSearchPaths.end()) {
+ frameworkSearchPaths.push_back(linkDir);
+ }
}
} else {
if (std::find(linkSearchPaths.begin(), linkSearchPaths.end(), linkDir) ==
@@ -3555,7 +3534,7 @@
linkSearchPaths.push_back(linkDir);
}
}
- // Add target dependency
+
if (libItem->Target && !libItem->Target->IsImported()) {
for (auto const& configName : this->CurrentConfigurationTypes) {
target->AddDependTarget(configName, libItem->Target->GetName());
@@ -3729,22 +3708,27 @@
if (cmSystemTools::FileIsFullPath(cleanPath)) {
cleanPath = cmSystemTools::CollapseFullPath(cleanPath);
}
- const auto libPath = GetLibraryOrFrameworkPath(cleanPath);
- if (cmSystemTools::StringEndsWith(libPath.c_str(), ".framework")) {
- const auto fwName =
- cmSystemTools::GetFilenameWithoutExtension(libPath);
- const auto fwDir = cmSystemTools::GetParentDirectory(libPath);
- if (emitted.insert(fwDir).second) {
- // This is a search path we had not added before and it isn't an
- // implicit search path, so we need it
- libPaths.Add("-F " + this->XCodeEscapePath(fwDir));
+ bool isFramework =
+ cmHasSuffix(libName.GetFeatureName(), "FRAMEWORK"_s);
+ if (isFramework) {
+ const auto fwItems =
+ this->SplitFrameworkPath(cleanPath, isFramework);
+ if (!fwItems->first.empty() &&
+ emitted.insert(fwItems->first).second) {
+ // This is a search path we had not added before and it isn't
+ // an implicit search path, so we need it
+ libPaths.Add("-F " + this->XCodeEscapePath(fwItems->first));
}
- libPaths.Add("-framework " + this->XCodeEscapePath(fwName));
+ libPaths.Add(
+ libName.GetFormattedItem(this->XCodeEscapePath(fwItems->second))
+ .Value);
} else {
- libPaths.Add(this->XCodeEscapePath(cleanPath));
+ libPaths.Add(
+ libName.GetFormattedItem(this->XCodeEscapePath(cleanPath))
+ .Value);
}
if ((!libName.Target || libName.Target->IsImported()) &&
- IsLinkPhaseLibraryExtension(libPath)) {
+ (isFramework || IsLinkPhaseLibraryExtension(cleanPath))) {
// Create file reference for embedding
auto it = this->ExternalLibRefs.find(cleanPath);
if (it == this->ExternalLibRefs.end()) {
@@ -3912,8 +3896,8 @@
{
static const auto dstSubfolderSpec = "10";
- // Despite the name, by default Xcode uses "Embed Frameworks" build phase for
- // both frameworks and dynamic libraries
+ // Despite the name, by default Xcode uses "Embed Frameworks" build phase
+ // for both frameworks and dynamic libraries
this->AddEmbeddedObjects(target, "Embed Frameworks",
"XCODE_EMBED_FRAMEWORKS", dstSubfolderSpec,
NoActionOnCopyByDefault);
@@ -4711,10 +4695,12 @@
std::string cmGlobalXCodeGenerator::RelativeToSource(const std::string& p)
{
- // We force conversion because Xcode breakpoints do not work unless
- // they are in a file named relative to the source tree.
- return cmSystemTools::ForceToRelativePath(
- this->CurrentRootGenerator->GetCurrentSourceDirectory(), p);
+ std::string const& rootSrc =
+ this->CurrentRootGenerator->GetCurrentSourceDirectory();
+ if (cmSystemTools::IsSubDirectory(p, rootSrc)) {
+ return cmSystemTools::ForceToRelativePath(rootSrc, p);
+ }
+ return p;
}
std::string cmGlobalXCodeGenerator::RelativeToBinary(const std::string& p)
diff --git a/Source/cmGlobalXCodeGenerator.h b/Source/cmGlobalXCodeGenerator.h
index ff6ffe8..98cebef 100644
--- a/Source/cmGlobalXCodeGenerator.h
+++ b/Source/cmGlobalXCodeGenerator.h
@@ -330,6 +330,8 @@
{
}
+ std::string GetLibraryOrFrameworkPath(const std::string& path) const;
+
std::string GetObjectsDirectory(const std::string& projName,
const std::string& configName,
const cmGeneratorTarget* t,
diff --git a/Source/cmLinkLibrariesCommand.cxx b/Source/cmLinkLibrariesCommand.cxx
index 2b8f836..ed89e91 100644
--- a/Source/cmLinkLibrariesCommand.cxx
+++ b/Source/cmLinkLibrariesCommand.cxx
@@ -35,5 +35,7 @@
mf.AppendProperty("LINK_LIBRARIES", *i);
}
+ mf.CheckProperty("LINK_LIBRARIES");
+
return true;
}
diff --git a/Source/cmLinkLineComputer.cxx b/Source/cmLinkLineComputer.cxx
index 5646368..290642b 100644
--- a/Source/cmLinkLineComputer.cxx
+++ b/Source/cmLinkLineComputer.cxx
@@ -75,14 +75,8 @@
BT<std::string> linkLib;
if (item.IsPath == cmComputeLinkInformation::ItemIsPath::Yes) {
- if (item.IsObject == cmComputeLinkInformation::ItemIsObject::Yes) {
- linkLib.Value += cli.GetObjLinkFileFlag();
- } else {
- linkLib.Value += cli.GetLibLinkFileFlag();
- }
- linkLib.Value += this->ConvertToOutputFormat(
- this->ConvertToLinkReference(item.Value.Value));
- linkLib.Backtrace = item.Value.Backtrace;
+ linkLib = item.GetFormattedItem(this->ConvertToOutputFormat(
+ this->ConvertToLinkReference(item.Value.Value)));
} else {
linkLib = item.Value;
}
diff --git a/Source/cmLinkLineDeviceComputer.cxx b/Source/cmLinkLineDeviceComputer.cxx
index 43f161b..71f9f80 100644
--- a/Source/cmLinkLineDeviceComputer.cxx
+++ b/Source/cmLinkLineDeviceComputer.cxx
@@ -118,8 +118,10 @@
// can tolerate '.so' or '.dylib' it cannot tolerate '.so.1'.
if (cmHasLiteralSuffix(item.Value.Value, ".a") ||
cmHasLiteralSuffix(item.Value.Value, ".lib")) {
- linkLib.Value += this->ConvertToOutputFormat(
- this->ConvertToLinkReference(item.Value.Value));
+ linkLib.Value = item
+ .GetFormattedItem(this->ConvertToOutputFormat(
+ this->ConvertToLinkReference(item.Value.Value)))
+ .Value;
}
} else if (item.Value == "-framework") {
// This is the first part of '-framework Name' where the framework
@@ -127,7 +129,7 @@
skipItemAfterFramework = true;
continue;
} else if (cmLinkItemValidForDevice(item.Value.Value)) {
- linkLib.Value += item.Value.Value;
+ linkLib.Value = item.Value.Value;
}
if (emitted.insert(linkLib.Value).second) {
diff --git a/Source/cmListFileCache.cxx b/Source/cmListFileCache.cxx
index 3da266d..b90af08 100644
--- a/Source/cmListFileCache.cxx
+++ b/Source/cmListFileCache.cxx
@@ -40,6 +40,7 @@
cmListFileLexer* Lexer;
std::string FunctionName;
long FunctionLine;
+ long FunctionLineEnd;
std::vector<cmListFileArgument> FunctionArguments;
enum
{
@@ -146,7 +147,7 @@
if (this->ParseFunction(token->text, token->line)) {
this->ListFile->Functions.emplace_back(
std::move(this->FunctionName), this->FunctionLine,
- std::move(this->FunctionArguments));
+ this->FunctionLineEnd, std::move(this->FunctionArguments));
} else {
return false;
}
@@ -259,6 +260,7 @@
}
} else if (token->type == cmListFileLexer_Token_ParenRight) {
if (parenDepth == 0) {
+ this->FunctionLineEnd = token->line;
return true;
}
parenDepth--;
@@ -539,11 +541,11 @@
return os << s.Value;
}
-std::vector<BT<std::string>> ExpandListWithBacktrace(
- std::string const& list, cmListFileBacktrace const& bt)
+std::vector<BT<std::string>> cmExpandListWithBacktrace(
+ std::string const& list, cmListFileBacktrace const& bt, bool emptyArgs)
{
std::vector<BT<std::string>> result;
- std::vector<std::string> tmp = cmExpandedList(list);
+ std::vector<std::string> tmp = cmExpandedList(list, emptyArgs);
result.reserve(tmp.size());
for (std::string& i : tmp) {
result.emplace_back(std::move(i), bt);
diff --git a/Source/cmListFileCache.h b/Source/cmListFileCache.h
index 5d45027..c3da81b 100644
--- a/Source/cmListFileCache.h
+++ b/Source/cmListFileCache.h
@@ -51,9 +51,9 @@
class cmListFileFunction
{
public:
- cmListFileFunction(std::string name, long line,
+ cmListFileFunction(std::string name, long line, long lineEnd,
std::vector<cmListFileArgument> args)
- : Impl{ std::make_shared<Implementation>(std::move(name), line,
+ : Impl{ std::make_shared<Implementation>(std::move(name), line, lineEnd,
std::move(args)) }
{
}
@@ -69,6 +69,7 @@
}
long Line() const noexcept { return this->Impl->Line; }
+ long LineEnd() const noexcept { return this->Impl->LineEnd; }
std::vector<cmListFileArgument> const& Arguments() const noexcept
{
@@ -78,11 +79,12 @@
private:
struct Implementation
{
- Implementation(std::string name, long line,
+ Implementation(std::string name, long line, long lineEnd,
std::vector<cmListFileArgument> args)
: OriginalName{ std::move(name) }
, LowerCaseName{ cmSystemTools::LowerCase(this->OriginalName) }
, Line{ line }
+ , LineEnd{ lineEnd }
, Arguments{ std::move(args) }
{
}
@@ -90,6 +92,7 @@
std::string OriginalName;
std::string LowerCaseName;
long Line = 0;
+ long LineEnd = 0;
std::vector<cmListFileArgument> Arguments;
};
@@ -230,9 +233,10 @@
friend bool operator==(T const& l, BTs<T> const& r) { return l == r.Value; }
};
-std::vector<BT<std::string>> ExpandListWithBacktrace(
+std::vector<BT<std::string>> cmExpandListWithBacktrace(
std::string const& list,
- cmListFileBacktrace const& bt = cmListFileBacktrace());
+ cmListFileBacktrace const& bt = cmListFileBacktrace(),
+ bool emptyArgs = false);
struct cmListFile
{
diff --git a/Source/cmLocalGenerator.cxx b/Source/cmLocalGenerator.cxx
index 2adb232..4fa7d4f 100644
--- a/Source/cmLocalGenerator.cxx
+++ b/Source/cmLocalGenerator.cxx
@@ -1609,6 +1609,7 @@
this->AddCMP0018Flags(compileFlags, target, lang, config);
this->AddVisibilityPresetFlags(compileFlags, target, lang);
+ this->AddColorDiagnosticsFlags(compileFlags, lang);
this->AppendFlags(compileFlags, mf->GetDefineFlags());
this->AppendFlags(compileFlags,
this->GetFrameworkFlags(lang, config, target));
@@ -2354,6 +2355,29 @@
}
}
+void cmLocalGenerator::AddColorDiagnosticsFlags(std::string& flags,
+ const std::string& lang)
+{
+ cmValue diag = this->Makefile->GetDefinition("CMAKE_COLOR_DIAGNOSTICS");
+ if (diag.IsSet()) {
+ std::string colorFlagName;
+ if (diag.IsOn()) {
+ colorFlagName =
+ cmStrCat("CMAKE_", lang, "_COMPILE_OPTIONS_COLOR_DIAGNOSTICS");
+ } else {
+ colorFlagName =
+ cmStrCat("CMAKE_", lang, "_COMPILE_OPTIONS_COLOR_DIAGNOSTICS_OFF");
+ }
+
+ std::vector<std::string> options;
+ this->Makefile->GetDefExpandList(colorFlagName, options);
+
+ for (std::string const& option : options) {
+ this->AppendFlagEscape(flags, option);
+ }
+ }
+}
+
void cmLocalGenerator::AddConfigVariableFlags(std::string& flags,
const std::string& var,
const std::string& config)
@@ -3199,7 +3223,7 @@
std::string const& defines_list) const
{
std::set<BT<std::string>> tmp;
- this->AppendDefines(tmp, ExpandListWithBacktrace(defines_list));
+ this->AppendDefines(tmp, cmExpandListWithBacktrace(defines_list));
for (BT<std::string> const& i : tmp) {
defines.emplace(i.Value);
}
@@ -3214,7 +3238,7 @@
}
// Expand the list of definitions.
- this->AppendDefines(defines, ExpandListWithBacktrace(defines_list));
+ this->AppendDefines(defines, cmExpandListWithBacktrace(defines_list));
}
void cmLocalGenerator::AppendDefines(
diff --git a/Source/cmLocalGenerator.h b/Source/cmLocalGenerator.h
index 115a54a..436a29e 100644
--- a/Source/cmLocalGenerator.h
+++ b/Source/cmLocalGenerator.h
@@ -159,6 +159,7 @@
cmGeneratorTarget const* target,
const std::string& lang,
const std::string& config);
+ void AddColorDiagnosticsFlags(std::string& flags, const std::string& lang);
//! Append flags to a string.
virtual void AppendFlags(std::string& flags,
const std::string& newFlags) const;
diff --git a/Source/cmLocalUnixMakefileGenerator3.cxx b/Source/cmLocalUnixMakefileGenerator3.cxx
index 0f8cdca..97a275a 100644
--- a/Source/cmLocalUnixMakefileGenerator3.cxx
+++ b/Source/cmLocalUnixMakefileGenerator3.cxx
@@ -133,7 +133,11 @@
// Record whether some options are enabled to avoid checking many
// times later.
if (!this->GetGlobalGenerator()->GetCMakeInstance()->GetIsInTryCompile()) {
- this->ColorMakefile = this->Makefile->IsOn("CMAKE_COLOR_MAKEFILE");
+ if (this->Makefile->IsSet("CMAKE_COLOR_MAKEFILE")) {
+ this->ColorMakefile = this->Makefile->IsOn("CMAKE_COLOR_MAKEFILE");
+ } else {
+ this->ColorMakefile = this->Makefile->IsOn("CMAKE_COLOR_DIAGNOSTICS");
+ }
}
this->SkipPreprocessedSourceRules =
this->Makefile->IsOn("CMAKE_SKIP_PREPROCESSED_SOURCE_RULES");
@@ -1508,13 +1512,12 @@
}
// Setup relative path top directories.
- if (cmValue relativePathTopSource =
- mf->GetDefinition("CMAKE_RELATIVE_PATH_TOP_SOURCE")) {
- this->SetRelativePathTopSource(*relativePathTopSource);
- }
- if (cmValue relativePathTopBinary =
- mf->GetDefinition("CMAKE_RELATIVE_PATH_TOP_BINARY")) {
- this->SetRelativePathTopBinary(*relativePathTopBinary);
+ cmValue relativePathTopSource =
+ mf->GetDefinition("CMAKE_RELATIVE_PATH_TOP_SOURCE");
+ cmValue relativePathTopBinary =
+ mf->GetDefinition("CMAKE_RELATIVE_PATH_TOP_BINARY");
+ if (relativePathTopSource && relativePathTopBinary) {
+ this->SetRelativePathTop(*relativePathTopSource, *relativePathTopBinary);
}
} else {
cmSystemTools::Error("Directory Information file not found");
@@ -1849,7 +1852,7 @@
cmSystemTools::Touch(DepTimestamp.GenericString(), true);
// clear the dependencies files generated by the compiler
- std::vector<std::string> dependencies = cmExpandedList(depsFiles);
+ std::vector<std::string> dependencies = cmExpandedList(depsFiles, true);
cmDependsCompiler depsManager;
depsManager.SetVerbose(verbose);
depsManager.ClearDependencies(dependencies);
diff --git a/Source/cmLocalVisualStudio7Generator.cxx b/Source/cmLocalVisualStudio7Generator.cxx
index ed7e888..f65add1 100644
--- a/Source/cmLocalVisualStudio7Generator.cxx
+++ b/Source/cmLocalVisualStudio7Generator.cxx
@@ -1294,7 +1294,9 @@
for (auto const& lib : libs) {
if (lib.IsPath == cmComputeLinkInformation::ItemIsPath::Yes) {
std::string rel = lg->MaybeRelativeToCurBinDir(lib.Value.Value);
- fout << lg->ConvertToXMLOutputPath(rel) << " ";
+ rel = lg->ConvertToXMLOutputPath(rel);
+ fout << (lib.HasFeature() ? lib.GetFormattedItem(rel).Value : rel)
+ << " ";
} else if (!lib.Target ||
lib.Target->GetType() != cmStateEnums::INTERFACE_LIBRARY) {
fout << lib.Value.Value << " ";
diff --git a/Source/cmLocalVisualStudioGenerator.cxx b/Source/cmLocalVisualStudioGenerator.cxx
index 93f01ed..2703c7b 100644
--- a/Source/cmLocalVisualStudioGenerator.cxx
+++ b/Source/cmLocalVisualStudioGenerator.cxx
@@ -252,7 +252,7 @@
// Store the script in a string.
std::string script;
- if (useLocal && projectType == VsProjectType::csproj) {
+ if (useLocal && projectType != VsProjectType::vcxproj) {
// This label is not provided by MSBuild for C# projects.
script += newline;
script += this->GetReportErrorLabel();
diff --git a/Source/cmMacroCommand.cxx b/Source/cmMacroCommand.cxx
index 154df63..ef12487 100644
--- a/Source/cmMacroCommand.cxx
+++ b/Source/cmMacroCommand.cxx
@@ -116,7 +116,7 @@
newLFFArgs.push_back(std::move(arg));
}
cmListFileFunction newLFF{ func.OriginalName(), func.Line(),
- std::move(newLFFArgs) };
+ func.LineEnd(), std::move(newLFFArgs) };
cmExecutionStatus status(makefile);
if (!makefile.ExecuteCommand(newLFF, status) || status.GetNestedError()) {
// The error message should have already included the call stack
diff --git a/Source/cmMakefile.cxx b/Source/cmMakefile.cxx
index 94d3be6..f0a96a8 100644
--- a/Source/cmMakefile.cxx
+++ b/Source/cmMakefile.cxx
@@ -291,6 +291,9 @@
builder["indentation"] = "";
val["file"] = full_path;
val["line"] = static_cast<Json::Value::Int64>(lff.Line());
+ if (lff.Line() != lff.LineEnd()) {
+ val["line_end"] = static_cast<Json::Value::Int64>(lff.LineEnd());
+ }
if (deferId) {
val["defer"] = *deferId;
}
@@ -302,6 +305,8 @@
val["time"] = cmSystemTools::GetTime();
val["frame"] =
static_cast<Json::Value::UInt64>(this->ExecutionStatusStack.size());
+ val["global_frame"] =
+ static_cast<Json::Value::UInt64>(this->RecursionDepth);
msg << Json::writeString(builder, val);
#endif
break;
@@ -453,6 +458,11 @@
return result;
}
+bool cmMakefile::IsImportedTargetGlobalScope() const
+{
+ return this->CurrentImportedTargetScope == ImportedTargetScope::Global;
+}
+
class cmMakefile::IncludeScope
{
public:
@@ -1663,6 +1673,7 @@
this->Backtrace);
cmListFileFunction project{ "project",
0,
+ 0,
{ { "Project", cmListFileArgument::Unquoted,
0 },
{ "__CMAKE_INJECTED_PROJECT_COMMAND__",
@@ -3976,6 +3987,31 @@
return this->StateSnapshot.GetDirectory().GetPropertyKeys();
}
+void cmMakefile::CheckProperty(const std::string& prop) const
+{
+ // Certain properties need checking.
+ if (prop == "LINK_LIBRARIES") {
+ if (cmValue value = this->GetProperty(prop)) {
+ // Look for <LINK_LIBRARY:> internal pattern
+ static cmsys::RegularExpression linkPattern(
+ "(^|;)(</?LINK_(LIBRARY|GROUP):[^;>]*>)(;|$)");
+ if (!linkPattern.find(value)) {
+ return;
+ }
+
+ // Report an error.
+ this->IssueMessage(
+ MessageType::FATAL_ERROR,
+ cmStrCat("Property ", prop, " contains the invalid item \"",
+ linkPattern.match(2), "\". The ", prop,
+ " property may contain the generator-expression \"$<LINK_",
+ linkPattern.match(3),
+ ":...>\" which may be used to specify how the libraries are "
+ "linked."));
+ }
+ }
+}
+
cmTarget* cmMakefile::FindLocalNonAliasTarget(const std::string& name) const
{
auto i = this->Targets.find(name);
@@ -4395,12 +4431,14 @@
}
// Deprecate old policies.
- if (status == cmPolicies::OLD && id <= cmPolicies::CMP0094 &&
+ if (status == cmPolicies::OLD && id <= cmPolicies::CMP0097 &&
!(this->GetCMakeInstance()->GetIsInTryCompile() &&
(
// Policies set by cmCoreTryCompile::TryCompileCode.
id == cmPolicies::CMP0065 || id == cmPolicies::CMP0083 ||
- id == cmPolicies::CMP0091))) {
+ id == cmPolicies::CMP0091)) &&
+ (!this->IsSet("CMAKE_WARN_DEPRECATED") ||
+ this->IsOn("CMAKE_WARN_DEPRECATED"))) {
this->IssueMessage(MessageType::DEPRECATION_WARNING,
cmPolicies::GetPolicyDeprecatedWarning(id));
}
diff --git a/Source/cmMakefile.h b/Source/cmMakefile.h
index f425697..6d44e79 100644
--- a/Source/cmMakefile.h
+++ b/Source/cmMakefile.h
@@ -787,6 +787,7 @@
cmValue GetProperty(const std::string& prop, bool chain) const;
bool GetPropertyAsBool(const std::string& prop) const;
std::vector<std::string> GetPropertyKeys() const;
+ void CheckProperty(const std::string& prop) const;
//! Initialize a makefile from its parent
void InitializeFromParent(cmMakefile* parent);
@@ -859,6 +860,44 @@
void PushLoopBlockBarrier();
void PopLoopBlockBarrier();
+ bool IsImportedTargetGlobalScope() const;
+
+ enum class ImportedTargetScope
+ {
+ Local,
+ Global,
+ };
+
+ /** Helper class to manage whether imported packages
+ * should be globally scoped based off the find package command
+ */
+ class SetGlobalTargetImportScope
+ {
+ public:
+ SetGlobalTargetImportScope(cmMakefile* mk, ImportedTargetScope const scope)
+ : Makefile(mk)
+ {
+ if (scope == ImportedTargetScope::Global &&
+ !this->Makefile->IsImportedTargetGlobalScope()) {
+ this->Makefile->CurrentImportedTargetScope = scope;
+ this->Set = true;
+ } else {
+ this->Set = false;
+ }
+ }
+ ~SetGlobalTargetImportScope()
+ {
+ if (this->Set) {
+ this->Makefile->CurrentImportedTargetScope =
+ ImportedTargetScope::Local;
+ }
+ }
+
+ private:
+ cmMakefile* Makefile;
+ bool Set;
+ };
+
/** Helper class to push and pop scopes automatically. */
class ScopePushPop
{
@@ -1123,4 +1162,5 @@
std::set<std::string> WarnedCMP0074;
bool IsSourceFileTryCompile;
mutable bool SuppressSideEffects;
+ ImportedTargetScope CurrentImportedTargetScope = ImportedTargetScope::Local;
};
diff --git a/Source/cmOutputConverter.cxx b/Source/cmOutputConverter.cxx
index b143170..e62e0cd 100644
--- a/Source/cmOutputConverter.cxx
+++ b/Source/cmOutputConverter.cxx
@@ -34,6 +34,7 @@
assert(this->StateSnapshot.IsValid());
this->ComputeRelativePathTopSource();
this->ComputeRelativePathTopBinary();
+ this->ComputeRelativePathTopRelation();
}
void cmOutputConverter::ComputeRelativePathTopSource()
@@ -69,6 +70,22 @@
this->RelativePathTopBinary = snapshot.GetDirectory().GetCurrentBinary();
}
+void cmOutputConverter::ComputeRelativePathTopRelation()
+{
+ if (cmSystemTools::ComparePath(this->RelativePathTopSource,
+ this->RelativePathTopBinary)) {
+ this->RelativePathTopRelation = TopRelation::InSource;
+ } else if (cmSystemTools::IsSubDirectory(this->RelativePathTopBinary,
+ this->RelativePathTopSource)) {
+ this->RelativePathTopRelation = TopRelation::BinInSrc;
+ } else if (cmSystemTools::IsSubDirectory(this->RelativePathTopSource,
+ this->RelativePathTopBinary)) {
+ this->RelativePathTopRelation = TopRelation::SrcInBin;
+ } else {
+ this->RelativePathTopRelation = TopRelation::Separate;
+ }
+}
+
std::string const& cmOutputConverter::GetRelativePathTopSource() const
{
return this->RelativePathTopSource;
@@ -79,27 +96,45 @@
return this->RelativePathTopBinary;
}
-void cmOutputConverter::SetRelativePathTopSource(std::string const& top)
+void cmOutputConverter::SetRelativePathTop(std::string const& topSource,
+ std::string const& topBinary)
{
- this->RelativePathTopSource = top;
-}
-
-void cmOutputConverter::SetRelativePathTopBinary(std::string const& top)
-{
- this->RelativePathTopBinary = top;
+ this->RelativePathTopSource = topSource;
+ this->RelativePathTopBinary = topBinary;
+ this->ComputeRelativePathTopRelation();
}
std::string cmOutputConverter::MaybeRelativeTo(
std::string const& local_path, std::string const& remote_path) const
{
- bool bothInBinary =
- PathEqOrSubDir(local_path, this->RelativePathTopBinary) &&
+ bool localInBinary = PathEqOrSubDir(local_path, this->RelativePathTopBinary);
+ bool remoteInBinary =
PathEqOrSubDir(remote_path, this->RelativePathTopBinary);
- bool bothInSource =
- PathEqOrSubDir(local_path, this->RelativePathTopSource) &&
+ bool localInSource = PathEqOrSubDir(local_path, this->RelativePathTopSource);
+ bool remoteInSource =
PathEqOrSubDir(remote_path, this->RelativePathTopSource);
+ switch (this->RelativePathTopRelation) {
+ case TopRelation::Separate:
+ // Checks are independent.
+ break;
+ case TopRelation::BinInSrc:
+ localInSource = localInSource && !localInBinary;
+ remoteInSource = remoteInSource && !remoteInBinary;
+ break;
+ case TopRelation::SrcInBin:
+ localInBinary = localInBinary && !localInSource;
+ remoteInBinary = remoteInBinary && !remoteInSource;
+ break;
+ case TopRelation::InSource:
+ // Checks are identical.
+ break;
+ };
+
+ bool const bothInBinary = localInBinary && remoteInBinary;
+ bool const bothInSource = localInSource && remoteInSource;
+
if (bothInBinary || bothInSource) {
return cmSystemTools::ForceToRelativePath(local_path, remote_path);
}
diff --git a/Source/cmOutputConverter.h b/Source/cmOutputConverter.h
index 335442d..d19bccc 100644
--- a/Source/cmOutputConverter.h
+++ b/Source/cmOutputConverter.h
@@ -29,8 +29,8 @@
std::string const& GetRelativePathTopSource() const;
std::string const& GetRelativePathTopBinary() const;
- void SetRelativePathTopSource(std::string const& top);
- void SetRelativePathTopBinary(std::string const& top);
+ void SetRelativePathTop(std::string const& topSource,
+ std::string const& topBinary);
enum OutputFormat
{
@@ -147,8 +147,17 @@
// safely by the build tools.
std::string RelativePathTopSource;
std::string RelativePathTopBinary;
+ enum class TopRelation
+ {
+ Separate,
+ BinInSrc,
+ SrcInBin,
+ InSource,
+ };
+ TopRelation RelativePathTopRelation = TopRelation::Separate;
void ComputeRelativePathTopSource();
void ComputeRelativePathTopBinary();
+ void ComputeRelativePathTopRelation();
std::string MaybeRelativeTo(std::string const& local_path,
std::string const& remote_path) const;
};
diff --git a/Source/cmPlaceholderExpander.cxx b/Source/cmPlaceholderExpander.cxx
new file mode 100644
index 0000000..118017e
--- /dev/null
+++ b/Source/cmPlaceholderExpander.cxx
@@ -0,0 +1,54 @@
+/* Distributed under the OSI-approved BSD 3-Clause License. See accompanying
+ file Copyright.txt or https://cmake.org/licensing for details. */
+#include "cmPlaceholderExpander.h"
+
+#include <cctype>
+
+std::string& cmPlaceholderExpander::ExpandVariables(std::string& s)
+{
+ std::string::size_type start = s.find('<');
+ // no variables to expand
+ if (start == std::string::npos) {
+ return s;
+ }
+ std::string::size_type pos = 0;
+ std::string expandedInput;
+ while (start != std::string::npos && start < s.size() - 2) {
+ std::string::size_type end = s.find('>', start);
+ // if we find a < with no > we are done
+ if (end == std::string::npos) {
+ s = expandedInput;
+ return s;
+ }
+ char c = s[start + 1];
+ // if the next char after the < is not A-Za-z then
+ // skip it and try to find the next < in the string
+ if (!isalpha(c)) {
+ start = s.find('<', start + 1);
+ } else {
+ // extract the var
+ std::string var = s.substr(start + 1, end - start - 1);
+ std::string replace = this->ExpandVariable(var);
+ expandedInput += s.substr(pos, start - pos);
+
+ // Prevent consecutive whitespace in the output if the rule variable
+ // expands to an empty string.
+ bool consecutive = replace.empty() && start > 0 && s[start - 1] == ' ' &&
+ end + 1 < s.size() && s[end + 1] == ' ';
+ if (consecutive) {
+ expandedInput.pop_back();
+ }
+
+ expandedInput += replace;
+
+ // move to next one
+ start = s.find('<', start + var.size() + 2);
+ pos = end + 1;
+ }
+ }
+ // add the rest of the input
+ expandedInput += s.substr(pos, s.size() - pos);
+ s = expandedInput;
+
+ return s;
+}
diff --git a/Source/cmPlaceholderExpander.h b/Source/cmPlaceholderExpander.h
new file mode 100644
index 0000000..24225cc
--- /dev/null
+++ b/Source/cmPlaceholderExpander.h
@@ -0,0 +1,19 @@
+/* Distributed under the OSI-approved BSD 3-Clause License. See accompanying
+ file Copyright.txt or https://cmake.org/licensing for details. */
+
+#pragma once
+
+#include "cmConfigure.h" // IWYU pragma: keep
+
+#include <string>
+
+class cmPlaceholderExpander
+{
+public:
+ virtual ~cmPlaceholderExpander() = default;
+
+ std::string& ExpandVariables(std::string& string);
+
+protected:
+ virtual std::string ExpandVariable(std::string const& variable) = 0;
+};
diff --git a/Source/cmPolicies.h b/Source/cmPolicies.h
index 99e2eb6..7d4012d 100644
--- a/Source/cmPolicies.h
+++ b/Source/cmPolicies.h
@@ -388,7 +388,9 @@
22, 0, cmPolicies::WARN) \
SELECT(POLICY, CMP0129, \
"Compiler id for MCST LCC compilers is now LCC, not GNU.", 3, 23, 0, \
- cmPolicies::WARN)
+ cmPolicies::WARN) \
+ SELECT(POLICY, CMP0130, "while() diagnoses condition evaluation errors.", \
+ 3, 24, 0, cmPolicies::WARN)
#define CM_SELECT_ID(F, A1, A2, A3, A4, A5, A6) F(A1)
#define CM_FOR_EACH_POLICY_ID(POLICY) \
diff --git a/Source/cmRulePlaceholderExpander.cxx b/Source/cmRulePlaceholderExpander.cxx
index 4cee09d..b63d11c 100644
--- a/Source/cmRulePlaceholderExpander.cxx
+++ b/Source/cmRulePlaceholderExpander.cxx
@@ -2,7 +2,6 @@
file Copyright.txt or https://cmake.org/licensing for details. */
#include "cmRulePlaceholderExpander.h"
-#include <cctype>
#include <utility>
#include "cmOutputConverter.h"
@@ -20,195 +19,194 @@
{
}
-std::string cmRulePlaceholderExpander::ExpandRuleVariable(
- cmOutputConverter* outputConverter, std::string const& variable,
- const RuleVariables& replaceValues)
+std::string cmRulePlaceholderExpander::ExpandVariable(
+ std::string const& variable)
{
- if (replaceValues.LinkFlags) {
+ if (this->ReplaceValues->LinkFlags) {
if (variable == "LINK_FLAGS") {
- return replaceValues.LinkFlags;
+ return this->ReplaceValues->LinkFlags;
}
}
- if (replaceValues.Manifests) {
+ if (this->ReplaceValues->Manifests) {
if (variable == "MANIFESTS") {
- return replaceValues.Manifests;
+ return this->ReplaceValues->Manifests;
}
}
- if (replaceValues.Flags) {
+ if (this->ReplaceValues->Flags) {
if (variable == "FLAGS") {
- return replaceValues.Flags;
+ return this->ReplaceValues->Flags;
}
}
- if (replaceValues.Source) {
+ if (this->ReplaceValues->Source) {
if (variable == "SOURCE") {
- return replaceValues.Source;
+ return this->ReplaceValues->Source;
}
}
- if (replaceValues.DynDepFile) {
+ if (this->ReplaceValues->DynDepFile) {
if (variable == "DYNDEP_FILE") {
- return replaceValues.DynDepFile;
+ return this->ReplaceValues->DynDepFile;
}
}
- if (replaceValues.PreprocessedSource) {
+ if (this->ReplaceValues->PreprocessedSource) {
if (variable == "PREPROCESSED_SOURCE") {
- return replaceValues.PreprocessedSource;
+ return this->ReplaceValues->PreprocessedSource;
}
}
- if (replaceValues.AssemblySource) {
+ if (this->ReplaceValues->AssemblySource) {
if (variable == "ASSEMBLY_SOURCE") {
- return replaceValues.AssemblySource;
+ return this->ReplaceValues->AssemblySource;
}
}
- if (replaceValues.Object) {
+ if (this->ReplaceValues->Object) {
if (variable == "OBJECT") {
- return replaceValues.Object;
+ return this->ReplaceValues->Object;
}
}
- if (replaceValues.ObjectDir) {
+ if (this->ReplaceValues->ObjectDir) {
if (variable == "OBJECT_DIR") {
- return replaceValues.ObjectDir;
+ return this->ReplaceValues->ObjectDir;
}
}
- if (replaceValues.ObjectFileDir) {
+ if (this->ReplaceValues->ObjectFileDir) {
if (variable == "OBJECT_FILE_DIR") {
- return replaceValues.ObjectFileDir;
+ return this->ReplaceValues->ObjectFileDir;
}
}
- if (replaceValues.Objects) {
+ if (this->ReplaceValues->Objects) {
if (variable == "OBJECTS") {
- return replaceValues.Objects;
+ return this->ReplaceValues->Objects;
}
}
- if (replaceValues.ObjectsQuoted) {
+ if (this->ReplaceValues->ObjectsQuoted) {
if (variable == "OBJECTS_QUOTED") {
- return replaceValues.ObjectsQuoted;
+ return this->ReplaceValues->ObjectsQuoted;
}
}
- if (replaceValues.CudaCompileMode) {
+ if (this->ReplaceValues->CudaCompileMode) {
if (variable == "CUDA_COMPILE_MODE") {
- return replaceValues.CudaCompileMode;
+ return this->ReplaceValues->CudaCompileMode;
}
}
- if (replaceValues.AIXExports) {
+ if (this->ReplaceValues->AIXExports) {
if (variable == "AIX_EXPORTS") {
- return replaceValues.AIXExports;
+ return this->ReplaceValues->AIXExports;
}
}
- if (replaceValues.ISPCHeader) {
+ if (this->ReplaceValues->ISPCHeader) {
if (variable == "ISPC_HEADER") {
- return replaceValues.ISPCHeader;
+ return this->ReplaceValues->ISPCHeader;
}
}
- if (replaceValues.Defines && variable == "DEFINES") {
- return replaceValues.Defines;
+ if (this->ReplaceValues->Defines && variable == "DEFINES") {
+ return this->ReplaceValues->Defines;
}
- if (replaceValues.Includes && variable == "INCLUDES") {
- return replaceValues.Includes;
+ if (this->ReplaceValues->Includes && variable == "INCLUDES") {
+ return this->ReplaceValues->Includes;
}
- if (replaceValues.SwiftLibraryName) {
+ if (this->ReplaceValues->SwiftLibraryName) {
if (variable == "SWIFT_LIBRARY_NAME") {
- return replaceValues.SwiftLibraryName;
+ return this->ReplaceValues->SwiftLibraryName;
}
}
- if (replaceValues.SwiftModule) {
+ if (this->ReplaceValues->SwiftModule) {
if (variable == "SWIFT_MODULE") {
- return replaceValues.SwiftModule;
+ return this->ReplaceValues->SwiftModule;
}
}
- if (replaceValues.SwiftModuleName) {
+ if (this->ReplaceValues->SwiftModuleName) {
if (variable == "SWIFT_MODULE_NAME") {
- return replaceValues.SwiftModuleName;
+ return this->ReplaceValues->SwiftModuleName;
}
}
- if (replaceValues.SwiftOutputFileMap) {
+ if (this->ReplaceValues->SwiftOutputFileMap) {
if (variable == "SWIFT_OUTPUT_FILE_MAP") {
- return replaceValues.SwiftOutputFileMap;
+ return this->ReplaceValues->SwiftOutputFileMap;
}
}
- if (replaceValues.SwiftSources) {
+ if (this->ReplaceValues->SwiftSources) {
if (variable == "SWIFT_SOURCES") {
- return replaceValues.SwiftSources;
+ return this->ReplaceValues->SwiftSources;
}
}
- if (replaceValues.TargetPDB) {
+ if (this->ReplaceValues->TargetPDB) {
if (variable == "TARGET_PDB") {
- return replaceValues.TargetPDB;
+ return this->ReplaceValues->TargetPDB;
}
}
- if (replaceValues.TargetCompilePDB) {
+ if (this->ReplaceValues->TargetCompilePDB) {
if (variable == "TARGET_COMPILE_PDB") {
- return replaceValues.TargetCompilePDB;
+ return this->ReplaceValues->TargetCompilePDB;
}
}
- if (replaceValues.DependencyFile) {
+ if (this->ReplaceValues->DependencyFile) {
if (variable == "DEP_FILE") {
- return replaceValues.DependencyFile;
+ return this->ReplaceValues->DependencyFile;
}
}
- if (replaceValues.DependencyTarget) {
+ if (this->ReplaceValues->DependencyTarget) {
if (variable == "DEP_TARGET") {
- return replaceValues.DependencyTarget;
+ return this->ReplaceValues->DependencyTarget;
}
}
- if (replaceValues.Fatbinary) {
+ if (this->ReplaceValues->Fatbinary) {
if (variable == "FATBINARY") {
- return replaceValues.Fatbinary;
+ return this->ReplaceValues->Fatbinary;
}
}
- if (replaceValues.RegisterFile) {
+ if (this->ReplaceValues->RegisterFile) {
if (variable == "REGISTER_FILE") {
- return replaceValues.RegisterFile;
+ return this->ReplaceValues->RegisterFile;
}
}
- if (replaceValues.Target) {
+ if (this->ReplaceValues->Target) {
if (variable == "TARGET_QUOTED") {
- std::string targetQuoted = replaceValues.Target;
+ std::string targetQuoted = this->ReplaceValues->Target;
if (!targetQuoted.empty() && targetQuoted.front() != '\"') {
targetQuoted = '\"';
- targetQuoted += replaceValues.Target;
+ targetQuoted += this->ReplaceValues->Target;
targetQuoted += '\"';
}
return targetQuoted;
}
if (variable == "TARGET_UNQUOTED") {
- std::string unquoted = replaceValues.Target;
+ std::string unquoted = this->ReplaceValues->Target;
std::string::size_type sz = unquoted.size();
if (sz > 2 && unquoted.front() == '\"' && unquoted.back() == '\"') {
unquoted = unquoted.substr(1, sz - 2);
}
return unquoted;
}
- if (replaceValues.LanguageCompileFlags) {
+ if (this->ReplaceValues->LanguageCompileFlags) {
if (variable == "LANGUAGE_COMPILE_FLAGS") {
- return replaceValues.LanguageCompileFlags;
+ return this->ReplaceValues->LanguageCompileFlags;
}
}
- if (replaceValues.Target) {
+ if (this->ReplaceValues->Target) {
if (variable == "TARGET") {
- return replaceValues.Target;
+ return this->ReplaceValues->Target;
}
}
if (variable == "TARGET_IMPLIB") {
return this->TargetImpLib;
}
if (variable == "TARGET_VERSION_MAJOR") {
- if (replaceValues.TargetVersionMajor) {
- return replaceValues.TargetVersionMajor;
+ if (this->ReplaceValues->TargetVersionMajor) {
+ return this->ReplaceValues->TargetVersionMajor;
}
return "0";
}
if (variable == "TARGET_VERSION_MINOR") {
- if (replaceValues.TargetVersionMinor) {
- return replaceValues.TargetVersionMinor;
+ if (this->ReplaceValues->TargetVersionMinor) {
+ return this->ReplaceValues->TargetVersionMinor;
}
return "0";
}
- if (replaceValues.Target) {
+ if (this->ReplaceValues->Target) {
if (variable == "TARGET_BASE") {
// Strip the last extension off the target name.
- std::string targetBase = replaceValues.Target;
+ std::string targetBase = this->ReplaceValues->Target;
std::string::size_type pos = targetBase.rfind('.');
if (pos != std::string::npos) {
return targetBase.substr(0, pos);
@@ -220,54 +218,54 @@
if (variable == "TARGET_SONAME" || variable == "SONAME_FLAG" ||
variable == "TARGET_INSTALLNAME_DIR") {
// All these variables depend on TargetSOName
- if (replaceValues.TargetSOName) {
+ if (this->ReplaceValues->TargetSOName) {
if (variable == "TARGET_SONAME") {
- return replaceValues.TargetSOName;
+ return this->ReplaceValues->TargetSOName;
}
- if (variable == "SONAME_FLAG" && replaceValues.SONameFlag) {
- return replaceValues.SONameFlag;
+ if (variable == "SONAME_FLAG" && this->ReplaceValues->SONameFlag) {
+ return this->ReplaceValues->SONameFlag;
}
- if (replaceValues.TargetInstallNameDir &&
+ if (this->ReplaceValues->TargetInstallNameDir &&
variable == "TARGET_INSTALLNAME_DIR") {
- return replaceValues.TargetInstallNameDir;
+ return this->ReplaceValues->TargetInstallNameDir;
}
}
return "";
}
- if (replaceValues.LinkLibraries) {
+ if (this->ReplaceValues->LinkLibraries) {
if (variable == "LINK_LIBRARIES") {
- return replaceValues.LinkLibraries;
+ return this->ReplaceValues->LinkLibraries;
}
}
- if (replaceValues.Language) {
+ if (this->ReplaceValues->Language) {
if (variable == "LANGUAGE") {
- return replaceValues.Language;
+ return this->ReplaceValues->Language;
}
}
- if (replaceValues.CMTargetName) {
+ if (this->ReplaceValues->CMTargetName) {
if (variable == "TARGET_NAME") {
- return replaceValues.CMTargetName;
+ return this->ReplaceValues->CMTargetName;
}
}
- if (replaceValues.CMTargetType) {
+ if (this->ReplaceValues->CMTargetType) {
if (variable == "TARGET_TYPE") {
- return replaceValues.CMTargetType;
+ return this->ReplaceValues->CMTargetType;
}
}
- if (replaceValues.Output) {
+ if (this->ReplaceValues->Output) {
if (variable == "OUTPUT") {
- return replaceValues.Output;
+ return this->ReplaceValues->Output;
}
}
if (variable == "CMAKE_COMMAND") {
- return outputConverter->ConvertToOutputFormat(
+ return this->OutputConverter->ConvertToOutputFormat(
cmSystemTools::GetCMakeCommand(), cmOutputConverter::SHELL);
}
auto compIt = this->Compilers.find(variable);
if (compIt != this->Compilers.end()) {
- std::string ret = outputConverter->ConvertToOutputForExisting(
+ std::string ret = this->OutputConverter->ConvertToOutputForExisting(
this->VariableMappings["CMAKE_" + compIt->second + "_COMPILER"]);
std::string const& compilerArg1 =
this->VariableMappings["CMAKE_" + compIt->second + "_COMPILER_ARG1"];
@@ -286,11 +284,12 @@
this->VariableMappings["CMAKE_" + compIt->second +
"_COMPILE_OPTIONS_SYSROOT"];
- if (compIt->second == replaceValues.Language && replaceValues.Launcher) {
+ if (compIt->second == this->ReplaceValues->Language &&
+ this->ReplaceValues->Launcher) {
// Add launcher as part of expansion so that it always appears
// immediately before the command itself, regardless of whether the
// overall rule template contains other content at the front.
- ret = cmStrCat(replaceValues.Launcher, " ", ret);
+ ret = cmStrCat(this->ReplaceValues->Launcher, " ", ret);
}
// if there are required arguments to the compiler add it
@@ -308,13 +307,14 @@
!compilerOptionExternalToolchain.empty()) {
ret += " ";
ret += compilerOptionExternalToolchain;
- ret += outputConverter->EscapeForShell(compilerExternalToolchain, true);
+ ret +=
+ this->OutputConverter->EscapeForShell(compilerExternalToolchain, true);
}
std::string sysroot;
// Some platforms may use separate sysroots for compiling and linking.
// If we detect link flags, then we pass the link sysroot instead.
// FIXME: Use a more robust way to detect link line expansion.
- if (replaceValues.LinkFlags) {
+ if (this->ReplaceValues->LinkFlags) {
sysroot = this->LinkerSysroot;
} else {
sysroot = this->CompilerSysroot;
@@ -322,7 +322,7 @@
if (!sysroot.empty() && !compilerOptionSysroot.empty()) {
ret += " ";
ret += compilerOptionSysroot;
- ret += outputConverter->EscapeForShell(sysroot, true);
+ ret += this->OutputConverter->EscapeForShell(sysroot, true);
}
return ret;
}
@@ -331,13 +331,13 @@
if (mapIt != this->VariableMappings.end()) {
if (variable.find("_FLAG") == std::string::npos) {
std::string ret =
- outputConverter->ConvertToOutputForExisting(mapIt->second);
+ this->OutputConverter->ConvertToOutputForExisting(mapIt->second);
- if (replaceValues.Launcher && variable == "CMAKE_LINKER") {
+ if (this->ReplaceValues->Launcher && variable == "CMAKE_LINKER") {
// Add launcher as part of expansion so that it always appears
// immediately before the command itself, regardless of whether the
// overall rule template contains other content at the front.
- ret = cmStrCat(replaceValues.Launcher, " ", ret);
+ ret = cmStrCat(this->ReplaceValues->Launcher, " ", ret);
}
return ret;
@@ -351,47 +351,8 @@
cmOutputConverter* outputConverter, std::string& s,
const RuleVariables& replaceValues)
{
- std::string::size_type start = s.find('<');
- // no variables to expand
- if (start == std::string::npos) {
- return;
- }
- std::string::size_type pos = 0;
- std::string expandedInput;
- while (start != std::string::npos && start < s.size() - 2) {
- std::string::size_type end = s.find('>', start);
- // if we find a < with no > we are done
- if (end == std::string::npos) {
- return;
- }
- char c = s[start + 1];
- // if the next char after the < is not A-Za-z then
- // skip it and try to find the next < in the string
- if (!isalpha(c)) {
- start = s.find('<', start + 1);
- } else {
- // extract the var
- std::string var = s.substr(start + 1, end - start - 1);
- std::string replace =
- this->ExpandRuleVariable(outputConverter, var, replaceValues);
- expandedInput += s.substr(pos, start - pos);
+ this->OutputConverter = outputConverter;
+ this->ReplaceValues = &replaceValues;
- // Prevent consecutive whitespace in the output if the rule variable
- // expands to an empty string.
- bool consecutive = replace.empty() && start > 0 && s[start - 1] == ' ' &&
- end + 1 < s.size() && s[end + 1] == ' ';
- if (consecutive) {
- expandedInput.pop_back();
- }
-
- expandedInput += replace;
-
- // move to next one
- start = s.find('<', start + var.size() + 2);
- pos = end + 1;
- }
- }
- // add the rest of the input
- expandedInput += s.substr(pos, s.size() - pos);
- s = expandedInput;
+ this->ExpandVariables(s);
}
diff --git a/Source/cmRulePlaceholderExpander.h b/Source/cmRulePlaceholderExpander.h
index 852954f..23ec405 100644
--- a/Source/cmRulePlaceholderExpander.h
+++ b/Source/cmRulePlaceholderExpander.h
@@ -8,9 +8,11 @@
#include <map>
#include <string>
+#include "cmPlaceholderExpander.h"
+
class cmOutputConverter;
-class cmRulePlaceholderExpander
+class cmRulePlaceholderExpander : public cmPlaceholderExpander
{
public:
cmRulePlaceholderExpander(
@@ -76,16 +78,16 @@
std::string& string,
const RuleVariables& replaceValues);
- // Expand rule variables in a single string
- std::string ExpandRuleVariable(cmOutputConverter* outputConverter,
- std::string const& variable,
- const RuleVariables& replaceValues);
-
private:
+ std::string ExpandVariable(std::string const& variable) override;
+
std::string TargetImpLib;
std::map<std::string, std::string> Compilers;
std::map<std::string, std::string> VariableMappings;
std::string CompilerSysroot;
std::string LinkerSysroot;
+
+ cmOutputConverter* OutputConverter = nullptr;
+ RuleVariables const* ReplaceValues = nullptr;
};
diff --git a/Source/cmSystemTools.cxx b/Source/cmSystemTools.cxx
index effb837..a5dfa4c 100644
--- a/Source/cmSystemTools.cxx
+++ b/Source/cmSystemTools.cxx
@@ -3314,12 +3314,22 @@
uv_fs_t req;
int flags = 0;
#if defined(_WIN32)
- if (cmsys::SystemTools::FileIsDirectory(origName)) {
- flags |= UV_FS_SYMLINK_DIR;
+ bool const isDir = cmsys::SystemTools::FileIsDirectory(origName);
+ if (isDir) {
+ flags |= UV_FS_SYMLINK_JUNCTION;
}
#endif
int err = uv_fs_symlink(nullptr, &req, origName.c_str(), newName.c_str(),
flags, nullptr);
+#if defined(_WIN32)
+ if (err && uv_fs_get_system_error(&req) == ERROR_NOT_SUPPORTED && isDir) {
+ // Try fallback to symlink for network (requires additional permissions).
+ flags ^= UV_FS_SYMLINK_JUNCTION | UV_FS_SYMLINK_DIR;
+ err = uv_fs_symlink(nullptr, &req, origName.c_str(), newName.c_str(),
+ flags, nullptr);
+ }
+#endif
+
cmsys::Status status;
if (err) {
#if defined(_WIN32)
diff --git a/Source/cmTarget.cxx b/Source/cmTarget.cxx
index 6059055..4ca1b9b 100644
--- a/Source/cmTarget.cxx
+++ b/Source/cmTarget.cxx
@@ -1783,69 +1783,94 @@
this->impl->PrecompileHeadersEntries.push_back(entry);
}
-static void cmTargetCheckLINK_INTERFACE_LIBRARIES(const std::string& prop,
- const std::string& value,
- cmMakefile* context,
- bool imported)
+namespace {
+void CheckLinkLibraryPattern(const std::string& property,
+ const std::string& value, cmMakefile* context)
{
- // Look for link-type keywords in the value.
- static cmsys::RegularExpression keys("(^|;)(debug|optimized|general)(;|$)");
- if (!keys.find(value)) {
+ // Look for <LINK_LIBRARY:> and </LINK_LIBRARY:> internal tags
+ static cmsys::RegularExpression linkPattern(
+ "(^|;)(</?LINK_(LIBRARY|GROUP):[^;>]*>)(;|$)");
+ if (!linkPattern.find(value)) {
return;
}
+ // Report an error.
+ context->IssueMessage(
+ MessageType::FATAL_ERROR,
+ cmStrCat(
+ "Property ", property, " contains the invalid item \"",
+ linkPattern.match(2), "\". The ", property,
+ " property may contain the generator-expression \"$<LINK_",
+ linkPattern.match(3),
+ ":...>\" which may be used to specify how the libraries are linked."));
+}
+
+void CheckLINK_INTERFACE_LIBRARIES(const std::string& prop,
+ const std::string& value,
+ cmMakefile* context, bool imported)
+{
// Support imported and non-imported versions of the property.
const char* base = (imported ? "IMPORTED_LINK_INTERFACE_LIBRARIES"
: "LINK_INTERFACE_LIBRARIES");
- // Report an error.
- std::ostringstream e;
- e << "Property " << prop << " may not contain link-type keyword \""
- << keys.match(2) << "\". "
- << "The " << base << " property has a per-configuration "
- << "version called " << base << "_<CONFIG> which may be "
- << "used to specify per-configuration rules.";
- if (!imported) {
- e << " "
- << "Alternatively, an IMPORTED library may be created, configured "
- << "with a per-configuration location, and then named in the "
- << "property value. "
- << "See the add_library command's IMPORTED mode for details."
- << "\n"
- << "If you have a list of libraries that already contains the "
- << "keyword, use the target_link_libraries command with its "
- << "LINK_INTERFACE_LIBRARIES mode to set the property. "
- << "The command automatically recognizes link-type keywords and sets "
- << "the LINK_INTERFACE_LIBRARIES and LINK_INTERFACE_LIBRARIES_DEBUG "
- << "properties accordingly.";
+ // Look for link-type keywords in the value.
+ static cmsys::RegularExpression keys("(^|;)(debug|optimized|general)(;|$)");
+ if (keys.find(value)) {
+ // Report an error.
+ std::ostringstream e;
+ e << "Property " << prop << " may not contain link-type keyword \""
+ << keys.match(2) << "\". "
+ << "The " << base << " property has a per-configuration "
+ << "version called " << base << "_<CONFIG> which may be "
+ << "used to specify per-configuration rules.";
+ if (!imported) {
+ e << " "
+ << "Alternatively, an IMPORTED library may be created, configured "
+ << "with a per-configuration location, and then named in the "
+ << "property value. "
+ << "See the add_library command's IMPORTED mode for details."
+ << "\n"
+ << "If you have a list of libraries that already contains the "
+ << "keyword, use the target_link_libraries command with its "
+ << "LINK_INTERFACE_LIBRARIES mode to set the property. "
+ << "The command automatically recognizes link-type keywords and sets "
+ << "the LINK_INTERFACE_LIBRARIES and LINK_INTERFACE_LIBRARIES_DEBUG "
+ << "properties accordingly.";
+ }
+ context->IssueMessage(MessageType::FATAL_ERROR, e.str());
}
- context->IssueMessage(MessageType::FATAL_ERROR, e.str());
+
+ CheckLinkLibraryPattern(base, value, context);
}
-static void cmTargetCheckINTERFACE_LINK_LIBRARIES(const std::string& value,
- cmMakefile* context)
+void CheckLINK_LIBRARIES(const std::string& value, cmMakefile* context)
+{
+ CheckLinkLibraryPattern("LINK_LIBRARIES", value, context);
+}
+
+void CheckINTERFACE_LINK_LIBRARIES(const std::string& value,
+ cmMakefile* context)
{
// Look for link-type keywords in the value.
static cmsys::RegularExpression keys("(^|;)(debug|optimized|general)(;|$)");
- if (!keys.find(value)) {
- return;
+ if (keys.find(value)) {
+ // Report an error.
+ std::ostringstream e;
+
+ e << "Property INTERFACE_LINK_LIBRARIES may not contain link-type "
+ "keyword \""
+ << keys.match(2)
+ << "\". The INTERFACE_LINK_LIBRARIES "
+ "property may contain configuration-sensitive generator-expressions "
+ "which may be used to specify per-configuration rules.";
+
+ context->IssueMessage(MessageType::FATAL_ERROR, e.str());
}
- // Report an error.
- std::ostringstream e;
-
- e << "Property INTERFACE_LINK_LIBRARIES may not contain link-type "
- "keyword \""
- << keys.match(2)
- << "\". The INTERFACE_LINK_LIBRARIES "
- "property may contain configuration-sensitive generator-expressions "
- "which may be used to specify per-configuration rules.";
-
- context->IssueMessage(MessageType::FATAL_ERROR, e.str());
+ CheckLinkLibraryPattern("INTERFACE_LINK_LIBRARIES", value, context);
}
-static void cmTargetCheckIMPORTED_GLOBAL(const cmTarget* target,
- cmMakefile* context)
+void CheckIMPORTED_GLOBAL(const cmTarget* target, cmMakefile* context)
{
const auto& targets = context->GetOwnedImportedTargets();
auto it =
@@ -1861,6 +1886,7 @@
context->IssueMessage(MessageType::FATAL_ERROR, e.str());
}
}
+}
void cmTarget::CheckProperty(const std::string& prop,
cmMakefile* context) const
@@ -1868,22 +1894,23 @@
// Certain properties need checking.
if (cmHasLiteralPrefix(prop, "LINK_INTERFACE_LIBRARIES")) {
if (cmValue value = this->GetProperty(prop)) {
- cmTargetCheckLINK_INTERFACE_LIBRARIES(prop, *value, context, false);
+ CheckLINK_INTERFACE_LIBRARIES(prop, *value, context, false);
}
- }
- if (cmHasLiteralPrefix(prop, "IMPORTED_LINK_INTERFACE_LIBRARIES")) {
+ } else if (cmHasLiteralPrefix(prop, "IMPORTED_LINK_INTERFACE_LIBRARIES")) {
if (cmValue value = this->GetProperty(prop)) {
- cmTargetCheckLINK_INTERFACE_LIBRARIES(prop, *value, context, true);
+ CheckLINK_INTERFACE_LIBRARIES(prop, *value, context, true);
}
- }
- if (prop == "INTERFACE_LINK_LIBRARIES") {
+ } else if (prop == "LINK_LIBRARIES") {
if (cmValue value = this->GetProperty(prop)) {
- cmTargetCheckINTERFACE_LINK_LIBRARIES(*value, context);
+ CheckLINK_LIBRARIES(*value, context);
}
- }
- if (prop == "IMPORTED_GLOBAL") {
+ } else if (prop == "INTERFACE_LINK_LIBRARIES") {
+ if (cmValue value = this->GetProperty(prop)) {
+ CheckINTERFACE_LINK_LIBRARIES(*value, context);
+ }
+ } else if (prop == "IMPORTED_GLOBAL") {
if (this->IsImported()) {
- cmTargetCheckIMPORTED_GLOBAL(this, context);
+ CheckIMPORTED_GLOBAL(this, context);
}
}
}
diff --git a/Source/cmTargetLinkLibrariesCommand.cxx b/Source/cmTargetLinkLibrariesCommand.cxx
index e10d0b5..e1a6c78 100644
--- a/Source/cmTargetLinkLibrariesCommand.cxx
+++ b/Source/cmTargetLinkLibrariesCommand.cxx
@@ -379,6 +379,9 @@
target->SetProperty("LINK_INTERFACE_LIBRARIES", "");
}
+ target->CheckProperty("LINK_LIBRARIES", &mf);
+ target->CheckProperty("INTERFACE_LINK_LIBRARIES", &mf);
+
return true;
}
diff --git a/Source/cmVariableWatchCommand.cxx b/Source/cmVariableWatchCommand.cxx
index fd5402c..24394d9 100644
--- a/Source/cmVariableWatchCommand.cxx
+++ b/Source/cmVariableWatchCommand.cxx
@@ -58,7 +58,7 @@
{ stack, cmListFileArgument::Quoted, fakeLineNo }
};
- cmListFileFunction newLFF{ data->Command, fakeLineNo,
+ cmListFileFunction newLFF{ data->Command, fakeLineNo, fakeLineNo,
std::move(newLFFArgs) };
cmExecutionStatus status(*makefile);
if (!makefile->ExecuteCommand(newLFF, status)) {
diff --git a/Source/cmVisualStudio10TargetGenerator.cxx b/Source/cmVisualStudio10TargetGenerator.cxx
index 8ffb664..276eccf 100644
--- a/Source/cmVisualStudio10TargetGenerator.cxx
+++ b/Source/cmVisualStudio10TargetGenerator.cxx
@@ -50,6 +50,24 @@
#include "cmValue.h"
#include "cmVisualStudioGeneratorOptions.h"
+namespace {
+std::string getProjectFileExtension(VsProjectType projectType)
+{
+ switch (projectType) {
+ case VsProjectType::csproj:
+ return ".csproj";
+ case VsProjectType::proj:
+ return ".proj";
+ case VsProjectType::vcxproj:
+ return ".vcxproj";
+ // Valid inputs shouldn't reach here. This default is needed so that all
+ // paths return value (C4715).
+ default:
+ return "";
+ }
+}
+}
+
struct cmIDEFlagTable;
static void ConvertToWindowsSlash(std::string& s);
@@ -235,29 +253,6 @@
return cmSystemTools::Strucmp(ext.c_str(), ".targets") == 0;
}
-static VsProjectType computeProjectType(cmGeneratorTarget const* t)
-{
- if (t->IsCSharpOnly()) {
- return VsProjectType::csproj;
- }
- return VsProjectType::vcxproj;
-}
-
-static std::string computeProjectFileExtension(VsProjectType projectType)
-{
- switch (projectType) {
- case VsProjectType::csproj:
- return ".csproj";
- default:
- return ".vcxproj";
- }
-}
-
-static std::string computeProjectFileExtension(cmGeneratorTarget const* t)
-{
- return computeProjectFileExtension(computeProjectType(t));
-}
-
cmVisualStudio10TargetGenerator::cmVisualStudio10TargetGenerator(
cmGeneratorTarget* target, cmGlobalVisualStudio10Generator* gg)
: GeneratorTarget(target)
@@ -352,10 +347,10 @@
void cmVisualStudio10TargetGenerator::Generate()
{
- this->ProjectType = computeProjectType(this->GeneratorTarget);
+ this->ProjectType = this->ComputeProjectType(this->GeneratorTarget);
this->Managed = this->ProjectType == VsProjectType::csproj;
const std::string ProjectFileExtension =
- computeProjectFileExtension(this->ProjectType);
+ getProjectFileExtension(this->ProjectType);
if (this->ProjectType == VsProjectType::csproj &&
this->GeneratorTarget->GetType() == cmStateEnums::STATIC_LIBRARY) {
@@ -416,10 +411,12 @@
char magic[] = { char(0xEF), char(0xBB), char(0xBF) };
BuildFileStream.write(magic, 3);
- if (this->ProjectType == VsProjectType::csproj &&
- this->GeneratorTarget->IsDotNetSdkTarget() &&
- this->GlobalGenerator->GetVersion() >=
- cmGlobalVisualStudioGenerator::VSVersion::VS16) {
+ if (this->ProjectType == VsProjectType::proj) {
+ this->WriteZeroCheckProj(BuildFileStream);
+ } else if (this->ProjectType == VsProjectType::csproj &&
+ this->GeneratorTarget->IsDotNetSdkTarget() &&
+ this->GlobalGenerator->GetVersion() >=
+ cmGlobalVisualStudioGenerator::VSVersion::VS16) {
this->WriteSdkStyleProjectFile(BuildFileStream);
} else {
this->WriteClassicMsBuildProjectFile(BuildFileStream);
@@ -681,6 +678,8 @@
.Attribute("Project", VS10_CSharp_DEFAULT_PROPS)
.Attribute("Condition", "Exists('" VS10_CSharp_DEFAULT_PROPS "')");
break;
+ default:
+ break;
}
this->WriteProjectConfigurationValues(e0);
@@ -737,6 +736,8 @@
case VsProjectType::csproj:
props = VS10_CSharp_USER_PROPS;
break;
+ default:
+ break;
}
if (cmValue p = this->GeneratorTarget->GetProperty("VS_USER_PROPS")) {
props = *p;
@@ -779,6 +780,8 @@
Elem(e0, "Import").Attribute("Project", VS10_CSharp_TARGETS);
}
break;
+ default:
+ break;
}
this->WriteTargetSpecificReferences(e0);
@@ -944,6 +947,45 @@
this->WriteProjectReferences(e0);
}
+void cmVisualStudio10TargetGenerator::WriteZeroCheckProj(
+ cmGeneratedFileStream& BuildFileStream)
+{
+ // ZERO_CHECK.proj is an XML file without any imports or targets. This is a
+ // ProjectReference for other targets and therefore, it needs to follow the
+ // ProjectReference protocol as documented here:
+ // https://github.com/dotnet/msbuild/blob/main/documentation/ProjectReference-Protocol.md
+ //
+ // We implement MSBuild target Build from WriteCustomCommand which calls
+ // WriteZeroCheckBuildTarget after setting up the command generator. MSBuild
+ // target Clean is a no-op as we do all the work for ZERO_CHECK on Build.
+ // MSBuild target GetTargetPath is needed and is no-op.
+ // MSBuild targets GetNativeManifest and GetCopyToOutputDirectoryItems are
+ // needed for MSBuild versions below 15.7 and are no-op. MSBuild target
+ // BeforeBuild is needed for supporting GLOBs.
+ BuildFileStream << "<?xml version=\"1.0\" encoding=\""
+ << this->GlobalGenerator->Encoding() << "\"?>";
+ {
+ Elem e0(BuildFileStream, "Project");
+ e0.Attribute("DefaultTargets", "Build");
+ e0.Attribute("ToolsVersion", this->GlobalGenerator->GetToolsVersion());
+ e0.Attribute("xmlns",
+ "http://schemas.microsoft.com/developer/msbuild/2003");
+
+ this->WriteCustomCommands(e0);
+
+ for (const char* targetName :
+ { "Clean", "GetTargetPath", "GetNativeManifest",
+ "GetCopyToOutputDirectoryItems" }) {
+ {
+ Elem e1(e0, "Target");
+ e1.Attribute("Name", targetName);
+ }
+ }
+
+ this->WriteZeroCheckBeforeBuildTarget(e0);
+ }
+}
+
void cmVisualStudio10TargetGenerator::WriteCommonPropertyGroupGlobals(Elem& e1)
{
e1.Attribute("Label", "Globals");
@@ -1659,11 +1701,16 @@
}
}
}
+ if (this->ProjectType == VsProjectType::proj) {
+ this->WriteZeroCheckBuildTarget(e0, command, source);
+ return;
+ }
+
cmLocalVisualStudio7Generator* lg = this->LocalGenerator;
std::unique_ptr<Elem> spe1;
std::unique_ptr<Elem> spe2;
- if (this->ProjectType != VsProjectType::csproj) {
+ if (this->ProjectType == VsProjectType::vcxproj) {
spe1 = cm::make_unique<Elem>(e0, "ItemGroup");
spe2 = cm::make_unique<Elem>(*spe1, "CustomBuild");
this->WriteSource(*spe2, source);
@@ -1861,7 +1908,7 @@
// Write out group file
std::string path = cmStrCat(
this->LocalGenerator->GetCurrentBinaryDirectory(), '/', this->Name,
- computeProjectFileExtension(this->GeneratorTarget), ".filters");
+ this->ComputeProjectFileExtension(this->GeneratorTarget), ".filters");
cmGeneratedFileStream fout(path);
fout.SetCopyIfDifferent(true);
char magic[] = { char(0xEF), char(0xBB), char(0xBF) };
@@ -3016,6 +3063,134 @@
}
}
+void cmVisualStudio10TargetGenerator::WriteZeroCheckBuildTarget(
+ cmVisualStudio10TargetGenerator::Elem& e0, const cmCustomCommand& command,
+ const cmSourceFile* source)
+{
+ cmLocalVisualStudio7Generator* lg = this->LocalGenerator;
+
+ Elem e1(e0, "Target");
+ e1.Attribute("Name", "Build");
+
+ std::string noConfig{};
+ cmCustomCommandGenerator ccg{ command, noConfig, lg, true };
+ std::string comment = lg->ConstructComment(ccg);
+ comment = cmVS10EscapeComment(comment);
+ std::string script = lg->ConstructScript(ccg);
+ bool symbolic = false;
+ // input files for custom command
+ std::stringstream additional_inputs;
+ {
+ const char* sep = "";
+ if (this->ProjectType == VsProjectType::proj) {
+ // List explicitly the path to primary input.
+ std::string sourceFullPath = source->GetFullPath();
+ ConvertToWindowsSlash(sourceFullPath);
+ additional_inputs << sourceFullPath;
+ sep = ";";
+ }
+
+ // Avoid listing an input more than once.
+ std::set<std::string> unique_inputs;
+ // The source is either implicitly an input or has been added above.
+ unique_inputs.insert(source->GetFullPath());
+
+ for (std::string const& d : ccg.GetDepends()) {
+ std::string dep;
+ if (lg->GetRealDependency(d, noConfig, dep)) {
+ if (!unique_inputs.insert(dep).second) {
+ // already listed
+ continue;
+ }
+ ConvertToWindowsSlash(dep);
+ additional_inputs << sep << dep;
+ sep = ";";
+ if (!symbolic) {
+ if (cmSourceFile* sf = this->Makefile->GetSource(
+ dep, cmSourceFileLocationKind::Known)) {
+ symbolic = sf->GetPropertyAsBool("SYMBOLIC");
+ }
+ }
+ }
+ }
+ }
+ // output files for custom command
+ std::stringstream outputs;
+ {
+ const char* sep = "";
+ for (std::string const& o : ccg.GetOutputs()) {
+ std::string out = o;
+ ConvertToWindowsSlash(out);
+ outputs << sep << out;
+ sep = ";";
+ if (!symbolic) {
+ if (cmSourceFile* sf =
+ this->Makefile->GetSource(o, cmSourceFileLocationKind::Known)) {
+ symbolic = sf->GetPropertyAsBool("SYMBOLIC");
+ }
+ }
+ }
+ }
+ script += lg->FinishConstructScript(this->ProjectType);
+
+ e1.Attribute("Inputs", cmVS10EscapeAttr(additional_inputs.str()));
+ e1.Attribute("Outputs", cmVS10EscapeAttr(outputs.str()));
+
+ e1.SetHasElements();
+
+ if (!comment.empty()) {
+ Elem(e1, "Message").Attribute("Text", comment);
+ }
+ Elem(e1, "Exec").Attribute("Command", script);
+}
+
+void cmVisualStudio10TargetGenerator::WriteZeroCheckBeforeBuildTarget(
+ cmVisualStudio10TargetGenerator::Elem& e0)
+{
+ const auto& commands = this->GeneratorTarget->GetPreBuildCommands();
+ if (commands.empty()) {
+ return;
+ }
+
+ {
+ Elem e1(e0, "Target");
+ e1.Attribute("Name", "BeforeBuild");
+ e1.Attribute("BeforeTargets", "Build");
+
+ cmLocalVisualStudio7Generator* lg = this->LocalGenerator;
+ std::string script;
+ const char* pre = "";
+ std::string comment;
+ for (cmCustomCommand const& cc : commands) {
+ cmCustomCommandGenerator ccg(cc, std::string{}, lg);
+ if (!ccg.HasOnlyEmptyCommandLines()) {
+ comment += pre;
+ comment += lg->ConstructComment(ccg);
+ script += pre;
+ pre = "\n";
+ script += lg->ConstructScript(ccg);
+ }
+ }
+
+ if (script.empty()) {
+ return;
+ }
+
+ script += lg->FinishConstructScript(this->ProjectType);
+ comment = cmVS10EscapeComment(comment);
+ std::string strippedComment = comment;
+ strippedComment.erase(
+ std::remove(strippedComment.begin(), strippedComment.end(), '\t'),
+ strippedComment.end());
+
+ e1.SetHasElements();
+ if (!comment.empty() && !strippedComment.empty()) {
+ Elem(e1, "Message").Attribute("Text", comment);
+ }
+ Elem(e1, "Exec").Attribute("Command", script);
+ }
+}
+
std::vector<std::string> cmVisualStudio10TargetGenerator::GetIncludes(
std::string const& config, std::string const& lang) const
{
@@ -3057,6 +3232,8 @@
cm::make_unique<Options>(this->LocalGenerator, Options::CSharpCompiler,
gg->GetCSharpFlagTable());
break;
+ default:
+ break;
}
Options& clOptions = *pOptions;
@@ -3182,6 +3359,8 @@
return def.find('=') != std::string::npos;
});
break;
+ default:
+ break;
}
clOptions.AddDefines(targetDefines);
@@ -3309,7 +3488,9 @@
} else if (this->MSTools) {
cmsys::RegularExpression clangToolset("v[0-9]+_clang_.*");
const char* toolset = this->GlobalGenerator->GetPlatformToolset();
- if (toolset && clangToolset.find(toolset)) {
+ cmValue noCompileBatching =
+ this->GeneratorTarget->GetProperty("VS_NO_COMPILE_BATCHING");
+ if (noCompileBatching.IsOn() || (toolset && clangToolset.find(toolset))) {
e2.Element("ObjectFileName", "$(IntDir)%(filename).obj");
} else {
e2.Element("ObjectFileName", "$(IntDir)");
@@ -3688,7 +3869,8 @@
this->LocalGenerator->MaybeRelativeToCurBinDir(l.Value.Value);
ConvertToWindowsSlash(path);
if (!cmVS10IsTargetsFile(l.Value.Value)) {
- libVec.push_back(path);
+ libVec.push_back(l.HasFeature() ? l.GetFormattedItem(path).Value
+ : path);
}
} else {
libVec.push_back(l.Value.Value);
@@ -4305,6 +4487,9 @@
this->AdditionalUsingDirectories[config].insert(
cmSystemTools::GetFilenamePath(location));
break;
+ default:
+ // In .proj files, we wouldn't be referencing libraries.
+ break;
}
}
}
@@ -4326,7 +4511,8 @@
if (cmVS10IsTargetsFile(l.Value.Value)) {
vsTargetVec.push_back(path);
} else {
- libVec.push_back(path);
+ libVec.push_back(l.HasFeature() ? l.GetFormattedItem(path).Value
+ : path);
}
} else if (!l.Target ||
l.Target->GetType() != cmStateEnums::INTERFACE_LIBRARY) {
@@ -4533,7 +4719,7 @@
path = *p;
} else {
path = cmStrCat(lg->GetCurrentBinaryDirectory(), '/', dt->GetName(),
- computeProjectFileExtension(dt));
+ this->ComputeProjectFileExtension(dt));
}
ConvertToWindowsSlash(path);
Elem e2(e1, "ProjectReference");
@@ -5387,6 +5573,26 @@
return path;
}
+std::string cmVisualStudio10TargetGenerator::ComputeProjectFileExtension(
+ cmGeneratorTarget const* t) const
+{
+ return getProjectFileExtension(this->ComputeProjectType(t));
+}
+
+VsProjectType cmVisualStudio10TargetGenerator::ComputeProjectType(
+ cmGeneratorTarget const* t) const
+{
+ if (this->GlobalGenerator->GetVersion() >=
+ cmGlobalVisualStudioGenerator::VSVersion::VS16 &&
+ t->GetName() == CMAKE_CHECK_BUILD_SYSTEM_TARGET) {
+ return VsProjectType::proj;
+ }
+ if (t->IsCSharpOnly()) {
+ return VsProjectType::csproj;
+ }
+ return VsProjectType::vcxproj;
+}
+
void cmVisualStudio10TargetGenerator::WriteStdOutEncodingUtf8(Elem& e1)
{
if (this->GlobalGenerator->IsUtf8EncodingSupported()) {
diff --git a/Source/cmVisualStudio10TargetGenerator.h b/Source/cmVisualStudio10TargetGenerator.h
index 8d777a3..7a0b8da 100644
--- a/Source/cmVisualStudio10TargetGenerator.h
+++ b/Source/cmVisualStudio10TargetGenerator.h
@@ -264,6 +264,13 @@
void WriteClassicMsBuildProjectFile(cmGeneratedFileStream& BuildFileStream);
void WriteSdkStyleProjectFile(cmGeneratedFileStream& BuildFileStream);
+ void WriteZeroCheckProj(cmGeneratedFileStream& BuildFileStream);
+ void WriteZeroCheckBuildTarget(cmVisualStudio10TargetGenerator::Elem& e0,
+ const cmCustomCommand& command,
+ const cmSourceFile* source);
+ void WriteZeroCheckBeforeBuildTarget(
+ cmVisualStudio10TargetGenerator::Elem& e0);
+
void WriteCommonPropertyGroupGlobals(
cmVisualStudio10TargetGenerator::Elem& e1);
@@ -275,4 +282,7 @@
void ParseSettingsProperty(const std::string& settingsPropertyValue,
ConfigToSettings& toolSettings);
std::string GetCMakeFilePath(const char* name) const;
+
+ std::string ComputeProjectFileExtension(cmGeneratorTarget const* t) const;
+ VsProjectType ComputeProjectType(cmGeneratorTarget const* t) const;
};
diff --git a/Source/cmVisualStudioGeneratorOptions.cxx b/Source/cmVisualStudioGeneratorOptions.cxx
index 9045a4d..d5d08b8 100644
--- a/Source/cmVisualStudioGeneratorOptions.cxx
+++ b/Source/cmVisualStudioGeneratorOptions.cxx
@@ -182,7 +182,8 @@
// First entries for the -arch=<arch> [-code=<code>,...] pair.
if (!arch.empty()) {
std::string arch_name = arch[0];
- if (arch_name == "all" || arch_name == "all-major") {
+ if (arch_name == "all" || arch_name == "all-major" ||
+ arch_name == "native") {
AppendFlagString("AdditionalOptions", "-arch=" + arch_name);
return;
}
diff --git a/Source/cmVsProjectType.h b/Source/cmVsProjectType.h
index 8899267..04053a0 100644
--- a/Source/cmVsProjectType.h
+++ b/Source/cmVsProjectType.h
@@ -7,5 +7,6 @@
enum class VsProjectType
{
vcxproj,
- csproj
+ csproj,
+ proj,
};
diff --git a/Source/cmWhileCommand.cxx b/Source/cmWhileCommand.cxx
index a93a81f..68d5a9a 100644
--- a/Source/cmWhileCommand.cxx
+++ b/Source/cmWhileCommand.cxx
@@ -17,6 +17,8 @@
#include "cmMakefile.h"
#include "cmMessageType.h"
#include "cmOutputConverter.h"
+#include "cmPolicies.h"
+#include "cmStringAlgorithms.h"
#include "cmSystemTools.h"
#include "cmake.h"
@@ -79,9 +81,8 @@
return out;
};
- // FIXME(#23296): For compatibility with older versions of CMake, we
- // tolerate condition errors that evaluate to false. We should add
- // a policy to enforce such errors.
+ // For compatibility with projects that do not set CMP0130 to NEW,
+ // we tolerate condition errors that evaluate to false.
bool enforceError = true;
std::string errorString;
MessageType messageType;
@@ -110,14 +111,38 @@
}
}
+ if (!errorString.empty() && !enforceError) {
+ // This error should only be enforced if CMP0130 is NEW.
+ switch (mf.GetPolicyStatus(cmPolicies::CMP0130)) {
+ case cmPolicies::WARN:
+ // Convert the error to a warning and enforce it.
+ messageType = MessageType::AUTHOR_WARNING;
+ enforceError = true;
+ break;
+ case cmPolicies::OLD:
+ // OLD behavior is to silently ignore the error.
+ break;
+ case cmPolicies::REQUIRED_ALWAYS:
+ case cmPolicies::REQUIRED_IF_USED:
+ case cmPolicies::NEW:
+ // NEW behavior is to enforce the error.
+ enforceError = true;
+ break;
+ }
+ }
+
if (!errorString.empty() && enforceError) {
- std::string err = "had incorrect arguments:\n ";
+ std::string err = "while() given incorrect arguments:\n ";
for (auto const& i : expandedArguments) {
err += " ";
err += cmOutputConverter::EscapeForCMake(i.GetValue());
}
err += "\n";
err += errorString;
+ if (mf.GetPolicyStatus(cmPolicies::CMP0130) == cmPolicies::WARN) {
+ err =
+ cmStrCat(cmPolicies::GetPolicyWarning(cmPolicies::CMP0130), '\n', err);
+ }
mf.GetCMakeInstance()->IssueMessage(messageType, err, whileBT);
if (messageType == MessageType::FATAL_ERROR) {
cmSystemTools::SetFatalErrorOccured();
diff --git a/Source/cmake.cxx b/Source/cmake.cxx
index 7de488b..a602458 100644
--- a/Source/cmake.cxx
+++ b/Source/cmake.cxx
@@ -1158,6 +1158,12 @@
// iterate each argument
std::string const& arg = args[i];
+ if (scriptMode && arg == "--") {
+ // Stop processing CMake args and avoid possible errors
+ // when arbitrary args are given to CMake script.
+ break;
+ }
+
// Generator flag has special handling for when to print help
// so it becomes the exception
if (generatorCommand.matches(arg)) {
@@ -1455,7 +1461,7 @@
Json::StreamWriterBuilder builder;
builder["indentation"] = "";
version["major"] = 1;
- version["minor"] = 1;
+ version["minor"] = 2;
val["version"] = version;
msg = Json::writeString(builder, val);
#endif
diff --git a/Source/cmcmd.cxx b/Source/cmcmd.cxx
index 32c01e5..f1c1bdc 100644
--- a/Source/cmcmd.cxx
+++ b/Source/cmcmd.cxx
@@ -97,7 +97,8 @@
<< "Available commands: \n"
<< " capabilities - Report capabilities built into cmake "
"in JSON format\n"
- << " cat <files>... - concat the files and print them to the standard output\n"
+ << " cat [--] <files>... - concat the files and print them to the "
+ "standard output\n"
<< " chdir dir cmd [args...] - run command in a given directory\n"
<< " compare_files [--ignore-eol] file1 file2\n"
<< " - check if file1 is same as file2\n"
@@ -110,7 +111,7 @@
<< " echo [<string>...] - displays arguments as text\n"
<< " echo_append [<string>...] - displays arguments as text but no new "
"line\n"
- << " env [--unset=NAME]... [NAME=VALUE]... COMMAND [ARG]...\n"
+ << " env [--unset=NAME ...] [NAME=VALUE ...] [--] <command> [<arg>...]\n"
<< " - run command in a modified environment\n"
<< " environment - display the current environment\n"
<< " make_directory <dir>... - create parent and <dir> directories\n"
@@ -125,8 +126,9 @@
<< " remove_directory <dir>... - remove directories and their contents (deprecated: use rm instead)\n"
<< " rename oldname newname - rename a file or directory "
"(on one volume)\n"
- << " rm [-rRf] <file/dir>... - remove files or directories, use -f to "
- "force it, r or R to remove directories and their contents recursively\n"
+ << " rm [-rRf] [--] <file/dir>... - remove files or directories, use -f "
+ "to force it, r or R to remove directories and their contents "
+ "recursively\n"
<< " sleep <number>... - sleep for given number of seconds\n"
<< " tar [cxt][vf][zjJ] file.tar [file/dir1 file/dir2 ...]\n"
<< " - create or extract a tar or zip archive\n"
@@ -793,6 +795,12 @@
auto ae = args.cend();
for (; ai != ae; ++ai) {
std::string const& a = *ai;
+ if (a == "--") {
+ // Stop parsing options/environment variables; the next argument
+ // should be the command.
+ ++ai;
+ break;
+ }
if (cmHasLiteralPrefix(a, "--unset=")) {
// Unset environment variable.
cmSystemTools::UnPutEnv(a.substr(8));
@@ -1051,9 +1059,12 @@
// Command to concat files into one
if (args[1] == "cat" && args.size() >= 3) {
int return_value = 0;
+ bool doing_options = true;
for (auto const& arg : cmMakeRange(args).advance(2)) {
- if (cmHasLiteralPrefix(arg, "-")) {
- if (arg != "--") {
+ if (doing_options && cmHasLiteralPrefix(arg, "-")) {
+ if (arg == "--") {
+ doing_options = false;
+ } else {
cmSystemTools::Error(arg + ": option not handled");
return_value = 1;
}
@@ -1275,8 +1286,7 @@
// FIXME: With advanced add_subdirectory usage, these are
// not necessarily the same as the generator originally used.
// We should pass all these directories through an info file.
- lgd->SetRelativePathTopSource(homeDir);
- lgd->SetRelativePathTopBinary(homeOutDir);
+ lgd->SetRelativePathTop(homeDir, homeOutDir);
// Actually scan dependencies.
return lgd->UpdateDependencies(depInfo, verbose, color) ? 0 : 2;
@@ -1558,8 +1568,7 @@
// FIXME: With advanced add_subdirectory usage, these are
// not necessarily the same as the generator originally used.
// We should pass all these directories through an info file.
- lgd->SetRelativePathTopSource(homeDir);
- lgd->SetRelativePathTopBinary(homeOutDir);
+ lgd->SetRelativePathTop(homeDir, homeOutDir);
return cmTransformDepfile(format, *lgd, args[8], args[9]) ? 0 : 2;
}
diff --git a/Source/ctest.cxx b/Source/ctest.cxx
index cad27fa..363f473 100644
--- a/Source/ctest.cxx
+++ b/Source/ctest.cxx
@@ -44,6 +44,9 @@
{ "--test-output-size-failed <size>",
"Limit the output for failed tests "
"to <size> bytes" },
+ { "--test-output-truncation <mode>",
+ "Truncate 'tail' (default), 'middle' or 'head' of test output once "
+ "maximum output size is reached" },
{ "-F", "Enable failover." },
{ "-j <jobs>, --parallel <jobs>",
"Run the tests in parallel using the "
diff --git a/Source/kwsys/ProcessUNIX.c b/Source/kwsys/ProcessUNIX.c
index 19bf982..22cbf06 100644
--- a/Source/kwsys/ProcessUNIX.c
+++ b/Source/kwsys/ProcessUNIX.c
@@ -1906,7 +1906,7 @@
(errno == EINTR)) {
}
if (result > 0) {
- /* This child has termianted. */
+ /* This child has terminated. */
cp->ForkPIDs[i] = 0;
if (--cp->CommandsLeft == 0) {
/* All children have terminated. Close the signal pipe
diff --git a/Source/kwsys/ProcessWin32.c b/Source/kwsys/ProcessWin32.c
index e97973e..17e1507 100644
--- a/Source/kwsys/ProcessWin32.c
+++ b/Source/kwsys/ProcessWin32.c
@@ -2119,7 +2119,7 @@
KWSYSPE_CASE(Fault, "In-page error");
break;
case STATUS_INVALID_HANDLE:
- KWSYSPE_CASE(Fault, "Invalid hanlde");
+ KWSYSPE_CASE(Fault, "Invalid handle");
break;
case STATUS_NONCONTINUABLE_EXCEPTION:
KWSYSPE_CASE(Fault, "Noncontinuable exception");
diff --git a/Tests/CMakeLists.txt b/Tests/CMakeLists.txt
index 6946ffb..e39cdaf 100644
--- a/Tests/CMakeLists.txt
+++ b/Tests/CMakeLists.txt
@@ -294,26 +294,6 @@
mark_as_advanced(CTEST_TEST_CTEST)
endif ()
- # Should tests that use CVS be run?
- #
- set(do_cvs_tests 0)
-
- if(EXISTS ${CMAKE_ROOT}/Modules/FindCVS.cmake)
- find_package(CVS QUIET)
- else()
- find_program(CVS_EXECUTABLE NAMES cvs)
- endif()
-
- if(CVS_EXECUTABLE)
- set(do_cvs_tests 1)
- endif()
-
- if(do_cvs_tests AND NOT UNIX)
- if("${CVS_EXECUTABLE}" MATCHES "cygwin")
- set(do_cvs_tests 0)
- endif()
- endif()
-
# Should CPack tests be run? By default, yes, but...
#
# Disable packaging test on Apple 10.3 and below. PackageMaker starts
@@ -1574,6 +1554,12 @@
ADD_TEST_MACRO(FindMatlab.targets_checks ${CMAKE_CTEST_COMMAND} -V -C $<CONFIGURATION>)
endif()
+ set(ExternalProject_BUILD_OPTIONS "")
+ foreach(vcs CVS SVN GIT HG)
+ if(DEFINED CMake_TEST_ExternalProject_${vcs})
+ list(APPEND ExternalProject_BUILD_OPTIONS -DEP_TEST_${vcs}=${CMake_TEST_ExternalProject_${vcs}})
+ endif()
+ endforeach()
add_test(ExternalProject ${CMAKE_CTEST_COMMAND}
--build-and-test
"${CMake_SOURCE_DIR}/Tests/ExternalProject"
@@ -1582,6 +1568,7 @@
--build-project ExternalProjectTest
--build-exe-dir "${CMake_BINARY_DIR}/Tests/ExternalProject"
--force-new-ctest-process
+ --build-options ${ExternalProject_BUILD_OPTIONS}
--test-command ${CMAKE_CTEST_COMMAND} -V
)
list(APPEND TEST_BUILD_DIRS "${CMake_BINARY_DIR}/Tests/ExternalProject")
@@ -2332,7 +2319,7 @@
endmacro()
macro(add_test_GhsMulti_rename_install test_name)
add_test_GhsMulti( ${test_name} GhsMultiRenameInstall ${test_name}
- "-DCMAKE_INSTALL_PREFIX=. -DRUN_TEST=${test_name}" ${CMAKE_CMAKE_COMMAND} --build . --target install)
+ "-DCMAKE_INSTALL_PREFIX=. -DRUN_TEST=${test_name}" ${CMAKE_CMAKE_COMMAND} --build . --target INSTALL)
endmacro()
#unset ghs config variables
unset(ghs_config_name)
@@ -2562,27 +2549,8 @@
# -S "${CMake_BINARY_DIR}/Tests/CTestScriptMode/CTestTestScriptMode.cmake"
# )
- # A test for ctest_build() with targets in subdirectories
- set(ctest_configure_options)
- if(CMAKE_GENERATOR_PLATFORM)
- list(APPEND ctest_configure_options -A ${CMAKE_GENERATOR_PLATFORM})
- endif()
- if(CMAKE_GENERATOR_TOOLSET)
- list(APPEND ctest_configure_options -T ${CMAKE_GENERATOR_TOOLSET})
- endif()
- if(CMake_TEST_EXPLICIT_MAKE_PROGRAM)
- list(APPEND ctest_configure_options -DCMAKE_MAKE_PROGRAM:FILEPATH=${CMake_TEST_EXPLICIT_MAKE_PROGRAM})
- endif()
- configure_file("${CMake_SOURCE_DIR}/Tests/CTestBuildCommandProjectInSubdir/CTestBuildCommandProjectInSubdir.cmake.in"
- "${CMake_BINARY_DIR}/Tests/CTestBuildCommandProjectInSubdir/CTestBuildCommandProjectInSubdir.cmake" @ONLY)
- unset(ctest_configure_options)
- add_test(CTest.BuildCommand.ProjectInSubdir
- ${CMAKE_CTEST_COMMAND} -S "${CMake_BINARY_DIR}/Tests/CTestBuildCommandProjectInSubdir/CTestBuildCommandProjectInSubdir.cmake")
- list(APPEND TEST_BUILD_DIRS "${CMake_BINARY_DIR}/Tests/CTestBuildCommandProjectInSubdir/Nested")
-
- set(CTEST_TEST_UPDATE 1)
- if(CTEST_TEST_UPDATE)
- # Test CTest Update with Subversion
+ # Test CTest Update with Subversion
+ if(NOT DEFINED CMake_TEST_CTestUpdate_SVN OR CMake_TEST_CTestUpdate_SVN)
find_package(Subversion QUIET)
if(Subversion_FOUND)
get_filename_component(_Subversion_BIN_DIR
@@ -2595,129 +2563,131 @@
set(Subversion_FOUND FALSE)
endif()
endif()
- if(Subversion_FOUND)
- set(CTestUpdateSVN_DIR "CTest UpdateSVN")
- configure_file("${CMake_SOURCE_DIR}/Tests/CTestUpdateSVN.cmake.in"
- "${CMake_BINARY_DIR}/Tests/CTestUpdateSVN.cmake" @ONLY)
- add_test(CTest.UpdateSVN ${CMAKE_CMAKE_COMMAND}
- -P "${CMake_BINARY_DIR}/Tests/CTestUpdateSVN.cmake"
- )
- list(APPEND TEST_BUILD_DIRS "${CMake_BINARY_DIR}/Tests/${CTestUpdateSVN_DIR}")
+ endif()
+ if(NOT DEFINED CMake_TEST_CTestUpdate_SVN AND Subversion_FOUND)
+ set(CMake_TEST_CTestUpdate_SVN 1)
+ endif()
+ if(CMake_TEST_CTestUpdate_SVN)
+ if(NOT Subversion_FOUND)
+ message(FATAL_ERROR "CMake_TEST_CTestUpdate_SVN enabled but Subversion is not found.")
endif()
+ set(CTestUpdateSVN_DIR "CTest UpdateSVN")
+ configure_file("${CMake_SOURCE_DIR}/Tests/CTestUpdateSVN.cmake.in"
+ "${CMake_BINARY_DIR}/Tests/CTestUpdateSVN.cmake" @ONLY)
+ add_test(CTest.UpdateSVN ${CMAKE_CMAKE_COMMAND}
+ -P "${CMake_BINARY_DIR}/Tests/CTestUpdateSVN.cmake"
+ )
+ list(APPEND TEST_BUILD_DIRS "${CMake_BINARY_DIR}/Tests/${CTestUpdateSVN_DIR}")
+ endif()
- # Test CTest Update with CVS
- if(EXISTS ${CMAKE_ROOT}/Modules/FindCVS.cmake)
- find_package(CVS QUIET)
- else()
- find_program(CVS_EXECUTABLE NAMES cvs)
- set(CVS_FOUND ${CVS_EXECUTABLE})
+ # Test CTest Update with CVS
+ if(NOT DEFINED CMake_TEST_CTestUpdate_CVS OR CMake_TEST_CTestUpdate_CVS)
+ find_program(CVS_EXECUTABLE NAMES cvs)
+ mark_as_advanced(CVS_EXECUTABLE)
+ endif()
+ if(NOT DEFINED CMake_TEST_CTestUpdate_CVS AND CVS_EXECUTABLE
+ AND (UNIX OR NOT "${CVS_EXECUTABLE}" MATCHES "cygwin"))
+ set(CMake_TEST_CTestUpdate_CVS 1)
+ endif()
+ if(CMake_TEST_CTestUpdate_CVS)
+ if(NOT CVS_EXECUTABLE)
+ message(FATAL_ERROR "CMake_TEST_CTestUpdate_CVS enabled but CVS_EXECUTABLE is not found.")
endif()
- set(CTEST_TEST_UPDATE_CVS ${CVS_FOUND})
- if(CTEST_TEST_UPDATE_CVS AND NOT UNIX)
- if("${CVS_EXECUTABLE}" MATCHES "cygwin")
- message(STATUS "No CTest.UpdateCVS test with cygwin cvs.exe outside cygwin!")
- set(CTEST_TEST_UPDATE_CVS 0)
- endif()
- endif()
- if(CTEST_TEST_UPDATE_CVS)
- set(CTestUpdateCVS_DIR "CTest UpdateCVS")
- configure_file("${CMake_SOURCE_DIR}/Tests/CTestUpdateCVS.cmake.in"
- "${CMake_BINARY_DIR}/Tests/CTestUpdateCVS.cmake" @ONLY)
- add_test(CTest.UpdateCVS ${CMAKE_CMAKE_COMMAND}
- -P "${CMake_BINARY_DIR}/Tests/CTestUpdateCVS.cmake"
- )
- list(APPEND TEST_BUILD_DIRS "${CMake_BINARY_DIR}/Tests/${CTestUpdateCVS_DIR}")
- endif()
+ set(CTestUpdateCVS_DIR "CTest UpdateCVS")
+ configure_file("${CMake_SOURCE_DIR}/Tests/CTestUpdateCVS.cmake.in"
+ "${CMake_BINARY_DIR}/Tests/CTestUpdateCVS.cmake" @ONLY)
+ add_test(CTest.UpdateCVS ${CMAKE_CMAKE_COMMAND}
+ -P "${CMake_BINARY_DIR}/Tests/CTestUpdateCVS.cmake"
+ )
+ list(APPEND TEST_BUILD_DIRS "${CMake_BINARY_DIR}/Tests/${CTestUpdateCVS_DIR}")
+ endif()
- # Test CTest Update with BZR
+ # Test CTest Update with BZR
+ if(CMake_TEST_CTestUpdate_BZR)
+ if(TEST_HOME)
+ file(MAKE_DIRECTORY "${TEST_HOME}/.bazaar")
+ endif()
find_program(BZR_EXECUTABLE NAMES bzr)
mark_as_advanced(BZR_EXECUTABLE)
- set(CTEST_TEST_UPDATE_BZR 0)
- if(BZR_EXECUTABLE)
- if(NOT "${BZR_EXECUTABLE}" MATCHES "cygwin" OR UNIX)
- set(CTEST_TEST_UPDATE_BZR 1)
- endif()
+ if(NOT BZR_EXECUTABLE)
+ message(FATAL_ERROR "CMake_TEST_CTestUpdate_BZR enabled but BZR_EXECUTABLE is not found.")
endif()
- if(CTEST_TEST_UPDATE_BZR)
- # Check if xmloutput plugin is there
- execute_process(COMMAND ${BZR_EXECUTABLE} xmlplugins RESULT_VARIABLE xmlplugres
- OUTPUT_QUIET ERROR_QUIET)
- if( NOT ${xmlplugres} )
- set(CTestUpdateBZR_DIR "CTest UpdateBZR")
- configure_file("${CMake_SOURCE_DIR}/Tests/CTestUpdateBZR.cmake.in"
- "${CMake_BINARY_DIR}/Tests/CTestUpdateBZR.cmake" @ONLY)
- add_test(CTest.UpdateBZR ${CMAKE_CMAKE_COMMAND}
- -P "${CMake_BINARY_DIR}/Tests/CTestUpdateBZR.cmake"
- )
- list(APPEND TEST_BUILD_DIRS "${CMake_BINARY_DIR}/Tests/${CTestUpdateBZR_DIR}")
- set(CTestUpdateBZR_DIR "CTest UpdateBZR_CLocale")
- configure_file("${CMake_SOURCE_DIR}/Tests/CTestUpdateBZR.cmake.in"
- "${CMake_BINARY_DIR}/Tests/CTestUpdateBZR_CLocale.cmake" @ONLY)
- add_test(CTest.UpdateBZR.CLocale ${CMAKE_CMAKE_COMMAND}
- -P "${CMake_BINARY_DIR}/Tests/CTestUpdateBZR_CLocale.cmake"
- )
- set_tests_properties(CTest.UpdateBZR.CLocale PROPERTIES ENVIRONMENT LC_ALL=C)
- list(APPEND TEST_BUILD_DIRS "${CMake_BINARY_DIR}/Tests/${CTestUpdateBZR_DIR}")
- endif()
- endif()
+ set(CTestUpdateBZR_DIR "CTest UpdateBZR")
+ configure_file("${CMake_SOURCE_DIR}/Tests/CTestUpdateBZR.cmake.in"
+ "${CMake_BINARY_DIR}/Tests/CTestUpdateBZR.cmake" @ONLY)
+ add_test(CTest.UpdateBZR ${CMAKE_CMAKE_COMMAND}
+ -P "${CMake_BINARY_DIR}/Tests/CTestUpdateBZR.cmake"
+ )
+ list(APPEND TEST_BUILD_DIRS "${CMake_BINARY_DIR}/Tests/${CTestUpdateBZR_DIR}")
+ set(CTestUpdateBZR_DIR "CTest UpdateBZR_CLocale")
+ configure_file("${CMake_SOURCE_DIR}/Tests/CTestUpdateBZR.cmake.in"
+ "${CMake_BINARY_DIR}/Tests/CTestUpdateBZR_CLocale.cmake" @ONLY)
+ add_test(CTest.UpdateBZR.CLocale ${CMAKE_CMAKE_COMMAND}
+ -P "${CMake_BINARY_DIR}/Tests/CTestUpdateBZR_CLocale.cmake"
+ )
+ set_tests_properties(CTest.UpdateBZR.CLocale PROPERTIES ENVIRONMENT LC_ALL=C)
+ list(APPEND TEST_BUILD_DIRS "${CMake_BINARY_DIR}/Tests/${CTestUpdateBZR_DIR}")
+ endif()
- # Test CTest Update with GIT
+ # Test CTest Update with GIT
+ if(NOT DEFINED CMake_TEST_CTestUpdate_GIT OR CMake_TEST_CTestUpdate_GIT)
find_program(GIT_EXECUTABLE NAMES git)
mark_as_advanced(GIT_EXECUTABLE)
- set(CTEST_TEST_UPDATE_GIT 0)
- if(GIT_EXECUTABLE)
- if(NOT "${GIT_EXECUTABLE}" MATCHES "cygwin" OR UNIX)
- set(CTEST_TEST_UPDATE_GIT 1)
- endif()
+ endif()
+ if(NOT DEFINED CMake_TEST_CTestUpdate_GIT AND GIT_EXECUTABLE
+ AND (UNIX OR NOT "${GIT_EXECUTABLE}" MATCHES "cygwin"))
+ set(CMake_TEST_CTestUpdate_GIT 1)
+ endif()
+ if(CMake_TEST_CTestUpdate_GIT)
+ if(NOT GIT_EXECUTABLE)
+ message(FATAL_ERROR "CMake_TEST_CTestUpdate_GIT enabled but GIT_EXECUTABLE is not found.")
endif()
- if(CTEST_TEST_UPDATE_GIT)
- set(CTestUpdateGIT_DIR "CTest UpdateGIT")
- configure_file("${CMake_SOURCE_DIR}/Tests/CTestUpdateGIT.cmake.in"
- "${CMake_BINARY_DIR}/Tests/CTestUpdateGIT.cmake" @ONLY)
- add_test(CTest.UpdateGIT ${CMAKE_CMAKE_COMMAND}
- -P "${CMake_BINARY_DIR}/Tests/CTestUpdateGIT.cmake"
- )
- list(APPEND TEST_BUILD_DIRS "${CMake_BINARY_DIR}/Tests/${CTestUpdateGIT_DIR}")
- endif()
+ set(CTestUpdateGIT_DIR "CTest UpdateGIT")
+ configure_file("${CMake_SOURCE_DIR}/Tests/CTestUpdateGIT.cmake.in"
+ "${CMake_BINARY_DIR}/Tests/CTestUpdateGIT.cmake" @ONLY)
+ add_test(CTest.UpdateGIT ${CMAKE_CMAKE_COMMAND}
+ -P "${CMake_BINARY_DIR}/Tests/CTestUpdateGIT.cmake"
+ )
+ list(APPEND TEST_BUILD_DIRS "${CMake_BINARY_DIR}/Tests/${CTestUpdateGIT_DIR}")
+ endif()
- # Test CTest Update with HG
+ # Test CTest Update with HG
+ if(NOT DEFINED CMake_TEST_CTestUpdate_HG OR CMake_TEST_CTestUpdate_HG)
find_program(HG_EXECUTABLE NAMES hg)
mark_as_advanced(HG_EXECUTABLE)
- set(CTEST_TEST_UPDATE_HG 0)
- if(HG_EXECUTABLE)
- if(NOT "${HG_EXECUTABLE}" MATCHES "cygwin" OR UNIX)
- set(CTEST_TEST_UPDATE_HG 1)
- endif()
+ endif()
+ if(NOT DEFINED CMake_TEST_CTestUpdate_HG AND HG_EXECUTABLE
+ AND (UNIX OR NOT "${HG_EXECUTABLE}" MATCHES "cygwin"))
+ set(CMake_TEST_CTestUpdate_HG 1)
+ endif()
+ if(CMake_TEST_CTestUpdate_HG)
+ if(NOT HG_EXECUTABLE)
+ message(FATAL_ERROR "CMake_TEST_CTestUpdate_HG enabled but HG_EXECUTABLE is not found.")
endif()
- if(CTEST_TEST_UPDATE_HG)
- set(CTestUpdateHG_DIR "CTest UpdateHG")
- configure_file("${CMake_SOURCE_DIR}/Tests/CTestUpdateHG.cmake.in"
- "${CMake_BINARY_DIR}/Tests/CTestUpdateHG.cmake" @ONLY)
- add_test(CTest.UpdateHG ${CMAKE_CMAKE_COMMAND}
- -P "${CMake_BINARY_DIR}/Tests/CTestUpdateHG.cmake"
- )
- list(APPEND TEST_BUILD_DIRS "${CMake_BINARY_DIR}/Tests/${CTestUpdateHG_DIR}")
- endif()
+ set(CTestUpdateHG_DIR "CTest UpdateHG")
+ configure_file("${CMake_SOURCE_DIR}/Tests/CTestUpdateHG.cmake.in"
+ "${CMake_BINARY_DIR}/Tests/CTestUpdateHG.cmake" @ONLY)
+ add_test(CTest.UpdateHG ${CMAKE_CMAKE_COMMAND}
+ -P "${CMake_BINARY_DIR}/Tests/CTestUpdateHG.cmake"
+ )
+ list(APPEND TEST_BUILD_DIRS "${CMake_BINARY_DIR}/Tests/${CTestUpdateHG_DIR}")
+ endif()
- # Test CTest Update with P4
+ # Test CTest Update with P4
+ if(CMake_TEST_CTestUpdate_P4)
find_program(P4_EXECUTABLE NAMES p4)
find_program(P4D_EXECUTABLE NAMES p4d)
mark_as_advanced(P4_EXECUTABLE P4D_EXECUTABLE)
- set(CTEST_TEST_UPDATE_P4 0)
- if(P4_EXECUTABLE AND P4D_EXECUTABLE)
- if(NOT "${P4_EXECUTABLE};${P4D_EXECUTABLE}" MATCHES "cygwin" OR UNIX)
- set(CTEST_TEST_UPDATE_P4 1)
- endif()
+ if(NOT P4_EXECUTABLE OR NOT P4D_EXECUTABLE)
+ message(FATAL_ERROR "CMake_TEST_CTestUpdate_HG enabled but P4_EXECUTABLE and P4D_EXECUTABLE are not both not found.")
endif()
- if(CTEST_TEST_UPDATE_P4)
- set(CTestUpdateP4_DIR "CTest UpdateP4")
- configure_file("${CMake_SOURCE_DIR}/Tests/CTestUpdateP4.cmake.in"
- "${CMake_BINARY_DIR}/Tests/CTestUpdateP4.cmake" @ONLY)
- add_test(CTest.UpdateP4 ${CMAKE_CMAKE_COMMAND}
- -P "${CMake_BINARY_DIR}/Tests/CTestUpdateP4.cmake"
- )
- list(APPEND TEST_BUILD_DIRS "${CMake_BINARY_DIR}/Tests/${CTestUpdateP4_DIR}")
- endif()
+ set(CTestUpdateP4_DIR "CTest UpdateP4")
+ configure_file("${CMake_SOURCE_DIR}/Tests/CTestUpdateP4.cmake.in"
+ "${CMake_BINARY_DIR}/Tests/CTestUpdateP4.cmake" @ONLY)
+ add_test(CTest.UpdateP4 ${CMAKE_CMAKE_COMMAND}
+ -P "${CMake_BINARY_DIR}/Tests/CTestUpdateP4.cmake"
+ )
+ list(APPEND TEST_BUILD_DIRS "${CMake_BINARY_DIR}/Tests/${CTestUpdateP4_DIR}")
endif()
configure_file(
@@ -3029,7 +2999,7 @@
-C "\${CTestTest_CONFIG}"
)
set_property(TEST CTestTestVerboseOutput PROPERTY PASS_REGULAR_EXPRESSION
- "Environment variables:.*foo=bar.*this=that"
+ "Test command:.*Working Directory:.*Environment variables:.*foo=bar.*this=that"
)
configure_file(
diff --git a/Tests/CMakeTests/FileDownloadTest.cmake.in b/Tests/CMakeTests/FileDownloadTest.cmake.in
index e0ce99a..255909d 100644
--- a/Tests/CMakeTests/FileDownloadTest.cmake.in
+++ b/Tests/CMakeTests/FileDownloadTest.cmake.in
@@ -179,3 +179,51 @@
message(SEND_ERROR "TIMEOUT argument was incorrectly interpreted as a filename")
endif()
message(STATUS "${status}")
+
+message(STATUS "FileDownload:14")
+file(DOWNLOAD
+ ${url}
+ ${dir}/file14.bin
+ TIMEOUT ${timeout}
+ STATUS status
+ RANGE_START 0
+ EXPECTED_MD5 dbd330d52f4dbd60115d4191904ded92
+ )
+__reportIfWrongStatus("${status}" 0)
+
+message(STATUS "FileDownload:15")
+file(DOWNLOAD
+ ${url}
+ ${dir}/file15.bin
+ TIMEOUT ${timeout}
+ STATUS status
+ RANGE_END 50
+ EXPECTED_MD5 8592e5665b839b5d23825dc84c135b61
+ )
+__reportIfWrongStatus("${status}" 0)
+
+message(STATUS "FileDownload:16")
+file(DOWNLOAD
+ ${url}
+ ${dir}/file16.bin
+ TIMEOUT ${timeout}
+ STATUS status
+ RANGE_START 10
+ RANGE_END 50
+ EXPECTED_MD5 36cd52681e6c6c8fef85fcd9e86fc30d
+ )
+__reportIfWrongStatus("${status}" 0)
+
+message(STATUS "FileDownload:17")
+file(DOWNLOAD
+ ${url}
+ ${dir}/file17.bin
+ TIMEOUT ${timeout}
+ STATUS status
+ RANGE_START 0
+ RANGE_END 50
+ RANGE_START 60
+ RANGE_END 100
+ EXPECTED_MD5 c5c9e74e82d493dd901eecccd659cebc
+ )
+__reportIfWrongStatus("${status}" 0)
diff --git a/Tests/CTestBuildCommandProjectInSubdir/CTestBuildCommandProjectInSubdir.cmake.in b/Tests/CTestBuildCommandProjectInSubdir/CTestBuildCommandProjectInSubdir.cmake.in
deleted file mode 100644
index 0f56781..0000000
--- a/Tests/CTestBuildCommandProjectInSubdir/CTestBuildCommandProjectInSubdir.cmake.in
+++ /dev/null
@@ -1,11 +0,0 @@
-cmake_minimum_required(VERSION 2.8.10)
-
-set(CTEST_SOURCE_DIRECTORY "@CMake_SOURCE_DIR@/Tests/VSProjectInSubdir")
-set(CTEST_BINARY_DIRECTORY "@CMake_BINARY_DIR@/Tests/CTestBuildCommandProjectInSubdir/Nested")
-set(CTEST_CMAKE_GENERATOR "@CMAKE_GENERATOR@")
-set(CTEST_BUILD_CONFIGURATION "@CTestTest_CONFIG@")
-
-ctest_empty_binary_directory(${CTEST_BINARY_DIRECTORY})
-ctest_start(Experimental)
-ctest_configure(OPTIONS "@ctest_configure_options@")
-ctest_build(TARGET test)
diff --git a/Tests/CTestUpdateP4.cmake.in b/Tests/CTestUpdateP4.cmake.in
index 5eef9fb..8a99e67 100644
--- a/Tests/CTestUpdateP4.cmake.in
+++ b/Tests/CTestUpdateP4.cmake.in
@@ -66,6 +66,7 @@
fi
done
echo 'Gave up waiting for server to start.'
+sed 's/^/ /' '${P4_ROOT}/p4.log'
"
)
endif()
@@ -258,4 +259,4 @@
run_child(
WORKING_DIRECTORY ${TOP}
COMMAND ${P4CMD} admin stop
-)
\ No newline at end of file
+)
diff --git a/Tests/CudaOnly/All/CMakeLists.txt b/Tests/CudaOnly/ArchSpecial/CMakeLists.txt
similarity index 74%
rename from Tests/CudaOnly/All/CMakeLists.txt
rename to Tests/CudaOnly/ArchSpecial/CMakeLists.txt
index ba32e9a..46f4ada 100644
--- a/Tests/CudaOnly/All/CMakeLists.txt
+++ b/Tests/CudaOnly/ArchSpecial/CMakeLists.txt
@@ -1,5 +1,5 @@
cmake_minimum_required(VERSION 3.20)
-project(CudaOnlyAll CUDA)
+project(ArchSpecial CUDA)
if(CMAKE_CUDA_COMPILER_ID STREQUAL "NVIDIA" AND
CMAKE_CUDA_COMPILER_VERSION VERSION_GREATER_EQUAL 8.0)
@@ -25,6 +25,7 @@
endforeach()
list(SORT command_archs)
+ list(REMOVE_DUPLICATES command_archs)
if(NOT "${command_archs}" STREQUAL "${architectures}")
message(FATAL_ERROR "Architectures used for \"${flag}\" don't match the reference (\"${command_archs}\" != \"${architectures}\").")
endif()
@@ -50,7 +51,17 @@
)
verify_output(all-major)
-if(all_archs_compiles AND all_major_archs_compiles)
- add_executable(CudaOnlyAll main.cu)
- target_compile_options(CudaOnlyAll PRIVATE ${compile_options})
+set(CMAKE_CUDA_ARCHITECTURES native)
+try_compile(native_archs_compiles
+ ${CMAKE_CURRENT_BINARY_DIR}/try_compile/native_archs_compiles
+ ${CMAKE_CURRENT_SOURCE_DIR}/main.cu
+ COMPILE_DEFINITIONS ${try_compile_flags}
+ OUTPUT_VARIABLE output
+ )
+verify_output(native)
+
+if(all_archs_compiles AND all_major_archs_compiles AND native_archs_compiles)
+ set(CMAKE_CUDA_ARCHITECTURES all)
+ add_executable(CudaOnlyArchSpecial main.cu)
+ target_compile_options(CudaOnlyArchSpecial PRIVATE ${compile_options})
endif()
diff --git a/Tests/CudaOnly/All/main.cu b/Tests/CudaOnly/ArchSpecial/main.cu
similarity index 100%
rename from Tests/CudaOnly/All/main.cu
rename to Tests/CudaOnly/ArchSpecial/main.cu
diff --git a/Tests/CudaOnly/CMakeLists.txt b/Tests/CudaOnly/CMakeLists.txt
index cacfb76..aa4755d 100644
--- a/Tests/CudaOnly/CMakeLists.txt
+++ b/Tests/CudaOnly/CMakeLists.txt
@@ -4,8 +4,8 @@
PROPERTY LABELS "CUDA")
endmacro ()
-add_cuda_test_macro(CudaOnly.All CudaOnlyAll)
add_cuda_test_macro(CudaOnly.Architecture Architecture)
+add_cuda_test_macro(CudaOnly.ArchSpecial CudaOnlyArchSpecial)
add_cuda_test_macro(CudaOnly.CompileFlags CudaOnlyCompileFlags)
add_cuda_test_macro(CudaOnly.EnableStandard CudaOnlyEnableStandard)
diff --git a/Tests/ExternalProject/CMakeLists.txt b/Tests/ExternalProject/CMakeLists.txt
index 59e3bcc..e4c6c66 100644
--- a/Tests/ExternalProject/CMakeLists.txt
+++ b/Tests/ExternalProject/CMakeLists.txt
@@ -8,10 +8,50 @@
# Test ExternalProject, especially with checkouts from VCS
-find_package(CVS)
-find_package(Subversion)
-find_package(Git)
-find_package(Hg)
+if(NOT DEFINED EP_TEST_CVS OR EP_TEST_CVS)
+ find_package(CVS)
+endif()
+if(NOT DEFINED EP_TEST_CVS AND CVS_FOUND AND (UNIX OR NOT "${CVS_EXECUTABLE}" MATCHES "cygwin"))
+ set(EP_TEST_CVS 1)
+endif()
+
+if(NOT DEFINED EP_TEST_SVN OR EP_TEST_SVN)
+ find_package(Subversion)
+ if(Subversion_FOUND AND Subversion_VERSION_SVN VERSION_LESS 1.2)
+ message(STATUS "No ExternalProject svn tests with svn client less than version 1.2")
+ set(Subversion_FOUND 0)
+ endif()
+ # Only do svn tests in cygwin/cygwin or not-cygwin/not-cygwin arrangements:
+ if(Subversion_FOUND AND CMAKE_CURRENT_BINARY_DIR MATCHES "cygdrive/" AND NOT "${Subversion_SVN_EXECUTABLE}" MATCHES "cygwin")
+ message(STATUS "No ExternalProject svn tests with non-cygwin svn client in a /cygdrive based build")
+ set(Subversion_FOUND 0)
+ endif()
+endif()
+if(NOT DEFINED EP_TEST_SVN AND Subversion_FOUND)
+ set(EP_TEST_SVN 1)
+endif()
+
+if(NOT DEFINED EP_TEST_GIT OR EP_TEST_GIT)
+ find_package(Git)
+endif()
+if(NOT DEFINED EP_TEST_GIT AND Git_FOUND)
+ message(STATUS "GIT_VERSION_STRING='${GIT_VERSION_STRING}'")
+ if(NOT "${GIT_VERSION_STRING}" VERSION_LESS 1.6.5)
+ set(EP_TEST_GIT 1)
+ endif()
+endif()
+
+if(NOT DEFINED EP_TEST_HG OR EP_TEST_HG)
+ find_package(Hg)
+endif()
+if(NOT DEFINED EP_TEST_HG AND Hg_FOUND)
+ set(EP_TEST_HG 1)
+endif()
+
+message(STATUS "EP_TEST_CVS='${EP_TEST_CVS}' CVS_EXECUTABLE='${CVS_EXECUTABLE}'")
+message(STATUS "EP_TEST_SVN='${EP_TEST_SVN}' Subversion_SVN_EXECUTABLE='${Subversion_SVN_EXECUTABLE}'")
+message(STATUS "EP_TEST_GIT='${EP_TEST_GIT}' GIT_EXECUTABLE='${GIT_EXECUTABLE}'")
+message(STATUS "EP_TEST_HG='${EP_TEST_HG}' HG_EXECUTABLE='${HG_EXECUTABLE}'")
option(ExternalProjectTest_USE_FOLDERS "Enable folder grouping in IDEs." ON)
if(ExternalProjectTest_USE_FOLDERS)
@@ -115,20 +155,7 @@
# CVS-based tests:
#
-set(do_cvs_tests 0)
-
-if(CVS_EXECUTABLE)
- set(do_cvs_tests 1)
-endif()
-
-if(do_cvs_tests AND NOT UNIX)
- if("${CVS_EXECUTABLE}" MATCHES "cygwin")
- message(STATUS "No ExternalProject cvs tests with cygwin cvs.exe outside cygwin!")
- set(do_cvs_tests 0)
- endif()
-endif()
-
-if(do_cvs_tests)
+if(EP_TEST_CVS)
# Unzip/untar the CVS repository in our source folder so that other
# projects below may use it to test CVS args of ExternalProject_Add
#
@@ -207,32 +234,7 @@
# SVN-based tests:
#
-set(do_svn_tests 0)
-
-if(Subversion_SVN_EXECUTABLE)
- set(do_svn_tests 1)
-endif()
-
-# Only do svn tests with svn >= version 1.2
-#
-if(do_svn_tests)
- if(Subversion_VERSION_SVN VERSION_LESS 1.2)
- message(STATUS "No ExternalProject svn tests with svn client less than version 1.2")
- set(do_svn_tests 0)
- endif()
-endif()
-
-# Only do svn tests in cygwin/cygwin or not-cygwin/not-cygwin arrangements:
-#
-if(do_svn_tests)
- if(CMAKE_CURRENT_BINARY_DIR MATCHES "cygdrive/" AND
- NOT "${Subversion_SVN_EXECUTABLE}" MATCHES "cygwin")
- message(STATUS "No ExternalProject svn tests with non-cygwin svn client in a /cygdrive based build")
- set(do_svn_tests 0)
- endif()
-endif()
-
-if(do_svn_tests)
+if(EP_TEST_SVN)
# Unzip/untar the SVN repository in our source folder so that other
# projects below may use it to test SVN args of ExternalProject_Add
#
@@ -292,22 +294,7 @@
set_property(TARGET ${proj} PROPERTY FOLDER "SVN")
endif()
-
-set(do_git_tests 0)
-
-if(GIT_EXECUTABLE)
- set(do_git_tests 1)
-
- message(STATUS "GIT_VERSION_STRING='${GIT_VERSION_STRING}'")
-
- if("${GIT_VERSION_STRING}" VERSION_LESS 1.6.5)
- message(STATUS "No ExternalProject git tests with git client less than version 1.6.5")
- set(do_git_tests 0)
- endif()
-endif()
-
-
-if(do_git_tests)
+if(EP_TEST_GIT)
set(local_git_repo "../../LocalRepositories/GIT")
# Unzip/untar the git repository in our source folder so that other
@@ -444,7 +431,9 @@
set_property(TARGET ${proj} PROPERTY FOLDER "GIT")
set(proj TS1-GIT-all-GIT_SUBMODULES-via-CMP0097-OLD)
+ set(CMAKE_WARN_DEPRECATED FALSE) # we are testing CMP0097 OLD behavior
cmake_policy(SET CMP0097 OLD)
+ unset(CMAKE_WARN_DEPRECATED)
ExternalProject_Add(${proj}
GIT_REPOSITORY "${local_git_repo}"
GIT_SUBMODULES ""
@@ -552,20 +541,7 @@
endif()
-set(do_hg_tests 0)
-
-if(HG_EXECUTABLE)
- set(do_hg_tests 1)
-endif()
-
-if(do_hg_tests AND NOT UNIX)
- if("${HG_EXECUTABLE}" MATCHES "cygwin")
- message(STATUS "No ExternalProject hg tests with cygwin hg outside cygwin!")
- set(do_hg_tests 0)
- endif()
-endif()
-
-if(do_hg_tests)
+if(EP_TEST_HG)
set(local_hg_repo "../../LocalRepositories/HG")
# Unzip/untar the hg repository in our source folder so that other
@@ -640,7 +616,7 @@
#
# BuildTree tests:
#
-if(do_cvs_tests)
+if(EP_TEST_CVS)
add_test(TutorialStep1-CVS-20090626-BuildTreeTest
"${binary_base}/TutorialStep1-CVS-20090626/Tutorial" 4)
@@ -651,7 +627,7 @@
"${binary_base}/TutorialStep1-CVS-HEAD/Tutorial" 81)
endif()
-if(do_svn_tests)
+if(EP_TEST_SVN)
add_test(TutorialStep1-SVN-20090626-BuildTreeTest
"${binary_base}/TutorialStep1-SVN-20090626/Tutorial" 100)
@@ -662,7 +638,7 @@
"${binary_base}/TutorialStep1-SVN-trunk/Tutorial" 98)
endif()
-if(do_git_tests)
+if(EP_TEST_GIT)
add_test(TutorialStep1-GIT-byhash
${CMAKE_COMMAND} -P "${binary_base}/TutorialStep1-GIT-byhash/example.cmake")
@@ -684,13 +660,6 @@
endif()
endif()
-
-message(STATUS "do_cvs_tests='${do_cvs_tests}'")
-message(STATUS "do_svn_tests='${do_svn_tests}'")
-message(STATUS "do_git_tests='${do_git_tests}' GIT_EXECUTABLE='${GIT_EXECUTABLE}'")
-message(STATUS "do_hg_tests='${do_hg_tests}' HG_EXECUTABLE='${HG_EXECUTABLE}'")
-
-
# Test if log works when the first arguments of *_COMMAND is "COMMAND".
set(proj ExternalProject-no-log)
set(download_cmd "")
diff --git a/Tests/FindMatlab/cmake_matlab_unit_tests4.m b/Tests/FindMatlab/cmake_matlab_unit_tests4.m
index 6a7b04d..c2bf270 100644
--- a/Tests/FindMatlab/cmake_matlab_unit_tests4.m
+++ b/Tests/FindMatlab/cmake_matlab_unit_tests4.m
@@ -1,4 +1,3 @@
-
classdef cmake_matlab_unit_tests4 < matlab.unittest.TestCase
% Testing R2017b and R2018a APIs
properties
@@ -12,11 +11,7 @@
function testR2018a(testCase)
ret = cmake_matlab_mex2b(5+6i);
- v = version;
- n = find(v=='.');
- v = str2double(v(1:n(2)-1));
- disp(v)
- if v>= 9.4 % R2018a
+ if not(verLessThan('matlab','9.4')) % R2018a
testCase.verifyEqual(ret, 16);
disp('TESTING version >= 9.4')
else
diff --git a/Tests/FindX11/Test/CMakeLists.txt b/Tests/FindX11/Test/CMakeLists.txt
index 5b304d9..18a73a3 100644
--- a/Tests/FindX11/Test/CMakeLists.txt
+++ b/Tests/FindX11/Test/CMakeLists.txt
@@ -33,8 +33,11 @@
test_x11_component(x11_components xcb)
test_x11_component(x11_components X11_xcb)
test_x11_component(x11_components xcb_icccm)
+test_x11_component(x11_components xcb_randr)
test_x11_component(x11_components xcb_util)
test_x11_component(x11_components xcb_xfixes)
+test_x11_component(x11_components xcb_xtest)
+test_x11_component(x11_components xcb_keysyms)
test_x11_component(x11_components xcb_xkb)
test_x11_component(x11_components Xcomposite)
test_x11_component(x11_components Xdamage)
@@ -74,6 +77,7 @@
xcb
X11_xcb
xcb_icccm
+ xcb_randr
xcb_util
xcb_xfixes
Xcomposite
diff --git a/Tests/FindX11/Test/main.c b/Tests/FindX11/Test/main.c
index b44ae28..653a2be 100644
--- a/Tests/FindX11/Test/main.c
+++ b/Tests/FindX11/Test/main.c
@@ -336,6 +336,20 @@
xcb_disconnect(connection);
}
+# ifdef HAVE_xcb_randr
+# include <xcb/randr.h>
+
+static void test_xcb_randr(void)
+{
+ int screen_nbr;
+ xcb_connection_t* connection = xcb_connect(NULL, &screen_nbr);
+ xcb_randr_query_version_cookie_t cookie =
+ xcb_randr_query_version(connection, 0, 0);
+ xcb_disconnect(connection);
+}
+
+# endif
+
# ifdef HAVE_xcb_util
# include <xcb/xcb_aux.h>
@@ -362,6 +376,34 @@
# endif
+# ifdef HAVE_xcb_xtest
+# include <xcb/xtest.h>
+
+static void test_xcb_xtest(void)
+{
+ int screen_nbr;
+ xcb_connection_t* connection = xcb_connect(NULL, &screen_nbr);
+ xcb_test_get_version_unchecked(connection, 1, 0);
+ xcb_disconnect(connection);
+}
+
+# endif
+
+# ifdef HAVE_xcb_keysyms
+# include <xcb/xcb_keysyms.h>
+
+static void test_xcb_keysyms(void)
+{
+ int screen_nbr;
+ xcb_connection_t* connection = xcb_connect(NULL, &screen_nbr);
+ xcb_key_symbols_t* symbols = xcb_key_symbols_alloc(connection);
+ if (symbols != NULL)
+ xcb_key_symbols_free(symbols);
+ xcb_disconnect(connection);
+}
+
+# endif
+
#endif
#include <stddef.h>
@@ -455,6 +497,9 @@
test_xcb,
#endif
#ifdef HAVE_xcb_util
+ test_xcb_randr,
+#endif
+#ifdef HAVE_xcb_util
test_xcb_util,
#endif
#ifdef HAVE_xcb_xfixes
diff --git a/Tests/GhsMulti/GhsMultiCompilerOptions/CMakeLists.txt b/Tests/GhsMulti/GhsMultiCompilerOptions/CMakeLists.txt
index 4a3f5c2..9250709 100644
--- a/Tests/GhsMulti/GhsMultiCompilerOptions/CMakeLists.txt
+++ b/Tests/GhsMulti/GhsMultiCompilerOptions/CMakeLists.txt
@@ -27,8 +27,7 @@
message("Output from build:\n${OUTPUT}")
if (RUN_TEST STREQUAL "RELEASE_FLAGS")
find_file (fileName test_none.gpj
- ${CMAKE_CURRENT_BINARY_DIR}/build
- ${CMAKE_CURRENT_BINARY_DIR}/build/test_none
+ ${CMAKE_CURRENT_BINARY_DIR}/build/test_none.dir
)
message("Parsing project file: ${fileName}")
file(STRINGS ${fileName} fileText)
@@ -40,8 +39,7 @@
else()
unset(fileName CACHE)
find_file (fileName K1.gpj
- ${CMAKE_CURRENT_BINARY_DIR}/build
- ${CMAKE_CURRENT_BINARY_DIR}/build/K1
+ ${CMAKE_CURRENT_BINARY_DIR}/build/K1.dir
)
message("Parsing project file: ${fileName}")
file(STRINGS ${fileName} fileText)
@@ -53,8 +51,7 @@
unset(fileName CACHE)
find_file (fileName K2.gpj
- ${CMAKE_CURRENT_BINARY_DIR}/build
- ${CMAKE_CURRENT_BINARY_DIR}/build/K2
+ ${CMAKE_CURRENT_BINARY_DIR}/build/K2.dir
)
message("Parsing project file: ${fileName}")
file(STRINGS ${fileName} fileText)
@@ -66,8 +63,7 @@
unset(fileName CACHE)
find_file (fileName K3.gpj
- ${CMAKE_CURRENT_BINARY_DIR}/build
- ${CMAKE_CURRENT_BINARY_DIR}/build/K3
+ ${CMAKE_CURRENT_BINARY_DIR}/build/K3.dir
)
message("Parsing project file: ${fileName}")
file(STRINGS ${fileName} fileText)
@@ -79,8 +75,7 @@
unset(fileName CACHE)
find_file (fileName K4.gpj
- ${CMAKE_CURRENT_BINARY_DIR}/build
- ${CMAKE_CURRENT_BINARY_DIR}/build/K4
+ ${CMAKE_CURRENT_BINARY_DIR}/build/K4.dir
)
message("Parsing project file: ${fileName}")
file(STRINGS ${fileName} fileText)
diff --git a/Tests/GhsMulti/GhsMultiExclude/CMakeLists.txt b/Tests/GhsMulti/GhsMultiExclude/CMakeLists.txt
index 0448cf2..575bf50 100644
--- a/Tests/GhsMulti/GhsMultiExclude/CMakeLists.txt
+++ b/Tests/GhsMulti/GhsMultiExclude/CMakeLists.txt
@@ -14,4 +14,6 @@
add_library(lib2 EXCLUDE_FROM_ALL lib1.c)
+add_library(lib3 lib1.c)
+
add_executable(exe1 exe1.c)
diff --git a/Tests/GhsMulti/GhsMultiExclude/verify.cmake b/Tests/GhsMulti/GhsMultiExclude/verify.cmake
index 0467b5a..99cef63 100644
--- a/Tests/GhsMulti/GhsMultiExclude/verify.cmake
+++ b/Tests/GhsMulti/GhsMultiExclude/verify.cmake
@@ -1,54 +1,56 @@
# Distributed under the OSI-approved BSD 3-Clause License. See accompanying
# file Copyright.txt or https://cmake.org/licensing for details.
-#test project was generated
-unset(fileName CACHE)
-find_file (fileName lib1.gpj
- ${CMAKE_CURRENT_BINARY_DIR}
- ${CMAKE_CURRENT_BINARY_DIR}/lib1
- )
+function(verify_skipped_tgt name)
+ unset(fileName CACHE)
+ find_file (fileName ${name}.tgt.gpj
+ ${CMAKE_CURRENT_BINARY_DIR}
+ )
-if (fileName)
- message("Found target lib1: ${fileName}")
-else()
- message(SEND_ERROR "Could not find target lib1: ${fileName}")
-endif()
+ if (fileName)
+ message("Found target ${name}: ${fileName}")
+ else()
+ message(SEND_ERROR "Could not find target ${name}: ${fileName}")
+ endif()
-#test project was built
-unset(fileName CACHE)
-find_file (fileName lib1.a
- ${CMAKE_CURRENT_BINARY_DIR}
- ${CMAKE_CURRENT_BINARY_DIR}/lib1
- )
+ #test project was built
+ unset(fileName CACHE)
+ find_file (fileName lib${name}.a
+ ${CMAKE_CURRENT_BINARY_DIR}
+ )
-if (fileName)
- message(SEND_ERROR "Found target lib1: ${fileName}")
-else()
- message("Could not find target lib1: ${fileName}")
-endif()
+ if (fileName)
+ message(SEND_ERROR "Found target ${name}: ${fileName}")
+ else()
+ message("Could not find target ${name}: ${fileName}")
+ endif()
+endfunction()
-#test project was generated
-unset(fileName CACHE)
-find_file (fileName lib2.gpj
- ${CMAKE_CURRENT_BINARY_DIR}
- ${CMAKE_CURRENT_BINARY_DIR}/lib2
- )
+function(locate_tgt name)
+ unset(fileName CACHE)
+ find_file (fileName ${name}.tgt.gpj
+ ${CMAKE_CURRENT_BINARY_DIR}
+ )
-if (fileName)
- message("Found target lib2 ${fileName}")
-else()
- message(SEND_ERROR "Could not find target lib2: ${fileName}")
-endif()
+ if (fileName)
+ message("Found target ${name}: ${fileName}")
+ else()
+ message(SEND_ERROR "Could not find target ${name}: ${fileName}")
+ endif()
-#test project was built
-unset(fileName CACHE)
-find_file (fileName lib2.a
- ${CMAKE_CURRENT_BINARY_DIR}
- ${CMAKE_CURRENT_BINARY_DIR}/lib2
- )
+ #test project was built
+ unset(fileName CACHE)
+ find_file (fileName lib${name}.a
+ ${CMAKE_CURRENT_BINARY_DIR}
+ )
-if (fileName)
- message(SEND_ERROR "Found target lib2: ${fileName}")
-else()
- message("Could not find target lib2: ${fileName}")
-endif()
+ if (fileName)
+ message( "Found target ${name}: ${fileName}")
+ else()
+ message(SEND_ERROR "Could not find target ${name}: ${fileName}")
+ endif()
+endfunction()
+
+verify_skipped_tgt(lib1)
+verify_skipped_tgt(lib2)
+locate_tgt(lib3)
diff --git a/Tests/GhsMulti/GhsMultiLinkTest/CMakeLists.txt b/Tests/GhsMulti/GhsMultiLinkTest/CMakeLists.txt
index da80b51..2d21bfb 100644
--- a/Tests/GhsMulti/GhsMultiLinkTest/CMakeLists.txt
+++ b/Tests/GhsMulti/GhsMultiLinkTest/CMakeLists.txt
@@ -38,8 +38,7 @@
else()
unset(fileName CACHE)
find_file(fileName exe1.gpj
- ${CMAKE_CURRENT_BINARY_DIR}/link_build
- ${CMAKE_CURRENT_BINARY_DIR}/link_build/exe1
+ ${CMAKE_CURRENT_BINARY_DIR}/link_build/exe1.dir
)
message("Parsing project file: ${fileName}")
file(STRINGS ${fileName} fileText)
@@ -54,13 +53,14 @@
string(FIND "${fileText}" "${opt}" opt_found)
if ( opt_found EQUAL -1 )
message(SEND_ERROR "Could not find: ${opt}")
+ else()
+ message("located: ${opt}")
endif()
endforeach()
unset(fileName CACHE)
find_file (fileName lib1.gpj
- ${CMAKE_CURRENT_BINARY_DIR}/link_build
- ${CMAKE_CURRENT_BINARY_DIR}/link_build/lib1
+ ${CMAKE_CURRENT_BINARY_DIR}/link_build/lib1.dir
)
message("Parsing project file: ${fileName}")
file(STRINGS ${fileName} fileText)
@@ -71,13 +71,14 @@
string(FIND "${fileText}" "${opt}" opt_found)
if (opt_found EQUAL -1)
message(SEND_ERROR "Could not find: ${opt}")
+ else()
+ message("located: ${opt}")
endif()
endforeach()
unset(fileName CACHE)
find_file (fileName lib2.gpj
- ${CMAKE_CURRENT_BINARY_DIR}/link_build
- ${CMAKE_CURRENT_BINARY_DIR}/link_build/lib2
+ ${CMAKE_CURRENT_BINARY_DIR}/link_build/lib2.dir
)
message("Parsing project file: ${fileName}")
file(STRINGS ${fileName} fileText)
@@ -87,6 +88,8 @@
string(FIND "${fileText}" "${opt}" opt_found)
if ( opt_found EQUAL -1 )
message(SEND_ERROR "Could not find: ${opt}")
+ else()
+ message("located: ${opt}")
endif()
endforeach()
endif()
diff --git a/Tests/GhsMulti/GhsMultiMultipleProjects/verify.cmake b/Tests/GhsMulti/GhsMultiMultipleProjects/verify.cmake
index 3855215..b6af935 100644
--- a/Tests/GhsMulti/GhsMultiMultipleProjects/verify.cmake
+++ b/Tests/GhsMulti/GhsMultiMultipleProjects/verify.cmake
@@ -1,58 +1,38 @@
# Distributed under the OSI-approved BSD 3-Clause License. See accompanying
# file Copyright.txt or https://cmake.org/licensing for details.
-#test project was generated
-unset(fileName CACHE)
-find_file(fileName lib3.gpj
- ${CMAKE_CURRENT_BINARY_DIR}
- ${CMAKE_CURRENT_BINARY_DIR}/lib3
- ${CMAKE_CURRENT_BINARY_DIR}/examples
- )
+function(verify_project_top name)
+ unset(fileName CACHE)
+ find_file (fileName ${name}.top.gpj
+ ${CMAKE_CURRENT_BINARY_DIR}
+ ${CMAKE_CURRENT_BINARY_DIR}/sub
+ ${CMAKE_CURRENT_BINARY_DIR}/examples
+ )
-if (fileName)
- message("Found target lib3: ${fileName}")
-else()
- message(SEND_ERROR "Could not find target lib3: ${fileName}")
-endif()
+ if (fileName)
+ message("Found target ${name}: ${fileName}")
+ else()
+ message(SEND_ERROR "Could not find project ${name}: ${fileName}")
+ endif()
+endfunction()
-#test project was generated
-unset(fileName CACHE)
-find_file (fileName exe3.gpj
- ${CMAKE_CURRENT_BINARY_DIR}
- ${CMAKE_CURRENT_BINARY_DIR}/exe3
- ${CMAKE_CURRENT_BINARY_DIR}/examples
- )
+function(verify_exe_built name)
+ unset(fileName CACHE)
+ find_file (fileName ${name}
+ ${CMAKE_CURRENT_BINARY_DIR}
+ ${CMAKE_CURRENT_BINARY_DIR}/sub
+ )
-if (fileName)
- message("Found target exe3: ${fileName}")
-else()
- message(SEND_ERROR "Could not find target exe3: ${fileName}")
-endif()
+ if (fileName)
+ message("Found target ${name}: ${fileName}")
+ else()
+ message(SEND_ERROR "Could not find project ${name}: ${fileName}")
+ endif()
+endfunction()
-#test project was not built
-unset(fileName CACHE)
-find_file (fileName lib3.a
- ${CMAKE_CURRENT_BINARY_DIR}
- ${CMAKE_CURRENT_BINARY_DIR}/lib3
- ${CMAKE_CURRENT_BINARY_DIR}/examples
- )
-
-if (fileName)
- message(SEND_ERROR "Found target lib3: ${fileName}")
-else()
- message("Could not find target lib3: ${fileName}")
-endif()
-
-unset(fileName CACHE)
-find_file (fileName NAMES exe3.as exe3
- HINTS
- ${CMAKE_CURRENT_BINARY_DIR}
- ${CMAKE_CURRENT_BINARY_DIR}/exe3
- ${CMAKE_CURRENT_BINARY_DIR}/examples
- )
-
-if (fileName)
- message(SEND_ERROR "Found target exe3: ${fileName}")
-else()
- message("Could not find target exe3: ${fileName}")
-endif()
+#test project top files were generated
+verify_project_top(test)
+verify_project_top(test2)
+verify_project_top(test3)
+verify_exe_built(exe1)
+verify_exe_built(exe2)
diff --git a/Tests/QtAutogen/MocInclude/CMakeLists.txt b/Tests/QtAutogen/MocInclude/CMakeLists.txt
index 4224d2f..c62128b 100644
--- a/Tests/QtAutogen/MocInclude/CMakeLists.txt
+++ b/Tests/QtAutogen/MocInclude/CMakeLists.txt
@@ -1,7 +1,9 @@
cmake_minimum_required(VERSION 3.16)
project(MocInclude)
-get_filename_component(CS_REAL ${CMAKE_CURRENT_SOURCE_DIR} REALPATH)
-include("${CS_REAL}/../AutogenCoreTest.cmake")
+if (NOT DEFINED AUTOGEN_CORE_TEST_CMAKE)
+ get_filename_component(AUTOGEN_CORE_TEST_CMAKE "../AutogenCoreTest.cmake" ABSOLUTE)
+endif()
+include("${AUTOGEN_CORE_TEST_CMAKE}")
# Test moc include patterns
diff --git a/Tests/QtAutogen/MocIncludeSymlink/CMakeLists.txt b/Tests/QtAutogen/MocIncludeSymlink/CMakeLists.txt
index c28616b..cf60555 100644
--- a/Tests/QtAutogen/MocIncludeSymlink/CMakeLists.txt
+++ b/Tests/QtAutogen/MocIncludeSymlink/CMakeLists.txt
@@ -1,6 +1,7 @@
cmake_minimum_required(VERSION 3.16)
project(MocIncludeSymlink)
-include("../AutogenCoreTest.cmake")
+get_filename_component(AUTOGEN_CORE_TEST_CMAKE "../AutogenCoreTest.cmake" ABSOLUTE)
+include("${AUTOGEN_CORE_TEST_CMAKE}")
#
# Tests if MocInclude can be build when
@@ -65,6 +66,7 @@
"-DCMAKE_AUTOGEN_VERBOSE=${CMAKE_AUTOGEN_VERBOSE}"
"-DCMAKE_PREFIX_PATH:STRING=${CMAKE_PREFIX_PATH}"
"-DQT_QMAKE_EXECUTABLE:FILEPATH=${QT_QMAKE_EXECUTABLE}"
+ "-DAUTOGEN_CORE_TEST_CMAKE:STRING=${AUTOGEN_CORE_TEST_CMAKE}"
OUTPUT_VARIABLE output
)
if (result)
diff --git a/Tests/RunCMake/CMakeLists.txt b/Tests/RunCMake/CMakeLists.txt
index e97b7dc..1deb75f 100644
--- a/Tests/RunCMake/CMakeLists.txt
+++ b/Tests/RunCMake/CMakeLists.txt
@@ -278,6 +278,9 @@
add_RunCMake_test(CMakeDependentOption)
add_RunCMake_test(CMakeRoleGlobalProperty)
add_RunCMake_test(CMakeRelease -DCMake_TEST_JQ=${CMake_TEST_JQ})
+if(CMAKE_GENERATOR MATCHES "Make|Ninja")
+ add_RunCMake_test(Color)
+endif()
if(UNIX AND "${CMAKE_GENERATOR}" MATCHES "Unix Makefiles|Ninja")
add_RunCMake_test(CompilerChange)
endif()
@@ -313,6 +316,8 @@
add_RunCMake_test(GenEx-LINK_LANG_AND_ID)
add_RunCMake_test(GenEx-HOST_LINK)
add_RunCMake_test(GenEx-DEVICE_LINK)
+add_RunCMake_test(GenEx-LINK_LIBRARY)
+add_RunCMake_test(GenEx-LINK_GROUP)
add_RunCMake_test(GenEx-TARGET_FILE -DLINKER_SUPPORTS_PDB=${LINKER_SUPPORTS_PDB})
add_RunCMake_test(GenEx-GENEX_EVAL)
add_RunCMake_test(GenEx-TARGET_RUNTIME_DLLS)
@@ -657,6 +662,30 @@
add_RunCMake_test(target_link_libraries-ALIAS)
add_RunCMake_test(target_link_libraries-LINK_LANGUAGE)
add_RunCMake_test(target_link_libraries-LINK_LANG_AND_ID)
+add_RunCMake_test(target_link_libraries-LINK_LIBRARY -DCMAKE_SYSTEM_NAME=${CMAKE_SYSTEM_NAME}
+ -DMINGW=${MINGW}
+ -DMSYS=${MSYS}
+ -DCYGWIN=${CYGWIN}
+ -DCMAKE_C_COMPILER_ID=${CMAKE_C_COMPILER_ID}
+ -DCMAKE_C_COMPILER_VERSION=${CMAKE_C_COMPILER_VERSION}
+ -DMSVC_VERSION=${MSVC_VERSION}
+ -DCMAKE_SHARED_LIBRARY_PREFIX=${CMAKE_SHARED_LIBRARY_PREFIX}
+ -DCMAKE_SHARED_LIBRARY_SUFFIX=${CMAKE_SHARED_LIBRARY_SUFFIX}
+ -DCMAKE_IMPORT_LIBRARY_PREFIX=${CMAKE_IMPORT_LIBRARY_PREFIX}
+ -DCMAKE_IMPORT_LIBRARY_SUFFIX=${CMAKE_IMPORT_LIBRARY_SUFFIX}
+ -DCMAKE_LINK_LIBRARY_FLAG=${CMAKE_LINK_LIBRARY_FLAG})
+add_RunCMake_test(target_link_libraries-LINK_GROUP -DCMAKE_SYSTEM_NAME=${CMAKE_SYSTEM_NAME}
+ -DMINGW=${MINGW}
+ -DMSYS=${MSYS}
+ -DCYGWIN=${CYGWIN}
+ -DCMAKE_C_COMPILER_ID=${CMAKE_C_COMPILER_ID}
+ -DCMAKE_C_COMPILER_VERSION=${CMAKE_C_COMPILER_VERSION}
+ -DMSVC_VERSION=${MSVC_VERSION}
+ -DCMAKE_SHARED_LIBRARY_PREFIX=${CMAKE_SHARED_LIBRARY_PREFIX}
+ -DCMAKE_SHARED_LIBRARY_SUFFIX=${CMAKE_SHARED_LIBRARY_SUFFIX}
+ -DCMAKE_IMPORT_LIBRARY_PREFIX=${CMAKE_IMPORT_LIBRARY_PREFIX}
+ -DCMAKE_IMPORT_LIBRARY_SUFFIX=${CMAKE_IMPORT_LIBRARY_SUFFIX}
+ -DCMAKE_LINK_LIBRARY_FLAG=${CMAKE_LINK_LIBRARY_FLAG})
add_RunCMake_test(add_link_options -DCMAKE_C_COMPILER_ID=${CMAKE_C_COMPILER_ID})
add_RunCMake_test(target_link_options -DCMAKE_C_COMPILER_ID=${CMAKE_C_COMPILER_ID}
-DCMake_TEST_CUDA=${CMake_TEST_CUDA})
@@ -708,7 +737,8 @@
add_executable(pseudo_llvm-rc pseudo_llvm-rc.c)
add_RunCMake_test(CommandLine -DLLVM_RC=$<TARGET_FILE:pseudo_llvm-rc> -DCMAKE_SYSTEM_NAME=${CMAKE_SYSTEM_NAME}
- -DCYGWIN=${CYGWIN} -DMSYS=${MSYS} -DPYTHON_EXECUTABLE=${PYTHON_EXECUTABLE})
+ -DCYGWIN=${CYGWIN} -DMSYS=${MSYS} -DPYTHON_EXECUTABLE=${PYTHON_EXECUTABLE}
+ -DEXIT_CODE_EXE=$<TARGET_FILE:exit_code>)
add_RunCMake_test(CommandLineTar)
if(CMAKE_PLATFORM_NO_VERSIONED_SONAME OR (NOT CMAKE_SHARED_LIBRARY_SONAME_FLAG AND NOT CMAKE_SHARED_LIBRARY_SONAME_C_FLAG))
@@ -738,6 +768,9 @@
if(XCODE_VERSION)
set(ExternalProject_ARGS -DXCODE_VERSION=${XCODE_VERSION})
endif()
+if(CMake_TEST_RunCMake_ExternalProject_DOWNLOAD_SERVER_TIMEOUT)
+ list(APPEND ExternalProject_ARGS -DDOWNLOAD_SERVER_TIMEOUT=${CMake_TEST_RunCMake_ExternalProject_DOWNLOAD_SERVER_TIMEOUT})
+endif()
add_RunCMake_test(ExternalProject)
add_RunCMake_test(FetchContent)
set(CTestCommandLine_ARGS -DPYTHON_EXECUTABLE=${PYTHON_EXECUTABLE})
diff --git a/Tests/RunCMake/CMakePresets/IncludeOutsideProjectInclude.json b/Tests/RunCMake/CMakePresets/IncludeOutsideProjectInclude.json
index f13e55c..ebf106f 100644
--- a/Tests/RunCMake/CMakePresets/IncludeOutsideProjectInclude.json
+++ b/Tests/RunCMake/CMakePresets/IncludeOutsideProjectInclude.json
@@ -1,3 +1,3 @@
{
- "version": 4
+ "version": 5
}
diff --git a/Tests/RunCMake/CMakePresetsBuild/Good.json.in b/Tests/RunCMake/CMakePresetsBuild/Good.json.in
index 568907c..a953f48 100644
--- a/Tests/RunCMake/CMakePresetsBuild/Good.json.in
+++ b/Tests/RunCMake/CMakePresetsBuild/Good.json.in
@@ -1,5 +1,5 @@
{
- "version": 4,
+ "version": 5,
"configurePresets": [
{
"name": "default",
diff --git a/Tests/RunCMake/CMakePresetsTest/Good.json.in b/Tests/RunCMake/CMakePresetsTest/Good.json.in
index 57be5a5..d484a19 100644
--- a/Tests/RunCMake/CMakePresetsTest/Good.json.in
+++ b/Tests/RunCMake/CMakePresetsTest/Good.json.in
@@ -1,5 +1,5 @@
{
- "version": 2,
+ "version": 5,
"configurePresets": [
{
"name": "default",
@@ -48,7 +48,8 @@
"quiet": false,
"outputLogFile": "",
"labelSummary": true,
- "subprojectSummary": true
+ "subprojectSummary": true,
+ "testOutputTruncation": "tail"
},
"filter": {
"include": {
diff --git a/Tests/RunCMake/CTestCommandLine/RunCMakeTest.cmake b/Tests/RunCMake/CTestCommandLine/RunCMakeTest.cmake
index 7da95a2..6835834 100644
--- a/Tests/RunCMake/CTestCommandLine/RunCMakeTest.cmake
+++ b/Tests/RunCMake/CTestCommandLine/RunCMakeTest.cmake
@@ -274,6 +274,27 @@
endfunction()
run_TestOutputSize()
+# Test --test-output-truncation
+function(run_TestOutputTruncation mode expected)
+ set(RunCMake_TEST_BINARY_DIR ${RunCMake_BINARY_DIR}/TestOutputTruncation_${mode})
+ set(RunCMake_TEST_NO_CLEAN 1)
+ set(TRUNCATED_OUTPUT ${expected}) # used in TestOutputTruncation-check.cmake
+ file(REMOVE_RECURSE "${RunCMake_TEST_BINARY_DIR}")
+ file(MAKE_DIRECTORY "${RunCMake_TEST_BINARY_DIR}")
+ file(WRITE "${RunCMake_TEST_BINARY_DIR}/CTestTestfile.cmake" "
+ add_test(Truncation_${mode} \"${CMAKE_COMMAND}\" -E echo 123456789)
+")
+ run_cmake_command(TestOutputTruncation
+ ${CMAKE_CTEST_COMMAND} -M Experimental -T Test
+ --no-compress-output
+ --test-output-size-passed 5
+ --test-output-truncation ${mode}
+ )
+endfunction()
+run_TestOutputTruncation("head" "\\.\\.\\.6789")
+run_TestOutputTruncation("middle" "12\\.\\.\\..*\\.\\.\\.89")
+run_TestOutputTruncation("tail" "12345\\.\\.\\.")
+
# Test --stop-on-failure
function(run_stop_on_failure)
set(RunCMake_TEST_BINARY_DIR ${RunCMake_BINARY_DIR}/stop-on-failure)
diff --git a/Tests/RunCMake/CTestCommandLine/TestOutputTruncation-check.cmake b/Tests/RunCMake/CTestCommandLine/TestOutputTruncation-check.cmake
new file mode 100644
index 0000000..5769c9f
--- /dev/null
+++ b/Tests/RunCMake/CTestCommandLine/TestOutputTruncation-check.cmake
@@ -0,0 +1,12 @@
+file(GLOB test_xml_file "${RunCMake_TEST_BINARY_DIR}/Testing/*/Test.xml")
+if(test_xml_file)
+ file(READ "${test_xml_file}" test_xml LIMIT 4096)
+ if("${test_xml}" MATCHES [[(<Test Status="passed">.*</Test>)]])
+ set(test_result "${CMAKE_MATCH_1}")
+ endif()
+ if(NOT "${test_result}" MATCHES "<Value>.*${TRUNCATED_OUTPUT}.*</Value>")
+ set(RunCMake_TEST_FAILED "Test output truncation failed:\n ${test_result}\nExpected: ${TRUNCATED_OUTPUT}")
+ endif()
+else()
+ set(RunCMake_TEST_FAILED "Test.xml not found")
+endif()
diff --git a/Tests/RunCMake/CTestCommandLine/TestOutputTruncation-stderr.txt b/Tests/RunCMake/CTestCommandLine/TestOutputTruncation-stderr.txt
new file mode 100644
index 0000000..30b46ce
--- /dev/null
+++ b/Tests/RunCMake/CTestCommandLine/TestOutputTruncation-stderr.txt
@@ -0,0 +1 @@
+^Cannot find file: .*/Tests/RunCMake/CTestCommandLine/TestOutputTruncation.*/DartConfiguration.tcl
diff --git a/Tests/RunCMake/CUDA_architectures/RunCMakeTest.cmake b/Tests/RunCMake/CUDA_architectures/RunCMakeTest.cmake
index 6fecae7..e37d025 100644
--- a/Tests/RunCMake/CUDA_architectures/RunCMakeTest.cmake
+++ b/Tests/RunCMake/CUDA_architectures/RunCMakeTest.cmake
@@ -2,6 +2,7 @@
run_cmake(architectures-all)
run_cmake(architectures-all-major)
+run_cmake(architectures-native)
run_cmake(architectures-empty)
run_cmake(architectures-invalid)
diff --git a/Tests/RunCMake/CUDA_architectures/architectures-all-major-stdout.txt b/Tests/RunCMake/CUDA_architectures/architectures-all-major-stdout.txt
index c5cde8f..ee0a5f7 100644
--- a/Tests/RunCMake/CUDA_architectures/architectures-all-major-stdout.txt
+++ b/Tests/RunCMake/CUDA_architectures/architectures-all-major-stdout.txt
@@ -1,3 +1,4 @@
-- CMAKE_CUDA_ARCHITECTURES='all-major'
-- CMAKE_CUDA_ARCHITECTURES_ALL='[0-9;]+'
-- CMAKE_CUDA_ARCHITECTURES_ALL_MAJOR='[0-9;]+'
+-- CMAKE_CUDA_ARCHITECTURES_NATIVE='[0-9;]+'
diff --git a/Tests/RunCMake/CUDA_architectures/architectures-all-major.cmake b/Tests/RunCMake/CUDA_architectures/architectures-all-major.cmake
index 5112473..7203c98 100644
--- a/Tests/RunCMake/CUDA_architectures/architectures-all-major.cmake
+++ b/Tests/RunCMake/CUDA_architectures/architectures-all-major.cmake
@@ -3,3 +3,4 @@
message(STATUS "CMAKE_CUDA_ARCHITECTURES='${CMAKE_CUDA_ARCHITECTURES}'")
message(STATUS "CMAKE_CUDA_ARCHITECTURES_ALL='${CMAKE_CUDA_ARCHITECTURES_ALL}'")
message(STATUS "CMAKE_CUDA_ARCHITECTURES_ALL_MAJOR='${CMAKE_CUDA_ARCHITECTURES_ALL_MAJOR}'")
+message(STATUS "CMAKE_CUDA_ARCHITECTURES_NATIVE='${CMAKE_CUDA_ARCHITECTURES_NATIVE}'")
diff --git a/Tests/RunCMake/CUDA_architectures/architectures-all-stdout.txt b/Tests/RunCMake/CUDA_architectures/architectures-all-stdout.txt
index aba26b9..fd738e4 100644
--- a/Tests/RunCMake/CUDA_architectures/architectures-all-stdout.txt
+++ b/Tests/RunCMake/CUDA_architectures/architectures-all-stdout.txt
@@ -1,3 +1,4 @@
-- CMAKE_CUDA_ARCHITECTURES='all'
-- CMAKE_CUDA_ARCHITECTURES_ALL='[0-9;]+'
-- CMAKE_CUDA_ARCHITECTURES_ALL_MAJOR='[0-9;]+'
+-- CMAKE_CUDA_ARCHITECTURES_NATIVE='[0-9;]+'
diff --git a/Tests/RunCMake/CUDA_architectures/architectures-all.cmake b/Tests/RunCMake/CUDA_architectures/architectures-all.cmake
index 32175f6..0c3a4e9 100644
--- a/Tests/RunCMake/CUDA_architectures/architectures-all.cmake
+++ b/Tests/RunCMake/CUDA_architectures/architectures-all.cmake
@@ -3,3 +3,4 @@
message(STATUS "CMAKE_CUDA_ARCHITECTURES='${CMAKE_CUDA_ARCHITECTURES}'")
message(STATUS "CMAKE_CUDA_ARCHITECTURES_ALL='${CMAKE_CUDA_ARCHITECTURES_ALL}'")
message(STATUS "CMAKE_CUDA_ARCHITECTURES_ALL_MAJOR='${CMAKE_CUDA_ARCHITECTURES_ALL_MAJOR}'")
+message(STATUS "CMAKE_CUDA_ARCHITECTURES_NATIVE='${CMAKE_CUDA_ARCHITECTURES_NATIVE}'")
diff --git a/Tests/RunCMake/CUDA_architectures/architectures-native-stdout.txt b/Tests/RunCMake/CUDA_architectures/architectures-native-stdout.txt
new file mode 100644
index 0000000..af49e00
--- /dev/null
+++ b/Tests/RunCMake/CUDA_architectures/architectures-native-stdout.txt
@@ -0,0 +1,4 @@
+-- CMAKE_CUDA_ARCHITECTURES='native'
+-- CMAKE_CUDA_ARCHITECTURES_ALL='[0-9;]+'
+-- CMAKE_CUDA_ARCHITECTURES_ALL_MAJOR='[0-9;]+'
+-- CMAKE_CUDA_ARCHITECTURES_NATIVE='[0-9;]+'
diff --git a/Tests/RunCMake/CUDA_architectures/architectures-native.cmake b/Tests/RunCMake/CUDA_architectures/architectures-native.cmake
new file mode 100644
index 0000000..64afe13
--- /dev/null
+++ b/Tests/RunCMake/CUDA_architectures/architectures-native.cmake
@@ -0,0 +1,6 @@
+set(CMAKE_CUDA_ARCHITECTURES "native")
+enable_language(CUDA)
+message(STATUS "CMAKE_CUDA_ARCHITECTURES='${CMAKE_CUDA_ARCHITECTURES}'")
+message(STATUS "CMAKE_CUDA_ARCHITECTURES_ALL='${CMAKE_CUDA_ARCHITECTURES_ALL}'")
+message(STATUS "CMAKE_CUDA_ARCHITECTURES_ALL_MAJOR='${CMAKE_CUDA_ARCHITECTURES_ALL_MAJOR}'")
+message(STATUS "CMAKE_CUDA_ARCHITECTURES_NATIVE='${CMAKE_CUDA_ARCHITECTURES_NATIVE}'")
diff --git a/Tests/RunCMake/Color/CMakeLists.txt b/Tests/RunCMake/Color/CMakeLists.txt
new file mode 100644
index 0000000..5ff8d3e
--- /dev/null
+++ b/Tests/RunCMake/Color/CMakeLists.txt
@@ -0,0 +1,3 @@
+cmake_minimum_required(VERSION 3.23)
+project(${RunCMake_TEST} NONE)
+include(${RunCMake_TEST}.cmake)
diff --git a/Tests/RunCMake/Color/DiagCommon.cmake b/Tests/RunCMake/Color/DiagCommon.cmake
new file mode 100644
index 0000000..9a69317
--- /dev/null
+++ b/Tests/RunCMake/Color/DiagCommon.cmake
@@ -0,0 +1,9 @@
+enable_language(C)
+
+set(CMAKE_C_COMPILE_OPTIONS_COLOR_DIAGNOSTICS -DCOLOR_ON)
+set(CMAKE_C_COMPILE_OPTIONS_COLOR_DIAGNOSTICS_OFF -DCOLOR_OFF)
+
+add_library(diag STATIC diag.c)
+if(DEFINED EXPECT_COLOR)
+ target_compile_definitions(diag PRIVATE EXPECT_COLOR=${EXPECT_COLOR})
+endif()
diff --git a/Tests/RunCMake/Color/DiagDefault.cmake b/Tests/RunCMake/Color/DiagDefault.cmake
new file mode 100644
index 0000000..5add9dc
--- /dev/null
+++ b/Tests/RunCMake/Color/DiagDefault.cmake
@@ -0,0 +1,8 @@
+include(DiagCommon.cmake)
+
+if(DEFINED CMAKE_COLOR_DIAGNOSTICS)
+ message(FATAL_ERROR "CMAKE_COLOR_DIAGNOSTICS incorrectly defined.")
+endif()
+if(CMAKE_GENERATOR MATCHES "Make" AND NOT DEFINED CMAKE_COLOR_MAKEFILE)
+ message(FATAL_ERROR "CMAKE_COLOR_MAKEFILE incorrectly not defined.")
+endif()
diff --git a/Tests/RunCMake/Color/DiagOff.cmake b/Tests/RunCMake/Color/DiagOff.cmake
new file mode 100644
index 0000000..56657b0
--- /dev/null
+++ b/Tests/RunCMake/Color/DiagOff.cmake
@@ -0,0 +1,6 @@
+set(EXPECT_COLOR 0)
+include(DiagCommon.cmake)
+
+if(DEFINED CMAKE_COLOR_MAKEFILE)
+ message(FATAL_ERROR "CMAKE_COLOR_MAKEFILE incorrectly defined.")
+endif()
diff --git a/Tests/RunCMake/Color/DiagOn.cmake b/Tests/RunCMake/Color/DiagOn.cmake
new file mode 100644
index 0000000..fbb6c70
--- /dev/null
+++ b/Tests/RunCMake/Color/DiagOn.cmake
@@ -0,0 +1,6 @@
+set(EXPECT_COLOR 1)
+include(DiagCommon.cmake)
+
+if(DEFINED CMAKE_COLOR_MAKEFILE)
+ message(FATAL_ERROR "CMAKE_COLOR_MAKEFILE incorrectly defined.")
+endif()
diff --git a/Tests/RunCMake/Color/RunCMakeTest.cmake b/Tests/RunCMake/Color/RunCMakeTest.cmake
new file mode 100644
index 0000000..bb62d4c
--- /dev/null
+++ b/Tests/RunCMake/Color/RunCMakeTest.cmake
@@ -0,0 +1,14 @@
+include(RunCMake)
+
+unset(ENV{CMAKE_COLOR_DIAGNOSTICS})
+
+function(run_Diag case)
+ set(RunCMake_TEST_BINARY_DIR "${RunCMake_BINARY_DIR}/Diag${case}-build")
+ run_cmake_with_options(Diag${case} ${ARGN})
+ set(RunCMake_TEST_NO_CLEAN 1)
+ run_cmake_command(Diag${case}-build ${CMAKE_COMMAND} --build . --config Debug)
+endfunction()
+
+run_Diag(On -DCMAKE_COLOR_DIAGNOSTICS=ON)
+run_Diag(Off -DCMAKE_COLOR_DIAGNOSTICS=OFF)
+run_Diag(Default)
diff --git a/Tests/RunCMake/Color/diag.c b/Tests/RunCMake/Color/diag.c
new file mode 100644
index 0000000..7ff8304
--- /dev/null
+++ b/Tests/RunCMake/Color/diag.c
@@ -0,0 +1,28 @@
+#ifdef EXPECT_COLOR
+# if EXPECT_COLOR
+# ifndef COLOR_ON
+# error "COLOR_ON incorrectly not defined"
+# endif
+# ifdef COLOR_OFF
+# error "COLOR_OFF incorrectly defined"
+# endif
+# else
+# ifdef COLOR_ON
+# error "COLOR_ON incorrectly defined"
+# endif
+# ifndef COLOR_OFF
+# error "COLOR_OFF incorrectly not defined"
+# endif
+# endif
+#else
+# ifdef COLOR_ON
+# error "COLOR_ON incorrectly defined"
+# endif
+# ifdef COLOR_OFF
+# error "COLOR_OFF incorrectly defined"
+# endif
+#endif
+
+void diag(void)
+{
+}
diff --git a/Tests/RunCMake/CommandLine/E_cat-with-double-dash-stdout.txt b/Tests/RunCMake/CommandLine/E_cat-with-double-dash-stdout.txt
new file mode 100644
index 0000000..e5939d0
--- /dev/null
+++ b/Tests/RunCMake/CommandLine/E_cat-with-double-dash-stdout.txt
@@ -0,0 +1 @@
+file starting with dash, not an option
diff --git a/Tests/RunCMake/CommandLine/E_cat-without-double-dash-result.txt b/Tests/RunCMake/CommandLine/E_cat-without-double-dash-result.txt
new file mode 100644
index 0000000..d00491f
--- /dev/null
+++ b/Tests/RunCMake/CommandLine/E_cat-without-double-dash-result.txt
@@ -0,0 +1 @@
+1
diff --git a/Tests/RunCMake/CommandLine/E_cat-without-double-dash-stderr.txt b/Tests/RunCMake/CommandLine/E_cat-without-double-dash-stderr.txt
new file mode 100644
index 0000000..051f678
--- /dev/null
+++ b/Tests/RunCMake/CommandLine/E_cat-without-double-dash-stderr.txt
@@ -0,0 +1 @@
+^CMake Error: -file-starting-with-dash.txt: option not handled$
diff --git a/Tests/RunCMake/CommandLine/E_env-with-double-dash-result.txt b/Tests/RunCMake/CommandLine/E_env-with-double-dash-result.txt
new file mode 100644
index 0000000..573541a
--- /dev/null
+++ b/Tests/RunCMake/CommandLine/E_env-with-double-dash-result.txt
@@ -0,0 +1 @@
+0
diff --git a/Tests/RunCMake/CommandLine/E_env-without-double-dash-result.txt b/Tests/RunCMake/CommandLine/E_env-without-double-dash-result.txt
new file mode 100644
index 0000000..d00491f
--- /dev/null
+++ b/Tests/RunCMake/CommandLine/E_env-without-double-dash-result.txt
@@ -0,0 +1 @@
+1
diff --git a/Tests/RunCMake/CommandLine/E_env-without-double-dash-stderr.txt b/Tests/RunCMake/CommandLine/E_env-without-double-dash-stderr.txt
new file mode 100644
index 0000000..8d98f9d
--- /dev/null
+++ b/Tests/RunCMake/CommandLine/E_env-without-double-dash-stderr.txt
@@ -0,0 +1 @@
+.*
diff --git a/Tests/RunCMake/CommandLine/EnvColorDefault.cmake b/Tests/RunCMake/CommandLine/EnvColorDefault.cmake
new file mode 100644
index 0000000..dc4bc98
--- /dev/null
+++ b/Tests/RunCMake/CommandLine/EnvColorDefault.cmake
@@ -0,0 +1,6 @@
+if(DEFINED CMAKE_COLOR_DIAGNOSTICS)
+ message(FATAL_ERROR "CMAKE_COLOR_DIAGNOSTICS incorrectly defined.")
+endif()
+if(CMAKE_GENERATOR MATCHES "Make" AND NOT DEFINED CMAKE_COLOR_MAKEFILE)
+ message(FATAL_ERROR "CMAKE_COLOR_MAKEFILE incorrectly not defined.")
+endif()
diff --git a/Tests/RunCMake/CommandLine/EnvColorOn-stdout.txt b/Tests/RunCMake/CommandLine/EnvColorOn-stdout.txt
new file mode 100644
index 0000000..885925e
--- /dev/null
+++ b/Tests/RunCMake/CommandLine/EnvColorOn-stdout.txt
@@ -0,0 +1 @@
+-- CMAKE_COLOR_DIAGNOSTICS='ON'
diff --git a/Tests/RunCMake/CommandLine/EnvColorOn.cmake b/Tests/RunCMake/CommandLine/EnvColorOn.cmake
new file mode 100644
index 0000000..af1235d
--- /dev/null
+++ b/Tests/RunCMake/CommandLine/EnvColorOn.cmake
@@ -0,0 +1,4 @@
+message(STATUS "CMAKE_COLOR_DIAGNOSTICS='${CMAKE_COLOR_DIAGNOSTICS}'")
+if(DEFINED CMAKE_COLOR_MAKEFILE)
+ message(FATAL_ERROR "CMAKE_COLOR_MAKEFILE incorrectly defined.")
+endif()
diff --git a/Tests/RunCMake/CommandLine/P_arbitrary_args-stdout.txt b/Tests/RunCMake/CommandLine/P_arbitrary_args-stdout.txt
new file mode 100644
index 0000000..c0f96f3
--- /dev/null
+++ b/Tests/RunCMake/CommandLine/P_arbitrary_args-stdout.txt
@@ -0,0 +1,8 @@
+^-- CMAKE_ARGC='7'
+-- CMAKE_ARGV1='-P'
+-- CMAKE_ARGV2='[^']*/Tests/RunCMake/CommandLine/P_arbitrary_args.cmake'
+-- CMAKE_ARGV3='--'
+-- CMAKE_ARGV4='-DFOO'
+-- CMAKE_ARGV5='-S'
+-- CMAKE_ARGV6='-B'
+-- CMAKE_ARGV7=''$
diff --git a/Tests/RunCMake/CommandLine/P_arbitrary_args.cmake b/Tests/RunCMake/CommandLine/P_arbitrary_args.cmake
index 29faae3..d0a4859 100644
--- a/Tests/RunCMake/CommandLine/P_arbitrary_args.cmake
+++ b/Tests/RunCMake/CommandLine/P_arbitrary_args.cmake
@@ -1,3 +1,8 @@
-if(NOT ("${CMAKE_ARGV3}" STREQUAL "--" AND "${CMAKE_ARGV4}" STREQUAL "-DFOO"))
- message(FATAL_ERROR "`-DFOO` shouldn't trigger an error after `--`")
-endif()
+message(STATUS "CMAKE_ARGC='${CMAKE_ARGC}'")
+message(STATUS "CMAKE_ARGV1='${CMAKE_ARGV1}'")
+message(STATUS "CMAKE_ARGV2='${CMAKE_ARGV2}'")
+message(STATUS "CMAKE_ARGV3='${CMAKE_ARGV3}'")
+message(STATUS "CMAKE_ARGV4='${CMAKE_ARGV4}'")
+message(STATUS "CMAKE_ARGV5='${CMAKE_ARGV5}'")
+message(STATUS "CMAKE_ARGV6='${CMAKE_ARGV6}'")
+message(STATUS "CMAKE_ARGV7='${CMAKE_ARGV7}'")
diff --git a/Tests/RunCMake/CommandLine/RunCMakeTest.cmake b/Tests/RunCMake/CommandLine/RunCMakeTest.cmake
index f7554ff..22a59f2 100644
--- a/Tests/RunCMake/CommandLine/RunCMakeTest.cmake
+++ b/Tests/RunCMake/CommandLine/RunCMakeTest.cmake
@@ -52,7 +52,7 @@
run_cmake_command(G_bad-arg ${CMAKE_COMMAND} -B DummyBuildDir -G NoSuchGenerator)
run_cmake_command(P_no-arg ${CMAKE_COMMAND} -P)
run_cmake_command(P_no-file ${CMAKE_COMMAND} -P nosuchscriptfile.cmake)
-run_cmake_command(P_arbitrary_args ${CMAKE_COMMAND} -P "${RunCMake_SOURCE_DIR}/P_arbitrary_args.cmake" -- -DFOO)
+run_cmake_command(P_arbitrary_args ${CMAKE_COMMAND} -P "${RunCMake_SOURCE_DIR}/P_arbitrary_args.cmake" -- -DFOO -S -B)
run_cmake_command(build-no-dir
${CMAKE_COMMAND} --build)
@@ -445,6 +445,14 @@
endfunction()
run_EnvironmentToolchain()
+function(run_EnvironmentColor)
+ set(ENV{CMAKE_COLOR_DIAGNOSTICS} "ON")
+ run_cmake(EnvColorOn)
+ unset(ENV{CMAKE_COLOR_DIAGNOSTICS})
+ run_cmake(EnvColorDefault)
+endfunction()
+run_EnvironmentColor()
+
if(RunCMake_GENERATOR STREQUAL "Ninja")
# Use a single build tree for a few tests without cleaning.
set(RunCMake_TEST_BINARY_DIR ${RunCMake_BINARY_DIR}/Build-build)
@@ -705,17 +713,33 @@
file(WRITE "${out}/unicode_file.txt" "àéùç - í•œêµì–´") # Korean in Korean
run_cmake_command(E_cat_good_cat
${CMAKE_COMMAND} -E cat "${out}/first_file.txt" "${out}/second_file.txt" "${out}/empty_file.txt" "${out}/unicode_file.txt")
-unset(out)
run_cmake_command(E_cat_good_binary_cat
${CMAKE_COMMAND} -E cat "${RunCMake_SOURCE_DIR}/E_cat_binary_files/binary.obj" "${RunCMake_SOURCE_DIR}/E_cat_binary_files/binary.obj")
+# To test whether the double dash (--) works, we need to control the working directory
+# in order to be able to pass a relative path that starts with a dash.
+file(WRITE "${out}/-file-starting-with-dash.txt" "file starting with dash, not an option\n")
+set(RunCMake_TEST_COMMAND_WORKING_DIRECTORY "${out}")
+run_cmake_command(E_cat-with-double-dash ${CMAKE_COMMAND} -E cat -- "-file-starting-with-dash.txt")
+run_cmake_command(E_cat-without-double-dash ${CMAKE_COMMAND} -E cat "-file-starting-with-dash.txt")
+unset(RunCMake_TEST_COMMAND_WORKING_DIRECTORY)
+unset(out)
+
run_cmake_command(E_env-no-command0 ${CMAKE_COMMAND} -E env)
run_cmake_command(E_env-no-command1 ${CMAKE_COMMAND} -E env TEST_ENV=1)
run_cmake_command(E_env-bad-arg1 ${CMAKE_COMMAND} -E env -bad-arg1)
run_cmake_command(E_env-set ${CMAKE_COMMAND} -E env TEST_ENV=1 ${CMAKE_COMMAND} -P ${RunCMake_SOURCE_DIR}/E_env-set.cmake)
run_cmake_command(E_env-unset ${CMAKE_COMMAND} -E env TEST_ENV=1 ${CMAKE_COMMAND} -E env --unset=TEST_ENV ${CMAKE_COMMAND} -P ${RunCMake_SOURCE_DIR}/E_env-unset.cmake)
+# To test whether the double dash (--) works for the env command, we need a command that e.g. contains an equals sign (=)
+# and would normally be interpreted as an NAME=VALUE environment variable.
+# Ensuring such a command is done by simply copying the trivial exit_code executable with a different name.
+cmake_path(GET EXIT_CODE_EXE FILENAME exit_code)
+file(COPY_FILE "${EXIT_CODE_EXE}" "${RunCMake_BINARY_DIR}/env=${exit_code}")
+run_cmake_command(E_env-with-double-dash ${CMAKE_COMMAND} -E env TEST_ENV=1 -- "${RunCMake_BINARY_DIR}/env=${exit_code}" zero_exit)
+run_cmake_command(E_env-without-double-dash ${CMAKE_COMMAND} -E env TEST_ENV=1 "${RunCMake_BINARY_DIR}/env=${exit_code}" zero_exit)
+
run_cmake_command(E_md5sum-dir ${CMAKE_COMMAND} -E md5sum .)
run_cmake_command(E_sha1sum-dir ${CMAKE_COMMAND} -E sha1sum .)
run_cmake_command(E_sha224sum-dir ${CMAKE_COMMAND} -E sha224sum .)
diff --git a/Tests/RunCMake/CommandLine/trace-json-v1-check.py b/Tests/RunCMake/CommandLine/trace-json-v1-check.py
index 1ee005e..2ef1495 100755
--- a/Tests/RunCMake/CommandLine/trace-json-v1-check.py
+++ b/Tests/RunCMake/CommandLine/trace-json-v1-check.py
@@ -30,6 +30,8 @@
{
'args': ['STATUS', 'JSON-V1 str', 'spaces'],
'cmd': 'message',
+ 'line': 1,
+ 'line_end': 5
},
{
'args': ['ASDF', 'fff', 'sss', ' SPACES !!! '],
@@ -46,31 +48,54 @@
{
'args': msg_args,
'cmd': 'message',
- 'frame': 3 if expand else 2
+ 'frame': 3 if expand else 2,
+ 'global_frame': 3 if expand else 2
},
+ {
+ 'args': ['STATUS', 'nested global_frame'],
+ 'cmd': 'message',
+ 'frame': 3,
+ 'global_frame': 6 if expand else 5
+ }
]
+def assert_fields_look_good(line):
+ expected_fields = {'args', 'cmd', 'file', 'frame', 'global_frame','line', 'time'}
+ if "line_end" in line:
+ assert isinstance(line['line_end'], int)
+ assert line['line'] != line['line_end']
+ expected_fields.add("line_end")
+
+ assert set(line.keys()) == expected_fields
+
+ assert isinstance(line['args'], list)
+ assert isinstance(line['cmd'], unicode)
+ assert isinstance(line['file'], unicode)
+ assert isinstance(line['frame'], int)
+ assert isinstance(line['global_frame'], int)
+ assert isinstance(line['line'], int)
+ assert isinstance(line['time'], float)
+
+
with open(trace_file, 'r') as fp:
# Check for version (must be the first document)
vers = json.loads(fp.readline())
assert sorted(vers.keys()) == ['version']
assert sorted(vers['version'].keys()) == ['major', 'minor']
assert vers['version']['major'] == 1
- assert vers['version']['minor'] == 1
+ assert vers['version']['minor'] == 2
for i in fp.readlines():
line = json.loads(i)
- assert sorted(line.keys()) == ['args', 'cmd', 'file', 'frame', 'line', 'time']
- assert isinstance(line['args'], list)
- assert isinstance(line['cmd'], unicode)
- assert isinstance(line['file'], unicode)
- assert isinstance(line['frame'], int)
- assert isinstance(line['line'], int)
- assert isinstance(line['time'], float)
-
+ assert_fields_look_good(line)
for j in required_traces:
# Compare the subset of required keys with line
- if {k: line[k] for k in j} == j:
+ subset = {
+ k: line[k]
+ for k in j
+ if k in line
+ }
+ if subset == j:
required_traces.remove(j)
assert not required_traces
diff --git a/Tests/RunCMake/CommandLine/trace-json-v1-nested/CMakeLists.txt b/Tests/RunCMake/CommandLine/trace-json-v1-nested/CMakeLists.txt
new file mode 100644
index 0000000..089a960
--- /dev/null
+++ b/Tests/RunCMake/CommandLine/trace-json-v1-nested/CMakeLists.txt
@@ -0,0 +1,9 @@
+function(f)
+ message(STATUS "nested global_frame")
+endfunction()
+
+function(g)
+ f()
+endfunction()
+
+g()
diff --git a/Tests/RunCMake/CommandLine/trace-json-v1.cmake b/Tests/RunCMake/CommandLine/trace-json-v1.cmake
index ed0a0f9..4ed6160 100644
--- a/Tests/RunCMake/CommandLine/trace-json-v1.cmake
+++ b/Tests/RunCMake/CommandLine/trace-json-v1.cmake
@@ -1,5 +1,10 @@
-message(STATUS "JSON-V1 str" "spaces")
+message(
+ STATUS
+ "JSON-V1 str"
+ "spaces"
+ )
set(ASDF fff sss " SPACES !!! ")
set(FOO 42)
set(BAR " space in string!")
message(STATUS fff ${ASDF} " ${FOO} ${BAR}" " SPACES !!! ")
+add_subdirectory(trace-json-v1-nested)
diff --git a/Tests/RunCMake/ExternalProject/CONFIGURE_HANDLED_BY_BUILD.cmake b/Tests/RunCMake/ExternalProject/CONFIGURE_HANDLED_BY_BUILD.cmake
index 6dbf0f4..d531928 100644
--- a/Tests/RunCMake/ExternalProject/CONFIGURE_HANDLED_BY_BUILD.cmake
+++ b/Tests/RunCMake/ExternalProject/CONFIGURE_HANDLED_BY_BUILD.cmake
@@ -1,5 +1,12 @@
include(ExternalProject)
+if(CMAKE_GENERATOR STREQUAL "Borland Makefiles" OR
+ CMAKE_GENERATOR STREQUAL "Watcom WMake")
+ set(fs_delay 3)
+else()
+ set(fs_delay 1.125)
+endif()
+
# Given this setup, on the first build, both configure steps and both build
# steps will run. On a noop rebuild, only the build steps will run. Without
# CONFIGURE_HANDLED_BY_BUILD, the configure step of proj2 would also run on a
@@ -11,7 +18,7 @@
CONFIGURE_COMMAND ${CMAKE_COMMAND} -E echo "Doing something"
# file(TIMESTAMP) gives back the timestamp in seconds so we sleep a second to
# make sure we get a different timestamp on the stamp file
- BUILD_COMMAND ${CMAKE_COMMAND} -E sleep 1.125
+ BUILD_COMMAND ${CMAKE_COMMAND} -E sleep ${fs_delay}
INSTALL_COMMAND ""
BUILD_ALWAYS ON
STAMP_DIR "stamp"
@@ -20,7 +27,7 @@
DOWNLOAD_COMMAND ""
SOURCE_DIR ""
CONFIGURE_COMMAND ${CMAKE_COMMAND} -E echo "Doing something"
- BUILD_COMMAND ${CMAKE_COMMAND} -E sleep 1.125
+ BUILD_COMMAND ${CMAKE_COMMAND} -E sleep ${fs_delay}
INSTALL_COMMAND ""
CONFIGURE_HANDLED_BY_BUILD ON
DEPENDS proj1
diff --git a/Tests/RunCMake/ExternalProject/RunCMakeTest.cmake b/Tests/RunCMake/ExternalProject/RunCMakeTest.cmake
index fde384f..08adee2 100644
--- a/Tests/RunCMake/ExternalProject/RunCMakeTest.cmake
+++ b/Tests/RunCMake/ExternalProject/RunCMakeTest.cmake
@@ -105,12 +105,15 @@
if(EXISTS "${URL_FILE}")
file(REMOVE "${URL_FILE}")
endif()
+ if(NOT DOWNLOAD_SERVER_TIMEOUT)
+ set(DOWNLOAD_SERVER_TIMEOUT 30)
+ endif()
execute_process(
COMMAND ${Python3_EXECUTABLE} ${CMAKE_CURRENT_LIST_DIR}/DownloadServer.py --file "${URL_FILE}" ${ARGN}
OUTPUT_FILE ${RunCMake_BINARY_DIR}/${testName}-python.txt
ERROR_FILE ${RunCMake_BINARY_DIR}/${testName}-python.txt
RESULT_VARIABLE result
- TIMEOUT 30
+ TIMEOUT "${DOWNLOAD_SERVER_TIMEOUT}"
)
if(NOT result EQUAL 0)
message(FATAL_ERROR "Failed to start download server:\n ${result}")
diff --git a/Tests/RunCMake/GenEx-LINK_GROUP/CMakeLists.txt b/Tests/RunCMake/GenEx-LINK_GROUP/CMakeLists.txt
new file mode 100644
index 0000000..612169c
--- /dev/null
+++ b/Tests/RunCMake/GenEx-LINK_GROUP/CMakeLists.txt
@@ -0,0 +1,3 @@
+cmake_minimum_required(VERSION 3.18...3.22)
+project(${RunCMake_TEST} NONE)
+include(${RunCMake_TEST}.cmake)
diff --git a/Tests/RunCMake/GenEx-LINK_GROUP/RunCMakeTest.cmake b/Tests/RunCMake/GenEx-LINK_GROUP/RunCMakeTest.cmake
new file mode 100644
index 0000000..98eef35
--- /dev/null
+++ b/Tests/RunCMake/GenEx-LINK_GROUP/RunCMakeTest.cmake
@@ -0,0 +1,35 @@
+include(RunCMake)
+
+run_cmake(add_custom_target)
+run_cmake(add_custom_command)
+run_cmake(add_link_options)
+run_cmake(link_directories)
+run_cmake(target_link_options)
+run_cmake(target_link_directories)
+run_cmake(no-arguments)
+run_cmake(empty-arguments)
+run_cmake(forbidden-arguments)
+run_cmake(nested-incompatible-genex)
+run_cmake(invalid-feature)
+run_cmake(bad-feature1)
+run_cmake(bad-feature2)
+run_cmake(bad-feature3)
+run_cmake(bad-feature4)
+run_cmake(bad-feature5)
+run_cmake(feature-not-supported)
+run_cmake(library-ignored)
+run_cmake(compatible-features1)
+run_cmake(compatible-features2)
+run_cmake(compatible-features3)
+run_cmake(incompatible-features1)
+run_cmake(nested-incompatible-features1)
+run_cmake(nested-incompatible-features2)
+run_cmake(circular-dependencies1)
+run_cmake(circular-dependencies2)
+run_cmake(only-targets)
+
+# usage of LINK_LIBRARY with LINK_GROUP
+run_cmake(incompatible-library-features1)
+run_cmake(incompatible-library-features2)
+run_cmake(override-library-features1)
+run_cmake(override-library-features2)
diff --git a/Tests/RunCMake/GenEx-LINK_GROUP/add_custom_command-result.txt b/Tests/RunCMake/GenEx-LINK_GROUP/add_custom_command-result.txt
new file mode 100644
index 0000000..d00491f
--- /dev/null
+++ b/Tests/RunCMake/GenEx-LINK_GROUP/add_custom_command-result.txt
@@ -0,0 +1 @@
+1
diff --git a/Tests/RunCMake/GenEx-LINK_GROUP/add_custom_command-stderr.txt b/Tests/RunCMake/GenEx-LINK_GROUP/add_custom_command-stderr.txt
new file mode 100644
index 0000000..a80a11b
--- /dev/null
+++ b/Tests/RunCMake/GenEx-LINK_GROUP/add_custom_command-stderr.txt
@@ -0,0 +1,9 @@
+CMake Error at add_custom_command.cmake:[0-9]+ \(add_custom_command\):
+ Error evaluating generator expression:
+
+ \$<LINK_GROUP:feat>
+
+ \$<LINK_GROUP:...> may only be used with binary targets to specify group of
+ link libraries.
+Call Stack \(most recent call first\):
+ CMakeLists.txt:[0-9]+ \(include\)
diff --git a/Tests/RunCMake/GenEx-LINK_GROUP/add_custom_command.cmake b/Tests/RunCMake/GenEx-LINK_GROUP/add_custom_command.cmake
new file mode 100644
index 0000000..1efe276
--- /dev/null
+++ b/Tests/RunCMake/GenEx-LINK_GROUP/add_custom_command.cmake
@@ -0,0 +1,4 @@
+add_custom_target(drive)
+add_custom_command(TARGET drive PRE_BUILD
+ COMMAND ${CMAKE_COMMAND} -E echo "$<LINK_GROUP:feat>"
+)
diff --git a/Tests/RunCMake/GenEx-LINK_GROUP/add_custom_target-result.txt b/Tests/RunCMake/GenEx-LINK_GROUP/add_custom_target-result.txt
new file mode 100644
index 0000000..d00491f
--- /dev/null
+++ b/Tests/RunCMake/GenEx-LINK_GROUP/add_custom_target-result.txt
@@ -0,0 +1 @@
+1
diff --git a/Tests/RunCMake/GenEx-LINK_GROUP/add_custom_target-stderr.txt b/Tests/RunCMake/GenEx-LINK_GROUP/add_custom_target-stderr.txt
new file mode 100644
index 0000000..deb246a
--- /dev/null
+++ b/Tests/RunCMake/GenEx-LINK_GROUP/add_custom_target-stderr.txt
@@ -0,0 +1,9 @@
+CMake Error at add_custom_target.cmake:[0-9]+ \(add_custom_target\):
+ Error evaluating generator expression:
+
+ \$<LINK_GROUP:feat>
+
+ \$<LINK_GROUP:...> may only be used with binary targets to specify group of
+ link libraries.
+Call Stack \(most recent call first\):
+ CMakeLists.txt:[0-9]+ \(include\)
diff --git a/Tests/RunCMake/GenEx-LINK_GROUP/add_custom_target.cmake b/Tests/RunCMake/GenEx-LINK_GROUP/add_custom_target.cmake
new file mode 100644
index 0000000..cbb5ff0
--- /dev/null
+++ b/Tests/RunCMake/GenEx-LINK_GROUP/add_custom_target.cmake
@@ -0,0 +1,3 @@
+add_custom_target(drive
+ COMMAND ${CMAKE_COMMAND} -E echo "$<LINK_GROUP:feat>"
+)
diff --git a/Tests/RunCMake/GenEx-LINK_GROUP/add_link_options-result.txt b/Tests/RunCMake/GenEx-LINK_GROUP/add_link_options-result.txt
new file mode 100644
index 0000000..d00491f
--- /dev/null
+++ b/Tests/RunCMake/GenEx-LINK_GROUP/add_link_options-result.txt
@@ -0,0 +1 @@
+1
diff --git a/Tests/RunCMake/GenEx-LINK_GROUP/add_link_options-stderr.txt b/Tests/RunCMake/GenEx-LINK_GROUP/add_link_options-stderr.txt
new file mode 100644
index 0000000..17c348c
--- /dev/null
+++ b/Tests/RunCMake/GenEx-LINK_GROUP/add_link_options-stderr.txt
@@ -0,0 +1,9 @@
+CMake Error at add_link_options.cmake:[0-9]+ \(add_link_options\):
+ Error evaluating generator expression:
+
+ \$<LINK_GROUP:feat>
+
+ \$<LINK_GROUP:...> may only be used with binary targets to specify group of
+ link libraries.
+Call Stack \(most recent call first\):
+ CMakeLists.txt:[0-9]+ \(include\)
diff --git a/Tests/RunCMake/GenEx-LINK_GROUP/add_link_options.cmake b/Tests/RunCMake/GenEx-LINK_GROUP/add_link_options.cmake
new file mode 100644
index 0000000..2e31b34
--- /dev/null
+++ b/Tests/RunCMake/GenEx-LINK_GROUP/add_link_options.cmake
@@ -0,0 +1,5 @@
+enable_language(C)
+
+add_link_options("$<LINK_GROUP:feat>")
+
+add_library(empty SHARED empty.c)
diff --git a/Tests/RunCMake/GenEx-LINK_GROUP/bad-feature1-result.txt b/Tests/RunCMake/GenEx-LINK_GROUP/bad-feature1-result.txt
new file mode 100644
index 0000000..d00491f
--- /dev/null
+++ b/Tests/RunCMake/GenEx-LINK_GROUP/bad-feature1-result.txt
@@ -0,0 +1 @@
+1
diff --git a/Tests/RunCMake/GenEx-LINK_GROUP/bad-feature1-stderr.txt b/Tests/RunCMake/GenEx-LINK_GROUP/bad-feature1-stderr.txt
new file mode 100644
index 0000000..8c95452
--- /dev/null
+++ b/Tests/RunCMake/GenEx-LINK_GROUP/bad-feature1-stderr.txt
@@ -0,0 +1,5 @@
+CMake Error at bad-feature1.cmake:[0-9]+ \(add_library\):
+ Feature 'bad_feat', specified through generator-expression '\$<LINK_GROUP>'
+ to link target 'lib', is not supported for the 'C' link language.
+Call Stack \(most recent call first\):
+ CMakeLists.txt:[0-9]+ \(include\)
diff --git a/Tests/RunCMake/GenEx-LINK_GROUP/bad-feature1.cmake b/Tests/RunCMake/GenEx-LINK_GROUP/bad-feature1.cmake
new file mode 100644
index 0000000..0161221
--- /dev/null
+++ b/Tests/RunCMake/GenEx-LINK_GROUP/bad-feature1.cmake
@@ -0,0 +1,6 @@
+enable_language(C)
+
+add_library(dep SHARED empty.c)
+
+add_library(lib SHARED empty.c)
+target_link_libraries(lib PRIVATE "$<LINK_GROUP:bad_feat,dep>")
diff --git a/Tests/RunCMake/GenEx-LINK_GROUP/bad-feature2-result.txt b/Tests/RunCMake/GenEx-LINK_GROUP/bad-feature2-result.txt
new file mode 100644
index 0000000..d00491f
--- /dev/null
+++ b/Tests/RunCMake/GenEx-LINK_GROUP/bad-feature2-result.txt
@@ -0,0 +1 @@
+1
diff --git a/Tests/RunCMake/GenEx-LINK_GROUP/bad-feature2-stderr.txt b/Tests/RunCMake/GenEx-LINK_GROUP/bad-feature2-stderr.txt
new file mode 100644
index 0000000..3f057c4
--- /dev/null
+++ b/Tests/RunCMake/GenEx-LINK_GROUP/bad-feature2-stderr.txt
@@ -0,0 +1,5 @@
+CMake Error at bad-feature2.cmake:[0-9]+ \(add_library\):
+ Feature 'feat', specified through generator-expression '\$<LINK_GROUP>' to
+ link target 'lib', is not defined for the 'C' link language.
+Call Stack \(most recent call first\):
+ CMakeLists.txt:[0-9]+ \(include\)
diff --git a/Tests/RunCMake/GenEx-LINK_GROUP/bad-feature2.cmake b/Tests/RunCMake/GenEx-LINK_GROUP/bad-feature2.cmake
new file mode 100644
index 0000000..7e56194
--- /dev/null
+++ b/Tests/RunCMake/GenEx-LINK_GROUP/bad-feature2.cmake
@@ -0,0 +1,8 @@
+enable_language(C)
+
+set(CMAKE_C_LINK_GROUP_USING_feat_SUPPORTED TRUE)
+
+add_library(dep SHARED empty.c)
+
+add_library(lib SHARED empty.c)
+target_link_libraries(lib PRIVATE "$<LINK_GROUP:feat,dep>")
diff --git a/Tests/RunCMake/GenEx-LINK_GROUP/bad-feature3-result.txt b/Tests/RunCMake/GenEx-LINK_GROUP/bad-feature3-result.txt
new file mode 100644
index 0000000..d00491f
--- /dev/null
+++ b/Tests/RunCMake/GenEx-LINK_GROUP/bad-feature3-result.txt
@@ -0,0 +1 @@
+1
diff --git a/Tests/RunCMake/GenEx-LINK_GROUP/bad-feature3-stderr.txt b/Tests/RunCMake/GenEx-LINK_GROUP/bad-feature3-stderr.txt
new file mode 100644
index 0000000..43e2700
--- /dev/null
+++ b/Tests/RunCMake/GenEx-LINK_GROUP/bad-feature3-stderr.txt
@@ -0,0 +1,6 @@
+CMake Error at bad-feature3.cmake:[0-9]+ \(add_library\):
+ Feature 'feat', specified by variable 'CMAKE_C_LINK_GROUP_USING_feat', is
+ malformed \(wrong number of elements\) and cannot be used to link target
+ 'lib'.
+Call Stack \(most recent call first\):
+ CMakeLists.txt:[0-9]+ \(include\)
diff --git a/Tests/RunCMake/GenEx-LINK_GROUP/bad-feature3.cmake b/Tests/RunCMake/GenEx-LINK_GROUP/bad-feature3.cmake
new file mode 100644
index 0000000..58b422a
--- /dev/null
+++ b/Tests/RunCMake/GenEx-LINK_GROUP/bad-feature3.cmake
@@ -0,0 +1,9 @@
+enable_language(C)
+
+set(CMAKE_C_LINK_GROUP_USING_feat_SUPPORTED TRUE)
+set(CMAKE_C_LINK_GROUP_USING_feat "")
+
+add_library(dep SHARED empty.c)
+
+add_library(lib SHARED empty.c)
+target_link_libraries(lib PRIVATE "$<LINK_GROUP:feat,dep>")
diff --git a/Tests/RunCMake/GenEx-LINK_GROUP/bad-feature4-result.txt b/Tests/RunCMake/GenEx-LINK_GROUP/bad-feature4-result.txt
new file mode 100644
index 0000000..d00491f
--- /dev/null
+++ b/Tests/RunCMake/GenEx-LINK_GROUP/bad-feature4-result.txt
@@ -0,0 +1 @@
+1
diff --git a/Tests/RunCMake/GenEx-LINK_GROUP/bad-feature4-stderr.txt b/Tests/RunCMake/GenEx-LINK_GROUP/bad-feature4-stderr.txt
new file mode 100644
index 0000000..0a2ba60
--- /dev/null
+++ b/Tests/RunCMake/GenEx-LINK_GROUP/bad-feature4-stderr.txt
@@ -0,0 +1,6 @@
+CMake Error at bad-feature4.cmake:[0-9]+ \(add_library\):
+ Feature 'feat', specified by variable 'CMAKE_C_LINK_GROUP_USING_feat', is
+ malformed \(wrong number of elements\) and cannot be used to link target
+ 'lib'.
+Call Stack \(most recent call first\):
+ CMakeLists.txt:[0-9]+ \(include\)
diff --git a/Tests/RunCMake/GenEx-LINK_GROUP/bad-feature4.cmake b/Tests/RunCMake/GenEx-LINK_GROUP/bad-feature4.cmake
new file mode 100644
index 0000000..dcb8236
--- /dev/null
+++ b/Tests/RunCMake/GenEx-LINK_GROUP/bad-feature4.cmake
@@ -0,0 +1,9 @@
+enable_language(C)
+
+set(CMAKE_C_LINK_GROUP_USING_feat_SUPPORTED TRUE)
+set(CMAKE_C_LINK_GROUP_USING_feat "-opt")
+
+add_library(dep SHARED empty.c)
+
+add_library(lib SHARED empty.c)
+target_link_libraries(lib PRIVATE "$<LINK_GROUP:feat,dep>")
diff --git a/Tests/RunCMake/GenEx-LINK_GROUP/bad-feature5-result.txt b/Tests/RunCMake/GenEx-LINK_GROUP/bad-feature5-result.txt
new file mode 100644
index 0000000..d00491f
--- /dev/null
+++ b/Tests/RunCMake/GenEx-LINK_GROUP/bad-feature5-result.txt
@@ -0,0 +1 @@
+1
diff --git a/Tests/RunCMake/GenEx-LINK_GROUP/bad-feature5-stderr.txt b/Tests/RunCMake/GenEx-LINK_GROUP/bad-feature5-stderr.txt
new file mode 100644
index 0000000..4b1f01d
--- /dev/null
+++ b/Tests/RunCMake/GenEx-LINK_GROUP/bad-feature5-stderr.txt
@@ -0,0 +1,6 @@
+CMake Error at bad-feature5.cmake:[0-9]+ \(add_library\):
+ Feature 'feat', specified by variable 'CMAKE_C_LINK_GROUP_USING_feat', is
+ malformed \(wrong number of elements\) and cannot be used to link target
+ 'lib'.
+Call Stack \(most recent call first\):
+ CMakeLists.txt:[0-9]+ \(include\)
diff --git a/Tests/RunCMake/GenEx-LINK_GROUP/bad-feature5.cmake b/Tests/RunCMake/GenEx-LINK_GROUP/bad-feature5.cmake
new file mode 100644
index 0000000..cb10996
--- /dev/null
+++ b/Tests/RunCMake/GenEx-LINK_GROUP/bad-feature5.cmake
@@ -0,0 +1,9 @@
+enable_language(C)
+
+set(CMAKE_C_LINK_GROUP_USING_feat_SUPPORTED TRUE)
+set(CMAKE_C_LINK_GROUP_USING_feat "-start" "<LIBRARY>" "-stop")
+
+add_library(dep SHARED empty.c)
+
+add_library(lib SHARED empty.c)
+target_link_libraries(lib PRIVATE "$<LINK_GROUP:feat,dep>")
diff --git a/Tests/RunCMake/GenEx-LINK_GROUP/circular-dependencies1-result.txt b/Tests/RunCMake/GenEx-LINK_GROUP/circular-dependencies1-result.txt
new file mode 100644
index 0000000..d00491f
--- /dev/null
+++ b/Tests/RunCMake/GenEx-LINK_GROUP/circular-dependencies1-result.txt
@@ -0,0 +1 @@
+1
diff --git a/Tests/RunCMake/GenEx-LINK_GROUP/circular-dependencies1-stderr.txt b/Tests/RunCMake/GenEx-LINK_GROUP/circular-dependencies1-stderr.txt
new file mode 100644
index 0000000..94008e1
--- /dev/null
+++ b/Tests/RunCMake/GenEx-LINK_GROUP/circular-dependencies1-stderr.txt
@@ -0,0 +1,11 @@
+CMake Error at circular-dependencies1.cmake:[0-9]+ \(add_library\):
+ The inter-target dependency graph, for the target "lib1", contains the
+ following strongly connected component \(cycle\):
+
+ group "feat:{dep1.1,dep1.2}"
+ depends on group "feat:{dep2.1,dep2.2}"
+ group "feat:{dep2.1,dep2.2}"
+ depends on group "feat:{dep1.1,dep1.2}"
+
+Call Stack \(most recent call first\):
+ CMakeLists.txt:[0-9]+ \(include\)
diff --git a/Tests/RunCMake/GenEx-LINK_GROUP/circular-dependencies1.cmake b/Tests/RunCMake/GenEx-LINK_GROUP/circular-dependencies1.cmake
new file mode 100644
index 0000000..a1d7575
--- /dev/null
+++ b/Tests/RunCMake/GenEx-LINK_GROUP/circular-dependencies1.cmake
@@ -0,0 +1,17 @@
+enable_language(C)
+
+set(CMAKE_C_LINK_GROUP_USING_feat_SUPPORTED TRUE)
+set(CMAKE_C_LINK_GROUP_USING_feat "--start" "--stop")
+
+add_library(dep1.1 SHARED empty.c)
+add_library(dep1.2 SHARED empty.c)
+
+add_library(dep2.1 SHARED empty.c)
+add_library(dep2.2 SHARED empty.c)
+
+target_link_libraries(dep1.1 PUBLIC dep2.1)
+target_link_libraries(dep2.2 PUBLIC dep1.2)
+
+add_library(lib1 SHARED empty.c)
+target_link_libraries(lib1 PRIVATE "$<LINK_GROUP:feat,dep1.1,dep1.2>"
+ "$<LINK_GROUP:feat,dep2.1,dep2.2>")
diff --git a/Tests/RunCMake/GenEx-LINK_GROUP/circular-dependencies2-result.txt b/Tests/RunCMake/GenEx-LINK_GROUP/circular-dependencies2-result.txt
new file mode 100644
index 0000000..d00491f
--- /dev/null
+++ b/Tests/RunCMake/GenEx-LINK_GROUP/circular-dependencies2-result.txt
@@ -0,0 +1 @@
+1
diff --git a/Tests/RunCMake/GenEx-LINK_GROUP/circular-dependencies2-stderr.txt b/Tests/RunCMake/GenEx-LINK_GROUP/circular-dependencies2-stderr.txt
new file mode 100644
index 0000000..365e98f
--- /dev/null
+++ b/Tests/RunCMake/GenEx-LINK_GROUP/circular-dependencies2-stderr.txt
@@ -0,0 +1,11 @@
+CMake Error at circular-dependencies2.cmake:[0-9]+ \(add_library\):
+ The inter-target dependency graph, for the target "lib2", contains the
+ following strongly connected component \(cycle\):
+
+ group "feat:{base3,base4}"
+ depends on group "feat:{base1,base2}"
+ group "feat:{base1,base2}"
+ depends on group "feat:{base3,base4}"
+
+Call Stack \(most recent call first\):
+ CMakeLists.txt:[0-9]+ \(include\)
diff --git a/Tests/RunCMake/GenEx-LINK_GROUP/circular-dependencies2.cmake b/Tests/RunCMake/GenEx-LINK_GROUP/circular-dependencies2.cmake
new file mode 100644
index 0000000..99fda4d
--- /dev/null
+++ b/Tests/RunCMake/GenEx-LINK_GROUP/circular-dependencies2.cmake
@@ -0,0 +1,18 @@
+enable_language(C)
+
+set(CMAKE_C_LINK_GROUP_USING_feat_SUPPORTED TRUE)
+set(CMAKE_C_LINK_GROUP_USING_feat "--start" "--stop")
+
+add_library(base1 SHARED empty.c)
+add_library(base2 SHARED empty.c)
+add_library(base3 SHARED empty.c)
+add_library(base4 SHARED empty.c)
+
+target_link_libraries(base1 PUBLIC base3)
+target_link_libraries(base4 PUBLIC base2)
+
+add_library(lib1 SHARED empty.c)
+target_link_libraries(lib1 PUBLIC "$<LINK_GROUP:feat,base1,base2>")
+
+add_library(lib2 SHARED empty.c)
+target_link_libraries(lib2 PRIVATE "$<LINK_GROUP:feat,base3,base4>" lib1)
diff --git a/Tests/RunCMake/GenEx-LINK_GROUP/compatible-features1.cmake b/Tests/RunCMake/GenEx-LINK_GROUP/compatible-features1.cmake
new file mode 100644
index 0000000..9d10f95
--- /dev/null
+++ b/Tests/RunCMake/GenEx-LINK_GROUP/compatible-features1.cmake
@@ -0,0 +1,18 @@
+enable_language(C)
+
+set(CMAKE_C_LINK_GROUP_USING_feat1_SUPPORTED TRUE)
+set(CMAKE_C_LINK_GROUP_USING_feat1 "--start" "--stop")
+
+set(CMAKE_C_LINK_GROUP_USING_feat2_SUPPORTED TRUE)
+set(CMAKE_C_LINK_GROUP_USING_feat2 "--start" "--stop")
+
+add_library(dep1 SHARED empty.c)
+
+add_library(dep2 SHARED empty.c)
+target_link_libraries(dep2 PRIVATE "$<LINK_GROUP:feat1,dep1>")
+
+add_library(dep3 SHARED empty.c)
+target_link_libraries(dep3 PUBLIC dep2)
+
+add_library(lib1 SHARED empty.c)
+target_link_libraries(lib1 PRIVATE $<LINK_GROUP:feat2,dep1,dep2>)
diff --git a/Tests/RunCMake/GenEx-LINK_GROUP/compatible-features2.cmake b/Tests/RunCMake/GenEx-LINK_GROUP/compatible-features2.cmake
new file mode 100644
index 0000000..1fe2880
--- /dev/null
+++ b/Tests/RunCMake/GenEx-LINK_GROUP/compatible-features2.cmake
@@ -0,0 +1,13 @@
+enable_language(C)
+
+set(CMAKE_C_LINK_GROUP_USING_feat_SUPPORTED TRUE)
+set(CMAKE_C_LINK_GROUP_USING_feat "--start" "--stop")
+
+add_library(dep1 SHARED empty.c)
+add_library(dep2 SHARED empty.c)
+
+add_library(lib1 SHARED empty.c)
+target_link_libraries(lib1 PUBLIC "$<LINK_GROUP:feat,dep1,dep2>")
+
+add_library(lib2 SHARED empty.c)
+target_link_libraries(lib2 PRIVATE "$<LINK_GROUP:feat,dep2,lib1>")
diff --git a/Tests/RunCMake/GenEx-LINK_GROUP/compatible-features3.cmake b/Tests/RunCMake/GenEx-LINK_GROUP/compatible-features3.cmake
new file mode 100644
index 0000000..ac486ce
--- /dev/null
+++ b/Tests/RunCMake/GenEx-LINK_GROUP/compatible-features3.cmake
@@ -0,0 +1,13 @@
+enable_language(C)
+
+set(CMAKE_C_LINK_GROUP_USING_feat_SUPPORTED TRUE)
+set(CMAKE_C_LINK_GROUP_USING_feat "--start" "--stop")
+
+add_library(dep1 SHARED empty.c)
+add_library(dep2 SHARED empty.c)
+target_link_libraries(dep2 PUBLIC dep1)
+add_library(dep3 SHARED empty.c)
+target_link_libraries(dep3 PUBLIC dep1)
+
+add_library(lib1 SHARED empty.c)
+target_link_libraries(lib1 PUBLIC "$<LINK_GROUP:feat,dep1,dep2>" dep3)
diff --git a/Tests/RunCMake/GenEx-LINK_GROUP/empty-arguments-result.txt b/Tests/RunCMake/GenEx-LINK_GROUP/empty-arguments-result.txt
new file mode 100644
index 0000000..d00491f
--- /dev/null
+++ b/Tests/RunCMake/GenEx-LINK_GROUP/empty-arguments-result.txt
@@ -0,0 +1 @@
+1
diff --git a/Tests/RunCMake/GenEx-LINK_GROUP/empty-arguments-stderr.txt b/Tests/RunCMake/GenEx-LINK_GROUP/empty-arguments-stderr.txt
new file mode 100644
index 0000000..27101cb
--- /dev/null
+++ b/Tests/RunCMake/GenEx-LINK_GROUP/empty-arguments-stderr.txt
@@ -0,0 +1,8 @@
+CMake Error at empty-arguments.cmake:[0-9]+ \(target_link_libraries\):
+ Error evaluating generator expression:
+
+ \$<LINK_GROUP:,>
+
+ \$<LINK_GROUP:...> expects a feature name as first argument.
+Call Stack \(most recent call first\):
+ CMakeLists.txt:[0-9]+ \(include\)
diff --git a/Tests/RunCMake/GenEx-LINK_GROUP/empty-arguments.cmake b/Tests/RunCMake/GenEx-LINK_GROUP/empty-arguments.cmake
new file mode 100644
index 0000000..6093935
--- /dev/null
+++ b/Tests/RunCMake/GenEx-LINK_GROUP/empty-arguments.cmake
@@ -0,0 +1,4 @@
+enable_language(C)
+
+add_library(lib SHARED empty.c)
+target_link_libraries(lib PRIVATE "$<LINK_GROUP:,>")
diff --git a/Tests/RunCMake/GenEx-LINK_GROUP/empty.c b/Tests/RunCMake/GenEx-LINK_GROUP/empty.c
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/Tests/RunCMake/GenEx-LINK_GROUP/empty.c
diff --git a/Tests/RunCMake/GenEx-LINK_GROUP/feature-not-supported-result.txt b/Tests/RunCMake/GenEx-LINK_GROUP/feature-not-supported-result.txt
new file mode 100644
index 0000000..d00491f
--- /dev/null
+++ b/Tests/RunCMake/GenEx-LINK_GROUP/feature-not-supported-result.txt
@@ -0,0 +1 @@
+1
diff --git a/Tests/RunCMake/GenEx-LINK_GROUP/feature-not-supported-stderr.txt b/Tests/RunCMake/GenEx-LINK_GROUP/feature-not-supported-stderr.txt
new file mode 100644
index 0000000..3507f4d
--- /dev/null
+++ b/Tests/RunCMake/GenEx-LINK_GROUP/feature-not-supported-stderr.txt
@@ -0,0 +1,5 @@
+CMake Error at feature-not-supported.cmake:[0-9]+ \(add_library\):
+ Feature 'feat', specified through generator-expression '\$<LINK_GROUP>' to
+ link target 'lib', is not supported for the 'C' link language.
+Call Stack \(most recent call first\):
+ CMakeLists.txt:[0-9]+ \(include\)
diff --git a/Tests/RunCMake/GenEx-LINK_GROUP/feature-not-supported.cmake b/Tests/RunCMake/GenEx-LINK_GROUP/feature-not-supported.cmake
new file mode 100644
index 0000000..c4739bb
--- /dev/null
+++ b/Tests/RunCMake/GenEx-LINK_GROUP/feature-not-supported.cmake
@@ -0,0 +1,9 @@
+enable_language(C)
+
+set(CMAKE_C_LINK_GROUP_USING_feat_SUPPORTED FALSE)
+set(CMAKE_C_LINK_GROUP_USING_feat "--start" "--end")
+
+add_library(dep SHARED empty.c)
+
+add_library(lib SHARED empty.c)
+target_link_libraries(lib PRIVATE "$<LINK_GROUP:feat,dep>")
diff --git a/Tests/RunCMake/GenEx-LINK_GROUP/forbidden-arguments-result.txt b/Tests/RunCMake/GenEx-LINK_GROUP/forbidden-arguments-result.txt
new file mode 100644
index 0000000..d00491f
--- /dev/null
+++ b/Tests/RunCMake/GenEx-LINK_GROUP/forbidden-arguments-result.txt
@@ -0,0 +1 @@
+1
diff --git a/Tests/RunCMake/GenEx-LINK_GROUP/forbidden-arguments-stderr.txt b/Tests/RunCMake/GenEx-LINK_GROUP/forbidden-arguments-stderr.txt
new file mode 100644
index 0000000..bae6505
--- /dev/null
+++ b/Tests/RunCMake/GenEx-LINK_GROUP/forbidden-arguments-stderr.txt
@@ -0,0 +1,16 @@
+CMake Error at forbidden-arguments.cmake:[0-9]+ \(link_libraries\):
+ Property LINK_LIBRARIES contains the invalid item "<LINK_GROUP:feat>". The
+ LINK_LIBRARIES property may contain the generator-expression
+ "\$<LINK_GROUP:...>" which may be used to specify how the libraries are
+ linked.
+Call Stack \(most recent call first\):
+ CMakeLists.txt:[0-9]+ \(include\)
+
+
+CMake Error at forbidden-arguments.cmake:[0-9]+ \(target_link_libraries\):
+ Property LINK_LIBRARIES contains the invalid item "<LINK_GROUP:feat>". The
+ LINK_LIBRARIES property may contain the generator-expression
+ "\$<LINK_GROUP:...>" which may be used to specify how the libraries are
+ linked.
+Call Stack \(most recent call first\):
+ CMakeLists.txt:[0-9]+ \(include\)
diff --git a/Tests/RunCMake/GenEx-LINK_GROUP/forbidden-arguments.cmake b/Tests/RunCMake/GenEx-LINK_GROUP/forbidden-arguments.cmake
new file mode 100644
index 0000000..dcbf8dd
--- /dev/null
+++ b/Tests/RunCMake/GenEx-LINK_GROUP/forbidden-arguments.cmake
@@ -0,0 +1,6 @@
+enable_language(C)
+
+link_libraries(<LINK_GROUP:feat> foo </LINK_GROUP:feat>)
+
+add_library(lib SHARED empty.c)
+target_link_libraries(lib PRIVATE <LINK_GROUP:feat> foo </LINK_GROUP:feat>)
diff --git a/Tests/RunCMake/GenEx-LINK_GROUP/incompatible-features1-result.txt b/Tests/RunCMake/GenEx-LINK_GROUP/incompatible-features1-result.txt
new file mode 100644
index 0000000..d00491f
--- /dev/null
+++ b/Tests/RunCMake/GenEx-LINK_GROUP/incompatible-features1-result.txt
@@ -0,0 +1 @@
+1
diff --git a/Tests/RunCMake/GenEx-LINK_GROUP/incompatible-features1-stderr.txt b/Tests/RunCMake/GenEx-LINK_GROUP/incompatible-features1-stderr.txt
new file mode 100644
index 0000000..932245d
--- /dev/null
+++ b/Tests/RunCMake/GenEx-LINK_GROUP/incompatible-features1-stderr.txt
@@ -0,0 +1,6 @@
+CMake Error at incompatible-features1.cmake:[0-9]+ \(add_library\):
+ Impossible to link target 'lib1' because the link item 'dep2', specified
+ with the group feature 'feat1', has already occurred with the feature
+ 'feat2', which is not allowed.
+Call Stack \(most recent call first\):
+ CMakeLists.txt:[0-9]+ \(include\)
diff --git a/Tests/RunCMake/GenEx-LINK_GROUP/incompatible-features1.cmake b/Tests/RunCMake/GenEx-LINK_GROUP/incompatible-features1.cmake
new file mode 100644
index 0000000..efac0f8
--- /dev/null
+++ b/Tests/RunCMake/GenEx-LINK_GROUP/incompatible-features1.cmake
@@ -0,0 +1,15 @@
+enable_language(C)
+
+set(CMAKE_C_LINK_GROUP_USING_feat1_SUPPORTED TRUE)
+set(CMAKE_C_LINK_GROUP_USING_feat1 "--start" "--stop")
+
+set(CMAKE_C_LINK_GROUP_USING_feat2_SUPPORTED TRUE)
+set(CMAKE_C_LINK_GROUP_USING_feat2 "--start" "--stop")
+
+add_library(dep1 SHARED empty.c)
+add_library(dep2 SHARED empty.c)
+add_library(dep3 SHARED empty.c)
+target_link_libraries(dep3 PUBLIC "$<LINK_GROUP:feat1,dep1,dep2>")
+
+add_library(lib1 SHARED empty.c)
+target_link_libraries(lib1 PRIVATE "$<LINK_GROUP:feat2,dep2,dep3>")
diff --git a/Tests/RunCMake/GenEx-LINK_GROUP/incompatible-library-features1-result.txt b/Tests/RunCMake/GenEx-LINK_GROUP/incompatible-library-features1-result.txt
new file mode 100644
index 0000000..d00491f
--- /dev/null
+++ b/Tests/RunCMake/GenEx-LINK_GROUP/incompatible-library-features1-result.txt
@@ -0,0 +1 @@
+1
diff --git a/Tests/RunCMake/GenEx-LINK_GROUP/incompatible-library-features1-stderr.txt b/Tests/RunCMake/GenEx-LINK_GROUP/incompatible-library-features1-stderr.txt
new file mode 100644
index 0000000..e3a4250
--- /dev/null
+++ b/Tests/RunCMake/GenEx-LINK_GROUP/incompatible-library-features1-stderr.txt
@@ -0,0 +1,6 @@
+CMake Error at incompatible-library-features1.cmake:[0-9]+ \(add_library\):
+ Impossible to link target 'lib1' because the link item 'dep1', specified
+ with the feature 'feat1', has already occurred without any feature or
+ 'DEFAULT' feature, which is not allowed.
+Call Stack \(most recent call first\):
+ CMakeLists.txt:[0-9]+ \(include\)
diff --git a/Tests/RunCMake/GenEx-LINK_GROUP/incompatible-library-features1.cmake b/Tests/RunCMake/GenEx-LINK_GROUP/incompatible-library-features1.cmake
new file mode 100644
index 0000000..203f071
--- /dev/null
+++ b/Tests/RunCMake/GenEx-LINK_GROUP/incompatible-library-features1.cmake
@@ -0,0 +1,17 @@
+enable_language(C)
+
+set(CMAKE_C_LINK_GROUP_USING_feat1_SUPPORTED TRUE)
+set(CMAKE_C_LINK_GROUP_USING_feat1 "--start" "--stop")
+
+set(CMAKE_C_LINK_LIBRARY_USING_feat1_SUPPORTED TRUE)
+set(CMAKE_C_LINK_LIBRARY_USING_feat1 "--libflag1<LIBRARY>")
+
+set(CMAKE_C_LINK_LIBRARY_USING_feat2_SUPPORTED TRUE)
+set(CMAKE_C_LINK_LIBRARY_USING_feat2 "--libflag2<LIBRARY>")
+
+add_library(dep1 SHARED empty.c)
+add_library(dep2 SHARED empty.c)
+target_link_libraries(dep2 PUBLIC "$<LINK_LIBRARY:feat1,dep1>")
+
+add_library(lib1 SHARED empty.c)
+target_link_libraries(lib1 PRIVATE "$<LINK_GROUP:feat1,$<LINK_LIBRARY:feat2,dep2>,dep1>")
diff --git a/Tests/RunCMake/GenEx-LINK_GROUP/incompatible-library-features2-result.txt b/Tests/RunCMake/GenEx-LINK_GROUP/incompatible-library-features2-result.txt
new file mode 100644
index 0000000..d00491f
--- /dev/null
+++ b/Tests/RunCMake/GenEx-LINK_GROUP/incompatible-library-features2-result.txt
@@ -0,0 +1 @@
+1
diff --git a/Tests/RunCMake/GenEx-LINK_GROUP/incompatible-library-features2-stderr.txt b/Tests/RunCMake/GenEx-LINK_GROUP/incompatible-library-features2-stderr.txt
new file mode 100644
index 0000000..889cba0
--- /dev/null
+++ b/Tests/RunCMake/GenEx-LINK_GROUP/incompatible-library-features2-stderr.txt
@@ -0,0 +1,6 @@
+CMake Error at incompatible-library-features2.cmake:[0-9]+ \(add_library\):
+ Impossible to link target 'lib1' because the link item 'dep1', specified
+ with the feature 'feat1', has already occurred with the feature 'feat2',
+ which is not allowed.
+Call Stack \(most recent call first\):
+ CMakeLists.txt:[0-9]+ \(include\)
diff --git a/Tests/RunCMake/GenEx-LINK_GROUP/incompatible-library-features2.cmake b/Tests/RunCMake/GenEx-LINK_GROUP/incompatible-library-features2.cmake
new file mode 100644
index 0000000..6490819
--- /dev/null
+++ b/Tests/RunCMake/GenEx-LINK_GROUP/incompatible-library-features2.cmake
@@ -0,0 +1,17 @@
+enable_language(C)
+
+set(CMAKE_C_LINK_GROUP_USING_feat1_SUPPORTED TRUE)
+set(CMAKE_C_LINK_GROUP_USING_feat1 "--start" "--stop")
+
+set(CMAKE_C_LINK_LIBRARY_USING_feat1_SUPPORTED TRUE)
+set(CMAKE_C_LINK_LIBRARY_USING_feat1 "--libflag1<LIBRARY>")
+
+set(CMAKE_C_LINK_LIBRARY_USING_feat2_SUPPORTED TRUE)
+set(CMAKE_C_LINK_LIBRARY_USING_feat2 "--libflag2<LIBRARY>")
+
+add_library(dep1 SHARED empty.c)
+add_library(dep2 SHARED empty.c)
+target_link_libraries(dep2 PUBLIC "$<LINK_LIBRARY:feat1,dep1>")
+
+add_library(lib1 SHARED empty.c)
+target_link_libraries(lib1 PRIVATE "$<LINK_GROUP:feat1,$<LINK_LIBRARY:feat2,dep2,dep1>>")
diff --git a/Tests/RunCMake/GenEx-LINK_GROUP/invalid-feature-result.txt b/Tests/RunCMake/GenEx-LINK_GROUP/invalid-feature-result.txt
new file mode 100644
index 0000000..d00491f
--- /dev/null
+++ b/Tests/RunCMake/GenEx-LINK_GROUP/invalid-feature-result.txt
@@ -0,0 +1 @@
+1
diff --git a/Tests/RunCMake/GenEx-LINK_GROUP/invalid-feature-stderr.txt b/Tests/RunCMake/GenEx-LINK_GROUP/invalid-feature-stderr.txt
new file mode 100644
index 0000000..793b393
--- /dev/null
+++ b/Tests/RunCMake/GenEx-LINK_GROUP/invalid-feature-stderr.txt
@@ -0,0 +1,8 @@
+CMake Error at invalid-feature.cmake:[0-9]+ \(target_link_libraries\):
+ Error evaluating generator expression:
+
+ \$<LINK_GROUP:feat:invalid,dep>
+
+ The feature name 'feat:invalid' contains invalid characters.
+Call Stack \(most recent call first\):
+ CMakeLists.txt:[0-9]+ \(include\)
diff --git a/Tests/RunCMake/GenEx-LINK_GROUP/invalid-feature.cmake b/Tests/RunCMake/GenEx-LINK_GROUP/invalid-feature.cmake
new file mode 100644
index 0000000..34a319c
--- /dev/null
+++ b/Tests/RunCMake/GenEx-LINK_GROUP/invalid-feature.cmake
@@ -0,0 +1,6 @@
+enable_language(C)
+
+add_library(dep SHARED empty.c)
+
+add_library(lib SHARED empty.c)
+target_link_libraries(lib PRIVATE "$<LINK_GROUP:feat:invalid,dep>")
diff --git a/Tests/RunCMake/GenEx-LINK_GROUP/library-ignored-stderr.txt b/Tests/RunCMake/GenEx-LINK_GROUP/library-ignored-stderr.txt
new file mode 100644
index 0000000..b29c4ec
--- /dev/null
+++ b/Tests/RunCMake/GenEx-LINK_GROUP/library-ignored-stderr.txt
@@ -0,0 +1,13 @@
+CMake Warning \(dev\) at library-ignored.cmake:[0-9]+ \(add_library\):
+ The feature 'feat', specified as part of a generator-expression
+ '\$<LINK_GROUP:feat>', will not be applied to the INTERFACE library 'front'.
+Call Stack \(most recent call first\):
+ CMakeLists.txt:[0-9]+ \(include\)
+This warning is for project developers. Use -Wno-dev to suppress it.
+
+CMake Warning \(dev\) at library-ignored.cmake:[0-9]+ \(add_library\):
+ The feature 'feat', specified as part of a generator-expression
+ '\$<LINK_GROUP:feat>', will not be applied to the OBJECT library 'dep'.
+Call Stack \(most recent call first\):
+ CMakeLists.txt:[0-9]+ \(include\)
+This warning is for project developers. Use -Wno-dev to suppress it.
diff --git a/Tests/RunCMake/GenEx-LINK_GROUP/library-ignored.cmake b/Tests/RunCMake/GenEx-LINK_GROUP/library-ignored.cmake
new file mode 100644
index 0000000..b3f19a7
--- /dev/null
+++ b/Tests/RunCMake/GenEx-LINK_GROUP/library-ignored.cmake
@@ -0,0 +1,15 @@
+enable_language(C)
+
+set(CMAKE_C_LINK_GROUP_USING_feat_SUPPORTED TRUE)
+set(CMAKE_C_LINK_GROUP_USING_feat "--start" "--end")
+
+add_library(dep OBJECT empty.c)
+
+add_library(lib SHARED empty.c)
+
+add_library(front INTERFACE)
+target_link_libraries(front INTERFACE lib)
+
+
+add_library(lib2 SHARED empty.c)
+target_link_libraries(lib2 PRIVATE "$<LINK_GROUP:feat,front,dep>")
diff --git a/Tests/RunCMake/GenEx-LINK_GROUP/link_directories-result.txt b/Tests/RunCMake/GenEx-LINK_GROUP/link_directories-result.txt
new file mode 100644
index 0000000..d00491f
--- /dev/null
+++ b/Tests/RunCMake/GenEx-LINK_GROUP/link_directories-result.txt
@@ -0,0 +1 @@
+1
diff --git a/Tests/RunCMake/GenEx-LINK_GROUP/link_directories-stderr.txt b/Tests/RunCMake/GenEx-LINK_GROUP/link_directories-stderr.txt
new file mode 100644
index 0000000..51194a4
--- /dev/null
+++ b/Tests/RunCMake/GenEx-LINK_GROUP/link_directories-stderr.txt
@@ -0,0 +1,9 @@
+CMake Error at link_directories.cmake:[0-9]+ \(link_directories\):
+ Error evaluating generator expression:
+
+ \$<LINK_GROUP:feat>
+
+ \$<LINK_GROUP:...> may only be used with binary targets to specify group of
+ link libraries.
+Call Stack \(most recent call first\):
+ CMakeLists.txt:[0-9]+ \(include\)
diff --git a/Tests/RunCMake/GenEx-LINK_GROUP/link_directories.cmake b/Tests/RunCMake/GenEx-LINK_GROUP/link_directories.cmake
new file mode 100644
index 0000000..e356e91
--- /dev/null
+++ b/Tests/RunCMake/GenEx-LINK_GROUP/link_directories.cmake
@@ -0,0 +1,5 @@
+enable_language(C)
+
+link_directories("$<LINK_GROUP:feat>")
+
+add_library(empty SHARED empty.c)
diff --git a/Tests/RunCMake/GenEx-LINK_GROUP/nested-incompatible-features1-result.txt b/Tests/RunCMake/GenEx-LINK_GROUP/nested-incompatible-features1-result.txt
new file mode 100644
index 0000000..d00491f
--- /dev/null
+++ b/Tests/RunCMake/GenEx-LINK_GROUP/nested-incompatible-features1-result.txt
@@ -0,0 +1 @@
+1
diff --git a/Tests/RunCMake/GenEx-LINK_GROUP/nested-incompatible-features1-stderr.txt b/Tests/RunCMake/GenEx-LINK_GROUP/nested-incompatible-features1-stderr.txt
new file mode 100644
index 0000000..78631ab
--- /dev/null
+++ b/Tests/RunCMake/GenEx-LINK_GROUP/nested-incompatible-features1-stderr.txt
@@ -0,0 +1,8 @@
+CMake Error at nested-incompatible-features1.cmake:[0-9]+ \(target_link_libraries\):
+ Error evaluating generator expression:
+
+ \$<LINK_GROUP:feat,dep1,\$<LINK_GROUP:feat,dep2>>
+
+ \$<LINK_GROUP:...> cannot be nested.
+Call Stack \(most recent call first\):
+ CMakeLists.txt:3 \(include\)
diff --git a/Tests/RunCMake/GenEx-LINK_GROUP/nested-incompatible-features1.cmake b/Tests/RunCMake/GenEx-LINK_GROUP/nested-incompatible-features1.cmake
new file mode 100644
index 0000000..50e0c64
--- /dev/null
+++ b/Tests/RunCMake/GenEx-LINK_GROUP/nested-incompatible-features1.cmake
@@ -0,0 +1,11 @@
+enable_language(C)
+
+set(CMAKE_C_LINK_GROUP_USING_feat_SUPPORTED TRUE)
+set(CMAKE_C_LINK_GROUP_USING_feat "--start" "--end")
+
+add_library(dep1 SHARED empty.c)
+
+add_library(dep2 SHARED empty.c)
+
+add_library(lib SHARED empty.c)
+target_link_libraries(lib PRIVATE "$<LINK_GROUP:feat,dep1,$<LINK_GROUP:feat,dep2>>")
diff --git a/Tests/RunCMake/GenEx-LINK_GROUP/nested-incompatible-features2-result.txt b/Tests/RunCMake/GenEx-LINK_GROUP/nested-incompatible-features2-result.txt
new file mode 100644
index 0000000..d00491f
--- /dev/null
+++ b/Tests/RunCMake/GenEx-LINK_GROUP/nested-incompatible-features2-result.txt
@@ -0,0 +1 @@
+1
diff --git a/Tests/RunCMake/GenEx-LINK_GROUP/nested-incompatible-features2-stderr.txt b/Tests/RunCMake/GenEx-LINK_GROUP/nested-incompatible-features2-stderr.txt
new file mode 100644
index 0000000..1a27c37
--- /dev/null
+++ b/Tests/RunCMake/GenEx-LINK_GROUP/nested-incompatible-features2-stderr.txt
@@ -0,0 +1,8 @@
+CMake Error at nested-incompatible-features2.cmake:[0-9]+ \(target_link_libraries\):
+ Error evaluating generator expression:
+
+ \$<LINK_GROUP:feat1,dep1,\$<LINK_GROUP:feat2,dep2>>
+
+ \$<LINK_GROUP:...> cannot be nested.
+Call Stack \(most recent call first\):
+ CMakeLists.txt:[0-9]+ \(include\)
diff --git a/Tests/RunCMake/GenEx-LINK_GROUP/nested-incompatible-features2.cmake b/Tests/RunCMake/GenEx-LINK_GROUP/nested-incompatible-features2.cmake
new file mode 100644
index 0000000..c6ea14c
--- /dev/null
+++ b/Tests/RunCMake/GenEx-LINK_GROUP/nested-incompatible-features2.cmake
@@ -0,0 +1,14 @@
+enable_language(C)
+
+set(CMAKE_C_LINK_GROUP_USING_feat1_SUPPORTED TRUE)
+set(CMAKE_C_LINK_GROUP_USING_feat1 "--start" "--end")
+
+set(CMAKE_C_LINK_GROUP_USING_feat2_SUPPORTED TRUE)
+set(CMAKE_C_LINK_GROUP_USING_feat2 "--start" "--end")
+
+add_library(dep1 SHARED empty.c)
+
+add_library(dep2 SHARED empty.c)
+
+add_library(lib SHARED empty.c)
+target_link_libraries(lib PRIVATE "$<LINK_GROUP:feat1,dep1,$<LINK_GROUP:feat2,dep2>>")
diff --git a/Tests/RunCMake/GenEx-LINK_GROUP/nested-incompatible-genex-result.txt b/Tests/RunCMake/GenEx-LINK_GROUP/nested-incompatible-genex-result.txt
new file mode 100644
index 0000000..d00491f
--- /dev/null
+++ b/Tests/RunCMake/GenEx-LINK_GROUP/nested-incompatible-genex-result.txt
@@ -0,0 +1 @@
+1
diff --git a/Tests/RunCMake/GenEx-LINK_GROUP/nested-incompatible-genex-stderr.txt b/Tests/RunCMake/GenEx-LINK_GROUP/nested-incompatible-genex-stderr.txt
new file mode 100644
index 0000000..87eeb4d
--- /dev/null
+++ b/Tests/RunCMake/GenEx-LINK_GROUP/nested-incompatible-genex-stderr.txt
@@ -0,0 +1,18 @@
+CMake Error at nested-incompatible-genex.cmake:[0-9]+ \(add_library\):
+ Error evaluating generator expression:
+
+ \$<LINK_LIBRARY:feat,\$<LINK_GROUP:feat,foo>>
+
+ \$<LINK_GROUP:...> cannot be nested inside a \$<LINK_LIBRARY:...> expression.
+Call Stack \(most recent call first\):
+ CMakeLists.txt:[0-9]+ \(include\)
+
+
+CMake Error at nested-incompatible-genex.cmake:[0-9]+ \(target_link_libraries\):
+ Error evaluating generator expression:
+
+ \$<LINK_LIBRARY:feat,\$<LINK_GROUP:feat,foo>>
+
+ \$<LINK_GROUP:...> cannot be nested inside a \$<LINK_LIBRARY:...> expression.
+Call Stack \(most recent call first\):
+ CMakeLists.txt:[0-9]+ \(include\)
diff --git a/Tests/RunCMake/GenEx-LINK_GROUP/nested-incompatible-genex.cmake b/Tests/RunCMake/GenEx-LINK_GROUP/nested-incompatible-genex.cmake
new file mode 100644
index 0000000..e3f2ade
--- /dev/null
+++ b/Tests/RunCMake/GenEx-LINK_GROUP/nested-incompatible-genex.cmake
@@ -0,0 +1,6 @@
+enable_language(C)
+
+link_libraries("$<LINK_LIBRARY:feat,$<LINK_GROUP:feat,foo>>")
+
+add_library(lib SHARED empty.c)
+target_link_libraries(lib PRIVATE "$<LINK_LIBRARY:feat,$<LINK_GROUP:feat,foo>>")
diff --git a/Tests/RunCMake/GenEx-LINK_GROUP/no-arguments-result.txt b/Tests/RunCMake/GenEx-LINK_GROUP/no-arguments-result.txt
new file mode 100644
index 0000000..d00491f
--- /dev/null
+++ b/Tests/RunCMake/GenEx-LINK_GROUP/no-arguments-result.txt
@@ -0,0 +1 @@
+1
diff --git a/Tests/RunCMake/GenEx-LINK_GROUP/no-arguments-stderr.txt b/Tests/RunCMake/GenEx-LINK_GROUP/no-arguments-stderr.txt
new file mode 100644
index 0000000..63c2648
--- /dev/null
+++ b/Tests/RunCMake/GenEx-LINK_GROUP/no-arguments-stderr.txt
@@ -0,0 +1,8 @@
+CMake Error at no-arguments.cmake:[0-9]+ \(target_link_libraries\):
+ Error evaluating generator expression:
+
+ \$<LINK_GROUP>
+
+ \$<LINK_GROUP> expression requires at least one parameter.
+Call Stack \(most recent call first\):
+ CMakeLists.txt:[0-9]+ \(include\)
diff --git a/Tests/RunCMake/GenEx-LINK_GROUP/no-arguments.cmake b/Tests/RunCMake/GenEx-LINK_GROUP/no-arguments.cmake
new file mode 100644
index 0000000..ffc1381
--- /dev/null
+++ b/Tests/RunCMake/GenEx-LINK_GROUP/no-arguments.cmake
@@ -0,0 +1,4 @@
+enable_language(C)
+
+add_library(lib SHARED empty.c)
+target_link_libraries(lib PRIVATE "$<LINK_GROUP>")
diff --git a/Tests/RunCMake/GenEx-LINK_GROUP/only-targets-result.txt b/Tests/RunCMake/GenEx-LINK_GROUP/only-targets-result.txt
new file mode 100644
index 0000000..d00491f
--- /dev/null
+++ b/Tests/RunCMake/GenEx-LINK_GROUP/only-targets-result.txt
@@ -0,0 +1 @@
+1
diff --git a/Tests/RunCMake/GenEx-LINK_GROUP/only-targets-stderr.txt b/Tests/RunCMake/GenEx-LINK_GROUP/only-targets-stderr.txt
new file mode 100644
index 0000000..6b770f0
--- /dev/null
+++ b/Tests/RunCMake/GenEx-LINK_GROUP/only-targets-stderr.txt
@@ -0,0 +1,13 @@
+CMake Error at only-targets.cmake:[0-9]+ \(target_link_libraries\):
+ Target "lib2" has LINK_LIBRARIES_ONLY_TARGETS enabled, but it links to:
+
+ external
+
+ which is not a target. Possible reasons include:
+
+ \* There is a typo in the target name.
+ \* A find_package call is missing for an IMPORTED target.
+ \* An ALIAS target is missing.
+
+Call Stack \(most recent call first\):
+ CMakeLists.txt:[0-9]+ \(include\)
diff --git a/Tests/RunCMake/GenEx-LINK_GROUP/only-targets.cmake b/Tests/RunCMake/GenEx-LINK_GROUP/only-targets.cmake
new file mode 100644
index 0000000..8501f1d
--- /dev/null
+++ b/Tests/RunCMake/GenEx-LINK_GROUP/only-targets.cmake
@@ -0,0 +1,16 @@
+enable_language(C)
+
+set(CMAKE_C_LINK_GROUP_USING_feat_SUPPORTED TRUE)
+set(CMAKE_C_LINK_GROUP_USING_feat "--start" "--end")
+
+set(CMAKE_LINK_LIBRARIES_ONLY_TARGETS 1)
+
+add_library(dep1 SHARED empty.c)
+
+add_library(lib1 SHARED empty.c)
+# accepted
+target_link_libraries(lib1 PRIVATE "$<LINK_GROUP:feat,dep1>")
+
+add_library(lib2 SHARED empty.c)
+# invalid
+target_link_libraries(lib2 PRIVATE "$<LINK_GROUP:feat,external>")
diff --git a/Tests/RunCMake/GenEx-LINK_GROUP/override-library-features1.cmake b/Tests/RunCMake/GenEx-LINK_GROUP/override-library-features1.cmake
new file mode 100644
index 0000000..127e73f
--- /dev/null
+++ b/Tests/RunCMake/GenEx-LINK_GROUP/override-library-features1.cmake
@@ -0,0 +1,4 @@
+
+include(incompatible-library-features1.cmake)
+
+set_property(TARGET lib1 PROPERTY LINK_LIBRARY_OVERRIDE "feat1,dep1")
diff --git a/Tests/RunCMake/GenEx-LINK_GROUP/override-library-features2.cmake b/Tests/RunCMake/GenEx-LINK_GROUP/override-library-features2.cmake
new file mode 100644
index 0000000..9ad0bfe
--- /dev/null
+++ b/Tests/RunCMake/GenEx-LINK_GROUP/override-library-features2.cmake
@@ -0,0 +1,4 @@
+
+include(incompatible-library-features2.cmake)
+
+set_property(TARGET lib1 PROPERTY LINK_LIBRARY_OVERRIDE_dep1 "feat1")
diff --git a/Tests/RunCMake/GenEx-LINK_GROUP/target_link_directories-result.txt b/Tests/RunCMake/GenEx-LINK_GROUP/target_link_directories-result.txt
new file mode 100644
index 0000000..d00491f
--- /dev/null
+++ b/Tests/RunCMake/GenEx-LINK_GROUP/target_link_directories-result.txt
@@ -0,0 +1 @@
+1
diff --git a/Tests/RunCMake/GenEx-LINK_GROUP/target_link_directories-stderr.txt b/Tests/RunCMake/GenEx-LINK_GROUP/target_link_directories-stderr.txt
new file mode 100644
index 0000000..042dd0b
--- /dev/null
+++ b/Tests/RunCMake/GenEx-LINK_GROUP/target_link_directories-stderr.txt
@@ -0,0 +1,9 @@
+CMake Error at target_link_directories.cmake:[0-9]+ \(target_link_directories\):
+ Error evaluating generator expression:
+
+ \$<LINK_GROUP:feat>
+
+ \$<LINK_GROUP:...> may only be used with binary targets to specify group of
+ link libraries.
+Call Stack \(most recent call first\):
+ CMakeLists.txt:[0-9]+ \(include\)
diff --git a/Tests/RunCMake/GenEx-LINK_GROUP/target_link_directories.cmake b/Tests/RunCMake/GenEx-LINK_GROUP/target_link_directories.cmake
new file mode 100644
index 0000000..47a5f9c
--- /dev/null
+++ b/Tests/RunCMake/GenEx-LINK_GROUP/target_link_directories.cmake
@@ -0,0 +1,4 @@
+enable_language(C)
+
+add_library(empty SHARED empty.c)
+target_link_directories(empty PRIVATE "$<LINK_GROUP:feat>")
diff --git a/Tests/RunCMake/GenEx-LINK_GROUP/target_link_options-result.txt b/Tests/RunCMake/GenEx-LINK_GROUP/target_link_options-result.txt
new file mode 100644
index 0000000..d00491f
--- /dev/null
+++ b/Tests/RunCMake/GenEx-LINK_GROUP/target_link_options-result.txt
@@ -0,0 +1 @@
+1
diff --git a/Tests/RunCMake/GenEx-LINK_GROUP/target_link_options-stderr.txt b/Tests/RunCMake/GenEx-LINK_GROUP/target_link_options-stderr.txt
new file mode 100644
index 0000000..7030b9c
--- /dev/null
+++ b/Tests/RunCMake/GenEx-LINK_GROUP/target_link_options-stderr.txt
@@ -0,0 +1,9 @@
+CMake Error at target_link_options.cmake:[0-9]+ \(target_link_options\):
+ Error evaluating generator expression:
+
+ \$<LINK_GROUP:FEAT>
+
+ \$<LINK_GROUP:...> may only be used with binary targets to specify group of
+ link libraries.
+Call Stack \(most recent call first\):
+ CMakeLists.txt:[0-9]+ \(include\)
diff --git a/Tests/RunCMake/GenEx-LINK_GROUP/target_link_options.cmake b/Tests/RunCMake/GenEx-LINK_GROUP/target_link_options.cmake
new file mode 100644
index 0000000..d7dd876
--- /dev/null
+++ b/Tests/RunCMake/GenEx-LINK_GROUP/target_link_options.cmake
@@ -0,0 +1,4 @@
+enable_language(C)
+
+add_library(empty SHARED empty.c)
+target_link_options(empty PRIVATE $<LINK_GROUP:FEAT>)
diff --git a/Tests/RunCMake/GenEx-LINK_LIBRARY/CMakeLists.txt b/Tests/RunCMake/GenEx-LINK_LIBRARY/CMakeLists.txt
new file mode 100644
index 0000000..612169c
--- /dev/null
+++ b/Tests/RunCMake/GenEx-LINK_LIBRARY/CMakeLists.txt
@@ -0,0 +1,3 @@
+cmake_minimum_required(VERSION 3.18...3.22)
+project(${RunCMake_TEST} NONE)
+include(${RunCMake_TEST}.cmake)
diff --git a/Tests/RunCMake/GenEx-LINK_LIBRARY/RunCMakeTest.cmake b/Tests/RunCMake/GenEx-LINK_LIBRARY/RunCMakeTest.cmake
new file mode 100644
index 0000000..9c266fe
--- /dev/null
+++ b/Tests/RunCMake/GenEx-LINK_LIBRARY/RunCMakeTest.cmake
@@ -0,0 +1,35 @@
+include(RunCMake)
+
+run_cmake(add_custom_target)
+run_cmake(add_custom_command)
+run_cmake(add_link_options)
+run_cmake(link_directories)
+run_cmake(target_link_options)
+run_cmake(target_link_directories)
+run_cmake(no-arguments)
+run_cmake(empty-arguments)
+run_cmake(forbidden-arguments)
+run_cmake(invalid-feature)
+run_cmake(bad-feature1)
+run_cmake(bad-feature2)
+run_cmake(bad-feature3)
+run_cmake(bad-feature4)
+run_cmake(bad-feature5)
+run_cmake(bad-feature6)
+run_cmake(bad-feature7)
+run_cmake(feature-not-supported)
+run_cmake(library-ignored)
+run_cmake(compatible-features)
+run_cmake(incompatible-features1)
+run_cmake(incompatible-features2)
+run_cmake(incompatible-features3)
+run_cmake(nested-compatible-features)
+run_cmake(nested-incompatible-features)
+run_cmake(only-targets)
+
+# testing target propertes LINK_LIBRARY_OVERRIDE and LINK_LIBRARY_OVERRIDE_<LIBRARY>
+run_cmake(override-features1)
+run_cmake(override-features2)
+run_cmake(override-features3)
+run_cmake(override-features4)
+run_cmake(override-features5)
diff --git a/Tests/RunCMake/GenEx-LINK_LIBRARY/add_custom_command-result.txt b/Tests/RunCMake/GenEx-LINK_LIBRARY/add_custom_command-result.txt
new file mode 100644
index 0000000..d00491f
--- /dev/null
+++ b/Tests/RunCMake/GenEx-LINK_LIBRARY/add_custom_command-result.txt
@@ -0,0 +1 @@
+1
diff --git a/Tests/RunCMake/GenEx-LINK_LIBRARY/add_custom_command-stderr.txt b/Tests/RunCMake/GenEx-LINK_LIBRARY/add_custom_command-stderr.txt
new file mode 100644
index 0000000..d8ff0eb
--- /dev/null
+++ b/Tests/RunCMake/GenEx-LINK_LIBRARY/add_custom_command-stderr.txt
@@ -0,0 +1,9 @@
+CMake Error at add_custom_command.cmake:[0-9]+ \(add_custom_command\):
+ Error evaluating generator expression:
+
+ \$<LINK_LIBRARY:feat>
+
+ \$<LINK_LIBRARY:...> may only be used with binary targets to specify link
+ libraries.
+Call Stack \(most recent call first\):
+ CMakeLists.txt:[0-9]+ \(include\)
diff --git a/Tests/RunCMake/GenEx-LINK_LIBRARY/add_custom_command.cmake b/Tests/RunCMake/GenEx-LINK_LIBRARY/add_custom_command.cmake
new file mode 100644
index 0000000..3583a67
--- /dev/null
+++ b/Tests/RunCMake/GenEx-LINK_LIBRARY/add_custom_command.cmake
@@ -0,0 +1,4 @@
+add_custom_target(drive)
+add_custom_command(TARGET drive PRE_BUILD
+ COMMAND ${CMAKE_COMMAND} -E echo "$<LINK_LIBRARY:feat>"
+)
diff --git a/Tests/RunCMake/GenEx-LINK_LIBRARY/add_custom_target-result.txt b/Tests/RunCMake/GenEx-LINK_LIBRARY/add_custom_target-result.txt
new file mode 100644
index 0000000..d00491f
--- /dev/null
+++ b/Tests/RunCMake/GenEx-LINK_LIBRARY/add_custom_target-result.txt
@@ -0,0 +1 @@
+1
diff --git a/Tests/RunCMake/GenEx-LINK_LIBRARY/add_custom_target-stderr.txt b/Tests/RunCMake/GenEx-LINK_LIBRARY/add_custom_target-stderr.txt
new file mode 100644
index 0000000..8ca384d
--- /dev/null
+++ b/Tests/RunCMake/GenEx-LINK_LIBRARY/add_custom_target-stderr.txt
@@ -0,0 +1,9 @@
+CMake Error at add_custom_target.cmake:[0-9]+ \(add_custom_target\):
+ Error evaluating generator expression:
+
+ \$<LINK_LIBRARY:feat>
+
+ \$<LINK_LIBRARY:...> may only be used with binary targets to specify link
+ libraries.
+Call Stack \(most recent call first\):
+ CMakeLists.txt:[0-9]+ \(include\)
diff --git a/Tests/RunCMake/GenEx-LINK_LIBRARY/add_custom_target.cmake b/Tests/RunCMake/GenEx-LINK_LIBRARY/add_custom_target.cmake
new file mode 100644
index 0000000..ef00965
--- /dev/null
+++ b/Tests/RunCMake/GenEx-LINK_LIBRARY/add_custom_target.cmake
@@ -0,0 +1,3 @@
+add_custom_target(drive
+ COMMAND ${CMAKE_COMMAND} -E echo "$<LINK_LIBRARY:feat>"
+)
diff --git a/Tests/RunCMake/GenEx-LINK_LIBRARY/add_link_options-result.txt b/Tests/RunCMake/GenEx-LINK_LIBRARY/add_link_options-result.txt
new file mode 100644
index 0000000..d00491f
--- /dev/null
+++ b/Tests/RunCMake/GenEx-LINK_LIBRARY/add_link_options-result.txt
@@ -0,0 +1 @@
+1
diff --git a/Tests/RunCMake/GenEx-LINK_LIBRARY/add_link_options-stderr.txt b/Tests/RunCMake/GenEx-LINK_LIBRARY/add_link_options-stderr.txt
new file mode 100644
index 0000000..399a413
--- /dev/null
+++ b/Tests/RunCMake/GenEx-LINK_LIBRARY/add_link_options-stderr.txt
@@ -0,0 +1,9 @@
+CMake Error at add_link_options.cmake:[0-9]+ \(add_link_options\):
+ Error evaluating generator expression:
+
+ \$<LINK_LIBRARY:feat>
+
+ \$<LINK_LIBRARY:...> may only be used with binary targets to specify link
+ libraries.
+Call Stack \(most recent call first\):
+ CMakeLists.txt:[0-9]+ \(include\)
diff --git a/Tests/RunCMake/GenEx-LINK_LIBRARY/add_link_options.cmake b/Tests/RunCMake/GenEx-LINK_LIBRARY/add_link_options.cmake
new file mode 100644
index 0000000..fdccf95
--- /dev/null
+++ b/Tests/RunCMake/GenEx-LINK_LIBRARY/add_link_options.cmake
@@ -0,0 +1,5 @@
+enable_language(C)
+
+add_link_options("$<LINK_LIBRARY:feat>")
+
+add_library(empty SHARED empty.c)
diff --git a/Tests/RunCMake/GenEx-LINK_LIBRARY/bad-feature1-result.txt b/Tests/RunCMake/GenEx-LINK_LIBRARY/bad-feature1-result.txt
new file mode 100644
index 0000000..d00491f
--- /dev/null
+++ b/Tests/RunCMake/GenEx-LINK_LIBRARY/bad-feature1-result.txt
@@ -0,0 +1 @@
+1
diff --git a/Tests/RunCMake/GenEx-LINK_LIBRARY/bad-feature1-stderr.txt b/Tests/RunCMake/GenEx-LINK_LIBRARY/bad-feature1-stderr.txt
new file mode 100644
index 0000000..0ff8aca
--- /dev/null
+++ b/Tests/RunCMake/GenEx-LINK_LIBRARY/bad-feature1-stderr.txt
@@ -0,0 +1,6 @@
+CMake Error at bad-feature1.cmake:[0-9]+ \(add_library\):
+ Feature 'bad_feat', specified through generator-expression
+ '\$<LINK_LIBRARY>' to link target 'lib', is not supported for the 'C' link
+ language.
+Call Stack \(most recent call first\):
+ CMakeLists.txt:[0-9]+ \(include\)
diff --git a/Tests/RunCMake/GenEx-LINK_LIBRARY/bad-feature1.cmake b/Tests/RunCMake/GenEx-LINK_LIBRARY/bad-feature1.cmake
new file mode 100644
index 0000000..5e540cf
--- /dev/null
+++ b/Tests/RunCMake/GenEx-LINK_LIBRARY/bad-feature1.cmake
@@ -0,0 +1,6 @@
+enable_language(C)
+
+add_library(dep SHARED empty.c)
+
+add_library(lib SHARED empty.c)
+target_link_libraries(lib PRIVATE "$<LINK_LIBRARY:bad_feat,dep>")
diff --git a/Tests/RunCMake/GenEx-LINK_LIBRARY/bad-feature2-result.txt b/Tests/RunCMake/GenEx-LINK_LIBRARY/bad-feature2-result.txt
new file mode 100644
index 0000000..d00491f
--- /dev/null
+++ b/Tests/RunCMake/GenEx-LINK_LIBRARY/bad-feature2-result.txt
@@ -0,0 +1 @@
+1
diff --git a/Tests/RunCMake/GenEx-LINK_LIBRARY/bad-feature2-stderr.txt b/Tests/RunCMake/GenEx-LINK_LIBRARY/bad-feature2-stderr.txt
new file mode 100644
index 0000000..9e878cc
--- /dev/null
+++ b/Tests/RunCMake/GenEx-LINK_LIBRARY/bad-feature2-stderr.txt
@@ -0,0 +1,5 @@
+CMake Error at bad-feature2.cmake:[0-9]+ \(add_library\):
+ Feature 'feat', specified through generator-expression '\$<LINK_LIBRARY>' to
+ link target 'lib', is not defined for the 'C' link language.
+Call Stack \(most recent call first\):
+ CMakeLists.txt:[0-9]+ \(include\)
diff --git a/Tests/RunCMake/GenEx-LINK_LIBRARY/bad-feature2.cmake b/Tests/RunCMake/GenEx-LINK_LIBRARY/bad-feature2.cmake
new file mode 100644
index 0000000..2c9efce
--- /dev/null
+++ b/Tests/RunCMake/GenEx-LINK_LIBRARY/bad-feature2.cmake
@@ -0,0 +1,8 @@
+enable_language(C)
+
+set(CMAKE_C_LINK_LIBRARY_USING_feat_SUPPORTED TRUE)
+
+add_library(dep SHARED empty.c)
+
+add_library(lib SHARED empty.c)
+target_link_libraries(lib PRIVATE "$<LINK_LIBRARY:feat,dep>")
diff --git a/Tests/RunCMake/GenEx-LINK_LIBRARY/bad-feature3-result.txt b/Tests/RunCMake/GenEx-LINK_LIBRARY/bad-feature3-result.txt
new file mode 100644
index 0000000..d00491f
--- /dev/null
+++ b/Tests/RunCMake/GenEx-LINK_LIBRARY/bad-feature3-result.txt
@@ -0,0 +1 @@
+1
diff --git a/Tests/RunCMake/GenEx-LINK_LIBRARY/bad-feature3-stderr.txt b/Tests/RunCMake/GenEx-LINK_LIBRARY/bad-feature3-stderr.txt
new file mode 100644
index 0000000..48cf51e
--- /dev/null
+++ b/Tests/RunCMake/GenEx-LINK_LIBRARY/bad-feature3-stderr.txt
@@ -0,0 +1,6 @@
+CMake Error at bad-feature3.cmake:[0-9]+ \(add_library\):
+ Feature 'feat', specified by variable 'CMAKE_C_LINK_LIBRARY_USING_feat', is
+ malformed \("<LIBRARY>", "<LIB_ITEM>", or "<LINK_ITEM>" patterns are
+ missing\) and cannot be used to link target 'lib'.
+Call Stack \(most recent call first\):
+ CMakeLists.txt:[0-9]+ \(include\)
diff --git a/Tests/RunCMake/GenEx-LINK_LIBRARY/bad-feature3.cmake b/Tests/RunCMake/GenEx-LINK_LIBRARY/bad-feature3.cmake
new file mode 100644
index 0000000..dab6a64
--- /dev/null
+++ b/Tests/RunCMake/GenEx-LINK_LIBRARY/bad-feature3.cmake
@@ -0,0 +1,9 @@
+enable_language(C)
+
+set(CMAKE_C_LINK_LIBRARY_USING_feat_SUPPORTED TRUE)
+set(CMAKE_C_LINK_LIBRARY_USING_feat "")
+
+add_library(dep SHARED empty.c)
+
+add_library(lib SHARED empty.c)
+target_link_libraries(lib PRIVATE "$<LINK_LIBRARY:feat,dep>")
diff --git a/Tests/RunCMake/GenEx-LINK_LIBRARY/bad-feature4-result.txt b/Tests/RunCMake/GenEx-LINK_LIBRARY/bad-feature4-result.txt
new file mode 100644
index 0000000..d00491f
--- /dev/null
+++ b/Tests/RunCMake/GenEx-LINK_LIBRARY/bad-feature4-result.txt
@@ -0,0 +1 @@
+1
diff --git a/Tests/RunCMake/GenEx-LINK_LIBRARY/bad-feature4-stderr.txt b/Tests/RunCMake/GenEx-LINK_LIBRARY/bad-feature4-stderr.txt
new file mode 100644
index 0000000..c074dd0
--- /dev/null
+++ b/Tests/RunCMake/GenEx-LINK_LIBRARY/bad-feature4-stderr.txt
@@ -0,0 +1,6 @@
+CMake Error at bad-feature4.cmake:[0-9]+ \(add_library\):
+ Feature 'feat', specified by variable 'CMAKE_C_LINK_LIBRARY_USING_feat', is
+ malformed \("<LIBRARY>", "<LIB_ITEM>", or "<LINK_ITEM>" patterns are
+ missing\) and cannot be used to link target 'lib'.
+Call Stack \(most recent call first\):
+ CMakeLists.txt:[0-9]+ \(include\)
diff --git a/Tests/RunCMake/GenEx-LINK_LIBRARY/bad-feature4.cmake b/Tests/RunCMake/GenEx-LINK_LIBRARY/bad-feature4.cmake
new file mode 100644
index 0000000..6942f7c
--- /dev/null
+++ b/Tests/RunCMake/GenEx-LINK_LIBRARY/bad-feature4.cmake
@@ -0,0 +1,9 @@
+enable_language(C)
+
+set(CMAKE_C_LINK_LIBRARY_USING_feat_SUPPORTED TRUE)
+set(CMAKE_C_LINK_LIBRARY_USING_feat "-opt")
+
+add_library(dep SHARED empty.c)
+
+add_library(lib SHARED empty.c)
+target_link_libraries(lib PRIVATE "$<LINK_LIBRARY:feat,dep>")
diff --git a/Tests/RunCMake/GenEx-LINK_LIBRARY/bad-feature5-result.txt b/Tests/RunCMake/GenEx-LINK_LIBRARY/bad-feature5-result.txt
new file mode 100644
index 0000000..d00491f
--- /dev/null
+++ b/Tests/RunCMake/GenEx-LINK_LIBRARY/bad-feature5-result.txt
@@ -0,0 +1 @@
+1
diff --git a/Tests/RunCMake/GenEx-LINK_LIBRARY/bad-feature5-stderr.txt b/Tests/RunCMake/GenEx-LINK_LIBRARY/bad-feature5-stderr.txt
new file mode 100644
index 0000000..6604307
--- /dev/null
+++ b/Tests/RunCMake/GenEx-LINK_LIBRARY/bad-feature5-stderr.txt
@@ -0,0 +1,6 @@
+CMake Error at bad-feature5.cmake:[0-9]+ \(add_library\):
+ Feature 'feat', specified by variable 'CMAKE_C_LINK_LIBRARY_USING_feat', is
+ malformed \(wrong number of elements\) and cannot be used to link target
+ 'lib'.
+Call Stack \(most recent call first\):
+ CMakeLists.txt:[0-9]+ \(include\)
diff --git a/Tests/RunCMake/GenEx-LINK_LIBRARY/bad-feature5.cmake b/Tests/RunCMake/GenEx-LINK_LIBRARY/bad-feature5.cmake
new file mode 100644
index 0000000..d0a827a
--- /dev/null
+++ b/Tests/RunCMake/GenEx-LINK_LIBRARY/bad-feature5.cmake
@@ -0,0 +1,9 @@
+enable_language(C)
+
+set(CMAKE_C_LINK_LIBRARY_USING_feat_SUPPORTED TRUE)
+set(CMAKE_C_LINK_LIBRARY_USING_feat "-prefix" "<LIBRARY>")
+
+add_library(dep SHARED empty.c)
+
+add_library(lib SHARED empty.c)
+target_link_libraries(lib PRIVATE "$<LINK_LIBRARY:feat,dep>")
diff --git a/Tests/RunCMake/GenEx-LINK_LIBRARY/bad-feature6-result.txt b/Tests/RunCMake/GenEx-LINK_LIBRARY/bad-feature6-result.txt
new file mode 100644
index 0000000..d00491f
--- /dev/null
+++ b/Tests/RunCMake/GenEx-LINK_LIBRARY/bad-feature6-result.txt
@@ -0,0 +1 @@
+1
diff --git a/Tests/RunCMake/GenEx-LINK_LIBRARY/bad-feature6-stderr.txt b/Tests/RunCMake/GenEx-LINK_LIBRARY/bad-feature6-stderr.txt
new file mode 100644
index 0000000..9de4ffa
--- /dev/null
+++ b/Tests/RunCMake/GenEx-LINK_LIBRARY/bad-feature6-stderr.txt
@@ -0,0 +1,6 @@
+CMake Error at bad-feature6.cmake:[0-9]+ \(add_library\):
+ Feature 'feat', specified by variable 'CMAKE_C_LINK_LIBRARY_USING_feat', is
+ malformed \("<LIBRARY>", "<LIB_ITEM>", or "<LINK_ITEM>" patterns are missing
+ for "PATH{}" alternative\) and cannot be used to link target 'lib'.
+Call Stack \(most recent call first\):
+ CMakeLists.txt:[0-9]+ \(include\)
diff --git a/Tests/RunCMake/GenEx-LINK_LIBRARY/bad-feature6.cmake b/Tests/RunCMake/GenEx-LINK_LIBRARY/bad-feature6.cmake
new file mode 100644
index 0000000..04a50f8
--- /dev/null
+++ b/Tests/RunCMake/GenEx-LINK_LIBRARY/bad-feature6.cmake
@@ -0,0 +1,9 @@
+enable_language(C)
+
+set(CMAKE_C_LINK_LIBRARY_USING_feat_SUPPORTED TRUE)
+set(CMAKE_C_LINK_LIBRARY_USING_feat "PATH{}NAME{<LIBRARY>}")
+
+add_library(dep SHARED empty.c)
+
+add_library(lib SHARED empty.c)
+target_link_libraries(lib PRIVATE "$<LINK_LIBRARY:feat,dep>")
diff --git a/Tests/RunCMake/GenEx-LINK_LIBRARY/bad-feature7-result.txt b/Tests/RunCMake/GenEx-LINK_LIBRARY/bad-feature7-result.txt
new file mode 100644
index 0000000..d00491f
--- /dev/null
+++ b/Tests/RunCMake/GenEx-LINK_LIBRARY/bad-feature7-result.txt
@@ -0,0 +1 @@
+1
diff --git a/Tests/RunCMake/GenEx-LINK_LIBRARY/bad-feature7-stderr.txt b/Tests/RunCMake/GenEx-LINK_LIBRARY/bad-feature7-stderr.txt
new file mode 100644
index 0000000..9ea9936
--- /dev/null
+++ b/Tests/RunCMake/GenEx-LINK_LIBRARY/bad-feature7-stderr.txt
@@ -0,0 +1,6 @@
+CMake Error at bad-feature7.cmake:[0-9]+ \(add_library\):
+ Feature 'feat', specified by variable 'CMAKE_C_LINK_LIBRARY_USING_feat', is
+ malformed \("<LIBRARY>", "<LIB_ITEM>", or "<LINK_ITEM>" patterns are missing
+ for "NAME{}" alternative\) and cannot be used to link target 'lib'.
+Call Stack \(most recent call first\):
+ CMakeLists.txt:[0-9]+ \(include\)
diff --git a/Tests/RunCMake/GenEx-LINK_LIBRARY/bad-feature7.cmake b/Tests/RunCMake/GenEx-LINK_LIBRARY/bad-feature7.cmake
new file mode 100644
index 0000000..9659811
--- /dev/null
+++ b/Tests/RunCMake/GenEx-LINK_LIBRARY/bad-feature7.cmake
@@ -0,0 +1,9 @@
+enable_language(C)
+
+set(CMAKE_C_LINK_LIBRARY_USING_feat_SUPPORTED TRUE)
+set(CMAKE_C_LINK_LIBRARY_USING_feat "NAME{}PATH{<LIBRARY>}")
+
+add_library(dep SHARED empty.c)
+
+add_library(lib SHARED empty.c)
+target_link_libraries(lib PRIVATE "$<LINK_LIBRARY:feat,dep>")
diff --git a/Tests/RunCMake/GenEx-LINK_LIBRARY/compatible-features.cmake b/Tests/RunCMake/GenEx-LINK_LIBRARY/compatible-features.cmake
new file mode 100644
index 0000000..fb88e36
--- /dev/null
+++ b/Tests/RunCMake/GenEx-LINK_LIBRARY/compatible-features.cmake
@@ -0,0 +1,21 @@
+enable_language(C)
+
+set(CMAKE_C_LINK_LIBRARY_USING_feat1_SUPPORTED TRUE)
+set(CMAKE_C_LINK_LIBRARY_USING_feat1 "<LIBRARY>")
+
+set(CMAKE_C_LINK_LIBRARY_USING_feat2_SUPPORTED TRUE)
+set(CMAKE_C_LINK_LIBRARY_USING_feat2 "<LIBRARY>")
+
+add_library(dep1 SHARED empty.c)
+
+add_library(dep2 SHARED empty.c)
+target_link_libraries(dep2 PRIVATE "$<LINK_LIBRARY:feat1,dep1>")
+
+add_library(dep3 SHARED empty.c)
+target_link_libraries(dep3 PUBLIC dep2)
+
+add_library(lib1 SHARED empty.c)
+target_link_libraries(lib1 PRIVATE "$<LINK_LIBRARY:feat2,dep1,dep2>")
+
+add_library(lib2 SHARED empty.c)
+target_link_libraries(lib2 PRIVATE "$<LINK_LIBRARY:DEFAULT,dep2,dep3>")
diff --git a/Tests/RunCMake/GenEx-LINK_LIBRARY/empty-arguments-result.txt b/Tests/RunCMake/GenEx-LINK_LIBRARY/empty-arguments-result.txt
new file mode 100644
index 0000000..d00491f
--- /dev/null
+++ b/Tests/RunCMake/GenEx-LINK_LIBRARY/empty-arguments-result.txt
@@ -0,0 +1 @@
+1
diff --git a/Tests/RunCMake/GenEx-LINK_LIBRARY/empty-arguments-stderr.txt b/Tests/RunCMake/GenEx-LINK_LIBRARY/empty-arguments-stderr.txt
new file mode 100644
index 0000000..1530f61
--- /dev/null
+++ b/Tests/RunCMake/GenEx-LINK_LIBRARY/empty-arguments-stderr.txt
@@ -0,0 +1,8 @@
+CMake Error at empty-arguments.cmake:[0-9]+ \(target_link_libraries\):
+ Error evaluating generator expression:
+
+ \$<LINK_LIBRARY:,>
+
+ \$<LINK_LIBRARY:...> expects a feature name as first argument.
+Call Stack \(most recent call first\):
+ CMakeLists.txt:[0-9]+ \(include\)
diff --git a/Tests/RunCMake/GenEx-LINK_LIBRARY/empty-arguments.cmake b/Tests/RunCMake/GenEx-LINK_LIBRARY/empty-arguments.cmake
new file mode 100644
index 0000000..c6e2260
--- /dev/null
+++ b/Tests/RunCMake/GenEx-LINK_LIBRARY/empty-arguments.cmake
@@ -0,0 +1,4 @@
+enable_language(C)
+
+add_library(lib SHARED empty.c)
+target_link_libraries(lib PRIVATE "$<LINK_LIBRARY:,>")
diff --git a/Tests/RunCMake/GenEx-LINK_LIBRARY/empty.c b/Tests/RunCMake/GenEx-LINK_LIBRARY/empty.c
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/Tests/RunCMake/GenEx-LINK_LIBRARY/empty.c
diff --git a/Tests/RunCMake/GenEx-LINK_LIBRARY/feature-not-supported-result.txt b/Tests/RunCMake/GenEx-LINK_LIBRARY/feature-not-supported-result.txt
new file mode 100644
index 0000000..d00491f
--- /dev/null
+++ b/Tests/RunCMake/GenEx-LINK_LIBRARY/feature-not-supported-result.txt
@@ -0,0 +1 @@
+1
diff --git a/Tests/RunCMake/GenEx-LINK_LIBRARY/feature-not-supported-stderr.txt b/Tests/RunCMake/GenEx-LINK_LIBRARY/feature-not-supported-stderr.txt
new file mode 100644
index 0000000..6067bce
--- /dev/null
+++ b/Tests/RunCMake/GenEx-LINK_LIBRARY/feature-not-supported-stderr.txt
@@ -0,0 +1,5 @@
+CMake Error at feature-not-supported.cmake:[0-9]+ \(add_library\):
+ Feature 'feat', specified through generator-expression '\$<LINK_LIBRARY>' to
+ link target 'lib', is not supported for the 'C' link language.
+Call Stack \(most recent call first\):
+ CMakeLists.txt:[0-9]+ \(include\)
diff --git a/Tests/RunCMake/GenEx-LINK_LIBRARY/feature-not-supported.cmake b/Tests/RunCMake/GenEx-LINK_LIBRARY/feature-not-supported.cmake
new file mode 100644
index 0000000..0d952c2
--- /dev/null
+++ b/Tests/RunCMake/GenEx-LINK_LIBRARY/feature-not-supported.cmake
@@ -0,0 +1,9 @@
+enable_language(C)
+
+set(CMAKE_C_LINK_LIBRARY_USING_feat_SUPPORTED FALSE)
+set(CMAKE_C_LINK_LIBRARY_USING_feat "<LIBRARY>")
+
+add_library(dep SHARED empty.c)
+
+add_library(lib SHARED empty.c)
+target_link_libraries(lib PRIVATE "$<LINK_LIBRARY:feat,dep>")
diff --git a/Tests/RunCMake/GenEx-LINK_LIBRARY/forbidden-arguments-result.txt b/Tests/RunCMake/GenEx-LINK_LIBRARY/forbidden-arguments-result.txt
new file mode 100644
index 0000000..d00491f
--- /dev/null
+++ b/Tests/RunCMake/GenEx-LINK_LIBRARY/forbidden-arguments-result.txt
@@ -0,0 +1 @@
+1
diff --git a/Tests/RunCMake/GenEx-LINK_LIBRARY/forbidden-arguments-stderr.txt b/Tests/RunCMake/GenEx-LINK_LIBRARY/forbidden-arguments-stderr.txt
new file mode 100644
index 0000000..5245dd8
--- /dev/null
+++ b/Tests/RunCMake/GenEx-LINK_LIBRARY/forbidden-arguments-stderr.txt
@@ -0,0 +1,16 @@
+CMake Error at forbidden-arguments.cmake:[0-9]+ \(link_libraries\):
+ Property LINK_LIBRARIES contains the invalid item "<LINK_LIBRARY:feat>".
+ The LINK_LIBRARIES property may contain the generator-expression
+ "\$<LINK_LIBRARY:...>" which may be used to specify how the libraries are
+ linked.
+Call Stack \(most recent call first\):
+ CMakeLists.txt:[0-9]+ \(include\)
+
+
+CMake Error at forbidden-arguments.cmake:[0-9]+ \(target_link_libraries\):
+ Property LINK_LIBRARIES contains the invalid item "<LINK_LIBRARY:feat>".
+ The LINK_LIBRARIES property may contain the generator-expression
+ "\$<LINK_LIBRARY:...>" which may be used to specify how the libraries are
+ linked.
+Call Stack \(most recent call first\):
+ CMakeLists.txt:[0-9]+ \(include\)
diff --git a/Tests/RunCMake/GenEx-LINK_LIBRARY/forbidden-arguments.cmake b/Tests/RunCMake/GenEx-LINK_LIBRARY/forbidden-arguments.cmake
new file mode 100644
index 0000000..1c51c44
--- /dev/null
+++ b/Tests/RunCMake/GenEx-LINK_LIBRARY/forbidden-arguments.cmake
@@ -0,0 +1,6 @@
+enable_language(C)
+
+link_libraries(<LINK_LIBRARY:feat> foo </LINK_LIBRARY:feat>)
+
+add_library(lib SHARED empty.c)
+target_link_libraries(lib PRIVATE <LINK_LIBRARY:feat> foo </LINK_LIBRARY:feat>)
diff --git a/Tests/RunCMake/GenEx-LINK_LIBRARY/incompatible-features1-result.txt b/Tests/RunCMake/GenEx-LINK_LIBRARY/incompatible-features1-result.txt
new file mode 100644
index 0000000..d00491f
--- /dev/null
+++ b/Tests/RunCMake/GenEx-LINK_LIBRARY/incompatible-features1-result.txt
@@ -0,0 +1 @@
+1
diff --git a/Tests/RunCMake/GenEx-LINK_LIBRARY/incompatible-features1-stderr.txt b/Tests/RunCMake/GenEx-LINK_LIBRARY/incompatible-features1-stderr.txt
new file mode 100644
index 0000000..1b31faa
--- /dev/null
+++ b/Tests/RunCMake/GenEx-LINK_LIBRARY/incompatible-features1-stderr.txt
@@ -0,0 +1,6 @@
+CMake Error at incompatible-features1.cmake:[0-9]+ \(add_library\):
+ Impossible to link target 'lib' because the link item 'dep1', specified
+ with the feature 'feat1', has already occurred with the feature 'feat2',
+ which is not allowed.
+Call Stack \(most recent call first\):
+ CMakeLists.txt:[0-9]+ \(include\)
diff --git a/Tests/RunCMake/GenEx-LINK_LIBRARY/incompatible-features1.cmake b/Tests/RunCMake/GenEx-LINK_LIBRARY/incompatible-features1.cmake
new file mode 100644
index 0000000..c230c4f
--- /dev/null
+++ b/Tests/RunCMake/GenEx-LINK_LIBRARY/incompatible-features1.cmake
@@ -0,0 +1,15 @@
+enable_language(C)
+
+set(CMAKE_C_LINK_LIBRARY_USING_feat1_SUPPORTED TRUE)
+set(CMAKE_C_LINK_LIBRARY_USING_feat1 "<LIBRARY>")
+
+set(CMAKE_C_LINK_LIBRARY_USING_feat2_SUPPORTED TRUE)
+set(CMAKE_C_LINK_LIBRARY_USING_feat2 "<LIBRARY>")
+
+add_library(dep1 SHARED empty.c)
+
+add_library(dep2 SHARED empty.c)
+target_link_libraries(dep2 PUBLIC "$<LINK_LIBRARY:feat1,dep1>")
+
+add_library(lib SHARED empty.c)
+target_link_libraries(lib PRIVATE "$<LINK_LIBRARY:feat2,dep1,dep2>")
diff --git a/Tests/RunCMake/GenEx-LINK_LIBRARY/incompatible-features2-result.txt b/Tests/RunCMake/GenEx-LINK_LIBRARY/incompatible-features2-result.txt
new file mode 100644
index 0000000..d00491f
--- /dev/null
+++ b/Tests/RunCMake/GenEx-LINK_LIBRARY/incompatible-features2-result.txt
@@ -0,0 +1 @@
+1
diff --git a/Tests/RunCMake/GenEx-LINK_LIBRARY/incompatible-features2-stderr.txt b/Tests/RunCMake/GenEx-LINK_LIBRARY/incompatible-features2-stderr.txt
new file mode 100644
index 0000000..0855481
--- /dev/null
+++ b/Tests/RunCMake/GenEx-LINK_LIBRARY/incompatible-features2-stderr.txt
@@ -0,0 +1,6 @@
+CMake Error at incompatible-features2.cmake:[0-9]+ \(add_library\):
+ Impossible to link target 'lib' because the link item 'dep1', specified
+ without any feature or 'DEFAULT' feature, has already occurred with the
+ feature 'feat2', which is not allowed.
+Call Stack \(most recent call first\):
+ CMakeLists.txt:[0-9]+ \(include\)
diff --git a/Tests/RunCMake/GenEx-LINK_LIBRARY/incompatible-features2.cmake b/Tests/RunCMake/GenEx-LINK_LIBRARY/incompatible-features2.cmake
new file mode 100644
index 0000000..d204ebd
--- /dev/null
+++ b/Tests/RunCMake/GenEx-LINK_LIBRARY/incompatible-features2.cmake
@@ -0,0 +1,15 @@
+enable_language(C)
+
+set(CMAKE_C_LINK_LIBRARY_USING_feat1_SUPPORTED TRUE)
+set(CMAKE_C_LINK_LIBRARY_USING_feat1 "<LIBRARY>")
+
+set(CMAKE_C_LINK_LIBRARY_USING_feat2_SUPPORTED TRUE)
+set(CMAKE_C_LINK_LIBRARY_USING_feat2 "<LIBRARY>")
+
+add_library(dep1 SHARED empty.c)
+
+add_library(dep2 SHARED empty.c)
+target_link_libraries(dep2 PUBLIC dep1)
+
+add_library(lib SHARED empty.c)
+target_link_libraries(lib PRIVATE "$<LINK_LIBRARY:feat2,dep1,dep2>")
diff --git a/Tests/RunCMake/GenEx-LINK_LIBRARY/incompatible-features3-result.txt b/Tests/RunCMake/GenEx-LINK_LIBRARY/incompatible-features3-result.txt
new file mode 100644
index 0000000..d00491f
--- /dev/null
+++ b/Tests/RunCMake/GenEx-LINK_LIBRARY/incompatible-features3-result.txt
@@ -0,0 +1 @@
+1
diff --git a/Tests/RunCMake/GenEx-LINK_LIBRARY/incompatible-features3-stderr.txt b/Tests/RunCMake/GenEx-LINK_LIBRARY/incompatible-features3-stderr.txt
new file mode 100644
index 0000000..2f40a1d
--- /dev/null
+++ b/Tests/RunCMake/GenEx-LINK_LIBRARY/incompatible-features3-stderr.txt
@@ -0,0 +1,6 @@
+CMake Error at incompatible-features3.cmake:[0-9]+ \(add_library\):
+ Impossible to link target 'lib' because the link item 'dep1', specified
+ with the feature 'feat1', has already occurred without any feature or
+ 'DEFAULT' feature, which is not allowed.
+Call Stack \(most recent call first\):
+ CMakeLists.txt:[0-9]+ \(include\)
diff --git a/Tests/RunCMake/GenEx-LINK_LIBRARY/incompatible-features3.cmake b/Tests/RunCMake/GenEx-LINK_LIBRARY/incompatible-features3.cmake
new file mode 100644
index 0000000..bf79e11
--- /dev/null
+++ b/Tests/RunCMake/GenEx-LINK_LIBRARY/incompatible-features3.cmake
@@ -0,0 +1,15 @@
+enable_language(C)
+
+set(CMAKE_C_LINK_LIBRARY_USING_feat1_SUPPORTED TRUE)
+set(CMAKE_C_LINK_LIBRARY_USING_feat1 "<LIBRARY>")
+
+set(CMAKE_C_LINK_LIBRARY_USING_feat2_SUPPORTED TRUE)
+set(CMAKE_C_LINK_LIBRARY_USING_feat2 "<LIBRARY>")
+
+add_library(dep1 SHARED empty.c)
+
+add_library(dep2 SHARED empty.c)
+target_link_libraries(dep2 PUBLIC "$<LINK_LIBRARY:feat1,dep1>")
+
+add_library(lib SHARED empty.c)
+target_link_libraries(lib PRIVATE dep1 dep2)
diff --git a/Tests/RunCMake/GenEx-LINK_LIBRARY/invalid-feature-result.txt b/Tests/RunCMake/GenEx-LINK_LIBRARY/invalid-feature-result.txt
new file mode 100644
index 0000000..d00491f
--- /dev/null
+++ b/Tests/RunCMake/GenEx-LINK_LIBRARY/invalid-feature-result.txt
@@ -0,0 +1 @@
+1
diff --git a/Tests/RunCMake/GenEx-LINK_LIBRARY/invalid-feature-stderr.txt b/Tests/RunCMake/GenEx-LINK_LIBRARY/invalid-feature-stderr.txt
new file mode 100644
index 0000000..fb5cdab
--- /dev/null
+++ b/Tests/RunCMake/GenEx-LINK_LIBRARY/invalid-feature-stderr.txt
@@ -0,0 +1,8 @@
+CMake Error at invalid-feature.cmake:[0-9]+ \(target_link_libraries\):
+ Error evaluating generator expression:
+
+ \$<LINK_LIBRARY:feat:invalid,dep>
+
+ The feature name 'feat:invalid' contains invalid characters.
+Call Stack \(most recent call first\):
+ CMakeLists.txt:[0-9]+ \(include\)
diff --git a/Tests/RunCMake/GenEx-LINK_LIBRARY/invalid-feature.cmake b/Tests/RunCMake/GenEx-LINK_LIBRARY/invalid-feature.cmake
new file mode 100644
index 0000000..c49e4cd
--- /dev/null
+++ b/Tests/RunCMake/GenEx-LINK_LIBRARY/invalid-feature.cmake
@@ -0,0 +1,6 @@
+enable_language(C)
+
+add_library(dep SHARED empty.c)
+
+add_library(lib SHARED empty.c)
+target_link_libraries(lib PRIVATE "$<LINK_LIBRARY:feat:invalid,dep>")
diff --git a/Tests/RunCMake/GenEx-LINK_LIBRARY/library-ignored-stderr.txt b/Tests/RunCMake/GenEx-LINK_LIBRARY/library-ignored-stderr.txt
new file mode 100644
index 0000000..f9a99af
--- /dev/null
+++ b/Tests/RunCMake/GenEx-LINK_LIBRARY/library-ignored-stderr.txt
@@ -0,0 +1,14 @@
+CMake Warning \(dev\) at library-ignored.cmake:[0-9]+ \(add_library\):
+ The feature 'feat', specified as part of a generator-expression
+ '\$<LINK_LIBRARY:feat>', will not be applied to the INTERFACE library
+ 'front'.
+Call Stack \(most recent call first\):
+ CMakeLists.txt:[0-9]+ \(include\)
+This warning is for project developers. Use -Wno-dev to suppress it.
+
+CMake Warning \(dev\) at library-ignored.cmake:[0-9]+ \(add_library\):
+ The feature 'feat', specified as part of a generator-expression
+ '\$<LINK_LIBRARY:feat>', will not be applied to the OBJECT library 'dep'.
+Call Stack \(most recent call first\):
+ CMakeLists.txt:[0-9]+ \(include\)
+This warning is for project developers. Use -Wno-dev to suppress it.
diff --git a/Tests/RunCMake/GenEx-LINK_LIBRARY/library-ignored.cmake b/Tests/RunCMake/GenEx-LINK_LIBRARY/library-ignored.cmake
new file mode 100644
index 0000000..a888bb8
--- /dev/null
+++ b/Tests/RunCMake/GenEx-LINK_LIBRARY/library-ignored.cmake
@@ -0,0 +1,15 @@
+enable_language(C)
+
+set(CMAKE_C_LINK_LIBRARY_USING_feat_SUPPORTED TRUE)
+set(CMAKE_C_LINK_LIBRARY_USING_feat "<LIBRARY>")
+
+add_library(dep OBJECT empty.c)
+
+add_library(lib SHARED empty.c)
+
+add_library(front INTERFACE)
+target_link_libraries(front INTERFACE lib)
+
+
+add_library(lib2 SHARED empty.c)
+target_link_libraries(lib2 PRIVATE "$<LINK_LIBRARY:feat,front,dep>")
diff --git a/Tests/RunCMake/GenEx-LINK_LIBRARY/link_directories-result.txt b/Tests/RunCMake/GenEx-LINK_LIBRARY/link_directories-result.txt
new file mode 100644
index 0000000..d00491f
--- /dev/null
+++ b/Tests/RunCMake/GenEx-LINK_LIBRARY/link_directories-result.txt
@@ -0,0 +1 @@
+1
diff --git a/Tests/RunCMake/GenEx-LINK_LIBRARY/link_directories-stderr.txt b/Tests/RunCMake/GenEx-LINK_LIBRARY/link_directories-stderr.txt
new file mode 100644
index 0000000..aeb32f2
--- /dev/null
+++ b/Tests/RunCMake/GenEx-LINK_LIBRARY/link_directories-stderr.txt
@@ -0,0 +1,9 @@
+CMake Error at link_directories.cmake:[0-9]+ \(link_directories\):
+ Error evaluating generator expression:
+
+ \$<LINK_LIBRARY:feat>
+
+ \$<LINK_LIBRARY:...> may only be used with binary targets to specify link
+ libraries.
+Call Stack \(most recent call first\):
+ CMakeLists.txt:[0-9]+ \(include\)
diff --git a/Tests/RunCMake/GenEx-LINK_LIBRARY/link_directories.cmake b/Tests/RunCMake/GenEx-LINK_LIBRARY/link_directories.cmake
new file mode 100644
index 0000000..b6d9a36
--- /dev/null
+++ b/Tests/RunCMake/GenEx-LINK_LIBRARY/link_directories.cmake
@@ -0,0 +1,5 @@
+enable_language(C)
+
+link_directories("$<LINK_LIBRARY:feat>")
+
+add_library(empty SHARED empty.c)
diff --git a/Tests/RunCMake/GenEx-LINK_LIBRARY/nested-compatible-features.cmake b/Tests/RunCMake/GenEx-LINK_LIBRARY/nested-compatible-features.cmake
new file mode 100644
index 0000000..561aa09
--- /dev/null
+++ b/Tests/RunCMake/GenEx-LINK_LIBRARY/nested-compatible-features.cmake
@@ -0,0 +1,11 @@
+enable_language(C)
+
+set(CMAKE_C_LINK_LIBRARY_USING_feat1_SUPPORTED TRUE)
+set(CMAKE_C_LINK_LIBRARY_USING_feat1 "<LIBRARY>")
+
+add_library(dep1 SHARED empty.c)
+
+add_library(dep2 SHARED empty.c)
+
+add_library(lib SHARED empty.c)
+target_link_libraries(lib PRIVATE "$<LINK_LIBRARY:feat1,dep1,$<LINK_LIBRARY:feat1,dep2>>")
diff --git a/Tests/RunCMake/GenEx-LINK_LIBRARY/nested-incompatible-features-result.txt b/Tests/RunCMake/GenEx-LINK_LIBRARY/nested-incompatible-features-result.txt
new file mode 100644
index 0000000..d00491f
--- /dev/null
+++ b/Tests/RunCMake/GenEx-LINK_LIBRARY/nested-incompatible-features-result.txt
@@ -0,0 +1 @@
+1
diff --git a/Tests/RunCMake/GenEx-LINK_LIBRARY/nested-incompatible-features-stderr.txt b/Tests/RunCMake/GenEx-LINK_LIBRARY/nested-incompatible-features-stderr.txt
new file mode 100644
index 0000000..3f6c504
--- /dev/null
+++ b/Tests/RunCMake/GenEx-LINK_LIBRARY/nested-incompatible-features-stderr.txt
@@ -0,0 +1,8 @@
+CMake Error at nested-incompatible-features.cmake:[0-9]+ \(target_link_libraries\):
+ Error evaluating generator expression:
+
+ \$<LINK_LIBRARY:feat2,dep1,\$<LINK_LIBRARY:feat1,dep2>>
+
+ \$<LINK_LIBRARY:...> with different features cannot be nested.
+Call Stack \(most recent call first\):
+ CMakeLists.txt:[0-9]+ \(include\)
diff --git a/Tests/RunCMake/GenEx-LINK_LIBRARY/nested-incompatible-features.cmake b/Tests/RunCMake/GenEx-LINK_LIBRARY/nested-incompatible-features.cmake
new file mode 100644
index 0000000..746638e
--- /dev/null
+++ b/Tests/RunCMake/GenEx-LINK_LIBRARY/nested-incompatible-features.cmake
@@ -0,0 +1,14 @@
+enable_language(C)
+
+set(CMAKE_C_LINK_LIBRARY_USING_feat1_SUPPORTED TRUE)
+set(CMAKE_C_LINK_LIBRARY_USING_feat1 "<LIBRARY>")
+
+set(CMAKE_C_LINK_LIBRARY_USING_feat2_SUPPORTED TRUE)
+set(CMAKE_C_LINK_LIBRARY_USING_feat2 "<LIBRARY>")
+
+add_library(dep1 SHARED empty.c)
+
+add_library(dep2 SHARED empty.c)
+
+add_library(lib SHARED empty.c)
+target_link_libraries(lib PRIVATE "$<LINK_LIBRARY:feat2,dep1,$<LINK_LIBRARY:feat1,dep2>>")
diff --git a/Tests/RunCMake/GenEx-LINK_LIBRARY/no-arguments-result.txt b/Tests/RunCMake/GenEx-LINK_LIBRARY/no-arguments-result.txt
new file mode 100644
index 0000000..d00491f
--- /dev/null
+++ b/Tests/RunCMake/GenEx-LINK_LIBRARY/no-arguments-result.txt
@@ -0,0 +1 @@
+1
diff --git a/Tests/RunCMake/GenEx-LINK_LIBRARY/no-arguments-stderr.txt b/Tests/RunCMake/GenEx-LINK_LIBRARY/no-arguments-stderr.txt
new file mode 100644
index 0000000..af58fa0
--- /dev/null
+++ b/Tests/RunCMake/GenEx-LINK_LIBRARY/no-arguments-stderr.txt
@@ -0,0 +1,8 @@
+CMake Error at no-arguments.cmake:[0-9]+ \(target_link_libraries\):
+ Error evaluating generator expression:
+
+ \$<LINK_LIBRARY>
+
+ \$<LINK_LIBRARY> expression requires at least one parameter.
+Call Stack \(most recent call first\):
+ CMakeLists.txt:[0-9]+ \(include\)
diff --git a/Tests/RunCMake/GenEx-LINK_LIBRARY/no-arguments.cmake b/Tests/RunCMake/GenEx-LINK_LIBRARY/no-arguments.cmake
new file mode 100644
index 0000000..0645dc7
--- /dev/null
+++ b/Tests/RunCMake/GenEx-LINK_LIBRARY/no-arguments.cmake
@@ -0,0 +1,4 @@
+enable_language(C)
+
+add_library(lib SHARED empty.c)
+target_link_libraries(lib PRIVATE "$<LINK_LIBRARY>")
diff --git a/Tests/RunCMake/GenEx-LINK_LIBRARY/only-targets-result.txt b/Tests/RunCMake/GenEx-LINK_LIBRARY/only-targets-result.txt
new file mode 100644
index 0000000..d00491f
--- /dev/null
+++ b/Tests/RunCMake/GenEx-LINK_LIBRARY/only-targets-result.txt
@@ -0,0 +1 @@
+1
diff --git a/Tests/RunCMake/GenEx-LINK_LIBRARY/only-targets-stderr.txt b/Tests/RunCMake/GenEx-LINK_LIBRARY/only-targets-stderr.txt
new file mode 100644
index 0000000..6b770f0
--- /dev/null
+++ b/Tests/RunCMake/GenEx-LINK_LIBRARY/only-targets-stderr.txt
@@ -0,0 +1,13 @@
+CMake Error at only-targets.cmake:[0-9]+ \(target_link_libraries\):
+ Target "lib2" has LINK_LIBRARIES_ONLY_TARGETS enabled, but it links to:
+
+ external
+
+ which is not a target. Possible reasons include:
+
+ \* There is a typo in the target name.
+ \* A find_package call is missing for an IMPORTED target.
+ \* An ALIAS target is missing.
+
+Call Stack \(most recent call first\):
+ CMakeLists.txt:[0-9]+ \(include\)
diff --git a/Tests/RunCMake/GenEx-LINK_LIBRARY/only-targets.cmake b/Tests/RunCMake/GenEx-LINK_LIBRARY/only-targets.cmake
new file mode 100644
index 0000000..8cec0c3
--- /dev/null
+++ b/Tests/RunCMake/GenEx-LINK_LIBRARY/only-targets.cmake
@@ -0,0 +1,16 @@
+enable_language(C)
+
+set(CMAKE_C_LINK_LIBRARY_USING_feat1_SUPPORTED TRUE)
+set(CMAKE_C_LINK_LIBRARY_USING_feat1 "<LIBRARY>")
+
+set(CMAKE_LINK_LIBRARIES_ONLY_TARGETS 1)
+
+add_library(dep1 SHARED empty.c)
+
+add_library(lib1 SHARED empty.c)
+# accepted
+target_link_libraries(lib1 PRIVATE "$<LINK_LIBRARY:feat1,dep1>")
+
+add_library(lib2 SHARED empty.c)
+# invalid
+target_link_libraries(lib2 PRIVATE "$<LINK_LIBRARY:feat1,external>")
diff --git a/Tests/RunCMake/GenEx-LINK_LIBRARY/override-features1.cmake b/Tests/RunCMake/GenEx-LINK_LIBRARY/override-features1.cmake
new file mode 100644
index 0000000..6306c5d
--- /dev/null
+++ b/Tests/RunCMake/GenEx-LINK_LIBRARY/override-features1.cmake
@@ -0,0 +1,4 @@
+
+include(incompatible-features1.cmake)
+
+set_property(TARGET lib PROPERTY LINK_LIBRARY_OVERRIDE "feat1,dep1")
diff --git a/Tests/RunCMake/GenEx-LINK_LIBRARY/override-features2.cmake b/Tests/RunCMake/GenEx-LINK_LIBRARY/override-features2.cmake
new file mode 100644
index 0000000..aa6ee76
--- /dev/null
+++ b/Tests/RunCMake/GenEx-LINK_LIBRARY/override-features2.cmake
@@ -0,0 +1,4 @@
+
+include(incompatible-features1.cmake)
+
+set_property(TARGET lib PROPERTY LINK_LIBRARY_OVERRIDE "feat2,dep1")
diff --git a/Tests/RunCMake/GenEx-LINK_LIBRARY/override-features3.cmake b/Tests/RunCMake/GenEx-LINK_LIBRARY/override-features3.cmake
new file mode 100644
index 0000000..a1437e6
--- /dev/null
+++ b/Tests/RunCMake/GenEx-LINK_LIBRARY/override-features3.cmake
@@ -0,0 +1,7 @@
+
+include(incompatible-features1.cmake)
+
+set(CMAKE_C_LINK_LIBRARY_USING_feat3_SUPPORTED TRUE)
+set(CMAKE_C_LINK_LIBRARY_USING_feat3 "<LIBRARY>")
+
+set_property(TARGET lib PROPERTY LINK_LIBRARY_OVERRIDE "feat3,dep1")
diff --git a/Tests/RunCMake/GenEx-LINK_LIBRARY/override-features4.cmake b/Tests/RunCMake/GenEx-LINK_LIBRARY/override-features4.cmake
new file mode 100644
index 0000000..f34f745
--- /dev/null
+++ b/Tests/RunCMake/GenEx-LINK_LIBRARY/override-features4.cmake
@@ -0,0 +1,9 @@
+
+include(incompatible-features1.cmake)
+
+
+set(CMAKE_C_LINK_LIBRARY_USING_feat3_SUPPORTED TRUE)
+set(CMAKE_C_LINK_LIBRARY_USING_feat3 "<LIBRARY>")
+
+set_property(TARGET lib PROPERTY LINK_LIBRARY_OVERRIDE "feat3,dep1")
+set_property(TARGET lib PROPERTY LINK_LIBRARY_OVERRIDE_dep1 feat1)
diff --git a/Tests/RunCMake/GenEx-LINK_LIBRARY/override-features5.cmake b/Tests/RunCMake/GenEx-LINK_LIBRARY/override-features5.cmake
new file mode 100644
index 0000000..1406d2a
--- /dev/null
+++ b/Tests/RunCMake/GenEx-LINK_LIBRARY/override-features5.cmake
@@ -0,0 +1,7 @@
+
+include(incompatible-features1.cmake)
+
+
+set_property(TARGET lib PROPERTY LINK_LIBRARY_OVERRIDE "feat1,dep1")
+# next property will be ignored because no feature is specified
+set_property(TARGET lib PROPERTY LINK_LIBRARY_OVERRIDE_dep1)
diff --git a/Tests/RunCMake/GenEx-LINK_LIBRARY/target_link_directories-result.txt b/Tests/RunCMake/GenEx-LINK_LIBRARY/target_link_directories-result.txt
new file mode 100644
index 0000000..d00491f
--- /dev/null
+++ b/Tests/RunCMake/GenEx-LINK_LIBRARY/target_link_directories-result.txt
@@ -0,0 +1 @@
+1
diff --git a/Tests/RunCMake/GenEx-LINK_LIBRARY/target_link_directories-stderr.txt b/Tests/RunCMake/GenEx-LINK_LIBRARY/target_link_directories-stderr.txt
new file mode 100644
index 0000000..e0c60c4
--- /dev/null
+++ b/Tests/RunCMake/GenEx-LINK_LIBRARY/target_link_directories-stderr.txt
@@ -0,0 +1,9 @@
+CMake Error at target_link_directories.cmake:[0-9]+ \(target_link_directories\):
+ Error evaluating generator expression:
+
+ \$<LINK_LIBRARY:feat>
+
+ \$<LINK_LIBRARY:...> may only be used with binary targets to specify link
+ libraries.
+Call Stack \(most recent call first\):
+ CMakeLists.txt:[0-9]+ \(include\)
diff --git a/Tests/RunCMake/GenEx-LINK_LIBRARY/target_link_directories.cmake b/Tests/RunCMake/GenEx-LINK_LIBRARY/target_link_directories.cmake
new file mode 100644
index 0000000..e8cc670
--- /dev/null
+++ b/Tests/RunCMake/GenEx-LINK_LIBRARY/target_link_directories.cmake
@@ -0,0 +1,4 @@
+enable_language(C)
+
+add_library(empty SHARED empty.c)
+target_link_directories(empty PRIVATE "$<LINK_LIBRARY:feat>")
diff --git a/Tests/RunCMake/GenEx-LINK_LIBRARY/target_link_options-result.txt b/Tests/RunCMake/GenEx-LINK_LIBRARY/target_link_options-result.txt
new file mode 100644
index 0000000..d00491f
--- /dev/null
+++ b/Tests/RunCMake/GenEx-LINK_LIBRARY/target_link_options-result.txt
@@ -0,0 +1 @@
+1
diff --git a/Tests/RunCMake/GenEx-LINK_LIBRARY/target_link_options-stderr.txt b/Tests/RunCMake/GenEx-LINK_LIBRARY/target_link_options-stderr.txt
new file mode 100644
index 0000000..6c9aab1
--- /dev/null
+++ b/Tests/RunCMake/GenEx-LINK_LIBRARY/target_link_options-stderr.txt
@@ -0,0 +1,9 @@
+CMake Error at target_link_options.cmake:[0-9]+ \(target_link_options\):
+ Error evaluating generator expression:
+
+ \$<LINK_LIBRARY:FEAT>
+
+ \$<LINK_LIBRARY:...> may only be used with binary targets to specify link
+ libraries.
+Call Stack \(most recent call first\):
+ CMakeLists.txt:[0-9]+ \(include\)
diff --git a/Tests/RunCMake/GenEx-LINK_LIBRARY/target_link_options.cmake b/Tests/RunCMake/GenEx-LINK_LIBRARY/target_link_options.cmake
new file mode 100644
index 0000000..a989a53
--- /dev/null
+++ b/Tests/RunCMake/GenEx-LINK_LIBRARY/target_link_options.cmake
@@ -0,0 +1,4 @@
+enable_language(C)
+
+add_library(empty SHARED empty.c)
+target_link_options(empty PRIVATE "$<LINK_LIBRARY:FEAT>")
diff --git a/Tests/RunCMake/RunCMake.cmake b/Tests/RunCMake/RunCMake.cmake
index 9f692ee..1f43ee0 100644
--- a/Tests/RunCMake/RunCMake.cmake
+++ b/Tests/RunCMake/RunCMake.cmake
@@ -153,6 +153,7 @@
"|BullseyeCoverage"
"|[a-z]+\\([0-9]+\\) malloc:"
"|clang[^:]*: warning: the object size sanitizer has no effect at -O0, but is explicitly enabled:"
+ "|lld-link: warning: procedure symbol record for .* refers to PDB item index [0-9A-Fa-fx]+ which is not a valid function ID record"
"|Error kstat returned"
"|Hit xcodebuild bug"
"|Recompacting log\\.\\.\\."
@@ -164,6 +165,7 @@
"|[^\n]*install_name_tool: warning: changes being made to the file will invalidate the code signature in:"
"|[^\n]*xcodebuild[^\n]*DVTPlugInManager"
+ "|[^\n]*xcodebuild[^\n]*Requested but did not find extension point with identifier"
"|[^\n]*xcodebuild[^\n]*warning: file type[^\n]*is based on missing file type"
"|[^\n]*objc[^\n]*: Class AMSupportURL[^\n]* One of the two will be used. Which one is undefined."
"|[^\n]*is a member of multiple groups"
diff --git a/Tests/RunCMake/SymlinkTrees/CMakeLists.txt b/Tests/RunCMake/SymlinkTrees/CMakeLists.txt
index d6fea2c..e16faea 100644
--- a/Tests/RunCMake/SymlinkTrees/CMakeLists.txt
+++ b/Tests/RunCMake/SymlinkTrees/CMakeLists.txt
@@ -1,3 +1,52 @@
cmake_minimum_required(VERSION 2.8.12)
project(${RunCMake_TEST} NONE)
-include("${include_dir}/${RunCMake_TEST}.cmake")
+
+message(STATUS "source: '${CMAKE_SOURCE_DIR}'")
+message(STATUS "binary: '${CMAKE_BINARY_DIR}'")
+get_filename_component(real_source "${CMAKE_SOURCE_DIR}" REALPATH)
+get_filename_component(real_binary "${CMAKE_BINARY_DIR}" REALPATH)
+message(STATUS "real source: '${real_source}'")
+message(STATUS "real binary: '${real_binary}'")
+
+if(RunCMake_TEST MATCHES "-exe")
+ enable_language(C)
+ file(WRITE "${CMAKE_SOURCE_DIR}/source.c" [[
+ #include <stdio.h>
+ #include "source.h"
+ #include "binary.h"
+ extern void print_binary_c(void);
+ extern void print_binary_c(void);
+ void print_source_c(void) {
+ printf("source.c: '%s'\n", __FILE__);
+ }
+ int main(void) {
+ print_source_c();
+ print_source_h();
+ print_binary_c();
+ print_binary_h();
+ return 0;
+ }
+ ]])
+ file(WRITE "${CMAKE_BINARY_DIR}/binary.c" [[
+ #include <stdio.h>
+ void print_binary_c(void) {
+ printf("binary.c: '%s'\n", __FILE__);
+ }
+ ]])
+ file(WRITE "${CMAKE_SOURCE_DIR}/include/source.h" [[
+ void print_source_h(void) {
+ printf("source.h: '%s'\n", __FILE__);
+ }
+ ]])
+ file(WRITE "${CMAKE_BINARY_DIR}/include/binary.h" [[
+ void print_binary_h(void) {
+ printf("binary.h: '%s'\n", __FILE__);
+ }
+ ]])
+ add_executable(exe source.c ${CMAKE_BINARY_DIR}/binary.c)
+ target_include_directories(exe PRIVATE
+ ${CMAKE_SOURCE_DIR}/include
+ ${CMAKE_BINARY_DIR}/include
+ )
+ add_custom_target(print ALL COMMAND exe)
+endif()
diff --git a/Tests/RunCMake/SymlinkTrees/PrintTrees.cmake b/Tests/RunCMake/SymlinkTrees/PrintTrees.cmake
deleted file mode 100644
index aa99127..0000000
--- a/Tests/RunCMake/SymlinkTrees/PrintTrees.cmake
+++ /dev/null
@@ -1,6 +0,0 @@
-message(STATUS "source: '${CMAKE_SOURCE_DIR}'")
-message(STATUS "binary: '${CMAKE_BINARY_DIR}'")
-get_filename_component(real_source "${CMAKE_SOURCE_DIR}" REALPATH)
-get_filename_component(real_binary "${CMAKE_BINARY_DIR}" REALPATH)
-message(STATUS "real source: '${real_source}'")
-message(STATUS "real binary: '${real_binary}'")
diff --git a/Tests/RunCMake/SymlinkTrees/RunCMakeTest.cmake b/Tests/RunCMake/SymlinkTrees/RunCMakeTest.cmake
index e5f1f7f..e5bfac4 100644
--- a/Tests/RunCMake/SymlinkTrees/RunCMakeTest.cmake
+++ b/Tests/RunCMake/SymlinkTrees/RunCMakeTest.cmake
@@ -1,34 +1,234 @@
include(RunCMake)
+function(run_symlink_test_case)
+ file(REMOVE_RECURSE
+ "${RunCMake_TEST_BINARY_DIR}/CMakeCache.txt"
+ "${RunCMake_TEST_BINARY_DIR}/CMakeFiles"
+ )
+ run_cmake_with_options(${ARGN})
+endfunction()
+
# This function assumes that ``${RunCMake_BINARY_DIR}/${name}/source`` and
# ``${RunCMake_BINARY_DIR}/${name}/binary`` are set up properly prior to
# calling it.
-function (run_symlink_test name)
+function (run_symlink_test case src bin src_from_bin bin_from_src)
+ string(REGEX REPLACE "-.*" "" name "${case}")
set(RunCMake_TEST_NO_CLEAN TRUE)
+ set(RunCMake_TEST_SOURCE_DIR "${RunCMake_BINARY_DIR}/${name}/${src}")
+ set(RunCMake_TEST_BINARY_DIR "${RunCMake_BINARY_DIR}/${name}/${bin}")
configure_file(
"${CMAKE_CURRENT_LIST_DIR}/CMakeLists.txt"
- "${RunCMake_BINARY_DIR}/${name}/source/CMakeLists.txt"
+ "${RunCMake_TEST_SOURCE_DIR}/CMakeLists.txt"
COPYONLY)
- set(RunCMake_TEST_SOURCE_DIR "${RunCMake_BINARY_DIR}/${name}/source")
- set(RunCMake_TEST_BINARY_DIR "${RunCMake_BINARY_DIR}/${name}/binary")
+
+ # We explicitly pass the source directory argument for each case.
+ set(RunCMake_TEST_NO_SOURCE_DIR 1)
+
+ # Test running in binary directory.
+ set(RunCMake_TEST_COMMAND_WORKING_DIRECTORY "${RunCMake_TEST_BINARY_DIR}")
# Emulate a shell using this directory.
- set(ENV{PWD} "${RunCMake_TEST_BINARY_DIR}")
- set(RunCMake_TEST_OPTIONS
- "-Dinclude_dir:PATH=${CMAKE_CURRENT_LIST_DIR}")
- run_cmake("${name}_symlinks")
+ set(ENV{PWD} "${RunCMake_TEST_COMMAND_WORKING_DIRECTORY}")
+
+ # Pass absolute path to the source tree, plain.
+ set(RunCMake_TEST_VARIANT_DESCRIPTION " $abs/${name}/${src}")
+ run_symlink_test_case("${case}" "${RunCMake_TEST_SOURCE_DIR}")
+
+ # Pass absolute path to the source tree, with -S.
+ set(RunCMake_TEST_VARIANT_DESCRIPTION " -S $abs/${name}/${src}")
+ run_symlink_test_case("${case}" -S "${RunCMake_TEST_SOURCE_DIR}")
+
+ # Pass relative path to the source tree, plain.
+ set(RunCMake_TEST_VARIANT_DESCRIPTION " ${src_from_bin}")
+ run_symlink_test_case("${case}" "${src_from_bin}")
+
+ # Pass relative path to the source tree, with -S.
+ set(RunCMake_TEST_VARIANT_DESCRIPTION " -S ${src_from_bin}")
+ run_symlink_test_case("${case}" -S "${src_from_bin}")
+
+ # Test running in source directory.
+ set(RunCMake_TEST_COMMAND_WORKING_DIRECTORY "${RunCMake_TEST_SOURCE_DIR}")
+ # Emulate a shell using this directory.
+ set(ENV{PWD} "${RunCMake_TEST_COMMAND_WORKING_DIRECTORY}")
+
+ # Pass absolute path to the binary tree with -B.
+ set(RunCMake_TEST_VARIANT_DESCRIPTION " -B $abs/${name}/${bin}")
+ run_symlink_test_case("${case}" -B "${RunCMake_TEST_BINARY_DIR}")
+
+ # Pass relative path to the binary tree with -B.
+ set(RunCMake_TEST_VARIANT_DESCRIPTION " -B ${bin_from_src}")
+ run_symlink_test_case("${case}" -B "${bin_from_src}")
+
+ # Test running in another directory.
+ set(RunCMake_TEST_COMMAND_WORKING_DIRECTORY "${RunCMake_BINARY_DIR}/${name}")
+ # Emulate a shell using this directory.
+ set(ENV{PWD} "${RunCMake_TEST_COMMAND_WORKING_DIRECTORY}")
+
+ # Pass absolute paths to the source and binary trees.
+ set(RunCMake_TEST_VARIANT_DESCRIPTION " -S $abs/${name}/${src} -B $abs/${name}/${bin}")
+ run_symlink_test_case("${case}" -S "${RunCMake_TEST_SOURCE_DIR}" -B "${RunCMake_TEST_BINARY_DIR}")
+
+ # Pass relative paths to the source and binary trees.
+ set(RunCMake_TEST_VARIANT_DESCRIPTION " -S ${src} -B ${bin}")
+ run_symlink_test_case("${case}" -S "${src}" -B "${bin}")
+
+ # Pass relative paths to the source and binary trees.
+ set(RunCMake_TEST_VARIANT_DESCRIPTION " -S ../${name}/${src} -B ../${name}/${bin}")
+ run_symlink_test_case("${case}" -S "../${name}/${src}" -B "../${name}/${bin}")
+
+ # Verify paths passed to compiler.
+ unset(RunCMake_TEST_VARIANT_DESCRIPTION)
+ run_symlink_test_case("${case}-exe" -S "${src}" -B "${bin}")
+ if (RunCMake_GENERATOR MATCHES "Xcode")
+ # The native build system may pass the real paths.
+ set(RunCMake-stdout-file "generic-exe-build-stdout.txt")
+ endif()
+ set(RunCMake_TEST_OUTPUT_MERGE 1)
+ run_cmake_command("${case}-exe-build" ${CMAKE_COMMAND} --build "${bin}")
endfunction ()
# Create the following structure:
#
+# .../none/source
+# .../none/binary
+file(REMOVE_RECURSE "${RunCMake_BINARY_DIR}/none")
+file(MAKE_DIRECTORY "${RunCMake_BINARY_DIR}/none/source")
+file(MAKE_DIRECTORY "${RunCMake_BINARY_DIR}/none/binary")
+run_symlink_test(none-separate "source" "binary" "../source" "../binary")
+
+# Create the following structure:
+#
+# .../none/source
+# .../none/source/binary
+file(REMOVE_RECURSE "${RunCMake_BINARY_DIR}/none")
+file(MAKE_DIRECTORY "${RunCMake_BINARY_DIR}/none/source")
+file(MAKE_DIRECTORY "${RunCMake_BINARY_DIR}/none/source/binary")
+run_symlink_test(none-bin_in_src "source" "source/binary" ".." "binary")
+
+# Create the following structure:
+#
+# .../none/binary
+# .../none/binary/source
+file(REMOVE_RECURSE "${RunCMake_BINARY_DIR}/none")
+file(MAKE_DIRECTORY "${RunCMake_BINARY_DIR}/none/binary")
+file(MAKE_DIRECTORY "${RunCMake_BINARY_DIR}/none/binary/source")
+run_symlink_test(none-src_in_bin "binary/source" "binary" "source" "..")
+
+# Create the following structure:
+#
# .../common_real/source
# .../common_real/binary
# .../common -> common_real
-#
-# In this case, CMake should act as if .../common *is* .../common_real for all
-# computations except ``REALPATH``. This supports the case where a system has
-# a stable *symlink*, but not a stable target for that symlink.
file(REMOVE_RECURSE "${RunCMake_BINARY_DIR}/common_real")
file(REMOVE "${RunCMake_BINARY_DIR}/common")
file(MAKE_DIRECTORY "${RunCMake_BINARY_DIR}/common_real/source")
+file(MAKE_DIRECTORY "${RunCMake_BINARY_DIR}/common_real/binary")
file(CREATE_LINK "common_real" "${RunCMake_BINARY_DIR}/common" SYMBOLIC)
-run_symlink_test(common)
+run_symlink_test(common-separate "source" "binary" "../source" "../binary")
+
+# Create the following structure:
+#
+# .../common_real/source
+# .../common_real/source/binary
+# .../common -> common_real
+file(REMOVE_RECURSE "${RunCMake_BINARY_DIR}/common_real")
+file(REMOVE "${RunCMake_BINARY_DIR}/common")
+file(MAKE_DIRECTORY "${RunCMake_BINARY_DIR}/common_real/source")
+file(MAKE_DIRECTORY "${RunCMake_BINARY_DIR}/common_real/source/binary")
+file(CREATE_LINK "common_real" "${RunCMake_BINARY_DIR}/common" SYMBOLIC)
+run_symlink_test(common-bin_in_src "source" "source/binary" ".." "binary")
+
+# Create the following structure:
+#
+# .../common_real/binary
+# .../common_real/binary/source
+# .../common -> common_real
+file(REMOVE_RECURSE "${RunCMake_BINARY_DIR}/common_real")
+file(REMOVE "${RunCMake_BINARY_DIR}/common")
+file(MAKE_DIRECTORY "${RunCMake_BINARY_DIR}/common_real/binary")
+file(MAKE_DIRECTORY "${RunCMake_BINARY_DIR}/common_real/binary/source")
+file(CREATE_LINK "common_real" "${RunCMake_BINARY_DIR}/common" SYMBOLIC)
+run_symlink_test(common-src_in_bin "binary/source" "binary" "source" "..")
+
+# Create the following structure:
+#
+# .../different_src/source_real
+# .../different_bin/binary_real
+# .../different/source -> ../different_src/source_real
+# .../different/binary -> ../different_bin/binary_real
+file(REMOVE_RECURSE "${RunCMake_BINARY_DIR}/different")
+file(REMOVE_RECURSE "${RunCMake_BINARY_DIR}/different_src")
+file(REMOVE_RECURSE "${RunCMake_BINARY_DIR}/different_bin")
+file(MAKE_DIRECTORY "${RunCMake_BINARY_DIR}/different")
+file(MAKE_DIRECTORY "${RunCMake_BINARY_DIR}/different_src/source_real")
+file(MAKE_DIRECTORY "${RunCMake_BINARY_DIR}/different_bin/binary_real")
+file(CREATE_LINK "../different_src/source_real" "${RunCMake_BINARY_DIR}/different/source" SYMBOLIC)
+file(CREATE_LINK "../different_bin/binary_real" "${RunCMake_BINARY_DIR}/different/binary" SYMBOLIC)
+run_symlink_test(different-separate "source" "binary" "../../different/source" "../../different/binary")
+
+# Create the following structure:
+#
+# .../different_src/source_real
+# .../different_bin/binary_real
+# .../different/source -> ../different_src/source_real
+# .../different_src/source_real/binary -> ../../different_bin/binary_real
+file(REMOVE_RECURSE "${RunCMake_BINARY_DIR}/different")
+file(REMOVE_RECURSE "${RunCMake_BINARY_DIR}/different_src")
+file(REMOVE_RECURSE "${RunCMake_BINARY_DIR}/different_bin")
+file(MAKE_DIRECTORY "${RunCMake_BINARY_DIR}/different")
+file(MAKE_DIRECTORY "${RunCMake_BINARY_DIR}/different_src/source_real")
+file(MAKE_DIRECTORY "${RunCMake_BINARY_DIR}/different_bin/binary_real")
+file(CREATE_LINK "../different_src/source_real" "${RunCMake_BINARY_DIR}/different/source" SYMBOLIC)
+file(CREATE_LINK "../../different_bin/binary_real" "${RunCMake_BINARY_DIR}/different_src/source_real/binary" SYMBOLIC)
+run_symlink_test(different-bin_in_src "source" "source/binary" "../../different/source" "binary")
+
+# Create the following structure:
+#
+# .../different_src/source_real
+# .../different_bin/binary_real
+# .../different/binary -> ../different_bin/binary_real
+# .../different_bin/binary_real/source -> ../../different_src/source_real
+file(REMOVE_RECURSE "${RunCMake_BINARY_DIR}/different")
+file(REMOVE_RECURSE "${RunCMake_BINARY_DIR}/different_src")
+file(REMOVE_RECURSE "${RunCMake_BINARY_DIR}/different_bin")
+file(MAKE_DIRECTORY "${RunCMake_BINARY_DIR}/different")
+file(MAKE_DIRECTORY "${RunCMake_BINARY_DIR}/different_src/source_real")
+file(MAKE_DIRECTORY "${RunCMake_BINARY_DIR}/different_bin/binary_real")
+file(CREATE_LINK "../different_bin/binary_real" "${RunCMake_BINARY_DIR}/different/binary" SYMBOLIC)
+file(CREATE_LINK "../../different_src/source_real" "${RunCMake_BINARY_DIR}/different_bin/binary_real/source" SYMBOLIC)
+run_symlink_test(different-src_in_bin "binary/source" "binary" "source" "../../different/binary")
+
+# Create the following structure:
+#
+# .../asymmetric_real/path/binary
+# .../asymmetric/source
+# .../asymmetric/binary -> ../asymmetric_real/path/binary
+file(REMOVE_RECURSE "${RunCMake_BINARY_DIR}/asymmetric")
+file(REMOVE_RECURSE "${RunCMake_BINARY_DIR}/asymmetric_real")
+file(MAKE_DIRECTORY "${RunCMake_BINARY_DIR}/asymmetric/source")
+file(MAKE_DIRECTORY "${RunCMake_BINARY_DIR}/asymmetric_real/path/binary")
+file(CREATE_LINK "../asymmetric_real/path/binary" "${RunCMake_BINARY_DIR}/asymmetric/binary" SYMBOLIC)
+run_symlink_test(asymmetric-separate "source" "binary" "../../../asymmetric/source" "../binary")
+
+# Create the following structure:
+#
+# .../asymmetric_real/path/binary
+# .../asymmetric/source
+# .../asymmetric/source/binary -> ../../asymmetric_real/path/binary
+file(REMOVE_RECURSE "${RunCMake_BINARY_DIR}/asymmetric")
+file(REMOVE_RECURSE "${RunCMake_BINARY_DIR}/asymmetric_real")
+file(MAKE_DIRECTORY "${RunCMake_BINARY_DIR}/asymmetric/source")
+file(MAKE_DIRECTORY "${RunCMake_BINARY_DIR}/asymmetric_real/path/binary")
+file(CREATE_LINK "../../asymmetric_real/path/binary" "${RunCMake_BINARY_DIR}/asymmetric/source/binary" SYMBOLIC)
+run_symlink_test(asymmetric-bin_in_src "source" "source/binary" "../../../asymmetric/source" "binary")
+
+# Create the following structure:
+#
+# .../asymmetric_real/path/source
+# .../asymmetric/binary
+# .../asymmetric/binary/source -> ../../asymmetric_real/path/source
+file(REMOVE_RECURSE "${RunCMake_BINARY_DIR}/asymmetric")
+file(REMOVE_RECURSE "${RunCMake_BINARY_DIR}/asymmetric_real")
+file(MAKE_DIRECTORY "${RunCMake_BINARY_DIR}/asymmetric/binary")
+file(MAKE_DIRECTORY "${RunCMake_BINARY_DIR}/asymmetric_real/path/source")
+file(CREATE_LINK "../../asymmetric_real/path/source" "${RunCMake_BINARY_DIR}/asymmetric/binary/source" SYMBOLIC)
+run_symlink_test(asymmetric-src_in_bin "binary/source" "binary" "source" "../../../asymmetric/binary")
diff --git a/Tests/RunCMake/SymlinkTrees/asymmetric-bin_in_src-exe-build-stdout.txt b/Tests/RunCMake/SymlinkTrees/asymmetric-bin_in_src-exe-build-stdout.txt
new file mode 100644
index 0000000..450d9f1
--- /dev/null
+++ b/Tests/RunCMake/SymlinkTrees/asymmetric-bin_in_src-exe-build-stdout.txt
@@ -0,0 +1,4 @@
+source.c: '[^']*/Tests/RunCMake/SymlinkTrees/asymmetric/source/source.c'
+source.h: '[^']*/Tests/RunCMake/SymlinkTrees/asymmetric/source/include/source.h'
+binary.c: '[^']*/Tests/RunCMake/SymlinkTrees/asymmetric/source/binary/binary.c'
+binary.h: '[^']*/Tests/RunCMake/SymlinkTrees/asymmetric/source/binary/include/binary.h'
diff --git a/Tests/RunCMake/SymlinkTrees/asymmetric-bin_in_src-stdout.txt b/Tests/RunCMake/SymlinkTrees/asymmetric-bin_in_src-stdout.txt
new file mode 100644
index 0000000..bc19ac9
--- /dev/null
+++ b/Tests/RunCMake/SymlinkTrees/asymmetric-bin_in_src-stdout.txt
@@ -0,0 +1,4 @@
+-- source: '[^']*/Tests/RunCMake/SymlinkTrees/asymmetric/source'
+-- binary: '[^']*/Tests/RunCMake/SymlinkTrees/asymmetric/source/binary'
+-- real source: '[^']*/Tests/RunCMake/SymlinkTrees/asymmetric/source'
+-- real binary: '[^']*/Tests/RunCMake/SymlinkTrees/asymmetric_real/path/binary'
diff --git a/Tests/RunCMake/SymlinkTrees/asymmetric-separate-exe-build-stdout.txt b/Tests/RunCMake/SymlinkTrees/asymmetric-separate-exe-build-stdout.txt
new file mode 100644
index 0000000..c1ad9d7
--- /dev/null
+++ b/Tests/RunCMake/SymlinkTrees/asymmetric-separate-exe-build-stdout.txt
@@ -0,0 +1,4 @@
+source.c: '[^']*/Tests/RunCMake/SymlinkTrees/asymmetric/source/source.c'
+source.h: '[^']*/Tests/RunCMake/SymlinkTrees/asymmetric/source/include/source.h'
+binary.c: '[^']*/Tests/RunCMake/SymlinkTrees/asymmetric/binary/binary.c'
+binary.h: '[^']*/Tests/RunCMake/SymlinkTrees/asymmetric/binary/include/binary.h'
diff --git a/Tests/RunCMake/SymlinkTrees/asymmetric-separate-stdout.txt b/Tests/RunCMake/SymlinkTrees/asymmetric-separate-stdout.txt
new file mode 100644
index 0000000..f103630
--- /dev/null
+++ b/Tests/RunCMake/SymlinkTrees/asymmetric-separate-stdout.txt
@@ -0,0 +1,4 @@
+-- source: '[^']*/Tests/RunCMake/SymlinkTrees/asymmetric/source'
+-- binary: '[^']*/Tests/RunCMake/SymlinkTrees/asymmetric/binary'
+-- real source: '[^']*/Tests/RunCMake/SymlinkTrees/asymmetric/source'
+-- real binary: '[^']*/Tests/RunCMake/SymlinkTrees/asymmetric_real/path/binary'
diff --git a/Tests/RunCMake/SymlinkTrees/asymmetric-src_in_bin-exe-build-stdout.txt b/Tests/RunCMake/SymlinkTrees/asymmetric-src_in_bin-exe-build-stdout.txt
new file mode 100644
index 0000000..4a33651
--- /dev/null
+++ b/Tests/RunCMake/SymlinkTrees/asymmetric-src_in_bin-exe-build-stdout.txt
@@ -0,0 +1,4 @@
+source.c: '[^']*/Tests/RunCMake/SymlinkTrees/asymmetric/binary/source/source.c'
+source.h: '[^']*/Tests/RunCMake/SymlinkTrees/asymmetric/binary/source/include/source.h'
+binary.c: '[^']*/Tests/RunCMake/SymlinkTrees/asymmetric/binary/binary.c'
+binary.h: '[^']*/Tests/RunCMake/SymlinkTrees/asymmetric/binary/include/binary.h'
diff --git a/Tests/RunCMake/SymlinkTrees/asymmetric-src_in_bin-stdout.txt b/Tests/RunCMake/SymlinkTrees/asymmetric-src_in_bin-stdout.txt
new file mode 100644
index 0000000..6b6bf11
--- /dev/null
+++ b/Tests/RunCMake/SymlinkTrees/asymmetric-src_in_bin-stdout.txt
@@ -0,0 +1,4 @@
+-- source: '[^']*/Tests/RunCMake/SymlinkTrees/asymmetric/binary/source'
+-- binary: '[^']*/Tests/RunCMake/SymlinkTrees/asymmetric/binary'
+-- real source: '[^']*/Tests/RunCMake/SymlinkTrees/asymmetric_real/path/source'
+-- real binary: '[^']*/Tests/RunCMake/SymlinkTrees/asymmetric/binary'
diff --git a/Tests/RunCMake/SymlinkTrees/common-bin_in_src-exe-build-stdout.txt b/Tests/RunCMake/SymlinkTrees/common-bin_in_src-exe-build-stdout.txt
new file mode 100644
index 0000000..d72e250
--- /dev/null
+++ b/Tests/RunCMake/SymlinkTrees/common-bin_in_src-exe-build-stdout.txt
@@ -0,0 +1,4 @@
+source.c: '[^']*/Tests/RunCMake/SymlinkTrees/common/source/source.c'
+source.h: '[^']*/Tests/RunCMake/SymlinkTrees/common/source/include/source.h'
+binary.c: '[^']*/Tests/RunCMake/SymlinkTrees/common/source/binary/binary.c'
+binary.h: '[^']*/Tests/RunCMake/SymlinkTrees/common/source/binary/include/binary.h'
diff --git a/Tests/RunCMake/SymlinkTrees/common-bin_in_src-stdout.txt b/Tests/RunCMake/SymlinkTrees/common-bin_in_src-stdout.txt
new file mode 100644
index 0000000..90dcf02
--- /dev/null
+++ b/Tests/RunCMake/SymlinkTrees/common-bin_in_src-stdout.txt
@@ -0,0 +1,4 @@
+-- source: '[^']*/Tests/RunCMake/SymlinkTrees/common/source'
+-- binary: '[^']*/Tests/RunCMake/SymlinkTrees/common/source/binary'
+-- real source: '[^']*/Tests/RunCMake/SymlinkTrees/common_real/source'
+-- real binary: '[^']*/Tests/RunCMake/SymlinkTrees/common_real/source/binary'
diff --git a/Tests/RunCMake/SymlinkTrees/common-separate-exe-build-stdout.txt b/Tests/RunCMake/SymlinkTrees/common-separate-exe-build-stdout.txt
new file mode 100644
index 0000000..7f73af2
--- /dev/null
+++ b/Tests/RunCMake/SymlinkTrees/common-separate-exe-build-stdout.txt
@@ -0,0 +1,4 @@
+source.c: '[^']*/Tests/RunCMake/SymlinkTrees/common/source/source.c'
+source.h: '[^']*/Tests/RunCMake/SymlinkTrees/common/source/include/source.h'
+binary.c: '[^']*/Tests/RunCMake/SymlinkTrees/common/binary/binary.c'
+binary.h: '[^']*/Tests/RunCMake/SymlinkTrees/common/binary/include/binary.h'
diff --git a/Tests/RunCMake/SymlinkTrees/common_symlinks-stdout.txt b/Tests/RunCMake/SymlinkTrees/common-separate-stdout.txt
similarity index 100%
rename from Tests/RunCMake/SymlinkTrees/common_symlinks-stdout.txt
rename to Tests/RunCMake/SymlinkTrees/common-separate-stdout.txt
diff --git a/Tests/RunCMake/SymlinkTrees/common-src_in_bin-exe-build-stdout.txt b/Tests/RunCMake/SymlinkTrees/common-src_in_bin-exe-build-stdout.txt
new file mode 100644
index 0000000..aa0d60a
--- /dev/null
+++ b/Tests/RunCMake/SymlinkTrees/common-src_in_bin-exe-build-stdout.txt
@@ -0,0 +1,4 @@
+source.c: '[^']*/Tests/RunCMake/SymlinkTrees/common/binary/source/source.c'
+source.h: '[^']*/Tests/RunCMake/SymlinkTrees/common/binary/source/include/source.h'
+binary.c: '[^']*/Tests/RunCMake/SymlinkTrees/common/binary/binary.c'
+binary.h: '[^']*/Tests/RunCMake/SymlinkTrees/common/binary/include/binary.h'
diff --git a/Tests/RunCMake/SymlinkTrees/common-src_in_bin-stdout.txt b/Tests/RunCMake/SymlinkTrees/common-src_in_bin-stdout.txt
new file mode 100644
index 0000000..fc9db21
--- /dev/null
+++ b/Tests/RunCMake/SymlinkTrees/common-src_in_bin-stdout.txt
@@ -0,0 +1,4 @@
+-- source: '[^']*/Tests/RunCMake/SymlinkTrees/common/binary/source'
+-- binary: '[^']*/Tests/RunCMake/SymlinkTrees/common/binary'
+-- real source: '[^']*/Tests/RunCMake/SymlinkTrees/common_real/binary/source'
+-- real binary: '[^']*/Tests/RunCMake/SymlinkTrees/common_real/binary'
diff --git a/Tests/RunCMake/SymlinkTrees/common_symlinks.cmake b/Tests/RunCMake/SymlinkTrees/common_symlinks.cmake
deleted file mode 100644
index 5eafe26..0000000
--- a/Tests/RunCMake/SymlinkTrees/common_symlinks.cmake
+++ /dev/null
@@ -1 +0,0 @@
-include("${CMAKE_CURRENT_LIST_DIR}/PrintTrees.cmake")
diff --git a/Tests/RunCMake/SymlinkTrees/different-bin_in_src-exe-build-stdout.txt b/Tests/RunCMake/SymlinkTrees/different-bin_in_src-exe-build-stdout.txt
new file mode 100644
index 0000000..1bd1559
--- /dev/null
+++ b/Tests/RunCMake/SymlinkTrees/different-bin_in_src-exe-build-stdout.txt
@@ -0,0 +1,4 @@
+source.c: '[^']*/Tests/RunCMake/SymlinkTrees/different/source/source.c'
+source.h: '[^']*/Tests/RunCMake/SymlinkTrees/different/source/include/source.h'
+binary.c: '[^']*/Tests/RunCMake/SymlinkTrees/different/source/binary/binary.c'
+binary.h: '[^']*/Tests/RunCMake/SymlinkTrees/different/source/binary/include/binary.h'
diff --git a/Tests/RunCMake/SymlinkTrees/different-bin_in_src-stdout.txt b/Tests/RunCMake/SymlinkTrees/different-bin_in_src-stdout.txt
new file mode 100644
index 0000000..0533872
--- /dev/null
+++ b/Tests/RunCMake/SymlinkTrees/different-bin_in_src-stdout.txt
@@ -0,0 +1,4 @@
+-- source: '[^']*/Tests/RunCMake/SymlinkTrees/different/source'
+-- binary: '[^']*/Tests/RunCMake/SymlinkTrees/different/source/binary'
+-- real source: '[^']*/Tests/RunCMake/SymlinkTrees/different_src/source_real'
+-- real binary: '[^']*/Tests/RunCMake/SymlinkTrees/different_bin/binary_real'
diff --git a/Tests/RunCMake/SymlinkTrees/different-separate-exe-build-stdout.txt b/Tests/RunCMake/SymlinkTrees/different-separate-exe-build-stdout.txt
new file mode 100644
index 0000000..e598725
--- /dev/null
+++ b/Tests/RunCMake/SymlinkTrees/different-separate-exe-build-stdout.txt
@@ -0,0 +1,4 @@
+source.c: '[^']*/Tests/RunCMake/SymlinkTrees/different/source/source.c'
+source.h: '[^']*/Tests/RunCMake/SymlinkTrees/different/source/include/source.h'
+binary.c: '[^']*/Tests/RunCMake/SymlinkTrees/different/binary/binary.c'
+binary.h: '[^']*/Tests/RunCMake/SymlinkTrees/different/binary/include/binary.h'
diff --git a/Tests/RunCMake/SymlinkTrees/different-separate-stdout.txt b/Tests/RunCMake/SymlinkTrees/different-separate-stdout.txt
new file mode 100644
index 0000000..fe9c472
--- /dev/null
+++ b/Tests/RunCMake/SymlinkTrees/different-separate-stdout.txt
@@ -0,0 +1,4 @@
+-- source: '[^']*/Tests/RunCMake/SymlinkTrees/different/source'
+-- binary: '[^']*/Tests/RunCMake/SymlinkTrees/different/binary'
+-- real source: '[^']*/Tests/RunCMake/SymlinkTrees/different_src/source_real'
+-- real binary: '[^']*/Tests/RunCMake/SymlinkTrees/different_bin/binary_real'
diff --git a/Tests/RunCMake/SymlinkTrees/different-src_in_bin-exe-build-stdout.txt b/Tests/RunCMake/SymlinkTrees/different-src_in_bin-exe-build-stdout.txt
new file mode 100644
index 0000000..a5a2111
--- /dev/null
+++ b/Tests/RunCMake/SymlinkTrees/different-src_in_bin-exe-build-stdout.txt
@@ -0,0 +1,4 @@
+source.c: '[^']*/Tests/RunCMake/SymlinkTrees/different/binary/source/source.c'
+source.h: '[^']*/Tests/RunCMake/SymlinkTrees/different/binary/source/include/source.h'
+binary.c: '[^']*/Tests/RunCMake/SymlinkTrees/different/binary/binary.c'
+binary.h: '[^']*/Tests/RunCMake/SymlinkTrees/different/binary/include/binary.h'
diff --git a/Tests/RunCMake/SymlinkTrees/different-src_in_bin-stdout.txt b/Tests/RunCMake/SymlinkTrees/different-src_in_bin-stdout.txt
new file mode 100644
index 0000000..248e820
--- /dev/null
+++ b/Tests/RunCMake/SymlinkTrees/different-src_in_bin-stdout.txt
@@ -0,0 +1,4 @@
+-- source: '[^']*/Tests/RunCMake/SymlinkTrees/different/binary/source'
+-- binary: '[^']*/Tests/RunCMake/SymlinkTrees/different/binary'
+-- real source: '[^']*/Tests/RunCMake/SymlinkTrees/different_src/source_real'
+-- real binary: '[^']*/Tests/RunCMake/SymlinkTrees/different_bin/binary_real'
diff --git a/Tests/RunCMake/SymlinkTrees/generic-exe-build-stdout.txt b/Tests/RunCMake/SymlinkTrees/generic-exe-build-stdout.txt
new file mode 100644
index 0000000..db2173c
--- /dev/null
+++ b/Tests/RunCMake/SymlinkTrees/generic-exe-build-stdout.txt
@@ -0,0 +1,4 @@
+source.c: '[^']*/Tests/RunCMake/SymlinkTrees/[^']*/source.c'
+source.h: '[^']*/Tests/RunCMake/SymlinkTrees/[^']*/include/source.h'
+binary.c: '[^']*/Tests/RunCMake/SymlinkTrees/[^']*/binary.c'
+binary.h: '[^']*/Tests/RunCMake/SymlinkTrees/[^']*/include/binary.h'
diff --git a/Tests/RunCMake/SymlinkTrees/none-bin_in_src-exe-build-stdout.txt b/Tests/RunCMake/SymlinkTrees/none-bin_in_src-exe-build-stdout.txt
new file mode 100644
index 0000000..520d8a8
--- /dev/null
+++ b/Tests/RunCMake/SymlinkTrees/none-bin_in_src-exe-build-stdout.txt
@@ -0,0 +1,4 @@
+source.c: '[^']*/Tests/RunCMake/SymlinkTrees/none/source/source.c'
+source.h: '[^']*/Tests/RunCMake/SymlinkTrees/none/source/include/source.h'
+binary.c: '[^']*/Tests/RunCMake/SymlinkTrees/none/source/binary/binary.c'
+binary.h: '[^']*/Tests/RunCMake/SymlinkTrees/none/source/binary/include/binary.h'
diff --git a/Tests/RunCMake/SymlinkTrees/none-bin_in_src-stdout.txt b/Tests/RunCMake/SymlinkTrees/none-bin_in_src-stdout.txt
new file mode 100644
index 0000000..6d6af52
--- /dev/null
+++ b/Tests/RunCMake/SymlinkTrees/none-bin_in_src-stdout.txt
@@ -0,0 +1,4 @@
+-- source: '[^']*/Tests/RunCMake/SymlinkTrees/none/source'
+-- binary: '[^']*/Tests/RunCMake/SymlinkTrees/none/source/binary'
+-- real source: '[^']*/Tests/RunCMake/SymlinkTrees/none/source'
+-- real binary: '[^']*/Tests/RunCMake/SymlinkTrees/none/source/binary'
diff --git a/Tests/RunCMake/SymlinkTrees/none-separate-exe-build-stdout.txt b/Tests/RunCMake/SymlinkTrees/none-separate-exe-build-stdout.txt
new file mode 100644
index 0000000..90791d4
--- /dev/null
+++ b/Tests/RunCMake/SymlinkTrees/none-separate-exe-build-stdout.txt
@@ -0,0 +1,4 @@
+source.c: '[^']*/Tests/RunCMake/SymlinkTrees/none/source/source.c'
+source.h: '[^']*/Tests/RunCMake/SymlinkTrees/none/source/include/source.h'
+binary.c: '[^']*/Tests/RunCMake/SymlinkTrees/none/binary/binary.c'
+binary.h: '[^']*/Tests/RunCMake/SymlinkTrees/none/binary/include/binary.h'
diff --git a/Tests/RunCMake/SymlinkTrees/none-separate-stdout.txt b/Tests/RunCMake/SymlinkTrees/none-separate-stdout.txt
new file mode 100644
index 0000000..2251ac5
--- /dev/null
+++ b/Tests/RunCMake/SymlinkTrees/none-separate-stdout.txt
@@ -0,0 +1,4 @@
+-- source: '[^']*/Tests/RunCMake/SymlinkTrees/none/source'
+-- binary: '[^']*/Tests/RunCMake/SymlinkTrees/none/binary'
+-- real source: '[^']*/Tests/RunCMake/SymlinkTrees/none/source'
+-- real binary: '[^']*/Tests/RunCMake/SymlinkTrees/none/binary'
diff --git a/Tests/RunCMake/SymlinkTrees/none-src_in_bin-exe-build-stdout.txt b/Tests/RunCMake/SymlinkTrees/none-src_in_bin-exe-build-stdout.txt
new file mode 100644
index 0000000..07aed79
--- /dev/null
+++ b/Tests/RunCMake/SymlinkTrees/none-src_in_bin-exe-build-stdout.txt
@@ -0,0 +1,4 @@
+source.c: '[^']*/Tests/RunCMake/SymlinkTrees/none/binary/source/source.c'
+source.h: '[^']*/Tests/RunCMake/SymlinkTrees/none/binary/source/include/source.h'
+binary.c: '[^']*/Tests/RunCMake/SymlinkTrees/none/binary/binary.c'
+binary.h: '[^']*/Tests/RunCMake/SymlinkTrees/none/binary/include/binary.h'
diff --git a/Tests/RunCMake/SymlinkTrees/none-src_in_bin-stdout.txt b/Tests/RunCMake/SymlinkTrees/none-src_in_bin-stdout.txt
new file mode 100644
index 0000000..731d62a
--- /dev/null
+++ b/Tests/RunCMake/SymlinkTrees/none-src_in_bin-stdout.txt
@@ -0,0 +1,4 @@
+-- source: '[^']*/Tests/RunCMake/SymlinkTrees/none/binary/source'
+-- binary: '[^']*/Tests/RunCMake/SymlinkTrees/none/binary'
+-- real source: '[^']*/Tests/RunCMake/SymlinkTrees/none/binary/source'
+-- real binary: '[^']*/Tests/RunCMake/SymlinkTrees/none/binary'
diff --git a/Tests/RunCMake/VS10Project/RunCMakeTest.cmake b/Tests/RunCMake/VS10Project/RunCMakeTest.cmake
index 139dcc7..b19c1a8 100644
--- a/Tests/RunCMake/VS10Project/RunCMakeTest.cmake
+++ b/Tests/RunCMake/VS10Project/RunCMakeTest.cmake
@@ -84,3 +84,4 @@
run_cmake(VsDotnetTargetFramework)
run_cmake(VsDotnetTargetFrameworkVersion)
+run_cmake(VsNoCompileBatching)
diff --git a/Tests/RunCMake/VS10Project/VsNoCompileBatching-check.cmake b/Tests/RunCMake/VS10Project/VsNoCompileBatching-check.cmake
new file mode 100644
index 0000000..4002c3f
--- /dev/null
+++ b/Tests/RunCMake/VS10Project/VsNoCompileBatching-check.cmake
@@ -0,0 +1,31 @@
+macro(VsNoCompileBatching_check tgt ofn_expect)
+ set(vcProjectFile "${RunCMake_TEST_BINARY_DIR}/${tgt}.vcxproj")
+ if(NOT EXISTS "${vcProjectFile}")
+ set(RunCMake_TEST_FAILED "Project file ${tgt}.vcxproj does not exist.")
+ return()
+ endif()
+
+ set(HAVE_OFN 0)
+
+ file(STRINGS "${vcProjectFile}" lines)
+ foreach(line IN LISTS lines)
+ if(line MATCHES "^ *<ObjectFileName>([^<>]+)</ObjectFileName>")
+ set(ofn_actual "${CMAKE_MATCH_1}")
+ if(NOT "${ofn_actual}" STREQUAL "${ofn_expect}")
+ set(RunCMake_TEST_FAILED "Project file ${tgt}.vcxproj has <ObjectFileName> '${ofn_actual}', not '${ofn_expect}'.")
+ return()
+ endif()
+ set(HAVE_OFN 1)
+ break()
+ endif()
+ endforeach()
+
+ if(NOT HAVE_OFN)
+ set(RunCMake_TEST_FAILED "Project file ${tgt}.vcxproj does not have a <ObjectFileName> property.")
+ return()
+ endif()
+endmacro()
+
+VsNoCompileBatching_check(foo "$(IntDir)")
+VsNoCompileBatching_check(foo_NB "$(IntDir)%(filename).obj")
+VsNoCompileBatching_check(foo_NB_OFF "$(IntDir)")
diff --git a/Tests/RunCMake/VS10Project/VsNoCompileBatching.cmake b/Tests/RunCMake/VS10Project/VsNoCompileBatching.cmake
new file mode 100644
index 0000000..c96edce
--- /dev/null
+++ b/Tests/RunCMake/VS10Project/VsNoCompileBatching.cmake
@@ -0,0 +1,9 @@
+enable_language(CXX)
+
+add_library(foo foo.cpp)
+
+add_library(foo_NB foo.cpp)
+set_property(TARGET foo_NB PROPERTY VS_NO_COMPILE_BATCHING ON)
+
+add_library(foo_NB_OFF foo.cpp)
+set_property(TARGET foo_NB_OFF PROPERTY VS_NO_COMPILE_BATCHING OFF)
diff --git a/Tests/RunCMake/cmake_language/defer_call_trace_json-stderr.txt b/Tests/RunCMake/cmake_language/defer_call_trace_json-stderr.txt
index 647beb0..3bde16d 100644
--- a/Tests/RunCMake/cmake_language/defer_call_trace_json-stderr.txt
+++ b/Tests/RunCMake/cmake_language/defer_call_trace_json-stderr.txt
@@ -1,5 +1,5 @@
-{"args":\["DEFER","CALL","message","Deferred Message"\],"cmd":"cmake_language","file":"[^"]*/Tests/RunCMake/cmake_language/defer_call_trace_json.cmake","frame":2,"line":2,"time":[0-9.]+}
-{"args":\["Immediate Message"\],"cmd":"message","file":"[^"]*/Tests/RunCMake/cmake_language/defer_call_trace_json.cmake","frame":2,"line":3,"time":[0-9.]+}
+{"args":\["DEFER","CALL","message","Deferred Message"\],"cmd":"cmake_language","file":"[^"]*/Tests/RunCMake/cmake_language/defer_call_trace_json.cmake","frame":2,"global_frame":2,"line":2,"time":[0-9.]+}
+{"args":\["Immediate Message"\],"cmd":"message","file":"[^"]*/Tests/RunCMake/cmake_language/defer_call_trace_json.cmake","frame":2,"global_frame":2,"line":3,"time":[0-9.]+}
Immediate Message
-{"args":\["Deferred Message"],"cmd":"message","defer":"__0","file":"[^"]*/Tests/RunCMake/cmake_language/defer_call_trace_json.cmake","frame":1,"line":2,"time":[0-9.]+}
+{"args":\["Deferred Message"],"cmd":"message","defer":"__0","file":"[^"]*/Tests/RunCMake/cmake_language/defer_call_trace_json.cmake","frame":1,"global_frame":1,"line":2,"time":[0-9.]+}
Deferred Message$
diff --git a/Tests/RunCMake/ctest_build/RunCMakeTest.cmake b/Tests/RunCMake/ctest_build/RunCMakeTest.cmake
index 511cd71..e94a55d 100644
--- a/Tests/RunCMake/ctest_build/RunCMakeTest.cmake
+++ b/Tests/RunCMake/ctest_build/RunCMakeTest.cmake
@@ -49,6 +49,18 @@
endfunction()
run_BuildChangeId()
+function(run_SubdirTarget)
+ set(CASE_CMAKELISTS_SUFFIX_CODE [=[
+file(WRITE ${CMAKE_CURRENT_SOURCE_DIR}/subdir/CMakeLists.txt [[
+add_custom_target(target_in_subdir COMMAND ${CMAKE_COMMAND} -E touch target_in_subdir.out VERBATIM)
+]])
+add_subdirectory(subdir)
+]=])
+ set(CASE_CTEST_BUILD_ARGS TARGET target_in_subdir)
+ run_ctest(SubdirTarget)
+endfunction()
+run_SubdirTarget()
+
set(RunCMake_USE_CUSTOM_BUILD_COMMAND TRUE)
set(RunCMake_BUILD_COMMAND "${FAKE_BUILD_COMMAND_EXE}")
run_ctest(BuildCommandFailure)
diff --git a/Tests/RunCMake/ctest_build/SubdirTarget-check.cmake b/Tests/RunCMake/ctest_build/SubdirTarget-check.cmake
new file mode 100644
index 0000000..81d21ec
--- /dev/null
+++ b/Tests/RunCMake/ctest_build/SubdirTarget-check.cmake
@@ -0,0 +1,4 @@
+set(expected_file "${RunCMake_TEST_BINARY_DIR}/subdir/target_in_subdir.out")
+if(NOT EXISTS "${expected_file}")
+ set(RunCMake_TEST_FAILED "Expected build output file not found:\n ${expected_file}")
+endif()
diff --git a/Tests/RunCMake/ctest_test/RunCMakeTest.cmake b/Tests/RunCMake/ctest_test/RunCMakeTest.cmake
index de81049..b41c271 100644
--- a/Tests/RunCMake/ctest_test/RunCMakeTest.cmake
+++ b/Tests/RunCMake/ctest_test/RunCMakeTest.cmake
@@ -80,6 +80,23 @@
endfunction()
run_TestOutputSize()
+# Test --test-output-truncation
+function(run_TestOutputTruncation mode expected)
+ set(CASE_CTEST_TEST_ARGS EXCLUDE RunCMakeVersion)
+ set(TRUNCATED_OUTPUT ${expected}) # used in TestOutputTruncation-check.cmake
+ set(CASE_TEST_PREFIX_CODE [[
+set( CTEST_CUSTOM_TEST_OUTPUT_TRUNCATION${mode})
+ ]])
+ set(CASE_CMAKELISTS_SUFFIX_CODE [[
+add_test(NAME Truncation_${mode} COMMAND ${CMAKE_COMMAND} -E echo 123456789)
+ ]])
+
+ run_ctest(TestOutputTruncation)
+endfunction()
+run_TestOutputTruncation("head" "...6789")
+run_TestOutputTruncation("middle" "12....*...89")
+run_TestOutputTruncation("tail" "12345...")
+
run_ctest_test(TestRepeatBad1 REPEAT UNKNOWN:3)
run_ctest_test(TestRepeatBad2 REPEAT UNTIL_FAIL:-1)
diff --git a/Tests/RunCMake/ctest_test/TestOutputTruncation-check.cmake b/Tests/RunCMake/ctest_test/TestOutputTruncation-check.cmake
new file mode 100644
index 0000000..5769c9f
--- /dev/null
+++ b/Tests/RunCMake/ctest_test/TestOutputTruncation-check.cmake
@@ -0,0 +1,12 @@
+file(GLOB test_xml_file "${RunCMake_TEST_BINARY_DIR}/Testing/*/Test.xml")
+if(test_xml_file)
+ file(READ "${test_xml_file}" test_xml LIMIT 4096)
+ if("${test_xml}" MATCHES [[(<Test Status="passed">.*</Test>)]])
+ set(test_result "${CMAKE_MATCH_1}")
+ endif()
+ if(NOT "${test_result}" MATCHES "<Value>.*${TRUNCATED_OUTPUT}.*</Value>")
+ set(RunCMake_TEST_FAILED "Test output truncation failed:\n ${test_result}\nExpected: ${TRUNCATED_OUTPUT}")
+ endif()
+else()
+ set(RunCMake_TEST_FAILED "Test.xml not found")
+endif()
diff --git a/Tests/RunCMake/find_package/GlobalImportTarget-stdout.txt b/Tests/RunCMake/find_package/GlobalImportTarget-stdout.txt
new file mode 100644
index 0000000..bd06873
--- /dev/null
+++ b/Tests/RunCMake/find_package/GlobalImportTarget-stdout.txt
@@ -0,0 +1,31 @@
+-- IMPORTED TARGET imported_local_target has GLOBAL scope: TRUE
+-- IMPORTED TARGET imported_global_target has GLOBAL scope: TRUE
+-- IMPORTED TARGET imported_local_ex has GLOBAL scope: TRUE
+-- IMPORTED TARGET imported_global_ex has GLOBAL scope: TRUE
+-- IMPORTED TARGET Foo1 has GLOBAL scope: TRUE
+-- IMPORTED TARGET Foo2 has GLOBAL scope: TRUE
+-- IMPORTED TARGET imported_var_local_target has GLOBAL scope: TRUE
+-- IMPORTED TARGET imported_var_global_target has GLOBAL scope: TRUE
+-- IMPORTED TARGET imported_var_local_ex has GLOBAL scope: TRUE
+-- IMPORTED TARGET imported_var_global_ex has GLOBAL scope: TRUE
+-- IMPORTED TARGET imported_global_lib has GLOBAL scope: TRUE
+-- IMPORTED TARGET imported_explicit_global_ex has GLOBAL scope: TRUE
+-- IMPORTED TARGET imported_local_lib has GLOBAL scope: FALSE
+-- IMPORTED TARGET imported_implied_local_ex has GLOBAL scope: FALSE
+-- IMPORTED TARGET imported_no_var_local_target has GLOBAL scope: TRUE
+-- IMPORTED TARGET imported_no_var_global_target has GLOBAL scope: TRUE
+-- IMPORTED TARGET imported_no_var_local_ex has GLOBAL scope: TRUE
+-- IMPORTED TARGET imported_no_var_global_ex has GLOBAL scope: TRUE
+-- IMPORTED TARGET not_imported_not_global has GLOBAL scope: FALSE
+-- IMPORTED TARGET PackName has GLOBAL scope: TRUE
+-- IMPORTED TARGET PackNameExe has GLOBAL scope: TRUE
+-- IMPORTED TARGET PackName1 has GLOBAL scope: TRUE
+-- IMPORTED TARGET PackNameExe1 has GLOBAL scope: TRUE
+-- IMPORTED TARGET local_lib_glob has GLOBAL scope: TRUE
+-- IMPORTED TARGET local_exe_glob has GLOBAL scope: TRUE
+-- IMPORTED TARGET local_lib has GLOBAL scope: FALSE
+-- IMPORTED TARGET local_exe has GLOBAL scope: FALSE
+-- IMPORTED TARGET LT1 has GLOBAL scope: TRUE
+-- IMPORTED TARGET LT2 has GLOBAL scope: TRUE
+-- IMPORTED TARGET LT3 has GLOBAL scope: TRUE
+-- IMPORTED TARGET LT4 has GLOBAL scope: TRUE
diff --git a/Tests/RunCMake/find_package/GlobalImportTarget.cmake b/Tests/RunCMake/find_package/GlobalImportTarget.cmake
new file mode 100644
index 0000000..7e6d2b8
--- /dev/null
+++ b/Tests/RunCMake/find_package/GlobalImportTarget.cmake
@@ -0,0 +1,57 @@
+function (assess_target_property target)
+ get_target_property(target_val "${target}" IMPORTED_GLOBAL)
+ message(STATUS "IMPORTED TARGET ${target} has GLOBAL scope: ${target_val}")
+endfunction ()
+
+list(INSERT CMAKE_MODULE_PATH 0 ${CMAKE_CURRENT_SOURCE_DIR}/PackageRoot)
+
+find_package(GlobalTarget GLOBAL REQUIRED)
+assess_target_property(imported_local_target)
+assess_target_property(imported_global_target)
+assess_target_property(imported_local_ex)
+assess_target_property(imported_global_ex)
+assess_target_property(Foo1)
+assess_target_property(Foo2)
+
+set(CMAKE_FIND_PACKAGE_TARGETS_GLOBAL TRUE)
+find_package(GlobalVarTarget)
+assess_target_property(imported_var_local_target)
+assess_target_property(imported_var_global_target)
+assess_target_property(imported_var_local_ex)
+assess_target_property(imported_var_global_ex)
+set(CMAKE_FIND_PACKAGE_TARGETS_GLOBAL OFF)
+
+find_package(LocalTarget)
+assess_target_property(imported_global_lib)
+assess_target_property(imported_explicit_global_ex)
+assess_target_property(imported_local_lib)
+assess_target_property(imported_implied_local_ex)
+
+find_package(GlobalTargetNoVar GLOBAL)
+assess_target_property(imported_no_var_local_target)
+assess_target_property(imported_no_var_global_target)
+assess_target_property(imported_no_var_local_ex)
+assess_target_property(imported_no_var_global_ex)
+assess_target_property(not_imported_not_global)
+
+set(Baz_DIR "${CMAKE_CURRENT_SOURCE_DIR}/PackageRoot")
+find_package(Baz GLOBAL REQUIRED)
+assess_target_property(PackName)
+assess_target_property(PackNameExe)
+assess_target_property(PackName1)
+assess_target_property(PackNameExe1)
+
+set(Biz_DIR "${CMAKE_CURRENT_SOURCE_DIR}/PackageRoot")
+find_package(Biz REQUIRED)
+assess_target_property(local_lib_glob)
+assess_target_property(local_exe_glob)
+assess_target_property(local_lib)
+assess_target_property(local_exe)
+
+set(CMAKE_FIND_PACKAGE_TARGETS_GLOBAL TRUE)
+set(Simple_DIR "${CMAKE_CURRENT_SOURCE_DIR}/PackageRoot")
+find_package(Simple REQUIRED)
+assess_target_property(LT1)
+assess_target_property(LT2)
+assess_target_property(LT3)
+assess_target_property(LT4)
diff --git a/Tests/RunCMake/find_package/PackageRoot/BazConfig.cmake b/Tests/RunCMake/find_package/PackageRoot/BazConfig.cmake
new file mode 100644
index 0000000..cca95a2
--- /dev/null
+++ b/Tests/RunCMake/find_package/PackageRoot/BazConfig.cmake
@@ -0,0 +1,3 @@
+include(CMakeFindDependencyMacro)
+
+find_dependency(PackName PATHS ${CMAKE_CURRENT_LIST_DIR})
diff --git a/Tests/RunCMake/find_package/PackageRoot/BizConfig.cmake b/Tests/RunCMake/find_package/PackageRoot/BizConfig.cmake
new file mode 100644
index 0000000..5b0e398
--- /dev/null
+++ b/Tests/RunCMake/find_package/PackageRoot/BizConfig.cmake
@@ -0,0 +1,3 @@
+include(CMakeFindDependencyMacro)
+
+find_dependency(LocalPack PATHS ${CMAKE_CURRENT_LIST_DIR})
diff --git a/Tests/RunCMake/find_package/PackageRoot/FindGlobalTarget.cmake b/Tests/RunCMake/find_package/PackageRoot/FindGlobalTarget.cmake
new file mode 100644
index 0000000..9e34613
--- /dev/null
+++ b/Tests/RunCMake/find_package/PackageRoot/FindGlobalTarget.cmake
@@ -0,0 +1,7 @@
+add_library(imported_global_target SHARED IMPORTED GLOBAL)
+add_executable(imported_global_ex IMPORTED GLOBAL)
+
+add_library(imported_local_target SHARED IMPORTED)
+add_executable(imported_local_ex IMPORTED)
+
+find_package(SimpleTarget)
diff --git a/Tests/RunCMake/find_package/PackageRoot/FindGlobalTargetNoVar.cmake b/Tests/RunCMake/find_package/PackageRoot/FindGlobalTargetNoVar.cmake
new file mode 100644
index 0000000..a156f90
--- /dev/null
+++ b/Tests/RunCMake/find_package/PackageRoot/FindGlobalTargetNoVar.cmake
@@ -0,0 +1,7 @@
+add_library(imported_no_var_global_target SHARED IMPORTED GLOBAL)
+add_executable(imported_no_var_global_ex IMPORTED GLOBAL)
+
+add_library(imported_no_var_local_target SHARED IMPORTED)
+add_executable(imported_no_var_local_ex IMPORTED)
+
+add_library(not_imported_not_global INTERFACE)
diff --git a/Tests/RunCMake/find_package/PackageRoot/FindGlobalVarTarget.cmake b/Tests/RunCMake/find_package/PackageRoot/FindGlobalVarTarget.cmake
new file mode 100644
index 0000000..2e96a6c
--- /dev/null
+++ b/Tests/RunCMake/find_package/PackageRoot/FindGlobalVarTarget.cmake
@@ -0,0 +1,5 @@
+add_library(imported_var_global_target SHARED IMPORTED GLOBAL)
+add_executable(imported_var_global_ex IMPORTED GLOBAL)
+
+add_library(imported_var_local_target SHARED IMPORTED)
+add_executable(imported_var_local_ex IMPORTED)
diff --git a/Tests/RunCMake/find_package/PackageRoot/FindLocalTarget.cmake b/Tests/RunCMake/find_package/PackageRoot/FindLocalTarget.cmake
new file mode 100644
index 0000000..d533405
--- /dev/null
+++ b/Tests/RunCMake/find_package/PackageRoot/FindLocalTarget.cmake
@@ -0,0 +1,5 @@
+add_library(imported_global_lib SHARED IMPORTED GLOBAL)
+add_executable(imported_explicit_global_ex IMPORTED GLOBAL)
+
+add_library(imported_local_lib SHARED IMPORTED)
+add_executable(imported_implied_local_ex IMPORTED)
diff --git a/Tests/RunCMake/find_package/PackageRoot/FindSimpleTarget.cmake b/Tests/RunCMake/find_package/PackageRoot/FindSimpleTarget.cmake
new file mode 100644
index 0000000..cd58004
--- /dev/null
+++ b/Tests/RunCMake/find_package/PackageRoot/FindSimpleTarget.cmake
@@ -0,0 +1,2 @@
+add_library(Foo1 SHARED IMPORTED)
+add_executable(Foo2 IMPORTED)
diff --git a/Tests/RunCMake/find_package/PackageRoot/LTConfig.cmake b/Tests/RunCMake/find_package/PackageRoot/LTConfig.cmake
new file mode 100644
index 0000000..f451eb6
--- /dev/null
+++ b/Tests/RunCMake/find_package/PackageRoot/LTConfig.cmake
@@ -0,0 +1,5 @@
+add_library(LT1 INTERFACE IMPORTED)
+add_executable(LT2 IMPORTED)
+
+add_library(LT3 INTERFACE IMPORTED GLOBAL)
+add_executable(LT4 IMPORTED GLOBAL)
diff --git a/Tests/RunCMake/find_package/PackageRoot/LocalPackConfig.cmake b/Tests/RunCMake/find_package/PackageRoot/LocalPackConfig.cmake
new file mode 100644
index 0000000..a962849
--- /dev/null
+++ b/Tests/RunCMake/find_package/PackageRoot/LocalPackConfig.cmake
@@ -0,0 +1,5 @@
+add_library(local_lib_glob SHARED IMPORTED GLOBAL)
+add_executable(local_exe_glob IMPORTED GLOBAL)
+
+add_library(local_lib SHARED IMPORTED)
+add_executable(local_exe IMPORTED)
diff --git a/Tests/RunCMake/find_package/PackageRoot/PackNameConfig.cmake b/Tests/RunCMake/find_package/PackageRoot/PackNameConfig.cmake
new file mode 100644
index 0000000..38dd2f8
--- /dev/null
+++ b/Tests/RunCMake/find_package/PackageRoot/PackNameConfig.cmake
@@ -0,0 +1,5 @@
+add_library(PackName INTERFACE IMPORTED GLOBAL)
+add_executable(PackNameExe IMPORTED GLOBAL)
+
+add_library(PackName1 INTERFACE IMPORTED)
+add_executable(PackNameExe1 IMPORTED)
diff --git a/Tests/RunCMake/find_package/PackageRoot/SimpleConfig.cmake b/Tests/RunCMake/find_package/PackageRoot/SimpleConfig.cmake
new file mode 100644
index 0000000..44059c6
--- /dev/null
+++ b/Tests/RunCMake/find_package/PackageRoot/SimpleConfig.cmake
@@ -0,0 +1,3 @@
+include(CMakeFindDependencyMacro)
+
+find_dependency(LT PATHS ${CMAKE_CURRENT_LIST_DIR})
diff --git a/Tests/RunCMake/find_package/RunCMakeTest.cmake b/Tests/RunCMake/find_package/RunCMakeTest.cmake
index 5f4c6cb..2b5fb1f 100644
--- a/Tests/RunCMake/find_package/RunCMakeTest.cmake
+++ b/Tests/RunCMake/find_package/RunCMakeTest.cmake
@@ -6,6 +6,7 @@
run_cmake(FromPATHEnv)
run_cmake_with_options(FromPATHEnvDebugPkg --debug-find-pkg=Resolved)
run_cmake(FromPrefixPath)
+run_cmake(GlobalImportTarget)
run_cmake(MissingNormal)
run_cmake(MissingNormalForceRequired)
run_cmake(MissingNormalRequired)
diff --git a/Tests/RunCMake/install/TARGETS-FILE_RPATH_CHANGE-new_rpath-stderr.txt b/Tests/RunCMake/install/TARGETS-FILE_RPATH_CHANGE-new_rpath-stderr.txt
index 2561263..8b0970a 100644
--- a/Tests/RunCMake/install/TARGETS-FILE_RPATH_CHANGE-new_rpath-stderr.txt
+++ b/Tests/RunCMake/install/TARGETS-FILE_RPATH_CHANGE-new_rpath-stderr.txt
@@ -1,3 +1,15 @@
+^CMake Deprecation Warning at TARGETS-FILE_RPATH_CHANGE-new_rpath.cmake:[0-9]+ \(cmake_policy\):
+ The OLD behavior for policy CMP0095 will be removed from a future version
+ of CMake.
+
+ The cmake-policies\(7\) manual explains that the OLD behaviors of all
+ policies are deprecated and that a policy should be set to OLD only under
+ specific short-term circumstances. Projects should be ported to the NEW
+ behavior and not rely on setting a policy to OLD.
+Call Stack \(most recent call first\):
+ TARGETS-FILE_RPATH_CHANGE-new_rpath.cmake:[0-9]+ \(A_CMP0095\)
+ CMakeLists.txt:[0-9]+ \(include\)(
++
CMake Warning \(dev\) at TARGETS-FILE_RPATH_CHANGE-new_rpath\.cmake:[0-9]+ \(install\):
Policy CMP0095 is not set: RPATH entries are properly escaped in the
intermediary CMake install script\. Run "cmake --help-policy CMP0095" for
@@ -8,8 +20,8 @@
intermediary cmake_install\.cmake script\.
Call Stack \(most recent call first\):
CMakeLists\.txt:[0-9]+ \(include\)
-This warning is for project developers\. Use -Wno-dev to suppress it\.
-
+This warning is for project developers\. Use -Wno-dev to suppress it\.)+(
++
CMake Warning \(dev\) at TARGETS-FILE_RPATH_CHANGE-new_rpath\.cmake:[0-9]+ \(install\):
Policy CMP0095 is not set: RPATH entries are properly escaped in the
intermediary CMake install script\. Run "cmake --help-policy CMP0095" for
@@ -20,4 +32,4 @@
intermediary cmake_install\.cmake script\.
Call Stack \(most recent call first\):
CMakeLists\.txt:[0-9]+ \(include\)
-This warning is for project developers\. Use -Wno-dev to suppress it\.
+This warning is for project developers\. Use -Wno-dev to suppress it\.)+$
diff --git a/Tests/RunCMake/project/CMP0096-OLD-stderr.txt b/Tests/RunCMake/project/CMP0096-OLD-stderr.txt
new file mode 100644
index 0000000..beb7a84
--- /dev/null
+++ b/Tests/RunCMake/project/CMP0096-OLD-stderr.txt
@@ -0,0 +1,10 @@
+^CMake Deprecation Warning at CMP0096-OLD.cmake:[0-9]+ \(cmake_policy\):
+ The OLD behavior for policy CMP0096 will be removed from a future version
+ of CMake.
+
+ The cmake-policies\(7\) manual explains that the OLD behaviors of all
+ policies are deprecated and that a policy should be set to OLD only under
+ specific short-term circumstances. Projects should be ported to the NEW
+ behavior and not rely on setting a policy to OLD.
+Call Stack \(most recent call first\):
+ CMakeLists.txt:[0-9]+ \(include\)$
diff --git a/Tests/RunCMake/project/VersionMax-stderr.txt b/Tests/RunCMake/project/VersionMax-stderr.txt
new file mode 100644
index 0000000..b789640
--- /dev/null
+++ b/Tests/RunCMake/project/VersionMax-stderr.txt
@@ -0,0 +1,10 @@
+^CMake Deprecation Warning at VersionMax.cmake:[0-9]+ \(cmake_policy\):
+ The OLD behavior for policy CMP0096 will be removed from a future version
+ of CMake.
+
+ The cmake-policies\(7\) manual explains that the OLD behaviors of all
+ policies are deprecated and that a policy should be set to OLD only under
+ specific short-term circumstances. Projects should be ported to the NEW
+ behavior and not rely on setting a policy to OLD.
+Call Stack \(most recent call first\):
+ CMakeLists.txt:[0-9]+ \(include\)$
diff --git a/Tests/RunCMake/target_link_libraries-LINK_GROUP/CMakeLists.txt b/Tests/RunCMake/target_link_libraries-LINK_GROUP/CMakeLists.txt
new file mode 100644
index 0000000..915fc41
--- /dev/null
+++ b/Tests/RunCMake/target_link_libraries-LINK_GROUP/CMakeLists.txt
@@ -0,0 +1,3 @@
+cmake_minimum_required(VERSION 3.1...3.22)
+project(${RunCMake_TEST} NONE)
+include(${RunCMake_TEST}.cmake NO_POLICY_SCOPE)
diff --git a/Tests/RunCMake/target_link_libraries-LINK_GROUP/LINK_GROUP-group-and-single-check.cmake b/Tests/RunCMake/target_link_libraries-LINK_GROUP/LINK_GROUP-group-and-single-check.cmake
new file mode 100644
index 0000000..3b8f3ba
--- /dev/null
+++ b/Tests/RunCMake/target_link_libraries-LINK_GROUP/LINK_GROUP-group-and-single-check.cmake
@@ -0,0 +1,4 @@
+
+if (NOT actual_stdout MATCHES "(/|-)-START_GROUP\"? +.*${LINK_SHARED_LIBRARY_PREFIX}base1${LINK_SHARED_LIBRARY_SUFFIX} +.*${LINK_SHARED_LIBRARY_PREFIX}base3${LINK_SHARED_LIBRARY_SUFFIX} +\"?(/|-)-END_GROUP\"? +.*${LINK_SHARED_LIBRARY_PREFIX}base5${LINK_SHARED_LIBRARY_SUFFIX} +\"?(/|-)-START_GROUP\"? +.*${LINK_SHARED_LIBRARY_PREFIX}base1${LINK_SHARED_LIBRARY_SUFFIX} +.*${LINK_SHARED_LIBRARY_PREFIX}base3${LINK_SHARED_LIBRARY_SUFFIX} +\"?(/|-)-END_GROUP")
+ set (RunCMake_TEST_FAILED "Not found expected '--START_GROUP <base1> <base3> --END_GROUP <base5> --START_GROUP <base1> <base3> --END_GROUP'.")
+endif()
diff --git a/Tests/RunCMake/target_link_libraries-LINK_GROUP/LINK_GROUP-group-and-single-result.txt b/Tests/RunCMake/target_link_libraries-LINK_GROUP/LINK_GROUP-group-and-single-result.txt
new file mode 100644
index 0000000..8d98f9d
--- /dev/null
+++ b/Tests/RunCMake/target_link_libraries-LINK_GROUP/LINK_GROUP-group-and-single-result.txt
@@ -0,0 +1 @@
+.*
diff --git a/Tests/RunCMake/target_link_libraries-LINK_GROUP/LINK_GROUP-multiple-groups-check.cmake b/Tests/RunCMake/target_link_libraries-LINK_GROUP/LINK_GROUP-multiple-groups-check.cmake
new file mode 100644
index 0000000..97732a5
--- /dev/null
+++ b/Tests/RunCMake/target_link_libraries-LINK_GROUP/LINK_GROUP-multiple-groups-check.cmake
@@ -0,0 +1,4 @@
+
+if (NOT actual_stdout MATCHES "(/|-)-START_GROUP\"? +.*${LINK_SHARED_LIBRARY_PREFIX}base2${LINK_SHARED_LIBRARY_SUFFIX} +.*${LINK_SHARED_LIBRARY_PREFIX}base4${LINK_SHARED_LIBRARY_SUFFIX} +\"?(/|-)-END_GROUP\"? +\"?(/|-)-START_GROUP\"? +.*${LINK_SHARED_LIBRARY_PREFIX}base1${LINK_SHARED_LIBRARY_SUFFIX} +.*${LINK_SHARED_LIBRARY_PREFIX}base2${LINK_SHARED_LIBRARY_SUFFIX} +\"?(/|-)-END_GROUP")
+ set (RunCMake_TEST_FAILED "Not found expected '--START_GROUP <base2> <base4> --END_GROUP --START_GROUP <base1> <base2> --END_GROUP'.")
+endif()
diff --git a/Tests/RunCMake/target_link_libraries-LINK_GROUP/LINK_GROUP-multiple-groups-result.txt b/Tests/RunCMake/target_link_libraries-LINK_GROUP/LINK_GROUP-multiple-groups-result.txt
new file mode 100644
index 0000000..8d98f9d
--- /dev/null
+++ b/Tests/RunCMake/target_link_libraries-LINK_GROUP/LINK_GROUP-multiple-groups-result.txt
@@ -0,0 +1 @@
+.*
diff --git a/Tests/RunCMake/target_link_libraries-LINK_GROUP/LINK_GROUP-simple1-check.cmake b/Tests/RunCMake/target_link_libraries-LINK_GROUP/LINK_GROUP-simple1-check.cmake
new file mode 100644
index 0000000..3e53d26
--- /dev/null
+++ b/Tests/RunCMake/target_link_libraries-LINK_GROUP/LINK_GROUP-simple1-check.cmake
@@ -0,0 +1,4 @@
+
+if (NOT actual_stdout MATCHES "(/|-)-START_GROUP\"? +.*${LINK_SHARED_LIBRARY_PREFIX}base1${LINK_SHARED_LIBRARY_SUFFIX} +.*${LINK_SHARED_LIBRARY_PREFIX}base2${LINK_SHARED_LIBRARY_SUFFIX} +\"?(/|-)-END_GROUP")
+ set (RunCMake_TEST_FAILED "Not found expected '--START_GROUP <base1> <base2> --END_GROUP'.")
+endif()
diff --git a/Tests/RunCMake/target_link_libraries-LINK_GROUP/LINK_GROUP-simple1-result.txt b/Tests/RunCMake/target_link_libraries-LINK_GROUP/LINK_GROUP-simple1-result.txt
new file mode 100644
index 0000000..8d98f9d
--- /dev/null
+++ b/Tests/RunCMake/target_link_libraries-LINK_GROUP/LINK_GROUP-simple1-result.txt
@@ -0,0 +1 @@
+.*
diff --git a/Tests/RunCMake/target_link_libraries-LINK_GROUP/LINK_GROUP-simple2-check.cmake b/Tests/RunCMake/target_link_libraries-LINK_GROUP/LINK_GROUP-simple2-check.cmake
new file mode 100644
index 0000000..475a0e2
--- /dev/null
+++ b/Tests/RunCMake/target_link_libraries-LINK_GROUP/LINK_GROUP-simple2-check.cmake
@@ -0,0 +1,4 @@
+
+if (NOT actual_stdout MATCHES "(/|-)-START_GROUP\"? +.*${LINK_SHARED_LIBRARY_PREFIX}base2${LINK_SHARED_LIBRARY_SUFFIX} +.*${LINK_SHARED_LIBRARY_PREFIX}base3${LINK_SHARED_LIBRARY_SUFFIX} +\"?(/|-)-END_GROUP\"? +.*${LINK_SHARED_LIBRARY_PREFIX}base1${LINK_SHARED_LIBRARY_SUFFIX}")
+ set (RunCMake_TEST_FAILED "Not found expected '--START_GROUP <base2> <base3> --END_GROUP <base1>'.")
+endif()
diff --git a/Tests/RunCMake/target_link_libraries-LINK_GROUP/LINK_GROUP-simple2-result.txt b/Tests/RunCMake/target_link_libraries-LINK_GROUP/LINK_GROUP-simple2-result.txt
new file mode 100644
index 0000000..8d98f9d
--- /dev/null
+++ b/Tests/RunCMake/target_link_libraries-LINK_GROUP/LINK_GROUP-simple2-result.txt
@@ -0,0 +1 @@
+.*
diff --git a/Tests/RunCMake/target_link_libraries-LINK_GROUP/LINK_GROUP-with-LINK_LIBRARY-check.cmake b/Tests/RunCMake/target_link_libraries-LINK_GROUP/LINK_GROUP-with-LINK_LIBRARY-check.cmake
new file mode 100644
index 0000000..2b2460e
--- /dev/null
+++ b/Tests/RunCMake/target_link_libraries-LINK_GROUP/LINK_GROUP-with-LINK_LIBRARY-check.cmake
@@ -0,0 +1,4 @@
+
+if (NOT actual_stdout MATCHES "(/|-)-START_GROUP\"? +\"?(/|-)-LIBFLAG.*${LINK_SHARED_LIBRARY_PREFIX}base1${LINK_SHARED_LIBRARY_SUFFIX}\"? +.*${LINK_SHARED_LIBRARY_PREFIX}base2${LINK_SHARED_LIBRARY_SUFFIX} +\"?(/|-)-END_GROUP")
+ set (RunCMake_TEST_FAILED "Not found expected '--START_GROUP --LIBFLAG<base1> <base2> --END_GROUP'.")
+endif()
diff --git a/Tests/RunCMake/target_link_libraries-LINK_GROUP/LINK_GROUP-with-LINK_LIBRARY-result.txt b/Tests/RunCMake/target_link_libraries-LINK_GROUP/LINK_GROUP-with-LINK_LIBRARY-result.txt
new file mode 100644
index 0000000..8d98f9d
--- /dev/null
+++ b/Tests/RunCMake/target_link_libraries-LINK_GROUP/LINK_GROUP-with-LINK_LIBRARY-result.txt
@@ -0,0 +1 @@
+.*
diff --git a/Tests/RunCMake/target_link_libraries-LINK_GROUP/LINK_GROUP-with-LINK_LIBRARY_OVERRIDE-check.cmake b/Tests/RunCMake/target_link_libraries-LINK_GROUP/LINK_GROUP-with-LINK_LIBRARY_OVERRIDE-check.cmake
new file mode 100644
index 0000000..5ef830c
--- /dev/null
+++ b/Tests/RunCMake/target_link_libraries-LINK_GROUP/LINK_GROUP-with-LINK_LIBRARY_OVERRIDE-check.cmake
@@ -0,0 +1,4 @@
+
+if (NOT actual_stdout MATCHES "(/|-)-START_GROUP\"? +\"?(/|-)-LIBFLAG.*${LINK_SHARED_LIBRARY_PREFIX}base1${LINK_SHARED_LIBRARY_SUFFIX}\"? +\"?(/|-)-LIBFLAG.*${LINK_SHARED_LIBRARY_PREFIX}base3${LINK_SHARED_LIBRARY_SUFFIX}\"? +.*${LINK_SHARED_LIBRARY_PREFIX}base2${LINK_SHARED_LIBRARY_SUFFIX} +\"?(/|-)-END_GROUP")
+ set (RunCMake_TEST_FAILED "Not found expected '--START_GROUP --LIBFLAG<base1> --LIBFLAG<base3> <base2> --END_GROUP'.")
+endif()
diff --git a/Tests/RunCMake/target_link_libraries-LINK_GROUP/LINK_GROUP-with-LINK_LIBRARY_OVERRIDE-result.txt b/Tests/RunCMake/target_link_libraries-LINK_GROUP/LINK_GROUP-with-LINK_LIBRARY_OVERRIDE-result.txt
new file mode 100644
index 0000000..8d98f9d
--- /dev/null
+++ b/Tests/RunCMake/target_link_libraries-LINK_GROUP/LINK_GROUP-with-LINK_LIBRARY_OVERRIDE-result.txt
@@ -0,0 +1 @@
+.*
diff --git a/Tests/RunCMake/target_link_libraries-LINK_GROUP/LINK_GROUP.cmake b/Tests/RunCMake/target_link_libraries-LINK_GROUP/LINK_GROUP.cmake
new file mode 100644
index 0000000..d08db16
--- /dev/null
+++ b/Tests/RunCMake/target_link_libraries-LINK_GROUP/LINK_GROUP.cmake
@@ -0,0 +1,52 @@
+enable_language(C)
+
+# ensure command line is always displayed and do not use any response file
+set(CMAKE_VERBOSE_MAKEFILE TRUE)
+set(CMAKE_C_USE_RESPONSE_FILE_FOR_LIBRARIES FALSE)
+
+if (CMAKE_GENERATOR MATCHES "Borland|NMake")
+ string(REPLACE "${CMAKE_START_TEMP_FILE}" "" CMAKE_C_CREATE_SHARED_LIBRARY "${CMAKE_C_CREATE_SHARED_LIBRARY}")
+ string(REPLACE "${CMAKE_END_TEMP_FILE}" "" CMAKE_C_CREATE_SHARED_LIBRARY "${CMAKE_C_CREATE_SHARED_LIBRARY}")
+endif()
+
+
+add_library(base1 SHARED base.c)
+add_library(base2 SHARED base.c)
+
+
+set(CMAKE_C_LINK_GROUP_USING_feat1 "--START_GROUP" "--END_GROUP")
+set(CMAKE_C_LINK_GROUP_USING_feat1_SUPPORTED TRUE)
+
+set(CMAKE_C_LINK_LIBRARY_USING_feat1 "--LIBFLAG<LIBRARY>")
+set(CMAKE_C_LINK_LIBRARY_USING_feat1_SUPPORTED TRUE)
+
+
+add_library(LinkGroup_simple1 SHARED lib.c)
+target_link_libraries(LinkGroup_simple1 PRIVATE "$<LINK_GROUP:feat1,base1,base2>")
+
+
+add_library(base3 SHARED base.c)
+target_link_libraries(base3 PUBLIC base1)
+add_library(LinkGroup_simple2 SHARED lib.c)
+target_link_libraries(LinkGroup_simple2 PRIVATE "$<LINK_GROUP:feat1,base2,base3>")
+
+
+add_library(base4 SHARED base.c)
+target_link_libraries(base4 INTERFACE "$<LINK_GROUP:feat1,base1,base2>")
+add_library(LinkGroup_multiple-groups SHARED lib.c)
+target_link_libraries(LinkGroup_multiple-groups PRIVATE "$<LINK_GROUP:feat1,base2,base4>")
+
+
+add_library(base5 SHARED base.c)
+target_link_libraries(base5 PUBLIC base1)
+add_library(LinkGroup_group-and-single SHARED lib.c)
+target_link_libraries(LinkGroup_group-and-single PRIVATE "$<LINK_GROUP:feat1,base1,base3>" base5)
+
+
+add_library(LinkGroup_with-LINK_LIBRARY SHARED lib.c)
+target_link_libraries(LinkGroup_with-LINK_LIBRARY PRIVATE "$<LINK_GROUP:feat1,$<LINK_LIBRARY:feat1,base1>,base2>")
+
+
+add_library(LinkGroup_with-LINK_LIBRARY_OVERRIDE SHARED lib.c)
+target_link_libraries(LinkGroup_with-LINK_LIBRARY_OVERRIDE PRIVATE "$<LINK_GROUP:feat1,$<LINK_LIBRARY:feat1,base1,base3>,base2>")
+set_property(TARGET LinkGroup_with-LINK_LIBRARY_OVERRIDE PROPERTY LINK_LIBRARY_OVERRIDE_base1 feat1)
diff --git a/Tests/RunCMake/target_link_libraries-LINK_GROUP/RunCMakeTest.cmake b/Tests/RunCMake/target_link_libraries-LINK_GROUP/RunCMakeTest.cmake
new file mode 100644
index 0000000..8307bb2
--- /dev/null
+++ b/Tests/RunCMake/target_link_libraries-LINK_GROUP/RunCMakeTest.cmake
@@ -0,0 +1,71 @@
+
+include(RunCMake)
+
+cmake_policy(SET CMP0054 NEW)
+
+macro(run_cmake_target test subtest target)
+ set(RunCMake_TEST_BINARY_DIR ${RunCMake_BINARY_DIR}/${test}-build)
+ set(RunCMake_TEST_NO_CLEAN 1)
+ run_cmake_command(${test}-${subtest} ${CMAKE_COMMAND} --build . --target ${target} --config Release --verbose ${ARGN})
+
+ unset(RunCMake_TEST_BINARY_DIR)
+ unset(RunCMake_TEST_NO_CLEAN)
+endmacro()
+
+
+# Some environments are excluded because they are not able to honor verbose mode
+if ((RunCMake_GENERATOR MATCHES "Makefiles|Ninja|Xcode"
+ OR (RunCMake_GENERATOR MATCHES "Visual Studio" AND MSVC_VERSION GREATER_EQUAL "1600"))
+ AND NOT CMAKE_C_COMPILER_ID STREQUAL "Intel")
+
+ set(RunCMake_TEST_OUTPUT_MERGE TRUE)
+ if (NOT RunCMake_GENERATOR_IS_MULTI_CONFIG)
+ set(RunCMake_TEST_OPTIONS -DCMAKE_BUILD_TYPE=Release)
+ endif()
+
+ if (CMAKE_SYSTEM_NAME STREQUAL "Windows"
+ OR CMAKE_SYSTEM_NAME STREQUAL "CYGWIN"
+ OR CMAKE_SYSTEM_NAME STREQUAL "MSYS")
+ set(LINK_SHARED_LIBRARY_PREFIX ${CMAKE_IMPORT_LIBRARY_PREFIX})
+ set(LINK_SHARED_LIBRARY_SUFFIX ${CMAKE_IMPORT_LIBRARY_SUFFIX})
+ else()
+ set(LINK_SHARED_LIBRARY_PREFIX ${CMAKE_SHARED_LIBRARY_PREFIX})
+ set(LINK_SHARED_LIBRARY_SUFFIX ${CMAKE_SHARED_LIBRARY_SUFFIX})
+ endif()
+ if (MINGW OR MSYS OR CYGWIN)
+ set(LINK_EXTERN_LIBRARY_SUFFIX "")
+ else()
+ set(LINK_EXTERN_LIBRARY_SUFFIX "${CMAKE_IMPORT_LIBRARY_SUFFIX}")
+ endif()
+
+ run_cmake(LINK_GROUP)
+
+ run_cmake_target(LINK_GROUP simple1 LinkGroup_simple1)
+ run_cmake_target(LINK_GROUP simple2 LinkGroup_simple2)
+ run_cmake_target(LINK_GROUP multiple-groups LinkGroup_multiple-groups)
+ run_cmake_target(LINK_GROUP group-and-single LinkGroup_group-and-single)
+ run_cmake_target(LINK_GROUP with-LINK_LIBRARY LinkGroup_with-LINK_LIBRARY)
+ run_cmake_target(LINK_GROUP with-LINK_LIBRARY_OVERRIDE LinkGroup_with-LINK_LIBRARY_OVERRIDE)
+
+ run_cmake(imported-target)
+
+ # tests using features as described in the documentation
+ if((CMAKE_C_COMPILER_ID STREQUAL "GNU" AND CMAKE_SYSTEM_NAME STREQUAL "Linux")
+ OR (CMAKE_C_COMPILER_ID STREQUAL "SunPro" AND CMAKE_C_COMPILER_VERSION VERSION_GREATER "5.9"
+ AND CMAKE_SYSTEM_NAME STREQUAL "SunOS"))
+ run_cmake(cross_refs)
+ run_cmake_target(cross_refs link main)
+ endif()
+
+ unset(RunCMake_TEST_OPTIONS)
+ unset(RunCMake_TEST_OUTPUT_MERGE)
+
+endif()
+
+# Feature RESCAN
+if (CMAKE_SYSTEM_NAME STREQUAL "Linux"
+ OR (CMAKE_SYSTEM_NAME STREQUAL "SunOS" AND (NOT CMAKE_C_COMPILER_ID STREQUAL "SunPro" OR CMAKE_C_COMPILER_VERSION VERSION_GREATER "5.9"))
+ OR (WIN32 AND CMAKE_C_COMPILER_ID STREQUAL "GNU"))
+ run_cmake(rescan)
+ run_cmake_target(rescan link main)
+endif()
diff --git a/Tests/RunCMake/target_link_libraries-LINK_GROUP/base.c b/Tests/RunCMake/target_link_libraries-LINK_GROUP/base.c
new file mode 100644
index 0000000..a5075d4
--- /dev/null
+++ b/Tests/RunCMake/target_link_libraries-LINK_GROUP/base.c
@@ -0,0 +1,9 @@
+
+#if !defined(STATIC_BASE)
+# if defined(_WIN32)
+__declspec(dllexport)
+# endif
+#endif
+ void base()
+{
+}
diff --git a/Tests/RunCMake/target_link_libraries-LINK_GROUP/cross_refs.cmake b/Tests/RunCMake/target_link_libraries-LINK_GROUP/cross_refs.cmake
new file mode 100644
index 0000000..f5f7857
--- /dev/null
+++ b/Tests/RunCMake/target_link_libraries-LINK_GROUP/cross_refs.cmake
@@ -0,0 +1,22 @@
+
+enable_language(C)
+
+set(CMAKE_C_LINK_GROUP_USING_cross_refs_SUPPORTED TRUE)
+if(CMAKE_C_COMPILER_ID STREQUAL "GNU"
+ AND CMAKE_SYSTEM_NAME STREQUAL "Linux")
+set(CMAKE_C_LINK_GROUP_USING_cross_refs "LINKER:--start-group"
+ "LINKER:--end-group")
+elseif(CMAKE_C_COMPILER_ID STREQUAL "SunPro"
+ AND CMAKE_SYSTEM_NAME STREQUAL "SunOS")
+ set(CMAKE_C_LINK_GROUP_USING_cross_refs "LINKER:-z,rescan-start"
+ "LINKER:-z,rescan-end")
+else()
+ # feature not yet supported for the other environments
+ set(CMAKE_C_LINK_GROUP_USING_cross_refs_SUPPORTED FALSE)
+endif()
+
+add_library(func1 STATIC func1.c func3.c)
+add_library(func2 STATIC func2.c)
+
+add_executable(main main.c)
+target_link_libraries(main PRIVATE "$<LINK_GROUP:cross_refs,func1,func2>")
diff --git a/Tests/RunCMake/target_link_libraries-LINK_GROUP/func1.c b/Tests/RunCMake/target_link_libraries-LINK_GROUP/func1.c
new file mode 100644
index 0000000..3399e00
--- /dev/null
+++ b/Tests/RunCMake/target_link_libraries-LINK_GROUP/func1.c
@@ -0,0 +1,7 @@
+
+extern void func2();
+
+void func1()
+{
+ func2();
+}
diff --git a/Tests/RunCMake/target_link_libraries-LINK_GROUP/func2.c b/Tests/RunCMake/target_link_libraries-LINK_GROUP/func2.c
new file mode 100644
index 0000000..0f9aa64
--- /dev/null
+++ b/Tests/RunCMake/target_link_libraries-LINK_GROUP/func2.c
@@ -0,0 +1,7 @@
+
+extern void func3();
+
+void func2()
+{
+ func3();
+}
diff --git a/Tests/RunCMake/target_link_libraries-LINK_GROUP/func3.c b/Tests/RunCMake/target_link_libraries-LINK_GROUP/func3.c
new file mode 100644
index 0000000..0b7df64
--- /dev/null
+++ b/Tests/RunCMake/target_link_libraries-LINK_GROUP/func3.c
@@ -0,0 +1,6 @@
+
+extern void func3();
+
+void func3()
+{
+}
diff --git a/Tests/RunCMake/target_link_libraries-LINK_GROUP/imported-target-result.txt b/Tests/RunCMake/target_link_libraries-LINK_GROUP/imported-target-result.txt
new file mode 100644
index 0000000..d00491f
--- /dev/null
+++ b/Tests/RunCMake/target_link_libraries-LINK_GROUP/imported-target-result.txt
@@ -0,0 +1 @@
+1
diff --git a/Tests/RunCMake/target_link_libraries-LINK_GROUP/imported-target-stdout.txt b/Tests/RunCMake/target_link_libraries-LINK_GROUP/imported-target-stdout.txt
new file mode 100644
index 0000000..16b93d1
--- /dev/null
+++ b/Tests/RunCMake/target_link_libraries-LINK_GROUP/imported-target-stdout.txt
@@ -0,0 +1,16 @@
+CMake Warning \(dev\) at imported-target.cmake:[0-9]+ \(add_library\):
+ The 'IMPORTED' target 'NS::lib2' uses the generator-expression
+ '\$<LINK_GROUP>' with the feature 'feat', which is undefined or unsupported.
+
+ Did you miss to define it by setting variables
+ "CMAKE_C_LINK_GROUP_USING_feat" and
+ "CMAKE_C_LINK_GROUP_USING_feat_SUPPORTED"\?
+Call Stack \(most recent call first\):
+ CMakeLists.txt:[0-9]+ \(include\)
+This warning is for project developers. Use -Wno-dev to suppress it.
+
+CMake Error at imported-target.cmake:[0-9]+ \(add_library\):
+ Feature 'feat', specified through generator-expression '\$<LINK_GROUP>' to
+ link target 'lib', is not supported for the 'C' link language.
+Call Stack \(most recent call first\):
+ CMakeLists.txt:[0-9]+ \(include\)
diff --git a/Tests/RunCMake/target_link_libraries-LINK_GROUP/imported-target.cmake b/Tests/RunCMake/target_link_libraries-LINK_GROUP/imported-target.cmake
new file mode 100644
index 0000000..bd83f97
--- /dev/null
+++ b/Tests/RunCMake/target_link_libraries-LINK_GROUP/imported-target.cmake
@@ -0,0 +1,22 @@
+
+enable_language(C)
+
+# Create imported target NS::lib
+add_library(NS::lib STATIC IMPORTED)
+set_target_properties(NS::lib PROPERTIES
+ IMPORTED_LOCATION "/path/to/lib"
+ IMPORTED_IMPLIB "/path/to/import.lib"
+)
+
+# Create imported target NS::lib2
+add_library(NS::lib2 SHARED IMPORTED)
+
+set_target_properties(NS::lib2 PROPERTIES
+ IMPORTED_LOCATION "/path/to/lib"
+ IMPORTED_IMPLIB "/path/to/import.lib"
+ INTERFACE_LINK_LIBRARIES "$<LINK_GROUP:feat,NS::lib>"
+)
+
+
+add_library(lib SHARED lib.c)
+target_link_libraries(lib PRIVATE NS::lib2)
diff --git a/Tests/RunCMake/target_link_libraries-LINK_GROUP/lib.c b/Tests/RunCMake/target_link_libraries-LINK_GROUP/lib.c
new file mode 100644
index 0000000..35ab367
--- /dev/null
+++ b/Tests/RunCMake/target_link_libraries-LINK_GROUP/lib.c
@@ -0,0 +1,15 @@
+
+#if !defined(STATIC_BASE)
+# if defined(_WIN32)
+__declspec(dllimport)
+# endif
+#endif
+ void base();
+
+#if defined(_WIN32)
+__declspec(dllexport)
+#endif
+ void lib()
+{
+ base();
+}
diff --git a/Tests/RunCMake/target_link_libraries-LINK_GROUP/main.c b/Tests/RunCMake/target_link_libraries-LINK_GROUP/main.c
new file mode 100644
index 0000000..403583d
--- /dev/null
+++ b/Tests/RunCMake/target_link_libraries-LINK_GROUP/main.c
@@ -0,0 +1,7 @@
+
+extern void func1();
+
+int main()
+{
+ func1();
+}
diff --git a/Tests/RunCMake/target_link_libraries-LINK_GROUP/rescan.cmake b/Tests/RunCMake/target_link_libraries-LINK_GROUP/rescan.cmake
new file mode 100644
index 0000000..810b892
--- /dev/null
+++ b/Tests/RunCMake/target_link_libraries-LINK_GROUP/rescan.cmake
@@ -0,0 +1,9 @@
+
+enable_language(C)
+
+# Feature RESCAN
+add_library(static1 STATIC func1.c func3.c)
+add_library(static2 STATIC func2.c)
+
+add_executable(main main.c)
+target_link_libraries(main PRIVATE "$<LINK_GROUP:RESCAN,static1,static2>")
diff --git a/Tests/RunCMake/target_link_libraries-LINK_LIBRARY/CMakeLists.txt b/Tests/RunCMake/target_link_libraries-LINK_LIBRARY/CMakeLists.txt
new file mode 100644
index 0000000..915fc41
--- /dev/null
+++ b/Tests/RunCMake/target_link_libraries-LINK_LIBRARY/CMakeLists.txt
@@ -0,0 +1,3 @@
+cmake_minimum_required(VERSION 3.1...3.22)
+project(${RunCMake_TEST} NONE)
+include(${RunCMake_TEST}.cmake NO_POLICY_SCOPE)
diff --git a/Tests/RunCMake/target_link_libraries-LINK_LIBRARY/External/CMakeLists.txt b/Tests/RunCMake/target_link_libraries-LINK_LIBRARY/External/CMakeLists.txt
new file mode 100644
index 0000000..212741a
--- /dev/null
+++ b/Tests/RunCMake/target_link_libraries-LINK_LIBRARY/External/CMakeLists.txt
@@ -0,0 +1,6 @@
+
+cmake_minimum_required(VERSION 3.23)
+
+project(External LANGUAGES C)
+
+add_library(external SHARED ../unref.c)
diff --git a/Tests/RunCMake/target_link_libraries-LINK_LIBRARY/LINK_LIBRARY-group1-check.cmake b/Tests/RunCMake/target_link_libraries-LINK_LIBRARY/LINK_LIBRARY-group1-check.cmake
new file mode 100644
index 0000000..255c9a6
--- /dev/null
+++ b/Tests/RunCMake/target_link_libraries-LINK_LIBRARY/LINK_LIBRARY-group1-check.cmake
@@ -0,0 +1,4 @@
+
+if (NOT actual_stdout MATCHES "(/|-)-LIBFLAG.*${LINK_SHARED_LIBRARY_PREFIX}base1${LINK_SHARED_LIBRARY_SUFFIX}\"? +\"?(/|-)-LIBFLAG.*${LINK_SHARED_LIBRARY_PREFIX}base2${LINK_SHARED_LIBRARY_SUFFIX}")
+ set (RunCMake_TEST_FAILED "Not found expected '--LIBFLAG<base1> --LIBFLAG<base2>'.")
+endif()
diff --git a/Tests/RunCMake/target_link_libraries-LINK_LIBRARY/LINK_LIBRARY-group1-result.txt b/Tests/RunCMake/target_link_libraries-LINK_LIBRARY/LINK_LIBRARY-group1-result.txt
new file mode 100644
index 0000000..8d98f9d
--- /dev/null
+++ b/Tests/RunCMake/target_link_libraries-LINK_LIBRARY/LINK_LIBRARY-group1-result.txt
@@ -0,0 +1 @@
+.*
diff --git a/Tests/RunCMake/target_link_libraries-LINK_LIBRARY/LINK_LIBRARY-group2-check.cmake b/Tests/RunCMake/target_link_libraries-LINK_LIBRARY/LINK_LIBRARY-group2-check.cmake
new file mode 100644
index 0000000..a8e0da7
--- /dev/null
+++ b/Tests/RunCMake/target_link_libraries-LINK_LIBRARY/LINK_LIBRARY-group2-check.cmake
@@ -0,0 +1,4 @@
+
+if (NOT actual_stdout MATCHES "(/|-)-PREFIXGROUP\"? +\"?(/|-)-LIBGROUP.*${LINK_SHARED_LIBRARY_PREFIX}base1${LINK_SHARED_LIBRARY_SUFFIX}\"? +\"?(/|-)-LIBGROUP.*${LINK_SHARED_LIBRARY_PREFIX}base2${LINK_SHARED_LIBRARY_SUFFIX}\"? +\"?(/|-)-SUFFIXGROUP")
+ set (RunCMake_TEST_FAILED "Not found expected '--PREFIXGROUP --LIBGROUP<base1> --LIBGROUP<base2> --SUFFIXGROUP'.")
+endif()
diff --git a/Tests/RunCMake/target_link_libraries-LINK_LIBRARY/LINK_LIBRARY-group2-result.txt b/Tests/RunCMake/target_link_libraries-LINK_LIBRARY/LINK_LIBRARY-group2-result.txt
new file mode 100644
index 0000000..8d98f9d
--- /dev/null
+++ b/Tests/RunCMake/target_link_libraries-LINK_LIBRARY/LINK_LIBRARY-group2-result.txt
@@ -0,0 +1 @@
+.*
diff --git a/Tests/RunCMake/target_link_libraries-LINK_LIBRARY/LINK_LIBRARY-link-items1-check.cmake b/Tests/RunCMake/target_link_libraries-LINK_LIBRARY/LINK_LIBRARY-link-items1-check.cmake
new file mode 100644
index 0000000..54cef2c
--- /dev/null
+++ b/Tests/RunCMake/target_link_libraries-LINK_LIBRARY/LINK_LIBRARY-link-items1-check.cmake
@@ -0,0 +1,4 @@
+
+if (NOT actual_stdout MATCHES "(/|-)-PREFIXGROUP\"? +\"?.*${LINK_SHARED_LIBRARY_PREFIX}base1${LINK_SHARED_LIBRARY_SUFFIX}\"? +\"?${CMAKE_LINK_LIBRARY_FLAG}other${LINK_EXTERN_LIBRARY_SUFFIX}\"? +\"?(/|-)-SUFFIXGROUP")
+ set (RunCMake_TEST_FAILED "Not found expected '--PREFIXGROUP <base1> <other> --SUFFIXGROUP'.")
+endif()
diff --git a/Tests/RunCMake/target_link_libraries-LINK_LIBRARY/LINK_LIBRARY-link-items1-result.txt b/Tests/RunCMake/target_link_libraries-LINK_LIBRARY/LINK_LIBRARY-link-items1-result.txt
new file mode 100644
index 0000000..8d98f9d
--- /dev/null
+++ b/Tests/RunCMake/target_link_libraries-LINK_LIBRARY/LINK_LIBRARY-link-items1-result.txt
@@ -0,0 +1 @@
+.*
diff --git a/Tests/RunCMake/target_link_libraries-LINK_LIBRARY/LINK_LIBRARY-link-items2-check.cmake b/Tests/RunCMake/target_link_libraries-LINK_LIBRARY/LINK_LIBRARY-link-items2-check.cmake
new file mode 100644
index 0000000..7c38134
--- /dev/null
+++ b/Tests/RunCMake/target_link_libraries-LINK_LIBRARY/LINK_LIBRARY-link-items2-check.cmake
@@ -0,0 +1,4 @@
+
+if (NOT actual_stdout MATCHES "(/|-)-PREFIXGROUP\"? +\"?(/|-)-LIBGROUP.*${LINK_SHARED_LIBRARY_PREFIX}base1${LINK_SHARED_LIBRARY_SUFFIX}\"? +\"?(/|-)-LIBGROUPother${LINK_EXTERN_LIBRARY_SUFFIX}\"? +\"?(/|-)-SUFFIXGROUP")
+ set (RunCMake_TEST_FAILED "Not found expected '--PREFIXGROUP --LIBGROUP<base1> --LIBGROUP<other> --SUFFIXGROUP'.")
+endif()
diff --git a/Tests/RunCMake/target_link_libraries-LINK_LIBRARY/LINK_LIBRARY-link-items2-result.txt b/Tests/RunCMake/target_link_libraries-LINK_LIBRARY/LINK_LIBRARY-link-items2-result.txt
new file mode 100644
index 0000000..8d98f9d
--- /dev/null
+++ b/Tests/RunCMake/target_link_libraries-LINK_LIBRARY/LINK_LIBRARY-link-items2-result.txt
@@ -0,0 +1 @@
+.*
diff --git a/Tests/RunCMake/target_link_libraries-LINK_LIBRARY/LINK_LIBRARY-link-items3-check.cmake b/Tests/RunCMake/target_link_libraries-LINK_LIBRARY/LINK_LIBRARY-link-items3-check.cmake
new file mode 100644
index 0000000..88b5cf6
--- /dev/null
+++ b/Tests/RunCMake/target_link_libraries-LINK_LIBRARY/LINK_LIBRARY-link-items3-check.cmake
@@ -0,0 +1,4 @@
+
+if (NOT actual_stdout MATCHES "(/|-)-PREFIXGROUP\"? +\"?(/|-)-LIBFLAG.*${LINK_SHARED_LIBRARY_PREFIX}base1${LINK_SHARED_LIBRARY_SUFFIX}\"? +\"?(/|-)-ITEMFLAG.*${LINK_SHARED_LIBRARY_PREFIX}base1${LINK_SHARED_LIBRARY_SUFFIX}\"? +\"?(/|-)-LIBFLAGother${LINK_EXTERN_LIBRARY_SUFFIX}\"? +\"?(/|-)-ITEMFLAGother\"? +\"?(/|-)-SUFFIXGROUP")
+ set (RunCMake_TEST_FAILED "Not found expected '--PREFIXGROUP --LIBFLAG<base1> --ITEMFLAG<base1> --LIBFLAG<other> --ITEMFLAG<other> --SUFFIXGROUP'.")
+endif()
diff --git a/Tests/RunCMake/target_link_libraries-LINK_LIBRARY/LINK_LIBRARY-link-items3-result.txt b/Tests/RunCMake/target_link_libraries-LINK_LIBRARY/LINK_LIBRARY-link-items3-result.txt
new file mode 100644
index 0000000..8d98f9d
--- /dev/null
+++ b/Tests/RunCMake/target_link_libraries-LINK_LIBRARY/LINK_LIBRARY-link-items3-result.txt
@@ -0,0 +1 @@
+.*
diff --git a/Tests/RunCMake/target_link_libraries-LINK_LIBRARY/LINK_LIBRARY-link-items4-check.cmake b/Tests/RunCMake/target_link_libraries-LINK_LIBRARY/LINK_LIBRARY-link-items4-check.cmake
new file mode 100644
index 0000000..c473637
--- /dev/null
+++ b/Tests/RunCMake/target_link_libraries-LINK_LIBRARY/LINK_LIBRARY-link-items4-check.cmake
@@ -0,0 +1,4 @@
+
+if (NOT actual_stdout MATCHES "(/|-)-PREFIXGROUP\"? +\"?(/|-)-LIBFLAG.*${LINK_SHARED_LIBRARY_PREFIX}base1${LINK_SHARED_LIBRARY_SUFFIX}\"? +\"?(/|-)-ITEMFLAGother\"? +\"?(/|-)-SUFFIXGROUP")
+ set (RunCMake_TEST_FAILED "Not found expected '--PREFIXGROUP --LIBFLAG<base1> --ITEMFLAG<other> --SUFFIXGROUP'.")
+endif()
diff --git a/Tests/RunCMake/target_link_libraries-LINK_LIBRARY/LINK_LIBRARY-link-items4-result.txt b/Tests/RunCMake/target_link_libraries-LINK_LIBRARY/LINK_LIBRARY-link-items4-result.txt
new file mode 100644
index 0000000..8d98f9d
--- /dev/null
+++ b/Tests/RunCMake/target_link_libraries-LINK_LIBRARY/LINK_LIBRARY-link-items4-result.txt
@@ -0,0 +1 @@
+.*
diff --git a/Tests/RunCMake/target_link_libraries-LINK_LIBRARY/LINK_LIBRARY-mix-features1-check.cmake b/Tests/RunCMake/target_link_libraries-LINK_LIBRARY/LINK_LIBRARY-mix-features1-check.cmake
new file mode 100644
index 0000000..858dcfe
--- /dev/null
+++ b/Tests/RunCMake/target_link_libraries-LINK_LIBRARY/LINK_LIBRARY-mix-features1-check.cmake
@@ -0,0 +1,4 @@
+
+if (NOT actual_stdout MATCHES "(/|-)-PREFIXGROUP\"? +\"?(/|-)-LIBGROUP.*${LINK_SHARED_LIBRARY_PREFIX}base3${LINK_SHARED_LIBRARY_SUFFIX}\"? +\"?(/|-)-LIBGROUP.*${LINK_SHARED_LIBRARY_PREFIX}base1${LINK_SHARED_LIBRARY_SUFFIX}\"? +\"?(/|-)-SUFFIXGROUP")
+ set (RunCMake_TEST_FAILED "Not found expected '--PREFIXGROUP --LIBGROUP<base1> --LIBGROUP<base3> --SUFFIXGROUP'.")
+endif()
diff --git a/Tests/RunCMake/target_link_libraries-LINK_LIBRARY/LINK_LIBRARY-mix-features1-result.txt b/Tests/RunCMake/target_link_libraries-LINK_LIBRARY/LINK_LIBRARY-mix-features1-result.txt
new file mode 100644
index 0000000..8d98f9d
--- /dev/null
+++ b/Tests/RunCMake/target_link_libraries-LINK_LIBRARY/LINK_LIBRARY-mix-features1-result.txt
@@ -0,0 +1 @@
+.*
diff --git a/Tests/RunCMake/target_link_libraries-LINK_LIBRARY/LINK_LIBRARY-mix-features2-check.cmake b/Tests/RunCMake/target_link_libraries-LINK_LIBRARY/LINK_LIBRARY-mix-features2-check.cmake
new file mode 100644
index 0000000..ab06726
--- /dev/null
+++ b/Tests/RunCMake/target_link_libraries-LINK_LIBRARY/LINK_LIBRARY-mix-features2-check.cmake
@@ -0,0 +1,4 @@
+
+if (NOT actual_stdout MATCHES "(/|-)-PREFIXGROUP\"? +\"?(/|-)-LIBGROUP.*${LINK_SHARED_LIBRARY_PREFIX}base3${LINK_SHARED_LIBRARY_SUFFIX}\"? +\"?(/|-)-LIBGROUP.*${LINK_SHARED_LIBRARY_PREFIX}base1${LINK_SHARED_LIBRARY_SUFFIX}\"? +\"?(/|-)-SUFFIXGROUP")
+ set (RunCMake_TEST_FAILED "Not found expected '--PREFIXGROUP --LIBGROUP<base3> --LIBGROUP<base1> --SUFFIXGROUP'.")
+endif()
diff --git a/Tests/RunCMake/target_link_libraries-LINK_LIBRARY/LINK_LIBRARY-mix-features2-result.txt b/Tests/RunCMake/target_link_libraries-LINK_LIBRARY/LINK_LIBRARY-mix-features2-result.txt
new file mode 100644
index 0000000..8d98f9d
--- /dev/null
+++ b/Tests/RunCMake/target_link_libraries-LINK_LIBRARY/LINK_LIBRARY-mix-features2-result.txt
@@ -0,0 +1 @@
+.*
diff --git a/Tests/RunCMake/target_link_libraries-LINK_LIBRARY/LINK_LIBRARY-mix-features3-check.cmake b/Tests/RunCMake/target_link_libraries-LINK_LIBRARY/LINK_LIBRARY-mix-features3-check.cmake
new file mode 100644
index 0000000..62aa17c
--- /dev/null
+++ b/Tests/RunCMake/target_link_libraries-LINK_LIBRARY/LINK_LIBRARY-mix-features3-check.cmake
@@ -0,0 +1,4 @@
+
+if (NOT actual_stdout MATCHES "${LINK_SHARED_LIBRARY_PREFIX}base2${LINK_SHARED_LIBRARY_SUFFIX}\"? +\"?(/|-)-PREFIXGROUP\"? +\"?(/|-)-LIBGROUP.*${LINK_SHARED_LIBRARY_PREFIX}base3${LINK_SHARED_LIBRARY_SUFFIX}\"? +\"?(/|-)-SUFFIXGROUP\"? +\"?${CMAKE_LINK_LIBRARY_FLAG}other2${LINK_EXTERN_LIBRARY_SUFFIX}\"? +\"?(/|-)-PREFIXGROUP\"? +\"?(/|-)-LIBGROUP.*${LINK_SHARED_LIBRARY_PREFIX}base1${LINK_SHARED_LIBRARY_SUFFIX}\"? +\"?(/|-)-SUFFIXGROUP\"? +\"?${CMAKE_LINK_LIBRARY_FLAG}other1${LINK_EXTERN_LIBRARY_SUFFIX}")
+ set (RunCMake_TEST_FAILED "Not found expected '<base2> --PREFIXGROUP --LIBGROUP<base3> --SUFFIXGROUP <other2> --PREFIXGROUP --LIBGROUP<base1> --SUFFIXGROUP <other1>'.")
+endif()
diff --git a/Tests/RunCMake/target_link_libraries-LINK_LIBRARY/LINK_LIBRARY-mix-features3-result.txt b/Tests/RunCMake/target_link_libraries-LINK_LIBRARY/LINK_LIBRARY-mix-features3-result.txt
new file mode 100644
index 0000000..8d98f9d
--- /dev/null
+++ b/Tests/RunCMake/target_link_libraries-LINK_LIBRARY/LINK_LIBRARY-mix-features3-result.txt
@@ -0,0 +1 @@
+.*
diff --git a/Tests/RunCMake/target_link_libraries-LINK_LIBRARY/LINK_LIBRARY-nested-feature1-check.cmake b/Tests/RunCMake/target_link_libraries-LINK_LIBRARY/LINK_LIBRARY-nested-feature1-check.cmake
new file mode 100644
index 0000000..255c9a6
--- /dev/null
+++ b/Tests/RunCMake/target_link_libraries-LINK_LIBRARY/LINK_LIBRARY-nested-feature1-check.cmake
@@ -0,0 +1,4 @@
+
+if (NOT actual_stdout MATCHES "(/|-)-LIBFLAG.*${LINK_SHARED_LIBRARY_PREFIX}base1${LINK_SHARED_LIBRARY_SUFFIX}\"? +\"?(/|-)-LIBFLAG.*${LINK_SHARED_LIBRARY_PREFIX}base2${LINK_SHARED_LIBRARY_SUFFIX}")
+ set (RunCMake_TEST_FAILED "Not found expected '--LIBFLAG<base1> --LIBFLAG<base2>'.")
+endif()
diff --git a/Tests/RunCMake/target_link_libraries-LINK_LIBRARY/LINK_LIBRARY-nested-feature1-result.txt b/Tests/RunCMake/target_link_libraries-LINK_LIBRARY/LINK_LIBRARY-nested-feature1-result.txt
new file mode 100644
index 0000000..8d98f9d
--- /dev/null
+++ b/Tests/RunCMake/target_link_libraries-LINK_LIBRARY/LINK_LIBRARY-nested-feature1-result.txt
@@ -0,0 +1 @@
+.*
diff --git a/Tests/RunCMake/target_link_libraries-LINK_LIBRARY/LINK_LIBRARY-nested-feature2-check.cmake b/Tests/RunCMake/target_link_libraries-LINK_LIBRARY/LINK_LIBRARY-nested-feature2-check.cmake
new file mode 100644
index 0000000..a8e0da7
--- /dev/null
+++ b/Tests/RunCMake/target_link_libraries-LINK_LIBRARY/LINK_LIBRARY-nested-feature2-check.cmake
@@ -0,0 +1,4 @@
+
+if (NOT actual_stdout MATCHES "(/|-)-PREFIXGROUP\"? +\"?(/|-)-LIBGROUP.*${LINK_SHARED_LIBRARY_PREFIX}base1${LINK_SHARED_LIBRARY_SUFFIX}\"? +\"?(/|-)-LIBGROUP.*${LINK_SHARED_LIBRARY_PREFIX}base2${LINK_SHARED_LIBRARY_SUFFIX}\"? +\"?(/|-)-SUFFIXGROUP")
+ set (RunCMake_TEST_FAILED "Not found expected '--PREFIXGROUP --LIBGROUP<base1> --LIBGROUP<base2> --SUFFIXGROUP'.")
+endif()
diff --git a/Tests/RunCMake/target_link_libraries-LINK_LIBRARY/LINK_LIBRARY-nested-feature2-result.txt b/Tests/RunCMake/target_link_libraries-LINK_LIBRARY/LINK_LIBRARY-nested-feature2-result.txt
new file mode 100644
index 0000000..8d98f9d
--- /dev/null
+++ b/Tests/RunCMake/target_link_libraries-LINK_LIBRARY/LINK_LIBRARY-nested-feature2-result.txt
@@ -0,0 +1 @@
+.*
diff --git a/Tests/RunCMake/target_link_libraries-LINK_LIBRARY/LINK_LIBRARY-override-features1-check.cmake b/Tests/RunCMake/target_link_libraries-LINK_LIBRARY/LINK_LIBRARY-override-features1-check.cmake
new file mode 100644
index 0000000..a9fba20
--- /dev/null
+++ b/Tests/RunCMake/target_link_libraries-LINK_LIBRARY/LINK_LIBRARY-override-features1-check.cmake
@@ -0,0 +1,4 @@
+
+if (NOT actual_stdout MATCHES "(/|-)-LIBFLAG.*${LINK_SHARED_LIBRARY_PREFIX}base3${LINK_SHARED_LIBRARY_SUFFIX}\"? +\"?(/|-)-LIBFLAG.*${LINK_SHARED_LIBRARY_PREFIX}base1${LINK_SHARED_LIBRARY_SUFFIX}\"? +\"?${CMAKE_LINK_LIBRARY_FLAG}other1")
+ set (RunCMake_TEST_FAILED "Not found expected '--LIBFLAG<base3> --LIBFLAG<base1> <other1>'.")
+endif()
diff --git a/Tests/RunCMake/target_link_libraries-LINK_LIBRARY/LINK_LIBRARY-override-features1-result.txt b/Tests/RunCMake/target_link_libraries-LINK_LIBRARY/LINK_LIBRARY-override-features1-result.txt
new file mode 100644
index 0000000..8d98f9d
--- /dev/null
+++ b/Tests/RunCMake/target_link_libraries-LINK_LIBRARY/LINK_LIBRARY-override-features1-result.txt
@@ -0,0 +1 @@
+.*
diff --git a/Tests/RunCMake/target_link_libraries-LINK_LIBRARY/LINK_LIBRARY-override-features2-check.cmake b/Tests/RunCMake/target_link_libraries-LINK_LIBRARY/LINK_LIBRARY-override-features2-check.cmake
new file mode 100644
index 0000000..58c117e
--- /dev/null
+++ b/Tests/RunCMake/target_link_libraries-LINK_LIBRARY/LINK_LIBRARY-override-features2-check.cmake
@@ -0,0 +1,4 @@
+
+if (NOT actual_stdout MATCHES "(/|-)-LIBFLAG.*${LINK_SHARED_LIBRARY_PREFIX}base3${LINK_SHARED_LIBRARY_SUFFIX}\"? +\"?(/|-)-PREFIXGROUP\"? +\"?(/|-)-LIBGROUP.*${LINK_SHARED_LIBRARY_PREFIX}base1${LINK_SHARED_LIBRARY_SUFFIX}\"? +\"?(/|-)-LIBGROUPother1${LINK_EXTERN_LIBRARY_SUFFIX}\"? +\"?(/|-)-SUFFIXGROUP")
+ set (RunCMake_TEST_FAILED "Not found expected '--LIBFLAG<base3> --PREFIXGROUP --LIBGROUP<base1> --LIBGROUP<other1> --SUFFIXGROUP'.")
+endif()
diff --git a/Tests/RunCMake/target_link_libraries-LINK_LIBRARY/LINK_LIBRARY-override-features2-result.txt b/Tests/RunCMake/target_link_libraries-LINK_LIBRARY/LINK_LIBRARY-override-features2-result.txt
new file mode 100644
index 0000000..8d98f9d
--- /dev/null
+++ b/Tests/RunCMake/target_link_libraries-LINK_LIBRARY/LINK_LIBRARY-override-features2-result.txt
@@ -0,0 +1 @@
+.*
diff --git a/Tests/RunCMake/target_link_libraries-LINK_LIBRARY/LINK_LIBRARY-override-features3-check.cmake b/Tests/RunCMake/target_link_libraries-LINK_LIBRARY/LINK_LIBRARY-override-features3-check.cmake
new file mode 100644
index 0000000..a9fba20
--- /dev/null
+++ b/Tests/RunCMake/target_link_libraries-LINK_LIBRARY/LINK_LIBRARY-override-features3-check.cmake
@@ -0,0 +1,4 @@
+
+if (NOT actual_stdout MATCHES "(/|-)-LIBFLAG.*${LINK_SHARED_LIBRARY_PREFIX}base3${LINK_SHARED_LIBRARY_SUFFIX}\"? +\"?(/|-)-LIBFLAG.*${LINK_SHARED_LIBRARY_PREFIX}base1${LINK_SHARED_LIBRARY_SUFFIX}\"? +\"?${CMAKE_LINK_LIBRARY_FLAG}other1")
+ set (RunCMake_TEST_FAILED "Not found expected '--LIBFLAG<base3> --LIBFLAG<base1> <other1>'.")
+endif()
diff --git a/Tests/RunCMake/target_link_libraries-LINK_LIBRARY/LINK_LIBRARY-override-features3-result.txt b/Tests/RunCMake/target_link_libraries-LINK_LIBRARY/LINK_LIBRARY-override-features3-result.txt
new file mode 100644
index 0000000..8d98f9d
--- /dev/null
+++ b/Tests/RunCMake/target_link_libraries-LINK_LIBRARY/LINK_LIBRARY-override-features3-result.txt
@@ -0,0 +1 @@
+.*
diff --git a/Tests/RunCMake/target_link_libraries-LINK_LIBRARY/LINK_LIBRARY-override-features4-check.cmake b/Tests/RunCMake/target_link_libraries-LINK_LIBRARY/LINK_LIBRARY-override-features4-check.cmake
new file mode 100644
index 0000000..58c117e
--- /dev/null
+++ b/Tests/RunCMake/target_link_libraries-LINK_LIBRARY/LINK_LIBRARY-override-features4-check.cmake
@@ -0,0 +1,4 @@
+
+if (NOT actual_stdout MATCHES "(/|-)-LIBFLAG.*${LINK_SHARED_LIBRARY_PREFIX}base3${LINK_SHARED_LIBRARY_SUFFIX}\"? +\"?(/|-)-PREFIXGROUP\"? +\"?(/|-)-LIBGROUP.*${LINK_SHARED_LIBRARY_PREFIX}base1${LINK_SHARED_LIBRARY_SUFFIX}\"? +\"?(/|-)-LIBGROUPother1${LINK_EXTERN_LIBRARY_SUFFIX}\"? +\"?(/|-)-SUFFIXGROUP")
+ set (RunCMake_TEST_FAILED "Not found expected '--LIBFLAG<base3> --PREFIXGROUP --LIBGROUP<base1> --LIBGROUP<other1> --SUFFIXGROUP'.")
+endif()
diff --git a/Tests/RunCMake/target_link_libraries-LINK_LIBRARY/LINK_LIBRARY-override-features4-result.txt b/Tests/RunCMake/target_link_libraries-LINK_LIBRARY/LINK_LIBRARY-override-features4-result.txt
new file mode 100644
index 0000000..8d98f9d
--- /dev/null
+++ b/Tests/RunCMake/target_link_libraries-LINK_LIBRARY/LINK_LIBRARY-override-features4-result.txt
@@ -0,0 +1 @@
+.*
diff --git a/Tests/RunCMake/target_link_libraries-LINK_LIBRARY/LINK_LIBRARY-override-with-DEFAULT-check.cmake b/Tests/RunCMake/target_link_libraries-LINK_LIBRARY/LINK_LIBRARY-override-with-DEFAULT-check.cmake
new file mode 100644
index 0000000..d022f7e
--- /dev/null
+++ b/Tests/RunCMake/target_link_libraries-LINK_LIBRARY/LINK_LIBRARY-override-with-DEFAULT-check.cmake
@@ -0,0 +1,4 @@
+
+if (NOT actual_stdout MATCHES "(/|-)-LIBFLAG.*${LINK_SHARED_LIBRARY_PREFIX}base3${LINK_SHARED_LIBRARY_SUFFIX}\"? +\"?.*${LINK_SHARED_LIBRARY_PREFIX}base1${LINK_SHARED_LIBRARY_SUFFIX}\"? +\"?${CMAKE_LINK_LIBRARY_FLAG}other1${LINK_EXTERN_LIBRARY_SUFFIX}\"?")
+ set (RunCMake_TEST_FAILED "Not found expected '--LIBFLAG<base3> <base1> <other1>'.")
+endif()
diff --git a/Tests/RunCMake/target_link_libraries-LINK_LIBRARY/LINK_LIBRARY-override-with-DEFAULT-result.txt b/Tests/RunCMake/target_link_libraries-LINK_LIBRARY/LINK_LIBRARY-override-with-DEFAULT-result.txt
new file mode 100644
index 0000000..8d98f9d
--- /dev/null
+++ b/Tests/RunCMake/target_link_libraries-LINK_LIBRARY/LINK_LIBRARY-override-with-DEFAULT-result.txt
@@ -0,0 +1 @@
+.*
diff --git a/Tests/RunCMake/target_link_libraries-LINK_LIBRARY/LINK_LIBRARY-simple1-check.cmake b/Tests/RunCMake/target_link_libraries-LINK_LIBRARY/LINK_LIBRARY-simple1-check.cmake
new file mode 100644
index 0000000..32b58fe
--- /dev/null
+++ b/Tests/RunCMake/target_link_libraries-LINK_LIBRARY/LINK_LIBRARY-simple1-check.cmake
@@ -0,0 +1,4 @@
+
+if (NOT actual_stdout MATCHES "(/|-)-LIBFLAG.*${LINK_SHARED_LIBRARY_PREFIX}base1")
+ set (RunCMake_TEST_FAILED "Not found expected '--LIBFLAG<base1>'.")
+endif()
diff --git a/Tests/RunCMake/target_link_libraries-LINK_LIBRARY/LINK_LIBRARY-simple1-result.txt b/Tests/RunCMake/target_link_libraries-LINK_LIBRARY/LINK_LIBRARY-simple1-result.txt
new file mode 100644
index 0000000..8d98f9d
--- /dev/null
+++ b/Tests/RunCMake/target_link_libraries-LINK_LIBRARY/LINK_LIBRARY-simple1-result.txt
@@ -0,0 +1 @@
+.*
diff --git a/Tests/RunCMake/target_link_libraries-LINK_LIBRARY/LINK_LIBRARY-simple2-check.cmake b/Tests/RunCMake/target_link_libraries-LINK_LIBRARY/LINK_LIBRARY-simple2-check.cmake
new file mode 100644
index 0000000..32b58fe
--- /dev/null
+++ b/Tests/RunCMake/target_link_libraries-LINK_LIBRARY/LINK_LIBRARY-simple2-check.cmake
@@ -0,0 +1,4 @@
+
+if (NOT actual_stdout MATCHES "(/|-)-LIBFLAG.*${LINK_SHARED_LIBRARY_PREFIX}base1")
+ set (RunCMake_TEST_FAILED "Not found expected '--LIBFLAG<base1>'.")
+endif()
diff --git a/Tests/RunCMake/target_link_libraries-LINK_LIBRARY/LINK_LIBRARY-simple2-result.txt b/Tests/RunCMake/target_link_libraries-LINK_LIBRARY/LINK_LIBRARY-simple2-result.txt
new file mode 100644
index 0000000..8d98f9d
--- /dev/null
+++ b/Tests/RunCMake/target_link_libraries-LINK_LIBRARY/LINK_LIBRARY-simple2-result.txt
@@ -0,0 +1 @@
+.*
diff --git a/Tests/RunCMake/target_link_libraries-LINK_LIBRARY/LINK_LIBRARY.cmake b/Tests/RunCMake/target_link_libraries-LINK_LIBRARY/LINK_LIBRARY.cmake
new file mode 100644
index 0000000..1581611
--- /dev/null
+++ b/Tests/RunCMake/target_link_libraries-LINK_LIBRARY/LINK_LIBRARY.cmake
@@ -0,0 +1,104 @@
+enable_language(C)
+
+# ensure command line is always displayed and do not use any response file
+set(CMAKE_VERBOSE_MAKEFILE TRUE)
+set(CMAKE_C_USE_RESPONSE_FILE_FOR_LIBRARIES FALSE)
+
+if (CMAKE_GENERATOR MATCHES "Borland|NMake")
+ string(REPLACE "${CMAKE_START_TEMP_FILE}" "" CMAKE_C_CREATE_SHARED_LIBRARY "${CMAKE_C_CREATE_SHARED_LIBRARY}")
+ string(REPLACE "${CMAKE_END_TEMP_FILE}" "" CMAKE_C_CREATE_SHARED_LIBRARY "${CMAKE_C_CREATE_SHARED_LIBRARY}")
+endif()
+
+add_library(base1 SHARED base.c)
+add_library(base2 SHARED base.c)
+
+set(CMAKE_C_LINK_LIBRARY_USING_feat1 "--LIBFLAG<LIBRARY>")
+set(CMAKE_C_LINK_LIBRARY_USING_feat1_SUPPORTED TRUE)
+
+set(CMAKE_C_LINK_LIBRARY_USING_feat1_1 "--LIBFLAG_C<LIBRARY>")
+set(CMAKE_C_LINK_LIBRARY_USING_feat1_1_SUPPORTED FALSE)
+set(CMAKE_LINK_LIBRARY_USING_feat1_1 "--LIBFLAG<LIBRARY>")
+set(CMAKE_LINK_LIBRARY_USING_feat1_1_SUPPORTED TRUE)
+
+set(CMAKE_C_LINK_LIBRARY_USING_feat2 "--PREFIXGROUP" "--LIBGROUP<LIBRARY>" "--SUFFIXGROUP")
+set(CMAKE_C_LINK_LIBRARY_USING_feat2_SUPPORTED TRUE)
+
+set(CMAKE_C_LINK_LIBRARY_USING_feat3 "--PREFIXGROUP" "<LINK_ITEM>" "--SUFFIXGROUP")
+set(CMAKE_C_LINK_LIBRARY_USING_feat3_SUPPORTED TRUE)
+
+set(CMAKE_C_LINK_LIBRARY_USING_feat4 "--PREFIXGROUP" "--LIBFLAG<LIBRARY> --ITEMFLAG<LIB_ITEM>" "--SUFFIXGROUP")
+set(CMAKE_C_LINK_LIBRARY_USING_feat4_SUPPORTED TRUE)
+
+set(CMAKE_C_LINK_LIBRARY_USING_feat5 "--PREFIXGROUP" "PATH{--LIBFLAG<LIBRARY>}NAME{--ITEMFLAG<LIB_ITEM>}" "--SUFFIXGROUP")
+set(CMAKE_C_LINK_LIBRARY_USING_feat5_SUPPORTED TRUE)
+
+set(CMAKE_C_LINK_LIBRARY_USING_feat6 "<LINK_ITEM>")
+set(CMAKE_C_LINK_LIBRARY_USING_feat6_SUPPORTED TRUE)
+
+
+add_library(LinkLibrary_simple1 SHARED lib.c)
+target_link_libraries(LinkLibrary_simple1 PRIVATE "$<LINK_LIBRARY:feat1,base1>")
+
+add_library(LinkLibrary_simple2 SHARED lib.c)
+target_link_libraries(LinkLibrary_simple2 PRIVATE "$<LINK_LIBRARY:feat1_1,base1>")
+
+add_library(LinkLibrary_group1 SHARED lib.c)
+target_link_libraries(LinkLibrary_group1 PRIVATE "$<LINK_LIBRARY:feat1,base1,base2>")
+
+add_library(LinkLibrary_group2 SHARED lib.c)
+target_link_libraries(LinkLibrary_group2 PRIVATE "$<LINK_LIBRARY:feat2,base1,base2>")
+
+add_library(LinkLibrary_nested_feature1 SHARED lib.c)
+target_link_libraries(LinkLibrary_nested_feature1 PRIVATE "$<LINK_LIBRARY:feat1,base1,$<LINK_LIBRARY:feat1,base2>>")
+
+add_library(LinkLibrary_nested_feature2 SHARED lib.c)
+target_link_libraries(LinkLibrary_nested_feature2 PRIVATE "$<LINK_LIBRARY:feat2,base1,$<LINK_LIBRARY:feat2,base2>>")
+
+add_library(LinkLibrary_link_items1 SHARED lib.c)
+target_link_libraries(LinkLibrary_link_items1 PRIVATE "$<LINK_LIBRARY:feat3,base1,other>")
+
+add_library(LinkLibrary_link_items2 SHARED lib.c)
+target_link_libraries(LinkLibrary_link_items2 PRIVATE "$<LINK_LIBRARY:feat2,base1,other>")
+
+add_library(LinkLibrary_link_items3 SHARED lib.c)
+target_link_libraries(LinkLibrary_link_items3 PRIVATE "$<LINK_LIBRARY:feat4,base1,other>")
+
+add_library(LinkLibrary_link_items4 SHARED lib.c)
+target_link_libraries(LinkLibrary_link_items4 PRIVATE "$<LINK_LIBRARY:feat5,base1,other>")
+
+add_library(base3 SHARED base.c)
+target_link_libraries(base3 PRIVATE "$<LINK_LIBRARY:feat6,base1>")
+add_library(LinkLibrary_mix_features1 SHARED lib.c)
+target_link_libraries(LinkLibrary_mix_features1 PRIVATE "$<LINK_LIBRARY:feat2,base1,base3>")
+
+target_link_libraries(base3 INTERFACE "$<LINK_LIBRARY:feat2,base1>")
+add_library(LinkLibrary_mix_features2 SHARED lib.c)
+target_link_libraries(LinkLibrary_mix_features2 PRIVATE "$<LINK_LIBRARY:feat2,base1,base3>")
+
+target_link_libraries(base3 INTERFACE other1)
+add_library(LinkLibrary_mix_features3 SHARED lib.c)
+target_link_libraries(LinkLibrary_mix_features3 PRIVATE base2 "$<LINK_LIBRARY:feat2,base1,base3>" other2)
+
+# testing LINK_LIBRARY_OVERRIDE property
+add_library(LinkLibrary_override_features1 SHARED lib.c)
+target_link_libraries(LinkLibrary_override_features1 PRIVATE "$<LINK_LIBRARY:feat1,base1,base3>")
+set_property(TARGET LinkLibrary_override_features1 PROPERTY LINK_LIBRARY_OVERRIDE "feat1,base1")
+
+add_library(LinkLibrary_override_features2 SHARED lib.c)
+target_link_libraries(LinkLibrary_override_features2 PRIVATE "$<LINK_LIBRARY:feat1,base1,base3>")
+set_property(TARGET LinkLibrary_override_features2 PROPERTY LINK_LIBRARY_OVERRIDE "feat2,base1,other1")
+
+add_library(LinkLibrary_override_with_default SHARED lib.c)
+target_link_libraries(LinkLibrary_override_with_default PRIVATE "$<LINK_LIBRARY:feat1,base1,base3>")
+set_property(TARGET LinkLibrary_override_with_default PROPERTY LINK_LIBRARY_OVERRIDE "$<$<LINK_LANGUAGE:C>:DEFAULT,base1,other1>")
+
+# testing LINK_LIBRARY_OVERRIDE_<LIBRARY> property
+add_library(LinkLibrary_override_features3 SHARED lib.c)
+target_link_libraries(LinkLibrary_override_features3 PRIVATE "$<LINK_LIBRARY:feat1,base1,base3>")
+set_property(TARGET LinkLibrary_override_features3 PROPERTY LINK_LIBRARY_OVERRIDE_base1 feat1)
+
+add_library(LinkLibrary_override_features4 SHARED lib.c)
+target_link_libraries(LinkLibrary_override_features4 PRIVATE "$<LINK_LIBRARY:feat1,base1,base3>")
+set_property(TARGET LinkLibrary_override_features4 PROPERTY LINK_LIBRARY_OVERRIDE "feat3,base1,other1")
+set_property(TARGET LinkLibrary_override_features4 PROPERTY LINK_LIBRARY_OVERRIDE_base1 feat2)
+set_property(TARGET LinkLibrary_override_features4 PROPERTY LINK_LIBRARY_OVERRIDE_other1 feat2)
diff --git a/Tests/RunCMake/target_link_libraries-LINK_LIBRARY/RunCMakeTest.cmake b/Tests/RunCMake/target_link_libraries-LINK_LIBRARY/RunCMakeTest.cmake
new file mode 100644
index 0000000..021de41
--- /dev/null
+++ b/Tests/RunCMake/target_link_libraries-LINK_LIBRARY/RunCMakeTest.cmake
@@ -0,0 +1,122 @@
+
+include(RunCMake)
+
+cmake_policy(SET CMP0054 NEW)
+
+macro(run_cmake_target test subtest target)
+ set(RunCMake_TEST_BINARY_DIR ${RunCMake_BINARY_DIR}/${test}-build)
+ set(RunCMake_TEST_NO_CLEAN 1)
+ run_cmake_command(${test}-${subtest} ${CMAKE_COMMAND} --build . --target ${target} --config Release --verbose ${ARGN})
+
+ unset(RunCMake_TEST_BINARY_DIR)
+ unset(RunCMake_TEST_NO_CLEAN)
+endmacro()
+
+# Some environments are excluded because they are not able to honor verbose mode
+if ((RunCMake_GENERATOR MATCHES "Makefiles|Ninja|Xcode"
+ OR (RunCMake_GENERATOR MATCHES "Visual Studio" AND MSVC_VERSION GREATER_EQUAL "1600"))
+ AND NOT CMAKE_C_COMPILER_ID STREQUAL "Intel")
+
+ set(RunCMake_TEST_OUTPUT_MERGE TRUE)
+ if (NOT RunCMake_GENERATOR_IS_MULTI_CONFIG)
+ set(RunCMake_TEST_OPTIONS -DCMAKE_BUILD_TYPE=Release)
+ endif()
+
+ if (CMAKE_SYSTEM_NAME STREQUAL "Windows"
+ OR CMAKE_SYSTEM_NAME STREQUAL "CYGWIN"
+ OR CMAKE_SYSTEM_NAME STREQUAL "MSYS")
+ set(LINK_SHARED_LIBRARY_PREFIX ${CMAKE_IMPORT_LIBRARY_PREFIX})
+ set(LINK_SHARED_LIBRARY_SUFFIX ${CMAKE_IMPORT_LIBRARY_SUFFIX})
+ else()
+ set(LINK_SHARED_LIBRARY_PREFIX ${CMAKE_SHARED_LIBRARY_PREFIX})
+ set(LINK_SHARED_LIBRARY_SUFFIX ${CMAKE_SHARED_LIBRARY_SUFFIX})
+ endif()
+ if (MINGW OR MSYS OR CYGWIN)
+ set(LINK_EXTERN_LIBRARY_SUFFIX "")
+ else()
+ set(LINK_EXTERN_LIBRARY_SUFFIX "${CMAKE_IMPORT_LIBRARY_SUFFIX}")
+ endif()
+
+ run_cmake(LINK_LIBRARY)
+
+ run_cmake_target(LINK_LIBRARY simple1 LinkLibrary_simple1)
+ run_cmake_target(LINK_LIBRARY simple2 LinkLibrary_simple2)
+ run_cmake_target(LINK_LIBRARY group1 LinkLibrary_group1)
+ run_cmake_target(LINK_LIBRARY group2 LinkLibrary_group2)
+ run_cmake_target(LINK_LIBRARY nested-feature1 LinkLibrary_nested_feature1)
+ run_cmake_target(LINK_LIBRARY nested-feature2 LinkLibrary_nested_feature2)
+ run_cmake_target(LINK_LIBRARY link-items1 LinkLibrary_link_items1)
+ run_cmake_target(LINK_LIBRARY link-items2 LinkLibrary_link_items2)
+ run_cmake_target(LINK_LIBRARY link-items3 LinkLibrary_link_items3)
+ run_cmake_target(LINK_LIBRARY link-items4 LinkLibrary_link_items4)
+ run_cmake_target(LINK_LIBRARY mix-features1 LinkLibrary_mix_features1)
+ run_cmake_target(LINK_LIBRARY mix-features2 LinkLibrary_mix_features2)
+ run_cmake_target(LINK_LIBRARY mix-features3 LinkLibrary_mix_features3)
+
+ # testing target property LINK_LIBRARY_OVERRIDE
+ run_cmake_target(LINK_LIBRARY override-features1 LinkLibrary_override_features1)
+ run_cmake_target(LINK_LIBRARY override-features2 LinkLibrary_override_features2)
+ run_cmake_target(LINK_LIBRARY override-with-DEFAULT LinkLibrary_override_with_default)
+ # testing target property LINK_LIBRARY_OVERRIDE_<LIBRARY>
+ run_cmake_target(LINK_LIBRARY override-features3 LinkLibrary_override_features3)
+ run_cmake_target(LINK_LIBRARY override-features4 LinkLibrary_override_features4)
+
+ run_cmake(imported-target)
+
+ # tests using features as described in the documentation
+ if(CMAKE_C_COMPILER_ID STREQUAL "AppleClang"
+ OR (CMAKE_C_COMPILER_ID STREQUAL "MSVC" AND MSVC_VERSION GREATER "1900")
+ OR (CMAKE_C_COMPILER_ID STREQUAL "GNU" AND CMAKE_SYSTEM_NAME STREQUAL "Linux"))
+ run_cmake(load_archive)
+ run_cmake_target(load_archive link-exe main)
+ endif()
+ if(CMAKE_C_COMPILER_ID STREQUAL "AppleClang")
+ run_cmake(weak_library)
+ run_cmake_target(weak_library link-exe main)
+ endif()
+
+ unset(RunCMake_TEST_OPTIONS)
+ unset(RunCMake_TEST_OUTPUT_MERGE)
+
+endif()
+
+# Apple framework features
+if(APPLE AND (CMAKE_C_COMPILER_ID STREQUAL "GNU" OR CMAKE_C_COMPILER_ID MATCHES "Clang"))
+ run_cmake(apple_framework)
+ run_cmake_target(apple_framework framework main-framework)
+ run_cmake_target(apple_framework reexport_framework main-reexport_framework)
+ run_cmake_target(apple_framework weak_framework main-weak_framework)
+
+ run_cmake_target(apple_framework target-framework main-target-framework)
+ run_cmake_target(apple_framework target-reexport_framework main-target-reexport_framework)
+ run_cmake_target(apple_framework target-weak_framework main-target-weak_framework)
+endif()
+
+if (CMAKE_C_COMPILER_ID STREQUAL "AppleClang" AND CMAKE_C_COMPILER_VERSION GREATER_EQUAL "12")
+ run_cmake_target(apple_framework needed_framework main-needed_framework)
+
+ run_cmake_target(apple_framework target-needed_framework main-target-needed_framework)
+endif()
+
+# Apple library features
+if(APPLE AND (CMAKE_C_COMPILER_ID STREQUAL "GNU" OR CMAKE_C_COMPILER_ID MATCHES "Clang"))
+ run_cmake(apple_library_external)
+ run_cmake_target(apple_library_external build external)
+ run_cmake_with_options(apple_library "-DRunCMake_BINARY_DIR=${RunCMake_BINARY_DIR}")
+ run_cmake_target(apple_library reexport_library main-reexport_library)
+ run_cmake_target(apple_library weak_library main-weak_library)
+endif()
+
+if (CMAKE_C_COMPILER_ID STREQUAL "AppleClang" AND CMAKE_C_COMPILER_VERSION GREATER_EQUAL "12")
+ run_cmake_target(apple_library needed_library main-needed_library)
+endif()
+
+# WHOLE_ARCHIVE feature
+if ((CMAKE_SYSTEM_NAME STREQUAL "Windows" AND
+ ((DEFINED MSVC_VERSION AND MSVC_VERSION GREATER "1900") OR (CMAKE_C_COMPILER_ID MATCHES "GNU|Clang" AND NOT CMAKE_C_SIMULATE_ID STREQUAL "MSVC")))
+ OR (CMAKE_SYSTEM_NAME STREQUAL "SunOS" AND
+ (NOT CMAKE_C_COMPILER_ID STREQUAL "SunPro" OR CMAKE_C_COMPILER_VERSION GREATER "5.9"))
+ OR CMAKE_SYSTEM_NAME MATCHES "Darwin|iOS|tvOS|watchOS|Linux|BSD|MSYS|CYGWIN")
+ run_cmake(feature-WHOLE_ARCHIVE)
+ run_cmake_target(feature-WHOLE_ARCHIVE link-exe main)
+endif()
diff --git a/Tests/RunCMake/target_link_libraries-LINK_LIBRARY/apple_framework.cmake b/Tests/RunCMake/target_link_libraries-LINK_LIBRARY/apple_framework.cmake
new file mode 100644
index 0000000..e9a93e9
--- /dev/null
+++ b/Tests/RunCMake/target_link_libraries-LINK_LIBRARY/apple_framework.cmake
@@ -0,0 +1,61 @@
+
+enable_language(OBJCXX)
+
+
+# feature FRAMEWORK
+add_library(foo-framework SHARED foo.mm)
+target_link_libraries(foo-framework PRIVATE "$<LINK_LIBRARY:FRAMEWORK,Foundation>")
+
+add_executable(main-framework main.mm)
+target_link_libraries(main-framework PRIVATE "$<LINK_LIBRARY:FRAMEWORK,Foundation>" foo-framework)
+
+
+# feature NEEDED_FRAMEWORK
+add_library(foo-needed_framework SHARED foo.mm)
+target_link_libraries(foo-needed_framework PRIVATE "$<LINK_LIBRARY:NEEDED_FRAMEWORK,Foundation>")
+
+add_executable(main-needed_framework main.mm)
+target_link_libraries(main-needed_framework PRIVATE "$<LINK_LIBRARY:FRAMEWORK,Foundation>" foo-needed_framework)
+
+
+# feature REEXPORT_FRAMEWORK
+add_library(foo-reexport_framework SHARED foo.mm)
+target_link_libraries(foo-reexport_framework PRIVATE "$<LINK_LIBRARY:REEXPORT_FRAMEWORK,Foundation>")
+
+add_executable(main-reexport_framework main.mm)
+target_link_libraries(main-reexport_framework PRIVATE "$<LINK_LIBRARY:FRAMEWORK,Foundation>" foo-reexport_framework)
+
+
+# feature WEAK_FRAMEWORK
+add_library(foo-weak_framework SHARED foo.mm)
+target_link_libraries(foo-weak_framework PRIVATE "$<LINK_LIBRARY:WEAK_FRAMEWORK,Foundation>")
+
+add_executable(main-weak_framework main.mm)
+target_link_libraries(main-weak_framework PRIVATE "$<LINK_LIBRARY:FRAMEWORK,Foundation>" foo-weak_framework)
+
+
+##
+## Consumption of target specified as FRAMEWORK
+add_library(target-framework SHARED foo.mm)
+set_target_properties(target-framework PROPERTIES FRAMEWORK TRUE)
+target_link_libraries(target-framework PRIVATE "$<LINK_LIBRARY:FRAMEWORK,Foundation>")
+
+
+# feature FRAMEWORK
+add_executable(main-target-framework main.mm)
+target_link_libraries(main-target-framework PRIVATE "$<LINK_LIBRARY:FRAMEWORK,Foundation>" "$<LINK_LIBRARY:FRAMEWORK,target-framework>")
+
+
+# feature NEEDED_FRAMEWORK
+add_executable(main-target-needed_framework main.mm)
+target_link_libraries(main-target-needed_framework PRIVATE "$<LINK_LIBRARY:FRAMEWORK,Foundation>" "$<LINK_LIBRARY:NEEDED_FRAMEWORK,target-framework>")
+
+
+# feature REEXPORT_FRAMEWORK
+add_executable(main-target-reexport_framework main.mm)
+target_link_libraries(main-target-reexport_framework PRIVATE "$<LINK_LIBRARY:FRAMEWORK,Foundation>" "$<LINK_LIBRARY:REEXPORT_FRAMEWORK,target-framework>")
+
+
+# feature WEAK_FRAMEWORK
+add_executable(main-target-weak_framework main.mm)
+target_link_libraries(main-target-weak_framework PRIVATE "$<LINK_LIBRARY:FRAMEWORK,Foundation>" "$<LINK_LIBRARY:REEXPORT_FRAMEWORK,target-framework>")
diff --git a/Tests/RunCMake/target_link_libraries-LINK_LIBRARY/apple_library.cmake b/Tests/RunCMake/target_link_libraries-LINK_LIBRARY/apple_library.cmake
new file mode 100644
index 0000000..fb85d05
--- /dev/null
+++ b/Tests/RunCMake/target_link_libraries-LINK_LIBRARY/apple_library.cmake
@@ -0,0 +1,24 @@
+
+enable_language(C)
+
+add_library(lib SHARED base.c lib.c)
+
+# feature NEEDED_FRAMEWORK
+add_executable(main-needed_library main.c)
+target_link_directories(main-needed_library PRIVATE "${RunCMake_BINARY_DIR}/apple_library_external-build"
+ "${RunCMake_BINARY_DIR}/apple_library_external-build/$<CONFIG>")
+target_link_libraries(main-needed_library PRIVATE "$<LINK_LIBRARY:NEEDED_LIBRARY,lib,external>")
+
+
+# feature REEXPORT_FRAMEWORK
+add_executable(main-reexport_library main.c)
+target_link_directories(main-reexport_library PRIVATE "${RunCMake_BINARY_DIR}/apple_library_external-build"
+ "${RunCMake_BINARY_DIR}/apple_library_external-build/$<CONFIG>")
+target_link_libraries(main-reexport_library PRIVATE "$<LINK_LIBRARY:REEXPORT_LIBRARY,lib,external>")
+
+
+# feature WEAK_FRAMEWORK
+add_executable(main-weak_library main.c)
+target_link_directories(main-weak_library PRIVATE "${RunCMake_BINARY_DIR}/apple_library_external-build"
+ "${RunCMake_BINARY_DIR}/apple_library_external-build/$<CONFIG>")
+target_link_libraries(main-weak_library PRIVATE "$<LINK_LIBRARY:WEAK_LIBRARY,lib,external>")
diff --git a/Tests/RunCMake/target_link_libraries-LINK_LIBRARY/apple_library_external.cmake b/Tests/RunCMake/target_link_libraries-LINK_LIBRARY/apple_library_external.cmake
new file mode 100644
index 0000000..f5a566f
--- /dev/null
+++ b/Tests/RunCMake/target_link_libraries-LINK_LIBRARY/apple_library_external.cmake
@@ -0,0 +1,4 @@
+
+enable_language(C)
+
+add_library(external SHARED unref.c)
diff --git a/Tests/RunCMake/target_link_libraries-LINK_LIBRARY/base.c b/Tests/RunCMake/target_link_libraries-LINK_LIBRARY/base.c
new file mode 100644
index 0000000..ed769a0
--- /dev/null
+++ b/Tests/RunCMake/target_link_libraries-LINK_LIBRARY/base.c
@@ -0,0 +1,9 @@
+
+#if !defined(STATIC_BASE)
+# if defined(_WIN32)
+__declspec(dllexport)
+# endif
+#endif
+ void base(void)
+{
+}
diff --git a/Tests/RunCMake/target_link_libraries-LINK_LIBRARY/feature-WHOLE_ARCHIVE.cmake b/Tests/RunCMake/target_link_libraries-LINK_LIBRARY/feature-WHOLE_ARCHIVE.cmake
new file mode 100644
index 0000000..e525325
--- /dev/null
+++ b/Tests/RunCMake/target_link_libraries-LINK_LIBRARY/feature-WHOLE_ARCHIVE.cmake
@@ -0,0 +1,11 @@
+
+enable_language(C)
+
+add_library(base STATIC base.c unref.c)
+target_compile_definitions(base PUBLIC STATIC_BASE)
+
+add_library(lib SHARED lib.c)
+target_link_libraries(lib PRIVATE "$<LINK_LIBRARY:WHOLE_ARCHIVE,base>")
+
+add_executable(main main.c)
+target_link_libraries(main PRIVATE lib)
diff --git a/Tests/RunCMake/target_link_libraries-LINK_LIBRARY/foo.h b/Tests/RunCMake/target_link_libraries-LINK_LIBRARY/foo.h
new file mode 100644
index 0000000..b3fb084
--- /dev/null
+++ b/Tests/RunCMake/target_link_libraries-LINK_LIBRARY/foo.h
@@ -0,0 +1,9 @@
+#import <Foundation/Foundation.h>
+
+@interface Foo : NSObject {
+ NSNumber* age;
+}
+
+@property (nonatomic, retain) NSNumber* age;
+
+@end
diff --git a/Tests/RunCMake/target_link_libraries-LINK_LIBRARY/foo.mm b/Tests/RunCMake/target_link_libraries-LINK_LIBRARY/foo.mm
new file mode 100644
index 0000000..2d452a8
--- /dev/null
+++ b/Tests/RunCMake/target_link_libraries-LINK_LIBRARY/foo.mm
@@ -0,0 +1,7 @@
+#import "foo.h"
+
+@implementation Foo
+
+@synthesize age;
+
+@end
diff --git a/Tests/RunCMake/target_link_libraries-LINK_LIBRARY/imported-target-result.txt b/Tests/RunCMake/target_link_libraries-LINK_LIBRARY/imported-target-result.txt
new file mode 100644
index 0000000..d00491f
--- /dev/null
+++ b/Tests/RunCMake/target_link_libraries-LINK_LIBRARY/imported-target-result.txt
@@ -0,0 +1 @@
+1
diff --git a/Tests/RunCMake/target_link_libraries-LINK_LIBRARY/imported-target-stdout.txt b/Tests/RunCMake/target_link_libraries-LINK_LIBRARY/imported-target-stdout.txt
new file mode 100644
index 0000000..981376a
--- /dev/null
+++ b/Tests/RunCMake/target_link_libraries-LINK_LIBRARY/imported-target-stdout.txt
@@ -0,0 +1,18 @@
+CMake Warning \(dev\) at imported-target.cmake:[0-9]+ \(add_library\):
+ The 'IMPORTED' target 'NS::lib2' uses the generator-expression
+ '\$<LINK_LIBRARY>' with the feature 'whole_archive', which is undefined or
+ unsupported.
+
+ Did you miss to define it by setting variables
+ "CMAKE_C_LINK_LIBRARY_USING_whole_archive" and
+ "CMAKE_C_LINK_LIBRARY_USING_whole_archive_SUPPORTED"\?
+Call Stack \(most recent call first\):
+ CMakeLists.txt:[0-9]+ \(include\)
+This warning is for project developers. Use -Wno-dev to suppress it.
+
+CMake Error at imported-target.cmake:[0-9]+ \(add_library\):
+ Feature 'whole_archive', specified through generator-expression
+ '\$<LINK_LIBRARY>' to link target 'lib', is not supported for the 'C' link
+ language.
+Call Stack \(most recent call first\):
+ CMakeLists.txt:[0-9]+ \(include\)
diff --git a/Tests/RunCMake/target_link_libraries-LINK_LIBRARY/imported-target.cmake b/Tests/RunCMake/target_link_libraries-LINK_LIBRARY/imported-target.cmake
new file mode 100644
index 0000000..9283054
--- /dev/null
+++ b/Tests/RunCMake/target_link_libraries-LINK_LIBRARY/imported-target.cmake
@@ -0,0 +1,18 @@
+
+enable_language(C)
+
+# Create imported target NS::lib
+add_library(NS::lib STATIC IMPORTED)
+
+# Create imported target NS::lib2
+add_library(NS::lib2 SHARED IMPORTED)
+
+set_target_properties(NS::lib2 PROPERTIES
+ IMPORTED_LOCATION "/path/to/lib"
+ IMPORTED_IMPLIB "/path/to/import.lib"
+ INTERFACE_LINK_LIBRARIES "$<LINK_LIBRARY:whole_archive,NS::lib>"
+)
+
+
+add_library(lib SHARED lib.c)
+target_link_libraries(lib PRIVATE NS::lib2)
diff --git a/Tests/RunCMake/target_link_libraries-LINK_LIBRARY/lib.c b/Tests/RunCMake/target_link_libraries-LINK_LIBRARY/lib.c
new file mode 100644
index 0000000..21f559c
--- /dev/null
+++ b/Tests/RunCMake/target_link_libraries-LINK_LIBRARY/lib.c
@@ -0,0 +1,15 @@
+
+#if !defined(STATIC_BASE)
+# if defined(_WIN32)
+__declspec(dllimport)
+# endif
+#endif
+ void base(void);
+
+#if defined(_WIN32)
+__declspec(dllexport)
+#endif
+ void lib(void)
+{
+ base();
+}
diff --git a/Tests/RunCMake/target_link_libraries-LINK_LIBRARY/load_archive.cmake b/Tests/RunCMake/target_link_libraries-LINK_LIBRARY/load_archive.cmake
new file mode 100644
index 0000000..a0bbb43
--- /dev/null
+++ b/Tests/RunCMake/target_link_libraries-LINK_LIBRARY/load_archive.cmake
@@ -0,0 +1,34 @@
+
+enable_language(C)
+
+set(CMAKE_C_LINK_LIBRARY_USING_load_archive_SUPPORTED TRUE)
+if(CMAKE_C_COMPILER_ID STREQUAL "AppleClang")
+ set(CMAKE_C_LINK_LIBRARY_USING_load_archive "-force_load <LIB_ITEM>")
+elseif(CMAKE_C_COMPILER_ID STREQUAL "GNU" AND CMAKE_SYSTEM_NAME STREQUAL "Linux")
+ execute_process(COMMAND "${CMAKE_LINKER}" --help
+ OUTPUT_VARIABLE linker_help
+ ERROR_VARIABLE linker_help)
+ if(linker_help MATCHES "--push-state" AND linker_help MATCHES "--pop-state")
+ set(CMAKE_C_LINK_LIBRARY_USING_load_archive "LINKER:--push-state,--whole-archive"
+ "<LINK_ITEM>"
+ "LINKER:--pop-state")
+ else()
+ set(CMAKE_C_LINK_LIBRARY_USING_load_archive "LINKER:--whole-archive"
+ "<LINK_ITEM>"
+ "LINKER:--no-whole-archive")
+ endif()
+elseif(CMAKE_C_COMPILER_ID STREQUAL "MSVC")
+ set(CMAKE_C_LINK_LIBRARY_USING_load_archive "/WHOLEARCHIVE:<LIBRARY>")
+else()
+ # feature not yet supported for the other environments
+ set(CMAKE_C_LINK_LIBRARY_USING_load_archive_SUPPORTED FALSE)
+endif()
+
+add_library(base STATIC base.c unref.c)
+target_compile_definitions(base PUBLIC STATIC_BASE)
+
+add_library(lib SHARED lib.c)
+target_link_libraries(lib PRIVATE "$<LINK_LIBRARY:load_archive,base>")
+
+add_executable(main main.c)
+target_link_libraries(main PRIVATE lib)
diff --git a/Tests/RunCMake/target_link_libraries-LINK_LIBRARY/main.c b/Tests/RunCMake/target_link_libraries-LINK_LIBRARY/main.c
new file mode 100644
index 0000000..2e39bce
--- /dev/null
+++ b/Tests/RunCMake/target_link_libraries-LINK_LIBRARY/main.c
@@ -0,0 +1,18 @@
+
+#if defined(_WIN32)
+__declspec(dllimport)
+#endif
+ void lib(void);
+
+#if defined(_WIN32)
+__declspec(dllimport)
+#endif
+ void unref(void);
+
+int main(void)
+{
+ lib();
+ unref();
+
+ return 0;
+}
diff --git a/Tests/RunCMake/target_link_libraries-LINK_LIBRARY/main.mm b/Tests/RunCMake/target_link_libraries-LINK_LIBRARY/main.mm
new file mode 100644
index 0000000..7c85551
--- /dev/null
+++ b/Tests/RunCMake/target_link_libraries-LINK_LIBRARY/main.mm
@@ -0,0 +1,14 @@
+#import <Foundation/Foundation.h>
+#import "foo.h"
+#include <iostream>
+
+int main(int argc, char **argv)
+{
+ NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
+ Foo *theFoo = [[Foo alloc] init];
+ theFoo.age = [NSNumber numberWithInt:argc];
+ NSLog(@"%d\n",[theFoo.age intValue]);
+ std::cout << [theFoo.age intValue] << std::endl;
+ [pool release];
+ return 0;
+}
diff --git a/Tests/RunCMake/target_link_libraries-LINK_LIBRARY/unref.c b/Tests/RunCMake/target_link_libraries-LINK_LIBRARY/unref.c
new file mode 100644
index 0000000..11922de
--- /dev/null
+++ b/Tests/RunCMake/target_link_libraries-LINK_LIBRARY/unref.c
@@ -0,0 +1,8 @@
+
+
+#if defined(_WIN32)
+__declspec(dllexport)
+#endif
+ void unref(void)
+{
+}
diff --git a/Tests/RunCMake/target_link_libraries-LINK_LIBRARY/weak_library.cmake b/Tests/RunCMake/target_link_libraries-LINK_LIBRARY/weak_library.cmake
new file mode 100644
index 0000000..45b4f66
--- /dev/null
+++ b/Tests/RunCMake/target_link_libraries-LINK_LIBRARY/weak_library.cmake
@@ -0,0 +1,20 @@
+
+enable_language(C)
+
+if(CMAKE_C_COMPILER_ID STREQUAL "AppleClang")
+ set(CMAKE_LINK_LIBRARY_USING_weak_library "PATH{-weak_library <LIBRARY>}NAME{LINKER:-weak-l<LIB_ITEM>}")
+ set(CMAKE_LINK_LIBRARY_USING_weak_library_SUPPORTED TRUE)
+else()
+ # feature not yet supported for the other environments
+ set(CMAKE_LINK_LIBRARY_USING_whole_library_SUPPORTED FALSE)
+endif()
+
+add_library(lib SHARED base.c lib.c unref.c)
+set_property(TARGET lib PROPERTY OUTPUT_NAME base)
+
+add_executable(main main.c)
+target_link_libraries(main PRIVATE "$<LINK_LIBRARY:weak_library,lib>")
+
+add_executable(main2 main.c)
+target_link_directories(main2 PRIVATE "$<TARGET_FILE_DIR:lib>")
+target_link_libraries(main2 PRIVATE "$<LINK_LIBRARY:weak_library,base>")
diff --git a/Tests/RunCMake/while/CMP0130-NEW-result.txt b/Tests/RunCMake/while/CMP0130-NEW-result.txt
new file mode 100644
index 0000000..d00491f
--- /dev/null
+++ b/Tests/RunCMake/while/CMP0130-NEW-result.txt
@@ -0,0 +1 @@
+1
diff --git a/Tests/RunCMake/while/CMP0130-NEW-stderr.txt b/Tests/RunCMake/while/CMP0130-NEW-stderr.txt
new file mode 100644
index 0000000..df492d5
--- /dev/null
+++ b/Tests/RunCMake/while/CMP0130-NEW-stderr.txt
@@ -0,0 +1,9 @@
+^CMake Error at CMP0130-common.cmake:[0-9]+ \(while\):
+ while\(\) given incorrect arguments:
+
+ "\("
+
+ mismatched parenthesis in condition
+Call Stack \(most recent call first\):
+ CMP0130-NEW.cmake:[0-9]+ \(include\)
+ CMakeLists.txt:[0-9]+ \(include\)$
diff --git a/Tests/RunCMake/while/CMP0130-NEW.cmake b/Tests/RunCMake/while/CMP0130-NEW.cmake
new file mode 100644
index 0000000..3cc5027
--- /dev/null
+++ b/Tests/RunCMake/while/CMP0130-NEW.cmake
@@ -0,0 +1,2 @@
+cmake_policy(SET CMP0130 NEW)
+include(CMP0130-common.cmake)
diff --git a/Tests/RunCMake/while/unbalanced-parenthesis-stdout.txt b/Tests/RunCMake/while/CMP0130-OLD-stdout.txt
similarity index 100%
rename from Tests/RunCMake/while/unbalanced-parenthesis-stdout.txt
rename to Tests/RunCMake/while/CMP0130-OLD-stdout.txt
diff --git a/Tests/RunCMake/while/CMP0130-OLD.cmake b/Tests/RunCMake/while/CMP0130-OLD.cmake
new file mode 100644
index 0000000..15a4290
--- /dev/null
+++ b/Tests/RunCMake/while/CMP0130-OLD.cmake
@@ -0,0 +1,2 @@
+cmake_policy(SET CMP0130 OLD)
+include(CMP0130-common.cmake)
diff --git a/Tests/RunCMake/while/CMP0130-WARN-stderr.txt b/Tests/RunCMake/while/CMP0130-WARN-stderr.txt
new file mode 100644
index 0000000..bc88c5e
--- /dev/null
+++ b/Tests/RunCMake/while/CMP0130-WARN-stderr.txt
@@ -0,0 +1,14 @@
+^CMake Warning \(dev\) at CMP0130-common.cmake:[0-9]+ \(while\):
+ Policy CMP0130 is not set: while\(\) diagnoses condition evaluation errors.
+ Run "cmake --help-policy CMP0130" for policy details. Use the cmake_policy
+ command to set the policy and suppress this warning.
+
+ while\(\) given incorrect arguments:
+
+ "\("
+
+ mismatched parenthesis in condition
+Call Stack \(most recent call first\):
+ CMP0130-WARN.cmake:[0-9]+ \(include\)
+ CMakeLists.txt:[0-9]+ \(include\)
+This warning is for project developers. Use -Wno-dev to suppress it.$
diff --git a/Tests/RunCMake/while/unbalanced-parenthesis-stdout.txt b/Tests/RunCMake/while/CMP0130-WARN-stdout.txt
similarity index 100%
copy from Tests/RunCMake/while/unbalanced-parenthesis-stdout.txt
copy to Tests/RunCMake/while/CMP0130-WARN-stdout.txt
diff --git a/Tests/RunCMake/while/CMP0130-WARN.cmake b/Tests/RunCMake/while/CMP0130-WARN.cmake
new file mode 100644
index 0000000..562c25d
--- /dev/null
+++ b/Tests/RunCMake/while/CMP0130-WARN.cmake
@@ -0,0 +1,2 @@
+# CMP0130 left unset
+include(CMP0130-common.cmake)
diff --git a/Tests/RunCMake/while/unbalanced-parenthesis.cmake b/Tests/RunCMake/while/CMP0130-common.cmake
similarity index 65%
rename from Tests/RunCMake/while/unbalanced-parenthesis.cmake
rename to Tests/RunCMake/while/CMP0130-common.cmake
index 39d736b..15322e0 100644
--- a/Tests/RunCMake/while/unbalanced-parenthesis.cmake
+++ b/Tests/RunCMake/while/CMP0130-common.cmake
@@ -3,5 +3,4 @@
message(STATUS "Condition incorrectly true")
break()
endwhile()
-# FIXME(#23296): The above condition error is tolerated for compatibility.
message(STATUS "Code incorrectly accepted")
diff --git a/Tests/RunCMake/while/RunCMakeTest.cmake b/Tests/RunCMake/while/RunCMakeTest.cmake
index bb9b991..d018b16 100644
--- a/Tests/RunCMake/while/RunCMakeTest.cmake
+++ b/Tests/RunCMake/while/RunCMakeTest.cmake
@@ -6,4 +6,6 @@
run_cmake(EndAlone)
run_cmake(EndAloneArgs)
-run_cmake(unbalanced-parenthesis)
+run_cmake(CMP0130-OLD)
+run_cmake(CMP0130-WARN)
+run_cmake(CMP0130-NEW)
diff --git a/Tests/TryCompile/CMakeLists.txt b/Tests/TryCompile/CMakeLists.txt
index b1b9d57..594f37a 100644
--- a/Tests/TryCompile/CMakeLists.txt
+++ b/Tests/TryCompile/CMakeLists.txt
@@ -32,7 +32,7 @@
# try to compile a file that should compile
# also check that COPY_FILE works
try_compile(SHOULD_PASS
- ${TryCompile_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeTmp
+ ${TryCompile_BINARY_DIR}
${TryCompile_SOURCE_DIR}/pass.c
OUTPUT_VARIABLE TRY_OUT
COPY_FILE ${TryCompile_BINARY_DIR}/CopyOfPass
@@ -51,7 +51,7 @@
# also check that COPY_FILE_ERROR works
file(WRITE ${TryCompile_BINARY_DIR}/invalid "")
try_compile(SHOULD_PASS
- ${TryCompile_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeTmp
+ ${TryCompile_BINARY_DIR}
${TryCompile_SOURCE_DIR}/pass.c
OUTPUT_VARIABLE TRY_OUT
COPY_FILE ${TryCompile_BINARY_DIR}/invalid/path
@@ -66,7 +66,7 @@
# try to compile a file that should not compile
try_compile(SHOULD_FAIL
- ${TryCompile_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeTmp
+ ${TryCompile_BINARY_DIR}
${TryCompile_SOURCE_DIR}/fail.c
OUTPUT_VARIABLE TRY_OUT)
if(SHOULD_FAIL)
@@ -75,7 +75,7 @@
# try to compile a file that should compile
try_compile(SHOULD_PASS
- ${TryCompile_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeTmp
+ ${TryCompile_BINARY_DIR}
${TryCompile_SOURCE_DIR}/pass.c
OUTPUT_VARIABLE TRY_OUT)
if(NOT SHOULD_PASS)
@@ -84,7 +84,7 @@
# try to compile a file that should not compile
try_compile(SHOULD_FAIL
- ${TryCompile_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeTmp
+ ${TryCompile_BINARY_DIR}
${TryCompile_SOURCE_DIR}/fail.c
OUTPUT_VARIABLE TRY_OUT)
if(SHOULD_FAIL)
@@ -93,7 +93,7 @@
# try to compile two files that should compile
try_compile(SHOULD_PASS
- ${TryCompile_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeTmp
+ ${TryCompile_BINARY_DIR}
SOURCES ${TryCompile_SOURCE_DIR}/pass2a.c ${TryCompile_SOURCE_DIR}/pass2b.cxx
OUTPUT_VARIABLE TRY_OUT)
if(NOT SHOULD_PASS)
@@ -102,7 +102,7 @@
# try to compile two files that should not compile
try_compile(SHOULD_FAIL
- ${TryCompile_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeTmp
+ ${TryCompile_BINARY_DIR}
SOURCES ${TryCompile_SOURCE_DIR}/fail2a.c ${TryCompile_SOURCE_DIR}/fail2b.c
OUTPUT_VARIABLE TRY_OUT)
if(SHOULD_FAIL)
@@ -117,7 +117,7 @@
string(APPEND CMAKE_C_FLAGS " \"-DTESTDEF\"")
endif()
try_compile(SHOULD_PASS
- ${TryCompile_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeTmp
+ ${TryCompile_BINARY_DIR}
${TryCompile_SOURCE_DIR}/testdef.c
OUTPUT_VARIABLE TRY_OUT)
if(NOT SHOULD_PASS)
@@ -135,7 +135,7 @@
message("Test failed")
endif()
try_compile(CMAKE_ANSI_FOR_SCOPE
- ${TryCompile_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeTmp
+ ${TryCompile_BINARY_DIR}
${CMAKE_ROOT}/Modules/TestForAnsiForScope.cxx OUTPUT_VARIABLE OUT)
if (CMAKE_ANSI_FOR_SCOPE)
message("Compiler supports ansi for")
@@ -144,7 +144,7 @@
endif()
try_compile(CMAKE_ANSI_FOR_SCOPE
- ${TryCompile_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeTmp
+ ${TryCompile_BINARY_DIR}
${CMAKE_ROOT}/Modules/TestForAnsiForScope.cxx OUTPUT_VARIABLE OUT)
if (CMAKE_ANSI_FOR_SCOPE)
message("Compiler supports ansi for")
@@ -169,7 +169,7 @@
TEST_ASSERT(TEST_INNER "try_compile project mode failed:\n${output}")
try_compile(COMPILE_DEFINITIONS_LIST_EXPANDED
- ${TryCompile_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeTmp
+ ${TryCompile_BINARY_DIR}
${TryCompile_SOURCE_DIR}/check_a_b.c
OUTPUT_VARIABLE output
COMPILE_DEFINITIONS "-DDEF_A;-DDEF_B"
@@ -182,7 +182,7 @@
endif()
try_compile(SHOULD_FAIL_DUE_TO_BAD_SOURCE
- ${TryCompile_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeTmp
+ ${TryCompile_BINARY_DIR}
${TryCompile_SOURCE_DIR}/pass.c
OUTPUT_VARIABLE output
COMPILE_DEFINITIONS "bad#source.c"
@@ -207,7 +207,7 @@
# also check that OUTPUT_VARIABLE contains both the compile output
# and the run output
try_run(SHOULD_RUN SHOULD_COMPILE
- ${TryCompile_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeTmp
+ ${TryCompile_BINARY_DIR}
${TryCompile_SOURCE_DIR}/exit_success.c
OUTPUT_VARIABLE TRY_OUT)
if(NOT SHOULD_COMPILE)
@@ -226,7 +226,7 @@
endif()
try_run(ARG_TEST_RUN ARG_TEST_COMPILE
- ${TryCompile_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeTmp
+ ${TryCompile_BINARY_DIR}
${TryCompile_SOURCE_DIR}/expect_arg.c
OUTPUT_VARIABLE TRY_OUT
ARGS arg1 arg2)
@@ -239,7 +239,7 @@
# try to run a file that should compile and run, but return an error
try_run(SHOULD_EXIT_WITH_ERROR SHOULD_COMPILE
- ${TryCompile_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeTmp
+ ${TryCompile_BINARY_DIR}
${TryCompile_SOURCE_DIR}/exit_with_error.c
COMPILE_OUTPUT_VARIABLE COMPILE_OUTPUT
RUN_OUTPUT_VARIABLE RUN_OUTPUT)
@@ -385,7 +385,7 @@
# try to compile a file that should compile
try_compile(SHOULD_PASS
- ${TryCompile_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeTmp
+ ${TryCompile_BINARY_DIR}
${TryCompile_SOURCE_DIR}/pass.m
OUTPUT_VARIABLE TRY_OUT)
if(NOT SHOULD_PASS)
@@ -394,7 +394,7 @@
# try to compile a file that should not compile
try_compile(SHOULD_FAIL
- ${TryCompile_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeTmp
+ ${TryCompile_BINARY_DIR}
${TryCompile_SOURCE_DIR}/fail.m
OUTPUT_VARIABLE TRY_OUT)
if(SHOULD_FAIL)
diff --git a/Tests/TryCompile/Inner/CMakeLists.txt b/Tests/TryCompile/Inner/CMakeLists.txt
index d8c22d0..9f89af2 100644
--- a/Tests/TryCompile/Inner/CMakeLists.txt
+++ b/Tests/TryCompile/Inner/CMakeLists.txt
@@ -2,7 +2,7 @@
project(TryCompileInner C)
try_compile(SHOULD_PASS
- ${TryCompileInner_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeTmp
+ ${TryCompileInner_BINARY_DIR}
${TryCompileInner_SOURCE_DIR}/../pass.c
OUTPUT_VARIABLE TRY_OUT
)
diff --git a/Tests/VSWinStorePhone/CMakeLists.txt b/Tests/VSWinStorePhone/CMakeLists.txt
index edd4330..2cb80fa 100644
--- a/Tests/VSWinStorePhone/CMakeLists.txt
+++ b/Tests/VSWinStorePhone/CMakeLists.txt
@@ -63,7 +63,8 @@
Direct3DApp1/SimpleVertexShader.hlsl
)
-set(CONTENT_FILES ${PIXELSHADER_FILES} ${VERTEXSHADER_FILES})
+ set(COPY_TO_OUTPUT_FILES Direct3DApp1/Simple.manifest)
+ set(CONTENT_FILES ${PIXELSHADER_FILES} ${VERTEXSHADER_FILES} ${COPY_TO_OUTPUT_FILES})
if (WINDOWS_PHONE8)
set(CONTENT_FILES ${CONTENT_FILES}
@@ -108,6 +109,7 @@
${CONTENT_FILES} ${DEBUG_CONTENT_FILES} ${RELEASE_CONTENT_FILES} ${ASSET_FILES} ${STRING_FILES}
Direct3DApp1/Direct3DApp1_TemporaryKey.pfx)
+set_property(SOURCE ${COPY_TO_OUTPUT_FILES} PROPERTY VS_COPY_TO_OUT_DIR "PreserveNewest")
set_property(SOURCE ${CONTENT_FILES} PROPERTY VS_DEPLOYMENT_CONTENT 1)
set_property(SOURCE ${ASSET_FILES} PROPERTY VS_DEPLOYMENT_CONTENT 1)
set_property(SOURCE ${ASSET_FILES} PROPERTY VS_DEPLOYMENT_LOCATION "Assets")
diff --git a/Tests/VSWinStorePhone/Direct3DApp1/CubeRenderer.cpp b/Tests/VSWinStorePhone/Direct3DApp1/CubeRenderer.cpp
index 595f553..d287857 100644
--- a/Tests/VSWinStorePhone/Direct3DApp1/CubeRenderer.cpp
+++ b/Tests/VSWinStorePhone/Direct3DApp1/CubeRenderer.cpp
@@ -17,6 +17,13 @@
// Create a new WinRT object to validate that we can link properly
Batman ^ hero = ref new Batman();
hero->savePeople();
+
+ // Test that .manifest files can be bundled with app
+ DX::ReadDataAsync("Direct3DApp1\\Simple.manifest")
+ .then([this](Platform::Array<byte> ^ fileData) {
+ std::string manifestContent(fileData->begin(), fileData->end());
+ assert(manifestContent.find("hello") == 0);
+ });
}
void CubeRenderer::CreateDeviceResources()
diff --git a/Tests/VSWinStorePhone/Direct3DApp1/Simple.manifest b/Tests/VSWinStorePhone/Direct3DApp1/Simple.manifest
new file mode 100644
index 0000000..ce01362
--- /dev/null
+++ b/Tests/VSWinStorePhone/Direct3DApp1/Simple.manifest
@@ -0,0 +1 @@
+hello
diff --git a/Utilities/Doxygen/CMakeLists.txt b/Utilities/Doxygen/CMakeLists.txt
index 72cfc05..b712c27 100644
--- a/Utilities/Doxygen/CMakeLists.txt
+++ b/Utilities/Doxygen/CMakeLists.txt
@@ -3,7 +3,7 @@
if(NOT CMake_SOURCE_DIR)
set(CMakeDeveloperReference_STANDALONE 1)
- cmake_minimum_required(VERSION 3.1...3.21 FATAL_ERROR)
+ cmake_minimum_required(VERSION 3.13...3.22 FATAL_ERROR)
get_filename_component(tmp "${CMAKE_CURRENT_SOURCE_DIR}" PATH)
get_filename_component(CMake_SOURCE_DIR "${tmp}" PATH)
include(${CMake_SOURCE_DIR}/Modules/CTestUseLaunchers.cmake)
diff --git a/Utilities/Git/ignore-revs b/Utilities/Git/ignore-revs
new file mode 100644
index 0000000..af058e8
--- /dev/null
+++ b/Utilities/Git/ignore-revs
@@ -0,0 +1,38 @@
+# LexerParser regeneration
+34b7dbbfc37180989b57a0fb25ca4e0010cf992b
+
+# CMAKE_BOOTSTRAP rename
+54e9d38c28d0073f2cc5d690adb5c993e7793c97
+
+# CMake code reindentation
+2c807b75f3283d30ecde55be5b434be65d0ea141
+932dcce1e63b98739ab547f2146a39310c2d0e1e
+
+# `#pragma once`
+bdca8b01d2d96d63e685e7eca03e0f51f5410fdf
+
+# clang-format-6
+ed98209ddc8d5e9f5b20cd010c69a25d553b2654
+d7204e649ed4ebb19bb341b4e49eb51514364922
+# Initial clang-format
+d9fd2f5402eeaa345691313658e02b51038f570b
+
+# Fortran parser renaming
+98b9645bcebf009643cff4e265cfcd31b56d80f5
+
+# Sphinx conversion, reformattings
+496ec6036fb2b4ebbae000ee362cdfb7704d08de
+df4ed1e9ffcdb6b99ccff9e6f44808fdd2abda56
+3442f2bcc47ccce86124144423b416b98d589b20
+28f08ba25cc60de3fc7cb9eb4b3297ed6fe1dee0
+baaab068f2fa9e736ed85f3ba9b75d96e9339f89
+a77e3086938d46c56f62901531245711dbd55cc4
+f051814ed0e63badbfd68049354f36259dbf4b49
+81759c77af28f367c71e71973d985dc1d7a7c87c
+
+# Removal of `end*` command arguments
+9db3116226cb99fcf54e936c833953abcde9b729
+# Lowercasing command names
+77543bde41b0e52c3959016698b529835945d62d
+# Removal of trailing whitespace
+7bbaa4283de26864b2e55e819db0884771585467
diff --git a/Utilities/Scripts/update-libarchive.bash b/Utilities/Scripts/update-libarchive.bash
index 3a24e2b..856a6ea 100755
--- a/Utilities/Scripts/update-libarchive.bash
+++ b/Utilities/Scripts/update-libarchive.bash
@@ -8,7 +8,7 @@
readonly ownership="LibArchive Upstream <libarchive-discuss@googlegroups.com>"
readonly subtree="Utilities/cmlibarchive"
readonly repo="https://github.com/libarchive/libarchive.git"
-readonly tag="v3.5.1"
+readonly tag="v3.6.0"
readonly shortlog=false
readonly paths="
CMakeLists.txt
diff --git a/Utilities/Sphinx/CMakeLists.txt b/Utilities/Sphinx/CMakeLists.txt
index 073e5ff..a2c7060 100644
--- a/Utilities/Sphinx/CMakeLists.txt
+++ b/Utilities/Sphinx/CMakeLists.txt
@@ -3,7 +3,7 @@
if(NOT CMake_SOURCE_DIR)
set(CMakeHelp_STANDALONE 1)
- cmake_minimum_required(VERSION 3.1...3.21 FATAL_ERROR)
+ cmake_minimum_required(VERSION 3.13...3.22 FATAL_ERROR)
get_filename_component(tmp "${CMAKE_CURRENT_SOURCE_DIR}" PATH)
get_filename_component(CMake_SOURCE_DIR "${tmp}" PATH)
include(${CMake_SOURCE_DIR}/Modules/CTestUseLaunchers.cmake)
diff --git a/Utilities/cmThirdPartyChecks.cmake b/Utilities/cmThirdPartyChecks.cmake
index 7e38df9..c7b3c8a 100644
--- a/Utilities/cmThirdPartyChecks.cmake
+++ b/Utilities/cmThirdPartyChecks.cmake
@@ -118,6 +118,7 @@
set(HAVE_LIBWS2_32 1)
set(HAVE_LIMITS_H 1)
set(HAVE_LINK 0)
+ set(HAVE_LINKAT 0)
set(HAVE_LINUX_FIEMAP_H 0)
set(HAVE_LINUX_FS_H 0)
set(HAVE_LINUX_MAGIC_H 0)
@@ -184,6 +185,7 @@
set(HAVE_STROPTS_H 0)
set(HAVE__STRTOI64 1)
set(HAVE_STRTOLL 1)
+ set(HAVE_STRUCT_STATFS 0)
set(HAVE_STRUCT_STATFS_F_NAMEMAX 0)
set(HAVE_STRUCT_STAT_ST_BIRTHTIME 0)
set(HAVE_STRUCT_STAT_ST_BIRTHTIMESPEC_TV_NSEC 0)
diff --git a/Utilities/cmlibarchive/CMakeLists.txt b/Utilities/cmlibarchive/CMakeLists.txt
index 2a788ff..9ab7cec 100644
--- a/Utilities/cmlibarchive/CMakeLists.txt
+++ b/Utilities/cmlibarchive/CMakeLists.txt
@@ -1,6 +1,9 @@
#
IF(0) # CMake handles policy settings in its own build.
CMAKE_MINIMUM_REQUIRED(VERSION 2.8.12 FATAL_ERROR)
+if(POLICY CMP0065)
+ cmake_policy(SET CMP0065 NEW) #3.4 don't use `-rdynamic` with executables
+endif()
if(POLICY CMP0074)
cmake_policy(SET CMP0074 NEW) #3.12.0 `find_package()`` uses ``<PackageName>_ROOT`` variables.
endif()
@@ -81,7 +84,7 @@
# ?? Should there be more here ??
SET(SOVERSION "${INTERFACE_VERSION}")
-# Enalbe CMAKE_PUSH_CHECK_STATE() and CMAKE_POP_CHECK_STATE() macros
+# Enable CMAKE_PUSH_CHECK_STATE() and CMAKE_POP_CHECK_STATE() macros
# saving and restoring the state of the variables.
INCLUDE(${CMake_SOURCE_DIR}/Modules/CMakePushCheckState.cmake)
@@ -110,24 +113,8 @@
# Especially for early development, we want to be a little
# aggressive about diagnosing build problems; this can get
# relaxed somewhat in final shipping versions.
-IF (CMAKE_C_COMPILER_ID MATCHES "^GNU$" OR CMAKE_C_COMPILER_ID MATCHES "^LCC$")
- SET(CMAKE_REQUIRED_FLAGS "-Wall -Wformat -Wformat-security")
- #################################################################
- # Set compile flags for all build types.
- SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wall -Wformat -Wformat-security")
- if (ENABLE_WERROR)
- SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Werror")
- endif ()
- #################################################################
- # Set compile flags for debug build.
- # This is added into CMAKE_C_FLAGS when CMAKE_BUILD_TYPE is "Debug"
- SET(CMAKE_C_FLAGS_DEBUG "${CMAKE_C_FLAGS_DEBUG} -Wextra")
- SET(CMAKE_C_FLAGS_DEBUG "${CMAKE_C_FLAGS_DEBUG} -Wunused")
- SET(CMAKE_C_FLAGS_DEBUG "${CMAKE_C_FLAGS_DEBUG} -Wshadow")
- SET(CMAKE_C_FLAGS_DEBUG "${CMAKE_C_FLAGS_DEBUG} -Wmissing-prototypes")
- SET(CMAKE_C_FLAGS_DEBUG "${CMAKE_C_FLAGS_DEBUG} -Wcast-qual")
-ENDIF (CMAKE_C_COMPILER_ID MATCHES "^GNU$" OR CMAKE_C_COMPILER_ID MATCHES "^LCC$")
-IF (CMAKE_C_COMPILER_ID MATCHES "^Clang$")
+IF (CMAKE_C_COMPILER_ID MATCHES "^GNU$" OR
+ CMAKE_C_COMPILER_ID MATCHES "^Clang$")
SET(CMAKE_REQUIRED_FLAGS "-Wall -Wformat -Wformat-security")
#################################################################
# Set compile flags for all build types.
@@ -144,7 +131,26 @@
SET(CMAKE_C_FLAGS_DEBUG "${CMAKE_C_FLAGS_DEBUG} -Wshadow")
SET(CMAKE_C_FLAGS_DEBUG "${CMAKE_C_FLAGS_DEBUG} -Wmissing-prototypes")
SET(CMAKE_C_FLAGS_DEBUG "${CMAKE_C_FLAGS_DEBUG} -Wcast-qual")
-ENDIF (CMAKE_C_COMPILER_ID MATCHES "^Clang$")
+ # Ideally this will be a compile/link time check, yet there's no obvious way
+ # how considering how old our minimum required cmake version is. The official
+ # cmake.org side does not host the manual pages even. Normally we can use
+ # either of the following two, yet neither is supported as of 3.0.2
+ # - check_linker_flag - does not exist
+ # - try_compile - does not support linker flags
+ #
+ # The CI fails with this on MacOS
+ IF(NOT CMAKE_SYSTEM_NAME MATCHES "Darwin")
+ # Place the functions and data into separate sections, allowing the linker
+ # to garbage collect the unused ones.
+ SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -ffunction-sections -fdata-sections")
+ SET(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -Wl,--gc-sections")
+ SET(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} -Wl,--gc-sections")
+ # Printing the discarded section is "too much", so enable on demand.
+ #SET(CMAKE_EXE_LINKER_FLAGS_DEBUG "${CMAKE_EXE_LINKER_FLAGS_DEBUG} -Wl,--print-gc-sections")
+ #SET(CMAKE_SHARED_LINKER_FLAGS_DEBUG "${CMAKE_SHARED_LINKER_FLAGS_DEBUG} -Wl,--print-gc-sections")
+ ENDIF(NOT CMAKE_SYSTEM_NAME MATCHES "Darwin")
+ENDIF (CMAKE_C_COMPILER_ID MATCHES "^GNU$" OR
+ CMAKE_C_COMPILER_ID MATCHES "^Clang$")
IF (CMAKE_C_COMPILER_ID MATCHES "^XL$")
SET(CMAKE_C_COMPILER "xlc_r")
SET(CMAKE_REQUIRED_FLAGS "-qflag=e:e -qformat=sec")
@@ -226,18 +232,15 @@
# CNG is used for encrypt/decrypt Zip archives on Windows.
OPTION(ENABLE_CNG "Enable the use of CNG(Crypto Next Generation)" ON)
-IF(0) # CMake does not build libarchive's command-line tools.
OPTION(ENABLE_TAR "Enable tar building" ON)
OPTION(ENABLE_TAR_SHARED "Enable dynamic build of tar" FALSE)
OPTION(ENABLE_CPIO "Enable cpio building" ON)
OPTION(ENABLE_CPIO_SHARED "Enable dynamic build of cpio" FALSE)
OPTION(ENABLE_CAT "Enable cat building" ON)
OPTION(ENABLE_CAT_SHARED "Enable dynamic build of cat" FALSE)
-ENDIF()
OPTION(ENABLE_XATTR "Enable extended attribute support" ON)
OPTION(ENABLE_ACL "Enable ACL support" ON)
OPTION(ENABLE_ICONV "Enable iconv support" ON)
-IF(0) # CMake does not build libarchive's tests.
OPTION(ENABLE_TEST "Enable unit and regression tests" ON)
OPTION(ENABLE_COVERAGE "Enable code coverage (GCC only, automatically sets ENABLE_TEST to ON)" FALSE)
OPTION(ENABLE_INSTALL "Enable installing of libraries" ON)
@@ -253,16 +256,8 @@
IF(ENABLE_TEST)
ENABLE_TESTING()
ENDIF(ENABLE_TEST)
-ENDIF()
IF(WIN32)
- SET(NTDDI_VERSION 0x05010000)
- SET(_WIN32_WINNT 0x0501)
- SET(WINVER 0x0501)
-ENDIF(WIN32)
-
-IF(0) # CMake hard-codes its own supported version of Windows.
-IF(WIN32)
IF(WINDOWS_VERSION STREQUAL "WIN8")
SET(NTDDI_VERSION 0x06020000)
SET(_WIN32_WINNT 0x0602)
@@ -308,7 +303,6 @@
SET(ENV{LDFLAGS} "$ENV{LDFLAGS} /SAFESEH:NO")
ENDIF(ENABLE_SAFESEH STREQUAL "YES")
ENDIF(MSVC)
-ENDIF()
IF("${CMAKE_C_PLATFORM_ID}" MATCHES "^(HP-UX)$")
ADD_DEFINITIONS(-D_XOPEN_SOURCE=500) # Ask wchar.h for mbstate_t
@@ -405,7 +399,7 @@
SET(__GNUWIN32PATH "C:/Program Files/GnuWin32")
ENDIF(WIN32 AND NOT CMAKE_CL_64 AND NOT CYGWIN)
IF(DEFINED __GNUWIN32PATH AND EXISTS "${__GNUWIN32PATH}")
- # You have to add a path availabel DLL file into PATH environment variable.
+ # You have to add a path available DLL file into PATH environment variable.
# Maybe DLL path is "C:/Program Files/GnuWin32/bin".
# The zlib and the bzip2 Setup program have installed programs and DLLs into
# "C:/Program Files/GnuWin32" by default.
@@ -638,11 +632,13 @@
INCLUDE_DIRECTORIES(${ZSTD_INCLUDE_DIR})
LIST(APPEND ADDITIONAL_LIBS ${ZSTD_LIBRARY})
SET(HAVE_LIBZSTD 1)
+ SET(HAVE_LIBZSTD_COMPRESSOR 1)
IF(0) # CMake expects the zstd library to work.
CMAKE_PUSH_CHECK_STATE()
SET(CMAKE_REQUIRED_LIBRARIES ${ZSTD_LIBRARY})
SET(CMAKE_REQUIRED_INCLUDES ${ZSTD_INCLUDE_DIR})
- CHECK_FUNCTION_EXISTS(ZSTD_compressStream HAVE_LIBZSTD)
+ CHECK_FUNCTION_EXISTS(ZSTD_decompressStream HAVE_LIBZSTD)
+ CHECK_FUNCTION_EXISTS(ZSTD_compressStream HAVE_LIBZSTD_COMPRESSOR)
#
# TODO: test for static library.
#
@@ -1044,7 +1040,7 @@
CMAKE_C_COMPILER_ID MATCHES "^Clang$")
#
# During checking iconv proto type, we should use -Werror to avoid the
- # success of iconv detection with a warnig which success is a miss
+ # success of iconv detection with a warning which success is a miss
# detection. So this needs for all build mode(even it's a release mode).
#
SET(CMAKE_REQUIRED_FLAGS "${CMAKE_REQUIRED_FLAGS} -Werror")
@@ -1380,6 +1376,7 @@
CHECK_FUNCTION_EXISTS_GLIBC(lchmod HAVE_LCHMOD)
CHECK_FUNCTION_EXISTS_GLIBC(lchown HAVE_LCHOWN)
CHECK_FUNCTION_EXISTS_GLIBC(link HAVE_LINK)
+CHECK_FUNCTION_EXISTS_GLIBC(linkat HAVE_LINKAT)
CHECK_FUNCTION_EXISTS_GLIBC(localtime_r HAVE_LOCALTIME_R)
CHECK_FUNCTION_EXISTS_GLIBC(lstat HAVE_LSTAT)
CHECK_FUNCTION_EXISTS_GLIBC(lutimes HAVE_LUTIMES)
@@ -1449,6 +1446,10 @@
"#include <sys/types.h>\n#include <sys/mount.h>\nint main(void) { struct xvfsconf v; return sizeof(v);}"
HAVE_STRUCT_XVFSCONF)
+CHECK_C_SOURCE_COMPILES(
+ "#include <sys/types.h>\n#include <sys/mount.h>\nint main(void) { struct statfs s; return sizeof(s);}"
+ HAVE_STRUCT_STATFS)
+
# Make sure we have the POSIX version of readdir_r, not the
# older 2-argument version.
CHECK_C_SOURCE_COMPILES(
@@ -1512,9 +1513,14 @@
CHECK_STRUCT_HAS_MEMBER("struct tm" __tm_gmtoff
"time.h" HAVE_STRUCT_TM___TM_GMTOFF)
+IF(HAVE_STRUCT_STATFS)
# Check for f_namemax in struct statfs
CHECK_STRUCT_HAS_MEMBER("struct statfs" f_namemax
"sys/param.h;sys/mount.h" HAVE_STRUCT_STATFS_F_NAMEMAX)
+# Check for f_iosize in struct statfs
+CHECK_STRUCT_HAS_MEMBER("struct statfs" f_iosize
+ "sys/param.h;sys/mount.h" HAVE_STRUCT_STATFS_F_IOSIZE)
+ENDIF(HAVE_STRUCT_STATFS)
# Check for birthtime in struct stat
CHECK_STRUCT_HAS_MEMBER("struct stat" st_birthtime
@@ -2019,11 +2025,9 @@
ADD_DEFINITIONS(-Wno-deprecated-declarations)
ENDIF(APPLE)
-IF(0) # CMake does not build libarchive's tests.
IF(ENABLE_TEST)
ADD_CUSTOM_TARGET(run_all_tests)
ENDIF(ENABLE_TEST)
-ENDIF()
# We need CoreServices on Mac OS.
IF(APPLE)
diff --git a/Utilities/cmlibarchive/build/cmake/config.h.in b/Utilities/cmlibarchive/build/cmake/config.h.in
index 9bd2667..72467a5 100644
--- a/Utilities/cmlibarchive/build/cmake/config.h.in
+++ b/Utilities/cmlibarchive/build/cmake/config.h.in
@@ -522,14 +522,18 @@
/* Define to 1 if you have the `zstd' library (-lzstd). */
#cmakedefine HAVE_LIBZSTD 1
+/* Define to 1 if you have the `zstd' library (-lzstd) with compression
+ support. */
+#cmakedefine HAVE_LIBZSTD_COMPRESSOR 1
+
/* Define to 1 if you have the <limits.h> header file. */
#cmakedefine HAVE_LIMITS_H 1
/* Define to 1 if you have the `link' function. */
#cmakedefine HAVE_LINK 1
-/* Define to 1 if you have the <linux/types.h> header file. */
-#cmakedefine HAVE_LINUX_TYPES_H 1
+/* Define to 1 if you have the `linkat' function. */
+#cmakedefine HAVE_LINKAT 1
/* Define to 1 if you have the <linux/fiemap.h> header file. */
#cmakedefine HAVE_LINUX_FIEMAP_H 1
diff --git a/Utilities/cmlibarchive/build/utils/gen_archive_string_composition_h.sh b/Utilities/cmlibarchive/build/utils/gen_archive_string_composition_h.sh
index 925de5c..558e9c0 100755
--- a/Utilities/cmlibarchive/build/utils/gen_archive_string_composition_h.sh
+++ b/Utilities/cmlibarchive/build/utils/gen_archive_string_composition_h.sh
@@ -246,7 +246,7 @@
# Exclusion code points specified by
# http://unicode.org/Public/6.0.0/ucd/CompositionExclusions.txt
##
-# 1. Script Specifices
+# 1. Script Specifics
##
\$1 ~/^095[89ABCDEF]\$/ {
next
diff --git a/Utilities/cmlibarchive/build/version b/Utilities/cmlibarchive/build/version
index 205791c..102ec29 100644
--- a/Utilities/cmlibarchive/build/version
+++ b/Utilities/cmlibarchive/build/version
@@ -1 +1 @@
-3005001
+3006000
diff --git a/Utilities/cmlibarchive/libarchive/CMakeLists.txt b/Utilities/cmlibarchive/libarchive/CMakeLists.txt
index 891a140..feb8697 100644
--- a/Utilities/cmlibarchive/libarchive/CMakeLists.txt
+++ b/Utilities/cmlibarchive/libarchive/CMakeLists.txt
@@ -144,7 +144,9 @@
archive_write_set_format_ar.c
archive_write_set_format_by_name.c
archive_write_set_format_cpio.c
+ archive_write_set_format_cpio_binary.c
archive_write_set_format_cpio_newc.c
+ archive_write_set_format_cpio_odc.c
archive_write_set_format_filter_by_ext.c
archive_write_set_format_gnutar.c
archive_write_set_format_iso9660.c
diff --git a/Utilities/cmlibarchive/libarchive/archive.h b/Utilities/cmlibarchive/libarchive/archive.h
index a1f0b87..ac01738 100644
--- a/Utilities/cmlibarchive/libarchive/archive.h
+++ b/Utilities/cmlibarchive/libarchive/archive.h
@@ -36,7 +36,7 @@
* assert that ARCHIVE_VERSION_NUMBER >= 2012108.
*/
/* Note: Compiler will complain if this does not match archive_entry.h! */
-#define ARCHIVE_VERSION_NUMBER 3005001
+#define ARCHIVE_VERSION_NUMBER 3006000
#include <sys/stat.h>
#include <stddef.h> /* for wchar_t */
@@ -97,7 +97,7 @@
#endif
/* Large file support for Android */
-#ifdef __ANDROID__
+#if defined(__LIBARCHIVE_BUILD) && defined(__ANDROID__)
#include "android_lf.h"
#endif
@@ -152,7 +152,7 @@
/*
* Textual name/version of the library, useful for version displays.
*/
-#define ARCHIVE_VERSION_ONLY_STRING "3.5.1"
+#define ARCHIVE_VERSION_ONLY_STRING "3.6.0"
#define ARCHIVE_VERSION_STRING "libarchive " ARCHIVE_VERSION_ONLY_STRING
__LA_DECL const char * archive_version_string(void);
@@ -316,6 +316,7 @@
#define ARCHIVE_FORMAT_CPIO_SVR4_NOCRC (ARCHIVE_FORMAT_CPIO | 4)
#define ARCHIVE_FORMAT_CPIO_SVR4_CRC (ARCHIVE_FORMAT_CPIO | 5)
#define ARCHIVE_FORMAT_CPIO_AFIO_LARGE (ARCHIVE_FORMAT_CPIO | 6)
+#define ARCHIVE_FORMAT_CPIO_PWB (ARCHIVE_FORMAT_CPIO | 7)
#define ARCHIVE_FORMAT_SHAR 0x20000
#define ARCHIVE_FORMAT_SHAR_BASE (ARCHIVE_FORMAT_SHAR | 1)
#define ARCHIVE_FORMAT_SHAR_DUMP (ARCHIVE_FORMAT_SHAR | 2)
@@ -797,7 +798,10 @@
__LA_DECL int archive_write_set_format_ar_bsd(struct archive *);
__LA_DECL int archive_write_set_format_ar_svr4(struct archive *);
__LA_DECL int archive_write_set_format_cpio(struct archive *);
+__LA_DECL int archive_write_set_format_cpio_bin(struct archive *);
__LA_DECL int archive_write_set_format_cpio_newc(struct archive *);
+__LA_DECL int archive_write_set_format_cpio_odc(struct archive *);
+__LA_DECL int archive_write_set_format_cpio_pwb(struct archive *);
__LA_DECL int archive_write_set_format_gnutar(struct archive *);
__LA_DECL int archive_write_set_format_iso9660(struct archive *);
__LA_DECL int archive_write_set_format_mtree(struct archive *);
@@ -1017,6 +1021,8 @@
#define ARCHIVE_READDISK_NO_ACL (0x0020)
/* Default: File flags are read from disk. */
#define ARCHIVE_READDISK_NO_FFLAGS (0x0040)
+/* Default: Sparse file information is read from disk. */
+#define ARCHIVE_READDISK_NO_SPARSE (0x0080)
__LA_DECL int archive_read_disk_set_behavior(struct archive *,
int flags);
diff --git a/Utilities/cmlibarchive/libarchive/archive_blake2.h b/Utilities/cmlibarchive/libarchive/archive_blake2.h
index dd6fe6f..8f6b5e9 100644
--- a/Utilities/cmlibarchive/libarchive/archive_blake2.h
+++ b/Utilities/cmlibarchive/libarchive/archive_blake2.h
@@ -21,8 +21,10 @@
#if defined(_MSC_VER)
#define BLAKE2_PACKED(x) __pragma(pack(push, 1)) x __pragma(pack(pop))
-#else
+#elif defined(__GNUC__)
#define BLAKE2_PACKED(x) x __attribute__((packed))
+#else
+#define BLAKE2_PACKED(x) _Pragma("pack 1") x _Pragma("pack 0")
#endif
#if defined(__cplusplus)
diff --git a/Utilities/cmlibarchive/libarchive/archive_blake2_impl.h b/Utilities/cmlibarchive/libarchive/archive_blake2_impl.h
index 0f05def..eb8619c 100644
--- a/Utilities/cmlibarchive/libarchive/archive_blake2_impl.h
+++ b/Utilities/cmlibarchive/libarchive/archive_blake2_impl.h
@@ -154,7 +154,7 @@
/* prevents compiler optimizing out memset() */
static BLAKE2_INLINE void secure_zero_memory(void *v, size_t n)
{
- static void *(*const volatile memset_v)(void *, int, size_t) = &memset;
+ static void *(__LA_LIBC_CC *const volatile memset_v)(void *, int, size_t) = &memset;
memset_v(v, 0, n);
}
diff --git a/Utilities/cmlibarchive/libarchive/archive_blake2s_ref.c b/Utilities/cmlibarchive/libarchive/archive_blake2s_ref.c
index d92ffd0..93d3281 100644
--- a/Utilities/cmlibarchive/libarchive/archive_blake2s_ref.c
+++ b/Utilities/cmlibarchive/libarchive/archive_blake2s_ref.c
@@ -13,6 +13,8 @@
https://blake2.net.
*/
+#include "archive_platform.h"
+
#include <stdint.h>
#include <string.h>
#include <stdio.h>
diff --git a/Utilities/cmlibarchive/libarchive/archive_blake2sp_ref.c b/Utilities/cmlibarchive/libarchive/archive_blake2sp_ref.c
index aef1010..b913a4d 100644
--- a/Utilities/cmlibarchive/libarchive/archive_blake2sp_ref.c
+++ b/Utilities/cmlibarchive/libarchive/archive_blake2sp_ref.c
@@ -13,6 +13,8 @@
https://blake2.net.
*/
+#include "archive_platform.h"
+
#include <stdlib.h>
#include <string.h>
#include <stdio.h>
diff --git a/Utilities/cmlibarchive/libarchive/archive_cryptor.c b/Utilities/cmlibarchive/libarchive/archive_cryptor.c
index d4bca90..112baf1 100644
--- a/Utilities/cmlibarchive/libarchive/archive_cryptor.c
+++ b/Utilities/cmlibarchive/libarchive/archive_cryptor.c
@@ -401,14 +401,6 @@
memcpy(ctx->key, key, key_len);
memset(ctx->nonce, 0, sizeof(ctx->nonce));
ctx->encr_pos = AES_BLOCK_SIZE;
-#if OPENSSL_VERSION_NUMBER >= 0x10100000L && !defined(LIBRESSL_VERSION_NUMBER)
- if (!EVP_CIPHER_CTX_reset(ctx->ctx)) {
- EVP_CIPHER_CTX_free(ctx->ctx);
- ctx->ctx = NULL;
- }
-#else
- EVP_CIPHER_CTX_init(ctx->ctx);
-#endif
return 0;
}
diff --git a/Utilities/cmlibarchive/libarchive/archive_disk_acl_freebsd.c b/Utilities/cmlibarchive/libarchive/archive_disk_acl_freebsd.c
index aba41e5..ed4e7a7 100644
--- a/Utilities/cmlibarchive/libarchive/archive_disk_acl_freebsd.c
+++ b/Utilities/cmlibarchive/libarchive/archive_disk_acl_freebsd.c
@@ -319,7 +319,7 @@
static int
set_acl(struct archive *a, int fd, const char *name,
- struct archive_acl *abstract_acl,
+ struct archive_acl *abstract_acl, __LA_MODE_T mode,
int ae_requested_type, const char *tname)
{
int acl_type = 0;
@@ -364,6 +364,13 @@
return (ARCHIVE_FAILED);
}
+ if (acl_type == ACL_TYPE_DEFAULT && !S_ISDIR(mode)) {
+ errno = EINVAL;
+ archive_set_error(a, errno,
+ "Cannot set default ACL on non-directory");
+ return (ARCHIVE_WARN);
+ }
+
acl = acl_init(entries);
if (acl == (acl_t)NULL) {
archive_set_error(a, errno,
@@ -542,7 +549,10 @@
else if (acl_set_link_np(name, acl_type, acl) != 0)
#else
/* FreeBSD older than 8.0 */
- else if (acl_set_file(name, acl_type, acl) != 0)
+ else if (S_ISLNK(mode)) {
+ /* acl_set_file() follows symbolic links, skip */
+ ret = ARCHIVE_OK;
+ } else if (acl_set_file(name, acl_type, acl) != 0)
#endif
{
if (errno == EOPNOTSUPP) {
@@ -677,14 +687,14 @@
& ARCHIVE_ENTRY_ACL_TYPE_POSIX1E) != 0) {
if ((archive_acl_types(abstract_acl)
& ARCHIVE_ENTRY_ACL_TYPE_ACCESS) != 0) {
- ret = set_acl(a, fd, name, abstract_acl,
+ ret = set_acl(a, fd, name, abstract_acl, mode,
ARCHIVE_ENTRY_ACL_TYPE_ACCESS, "access");
if (ret != ARCHIVE_OK)
return (ret);
}
if ((archive_acl_types(abstract_acl)
& ARCHIVE_ENTRY_ACL_TYPE_DEFAULT) != 0)
- ret = set_acl(a, fd, name, abstract_acl,
+ ret = set_acl(a, fd, name, abstract_acl, mode,
ARCHIVE_ENTRY_ACL_TYPE_DEFAULT, "default");
/* Simultaneous POSIX.1e and NFSv4 is not supported */
@@ -693,7 +703,7 @@
#if ARCHIVE_ACL_FREEBSD_NFS4
else if ((archive_acl_types(abstract_acl) &
ARCHIVE_ENTRY_ACL_TYPE_NFS4) != 0) {
- ret = set_acl(a, fd, name, abstract_acl,
+ ret = set_acl(a, fd, name, abstract_acl, mode,
ARCHIVE_ENTRY_ACL_TYPE_NFS4, "nfs4");
}
#endif
diff --git a/Utilities/cmlibarchive/libarchive/archive_disk_acl_linux.c b/Utilities/cmlibarchive/libarchive/archive_disk_acl_linux.c
index 3928f3d..31d2705 100644
--- a/Utilities/cmlibarchive/libarchive/archive_disk_acl_linux.c
+++ b/Utilities/cmlibarchive/libarchive/archive_disk_acl_linux.c
@@ -343,6 +343,11 @@
return (ARCHIVE_FAILED);
}
+ if (S_ISLNK(mode)) {
+ /* Linux does not support RichACLs on symbolic links */
+ return (ARCHIVE_OK);
+ }
+
richacl = richacl_alloc(entries);
if (richacl == NULL) {
archive_set_error(a, errno,
@@ -455,7 +460,7 @@
#if ARCHIVE_ACL_LIBACL
static int
set_acl(struct archive *a, int fd, const char *name,
- struct archive_acl *abstract_acl,
+ struct archive_acl *abstract_acl, __LA_MODE_T mode,
int ae_requested_type, const char *tname)
{
int acl_type = 0;
@@ -488,6 +493,18 @@
return (ARCHIVE_FAILED);
}
+ if (S_ISLNK(mode)) {
+ /* Linux does not support ACLs on symbolic links */
+ return (ARCHIVE_OK);
+ }
+
+ if (acl_type == ACL_TYPE_DEFAULT && !S_ISDIR(mode)) {
+ errno = EINVAL;
+ archive_set_error(a, errno,
+ "Cannot set default ACL on non-directory");
+ return (ARCHIVE_WARN);
+ }
+
acl = acl_init(entries);
if (acl == (acl_t)NULL) {
archive_set_error(a, errno,
@@ -727,14 +744,14 @@
& ARCHIVE_ENTRY_ACL_TYPE_POSIX1E) != 0) {
if ((archive_acl_types(abstract_acl)
& ARCHIVE_ENTRY_ACL_TYPE_ACCESS) != 0) {
- ret = set_acl(a, fd, name, abstract_acl,
+ ret = set_acl(a, fd, name, abstract_acl, mode,
ARCHIVE_ENTRY_ACL_TYPE_ACCESS, "access");
if (ret != ARCHIVE_OK)
return (ret);
}
if ((archive_acl_types(abstract_acl)
& ARCHIVE_ENTRY_ACL_TYPE_DEFAULT) != 0)
- ret = set_acl(a, fd, name, abstract_acl,
+ ret = set_acl(a, fd, name, abstract_acl, mode,
ARCHIVE_ENTRY_ACL_TYPE_DEFAULT, "default");
}
#endif /* ARCHIVE_ACL_LIBACL */
diff --git a/Utilities/cmlibarchive/libarchive/archive_disk_acl_sunos.c b/Utilities/cmlibarchive/libarchive/archive_disk_acl_sunos.c
index b0f5dfa..0ef3ad5 100644
--- a/Utilities/cmlibarchive/libarchive/archive_disk_acl_sunos.c
+++ b/Utilities/cmlibarchive/libarchive/archive_disk_acl_sunos.c
@@ -443,7 +443,7 @@
static int
set_acl(struct archive *a, int fd, const char *name,
- struct archive_acl *abstract_acl,
+ struct archive_acl *abstract_acl, __LA_MODE_T mode,
int ae_requested_type, const char *tname)
{
aclent_t *aclent;
@@ -467,7 +467,6 @@
if (entries == 0)
return (ARCHIVE_OK);
-
switch (ae_requested_type) {
case ARCHIVE_ENTRY_ACL_TYPE_POSIX1E:
cmd = SETACL;
@@ -492,6 +491,12 @@
return (ARCHIVE_FAILED);
}
+ if (S_ISLNK(mode)) {
+ /* Skip ACLs on symbolic links */
+ ret = ARCHIVE_OK;
+ goto exit_free;
+ }
+
e = 0;
while (archive_acl_next(a, abstract_acl, ae_requested_type, &ae_type,
@@ -801,7 +806,7 @@
if ((archive_acl_types(abstract_acl)
& ARCHIVE_ENTRY_ACL_TYPE_POSIX1E) != 0) {
/* Solaris writes POSIX.1e access and default ACLs together */
- ret = set_acl(a, fd, name, abstract_acl,
+ ret = set_acl(a, fd, name, abstract_acl, mode,
ARCHIVE_ENTRY_ACL_TYPE_POSIX1E, "posix1e");
/* Simultaneous POSIX.1e and NFSv4 is not supported */
@@ -810,7 +815,7 @@
#if ARCHIVE_ACL_SUNOS_NFS4
else if ((archive_acl_types(abstract_acl) &
ARCHIVE_ENTRY_ACL_TYPE_NFS4) != 0) {
- ret = set_acl(a, fd, name, abstract_acl,
+ ret = set_acl(a, fd, name, abstract_acl, mode,
ARCHIVE_ENTRY_ACL_TYPE_NFS4, "nfs4");
}
#endif
diff --git a/Utilities/cmlibarchive/libarchive/archive_entry.h b/Utilities/cmlibarchive/libarchive/archive_entry.h
index 21e89d2..221ef80 100644
--- a/Utilities/cmlibarchive/libarchive/archive_entry.h
+++ b/Utilities/cmlibarchive/libarchive/archive_entry.h
@@ -30,7 +30,7 @@
#define ARCHIVE_ENTRY_H_INCLUDED
/* Note: Compiler will complain if this does not match archive.h! */
-#define ARCHIVE_VERSION_NUMBER 3005001
+#define ARCHIVE_VERSION_NUMBER 3006000
/*
* Note: archive_entry.h is for use outside of libarchive; the
@@ -99,7 +99,7 @@
#endif
/* Large file support for Android */
-#ifdef __ANDROID__
+#if defined(__LIBARCHIVE_BUILD) && defined(__ANDROID__)
#include "android_lf.h"
#endif
diff --git a/Utilities/cmlibarchive/libarchive/archive_getdate.c b/Utilities/cmlibarchive/libarchive/archive_getdate.c
index 6786d35..5b0b775 100644
--- a/Utilities/cmlibarchive/libarchive/archive_getdate.c
+++ b/Utilities/cmlibarchive/libarchive/archive_getdate.c
@@ -716,7 +716,7 @@
? 29 : 28;
/* Checking for 2038 bogusly assumes that time_t is 32 bits. But
I'm too lazy to try to check for time_t overflow in another way. */
- if (Year < EPOCH || Year > 2038
+ if (Year < EPOCH || Year >= 2038
|| Month < 1 || Month > 12
/* Lint fluff: "conversion from long may lose accuracy" */
|| Day < 1 || Day > DaysInMonth[(int)--Month]
diff --git a/Utilities/cmlibarchive/libarchive/archive_pack_dev.c b/Utilities/cmlibarchive/libarchive/archive_pack_dev.c
index f8286d8..d95444d 100644
--- a/Utilities/cmlibarchive/libarchive/archive_pack_dev.c
+++ b/Utilities/cmlibarchive/libarchive/archive_pack_dev.c
@@ -77,7 +77,7 @@
static pack_t pack_14_18;
static pack_t pack_8_24;
static pack_t pack_bsdos;
-static int compare_format(const void *, const void *);
+static int __LA_LIBC_CC compare_format(const void *, const void *);
static const char iMajorError[] = "invalid major number";
static const char iMinorError[] = "invalid minor number";
@@ -310,6 +310,7 @@
};
static int
+__LA_LIBC_CC
compare_format(const void *key, const void *element)
{
const char *name;
diff --git a/Utilities/cmlibarchive/libarchive/archive_pathmatch.c b/Utilities/cmlibarchive/libarchive/archive_pathmatch.c
index 619e2b6..0867a26 100644
--- a/Utilities/cmlibarchive/libarchive/archive_pathmatch.c
+++ b/Utilities/cmlibarchive/libarchive/archive_pathmatch.c
@@ -384,6 +384,8 @@
/* Empty pattern only matches the empty string. */
if (p == NULL || *p == '\0')
return (s == NULL || *s == '\0');
+ else if (s == NULL)
+ return (0);
/* Leading '^' anchors the start of the pattern. */
if (*p == '^') {
@@ -424,6 +426,8 @@
/* Empty pattern only matches the empty string. */
if (p == NULL || *p == L'\0')
return (s == NULL || *s == L'\0');
+ else if (s == NULL)
+ return (0);
/* Leading '^' anchors the start of the pattern. */
if (*p == L'^') {
diff --git a/Utilities/cmlibarchive/libarchive/archive_platform.h b/Utilities/cmlibarchive/libarchive/archive_platform.h
index 3273930..f87b423 100644
--- a/Utilities/cmlibarchive/libarchive/archive_platform.h
+++ b/Utilities/cmlibarchive/libarchive/archive_platform.h
@@ -69,8 +69,16 @@
* either Windows or Posix APIs. */
#if (defined(__WIN32__) || defined(_WIN32) || defined(__WIN32)) && !defined(__CYGWIN__)
#include "archive_windows.h"
+/* The C library on Windows specifies a calling convention for callback
+ * functions and exports; when we interact with them (capture pointers,
+ * call and pass function pointers) we need to match their calling
+ * convention.
+ * This only matters when libarchive is built with /Gr, /Gz or /Gv
+ * (which change the default calling convention.) */
+#define __LA_LIBC_CC __cdecl
#else
#define la_stat(path,stref) stat(path,stref)
+#define __LA_LIBC_CC
#endif
/*
@@ -148,6 +156,28 @@
#define INTMAX_MIN ((intmax_t)(~INTMAX_MAX))
#endif
+/* Some platforms lack the standard PRIxN/PRIdN definitions. */
+#if !HAVE_INTTYPES_H || !defined(PRIx32) || !defined(PRId32)
+#ifndef PRIx32
+#if SIZEOF_INT == 4
+#define PRIx32 "x"
+#elif SIZEOF_LONG == 4
+#define PRIx32 "lx"
+#else
+#error No suitable 32-bit unsigned integer type found for this platform
+#endif
+#endif // PRIx32
+#ifndef PRId32
+#if SIZEOF_INT == 4
+#define PRId32 "d"
+#elif SIZEOF_LONG == 4
+#define PRId32 "ld"
+#else
+#error No suitable 32-bit signed integer type found for this platform
+#endif
+#endif // PRId32
+#endif // !HAVE_INTTYPES_H || !defined(PRIx32) || !defined(PRId32)
+
/*
* If we can't restore metadata using a file descriptor, then
* for compatibility's sake, close files before trying to restore metadata.
diff --git a/Utilities/cmlibarchive/libarchive/archive_private.h b/Utilities/cmlibarchive/libarchive/archive_private.h
index 937a87b..b2a2cda 100644
--- a/Utilities/cmlibarchive/libarchive/archive_private.h
+++ b/Utilities/cmlibarchive/libarchive/archive_private.h
@@ -46,6 +46,13 @@
#define __LA_DEAD
#endif
+#if defined(__GNUC__) && (__GNUC__ > 2 || \
+ (__GNUC__ == 2 && __GNUC_MINOR__ >= 7))
+#define __LA_UNUSED __attribute__((__unused__))
+#else
+#define __LA_UNUSED
+#endif
+
#define ARCHIVE_WRITE_MAGIC (0xb0c5c0deU)
#define ARCHIVE_READ_MAGIC (0xdeb0c5U)
#define ARCHIVE_WRITE_DISK_MAGIC (0xc001b0c5U)
@@ -100,14 +107,11 @@
* Some public API functions depend on the "real" type of the
* archive object.
*/
- struct archive_vtable *vtable;
+ const struct archive_vtable *vtable;
int archive_format;
const char *archive_format_name;
- int compression_code; /* Currently active compression. */
- const char *compression_name;
-
/* Number of file entries processed. */
int file_count;
diff --git a/Utilities/cmlibarchive/libarchive/archive_read.c b/Utilities/cmlibarchive/libarchive/archive_read.c
index c59f051..45a38ae 100644
--- a/Utilities/cmlibarchive/libarchive/archive_read.c
+++ b/Utilities/cmlibarchive/libarchive/archive_read.c
@@ -58,7 +58,6 @@
static int choose_filters(struct archive_read *);
static int choose_format(struct archive_read *);
static int close_filters(struct archive_read *);
-static struct archive_vtable *archive_read_vtable(void);
static int64_t _archive_filter_bytes(struct archive *, int);
static int _archive_filter_code(struct archive *, int);
static const char *_archive_filter_name(struct archive *, int);
@@ -73,26 +72,18 @@
struct archive_entry *);
static int64_t advance_file_pointer(struct archive_read_filter *, int64_t);
-static struct archive_vtable *
-archive_read_vtable(void)
-{
- static struct archive_vtable av;
- static int inited = 0;
-
- if (!inited) {
- av.archive_filter_bytes = _archive_filter_bytes;
- av.archive_filter_code = _archive_filter_code;
- av.archive_filter_name = _archive_filter_name;
- av.archive_filter_count = _archive_filter_count;
- av.archive_read_data_block = _archive_read_data_block;
- av.archive_read_next_header = _archive_read_next_header;
- av.archive_read_next_header2 = _archive_read_next_header2;
- av.archive_free = _archive_read_free;
- av.archive_close = _archive_read_close;
- inited = 1;
- }
- return (&av);
-}
+static const struct archive_vtable
+archive_read_vtable = {
+ .archive_filter_bytes = _archive_filter_bytes,
+ .archive_filter_code = _archive_filter_code,
+ .archive_filter_name = _archive_filter_name,
+ .archive_filter_count = _archive_filter_count,
+ .archive_read_data_block = _archive_read_data_block,
+ .archive_read_next_header = _archive_read_next_header,
+ .archive_read_next_header2 = _archive_read_next_header2,
+ .archive_free = _archive_read_free,
+ .archive_close = _archive_read_close,
+};
/*
* Allocate, initialize and return a struct archive object.
@@ -109,7 +100,7 @@
a->archive.state = ARCHIVE_STATE_NEW;
a->entry = archive_entry_new2(&a->archive);
- a->archive.vtable = archive_read_vtable();
+ a->archive.vtable = &archive_read_vtable;
a->passphrases.last = &a->passphrases.first;
@@ -245,18 +236,17 @@
}
static int
-client_close_proxy(struct archive_read_filter *self)
+read_client_close_proxy(struct archive_read *a)
{
int r = ARCHIVE_OK, r2;
unsigned int i;
- if (self->archive->client.closer == NULL)
+ if (a->client.closer == NULL)
return (r);
- for (i = 0; i < self->archive->client.nodes; i++)
+ for (i = 0; i < a->client.nodes; i++)
{
- r2 = (self->archive->client.closer)
- ((struct archive *)self->archive,
- self->archive->client.dataset[i].data);
+ r2 = (a->client.closer)
+ ((struct archive *)a, a->client.dataset[i].data);
if (r > r2)
r = r2;
}
@@ -264,6 +254,12 @@
}
static int
+client_close_proxy(struct archive_read_filter *self)
+{
+ return read_client_close_proxy(self->archive);
+}
+
+static int
client_open_proxy(struct archive_read_filter *self)
{
int r = ARCHIVE_OK;
@@ -298,9 +294,7 @@
r1 = (self->archive->client.closer)
((struct archive *)self->archive, self->data);
self->data = data2;
- if (self->archive->client.opener != NULL)
- r2 = (self->archive->client.opener)
- ((struct archive *)self->archive, self->data);
+ r2 = client_open_proxy(self);
}
return (r1 < r2) ? r1 : r2;
}
@@ -457,13 +451,18 @@
return archive_read_add_callback_data(_a, client_data, 0);
}
+static const struct archive_read_filter_vtable
+none_reader_vtable = {
+ .read = client_read_proxy,
+ .close = client_close_proxy,
+};
+
int
archive_read_open1(struct archive *_a)
{
struct archive_read *a = (struct archive_read *)_a;
struct archive_read_filter *filter, *tmp;
int slot, e = ARCHIVE_OK;
- unsigned int i;
archive_check_magic(_a, ARCHIVE_READ_MAGIC, ARCHIVE_STATE_NEW,
"archive_read_open");
@@ -481,11 +480,7 @@
e = (a->client.opener)(&a->archive, a->client.dataset[0].data);
if (e != 0) {
/* If the open failed, call the closer to clean up. */
- if (a->client.closer) {
- for (i = 0; i < a->client.nodes; i++)
- (a->client.closer)(&a->archive,
- a->client.dataset[i].data);
- }
+ read_client_close_proxy(a);
return (e);
}
}
@@ -497,14 +492,11 @@
filter->upstream = NULL;
filter->archive = a;
filter->data = a->client.dataset[0].data;
- filter->open = client_open_proxy;
- filter->read = client_read_proxy;
- filter->skip = client_skip_proxy;
- filter->seek = client_seek_proxy;
- filter->close = client_close_proxy;
- filter->sswitch = client_switch_proxy;
+ filter->vtable = &none_reader_vtable;
filter->name = "none";
filter->code = ARCHIVE_FILTER_NONE;
+ filter->can_skip = 1;
+ filter->can_seek = 1;
a->client.dataset[0].begin_position = 0;
if (!a->filter || !a->bypass_filter_bidding)
@@ -570,12 +562,12 @@
bidder = a->bidders;
for (i = 0; i < number_bidders; i++, bidder++) {
- if (bidder->bid != NULL) {
- bid = (bidder->bid)(bidder, a->filter);
- if (bid > best_bid) {
- best_bid = bid;
- best_bidder = bidder;
- }
+ if (bidder->vtable == NULL)
+ continue;
+ bid = (bidder->vtable->bid)(bidder, a->filter);
+ if (bid > best_bid) {
+ best_bid = bid;
+ best_bidder = bidder;
}
}
@@ -587,8 +579,6 @@
__archive_read_free_filters(a);
return (ARCHIVE_FATAL);
}
- a->archive.compression_name = a->filter->name;
- a->archive.compression_code = a->filter->code;
return (ARCHIVE_OK);
}
@@ -600,7 +590,7 @@
filter->archive = a;
filter->upstream = a->filter;
a->filter = filter;
- r = (best_bidder->init)(a->filter);
+ r = (best_bidder->vtable->init)(a->filter);
if (r != ARCHIVE_OK) {
__archive_read_free_filters(a);
return (ARCHIVE_FATAL);
@@ -614,10 +604,9 @@
int
__archive_read_header(struct archive_read *a, struct archive_entry *entry)
{
- if (a->filter->read_header)
- return a->filter->read_header(a->filter, entry);
- else
+ if (!a->filter->vtable->read_header)
return (ARCHIVE_OK);
+ return a->filter->vtable->read_header(a->filter, entry);
}
/*
@@ -1006,8 +995,8 @@
/* Close each filter in the pipeline. */
while (f != NULL) {
struct archive_read_filter *t = f->upstream;
- if (!f->closed && f->close != NULL) {
- int r1 = (f->close)(f);
+ if (!f->closed && f->vtable != NULL) {
+ int r1 = (f->vtable->close)(f);
f->closed = 1;
if (r1 < r)
r = r1;
@@ -1112,11 +1101,10 @@
/* Release the bidder objects. */
n = sizeof(a->bidders)/sizeof(a->bidders[0]);
for (i = 0; i < n; i++) {
- if (a->bidders[i].free != NULL) {
- int r1 = (a->bidders[i].free)(&a->bidders[i]);
- if (r1 < r)
- r = r1;
- }
+ if (a->bidders[i].vtable == NULL ||
+ a->bidders[i].vtable->free == NULL)
+ continue;
+ (a->bidders[i].vtable->free)(&a->bidders[i]);
}
/* Release passphrase list. */
@@ -1241,19 +1229,35 @@
* initialization functions.
*/
int
-__archive_read_get_bidder(struct archive_read *a,
- struct archive_read_filter_bidder **bidder)
+__archive_read_register_bidder(struct archive_read *a,
+ void *bidder_data,
+ const char *name,
+ const struct archive_read_filter_bidder_vtable *vtable)
{
+ struct archive_read_filter_bidder *bidder;
int i, number_slots;
+ archive_check_magic(&a->archive, ARCHIVE_READ_MAGIC,
+ ARCHIVE_STATE_NEW, "__archive_read_register_bidder");
+
number_slots = sizeof(a->bidders) / sizeof(a->bidders[0]);
for (i = 0; i < number_slots; i++) {
- if (a->bidders[i].bid == NULL) {
- memset(a->bidders + i, 0, sizeof(a->bidders[0]));
- *bidder = (a->bidders + i);
- return (ARCHIVE_OK);
+ if (a->bidders[i].vtable != NULL)
+ continue;
+ memset(a->bidders + i, 0, sizeof(a->bidders[0]));
+ bidder = (a->bidders + i);
+ bidder->data = bidder_data;
+ bidder->name = name;
+ bidder->vtable = vtable;
+ if (bidder->vtable->bid == NULL || bidder->vtable->init == NULL) {
+ archive_set_error(&a->archive, ARCHIVE_ERRNO_PROGRAMMER,
+ "Internal error: "
+ "no bid/init for filter bidder");
+ return (ARCHIVE_FATAL);
}
+
+ return (ARCHIVE_OK);
}
archive_set_error(&a->archive, ENOMEM,
@@ -1382,7 +1386,7 @@
*avail = 0;
return (NULL);
}
- bytes_read = (filter->read)(filter,
+ bytes_read = (filter->vtable->read)(filter,
&filter->client_buff);
if (bytes_read < 0) { /* Read error. */
filter->client_total = filter->client_avail = 0;
@@ -1561,8 +1565,8 @@
return (total_bytes_skipped);
/* If there's an optimized skip function, use it. */
- if (filter->skip != NULL) {
- bytes_skipped = (filter->skip)(filter, request);
+ if (filter->can_skip != 0) {
+ bytes_skipped = client_skip_proxy(filter, request);
if (bytes_skipped < 0) { /* error */
filter->fatal = 1;
return (bytes_skipped);
@@ -1576,7 +1580,7 @@
/* Use ordinary reads as necessary to complete the request. */
for (;;) {
- bytes_read = (filter->read)(filter, &filter->client_buff);
+ bytes_read = (filter->vtable->read)(filter, &filter->client_buff);
if (bytes_read < 0) {
filter->client_buff = NULL;
filter->fatal = 1;
@@ -1631,7 +1635,7 @@
if (filter->closed || filter->fatal)
return (ARCHIVE_FATAL);
- if (filter->seek == NULL)
+ if (filter->can_seek == 0)
return (ARCHIVE_FAILED);
client = &(filter->archive->client);
diff --git a/Utilities/cmlibarchive/libarchive/archive_read_append_filter.c b/Utilities/cmlibarchive/libarchive/archive_read_append_filter.c
index da7c55b..25dc4b2 100644
--- a/Utilities/cmlibarchive/libarchive/archive_read_append_filter.c
+++ b/Utilities/cmlibarchive/libarchive/archive_read_append_filter.c
@@ -135,7 +135,7 @@
filter->archive = a;
filter->upstream = a->filter;
a->filter = filter;
- r2 = (bidder->init)(a->filter);
+ r2 = (bidder->vtable->init)(a->filter);
if (r2 != ARCHIVE_OK) {
__archive_read_free_filters(a);
return (ARCHIVE_FATAL);
@@ -192,7 +192,7 @@
filter->archive = a;
filter->upstream = a->filter;
a->filter = filter;
- r = (bidder->init)(a->filter);
+ r = (bidder->vtable->init)(a->filter);
if (r != ARCHIVE_OK) {
__archive_read_free_filters(a);
return (ARCHIVE_FATAL);
diff --git a/Utilities/cmlibarchive/libarchive/archive_read_disk.3 b/Utilities/cmlibarchive/libarchive/archive_read_disk.3
index 82d6a5c..8b568d7 100644
--- a/Utilities/cmlibarchive/libarchive/archive_read_disk.3
+++ b/Utilities/cmlibarchive/libarchive/archive_read_disk.3
@@ -29,6 +29,8 @@
.Os
.Sh NAME
.Nm archive_read_disk_new ,
+.Nm archive_read_disk_open ,
+.Nm archive_read_disk_open_w ,
.Nm archive_read_disk_set_behavior ,
.Nm archive_read_disk_set_symlink_logical ,
.Nm archive_read_disk_set_symlink_physical ,
@@ -38,7 +40,14 @@
.Nm archive_read_disk_uname ,
.Nm archive_read_disk_set_uname_lookup ,
.Nm archive_read_disk_set_gname_lookup ,
-.Nm archive_read_disk_set_standard_lookup
+.Nm archive_read_disk_set_standard_lookup ,
+.Nm archive_read_disk_descend ,
+.Nm archive_read_disk_can_descend ,
+.Nm archive_read_disk_current_filesystem ,
+.Nm archive_read_disk_current_filesystem_is_synthetic ,
+.Nm archive_read_disk_current_filesystem_is_remote ,
+.Nm archive_read_disk_set_matching ,
+.Nm archive_read_disk_set_metadata_filter_callback ,
.Nd functions for reading objects from disk
.Sh LIBRARY
Streaming Archive Library (libarchive, -larchive)
@@ -47,6 +56,10 @@
.Ft struct archive *
.Fn archive_read_disk_new "void"
.Ft int
+.Fn archive_read_disk_open "struct archive *" "const char *"
+.Ft int
+.Fn archive_read_disk_open_w "struct archive *" "const wchar_t *"
+.Ft int
.Fn archive_read_disk_set_behavior "struct archive *" "int"
.Ft int
.Fn archive_read_disk_set_symlink_logical "struct archive *"
@@ -81,6 +94,29 @@
.Fa "int fd"
.Fa "const struct stat *"
.Fc
+.Ft int
+.Fn archive_read_disk_descend "struct archive *"
+.Ft int
+.Fn archive_read_disk_can_descend "struct archive *"
+.Ft int
+.Fn archive_read_disk_current_filesystem "struct archive *"
+.Ft int
+.Fn archive_read_disk_current_filesystem_is_synthetic "struct archive *"
+.Ft int
+.Fn archive_read_disk_current_filesystem_is_remote "struct archive *"
+.Ft int
+.Fo archive_read_disk_set_matching
+.Fa "struct archive *"
+.Fa "struct archive *"
+.Fa "void (*excluded_func)(struct archive *, void *, struct archive entry *)"
+.Fa "void *"
+.Fc
+.Ft int
+.Fo archive_read_disk_set_metadata_filter_callback
+.Fa "struct archive *"
+.Fa "int (*metadata_filter_func)(struct archive *, void*, struct archive_entry *)"
+.Fa "void *"
+.Fc
.Sh DESCRIPTION
These functions provide an API for reading information about
objects on disk.
@@ -92,6 +128,14 @@
Allocates and initializes a
.Tn struct archive
object suitable for reading object information from disk.
+.It Fn archive_read_disk_open
+Opens the file or directory from the given path and prepares the
+.Tn struct archive
+to read it from disk.
+.It Fn archive_read_disk_open_w
+Opens the file or directory from the given path as a wide character string and prepares the
+.Tn struct archive
+to read it from disk.
.It Fn archive_read_disk_set_behavior
Configures various behavior options when reading entries from disk.
The flags field consists of a bitwise OR of one or more of the
@@ -137,6 +181,9 @@
.It Cm ARCHIVE_READDISK_RESTORE_ATIME
Restore access time of traversed files.
By default, access time of traversed files is not restored.
+.It Cm ARCHIVE_READDISK_NO_SPARSE
+Do not read sparse file information.
+By default, sparse file information is read from disk.
.El
.It Xo
.Fn archive_read_disk_set_symlink_logical ,
@@ -221,6 +268,37 @@
This affects the file ownership fields and ACL values in the
.Tn struct archive_entry
object.
+.It Fn archive_read_disk_descend
+If the current entry can be descended, this function will mark the directory as the next entry for
+.Xr archive_read_header 3
+to visit.
+.It Fn archive_read_disk_can_descend
+Returns 1 if the current entry is an unvisited directory and 0 otherwise.
+.It Fn archive_read_disk_current_filesystem
+Returns the index of the most recent filesystem entry that has been visited through archive_read_disk
+.It Fn archive_read_disk_current_filesystem_is_synthetic
+Returns 1 if the current filesystem is a virtual filesystem. Returns 0 if the current filesystem is not a virtual filesystem. Returns -1 if it is unknown.
+.It Fn archive_read_disk_current_filesystem_is_remote
+Returns 1 if the current filesystem is a remote filesystem. Returns 0 if the current filesystem is not a remote filesystem. Returns -1 if it is unknown.
+.It Fn archive_read_disk_set_matching
+Allows the caller to set
+.Tn struct archive
+*_ma to compare each entry during
+.Xr archive_read_header 3
+calls. If matched based on calls to
+.Tn archive_match_path_excluded ,
+.Tn archive_match_time_excluded ,
+or
+.Tn archive_match_owner_excluded ,
+then the callback function specified by the _excluded_func parameter will execute. This function will recieve data provided to the fourth parameter, void *_client_data.
+.It Fn archive_read_disk_set_metadata_filter_callback
+Allows the caller to set a callback function during calls to
+.Xr archive_read_header 3
+to filter out metadata for each entry. The callback function recieves the
+.Tn struct archive
+object, void* custom filter data, and the
+.Tn struct archive_entry .
+If the callback function returns an error, ARCHIVE_RETRY will be returned and the entry will not be further processed.
.El
More information about the
.Va struct archive
diff --git a/Utilities/cmlibarchive/libarchive/archive_read_disk_entry_from_file.c b/Utilities/cmlibarchive/libarchive/archive_read_disk_entry_from_file.c
index 9c9cf38..ab0270b 100644
--- a/Utilities/cmlibarchive/libarchive/archive_read_disk_entry_from_file.c
+++ b/Utilities/cmlibarchive/libarchive/archive_read_disk_entry_from_file.c
@@ -303,9 +303,11 @@
if (r1 < r)
r = r1;
}
- r1 = setup_sparse(a, entry, &fd);
- if (r1 < r)
- r = r1;
+ if ((a->flags & ARCHIVE_READDISK_NO_SPARSE) == 0) {
+ r1 = setup_sparse(a, entry, &fd);
+ if (r1 < r)
+ r = r1;
+ }
/* If we opened the file earlier in this function, close it. */
if (initial_fd != fd)
diff --git a/Utilities/cmlibarchive/libarchive/archive_read_disk_posix.c b/Utilities/cmlibarchive/libarchive/archive_read_disk_posix.c
index 2898206..d0e1f35 100644
--- a/Utilities/cmlibarchive/libarchive/archive_read_disk_posix.c
+++ b/Utilities/cmlibarchive/libarchive/archive_read_disk_posix.c
@@ -369,22 +369,14 @@
static int tree_dup(int);
-static struct archive_vtable *
-archive_read_disk_vtable(void)
-{
- static struct archive_vtable av;
- static int inited = 0;
-
- if (!inited) {
- av.archive_free = _archive_read_free;
- av.archive_close = _archive_read_close;
- av.archive_read_data_block = _archive_read_data_block;
- av.archive_read_next_header = _archive_read_next_header;
- av.archive_read_next_header2 = _archive_read_next_header2;
- inited = 1;
- }
- return (&av);
-}
+static const struct archive_vtable
+archive_read_disk_vtable = {
+ .archive_free = _archive_read_free,
+ .archive_close = _archive_read_close,
+ .archive_read_data_block = _archive_read_data_block,
+ .archive_read_next_header = _archive_read_next_header,
+ .archive_read_next_header2 = _archive_read_next_header2,
+};
const char *
archive_read_disk_gname(struct archive *_a, la_int64_t gid)
@@ -461,7 +453,7 @@
return (NULL);
a->archive.magic = ARCHIVE_READ_DISK_MAGIC;
a->archive.state = ARCHIVE_STATE_NEW;
- a->archive.vtable = archive_read_disk_vtable();
+ a->archive.vtable = &archive_read_disk_vtable;
a->entry = archive_entry_new2(&a->archive);
a->lookup_uname = trivial_lookup_uname;
a->lookup_gname = trivial_lookup_gname;
@@ -1290,7 +1282,7 @@
ARCHIVE_STATE_HEADER | ARCHIVE_STATE_DATA,
"archive_read_disk_descend");
- if (t->visit_type != TREE_REGULAR || !t->descend)
+ if (!archive_read_disk_can_descend(_a))
return (ARCHIVE_OK);
/*
@@ -1522,8 +1514,40 @@
}
#endif
-#if defined(HAVE_STATFS) && defined(HAVE_FSTATFS) && defined(MNT_LOCAL) \
- && !defined(ST_LOCAL)
+#if defined(HAVE_STATVFS)
+static inline __LA_UNUSED void
+set_statvfs_transfer_size(struct filesystem *fs, const struct statvfs *sfs)
+{
+ fs->xfer_align = sfs->f_frsize > 0 ? (long)sfs->f_frsize : -1;
+ fs->max_xfer_size = -1;
+#if defined(HAVE_STRUCT_STATVFS_F_IOSIZE)
+ fs->min_xfer_size = sfs->f_iosize > 0 ? (long)sfs->f_iosize : -1;
+ fs->incr_xfer_size = sfs->f_iosize > 0 ? (long)sfs->f_iosize : -1;
+#else
+ fs->min_xfer_size = sfs->f_bsize > 0 ? (long)sfs->f_bsize : -1;
+ fs->incr_xfer_size = sfs->f_bsize > 0 ? (long)sfs->f_bsize : -1;
+#endif
+}
+#endif
+
+#if defined(HAVE_STRUCT_STATFS)
+static inline __LA_UNUSED void
+set_statfs_transfer_size(struct filesystem *fs, const struct statfs *sfs)
+{
+ fs->xfer_align = sfs->f_bsize > 0 ? (long)sfs->f_bsize : -1;
+ fs->max_xfer_size = -1;
+#if defined(HAVE_STRUCT_STATFS_F_IOSIZE)
+ fs->min_xfer_size = sfs->f_iosize > 0 ? (long)sfs->f_iosize : -1;
+ fs->incr_xfer_size = sfs->f_iosize > 0 ? (long)sfs->f_iosize : -1;
+#else
+ fs->min_xfer_size = sfs->f_bsize > 0 ? (long)sfs->f_bsize : -1;
+ fs->incr_xfer_size = sfs->f_bsize > 0 ? (long)sfs->f_bsize : -1;
+#endif
+}
+#endif
+
+#if defined(HAVE_STRUCT_STATFS) && defined(HAVE_STATFS) && \
+ defined(HAVE_FSTATFS) && defined(MNT_LOCAL) && !defined(ST_LOCAL)
/*
* Gather current filesystem properties on FreeBSD, OpenBSD and Mac OS X.
@@ -1593,10 +1617,7 @@
return (ARCHIVE_FAILED);
} else if (xr == 1) {
/* pathconf(_PC_REX_*) operations are not supported. */
- t->current_filesystem->xfer_align = sfs.f_bsize;
- t->current_filesystem->max_xfer_size = -1;
- t->current_filesystem->min_xfer_size = sfs.f_iosize;
- t->current_filesystem->incr_xfer_size = sfs.f_iosize;
+ set_statfs_transfer_size(t->current_filesystem, &sfs);
}
if (sfs.f_flags & MNT_LOCAL)
t->current_filesystem->remote = 0;
@@ -1688,15 +1709,7 @@
} else if (xr == 1) {
/* Usually come here unless NetBSD supports _PC_REC_XFER_ALIGN
* for pathconf() function. */
- t->current_filesystem->xfer_align = svfs.f_frsize;
- t->current_filesystem->max_xfer_size = -1;
-#if defined(HAVE_STRUCT_STATVFS_F_IOSIZE)
- t->current_filesystem->min_xfer_size = svfs.f_iosize;
- t->current_filesystem->incr_xfer_size = svfs.f_iosize;
-#else
- t->current_filesystem->min_xfer_size = svfs.f_bsize;
- t->current_filesystem->incr_xfer_size = svfs.f_bsize;
-#endif
+ set_statvfs_transfer_size(t->current_filesystem, &svfs);
}
if (svfs.f_flag & ST_LOCAL)
t->current_filesystem->remote = 0;
@@ -1803,15 +1816,9 @@
} else if (xr == 1) {
/* pathconf(_PC_REX_*) operations are not supported. */
#if defined(HAVE_STATVFS)
- t->current_filesystem->xfer_align = svfs.f_frsize;
- t->current_filesystem->max_xfer_size = -1;
- t->current_filesystem->min_xfer_size = svfs.f_bsize;
- t->current_filesystem->incr_xfer_size = svfs.f_bsize;
+ set_statvfs_transfer_size(t->current_filesystem, &svfs);
#else
- t->current_filesystem->xfer_align = sfs.f_frsize;
- t->current_filesystem->max_xfer_size = -1;
- t->current_filesystem->min_xfer_size = sfs.f_bsize;
- t->current_filesystem->incr_xfer_size = sfs.f_bsize;
+ set_statfs_transfer_size(t->current_filesystem, &sfs);
#endif
}
switch (sfs.f_type) {
@@ -1918,10 +1925,7 @@
return (ARCHIVE_FAILED);
} else if (xr == 1) {
/* pathconf(_PC_REX_*) operations are not supported. */
- t->current_filesystem->xfer_align = svfs.f_frsize;
- t->current_filesystem->max_xfer_size = -1;
- t->current_filesystem->min_xfer_size = svfs.f_bsize;
- t->current_filesystem->incr_xfer_size = svfs.f_bsize;
+ set_statvfs_transfer_size(t->current_filesystem, &svfs);
}
#if defined(ST_NOATIME)
diff --git a/Utilities/cmlibarchive/libarchive/archive_read_disk_windows.c b/Utilities/cmlibarchive/libarchive/archive_read_disk_windows.c
index fdd376f..ea32e2a 100644
--- a/Utilities/cmlibarchive/libarchive/archive_read_disk_windows.c
+++ b/Utilities/cmlibarchive/libarchive/archive_read_disk_windows.c
@@ -449,22 +449,14 @@
return;
}
-static struct archive_vtable *
-archive_read_disk_vtable(void)
-{
- static struct archive_vtable av;
- static int inited = 0;
-
- if (!inited) {
- av.archive_free = _archive_read_free;
- av.archive_close = _archive_read_close;
- av.archive_read_data_block = _archive_read_data_block;
- av.archive_read_next_header = _archive_read_next_header;
- av.archive_read_next_header2 = _archive_read_next_header2;
- inited = 1;
- }
- return (&av);
-}
+static const struct archive_vtable
+archive_read_disk_vtable = {
+ .archive_free = _archive_read_free,
+ .archive_close = _archive_read_close,
+ .archive_read_data_block = _archive_read_data_block,
+ .archive_read_next_header = _archive_read_next_header,
+ .archive_read_next_header2 = _archive_read_next_header2,
+};
const char *
archive_read_disk_gname(struct archive *_a, la_int64_t gid)
@@ -541,7 +533,7 @@
return (NULL);
a->archive.magic = ARCHIVE_READ_DISK_MAGIC;
a->archive.state = ARCHIVE_STATE_NEW;
- a->archive.vtable = archive_read_disk_vtable();
+ a->archive.vtable = &archive_read_disk_vtable;
a->entry = archive_entry_new2(&a->archive);
a->lookup_uname = trivial_lookup_uname;
a->lookup_gname = trivial_lookup_gname;
@@ -1090,9 +1082,11 @@
}
/* Find sparse data from the disk. */
- if (archive_entry_hardlink(entry) == NULL &&
- (st->dwFileAttributes & FILE_ATTRIBUTE_SPARSE_FILE) != 0)
- r = setup_sparse_from_disk(a, entry, t->entry_fh);
+ if ((a->flags & ARCHIVE_READDISK_NO_SPARSE) == 0) {
+ if (archive_entry_hardlink(entry) == NULL &&
+ (st->dwFileAttributes & FILE_ATTRIBUTE_SPARSE_FILE) != 0)
+ r = setup_sparse_from_disk(a, entry, t->entry_fh);
+ }
}
return (r);
}
@@ -1300,7 +1294,7 @@
ARCHIVE_STATE_HEADER | ARCHIVE_STATE_DATA,
"archive_read_disk_descend");
- if (t->visit_type != TREE_REGULAR || !t->descend)
+ if (!archive_read_disk_can_descend(_a))
return (ARCHIVE_OK);
if (tree_current_is_physical_dir(t)) {
@@ -1844,7 +1838,7 @@
continue;
return (r);
} else {
- HANDLE h = FindFirstFileW(d, &t->_findData);
+ HANDLE h = FindFirstFileW(t->stack->full_path.s, &t->_findData);
if (h == INVALID_HANDLE_VALUE) {
la_dosmaperr(GetLastError());
t->tree_errno = errno;
@@ -2371,9 +2365,11 @@
return (ARCHIVE_OK);
}
- r = setup_sparse_from_disk(a, entry, h);
- if (fd < 0)
- CloseHandle(h);
+ if ((a->flags & ARCHIVE_READDISK_NO_SPARSE) == 0) {
+ r = setup_sparse_from_disk(a, entry, h);
+ if (fd < 0)
+ CloseHandle(h);
+ }
return (r);
}
diff --git a/Utilities/cmlibarchive/libarchive/archive_read_private.h b/Utilities/cmlibarchive/libarchive/archive_read_private.h
index c842e6f..383405d 100644
--- a/Utilities/cmlibarchive/libarchive/archive_read_private.h
+++ b/Utilities/cmlibarchive/libarchive/archive_read_private.h
@@ -42,6 +42,16 @@
struct archive_read_filter_bidder;
struct archive_read_filter;
+struct archive_read_filter_bidder_vtable {
+ /* Taste the upstream filter to see if we handle this. */
+ int (*bid)(struct archive_read_filter_bidder *,
+ struct archive_read_filter *);
+ /* Initialize a newly-created filter. */
+ int (*init)(struct archive_read_filter *);
+ /* Release the bidder's configuration data. */
+ void (*free)(struct archive_read_filter_bidder *);
+};
+
/*
* How bidding works for filters:
* * The bid manager initializes the client-provided reader as the
@@ -62,16 +72,16 @@
void *data;
/* Name of the filter */
const char *name;
- /* Taste the upstream filter to see if we handle this. */
- int (*bid)(struct archive_read_filter_bidder *,
- struct archive_read_filter *);
- /* Initialize a newly-created filter. */
- int (*init)(struct archive_read_filter *);
- /* Set an option for the filter bidder. */
- int (*options)(struct archive_read_filter_bidder *,
- const char *key, const char *value);
- /* Release the bidder's configuration data. */
- int (*free)(struct archive_read_filter_bidder *);
+ const struct archive_read_filter_bidder_vtable *vtable;
+};
+
+struct archive_read_filter_vtable {
+ /* Return next block. */
+ ssize_t (*read)(struct archive_read_filter *, const void **);
+ /* Close (just this filter) and free(self). */
+ int (*close)(struct archive_read_filter *self);
+ /* Read any header metadata if available. */
+ int (*read_header)(struct archive_read_filter *self, struct archive_entry *entry);
};
/*
@@ -86,25 +96,14 @@
struct archive_read_filter_bidder *bidder; /* My bidder. */
struct archive_read_filter *upstream; /* Who I read from. */
struct archive_read *archive; /* Associated archive. */
- /* Open a block for reading */
- int (*open)(struct archive_read_filter *self);
- /* Return next block. */
- ssize_t (*read)(struct archive_read_filter *, const void **);
- /* Skip forward this many bytes. */
- int64_t (*skip)(struct archive_read_filter *self, int64_t request);
- /* Seek to an absolute location. */
- int64_t (*seek)(struct archive_read_filter *self, int64_t offset, int whence);
- /* Close (just this filter) and free(self). */
- int (*close)(struct archive_read_filter *self);
- /* Function that handles switching from reading one block to the next/prev */
- int (*sswitch)(struct archive_read_filter *self, unsigned int iindex);
- /* Read any header metadata if available. */
- int (*read_header)(struct archive_read_filter *self, struct archive_entry *entry);
+ const struct archive_read_filter_vtable *vtable;
/* My private data. */
void *data;
const char *name;
int code;
+ int can_skip;
+ int can_seek;
/* Used by reblocking logic. */
char *buffer;
@@ -242,8 +241,10 @@
int (*format_capabilities)(struct archive_read *),
int (*has_encrypted_entries)(struct archive_read *));
-int __archive_read_get_bidder(struct archive_read *a,
- struct archive_read_filter_bidder **bidder);
+int __archive_read_register_bidder(struct archive_read *a,
+ void *bidder_data,
+ const char *name,
+ const struct archive_read_filter_bidder_vtable *vtable);
const void *__archive_read_ahead(struct archive_read *, size_t, ssize_t *);
const void *__archive_read_filter_ahead(struct archive_read_filter *,
diff --git a/Utilities/cmlibarchive/libarchive/archive_read_set_options.3 b/Utilities/cmlibarchive/libarchive/archive_read_set_options.3
index 78d9999..b2db4cb 100644
--- a/Utilities/cmlibarchive/libarchive/archive_read_set_options.3
+++ b/Utilities/cmlibarchive/libarchive/archive_read_set_options.3
@@ -188,9 +188,18 @@
.El
.It Format cpio
.Bl -tag -compact -width indent
+.It Cm compat-2x
+Libarchive 2.x incorrectly encoded Unicode filenames on
+some platforms.
+This option mimics the libarchive 2.x filename handling
+so that such archives can be read correctly.
.It Cm hdrcharset
The value is used as a character set name that will be
used when translating file names.
+.It Cm pwb
+When reading a binary CPIO archive, assume that it is
+in the original PWB cpio format, and handle file mode
+bits accordingly. The default is to assume v7 format.
.El
.It Format iso9660
.Bl -tag -compact -width indent
diff --git a/Utilities/cmlibarchive/libarchive/archive_read_set_options.c b/Utilities/cmlibarchive/libarchive/archive_read_set_options.c
index 2e2eea6..2bd9b81 100644
--- a/Utilities/cmlibarchive/libarchive/archive_read_set_options.c
+++ b/Utilities/cmlibarchive/libarchive/archive_read_set_options.c
@@ -112,37 +112,15 @@
archive_set_filter_option(struct archive *_a, const char *m, const char *o,
const char *v)
{
- struct archive_read *a = (struct archive_read *)_a;
- struct archive_read_filter *filter;
- struct archive_read_filter_bidder *bidder;
- int r, rv = ARCHIVE_WARN, matched_modules = 0;
+ (void)_a; /* UNUSED */
+ (void)o; /* UNUSED */
+ (void)v; /* UNUSED */
- for (filter = a->filter; filter != NULL; filter = filter->upstream) {
- bidder = filter->bidder;
- if (bidder == NULL)
- continue;
- if (bidder->options == NULL)
- /* This bidder does not support option */
- continue;
- if (m != NULL) {
- if (strcmp(filter->name, m) != 0)
- continue;
- ++matched_modules;
- }
-
- r = bidder->options(bidder, o, v);
-
- if (r == ARCHIVE_FATAL)
- return (ARCHIVE_FATAL);
-
- if (r == ARCHIVE_OK)
- rv = ARCHIVE_OK;
- }
/* If the filter name didn't match, return a special code for
* _archive_set_option[s]. */
- if (m != NULL && matched_modules == 0)
+ if (m != NULL)
return ARCHIVE_WARN - 1;
- return (rv);
+ return ARCHIVE_WARN;
}
static int
diff --git a/Utilities/cmlibarchive/libarchive/archive_read_support_filter_bzip2.c b/Utilities/cmlibarchive/libarchive/archive_read_support_filter_bzip2.c
index 5333d47..a5243af 100644
--- a/Utilities/cmlibarchive/libarchive/archive_read_support_filter_bzip2.c
+++ b/Utilities/cmlibarchive/libarchive/archive_read_support_filter_bzip2.c
@@ -70,7 +70,6 @@
*/
static int bzip2_reader_bid(struct archive_read_filter_bidder *, struct archive_read_filter *);
static int bzip2_reader_init(struct archive_read_filter *);
-static int bzip2_reader_free(struct archive_read_filter_bidder *);
#if ARCHIVE_VERSION_NUMBER < 4000000
/* Deprecated; remove in libarchive 4.0 */
@@ -81,24 +80,21 @@
}
#endif
+static const struct archive_read_filter_bidder_vtable
+bzip2_bidder_vtable = {
+ .bid = bzip2_reader_bid,
+ .init = bzip2_reader_init,
+};
+
int
archive_read_support_filter_bzip2(struct archive *_a)
{
struct archive_read *a = (struct archive_read *)_a;
- struct archive_read_filter_bidder *reader;
- archive_check_magic(_a, ARCHIVE_READ_MAGIC,
- ARCHIVE_STATE_NEW, "archive_read_support_filter_bzip2");
-
- if (__archive_read_get_bidder(a, &reader) != ARCHIVE_OK)
+ if (__archive_read_register_bidder(a, NULL, "bzip2",
+ &bzip2_bidder_vtable) != ARCHIVE_OK)
return (ARCHIVE_FATAL);
- reader->data = NULL;
- reader->name = "bzip2";
- reader->bid = bzip2_reader_bid;
- reader->init = bzip2_reader_init;
- reader->options = NULL;
- reader->free = bzip2_reader_free;
#if defined(HAVE_BZLIB_H) && defined(BZ_CONFIG_ERROR)
return (ARCHIVE_OK);
#else
@@ -108,12 +104,6 @@
#endif
}
-static int
-bzip2_reader_free(struct archive_read_filter_bidder *self){
- (void)self; /* UNUSED */
- return (ARCHIVE_OK);
-}
-
/*
* Test whether we can handle this data.
*
@@ -183,6 +173,12 @@
#else
+static const struct archive_read_filter_vtable
+bzip2_reader_vtable = {
+ .read = bzip2_filter_read,
+ .close = bzip2_filter_close,
+};
+
/*
* Setup the callbacks.
*/
@@ -209,9 +205,7 @@
self->data = state;
state->out_block_size = out_block_size;
state->out_block = out_block;
- self->read = bzip2_filter_read;
- self->skip = NULL; /* not supported */
- self->close = bzip2_filter_close;
+ self->vtable = &bzip2_reader_vtable;
return (ARCHIVE_OK);
}
diff --git a/Utilities/cmlibarchive/libarchive/archive_read_support_filter_compress.c b/Utilities/cmlibarchive/libarchive/archive_read_support_filter_compress.c
index e05132d..05b80a5 100644
--- a/Utilities/cmlibarchive/libarchive/archive_read_support_filter_compress.c
+++ b/Utilities/cmlibarchive/libarchive/archive_read_support_filter_compress.c
@@ -133,7 +133,6 @@
static int compress_bidder_bid(struct archive_read_filter_bidder *, struct archive_read_filter *);
static int compress_bidder_init(struct archive_read_filter *);
-static int compress_bidder_free(struct archive_read_filter_bidder *);
static ssize_t compress_filter_read(struct archive_read_filter *, const void **);
static int compress_filter_close(struct archive_read_filter *);
@@ -150,25 +149,19 @@
}
#endif
+static const struct archive_read_filter_bidder_vtable
+compress_bidder_vtable = {
+ .bid = compress_bidder_bid,
+ .init = compress_bidder_init,
+};
+
int
archive_read_support_filter_compress(struct archive *_a)
{
struct archive_read *a = (struct archive_read *)_a;
- struct archive_read_filter_bidder *bidder;
- archive_check_magic(_a, ARCHIVE_READ_MAGIC,
- ARCHIVE_STATE_NEW, "archive_read_support_filter_compress");
-
- if (__archive_read_get_bidder(a, &bidder) != ARCHIVE_OK)
- return (ARCHIVE_FATAL);
-
- bidder->data = NULL;
- bidder->name = "compress (.Z)";
- bidder->bid = compress_bidder_bid;
- bidder->init = compress_bidder_init;
- bidder->options = NULL;
- bidder->free = compress_bidder_free;
- return (ARCHIVE_OK);
+ return __archive_read_register_bidder(a, NULL, "compress (.Z)",
+ &compress_bidder_vtable);
}
/*
@@ -205,6 +198,12 @@
return (bits_checked);
}
+static const struct archive_read_filter_vtable
+compress_reader_vtable = {
+ .read = compress_filter_read,
+ .close = compress_filter_close,
+};
+
/*
* Setup the callbacks.
*/
@@ -233,9 +232,7 @@
self->data = state;
state->out_block_size = out_block_size;
state->out_block = out_block;
- self->read = compress_filter_read;
- self->skip = NULL; /* not supported */
- self->close = compress_filter_close;
+ self->vtable = &compress_reader_vtable;
/* XXX MOVE THE FOLLOWING OUT OF INIT() XXX */
@@ -306,16 +303,6 @@
}
/*
- * Clean up the reader.
- */
-static int
-compress_bidder_free(struct archive_read_filter_bidder *self)
-{
- self->data = NULL;
- return (ARCHIVE_OK);
-}
-
-/*
* Close and release the filter.
*/
static int
diff --git a/Utilities/cmlibarchive/libarchive/archive_read_support_filter_grzip.c b/Utilities/cmlibarchive/libarchive/archive_read_support_filter_grzip.c
index 84c86ae..d4d1737 100644
--- a/Utilities/cmlibarchive/libarchive/archive_read_support_filter_grzip.c
+++ b/Utilities/cmlibarchive/libarchive/archive_read_support_filter_grzip.c
@@ -54,30 +54,21 @@
static int grzip_bidder_init(struct archive_read_filter *);
-static int
-grzip_reader_free(struct archive_read_filter_bidder *self)
-{
- (void)self; /* UNUSED */
- return (ARCHIVE_OK);
-}
+static const struct archive_read_filter_bidder_vtable
+grzip_bidder_vtable = {
+ .bid = grzip_bidder_bid,
+ .init = grzip_bidder_init,
+};
int
archive_read_support_filter_grzip(struct archive *_a)
{
struct archive_read *a = (struct archive_read *)_a;
- struct archive_read_filter_bidder *reader;
- archive_check_magic(_a, ARCHIVE_READ_MAGIC,
- ARCHIVE_STATE_NEW, "archive_read_support_filter_grzip");
-
- if (__archive_read_get_bidder(a, &reader) != ARCHIVE_OK)
+ if (__archive_read_register_bidder(a, NULL, NULL,
+ &grzip_bidder_vtable) != ARCHIVE_OK)
return (ARCHIVE_FATAL);
- reader->data = NULL;
- reader->bid = grzip_bidder_bid;
- reader->init = grzip_bidder_init;
- reader->options = NULL;
- reader->free = grzip_reader_free;
/* This filter always uses an external program. */
archive_set_error(_a, ARCHIVE_ERRNO_MISC,
"Using external grzip program for grzip decompression");
diff --git a/Utilities/cmlibarchive/libarchive/archive_read_support_filter_gzip.c b/Utilities/cmlibarchive/libarchive/archive_read_support_filter_gzip.c
index ac0b694..976a392 100644
--- a/Utilities/cmlibarchive/libarchive/archive_read_support_filter_gzip.c
+++ b/Utilities/cmlibarchive/libarchive/archive_read_support_filter_gzip.c
@@ -94,24 +94,21 @@
}
#endif
+static const struct archive_read_filter_bidder_vtable
+gzip_bidder_vtable = {
+ .bid = gzip_bidder_bid,
+ .init = gzip_bidder_init,
+};
+
int
archive_read_support_filter_gzip(struct archive *_a)
{
struct archive_read *a = (struct archive_read *)_a;
- struct archive_read_filter_bidder *bidder;
- archive_check_magic(_a, ARCHIVE_READ_MAGIC,
- ARCHIVE_STATE_NEW, "archive_read_support_filter_gzip");
-
- if (__archive_read_get_bidder(a, &bidder) != ARCHIVE_OK)
+ if (__archive_read_register_bidder(a, NULL, "gzip",
+ &gzip_bidder_vtable) != ARCHIVE_OK)
return (ARCHIVE_FATAL);
- bidder->data = NULL;
- bidder->name = "gzip";
- bidder->bid = gzip_bidder_bid;
- bidder->init = gzip_bidder_init;
- bidder->options = NULL;
- bidder->free = NULL; /* No data, so no cleanup necessary. */
/* Signal the extent of gzip support with the return value here. */
#if HAVE_ZLIB_H
return (ARCHIVE_OK);
@@ -291,6 +288,15 @@
return (ARCHIVE_OK);
}
+static const struct archive_read_filter_vtable
+gzip_reader_vtable = {
+ .read = gzip_filter_read,
+ .close = gzip_filter_close,
+#ifdef HAVE_ZLIB_H
+ .read_header = gzip_read_header,
+#endif
+};
+
/*
* Initialize the filter object.
*/
@@ -317,12 +323,7 @@
self->data = state;
state->out_block_size = out_block_size;
state->out_block = out_block;
- self->read = gzip_filter_read;
- self->skip = NULL; /* not supported */
- self->close = gzip_filter_close;
-#ifdef HAVE_ZLIB_H
- self->read_header = gzip_read_header;
-#endif
+ self->vtable = &gzip_reader_vtable;
state->in_stream = 0; /* We're not actually within a stream yet. */
diff --git a/Utilities/cmlibarchive/libarchive/archive_read_support_filter_lrzip.c b/Utilities/cmlibarchive/libarchive/archive_read_support_filter_lrzip.c
index c82a8e2..a238989 100644
--- a/Utilities/cmlibarchive/libarchive/archive_read_support_filter_lrzip.c
+++ b/Utilities/cmlibarchive/libarchive/archive_read_support_filter_lrzip.c
@@ -53,31 +53,21 @@
static int lrzip_bidder_init(struct archive_read_filter *);
-static int
-lrzip_reader_free(struct archive_read_filter_bidder *self)
-{
- (void)self; /* UNUSED */
- return (ARCHIVE_OK);
-}
+static const struct archive_read_filter_bidder_vtable
+lrzip_bidder_vtable = {
+ .bid = lrzip_bidder_bid,
+ .init = lrzip_bidder_init,
+};
int
archive_read_support_filter_lrzip(struct archive *_a)
{
struct archive_read *a = (struct archive_read *)_a;
- struct archive_read_filter_bidder *reader;
- archive_check_magic(_a, ARCHIVE_READ_MAGIC,
- ARCHIVE_STATE_NEW, "archive_read_support_filter_lrzip");
-
- if (__archive_read_get_bidder(a, &reader) != ARCHIVE_OK)
+ if (__archive_read_register_bidder(a, NULL, "lrzip",
+ &lrzip_bidder_vtable) != ARCHIVE_OK)
return (ARCHIVE_FATAL);
- reader->data = NULL;
- reader->name = "lrzip";
- reader->bid = lrzip_bidder_bid;
- reader->init = lrzip_bidder_init;
- reader->options = NULL;
- reader->free = lrzip_reader_free;
/* This filter always uses an external program. */
archive_set_error(_a, ARCHIVE_ERRNO_MISC,
"Using external lrzip program for lrzip decompression");
diff --git a/Utilities/cmlibarchive/libarchive/archive_read_support_filter_lz4.c b/Utilities/cmlibarchive/libarchive/archive_read_support_filter_lz4.c
index 43ee6c2..ae0b080 100644
--- a/Utilities/cmlibarchive/libarchive/archive_read_support_filter_lz4.c
+++ b/Utilities/cmlibarchive/libarchive/archive_read_support_filter_lz4.c
@@ -99,7 +99,6 @@
*/
static int lz4_reader_bid(struct archive_read_filter_bidder *, struct archive_read_filter *);
static int lz4_reader_init(struct archive_read_filter *);
-static int lz4_reader_free(struct archive_read_filter_bidder *);
#if defined(HAVE_LIBLZ4)
static ssize_t lz4_filter_read_default_stream(struct archive_read_filter *,
const void **);
@@ -107,24 +106,21 @@
const void **);
#endif
+static const struct archive_read_filter_bidder_vtable
+lz4_bidder_vtable = {
+ .bid = lz4_reader_bid,
+ .init = lz4_reader_init,
+};
+
int
archive_read_support_filter_lz4(struct archive *_a)
{
struct archive_read *a = (struct archive_read *)_a;
- struct archive_read_filter_bidder *reader;
- archive_check_magic(_a, ARCHIVE_READ_MAGIC,
- ARCHIVE_STATE_NEW, "archive_read_support_filter_lz4");
-
- if (__archive_read_get_bidder(a, &reader) != ARCHIVE_OK)
+ if (__archive_read_register_bidder(a, NULL, "lz4",
+ &lz4_bidder_vtable) != ARCHIVE_OK)
return (ARCHIVE_FATAL);
- reader->data = NULL;
- reader->name = "lz4";
- reader->bid = lz4_reader_bid;
- reader->init = lz4_reader_init;
- reader->options = NULL;
- reader->free = lz4_reader_free;
#if defined(HAVE_LIBLZ4)
return (ARCHIVE_OK);
#else
@@ -134,12 +130,6 @@
#endif
}
-static int
-lz4_reader_free(struct archive_read_filter_bidder *self){
- (void)self; /* UNUSED */
- return (ARCHIVE_OK);
-}
-
/*
* Test whether we can handle this data.
*
@@ -218,6 +208,12 @@
#else
+static const struct archive_read_filter_vtable
+lz4_reader_vtable = {
+ .read = lz4_filter_read,
+ .close = lz4_filter_close,
+};
+
/*
* Setup the callbacks.
*/
@@ -238,9 +234,7 @@
self->data = state;
state->stage = SELECT_STREAM;
- self->read = lz4_filter_read;
- self->skip = NULL; /* not supported */
- self->close = lz4_filter_close;
+ self->vtable = &lz4_reader_vtable;
return (ARCHIVE_OK);
}
diff --git a/Utilities/cmlibarchive/libarchive/archive_read_support_filter_lzop.c b/Utilities/cmlibarchive/libarchive/archive_read_support_filter_lzop.c
index 05f740b..42e2636 100644
--- a/Utilities/cmlibarchive/libarchive/archive_read_support_filter_lzop.c
+++ b/Utilities/cmlibarchive/libarchive/archive_read_support_filter_lzop.c
@@ -101,23 +101,21 @@
struct archive_read_filter *);
static int lzop_bidder_init(struct archive_read_filter *);
+static const struct archive_read_filter_bidder_vtable
+lzop_bidder_vtable = {
+ .bid = lzop_bidder_bid,
+ .init = lzop_bidder_init,
+};
+
int
archive_read_support_filter_lzop(struct archive *_a)
{
struct archive_read *a = (struct archive_read *)_a;
- struct archive_read_filter_bidder *reader;
- archive_check_magic(_a, ARCHIVE_READ_MAGIC,
- ARCHIVE_STATE_NEW, "archive_read_support_filter_lzop");
-
- if (__archive_read_get_bidder(a, &reader) != ARCHIVE_OK)
+ if (__archive_read_register_bidder(a, NULL, NULL,
+ &lzop_bidder_vtable) != ARCHIVE_OK)
return (ARCHIVE_FATAL);
- reader->data = NULL;
- reader->bid = lzop_bidder_bid;
- reader->init = lzop_bidder_init;
- reader->options = NULL;
- reader->free = NULL;
/* Signal the extent of lzop support with the return value here. */
#if defined(HAVE_LZO_LZOCONF_H) && defined(HAVE_LZO_LZO1X_H)
return (ARCHIVE_OK);
@@ -171,6 +169,13 @@
return (r);
}
#else
+
+static const struct archive_read_filter_vtable
+lzop_reader_vtable = {
+ .read = lzop_filter_read,
+ .close = lzop_filter_close
+};
+
/*
* Initialize the filter object.
*/
@@ -190,9 +195,7 @@
}
self->data = state;
- self->read = lzop_filter_read;
- self->skip = NULL; /* not supported */
- self->close = lzop_filter_close;
+ self->vtable = &lzop_reader_vtable;
return (ARCHIVE_OK);
}
diff --git a/Utilities/cmlibarchive/libarchive/archive_read_support_filter_program.c b/Utilities/cmlibarchive/libarchive/archive_read_support_filter_program.c
index bf5b6f2..885b2c2 100644
--- a/Utilities/cmlibarchive/libarchive/archive_read_support_filter_program.c
+++ b/Utilities/cmlibarchive/libarchive/archive_read_support_filter_program.c
@@ -98,7 +98,7 @@
static int program_bidder_bid(struct archive_read_filter_bidder *,
struct archive_read_filter *upstream);
static int program_bidder_init(struct archive_read_filter *);
-static int program_bidder_free(struct archive_read_filter_bidder *);
+static void program_bidder_free(struct archive_read_filter_bidder *);
/*
* The actual filter needs to track input and output data.
@@ -123,43 +123,21 @@
static int program_filter_close(struct archive_read_filter *);
static void free_state(struct program_bidder *);
-static int
-set_bidder_signature(struct archive_read_filter_bidder *bidder,
- struct program_bidder *state, const void *signature, size_t signature_len)
-{
-
- if (signature != NULL && signature_len > 0) {
- state->signature_len = signature_len;
- state->signature = malloc(signature_len);
- memcpy(state->signature, signature, signature_len);
- }
-
- /*
- * Fill in the bidder object.
- */
- bidder->data = state;
- bidder->bid = program_bidder_bid;
- bidder->init = program_bidder_init;
- bidder->options = NULL;
- bidder->free = program_bidder_free;
- return (ARCHIVE_OK);
-}
+static const struct archive_read_filter_bidder_vtable
+program_bidder_vtable = {
+ .bid = program_bidder_bid,
+ .init = program_bidder_init,
+ .free = program_bidder_free,
+};
int
archive_read_support_filter_program_signature(struct archive *_a,
const char *cmd, const void *signature, size_t signature_len)
{
struct archive_read *a = (struct archive_read *)_a;
- struct archive_read_filter_bidder *bidder;
struct program_bidder *state;
/*
- * Get a bidder object from the read core.
- */
- if (__archive_read_get_bidder(a, &bidder) != ARCHIVE_OK)
- return (ARCHIVE_FATAL);
-
- /*
* Allocate our private state.
*/
state = (struct program_bidder *)calloc(1, sizeof (*state));
@@ -169,20 +147,31 @@
if (state->cmd == NULL)
goto memerr;
- return set_bidder_signature(bidder, state, signature, signature_len);
+ if (signature != NULL && signature_len > 0) {
+ state->signature_len = signature_len;
+ state->signature = malloc(signature_len);
+ memcpy(state->signature, signature, signature_len);
+ }
+
+ if (__archive_read_register_bidder(a, state, NULL,
+ &program_bidder_vtable) != ARCHIVE_OK) {
+ free_state(state);
+ return (ARCHIVE_FATAL);
+ }
+ return (ARCHIVE_OK);
+
memerr:
free_state(state);
archive_set_error(_a, ENOMEM, "Can't allocate memory");
return (ARCHIVE_FATAL);
}
-static int
+static void
program_bidder_free(struct archive_read_filter_bidder *self)
{
struct program_bidder *state = (struct program_bidder *)self->data;
free_state(state);
- return (ARCHIVE_OK);
}
static void
@@ -393,6 +382,12 @@
}
}
+static const struct archive_read_filter_vtable
+program_reader_vtable = {
+ .read = program_filter_read,
+ .close = program_filter_close,
+};
+
int
__archive_read_program(struct archive_read_filter *self, const char *cmd)
{
@@ -439,9 +434,7 @@
}
self->data = state;
- self->read = program_filter_read;
- self->skip = NULL;
- self->close = program_filter_close;
+ self->vtable = &program_reader_vtable;
/* XXX Check that we can read at least one byte? */
return (ARCHIVE_OK);
diff --git a/Utilities/cmlibarchive/libarchive/archive_read_support_filter_rpm.c b/Utilities/cmlibarchive/libarchive/archive_read_support_filter_rpm.c
index e7e58e5..67a979c 100644
--- a/Utilities/cmlibarchive/libarchive/archive_read_support_filter_rpm.c
+++ b/Utilities/cmlibarchive/libarchive/archive_read_support_filter_rpm.c
@@ -72,25 +72,19 @@
}
#endif
+static const struct archive_read_filter_bidder_vtable
+rpm_bidder_vtable = {
+ .bid = rpm_bidder_bid,
+ .init = rpm_bidder_init,
+};
+
int
archive_read_support_filter_rpm(struct archive *_a)
{
struct archive_read *a = (struct archive_read *)_a;
- struct archive_read_filter_bidder *bidder;
- archive_check_magic(_a, ARCHIVE_READ_MAGIC,
- ARCHIVE_STATE_NEW, "archive_read_support_filter_rpm");
-
- if (__archive_read_get_bidder(a, &bidder) != ARCHIVE_OK)
- return (ARCHIVE_FATAL);
-
- bidder->data = NULL;
- bidder->name = "rpm";
- bidder->bid = rpm_bidder_bid;
- bidder->init = rpm_bidder_init;
- bidder->options = NULL;
- bidder->free = NULL;
- return (ARCHIVE_OK);
+ return __archive_read_register_bidder(a, NULL, "rpm",
+ &rpm_bidder_vtable);
}
static int
@@ -133,6 +127,12 @@
return (bits_checked);
}
+static const struct archive_read_filter_vtable
+rpm_reader_vtable = {
+ .read = rpm_filter_read,
+ .close = rpm_filter_close,
+};
+
static int
rpm_bidder_init(struct archive_read_filter *self)
{
@@ -140,9 +140,6 @@
self->code = ARCHIVE_FILTER_RPM;
self->name = "rpm";
- self->read = rpm_filter_read;
- self->skip = NULL; /* not supported */
- self->close = rpm_filter_close;
rpm = (struct rpm *)calloc(sizeof(*rpm), 1);
if (rpm == NULL) {
@@ -153,6 +150,7 @@
self->data = rpm;
rpm->state = ST_LEAD;
+ self->vtable = &rpm_reader_vtable;
return (ARCHIVE_OK);
}
@@ -216,7 +214,7 @@
archive_set_error(
&self->archive->archive,
ARCHIVE_ERRNO_FILE_FORMAT,
- "Unrecoginized rpm header");
+ "Unrecognized rpm header");
return (ARCHIVE_FATAL);
}
rpm->state = ST_ARCHIVE;
diff --git a/Utilities/cmlibarchive/libarchive/archive_read_support_filter_uu.c b/Utilities/cmlibarchive/libarchive/archive_read_support_filter_uu.c
index 67ddffb..209b2a1 100644
--- a/Utilities/cmlibarchive/libarchive/archive_read_support_filter_uu.c
+++ b/Utilities/cmlibarchive/libarchive/archive_read_support_filter_uu.c
@@ -76,25 +76,19 @@
}
#endif
+static const struct archive_read_filter_bidder_vtable
+uudecode_bidder_vtable = {
+ .bid = uudecode_bidder_bid,
+ .init = uudecode_bidder_init,
+};
+
int
archive_read_support_filter_uu(struct archive *_a)
{
struct archive_read *a = (struct archive_read *)_a;
- struct archive_read_filter_bidder *bidder;
- archive_check_magic(_a, ARCHIVE_READ_MAGIC,
- ARCHIVE_STATE_NEW, "archive_read_support_filter_uu");
-
- if (__archive_read_get_bidder(a, &bidder) != ARCHIVE_OK)
- return (ARCHIVE_FATAL);
-
- bidder->data = NULL;
- bidder->name = "uu";
- bidder->bid = uudecode_bidder_bid;
- bidder->init = uudecode_bidder_init;
- bidder->options = NULL;
- bidder->free = NULL;
- return (ARCHIVE_OK);
+ return __archive_read_register_bidder(a, NULL, "uu",
+ &uudecode_bidder_vtable);
}
static const unsigned char ascii[256] = {
@@ -248,7 +242,7 @@
*ravail = *avail;
*b += diff;
*avail -= diff;
- tested = len;/* Skip some bytes we already determinated. */
+ tested = len;/* Skip some bytes we already determined. */
len = get_line(*b + tested, *avail - tested, nl);
if (len >= 0)
len += tested;
@@ -357,6 +351,12 @@
return (0);
}
+static const struct archive_read_filter_vtable
+uudecode_reader_vtable = {
+ .read = uudecode_filter_read,
+ .close = uudecode_filter_close,
+};
+
static int
uudecode_bidder_init(struct archive_read_filter *self)
{
@@ -366,9 +366,6 @@
self->code = ARCHIVE_FILTER_UU;
self->name = "uu";
- self->read = uudecode_filter_read;
- self->skip = NULL; /* not supported */
- self->close = uudecode_filter_close;
uudecode = (struct uudecode *)calloc(sizeof(*uudecode), 1);
out_buff = malloc(OUT_BUFF_SIZE);
@@ -388,6 +385,7 @@
uudecode->in_allocated = IN_BUFF_SIZE;
uudecode->out_buff = out_buff;
uudecode->state = ST_FIND_HEAD;
+ self->vtable = &uudecode_reader_vtable;
return (ARCHIVE_OK);
}
diff --git a/Utilities/cmlibarchive/libarchive/archive_read_support_filter_xz.c b/Utilities/cmlibarchive/libarchive/archive_read_support_filter_xz.c
index 3223b38..b978eb0 100644
--- a/Utilities/cmlibarchive/libarchive/archive_read_support_filter_xz.c
+++ b/Utilities/cmlibarchive/libarchive/archive_read_support_filter_xz.c
@@ -108,24 +108,21 @@
}
#endif
+static const struct archive_read_filter_bidder_vtable
+xz_bidder_vtable = {
+ .bid = xz_bidder_bid,
+ .init = xz_bidder_init,
+};
+
int
archive_read_support_filter_xz(struct archive *_a)
{
struct archive_read *a = (struct archive_read *)_a;
- struct archive_read_filter_bidder *bidder;
- archive_check_magic(_a, ARCHIVE_READ_MAGIC,
- ARCHIVE_STATE_NEW, "archive_read_support_filter_xz");
-
- if (__archive_read_get_bidder(a, &bidder) != ARCHIVE_OK)
+ if (__archive_read_register_bidder(a, NULL, "xz",
+ &xz_bidder_vtable) != ARCHIVE_OK)
return (ARCHIVE_FATAL);
- bidder->data = NULL;
- bidder->name = "xz";
- bidder->bid = xz_bidder_bid;
- bidder->init = xz_bidder_init;
- bidder->options = NULL;
- bidder->free = NULL;
#if HAVE_LZMA_H && HAVE_LIBLZMA
return (ARCHIVE_OK);
#else
@@ -143,24 +140,21 @@
}
#endif
+static const struct archive_read_filter_bidder_vtable
+lzma_bidder_vtable = {
+ .bid = lzma_bidder_bid,
+ .init = lzma_bidder_init,
+};
+
int
archive_read_support_filter_lzma(struct archive *_a)
{
struct archive_read *a = (struct archive_read *)_a;
- struct archive_read_filter_bidder *bidder;
- archive_check_magic(_a, ARCHIVE_READ_MAGIC,
- ARCHIVE_STATE_NEW, "archive_read_support_filter_lzma");
-
- if (__archive_read_get_bidder(a, &bidder) != ARCHIVE_OK)
+ if (__archive_read_register_bidder(a, NULL, "lzma",
+ &lzma_bidder_vtable) != ARCHIVE_OK)
return (ARCHIVE_FATAL);
- bidder->data = NULL;
- bidder->name = "lzma";
- bidder->bid = lzma_bidder_bid;
- bidder->init = lzma_bidder_init;
- bidder->options = NULL;
- bidder->free = NULL;
#if HAVE_LZMA_H && HAVE_LIBLZMA
return (ARCHIVE_OK);
#else
@@ -179,24 +173,21 @@
}
#endif
+static const struct archive_read_filter_bidder_vtable
+lzip_bidder_vtable = {
+ .bid = lzip_bidder_bid,
+ .init = lzip_bidder_init,
+};
+
int
archive_read_support_filter_lzip(struct archive *_a)
{
struct archive_read *a = (struct archive_read *)_a;
- struct archive_read_filter_bidder *bidder;
- archive_check_magic(_a, ARCHIVE_READ_MAGIC,
- ARCHIVE_STATE_NEW, "archive_read_support_filter_lzip");
-
- if (__archive_read_get_bidder(a, &bidder) != ARCHIVE_OK)
+ if (__archive_read_register_bidder(a, NULL, "lzip",
+ &lzip_bidder_vtable) != ARCHIVE_OK)
return (ARCHIVE_FATAL);
- bidder->data = NULL;
- bidder->name = "lzip";
- bidder->bid = lzip_bidder_bid;
- bidder->init = lzip_bidder_init;
- bidder->options = NULL;
- bidder->free = NULL;
#if HAVE_LZMA_H && HAVE_LIBLZMA
return (ARCHIVE_OK);
#else
@@ -293,8 +284,8 @@
/* Second through fifth bytes are dictionary size, stored in
* little-endian order. The minimum dictionary size is
* 1 << 12(4KiB) which the lzma of LZMA SDK uses with option
- * -d12 and the maximum dictionary size is 1 << 27(128MiB)
- * which the one uses with option -d27.
+ * -d12 and the maximum dictionary size is 1 << 29(512MiB)
+ * which the one uses with option -d29.
* NOTE: A comment of LZMA SDK source code says this dictionary
* range is from 1 << 12 to 1 << 30. */
dicsize = archive_le32dec(buffer+1);
@@ -377,7 +368,7 @@
/* Dictionary size. */
log2dic = buffer[5] & 0x1f;
- if (log2dic < 12 || log2dic > 27)
+ if (log2dic < 12 || log2dic > 29)
return (0);
bits_checked += 8;
@@ -470,6 +461,12 @@
}
}
+static const struct archive_read_filter_vtable
+xz_lzma_reader_vtable = {
+ .read = xz_filter_read,
+ .close = xz_filter_close,
+};
+
/*
* Setup the callbacks.
*/
@@ -494,9 +491,7 @@
self->data = state;
state->out_block_size = out_block_size;
state->out_block = out_block;
- self->read = xz_filter_read;
- self->skip = NULL; /* not supported */
- self->close = xz_filter_close;
+ self->vtable = &xz_lzma_reader_vtable;
state->stream.avail_in = 0;
@@ -562,7 +557,7 @@
/* Get dictionary size. */
log2dic = h[5] & 0x1f;
- if (log2dic < 12 || log2dic > 27)
+ if (log2dic < 12 || log2dic > 29)
return (ARCHIVE_FATAL);
dicsize = 1U << log2dic;
if (log2dic > 12)
diff --git a/Utilities/cmlibarchive/libarchive/archive_read_support_filter_zstd.c b/Utilities/cmlibarchive/libarchive/archive_read_support_filter_zstd.c
index c4e8ec7..29d4d62 100644
--- a/Utilities/cmlibarchive/libarchive/archive_read_support_filter_zstd.c
+++ b/Utilities/cmlibarchive/libarchive/archive_read_support_filter_zstd.c
@@ -79,24 +79,21 @@
struct archive_read_filter *);
static int zstd_bidder_init(struct archive_read_filter *);
+static const struct archive_read_filter_bidder_vtable
+zstd_bidder_vtable = {
+ .bid = zstd_bidder_bid,
+ .init = zstd_bidder_init,
+};
+
int
archive_read_support_filter_zstd(struct archive *_a)
{
struct archive_read *a = (struct archive_read *)_a;
- struct archive_read_filter_bidder *bidder;
- archive_check_magic(_a, ARCHIVE_READ_MAGIC,
- ARCHIVE_STATE_NEW, "archive_read_support_filter_zstd");
-
- if (__archive_read_get_bidder(a, &bidder) != ARCHIVE_OK)
+ if (__archive_read_register_bidder(a, NULL, "zstd",
+ &zstd_bidder_vtable) != ARCHIVE_OK)
return (ARCHIVE_FATAL);
- bidder->data = NULL;
- bidder->name = "zstd";
- bidder->bid = zstd_bidder_bid;
- bidder->init = zstd_bidder_init;
- bidder->options = NULL;
- bidder->free = NULL;
#if HAVE_ZSTD_H && HAVE_LIBZSTD
return (ARCHIVE_OK);
#else
@@ -160,6 +157,12 @@
#else
+static const struct archive_read_filter_vtable
+zstd_reader_vtable = {
+ .read = zstd_filter_read,
+ .close = zstd_filter_close,
+};
+
/*
* Initialize the filter object
*/
@@ -192,9 +195,7 @@
state->out_block_size = out_block_size;
state->out_block = out_block;
state->dstream = dstream;
- self->read = zstd_filter_read;
- self->skip = NULL; /* not supported */
- self->close = zstd_filter_close;
+ self->vtable = &zstd_reader_vtable;
state->eof = 0;
state->in_frame = 0;
diff --git a/Utilities/cmlibarchive/libarchive/archive_read_support_format_7zip.c b/Utilities/cmlibarchive/libarchive/archive_read_support_format_7zip.c
index 456b2f8..7d7e702 100644
--- a/Utilities/cmlibarchive/libarchive/archive_read_support_format_7zip.c
+++ b/Utilities/cmlibarchive/libarchive/archive_read_support_format_7zip.c
@@ -808,8 +808,12 @@
if (zip->end_of_entry)
return (ARCHIVE_EOF);
- bytes = read_stream(a, buff,
- (size_t)zip->entry_bytes_remaining, 0);
+ const uint64_t max_read_size = 16 * 1024 * 1024; // Don't try to read more than 16 MB at a time
+ size_t bytes_to_read = max_read_size;
+ if ((uint64_t)bytes_to_read > zip->entry_bytes_remaining) {
+ bytes_to_read = zip->entry_bytes_remaining;
+ }
+ bytes = read_stream(a, buff, bytes_to_read, 0);
if (bytes < 0)
return ((int)bytes);
if (bytes == 0) {
@@ -1493,7 +1497,7 @@
zip->ppmd7_stat = -1;
archive_set_error(&a->archive,
ARCHIVE_ERRNO_MISC,
- "Failed to initialize PPMd range decorder");
+ "Failed to initialize PPMd range decoder");
return (ARCHIVE_FAILED);
}
if (zip->ppstream.overconsumed) {
@@ -3031,10 +3035,10 @@
"Truncated 7-Zip file body");
return (ARCHIVE_FATAL);
}
- if (bytes_avail > (ssize_t)zip->pack_stream_inbytes_remaining)
+ if ((uint64_t)bytes_avail > zip->pack_stream_inbytes_remaining)
bytes_avail = (ssize_t)zip->pack_stream_inbytes_remaining;
zip->pack_stream_inbytes_remaining -= bytes_avail;
- if (bytes_avail > (ssize_t)zip->folder_outbytes_remaining)
+ if ((uint64_t)bytes_avail > zip->folder_outbytes_remaining)
bytes_avail = (ssize_t)zip->folder_outbytes_remaining;
zip->folder_outbytes_remaining -= bytes_avail;
zip->uncompressed_buffer_bytes_remaining = bytes_avail;
diff --git a/Utilities/cmlibarchive/libarchive/archive_read_support_format_cab.c b/Utilities/cmlibarchive/libarchive/archive_read_support_format_cab.c
index 57547d4..8742378 100644
--- a/Utilities/cmlibarchive/libarchive/archive_read_support_format_cab.c
+++ b/Utilities/cmlibarchive/libarchive/archive_read_support_format_cab.c
@@ -2110,7 +2110,6 @@
ds->pos_tbl = malloc(sizeof(ds->pos_tbl[0]) * w_slot);
if (ds->pos_tbl == NULL)
return (ARCHIVE_FATAL);
- lzx_huffman_free(&(ds->mt));
}
for (footer = 0; footer < 18; footer++)
diff --git a/Utilities/cmlibarchive/libarchive/archive_read_support_format_cpio.c b/Utilities/cmlibarchive/libarchive/archive_read_support_format_cpio.c
index 1c96e6a..6b8ae33 100644
--- a/Utilities/cmlibarchive/libarchive/archive_read_support_format_cpio.c
+++ b/Utilities/cmlibarchive/libarchive/archive_read_support_format_cpio.c
@@ -185,6 +185,8 @@
struct archive_string_conv *opt_sconv;
struct archive_string_conv *sconv_default;
int init_default_conversion;
+
+ int option_pwb;
};
static int64_t atol16(const char *, unsigned);
@@ -343,6 +345,10 @@
ret = ARCHIVE_FATAL;
}
return (ret);
+ } else if (strcmp(key, "pwb") == 0) {
+ if (val != NULL && val[0] != 0)
+ cpio->option_pwb = 1;
+ return (ARCHIVE_OK);
}
/* Note: The "warn" return is just to inform the options
@@ -891,6 +897,12 @@
archive_entry_set_dev(entry, header[bin_dev_offset] + header[bin_dev_offset + 1] * 256);
archive_entry_set_ino(entry, header[bin_ino_offset] + header[bin_ino_offset + 1] * 256);
archive_entry_set_mode(entry, header[bin_mode_offset] + header[bin_mode_offset + 1] * 256);
+ if (cpio->option_pwb) {
+ /* turn off random bits left over from V6 inode */
+ archive_entry_set_mode(entry, archive_entry_mode(entry) & 067777);
+ if ((archive_entry_mode(entry) & AE_IFMT) == 0)
+ archive_entry_set_mode(entry, archive_entry_mode(entry) | AE_IFREG);
+ }
archive_entry_set_uid(entry, header[bin_uid_offset] + header[bin_uid_offset + 1] * 256);
archive_entry_set_gid(entry, header[bin_gid_offset] + header[bin_gid_offset + 1] * 256);
archive_entry_set_nlink(entry, header[bin_nlink_offset] + header[bin_nlink_offset + 1] * 256);
@@ -930,6 +942,12 @@
archive_entry_set_dev(entry, header[bin_dev_offset] * 256 + header[bin_dev_offset + 1]);
archive_entry_set_ino(entry, header[bin_ino_offset] * 256 + header[bin_ino_offset + 1]);
archive_entry_set_mode(entry, header[bin_mode_offset] * 256 + header[bin_mode_offset + 1]);
+ if (cpio->option_pwb) {
+ /* turn off random bits left over from V6 inode */
+ archive_entry_set_mode(entry, archive_entry_mode(entry) & 067777);
+ if ((archive_entry_mode(entry) & AE_IFMT) == 0)
+ archive_entry_set_mode(entry, archive_entry_mode(entry) | AE_IFREG);
+ }
archive_entry_set_uid(entry, header[bin_uid_offset] * 256 + header[bin_uid_offset + 1]);
archive_entry_set_gid(entry, header[bin_gid_offset] * 256 + header[bin_gid_offset + 1]);
archive_entry_set_nlink(entry, header[bin_nlink_offset] * 256 + header[bin_nlink_offset + 1]);
diff --git a/Utilities/cmlibarchive/libarchive/archive_read_support_format_mtree.c b/Utilities/cmlibarchive/libarchive/archive_read_support_format_mtree.c
index 93ba295..88bca76 100644
--- a/Utilities/cmlibarchive/libarchive/archive_read_support_format_mtree.c
+++ b/Utilities/cmlibarchive/libarchive/archive_read_support_format_mtree.c
@@ -408,7 +408,7 @@
*ravail = *avail;
*b += diff;
*avail -= diff;
- tested = len;/* Skip some bytes we already determinated. */
+ tested = len;/* Skip some bytes we already determined. */
len = get_line_size(*b + len, *avail - len, nl);
if (len >= 0)
len += tested;
@@ -1074,7 +1074,7 @@
continue;
/* Non-printable characters are not allowed */
for (s = p;s < p + len - 1; s++) {
- if (!isprint(*s)) {
+ if (!isprint((unsigned char)*s)) {
r = ARCHIVE_FATAL;
break;
}
@@ -1629,11 +1629,11 @@
|| strcmp(key, "contents") == 0) {
parse_escapes(val, NULL);
archive_strcpy(&mtree->contents_name, val);
- break;
+ return (ARCHIVE_OK);
}
if (strcmp(key, "cksum") == 0)
- break;
- __LA_FALLTHROUGH;
+ return (ARCHIVE_OK);
+ break;
case 'd':
if (strcmp(key, "device") == 0) {
/* stat(2) st_rdev field, e.g. the major/minor IDs
@@ -1647,65 +1647,64 @@
archive_entry_set_rdev(entry, dev);
return r;
}
- __LA_FALLTHROUGH;
+ break;
case 'f':
if (strcmp(key, "flags") == 0) {
*parsed_kws |= MTREE_HAS_FFLAGS;
archive_entry_copy_fflags_text(entry, val);
- break;
+ return (ARCHIVE_OK);
}
- __LA_FALLTHROUGH;
+ break;
case 'g':
if (strcmp(key, "gid") == 0) {
*parsed_kws |= MTREE_HAS_GID;
archive_entry_set_gid(entry, mtree_atol(&val, 10));
- break;
+ return (ARCHIVE_OK);
}
if (strcmp(key, "gname") == 0) {
*parsed_kws |= MTREE_HAS_GNAME;
archive_entry_copy_gname(entry, val);
- break;
+ return (ARCHIVE_OK);
}
- __LA_FALLTHROUGH;
+ break;
case 'i':
if (strcmp(key, "inode") == 0) {
archive_entry_set_ino(entry, mtree_atol(&val, 10));
- break;
+ return (ARCHIVE_OK);
}
- __LA_FALLTHROUGH;
+ break;
case 'l':
if (strcmp(key, "link") == 0) {
+ parse_escapes(val, NULL);
archive_entry_copy_symlink(entry, val);
- break;
+ return (ARCHIVE_OK);
}
- __LA_FALLTHROUGH;
+ break;
case 'm':
if (strcmp(key, "md5") == 0 || strcmp(key, "md5digest") == 0) {
return parse_digest(a, entry, val,
ARCHIVE_ENTRY_DIGEST_MD5);
}
if (strcmp(key, "mode") == 0) {
- if (val[0] >= '0' && val[0] <= '7') {
- *parsed_kws |= MTREE_HAS_PERM;
- archive_entry_set_perm(entry,
- (mode_t)mtree_atol(&val, 8));
- } else {
+ if (val[0] < '0' || val[0] > '7') {
archive_set_error(&a->archive,
ARCHIVE_ERRNO_FILE_FORMAT,
"Symbolic or non-octal mode \"%s\" unsupported", val);
- return ARCHIVE_WARN;
+ return (ARCHIVE_WARN);
}
- break;
+ *parsed_kws |= MTREE_HAS_PERM;
+ archive_entry_set_perm(entry, (mode_t)mtree_atol(&val, 8));
+ return (ARCHIVE_OK);
}
- __LA_FALLTHROUGH;
+ break;
case 'n':
if (strcmp(key, "nlink") == 0) {
*parsed_kws |= MTREE_HAS_NLINK;
archive_entry_set_nlink(entry,
(unsigned int)mtree_atol(&val, 10));
- break;
+ return (ARCHIVE_OK);
}
- __LA_FALLTHROUGH;
+ break;
case 'r':
if (strcmp(key, "resdevice") == 0) {
/* stat(2) st_dev field, e.g. the device ID where the
@@ -1723,7 +1722,7 @@
return parse_digest(a, entry, val,
ARCHIVE_ENTRY_DIGEST_RMD160);
}
- __LA_FALLTHROUGH;
+ break;
case 's':
if (strcmp(key, "sha1") == 0 ||
strcmp(key, "sha1digest") == 0) {
@@ -1747,9 +1746,9 @@
}
if (strcmp(key, "size") == 0) {
archive_entry_set_size(entry, mtree_atol(&val, 10));
- break;
+ return (ARCHIVE_OK);
}
- __LA_FALLTHROUGH;
+ break;
case 't':
if (strcmp(key, "tags") == 0) {
/*
@@ -1757,7 +1756,7 @@
* Ignore the tags for now, but the interface
* should be extended to allow inclusion/exclusion.
*/
- break;
+ return (ARCHIVE_OK);
}
if (strcmp(key, "time") == 0) {
int64_t m;
@@ -1783,79 +1782,85 @@
else if (m < my_time_t_min)
m = my_time_t_min;
archive_entry_set_mtime(entry, (time_t)m, ns);
- break;
+ return (ARCHIVE_OK);
}
if (strcmp(key, "type") == 0) {
switch (val[0]) {
case 'b':
if (strcmp(val, "block") == 0) {
- archive_entry_set_filetype(entry, AE_IFBLK);
- break;
+ *parsed_kws |= MTREE_HAS_TYPE;
+ archive_entry_set_filetype(entry,
+ AE_IFBLK);
+ return (ARCHIVE_OK);
}
- __LA_FALLTHROUGH;
+ break;
case 'c':
if (strcmp(val, "char") == 0) {
+ *parsed_kws |= MTREE_HAS_TYPE;
archive_entry_set_filetype(entry,
AE_IFCHR);
- break;
+ return (ARCHIVE_OK);
}
- __LA_FALLTHROUGH;
+ break;
case 'd':
if (strcmp(val, "dir") == 0) {
+ *parsed_kws |= MTREE_HAS_TYPE;
archive_entry_set_filetype(entry,
AE_IFDIR);
- break;
+ return (ARCHIVE_OK);
}
- __LA_FALLTHROUGH;
+ break;
case 'f':
if (strcmp(val, "fifo") == 0) {
+ *parsed_kws |= MTREE_HAS_TYPE;
archive_entry_set_filetype(entry,
AE_IFIFO);
- break;
+ return (ARCHIVE_OK);
}
if (strcmp(val, "file") == 0) {
+ *parsed_kws |= MTREE_HAS_TYPE;
archive_entry_set_filetype(entry,
AE_IFREG);
- break;
+ return (ARCHIVE_OK);
}
- __LA_FALLTHROUGH;
+ break;
case 'l':
if (strcmp(val, "link") == 0) {
+ *parsed_kws |= MTREE_HAS_TYPE;
archive_entry_set_filetype(entry,
AE_IFLNK);
- break;
+ return (ARCHIVE_OK);
}
- __LA_FALLTHROUGH;
+ break;
default:
- archive_set_error(&a->archive,
- ARCHIVE_ERRNO_FILE_FORMAT,
- "Unrecognized file type \"%s\"; "
- "assuming \"file\"", val);
- archive_entry_set_filetype(entry, AE_IFREG);
- return (ARCHIVE_WARN);
+ break;
}
- *parsed_kws |= MTREE_HAS_TYPE;
- break;
+ archive_set_error(&a->archive,
+ ARCHIVE_ERRNO_FILE_FORMAT,
+ "Unrecognized file type \"%s\"; "
+ "assuming \"file\"", val);
+ archive_entry_set_filetype(entry, AE_IFREG);
+ return (ARCHIVE_WARN);
}
- __LA_FALLTHROUGH;
+ break;
case 'u':
if (strcmp(key, "uid") == 0) {
*parsed_kws |= MTREE_HAS_UID;
archive_entry_set_uid(entry, mtree_atol(&val, 10));
- break;
+ return (ARCHIVE_OK);
}
if (strcmp(key, "uname") == 0) {
*parsed_kws |= MTREE_HAS_UNAME;
archive_entry_copy_uname(entry, val);
- break;
+ return (ARCHIVE_OK);
}
- __LA_FALLTHROUGH;
+ break;
default:
- archive_set_error(&a->archive, ARCHIVE_ERRNO_FILE_FORMAT,
- "Unrecognized key %s=%s", key, val);
- return (ARCHIVE_WARN);
+ break;
}
- return (ARCHIVE_OK);
+ archive_set_error(&a->archive, ARCHIVE_ERRNO_FILE_FORMAT,
+ "Unrecognized key %s=%s", key, val);
+ return (ARCHIVE_WARN);
}
static int
@@ -2035,13 +2040,13 @@
if (**p == '-') {
limit = INT64_MIN / base;
- last_digit_limit = INT64_MIN % base;
+ last_digit_limit = -(INT64_MIN % base);
++(*p);
l = 0;
digit = parsedigit(**p);
while (digit >= 0 && digit < base) {
- if (l < limit || (l == limit && digit > last_digit_limit))
+ if (l < limit || (l == limit && digit >= last_digit_limit))
return INT64_MIN;
l = (l * base) - digit;
digit = parsedigit(*++(*p));
diff --git a/Utilities/cmlibarchive/libarchive/archive_read_support_format_rar.c b/Utilities/cmlibarchive/libarchive/archive_read_support_format_rar.c
index 6dca350..5c02a25 100644
--- a/Utilities/cmlibarchive/libarchive/archive_read_support_format_rar.c
+++ b/Utilities/cmlibarchive/libarchive/archive_read_support_format_rar.c
@@ -135,6 +135,16 @@
#define MAX_SYMBOL_LENGTH 0xF
#define MAX_SYMBOLS 20
+/* Virtual Machine Properties */
+#define VM_MEMORY_SIZE 0x40000
+#define VM_MEMORY_MASK (VM_MEMORY_SIZE - 1)
+#define PROGRAM_WORK_SIZE 0x3C000
+#define PROGRAM_GLOBAL_SIZE 0x2000
+#define PROGRAM_SYSTEM_GLOBAL_ADDRESS PROGRAM_WORK_SIZE
+#define PROGRAM_SYSTEM_GLOBAL_SIZE 0x40
+#define PROGRAM_USER_GLOBAL_ADDRESS (PROGRAM_SYSTEM_GLOBAL_ADDRESS + PROGRAM_SYSTEM_GLOBAL_SIZE)
+#define PROGRAM_USER_GLOBAL_SIZE (PROGRAM_GLOBAL_SIZE - PROGRAM_SYSTEM_GLOBAL_SIZE)
+
/*
* Considering L1,L2 cache miss and a calling of write system-call,
* the best size of the output buffer(uncompressed buffer) is 128K.
@@ -213,6 +223,69 @@
int64_t end_offset;
};
+struct rar_program_code
+{
+ uint8_t *staticdata;
+ uint32_t staticdatalen;
+ uint8_t *globalbackup;
+ uint32_t globalbackuplen;
+ uint64_t fingerprint;
+ uint32_t usagecount;
+ uint32_t oldfilterlength;
+ struct rar_program_code *next;
+};
+
+struct rar_filter
+{
+ struct rar_program_code *prog;
+ uint32_t initialregisters[8];
+ uint8_t *globaldata;
+ uint32_t globaldatalen;
+ size_t blockstartpos;
+ uint32_t blocklength;
+ uint32_t filteredblockaddress;
+ uint32_t filteredblocklength;
+ struct rar_filter *next;
+};
+
+struct memory_bit_reader
+{
+ const uint8_t *bytes;
+ size_t length;
+ size_t offset;
+ uint64_t bits;
+ int available;
+ int at_eof;
+};
+
+struct rar_virtual_machine
+{
+ uint32_t registers[8];
+ uint8_t memory[VM_MEMORY_SIZE + sizeof(uint32_t)];
+};
+
+struct rar_filters
+{
+ struct rar_virtual_machine *vm;
+ struct rar_program_code *progs;
+ struct rar_filter *stack;
+ int64_t filterstart;
+ uint32_t lastfilternum;
+ int64_t lastend;
+ uint8_t *bytes;
+ size_t bytes_ready;
+};
+
+struct audio_state
+{
+ int8_t weight[5];
+ int16_t delta[4];
+ int8_t lastdelta;
+ int error[11];
+ int count;
+ uint8_t lastbyte;
+};
+
struct rar
{
/* Entries from main RAR header */
@@ -273,15 +346,16 @@
struct huffman_code lengthcode;
unsigned char lengthtable[HUFFMAN_TABLE_SIZE];
struct lzss lzss;
- char output_last_match;
unsigned int lastlength;
unsigned int lastoffset;
unsigned int oldoffset[4];
unsigned int lastlowoffset;
unsigned int numlowoffsetrepeats;
- int64_t filterstart;
char start_new_table;
+ /* Filters */
+ struct rar_filters filters;
+
/* PPMd Variant H members */
char ppmd_valid;
char ppmd_eod;
@@ -343,13 +417,13 @@
static int read_data_stored(struct archive_read *, const void **, size_t *,
int64_t *);
static int read_data_compressed(struct archive_read *, const void **, size_t *,
- int64_t *, size_t);
+ int64_t *, size_t);
static int rar_br_preparation(struct archive_read *, struct rar_br *);
static int parse_codes(struct archive_read *);
static void free_codes(struct archive_read *);
static int read_next_symbol(struct archive_read *, struct huffman_code *);
static int create_code(struct archive_read *, struct huffman_code *,
- unsigned char *, int, char);
+ unsigned char *, int, char);
static int add_value(struct archive_read *, struct huffman_code *, int, int,
int);
static int new_node(struct huffman_code *);
@@ -357,9 +431,29 @@
static int make_table_recurse(struct archive_read *, struct huffman_code *, int,
struct huffman_table_entry *, int, int);
static int64_t expand(struct archive_read *, int64_t);
-static int copy_from_lzss_window(struct archive_read *, const void **,
- int64_t, int);
+static int copy_from_lzss_window_to_unp(struct archive_read *, const void **,
+ int64_t, int);
static const void *rar_read_ahead(struct archive_read *, size_t, ssize_t *);
+static int parse_filter(struct archive_read *, const uint8_t *, uint16_t,
+ uint8_t);
+static int run_filters(struct archive_read *);
+static void clear_filters(struct rar_filters *);
+static struct rar_filter *create_filter(struct rar_program_code *,
+ const uint8_t *, uint32_t,
+ uint32_t[8], size_t, uint32_t);
+static void delete_filter(struct rar_filter *filter);
+static struct rar_program_code *compile_program(const uint8_t *, size_t);
+static void delete_program_code(struct rar_program_code *prog);
+static uint32_t membr_next_rarvm_number(struct memory_bit_reader *br);
+static inline uint32_t membr_bits(struct memory_bit_reader *br, int bits);
+static int membr_fill(struct memory_bit_reader *br, int bits);
+static int read_filter(struct archive_read *, int64_t *);
+static int rar_decode_byte(struct archive_read*, uint8_t *);
+static int execute_filter(struct archive_read*, struct rar_filter *,
+ struct rar_virtual_machine *, size_t);
+static int copy_from_lzss_window(struct archive_read *, void *, int64_t, int);
+static inline void vm_write_32(struct rar_virtual_machine*, size_t, uint32_t);
+static inline uint32_t vm_read_32(struct rar_virtual_machine*, size_t);
/*
* Bit stream reader.
@@ -958,17 +1052,17 @@
crc32_val = 0;
while (skip > 0) {
size_t to_read = skip;
- ssize_t did_read;
- if (to_read > 32 * 1024) {
+ if (to_read > 32 * 1024)
to_read = 32 * 1024;
- }
- if ((h = __archive_read_ahead(a, to_read, &did_read)) == NULL) {
+ if ((h = __archive_read_ahead(a, to_read, NULL)) == NULL) {
+ archive_set_error(&a->archive, ARCHIVE_ERRNO_FILE_FORMAT,
+ "Bad RAR file");
return (ARCHIVE_FATAL);
}
p = h;
- crc32_val = crc32(crc32_val, (const unsigned char *)p, (unsigned)did_read);
- __archive_read_consume(a, did_read);
- skip -= did_read;
+ crc32_val = crc32(crc32_val, (const unsigned char *)p, to_read);
+ __archive_read_consume(a, to_read);
+ skip -= to_read;
}
if ((crc32_val & 0xffff) != crc32_expected) {
archive_set_error(&a->archive, ARCHIVE_ERRNO_FILE_FORMAT,
@@ -1244,6 +1338,7 @@
rar = (struct rar *)(a->format->data);
free_codes(a);
+ clear_filters(&rar->filters);
free(rar->filename);
free(rar->filename_save);
free(rar->dbo);
@@ -1662,6 +1757,7 @@
memset(rar->lengthtable, 0, sizeof(rar->lengthtable));
__archive_ppmd7_functions.Ppmd7_Free(&rar->ppmd7_context);
rar->ppmd_valid = rar->ppmd_eod = 0;
+ rar->filters.filterstart = INT64_MAX;
/* Don't set any archive entries for non-file header types */
if (head_type == NEWSUB_HEAD)
@@ -1886,7 +1982,7 @@
static int
read_data_compressed(struct archive_read *a, const void **buff, size_t *size,
- int64_t *offset, size_t looper)
+ int64_t *offset, size_t looper)
{
if (looper++ > MAX_COMPRESS_DEPTH)
return (ARCHIVE_FATAL);
@@ -1901,6 +1997,33 @@
do {
if (!rar->valid)
return (ARCHIVE_FATAL);
+
+ if (rar->filters.bytes_ready > 0)
+ {
+ /* Flush unp_buffer first */
+ if (rar->unp_offset > 0)
+ {
+ *buff = rar->unp_buffer;
+ *size = rar->unp_offset;
+ rar->unp_offset = 0;
+ *offset = rar->offset_outgoing;
+ rar->offset_outgoing += *size;
+ }
+ else
+ {
+ *buff = rar->filters.bytes;
+ *size = rar->filters.bytes_ready;
+
+ rar->offset += *size;
+ *offset = rar->offset_outgoing;
+ rar->offset_outgoing += *size;
+
+ rar->filters.bytes_ready -= *size;
+ rar->filters.bytes += *size;
+ }
+ goto ending_block;
+ }
+
if (rar->ppmd_eod ||
(rar->dictionary_size && rar->offset >= rar->unp_size))
{
@@ -1936,7 +2059,7 @@
bs = rar->unp_buffer_size - rar->unp_offset;
else
bs = (size_t)rar->bytes_uncopied;
- ret = copy_from_lzss_window(a, buff, rar->offset, (int)bs);
+ ret = copy_from_lzss_window_to_unp(a, buff, rar->offset, (int)bs);
if (ret != ARCHIVE_OK)
return (ret);
rar->offset += bs;
@@ -1954,6 +2077,13 @@
continue;
}
+ if (rar->filters.lastend == rar->filters.filterstart)
+ {
+ if (!run_filters(a))
+ return (ARCHIVE_FATAL);
+ continue;
+ }
+
if (!rar->br.next_in &&
(ret = rar_br_preparation(a, &(rar->br))) < ARCHIVE_WARN)
return (ret);
@@ -2045,13 +2175,16 @@
{
start = rar->offset;
end = start + rar->dictionary_size;
- rar->filterstart = INT64_MAX;
+ if (rar->filters.filterstart < end) {
+ end = rar->filters.filterstart;
+ }
if ((actualend = expand(a, end)) < 0)
return ((int)actualend);
rar->bytes_uncopied = actualend - start;
- if (rar->bytes_uncopied == 0) {
+ rar->filters.lastend = actualend;
+ if (rar->filters.lastend != rar->filters.filterstart && rar->bytes_uncopied == 0) {
/* Broken RAR files cause this case.
* NOTE: If this case were possible on a normal RAR file
* we would find out where it was actually bad and
@@ -2065,7 +2198,7 @@
bs = rar->unp_buffer_size - rar->unp_offset;
else
bs = (size_t)rar->bytes_uncopied;
- ret = copy_from_lzss_window(a, buff, rar->offset, (int)bs);
+ ret = copy_from_lzss_window_to_unp(a, buff, rar->offset, (int)bs);
if (ret != ARCHIVE_OK)
return (ret);
rar->offset += bs;
@@ -2080,6 +2213,7 @@
*size = rar->unp_buffer_size;
*offset = rar->offset_outgoing;
rar->offset_outgoing += *size;
+ending_block:
/* Calculate File CRC. */
rar->crc_calculated = crc32(rar->crc_calculated, *buff, (unsigned)*size);
return ret;
@@ -2739,25 +2873,19 @@
struct rar *rar = (struct rar *)(a->format->data);
struct rar_br *br = &(rar->br);
- if (rar->filterstart < end)
- end = rar->filterstart;
+ if (rar->filters.filterstart < end)
+ end = rar->filters.filterstart;
while (1)
{
- if (rar->output_last_match &&
- lzss_position(&rar->lzss) + rar->lastlength <= end)
- {
- lzss_emit_match(rar, rar->lastoffset, rar->lastlength);
- rar->output_last_match = 0;
- }
+ if(lzss_position(&rar->lzss) >= end)
+ return end;
- if(rar->is_ppmd_block || rar->output_last_match ||
- lzss_position(&rar->lzss) >= end)
+ if(rar->is_ppmd_block)
return lzss_position(&rar->lzss);
if ((symbol = read_next_symbol(a, &rar->maincode)) < 0)
return (ARCHIVE_FATAL);
- rar->output_last_match = 0;
if (symbol < 256)
{
@@ -2789,9 +2917,9 @@
}
else if(symbol==257)
{
- archive_set_error(&a->archive, ARCHIVE_ERRNO_MISC,
- "Parsing filters is unsupported.");
- return (ARCHIVE_FAILED);
+ if (!read_filter(a, &end))
+ return (ARCHIVE_FATAL);
+ continue;
}
else if(symbol==258)
{
@@ -2864,7 +2992,7 @@
goto truncated_data;
offs += rar_br_bits(br, offsetbits[offssymbol] - 4) << 4;
rar_br_consume(br, offsetbits[offssymbol] - 4);
- }
+ }
if(rar->numlowoffsetrepeats > 0)
{
@@ -2908,7 +3036,8 @@
rar->lastoffset = offs;
rar->lastlength = len;
- rar->output_last_match = 1;
+
+ lzss_emit_match(rar, rar->lastoffset, rar->lastlength);
}
truncated_data:
archive_set_error(&a->archive, ARCHIVE_ERRNO_FILE_FORMAT,
@@ -2922,8 +3051,31 @@
}
static int
-copy_from_lzss_window(struct archive_read *a, const void **buffer,
- int64_t startpos, int length)
+copy_from_lzss_window(struct archive_read *a, void *buffer,
+ int64_t startpos, int length)
+{
+ int windowoffs, firstpart;
+ struct rar *rar = (struct rar *)(a->format->data);
+
+ windowoffs = lzss_offset_for_position(&rar->lzss, startpos);
+ firstpart = lzss_size(&rar->lzss) - windowoffs;
+ if (firstpart < 0) {
+ archive_set_error(&a->archive, ARCHIVE_ERRNO_FILE_FORMAT,
+ "Bad RAR file data");
+ return (ARCHIVE_FATAL);
+ }
+ if (firstpart < length) {
+ memcpy(buffer, &rar->lzss.window[windowoffs], firstpart);
+ memcpy(buffer, &rar->lzss.window[0], length - firstpart);
+ } else {
+ memcpy(buffer, &rar->lzss.window[windowoffs], length);
+ }
+ return (ARCHIVE_OK);
+}
+
+static int
+copy_from_lzss_window_to_unp(struct archive_read *a, const void **buffer,
+ int64_t startpos, int length)
{
int windowoffs, firstpart;
struct rar *rar = (struct rar *)(a->format->data);
@@ -3003,3 +3155,599 @@
}
return h;
}
+
+static int
+parse_filter(struct archive_read *a, const uint8_t *bytes, uint16_t length, uint8_t flags)
+{
+ struct rar *rar = (struct rar *)(a->format->data);
+ struct rar_filters *filters = &rar->filters;
+
+ struct memory_bit_reader br = { 0 };
+ struct rar_program_code *prog;
+ struct rar_filter *filter, **nextfilter;
+
+ uint32_t numprogs, num, blocklength, globaldatalen;
+ uint8_t *globaldata;
+ size_t blockstartpos;
+ uint32_t registers[8] = { 0 };
+ uint32_t i;
+
+ br.bytes = bytes;
+ br.length = length;
+
+ numprogs = 0;
+ for (prog = filters->progs; prog; prog = prog->next)
+ numprogs++;
+
+ if ((flags & 0x80))
+ {
+ num = membr_next_rarvm_number(&br);
+ if (num == 0)
+ {
+ delete_filter(filters->stack);
+ filters->stack = NULL;
+ delete_program_code(filters->progs);
+ filters->progs = NULL;
+ }
+ else
+ num--;
+ if (num > numprogs) {
+ return 0;
+ }
+ filters->lastfilternum = num;
+ }
+ else
+ num = filters->lastfilternum;
+
+ prog = filters->progs;
+ for (i = 0; i < num; i++)
+ prog = prog->next;
+ if (prog)
+ prog->usagecount++;
+
+ blockstartpos = membr_next_rarvm_number(&br) + (size_t)lzss_position(&rar->lzss);
+ if ((flags & 0x40))
+ blockstartpos += 258;
+ if ((flags & 0x20))
+ blocklength = membr_next_rarvm_number(&br);
+ else
+ blocklength = prog ? prog->oldfilterlength : 0;
+
+ registers[3] = PROGRAM_SYSTEM_GLOBAL_ADDRESS;
+ registers[4] = blocklength;
+ registers[5] = prog ? prog->usagecount : 0;
+ registers[7] = VM_MEMORY_SIZE;
+
+ if ((flags & 0x10))
+ {
+ uint8_t mask = (uint8_t)membr_bits(&br, 7);
+ for (i = 0; i < 7; i++)
+ if ((mask & (1 << i)))
+ registers[i] = membr_next_rarvm_number(&br);
+ }
+
+ if (!prog)
+ {
+ uint32_t len = membr_next_rarvm_number(&br);
+ uint8_t *bytecode;
+ struct rar_program_code **next;
+
+ if (len == 0 || len > 0x10000)
+ return 0;
+ bytecode = malloc(len);
+ if (!bytecode)
+ return 0;
+ for (i = 0; i < len; i++)
+ bytecode[i] = (uint8_t)membr_bits(&br, 8);
+ prog = compile_program(bytecode, len);
+ if (!prog) {
+ free(bytecode);
+ return 0;
+ }
+ free(bytecode);
+ next = &filters->progs;
+ while (*next)
+ next = &(*next)->next;
+ *next = prog;
+ }
+ prog->oldfilterlength = blocklength;
+
+ globaldata = NULL;
+ globaldatalen = 0;
+ if ((flags & 0x08))
+ {
+ globaldatalen = membr_next_rarvm_number(&br);
+ if (globaldatalen > PROGRAM_USER_GLOBAL_SIZE)
+ return 0;
+ globaldata = malloc(globaldatalen + PROGRAM_SYSTEM_GLOBAL_SIZE);
+ if (!globaldata)
+ return 0;
+ for (i = 0; i < globaldatalen; i++)
+ globaldata[i + PROGRAM_SYSTEM_GLOBAL_SIZE] = (uint8_t)membr_bits(&br, 8);
+ }
+
+ if (br.at_eof)
+ {
+ free(globaldata);
+ return 0;
+ }
+
+ filter = create_filter(prog, globaldata, globaldatalen, registers, blockstartpos, blocklength);
+ free(globaldata);
+ if (!filter)
+ return 0;
+
+ for (i = 0; i < 7; i++)
+ archive_le32enc(&filter->globaldata[i * 4], registers[i]);
+ archive_le32enc(&filter->globaldata[0x1C], blocklength);
+ archive_le32enc(&filter->globaldata[0x20], 0);
+ archive_le32enc(&filter->globaldata[0x2C], prog->usagecount);
+
+ nextfilter = &filters->stack;
+ while (*nextfilter)
+ nextfilter = &(*nextfilter)->next;
+ *nextfilter = filter;
+
+ if (!filters->stack->next)
+ filters->filterstart = blockstartpos;
+
+ return 1;
+}
+
+static struct rar_filter *
+create_filter(struct rar_program_code *prog, const uint8_t *globaldata, uint32_t globaldatalen, uint32_t registers[8], size_t startpos, uint32_t length)
+{
+ struct rar_filter *filter;
+
+ filter = calloc(1, sizeof(*filter));
+ if (!filter)
+ return NULL;
+ filter->prog = prog;
+ filter->globaldatalen = globaldatalen > PROGRAM_SYSTEM_GLOBAL_SIZE ? globaldatalen : PROGRAM_SYSTEM_GLOBAL_SIZE;
+ filter->globaldata = calloc(1, filter->globaldatalen);
+ if (!filter->globaldata)
+ return NULL;
+ if (globaldata)
+ memcpy(filter->globaldata, globaldata, globaldatalen);
+ if (registers)
+ memcpy(filter->initialregisters, registers, sizeof(filter->initialregisters));
+ filter->blockstartpos = startpos;
+ filter->blocklength = length;
+
+ return filter;
+}
+
+static int
+run_filters(struct archive_read *a)
+{
+ struct rar *rar = (struct rar *)(a->format->data);
+ struct rar_filters *filters = &rar->filters;
+ struct rar_filter *filter = filters->stack;
+ size_t start = filters->filterstart;
+ size_t end = start + filter->blocklength;
+ uint32_t lastfilteraddress;
+ uint32_t lastfilterlength;
+ int ret;
+
+ filters->filterstart = INT64_MAX;
+ end = (size_t)expand(a, end);
+ if (end != start + filter->blocklength)
+ return 0;
+
+ if (!filters->vm)
+ {
+ filters->vm = calloc(1, sizeof(*filters->vm));
+ if (!filters->vm)
+ return 0;
+ }
+
+ ret = copy_from_lzss_window(a, filters->vm->memory, start, filter->blocklength);
+ if (ret != ARCHIVE_OK)
+ return 0;
+ if (!execute_filter(a, filter, filters->vm, rar->offset))
+ return 0;
+
+ lastfilteraddress = filter->filteredblockaddress;
+ lastfilterlength = filter->filteredblocklength;
+ filters->stack = filter->next;
+ filter->next = NULL;
+ delete_filter(filter);
+
+ while ((filter = filters->stack) != NULL && (int64_t)filter->blockstartpos == filters->filterstart && filter->blocklength == lastfilterlength)
+ {
+ memmove(&filters->vm->memory[0], &filters->vm->memory[lastfilteraddress], lastfilterlength);
+ if (!execute_filter(a, filter, filters->vm, rar->offset))
+ return 0;
+
+ lastfilteraddress = filter->filteredblockaddress;
+ lastfilterlength = filter->filteredblocklength;
+ filters->stack = filter->next;
+ filter->next = NULL;
+ delete_filter(filter);
+ }
+
+ if (filters->stack)
+ {
+ if (filters->stack->blockstartpos < end)
+ return 0;
+ filters->filterstart = filters->stack->blockstartpos;
+ }
+
+ filters->lastend = end;
+ filters->bytes = &filters->vm->memory[lastfilteraddress];
+ filters->bytes_ready = lastfilterlength;
+
+ return 1;
+}
+
+static struct rar_program_code *
+compile_program(const uint8_t *bytes, size_t length)
+{
+ struct memory_bit_reader br = { 0 };
+ struct rar_program_code *prog;
+ // uint32_t instrcount = 0;
+ uint8_t xor;
+ size_t i;
+
+ xor = 0;
+ for (i = 1; i < length; i++)
+ xor ^= bytes[i];
+ if (!length || xor != bytes[0])
+ return NULL;
+
+ br.bytes = bytes;
+ br.length = length;
+ br.offset = 1;
+
+ prog = calloc(1, sizeof(*prog));
+ if (!prog)
+ return NULL;
+ prog->fingerprint = crc32(0, bytes, length) | ((uint64_t)length << 32);
+
+ if (membr_bits(&br, 1))
+ {
+ prog->staticdatalen = membr_next_rarvm_number(&br) + 1;
+ prog->staticdata = malloc(prog->staticdatalen);
+ if (!prog->staticdata)
+ {
+ delete_program_code(prog);
+ return NULL;
+ }
+ for (i = 0; i < prog->staticdatalen; i++)
+ prog->staticdata[i] = (uint8_t)membr_bits(&br, 8);
+ }
+
+ return prog;
+}
+
+static void
+delete_filter(struct rar_filter *filter)
+{
+ while (filter)
+ {
+ struct rar_filter *next = filter->next;
+ free(filter->globaldata);
+ free(filter);
+ filter = next;
+ }
+}
+
+static void
+clear_filters(struct rar_filters *filters)
+{
+ delete_filter(filters->stack);
+ delete_program_code(filters->progs);
+ free(filters->vm);
+}
+
+static void
+delete_program_code(struct rar_program_code *prog)
+{
+ while (prog)
+ {
+ struct rar_program_code *next = prog->next;
+ free(prog->staticdata);
+ free(prog->globalbackup);
+ free(prog);
+ prog = next;
+ }
+}
+
+static uint32_t
+membr_next_rarvm_number(struct memory_bit_reader *br)
+{
+ uint32_t val;
+ switch (membr_bits(br, 2))
+ {
+ case 0:
+ return membr_bits(br, 4);
+ case 1:
+ val = membr_bits(br, 8);
+ if (val >= 16)
+ return val;
+ return 0xFFFFFF00 | (val << 4) | membr_bits(br, 4);
+ case 2:
+ return membr_bits(br, 16);
+ default:
+ return membr_bits(br, 32);
+ }
+}
+
+static inline uint32_t
+membr_bits(struct memory_bit_reader *br, int bits)
+{
+ if (bits > br->available && (br->at_eof || !membr_fill(br, bits)))
+ return 0;
+ return (uint32_t)((br->bits >> (br->available -= bits)) & (((uint64_t)1 << bits) - 1));
+}
+
+static int
+membr_fill(struct memory_bit_reader *br, int bits)
+{
+ while (br->available < bits && br->offset < br->length)
+ {
+ br->bits = (br->bits << 8) | br->bytes[br->offset++];
+ br->available += 8;
+ }
+ if (bits > br->available)
+ {
+ br->at_eof = 1;
+ return 0;
+ }
+ return 1;
+}
+
+static int
+read_filter(struct archive_read *a, int64_t *end)
+{
+ struct rar *rar = (struct rar *)(a->format->data);
+ uint8_t flags, val, *code;
+ uint16_t length, i;
+
+ if (!rar_decode_byte(a, &flags))
+ return 0;
+ length = (flags & 0x07) + 1;
+ if (length == 7)
+ {
+ if (!rar_decode_byte(a, &val))
+ return 0;
+ length = val + 7;
+ }
+ else if (length == 8)
+ {
+ if (!rar_decode_byte(a, &val))
+ return 0;
+ length = val << 8;
+ if (!rar_decode_byte(a, &val))
+ return 0;
+ length |= val;
+ }
+
+ code = malloc(length);
+ if (!code)
+ return 0;
+ for (i = 0; i < length; i++)
+ {
+ if (!rar_decode_byte(a, &code[i]))
+ {
+ free(code);
+ return 0;
+ }
+ }
+ if (!parse_filter(a, code, length, flags))
+ {
+ free(code);
+ return 0;
+ }
+ free(code);
+
+ if (rar->filters.filterstart < *end)
+ *end = rar->filters.filterstart;
+
+ return 1;
+}
+
+static int
+execute_filter_delta(struct rar_filter *filter, struct rar_virtual_machine *vm)
+{
+ uint32_t length = filter->initialregisters[4];
+ uint32_t numchannels = filter->initialregisters[0];
+ uint8_t *src, *dst;
+ uint32_t i, idx;
+
+ if (length > PROGRAM_WORK_SIZE / 2)
+ return 0;
+
+ src = &vm->memory[0];
+ dst = &vm->memory[length];
+ for (i = 0; i < numchannels; i++)
+ {
+ uint8_t lastbyte = 0;
+ for (idx = i; idx < length; idx += numchannels)
+ lastbyte = dst[idx] = lastbyte - *src++;
+ }
+
+ filter->filteredblockaddress = length;
+ filter->filteredblocklength = length;
+
+ return 1;
+}
+
+static int
+execute_filter_e8(struct rar_filter *filter, struct rar_virtual_machine *vm, size_t pos, int e9also)
+{
+ uint32_t length = filter->initialregisters[4];
+ uint32_t filesize = 0x1000000;
+ uint32_t i;
+
+ if (length > PROGRAM_WORK_SIZE || length < 4)
+ return 0;
+
+ for (i = 0; i <= length - 5; i++)
+ {
+ if (vm->memory[i] == 0xE8 || (e9also && vm->memory[i] == 0xE9))
+ {
+ uint32_t currpos = (uint32_t)pos + i + 1;
+ int32_t address = (int32_t)vm_read_32(vm, i + 1);
+ if (address < 0 && currpos >= (uint32_t)-address)
+ vm_write_32(vm, i + 1, address + filesize);
+ else if (address >= 0 && (uint32_t)address < filesize)
+ vm_write_32(vm, i + 1, address - currpos);
+ i += 4;
+ }
+ }
+
+ filter->filteredblockaddress = 0;
+ filter->filteredblocklength = length;
+
+ return 1;
+}
+
+static int
+execute_filter_rgb(struct rar_filter *filter, struct rar_virtual_machine *vm)
+{
+ uint32_t stride = filter->initialregisters[0];
+ uint32_t byteoffset = filter->initialregisters[1];
+ uint32_t blocklength = filter->initialregisters[4];
+ uint8_t *src, *dst;
+ uint32_t i, j;
+
+ if (blocklength > PROGRAM_WORK_SIZE / 2 || stride > blocklength)
+ return 0;
+
+ src = &vm->memory[0];
+ dst = &vm->memory[blocklength];
+ for (i = 0; i < 3; i++) {
+ uint8_t byte = 0;
+ uint8_t *prev = dst + i - stride;
+ for (j = i; j < blocklength; j += 3)
+ {
+ if (prev >= dst)
+ {
+ uint32_t delta1 = abs(prev[3] - prev[0]);
+ uint32_t delta2 = abs(byte - prev[0]);
+ uint32_t delta3 = abs(prev[3] - prev[0] + byte - prev[0]);
+ if (delta1 > delta2 || delta1 > delta3)
+ byte = delta2 <= delta3 ? prev[3] : prev[0];
+ }
+ byte -= *src++;
+ dst[j] = byte;
+ prev += 3;
+ }
+ }
+ for (i = byteoffset; i < blocklength - 2; i += 3)
+ {
+ dst[i] += dst[i + 1];
+ dst[i + 2] += dst[i + 1];
+ }
+
+ filter->filteredblockaddress = blocklength;
+ filter->filteredblocklength = blocklength;
+
+ return 1;
+}
+
+static int
+execute_filter_audio(struct rar_filter *filter, struct rar_virtual_machine *vm)
+{
+ uint32_t length = filter->initialregisters[4];
+ uint32_t numchannels = filter->initialregisters[0];
+ uint8_t *src, *dst;
+ uint32_t i, j;
+
+ if (length > PROGRAM_WORK_SIZE / 2)
+ return 0;
+
+ src = &vm->memory[0];
+ dst = &vm->memory[length];
+ for (i = 0; i < numchannels; i++)
+ {
+ struct audio_state state;
+ memset(&state, 0, sizeof(state));
+ for (j = i; j < length; j += numchannels)
+ {
+ int8_t delta = (int8_t)*src++;
+ uint8_t predbyte, byte;
+ int prederror;
+ state.delta[2] = state.delta[1];
+ state.delta[1] = state.lastdelta - state.delta[0];
+ state.delta[0] = state.lastdelta;
+ predbyte = ((8 * state.lastbyte + state.weight[0] * state.delta[0] + state.weight[1] * state.delta[1] + state.weight[2] * state.delta[2]) >> 3) & 0xFF;
+ byte = (predbyte - delta) & 0xFF;
+ prederror = delta << 3;
+ state.error[0] += abs(prederror);
+ state.error[1] += abs(prederror - state.delta[0]); state.error[2] += abs(prederror + state.delta[0]);
+ state.error[3] += abs(prederror - state.delta[1]); state.error[4] += abs(prederror + state.delta[1]);
+ state.error[5] += abs(prederror - state.delta[2]); state.error[6] += abs(prederror + state.delta[2]);
+ state.lastdelta = (int8_t)(byte - state.lastbyte);
+ dst[j] = state.lastbyte = byte;
+ if (!(state.count++ & 0x1F))
+ {
+ uint8_t k, idx = 0;
+ for (k = 1; k < 7; k++)
+ {
+ if (state.error[k] < state.error[idx])
+ idx = k;
+ }
+ memset(state.error, 0, sizeof(state.error));
+ switch (idx)
+ {
+ case 1: if (state.weight[0] >= -16) state.weight[0]--; break;
+ case 2: if (state.weight[0] < 16) state.weight[0]++; break;
+ case 3: if (state.weight[1] >= -16) state.weight[1]--; break;
+ case 4: if (state.weight[1] < 16) state.weight[1]++; break;
+ case 5: if (state.weight[2] >= -16) state.weight[2]--; break;
+ case 6: if (state.weight[2] < 16) state.weight[2]++; break;
+ }
+ }
+ }
+ }
+
+ filter->filteredblockaddress = length;
+ filter->filteredblocklength = length;
+
+ return 1;
+}
+
+
+static int
+execute_filter(struct archive_read *a, struct rar_filter *filter, struct rar_virtual_machine *vm, size_t pos)
+{
+ if (filter->prog->fingerprint == 0x1D0E06077D)
+ return execute_filter_delta(filter, vm);
+ if (filter->prog->fingerprint == 0x35AD576887)
+ return execute_filter_e8(filter, vm, pos, 0);
+ if (filter->prog->fingerprint == 0x393CD7E57E)
+ return execute_filter_e8(filter, vm, pos, 1);
+ if (filter->prog->fingerprint == 0x951C2C5DC8)
+ return execute_filter_rgb(filter, vm);
+ if (filter->prog->fingerprint == 0xD8BC85E701)
+ return execute_filter_audio(filter, vm);
+
+ archive_set_error(&a->archive, ARCHIVE_ERRNO_FILE_FORMAT, "No support for RAR VM program filter");
+ return 0;
+}
+
+static int
+rar_decode_byte(struct archive_read *a, uint8_t *byte)
+{
+ struct rar *rar = (struct rar *)(a->format->data);
+ struct rar_br *br = &(rar->br);
+ if (!rar_br_read_ahead(a, br, 8))
+ return 0;
+ *byte = (uint8_t)rar_br_bits(br, 8);
+ rar_br_consume(br, 8);
+ return 1;
+}
+
+static inline void
+vm_write_32(struct rar_virtual_machine* vm, size_t offset, uint32_t u32)
+{
+ archive_le32enc(vm->memory + offset, u32);
+}
+
+static inline uint32_t
+vm_read_32(struct rar_virtual_machine* vm, size_t offset)
+{
+ return archive_le32dec(vm->memory + offset);
+}
diff --git a/Utilities/cmlibarchive/libarchive/archive_read_support_format_rar5.c b/Utilities/cmlibarchive/libarchive/archive_read_support_format_rar5.c
index 3131955..8850c93 100644
--- a/Utilities/cmlibarchive/libarchive/archive_read_support_format_rar5.c
+++ b/Utilities/cmlibarchive/libarchive/archive_read_support_format_rar5.c
@@ -632,7 +632,7 @@
/* 0xEB = ARM's BL (branch + link) instruction. */
offset = read_filter_data(rar,
(rar->cstate.solid_offset + flt->block_start + i) &
- rar->cstate.window_mask) & 0x00ffffff;
+ (uint32_t)rar->cstate.window_mask) & 0x00ffffff;
offset -= (uint32_t) ((i + flt->block_start) / 4);
offset = (offset & 0x00ffffff) | 0xeb000000;
@@ -1012,7 +1012,16 @@
return ret;
}
-static int read_bits_32(struct rar5* rar, const uint8_t* p, uint32_t* value) {
+static int read_bits_32(struct archive_read* a, struct rar5* rar,
+ const uint8_t* p, uint32_t* value)
+{
+ if(rar->bits.in_addr >= rar->cstate.cur_block_size) {
+ archive_set_error(&a->archive,
+ ARCHIVE_ERRNO_PROGRAMMER,
+ "Premature end of stream during extraction of data (#1)");
+ return ARCHIVE_FATAL;
+ }
+
uint32_t bits = ((uint32_t) p[rar->bits.in_addr]) << 24;
bits |= p[rar->bits.in_addr + 1] << 16;
bits |= p[rar->bits.in_addr + 2] << 8;
@@ -1023,7 +1032,16 @@
return ARCHIVE_OK;
}
-static int read_bits_16(struct rar5* rar, const uint8_t* p, uint16_t* value) {
+static int read_bits_16(struct archive_read* a, struct rar5* rar,
+ const uint8_t* p, uint16_t* value)
+{
+ if(rar->bits.in_addr >= rar->cstate.cur_block_size) {
+ archive_set_error(&a->archive,
+ ARCHIVE_ERRNO_PROGRAMMER,
+ "Premature end of stream during extraction of data (#2)");
+ return ARCHIVE_FATAL;
+ }
+
int bits = (int) ((uint32_t) p[rar->bits.in_addr]) << 16;
bits |= (int) p[rar->bits.in_addr + 1] << 8;
bits |= (int) p[rar->bits.in_addr + 2];
@@ -1039,8 +1057,8 @@
}
/* n = up to 16 */
-static int read_consume_bits(struct rar5* rar, const uint8_t* p, int n,
- int* value)
+static int read_consume_bits(struct archive_read* a, struct rar5* rar,
+ const uint8_t* p, int n, int* value)
{
uint16_t v;
int ret, num;
@@ -1051,7 +1069,7 @@
return ARCHIVE_FATAL;
}
- ret = read_bits_16(rar, p, &v);
+ ret = read_bits_16(a, rar, p, &v);
if(ret != ARCHIVE_OK)
return ret;
@@ -1099,6 +1117,44 @@
return -1;
}
+static int bid_sfx(struct archive_read *a)
+{
+ const char *p;
+
+ if ((p = __archive_read_ahead(a, 7, NULL)) == NULL)
+ return -1;
+
+ if ((p[0] == 'M' && p[1] == 'Z') || memcmp(p, "\x7F\x45LF", 4) == 0) {
+ /* This is a PE file */
+ char signature[sizeof(rar5_signature_xor)];
+ ssize_t offset = 0x10000;
+ ssize_t window = 4096;
+ ssize_t bytes_avail;
+
+ rar5_signature(signature);
+
+ while (offset + window <= (1024 * 512)) {
+ const char *buff = __archive_read_ahead(a, offset + window, &bytes_avail);
+ if (buff == NULL) {
+ /* Remaining bytes are less than window. */
+ window >>= 1;
+ if (window < 0x40)
+ return 0;
+ continue;
+ }
+ p = buff + offset;
+ while (p + 8 < buff + bytes_avail) {
+ if (memcmp(p, signature, sizeof(signature)) == 0)
+ return 30;
+ p += 0x10;
+ }
+ offset = p - buff;
+ }
+ }
+
+ return 0;
+}
+
static int rar5_bid(struct archive_read* a, int best_bid) {
int my_bid;
@@ -1109,6 +1165,10 @@
if(my_bid > -1) {
return my_bid;
}
+ my_bid = bid_sfx(a);
+ if (my_bid > -1) {
+ return my_bid;
+ }
return -1;
}
@@ -1712,14 +1772,29 @@
}
}
- /* If we're currently switching volumes, ignore the new definition of
- * window_size. */
- if(rar->cstate.switch_multivolume == 0) {
- /* Values up to 64M should fit into ssize_t on every
- * architecture. */
- rar->cstate.window_size = (ssize_t) window_size;
+ if(rar->cstate.window_size < (ssize_t) window_size &&
+ rar->cstate.window_buf)
+ {
+ /* If window_buf has been allocated before, reallocate it, so
+ * that its size will match new window_size. */
+
+ uint8_t* new_window_buf =
+ realloc(rar->cstate.window_buf, window_size);
+
+ if(!new_window_buf) {
+ archive_set_error(&a->archive, ARCHIVE_ERRNO_PROGRAMMER,
+ "Not enough memory when trying to realloc the window "
+ "buffer.");
+ return ARCHIVE_FATAL;
+ }
+
+ rar->cstate.window_buf = new_window_buf;
}
+ /* Values up to 64M should fit into ssize_t on every
+ * architecture. */
+ rar->cstate.window_size = (ssize_t) window_size;
+
if(rar->file.solid > 0 && rar->file.solid_window_size == 0) {
/* Solid files have to have the same window_size across
whole archive. Remember the window_size parameter
@@ -2273,6 +2348,62 @@
return ret;
}
+static int try_skip_sfx(struct archive_read *a)
+{
+ const char *p;
+
+ if ((p = __archive_read_ahead(a, 7, NULL)) == NULL)
+ return ARCHIVE_EOF;
+
+ if ((p[0] == 'M' && p[1] == 'Z') || memcmp(p, "\x7F\x45LF", 4) == 0)
+ {
+ char signature[sizeof(rar5_signature_xor)];
+ const void *h;
+ const char *q;
+ size_t skip, total = 0;
+ ssize_t bytes, window = 4096;
+
+ rar5_signature(signature);
+
+ while (total + window <= (1024 * 512)) {
+ h = __archive_read_ahead(a, window, &bytes);
+ if (h == NULL) {
+ /* Remaining bytes are less than window. */
+ window >>= 1;
+ if (window < 0x40)
+ goto fatal;
+ continue;
+ }
+ if (bytes < 0x40)
+ goto fatal;
+ p = h;
+ q = p + bytes;
+
+ /*
+ * Scan ahead until we find something that looks
+ * like the RAR header.
+ */
+ while (p + 8 < q) {
+ if (memcmp(p, signature, sizeof(signature)) == 0) {
+ skip = p - (const char *)h;
+ __archive_read_consume(a, skip);
+ return (ARCHIVE_OK);
+ }
+ p += 0x10;
+ }
+ skip = p - (const char *)h;
+ __archive_read_consume(a, skip);
+ total += skip;
+ }
+ }
+
+ return ARCHIVE_OK;
+fatal:
+ archive_set_error(&a->archive, ARCHIVE_ERRNO_FILE_FORMAT,
+ "Couldn't find out RAR header");
+ return (ARCHIVE_FATAL);
+}
+
static int rar5_read_header(struct archive_read *a,
struct archive_entry *entry)
{
@@ -2281,6 +2412,8 @@
if(rar->header_initialized == 0) {
init_header(a);
+ if ((ret = try_skip_sfx(a)) < ARCHIVE_WARN)
+ return ret;
rar->header_initialized = 1;
}
@@ -2425,13 +2558,13 @@
static int decode_number(struct archive_read* a, struct decode_table* table,
const uint8_t* p, uint16_t* num)
{
- int i, bits, dist;
+ int i, bits, dist, ret;
uint16_t bitfield;
uint32_t pos;
struct rar5* rar = get_context(a);
- if(ARCHIVE_OK != read_bits_16(rar, p, &bitfield)) {
- return ARCHIVE_EOF;
+ if(ARCHIVE_OK != (ret = read_bits_16(a, rar, p, &bitfield))) {
+ return ret;
}
bitfield &= 0xfffe;
@@ -2537,14 +2670,6 @@
for(i = 0; i < HUFF_TABLE_SIZE;) {
uint16_t num;
- if((rar->bits.in_addr + 6) >= rar->cstate.cur_block_size) {
- /* Truncated data, can't continue. */
- archive_set_error(&a->archive,
- ARCHIVE_ERRNO_FILE_FORMAT,
- "Truncated data in huffman tables (#2)");
- return ARCHIVE_FATAL;
- }
-
ret = decode_number(a, &rar->cstate.bd, p, &num);
if(ret != ARCHIVE_OK) {
archive_set_error(&a->archive,
@@ -2561,8 +2686,8 @@
/* 16..17: repeat previous code */
uint16_t n;
- if(ARCHIVE_OK != read_bits_16(rar, p, &n))
- return ARCHIVE_EOF;
+ if(ARCHIVE_OK != (ret = read_bits_16(a, rar, p, &n)))
+ return ret;
if(num == 16) {
n >>= 13;
@@ -2590,8 +2715,8 @@
/* other codes: fill with zeroes `n` times */
uint16_t n;
- if(ARCHIVE_OK != read_bits_16(rar, p, &n))
- return ARCHIVE_EOF;
+ if(ARCHIVE_OK != (ret = read_bits_16(a, rar, p, &n)))
+ return ret;
if(num == 18) {
n >>= 13;
@@ -2707,22 +2832,22 @@
}
/* Convenience function used during filter processing. */
-static int parse_filter_data(struct rar5* rar, const uint8_t* p,
- uint32_t* filter_data)
+static int parse_filter_data(struct archive_read* a, struct rar5* rar,
+ const uint8_t* p, uint32_t* filter_data)
{
- int i, bytes;
+ int i, bytes, ret;
uint32_t data = 0;
- if(ARCHIVE_OK != read_consume_bits(rar, p, 2, &bytes))
- return ARCHIVE_EOF;
+ if(ARCHIVE_OK != (ret = read_consume_bits(a, rar, p, 2, &bytes)))
+ return ret;
bytes++;
for(i = 0; i < bytes; i++) {
uint16_t byte;
- if(ARCHIVE_OK != read_bits_16(rar, p, &byte)) {
- return ARCHIVE_EOF;
+ if(ARCHIVE_OK != (ret = read_bits_16(a, rar, p, &byte))) {
+ return ret;
}
/* Cast to uint32_t will ensure the shift operation will not
@@ -2765,16 +2890,17 @@
uint16_t filter_type;
struct filter_info* filt = NULL;
struct rar5* rar = get_context(ar);
+ int ret;
/* Read the parameters from the input stream. */
- if(ARCHIVE_OK != parse_filter_data(rar, p, &block_start))
- return ARCHIVE_EOF;
+ if(ARCHIVE_OK != (ret = parse_filter_data(ar, rar, p, &block_start)))
+ return ret;
- if(ARCHIVE_OK != parse_filter_data(rar, p, &block_length))
- return ARCHIVE_EOF;
+ if(ARCHIVE_OK != (ret = parse_filter_data(ar, rar, p, &block_length)))
+ return ret;
- if(ARCHIVE_OK != read_bits_16(rar, p, &filter_type))
- return ARCHIVE_EOF;
+ if(ARCHIVE_OK != (ret = read_bits_16(ar, rar, p, &filter_type)))
+ return ret;
filter_type >>= 13;
skip_bits(rar, 3);
@@ -2814,8 +2940,8 @@
if(filter_type == FILTER_DELTA) {
int channels;
- if(ARCHIVE_OK != read_consume_bits(rar, p, 5, &channels))
- return ARCHIVE_EOF;
+ if(ARCHIVE_OK != (ret = read_consume_bits(ar, rar, p, 5, &channels)))
+ return ret;
filt->channels = channels + 1;
}
@@ -2823,10 +2949,11 @@
return ARCHIVE_OK;
}
-static int decode_code_length(struct rar5* rar, const uint8_t* p,
- uint16_t code)
+static int decode_code_length(struct archive_read* a, struct rar5* rar,
+ const uint8_t* p, uint16_t code)
{
int lbits, length = 2;
+
if(code < 8) {
lbits = 0;
length += code;
@@ -2838,7 +2965,7 @@
if(lbits > 0) {
int add;
- if(ARCHIVE_OK != read_consume_bits(rar, p, lbits, &add))
+ if(ARCHIVE_OK != read_consume_bits(a, rar, p, lbits, &add))
return -1;
length += add;
@@ -2933,7 +3060,7 @@
continue;
} else if(num >= 262) {
uint16_t dist_slot;
- int len = decode_code_length(rar, p, num - 262),
+ int len = decode_code_length(a, rar, p, num - 262),
dbits,
dist = 1;
@@ -2975,12 +3102,12 @@
uint16_t low_dist;
if(dbits > 4) {
- if(ARCHIVE_OK != read_bits_32(
- rar, p, &add)) {
+ if(ARCHIVE_OK != (ret = read_bits_32(
+ a, rar, p, &add))) {
/* Return EOF if we
* can't read more
* data. */
- return ARCHIVE_EOF;
+ return ret;
}
skip_bits(rar, dbits - 4);
@@ -3015,11 +3142,11 @@
/* dbits is one of [0,1,2,3] */
int add;
- if(ARCHIVE_OK != read_consume_bits(rar,
- p, dbits, &add)) {
+ if(ARCHIVE_OK != (ret = read_consume_bits(a, rar,
+ p, dbits, &add))) {
/* Return EOF if we can't read
* more data. */
- return ARCHIVE_EOF;
+ return ret;
}
dist += add;
@@ -3076,7 +3203,11 @@
return ARCHIVE_FATAL;
}
- len = decode_code_length(rar, p, len_slot);
+ len = decode_code_length(a, rar, p, len_slot);
+ if (len == -1) {
+ return ARCHIVE_FATAL;
+ }
+
rar->cstate.last_len = len;
if(ARCHIVE_OK != copy_string(a, len, dist))
@@ -3600,6 +3731,16 @@
rar->cstate.initialized = 1;
}
+ /* Don't allow extraction if window_size is invalid. */
+ if(rar->cstate.window_size == 0) {
+ archive_set_error(&a->archive,
+ ARCHIVE_ERRNO_FILE_FORMAT,
+ "Invalid window size declaration in this file");
+
+ /* This should never happen in valid files. */
+ return ARCHIVE_FATAL;
+ }
+
if(rar->cstate.all_filters_applied == 1) {
/* We use while(1) here, but standard case allows for just 1
* iteration. The loop will iterate if process_block() didn't
@@ -4076,6 +4217,7 @@
if(ARCHIVE_OK != rar5_init(rar)) {
archive_set_error(&ar->archive, ENOMEM,
"Can't allocate rar5 filter buffer");
+ free(rar);
return ARCHIVE_FATAL;
}
diff --git a/Utilities/cmlibarchive/libarchive/archive_read_support_format_tar.c b/Utilities/cmlibarchive/libarchive/archive_read_support_format_tar.c
index 96d8101..bfdad7f 100644
--- a/Utilities/cmlibarchive/libarchive/archive_read_support_format_tar.c
+++ b/Utilities/cmlibarchive/libarchive/archive_read_support_format_tar.c
@@ -573,11 +573,15 @@
l = wcslen(wp);
if (l > 0 && wp[l - 1] == L'/') {
archive_entry_set_filetype(entry, AE_IFDIR);
+ tar->entry_bytes_remaining = 0;
+ tar->entry_padding = 0;
}
} else if ((p = archive_entry_pathname(entry)) != NULL) {
l = strlen(p);
if (l > 0 && p[l - 1] == '/') {
archive_entry_set_filetype(entry, AE_IFDIR);
+ tar->entry_bytes_remaining = 0;
+ tar->entry_padding = 0;
}
}
}
@@ -1396,6 +1400,7 @@
struct archive_entry *entry, const void *h, size_t *unconsumed)
{
int64_t size;
+ size_t msize;
const void *data;
const char *p, *name;
const wchar_t *wp, *wname;
@@ -1434,6 +1439,11 @@
/* Read the body as a Mac OS metadata blob. */
size = archive_entry_size(entry);
+ msize = (size_t)size;
+ if (size < 0 || (uintmax_t)msize != (uintmax_t)size) {
+ *unconsumed = 0;
+ return (ARCHIVE_FATAL);
+ }
/*
* TODO: Look beyond the body here to peek at the next header.
@@ -1447,13 +1457,13 @@
* Q: Is the above idea really possible? Even
* when there are GNU or pax extension entries?
*/
- data = __archive_read_ahead(a, (size_t)size, NULL);
+ data = __archive_read_ahead(a, msize, NULL);
if (data == NULL) {
*unconsumed = 0;
return (ARCHIVE_FATAL);
}
- archive_entry_copy_mac_metadata(entry, data, (size_t)size);
- *unconsumed = (size_t)((size + 511) & ~ 511);
+ archive_entry_copy_mac_metadata(entry, data, msize);
+ *unconsumed = (msize + 511) & ~ 511;
tar_flush_unconsumed(a, unconsumed);
return (tar_read_header(a, tar, entry, unconsumed));
}
@@ -1906,7 +1916,7 @@
}
if (strcmp(key, "GNU.sparse.numbytes") == 0) {
tar->sparse_numbytes = tar_atol10(value, strlen(value));
- if (tar->sparse_numbytes != -1) {
+ if (tar->sparse_offset != -1) {
if (gnu_add_sparse_entry(a, tar,
tar->sparse_offset, tar->sparse_numbytes)
!= ARCHIVE_OK)
@@ -2643,14 +2653,14 @@
maxval = INT64_MIN;
limit = -(INT64_MIN / base);
- last_digit_limit = INT64_MIN % base;
+ last_digit_limit = -(INT64_MIN % base);
}
l = 0;
if (char_cnt != 0) {
digit = *p - '0';
while (digit >= 0 && digit < base && char_cnt != 0) {
- if (l>limit || (l == limit && digit > last_digit_limit)) {
+ if (l>limit || (l == limit && digit >= last_digit_limit)) {
return maxval; /* Truncate on overflow. */
}
l = (l * base) + digit;
diff --git a/Utilities/cmlibarchive/libarchive/archive_read_support_format_zip.c b/Utilities/cmlibarchive/libarchive/archive_read_support_format_zip.c
index 6314c68..8ad73b6 100644
--- a/Utilities/cmlibarchive/libarchive/archive_read_support_format_zip.c
+++ b/Utilities/cmlibarchive/libarchive/archive_read_support_format_zip.c
@@ -58,6 +58,9 @@
#ifdef HAVE_LZMA_H
#include <cm3p/lzma.h>
#endif
+#ifdef HAVE_ZSTD_H
+#include <cm3p/zstd.h>
+#endif
#include "archive.h"
#include "archive_digest_private.h"
@@ -142,6 +145,7 @@
/* Structural information about the archive. */
struct archive_string format_name;
int64_t central_directory_offset;
+ int64_t central_directory_offset_adjusted;
size_t central_directory_entries_total;
size_t central_directory_entries_on_this_disk;
int has_encrypted_entries;
@@ -190,6 +194,11 @@
char bzstream_valid;
#endif
+#if HAVE_ZSTD_H && HAVE_LIBZSTD
+ ZSTD_DStream *zstdstream;
+ char zstdstream_valid;
+#endif
+
IByteIn zipx_ppmd_stream;
ssize_t zipx_ppmd_read_compressed;
CPpmd8 ppmd8;
@@ -246,6 +255,17 @@
/* Many systems define min or MIN, but not all. */
#define zipmin(a,b) ((a) < (b) ? (a) : (b))
+#ifdef HAVE_ZLIB_H
+static int
+zip_read_data_deflate(struct archive_read *a, const void **buff,
+ size_t *size, int64_t *offset);
+#endif
+#if HAVE_LZMA_H && HAVE_LIBLZMA
+static int
+zip_read_data_zipx_lzma_alone(struct archive_read *a, const void **buff,
+ size_t *size, int64_t *offset);
+#endif
+
/* This function is used by Ppmd8_DecodeSymbol during decompression of Ppmd8
* streams inside ZIP files. It has 2 purposes: one is to fetch the next
* compressed byte from the stream, second one is to increase the counter how
@@ -423,6 +443,7 @@
{17, "reserved"}, /* Reserved by PKWARE */
{18, "ibm-terse-new"}, /* File is compressed using IBM TERSE (new) */
{19, "ibm-lz777"},/* IBM LZ77 z Architecture (PFS) */
+ {93, "zstd"}, /* Zstandard (zstd) Compression */
{95, "xz"}, /* XZ compressed data */
{96, "jpeg"}, /* JPEG compressed data */
{97, "wav-pack"}, /* WavPack compressed data */
@@ -899,81 +920,6 @@
return ARCHIVE_OK;
}
-#if HAVE_LZMA_H && HAVE_LIBLZMA
-/*
- * Auxiliary function to uncompress data chunk from zipx archive
- * (zip with lzma compression).
- */
-static int
-zipx_lzma_uncompress_buffer(const char *compressed_buffer,
- size_t compressed_buffer_size,
- char *uncompressed_buffer,
- size_t uncompressed_buffer_size)
-{
- int status = ARCHIVE_FATAL;
- // length of 'lzma properties data' in lzma compressed
- // data segment (stream) inside zip archive
- const size_t lzma_params_length = 5;
- // offset of 'lzma properties data' from the beginning of lzma stream
- const size_t lzma_params_offset = 4;
- // end position of 'lzma properties data' in lzma stream
- const size_t lzma_params_end = lzma_params_offset + lzma_params_length;
- if (compressed_buffer == NULL ||
- compressed_buffer_size < lzma_params_end ||
- uncompressed_buffer == NULL)
- return status;
-
- // prepare header for lzma_alone_decoder to replace zipx header
- // (see comments in 'zipx_lzma_alone_init' for justification)
-#pragma pack(push)
-#pragma pack(1)
- struct _alone_header
- {
- uint8_t bytes[5]; // lzma_params_length
- uint64_t uncompressed_size;
- } alone_header;
-#pragma pack(pop)
- // copy 'lzma properties data' blob
- memcpy(&alone_header.bytes[0], compressed_buffer + lzma_params_offset,
- lzma_params_length);
- alone_header.uncompressed_size = UINT64_MAX;
-
- // prepare new compressed buffer, see 'zipx_lzma_alone_init' for details
- const size_t lzma_alone_buffer_size =
- compressed_buffer_size - lzma_params_end + sizeof(alone_header);
- unsigned char *lzma_alone_compressed_buffer =
- (unsigned char*) malloc(lzma_alone_buffer_size);
- if (lzma_alone_compressed_buffer == NULL)
- return status;
- // copy lzma_alone header into new buffer
- memcpy(lzma_alone_compressed_buffer, (void*) &alone_header,
- sizeof(alone_header));
- // copy compressed data into new buffer
- memcpy(lzma_alone_compressed_buffer + sizeof(alone_header),
- compressed_buffer + lzma_params_end,
- compressed_buffer_size - lzma_params_end);
-
- // create and fill in lzma_alone_decoder stream
- lzma_stream stream = LZMA_STREAM_INIT;
- lzma_ret ret = lzma_alone_decoder(&stream, UINT64_MAX);
- if (ret == LZMA_OK)
- {
- stream.next_in = lzma_alone_compressed_buffer;
- stream.avail_in = lzma_alone_buffer_size;
- stream.total_in = 0;
- stream.next_out = (unsigned char*)uncompressed_buffer;
- stream.avail_out = uncompressed_buffer_size;
- stream.total_out = 0;
- ret = lzma_code(&stream, LZMA_RUN);
- if (ret == LZMA_OK || ret == LZMA_STREAM_END)
- status = ARCHIVE_OK;
- }
- lzma_end(&stream);
- free(lzma_alone_compressed_buffer);
- return status;
-}
-#endif
-
/*
* Assumes file pointer is at beginning of local file header.
*/
@@ -1207,7 +1153,8 @@
(intmax_t)zip_entry->compressed_size);
ret = ARCHIVE_WARN;
}
- if (zip_entry->uncompressed_size == 0) {
+ if (zip_entry->uncompressed_size == 0 ||
+ zip_entry->uncompressed_size == 0xffffffff) {
zip_entry->uncompressed_size
= zip_entry_central_dir.uncompressed_size;
} else if (zip_entry->uncompressed_size
@@ -1242,36 +1189,30 @@
linkname_length = (size_t)zip_entry->compressed_size;
archive_entry_set_size(entry, 0);
- p = __archive_read_ahead(a, linkname_length, NULL);
- if (p == NULL) {
- archive_set_error(&a->archive, ARCHIVE_ERRNO_MISC,
- "Truncated Zip file");
- return ARCHIVE_FATAL;
- }
+
// take into account link compression if any
size_t linkname_full_length = linkname_length;
if (zip->entry->compression != 0)
{
// symlink target string appeared to be compressed
int status = ARCHIVE_FATAL;
- char *uncompressed_buffer =
- (char*) malloc(zip_entry->uncompressed_size);
- if (uncompressed_buffer == NULL)
- {
- archive_set_error(&a->archive, ENOMEM,
- "No memory for lzma decompression");
- return status;
- }
+ const void *uncompressed_buffer = NULL;
switch (zip->entry->compression)
{
+#if HAVE_ZLIB_H
+ case 8: /* Deflate compression. */
+ zip->entry_bytes_remaining = zip_entry->compressed_size;
+ status = zip_read_data_deflate(a, &uncompressed_buffer,
+ &linkname_full_length, NULL);
+ break;
+#endif
#if HAVE_LZMA_H && HAVE_LIBLZMA
case 14: /* ZIPx LZMA compression. */
/*(see zip file format specification, section 4.4.5)*/
- status = zipx_lzma_uncompress_buffer(p,
- linkname_length,
- uncompressed_buffer,
- (size_t)zip_entry->uncompressed_size);
+ zip->entry_bytes_remaining = zip_entry->compressed_size;
+ status = zip_read_data_zipx_lzma_alone(a, &uncompressed_buffer,
+ &linkname_full_length, NULL);
break;
#endif
default: /* Unsupported compression. */
@@ -1280,8 +1221,6 @@
if (status == ARCHIVE_OK)
{
p = uncompressed_buffer;
- linkname_full_length =
- (size_t)zip_entry->uncompressed_size;
}
else
{
@@ -1294,6 +1233,16 @@
return ARCHIVE_FAILED;
}
}
+ else
+ {
+ p = __archive_read_ahead(a, linkname_length, NULL);
+ }
+
+ if (p == NULL) {
+ archive_set_error(&a->archive, ARCHIVE_ERRNO_MISC,
+ "Truncated Zip file");
+ return ARCHIVE_FATAL;
+ }
sconv = zip->sconv;
if (sconv == NULL && (zip->entry->zip_flags & ZIP_UTF8_NAME))
@@ -1663,7 +1612,8 @@
/* To unpack ZIPX's "LZMA" (id 14) stream we can use standard liblzma
* that is a part of XZ Utils. The stream format stored inside ZIPX
* file is a modified "lzma alone" file format, that was used by the
- * `lzma` utility which was later deprecated in favour of `xz` utility. * Since those formats are nearly the same, we can use a standard
+ * `lzma` utility which was later deprecated in favour of `xz` utility.
+ * Since those formats are nearly the same, we can use a standard
* "lzma alone" decoder from XZ Utils. */
memset(&zip->zipx_lzma_stream, 0, sizeof(zip->zipx_lzma_stream));
@@ -2298,6 +2248,140 @@
#endif
+#if HAVE_ZSTD_H && HAVE_LIBZSTD
+static int
+zipx_zstd_init(struct archive_read *a, struct zip *zip)
+{
+ size_t r;
+
+ /* Deallocate already existing Zstd decompression context if it
+ * exists. */
+ if(zip->zstdstream_valid) {
+ ZSTD_freeDStream(zip->zstdstream);
+ zip->zstdstream_valid = 0;
+ }
+
+ /* Allocate a new Zstd decompression context. */
+ zip->zstdstream = ZSTD_createDStream();
+
+ r = ZSTD_initDStream(zip->zstdstream);
+ if (ZSTD_isError(r)) {
+ archive_set_error(&a->archive, ARCHIVE_ERRNO_MISC,
+ "Error initializing zstd decompressor: %s",
+ ZSTD_getErrorName(r));
+
+ return ARCHIVE_FAILED;
+ }
+
+ /* Mark the zstdstream field to be released in cleanup phase. */
+ zip->zstdstream_valid = 1;
+
+ /* (Re)allocate the buffer that will contain decompressed bytes. */
+ free(zip->uncompressed_buffer);
+
+ zip->uncompressed_buffer_size = ZSTD_DStreamOutSize();
+ zip->uncompressed_buffer =
+ (uint8_t*) malloc(zip->uncompressed_buffer_size);
+ if (zip->uncompressed_buffer == NULL) {
+ archive_set_error(&a->archive, ENOMEM,
+ "No memory for Zstd decompression");
+
+ return ARCHIVE_FATAL;
+ }
+
+ /* Initialization done. */
+ zip->decompress_init = 1;
+ return ARCHIVE_OK;
+}
+
+static int
+zip_read_data_zipx_zstd(struct archive_read *a, const void **buff,
+ size_t *size, int64_t *offset)
+{
+ struct zip *zip = (struct zip *)(a->format->data);
+ ssize_t bytes_avail = 0, in_bytes, to_consume;
+ const void *compressed_buff;
+ int r;
+ size_t ret;
+ uint64_t total_out;
+ ZSTD_outBuffer out;
+ ZSTD_inBuffer in;
+
+ (void) offset; /* UNUSED */
+
+ /* Initialize decompression context if we're here for the first time. */
+ if(!zip->decompress_init) {
+ r = zipx_zstd_init(a, zip);
+ if(r != ARCHIVE_OK)
+ return r;
+ }
+
+ /* Fetch more compressed bytes */
+ compressed_buff = __archive_read_ahead(a, 1, &bytes_avail);
+ if(bytes_avail < 0) {
+ archive_set_error(&a->archive, ARCHIVE_ERRNO_FILE_FORMAT,
+ "Truncated zstd file body");
+ return (ARCHIVE_FATAL);
+ }
+
+ in_bytes = zipmin(zip->entry_bytes_remaining, bytes_avail);
+ if(in_bytes < 1) {
+ /* zstd doesn't complain when caller feeds avail_in == 0.
+ * It will actually return success in this case, which is
+ * undesirable. This is why we need to make this check
+ * manually. */
+ archive_set_error(&a->archive, ARCHIVE_ERRNO_FILE_FORMAT,
+ "Truncated zstd file body");
+ return (ARCHIVE_FATAL);
+ }
+
+ /* Setup buffer boundaries */
+ in.src = compressed_buff;
+ in.size = in_bytes;
+ in.pos = 0;
+ out = (ZSTD_outBuffer) { zip->uncompressed_buffer, zip->uncompressed_buffer_size, 0 };
+
+ /* Perform the decompression. */
+ ret = ZSTD_decompressStream(zip->zstdstream, &out, &in);
+ if (ZSTD_isError(ret)) {
+ archive_set_error(&a->archive, ARCHIVE_ERRNO_MISC,
+ "Error during zstd decompression: %s",
+ ZSTD_getErrorName(ret));
+ return (ARCHIVE_FATAL);
+ }
+
+ /* Check end of the stream. */
+ if (ret == 0) {
+ if ((in.pos == in.size) && (out.pos < out.size)) {
+ zip->end_of_entry = 1;
+ ZSTD_freeDStream(zip->zstdstream);
+ zip->zstdstream_valid = 0;
+ }
+ }
+
+ /* Update the pointers so decompressor can continue decoding. */
+ to_consume = in.pos;
+ __archive_read_consume(a, to_consume);
+
+ total_out = out.pos;
+
+ zip->entry_bytes_remaining -= to_consume;
+ zip->entry_compressed_bytes_read += to_consume;
+ zip->entry_uncompressed_bytes_read += total_out;
+
+ /* Give libarchive its due. */
+ *size = total_out;
+ *buff = zip->uncompressed_buffer;
+
+ /* Seek for optional marker, like in other entries. */
+ r = consume_optional_marker(a, zip);
+ if(r != ARCHIVE_OK)
+ return r;
+
+ return ARCHIVE_OK;
+}
+#endif
+
#ifdef HAVE_ZLIB_H
static int
zip_deflate_init(struct archive_read *a, struct zip *zip)
@@ -2918,6 +3002,11 @@
r = zip_read_data_zipx_xz(a, buff, size, offset);
break;
#endif
+#if HAVE_ZSTD_H && HAVE_LIBZSTD
+ case 93: /* ZIPx Zstd compression. */
+ r = zip_read_data_zipx_zstd(a, buff, size, offset);
+ break;
+#endif
/* PPMd support is built-in, so we don't need any #if guards. */
case 98: /* ZIPx PPMd compression. */
r = zip_read_data_zipx_ppmd(a, buff, size, offset);
@@ -3008,6 +3097,12 @@
}
#endif
+#if HAVE_ZSTD_H && HAVE_LIBZSTD
+ if (zip->zstdstream_valid) {
+ ZSTD_freeDStream(zip->zstdstream);
+ }
+#endif
+
free(zip->uncompressed_buffer);
if (zip->ppmd8_valid)
@@ -3415,24 +3510,31 @@
static int
read_eocd(struct zip *zip, const char *p, int64_t current_offset)
{
+ uint16_t disk_num;
+ uint32_t cd_size, cd_offset;
+
+ disk_num = archive_le16dec(p + 4);
+ cd_size = archive_le32dec(p + 12);
+ cd_offset = archive_le32dec(p + 16);
+
/* Sanity-check the EOCD we've found. */
/* This must be the first volume. */
- if (archive_le16dec(p + 4) != 0)
+ if (disk_num != 0)
return 0;
/* Central directory must be on this volume. */
- if (archive_le16dec(p + 4) != archive_le16dec(p + 6))
+ if (disk_num != archive_le16dec(p + 6))
return 0;
/* All central directory entries must be on this volume. */
if (archive_le16dec(p + 10) != archive_le16dec(p + 8))
return 0;
/* Central directory can't extend beyond start of EOCD record. */
- if (archive_le32dec(p + 16) + archive_le32dec(p + 12)
- > current_offset)
+ if (cd_offset + cd_size > current_offset)
return 0;
/* Save the central directory location for later use. */
- zip->central_directory_offset = archive_le32dec(p + 16);
+ zip->central_directory_offset = cd_offset;
+ zip->central_directory_offset_adjusted = current_offset - cd_size;
/* This is just a tiny bit higher than the maximum
returned by the streaming Zip bidder. This ensures
@@ -3484,6 +3586,8 @@
/* Save the central directory offset for later use. */
zip->central_directory_offset = archive_le64dec(p + 48);
+ /* TODO: Needs scanning backwards to find the eocd64 instead of assuming */
+ zip->central_directory_offset_adjusted = zip->central_directory_offset;
return 32;
}
@@ -3655,7 +3759,8 @@
* know the correction we need to apply to account for leading
* padding.
*/
- if (__archive_read_seek(a, zip->central_directory_offset, SEEK_SET) < 0)
+ if (__archive_read_seek(a, zip->central_directory_offset_adjusted, SEEK_SET)
+ < 0)
return ARCHIVE_FATAL;
found = 0;
diff --git a/Utilities/cmlibarchive/libarchive/archive_string.c b/Utilities/cmlibarchive/libarchive/archive_string.c
index 7460ded..d7f2c46 100644
--- a/Utilities/cmlibarchive/libarchive/archive_string.c
+++ b/Utilities/cmlibarchive/libarchive/archive_string.c
@@ -745,7 +745,7 @@
dp = &defchar_used;
count = WideCharToMultiByte(to_cp, 0, ws, wslen,
as->s + as->length,
- (int)as->buffer_length - as->length - 1, NULL, dp);
+ (int)as->buffer_length - (int)as->length - 1, NULL, dp);
if (count == 0 &&
GetLastError() == ERROR_INSUFFICIENT_BUFFER) {
/* Expand the MBS buffer and retry. */
diff --git a/Utilities/cmlibarchive/libarchive/archive_write.c b/Utilities/cmlibarchive/libarchive/archive_write.c
index 8d70f51..66592e8 100644
--- a/Utilities/cmlibarchive/libarchive/archive_write.c
+++ b/Utilities/cmlibarchive/libarchive/archive_write.c
@@ -60,8 +60,6 @@
#include "archive_private.h"
#include "archive_write_private.h"
-static struct archive_vtable *archive_write_vtable(void);
-
static int _archive_filter_code(struct archive *, int);
static const char *_archive_filter_name(struct archive *, int);
static int64_t _archive_filter_bytes(struct archive *, int);
@@ -79,26 +77,18 @@
char *next;
};
-static struct archive_vtable *
-archive_write_vtable(void)
-{
- static struct archive_vtable av;
- static int inited = 0;
-
- if (!inited) {
- av.archive_close = _archive_write_close;
- av.archive_filter_bytes = _archive_filter_bytes;
- av.archive_filter_code = _archive_filter_code;
- av.archive_filter_name = _archive_filter_name;
- av.archive_filter_count = _archive_write_filter_count;
- av.archive_free = _archive_write_free;
- av.archive_write_header = _archive_write_header;
- av.archive_write_finish_entry = _archive_write_finish_entry;
- av.archive_write_data = _archive_write_data;
- inited = 1;
- }
- return (&av);
-}
+static const struct archive_vtable
+archive_write_vtable = {
+ .archive_close = _archive_write_close,
+ .archive_filter_bytes = _archive_filter_bytes,
+ .archive_filter_code = _archive_filter_code,
+ .archive_filter_name = _archive_filter_name,
+ .archive_filter_count = _archive_write_filter_count,
+ .archive_free = _archive_write_free,
+ .archive_write_header = _archive_write_header,
+ .archive_write_finish_entry = _archive_write_finish_entry,
+ .archive_write_data = _archive_write_data,
+};
/*
* Allocate, initialize and return an archive object.
@@ -114,7 +104,7 @@
return (NULL);
a->archive.magic = ARCHIVE_WRITE_MAGIC;
a->archive.state = ARCHIVE_STATE_NEW;
- a->archive.vtable = archive_write_vtable();
+ a->archive.vtable = &archive_write_vtable;
/*
* The value 10240 here matches the traditional tar default,
* but is otherwise arbitrary.
@@ -482,6 +472,8 @@
ssize_t block_length;
ssize_t target_block_length;
ssize_t bytes_written;
+ size_t to_write;
+ char *p;
int ret = ARCHIVE_OK;
/* If there's pending data, pad and write the last block */
@@ -504,9 +496,24 @@
target_block_length - block_length);
block_length = target_block_length;
}
- bytes_written = (a->client_writer)(&a->archive,
- a->client_data, state->buffer, block_length);
- ret = bytes_written <= 0 ? ARCHIVE_FATAL : ARCHIVE_OK;
+ p = state->buffer;
+ to_write = block_length;
+ while (to_write > 0) {
+ bytes_written = (a->client_writer)(&a->archive,
+ a->client_data, p, to_write);
+ if (bytes_written <= 0) {
+ ret = ARCHIVE_FATAL;
+ break;
+ }
+ if ((size_t)bytes_written > to_write) {
+ archive_set_error(&(a->archive),
+ -1, "write overrun");
+ ret = ARCHIVE_FATAL;
+ break;
+ }
+ p += bytes_written;
+ to_write -= bytes_written;
+ }
}
if (a->client_closer)
(*a->client_closer)(&a->archive, a->client_data);
diff --git a/Utilities/cmlibarchive/libarchive/archive_write_add_filter_xz.c b/Utilities/cmlibarchive/libarchive/archive_write_add_filter_xz.c
index 00df8da..0cc03b1 100644
--- a/Utilities/cmlibarchive/libarchive/archive_write_add_filter_xz.c
+++ b/Utilities/cmlibarchive/libarchive/archive_write_add_filter_xz.c
@@ -251,13 +251,13 @@
int ds, log2dic, wedges;
/* Calculate a coded dictionary size */
- if (dict_size < (1 << 12) || dict_size > (1 << 27)) {
+ if (dict_size < (1 << 12) || dict_size > (1 << 29)) {
archive_set_error(f->archive, ARCHIVE_ERRNO_MISC,
"Unacceptable dictionary size for lzip: %d",
dict_size);
return (ARCHIVE_FATAL);
}
- for (log2dic = 27; log2dic >= 12; log2dic--) {
+ for (log2dic = 29; log2dic >= 12; log2dic--) {
if (dict_size & (1 << log2dic))
break;
}
diff --git a/Utilities/cmlibarchive/libarchive/archive_write_add_filter_zstd.c b/Utilities/cmlibarchive/libarchive/archive_write_add_filter_zstd.c
index 6d71628..7d36d58 100644
--- a/Utilities/cmlibarchive/libarchive/archive_write_add_filter_zstd.c
+++ b/Utilities/cmlibarchive/libarchive/archive_write_add_filter_zstd.c
@@ -50,7 +50,8 @@
struct private_data {
int compression_level;
-#if HAVE_ZSTD_H && HAVE_LIBZSTD
+ int threads;
+#if HAVE_ZSTD_H && HAVE_LIBZSTD_COMPRESSOR
ZSTD_CStream *cstream;
int64_t total_in;
ZSTD_outBuffer out;
@@ -76,7 +77,7 @@
const void *, size_t);
static int archive_compressor_zstd_close(struct archive_write_filter *);
static int archive_compressor_zstd_free(struct archive_write_filter *);
-#if HAVE_ZSTD_H && HAVE_LIBZSTD
+#if HAVE_ZSTD_H && HAVE_LIBZSTD_COMPRESSOR
static int drive_compressor(struct archive_write_filter *,
struct private_data *, int, const void *, size_t);
#endif
@@ -107,7 +108,8 @@
f->code = ARCHIVE_FILTER_ZSTD;
f->name = "zstd";
data->compression_level = CLEVEL_DEFAULT;
-#if HAVE_ZSTD_H && HAVE_LIBZSTD
+ data->threads = 0;
+#if HAVE_ZSTD_H && HAVE_LIBZSTD_COMPRESSOR
data->cstream = ZSTD_createCStream();
if (data->cstream == NULL) {
free(data);
@@ -134,7 +136,7 @@
archive_compressor_zstd_free(struct archive_write_filter *f)
{
struct private_data *data = (struct private_data *)f->data;
-#if HAVE_ZSTD_H && HAVE_LIBZSTD
+#if HAVE_ZSTD_H && HAVE_LIBZSTD_COMPRESSOR
ZSTD_freeCStream(data->cstream);
free(data->out.dst);
#else
@@ -187,7 +189,7 @@
if (string_is_numeric(value) != ARCHIVE_OK) {
return (ARCHIVE_WARN);
}
-#if HAVE_ZSTD_H && HAVE_LIBZSTD
+#if HAVE_ZSTD_H && HAVE_LIBZSTD_COMPRESSOR
maximum = ZSTD_maxCLevel();
#if ZSTD_VERSION_NUMBER >= MINVER_MINCLEVEL
if (ZSTD_versionNumber() >= MINVER_MINCLEVEL) {
@@ -204,6 +206,20 @@
}
data->compression_level = level;
return (ARCHIVE_OK);
+ } else if (strcmp(key, "threads") == 0) {
+ int threads = atoi(value);
+ if (string_is_numeric(value) != ARCHIVE_OK) {
+ return (ARCHIVE_WARN);
+ }
+
+ int minimum = 0;
+
+ if (threads < minimum) {
+ return (ARCHIVE_WARN);
+ }
+
+ data->threads = threads;
+ return (ARCHIVE_OK);
}
/* Note: The "warn" return is just to inform the options
@@ -212,7 +228,7 @@
return (ARCHIVE_WARN);
}
-#if HAVE_ZSTD_H && HAVE_LIBZSTD
+#if HAVE_ZSTD_H && HAVE_LIBZSTD_COMPRESSOR
/*
* Setup callback.
*/
@@ -252,6 +268,8 @@
return (ARCHIVE_FATAL);
}
+ ZSTD_CCtx_setParameter(data->cstream, ZSTD_c_nbWorkers, data->threads);
+
return (ARCHIVE_OK);
}
@@ -335,7 +353,7 @@
}
}
-#else /* HAVE_ZSTD_H && HAVE_LIBZSTD */
+#else /* HAVE_ZSTD_H && HAVE_LIBZSTD_COMPRESSOR */
static int
archive_compressor_zstd_open(struct archive_write_filter *f)
@@ -366,6 +384,14 @@
archive_strcat(&as, " --ultra");
}
+ if (data->threads != 0) {
+ struct archive_string as2;
+ archive_string_init(&as2);
+ archive_string_sprintf(&as2, " --threads=%d", data->threads);
+ archive_string_concat(&as, &as2);
+ archive_string_free(&as2);
+ }
+
f->write = archive_compressor_zstd_write;
r = __archive_write_program_open(f, data->pdata, as.s);
archive_string_free(&as);
@@ -389,4 +415,4 @@
return __archive_write_program_close(f, data->pdata);
}
-#endif /* HAVE_ZSTD_H && HAVE_LIBZSTD */
+#endif /* HAVE_ZSTD_H && HAVE_LIBZSTD_COMPRESSOR */
diff --git a/Utilities/cmlibarchive/libarchive/archive_write_disk.3 b/Utilities/cmlibarchive/libarchive/archive_write_disk.3
index 2fa016e..97f3fcd 100644
--- a/Utilities/cmlibarchive/libarchive/archive_write_disk.3
+++ b/Utilities/cmlibarchive/libarchive/archive_write_disk.3
@@ -163,14 +163,14 @@
files outside of the current directory.
The default is not to perform this check.
If
-.It Cm ARCHIVE_EXTRACT_SPARSE
-Scan data for blocks of NUL bytes and try to recreate them with holes.
-This results in sparse files, independent of whether the archive format
-supports or uses them.
.Cm ARCHIVE_EXTRACT_UNLINK
is specified together with this option, the library will
remove any intermediate symlinks it finds and return an
error only if such symlink could not be removed.
+.It Cm ARCHIVE_EXTRACT_SPARSE
+Scan data for blocks of NUL bytes and try to recreate them with holes.
+This results in sparse files, independent of whether the archive format
+supports or uses them.
.It Cm ARCHIVE_EXTRACT_TIME
The timestamps (mtime, ctime, and atime) should be restored.
By default, they are ignored.
diff --git a/Utilities/cmlibarchive/libarchive/archive_write_disk_posix.c b/Utilities/cmlibarchive/libarchive/archive_write_disk_posix.c
index 2551ebe..b6d3d0a 100644
--- a/Utilities/cmlibarchive/libarchive/archive_write_disk_posix.c
+++ b/Utilities/cmlibarchive/libarchive/archive_write_disk_posix.c
@@ -173,6 +173,7 @@
struct fixup_entry *next;
struct archive_acl acl;
mode_t mode;
+ __LA_MODE_T filetype;
int64_t atime;
int64_t birthtime;
int64_t mtime;
@@ -357,10 +358,11 @@
static int la_opendirat(int, const char *);
static int la_mktemp(struct archive_write_disk *);
+static int la_verify_filetype(mode_t, __LA_MODE_T);
static void fsobj_error(int *, struct archive_string *, int, const char *,
const char *);
static int check_symlinks_fsobj(char *, int *, struct archive_string *,
- int);
+ int, int);
static int check_symlinks(struct archive_write_disk *);
static int create_filesystem_object(struct archive_write_disk *);
static struct fixup_entry *current_fixup(struct archive_write_disk *,
@@ -396,8 +398,6 @@
static ssize_t write_data_block(struct archive_write_disk *,
const char *, size_t);
-static struct archive_vtable *archive_write_disk_vtable(void);
-
static int _archive_write_disk_close(struct archive *);
static int _archive_write_disk_free(struct archive *);
static int _archive_write_disk_header(struct archive *,
@@ -465,6 +465,39 @@
}
static int
+la_verify_filetype(mode_t mode, __LA_MODE_T filetype) {
+ int ret = 0;
+
+ switch (filetype) {
+ case AE_IFREG:
+ ret = (S_ISREG(mode));
+ break;
+ case AE_IFDIR:
+ ret = (S_ISDIR(mode));
+ break;
+ case AE_IFLNK:
+ ret = (S_ISLNK(mode));
+ break;
+ case AE_IFSOCK:
+ ret = (S_ISSOCK(mode));
+ break;
+ case AE_IFCHR:
+ ret = (S_ISCHR(mode));
+ break;
+ case AE_IFBLK:
+ ret = (S_ISBLK(mode));
+ break;
+ case AE_IFIFO:
+ ret = (S_ISFIFO(mode));
+ break;
+ default:
+ break;
+ }
+
+ return (ret);
+}
+
+static int
lazy_stat(struct archive_write_disk *a)
{
if (a->pst != NULL) {
@@ -489,25 +522,16 @@
return (ARCHIVE_WARN);
}
-static struct archive_vtable *
-archive_write_disk_vtable(void)
-{
- static struct archive_vtable av;
- static int inited = 0;
-
- if (!inited) {
- av.archive_close = _archive_write_disk_close;
- av.archive_filter_bytes = _archive_write_disk_filter_bytes;
- av.archive_free = _archive_write_disk_free;
- av.archive_write_header = _archive_write_disk_header;
- av.archive_write_finish_entry
- = _archive_write_disk_finish_entry;
- av.archive_write_data = _archive_write_disk_data;
- av.archive_write_data_block = _archive_write_disk_data_block;
- inited = 1;
- }
- return (&av);
-}
+static const struct archive_vtable
+archive_write_disk_vtable = {
+ .archive_close = _archive_write_disk_close,
+ .archive_filter_bytes = _archive_write_disk_filter_bytes,
+ .archive_free = _archive_write_disk_free,
+ .archive_write_header = _archive_write_disk_header,
+ .archive_write_finish_entry = _archive_write_disk_finish_entry,
+ .archive_write_data = _archive_write_disk_data,
+ .archive_write_data_block = _archive_write_disk_data_block,
+};
static int64_t
_archive_write_disk_filter_bytes(struct archive *_a, int n)
@@ -822,6 +846,7 @@
fe = current_fixup(a, archive_entry_pathname(entry));
if (fe == NULL)
return (ARCHIVE_FATAL);
+ fe->filetype = archive_entry_filetype(entry);
fe->fixup |= TODO_MODE_BASE;
fe->mode = a->mode;
}
@@ -832,6 +857,7 @@
fe = current_fixup(a, archive_entry_pathname(entry));
if (fe == NULL)
return (ARCHIVE_FATAL);
+ fe->filetype = archive_entry_filetype(entry);
fe->mode = a->mode;
fe->fixup |= TODO_TIMES;
if (archive_entry_atime_is_set(entry)) {
@@ -865,6 +891,7 @@
fe = current_fixup(a, archive_entry_pathname(entry));
if (fe == NULL)
return (ARCHIVE_FATAL);
+ fe->filetype = archive_entry_filetype(entry);
fe->fixup |= TODO_ACLS;
archive_acl_copy(&fe->acl, archive_entry_acl(entry));
}
@@ -877,6 +904,7 @@
fe = current_fixup(a, archive_entry_pathname(entry));
if (fe == NULL)
return (ARCHIVE_FATAL);
+ fe->filetype = archive_entry_filetype(entry);
fe->mac_metadata = malloc(metadata_size);
if (fe->mac_metadata != NULL) {
memcpy(fe->mac_metadata, metadata,
@@ -891,6 +919,7 @@
fe = current_fixup(a, archive_entry_pathname(entry));
if (fe == NULL)
return (ARCHIVE_FATAL);
+ fe->filetype = archive_entry_filetype(entry);
fe->fixup |= TODO_FFLAGS;
/* TODO: Complete this.. defer fflags from below. */
}
@@ -1956,7 +1985,7 @@
a->archive.magic = ARCHIVE_WRITE_DISK_MAGIC;
/* We're ready to write a header immediately. */
a->archive.state = ARCHIVE_STATE_HEADER;
- a->archive.vtable = archive_write_disk_vtable();
+ a->archive.vtable = &archive_write_disk_vtable;
a->start_time = time(NULL);
/* Query and restore the umask. */
umask(a->user_umask = umask(0));
@@ -2263,7 +2292,7 @@
return (EPERM);
}
r = check_symlinks_fsobj(linkname_copy, &error_number,
- &error_string, a->flags);
+ &error_string, a->flags, 1);
if (r != ARCHIVE_OK) {
archive_set_error(&a->archive, error_number, "%s",
error_string.s);
@@ -2284,7 +2313,12 @@
*/
if (a->flags & ARCHIVE_EXTRACT_SAFE_WRITES)
unlink(a->name);
+#ifdef HAVE_LINKAT
+ r = linkat(AT_FDCWD, linkname, AT_FDCWD, a->name,
+ 0) ? errno : 0;
+#else
r = link(linkname, a->name) ? errno : 0;
+#endif
/*
* New cpio and pax formats allow hardlink entries
* to carry data, so we may have to open the file
@@ -2456,7 +2490,9 @@
{
struct archive_write_disk *a = (struct archive_write_disk *)_a;
struct fixup_entry *next, *p;
- int fd, ret;
+ struct stat st;
+ char *c;
+ int fd, ret, openflags;
archive_check_magic(&a->archive, ARCHIVE_WRITE_DISK_MAGIC,
ARCHIVE_STATE_HEADER | ARCHIVE_STATE_DATA,
@@ -2469,10 +2505,70 @@
while (p != NULL) {
fd = -1;
a->pst = NULL; /* Mark stat cache as out-of-date. */
- if (p->fixup &
- (TODO_TIMES | TODO_MODE_BASE | TODO_ACLS | TODO_FFLAGS)) {
- fd = open(p->name,
- O_WRONLY | O_BINARY | O_NOFOLLOW | O_CLOEXEC);
+
+ /* We must strip trailing slashes from the path to avoid
+ dereferencing symbolic links to directories */
+ c = p->name;
+ while (*c != '\0')
+ c++;
+ while (c != p->name && *(c - 1) == '/') {
+ c--;
+ *c = '\0';
+ }
+
+ if (p->fixup == 0)
+ goto skip_fixup_entry;
+ else {
+ /*
+ * We need to verify if the type of the file
+ * we are going to open matches the file type
+ * of the fixup entry.
+ */
+ openflags = O_BINARY | O_NOFOLLOW | O_RDONLY
+ | O_CLOEXEC;
+#if defined(O_DIRECTORY)
+ if (p->filetype == AE_IFDIR)
+ openflags |= O_DIRECTORY;
+#endif
+ fd = open(p->name, openflags);
+
+#if defined(O_DIRECTORY)
+ /*
+ * If we support O_DIRECTORY and open was
+ * successful we can skip the file type check
+ * for directories. For other file types
+ * we need to verify via fstat() or lstat()
+ */
+ if (fd == -1 || p->filetype != AE_IFDIR) {
+#if HAVE_FSTAT
+ if (fd > 0 && (
+ fstat(fd, &st) != 0 ||
+ la_verify_filetype(st.st_mode,
+ p->filetype) == 0)) {
+ goto skip_fixup_entry;
+ } else
+#endif
+ if (lstat(p->name, &st) != 0 ||
+ la_verify_filetype(st.st_mode,
+ p->filetype) == 0) {
+ goto skip_fixup_entry;
+ }
+ }
+#else
+#if HAVE_FSTAT
+ if (fd > 0 && (
+ fstat(fd, &st) != 0 ||
+ la_verify_filetype(st.st_mode,
+ p->filetype) == 0)) {
+ goto skip_fixup_entry;
+ } else
+#endif
+ if (lstat(p->name, &st) != 0 ||
+ la_verify_filetype(st.st_mode,
+ p->filetype) == 0) {
+ goto skip_fixup_entry;
+ }
+#endif
}
if (p->fixup & TODO_TIMES) {
set_times(a, fd, p->mode, p->name,
@@ -2484,10 +2580,14 @@
if (p->fixup & TODO_MODE_BASE) {
#ifdef HAVE_FCHMOD
if (fd >= 0)
- fchmod(fd, p->mode);
+ fchmod(fd, p->mode & 07777);
else
#endif
- chmod(p->name, p->mode);
+#ifdef HAVE_LCHMOD
+ lchmod(p->name, p->mode & 07777);
+#else
+ chmod(p->name, p->mode & 07777);
+#endif
}
if (p->fixup & TODO_ACLS)
archive_write_disk_set_acls(&a->archive, fd,
@@ -2498,6 +2598,7 @@
if (p->fixup & TODO_MAC_METADATA)
set_mac_metadata(a, p->name, p->mac_metadata,
p->mac_metadata_size);
+skip_fixup_entry:
next = p->next;
archive_acl_clear(&p->acl);
free(p->mac_metadata);
@@ -2638,6 +2739,7 @@
fe->next = a->fixup_list;
a->fixup_list = fe;
fe->fixup = 0;
+ fe->filetype = 0;
fe->name = strdup(pathname);
return (fe);
}
@@ -2675,7 +2777,7 @@
*/
static int
check_symlinks_fsobj(char *path, int *a_eno, struct archive_string *a_estr,
- int flags)
+ int flags, int checking_linkname)
{
#if !defined(HAVE_LSTAT) && \
!(defined(HAVE_OPENAT) && defined(HAVE_FSTATAT) && defined(HAVE_UNLINKAT))
@@ -2684,6 +2786,7 @@
(void)error_number; /* UNUSED */
(void)error_string; /* UNUSED */
(void)flags; /* UNUSED */
+ (void)checking_linkname; /* UNUSED */
return (ARCHIVE_OK);
#else
int res = ARCHIVE_OK;
@@ -2805,6 +2908,28 @@
head = tail + 1;
}
} else if (S_ISLNK(st.st_mode)) {
+ if (last && checking_linkname) {
+#ifdef HAVE_LINKAT
+ /*
+ * Hardlinks to symlinks are safe to write
+ * if linkat() is supported as it does not
+ * follow symlinks.
+ */
+ res = ARCHIVE_OK;
+#else
+ /*
+ * We return ARCHIVE_FAILED here as we are
+ * not able to safely write hardlinks
+ * to symlinks.
+ */
+ tail[0] = c;
+ fsobj_error(a_eno, a_estr, errno,
+ "Cannot write hardlink to symlink ",
+ path);
+ res = ARCHIVE_FAILED;
+#endif
+ break;
+ } else
if (last) {
/*
* Last element is symlink; remove it
@@ -2971,7 +3096,7 @@
int rc;
archive_string_init(&error_string);
rc = check_symlinks_fsobj(a->name, &error_number, &error_string,
- a->flags);
+ a->flags, 0);
if (rc != ARCHIVE_OK) {
archive_set_error(&a->archive, error_number, "%s",
error_string.s);
@@ -3737,6 +3862,7 @@
le = current_fixup(a, a->name);
if (le == NULL)
return (ARCHIVE_FATAL);
+ le->filetype = archive_entry_filetype(a->entry);
le->fixup |= TODO_FFLAGS;
le->fflags_set = set;
/* Store the mode if it's not already there. */
@@ -3899,7 +4025,8 @@
/* If we weren't given an fd, open it ourselves. */
if (myfd < 0) {
- myfd = open(name, O_RDONLY | O_NONBLOCK | O_BINARY | O_CLOEXEC);
+ myfd = open(name, O_RDONLY | O_NONBLOCK | O_BINARY |
+ O_CLOEXEC | O_NOFOLLOW);
__archive_ensure_cloexec_flag(myfd);
}
if (myfd < 0)
diff --git a/Utilities/cmlibarchive/libarchive/archive_write_disk_windows.c b/Utilities/cmlibarchive/libarchive/archive_write_disk_windows.c
index 0c60017..1b12a29 100644
--- a/Utilities/cmlibarchive/libarchive/archive_write_disk_windows.c
+++ b/Utilities/cmlibarchive/libarchive/archive_write_disk_windows.c
@@ -213,7 +213,7 @@
static int create_filesystem_object(struct archive_write_disk *);
static struct fixup_entry *current_fixup(struct archive_write_disk *,
const wchar_t *pathname);
-static int cleanup_pathname(struct archive_write_disk *);
+static int cleanup_pathname(struct archive_write_disk *, wchar_t *);
static int create_dir(struct archive_write_disk *, wchar_t *);
static int create_parent_dir(struct archive_write_disk *, wchar_t *);
static int la_chmod(const wchar_t *, mode_t);
@@ -238,8 +238,6 @@
static ssize_t write_data_block(struct archive_write_disk *,
const char *, size_t);
-static struct archive_vtable *archive_write_disk_vtable(void);
-
static int _archive_write_disk_close(struct archive *);
static int _archive_write_disk_free(struct archive *);
static int _archive_write_disk_header(struct archive *,
@@ -628,7 +626,7 @@
static BOOLEAN (WINAPI *f)(LPCWSTR, LPCWSTR, DWORD);
static int set;
wchar_t *ttarget, *p;
- int len;
+ size_t len;
DWORD attrs = 0;
DWORD flags = 0;
DWORD newflags = 0;
@@ -759,25 +757,16 @@
return (ARCHIVE_WARN);
}
-static struct archive_vtable *
-archive_write_disk_vtable(void)
-{
- static struct archive_vtable av;
- static int inited = 0;
-
- if (!inited) {
- av.archive_close = _archive_write_disk_close;
- av.archive_filter_bytes = _archive_write_disk_filter_bytes;
- av.archive_free = _archive_write_disk_free;
- av.archive_write_header = _archive_write_disk_header;
- av.archive_write_finish_entry
- = _archive_write_disk_finish_entry;
- av.archive_write_data = _archive_write_disk_data;
- av.archive_write_data_block = _archive_write_disk_data_block;
- inited = 1;
- }
- return (&av);
-}
+static const struct archive_vtable
+archive_write_disk_vtable = {
+ .archive_close = _archive_write_disk_close,
+ .archive_filter_bytes = _archive_write_disk_filter_bytes,
+ .archive_free = _archive_write_disk_free,
+ .archive_write_header = _archive_write_disk_header,
+ .archive_write_finish_entry = _archive_write_disk_finish_entry,
+ .archive_write_data = _archive_write_disk_data,
+ .archive_write_data_block = _archive_write_disk_data_block,
+};
static int64_t
_archive_write_disk_filter_bytes(struct archive *_a, int n)
@@ -854,7 +843,7 @@
* dir restores; the dir restore logic otherwise gets messed
* up by nonsense like "dir/.".
*/
- ret = cleanup_pathname(a);
+ ret = cleanup_pathname(a, a->name);
if (ret != ARCHIVE_OK)
return (ret);
@@ -1373,7 +1362,7 @@
a->archive.magic = ARCHIVE_WRITE_DISK_MAGIC;
/* We're ready to write a header immediately. */
a->archive.state = ARCHIVE_STATE_HEADER;
- a->archive.vtable = archive_write_disk_vtable();
+ a->archive.vtable = &archive_write_disk_vtable;
a->start_time = time(NULL);
/* Query and restore the umask. */
umask(a->user_umask = umask(0));
@@ -1671,9 +1660,22 @@
/* Since link(2) and symlink(2) don't handle modes, we're done here. */
linkname = archive_entry_hardlink_w(a->entry);
if (linkname != NULL) {
- wchar_t *linkfull, *namefull;
-
- linkfull = __la_win_permissive_name_w(linkname);
+ wchar_t *linksanitized, *linkfull, *namefull;
+ size_t l = (wcslen(linkname) + 1) * sizeof(wchar_t);
+ linksanitized = malloc(l);
+ if (linksanitized == NULL) {
+ archive_set_error(&a->archive, ENOMEM,
+ "Can't allocate memory for hardlink target");
+ return (-1);
+ }
+ memcpy(linksanitized, linkname, l);
+ r = cleanup_pathname(a, linksanitized);
+ if (r != ARCHIVE_OK) {
+ free(linksanitized);
+ return (r);
+ }
+ linkfull = __la_win_permissive_name_w(linksanitized);
+ free(linksanitized);
namefull = __la_win_permissive_name_w(a->name);
if (linkfull == NULL || namefull == NULL) {
errno = EINVAL;
@@ -2184,12 +2186,12 @@
* set) any '..' in the path.
*/
static int
-cleanup_pathname(struct archive_write_disk *a)
+cleanup_pathname(struct archive_write_disk *a, wchar_t *name)
{
wchar_t *dest, *src, *p, *top;
wchar_t separator = L'\0';
- p = a->name;
+ p = name;
if (*p == L'\0') {
archive_set_error(&a->archive, ARCHIVE_ERRNO_MISC,
"Invalid empty pathname");
@@ -2201,7 +2203,7 @@
if (*p == L'/')
*p = L'\\';
}
- p = a->name;
+ p = name;
/* Skip leading "\\.\" or "\\?\" or "\\?\UNC\" or
* "\\?\Volume{GUID}\"
diff --git a/Utilities/cmlibarchive/libarchive/archive_write_format.3 b/Utilities/cmlibarchive/libarchive/archive_write_format.3
index 47a7403..653089f 100644
--- a/Utilities/cmlibarchive/libarchive/archive_write_format.3
+++ b/Utilities/cmlibarchive/libarchive/archive_write_format.3
@@ -35,7 +35,10 @@
.Nm archive_write_set_format_ar_svr4 ,
.Nm archive_write_set_format_by_name ,
.Nm archive_write_set_format_cpio ,
+.Nm archive_write_set_format_cpio_bin ,
.Nm archive_write_set_format_cpio_newc ,
+.Nm archive_write_set_format_cpio_odc ,
+.Nm archive_write_set_format_cpio_pwb ,
.Nm archive_write_set_format_filter_by_ext ,
.Nm archive_write_set_format_filter_by_ext_def ,
.Nm archive_write_set_format_gnutar ,
@@ -73,8 +76,14 @@
.Ft int
.Fn archive_write_set_format_cpio "struct archive *"
.Ft int
+.Fn archive_write_set_format_cpio_bin "struct archive *"
+.Ft int
.Fn archive_write_set_format_cpio_newc "struct archive *"
.Ft int
+.Fn archive_write_set_format_cpio_odc "struct archive *"
+.Ft int
+.Fn archive_write_set_format_cpio_pwb "struct archive *"
+.Ft int
.Fn archive_write_set_format_filter_by_ext "struct archive *" "const char *filename"
.Ft int
.Fn archive_write_set_format_filter_by_ext_def "struct archive *" "const char *filename" "const char *def_ext"
@@ -119,17 +128,20 @@
.It Fn archive_write_set_format_by_name
Sets the corresponding format based on the common name.
.It Xo
-.Fn archive_write_set_format_filter_by_ext ,
+.Fn archive_write_set_format_filter_by_ext
.Fn archive_write_set_format_filter_by_ext_def
.Xc
Sets both filters and format based on the output filename.
Supported extensions: .7z, .zip, .jar, .cpio, .iso, .a, .ar, .tar, .tgz, .tar.gz, .tar.bz2, .tar.xz
.It Xo
.Fn archive_write_set_format_7zip
-.Fn archive_write_set_format_ar_bsd ,
-.Fn archive_write_set_format_ar_svr4 ,
+.Fn archive_write_set_format_ar_bsd
+.Fn archive_write_set_format_ar_svr4
.Fn archive_write_set_format_cpio
+.Fn archive_write_set_format_cpio_bin
.Fn archive_write_set_format_cpio_newc
+.Fn archive_write_set_format_cpio_odc
+.Fn archive_write_set_format_cpio_pwb
.Fn archive_write_set_format_gnutar
.Fn archive_write_set_format_iso9660
.Fn archive_write_set_format_mtree
diff --git a/Utilities/cmlibarchive/libarchive/archive_write_set_format.c b/Utilities/cmlibarchive/libarchive/archive_write_set_format.c
index 7dbe7b9..1f65fa4 100644
--- a/Utilities/cmlibarchive/libarchive/archive_write_set_format.c
+++ b/Utilities/cmlibarchive/libarchive/archive_write_set_format.c
@@ -44,7 +44,9 @@
{
{ ARCHIVE_FORMAT_7ZIP, archive_write_set_format_7zip },
{ ARCHIVE_FORMAT_CPIO, archive_write_set_format_cpio },
- { ARCHIVE_FORMAT_CPIO_POSIX, archive_write_set_format_cpio },
+ { ARCHIVE_FORMAT_CPIO_BIN_LE, archive_write_set_format_cpio_bin },
+ { ARCHIVE_FORMAT_CPIO_PWB, archive_write_set_format_cpio_pwb },
+ { ARCHIVE_FORMAT_CPIO_POSIX, archive_write_set_format_cpio_odc },
{ ARCHIVE_FORMAT_CPIO_SVR4_NOCRC, archive_write_set_format_cpio_newc },
{ ARCHIVE_FORMAT_ISO9660, archive_write_set_format_iso9660 },
{ ARCHIVE_FORMAT_MTREE, archive_write_set_format_mtree },
diff --git a/Utilities/cmlibarchive/libarchive/archive_write_set_format_7zip.c b/Utilities/cmlibarchive/libarchive/archive_write_set_format_7zip.c
index 7f2e6ac..87b3586 100644
--- a/Utilities/cmlibarchive/libarchive/archive_write_set_format_7zip.c
+++ b/Utilities/cmlibarchive/libarchive/archive_write_set_format_7zip.c
@@ -755,6 +755,10 @@
*/
#if HAVE_LZMA_H
header_compression = _7Z_LZMA1;
+ if(zip->opt_compression == _7Z_LZMA2 ||
+ zip->opt_compression == _7Z_COPY)
+ header_compression = zip->opt_compression;
+
/* If the stored file is only one, do not encode the header.
* This is the same way 7z command does. */
if (zip->total_number_entry == 1)
@@ -762,7 +766,8 @@
#else
header_compression = _7Z_COPY;
#endif
- r = _7z_compression_init_encoder(a, header_compression, 6);
+ r = _7z_compression_init_encoder(a, header_compression,
+ zip->opt_compression_level);
if (r < 0)
return (r);
zip->crc32flg = PRECODE_CRC32;
diff --git a/Utilities/cmlibarchive/libarchive/archive_write_set_format_by_name.c b/Utilities/cmlibarchive/libarchive/archive_write_set_format_by_name.c
index 86e8621..bfb4b35 100644
--- a/Utilities/cmlibarchive/libarchive/archive_write_set_format_by_name.c
+++ b/Utilities/cmlibarchive/libarchive/archive_write_set_format_by_name.c
@@ -49,6 +49,7 @@
{ "arbsd", archive_write_set_format_ar_bsd },
{ "argnu", archive_write_set_format_ar_svr4 },
{ "arsvr4", archive_write_set_format_ar_svr4 },
+ { "bin", archive_write_set_format_cpio_bin },
{ "bsdtar", archive_write_set_format_pax_restricted },
{ "cd9660", archive_write_set_format_iso9660 },
{ "cpio", archive_write_set_format_cpio },
@@ -58,11 +59,12 @@
{ "mtree", archive_write_set_format_mtree },
{ "mtree-classic", archive_write_set_format_mtree_classic },
{ "newc", archive_write_set_format_cpio_newc },
- { "odc", archive_write_set_format_cpio },
+ { "odc", archive_write_set_format_cpio_odc },
{ "oldtar", archive_write_set_format_v7tar },
{ "pax", archive_write_set_format_pax },
{ "paxr", archive_write_set_format_pax_restricted },
{ "posix", archive_write_set_format_pax },
+ { "pwb", archive_write_set_format_cpio_pwb },
{ "raw", archive_write_set_format_raw },
{ "rpax", archive_write_set_format_pax_restricted },
{ "shar", archive_write_set_format_shar },
diff --git a/Utilities/cmlibarchive/libarchive/archive_write_set_format_cpio.c b/Utilities/cmlibarchive/libarchive/archive_write_set_format_cpio.c
index e066733..47152cc 100644
--- a/Utilities/cmlibarchive/libarchive/archive_write_set_format_cpio.c
+++ b/Utilities/cmlibarchive/libarchive/archive_write_set_format_cpio.c
@@ -1,500 +1,11 @@
-/*-
- * Copyright (c) 2003-2007 Tim Kientzle
- * Copyright (c) 2011-2012 Michihiro NAKAJIMA
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY THE AUTHOR(S) ``AS IS'' AND ANY EXPRESS OR
- * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
- * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
- * IN NO EVENT SHALL THE AUTHOR(S) BE LIABLE FOR ANY DIRECT, INDIRECT,
- * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
- * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
- * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
- * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
- * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
#include "archive_platform.h"
-__FBSDID("$FreeBSD: head/lib/libarchive/archive_write_set_format_cpio.c 201170 2009-12-29 06:34:23Z kientzle $");
-
-#ifdef HAVE_ERRNO_H
-#include <errno.h>
-#endif
-#include <stdio.h>
-#ifdef HAVE_STDLIB_H
-#include <stdlib.h>
-#endif
-#ifdef HAVE_STRING_H
-#include <string.h>
-#endif
-
#include "archive.h"
-#include "archive_entry.h"
-#include "archive_entry_locale.h"
-#include "archive_private.h"
-#include "archive_write_private.h"
-#include "archive_write_set_format_private.h"
-
-static ssize_t archive_write_cpio_data(struct archive_write *,
- const void *buff, size_t s);
-static int archive_write_cpio_close(struct archive_write *);
-static int archive_write_cpio_free(struct archive_write *);
-static int archive_write_cpio_finish_entry(struct archive_write *);
-static int archive_write_cpio_header(struct archive_write *,
- struct archive_entry *);
-static int archive_write_cpio_options(struct archive_write *,
- const char *, const char *);
-static int format_octal(int64_t, void *, int);
-static int64_t format_octal_recursive(int64_t, char *, int);
-static int write_header(struct archive_write *, struct archive_entry *);
-
-struct cpio {
- uint64_t entry_bytes_remaining;
-
- int64_t ino_next;
-
- struct { int64_t old; int new;} *ino_list;
- size_t ino_list_size;
- size_t ino_list_next;
-
- struct archive_string_conv *opt_sconv;
- struct archive_string_conv *sconv_default;
- int init_default_conversion;
-};
-
-#define c_magic_offset 0
-#define c_magic_size 6
-#define c_dev_offset 6
-#define c_dev_size 6
-#define c_ino_offset 12
-#define c_ino_size 6
-#define c_mode_offset 18
-#define c_mode_size 6
-#define c_uid_offset 24
-#define c_uid_size 6
-#define c_gid_offset 30
-#define c_gid_size 6
-#define c_nlink_offset 36
-#define c_nlink_size 6
-#define c_rdev_offset 42
-#define c_rdev_size 6
-#define c_mtime_offset 48
-#define c_mtime_size 11
-#define c_namesize_offset 59
-#define c_namesize_size 6
-#define c_filesize_offset 65
-#define c_filesize_size 11
/*
- * Set output format to 'cpio' format.
+ * Set output format to the default 'cpio' format.
*/
int
archive_write_set_format_cpio(struct archive *_a)
{
- struct archive_write *a = (struct archive_write *)_a;
- struct cpio *cpio;
-
- archive_check_magic(_a, ARCHIVE_WRITE_MAGIC,
- ARCHIVE_STATE_NEW, "archive_write_set_format_cpio");
-
- /* If someone else was already registered, unregister them. */
- if (a->format_free != NULL)
- (a->format_free)(a);
-
- cpio = (struct cpio *)calloc(1, sizeof(*cpio));
- if (cpio == NULL) {
- archive_set_error(&a->archive, ENOMEM, "Can't allocate cpio data");
- return (ARCHIVE_FATAL);
- }
- a->format_data = cpio;
- a->format_name = "cpio";
- a->format_options = archive_write_cpio_options;
- a->format_write_header = archive_write_cpio_header;
- a->format_write_data = archive_write_cpio_data;
- a->format_finish_entry = archive_write_cpio_finish_entry;
- a->format_close = archive_write_cpio_close;
- a->format_free = archive_write_cpio_free;
- a->archive.archive_format = ARCHIVE_FORMAT_CPIO_POSIX;
- a->archive.archive_format_name = "POSIX cpio";
- return (ARCHIVE_OK);
-}
-
-static int
-archive_write_cpio_options(struct archive_write *a, const char *key,
- const char *val)
-{
- struct cpio *cpio = (struct cpio *)a->format_data;
- int ret = ARCHIVE_FAILED;
-
- if (strcmp(key, "hdrcharset") == 0) {
- if (val == NULL || val[0] == 0)
- archive_set_error(&a->archive, ARCHIVE_ERRNO_MISC,
- "%s: hdrcharset option needs a character-set name",
- a->format_name);
- else {
- cpio->opt_sconv = archive_string_conversion_to_charset(
- &a->archive, val, 0);
- if (cpio->opt_sconv != NULL)
- ret = ARCHIVE_OK;
- else
- ret = ARCHIVE_FATAL;
- }
- return (ret);
- }
-
- /* Note: The "warn" return is just to inform the options
- * supervisor that we didn't handle it. It will generate
- * a suitable error if no one used this option. */
- return (ARCHIVE_WARN);
-}
-
-/*
- * Ino values are as long as 64 bits on some systems; cpio format
- * only allows 18 bits and relies on the ino values to identify hardlinked
- * files. So, we can't merely "hash" the ino numbers since collisions
- * would corrupt the archive. Instead, we generate synthetic ino values
- * to store in the archive and maintain a map of original ino values to
- * synthetic ones so we can preserve hardlink information.
- *
- * TODO: Make this more efficient. It's not as bad as it looks (most
- * files don't have any hardlinks and we don't do any work here for those),
- * but it wouldn't be hard to do better.
- *
- * TODO: Work with dev/ino pairs here instead of just ino values.
- */
-static int
-synthesize_ino_value(struct cpio *cpio, struct archive_entry *entry)
-{
- int64_t ino = archive_entry_ino64(entry);
- int ino_new;
- size_t i;
-
- /*
- * If no index number was given, don't assign one. In
- * particular, this handles the end-of-archive marker
- * correctly by giving it a zero index value. (This is also
- * why we start our synthetic index numbers with one below.)
- */
- if (ino == 0)
- return (0);
-
- /* Don't store a mapping if we don't need to. */
- if (archive_entry_nlink(entry) < 2) {
- return (int)(++cpio->ino_next);
- }
-
- /* Look up old ino; if we have it, this is a hardlink
- * and we reuse the same value. */
- for (i = 0; i < cpio->ino_list_next; ++i) {
- if (cpio->ino_list[i].old == ino)
- return (cpio->ino_list[i].new);
- }
-
- /* Assign a new index number. */
- ino_new = (int)(++cpio->ino_next);
-
- /* Ensure space for the new mapping. */
- if (cpio->ino_list_size <= cpio->ino_list_next) {
- size_t newsize = cpio->ino_list_size < 512
- ? 512 : cpio->ino_list_size * 2;
- void *newlist = realloc(cpio->ino_list,
- sizeof(cpio->ino_list[0]) * newsize);
- if (newlist == NULL)
- return (-1);
-
- cpio->ino_list_size = newsize;
- cpio->ino_list = newlist;
- }
-
- /* Record and return the new value. */
- cpio->ino_list[cpio->ino_list_next].old = ino;
- cpio->ino_list[cpio->ino_list_next].new = ino_new;
- ++cpio->ino_list_next;
- return (ino_new);
-}
-
-
-static struct archive_string_conv *
-get_sconv(struct archive_write *a)
-{
- struct cpio *cpio;
- struct archive_string_conv *sconv;
-
- cpio = (struct cpio *)a->format_data;
- sconv = cpio->opt_sconv;
- if (sconv == NULL) {
- if (!cpio->init_default_conversion) {
- cpio->sconv_default =
- archive_string_default_conversion_for_write(
- &(a->archive));
- cpio->init_default_conversion = 1;
- }
- sconv = cpio->sconv_default;
- }
- return (sconv);
-}
-
-static int
-archive_write_cpio_header(struct archive_write *a, struct archive_entry *entry)
-{
- const char *path;
- size_t len;
-
- if (archive_entry_filetype(entry) == 0 && archive_entry_hardlink(entry) == NULL) {
- archive_set_error(&a->archive, -1, "Filetype required");
- return (ARCHIVE_FAILED);
- }
-
- if (archive_entry_pathname_l(entry, &path, &len, get_sconv(a)) != 0
- && errno == ENOMEM) {
- archive_set_error(&a->archive, ENOMEM,
- "Can't allocate memory for Pathname");
- return (ARCHIVE_FATAL);
- }
- if (len == 0 || path == NULL || path[0] == '\0') {
- archive_set_error(&a->archive, -1, "Pathname required");
- return (ARCHIVE_FAILED);
- }
-
- if (!archive_entry_size_is_set(entry) || archive_entry_size(entry) < 0) {
- archive_set_error(&a->archive, -1, "Size required");
- return (ARCHIVE_FAILED);
- }
- return write_header(a, entry);
-}
-
-static int
-write_header(struct archive_write *a, struct archive_entry *entry)
-{
- struct cpio *cpio;
- const char *p, *path;
- int pathlength, ret, ret_final;
- int64_t ino;
- char h[76];
- struct archive_string_conv *sconv;
- struct archive_entry *entry_main;
- size_t len;
-
- cpio = (struct cpio *)a->format_data;
- ret_final = ARCHIVE_OK;
- sconv = get_sconv(a);
-
-#if defined(_WIN32) && !defined(__CYGWIN__)
- /* Make sure the path separators in pathname, hardlink and symlink
- * are all slash '/', not the Windows path separator '\'. */
- entry_main = __la_win_entry_in_posix_pathseparator(entry);
- if (entry_main == NULL) {
- archive_set_error(&a->archive, ENOMEM,
- "Can't allocate ustar data");
- return(ARCHIVE_FATAL);
- }
- if (entry != entry_main)
- entry = entry_main;
- else
- entry_main = NULL;
-#else
- entry_main = NULL;
-#endif
-
- ret = archive_entry_pathname_l(entry, &path, &len, sconv);
- if (ret != 0) {
- if (errno == ENOMEM) {
- archive_set_error(&a->archive, ENOMEM,
- "Can't allocate memory for Pathname");
- ret_final = ARCHIVE_FATAL;
- goto exit_write_header;
- }
- archive_set_error(&a->archive, ARCHIVE_ERRNO_FILE_FORMAT,
- "Can't translate pathname '%s' to %s",
- archive_entry_pathname(entry),
- archive_string_conversion_charset_name(sconv));
- ret_final = ARCHIVE_WARN;
- }
- /* Include trailing null. */
- pathlength = (int)len + 1;
-
- memset(h, 0, sizeof(h));
- format_octal(070707, h + c_magic_offset, c_magic_size);
- format_octal(archive_entry_dev(entry), h + c_dev_offset, c_dev_size);
-
- ino = synthesize_ino_value(cpio, entry);
- if (ino < 0) {
- archive_set_error(&a->archive, ENOMEM,
- "No memory for ino translation table");
- ret_final = ARCHIVE_FATAL;
- goto exit_write_header;
- } else if (ino > 0777777) {
- archive_set_error(&a->archive, ERANGE,
- "Too many files for this cpio format");
- ret_final = ARCHIVE_FATAL;
- goto exit_write_header;
- }
- format_octal(ino & 0777777, h + c_ino_offset, c_ino_size);
-
- /* TODO: Set ret_final to ARCHIVE_WARN if any of these overflow. */
- format_octal(archive_entry_mode(entry), h + c_mode_offset, c_mode_size);
- format_octal(archive_entry_uid(entry), h + c_uid_offset, c_uid_size);
- format_octal(archive_entry_gid(entry), h + c_gid_offset, c_gid_size);
- format_octal(archive_entry_nlink(entry), h + c_nlink_offset, c_nlink_size);
- if (archive_entry_filetype(entry) == AE_IFBLK
- || archive_entry_filetype(entry) == AE_IFCHR)
- format_octal(archive_entry_rdev(entry), h + c_rdev_offset, c_rdev_size);
- else
- format_octal(0, h + c_rdev_offset, c_rdev_size);
- format_octal(archive_entry_mtime(entry), h + c_mtime_offset, c_mtime_size);
- format_octal(pathlength, h + c_namesize_offset, c_namesize_size);
-
- /* Non-regular files don't store bodies. */
- if (archive_entry_filetype(entry) != AE_IFREG)
- archive_entry_set_size(entry, 0);
-
- /* Symlinks get the link written as the body of the entry. */
- ret = archive_entry_symlink_l(entry, &p, &len, sconv);
- if (ret != 0) {
- if (errno == ENOMEM) {
- archive_set_error(&a->archive, ENOMEM,
- "Can't allocate memory for Linkname");
- ret_final = ARCHIVE_FATAL;
- goto exit_write_header;
- }
- archive_set_error(&a->archive, ARCHIVE_ERRNO_FILE_FORMAT,
- "Can't translate linkname '%s' to %s",
- archive_entry_symlink(entry),
- archive_string_conversion_charset_name(sconv));
- ret_final = ARCHIVE_WARN;
- }
- if (len > 0 && p != NULL && *p != '\0')
- ret = format_octal(strlen(p), h + c_filesize_offset,
- c_filesize_size);
- else
- ret = format_octal(archive_entry_size(entry),
- h + c_filesize_offset, c_filesize_size);
- if (ret) {
- archive_set_error(&a->archive, ERANGE,
- "File is too large for cpio format.");
- ret_final = ARCHIVE_FAILED;
- goto exit_write_header;
- }
-
- ret = __archive_write_output(a, h, sizeof(h));
- if (ret != ARCHIVE_OK) {
- ret_final = ARCHIVE_FATAL;
- goto exit_write_header;
- }
-
- ret = __archive_write_output(a, path, pathlength);
- if (ret != ARCHIVE_OK) {
- ret_final = ARCHIVE_FATAL;
- goto exit_write_header;
- }
-
- cpio->entry_bytes_remaining = archive_entry_size(entry);
-
- /* Write the symlink now. */
- if (p != NULL && *p != '\0') {
- ret = __archive_write_output(a, p, strlen(p));
- if (ret != ARCHIVE_OK) {
- ret_final = ARCHIVE_FATAL;
- goto exit_write_header;
- }
- }
-exit_write_header:
- archive_entry_free(entry_main);
- return (ret_final);
-}
-
-static ssize_t
-archive_write_cpio_data(struct archive_write *a, const void *buff, size_t s)
-{
- struct cpio *cpio;
- int ret;
-
- cpio = (struct cpio *)a->format_data;
- if (s > cpio->entry_bytes_remaining)
- s = (size_t)cpio->entry_bytes_remaining;
-
- ret = __archive_write_output(a, buff, s);
- cpio->entry_bytes_remaining -= s;
- if (ret >= 0)
- return (s);
- else
- return (ret);
-}
-
-/*
- * Format a number into the specified field.
- */
-static int
-format_octal(int64_t v, void *p, int digits)
-{
- int64_t max;
- int ret;
-
- max = (((int64_t)1) << (digits * 3)) - 1;
- if (v >= 0 && v <= max) {
- format_octal_recursive(v, (char *)p, digits);
- ret = 0;
- } else {
- format_octal_recursive(max, (char *)p, digits);
- ret = -1;
- }
- return (ret);
-}
-
-static int64_t
-format_octal_recursive(int64_t v, char *p, int s)
-{
- if (s == 0)
- return (v);
- v = format_octal_recursive(v, p+1, s-1);
- *p = '0' + ((char)v & 7);
- return (v >> 3);
-}
-
-static int
-archive_write_cpio_close(struct archive_write *a)
-{
- int er;
- struct archive_entry *trailer;
-
- trailer = archive_entry_new2(NULL);
- /* nlink = 1 here for GNU cpio compat. */
- archive_entry_set_nlink(trailer, 1);
- archive_entry_set_size(trailer, 0);
- archive_entry_set_pathname(trailer, "TRAILER!!!");
- er = write_header(a, trailer);
- archive_entry_free(trailer);
- return (er);
-}
-
-static int
-archive_write_cpio_free(struct archive_write *a)
-{
- struct cpio *cpio;
-
- cpio = (struct cpio *)a->format_data;
- free(cpio->ino_list);
- free(cpio);
- a->format_data = NULL;
- return (ARCHIVE_OK);
-}
-
-static int
-archive_write_cpio_finish_entry(struct archive_write *a)
-{
- struct cpio *cpio;
-
- cpio = (struct cpio *)a->format_data;
- return (__archive_write_nulls(a,
- (size_t)cpio->entry_bytes_remaining));
+ return archive_write_set_format_cpio_odc(_a);
}
diff --git a/Utilities/cmlibarchive/libarchive/archive_write_set_format_cpio_binary.c b/Utilities/cmlibarchive/libarchive/archive_write_set_format_cpio_binary.c
new file mode 100644
index 0000000..d6ce35a
--- /dev/null
+++ b/Utilities/cmlibarchive/libarchive/archive_write_set_format_cpio_binary.c
@@ -0,0 +1,610 @@
+/*-
+ * Copyright (c) 2003-2007 Tim Kientzle
+ * Copyright (c) 2011-2012 Michihiro NAKAJIMA
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR(S) ``AS IS'' AND ANY EXPRESS OR
+ * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
+ * IN NO EVENT SHALL THE AUTHOR(S) BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
+ * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
+ * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "archive_platform.h"
+__FBSDID("$FreeBSD: head/lib/libarchive/archive_write_set_format_cpio.c 201170 2009-12-29 06:34:23Z kientzle $");
+
+#ifdef HAVE_ERRNO_H
+#include <errno.h>
+#endif
+#include <stdio.h>
+#ifdef HAVE_STDLIB_H
+#include <stdlib.h>
+#endif
+#ifdef HAVE_STRING_H
+#include <string.h>
+#endif
+
+#include "archive.h"
+#include "archive_entry.h"
+#include "archive_entry_locale.h"
+#include "archive_private.h"
+#include "archive_write_private.h"
+#include "archive_write_set_format_private.h"
+
+static ssize_t archive_write_binary_data(struct archive_write *,
+ const void *buff, size_t s);
+static int archive_write_binary_close(struct archive_write *);
+static int archive_write_binary_free(struct archive_write *);
+static int archive_write_binary_finish_entry(struct archive_write *);
+static int archive_write_binary_header(struct archive_write *,
+ struct archive_entry *);
+static int archive_write_binary_options(struct archive_write *,
+ const char *, const char *);
+static int write_header(struct archive_write *, struct archive_entry *);
+
+struct cpio {
+ uint64_t entry_bytes_remaining;
+
+ int64_t ino_next;
+
+ struct { int64_t old; int new;} *ino_list;
+ size_t ino_list_size;
+ size_t ino_list_next;
+
+ struct archive_string_conv *opt_sconv;
+ struct archive_string_conv *sconv_default;
+ int init_default_conversion;
+};
+
+/* This struct needs to be packed to get the header right */
+
+#if defined(__GNUC__)
+#define PACKED(x) x __attribute__((packed))
+#elif defined(_MSC_VER)
+#define PACKED(x) __pragma(pack(push, 1)) x __pragma(pack(pop))
+#else
+#define PACKED(x) x
+#endif
+
+#define HSIZE 26
+
+PACKED(struct cpio_binary_header {
+ uint16_t h_magic;
+ uint16_t h_dev;
+ uint16_t h_ino;
+ uint16_t h_mode;
+ uint16_t h_uid;
+ uint16_t h_gid;
+ uint16_t h_nlink;
+ uint16_t h_majmin;
+ uint32_t h_mtime;
+ uint16_t h_namesize;
+ uint32_t h_filesize;
+});
+
+/* Back in the day, the 7th Edition cpio.c had this, to
+ * adapt to, as the comment said, "VAX, Interdata, ...":
+ *
+ * union { long l; short s[2]; char c[4]; } U;
+ * #define MKSHORT(v,lv) {U.l=1L;if(U.c[0]) U.l=lv,v[0]=U.s[1],v[1]=U.s[0]; else U.l=lv,v[0]=U.s[0],v[1]=U.s[1];}
+ * long mklong(v)
+ * short v[];
+ * {
+ * U.l = 1;
+ * if(U.c[0])
+ * U.s[0] = v[1], U.s[1] = v[0];
+ * else
+ * U.s[0] = v[0], U.s[1] = v[1];
+ * return U.l;
+ * }
+ *
+ * Of course, that assumes that all machines have little-endian shorts,
+ * and just adapts the others to the special endianness of the PDP-11.
+ *
+ * Now, we could do this:
+ *
+ * union { uint32_t l; uint16_t s[2]; uint8_t c[4]; } U;
+ * #define PUTI16(v,sv) {U.s[0]=1;if(U.c[0]) v=sv; else U.s[0]=sv,U.c[2]=U.c[1],U.c[3]=U.c[0],v=U.s[1];}
+ * #define PUTI32(v,lv) {char_t Ut;U.l=1;if(U.c[0]) U.l=lv,v[0]=U.s[1],v[1]=U.s[0]; else U.l=lv,Ut=U.c[0],U.c[0]=U.c[1],U.c[1]=Ut,Ut=U.c[2],U.c[2]=U.c[3],U.c[3]=Ut,v[0]=U.s[0],v[1]=U.s[1];}
+ *
+ * ...but it feels a little better to do it like this:
+ */
+
+static uint16_t la_swap16(uint16_t in) {
+ union {
+ uint16_t s[2];
+ uint8_t c[4];
+ } U;
+ U.s[0] = 1;
+ if (U.c[0])
+ return in;
+ else {
+ U.s[0] = in;
+ U.c[2] = U.c[1];
+ U.c[3] = U.c[0];
+ return U.s[1];
+ }
+ /* NOTREACHED */
+}
+
+static uint32_t la_swap32(uint32_t in) {
+ union {
+ uint32_t l;
+ uint16_t s[2];
+ uint8_t c[4];
+ } U;
+ U.l = 1;
+ if (U.c[0]) { /* Little-endian */
+ uint16_t t;
+ U.l = in;
+ t = U.s[0];
+ U.s[0] = U.s[1];
+ U.s[1] = t;
+ } else if (U.c[3]) { /* Big-endian */
+ U.l = in;
+ U.s[0] = la_swap16(U.s[0]);
+ U.s[1] = la_swap16(U.s[1]);
+ } else { /* PDP-endian */
+ U.l = in;
+ }
+ return U.l;
+}
+
+/*
+ * Set output format to the selected binary variant
+ */
+static int
+archive_write_set_format_cpio_binary(struct archive *_a, int format)
+{
+ struct archive_write *a = (struct archive_write *)_a;
+ struct cpio *cpio;
+
+ if (sizeof(struct cpio_binary_header) != HSIZE) {
+ archive_set_error(&a->archive, EINVAL,
+ "Binary cpio format not supported on this platform");
+ return (ARCHIVE_FATAL);
+ }
+
+ archive_check_magic(_a, ARCHIVE_WRITE_MAGIC,
+ ARCHIVE_STATE_NEW, "archive_write_set_format_cpio_binary");
+
+ /* If someone else was already registered, unregister them. */
+ if (a->format_free != NULL)
+ (a->format_free)(a);
+
+ cpio = (struct cpio *)calloc(1, sizeof(*cpio));
+ if (cpio == NULL) {
+ archive_set_error(&a->archive, ENOMEM, "Can't allocate cpio data");
+ return (ARCHIVE_FATAL);
+ }
+ a->format_data = cpio;
+ a->format_name = "cpio";
+ a->format_options = archive_write_binary_options;
+ a->format_write_header = archive_write_binary_header;
+ a->format_write_data = archive_write_binary_data;
+ a->format_finish_entry = archive_write_binary_finish_entry;
+ a->format_close = archive_write_binary_close;
+ a->format_free = archive_write_binary_free;
+ a->archive.archive_format = format;
+ switch (format) {
+ case ARCHIVE_FORMAT_CPIO_PWB:
+ a->archive.archive_format_name = "PWB cpio";
+ break;
+ case ARCHIVE_FORMAT_CPIO_BIN_LE:
+ a->archive.archive_format_name = "7th Edition cpio";
+ break;
+ default:
+ archive_set_error(&a->archive, EINVAL, "binary format must be 'pwb' or 'bin'");
+ return (ARCHIVE_FATAL);
+ }
+ return (ARCHIVE_OK);
+}
+
+/*
+ * Set output format to PWB (6th Edition) binary format
+ */
+int
+archive_write_set_format_cpio_pwb(struct archive *_a)
+{
+ return archive_write_set_format_cpio_binary(_a, ARCHIVE_FORMAT_CPIO_PWB);
+}
+
+/*
+ * Set output format to 7th Edition binary format
+ */
+int
+archive_write_set_format_cpio_bin(struct archive *_a)
+{
+ return archive_write_set_format_cpio_binary(_a, ARCHIVE_FORMAT_CPIO_BIN_LE);
+}
+
+static int
+archive_write_binary_options(struct archive_write *a, const char *key,
+ const char *val)
+{
+ struct cpio *cpio = (struct cpio *)a->format_data;
+ int ret = ARCHIVE_FAILED;
+
+ if (strcmp(key, "hdrcharset") == 0) {
+ if (val == NULL || val[0] == 0)
+ archive_set_error(&a->archive, ARCHIVE_ERRNO_MISC,
+ "%s: hdrcharset option needs a character-set name",
+ a->format_name);
+ else {
+ cpio->opt_sconv = archive_string_conversion_to_charset(
+ &a->archive, val, 0);
+ if (cpio->opt_sconv != NULL)
+ ret = ARCHIVE_OK;
+ else
+ ret = ARCHIVE_FATAL;
+ }
+ return (ret);
+ }
+
+ /* Note: The "warn" return is just to inform the options
+ * supervisor that we didn't handle it. It will generate
+ * a suitable error if no one used this option. */
+ return (ARCHIVE_WARN);
+}
+
+/*
+ * Ino values are as long as 64 bits on some systems; cpio format
+ * only allows 16 bits and relies on the ino values to identify hardlinked
+ * files. So, we can't merely "hash" the ino numbers since collisions
+ * would corrupt the archive. Instead, we generate synthetic ino values
+ * to store in the archive and maintain a map of original ino values to
+ * synthetic ones so we can preserve hardlink information.
+ *
+ * TODO: Make this more efficient. It's not as bad as it looks (most
+ * files don't have any hardlinks and we don't do any work here for those),
+ * but it wouldn't be hard to do better.
+ *
+ * TODO: Work with dev/ino pairs here instead of just ino values.
+ */
+static int
+synthesize_ino_value(struct cpio *cpio, struct archive_entry *entry)
+{
+ int64_t ino = archive_entry_ino64(entry);
+ int ino_new;
+ size_t i;
+
+ /*
+ * If no index number was given, don't assign one. In
+ * particular, this handles the end-of-archive marker
+ * correctly by giving it a zero index value. (This is also
+ * why we start our synthetic index numbers with one below.)
+ */
+ if (ino == 0)
+ return (0);
+
+ /* Don't store a mapping if we don't need to. */
+ if (archive_entry_nlink(entry) < 2) {
+ return (int)(++cpio->ino_next);
+ }
+
+ /* Look up old ino; if we have it, this is a hardlink
+ * and we reuse the same value. */
+ for (i = 0; i < cpio->ino_list_next; ++i) {
+ if (cpio->ino_list[i].old == ino)
+ return (cpio->ino_list[i].new);
+ }
+
+ /* Assign a new index number. */
+ ino_new = (int)(++cpio->ino_next);
+
+ /* Ensure space for the new mapping. */
+ if (cpio->ino_list_size <= cpio->ino_list_next) {
+ size_t newsize = cpio->ino_list_size < 512
+ ? 512 : cpio->ino_list_size * 2;
+ void *newlist = realloc(cpio->ino_list,
+ sizeof(cpio->ino_list[0]) * newsize);
+ if (newlist == NULL)
+ return (-1);
+
+ cpio->ino_list_size = newsize;
+ cpio->ino_list = newlist;
+ }
+
+ /* Record and return the new value. */
+ cpio->ino_list[cpio->ino_list_next].old = ino;
+ cpio->ino_list[cpio->ino_list_next].new = ino_new;
+ ++cpio->ino_list_next;
+ return (ino_new);
+}
+
+
+static struct archive_string_conv *
+get_sconv(struct archive_write *a)
+{
+ struct cpio *cpio;
+ struct archive_string_conv *sconv;
+
+ cpio = (struct cpio *)a->format_data;
+ sconv = cpio->opt_sconv;
+ if (sconv == NULL) {
+ if (!cpio->init_default_conversion) {
+ cpio->sconv_default =
+ archive_string_default_conversion_for_write(
+ &(a->archive));
+ cpio->init_default_conversion = 1;
+ }
+ sconv = cpio->sconv_default;
+ }
+ return (sconv);
+}
+
+static int
+archive_write_binary_header(struct archive_write *a, struct archive_entry *entry)
+{
+ const char *path;
+ size_t len;
+
+ if (archive_entry_filetype(entry) == 0 && archive_entry_hardlink(entry) == NULL) {
+ archive_set_error(&a->archive, -1, "Filetype required");
+ return (ARCHIVE_FAILED);
+ }
+
+ if (archive_entry_pathname_l(entry, &path, &len, get_sconv(a)) != 0
+ && errno == ENOMEM) {
+ archive_set_error(&a->archive, ENOMEM,
+ "Can't allocate memory for Pathname");
+ return (ARCHIVE_FATAL);
+ }
+ if (len == 0 || path == NULL || path[0] == '\0') {
+ archive_set_error(&a->archive, -1, "Pathname required");
+ return (ARCHIVE_FAILED);
+ }
+
+ if (!archive_entry_size_is_set(entry) || archive_entry_size(entry) < 0) {
+ archive_set_error(&a->archive, -1, "Size required");
+ return (ARCHIVE_FAILED);
+ }
+ return write_header(a, entry);
+}
+
+static int
+write_header(struct archive_write *a, struct archive_entry *entry)
+{
+ struct cpio *cpio;
+ const char *p, *path;
+ int pathlength, ret, ret_final;
+ int64_t ino;
+ struct cpio_binary_header h;
+ struct archive_string_conv *sconv;
+ struct archive_entry *entry_main;
+ size_t len;
+
+ cpio = (struct cpio *)a->format_data;
+ ret_final = ARCHIVE_OK;
+ sconv = get_sconv(a);
+
+#if defined(_WIN32) && !defined(__CYGWIN__)
+ /* Make sure the path separators in pathname, hardlink and symlink
+ * are all slash '/', not the Windows path separator '\'. */
+ entry_main = __la_win_entry_in_posix_pathseparator(entry);
+ if (entry_main == NULL) {
+ archive_set_error(&a->archive, ENOMEM,
+ "Can't allocate ustar data");
+ return(ARCHIVE_FATAL);
+ }
+ if (entry != entry_main)
+ entry = entry_main;
+ else
+ entry_main = NULL;
+#else
+ entry_main = NULL;
+#endif
+
+ ret = archive_entry_pathname_l(entry, &path, &len, sconv);
+ if (ret != 0) {
+ if (errno == ENOMEM) {
+ archive_set_error(&a->archive, ENOMEM,
+ "Can't allocate memory for Pathname");
+ ret_final = ARCHIVE_FATAL;
+ goto exit_write_header;
+ }
+ archive_set_error(&a->archive, ARCHIVE_ERRNO_FILE_FORMAT,
+ "Can't translate pathname '%s' to %s",
+ archive_entry_pathname(entry),
+ archive_string_conversion_charset_name(sconv));
+ ret_final = ARCHIVE_WARN;
+ }
+ /* Include trailing null */
+ pathlength = (int)len + 1;
+
+ h.h_magic = la_swap16(070707);
+ h.h_dev = la_swap16(archive_entry_dev(entry));
+
+ ino = synthesize_ino_value(cpio, entry);
+ if (ino < 0) {
+ archive_set_error(&a->archive, ENOMEM,
+ "No memory for ino translation table");
+ ret_final = ARCHIVE_FATAL;
+ goto exit_write_header;
+ } else if (ino > 077777) {
+ archive_set_error(&a->archive, ERANGE,
+ "Too many files for this cpio format");
+ ret_final = ARCHIVE_FATAL;
+ goto exit_write_header;
+ }
+ h.h_ino = la_swap16((uint16_t)ino);
+
+ h.h_mode = archive_entry_mode(entry);
+ if (((h.h_mode & AE_IFMT) == AE_IFSOCK) || ((h.h_mode & AE_IFMT) == AE_IFIFO)) {
+ archive_set_error(&a->archive, EINVAL,
+ "sockets and fifos cannot be represented in the binary cpio formats");
+ ret_final = ARCHIVE_FATAL;
+ goto exit_write_header;
+ }
+ if (a->archive.archive_format == ARCHIVE_FORMAT_CPIO_PWB) {
+ if ((h.h_mode & AE_IFMT) == AE_IFLNK) {
+ archive_set_error(&a->archive, EINVAL,
+ "symbolic links cannot be represented in the PWB cpio format");
+ ret_final = ARCHIVE_FATAL;
+ goto exit_write_header;
+ }
+ /* we could turn off AE_IFREG here, but it does no harm, */
+ /* and allows v7 cpio to read the entry without confusion */
+ }
+ h.h_mode = la_swap16(h.h_mode);
+
+ h.h_uid = la_swap16((uint16_t)archive_entry_uid(entry));
+ h.h_gid = la_swap16((uint16_t)archive_entry_gid(entry));
+ h.h_nlink = la_swap16((uint16_t)archive_entry_nlink(entry));
+
+ if (archive_entry_filetype(entry) == AE_IFBLK
+ || archive_entry_filetype(entry) == AE_IFCHR)
+ h.h_majmin = la_swap16(archive_entry_rdev(entry));
+ else
+ h.h_majmin = 0;
+
+ h.h_mtime = la_swap32((uint32_t)archive_entry_mtime(entry));
+ h.h_namesize = la_swap16(pathlength);
+
+ /* Non-regular files don't store bodies. */
+ if (archive_entry_filetype(entry) != AE_IFREG)
+ archive_entry_set_size(entry, 0);
+
+ /* Symlinks get the link written as the body of the entry. */
+ ret = archive_entry_symlink_l(entry, &p, &len, sconv);
+ if (ret != 0) {
+ if (errno == ENOMEM) {
+ archive_set_error(&a->archive, ENOMEM,
+ "Can't allocate memory for Linkname");
+ ret_final = ARCHIVE_FATAL;
+ goto exit_write_header;
+ }
+ archive_set_error(&a->archive, ARCHIVE_ERRNO_FILE_FORMAT,
+ "Can't translate linkname '%s' to %s",
+ archive_entry_symlink(entry),
+ archive_string_conversion_charset_name(sconv));
+ ret_final = ARCHIVE_WARN;
+ }
+
+ if (len > 0 && p != NULL && *p != '\0') {
+ if (a->archive.archive_format == ARCHIVE_FORMAT_CPIO_PWB) {
+ archive_set_error(&a->archive, EINVAL,
+ "symlinks are not supported by UNIX V6 or by PWB cpio");
+ ret_final = ARCHIVE_FATAL;
+ goto exit_write_header;
+ }
+ h.h_filesize = la_swap32((uint32_t)strlen(p)); /* symlink */
+ } else {
+ if ((a->archive.archive_format == ARCHIVE_FORMAT_CPIO_PWB) &&
+ (archive_entry_size(entry) > 256*256*256-1)) {
+ archive_set_error(&a->archive, ERANGE,
+ "File is too large for PWB binary cpio format.");
+ ret_final = ARCHIVE_FAILED;
+ goto exit_write_header;
+ } else if (archive_entry_size(entry) > INT32_MAX) {
+ archive_set_error(&a->archive, ERANGE,
+ "File is too large for binary cpio format.");
+ ret_final = ARCHIVE_FAILED;
+ goto exit_write_header;
+ }
+ h.h_filesize = la_swap32((uint32_t)archive_entry_size(entry)); /* file */
+ }
+
+ ret = __archive_write_output(a, &h, HSIZE);
+ if (ret != ARCHIVE_OK) {
+ ret_final = ARCHIVE_FATAL;
+ goto exit_write_header;
+ }
+
+ ret = __archive_write_output(a, path, pathlength);
+ if ((ret == ARCHIVE_OK) && ((pathlength % 2) != 0))
+ ret = __archive_write_nulls(a, 1);
+ if (ret != ARCHIVE_OK) {
+ ret_final = ARCHIVE_FATAL;
+ goto exit_write_header;
+ }
+
+ cpio->entry_bytes_remaining = archive_entry_size(entry);
+ if ((cpio->entry_bytes_remaining % 2) != 0)
+ cpio->entry_bytes_remaining++;
+
+ /* Write the symlink now. */
+ if (p != NULL && *p != '\0') {
+ ret = __archive_write_output(a, p, strlen(p));
+ if ((ret == ARCHIVE_OK) && ((strlen(p) % 2) != 0))
+ ret = __archive_write_nulls(a, 1);
+ if (ret != ARCHIVE_OK) {
+ ret_final = ARCHIVE_FATAL;
+ goto exit_write_header;
+ }
+ }
+
+exit_write_header:
+ archive_entry_free(entry_main);
+ return (ret_final);
+}
+
+static ssize_t
+archive_write_binary_data(struct archive_write *a, const void *buff, size_t s)
+{
+ struct cpio *cpio;
+ int ret;
+
+ cpio = (struct cpio *)a->format_data;
+ if (s > cpio->entry_bytes_remaining)
+ s = (size_t)cpio->entry_bytes_remaining;
+
+ ret = __archive_write_output(a, buff, s);
+ cpio->entry_bytes_remaining -= s;
+ if (ret >= 0)
+ return (s);
+ else
+ return (ret);
+}
+
+static int
+archive_write_binary_close(struct archive_write *a)
+{
+ int er;
+ struct archive_entry *trailer;
+
+ trailer = archive_entry_new2(NULL);
+ /* nlink = 1 here for GNU cpio compat. */
+ archive_entry_set_nlink(trailer, 1);
+ archive_entry_set_size(trailer, 0);
+ archive_entry_set_pathname(trailer, "TRAILER!!!");
+ er = write_header(a, trailer);
+ archive_entry_free(trailer);
+ return (er);
+}
+
+static int
+archive_write_binary_free(struct archive_write *a)
+{
+ struct cpio *cpio;
+
+ cpio = (struct cpio *)a->format_data;
+ free(cpio->ino_list);
+ free(cpio);
+ a->format_data = NULL;
+ return (ARCHIVE_OK);
+}
+
+static int
+archive_write_binary_finish_entry(struct archive_write *a)
+{
+ struct cpio *cpio;
+
+ cpio = (struct cpio *)a->format_data;
+ return (__archive_write_nulls(a,
+ (size_t)cpio->entry_bytes_remaining));
+}
diff --git a/Utilities/cmlibarchive/libarchive/archive_write_set_format_cpio_odc.c b/Utilities/cmlibarchive/libarchive/archive_write_set_format_cpio_odc.c
new file mode 100644
index 0000000..091925a
--- /dev/null
+++ b/Utilities/cmlibarchive/libarchive/archive_write_set_format_cpio_odc.c
@@ -0,0 +1,500 @@
+/*-
+ * Copyright (c) 2003-2007 Tim Kientzle
+ * Copyright (c) 2011-2012 Michihiro NAKAJIMA
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR(S) ``AS IS'' AND ANY EXPRESS OR
+ * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
+ * IN NO EVENT SHALL THE AUTHOR(S) BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
+ * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
+ * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "archive_platform.h"
+__FBSDID("$FreeBSD: head/lib/libarchive/archive_write_set_format_cpio.c 201170 2009-12-29 06:34:23Z kientzle $");
+
+#ifdef HAVE_ERRNO_H
+#include <errno.h>
+#endif
+#include <stdio.h>
+#ifdef HAVE_STDLIB_H
+#include <stdlib.h>
+#endif
+#ifdef HAVE_STRING_H
+#include <string.h>
+#endif
+
+#include "archive.h"
+#include "archive_entry.h"
+#include "archive_entry_locale.h"
+#include "archive_private.h"
+#include "archive_write_private.h"
+#include "archive_write_set_format_private.h"
+
+static ssize_t archive_write_odc_data(struct archive_write *,
+ const void *buff, size_t s);
+static int archive_write_odc_close(struct archive_write *);
+static int archive_write_odc_free(struct archive_write *);
+static int archive_write_odc_finish_entry(struct archive_write *);
+static int archive_write_odc_header(struct archive_write *,
+ struct archive_entry *);
+static int archive_write_odc_options(struct archive_write *,
+ const char *, const char *);
+static int format_octal(int64_t, void *, int);
+static int64_t format_octal_recursive(int64_t, char *, int);
+static int write_header(struct archive_write *, struct archive_entry *);
+
+struct cpio {
+ uint64_t entry_bytes_remaining;
+
+ int64_t ino_next;
+
+ struct { int64_t old; int new;} *ino_list;
+ size_t ino_list_size;
+ size_t ino_list_next;
+
+ struct archive_string_conv *opt_sconv;
+ struct archive_string_conv *sconv_default;
+ int init_default_conversion;
+};
+
+#define c_magic_offset 0
+#define c_magic_size 6
+#define c_dev_offset 6
+#define c_dev_size 6
+#define c_ino_offset 12
+#define c_ino_size 6
+#define c_mode_offset 18
+#define c_mode_size 6
+#define c_uid_offset 24
+#define c_uid_size 6
+#define c_gid_offset 30
+#define c_gid_size 6
+#define c_nlink_offset 36
+#define c_nlink_size 6
+#define c_rdev_offset 42
+#define c_rdev_size 6
+#define c_mtime_offset 48
+#define c_mtime_size 11
+#define c_namesize_offset 59
+#define c_namesize_size 6
+#define c_filesize_offset 65
+#define c_filesize_size 11
+
+/*
+ * Set output format to 'cpio' format.
+ */
+int
+archive_write_set_format_cpio_odc(struct archive *_a)
+{
+ struct archive_write *a = (struct archive_write *)_a;
+ struct cpio *cpio;
+
+ archive_check_magic(_a, ARCHIVE_WRITE_MAGIC,
+ ARCHIVE_STATE_NEW, "archive_write_set_format_cpio_odc");
+
+ /* If someone else was already registered, unregister them. */
+ if (a->format_free != NULL)
+ (a->format_free)(a);
+
+ cpio = (struct cpio *)calloc(1, sizeof(*cpio));
+ if (cpio == NULL) {
+ archive_set_error(&a->archive, ENOMEM, "Can't allocate cpio data");
+ return (ARCHIVE_FATAL);
+ }
+ a->format_data = cpio;
+ a->format_name = "cpio";
+ a->format_options = archive_write_odc_options;
+ a->format_write_header = archive_write_odc_header;
+ a->format_write_data = archive_write_odc_data;
+ a->format_finish_entry = archive_write_odc_finish_entry;
+ a->format_close = archive_write_odc_close;
+ a->format_free = archive_write_odc_free;
+ a->archive.archive_format = ARCHIVE_FORMAT_CPIO_POSIX;
+ a->archive.archive_format_name = "POSIX cpio";
+ return (ARCHIVE_OK);
+}
+
+static int
+archive_write_odc_options(struct archive_write *a, const char *key,
+ const char *val)
+{
+ struct cpio *cpio = (struct cpio *)a->format_data;
+ int ret = ARCHIVE_FAILED;
+
+ if (strcmp(key, "hdrcharset") == 0) {
+ if (val == NULL || val[0] == 0)
+ archive_set_error(&a->archive, ARCHIVE_ERRNO_MISC,
+ "%s: hdrcharset option needs a character-set name",
+ a->format_name);
+ else {
+ cpio->opt_sconv = archive_string_conversion_to_charset(
+ &a->archive, val, 0);
+ if (cpio->opt_sconv != NULL)
+ ret = ARCHIVE_OK;
+ else
+ ret = ARCHIVE_FATAL;
+ }
+ return (ret);
+ }
+
+ /* Note: The "warn" return is just to inform the options
+ * supervisor that we didn't handle it. It will generate
+ * a suitable error if no one used this option. */
+ return (ARCHIVE_WARN);
+}
+
+/*
+ * Ino values are as long as 64 bits on some systems; cpio format
+ * only allows 18 bits and relies on the ino values to identify hardlinked
+ * files. So, we can't merely "hash" the ino numbers since collisions
+ * would corrupt the archive. Instead, we generate synthetic ino values
+ * to store in the archive and maintain a map of original ino values to
+ * synthetic ones so we can preserve hardlink information.
+ *
+ * TODO: Make this more efficient. It's not as bad as it looks (most
+ * files don't have any hardlinks and we don't do any work here for those),
+ * but it wouldn't be hard to do better.
+ *
+ * TODO: Work with dev/ino pairs here instead of just ino values.
+ */
+static int
+synthesize_ino_value(struct cpio *cpio, struct archive_entry *entry)
+{
+ int64_t ino = archive_entry_ino64(entry);
+ int ino_new;
+ size_t i;
+
+ /*
+ * If no index number was given, don't assign one. In
+ * particular, this handles the end-of-archive marker
+ * correctly by giving it a zero index value. (This is also
+ * why we start our synthetic index numbers with one below.)
+ */
+ if (ino == 0)
+ return (0);
+
+ /* Don't store a mapping if we don't need to. */
+ if (archive_entry_nlink(entry) < 2) {
+ return (int)(++cpio->ino_next);
+ }
+
+ /* Look up old ino; if we have it, this is a hardlink
+ * and we reuse the same value. */
+ for (i = 0; i < cpio->ino_list_next; ++i) {
+ if (cpio->ino_list[i].old == ino)
+ return (cpio->ino_list[i].new);
+ }
+
+ /* Assign a new index number. */
+ ino_new = (int)(++cpio->ino_next);
+
+ /* Ensure space for the new mapping. */
+ if (cpio->ino_list_size <= cpio->ino_list_next) {
+ size_t newsize = cpio->ino_list_size < 512
+ ? 512 : cpio->ino_list_size * 2;
+ void *newlist = realloc(cpio->ino_list,
+ sizeof(cpio->ino_list[0]) * newsize);
+ if (newlist == NULL)
+ return (-1);
+
+ cpio->ino_list_size = newsize;
+ cpio->ino_list = newlist;
+ }
+
+ /* Record and return the new value. */
+ cpio->ino_list[cpio->ino_list_next].old = ino;
+ cpio->ino_list[cpio->ino_list_next].new = ino_new;
+ ++cpio->ino_list_next;
+ return (ino_new);
+}
+
+
+static struct archive_string_conv *
+get_sconv(struct archive_write *a)
+{
+ struct cpio *cpio;
+ struct archive_string_conv *sconv;
+
+ cpio = (struct cpio *)a->format_data;
+ sconv = cpio->opt_sconv;
+ if (sconv == NULL) {
+ if (!cpio->init_default_conversion) {
+ cpio->sconv_default =
+ archive_string_default_conversion_for_write(
+ &(a->archive));
+ cpio->init_default_conversion = 1;
+ }
+ sconv = cpio->sconv_default;
+ }
+ return (sconv);
+}
+
+static int
+archive_write_odc_header(struct archive_write *a, struct archive_entry *entry)
+{
+ const char *path;
+ size_t len;
+
+ if (archive_entry_filetype(entry) == 0 && archive_entry_hardlink(entry) == NULL) {
+ archive_set_error(&a->archive, -1, "Filetype required");
+ return (ARCHIVE_FAILED);
+ }
+
+ if (archive_entry_pathname_l(entry, &path, &len, get_sconv(a)) != 0
+ && errno == ENOMEM) {
+ archive_set_error(&a->archive, ENOMEM,
+ "Can't allocate memory for Pathname");
+ return (ARCHIVE_FATAL);
+ }
+ if (len == 0 || path == NULL || path[0] == '\0') {
+ archive_set_error(&a->archive, -1, "Pathname required");
+ return (ARCHIVE_FAILED);
+ }
+
+ if (!archive_entry_size_is_set(entry) || archive_entry_size(entry) < 0) {
+ archive_set_error(&a->archive, -1, "Size required");
+ return (ARCHIVE_FAILED);
+ }
+ return write_header(a, entry);
+}
+
+static int
+write_header(struct archive_write *a, struct archive_entry *entry)
+{
+ struct cpio *cpio;
+ const char *p, *path;
+ int pathlength, ret, ret_final;
+ int64_t ino;
+ char h[76];
+ struct archive_string_conv *sconv;
+ struct archive_entry *entry_main;
+ size_t len;
+
+ cpio = (struct cpio *)a->format_data;
+ ret_final = ARCHIVE_OK;
+ sconv = get_sconv(a);
+
+#if defined(_WIN32) && !defined(__CYGWIN__)
+ /* Make sure the path separators in pathname, hardlink and symlink
+ * are all slash '/', not the Windows path separator '\'. */
+ entry_main = __la_win_entry_in_posix_pathseparator(entry);
+ if (entry_main == NULL) {
+ archive_set_error(&a->archive, ENOMEM,
+ "Can't allocate ustar data");
+ return(ARCHIVE_FATAL);
+ }
+ if (entry != entry_main)
+ entry = entry_main;
+ else
+ entry_main = NULL;
+#else
+ entry_main = NULL;
+#endif
+
+ ret = archive_entry_pathname_l(entry, &path, &len, sconv);
+ if (ret != 0) {
+ if (errno == ENOMEM) {
+ archive_set_error(&a->archive, ENOMEM,
+ "Can't allocate memory for Pathname");
+ ret_final = ARCHIVE_FATAL;
+ goto exit_write_header;
+ }
+ archive_set_error(&a->archive, ARCHIVE_ERRNO_FILE_FORMAT,
+ "Can't translate pathname '%s' to %s",
+ archive_entry_pathname(entry),
+ archive_string_conversion_charset_name(sconv));
+ ret_final = ARCHIVE_WARN;
+ }
+ /* Include trailing null. */
+ pathlength = (int)len + 1;
+
+ memset(h, 0, sizeof(h));
+ format_octal(070707, h + c_magic_offset, c_magic_size);
+ format_octal(archive_entry_dev(entry), h + c_dev_offset, c_dev_size);
+
+ ino = synthesize_ino_value(cpio, entry);
+ if (ino < 0) {
+ archive_set_error(&a->archive, ENOMEM,
+ "No memory for ino translation table");
+ ret_final = ARCHIVE_FATAL;
+ goto exit_write_header;
+ } else if (ino > 0777777) {
+ archive_set_error(&a->archive, ERANGE,
+ "Too many files for this cpio format");
+ ret_final = ARCHIVE_FATAL;
+ goto exit_write_header;
+ }
+ format_octal(ino & 0777777, h + c_ino_offset, c_ino_size);
+
+ /* TODO: Set ret_final to ARCHIVE_WARN if any of these overflow. */
+ format_octal(archive_entry_mode(entry), h + c_mode_offset, c_mode_size);
+ format_octal(archive_entry_uid(entry), h + c_uid_offset, c_uid_size);
+ format_octal(archive_entry_gid(entry), h + c_gid_offset, c_gid_size);
+ format_octal(archive_entry_nlink(entry), h + c_nlink_offset, c_nlink_size);
+ if (archive_entry_filetype(entry) == AE_IFBLK
+ || archive_entry_filetype(entry) == AE_IFCHR)
+ format_octal(archive_entry_rdev(entry), h + c_rdev_offset, c_rdev_size);
+ else
+ format_octal(0, h + c_rdev_offset, c_rdev_size);
+ format_octal(archive_entry_mtime(entry), h + c_mtime_offset, c_mtime_size);
+ format_octal(pathlength, h + c_namesize_offset, c_namesize_size);
+
+ /* Non-regular files don't store bodies. */
+ if (archive_entry_filetype(entry) != AE_IFREG)
+ archive_entry_set_size(entry, 0);
+
+ /* Symlinks get the link written as the body of the entry. */
+ ret = archive_entry_symlink_l(entry, &p, &len, sconv);
+ if (ret != 0) {
+ if (errno == ENOMEM) {
+ archive_set_error(&a->archive, ENOMEM,
+ "Can't allocate memory for Linkname");
+ ret_final = ARCHIVE_FATAL;
+ goto exit_write_header;
+ }
+ archive_set_error(&a->archive, ARCHIVE_ERRNO_FILE_FORMAT,
+ "Can't translate linkname '%s' to %s",
+ archive_entry_symlink(entry),
+ archive_string_conversion_charset_name(sconv));
+ ret_final = ARCHIVE_WARN;
+ }
+ if (len > 0 && p != NULL && *p != '\0')
+ ret = format_octal(strlen(p), h + c_filesize_offset,
+ c_filesize_size);
+ else
+ ret = format_octal(archive_entry_size(entry),
+ h + c_filesize_offset, c_filesize_size);
+ if (ret) {
+ archive_set_error(&a->archive, ERANGE,
+ "File is too large for cpio format.");
+ ret_final = ARCHIVE_FAILED;
+ goto exit_write_header;
+ }
+
+ ret = __archive_write_output(a, h, sizeof(h));
+ if (ret != ARCHIVE_OK) {
+ ret_final = ARCHIVE_FATAL;
+ goto exit_write_header;
+ }
+
+ ret = __archive_write_output(a, path, pathlength);
+ if (ret != ARCHIVE_OK) {
+ ret_final = ARCHIVE_FATAL;
+ goto exit_write_header;
+ }
+
+ cpio->entry_bytes_remaining = archive_entry_size(entry);
+
+ /* Write the symlink now. */
+ if (p != NULL && *p != '\0') {
+ ret = __archive_write_output(a, p, strlen(p));
+ if (ret != ARCHIVE_OK) {
+ ret_final = ARCHIVE_FATAL;
+ goto exit_write_header;
+ }
+ }
+exit_write_header:
+ archive_entry_free(entry_main);
+ return (ret_final);
+}
+
+static ssize_t
+archive_write_odc_data(struct archive_write *a, const void *buff, size_t s)
+{
+ struct cpio *cpio;
+ int ret;
+
+ cpio = (struct cpio *)a->format_data;
+ if (s > cpio->entry_bytes_remaining)
+ s = (size_t)cpio->entry_bytes_remaining;
+
+ ret = __archive_write_output(a, buff, s);
+ cpio->entry_bytes_remaining -= s;
+ if (ret >= 0)
+ return (s);
+ else
+ return (ret);
+}
+
+/*
+ * Format a number into the specified field.
+ */
+static int
+format_octal(int64_t v, void *p, int digits)
+{
+ int64_t max;
+ int ret;
+
+ max = (((int64_t)1) << (digits * 3)) - 1;
+ if (v >= 0 && v <= max) {
+ format_octal_recursive(v, (char *)p, digits);
+ ret = 0;
+ } else {
+ format_octal_recursive(max, (char *)p, digits);
+ ret = -1;
+ }
+ return (ret);
+}
+
+static int64_t
+format_octal_recursive(int64_t v, char *p, int s)
+{
+ if (s == 0)
+ return (v);
+ v = format_octal_recursive(v, p+1, s-1);
+ *p = '0' + ((char)v & 7);
+ return (v >> 3);
+}
+
+static int
+archive_write_odc_close(struct archive_write *a)
+{
+ int er;
+ struct archive_entry *trailer;
+
+ trailer = archive_entry_new2(NULL);
+ /* nlink = 1 here for GNU cpio compat. */
+ archive_entry_set_nlink(trailer, 1);
+ archive_entry_set_size(trailer, 0);
+ archive_entry_set_pathname(trailer, "TRAILER!!!");
+ er = write_header(a, trailer);
+ archive_entry_free(trailer);
+ return (er);
+}
+
+static int
+archive_write_odc_free(struct archive_write *a)
+{
+ struct cpio *cpio;
+
+ cpio = (struct cpio *)a->format_data;
+ free(cpio->ino_list);
+ free(cpio);
+ a->format_data = NULL;
+ return (ARCHIVE_OK);
+}
+
+static int
+archive_write_odc_finish_entry(struct archive_write *a)
+{
+ struct cpio *cpio;
+
+ cpio = (struct cpio *)a->format_data;
+ return (__archive_write_nulls(a,
+ (size_t)cpio->entry_bytes_remaining));
+}
diff --git a/Utilities/cmlibarchive/libarchive/archive_write_set_format_iso9660.c b/Utilities/cmlibarchive/libarchive/archive_write_set_format_iso9660.c
index 68e3fe3..3190b46 100644
--- a/Utilities/cmlibarchive/libarchive/archive_write_set_format_iso9660.c
+++ b/Utilities/cmlibarchive/libarchive/archive_write_set_format_iso9660.c
@@ -6802,6 +6802,7 @@
* This comparing rule is according to ISO9660 Standard 6.9.1
*/
static int
+__LA_LIBC_CC
_compare_path_table(const void *v1, const void *v2)
{
const struct isoent *p1, *p2;
@@ -6844,6 +6845,7 @@
}
static int
+__LA_LIBC_CC
_compare_path_table_joliet(const void *v1, const void *v2)
{
const struct isoent *p1, *p2;
diff --git a/Utilities/cmlibarchive/libarchive/archive_write_set_format_pax.c b/Utilities/cmlibarchive/libarchive/archive_write_set_format_pax.c
index a2b2710..5291149 100644
--- a/Utilities/cmlibarchive/libarchive/archive_write_set_format_pax.c
+++ b/Utilities/cmlibarchive/libarchive/archive_write_set_format_pax.c
@@ -1028,10 +1028,8 @@
archive_string_init(&entry_name);
archive_strcpy(&entry_name, archive_entry_pathname(entry_main));
- /* If file size is too large, add 'size' to pax extended attrs. */
+ /* If file size is too large, we need pax extended attrs. */
if (archive_entry_size(entry_main) >= (((int64_t)1) << 33)) {
- add_pax_attr_int(&(pax->pax_header), "size",
- archive_entry_size(entry_main));
need_extension = 1;
}
@@ -1347,6 +1345,12 @@
mapsize + pax->sparse_map_padding + sparse_total);
}
+ /* If file size is too large, add 'size' to pax extended attrs. */
+ if (archive_entry_size(entry_main) >= (((int64_t)1) << 33)) {
+ add_pax_attr_int(&(pax->pax_header), "size",
+ archive_entry_size(entry_main));
+ }
+
/* Format 'ustar' header for main entry.
*
* The trouble with file size: If the reader can't understand
diff --git a/Utilities/cmlibarchive/libarchive/archive_write_set_format_zip.c b/Utilities/cmlibarchive/libarchive/archive_write_set_format_zip.c
index 66a1f84..530e1e8 100644
--- a/Utilities/cmlibarchive/libarchive/archive_write_set_format_zip.c
+++ b/Utilities/cmlibarchive/libarchive/archive_write_set_format_zip.c
@@ -740,12 +740,16 @@
/* We may know the size, but never the CRC. */
zip->entry_flags |= ZIP_ENTRY_FLAG_LENGTH_AT_END;
} else {
- /* We don't know the size. In this case, we prefer
- * deflate (it has a clear end-of-data marker which
- * makes length-at-end more reliable) and will
- * enable Zip64 extensions unless we're told not to.
+ /* We don't know the size. Use the default
+ * compression unless specified otherwise.
+ * We enable Zip64 extensions unless we're told not to.
*/
- zip->entry_compression = COMPRESSION_DEFAULT;
+
+ zip->entry_compression = zip->requested_compression;
+ if(zip->entry_compression == COMPRESSION_UNSPECIFIED){
+ zip->entry_compression = COMPRESSION_DEFAULT;
+ }
+
zip->entry_flags |= ZIP_ENTRY_FLAG_LENGTH_AT_END;
if ((zip->flags & ZIP_FLAG_AVOID_ZIP64) == 0) {
zip->entry_uses_zip64 = 1;
diff --git a/Utilities/cmlibarchive/libarchive/archive_write_set_options.3 b/Utilities/cmlibarchive/libarchive/archive_write_set_options.3
index d4a52e3..dd57358 100644
--- a/Utilities/cmlibarchive/libarchive/archive_write_set_options.3
+++ b/Utilities/cmlibarchive/libarchive/archive_write_set_options.3
@@ -279,7 +279,7 @@
The interpretation of the compression level depends on the chosen
compression method.
.El
-.It Format cpio
+.It Format bin
.Bl -tag -compact -width indent
.It Cm hdrcharset
The value is used as a character set name that will be
@@ -519,6 +519,18 @@
The value is used as a character set name that will be
used when translating file names.
.El
+.It Format odc
+.Bl -tag -compact -width indent
+.It Cm hdrcharset
+The value is used as a character set name that will be
+used when translating file names.
+.El
+.It Format pwb
+.Bl -tag -compact -width indent
+.It Cm hdrcharset
+The value is used as a character set name that will be
+used when translating file names.
+.El
.It Format pax
.Bl -tag -compact -width indent
.It Cm hdrcharset
diff --git a/Utilities/cmlibarchive/libarchive/config_freebsd.h b/Utilities/cmlibarchive/libarchive/config_freebsd.h
index a484618..758621c 100644
--- a/Utilities/cmlibarchive/libarchive/config_freebsd.h
+++ b/Utilities/cmlibarchive/libarchive/config_freebsd.h
@@ -138,6 +138,7 @@
#define HAVE_LIBZ 1
#define HAVE_LIMITS_H 1
#define HAVE_LINK 1
+#define HAVE_LINKAT 1
#define HAVE_LOCALE_H 1
#define HAVE_LOCALTIME_R 1
#define HAVE_LONG_LONG_INT 1
@@ -235,6 +236,14 @@
#define HAVE_ZLIB_H 1
#define TIME_WITH_SYS_TIME 1
+#if __FreeBSD_version >= 800505
+#define HAVE_LIBLZMA 1
+#define HAVE_LZMA_H 1
+#if __FreeBSD_version >= 1002504
+#define HAVE_LZMA_STREAM_ENCODER_MT 1
+#endif
+#endif
+
#if __FreeBSD_version >= 1100056
#define HAVE_FUTIMENS 1
#define HAVE_UTIMENSAT 1
diff --git a/Utilities/cmlibarchive/libarchive/cpio.5 b/Utilities/cmlibarchive/libarchive/cpio.5
index a91f0c5..837a456 100644
--- a/Utilities/cmlibarchive/libarchive/cpio.5
+++ b/Utilities/cmlibarchive/libarchive/cpio.5
@@ -56,40 +56,44 @@
the pathname
.Dq TRAILER!!! .
.Ss PWB format
-XXX Any documentation of the original PWB/UNIX 1.0 format? XXX
-.Ss Old Binary Format
-The old binary
+The PWB binary
.Nm
-format stores numbers as 2-byte and 4-byte binary values.
+format is the original format, when cpio was introduced as part of the
+Programmer's Work Bench system, a variant of 6th Edition UNIX. It
+stores numbers as 2-byte and 4-byte binary values.
Each entry begins with a header in the following format:
+.Pp
.Bd -literal -offset indent
-struct header_old_cpio {
- unsigned short c_magic;
- unsigned short c_dev;
- unsigned short c_ino;
- unsigned short c_mode;
- unsigned short c_uid;
- unsigned short c_gid;
- unsigned short c_nlink;
- unsigned short c_rdev;
- unsigned short c_mtime[2];
- unsigned short c_namesize;
- unsigned short c_filesize[2];
+struct header_pwb_cpio {
+ short h_magic;
+ short h_dev;
+ short h_ino;
+ short h_mode;
+ short h_uid;
+ short h_gid;
+ short h_nlink;
+ short h_majmin;
+ long h_mtime;
+ short h_namesize;
+ long h_filesize;
};
.Ed
.Pp
The
-.Va unsigned short
-fields here are 16-bit integer values; the
-.Va unsigned int
-fields are 32-bit integer values.
-The fields are as follows
+.Va short
+fields here are 16-bit integer values, while the
+.Va long
+fields are 32 bit integers. Since PWB UNIX, like the 6th Edition UNIX
+it was based on, only ran on PDP-11 computers, they
+are in PDP-endian format, which has little-endian shorts, and
+big-endian longs. That is, the long integer whose hexadecimal
+representation is 0x12345678 would be stored in four successive bytes
+as 0x34, 0x12, 0x78, 0x56.
+The fields are as follows:
.Bl -tag -width indent
-.It Va magic
+.It Va h_magic
The integer value octal 070707.
-This value can be used to determine whether this archive is
-written with little-endian or big-endian integers.
-.It Va dev , Va ino
+.It Va h_dev , Va h_ino
The device and inode numbers from the disk.
These are used by programs that read
.Nm
@@ -97,9 +101,94 @@
Programs that synthesize
.Nm
archives should be careful to set these to distinct values for each entry.
-.It Va mode
-The mode specifies both the regular permissions and the file type.
-It consists of several bit fields as follows:
+.It Va h_mode
+The mode specifies both the regular permissions and the file type, and
+it also holds a couple of bits that are irrelevant to the cpio format,
+because the field is actually a raw copy of the mode field in the inode
+representing the file. These are the IALLOC flag, which shows that
+the inode entry is in use, and the ILARG flag, which shows that the
+file it represents is large enough to have indirect blocks pointers in
+the inode.
+The mode is decoded as follows:
+.Pp
+.Bl -tag -width "MMMMMMM" -compact
+.It 0100000
+IALLOC flag - irrelevant to cpio.
+.It 0060000
+This masks the file type bits.
+.It 0040000
+File type value for directories.
+.It 0020000
+File type value for character special devices.
+.It 0060000
+File type value for block special devices.
+.It 0010000
+ILARG flag - irrelevant to cpio.
+.It 0004000
+SUID bit.
+.It 0002000
+SGID bit.
+.It 0001000
+Sticky bit.
+.It 0000777
+The lower 9 bits specify read/write/execute permissions
+for world, group, and user following standard POSIX conventions.
+.El
+.It Va h_uid , Va h_gid
+The numeric user id and group id of the owner.
+.It Va h_nlink
+The number of links to this file.
+Directories always have a value of at least two here.
+Note that hardlinked files include file data with every copy in the archive.
+.It Va h_majmin
+For block special and character special entries,
+this field contains the associated device number, with the major
+number in the high byte, and the minor number in the low byte.
+For all other entry types, it should be set to zero by writers
+and ignored by readers.
+.It Va h_mtime
+Modification time of the file, indicated as the number
+of seconds since the start of the epoch,
+00:00:00 UTC January 1, 1970.
+.It Va h_namesize
+The number of bytes in the pathname that follows the header.
+This count includes the trailing NUL byte.
+.It Va h_filesize
+The size of the file. Note that this archive format is limited to 16
+megabyte file sizes, because PWB UNIX, like 6th Edition, only used
+an unsigned 24 bit integer for the file size internally.
+.El
+.Pp
+The pathname immediately follows the fixed header.
+If
+.Cm h_namesize
+is odd, an additional NUL byte is added after the pathname.
+The file data is then appended, again with an additional NUL
+appended if needed to get the next header at an even offset.
+.Pp
+Hardlinked files are not given special treatment;
+the full file contents are included with each copy of the
+file.
+.Ss New Binary Format
+The new binary
+.Nm
+format showed up when cpio was adopted into late 7th Edition UNIX.
+It is exactly like the PWB binary format, described above, except for
+three changes:
+.Pp
+First, UNIX now ran on more than one hardware type, so the endianness
+of 16 bit integers must be determined by observing the magic number at
+the start of the header. The 32 bit integers are still always stored
+with the most significant word first, though, so each of those two, in
+the struct shown above, was stored as an array of two 16 bit integers,
+in the traditional order. Those 16 bit integers, like all the others
+in the struct, were accessed using a macro that byte swapped them if
+necessary.
+.Pp
+Next, 7th Edition had more file types to store, and the IALLOC and ILARG
+flag bits were re-purposed to accommodate these. The revised use of the
+various bits is as follows:
+.Pp
.Bl -tag -width "MMMMMMM" -compact
.It 0170000
This masks the file type bits.
@@ -124,51 +213,26 @@
SGID bit.
.It 0001000
Sticky bit.
-On some systems, this modifies the behavior of executables and/or directories.
.It 0000777
The lower 9 bits specify read/write/execute permissions
for world, group, and user following standard POSIX conventions.
.El
-.It Va uid , Va gid
-The numeric user id and group id of the owner.
-.It Va nlink
-The number of links to this file.
-Directories always have a value of at least two here.
-Note that hardlinked files include file data with every copy in the archive.
-.It Va rdev
-For block special and character special entries,
-this field contains the associated device number.
-For all other entry types, it should be set to zero by writers
-and ignored by readers.
-.It Va mtime
-Modification time of the file, indicated as the number
-of seconds since the start of the epoch,
-00:00:00 UTC January 1, 1970.
-The four-byte integer is stored with the most-significant 16 bits first
-followed by the least-significant 16 bits.
-Each of the two 16 bit values are stored in machine-native byte order.
-.It Va namesize
-The number of bytes in the pathname that follows the header.
-This count includes the trailing NUL byte.
-.It Va filesize
-The size of the file.
-Note that this archive format is limited to
-four gigabyte file sizes.
-See
-.Va mtime
-above for a description of the storage of four-byte integers.
-.El
.Pp
-The pathname immediately follows the fixed header.
-If the
-.Cm namesize
-is odd, an additional NUL byte is added after the pathname.
-The file data is then appended, padded with NUL
-bytes to an even length.
+Finally, the file size field now represents a signed 32 bit integer in
+the underlying file system, so the maximum file size has increased to
+2 gigabytes.
.Pp
-Hardlinked files are not given special treatment;
-the full file contents are included with each copy of the
-file.
+Note that there is no obvious way to tell which of the two binary
+formats an archive uses, other than to see which one makes more
+sense. The typical error scenario is that a PWB format archive
+unpacked as if it were in the new format will create named sockets
+instead of directories, and then fail to unpack files that should
+go in those directories. Running
+.Va bsdcpio -itv
+on an unknown archive will make it obvious which it is: if it's
+PWB format, directories will be listed with an 's' instead of
+a 'd' as the first character of the mode string, and the larger
+files will have a '?' in that position.
.Ss Portable ASCII Format
.St -susv2
standardized an ASCII variant that is portable across all
@@ -180,6 +244,7 @@
format.
It stores the same numeric fields as the old binary format, but
represents them as 6-character or 11-character octal values.
+.Pp
.Bd -literal -offset indent
struct cpio_odc_header {
char c_magic[6];
@@ -196,9 +261,9 @@
};
.Ed
.Pp
-The fields are identical to those in the old binary format.
+The fields are identical to those in the new binary format.
The name and file body follow the fixed header.
-Unlike the old binary format, there is no additional padding
+Unlike the binary formats, there is no additional padding
after the pathname or file contents.
If the files being archived are themselves entirely ASCII, then
the resulting archive will be entirely ASCII, except for the
@@ -207,6 +272,7 @@
The "new" ASCII format uses 8-byte hexadecimal fields for
all numbers and separates device numbers into separate fields
for major and minor numbers.
+.Pp
.Bd -literal -offset indent
struct cpio_newc_header {
char c_magic[6];
@@ -227,7 +293,7 @@
.Ed
.Pp
Except as specified below, the fields here match those specified
-for the old binary format above.
+for the new binary format above.
.Bl -tag -width indent
.It Va magic
The string
@@ -288,9 +354,9 @@
It appeared in 1977 as part of PWB/UNIX 1.0, the
.Dq Programmer's Work Bench
derived from
-.At v6
+.At 6th Edition UNIX
that was used internally at AT&T.
-Both the old binary and old character formats were in use
+Both the new binary and old character formats were in use
by 1980, according to the System III source released
by SCO under their
.Dq Ancient Unix
@@ -304,9 +370,9 @@
format is mis-named, as it uses a simple checksum and
not a cyclic redundancy check.
.Pp
-The old binary format is limited to 16 bits for user id,
-group id, device, and inode numbers.
-It is limited to 4 gigabyte file sizes.
+The binary formats are limited to 16 bits for user id, group id,
+device, and inode numbers. They are limited to 16 megabyte and 2
+gigabyte file sizes for the older and newer variants, respectively.
.Pp
The old ASCII format is limited to 18 bits for
the user id, group id, device, and inode numbers.
diff --git a/Utilities/cmlibarchive/libarchive/filter_fork_windows.c b/Utilities/cmlibarchive/libarchive/filter_fork_windows.c
index 8d11179..0b96397 100644
--- a/Utilities/cmlibarchive/libarchive/filter_fork_windows.c
+++ b/Utilities/cmlibarchive/libarchive/filter_fork_windows.c
@@ -31,6 +31,43 @@
#include "filter_fork.h"
+/* There are some editions of Windows ("nano server," for example) that
+ * do not host user32.dll. If we want to keep running on those editions,
+ * we need to delay-load WaitForInputIdle. */
+static void *
+la_GetFunctionUser32(const char *name)
+{
+ static HINSTANCE lib;
+ static int set;
+ if (!set) {
+ set = 1;
+ lib = LoadLibrary(TEXT("user32.dll"));
+ }
+ if (lib == NULL) {
+ return NULL;
+ }
+ return (void *)GetProcAddress(lib, name);
+}
+
+static int
+la_WaitForInputIdle(HANDLE hProcess, DWORD dwMilliseconds)
+{
+ static DWORD (WINAPI *f)(HANDLE, DWORD);
+ static int set;
+
+ if (!set) {
+ set = 1;
+ f = la_GetFunctionUser32("WaitForInputIdle");
+ }
+
+ if (!f) {
+ /* An inability to wait for input idle is
+ * not _good_, but it is not catastrophic. */
+ return WAIT_FAILED;
+ }
+ return (*f)(hProcess, dwMilliseconds);
+}
+
int
__archive_create_child(const char *cmd, int *child_stdin, int *child_stdout,
HANDLE *out_child)
@@ -149,7 +186,7 @@
if (CreateProcessA(fullpath.s, cmdline.s, NULL, NULL, TRUE, 0,
NULL, NULL, &staInfo, &childInfo) == 0)
goto fail;
- WaitForInputIdle(childInfo.hProcess, INFINITE);
+ la_WaitForInputIdle(childInfo.hProcess, INFINITE);
CloseHandle(childInfo.hProcess);
CloseHandle(childInfo.hThread);
diff --git a/Utilities/cmlibarchive/libarchive/libarchive-formats.5 b/Utilities/cmlibarchive/libarchive/libarchive-formats.5
index 62359dd..5a118ff 100644
--- a/Utilities/cmlibarchive/libarchive/libarchive-formats.5
+++ b/Utilities/cmlibarchive/libarchive/libarchive-formats.5
@@ -201,28 +201,27 @@
.Dq pax interchange
format.
.Ss Cpio Formats
-The libarchive library can read a number of common cpio variants and can write
-.Dq odc
-and
-.Dq newc
-format archives.
-A cpio archive stores each entry as a fixed-size header followed
-by a variable-length filename and variable-length data.
-Unlike the tar format, the cpio format does only minimal padding
-of the header or file data.
-There are several cpio variants, which differ primarily in
-how they store the initial header: some store the values as
-octal or hexadecimal numbers in ASCII, others as binary values of
-varying byte order and length.
+The libarchive library can read and write a number of common cpio
+variants. A cpio archive stores each entry as a fixed-size header
+followed by a variable-length filename and variable-length data.
+Unlike the tar format, the cpio format does only minimal padding of
+the header or file data. There are several cpio variants, which
+differ primarily in how they store the initial header: some store the
+values as octal or hexadecimal numbers in ASCII, others as binary
+values of varying byte order and length.
.Bl -tag -width indent
.It Cm binary
-The libarchive library transparently reads both big-endian and little-endian
-variants of the original binary cpio format.
-This format used 32-bit binary values for file size and mtime,
-and 16-bit binary values for the other fields.
+The libarchive library transparently reads both big-endian and
+little-endian variants of the the two binary cpio formats; the
+original one from PWB/UNIX, and the later, more widely used, variant.
+This format used 32-bit binary values for file size and mtime, and
+16-bit binary values for the other fields. The formats support only
+the file types present in UNIX at the time of their creation. File
+sizes are limited to 24 bits in the PWB format, because of the limits
+of the file system, and to 31 bits in the newer binary format, where
+signed 32 bit longs were used.
.It Cm odc
-The libarchive library can both read and write this
-POSIX-standard format, which is officially known as the
+This is the POSIX standardized format, which is officially known as the
.Dq cpio interchange format
or the
.Dq octet-oriented cpio archive format
diff --git a/Utilities/cmlibarchive/libarchive/libarchive.3 b/Utilities/cmlibarchive/libarchive/libarchive.3
index c6894d2..6490562 100644
--- a/Utilities/cmlibarchive/libarchive/libarchive.3
+++ b/Utilities/cmlibarchive/libarchive/libarchive.3
@@ -62,30 +62,40 @@
.It
most common cpio archive formats,
.It
-ISO9660 CD images (including RockRidge and Joliet extensions),
-.It
-Zip archives,
+7-Zip archives,
.It
ar archives (including GNU/SysV and BSD extensions),
.It
Microsoft CAB archives,
.It
+ISO9660 CD images (including RockRidge and Joliet extensions),
+.It
LHA archives,
.It
mtree file tree descriptions,
.It
-RAR archives,
+RAR and most RAR5 archives,
.It
-XAR archives.
+WARC archives,
+.It
+XAR archives,
+.It
+Zip archives.
.El
The library automatically detects archives compressed with
-.Xr gzip 1 ,
+.Xr compress 1 ,
.Xr bzip2 1 ,
-.Xr xz 1 ,
+.Xr grzip 1 ,
+.Xr gzip 1 ,
+.Xr lrzip 1 ,
+.Xr lz4 1 ,
.Xr lzip 1 ,
+.Xr lzop 1 ,
+.Xr xz 1 ,
or
-.Xr compress 1
-and decompresses them transparently.
+.Xr zstd 1
+and decompresses them transparently. Decompression of some formats
+requires external decompressor utilities.
It can similarly detect and decode archives processed with
.Xr uuencode 1
or which have an
@@ -105,21 +115,21 @@
.Dq pax interchange format
archives,
.It
-POSIX octet-oriented cpio archives,
-.It
-Zip archive,
-.It
-two different variants of shar archives,
-.It
-ISO9660 CD images,
+cpio archives,
.It
7-Zip archives,
.It
ar archives,
.It
+two different variants of shar archives,
+.It
+ISO9660 CD images,
+.It
mtree file tree descriptions,
.It
-XAR archives.
+XAR archives,
+.It
+Zip archive.
.El
Pax interchange format is an extension of the tar archive format that
eliminates essentially all of the limitations of historic tar formats
diff --git a/Utilities/cmlibarchive/libarchive/xxhash.c b/Utilities/cmlibarchive/libarchive/xxhash.c
index 70750ba..f96e9d9 100644
--- a/Utilities/cmlibarchive/libarchive/xxhash.c
+++ b/Utilities/cmlibarchive/libarchive/xxhash.c
@@ -150,7 +150,11 @@
#if GCC_VERSION >= 409
__attribute__((__no_sanitize_undefined__))
#endif
-static inline U32 A32(const void * x)
+#if defined(_MSC_VER)
+static __inline U32 A32(const void * x)
+#else
+static inline U32 A32(const void* x)
+#endif
{
return (((const U32_S *)(x))->v);
}
diff --git a/bootstrap b/bootstrap
index e0791d5..98b5959 100755
--- a/bootstrap
+++ b/bootstrap
@@ -442,6 +442,7 @@
cmGccDepfileLexerHelper \
cmGccDepfileReader \
cmReturnCommand \
+ cmPlaceholderExpander \
cmRulePlaceholderExpander \
cmRuntimeDependencyArchive \
cmScriptGenerator \