summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--.gitlab-ci.yml97
-rwxr-xr-x.gitlab/ci/cmake.sh16
-rw-r--r--.gitlab/ci/configure_common.cmake3
-rw-r--r--.gitlab/ci/configure_debian10_iwyu.cmake4
-rw-r--r--.gitlab/ci/configure_fedora31_tidy.cmake3
-rw-r--r--.gitlab/ci/configure_sccache.cmake2
-rw-r--r--.gitlab/ci/ctest_build.cmake30
-rw-r--r--.gitlab/ci/ctest_configure.cmake32
-rw-r--r--.gitlab/ci/ctest_exclusions.cmake6
-rw-r--r--.gitlab/ci/ctest_test.cmake24
-rw-r--r--.gitlab/ci/docker/debian10/Dockerfile15
-rwxr-xr-x.gitlab/ci/docker/debian10/install_deps.sh22
-rwxr-xr-x.gitlab/ci/docker/debian10/install_iwyu.sh32
-rw-r--r--.gitlab/ci/docker/fedora31/Dockerfile5
-rwxr-xr-x.gitlab/ci/docker/fedora31/install_deps.sh13
-rw-r--r--.gitlab/ci/gitlab_ci.cmake46
-rwxr-xr-x.gitlab/ci/ninja.sh15
-rwxr-xr-x.gitlab/ci/sccache.sh16
-rw-r--r--Help/variable/CTEST_NIGHTLY_START_TIME.rst8
-rw-r--r--Help/variable/PROJECT_SOURCE_DIR.rst8
-rw-r--r--Modules/FindPython/Support.cmake40
-rw-r--r--Modules/Platform/Linux-OpenWatcom-C.cmake1
-rw-r--r--Modules/Platform/Linux-OpenWatcom-CXX.cmake1
-rw-r--r--Modules/Platform/Linux-OpenWatcom.cmake16
-rw-r--r--Source/CMakeVersion.cmake2
-rw-r--r--Source/CPack/IFW/cmCPackIFWCommon.cxx2
-rw-r--r--Source/CTest/cmCTestMultiProcessHandler.cxx2
-rw-r--r--Source/CTest/cmCTestRunTest.cxx2
-rw-r--r--Source/CTest/cmCTestTestHandler.cxx2
-rw-r--r--Source/Checks/cm_cxx_features.cmake4
-rw-r--r--Source/bindexplib.cxx2
-rw-r--r--Source/cmArgumentParser.cxx1
-rw-r--r--Source/cmCommonTargetGenerator.cxx4
-rw-r--r--Source/cmComputeLinkInformation.cxx17
-rw-r--r--Source/cmCustomCommandGenerator.cxx4
-rw-r--r--Source/cmExportFileGenerator.cxx57
-rw-r--r--Source/cmExportTryCompileFileGenerator.cxx6
-rw-r--r--Source/cmFileAPICodemodel.cxx4
-rw-r--r--Source/cmForEachCommand.cxx2
-rw-r--r--Source/cmFunctionBlocker.cxx2
-rw-r--r--Source/cmGeneratorExpressionNode.cxx17
-rw-r--r--Source/cmGeneratorTarget.cxx387
-rw-r--r--Source/cmGeneratorTarget.h4
-rw-r--r--Source/cmGhsMultiTargetGenerator.cxx10
-rw-r--r--Source/cmGlobalCommonGenerator.cxx4
-rw-r--r--Source/cmGlobalGenerator.cxx24
-rw-r--r--Source/cmGlobalGhsMultiGenerator.cxx11
-rw-r--r--Source/cmGlobalVisualStudio71Generator.cxx12
-rw-r--r--Source/cmGlobalVisualStudio7Generator.cxx25
-rw-r--r--Source/cmGlobalVisualStudio8Generator.cxx14
-rw-r--r--Source/cmGlobalVisualStudioGenerator.cxx6
-rw-r--r--Source/cmGlobalXCodeGenerator.cxx48
-rw-r--r--Source/cmInstallTargetGenerator.cxx8
-rw-r--r--Source/cmLinkLineDeviceComputer.cxx8
-rw-r--r--Source/cmLocalGenerator.cxx147
-rw-r--r--Source/cmLocalUnixMakefileGenerator3.cxx10
-rw-r--r--Source/cmLocalVisualStudio7Generator.cxx65
-rw-r--r--Source/cmMakefileTargetGenerator.cxx45
-rw-r--r--Source/cmNinjaNormalTargetGenerator.cxx12
-rw-r--r--Source/cmNinjaTargetGenerator.cxx53
-rw-r--r--Source/cmNinjaUtilityTargetGenerator.cxx4
-rw-r--r--Source/cmQtAutoGenInitializer.cxx13
-rw-r--r--Source/cmStringAlgorithms.cxx2
-rw-r--r--Source/cmTestGenerator.cxx6
-rw-r--r--Source/cmUVProcessChain.h2
-rw-r--r--Source/cmVisualStudio10TargetGenerator.cxx250
-rw-r--r--Source/cmVisualStudioGeneratorOptions.cxx5
-rw-r--r--Source/cmXCodeScheme.cxx17
-rw-r--r--Source/cmXMLWriter.h2
-rw-r--r--Tests/CMakeLib/testCTestBinPacker.cxx2
-rw-r--r--Tests/CMakeLib/testGccDepfileReader.cxx2
-rw-r--r--Tests/CMakeLib/testString.cxx2
-rw-r--r--Tests/RunCMake/CTestResourceAllocation/ctresalloc.cxx2
-rw-r--r--Tests/RunCMake/ctest_start/NoStartTimeNightly-result.txt1
-rw-r--r--Tests/RunCMake/ctest_start/NoStartTimeNightly-stderr.txt4
-rw-r--r--Tests/RunCMake/ctest_start/RunCMakeTest.cmake2
-rw-r--r--Tests/RunCMake/ctest_start/test.cmake.in4
-rw-r--r--Utilities/IWYU/mapping.imp4
-rw-r--r--Utilities/cmlibuv/include/uv.h29
-rw-r--r--Utilities/cmlibuv/include/uv/version.h4
-rw-r--r--Utilities/cmlibuv/src/threadpool.c4
-rw-r--r--Utilities/cmlibuv/src/timer.c7
-rw-r--r--Utilities/cmlibuv/src/unix/aix.c2
-rw-r--r--Utilities/cmlibuv/src/unix/async.c33
-rw-r--r--Utilities/cmlibuv/src/unix/atomic-ops.h2
-rw-r--r--Utilities/cmlibuv/src/unix/bsd-proctitle.c7
-rw-r--r--Utilities/cmlibuv/src/unix/cmake-bootstrap.c6
-rw-r--r--Utilities/cmlibuv/src/unix/core.c7
-rw-r--r--Utilities/cmlibuv/src/unix/darwin-proctitle.c3
-rw-r--r--Utilities/cmlibuv/src/unix/darwin-stub.h97
-rw-r--r--Utilities/cmlibuv/src/unix/fs.c93
-rw-r--r--Utilities/cmlibuv/src/unix/fsevents.c54
-rw-r--r--Utilities/cmlibuv/src/unix/internal.h2
-rw-r--r--Utilities/cmlibuv/src/unix/linux-core.c20
-rw-r--r--Utilities/cmlibuv/src/unix/no-proctitle.c3
-rw-r--r--Utilities/cmlibuv/src/unix/proctitle.c2
-rw-r--r--Utilities/cmlibuv/src/unix/signal.c4
-rw-r--r--Utilities/cmlibuv/src/unix/udp.c41
-rw-r--r--Utilities/cmlibuv/src/uv-common.c46
-rw-r--r--Utilities/cmlibuv/src/uv-common.h10
-rw-r--r--Utilities/cmlibuv/src/win/core.c12
-rw-r--r--Utilities/cmlibuv/src/win/error.c1
-rw-r--r--Utilities/cmlibuv/src/win/fs-event.c33
-rw-r--r--Utilities/cmlibuv/src/win/fs.c279
-rw-r--r--Utilities/cmlibuv/src/win/poll.c183
-rw-r--r--Utilities/cmlibuv/src/win/process.c9
-rw-r--r--Utilities/cmlibuv/src/win/signal.c5
-rw-r--r--Utilities/cmlibuv/src/win/udp.c20
-rw-r--r--Utilities/cmlibuv/src/win/util.c194
-rw-r--r--Utilities/cmlibuv/src/win/winapi.h7
110 files changed, 1952 insertions, 1069 deletions
diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml
new file mode 100644
index 0000000..9a91d20
--- /dev/null
+++ b/.gitlab-ci.yml
@@ -0,0 +1,97 @@
+.only_settings: &only_settings
+ - merge_requests
+ - branches@cmake/cmake
+ - tags@cmake/cmake
+
+.fedora31: &fedora31
+ image: "kitware/cmake:ci-fedora31-x86_64-2020-04-27"
+
+ variables:
+ GIT_CLONE_PATH: "$CI_BUILDS_DIR/gitlab-kitware-cmake ci"
+
+.debian10: &debian10
+ image: "kitware/cmake:ci-debian10-x86_64-2020-04-27"
+
+ variables:
+ GIT_CLONE_PATH: "$CI_BUILDS_DIR/gitlab-kitware-cmake ci"
+
+.debian10_iwyu: &debian10_iwyu
+ extends: .debian10
+
+ variables:
+ CMAKE_CONFIGURATION: debian10_iwyu
+ CTEST_NO_WARNINGS_ALLOWED: 1
+
+.fedora31_tidy: &fedora31_tidy
+ extends: .fedora31
+
+ variables:
+ CMAKE_CONFIGURATION: fedora31_tidy
+ CTEST_NO_WARNINGS_ALLOWED: 1
+
+before_script:
+ - .gitlab/ci/cmake.sh
+ - .gitlab/ci/ninja.sh
+ - export PATH=$PWD/.gitlab:$PWD/.gitlab/cmake/bin:$PATH
+ - cmake --version
+ - ninja --version
+
+.cmake_build_unix: &cmake_build_unix
+ stage: build
+ only: *only_settings
+ tags:
+ - build
+ - docker
+ - linux
+
+ script:
+ - .gitlab/ci/sccache.sh
+ - sccache --start-server
+ - sccache --show-stats
+ - "$LAUNCHER ctest -VV -S .gitlab/ci/ctest_configure.cmake"
+ - "$LAUNCHER ctest -VV -S .gitlab/ci/ctest_build.cmake"
+ - sccache --show-stats
+
+ interruptible: true
+
+stages:
+ - build
+ - test
+
+build:debian10-iwyu:
+ <<:
+ - *debian10_iwyu
+ stage: build
+ only: *only_settings
+ tags:
+ - build
+ - docker
+ - linux
+
+ script:
+ - .gitlab/ci/sccache.sh
+ - sccache --start-server
+ - sccache --show-stats
+ - "$LAUNCHER ctest -VV -S .gitlab/ci/ctest_configure.cmake"
+ - "$LAUNCHER ctest -VV -S .gitlab/ci/ctest_build.cmake"
+ - sccache --show-stats
+ interruptible: true
+
+build:fedora31-tidy:
+ <<:
+ - *fedora31_tidy
+ stage: build
+ only: *only_settings
+ tags:
+ - build
+ - docker
+ - linux
+
+ script:
+ - .gitlab/ci/sccache.sh
+ - sccache --start-server
+ - sccache --show-stats
+ - "$LAUNCHER ctest -VV -S .gitlab/ci/ctest_configure.cmake"
+ - "$LAUNCHER ctest -VV -S .gitlab/ci/ctest_build.cmake"
+ - sccache --show-stats
+ interruptible: true
diff --git a/.gitlab/ci/cmake.sh b/.gitlab/ci/cmake.sh
new file mode 100755
index 0000000..4b2f53f
--- /dev/null
+++ b/.gitlab/ci/cmake.sh
@@ -0,0 +1,16 @@
+#!/bin/sh
+
+set -e
+
+readonly version="3.17.2"
+readonly sha256sum="dc57f3cc448ca67fc8776b4ad4c22b087b9c6a8e459938b9622b8c7f4ef6b21e"
+readonly filename="cmake-$version-Linux-x86_64"
+readonly tarball="$filename.tar.gz"
+
+cd .gitlab
+
+echo "$sha256sum $tarball" > cmake.sha256sum
+curl -OL "https://github.com/Kitware/CMake/releases/download/v$version/$tarball"
+sha256sum --check cmake.sha256sum
+tar xf "$tarball"
+mv "$filename" cmake
diff --git a/.gitlab/ci/configure_common.cmake b/.gitlab/ci/configure_common.cmake
new file mode 100644
index 0000000..fc2aaae
--- /dev/null
+++ b/.gitlab/ci/configure_common.cmake
@@ -0,0 +1,3 @@
+set(CTEST_USE_LAUNCHERS "ON" CACHE STRING "")
+
+include("${CMAKE_CURRENT_LIST_DIR}/configure_sccache.cmake")
diff --git a/.gitlab/ci/configure_debian10_iwyu.cmake b/.gitlab/ci/configure_debian10_iwyu.cmake
new file mode 100644
index 0000000..1daa581
--- /dev/null
+++ b/.gitlab/ci/configure_debian10_iwyu.cmake
@@ -0,0 +1,4 @@
+set(CMake_RUN_IWYU ON CACHE BOOL "")
+set(IWYU_COMMAND "/usr/bin/include-what-you-use-6.0" CACHE FILEPATH "")
+
+include("${CMAKE_CURRENT_LIST_DIR}/configure_common.cmake")
diff --git a/.gitlab/ci/configure_fedora31_tidy.cmake b/.gitlab/ci/configure_fedora31_tidy.cmake
new file mode 100644
index 0000000..f41ad82
--- /dev/null
+++ b/.gitlab/ci/configure_fedora31_tidy.cmake
@@ -0,0 +1,3 @@
+set(CMake_RUN_CLANG_TIDY ON CACHE BOOL "")
+
+include("${CMAKE_CURRENT_LIST_DIR}/configure_common.cmake")
diff --git a/.gitlab/ci/configure_sccache.cmake b/.gitlab/ci/configure_sccache.cmake
new file mode 100644
index 0000000..261bb28
--- /dev/null
+++ b/.gitlab/ci/configure_sccache.cmake
@@ -0,0 +1,2 @@
+set(CMAKE_C_COMPILER_LAUNCHER "sccache" CACHE STRING "")
+set(CMAKE_CXX_COMPILER_LAUNCHER "sccache" CACHE STRING "")
diff --git a/.gitlab/ci/ctest_build.cmake b/.gitlab/ci/ctest_build.cmake
new file mode 100644
index 0000000..28bdb35
--- /dev/null
+++ b/.gitlab/ci/ctest_build.cmake
@@ -0,0 +1,30 @@
+cmake_minimum_required(VERSION 3.8)
+
+include("${CMAKE_CURRENT_LIST_DIR}/gitlab_ci.cmake")
+
+# Read the files from the build directory.
+ctest_read_custom_files("${CTEST_BINARY_DIRECTORY}")
+
+# Pick up from where the configure left off.
+ctest_start(APPEND)
+
+if (CTEST_CMAKE_GENERATOR STREQUAL "Unix Makefiles")
+ include(ProcessorCount)
+ ProcessorCount(nproc)
+ set(CTEST_BUILD_FLAGS "-j${nproc}")
+endif ()
+
+ctest_build(
+ NUMBER_WARNINGS num_warnings
+ RETURN_VALUE build_result)
+ctest_submit(PARTS Build)
+
+if (build_result)
+ message(FATAL_ERROR
+ "Failed to build")
+endif ()
+
+if ("$ENV{CTEST_NO_WARNINGS_ALLOWED}" AND num_warnings GREATER 0)
+ message(FATAL_ERROR
+ "Found ${num_warnings} warnings (treating as fatal).")
+endif ()
diff --git a/.gitlab/ci/ctest_configure.cmake b/.gitlab/ci/ctest_configure.cmake
new file mode 100644
index 0000000..55cad13
--- /dev/null
+++ b/.gitlab/ci/ctest_configure.cmake
@@ -0,0 +1,32 @@
+cmake_minimum_required(VERSION 3.8)
+
+include("${CMAKE_CURRENT_LIST_DIR}/gitlab_ci.cmake")
+
+set(cmake_args
+ -C "${CMAKE_CURRENT_LIST_DIR}/configure_$ENV{CMAKE_CONFIGURATION}.cmake")
+
+# Create an entry in CDash.
+ctest_start(Experimental TRACK "${ctest_track}")
+
+# Gather update information.
+find_package(Git)
+set(CTEST_UPDATE_VERSION_ONLY ON)
+set(CTEST_UPDATE_COMMAND "${GIT_EXECUTABLE}")
+ctest_update()
+
+# Configure the project.
+ctest_configure(
+ OPTIONS "${cmake_args}"
+ RETURN_VALUE configure_result)
+
+# Read the files from the build directory.
+ctest_read_custom_files("${CTEST_BINARY_DIRECTORY}")
+
+# We can now submit because we've configured. This is a cmb-superbuild-ism.
+ctest_submit(PARTS Update)
+ctest_submit(PARTS Configure)
+
+if (configure_result)
+ message(FATAL_ERROR
+ "Failed to configure")
+endif ()
diff --git a/.gitlab/ci/ctest_exclusions.cmake b/.gitlab/ci/ctest_exclusions.cmake
new file mode 100644
index 0000000..5bb03ca
--- /dev/null
+++ b/.gitlab/ci/ctest_exclusions.cmake
@@ -0,0 +1,6 @@
+set(test_exclusions
+)
+string(REPLACE ";" "|" test_exclusions "${test_exclusions}")
+if (test_exclusions)
+ set(test_exclusions "(${test_exclusions})")
+endif ()
diff --git a/.gitlab/ci/ctest_test.cmake b/.gitlab/ci/ctest_test.cmake
new file mode 100644
index 0000000..569139d
--- /dev/null
+++ b/.gitlab/ci/ctest_test.cmake
@@ -0,0 +1,24 @@
+cmake_minimum_required(VERSION 3.8)
+
+include("${CMAKE_CURRENT_LIST_DIR}/gitlab_ci.cmake")
+
+# Read the files from the build directory.
+ctest_read_custom_files("${CTEST_BINARY_DIRECTORY}")
+
+# Pick up from where the configure left off.
+ctest_start(APPEND)
+
+include(ProcessorCount)
+ProcessorCount(nproc)
+
+include("${CMAKE_CURRENT_LIST_DIR}/ctest_exclusions.cmake")
+ctest_test(
+ PARALLEL_LEVEL "${nproc}"
+ RETURN_VALUE test_result
+ EXCLUDE "${test_exclusions}")
+ctest_submit(PARTS Test)
+
+if (test_result)
+ message(FATAL_ERROR
+ "Failed to test")
+endif ()
diff --git a/.gitlab/ci/docker/debian10/Dockerfile b/.gitlab/ci/docker/debian10/Dockerfile
new file mode 100644
index 0000000..e8c3851
--- /dev/null
+++ b/.gitlab/ci/docker/debian10/Dockerfile
@@ -0,0 +1,15 @@
+FROM debian:10 as iwyu-build
+MAINTAINER Ben Boeckel <ben.boeckel@kitware.com>
+
+COPY install_iwyu.sh /root/install_iwyu.sh
+RUN sh /root/install_iwyu.sh
+
+FROM debian:10
+MAINTAINER Ben Boeckel <ben.boeckel@kitware.com>
+
+COPY install_deps.sh /root/install_deps.sh
+RUN sh /root/install_deps.sh
+
+COPY --from=iwyu-build /root/iwyu.tar.gz /root/iwyu.tar.gz
+RUN tar -C / -xf /root/iwyu.tar.gz
+RUN ln -s /usr/lib/llvm-6.0/bin/include-what-you-use /usr/bin/include-what-you-use-6.0
diff --git a/.gitlab/ci/docker/debian10/install_deps.sh b/.gitlab/ci/docker/debian10/install_deps.sh
new file mode 100755
index 0000000..9c32d64
--- /dev/null
+++ b/.gitlab/ci/docker/debian10/install_deps.sh
@@ -0,0 +1,22 @@
+#!/bin/sh
+
+set -e
+
+apt-get update
+
+# Install build requirements.
+apt-get install -y \
+ libssl-dev
+
+# Install development tools.
+apt-get install -y \
+ g++ \
+ curl \
+ git
+
+# Install iwyu runtime deps.
+apt-get install -y \
+ clang-6.0 \
+ libncurses6
+
+apt-get clean
diff --git a/.gitlab/ci/docker/debian10/install_iwyu.sh b/.gitlab/ci/docker/debian10/install_iwyu.sh
new file mode 100755
index 0000000..54d26ef
--- /dev/null
+++ b/.gitlab/ci/docker/debian10/install_iwyu.sh
@@ -0,0 +1,32 @@
+#!/bin/sh
+
+set -e
+
+# Install development tools.
+apt-get update
+apt-get install -y \
+ clang-6.0 \
+ libclang-6.0-dev \
+ llvm-6.0-dev \
+ libz-dev \
+ g++ \
+ cmake \
+ ninja-build \
+ git
+
+cd /root
+git clone "https://github.com/include-what-you-use/include-what-you-use.git"
+cd include-what-you-use
+readonly llvm_version="$( clang-6.0 --version | head -n1 | cut -d' ' -f3 | cut -d. -f-2 )"
+git checkout "clang_$llvm_version"
+mkdir build
+cd build
+
+cmake -GNinja \
+ -DCMAKE_BUILD_TYPE=Release \
+ "-DCMAKE_INSTALL_PREFIX=/usr/lib/llvm-$llvm_version" \
+ "-DIWYU_LLVM_ROOT_PATH=/usr/lib/llvm-$llvm_version" \
+ ..
+ninja
+DESTDIR=/root/iwyu-destdir ninja install
+tar -C /root/iwyu-destdir -cf /root/iwyu.tar.gz .
diff --git a/.gitlab/ci/docker/fedora31/Dockerfile b/.gitlab/ci/docker/fedora31/Dockerfile
new file mode 100644
index 0000000..5588a85
--- /dev/null
+++ b/.gitlab/ci/docker/fedora31/Dockerfile
@@ -0,0 +1,5 @@
+FROM fedora:31
+MAINTAINER Ben Boeckel <ben.boeckel@kitware.com>
+
+COPY install_deps.sh /root/install_deps.sh
+RUN sh /root/install_deps.sh
diff --git a/.gitlab/ci/docker/fedora31/install_deps.sh b/.gitlab/ci/docker/fedora31/install_deps.sh
new file mode 100755
index 0000000..978fdbd
--- /dev/null
+++ b/.gitlab/ci/docker/fedora31/install_deps.sh
@@ -0,0 +1,13 @@
+#!/bin/sh
+
+# Install build requirements.
+dnf install -y \
+ openssl-devel
+
+# Install development tools.
+dnf install -y \
+ clang-tools-extra \
+ gcc-c++ \
+ git-core
+
+dnf clean all
diff --git a/.gitlab/ci/gitlab_ci.cmake b/.gitlab/ci/gitlab_ci.cmake
new file mode 100644
index 0000000..401cc40
--- /dev/null
+++ b/.gitlab/ci/gitlab_ci.cmake
@@ -0,0 +1,46 @@
+if (NOT DEFINED "ENV{GITLAB_CI}")
+ message(FATAL_ERROR
+ "This script assumes it is being run inside of GitLab-CI")
+endif ()
+
+# 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_CONFIGURATION}" STREQUAL "")
+ message(FATAL_ERROR
+ "The CMAKE_CONFIGURATION environment variable is required to know what "
+ "cache initialization file to use.")
+endif ()
+
+# Set the build metadata.
+set(CTEST_BUILD_NAME "$ENV{CI_PROJECT_NAME}-$ENV{CMAKE_CONFIGURATION}")
+set(CTEST_SITE "gitlab-ci")
+
+# Default to Release builds.
+if (NOT "$ENV{CMAKE_BUILD_TYPE}" STREQUAL "")
+ set(CTEST_BUILD_CONFIGURATION "$ENV{CMAKE_BUILD_TYPE}")
+endif ()
+if (NOT CTEST_BUILD_CONFIGURATION)
+ set(CTEST_BUILD_CONFIGURATION "Release")
+endif ()
+
+# Default to using Ninja.
+if (NOT "$ENV{CMAKE_GENERATOR}" STREQUAL "")
+ set(CTEST_CMAKE_GENERATOR "$ENV{CMAKE_GENERATOR}")
+endif ()
+if (NOT CTEST_CMAKE_GENERATOR)
+ set(CTEST_CMAKE_GENERATOR "Ninja")
+endif ()
+
+# Determine the track to submit to.
+set(ctest_track "Experimental")
+if (NOT "$ENV{CI_MERGE_REQUEST_ID}" STREQUAL "")
+ set(ctest_track "merge-requests")
+elseif ("$ENV{CI_PROJECT_PATH}" STREQUAL "cmb/smtk")
+ if ("$ENV{CI_COMMIT_REF_NAME}" STREQUAL "master")
+ set(ctest_track "master")
+ elseif ("$ENV{CI_COMMIT_REF_NAME}" STREQUAL "release")
+ set(ctest_track "release")
+ endif ()
+endif ()
diff --git a/.gitlab/ci/ninja.sh b/.gitlab/ci/ninja.sh
new file mode 100755
index 0000000..31da12b
--- /dev/null
+++ b/.gitlab/ci/ninja.sh
@@ -0,0 +1,15 @@
+#!/bin/sh
+
+set -e
+
+readonly version="1.10.0"
+readonly sha256sum="6566836ddf3d72ca06685b34814e0c6fa0f0943542d651d0dab3150f10307c82"
+readonly filename="ninja-linux"
+readonly tarball="$filename.zip"
+
+cd .gitlab
+
+echo "$sha256sum $tarball" > ninja.sha256sum
+curl -OL "https://github.com/ninja-build/ninja/releases/download/v$version/$tarball"
+sha256sum --check ninja.sha256sum
+./cmake/bin/cmake -E tar xf "$tarball"
diff --git a/.gitlab/ci/sccache.sh b/.gitlab/ci/sccache.sh
new file mode 100755
index 0000000..c88cdcc
--- /dev/null
+++ b/.gitlab/ci/sccache.sh
@@ -0,0 +1,16 @@
+#!/bin/sh
+
+set -e
+
+readonly version="0.2.12"
+readonly sha256sum="26fd04c1273952cc2a0f359a71c8a1857137f0ee3634058b3f4a63b69fc8eb7f"
+readonly filename="sccache-$version-x86_64-unknown-linux-musl"
+readonly tarball="$filename.tar.gz"
+
+cd .gitlab
+
+echo "$sha256sum $tarball" > sccache.sha256sum
+curl -OL "https://github.com/mozilla/sccache/releases/download/$version/$tarball"
+sha256sum --check sccache.sha256sum
+tar xf "$tarball"
+mv "$filename/sccache" .
diff --git a/Help/variable/CTEST_NIGHTLY_START_TIME.rst b/Help/variable/CTEST_NIGHTLY_START_TIME.rst
index bc80276..90841f9 100644
--- a/Help/variable/CTEST_NIGHTLY_START_TIME.rst
+++ b/Help/variable/CTEST_NIGHTLY_START_TIME.rst
@@ -1,5 +1,9 @@
CTEST_NIGHTLY_START_TIME
------------------------
-Specify the CTest ``NightlyStartTime`` setting
-in a :manual:`ctest(1)` dashboard client script.
+Specify the CTest ``NightlyStartTime`` setting in a :manual:`ctest(1)`
+dashboard client script.
+
+Note that this variable must always be set for a nightly build in a
+dashboard script. It is needed so that nightly builds can be properly grouped
+together in CDash.
diff --git a/Help/variable/PROJECT_SOURCE_DIR.rst b/Help/variable/PROJECT_SOURCE_DIR.rst
index 27f2838..b4601c2 100644
--- a/Help/variable/PROJECT_SOURCE_DIR.rst
+++ b/Help/variable/PROJECT_SOURCE_DIR.rst
@@ -1,6 +1,8 @@
PROJECT_SOURCE_DIR
------------------
-Top level source directory for the current project.
-
-This is the source directory of the most recent :command:`project` command.
+This is the source directory of the last call to the
+:command:`project` command made in the current directory scope or one
+of its parents. Note, it is not affected by calls to
+:command:`project` made within a child directory scope (i.e. from
+within a call to :command:`add_subdirectory` from the current scope).
diff --git a/Modules/FindPython/Support.cmake b/Modules/FindPython/Support.cmake
index ecbc53c..733faa8 100644
--- a/Modules/FindPython/Support.cmake
+++ b/Modules/FindPython/Support.cmake
@@ -1788,6 +1788,23 @@ if ("Compiler" IN_LIST ${_PYTHON_PREFIX}_FIND_COMPONENTS)
endif()
# third step, search for the development artifacts
+if (${_PYTHON_PREFIX}_FIND_REQUIRED_Development.Module)
+ if ("LIBRARY" IN_LIST _${_PYTHON_PREFIX}_FIND_DEVELOPMENT_MODULE_ARTIFACTS)
+ list (APPEND _${_PYTHON_PREFIX}_REQUIRED_VARS ${_PYTHON_PREFIX}_LIBRARIES)
+ endif()
+ if ("INCLUDE_DIR" IN_LIST _${_PYTHON_PREFIX}_FIND_DEVELOPMENT_MODULE_ARTIFACTS)
+ list (APPEND _${_PYTHON_PREFIX}_REQUIRED_VARS ${_PYTHON_PREFIX}_INCLUDE_DIRS)
+ endif()
+endif()
+if (${_PYTHON_PREFIX}_FIND_REQUIRED_Development.Embed)
+ if ("LIBRARY" IN_LIST _${_PYTHON_PREFIX}_FIND_DEVELOPMENT_EMBED_ARTIFACTS)
+ list (APPEND _${_PYTHON_PREFIX}_REQUIRED_VARS ${_PYTHON_PREFIX}_LIBRARIES)
+ endif()
+ if ("INCLUDE_DIR" IN_LIST _${_PYTHON_PREFIX}_FIND_DEVELOPMENT_EMBED_ARTIFACTS)
+ list (APPEND _${_PYTHON_PREFIX}_REQUIRED_VARS ${_PYTHON_PREFIX}_INCLUDE_DIRS)
+ endif()
+endif()
+list (REMOVE_DUPLICATES _${_PYTHON_PREFIX}_REQUIRED_VARS)
## Development environment is not compatible with IronPython interpreter
if (("Development.Module" IN_LIST ${_PYTHON_PREFIX}_FIND_COMPONENTS
OR "Development.Embed" IN_LIST ${_PYTHON_PREFIX}_FIND_COMPONENTS)
@@ -1803,23 +1820,6 @@ if (("Development.Module" IN_LIST ${_PYTHON_PREFIX}_FIND_COMPONENTS
if ("INCLUDE_DIR" IN_LIST _${_PYTHON_PREFIX}_FIND_DEVELOPMENT_ARTIFACTS)
list (APPEND _${_PYTHON_PREFIX}_CACHED_VARS _${_PYTHON_PREFIX}_INCLUDE_DIR)
endif()
- if (${_PYTHON_PREFIX}_FIND_REQUIRED_Development.Module)
- if ("LIBRARY" IN_LIST _${_PYTHON_PREFIX}_FIND_DEVELOPMENT_MODULE_ARTIFACTS)
- list (APPEND _${_PYTHON_PREFIX}_REQUIRED_VARS ${_PYTHON_PREFIX}_LIBRARIES)
- endif()
- if ("INCLUDE_DIR" IN_LIST _${_PYTHON_PREFIX}_FIND_DEVELOPMENT_MODULE_ARTIFACTS)
- list (APPEND _${_PYTHON_PREFIX}_REQUIRED_VARS ${_PYTHON_PREFIX}_INCLUDE_DIRS)
- endif()
- endif()
- if (${_PYTHON_PREFIX}_FIND_REQUIRED_Development.Embed)
- if ("LIBRARY" IN_LIST _${_PYTHON_PREFIX}_FIND_DEVELOPMENT_EMBED_ARTIFACTS)
- list (APPEND _${_PYTHON_PREFIX}_REQUIRED_VARS ${_PYTHON_PREFIX}_LIBRARIES)
- endif()
- if ("INCLUDE_DIR" IN_LIST _${_PYTHON_PREFIX}_FIND_DEVELOPMENT_EMBED_ARTIFACTS)
- list (APPEND _${_PYTHON_PREFIX}_REQUIRED_VARS ${_PYTHON_PREFIX}_INCLUDE_DIRS)
- endif()
- endif()
- list (REMOVE_DUPLICATES _${_PYTHON_PREFIX}_REQUIRED_VARS)
_python_check_development_signature (Module)
_python_check_development_signature (Embed)
@@ -2514,11 +2514,11 @@ if (("Development.Module" IN_LIST ${_PYTHON_PREFIX}_FIND_COMPONENTS
_${_PYTHON_PREFIX}_DEVELOPMENT_EMBED_SIGNATURE)
endif()
+if (${_PYTHON_PREFIX}_FIND_REQUIRED_NumPy)
+ list (APPEND _${_PYTHON_PREFIX}_REQUIRED_VARS ${_PYTHON_PREFIX}_NumPy_INCLUDE_DIRS)
+endif()
if ("NumPy" IN_LIST ${_PYTHON_PREFIX}_FIND_COMPONENTS AND ${_PYTHON_PREFIX}_Interpreter_FOUND)
list (APPEND _${_PYTHON_PREFIX}_CACHED_VARS _${_PYTHON_PREFIX}_NumPy_INCLUDE_DIR)
- if (${_PYTHON_PREFIX}_FIND_REQUIRED_NumPy)
- list (APPEND _${_PYTHON_PREFIX}_REQUIRED_VARS ${_PYTHON_PREFIX}_NumPy_INCLUDE_DIRS)
- endif()
if (DEFINED ${_PYTHON_PREFIX}_NumPy_INCLUDE_DIR
AND IS_ABSOLUTE "${${_PYTHON_PREFIX}_NumPy_INCLUDE_DIR}")
diff --git a/Modules/Platform/Linux-OpenWatcom-C.cmake b/Modules/Platform/Linux-OpenWatcom-C.cmake
new file mode 100644
index 0000000..383349a
--- /dev/null
+++ b/Modules/Platform/Linux-OpenWatcom-C.cmake
@@ -0,0 +1 @@
+include(Platform/Linux-OpenWatcom)
diff --git a/Modules/Platform/Linux-OpenWatcom-CXX.cmake b/Modules/Platform/Linux-OpenWatcom-CXX.cmake
new file mode 100644
index 0000000..383349a
--- /dev/null
+++ b/Modules/Platform/Linux-OpenWatcom-CXX.cmake
@@ -0,0 +1 @@
+include(Platform/Linux-OpenWatcom)
diff --git a/Modules/Platform/Linux-OpenWatcom.cmake b/Modules/Platform/Linux-OpenWatcom.cmake
new file mode 100644
index 0000000..df23366
--- /dev/null
+++ b/Modules/Platform/Linux-OpenWatcom.cmake
@@ -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.
+
+# This module is shared by multiple languages; use include blocker.
+include_guard()
+
+string(APPEND CMAKE_EXE_LINKER_FLAGS_INIT " system linux")
+string(APPEND CMAKE_MODULE_LINKER_FLAGS_INIT " system linux")
+string(APPEND CMAKE_EXE_LINKER_FLAGS_INIT " system linux")
+
+set(CMAKE_BUILD_TYPE_INIT Debug)
+
+# single/multi-threaded /-bm
+# default is setup for single-threaded libraries
+string(APPEND CMAKE_C_FLAGS_INIT " -bt=linux")
+string(APPEND CMAKE_CXX_FLAGS_INIT " -bt=linux -xs")
diff --git a/Source/CMakeVersion.cmake b/Source/CMakeVersion.cmake
index 4c8f6d4..72c70c2 100644
--- a/Source/CMakeVersion.cmake
+++ b/Source/CMakeVersion.cmake
@@ -1,7 +1,7 @@
# CMake version number components.
set(CMake_VERSION_MAJOR 3)
set(CMake_VERSION_MINOR 17)
-set(CMake_VERSION_PATCH 20200430)
+set(CMake_VERSION_PATCH 20200501)
#set(CMake_VERSION_RC 0)
set(CMake_VERSION_IS_DIRTY 0)
diff --git a/Source/CPack/IFW/cmCPackIFWCommon.cxx b/Source/CPack/IFW/cmCPackIFWCommon.cxx
index 9fa74be..20d392d 100644
--- a/Source/CPack/IFW/cmCPackIFWCommon.cxx
+++ b/Source/CPack/IFW/cmCPackIFWCommon.cxx
@@ -2,7 +2,7 @@
file Copyright.txt or https://cmake.org/licensing for details. */
#include "cmCPackIFWCommon.h"
-#include <cstddef>
+#include <cstddef> // IWYU pragma: keep
#include <sstream>
#include <utility>
#include <vector>
diff --git a/Source/CTest/cmCTestMultiProcessHandler.cxx b/Source/CTest/cmCTestMultiProcessHandler.cxx
index 5c37f97..b7251d9 100644
--- a/Source/CTest/cmCTestMultiProcessHandler.cxx
+++ b/Source/CTest/cmCTestMultiProcessHandler.cxx
@@ -6,7 +6,7 @@
#include <cassert>
#include <chrono>
#include <cmath>
-#include <cstddef>
+#include <cstddef> // IWYU pragma: keep
#include <cstdlib>
#include <cstring>
#include <iomanip>
diff --git a/Source/CTest/cmCTestRunTest.cxx b/Source/CTest/cmCTestRunTest.cxx
index 7d0f69b..7674d7a 100644
--- a/Source/CTest/cmCTestRunTest.cxx
+++ b/Source/CTest/cmCTestRunTest.cxx
@@ -3,7 +3,7 @@
#include "cmCTestRunTest.h"
#include <chrono>
-#include <cstddef>
+#include <cstddef> // IWYU pragma: keep
#include <cstdint>
#include <cstdio>
#include <cstring>
diff --git a/Source/CTest/cmCTestTestHandler.cxx b/Source/CTest/cmCTestTestHandler.cxx
index ef6955d..8fc5cd6 100644
--- a/Source/CTest/cmCTestTestHandler.cxx
+++ b/Source/CTest/cmCTestTestHandler.cxx
@@ -5,7 +5,7 @@
#include <algorithm>
#include <chrono>
#include <cmath>
-#include <cstddef>
+#include <cstddef> // IWYU pragma: keep
#include <cstdio>
#include <cstdlib>
#include <cstring>
diff --git a/Source/Checks/cm_cxx_features.cmake b/Source/Checks/cm_cxx_features.cmake
index 3b00dfb..50ccc7c 100644
--- a/Source/Checks/cm_cxx_features.cmake
+++ b/Source/Checks/cm_cxx_features.cmake
@@ -28,8 +28,12 @@ function(cm_check_cxx_feature name)
string(REGEX REPLACE "[^\n]*warning:[^\n]*object file compiled with -mlong-branch which is no longer needed[^\n]*" "" check_output "${check_output}")
# Filter out other warnings unrelated to feature checks.
string(REGEX REPLACE "[^\n]*warning:[^\n]*sprintf\\(\\) is often misused, please use snprintf[^\n]*" "" check_output "${check_output}")
+ # Filter out libhugetlbfs warnings.
+ string(REGEX REPLACE "[^\n]*libhugetlbfs [^\n]*: WARNING[^\n]*" "" check_output "${check_output}")
# Filter out xcodebuild warnings.
string(REGEX REPLACE "[^\n]* xcodebuild\\[[0-9]*:[0-9]*\\] warning: [^\n]*" "" check_output "${check_output}")
+ # Filter out icpc warnings
+ string(REGEX REPLACE "[^\n]*icpc: command line warning #10121: overriding [^\n]*" "" check_output "${check_output}")
# Filter out ld warnings.
string(REGEX REPLACE "[^\n]*ld: warning: [^\n]*" "" check_output "${check_output}")
# If using the feature causes warnings, treat it as broken/unavailable.
diff --git a/Source/bindexplib.cxx b/Source/bindexplib.cxx
index fdfd4c0..4a5c641 100644
--- a/Source/bindexplib.cxx
+++ b/Source/bindexplib.cxx
@@ -64,7 +64,7 @@
*/
#include "bindexplib.h"
-#include <cstddef>
+#include <cstddef> // IWYU pragma: keep
#include <sstream>
#include <vector>
diff --git a/Source/cmArgumentParser.cxx b/Source/cmArgumentParser.cxx
index 4c87177..4624f1c 100644
--- a/Source/cmArgumentParser.cxx
+++ b/Source/cmArgumentParser.cxx
@@ -3,7 +3,6 @@
#include "cmArgumentParser.h"
#include <algorithm>
-#include <type_traits>
namespace ArgumentParser {
diff --git a/Source/cmCommonTargetGenerator.cxx b/Source/cmCommonTargetGenerator.cxx
index fbb9429..6c1a476 100644
--- a/Source/cmCommonTargetGenerator.cxx
+++ b/Source/cmCommonTargetGenerator.cxx
@@ -225,9 +225,9 @@ std::string cmCommonTargetGenerator::GetAIXExports(std::string const&)
{
std::string aixExports;
if (this->GeneratorTarget->Target->IsAIX()) {
- if (const char* exportAll =
+ if (cmProp exportAll =
this->GeneratorTarget->GetProperty("AIX_EXPORT_ALL_SYMBOLS")) {
- if (cmIsOff(exportAll)) {
+ if (cmIsOff(*exportAll)) {
aixExports = "-n";
}
}
diff --git a/Source/cmComputeLinkInformation.cxx b/Source/cmComputeLinkInformation.cxx
index f0174d9..ea7ede4 100644
--- a/Source/cmComputeLinkInformation.cxx
+++ b/Source/cmComputeLinkInformation.cxx
@@ -514,8 +514,8 @@ bool cmComputeLinkInformation::Compute()
// Restore the target link type so the correct system runtime
// libraries are found.
- const char* lss = this->Target->GetProperty("LINK_SEARCH_END_STATIC");
- if (cmIsOn(lss)) {
+ cmProp lss = this->Target->GetProperty("LINK_SEARCH_END_STATIC");
+ if (lss && cmIsOn(*lss)) {
this->SetCurrentLinkType(LinkStatic);
} else {
this->SetCurrentLinkType(this->StartLinkType);
@@ -591,10 +591,9 @@ void cmComputeLinkInformation::AddRuntimeLinkLibrary(std::string const& lang)
// of a default selection whether or not it is overridden by a property.
std::string defaultVar =
cmStrCat("CMAKE_", lang, "_RUNTIME_LIBRARY_DEFAULT");
- const char* langRuntimeLibraryDefault =
- this->Makefile->GetDefinition(defaultVar);
- if (langRuntimeLibraryDefault && *langRuntimeLibraryDefault) {
- const char* runtimeLibraryValue =
+ cmProp langRuntimeLibraryDefault = this->Makefile->GetDef(defaultVar);
+ if (langRuntimeLibraryDefault && !langRuntimeLibraryDefault->empty()) {
+ cmProp runtimeLibraryValue =
this->Target->GetProperty(cmStrCat(lang, "_RUNTIME_LIBRARY"));
if (!runtimeLibraryValue) {
runtimeLibraryValue = langRuntimeLibraryDefault;
@@ -602,7 +601,7 @@ void cmComputeLinkInformation::AddRuntimeLinkLibrary(std::string const& lang)
std::string runtimeLibrary =
cmSystemTools::UpperCase(cmGeneratorExpression::Evaluate(
- runtimeLibraryValue, this->Target->GetLocalGenerator(), this->Config,
+ *runtimeLibraryValue, this->Target->GetLocalGenerator(), this->Config,
this->Target));
if (!runtimeLibrary.empty()) {
if (const char* runtimeLinkOptions = this->Makefile->GetDefinition(
@@ -855,8 +854,8 @@ void cmComputeLinkInformation::ComputeLinkTypeInfo()
}
// Lookup the starting link type from the target (linked statically?).
- const char* lss = this->Target->GetProperty("LINK_SEARCH_START_STATIC");
- this->StartLinkType = cmIsOn(lss) ? LinkStatic : LinkShared;
+ cmProp lss = this->Target->GetProperty("LINK_SEARCH_START_STATIC");
+ this->StartLinkType = (lss && cmIsOn(*lss)) ? LinkStatic : LinkShared;
this->CurrentLinkType = this->StartLinkType;
}
diff --git a/Source/cmCustomCommandGenerator.cxx b/Source/cmCustomCommandGenerator.cxx
index 2432d2b..0fe19b6 100644
--- a/Source/cmCustomCommandGenerator.cxx
+++ b/Source/cmCustomCommandGenerator.cxx
@@ -111,13 +111,13 @@ void cmCustomCommandGenerator::FillEmulatorsWithArguments()
if (target && target->GetType() == cmStateEnums::EXECUTABLE &&
!target->IsImported()) {
- const char* emulator_property =
+ cmProp emulator_property =
target->GetProperty("CROSSCOMPILING_EMULATOR");
if (!emulator_property) {
continue;
}
- cmExpandList(emulator_property, this->EmulatorsWithArguments[c]);
+ cmExpandList(*emulator_property, this->EmulatorsWithArguments[c]);
}
}
}
diff --git a/Source/cmExportFileGenerator.cxx b/Source/cmExportFileGenerator.cxx
index ea31417..28037c6 100644
--- a/Source/cmExportFileGenerator.cxx
+++ b/Source/cmExportFileGenerator.cxx
@@ -125,9 +125,9 @@ void cmExportFileGenerator::PopulateInterfaceProperty(
const std::string& propName, cmGeneratorTarget* target,
ImportPropertyMap& properties)
{
- const char* input = target->GetProperty(propName);
+ cmProp input = target->GetProperty(propName);
if (input) {
- properties[propName] = input;
+ properties[propName] = *input;
}
}
@@ -137,16 +137,16 @@ void cmExportFileGenerator::PopulateInterfaceProperty(
cmGeneratorExpression::PreprocessContext preprocessRule,
ImportPropertyMap& properties, std::vector<std::string>& missingTargets)
{
- const char* input = target->GetProperty(propName);
+ cmProp input = target->GetProperty(propName);
if (input) {
- if (!*input) {
+ if (input->empty()) {
// Set to empty
properties[outputName].clear();
return;
}
std::string prepro =
- cmGeneratorExpression::Preprocess(input, preprocessRule);
+ cmGeneratorExpression::Preprocess(*input, preprocessRule);
if (!prepro.empty()) {
this->ResolveTargetsInGeneratorExpressions(prepro, target,
missingTargets);
@@ -174,10 +174,10 @@ bool cmExportFileGenerator::PopulateInterfaceLinkLibrariesProperty(
if (!target->IsLinkable()) {
return false;
}
- const char* input = target->GetProperty("INTERFACE_LINK_LIBRARIES");
+ cmProp input = target->GetProperty("INTERFACE_LINK_LIBRARIES");
if (input) {
std::string prepro =
- cmGeneratorExpression::Preprocess(input, preprocessRule);
+ cmGeneratorExpression::Preprocess(*input, preprocessRule);
if (!prepro.empty()) {
this->ResolveTargetsInGeneratorExpressions(
prepro, target, missingTargets, ReplaceFreeTargets);
@@ -341,19 +341,19 @@ void cmExportFileGenerator::PopulateSourcesInterface(
assert(preprocessRule == cmGeneratorExpression::InstallInterface);
const char* propName = "INTERFACE_SOURCES";
- const char* input = gt->GetProperty(propName);
+ cmProp input = gt->GetProperty(propName);
if (!input) {
return;
}
- if (!*input) {
+ if (input->empty()) {
properties[propName].clear();
return;
}
std::string prepro =
- cmGeneratorExpression::Preprocess(input, preprocessRule, true);
+ cmGeneratorExpression::Preprocess(*input, preprocessRule, true);
if (!prepro.empty()) {
this->ResolveTargetsInGeneratorExpressions(prepro, gt, missingTargets);
@@ -372,7 +372,7 @@ void cmExportFileGenerator::PopulateIncludeDirectoriesInterface(
assert(preprocessRule == cmGeneratorExpression::InstallInterface);
const char* propName = "INTERFACE_INCLUDE_DIRECTORIES";
- const char* input = target->GetProperty(propName);
+ cmProp input = target->GetProperty(propName);
cmGeneratorExpression ge;
@@ -399,7 +399,7 @@ void cmExportFileGenerator::PopulateIncludeDirectoriesInterface(
if (!input && exportDirs.empty()) {
return;
}
- if ((input && !*input) && exportDirs.empty()) {
+ if ((input && input->empty()) && exportDirs.empty()) {
// Set to empty
properties[propName].clear();
return;
@@ -407,7 +407,7 @@ void cmExportFileGenerator::PopulateIncludeDirectoriesInterface(
prefixItems(exportDirs);
- std::string includes = (input ? input : "");
+ std::string includes = (input ? *input : "");
const char* sep = input ? ";" : "";
includes += sep + exportDirs;
std::string prepro =
@@ -430,19 +430,19 @@ void cmExportFileGenerator::PopulateLinkDependsInterface(
assert(preprocessRule == cmGeneratorExpression::InstallInterface);
const char* propName = "INTERFACE_LINK_DEPENDS";
- const char* input = gt->GetProperty(propName);
+ cmProp input = gt->GetProperty(propName);
if (!input) {
return;
}
- if (!*input) {
+ if (input->empty()) {
properties[propName].clear();
return;
}
std::string prepro =
- cmGeneratorExpression::Preprocess(input, preprocessRule, true);
+ cmGeneratorExpression::Preprocess(*input, preprocessRule, true);
if (!prepro.empty()) {
this->ResolveTargetsInGeneratorExpressions(prepro, gt, missingTargets);
@@ -461,19 +461,19 @@ void cmExportFileGenerator::PopulateLinkDirectoriesInterface(
assert(preprocessRule == cmGeneratorExpression::InstallInterface);
const char* propName = "INTERFACE_LINK_DIRECTORIES";
- const char* input = gt->GetProperty(propName);
+ cmProp input = gt->GetProperty(propName);
if (!input) {
return;
}
- if (!*input) {
+ if (input->empty()) {
properties[propName].clear();
return;
}
std::string prepro =
- cmGeneratorExpression::Preprocess(input, preprocessRule, true);
+ cmGeneratorExpression::Preprocess(*input, preprocessRule, true);
if (!prepro.empty()) {
this->ResolveTargetsInGeneratorExpressions(prepro, gt, missingTargets);
@@ -496,11 +496,11 @@ void cmExportFileGenerator::PopulateInterfaceProperty(
void getPropertyContents(cmGeneratorTarget const* tgt, const std::string& prop,
std::set<std::string>& ifaceProperties)
{
- const char* p = tgt->GetProperty(prop);
+ cmProp p = tgt->GetProperty(prop);
if (!p) {
return;
}
- std::vector<std::string> content = cmExpandedList(p);
+ std::vector<std::string> content = cmExpandedList(*p);
ifaceProperties.insert(content.begin(), content.end());
}
@@ -761,13 +761,12 @@ void cmExportFileGenerator::SetImportLinkInterface(
return;
}
- const char* propContent;
+ cmProp propContent;
- if (const char* prop_suffixed =
+ if (cmProp prop_suffixed =
target->GetProperty("LINK_INTERFACE_LIBRARIES" + suffix)) {
propContent = prop_suffixed;
- } else if (const char* prop =
- target->GetProperty("LINK_INTERFACE_LIBRARIES")) {
+ } else if (cmProp prop = target->GetProperty("LINK_INTERFACE_LIBRARIES")) {
propContent = prop;
} else {
return;
@@ -789,13 +788,13 @@ void cmExportFileGenerator::SetImportLinkInterface(
return;
}
- if (!*propContent) {
+ if (propContent->empty()) {
properties["IMPORTED_LINK_INTERFACE_LIBRARIES" + suffix].clear();
return;
}
std::string prepro =
- cmGeneratorExpression::Preprocess(propContent, preprocessRule);
+ cmGeneratorExpression::Preprocess(*propContent, preprocessRule);
if (!prepro.empty()) {
this->ResolveTargetsInGeneratorExpressions(prepro, target, missingTargets,
ReplaceFreeTargets);
@@ -855,8 +854,8 @@ void cmExportFileGenerator::SetImportDetailProperties(
cmGeneratorTarget::ManagedType::Native) {
std::string prop = cmStrCat("IMPORTED_COMMON_LANGUAGE_RUNTIME", suffix);
std::string propval;
- if (auto* p = target->GetProperty("COMMON_LANGUAGE_RUNTIME")) {
- propval = p;
+ if (cmProp p = target->GetProperty("COMMON_LANGUAGE_RUNTIME")) {
+ propval = *p;
} else if (target->IsCSharpOnly()) {
// C# projects do not have the /clr flag, so we set the property
// here to mark the target as (only) managed (i.e. no .lib file
diff --git a/Source/cmExportTryCompileFileGenerator.cxx b/Source/cmExportTryCompileFileGenerator.cxx
index 807ebed..6212667 100644
--- a/Source/cmExportTryCompileFileGenerator.cxx
+++ b/Source/cmExportTryCompileFileGenerator.cxx
@@ -58,7 +58,7 @@ std::string cmExportTryCompileFileGenerator::FindTargets(
const std::string& propName, cmGeneratorTarget const* tgt,
std::string const& language, std::set<cmGeneratorTarget const*>& emitted)
{
- const char* prop = tgt->GetProperty(propName);
+ cmProp prop = tgt->GetProperty(propName);
if (!prop) {
return std::string();
}
@@ -67,7 +67,7 @@ std::string cmExportTryCompileFileGenerator::FindTargets(
cmGeneratorExpressionDAGChecker dagChecker(tgt, propName, nullptr, nullptr);
- std::unique_ptr<cmCompiledGeneratorExpression> cge = ge.Parse(prop);
+ std::unique_ptr<cmCompiledGeneratorExpression> cge = ge.Parse(*prop);
cmTarget dummyHead("try_compile_dummy_exe", cmStateEnums::EXECUTABLE,
cmTarget::VisibilityNormal, tgt->Target->GetMakefile(),
@@ -95,7 +95,7 @@ void cmExportTryCompileFileGenerator::PopulateProperties(
std::vector<std::string> props = target->GetPropertyKeys();
for (std::string const& p : props) {
- properties[p] = target->GetProperty(p);
+ properties[p] = *target->GetProperty(p);
if (cmHasLiteralPrefix(p, "IMPORTED_LINK_INTERFACE_LIBRARIES") ||
cmHasLiteralPrefix(p, "IMPORTED_LINK_DEPENDENT_LIBRARIES") ||
diff --git a/Source/cmFileAPICodemodel.cxx b/Source/cmFileAPICodemodel.cxx
index f4237cb..f34d7d5 100644
--- a/Source/cmFileAPICodemodel.cxx
+++ b/Source/cmFileAPICodemodel.cxx
@@ -1424,9 +1424,9 @@ Json::Value Target::DumpDependency(cmTargetDepend const& td)
Json::Value Target::DumpFolder()
{
Json::Value folder;
- if (const char* f = this->GT->GetProperty("FOLDER")) {
+ if (cmProp f = this->GT->GetProperty("FOLDER")) {
folder = Json::objectValue;
- folder["name"] = f;
+ folder["name"] = *f;
}
return folder;
}
diff --git a/Source/cmForEachCommand.cxx b/Source/cmForEachCommand.cxx
index 6e64e6d..32e7892 100644
--- a/Source/cmForEachCommand.cxx
+++ b/Source/cmForEachCommand.cxx
@@ -4,7 +4,7 @@
#include <algorithm>
#include <cassert>
-#include <cstddef>
+#include <cstddef> // IWYU pragma: keep
// NOTE The declaration of `std::abs` has moved to `cmath` since C++17
// See https://en.cppreference.com/w/cpp/numeric/math/abs
// ALERT But IWYU used to lint `#include`s do not "understand"
diff --git a/Source/cmFunctionBlocker.cxx b/Source/cmFunctionBlocker.cxx
index 5778a71..643cd82 100644
--- a/Source/cmFunctionBlocker.cxx
+++ b/Source/cmFunctionBlocker.cxx
@@ -3,7 +3,9 @@
#include "cmFunctionBlocker.h"
#include <cassert>
+#include <memory> // IWYU pragma: keep
#include <sstream>
+#include <string> // IWYU pragma: keep
#include <utility>
#include "cmExecutionStatus.h"
diff --git a/Source/cmGeneratorExpressionNode.cxx b/Source/cmGeneratorExpressionNode.cxx
index 947601e..e3de2d8 100644
--- a/Source/cmGeneratorExpressionNode.cxx
+++ b/Source/cmGeneratorExpressionNode.cxx
@@ -919,9 +919,8 @@ static const struct ConfigurationTestNode : public cmGeneratorExpressionNode
std::vector<std::string> mappedConfigs;
std::string mapProp = cmStrCat(
"MAP_IMPORTED_CONFIG_", cmSystemTools::UpperCase(context->Config));
- if (const char* mapValue =
- context->CurrentTarget->GetProperty(mapProp)) {
- cmExpandList(cmSystemTools::UpperCase(mapValue), mappedConfigs);
+ if (cmProp mapValue = context->CurrentTarget->GetProperty(mapProp)) {
+ cmExpandList(cmSystemTools::UpperCase(*mapValue), mappedConfigs);
return cm::contains(mappedConfigs,
cmSystemTools::UpperCase(parameters.front()))
? "1"
@@ -1483,8 +1482,8 @@ static const struct TargetPropertyNode : public cmGeneratorExpressionNode
std::string result;
bool haveProp = false;
- if (const char* p = target->GetProperty(propertyName)) {
- result = p;
+ if (cmProp p = target->GetProperty(propertyName)) {
+ result = *p;
haveProp = true;
} else if (evaluatingLinkLibraries) {
return std::string();
@@ -1722,13 +1721,13 @@ static const struct CompileFeaturesNode : public cmGeneratorExpressionNode
for (auto const& lit : testedFeatures) {
std::vector<std::string> const& langAvailable =
availableFeatures[lit.first];
- const char* standardDefault = context->LG->GetMakefile()->GetDefinition(
+ cmProp standardDefault = context->LG->GetMakefile()->GetDef(
"CMAKE_" + lit.first + "_STANDARD_DEFAULT");
for (std::string const& it : lit.second) {
if (!cm::contains(langAvailable, it)) {
return "0";
}
- if (standardDefault && !*standardDefault) {
+ if (standardDefault && standardDefault->empty()) {
// This compiler has no notion of language standard levels.
// All features known for the language are always available.
continue;
@@ -1736,12 +1735,12 @@ static const struct CompileFeaturesNode : public cmGeneratorExpressionNode
if (!context->LG->GetMakefile()->HaveStandardAvailable(
target->Target, lit.first, it)) {
if (evalLL) {
- const char* l = target->GetProperty(lit.first + "_STANDARD");
+ cmProp l = target->GetProperty(lit.first + "_STANDARD");
if (!l) {
l = standardDefault;
}
assert(l);
- context->MaxLanguageStandard[target][lit.first] = l;
+ context->MaxLanguageStandard[target][lit.first] = *l;
} else {
return "0";
}
diff --git a/Source/cmGeneratorTarget.cxx b/Source/cmGeneratorTarget.cxx
index 44a20fc..ac08cf7 100644
--- a/Source/cmGeneratorTarget.cxx
+++ b/Source/cmGeneratorTarget.cxx
@@ -355,22 +355,22 @@ const std::string& cmGeneratorTarget::GetName() const
std::string cmGeneratorTarget::GetExportName() const
{
- const char* exportName = this->GetProperty("EXPORT_NAME");
+ cmProp exportName = this->GetProperty("EXPORT_NAME");
- if (exportName && *exportName) {
- if (!cmGeneratorExpression::IsValidTargetName(exportName)) {
+ if (exportName && !exportName->empty()) {
+ if (!cmGeneratorExpression::IsValidTargetName(*exportName)) {
std::ostringstream e;
- e << "EXPORT_NAME property \"" << exportName << "\" for \""
+ e << "EXPORT_NAME property \"" << *exportName << "\" for \""
<< this->GetName() << "\": is not valid.";
cmSystemTools::Error(e.str());
return "";
}
- return exportName;
+ return *exportName;
}
return this->GetName();
}
-const char* cmGeneratorTarget::GetProperty(const std::string& prop) const
+cmProp cmGeneratorTarget::GetProperty(const std::string& prop) const
{
if (!cmTargetPropertyComputer::PassesWhitelist(
this->GetType(), prop, this->Makefile->GetMessenger(),
@@ -379,22 +379,22 @@ const char* cmGeneratorTarget::GetProperty(const std::string& prop) const
}
if (cmProp result = cmTargetPropertyComputer::GetProperty(
this, prop, this->Makefile->GetMessenger(), this->GetBacktrace())) {
- return result->c_str();
+ return result;
}
if (cmSystemTools::GetFatalErrorOccured()) {
return nullptr;
}
- cmProp retval = this->Target->GetProperty(prop);
- return retval ? retval->c_str() : nullptr;
+ return this->Target->GetProperty(prop);
}
const char* cmGeneratorTarget::GetSafeProperty(const std::string& prop) const
{
- const char* ret = this->GetProperty(prop);
+ cmProp ret = this->GetProperty(prop);
if (!ret) {
return "";
}
- return ret;
+
+ return ret->c_str();
}
const char* cmGeneratorTarget::GetOutputTargetType(
@@ -483,8 +483,8 @@ std::string cmGeneratorTarget::GetOutputName(
std::string outName;
for (std::string const& p : props) {
- if (const char* outNameProp = this->GetProperty(p)) {
- outName = outNameProp;
+ if (cmProp outNameProp = this->GetProperty(p)) {
+ outName = *outNameProp;
break;
}
}
@@ -540,7 +540,7 @@ std::string cmGeneratorTarget::GetFileSuffix(
std::string cmGeneratorTarget::GetFilePostfix(const std::string& config) const
{
- const char* postfix = nullptr;
+ cmProp postfix = nullptr;
std::string frameworkPostfix;
if (!config.empty()) {
std::string configProp =
@@ -558,16 +558,16 @@ std::string cmGeneratorTarget::GetFilePostfix(const std::string& config) const
// framework postfix.
frameworkPostfix = GetFrameworkMultiConfigPostfix(config);
if (!frameworkPostfix.empty()) {
- postfix = frameworkPostfix.c_str();
+ postfix = &frameworkPostfix;
}
}
- return postfix ? postfix : std::string();
+ return postfix ? *postfix : std::string();
}
std::string cmGeneratorTarget::GetFrameworkMultiConfigPostfix(
const std::string& config) const
{
- const char* postfix = nullptr;
+ cmProp postfix = nullptr;
if (!config.empty()) {
std::string configProp = cmStrCat("FRAMEWORK_MULTI_CONFIG_POSTFIX_",
cmSystemTools::UpperCase(config));
@@ -579,7 +579,7 @@ std::string cmGeneratorTarget::GetFrameworkMultiConfigPostfix(
postfix = nullptr;
}
}
- return postfix ? postfix : std::string();
+ return postfix ? *postfix : std::string();
}
const char* cmGeneratorTarget::GetFilePrefixInternal(
@@ -612,7 +612,7 @@ const char* cmGeneratorTarget::GetFilePrefixInternal(
}
// Compute prefix value.
- const char* targetPrefix =
+ cmProp targetPrefix =
(isImportedLibraryArtifact ? this->GetProperty("IMPORT_PREFIX")
: this->GetProperty("PREFIX"));
@@ -620,17 +620,17 @@ const char* cmGeneratorTarget::GetFilePrefixInternal(
const char* prefixVar = this->Target->GetPrefixVariableInternal(artifact);
if (!language.empty() && prefixVar && *prefixVar) {
std::string langPrefix = prefixVar + std::string("_") + language;
- targetPrefix = this->Makefile->GetDefinition(langPrefix);
+ targetPrefix = this->Makefile->GetDef(langPrefix);
}
// if there is no prefix on the target nor specific language
// use the cmake definition.
if (!targetPrefix && prefixVar) {
- targetPrefix = this->Makefile->GetDefinition(prefixVar);
+ targetPrefix = this->Makefile->GetDef(prefixVar);
}
}
- return targetPrefix;
+ return targetPrefix ? targetPrefix->c_str() : nullptr;
}
const char* cmGeneratorTarget::GetFileSuffixInternal(
std::string const& config, cmStateEnums::ArtifactType artifact,
@@ -662,7 +662,7 @@ const char* cmGeneratorTarget::GetFileSuffixInternal(
}
// Compute suffix value.
- const char* targetSuffix =
+ cmProp targetSuffix =
(isImportedLibraryArtifact ? this->GetProperty("IMPORT_SUFFIX")
: this->GetProperty("SUFFIX"));
@@ -670,17 +670,17 @@ const char* cmGeneratorTarget::GetFileSuffixInternal(
const char* suffixVar = this->Target->GetSuffixVariableInternal(artifact);
if (!language.empty() && suffixVar && *suffixVar) {
std::string langSuffix = suffixVar + std::string("_") + language;
- targetSuffix = this->Makefile->GetDefinition(langSuffix);
+ targetSuffix = this->Makefile->GetDef(langSuffix);
}
// if there is no suffix on the target nor specific language
// use the cmake definition.
if (!targetSuffix && suffixVar) {
- targetSuffix = this->Makefile->GetDefinition(suffixVar);
+ targetSuffix = this->Makefile->GetDef(suffixVar);
}
}
- return targetSuffix;
+ return targetSuffix ? targetSuffix->c_str() : nullptr;
}
void cmGeneratorTarget::ClearSourcesCache()
@@ -742,9 +742,9 @@ void handleSystemIncludesDep(cmLocalGenerator* lg,
std::vector<std::string>& result,
bool excludeImported, std::string const& language)
{
- if (const char* dirs =
+ if (cmProp dirs =
depTgt->GetProperty("INTERFACE_SYSTEM_INCLUDE_DIRECTORIES")) {
- cmExpandList(cmGeneratorExpression::Evaluate(dirs, lg, config, headTarget,
+ cmExpandList(cmGeneratorExpression::Evaluate(*dirs, lg, config, headTarget,
dagChecker, depTgt, language),
result);
}
@@ -752,9 +752,8 @@ void handleSystemIncludesDep(cmLocalGenerator* lg,
return;
}
- if (const char* dirs =
- depTgt->GetProperty("INTERFACE_INCLUDE_DIRECTORIES")) {
- cmExpandList(cmGeneratorExpression::Evaluate(dirs, lg, config, headTarget,
+ if (cmProp dirs = depTgt->GetProperty("INTERFACE_INCLUDE_DIRECTORIES")) {
+ cmExpandList(cmGeneratorExpression::Evaluate(*dirs, lg, config, headTarget,
dagChecker, depTgt, language),
result);
}
@@ -810,12 +809,12 @@ const char* cmGeneratorTarget::GetFeature(const std::string& feature,
if (!config.empty()) {
std::string featureConfig =
cmStrCat(feature, '_', cmSystemTools::UpperCase(config));
- if (const char* value = this->GetProperty(featureConfig)) {
- return value;
+ if (cmProp value = this->GetProperty(featureConfig)) {
+ return value->c_str();
}
}
- if (const char* value = this->GetProperty(feature)) {
- return value;
+ if (cmProp value = this->GetProperty(feature)) {
+ return value->c_str();
}
return this->LocalGenerator->GetFeature(feature, config);
}
@@ -1171,8 +1170,8 @@ bool cmGeneratorTarget::MaybeHaveInterfaceProperty(
bool& maybeInterfaceProp = i->second;
// If this target itself has a non-empty property value, we are done.
- const char* p = this->GetProperty(prop);
- maybeInterfaceProp = p && *p;
+ cmProp p = this->GetProperty(prop);
+ maybeInterfaceProp = p && !p->empty();
// Otherwise, recurse to interface dependencies.
if (!maybeInterfaceProp) {
@@ -1238,9 +1237,9 @@ std::string cmGeneratorTarget::EvaluateInterfaceProperty(
cmGeneratorTarget const* headTarget =
context->HeadTarget ? context->HeadTarget : this;
- if (const char* p = this->GetProperty(prop)) {
+ if (cmProp p = this->GetProperty(prop)) {
result = cmGeneratorExpressionNode::EvaluateDependentExpression(
- p, context->LG, context, headTarget, &dagChecker, this);
+ *p, context->LG, context, headTarget, &dagChecker, this);
}
if (cmLinkInterfaceLibraries const* iface = this->GetLinkInterfaceLibraries(
@@ -1345,9 +1344,8 @@ void AddSwiftImplicitIncludeDirectories(
"Swift")) {
EvaluatedTargetPropertyEntry entry{ library, library.Backtrace };
- if (const char* val =
- dependency->GetProperty("Swift_MODULE_DIRECTORY")) {
- entry.Values.emplace_back(val);
+ if (cmProp val = dependency->GetProperty("Swift_MODULE_DIRECTORY")) {
+ entry.Values.emplace_back(*val);
} else {
entry.Values.emplace_back(
dependency->GetLocalGenerator()->GetCurrentBinaryDirectory());
@@ -1824,14 +1822,14 @@ std::string cmGeneratorTarget::GetCompilePDBName(
// Check for a per-configuration output directory target property.
std::string configUpper = cmSystemTools::UpperCase(config);
std::string configProp = cmStrCat("COMPILE_PDB_NAME_", configUpper);
- const char* config_name = this->GetProperty(configProp);
- if (config_name && *config_name) {
- return prefix + config_name + ".pdb";
+ cmProp config_name = this->GetProperty(configProp);
+ if (config_name && !config_name->empty()) {
+ return prefix + *config_name + ".pdb";
}
- const char* name = this->GetProperty("COMPILE_PDB_NAME");
- if (name && *name) {
- return prefix + name + ".pdb";
+ cmProp name = this->GetProperty("COMPILE_PDB_NAME");
+ if (name && !name->empty()) {
+ return prefix + *name + ".pdb";
}
return "";
@@ -2013,10 +2011,9 @@ bool cmGeneratorTarget::HasMacOSXRpathInstallNameDir(
if (this->GetType() != cmStateEnums::SHARED_LIBRARY) {
return false;
}
- const char* install_name = this->GetProperty("INSTALL_NAME_DIR");
+ cmProp install_name = this->GetProperty("INSTALL_NAME_DIR");
bool use_install_name = this->MacOSXUseInstallNameDir();
- if (install_name && use_install_name &&
- std::string(install_name) == "@rpath") {
+ if (install_name && use_install_name && *install_name == "@rpath") {
install_name_is_rpath = true;
} else if (install_name && use_install_name) {
return false;
@@ -2072,7 +2069,7 @@ bool cmGeneratorTarget::MacOSXRpathInstallNameDirDefault() const
return false;
}
- const char* macosx_rpath_str = this->GetProperty("MACOSX_RPATH");
+ cmProp macosx_rpath_str = this->GetProperty("MACOSX_RPATH");
if (macosx_rpath_str) {
return this->GetPropertyAsBool("MACOSX_RPATH");
}
@@ -2089,10 +2086,10 @@ bool cmGeneratorTarget::MacOSXRpathInstallNameDirDefault() const
bool cmGeneratorTarget::MacOSXUseInstallNameDir() const
{
- const char* build_with_install_name =
+ cmProp build_with_install_name =
this->GetProperty("BUILD_WITH_INSTALL_NAME_DIR");
if (build_with_install_name) {
- return cmIsOn(build_with_install_name);
+ return cmIsOn(*build_with_install_name);
}
cmPolicies::PolicyStatus cmp0068 = this->GetPolicyStatusCMP0068();
@@ -2174,11 +2171,8 @@ std::string cmGeneratorTarget::GetAppBundleDirectory(
{
std::string fpath = cmStrCat(
this->GetFullName(config, cmStateEnums::RuntimeBinaryArtifact), '.');
- const char* ext = this->GetProperty("BUNDLE_EXTENSION");
- if (!ext) {
- ext = "app";
- }
- fpath += ext;
+ cmProp ext = this->GetProperty("BUNDLE_EXTENSION");
+ fpath += (ext ? *ext : "app");
if (shouldAddContentLevel(level) &&
!this->Makefile->PlatformIsAppleEmbedded()) {
fpath += "/Contents";
@@ -2200,8 +2194,10 @@ std::string cmGeneratorTarget::GetCFBundleDirectory(
{
std::string fpath = cmStrCat(
this->GetOutputName(config, cmStateEnums::RuntimeBinaryArtifact), '.');
- const char* ext = this->GetProperty("BUNDLE_EXTENSION");
- if (!ext) {
+ std::string ext;
+ if (cmProp p = this->GetProperty("BUNDLE_EXTENSION")) {
+ ext = *p;
+ } else {
if (this->IsXCTestOnApple()) {
ext = "xctest";
} else {
@@ -2224,11 +2220,8 @@ std::string cmGeneratorTarget::GetFrameworkDirectory(
{
std::string fpath = cmStrCat(
this->GetOutputName(config, cmStateEnums::RuntimeBinaryArtifact), '.');
- const char* ext = this->GetProperty("BUNDLE_EXTENSION");
- if (!ext) {
- ext = "framework";
- }
- fpath += ext;
+ cmProp ext = this->GetProperty("BUNDLE_EXTENSION");
+ fpath += (ext ? *ext : "framework");
if (shouldAddFullLevel(level) &&
!this->Makefile->PlatformIsAppleEmbedded()) {
fpath += "/Versions/";
@@ -2279,11 +2272,11 @@ std::string cmGeneratorTarget::GetInstallNameDirForInstallTree(
{
if (this->Makefile->IsOn("CMAKE_PLATFORM_HAS_INSTALLNAME")) {
std::string dir;
- const char* install_name_dir = this->GetProperty("INSTALL_NAME_DIR");
+ cmProp install_name_dir = this->GetProperty("INSTALL_NAME_DIR");
if (this->CanGenerateInstallNameDir(INSTALL_NAME_FOR_INSTALL)) {
- if (install_name_dir && *install_name_dir) {
- dir = install_name_dir;
+ if (install_name_dir && !install_name_dir->empty()) {
+ dir = *install_name_dir;
cmGeneratorExpression::ReplaceInstallPrefix(dir, installPrefix);
dir =
cmGeneratorExpression::Evaluate(dir, this->LocalGenerator, config);
@@ -2328,8 +2321,8 @@ const std::string* cmGeneratorTarget::GetExportMacro() const
if (this->GetType() == cmStateEnums::SHARED_LIBRARY ||
this->GetType() == cmStateEnums::MODULE_LIBRARY ||
this->IsExecutableWithExports()) {
- if (const char* custom_export_name = this->GetProperty("DEFINE_SYMBOL")) {
- this->ExportMacro = custom_export_name;
+ if (cmProp custom_export_name = this->GetProperty("DEFINE_SYMBOL")) {
+ this->ExportMacro = *custom_export_name;
} else {
std::string in = cmStrCat(this->GetName(), "_EXPORTS");
this->ExportMacro = cmSystemTools::MakeCidentifier(in);
@@ -2616,9 +2609,9 @@ std::string cmGeneratorTarget::GetEffectiveFolderName() const
return effectiveFolder;
}
- const char* targetFolder = this->GetProperty("FOLDER");
+ cmProp targetFolder = this->GetProperty("FOLDER");
if (targetFolder) {
- effectiveFolder += targetFolder;
+ effectiveFolder += *targetFolder;
}
return effectiveFolder;
@@ -3074,7 +3067,7 @@ std::string cmGeneratorTarget::GetCompilePDBDirectory(
void cmGeneratorTarget::GetAppleArchs(const std::string& config,
std::vector<std::string>& archVec) const
{
- const char* archs = nullptr;
+ cmProp archs = nullptr;
if (!config.empty()) {
std::string defVarName =
cmStrCat("OSX_ARCHITECTURES_", cmSystemTools::UpperCase(config));
@@ -3084,7 +3077,7 @@ void cmGeneratorTarget::GetAppleArchs(const std::string& config,
archs = this->GetProperty("OSX_ARCHITECTURES");
}
if (archs) {
- cmExpandList(std::string(archs), archVec);
+ cmExpandList(*archs, archVec);
}
}
@@ -3640,7 +3633,7 @@ std::vector<BT<std::string>> cmGeneratorTarget::GetCompileDefinitions(
if (!config.empty()) {
std::string configPropName =
"COMPILE_DEFINITIONS_" + cmSystemTools::UpperCase(config);
- const char* configProp = this->GetProperty(configPropName);
+ cmProp configProp = this->GetProperty(configPropName);
if (configProp) {
switch (this->Makefile->GetPolicyStatus(cmPolicies::CMP0043)) {
case cmPolicies::WARN: {
@@ -3651,7 +3644,7 @@ std::vector<BT<std::string>> cmGeneratorTarget::GetCompileDefinitions(
}
case cmPolicies::OLD: {
std::unique_ptr<TargetPropertyEntry> entry =
- CreateTargetPropertyEntry(configProp);
+ CreateTargetPropertyEntry(*configProp);
entries.emplace_back(EvaluateTargetPropertyEntry(
this, config, language, &dagChecker, *entry));
} break;
@@ -3719,7 +3712,7 @@ std::string cmGeneratorTarget::GetPchHeader(const std::string& config,
return std::string();
}
const cmGeneratorTarget* generatorTarget = this;
- const char* pchReuseFrom =
+ cmProp pchReuseFrom =
generatorTarget->GetProperty("PRECOMPILE_HEADERS_REUSE_FROM");
const auto inserted =
@@ -3734,7 +3727,7 @@ std::string cmGeneratorTarget::GetPchHeader(const std::string& config,
if (pchReuseFrom) {
generatorTarget =
- this->GetGlobalGenerator()->FindGeneratorTarget(pchReuseFrom);
+ this->GetGlobalGenerator()->FindGeneratorTarget(*pchReuseFrom);
}
filename = cmStrCat(
@@ -3832,11 +3825,11 @@ std::string cmGeneratorTarget::GetPchSource(const std::string& config,
std::string& filename = inserted.first->second;
const cmGeneratorTarget* generatorTarget = this;
- const char* pchReuseFrom =
+ cmProp pchReuseFrom =
generatorTarget->GetProperty("PRECOMPILE_HEADERS_REUSE_FROM");
if (pchReuseFrom) {
generatorTarget =
- this->GetGlobalGenerator()->FindGeneratorTarget(pchReuseFrom);
+ this->GetGlobalGenerator()->FindGeneratorTarget(*pchReuseFrom);
}
filename =
@@ -3928,11 +3921,11 @@ std::string cmGeneratorTarget::GetPchFile(const std::string& config,
};
cmGeneratorTarget* generatorTarget = this;
- const char* pchReuseFrom =
+ cmProp pchReuseFrom =
generatorTarget->GetProperty("PRECOMPILE_HEADERS_REUSE_FROM");
if (pchReuseFrom) {
generatorTarget =
- this->GetGlobalGenerator()->FindGeneratorTarget(pchReuseFrom);
+ this->GetGlobalGenerator()->FindGeneratorTarget(*pchReuseFrom);
}
const std::string pchFileObject =
@@ -4210,8 +4203,8 @@ std::vector<BT<std::string>> cmGeneratorTarget::GetStaticLibraryLinkOptions(
nullptr, nullptr);
std::vector<EvaluatedTargetPropertyEntry> entries;
- if (const char* linkOptions = this->GetProperty("STATIC_LIBRARY_OPTIONS")) {
- std::vector<std::string> options = cmExpandedList(linkOptions);
+ if (cmProp linkOptions = this->GetProperty("STATIC_LIBRARY_OPTIONS")) {
+ std::vector<std::string> options = cmExpandedList(*linkOptions);
for (const auto& option : options) {
std::unique_ptr<TargetPropertyEntry> entry =
CreateTargetPropertyEntry(option);
@@ -4365,8 +4358,8 @@ std::vector<BT<std::string>> cmGeneratorTarget::GetLinkDepends(
nullptr);
std::vector<EvaluatedTargetPropertyEntry> entries;
- if (const char* linkDepends = this->GetProperty("LINK_DEPENDS")) {
- std::vector<std::string> depends = cmExpandedList(linkDepends);
+ if (cmProp linkDepends = this->GetProperty("LINK_DEPENDS")) {
+ std::vector<std::string> depends = cmExpandedList(*linkDepends);
for (const auto& depend : depends) {
std::unique_ptr<TargetPropertyEntry> entry =
CreateTargetPropertyEntry(depend);
@@ -4526,8 +4519,8 @@ cmGeneratorTarget::Names cmGeneratorTarget::GetLibraryNames(
}
// Check for library version properties.
- const char* version = this->GetProperty("VERSION");
- const char* soversion = this->GetProperty("SOVERSION");
+ cmProp version = this->GetProperty("VERSION");
+ cmProp soversion = this->GetProperty("SOVERSION");
if (!this->HasSOName(config) ||
this->Makefile->IsOn("CMAKE_PLATFORM_NO_VERSIONED_SONAME") ||
this->IsFrameworkOnApple()) {
@@ -4568,11 +4561,12 @@ cmGeneratorTarget::Names cmGeneratorTarget::GetLibraryNames(
// The library's soname.
this->ComputeVersionedName(targetNames.SharedObject, prefix,
targetNames.Base, suffix, targetNames.Output,
- soversion);
+ (soversion ? soversion->c_str() : nullptr));
// The library's real name on disk.
this->ComputeVersionedName(targetNames.Real, prefix, targetNames.Base,
- suffix, targetNames.Output, version);
+ suffix, targetNames.Output,
+ (version ? version->c_str() : nullptr));
}
// The import library name.
@@ -4605,10 +4599,13 @@ cmGeneratorTarget::Names cmGeneratorTarget::GetExecutableNames(
// This versioning is supported only for executables and then only
// when the platform supports symbolic links.
#if defined(_WIN32) && !defined(__CYGWIN__)
- const char* version = 0;
+ const char* version = nullptr;
#else
// Check for executable version properties.
- const char* version = this->GetProperty("VERSION");
+ const char* version = nullptr;
+ if (cmProp p = this->GetProperty("VERSION")) {
+ version = p->c_str();
+ }
if (this->GetType() != cmStateEnums::EXECUTABLE ||
this->Makefile->IsOn("XCODE")) {
version = nullptr;
@@ -4749,12 +4746,12 @@ void cmGeneratorTarget::GetFullNameInternal(
}
// Name shared libraries with their version number on some platforms.
- if (const char* soversion = this->GetProperty("SOVERSION")) {
+ if (cmProp soversion = this->GetProperty("SOVERSION")) {
if (this->GetType() == cmStateEnums::SHARED_LIBRARY &&
!isImportedLibraryArtifact &&
this->Makefile->IsOn("CMAKE_SHARED_LIBRARY_NAME_WITH_VERSION")) {
outBase += "-";
- outBase += soversion;
+ outBase += *soversion;
}
}
@@ -4785,8 +4782,8 @@ std::string cmGeneratorTarget::GetPDBOutputName(
props.emplace_back("PDB_NAME");
for (std::string const& p : props) {
- if (const char* outName = this->GetProperty(p)) {
- base = outName;
+ if (cmProp outName = this->GetProperty(p)) {
+ base = *outName;
break;
}
}
@@ -4812,8 +4809,8 @@ std::string cmGeneratorTarget::GetPDBName(const std::string& config) const
props.emplace_back("PDB_NAME");
for (std::string const& p : props) {
- if (const char* outName = this->GetProperty(p)) {
- base = outName;
+ if (cmProp outName = this->GetProperty(p)) {
+ base = *outName;
break;
}
}
@@ -4915,8 +4912,8 @@ void cmGeneratorTarget::ConstructSourceFileFlags() const
this->SourceFileFlagsConstructed = true;
// Process public headers to mark the source files.
- if (const char* files = this->GetProperty("PUBLIC_HEADER")) {
- std::vector<std::string> relFiles = cmExpandedList(files);
+ if (cmProp files = this->GetProperty("PUBLIC_HEADER")) {
+ std::vector<std::string> relFiles = cmExpandedList(*files);
for (std::string const& relFile : relFiles) {
if (cmSourceFile* sf = this->Makefile->GetSource(relFile)) {
SourceFileFlags& flags = this->SourceFlagsMap[sf];
@@ -4928,8 +4925,8 @@ void cmGeneratorTarget::ConstructSourceFileFlags() const
// Process private headers after public headers so that they take
// precedence if a file is listed in both.
- if (const char* files = this->GetProperty("PRIVATE_HEADER")) {
- std::vector<std::string> relFiles = cmExpandedList(files);
+ if (cmProp files = this->GetProperty("PRIVATE_HEADER")) {
+ std::vector<std::string> relFiles = cmExpandedList(*files);
for (std::string const& relFile : relFiles) {
if (cmSourceFile* sf = this->Makefile->GetSource(relFile)) {
SourceFileFlags& flags = this->SourceFlagsMap[sf];
@@ -4940,8 +4937,8 @@ void cmGeneratorTarget::ConstructSourceFileFlags() const
}
// Mark sources listed as resources.
- if (const char* files = this->GetProperty("RESOURCE")) {
- std::vector<std::string> relFiles = cmExpandedList(files);
+ if (cmProp files = this->GetProperty("RESOURCE")) {
+ std::vector<std::string> relFiles = cmExpandedList(*files);
for (std::string const& relFile : relFiles) {
if (cmSourceFile* sf = this->Makefile->GetSource(relFile)) {
SourceFileFlags& flags = this->SourceFlagsMap[sf];
@@ -4968,9 +4965,9 @@ cmGeneratorTarget::GetCompatibleInterfaces(std::string const& config) const
this->GetLinkImplementationClosure(config);
for (cmGeneratorTarget const* li : deps) {
#define CM_READ_COMPATIBLE_INTERFACE(X, x) \
- if (const char* prop = li->GetProperty("COMPATIBLE_INTERFACE_" #X)) { \
+ if (cmProp prop = li->GetProperty("COMPATIBLE_INTERFACE_" #X)) { \
std::vector<std::string> props; \
- cmExpandList(prop, props); \
+ cmExpandList(*prop, props); \
compat.Props##x.insert(props.begin(), props.end()); \
}
CM_READ_COMPATIBLE_INTERFACE(BOOL, Bool)
@@ -5078,12 +5075,12 @@ void checkPropertyConsistency(cmGeneratorTarget const* depender,
const std::string& config, CompatibleType t,
PropertyType* /*unused*/)
{
- const char* prop = dependee->GetProperty(propName);
+ cmProp prop = dependee->GetProperty(propName);
if (!prop) {
return;
}
- std::vector<std::string> props = cmExpandedList(prop);
+ std::vector<std::string> props = cmExpandedList(*prop);
std::string pdir =
cmStrCat(cmSystemTools::GetCMakeRoot(), "/Help/prop_tgt/");
@@ -5313,8 +5310,9 @@ bool getTypedProperty<bool>(cmGeneratorTarget const* tgt,
return tgt->GetPropertyAsBool(prop);
}
- const char* value = tgt->GetProperty(prop);
- return cmIsOn(genexInterpreter->Evaluate(value, prop));
+ cmProp value = tgt->GetProperty(prop);
+ return cmIsOn(
+ genexInterpreter->Evaluate(value ? value->c_str() : nullptr, prop));
}
template <>
@@ -5322,13 +5320,14 @@ const char* getTypedProperty<const char*>(
cmGeneratorTarget const* tgt, const std::string& prop,
cmGeneratorExpressionInterpreter* genexInterpreter)
{
- const char* value = tgt->GetProperty(prop);
+ cmProp value = tgt->GetProperty(prop);
if (genexInterpreter == nullptr) {
- return value;
+ return value ? value->c_str() : nullptr;
}
- return genexInterpreter->Evaluate(value, prop).c_str();
+ return genexInterpreter->Evaluate(value ? value->c_str() : nullptr, prop)
+ .c_str();
}
template <>
@@ -5336,13 +5335,13 @@ std::string getTypedProperty<std::string>(
cmGeneratorTarget const* tgt, const std::string& prop,
cmGeneratorExpressionInterpreter* genexInterpreter)
{
- const char* value = tgt->GetProperty(prop);
+ cmProp value = tgt->GetProperty(prop);
if (genexInterpreter == nullptr) {
- return valueAsString(value);
+ return valueAsString(value ? value->c_str() : nullptr);
}
- return genexInterpreter->Evaluate(value, prop);
+ return genexInterpreter->Evaluate(value ? value->c_str() : nullptr, prop);
}
template <typename PropertyType>
@@ -5713,13 +5712,13 @@ void cmGeneratorTarget::GetTargetVersion(const std::string& property,
assert(this->GetType() != cmStateEnums::INTERFACE_LIBRARY);
- if (const char* version = this->GetProperty(property)) {
+ if (cmProp version = this->GetProperty(property)) {
// Try to parse the version number and store the results that were
// successfully parsed.
int parsed_major;
int parsed_minor;
int parsed_patch;
- switch (sscanf(version, "%d.%d.%d", &parsed_major, &parsed_minor,
+ switch (sscanf(version->c_str(), "%d.%d.%d", &parsed_major, &parsed_minor,
&parsed_patch)) {
case 3:
patch = parsed_patch;
@@ -5753,8 +5752,8 @@ std::string cmGeneratorTarget::CreateFortranModuleDirectory(
{
std::string mod_dir;
std::string target_mod_dir;
- if (const char* prop = this->GetProperty("Fortran_MODULE_DIRECTORY")) {
- target_mod_dir = prop;
+ if (cmProp prop = this->GetProperty("Fortran_MODULE_DIRECTORY")) {
+ target_mod_dir = *prop;
} else {
std::string const& default_mod_dir =
this->LocalGenerator->GetCurrentBinaryDirectory();
@@ -5785,11 +5784,11 @@ std::string cmGeneratorTarget::GetFrameworkVersion() const
{
assert(this->GetType() != cmStateEnums::INTERFACE_LIBRARY);
- if (const char* fversion = this->GetProperty("FRAMEWORK_VERSION")) {
- return fversion;
+ if (cmProp fversion = this->GetProperty("FRAMEWORK_VERSION")) {
+ return *fversion;
}
- if (const char* tversion = this->GetProperty("VERSION")) {
- return tversion;
+ if (cmProp tversion = this->GetProperty("VERSION")) {
+ return *tversion;
}
return "A";
}
@@ -6025,11 +6024,11 @@ void cmGeneratorTarget::ComputeLinkInterface(
// How many repetitions are needed if this library has cyclic
// dependencies?
std::string propName = cmStrCat("LINK_INTERFACE_MULTIPLICITY", suffix);
- if (const char* config_reps = this->GetProperty(propName)) {
- sscanf(config_reps, "%u", &iface.Multiplicity);
- } else if (const char* reps =
+ if (cmProp config_reps = this->GetProperty(propName)) {
+ sscanf(config_reps->c_str(), "%u", &iface.Multiplicity);
+ } else if (cmProp reps =
this->GetProperty("LINK_INTERFACE_MULTIPLICITY")) {
- sscanf(reps, "%u", &iface.Multiplicity);
+ sscanf(reps->c_str(), "%u", &iface.Multiplicity);
}
}
}
@@ -6179,21 +6178,21 @@ bool cmGeneratorTarget::ComputeOutputDir(const std::string& config,
}
// Select an output directory.
- if (const char* config_outdir = this->GetProperty(configProp)) {
+ if (cmProp config_outdir = this->GetProperty(configProp)) {
// Use the user-specified per-configuration output directory.
- out = cmGeneratorExpression::Evaluate(config_outdir, this->LocalGenerator,
+ out = cmGeneratorExpression::Evaluate(*config_outdir, this->LocalGenerator,
config);
// Skip per-configuration subdirectory.
conf.clear();
- } else if (const char* outdir = this->GetProperty(propertyName)) {
+ } else if (cmProp outdir = this->GetProperty(propertyName)) {
// Use the user-specified output directory.
out =
- cmGeneratorExpression::Evaluate(outdir, this->LocalGenerator, config);
+ cmGeneratorExpression::Evaluate(*outdir, this->LocalGenerator, config);
// Skip per-configuration subdirectory if the value contained a
// generator expression.
- if (out != outdir) {
+ if (out != *outdir) {
conf.clear();
}
} else if (this->GetType() == cmStateEnums::EXECUTABLE) {
@@ -6255,21 +6254,21 @@ bool cmGeneratorTarget::ComputePDBOutputDir(const std::string& kind,
}
// Select an output directory.
- if (const char* config_outdir = this->GetProperty(configProp)) {
+ if (cmProp config_outdir = this->GetProperty(configProp)) {
// Use the user-specified per-configuration output directory.
- out = cmGeneratorExpression::Evaluate(config_outdir, this->LocalGenerator,
+ out = cmGeneratorExpression::Evaluate(*config_outdir, this->LocalGenerator,
config);
// Skip per-configuration subdirectory.
conf.clear();
- } else if (const char* outdir = this->GetProperty(propertyName)) {
+ } else if (cmProp outdir = this->GetProperty(propertyName)) {
// Use the user-specified output directory.
out =
- cmGeneratorExpression::Evaluate(outdir, this->LocalGenerator, config);
+ cmGeneratorExpression::Evaluate(*outdir, this->LocalGenerator, config);
// Skip per-configuration subdirectory if the value contained a
// generator expression.
- if (out != outdir) {
+ if (out != *outdir) {
conf.clear();
}
}
@@ -6315,12 +6314,13 @@ bool cmGeneratorTarget::GetRPATH(const std::string& config,
const std::string& prop,
std::string& rpath) const
{
- const char* value = this->GetProperty(prop);
+ cmProp value = this->GetProperty(prop);
if (!value) {
return false;
}
- rpath = cmGeneratorExpression::Evaluate(value, this->LocalGenerator, config);
+ rpath =
+ cmGeneratorExpression::Evaluate(*value, this->LocalGenerator, config);
return true;
}
@@ -6339,7 +6339,7 @@ void cmGeneratorTarget::ComputeLinkInterfaceLibraries(
// An explicit list of interface libraries may be set for shared
// libraries and executables that export symbols.
- const char* explicitLibraries = nullptr;
+ cmProp explicitLibraries = nullptr;
std::string linkIfaceProp;
bool const cmp0022NEW = (this->GetPolicyStatusCMP0022() != cmPolicies::OLD &&
this->GetPolicyStatusCMP0022() != cmPolicies::WARN);
@@ -6368,10 +6368,10 @@ void cmGeneratorTarget::ComputeLinkInterfaceLibraries(
!this->PolicyWarnedCMP0022) {
// Compare the explicitly set old link interface properties to the
// preferred new link interface property one and warn if different.
- const char* newExplicitLibraries =
+ cmProp newExplicitLibraries =
this->GetProperty("INTERFACE_LINK_LIBRARIES");
if (newExplicitLibraries &&
- strcmp(newExplicitLibraries, explicitLibraries) != 0) {
+ (*newExplicitLibraries != *explicitLibraries)) {
std::ostringstream w;
/* clang-format off */
w << cmPolicies::GetPolicyWarning(cmPolicies::CMP0022) << "\n"
@@ -6380,9 +6380,9 @@ void cmGeneratorTarget::ComputeLinkInterfaceLibraries(
linkIfaceProp << " properties."
"\n"
"INTERFACE_LINK_LIBRARIES:\n"
- " " << newExplicitLibraries << "\n" <<
+ " " << *newExplicitLibraries << "\n" <<
linkIfaceProp << ":\n"
- " " << explicitLibraries << "\n";
+ " " << *explicitLibraries << "\n";
/* clang-format on */
this->LocalGenerator->IssueMessage(MessageType::AUTHOR_WARNING, w.str());
this->PolicyWarnedCMP0022 = true;
@@ -6401,8 +6401,8 @@ void cmGeneratorTarget::ComputeLinkInterfaceLibraries(
if (explicitLibraries) {
// The interface libraries have been explicitly set.
- this->ExpandLinkItems(linkIfaceProp, explicitLibraries, config, headTarget,
- usage_requirements_only, iface.Libraries,
+ this->ExpandLinkItems(linkIfaceProp, *explicitLibraries, config,
+ headTarget, usage_requirements_only, iface.Libraries,
iface.HadHeadSensitiveCondition,
iface.HadLinkLanguageSensitiveCondition);
} else if (!cmp0022NEW)
@@ -6422,10 +6422,10 @@ void cmGeneratorTarget::ComputeLinkInterfaceLibraries(
// preferred new link interface property and warn if different.
std::vector<cmLinkItem> ifaceLibs;
static const std::string newProp = "INTERFACE_LINK_LIBRARIES";
- if (const char* newExplicitLibraries = this->GetProperty(newProp)) {
+ if (cmProp newExplicitLibraries = this->GetProperty(newProp)) {
bool hadHeadSensitiveConditionDummy = false;
bool hadLinkLanguageSensitiveConditionDummy = false;
- this->ExpandLinkItems(newProp, newExplicitLibraries, config,
+ this->ExpandLinkItems(newProp, *newExplicitLibraries, config,
headTarget, usage_requirements_only, ifaceLibs,
hadHeadSensitiveConditionDummy,
hadLinkLanguageSensitiveConditionDummy);
@@ -6561,7 +6561,7 @@ void cmGeneratorTarget::ComputeImportInfo(std::string const& desired_config,
// Get the link interface.
{
std::string linkProp = "INTERFACE_LINK_LIBRARIES";
- const char* propertyLibs = this->GetProperty(linkProp);
+ cmProp propertyLibs = this->GetProperty(linkProp);
if (this->GetType() != cmStateEnums::INTERFACE_LIBRARY) {
if (!propertyLibs) {
@@ -6576,7 +6576,7 @@ void cmGeneratorTarget::ComputeImportInfo(std::string const& desired_config,
}
if (propertyLibs) {
info.LibrariesProp = linkProp;
- info.Libraries = propertyLibs;
+ info.Libraries = *propertyLibs;
}
}
if (this->GetType() == cmStateEnums::INTERFACE_LIBRARY) {
@@ -6594,31 +6594,30 @@ void cmGeneratorTarget::ComputeImportInfo(std::string const& desired_config,
info.Location = *loc;
} else {
std::string impProp = cmStrCat("IMPORTED_LOCATION", suffix);
- if (const char* config_location = this->GetProperty(impProp)) {
- info.Location = config_location;
- } else if (const char* location = this->GetProperty("IMPORTED_LOCATION")) {
- info.Location = location;
+ if (cmProp config_location = this->GetProperty(impProp)) {
+ info.Location = *config_location;
+ } else if (cmProp location = this->GetProperty("IMPORTED_LOCATION")) {
+ info.Location = *location;
}
}
// Get the soname.
if (this->GetType() == cmStateEnums::SHARED_LIBRARY) {
std::string soProp = cmStrCat("IMPORTED_SONAME", suffix);
- if (const char* config_soname = this->GetProperty(soProp)) {
- info.SOName = config_soname;
- } else if (const char* soname = this->GetProperty("IMPORTED_SONAME")) {
- info.SOName = soname;
+ if (cmProp config_soname = this->GetProperty(soProp)) {
+ info.SOName = *config_soname;
+ } else if (cmProp soname = this->GetProperty("IMPORTED_SONAME")) {
+ info.SOName = *soname;
}
}
// Get the "no-soname" mark.
if (this->GetType() == cmStateEnums::SHARED_LIBRARY) {
std::string soProp = cmStrCat("IMPORTED_NO_SONAME", suffix);
- if (const char* config_no_soname = this->GetProperty(soProp)) {
- info.NoSOName = cmIsOn(config_no_soname);
- } else if (const char* no_soname =
- this->GetProperty("IMPORTED_NO_SONAME")) {
- info.NoSOName = cmIsOn(no_soname);
+ if (cmProp config_no_soname = this->GetProperty(soProp)) {
+ info.NoSOName = cmIsOn(*config_no_soname);
+ } else if (cmProp no_soname = this->GetProperty("IMPORTED_NO_SONAME")) {
+ info.NoSOName = cmIsOn(*no_soname);
}
}
@@ -6628,10 +6627,10 @@ void cmGeneratorTarget::ComputeImportInfo(std::string const& desired_config,
} else if (this->GetType() == cmStateEnums::SHARED_LIBRARY ||
this->IsExecutableWithExports()) {
std::string impProp = cmStrCat("IMPORTED_IMPLIB", suffix);
- if (const char* config_implib = this->GetProperty(impProp)) {
- info.ImportLibrary = config_implib;
- } else if (const char* implib = this->GetProperty("IMPORTED_IMPLIB")) {
- info.ImportLibrary = implib;
+ if (cmProp config_implib = this->GetProperty(impProp)) {
+ info.ImportLibrary = *config_implib;
+ } else if (cmProp implib = this->GetProperty("IMPORTED_IMPLIB")) {
+ info.ImportLibrary = *implib;
}
}
@@ -6639,11 +6638,11 @@ void cmGeneratorTarget::ComputeImportInfo(std::string const& desired_config,
{
std::string linkProp =
cmStrCat("IMPORTED_LINK_DEPENDENT_LIBRARIES", suffix);
- if (const char* config_libs = this->GetProperty(linkProp)) {
- info.SharedDeps = config_libs;
- } else if (const char* libs =
+ if (cmProp config_libs = this->GetProperty(linkProp)) {
+ info.SharedDeps = *config_libs;
+ } else if (cmProp libs =
this->GetProperty("IMPORTED_LINK_DEPENDENT_LIBRARIES")) {
- info.SharedDeps = libs;
+ info.SharedDeps = *libs;
}
}
@@ -6651,21 +6650,21 @@ void cmGeneratorTarget::ComputeImportInfo(std::string const& desired_config,
if (this->LinkLanguagePropagatesToDependents()) {
std::string linkProp =
cmStrCat("IMPORTED_LINK_INTERFACE_LANGUAGES", suffix);
- if (const char* config_libs = this->GetProperty(linkProp)) {
- info.Languages = config_libs;
- } else if (const char* libs =
+ if (cmProp config_libs = this->GetProperty(linkProp)) {
+ info.Languages = *config_libs;
+ } else if (cmProp libs =
this->GetProperty("IMPORTED_LINK_INTERFACE_LANGUAGES")) {
- info.Languages = libs;
+ info.Languages = *libs;
}
}
// Get information if target is managed assembly.
{
std::string linkProp = "IMPORTED_COMMON_LANGUAGE_RUNTIME";
- if (auto pc = this->GetProperty(linkProp + suffix)) {
- info.Managed = this->CheckManagedType(pc);
- } else if (auto p = this->GetProperty(linkProp)) {
- info.Managed = this->CheckManagedType(p);
+ if (cmProp pc = this->GetProperty(linkProp + suffix)) {
+ info.Managed = this->CheckManagedType(*pc);
+ } else if (cmProp p = this->GetProperty(linkProp)) {
+ info.Managed = this->CheckManagedType(*p);
}
}
@@ -6673,11 +6672,11 @@ void cmGeneratorTarget::ComputeImportInfo(std::string const& desired_config,
if (this->GetType() == cmStateEnums::STATIC_LIBRARY) {
std::string linkProp =
cmStrCat("IMPORTED_LINK_INTERFACE_MULTIPLICITY", suffix);
- if (const char* config_reps = this->GetProperty(linkProp)) {
- sscanf(config_reps, "%u", &info.Multiplicity);
- } else if (const char* reps =
+ if (cmProp config_reps = this->GetProperty(linkProp)) {
+ sscanf(config_reps->c_str(), "%u", &info.Multiplicity);
+ } else if (cmProp reps =
this->GetProperty("IMPORTED_LINK_INTERFACE_MULTIPLICITY")) {
- sscanf(reps, "%u", &info.Multiplicity);
+ sscanf(reps->c_str(), "%u", &info.Multiplicity);
}
}
}
@@ -6853,15 +6852,15 @@ std::string cmGeneratorTarget::CheckCMP0004(std::string const& item) const
bool cmGeneratorTarget::IsDeprecated() const
{
- const char* deprecation = this->GetProperty("DEPRECATION");
- return deprecation && *deprecation;
+ cmProp deprecation = this->GetProperty("DEPRECATION");
+ return deprecation && !deprecation->empty();
}
std::string cmGeneratorTarget::GetDeprecation() const
{
// find DEPRECATION property
- if (const char* deprecation = this->GetProperty("DEPRECATION")) {
- return deprecation;
+ if (cmProp deprecation = this->GetProperty("DEPRECATION")) {
+ return *deprecation;
}
return std::string();
}
@@ -6918,9 +6917,9 @@ bool cmGeneratorTarget::IsCSharpOnly() const
std::set<std::string> languages = this->GetAllConfigCompileLanguages();
// Consider an explicit linker language property, but *not* the
// computed linker language that may depend on linked targets.
- const char* linkLang = this->GetProperty("LINKER_LANGUAGE");
- if (linkLang && *linkLang) {
- languages.insert(linkLang);
+ cmProp linkLang = this->GetProperty("LINKER_LANGUAGE");
+ if (linkLang && !linkLang->empty()) {
+ languages.insert(*linkLang);
}
return languages.size() == 1 && languages.count("CSharp") > 0;
}
@@ -7298,8 +7297,8 @@ cmGeneratorTarget::ManagedType cmGeneratorTarget::GetManagedType(
}
// Check for explicitly set clr target property.
- if (auto* clr = this->GetProperty("COMMON_LANGUAGE_RUNTIME")) {
- return this->CheckManagedType(clr);
+ if (cmProp clr = this->GetProperty("COMMON_LANGUAGE_RUNTIME")) {
+ return this->CheckManagedType(*clr);
}
// C# targets are always managed. This language specific check
diff --git a/Source/cmGeneratorTarget.h b/Source/cmGeneratorTarget.h
index dd46bb9..dc98407 100644
--- a/Source/cmGeneratorTarget.h
+++ b/Source/cmGeneratorTarget.h
@@ -31,6 +31,8 @@ class cmTarget;
struct cmGeneratorExpressionContext;
struct cmGeneratorExpressionDAGChecker;
+using cmProp = const std::string*;
+
class cmGeneratorTarget
{
public:
@@ -76,7 +78,7 @@ public:
std::vector<std::string> GetPropertyKeys() const;
//! Might return a nullptr if the property is not set or invalid
- const char* GetProperty(const std::string& prop) const;
+ cmProp GetProperty(const std::string& prop) const;
//! Always returns a valid pointer
const char* GetSafeProperty(const std::string& prop) const;
bool GetPropertyAsBool(const std::string& prop) const;
diff --git a/Source/cmGhsMultiTargetGenerator.cxx b/Source/cmGhsMultiTargetGenerator.cxx
index f0c6d48..a5e496b 100644
--- a/Source/cmGhsMultiTargetGenerator.cxx
+++ b/Source/cmGhsMultiTargetGenerator.cxx
@@ -14,7 +14,7 @@
#include "cmGeneratedFileStream.h"
#include "cmGeneratorTarget.h"
#include "cmGlobalGhsMultiGenerator.h"
-#include "cmLinkLineComputer.h"
+#include "cmLinkLineComputer.h" // IWYU pragma: keep
#include "cmLocalGenerator.h"
#include "cmLocalGhsMultiGenerator.h"
#include "cmMakefile.h"
@@ -549,8 +549,8 @@ void cmGhsMultiTargetGenerator::WriteSources(std::ostream& fout_proj)
*/
for (auto& sg : groupFilesList) {
std::ostream* fout;
- bool useProjectFile =
- cmIsOn(this->GeneratorTarget->GetProperty("GHS_NO_SOURCE_GROUP_FILE")) ||
+ bool useProjectFile = cmIsOn(*this->GeneratorTarget->GetProperty(
+ "GHS_NO_SOURCE_GROUP_FILE")) ||
cmIsOn(this->Makefile->GetDefinition("CMAKE_GHS_NO_SOURCE_GROUP_FILE"));
if (useProjectFile || sg.empty()) {
fout = &fout_proj;
@@ -720,9 +720,9 @@ void cmGhsMultiTargetGenerator::WriteObjectLangOverride(
bool cmGhsMultiTargetGenerator::DetermineIfIntegrityApp()
{
- const char* p = this->GeneratorTarget->GetProperty("ghs_integrity_app");
+ cmProp p = this->GeneratorTarget->GetProperty("ghs_integrity_app");
if (p) {
- return cmIsOn(this->GeneratorTarget->GetProperty("ghs_integrity_app"));
+ return cmIsOn(*p);
}
std::vector<cmSourceFile*> sources;
this->GeneratorTarget->GetSourceFiles(sources, this->ConfigName);
diff --git a/Source/cmGlobalCommonGenerator.cxx b/Source/cmGlobalCommonGenerator.cxx
index e04eef1..f57ef04 100644
--- a/Source/cmGlobalCommonGenerator.cxx
+++ b/Source/cmGlobalCommonGenerator.cxx
@@ -45,8 +45,8 @@ cmGlobalCommonGenerator::ComputeDirectoryTargets() const
}
DirectoryTarget::Target t;
t.GT = gt.get();
- if (const char* exclude = gt->GetProperty("EXCLUDE_FROM_ALL")) {
- if (cmIsOn(exclude)) {
+ if (cmProp exclude = gt->GetProperty("EXCLUDE_FROM_ALL")) {
+ if (cmIsOn(*exclude)) {
// This target has been explicitly excluded.
t.ExcludeFromAll = true;
} else {
diff --git a/Source/cmGlobalGenerator.cxx b/Source/cmGlobalGenerator.cxx
index a6ca75f..2664fb0 100644
--- a/Source/cmGlobalGenerator.cxx
+++ b/Source/cmGlobalGenerator.cxx
@@ -303,10 +303,14 @@ bool cmGlobalGenerator::CheckTargetsForMissingSources() const
for (const auto& target : localGen->GetGeneratorTargets()) {
if (target->GetType() == cmStateEnums::TargetType::GLOBAL_TARGET ||
target->GetType() == cmStateEnums::TargetType::INTERFACE_LIBRARY ||
- target->GetType() == cmStateEnums::TargetType::UTILITY ||
- cmIsOn(target->GetProperty("ghs_integrity_app"))) {
+ target->GetType() == cmStateEnums::TargetType::UTILITY) {
continue;
}
+ if (cmProp p = target->GetProperty("ghs_integrity_app")) {
+ if (cmIsOn(*p)) {
+ continue;
+ }
+ }
std::vector<std::string> configs;
target->Makefile->GetConfigurations(configs);
@@ -371,10 +375,14 @@ bool cmGlobalGenerator::CheckTargetsForPchCompilePdb() const
for (const auto& target : generator->GetGeneratorTargets()) {
if (target->GetType() == cmStateEnums::TargetType::GLOBAL_TARGET ||
target->GetType() == cmStateEnums::TargetType::INTERFACE_LIBRARY ||
- target->GetType() == cmStateEnums::TargetType::UTILITY ||
- cmIsOn(target->GetProperty("ghs_integrity_app"))) {
+ target->GetType() == cmStateEnums::TargetType::UTILITY) {
continue;
}
+ if (cmProp p = target->GetProperty("ghs_integrity_app")) {
+ if (cmIsOn(*p)) {
+ continue;
+ }
+ }
const std::string reuseFrom =
target->GetSafeProperty("PRECOMPILE_HEADERS_REUSE_FROM");
@@ -2160,8 +2168,8 @@ bool cmGlobalGenerator::IsExcluded(cmLocalGenerator* root,
if (target->GetType() == cmStateEnums::INTERFACE_LIBRARY) {
return true;
}
- if (const char* exclude = target->GetProperty("EXCLUDE_FROM_ALL")) {
- return cmIsOn(exclude);
+ if (cmProp exclude = target->GetProperty("EXCLUDE_FROM_ALL")) {
+ return cmIsOn(*exclude);
}
// This target is included in its directory. Check whether the
// directory is excluded.
@@ -3040,7 +3048,7 @@ void cmGlobalGenerator::WriteSummary(cmGeneratorTarget* target)
#ifndef CMAKE_BOOTSTRAP
// Check whether labels are enabled for this target.
- const char* targetLabels = target->GetProperty("LABELS");
+ cmProp targetLabels = target->GetProperty("LABELS");
cmProp directoryLabels =
target->Target->GetMakefile()->GetProperty("LABELS");
const char* cmakeDirectoryLabels =
@@ -3060,7 +3068,7 @@ void cmGlobalGenerator::WriteSummary(cmGeneratorTarget* target)
// List the target-wide labels. All sources in the target get
// these labels.
if (targetLabels) {
- cmExpandList(targetLabels, labels);
+ cmExpandList(*targetLabels, labels);
if (!labels.empty()) {
fout << "# Target labels\n";
for (std::string const& l : labels) {
diff --git a/Source/cmGlobalGhsMultiGenerator.cxx b/Source/cmGlobalGhsMultiGenerator.cxx
index 24559e6..651bfbd 100644
--- a/Source/cmGlobalGhsMultiGenerator.cxx
+++ b/Source/cmGlobalGhsMultiGenerator.cxx
@@ -376,8 +376,8 @@ void cmGlobalGhsMultiGenerator::WriteProjectLine(
std::ostream& fout, cmGeneratorTarget const* target, cmLocalGenerator* root,
std::string& rootBinaryDir)
{
- const char* projName = target->GetProperty("GENERATOR_FILE_NAME");
- const char* projType = target->GetProperty("GENERATOR_FILE_NAME_EXT");
+ cmProp projName = target->GetProperty("GENERATOR_FILE_NAME");
+ cmProp projType = target->GetProperty("GENERATOR_FILE_NAME_EXT");
if (projName && projType) {
cmLocalGenerator* lg = target->GetLocalGenerator();
std::string dir = lg->GetCurrentBinaryDirectory();
@@ -390,9 +390,9 @@ void cmGlobalGhsMultiGenerator::WriteProjectLine(
}
}
- std::string projFile = dir + projName + FILE_EXTENSION;
+ std::string projFile = dir + *projName + FILE_EXTENSION;
fout << projFile;
- fout << ' ' << projType << '\n';
+ fout << ' ' << *projType << '\n';
} else {
/* Should never happen */
std::string message =
@@ -469,7 +469,8 @@ void cmGlobalGhsMultiGenerator::WriteAllTarget(
if (t->GetType() == cmStateEnums::INTERFACE_LIBRARY) {
continue;
}
- if (!cmIsOn(t->GetProperty("EXCLUDE_FROM_ALL"))) {
+ cmProp p = t->GetProperty("EXCLUDE_FROM_ALL");
+ if (!(p && cmIsOn(*p))) {
defaultTargets.push_back(t);
}
}
diff --git a/Source/cmGlobalVisualStudio71Generator.cxx b/Source/cmGlobalVisualStudio71Generator.cxx
index d0aec61..7ada325 100644
--- a/Source/cmGlobalVisualStudio71Generator.cxx
+++ b/Source/cmGlobalVisualStudio71Generator.cxx
@@ -91,7 +91,7 @@ void cmGlobalVisualStudio71Generator::WriteProject(std::ostream& fout,
cmGeneratorTarget const* t)
{
// check to see if this is a fortran build
- const char* ext = ".vcproj";
+ std::string ext = ".vcproj";
const char* project =
"Project(\"{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}\") = \"";
if (this->TargetIsFortranOnly(t)) {
@@ -102,9 +102,9 @@ void cmGlobalVisualStudio71Generator::WriteProject(std::ostream& fout,
ext = ".csproj";
project = "Project(\"{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}\") = \"";
}
- const char* targetExt = t->GetProperty("GENERATOR_FILE_NAME_EXT");
+ cmProp targetExt = t->GetProperty("GENERATOR_FILE_NAME_EXT");
if (targetExt) {
- ext = targetExt;
+ ext = *targetExt;
}
std::string guid = this->GetGUID(dspname);
@@ -198,9 +198,9 @@ void cmGlobalVisualStudio71Generator::WriteProjectConfigurations(
std::vector<std::string> mapConfig;
const char* dstConfig = i.c_str();
if (target.GetProperty("EXTERNAL_MSPROJECT")) {
- if (const char* m = target.GetProperty("MAP_IMPORTED_CONFIG_" +
- cmSystemTools::UpperCase(i))) {
- cmExpandList(m, mapConfig);
+ if (cmProp m = target.GetProperty("MAP_IMPORTED_CONFIG_" +
+ cmSystemTools::UpperCase(i))) {
+ cmExpandList(*m, mapConfig);
if (!mapConfig.empty()) {
dstConfig = mapConfig[0].c_str();
}
diff --git a/Source/cmGlobalVisualStudio7Generator.cxx b/Source/cmGlobalVisualStudio7Generator.cxx
index 4b8010a..428c748 100644
--- a/Source/cmGlobalVisualStudio7Generator.cxx
+++ b/Source/cmGlobalVisualStudio7Generator.cxx
@@ -342,19 +342,19 @@ void cmGlobalVisualStudio7Generator::WriteTargetConfigurations(
if (target->GetType() == cmStateEnums::INTERFACE_LIBRARY) {
continue;
}
- const char* expath = target->GetProperty("EXTERNAL_MSPROJECT");
+ cmProp expath = target->GetProperty("EXTERNAL_MSPROJECT");
if (expath) {
std::set<std::string> allConfigurations(configs.begin(), configs.end());
- const char* mapping = target->GetProperty("VS_PLATFORM_MAPPING");
+ cmProp mapping = target->GetProperty("VS_PLATFORM_MAPPING");
this->WriteProjectConfigurations(fout, target->GetName(), *target,
configs, allConfigurations,
- mapping ? mapping : "");
+ mapping ? *mapping : "");
} else {
const std::set<std::string>& configsPartOfDefaultBuild =
this->IsPartOfDefaultBuild(configs, projectTargets, target);
- const char* vcprojName = target->GetProperty("GENERATOR_FILE_NAME");
+ cmProp vcprojName = target->GetProperty("GENERATOR_FILE_NAME");
if (vcprojName) {
- this->WriteProjectConfigurations(fout, vcprojName, *target, configs,
+ this->WriteProjectConfigurations(fout, *vcprojName, *target, configs,
configsPartOfDefaultBuild);
}
}
@@ -375,17 +375,18 @@ void cmGlobalVisualStudio7Generator::WriteTargetsToSolution(
bool written = false;
// handle external vc project files
- const char* expath = target->GetProperty("EXTERNAL_MSPROJECT");
+ cmProp expath = target->GetProperty("EXTERNAL_MSPROJECT");
if (expath) {
std::string project = target->GetName();
- std::string location = expath;
+ std::string location = *expath;
+ cmProp p = target->GetProperty("VS_PROJECT_TYPE");
this->WriteExternalProject(fout, project, location,
- target->GetProperty("VS_PROJECT_TYPE"),
+ p ? p->c_str() : nullptr,
target->GetUtilities());
written = true;
} else {
- const char* vcprojName = target->GetProperty("GENERATOR_FILE_NAME");
+ cmProp vcprojName = target->GetProperty("GENERATOR_FILE_NAME");
if (vcprojName) {
cmLocalGenerator* lg = target->GetLocalGenerator();
std::string dir = lg->GetCurrentBinaryDirectory();
@@ -393,7 +394,7 @@ void cmGlobalVisualStudio7Generator::WriteTargetsToSolution(
if (dir == ".") {
dir.clear(); // msbuild cannot handle ".\" prefix
}
- this->WriteProject(fout, vcprojName, dir, target);
+ this->WriteProject(fout, *vcprojName, dir, target);
written = true;
}
}
@@ -438,11 +439,11 @@ void cmGlobalVisualStudio7Generator::WriteTargetDepends(
if (target->GetType() == cmStateEnums::INTERFACE_LIBRARY) {
continue;
}
- const char* vcprojName = target->GetProperty("GENERATOR_FILE_NAME");
+ cmProp vcprojName = target->GetProperty("GENERATOR_FILE_NAME");
if (vcprojName) {
std::string dir =
target->GetLocalGenerator()->GetCurrentSourceDirectory();
- this->WriteProjectDepends(fout, vcprojName, dir.c_str(), target);
+ this->WriteProjectDepends(fout, *vcprojName, dir, target);
}
}
}
diff --git a/Source/cmGlobalVisualStudio8Generator.cxx b/Source/cmGlobalVisualStudio8Generator.cxx
index 1df76ca..29ca154 100644
--- a/Source/cmGlobalVisualStudio8Generator.cxx
+++ b/Source/cmGlobalVisualStudio8Generator.cxx
@@ -244,9 +244,9 @@ void cmGlobalVisualStudio8Generator::WriteProjectConfigurations(
std::vector<std::string> mapConfig;
const char* dstConfig = i.c_str();
if (target.GetProperty("EXTERNAL_MSPROJECT")) {
- if (const char* m = target.GetProperty("MAP_IMPORTED_CONFIG_" +
- cmSystemTools::UpperCase(i))) {
- cmExpandList(m, mapConfig);
+ if (cmProp m = target.GetProperty("MAP_IMPORTED_CONFIG_" +
+ cmSystemTools::UpperCase(i))) {
+ cmExpandList(*m, mapConfig);
if (!mapConfig.empty()) {
dstConfig = mapConfig[0].c_str();
}
@@ -286,15 +286,15 @@ bool cmGlobalVisualStudio8Generator::NeedsDeploy(
return false;
}
- if (const char* prop = target.GetProperty("VS_SOLUTION_DEPLOY")) {
+ if (cmProp prop = target.GetProperty("VS_SOLUTION_DEPLOY")) {
// If set, it dictates behavior
return cmIsOn(
- cmGeneratorExpression::Evaluate(prop, target.LocalGenerator, config));
+ cmGeneratorExpression::Evaluate(*prop, target.LocalGenerator, config));
}
// To be deprecated, disable deployment even if target supports it.
- if (const char* prop = target.GetProperty("VS_NO_SOLUTION_DEPLOY")) {
- if (cmIsOn(cmGeneratorExpression::Evaluate(prop, target.LocalGenerator,
+ if (cmProp prop = target.GetProperty("VS_NO_SOLUTION_DEPLOY")) {
+ if (cmIsOn(cmGeneratorExpression::Evaluate(*prop, target.LocalGenerator,
config))) {
// If true, always disable deployment
return false;
diff --git a/Source/cmGlobalVisualStudioGenerator.cxx b/Source/cmGlobalVisualStudioGenerator.cxx
index b9f4609..28bd1ca 100644
--- a/Source/cmGlobalVisualStudioGenerator.cxx
+++ b/Source/cmGlobalVisualStudioGenerator.cxx
@@ -808,9 +808,9 @@ bool cmGlobalVisualStudioGenerator::TargetIsFortranOnly(
// This allows the project to control the language choice in
// a target with none of its own sources, e.g. when also using
// object libraries.
- const char* linkLang = gt->GetProperty("LINKER_LANGUAGE");
- if (linkLang && *linkLang) {
- languages.insert(linkLang);
+ cmProp linkLang = gt->GetProperty("LINKER_LANGUAGE");
+ if (linkLang && !linkLang->empty()) {
+ languages.insert(*linkLang);
}
// Intel Fortran .vfproj files do support the resource compiler.
diff --git a/Source/cmGlobalXCodeGenerator.cxx b/Source/cmGlobalXCodeGenerator.cxx
index f305246..77fa6fa 100644
--- a/Source/cmGlobalXCodeGenerator.cxx
+++ b/Source/cmGlobalXCodeGenerator.cxx
@@ -1867,16 +1867,16 @@ void cmGlobalXCodeGenerator::CreateBuildSettings(cmGeneratorTarget* gtgt,
this->CurrentLocalGenerator->GetStaticLibraryFlags(
extraLinkOptions, configName, llang, gtgt);
} else {
- const char* targetLinkFlags = gtgt->GetProperty("LINK_FLAGS");
+ cmProp targetLinkFlags = gtgt->GetProperty("LINK_FLAGS");
if (targetLinkFlags) {
this->CurrentLocalGenerator->AppendFlags(extraLinkOptions,
- targetLinkFlags);
+ *targetLinkFlags);
}
if (!configName.empty()) {
std::string linkFlagsVar =
cmStrCat("LINK_FLAGS_", cmSystemTools::UpperCase(configName));
- if (const char* linkFlags = gtgt->GetProperty(linkFlagsVar)) {
- this->CurrentLocalGenerator->AppendFlags(extraLinkOptions, linkFlags);
+ if (cmProp linkFlags = gtgt->GetProperty(linkFlagsVar)) {
+ this->CurrentLocalGenerator->AppendFlags(extraLinkOptions, *linkFlags);
}
}
std::vector<std::string> opts;
@@ -1912,8 +1912,8 @@ void cmGlobalXCodeGenerator::CreateBuildSettings(cmGeneratorTarget* gtgt,
std::string pnsuffix;
gtgt->GetFullNameComponents(pnprefix, pnbase, pnsuffix, configName);
- const char* version = gtgt->GetProperty("VERSION");
- const char* soversion = gtgt->GetProperty("SOVERSION");
+ cmProp version = gtgt->GetProperty("VERSION");
+ cmProp soversion = gtgt->GetProperty("SOVERSION");
if (!gtgt->HasSOName(configName) || gtgt->IsFrameworkOnApple()) {
version = nullptr;
soversion = nullptr;
@@ -1929,9 +1929,9 @@ void cmGlobalXCodeGenerator::CreateBuildSettings(cmGeneratorTarget* gtgt,
std::string soName = pnbase;
if (version && soversion) {
realName += ".";
- realName += version;
+ realName += *version;
soName += ".";
- soName += soversion;
+ soName += *soversion;
}
// Set attributes to specify the proper name for the target.
@@ -1977,10 +1977,10 @@ void cmGlobalXCodeGenerator::CreateBuildSettings(cmGeneratorTarget* gtgt,
std::string fw_version = gtgt->GetFrameworkVersion();
buildSettings->AddAttribute("FRAMEWORK_VERSION",
this->CreateString(fw_version));
- const char* ext = gtgt->GetProperty("BUNDLE_EXTENSION");
+ cmProp ext = gtgt->GetProperty("BUNDLE_EXTENSION");
if (ext) {
buildSettings->AddAttribute("WRAPPER_EXTENSION",
- this->CreateString(ext));
+ this->CreateString(*ext));
}
std::string plist = this->ComputeInfoPListLocation(gtgt);
@@ -2018,10 +2018,10 @@ void cmGlobalXCodeGenerator::CreateBuildSettings(cmGeneratorTarget* gtgt,
extraLinkOptions += " ";
extraLinkOptions += createFlags;
}
- const char* ext = gtgt->GetProperty("BUNDLE_EXTENSION");
+ cmProp ext = gtgt->GetProperty("BUNDLE_EXTENSION");
if (ext) {
buildSettings->AddAttribute("WRAPPER_EXTENSION",
- this->CreateString(ext));
+ this->CreateString(*ext));
}
std::string plist = this->ComputeInfoPListLocation(gtgt);
// Xcode will create the final version of Info.plist at build time,
@@ -2052,10 +2052,10 @@ void cmGlobalXCodeGenerator::CreateBuildSettings(cmGeneratorTarget* gtgt,
std::string fw_version = gtgt->GetFrameworkVersion();
buildSettings->AddAttribute("FRAMEWORK_VERSION",
this->CreateString(fw_version));
- const char* ext = gtgt->GetProperty("BUNDLE_EXTENSION");
+ cmProp ext = gtgt->GetProperty("BUNDLE_EXTENSION");
if (ext) {
buildSettings->AddAttribute("WRAPPER_EXTENSION",
- this->CreateString(ext));
+ this->CreateString(*ext));
}
std::string plist = this->ComputeInfoPListLocation(gtgt);
@@ -2091,10 +2091,10 @@ void cmGlobalXCodeGenerator::CreateBuildSettings(cmGeneratorTarget* gtgt,
// Handle bundles and normal executables separately.
if (gtgt->GetPropertyAsBool("MACOSX_BUNDLE")) {
- const char* ext = gtgt->GetProperty("BUNDLE_EXTENSION");
+ cmProp ext = gtgt->GetProperty("BUNDLE_EXTENSION");
if (ext) {
buildSettings->AddAttribute("WRAPPER_EXTENSION",
- this->CreateString(ext));
+ this->CreateString(*ext));
}
std::string plist = this->ComputeInfoPListLocation(gtgt);
// Xcode will create the final version of Info.plist at build time,
@@ -2416,9 +2416,9 @@ void cmGlobalXCodeGenerator::CreateBuildSettings(cmGeneratorTarget* gtgt,
std::string attribute = prop.substr(16);
this->FilterConfigurationAttribute(configName, attribute);
if (!attribute.empty()) {
- const char* pr = gtgt->GetProperty(prop);
+ const std::string pr = gtgt->GetSafeProperty(prop);
std::string processed = cmGeneratorExpression::Evaluate(
- pr ? pr : "", this->CurrentLocalGenerator, configName);
+ pr, this->CurrentLocalGenerator, configName);
buildSettings->AddAttribute(attribute,
this->CreateString(processed));
}
@@ -2537,8 +2537,8 @@ const char* cmGlobalXCodeGenerator::GetTargetLinkFlagsVar(
const char* cmGlobalXCodeGenerator::GetTargetFileType(
cmGeneratorTarget* target)
{
- if (const char* e = target->GetProperty("XCODE_EXPLICIT_FILE_TYPE")) {
- return e;
+ if (cmProp e = target->GetProperty("XCODE_EXPLICIT_FILE_TYPE")) {
+ return e->c_str();
}
switch (target->GetType()) {
@@ -2570,8 +2570,8 @@ const char* cmGlobalXCodeGenerator::GetTargetFileType(
const char* cmGlobalXCodeGenerator::GetTargetProductType(
cmGeneratorTarget* target)
{
- if (const char* e = target->GetProperty("XCODE_PRODUCT_TYPE")) {
- return e;
+ if (cmProp e = target->GetProperty("XCODE_PRODUCT_TYPE")) {
+ return e->c_str();
}
switch (target->GetType()) {
@@ -3407,12 +3407,12 @@ bool cmGlobalXCodeGenerator::OutputXCodeSharedSchemes(
continue;
}
- const char* testee = obj->GetTarget()->GetProperty("XCTEST_TESTEE");
+ cmProp testee = obj->GetTarget()->GetProperty("XCTEST_TESTEE");
if (!testee) {
continue;
}
- testables[testee].push_back(obj.get());
+ testables[*testee].push_back(obj.get());
}
// generate scheme
diff --git a/Source/cmInstallTargetGenerator.cxx b/Source/cmInstallTargetGenerator.cxx
index e05daa8..37d8c28 100644
--- a/Source/cmInstallTargetGenerator.cxx
+++ b/Source/cmInstallTargetGenerator.cxx
@@ -24,6 +24,8 @@
#include "cmTarget.h"
#include "cmake.h"
+using cmProp = const std::string*; // just to silence IWYU
+
cmInstallTargetGenerator::cmInstallTargetGenerator(
std::string targetName, std::string const& dest, bool implib,
std::string file_permissions, std::vector<std::string> const& configurations,
@@ -133,8 +135,10 @@ void cmInstallTargetGenerator::GenerateScriptForConfig(
cmMakefile const* mf = this->Target->Target->GetMakefile();
// Get App Bundle Extension
- const char* ext = this->Target->GetProperty("BUNDLE_EXTENSION");
- if (!ext) {
+ std::string ext;
+ if (cmProp p = this->Target->GetProperty("BUNDLE_EXTENSION")) {
+ ext = *p;
+ } else {
ext = "app";
}
diff --git a/Source/cmLinkLineDeviceComputer.cxx b/Source/cmLinkLineDeviceComputer.cxx
index b9a73b0..eebf328 100644
--- a/Source/cmLinkLineDeviceComputer.cxx
+++ b/Source/cmLinkLineDeviceComputer.cxx
@@ -177,11 +177,11 @@ bool requireDeviceLinking(cmGeneratorTarget& target, cmLocalGenerator& lg,
return false;
}
- if (const char* resolveDeviceSymbols =
+ if (cmProp resolveDeviceSymbols =
target.GetProperty("CUDA_RESOLVE_DEVICE_SYMBOLS")) {
// If CUDA_RESOLVE_DEVICE_SYMBOLS has been explicitly set we need
// to honor the value no matter what it is.
- return cmIsOn(resolveDeviceSymbols);
+ return cmIsOn(*resolveDeviceSymbols);
}
// Determine if we have any dependencies that require
@@ -190,9 +190,9 @@ bool requireDeviceLinking(cmGeneratorTarget& target, cmLocalGenerator& lg,
target.GetLinkClosure(config);
if (cm::contains(closure->Languages, "CUDA")) {
- if (const char* separableCompilation =
+ if (cmProp separableCompilation =
target.GetProperty("CUDA_SEPARABLE_COMPILATION")) {
- if (cmIsOn(separableCompilation)) {
+ if (cmIsOn(*separableCompilation)) {
bool doDeviceLinking = false;
switch (target.GetType()) {
case cmStateEnums::SHARED_LIBRARY:
diff --git a/Source/cmLocalGenerator.cxx b/Source/cmLocalGenerator.cxx
index 829f9cc..a2208e5 100644
--- a/Source/cmLocalGenerator.cxx
+++ b/Source/cmLocalGenerator.cxx
@@ -6,7 +6,6 @@
#include <cassert>
#include <cstdio>
#include <cstdlib>
-#include <cstring>
#include <initializer_list>
#include <iterator>
#include <sstream>
@@ -805,14 +804,14 @@ bool cmLocalGenerator::ComputeTargetCompileFeatures()
if (target->GetType() != cmStateEnums::INTERFACE_LIBRARY) {
auto copyStandardToObjLang = [&](LanguagePair const& lang) -> bool {
if (!target->GetProperty(cmStrCat(lang.first, "_STANDARD"))) {
- auto* standard =
+ cmProp standard =
target->GetProperty(cmStrCat(lang.second, "_STANDARD"));
if (!standard) {
- standard = this->Makefile->GetDefinition(
+ standard = this->Makefile->GetDef(
cmStrCat("CMAKE_", lang.second, "_STANDARD_DEFAULT"));
}
target->Target->SetProperty(cmStrCat(lang.first, "_STANDARD"),
- standard);
+ standard ? standard->c_str() : nullptr);
return true;
}
return false;
@@ -821,9 +820,9 @@ bool cmLocalGenerator::ComputeTargetCompileFeatures()
const char* property) {
if (!target->GetProperty(cmStrCat(lang.first, property)) &&
target->GetProperty(cmStrCat(lang.second, property))) {
- target->Target->SetProperty(
- cmStrCat(lang.first, property),
- target->GetProperty(cmStrCat(lang.second, property)));
+ cmProp p = target->GetProperty(cmStrCat(lang.second, property));
+ target->Target->SetProperty(cmStrCat(lang.first, property),
+ p ? p->c_str() : nullptr);
}
};
for (auto const& lang : pairedLanguages) {
@@ -832,8 +831,8 @@ bool cmLocalGenerator::ComputeTargetCompileFeatures()
copyPropertyToObjLang(lang, "_EXTENSIONS");
}
}
- if (const char* standard = target->GetProperty("CUDA_STANDARD")) {
- if (std::string{ standard } == "98") {
+ if (cmProp standard = target->GetProperty("CUDA_STANDARD")) {
+ if (*standard == "98") {
target->Target->SetProperty("CUDA_STANDARD", "03");
}
}
@@ -861,10 +860,12 @@ cmStateSnapshot cmLocalGenerator::GetStateSnapshot() const
const char* cmLocalGenerator::GetRuleLauncher(cmGeneratorTarget* target,
const std::string& prop)
{
+ cmProp p;
if (target) {
- return target->GetProperty(prop);
+ p = target->GetProperty(prop);
+ } else {
+ p = this->Makefile->GetProperty(prop);
}
- cmProp p = this->Makefile->GetProperty(prop);
return p ? p->c_str() : nullptr;
}
@@ -992,9 +993,9 @@ void cmLocalGenerator::AddCompileOptions(std::vector<BT<std::string>>& flags,
if (const char* langFlagRegexStr =
this->Makefile->GetDefinition(langFlagRegexVar)) {
// Filter flags acceptable to this language.
- if (const char* targetFlags = target->GetProperty("COMPILE_FLAGS")) {
+ if (cmProp targetFlags = target->GetProperty("COMPILE_FLAGS")) {
std::vector<std::string> opts;
- cmSystemTools::ParseWindowsCommandLine(targetFlags, opts);
+ cmSystemTools::ParseWindowsCommandLine(targetFlags->c_str(), opts);
// Re-escape these flags since COMPILE_FLAGS were already parsed
// as a command line above.
std::string compileOpts;
@@ -1009,10 +1010,10 @@ void cmLocalGenerator::AddCompileOptions(std::vector<BT<std::string>>& flags,
this->AppendCompileOptions(flags, targetCompileOpts, langFlagRegexStr);
} else {
// Use all flags.
- if (const char* targetFlags = target->GetProperty("COMPILE_FLAGS")) {
+ if (cmProp targetFlags = target->GetProperty("COMPILE_FLAGS")) {
// COMPILE_FLAGS are not escaped for historical reasons.
std::string compileFlags;
- this->AppendFlags(compileFlags, targetFlags);
+ this->AppendFlags(compileFlags, *targetFlags);
if (!compileFlags.empty()) {
flags.emplace_back(std::move(compileFlags));
}
@@ -1024,11 +1025,11 @@ void cmLocalGenerator::AddCompileOptions(std::vector<BT<std::string>>& flags,
}
for (auto const& it : target->GetMaxLanguageStandards()) {
- const char* standard = target->GetProperty(it.first + "_STANDARD");
+ cmProp standard = target->GetProperty(it.first + "_STANDARD");
if (!standard) {
continue;
}
- if (this->Makefile->IsLaterStandard(it.first, standard, it.second)) {
+ if (this->Makefile->IsLaterStandard(it.first, *standard, it.second)) {
std::ostringstream e;
e << "The COMPILE_FEATURES property of target \"" << target->GetName()
<< "\" was evaluated when computing the link "
@@ -1037,7 +1038,7 @@ void cmLocalGenerator::AddCompileOptions(std::vector<BT<std::string>>& flags,
<< "\" for that computation. Computing the "
"COMPILE_FEATURES based on the link implementation resulted in a "
"higher \""
- << it.first << "_STANDARD\" \"" << standard
+ << it.first << "_STANDARD\" \"" << *standard
<< "\". "
"This is not permitted. The COMPILE_FEATURES may not both depend "
"on "
@@ -1064,10 +1065,10 @@ void cmLocalGenerator::AddCompileOptions(std::vector<BT<std::string>>& flags,
cmGeneratorTarget::ManagedType::Managed) {
// add /JMC flags if target property VS_JUST_MY_CODE_DEBUGGING is set
// to ON
- if (char const* jmcExprGen =
+ if (cmProp jmcExprGen =
target->GetProperty("VS_JUST_MY_CODE_DEBUGGING")) {
std::string isJMCEnabled =
- cmGeneratorExpression::Evaluate(jmcExprGen, this, config);
+ cmGeneratorExpression::Evaluate(*jmcExprGen, this, config);
if (cmIsOn(isJMCEnabled)) {
std::vector<std::string> optVec = cmExpandedList(jmc);
std::string jmcFlags;
@@ -1510,16 +1511,16 @@ void cmLocalGenerator::GetTargetFlags(
}
}
- const char* targetLinkFlags = target->GetProperty("LINK_FLAGS");
+ cmProp targetLinkFlags = target->GetProperty("LINK_FLAGS");
if (targetLinkFlags) {
- sharedLibFlags += targetLinkFlags;
+ sharedLibFlags += *targetLinkFlags;
sharedLibFlags += " ";
}
if (!configUpper.empty()) {
targetLinkFlags =
target->GetProperty(cmStrCat("LINK_FLAGS_", configUpper));
if (targetLinkFlags) {
- sharedLibFlags += targetLinkFlags;
+ sharedLibFlags += *targetLinkFlags;
sharedLibFlags += " ";
}
}
@@ -1591,16 +1592,16 @@ void cmLocalGenerator::GetTargetFlags(
exeFlags += " ";
}
- const char* targetLinkFlags = target->GetProperty("LINK_FLAGS");
+ cmProp targetLinkFlags = target->GetProperty("LINK_FLAGS");
if (targetLinkFlags) {
- exeFlags += targetLinkFlags;
+ exeFlags += *targetLinkFlags;
exeFlags += " ";
}
if (!configUpper.empty()) {
targetLinkFlags =
target->GetProperty(cmStrCat("LINK_FLAGS_", configUpper));
if (targetLinkFlags) {
- exeFlags += targetLinkFlags;
+ exeFlags += *targetLinkFlags;
exeFlags += " ";
}
}
@@ -1975,12 +1976,12 @@ void cmLocalGenerator::AddLanguageFlags(std::string& flags,
config);
if (lang == "Swift") {
- if (const char* v = target->GetProperty("Swift_LANGUAGE_VERSION")) {
+ if (cmProp v = target->GetProperty("Swift_LANGUAGE_VERSION")) {
if (cmSystemTools::VersionCompare(
cmSystemTools::OP_GREATER_EQUAL,
this->Makefile->GetDefinition("CMAKE_Swift_COMPILER_VERSION"),
"4.2")) {
- this->AppendFlags(flags, "-swift-version " + std::string(v));
+ this->AppendFlags(flags, "-swift-version " + *v);
}
}
} else if (lang == "CUDA") {
@@ -1989,16 +1990,16 @@ void cmLocalGenerator::AddLanguageFlags(std::string& flags,
// Add MSVC runtime library flags. This is activated by the presence
// of a default selection whether or not it is overridden by a property.
- const char* msvcRuntimeLibraryDefault =
- this->Makefile->GetDefinition("CMAKE_MSVC_RUNTIME_LIBRARY_DEFAULT");
- if (msvcRuntimeLibraryDefault && *msvcRuntimeLibraryDefault) {
- const char* msvcRuntimeLibraryValue =
+ cmProp msvcRuntimeLibraryDefault =
+ this->Makefile->GetDef("CMAKE_MSVC_RUNTIME_LIBRARY_DEFAULT");
+ if (msvcRuntimeLibraryDefault && !msvcRuntimeLibraryDefault->empty()) {
+ cmProp msvcRuntimeLibraryValue =
target->GetProperty("MSVC_RUNTIME_LIBRARY");
if (!msvcRuntimeLibraryValue) {
msvcRuntimeLibraryValue = msvcRuntimeLibraryDefault;
}
std::string const msvcRuntimeLibrary = cmGeneratorExpression::Evaluate(
- msvcRuntimeLibraryValue, this, config, target);
+ *msvcRuntimeLibraryValue, this, config, target);
if (!msvcRuntimeLibrary.empty()) {
if (const char* msvcRuntimeLibraryOptions =
this->Makefile->GetDefinition(
@@ -2177,13 +2178,13 @@ void cmLocalGenerator::AddCompilerRequirementFlag(
}
std::string extProp = lang + "_EXTENSIONS";
bool ext = true;
- if (const char* extPropValue = target->GetProperty(extProp)) {
- if (cmIsOff(extPropValue)) {
+ if (cmProp extPropValue = target->GetProperty(extProp)) {
+ if (cmIsOff(*extPropValue)) {
ext = false;
}
}
std::string stdProp = lang + "_STANDARD";
- const char* standardProp = target->GetProperty(stdProp);
+ cmProp standardProp = target->GetProperty(stdProp);
if (!standardProp) {
if (ext) {
// No language standard is specified and extensions are not disabled.
@@ -2205,7 +2206,7 @@ void cmLocalGenerator::AddCompilerRequirementFlag(
if (target->GetPropertyAsBool(lang + "_STANDARD_REQUIRED")) {
std::string option_flag =
- "CMAKE_" + lang + standardProp + "_" + type + "_COMPILE_OPTION";
+ "CMAKE_" + lang + *standardProp + "_" + type + "_COMPILE_OPTION";
const char* opt =
target->Target->GetMakefile()->GetDefinition(option_flag);
@@ -2214,7 +2215,7 @@ void cmLocalGenerator::AddCompilerRequirementFlag(
e << "Target \"" << target->GetName()
<< "\" requires the language "
"dialect \""
- << lang << standardProp << "\" "
+ << lang << *standardProp << "\" "
<< (ext ? "(with compiler extensions)" : "")
<< ", but CMake "
"does not know the compile flags to use to enable it.";
@@ -2258,7 +2259,7 @@ void cmLocalGenerator::AddCompilerRequirementFlag(
langStdMap["CUDA"].emplace_back("03");
}
- std::string standard(standardProp);
+ std::string standard(*standardProp);
if (lang == "CUDA" && standard == "98") {
standard = "03";
}
@@ -2331,7 +2332,7 @@ static void AddVisibilityCompileOption(std::string& flags,
}
std::string flagDefine = lang + "_VISIBILITY_PRESET";
- const char* prop = target->GetProperty(flagDefine);
+ cmProp prop = target->GetProperty(flagDefine);
if (!prop) {
return;
}
@@ -2339,17 +2340,17 @@ static void AddVisibilityCompileOption(std::string& flags,
*warnCMP0063 += " " + flagDefine + "\n";
return;
}
- if (strcmp(prop, "hidden") != 0 && strcmp(prop, "default") != 0 &&
- strcmp(prop, "protected") != 0 && strcmp(prop, "internal") != 0) {
+ if ((*prop != "hidden") && (*prop != "default") && (*prop != "protected") &&
+ (*prop != "internal")) {
std::ostringstream e;
- e << "Target " << target->GetName() << " uses unsupported value \"" << prop
- << "\" for " << flagDefine << "."
+ e << "Target " << target->GetName() << " uses unsupported value \""
+ << *prop << "\" for " << flagDefine << "."
<< " The supported values are: default, hidden, protected, and "
"internal.";
cmSystemTools::Error(e.str());
return;
}
- std::string option = std::string(opt) + prop;
+ std::string option = opt + *prop;
lg->AppendFlags(flags, option);
}
@@ -2616,14 +2617,14 @@ void cmLocalGenerator::AddPchDependencies(cmGeneratorTarget* target)
continue;
}
- const char* pchReuseFrom =
+ cmProp ReuseFrom =
target->GetProperty("PRECOMPILE_HEADERS_REUSE_FROM");
auto pch_sf = this->Makefile->GetOrCreateSource(
pchSource, false, cmSourceFileLocationKind::Known);
if (!this->GetGlobalGenerator()->IsXcode()) {
- if (!pchReuseFrom) {
+ if (!ReuseFrom) {
target->AddSource(pchSource, true);
}
@@ -2631,11 +2632,11 @@ void cmLocalGenerator::AddPchDependencies(cmGeneratorTarget* target)
// Exclude the pch files from linking
if (this->Makefile->IsOn("CMAKE_LINK_PCH")) {
- if (!pchReuseFrom) {
+ if (!ReuseFrom) {
pch_sf->SetProperty("OBJECT_OUTPUTS", pchFile.c_str());
} else {
auto reuseTarget =
- this->GlobalGenerator->FindGeneratorTarget(pchReuseFrom);
+ this->GlobalGenerator->FindGeneratorTarget(*ReuseFrom);
if (this->Makefile->IsOn("CMAKE_PCH_COPY_COMPILE_PDB")) {
@@ -2657,22 +2658,22 @@ void cmLocalGenerator::AddPchDependencies(cmGeneratorTarget* target)
const std::string from_file =
cmStrCat(reuseTarget->GetLocalGenerator()
->GetCurrentBinaryDirectory(),
- "/", pchReuseFrom, ".dir/${PDB_PREFIX}",
- pchReuseFrom, extension);
+ "/", *ReuseFrom, ".dir/${PDB_PREFIX}", *ReuseFrom,
+ extension);
const std::string to_dir = cmStrCat(
target->GetLocalGenerator()->GetCurrentBinaryDirectory(),
"/", target->GetName(), ".dir/${PDB_PREFIX}");
const std::string to_file =
- cmStrCat(to_dir, pchReuseFrom, extension);
+ cmStrCat(to_dir, *ReuseFrom, extension);
std::string dest_file = to_file;
const std::string prefix = target->GetSafeProperty("PREFIX");
if (!prefix.empty()) {
dest_file =
- cmStrCat(to_dir, prefix, pchReuseFrom, extension);
+ cmStrCat(to_dir, prefix, *ReuseFrom, extension);
}
file << "if (EXISTS \"" << from_file << "\" AND \""
@@ -2702,7 +2703,7 @@ void cmLocalGenerator::AddPchDependencies(cmGeneratorTarget* target)
std::vector<std::string> outputs;
outputs.push_back(cmStrCat(target_compile_pdb_dir, pdb_prefix,
- pchReuseFrom, ".pdb"));
+ *ReuseFrom, ".pdb"));
if (this->GetGlobalGenerator()->IsVisualStudio()) {
this->AddCustomCommandToTarget(
@@ -2774,12 +2775,14 @@ void cmLocalGenerator::AddUnityBuild(cmGeneratorTarget* target)
std::vector<cmSourceFile*> sources;
target->GetSourceFiles(sources, config);
- auto batchSizeString = target->GetProperty("UNITY_BUILD_BATCH_SIZE");
- const size_t unityBatchSize =
- static_cast<size_t>(std::atoi(batchSizeString));
+ cmProp batchSizeString = target->GetProperty("UNITY_BUILD_BATCH_SIZE");
+ const size_t unityBatchSize = batchSizeString
+ ? static_cast<size_t>(std::atoi(batchSizeString->c_str()))
+ : 0;
- auto beforeInclude = target->GetProperty("UNITY_BUILD_CODE_BEFORE_INCLUDE");
- auto afterInclude = target->GetProperty("UNITY_BUILD_CODE_AFTER_INCLUDE");
+ cmProp beforeInclude =
+ target->GetProperty("UNITY_BUILD_CODE_BEFORE_INCLUDE");
+ cmProp afterInclude = target->GetProperty("UNITY_BUILD_CODE_AFTER_INCLUDE");
for (std::string lang : { "C", "CXX" }) {
std::vector<cmSourceFile*> filtered_sources;
@@ -2824,13 +2827,13 @@ void cmLocalGenerator::AddUnityBuild(cmGeneratorTarget* target)
sf->SetProperty("UNITY_SOURCE_FILE", filename.c_str());
if (beforeInclude) {
- file << beforeInclude << "\n";
+ file << *beforeInclude << "\n";
}
file << "#include \"" << sf->ResolveFullPath() << "\"\n";
if (afterInclude) {
- file << afterInclude << "\n";
+ file << *afterInclude << "\n";
}
}
}
@@ -3190,8 +3193,8 @@ void cmLocalGenerator::GenerateTargetInstallRules(
}
// Include the user-specified pre-install script for this target.
- if (const char* preinstall = l->GetProperty("PRE_INSTALL_SCRIPT")) {
- cmInstallScriptGenerator g(preinstall, false, "", false);
+ if (cmProp preinstall = l->GetProperty("PRE_INSTALL_SCRIPT")) {
+ cmInstallScriptGenerator g(*preinstall, false, "", false);
g.Generate(os, config, configurationTypes);
}
@@ -3243,8 +3246,8 @@ void cmLocalGenerator::GenerateTargetInstallRules(
}
// Include the user-specified post-install script for this target.
- if (const char* postinstall = l->GetProperty("POST_INSTALL_SCRIPT")) {
- cmInstallScriptGenerator g(postinstall, false, "", false);
+ if (cmProp postinstall = l->GetProperty("POST_INSTALL_SCRIPT")) {
+ cmInstallScriptGenerator g(*postinstall, false, "", false);
g.Generate(os, config, configurationTypes);
}
}
@@ -3655,8 +3658,8 @@ bool cmLocalGenerator::CheckDefinition(std::string const& define) const
static void cmLGInfoProp(cmMakefile* mf, cmGeneratorTarget* target,
const std::string& prop)
{
- if (const char* val = target->GetProperty(prop)) {
- mf->AddDefinition(prop, val);
+ if (cmProp val = target->GetProperty(prop)) {
+ mf->AddDefinition(prop, *val);
}
}
@@ -3665,8 +3668,9 @@ void cmLocalGenerator::GenerateAppleInfoPList(cmGeneratorTarget* target,
const std::string& fname)
{
// Find the Info.plist template.
- const char* in = target->GetProperty("MACOSX_BUNDLE_INFO_PLIST");
- std::string inFile = (in && *in) ? in : "MacOSXBundleInfo.plist.in";
+ cmProp in = target->GetProperty("MACOSX_BUNDLE_INFO_PLIST");
+ std::string inFile =
+ (in && !in->empty()) ? *in : "MacOSXBundleInfo.plist.in";
if (!cmSystemTools::FileIsFullPath(inFile)) {
std::string inMod = this->Makefile->GetModulesFile(inFile);
if (!inMod.empty()) {
@@ -3704,8 +3708,9 @@ void cmLocalGenerator::GenerateFrameworkInfoPList(
const std::string& fname)
{
// Find the Info.plist template.
- const char* in = target->GetProperty("MACOSX_FRAMEWORK_INFO_PLIST");
- std::string inFile = (in && *in) ? in : "MacOSXFrameworkInfo.plist.in";
+ cmProp in = target->GetProperty("MACOSX_FRAMEWORK_INFO_PLIST");
+ std::string inFile =
+ (in && !in->empty()) ? *in : "MacOSXFrameworkInfo.plist.in";
if (!cmSystemTools::FileIsFullPath(inFile)) {
std::string inMod = this->Makefile->GetModulesFile(inFile);
if (!inMod.empty()) {
diff --git a/Source/cmLocalUnixMakefileGenerator3.cxx b/Source/cmLocalUnixMakefileGenerator3.cxx
index 1401e29..4c7c8c4 100644
--- a/Source/cmLocalUnixMakefileGenerator3.cxx
+++ b/Source/cmLocalUnixMakefileGenerator3.cxx
@@ -1546,10 +1546,8 @@ void cmLocalUnixMakefileGenerator3::WriteLocalAllRules(
std::vector<std::string> commands;
std::vector<std::string> depends;
- const char* text = gt->GetProperty("EchoString");
- if (!text) {
- text = "Running external command ...";
- }
+ cmProp p = gt->GetProperty("EchoString");
+ const char* text = p ? p->c_str() : "Running external command ...";
depends.reserve(gt->GetUtilities().size());
for (BT<std::pair<std::string, bool>> const& u : gt->GetUtilities()) {
depends.push_back(u.Value.first);
@@ -1870,9 +1868,9 @@ void cmLocalUnixMakefileGenerator3::WriteDependLanguageInfo(
this->Makefile->GetProperty("IMPLICIT_DEPENDS_INCLUDE_TRANSFORM")) {
cmExpandList(*xform, transformRules);
}
- if (const char* xform =
+ if (cmProp xform =
target->GetProperty("IMPLICIT_DEPENDS_INCLUDE_TRANSFORM")) {
- cmExpandList(xform, transformRules);
+ cmExpandList(*xform, transformRules);
}
if (!transformRules.empty()) {
cmakefileStream << "set(CMAKE_INCLUDE_TRANSFORMS\n";
diff --git a/Source/cmLocalVisualStudio7Generator.cxx b/Source/cmLocalVisualStudio7Generator.cxx
index 8daffa0..e18fac3 100644
--- a/Source/cmLocalVisualStudio7Generator.cxx
+++ b/Source/cmLocalVisualStudio7Generator.cxx
@@ -70,9 +70,9 @@ void cmLocalVisualStudio7Generator::AddHelperCommands()
if (l->GetType() == cmStateEnums::INTERFACE_LIBRARY) {
continue;
}
- const char* path = l->GetProperty("EXTERNAL_MSPROJECT");
+ cmProp path = l->GetProperty("EXTERNAL_MSPROJECT");
if (path) {
- this->ReadAndStoreExternalGUID(l->GetName(), path);
+ this->ReadAndStoreExternalGUID(l->GetName(), path->c_str());
}
}
@@ -778,12 +778,11 @@ void cmLocalVisualStudio7Generator::WriteConfiguration(
fout << "\t\t\t<Tool\n"
<< "\t\t\t\tName=\"" << tool << "\"\n";
if (this->FortranProject) {
- const char* target_mod_dir =
- target->GetProperty("Fortran_MODULE_DIRECTORY");
+ cmProp target_mod_dir = target->GetProperty("Fortran_MODULE_DIRECTORY");
std::string modDir;
if (target_mod_dir) {
modDir = this->MaybeConvertToRelativePath(
- this->GetCurrentBinaryDirectory(), target_mod_dir);
+ this->GetCurrentBinaryDirectory(), *target_mod_dir);
} else {
modDir = ".";
}
@@ -937,17 +936,17 @@ void cmLocalVisualStudio7Generator::OutputBuildTool(
" " + GetBuildTypeLinkerFlags("CMAKE_MODULE_LINKER_FLAGS", configName);
}
- const char* targetLinkFlags = target->GetProperty("LINK_FLAGS");
+ cmProp targetLinkFlags = target->GetProperty("LINK_FLAGS");
if (targetLinkFlags) {
extraLinkOptions += " ";
- extraLinkOptions += targetLinkFlags;
+ extraLinkOptions += *targetLinkFlags;
}
std::string configTypeUpper = cmSystemTools::UpperCase(configName);
std::string linkFlagsConfig = cmStrCat("LINK_FLAGS_", configTypeUpper);
targetLinkFlags = target->GetProperty(linkFlagsConfig);
if (targetLinkFlags) {
extraLinkOptions += " ";
- extraLinkOptions += targetLinkFlags;
+ extraLinkOptions += *targetLinkFlags;
}
std::vector<std::string> opts;
@@ -1205,8 +1204,8 @@ void cmLocalVisualStudio7Generator::OutputDeploymentDebuggerTool(
std::ostream& fout, std::string const& config, cmGeneratorTarget* target)
{
if (this->WindowsCEProject) {
- const char* dir = target->GetProperty("DEPLOYMENT_REMOTE_DIRECTORY");
- const char* additionalFiles =
+ cmProp dir = target->GetProperty("DEPLOYMENT_REMOTE_DIRECTORY");
+ cmProp additionalFiles =
target->GetProperty("DEPLOYMENT_ADDITIONAL_FILES");
if (dir == nullptr && additionalFiles == nullptr) {
@@ -1216,15 +1215,15 @@ void cmLocalVisualStudio7Generator::OutputDeploymentDebuggerTool(
fout << "\t\t\t<DeploymentTool\n"
"\t\t\t\tForceDirty=\"-1\"\n"
"\t\t\t\tRemoteDirectory=\""
- << GetEscapedPropertyIfValueNotNULL(dir)
+ << GetEscapedPropertyIfValueNotNULL(dir->c_str())
<< "\"\n"
"\t\t\t\tRegisterOutput=\"0\"\n"
"\t\t\t\tAdditionalFiles=\""
- << GetEscapedPropertyIfValueNotNULL(additionalFiles) << "\"/>\n";
+ << GetEscapedPropertyIfValueNotNULL(additionalFiles->c_str())
+ << "\"/>\n";
if (dir != nullptr) {
- std::string const exe =
- dir + std::string("\\") + target->GetFullName(config);
+ std::string const exe = *dir + "\\" + target->GetFullName(config);
fout << "\t\t\t<DebuggerTool\n"
"\t\t\t\tRemoteExecutable=\""
@@ -1876,20 +1875,20 @@ void cmLocalVisualStudio7Generator::WriteProjectSCC(std::ostream& fout,
{
// if we have all the required Source code control tags
// then add that to the project
- const char* vsProjectname = target->GetProperty("VS_SCC_PROJECTNAME");
- const char* vsLocalpath = target->GetProperty("VS_SCC_LOCALPATH");
- const char* vsProvider = target->GetProperty("VS_SCC_PROVIDER");
+ cmProp vsProjectname = target->GetProperty("VS_SCC_PROJECTNAME");
+ cmProp vsLocalpath = target->GetProperty("VS_SCC_LOCALPATH");
+ cmProp vsProvider = target->GetProperty("VS_SCC_PROVIDER");
if (vsProvider && vsLocalpath && vsProjectname) {
/* clang-format off */
- fout << "\tSccProjectName=\"" << vsProjectname << "\"\n"
- << "\tSccLocalPath=\"" << vsLocalpath << "\"\n"
- << "\tSccProvider=\"" << vsProvider << "\"\n";
+ fout << "\tSccProjectName=\"" << *vsProjectname << "\"\n"
+ << "\tSccLocalPath=\"" << *vsLocalpath << "\"\n"
+ << "\tSccProvider=\"" << *vsProvider << "\"\n";
/* clang-format on */
- const char* vsAuxPath = target->GetProperty("VS_SCC_AUXPATH");
+ cmProp vsAuxPath = target->GetProperty("VS_SCC_AUXPATH");
if (vsAuxPath) {
- fout << "\tSccAuxPath=\"" << vsAuxPath << "\"\n";
+ fout << "\tSccAuxPath=\"" << *vsAuxPath << "\"\n";
}
}
}
@@ -1907,10 +1906,8 @@ void cmLocalVisualStudio7Generator::WriteProjectStartFortran(
<< "\tProjectCreator=\"Intel Fortran\"\n"
<< "\tVersion=\"" << gg->GetIntelProjectVersion() << "\"\n";
/* clang-format on */
- const char* keyword = target->GetProperty("VS_KEYWORD");
- if (!keyword) {
- keyword = "Console Application";
- }
+ cmProp p = target->GetProperty("VS_KEYWORD");
+ const char* keyword = p ? p->c_str() : "Console Application";
const char* projectType = 0;
switch (target->GetType()) {
case cmStateEnums::STATIC_LIBRARY:
@@ -1969,20 +1966,16 @@ void cmLocalVisualStudio7Generator::WriteProjectStart(
<< "\tProjectType=\"Visual C++\"\n";
/* clang-format on */
fout << "\tVersion=\"" << (gg->GetVersion() / 10) << ".00\"\n";
- const char* projLabel = target->GetProperty("PROJECT_LABEL");
- if (!projLabel) {
- projLabel = libName.c_str();
- }
- const char* keyword = target->GetProperty("VS_KEYWORD");
- if (!keyword) {
- keyword = "Win32Proj";
- }
+ cmProp p = target->GetProperty("PROJECT_LABEL");
+ const std::string projLabel = p ? *p : libName;
+ p = target->GetProperty("VS_KEYWORD");
+ const std::string keyword = p ? *p : "Win32Proj";
fout << "\tName=\"" << projLabel << "\"\n";
fout << "\tProjectGUID=\"{" << gg->GetGUID(libName) << "}\"\n";
this->WriteProjectSCC(fout, target);
- if (const char* targetFrameworkVersion =
+ if (cmProp targetFrameworkVersion =
target->GetProperty("VS_DOTNET_TARGET_FRAMEWORK_VERSION")) {
- fout << "\tTargetFrameworkVersion=\"" << targetFrameworkVersion << "\"\n";
+ fout << "\tTargetFrameworkVersion=\"" << *targetFrameworkVersion << "\"\n";
}
/* clang-format off */
fout << "\tKeyword=\"" << keyword << "\">\n"
diff --git a/Source/cmMakefileTargetGenerator.cxx b/Source/cmMakefileTargetGenerator.cxx
index 267d5e1..5f0cfcf 100644
--- a/Source/cmMakefileTargetGenerator.cxx
+++ b/Source/cmMakefileTargetGenerator.cxx
@@ -18,7 +18,7 @@
#include "cmGeneratorExpression.h"
#include "cmGeneratorTarget.h"
#include "cmGlobalUnixMakefileGenerator3.h"
-#include "cmLinkLineComputer.h"
+#include "cmLinkLineComputer.h" // IWYU pragma: keep
#include "cmLocalCommonGenerator.h"
#include "cmLocalUnixMakefileGenerator3.h"
#include "cmMakefile.h"
@@ -184,9 +184,9 @@ void cmMakefileTargetGenerator::WriteTargetBuildRules()
}
// Look for additional files registered for cleaning in this target.
- if (const char* prop_value =
+ if (cmProp prop_value =
this->GeneratorTarget->GetProperty("ADDITIONAL_CLEAN_FILES")) {
- std::vector<std::string> const files = evaluatedFiles(prop_value);
+ std::vector<std::string> const files = evaluatedFiles(*prop_value);
// For relative path support
std::string const& binaryDir =
this->LocalGenerator->GetCurrentBinaryDirectory();
@@ -797,25 +797,24 @@ void cmMakefileTargetGenerator::WriteObjectRuleFiles(
(lang == "C" || lang == "CXX" || lang == "Fortran" || lang == "CUDA" ||
lang == "OBJC" || lang == "OBJCXX")) {
std::string const clauncher_prop = lang + "_COMPILER_LAUNCHER";
- const char* clauncher =
- this->GeneratorTarget->GetProperty(clauncher_prop);
- if (clauncher && *clauncher) {
- compilerLauncher = clauncher;
+ cmProp clauncher = this->GeneratorTarget->GetProperty(clauncher_prop);
+ if (clauncher && !clauncher->empty()) {
+ compilerLauncher = *clauncher;
}
}
// Maybe insert an include-what-you-use runner.
if (!compileCommands.empty() && (lang == "C" || lang == "CXX")) {
std::string const iwyu_prop = lang + "_INCLUDE_WHAT_YOU_USE";
- const char* iwyu = this->GeneratorTarget->GetProperty(iwyu_prop);
+ cmProp iwyu = this->GeneratorTarget->GetProperty(iwyu_prop);
std::string const tidy_prop = lang + "_CLANG_TIDY";
- const char* tidy = this->GeneratorTarget->GetProperty(tidy_prop);
+ cmProp tidy = this->GeneratorTarget->GetProperty(tidy_prop);
std::string const cpplint_prop = lang + "_CPPLINT";
- const char* cpplint = this->GeneratorTarget->GetProperty(cpplint_prop);
+ cmProp cpplint = this->GeneratorTarget->GetProperty(cpplint_prop);
std::string const cppcheck_prop = lang + "_CPPCHECK";
- const char* cppcheck = this->GeneratorTarget->GetProperty(cppcheck_prop);
- if ((iwyu && *iwyu) || (tidy && *tidy) || (cpplint && *cpplint) ||
- (cppcheck && *cppcheck)) {
+ cmProp cppcheck = this->GeneratorTarget->GetProperty(cppcheck_prop);
+ if ((iwyu && !iwyu->empty()) || (tidy && !tidy->empty()) ||
+ (cpplint && !cpplint->empty()) || (cppcheck && !cppcheck->empty())) {
std::string run_iwyu = "$(CMAKE_COMMAND) -E __run_co_compile";
if (!compilerLauncher.empty()) {
// In __run_co_compile case the launcher command is supplied
@@ -824,11 +823,11 @@ void cmMakefileTargetGenerator::WriteObjectRuleFiles(
run_iwyu += this->LocalGenerator->EscapeForShell(compilerLauncher);
compilerLauncher.clear();
}
- if (iwyu && *iwyu) {
+ if (iwyu && !iwyu->empty()) {
run_iwyu += " --iwyu=";
- run_iwyu += this->LocalGenerator->EscapeForShell(iwyu);
+ run_iwyu += this->LocalGenerator->EscapeForShell(*iwyu);
}
- if (tidy && *tidy) {
+ if (tidy && !tidy->empty()) {
run_iwyu += " --tidy=";
const char* driverMode = this->Makefile->GetDefinition(
"CMAKE_" + lang + "_CLANG_TIDY_DRIVER_MODE");
@@ -836,18 +835,18 @@ void cmMakefileTargetGenerator::WriteObjectRuleFiles(
driverMode = lang == "C" ? "gcc" : "g++";
}
run_iwyu += this->LocalGenerator->EscapeForShell(
- cmStrCat(tidy, ";--extra-arg-before=--driver-mode=", driverMode));
+ cmStrCat(*tidy, ";--extra-arg-before=--driver-mode=", driverMode));
}
- if (cpplint && *cpplint) {
+ if (cpplint && !cpplint->empty()) {
run_iwyu += " --cpplint=";
- run_iwyu += this->LocalGenerator->EscapeForShell(cpplint);
+ run_iwyu += this->LocalGenerator->EscapeForShell(*cpplint);
}
- if (cppcheck && *cppcheck) {
+ if (cppcheck && !cppcheck->empty()) {
run_iwyu += " --cppcheck=";
- run_iwyu += this->LocalGenerator->EscapeForShell(cppcheck);
+ run_iwyu += this->LocalGenerator->EscapeForShell(*cppcheck);
}
- if ((tidy && *tidy) || (cpplint && *cpplint) ||
- (cppcheck && *cppcheck)) {
+ if ((tidy && !tidy->empty()) || (cpplint && !cpplint->empty()) ||
+ (cppcheck && !cppcheck->empty())) {
run_iwyu += " --source=";
run_iwyu += sourceFile;
}
diff --git a/Source/cmNinjaNormalTargetGenerator.cxx b/Source/cmNinjaNormalTargetGenerator.cxx
index 49e8af9..db069ed 100644
--- a/Source/cmNinjaNormalTargetGenerator.cxx
+++ b/Source/cmNinjaNormalTargetGenerator.cxx
@@ -847,8 +847,8 @@ void cmNinjaNormalTargetGenerator::WriteLinkStatement(
}();
vars["SWIFT_MODULE_NAME"] = [gt]() -> std::string {
- if (const char* name = gt->GetProperty("Swift_MODULE_NAME")) {
- return name;
+ if (cmProp name = gt->GetProperty("Swift_MODULE_NAME")) {
+ return *name;
}
return gt->GetName();
}();
@@ -856,15 +856,15 @@ void cmNinjaNormalTargetGenerator::WriteLinkStatement(
vars["SWIFT_MODULE"] = [this](const std::string& module) -> std::string {
std::string directory =
this->GetLocalGenerator()->GetCurrentBinaryDirectory();
- if (const char* prop = this->GetGeneratorTarget()->GetProperty(
+ if (cmProp prop = this->GetGeneratorTarget()->GetProperty(
"Swift_MODULE_DIRECTORY")) {
- directory = prop;
+ directory = *prop;
}
std::string name = module + ".swiftmodule";
- if (const char* prop =
+ if (cmProp prop =
this->GetGeneratorTarget()->GetProperty("Swift_MODULE")) {
- name = prop;
+ name = *prop;
}
return this->GetLocalGenerator()->ConvertToOutputFormat(
diff --git a/Source/cmNinjaTargetGenerator.cxx b/Source/cmNinjaTargetGenerator.cxx
index 701c44f..0606484 100644
--- a/Source/cmNinjaTargetGenerator.cxx
+++ b/Source/cmNinjaTargetGenerator.cxx
@@ -746,24 +746,24 @@ void cmNinjaTargetGenerator::WriteCompileRule(const std::string& lang,
(lang == "C" || lang == "CXX" || lang == "Fortran" || lang == "CUDA" ||
lang == "OBJC" || lang == "OBJCXX")) {
std::string const clauncher_prop = cmStrCat(lang, "_COMPILER_LAUNCHER");
- const char* clauncher = this->GeneratorTarget->GetProperty(clauncher_prop);
- if (clauncher && *clauncher) {
- compilerLauncher = clauncher;
+ cmProp clauncher = this->GeneratorTarget->GetProperty(clauncher_prop);
+ if (clauncher && !clauncher->empty()) {
+ compilerLauncher = *clauncher;
}
}
// Maybe insert an include-what-you-use runner.
if (!compileCmds.empty() && (lang == "C" || lang == "CXX")) {
std::string const iwyu_prop = cmStrCat(lang, "_INCLUDE_WHAT_YOU_USE");
- const char* iwyu = this->GeneratorTarget->GetProperty(iwyu_prop);
+ cmProp iwyu = this->GeneratorTarget->GetProperty(iwyu_prop);
std::string const tidy_prop = cmStrCat(lang, "_CLANG_TIDY");
- const char* tidy = this->GeneratorTarget->GetProperty(tidy_prop);
+ cmProp tidy = this->GeneratorTarget->GetProperty(tidy_prop);
std::string const cpplint_prop = cmStrCat(lang, "_CPPLINT");
- const char* cpplint = this->GeneratorTarget->GetProperty(cpplint_prop);
+ cmProp cpplint = this->GeneratorTarget->GetProperty(cpplint_prop);
std::string const cppcheck_prop = cmStrCat(lang, "_CPPCHECK");
- const char* cppcheck = this->GeneratorTarget->GetProperty(cppcheck_prop);
- if ((iwyu && *iwyu) || (tidy && *tidy) || (cpplint && *cpplint) ||
- (cppcheck && *cppcheck)) {
+ cmProp cppcheck = this->GeneratorTarget->GetProperty(cppcheck_prop);
+ if ((iwyu && !iwyu->empty()) || (tidy && !tidy->empty()) ||
+ (cpplint && !cpplint->empty()) || (cppcheck && !cppcheck->empty())) {
std::string run_iwyu = cmStrCat(cmakeCmd, " -E __run_co_compile");
if (!compilerLauncher.empty()) {
// In __run_co_compile case the launcher command is supplied
@@ -773,11 +773,11 @@ void cmNinjaTargetGenerator::WriteCompileRule(const std::string& lang,
this->LocalGenerator->EscapeForShell(compilerLauncher));
compilerLauncher.clear();
}
- if (iwyu && *iwyu) {
+ if (iwyu && !iwyu->empty()) {
run_iwyu += cmStrCat(" --iwyu=",
- this->GetLocalGenerator()->EscapeForShell(iwyu));
+ this->GetLocalGenerator()->EscapeForShell(*iwyu));
}
- if (tidy && *tidy) {
+ if (tidy && !tidy->empty()) {
run_iwyu += " --tidy=";
const char* driverMode = this->Makefile->GetDefinition(
cmStrCat("CMAKE_", lang, "_CLANG_TIDY_DRIVER_MODE"));
@@ -785,18 +785,19 @@ void cmNinjaTargetGenerator::WriteCompileRule(const std::string& lang,
driverMode = lang == "C" ? "gcc" : "g++";
}
run_iwyu += this->GetLocalGenerator()->EscapeForShell(
- cmStrCat(tidy, ";--extra-arg-before=--driver-mode=", driverMode));
+ cmStrCat(*tidy, ";--extra-arg-before=--driver-mode=", driverMode));
}
- if (cpplint && *cpplint) {
+ if (cpplint && !cpplint->empty()) {
run_iwyu += cmStrCat(
- " --cpplint=", this->GetLocalGenerator()->EscapeForShell(cpplint));
+ " --cpplint=", this->GetLocalGenerator()->EscapeForShell(*cpplint));
}
- if (cppcheck && *cppcheck) {
- run_iwyu += cmStrCat(
- " --cppcheck=", this->GetLocalGenerator()->EscapeForShell(cppcheck));
+ if (cppcheck && !cppcheck->empty()) {
+ run_iwyu +=
+ cmStrCat(" --cppcheck=",
+ this->GetLocalGenerator()->EscapeForShell(*cppcheck));
}
- if ((tidy && *tidy) || (cpplint && *cpplint) ||
- (cppcheck && *cppcheck)) {
+ if ((tidy && !tidy->empty()) || (cpplint && !cpplint->empty()) ||
+ (cppcheck && !cppcheck->empty())) {
run_iwyu += " --source=$in";
}
run_iwyu += " -- ";
@@ -976,8 +977,8 @@ void cmNinjaTargetGenerator::WriteObjectBuildStatements(
"output-file-map.json");
std::string const targetSwiftDepsPath = [this, config]() -> std::string {
cmGeneratorTarget const* target = this->GeneratorTarget;
- if (const char* name = target->GetProperty("Swift_DEPENDENCIES_FILE")) {
- return name;
+ if (cmProp name = target->GetProperty("Swift_DEPENDENCIES_FILE")) {
+ return *name;
}
return this->ConvertToNinjaPath(
cmStrCat(target->GetSupportDirectory(), '/', config, '/',
@@ -1444,11 +1445,11 @@ void cmNinjaTargetGenerator::ExportObjectCompileCommand(
void cmNinjaTargetGenerator::AdditionalCleanFiles(const std::string& config)
{
- if (const char* prop_value =
+ if (cmProp prop_value =
this->GeneratorTarget->GetProperty("ADDITIONAL_CLEAN_FILES")) {
cmLocalNinjaGenerator* lg = this->LocalGenerator;
std::vector<std::string> cleanFiles;
- cmExpandList(cmGeneratorExpression::Evaluate(prop_value, lg, config,
+ cmExpandList(cmGeneratorExpression::Evaluate(*prop_value, lg, config,
this->GeneratorTarget),
cleanFiles);
std::string const& binaryDir = lg->GetCurrentBinaryDirectory();
@@ -1534,9 +1535,9 @@ void cmNinjaTargetGenerator::addPoolNinjaVariable(
const std::string& pool_property, cmGeneratorTarget* target,
cmNinjaVars& vars)
{
- const char* pool = target->GetProperty(pool_property);
+ cmProp pool = target->GetProperty(pool_property);
if (pool) {
- vars["pool"] = pool;
+ vars["pool"] = *pool;
}
}
diff --git a/Source/cmNinjaUtilityTargetGenerator.cxx b/Source/cmNinjaUtilityTargetGenerator.cxx
index a42d65d..134924e 100644
--- a/Source/cmNinjaUtilityTargetGenerator.cxx
+++ b/Source/cmNinjaUtilityTargetGenerator.cxx
@@ -110,9 +110,9 @@ void cmNinjaUtilityTargetGenerator::Generate(const std::string& config)
std::string command =
lg->BuildCommandLine(commands, "utility", this->GeneratorTarget);
std::string desc;
- const char* echoStr = genTarget->GetProperty("EchoString");
+ cmProp echoStr = genTarget->GetProperty("EchoString");
if (echoStr) {
- desc = echoStr;
+ desc = *echoStr;
} else {
desc = "Running utility command for " + this->GetTargetName();
}
diff --git a/Source/cmQtAutoGenInitializer.cxx b/Source/cmQtAutoGenInitializer.cxx
index b0a7c30..fa523cc 100644
--- a/Source/cmQtAutoGenInitializer.cxx
+++ b/Source/cmQtAutoGenInitializer.cxx
@@ -339,21 +339,18 @@ bool cmQtAutoGenInitializer::InitCustomTargets()
// Targets FOLDER
{
- cmProp prop =
+ cmProp folder =
this->Makefile->GetState()->GetGlobalProperty("AUTOMOC_TARGETS_FOLDER");
- if (prop == nullptr) {
- prop = this->Makefile->GetState()->GetGlobalProperty(
+ if (folder == nullptr) {
+ folder = this->Makefile->GetState()->GetGlobalProperty(
"AUTOGEN_TARGETS_FOLDER");
}
- const char* folder;
// Inherit FOLDER property from target (#13688)
- if (prop == nullptr) {
+ if (folder == nullptr) {
folder = this->GenTarget->GetProperty("FOLDER");
- } else {
- folder = prop->c_str();
}
if (folder != nullptr) {
- this->TargetsFolder = folder;
+ this->TargetsFolder = *folder;
}
}
diff --git a/Source/cmStringAlgorithms.cxx b/Source/cmStringAlgorithms.cxx
index bb6dcd7..71d28a4 100644
--- a/Source/cmStringAlgorithms.cxx
+++ b/Source/cmStringAlgorithms.cxx
@@ -4,7 +4,7 @@
#include <algorithm>
#include <cerrno>
-#include <cstddef>
+#include <cstddef> // IWYU pragma: keep
#include <cstdio>
#include <cstdlib>
diff --git a/Source/cmTestGenerator.cxx b/Source/cmTestGenerator.cxx
index 1142dbd..025a7b3 100644
--- a/Source/cmTestGenerator.cxx
+++ b/Source/cmTestGenerator.cxx
@@ -100,9 +100,9 @@ void cmTestGenerator::GenerateScriptForConfig(std::ostream& os,
exe = target->GetFullPath(config);
// Prepend with the emulator when cross compiling if required.
- const char* emulator = target->GetProperty("CROSSCOMPILING_EMULATOR");
- if (emulator != nullptr && *emulator) {
- std::vector<std::string> emulatorWithArgs = cmExpandedList(emulator);
+ cmProp emulator = target->GetProperty("CROSSCOMPILING_EMULATOR");
+ if (emulator != nullptr && !emulator->empty()) {
+ std::vector<std::string> emulatorWithArgs = cmExpandedList(*emulator);
std::string emulatorExe(emulatorWithArgs[0]);
cmSystemTools::ConvertToUnixSlashes(emulatorExe);
os << cmOutputConverter::EscapeForCMake(emulatorExe) << " ";
diff --git a/Source/cmUVProcessChain.h b/Source/cmUVProcessChain.h
index 05a7cc8..cd7397e 100644
--- a/Source/cmUVProcessChain.h
+++ b/Source/cmUVProcessChain.h
@@ -4,7 +4,7 @@
#define cmUVProcessChain_h
#include <array>
-#include <cstddef>
+#include <cstddef> // IWYU pragma: keep
#include <cstdint>
#include <iosfwd>
#include <memory>
diff --git a/Source/cmVisualStudio10TargetGenerator.cxx b/Source/cmVisualStudio10TargetGenerator.cxx
index 5f79eb0..9c2b302 100644
--- a/Source/cmVisualStudio10TargetGenerator.cxx
+++ b/Source/cmVisualStudio10TargetGenerator.cxx
@@ -431,32 +431,32 @@ void cmVisualStudio10TargetGenerator::Generate()
this->VerifyNecessaryFiles();
}
- const char* vsProjectTypes =
+ cmProp vsProjectTypes =
this->GeneratorTarget->GetProperty("VS_GLOBAL_PROJECT_TYPES");
if (vsProjectTypes) {
const char* tagName = "ProjectTypes";
if (this->ProjectType == csproj) {
tagName = "ProjectTypeGuids";
}
- e1.Element(tagName, vsProjectTypes);
+ e1.Element(tagName, *vsProjectTypes);
}
- const char* vsProjectName =
+ cmProp vsProjectName =
this->GeneratorTarget->GetProperty("VS_SCC_PROJECTNAME");
- const char* vsLocalPath =
+ cmProp vsLocalPath =
this->GeneratorTarget->GetProperty("VS_SCC_LOCALPATH");
- const char* vsProvider =
+ cmProp vsProvider =
this->GeneratorTarget->GetProperty("VS_SCC_PROVIDER");
if (vsProjectName && vsLocalPath && vsProvider) {
- e1.Element("SccProjectName", vsProjectName);
- e1.Element("SccLocalPath", vsLocalPath);
- e1.Element("SccProvider", vsProvider);
+ e1.Element("SccProjectName", *vsProjectName);
+ e1.Element("SccLocalPath", *vsLocalPath);
+ e1.Element("SccProvider", *vsProvider);
- const char* vsAuxPath =
+ cmProp vsAuxPath =
this->GeneratorTarget->GetProperty("VS_SCC_AUXPATH");
if (vsAuxPath) {
- e1.Element("SccAuxPath", vsAuxPath);
+ e1.Element("SccAuxPath", *vsAuxPath);
}
}
@@ -464,45 +464,44 @@ void cmVisualStudio10TargetGenerator::Generate()
e1.Element("WinMDAssembly", "true");
}
- const char* vsGlobalKeyword =
+ cmProp vsGlobalKeyword =
this->GeneratorTarget->GetProperty("VS_GLOBAL_KEYWORD");
if (!vsGlobalKeyword) {
e1.Element("Keyword", "Win32Proj");
} else {
- e1.Element("Keyword", vsGlobalKeyword);
+ e1.Element("Keyword", *vsGlobalKeyword);
}
- const char* vsGlobalRootNamespace =
+ cmProp vsGlobalRootNamespace =
this->GeneratorTarget->GetProperty("VS_GLOBAL_ROOTNAMESPACE");
if (vsGlobalRootNamespace) {
- e1.Element("RootNamespace", vsGlobalRootNamespace);
+ e1.Element("RootNamespace", *vsGlobalRootNamespace);
}
e1.Element("Platform", this->Platform);
- const char* projLabel =
- this->GeneratorTarget->GetProperty("PROJECT_LABEL");
+ cmProp projLabel = this->GeneratorTarget->GetProperty("PROJECT_LABEL");
if (!projLabel) {
- projLabel = this->Name.c_str();
+ projLabel = &this->Name;
}
- e1.Element("ProjectName", projLabel);
+ e1.Element("ProjectName", *projLabel);
{
- const char* targetFramework =
+ cmProp targetFramework =
this->GeneratorTarget->GetProperty("DOTNET_TARGET_FRAMEWORK");
if (targetFramework) {
- if (std::strchr(targetFramework, ';') != nullptr) {
- e1.Element("TargetFrameworks", targetFramework);
+ if (std::strchr(targetFramework->c_str(), ';') != nullptr) {
+ e1.Element("TargetFrameworks", *targetFramework);
} else {
- e1.Element("TargetFramework", targetFramework);
+ e1.Element("TargetFramework", *targetFramework);
}
} else {
// TODO: add deprecation warning for VS_* property?
- const char* targetFrameworkVersion =
- this->GeneratorTarget->GetProperty(
- "VS_DOTNET_TARGET_FRAMEWORK_VERSION");
- if (!targetFrameworkVersion) {
- targetFrameworkVersion = this->GeneratorTarget->GetProperty(
+ cmProp p = this->GeneratorTarget->GetProperty(
+ "VS_DOTNET_TARGET_FRAMEWORK_VERSION");
+ if (!p) {
+ p = this->GeneratorTarget->GetProperty(
"DOTNET_TARGET_FRAMEWORK_VERSION");
}
+ const char* targetFrameworkVersion = p ? p->c_str() : nullptr;
if (!targetFrameworkVersion && this->ProjectType == csproj &&
this->GlobalGenerator->TargetsWindowsCE() &&
this->GlobalGenerator->GetVersion() ==
@@ -521,18 +520,15 @@ void cmVisualStudio10TargetGenerator::Generate()
}
if (this->ProjectType == csproj &&
this->GlobalGenerator->TargetsWindowsCE()) {
- const char* targetFrameworkId = this->GeneratorTarget->GetProperty(
+ cmProp targetFrameworkId = this->GeneratorTarget->GetProperty(
"VS_TARGET_FRAMEWORK_IDENTIFIER");
- if (!targetFrameworkId) {
- targetFrameworkId = "WindowsEmbeddedCompact";
- }
- e1.Element("TargetFrameworkIdentifier", targetFrameworkId);
- const char* targetFrameworkVer = this->GeneratorTarget->GetProperty(
+ e1.Element("TargetFrameworkIdentifier",
+ targetFrameworkId ? *targetFrameworkId
+ : "WindowsEmbeddedCompact");
+ cmProp targetFrameworkVer = this->GeneratorTarget->GetProperty(
"VS_TARGET_FRAMEWORKS_TARGET_VERSION");
- if (!targetFrameworkVer) {
- targetFrameworkVer = "v8.0";
- }
- e1.Element("TargetFrameworkTargetsVersion", targetFrameworkVer);
+ e1.Element("TargetFrameworkTargetsVersion",
+ targetFrameworkVer ? *targetFrameworkVer : "v8.0");
}
if (!this->GlobalGenerator->GetPlatformToolsetCudaCustomDirString()
.empty()) {
@@ -568,10 +564,10 @@ void cmVisualStudio10TargetGenerator::Generate()
globalKey == "ROOTNAMESPACE" || globalKey == "KEYWORD") {
continue;
}
- const char* value = this->GeneratorTarget->GetProperty(keyIt);
+ cmProp value = this->GeneratorTarget->GetProperty(keyIt);
if (!value)
continue;
- e1.Element(globalKey, value);
+ e1.Element(globalKey, *value);
}
if (this->Managed) {
@@ -676,9 +672,8 @@ void cmVisualStudio10TargetGenerator::Generate()
props = VS10_CSharp_USER_PROPS;
break;
}
- if (const char* p =
- this->GeneratorTarget->GetProperty("VS_USER_PROPS")) {
- props = p;
+ if (cmProp p = this->GeneratorTarget->GetProperty("VS_USER_PROPS")) {
+ props = *p;
}
if (!props.empty()) {
ConvertToWindowsSlash(props);
@@ -784,9 +779,9 @@ void cmVisualStudio10TargetGenerator::Generate()
void cmVisualStudio10TargetGenerator::WritePackageReferences(Elem& e0)
{
std::vector<std::string> packageReferences;
- if (const char* vsPackageReferences =
+ if (cmProp vsPackageReferences =
this->GeneratorTarget->GetProperty("VS_PACKAGE_REFERENCES")) {
- cmExpandList(vsPackageReferences, packageReferences);
+ cmExpandList(*vsPackageReferences, packageReferences);
}
if (!packageReferences.empty()) {
Elem e1(e0, "ItemGroup");
@@ -804,9 +799,9 @@ void cmVisualStudio10TargetGenerator::WritePackageReferences(Elem& e0)
void cmVisualStudio10TargetGenerator::WriteDotNetReferences(Elem& e0)
{
std::vector<std::string> references;
- if (const char* vsDotNetReferences =
+ if (cmProp vsDotNetReferences =
this->GeneratorTarget->GetProperty("VS_DOTNET_REFERENCES")) {
- cmExpandList(vsDotNetReferences, references);
+ cmExpandList(*vsDotNetReferences, references);
}
cmPropertyMap const& props = this->GeneratorTarget->Target->GetProperties();
for (auto const& i : props.GetList()) {
@@ -863,9 +858,9 @@ void cmVisualStudio10TargetGenerator::WriteDotNetReference(
e2.Element("ReferenceOutputAssembly", "true");
if (!hint.empty()) {
const char* privateReference = "True";
- if (const char* value = this->GeneratorTarget->GetProperty(
+ if (cmProp value = this->GeneratorTarget->GetProperty(
"VS_DOTNET_REFERENCES_COPY_LOCAL")) {
- if (cmIsOff(value)) {
+ if (cmIsOff(*value)) {
privateReference = "False";
}
}
@@ -1082,9 +1077,9 @@ void cmVisualStudio10TargetGenerator::WriteTargetsFileReferences(Elem& e1)
void cmVisualStudio10TargetGenerator::WriteWinRTReferences(Elem& e0)
{
std::vector<std::string> references;
- if (const char* vsWinRTReferences =
+ if (cmProp vsWinRTReferences =
this->GeneratorTarget->GetProperty("VS_WINRT_REFERENCES")) {
- cmExpandList(vsWinRTReferences, references);
+ cmExpandList(*vsWinRTReferences, references);
}
if (this->GlobalGenerator->TargetsWindowsPhone() &&
@@ -1125,9 +1120,9 @@ void cmVisualStudio10TargetGenerator::WriteProjectConfigurationValues(Elem& e0)
if (this->ProjectType != csproj) {
std::string configType;
- if (const char* vsConfigurationType =
+ if (cmProp vsConfigurationType =
this->GeneratorTarget->GetProperty("VS_CONFIGURATION_TYPE")) {
- configType = cmGeneratorExpression::Evaluate(vsConfigurationType,
+ configType = cmGeneratorExpression::Evaluate(*vsConfigurationType,
this->LocalGenerator, c);
} else {
switch (this->GeneratorTarget->GetType()) {
@@ -1183,9 +1178,9 @@ void cmVisualStudio10TargetGenerator::WriteCEDebugProjectConfigurationValues(
if (!this->GlobalGenerator->TargetsWindowsCE()) {
return;
}
- const char* additionalFiles =
+ cmProp additionalFiles =
this->GeneratorTarget->GetProperty("DEPLOYMENT_ADDITIONAL_FILES");
- const char* remoteDirectory =
+ cmProp remoteDirectory =
this->GeneratorTarget->GetProperty("DEPLOYMENT_REMOTE_DIRECTORY");
if (!(additionalFiles || remoteDirectory)) {
return;
@@ -1195,10 +1190,10 @@ void cmVisualStudio10TargetGenerator::WriteCEDebugProjectConfigurationValues(
e1.Attribute("Condition", this->CalcCondition(c));
if (remoteDirectory) {
- e1.Element("RemoteDirectory", remoteDirectory);
+ e1.Element("RemoteDirectory", *remoteDirectory);
}
if (additionalFiles) {
- e1.Element("CEAdditionalFiles", additionalFiles);
+ e1.Element("CEAdditionalFiles", *additionalFiles);
}
}
}
@@ -1236,9 +1231,9 @@ void cmVisualStudio10TargetGenerator::WriteMSToolConfigurationValues(
} else {
e1.Element("CharacterSet", "MultiByte");
}
- if (const char* projectToolsetOverride =
+ if (cmProp projectToolsetOverride =
this->GeneratorTarget->GetProperty("VS_PLATFORM_TOOLSET")) {
- e1.Element("PlatformToolset", projectToolsetOverride);
+ e1.Element("PlatformToolset", *projectToolsetOverride);
} else if (const char* toolset = gg->GetPlatformToolset()) {
e1.Element("PlatformToolset", toolset);
}
@@ -1282,9 +1277,9 @@ void cmVisualStudio10TargetGenerator::WriteMSToolConfigurationValuesManaged(
o.RemoveFlag("Platform");
}
- if (const char* projectToolsetOverride =
+ if (cmProp projectToolsetOverride =
this->GeneratorTarget->GetProperty("VS_PLATFORM_TOOLSET")) {
- e1.Element("PlatformToolset", projectToolsetOverride);
+ e1.Element("PlatformToolset", *projectToolsetOverride);
} else if (const char* toolset = gg->GetPlatformToolset()) {
e1.Element("PlatformToolset", toolset);
}
@@ -1293,8 +1288,8 @@ void cmVisualStudio10TargetGenerator::WriteMSToolConfigurationValuesManaged(
cmStrCat(cmSystemTools::UpperCase(config), "_POSTFIX");
std::string assemblyName = this->GeneratorTarget->GetOutputName(
config, cmStateEnums::RuntimeBinaryArtifact);
- if (const char* postfix = this->GeneratorTarget->GetProperty(postfixName)) {
- assemblyName += postfix;
+ if (cmProp postfix = this->GeneratorTarget->GetProperty(postfixName)) {
+ assemblyName += *postfix;
}
e1.Element("AssemblyName", assemblyName);
@@ -1314,22 +1309,20 @@ void cmVisualStudio10TargetGenerator::WriteNsightTegraConfigurationValues(
cmGlobalVisualStudio10Generator* gg = this->GlobalGenerator;
const char* toolset = gg->GetPlatformToolset();
e1.Element("NdkToolchainVersion", toolset ? toolset : "Default");
- if (const char* minApi =
- this->GeneratorTarget->GetProperty("ANDROID_API_MIN")) {
- e1.Element("AndroidMinAPI", "android-" + std::string(minApi));
+ if (cmProp minApi = this->GeneratorTarget->GetProperty("ANDROID_API_MIN")) {
+ e1.Element("AndroidMinAPI", "android-" + *minApi);
}
- if (const char* api = this->GeneratorTarget->GetProperty("ANDROID_API")) {
- e1.Element("AndroidTargetAPI", "android-" + std::string(api));
+ if (cmProp api = this->GeneratorTarget->GetProperty("ANDROID_API")) {
+ e1.Element("AndroidTargetAPI", "android-" + *api);
}
- if (const char* cpuArch =
- this->GeneratorTarget->GetProperty("ANDROID_ARCH")) {
- e1.Element("AndroidArch", cpuArch);
+ if (cmProp cpuArch = this->GeneratorTarget->GetProperty("ANDROID_ARCH")) {
+ e1.Element("AndroidArch", *cpuArch);
}
- if (const char* stlType =
+ if (cmProp stlType =
this->GeneratorTarget->GetProperty("ANDROID_STL_TYPE")) {
- e1.Element("AndroidStlType", stlType);
+ e1.Element("AndroidStlType", *stlType);
}
}
@@ -2512,34 +2505,34 @@ void cmVisualStudio10TargetGenerator::WritePathAndIncrementalLinkOptions(
const std::string cond = this->CalcCondition(config);
if (ttype <= cmStateEnums::UTILITY) {
- if (const char* workingDir = this->GeneratorTarget->GetProperty(
+ if (cmProp workingDir = this->GeneratorTarget->GetProperty(
"VS_DEBUGGER_WORKING_DIRECTORY")) {
std::string genWorkingDir = cmGeneratorExpression::Evaluate(
- workingDir, this->LocalGenerator, config);
+ *workingDir, this->LocalGenerator, config);
e1.WritePlatformConfigTag("LocalDebuggerWorkingDirectory", cond,
genWorkingDir);
}
- if (const char* environment =
+ if (cmProp environment =
this->GeneratorTarget->GetProperty("VS_DEBUGGER_ENVIRONMENT")) {
std::string genEnvironment = cmGeneratorExpression::Evaluate(
- environment, this->LocalGenerator, config);
+ *environment, this->LocalGenerator, config);
e1.WritePlatformConfigTag("LocalDebuggerEnvironment", cond,
genEnvironment);
}
- if (const char* debuggerCommand =
+ if (cmProp debuggerCommand =
this->GeneratorTarget->GetProperty("VS_DEBUGGER_COMMAND")) {
std::string genDebuggerCommand = cmGeneratorExpression::Evaluate(
- debuggerCommand, this->LocalGenerator, config);
+ *debuggerCommand, this->LocalGenerator, config);
e1.WritePlatformConfigTag("LocalDebuggerCommand", cond,
genDebuggerCommand);
}
- if (const char* commandArguments = this->GeneratorTarget->GetProperty(
+ if (cmProp commandArguments = this->GeneratorTarget->GetProperty(
"VS_DEBUGGER_COMMAND_ARGUMENTS")) {
std::string genCommandArguments = cmGeneratorExpression::Evaluate(
- commandArguments, this->LocalGenerator, config);
+ *commandArguments, this->LocalGenerator, config);
e1.WritePlatformConfigTag("LocalDebuggerCommandArguments", cond,
genCommandArguments);
}
@@ -2799,9 +2792,9 @@ bool cmVisualStudio10TargetGenerator::ComputeClOptions(
this->Makefile->IssueMessage(MessageType::WARNING, message);
}
}
- if (auto* clr =
+ if (cmProp clr =
this->GeneratorTarget->GetProperty("COMMON_LANGUAGE_RUNTIME")) {
- std::string clrString = clr;
+ std::string clrString = *clr;
if (!clrString.empty()) {
clrString = ":" + clrString;
}
@@ -2919,9 +2912,9 @@ void cmVisualStudio10TargetGenerator::WriteClOptions(
oh.OutputPreprocessorDefinitions(this->LangForClCompile);
if (this->NsightTegra) {
- if (const char* processMax =
+ if (cmProp processMax =
this->GeneratorTarget->GetProperty("ANDROID_PROCESS_MAX")) {
- e2.Element("ProcessMax", processMax);
+ e2.Element("ProcessMax", *processMax);
}
}
@@ -3466,7 +3459,7 @@ void cmVisualStudio10TargetGenerator::WriteManifestOptions(
std::vector<cmSourceFile const*> manifest_srcs;
this->GeneratorTarget->GetManifests(manifest_srcs, config);
- const char* dpiAware = this->GeneratorTarget->GetProperty("VS_DPI_AWARE");
+ cmProp dpiAware = this->GeneratorTarget->GetProperty("VS_DPI_AWARE");
if (!manifest_srcs.empty() || dpiAware) {
Elem e2(e1, "Manifest");
@@ -3480,15 +3473,14 @@ void cmVisualStudio10TargetGenerator::WriteManifestOptions(
e2.Element("AdditionalManifestFiles", oss.str());
}
if (dpiAware) {
- if (!strcmp(dpiAware, "PerMonitor")) {
+ if (*dpiAware == "PerMonitor") {
e2.Element("EnableDpiAwareness", "PerMonitorHighDPIAware");
- } else if (cmIsOn(dpiAware)) {
+ } else if (cmIsOn(*dpiAware)) {
e2.Element("EnableDpiAwareness", "true");
- } else if (cmIsOff(dpiAware)) {
+ } else if (cmIsOff(*dpiAware)) {
e2.Element("EnableDpiAwareness", "false");
} else {
- cmSystemTools::Error("Bad parameter for VS_DPI_AWARE: " +
- std::string(dpiAware));
+ cmSystemTools::Error("Bad parameter for VS_DPI_AWARE: " + *dpiAware);
}
}
}
@@ -3528,51 +3520,51 @@ void cmVisualStudio10TargetGenerator::WriteAntBuildOptions(
e2.Element("EnableProGuard", "true");
}
- if (const char* proGuardConfigLocation =
+ if (cmProp proGuardConfigLocation =
this->GeneratorTarget->GetProperty("ANDROID_PROGUARD_CONFIG_PATH")) {
- e2.Element("ProGuardConfigLocation", proGuardConfigLocation);
+ e2.Element("ProGuardConfigLocation", *proGuardConfigLocation);
}
- if (const char* securePropertiesLocation =
+ if (cmProp securePropertiesLocation =
this->GeneratorTarget->GetProperty("ANDROID_SECURE_PROPS_PATH")) {
- e2.Element("SecurePropertiesLocation", securePropertiesLocation);
+ e2.Element("SecurePropertiesLocation", *securePropertiesLocation);
}
- if (const char* nativeLibDirectoriesExpression =
+ if (cmProp nativeLibDirectoriesExpression =
this->GeneratorTarget->GetProperty("ANDROID_NATIVE_LIB_DIRECTORIES")) {
std::string nativeLibDirs = cmGeneratorExpression::Evaluate(
- nativeLibDirectoriesExpression, this->LocalGenerator, configName);
+ *nativeLibDirectoriesExpression, this->LocalGenerator, configName);
e2.Element("NativeLibDirectories", nativeLibDirs);
}
- if (const char* nativeLibDependenciesExpression =
+ if (cmProp nativeLibDependenciesExpression =
this->GeneratorTarget->GetProperty(
"ANDROID_NATIVE_LIB_DEPENDENCIES")) {
std::string nativeLibDeps = cmGeneratorExpression::Evaluate(
- nativeLibDependenciesExpression, this->LocalGenerator, configName);
+ *nativeLibDependenciesExpression, this->LocalGenerator, configName);
e2.Element("NativeLibDependencies", nativeLibDeps);
}
- if (const char* javaSourceDir =
+ if (cmProp javaSourceDir =
this->GeneratorTarget->GetProperty("ANDROID_JAVA_SOURCE_DIR")) {
- e2.Element("JavaSourceDir", javaSourceDir);
+ e2.Element("JavaSourceDir", *javaSourceDir);
}
- if (const char* jarDirectoriesExpression =
+ if (cmProp jarDirectoriesExpression =
this->GeneratorTarget->GetProperty("ANDROID_JAR_DIRECTORIES")) {
std::string jarDirectories = cmGeneratorExpression::Evaluate(
- jarDirectoriesExpression, this->LocalGenerator, configName);
+ *jarDirectoriesExpression, this->LocalGenerator, configName);
e2.Element("JarDirectories", jarDirectories);
}
- if (const char* jarDeps =
+ if (cmProp jarDeps =
this->GeneratorTarget->GetProperty("ANDROID_JAR_DEPENDENCIES")) {
- e2.Element("JarDependencies", jarDeps);
+ e2.Element("JarDependencies", *jarDeps);
}
- if (const char* assetsDirectories =
+ if (cmProp assetsDirectories =
this->GeneratorTarget->GetProperty("ANDROID_ASSETS_DIRECTORIES")) {
- e2.Element("AssetsDirectories", assetsDirectories);
+ e2.Element("AssetsDirectories", *assetsDirectories);
}
{
@@ -3581,10 +3573,10 @@ void cmVisualStudio10TargetGenerator::WriteAntBuildOptions(
e2.Element("AndroidManifestLocation", manifest_xml);
}
- if (const char* antAdditionalOptions =
+ if (cmProp antAdditionalOptions =
this->GeneratorTarget->GetProperty("ANDROID_ANT_ADDITIONAL_OPTIONS")) {
e2.Element("AdditionalOptions",
- std::string(antAdditionalOptions) + " %(AdditionalOptions)");
+ *antAdditionalOptions + " %(AdditionalOptions)");
}
}
@@ -3636,17 +3628,15 @@ bool cmVisualStudio10TargetGenerator::ComputeLinkOptions(
std::string linkFlagVar = linkFlagVarBase + "_" + CONFIG;
flags += " ";
flags += this->Makefile->GetRequiredDefinition(linkFlagVar);
- const char* targetLinkFlags =
- this->GeneratorTarget->GetProperty("LINK_FLAGS");
+ cmProp targetLinkFlags = this->GeneratorTarget->GetProperty("LINK_FLAGS");
if (targetLinkFlags) {
flags += " ";
- flags += targetLinkFlags;
+ flags += *targetLinkFlags;
}
std::string flagsProp = cmStrCat("LINK_FLAGS_", CONFIG);
- if (const char* flagsConfig =
- this->GeneratorTarget->GetProperty(flagsProp)) {
+ if (cmProp flagsConfig = this->GeneratorTarget->GetProperty(flagsProp)) {
flags += " ";
- flags += flagsConfig;
+ flags += *flagsConfig;
}
std::vector<std::string> opts;
@@ -4125,9 +4115,9 @@ void cmVisualStudio10TargetGenerator::WriteProjectReferences(Elem& e0)
cmLocalGenerator* lg = dt->GetLocalGenerator();
std::string name = dt->GetName();
std::string path;
- const char* p = dt->GetProperty("EXTERNAL_MSPROJECT");
+ cmProp p = dt->GetProperty("EXTERNAL_MSPROJECT");
if (p) {
- path = p;
+ path = *p;
} else {
path = cmStrCat(lg->GetCurrentBinaryDirectory(), '/', dt->GetName(),
computeProjectFileExtension(dt));
@@ -4155,17 +4145,17 @@ void cmVisualStudio10TargetGenerator::WritePlatformExtensions(Elem& e1)
// This only applies to Windows 10 apps
if (this->GlobalGenerator->TargetsWindowsStore() &&
cmHasLiteralPrefix(this->GlobalGenerator->GetSystemVersion(), "10.0")) {
- const char* desktopExtensionsVersion =
+ cmProp desktopExtensionsVersion =
this->GeneratorTarget->GetProperty("VS_DESKTOP_EXTENSIONS_VERSION");
if (desktopExtensionsVersion) {
this->WriteSinglePlatformExtension(e1, "WindowsDesktop",
- desktopExtensionsVersion);
+ *desktopExtensionsVersion);
}
- const char* mobileExtensionsVersion =
+ cmProp mobileExtensionsVersion =
this->GeneratorTarget->GetProperty("VS_MOBILE_EXTENSIONS_VERSION");
if (mobileExtensionsVersion) {
this->WriteSinglePlatformExtension(e1, "WindowsMobile",
- mobileExtensionsVersion);
+ *mobileExtensionsVersion);
}
}
}
@@ -4190,9 +4180,9 @@ void cmVisualStudio10TargetGenerator::WriteSDKReferences(Elem& e0)
{
std::vector<std::string> sdkReferences;
std::unique_ptr<Elem> spe1;
- if (const char* vsSDKReferences =
+ if (cmProp vsSDKReferences =
this->GeneratorTarget->GetProperty("VS_SDK_REFERENCES")) {
- cmExpandList(vsSDKReferences, sdkReferences);
+ cmExpandList(*vsSDKReferences, sdkReferences);
spe1 = cm::make_unique<Elem>(e0, "ItemGroup");
for (std::string const& ri : sdkReferences) {
Elem(*spe1, "SDKReference").Attribute("Include", ri);
@@ -4202,11 +4192,11 @@ void cmVisualStudio10TargetGenerator::WriteSDKReferences(Elem& e0)
// This only applies to Windows 10 apps
if (this->GlobalGenerator->TargetsWindowsStore() &&
cmHasLiteralPrefix(this->GlobalGenerator->GetSystemVersion(), "10.0")) {
- const char* desktopExtensionsVersion =
+ cmProp desktopExtensionsVersion =
this->GeneratorTarget->GetProperty("VS_DESKTOP_EXTENSIONS_VERSION");
- const char* mobileExtensionsVersion =
+ cmProp mobileExtensionsVersion =
this->GeneratorTarget->GetProperty("VS_MOBILE_EXTENSIONS_VERSION");
- const char* iotExtensionsVersion =
+ cmProp iotExtensionsVersion =
this->GeneratorTarget->GetProperty("VS_IOT_EXTENSIONS_VERSION");
if (desktopExtensionsVersion || mobileExtensionsVersion ||
@@ -4216,15 +4206,15 @@ void cmVisualStudio10TargetGenerator::WriteSDKReferences(Elem& e0)
}
if (desktopExtensionsVersion) {
this->WriteSingleSDKReference(*spe1, "WindowsDesktop",
- desktopExtensionsVersion);
+ *desktopExtensionsVersion);
}
if (mobileExtensionsVersion) {
this->WriteSingleSDKReference(*spe1, "WindowsMobile",
- mobileExtensionsVersion);
+ *mobileExtensionsVersion);
}
if (iotExtensionsVersion) {
this->WriteSingleSDKReference(*spe1, "WindowsIoT",
- iotExtensionsVersion);
+ *iotExtensionsVersion);
}
}
}
@@ -4375,10 +4365,10 @@ void cmVisualStudio10TargetGenerator::WriteApplicationTypeSettings(Elem& e1)
if (!targetPlatformVersion.empty()) {
e1.Element("WindowsTargetPlatformVersion", targetPlatformVersion);
}
- const char* targetPlatformMinVersion = this->GeneratorTarget->GetProperty(
+ cmProp targetPlatformMinVersion = this->GeneratorTarget->GetProperty(
"VS_WINDOWS_TARGET_PLATFORM_MIN_VERSION");
if (targetPlatformMinVersion) {
- e1.Element("WindowsTargetPlatformMinVersion", targetPlatformMinVersion);
+ e1.Element("WindowsTargetPlatformMinVersion", *targetPlatformMinVersion);
} else if (isWindowsStore && rev == "10.0") {
// If the min version is not set, then use the TargetPlatformVersion
if (!targetPlatformVersion.empty()) {
diff --git a/Source/cmVisualStudioGeneratorOptions.cxx b/Source/cmVisualStudioGeneratorOptions.cxx
index 4004b66..7775f62 100644
--- a/Source/cmVisualStudioGeneratorOptions.cxx
+++ b/Source/cmVisualStudioGeneratorOptions.cxx
@@ -157,12 +157,11 @@ void cmVisualStudioGeneratorOptions::FixCudaRuntime(cmGeneratorTarget* target)
this->FlagMap.find("CudaRuntime");
if (i == this->FlagMap.end()) {
// User didn't provide am override so get the property value
- const char* runtimeLibraryValue =
- target->GetProperty("CUDA_RUNTIME_LIBRARY");
+ cmProp runtimeLibraryValue = target->GetProperty("CUDA_RUNTIME_LIBRARY");
if (runtimeLibraryValue) {
std::string cudaRuntime =
cmSystemTools::UpperCase(cmGeneratorExpression::Evaluate(
- runtimeLibraryValue, this->LocalGenerator, this->Configuration,
+ *runtimeLibraryValue, this->LocalGenerator, this->Configuration,
target));
if (cudaRuntime == "STATIC") {
this->AddFlag("CudaRuntime", "Static");
diff --git a/Source/cmXCodeScheme.cxx b/Source/cmXCodeScheme.cxx
index 1b437e9..aab367a 100644
--- a/Source/cmXCodeScheme.cxx
+++ b/Source/cmXCodeScheme.cxx
@@ -204,14 +204,14 @@ void cmXCodeScheme::WriteLaunchAction(cmXMLWriter& xout,
// Info tab begin
- if (const char* exe =
+ if (cmProp exe =
this->Target->GetTarget()->GetProperty("XCODE_SCHEME_EXECUTABLE")) {
xout.StartElement("PathRunnable");
xout.BreakAttributes();
xout.Attribute("runnableDebuggingMode", "0");
- xout.Attribute("FilePath", exe);
+ xout.Attribute("FilePath", *exe);
xout.EndElement(); // PathRunnable
}
@@ -220,9 +220,9 @@ void cmXCodeScheme::WriteLaunchAction(cmXMLWriter& xout,
// Arguments tab begin
- if (const char* argList =
+ if (cmProp argList =
this->Target->GetTarget()->GetProperty("XCODE_SCHEME_ARGUMENTS")) {
- std::vector<std::string> arguments = cmExpandedList(argList);
+ std::vector<std::string> arguments = cmExpandedList(*argList);
if (!arguments.empty()) {
xout.StartElement("CommandLineArguments");
@@ -240,9 +240,9 @@ void cmXCodeScheme::WriteLaunchAction(cmXMLWriter& xout,
}
}
- if (const char* envList =
+ if (cmProp envList =
this->Target->GetTarget()->GetProperty("XCODE_SCHEME_ENVIRONMENT")) {
- std::vector<std::string> envs = cmExpandedList(envList);
+ std::vector<std::string> envs = cmExpandedList(*envList);
if (!envs.empty()) {
xout.StartElement("EnvironmentVariables");
@@ -323,8 +323,9 @@ bool cmXCodeScheme::WriteLaunchActionBooleanAttribute(
cmXMLWriter& xout, const std::string& attrName, const std::string& varName,
bool defaultValue)
{
- auto property = Target->GetTarget()->GetProperty(varName);
- bool isOn = (property == nullptr && defaultValue) || cmIsOn(property);
+ cmProp property = Target->GetTarget()->GetProperty(varName);
+ bool isOn =
+ (property == nullptr && defaultValue) || (property && cmIsOn(*property));
if (isOn) {
xout.Attribute(attrName.c_str(), "YES");
diff --git a/Source/cmXMLWriter.h b/Source/cmXMLWriter.h
index bc445aa..00ea08c 100644
--- a/Source/cmXMLWriter.h
+++ b/Source/cmXMLWriter.h
@@ -6,7 +6,7 @@
#include "cmConfigure.h" // IWYU pragma: keep
#include <chrono>
-#include <cstddef>
+#include <cstddef> // IWYU pragma: keep
#include <ctime>
#include <ostream>
#include <stack>
diff --git a/Tests/CMakeLib/testCTestBinPacker.cxx b/Tests/CMakeLib/testCTestBinPacker.cxx
index 6f09af2..abdbefb 100644
--- a/Tests/CMakeLib/testCTestBinPacker.cxx
+++ b/Tests/CMakeLib/testCTestBinPacker.cxx
@@ -1,4 +1,4 @@
-#include <cstddef>
+#include <cstddef> // IWYU pragma: keep
#include <iostream>
#include <map>
#include <string>
diff --git a/Tests/CMakeLib/testGccDepfileReader.cxx b/Tests/CMakeLib/testGccDepfileReader.cxx
index 924d87b..e79f047 100644
--- a/Tests/CMakeLib/testGccDepfileReader.cxx
+++ b/Tests/CMakeLib/testGccDepfileReader.cxx
@@ -1,4 +1,4 @@
-#include <cstddef>
+#include <cstddef> // IWYU pragma: keep
#include <iostream>
#include <memory>
#include <string>
diff --git a/Tests/CMakeLib/testString.cxx b/Tests/CMakeLib/testString.cxx
index 539f2dd..ad800cf 100644
--- a/Tests/CMakeLib/testString.cxx
+++ b/Tests/CMakeLib/testString.cxx
@@ -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. */
-#include <cstddef>
+#include <cstddef> // IWYU pragma: keep
#include <cstring>
#include <iostream>
#include <iterator>
diff --git a/Tests/RunCMake/CTestResourceAllocation/ctresalloc.cxx b/Tests/RunCMake/CTestResourceAllocation/ctresalloc.cxx
index 80db05e..daf8a2d 100644
--- a/Tests/RunCMake/CTestResourceAllocation/ctresalloc.cxx
+++ b/Tests/RunCMake/CTestResourceAllocation/ctresalloc.cxx
@@ -1,6 +1,6 @@
#include <cassert>
#include <chrono>
-#include <cstddef>
+#include <cstddef> // IWYU pragma: keep
#include <cstdlib>
#include <iostream>
#include <map>
diff --git a/Tests/RunCMake/ctest_start/NoStartTimeNightly-result.txt b/Tests/RunCMake/ctest_start/NoStartTimeNightly-result.txt
new file mode 100644
index 0000000..b57e2de
--- /dev/null
+++ b/Tests/RunCMake/ctest_start/NoStartTimeNightly-result.txt
@@ -0,0 +1 @@
+(-1|255)
diff --git a/Tests/RunCMake/ctest_start/NoStartTimeNightly-stderr.txt b/Tests/RunCMake/ctest_start/NoStartTimeNightly-stderr.txt
new file mode 100644
index 0000000..79756eb
--- /dev/null
+++ b/Tests/RunCMake/ctest_start/NoStartTimeNightly-stderr.txt
@@ -0,0 +1,4 @@
+^WARNING: No nightly start time found please set in CTestConfig\.cmake or DartConfig\.cmake
+CMake Error at [^
+]*/Tests/RunCMake/ctest_start/NoStartTimeNightly/test\.cmake:[0-9]+ \(ctest_start\):
+ ctest_start unknown error\.$
diff --git a/Tests/RunCMake/ctest_start/RunCMakeTest.cmake b/Tests/RunCMake/ctest_start/RunCMakeTest.cmake
index da85b39..f11f1ec 100644
--- a/Tests/RunCMake/ctest_start/RunCMakeTest.cmake
+++ b/Tests/RunCMake/ctest_start/RunCMakeTest.cmake
@@ -48,6 +48,8 @@ run_ctest_start(TooManyArgs Experimental
${RunCMake_BINARY_DIR}/TooManyArgs-build
${RunCMake_BINARY_DIR}/TooManyArgs-build
${RunCMake_BINARY_DIR}/TooManyArgs-build)
+run_ctest_start(NoStartTimeExperimental Experimental)
+run_ctest_start(NoStartTimeNightly Nightly)
function(run_ConfigInBuild)
set(RunCMake_TEST_BINARY_DIR ${RunCMake_BINARY_DIR}/ConfigInBuild-build)
diff --git a/Tests/RunCMake/ctest_start/test.cmake.in b/Tests/RunCMake/ctest_start/test.cmake.in
index 8cd3cff..4063ece 100644
--- a/Tests/RunCMake/ctest_start/test.cmake.in
+++ b/Tests/RunCMake/ctest_start/test.cmake.in
@@ -8,7 +8,9 @@ set(CTEST_CMAKE_GENERATOR "@RunCMake_GENERATOR@")
set(CTEST_CMAKE_GENERATOR_PLATFORM "@RunCMake_GENERATOR_PLATFORM@")
set(CTEST_CMAKE_GENERATOR_TOOLSET "@RunCMake_GENERATOR_TOOLSET@")
set(CTEST_BUILD_CONFIGURATION "$ENV{CMAKE_CONFIG_TYPE}")
-set(CTEST_NIGHTLY_START_TIME "01:00:00 UTC")
+if(NOT "@CASE_NAME@" MATCHES "^NoStartTime")
+ set(CTEST_NIGHTLY_START_TIME "01:00:00 UTC")
+endif()
function(setup_tests)
ctest_start(${ctest_start_args})
diff --git a/Utilities/IWYU/mapping.imp b/Utilities/IWYU/mapping.imp
index 3497b53..87e8bad 100644
--- a/Utilities/IWYU/mapping.imp
+++ b/Utilities/IWYU/mapping.imp
@@ -27,6 +27,7 @@
{ include: [ "<bits/std_abs.h>", private, "<stdlib.h>", public ] },
{ include: [ "<bits/stdint-intn.h>", private, "<stdint.h>", public ] },
{ include: [ "<bits/stdint-uintn.h>", private, "<stdint.h>", public ] },
+ { include: [ "<bits/string_view.tcc>", private, "<string_view>", public ] },
{ include: [ "<bits/time.h>", private, "<time.h>", public ] },
{ include: [ "<bits/types/clock_t.h>", private, "<time.h>", public ] },
{ include: [ "<bits/types/mbstate_t.h>", private, "<wchar.h>", public ] },
@@ -77,6 +78,7 @@
# Use '-Xiwyu -v7' to see the fully qualified names that need this.
# TODO: Can this be simplified with an @-expression?
#{ symbol: [ "@std::__decay_and_strip<.*>::__type", private, "\"cmConfigure.h\"", public ] },
+ { symbol: [ "std::__decay_and_strip<bool>::__type", private, "\"cmConfigure.h\"", public ] },
{ symbol: [ "std::__decay_and_strip<char const (&)[1]>::__type", private, "\"cmConfigure.h\"", public ] },
{ symbol: [ "std::__decay_and_strip<cmCommand *&>::__type", private, "\"cmConfigure.h\"", public ] },
{ symbol: [ "std::__decay_and_strip<cmGeneratorTarget *&>::__type", private, "\"cmConfigure.h\"", public ] },
@@ -86,7 +88,9 @@
{ symbol: [ "std::__decay_and_strip<std::basic_string<char> &>::__type", private, "\"cmConfigure.h\"", public ] },
{ symbol: [ "std::__decay_and_strip<const std::basic_string<char> &>::__type", private, "\"cmConfigure.h\"", public ] },
{ symbol: [ "std::__decay_and_strip<cmFindPackageCommand::PathLabel &>::__type", private, "\"cmConfigure.h\"", public ] },
+ { symbol: [ "std::__decay_and_strip<cmGlobalNinjaGenerator::TargetAlias &>::__type", private, "\"cmConfigure.h\"", public ] },
{ symbol: [ "std::__decay_and_strip<__gnu_cxx::__normal_iterator<const cmCTestTestHandler::cmCTestTestProperties *, std::vector<cmCTestTestHandler::cmCTestTestProperties, std::allocator<cmCTestTestHandler::cmCTestTestProperties> > > &>::__type", private, "\"cmConfigure.h\"", public ] },
+ { symbol: [ "std::__decay_and_strip<const __gnu_cxx::__normal_iterator<std::pair<cm::string_view, std::function<void (ArgumentParser::Instance &, void *)> > *, std::vector<std::pair<cm::string_view, std::function<void (ArgumentParser::Instance &, void *)> >, std::allocator<std::pair<cm::string_view, std::function<void (ArgumentParser::Instance &, void *)> > > > > &>::__type", private, "\"cmConfigure.h\"", public ] },
{ symbol: [ "std::__success_type<std::chrono::duration<double, std::ratio<1, 1> > >::type", private, "\"cmConfigure.h\"", public ] },
{ symbol: [ "std::__success_type<std::chrono::duration<long, std::ratio<1, 1000000000> > >::type", private, "\"cmConfigure.h\"", public ] },
{ symbol: [ "std::enable_if<true, std::chrono::duration<long, std::ratio<1, 1> > >::type", private, "\"cmConfigure.h\"", public ] },
diff --git a/Utilities/cmlibuv/include/uv.h b/Utilities/cmlibuv/include/uv.h
index 5fa264c..6f32b48 100644
--- a/Utilities/cmlibuv/include/uv.h
+++ b/Utilities/cmlibuv/include/uv.h
@@ -269,6 +269,8 @@ typedef void* (*uv_realloc_func)(void* ptr, size_t size);
typedef void* (*uv_calloc_func)(size_t count, size_t size);
typedef void (*uv_free_func)(void* ptr);
+UV_EXTERN void uv_library_shutdown(void);
+
UV_EXTERN int uv_replace_allocator(uv_malloc_func malloc_func,
uv_realloc_func realloc_func,
uv_calloc_func calloc_func,
@@ -614,7 +616,12 @@ enum uv_udp_flags {
* Indicates that the message was received by recvmmsg, so the buffer provided
* must not be freed by the recv_cb callback.
*/
- UV_UDP_MMSG_CHUNK = 8
+ UV_UDP_MMSG_CHUNK = 8,
+
+ /*
+ * Indicates that recvmmsg should be used, if available.
+ */
+ UV_UDP_RECVMMSG = 256
};
typedef void (*uv_udp_send_cb)(uv_udp_send_t* req, int status);
@@ -1081,11 +1088,11 @@ UV_EXTERN int uv_cancel(uv_req_t* req);
struct uv_cpu_times_s {
- uint64_t user;
- uint64_t nice;
- uint64_t sys;
- uint64_t idle;
- uint64_t irq;
+ uint64_t user; /* milliseconds */
+ uint64_t nice; /* milliseconds */
+ uint64_t sys; /* milliseconds */
+ uint64_t idle; /* milliseconds */
+ uint64_t irq; /* milliseconds */
};
struct uv_cpu_info_s {
@@ -1292,7 +1299,8 @@ typedef enum {
UV_FS_READDIR,
UV_FS_CLOSEDIR,
UV_FS_STATFS,
- UV_FS_MKSTEMP
+ UV_FS_MKSTEMP,
+ UV_FS_LUTIME
} uv_fs_type;
struct uv_dir_s {
@@ -1317,6 +1325,7 @@ struct uv_fs_s {
UV_EXTERN uv_fs_type uv_fs_get_type(const uv_fs_t*);
UV_EXTERN ssize_t uv_fs_get_result(const uv_fs_t*);
+UV_EXTERN int uv_fs_get_system_error(const uv_fs_t*);
UV_EXTERN void* uv_fs_get_ptr(const uv_fs_t*);
UV_EXTERN const char* uv_fs_get_path(const uv_fs_t*);
UV_EXTERN uv_stat_t* uv_fs_get_statbuf(uv_fs_t*);
@@ -1465,6 +1474,12 @@ UV_EXTERN int uv_fs_futime(uv_loop_t* loop,
double atime,
double mtime,
uv_fs_cb cb);
+UV_EXTERN int uv_fs_lutime(uv_loop_t* loop,
+ uv_fs_t* req,
+ const char* path,
+ double atime,
+ double mtime,
+ uv_fs_cb cb);
UV_EXTERN int uv_fs_lstat(uv_loop_t* loop,
uv_fs_t* req,
const char* path,
diff --git a/Utilities/cmlibuv/include/uv/version.h b/Utilities/cmlibuv/include/uv/version.h
index 1536a35..f932483 100644
--- a/Utilities/cmlibuv/include/uv/version.h
+++ b/Utilities/cmlibuv/include/uv/version.h
@@ -26,12 +26,12 @@
* Versions with the same major number are ABI stable. API is allowed to
* evolve between minor releases, but only in a backwards compatible way.
* Make sure you update the -soname directives in configure.ac
- * and uv.gyp whenever you bump UV_VERSION_MAJOR or UV_VERSION_MINOR (but
+ * whenever you bump UV_VERSION_MAJOR or UV_VERSION_MINOR (but
* not UV_VERSION_PATCH.)
*/
#define UV_VERSION_MAJOR 1
-#define UV_VERSION_MINOR 35
+#define UV_VERSION_MINOR 37
#define UV_VERSION_PATCH 1
#define UV_VERSION_IS_RELEASE 0
#define UV_VERSION_SUFFIX "dev"
diff --git a/Utilities/cmlibuv/src/threadpool.c b/Utilities/cmlibuv/src/threadpool.c
index a8f433f..0998938 100644
--- a/Utilities/cmlibuv/src/threadpool.c
+++ b/Utilities/cmlibuv/src/threadpool.c
@@ -160,8 +160,8 @@ static void post(QUEUE* q, enum uv__work_kind kind) {
}
+void uv__threadpool_cleanup(void) {
#ifndef _WIN32
-UV_DESTRUCTOR(static void cleanup(void)) {
unsigned int i;
if (nthreads == 0)
@@ -181,8 +181,8 @@ UV_DESTRUCTOR(static void cleanup(void)) {
threads = NULL;
nthreads = 0;
-}
#endif
+}
static void init_threads(void) {
diff --git a/Utilities/cmlibuv/src/timer.c b/Utilities/cmlibuv/src/timer.c
index 9da513f..4cf4ed4 100644
--- a/Utilities/cmlibuv/src/timer.c
+++ b/Utilities/cmlibuv/src/timer.c
@@ -51,12 +51,7 @@ static int timer_less_than(const struct heap_node* ha,
/* Compare start_id when both have the same timeout. start_id is
* allocated with loop->timer_counter in uv_timer_start().
*/
- if (a->start_id < b->start_id)
- return 1;
- if (b->start_id < a->start_id)
- return 0;
-
- return 0;
+ return a->start_id < b->start_id;
}
diff --git a/Utilities/cmlibuv/src/unix/aix.c b/Utilities/cmlibuv/src/unix/aix.c
index 417ee55..6b4594b 100644
--- a/Utilities/cmlibuv/src/unix/aix.c
+++ b/Utilities/cmlibuv/src/unix/aix.c
@@ -926,7 +926,7 @@ int uv_get_process_title(char* buffer, size_t size) {
}
-UV_DESTRUCTOR(static void free_args_mem(void)) {
+void uv__process_title_cleanup(void) {
uv__free(args_mem); /* Keep valgrind happy. */
args_mem = NULL;
}
diff --git a/Utilities/cmlibuv/src/unix/async.c b/Utilities/cmlibuv/src/unix/async.c
index 26d337e..5f58fb8 100644
--- a/Utilities/cmlibuv/src/unix/async.c
+++ b/Utilities/cmlibuv/src/unix/async.c
@@ -32,6 +32,7 @@
#include <stdlib.h>
#include <string.h>
#include <unistd.h>
+#include <sched.h> /* sched_yield() */
#ifdef __linux__
#include <sys/eventfd.h>
@@ -81,20 +82,32 @@ int uv_async_send(uv_async_t* handle) {
/* Only call this from the event loop thread. */
static int uv__async_spin(uv_async_t* handle) {
+ int i;
int rc;
for (;;) {
- /* rc=0 -- handle is not pending.
- * rc=1 -- handle is pending, other thread is still working with it.
- * rc=2 -- handle is pending, other thread is done.
+ /* 997 is not completely chosen at random. It's a prime number, acyclical
+ * by nature, and should therefore hopefully dampen sympathetic resonance.
*/
- rc = cmpxchgi(&handle->pending, 2, 0);
-
- if (rc != 1)
- return rc;
-
- /* Other thread is busy with this handle, spin until it's done. */
- cpu_relax();
+ for (i = 0; i < 997; i++) {
+ /* rc=0 -- handle is not pending.
+ * rc=1 -- handle is pending, other thread is still working with it.
+ * rc=2 -- handle is pending, other thread is done.
+ */
+ rc = cmpxchgi(&handle->pending, 2, 0);
+
+ if (rc != 1)
+ return rc;
+
+ /* Other thread is busy with this handle, spin until it's done. */
+ cpu_relax();
+ }
+
+ /* Yield the CPU. We may have preempted the other thread while it's
+ * inside the critical section and if it's running on the same CPU
+ * as us, we'll just burn CPU cycles until the end of our time slice.
+ */
+ sched_yield();
}
}
diff --git a/Utilities/cmlibuv/src/unix/atomic-ops.h b/Utilities/cmlibuv/src/unix/atomic-ops.h
index 7efed02..2518a06 100644
--- a/Utilities/cmlibuv/src/unix/atomic-ops.h
+++ b/Utilities/cmlibuv/src/unix/atomic-ops.h
@@ -59,6 +59,8 @@ UV_UNUSED(static int cmpxchgi(int* ptr, int oldval, int newval)) {
UV_UNUSED(static void cpu_relax(void)) {
#if defined(__i386__) || defined(__x86_64__)
__asm__ __volatile__ ("rep; nop"); /* a.k.a. PAUSE */
+#elif (defined(__arm__) && __ARM_ARCH >= 7) || defined(__aarch64__)
+ __asm__ volatile("yield");
#endif
}
diff --git a/Utilities/cmlibuv/src/unix/bsd-proctitle.c b/Utilities/cmlibuv/src/unix/bsd-proctitle.c
index 0ce47c8..723b81c 100644
--- a/Utilities/cmlibuv/src/unix/bsd-proctitle.c
+++ b/Utilities/cmlibuv/src/unix/bsd-proctitle.c
@@ -37,6 +37,13 @@ static void init_process_title_mutex_once(void) {
}
+void uv__process_title_cleanup(void) {
+ /* TODO(bnoordhuis) uv_mutex_destroy(&process_title_mutex)
+ * and reset process_title_mutex_once?
+ */
+}
+
+
char** uv_setup_args(int argc, char** argv) {
process_title = argc > 0 ? uv__strdup(argv[0]) : NULL;
return argv;
diff --git a/Utilities/cmlibuv/src/unix/cmake-bootstrap.c b/Utilities/cmlibuv/src/unix/cmake-bootstrap.c
index d42ff05..6cf42fa 100644
--- a/Utilities/cmlibuv/src/unix/cmake-bootstrap.c
+++ b/Utilities/cmlibuv/src/unix/cmake-bootstrap.c
@@ -1,6 +1,12 @@
#include "uv.h"
#include "internal.h"
+void uv__process_title_cleanup(void) {
+}
+
+void uv__threadpool_cleanup(void) {
+}
+
int uv__tcp_nodelay(int fd, int on) {
errno = EINVAL;
return -1;
diff --git a/Utilities/cmlibuv/src/unix/core.c b/Utilities/cmlibuv/src/unix/core.c
index 898ecd6..7b80ed5 100644
--- a/Utilities/cmlibuv/src/unix/core.c
+++ b/Utilities/cmlibuv/src/unix/core.c
@@ -74,7 +74,7 @@ extern char** environ;
# include <sys/wait.h>
# include <sys/param.h>
# include <sys/cpuset.h>
-# if defined(__FreeBSD__) || defined(__linux__)
+# if defined(__FreeBSD__)
# define uv__accept4 accept4
# endif
# if defined(__NetBSD__)
@@ -91,7 +91,8 @@ extern char** environ;
#endif
#if defined(__linux__)
-#include <sys/syscall.h>
+# include <sys/syscall.h>
+# define uv__accept4 accept4
#endif
static int uv__run_pending(uv_loop_t* loop);
@@ -1260,7 +1261,7 @@ int uv_os_environ(uv_env_item_t** envitems, int* count) {
*envitems = uv__calloc(i, sizeof(**envitems));
- if (envitems == NULL)
+ if (*envitems == NULL)
return UV_ENOMEM;
for (j = 0, cnt = 0; j < i; j++) {
diff --git a/Utilities/cmlibuv/src/unix/darwin-proctitle.c b/Utilities/cmlibuv/src/unix/darwin-proctitle.c
index 2daf3e3..5288083 100644
--- a/Utilities/cmlibuv/src/unix/darwin-proctitle.c
+++ b/Utilities/cmlibuv/src/unix/darwin-proctitle.c
@@ -30,8 +30,7 @@
#include <TargetConditionals.h>
#if !TARGET_OS_IPHONE
-# include <CoreFoundation/CoreFoundation.h>
-# include <ApplicationServices/ApplicationServices.h>
+#include "darwin-stub.h"
#endif
diff --git a/Utilities/cmlibuv/src/unix/darwin-stub.h b/Utilities/cmlibuv/src/unix/darwin-stub.h
new file mode 100644
index 0000000..b93cf67
--- /dev/null
+++ b/Utilities/cmlibuv/src/unix/darwin-stub.h
@@ -0,0 +1,97 @@
+/* Copyright libuv project contributors. All rights reserved.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
+ * of this software and associated documentation files (the "Software"), to
+ * deal in the Software without restriction, including without limitation the
+ * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
+ * sell copies of the Software, and to permit persons to whom the Software is
+ * furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in
+ * all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
+ * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
+ * IN THE SOFTWARE.
+ */
+
+#ifndef UV_DARWIN_STUB_H_
+#define UV_DARWIN_STUB_H_
+
+#include <stdint.h>
+
+struct CFArrayCallBacks;
+struct CFRunLoopSourceContext;
+struct FSEventStreamContext;
+
+typedef double CFAbsoluteTime;
+typedef double CFTimeInterval;
+typedef int FSEventStreamEventFlags;
+typedef int OSStatus;
+typedef long CFIndex;
+typedef struct CFArrayCallBacks CFArrayCallBacks;
+typedef struct CFRunLoopSourceContext CFRunLoopSourceContext;
+typedef struct FSEventStreamContext FSEventStreamContext;
+typedef uint32_t FSEventStreamCreateFlags;
+typedef uint64_t FSEventStreamEventId;
+typedef unsigned CFStringEncoding;
+typedef void* CFAllocatorRef;
+typedef void* CFArrayRef;
+typedef void* CFBundleRef;
+typedef void* CFDictionaryRef;
+typedef void* CFRunLoopRef;
+typedef void* CFRunLoopSourceRef;
+typedef void* CFStringRef;
+typedef void* CFTypeRef;
+typedef void* FSEventStreamRef;
+
+typedef void (*FSEventStreamCallback)(const FSEventStreamRef,
+ void*,
+ size_t,
+ void*,
+ const FSEventStreamEventFlags*,
+ const FSEventStreamEventId*);
+
+struct CFRunLoopSourceContext {
+ CFIndex version;
+ void* info;
+ void* pad[7];
+ void (*perform)(void*);
+};
+
+struct FSEventStreamContext {
+ CFIndex version;
+ void* info;
+ void* pad[3];
+};
+
+static const CFStringEncoding kCFStringEncodingUTF8 = 0x8000100;
+static const OSStatus noErr = 0;
+
+static const FSEventStreamEventId kFSEventStreamEventIdSinceNow = -1;
+
+static const int kFSEventStreamCreateFlagNoDefer = 2;
+static const int kFSEventStreamCreateFlagFileEvents = 16;
+
+static const int kFSEventStreamEventFlagEventIdsWrapped = 8;
+static const int kFSEventStreamEventFlagHistoryDone = 16;
+static const int kFSEventStreamEventFlagItemChangeOwner = 0x4000;
+static const int kFSEventStreamEventFlagItemCreated = 0x100;
+static const int kFSEventStreamEventFlagItemFinderInfoMod = 0x2000;
+static const int kFSEventStreamEventFlagItemInodeMetaMod = 0x400;
+static const int kFSEventStreamEventFlagItemIsDir = 0x20000;
+static const int kFSEventStreamEventFlagItemModified = 0x1000;
+static const int kFSEventStreamEventFlagItemRemoved = 0x200;
+static const int kFSEventStreamEventFlagItemRenamed = 0x800;
+static const int kFSEventStreamEventFlagItemXattrMod = 0x8000;
+static const int kFSEventStreamEventFlagKernelDropped = 4;
+static const int kFSEventStreamEventFlagMount = 64;
+static const int kFSEventStreamEventFlagRootChanged = 32;
+static const int kFSEventStreamEventFlagUnmount = 128;
+static const int kFSEventStreamEventFlagUserDropped = 2;
+
+#endif /* UV_DARWIN_STUB_H_ */
diff --git a/Utilities/cmlibuv/src/unix/fs.c b/Utilities/cmlibuv/src/unix/fs.c
index 70fe21a..f37749c 100644
--- a/Utilities/cmlibuv/src/unix/fs.c
+++ b/Utilities/cmlibuv/src/unix/fs.c
@@ -205,6 +205,20 @@ static ssize_t uv__fs_fdatasync(uv_fs_t* req) {
}
+UV_UNUSED(static struct timespec uv__fs_to_timespec(double time)) {
+ struct timespec ts;
+ ts.tv_sec = time;
+ ts.tv_nsec = (uint64_t)(time * 1000000) % 1000000 * 1000;
+ return ts;
+}
+
+UV_UNUSED(static struct timeval uv__fs_to_timeval(double time)) {
+ struct timeval tv;
+ tv.tv_sec = time;
+ tv.tv_usec = (uint64_t)(time * 1000000) % 1000000;
+ return tv;
+}
+
static ssize_t uv__fs_futime(uv_fs_t* req) {
#if defined(__linux__) \
|| defined(_AIX71) \
@@ -213,10 +227,8 @@ static ssize_t uv__fs_futime(uv_fs_t* req) {
* for the sake of consistency with other platforms.
*/
struct timespec ts[2];
- ts[0].tv_sec = req->atime;
- ts[0].tv_nsec = (uint64_t)(req->atime * 1000000) % 1000000 * 1000;
- ts[1].tv_sec = req->mtime;
- ts[1].tv_nsec = (uint64_t)(req->mtime * 1000000) % 1000000 * 1000;
+ ts[0] = uv__fs_to_timespec(req->atime);
+ ts[1] = uv__fs_to_timespec(req->mtime);
#if defined(__ANDROID_API__) && __ANDROID_API__ < 21
return utimensat(req->file, NULL, ts, 0);
#else
@@ -230,10 +242,8 @@ static ssize_t uv__fs_futime(uv_fs_t* req) {
|| defined(__OpenBSD__) \
|| defined(__sun)
struct timeval tv[2];
- tv[0].tv_sec = req->atime;
- tv[0].tv_usec = (uint64_t)(req->atime * 1000000) % 1000000;
- tv[1].tv_sec = req->mtime;
- tv[1].tv_usec = (uint64_t)(req->mtime * 1000000) % 1000000;
+ tv[0] = uv__fs_to_timeval(req->atime);
+ tv[1] = uv__fs_to_timeval(req->mtime);
# if defined(__sun)
return futimesat(req->file, NULL, tv);
# else
@@ -982,10 +992,8 @@ static ssize_t uv__fs_utime(uv_fs_t* req) {
* for the sake of consistency with other platforms.
*/
struct timespec ts[2];
- ts[0].tv_sec = req->atime;
- ts[0].tv_nsec = (uint64_t)(req->atime * 1000000) % 1000000 * 1000;
- ts[1].tv_sec = req->mtime;
- ts[1].tv_nsec = (uint64_t)(req->mtime * 1000000) % 1000000 * 1000;
+ ts[0] = uv__fs_to_timespec(req->atime);
+ ts[1] = uv__fs_to_timespec(req->mtime);
return utimensat(AT_FDCWD, req->path, ts, 0);
#elif defined(__APPLE__) \
|| defined(__DragonFly__) \
@@ -994,10 +1002,8 @@ static ssize_t uv__fs_utime(uv_fs_t* req) {
|| defined(__NetBSD__) \
|| defined(__OpenBSD__)
struct timeval tv[2];
- tv[0].tv_sec = req->atime;
- tv[0].tv_usec = (uint64_t)(req->atime * 1000000) % 1000000;
- tv[1].tv_sec = req->mtime;
- tv[1].tv_usec = (uint64_t)(req->mtime * 1000000) % 1000000;
+ tv[0] = uv__fs_to_timeval(req->atime);
+ tv[1] = uv__fs_to_timeval(req->mtime);
return utimes(req->path, tv);
#elif defined(_AIX) \
&& !defined(_AIX71)
@@ -1020,6 +1026,31 @@ static ssize_t uv__fs_utime(uv_fs_t* req) {
}
+static ssize_t uv__fs_lutime(uv_fs_t* req) {
+#if defined(__linux__) || \
+ defined(_AIX71) || \
+ defined(__sun) || \
+ defined(__HAIKU__)
+ struct timespec ts[2];
+ ts[0] = uv__fs_to_timespec(req->atime);
+ ts[1] = uv__fs_to_timespec(req->mtime);
+ return utimensat(AT_FDCWD, req->path, ts, AT_SYMLINK_NOFOLLOW);
+#elif defined(__APPLE__) || \
+ defined(__DragonFly__) || \
+ defined(__FreeBSD__) || \
+ defined(__FreeBSD_kernel__) || \
+ defined(__NetBSD__)
+ struct timeval tv[2];
+ tv[0] = uv__fs_to_timeval(req->atime);
+ tv[1] = uv__fs_to_timeval(req->mtime);
+ return lutimes(req->path, tv);
+#else
+ errno = ENOSYS;
+ return -1;
+#endif
+}
+
+
static ssize_t uv__fs_write(uv_fs_t* req) {
#if defined(__linux__)
static int no_pwritev;
@@ -1089,9 +1120,10 @@ static ssize_t uv__fs_copyfile(uv_fs_t* req) {
int dst_flags;
int result;
int err;
- size_t bytes_to_send;
- int64_t in_offset;
- ssize_t bytes_written;
+ off_t bytes_to_send;
+ off_t in_offset;
+ off_t bytes_written;
+ size_t bytes_chunk;
dstfd = -1;
err = 0;
@@ -1190,7 +1222,10 @@ static ssize_t uv__fs_copyfile(uv_fs_t* req) {
bytes_to_send = src_statsbuf.st_size;
in_offset = 0;
while (bytes_to_send != 0) {
- uv_fs_sendfile(NULL, &fs_req, dstfd, srcfd, in_offset, bytes_to_send, NULL);
+ bytes_chunk = SSIZE_MAX;
+ if (bytes_to_send < (off_t) bytes_chunk)
+ bytes_chunk = bytes_to_send;
+ uv_fs_sendfile(NULL, &fs_req, dstfd, srcfd, in_offset, bytes_chunk, NULL);
bytes_written = fs_req.result;
uv_fs_req_cleanup(&fs_req);
@@ -1533,6 +1568,7 @@ static void uv__fs_work(struct uv__work* w) {
X(FSYNC, uv__fs_fsync(req));
X(FTRUNCATE, ftruncate(req->file, req->off));
X(FUTIME, uv__fs_futime(req));
+ X(LUTIME, uv__fs_lutime(req));
X(LSTAT, uv__fs_lstat(req->path, &req->statbuf));
X(LINK, link(req->path, req->new_path));
X(MKDIR, mkdir(req->path, req->mode));
@@ -1719,6 +1755,19 @@ int uv_fs_futime(uv_loop_t* loop,
POST;
}
+int uv_fs_lutime(uv_loop_t* loop,
+ uv_fs_t* req,
+ const char* path,
+ double atime,
+ double mtime,
+ uv_fs_cb cb) {
+ INIT(LUTIME);
+ PATH;
+ req->atime = atime;
+ req->mtime = mtime;
+ POST;
+}
+
int uv_fs_lstat(uv_loop_t* loop, uv_fs_t* req, const char* path, uv_fs_cb cb) {
INIT(LSTAT);
@@ -2047,3 +2096,7 @@ int uv_fs_statfs(uv_loop_t* loop,
PATH;
POST;
}
+
+int uv_fs_get_system_error(const uv_fs_t* req) {
+ return -req->result;
+}
diff --git a/Utilities/cmlibuv/src/unix/fsevents.c b/Utilities/cmlibuv/src/unix/fsevents.c
index 448921f..a51f29b 100644
--- a/Utilities/cmlibuv/src/unix/fsevents.c
+++ b/Utilities/cmlibuv/src/unix/fsevents.c
@@ -41,34 +41,33 @@ void uv__fsevents_loop_delete(uv_loop_t* loop) {
#else /* TARGET_OS_IPHONE */
+#include "darwin-stub.h"
+
#include <dlfcn.h>
#include <assert.h>
#include <stdlib.h>
#include <pthread.h>
-#include <CoreFoundation/CFRunLoop.h>
-#include <CoreServices/CoreServices.h>
-
-/* These are macros to avoid "initializer element is not constant" errors
- * with old versions of gcc.
- */
-#define kFSEventsModified (kFSEventStreamEventFlagItemFinderInfoMod | \
- kFSEventStreamEventFlagItemModified | \
- kFSEventStreamEventFlagItemInodeMetaMod | \
- kFSEventStreamEventFlagItemChangeOwner | \
- kFSEventStreamEventFlagItemXattrMod)
-
-#define kFSEventsRenamed (kFSEventStreamEventFlagItemCreated | \
- kFSEventStreamEventFlagItemRemoved | \
- kFSEventStreamEventFlagItemRenamed)
-
-#define kFSEventsSystem (kFSEventStreamEventFlagUserDropped | \
- kFSEventStreamEventFlagKernelDropped | \
- kFSEventStreamEventFlagEventIdsWrapped | \
- kFSEventStreamEventFlagHistoryDone | \
- kFSEventStreamEventFlagMount | \
- kFSEventStreamEventFlagUnmount | \
- kFSEventStreamEventFlagRootChanged)
+static const int kFSEventsModified =
+ kFSEventStreamEventFlagItemChangeOwner |
+ kFSEventStreamEventFlagItemFinderInfoMod |
+ kFSEventStreamEventFlagItemInodeMetaMod |
+ kFSEventStreamEventFlagItemModified |
+ kFSEventStreamEventFlagItemXattrMod;
+
+static const int kFSEventsRenamed =
+ kFSEventStreamEventFlagItemCreated |
+ kFSEventStreamEventFlagItemRemoved |
+ kFSEventStreamEventFlagItemRenamed;
+
+static const int kFSEventsSystem =
+ kFSEventStreamEventFlagUserDropped |
+ kFSEventStreamEventFlagKernelDropped |
+ kFSEventStreamEventFlagEventIdsWrapped |
+ kFSEventStreamEventFlagHistoryDone |
+ kFSEventStreamEventFlagMount |
+ kFSEventStreamEventFlagUnmount |
+ kFSEventStreamEventFlagRootChanged;
typedef struct uv__fsevents_event_s uv__fsevents_event_t;
typedef struct uv__cf_loop_signal_s uv__cf_loop_signal_t;
@@ -148,7 +147,7 @@ static void (*pFSEventStreamRelease)(FSEventStreamRef);
static void (*pFSEventStreamScheduleWithRunLoop)(FSEventStreamRef,
CFRunLoopRef,
CFStringRef);
-static Boolean (*pFSEventStreamStart)(FSEventStreamRef);
+static int (*pFSEventStreamStart)(FSEventStreamRef);
static void (*pFSEventStreamStop)(FSEventStreamRef);
#define UV__FSEVENTS_PROCESS(handle, block) \
@@ -215,7 +214,7 @@ static void uv__fsevents_push_event(uv_fs_event_t* handle,
/* Runs in CF thread, when there're events in FSEventStream */
-static void uv__fsevents_event_cb(ConstFSEventStreamRef streamRef,
+static void uv__fsevents_event_cb(const FSEventStreamRef streamRef,
void* info,
size_t numEvents,
void* eventPaths,
@@ -340,11 +339,8 @@ static int uv__fsevents_create_stream(uv_loop_t* loop, CFArrayRef paths) {
FSEventStreamCreateFlags flags;
/* Initialize context */
- ctx.version = 0;
+ memset(&ctx, 0, sizeof(ctx));
ctx.info = loop;
- ctx.retain = NULL;
- ctx.release = NULL;
- ctx.copyDescription = NULL;
latency = 0.05;
diff --git a/Utilities/cmlibuv/src/unix/internal.h b/Utilities/cmlibuv/src/unix/internal.h
index 2276b78..2549602 100644
--- a/Utilities/cmlibuv/src/unix/internal.h
+++ b/Utilities/cmlibuv/src/unix/internal.h
@@ -116,10 +116,8 @@ int uv__pthread_sigmask(int how, const sigset_t* set, sigset_t* oset);
#if defined(__clang__) || \
defined(__GNUC__) || \
defined(__INTEL_COMPILER)
-# define UV_DESTRUCTOR(declaration) __attribute__((destructor)) declaration
# define UV_UNUSED(declaration) __attribute__((unused)) declaration
#else
-# define UV_DESTRUCTOR(declaration) declaration
# define UV_UNUSED(declaration) declaration
#endif
diff --git a/Utilities/cmlibuv/src/unix/linux-core.c b/Utilities/cmlibuv/src/unix/linux-core.c
index f8d9ff5..99cbb1c 100644
--- a/Utilities/cmlibuv/src/unix/linux-core.c
+++ b/Utilities/cmlibuv/src/unix/linux-core.c
@@ -768,7 +768,8 @@ static int read_times(FILE* statfile_fp,
unsigned int numcpus,
uv_cpu_info_t* ci) {
struct uv_cpu_times_s ts;
- uint64_t clock_ticks;
+ unsigned int ticks;
+ unsigned int multiplier;
uint64_t user;
uint64_t nice;
uint64_t sys;
@@ -779,9 +780,10 @@ static int read_times(FILE* statfile_fp,
uint64_t len;
char buf[1024];
- clock_ticks = sysconf(_SC_CLK_TCK);
- assert(clock_ticks != (uint64_t) -1);
- assert(clock_ticks != 0);
+ ticks = (unsigned int)sysconf(_SC_CLK_TCK);
+ multiplier = ((uint64_t)1000L / ticks);
+ assert(ticks != (unsigned int) -1);
+ assert(ticks != 0);
rewind(statfile_fp);
@@ -823,11 +825,11 @@ static int read_times(FILE* statfile_fp,
&irq))
abort();
- ts.user = clock_ticks * user;
- ts.nice = clock_ticks * nice;
- ts.sys = clock_ticks * sys;
- ts.idle = clock_ticks * idle;
- ts.irq = clock_ticks * irq;
+ ts.user = user * multiplier;
+ ts.nice = nice * multiplier;
+ ts.sys = sys * multiplier;
+ ts.idle = idle * multiplier;
+ ts.irq = irq * multiplier;
ci[num++].cpu_times = ts;
}
assert(num == numcpus);
diff --git a/Utilities/cmlibuv/src/unix/no-proctitle.c b/Utilities/cmlibuv/src/unix/no-proctitle.c
index 165740c..32aa0af 100644
--- a/Utilities/cmlibuv/src/unix/no-proctitle.c
+++ b/Utilities/cmlibuv/src/unix/no-proctitle.c
@@ -29,6 +29,9 @@ char** uv_setup_args(int argc, char** argv) {
return argv;
}
+void uv__process_title_cleanup(void) {
+}
+
int uv_set_process_title(const char* title) {
return 0;
}
diff --git a/Utilities/cmlibuv/src/unix/proctitle.c b/Utilities/cmlibuv/src/unix/proctitle.c
index d124d3c..4ee991f 100644
--- a/Utilities/cmlibuv/src/unix/proctitle.c
+++ b/Utilities/cmlibuv/src/unix/proctitle.c
@@ -145,7 +145,7 @@ int uv_get_process_title(char* buffer, size_t size) {
}
-UV_DESTRUCTOR(static void free_args_mem(void)) {
+void uv__process_title_cleanup(void) {
uv__free(args_mem); /* Keep valgrind happy. */
args_mem = NULL;
}
diff --git a/Utilities/cmlibuv/src/unix/signal.c b/Utilities/cmlibuv/src/unix/signal.c
index 1e7e8ac..1c83e09 100644
--- a/Utilities/cmlibuv/src/unix/signal.c
+++ b/Utilities/cmlibuv/src/unix/signal.c
@@ -77,7 +77,7 @@ static void uv__signal_global_init(void) {
}
-UV_DESTRUCTOR(static void uv__signal_global_fini(void)) {
+void uv__signal_cleanup(void) {
/* We can only use signal-safe functions here.
* That includes read/write and close, fortunately.
* We do all of this directly here instead of resetting
@@ -98,7 +98,7 @@ UV_DESTRUCTOR(static void uv__signal_global_fini(void)) {
static void uv__signal_global_reinit(void) {
- uv__signal_global_fini();
+ uv__signal_cleanup();
if (uv__make_pipe(uv__signal_lock_pipefd, 0))
abort();
diff --git a/Utilities/cmlibuv/src/unix/udp.c b/Utilities/cmlibuv/src/unix/udp.c
index f2fcae1..21b922f 100644
--- a/Utilities/cmlibuv/src/unix/udp.c
+++ b/Utilities/cmlibuv/src/unix/udp.c
@@ -202,6 +202,9 @@ static int uv__udp_recvmmsg(uv_udp_t* handle, uv_buf_t* buf) {
msgs[k].msg_hdr.msg_iovlen = 1;
msgs[k].msg_hdr.msg_name = peers + k;
msgs[k].msg_hdr.msg_namelen = sizeof(peers[0]);
+ msgs[k].msg_hdr.msg_control = NULL;
+ msgs[k].msg_hdr.msg_controllen = 0;
+ msgs[k].msg_hdr.msg_flags = 0;
}
do
@@ -262,11 +265,9 @@ static void uv__udp_recvmsg(uv_udp_t* handle) {
assert(buf.base != NULL);
#if HAVE_MMSG
- uv_once(&once, uv__udp_mmsg_init);
- if (uv__recvmmsg_avail) {
- /* Returned space for more than 1 datagram, use it to receive
- * multiple datagrams. */
- if (buf.len >= 2 * UV__UDP_DGRAM_MAXSIZE) {
+ if (handle->flags & UV_HANDLE_UDP_RECVMMSG) {
+ uv_once(&once, uv__udp_mmsg_init);
+ if (uv__recvmmsg_avail) {
nread = uv__udp_recvmmsg(handle, &buf);
if (nread > 0)
count -= nread;
@@ -946,26 +947,17 @@ static int uv__udp_set_source_membership6(uv_udp_t* handle,
#endif
-int uv_udp_init_ex(uv_loop_t* loop, uv_udp_t* handle, unsigned int flags) {
- int domain;
- int err;
+int uv__udp_init_ex(uv_loop_t* loop,
+ uv_udp_t* handle,
+ unsigned flags,
+ int domain) {
int fd;
- /* Use the lower 8 bits for the domain */
- domain = flags & 0xFF;
- if (domain != AF_INET && domain != AF_INET6 && domain != AF_UNSPEC)
- return UV_EINVAL;
-
- if (flags & ~0xFF)
- return UV_EINVAL;
-
+ fd = -1;
if (domain != AF_UNSPEC) {
- err = uv__socket(domain, SOCK_DGRAM, 0);
- if (err < 0)
- return err;
- fd = err;
- } else {
- fd = -1;
+ fd = uv__socket(domain, SOCK_DGRAM, 0);
+ if (fd < 0)
+ return fd;
}
uv__handle_init(loop, (uv_handle_t*)handle, UV_UDP);
@@ -981,11 +973,6 @@ int uv_udp_init_ex(uv_loop_t* loop, uv_udp_t* handle, unsigned int flags) {
}
-int uv_udp_init(uv_loop_t* loop, uv_udp_t* handle) {
- return uv_udp_init_ex(loop, handle, AF_UNSPEC);
-}
-
-
int uv_udp_open(uv_udp_t* handle, uv_os_sock_t sock) {
int err;
diff --git a/Utilities/cmlibuv/src/uv-common.c b/Utilities/cmlibuv/src/uv-common.c
index 49fc184..2fcbe3d 100644
--- a/Utilities/cmlibuv/src/uv-common.c
+++ b/Utilities/cmlibuv/src/uv-common.c
@@ -294,6 +294,36 @@ int uv_tcp_bind(uv_tcp_t* handle,
}
+int uv_udp_init_ex(uv_loop_t* loop, uv_udp_t* handle, unsigned flags) {
+ unsigned extra_flags;
+ int domain;
+ int rc;
+
+ /* Use the lower 8 bits for the domain. */
+ domain = flags & 0xFF;
+ if (domain != AF_INET && domain != AF_INET6 && domain != AF_UNSPEC)
+ return UV_EINVAL;
+
+ /* Use the higher bits for extra flags. */
+ extra_flags = flags & ~0xFF;
+ if (extra_flags & ~UV_UDP_RECVMMSG)
+ return UV_EINVAL;
+
+ rc = uv__udp_init_ex(loop, handle, flags, domain);
+
+ if (rc == 0)
+ if (extra_flags & UV_UDP_RECVMMSG)
+ handle->flags |= UV_HANDLE_UDP_RECVMMSG;
+
+ return rc;
+}
+
+
+int uv_udp_init(uv_loop_t* loop, uv_udp_t* handle) {
+ return uv_udp_init_ex(loop, handle, AF_UNSPEC);
+}
+
+
int uv_udp_bind(uv_udp_t* handle,
const struct sockaddr* addr,
unsigned int flags) {
@@ -823,3 +853,19 @@ void uv_free_cpu_info(uv_cpu_info_t* cpu_infos, int count) {
uv__free(cpu_infos);
}
+
+
+#ifdef __GNUC__ /* Also covers __clang__ and __INTEL_COMPILER. */
+__attribute__((destructor))
+#endif
+void uv_library_shutdown(void) {
+ static int was_shutdown;
+
+ if (was_shutdown)
+ return;
+
+ uv__process_title_cleanup();
+ uv__signal_cleanup();
+ uv__threadpool_cleanup();
+ was_shutdown = 1;
+}
diff --git a/Utilities/cmlibuv/src/uv-common.h b/Utilities/cmlibuv/src/uv-common.h
index 13192c1..0b0f5f8 100644
--- a/Utilities/cmlibuv/src/uv-common.h
+++ b/Utilities/cmlibuv/src/uv-common.h
@@ -104,6 +104,7 @@ enum {
/* Only used by uv_udp_t handles. */
UV_HANDLE_UDP_PROCESSING = 0x01000000,
UV_HANDLE_UDP_CONNECTED = 0x02000000,
+ UV_HANDLE_UDP_RECVMMSG = 0x04000000,
/* Only used by uv_pipe_t handles. */
UV_HANDLE_NON_OVERLAPPED_PIPE = 0x01000000,
@@ -138,6 +139,11 @@ int uv__tcp_connect(uv_connect_t* req,
unsigned int addrlen,
uv_connect_cb cb);
+int uv__udp_init_ex(uv_loop_t* loop,
+ uv_udp_t* handle,
+ unsigned flags,
+ int domain);
+
int uv__udp_bind(uv_udp_t* handle,
const struct sockaddr* addr,
unsigned int addrlen,
@@ -200,6 +206,10 @@ int uv__next_timeout(const uv_loop_t* loop);
void uv__run_timers(uv_loop_t* loop);
void uv__timer_close(uv_timer_t* handle);
+void uv__process_title_cleanup(void);
+void uv__signal_cleanup(void);
+void uv__threadpool_cleanup(void);
+
#define uv__has_active_reqs(loop) \
((loop)->active_reqs.count > 0)
diff --git a/Utilities/cmlibuv/src/win/core.c b/Utilities/cmlibuv/src/win/core.c
index 6ded90c..9974a11 100644
--- a/Utilities/cmlibuv/src/win/core.c
+++ b/Utilities/cmlibuv/src/win/core.c
@@ -449,12 +449,12 @@ static void uv__poll(uv_loop_t* loop, DWORD timeout) {
timeout_time = loop->time + timeout;
for (repeat = 0; ; repeat++) {
- success = GetQueuedCompletionStatusEx(loop->iocp,
- overlappeds,
- ARRAY_SIZE(overlappeds),
- &count,
- timeout,
- FALSE);
+ success = pGetQueuedCompletionStatusEx(loop->iocp,
+ overlappeds,
+ ARRAY_SIZE(overlappeds),
+ &count,
+ timeout,
+ FALSE);
if (success) {
for (i = 0; i < count; i++) {
diff --git a/Utilities/cmlibuv/src/win/error.c b/Utilities/cmlibuv/src/win/error.c
index 32ac5e5..3ec984c 100644
--- a/Utilities/cmlibuv/src/win/error.c
+++ b/Utilities/cmlibuv/src/win/error.c
@@ -72,6 +72,7 @@ int uv_translate_sys_error(int sys_errno) {
case ERROR_NOACCESS: return UV_EACCES;
case WSAEACCES: return UV_EACCES;
case ERROR_ELEVATION_REQUIRED: return UV_EACCES;
+ case ERROR_CANT_ACCESS_FILE: return UV_EACCES;
case ERROR_ADDRESS_ALREADY_ASSOCIATED: return UV_EADDRINUSE;
case WSAEADDRINUSE: return UV_EADDRINUSE;
case WSAEADDRNOTAVAIL: return UV_EADDRNOTAVAIL;
diff --git a/Utilities/cmlibuv/src/win/fs-event.c b/Utilities/cmlibuv/src/win/fs-event.c
index acf8e11..0126c5e 100644
--- a/Utilities/cmlibuv/src/win/fs-event.c
+++ b/Utilities/cmlibuv/src/win/fs-event.c
@@ -83,6 +83,7 @@ static void uv_relative_path(const WCHAR* filename,
static int uv_split_path(const WCHAR* filename, WCHAR** dir,
WCHAR** file) {
size_t len, i;
+ DWORD dir_len;
if (filename == NULL) {
if (dir != NULL)
@@ -97,12 +98,16 @@ static int uv_split_path(const WCHAR* filename, WCHAR** dir,
if (i == 0) {
if (dir) {
- *dir = (WCHAR*)uv__malloc((MAX_PATH + 1) * sizeof(WCHAR));
+ dir_len = GetCurrentDirectoryW(0, NULL);
+ if (dir_len == 0) {
+ return -1;
+ }
+ *dir = (WCHAR*)uv__malloc(dir_len * sizeof(WCHAR));
if (!*dir) {
uv_fatal_error(ERROR_OUTOFMEMORY, "uv__malloc");
}
- if (!GetCurrentDirectoryW(MAX_PATH, *dir)) {
+ if (!GetCurrentDirectoryW(dir_len, *dir)) {
uv__free(*dir);
*dir = NULL;
return -1;
@@ -155,9 +160,11 @@ int uv_fs_event_start(uv_fs_event_t* handle,
int name_size, is_path_dir, size;
DWORD attr, last_error;
WCHAR* dir = NULL, *dir_to_watch, *pathw = NULL;
- WCHAR short_path_buffer[MAX_PATH];
+ DWORD short_path_buffer_len;
+ WCHAR *short_path_buffer;
WCHAR* short_path, *long_path;
+ short_path = NULL;
if (uv__is_active(handle))
return UV_EINVAL;
@@ -230,13 +237,23 @@ int uv_fs_event_start(uv_fs_event_t* handle,
*/
/* Convert to short path. */
+ short_path_buffer = NULL;
+ short_path_buffer_len = GetShortPathNameW(pathw, NULL, 0);
+ if (short_path_buffer_len == 0) {
+ goto short_path_done;
+ }
+ short_path_buffer = uv__malloc(short_path_buffer_len * sizeof(WCHAR));
+ if (short_path_buffer == NULL) {
+ goto short_path_done;
+ }
if (GetShortPathNameW(pathw,
short_path_buffer,
- ARRAY_SIZE(short_path_buffer))) {
- short_path = short_path_buffer;
- } else {
- short_path = NULL;
+ short_path_buffer_len) == 0) {
+ uv__free(short_path_buffer);
+ short_path_buffer = NULL;
}
+short_path_done:
+ short_path = short_path_buffer;
if (uv_split_path(pathw, &dir, &handle->filew) != 0) {
last_error = GetLastError();
@@ -346,6 +363,8 @@ error:
if (uv__is_active(handle))
uv__handle_stop(handle);
+ uv__free(short_path);
+
return uv_translate_sys_error(last_error);
}
diff --git a/Utilities/cmlibuv/src/win/fs.c b/Utilities/cmlibuv/src/win/fs.c
index 8502b07..9577bc0 100644
--- a/Utilities/cmlibuv/src/win/fs.c
+++ b/Utilities/cmlibuv/src/win/fs.c
@@ -257,6 +257,7 @@ INLINE static void uv_fs_req_init(uv_loop_t* loop, uv_fs_t* req,
req->loop = loop;
req->flags = 0;
req->fs_type = fs_type;
+ req->sys_errno_ = 0;
req->result = 0;
req->ptr = NULL;
req->path = NULL;
@@ -321,6 +322,8 @@ INLINE static int fs__readlink_handle(HANDLE handle, char** target_ptr,
WCHAR* w_target;
DWORD w_target_len;
DWORD bytes;
+ size_t i;
+ size_t len;
if (!DeviceIoControl(handle,
FSCTL_GET_REPARSE_POINT,
@@ -405,6 +408,38 @@ INLINE static int fs__readlink_handle(HANDLE handle, char** target_ptr,
w_target += 4;
w_target_len -= 4;
+ } else if (reparse_data->ReparseTag == IO_REPARSE_TAG_APPEXECLINK) {
+ /* String #3 in the list has the target filename. */
+ if (reparse_data->AppExecLinkReparseBuffer.StringCount < 3) {
+ SetLastError(ERROR_SYMLINK_NOT_SUPPORTED);
+ return -1;
+ }
+ w_target = reparse_data->AppExecLinkReparseBuffer.StringList;
+ /* The StringList buffer contains a list of strings separated by "\0", */
+ /* with "\0\0" terminating the list. Move to the 3rd string in the list: */
+ for (i = 0; i < 2; ++i) {
+ len = wcslen(w_target);
+ if (len == 0) {
+ SetLastError(ERROR_SYMLINK_NOT_SUPPORTED);
+ return -1;
+ }
+ w_target += len + 1;
+ }
+ w_target_len = wcslen(w_target);
+ if (w_target_len == 0) {
+ SetLastError(ERROR_SYMLINK_NOT_SUPPORTED);
+ return -1;
+ }
+ /* Make sure it is an absolute path. */
+ if (!(w_target_len >= 3 &&
+ ((w_target[0] >= L'a' && w_target[0] <= L'z') ||
+ (w_target[0] >= L'A' && w_target[0] <= L'Z')) &&
+ w_target[1] == L':' &&
+ w_target[2] == L'\\')) {
+ SetLastError(ERROR_SYMLINK_NOT_SUPPORTED);
+ return -1;
+ }
+
} else {
/* Reparse tag does not indicate a symlink. */
SetLastError(ERROR_SYMLINK_NOT_SUPPORTED);
@@ -2225,34 +2260,68 @@ INLINE static int fs__utime_handle(HANDLE handle, double atime, double mtime) {
return 0;
}
-
-static void fs__utime(uv_fs_t* req) {
+INLINE static DWORD fs__utime_impl_from_path(WCHAR* path,
+ double atime,
+ double mtime,
+ int do_lutime) {
HANDLE handle;
+ DWORD flags;
+ DWORD ret;
- handle = CreateFileW(req->file.pathw,
+ flags = FILE_FLAG_BACKUP_SEMANTICS;
+ if (do_lutime) {
+ flags |= FILE_FLAG_OPEN_REPARSE_POINT;
+ }
+
+ handle = CreateFileW(path,
FILE_WRITE_ATTRIBUTES,
FILE_SHARE_READ | FILE_SHARE_WRITE | FILE_SHARE_DELETE,
NULL,
OPEN_EXISTING,
- FILE_FLAG_BACKUP_SEMANTICS,
+ flags,
NULL);
if (handle == INVALID_HANDLE_VALUE) {
- SET_REQ_WIN32_ERROR(req, GetLastError());
- return;
+ ret = GetLastError();
+ } else if (fs__utime_handle(handle, atime, mtime) != 0) {
+ ret = GetLastError();
+ } else {
+ ret = 0;
}
- if (fs__utime_handle(handle, req->fs.time.atime, req->fs.time.mtime) != 0) {
- SET_REQ_WIN32_ERROR(req, GetLastError());
- CloseHandle(handle);
+ CloseHandle(handle);
+ return ret;
+}
+
+INLINE static void fs__utime_impl(uv_fs_t* req, int do_lutime) {
+ DWORD error;
+
+ error = fs__utime_impl_from_path(req->file.pathw,
+ req->fs.time.atime,
+ req->fs.time.mtime,
+ do_lutime);
+
+ if (error != 0) {
+ if (do_lutime &&
+ (error == ERROR_SYMLINK_NOT_SUPPORTED ||
+ error == ERROR_NOT_A_REPARSE_POINT)) {
+ /* Opened file is a reparse point but not a symlink. Try again. */
+ fs__utime_impl(req, 0);
+ } else {
+ /* utime failed. */
+ SET_REQ_WIN32_ERROR(req, error);
+ }
+
return;
}
- CloseHandle(handle);
-
req->result = 0;
}
+static void fs__utime(uv_fs_t* req) {
+ fs__utime_impl(req, /* do_lutime */ 0);
+}
+
static void fs__futime(uv_fs_t* req) {
int fd = req->file.fd;
@@ -2274,6 +2343,10 @@ static void fs__futime(uv_fs_t* req) {
req->result = 0;
}
+static void fs__lutime(uv_fs_t* req) {
+ fs__utime_impl(req, /* do_lutime */ 1);
+}
+
static void fs__link(uv_fs_t* req) {
DWORD r = CreateHardLinkW(req->fs.info.new_pathw, req->file.pathw, NULL);
@@ -2621,14 +2694,62 @@ static void fs__statfs(uv_fs_t* req) {
DWORD bytes_per_sector;
DWORD free_clusters;
DWORD total_clusters;
+ WCHAR* pathw;
- if (0 == GetDiskFreeSpaceW(req->file.pathw,
+ pathw = req->file.pathw;
+retry_get_disk_free_space:
+ if (0 == GetDiskFreeSpaceW(pathw,
&sectors_per_cluster,
&bytes_per_sector,
&free_clusters,
&total_clusters)) {
- SET_REQ_WIN32_ERROR(req, GetLastError());
- return;
+ DWORD err;
+ WCHAR* fpart;
+ size_t len;
+ DWORD ret;
+ BOOL is_second;
+
+ err = GetLastError();
+ is_second = pathw != req->file.pathw;
+ if (err != ERROR_DIRECTORY || is_second) {
+ if (is_second)
+ uv__free(pathw);
+
+ SET_REQ_WIN32_ERROR(req, err);
+ return;
+ }
+
+ len = MAX_PATH + 1;
+ pathw = uv__malloc(len * sizeof(*pathw));
+ if (pathw == NULL) {
+ SET_REQ_UV_ERROR(req, UV_ENOMEM, ERROR_OUTOFMEMORY);
+ return;
+ }
+retry_get_full_path_name:
+ ret = GetFullPathNameW(req->file.pathw,
+ len,
+ pathw,
+ &fpart);
+ if (ret == 0) {
+ uv__free(pathw);
+ SET_REQ_WIN32_ERROR(req, err);
+ return;
+ } else if (ret > len) {
+ len = ret;
+ pathw = uv__reallocf(pathw, len * sizeof(*pathw));
+ if (pathw == NULL) {
+ SET_REQ_UV_ERROR(req, UV_ENOMEM, ERROR_OUTOFMEMORY);
+ return;
+ }
+ goto retry_get_full_path_name;
+ }
+ if (fpart != 0)
+ *fpart = L'\0';
+
+ goto retry_get_disk_free_space;
+ }
+ if (pathw != req->file.pathw) {
+ uv__free(pathw);
}
stat_fs = uv__malloc(sizeof(*stat_fs));
@@ -2670,6 +2791,7 @@ static void uv__fs_work(struct uv__work* w) {
XX(FTRUNCATE, ftruncate)
XX(UTIME, utime)
XX(FUTIME, futime)
+ XX(LUTIME, lutime)
XX(ACCESS, access)
XX(CHMOD, chmod)
XX(FCHMOD, fchmod)
@@ -2753,7 +2875,8 @@ int uv_fs_open(uv_loop_t* loop, uv_fs_t* req, const char* path, int flags,
INIT(UV_FS_OPEN);
err = fs__capture_path(req, path, NULL, cb != NULL);
if (err) {
- return uv_translate_sys_error(err);
+ SET_REQ_WIN32_ERROR(req, err);
+ return req->result;
}
req->fs.info.file_flags = flags;
@@ -2778,8 +2901,10 @@ int uv_fs_read(uv_loop_t* loop,
uv_fs_cb cb) {
INIT(UV_FS_READ);
- if (bufs == NULL || nbufs == 0)
+ if (bufs == NULL || nbufs == 0) {
+ SET_REQ_UV_ERROR(req, UV_EINVAL, ERROR_INVALID_PARAMETER);
return UV_EINVAL;
+ }
req->file.fd = fd;
@@ -2788,8 +2913,10 @@ int uv_fs_read(uv_loop_t* loop,
if (nbufs > ARRAY_SIZE(req->fs.info.bufsml))
req->fs.info.bufs = uv__malloc(nbufs * sizeof(*bufs));
- if (req->fs.info.bufs == NULL)
+ if (req->fs.info.bufs == NULL) {
+ SET_REQ_UV_ERROR(req, UV_ENOMEM, ERROR_OUTOFMEMORY);
return UV_ENOMEM;
+ }
memcpy(req->fs.info.bufs, bufs, nbufs * sizeof(*bufs));
@@ -2807,8 +2934,10 @@ int uv_fs_write(uv_loop_t* loop,
uv_fs_cb cb) {
INIT(UV_FS_WRITE);
- if (bufs == NULL || nbufs == 0)
+ if (bufs == NULL || nbufs == 0) {
+ SET_REQ_UV_ERROR(req, UV_EINVAL, ERROR_INVALID_PARAMETER);
return UV_EINVAL;
+ }
req->file.fd = fd;
@@ -2817,8 +2946,10 @@ int uv_fs_write(uv_loop_t* loop,
if (nbufs > ARRAY_SIZE(req->fs.info.bufsml))
req->fs.info.bufs = uv__malloc(nbufs * sizeof(*bufs));
- if (req->fs.info.bufs == NULL)
+ if (req->fs.info.bufs == NULL) {
+ SET_REQ_UV_ERROR(req, UV_ENOMEM, ERROR_OUTOFMEMORY);
return UV_ENOMEM;
+ }
memcpy(req->fs.info.bufs, bufs, nbufs * sizeof(*bufs));
@@ -2834,7 +2965,8 @@ int uv_fs_unlink(uv_loop_t* loop, uv_fs_t* req, const char* path,
INIT(UV_FS_UNLINK);
err = fs__capture_path(req, path, NULL, cb != NULL);
if (err) {
- return uv_translate_sys_error(err);
+ SET_REQ_WIN32_ERROR(req, err);
+ return req->result;
}
POST;
@@ -2848,7 +2980,8 @@ int uv_fs_mkdir(uv_loop_t* loop, uv_fs_t* req, const char* path, int mode,
INIT(UV_FS_MKDIR);
err = fs__capture_path(req, path, NULL, cb != NULL);
if (err) {
- return uv_translate_sys_error(err);
+ SET_REQ_WIN32_ERROR(req, err);
+ return req->result;
}
req->fs.info.mode = mode;
@@ -2864,8 +2997,10 @@ int uv_fs_mkdtemp(uv_loop_t* loop,
INIT(UV_FS_MKDTEMP);
err = fs__capture_path(req, tpl, NULL, TRUE);
- if (err)
- return uv_translate_sys_error(err);
+ if (err) {
+ SET_REQ_WIN32_ERROR(req, err);
+ return req->result;
+ }
POST;
}
@@ -2879,8 +3014,10 @@ int uv_fs_mkstemp(uv_loop_t* loop,
INIT(UV_FS_MKSTEMP);
err = fs__capture_path(req, tpl, NULL, TRUE);
- if (err)
- return uv_translate_sys_error(err);
+ if (err) {
+ SET_REQ_WIN32_ERROR(req, err);
+ return req->result;
+ }
POST;
}
@@ -2892,7 +3029,8 @@ int uv_fs_rmdir(uv_loop_t* loop, uv_fs_t* req, const char* path, uv_fs_cb cb) {
INIT(UV_FS_RMDIR);
err = fs__capture_path(req, path, NULL, cb != NULL);
if (err) {
- return uv_translate_sys_error(err);
+ SET_REQ_WIN32_ERROR(req, err);
+ return req->result;
}
POST;
@@ -2906,7 +3044,8 @@ int uv_fs_scandir(uv_loop_t* loop, uv_fs_t* req, const char* path, int flags,
INIT(UV_FS_SCANDIR);
err = fs__capture_path(req, path, NULL, cb != NULL);
if (err) {
- return uv_translate_sys_error(err);
+ SET_REQ_WIN32_ERROR(req, err);
+ return req->result;
}
req->fs.info.file_flags = flags;
@@ -2921,8 +3060,10 @@ int uv_fs_opendir(uv_loop_t* loop,
INIT(UV_FS_OPENDIR);
err = fs__capture_path(req, path, NULL, cb != NULL);
- if (err)
- return uv_translate_sys_error(err);
+ if (err) {
+ SET_REQ_WIN32_ERROR(req, err);
+ return req->result;
+ }
POST;
}
@@ -2935,6 +3076,7 @@ int uv_fs_readdir(uv_loop_t* loop,
if (dir == NULL ||
dir->dirents == NULL ||
dir->dir_handle == INVALID_HANDLE_VALUE) {
+ SET_REQ_UV_ERROR(req, UV_EINVAL, ERROR_INVALID_PARAMETER);
return UV_EINVAL;
}
@@ -2947,8 +3089,10 @@ int uv_fs_closedir(uv_loop_t* loop,
uv_dir_t* dir,
uv_fs_cb cb) {
INIT(UV_FS_CLOSEDIR);
- if (dir == NULL)
+ if (dir == NULL) {
+ SET_REQ_UV_ERROR(req, UV_EINVAL, ERROR_INVALID_PARAMETER);
return UV_EINVAL;
+ }
req->ptr = dir;
POST;
}
@@ -2960,7 +3104,8 @@ int uv_fs_link(uv_loop_t* loop, uv_fs_t* req, const char* path,
INIT(UV_FS_LINK);
err = fs__capture_path(req, path, new_path, cb != NULL);
if (err) {
- return uv_translate_sys_error(err);
+ SET_REQ_WIN32_ERROR(req, err);
+ return req->result;
}
POST;
@@ -2974,7 +3119,8 @@ int uv_fs_symlink(uv_loop_t* loop, uv_fs_t* req, const char* path,
INIT(UV_FS_SYMLINK);
err = fs__capture_path(req, path, new_path, cb != NULL);
if (err) {
- return uv_translate_sys_error(err);
+ SET_REQ_WIN32_ERROR(req, err);
+ return req->result;
}
req->fs.info.file_flags = flags;
@@ -2989,7 +3135,8 @@ int uv_fs_readlink(uv_loop_t* loop, uv_fs_t* req, const char* path,
INIT(UV_FS_READLINK);
err = fs__capture_path(req, path, NULL, cb != NULL);
if (err) {
- return uv_translate_sys_error(err);
+ SET_REQ_WIN32_ERROR(req, err);
+ return req->result;
}
POST;
@@ -3003,12 +3150,14 @@ int uv_fs_realpath(uv_loop_t* loop, uv_fs_t* req, const char* path,
INIT(UV_FS_REALPATH);
if (!path) {
+ SET_REQ_UV_ERROR(req, UV_EINVAL, ERROR_INVALID_PARAMETER);
return UV_EINVAL;
}
err = fs__capture_path(req, path, NULL, cb != NULL);
if (err) {
- return uv_translate_sys_error(err);
+ SET_REQ_WIN32_ERROR(req, err);
+ return req->result;
}
POST;
@@ -3022,7 +3171,8 @@ int uv_fs_chown(uv_loop_t* loop, uv_fs_t* req, const char* path, uv_uid_t uid,
INIT(UV_FS_CHOWN);
err = fs__capture_path(req, path, NULL, cb != NULL);
if (err) {
- return uv_translate_sys_error(err);
+ SET_REQ_WIN32_ERROR(req, err);
+ return req->result;
}
POST;
@@ -3043,8 +3193,10 @@ int uv_fs_lchown(uv_loop_t* loop, uv_fs_t* req, const char* path, uv_uid_t uid,
INIT(UV_FS_LCHOWN);
err = fs__capture_path(req, path, NULL, cb != NULL);
if (err) {
- return uv_translate_sys_error(err);
+ SET_REQ_WIN32_ERROR(req, err);
+ return req->result;
}
+
POST;
}
@@ -3055,7 +3207,8 @@ int uv_fs_stat(uv_loop_t* loop, uv_fs_t* req, const char* path, uv_fs_cb cb) {
INIT(UV_FS_STAT);
err = fs__capture_path(req, path, NULL, cb != NULL);
if (err) {
- return uv_translate_sys_error(err);
+ SET_REQ_WIN32_ERROR(req, err);
+ return req->result;
}
POST;
@@ -3068,7 +3221,8 @@ int uv_fs_lstat(uv_loop_t* loop, uv_fs_t* req, const char* path, uv_fs_cb cb) {
INIT(UV_FS_LSTAT);
err = fs__capture_path(req, path, NULL, cb != NULL);
if (err) {
- return uv_translate_sys_error(err);
+ SET_REQ_WIN32_ERROR(req, err);
+ return req->result;
}
POST;
@@ -3089,7 +3243,8 @@ int uv_fs_rename(uv_loop_t* loop, uv_fs_t* req, const char* path,
INIT(UV_FS_RENAME);
err = fs__capture_path(req, path, new_path, cb != NULL);
if (err) {
- return uv_translate_sys_error(err);
+ SET_REQ_WIN32_ERROR(req, err);
+ return req->result;
}
POST;
@@ -3132,13 +3287,15 @@ int uv_fs_copyfile(uv_loop_t* loop,
if (flags & ~(UV_FS_COPYFILE_EXCL |
UV_FS_COPYFILE_FICLONE |
UV_FS_COPYFILE_FICLONE_FORCE)) {
+ SET_REQ_UV_ERROR(req, UV_EINVAL, ERROR_INVALID_PARAMETER);
return UV_EINVAL;
}
err = fs__capture_path(req, path, new_path, cb != NULL);
-
- if (err)
- return uv_translate_sys_error(err);
+ if (err) {
+ SET_REQ_WIN32_ERROR(req, err);
+ return req->result;
+ }
req->fs.info.file_flags = flags;
POST;
@@ -3165,8 +3322,10 @@ int uv_fs_access(uv_loop_t* loop,
INIT(UV_FS_ACCESS);
err = fs__capture_path(req, path, NULL, cb != NULL);
- if (err)
- return uv_translate_sys_error(err);
+ if (err) {
+ SET_REQ_WIN32_ERROR(req, err);
+ return req->result;
+ }
req->fs.info.mode = flags;
POST;
@@ -3180,7 +3339,8 @@ int uv_fs_chmod(uv_loop_t* loop, uv_fs_t* req, const char* path, int mode,
INIT(UV_FS_CHMOD);
err = fs__capture_path(req, path, NULL, cb != NULL);
if (err) {
- return uv_translate_sys_error(err);
+ SET_REQ_WIN32_ERROR(req, err);
+ return req->result;
}
req->fs.info.mode = mode;
@@ -3204,7 +3364,8 @@ int uv_fs_utime(uv_loop_t* loop, uv_fs_t* req, const char* path, double atime,
INIT(UV_FS_UTIME);
err = fs__capture_path(req, path, NULL, cb != NULL);
if (err) {
- return uv_translate_sys_error(err);
+ SET_REQ_WIN32_ERROR(req, err);
+ return req->result;
}
req->fs.time.atime = atime;
@@ -3222,6 +3383,22 @@ int uv_fs_futime(uv_loop_t* loop, uv_fs_t* req, uv_file fd, double atime,
POST;
}
+int uv_fs_lutime(uv_loop_t* loop, uv_fs_t* req, const char* path, double atime,
+ double mtime, uv_fs_cb cb) {
+ int err;
+
+ INIT(UV_FS_LUTIME);
+ err = fs__capture_path(req, path, NULL, cb != NULL);
+ if (err) {
+ SET_REQ_WIN32_ERROR(req, err);
+ return req->result;
+ }
+
+ req->fs.time.atime = atime;
+ req->fs.time.mtime = mtime;
+ POST;
+}
+
int uv_fs_statfs(uv_loop_t* loop,
uv_fs_t* req,
@@ -3231,8 +3408,14 @@ int uv_fs_statfs(uv_loop_t* loop,
INIT(UV_FS_STATFS);
err = fs__capture_path(req, path, NULL, cb != NULL);
- if (err)
- return uv_translate_sys_error(err);
+ if (err) {
+ SET_REQ_WIN32_ERROR(req, err);
+ return req->result;
+ }
POST;
}
+
+int uv_fs_get_system_error(const uv_fs_t* req) {
+ return req->sys_errno_;
+}
diff --git a/Utilities/cmlibuv/src/win/poll.c b/Utilities/cmlibuv/src/win/poll.c
index 3c66786..8785859 100644
--- a/Utilities/cmlibuv/src/win/poll.c
+++ b/Utilities/cmlibuv/src/win/poll.c
@@ -134,32 +134,6 @@ static void uv__fast_poll_submit_poll_req(uv_loop_t* loop, uv_poll_t* handle) {
}
-static int uv__fast_poll_cancel_poll_req(uv_loop_t* loop, uv_poll_t* handle) {
- AFD_POLL_INFO afd_poll_info;
- int result;
-
- afd_poll_info.Exclusive = TRUE;
- afd_poll_info.NumberOfHandles = 1;
- afd_poll_info.Timeout.QuadPart = INT64_MAX;
- afd_poll_info.Handles[0].Handle = (HANDLE) handle->socket;
- afd_poll_info.Handles[0].Status = 0;
- afd_poll_info.Handles[0].Events = AFD_POLL_ALL;
-
- result = uv_msafd_poll(handle->socket,
- &afd_poll_info,
- uv__get_afd_poll_info_dummy(),
- uv__get_overlapped_dummy());
-
- if (result == SOCKET_ERROR) {
- DWORD error = WSAGetLastError();
- if (error != WSA_IO_PENDING)
- return error;
- }
-
- return 0;
-}
-
-
static void uv__fast_poll_process_poll_req(uv_loop_t* loop, uv_poll_t* handle,
uv_req_t* req) {
unsigned char mask_events;
@@ -226,44 +200,6 @@ static void uv__fast_poll_process_poll_req(uv_loop_t* loop, uv_poll_t* handle,
}
-static int uv__fast_poll_set(uv_loop_t* loop, uv_poll_t* handle, int events) {
- assert(handle->type == UV_POLL);
- assert(!(handle->flags & UV_HANDLE_CLOSING));
- assert((events & ~(UV_READABLE | UV_WRITABLE | UV_DISCONNECT)) == 0);
-
- handle->events = events;
-
- if (handle->events != 0) {
- uv__handle_start(handle);
- } else {
- uv__handle_stop(handle);
- }
-
- if ((handle->events & ~(handle->submitted_events_1 |
- handle->submitted_events_2)) != 0) {
- uv__fast_poll_submit_poll_req(handle->loop, handle);
- }
-
- return 0;
-}
-
-
-static int uv__fast_poll_close(uv_loop_t* loop, uv_poll_t* handle) {
- handle->events = 0;
- uv__handle_closing(handle);
-
- if (handle->submitted_events_1 == 0 &&
- handle->submitted_events_2 == 0) {
- uv_want_endgame(loop, (uv_handle_t*) handle);
- return 0;
- } else {
- /* Cancel outstanding poll requests by executing another, unique poll
- * request that forces the outstanding ones to return. */
- return uv__fast_poll_cancel_poll_req(loop, handle);
- }
-}
-
-
static SOCKET uv__fast_poll_create_peer_socket(HANDLE iocp,
WSAPROTOCOL_INFOW* protocol_info) {
SOCKET sock = 0;
@@ -469,41 +405,6 @@ static void uv__slow_poll_process_poll_req(uv_loop_t* loop, uv_poll_t* handle,
}
-static int uv__slow_poll_set(uv_loop_t* loop, uv_poll_t* handle, int events) {
- assert(handle->type == UV_POLL);
- assert(!(handle->flags & UV_HANDLE_CLOSING));
- assert((events & ~(UV_READABLE | UV_WRITABLE)) == 0);
-
- handle->events = events;
-
- if (handle->events != 0) {
- uv__handle_start(handle);
- } else {
- uv__handle_stop(handle);
- }
-
- if ((handle->events &
- ~(handle->submitted_events_1 | handle->submitted_events_2)) != 0) {
- uv__slow_poll_submit_poll_req(handle->loop, handle);
- }
-
- return 0;
-}
-
-
-static int uv__slow_poll_close(uv_loop_t* loop, uv_poll_t* handle) {
- handle->events = 0;
- uv__handle_closing(handle);
-
- if (handle->submitted_events_1 == 0 &&
- handle->submitted_events_2 == 0) {
- uv_want_endgame(loop, (uv_handle_t*) handle);
- }
-
- return 0;
-}
-
-
int uv_poll_init(uv_loop_t* loop, uv_poll_t* handle, int fd) {
return uv_poll_init_socket(loop, handle, (SOCKET) uv__get_osfhandle(fd));
}
@@ -582,35 +483,43 @@ int uv_poll_init_socket(uv_loop_t* loop, uv_poll_t* handle,
}
-int uv_poll_start(uv_poll_t* handle, int events, uv_poll_cb cb) {
- int err;
+static int uv__poll_set(uv_poll_t* handle, int events, uv_poll_cb cb) {
+ int submitted_events;
- if (!(handle->flags & UV_HANDLE_POLL_SLOW)) {
- err = uv__fast_poll_set(handle->loop, handle, events);
- } else {
- err = uv__slow_poll_set(handle->loop, handle, events);
- }
+ assert(handle->type == UV_POLL);
+ assert(!(handle->flags & UV_HANDLE_CLOSING));
+ assert((events & ~(UV_READABLE | UV_WRITABLE | UV_DISCONNECT)) == 0);
+
+ handle->events = events;
+ handle->poll_cb = cb;
- if (err) {
- return uv_translate_sys_error(err);
+ if (handle->events == 0) {
+ uv__handle_stop(handle);
+ return 0;
}
- handle->poll_cb = cb;
+ uv__handle_start(handle);
+ submitted_events = handle->submitted_events_1 | handle->submitted_events_2;
+
+ if (handle->events & ~submitted_events) {
+ if (handle->flags & UV_HANDLE_POLL_SLOW) {
+ uv__slow_poll_submit_poll_req(handle->loop, handle);
+ } else {
+ uv__fast_poll_submit_poll_req(handle->loop, handle);
+ }
+ }
return 0;
}
-int uv_poll_stop(uv_poll_t* handle) {
- int err;
+int uv_poll_start(uv_poll_t* handle, int events, uv_poll_cb cb) {
+ return uv__poll_set(handle, events, cb);
+}
- if (!(handle->flags & UV_HANDLE_POLL_SLOW)) {
- err = uv__fast_poll_set(handle->loop, handle, 0);
- } else {
- err = uv__slow_poll_set(handle->loop, handle, 0);
- }
- return uv_translate_sys_error(err);
+int uv_poll_stop(uv_poll_t* handle) {
+ return uv__poll_set(handle, 0, handle->poll_cb);
}
@@ -624,11 +533,43 @@ void uv_process_poll_req(uv_loop_t* loop, uv_poll_t* handle, uv_req_t* req) {
int uv_poll_close(uv_loop_t* loop, uv_poll_t* handle) {
- if (!(handle->flags & UV_HANDLE_POLL_SLOW)) {
- return uv__fast_poll_close(loop, handle);
- } else {
- return uv__slow_poll_close(loop, handle);
+ AFD_POLL_INFO afd_poll_info;
+ DWORD error;
+ int result;
+
+ handle->events = 0;
+ uv__handle_closing(handle);
+
+ if (handle->submitted_events_1 == 0 &&
+ handle->submitted_events_2 == 0) {
+ uv_want_endgame(loop, (uv_handle_t*) handle);
+ return 0;
+ }
+
+ if (handle->flags & UV_HANDLE_POLL_SLOW)
+ return 0;
+
+ /* Cancel outstanding poll requests by executing another, unique poll
+ * request that forces the outstanding ones to return. */
+ afd_poll_info.Exclusive = TRUE;
+ afd_poll_info.NumberOfHandles = 1;
+ afd_poll_info.Timeout.QuadPart = INT64_MAX;
+ afd_poll_info.Handles[0].Handle = (HANDLE) handle->socket;
+ afd_poll_info.Handles[0].Status = 0;
+ afd_poll_info.Handles[0].Events = AFD_POLL_ALL;
+
+ result = uv_msafd_poll(handle->socket,
+ &afd_poll_info,
+ uv__get_afd_poll_info_dummy(),
+ uv__get_overlapped_dummy());
+
+ if (result == SOCKET_ERROR) {
+ error = WSAGetLastError();
+ if (error != WSA_IO_PENDING)
+ return uv_translate_sys_error(error);
}
+
+ return 0;
}
diff --git a/Utilities/cmlibuv/src/win/process.c b/Utilities/cmlibuv/src/win/process.c
index ce7b9dc..04718db 100644
--- a/Utilities/cmlibuv/src/win/process.c
+++ b/Utilities/cmlibuv/src/win/process.c
@@ -58,7 +58,6 @@ static const env_var_t required_vars[] = { /* keep me sorted */
E_V("USERPROFILE"),
E_V("WINDIR"),
};
-static size_t n_required_vars = ARRAY_SIZE(required_vars);
static HANDLE uv_global_job_handle_;
@@ -692,7 +691,7 @@ int make_program_env(char* env_block[], WCHAR** dst_ptr) {
WCHAR* dst_copy;
WCHAR** ptr_copy;
WCHAR** env_copy;
- DWORD* required_vars_value_len = alloca(n_required_vars * sizeof(DWORD*));
+ DWORD required_vars_value_len[ARRAY_SIZE(required_vars)];
/* first pass: determine size in UTF-16 */
for (env = env_block; *env; env++) {
@@ -745,7 +744,7 @@ int make_program_env(char* env_block[], WCHAR** dst_ptr) {
qsort(env_copy, env_block_count-1, sizeof(wchar_t*), qsort_wcscmp);
/* third pass: check for required variables */
- for (ptr_copy = env_copy, i = 0; i < n_required_vars; ) {
+ for (ptr_copy = env_copy, i = 0; i < ARRAY_SIZE(required_vars); ) {
int cmp;
if (!*ptr_copy) {
cmp = -1;
@@ -778,10 +777,10 @@ int make_program_env(char* env_block[], WCHAR** dst_ptr) {
}
for (ptr = dst, ptr_copy = env_copy, i = 0;
- *ptr_copy || i < n_required_vars;
+ *ptr_copy || i < ARRAY_SIZE(required_vars);
ptr += len) {
int cmp;
- if (i >= n_required_vars) {
+ if (i >= ARRAY_SIZE(required_vars)) {
cmp = 1;
} else if (!*ptr_copy) {
cmp = -1;
diff --git a/Utilities/cmlibuv/src/win/signal.c b/Utilities/cmlibuv/src/win/signal.c
index 276dc60..3d9f92c 100644
--- a/Utilities/cmlibuv/src/win/signal.c
+++ b/Utilities/cmlibuv/src/win/signal.c
@@ -46,6 +46,11 @@ void uv_signals_init(void) {
}
+void uv__signal_cleanup(void) {
+ /* TODO(bnoordhuis) Undo effects of uv_signal_init()? */
+}
+
+
static int uv__signal_compare(uv_signal_t* w1, uv_signal_t* w2) {
/* Compare signums first so all watchers with the same signnum end up
* adjacent. */
diff --git a/Utilities/cmlibuv/src/win/udp.c b/Utilities/cmlibuv/src/win/udp.c
index 3daa55f..508ed37 100644
--- a/Utilities/cmlibuv/src/win/udp.c
+++ b/Utilities/cmlibuv/src/win/udp.c
@@ -125,17 +125,10 @@ static int uv_udp_set_socket(uv_loop_t* loop, uv_udp_t* handle, SOCKET socket,
}
-int uv_udp_init_ex(uv_loop_t* loop, uv_udp_t* handle, unsigned int flags) {
- int domain;
-
- /* Use the lower 8 bits for the domain */
- domain = flags & 0xFF;
- if (domain != AF_INET && domain != AF_INET6 && domain != AF_UNSPEC)
- return UV_EINVAL;
-
- if (flags & ~0xFF)
- return UV_EINVAL;
-
+int uv__udp_init_ex(uv_loop_t* loop,
+ uv_udp_t* handle,
+ unsigned flags,
+ int domain) {
uv__handle_init(loop, (uv_handle_t*) handle, UV_UDP);
handle->socket = INVALID_SOCKET;
handle->reqs_pending = 0;
@@ -174,11 +167,6 @@ int uv_udp_init_ex(uv_loop_t* loop, uv_udp_t* handle, unsigned int flags) {
}
-int uv_udp_init(uv_loop_t* loop, uv_udp_t* handle) {
- return uv_udp_init_ex(loop, handle, AF_UNSPEC);
-}
-
-
void uv_udp_close(uv_loop_t* loop, uv_udp_t* handle) {
uv_udp_recv_stop(handle);
closesocket(handle->socket);
diff --git a/Utilities/cmlibuv/src/win/util.c b/Utilities/cmlibuv/src/win/util.c
index 34a898b..9e1e7f7 100644
--- a/Utilities/cmlibuv/src/win/util.c
+++ b/Utilities/cmlibuv/src/win/util.c
@@ -60,9 +60,6 @@
#endif
-/* Maximum environment variable size, including the terminating null */
-#define MAX_ENV_VAR_LENGTH 32767
-
/* A RtlGenRandom() by any other name... */
extern BOOLEAN NTAPI SystemFunction036(PVOID Buffer, ULONG BufferLength);
@@ -154,20 +151,26 @@ int uv_exepath(char* buffer, size_t* size_ptr) {
int uv_cwd(char* buffer, size_t* size) {
DWORD utf16_len;
- WCHAR utf16_buffer[MAX_PATH];
+ WCHAR *utf16_buffer;
int r;
if (buffer == NULL || size == NULL) {
return UV_EINVAL;
}
- utf16_len = GetCurrentDirectoryW(MAX_PATH, utf16_buffer);
+ utf16_len = GetCurrentDirectoryW(0, NULL);
if (utf16_len == 0) {
return uv_translate_sys_error(GetLastError());
- } else if (utf16_len > MAX_PATH) {
- /* This should be impossible; however the CRT has a code path to deal with
- * this scenario, so I added a check anyway. */
- return UV_EIO;
+ }
+ utf16_buffer = uv__malloc(utf16_len * sizeof(WCHAR));
+ if (utf16_buffer == NULL) {
+ return UV_ENOMEM;
+ }
+
+ utf16_len = GetCurrentDirectoryW(utf16_len, utf16_buffer);
+ if (utf16_len == 0) {
+ uv__free(utf16_buffer);
+ return uv_translate_sys_error(GetLastError());
}
/* utf16_len contains the length, *not* including the terminating null. */
@@ -191,8 +194,10 @@ int uv_cwd(char* buffer, size_t* size) {
NULL,
NULL);
if (r == 0) {
+ uv__free(utf16_buffer);
return uv_translate_sys_error(GetLastError());
} else if (r > (int) *size) {
+ uv__free(utf16_buffer);
*size = r;
return UV_ENOBUFS;
}
@@ -206,6 +211,8 @@ int uv_cwd(char* buffer, size_t* size) {
*size > INT_MAX ? INT_MAX : (int) *size,
NULL,
NULL);
+ uv__free(utf16_buffer);
+
if (r == 0) {
return uv_translate_sys_error(GetLastError());
}
@@ -216,43 +223,61 @@ int uv_cwd(char* buffer, size_t* size) {
int uv_chdir(const char* dir) {
- WCHAR utf16_buffer[MAX_PATH];
- size_t utf16_len;
+ WCHAR *utf16_buffer;
+ size_t utf16_len, new_utf16_len;
WCHAR drive_letter, env_var[4];
if (dir == NULL) {
return UV_EINVAL;
}
+ utf16_len = MultiByteToWideChar(CP_UTF8,
+ 0,
+ dir,
+ -1,
+ NULL,
+ 0);
+ if (utf16_len == 0) {
+ return uv_translate_sys_error(GetLastError());
+ }
+ utf16_buffer = uv__malloc(utf16_len * sizeof(WCHAR));
+ if (utf16_buffer == NULL) {
+ return UV_ENOMEM;
+ }
+
if (MultiByteToWideChar(CP_UTF8,
0,
dir,
-1,
utf16_buffer,
- MAX_PATH) == 0) {
- DWORD error = GetLastError();
- /* The maximum length of the current working directory is 260 chars,
- * including terminating null. If it doesn't fit, the path name must be too
- * long. */
- if (error == ERROR_INSUFFICIENT_BUFFER) {
- return UV_ENAMETOOLONG;
- } else {
- return uv_translate_sys_error(error);
- }
+ utf16_len) == 0) {
+ uv__free(utf16_buffer);
+ return uv_translate_sys_error(GetLastError());
}
if (!SetCurrentDirectoryW(utf16_buffer)) {
+ uv__free(utf16_buffer);
return uv_translate_sys_error(GetLastError());
}
/* Windows stores the drive-local path in an "hidden" environment variable,
* which has the form "=C:=C:\Windows". SetCurrentDirectory does not update
* this, so we'll have to do it. */
- utf16_len = GetCurrentDirectoryW(MAX_PATH, utf16_buffer);
+ new_utf16_len = GetCurrentDirectoryW(utf16_len, utf16_buffer);
+ if (new_utf16_len > utf16_len ) {
+ uv__free(utf16_buffer);
+ utf16_buffer = uv__malloc(new_utf16_len * sizeof(WCHAR));
+ if (utf16_buffer == NULL) {
+ /* When updating the environment variable fails, return UV_OK anyway.
+ * We did successfully change current working directory, only updating
+ * hidden env variable failed. */
+ return 0;
+ }
+ new_utf16_len = GetCurrentDirectoryW(new_utf16_len, utf16_buffer);
+ }
if (utf16_len == 0) {
- return uv_translate_sys_error(GetLastError());
- } else if (utf16_len > MAX_PATH) {
- return UV_EIO;
+ uv__free(utf16_buffer);
+ return 0;
}
/* The returned directory should not have a trailing slash, unless it points
@@ -284,11 +309,10 @@ int uv_chdir(const char* dir) {
env_var[2] = L':';
env_var[3] = L'\0';
- if (!SetEnvironmentVariableW(env_var, utf16_buffer)) {
- return uv_translate_sys_error(GetLastError());
- }
+ SetEnvironmentVariableW(env_var, utf16_buffer);
}
+ uv__free(utf16_buffer);
return 0;
}
@@ -361,6 +385,10 @@ char** uv_setup_args(int argc, char** argv) {
}
+void uv__process_title_cleanup(void) {
+}
+
+
int uv_set_process_title(const char* title) {
int err;
int length;
@@ -1163,20 +1191,29 @@ int uv_os_homedir(char* buffer, size_t* size) {
int uv_os_tmpdir(char* buffer, size_t* size) {
- wchar_t path[MAX_PATH + 2];
+ wchar_t *path;
DWORD bufsize;
size_t len;
if (buffer == NULL || size == NULL || *size == 0)
return UV_EINVAL;
- len = GetTempPathW(ARRAY_SIZE(path), path);
+ len = 0;
+ len = GetTempPathW(0, NULL);
+ if (len == 0) {
+ return uv_translate_sys_error(GetLastError());
+ }
+ /* Include space for terminating null char. */
+ len += 1;
+ path = uv__malloc(len * sizeof(wchar_t));
+ if (path == NULL) {
+ return UV_ENOMEM;
+ }
+ len = GetTempPathW(len, path);
if (len == 0) {
+ uv__free(path);
return uv_translate_sys_error(GetLastError());
- } else if (len > ARRAY_SIZE(path)) {
- /* This should not be possible */
- return UV_EIO;
}
/* The returned directory should not have a trailing slash, unless it points
@@ -1191,8 +1228,10 @@ int uv_os_tmpdir(char* buffer, size_t* size) {
bufsize = WideCharToMultiByte(CP_UTF8, 0, path, -1, NULL, 0, NULL, NULL);
if (bufsize == 0) {
+ uv__free(path);
return uv_translate_sys_error(GetLastError());
} else if (bufsize > *size) {
+ uv__free(path);
*size = bufsize;
return UV_ENOBUFS;
}
@@ -1206,6 +1245,7 @@ int uv_os_tmpdir(char* buffer, size_t* size) {
*size,
NULL,
NULL);
+ uv__free(path);
if (bufsize == 0)
return uv_translate_sys_error(GetLastError());
@@ -1325,7 +1365,7 @@ int uv__convert_utf8_to_utf16(const char* utf8, int utf8len, WCHAR** utf16) {
int uv__getpwuid_r(uv_passwd_t* pwd) {
HANDLE token;
wchar_t username[UNLEN + 1];
- wchar_t path[MAX_PATH];
+ wchar_t *path;
DWORD bufsize;
int r;
@@ -1336,15 +1376,24 @@ int uv__getpwuid_r(uv_passwd_t* pwd) {
if (OpenProcessToken(GetCurrentProcess(), TOKEN_READ, &token) == 0)
return uv_translate_sys_error(GetLastError());
- bufsize = ARRAY_SIZE(path);
- if (!GetUserProfileDirectoryW(token, path, &bufsize)) {
+ bufsize = 0;
+ GetUserProfileDirectoryW(token, NULL, &bufsize);
+ if (GetLastError() != ERROR_INSUFFICIENT_BUFFER) {
r = GetLastError();
CloseHandle(token);
+ return uv_translate_sys_error(r);
+ }
- /* This should not be possible */
- if (r == ERROR_INSUFFICIENT_BUFFER)
- return UV_ENOMEM;
+ path = uv__malloc(bufsize * sizeof(wchar_t));
+ if (path == NULL) {
+ CloseHandle(token);
+ return UV_ENOMEM;
+ }
+ if (!GetUserProfileDirectoryW(token, path, &bufsize)) {
+ r = GetLastError();
+ CloseHandle(token);
+ uv__free(path);
return uv_translate_sys_error(r);
}
@@ -1354,6 +1403,7 @@ int uv__getpwuid_r(uv_passwd_t* pwd) {
bufsize = ARRAY_SIZE(username);
if (!GetUserNameW(username, &bufsize)) {
r = GetLastError();
+ uv__free(path);
/* This should not be possible */
if (r == ERROR_INSUFFICIENT_BUFFER)
@@ -1364,6 +1414,7 @@ int uv__getpwuid_r(uv_passwd_t* pwd) {
pwd->homedir = NULL;
r = uv__convert_utf16_to_utf8(path, -1, &pwd->homedir);
+ uv__free(path);
if (r != 0)
return r;
@@ -1405,7 +1456,7 @@ int uv_os_environ(uv_env_item_t** envitems, int* count) {
for (penv = env, i = 0; *penv != L'\0'; penv += wcslen(penv) + 1, i++);
*envitems = uv__calloc(i, sizeof(**envitems));
- if (envitems == NULL) {
+ if (*envitems == NULL) {
FreeEnvironmentStringsW(env);
return UV_ENOMEM;
}
@@ -1461,7 +1512,9 @@ fail:
int uv_os_getenv(const char* name, char* buffer, size_t* size) {
- wchar_t var[MAX_ENV_VAR_LENGTH];
+ wchar_t fastvar[512];
+ wchar_t* var;
+ DWORD varlen;
wchar_t* name_w;
DWORD bufsize;
size_t len;
@@ -1475,25 +1528,52 @@ int uv_os_getenv(const char* name, char* buffer, size_t* size) {
if (r != 0)
return r;
- SetLastError(ERROR_SUCCESS);
- len = GetEnvironmentVariableW(name_w, var, MAX_ENV_VAR_LENGTH);
+ var = fastvar;
+ varlen = ARRAY_SIZE(fastvar);
+
+ for (;;) {
+ SetLastError(ERROR_SUCCESS);
+ len = GetEnvironmentVariableW(name_w, var, varlen);
+
+ if (len < varlen)
+ break;
+
+ /* Try repeatedly because we might have been preempted by another thread
+ * modifying the environment variable just as we're trying to read it.
+ */
+ if (var != fastvar)
+ uv__free(var);
+
+ varlen = 1 + len;
+ var = uv__malloc(varlen * sizeof(*var));
+
+ if (var == NULL) {
+ r = UV_ENOMEM;
+ goto fail;
+ }
+ }
+
uv__free(name_w);
- assert(len < MAX_ENV_VAR_LENGTH); /* len does not include the null */
+ name_w = NULL;
if (len == 0) {
r = GetLastError();
- if (r != ERROR_SUCCESS)
- return uv_translate_sys_error(r);
+ if (r != ERROR_SUCCESS) {
+ r = uv_translate_sys_error(r);
+ goto fail;
+ }
}
/* Check how much space we need */
bufsize = WideCharToMultiByte(CP_UTF8, 0, var, -1, NULL, 0, NULL, NULL);
if (bufsize == 0) {
- return uv_translate_sys_error(GetLastError());
+ r = uv_translate_sys_error(GetLastError());
+ goto fail;
} else if (bufsize > *size) {
*size = bufsize;
- return UV_ENOBUFS;
+ r = UV_ENOBUFS;
+ goto fail;
}
/* Convert to UTF-8 */
@@ -1506,11 +1586,23 @@ int uv_os_getenv(const char* name, char* buffer, size_t* size) {
NULL,
NULL);
- if (bufsize == 0)
- return uv_translate_sys_error(GetLastError());
+ if (bufsize == 0) {
+ r = uv_translate_sys_error(GetLastError());
+ goto fail;
+ }
*size = bufsize - 1;
- return 0;
+ r = 0;
+
+fail:
+
+ if (name_w != NULL)
+ uv__free(name_w);
+
+ if (var != fastvar)
+ uv__free(var);
+
+ return r;
}
diff --git a/Utilities/cmlibuv/src/win/winapi.h b/Utilities/cmlibuv/src/win/winapi.h
index 7803ca3..77f1878 100644
--- a/Utilities/cmlibuv/src/win/winapi.h
+++ b/Utilities/cmlibuv/src/win/winapi.h
@@ -4160,6 +4160,10 @@ typedef const UNICODE_STRING *PCUNICODE_STRING;
struct {
UCHAR DataBuffer[1];
} GenericReparseBuffer;
+ struct {
+ ULONG StringCount;
+ WCHAR StringList[1];
+ } AppExecLinkReparseBuffer;
};
} REPARSE_DATA_BUFFER, *PREPARSE_DATA_BUFFER;
#endif
@@ -4525,6 +4529,9 @@ typedef struct _SYSTEM_PROCESSOR_PERFORMANCE_INFORMATION {
#ifndef IO_REPARSE_TAG_SYMLINK
# define IO_REPARSE_TAG_SYMLINK (0xA000000CL)
#endif
+#ifndef IO_REPARSE_TAG_APPEXECLINK
+# define IO_REPARSE_TAG_APPEXECLINK (0x8000001BL)
+#endif
typedef VOID (NTAPI *PIO_APC_ROUTINE)
(PVOID ApcContext,