summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--Help/manual/cmake-modules.7.rst1
-rw-r--r--Help/manual/cmake-variables.7.rst2
-rw-r--r--Help/module/FindCUDAToolkit.rst1
-rw-r--r--Help/release/dev/FindCUDAToolkit-module.rst4
-rw-r--r--Help/variable/CMAKE_VS_WINRT_BY_DEFAULT.rst14
-rw-r--r--Modules/CMakeCUDACompiler.cmake.in13
-rw-r--r--Modules/FindCUDA.cmake11
-rw-r--r--Modules/FindCUDAToolkit.cmake785
-rw-r--r--Modules/FindProtobuf.cmake26
-rw-r--r--Modules/Platform/Darwin-Initialize.cmake105
-rw-r--r--Source/CMakeVersion.cmake2
-rw-r--r--Source/cmCoreTryCompile.cxx3
-rw-r--r--Source/cmExportInstallAndroidMKGenerator.cxx2
-rw-r--r--Source/cmGhsMultiTargetGenerator.cxx2
-rw-r--r--Source/cmGlobalGenerator.cxx2
-rw-r--r--Source/cmIncludeExternalMSProjectCommand.cxx13
-rw-r--r--Source/cmLocalGenerator.cxx55
-rw-r--r--Source/cmLocalVisualStudio7Generator.cxx2
-rw-r--r--Source/cmMakefile.cxx8
-rw-r--r--Source/cmQtAutoGenInitializer.cxx8
-rw-r--r--Source/cmSetTargetPropertiesCommand.cxx2
-rw-r--r--Source/cmTarget.cxx11
-rw-r--r--Source/cmTarget.h9
-rw-r--r--Source/cmTargetCompileDefinitionsCommand.cxx2
-rw-r--r--Source/cmTargetIncludeDirectoriesCommand.cxx3
-rw-r--r--Source/cmTargetLinkLibrariesCommand.cxx11
-rw-r--r--Source/cmTargetPrecompileHeadersCommand.cxx5
-rw-r--r--Source/cmTargetPropCommandBase.cxx9
-rw-r--r--Source/cmTargetSourcesCommand.cxx3
-rw-r--r--Source/cmVisualStudio10TargetGenerator.cxx31
-rw-r--r--Source/cmake.cxx2
-rw-r--r--Tests/Cuda/CMakeLists.txt3
-rw-r--r--Tests/Cuda/IncludePathNoToolkit/CMakeLists.txt (renamed from Tests/Cuda/ToolkitInclude/CMakeLists.txt)6
-rw-r--r--Tests/Cuda/IncludePathNoToolkit/main.cpp (renamed from Tests/Cuda/ToolkitInclude/main.cpp)0
-rw-r--r--Tests/Cuda/Toolkit/CMakeLists.txt38
-rw-r--r--Tests/Cuda/Toolkit/main.cpp8
-rw-r--r--Tests/CudaOnly/CMakeLists.txt1
-rw-r--r--Tests/CudaOnly/Toolkit/CMakeLists.txt44
-rw-r--r--Tests/CudaOnly/Toolkit/main.cu8
-rw-r--r--Tests/RunCMake/VS10Project/RunCMakeTest.cmake4
-rw-r--r--Tests/RunCMake/VS10Project/VsWinRTByDefault-check.cmake66
-rw-r--r--Tests/RunCMake/VS10Project/VsWinRTByDefault.cmake16
42 files changed, 1222 insertions, 119 deletions
diff --git a/Help/manual/cmake-modules.7.rst b/Help/manual/cmake-modules.7.rst
index c60dc40..be64112 100644
--- a/Help/manual/cmake-modules.7.rst
+++ b/Help/manual/cmake-modules.7.rst
@@ -122,6 +122,7 @@ They are normally called through the :command:`find_package` command.
/module/FindCABLE
/module/FindCoin3D
/module/FindCups
+ /module/FindCUDAToolkit
/module/FindCURL
/module/FindCurses
/module/FindCVS
diff --git a/Help/manual/cmake-variables.7.rst b/Help/manual/cmake-variables.7.rst
index 5143124..d0eaa31 100644
--- a/Help/manual/cmake-variables.7.rst
+++ b/Help/manual/cmake-variables.7.rst
@@ -45,6 +45,7 @@ Variables that Provide Information
/variable/CMAKE_CURRENT_LIST_FILE
/variable/CMAKE_CURRENT_LIST_LINE
/variable/CMAKE_CURRENT_SOURCE_DIR
+ /variable/CMAKE_DEBUG_TARGET_PROPERTIES
/variable/CMAKE_DIRECTORY_LABELS
/variable/CMAKE_DL_LIBS
/variable/CMAKE_DOTNET_TARGET_FRAMEWORK_VERSION
@@ -158,7 +159,6 @@ Variables that Change Behavior
/variable/CMAKE_CODELITE_USE_TARGETS
/variable/CMAKE_COLOR_MAKEFILE
/variable/CMAKE_CONFIGURATION_TYPES
- /variable/CMAKE_DEBUG_TARGET_PROPERTIES
/variable/CMAKE_DEPENDS_IN_PROJECT_ONLY
/variable/CMAKE_DISABLE_FIND_PACKAGE_PackageName
/variable/CMAKE_ECLIPSE_GENERATE_LINKED_RESOURCES
diff --git a/Help/module/FindCUDAToolkit.rst b/Help/module/FindCUDAToolkit.rst
new file mode 100644
index 0000000..5f01d68
--- /dev/null
+++ b/Help/module/FindCUDAToolkit.rst
@@ -0,0 +1 @@
+.. cmake-module:: ../../Modules/FindCUDAToolkit.cmake
diff --git a/Help/release/dev/FindCUDAToolkit-module.rst b/Help/release/dev/FindCUDAToolkit-module.rst
new file mode 100644
index 0000000..53a69c6
--- /dev/null
+++ b/Help/release/dev/FindCUDAToolkit-module.rst
@@ -0,0 +1,4 @@
+FindCUDAToolkit-module
+----------------------
+
+* The :module:`FindCUDAToolkit` module was added to find the CUDA Toolkit without enabling CUDA as a language.
diff --git a/Help/variable/CMAKE_VS_WINRT_BY_DEFAULT.rst b/Help/variable/CMAKE_VS_WINRT_BY_DEFAULT.rst
index 2ba8fe2..2eea424 100644
--- a/Help/variable/CMAKE_VS_WINRT_BY_DEFAULT.rst
+++ b/Help/variable/CMAKE_VS_WINRT_BY_DEFAULT.rst
@@ -1,8 +1,18 @@
CMAKE_VS_WINRT_BY_DEFAULT
-------------------------
-Tell :ref:`Visual Studio Generators` for VS 2010 and above that the
-target platform compiles as WinRT by default (compiles with ``/ZW``).
+Inform :ref:`Visual Studio Generators` for VS 2010 and above that the
+target platform enables WinRT compilation by default and it needs to
+be explicitly disabled if ``/ZW`` or :prop_tgt:`VS_WINRT_COMPONENT` is
+omitted (as opposed to enabling it when either of those options is
+present)
+
+This makes cmake configuration consistent in terms of WinRT among
+platforms - if you did not enable the WinRT compilation explicitly, it
+will be disabled (by either not enabling it or explicitly disabling it)
+
+Note: WinRT compilation is always explicitly disabled for C language
+source files, even if it is expliclty enabled for a project
This variable is meant to be set by a
:variable:`toolchain file <CMAKE_TOOLCHAIN_FILE>` for such platforms.
diff --git a/Modules/CMakeCUDACompiler.cmake.in b/Modules/CMakeCUDACompiler.cmake.in
index ea491a9..4a615a3 100644
--- a/Modules/CMakeCUDACompiler.cmake.in
+++ b/Modules/CMakeCUDACompiler.cmake.in
@@ -11,7 +11,9 @@ set(CMAKE_CUDA14_COMPILE_FEATURES "@CMAKE_CUDA14_COMPILE_FEATURES@")
set(CMAKE_CUDA17_COMPILE_FEATURES "@CMAKE_CUDA17_COMPILE_FEATURES@")
set(CMAKE_CUDA20_COMPILE_FEATURES "@CMAKE_CUDA20_COMPILE_FEATURES@")
+set(CMAKE_CUDA_PLATFORM_ID "@CMAKE_CUDA_PLATFORM_ID@")
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@
@@ -24,7 +26,18 @@ set(CMAKE_CUDA_SOURCE_FILE_EXTENSIONS cu)
set(CMAKE_CUDA_LINKER_PREFERENCE 15)
set(CMAKE_CUDA_LINKER_PREFERENCE_PROPAGATES 1)
+set(CMAKE_CUDA_SIZEOF_DATA_PTR "@CMAKE_CUDA_SIZEOF_DATA_PTR@")
+set(CMAKE_CUDA_COMPILER_ABI "@CMAKE_CUDA_COMPILER_ABI@")
set(CMAKE_CUDA_LIBRARY_ARCHITECTURE "@CMAKE_CUDA_LIBRARY_ARCHITECTURE@")
+
+if(CMAKE_CUDA_SIZEOF_DATA_PTR)
+ set(CMAKE_SIZEOF_VOID_P "${CMAKE_CUDA_SIZEOF_DATA_PTR}")
+endif()
+
+if(CMAKE_CUDA_COMPILER_ABI)
+ set(CMAKE_INTERNAL_PLATFORM_ABI "${CMAKE_CUDA_COMPILER_ABI}")
+endif()
+
if(CMAKE_CUDA_LIBRARY_ARCHITECTURE)
set(CMAKE_LIBRARY_ARCHITECTURE "@CMAKE_CUDA_LIBRARY_ARCHITECTURE@")
endif()
diff --git a/Modules/FindCUDA.cmake b/Modules/FindCUDA.cmake
index ad7fe99..0e2f551 100644
--- a/Modules/FindCUDA.cmake
+++ b/Modules/FindCUDA.cmake
@@ -5,17 +5,22 @@ FindCUDA
.. deprecated:: 3.10
Superseded by first-class support for the CUDA language in CMake.
+ Superseded by the :module:`FindCUDAToolkit` for CUDA toolkit libraries.
Replacement
^^^^^^^^^^^
-It is no longer necessary to use this module or call ``find_package(CUDA)``.
-Instead, list ``CUDA`` among the languages named in the top-level
-call to the :command:`project` command, or call the
+It is no longer necessary to use this module or call ``find_package(CUDA)``
+for compiling CUDA code. Instead, list ``CUDA`` among the languages named
+in the top-level call to the :command:`project` command, or call the
:command:`enable_language` command with ``CUDA``.
Then one can add CUDA (``.cu``) sources to programs directly
in calls to :command:`add_library` and :command:`add_executable`.
+To find and use the CUDA toolkit libraries the :module:`FindCUDAToolkit`
+module has superseded this module. It works whether or not the ``CUDA``
+language is enabled.
+
Documentation of Deprecated Usage
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
diff --git a/Modules/FindCUDAToolkit.cmake b/Modules/FindCUDAToolkit.cmake
new file mode 100644
index 0000000..1837694
--- /dev/null
+++ b/Modules/FindCUDAToolkit.cmake
@@ -0,0 +1,785 @@
+# Distributed under the OSI-approved BSD 3-Clause License. See accompanying
+# file Copyright.txt or https://cmake.org/licensing for details.
+
+#[=======================================================================[.rst:
+FindCUDAToolkit
+---------------
+
+This script locates the NVIDIA CUDA toolkit and the associated libraries, but
+does not require the ``CUDA`` language be enabled for a given project. This
+module does not search for the NVIDIA CUDA Samples.
+
+Search Behavior
+^^^^^^^^^^^^^^^
+
+Finding the CUDA Toolkit requires finding the ``nvcc`` executable, which is
+searched for in the following order:
+
+1. If the ``CUDA`` language has been enabled we will use the directory
+ containing the compiler as the first search location for ``nvcc``.
+
+2. If the ``CUDAToolkit_ROOT`` cmake configuration variable (e.g.,
+ ``-DCUDAToolkit_ROOT=/some/path``) *or* environment variable is defined, it
+ will be searched. If both an environment variable **and** a
+ configuration variable are specified, the *configuration* variable takes
+ precedence.
+
+ The directory specified here must be such that the executable ``nvcc`` can be
+ found underneath the directory specified by ``CUDAToolkit_ROOT``. If
+ ``CUDAToolkit_ROOT`` is specified, but no ``nvcc`` is found underneath, this
+ package is marked as **not** found. No subsequent search attempts are
+ performed.
+
+3. If the CUDA_PATH environment variable is defined, it will be searched.
+
+4. The user's path is searched for ``nvcc`` using :command:`find_program`. If
+ this is found, no subsequent search attempts are performed. Users are
+ responsible for ensuring that the first ``nvcc`` to show up in the path is
+ the desired path in the event that multiple CUDA Toolkits are installed.
+
+5. On Unix systems, if the symbolic link ``/usr/local/cuda`` exists, this is
+ used. No subsequent search attempts are performed. No default symbolic link
+ location exists for the Windows platform.
+
+6. The platform specific default install locations are searched. If exactly one
+ candidate is found, this is used. The default CUDA Toolkit install locations
+ searched are:
+
+ +-------------+-------------------------------------------------------------+
+ | Platform | Search Pattern |
+ +=============+=============================================================+
+ | macOS | ``/Developer/NVIDIA/CUDA-X.Y`` |
+ +-------------+-------------------------------------------------------------+
+ | Other Unix | ``/usr/local/cuda-X.Y`` |
+ +-------------+-------------------------------------------------------------+
+ | Windows | ``C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\vX.Y`` |
+ +-------------+-------------------------------------------------------------+
+
+ Where ``X.Y`` would be a specific version of the CUDA Toolkit, such as
+ ``/usr/local/cuda-9.0`` or
+ ``C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v9.0``
+
+ .. note::
+
+ When multiple CUDA Toolkits are installed in the default location of a
+ system (e.g., both ``/usr/local/cuda-9.0`` and ``/usr/local/cuda-10.0``
+ exist but the ``/usr/local/cuda`` symbolic link does **not** exist), this
+ package is marked as **not** found.
+
+ There are too many factors involved in making an automatic decision in
+ the presence of multiple CUDA Toolkits being installed. In this
+ situation, users are encouraged to either (1) set ``CUDAToolkit_ROOT`` or
+ (2) ensure that the correct ``nvcc`` executable shows up in ``$PATH`` for
+ :command:`find_program` to find.
+
+Options
+^^^^^^^
+
+``VERSION``
+ If specified, describes the version of the CUDA Toolkit to search for.
+
+``REQUIRED``
+ If specified, configuration will error if a suitable CUDA Toolkit is not
+ found.
+
+``QUIET``
+ If specified, the search for a suitable CUDA Toolkit will not produce any
+ messages.
+
+``EXACT``
+ If specified, the CUDA Toolkit is considered found only if the exact
+ ``VERSION`` specified is recovered.
+
+Imported targets
+^^^^^^^^^^^^^^^^
+
+An :ref:`imported target <Imported targets>` named ``CUDA::toolkit`` is provided.
+
+This module defines :prop_tgt:`IMPORTED` targets for each
+of the following libraries that are part of the CUDAToolkit:
+
+- :ref:`CUDA Runtime Library<cuda_toolkit_rt_lib>`
+- :ref:`CUDA Driver Library<cuda_toolkit_driver_lib>`
+- :ref:`cuBLAS<cuda_toolkit_cuBLAS>`
+- :ref:`cuFFT<cuda_toolkit_cuFFT>`
+- :ref:`cuRAND<cuda_toolkit_cuRAND>`
+- :ref:`cuSOLVER<cuda_toolkit_cuSOLVER>`
+- :ref:`cuSPARSE<cuda_toolkit_cuSPARSE>`
+- :ref:`NPP<cuda_toolkit_NPP>`
+- :ref:`nvBLAS<cuda_toolkit_nvBLAS>`
+- :ref:`nvGRAPH<cuda_toolkit_nvGRAPH>`
+- :ref:`nvJPEG<cuda_toolkit_nvJPEG>`
+- :ref:`nvidia-ML<cuda_toolkit_nvML>`
+- :ref:`nvRTC<cuda_toolkit_nvRTC>`
+- :ref:`nvToolsExt<cuda_toolkit_nvToolsExt>`
+- :ref:`OpenCL<cuda_toolkit_opencl>`
+- :ref:`cuLIBOS<cuda_toolkit_cuLIBOS>`
+
+.. _`cuda_toolkit_rt_lib`:
+
+CUDA Runtime Library
+""""""""""""""""""""
+
+The CUDA Runtime library (cudart) are what most applications will typically
+need to link against to make any calls such as `cudaMalloc`, and `cudaFree`.
+They are an explicit dependency of almost every library.
+
+Targets Created:
+
+- ``CUDA::cudart``
+- ``CUDA::cudart_static``
+
+.. _`cuda_toolkit_driver_lib`:
+
+CUDA Driver Library
+""""""""""""""""""""
+
+The CUDA Driver library (cuda) are used by applications that use calls
+such as `cuMemAlloc`, and `cuMemFree`. This is generally used by advanced
+
+
+Targets Created:
+
+- ``CUDA::cuda_driver``
+- ``CUDA::cuda_driver``
+
+.. _`cuda_toolkit_cuBLAS`:
+
+cuBLAS
+""""""
+
+The `cuBLAS <https://docs.nvidia.com/cuda/cublas/index.html>`_ library.
+
+Targets Created:
+
+- ``CUDA::cublas``
+- ``CUDA::cublas_static``
+
+.. _`cuda_toolkit_cuFFT`:
+
+cuFFT
+"""""
+
+The `cuFFT <https://docs.nvidia.com/cuda/cufft/index.html>`_ library.
+
+Targets Created:
+
+- ``CUDA::cufft``
+- ``CUDA::cufftw``
+- ``CUDA::cufft_static``
+- ``CUDA::cufftw_static``
+
+cuRAND
+""""""
+
+The `cuRAND <https://docs.nvidia.com/cuda/curand/index.html>`_ library.
+
+Targets Created:
+
+- ``CUDA::curand``
+- ``CUDA::curand_static``
+
+.. _`cuda_toolkit_cuSOLVER`:
+
+cuSOLVER
+""""""""
+
+The `cuSOLVER <https://docs.nvidia.com/cuda/cusolver/index.html>`_ library.
+
+Targets Created:
+
+- ``CUDA::cusolver``
+- ``CUDA::cusolver_static``
+
+.. _`cuda_toolkit_cuSPARSE`:
+
+cuSPARSE
+""""""""
+
+The `cuSPARSE <https://docs.nvidia.com/cuda/cusparse/index.html>`_ library.
+
+Targets Created:
+
+- ``CUDA::cusparse``
+- ``CUDA::cusparse_static``
+
+.. _`cuda_toolkit_NPP`:
+
+NPP
+"""
+
+The `NPP <https://docs.nvidia.com/cuda/npp/index.html>`_ libraries.
+
+Targets Created:
+
+- `nppc`:
+
+ - ``CUDA::nppc``
+ - ``CUDA::nppc_static``
+
+- `nppial`: Arithmetic and logical operation functions in `nppi_arithmetic_and_logical_operations.h`
+
+ - ``CUDA::nppial``
+ - ``CUDA::nppial_static``
+
+- `nppicc`: Color conversion and sampling functions in `nppi_color_conversion.h`
+
+ - ``CUDA::nppicc``
+ - ``CUDA::nppicc_static``
+
+- `nppicom`: JPEG compression and decompression functions in `nppi_compression_functions.h`
+
+ - ``CUDA::nppicom``
+ - ``CUDA::nppicom_static``
+
+- `nppidei`: Data exchange and initialization functions in `nppi_data_exchange_and_initialization.h`
+
+ - ``CUDA::nppidei``
+ - ``CUDA::nppidei_static``
+
+- `nppif`: Filtering and computer vision functions in `nppi_filter_functions.h`
+
+ - ``CUDA::nppif``
+ - ``CUDA::nppif_static``
+
+- `nppig`: Geometry transformation functions found in `nppi_geometry_transforms.h`
+
+ - ``CUDA::nppig``
+ - ``CUDA::nppig_static``
+
+- `nppim`: Morphological operation functions found in `nppi_morphological_operations.h`
+
+ - ``CUDA::nppim``
+ - ``CUDA::nppim_static``
+
+- `nppist`: Statistics and linear transform in `nppi_statistics_functions.h` and `nppi_linear_transforms.h`
+
+ - ``CUDA::nppist``
+ - ``CUDA::nppist_static``
+
+- `nppisu`: Memory support functions in `nppi_support_functions.h`
+
+ - ``CUDA::nppisu``
+ - ``CUDA::nppisu_static``
+
+- `nppitc`: Threshold and compare operation functions in `nppi_threshold_and_compare_operations.h`
+
+ - ``CUDA::nppitc``
+ - ``CUDA::nppitc_static``
+
+- `npps`:
+
+ - ``CUDA::npps``
+ - ``CUDA::npps_static``
+
+.. _`cuda_toolkit_nvBLAS`:
+
+nvBLAS
+""""""
+
+The `nvBLAS <https://docs.nvidia.com/cuda/nvblas/index.html>`_ libraries.
+This is a shared library only.
+
+Targets Created:
+
+- ``CUDA::nvblas``
+
+.. _`cuda_toolkit_nvGRAPH`:
+
+nvGRAPH
+"""""""
+
+The `nvGRAPH <https://docs.nvidia.com/cuda/nvgraph/index.html>`_ library.
+
+Targets Created:
+
+- ``CUDA::nvgraph``
+- ``CUDA::nvgraph_static``
+
+
+.. _`cuda_toolkit_nvJPEG`:
+
+nvJPEG
+""""""
+
+The `nvJPEG <https://docs.nvidia.com/cuda/nvjpeg/index.html>`_ library.
+Introduced in CUDA 10.
+
+Targets Created:
+
+- ``CUDA::nvjpeg``
+- ``CUDA::nvjpeg_static``
+
+.. _`cuda_toolkit_nvRTC`:
+
+nvRTC
+"""""
+
+The `nvRTC <https://docs.nvidia.com/cuda/nvrtc/index.html>`_ (Runtime Compilation) library.
+This is a shared library only.
+
+Targets Created:
+
+- ``CUDA::nvrtc``
+
+.. _`cuda_toolkit_nvml`:
+
+nvidia-ML
+"""""""""
+
+The `NVIDIA Management Library <https://developer.nvidia.com/nvidia-management-library-nvml>`_.
+This is a shared library only.
+
+Targets Created:
+
+- ``CUDA::nvml``
+
+.. _`cuda_toolkit_opencl`:
+
+.. _`cuda_toolkit_nvToolsExt`:
+
+nvToolsExt
+""""""""""
+
+The `NVIDIA Tools Extension <https://docs.nvidia.com/gameworks/content/gameworkslibrary/nvtx/nvidia_tools_extension_library_nvtx.htm>`_.
+This is a shared library only.
+
+Targets Created:
+
+- ``CUDA::nvToolsExt``
+
+OpenCL
+""""""
+
+The `NVIDIA OpenCL Library <https://developer.nvidia.com/opencl>`_.
+This is a shared library only.
+
+Targets Created:
+
+- ``CUDA::OpenCL``
+
+.. _`cuda_toolkit_cuLIBOS`:
+
+cuLIBOS
+"""""""
+
+The cuLIBOS library is a backend thread abstraction layer library which is
+static only. The ``CUDA::cublas_static``, ``CUDA::cusparse_static``,
+``CUDA::cufft_static``, ``CUDA::curand_static``, and (when implemented) NPP
+libraries all automatically have this dependency linked.
+
+Target Created:
+
+- ``CUDA::culibos``
+
+**Note**: direct usage of this target by consumers should not be necessary.
+
+.. _`cuda_toolkit_cuRAND`:
+
+
+
+Result variables
+^^^^^^^^^^^^^^^^
+
+``CUDAToolkit_FOUND``
+ A boolean specifying whether or not the CUDA Toolkit was found.
+
+``CUDAToolkit_VERSION``
+ The exact version of the CUDA Toolkit found (as reported by
+ ``nvcc --version``).
+
+``CUDAToolkit_VERSION_MAJOR``
+ The major version of the CUDA Toolkit.
+
+``CUDAToolkit_VERSION_MAJOR``
+ The minor version of the CUDA Toolkit.
+
+``CUDAToolkit_VERSION_PATCH``
+ The patch version of the CUDA Toolkit.
+
+``CUDAToolkit_BIN_DIR``
+ The path to the CUDA Toolkit library directory that contains the CUDA
+ executable ``nvcc``.
+
+``CUDAToolkit_INCLUDE_DIRS``
+ The path to the CUDA Toolkit ``include`` folder containing the header files
+ required to compile a project linking against CUDA.
+
+``CUDAToolkit_LIBRARY_DIR``
+ The path to the CUDA Toolkit library directory that contains the CUDA
+ Runtime library ``cudart``.
+
+``CUDAToolkit_NVCC_EXECUTABLE``
+ The path to the NVIDIA CUDA compiler ``nvcc``. Note that this path may
+ **not** be the same as
+ :variable:`CMAKE_CUDA_COMPILER <CMAKE_<LANG>_COMPILER>`. ``nvcc`` must be
+ found to determine the CUDA Toolkit version as well as determining other
+ features of the Toolkit. This variable is set for the convenience of
+ modules that depend on this one.
+
+
+#]=======================================================================]
+
+# NOTE: much of this was simply extracted from FindCUDA.cmake.
+
+# James Bigler, NVIDIA Corp (nvidia.com - jbigler)
+# Abe Stephens, SCI Institute -- http://www.sci.utah.edu/~abe/FindCuda.html
+#
+# Copyright (c) 2008 - 2009 NVIDIA Corporation. All rights reserved.
+#
+# Copyright (c) 2007-2009
+# Scientific Computing and Imaging Institute, University of Utah
+#
+# This code is licensed under the MIT License. See the FindCUDA.cmake script
+# for the text of the license.
+
+# The MIT License
+#
+# License for the specific language governing rights and limitations under
+# Permission is hereby granted, free of charge, to any person obtaining a
+# copy of this software and associated documentation files (the "Software"),
+# to deal in the Software without restriction, including without limitation
+# the rights to use, copy, modify, merge, publish, distribute, sublicense,
+# and/or sell copies of the Software, and to permit persons to whom the
+# Software is furnished to do so, subject to the following conditions:
+#
+# The above copyright notice and this permission notice shall be included
+# in all copies or substantial portions of the Software.
+#
+# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+# OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
+# THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
+# FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
+# DEALINGS IN THE SOFTWARE.
+#
+###############################################################################
+
+if(CMAKE_CUDA_COMPILER_LOADED AND NOT CUDAToolkit_BIN_DIR)
+ get_filename_component(cuda_dir "${CMAKE_CUDA_COMPILER}" DIRECTORY)
+ # use the already detected cuda compiler
+ set(CUDAToolkit_BIN_DIR "${cuda_dir}" CACHE PATH "")
+ unset(cuda_dir)
+endif()
+
+# Try language- or user-provided path first.
+if(CUDAToolkit_BIN_DIR)
+ find_program(CUDAToolkit_NVCC_EXECUTABLE
+ NAMES nvcc nvcc.exe
+ PATHS ${CUDAToolkit_BIN_DIR}
+ NO_DEFAULT_PATH
+ )
+endif()
+
+# Search using CUDAToolkit_ROOT
+find_program(CUDAToolkit_NVCC_EXECUTABLE
+ NAMES nvcc nvcc.exe
+ PATHS ENV CUDA_PATH
+ PATH_SUFFIXES bin
+)
+
+# If the user specified CUDAToolkit_ROOT but nvcc could not be found, this is an error.
+if (NOT CUDAToolkit_NVCC_EXECUTABLE AND (DEFINED CUDAToolkit_ROOT OR DEFINED ENV{CUDAToolkit_ROOT}))
+ # Declare error messages now, print later depending on find_package args.
+ set(fail_base "Could not find nvcc executable in path specified by")
+ set(cuda_root_fail "${fail_base} CUDAToolkit_ROOT=${CUDAToolkit_ROOT}")
+ set(env_cuda_root_fail "${fail_base} environment variable CUDAToolkit_ROOT=$ENV{CUDAToolkit_ROOT}")
+
+ if (CUDAToolkit_FIND_REQUIRED)
+ if (DEFINED CUDAToolkit_ROOT)
+ message(FATAL_ERROR ${cuda_root_fail})
+ elseif (DEFINED ENV{CUDAToolkit_ROOT})
+ message(FATAL_ERROR ${env_cuda_root_fail})
+ endif()
+ else()
+ if (NOT CUDAToolkit_FIND_QUIETLY)
+ if (DEFINED CUDAToolkit_ROOT)
+ message(STATUS ${cuda_root_fail})
+ elseif (DEFINED ENV{CUDAToolkit_ROOT})
+ message(STATUS ${env_cuda_root_fail})
+ endif()
+ endif()
+ set(CUDAToolkit_FOUND FALSE)
+ unset(fail_base)
+ unset(cuda_root_fail)
+ unset(env_cuda_root_fail)
+ return()
+ endif()
+endif()
+
+# CUDAToolkit_ROOT cmake / env variable not specified, try platform defaults.
+#
+# - Linux: /usr/local/cuda-X.Y
+# - macOS: /Developer/NVIDIA/CUDA-X.Y
+# - Windows: C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\vX.Y
+#
+# We will also search the default symlink location /usr/local/cuda first since
+# if CUDAToolkit_ROOT is not specified, it is assumed that the symlinked
+# directory is the desired location.
+if (NOT CUDAToolkit_NVCC_EXECUTABLE)
+ if (UNIX)
+ if (NOT APPLE)
+ set(platform_base "/usr/local/cuda-")
+ else()
+ set(platform_base "/Developer/NVIDIA/CUDA-")
+ endif()
+ else()
+ set(platform_base "C:\\Program Files\\NVIDIA GPU Computing Toolkit\\CUDA\\v")
+ endif()
+
+ # Build out a descending list of possible cuda installations, e.g.
+ file(GLOB possible_paths "${platform_base}*")
+ # Iterate the glob results and create a descending list.
+ set(possible_versions)
+ foreach (p ${possible_paths})
+ # Extract version number from end of string
+ string(REGEX MATCH "[0-9][0-9]?\\.[0-9]$" p_version ${p})
+ if (IS_DIRECTORY ${p} AND p_version)
+ list(APPEND possible_versions ${p_version})
+ endif()
+ endforeach()
+
+ # Cannot use list(SORT) because that is alphabetical, we need numerical.
+ # NOTE: this is not an efficient sorting strategy. But even if a user had
+ # every possible version of CUDA installed, this wouldn't create any
+ # significant overhead.
+ set(versions)
+ foreach (v ${possible_versions})
+ list(LENGTH versions num_versions)
+ # First version, nothing to compare with so just append.
+ if (num_versions EQUAL 0)
+ list(APPEND versions ${v})
+ else()
+ # Loop through list. Insert at an index when comparison is
+ # VERSION_GREATER since we want a descending list. Duplicates will not
+ # happen since this came from a glob list of directories.
+ set(i 0)
+ set(early_terminate FALSE)
+ while (i LESS num_versions)
+ list(GET versions ${i} curr)
+ if (v VERSION_GREATER curr)
+ list(INSERT versions ${i} ${v})
+ set(early_terminate TRUE)
+ break()
+ endif()
+ math(EXPR i "${i} + 1")
+ endwhile()
+ # If it did not get inserted, place it at the end.
+ if (NOT early_terminate)
+ list(APPEND versions ${v})
+ endif()
+ endif()
+ endforeach()
+
+ # With a descending list of versions, populate possible paths to search.
+ set(search_paths)
+ foreach (v ${versions})
+ list(APPEND search_paths "${platform_base}${v}")
+ endforeach()
+
+ # Force the global default /usr/local/cuda to the front on Unix.
+ if (UNIX)
+ list(INSERT search_paths 0 "/usr/local/cuda")
+ endif()
+
+ # Now search for nvcc again using the platform default search paths.
+ find_program(CUDAToolkit_NVCC_EXECUTABLE
+ NAMES nvcc nvcc.exe
+ PATHS ${search_paths}
+ PATH_SUFFIXES bin
+ )
+
+ # We are done with these variables now, cleanup for caller.
+ unset(platform_base)
+ unset(possible_paths)
+ unset(possible_versions)
+ unset(versions)
+ unset(i)
+ unset(early_terminate)
+ unset(search_paths)
+
+ if (NOT CUDAToolkit_NVCC_EXECUTABLE)
+ if (CUDAToolkit_FIND_REQUIRED)
+ message(FATAL_ERROR "Could not find nvcc, please set CUDAToolkit_ROOT.")
+ elseif(NOT CUDAToolkit_FIND_QUIETLY)
+ message(STATUS "Could not find nvcc, please set CUDAToolkit_ROOT.")
+ endif()
+
+ set(CUDAToolkit_FOUND FALSE)
+ return()
+ endif()
+endif()
+
+if(NOT CUDAToolkit_BIN_DIR AND CUDAToolkit_NVCC_EXECUTABLE)
+ get_filename_component(cuda_dir "${CUDAToolkit_NVCC_EXECUTABLE}" DIRECTORY)
+ set(CUDAToolkit_BIN_DIR "${cuda_dir}" CACHE PATH "" FORCE)
+ unset(cuda_dir)
+endif()
+
+if(CUDAToolkit_NVCC_EXECUTABLE AND
+ CUDAToolkit_NVCC_EXECUTABLE STREQUAL CMAKE_CUDA_COMPILER)
+ # Need to set these based off the already computed CMAKE_CUDA_COMPILER_VERSION value
+ # This if statement will always match, but is used to provide variables for MATCH 1,2,3...
+ if(CMAKE_CUDA_COMPILER_VERSION MATCHES [=[([0-9]+)\.([0-9]+)\.([0-9]+)]=])
+ set(CUDAToolkit_VERSION_MAJOR "${CMAKE_MATCH_1}")
+ set(CUDAToolkit_VERSION_MINOR "${CMAKE_MATCH_2}")
+ set(CUDAToolkit_VERSION_PATCH "${CMAKE_MATCH_3}")
+ set(CUDAToolkit_VERSION "${CMAKE_CUDA_COMPILER_VERSION}")
+ endif()
+else()
+ # Compute the version by invoking nvcc
+ execute_process (COMMAND ${CUDAToolkit_NVCC_EXECUTABLE} "--version" OUTPUT_VARIABLE NVCC_OUT)
+ if(NVCC_OUT MATCHES [=[ V([0-9]+)\.([0-9]+)\.([0-9]+)]=])
+ set(CUDAToolkit_VERSION_MAJOR "${CMAKE_MATCH_1}")
+ set(CUDAToolkit_VERSION_MINOR "${CMAKE_MATCH_2}")
+ set(CUDAToolkit_VERSION_PATCH "${CMAKE_MATCH_3}")
+ set(CUDAToolkit_VERSION "${CMAKE_MATCH_1}.${CMAKE_MATCH_2}.${CMAKE_MATCH_3}")
+ endif()
+ unset(NVCC_OUT)
+endif()
+
+
+get_filename_component(CUDAToolkit_ROOT_DIR ${CUDAToolkit_BIN_DIR} DIRECTORY ABSOLUTE)
+
+# Now that we have the real ROOT_DIR, find components inside it.
+list(APPEND CMAKE_PREFIX_PATH ${CUDAToolkit_ROOT_DIR})
+
+# Find the include/ directory
+find_path(CUDAToolkit_INCLUDE_DIR
+ NAMES cuda_runtime.h
+)
+
+# And find the CUDA Runtime Library libcudart
+find_library(CUDA_CUDART
+ NAMES cudart
+ PATH_SUFFIXES lib64 lib/x64
+)
+if (NOT CUDA_CUDART AND NOT CUDAToolkit_FIND_QUIETLY)
+ message(STATUS "Unable to find cudart library.")
+endif()
+
+unset(CUDAToolkit_ROOT_DIR)
+list(REMOVE_AT CMAKE_PREFIX_PATH -1)
+
+#-----------------------------------------------------------------------------
+# Perform version comparison and validate all required variables are set.
+include(${CMAKE_CURRENT_LIST_DIR}/FindPackageHandleStandardArgs.cmake)
+find_package_handle_standard_args(CUDAToolkit
+ REQUIRED_VARS
+ CUDAToolkit_INCLUDE_DIR
+ CUDA_CUDART
+ CUDAToolkit_NVCC_EXECUTABLE
+ VERSION_VAR
+ CUDAToolkit_VERSION
+)
+
+#-----------------------------------------------------------------------------
+# Construct result variables
+if(CUDAToolkit_FOUND)
+ set(CUDAToolkit_INCLUDE_DIRS ${CUDAToolkit_INCLUDE_DIR})
+ get_filename_component(CUDAToolkit_LIBRARY_DIR ${CUDA_CUDART} DIRECTORY ABSOLUTE)
+endif()
+
+#-----------------------------------------------------------------------------
+# Construct import targets
+if(CUDAToolkit_FOUND)
+
+ function(find_and_add_cuda_import_lib lib_name)
+
+ if(ARGC GREATER 1)
+ set(search_names ${ARGN})
+ else()
+ set(search_names ${lib_name})
+ endif()
+
+ find_library(CUDA_${lib_name}_LIBRARY
+ NAMES ${search_names}
+ PATHS ${CUDAToolkit_LIBRARY_DIR}
+ ENV CUDA_PATH
+ PATH_SUFFIXES nvidia/current lib64 lib/x64 lib
+ )
+
+ if (NOT CUDA::${lib_name} AND CUDA_${lib_name}_LIBRARY)
+ add_library(CUDA::${lib_name} IMPORTED INTERFACE)
+ target_include_directories(CUDA::${lib_name} SYSTEM INTERFACE "${CUDAToolkit_INCLUDE_DIRS}")
+ target_link_libraries(CUDA::${lib_name} INTERFACE "${CUDA_${lib_name}_LIBRARY}")
+ endif()
+ endfunction()
+
+ function(add_cuda_link_dependency lib_name)
+ foreach(dependency IN LISTS ${ARGN})
+ target_link_libraries(CUDA::${lib_name} INTERFACE CUDA::${dependency})
+ endforeach()
+ endfunction()
+
+ add_library(CUDA::toolkit IMPORTED INTERFACE)
+ target_include_directories(CUDA::toolkit SYSTEM INTERFACE "${CUDAToolkit_INCLUDE_DIRS}")
+ target_link_directories(CUDA::toolkit INTERFACE "${CUDAToolkit_LIBRARY_DIR}")
+
+
+ find_and_add_cuda_import_lib(cuda_driver cuda)
+
+ find_and_add_cuda_import_lib(cudart)
+ find_and_add_cuda_import_lib(cudart_static)
+
+ foreach (cuda_lib cublas cufft cufftw curand cusolver cusparse nvgraph nvjpeg)
+ find_and_add_cuda_import_lib(${cuda_lib})
+ add_cuda_link_dependency(${cuda_lib} cudart)
+
+ find_and_add_cuda_import_lib(${cuda_lib}_static)
+ add_cuda_link_dependency(${cuda_lib}_static cudart_static)
+ endforeach()
+
+ # cuSOLVER depends on cuBLAS, and cuSPARSE
+ add_cuda_link_dependency(cusolver cublas cusparse)
+ add_cuda_link_dependency(cusolver_static cublas_static cusparse)
+
+ # nvGRAPH depends on cuRAND, and cuSOLVER.
+ add_cuda_link_dependency(nvgraph curand cusolver)
+ add_cuda_link_dependency(nvgraph_static curand_static cusolver_static)
+
+ find_and_add_cuda_import_lib(nppc)
+ find_and_add_cuda_import_lib(nppc_static)
+
+ add_cuda_link_dependency(nppc cudart)
+ add_cuda_link_dependency(nppc_static cudart_static culibos)
+
+ # Process the majority of the NPP libraries.
+ foreach (cuda_lib nppial nppicc nppidei nppif nppig nppim nppist nppitc npps nppicom nppisu)
+ find_and_add_cuda_import_lib(${cuda_lib})
+ find_and_add_cuda_import_lib(${cuda_lib}_static)
+ add_cuda_link_dependency(${cuda_lib} nppc)
+ add_cuda_link_dependency(${cuda_lib}_static nppc_static)
+ endforeach()
+
+ find_and_add_cuda_import_lib(nvrtc)
+ add_cuda_link_dependency(nvrtc cuda_driver)
+
+ find_and_add_cuda_import_lib(nvml nvidia-ml nvml)
+
+ if(WIN32)
+ # nvtools can be installed outside the CUDA toolkit directory
+ # so prefer the NVTOOLSEXT_PATH windows only environment variable
+ # In addition on windows the most common name is nvToolsExt64_1
+ find_library(CUDA_nvToolsExt_LIBRARY
+ NAMES nvToolsExt64_1 nvToolsExt64 nvToolsExt
+ PATHS ENV NVTOOLSEXT_PATH
+ ENV CUDA_PATH
+ PATH_SUFFIXES lib/x64 lib
+ )
+ endif()
+ find_and_add_cuda_import_lib(nvToolsExt nvToolsExt nvToolsExt64)
+
+ add_cuda_link_dependency(nvToolsExt cudart)
+
+ find_and_add_cuda_import_lib(OpenCL)
+
+ find_and_add_cuda_import_lib(culibos)
+ if(TARGET CUDA::culibos)
+ foreach (cuda_lib cublas cufft cusparse curand nvjpeg)
+ add_cuda_link_dependency(${cuda_lib}_static culibos)
+ endforeach()
+ endif()
+
+endif()
diff --git a/Modules/FindProtobuf.cmake b/Modules/FindProtobuf.cmake
index 2d45965..f35978d 100644
--- a/Modules/FindProtobuf.cmake
+++ b/Modules/FindProtobuf.cmake
@@ -482,22 +482,24 @@ if(Protobuf_INCLUDE_DIR)
"${_PROTOBUF_COMMON_HEADER} reveals protobuf ${Protobuf_VERSION}")
endif()
- # Check Protobuf compiler version to be aligned with libraries version
- execute_process(COMMAND ${Protobuf_PROTOC_EXECUTABLE} --version
- OUTPUT_VARIABLE _PROTOBUF_PROTOC_EXECUTABLE_VERSION)
+ if(Protobuf_PROTOC_EXECUTABLE)
+ # Check Protobuf compiler version to be aligned with libraries version
+ execute_process(COMMAND ${Protobuf_PROTOC_EXECUTABLE} --version
+ OUTPUT_VARIABLE _PROTOBUF_PROTOC_EXECUTABLE_VERSION)
- if("${_PROTOBUF_PROTOC_EXECUTABLE_VERSION}" MATCHES "libprotoc ([0-9.]+)")
- set(_PROTOBUF_PROTOC_EXECUTABLE_VERSION "${CMAKE_MATCH_1}")
- endif()
+ if("${_PROTOBUF_PROTOC_EXECUTABLE_VERSION}" MATCHES "libprotoc ([0-9.]+)")
+ set(_PROTOBUF_PROTOC_EXECUTABLE_VERSION "${CMAKE_MATCH_1}")
+ endif()
- if(Protobuf_DEBUG)
- message(STATUS "[ ${CMAKE_CURRENT_LIST_FILE}:${CMAKE_CURRENT_LIST_LINE} ] "
- "${Protobuf_PROTOC_EXECUTABLE} reveals version ${_PROTOBUF_PROTOC_EXECUTABLE_VERSION}")
- endif()
+ if(Protobuf_DEBUG)
+ message(STATUS "[ ${CMAKE_CURRENT_LIST_FILE}:${CMAKE_CURRENT_LIST_LINE} ] "
+ "${Protobuf_PROTOC_EXECUTABLE} reveals version ${_PROTOBUF_PROTOC_EXECUTABLE_VERSION}")
+ endif()
- if(NOT "${_PROTOBUF_PROTOC_EXECUTABLE_VERSION}" VERSION_EQUAL "${Protobuf_VERSION}")
+ if(NOT "${_PROTOBUF_PROTOC_EXECUTABLE_VERSION}" VERSION_EQUAL "${Protobuf_VERSION}")
message(WARNING "Protobuf compiler version ${_PROTOBUF_PROTOC_EXECUTABLE_VERSION}"
- " doesn't match library version ${Protobuf_VERSION}")
+ " doesn't match library version ${Protobuf_VERSION}")
+ endif()
endif()
if(Protobuf_LIBRARY)
diff --git a/Modules/Platform/Darwin-Initialize.cmake b/Modules/Platform/Darwin-Initialize.cmake
index 2d797f6..729217c 100644
--- a/Modules/Platform/Darwin-Initialize.cmake
+++ b/Modules/Platform/Darwin-Initialize.cmake
@@ -122,7 +122,97 @@ endforeach()
set(CMAKE_OSX_SYSROOT "${_CMAKE_OSX_SYSROOT_DEFAULT}" CACHE ${_CMAKE_OSX_SYSROOT_TYPE}
"The product will be built against the headers and libraries located inside the indicated SDK.")
-# Transform the cached value to something we can use.
+# Resolves the SDK name into a path
+function(_apple_resolve_sdk_path sdk_name ret)
+ execute_process(
+ COMMAND xcrun -sdk ${sdk_name} --show-sdk-path
+ OUTPUT_VARIABLE _stdout
+ OUTPUT_STRIP_TRAILING_WHITESPACE
+ ERROR_VARIABLE _stderr
+ RESULT_VARIABLE _failed
+ )
+ set(${ret} "${_stdout}" PARENT_SCOPE)
+endfunction()
+# Handle multi-arch sysroots. Do this before CMAKE_OSX_SYSROOT is
+# transformed into a path, so that we know the sysroot name.
+function(_apple_resolve_multi_arch_sysroots)
+ if(CMAKE_APPLE_ARCH_SYSROOTS)
+ return() # Already cached
+ endif()
+
+ list(LENGTH CMAKE_OSX_ARCHITECTURES _num_archs)
+ if(NOT (_num_archs GREATER 1))
+ return() # Only apply to multi-arch
+ endif()
+
+ if(CMAKE_OSX_SYSROOT STREQUAL "macosx")
+ # macOS doesn't have a simulator sdk / sysroot, so there is no need to handle per-sdk arches.
+ return()
+ endif()
+
+ if(IS_DIRECTORY "${CMAKE_OSX_SYSROOT}")
+ if(NOT CMAKE_OSX_SYSROOT STREQUAL _CMAKE_OSX_SYSROOT_DEFAULT)
+ message(WARNING "Can not resolve multi-arch sysroots with CMAKE_OSX_SYSROOT set to path (${CMAKE_OSX_SYSROOT})")
+ endif()
+ return()
+ endif()
+
+ string(REPLACE "os" "simulator" _simulator_sdk ${CMAKE_OSX_SYSROOT})
+ set(_sdks "${CMAKE_OSX_SYSROOT};${_simulator_sdk}")
+ foreach(sdk ${_sdks})
+ _apple_resolve_sdk_path(${sdk} _sdk_path)
+ if(NOT IS_DIRECTORY "${_sdk_path}")
+ message(WARNING "Failed to resolve SDK path for '${sdk}'")
+ continue()
+ endif()
+
+ execute_process(
+ COMMAND plutil -extract SupportedTargets.${sdk}.Archs json ${_sdk_path}/SDKSettings.plist -o -
+ OUTPUT_VARIABLE _sdk_archs_json
+ OUTPUT_STRIP_TRAILING_WHITESPACE
+ ERROR_VARIABLE _stderr
+ RESULT_VARIABLE _failed
+ )
+ if(_failed)
+ # Failure to extract supported architectures for an SDK means that the installed SDK is old
+ # and does not provide such information (SDKs that come with Xcode >= 10.x started providing
+ # the information). In such a case, return early, and handle multi-arch builds the old way
+ # (no per-sdk arches).
+ return()
+ endif()
+
+ # Poor man's JSON decoding
+ string(REGEX REPLACE "[]\\[\"]" "" _sdk_archs ${_sdk_archs_json})
+ string(REPLACE "," ";" _sdk_archs ${_sdk_archs})
+
+ set(_sdk_archs_${sdk} ${_sdk_archs})
+ set(_sdk_path_${sdk} ${_sdk_path})
+ endforeach()
+
+ foreach(arch ${CMAKE_OSX_ARCHITECTURES})
+ set(_arch_sysroot "")
+ foreach(sdk ${_sdks})
+ list(FIND _sdk_archs_${sdk} ${arch} arch_index)
+ if(NOT arch_index EQUAL -1)
+ set(_arch_sysroot ${_sdk_path_${sdk}})
+ break()
+ endif()
+ endforeach()
+ if(_arch_sysroot)
+ list(APPEND _arch_sysroots ${_arch_sysroot})
+ else()
+ message(WARNING "No SDK found for architecture '${arch}'")
+ list(APPEND _arch_sysroots "") # Placeholder
+ endif()
+ endforeach()
+
+ set(CMAKE_APPLE_ARCH_SYSROOTS "${_arch_sysroots}" CACHE INTERNAL
+ "Architecture dependent sysroots, one per CMAKE_OSX_ARCHITECTURES")
+endfunction()
+
+_apple_resolve_multi_arch_sysroots()
+
+# Transform CMAKE_OSX_SYSROOT to absolute path
set(_CMAKE_OSX_SYSROOT_PATH "")
if(CMAKE_OSX_SYSROOT)
if("x${CMAKE_OSX_SYSROOT}" MATCHES "/")
@@ -134,16 +224,9 @@ if(CMAKE_OSX_SYSROOT)
endif()
set(_CMAKE_OSX_SYSROOT_PATH "${CMAKE_OSX_SYSROOT}")
else()
- # Transform the sdk name into a path.
- execute_process(
- COMMAND xcodebuild -sdk ${CMAKE_OSX_SYSROOT} -version Path
- OUTPUT_VARIABLE _stdout
- OUTPUT_STRIP_TRAILING_WHITESPACE
- ERROR_VARIABLE _stderr
- RESULT_VARIABLE _failed
- )
- if(NOT _failed AND IS_DIRECTORY "${_stdout}")
- set(_CMAKE_OSX_SYSROOT_PATH "${_stdout}")
+ _apple_resolve_sdk_path(${CMAKE_OSX_SYSROOT} _sdk_path)
+ if(IS_DIRECTORY "${_sdk_path}")
+ set(_CMAKE_OSX_SYSROOT_PATH "${_sdk_path}")
# For non-Xcode generators use the path.
if(NOT "${CMAKE_GENERATOR}" MATCHES "Xcode")
set(CMAKE_OSX_SYSROOT "${_CMAKE_OSX_SYSROOT_PATH}")
diff --git a/Source/CMakeVersion.cmake b/Source/CMakeVersion.cmake
index 88afed4..c917ece 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 16)
-set(CMake_VERSION_PATCH 20191217)
+set(CMake_VERSION_PATCH 20191218)
#set(CMake_VERSION_RC 0)
set(CMake_VERSION_IS_DIRTY 0)
diff --git a/Source/cmCoreTryCompile.cxx b/Source/cmCoreTryCompile.cxx
index 5711cae..4715cfa 100644
--- a/Source/cmCoreTryCompile.cxx
+++ b/Source/cmCoreTryCompile.cxx
@@ -51,6 +51,8 @@ static std::string const kCMAKE_OSX_ARCHITECTURES = "CMAKE_OSX_ARCHITECTURES";
static std::string const kCMAKE_OSX_DEPLOYMENT_TARGET =
"CMAKE_OSX_DEPLOYMENT_TARGET";
static std::string const kCMAKE_OSX_SYSROOT = "CMAKE_OSX_SYSROOT";
+static std::string const kCMAKE_APPLE_ARCH_SYSROOTS =
+ "CMAKE_APPLE_ARCH_SYSROOTS";
static std::string const kCMAKE_POSITION_INDEPENDENT_CODE =
"CMAKE_POSITION_INDEPENDENT_CODE";
static std::string const kCMAKE_SYSROOT = "CMAKE_SYSROOT";
@@ -723,6 +725,7 @@ int cmCoreTryCompile::TryCompileCode(std::vector<std::string> const& argv,
vars.insert(kCMAKE_OSX_ARCHITECTURES);
vars.insert(kCMAKE_OSX_DEPLOYMENT_TARGET);
vars.insert(kCMAKE_OSX_SYSROOT);
+ vars.insert(kCMAKE_APPLE_ARCH_SYSROOTS);
vars.insert(kCMAKE_POSITION_INDEPENDENT_CODE);
vars.insert(kCMAKE_SYSROOT);
vars.insert(kCMAKE_SYSROOT_COMPILE);
diff --git a/Source/cmExportInstallAndroidMKGenerator.cxx b/Source/cmExportInstallAndroidMKGenerator.cxx
index 2d732c1..9702e0e 100644
--- a/Source/cmExportInstallAndroidMKGenerator.cxx
+++ b/Source/cmExportInstallAndroidMKGenerator.cxx
@@ -49,7 +49,7 @@ void cmExportInstallAndroidMKGenerator::GenerateImportHeaderCode(
if (te->ArchiveGenerator) {
dest = te->ArchiveGenerator->GetDestination("");
}
- te->Target->Target->SetProperty("__dest", dest.c_str());
+ te->Target->Target->SetProperty("__dest", dest);
}
}
diff --git a/Source/cmGhsMultiTargetGenerator.cxx b/Source/cmGhsMultiTargetGenerator.cxx
index 8e4352e..f7c542f 100644
--- a/Source/cmGhsMultiTargetGenerator.cxx
+++ b/Source/cmGhsMultiTargetGenerator.cxx
@@ -113,7 +113,7 @@ void cmGhsMultiTargetGenerator::Generate()
// Tell the global generator the name of the project file
this->GeneratorTarget->Target->SetProperty("GENERATOR_FILE_NAME",
- this->Name.c_str());
+ this->Name);
this->GeneratorTarget->Target->SetProperty(
"GENERATOR_FILE_NAME_EXT", GhsMultiGpj::GetGpjTag(this->TagType));
diff --git a/Source/cmGlobalGenerator.cxx b/Source/cmGlobalGenerator.cxx
index b27c3dc..bcc9050 100644
--- a/Source/cmGlobalGenerator.cxx
+++ b/Source/cmGlobalGenerator.cxx
@@ -2668,7 +2668,7 @@ cmTarget cmGlobalGenerator::CreateGlobalTarget(GlobalTargetInfo const& gti,
cc.SetUsesTerminal(gti.UsesTerminal);
target.AddPostBuildCommand(std::move(cc));
if (!gti.Message.empty()) {
- target.SetProperty("EchoString", gti.Message.c_str());
+ target.SetProperty("EchoString", gti.Message);
}
for (std::string const& d : gti.Depends) {
target.AddUtility(d);
diff --git a/Source/cmIncludeExternalMSProjectCommand.cxx b/Source/cmIncludeExternalMSProjectCommand.cxx
index fa1e8bc..e59c428 100644
--- a/Source/cmIncludeExternalMSProjectCommand.cxx
+++ b/Source/cmIncludeExternalMSProjectCommand.cxx
@@ -83,22 +83,21 @@ bool cmIncludeExternalMSProjectCommand(std::vector<std::string> const& args,
}
// Create a target instance for this utility.
- cmTarget* target =
- mf.AddNewTarget(cmStateEnums::UTILITY, utility_name.c_str());
+ cmTarget* target = mf.AddNewTarget(cmStateEnums::UTILITY, utility_name);
if (mf.GetPropertyAsBool("EXCLUDE_FROM_ALL")) {
target->SetProperty("EXCLUDE_FROM_ALL", "TRUE");
}
- target->SetProperty("GENERATOR_FILE_NAME", utility_name.c_str());
- target->SetProperty("EXTERNAL_MSPROJECT", path.c_str());
+ target->SetProperty("GENERATOR_FILE_NAME", utility_name);
+ target->SetProperty("EXTERNAL_MSPROJECT", path);
if (!customType.empty())
- target->SetProperty("VS_PROJECT_TYPE", customType.c_str());
+ target->SetProperty("VS_PROJECT_TYPE", customType);
if (!platformMapping.empty())
- target->SetProperty("VS_PLATFORM_MAPPING", platformMapping.c_str());
+ target->SetProperty("VS_PLATFORM_MAPPING", platformMapping);
for (std::string const& d : depends) {
- target->AddUtility(d.c_str());
+ target->AddUtility(d);
}
}
#endif
diff --git a/Source/cmLocalGenerator.cxx b/Source/cmLocalGenerator.cxx
index e6b6cff..1da6efe 100644
--- a/Source/cmLocalGenerator.cxx
+++ b/Source/cmLocalGenerator.cxx
@@ -1778,10 +1778,18 @@ void cmLocalGenerator::AddArchitectureFlags(std::string& flags,
const std::string& lang,
const std::string& config)
{
- // Only add macOS specific flags on Darwin platforms (macOS and iOS):
+ // Only add Apple specific flags on Apple platforms
if (this->Makefile->IsOn("APPLE") && this->EmitUniversalBinaryFlags) {
std::vector<std::string> archs;
target->GetAppleArchs(config, archs);
+ if (!archs.empty() && !lang.empty() &&
+ (lang[0] == 'C' || lang[0] == 'F' || lang[0] == 'O')) {
+ for (std::string const& arch : archs) {
+ flags += " -arch ";
+ flags += arch;
+ }
+ }
+
const char* sysroot = this->Makefile->GetDefinition("CMAKE_OSX_SYSROOT");
if (sysroot && sysroot[0] == '/' && !sysroot[1]) {
sysroot = nullptr;
@@ -1789,27 +1797,37 @@ void cmLocalGenerator::AddArchitectureFlags(std::string& flags,
std::string sysrootFlagVar =
std::string("CMAKE_") + lang + "_SYSROOT_FLAG";
const char* sysrootFlag = this->Makefile->GetDefinition(sysrootFlagVar);
+ if (sysrootFlag && *sysrootFlag) {
+ std::vector<std::string> arch_sysroots;
+ if (const char* arch_sysroots_str =
+ this->Makefile->GetDefinition("CMAKE_APPLE_ARCH_SYSROOTS")) {
+ cmExpandList(std::string(arch_sysroots_str), arch_sysroots, true);
+ }
+ if (!arch_sysroots.empty()) {
+ assert(arch_sysroots.size() == archs.size());
+ for (size_t i = 0; i < archs.size(); ++i) {
+ if (arch_sysroots[i].empty()) {
+ continue;
+ }
+ flags += " -Xarch_" + archs[i] + " ";
+ // Combine sysroot flag and path to work with -Xarch
+ std::string arch_sysroot = sysrootFlag + arch_sysroots[i];
+ flags += this->ConvertToOutputFormat(arch_sysroot, SHELL);
+ }
+ } else if (sysroot && *sysroot) {
+ flags += " ";
+ flags += sysrootFlag;
+ flags += " ";
+ flags += this->ConvertToOutputFormat(sysroot, SHELL);
+ }
+ }
+
const char* deploymentTarget =
this->Makefile->GetDefinition("CMAKE_OSX_DEPLOYMENT_TARGET");
std::string deploymentTargetFlagVar =
std::string("CMAKE_") + lang + "_OSX_DEPLOYMENT_TARGET_FLAG";
const char* deploymentTargetFlag =
this->Makefile->GetDefinition(deploymentTargetFlagVar);
- if (!archs.empty() && !lang.empty() &&
- (lang[0] == 'C' || lang[0] == 'F' || lang[0] == 'O')) {
- for (std::string const& arch : archs) {
- flags += " -arch ";
- flags += arch;
- }
- }
-
- if (sysrootFlag && *sysrootFlag && sysroot && *sysroot) {
- flags += " ";
- flags += sysrootFlag;
- flags += " ";
- flags += this->ConvertToOutputFormat(sysroot, SHELL);
- }
-
if (deploymentTargetFlag && *deploymentTargetFlag && deploymentTarget &&
*deploymentTarget) {
flags += " ";
@@ -2534,7 +2552,7 @@ void cmLocalGenerator::AddPchDependencies(cmGeneratorTarget* target)
}
target->Target->SetProperty("COMPILE_PDB_OUTPUT_DIRECTORY",
- target_compile_pdb_dir.c_str());
+ target_compile_pdb_dir);
}
std::string pchSourceObj =
@@ -2543,8 +2561,7 @@ void cmLocalGenerator::AddPchDependencies(cmGeneratorTarget* target)
// Link to the pch object file
target->Target->AppendProperty(
"LINK_FLAGS",
- cmStrCat(" ", this->ConvertToOutputFormat(pchSourceObj, SHELL))
- .c_str(),
+ cmStrCat(" ", this->ConvertToOutputFormat(pchSourceObj, SHELL)),
true);
}
} else {
diff --git a/Source/cmLocalVisualStudio7Generator.cxx b/Source/cmLocalVisualStudio7Generator.cxx
index 0758fd4..7683855 100644
--- a/Source/cmLocalVisualStudio7Generator.cxx
+++ b/Source/cmLocalVisualStudio7Generator.cxx
@@ -194,7 +194,7 @@ void cmLocalVisualStudio7Generator::CreateSingleVCProj(
}
// add to the list of projects
- target->Target->SetProperty("GENERATOR_FILE_NAME", lname.c_str());
+ target->Target->SetProperty("GENERATOR_FILE_NAME", lname);
// create the dsp.cmake file
std::string fname;
fname = cmStrCat(this->GetCurrentBinaryDirectory(), '/', lname);
diff --git a/Source/cmMakefile.cxx b/Source/cmMakefile.cxx
index efacca3..75f00fc 100644
--- a/Source/cmMakefile.cxx
+++ b/Source/cmMakefile.cxx
@@ -1940,7 +1940,7 @@ void cmMakefile::AddGlobalLinkInformation(cmTarget& target)
target.AddLinkLibrary(*this, libraryName, libType);
target.AppendProperty(
"INTERFACE_LINK_LIBRARIES",
- target.GetDebugGeneratorExpressions(libraryName, libType).c_str());
+ target.GetDebugGeneratorExpressions(libraryName, libType));
}
}
}
@@ -2400,7 +2400,7 @@ void cmMakefile::ExpandVariablesCMP0019()
<< " " << dirs << "\n";
/* clang-format on */
}
- t.SetProperty("INCLUDE_DIRECTORIES", dirs.c_str());
+ t.SetProperty("INCLUDE_DIRECTORIES", dirs);
}
}
@@ -4551,7 +4551,7 @@ bool cmMakefile::AddRequiredTargetFeature(cmTarget* target,
std::string* error) const
{
if (cmGeneratorExpression::Find(feature) != std::string::npos) {
- target->AppendProperty("COMPILE_FEATURES", feature.c_str());
+ target->AppendProperty("COMPILE_FEATURES", feature);
return true;
}
@@ -4582,7 +4582,7 @@ bool cmMakefile::AddRequiredTargetFeature(cmTarget* target,
return false;
}
- target->AppendProperty("COMPILE_FEATURES", feature.c_str());
+ target->AppendProperty("COMPILE_FEATURES", feature);
if (lang == "C" || lang == "OBJC") {
return this->AddRequiredTargetCFeature(target, feature, lang, error);
diff --git a/Source/cmQtAutoGenInitializer.cxx b/Source/cmQtAutoGenInitializer.cxx
index fc65756..921e2b2 100644
--- a/Source/cmQtAutoGenInitializer.cxx
+++ b/Source/cmQtAutoGenInitializer.cxx
@@ -1147,7 +1147,7 @@ bool cmQtAutoGenInitializer::InitAutogenTarget()
// Set FOLDER property in autogen target
if (!this->TargetsFolder.empty()) {
- autogenTarget->SetProperty("FOLDER", this->TargetsFolder.c_str());
+ autogenTarget->SetProperty("FOLDER", this->TargetsFolder);
}
// Add autogen target to the origin target dependencies
@@ -1216,7 +1216,7 @@ bool cmQtAutoGenInitializer::InitRccTargets()
// Set FOLDER property in autogen target
if (!this->TargetsFolder.empty()) {
- autoRccTarget->SetProperty("FOLDER", this->TargetsFolder.c_str());
+ autoRccTarget->SetProperty("FOLDER", this->TargetsFolder);
}
if (!this->Rcc.ExecutableTargetName.empty()) {
autoRccTarget->AddUtility(this->Rcc.ExecutableTargetName,
@@ -1528,8 +1528,8 @@ bool cmQtAutoGenInitializer::AddToSourceGroup(std::string const& fileName,
void cmQtAutoGenInitializer::AddCleanFile(std::string const& fileName)
{
- this->GenTarget->Target->AppendProperty("ADDITIONAL_CLEAN_FILES",
- fileName.c_str(), false);
+ this->GenTarget->Target->AppendProperty("ADDITIONAL_CLEAN_FILES", fileName,
+ false);
}
void cmQtAutoGenInitializer::ConfigFileNames(ConfigString& configString,
diff --git a/Source/cmSetTargetPropertiesCommand.cxx b/Source/cmSetTargetPropertiesCommand.cxx
index 62252c0..cd0fa40 100644
--- a/Source/cmSetTargetPropertiesCommand.cxx
+++ b/Source/cmSetTargetPropertiesCommand.cxx
@@ -71,7 +71,7 @@ static bool SetOneTarget(const std::string& tname,
// now loop through all the props and set them
unsigned int k;
for (k = 0; k < propertyPairs.size(); k = k + 2) {
- target->SetProperty(propertyPairs[k], propertyPairs[k + 1].c_str());
+ target->SetProperty(propertyPairs[k], propertyPairs[k + 1]);
target->CheckProperty(propertyPairs[k], mf);
}
}
diff --git a/Source/cmTarget.cxx b/Source/cmTarget.cxx
index 548f761..d2693b8 100644
--- a/Source/cmTarget.cxx
+++ b/Source/cmTarget.cxx
@@ -952,9 +952,8 @@ void cmTarget::AddLinkLibrary(cmMakefile& mf, std::string const& lib,
(isNonImportedTarget && llt != GENERAL_LibraryType)
? targetNameGenex(libRef)
: libRef;
- this->AppendProperty(
- "LINK_LIBRARIES",
- this->GetDebugGeneratorExpressions(libName, llt).c_str());
+ this->AppendProperty("LINK_LIBRARIES",
+ this->GetDebugGeneratorExpressions(libName, llt));
}
if (cmGeneratorExpression::Find(lib) != std::string::npos || lib != libRef ||
@@ -1288,9 +1287,9 @@ void cmTarget::SetProperty(const std::string& prop, const char* value)
impl->Properties.SetProperty(prop, reusedFrom.c_str());
- reusedTarget->SetProperty("COMPILE_PDB_NAME", reusedFrom.c_str());
+ reusedTarget->SetProperty("COMPILE_PDB_NAME", reusedFrom);
reusedTarget->SetProperty("COMPILE_PDB_OUTPUT_DIRECTORY",
- cmStrCat(reusedFrom, ".dir/").c_str());
+ cmStrCat(reusedFrom, ".dir/"));
this->SetProperty("COMPILE_PDB_NAME",
reusedTarget->GetProperty("COMPILE_PDB_NAME"));
@@ -1425,7 +1424,7 @@ void cmTarget::AppendBuildInterfaceIncludes()
dirs += impl->Makefile->GetCurrentSourceDirectory();
if (!dirs.empty()) {
this->AppendProperty("INTERFACE_INCLUDE_DIRECTORIES",
- ("$<BUILD_INTERFACE:" + dirs + ">").c_str());
+ ("$<BUILD_INTERFACE:" + dirs + ">"));
}
}
}
diff --git a/Source/cmTarget.h b/Source/cmTarget.h
index 1bfa3ce..bdf8c0f 100644
--- a/Source/cmTarget.h
+++ b/Source/cmTarget.h
@@ -164,8 +164,17 @@ public:
//! Set/Get a property of this target file
void SetProperty(const std::string& prop, const char* value);
+ void SetProperty(const std::string& prop, const std::string& value)
+ {
+ SetProperty(prop, value.c_str());
+ }
void AppendProperty(const std::string& prop, const char* value,
bool asString = false);
+ void AppendProperty(const std::string& prop, const std::string& value,
+ bool asString = false)
+ {
+ AppendProperty(prop, value.c_str(), asString);
+ }
//! Might return a nullptr if the property is not set or invalid
const char* GetProperty(const std::string& prop) const;
//! Always returns a valid pointer
diff --git a/Source/cmTargetCompileDefinitionsCommand.cxx b/Source/cmTargetCompileDefinitionsCommand.cxx
index edee167..b56b245 100644
--- a/Source/cmTargetCompileDefinitionsCommand.cxx
+++ b/Source/cmTargetCompileDefinitionsCommand.cxx
@@ -28,7 +28,7 @@ private:
const std::vector<std::string>& content,
bool /*prepend*/, bool /*system*/) override
{
- tgt->AppendProperty("COMPILE_DEFINITIONS", this->Join(content).c_str());
+ tgt->AppendProperty("COMPILE_DEFINITIONS", this->Join(content));
return true; // Successfully handled.
}
diff --git a/Source/cmTargetIncludeDirectoriesCommand.cxx b/Source/cmTargetIncludeDirectoriesCommand.cxx
index 95b69f3..35635b9 100644
--- a/Source/cmTargetIncludeDirectoriesCommand.cxx
+++ b/Source/cmTargetIncludeDirectoriesCommand.cxx
@@ -88,8 +88,7 @@ void TargetIncludeDirectoriesImpl::HandleInterfaceContent(
system);
if (system) {
std::string joined = this->Join(content);
- tgt->AppendProperty("INTERFACE_SYSTEM_INCLUDE_DIRECTORIES",
- joined.c_str());
+ tgt->AppendProperty("INTERFACE_SYSTEM_INCLUDE_DIRECTORIES", joined);
}
}
diff --git a/Source/cmTargetLinkLibrariesCommand.cxx b/Source/cmTargetLinkLibrariesCommand.cxx
index 0d2383a..e1ac6a8 100644
--- a/Source/cmTargetLinkLibrariesCommand.cxx
+++ b/Source/cmTargetLinkLibrariesCommand.cxx
@@ -480,7 +480,7 @@ static bool HandleLibrary(cmMakefile& mf, cmTarget* target,
cmGeneratorExpression::Find(lib) != std::string::npos) {
configLib = "$<LINK_ONLY:" + configLib + ">";
}
- target->AppendProperty("INTERFACE_LINK_LIBRARIES", configLib.c_str());
+ target->AppendProperty("INTERFACE_LINK_LIBRARIES", configLib);
}
return true;
}
@@ -488,9 +488,8 @@ static bool HandleLibrary(cmMakefile& mf, cmTarget* target,
// Handle general case where the command was called with another keyword than
// PRIVATE / LINK_PRIVATE or none at all. (The "INTERFACE_LINK_LIBRARIES"
// property of the target on the LHS shall be populated.)
- target->AppendProperty(
- "INTERFACE_LINK_LIBRARIES",
- target->GetDebugGeneratorExpressions(libRef, llt).c_str());
+ target->AppendProperty("INTERFACE_LINK_LIBRARIES",
+ target->GetDebugGeneratorExpressions(libRef, llt));
// Stop processing if called without any keyword.
if (currentProcessingState == ProcessingLinkLibraries) {
@@ -522,12 +521,12 @@ static bool HandleLibrary(cmMakefile& mf, cmTarget* target,
// Put in the DEBUG configuration interfaces.
for (std::string const& dc : debugConfigs) {
prop = cmStrCat("LINK_INTERFACE_LIBRARIES_", dc);
- target->AppendProperty(prop, libRef.c_str());
+ target->AppendProperty(prop, libRef);
}
}
if (llt == OPTIMIZED_LibraryType || llt == GENERAL_LibraryType) {
// Put in the non-DEBUG configuration interfaces.
- target->AppendProperty("LINK_INTERFACE_LIBRARIES", libRef.c_str());
+ target->AppendProperty("LINK_INTERFACE_LIBRARIES", libRef);
// Make sure the DEBUG configuration interfaces exist so that the
// general one will not be used as a fall-back.
diff --git a/Source/cmTargetPrecompileHeadersCommand.cxx b/Source/cmTargetPrecompileHeadersCommand.cxx
index c6e2e5c..0670bd9 100644
--- a/Source/cmTargetPrecompileHeadersCommand.cxx
+++ b/Source/cmTargetPrecompileHeadersCommand.cxx
@@ -47,9 +47,8 @@ private:
bool /*prepend*/, bool /*system*/) override
{
std::string const& base = this->Makefile->GetCurrentSourceDirectory();
- tgt->AppendProperty(
- "PRECOMPILE_HEADERS",
- this->Join(ConvertToAbsoluteContent(content, base)).c_str());
+ tgt->AppendProperty("PRECOMPILE_HEADERS",
+ this->Join(ConvertToAbsoluteContent(content, base)));
return true;
}
diff --git a/Source/cmTargetPropCommandBase.cxx b/Source/cmTargetPropCommandBase.cxx
index bbc1e16..0de8d6d 100644
--- a/Source/cmTargetPropCommandBase.cxx
+++ b/Source/cmTargetPropCommandBase.cxx
@@ -84,9 +84,7 @@ bool cmTargetPropCommandBase::HandleArguments(
}
++argIndex;
- this->Target->SetProperty("PRECOMPILE_HEADERS_REUSE_FROM",
- args[argIndex].c_str());
-
+ this->Target->SetProperty("PRECOMPILE_HEADERS_REUSE_FROM", args[argIndex]);
++argIndex;
}
@@ -162,9 +160,8 @@ void cmTargetPropCommandBase::HandleInterfaceContent(
const char* propValue = tgt->GetProperty(propName);
const std::string totalContent = this->Join(content) +
(propValue ? std::string(";") + propValue : std::string());
- tgt->SetProperty(propName, totalContent.c_str());
+ tgt->SetProperty(propName, totalContent);
} else {
- tgt->AppendProperty("INTERFACE_" + this->Property,
- this->Join(content).c_str());
+ tgt->AppendProperty("INTERFACE_" + this->Property, this->Join(content));
}
}
diff --git a/Source/cmTargetSourcesCommand.cxx b/Source/cmTargetSourcesCommand.cxx
index c2e0b28..a1fbc9b 100644
--- a/Source/cmTargetSourcesCommand.cxx
+++ b/Source/cmTargetSourcesCommand.cxx
@@ -43,8 +43,7 @@ private:
bool /*prepend*/, bool /*system*/) override
{
tgt->AppendProperty(
- "SOURCES",
- this->Join(ConvertToAbsoluteContent(tgt, content, false)).c_str());
+ "SOURCES", this->Join(ConvertToAbsoluteContent(tgt, content, false)));
return true; // Successfully handled.
}
diff --git a/Source/cmVisualStudio10TargetGenerator.cxx b/Source/cmVisualStudio10TargetGenerator.cxx
index 66cf683..f707bb4 100644
--- a/Source/cmVisualStudio10TargetGenerator.cxx
+++ b/Source/cmVisualStudio10TargetGenerator.cxx
@@ -71,7 +71,7 @@ struct cmVisualStudio10TargetGenerator::Elem
void SetHasElements()
{
if (!HasElements) {
- this->S << ">\n";
+ this->S << ">";
HasElements = true;
}
}
@@ -103,15 +103,10 @@ struct cmVisualStudio10TargetGenerator::Elem
if (HasElements) {
this->WriteString("</") << this->Tag << ">";
- if (this->Indent > 0) {
- this->S << '\n';
- } else {
- // special case: don't print EOL at EOF
- }
} else if (HasContent) {
- this->S << "</" << this->Tag << ">\n";
+ this->S << "</" << this->Tag << ">";
} else {
- this->S << " />\n";
+ this->S << " />";
}
}
@@ -282,6 +277,7 @@ void cmVisualStudio10TargetGenerator::Elem::WritePlatformConfigTag(
std::ostream& cmVisualStudio10TargetGenerator::Elem::WriteString(
const char* line)
{
+ this->S << '\n';
this->S.fill(' ');
this->S.width(this->Indent * 2);
// write an empty string to get the fill level indent to print
@@ -334,9 +330,9 @@ void cmVisualStudio10TargetGenerator::Generate()
}
// Tell the global generator the name of the project file
this->GeneratorTarget->Target->SetProperty("GENERATOR_FILE_NAME",
- this->Name.c_str());
+ this->Name);
this->GeneratorTarget->Target->SetProperty("GENERATOR_FILE_NAME_EXT",
- ProjectFileExtension.c_str());
+ ProjectFileExtension);
this->DotNetHintReferences.clear();
this->AdditionalUsingDirectories.clear();
if (this->GeneratorTarget->GetType() <= cmStateEnums::OBJECT_LIBRARY) {
@@ -376,8 +372,7 @@ void cmVisualStudio10TargetGenerator::Generate()
char magic[] = { char(0xEF), char(0xBB), char(0xBF) };
BuildFileStream.write(magic, 3);
BuildFileStream << "<?xml version=\"1.0\" encoding=\""
- << this->GlobalGenerator->Encoding() << "\"?>"
- << "\n";
+ << this->GlobalGenerator->Encoding() << "\"?>";
{
Elem e0(BuildFileStream, "Project");
e0.Attribute("DefaultTargets", "Build");
@@ -1611,8 +1606,7 @@ void cmVisualStudio10TargetGenerator::WriteGroups()
fout.write(magic, 3);
fout << "<?xml version=\"1.0\" encoding=\""
- << this->GlobalGenerator->Encoding() << "\"?>"
- << "\n";
+ << this->GlobalGenerator->Encoding() << "\"?>";
{
Elem e0(fout, "Project");
e0.Attribute("ToolsVersion", this->GlobalGenerator->GetToolsVersion());
@@ -2835,10 +2829,8 @@ bool cmVisualStudio10TargetGenerator::ComputeClOptions(
}
if (this->MSTools) {
- // If we have the VS_WINRT_COMPONENT or CMAKE_VS_WINRT_BY_DEFAULT
- // set then force Compile as WinRT.
- if (this->GeneratorTarget->GetPropertyAsBool("VS_WINRT_COMPONENT") ||
- this->Makefile->IsOn("CMAKE_VS_WINRT_BY_DEFAULT")) {
+ // If we have the VS_WINRT_COMPONENT set then force Compile as WinRT
+ if (this->GeneratorTarget->GetPropertyAsBool("VS_WINRT_COMPONENT")) {
clOptions.AddFlag("CompileAsWinRT", "true");
// For WinRT components, add the _WINRT_DLL define to produce a lib
if (this->GeneratorTarget->GetType() == cmStateEnums::SHARED_LIBRARY ||
@@ -2846,7 +2838,8 @@ bool cmVisualStudio10TargetGenerator::ComputeClOptions(
clOptions.AddDefine("_WINRT_DLL");
}
} else if (this->GlobalGenerator->TargetsWindowsStore() ||
- this->GlobalGenerator->TargetsWindowsPhone()) {
+ this->GlobalGenerator->TargetsWindowsPhone() ||
+ this->Makefile->IsOn("CMAKE_VS_WINRT_BY_DEFAULT")) {
if (!clOptions.IsWinRt()) {
clOptions.AddFlag("CompileAsWinRT", "false");
}
diff --git a/Source/cmake.cxx b/Source/cmake.cxx
index a657bac..fdb3687 100644
--- a/Source/cmake.cxx
+++ b/Source/cmake.cxx
@@ -550,7 +550,7 @@ bool cmake::FindPackage(const std::vector<std::string>& args)
const char* targetName = "dummy";
std::vector<std::string> srcs;
cmTarget* tgt = mf->AddExecutable(targetName, srcs, true);
- tgt->SetProperty("LINKER_LANGUAGE", language.c_str());
+ tgt->SetProperty("LINKER_LANGUAGE", language);
std::string libs = mf->GetSafeDefinition("PACKAGE_LIBRARIES");
std::vector<std::string> libList = cmExpandedList(libs);
diff --git a/Tests/Cuda/CMakeLists.txt b/Tests/Cuda/CMakeLists.txt
index 3b6a611..35b9022 100644
--- a/Tests/Cuda/CMakeLists.txt
+++ b/Tests/Cuda/CMakeLists.txt
@@ -9,7 +9,8 @@ ADD_TEST_MACRO(Cuda.MixedStandardLevels3 MixedStandardLevels3)
ADD_TEST_MACRO(Cuda.MixedStandardLevels4 MixedStandardLevels4)
ADD_TEST_MACRO(Cuda.MixedStandardLevels5 MixedStandardLevels5)
ADD_TEST_MACRO(Cuda.NotEnabled CudaNotEnabled)
-ADD_TEST_MACRO(Cuda.ToolkitInclude CudaToolkitInclude)
+ADD_TEST_MACRO(Cuda.Toolkit Toolkit)
+ADD_TEST_MACRO(Cuda.IncludePathNoToolkit IncludePathNoToolkit)
ADD_TEST_MACRO(Cuda.ProperDeviceLibraries ProperDeviceLibraries)
ADD_TEST_MACRO(Cuda.ProperLinkFlags ProperLinkFlags)
ADD_TEST_MACRO(Cuda.WithC CudaWithC)
diff --git a/Tests/Cuda/ToolkitInclude/CMakeLists.txt b/Tests/Cuda/IncludePathNoToolkit/CMakeLists.txt
index f246b54..7be1561 100644
--- a/Tests/Cuda/ToolkitInclude/CMakeLists.txt
+++ b/Tests/Cuda/IncludePathNoToolkit/CMakeLists.txt
@@ -1,11 +1,11 @@
cmake_minimum_required(VERSION 3.8)
-project (ToolkitInclude CXX CUDA)
+project (IncludePathNoToolkit CXX CUDA)
#Goal for this example:
# Validate that between the CXX implicit include directories and the
# CMAKE_CUDA_TOOLKIT_INCLUDE_DIRECTORIES directories we can find
# the cuda runtime headers
-add_executable(CudaToolkitInclude main.cpp)
-target_include_directories(CudaToolkitInclude PRIVATE
+add_executable(IncludePathNoToolkit main.cpp)
+target_include_directories(IncludePathNoToolkit PRIVATE
${CMAKE_CUDA_TOOLKIT_INCLUDE_DIRECTORIES})
diff --git a/Tests/Cuda/ToolkitInclude/main.cpp b/Tests/Cuda/IncludePathNoToolkit/main.cpp
index c8d5c6b..c8d5c6b 100644
--- a/Tests/Cuda/ToolkitInclude/main.cpp
+++ b/Tests/Cuda/IncludePathNoToolkit/main.cpp
diff --git a/Tests/Cuda/Toolkit/CMakeLists.txt b/Tests/Cuda/Toolkit/CMakeLists.txt
new file mode 100644
index 0000000..86b4652
--- /dev/null
+++ b/Tests/Cuda/Toolkit/CMakeLists.txt
@@ -0,0 +1,38 @@
+cmake_minimum_required(VERSION 3.15)
+project(Toolkit CXX)
+
+#Goal for this example:
+# Validate that we can use CUDAToolkit to find cuda include paths
+find_package(CUDAToolkit REQUIRED)
+
+message(STATUS "CUDAToolkit_VERSION: ${CUDAToolkit_VERSION}")
+message(STATUS "CUDAToolkit_VERSION_MAJOR: ${CUDAToolkit_VERSION_MAJOR}")
+message(STATUS "CUDAToolkit_VERSION_MINOR: ${CUDAToolkit_VERSION_MINOR}")
+message(STATUS "CUDAToolkit_VERSION_PATCH: ${CUDAToolkit_VERSION_PATCH}")
+message(STATUS "CUDAToolkit_BIN_DIR: ${CUDAToolkit_BIN_DIR}")
+message(STATUS "CUDAToolkit_INCLUDE_DIRS: ${CUDAToolkit_INCLUDE_DIRS}")
+message(STATUS "CUDAToolkit_LIBRARY_DIR: ${CUDAToolkit_LIBRARY_DIR}")
+message(STATUS "CUDAToolkit_NVCC_EXECUTABLE ${CUDAToolkit_NVCC_EXECUTABLE}")
+
+# Verify that all the CUDA:: targets exist even when the CUDA language isn't enabled
+
+foreach (cuda_lib cudart cuda_driver cublas cufft cufftw curand cusolver cusparse nvgraph)
+ if(NOT TARGET CUDA::${cuda_lib})
+ message(FATAL_ERROR "The CUDA::${cuda_lib} target was expected but couldn't be found")
+ endif()
+endforeach()
+
+foreach (cuda_lib nppc nppial nppicc nppidei nppif nppig nppim nppist nppitc npps nppicom nppisu)
+ if(NOT TARGET CUDA::${cuda_lib})
+ message(FATAL_ERROR "The CUDA::${cuda_lib} target was expected but couldn't be found")
+ endif()
+endforeach()
+
+foreach (cuda_lib nvrtc nvToolsExt OpenCL)
+ if(NOT TARGET CUDA::${cuda_lib})
+ message(FATAL_ERROR "The CUDA::${cuda_lib} target was expected but couldn't be found")
+ endif()
+endforeach()
+
+add_executable(Toolkit main.cpp)
+target_link_libraries(Toolkit PRIVATE CUDA::toolkit)
diff --git a/Tests/Cuda/Toolkit/main.cpp b/Tests/Cuda/Toolkit/main.cpp
new file mode 100644
index 0000000..c8d5c6b
--- /dev/null
+++ b/Tests/Cuda/Toolkit/main.cpp
@@ -0,0 +1,8 @@
+// Only thing we care about is that these headers are found
+#include <cuda.h>
+#include <cuda_runtime_api.h>
+
+int main()
+{
+ return 0;
+}
diff --git a/Tests/CudaOnly/CMakeLists.txt b/Tests/CudaOnly/CMakeLists.txt
index 0dd3309..a0575cd 100644
--- a/Tests/CudaOnly/CMakeLists.txt
+++ b/Tests/CudaOnly/CMakeLists.txt
@@ -6,6 +6,7 @@ ADD_TEST_MACRO(CudaOnly.GPUDebugFlag CudaOnlyGPUDebugFlag)
ADD_TEST_MACRO(CudaOnly.ResolveDeviceSymbols CudaOnlyResolveDeviceSymbols)
ADD_TEST_MACRO(CudaOnly.SeparateCompilation CudaOnlySeparateCompilation)
ADD_TEST_MACRO(CudaOnly.Standard98 CudaOnlyStandard98)
+ADD_TEST_MACRO(CudaOnly.Toolkit CudaOnlyToolkit)
ADD_TEST_MACRO(CudaOnly.WithDefs CudaOnlyWithDefs)
add_test(NAME CudaOnly.DontResolveDeviceSymbols COMMAND
diff --git a/Tests/CudaOnly/Toolkit/CMakeLists.txt b/Tests/CudaOnly/Toolkit/CMakeLists.txt
new file mode 100644
index 0000000..0d5d574
--- /dev/null
+++ b/Tests/CudaOnly/Toolkit/CMakeLists.txt
@@ -0,0 +1,44 @@
+cmake_minimum_required(VERSION 3.15)
+project(CudaOnlyToolkit CUDA)
+find_package(CUDAToolkit REQUIRED)
+
+message(STATUS "CUDAToolkit_VERSION: ${CUDAToolkit_VERSION}")
+message(STATUS "CUDAToolkit_VERSION_MAJOR: ${CUDAToolkit_VERSION_MAJOR}")
+message(STATUS "CUDAToolkit_VERSION_MINOR: ${CUDAToolkit_VERSION_MINOR}")
+message(STATUS "CUDAToolkit_VERSION_PATCH: ${CUDAToolkit_VERSION_PATCH}")
+message(STATUS "CUDAToolkit_BIN_DIR: ${CUDAToolkit_BIN_DIR}")
+message(STATUS "CUDAToolkit_INCLUDE_DIRS: ${CUDAToolkit_INCLUDE_DIRS}")
+message(STATUS "CUDAToolkit_LIBRARY_DIR: ${CUDAToolkit_LIBRARY_DIR}")
+message(STATUS "CUDAToolkit_NVCC_EXECUTABLE ${CUDAToolkit_NVCC_EXECUTABLE}")
+
+# Verify that all the CUDA:: targets and variables exist
+foreach (cuda_lib cudart cuda_driver cublas cufft cufftw curand cusolver cusparse nvgraph)
+ if(NOT CUDA_${cuda_lib}_LIBRARY)
+ message(FATAL_ERROR "expected CUDAToolkit variable CUDA_${cuda_lib}_LIBRARY not found")
+ endif()
+ if(NOT TARGET CUDA::${cuda_lib})
+ message(FATAL_ERROR "expected CUDAToolkit target CUDA::${cuda_lib} not found")
+ endif()
+endforeach()
+
+foreach (cuda_lib nppc nppial nppicc nppidei nppif nppig nppim nppist nppitc npps nppicom nppisu)
+ if(NOT CUDA_${cuda_lib}_LIBRARY)
+ message(FATAL_ERROR "expected CUDAToolkit variable CUDA_${cuda_lib}_LIBRARY not found")
+ endif()
+ if(NOT TARGET CUDA::${cuda_lib})
+ message(FATAL_ERROR "expected CUDAToolkit target CUDA::${cuda_lib} not found")
+ endif()
+endforeach()
+
+foreach (cuda_lib nvrtc nvToolsExt OpenCL)
+ if(NOT CUDA_${cuda_lib}_LIBRARY)
+ message(FATAL_ERROR "expected CUDAToolkit variable CUDA_${cuda_lib}_LIBRARY not found")
+ endif()
+
+ if(NOT TARGET CUDA::${cuda_lib})
+ message(FATAL_ERROR "expected CUDAToolkit target CUDA::${cuda_lib} not found")
+ endif()
+endforeach()
+
+add_executable(CudaOnlyToolkit main.cu)
+target_link_libraries(CudaOnlyToolkit PRIVATE CUDA::toolkit)
diff --git a/Tests/CudaOnly/Toolkit/main.cu b/Tests/CudaOnly/Toolkit/main.cu
new file mode 100644
index 0000000..0f3ccdc
--- /dev/null
+++ b/Tests/CudaOnly/Toolkit/main.cu
@@ -0,0 +1,8 @@
+// Only thing we care about is that these headers are found
+#include <cuda.h>
+#include <cuda_runtime_api.h>
+
+int main(int argc, char** argv)
+{
+ return 0;
+}
diff --git a/Tests/RunCMake/VS10Project/RunCMakeTest.cmake b/Tests/RunCMake/VS10Project/RunCMakeTest.cmake
index 1487161..5cbe333 100644
--- a/Tests/RunCMake/VS10Project/RunCMakeTest.cmake
+++ b/Tests/RunCMake/VS10Project/RunCMakeTest.cmake
@@ -1,3 +1,5 @@
+cmake_policy(SET CMP0057 NEW)
+
include(RunCMake)
cmake_policy(SET CMP0054 NEW)
@@ -29,6 +31,8 @@ run_cmake(VsDpiAwareBadParam)
run_cmake(VsPrecompileHeaders)
run_cmake(VsPrecompileHeadersReuseFromCompilePDBName)
+run_cmake(VsWinRTByDefault)
+
set(RunCMake_GENERATOR_TOOLSET "VCTargetsPath=$(VCTargetsPath)")
run_cmake(VsVCTargetsPath)
unset(RunCMake_GENERATOR_TOOLSET)
diff --git a/Tests/RunCMake/VS10Project/VsWinRTByDefault-check.cmake b/Tests/RunCMake/VS10Project/VsWinRTByDefault-check.cmake
new file mode 100644
index 0000000..15bbaf2
--- /dev/null
+++ b/Tests/RunCMake/VS10Project/VsWinRTByDefault-check.cmake
@@ -0,0 +1,66 @@
+macro(checkCompileAsWinRT projectPath)
+ if(RunCMake_TEST_FAILED)
+ return()
+ endif()
+
+ if (NOT EXISTS "${projectPath}")
+ set(RunCMake_TEST_FAILED "Project file ${projectPath} does not exist.")
+ return()
+ endif()
+
+ get_filename_component(projectName "${projectPath}" NAME_WE)
+
+ cmake_parse_arguments("" "" "GLOBAL" "OVERRIDES_ENABLE;OVERRIDES_DISABLE" ${ARGN})
+
+ unset(sourceOverride)
+
+ file(STRINGS "${projectPath}" lines)
+ set(foundGlobalWinRT false)
+
+ foreach(line IN LISTS lines)
+ if(line MATCHES "^ *<CompileAsWinRT( Condition=\"[^\\\"]+\")?>(true|false)</CompileAsWinRT>$")
+ set(value ${CMAKE_MATCH_2})
+
+ if(sourceOverride)
+ set(expectedList)
+
+ if(value)
+ set(expectedList _OVERRIDES_ENABLE)
+ else()
+ set(expectedList _OVERRIDES_DISABLE)
+ endif()
+
+ if(NOT sourceOverride IN_LIST ${expectedList})
+ set(RunCMake_TEST_FAILED
+ "${projectName}: Unexpected CompileAsWinRT override ${value} for ${sourceOverride}")
+ return()
+ endif()
+ else()
+ if (NOT _GLOBAL STREQUAL value)
+ set(RunCMake_TEST_FAILED
+ "${projectName}: Global CompileAsWinRT value is ${value}, but expected ${_GLOBAL}")
+ return()
+ endif()
+
+ set(foundGlobalWinRT true)
+ endif()
+ elseif(line MATCHES "^ *<ClCompile Include=\"([^\"]+)\">$")
+ get_filename_component(sourceOverride "${CMAKE_MATCH_1}" NAME)
+ elseif(line MATCHES "^ *</ClCompile>$")
+ unset(sourceOverride)
+ endif()
+ endforeach()
+
+ if(NOT foundGlobalWinRT AND DEFINED _GLOBAL)
+ set(RunCMake_TEST_FAILED "${projectName}: Global CompileAsWinRT not found or have invalid value, but expected")
+ return()
+ endif()
+endmacro()
+
+checkCompileAsWinRT("${RunCMake_TEST_BINARY_DIR}/noFlagOnlyC.vcxproj" GLOBAL false)
+checkCompileAsWinRT("${RunCMake_TEST_BINARY_DIR}/noFlagMixedCAndCxx.vcxproj" GLOBAL false)
+checkCompileAsWinRT("${RunCMake_TEST_BINARY_DIR}/noFlagOnlyCxx.vcxproj" GLOBAL false)
+
+checkCompileAsWinRT("${RunCMake_TEST_BINARY_DIR}/flagOnlyC.vcxproj" GLOBAL true OVERRIDES_DISABLE empty.c)
+checkCompileAsWinRT("${RunCMake_TEST_BINARY_DIR}/flagMixedCAndCxx.vcxproj" GLOBAL true OVERRIDES_DISABLE empty.c)
+checkCompileAsWinRT("${RunCMake_TEST_BINARY_DIR}/flagOnlyCxx.vcxproj" GLOBAL true)
diff --git a/Tests/RunCMake/VS10Project/VsWinRTByDefault.cmake b/Tests/RunCMake/VS10Project/VsWinRTByDefault.cmake
new file mode 100644
index 0000000..139048b
--- /dev/null
+++ b/Tests/RunCMake/VS10Project/VsWinRTByDefault.cmake
@@ -0,0 +1,16 @@
+set(CMAKE_VS_WINRT_BY_DEFAULT true)
+
+enable_language(C)
+enable_language(CXX)
+
+add_library(noFlagOnlyC empty.c)
+add_library(noFlagMixedCAndCXX empty.c foo.cpp)
+add_library(noFlagOnlyCXX foo.cpp)
+
+add_library(flagOnlyC empty.c)
+add_library(flagMixedCAndCXX empty.c foo.cpp)
+add_library(flagOnlyCXX foo.cpp)
+
+target_compile_options(flagOnlyC PRIVATE /ZW)
+target_compile_options(flagMixedCAndCXX PRIVATE /ZW)
+target_compile_options(flagOnlyCXX PRIVATE /ZW)