summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--.clang-tidy2
-rw-r--r--Help/command/find_package.rst18
-rw-r--r--Help/command/list.rst7
-rw-r--r--Help/command/macro.rst2
-rw-r--r--Help/cpack_gen/nsis.rst4
-rw-r--r--Help/envvar/CMAKE_PREFIX_PATH.rst17
-rw-r--r--Help/manual/cmake-env-variables.7.rst7
-rw-r--r--Help/manual/cmake-policies.7.rst1
-rw-r--r--Help/manual/cmake-properties.7.rst1
-rw-r--r--Help/manual/cmake-variables.7.rst1
-rw-r--r--Help/policy/CMP0104.rst31
-rw-r--r--Help/prop_sf/SKIP_PRECOMPILE_HEADERS.rst4
-rw-r--r--Help/prop_tgt/CUDA_ARCHITECTURES.rst30
-rw-r--r--Help/release/dev/cuda-architectures-empty.rst7
-rw-r--r--Help/release/dev/cuda-architectures.rst6
-rw-r--r--Help/release/dev/list_natural_sort.rst5
-rw-r--r--Help/release/dev/nsis-dpi-aware.rst6
-rw-r--r--Help/variable/CMAKE_CUDA_ARCHITECTURES.rst17
-rw-r--r--Help/variable/CMAKE_CURRENT_FUNCTION.rst6
-rw-r--r--Help/variable/CMAKE_CURRENT_FUNCTION_LIST_DIR.rst50
-rw-r--r--Help/variable/CMAKE_CURRENT_FUNCTION_LIST_FILE.rst6
-rw-r--r--Help/variable/CMAKE_CURRENT_FUNCTION_LIST_LINE.rst7
-rw-r--r--Modules/CMakeASMCompiler.cmake.in1
-rw-r--r--Modules/CMakeCCompiler.cmake.in1
-rw-r--r--Modules/CMakeCUDACompiler.cmake.in1
-rw-r--r--Modules/CMakeCUDAInformation.cmake2
-rw-r--r--Modules/CMakeCXXCompiler.cmake.in1
-rw-r--r--Modules/CMakeDetermineASMCompiler.cmake11
-rw-r--r--Modules/CMakeDetermineCCompiler.cmake10
-rw-r--r--Modules/CMakeDetermineCUDACompiler.cmake21
-rw-r--r--Modules/CMakeDetermineCXXCompiler.cmake10
-rw-r--r--Modules/CMakeDetermineCompiler.cmake15
-rw-r--r--Modules/CMakeDetermineFortranCompiler.cmake10
-rw-r--r--Modules/CMakeFortranCompiler.cmake.in1
-rw-r--r--Modules/CMakePrintSystemInformation.cmake2
-rw-r--r--Modules/Compiler/Clang-CXX.cmake119
-rw-r--r--Modules/Compiler/Clang-OBJCXX.cmake69
-rw-r--r--Modules/Compiler/Clang.cmake120
-rw-r--r--Modules/Compiler/GNU.cmake3
-rw-r--r--Modules/Compiler/NVIDIA-CUDA.cmake1
-rw-r--r--Modules/FindBLAS.cmake34
-rw-r--r--Modules/FindCUDAToolkit.cmake26
-rw-r--r--Modules/FindLAPACK.cmake34
-rw-r--r--Modules/FindMPI.cmake6
-rw-r--r--Modules/FindOpenAL.cmake4
-rw-r--r--Modules/FindPython.cmake25
-rw-r--r--Modules/FindPython/Support.cmake18
-rw-r--r--Modules/FindPython2.cmake17
-rw-r--r--Modules/FindPython3.cmake25
-rw-r--r--Modules/GoogleTestAddTests.cmake1
-rw-r--r--Modules/Internal/CPack/NSIS.template.in1
-rw-r--r--Modules/Platform/UnixPaths.cmake4
-rw-r--r--Modules/UseJava.cmake12
-rw-r--r--Source/CMakeVersion.cmake2
-rw-r--r--Source/CPack/IFW/cmCPackIFWRepository.cxx4
-rw-r--r--Source/CPack/cmCPackNSISGenerator.cxx5
-rw-r--r--Source/CTest/cmCTestBuildHandler.cxx4
-rw-r--r--Source/CTest/cmCTestCVS.cxx6
-rw-r--r--Source/CTest/cmCTestMemCheckHandler.cxx40
-rw-r--r--Source/CTest/cmCTestTestHandler.cxx7
-rw-r--r--Source/CTest/cmParseCacheCoverage.cxx30
-rw-r--r--Source/CTest/cmParseCacheCoverage.h3
-rw-r--r--Source/CursesDialog/cmCursesLongMessageForm.cxx3
-rw-r--r--Source/QtDialog/CMakeSetupDialog.cxx3
-rw-r--r--Source/cmCPluginAPI.cxx3
-rw-r--r--Source/cmCTest.cxx12
-rw-r--r--Source/cmCommonTargetGenerator.cxx4
-rw-r--r--Source/cmComputeLinkInformation.cxx6
-rw-r--r--Source/cmConfigureFileCommand.cxx26
-rw-r--r--Source/cmCoreTryCompile.cxx6
-rw-r--r--Source/cmCustomCommand.cxx4
-rw-r--r--Source/cmCustomCommand.h7
-rw-r--r--Source/cmDepends.cxx4
-rw-r--r--Source/cmDepends.h12
-rw-r--r--Source/cmDependsC.cxx11
-rw-r--r--Source/cmDependsC.h4
-rw-r--r--Source/cmDependsFortran.cxx8
-rw-r--r--Source/cmDependsFortran.h4
-rw-r--r--Source/cmExtraCodeLiteGenerator.cxx4
-rw-r--r--Source/cmExtraEclipseCDT4Generator.cxx1
-rw-r--r--Source/cmExtraKateGenerator.cxx7
-rw-r--r--Source/cmExtraSublimeTextGenerator.cxx22
-rw-r--r--Source/cmFileAPICodemodel.cxx8
-rw-r--r--Source/cmFindPackageCommand.cxx6
-rw-r--r--Source/cmFindProgramCommand.cxx2
-rw-r--r--Source/cmGeneratorTarget.cxx109
-rw-r--r--Source/cmGeneratorTarget.h2
-rw-r--r--Source/cmGhsMultiTargetGenerator.cxx8
-rw-r--r--Source/cmGlobalBorlandMakefileGenerator.h1
-rw-r--r--Source/cmGlobalGenerator.cxx16
-rw-r--r--Source/cmGlobalGenerator.h1
-rw-r--r--Source/cmGlobalNinjaGenerator.cxx2
-rw-r--r--Source/cmGlobalUnixMakefileGenerator3.cxx78
-rw-r--r--Source/cmGlobalUnixMakefileGenerator3.h9
-rw-r--r--Source/cmGlobalVisualStudio8Generator.cxx8
-rw-r--r--Source/cmGlobalVisualStudioGenerator.cxx2
-rw-r--r--Source/cmGlobalXCodeGenerator.cxx46
-rw-r--r--Source/cmInstallCommand.cxx1
-rw-r--r--Source/cmJsonObjects.cxx20
-rw-r--r--Source/cmListCommand.cxx23
-rw-r--r--Source/cmLocalGenerator.cxx65
-rw-r--r--Source/cmLocalGenerator.h18
-rw-r--r--Source/cmLocalUnixMakefileGenerator3.cxx55
-rw-r--r--Source/cmLocalUnixMakefileGenerator3.h6
-rw-r--r--Source/cmLocalVisualStudio7Generator.cxx34
-rw-r--r--Source/cmLocalVisualStudioGenerator.cxx4
-rw-r--r--Source/cmMakefile.cxx60
-rw-r--r--Source/cmMakefile.h12
-rw-r--r--Source/cmMakefileTargetGenerator.cxx42
-rw-r--r--Source/cmNinjaTargetGenerator.cxx36
-rw-r--r--Source/cmOutputConverter.cxx2
-rw-r--r--Source/cmPolicies.cxx2
-rw-r--r--Source/cmPolicies.h7
-rw-r--r--Source/cmQTWrapCPPCommand.cxx3
-rw-r--r--Source/cmQtAutoGenInitializer.cxx13
-rw-r--r--Source/cmRST.cxx2
-rw-r--r--Source/cmSeparateArgumentsCommand.cxx2
-rw-r--r--Source/cmSourceFile.cxx34
-rw-r--r--Source/cmSourceFile.h4
-rw-r--r--Source/cmTarget.cxx8
-rw-r--r--Source/cmVisualStudio10TargetGenerator.cxx128
-rw-r--r--Source/cmVisualStudio10TargetGenerator.h4
-rw-r--r--Source/cmake.cxx25
-rw-r--r--Source/cmcmd.cxx5
-rw-r--r--Source/kwsys/Base64.c5
-rw-r--r--Source/kwsys/MD5.c30
-rw-r--r--Source/kwsys/ProcessUNIX.c215
-rw-r--r--Source/kwsys/SystemTools.cxx2
-rw-r--r--Source/kwsys/testProcess.c6
-rw-r--r--Source/kwsys/testSystemTools.cxx38
-rw-r--r--Templates/TestDriver.cxx.in7
-rw-r--r--Tests/CMakeLists.txt2
-rw-r--r--Tests/CMakeTests/ListTest.cmake.in23
-rw-r--r--Tests/CPackNSISGenerator/CMakeLists.txt1
-rw-r--r--Tests/CPackNSISGenerator/RunCPackVerifyResult.cmake8
-rw-r--r--Tests/Cuda/CXXStandardSetTwice/CMakeLists.txt3
-rw-r--r--Tests/Cuda/Complex/CMakeLists.txt2
-rw-r--r--Tests/Cuda/MixedStandardLevels1/CMakeLists.txt3
-rw-r--r--Tests/Cuda/MixedStandardLevels2/CMakeLists.txt3
-rw-r--r--Tests/Cuda/MixedStandardLevels3/CMakeLists.txt2
-rw-r--r--Tests/Cuda/MixedStandardLevels4/CMakeLists.txt3
-rw-r--r--Tests/Cuda/MixedStandardLevels5/CMakeLists.txt3
-rw-r--r--Tests/Cuda/ProperDeviceLibraries/CMakeLists.txt2
-rw-r--r--Tests/Cuda/WithC/CMakeLists.txt2
-rw-r--r--Tests/CudaOnly/Architecture/CMakeLists.txt5
-rw-r--r--Tests/CudaOnly/Architecture/main.cu9
-rw-r--r--Tests/CudaOnly/CMakeLists.txt2
-rw-r--r--Tests/CudaOnly/CircularLinkLine/CMakeLists.txt2
-rw-r--r--Tests/CudaOnly/CompileFlags/CMakeLists.txt16
-rw-r--r--Tests/CudaOnly/CompileFlags/main.cu16
-rw-r--r--Tests/CudaOnly/DontResolveDeviceSymbols/CMakeLists.txt2
-rw-r--r--Tests/CudaOnly/ResolveDeviceSymbols/CMakeLists.txt2
-rw-r--r--Tests/CudaOnly/RuntimeControls/CMakeLists.txt3
-rw-r--r--Tests/CudaOnly/SeparateCompilation/CMakeLists.txt4
-rw-r--r--Tests/CudaOnly/Standard98/CMakeLists.txt2
-rw-r--r--Tests/CudaOnly/WithDefs/CMakeLists.txt13
-rw-r--r--Tests/IncludeDirectories/CMakeLists.txt33
-rw-r--r--Tests/IncludeDirectories/main.cpp14
-rw-r--r--Tests/RunCMake/CMP0104/CMP0104-Common.cmake2
-rw-r--r--Tests/RunCMake/CMP0104/CMP0104-NEW.cmake6
-rw-r--r--Tests/RunCMake/CMP0104/CMP0104-OLD.cmake12
-rw-r--r--Tests/RunCMake/CMP0104/CMP0104-WARN-stderr.txt8
-rw-r--r--Tests/RunCMake/CMP0104/CMP0104-WARN.cmake1
-rw-r--r--Tests/RunCMake/CMP0104/CMakeLists.txt3
-rw-r--r--Tests/RunCMake/CMP0104/RunCMakeTest.cmake5
-rw-r--r--Tests/RunCMake/CMP0104/main.cu3
-rw-r--r--Tests/RunCMake/CMakeLists.txt3
-rw-r--r--Tests/RunCMake/CompilerLauncher/CUDA-common.cmake1
-rw-r--r--Tests/RunCMake/GoogleTest/GoogleTest-skip-timeout-stdout.txt10
-rw-r--r--Tests/RunCMake/GoogleTest/GoogleTest.cmake6
-rw-r--r--Tests/RunCMake/GoogleTest/RunCMakeTest.cmake14
-rw-r--r--Tests/RunCMake/GoogleTest/skip_test.cpp18
-rw-r--r--Tests/RunCMake/NinjaMultiConfig/CudaSimple.cmake1
-rw-r--r--Tests/RunCMake/TargetPolicies/PolicyList-stderr.txt1
-rw-r--r--Tests/RunCMake/exit_code.c3
-rw-r--r--Tests/RunCMake/find_program/ExeNoRead-stdout.txt1
-rw-r--r--Tests/RunCMake/find_program/ExeNoRead.cmake4
-rw-r--r--Tests/RunCMake/find_program/RunCMakeTest.cmake4
-rw-r--r--Tests/RunCMake/pseudo_cppcheck.c3
-rw-r--r--Tests/TryCompile/CMakeLists.txt2
-rwxr-xr-xbootstrap12
181 files changed, 1724 insertions, 887 deletions
diff --git a/.clang-tidy b/.clang-tidy
index a520679..10819ef 100644
--- a/.clang-tidy
+++ b/.clang-tidy
@@ -13,9 +13,11 @@ modernize-*,\
-modernize-avoid-c-arrays,\
-modernize-use-nodiscard,\
-modernize-use-noexcept,\
+-modernize-use-trailing-return-type,\
-modernize-use-transparent-functors,\
performance-*,\
readability-*,\
+-readability-convert-member-functions-to-static,\
-readability-function-size,\
-readability-identifier-naming,\
-readability-implicit-bool-conversion,\
diff --git a/Help/command/find_package.rst b/Help/command/find_package.rst
index 64a16f3..6753268 100644
--- a/Help/command/find_package.rst
+++ b/Help/command/find_package.rst
@@ -302,23 +302,23 @@ enabled.
are intended to be used on the command line with a ``-DVAR=value``.
The values are interpreted as :ref:`semicolon-separated lists <CMake Language Lists>`.
This can be skipped if ``NO_CMAKE_PATH`` is passed or by setting the
- :variable:`CMAKE_FIND_USE_CMAKE_PATH` to ``FALSE``::
+ :variable:`CMAKE_FIND_USE_CMAKE_PATH` to ``FALSE``:
- CMAKE_PREFIX_PATH
- CMAKE_FRAMEWORK_PATH
- CMAKE_APPBUNDLE_PATH
+ * :variable:`CMAKE_PREFIX_PATH`
+ * :variable:`CMAKE_FRAMEWORK_PATH`
+ * :variable:`CMAKE_APPBUNDLE_PATH`
3. Search paths specified in cmake-specific environment variables.
These are intended to be set in the user's shell configuration,
and therefore use the host's native path separator
(``;`` on Windows and ``:`` on UNIX).
This can be skipped if ``NO_CMAKE_ENVIRONMENT_PATH`` is passed or by setting
- the :variable:`CMAKE_FIND_USE_CMAKE_ENVIRONMENT_PATH` to ``FALSE``::
+ the :variable:`CMAKE_FIND_USE_CMAKE_ENVIRONMENT_PATH` to ``FALSE``:
- <PackageName>_DIR
- CMAKE_PREFIX_PATH
- CMAKE_FRAMEWORK_PATH
- CMAKE_APPBUNDLE_PATH
+ * ``<PackageName>_DIR``
+ * :envvar:`CMAKE_PREFIX_PATH`
+ * ``CMAKE_FRAMEWORK_PATH``
+ * ``CMAKE_APPBUNDLE_PATH``
4. Search paths specified by the ``HINTS`` option. These should be paths
computed by system introspection, such as a hint provided by the
diff --git a/Help/command/list.rst b/Help/command/list.rst
index 50bf417..4d339a0 100644
--- a/Help/command/list.rst
+++ b/Help/command/list.rst
@@ -308,6 +308,13 @@ The ``<compare>`` option should be one of:
* ``STRING``: Sorts a list of strings alphabetically. This is the
default behavior if the ``COMPARE`` option is not given.
* ``FILE_BASENAME``: Sorts a list of pathnames of files by their basenames.
+* ``NATURAL``: Sorts a list of strings using natural order
+ (see ``strverscmp(3)`` manual), i.e. such that contiguous digits
+ are compared as whole numbers.
+ For example: the following list `10.0 1.1 2.1 8.0 2.0 3.1`
+ will be sorted as `1.1 2.0 2.1 3.1 8.0 10.0` if the ``NATURAL``
+ comparison is selected where it will be sorted as
+ `1.1 10.0 2.0 2.1 3.1 8.0` with the ``STRING`` comparison.
Use the ``CASE`` keyword to select a case sensitive or case insensitive
sort mode. The ``<case>`` option should be one of:
diff --git a/Help/command/macro.rst b/Help/command/macro.rst
index ee955cb..65159f4 100644
--- a/Help/command/macro.rst
+++ b/Help/command/macro.rst
@@ -99,7 +99,7 @@ Unlike a function, the :variable:`CMAKE_CURRENT_FUNCTION`,
:variable:`CMAKE_CURRENT_FUNCTION_LIST_DIR`,
:variable:`CMAKE_CURRENT_FUNCTION_LIST_FILE`,
:variable:`CMAKE_CURRENT_FUNCTION_LIST_LINE` variables are not
-set for macro.
+set for a macro.
.. _`Argument Caveats`:
diff --git a/Help/cpack_gen/nsis.rst b/Help/cpack_gen/nsis.rst
index d1e495f..0dd876e 100644
--- a/Help/cpack_gen/nsis.rst
+++ b/Help/cpack_gen/nsis.rst
@@ -155,3 +155,7 @@ on Windows Nullsoft Scriptable Install System.
.. variable:: CPACK_NSIS_MUI_HEADERIMAGE
The image to display on the header of installers pages.
+
+.. variable:: CPACK_NSIS_MANIFEST_DPI_AWARE
+
+ If set, declares that the installer is DPI-aware.
diff --git a/Help/envvar/CMAKE_PREFIX_PATH.rst b/Help/envvar/CMAKE_PREFIX_PATH.rst
new file mode 100644
index 0000000..276fdd6
--- /dev/null
+++ b/Help/envvar/CMAKE_PREFIX_PATH.rst
@@ -0,0 +1,17 @@
+CMAKE_PREFIX_PATH
+-----------------
+
+.. include:: ENV_VAR.txt
+
+The ``CMAKE_PREFIX_PATH`` environment variable may be set to a list of
+directories specifying installation *prefixes* to be searched by the
+:command:`find_package`, :command:`find_program`, :command:`find_library`,
+:command:`find_file`, and :command:`find_path` commands. Each command will
+add appropriate subdirectories (like ``bin``, ``lib``, or ``include``)
+as specified in its own documentation.
+
+This variable may hold a single prefix or a list of prefixes separated
+by ``:`` on UNIX or ``;`` on Windows (the same as the ``PATH`` environment
+variable convention on those platforms).
+
+See also the :variable:`CMAKE_PREFIX_PATH` CMake variable.
diff --git a/Help/manual/cmake-env-variables.7.rst b/Help/manual/cmake-env-variables.7.rst
index adfc39e..dfdf415 100644
--- a/Help/manual/cmake-env-variables.7.rst
+++ b/Help/manual/cmake-env-variables.7.rst
@@ -14,6 +14,13 @@ For general information on environment variables, see the
:ref:`Environment Variables <CMake Language Environment Variables>`
section in the cmake-language manual.
+Environment Variables that Change Behavior
+==========================================
+
+.. toctree::
+ :maxdepth: 1
+
+ /envvar/CMAKE_PREFIX_PATH
Environment Variables that Control the Build
============================================
diff --git a/Help/manual/cmake-policies.7.rst b/Help/manual/cmake-policies.7.rst
index 08d59e7..869ae41 100644
--- a/Help/manual/cmake-policies.7.rst
+++ b/Help/manual/cmake-policies.7.rst
@@ -57,6 +57,7 @@ Policies Introduced by CMake 3.18
.. toctree::
:maxdepth: 1
+ CMP0104: CMAKE_CUDA_ARCHITECTURES now detected for NVCC, empty CUDA_ARCHITECTURES not allowed. </policy/CMP0104>
CMP0103: Multiple export() with same FILE without APPEND is not allowed. </policy/CMP0103>
Policies Introduced by CMake 3.17
diff --git a/Help/manual/cmake-properties.7.rst b/Help/manual/cmake-properties.7.rst
index cbb2298..4966f86 100644
--- a/Help/manual/cmake-properties.7.rst
+++ b/Help/manual/cmake-properties.7.rst
@@ -172,6 +172,7 @@ Properties on Targets
/prop_tgt/CONFIG_OUTPUT_NAME
/prop_tgt/CONFIG_POSTFIX
/prop_tgt/CROSSCOMPILING_EMULATOR
+ /prop_tgt/CUDA_ARCHITECTURES
/prop_tgt/CUDA_PTX_COMPILATION
/prop_tgt/CUDA_SEPARABLE_COMPILATION
/prop_tgt/CUDA_RESOLVE_DEVICE_SYMBOLS
diff --git a/Help/manual/cmake-variables.7.rst b/Help/manual/cmake-variables.7.rst
index 1642772..7d802e1 100644
--- a/Help/manual/cmake-variables.7.rst
+++ b/Help/manual/cmake-variables.7.rst
@@ -488,6 +488,7 @@ Variables for Languages
/variable/CMAKE_COMPILER_IS_GNUCC
/variable/CMAKE_COMPILER_IS_GNUCXX
/variable/CMAKE_COMPILER_IS_GNUG77
+ /variable/CMAKE_CUDA_ARCHITECTURES
/variable/CMAKE_CUDA_COMPILE_FEATURES
/variable/CMAKE_CUDA_HOST_COMPILER
/variable/CMAKE_CUDA_EXTENSIONS
diff --git a/Help/policy/CMP0104.rst b/Help/policy/CMP0104.rst
new file mode 100644
index 0000000..ca2c571
--- /dev/null
+++ b/Help/policy/CMP0104.rst
@@ -0,0 +1,31 @@
+CMP0104
+-------
+
+Initialize :variable:`CMAKE_CUDA_ARCHITECTURES` when
+:variable:`CMAKE_CUDA_COMPILER_ID <CMAKE_<LANG>_COMPILER_ID>` is ``NVIDIA``.
+Raise an error if :prop_tgt:`CUDA_ARCHITECTURES` is empty.
+
+:variable:`CMAKE_CUDA_ARCHITECTURES` introduced in CMake 3.18 is used to
+initialize :prop_tgt:`CUDA_ARCHITECTURES`, which passes correct code generation
+flags to the CUDA compiler.
+
+Previous to this users had to manually specify the code generation flags. This
+policy is for backwards compatibility with manually specifying code generation
+flags.
+
+The ``OLD`` behavior for this policy is to not initialize
+:variable:`CMAKE_CUDA_ARCHITECTURES` when
+:variable:`CMAKE_CUDA_COMPILER_ID <CMAKE_<LANG>_COMPILER_ID>` is ``NVIDIA``.
+Empty :prop_tgt:`CUDA_ARCHITECTURES` is allowed.
+
+The ``NEW`` behavior of this policy is to initialize
+:variable:`CMAKE_CUDA_ARCHITECTURES` when
+:variable:`CMAKE_CUDA_COMPILER_ID <CMAKE_<LANG>_COMPILER_ID>` is ``NVIDIA``
+and raise an error if :prop_tgt:`CUDA_ARCHITECTURES` is empty during generation.
+
+This policy was introduced in CMake version 3.18. CMake version
+|release| warns when the policy is not set and uses ``OLD`` behavior.
+Use the :command:`cmake_policy` command to set it to ``OLD`` or ``NEW``
+explicitly.
+
+.. include:: DEPRECATED.txt
diff --git a/Help/prop_sf/SKIP_PRECOMPILE_HEADERS.rst b/Help/prop_sf/SKIP_PRECOMPILE_HEADERS.rst
index 5f39f30..0031da3 100644
--- a/Help/prop_sf/SKIP_PRECOMPILE_HEADERS.rst
+++ b/Help/prop_sf/SKIP_PRECOMPILE_HEADERS.rst
@@ -6,8 +6,8 @@ Is this source file skipped by :prop_tgt:`PRECOMPILE_HEADERS` feature.
This property helps with build problems that one would run into
when using the :prop_tgt:`PRECOMPILE_HEADERS` feature.
-One example would be the usage of Objective-C (*.m) files, and
-Objective-C++ (*.mm) files, which lead to compilation failure
+One example would be the usage of Objective-C (``*.m``) files, and
+Objective-C++ (``*.mm``) files, which lead to compilation failure
because they are treated (in case of Ninja / Makefile generator)
as C, and CXX respectively. The precompile headers are not
compatible between languages.
diff --git a/Help/prop_tgt/CUDA_ARCHITECTURES.rst b/Help/prop_tgt/CUDA_ARCHITECTURES.rst
new file mode 100644
index 0000000..328f40b
--- /dev/null
+++ b/Help/prop_tgt/CUDA_ARCHITECTURES.rst
@@ -0,0 +1,30 @@
+CUDA_ARCHITECTURES
+------------------
+
+List of architectures to generate device code for.
+
+An architecture can be suffixed by either ``-real`` or ``-virtual`` to specify
+the kind of architecture to generate code for.
+If no suffix is given then code is generated for both real and virtual
+architectures.
+
+This property is initialized by the value of the :variable:`CMAKE_CUDA_ARCHITECTURES`
+variable if it is set when a target is created.
+
+The ``CUDA_ARCHITECTURES`` target property must be set to a non-empty value on targets
+that compile CUDA sources, or it is an error. See policy :policy:`CMP0104`.
+
+Examples
+^^^^^^^^
+
+.. code-block:: cmake
+
+ set_property(TARGET tgt PROPERTY CUDA_ARCHITECTURES 35 50 72)
+
+Generates code for real and virtual architectures ``30``, ``50`` and ``72``.
+
+.. code-block:: cmake
+
+ set_property(TARGET tgt PROPERTY CUDA_ARCHITECTURES 70-real 72-virtual)
+
+Generates code for real architecture ``70`` and virtual architecture ``72``.
diff --git a/Help/release/dev/cuda-architectures-empty.rst b/Help/release/dev/cuda-architectures-empty.rst
new file mode 100644
index 0000000..b0fc327
--- /dev/null
+++ b/Help/release/dev/cuda-architectures-empty.rst
@@ -0,0 +1,7 @@
+cuda-architectures-empty
+------------------------
+
+* :variable:`CMAKE_CUDA_ARCHITECTURES` is now initialized when
+ :variable:`CMAKE_CUDA_COMPILER_ID <CMAKE_<LANG>_COMPILER_ID>` is ``NVIDIA``.
+ Empty :prop_tgt:`CUDA_ARCHITECTURES` raises an error. See policy
+ :policy:`CMP0104`.
diff --git a/Help/release/dev/cuda-architectures.rst b/Help/release/dev/cuda-architectures.rst
new file mode 100644
index 0000000..dc6c55b
--- /dev/null
+++ b/Help/release/dev/cuda-architectures.rst
@@ -0,0 +1,6 @@
+cuda-architectures
+------------------
+
+* Added :prop_tgt:`CUDA_ARCHITECTURES` target property for specifying CUDA
+ output architectures. Users are encouraged to use this instead of specifying
+ options manually, as this approach is compiler-agnostic.
diff --git a/Help/release/dev/list_natural_sort.rst b/Help/release/dev/list_natural_sort.rst
new file mode 100644
index 0000000..ff74e5a
--- /dev/null
+++ b/Help/release/dev/list_natural_sort.rst
@@ -0,0 +1,5 @@
+list_natural_sort
+-----------------
+
+* The :command:`list` operation ``SORT`` gained the ``NATURAL`` sort
+ option to sort using natural order (see ``strverscmp(3)`` manual).
diff --git a/Help/release/dev/nsis-dpi-aware.rst b/Help/release/dev/nsis-dpi-aware.rst
new file mode 100644
index 0000000..8b5032e
--- /dev/null
+++ b/Help/release/dev/nsis-dpi-aware.rst
@@ -0,0 +1,6 @@
+nsis-dpi-aware
+--------------
+
+* The :cpack_gen:`CPack NSIS Generator` gained a new variable
+ :variable:`CPACK_NSIS_MANIFEST_DPI_AWARE` to declare that the
+ installer is DPI-aware.
diff --git a/Help/variable/CMAKE_CUDA_ARCHITECTURES.rst b/Help/variable/CMAKE_CUDA_ARCHITECTURES.rst
new file mode 100644
index 0000000..149bffa
--- /dev/null
+++ b/Help/variable/CMAKE_CUDA_ARCHITECTURES.rst
@@ -0,0 +1,17 @@
+CMAKE_CUDA_ARCHITECTURES
+------------------------
+
+Default value for :prop_tgt:`CUDA_ARCHITECTURES` property of targets.
+
+This is initialized as follows depending on :variable:`CMAKE_CUDA_COMPILER_ID <CMAKE_<LANG>_COMPILER_ID>`:
+
+- For ``Clang``: the oldest architecture that works.
+
+- For ``NVIDIA``: the default architecture chosen by the compiler.
+ See policy :policy:`CMP0104`.
+
+Users are encouraged to override this, as the default varies across compilers
+and compiler versions.
+
+This variable is used to initialize the :prop_tgt:`CUDA_ARCHITECTURES` property
+on all targets. See the target property for additional information.
diff --git a/Help/variable/CMAKE_CURRENT_FUNCTION.rst b/Help/variable/CMAKE_CURRENT_FUNCTION.rst
index aa2936c..fb7f610 100644
--- a/Help/variable/CMAKE_CURRENT_FUNCTION.rst
+++ b/Help/variable/CMAKE_CURRENT_FUNCTION.rst
@@ -2,5 +2,9 @@ CMAKE_CURRENT_FUNCTION
----------------------
When executing code inside a :command:`function`, this variable
-contains the name of the current function. It can be used for
+contains the name of the current function. It can be useful for
diagnostic or debug messages.
+
+See also :variable:`CMAKE_CURRENT_FUNCTION_LIST_DIR`,
+:variable:`CMAKE_CURRENT_FUNCTION_LIST_FILE` and
+:variable:`CMAKE_CURRENT_FUNCTION_LIST_LINE`.
diff --git a/Help/variable/CMAKE_CURRENT_FUNCTION_LIST_DIR.rst b/Help/variable/CMAKE_CURRENT_FUNCTION_LIST_DIR.rst
index 0119381..44ae1e5 100644
--- a/Help/variable/CMAKE_CURRENT_FUNCTION_LIST_DIR.rst
+++ b/Help/variable/CMAKE_CURRENT_FUNCTION_LIST_DIR.rst
@@ -2,32 +2,40 @@ CMAKE_CURRENT_FUNCTION_LIST_DIR
-------------------------------
When executing code inside a :command:`function`, this variable
-contains the full directory of the listfile defining the current function.
+contains the full directory of the listfile that defined the current function.
-It is quite common practice in CMake that modules use some additional files
-(e.g., templates to render). And the code typically did the following:
+It is quite common practice in CMake for modules to use some additional files,
+such as templates to be copied in after substituting CMake variables.
+In such cases, a function needs to know where to locate those files in a way
+that doesn't depend on where the function is called. Without
+``CMAKE_CURRENT_FUNCTION_LIST_DIR``, the code to do that would typically use
+the following pattern:
.. code-block:: cmake
- :caption: Bad
- set(_THIS_MODULE_BASE_DIR "${CMAKE_CURRENT_LIST_DIR}")
+ set(_THIS_MODULE_BASE_DIR "${CMAKE_CURRENT_LIST_DIR}")
- function(foo)
- configure_file(
- "${_THIS_MODULE_BASE_DIR}/some.template.in"
- some.output
- )
- endfunction()
+ function(foo)
+ configure_file(
+ "${_THIS_MODULE_BASE_DIR}/some.template.in"
+ some.output
+ )
+ endfunction()
-Using this variable inside a function eliminates the neccessity of the
-additional one with "global" scope:
+Using ``CMAKE_CURRENT_FUNCTION_LIST_DIR`` inside the function instead
+eliminates the need for the extra variable which would otherwise be visible
+outside the function's scope.
+The above example can be written in the more concise and more robust form:
.. code-block:: cmake
- :caption: Good
-
- function(foo)
- configure_file(
- "${CMAKE_CURRENT_FUNCTION_LIST_DIR}/some.template.in"
- some.output
- )
- endfunction()
+
+ function(foo)
+ configure_file(
+ "${CMAKE_CURRENT_FUNCTION_LIST_DIR}/some.template.in"
+ some.output
+ )
+ endfunction()
+
+See also :variable:`CMAKE_CURRENT_FUNCTION`,
+:variable:`CMAKE_CURRENT_FUNCTION_LIST_FILE` and
+:variable:`CMAKE_CURRENT_FUNCTION_LIST_LINE`.
diff --git a/Help/variable/CMAKE_CURRENT_FUNCTION_LIST_FILE.rst b/Help/variable/CMAKE_CURRENT_FUNCTION_LIST_FILE.rst
index d2c846a..c737af9 100644
--- a/Help/variable/CMAKE_CURRENT_FUNCTION_LIST_FILE.rst
+++ b/Help/variable/CMAKE_CURRENT_FUNCTION_LIST_FILE.rst
@@ -2,4 +2,8 @@ CMAKE_CURRENT_FUNCTION_LIST_FILE
--------------------------------
When executing code inside a :command:`function`, this variable
-contains the full path to the listfile declaring a current function.
+contains the full path to the listfile that defined the current function.
+
+See also :variable:`CMAKE_CURRENT_FUNCTION`,
+:variable:`CMAKE_CURRENT_FUNCTION_LIST_DIR` and
+:variable:`CMAKE_CURRENT_FUNCTION_LIST_LINE`.
diff --git a/Help/variable/CMAKE_CURRENT_FUNCTION_LIST_LINE.rst b/Help/variable/CMAKE_CURRENT_FUNCTION_LIST_LINE.rst
index 5a7cd13..ad6282e 100644
--- a/Help/variable/CMAKE_CURRENT_FUNCTION_LIST_LINE.rst
+++ b/Help/variable/CMAKE_CURRENT_FUNCTION_LIST_LINE.rst
@@ -2,4 +2,9 @@ CMAKE_CURRENT_FUNCTION_LIST_LINE
--------------------------------
When executing code inside a :command:`function`, this variable
-contains the line number in the listfile where a current function has defined.
+contains the line number in the listfile where the current function
+was defined.
+
+See also :variable:`CMAKE_CURRENT_FUNCTION`,
+:variable:`CMAKE_CURRENT_FUNCTION_LIST_DIR` and
+:variable:`CMAKE_CURRENT_FUNCTION_LIST_FILE`.
diff --git a/Modules/CMakeASMCompiler.cmake.in b/Modules/CMakeASMCompiler.cmake.in
index 858c053..3953b30 100644
--- a/Modules/CMakeASMCompiler.cmake.in
+++ b/Modules/CMakeASMCompiler.cmake.in
@@ -12,6 +12,7 @@ set(CMAKE_ASM@ASM_DIALECT@_COMPILER_VERSION "@_CMAKE_ASM_COMPILER_VERSION@")
set(CMAKE_ASM@ASM_DIALECT@_COMPILER_ENV_VAR "@_CMAKE_ASM_COMPILER_ENV_VAR@")
@_SET_CMAKE_ASM_COMPILER_ID_VENDOR_MATCH@
@_SET_CMAKE_ASM_COMPILER_ARCHITECTURE_ID@
+@_SET_CMAKE_ASM_COMPILER_SYSROOT@
set(CMAKE_ASM@ASM_DIALECT@_IGNORE_EXTENSIONS h;H;o;O;obj;OBJ;def;DEF;rc;RC)
set(CMAKE_ASM@ASM_DIALECT@_LINKER_PREFERENCE 0)
diff --git a/Modules/CMakeCCompiler.cmake.in b/Modules/CMakeCCompiler.cmake.in
index 9b8d423..eea3f5d 100644
--- a/Modules/CMakeCCompiler.cmake.in
+++ b/Modules/CMakeCCompiler.cmake.in
@@ -15,6 +15,7 @@ set(CMAKE_C_SIMULATE_ID "@CMAKE_C_SIMULATE_ID@")
set(CMAKE_C_COMPILER_FRONTEND_VARIANT "@CMAKE_C_COMPILER_FRONTEND_VARIANT@")
set(CMAKE_C_SIMULATE_VERSION "@CMAKE_C_SIMULATE_VERSION@")
@_SET_CMAKE_C_COMPILER_ARCHITECTURE_ID@
+@_SET_CMAKE_C_COMPILER_SYSROOT@
@SET_MSVC_C_ARCHITECTURE_ID@
@SET_CMAKE_XCODE_ARCHS@
set(CMAKE_AR "@CMAKE_AR@")
diff --git a/Modules/CMakeCUDACompiler.cmake.in b/Modules/CMakeCUDACompiler.cmake.in
index 14a39a9..289e96e 100644
--- a/Modules/CMakeCUDACompiler.cmake.in
+++ b/Modules/CMakeCUDACompiler.cmake.in
@@ -16,6 +16,7 @@ set(CMAKE_CUDA_SIMULATE_ID "@CMAKE_CUDA_SIMULATE_ID@")
set(CMAKE_CUDA_COMPILER_FRONTEND_VARIANT "@CMAKE_CUDA_COMPILER_FRONTEND_VARIANT@")
set(CMAKE_CUDA_SIMULATE_VERSION "@CMAKE_CUDA_SIMULATE_VERSION@")
@SET_MSVC_CUDA_ARCHITECTURE_ID@
+@_SET_CMAKE_CUDA_COMPILER_SYSROOT@
set(CMAKE_CUDA_COMPILER_ENV_VAR "CUDACXX")
set(CMAKE_CUDA_HOST_COMPILER_ENV_VAR "CUDAHOSTCXX")
diff --git a/Modules/CMakeCUDAInformation.cmake b/Modules/CMakeCUDAInformation.cmake
index f7eb4a7..ab562c6 100644
--- a/Modules/CMakeCUDAInformation.cmake
+++ b/Modules/CMakeCUDAInformation.cmake
@@ -138,7 +138,7 @@ endif()
#Specify how to compile when ptx has been requested
if(NOT CMAKE_CUDA_COMPILE_PTX_COMPILATION)
set(CMAKE_CUDA_COMPILE_PTX_COMPILATION
- "<CMAKE_CUDA_COMPILER> ${_CMAKE_CUDA_EXTRA_FLAGS} <DEFINES> <INCLUDES> <FLAGS> ${_CMAKE_COMPILE_AS_CUDA_FLAG} -ptx <SOURCE> -o <OBJECT>")
+ "<CMAKE_CUDA_COMPILER> ${_CMAKE_CUDA_EXTRA_FLAGS} <DEFINES> <INCLUDES> <FLAGS> ${_CMAKE_COMPILE_AS_CUDA_FLAG} ${_CMAKE_CUDA_PTX_FLAG} <SOURCE> -o <OBJECT>")
endif()
#Specify how to compile when separable compilation has been requested
diff --git a/Modules/CMakeCXXCompiler.cmake.in b/Modules/CMakeCXXCompiler.cmake.in
index efb8abf..09bdc23 100644
--- a/Modules/CMakeCXXCompiler.cmake.in
+++ b/Modules/CMakeCXXCompiler.cmake.in
@@ -17,6 +17,7 @@ set(CMAKE_CXX_SIMULATE_ID "@CMAKE_CXX_SIMULATE_ID@")
set(CMAKE_CXX_COMPILER_FRONTEND_VARIANT "@CMAKE_CXX_COMPILER_FRONTEND_VARIANT@")
set(CMAKE_CXX_SIMULATE_VERSION "@CMAKE_CXX_SIMULATE_VERSION@")
@_SET_CMAKE_CXX_COMPILER_ARCHITECTURE_ID@
+@_SET_CMAKE_CXX_COMPILER_SYSROOT@
@SET_MSVC_CXX_ARCHITECTURE_ID@
@SET_CMAKE_XCODE_ARCHS@
set(CMAKE_AR "@CMAKE_AR@")
diff --git a/Modules/CMakeDetermineASMCompiler.cmake b/Modules/CMakeDetermineASMCompiler.cmake
index 86fb057..bc8b86b 100644
--- a/Modules/CMakeDetermineASMCompiler.cmake
+++ b/Modules/CMakeDetermineASMCompiler.cmake
@@ -134,6 +134,9 @@ if(NOT CMAKE_ASM${ASM_DIALECT}_COMPILER_ID)
list(GET _all_compileid_matches "-1" CMAKE_ASM${ASM_DIALECT}_COMPILER_ARCHITECTURE_ID)
endif()
endif()
+
+ _cmake_find_compiler_sysroot(ASM${ASM_DIALECT})
+
unset(CMAKE_ASM${ASM_DIALECT}_COMPILER_ID_OUTPUT)
unset(_all_compileid_matches)
unset(_compileid)
@@ -211,6 +214,14 @@ foreach(_var
set(_CMAKE_ASM_${_var} "${CMAKE_ASM${ASM_DIALECT}_${_var}}")
endforeach()
+if(CMAKE_ASM${ASM_DIALECT}_COMPILER_SYSROOT)
+ string(CONCAT _SET_CMAKE_ASM_COMPILER_SYSROOT
+ "set(CMAKE_ASM${ASM_DIALECT}_COMPILER_SYSROOT \"${CMAKE_ASM${ASM_DIALECT}_COMPILER_SYSROOT}\")\n"
+ "set(CMAKE_COMPILER_SYSROOT \"${CMAKE_ASM${ASM_DIALECT}_COMPILER_SYSROOT}\")")
+else()
+ set(_SET_CMAKE_ASM_COMPILER_SYSROOT "")
+endif()
+
if(CMAKE_ASM${ASM_DIALECT}_COMPILER_ID_VENDOR_MATCH)
set(_SET_CMAKE_ASM_COMPILER_ID_VENDOR_MATCH
"set(CMAKE_ASM${ASM_DIALECT}_COMPILER_ID_VENDOR_MATCH [==[${CMAKE_ASM${ASM_DIALECT}_COMPILER_ID_VENDOR_MATCH}]==])")
diff --git a/Modules/CMakeDetermineCCompiler.cmake b/Modules/CMakeDetermineCCompiler.cmake
index 9d395e5..f870956 100644
--- a/Modules/CMakeDetermineCCompiler.cmake
+++ b/Modules/CMakeDetermineCCompiler.cmake
@@ -115,6 +115,8 @@ if(NOT CMAKE_C_COMPILER_ID_RUN)
include(${CMAKE_ROOT}/Modules/CMakeDetermineCompilerId.cmake)
CMAKE_DETERMINE_COMPILER_ID(C CFLAGS CMakeCCompilerId.c)
+ _cmake_find_compiler_sysroot(C)
+
# Set old compiler and platform id variables.
if(CMAKE_C_COMPILER_ID STREQUAL "GNU")
set(CMAKE_COMPILER_IS_GNUCC 1)
@@ -191,6 +193,14 @@ include(CMakeFindBinUtils)
include(Compiler/${CMAKE_C_COMPILER_ID}-FindBinUtils OPTIONAL)
unset(_CMAKE_PROCESSING_LANGUAGE)
+if(CMAKE_C_COMPILER_SYSROOT)
+ string(CONCAT _SET_CMAKE_C_COMPILER_SYSROOT
+ "set(CMAKE_C_COMPILER_SYSROOT \"${CMAKE_C_COMPILER_SYSROOT}\")\n"
+ "set(CMAKE_COMPILER_SYSROOT \"${CMAKE_C_COMPILER_SYSROOT}\")")
+else()
+ set(_SET_CMAKE_C_COMPILER_SYSROOT "")
+endif()
+
if(CMAKE_C_COMPILER_ARCHITECTURE_ID)
set(_SET_CMAKE_C_COMPILER_ARCHITECTURE_ID
"set(CMAKE_C_COMPILER_ARCHITECTURE_ID ${CMAKE_C_COMPILER_ARCHITECTURE_ID})")
diff --git a/Modules/CMakeDetermineCUDACompiler.cmake b/Modules/CMakeDetermineCUDACompiler.cmake
index 95c3cc9..ead4125 100644
--- a/Modules/CMakeDetermineCUDACompiler.cmake
+++ b/Modules/CMakeDetermineCUDACompiler.cmake
@@ -70,6 +70,8 @@ if(NOT CMAKE_CUDA_COMPILER_ID_RUN)
include(${CMAKE_ROOT}/Modules/CMakeDetermineCompilerId.cmake)
CMAKE_DETERMINE_COMPILER_ID(CUDA CUDAFLAGS CMakeCUDACompilerId.cu)
+
+ _cmake_find_compiler_sysroot(CUDA)
endif()
set(_CMAKE_PROCESSING_LANGUAGE "CUDA")
@@ -189,6 +191,14 @@ elseif(CMAKE_CUDA_COMPILER_ID STREQUAL "NVIDIA")
endif()
endif()
+if(CMAKE_CUDA_COMPILER_SYSROOT)
+ string(CONCAT _SET_CMAKE_CUDA_COMPILER_SYSROOT
+ "set(CMAKE_CUDA_COMPILER_SYSROOT \"${CMAKE_CUDA_COMPILER_SYSROOT}\")\n"
+ "set(CMAKE_COMPILER_SYSROOT \"${CMAKE_CUDA_COMPILER_SYSROOT}\")")
+else()
+ set(_SET_CMAKE_CUDA_COMPILER_SYSROOT "")
+endif()
+
# Determine CMAKE_CUDA_TOOLKIT_INCLUDE_DIRECTORIES
if(CMAKE_CUDA_COMPILER_ID STREQUAL "NVIDIA")
set(CMAKE_CUDA_TOOLKIT_INCLUDE_DIRECTORIES)
@@ -216,6 +226,17 @@ if(CMAKE_CUDA_COMPILER_ID STREQUAL "NVIDIA")
file(APPEND ${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeOutput.log
"Failed to detect CUDA nvcc include information:\n${_nvcc_log}\n\n")
endif()
+
+ # Parse default CUDA architecture.
+ cmake_policy(GET CMP0104 _CUDA_CMP0104)
+ if(NOT CMAKE_CUDA_ARCHITECTURES AND _CUDA_CMP0104 STREQUAL "NEW")
+ string(REGEX MATCH "arch[ =]compute_([0-9]+)" dont_care "${CMAKE_CUDA_COMPILER_PRODUCED_OUTPUT}")
+ set(CMAKE_CUDA_ARCHITECTURES "${CMAKE_MATCH_1}" CACHE STRING "CUDA architectures")
+
+ if(NOT CMAKE_CUDA_ARCHITECTURES)
+ message(FATAL_ERROR "Failed to find default CUDA architecture.")
+ endif()
+ endif()
endif()
# configure all variables set in this file
diff --git a/Modules/CMakeDetermineCXXCompiler.cmake b/Modules/CMakeDetermineCXXCompiler.cmake
index ebac435..e6b46b8 100644
--- a/Modules/CMakeDetermineCXXCompiler.cmake
+++ b/Modules/CMakeDetermineCXXCompiler.cmake
@@ -110,6 +110,8 @@ if(NOT CMAKE_CXX_COMPILER_ID_RUN)
include(${CMAKE_ROOT}/Modules/CMakeDetermineCompilerId.cmake)
CMAKE_DETERMINE_COMPILER_ID(CXX CXXFLAGS CMakeCXXCompilerId.cpp)
+ _cmake_find_compiler_sysroot(CXX)
+
# Set old compiler and platform id variables.
if(CMAKE_CXX_COMPILER_ID STREQUAL "GNU")
set(CMAKE_COMPILER_IS_GNUCXX 1)
@@ -189,6 +191,14 @@ include(CMakeFindBinUtils)
include(Compiler/${CMAKE_CXX_COMPILER_ID}-FindBinUtils OPTIONAL)
unset(_CMAKE_PROCESSING_LANGUAGE)
+if(CMAKE_CXX_COMPILER_SYSROOT)
+ string(CONCAT _SET_CMAKE_CXX_COMPILER_SYSROOT
+ "set(CMAKE_CXX_COMPILER_SYSROOT \"${CMAKE_CXX_COMPILER_SYSROOT}\")\n"
+ "set(CMAKE_COMPILER_SYSROOT \"${CMAKE_CXX_COMPILER_SYSROOT}\")")
+else()
+ set(_SET_CMAKE_CXX_COMPILER_SYSROOT "")
+endif()
+
if(CMAKE_CXX_COMPILER_ARCHITECTURE_ID)
set(_SET_CMAKE_CXX_COMPILER_ARCHITECTURE_ID
"set(CMAKE_CXX_COMPILER_ARCHITECTURE_ID ${CMAKE_CXX_COMPILER_ARCHITECTURE_ID})")
diff --git a/Modules/CMakeDetermineCompiler.cmake b/Modules/CMakeDetermineCompiler.cmake
index c37adae..7afae8a 100644
--- a/Modules/CMakeDetermineCompiler.cmake
+++ b/Modules/CMakeDetermineCompiler.cmake
@@ -118,3 +118,18 @@ macro(_cmake_find_compiler_path lang)
endif()
endif()
endmacro()
+
+function(_cmake_find_compiler_sysroot lang)
+ if(CMAKE_${lang}_COMPILER_ID STREQUAL "GNU")
+ execute_process(COMMAND "${CMAKE_${lang}_COMPILER}" -print-sysroot
+ OUTPUT_STRIP_TRAILING_WHITESPACE
+ OUTPUT_VARIABLE _cmake_sysroot_run_out
+ ERROR_VARIABLE _cmake_sysroot_run_err)
+
+ if(_cmake_sysroot_run_out AND NOT _cmake_sysroot_run_err AND IS_DIRECTORY "${_cmake_sysroot_run_out}/usr")
+ set(CMAKE_${lang}_COMPILER_SYSROOT "${_cmake_sysroot_run_out}/usr" PARENT_SCOPE)
+ else()
+ set(CMAKE_${lang}_COMPILER_SYSROOT "" PARENT_SCOPE)
+ endif()
+ endif()
+endfunction()
diff --git a/Modules/CMakeDetermineFortranCompiler.cmake b/Modules/CMakeDetermineFortranCompiler.cmake
index 6731abe..5f5a70a 100644
--- a/Modules/CMakeDetermineFortranCompiler.cmake
+++ b/Modules/CMakeDetermineFortranCompiler.cmake
@@ -186,6 +186,8 @@ if(NOT CMAKE_Fortran_COMPILER_ID_RUN)
include(${CMAKE_ROOT}/Modules/CMakeDetermineCompilerId.cmake)
CMAKE_DETERMINE_COMPILER_ID(Fortran FFLAGS CMakeFortranCompilerId.F)
+ _cmake_find_compiler_sysroot(Fortran)
+
# Fall back to old is-GNU test.
if(NOT CMAKE_Fortran_COMPILER_ID)
execute_process(COMMAND ${CMAKE_Fortran_COMPILER} ${CMAKE_Fortran_COMPILER_ID_FLAGS_LIST} -E "${CMAKE_ROOT}/Modules/CMakeTestGNU.c"
@@ -276,6 +278,14 @@ if(CMAKE_Fortran_XL_CPP)
"set(CMAKE_Fortran_XL_CPP \"${CMAKE_Fortran_XL_CPP}\")")
endif()
+if(CMAKE_Fortran_COMPILER_SYSROOT)
+ string(CONCAT _SET_CMAKE_Fortran_COMPILER_SYSROOT
+ "set(CMAKE_Fortran_COMPILER_SYSROOT \"${CMAKE_Fortran_COMPILER_SYSROOT}\")\n"
+ "set(CMAKE_COMPILER_SYSROOT \"${CMAKE_Fortran_COMPILER_SYSROOT}\")")
+else()
+ set(_SET_CMAKE_Fortran_COMPILER_SYSROOT "")
+endif()
+
if(CMAKE_Fortran_COMPILER_ARCHITECTURE_ID)
set(_SET_CMAKE_Fortran_COMPILER_ARCHITECTURE_ID
"set(CMAKE_Fortran_COMPILER_ARCHITECTURE_ID ${CMAKE_Fortran_COMPILER_ARCHITECTURE_ID})")
diff --git a/Modules/CMakeFortranCompiler.cmake.in b/Modules/CMakeFortranCompiler.cmake.in
index 34f44aa..06ee528 100644
--- a/Modules/CMakeFortranCompiler.cmake.in
+++ b/Modules/CMakeFortranCompiler.cmake.in
@@ -8,6 +8,7 @@ set(CMAKE_Fortran_SIMULATE_ID "@CMAKE_Fortran_SIMULATE_ID@")
set(CMAKE_Fortran_SIMULATE_VERSION "@CMAKE_Fortran_SIMULATE_VERSION@")
@_SET_CMAKE_Fortran_XL_CPP@
@_SET_CMAKE_Fortran_COMPILER_ARCHITECTURE_ID@
+@_SET_CMAKE_Fortran_COMPILER_SYSROOT@
@SET_MSVC_Fortran_ARCHITECTURE_ID@
set(CMAKE_AR "@CMAKE_AR@")
set(CMAKE_Fortran_COMPILER_AR "@CMAKE_Fortran_COMPILER_AR@")
diff --git a/Modules/CMakePrintSystemInformation.cmake b/Modules/CMakePrintSystemInformation.cmake
index 8d5cf5c..d44e933 100644
--- a/Modules/CMakePrintSystemInformation.cmake
+++ b/Modules/CMakePrintSystemInformation.cmake
@@ -11,7 +11,7 @@ This module serves diagnostic purposes. Just include it in a
project to see various internal CMake variables.
#]=======================================================================]
-message("CMAKE_SYSTEM is ${CMAKE_SYSTEM} ${CMAKE_SYSTEM_NAME} ${CMAKE_SYSTEM_VERSION}")
+message("CMAKE_SYSTEM is ${CMAKE_SYSTEM} ${CMAKE_SYSTEM_NAME} ${CMAKE_SYSTEM_VERSION} ${CMAKE_SYSTEM_PROCESSOR}")
message("CMAKE_SYSTEM file is ${CMAKE_SYSTEM_INFO_FILE}")
message("CMAKE_C_COMPILER is ${CMAKE_C_COMPILER}")
message("CMAKE_CXX_COMPILER is ${CMAKE_CXX_COMPILER}")
diff --git a/Modules/Compiler/Clang-CXX.cmake b/Modules/Compiler/Clang-CXX.cmake
index cb240f9..789e991 100644
--- a/Modules/Compiler/Clang-CXX.cmake
+++ b/Modules/Compiler/Clang-CXX.cmake
@@ -1,5 +1,6 @@
include(Compiler/Clang)
__compiler_clang(CXX)
+__compiler_clang_cxx_standards(CXX)
if("x${CMAKE_CXX_COMPILER_FRONTEND_VARIANT}" STREQUAL "xGNU")
set(CMAKE_CXX_COMPILE_OPTIONS_VISIBILITY_INLINES_HIDDEN "-fvisibility-inlines-hidden")
@@ -13,121 +14,3 @@ endif()
if("x${CMAKE_CXX_COMPILER_FRONTEND_VARIANT}" STREQUAL "xMSVC")
set(CMAKE_CXX_CLANG_TIDY_DRIVER_MODE "cl")
endif()
-
-if("x${CMAKE_CXX_COMPILER_FRONTEND_VARIANT}" STREQUAL "xGNU")
- if(NOT CMAKE_CXX_COMPILER_VERSION VERSION_LESS 2.1)
- set(CMAKE_CXX98_STANDARD_COMPILE_OPTION "-std=c++98")
- set(CMAKE_CXX98_EXTENSION_COMPILE_OPTION "-std=gnu++98")
- endif()
-
- if(NOT CMAKE_CXX_COMPILER_VERSION VERSION_LESS 3.1)
- set(CMAKE_CXX98_STANDARD__HAS_FULL_SUPPORT ON)
- set(CMAKE_CXX11_STANDARD_COMPILE_OPTION "-std=c++11")
- set(CMAKE_CXX11_EXTENSION_COMPILE_OPTION "-std=gnu++11")
- set(CMAKE_CXX11_STANDARD__HAS_FULL_SUPPORT ON)
- elseif(NOT CMAKE_CXX_COMPILER_VERSION VERSION_LESS 2.1)
- set(CMAKE_CXX11_STANDARD_COMPILE_OPTION "-std=c++0x")
- set(CMAKE_CXX11_EXTENSION_COMPILE_OPTION "-std=gnu++0x")
- endif()
-
- if(NOT CMAKE_CXX_COMPILER_VERSION VERSION_LESS 3.5)
- set(CMAKE_CXX14_STANDARD_COMPILE_OPTION "-std=c++14")
- set(CMAKE_CXX14_EXTENSION_COMPILE_OPTION "-std=gnu++14")
- set(CMAKE_CXX14_STANDARD__HAS_FULL_SUPPORT ON)
- elseif(NOT CMAKE_CXX_COMPILER_VERSION VERSION_LESS 3.4)
- set(CMAKE_CXX14_STANDARD_COMPILE_OPTION "-std=c++1y")
- set(CMAKE_CXX14_EXTENSION_COMPILE_OPTION "-std=gnu++1y")
- set(CMAKE_CXX14_STANDARD__HAS_FULL_SUPPORT ON)
- endif()
-
- set(_clang_version_std17 5.0)
- if(CMAKE_SYSTEM_NAME STREQUAL "Android")
- set(_clang_version_std17 6.0)
- endif()
-
- if (NOT CMAKE_CXX_COMPILER_VERSION VERSION_LESS "${_clang_version_std17}")
- set(CMAKE_CXX17_STANDARD_COMPILE_OPTION "-std=c++17")
- set(CMAKE_CXX17_EXTENSION_COMPILE_OPTION "-std=gnu++17")
- elseif (NOT CMAKE_CXX_COMPILER_VERSION VERSION_LESS 3.5)
- set(CMAKE_CXX17_STANDARD_COMPILE_OPTION "-std=c++1z")
- set(CMAKE_CXX17_EXTENSION_COMPILE_OPTION "-std=gnu++1z")
- endif()
-
- if (NOT CMAKE_CXX_COMPILER_VERSION VERSION_LESS "${_clang_version_std17}")
- set(CMAKE_CXX20_STANDARD_COMPILE_OPTION "-std=c++2a")
- set(CMAKE_CXX20_EXTENSION_COMPILE_OPTION "-std=gnu++2a")
- endif()
-
- unset(_clang_version_std17)
-
- if("x${CMAKE_CXX_SIMULATE_ID}" STREQUAL "xMSVC")
- # The MSVC standard library requires C++14, and MSVC itself has no
- # notion of operating in a mode not aware of at least that standard.
- set(CMAKE_CXX98_STANDARD_COMPILE_OPTION "-std=c++14")
- set(CMAKE_CXX98_EXTENSION_COMPILE_OPTION "-std=gnu++14")
- set(CMAKE_CXX11_STANDARD_COMPILE_OPTION "-std=c++14")
- set(CMAKE_CXX11_EXTENSION_COMPILE_OPTION "-std=gnu++14")
-
- # This clang++ is missing some features because of MSVC compatibility.
- unset(CMAKE_CXX11_STANDARD__HAS_FULL_SUPPORT)
- unset(CMAKE_CXX14_STANDARD__HAS_FULL_SUPPORT)
- unset(CMAKE_CXX17_STANDARD__HAS_FULL_SUPPORT)
- unset(CMAKE_CXX20_STANDARD__HAS_FULL_SUPPORT)
- endif()
-
- __compiler_check_default_language_standard(CXX 2.1 98)
-elseif(CMAKE_CXX_COMPILER_VERSION VERSION_GREATER_EQUAL 3.9
- AND CMAKE_CXX_SIMULATE_VERSION VERSION_GREATER_EQUAL 19.0)
- # This version of clang-cl and the MSVC version it simulates have
- # support for -std: flags.
- set(CMAKE_CXX98_STANDARD_COMPILE_OPTION "")
- set(CMAKE_CXX98_EXTENSION_COMPILE_OPTION "")
- set(CMAKE_CXX98_STANDARD__HAS_FULL_SUPPORT ON)
- set(CMAKE_CXX11_STANDARD_COMPILE_OPTION "")
- set(CMAKE_CXX11_EXTENSION_COMPILE_OPTION "")
- set(CMAKE_CXX14_STANDARD_COMPILE_OPTION "-std:c++14")
- set(CMAKE_CXX14_EXTENSION_COMPILE_OPTION "-std:c++14")
- if (CMAKE_CXX_COMPILER_VERSION VERSION_GREATER_EQUAL 6.0)
- set(CMAKE_CXX17_STANDARD_COMPILE_OPTION "-std:c++17")
- set(CMAKE_CXX17_EXTENSION_COMPILE_OPTION "-std:c++17")
- set(CMAKE_CXX20_STANDARD_COMPILE_OPTION "-std:c++latest")
- set(CMAKE_CXX20_EXTENSION_COMPILE_OPTION "-std:c++latest")
- else()
- set(CMAKE_CXX17_STANDARD_COMPILE_OPTION "-std:c++latest")
- set(CMAKE_CXX17_EXTENSION_COMPILE_OPTION "-std:c++latest")
- endif()
-
- __compiler_check_default_language_standard(CXX 3.9 14)
-else()
- # This version of clang-cl, or the MSVC version it simulates, does not have
- # language standards. Set these options as empty strings so the feature
- # test infrastructure can at least check to see if they are defined.
- set(CMAKE_CXX98_STANDARD_COMPILE_OPTION "")
- set(CMAKE_CXX98_EXTENSION_COMPILE_OPTION "")
- set(CMAKE_CXX11_STANDARD_COMPILE_OPTION "")
- set(CMAKE_CXX11_EXTENSION_COMPILE_OPTION "")
- set(CMAKE_CXX14_STANDARD_COMPILE_OPTION "")
- set(CMAKE_CXX14_EXTENSION_COMPILE_OPTION "")
- set(CMAKE_CXX17_STANDARD_COMPILE_OPTION "")
- set(CMAKE_CXX17_EXTENSION_COMPILE_OPTION "")
- set(CMAKE_CXX20_STANDARD_COMPILE_OPTION "")
- set(CMAKE_CXX20_EXTENSION_COMPILE_OPTION "")
-
- # There is no meaningful default for this
- set(CMAKE_CXX_STANDARD_DEFAULT "")
-
- # There are no compiler modes so we only need to test features once.
- # Override the default macro for this special case. Pretend that
- # all language standards are available so that at least compilation
- # can be attempted.
- macro(cmake_record_cxx_compile_features)
- list(APPEND CMAKE_CXX_COMPILE_FEATURES
- cxx_std_98
- cxx_std_11
- cxx_std_14
- cxx_std_17
- cxx_std_20
- )
- _record_compiler_features(CXX "" CMAKE_CXX_COMPILE_FEATURES)
- endmacro()
-endif()
diff --git a/Modules/Compiler/Clang-OBJCXX.cmake b/Modules/Compiler/Clang-OBJCXX.cmake
index b01ce64..453b5fd 100644
--- a/Modules/Compiler/Clang-OBJCXX.cmake
+++ b/Modules/Compiler/Clang-OBJCXX.cmake
@@ -1,70 +1,3 @@
include(Compiler/Clang)
__compiler_clang(OBJCXX)
-
-if("x${CMAKE_OBJCXX_COMPILER_FRONTEND_VARIANT}" STREQUAL "xGNU")
- if(NOT CMAKE_OBJCXX_COMPILER_VERSION VERSION_LESS 2.1)
- set(CMAKE_OBJCXX98_STANDARD_COMPILE_OPTION "-std=c++98")
- set(CMAKE_OBJCXX98_EXTENSION_COMPILE_OPTION "-std=gnu++98")
- endif()
-
- if(NOT CMAKE_OBJCXX_COMPILER_VERSION VERSION_LESS 3.1)
- set(CMAKE_OBJCXX98_STANDARD__HAS_FULL_SUPPORT ON)
- set(CMAKE_OBJCXX11_STANDARD_COMPILE_OPTION "-std=c++11")
- set(CMAKE_OBJCXX11_EXTENSION_COMPILE_OPTION "-std=gnu++11")
- set(CMAKE_OBJCXX11_STANDARD__HAS_FULL_SUPPORT ON)
- elseif(NOT CMAKE_OBJCXX_COMPILER_VERSION VERSION_LESS 2.1)
- set(CMAKE_OBJCXX11_STANDARD_COMPILE_OPTION "-std=c++0x")
- set(CMAKE_OBJCXX11_EXTENSION_COMPILE_OPTION "-std=gnu++0x")
- endif()
-
- if(NOT CMAKE_OBJCXX_COMPILER_VERSION VERSION_LESS 3.5)
- set(CMAKE_OBJCXX14_STANDARD_COMPILE_OPTION "-std=c++14")
- set(CMAKE_OBJCXX14_EXTENSION_COMPILE_OPTION "-std=gnu++14")
- set(CMAKE_OBJCXX14_STANDARD__HAS_FULL_SUPPORT ON)
- elseif(NOT CMAKE_OBJCXX_COMPILER_VERSION VERSION_LESS 3.4)
- set(CMAKE_OBJCXX14_STANDARD_COMPILE_OPTION "-std=c++1y")
- set(CMAKE_OBJCXX14_EXTENSION_COMPILE_OPTION "-std=gnu++1y")
- set(CMAKE_OBJCXX14_STANDARD__HAS_FULL_SUPPORT ON)
- endif()
-
- set(_clang_version_std17 5.0)
-
- if (NOT CMAKE_OBJCXX_COMPILER_VERSION VERSION_LESS "${_clang_version_std17}")
- set(CMAKE_OBJCXX17_STANDARD_COMPILE_OPTION "-std=c++17")
- set(CMAKE_OBJCXX17_EXTENSION_COMPILE_OPTION "-std=gnu++17")
- elseif (NOT CMAKE_OBJCXX_COMPILER_VERSION VERSION_LESS 3.5)
- set(CMAKE_OBJCXX17_STANDARD_COMPILE_OPTION "-std=c++1z")
- set(CMAKE_OBJCXX17_EXTENSION_COMPILE_OPTION "-std=gnu++1z")
- endif()
-
- if (NOT CMAKE_OBJCXX_COMPILER_VERSION VERSION_LESS "${_clang_version_std17}")
- set(CMAKE_OBJCXX20_STANDARD_COMPILE_OPTION "-std=c++2a")
- set(CMAKE_OBJCXX20_EXTENSION_COMPILE_OPTION "-std=gnu++2a")
- endif()
-
- unset(_clang_version_std17)
-
- __compiler_check_default_language_standard(OBJCXX 2.1 98)
-elseif(CMAKE_OBJCXX_COMPILER_VERSION VERSION_GREATER_EQUAL 3.9
- AND CMAKE_OBJCXX_SIMULATE_VERSION VERSION_GREATER_EQUAL 19.0)
- # This version of clang-cl and the MSVC version it simulates have
- # support for -std: flags.
- set(CMAKE_OBJCXX98_STANDARD_COMPILE_OPTION "")
- set(CMAKE_OBJCXX98_EXTENSION_COMPILE_OPTION "")
- set(CMAKE_OBJCXX98_STANDARD__HAS_FULL_SUPPORT ON)
- set(CMAKE_OBJCXX11_STANDARD_COMPILE_OPTION "")
- set(CMAKE_OBJCXX11_EXTENSION_COMPILE_OPTION "")
- set(CMAKE_OBJCXX14_STANDARD_COMPILE_OPTION "-std:c++14")
- set(CMAKE_OBJCXX14_EXTENSION_COMPILE_OPTION "-std:c++14")
- if (CMAKE_OBJCXX_COMPILER_VERSION VERSION_GREATER_EQUAL 6.0)
- set(CMAKE_OBJCXX17_STANDARD_COMPILE_OPTION "-std:c++17")
- set(CMAKE_OBJCXX17_EXTENSION_COMPILE_OPTION "-std:c++17")
- set(CMAKE_OBJCXX20_STANDARD_COMPILE_OPTION "-std:c++latest")
- set(CMAKE_OBJCXX20_EXTENSION_COMPILE_OPTION "-std:c++latest")
- else()
- set(CMAKE_OBJCXX17_STANDARD_COMPILE_OPTION "-std:c++latest")
- set(CMAKE_OBJCXX17_EXTENSION_COMPILE_OPTION "-std:c++latest")
- endif()
-
- __compiler_check_default_language_standard(OBJCXX 3.9 14)
-endif()
+__compiler_clang_cxx_standards(OBJCXX)
diff --git a/Modules/Compiler/Clang.cmake b/Modules/Compiler/Clang.cmake
index f65916f..cd47aa6 100644
--- a/Modules/Compiler/Clang.cmake
+++ b/Modules/Compiler/Clang.cmake
@@ -105,3 +105,123 @@ else()
set(CMAKE_${lang}_COMPILE_OPTIONS_CREATE_PCH -Xclang -emit-pch -Xclang -include -Xclang <PCH_HEADER>)
endmacro()
endif()
+
+macro(__compiler_clang_cxx_standards lang)
+ if("x${CMAKE_${lang}_COMPILER_FRONTEND_VARIANT}" STREQUAL "xGNU")
+ if(NOT CMAKE_${lang}_COMPILER_VERSION VERSION_LESS 2.1)
+ set(CMAKE_${lang}98_STANDARD_COMPILE_OPTION "-std=c++98")
+ set(CMAKE_${lang}98_EXTENSION_COMPILE_OPTION "-std=gnu++98")
+ endif()
+
+ if(NOT CMAKE_${lang}_COMPILER_VERSION VERSION_LESS 3.1)
+ set(CMAKE_${lang}98_STANDARD__HAS_FULL_SUPPORT ON)
+ set(CMAKE_${lang}11_STANDARD_COMPILE_OPTION "-std=c++11")
+ set(CMAKE_${lang}11_EXTENSION_COMPILE_OPTION "-std=gnu++11")
+ set(CMAKE_${lang}11_STANDARD__HAS_FULL_SUPPORT ON)
+ elseif(NOT CMAKE_${lang}_COMPILER_VERSION VERSION_LESS 2.1)
+ set(CMAKE_${lang}11_STANDARD_COMPILE_OPTION "-std=c++0x")
+ set(CMAKE_${lang}11_EXTENSION_COMPILE_OPTION "-std=gnu++0x")
+ endif()
+
+ if(NOT CMAKE_${lang}_COMPILER_VERSION VERSION_LESS 3.5)
+ set(CMAKE_${lang}14_STANDARD_COMPILE_OPTION "-std=c++14")
+ set(CMAKE_${lang}14_EXTENSION_COMPILE_OPTION "-std=gnu++14")
+ set(CMAKE_${lang}14_STANDARD__HAS_FULL_SUPPORT ON)
+ elseif(NOT CMAKE_${lang}_COMPILER_VERSION VERSION_LESS 3.4)
+ set(CMAKE_${lang}14_STANDARD_COMPILE_OPTION "-std=c++1y")
+ set(CMAKE_${lang}14_EXTENSION_COMPILE_OPTION "-std=gnu++1y")
+ set(CMAKE_${lang}14_STANDARD__HAS_FULL_SUPPORT ON)
+ endif()
+
+ set(_clang_version_std17 5.0)
+ if(CMAKE_SYSTEM_NAME STREQUAL "Android")
+ set(_clang_version_std17 6.0)
+ endif()
+
+ if (NOT CMAKE_${lang}_COMPILER_VERSION VERSION_LESS "${_clang_version_std17}")
+ set(CMAKE_${lang}17_STANDARD_COMPILE_OPTION "-std=c++17")
+ set(CMAKE_${lang}17_EXTENSION_COMPILE_OPTION "-std=gnu++17")
+ elseif (NOT CMAKE_${lang}_COMPILER_VERSION VERSION_LESS 3.5)
+ set(CMAKE_${lang}17_STANDARD_COMPILE_OPTION "-std=c++1z")
+ set(CMAKE_${lang}17_EXTENSION_COMPILE_OPTION "-std=gnu++1z")
+ endif()
+
+ if (NOT CMAKE_${lang}_COMPILER_VERSION VERSION_LESS "${_clang_version_std17}")
+ set(CMAKE_${lang}20_STANDARD_COMPILE_OPTION "-std=c++2a")
+ set(CMAKE_${lang}20_EXTENSION_COMPILE_OPTION "-std=gnu++2a")
+ endif()
+
+ unset(_clang_version_std17)
+
+ if("x${CMAKE_${lang}_SIMULATE_ID}" STREQUAL "xMSVC")
+ # The MSVC standard library requires C++14, and MSVC itself has no
+ # notion of operating in a mode not aware of at least that standard.
+ set(CMAKE_${lang}98_STANDARD_COMPILE_OPTION "-std=c++14")
+ set(CMAKE_${lang}98_EXTENSION_COMPILE_OPTION "-std=gnu++14")
+ set(CMAKE_${lang}11_STANDARD_COMPILE_OPTION "-std=c++14")
+ set(CMAKE_${lang}11_EXTENSION_COMPILE_OPTION "-std=gnu++14")
+
+ # This clang++ is missing some features because of MSVC compatibility.
+ unset(CMAKE_${lang}11_STANDARD__HAS_FULL_SUPPORT)
+ unset(CMAKE_${lang}14_STANDARD__HAS_FULL_SUPPORT)
+ unset(CMAKE_${lang}17_STANDARD__HAS_FULL_SUPPORT)
+ unset(CMAKE_${lang}20_STANDARD__HAS_FULL_SUPPORT)
+ endif()
+
+ __compiler_check_default_language_standard(${lang} 2.1 98)
+ elseif(CMAKE_${lang}_COMPILER_VERSION VERSION_GREATER_EQUAL 3.9
+ AND CMAKE_${lang}_SIMULATE_VERSION VERSION_GREATER_EQUAL 19.0)
+ # This version of clang-cl and the MSVC version it simulates have
+ # support for -std: flags.
+ set(CMAKE_${lang}98_STANDARD_COMPILE_OPTION "")
+ set(CMAKE_${lang}98_EXTENSION_COMPILE_OPTION "")
+ set(CMAKE_${lang}98_STANDARD__HAS_FULL_SUPPORT ON)
+ set(CMAKE_${lang}11_STANDARD_COMPILE_OPTION "")
+ set(CMAKE_${lang}11_EXTENSION_COMPILE_OPTION "")
+ set(CMAKE_${lang}14_STANDARD_COMPILE_OPTION "-std:c++14")
+ set(CMAKE_${lang}14_EXTENSION_COMPILE_OPTION "-std:c++14")
+ if (CMAKE_${lang}_COMPILER_VERSION VERSION_GREATER_EQUAL 6.0)
+ set(CMAKE_${lang}17_STANDARD_COMPILE_OPTION "-std:c++17")
+ set(CMAKE_${lang}17_EXTENSION_COMPILE_OPTION "-std:c++17")
+ set(CMAKE_${lang}20_STANDARD_COMPILE_OPTION "-std:c++latest")
+ set(CMAKE_${lang}20_EXTENSION_COMPILE_OPTION "-std:c++latest")
+ else()
+ set(CMAKE_${lang}17_STANDARD_COMPILE_OPTION "-std:c++latest")
+ set(CMAKE_${lang}17_EXTENSION_COMPILE_OPTION "-std:c++latest")
+ endif()
+
+ __compiler_check_default_language_standard(${lang} 3.9 14)
+ else()
+ # This version of clang-cl, or the MSVC version it simulates, does not have
+ # language standards. Set these options as empty strings so the feature
+ # test infrastructure can at least check to see if they are defined.
+ set(CMAKE_${lang}98_STANDARD_COMPILE_OPTION "")
+ set(CMAKE_${lang}98_EXTENSION_COMPILE_OPTION "")
+ set(CMAKE_${lang}11_STANDARD_COMPILE_OPTION "")
+ set(CMAKE_${lang}11_EXTENSION_COMPILE_OPTION "")
+ set(CMAKE_${lang}14_STANDARD_COMPILE_OPTION "")
+ set(CMAKE_${lang}14_EXTENSION_COMPILE_OPTION "")
+ set(CMAKE_${lang}17_STANDARD_COMPILE_OPTION "")
+ set(CMAKE_${lang}17_EXTENSION_COMPILE_OPTION "")
+ set(CMAKE_${lang}20_STANDARD_COMPILE_OPTION "")
+ set(CMAKE_${lang}20_EXTENSION_COMPILE_OPTION "")
+
+ # There is no meaningful default for this
+ set(CMAKE_${lang}_STANDARD_DEFAULT "")
+
+ # There are no compiler modes so we only need to test features once.
+ # Override the default macro for this special case. Pretend that
+ # all language standards are available so that at least compilation
+ # can be attempted.
+ macro(cmake_record_${lang}_compile_features)
+ list(APPEND CMAKE_${lang}_COMPILE_FEATURES
+ ${lang}_std_98
+ ${lang}_std_11
+ ${lang}_std_14
+ ${lang}_std_17
+ ${lang}_std_20
+ )
+ _record_compiler_features(${lang} "" CMAKE_${lang}_COMPILE_FEATURES)
+ endmacro()
+ endif()
+endmacro()
diff --git a/Modules/Compiler/GNU.cmake b/Modules/Compiler/GNU.cmake
index 3357a86..df6d6b8 100644
--- a/Modules/Compiler/GNU.cmake
+++ b/Modules/Compiler/GNU.cmake
@@ -44,7 +44,8 @@ macro(__compiler_gnu lang)
# tests to always succeed. Work around this by disabling dependency tracking
# in try_compile mode.
get_property(_IN_TC GLOBAL PROPERTY IN_TRY_COMPILE)
- if(NOT _IN_TC OR CMAKE_FORCE_DEPFILES)
+ if(CMAKE_${lang}_COMPILER_ID STREQUAL "GNU" AND _IN_TC AND NOT CMAKE_FORCE_DEPFILES)
+ else()
# distcc does not transform -o to -MT when invoking the preprocessor
# internally, as it ought to. Work around this bug by setting -MT here
# even though it isn't strictly necessary.
diff --git a/Modules/Compiler/NVIDIA-CUDA.cmake b/Modules/Compiler/NVIDIA-CUDA.cmake
index 2a2564e..e24738d 100644
--- a/Modules/Compiler/NVIDIA-CUDA.cmake
+++ b/Modules/Compiler/NVIDIA-CUDA.cmake
@@ -5,6 +5,7 @@ set(CMAKE_CUDA_VERBOSE_FLAG "-v")
set(CMAKE_CUDA_VERBOSE_COMPILE_FLAG "-Xcompiler=-v")
set(_CMAKE_COMPILE_AS_CUDA_FLAG "-x cu")
+set(_CMAKE_CUDA_PTX_FLAG "-ptx")
if (CMAKE_CUDA_COMPILER_VERSION VERSION_GREATER_EQUAL 10.2.89)
# The -forward-unknown-to-host-compiler flag was only
diff --git a/Modules/FindBLAS.cmake b/Modules/FindBLAS.cmake
index 9b6d09c..caed7ef 100644
--- a/Modules/FindBLAS.cmake
+++ b/Modules/FindBLAS.cmake
@@ -48,6 +48,10 @@ The following variables may be set to influence this module's behavior:
* ``ACML_GPU``
* ``Apple``
* ``NAS``
+ * ``Arm``
+ * ``Arm_mp``
+ * ``Arm_ilp64``
+ * ``Arm_ilp64_mp``
* ``Generic``
``BLA_F95``
@@ -550,6 +554,36 @@ if(BLA_VENDOR STREQUAL "OpenBLAS" OR BLA_VENDOR STREQUAL "All")
endif()
endif()
+# ArmPL blas library? (https://developer.arm.com/tools-and-software/server-and-hpc/compile/arm-compiler-for-linux/arm-performance-libraries)
+if(BLA_VENDOR MATCHES "Arm" OR BLA_VENDOR STREQUAL "All")
+
+ # Check for 64bit Integer support
+ if(BLA_VENDOR MATCHES "_ilp64")
+ set(BLAS_armpl_LIB "armpl_ilp64")
+ else()
+ set(BLAS_armpl_LIB "armpl_lp64")
+ endif()
+
+ # Check for OpenMP support, VIA BLA_VENDOR of Arm_mp or Arm_ipl64_mp
+ if(BLA_VENDOR MATCHES "_mp")
+ set(BLAS_armpl_LIB "${BLAS_armpl_LIB}_mp")
+ endif()
+
+ if(NOT BLAS_LIBRARIES)
+ check_blas_libraries(
+ BLAS_LIBRARIES
+ BLAS
+ sgemm
+ ""
+ "${BLAS_armpl_LIB}"
+ ""
+ ""
+ ""
+ )
+ endif()
+
+endif()
+
# FLAME's blis library? (https://github.com/flame/blis)
if(BLA_VENDOR STREQUAL "FLAME" OR BLA_VENDOR STREQUAL "All")
if(NOT BLAS_LIBRARIES)
diff --git a/Modules/FindCUDAToolkit.cmake b/Modules/FindCUDAToolkit.cmake
index 4b14ddc..8d20ff9 100644
--- a/Modules/FindCUDAToolkit.cmake
+++ b/Modules/FindCUDAToolkit.cmake
@@ -473,9 +473,9 @@ Result variables
#
###############################################################################
-if(CMAKE_CUDA_COMPILER_LOADED AND NOT CUDAToolkit_BIN_DIR)
+# For NVCC we can easily deduce the SDK binary directory from the compiler path.
+if(CMAKE_CUDA_COMPILER_LOADED AND NOT CUDAToolkit_BIN_DIR AND CMAKE_CUDA_COMPILER_ID STREQUAL "NVIDIA")
get_filename_component(cuda_dir "${CMAKE_CUDA_COMPILER}" DIRECTORY)
- # use the already detected cuda compiler
set(CUDAToolkit_BIN_DIR "${cuda_dir}" CACHE PATH "")
mark_as_advanced(CUDAToolkit_BIN_DIR)
unset(cuda_dir)
@@ -711,8 +711,15 @@ find_path(CUDAToolkit_INCLUDE_DIR
# And find the CUDA Runtime Library libcudart
find_library(CUDA_CUDART
NAMES cudart
- PATH_SUFFIXES lib64 lib64/stubs lib/x64
+ PATH_SUFFIXES lib64 lib/x64
)
+if (NOT CUDA_CUDART)
+ find_library(CUDA_CUDART
+ NAMES cudart
+ PATH_SUFFIXES lib64/stubs lib/x64/stubs
+ )
+endif()
+
if (NOT CUDA_CUDART AND NOT CUDAToolkit_FIND_QUIETLY)
message(STATUS "Unable to find cudart library.")
endif()
@@ -759,9 +766,20 @@ if(CUDAToolkit_FOUND)
NAMES ${search_names}
HINTS ${CUDAToolkit_LIBRARY_DIR}
ENV CUDA_PATH
- PATH_SUFFIXES nvidia/current lib64 lib64/stubs lib/x64 lib lib/stubs
+ PATH_SUFFIXES nvidia/current lib64 lib/x64 lib
${arg_EXTRA_PATH_SUFFIXES}
)
+ # Don't try any stub directories intil we have exhausted all other
+ # search locations.
+ if(NOT CUDA_${lib_name}_LIBRARY)
+ find_library(CUDA_${lib_name}_LIBRARY
+ NAMES ${search_names}
+ HINTS ${CUDAToolkit_LIBRARY_DIR}
+ ENV CUDA_PATH
+ PATH_SUFFIXES lib64/stubs lib/x64/stubs lib/stubs stubs
+ )
+ endif()
+
mark_as_advanced(CUDA_${lib_name}_LIBRARY)
if (NOT TARGET CUDA::${lib_name} AND CUDA_${lib_name}_LIBRARY)
diff --git a/Modules/FindLAPACK.cmake b/Modules/FindLAPACK.cmake
index c962976..e5bd58d 100644
--- a/Modules/FindLAPACK.cmake
+++ b/Modules/FindLAPACK.cmake
@@ -38,6 +38,10 @@ The following variables may be set to influence this module's behavior:
* ``ACML``
* ``Apple``
* ``NAS``
+ * ``Arm``
+ * ``Arm_mp``
+ * ``Arm_ilp64``
+ * ``Arm_ilp64_mp``
* ``Generic``
``BLA_F95``
@@ -359,6 +363,36 @@ if(BLAS_FOUND)
endif()
endif()
+ # ArmPL? (https://developer.arm.com/tools-and-software/server-and-hpc/compile/arm-compiler-for-linux/arm-performance-libraries)
+ if(BLA_VENDOR MATCHES "Arm" OR BLA_VENDOR STREQUAL "All")
+
+ # Check for 64bit Integer support
+ if(BLA_VENDOR MATCHES "_ilp64")
+ set(LAPACK_armpl_LIB "armpl_ilp64")
+ else()
+ set(LAPACK_armpl_LIB "armpl_lp64")
+ endif()
+
+ # Check for OpenMP support, VIA BLA_VENDOR of Arm_mp or Arm_ipl64_mp
+ if(BLA_VENDOR MATCHES "_mp")
+ set(LAPACK_armpl_LIB "${LAPACK_armpl_LIB}_mp")
+ endif()
+
+ if(NOT LAPACK_LIBRARIES)
+ check_lapack_libraries(
+ LAPACK_LIBRARIES
+ LAPACK
+ cheev
+ ""
+ "${LAPACK_armpl_LIB}"
+ ""
+ ""
+ ""
+ "${BLAS_LIBRARIES}"
+ )
+ endif()
+ endif()
+
# FLAME's blis library? (https://github.com/flame/blis)
if(BLA_VENDOR STREQUAL "FLAME" OR BLA_VENDOR STREQUAL "All")
if(NOT LAPACK_LIBRARIES)
diff --git a/Modules/FindMPI.cmake b/Modules/FindMPI.cmake
index 41e1d08..cdbb927 100644
--- a/Modules/FindMPI.cmake
+++ b/Modules/FindMPI.cmake
@@ -298,9 +298,9 @@ else()
endif()
# PGI compiler names
-set(_MPI_PGI_C_COMPILER_NAMES mpipgcc mppgcc)
-set(_MPI_PGI_CXX_COMPILER_NAMES mpipgCC mppgCC)
-set(_MPI_PGI_Fortran_COMPILER_NAMES mpipgf95 mpipgf90 mppgf95 mppgf90 mpipgf77 mppgf77)
+set(_MPI_PGI_C_COMPILER_NAMES mpipgicc mpipgcc mppgcc)
+set(_MPI_PGI_CXX_COMPILER_NAMES mpipgic++ mpipgCC mppgCC)
+set(_MPI_PGI_Fortran_COMPILER_NAMES mpipgifort mpipgf95 mpipgf90 mppgf95 mppgf90 mpipgf77 mppgf77)
# XLC MPI Compiler names
set(_MPI_XL_C_COMPILER_NAMES mpxlc mpxlc_r mpixlc mpixlc_r)
diff --git a/Modules/FindOpenAL.cmake b/Modules/FindOpenAL.cmake
index c9c0903..b5b92c5 100644
--- a/Modules/FindOpenAL.cmake
+++ b/Modules/FindOpenAL.cmake
@@ -7,8 +7,8 @@ FindOpenAL
Finds Open Audio Library (OpenAL).
-Projects using this module should use ``#include <al.h>`` to include the OpenAL
-header file, **not** ``#include <AL.al.h>``. The reason for this is that the
+Projects using this module should use ``#include "al.h"`` to include the OpenAL
+header file, **not** ``#include <AL/al.h>``. The reason for this is that the
latter is not entirely portable. Windows/Creative Labs does not by default put
their headers in ``AL/`` and macOS uses the convention ``<OpenAL/al.h>``.
diff --git a/Modules/FindPython.cmake b/Modules/FindPython.cmake
index 018956b..95426ba 100644
--- a/Modules/FindPython.cmake
+++ b/Modules/FindPython.cmake
@@ -77,29 +77,35 @@ This module will set the following variables in your project
Standard platform independent installation directory.
Information returned by
- ``distutils.sysconfig.get_python_lib(plat_specific=False,standard_lib=True)``.
+ ``distutils.sysconfig.get_python_lib(plat_specific=False,standard_lib=True)``
+ or else ``sysconfig.get_path('stdlib')``.
``Python_STDARCH``
Standard platform dependent installation directory.
Information returned by
- ``distutils.sysconfig.get_python_lib(plat_specific=True,standard_lib=True)``.
+ ``distutils.sysconfig.get_python_lib(plat_specific=True,standard_lib=True)``
+ or else ``sysconfig.get_path('platstdlib')``.
``Python_SITELIB``
Third-party platform independent installation directory.
Information returned by
- ``distutils.sysconfig.get_python_lib(plat_specific=False,standard_lib=False)``.
+ ``distutils.sysconfig.get_python_lib(plat_specific=False,standard_lib=False)``
+ or else ``sysconfig.get_path('purelib')``.
``Python_SITEARCH``
Third-party platform dependent installation directory.
Information returned by
- ``distutils.sysconfig.get_python_lib(plat_specific=True,standard_lib=False)``.
+ ``distutils.sysconfig.get_python_lib(plat_specific=True,standard_lib=False)``
+ or else ``sysconfig.get_path('platlib')``.
``Python_SOABI``
Extension suffix for modules.
Information returned by
- ``distutils.sysconfig.get_config_flag('SOABI')`` or computed from
- ``distutils.sysconfig.get_config_flag('EXT_SUFFIX')`` or
- ``python-config --extension-suffix``.
+ ``distutils.sysconfig.get_config_var('SOABI')`` or computed from
+ ``distutils.sysconfig.get_config_var('EXT_SUFFIX')`` or
+ ``python-config --extension-suffix``. If package ``distutils.sysconfig`` is
+ not available, ``sysconfig.get_config_var('SOABI')`` or
+ ``sysconfig.get_config_var('EXT_SUFFIX')`` are used.
``Python_Compiler_FOUND``
System has the Python compiler.
``Python_COMPILER``
@@ -237,8 +243,9 @@ Hints
* ``ONLY``: Only the virtual environment is used to look-up for the
interpreter.
* ``STANDARD``: The virtual environment is not used to look-up for the
- interpreter. In this case, variable ``Python_FIND_REGISTRY`` (Windows)
- or ``CMAKE_FIND_FRAMEWORK`` (macOS) can be set with value ``LAST`` or
+ interpreter but environment variable ``PATH`` is always considered.
+ In this case, variable ``Python_FIND_REGISTRY`` (Windows) or
+ ``CMAKE_FIND_FRAMEWORK`` (macOS) can be set with value ``LAST`` or
``NEVER`` to select preferably the interpreter from the virtual
environment.
diff --git a/Modules/FindPython/Support.cmake b/Modules/FindPython/Support.cmake
index 5467b77..a990f0d 100644
--- a/Modules/FindPython/Support.cmake
+++ b/Modules/FindPython/Support.cmake
@@ -450,7 +450,7 @@ function (_PYTHON_GET_VERSION)
set (${_PGV_PREFIX}VERSION_PATCH ${version_patch} PARENT_SCOPE)
# compute ABI flags
- if (version_major VERSION_GREATER 2)
+ if (version_major VERSION_GREATER "2")
file (STRINGS "${_${_PYTHON_PREFIX}_INCLUDE_DIR}/pyconfig.h" config REGEX "(Py_DEBUG|WITH_PYMALLOC|Py_UNICODE_SIZE|MS_WIN32)")
set (abi)
if (config MATCHES "#[ ]*define[ ]+MS_WIN32")
@@ -823,7 +823,7 @@ endif()
# Set ABIs to search
## default: search any ABI
-if (_${_PYTHON_PREFIX}_REQUIRED_VERSION_MAJOR VERSION_LESS 3)
+if (_${_PYTHON_PREFIX}_REQUIRED_VERSION_MAJOR VERSION_LESS "3")
# ABI not supported
unset (_${_PYTHON_PREFIX}_FIND_ABI)
set (_${_PYTHON_PREFIX}_ABIFLAGS "")
@@ -1409,7 +1409,7 @@ if ("Interpreter" IN_LIST ${_PYTHON_PREFIX}_FIND_COMPONENTS)
unset (${_PYTHON_PREFIX}_SITEARCH)
endif()
- if (_${_PYTHON_PREFIX}_REQUIRED_VERSION_MAJOR VERSION_GREATER_EQUAL 3)
+ if (_${_PYTHON_PREFIX}_REQUIRED_VERSION_MAJOR VERSION_GREATER_EQUAL "3")
_python_get_config_var (${_PYTHON_PREFIX}_SOABI SOABI)
endif()
@@ -1601,7 +1601,7 @@ if ("Compiler" IN_LIST ${_PYTHON_PREFIX}_FIND_COMPONENTS)
if (_${_PYTHON_PREFIX}_COMPILER AND _${_PYTHON_PREFIX}_COMPILER_USABLE)
if (${_PYTHON_PREFIX}_Interpreter_FOUND)
# Compiler must be compatible with interpreter
- if (${_${_PYTHON_PREFIX}_VERSION_MAJOR}.${_${_PYTHON_PREFIX}_VERSION_MINOR} VERSION_EQUAL ${${_PYTHON_PREFIX}_VERSION_MAJOR}.${${_PYTHON_PREFIX}_VERSION_MINOR})
+ if ("${_${_PYTHON_PREFIX}_VERSION_MAJOR}.${_${_PYTHON_PREFIX}_VERSION_MINOR}" VERSION_EQUAL "${${_PYTHON_PREFIX}_VERSION_MAJOR}.${${_PYTHON_PREFIX}_VERSION_MINOR}")
set (${_PYTHON_PREFIX}_Compiler_FOUND TRUE)
endif()
elseif (${_PYTHON_PREFIX}_VERSION_MAJOR VERSION_EQUAL _${_PYTHON_PREFIX}_REQUIRED_VERSION_MAJOR)
@@ -2242,7 +2242,7 @@ if ("Development" IN_LIST ${_PYTHON_PREFIX}_FIND_COMPONENTS
_python_get_version (INCLUDE PREFIX _${_PYTHON_PREFIX}_INC_)
# update versioning
- if (_${_PYTHON_PREFIX}_INC_VERSION VERSION_EQUAL ${_${_PYTHON_PREFIX}_VERSION})
+ if (_${_PYTHON_PREFIX}_INC_VERSION VERSION_EQUAL _${_PYTHON_PREFIX}_VERSION)
set (_${_PYTHON_PREFIX}_VERSION_PATCH ${_${_PYTHON_PREFIX}_INC_VERSION_PATCH})
endif()
endif()
@@ -2284,12 +2284,12 @@ if ("Development" IN_LIST ${_PYTHON_PREFIX}_FIND_COMPONENTS
if (_${_PYTHON_PREFIX}_LIBRARY_RELEASE AND _${_PYTHON_PREFIX}_INCLUDE_DIR)
if (${_PYTHON_PREFIX}_Interpreter_FOUND OR ${_PYTHON_PREFIX}_Compiler_FOUND)
# development environment must be compatible with interpreter/compiler
- if (${_${_PYTHON_PREFIX}_VERSION_MAJOR}.${_${_PYTHON_PREFIX}_VERSION_MINOR} VERSION_EQUAL ${${_PYTHON_PREFIX}_VERSION_MAJOR}.${${_PYTHON_PREFIX}_VERSION_MINOR}
- AND ${_${_PYTHON_PREFIX}_INC_VERSION_MAJOR}.${_${_PYTHON_PREFIX}_INC_VERSION_MINOR} VERSION_EQUAL ${_${_PYTHON_PREFIX}_VERSION_MAJOR}.${_${_PYTHON_PREFIX}_VERSION_MINOR})
+ if ("${_${_PYTHON_PREFIX}_VERSION_MAJOR}.${_${_PYTHON_PREFIX}_VERSION_MINOR}" VERSION_EQUAL "${${_PYTHON_PREFIX}_VERSION_MAJOR}.${${_PYTHON_PREFIX}_VERSION_MINOR}"
+ AND "${_${_PYTHON_PREFIX}_INC_VERSION_MAJOR}.${_${_PYTHON_PREFIX}_INC_VERSION_MINOR}" VERSION_EQUAL "${_${_PYTHON_PREFIX}_VERSION_MAJOR}.${_${_PYTHON_PREFIX}_VERSION_MINOR}")
set (${_PYTHON_PREFIX}_Development_FOUND TRUE)
endif()
elseif (${_PYTHON_PREFIX}_VERSION_MAJOR VERSION_EQUAL _${_PYTHON_PREFIX}_REQUIRED_VERSION_MAJOR
- AND ${_${_PYTHON_PREFIX}_INC_VERSION_MAJOR}.${_${_PYTHON_PREFIX}_INC_VERSION_MINOR} VERSION_EQUAL ${_${_PYTHON_PREFIX}_VERSION_MAJOR}.${_${_PYTHON_PREFIX}_VERSION_MINOR})
+ AND "${_${_PYTHON_PREFIX}_INC_VERSION_MAJOR}.${_${_PYTHON_PREFIX}_INC_VERSION_MINOR}" VERSION_EQUAL "${_${_PYTHON_PREFIX}_VERSION_MAJOR}.${_${_PYTHON_PREFIX}_VERSION_MINOR}")
set (${_PYTHON_PREFIX}_Development_FOUND TRUE)
endif()
if (DEFINED _${_PYTHON_PREFIX}_FIND_ABI AND
@@ -2299,7 +2299,7 @@ if ("Development" IN_LIST ${_PYTHON_PREFIX}_FIND_COMPONENTS
endif()
endif()
- if (_${_PYTHON_PREFIX}_REQUIRED_VERSION_MAJOR VERSION_GREATER_EQUAL 3
+ if (_${_PYTHON_PREFIX}_REQUIRED_VERSION_MAJOR VERSION_GREATER_EQUAL "3"
AND NOT DEFINED ${_PYTHON_PREFIX}_SOABI)
_python_get_config_var (${_PYTHON_PREFIX}_SOABI SOABI)
endif()
diff --git a/Modules/FindPython2.cmake b/Modules/FindPython2.cmake
index 15e1ce1..3d9ceb4 100644
--- a/Modules/FindPython2.cmake
+++ b/Modules/FindPython2.cmake
@@ -78,22 +78,26 @@ This module will set the following variables in your project
Standard platform independent installation directory.
Information returned by
- ``distutils.sysconfig.get_python_lib(plat_specific=False,standard_lib=True)``.
+ ``distutils.sysconfig.get_python_lib(plat_specific=False,standard_lib=True)``
+ or else ``sysconfig.get_path('stdlib')``.
``Python2_STDARCH``
Standard platform dependent installation directory.
Information returned by
- ``distutils.sysconfig.get_python_lib(plat_specific=True,standard_lib=True)``.
+ ``distutils.sysconfig.get_python_lib(plat_specific=True,standard_lib=True)``
+ or else ``sysconfig.get_path('platstdlib')``.
``Python2_SITELIB``
Third-party platform independent installation directory.
Information returned by
- ``distutils.sysconfig.get_python_lib(plat_specific=False,standard_lib=False)``.
+ ``distutils.sysconfig.get_python_lib(plat_specific=False,standard_lib=False)``
+ or else ``sysconfig.get_path('purelib')``.
``Python2_SITEARCH``
Third-party platform dependent installation directory.
Information returned by
- ``distutils.sysconfig.get_python_lib(plat_specific=True,standard_lib=False)``.
+ ``distutils.sysconfig.get_python_lib(plat_specific=True,standard_lib=False)``
+ or else ``sysconfig.get_path('platlib')``.
``Python2_Compiler_FOUND``
System has the Python 2 compiler.
``Python2_COMPILER``
@@ -186,8 +190,9 @@ Hints
* ``ONLY``: Only the virtual environment is used to look-up for the
interpreter.
* ``STANDARD``: The virtual environment is not used to look-up for the
- interpreter. In this case, variable ``Python2_FIND_REGISTRY`` (Windows)
- or ``CMAKE_FIND_FRAMEWORK`` (macOS) can be set with value ``LAST`` or
+ interpreter but environment variable ``PATH`` is always considered.
+ In this case, variable ``Python2_FIND_REGISTRY`` (Windows) or
+ ``CMAKE_FIND_FRAMEWORK`` (macOS) can be set with value ``LAST`` or
``NEVER`` to select preferably the interpreter from the virtual
environment.
diff --git a/Modules/FindPython3.cmake b/Modules/FindPython3.cmake
index 8135a1d..122316b 100644
--- a/Modules/FindPython3.cmake
+++ b/Modules/FindPython3.cmake
@@ -78,29 +78,35 @@ This module will set the following variables in your project
Standard platform independent installation directory.
Information returned by
- ``distutils.sysconfig.get_python_lib(plat_specific=False,standard_lib=True)``.
+ ``distutils.sysconfig.get_python_lib(plat_specific=False,standard_lib=True)``
+ or else ``sysconfig.get_path('stdlib')``.
``Python3_STDARCH``
Standard platform dependent installation directory.
Information returned by
- ``distutils.sysconfig.get_python_lib(plat_specific=True,standard_lib=True)``.
+ ``distutils.sysconfig.get_python_lib(plat_specific=True,standard_lib=True)``
+ or else ``sysconfig.get_path('platstdlib')``.
``Python3_SITELIB``
Third-party platform independent installation directory.
Information returned by
- ``distutils.sysconfig.get_python_lib(plat_specific=False,standard_lib=False)``.
+ ``distutils.sysconfig.get_python_lib(plat_specific=False,standard_lib=False)``
+ or else ``sysconfig.get_path('purelib')``.
``Python3_SITEARCH``
Third-party platform dependent installation directory.
Information returned by
- ``distutils.sysconfig.get_python_lib(plat_specific=True,standard_lib=False)``.
+ ``distutils.sysconfig.get_python_lib(plat_specific=True,standard_lib=False)``
+ or else ``sysconfig.get_path('platlib')``.
``Python3_SOABI``
Extension suffix for modules.
Information returned by
- ``distutils.sysconfig.get_config_flag('SOABI')`` or computed from
- ``distutils.sysconfig.get_config_flag('EXT_SUFFIX')`` or
- ``python3-config --extension-suffix``.
+ ``distutils.sysconfig.get_config_var('SOABI')`` or computed from
+ ``distutils.sysconfig.get_config_var('EXT_SUFFIX')`` or
+ ``python3-config --extension-suffix``. If package ``distutils.sysconfig`` is
+ not available, ``sysconfig.get_config_var('SOABI')`` or
+ ``sysconfig.get_config_var('EXT_SUFFIX')`` are used.
``Python3_Compiler_FOUND``
System has the Python 3 compiler.
``Python3_COMPILER``
@@ -234,8 +240,9 @@ Hints
* ``ONLY``: Only the virtual environment is used to look-up for the
interpreter.
* ``STANDARD``: The virtual environment is not used to look-up for the
- interpreter. In this case, variable ``Python3_FIND_REGISTRY`` (Windows)
- or ``CMAKE_FIND_FRAMEWORK`` (macOS) can be set with value ``LAST`` or
+ interpreter but environment variable ``PATH`` is always considered.
+ In this case, variable ``Python3_FIND_REGISTRY`` (Windows) or
+ ``CMAKE_FIND_FRAMEWORK`` (macOS) can be set with value ``LAST`` or
``NEVER`` to select preferably the interpreter from the virtual
environment.
diff --git a/Modules/GoogleTestAddTests.cmake b/Modules/GoogleTestAddTests.cmake
index 65af4c2..499332f 100644
--- a/Modules/GoogleTestAddTests.cmake
+++ b/Modules/GoogleTestAddTests.cmake
@@ -134,6 +134,7 @@ function(gtest_discover_tests_impl)
"${prefix}${pretty_suite}.${pretty_test}${suffix}"
PROPERTIES
WORKING_DIRECTORY "${_TEST_WORKING_DIR}"
+ SKIP_REGULAR_EXPRESSION "\\\\[ SKIPPED \\\\]"
${properties}
)
list(APPEND tests_buffer "${prefix}${pretty_suite}.${pretty_test}${suffix}")
diff --git a/Modules/Internal/CPack/NSIS.template.in b/Modules/Internal/CPack/NSIS.template.in
index 660bfa3..6009ce0 100644
--- a/Modules/Internal/CPack/NSIS.template.in
+++ b/Modules/Internal/CPack/NSIS.template.in
@@ -41,6 +41,7 @@
RequestExecutionLevel admin
@CPACK_NSIS_DEFINES@
+@CPACK_NSIS_MANIFEST_DPI_AWARE_CODE@
!include Sections.nsh
diff --git a/Modules/Platform/UnixPaths.cmake b/Modules/Platform/UnixPaths.cmake
index 97f744d..98c83aa 100644
--- a/Modules/Platform/UnixPaths.cmake
+++ b/Modules/Platform/UnixPaths.cmake
@@ -86,6 +86,10 @@ set(_CMAKE_CUDA_IMPLICIT_INCLUDE_DIRECTORIES_INIT
unset(_cmake_sysroot_compile)
+if(CMAKE_COMPILER_SYSROOT)
+ list(PREPEND CMAKE_SYSTEM_PREFIX_PATH "${CMAKE_COMPILER_SYSROOT}")
+endif()
+
# Enable use of lib32 and lib64 search path variants by default.
set_property(GLOBAL PROPERTY FIND_LIBRARY_USE_LIB32_PATHS TRUE)
set_property(GLOBAL PROPERTY FIND_LIBRARY_USE_LIB64_PATHS TRUE)
diff --git a/Modules/UseJava.cmake b/Modules/UseJava.cmake
index 9177d16..db3fb95 100644
--- a/Modules/UseJava.cmake
+++ b/Modules/UseJava.cmake
@@ -377,7 +377,9 @@ function (__java_copy_file src dest comment)
ARGS ${src}
${dest}
DEPENDS ${src}
- COMMENT ${comment})
+ COMMENT ${comment}
+ VERBATIM
+ )
endfunction ()
function(__java_lcat VAR)
@@ -615,7 +617,7 @@ function(add_jar _TARGET_NAME)
OUTPUT ${CMAKE_JAVA_CLASS_OUTPUT_PATH}/java_compiled_${_TARGET_NAME}
COMMAND ${CMAKE_COMMAND}
-DCMAKE_JAVA_CLASS_OUTPUT_PATH=${CMAKE_JAVA_CLASS_OUTPUT_PATH}
- -DCMAKE_JAR_CLASSES_PREFIX="${CMAKE_JAR_CLASSES_PREFIX}"
+ -DCMAKE_JAR_CLASSES_PREFIX=${CMAKE_JAR_CLASSES_PREFIX}
-P ${CMAKE_CURRENT_FUNCTION_LIST_DIR}/UseJava/ClearClassFiles.cmake
COMMAND ${Java_JAVAC_EXECUTABLE}
${CMAKE_JAVA_COMPILE_FLAGS}
@@ -627,15 +629,17 @@ function(add_jar _TARGET_NAME)
DEPENDS ${_JAVA_COMPILE_FILES} ${_JAVA_COMPILE_FILELISTS} ${_JAVA_COMPILE_DEPENDS} ${_JAVA_SOURCES_FILE}
WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}
COMMENT "Building Java objects for ${_TARGET_NAME}.jar"
+ VERBATIM
)
add_custom_command(
OUTPUT ${CMAKE_JAVA_CLASS_OUTPUT_PATH}/java_class_filelist
COMMAND ${CMAKE_COMMAND}
-DCMAKE_JAVA_CLASS_OUTPUT_PATH=${CMAKE_JAVA_CLASS_OUTPUT_PATH}
- -DCMAKE_JAR_CLASSES_PREFIX="${CMAKE_JAR_CLASSES_PREFIX}"
+ -DCMAKE_JAR_CLASSES_PREFIX=${CMAKE_JAR_CLASSES_PREFIX}
-P ${CMAKE_CURRENT_FUNCTION_LIST_DIR}/UseJavaClassFilelist.cmake
DEPENDS ${CMAKE_JAVA_CLASS_OUTPUT_PATH}/java_compiled_${_TARGET_NAME}
WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}
+ VERBATIM
)
else ()
# create an empty java_class_filelist
@@ -666,6 +670,7 @@ function(add_jar _TARGET_NAME)
DEPENDS ${_JAVA_RESOURCE_FILES} ${_JAVA_DEPENDS} ${CMAKE_JAVA_CLASS_OUTPUT_PATH}/java_class_filelist
WORKING_DIRECTORY ${CMAKE_JAVA_CLASS_OUTPUT_PATH}
COMMENT "Creating Java archive ${_JAVA_TARGET_OUTPUT_NAME}"
+ VERBATIM
)
else ()
add_custom_command(
@@ -681,6 +686,7 @@ function(add_jar _TARGET_NAME)
WORKING_DIRECTORY ${CMAKE_JAVA_CLASS_OUTPUT_PATH}
DEPENDS ${_JAVA_RESOURCE_FILES} ${_JAVA_DEPENDS} ${CMAKE_JAVA_CLASS_OUTPUT_PATH}/java_class_filelist
COMMENT "Creating Java archive ${_JAVA_TARGET_OUTPUT_NAME}"
+ VERBATIM
)
endif ()
diff --git a/Source/CMakeVersion.cmake b/Source/CMakeVersion.cmake
index b192df2..56d9174 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 20200409)
+set(CMake_VERSION_PATCH 20200416)
#set(CMake_VERSION_RC 0)
set(CMake_VERSION_IS_DIRTY 0)
diff --git a/Source/CPack/IFW/cmCPackIFWRepository.cxx b/Source/CPack/IFW/cmCPackIFWRepository.cxx
index a696549..f5e8744 100644
--- a/Source/CPack/IFW/cmCPackIFWRepository.cxx
+++ b/Source/CPack/IFW/cmCPackIFWRepository.cxx
@@ -21,11 +21,7 @@ bool cmCPackIFWRepository::IsValid() const
switch (this->Update) {
case cmCPackIFWRepository::None:
- valid = !this->Url.empty();
- break;
case cmCPackIFWRepository::Add:
- valid = !this->Url.empty();
- break;
case cmCPackIFWRepository::Remove:
valid = !this->Url.empty();
break;
diff --git a/Source/CPack/cmCPackNSISGenerator.cxx b/Source/CPack/cmCPackNSISGenerator.cxx
index 9afdc62..3067f96 100644
--- a/Source/CPack/cmCPackNSISGenerator.cxx
+++ b/Source/CPack/cmCPackNSISGenerator.cxx
@@ -203,6 +203,11 @@ int cmCPackNSISGenerator::PackageFiles()
"!define MUI_FINISHPAGE_TITLE_3LINES");
}
+ if (this->IsSet("CPACK_NSIS_MANIFEST_DPI_AWARE")) {
+ this->SetOptionIfNotSet("CPACK_NSIS_MANIFEST_DPI_AWARE_CODE",
+ "ManifestDPIAware true");
+ }
+
// Setup all of the component sections
if (this->Components.empty()) {
this->SetOptionIfNotSet("CPACK_NSIS_INSTALLATION_TYPES", "");
diff --git a/Source/CTest/cmCTestBuildHandler.cxx b/Source/CTest/cmCTestBuildHandler.cxx
index 90c5b2a..35c2b11 100644
--- a/Source/CTest/cmCTestBuildHandler.cxx
+++ b/Source/CTest/cmCTestBuildHandler.cxx
@@ -541,11 +541,11 @@ void cmCTestBuildHandler::GenerateXMLLaunched(cmXMLWriter& xml)
const char* fname = launchDir.GetFile(i);
if (this->IsLaunchedErrorFile(fname) && numErrorsAllowed) {
numErrorsAllowed--;
- fragments.insert(this->CTestLaunchDir + "/" + fname);
+ fragments.insert(this->CTestLaunchDir + '/' + fname);
++this->TotalErrors;
} else if (this->IsLaunchedWarningFile(fname) && numWarningsAllowed) {
numWarningsAllowed--;
- fragments.insert(this->CTestLaunchDir + "/" + fname);
+ fragments.insert(this->CTestLaunchDir + '/' + fname);
++this->TotalWarnings;
}
}
diff --git a/Source/CTest/cmCTestCVS.cxx b/Source/CTest/cmCTestCVS.cxx
index 45ec390..1209e06 100644
--- a/Source/CTest/cmCTestCVS.cxx
+++ b/Source/CTest/cmCTestCVS.cxx
@@ -152,10 +152,12 @@ private:
this->FinishRevision();
}
} else if (this->Section == SectionRevisions) {
+ // XXX(clang-tidy): https://bugs.llvm.org/show_bug.cgi?id=44165
+ // NOLINTNEXTLINE(bugprone-branch-clone)
if (!this->Rev.Log.empty()) {
// Continue the existing log.
this->Rev.Log += this->Line;
- this->Rev.Log += "\n";
+ this->Rev.Log += '\n';
} else if (this->Rev.Rev.empty() &&
this->RegexRevision.find(this->Line)) {
this->Rev.Rev = this->RegexRevision.match(1);
@@ -166,7 +168,7 @@ private:
} else if (!this->RegexBranches.find(this->Line)) {
// Start the log.
this->Rev.Log += this->Line;
- this->Rev.Log += "\n";
+ this->Rev.Log += '\n';
}
}
return this->Section != SectionEnd;
diff --git a/Source/CTest/cmCTestMemCheckHandler.cxx b/Source/CTest/cmCTestMemCheckHandler.cxx
index c1ecaf1..7ad87f5 100644
--- a/Source/CTest/cmCTestMemCheckHandler.cxx
+++ b/Source/CTest/cmCTestMemCheckHandler.cxx
@@ -957,35 +957,25 @@ bool cmCTestMemCheckHandler::ProcessMemCheckValgrindOutput(
"valgrind line " << lines[cc] << std::endl,
this->Quiet);
int failure = cmCTestMemCheckHandler::NO_MEMORY_FAULT;
- if (vgFIM.find(lines[cc])) {
+ auto& line = lines[cc];
+ if (vgFIM.find(line)) {
failure = cmCTestMemCheckHandler::FIM;
- } else if (vgFMM.find(lines[cc])) {
+ } else if (vgFMM.find(line)) {
failure = cmCTestMemCheckHandler::FMM;
- } else if (vgMLK1.find(lines[cc])) {
+ } else if (vgMLK1.find(line) || vgMLK2.find(line)) {
failure = cmCTestMemCheckHandler::MLK;
- } else if (vgMLK2.find(lines[cc])) {
- failure = cmCTestMemCheckHandler::MLK;
- } else if (vgPAR.find(lines[cc])) {
+ } else if (vgPAR.find(line)) {
failure = cmCTestMemCheckHandler::PAR;
- } else if (vgMPK1.find(lines[cc])) {
- failure = cmCTestMemCheckHandler::MPK;
- } else if (vgMPK2.find(lines[cc])) {
+ } else if (vgMPK1.find(line) || vgMPK2.find(line)) {
failure = cmCTestMemCheckHandler::MPK;
- } else if (vgUMC.find(lines[cc])) {
+ } else if (vgUMC.find(line)) {
failure = cmCTestMemCheckHandler::UMC;
- } else if (vgUMR1.find(lines[cc])) {
- failure = cmCTestMemCheckHandler::UMR;
- } else if (vgUMR2.find(lines[cc])) {
- failure = cmCTestMemCheckHandler::UMR;
- } else if (vgUMR3.find(lines[cc])) {
+ } else if (vgUMR1.find(line) || vgUMR2.find(line) || vgUMR3.find(line) ||
+ vgUMR4.find(line) || vgUMR5.find(line)) {
failure = cmCTestMemCheckHandler::UMR;
- } else if (vgUMR4.find(lines[cc])) {
- failure = cmCTestMemCheckHandler::UMR;
- } else if (vgUMR5.find(lines[cc])) {
- failure = cmCTestMemCheckHandler::UMR;
- } else if (vgIPW.find(lines[cc])) {
+ } else if (vgIPW.find(line)) {
failure = cmCTestMemCheckHandler::IPW;
- } else if (vgABR.find(lines[cc])) {
+ } else if (vgABR.find(line)) {
failure = cmCTestMemCheckHandler::ABR;
}
@@ -1049,13 +1039,9 @@ bool cmCTestMemCheckHandler::ProcessMemCheckDrMemoryOutput(
ostr << l << std::endl;
if (drMemoryError.find(l)) {
defects++;
- if (unaddressableAccess.find(l)) {
+ if (unaddressableAccess.find(l) || uninitializedRead.find(l)) {
results[cmCTestMemCheckHandler::UMR]++;
- } else if (uninitializedRead.find(l)) {
- results[cmCTestMemCheckHandler::UMR]++;
- } else if (leak.find(l)) {
- results[cmCTestMemCheckHandler::MLK]++;
- } else if (handleLeak.find(l)) {
+ } else if (leak.find(l) || handleLeak.find(l)) {
results[cmCTestMemCheckHandler::MLK]++;
} else if (invalidHeapArgument.find(l)) {
results[cmCTestMemCheckHandler::FMM]++;
diff --git a/Source/CTest/cmCTestTestHandler.cxx b/Source/CTest/cmCTestTestHandler.cxx
index f9850ef..ca65946 100644
--- a/Source/CTest/cmCTestTestHandler.cxx
+++ b/Source/CTest/cmCTestTestHandler.cxx
@@ -2402,10 +2402,9 @@ bool cmCTestTestHandler::AddTest(const std::vector<std::string>& args)
test.SkipReturnCode = -1;
test.PreviousRuns = 0;
if (this->UseIncludeRegExpFlag &&
- !this->IncludeTestsRegularExpression.find(testname)) {
- test.IsInBasedOnREOptions = false;
- } else if (this->UseExcludeRegExpFlag && !this->UseExcludeRegExpFirst &&
- this->ExcludeTestsRegularExpression.find(testname)) {
+ (!this->IncludeTestsRegularExpression.find(testname) ||
+ (!this->UseExcludeRegExpFirst &&
+ this->ExcludeTestsRegularExpression.find(testname)))) {
test.IsInBasedOnREOptions = false;
}
this->TestList.push_back(test);
diff --git a/Source/CTest/cmParseCacheCoverage.cxx b/Source/CTest/cmParseCacheCoverage.cxx
index 1a5e7c5..84d7de0 100644
--- a/Source/CTest/cmParseCacheCoverage.cxx
+++ b/Source/CTest/cmParseCacheCoverage.cxx
@@ -4,6 +4,7 @@
#include <cstdlib>
#include <map>
#include <utility>
+#include <vector>
#include "cmsys/Directory.hxx"
#include "cmsys/FStream.hxx"
@@ -69,26 +70,6 @@ void cmParseCacheCoverage::RemoveUnCoveredFiles()
}
}
-bool cmParseCacheCoverage::SplitString(std::vector<std::string>& args,
- std::string const& line)
-{
- std::string::size_type pos1 = 0;
- std::string::size_type pos2 = line.find(',', 0);
- if (pos2 == std::string::npos) {
- return false;
- }
- std::string arg;
- while (pos2 != std::string::npos) {
- arg = line.substr(pos1, pos2 - pos1);
- args.push_back(arg);
- pos1 = pos2 + 1;
- pos2 = line.find(',', pos1);
- }
- arg = line.substr(pos1);
- args.push_back(arg);
- return true;
-}
-
bool cmParseCacheCoverage::ReadCMCovFile(const char* file)
{
cmsys::ifstream in(file);
@@ -97,7 +78,6 @@ bool cmParseCacheCoverage::ReadCMCovFile(const char* file)
return false;
}
std::string line;
- std::vector<std::string> separateLine;
if (!cmSystemTools::GetLineFromStream(in, line)) {
cmCTestLog(this->CTest, ERROR_MESSAGE,
"Empty file : " << file
@@ -106,8 +86,8 @@ bool cmParseCacheCoverage::ReadCMCovFile(const char* file)
<< line << "]\n");
return false;
}
- separateLine.clear();
- this->SplitString(separateLine, line);
+ std::vector<std::string> separateLine =
+ cmSystemTools::SplitString(line, ',');
if (separateLine.size() != 4 || separateLine[0] != "Routine" ||
separateLine[1] != "Line" || separateLine[2] != "RtnLine" ||
separateLine[3] != "Code") {
@@ -120,10 +100,8 @@ bool cmParseCacheCoverage::ReadCMCovFile(const char* file)
std::string routine;
std::string filepath;
while (cmSystemTools::GetLineFromStream(in, line)) {
- // clear out line argument vector
- separateLine.clear();
// parse the comma separated line
- this->SplitString(separateLine, line);
+ separateLine = cmSystemTools::SplitString(line, ',');
// might have more because code could have a quoted , in it
// but we only care about the first 3 args anyway
if (separateLine.size() < 4) {
diff --git a/Source/CTest/cmParseCacheCoverage.h b/Source/CTest/cmParseCacheCoverage.h
index 3b554f3..a8200b7 100644
--- a/Source/CTest/cmParseCacheCoverage.h
+++ b/Source/CTest/cmParseCacheCoverage.h
@@ -6,7 +6,6 @@
#include "cmConfigure.h" // IWYU pragma: keep
#include <string>
-#include <vector>
#include "cmParseMumpsCoverage.h"
@@ -31,8 +30,6 @@ protected:
void RemoveUnCoveredFiles();
// Read a single mcov file
bool ReadCMCovFile(const char* f);
- // split a string based on ,
- bool SplitString(std::vector<std::string>& args, std::string const& line);
};
#endif
diff --git a/Source/CursesDialog/cmCursesLongMessageForm.cxx b/Source/CursesDialog/cmCursesLongMessageForm.cxx
index afd2b6b..664ba2f 100644
--- a/Source/CursesDialog/cmCursesLongMessageForm.cxx
+++ b/Source/CursesDialog/cmCursesLongMessageForm.cxx
@@ -41,7 +41,8 @@ void cmCursesLongMessageForm::UpdateContent(std::string const& output,
this->Title = title;
if (!output.empty() && this->Messages.size() < MAX_CONTENT_SIZE) {
- this->Messages.append("\n" + output);
+ this->Messages.push_back('\n');
+ this->Messages.append(output);
form_driver(this->Form, REQ_NEW_LINE);
this->DrawMessage(output.c_str());
}
diff --git a/Source/QtDialog/CMakeSetupDialog.cxx b/Source/QtDialog/CMakeSetupDialog.cxx
index 276bf64..4daf726 100644
--- a/Source/QtDialog/CMakeSetupDialog.cxx
+++ b/Source/QtDialog/CMakeSetupDialog.cxx
@@ -804,6 +804,9 @@ bool CMakeSetupDialog::setupFirstConfigure()
QString systemVersion = dialog.getSystemVersion();
m->insertProperty(QCMakeProperty::STRING, "CMAKE_SYSTEM_VERSION",
tr("CMake System Version"), systemVersion, false);
+ QString systemProcessor = dialog.getSystemProcessor();
+ m->insertProperty(QCMakeProperty::STRING, "CMAKE_SYSTEM_PROCESSOR",
+ tr("CMake System Processor"), systemProcessor, false);
QString cxxCompiler = dialog.getCXXCompiler();
m->insertProperty(QCMakeProperty::FILEPATH, "CMAKE_CXX_COMPILER",
tr("CXX compiler."), cxxCompiler, false);
diff --git a/Source/cmCPluginAPI.cxx b/Source/cmCPluginAPI.cxx
index 874efa5..697d435 100644
--- a/Source/cmCPluginAPI.cxx
+++ b/Source/cmCPluginAPI.cxx
@@ -580,7 +580,8 @@ const char* CCONV cmSourceFileGetProperty(void* arg, const char* prop)
{
cmCPluginAPISourceFile* sf = static_cast<cmCPluginAPISourceFile*>(arg);
if (cmSourceFile* rsf = sf->RealSourceFile) {
- return rsf->GetProperty(prop);
+ cmProp p = rsf->GetProperty(prop);
+ return p ? p->c_str() : nullptr;
}
if (!strcmp(prop, "LOCATION")) {
return sf->FullPath.c_str();
diff --git a/Source/cmCTest.cxx b/Source/cmCTest.cxx
index c5505f9..35a8952 100644
--- a/Source/cmCTest.cxx
+++ b/Source/cmCTest.cxx
@@ -1941,13 +1941,11 @@ bool cmCTest::HandleCommandLineArguments(size_t& i,
else if (this->CheckArgument(arg, "--debug"_s)) {
this->Impl->Debug = true;
this->Impl->ShowLineNumbers = true;
- } else if (this->CheckArgument(arg, "--group"_s) && i < args.size() - 1) {
- i++;
- this->Impl->SpecificGroup = args[i];
- }
- // This is an undocumented / deprecated option.
- // "Track" has been renamed to "Group".
- else if (this->CheckArgument(arg, "--track"_s) && i < args.size() - 1) {
+ } else if ((this->CheckArgument(arg, "--group"_s) ||
+ // This is an undocumented / deprecated option.
+ // "Track" has been renamed to "Group".
+ this->CheckArgument(arg, "--track"_s)) &&
+ i < args.size() - 1) {
i++;
this->Impl->SpecificGroup = args[i];
} else if (this->CheckArgument(arg, "--show-line-numbers"_s)) {
diff --git a/Source/cmCommonTargetGenerator.cxx b/Source/cmCommonTargetGenerator.cxx
index 939f757..673936c 100644
--- a/Source/cmCommonTargetGenerator.cxx
+++ b/Source/cmCommonTargetGenerator.cxx
@@ -73,9 +73,9 @@ void cmCommonTargetGenerator::AddModuleDefinitionFlag(
void cmCommonTargetGenerator::AppendFortranFormatFlags(
std::string& flags, cmSourceFile const& source)
{
- const char* srcfmt = source.GetProperty("Fortran_FORMAT");
+ cmProp srcfmt = source.GetProperty("Fortran_FORMAT");
cmOutputConverter::FortranFormat format =
- cmOutputConverter::GetFortranFormat(srcfmt);
+ cmOutputConverter::GetFortranFormat(srcfmt ? srcfmt->c_str() : nullptr);
if (format == cmOutputConverter::FortranFormatNone) {
const char* tgtfmt = this->GeneratorTarget->GetProperty("Fortran_FORMAT");
format = cmOutputConverter::GetFortranFormat(tgtfmt);
diff --git a/Source/cmComputeLinkInformation.cxx b/Source/cmComputeLinkInformation.cxx
index 8d27699..d8a6204 100644
--- a/Source/cmComputeLinkInformation.cxx
+++ b/Source/cmComputeLinkInformation.cxx
@@ -998,15 +998,16 @@ std::string cmComputeLinkInformation::CreateExtensionRegex(
std::string cmComputeLinkInformation::NoCaseExpression(const char* str)
{
std::string ret;
+ ret.reserve(strlen(str) * 4);
const char* s = str;
while (*s) {
if (*s == '.') {
ret += *s;
} else {
- ret += "[";
+ ret += '[';
ret += static_cast<char>(tolower(*s));
ret += static_cast<char>(toupper(*s));
- ret += "]";
+ ret += ']';
}
s++;
}
@@ -1440,7 +1441,6 @@ void cmComputeLinkInformation::HandleBadFullItem(std::string const& item,
}
case cmPolicies::OLD:
// OLD behavior does not warn.
- break;
case cmPolicies::NEW:
// NEW behavior will not get here.
break;
diff --git a/Source/cmConfigureFileCommand.cxx b/Source/cmConfigureFileCommand.cxx
index 8767386..bac9337 100644
--- a/Source/cmConfigureFileCommand.cxx
+++ b/Source/cmConfigureFileCommand.cxx
@@ -2,6 +2,12 @@
file Copyright.txt or https://cmake.org/licensing for details. */
#include "cmConfigureFileCommand.h"
+#include <set>
+
+#include <cm/string_view>
+
+#include "cm_static_string_view.hxx"
+
#include "cmExecutionStatus.h"
#include "cmMakefile.h"
#include "cmMessageType.h"
@@ -56,6 +62,18 @@ bool cmConfigureFileCommand(std::vector<std::string> const& args,
bool copyOnly = false;
bool escapeQuotes = false;
+ static std::set<cm::string_view> noopOptions = {
+ /* Legacy. */
+ "IMMEDIATE"_s,
+ /* Handled by NewLineStyle member. */
+ "NEWLINE_STYLE"_s,
+ "LF"_s,
+ "UNIX"_s,
+ "CRLF"_s,
+ "WIN32"_s,
+ "DOS"_s,
+ };
+
std::string unknown_args;
bool atOnly = false;
for (unsigned int i = 2; i < args.size(); ++i) {
@@ -70,12 +88,8 @@ bool cmConfigureFileCommand(std::vector<std::string> const& args,
escapeQuotes = true;
} else if (args[i] == "@ONLY") {
atOnly = true;
- } else if (args[i] == "IMMEDIATE") {
- /* Ignore legacy option. */
- } else if (args[i] == "NEWLINE_STYLE" || args[i] == "LF" ||
- args[i] == "UNIX" || args[i] == "CRLF" || args[i] == "WIN32" ||
- args[i] == "DOS") {
- /* Options handled by NewLineStyle member above. */
+ } else if (noopOptions.find(args[i]) != noopOptions.end()) {
+ /* Ignore no-op options. */
} else {
unknown_args += " ";
unknown_args += args[i];
diff --git a/Source/cmCoreTryCompile.cxx b/Source/cmCoreTryCompile.cxx
index 9c26f61..dc2df14 100644
--- a/Source/cmCoreTryCompile.cxx
+++ b/Source/cmCoreTryCompile.cxx
@@ -40,6 +40,10 @@ static std::string const kCMAKE_CXX_LINK_NO_PIE_SUPPORTED =
"CMAKE_CXX_LINK_NO_PIE_SUPPORTED";
static std::string const kCMAKE_CXX_LINK_PIE_SUPPORTED =
"CMAKE_CXX_LINK_PIE_SUPPORTED";
+static std::string const kCMAKE_CUDA_ARCHITECTURES =
+ "CMAKE_CUDA_ARCHITECTURES";
+static std::string const kCMAKE_CUDA_COMPILER_TARGET =
+ "CMAKE_CUDA_COMPILER_TARGET";
static std::string const kCMAKE_ENABLE_EXPORTS = "CMAKE_ENABLE_EXPORTS";
static std::string const kCMAKE_LINK_SEARCH_END_STATIC =
"CMAKE_LINK_SEARCH_END_STATIC";
@@ -711,6 +715,8 @@ int cmCoreTryCompile::TryCompileCode(std::vector<std::string> const& argv,
vars.insert(kCMAKE_C_COMPILER_TARGET);
vars.insert(kCMAKE_CXX_COMPILER_EXTERNAL_TOOLCHAIN);
vars.insert(kCMAKE_CXX_COMPILER_TARGET);
+ vars.insert(kCMAKE_CUDA_ARCHITECTURES);
+ vars.insert(kCMAKE_CUDA_COMPILER_TARGET);
vars.insert(kCMAKE_ENABLE_EXPORTS);
vars.insert(kCMAKE_LINK_SEARCH_END_STATIC);
vars.insert(kCMAKE_LINK_SEARCH_START_STATIC);
diff --git a/Source/cmCustomCommand.cxx b/Source/cmCustomCommand.cxx
index 0dd8722..149f5e9 100644
--- a/Source/cmCustomCommand.cxx
+++ b/Source/cmCustomCommand.cxx
@@ -11,7 +11,8 @@ cmCustomCommand::cmCustomCommand(std::vector<std::string> outputs,
std::vector<std::string> depends,
cmCustomCommandLines commandLines,
cmListFileBacktrace lfbt, const char* comment,
- const char* workingDirectory)
+ const char* workingDirectory,
+ bool stdPipesUTF8)
: Outputs(std::move(outputs))
, Byproducts(std::move(byproducts))
, Depends(std::move(depends))
@@ -20,6 +21,7 @@ cmCustomCommand::cmCustomCommand(std::vector<std::string> outputs,
, Comment(comment ? comment : "")
, WorkingDirectory(workingDirectory ? workingDirectory : "")
, HaveComment(comment != nullptr)
+ , StdPipesUTF8(stdPipesUTF8)
{
}
diff --git a/Source/cmCustomCommand.h b/Source/cmCustomCommand.h
index d300fa5..aa572ad 100644
--- a/Source/cmCustomCommand.h
+++ b/Source/cmCustomCommand.h
@@ -30,7 +30,8 @@ public:
std::vector<std::string> byproducts,
std::vector<std::string> depends,
cmCustomCommandLines commandLines, cmListFileBacktrace lfbt,
- const char* comment, const char* workingDirectory);
+ const char* comment, const char* workingDirectory,
+ bool stdPipesUTF8);
/** Get the output file produced by the command. */
const std::vector<std::string>& GetOutputs() const;
@@ -53,6 +54,9 @@ public:
/** Get the comment string for the command. */
const char* GetComment() const;
+ /** Get a value indicating if the command uses UTF-8 output pipes. */
+ bool GetStdPipesUTF8() const { return this->StdPipesUTF8; }
+
/** Append to the list of command lines. */
void AppendCommands(const cmCustomCommandLines& commandLines);
@@ -108,6 +112,7 @@ private:
bool EscapeOldStyle = true;
bool UsesTerminal = false;
bool CommandExpandLists = false;
+ bool StdPipesUTF8 = false;
};
#endif
diff --git a/Source/cmDepends.cxx b/Source/cmDepends.cxx
index d4e8da6..d8aa730 100644
--- a/Source/cmDepends.cxx
+++ b/Source/cmDepends.cxx
@@ -9,12 +9,12 @@
#include "cmFileTime.h"
#include "cmFileTimeCache.h"
#include "cmGeneratedFileStream.h"
-#include "cmLocalGenerator.h"
+#include "cmLocalUnixMakefileGenerator3.h"
#include "cmMakefile.h"
#include "cmStringAlgorithms.h"
#include "cmSystemTools.h"
-cmDepends::cmDepends(cmLocalGenerator* lg, std::string targetDir)
+cmDepends::cmDepends(cmLocalUnixMakefileGenerator3* lg, std::string targetDir)
: LocalGenerator(lg)
, TargetDirectory(std::move(targetDir))
{
diff --git a/Source/cmDepends.h b/Source/cmDepends.h
index d938775..8cf528f 100644
--- a/Source/cmDepends.h
+++ b/Source/cmDepends.h
@@ -12,7 +12,7 @@
#include <vector>
class cmFileTimeCache;
-class cmLocalGenerator;
+class cmLocalUnixMakefileGenerator3;
/** \class cmDepends
* \brief Dependency scanner superclass.
@@ -29,7 +29,8 @@ public:
public:
/** Instances need to know the build directory name and the relative
path from the build directory to the target file. */
- cmDepends(cmLocalGenerator* lg = nullptr, std::string targetDir = "");
+ cmDepends(cmLocalUnixMakefileGenerator3* lg = nullptr,
+ std::string targetDir = "");
cmDepends(cmDepends const&) = delete;
cmDepends& operator=(cmDepends const&) = delete;
@@ -38,7 +39,10 @@ public:
scanning dependencies. This is not a full local generator; it
has been setup to do relative path conversions for the current
directory. */
- void SetLocalGenerator(cmLocalGenerator* lg) { this->LocalGenerator = lg; }
+ void SetLocalGenerator(cmLocalUnixMakefileGenerator3* lg)
+ {
+ this->LocalGenerator = lg;
+ }
/** Set the specific language to be scanned. */
void SetLanguage(const std::string& lang) { this->Language = lang; }
@@ -92,7 +96,7 @@ protected:
std::ostream& internalDepends);
// The local generator.
- cmLocalGenerator* LocalGenerator;
+ cmLocalUnixMakefileGenerator3* LocalGenerator;
// Flag for verbose output.
bool Verbose = false;
diff --git a/Source/cmDependsC.cxx b/Source/cmDependsC.cxx
index 01bb6ed..4499a66 100644
--- a/Source/cmDependsC.cxx
+++ b/Source/cmDependsC.cxx
@@ -7,7 +7,7 @@
#include "cmsys/FStream.hxx"
#include "cmFileTime.h"
-#include "cmLocalGenerator.h"
+#include "cmLocalUnixMakefileGenerator3.h"
#include "cmMakefile.h"
#include "cmStringAlgorithms.h"
#include "cmSystemTools.h"
@@ -22,8 +22,9 @@
cmDependsC::cmDependsC() = default;
-cmDependsC::cmDependsC(cmLocalGenerator* lg, const std::string& targetDir,
- const std::string& lang, const DependencyMap* validDeps)
+cmDependsC::cmDependsC(cmLocalUnixMakefileGenerator3* lg,
+ const std::string& targetDir, const std::string& lang,
+ const DependencyMap* validDeps)
: cmDepends(lg, targetDir)
, ValidDeps(validDeps)
{
@@ -211,12 +212,12 @@ bool cmDependsC::WriteDependencies(const std::set<std::string>& sources,
// written by the original local generator for this directory
// convert the dependencies to paths relative to the home output
// directory. We must do the same here.
- std::string obj_m = cmSystemTools::ConvertToOutputPath(obj_i);
+ std::string obj_m = this->LocalGenerator->ConvertToMakefilePath(obj_i);
internalDepends << obj_i << '\n';
for (std::string const& dep : dependencies) {
makeDepends << obj_m << ": "
- << cmSystemTools::ConvertToOutputPath(
+ << this->LocalGenerator->ConvertToMakefilePath(
this->LocalGenerator->MaybeConvertToRelativePath(binDir,
dep))
<< '\n';
diff --git a/Source/cmDependsC.h b/Source/cmDependsC.h
index 868c94a..e01faa4 100644
--- a/Source/cmDependsC.h
+++ b/Source/cmDependsC.h
@@ -16,7 +16,7 @@
#include "cmDepends.h"
-class cmLocalGenerator;
+class cmLocalUnixMakefileGenerator3;
/** \class cmDependsC
* \brief Dependency scanner for C and C++ object files.
@@ -27,7 +27,7 @@ public:
/** Checking instances need to know the build directory name and the
relative path from the build directory to the target file. */
cmDependsC();
- cmDependsC(cmLocalGenerator* lg, const std::string& targetDir,
+ cmDependsC(cmLocalUnixMakefileGenerator3* lg, const std::string& targetDir,
const std::string& lang, const DependencyMap* validDeps);
/** Virtual destructor to cleanup subclasses properly. */
diff --git a/Source/cmDependsFortran.cxx b/Source/cmDependsFortran.cxx
index 666306c..95dfc4e 100644
--- a/Source/cmDependsFortran.cxx
+++ b/Source/cmDependsFortran.cxx
@@ -12,7 +12,7 @@
#include "cmFortranParser.h" /* Interface to parser object. */
#include "cmGeneratedFileStream.h"
-#include "cmLocalGenerator.h"
+#include "cmLocalUnixMakefileGenerator3.h"
#include "cmMakefile.h"
#include "cmOutputConverter.h"
#include "cmStateDirectory.h"
@@ -29,12 +29,10 @@ static void cmFortranModuleAppendUpperLower(std::string const& mod,
std::string& mod_lower)
{
std::string::size_type ext_len = 0;
- if (cmHasLiteralSuffix(mod, ".mod")) {
+ if (cmHasLiteralSuffix(mod, ".mod") || cmHasLiteralSuffix(mod, ".sub")) {
ext_len = 4;
} else if (cmHasLiteralSuffix(mod, ".smod")) {
ext_len = 5;
- } else if (cmHasLiteralSuffix(mod, ".sub")) {
- ext_len = 4;
}
std::string const& name = mod.substr(0, mod.size() - ext_len);
std::string const& ext = mod.substr(mod.size() - ext_len);
@@ -72,7 +70,7 @@ public:
cmDependsFortran::cmDependsFortran() = default;
-cmDependsFortran::cmDependsFortran(cmLocalGenerator* lg)
+cmDependsFortran::cmDependsFortran(cmLocalUnixMakefileGenerator3* lg)
: cmDepends(lg)
, Internal(new cmDependsFortranInternals)
{
diff --git a/Source/cmDependsFortran.h b/Source/cmDependsFortran.h
index e3e0d05..3e306dd 100644
--- a/Source/cmDependsFortran.h
+++ b/Source/cmDependsFortran.h
@@ -15,7 +15,7 @@
class cmDependsFortranInternals;
class cmFortranSourceInfo;
-class cmLocalGenerator;
+class cmLocalUnixMakefileGenerator3;
/** \class cmDependsFortran
* \brief Dependency scanner for Fortran object files.
@@ -31,7 +31,7 @@ public:
path from the build directory to the target file, the source
file from which to start scanning, the include file search
path, and the target directory. */
- cmDependsFortran(cmLocalGenerator* lg);
+ cmDependsFortran(cmLocalUnixMakefileGenerator3* lg);
/** Virtual destructor to cleanup subclasses properly. */
~cmDependsFortran() override;
diff --git a/Source/cmExtraCodeLiteGenerator.cxx b/Source/cmExtraCodeLiteGenerator.cxx
index de40c77..bf7555d 100644
--- a/Source/cmExtraCodeLiteGenerator.cxx
+++ b/Source/cmExtraCodeLiteGenerator.cxx
@@ -204,9 +204,7 @@ std::string cmExtraCodeLiteGenerator::CollectSourceFiles(
case cmStateEnums::STATIC_LIBRARY: {
projectType = "Static Library";
} break;
- case cmStateEnums::SHARED_LIBRARY: {
- projectType = "Dynamic Library";
- } break;
+ case cmStateEnums::SHARED_LIBRARY:
case cmStateEnums::MODULE_LIBRARY: {
projectType = "Dynamic Library";
} break;
diff --git a/Source/cmExtraEclipseCDT4Generator.cxx b/Source/cmExtraEclipseCDT4Generator.cxx
index 1c5bcaa..b65f097 100644
--- a/Source/cmExtraEclipseCDT4Generator.cxx
+++ b/Source/cmExtraEclipseCDT4Generator.cxx
@@ -981,7 +981,6 @@ void cmExtraEclipseCDT4Generator::CreateCProjectFile() const
}
} break;
case cmStateEnums::INTERFACE_LIBRARY:
- break;
default:
break;
}
diff --git a/Source/cmExtraKateGenerator.cxx b/Source/cmExtraKateGenerator.cxx
index 271bbee..01fac5a 100644
--- a/Source/cmExtraKateGenerator.cxx
+++ b/Source/cmExtraKateGenerator.cxx
@@ -129,9 +129,8 @@ void cmExtraKateGenerator::WriteTargets(const cmLocalGenerator& lg,
if (targetName == "edit_cache") {
const char* editCommand =
localGen->GetMakefile()->GetDefinition("CMAKE_EDIT_COMMAND");
- if (editCommand == nullptr) {
- insertTarget = false;
- } else if (strstr(editCommand, "ccmake") != nullptr) {
+ if (editCommand == nullptr ||
+ strstr(editCommand, "ccmake") != nullptr) {
insertTarget = false;
}
}
@@ -274,7 +273,7 @@ std::string cmExtraKateGenerator::GenerateProjectName(
const std::string& name, const std::string& type,
const std::string& path) const
{
- return name + (type.empty() ? "" : "-") + type + "@" + path;
+ return name + (type.empty() ? "" : "-") + type + '@' + path;
}
std::string cmExtraKateGenerator::GetPathBasename(
diff --git a/Source/cmExtraSublimeTextGenerator.cxx b/Source/cmExtraSublimeTextGenerator.cxx
index 5b136e2..6dbc7b7 100644
--- a/Source/cmExtraSublimeTextGenerator.cxx
+++ b/Source/cmExtraSublimeTextGenerator.cxx
@@ -23,6 +23,8 @@
#include "cmSystemTools.h"
#include "cmake.h"
+using cmProp = const std::string*; // just to silence IWYU
+
/*
Sublime Text 2 Generator
Author: Morné Chamberlain
@@ -358,14 +360,14 @@ std::string cmExtraSublimeTextGenerator::ComputeFlagsForObject(
language);
const std::string COMPILE_FLAGS("COMPILE_FLAGS");
- if (const char* cflags = source->GetProperty(COMPILE_FLAGS)) {
- lg->AppendFlags(flags, genexInterpreter.Evaluate(cflags, COMPILE_FLAGS));
+ if (cmProp cflags = source->GetProperty(COMPILE_FLAGS)) {
+ lg->AppendFlags(flags, genexInterpreter.Evaluate(*cflags, COMPILE_FLAGS));
}
const std::string COMPILE_OPTIONS("COMPILE_OPTIONS");
- if (const char* coptions = source->GetProperty(COMPILE_OPTIONS)) {
+ if (cmProp coptions = source->GetProperty(COMPILE_OPTIONS)) {
lg->AppendCompileOptions(
- flags, genexInterpreter.Evaluate(coptions, COMPILE_OPTIONS));
+ flags, genexInterpreter.Evaluate(*coptions, COMPILE_OPTIONS));
}
return flags;
@@ -387,17 +389,17 @@ std::string cmExtraSublimeTextGenerator::ComputeDefines(
// Add preprocessor definitions for this target and configuration.
lg->GetTargetDefines(target, config, language, defines);
const std::string COMPILE_DEFINITIONS("COMPILE_DEFINITIONS");
- if (const char* compile_defs = source->GetProperty(COMPILE_DEFINITIONS)) {
+ if (cmProp compile_defs = source->GetProperty(COMPILE_DEFINITIONS)) {
lg->AppendDefines(
- defines, genexInterpreter.Evaluate(compile_defs, COMPILE_DEFINITIONS));
+ defines, genexInterpreter.Evaluate(*compile_defs, COMPILE_DEFINITIONS));
}
std::string defPropName =
cmStrCat("COMPILE_DEFINITIONS_", cmSystemTools::UpperCase(config));
- if (const char* config_compile_defs = source->GetProperty(defPropName)) {
+ if (cmProp config_compile_defs = source->GetProperty(defPropName)) {
lg->AppendDefines(
defines,
- genexInterpreter.Evaluate(config_compile_defs, COMPILE_DEFINITIONS));
+ genexInterpreter.Evaluate(*config_compile_defs, COMPILE_DEFINITIONS));
}
std::string definesString;
@@ -419,9 +421,9 @@ std::string cmExtraSublimeTextGenerator::ComputeIncludes(
// Add include directories for this source file
const std::string INCLUDE_DIRECTORIES("INCLUDE_DIRECTORIES");
- if (const char* cincludes = source->GetProperty(INCLUDE_DIRECTORIES)) {
+ if (cmProp cincludes = source->GetProperty(INCLUDE_DIRECTORIES)) {
lg->AppendIncludeDirectories(
- includes, genexInterpreter.Evaluate(cincludes, INCLUDE_DIRECTORIES),
+ includes, genexInterpreter.Evaluate(*cincludes, INCLUDE_DIRECTORIES),
*source);
}
diff --git a/Source/cmFileAPICodemodel.cxx b/Source/cmFileAPICodemodel.cxx
index 70f5847..f4237cb 100644
--- a/Source/cmFileAPICodemodel.cxx
+++ b/Source/cmFileAPICodemodel.cxx
@@ -855,8 +855,8 @@ CompileData Target::BuildCompileData(cmSourceFile* sf)
fd.Language);
const std::string COMPILE_FLAGS("COMPILE_FLAGS");
- if (const char* cflags = sf->GetProperty(COMPILE_FLAGS)) {
- std::string flags = genexInterpreter.Evaluate(cflags, COMPILE_FLAGS);
+ if (cmProp cflags = sf->GetProperty(COMPILE_FLAGS)) {
+ std::string flags = genexInterpreter.Evaluate(*cflags, COMPILE_FLAGS);
fd.Flags.emplace_back(std::move(flags), JBTIndex());
}
const std::string COMPILE_OPTIONS("COMPILE_OPTIONS");
@@ -949,10 +949,10 @@ CompileData Target::BuildCompileData(cmSourceFile* sf)
std::set<std::string> configFileDefines;
const std::string defPropName =
"COMPILE_DEFINITIONS_" + cmSystemTools::UpperCase(this->Config);
- if (const char* config_defs = sf->GetProperty(defPropName)) {
+ if (cmProp config_defs = sf->GetProperty(defPropName)) {
lg->AppendDefines(
configFileDefines,
- genexInterpreter.Evaluate(config_defs, COMPILE_DEFINITIONS));
+ genexInterpreter.Evaluate(*config_defs, COMPILE_DEFINITIONS));
}
fd.Defines.reserve(fileDefines.size() + configFileDefines.size());
diff --git a/Source/cmFindPackageCommand.cxx b/Source/cmFindPackageCommand.cxx
index e996327..d1517fe 100644
--- a/Source/cmFindPackageCommand.cxx
+++ b/Source/cmFindPackageCommand.cxx
@@ -279,9 +279,13 @@ bool cmFindPackageCommand::InitialPass(std::vector<std::string> const& args)
} else if (args[i] == "MODULE") {
moduleArgs.insert(i);
doing = DoingNone;
+ // XXX(clang-tidy): https://bugs.llvm.org/show_bug.cgi?id=44165
+ // NOLINTNEXTLINE(bugprone-branch-clone)
} else if (args[i] == "CONFIG") {
configArgs.insert(i);
doing = DoingNone;
+ // XXX(clang-tidy): https://bugs.llvm.org/show_bug.cgi?id=44165
+ // NOLINTNEXTLINE(bugprone-branch-clone)
} else if (args[i] == "NO_MODULE") {
configArgs.insert(i);
doing = DoingNone;
@@ -318,6 +322,8 @@ bool cmFindPackageCommand::InitialPass(std::vector<std::string> const& args)
this->NoSystemRegistry = true;
configArgs.insert(i);
doing = DoingNone;
+ // XXX(clang-tidy): https://bugs.llvm.org/show_bug.cgi?id=44165
+ // NOLINTNEXTLINE(bugprone-branch-clone)
} else if (args[i] == "NO_CMAKE_BUILDS_PATH") {
// Ignore legacy option.
configArgs.insert(i);
diff --git a/Source/cmFindProgramCommand.cxx b/Source/cmFindProgramCommand.cxx
index 4b88bea..599b1d2 100644
--- a/Source/cmFindProgramCommand.cxx
+++ b/Source/cmFindProgramCommand.cxx
@@ -85,7 +85,7 @@ struct cmFindProgramHelper
this->TestNameExt = cmStrCat(name, ext);
this->TestPath =
cmSystemTools::CollapseFullPath(this->TestNameExt, path);
- bool exists = cmSystemTools::FileExists(this->TestPath, true);
+ bool exists = cmSystemTools::FileIsExecutable(this->TestPath);
exists ? this->DebugSearches.FoundAt(this->TestPath)
: this->DebugSearches.FailedAt(this->TestPath);
if (exists) {
diff --git a/Source/cmGeneratorTarget.cxx b/Source/cmGeneratorTarget.cxx
index 611f7b0..b424b90 100644
--- a/Source/cmGeneratorTarget.cxx
+++ b/Source/cmGeneratorTarget.cxx
@@ -1227,7 +1227,6 @@ std::string cmGeneratorTarget::EvaluateInterfaceProperty(
return result;
case cmGeneratorExpressionDAGChecker::CYCLIC_REFERENCE:
// No error. We just skip cyclic references.
- return result;
case cmGeneratorExpressionDAGChecker::ALREADY_SEEN:
// No error. We have already seen this transitive property.
return result;
@@ -1295,10 +1294,9 @@ std::string AddSwiftInterfaceIncludeDirectories(
dag.ReportError(nullptr,
"$<TARGET_PROPERTY:" + target->GetName() +
",Swift_MODULE_DIRECTORY>");
- return "";
+ CM_FALLTHROUGH;
case cmGeneratorExpressionDAGChecker::CYCLIC_REFERENCE:
// No error. We just skip cyclic references.
- return "";
case cmGeneratorExpressionDAGChecker::ALREADY_SEEN:
// No error. We have already seen this transitive property.
return "";
@@ -1689,10 +1687,14 @@ void cmGeneratorTarget::ComputeKindedSources(KindedSources& files,
std::string ext = cmSystemTools::LowerCase(sf->GetExtension());
if (sf->GetCustomCommand()) {
kind = SourceKindCustomCommand;
+ // XXX(clang-tidy): https://bugs.llvm.org/show_bug.cgi?id=44165
+ // NOLINTNEXTLINE(bugprone-branch-clone)
} else if (this->Target->GetType() == cmStateEnums::UTILITY) {
kind = SourceKindExtra;
} else if (this->IsSourceFilePartOfUnityBatch(sf->ResolveFullPath())) {
kind = SourceKindUnityBatched;
+ // XXX(clang-tidy): https://bugs.llvm.org/show_bug.cgi?id=44165
+ // NOLINTNEXTLINE(bugprone-branch-clone)
} else if (sf->GetPropertyAsBool("HEADER_FILE_ONLY")) {
kind = SourceKindHeader;
} else if (sf->GetPropertyAsBool("EXTERNAL_OBJECT")) {
@@ -2837,8 +2839,8 @@ void cmTargetTraceDependencies::Trace()
this->CurrentEntry = &this->GeneratorTarget->SourceDepends[sf];
// Queue dependencies added explicitly by the user.
- if (const char* additionalDeps = sf->GetProperty("OBJECT_DEPENDS")) {
- std::vector<std::string> objDeps = cmExpandedList(additionalDeps);
+ if (cmProp additionalDeps = sf->GetProperty("OBJECT_DEPENDS")) {
+ std::vector<std::string> objDeps = cmExpandedList(*additionalDeps);
for (std::string& objDep : objDeps) {
if (cmSystemTools::FileIsFullPath(objDep)) {
objDep = cmSystemTools::CollapseFullPath(objDep);
@@ -3083,6 +3085,95 @@ void cmGeneratorTarget::GetAppleArchs(const std::string& config,
}
}
+void cmGeneratorTarget::AddCUDAArchitectureFlags(std::string& flags) const
+{
+ struct CudaArchitecture
+ {
+ std::string name;
+ bool real{ true };
+ bool virtual_{ true };
+ };
+ std::vector<CudaArchitecture> architectures;
+
+ {
+ std::vector<std::string> options;
+ cmExpandList(this->GetSafeProperty("CUDA_ARCHITECTURES"), options);
+
+ if (options.empty()) {
+ switch (this->GetPolicyStatusCMP0104()) {
+ case cmPolicies::WARN:
+ if (!this->LocalGenerator->GetCMakeInstance()->GetIsInTryCompile()) {
+ this->Makefile->IssueMessage(
+ MessageType::AUTHOR_WARNING,
+ cmPolicies::GetPolicyWarning(cmPolicies::CMP0104) +
+ "\nCUDA_ARCHITECTURES is empty for target \"" +
+ this->GetName() + "\".");
+ }
+ CM_FALLTHROUGH;
+ case cmPolicies::OLD:
+ break;
+ default:
+ this->Makefile->IssueMessage(
+ MessageType::FATAL_ERROR,
+ "CUDA_ARCHITECTURES is empty for target \"" + this->GetName() +
+ "\".");
+ }
+ }
+
+ for (std::string& option : options) {
+ CudaArchitecture architecture;
+
+ // Architecture name is up to the first specifier.
+ std::size_t pos = option.find_first_of('-');
+ architecture.name = option.substr(0, pos);
+
+ if (pos != std::string::npos) {
+ cm::string_view specifier{ option.c_str() + pos + 1,
+ option.length() - pos - 1 };
+
+ if (specifier == "real") {
+ architecture.real = true;
+ architecture.virtual_ = false;
+ } else if (specifier == "virtual") {
+ architecture.real = false;
+ architecture.virtual_ = true;
+ } else {
+ this->Makefile->IssueMessage(
+ MessageType::FATAL_ERROR,
+ "Uknown CUDA architecture specifier \"" + std::string(specifier) +
+ "\".");
+ }
+ }
+
+ architectures.emplace_back(architecture);
+ }
+ }
+
+ std::string const& compiler =
+ this->Makefile->GetSafeDefinition("CMAKE_CUDA_COMPILER_ID");
+
+ if (compiler == "NVIDIA") {
+ for (CudaArchitecture& architecture : architectures) {
+ flags +=
+ " --generate-code=arch=compute_" + architecture.name + ",code=[";
+
+ if (architecture.virtual_) {
+ flags += "compute_" + architecture.name;
+
+ if (architecture.real) {
+ flags += ",";
+ }
+ }
+
+ if (architecture.real) {
+ flags += "sm_" + architecture.name;
+ }
+
+ flags += "]";
+ }
+ }
+}
+
//----------------------------------------------------------------------------
std::string cmGeneratorTarget::GetFeatureSpecificLinkRuleVariable(
std::string const& var, std::string const& lang,
@@ -4705,16 +4796,16 @@ cmGeneratorTarget::GetTargetSourceFileFlags(const cmSourceFile* sf) const
} else {
// Handle the MACOSX_PACKAGE_LOCATION property on source files that
// were not listed in one of the other lists.
- if (const char* location = sf->GetProperty("MACOSX_PACKAGE_LOCATION")) {
- flags.MacFolder = location;
+ if (cmProp location = sf->GetProperty("MACOSX_PACKAGE_LOCATION")) {
+ flags.MacFolder = location->c_str();
const bool stripResources =
this->GlobalGenerator->ShouldStripResourcePath(this->Makefile);
- if (strcmp(location, "Resources") == 0) {
+ if (*location == "Resources") {
flags.Type = cmGeneratorTarget::SourceFileTypeResource;
if (stripResources) {
flags.MacFolder = "";
}
- } else if (cmHasLiteralPrefix(location, "Resources/")) {
+ } else if (cmHasLiteralPrefix(*location, "Resources/")) {
flags.Type = cmGeneratorTarget::SourceFileTypeDeepResource;
if (stripResources) {
flags.MacFolder += strlen("Resources/");
diff --git a/Source/cmGeneratorTarget.h b/Source/cmGeneratorTarget.h
index 9136928..7cd253d 100644
--- a/Source/cmGeneratorTarget.h
+++ b/Source/cmGeneratorTarget.h
@@ -421,6 +421,8 @@ public:
void GetAppleArchs(const std::string& config,
std::vector<std::string>& archVec) const;
+ void AddCUDAArchitectureFlags(std::string& flags) const;
+
std::string GetFeatureSpecificLinkRuleVariable(
std::string const& var, std::string const& lang,
std::string const& config) const;
diff --git a/Source/cmGhsMultiTargetGenerator.cxx b/Source/cmGhsMultiTargetGenerator.cxx
index deb722f..f0c6d48 100644
--- a/Source/cmGhsMultiTargetGenerator.cxx
+++ b/Source/cmGhsMultiTargetGenerator.cxx
@@ -456,9 +456,9 @@ void cmGhsMultiTargetGenerator::WriteSourceProperty(
std::ostream& fout, const cmSourceFile* sf, std::string const& propName,
std::string const& propFlag)
{
- const char* prop = sf->GetProperty(propName);
+ cmProp prop = sf->GetProperty(propName);
if (prop) {
- std::vector<std::string> list = cmExpandedList(prop);
+ std::vector<std::string> list = cmExpandedList(*prop);
for (const std::string& p : list) {
fout << " " << propFlag << p << '\n';
}
@@ -708,9 +708,9 @@ void cmGhsMultiTargetGenerator::WriteCustomCommandLine(
void cmGhsMultiTargetGenerator::WriteObjectLangOverride(
std::ostream& fout, const cmSourceFile* sourceFile)
{
- const char* rawLangProp = sourceFile->GetProperty("LANGUAGE");
+ cmProp rawLangProp = sourceFile->GetProperty("LANGUAGE");
if (nullptr != rawLangProp) {
- std::string sourceLangProp(rawLangProp);
+ std::string sourceLangProp(*rawLangProp);
std::string const& extension = sourceFile->GetExtension();
if ("CXX" == sourceLangProp && ("c" == extension || "C" == extension)) {
fout << " -dotciscxx\n";
diff --git a/Source/cmGlobalBorlandMakefileGenerator.h b/Source/cmGlobalBorlandMakefileGenerator.h
index 9af0eac..3c97955 100644
--- a/Source/cmGlobalBorlandMakefileGenerator.h
+++ b/Source/cmGlobalBorlandMakefileGenerator.h
@@ -46,6 +46,7 @@ public:
bool AllowNotParallel() const override { return false; }
bool AllowDeleteOnError() const override { return false; }
+ bool CanEscapeOctothorpe() const override { return true; }
protected:
std::vector<GeneratedMakeCommand> GenerateBuildCommand(
diff --git a/Source/cmGlobalGenerator.cxx b/Source/cmGlobalGenerator.cxx
index ccbbf53..8505d43 100644
--- a/Source/cmGlobalGenerator.cxx
+++ b/Source/cmGlobalGenerator.cxx
@@ -2253,10 +2253,12 @@ std::string cmGlobalGenerator::IndexGeneratorTargetUniquely(
// Use a ":" prefix to avoid conflict with project-defined targets.
// We must satisfy cmGeneratorExpression::IsValidTargetName so use no
// other special characters.
- char buf[1 + sizeof(gt) * 2];
+ constexpr size_t sizeof_ptr =
+ sizeof(gt); // NOLINT(bugprone-sizeof-expression)
+ char buf[1 + sizeof_ptr * 2];
char* b = buf;
*b++ = ':';
- for (size_t i = 0; i < sizeof(gt); ++i) {
+ for (size_t i = 0; i < sizeof_ptr; ++i) {
unsigned char const c = reinterpret_cast<unsigned char const*>(&gt)[i];
*b++ = hexDigits[(c & 0xf0) >> 4];
*b++ = hexDigits[(c & 0x0f)];
@@ -2543,6 +2545,7 @@ void cmGlobalGenerator::AddGlobalTarget_EditCache(
singleLine.push_back("No interactive CMake dialog available.");
gti.Message = "No interactive CMake dialog available...";
gti.UsesTerminal = false;
+ gti.StdPipesUTF8 = true;
}
gti.CommandLines.push_back(std::move(singleLine));
@@ -2567,6 +2570,7 @@ void cmGlobalGenerator::AddGlobalTarget_RebuildCache(
singleLine.push_back("-S$(CMAKE_SOURCE_DIR)");
singleLine.push_back("-B$(CMAKE_BINARY_DIR)");
gti.CommandLines.push_back(std::move(singleLine));
+ gti.StdPipesUTF8 = true;
targets.push_back(std::move(gti));
}
@@ -2603,6 +2607,7 @@ void cmGlobalGenerator::AddGlobalTarget_Install(
gti.Name = this->GetInstallTargetName();
gti.Message = "Install the project...";
gti.UsesTerminal = true;
+ gti.StdPipesUTF8 = true;
cmCustomCommandLine singleLine;
if (this->GetPreinstallTargetName()) {
gti.Depends.emplace_back(this->GetPreinstallTargetName());
@@ -2714,7 +2719,8 @@ cmTarget cmGlobalGenerator::CreateGlobalTarget(GlobalTargetInfo const& gti,
std::vector<std::string> no_depends;
// Store the custom command in the target.
cmCustomCommand cc(no_outputs, no_byproducts, no_depends, gti.CommandLines,
- cmListFileBacktrace(), nullptr, gti.WorkingDir.c_str());
+ cmListFileBacktrace(), nullptr, gti.WorkingDir.c_str(),
+ gti.StdPipesUTF8);
cc.SetUsesTerminal(gti.UsesTerminal);
target.AddPostBuildCommand(std::move(cc));
if (!gti.Message.empty()) {
@@ -3103,10 +3109,10 @@ void cmGlobalGenerator::WriteSummary(cmGeneratorTarget* target)
std::string const& sfp = sf->ResolveFullPath();
fout << sfp << "\n";
lj_source["file"] = sfp;
- if (const char* svalue = sf->GetProperty("LABELS")) {
+ if (cmProp svalue = sf->GetProperty("LABELS")) {
labels.clear();
Json::Value& lj_source_labels = lj_source["labels"] = Json::arrayValue;
- cmExpandList(svalue, labels);
+ cmExpandList(*svalue, labels);
for (std::string const& label : labels) {
fout << " " << label << "\n";
lj_source_labels.append(label);
diff --git a/Source/cmGlobalGenerator.h b/Source/cmGlobalGenerator.h
index 70e43b5..a76ab3c 100644
--- a/Source/cmGlobalGenerator.h
+++ b/Source/cmGlobalGenerator.h
@@ -554,6 +554,7 @@ protected:
std::string WorkingDir;
bool UsesTerminal = false;
bool PerConfig = true;
+ bool StdPipesUTF8 = false;
};
void CreateDefaultGlobalTargets(std::vector<GlobalTargetInfo>& targets);
diff --git a/Source/cmGlobalNinjaGenerator.cxx b/Source/cmGlobalNinjaGenerator.cxx
index 5a31ab2..b33afff 100644
--- a/Source/cmGlobalNinjaGenerator.cxx
+++ b/Source/cmGlobalNinjaGenerator.cxx
@@ -436,8 +436,6 @@ cmGlobalNinjaGenerator::cmGlobalNinjaGenerator(cmake* cm)
#ifdef _WIN32
cm->GetState()->SetWindowsShell(true);
#endif
- // // Ninja is not ported to non-Unix OS yet.
- // this->ForceUnixPaths = true;
this->FindMakeProgramFile = "CMakeNinjaFindMake.cmake";
}
diff --git a/Source/cmGlobalUnixMakefileGenerator3.cxx b/Source/cmGlobalUnixMakefileGenerator3.cxx
index 582877f..5363ea5 100644
--- a/Source/cmGlobalUnixMakefileGenerator3.cxx
+++ b/Source/cmGlobalUnixMakefileGenerator3.cxx
@@ -117,6 +117,12 @@ void cmGlobalUnixMakefileGenerator3::ComputeTargetObjectDirectory(
gt->ObjectDirectory = dir;
}
+bool cmGlobalUnixMakefileGenerator3::CanEscapeOctothorpe() const
+{
+ // Make tools that use UNIX-style '/' paths also support '\' escaping.
+ return this->ForceUnixPaths;
+}
+
void cmGlobalUnixMakefileGenerator3::Configure()
{
// Initialize CMAKE_EDIT_COMMAND cache entry.
@@ -480,6 +486,78 @@ void cmGlobalUnixMakefileGenerator3::WriteDirectoryRules2(
}
}
+namespace {
+std::string ConvertToMakefilePathForUnix(std::string const& path)
+{
+ std::string result;
+ result.reserve(path.size());
+ for (char c : path) {
+ switch (c) {
+ case '=':
+ // We provide 'EQUALS = =' to encode '=' in a non-assignment case.
+ result.append("$(EQUALS)");
+ break;
+ case '$':
+ result.append("$$");
+ break;
+ case '\\':
+ case ' ':
+ case '#':
+ result.push_back('\\');
+ CM_FALLTHROUGH;
+ default:
+ result.push_back(c);
+ break;
+ }
+ }
+ return result;
+}
+
+#if defined(_WIN32) && !defined(__CYGWIN__)
+std::string ConvertToMakefilePathForWindows(std::string const& path)
+{
+ bool const quote = path.find_first_of(" #") != std::string::npos;
+ std::string result;
+ result.reserve(path.size() + (quote ? 2 : 0));
+ if (quote) {
+ result.push_back('"');
+ }
+ for (char c : path) {
+ switch (c) {
+ case '=':
+ // We provide 'EQUALS = =' to encode '=' in a non-assignment case.
+ result.append("$(EQUALS)");
+ break;
+ case '$':
+ result.append("$$");
+ break;
+ case '/':
+ result.push_back('\\');
+ break;
+ default:
+ result.push_back(c);
+ break;
+ }
+ }
+ if (quote) {
+ result.push_back('"');
+ }
+ return result;
+}
+#endif
+}
+
+std::string cmGlobalUnixMakefileGenerator3::ConvertToMakefilePath(
+ std::string const& path) const
+{
+#if defined(_WIN32) && !defined(__CYGWIN__)
+ if (!this->ForceUnixPaths) {
+ return ConvertToMakefilePathForWindows(path);
+ }
+#endif
+ return ConvertToMakefilePathForUnix(path);
+}
+
std::vector<cmGlobalGenerator::GeneratedMakeCommand>
cmGlobalUnixMakefileGenerator3::GenerateBuildCommand(
const std::string& makeProgram, const std::string& /*projectName*/,
diff --git a/Source/cmGlobalUnixMakefileGenerator3.h b/Source/cmGlobalUnixMakefileGenerator3.h
index 19b2b85..1caa4b7 100644
--- a/Source/cmGlobalUnixMakefileGenerator3.h
+++ b/Source/cmGlobalUnixMakefileGenerator3.h
@@ -136,6 +136,12 @@ public:
or dependencies. */
std::string GetEmptyRuleHackDepends() { return this->EmptyRuleHackDepends; }
+ /**
+ * Convert a file path to a Makefile target or dependency with
+ * escaping and quoting suitable for the generator's make tool.
+ */
+ std::string ConvertToMakefilePath(std::string const& path) const;
+
// change the build command for speed
std::vector<GeneratedMakeCommand> GenerateBuildCommand(
const std::string& makeProgram, const std::string& projectName,
@@ -157,6 +163,9 @@ public:
/** Does the make tool tolerate .DELETE_ON_ERROR? */
virtual bool AllowDeleteOnError() const { return true; }
+ /** Does the make tool interpret '\#' as '#'? */
+ virtual bool CanEscapeOctothorpe() const;
+
bool IsIPOSupported() const override { return true; }
void ComputeTargetObjectDirectory(cmGeneratorTarget* gt) const override;
diff --git a/Source/cmGlobalVisualStudio8Generator.cxx b/Source/cmGlobalVisualStudio8Generator.cxx
index fa0e935..1df76ca 100644
--- a/Source/cmGlobalVisualStudio8Generator.cxx
+++ b/Source/cmGlobalVisualStudio8Generator.cxx
@@ -142,6 +142,9 @@ bool cmGlobalVisualStudio8Generator::AddCheckTarget()
// Add a custom rule to re-run CMake if any input files changed.
{
+ // The custom rule runs cmake so set UTF-8 pipes.
+ bool stdPipesUTF8 = true;
+
// Collect the input files used to generate all targets in this
// project.
std::vector<std::string> listFiles;
@@ -160,7 +163,7 @@ bool cmGlobalVisualStudio8Generator::AddCheckTarget()
lg.AddCustomCommandToTarget(
CMAKE_CHECK_BUILD_SYSTEM_TARGET, byproducts, no_depends,
verifyCommandLines, cmCustomCommandType::PRE_BUILD,
- "Checking File Globs", no_working_directory, false);
+ "Checking File Globs", no_working_directory, stdPipesUTF8);
// Ensure ZERO_CHECK always runs in Visual Studio using MSBuild,
// otherwise the prebuild command will not be run.
@@ -192,7 +195,8 @@ bool cmGlobalVisualStudio8Generator::AddCheckTarget()
if (cmSourceFile* file = lg.AddCustomCommandToOutput(
stamps, no_byproducts, listFiles, no_main_dependency,
no_implicit_depends, commandLines, "Checking Build System",
- no_working_directory, true, false)) {
+ no_working_directory, true, false, false, false, "", "",
+ stdPipesUTF8)) {
gt->AddSource(file->ResolveFullPath());
} else {
cmSystemTools::Error("Error adding rule for " + stamps[0]);
diff --git a/Source/cmGlobalVisualStudioGenerator.cxx b/Source/cmGlobalVisualStudioGenerator.cxx
index d2f9760..b9f4609 100644
--- a/Source/cmGlobalVisualStudioGenerator.cxx
+++ b/Source/cmGlobalVisualStudioGenerator.cxx
@@ -932,7 +932,7 @@ void cmGlobalVisualStudioGenerator::AddSymbolExportCommand(
{ cmakeCommand, "-E", "__create_def", mdi->DefFile, objs_file });
cmCustomCommand command(outputs, empty, empty, commandLines,
gt->Target->GetMakefile()->GetBacktrace(),
- "Auto build dll exports", ".");
+ "Auto build dll exports", ".", true);
commands.push_back(std::move(command));
}
diff --git a/Source/cmGlobalXCodeGenerator.cxx b/Source/cmGlobalXCodeGenerator.cxx
index e74d618..c0068b4 100644
--- a/Source/cmGlobalXCodeGenerator.cxx
+++ b/Source/cmGlobalXCodeGenerator.cxx
@@ -770,11 +770,15 @@ public:
XCodeGeneratorExpressionInterpreter& operator=(
XCodeGeneratorExpressionInterpreter const&) = delete;
- using cmGeneratorExpressionInterpreter::Evaluate;
-
const std::string& Evaluate(const char* expression,
const std::string& property)
{
+ return this->Evaluate(std::string(expression ? expression : ""), property);
+ }
+
+ const std::string& Evaluate(const std::string& expression,
+ const std::string& property)
+ {
const std::string& processed =
this->cmGeneratorExpressionInterpreter::Evaluate(expression, property);
if (this->CompiledGeneratorExpression->GetHadContextSensitiveCondition()) {
@@ -805,8 +809,9 @@ cmXCodeObject* cmGlobalXCodeGenerator::CreateXCodeSourceFile(
// Add flags from target and source file properties.
std::string flags;
- const char* srcfmt = sf->GetProperty("Fortran_FORMAT");
- switch (cmOutputConverter::GetFortranFormat(srcfmt)) {
+ cmProp srcfmt = sf->GetProperty("Fortran_FORMAT");
+ switch (
+ cmOutputConverter::GetFortranFormat(srcfmt ? srcfmt->c_str() : nullptr)) {
case cmOutputConverter::FortranFormatFixed:
flags = "-fixed " + flags;
break;
@@ -817,22 +822,22 @@ cmXCodeObject* cmGlobalXCodeGenerator::CreateXCodeSourceFile(
break;
}
const std::string COMPILE_FLAGS("COMPILE_FLAGS");
- if (const char* cflags = sf->GetProperty(COMPILE_FLAGS)) {
- lg->AppendFlags(flags, genexInterpreter.Evaluate(cflags, COMPILE_FLAGS));
+ if (cmProp cflags = sf->GetProperty(COMPILE_FLAGS)) {
+ lg->AppendFlags(flags, genexInterpreter.Evaluate(*cflags, COMPILE_FLAGS));
}
const std::string COMPILE_OPTIONS("COMPILE_OPTIONS");
- if (const char* coptions = sf->GetProperty(COMPILE_OPTIONS)) {
+ if (cmProp coptions = sf->GetProperty(COMPILE_OPTIONS)) {
lg->AppendCompileOptions(
- flags, genexInterpreter.Evaluate(coptions, COMPILE_OPTIONS));
+ flags, genexInterpreter.Evaluate(*coptions, COMPILE_OPTIONS));
}
// Add per-source definitions.
BuildObjectListOrString flagsBuild(this, false);
const std::string COMPILE_DEFINITIONS("COMPILE_DEFINITIONS");
- if (const char* compile_defs = sf->GetProperty(COMPILE_DEFINITIONS)) {
+ if (cmProp compile_defs = sf->GetProperty(COMPILE_DEFINITIONS)) {
this->AppendDefines(
flagsBuild,
- genexInterpreter.Evaluate(compile_defs, COMPILE_DEFINITIONS).c_str(),
+ genexInterpreter.Evaluate(*compile_defs, COMPILE_DEFINITIONS).c_str(),
true);
}
@@ -850,9 +855,9 @@ cmXCodeObject* cmGlobalXCodeGenerator::CreateXCodeSourceFile(
// Add per-source include directories.
std::vector<std::string> includes;
const std::string INCLUDE_DIRECTORIES("INCLUDE_DIRECTORIES");
- if (const char* cincludes = sf->GetProperty(INCLUDE_DIRECTORIES)) {
+ if (cmProp cincludes = sf->GetProperty(INCLUDE_DIRECTORIES)) {
lg->AppendIncludeDirectories(
- includes, genexInterpreter.Evaluate(cincludes, INCLUDE_DIRECTORIES),
+ includes, genexInterpreter.Evaluate(*cincludes, INCLUDE_DIRECTORIES),
*sf);
}
lg->AppendFlags(flags, lg->GetIncludeFlags(includes, gtgt, lang, true));
@@ -881,10 +886,10 @@ cmXCodeObject* cmGlobalXCodeGenerator::CreateXCodeSourceFile(
}
// Add user-specified file attributes.
- const char* extraFileAttributes = sf->GetProperty("XCODE_FILE_ATTRIBUTES");
+ cmProp extraFileAttributes = sf->GetProperty("XCODE_FILE_ATTRIBUTES");
if (extraFileAttributes) {
// Expand the list of attributes.
- std::vector<std::string> attributes = cmExpandedList(extraFileAttributes);
+ std::vector<std::string> attributes = cmExpandedList(*extraFileAttributes);
// Store the attributes.
for (const auto& attribute : attributes) {
@@ -995,11 +1000,11 @@ cmXCodeObject* cmGlobalXCodeGenerator::CreateXCodeFileReferenceFromPath(
bool useLastKnownFileType = false;
std::string fileType;
if (sf) {
- if (const char* e = sf->GetProperty("XCODE_EXPLICIT_FILE_TYPE")) {
- fileType = e;
- } else if (const char* l = sf->GetProperty("XCODE_LAST_KNOWN_FILE_TYPE")) {
+ if (cmProp e = sf->GetProperty("XCODE_EXPLICIT_FILE_TYPE")) {
+ fileType = *e;
+ } else if (cmProp l = sf->GetProperty("XCODE_LAST_KNOWN_FILE_TYPE")) {
useLastKnownFileType = true;
- fileType = l;
+ fileType = *l;
}
}
if (fileType.empty()) {
@@ -1464,6 +1469,7 @@ void cmGlobalXCodeGenerator::CreateCustomCommands(
cmStrCat("$<TARGET_SONAME_FILE:", gtgt->GetName(), '>');
std::string str_link_file =
cmStrCat("$<TARGET_LINKER_FILE:", gtgt->GetName(), '>');
+ bool stdPipesUTF8 = true;
cmCustomCommandLines cmd = cmMakeSingleCommandLine(
{ cmSystemTools::GetCMakeCommand(), "-E", "cmake_symlink_library",
str_file, str_so_file, str_link_file });
@@ -1471,7 +1477,7 @@ void cmGlobalXCodeGenerator::CreateCustomCommands(
cmCustomCommand command(
std::vector<std::string>(), std::vector<std::string>(),
std::vector<std::string>(), cmd, this->CurrentMakefile->GetBacktrace(),
- "Creating symlinks", "");
+ "Creating symlinks", "", stdPipesUTF8);
postbuild.push_back(std::move(command));
}
@@ -3550,7 +3556,7 @@ std::string cmGlobalXCodeGenerator::RelativeToBinary(const std::string& p)
std::string cmGlobalXCodeGenerator::XCodeEscapePath(const std::string& p)
{
- if (p.find(' ') != std::string::npos) {
+ if (p.find_first_of(" []") != std::string::npos) {
std::string t = cmStrCat('"', p, '"');
return t;
}
diff --git a/Source/cmInstallCommand.cxx b/Source/cmInstallCommand.cxx
index 704db66..c9b22b6 100644
--- a/Source/cmInstallCommand.cxx
+++ b/Source/cmInstallCommand.cxx
@@ -661,7 +661,6 @@ bool HandleTargetsMode(std::vector<std::string> const& args,
// Nothing to do. An INTERFACE_LIBRARY can be installed, but the
// only effect of that is to make it exportable. It installs no
// other files itself.
- break;
default:
// This should never happen due to the above type check.
// Ignore the case.
diff --git a/Source/cmJsonObjects.cxx b/Source/cmJsonObjects.cxx
index 9ecf378..a4f78bc 100644
--- a/Source/cmJsonObjects.cxx
+++ b/Source/cmJsonObjects.cxx
@@ -275,14 +275,14 @@ static Json::Value DumpSourceFilesList(
std::string compileFlags = ld.Flags;
const std::string COMPILE_FLAGS("COMPILE_FLAGS");
- if (const char* cflags = file->GetProperty(COMPILE_FLAGS)) {
+ if (cmProp cflags = file->GetProperty(COMPILE_FLAGS)) {
lg->AppendFlags(compileFlags,
- genexInterpreter.Evaluate(cflags, COMPILE_FLAGS));
+ genexInterpreter.Evaluate(*cflags, COMPILE_FLAGS));
}
const std::string COMPILE_OPTIONS("COMPILE_OPTIONS");
- if (const char* coptions = file->GetProperty(COMPILE_OPTIONS)) {
+ if (cmProp coptions = file->GetProperty(COMPILE_OPTIONS)) {
lg->AppendCompileOptions(
- compileFlags, genexInterpreter.Evaluate(coptions, COMPILE_OPTIONS));
+ compileFlags, genexInterpreter.Evaluate(*coptions, COMPILE_OPTIONS));
}
fileData.Flags = compileFlags;
@@ -290,9 +290,9 @@ static Json::Value DumpSourceFilesList(
std::vector<std::string> includes;
const std::string INCLUDE_DIRECTORIES("INCLUDE_DIRECTORIES");
- if (const char* cincludes = file->GetProperty(INCLUDE_DIRECTORIES)) {
+ if (cmProp cincludes = file->GetProperty(INCLUDE_DIRECTORIES)) {
const std::string& evaluatedIncludes =
- genexInterpreter.Evaluate(cincludes, INCLUDE_DIRECTORIES);
+ genexInterpreter.Evaluate(*cincludes, INCLUDE_DIRECTORIES);
lg->AppendIncludeDirectories(includes, evaluatedIncludes, *file);
for (const auto& include : includes) {
@@ -309,17 +309,17 @@ static Json::Value DumpSourceFilesList(
const std::string COMPILE_DEFINITIONS("COMPILE_DEFINITIONS");
std::set<std::string> defines;
- if (const char* defs = file->GetProperty(COMPILE_DEFINITIONS)) {
+ if (cmProp defs = file->GetProperty(COMPILE_DEFINITIONS)) {
lg->AppendDefines(
- defines, genexInterpreter.Evaluate(defs, COMPILE_DEFINITIONS));
+ defines, genexInterpreter.Evaluate(*defs, COMPILE_DEFINITIONS));
}
const std::string defPropName =
"COMPILE_DEFINITIONS_" + cmSystemTools::UpperCase(config);
- if (const char* config_defs = file->GetProperty(defPropName)) {
+ if (cmProp config_defs = file->GetProperty(defPropName)) {
lg->AppendDefines(
defines,
- genexInterpreter.Evaluate(config_defs, COMPILE_DEFINITIONS));
+ genexInterpreter.Evaluate(*config_defs, COMPILE_DEFINITIONS));
}
defines.insert(ld.Defines.begin(), ld.Defines.end());
diff --git a/Source/cmListCommand.cxx b/Source/cmListCommand.cxx
index 5200a16..860b4da 100644
--- a/Source/cmListCommand.cxx
+++ b/Source/cmListCommand.cxx
@@ -1051,6 +1051,7 @@ public:
UNINITIALIZED,
STRING,
FILE_BASENAME,
+ NATURAL,
};
enum class CaseSensitivity
{
@@ -1074,10 +1075,25 @@ protected:
: nullptr;
}
+ using ComparisonFunction =
+ std::function<bool(const std::string&, const std::string&)>;
+ ComparisonFunction GetComparisonFunction(Compare compare)
+ {
+ if (compare == Compare::NATURAL) {
+ return std::function<bool(const std::string&, const std::string&)>(
+ [](const std::string& x, const std::string& y) {
+ return cmSystemTools::strverscmp(x, y) < 0;
+ });
+ }
+ return std::function<bool(const std::string&, const std::string&)>(
+ [](const std::string& x, const std::string& y) { return x < y; });
+ }
+
public:
cmStringSorter(Compare compare, CaseSensitivity caseSensitivity,
Order desc = Order::ASCENDING)
: filters{ GetCompareFilter(compare), GetCaseFilter(caseSensitivity) }
+ , sortMethod(GetComparisonFunction(compare))
, descending(desc == Order::DESCENDING)
{
}
@@ -1099,15 +1115,16 @@ public:
std::string bf = ApplyFilter(b);
bool result;
if (descending) {
- result = bf < af;
+ result = sortMethod(bf, af);
} else {
- result = af < bf;
+ result = sortMethod(af, bf);
}
return result;
}
protected:
StringFilter filters[2] = { nullptr, nullptr };
+ ComparisonFunction sortMethod;
bool descending;
};
@@ -1142,6 +1159,8 @@ bool HandleSortCommand(std::vector<std::string> const& args,
sortCompare = cmStringSorter::Compare::STRING;
} else if (argument == "FILE_BASENAME") {
sortCompare = cmStringSorter::Compare::FILE_BASENAME;
+ } else if (argument == "NATURAL") {
+ sortCompare = cmStringSorter::Compare::NATURAL;
} else {
std::string error =
cmStrCat(messageHint, "value \"", argument, "\" for option \"",
diff --git a/Source/cmLocalGenerator.cxx b/Source/cmLocalGenerator.cxx
index f5ca5f4..ca84f1e 100644
--- a/Source/cmLocalGenerator.cxx
+++ b/Source/cmLocalGenerator.cxx
@@ -1089,7 +1089,8 @@ cmTarget* cmLocalGenerator::AddCustomCommandToTarget(
const cmCustomCommandLines& commandLines, cmCustomCommandType type,
const char* comment, const char* workingDir, bool escapeOldStyle,
bool uses_terminal, const std::string& depfile, const std::string& job_pool,
- bool command_expand_lists, cmObjectLibraryCommands objLibCommands)
+ bool command_expand_lists, cmObjectLibraryCommands objLibCommands,
+ bool stdPipesUTF8)
{
cmTarget* t = this->Makefile->GetCustomCommandTarget(
target, objLibCommands, this->DirectoryBacktrace);
@@ -1100,7 +1101,7 @@ cmTarget* cmLocalGenerator::AddCustomCommandToTarget(
detail::AddCustomCommandToTarget(
*this, this->DirectoryBacktrace, cmCommandOrigin::Generator, t, byproducts,
depends, commandLines, type, comment, workingDir, escapeOldStyle,
- uses_terminal, depfile, job_pool, command_expand_lists);
+ uses_terminal, depfile, job_pool, command_expand_lists, stdPipesUTF8);
return t;
}
@@ -1110,14 +1111,14 @@ cmSourceFile* cmLocalGenerator::AddCustomCommandToOutput(
const std::string& main_dependency, const cmCustomCommandLines& commandLines,
const char* comment, const char* workingDir, bool replace,
bool escapeOldStyle, bool uses_terminal, bool command_expand_lists,
- const std::string& depfile, const std::string& job_pool)
+ const std::string& depfile, const std::string& job_pool, bool stdPipesUTF8)
{
std::vector<std::string> no_byproducts;
cmImplicitDependsList no_implicit_depends;
return this->AddCustomCommandToOutput(
{ output }, no_byproducts, depends, main_dependency, no_implicit_depends,
commandLines, comment, workingDir, replace, escapeOldStyle, uses_terminal,
- command_expand_lists, depfile, job_pool);
+ command_expand_lists, depfile, job_pool, stdPipesUTF8);
}
cmSourceFile* cmLocalGenerator::AddCustomCommandToOutput(
@@ -1128,7 +1129,7 @@ cmSourceFile* cmLocalGenerator::AddCustomCommandToOutput(
const cmCustomCommandLines& commandLines, const char* comment,
const char* workingDir, bool replace, bool escapeOldStyle,
bool uses_terminal, bool command_expand_lists, const std::string& depfile,
- const std::string& job_pool)
+ const std::string& job_pool, bool stdPipesUTF8)
{
// Make sure there is at least one output.
if (outputs.empty()) {
@@ -1140,7 +1141,7 @@ cmSourceFile* cmLocalGenerator::AddCustomCommandToOutput(
*this, this->DirectoryBacktrace, cmCommandOrigin::Generator, outputs,
byproducts, depends, main_dependency, implicit_depends, commandLines,
comment, workingDir, replace, escapeOldStyle, uses_terminal,
- command_expand_lists, depfile, job_pool);
+ command_expand_lists, depfile, job_pool, stdPipesUTF8);
}
cmTarget* cmLocalGenerator::AddUtilityCommand(
@@ -1149,7 +1150,7 @@ cmTarget* cmLocalGenerator::AddUtilityCommand(
const std::vector<std::string>& depends,
const cmCustomCommandLines& commandLines, bool escapeOldStyle,
const char* comment, bool uses_terminal, bool command_expand_lists,
- const std::string& job_pool)
+ const std::string& job_pool, bool stdPipesUTF8)
{
cmTarget* target =
this->Makefile->AddNewUtilityTarget(utilityName, excludeFromAll);
@@ -1163,7 +1164,7 @@ cmTarget* cmLocalGenerator::AddUtilityCommand(
*this, this->DirectoryBacktrace, cmCommandOrigin::Generator, target,
this->Makefile->GetUtilityOutput(target), workingDir, byproducts, depends,
commandLines, escapeOldStyle, comment, uses_terminal, command_expand_lists,
- job_pool);
+ job_pool, stdPipesUTF8);
return target;
}
@@ -1944,6 +1945,8 @@ void cmLocalGenerator::AddLanguageFlags(std::string& flags,
this->AppendFlags(flags, "-swift-version " + std::string(v));
}
}
+ } else if (lang == "CUDA") {
+ target->AddCUDAArchitectureFlags(flags);
}
// Add MSVC runtime library flags. This is activated by the presence
@@ -2070,11 +2073,9 @@ bool cmLocalGenerator::GetRealDependency(const std::string& inName,
case cmStateEnums::OBJECT_LIBRARY:
// An object library has no single file on which to depend.
// This was listed to get the target-level dependency.
- return false;
case cmStateEnums::INTERFACE_LIBRARY:
// An interface library has no file on which to depend.
// This was listed to get the target-level dependency.
- return false;
case cmStateEnums::UTILITY:
case cmStateEnums::GLOBAL_TARGET:
// A utility target has no file on which to depend. This was listed
@@ -2650,6 +2651,7 @@ void cmLocalGenerator::AddPchDependencies(cmGeneratorTarget* target)
file << "endif()\n";
}
+ bool stdPipesUTF8 = true;
cmCustomCommandLines commandLines = cmMakeSingleCommandLine(
{ cmSystemTools::GetCMakeCommand(),
cmStrCat("-DPDB_PREFIX=", pdb_prefix), "-P",
@@ -2668,14 +2670,16 @@ void cmLocalGenerator::AddPchDependencies(cmGeneratorTarget* target)
if (this->GetGlobalGenerator()->IsVisualStudio()) {
this->AddCustomCommandToTarget(
target->GetName(), outputs, no_deps, commandLines,
- cmCustomCommandType::PRE_BUILD, no_message,
- no_current_dir);
+ cmCustomCommandType::PRE_BUILD, no_message, no_current_dir,
+ true, false, "", "", false,
+ cmObjectLibraryCommands::Reject, stdPipesUTF8);
} else {
cmImplicitDependsList no_implicit_depends;
cmSourceFile* copy_rule = this->AddCustomCommandToOutput(
outputs, no_byproducts, no_deps, no_main_dependency,
no_implicit_depends, commandLines, no_message,
- no_current_dir);
+ no_current_dir, false, true, false, false, "", "",
+ stdPipesUTF8);
if (copy_rule) {
target->AddSource(copy_rule->ResolveFullPath());
@@ -3389,11 +3393,12 @@ std::string cmLocalGenerator::GetObjectFileNameWithoutTarget(
// Select a nice-looking reference to the source file to construct
// the object file name.
std::string objectName;
+ // XXX(clang-tidy): https://bugs.llvm.org/show_bug.cgi?id=44165
+ // NOLINTNEXTLINE(bugprone-branch-clone)
if ((relSource && !relBinary) || (subSource && !subBinary)) {
objectName = relFromSource;
- } else if ((relBinary && !relSource) || (subBinary && !subSource)) {
- objectName = relFromBinary;
- } else if (relFromBinary.length() < relFromSource.length()) {
+ } else if ((relBinary && !relSource) || (subBinary && !subSource) ||
+ relFromBinary.length() < relFromSource.length()) {
objectName = relFromBinary;
} else {
objectName = relFromSource;
@@ -3411,12 +3416,12 @@ std::string cmLocalGenerator::GetObjectFileNameWithoutTarget(
// Ensure that for the CMakeFiles/<target>.dir/generated_source_file
// we don't end up having:
// CMakeFiles/<target>.dir/CMakeFiles/<target>.dir/generated_source_file.obj
- const char* unitySourceFile = source.GetProperty("UNITY_SOURCE_FILE");
- const char* pchExtension = source.GetProperty("PCH_EXTENSION");
+ cmProp unitySourceFile = source.GetProperty("UNITY_SOURCE_FILE");
+ cmProp psExtension = source.GetProperty("PCH_EXTENSION");
const bool isPchObject = objectName.find("cmake_pch") != std::string::npos;
- if (unitySourceFile || pchExtension || isPchObject) {
- if (pchExtension) {
- customOutputExtension = pchExtension;
+ if (unitySourceFile || psExtension || isPchObject) {
+ if (psExtension) {
+ customOutputExtension = psExtension->c_str();
}
cmsys::RegularExpression var("(CMakeFiles/[^/]+.dir/)");
@@ -3552,7 +3557,6 @@ bool cmLocalGenerator::NeedBackwardsCompatibility_2_4()
break;
case cmPolicies::NEW:
// New behavior is to ignore the variable.
- return false;
case cmPolicies::REQUIRED_IF_USED:
case cmPolicies::REQUIRED_ALWAYS:
// This will never be the case because the only way to require
@@ -3732,7 +3736,7 @@ cmSourceFile* AddCustomCommand(
const cmCustomCommandLines& commandLines, const char* comment,
const char* workingDir, bool replace, bool escapeOldStyle,
bool uses_terminal, bool command_expand_lists, const std::string& depfile,
- const std::string& job_pool)
+ const std::string& job_pool, bool stdPipesUTF8)
{
cmMakefile* mf = lg.GetMakefile();
@@ -3794,7 +3798,8 @@ cmSourceFile* AddCustomCommand(
}
std::unique_ptr<cmCustomCommand> cc = cm::make_unique<cmCustomCommand>(
- outputs, byproducts, depends2, commandLines, lfbt, comment, workingDir);
+ outputs, byproducts, depends2, commandLines, lfbt, comment, workingDir,
+ stdPipesUTF8);
cc->SetEscapeOldStyle(escapeOldStyle);
cc->SetEscapeAllowMakeVars(true);
cc->SetImplicitDepends(implicit_depends);
@@ -3821,7 +3826,7 @@ void AddCustomCommandToTarget(cmLocalGenerator& lg,
const char* workingDir, bool escapeOldStyle,
bool uses_terminal, const std::string& depfile,
const std::string& job_pool,
- bool command_expand_lists)
+ bool command_expand_lists, bool stdPipesUTF8)
{
cmMakefile* mf = lg.GetMakefile();
@@ -3831,7 +3836,7 @@ void AddCustomCommandToTarget(cmLocalGenerator& lg,
// Add the command to the appropriate build step for the target.
std::vector<std::string> no_output;
cmCustomCommand cc(no_output, byproducts, depends, commandLines, lfbt,
- comment, workingDir);
+ comment, workingDir, stdPipesUTF8);
cc.SetEscapeOldStyle(escapeOldStyle);
cc.SetEscapeAllowMakeVars(true);
cc.SetUsesTerminal(uses_terminal);
@@ -3862,7 +3867,7 @@ cmSourceFile* AddCustomCommandToOutput(
const cmCustomCommandLines& commandLines, const char* comment,
const char* workingDir, bool replace, bool escapeOldStyle,
bool uses_terminal, bool command_expand_lists, const std::string& depfile,
- const std::string& job_pool)
+ const std::string& job_pool, bool stdPipesUTF8)
{
// Always create the output sources and mark them generated.
CreateGeneratedSources(lg, outputs, origin, lfbt);
@@ -3871,7 +3876,7 @@ cmSourceFile* AddCustomCommandToOutput(
return AddCustomCommand(
lg, lfbt, outputs, byproducts, depends, main_dependency, implicit_depends,
commandLines, comment, workingDir, replace, escapeOldStyle, uses_terminal,
- command_expand_lists, depfile, job_pool);
+ command_expand_lists, depfile, job_pool, stdPipesUTF8);
}
void AppendCustomCommandToOutput(cmLocalGenerator& lg,
@@ -3907,7 +3912,7 @@ void AddUtilityCommand(cmLocalGenerator& lg, const cmListFileBacktrace& lfbt,
const cmCustomCommandLines& commandLines,
bool escapeOldStyle, const char* comment,
bool uses_terminal, bool command_expand_lists,
- const std::string& job_pool)
+ const std::string& job_pool, bool stdPipesUTF8)
{
// Always create the byproduct sources and mark them generated.
CreateGeneratedSource(lg, force.Name, origin, lfbt);
@@ -3924,7 +3929,7 @@ void AddUtilityCommand(cmLocalGenerator& lg, const cmListFileBacktrace& lfbt,
lg, lfbt, { force.Name }, byproducts, depends, no_main_dependency,
no_implicit_depends, commandLines, comment, workingDir, /*replace=*/false,
escapeOldStyle, uses_terminal, command_expand_lists, /*depfile=*/"",
- job_pool);
+ job_pool, stdPipesUTF8);
if (rule) {
lg.GetMakefile()->AddTargetByproducts(target, byproducts);
}
diff --git a/Source/cmLocalGenerator.h b/Source/cmLocalGenerator.h
index 71cc63e..5fb9337 100644
--- a/Source/cmLocalGenerator.h
+++ b/Source/cmLocalGenerator.h
@@ -297,7 +297,8 @@ public:
const char* comment, const char* workingDir, bool escapeOldStyle = true,
bool uses_terminal = false, const std::string& depfile = "",
const std::string& job_pool = "", bool command_expand_lists = false,
- cmObjectLibraryCommands objLibCommands = cmObjectLibraryCommands::Reject);
+ cmObjectLibraryCommands objLibCommands = cmObjectLibraryCommands::Reject,
+ bool stdPipesUTF8 = false);
/**
* Add a custom command to a source file.
@@ -308,7 +309,8 @@ public:
const cmCustomCommandLines& commandLines, const char* comment,
const char* workingDir, bool replace = false, bool escapeOldStyle = true,
bool uses_terminal = false, bool command_expand_lists = false,
- const std::string& depfile = "", const std::string& job_pool = "");
+ const std::string& depfile = "", const std::string& job_pool = "",
+ bool stdPipesUTF8 = false);
cmSourceFile* AddCustomCommandToOutput(
const std::vector<std::string>& outputs,
const std::vector<std::string>& byproducts,
@@ -318,7 +320,8 @@ public:
const cmCustomCommandLines& commandLines, const char* comment,
const char* workingDir, bool replace = false, bool escapeOldStyle = true,
bool uses_terminal = false, bool command_expand_lists = false,
- const std::string& depfile = "", const std::string& job_pool = "");
+ const std::string& depfile = "", const std::string& job_pool = "",
+ bool stdPipesUTF8 = false);
/**
* Add a utility to the build. A utility target is a command that is run
@@ -330,7 +333,8 @@ public:
const std::vector<std::string>& depends,
const cmCustomCommandLines& commandLines, bool escapeOldStyle = true,
const char* comment = nullptr, bool uses_terminal = false,
- bool command_expand_lists = false, const std::string& job_pool = "");
+ bool command_expand_lists = false, const std::string& job_pool = "",
+ bool stdPipesUTF8 = false);
std::string GetProjectName() const;
@@ -548,7 +552,7 @@ void AddCustomCommandToTarget(cmLocalGenerator& lg,
const char* workingDir, bool escapeOldStyle,
bool uses_terminal, const std::string& depfile,
const std::string& job_pool,
- bool command_expand_lists);
+ bool command_expand_lists, bool stdPipesUTF8);
cmSourceFile* AddCustomCommandToOutput(
cmLocalGenerator& lg, const cmListFileBacktrace& lfbt,
@@ -559,7 +563,7 @@ cmSourceFile* AddCustomCommandToOutput(
const cmCustomCommandLines& commandLines, const char* comment,
const char* workingDir, bool replace, bool escapeOldStyle,
bool uses_terminal, bool command_expand_lists, const std::string& depfile,
- const std::string& job_pool);
+ const std::string& job_pool, bool stdPipesUTF8);
void AppendCustomCommandToOutput(cmLocalGenerator& lg,
const cmListFileBacktrace& lfbt,
@@ -576,7 +580,7 @@ void AddUtilityCommand(cmLocalGenerator& lg, const cmListFileBacktrace& lfbt,
const cmCustomCommandLines& commandLines,
bool escapeOldStyle, const char* comment,
bool uses_terminal, bool command_expand_lists,
- const std::string& job_pool);
+ const std::string& job_pool, bool stdPipesUTF8);
}
#endif
diff --git a/Source/cmLocalUnixMakefileGenerator3.cxx b/Source/cmLocalUnixMakefileGenerator3.cxx
index 99428bc..aa8912e 100644
--- a/Source/cmLocalUnixMakefileGenerator3.cxx
+++ b/Source/cmLocalUnixMakefileGenerator3.cxx
@@ -48,37 +48,6 @@
# include "cmDependsJava.h"
#endif
-// Escape special characters in Makefile dependency lines
-class cmMakeSafe
-{
-public:
- cmMakeSafe(const char* s)
- : Data(s)
- {
- }
- cmMakeSafe(std::string const& s)
- : Data(s.c_str())
- {
- }
-
-private:
- const char* Data;
- friend std::ostream& operator<<(std::ostream& os, cmMakeSafe const& self)
- {
- for (const char* c = self.Data; *c; ++c) {
- switch (*c) {
- case '=':
- os << "$(EQUALS)";
- break;
- default:
- os << *c;
- break;
- }
- }
- return os;
- }
-};
-
// Helper function used below.
static std::string cmSplitExtension(std::string const& in, std::string& base)
{
@@ -498,6 +467,14 @@ const std::string& cmLocalUnixMakefileGenerator3::GetHomeRelativeOutputPath()
return this->HomeRelativeOutputPath;
}
+std::string cmLocalUnixMakefileGenerator3::ConvertToMakefilePath(
+ std::string const& path) const
+{
+ cmGlobalUnixMakefileGenerator3* gg =
+ static_cast<cmGlobalUnixMakefileGenerator3*>(this->GlobalGenerator);
+ return gg->ConvertToMakefilePath(path);
+}
+
void cmLocalUnixMakefileGenerator3::WriteMakeRule(
std::ostream& os, const char* comment, const std::string& target,
const std::vector<std::string>& depends,
@@ -528,7 +505,7 @@ void cmLocalUnixMakefileGenerator3::WriteMakeRule(
}
// Construct the left hand side of the rule.
- std::string tgt = cmSystemTools::ConvertToOutputPath(
+ std::string tgt = this->ConvertToMakefilePath(
this->MaybeConvertToRelativePath(this->GetBinaryDirectory(), target));
const char* space = "";
@@ -542,30 +519,30 @@ void cmLocalUnixMakefileGenerator3::WriteMakeRule(
if (symbolic) {
if (const char* sym =
this->Makefile->GetDefinition("CMAKE_MAKE_SYMBOLIC_RULE")) {
- os << cmMakeSafe(tgt) << space << ": " << sym << "\n";
+ os << tgt << space << ": " << sym << "\n";
}
}
// Write the rule.
if (depends.empty()) {
// No dependencies. The commands will always run.
- os << cmMakeSafe(tgt) << space << ":\n";
+ os << tgt << space << ":\n";
} else {
// Split dependencies into multiple rule lines. This allows for
// very long dependency lists even on older make implementations.
std::string binDir = this->GetBinaryDirectory();
for (std::string const& depend : depends) {
- replace = depend;
- replace = cmSystemTools::ConvertToOutputPath(
- this->MaybeConvertToRelativePath(binDir, replace));
- os << cmMakeSafe(tgt) << space << ": " << cmMakeSafe(replace) << "\n";
+ os << tgt << space << ": "
+ << this->ConvertToMakefilePath(
+ this->MaybeConvertToRelativePath(binDir, depend))
+ << '\n';
}
}
// Write the list of commands.
os << cmWrap("\t", commands, "", "\n") << "\n";
if (symbolic && !this->IsWatcomWMake()) {
- os << ".PHONY : " << cmMakeSafe(tgt) << "\n";
+ os << ".PHONY : " << tgt << "\n";
}
os << "\n";
// Add the output to the local help if requested.
diff --git a/Source/cmLocalUnixMakefileGenerator3.h b/Source/cmLocalUnixMakefileGenerator3.h
index 68eeb29..2b07952 100644
--- a/Source/cmLocalUnixMakefileGenerator3.h
+++ b/Source/cmLocalUnixMakefileGenerator3.h
@@ -46,6 +46,12 @@ public:
// local generators StartOutputDirectory
const std::string& GetHomeRelativeOutputPath();
+ /**
+ * Convert a file path to a Makefile target or dependency with
+ * escaping and quoting suitable for the generator's make tool.
+ */
+ std::string ConvertToMakefilePath(std::string const& path) const;
+
// Write out a make rule
void WriteMakeRule(std::ostream& os, const char* comment,
const std::string& target,
diff --git a/Source/cmLocalVisualStudio7Generator.cxx b/Source/cmLocalVisualStudio7Generator.cxx
index 9148b27..2dfdd1f 100644
--- a/Source/cmLocalVisualStudio7Generator.cxx
+++ b/Source/cmLocalVisualStudio7Generator.cxx
@@ -251,14 +251,15 @@ cmSourceFile* cmLocalVisualStudio7Generator::CreateVCProjBuildRule()
std::string argB = cmStrCat("-B", this->GetBinaryDirectory());
std::string stampName =
cmStrCat(this->GetCurrentBinaryDirectory(), "/CMakeFiles/generate.stamp");
+ bool stdPipesUTF8 = true;
cmCustomCommandLines commandLines =
cmMakeSingleCommandLine({ cmSystemTools::GetCMakeCommand(), argS, argB,
"--check-stamp-file", stampName });
std::string comment = cmStrCat("Building Custom Rule ", makefileIn);
const char* no_working_directory = nullptr;
- this->AddCustomCommandToOutput(stampName, listFiles, makefileIn,
- commandLines, comment.c_str(),
- no_working_directory, true, false);
+ this->AddCustomCommandToOutput(
+ stampName, listFiles, makefileIn, commandLines, comment.c_str(),
+ no_working_directory, true, false, false, false, "", "", stdPipesUTF8);
if (cmSourceFile* file = this->Makefile->GetSource(makefileIn)) {
// Finalize the source file path now since we're adding this after
// the generator validated all project-named sources.
@@ -1445,14 +1446,15 @@ cmLocalVisualStudio7GeneratorFCInfo::cmLocalVisualStudio7GeneratorFCInfo(
needfc = true;
}
const std::string COMPILE_FLAGS("COMPILE_FLAGS");
- if (const char* cflags = sf.GetProperty(COMPILE_FLAGS)) {
- fc.CompileFlags = genexInterpreter.Evaluate(cflags, COMPILE_FLAGS);
+ if (cmProp cflags = sf.GetProperty(COMPILE_FLAGS)) {
+ fc.CompileFlags = genexInterpreter.Evaluate(*cflags, COMPILE_FLAGS);
needfc = true;
}
const std::string COMPILE_OPTIONS("COMPILE_OPTIONS");
- if (const char* coptions = sf.GetProperty(COMPILE_OPTIONS)) {
+ if (cmProp coptions = sf.GetProperty(COMPILE_OPTIONS)) {
lg->AppendCompileOptions(
- fc.CompileFlags, genexInterpreter.Evaluate(coptions, COMPILE_OPTIONS));
+ fc.CompileFlags,
+ genexInterpreter.Evaluate(*coptions, COMPILE_OPTIONS));
needfc = true;
}
// Add precompile headers compile options.
@@ -1473,7 +1475,7 @@ cmLocalVisualStudio7GeneratorFCInfo::cmLocalVisualStudio7GeneratorFCInfo(
if (lg->FortranProject) {
switch (cmOutputConverter::GetFortranFormat(
- sf.GetProperty("Fortran_FORMAT"))) {
+ sf.GetSafeProperty("Fortran_FORMAT"))) {
case cmOutputConverter::FortranFormatFixed:
fc.CompileFlags = "-fixed " + fc.CompileFlags;
needfc = true;
@@ -1487,26 +1489,26 @@ cmLocalVisualStudio7GeneratorFCInfo::cmLocalVisualStudio7GeneratorFCInfo(
}
}
const std::string COMPILE_DEFINITIONS("COMPILE_DEFINITIONS");
- if (const char* cdefs = sf.GetProperty(COMPILE_DEFINITIONS)) {
- fc.CompileDefs = genexInterpreter.Evaluate(cdefs, COMPILE_DEFINITIONS);
+ if (cmProp cdefs = sf.GetProperty(COMPILE_DEFINITIONS)) {
+ fc.CompileDefs = genexInterpreter.Evaluate(*cdefs, COMPILE_DEFINITIONS);
needfc = true;
}
std::string defPropName = cmStrCat("COMPILE_DEFINITIONS_", configUpper);
- if (const char* ccdefs = sf.GetProperty(defPropName)) {
+ if (cmProp ccdefs = sf.GetProperty(defPropName)) {
fc.CompileDefsConfig =
- genexInterpreter.Evaluate(ccdefs, COMPILE_DEFINITIONS);
+ genexInterpreter.Evaluate(*ccdefs, COMPILE_DEFINITIONS);
needfc = true;
}
const std::string INCLUDE_DIRECTORIES("INCLUDE_DIRECTORIES");
- if (const char* cincs = sf.GetProperty(INCLUDE_DIRECTORIES)) {
- fc.IncludeDirs = genexInterpreter.Evaluate(cincs, INCLUDE_DIRECTORIES);
+ if (cmProp cincs = sf.GetProperty(INCLUDE_DIRECTORIES)) {
+ fc.IncludeDirs = genexInterpreter.Evaluate(*cincs, INCLUDE_DIRECTORIES);
needfc = true;
}
// Check for extra object-file dependencies.
- if (const char* deps = sf.GetProperty("OBJECT_DEPENDS")) {
- std::vector<std::string> depends = cmExpandedList(deps);
+ if (cmProp deps = sf.GetProperty("OBJECT_DEPENDS")) {
+ std::vector<std::string> depends = cmExpandedList(*deps);
const char* sep = "";
for (const std::string& d : depends) {
fc.AdditionalDeps += sep;
diff --git a/Source/cmLocalVisualStudioGenerator.cxx b/Source/cmLocalVisualStudioGenerator.cxx
index 7267976..ebd4f96 100644
--- a/Source/cmLocalVisualStudioGenerator.cxx
+++ b/Source/cmLocalVisualStudioGenerator.cxx
@@ -102,10 +102,12 @@ cmLocalVisualStudioGenerator::MaybeCreateImplibDir(cmGeneratorTarget* target,
std::vector<std::string> no_output;
std::vector<std::string> no_byproducts;
std::vector<std::string> no_depends;
+ bool stdPipesUTF8 = true;
cmCustomCommandLines commands = cmMakeSingleCommandLine(
{ cmSystemTools::GetCMakeCommand(), "-E", "make_directory", impDir });
pcc.reset(new cmCustomCommand(no_output, no_byproducts, no_depends, commands,
- cmListFileBacktrace(), nullptr, nullptr));
+ cmListFileBacktrace(), nullptr, nullptr,
+ stdPipesUTF8));
pcc->SetEscapeOldStyle(false);
pcc->SetEscapeAllowMakeVars(true);
return pcc;
diff --git a/Source/cmMakefile.cxx b/Source/cmMakefile.cxx
index 69f316d..85e7df1 100644
--- a/Source/cmMakefile.cxx
+++ b/Source/cmMakefile.cxx
@@ -24,6 +24,7 @@
#include "cm_jsoncpp_value.h"
#include "cm_jsoncpp_writer.h"
+#include "cm_static_string_view.hxx"
#include "cm_sys_stat.h"
#include "cmAlgorithms.h"
@@ -1021,7 +1022,7 @@ cmTarget* cmMakefile::AddCustomCommandToTarget(
const cmCustomCommandLines& commandLines, cmCustomCommandType type,
const char* comment, const char* workingDir, bool escapeOldStyle,
bool uses_terminal, const std::string& depfile, const std::string& job_pool,
- bool command_expand_lists)
+ bool command_expand_lists, bool stdPipesUTF8)
{
cmTarget* t = this->GetCustomCommandTarget(
target, cmObjectLibraryCommands::Reject, this->Backtrace);
@@ -1039,14 +1040,15 @@ cmTarget* cmMakefile::AddCustomCommandToTarget(
cm::optional<std::string> workingStr = MakeOptionalString(workingDir);
// Dispatch command creation to allow generator expressions in outputs.
- this->AddGeneratorAction([=](cmLocalGenerator& lg,
- const cmListFileBacktrace& lfbt) {
- BacktraceGuard guard(this->Backtrace, lfbt);
- detail::AddCustomCommandToTarget(
- lg, lfbt, cmCommandOrigin::Project, t, byproducts, depends, commandLines,
- type, GetCStrOrNull(commentStr), GetCStrOrNull(workingStr),
- escapeOldStyle, uses_terminal, depfile, job_pool, command_expand_lists);
- });
+ this->AddGeneratorAction(
+ [=](cmLocalGenerator& lg, const cmListFileBacktrace& lfbt) {
+ BacktraceGuard guard(this->Backtrace, lfbt);
+ detail::AddCustomCommandToTarget(
+ lg, lfbt, cmCommandOrigin::Project, t, byproducts, depends,
+ commandLines, type, GetCStrOrNull(commentStr),
+ GetCStrOrNull(workingStr), escapeOldStyle, uses_terminal, depfile,
+ job_pool, command_expand_lists, stdPipesUTF8);
+ });
return t;
}
@@ -1057,14 +1059,14 @@ void cmMakefile::AddCustomCommandToOutput(
const char* comment, const char* workingDir,
const CommandSourceCallback& callback, bool replace, bool escapeOldStyle,
bool uses_terminal, bool command_expand_lists, const std::string& depfile,
- const std::string& job_pool)
+ const std::string& job_pool, bool stdPipesUTF8)
{
std::vector<std::string> no_byproducts;
cmImplicitDependsList no_implicit_depends;
this->AddCustomCommandToOutput(
{ output }, no_byproducts, depends, main_dependency, no_implicit_depends,
commandLines, comment, workingDir, callback, replace, escapeOldStyle,
- uses_terminal, command_expand_lists, depfile, job_pool);
+ uses_terminal, command_expand_lists, depfile, job_pool, stdPipesUTF8);
}
void cmMakefile::AddCustomCommandToOutput(
@@ -1075,7 +1077,7 @@ void cmMakefile::AddCustomCommandToOutput(
const cmCustomCommandLines& commandLines, const char* comment,
const char* workingDir, const CommandSourceCallback& callback, bool replace,
bool escapeOldStyle, bool uses_terminal, bool command_expand_lists,
- const std::string& depfile, const std::string& job_pool)
+ const std::string& depfile, const std::string& job_pool, bool stdPipesUTF8)
{
// Make sure there is at least one output.
if (outputs.empty()) {
@@ -1097,18 +1099,19 @@ void cmMakefile::AddCustomCommandToOutput(
cm::optional<std::string> workingStr = MakeOptionalString(workingDir);
// Dispatch command creation to allow generator expressions in outputs.
- this->AddGeneratorAction([=](cmLocalGenerator& lg,
- const cmListFileBacktrace& lfbt) {
- BacktraceGuard guard(this->Backtrace, lfbt);
- cmSourceFile* sf = detail::AddCustomCommandToOutput(
- lg, lfbt, cmCommandOrigin::Project, outputs, byproducts, depends,
- main_dependency, implicit_depends, commandLines,
- GetCStrOrNull(commentStr), GetCStrOrNull(workingStr), replace,
- escapeOldStyle, uses_terminal, command_expand_lists, depfile, job_pool);
- if (callback && sf) {
- callback(sf);
- }
- });
+ this->AddGeneratorAction(
+ [=](cmLocalGenerator& lg, const cmListFileBacktrace& lfbt) {
+ BacktraceGuard guard(this->Backtrace, lfbt);
+ cmSourceFile* sf = detail::AddCustomCommandToOutput(
+ lg, lfbt, cmCommandOrigin::Project, outputs, byproducts, depends,
+ main_dependency, implicit_depends, commandLines,
+ GetCStrOrNull(commentStr), GetCStrOrNull(workingStr), replace,
+ escapeOldStyle, uses_terminal, command_expand_lists, depfile, job_pool,
+ stdPipesUTF8);
+ if (callback && sf) {
+ callback(sf);
+ }
+ });
}
void cmMakefile::AddCustomCommandOldStyle(
@@ -1224,7 +1227,7 @@ cmTarget* cmMakefile::AddUtilityCommand(
const std::vector<std::string>& depends,
const cmCustomCommandLines& commandLines, bool escapeOldStyle,
const char* comment, bool uses_terminal, bool command_expand_lists,
- const std::string& job_pool)
+ const std::string& job_pool, bool stdPipesUTF8)
{
cmTarget* target = this->AddNewUtilityTarget(utilityName, excludeFromAll);
@@ -1253,7 +1256,7 @@ cmTarget* cmMakefile::AddUtilityCommand(
force, GetCStrOrNull(workingStr), byproducts,
depends, commandLines, escapeOldStyle,
GetCStrOrNull(commentStr), uses_terminal,
- command_expand_lists, job_pool);
+ command_expand_lists, job_pool, stdPipesUTF8);
});
return target;
@@ -2513,10 +2516,7 @@ void cmMakefile::ExpandVariablesCMP0019()
for (auto l = linkLibs.begin(); l != linkLibs.end(); ++l) {
std::string libName = *l;
- if (libName == "optimized") {
- ++l;
- libName = *l;
- } else if (libName == "debug") {
+ if (libName == "optimized"_s || libName == "debug"_s) {
++l;
libName = *l;
}
diff --git a/Source/cmMakefile.h b/Source/cmMakefile.h
index 9a7eff9..04a1f2d 100644
--- a/Source/cmMakefile.h
+++ b/Source/cmMakefile.h
@@ -188,7 +188,8 @@ public:
const cmCustomCommandLines& commandLines, cmCustomCommandType type,
const char* comment, const char* workingDir, bool escapeOldStyle = true,
bool uses_terminal = false, const std::string& depfile = "",
- const std::string& job_pool = "", bool command_expand_lists = false);
+ const std::string& job_pool = "", bool command_expand_lists = false,
+ bool stdPipesUTF8 = false);
/**
* Called for each file with custom command.
@@ -205,7 +206,8 @@ public:
const char* workingDir, const CommandSourceCallback& callback = nullptr,
bool replace = false, bool escapeOldStyle = true,
bool uses_terminal = false, bool command_expand_lists = false,
- const std::string& depfile = "", const std::string& job_pool = "");
+ const std::string& depfile = "", const std::string& job_pool = "",
+ bool stdPipesUTF8 = false);
void AddCustomCommandToOutput(
const std::vector<std::string>& outputs,
const std::vector<std::string>& byproducts,
@@ -216,7 +218,8 @@ public:
const char* workingDir, const CommandSourceCallback& callback = nullptr,
bool replace = false, bool escapeOldStyle = true,
bool uses_terminal = false, bool command_expand_lists = false,
- const std::string& depfile = "", const std::string& job_pool = "");
+ const std::string& depfile = "", const std::string& job_pool = "",
+ bool stdPipesUTF8 = false);
void AddCustomCommandOldStyle(const std::string& target,
const std::vector<std::string>& outputs,
const std::vector<std::string>& depends,
@@ -284,7 +287,8 @@ public:
const std::vector<std::string>& depends,
const cmCustomCommandLines& commandLines, bool escapeOldStyle = true,
const char* comment = nullptr, bool uses_terminal = false,
- bool command_expand_lists = false, const std::string& job_pool = "");
+ bool command_expand_lists = false, const std::string& job_pool = "",
+ bool stdPipesUTF8 = false);
/**
* Add a subdirectory to the build.
diff --git a/Source/cmMakefileTargetGenerator.cxx b/Source/cmMakefileTargetGenerator.cxx
index 5bb4c57..ee87044 100644
--- a/Source/cmMakefileTargetGenerator.cxx
+++ b/Source/cmMakefileTargetGenerator.cxx
@@ -341,12 +341,16 @@ void cmMakefileTargetGenerator::WriteTargetLanguageFlags()
<< "\n";
}
+ bool const escapeOctothorpe = this->GlobalGenerator->CanEscapeOctothorpe();
+
for (std::string const& language : languages) {
std::string defines = this->GetDefines(language, this->GetConfigName());
std::string includes = this->GetIncludes(language, this->GetConfigName());
- // Escape comment characters so they do not terminate assignment.
- cmSystemTools::ReplaceString(defines, "#", "\\#");
- cmSystemTools::ReplaceString(includes, "#", "\\#");
+ if (escapeOctothorpe) {
+ // Escape comment characters so they do not terminate assignment.
+ cmSystemTools::ReplaceString(defines, "#", "\\#");
+ cmSystemTools::ReplaceString(includes, "#", "\\#");
+ }
*this->FlagFileStream << language << "_DEFINES = " << defines << "\n\n";
*this->FlagFileStream << language << "_INCLUDES = " << includes << "\n\n";
@@ -357,7 +361,9 @@ void cmMakefileTargetGenerator::WriteTargetLanguageFlags()
for (const std::string& arch : architectures) {
std::string flags =
this->GetFlags(language, this->GetConfigName(), arch);
- cmSystemTools::ReplaceString(flags, "#", "\\#");
+ if (escapeOctothorpe) {
+ cmSystemTools::ReplaceString(flags, "#", "\\#");
+ }
*this->FlagFileStream << language << "_FLAGS" << arch << " = " << flags
<< "\n\n";
}
@@ -527,9 +533,9 @@ void cmMakefileTargetGenerator::WriteObjectRuleFiles(
// Add flags from source file properties.
const std::string COMPILE_FLAGS("COMPILE_FLAGS");
- if (const char* cflags = source.GetProperty(COMPILE_FLAGS)) {
+ if (cmProp cflags = source.GetProperty(COMPILE_FLAGS)) {
const std::string& evaluatedFlags =
- genexInterpreter.Evaluate(cflags, COMPILE_FLAGS);
+ genexInterpreter.Evaluate(*cflags, COMPILE_FLAGS);
this->LocalGenerator->AppendFlags(flags, evaluatedFlags);
*this->FlagFileStream << "# Custom flags: " << relativeObj
<< "_FLAGS = " << evaluatedFlags << "\n"
@@ -537,9 +543,9 @@ void cmMakefileTargetGenerator::WriteObjectRuleFiles(
}
const std::string COMPILE_OPTIONS("COMPILE_OPTIONS");
- if (const char* coptions = source.GetProperty(COMPILE_OPTIONS)) {
+ if (cmProp coptions = source.GetProperty(COMPILE_OPTIONS)) {
const std::string& evaluatedOptions =
- genexInterpreter.Evaluate(coptions, COMPILE_OPTIONS);
+ genexInterpreter.Evaluate(*coptions, COMPILE_OPTIONS);
this->LocalGenerator->AppendCompileOptions(flags, evaluatedOptions);
*this->FlagFileStream << "# Custom options: " << relativeObj
<< "_OPTIONS = " << evaluatedOptions << "\n"
@@ -571,9 +577,9 @@ void cmMakefileTargetGenerator::WriteObjectRuleFiles(
std::vector<std::string> includes;
const std::string INCLUDE_DIRECTORIES("INCLUDE_DIRECTORIES");
- if (const char* cincludes = source.GetProperty(INCLUDE_DIRECTORIES)) {
+ if (cmProp cincludes = source.GetProperty(INCLUDE_DIRECTORIES)) {
const std::string& evaluatedIncludes =
- genexInterpreter.Evaluate(cincludes, INCLUDE_DIRECTORIES);
+ genexInterpreter.Evaluate(*cincludes, INCLUDE_DIRECTORIES);
this->LocalGenerator->AppendIncludeDirectories(includes, evaluatedIncludes,
source);
*this->FlagFileStream << "# Custom include directories: " << relativeObj
@@ -587,18 +593,18 @@ void cmMakefileTargetGenerator::WriteObjectRuleFiles(
// Add source-specific preprocessor definitions.
const std::string COMPILE_DEFINITIONS("COMPILE_DEFINITIONS");
- if (const char* compile_defs = source.GetProperty(COMPILE_DEFINITIONS)) {
+ if (cmProp compile_defs = source.GetProperty(COMPILE_DEFINITIONS)) {
const std::string& evaluatedDefs =
- genexInterpreter.Evaluate(compile_defs, COMPILE_DEFINITIONS);
+ genexInterpreter.Evaluate(*compile_defs, COMPILE_DEFINITIONS);
this->LocalGenerator->AppendDefines(defines, evaluatedDefs);
*this->FlagFileStream << "# Custom defines: " << relativeObj
<< "_DEFINES = " << evaluatedDefs << "\n"
<< "\n";
}
std::string defPropName = cmStrCat("COMPILE_DEFINITIONS_", configUpper);
- if (const char* config_compile_defs = source.GetProperty(defPropName)) {
+ if (cmProp config_compile_defs = source.GetProperty(defPropName)) {
const std::string& evaluatedDefs =
- genexInterpreter.Evaluate(config_compile_defs, COMPILE_DEFINITIONS);
+ genexInterpreter.Evaluate(*config_compile_defs, COMPILE_DEFINITIONS);
this->LocalGenerator->AppendDefines(defines, evaluatedDefs);
*this->FlagFileStream << "# Custom defines: " << relativeObj << "_DEFINES_"
<< configUpper << " = " << evaluatedDefs << "\n"
@@ -876,9 +882,9 @@ void cmMakefileTargetGenerator::WriteObjectRuleFiles(
// Check for extra outputs created by the compilation.
std::vector<std::string> outputs(1, relativeObj);
- if (const char* extra_outputs_str = source.GetProperty("OBJECT_OUTPUTS")) {
+ if (cmProp extra_outputs_str = source.GetProperty("OBJECT_OUTPUTS")) {
// Register these as extra files to clean.
- cmExpandList(extra_outputs_str, outputs);
+ cmExpandList(*extra_outputs_str, outputs);
this->CleanFiles.insert(outputs.begin() + 1, outputs.end());
}
@@ -1229,8 +1235,8 @@ void cmMakefileTargetGenerator::WriteObjectDependRules(
// Create the list of dependencies known at cmake time. These are
// shared between the object file and dependency scanning rule.
depends.push_back(source.GetFullPath());
- if (const char* objectDeps = source.GetProperty("OBJECT_DEPENDS")) {
- cmExpandList(objectDeps, depends);
+ if (cmProp objectDeps = source.GetProperty("OBJECT_DEPENDS")) {
+ cmExpandList(*objectDeps, depends);
}
}
diff --git a/Source/cmNinjaTargetGenerator.cxx b/Source/cmNinjaTargetGenerator.cxx
index ed74cf9..a70b6a0 100644
--- a/Source/cmNinjaTargetGenerator.cxx
+++ b/Source/cmNinjaTargetGenerator.cxx
@@ -190,15 +190,15 @@ std::string cmNinjaTargetGenerator::ComputeFlagsForObject(
this->LocalGenerator, config, this->GeneratorTarget, language);
const std::string COMPILE_FLAGS("COMPILE_FLAGS");
- if (const char* cflags = source->GetProperty(COMPILE_FLAGS)) {
+ if (cmProp cflags = source->GetProperty(COMPILE_FLAGS)) {
this->LocalGenerator->AppendFlags(
- flags, genexInterpreter.Evaluate(cflags, COMPILE_FLAGS));
+ flags, genexInterpreter.Evaluate(*cflags, COMPILE_FLAGS));
}
const std::string COMPILE_OPTIONS("COMPILE_OPTIONS");
- if (const char* coptions = source->GetProperty(COMPILE_OPTIONS)) {
+ if (cmProp coptions = source->GetProperty(COMPILE_OPTIONS)) {
this->LocalGenerator->AppendCompileOptions(
- flags, genexInterpreter.Evaluate(coptions, COMPILE_OPTIONS));
+ flags, genexInterpreter.Evaluate(*coptions, COMPILE_OPTIONS));
}
// Add precompile headers compile options.
@@ -281,17 +281,17 @@ std::string cmNinjaTargetGenerator::ComputeDefines(cmSourceFile const* source,
}
const std::string COMPILE_DEFINITIONS("COMPILE_DEFINITIONS");
- if (const char* compile_defs = source->GetProperty(COMPILE_DEFINITIONS)) {
+ if (cmProp compile_defs = source->GetProperty(COMPILE_DEFINITIONS)) {
this->LocalGenerator->AppendDefines(
- defines, genexInterpreter.Evaluate(compile_defs, COMPILE_DEFINITIONS));
+ defines, genexInterpreter.Evaluate(*compile_defs, COMPILE_DEFINITIONS));
}
std::string defPropName =
cmStrCat("COMPILE_DEFINITIONS_", cmSystemTools::UpperCase(config));
- if (const char* config_compile_defs = source->GetProperty(defPropName)) {
+ if (cmProp config_compile_defs = source->GetProperty(defPropName)) {
this->LocalGenerator->AppendDefines(
defines,
- genexInterpreter.Evaluate(config_compile_defs, COMPILE_DEFINITIONS));
+ genexInterpreter.Evaluate(*config_compile_defs, COMPILE_DEFINITIONS));
}
std::string definesString = this->GetDefines(language, config);
@@ -309,9 +309,9 @@ std::string cmNinjaTargetGenerator::ComputeIncludes(
this->LocalGenerator, config, this->GeneratorTarget, language);
const std::string INCLUDE_DIRECTORIES("INCLUDE_DIRECTORIES");
- if (const char* cincludes = source->GetProperty(INCLUDE_DIRECTORIES)) {
+ if (cmProp cincludes = source->GetProperty(INCLUDE_DIRECTORIES)) {
this->LocalGenerator->AppendIncludeDirectories(
- includes, genexInterpreter.Evaluate(cincludes, INCLUDE_DIRECTORIES),
+ includes, genexInterpreter.Evaluate(*cincludes, INCLUDE_DIRECTORIES),
*source);
}
@@ -1096,8 +1096,8 @@ void cmNinjaTargetGenerator::WriteObjectBuildStatement(
}
}
- if (const char* objectDeps = source->GetProperty("OBJECT_DEPENDS")) {
- std::vector<std::string> objDepList = cmExpandedList(objectDeps);
+ if (cmProp objectDeps = source->GetProperty("OBJECT_DEPENDS")) {
+ std::vector<std::string> objDepList = cmExpandedList(*objectDeps);
std::copy(objDepList.begin(), objDepList.end(),
std::back_inserter(depList));
}
@@ -1264,10 +1264,10 @@ void cmNinjaTargetGenerator::WriteObjectBuildStatement(
objBuild, commandLineLengthLimit);
}
- if (const char* objectOutputs = source->GetProperty("OBJECT_OUTPUTS")) {
+ if (cmProp objectOutputs = source->GetProperty("OBJECT_OUTPUTS")) {
cmNinjaBuild build("phony");
build.Comment = "Additional output files.";
- build.Outputs = cmExpandedList(objectOutputs);
+ build.Outputs = cmExpandedList(*objectOutputs);
std::transform(build.Outputs.begin(), build.Outputs.end(),
build.Outputs.begin(), MapToNinjaPath());
build.ExplicitDeps = objBuild.Outputs;
@@ -1331,14 +1331,14 @@ void cmNinjaTargetGenerator::EmitSwiftDependencyInfo(
std::string const objectFilePath =
this->ConvertToNinjaPath(this->GetObjectFilePath(source, config));
std::string const swiftDepsPath = [source, objectFilePath]() -> std::string {
- if (const char* name = source->GetProperty("Swift_DEPENDENCIES_FILE")) {
- return name;
+ if (cmProp name = source->GetProperty("Swift_DEPENDENCIES_FILE")) {
+ return *name;
}
return cmStrCat(objectFilePath, ".swiftdeps");
}();
std::string const swiftDiaPath = [source, objectFilePath]() -> std::string {
- if (const char* name = source->GetProperty("Swift_DIAGNOSTICS_FILE")) {
- return name;
+ if (cmProp name = source->GetProperty("Swift_DIAGNOSTICS_FILE")) {
+ return *name;
}
return cmStrCat(objectFilePath, ".dia");
}();
diff --git a/Source/cmOutputConverter.cxx b/Source/cmOutputConverter.cxx
index 1c6fad1..68bf3af 100644
--- a/Source/cmOutputConverter.cxx
+++ b/Source/cmOutputConverter.cxx
@@ -26,7 +26,7 @@ std::string cmOutputConverter::ConvertToOutputForExisting(
// already exists, we can use a short-path to reference it without a
// space.
if (this->GetState()->UseWindowsShell() &&
- remote.find(' ') != std::string::npos &&
+ remote.find_first_of(" #") != std::string::npos &&
cmSystemTools::FileExists(remote)) {
std::string tmp;
if (cmSystemTools::GetShortPath(remote, tmp)) {
diff --git a/Source/cmPolicies.cxx b/Source/cmPolicies.cxx
index 5c8bc98..dea3f8a 100644
--- a/Source/cmPolicies.cxx
+++ b/Source/cmPolicies.cxx
@@ -72,6 +72,7 @@ static const char* idToVersion(cmPolicies::PolicyID id)
#define POLICY_CASE(ID, V_MAJOR, V_MINOR, V_PATCH) \
case cmPolicies::ID: \
return #V_MAJOR "." #V_MINOR "." #V_PATCH;
+ // NOLINTNEXTLINE(bugprone-branch-clone)
CM_FOR_EACH_POLICY_ID_VERSION(POLICY_CASE)
#undef POLICY_CASE
case cmPolicies::CMPCOUNT:
@@ -90,6 +91,7 @@ static bool isPolicyNewerThan(cmPolicies::PolicyID id, unsigned int majorV,
(majorV == (V_MAJOR) && minorV + 1 < (V_MINOR) + 1) || \
(majorV == (V_MAJOR) && minorV == (V_MINOR) && \
patchV + 1 < (V_PATCH) + 1));
+ // NOLINTNEXTLINE(bugprone-branch-clone)
CM_FOR_EACH_POLICY_ID_VERSION(POLICY_CASE)
#undef POLICY_CASE
case cmPolicies::CMPCOUNT:
diff --git a/Source/cmPolicies.h b/Source/cmPolicies.h
index d3daad8..0eb42bf 100644
--- a/Source/cmPolicies.h
+++ b/Source/cmPolicies.h
@@ -308,6 +308,10 @@ class cmMakefile;
3, 17, 0, cmPolicies::WARN) \
SELECT(POLICY, CMP0103, \
"multiple export() with same FILE without APPEND is not allowed.", \
+ 3, 18, 0, cmPolicies::WARN) \
+ SELECT(POLICY, CMP0104, \
+ "CMAKE_CUDA_ARCHITECTURES now detected for NVCC, empty " \
+ "CUDA_ARCHITECTURES not allowed.", \
3, 18, 0, cmPolicies::WARN)
#define CM_SELECT_ID(F, A1, A2, A3, A4, A5, A6) F(A1)
@@ -338,7 +342,8 @@ class cmMakefile;
F(CMP0081) \
F(CMP0083) \
F(CMP0095) \
- F(CMP0099)
+ F(CMP0099) \
+ F(CMP0104)
/** \class cmPolicies
* \brief Handles changes in CMake behavior and policies
diff --git a/Source/cmQTWrapCPPCommand.cxx b/Source/cmQTWrapCPPCommand.cxx
index cc4df8f..48c4b10 100644
--- a/Source/cmQTWrapCPPCommand.cxx
+++ b/Source/cmQTWrapCPPCommand.cxx
@@ -39,7 +39,8 @@ bool cmQTWrapCPPCommand(std::vector<std::string> const& args,
cmStrCat(mf.GetCurrentBinaryDirectory(), "/moc_", srcName, ".cxx");
cmSourceFile* sf = mf.GetOrCreateSource(newName, true);
if (curr) {
- sf->SetProperty("ABSTRACT", curr->GetProperty("ABSTRACT"));
+ cmProp p = curr->GetProperty("ABSTRACT");
+ sf->SetProperty("ABSTRACT", p ? p->c_str() : nullptr);
}
// Compute the name of the header from which to generate the file.
diff --git a/Source/cmQtAutoGenInitializer.cxx b/Source/cmQtAutoGenInitializer.cxx
index a5af810..87f4656 100644
--- a/Source/cmQtAutoGenInitializer.cxx
+++ b/Source/cmQtAutoGenInitializer.cxx
@@ -1097,6 +1097,7 @@ bool cmQtAutoGenInitializer::InitAutogenTarget()
// of fiddling with the include directories
std::vector<std::string> configs;
this->GlobalGen->GetQtAutoGenConfigs(configs);
+ bool stdPipesUTF8 = true;
cmCustomCommandLines commandLines;
for (auto const& config : configs) {
commandLines.push_back(cmMakeCommandLine(
@@ -1141,7 +1142,7 @@ bool cmQtAutoGenInitializer::InitAutogenTarget()
const std::vector<std::string> no_deps;
cmCustomCommand cc(no_output, autogenProvides, no_deps, commandLines,
this->Makefile->GetBacktrace(), autogenComment.c_str(),
- this->Dir.Work.c_str());
+ this->Dir.Work.c_str(), stdPipesUTF8);
cc.SetEscapeOldStyle(false);
cc.SetEscapeAllowMakeVars(true);
this->GenTarget->Target->AddPreBuildCommand(std::move(cc));
@@ -1211,7 +1212,8 @@ bool cmQtAutoGenInitializer::InitAutogenTarget()
autogenComment.c_str(), this->Dir.Work.c_str(), /*replace=*/false,
/*escapeOldStyle=*/false,
/*uses_terminal=*/false,
- /*command_expand_lists=*/false, this->AutogenTarget.DepFile);
+ /*command_expand_lists=*/false, this->AutogenTarget.DepFile, "",
+ stdPipesUTF8);
// Alter variables for the autogen target which now merely wraps the
// custom command
@@ -1282,6 +1284,7 @@ bool cmQtAutoGenInitializer::InitRccTargets()
ccDepends.push_back(qrc.QrcFile);
ccDepends.push_back(qrc.InfoFile);
+ bool stdPipesUTF8 = true;
cmCustomCommandLines commandLines;
if (this->MultiConfig) {
// Build for all configurations
@@ -1310,7 +1313,8 @@ bool cmQtAutoGenInitializer::InitRccTargets()
cmTarget* autoRccTarget = this->LocalGen->AddUtilityCommand(
ccName, true, this->Dir.Work.c_str(), ccOutput, ccDepends,
- commandLines, false, ccComment.c_str());
+ commandLines, false, ccComment.c_str(), false, false, "",
+ stdPipesUTF8);
// Create autogen generator target
this->LocalGen->AddGeneratorTarget(
@@ -1350,7 +1354,8 @@ bool cmQtAutoGenInitializer::InitRccTargets()
this->LocalGen->AddCustomCommandToOutput(
ccOutput, ccByproducts, ccDepends, no_main_dependency,
no_implicit_depends, commandLines, ccComment.c_str(),
- this->Dir.Work.c_str());
+ this->Dir.Work.c_str(), false, true, false, false, "", "",
+ stdPipesUTF8);
}
// Reconfigure when .qrc file changes
this->Makefile->AddCMakeDependFile(qrc.QrcFile);
diff --git a/Source/cmRST.cxx b/Source/cmRST.cxx
index c39d162..26e93bb 100644
--- a/Source/cmRST.cxx
+++ b/Source/cmRST.cxx
@@ -166,6 +166,8 @@ void cmRST::ProcessLine(std::string const& line)
this->Markup =
(line.find_first_not_of(" \t", 2) == std::string::npos ? MarkupEmpty
: MarkupNormal);
+ // XXX(clang-tidy): https://bugs.llvm.org/show_bug.cgi?id=44165
+ // NOLINTNEXTLINE(bugprone-branch-clone)
if (this->CMakeDirective.find(line)) {
// Output cmake domain directives and their content normally.
this->NormalLine(line);
diff --git a/Source/cmSeparateArgumentsCommand.cxx b/Source/cmSeparateArgumentsCommand.cxx
index 52bde7c..cfe3087 100644
--- a/Source/cmSeparateArgumentsCommand.cxx
+++ b/Source/cmSeparateArgumentsCommand.cxx
@@ -39,6 +39,8 @@ bool cmSeparateArgumentsCommand(std::vector<std::string> const& args,
if (doing == DoingVariable) {
var = arg;
doing = DoingMode;
+ // This will always clone one of the other blocks.
+ // NOLINTNEXTLINE(bugprone-branch-clone)
} else if (doing == DoingMode && arg == "NATIVE_COMMAND") {
#ifdef _WIN32
mode = ModeWindows;
diff --git a/Source/cmSourceFile.cxx b/Source/cmSourceFile.cxx
index ad59cd6..f525439 100644
--- a/Source/cmSourceFile.cxx
+++ b/Source/cmSourceFile.cxx
@@ -48,9 +48,9 @@ std::string cmSourceFile::GetObjectLibrary() const
std::string const& cmSourceFile::GetOrDetermineLanguage()
{
// If the language was set explicitly by the user then use it.
- if (const char* lang = this->GetProperty(propLANGUAGE)) {
+ if (cmProp lang = this->GetProperty(propLANGUAGE)) {
// Assign to member in order to return a reference.
- this->Language = lang;
+ this->Language = *lang;
return this->Language;
}
@@ -81,8 +81,8 @@ std::string const& cmSourceFile::GetOrDetermineLanguage()
std::string cmSourceFile::GetLanguage() const
{
// If the language was set explicitly by the user then use it.
- if (const char* lang = this->GetProperty(propLANGUAGE)) {
- return lang;
+ if (cmProp lang = this->GetProperty(propLANGUAGE)) {
+ return *lang;
}
// Use the language determined from the file extension.
@@ -317,17 +317,18 @@ const char* cmSourceFile::GetPropertyForUser(const std::string& prop)
}
// Perform the normal property lookup.
- return this->GetProperty(prop);
+ cmProp p = this->GetProperty(prop);
+ return p ? p->c_str() : nullptr;
}
-const char* cmSourceFile::GetProperty(const std::string& prop) const
+cmProp cmSourceFile::GetProperty(const std::string& prop) const
{
// Check for computed properties.
if (prop == propLOCATION) {
if (this->FullPath.empty()) {
return nullptr;
}
- return this->FullPath.c_str();
+ return &this->FullPath;
}
// Check for the properties with backtraces.
@@ -338,7 +339,7 @@ const char* cmSourceFile::GetProperty(const std::string& prop) const
static std::string output;
output = cmJoin(this->IncludeDirectories, ";");
- return output.c_str();
+ return &output;
}
if (prop == propCOMPILE_OPTIONS) {
@@ -348,7 +349,7 @@ const char* cmSourceFile::GetProperty(const std::string& prop) const
static std::string output;
output = cmJoin(this->CompileOptions, ";");
- return output.c_str();
+ return &output;
}
if (prop == propCOMPILE_DEFINITIONS) {
@@ -358,7 +359,7 @@ const char* cmSourceFile::GetProperty(const std::string& prop) const
static std::string output;
output = cmJoin(this->CompileDefinitions, ";");
- return output.c_str();
+ return &output;
}
cmProp retVal = this->Properties.GetPropertyValue(prop);
@@ -367,28 +368,27 @@ const char* cmSourceFile::GetProperty(const std::string& prop) const
const bool chain =
mf->GetState()->IsPropertyChained(prop, cmProperty::SOURCE_FILE);
if (chain) {
- if (cmProp p = mf->GetProperty(prop, chain)) {
- return p->c_str();
- }
+ return mf->GetProperty(prop, chain);
}
return nullptr;
}
- return retVal->c_str();
+ return retVal;
}
const char* cmSourceFile::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();
}
bool cmSourceFile::GetPropertyAsBool(const std::string& prop) const
{
- return cmIsOn(this->GetProperty(prop));
+ cmProp p = this->GetProperty(prop);
+ return p && cmIsOn(*p);
}
void cmSourceFile::SetProperties(cmPropertyMap properties)
diff --git a/Source/cmSourceFile.h b/Source/cmSourceFile.h
index e22829f..e527069 100644
--- a/Source/cmSourceFile.h
+++ b/Source/cmSourceFile.h
@@ -17,6 +17,8 @@
class cmMakefile;
+using cmProp = const std::string*;
+
/** \class cmSourceFile
* \brief Represent a class loaded from a makefile.
*
@@ -45,7 +47,7 @@ public:
void AppendProperty(const std::string& prop, const std::string& value,
bool asString = false);
//! 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/cmTarget.cxx b/Source/cmTarget.cxx
index 063576c..955a5cc 100644
--- a/Source/cmTarget.cxx
+++ b/Source/cmTarget.cxx
@@ -238,8 +238,11 @@ cmTarget::cmTarget(std::string const& name, cmStateEnums::TargetType type,
!impl->Makefile->GetSafeDefinition("CMAKE_IMPORT_LIBRARY_SUFFIX").empty();
// Check whether we are targeting AIX.
- impl->IsAIX =
- (impl->Makefile->GetSafeDefinition("CMAKE_SYSTEM_NAME") == "AIX");
+ {
+ std::string const& systemName =
+ impl->Makefile->GetSafeDefinition("CMAKE_SYSTEM_NAME");
+ impl->IsAIX = (systemName == "AIX" || systemName == "OS400");
+ }
// Check whether we are targeting an Android platform.
impl->IsAndroid =
@@ -360,6 +363,7 @@ cmTarget::cmTarget(std::string const& name, cmStateEnums::TargetType type,
initProp("CUDA_SEPARABLE_COMPILATION");
initProp("CUDA_RESOLVE_DEVICE_SYMBOLS");
initProp("CUDA_RUNTIME_LIBRARY");
+ initProp("CUDA_ARCHITECTURES");
initProp("LINK_SEARCH_START_STATIC");
initProp("LINK_SEARCH_END_STATIC");
initProp("Swift_LANGUAGE_VERSION");
diff --git a/Source/cmVisualStudio10TargetGenerator.cxx b/Source/cmVisualStudio10TargetGenerator.cxx
index ec7fe96..6cd8edd 100644
--- a/Source/cmVisualStudio10TargetGenerator.cxx
+++ b/Source/cmVisualStudio10TargetGenerator.cxx
@@ -983,8 +983,8 @@ void cmVisualStudio10TargetGenerator::WriteEmbeddedResourceGroup(Elem& e0)
".Designer.cs";
if (cmsys::SystemTools::FileExists(designerResource)) {
std::string generator = "PublicResXFileCodeGenerator";
- if (const char* g = oi->GetProperty("VS_RESOURCE_GENERATOR")) {
- generator = g;
+ if (cmProp g = oi->GetProperty("VS_RESOURCE_GENERATOR")) {
+ generator = *g;
}
if (!generator.empty()) {
e2.Element("Generator", generator);
@@ -1027,10 +1027,10 @@ void cmVisualStudio10TargetGenerator::WriteXamlFilesGroup(Elem& e0)
Elem e1(e0, "ItemGroup");
for (cmSourceFile const* oi : xamlObjs) {
std::string obj = oi->GetFullPath();
- const char* xamlType;
- const char* xamlTypeProperty = oi->GetProperty("VS_XAML_TYPE");
+ std::string xamlType;
+ cmProp xamlTypeProperty = oi->GetProperty("VS_XAML_TYPE");
if (xamlTypeProperty) {
- xamlType = xamlTypeProperty;
+ xamlType = *xamlTypeProperty;
} else {
xamlType = "Page";
}
@@ -1404,6 +1404,9 @@ void cmVisualStudio10TargetGenerator::WriteCustomRule(
spe2 = cm::make_unique<Elem>(*spe1, "CustomBuild");
this->WriteSource(*spe2, source);
spe2->SetHasElements();
+ if (command.GetStdPipesUTF8()) {
+ this->WriteStdOutEncodingUtf8(*spe2);
+ }
} else {
Elem e1(e0, "ItemGroup");
Elem e2(e1, "None");
@@ -1745,9 +1748,9 @@ void cmVisualStudio10TargetGenerator::WriteHeaderSource(Elem& e1,
}
void cmVisualStudio10TargetGenerator::ParseSettingsProperty(
- const char* settingsPropertyValue, ConfigToSettings& toolSettings)
+ const std::string& settingsPropertyValue, ConfigToSettings& toolSettings)
{
- if (settingsPropertyValue) {
+ if (!settingsPropertyValue.empty()) {
cmGeneratorExpression ge;
std::unique_ptr<cmCompiledGeneratorExpression> cge =
@@ -1821,45 +1824,45 @@ void cmVisualStudio10TargetGenerator::WriteExtraSource(Elem& e1,
if (ext == "hlsl") {
tool = "FXCompile";
// Figure out the type of shader compiler to use.
- if (const char* st = sf->GetProperty("VS_SHADER_TYPE")) {
+ if (cmProp st = sf->GetProperty("VS_SHADER_TYPE")) {
for (const std::string& config : this->Configurations) {
- toolSettings[config]["ShaderType"] = st;
+ toolSettings[config]["ShaderType"] = *st;
}
}
// Figure out which entry point to use if any
- if (const char* se = sf->GetProperty("VS_SHADER_ENTRYPOINT")) {
+ if (cmProp se = sf->GetProperty("VS_SHADER_ENTRYPOINT")) {
for (const std::string& config : this->Configurations) {
- toolSettings[config]["EntryPointName"] = se;
+ toolSettings[config]["EntryPointName"] = *se;
}
}
// Figure out which shader model to use if any
- if (const char* sm = sf->GetProperty("VS_SHADER_MODEL")) {
+ if (cmProp sm = sf->GetProperty("VS_SHADER_MODEL")) {
for (const std::string& config : this->Configurations) {
- toolSettings[config]["ShaderModel"] = sm;
+ toolSettings[config]["ShaderModel"] = *sm;
}
}
// Figure out which output header file to use if any
- if (const char* ohf = sf->GetProperty("VS_SHADER_OUTPUT_HEADER_FILE")) {
+ if (cmProp ohf = sf->GetProperty("VS_SHADER_OUTPUT_HEADER_FILE")) {
for (const std::string& config : this->Configurations) {
- toolSettings[config]["HeaderFileOutput"] = ohf;
+ toolSettings[config]["HeaderFileOutput"] = *ohf;
}
}
// Figure out which variable name to use if any
- if (const char* vn = sf->GetProperty("VS_SHADER_VARIABLE_NAME")) {
+ if (cmProp vn = sf->GetProperty("VS_SHADER_VARIABLE_NAME")) {
for (const std::string& config : this->Configurations) {
- toolSettings[config]["VariableName"] = vn;
+ toolSettings[config]["VariableName"] = *vn;
}
}
// Figure out if there's any additional flags to use
- if (const char* saf = sf->GetProperty("VS_SHADER_FLAGS")) {
+ if (cmProp saf = sf->GetProperty("VS_SHADER_FLAGS")) {
for (const std::string& config : this->Configurations) {
- toolSettings[config]["AdditionalOptions"] = saf;
+ toolSettings[config]["AdditionalOptions"] = *saf;
}
}
// Figure out if debug information should be generated
- if (const char* sed = sf->GetProperty("VS_SHADER_ENABLE_DEBUG")) {
+ if (cmProp sed = sf->GetProperty("VS_SHADER_ENABLE_DEBUG")) {
cmGeneratorExpression ge;
- std::unique_ptr<cmCompiledGeneratorExpression> cge = ge.Parse(sed);
+ std::unique_ptr<cmCompiledGeneratorExpression> cge = ge.Parse(*sed);
for (const std::string& config : this->Configurations) {
std::string evaluated = cge->Evaluate(this->LocalGenerator, config);
@@ -1871,9 +1874,9 @@ void cmVisualStudio10TargetGenerator::WriteExtraSource(Elem& e1,
}
}
// Figure out if optimizations should be disabled
- if (const char* sdo = sf->GetProperty("VS_SHADER_DISABLE_OPTIMIZATIONS")) {
+ if (cmProp sdo = sf->GetProperty("VS_SHADER_DISABLE_OPTIMIZATIONS")) {
cmGeneratorExpression ge;
- std::unique_ptr<cmCompiledGeneratorExpression> cge = ge.Parse(sdo);
+ std::unique_ptr<cmCompiledGeneratorExpression> cge = ge.Parse(*sdo);
for (const std::string& config : this->Configurations) {
std::string evaluated = cge->Evaluate(this->LocalGenerator, config);
@@ -1884,9 +1887,9 @@ void cmVisualStudio10TargetGenerator::WriteExtraSource(Elem& e1,
}
}
}
- if (const char* sofn = sf->GetProperty("VS_SHADER_OBJECT_FILE_NAME")) {
+ if (cmProp sofn = sf->GetProperty("VS_SHADER_OBJECT_FILE_NAME")) {
for (const std::string& config : this->Configurations) {
- toolSettings[config]["ObjectFileOutput"] = sofn;
+ toolSettings[config]["ObjectFileOutput"] = *sofn;
}
}
} else if (ext == "jpg" || ext == "png") {
@@ -1907,9 +1910,9 @@ void cmVisualStudio10TargetGenerator::WriteExtraSource(Elem& e1,
} else if (ext == "vsixmanifest") {
subType = "Designer";
}
- if (const char* c = sf->GetProperty("VS_COPY_TO_OUT_DIR")) {
+ if (cmProp c = sf->GetProperty("VS_COPY_TO_OUT_DIR")) {
tool = "Content";
- copyToOutDir = c;
+ copyToOutDir = *c;
toolHasSettings = true;
}
if (sf->GetPropertyAsBool("VS_INCLUDE_IN_VSIX")) {
@@ -1936,23 +1939,23 @@ void cmVisualStudio10TargetGenerator::WriteExtraSource(Elem& e1,
}
}
- const char* toolOverride = sf->GetProperty("VS_TOOL_OVERRIDE");
- if (toolOverride && *toolOverride) {
- tool = toolOverride;
+ cmProp toolOverride = sf->GetProperty("VS_TOOL_OVERRIDE");
+ if (toolOverride && !toolOverride->empty()) {
+ tool = toolOverride->c_str();
}
std::string deployContent;
std::string deployLocation;
if (this->GlobalGenerator->TargetsWindowsPhone() ||
this->GlobalGenerator->TargetsWindowsStore()) {
- const char* content = sf->GetProperty("VS_DEPLOYMENT_CONTENT");
- if (content && *content) {
+ cmProp content = sf->GetProperty("VS_DEPLOYMENT_CONTENT");
+ if (content && !content->empty()) {
toolHasSettings = true;
- deployContent = content;
+ deployContent = *content;
- const char* location = sf->GetProperty("VS_DEPLOYMENT_LOCATION");
- if (location && *location) {
- deployLocation = location;
+ cmProp location = sf->GetProperty("VS_DEPLOYMENT_LOCATION");
+ if (location && !location->empty()) {
+ deployLocation = *location;
}
}
}
@@ -1962,7 +1965,7 @@ void cmVisualStudio10TargetGenerator::WriteExtraSource(Elem& e1,
"VS_SOURCE_SETTINGS_" + std::string(tool));
ConfigToSettings toolTargetSettings;
if (toolTargetProperty) {
- ParseSettingsProperty(toolTargetProperty->c_str(), toolTargetSettings);
+ ParseSettingsProperty(*toolTargetProperty, toolTargetSettings);
}
ParsedToolTargetSettings[tool] = toolTargetSettings;
@@ -1974,7 +1977,9 @@ void cmVisualStudio10TargetGenerator::WriteExtraSource(Elem& e1,
}
}
- ParseSettingsProperty(sf->GetProperty("VS_SETTINGS"), toolSettings);
+ if (cmProp p = sf->GetProperty("VS_SETTINGS")) {
+ ParseSettingsProperty(*p, toolSettings);
+ }
if (!toolSettings.empty()) {
toolHasSettings = true;
@@ -2248,7 +2253,7 @@ void cmVisualStudio10TargetGenerator::WriteAllSources(Elem& e0)
e2.Attribute("CustomUnityFile", "true");
std::string unityDir = cmSystemTools::GetFilenamePath(
- si.Source->GetProperty("UNITY_SOURCE_FILE"));
+ *si.Source->GetProperty("UNITY_SOURCE_FILE"));
e2.Attribute("UnityFilesDirectory", unityDir);
} else {
// Visual Studio versions prior to 2017 15.8 do not know about unity
@@ -2293,25 +2298,25 @@ void cmVisualStudio10TargetGenerator::OutputSourceSpecificFlags(
bool configDependentDefines = false;
std::string includes;
bool configDependentIncludes = false;
- if (const char* cflags = sf.GetProperty("COMPILE_FLAGS")) {
+ if (cmProp cflags = sf.GetProperty("COMPILE_FLAGS")) {
configDependentFlags =
- cmGeneratorExpression::Find(cflags) != std::string::npos;
- flags += cflags;
+ cmGeneratorExpression::Find(*cflags) != std::string::npos;
+ flags += *cflags;
}
- if (const char* coptions = sf.GetProperty("COMPILE_OPTIONS")) {
+ if (cmProp coptions = sf.GetProperty("COMPILE_OPTIONS")) {
configDependentOptions =
- cmGeneratorExpression::Find(coptions) != std::string::npos;
- options += coptions;
+ cmGeneratorExpression::Find(*coptions) != std::string::npos;
+ options += *coptions;
}
- if (const char* cdefs = sf.GetProperty("COMPILE_DEFINITIONS")) {
+ if (cmProp cdefs = sf.GetProperty("COMPILE_DEFINITIONS")) {
configDependentDefines =
- cmGeneratorExpression::Find(cdefs) != std::string::npos;
- defines += cdefs;
+ cmGeneratorExpression::Find(*cdefs) != std::string::npos;
+ defines += *cdefs;
}
- if (const char* cincludes = sf.GetProperty("INCLUDE_DIRECTORIES")) {
+ if (cmProp cincludes = sf.GetProperty("INCLUDE_DIRECTORIES")) {
configDependentIncludes =
- cmGeneratorExpression::Find(cincludes) != std::string::npos;
- includes += cincludes;
+ cmGeneratorExpression::Find(*cincludes) != std::string::npos;
+ includes += *cincludes;
}
std::string lang =
this->GlobalGenerator->GetLanguageFromExtension(sf.GetExtension().c_str());
@@ -2350,13 +2355,13 @@ void cmVisualStudio10TargetGenerator::OutputSourceSpecificFlags(
std::string configUpper = cmSystemTools::UpperCase(config);
std::string configDefines = defines;
std::string defPropName = cmStrCat("COMPILE_DEFINITIONS_", configUpper);
- if (const char* ccdefs = sf.GetProperty(defPropName)) {
+ if (cmProp ccdefs = sf.GetProperty(defPropName)) {
if (!configDefines.empty()) {
configDefines += ";";
}
configDependentDefines |=
- cmGeneratorExpression::Find(ccdefs) != std::string::npos;
- configDefines += ccdefs;
+ cmGeneratorExpression::Find(*ccdefs) != std::string::npos;
+ configDefines += *ccdefs;
}
// Add precompile headers compile options.
@@ -4048,6 +4053,7 @@ void cmVisualStudio10TargetGenerator::WriteEvent(
std::string script;
const char* pre = "";
std::string comment;
+ bool stdPipesUTF8 = false;
for (cmCustomCommand const& cc : commands) {
cmCustomCommandGenerator ccg(cc, configName, lg);
if (!ccg.HasOnlyEmptyCommandLines()) {
@@ -4056,11 +4062,16 @@ void cmVisualStudio10TargetGenerator::WriteEvent(
script += pre;
pre = "\n";
script += lg->ConstructScript(ccg);
+
+ stdPipesUTF8 = stdPipesUTF8 || cc.GetStdPipesUTF8();
}
}
comment = cmVS10EscapeComment(comment);
if (this->ProjectType != csproj) {
Elem e2(e1, name);
+ if (stdPipesUTF8) {
+ this->WriteStdOutEncodingUtf8(e2);
+ }
e2.Element("Message", comment);
e2.Element("Command", script);
} else {
@@ -4887,8 +4898,8 @@ std::string cmVisualStudio10TargetGenerator::GetCSharpSourceLink(
link = fullFileName.substr(srcDir.length() + 1);
} else if (cmHasPrefix(fullFileName, binDir)) {
link = fullFileName.substr(binDir.length() + 1);
- } else if (const char* l = source->GetProperty("VS_CSHARP_Link")) {
- link = l;
+ } else if (cmProp l = source->GetProperty("VS_CSHARP_Link")) {
+ link = *l;
}
ConvertToWindowsSlash(link);
@@ -4905,3 +4916,8 @@ std::string cmVisualStudio10TargetGenerator::GetCMakeFilePath(
return path;
}
+
+void cmVisualStudio10TargetGenerator::WriteStdOutEncodingUtf8(Elem& e1)
+{
+ e1.Element("StdOutEncoding", "UTF-8");
+}
diff --git a/Source/cmVisualStudio10TargetGenerator.h b/Source/cmVisualStudio10TargetGenerator.h
index e588de8..e3782f4 100644
--- a/Source/cmVisualStudio10TargetGenerator.h
+++ b/Source/cmVisualStudio10TargetGenerator.h
@@ -184,6 +184,8 @@ private:
Elem& e2, const std::map<std::string, std::string>& tags);
std::string GetCSharpSourceLink(cmSourceFile const* source);
+ void WriteStdOutEncodingUtf8(Elem& e1);
+
private:
friend class cmVS10GeneratorOptions;
using Options = cmVS10GeneratorOptions;
@@ -242,7 +244,7 @@ private:
std::unordered_map<std::string, ConfigToSettings> ParsedToolTargetSettings;
bool PropertyIsSameInAllConfigs(const ConfigToSettings& toolSettings,
const std::string& propName);
- void ParseSettingsProperty(const char* settingsPropertyValue,
+ void ParseSettingsProperty(const std::string& settingsPropertyValue,
ConfigToSettings& toolSettings);
std::string GetCMakeFilePath(const char* name) const;
};
diff --git a/Source/cmake.cxx b/Source/cmake.cxx
index 2ec893f..ea1d8ca 100644
--- a/Source/cmake.cxx
+++ b/Source/cmake.cxx
@@ -642,6 +642,8 @@ void cmake::SetArgs(const std::vector<std::string>& args)
path = cmSystemTools::CollapseFullPath(path);
cmSystemTools::ConvertToUnixSlashes(path);
this->SetHomeDirectory(path);
+ // XXX(clang-tidy): https://bugs.llvm.org/show_bug.cgi?id=44165
+ // NOLINTNEXTLINE(bugprone-branch-clone)
} else if (cmHasLiteralPrefix(arg, "-O")) {
// There is no local generate anymore. Ignore -O option.
} else if (cmHasLiteralPrefix(arg, "-B")) {
@@ -681,27 +683,16 @@ void cmake::SetArgs(const std::vector<std::string>& args)
this->VSSolutionFile = args[++i];
}
#endif
- else if (cmHasLiteralPrefix(arg, "-D")) {
+ else if (cmHasLiteralPrefix(arg, "-D") || cmHasLiteralPrefix(arg, "-U") ||
+ cmHasLiteralPrefix(arg, "-C")) {
// skip for now
- // in case '-D var=val' is given, also skip the next
- // in case '-Dvar=val' is given, don't skip the next
- if (arg.size() == 2) {
- ++i;
- }
- } else if (cmHasLiteralPrefix(arg, "-U")) {
- // skip for now
- // in case '-U var' is given, also skip the next
- // in case '-Uvar' is given, don't skip the next
- if (arg.size() == 2) {
- ++i;
- }
- } else if (cmHasLiteralPrefix(arg, "-C")) {
- // skip for now
- // in case '-C path' is given, also skip the next
- // in case '-Cpath' is given, don't skip the next
+ // in case '-[DUC] argval' var' is given, also skip the next
+ // in case '-[DUC]argval' is given, don't skip the next
if (arg.size() == 2) {
++i;
}
+ // XXX(clang-tidy): https://bugs.llvm.org/show_bug.cgi?id=44165
+ // NOLINTNEXTLINE(bugprone-branch-clone)
} else if (cmHasLiteralPrefix(arg, "-P")) {
// skip for now
i++;
diff --git a/Source/cmcmd.cxx b/Source/cmcmd.cxx
index 3befb18..67a5d92 100644
--- a/Source/cmcmd.cxx
+++ b/Source/cmcmd.cxx
@@ -2007,9 +2007,8 @@ bool cmVSLink::Parse(std::vector<std::string>::const_iterator argBeg,
// Parse the link command to extract information we need.
for (; arg != argEnd; ++arg) {
- if (cmSystemTools::Strucmp(arg->c_str(), "/INCREMENTAL:YES") == 0) {
- this->Incremental = true;
- } else if (cmSystemTools::Strucmp(arg->c_str(), "/INCREMENTAL") == 0) {
+ if (cmSystemTools::Strucmp(arg->c_str(), "/INCREMENTAL:YES") == 0 ||
+ cmSystemTools::Strucmp(arg->c_str(), "/INCREMENTAL") == 0) {
this->Incremental = true;
} else if (cmSystemTools::Strucmp(arg->c_str(), "/MANIFEST:NO") == 0) {
this->LinkGeneratesManifest = false;
diff --git a/Source/kwsys/Base64.c b/Source/kwsys/Base64.c
index bf876f2..4265018 100644
--- a/Source/kwsys/Base64.c
+++ b/Source/kwsys/Base64.c
@@ -130,7 +130,10 @@ size_t kwsysBase64_Encode(const unsigned char* input, size_t length,
/* Decode 4 bytes into a 3 byte string. */
int kwsysBase64_Decode3(const unsigned char* src, unsigned char* dest)
{
- unsigned char d0, d1, d2, d3;
+ unsigned char d0;
+ unsigned char d1;
+ unsigned char d2;
+ unsigned char d3;
d0 = kwsysBase64DecodeChar(src[0]);
d1 = kwsysBase64DecodeChar(src[1]);
diff --git a/Source/kwsys/MD5.c b/Source/kwsys/MD5.c
index 97cf9ba..fb18a5b 100644
--- a/Source/kwsys/MD5.c
+++ b/Source/kwsys/MD5.c
@@ -171,8 +171,10 @@ typedef struct md5_state_s
static void md5_process(md5_state_t* pms, const md5_byte_t* data /*[64]*/)
{
- md5_word_t a = pms->abcd[0], b = pms->abcd[1], c = pms->abcd[2],
- d = pms->abcd[3];
+ md5_word_t a = pms->abcd[0];
+ md5_word_t b = pms->abcd[1];
+ md5_word_t c = pms->abcd[2];
+ md5_word_t d = pms->abcd[3];
md5_word_t t;
#if BYTE_ORDER > 0
/* Define storage only for big-endian CPUs. */
@@ -227,9 +229,10 @@ static void md5_process(md5_state_t* pms, const md5_byte_t* data /*[64]*/)
# else
# define xbuf X /* (static only) */
# endif
- for (i = 0; i < 16; ++i, xp += 4)
+ for (i = 0; i < 16; ++i, xp += 4) {
xbuf[i] =
(md5_word_t)(xp[0] + (xp[1] << 8) + (xp[2] << 16) + (xp[3] << 24));
+ }
}
#endif
}
@@ -367,34 +370,39 @@ static void md5_append(md5_state_t* pms, const md5_byte_t* data, size_t nbytes)
size_t offset = (pms->count[0] >> 3) & 63;
md5_word_t nbits = (md5_word_t)(nbytes << 3);
- if (nbytes <= 0)
+ if (nbytes <= 0) {
return;
+ }
/* Update the message length. */
pms->count[1] += (md5_word_t)(nbytes >> 29);
pms->count[0] += nbits;
- if (pms->count[0] < nbits)
+ if (pms->count[0] < nbits) {
pms->count[1]++;
+ }
/* Process an initial partial block. */
if (offset) {
size_t copy = (offset + nbytes > 64 ? 64 - offset : nbytes);
memcpy(pms->buf + offset, p, copy);
- if (offset + copy < 64)
+ if (offset + copy < 64) {
return;
+ }
p += copy;
left -= copy;
md5_process(pms, pms->buf);
}
/* Process full blocks. */
- for (; left >= 64; p += 64, left -= 64)
+ for (; left >= 64; p += 64, left -= 64) {
md5_process(pms, p);
+ }
/* Process a final partial block. */
- if (left)
+ if (left) {
memcpy(pms->buf, p, left);
+ }
}
/* Finish the message and return the digest. */
@@ -409,14 +417,16 @@ static void md5_finish(md5_state_t* pms, md5_byte_t digest[16])
int i;
/* Save the length before padding. */
- for (i = 0; i < 8; ++i)
+ for (i = 0; i < 8; ++i) {
data[i] = (md5_byte_t)(pms->count[i >> 2] >> ((i & 3) << 3));
+ }
/* Pad to 56 bytes mod 64. */
md5_append(pms, pad, ((55 - (pms->count[0] >> 3)) & 63) + 1);
/* Append the length. */
md5_append(pms, data, 8);
- for (i = 0; i < 16; ++i)
+ for (i = 0; i < 16; ++i) {
digest[i] = (md5_byte_t)(pms->abcd[i >> 2] >> ((i & 3) << 3));
+ }
}
#if defined(__clang__) && !defined(__INTEL_COMPILER)
diff --git a/Source/kwsys/ProcessUNIX.c b/Source/kwsys/ProcessUNIX.c
index 5fde0b0..cc45529 100644
--- a/Source/kwsys/ProcessUNIX.c
+++ b/Source/kwsys/ProcessUNIX.c
@@ -432,8 +432,8 @@ int kwsysProcess_AddCommand(kwsysProcess* cp, char const* const* command)
char const* const* c = command;
kwsysProcess_ptrdiff_t n = 0;
kwsysProcess_ptrdiff_t i = 0;
- while (*c++)
- ;
+ while (*c++) {
+ }
n = c - command - 1;
newCommands[cp->NumberOfCommands] =
(char**)malloc((size_t)(n + 1) * sizeof(char*));
@@ -685,7 +685,8 @@ const char* kwsysProcess_GetErrorString(kwsysProcess* cp)
{
if (!cp) {
return "Process management structure could not be allocated";
- } else if (cp->State == kwsysProcess_State_Error) {
+ }
+ if (cp->State == kwsysProcess_State_Error) {
return cp->ErrorMessage;
}
return "Success";
@@ -695,7 +696,8 @@ const char* kwsysProcess_GetExceptionString(kwsysProcess* cp)
{
if (!(cp && cp->ProcessResults && (cp->NumberOfCommands > 0))) {
return "GetExceptionString called with NULL process management structure";
- } else if (cp->State == kwsysProcess_State_Exception) {
+ }
+ if (cp->State == kwsysProcess_State_Exception) {
return cp->ProcessResults[cp->NumberOfCommands - 1].ExitExceptionString;
}
return "No exception";
@@ -787,8 +789,8 @@ void kwsysProcess_Execute(kwsysProcess* cp)
/* Some platforms specify that the chdir call may be
interrupted. Repeat the call until it finishes. */
- while (((r = chdir(cp->WorkingDirectory)) < 0) && (errno == EINTR))
- ;
+ while (((r = chdir(cp->WorkingDirectory)) < 0) && (errno == EINTR)) {
+ }
if (r < 0) {
kwsysProcessCleanup(cp, 1);
return;
@@ -1014,8 +1016,8 @@ void kwsysProcess_Execute(kwsysProcess* cp)
if (cp->RealWorkingDirectory) {
/* Some platforms specify that the chdir call may be
interrupted. Repeat the call until it finishes. */
- while ((chdir(cp->RealWorkingDirectory) < 0) && (errno == EINTR))
- ;
+ while ((chdir(cp->RealWorkingDirectory) < 0) && (errno == EINTR)) {
+ }
free(cp->RealWorkingDirectory);
cp->RealWorkingDirectory = 0;
}
@@ -1100,22 +1102,22 @@ int kwsysProcess_WaitForData(kwsysProcess* cp, char** data, int* length,
if (wd.PipeId) {
/* Data are ready on a pipe. */
return wd.PipeId;
- } else if (wd.Expired) {
+ }
+ if (wd.Expired) {
/* A timeout has expired. */
if (wd.User) {
/* The user timeout has expired. It has no time left. */
return kwsysProcess_Pipe_Timeout;
- } else {
- /* The process timeout has expired. Kill the children now. */
- kwsysProcess_Kill(cp);
- cp->Killed = 0;
- cp->TimeoutExpired = 1;
- return kwsysProcess_Pipe_None;
}
- } else {
- /* No pipes are left open. */
+
+ /* The process timeout has expired. Kill the children now. */
+ kwsysProcess_Kill(cp);
+ cp->Killed = 0;
+ cp->TimeoutExpired = 1;
return kwsysProcess_Pipe_None;
}
+ /* No pipes are left open. */
+ return kwsysProcess_Pipe_None;
}
static int kwsysProcessWaitForPipe(kwsysProcess* cp, char** data, int* length,
@@ -1145,8 +1147,8 @@ static int kwsysProcessWaitForPipe(kwsysProcess* cp, char** data, int* length,
read until the operation is not interrupted. */
while (((n = read(cp->PipeReadEnds[i], cp->PipeBuffer,
KWSYSPE_PIPE_BUFFER_SIZE)) < 0) &&
- (errno == EINTR))
- ;
+ (errno == EINTR)) {
+ }
if (n > 0) {
/* We have data on this pipe. */
if (i == KWSYSPE_PIPE_SIGNAL) {
@@ -1184,7 +1186,7 @@ static int kwsysProcessWaitForPipe(kwsysProcess* cp, char** data, int* length,
/* Make sure the set is empty (it should always be empty here
anyway). */
- FD_ZERO(&cp->PipeSet);
+ FD_ZERO(&cp->PipeSet); // NOLINT(readability-isolate-declaration)
/* Setup a timeout if required. */
if (wd->TimeoutTime.tv_sec < 0) {
@@ -1219,15 +1221,16 @@ static int kwsysProcessWaitForPipe(kwsysProcess* cp, char** data, int* length,
/* Run select to block until data are available. Repeat call
until it is not interrupted. */
while (((numReady = select(max + 1, &cp->PipeSet, 0, 0, timeout)) < 0) &&
- (errno == EINTR))
- ;
+ (errno == EINTR)) {
+ }
/* Check result of select. */
if (numReady == 0) {
/* Select's timeout expired. */
wd->Expired = 1;
return 1;
- } else if (numReady < 0) {
+ }
+ if (numReady < 0) {
/* Select returned an error. Leave the error description in the
pipe buffer. */
strncpy(cp->ErrorMessage, strerror(errno), KWSYSPE_PIPE_BUFFER_SIZE);
@@ -1367,11 +1370,13 @@ int kwsysProcess_WaitForExit(kwsysProcess* cp, double* userTimeout)
cp->ProcessResults[prPipe].State = kwsysProcess_StateByIndex_Exited;
cp->ProcessResults[prPipe].ExitException = kwsysProcess_Exception_None;
cp->ProcessResults[prPipe].ExitValue =
+ // NOLINTNEXTLINE(google-readability-casting)
(int)WEXITSTATUS(cp->ProcessResults[prPipe].ExitCode);
} else if (WIFSIGNALED(cp->ProcessResults[prPipe].ExitCode)) {
/* The child received an unhandled signal. */
cp->ProcessResults[prPipe].State = kwsysProcess_State_Exception;
kwsysProcessSetExitExceptionByIndex(
+ // NOLINTNEXTLINE(google-readability-casting)
cp, (int)WTERMSIG(cp->ProcessResults[prPipe].ExitCode), prPipe);
} else {
/* Error getting the child return code. */
@@ -1450,8 +1455,8 @@ void kwsysProcess_Kill(kwsysProcess* cp)
/* Reap the child. Keep trying until the call is not
interrupted. */
- while ((waitpid(cp->ForkPIDs[i], &status, 0) < 0) && (errno == EINTR))
- ;
+ while ((waitpid(cp->ForkPIDs[i], &status, 0) < 0) && (errno == EINTR)) {
+ }
}
}
@@ -1502,7 +1507,7 @@ static int kwsysProcessInitialize(kwsysProcess* cp)
cp->PipesLeft = 0;
cp->CommandsLeft = 0;
#if KWSYSPE_USE_SELECT
- FD_ZERO(&cp->PipeSet);
+ FD_ZERO(&cp->PipeSet); // NOLINT(readability-isolate-declaration)
#endif
cp->State = kwsysProcess_State_Starting;
cp->Killed = 0;
@@ -1591,16 +1596,16 @@ static void kwsysProcessCleanup(kwsysProcess* cp, int error)
/* Reap the child. Keep trying until the call is not
interrupted. */
while ((waitpid(cp->ForkPIDs[i], &status, 0) < 0) &&
- (errno == EINTR))
- ;
+ (errno == EINTR)) {
+ }
}
}
}
/* Restore the working directory. */
if (cp->RealWorkingDirectory) {
- while ((chdir(cp->RealWorkingDirectory) < 0) && (errno == EINTR))
- ;
+ while ((chdir(cp->RealWorkingDirectory) < 0) && (errno == EINTR)) {
+ }
}
}
@@ -1636,8 +1641,8 @@ static void kwsysProcessCleanupDescriptor(int* pfd)
if (pfd && *pfd > 2) {
/* Keep trying to close until it is not interrupted by a
* signal. */
- while ((close(*pfd) < 0) && (errno == EINTR))
- ;
+ while ((close(*pfd) < 0) && (errno == EINTR)) {
+ }
*pfd = -1;
}
}
@@ -1662,8 +1667,8 @@ static void kwsysProcessClosePipes(kwsysProcess* cp)
read until the operation is not interrupted. */
while ((read(cp->PipeReadEnds[i], cp->PipeBuffer,
KWSYSPE_PIPE_BUFFER_SIZE) < 0) &&
- (errno == EINTR))
- ;
+ (errno == EINTR)) {
+ }
}
#endif
@@ -1690,7 +1695,8 @@ int decc$set_child_standard_streams(int fd1, int fd2, int fd3);
static int kwsysProcessCreate(kwsysProcess* cp, int prIndex,
kwsysProcessCreateInformation* si)
{
- sigset_t mask, old_mask;
+ sigset_t mask;
+ sigset_t old_mask;
int pgidPipe[2];
char tmp;
ssize_t readRes;
@@ -1818,8 +1824,8 @@ static int kwsysProcessCreate(kwsysProcess* cp, int prIndex,
/* Make sure the child is in the process group before we proceed. This
avoids race conditions with calls to the kill function that we make for
signalling process groups. */
- while ((readRes = read(pgidPipe[0], &tmp, 1)) > 0)
- ;
+ while ((readRes = read(pgidPipe[0], &tmp, 1)) > 0) {
+ }
if (readRes < 0) {
sigprocmask(SIG_SETMASK, &old_mask, 0);
kwsysProcessCleanupDescriptor(&si->ErrorPipe[0]);
@@ -1847,8 +1853,8 @@ static int kwsysProcessCreate(kwsysProcess* cp, int prIndex,
/* Keep trying to read until the operation is not interrupted. */
while (((n = read(si->ErrorPipe[0], cp->ErrorMessage + total,
(size_t)(KWSYSPE_PIPE_BUFFER_SIZE - total))) < 0) &&
- (errno == EINTR))
- ;
+ (errno == EINTR)) {
+ }
if (n > 0) {
total += n;
}
@@ -1873,7 +1879,8 @@ static void kwsysProcessDestroy(kwsysProcess* cp)
int i;
/* Temporarily disable signals that access ForkPIDs. We don't want them to
read a reaped PID, and writes to ForkPIDs are not atomic. */
- sigset_t mask, old_mask;
+ sigset_t mask;
+ sigset_t old_mask;
sigemptyset(&mask);
sigaddset(&mask, SIGINT);
sigaddset(&mask, SIGTERM);
@@ -1886,8 +1893,8 @@ static void kwsysProcessDestroy(kwsysProcess* cp)
int result;
while (((result = waitpid(cp->ForkPIDs[i], &cp->CommandExitCodes[i],
WNOHANG)) < 0) &&
- (errno == EINTR))
- ;
+ (errno == EINTR)) {
+ }
if (result > 0) {
/* This child has termianted. */
cp->ForkPIDs[i] = 0;
@@ -2000,28 +2007,26 @@ static int kwsysProcessGetTimeoutLeft(kwsysProcessTime* timeoutTime,
if (timeoutTime->tv_sec < 0) {
/* No timeout time has been requested. */
return 0;
- } else {
- /* Calculate the remaining time. */
- kwsysProcessTime currentTime = kwsysProcessTimeGetCurrent();
- kwsysProcessTime timeLeft =
- kwsysProcessTimeSubtract(*timeoutTime, currentTime);
- if (timeLeft.tv_sec < 0 && userTimeout && *userTimeout <= 0) {
- /* Caller has explicitly requested a zero timeout. */
- timeLeft.tv_sec = 0;
- timeLeft.tv_usec = 0;
- }
+ }
+ /* Calculate the remaining time. */
+ kwsysProcessTime currentTime = kwsysProcessTimeGetCurrent();
+ kwsysProcessTime timeLeft =
+ kwsysProcessTimeSubtract(*timeoutTime, currentTime);
+ if (timeLeft.tv_sec < 0 && userTimeout && *userTimeout <= 0) {
+ /* Caller has explicitly requested a zero timeout. */
+ timeLeft.tv_sec = 0;
+ timeLeft.tv_usec = 0;
+ }
- if (timeLeft.tv_sec < 0 ||
- (timeLeft.tv_sec == 0 && timeLeft.tv_usec == 0 && zeroIsExpired)) {
- /* Timeout has already expired. */
- return 1;
- } else {
- /* There is some time left. */
- timeoutLength->tv_sec = timeLeft.tv_sec;
- timeoutLength->tv_usec = timeLeft.tv_usec;
- return 0;
- }
+ if (timeLeft.tv_sec < 0 ||
+ (timeLeft.tv_sec == 0 && timeLeft.tv_usec == 0 && zeroIsExpired)) {
+ /* Timeout has already expired. */
+ return 1;
}
+ /* There is some time left. */
+ timeoutLength->tv_sec = timeLeft.tv_sec;
+ timeoutLength->tv_usec = timeLeft.tv_usec;
+ return 0;
}
static kwsysProcessTime kwsysProcessTimeGetCurrent(void)
@@ -2426,41 +2431,39 @@ static pid_t kwsysProcessFork(kwsysProcess* cp,
if (middle_pid < 0) {
/* Fork failed. Return as if we were not detaching. */
return middle_pid;
- } else if (middle_pid == 0) {
+ }
+ if (middle_pid == 0) {
/* This is the intermediate process. Create the real child. */
pid_t child_pid = fork();
if (child_pid == 0) {
/* This is the real child process. There is nothing to do here. */
return 0;
- } else {
- /* Use the error pipe to report the pid to the real parent. */
- while ((write(si->ErrorPipe[1], &child_pid, sizeof(child_pid)) < 0) &&
- (errno == EINTR))
- ;
-
- /* Exit without cleanup. The parent holds all resources. */
- kwsysProcessExit();
- return 0; /* Never reached, but avoids SunCC warning. */
}
- } else {
- /* This is the original parent process. The intermediate
- process will use the error pipe to report the pid of the
- detached child. */
- pid_t child_pid;
- int status;
- while ((read(si->ErrorPipe[0], &child_pid, sizeof(child_pid)) < 0) &&
- (errno == EINTR))
- ;
+ /* Use the error pipe to report the pid to the real parent. */
+ while ((write(si->ErrorPipe[1], &child_pid, sizeof(child_pid)) < 0) &&
+ (errno == EINTR)) {
+ }
- /* Wait for the intermediate process to exit and clean it up. */
- while ((waitpid(middle_pid, &status, 0) < 0) && (errno == EINTR))
- ;
- return child_pid;
+ /* Exit without cleanup. The parent holds all resources. */
+ kwsysProcessExit();
+ return 0; /* Never reached, but avoids SunCC warning. */
}
- } else {
- /* Not creating a detached process. Use normal fork. */
- return fork();
+ /* This is the original parent process. The intermediate
+ process will use the error pipe to report the pid of the
+ detached child. */
+ pid_t child_pid;
+ int status;
+ while ((read(si->ErrorPipe[0], &child_pid, sizeof(child_pid)) < 0) &&
+ (errno == EINTR)) {
+ }
+
+ /* Wait for the intermediate process to exit and clean it up. */
+ while ((waitpid(middle_pid, &status, 0) < 0) && (errno == EINTR)) {
+ }
+ return child_pid;
}
+ /* Not creating a detached process. Use normal fork. */
+ return fork();
}
#endif
@@ -2565,7 +2568,8 @@ static void kwsysProcessKill(pid_t process_id)
/* Make sure the process started and provided a valid header. */
if (ps && fscanf(ps, "%*[^\n]\n") != EOF) {
/* Look for processes whose parent is the process being killed. */
- int pid, ppid;
+ int pid;
+ int ppid;
while (fscanf(ps, KWSYSPE_PS_FORMAT, &pid, &ppid) == 2) {
if (ppid == process_id) {
/* Recursively kill this child and its children. */
@@ -2727,8 +2731,8 @@ static int kwsysProcessesAdd(kwsysProcess* cp)
sigemptyset(&newSigAction.sa_mask);
while ((sigaction(SIGCHLD, &newSigAction,
&kwsysProcessesOldSigChldAction) < 0) &&
- (errno == EINTR))
- ;
+ (errno == EINTR)) {
+ }
/* Install our handler for SIGINT / SIGTERM. Repeat call until
it is not interrupted. */
@@ -2736,15 +2740,15 @@ static int kwsysProcessesAdd(kwsysProcess* cp)
sigaddset(&newSigAction.sa_mask, SIGTERM);
while ((sigaction(SIGINT, &newSigAction,
&kwsysProcessesOldSigIntAction) < 0) &&
- (errno == EINTR))
- ;
+ (errno == EINTR)) {
+ }
sigemptyset(&newSigAction.sa_mask);
sigaddset(&newSigAction.sa_mask, SIGINT);
while ((sigaction(SIGTERM, &newSigAction,
&kwsysProcessesOldSigIntAction) < 0) &&
- (errno == EINTR))
- ;
+ (errno == EINTR)) {
+ }
}
}
@@ -2775,14 +2779,14 @@ static void kwsysProcessesRemove(kwsysProcess* cp)
/* Restore the signal handlers. Repeat call until it is not
interrupted. */
while ((sigaction(SIGCHLD, &kwsysProcessesOldSigChldAction, 0) < 0) &&
- (errno == EINTR))
- ;
+ (errno == EINTR)) {
+ }
while ((sigaction(SIGINT, &kwsysProcessesOldSigIntAction, 0) < 0) &&
- (errno == EINTR))
- ;
+ (errno == EINTR)) {
+ }
while ((sigaction(SIGTERM, &kwsysProcessesOldSigTermAction, 0) < 0) &&
- (errno == EINTR))
- ;
+ (errno == EINTR)) {
+ }
/* Free the table of process pointers since it is now empty.
This is safe because the signal handler has been removed. */
@@ -2808,7 +2812,10 @@ static void kwsysProcessesSignalHandler(int signum
#endif
)
{
- int i, j, procStatus, old_errno = errno;
+ int i;
+ int j;
+ int procStatus;
+ int old_errno = errno;
#if KWSYSPE_USE_SIGINFO
(void)info;
(void)ucontext;
@@ -2865,8 +2872,8 @@ static void kwsysProcessesSignalHandler(int signum
memset(&defSigAction, 0, sizeof(defSigAction));
defSigAction.sa_handler = SIG_DFL;
sigemptyset(&defSigAction.sa_mask);
- while ((sigaction(signum, &defSigAction, 0) < 0) && (errno == EINTR))
- ;
+ while ((sigaction(signum, &defSigAction, 0) < 0) && (errno == EINTR)) {
+ }
/* Unmask the signal. */
sigemptyset(&unblockSet);
sigaddset(&unblockSet, signum);
diff --git a/Source/kwsys/SystemTools.cxx b/Source/kwsys/SystemTools.cxx
index 8ec3058..3a6ceec 100644
--- a/Source/kwsys/SystemTools.cxx
+++ b/Source/kwsys/SystemTools.cxx
@@ -1904,7 +1904,7 @@ std::vector<std::string> SystemTools::SplitString(const std::string& p,
paths.emplace_back("/");
}
std::string::size_type pos1 = 0;
- std::string::size_type pos2 = path.find(sep, pos1 + 1);
+ std::string::size_type pos2 = path.find(sep, pos1);
while (pos2 != std::string::npos) {
paths.push_back(path.substr(pos1, pos2 - pos1));
pos1 = pos2 + 1;
diff --git a/Source/kwsys/testProcess.c b/Source/kwsys/testProcess.c
index 39aaa23..74daa12 100644
--- a/Source/kwsys/testProcess.c
+++ b/Source/kwsys/testProcess.c
@@ -631,7 +631,8 @@ int main(int argc, const char* argv[])
}
fprintf(stderr, "Invalid test number %d.\n", n);
return 1;
- } else if (n >= 1 && n <= 10) {
+ }
+ if (n >= 1 && n <= 10) {
/* This is the parent process for a requested test number. */
int states[10] = {
kwsysProcess_State_Exited, kwsysProcess_State_Exited,
@@ -709,7 +710,8 @@ int main(int argc, const char* argv[])
free(argv0);
#endif
return r;
- } else if (argc > 2 && strcmp(argv[1], "0") == 0) {
+ }
+ if (argc > 2 && strcmp(argv[1], "0") == 0) {
/* This is the special debugging test to run a given command
line. */
const char** cmd = argv + 2;
diff --git a/Source/kwsys/testSystemTools.cxx b/Source/kwsys/testSystemTools.cxx
index aa38aec..8909b49 100644
--- a/Source/kwsys/testSystemTools.cxx
+++ b/Source/kwsys/testSystemTools.cxx
@@ -1120,6 +1120,42 @@ static bool CheckURLParsing()
return ret;
}
+static bool CheckSplitString()
+{
+ bool ret = true;
+
+ auto check_split = [](std::string const& input,
+ std::initializer_list<const char*> expected) -> bool {
+ auto const components = kwsys::SystemTools::SplitString(input, '/');
+ if (components.size() != expected.size()) {
+ std::cerr << "Incorrect split count for " << input << ": "
+ << components.size() << std::endl;
+ return false;
+ }
+ size_t i = 0;
+ for (auto& part : expected) {
+ if (components[i] != part) {
+ std::cerr << "Incorrect split component " << i << " for " << input
+ << ": " << components[i] << std::endl;
+ return false;
+ }
+ ++i;
+ }
+ return true;
+ };
+
+ // No separators
+ ret &= check_split("nosep", { "nosep" });
+ // Simple
+ ret &= check_split("first/second", { "first", "second" });
+ // Separator at beginning
+ ret &= check_split("/starts/sep", { "", "starts", "sep" });
+ // Separator at end
+ ret &= check_split("ends/sep/", { "ends", "sep", "" });
+
+ return ret;
+}
+
int testSystemTools(int, char* [])
{
bool res = true;
@@ -1169,5 +1205,7 @@ int testSystemTools(int, char* [])
res &= CheckURLParsing();
+ res &= CheckSplitString();
+
return res ? 0 : 1;
}
diff --git a/Templates/TestDriver.cxx.in b/Templates/TestDriver.cxx.in
index 846a828..053f1ee 100644
--- a/Templates/TestDriver.cxx.in
+++ b/Templates/TestDriver.cxx.in
@@ -45,7 +45,8 @@ static const int NumTests = CM_CAST(int,
(note that it has to be free'd manually) */
static char* lowercase(const char* string)
{
- char *new_string, *p;
+ char *new_string;
+ char *p;
size_t stringSize;
stringSize = CM_CAST(size_t, strlen(string) + 1);
@@ -63,7 +64,9 @@ static char* lowercase(const char* string)
int main(int ac, char* av[])
{
- int i, testNum = 0, partial_match;
+ int i;
+ int testNum = 0;
+ int partial_match;
char *arg;
int testToRun = -1;
diff --git a/Tests/CMakeLists.txt b/Tests/CMakeLists.txt
index 6428235..cc2931b 100644
--- a/Tests/CMakeLists.txt
+++ b/Tests/CMakeLists.txt
@@ -3477,6 +3477,8 @@ ${CMake_SOURCE_DIR}/Utilities/Release/push.bash --dir dev -- '${CMake_BUILD_NIGH
--build-two-config
${build_generator_args}
--build-project IncludeDirectories
+ --build-options
+ -DMAKE_SUPPORTS_SPACES=${MAKE_SUPPORTS_SPACES}
--test-command IncludeDirectories)
list(APPEND TEST_BUILD_DIRS "${CMake_BINARY_DIR}/Tests/IncludeDirectories")
diff --git a/Tests/CMakeTests/ListTest.cmake.in b/Tests/CMakeTests/ListTest.cmake.in
index f517e64..785f41d 100644
--- a/Tests/CMakeTests/ListTest.cmake.in
+++ b/Tests/CMakeTests/ListTest.cmake.in
@@ -85,6 +85,9 @@ set(result ken bill andy brad)
list(SORT result)
TEST("SORT result" "andy;bill;brad;ken")
+list(SORT result COMPARE NATURAL)
+TEST("SORT result COMPARE NATURAL" "andy;bill;brad;ken")
+
set(result andy bill brad ken)
list(REVERSE result)
TEST("REVERSE result" "ken;brad;bill;andy")
@@ -104,6 +107,26 @@ TEST("REVERSE empty result" "")
list(SORT result)
TEST("SORT empty result" "")
+list(SORT result COMPARE NATURAL)
+TEST("SORT result COMPARE NATURAL" "")
+
+set(result 1.1 10.0 11.0 12.0 12.1 2.0 2.1 3.0 3.1 3.2 8.0 9.0)
+
+list(SORT result COMPARE NATURAL)
+TEST("SORT result COMPARE NATURAL" "1.1;2.0;2.1;3.0;3.1;3.2;8.0;9.0;10.0;11.0;12.0;12.1")
+
+list(SORT result)
+TEST("SORT result" "1.1;10.0;11.0;12.0;12.1;2.0;2.1;3.0;3.1;3.2;8.0;9.0")
+
+list(SORT result COMPARE NATURAL ORDER DESCENDING)
+TEST("SORT result COMPARE NATURAL ORDER DESCENDING" "12.1;12.0;11.0;10.0;9.0;8.0;3.2;3.1;3.0;2.1;2.0;1.1")
+
+set(result b-1.1 a-10.0 c-2.0 d 1 00 0)
+
+list(SORT result COMPARE NATURAL)
+TEST("SORT result COMPARE NATURAL" "00;0;1;a-10.0;b-1.1;c-2.0;d")
+
+
# these trigger top-level condition
foreach(cmd IN ITEMS Append Find Get Insert Length Reverse Remove_At Remove_Duplicates Remove_Item Sort)
set(${cmd}-No-Arguments-RESULT 1)
diff --git a/Tests/CPackNSISGenerator/CMakeLists.txt b/Tests/CPackNSISGenerator/CMakeLists.txt
index b8b2ed6..8ed4d59 100644
--- a/Tests/CPackNSISGenerator/CMakeLists.txt
+++ b/Tests/CPackNSISGenerator/CMakeLists.txt
@@ -16,5 +16,6 @@ set(CPACK_NSIS_MUI_ICON "${PROJECT_SOURCE_DIR}\\\\install.ico")
set(CPACK_NSIS_MUI_UNIICON "${PROJECT_SOURCE_DIR}\\\\uninstall.ico")
set(CPACK_GENERATOR "NSIS")
set(CPACK_NSIS_ENABLE_UNINSTALL_BEFORE_INSTALL ON)
+set(CPACK_NSIS_MANIFEST_DPI_AWARE ON)
include(CPack)
diff --git a/Tests/CPackNSISGenerator/RunCPackVerifyResult.cmake b/Tests/CPackNSISGenerator/RunCPackVerifyResult.cmake
index 01b37c5..bfbcf9c 100644
--- a/Tests/CPackNSISGenerator/RunCPackVerifyResult.cmake
+++ b/Tests/CPackNSISGenerator/RunCPackVerifyResult.cmake
@@ -44,3 +44,11 @@ message(STATUS "Found the bitmap at index ${output_index}")
if("${output_index}" EQUAL "-1")
message(FATAL_ERROR "MUI_HEADERIMAGE_BITMAP not found in the project")
endif()
+
+file(STRINGS "${project_file}" line REGEX "^ManifestDPIAware true")
+string(FIND "${line}" "true" output_index)
+if("${output_index}" EQUAL "-1")
+ message(FATAL_ERROR "ManifestDPIAware true not found in the project")
+else()
+ message(STATUS "Found DPI-aware")
+endif()
diff --git a/Tests/Cuda/CXXStandardSetTwice/CMakeLists.txt b/Tests/Cuda/CXXStandardSetTwice/CMakeLists.txt
index 1941c49..f4ad83a 100644
--- a/Tests/Cuda/CXXStandardSetTwice/CMakeLists.txt
+++ b/Tests/Cuda/CXXStandardSetTwice/CMakeLists.txt
@@ -1,9 +1,8 @@
cmake_minimum_required(VERSION 3.7)
project(CXXStandardSetTwice CXX CUDA)
-string(APPEND CMAKE_CUDA_FLAGS " -gencode arch=compute_30,code=compute_30")
-
set(CMAKE_CXX_STANDARD 11)
+set(CMAKE_CUDA_ARCHITECTURES 30)
add_executable(CXXStandardSetTwice main.cu)
target_compile_features(CXXStandardSetTwice PUBLIC cxx_std_11)
diff --git a/Tests/Cuda/Complex/CMakeLists.txt b/Tests/Cuda/Complex/CMakeLists.txt
index 08d1e16..265bd85 100644
--- a/Tests/Cuda/Complex/CMakeLists.txt
+++ b/Tests/Cuda/Complex/CMakeLists.txt
@@ -15,7 +15,7 @@ project (Complex CXX CUDA)
#and also building cpp targets that need cuda implicit libraries
#verify that we can pass explicit cuda arch flags
-string(APPEND CMAKE_CUDA_FLAGS " -gencode arch=compute_30,code=compute_30")
+set(CMAKE_CUDA_ARCHITECTURES 30)
set(CMAKE_CUDA_STANDARD 11)
set(CMAKE_CXX_STANDARD 11)
set(CMAKE_CUDA_STANDARD_REQUIRED TRUE)
diff --git a/Tests/Cuda/MixedStandardLevels1/CMakeLists.txt b/Tests/Cuda/MixedStandardLevels1/CMakeLists.txt
index b03e51e..e40ffa6 100644
--- a/Tests/Cuda/MixedStandardLevels1/CMakeLists.txt
+++ b/Tests/Cuda/MixedStandardLevels1/CMakeLists.txt
@@ -1,10 +1,9 @@
cmake_minimum_required(VERSION 3.7)
project(MixedStandardLevels1 CXX CUDA)
-string(APPEND CMAKE_CUDA_FLAGS " -gencode arch=compute_30,code=compute_30")
-
set(CMAKE_CXX_STANDARD 14)
set(CMAKE_CUDA_STANDARD 11)
+set(CMAKE_CUDA_ARCHITECTURES 30)
add_executable(MixedStandardLevels1 main.cu lib.cpp)
diff --git a/Tests/Cuda/MixedStandardLevels2/CMakeLists.txt b/Tests/Cuda/MixedStandardLevels2/CMakeLists.txt
index 12dd328..7af8081 100644
--- a/Tests/Cuda/MixedStandardLevels2/CMakeLists.txt
+++ b/Tests/Cuda/MixedStandardLevels2/CMakeLists.txt
@@ -1,9 +1,8 @@
cmake_minimum_required(VERSION 3.7)
project(MixedStandardLevels2 CXX CUDA)
-string(APPEND CMAKE_CUDA_FLAGS " -gencode arch=compute_30,code=compute_30")
-
set(CMAKE_CXX_STANDARD 17) #this can decay
+set(CMAKE_CUDA_ARCHITECTURES 30)
add_executable(MixedStandardLevels2 main.cu lib.cpp)
target_compile_features(MixedStandardLevels2 PUBLIC cuda_std_11)
diff --git a/Tests/Cuda/MixedStandardLevels3/CMakeLists.txt b/Tests/Cuda/MixedStandardLevels3/CMakeLists.txt
index 2b611be..2c42003 100644
--- a/Tests/Cuda/MixedStandardLevels3/CMakeLists.txt
+++ b/Tests/Cuda/MixedStandardLevels3/CMakeLists.txt
@@ -1,7 +1,7 @@
cmake_minimum_required(VERSION 3.7)
project(MixedStandardLevels3 CXX CUDA)
-string(APPEND CMAKE_CUDA_FLAGS " -gencode arch=compute_30,code=compute_30")
+set(CMAKE_CUDA_ARCHITECTURES 30)
add_executable(MixedStandardLevels3 main.cu lib.cpp)
target_compile_features(MixedStandardLevels3 PUBLIC cuda_std_03 cxx_std_14)
diff --git a/Tests/Cuda/MixedStandardLevels4/CMakeLists.txt b/Tests/Cuda/MixedStandardLevels4/CMakeLists.txt
index faf6869..230230d 100644
--- a/Tests/Cuda/MixedStandardLevels4/CMakeLists.txt
+++ b/Tests/Cuda/MixedStandardLevels4/CMakeLists.txt
@@ -1,9 +1,8 @@
cmake_minimum_required(VERSION 3.7)
project(MixedStandardLevels4 CXX CUDA)
-string(APPEND CMAKE_CUDA_FLAGS " -gencode arch=compute_30,code=compute_30")
-
set(CMAKE_CUDA_STANDARD 03)
+set(CMAKE_CUDA_ARCHITECTURES 30)
add_executable(MixedStandardLevels4 main.cu lib.cpp)
target_compile_features(MixedStandardLevels4 PUBLIC cxx_std_14)
diff --git a/Tests/Cuda/MixedStandardLevels5/CMakeLists.txt b/Tests/Cuda/MixedStandardLevels5/CMakeLists.txt
index 7209f60..5f5ee06 100644
--- a/Tests/Cuda/MixedStandardLevels5/CMakeLists.txt
+++ b/Tests/Cuda/MixedStandardLevels5/CMakeLists.txt
@@ -1,9 +1,8 @@
cmake_minimum_required(VERSION 3.7)
project(MixedStandardLevels5 CXX CUDA)
-string(APPEND CMAKE_CUDA_FLAGS " -gencode arch=compute_30,code=compute_30")
-
set(CMAKE_CXX_STANDARD 98)
+set(CMAKE_CUDA_ARCHITECTURES 30)
add_executable(MixedStandardLevels5 main.cu lib.cpp)
diff --git a/Tests/Cuda/ProperDeviceLibraries/CMakeLists.txt b/Tests/Cuda/ProperDeviceLibraries/CMakeLists.txt
index cb47b09..fe28c3e 100644
--- a/Tests/Cuda/ProperDeviceLibraries/CMakeLists.txt
+++ b/Tests/Cuda/ProperDeviceLibraries/CMakeLists.txt
@@ -1,8 +1,8 @@
cmake_minimum_required(VERSION 3.13)
project(ProperDeviceLibraries CXX CUDA)
-string(APPEND CMAKE_CUDA_FLAGS " -gencode arch=compute_35,code=compute_35 -gencode arch=compute_35,code=sm_35")
set(CMAKE_CUDA_STANDARD 11)
+set(CMAKE_CUDA_ARCHITECTURES 35)
set(THREADS_PREFER_PTHREAD_FLAG ON)
find_package(Threads)
diff --git a/Tests/Cuda/WithC/CMakeLists.txt b/Tests/Cuda/WithC/CMakeLists.txt
index 69aa3f9..049cbce 100644
--- a/Tests/Cuda/WithC/CMakeLists.txt
+++ b/Tests/Cuda/WithC/CMakeLists.txt
@@ -1,7 +1,7 @@
cmake_minimum_required(VERSION 3.7)
project(WithC CUDA C)
-string(APPEND CMAKE_CUDA_FLAGS " -gencode arch=compute_30,code=compute_30")
+set(CMAKE_CUDA_ARCHITECTURES 30)
add_executable(CudaWithC main.c cuda.cu)
diff --git a/Tests/CudaOnly/Architecture/CMakeLists.txt b/Tests/CudaOnly/Architecture/CMakeLists.txt
new file mode 100644
index 0000000..7270b56
--- /dev/null
+++ b/Tests/CudaOnly/Architecture/CMakeLists.txt
@@ -0,0 +1,5 @@
+cmake_minimum_required(VERSION 3.17)
+project(Architecture CUDA)
+
+set(CMAKE_CUDA_ARCHITECTURES 52)
+add_executable(Architecture main.cu)
diff --git a/Tests/CudaOnly/Architecture/main.cu b/Tests/CudaOnly/Architecture/main.cu
new file mode 100644
index 0000000..8c817d5
--- /dev/null
+++ b/Tests/CudaOnly/Architecture/main.cu
@@ -0,0 +1,9 @@
+#ifdef __CUDA_ARCH__
+# if __CUDA_ARCH__ != 520
+# error "Passed architecture 52, but got something else."
+# endif
+#endif
+
+int main()
+{
+}
diff --git a/Tests/CudaOnly/CMakeLists.txt b/Tests/CudaOnly/CMakeLists.txt
index cc1ee1a..d74e810 100644
--- a/Tests/CudaOnly/CMakeLists.txt
+++ b/Tests/CudaOnly/CMakeLists.txt
@@ -1,5 +1,7 @@
+ADD_TEST_MACRO(CudaOnly.Architecture Architecture)
ADD_TEST_MACRO(CudaOnly.CircularLinkLine CudaOnlyCircularLinkLine)
+ADD_TEST_MACRO(CudaOnly.CompileFlags CudaOnlyCompileFlags)
ADD_TEST_MACRO(CudaOnly.EnableStandard CudaOnlyEnableStandard)
ADD_TEST_MACRO(CudaOnly.ExportPTX CudaOnlyExportPTX)
ADD_TEST_MACRO(CudaOnly.GPUDebugFlag CudaOnlyGPUDebugFlag)
diff --git a/Tests/CudaOnly/CircularLinkLine/CMakeLists.txt b/Tests/CudaOnly/CircularLinkLine/CMakeLists.txt
index 5e6f7ab..e10a348 100644
--- a/Tests/CudaOnly/CircularLinkLine/CMakeLists.txt
+++ b/Tests/CudaOnly/CircularLinkLine/CMakeLists.txt
@@ -5,9 +5,9 @@ project (CircularLinkLine CUDA)
# Verify that we de-duplicate the device link line
# Verify that a de-duplicated link line still works with circular static libraries
-string(APPEND CMAKE_CUDA_FLAGS " -gencode arch=compute_30,code=[compute_30]")
set(CMAKE_CXX_STANDARD 11)
set(CMAKE_CUDA_STANDARD 11)
+set(CMAKE_CUDA_ARCHITECTURES 30)
add_library(CUDACircularDeviceLinking1 STATIC file1.cu)
add_library(CUDACircularDeviceLinking2 STATIC file2.cu)
diff --git a/Tests/CudaOnly/CompileFlags/CMakeLists.txt b/Tests/CudaOnly/CompileFlags/CMakeLists.txt
new file mode 100644
index 0000000..cbce7d6
--- /dev/null
+++ b/Tests/CudaOnly/CompileFlags/CMakeLists.txt
@@ -0,0 +1,16 @@
+cmake_minimum_required(VERSION 3.17)
+cmake_policy(SET CMP0104 OLD)
+project(CompileFlags CUDA)
+
+# Clear defaults.
+set(CMAKE_CUDA_ARCHITECTURES)
+
+add_executable(CudaOnlyCompileFlags main.cu)
+
+# Try passing CUDA architecture flags explicitly.
+if(CMAKE_CUDA_COMPILER_ID STREQUAL "NVIDIA")
+ target_compile_options(CudaOnlyCompileFlags PRIVATE
+ -gencode arch=compute_50,code=compute_50
+ --compiler-options=-DHOST_DEFINE
+ )
+endif()
diff --git a/Tests/CudaOnly/CompileFlags/main.cu b/Tests/CudaOnly/CompileFlags/main.cu
new file mode 100644
index 0000000..573d230
--- /dev/null
+++ b/Tests/CudaOnly/CompileFlags/main.cu
@@ -0,0 +1,16 @@
+#ifdef __CUDA_ARCH__
+# if __CUDA_ARCH__ != 500
+# error "Passed architecture 50, but got something else."
+# endif
+#endif
+
+// Check HOST_DEFINE only for nvcc
+#ifndef __CUDA__
+# ifndef HOST_DEFINE
+# error "HOST_DEFINE not defined!"
+# endif
+#endif
+
+int main()
+{
+}
diff --git a/Tests/CudaOnly/DontResolveDeviceSymbols/CMakeLists.txt b/Tests/CudaOnly/DontResolveDeviceSymbols/CMakeLists.txt
index 6e3697f..1265660 100644
--- a/Tests/CudaOnly/DontResolveDeviceSymbols/CMakeLists.txt
+++ b/Tests/CudaOnly/DontResolveDeviceSymbols/CMakeLists.txt
@@ -24,9 +24,9 @@ endif()
# Don't resolve the device symbols in the static library
# Don't resolve the device symbols in the executable library
# Verify that we can't use those device symbols from anything
-string(APPEND CMAKE_CUDA_FLAGS " -gencode arch=compute_30,code=[compute_30] -gencode arch=compute_50,code=\\\"compute_50\\\"")
set(CMAKE_CXX_STANDARD 11)
set(CMAKE_CUDA_STANDARD 11)
+set(CMAKE_CUDA_ARCHITECTURES 30 50)
set(CMAKE_CUDA_RESOLVE_DEVICE_SYMBOLS OFF)
add_library(CUDANoDeviceResolve SHARED file1.cu)
diff --git a/Tests/CudaOnly/ResolveDeviceSymbols/CMakeLists.txt b/Tests/CudaOnly/ResolveDeviceSymbols/CMakeLists.txt
index 57aa0b9..bd94ec8 100644
--- a/Tests/CudaOnly/ResolveDeviceSymbols/CMakeLists.txt
+++ b/Tests/CudaOnly/ResolveDeviceSymbols/CMakeLists.txt
@@ -21,7 +21,7 @@ endif()
# confirming that the first static library is on the device link line
# 3. Verify that we can't use those device symbols from anything that links
# to the static library
-string(APPEND CMAKE_CUDA_FLAGS " -gencode arch=compute_30,code=[sm_30] -gencode arch=compute_50,code=\\\"compute_50\\\"")
+set(CMAKE_CUDA_ARCHITECTURES 30 50)
add_library(CUDAResolveDeviceDepsA STATIC file1.cu)
add_library(CUDAResolveDeviceDepsB STATIC file2.cu)
diff --git a/Tests/CudaOnly/RuntimeControls/CMakeLists.txt b/Tests/CudaOnly/RuntimeControls/CMakeLists.txt
index 8b58fec..0da5739 100644
--- a/Tests/CudaOnly/RuntimeControls/CMakeLists.txt
+++ b/Tests/CudaOnly/RuntimeControls/CMakeLists.txt
@@ -15,9 +15,8 @@ else()
endif()
endif()
-string(APPEND CMAKE_CUDA_FLAGS " -gencode arch=compute_30,code=[compute_30]")
-
set(CMAKE_CUDA_STANDARD 11)
+set(CMAKE_CUDA_ARCHITECTURES 30)
set(CMAKE_CUDA_RUNTIME_LIBRARY static)
if(NOT "x${CMAKE_CUDA_SIMULATE_ID}" STREQUAL "xMSVC")
diff --git a/Tests/CudaOnly/SeparateCompilation/CMakeLists.txt b/Tests/CudaOnly/SeparateCompilation/CMakeLists.txt
index c1bd64a..586be81 100644
--- a/Tests/CudaOnly/SeparateCompilation/CMakeLists.txt
+++ b/Tests/CudaOnly/SeparateCompilation/CMakeLists.txt
@@ -9,9 +9,7 @@ project (SeparateCompilation CUDA)
#and executables.
#We complicate the matter by also testing that multiple static libraries
#all containing cuda separable compilation code links properly
-string(APPEND CMAKE_CUDA_FLAGS " -gencode arch=compute_30,code=\\\"compute_30,sm_30,sm_35\\\"")
-string(APPEND CMAKE_CUDA_FLAGS " --generate-code=arch=compute_50,code=[compute_50,sm_50,sm_52]")
-
+set(CMAKE_CUDA_ARCHITECTURES 30 35 50 52)
set(CMAKE_CUDA_SEPARABLE_COMPILATION ON)
add_library(CUDASeparateLibA STATIC file1.cu file2.cu file3.cu)
target_compile_features(CUDASeparateLibA PRIVATE cuda_std_11)
diff --git a/Tests/CudaOnly/Standard98/CMakeLists.txt b/Tests/CudaOnly/Standard98/CMakeLists.txt
index ef9a685..3ba0360 100644
--- a/Tests/CudaOnly/Standard98/CMakeLists.txt
+++ b/Tests/CudaOnly/Standard98/CMakeLists.txt
@@ -1,7 +1,7 @@
cmake_minimum_required(VERSION 3.7)
project(CudaOnlyStandard98 CUDA)
-string(APPEND CMAKE_CUDA_FLAGS " -gencode arch=compute_30,code=compute_30")
+set(CMAKE_CUDA_ARCHITECTURES 30)
# Support setting CUDA Standard to 98 which internally gets transformed to
# CUDA03
diff --git a/Tests/CudaOnly/WithDefs/CMakeLists.txt b/Tests/CudaOnly/WithDefs/CMakeLists.txt
index ba9bf04..add8131 100644
--- a/Tests/CudaOnly/WithDefs/CMakeLists.txt
+++ b/Tests/CudaOnly/WithDefs/CMakeLists.txt
@@ -3,17 +3,7 @@ cmake_minimum_required(VERSION 3.7)
project (WithDefs CUDA)
#verify that we can pass explicit cuda arch flags
-string(APPEND CMAKE_CUDA_FLAGS " -gencode arch=compute_30,code=compute_30")
-if(CMAKE_CUDA_COMPILER_VERSION VERSION_GREATER_EQUAL 9)
- set(debug_compile_flags --generate-code arch=compute_32,code=sm_32)
-else()
- set(debug_compile_flags --generate-code arch=compute_20,code=sm_20)
-endif()
-if(CMAKE_CUDA_SIMULATE_ID STREQUAL "MSVC")
- list(APPEND debug_compile_flags -Xcompiler=-WX)
-else()
- list(APPEND debug_compile_flags -Xcompiler=-Werror)
-endif()
+set(CMAKE_CUDA_ARCHITECTURES 30)
set(release_compile_defs DEFREL)
#Goal for this example:
@@ -29,7 +19,6 @@ target_compile_options(CudaOnlyWithDefs
-DFLAG_COMPILE_LANG_$<COMPILE_LANGUAGE>
-DFLAG_LANG_IS_CUDA=$<COMPILE_LANGUAGE:CUDA>
--compiler-options=-DHOST_DEFINE
- $<$<CONFIG:DEBUG>:$<BUILD_INTERFACE:${debug_compile_flags}>>
)
target_compile_definitions(CudaOnlyWithDefs
diff --git a/Tests/IncludeDirectories/CMakeLists.txt b/Tests/IncludeDirectories/CMakeLists.txt
index fa3309f..eb08676 100644
--- a/Tests/IncludeDirectories/CMakeLists.txt
+++ b/Tests/IncludeDirectories/CMakeLists.txt
@@ -65,6 +65,39 @@ else()
PROPERTIES COMPILE_FLAGS "-ITarProp")
endif()
+# Test escaping of special characters in include directory paths.
+set(special_chars "~@%&{}()!'")
+if(NOT CMAKE_GENERATOR STREQUAL "Watcom WMake")
+ # Watcom seems to have no way to encode these characters.
+ string(APPEND special_chars "#=[]")
+endif()
+if(NOT (MINGW AND CMAKE_GENERATOR MATCHES "(Unix|MSYS) Makefiles"))
+ # FIXME: Dependencies work but command-line generation does not handle '$'.
+ string(APPEND special_chars "$")
+endif()
+if(NOT CMAKE_GENERATOR MATCHES "(Borland|NMake) Makefiles")
+ # NMake and Borland seem to have no way to encode a single '^'.
+ string(APPEND special_chars "^")
+endif()
+if(NOT CMAKE_GENERATOR MATCHES "Visual Studio 9 2008|Watcom WMake")
+ # The vcproj format separates values with ','.
+ string(APPEND special_chars ",")
+endif()
+if(NOT WIN32 AND NOT CYGWIN)
+ string(APPEND special_chars "*?<>")
+endif()
+set(special_dir "${CMAKE_CURRENT_BINARY_DIR}/special-${special_chars}-include")
+file(WRITE "${special_dir}/SpecialDir.h" "#define SPECIAL_DIR_H\n")
+target_include_directories(IncludeDirectories PRIVATE "${special_dir}")
+target_compile_definitions(IncludeDirectories PRIVATE INCLUDE_SPECIAL_DIR)
+
+if(MAKE_SUPPORTS_SPACES)
+ set(special_space_dir "${CMAKE_CURRENT_BINARY_DIR}/special-space ${special_chars}-include")
+ file(WRITE "${special_space_dir}/SpecialSpaceDir.h" "#define SPECIAL_SPACE_DIR_H\n")
+ target_include_directories(IncludeDirectories PRIVATE "${special_space_dir}")
+ target_compile_definitions(IncludeDirectories PRIVATE INCLUDE_SPECIAL_SPACE_DIR)
+endif()
+
add_library(ordertest ordertest.cpp)
target_include_directories(ordertest SYSTEM PUBLIC SystemIncludeDirectories/systemlib)
target_include_directories(ordertest PUBLIC SystemIncludeDirectories/userlib)
diff --git a/Tests/IncludeDirectories/main.cpp b/Tests/IncludeDirectories/main.cpp
index a59d27c..6dc88e2 100644
--- a/Tests/IncludeDirectories/main.cpp
+++ b/Tests/IncludeDirectories/main.cpp
@@ -3,6 +3,20 @@
#include "SrcProp.h"
#include "TarProp.h"
+#ifdef INCLUDE_SPECIAL_DIR
+# include "SpecialDir.h"
+# ifndef SPECIAL_DIR_H
+# error "SPECIAL_DIR_H not defined"
+# endif
+#endif
+
+#ifdef INCLUDE_SPECIAL_SPACE_DIR
+# include "SpecialSpaceDir.h"
+# ifndef SPECIAL_SPACE_DIR_H
+# error "SPECIAL_SPACE_DIR_H not defined"
+# endif
+#endif
+
int main(int argc, char** argv)
{
return 0;
diff --git a/Tests/RunCMake/CMP0104/CMP0104-Common.cmake b/Tests/RunCMake/CMP0104/CMP0104-Common.cmake
new file mode 100644
index 0000000..b3568f1
--- /dev/null
+++ b/Tests/RunCMake/CMP0104/CMP0104-Common.cmake
@@ -0,0 +1,2 @@
+enable_language(CUDA)
+add_library(cuda main.cu)
diff --git a/Tests/RunCMake/CMP0104/CMP0104-NEW.cmake b/Tests/RunCMake/CMP0104/CMP0104-NEW.cmake
new file mode 100644
index 0000000..732ab77
--- /dev/null
+++ b/Tests/RunCMake/CMP0104/CMP0104-NEW.cmake
@@ -0,0 +1,6 @@
+cmake_policy(SET CMP0104 NEW)
+include(CMP0104-Common.cmake)
+
+if(NOT CMAKE_CUDA_ARCHITECTURES)
+ message(FATAL_ERROR "CMAKE_CUDA_ARCHITECTURES is empty with CMP0104 enabled.")
+endif()
diff --git a/Tests/RunCMake/CMP0104/CMP0104-OLD.cmake b/Tests/RunCMake/CMP0104/CMP0104-OLD.cmake
new file mode 100644
index 0000000..415eecc
--- /dev/null
+++ b/Tests/RunCMake/CMP0104/CMP0104-OLD.cmake
@@ -0,0 +1,12 @@
+cmake_policy(SET CMP0104 OLD)
+include(CMP0104-Common.cmake)
+
+if(CMAKE_CUDA_COMPILER_ID STREQUAL "NVIDIA")
+ if(CMAKE_CUDA_ARCHITECTURES)
+ message(FATAL_ERROR "CMAKE_CUDA_ARCHITECTURES isn't empty for NVIDIA with CMP0104 OLD.")
+ endif()
+else(NOT CMAKE_CUDA_COMPILER_ID STREQUAL "Unknown")
+ if(NOT CMAKE_CUDA_ARCHITECTURES)
+ message(FATAL_ERROR "CMAKE_CUDA_ARCHITECTURES isn't non-empty for non-NVIDIA with CMP0104 OLD.")
+ endif()
+endif()
diff --git a/Tests/RunCMake/CMP0104/CMP0104-WARN-stderr.txt b/Tests/RunCMake/CMP0104/CMP0104-WARN-stderr.txt
new file mode 100644
index 0000000..2c9b7d7
--- /dev/null
+++ b/Tests/RunCMake/CMP0104/CMP0104-WARN-stderr.txt
@@ -0,0 +1,8 @@
+CMake Warning \(dev\) in CMakeLists.txt:
+ Policy CMP0104 is not set: CMAKE_CUDA_ARCHITECTURES now detected for NVCC,
+ empty CUDA_ARCHITECTURES not allowed. Run "cmake --help-policy CMP0104"
+ for policy details. Use the cmake_policy command to set the policy and
+ suppress this warning.
+
+ CUDA_ARCHITECTURES is empty for target "cuda".
+This warning is for project developers. Use -Wno-dev to suppress it.
diff --git a/Tests/RunCMake/CMP0104/CMP0104-WARN.cmake b/Tests/RunCMake/CMP0104/CMP0104-WARN.cmake
new file mode 100644
index 0000000..841d0a8
--- /dev/null
+++ b/Tests/RunCMake/CMP0104/CMP0104-WARN.cmake
@@ -0,0 +1 @@
+include(CMP0104-Common.cmake)
diff --git a/Tests/RunCMake/CMP0104/CMakeLists.txt b/Tests/RunCMake/CMP0104/CMakeLists.txt
new file mode 100644
index 0000000..2632ffa
--- /dev/null
+++ b/Tests/RunCMake/CMP0104/CMakeLists.txt
@@ -0,0 +1,3 @@
+cmake_minimum_required(VERSION 3.16)
+project(${RunCMake_TEST} NONE)
+include(${RunCMake_TEST}.cmake)
diff --git a/Tests/RunCMake/CMP0104/RunCMakeTest.cmake b/Tests/RunCMake/CMP0104/RunCMakeTest.cmake
new file mode 100644
index 0000000..bc8e1b1
--- /dev/null
+++ b/Tests/RunCMake/CMP0104/RunCMakeTest.cmake
@@ -0,0 +1,5 @@
+include(RunCMake)
+
+run_cmake(CMP0104-OLD)
+run_cmake(CMP0104-NEW)
+run_cmake(CMP0104-WARN)
diff --git a/Tests/RunCMake/CMP0104/main.cu b/Tests/RunCMake/CMP0104/main.cu
new file mode 100644
index 0000000..5047a34
--- /dev/null
+++ b/Tests/RunCMake/CMP0104/main.cu
@@ -0,0 +1,3 @@
+int main()
+{
+}
diff --git a/Tests/RunCMake/CMakeLists.txt b/Tests/RunCMake/CMakeLists.txt
index 2a4af3e..34e1fbc 100644
--- a/Tests/RunCMake/CMakeLists.txt
+++ b/Tests/RunCMake/CMakeLists.txt
@@ -116,6 +116,9 @@ endif()
add_RunCMake_test(CMP0069)
add_RunCMake_test(CMP0081)
add_RunCMake_test(CMP0102)
+if(CMake_TEST_CUDA)
+ add_RunCMake_test(CMP0104)
+endif()
# The test for Policy 65 requires the use of the
# CMAKE_SHARED_LIBRARY_LINK_CXX_FLAGS variable, which both the VS and Xcode
diff --git a/Tests/RunCMake/CompilerLauncher/CUDA-common.cmake b/Tests/RunCMake/CompilerLauncher/CUDA-common.cmake
index 6f7fc86..ca25b2a 100644
--- a/Tests/RunCMake/CompilerLauncher/CUDA-common.cmake
+++ b/Tests/RunCMake/CompilerLauncher/CUDA-common.cmake
@@ -1,3 +1,4 @@
+cmake_policy(SET CMP0104 NEW)
enable_language(CUDA)
set(CMAKE_VERBOSE_MAKEFILE TRUE)
add_executable(main main.cu)
diff --git a/Tests/RunCMake/GoogleTest/GoogleTest-skip-timeout-stdout.txt b/Tests/RunCMake/GoogleTest/GoogleTest-skip-timeout-stdout.txt
new file mode 100644
index 0000000..eeecb6a
--- /dev/null
+++ b/Tests/RunCMake/GoogleTest/GoogleTest-skip-timeout-stdout.txt
@@ -0,0 +1,10 @@
+Test project .*
+ Start 20: skip_test.test1
+1/1 Test #20: skip_test.test1 \.+\*\*\*Skipped +[0-9.]+ sec
+
+100% tests passed, 0 tests failed out of 1
+
+Total Test time \(real\) = +[0-9.]+ sec
+
+The following tests did not run:
+.*20 - skip_test\.test1 \(Skipped\)
diff --git a/Tests/RunCMake/GoogleTest/GoogleTest.cmake b/Tests/RunCMake/GoogleTest/GoogleTest.cmake
index 4bc6b9d..fca292a 100644
--- a/Tests/RunCMake/GoogleTest/GoogleTest.cmake
+++ b/Tests/RunCMake/GoogleTest/GoogleTest.cmake
@@ -49,3 +49,9 @@ gtest_discover_tests(
DISCOVERY_TIMEOUT 20
PROPERTIES TIMEOUT 2
)
+
+add_executable(skip_test skip_test.cpp)
+
+gtest_discover_tests(
+ skip_test
+)
diff --git a/Tests/RunCMake/GoogleTest/RunCMakeTest.cmake b/Tests/RunCMake/GoogleTest/RunCMakeTest.cmake
index 6b9d458..efd22be 100644
--- a/Tests/RunCMake/GoogleTest/RunCMakeTest.cmake
+++ b/Tests/RunCMake/GoogleTest/RunCMakeTest.cmake
@@ -60,6 +60,20 @@ function(run_GoogleTest DISCOVERY_MODE)
-R property_timeout\\.case_with_discovery
--no-label-summary
)
+
+ run_cmake_command(GoogleTest-build
+ ${CMAKE_COMMAND}
+ --build .
+ --config Debug
+ --target skip_test
+ )
+
+ run_cmake_command(GoogleTest-skip-test
+ ${CMAKE_CTEST_COMMAND}
+ -C Debug
+ -R skip_test
+ --no-label-summary
+ )
endfunction()
function(run_GoogleTestXML DISCOVERY_MODE)
diff --git a/Tests/RunCMake/GoogleTest/skip_test.cpp b/Tests/RunCMake/GoogleTest/skip_test.cpp
new file mode 100644
index 0000000..2bc9fe1
--- /dev/null
+++ b/Tests/RunCMake/GoogleTest/skip_test.cpp
@@ -0,0 +1,18 @@
+#include <iostream>
+#include <string>
+
+int main(int argc, char** argv)
+{
+ // Note: GoogleTest.cmake doesn't actually depend on Google Test as such;
+ // it only requires that we produces output in the expected format when
+ // invoked with --gtest_list_tests. Thus, we fake that here. This allows us
+ // to test the module without actually needing Google Test.
+ if (argc > 1 && std::string(argv[1]) == "--gtest_list_tests") {
+ std::cout << "skip_test." << std::endl;
+ std::cout << " test1" << std::endl;
+ return 0;
+ }
+
+ std::cout << "[ SKIPPED ] skip_test.test1" << std::endl;
+ return 0;
+}
diff --git a/Tests/RunCMake/NinjaMultiConfig/CudaSimple.cmake b/Tests/RunCMake/NinjaMultiConfig/CudaSimple.cmake
index 2e9b1cb..00d8a1b 100644
--- a/Tests/RunCMake/NinjaMultiConfig/CudaSimple.cmake
+++ b/Tests/RunCMake/NinjaMultiConfig/CudaSimple.cmake
@@ -1,3 +1,4 @@
+cmake_policy(SET CMP0104 NEW)
enable_language(CUDA)
file(TOUCH ${CMAKE_BINARY_DIR}/empty.cmake)
diff --git a/Tests/RunCMake/TargetPolicies/PolicyList-stderr.txt b/Tests/RunCMake/TargetPolicies/PolicyList-stderr.txt
index 9a1e027..7ffd522 100644
--- a/Tests/RunCMake/TargetPolicies/PolicyList-stderr.txt
+++ b/Tests/RunCMake/TargetPolicies/PolicyList-stderr.txt
@@ -29,6 +29,7 @@
\* CMP0083
\* CMP0095
\* CMP0099
+ \* CMP0104
Call Stack \(most recent call first\):
CMakeLists.txt:3 \(include\)
diff --git a/Tests/RunCMake/exit_code.c b/Tests/RunCMake/exit_code.c
index 3eba019..9fa8eca 100644
--- a/Tests/RunCMake/exit_code.c
+++ b/Tests/RunCMake/exit_code.c
@@ -21,7 +21,8 @@ int main(int argc, const char* argv[])
}
if (strcmp(str, substring_success) == 0) {
return EXIT_SUCCESS;
- } else if (strcmp(str, substring_failure) == 0) {
+ }
+ if (strcmp(str, substring_failure) == 0) {
return EXIT_FAILURE;
}
fprintf(stderr, "Failed to find string '%s' in '%s'\n", substring_success,
diff --git a/Tests/RunCMake/find_program/ExeNoRead-stdout.txt b/Tests/RunCMake/find_program/ExeNoRead-stdout.txt
new file mode 100644
index 0000000..35a83f2
--- /dev/null
+++ b/Tests/RunCMake/find_program/ExeNoRead-stdout.txt
@@ -0,0 +1 @@
+-- ExeNoRead_EXECUTABLE='.*/Tests/RunCMake/find_program/ExeNoRead-build/ExeNoRead'
diff --git a/Tests/RunCMake/find_program/ExeNoRead.cmake b/Tests/RunCMake/find_program/ExeNoRead.cmake
new file mode 100644
index 0000000..7e22dc5
--- /dev/null
+++ b/Tests/RunCMake/find_program/ExeNoRead.cmake
@@ -0,0 +1,4 @@
+file(WRITE "${CMAKE_CURRENT_BINARY_DIR}/ExeNoRead" "#!/bin/sh\n")
+execute_process(COMMAND chmod -r+x "${CMAKE_CURRENT_BINARY_DIR}/ExeNoRead")
+find_program(ExeNoRead_EXECUTABLE NAMES ExeNoRead NO_DEFAULT_PATH PATHS "${CMAKE_CURRENT_BINARY_DIR}")
+message(STATUS "ExeNoRead_EXECUTABLE='${ExeNoRead_EXECUTABLE}'")
diff --git a/Tests/RunCMake/find_program/RunCMakeTest.cmake b/Tests/RunCMake/find_program/RunCMakeTest.cmake
index 0ff9a97..95ffd84 100644
--- a/Tests/RunCMake/find_program/RunCMakeTest.cmake
+++ b/Tests/RunCMake/find_program/RunCMakeTest.cmake
@@ -10,3 +10,7 @@ if(CMAKE_SYSTEM_NAME MATCHES "^(Windows|CYGWIN)$")
run_cmake(WindowsCom)
run_cmake(WindowsExe)
endif()
+
+if(UNIX)
+ run_cmake(ExeNoRead)
+endif()
diff --git a/Tests/RunCMake/pseudo_cppcheck.c b/Tests/RunCMake/pseudo_cppcheck.c
index 5b1531b..e80620c 100644
--- a/Tests/RunCMake/pseudo_cppcheck.c
+++ b/Tests/RunCMake/pseudo_cppcheck.c
@@ -11,7 +11,8 @@ int main(int argc, char* argv[])
fprintf(stdout, "stdout from bad command line arg '-bad'\n");
fprintf(stderr, "stderr from bad command line arg '-bad'\n");
return 1;
- } else if (strcmp(argv[i], "-error") == 0) {
+ }
+ if (strcmp(argv[i], "-error") == 0) {
// The real cppcheck allows to set the exitcode with --error-exitcode
result = 5;
}
diff --git a/Tests/TryCompile/CMakeLists.txt b/Tests/TryCompile/CMakeLists.txt
index 9ec9b70..df921d8 100644
--- a/Tests/TryCompile/CMakeLists.txt
+++ b/Tests/TryCompile/CMakeLists.txt
@@ -187,7 +187,7 @@ try_compile(SHOULD_FAIL_DUE_TO_BAD_SOURCE
if(SHOULD_FAIL_DUE_TO_BAD_SOURCE AND NOT CMAKE_GENERATOR MATCHES "Watcom WMake|NMake Makefiles")
string(REPLACE "\n" "\n " output " ${output}")
message(SEND_ERROR "try_compile with bad#source.c did not fail:\n${output}")
-elseif(NOT output MATCHES [[(bad#source\.c|bad\\)]])
+elseif(NOT output MATCHES [[(bad#source\.c|bad\.c|bad')]])
string(REPLACE "\n" "\n " output " ${output}")
message(SEND_ERROR "try_compile with bad#source.c failed without mentioning bad source:\n${output}")
else()
diff --git a/bootstrap b/bootstrap
index 66dc861..0a65043 100755
--- a/bootstrap
+++ b/bootstrap
@@ -9,8 +9,16 @@ die() {
# Compile flag extraction function.
cmake_extract_standard_flags()
{
- sed -n "s/ *set *( *CMAKE_${2}${3}_EXTENSION_COMPILE_OPTION *\"\{0,1\}\([^\")]*\).*/\1/p" \
- "${cmake_source_dir}/Modules/Compiler/"${1:-*}-${2}.cmake 2>/dev/null | tr ';' ' '
+ id="${1:-*}"
+ lang="${2}"
+ ver="${3}"
+ sed -n "s/ *set *( *CMAKE_${lang}${ver}_EXTENSION_COMPILE_OPTION *\"\{0,1\}\([^\")]*\).*/\1/p" \
+ "${cmake_source_dir}/Modules/Compiler/"${id}-${lang}.cmake \
+ 2>/dev/null | tr ';' ' '
+ # Clang's CXX compiler flags are in the common module.
+ sed -n "s/ *set *( *CMAKE_\\\${lang}${ver}_EXTENSION_COMPILE_OPTION *\"\{0,1\}\([^\")]*\).*/\1/p" \
+ "${cmake_source_dir}/Modules/Compiler/Clang.cmake" \
+ 2>/dev/null | tr ';' ' '
}
# Version number extraction function.