diff options
89 files changed, 877 insertions, 139 deletions
diff --git a/.gitlab/os-linux.yml b/.gitlab/os-linux.yml index 669d437..30b4fc3 100644 --- a/.gitlab/os-linux.yml +++ b/.gitlab/os-linux.yml @@ -227,6 +227,7 @@ GIT_CLONE_PATH: "$CI_BUILDS_DIR/cmake ci" CMAKE_ARCH: x86_64 CTEST_LABELS: "CUDA" + CMAKE_CUDA_ARCHITECTURES_NATIVE_CLAMP: 1 .cuda9.2_nvidia: extends: .cuda9.2 @@ -242,6 +243,7 @@ GIT_CLONE_PATH: "$CI_BUILDS_DIR/cmake ci" CMAKE_ARCH: x86_64 CTEST_LABELS: "CUDA" + CMAKE_CUDA_ARCHITECTURES_NATIVE_CLAMP: 1 .cuda10.2_nvidia: extends: .cuda10.2 @@ -264,6 +266,7 @@ GIT_CLONE_PATH: "$CI_BUILDS_DIR/cmake ci" CMAKE_ARCH: x86_64 CTEST_LABELS: "CUDA" + CMAKE_CUDA_ARCHITECTURES_NATIVE_CLAMP: 1 .cuda11.6_nvidia: extends: .cuda11.6 diff --git a/Help/command/FIND_XXX.txt b/Help/command/FIND_XXX.txt index 5b63e1c..ee6c1cc 100644 --- a/Help/command/FIND_XXX.txt +++ b/Help/command/FIND_XXX.txt @@ -170,6 +170,11 @@ If ``NO_DEFAULT_PATH`` is not specified, the search process is as follows: or in the short-hand version of the command. These are typically hard-coded guesses. +The :variable:`CMAKE_IGNORE_PATH`, :variable:`CMAKE_IGNORE_PREFIX_PATH`, +:variable:`CMAKE_SYSTEM_IGNORE_PATH` and +:variable:`CMAKE_SYSTEM_IGNORE_PREFIX_PATH` variables can also cause some +of the above locations to be ignored. + .. versionadded:: 3.16 Added ``CMAKE_FIND_USE_<CATEGORY>_PATH`` variables to globally disable various search locations. diff --git a/Help/command/find_package.rst b/Help/command/find_package.rst index 1a79a8a..e43b7bd 100644 --- a/Help/command/find_package.rst +++ b/Help/command/find_package.rst @@ -79,7 +79,8 @@ Basic Signature find_package(<PackageName> [version] [EXACT] [QUIET] [MODULE] [REQUIRED] [[COMPONENTS] [components...]] [OPTIONAL_COMPONENTS components...] - [NO_POLICY_SCOPE]) + [NO_POLICY_SCOPE] + [GLOBAL]) The basic signature is supported by both Module and Config modes. The ``MODULE`` keyword implies that only Module mode can be used to find @@ -115,6 +116,11 @@ define what occurs in such cases. Common arrangements include assuming it should find all components, no components or some well-defined subset of the available components. +Specifying the ``GLOBAL`` keyword will promote all imported targets to +a global scope in the importing project. Alternatively this functionality +can be enabled by setting the variable +:variable:`CMAKE_FIND_PACKAGE_TARGETS_GLOBAL` + .. _FIND_PACKAGE_VERSION_FORMAT: The ``[version]`` argument requests a version with which the package found @@ -363,6 +369,11 @@ enabled. 9. Search paths specified by the ``PATHS`` option. These are typically hard-coded guesses. +The :variable:`CMAKE_IGNORE_PATH`, :variable:`CMAKE_IGNORE_PREFIX_PATH`, +:variable:`CMAKE_SYSTEM_IGNORE_PATH` and +:variable:`CMAKE_SYSTEM_IGNORE_PREFIX_PATH` variables can also cause some +of the above locations to be ignored. + .. versionadded:: 3.16 Added the ``CMAKE_FIND_USE_<CATEGORY>`` variables to globally disable various search locations. diff --git a/Help/manual/cmake-language.7.rst b/Help/manual/cmake-language.7.rst index b7f0861..e7d2694 100644 --- a/Help/manual/cmake-language.7.rst +++ b/Help/manual/cmake-language.7.rst @@ -627,3 +627,45 @@ in list elements, thus flattening nested lists: .. code-block:: cmake set(x a "b;c") # sets "x" to "a;b;c", not "a;b\;c" + +In general, lists do not support elements containing ``;`` characters. +To avoid problems, consider the following advice: + +* The interfaces of many CMake commands, variables, and properties accept + semicolon-separated lists. Avoid passing lists with elements containing + semicolons to these interfaces unless they document either direct support + or some way to escape or encode semicolons. + +* When constructing a list, substitute an otherwise-unused placeholder + for ``;`` in elements when. Then substitute ``;`` for the placeholder + when processing list elements. + For example, the following code uses ``|`` in place of ``;`` characters: + + .. code-block:: cmake + + set(mylist a "b|c") + foreach(entry IN LISTS mylist) + string(REPLACE "|" ";" entry "${entry}") + # use "${entry}" normally + endforeach() + + The :module:`ExternalProject` module's ``LIST_SEPARATOR`` option is an + example of an interface built using this approach. + +* In lists of :manual:`generator expressions <cmake-generator-expressions(7)>`, + use the :genex:`$<SEMICOLON>` generator expression. + +* In command calls, use `Quoted Argument`_ syntax whenever possible. + The called command will receive the content of the argument with + semicolons preserved. An `Unquoted Argument`_ will be split on + semicolons. + +* In :command:`function` implementations, avoid ``ARGV`` and ``ARGN``, + which do not distinguish semicolons in values from those separating values. + Instead, prefer using named positional arguments and the ``ARGC`` and + ``ARGV#`` variables. + When using :command:`cmake_parse_arguments` to parse arguments, prefer + its ``PARSE_ARGV`` signature, which uses the ``ARGV#`` variables. + + Note that this approach does not apply to :command:`macro` implementations + because they reference arguments using placeholders, not real variables. diff --git a/Help/manual/cmake-variables.7.rst b/Help/manual/cmake-variables.7.rst index da892dd..8d20ae2 100644 --- a/Help/manual/cmake-variables.7.rst +++ b/Help/manual/cmake-variables.7.rst @@ -198,6 +198,7 @@ Variables that Change Behavior /variable/CMAKE_FIND_PACKAGE_NO_SYSTEM_PACKAGE_REGISTRY /variable/CMAKE_FIND_PACKAGE_PREFER_CONFIG /variable/CMAKE_FIND_PACKAGE_RESOLVE_SYMLINKS + /variable/CMAKE_FIND_PACKAGE_TARGETS_GLOBAL /variable/CMAKE_FIND_PACKAGE_WARN_NO_MODULE /variable/CMAKE_FIND_ROOT_PATH /variable/CMAKE_FIND_ROOT_PATH_MODE_INCLUDE diff --git a/Help/manual/cmake.1.rst b/Help/manual/cmake.1.rst index 3c4e76a..e93cbe5 100644 --- a/Help/manual/cmake.1.rst +++ b/Help/manual/cmake.1.rst @@ -151,6 +151,33 @@ source and build trees and generate a buildsystem: In all cases the ``<options>`` may be zero or more of the `Options`_ below. +The above styles for specifying the source and build trees may be mixed. +Paths specified with ``-S`` or ``-B`` are always classified as source or +build trees, respectively. Paths specified with plain arguments are +classified based on their content and the types of paths given earlier. +If only one type of path is given, the current working directory (cwd) +is used for the other. For example: + +============================== ============ =========== + Command Line Source Dir Build Dir +============================== ============ =========== + ``cmake src`` ``src`` `cwd` + ``cmake build`` (existing) `loaded` ``build`` + ``cmake -S src`` ``src`` `cwd` + ``cmake -S src build`` ``src`` ``build`` + ``cmake -S src -B build`` ``src`` ``build`` + ``cmake -B build`` `cwd` ``build`` + ``cmake -B build src`` ``src`` ``build`` + ``cmake -B build -S src`` ``src`` ``build`` +============================== ============ =========== + +.. versionchanged:: 3.23 + + CMake warns when multiple source paths are specified. This has never + been officially documented or supported, but older versions accidentally + accepted multiple source paths and used the last path specified. + Avoid passing multiple source path arguments. + After generating a buildsystem one may use the corresponding native build tool to build the project. For example, after using the :generator:`Unix Makefiles` generator one may run ``make`` directly: diff --git a/Help/prop_sf/LANGUAGE.rst b/Help/prop_sf/LANGUAGE.rst index a9b5638..92bd227 100644 --- a/Help/prop_sf/LANGUAGE.rst +++ b/Help/prop_sf/LANGUAGE.rst @@ -7,8 +7,8 @@ A property that can be set to indicate what programming language the source file is. If it is not set the language is determined based on the file extension. Typical values are ``CXX`` (i.e. C++), ``C``, ``CSharp``, ``CUDA``, ``Fortran``, ``HIP``, ``ISPC``, and ``ASM``. Setting -this property for a file means this file will be compiled. Do not set this -for headers or files that should not be compiled. +this property for a file means this file will be compiled, unless +:prop_sf:`HEADER_FILE_ONLY` is set. .. versionchanged:: 3.20 Setting this property causes the source file to be compiled as the diff --git a/Help/prop_test/ENVIRONMENT.rst b/Help/prop_test/ENVIRONMENT.rst index 43bcdbe..07b96bb 100644 --- a/Help/prop_test/ENVIRONMENT.rst +++ b/Help/prop_test/ENVIRONMENT.rst @@ -3,7 +3,7 @@ ENVIRONMENT Specify environment variables that should be defined for running a test. -If set to a list of environment variables and values of the form -``MYVAR=value`` those environment variables will be defined while running -the test. The environment changes from this property do not affect other -tests. +Set to a :ref:`semicolon-separated list <CMake Language Lists>` list +of environment variables and values of the form ``MYVAR=value``. +Those environment variables will be defined while running the test. +The environment changes from this property do not affect other tests. diff --git a/Help/prop_test/ENVIRONMENT_MODIFICATION.rst b/Help/prop_test/ENVIRONMENT_MODIFICATION.rst index 99ff512..ad3e190 100644 --- a/Help/prop_test/ENVIRONMENT_MODIFICATION.rst +++ b/Help/prop_test/ENVIRONMENT_MODIFICATION.rst @@ -7,10 +7,11 @@ Specify environment variables that should be modified for running a test. Note that the operations performed by this property are performed after the :prop_test:`ENVIRONMENT` property is already applied. -If set to a list of environment variables and values of the form -``MYVAR=OP:VALUE``, where ``MYVAR`` is the case-sensitive name of an -environment variable to be modified. Entries are considered in the -order specified in the property's value. The ``OP`` may be one of: +Set to a :ref:`semicolon-separated list <CMake Language Lists>` of +environment variables and values of the form ``MYVAR=OP:VALUE``, +where ``MYVAR`` is the case-sensitive name of an environment variable +to be modified. Entries are considered in the order specified in the +property's value. The ``OP`` may be one of: - ``reset``: Reset to the unmodified value, ignoring all modifications to ``MYVAR`` prior to this entry. Note that this will reset the variable to diff --git a/Help/prop_tgt/CUDA_ARCHITECTURES.rst b/Help/prop_tgt/CUDA_ARCHITECTURES.rst index 191f78f..05c2599 100644 --- a/Help/prop_tgt/CUDA_ARCHITECTURES.rst +++ b/Help/prop_tgt/CUDA_ARCHITECTURES.rst @@ -34,6 +34,11 @@ The ``CUDA_ARCHITECTURES`` may be set to one of the following special values: Compile for all supported major real architectures, and the highest major virtual architecture. +``native`` + .. versionadded:: 3.24 + + Compile for the architecture(s) of the host's GPU(s). + Examples ^^^^^^^^ diff --git a/Help/prop_tgt/LINK_LIBRARIES_ONLY_TARGETS.rst b/Help/prop_tgt/LINK_LIBRARIES_ONLY_TARGETS.rst index 78fbb02..a9af74d 100644 --- a/Help/prop_tgt/LINK_LIBRARIES_ONLY_TARGETS.rst +++ b/Help/prop_tgt/LINK_LIBRARIES_ONLY_TARGETS.rst @@ -20,17 +20,16 @@ This property is initialized by the value of the target is created. The property may be explicitly enabled on an imported target to check its link interface. -For example, the following code: +In the following example, CMake will halt with an error at configure time +because ``miLib`` is not a target: .. code-block:: cmake set(CMAKE_LINK_LIBRARIES_ONLY_TARGETS ON) - add_executable(myLib STATIC myLib.c) + add_library(myLib STATIC myLib.c) add_executable(myExe myExe.c) target_link_libraries(myExe PRIVATE miLib) # typo for myLib -will produce a CMake-time error that ``miLib`` is not a target. - In order to link toolchain-provided libraries by name while still enforcing ``LINK_LIBRARIES_ONLY_TARGETS``, use an :ref:`imported <Imported Targets>` diff --git a/Help/release/3.23.rst b/Help/release/3.23.rst index c3bee02..69b935d 100644 --- a/Help/release/3.23.rst +++ b/Help/release/3.23.rst @@ -225,6 +225,12 @@ CPack Deprecated and Removed Features =============================== +* :manual:`cmake(1)` now warns when multiple source paths are specified, + as in ``cmake -S src1 src2``. This has never been officially documented + or supported, but older versions accidentally accepted multiple source + paths and used the last path specified. Update scripts to avoid + passing multiple source path arguments. + * The :manual:`cpack(1)` undocumented ``OSXX11`` generator has been removed. Other Changes diff --git a/Help/release/dev/cuda-arch-native.rst b/Help/release/dev/cuda-arch-native.rst new file mode 100644 index 0000000..f44a668 --- /dev/null +++ b/Help/release/dev/cuda-arch-native.rst @@ -0,0 +1,7 @@ +cuda-arch-native +---------------- + +* The :variable:`CMAKE_CUDA_ARCHITECTURES` variable and associated + :prop_tgt:`CUDA_ARCHITECTURES` target property now support the + special ``native`` value to compile for the architectures(s) + of the host's GPU(s). diff --git a/Help/release/dev/find_package-global-imported.rst b/Help/release/dev/find_package-global-imported.rst new file mode 100644 index 0000000..b32d18d --- /dev/null +++ b/Help/release/dev/find_package-global-imported.rst @@ -0,0 +1,9 @@ +find_package-global-imported +---------------------------- + +* The :command:`find_package` command gained a `GLOBAL` option that + allows for the promotion of imported targets to global scope fur the + duration of the :command:`find_package` call. + +* Adds support for :variable:`CMAKE_FIND_PACKAGE_TARGETS_GLOBAL` to + toggle behavior of the :command:`find_package` command's new GLOBAL option diff --git a/Help/release/dev/findzlib-static.rst b/Help/release/dev/findzlib-static.rst new file mode 100644 index 0000000..35855f6 --- /dev/null +++ b/Help/release/dev/findzlib-static.rst @@ -0,0 +1,5 @@ +findzlib-static +--------------- + +* The :module:`FindZLIB` learned a new ``ZLIB_USE_STATIC_LIBS`` variable to + search only for static libraries. diff --git a/Help/variable/CMAKE_FIND_PACKAGE_TARGETS_GLOBAL.rst b/Help/variable/CMAKE_FIND_PACKAGE_TARGETS_GLOBAL.rst new file mode 100644 index 0000000..58efccf --- /dev/null +++ b/Help/variable/CMAKE_FIND_PACKAGE_TARGETS_GLOBAL.rst @@ -0,0 +1,10 @@ +CMAKE_FIND_PACKAGE_TARGETS_GLOBAL +--------------------------------- + +Setting to ``TRUE`` promotes all :prop_tgt:`IMPORTED` targets discoverd +by :command:`find_package` to a ``GLOBAL`` scope. + + +Setting this to ``TRUE`` is akin to specifying ``GLOBAL`` +as an argument to :command:`find_package`. +Default value is ``OFF``. diff --git a/Help/variable/CMAKE_IGNORE_PATH.rst b/Help/variable/CMAKE_IGNORE_PATH.rst index 4bca34b..4b2bd8a 100644 --- a/Help/variable/CMAKE_IGNORE_PATH.rst +++ b/Help/variable/CMAKE_IGNORE_PATH.rst @@ -1,18 +1,18 @@ CMAKE_IGNORE_PATH ----------------- -:ref:`Semicolon-separated list <CMake Language Lists>` of directories to be *ignored* by -the :command:`find_program`, :command:`find_library`, :command:`find_file`, -and :command:`find_path` commands. This is useful in cross-compiling -environments where some system directories contain incompatible but -possibly linkable libraries. For example, on cross-compiled cluster -environments, this allows a user to ignore directories containing -libraries meant for the front-end machine. +.. |CMAKE_IGNORE_VAR| replace:: ``CMAKE_IGNORE_PATH`` +.. |CMAKE_IGNORE_PREFIX_VAR| replace:: :variable:`CMAKE_IGNORE_PREFIX_PATH` -By default this is empty; it is intended to be set by the project. -Note that ``CMAKE_IGNORE_PATH`` takes a list of directory names, *not* -a list of prefixes. To ignore paths under prefixes (``bin``, ``include``, -``lib``, etc.), specify them explicitly. +.. include:: IGNORE_SEARCH_PATH.txt +.. include:: IGNORE_SEARCH_LOCATIONS.txt +.. include:: IGNORE_SEARCH_NONSYSTEM.txt -See also the :variable:`CMAKE_PREFIX_PATH`, :variable:`CMAKE_LIBRARY_PATH`, -:variable:`CMAKE_INCLUDE_PATH`, and :variable:`CMAKE_PROGRAM_PATH` variables. +See also the following variables: + +- :variable:`CMAKE_IGNORE_PREFIX_PATH` +- :variable:`CMAKE_SYSTEM_IGNORE_PATH` +- :variable:`CMAKE_PREFIX_PATH` +- :variable:`CMAKE_LIBRARY_PATH` +- :variable:`CMAKE_INCLUDE_PATH` +- :variable:`CMAKE_PROGRAM_PATH` diff --git a/Help/variable/CMAKE_IGNORE_PREFIX_PATH.rst b/Help/variable/CMAKE_IGNORE_PREFIX_PATH.rst index 317c771..b81cc57 100644 --- a/Help/variable/CMAKE_IGNORE_PREFIX_PATH.rst +++ b/Help/variable/CMAKE_IGNORE_PREFIX_PATH.rst @@ -3,17 +3,18 @@ CMAKE_IGNORE_PREFIX_PATH .. versionadded:: 3.23 -:ref:`Semicolon-separated list <CMake Language Lists>` of prefixes to be -*ignored* by the :command:`find_program`, :command:`find_library`, -:command:`find_file`, :command:`find_path`, and :command:`find_package` -commands. This is useful in cross-compiling environments where some -system directories contain incompatible but possibly linkable libraries. -For example, on cross-compiled cluster environments, this allows a user -to ignore directories containing libraries meant for the front-end machine. +.. |CMAKE_IGNORE_VAR| replace:: ``CMAKE_IGNORE_PREFIX_PATH`` +.. |CMAKE_IGNORE_NONPREFIX_VAR| replace:: :variable:`CMAKE_IGNORE_PATH` -By default this is empty; it is intended to be set by the project and/or -the end user. Note that ``CMAKE_IGNORE_PREFIX_PATH`` takes a list of -prefixes, *not* a list of directory names. +.. include:: IGNORE_SEARCH_PREFIX.txt +.. include:: IGNORE_SEARCH_LOCATIONS.txt +.. include:: IGNORE_SEARCH_NONSYSTEM.txt -See also the :variable:`CMAKE_PREFIX_PATH`, :variable:`CMAKE_LIBRARY_PATH`, -:variable:`CMAKE_INCLUDE_PATH`, and :variable:`CMAKE_PROGRAM_PATH` variables. +See also the following variables: + +- :variable:`CMAKE_IGNORE_PATH` +- :variable:`CMAKE_SYSTEM_IGNORE_PREFIX_PATH` +- :variable:`CMAKE_PREFIX_PATH` +- :variable:`CMAKE_LIBRARY_PATH` +- :variable:`CMAKE_INCLUDE_PATH` +- :variable:`CMAKE_PROGRAM_PATH` diff --git a/Help/variable/CMAKE_SYSTEM_IGNORE_PATH.rst b/Help/variable/CMAKE_SYSTEM_IGNORE_PATH.rst index 6afbd33..a6d8016 100644 --- a/Help/variable/CMAKE_SYSTEM_IGNORE_PATH.rst +++ b/Help/variable/CMAKE_SYSTEM_IGNORE_PATH.rst @@ -1,18 +1,18 @@ CMAKE_SYSTEM_IGNORE_PATH ------------------------ -:ref:`Semicolon-separated list <CMake Language Lists>` of directories to be *ignored* by -the :command:`find_program`, :command:`find_library`, :command:`find_file`, -and :command:`find_path` commands. This is useful in cross-compiling -environments where some system directories contain incompatible but -possibly linkable libraries. For example, on cross-compiled cluster -environments, this allows a user to ignore directories containing -libraries meant for the front-end machine. +.. |CMAKE_IGNORE_VAR| replace:: ``CMAKE_SYSTEM_IGNORE_PATH`` +.. |CMAKE_IGNORE_PREFIX_VAR| replace:: :variable:`CMAKE_SYSTEM_IGNORE_PREFIX_PATH` +.. |CMAKE_IGNORE_NONSYSTEM_VAR| replace:: :variable:`CMAKE_IGNORE_PATH` -By default this contains a list of directories containing incompatible -binaries for the host system. See the :variable:`CMAKE_IGNORE_PATH` variable -that is intended to be set by the project. +.. include:: IGNORE_SEARCH_PATH.txt +.. include:: IGNORE_SEARCH_LOCATIONS.txt +.. include:: IGNORE_SEARCH_SYSTEM.txt -See also the :variable:`CMAKE_SYSTEM_PREFIX_PATH`, -:variable:`CMAKE_SYSTEM_LIBRARY_PATH`, :variable:`CMAKE_SYSTEM_INCLUDE_PATH`, -and :variable:`CMAKE_SYSTEM_PROGRAM_PATH` variables. +See also the following variables: + +- :variable:`CMAKE_SYSTEM_IGNORE_PREFIX_PATH` +- :variable:`CMAKE_SYSTEM_PREFIX_PATH` +- :variable:`CMAKE_SYSTEM_LIBRARY_PATH` +- :variable:`CMAKE_SYSTEM_INCLUDE_PATH` +- :variable:`CMAKE_SYSTEM_PROGRAM_PATH` diff --git a/Help/variable/CMAKE_SYSTEM_IGNORE_PREFIX_PATH.rst b/Help/variable/CMAKE_SYSTEM_IGNORE_PREFIX_PATH.rst index ce52f5a..48a2994 100644 --- a/Help/variable/CMAKE_SYSTEM_IGNORE_PREFIX_PATH.rst +++ b/Help/variable/CMAKE_SYSTEM_IGNORE_PREFIX_PATH.rst @@ -3,18 +3,18 @@ CMAKE_SYSTEM_IGNORE_PREFIX_PATH .. versionadded:: 3.23 -:ref:`Semicolon-separated list <CMake Language Lists>` of prefixes to be -*ignored* by the :command:`find_program`, :command:`find_library`, -:command:`find_file`, :command:`find_path`, and :command:`find_package` -commands. This is useful in cross-compiling environments where some -system directories contain incompatible but possibly linkable libraries. -For example, on cross-compiled cluster environments, this allows a user -to ignore directories containing libraries meant for the front-end machine. +.. |CMAKE_IGNORE_VAR| replace:: ``CMAKE_SYSTEM_IGNORE_PREFIX_PATH`` +.. |CMAKE_IGNORE_NONPREFIX_VAR| replace:: :variable:`CMAKE_SYSTEM_IGNORE_PATH` +.. |CMAKE_IGNORE_NONSYSTEM_VAR| replace:: :variable:`CMAKE_IGNORE_PREFIX_PATH` -By default this contains a list of directories containing incompatible -binaries for the host system. See the :variable:`CMAKE_IGNORE_PREFIX_PATH` -variable that is intended to be set by the project and/or the end user. +.. include:: IGNORE_SEARCH_PREFIX.txt +.. include:: IGNORE_SEARCH_LOCATIONS.txt +.. include:: IGNORE_SEARCH_SYSTEM.txt -See also the :variable:`CMAKE_SYSTEM_PREFIX_PATH`, -:variable:`CMAKE_SYSTEM_LIBRARY_PATH`, :variable:`CMAKE_SYSTEM_INCLUDE_PATH`, -and :variable:`CMAKE_SYSTEM_PROGRAM_PATH` variables. +See also the following variables: + +- :variable:`CMAKE_SYSTEM_IGNORE_PATH` +- :variable:`CMAKE_SYSTEM_PREFIX_PATH` +- :variable:`CMAKE_SYSTEM_LIBRARY_PATH` +- :variable:`CMAKE_SYSTEM_INCLUDE_PATH` +- :variable:`CMAKE_SYSTEM_PROGRAM_PATH` diff --git a/Help/variable/IGNORE_SEARCH_LOCATIONS.txt b/Help/variable/IGNORE_SEARCH_LOCATIONS.txt new file mode 100644 index 0000000..a98f359 --- /dev/null +++ b/Help/variable/IGNORE_SEARCH_LOCATIONS.txt @@ -0,0 +1,4 @@ +Ignoring search locations can be useful in cross-compiling environments where +some system directories contain incompatible but possibly linkable libraries. +For example, on cross-compiled cluster environments, this allows a user to +ignore directories containing libraries meant for the front-end machine. diff --git a/Help/variable/IGNORE_SEARCH_NONSYSTEM.txt b/Help/variable/IGNORE_SEARCH_NONSYSTEM.txt new file mode 100644 index 0000000..a32a189 --- /dev/null +++ b/Help/variable/IGNORE_SEARCH_NONSYSTEM.txt @@ -0,0 +1,2 @@ +By default, |CMAKE_IGNORE_VAR| is empty. It is intended to be set by the +project or the end user. diff --git a/Help/variable/IGNORE_SEARCH_PATH.txt b/Help/variable/IGNORE_SEARCH_PATH.txt new file mode 100644 index 0000000..0811e02 --- /dev/null +++ b/Help/variable/IGNORE_SEARCH_PATH.txt @@ -0,0 +1,19 @@ +:ref:`Semicolon-separated list <CMake Language Lists>` of directories +to be ignored by the various ``find...()`` commands. + +For :command:`find_program`, :command:`find_library`, :command:`find_file`, +and :command:`find_path`, any file found in one of the listed directories +will be ignored. The listed directories do not apply recursively, so any +subdirectories to be ignored must also be explicitly listed. +|CMAKE_IGNORE_VAR| does not affect the search *prefixes* used by these +four commands. To ignore individual paths under a search prefix +(e.g. ``bin``, ``include``, ``lib``, etc.), each path must be listed in +|CMAKE_IGNORE_VAR| as a full absolute path. |CMAKE_IGNORE_PREFIX_VAR| +provides a more appropriate way to ignore a whole search prefix. + +:command:`find_package` is also affected by |CMAKE_IGNORE_VAR|, but only +for *Config mode* searches. Any ``<Name>Config.cmake`` or +``<name>-config.cmake`` file found in one of the specified directories +will be ignored. In addition, any search *prefix* found in |CMAKE_IGNORE_VAR| +will be skipped for backward compatibility reasons, but new code should +prefer to use |CMAKE_IGNORE_PREFIX_VAR| to ignore prefixes instead. diff --git a/Help/variable/IGNORE_SEARCH_PREFIX.txt b/Help/variable/IGNORE_SEARCH_PREFIX.txt new file mode 100644 index 0000000..f5ec3dc --- /dev/null +++ b/Help/variable/IGNORE_SEARCH_PREFIX.txt @@ -0,0 +1,6 @@ +:ref:`Semicolon-separated list <CMake Language Lists>` of search *prefixes* +to be ignored by the :command:`find_program`, :command:`find_library`, +:command:`find_file`, and :command:`find_path` commands. +The prefixes are also ignored by the *Config mode* of the +:command:`find_package` command (*Module mode* is unaffected). +To ignore specific directories instead, see |CMAKE_IGNORE_NONPREFIX_VAR|. diff --git a/Help/variable/IGNORE_SEARCH_SYSTEM.txt b/Help/variable/IGNORE_SEARCH_SYSTEM.txt new file mode 100644 index 0000000..78b285d6 --- /dev/null +++ b/Help/variable/IGNORE_SEARCH_SYSTEM.txt @@ -0,0 +1,5 @@ +|CMAKE_IGNORE_VAR| is populated by CMake as part of its platform +and toolchain setup. Its purpose is to ignore locations containing +incompatible binaries meant for the host rather than the target platform. +The project or end user should not modify this variable, they should use +|CMAKE_IGNORE_NONSYSTEM_VAR| instead. diff --git a/Modules/CMakeCUDACompiler.cmake.in b/Modules/CMakeCUDACompiler.cmake.in index 9f2e213..57d595a 100644 --- a/Modules/CMakeCUDACompiler.cmake.in +++ b/Modules/CMakeCUDACompiler.cmake.in @@ -55,6 +55,7 @@ set(CMAKE_CUDA_COMPILER_LIBRARY_ROOT "@CMAKE_CUDA_COMPILER_LIBRARY_ROOT@") set(CMAKE_CUDA_ARCHITECTURES_ALL "@CMAKE_CUDA_ARCHITECTURES_ALL@") set(CMAKE_CUDA_ARCHITECTURES_ALL_MAJOR "@CMAKE_CUDA_ARCHITECTURES_ALL_MAJOR@") +set(CMAKE_CUDA_ARCHITECTURES_NATIVE "@CMAKE_CUDA_ARCHITECTURES_NATIVE@") set(CMAKE_CUDA_TOOLKIT_INCLUDE_DIRECTORIES "@CMAKE_CUDA_TOOLKIT_INCLUDE_DIRECTORIES@") diff --git a/Modules/CMakeCUDACompilerABI.cu b/Modules/CMakeCUDACompilerABI.cu index 449a079..8463e86 100644 --- a/Modules/CMakeCUDACompilerABI.cu +++ b/Modules/CMakeCUDACompilerABI.cu @@ -2,6 +2,10 @@ # error "A C or C++ compiler has been selected for CUDA" #endif +#include <cstdio> + +#include <cuda_runtime.h> + #include "CMakeCompilerABI.h" int main(int argc, char* argv[]) @@ -13,6 +17,31 @@ int main(int argc, char* argv[]) #if defined(ABI_ID) require += info_abi[argc]; #endif - (void)argv; - return require; + static_cast<void>(argv); + + int count = 0; + if (cudaGetDeviceCount(&count) != cudaSuccess || count == 0) { + std::fprintf(stderr, "No CUDA devices found.\n"); + return -1; + } + + int found = 0; + const char* sep = ""; + for (int device = 0; device < count; ++device) { + cudaDeviceProp prop; + if (cudaGetDeviceProperties(&prop, device) == cudaSuccess) { + std::printf("%s%d%d", sep, prop.major, prop.minor); + sep = ";"; + found = 1; + } + } + + if (!found) { + std::fprintf(stderr, "No CUDA architecture detected from any devices.\n"); + // Convince the compiler that the non-zero return value depends + // on the info strings so they are not optimized out. + return require ? -1 : 1; + } + + return 0; } diff --git a/Modules/CMakeDetermineCUDACompiler.cmake b/Modules/CMakeDetermineCUDACompiler.cmake index 2649441..f68c4b2 100644 --- a/Modules/CMakeDetermineCUDACompiler.cmake +++ b/Modules/CMakeDetermineCUDACompiler.cmake @@ -249,7 +249,8 @@ if(NOT CMAKE_CUDA_COMPILER_ID_RUN) set(CMAKE_CUDA_COMPILER_TOOLKIT_VERSION "${CMAKE_MATCH_1}") endif() - # Make the all and all-major architecture information available. + # Make the all, all-major, and native architecture information available. + # FIXME(#23161): Defer architecture detection until compiler testing. include(${CMAKE_ROOT}/Modules/CUDA/architectures.cmake) endif() @@ -272,6 +273,7 @@ if(NOT CMAKE_CUDA_COMPILER_ID_RUN) endif() endif() + # FIXME(#23161): Defer architecture testing until compiler testing. if(DEFINED CMAKE_CUDA_ARCHITECTURES) if(CMAKE_CUDA_ARCHITECTURES MATCHES "^(all|all-major)$") # For sufficiently new NVCC we can just use the all and all-major flags. @@ -289,6 +291,17 @@ if(NOT CMAKE_CUDA_COMPILER_ID_RUN) set(architectures_test ${CMAKE_CUDA_ARCHITECTURES_ALL_MAJOR}) endif() endif() + elseif(CMAKE_CUDA_ARCHITECTURES STREQUAL "native") + # For sufficiently new NVCC we can just use the 'native' value directly. + # For VS we don't test since we can't find nvcc this early (see #23161). + if(CMAKE_CUDA_COMPILER_ID STREQUAL "NVIDIA" AND CMAKE_CUDA_COMPILER_TOOLKIT_VERSION VERSION_GREATER_EQUAL 11.6) + string(APPEND nvcc_test_flags " -arch=${CMAKE_CUDA_ARCHITECTURES}") + set(architectures_tested "${CMAKE_CUDA_ARCHITECTURES}") + elseif(CMAKE_GENERATOR MATCHES "Visual Studio") + set(architectures_tested "${CMAKE_CUDA_ARCHITECTURES}") + else() + set(architectures_test ${_CUDA_ARCHITECTURES_NATIVE}) + endif() elseif(CMAKE_CUDA_ARCHITECTURES OR "${CMAKE_CUDA_ARCHITECTURES}" STREQUAL "") # Explicit architectures. Test them during detection. set(architectures_explicit TRUE) @@ -346,6 +359,7 @@ if(NOT CMAKE_CUDA_COMPILER_ID_RUN) # We now know the version, so make the architecture variables available. set(CMAKE_CUDA_COMPILER_TOOLKIT_VERSION ${CMAKE_CUDA_COMPILER_VERSION}) + # FIXME(#23161): Defer architecture detection until compiler testing. include(${CMAKE_ROOT}/Modules/CUDA/architectures.cmake) endif() @@ -633,7 +647,7 @@ if("${CMAKE_CUDA_ARCHITECTURES}" STREQUAL "") message(FATAL_ERROR "Failed to detect a default CUDA architecture.\n\nCompiler output:\n${CMAKE_CUDA_COMPILER_PRODUCED_OUTPUT}") endif() endif() -elseif(CMAKE_CUDA_ARCHITECTURES AND NOT "${architectures_tested}" MATCHES "^(all|all-major)$") +elseif(CMAKE_CUDA_ARCHITECTURES AND NOT "${architectures_tested}" MATCHES "^(all|all-major|native)$") # Sort since order mustn't matter. list(SORT architectures_detected) list(SORT architectures_tested) diff --git a/Modules/CMakeDetermineCompilerABI.cmake b/Modules/CMakeDetermineCompilerABI.cmake index 8191d81..82a6d21 100644 --- a/Modules/CMakeDetermineCompilerABI.cmake +++ b/Modules/CMakeDetermineCompilerABI.cmake @@ -26,6 +26,14 @@ function(CMAKE_DETERMINE_COMPILER_ABI lang src) if(DEFINED CMAKE_${lang}_VERBOSE_COMPILE_FLAG) set(COMPILE_DEFINITIONS "${CMAKE_${lang}_VERBOSE_COMPILE_FLAG}") endif() + if(lang STREQUAL "CUDA") + if(CMAKE_CUDA_ARCHITECTURES STREQUAL "native") + # We are about to detect the native architectures, so we do + # not yet know them. Use all architectures during detection. + set(CMAKE_CUDA_ARCHITECTURES "all") + endif() + set(CMAKE_CUDA_RUNTIME_LIBRARY "Static") + endif() if(NOT "x${CMAKE_${lang}_COMPILER_ID}" STREQUAL "xMSVC") # Avoid adding our own platform standard libraries for compilers # from which we might detect implicit link libraries. diff --git a/Modules/CMakeDetermineCompilerId.cmake b/Modules/CMakeDetermineCompilerId.cmake index 5670509..0317f34 100644 --- a/Modules/CMakeDetermineCompilerId.cmake +++ b/Modules/CMakeDetermineCompilerId.cmake @@ -495,7 +495,7 @@ Id flags: ${testflags} ${CMAKE_${lang}_COMPILER_ID_FLAGS_ALWAYS} if(CMAKE_VS_PLATFORM_NAME STREQUAL x64) set(cuda_target "<TargetMachinePlatform>64</TargetMachinePlatform>") endif() - if(CMAKE_CUDA_ARCHITECTURES AND NOT CMAKE_CUDA_ARCHITECTURES MATCHES "^(all|all-major)$") + if(CMAKE_CUDA_ARCHITECTURES AND NOT CMAKE_CUDA_ARCHITECTURES MATCHES "^(all|all-major|native)$") foreach(arch ${CMAKE_CUDA_ARCHITECTURES}) string(REGEX MATCH "[0-9]+" arch_name "${arch}") string(APPEND cuda_codegen "compute_${arch_name},sm_${arch_name};") diff --git a/Modules/CMakeFindBinUtils.cmake b/Modules/CMakeFindBinUtils.cmake index 16d3106..a6bd0d1 100644 --- a/Modules/CMakeFindBinUtils.cmake +++ b/Modules/CMakeFindBinUtils.cmake @@ -173,8 +173,13 @@ else() else() list(PREPEND _CMAKE_LINKER_NAMES "ld.lld") endif() - if(NOT APPLE) + if(APPLE) # llvm-ar does not generate a symbol table that the Apple ld64 linker accepts. + # FIXME(#23333): We still need to consider 'llvm-ar' as a fallback because + # the 'APPLE' definition may be based on the host in this context, and a + # cross-compiling toolchain may not have 'ar'. + list(APPEND _CMAKE_AR_NAMES "llvm-ar") + else() list(PREPEND _CMAKE_AR_NAMES "llvm-ar") endif() list(PREPEND _CMAKE_RANLIB_NAMES "llvm-ranlib") diff --git a/Modules/CMakeTestCUDACompiler.cmake b/Modules/CMakeTestCUDACompiler.cmake index 25a3653..ea07482 100644 --- a/Modules/CMakeTestCUDACompiler.cmake +++ b/Modules/CMakeTestCUDACompiler.cmake @@ -21,6 +21,51 @@ if(CMAKE_CUDA_ABI_COMPILED) # The compiler worked so skip dedicated test below. set(CMAKE_CUDA_COMPILER_WORKS TRUE) message(STATUS "Check for working CUDA compiler: ${CMAKE_CUDA_COMPILER} - skipped") + + # Run the test binary to detect the native architectures. + execute_process(COMMAND "${CMAKE_PLATFORM_INFO_DIR}/CMakeDetermineCompilerABI_CUDA.bin" + RESULT_VARIABLE _CUDA_ARCHS_RESULT + OUTPUT_VARIABLE _CUDA_ARCHS_OUTPUT + ERROR_VARIABLE _CUDA_ARCHS_OUTPUT + OUTPUT_STRIP_TRAILING_WHITESPACE + ) + if(_CUDA_ARCHS_RESULT EQUAL 0) + if("$ENV{CMAKE_CUDA_ARCHITECTURES_NATIVE_CLAMP}") + # Undocumented hook used by CMake's CI. + # Clamp native architecture to version range supported by this CUDA. + list(GET CMAKE_CUDA_ARCHITECTURES_ALL 0 _CUDA_ARCH_MIN) + list(GET CMAKE_CUDA_ARCHITECTURES_ALL -1 _CUDA_ARCH_MAX) + set(CMAKE_CUDA_ARCHITECTURES_NATIVE "") + foreach(_CUDA_ARCH IN LISTS _CUDA_ARCHS_OUTPUT) + if(_CUDA_ARCH LESS _CUDA_ARCH_MIN) + set(_CUDA_ARCH "${_CUDA_ARCH_MIN}") + endif() + if(_CUDA_ARCH GREATER _CUDA_ARCH_MAX) + set(_CUDA_ARCH "${_CUDA_ARCH_MAX}") + endif() + list(APPEND CMAKE_CUDA_ARCHITECTURES_NATIVE ${_CUDA_ARCH}) + endforeach() + unset(_CUDA_ARCH) + unset(_CUDA_ARCH_MIN) + unset(_CUDA_ARCH_MAX) + else() + set(CMAKE_CUDA_ARCHITECTURES_NATIVE "${_CUDA_ARCHS_OUTPUT}") + endif() + list(REMOVE_DUPLICATES CMAKE_CUDA_ARCHITECTURES_NATIVE) + else() + if(NOT _CUDA_ARCHS_RESULT MATCHES "[0-9]+") + set(_CUDA_ARCHS_STATUS " (${_CUDA_ARCHS_RESULT})") + else() + set(_CUDA_ARCHS_STATUS "") + endif() + string(REPLACE "\n" "\n " _CUDA_ARCHS_OUTPUT " ${_CUDA_ARCHS_OUTPUT}") + file(APPEND ${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeError.log + "Detecting the CUDA native architecture(s) failed with " + "the following output:\n${_CUDA_ARCHS_OUTPUT}\n\n") + endif() + unset(_CUDA_ARCHS_EXE) + unset(_CUDA_ARCHS_RESULT) + unset(_CUDA_ARCHS_OUTPUT) endif() # This file is used by EnableLanguage in cmGlobalGenerator to diff --git a/Modules/CUDA/architectures.cmake b/Modules/CUDA/architectures.cmake index fa3a5a1..9b1f2b5 100644 --- a/Modules/CUDA/architectures.cmake +++ b/Modules/CUDA/architectures.cmake @@ -44,3 +44,63 @@ if(CMAKE_CUDA_COMPILER_TOOLKIT_VERSION VERSION_GREATER_EQUAL 11.4 AND (NOT CMAKE_CUDA_COMPILER_ID STREQUAL "Clang")) list(APPEND CMAKE_CUDA_ARCHITECTURES_ALL 87) endif() + +# FIXME(#23161): Detect architectures early since we test them during +# compiler detection. We already have code to detect them later during +# compiler testing, so we should not need to do this here. +if(NOT CMAKE_GENERATOR MATCHES "Visual Studio") + set(_CUDA_ARCHS_EXE "${CMAKE_PLATFORM_INFO_DIR}/CMakeDetermineCUDACompilerArchs.bin") + execute_process( + COMMAND "${_CUDA_NVCC_EXECUTABLE}" -o "${_CUDA_ARCHS_EXE}" --cudart=static "${CMAKE_ROOT}/Modules/CMakeCUDACompilerABI.cu" + RESULT_VARIABLE _CUDA_ARCHS_RESULT + OUTPUT_VARIABLE _CUDA_ARCHS_OUTPUT + ERROR_VARIABLE _CUDA_ARCHS_OUTPUT + ) + if(_CUDA_ARCHS_RESULT EQUAL 0) + execute_process( + COMMAND "${_CUDA_ARCHS_EXE}" + RESULT_VARIABLE _CUDA_ARCHS_RESULT + OUTPUT_VARIABLE _CUDA_ARCHS_OUTPUT + ERROR_VARIABLE _CUDA_ARCHS_OUTPUT + OUTPUT_STRIP_TRAILING_WHITESPACE + ) + endif() + if(_CUDA_ARCHS_RESULT EQUAL 0) + if("$ENV{CMAKE_CUDA_ARCHITECTURES_NATIVE_CLAMP}") + # Undocumented hook used by CMake's CI. + # Clamp native architecture to version range supported by this CUDA. + list(GET CMAKE_CUDA_ARCHITECTURES_ALL 0 _CUDA_ARCH_MIN) + list(GET CMAKE_CUDA_ARCHITECTURES_ALL -1 _CUDA_ARCH_MAX) + set(_CUDA_ARCHITECTURES_NATIVE "") + foreach(_CUDA_ARCH IN LISTS _CUDA_ARCHS_OUTPUT) + if(_CUDA_ARCH LESS _CUDA_ARCH_MIN) + set(_CUDA_ARCH "${_CUDA_ARCH_MIN}") + endif() + if(_CUDA_ARCH GREATER _CUDA_ARCH_MAX) + set(_CUDA_ARCH "${_CUDA_ARCH_MAX}") + endif() + list(APPEND _CUDA_ARCHITECTURES_NATIVE ${_CUDA_ARCH}) + endforeach() + unset(_CUDA_ARCH) + unset(_CUDA_ARCH_MIN) + unset(_CUDA_ARCH_MAX) + else() + set(_CUDA_ARCHITECTURES_NATIVE "${_CUDA_ARCHS_OUTPUT}") + endif() + list(REMOVE_DUPLICATES _CUDA_ARCHITECTURES_NATIVE) + else() + if (NOT _CUDA_ARCHS_RESULT MATCHES "[0-9]+") + set(_CUDA_ARCHS_STATUS " (${_CUDA_ARCHS_RESULT})") + else() + set(_CUDA_ARCHS_STATUS "") + endif() + string(REPLACE "\n" "\n " _CUDA_ARCHS_OUTPUT " ${_CUDA_ARCHS_OUTPUT}") + file(APPEND ${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeError.log + "Detecting the CUDA native architecture(s) failed with " + "the following output:\n${_CUDA_ARCHS_OUTPUT}\n\n") + set(_CUDA_ARCHS_OUTPUT "") + endif() + unset(_CUDA_ARCHS_EXE) + unset(_CUDA_ARCHS_RESULT) + unset(_CUDA_ARCHS_OUTPUT) +endif() diff --git a/Modules/Compiler/AppleClang-CXX.cmake b/Modules/Compiler/AppleClang-CXX.cmake index 28be1df..7c97969 100644 --- a/Modules/Compiler/AppleClang-CXX.cmake +++ b/Modules/Compiler/AppleClang-CXX.cmake @@ -47,9 +47,17 @@ if (NOT CMAKE_CXX_COMPILER_VERSION VERSION_LESS 8.0) set(CMAKE_CXX11_STANDARD__HAS_FULL_SUPPORT ON) endif() -if (NOT CMAKE_CXX_COMPILER_VERSION VERSION_LESS 10.0) +if (NOT CMAKE_CXX_COMPILER_VERSION VERSION_LESS 13.0) + set(CMAKE_CXX20_STANDARD_COMPILE_OPTION "-std=c++20") + set(CMAKE_CXX20_EXTENSION_COMPILE_OPTION "-std=gnu++20") +elseif (NOT CMAKE_CXX_COMPILER_VERSION VERSION_LESS 10.0) set(CMAKE_CXX20_STANDARD_COMPILE_OPTION "-std=c++2a") set(CMAKE_CXX20_EXTENSION_COMPILE_OPTION "-std=gnu++2a") endif() +if (NOT CMAKE_CXX_COMPILER_VERSION VERSION_LESS 13.0) + set(CMAKE_CXX23_STANDARD_COMPILE_OPTION "-std=c++2b") + set(CMAKE_CXX23_EXTENSION_COMPILE_OPTION "-std=gnu++2b") +endif() + __compiler_check_default_language_standard(CXX 4.0 98) diff --git a/Modules/ExternalProject.cmake b/Modules/ExternalProject.cmake index 292333d..42cb7a0 100644 --- a/Modules/ExternalProject.cmake +++ b/Modules/ExternalProject.cmake @@ -811,11 +811,11 @@ External Project Definition **Miscellaneous Options:** ``LIST_SEPARATOR <sep>`` - For any of the various ``..._COMMAND`` options, replace ``;`` with - ``<sep>`` in the specified command lines. This can be useful where list - variables may be given in commands where they should end up as - space-separated arguments (``<sep>`` would be a single space character - string in this case). + For any of the various ``..._COMMAND`` options, and ``CMAKE_ARGS``, + replace ``;`` with ``<sep>`` in the specified command lines. + This can be useful where list variables may be given in commands where + they should end up as space-separated arguments (``<sep>`` would be a + single space character string in this case). ``COMMAND <cmd>...`` Any of the other ``..._COMMAND`` options can have additional commands diff --git a/Modules/FindMatlab.cmake b/Modules/FindMatlab.cmake index 3c7efbc..17c1fa1 100644 --- a/Modules/FindMatlab.cmake +++ b/Modules/FindMatlab.cmake @@ -288,6 +288,7 @@ if(NOT MATLAB_ADDITIONAL_VERSIONS) endif() set(MATLAB_VERSIONS_MAPPING + "R2022a=9.12" "R2021b=9.11" "R2021a=9.10" "R2020b=9.9" diff --git a/Modules/FindPostgreSQL.cmake b/Modules/FindPostgreSQL.cmake index 147071a..25c5c09 100644 --- a/Modules/FindPostgreSQL.cmake +++ b/Modules/FindPostgreSQL.cmake @@ -53,7 +53,7 @@ is set regardless of the presence of the ``Server`` component in find_package ca # In Windows the default installation of PostgreSQL uses that as part of the path. # E.g C:\Program Files\PostgreSQL\8.4. # Currently, the following version numbers are known to this module: -# "11" "10" "9.6" "9.5" "9.4" "9.3" "9.2" "9.1" "9.0" "8.4" "8.3" "8.2" "8.1" "8.0" +# "13" "12" "11" "10" "9.6" "9.5" "9.4" "9.3" "9.2" "9.1" "9.0" "8.4" "8.3" "8.2" "8.1" "8.0" # # To use this variable just do something like this: # set(PostgreSQL_ADDITIONAL_VERSIONS "9.2" "8.4.4") diff --git a/Modules/FindPython/Support.cmake b/Modules/FindPython/Support.cmake index b7a0ef6..afe9743 100644 --- a/Modules/FindPython/Support.cmake +++ b/Modules/FindPython/Support.cmake @@ -280,26 +280,26 @@ function (_PYTHON_GET_PATH_SUFFIXES _PYTHON_PGPS_PATH_SUFFIXES) if (CMAKE_LIBRARY_ARCHITECTURE) set (suffixes "${abi}") if (suffixes) - list (TRANSFORM suffixes PREPEND "lib/python${_PGPS_VERSION}/config-${_PGPS_VERSION}") + list (TRANSFORM suffixes PREPEND "lib/python${version}/config-${version}") list (TRANSFORM suffixes APPEND "-${CMAKE_LIBRARY_ARCHITECTURE}") else() - set (suffixes "lib/python${_PGPS_VERSION}/config-${_PGPS_VERSION}-${CMAKE_LIBRARY_ARCHITECTURE}") + set (suffixes "lib/python${version}/config-${version}-${CMAKE_LIBRARY_ARCHITECTURE}") endif() list (APPEND path_suffixes ${suffixes}) endif() set (suffixes "${abi}") if (suffixes) - list (TRANSFORM suffixes PREPEND "lib/python${_PGPS_VERSION}/config-${_PGPS_VERSION}") + list (TRANSFORM suffixes PREPEND "lib/python${version}/config-${version}") else() - set (suffixes "lib/python${_PGPS_VERSION}/config-${_PGPS_VERSION}") + set (suffixes "lib/python${version}/config-${version}") endif() list (APPEND path_suffixes ${suffixes}) elseif (_PGPS_INCLUDE) set (suffixes "${abi}") if (suffixes) - list (TRANSFORM suffixes PREPEND "include/python${_PGPS_VERSION}") + list (TRANSFORM suffixes PREPEND "include/python${version}") else() - set (suffixes "include/python${_PGPS_VERSION}") + set (suffixes "include/python${version}") endif() list (APPEND path_suffixes ${suffixes} include) endif() @@ -318,6 +318,9 @@ function (_PYTHON_GET_PATH_SUFFIXES _PYTHON_PGPS_PATH_SUFFIXES) elseif (_PGPS_LIBRARY) list (APPEND path_suffixes ${_${_PYTHON_PREFIX}_PYPY_LIBRARY_PATH_SUFFIXES}) elseif (_PGPS_INCLUDE) + foreach (version IN LISTS _PGPS_VERSION) + list (APPEND path_suffixes lib/pypy${version}/include pypy${version}/include) + endforeach() list (APPEND path_suffixes ${_${_PYTHON_PREFIX}_PYPY_INCLUDE_PATH_SUFFIXES}) endif() endif() @@ -587,7 +590,13 @@ function (_PYTHON_GET_VERSION) set (${_PGV_PREFIX}ABI "${CMAKE_MATCH_3}" PARENT_SCOPE) elseif (library_name MATCHES "pypy(3)?-c") set (version "${CMAKE_MATCH_1}") - if (version EQUAL "3") + # try to pick-up a more precise version from the path + get_filename_component (library_dir "${_${_PYTHON_PREFIX}_LIBRARY_RELEASE}" DIRECTORY) + if (library_dir MATCHES "/pypy([23])\\.([0-9]+)/") + set (${_PGV_PREFIX}VERSION_MAJOR "${CMAKE_MATCH_1}" PARENT_SCOPE) + set (${_PGV_PREFIX}VERSION_MINOR "${CMAKE_MATCH_2}" PARENT_SCOPE) + set (${_PGV_PREFIX}VERSION "${CMAKE_MATCH_1}.${CMAKE_MATCH_2}" PARENT_SCOPE) + elseif (version EQUAL "3") set (${_PGV_PREFIX}VERSION_MAJOR "3" PARENT_SCOPE) set (${_PGV_PREFIX}VERSION "3" PARENT_SCOPE) else() @@ -1265,7 +1274,7 @@ if (_${_PYTHON_PREFIX}_REQUIRED_VERSION_MAJOR EQUAL "3") # special name for runtime part list (APPEND _${_PYTHON_PREFIX}_PYPY_LIB_NAMES libpypy3-c) endif() - set (_${_PYTHON_PREFIX}_PYPY_INCLUDE_PATH_SUFFIXES lib/pypy3) + set (_${_PYTHON_PREFIX}_PYPY_INCLUDE_PATH_SUFFIXES lib/pypy3/include pypy3/include) else() set (_${_PYTHON_PREFIX}_PYPY_NAMES pypy) set (_${_PYTHON_PREFIX}_PYPY_LIB_NAMES pypy-c) @@ -1273,8 +1282,9 @@ else() # special name for runtime part list (APPEND _${_PYTHON_PREFIX}_PYPY_LIB_NAMES libpypy-c) endif() - set (_${_PYTHON_PREFIX}_PYPY_INCLUDE_PATH_SUFFIXES lib/pypy) + set (_${_PYTHON_PREFIX}_PYPY_INCLUDE_PATH_SUFFIXES lib/pypy/include pypy/include) endif() +list (APPEND _${_PYTHON_PREFIX}_PYPY_INCLUDE_PATH_SUFFIXES libexec/include) set (_${_PYTHON_PREFIX}_PYPY_EXECUTABLE_PATH_SUFFIXES bin) set (_${_PYTHON_PREFIX}_PYPY_LIBRARY_PATH_SUFFIXES lib libs bin) list (APPEND _${_PYTHON_PREFIX}_PYPY_INCLUDE_PATH_SUFFIXES include) @@ -1303,7 +1313,7 @@ foreach (_${_PYTHON_PREFIX}_IMPLEMENTATION IN LISTS _${_PYTHON_PREFIX}_FIND_IMPL if (_${_PYTHON_PREFIX}_IMPLEMENTATION STREQUAL "CPython") list (APPEND _${_PYTHON_PREFIX}_INCLUDE_NAMES "Python.h") elseif (_${_PYTHON_PREFIX}_IMPLEMENTATION STREQUAL "PyPy") - list (APPEND _${_PYTHON_PREFIX}_INCLUDE_NAMES "PyPy.h") + list (APPEND _${_PYTHON_PREFIX}_INCLUDE_NAMES "PyPy.h" "pypy_decl.h") endif() endforeach() @@ -2921,6 +2931,11 @@ if (("Development.Module" IN_LIST ${_PYTHON_PREFIX}_FIND_COMPONENTS # update versioning set (_${_PYTHON_PREFIX}_VERSION ${_${_PYTHON_PREFIX}_INC_VERSION}) set (_${_PYTHON_PREFIX}_VERSION_PATCH ${_${_PYTHON_PREFIX}_INC_VERSION_PATCH}) + elseif (_${_PYTHON_PREFIX}_VERSION VERSION_EQUAL _${_PYTHON_PREFIX}_INC_VERSION_MAJOR) + # library specify only major version, use include file for full version information + set (_${_PYTHON_PREFIX}_VERSION ${_${_PYTHON_PREFIX}_INC_VERSION}) + set (_${_PYTHON_PREFIX}_VERSION_MINOR ${_${_PYTHON_PREFIX}_INC_VERSION_MINOR}) + set (_${_PYTHON_PREFIX}_VERSION_PATCH ${_${_PYTHON_PREFIX}_INC_VERSION_PATCH}) endif() else() set (_${_PYTHON_PREFIX}_VERSION ${_${_PYTHON_PREFIX}_INC_VERSION}) diff --git a/Modules/FindX11.cmake b/Modules/FindX11.cmake index 5a9d2a0..8e5a5f1 100644 --- a/Modules/FindX11.cmake +++ b/Modules/FindX11.cmake @@ -34,6 +34,8 @@ and also the following more fine grained variables and targets: X11_xcb_randr_INCLUDE_PATH, X11_xcb_randr_LIB, X11_xcb_randr_FOUND, X11::xcb_randr X11_xcb_util_INCLUDE_PATH, X11_xcb_util_LIB, X11_xcb_util_FOUND, X11::xcb_util X11_xcb_xfixes_INCLUDE_PATH, X11_xcb_xfixes_LIB, X11_xcb_xfixes_FOUND, X11::xcb_xfixes + X11_xcb_xtest_INCLUDE_PATH, X11_xcb_xtest_LIB, X11_xcb_xtest_FOUND, X11::xcb_xtest + X11_xcb_keysyms_INCLUDE_PATH, X11_xcb_keysyms_LIB,X11_xcb_keysyms_FOUND,X11::xcb_keysyms X11_xcb_xkb_INCLUDE_PATH, X11_xcb_xkb_LIB, X11_xcb_xkb_FOUND, X11::xcb_xkb X11_Xcomposite_INCLUDE_PATH, X11_Xcomposite_LIB, X11_Xcomposite_FOUND, X11::Xcomposite X11_Xcursor_INCLUDE_PATH, X11_Xcursor_LIB, X11_Xcursor_FOUND, X11::Xcursor @@ -84,7 +86,7 @@ and also the following more fine grained variables and targets: Added the ``Xaw``, ``xcb_util``, and ``xcb_xfixes`` libraries. .. versionadded:: 3.24 - Added the ``xcb_randr`` library. + Added the ``xcb_randr``, ``xcb_xtext``, and ``xcb_keysyms`` libraries. #]=======================================================================] @@ -134,6 +136,8 @@ if (UNIX) find_path(X11_xcb_randr_INCLUDE_PATH xcb/randr.h ${X11_INC_SEARCH_PATH}) find_path(X11_xcb_util_INCLUDE_PATH xcb/xcb_aux.h ${X11_INC_SEARCH_PATH}) find_path(X11_xcb_xfixes_INCLUDE_PATH xcb/xfixes.h ${X11_INC_SEARCH_PATH}) + find_path(X11_xcb_xtest_INCLUDE_PATH xcb/xtest.h ${X11_INC_SEARCH_PATH}) + find_path(X11_xcb_keysyms_INCLUDE_PATH xcb/xcb_keysyms.h ${X11_INC_SEARCH_PATH}) find_path(X11_Xcomposite_INCLUDE_PATH X11/extensions/Xcomposite.h ${X11_INC_SEARCH_PATH}) find_path(X11_Xcursor_INCLUDE_PATH X11/Xcursor/Xcursor.h ${X11_INC_SEARCH_PATH}) find_path(X11_Xdamage_INCLUDE_PATH X11/extensions/Xdamage.h ${X11_INC_SEARCH_PATH}) @@ -188,6 +192,8 @@ if (UNIX) find_library(X11_xcb_randr_LIB xcb-randr ${X11_LIB_SEARCH_PATH}) find_library(X11_xcb_util_LIB xcb-util ${X11_LIB_SEARCH_PATH}) find_library(X11_xcb_xfixes_LIB xcb-xfixes ${X11_LIB_SEARCH_PATH}) + find_library(X11_xcb_xtest_LIB xcb-xtest ${X11_LIB_SEARCH_PATH}) + find_library(X11_xcb_keysyms_LIB xcb-keysyms ${X11_LIB_SEARCH_PATH}) find_library(X11_xcb_xkb_LIB xcb-xkb ${X11_LIB_SEARCH_PATH}) find_library(X11_Xcomposite_LIB Xcomposite ${X11_LIB_SEARCH_PATH}) find_library(X11_Xcursor_LIB Xcursor ${X11_LIB_SEARCH_PATH}) @@ -299,6 +305,14 @@ if (UNIX) set(X11_xcb_xfixes_FOUND TRUE) endif () + if (X11_xcb_xtest_LIB) + set(X11_xcb_xtest_FOUND TRUE) + endif () + + if (X11_xcb_keysyms_LIB) + set(X11_xcb_keysyms_FOUND TRUE) + endif () + if (X11_xcb_xkb_LIB) set(X11_xcb_xkb_FOUND TRUE) endif () @@ -631,6 +645,20 @@ if (UNIX) INTERFACE_LINK_LIBRARIES "X11::xcb") endif () + if (X11_xcb_xtest_FOUND AND NOT TARGET X11::xcb_xtest) + add_library(X11::xcb_xtest UNKNOWN IMPORTED) + set_target_properties(X11::xcb_xtest PROPERTIES + IMPORTED_LOCATION "${X11_xcb_xtest_LIB}" + INTERFACE_LINK_LIBRARIES "X11::xcb") + endif () + + if (X11_xcb_keysyms_FOUND AND NOT TARGET X11::xcb_keysyms) + add_library(X11::xcb_keysyms UNKNOWN IMPORTED) + set_target_properties(X11::xcb_keysyms PROPERTIES + IMPORTED_LOCATION "${X11_xcb_keysyms_LIB}" + INTERFACE_LINK_LIBRARIES "X11::xcb") + endif () + if (X11_xcb_xkb_FOUND AND NOT TARGET X11::xcb_xkb) add_library(X11::xcb_xkb UNKNOWN IMPORTED) set_target_properties(X11::xcb_xkb PROPERTIES @@ -853,6 +881,10 @@ if (UNIX) X11_xcb_util_INCLUDE_PATH X11_xcb_xfixes_LIB X11_xcb_xfixes_INCLUDE_PATH + X11_xcb_xtest_LIB + X11_xcb_xtest_INCLUDE_PATH + X11_xcb_keysyms_LIB + X11_xcb_keysyms_INCLUDE_PATH X11_xcb_xkb_LIB X11_X11_xcb_LIB X11_X11_xcb_INCLUDE_PATH diff --git a/Modules/FindZLIB.cmake b/Modules/FindZLIB.cmake index 5778b03..4af842a 100644 --- a/Modules/FindZLIB.cmake +++ b/Modules/FindZLIB.cmake @@ -53,6 +53,11 @@ Hints A user may set ``ZLIB_ROOT`` to a zlib installation root to tell this module where to look. + +.. versionadded:: 3.24 + Set ``ZLIB_USE_STATIC_LIBS`` to ``ON`` to look for static libraries. + Default is ``OFF``. + #]=======================================================================] set(_ZLIB_SEARCHES) @@ -72,8 +77,8 @@ set(_ZLIB_SEARCH_NORMAL unset(_ZLIB_x86) list(APPEND _ZLIB_SEARCHES _ZLIB_SEARCH_NORMAL) -set(ZLIB_NAMES z zlib zdll zlib1 zlibstatic) -set(ZLIB_NAMES_DEBUG zd zlibd zdlld zlibd1 zlib1d zlibstaticd) +set(ZLIB_NAMES z zlib zdll zlib1 zlibstatic zlibstat zlibvc) +set(ZLIB_NAMES_DEBUG zd zlibd zdlld zlibd1 zlib1d zlibstaticd zlibstatd zlibvcd) # Try each search configuration. foreach(search ${_ZLIB_SEARCHES}) @@ -82,11 +87,26 @@ endforeach() # Allow ZLIB_LIBRARY to be set manually, as the location of the zlib library if(NOT ZLIB_LIBRARY) + # Support preference of static libs by adjusting CMAKE_FIND_LIBRARY_SUFFIXES + if(ZLIB_USE_STATIC_LIBS) + set(_zlib_ORIG_CMAKE_FIND_LIBRARY_SUFFIXES ${CMAKE_FIND_LIBRARY_SUFFIXES}) + if(WIN32) + set(CMAKE_FIND_LIBRARY_SUFFIXES .lib .a ${CMAKE_FIND_LIBRARY_SUFFIXES}) + else() + set(CMAKE_FIND_LIBRARY_SUFFIXES .a) + endif() + endif() + foreach(search ${_ZLIB_SEARCHES}) find_library(ZLIB_LIBRARY_RELEASE NAMES ${ZLIB_NAMES} NAMES_PER_DIR ${${search}} PATH_SUFFIXES lib) find_library(ZLIB_LIBRARY_DEBUG NAMES ${ZLIB_NAMES_DEBUG} NAMES_PER_DIR ${${search}} PATH_SUFFIXES lib) endforeach() + # Restore the original find library ordering + if(ZLIB_USE_STATIC_LIBS) + set(CMAKE_FIND_LIBRARY_SUFFIXES ${_zlib_ORIG_CMAKE_FIND_LIBRARY_SUFFIXES}) + endif() + include(${CMAKE_CURRENT_LIST_DIR}/SelectLibraryConfigurations.cmake) select_library_configurations(ZLIB) endif() diff --git a/Source/CMakeVersion.cmake b/Source/CMakeVersion.cmake index 9af206e..8f753c3 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 23) -set(CMake_VERSION_PATCH 20220310) +set(CMake_VERSION_PATCH 20220321) #set(CMake_VERSION_RC 0) set(CMake_VERSION_IS_DIRTY 0) diff --git a/Source/Checks/cm_cxx_filesystem.cxx b/Source/Checks/cm_cxx_filesystem.cxx index b7d5be5..ae8acc5 100644 --- a/Source/Checks/cm_cxx_filesystem.cxx +++ b/Source/Checks/cm_cxx_filesystem.cxx @@ -3,8 +3,6 @@ int main() { - return 1; - std::filesystem::path p0(L"/a/b/c"); std::filesystem::path p1("/a/b/c"); diff --git a/Source/cmAddExecutableCommand.cxx b/Source/cmAddExecutableCommand.cxx index 9dd8a19..16a8965 100644 --- a/Source/cmAddExecutableCommand.cxx +++ b/Source/cmAddExecutableCommand.cxx @@ -54,6 +54,10 @@ bool cmAddExecutableCommand(std::vector<std::string> const& args, } } + if (importTarget && !importGlobal) { + importGlobal = mf.IsImportedTargetGlobalScope(); + } + bool nameOk = cmGeneratorExpression::IsValidTargetName(exename) && !cmGlobalGenerator::IsReservedTarget(exename); diff --git a/Source/cmAddLibraryCommand.cxx b/Source/cmAddLibraryCommand.cxx index a5d1f6a..29fc09b 100644 --- a/Source/cmAddLibraryCommand.cxx +++ b/Source/cmAddLibraryCommand.cxx @@ -131,6 +131,10 @@ bool cmAddLibraryCommand(std::vector<std::string> const& args, } } + if (importTarget && !importGlobal) { + importGlobal = mf.IsImportedTargetGlobalScope(); + } + if (type == cmStateEnums::INTERFACE_LIBRARY) { if (importGlobal && !importTarget) { status.SetError( diff --git a/Source/cmFindPackageCommand.cxx b/Source/cmFindPackageCommand.cxx index f55d838..18457a7 100644 --- a/Source/cmFindPackageCommand.cxx +++ b/Source/cmFindPackageCommand.cxx @@ -262,6 +262,9 @@ bool cmFindPackageCommand::InitialPass(std::vector<std::string> const& args) } else if (args[i] == "EXACT") { this->VersionExact = true; doing = DoingNone; + } else if (args[i] == "GLOBAL") { + this->GlobalScope = true; + doing = DoingNone; } else if (args[i] == "MODULE") { moduleArgs.insert(i); doing = DoingNone; @@ -364,6 +367,12 @@ bool cmFindPackageCommand::InitialPass(std::vector<std::string> const& args) } } + if (!this->GlobalScope) { + cmValue value( + this->Makefile->GetDefinition("CMAKE_FIND_PACKAGE_TARGETS_GLOBAL")); + this->GlobalScope = value.IsOn(); + } + std::vector<std::string> doubledComponents; std::set_intersection(requiredComponents.begin(), requiredComponents.end(), optionalComponents.begin(), optionalComponents.end(), @@ -1200,6 +1209,11 @@ bool cmFindPackageCommand::ReadListFile(const std::string& f, PolicyScopeRule psr) { const bool noPolicyScope = !this->PolicyScope || psr == NoPolicyScope; + + using ITScope = cmMakefile::ImportedTargetScope; + ITScope scope = this->GlobalScope ? ITScope::Global : ITScope::Local; + cmMakefile::SetGlobalTargetImportScope globScope(this->Makefile, scope); + if (this->Makefile->ReadDependentFile(f, noPolicyScope)) { return true; } diff --git a/Source/cmFindPackageCommand.h b/Source/cmFindPackageCommand.h index f921bb0..b9f19e4 100644 --- a/Source/cmFindPackageCommand.h +++ b/Source/cmFindPackageCommand.h @@ -199,6 +199,7 @@ private: bool UseLibx32Paths = false; bool UseRealPath = false; bool PolicyScope = true; + bool GlobalScope = false; std::string LibraryArchitecture; std::vector<std::string> Names; std::vector<std::string> Configs; diff --git a/Source/cmGeneratorTarget.cxx b/Source/cmGeneratorTarget.cxx index 8a6cc1c..ab3ed12 100644 --- a/Source/cmGeneratorTarget.cxx +++ b/Source/cmGeneratorTarget.cxx @@ -3467,6 +3467,23 @@ void cmGeneratorTarget::AddCUDAArchitectureFlags(std::string& flags) const property = *this->Makefile->GetDefinition("CMAKE_CUDA_ARCHITECTURES_ALL_MAJOR"); } + } else if (property == "native") { + cmValue native = + this->Makefile->GetDefinition("CMAKE_CUDA_ARCHITECTURES_NATIVE"); + if (native.IsEmpty()) { + this->Makefile->IssueMessage( + MessageType::FATAL_ERROR, + "CUDA_ARCHITECTURES is set to \"native\", but no GPU was detected."); + } + if (compiler == "NVIDIA" && + cmSystemTools::VersionCompare( + cmSystemTools::OP_GREATER_EQUAL, + this->Makefile->GetDefinition("CMAKE_CUDA_COMPILER_VERSION"), + "11.6")) { + flags = cmStrCat(flags, " -arch=", property); + return; + } + property = *native; } struct CudaArchitecture diff --git a/Source/cmMakefile.cxx b/Source/cmMakefile.cxx index be189a6..f0a96a8 100644 --- a/Source/cmMakefile.cxx +++ b/Source/cmMakefile.cxx @@ -458,6 +458,11 @@ bool cmMakefile::ExecuteCommand(const cmListFileFunction& lff, return result; } +bool cmMakefile::IsImportedTargetGlobalScope() const +{ + return this->CurrentImportedTargetScope == ImportedTargetScope::Global; +} + class cmMakefile::IncludeScope { public: diff --git a/Source/cmMakefile.h b/Source/cmMakefile.h index ad8a014..6d44e79 100644 --- a/Source/cmMakefile.h +++ b/Source/cmMakefile.h @@ -860,6 +860,44 @@ public: void PushLoopBlockBarrier(); void PopLoopBlockBarrier(); + bool IsImportedTargetGlobalScope() const; + + enum class ImportedTargetScope + { + Local, + Global, + }; + + /** Helper class to manage whether imported packages + * should be globally scoped based off the find package command + */ + class SetGlobalTargetImportScope + { + public: + SetGlobalTargetImportScope(cmMakefile* mk, ImportedTargetScope const scope) + : Makefile(mk) + { + if (scope == ImportedTargetScope::Global && + !this->Makefile->IsImportedTargetGlobalScope()) { + this->Makefile->CurrentImportedTargetScope = scope; + this->Set = true; + } else { + this->Set = false; + } + } + ~SetGlobalTargetImportScope() + { + if (this->Set) { + this->Makefile->CurrentImportedTargetScope = + ImportedTargetScope::Local; + } + } + + private: + cmMakefile* Makefile; + bool Set; + }; + /** Helper class to push and pop scopes automatically. */ class ScopePushPop { @@ -1124,4 +1162,5 @@ private: std::set<std::string> WarnedCMP0074; bool IsSourceFileTryCompile; mutable bool SuppressSideEffects; + ImportedTargetScope CurrentImportedTargetScope = ImportedTargetScope::Local; }; diff --git a/Source/cmTargetLinkLibrariesCommand.cxx b/Source/cmTargetLinkLibrariesCommand.cxx index 0ba93fb..e1a6c78 100644 --- a/Source/cmTargetLinkLibrariesCommand.cxx +++ b/Source/cmTargetLinkLibrariesCommand.cxx @@ -9,6 +9,7 @@ #include <utility> #include <cm/optional> +#include <cm/string_view> #include "cmExecutionStatus.h" #include "cmGeneratorExpression.h" @@ -183,8 +184,11 @@ bool cmTargetLinkLibrariesCommand(std::vector<std::string> const& args, // Accumulate consectuive non-keyword arguments into one entry in // order to handle unquoted generator expressions containing ';'. + std::size_t genexNesting = 0; cm::optional<std::string> currentEntry; auto processCurrentEntry = [&]() -> bool { + // FIXME: Warn about partial genex if genexNesting > 0? + genexNesting = 0; if (currentEntry) { assert(!haveLLT); if (!tll.HandleLibrary(currentProcessingState, *currentEntry, @@ -220,7 +224,7 @@ bool cmTargetLinkLibrariesCommand(std::vector<std::string> const& args, // of debug and optimized that can be used. for (unsigned int i = 1; i < args.size(); ++i) { if (keywords.count(args[i])) { - // A keyword argument terminates any preceding accumulated entry. + // A keyword argument terminates any accumulated partial genex. if (!processCurrentEntry()) { return false; } @@ -321,12 +325,33 @@ bool cmTargetLinkLibrariesCommand(std::vector<std::string> const& args, } llt = GENERAL_LibraryType; } else { + // Track the genex nesting level. + { + cm::string_view arg = args[i]; + for (std::string::size_type pos = 0; pos < arg.size(); ++pos) { + cm::string_view cur = arg.substr(pos); + if (cmHasLiteralPrefix(cur, "$<")) { + ++genexNesting; + ++pos; + } else if (genexNesting > 0 && cmHasLiteralPrefix(cur, ">")) { + --genexNesting; + } + } + } + // Accumulate this argument in the current entry. extendCurrentEntry(args[i]); + + // Process this entry if it does not end inside a genex. + if (genexNesting == 0) { + if (!processCurrentEntry()) { + return false; + } + } } } - // Process the last accumulated entry, if any. + // Process the last accumulated partial genex, if any. if (!processCurrentEntry()) { return false; } diff --git a/Source/cmVisualStudioGeneratorOptions.cxx b/Source/cmVisualStudioGeneratorOptions.cxx index 9045a4d..d5d08b8 100644 --- a/Source/cmVisualStudioGeneratorOptions.cxx +++ b/Source/cmVisualStudioGeneratorOptions.cxx @@ -182,7 +182,8 @@ void cmVisualStudioGeneratorOptions::FixCudaCodeGeneration() // First entries for the -arch=<arch> [-code=<code>,...] pair. if (!arch.empty()) { std::string arch_name = arch[0]; - if (arch_name == "all" || arch_name == "all-major") { + if (arch_name == "all" || arch_name == "all-major" || + arch_name == "native") { AppendFlagString("AdditionalOptions", "-arch=" + arch_name); return; } diff --git a/Source/cmake.cxx b/Source/cmake.cxx index 81d225d..a602458 100644 --- a/Source/cmake.cxx +++ b/Source/cmake.cxx @@ -819,7 +819,7 @@ void cmake::SetArgs(const std::vector<std::string>& args) std::string path = cmSystemTools::CollapseFullPath(value); cmSystemTools::ConvertToUnixSlashes(path); - state->SetHomeDirectoryViaCommandLine(path, HomeDirArgStyle::Dash_S); + state->SetHomeDirectoryViaCommandLine(path); return true; }; @@ -1158,6 +1158,12 @@ void cmake::SetArgs(const std::vector<std::string>& args) // iterate each argument std::string const& arg = args[i]; + if (scriptMode && arg == "--") { + // Stop processing CMake args and avoid possible errors + // when arbitrary args are given to CMake script. + break; + } + // Generator flag has special handling for when to print help // so it becomes the exception if (generatorCommand.matches(arg)) { @@ -1555,7 +1561,7 @@ bool cmake::SetDirectoriesFromFile(const std::string& arg) // When invoked with a path that points to an existing CMakeCache // This function is called multiple times with the same path if (is_source_dir) { - this->SetHomeDirectoryViaCommandLine(listPath, HomeDirArgStyle::Plain); + this->SetHomeDirectoryViaCommandLine(listPath); if (no_build_tree) { std::string cwd = cmSystemTools::GetCurrentWorkingDirectory(); this->SetHomeOutputDirectory(cwd); @@ -1780,28 +1786,19 @@ void cmake::PrintPresetList(const cmCMakePresetsGraph& graph) const } #endif -void cmake::SetHomeDirectoryViaCommandLine(std::string const& path, - HomeDirArgStyle argStyle) +void cmake::SetHomeDirectoryViaCommandLine(std::string const& path) { - bool fromDashS = argStyle == HomeDirArgStyle::Dash_S; - static bool homeDirectorySetExplicitly = false; if (path.empty()) { return; } auto prev_path = this->GetHomeDirectory(); if (prev_path != path && !prev_path.empty()) { - const bool ignore_prev_path = - (fromDashS || (!fromDashS && !homeDirectorySetExplicitly)); - const std::string& ignored_path = (ignore_prev_path) ? prev_path : path; this->IssueMessage(MessageType::WARNING, cmStrCat("Ignoring extra path from command line:\n \"", - ignored_path, "\"")); - } - if (fromDashS || !homeDirectorySetExplicitly) { - this->SetHomeDirectory(path); + prev_path, "\"")); } - homeDirectorySetExplicitly = fromDashS; + this->SetHomeDirectory(path); } void cmake::SetHomeDirectory(const std::string& dir) diff --git a/Source/cmake.h b/Source/cmake.h index 9c795c5..3c2a36c 100644 --- a/Source/cmake.h +++ b/Source/cmake.h @@ -183,12 +183,6 @@ public: #endif std::string ReportCapabilities() const; - enum class HomeDirArgStyle - { - Plain, - Dash_S, - }; - /** * Set the home directory from `-S` or from a known location * that contains a CMakeLists.txt. Will generate warnings @@ -199,12 +193,11 @@ public: * | `dirA dirA` | dirA | N/A | * | `-S dirA -S dirA` | dirA | N/A | * | `-S dirA -S dirB` | dirB | Ignoring dirA | - * | `-S dirA dirB` | dirA | Ignoring dirB | + * | `-S dirA dirB` | dirB | Ignoring dirA | * | `dirA -S dirB` | dirB | Ignoring dirA | * | `dirA dirB` | dirB | Ignoring dirA | */ - void SetHomeDirectoryViaCommandLine(std::string const& path, - HomeDirArgStyle argStyle); + void SetHomeDirectoryViaCommandLine(std::string const& path); //@{ /** diff --git a/Tests/CMakeCommands/target_link_libraries/cmp0022/CMakeLists.txt b/Tests/CMakeCommands/target_link_libraries/cmp0022/CMakeLists.txt index ca6309b..ebade02 100644 --- a/Tests/CMakeCommands/target_link_libraries/cmp0022/CMakeLists.txt +++ b/Tests/CMakeCommands/target_link_libraries/cmp0022/CMakeLists.txt @@ -33,6 +33,22 @@ add_library(staticlib2 STATIC staticlib2.cpp) generate_export_header(staticlib2) target_link_libraries(staticlib1 LINK_PUBLIC staticlib2) +# Test adding LINK_ONLY to each of multiple specified libraries. +add_library(staticlib2iface1 INTERFACE) +add_library(staticlib2iface2 INTERFACE) +target_compile_definitions(staticlib2iface1 INTERFACE STATICLIB2_IFACE_1) +target_compile_definitions(staticlib2iface2 INTERFACE STATICLIB2_IFACE_2) +target_link_libraries(staticlib2 PRIVATE staticlib2iface1 staticlib2iface2) + +# Test adding unquoted genex with ';' to LINK_LIBRARIES and INTERFACE_LINK_LIBRARIES. +target_link_libraries(staticlib2 + PUBLIC $<0:imp::missing1;imp::missing2> + PRIVATE $<0:imp::missing3;imp::missing4> + INTERFACE $<0:imp::missing5;imp::missing6> + ) +assert_property(staticlib2 INTERFACE_LINK_LIBRARIES "$<LINK_ONLY:staticlib2iface1>;$<LINK_ONLY:staticlib2iface2>;$<0:imp::missing1;imp::missing2>;$<LINK_ONLY:$<0:imp::missing3;imp::missing4>>;$<0:imp::missing5;imp::missing6>") +assert_property(staticlib2 LINK_LIBRARIES "staticlib2iface1;staticlib2iface2;$<0:imp::missing1;imp::missing2>;$<0:imp::missing3;imp::missing4>") + # Try adding a private link item to be propagated out of a static lib. set(private_link "") if (CMAKE_CXX_COMPILER_ID MATCHES GNU OR CMAKE_CXX_COMPILER_ID MATCHES Clang OR CMAKE_CXX_COMPILER_ID MATCHES LCC) diff --git a/Tests/CMakeCommands/target_link_libraries/cmp0022/staticlib1.cpp b/Tests/CMakeCommands/target_link_libraries/cmp0022/staticlib1.cpp index d6b3986..d7f3e7c 100644 --- a/Tests/CMakeCommands/target_link_libraries/cmp0022/staticlib1.cpp +++ b/Tests/CMakeCommands/target_link_libraries/cmp0022/staticlib1.cpp @@ -1,3 +1,9 @@ +#ifdef STATICLIB2_IFACE_1 +# error "STATICLIB2_IFACE_1 incorrectly defined" +#endif +#ifdef STATICLIB2_IFACE_2 +# error "STATICLIB2_IFACE_2 incorrectly defined" +#endif int staticlib1() { diff --git a/Tests/CMakeCommands/target_link_libraries/cmp0022/staticlib2.cpp b/Tests/CMakeCommands/target_link_libraries/cmp0022/staticlib2.cpp index bd1a901..caa4143 100644 --- a/Tests/CMakeCommands/target_link_libraries/cmp0022/staticlib2.cpp +++ b/Tests/CMakeCommands/target_link_libraries/cmp0022/staticlib2.cpp @@ -1,3 +1,9 @@ +#ifndef STATICLIB2_IFACE_1 +# error "STATICLIB2_IFACE_1 incorrectly not defined" +#endif +#ifndef STATICLIB2_IFACE_2 +# error "STATICLIB2_IFACE_2 incorrectly not defined" +#endif int staticlib2() { diff --git a/Tests/CudaOnly/All/CMakeLists.txt b/Tests/CudaOnly/ArchSpecial/CMakeLists.txt index ba32e9a..46f4ada 100644 --- a/Tests/CudaOnly/All/CMakeLists.txt +++ b/Tests/CudaOnly/ArchSpecial/CMakeLists.txt @@ -1,5 +1,5 @@ cmake_minimum_required(VERSION 3.20) -project(CudaOnlyAll CUDA) +project(ArchSpecial CUDA) if(CMAKE_CUDA_COMPILER_ID STREQUAL "NVIDIA" AND CMAKE_CUDA_COMPILER_VERSION VERSION_GREATER_EQUAL 8.0) @@ -25,6 +25,7 @@ function(verify_output flag) endforeach() list(SORT command_archs) + list(REMOVE_DUPLICATES command_archs) if(NOT "${command_archs}" STREQUAL "${architectures}") message(FATAL_ERROR "Architectures used for \"${flag}\" don't match the reference (\"${command_archs}\" != \"${architectures}\").") endif() @@ -50,7 +51,17 @@ try_compile(all_major_archs_compiles ) verify_output(all-major) -if(all_archs_compiles AND all_major_archs_compiles) - add_executable(CudaOnlyAll main.cu) - target_compile_options(CudaOnlyAll PRIVATE ${compile_options}) +set(CMAKE_CUDA_ARCHITECTURES native) +try_compile(native_archs_compiles + ${CMAKE_CURRENT_BINARY_DIR}/try_compile/native_archs_compiles + ${CMAKE_CURRENT_SOURCE_DIR}/main.cu + COMPILE_DEFINITIONS ${try_compile_flags} + OUTPUT_VARIABLE output + ) +verify_output(native) + +if(all_archs_compiles AND all_major_archs_compiles AND native_archs_compiles) + set(CMAKE_CUDA_ARCHITECTURES all) + add_executable(CudaOnlyArchSpecial main.cu) + target_compile_options(CudaOnlyArchSpecial PRIVATE ${compile_options}) endif() diff --git a/Tests/CudaOnly/All/main.cu b/Tests/CudaOnly/ArchSpecial/main.cu index 5047a34..5047a34 100644 --- a/Tests/CudaOnly/All/main.cu +++ b/Tests/CudaOnly/ArchSpecial/main.cu diff --git a/Tests/CudaOnly/CMakeLists.txt b/Tests/CudaOnly/CMakeLists.txt index cacfb76..aa4755d 100644 --- a/Tests/CudaOnly/CMakeLists.txt +++ b/Tests/CudaOnly/CMakeLists.txt @@ -4,8 +4,8 @@ macro (add_cuda_test_macro name) PROPERTY LABELS "CUDA") endmacro () -add_cuda_test_macro(CudaOnly.All CudaOnlyAll) add_cuda_test_macro(CudaOnly.Architecture Architecture) +add_cuda_test_macro(CudaOnly.ArchSpecial CudaOnlyArchSpecial) add_cuda_test_macro(CudaOnly.CompileFlags CudaOnlyCompileFlags) add_cuda_test_macro(CudaOnly.EnableStandard CudaOnlyEnableStandard) diff --git a/Tests/FindMatlab/cmake_matlab_unit_tests4.m b/Tests/FindMatlab/cmake_matlab_unit_tests4.m index 6a7b04d..c2bf270 100644 --- a/Tests/FindMatlab/cmake_matlab_unit_tests4.m +++ b/Tests/FindMatlab/cmake_matlab_unit_tests4.m @@ -1,4 +1,3 @@ - classdef cmake_matlab_unit_tests4 < matlab.unittest.TestCase % Testing R2017b and R2018a APIs properties @@ -12,11 +11,7 @@ classdef cmake_matlab_unit_tests4 < matlab.unittest.TestCase function testR2018a(testCase) ret = cmake_matlab_mex2b(5+6i); - v = version; - n = find(v=='.'); - v = str2double(v(1:n(2)-1)); - disp(v) - if v>= 9.4 % R2018a + if not(verLessThan('matlab','9.4')) % R2018a testCase.verifyEqual(ret, 16); disp('TESTING version >= 9.4') else diff --git a/Tests/FindX11/Test/CMakeLists.txt b/Tests/FindX11/Test/CMakeLists.txt index ddee835..18a73a3 100644 --- a/Tests/FindX11/Test/CMakeLists.txt +++ b/Tests/FindX11/Test/CMakeLists.txt @@ -36,6 +36,8 @@ test_x11_component(x11_components xcb_icccm) test_x11_component(x11_components xcb_randr) test_x11_component(x11_components xcb_util) test_x11_component(x11_components xcb_xfixes) +test_x11_component(x11_components xcb_xtest) +test_x11_component(x11_components xcb_keysyms) test_x11_component(x11_components xcb_xkb) test_x11_component(x11_components Xcomposite) test_x11_component(x11_components Xdamage) diff --git a/Tests/FindX11/Test/main.c b/Tests/FindX11/Test/main.c index ce6f224..653a2be 100644 --- a/Tests/FindX11/Test/main.c +++ b/Tests/FindX11/Test/main.c @@ -376,6 +376,34 @@ static void test_xcb_xfixes(void) # endif +# ifdef HAVE_xcb_xtest +# include <xcb/xtest.h> + +static void test_xcb_xtest(void) +{ + int screen_nbr; + xcb_connection_t* connection = xcb_connect(NULL, &screen_nbr); + xcb_test_get_version_unchecked(connection, 1, 0); + xcb_disconnect(connection); +} + +# endif + +# ifdef HAVE_xcb_keysyms +# include <xcb/xcb_keysyms.h> + +static void test_xcb_keysyms(void) +{ + int screen_nbr; + xcb_connection_t* connection = xcb_connect(NULL, &screen_nbr); + xcb_key_symbols_t* symbols = xcb_key_symbols_alloc(connection); + if (symbols != NULL) + xcb_key_symbols_free(symbols); + xcb_disconnect(connection); +} + +# endif + #endif #include <stddef.h> diff --git a/Tests/RunCMake/CTestCommandLine/RunCMakeTest.cmake b/Tests/RunCMake/CTestCommandLine/RunCMakeTest.cmake index 5b198bd..6835834 100644 --- a/Tests/RunCMake/CTestCommandLine/RunCMakeTest.cmake +++ b/Tests/RunCMake/CTestCommandLine/RunCMakeTest.cmake @@ -293,7 +293,7 @@ function(run_TestOutputTruncation mode expected) endfunction() run_TestOutputTruncation("head" "\\.\\.\\.6789") run_TestOutputTruncation("middle" "12\\.\\.\\..*\\.\\.\\.89") -run_TestOutputTruncation("tail" "12345\.\.\.") +run_TestOutputTruncation("tail" "12345\\.\\.\\.") # Test --stop-on-failure function(run_stop_on_failure) diff --git a/Tests/RunCMake/CUDA_architectures/RunCMakeTest.cmake b/Tests/RunCMake/CUDA_architectures/RunCMakeTest.cmake index 6fecae7..e37d025 100644 --- a/Tests/RunCMake/CUDA_architectures/RunCMakeTest.cmake +++ b/Tests/RunCMake/CUDA_architectures/RunCMakeTest.cmake @@ -2,6 +2,7 @@ include(RunCMake) run_cmake(architectures-all) run_cmake(architectures-all-major) +run_cmake(architectures-native) run_cmake(architectures-empty) run_cmake(architectures-invalid) diff --git a/Tests/RunCMake/CUDA_architectures/architectures-all-major-stdout.txt b/Tests/RunCMake/CUDA_architectures/architectures-all-major-stdout.txt index c5cde8f..ee0a5f7 100644 --- a/Tests/RunCMake/CUDA_architectures/architectures-all-major-stdout.txt +++ b/Tests/RunCMake/CUDA_architectures/architectures-all-major-stdout.txt @@ -1,3 +1,4 @@ -- CMAKE_CUDA_ARCHITECTURES='all-major' -- CMAKE_CUDA_ARCHITECTURES_ALL='[0-9;]+' -- CMAKE_CUDA_ARCHITECTURES_ALL_MAJOR='[0-9;]+' +-- CMAKE_CUDA_ARCHITECTURES_NATIVE='[0-9;]+' diff --git a/Tests/RunCMake/CUDA_architectures/architectures-all-major.cmake b/Tests/RunCMake/CUDA_architectures/architectures-all-major.cmake index 5112473..7203c98 100644 --- a/Tests/RunCMake/CUDA_architectures/architectures-all-major.cmake +++ b/Tests/RunCMake/CUDA_architectures/architectures-all-major.cmake @@ -3,3 +3,4 @@ enable_language(CUDA) message(STATUS "CMAKE_CUDA_ARCHITECTURES='${CMAKE_CUDA_ARCHITECTURES}'") message(STATUS "CMAKE_CUDA_ARCHITECTURES_ALL='${CMAKE_CUDA_ARCHITECTURES_ALL}'") message(STATUS "CMAKE_CUDA_ARCHITECTURES_ALL_MAJOR='${CMAKE_CUDA_ARCHITECTURES_ALL_MAJOR}'") +message(STATUS "CMAKE_CUDA_ARCHITECTURES_NATIVE='${CMAKE_CUDA_ARCHITECTURES_NATIVE}'") diff --git a/Tests/RunCMake/CUDA_architectures/architectures-all-stdout.txt b/Tests/RunCMake/CUDA_architectures/architectures-all-stdout.txt index aba26b9..fd738e4 100644 --- a/Tests/RunCMake/CUDA_architectures/architectures-all-stdout.txt +++ b/Tests/RunCMake/CUDA_architectures/architectures-all-stdout.txt @@ -1,3 +1,4 @@ -- CMAKE_CUDA_ARCHITECTURES='all' -- CMAKE_CUDA_ARCHITECTURES_ALL='[0-9;]+' -- CMAKE_CUDA_ARCHITECTURES_ALL_MAJOR='[0-9;]+' +-- CMAKE_CUDA_ARCHITECTURES_NATIVE='[0-9;]+' diff --git a/Tests/RunCMake/CUDA_architectures/architectures-all.cmake b/Tests/RunCMake/CUDA_architectures/architectures-all.cmake index 32175f6..0c3a4e9 100644 --- a/Tests/RunCMake/CUDA_architectures/architectures-all.cmake +++ b/Tests/RunCMake/CUDA_architectures/architectures-all.cmake @@ -3,3 +3,4 @@ enable_language(CUDA) message(STATUS "CMAKE_CUDA_ARCHITECTURES='${CMAKE_CUDA_ARCHITECTURES}'") message(STATUS "CMAKE_CUDA_ARCHITECTURES_ALL='${CMAKE_CUDA_ARCHITECTURES_ALL}'") message(STATUS "CMAKE_CUDA_ARCHITECTURES_ALL_MAJOR='${CMAKE_CUDA_ARCHITECTURES_ALL_MAJOR}'") +message(STATUS "CMAKE_CUDA_ARCHITECTURES_NATIVE='${CMAKE_CUDA_ARCHITECTURES_NATIVE}'") diff --git a/Tests/RunCMake/CUDA_architectures/architectures-native-stdout.txt b/Tests/RunCMake/CUDA_architectures/architectures-native-stdout.txt new file mode 100644 index 0000000..af49e00 --- /dev/null +++ b/Tests/RunCMake/CUDA_architectures/architectures-native-stdout.txt @@ -0,0 +1,4 @@ +-- CMAKE_CUDA_ARCHITECTURES='native' +-- CMAKE_CUDA_ARCHITECTURES_ALL='[0-9;]+' +-- CMAKE_CUDA_ARCHITECTURES_ALL_MAJOR='[0-9;]+' +-- CMAKE_CUDA_ARCHITECTURES_NATIVE='[0-9;]+' diff --git a/Tests/RunCMake/CUDA_architectures/architectures-native.cmake b/Tests/RunCMake/CUDA_architectures/architectures-native.cmake new file mode 100644 index 0000000..64afe13 --- /dev/null +++ b/Tests/RunCMake/CUDA_architectures/architectures-native.cmake @@ -0,0 +1,6 @@ +set(CMAKE_CUDA_ARCHITECTURES "native") +enable_language(CUDA) +message(STATUS "CMAKE_CUDA_ARCHITECTURES='${CMAKE_CUDA_ARCHITECTURES}'") +message(STATUS "CMAKE_CUDA_ARCHITECTURES_ALL='${CMAKE_CUDA_ARCHITECTURES_ALL}'") +message(STATUS "CMAKE_CUDA_ARCHITECTURES_ALL_MAJOR='${CMAKE_CUDA_ARCHITECTURES_ALL_MAJOR}'") +message(STATUS "CMAKE_CUDA_ARCHITECTURES_NATIVE='${CMAKE_CUDA_ARCHITECTURES_NATIVE}'") diff --git a/Tests/RunCMake/CommandLine/P_arbitrary_args-stdout.txt b/Tests/RunCMake/CommandLine/P_arbitrary_args-stdout.txt new file mode 100644 index 0000000..c0f96f3 --- /dev/null +++ b/Tests/RunCMake/CommandLine/P_arbitrary_args-stdout.txt @@ -0,0 +1,8 @@ +^-- CMAKE_ARGC='7' +-- CMAKE_ARGV1='-P' +-- CMAKE_ARGV2='[^']*/Tests/RunCMake/CommandLine/P_arbitrary_args.cmake' +-- CMAKE_ARGV3='--' +-- CMAKE_ARGV4='-DFOO' +-- CMAKE_ARGV5='-S' +-- CMAKE_ARGV6='-B' +-- CMAKE_ARGV7=''$ diff --git a/Tests/RunCMake/CommandLine/P_arbitrary_args.cmake b/Tests/RunCMake/CommandLine/P_arbitrary_args.cmake index 29faae3..d0a4859 100644 --- a/Tests/RunCMake/CommandLine/P_arbitrary_args.cmake +++ b/Tests/RunCMake/CommandLine/P_arbitrary_args.cmake @@ -1,3 +1,8 @@ -if(NOT ("${CMAKE_ARGV3}" STREQUAL "--" AND "${CMAKE_ARGV4}" STREQUAL "-DFOO")) - message(FATAL_ERROR "`-DFOO` shouldn't trigger an error after `--`") -endif() +message(STATUS "CMAKE_ARGC='${CMAKE_ARGC}'") +message(STATUS "CMAKE_ARGV1='${CMAKE_ARGV1}'") +message(STATUS "CMAKE_ARGV2='${CMAKE_ARGV2}'") +message(STATUS "CMAKE_ARGV3='${CMAKE_ARGV3}'") +message(STATUS "CMAKE_ARGV4='${CMAKE_ARGV4}'") +message(STATUS "CMAKE_ARGV5='${CMAKE_ARGV5}'") +message(STATUS "CMAKE_ARGV6='${CMAKE_ARGV6}'") +message(STATUS "CMAKE_ARGV7='${CMAKE_ARGV7}'") diff --git a/Tests/RunCMake/CommandLine/RunCMakeTest.cmake b/Tests/RunCMake/CommandLine/RunCMakeTest.cmake index 5b8c715..22a59f2 100644 --- a/Tests/RunCMake/CommandLine/RunCMakeTest.cmake +++ b/Tests/RunCMake/CommandLine/RunCMakeTest.cmake @@ -52,7 +52,7 @@ run_cmake_command(G_no-arg ${CMAKE_COMMAND} -B DummyBuildDir -G) run_cmake_command(G_bad-arg ${CMAKE_COMMAND} -B DummyBuildDir -G NoSuchGenerator) run_cmake_command(P_no-arg ${CMAKE_COMMAND} -P) run_cmake_command(P_no-file ${CMAKE_COMMAND} -P nosuchscriptfile.cmake) -run_cmake_command(P_arbitrary_args ${CMAKE_COMMAND} -P "${RunCMake_SOURCE_DIR}/P_arbitrary_args.cmake" -- -DFOO) +run_cmake_command(P_arbitrary_args ${CMAKE_COMMAND} -P "${RunCMake_SOURCE_DIR}/P_arbitrary_args.cmake" -- -DFOO -S -B) run_cmake_command(build-no-dir ${CMAKE_COMMAND} --build) @@ -180,7 +180,7 @@ message(STATUS "CMAKE_BINARY_DIR='${CMAKE_BINARY_DIR}'") run_cmake_with_options(ExplicitDirs-S-S-same -S ${source_dir} -S ${source_dir} -B ${binary_dir}) run_cmake_with_options(ExplicitDirs-S-S-differs -S ${binary_dir}/other_dir -S ${source_dir} -B ${binary_dir}) run_cmake_with_options(ExplicitDirs-S-implicit-same -S ${source_dir} ${source_dir} -B ${binary_dir}) - run_cmake_with_options(ExplicitDirs-S-implicit-differs -S ${source_dir} ${binary_dir}/other_dir -B ${binary_dir}) + run_cmake_with_options(ExplicitDirs-S-implicit-differs -S ${binary_dir}/other_dir ${source_dir} -B ${binary_dir}) run_cmake_with_options(ExplicitDirs-S-implicit-differs2 ${binary_dir}/other_dir -S ${source_dir} -B ${binary_dir}) run_cmake_with_options(ExplicitDirs-S-implicit-differs3 ${binary_dir}/other_dir ${source_dir} -B ${binary_dir}) run_cmake_with_options(ExplicitDirs-S-S-Sdiffers -S ${binary_dir}/other_dir1 -S ${binary_dir}/other_dir2 -S ${source_dir} -B ${binary_dir}) diff --git a/Tests/RunCMake/RunCMake.cmake b/Tests/RunCMake/RunCMake.cmake index 3066cc1..1f43ee0 100644 --- a/Tests/RunCMake/RunCMake.cmake +++ b/Tests/RunCMake/RunCMake.cmake @@ -153,6 +153,7 @@ function(run_cmake test) "|BullseyeCoverage" "|[a-z]+\\([0-9]+\\) malloc:" "|clang[^:]*: warning: the object size sanitizer has no effect at -O0, but is explicitly enabled:" + "|lld-link: warning: procedure symbol record for .* refers to PDB item index [0-9A-Fa-fx]+ which is not a valid function ID record" "|Error kstat returned" "|Hit xcodebuild bug" "|Recompacting log\\.\\.\\." diff --git a/Tests/RunCMake/find_package/GlobalImportTarget-stdout.txt b/Tests/RunCMake/find_package/GlobalImportTarget-stdout.txt new file mode 100644 index 0000000..bd06873 --- /dev/null +++ b/Tests/RunCMake/find_package/GlobalImportTarget-stdout.txt @@ -0,0 +1,31 @@ +-- IMPORTED TARGET imported_local_target has GLOBAL scope: TRUE +-- IMPORTED TARGET imported_global_target has GLOBAL scope: TRUE +-- IMPORTED TARGET imported_local_ex has GLOBAL scope: TRUE +-- IMPORTED TARGET imported_global_ex has GLOBAL scope: TRUE +-- IMPORTED TARGET Foo1 has GLOBAL scope: TRUE +-- IMPORTED TARGET Foo2 has GLOBAL scope: TRUE +-- IMPORTED TARGET imported_var_local_target has GLOBAL scope: TRUE +-- IMPORTED TARGET imported_var_global_target has GLOBAL scope: TRUE +-- IMPORTED TARGET imported_var_local_ex has GLOBAL scope: TRUE +-- IMPORTED TARGET imported_var_global_ex has GLOBAL scope: TRUE +-- IMPORTED TARGET imported_global_lib has GLOBAL scope: TRUE +-- IMPORTED TARGET imported_explicit_global_ex has GLOBAL scope: TRUE +-- IMPORTED TARGET imported_local_lib has GLOBAL scope: FALSE +-- IMPORTED TARGET imported_implied_local_ex has GLOBAL scope: FALSE +-- IMPORTED TARGET imported_no_var_local_target has GLOBAL scope: TRUE +-- IMPORTED TARGET imported_no_var_global_target has GLOBAL scope: TRUE +-- IMPORTED TARGET imported_no_var_local_ex has GLOBAL scope: TRUE +-- IMPORTED TARGET imported_no_var_global_ex has GLOBAL scope: TRUE +-- IMPORTED TARGET not_imported_not_global has GLOBAL scope: FALSE +-- IMPORTED TARGET PackName has GLOBAL scope: TRUE +-- IMPORTED TARGET PackNameExe has GLOBAL scope: TRUE +-- IMPORTED TARGET PackName1 has GLOBAL scope: TRUE +-- IMPORTED TARGET PackNameExe1 has GLOBAL scope: TRUE +-- IMPORTED TARGET local_lib_glob has GLOBAL scope: TRUE +-- IMPORTED TARGET local_exe_glob has GLOBAL scope: TRUE +-- IMPORTED TARGET local_lib has GLOBAL scope: FALSE +-- IMPORTED TARGET local_exe has GLOBAL scope: FALSE +-- IMPORTED TARGET LT1 has GLOBAL scope: TRUE +-- IMPORTED TARGET LT2 has GLOBAL scope: TRUE +-- IMPORTED TARGET LT3 has GLOBAL scope: TRUE +-- IMPORTED TARGET LT4 has GLOBAL scope: TRUE diff --git a/Tests/RunCMake/find_package/GlobalImportTarget.cmake b/Tests/RunCMake/find_package/GlobalImportTarget.cmake new file mode 100644 index 0000000..7e6d2b8 --- /dev/null +++ b/Tests/RunCMake/find_package/GlobalImportTarget.cmake @@ -0,0 +1,57 @@ +function (assess_target_property target) + get_target_property(target_val "${target}" IMPORTED_GLOBAL) + message(STATUS "IMPORTED TARGET ${target} has GLOBAL scope: ${target_val}") +endfunction () + +list(INSERT CMAKE_MODULE_PATH 0 ${CMAKE_CURRENT_SOURCE_DIR}/PackageRoot) + +find_package(GlobalTarget GLOBAL REQUIRED) +assess_target_property(imported_local_target) +assess_target_property(imported_global_target) +assess_target_property(imported_local_ex) +assess_target_property(imported_global_ex) +assess_target_property(Foo1) +assess_target_property(Foo2) + +set(CMAKE_FIND_PACKAGE_TARGETS_GLOBAL TRUE) +find_package(GlobalVarTarget) +assess_target_property(imported_var_local_target) +assess_target_property(imported_var_global_target) +assess_target_property(imported_var_local_ex) +assess_target_property(imported_var_global_ex) +set(CMAKE_FIND_PACKAGE_TARGETS_GLOBAL OFF) + +find_package(LocalTarget) +assess_target_property(imported_global_lib) +assess_target_property(imported_explicit_global_ex) +assess_target_property(imported_local_lib) +assess_target_property(imported_implied_local_ex) + +find_package(GlobalTargetNoVar GLOBAL) +assess_target_property(imported_no_var_local_target) +assess_target_property(imported_no_var_global_target) +assess_target_property(imported_no_var_local_ex) +assess_target_property(imported_no_var_global_ex) +assess_target_property(not_imported_not_global) + +set(Baz_DIR "${CMAKE_CURRENT_SOURCE_DIR}/PackageRoot") +find_package(Baz GLOBAL REQUIRED) +assess_target_property(PackName) +assess_target_property(PackNameExe) +assess_target_property(PackName1) +assess_target_property(PackNameExe1) + +set(Biz_DIR "${CMAKE_CURRENT_SOURCE_DIR}/PackageRoot") +find_package(Biz REQUIRED) +assess_target_property(local_lib_glob) +assess_target_property(local_exe_glob) +assess_target_property(local_lib) +assess_target_property(local_exe) + +set(CMAKE_FIND_PACKAGE_TARGETS_GLOBAL TRUE) +set(Simple_DIR "${CMAKE_CURRENT_SOURCE_DIR}/PackageRoot") +find_package(Simple REQUIRED) +assess_target_property(LT1) +assess_target_property(LT2) +assess_target_property(LT3) +assess_target_property(LT4) diff --git a/Tests/RunCMake/find_package/PackageRoot/BazConfig.cmake b/Tests/RunCMake/find_package/PackageRoot/BazConfig.cmake new file mode 100644 index 0000000..cca95a2 --- /dev/null +++ b/Tests/RunCMake/find_package/PackageRoot/BazConfig.cmake @@ -0,0 +1,3 @@ +include(CMakeFindDependencyMacro) + +find_dependency(PackName PATHS ${CMAKE_CURRENT_LIST_DIR}) diff --git a/Tests/RunCMake/find_package/PackageRoot/BizConfig.cmake b/Tests/RunCMake/find_package/PackageRoot/BizConfig.cmake new file mode 100644 index 0000000..5b0e398 --- /dev/null +++ b/Tests/RunCMake/find_package/PackageRoot/BizConfig.cmake @@ -0,0 +1,3 @@ +include(CMakeFindDependencyMacro) + +find_dependency(LocalPack PATHS ${CMAKE_CURRENT_LIST_DIR}) diff --git a/Tests/RunCMake/find_package/PackageRoot/FindGlobalTarget.cmake b/Tests/RunCMake/find_package/PackageRoot/FindGlobalTarget.cmake new file mode 100644 index 0000000..9e34613 --- /dev/null +++ b/Tests/RunCMake/find_package/PackageRoot/FindGlobalTarget.cmake @@ -0,0 +1,7 @@ +add_library(imported_global_target SHARED IMPORTED GLOBAL) +add_executable(imported_global_ex IMPORTED GLOBAL) + +add_library(imported_local_target SHARED IMPORTED) +add_executable(imported_local_ex IMPORTED) + +find_package(SimpleTarget) diff --git a/Tests/RunCMake/find_package/PackageRoot/FindGlobalTargetNoVar.cmake b/Tests/RunCMake/find_package/PackageRoot/FindGlobalTargetNoVar.cmake new file mode 100644 index 0000000..a156f90 --- /dev/null +++ b/Tests/RunCMake/find_package/PackageRoot/FindGlobalTargetNoVar.cmake @@ -0,0 +1,7 @@ +add_library(imported_no_var_global_target SHARED IMPORTED GLOBAL) +add_executable(imported_no_var_global_ex IMPORTED GLOBAL) + +add_library(imported_no_var_local_target SHARED IMPORTED) +add_executable(imported_no_var_local_ex IMPORTED) + +add_library(not_imported_not_global INTERFACE) diff --git a/Tests/RunCMake/find_package/PackageRoot/FindGlobalVarTarget.cmake b/Tests/RunCMake/find_package/PackageRoot/FindGlobalVarTarget.cmake new file mode 100644 index 0000000..2e96a6c --- /dev/null +++ b/Tests/RunCMake/find_package/PackageRoot/FindGlobalVarTarget.cmake @@ -0,0 +1,5 @@ +add_library(imported_var_global_target SHARED IMPORTED GLOBAL) +add_executable(imported_var_global_ex IMPORTED GLOBAL) + +add_library(imported_var_local_target SHARED IMPORTED) +add_executable(imported_var_local_ex IMPORTED) diff --git a/Tests/RunCMake/find_package/PackageRoot/FindLocalTarget.cmake b/Tests/RunCMake/find_package/PackageRoot/FindLocalTarget.cmake new file mode 100644 index 0000000..d533405 --- /dev/null +++ b/Tests/RunCMake/find_package/PackageRoot/FindLocalTarget.cmake @@ -0,0 +1,5 @@ +add_library(imported_global_lib SHARED IMPORTED GLOBAL) +add_executable(imported_explicit_global_ex IMPORTED GLOBAL) + +add_library(imported_local_lib SHARED IMPORTED) +add_executable(imported_implied_local_ex IMPORTED) diff --git a/Tests/RunCMake/find_package/PackageRoot/FindSimpleTarget.cmake b/Tests/RunCMake/find_package/PackageRoot/FindSimpleTarget.cmake new file mode 100644 index 0000000..cd58004 --- /dev/null +++ b/Tests/RunCMake/find_package/PackageRoot/FindSimpleTarget.cmake @@ -0,0 +1,2 @@ +add_library(Foo1 SHARED IMPORTED) +add_executable(Foo2 IMPORTED) diff --git a/Tests/RunCMake/find_package/PackageRoot/LTConfig.cmake b/Tests/RunCMake/find_package/PackageRoot/LTConfig.cmake new file mode 100644 index 0000000..f451eb6 --- /dev/null +++ b/Tests/RunCMake/find_package/PackageRoot/LTConfig.cmake @@ -0,0 +1,5 @@ +add_library(LT1 INTERFACE IMPORTED) +add_executable(LT2 IMPORTED) + +add_library(LT3 INTERFACE IMPORTED GLOBAL) +add_executable(LT4 IMPORTED GLOBAL) diff --git a/Tests/RunCMake/find_package/PackageRoot/LocalPackConfig.cmake b/Tests/RunCMake/find_package/PackageRoot/LocalPackConfig.cmake new file mode 100644 index 0000000..a962849 --- /dev/null +++ b/Tests/RunCMake/find_package/PackageRoot/LocalPackConfig.cmake @@ -0,0 +1,5 @@ +add_library(local_lib_glob SHARED IMPORTED GLOBAL) +add_executable(local_exe_glob IMPORTED GLOBAL) + +add_library(local_lib SHARED IMPORTED) +add_executable(local_exe IMPORTED) diff --git a/Tests/RunCMake/find_package/PackageRoot/PackNameConfig.cmake b/Tests/RunCMake/find_package/PackageRoot/PackNameConfig.cmake new file mode 100644 index 0000000..38dd2f8 --- /dev/null +++ b/Tests/RunCMake/find_package/PackageRoot/PackNameConfig.cmake @@ -0,0 +1,5 @@ +add_library(PackName INTERFACE IMPORTED GLOBAL) +add_executable(PackNameExe IMPORTED GLOBAL) + +add_library(PackName1 INTERFACE IMPORTED) +add_executable(PackNameExe1 IMPORTED) diff --git a/Tests/RunCMake/find_package/PackageRoot/SimpleConfig.cmake b/Tests/RunCMake/find_package/PackageRoot/SimpleConfig.cmake new file mode 100644 index 0000000..44059c6 --- /dev/null +++ b/Tests/RunCMake/find_package/PackageRoot/SimpleConfig.cmake @@ -0,0 +1,3 @@ +include(CMakeFindDependencyMacro) + +find_dependency(LT PATHS ${CMAKE_CURRENT_LIST_DIR}) diff --git a/Tests/RunCMake/find_package/RunCMakeTest.cmake b/Tests/RunCMake/find_package/RunCMakeTest.cmake index 5f4c6cb..2b5fb1f 100644 --- a/Tests/RunCMake/find_package/RunCMakeTest.cmake +++ b/Tests/RunCMake/find_package/RunCMakeTest.cmake @@ -6,6 +6,7 @@ run_cmake(ComponentRequiredAndOptional) run_cmake(FromPATHEnv) run_cmake_with_options(FromPATHEnvDebugPkg --debug-find-pkg=Resolved) run_cmake(FromPrefixPath) +run_cmake(GlobalImportTarget) run_cmake(MissingNormal) run_cmake(MissingNormalForceRequired) run_cmake(MissingNormalRequired) diff --git a/Utilities/Release/win/x86/Dockerfile b/Utilities/Release/win/x86/Dockerfile index a4f7445..d5a036a 100644 --- a/Utilities/Release/win/x86/Dockerfile +++ b/Utilities/Release/win/x86/Dockerfile @@ -11,8 +11,10 @@ ARG FROM_IMAGE_NAME=kitware/cmake:build-win-x86-deps-2020-04-27 ARG FROM_IMAGE_DIGEST=@sha256:04e229c0c0ba2247855d0e8c0fb87c1686f983adbafa4ce413e61b3905edb76b ARG FROM_IMAGE=$FROM_IMAGE_NAME$FROM_IMAGE_DIGEST -FROM $FROM_IMAGE as build +FROM $FROM_IMAGE as source COPY . C:\cmake\src\cmake + +FROM source as build ARG ARCH="x86_64" ARG TEST="true" RUN \cmake\src\cmake\Utilities\Release\win\x86\build.bat %ARCH% %TEST% |