diff options
48 files changed, 525 insertions, 124 deletions
diff --git a/.gitlab/ci/configure_cuda12.2_clang.cmake b/.gitlab/ci/configure_cuda12.2_clang.cmake index e13ca88..8f10f86 100644 --- a/.gitlab/ci/configure_cuda12.2_clang.cmake +++ b/.gitlab/ci/configure_cuda12.2_clang.cmake @@ -1,3 +1,4 @@ set(CMake_TEST_CUDA "Clang" CACHE STRING "") +set(CMake_TEST_CUDA_STANDARDS "03;11;14;17;20;23" CACHE STRING "") include("${CMAKE_CURRENT_LIST_DIR}/configure_external_test.cmake") diff --git a/.gitlab/ci/configure_cuda12.2_nvidia.cmake b/.gitlab/ci/configure_cuda12.2_nvidia.cmake index 2cb2950..51a2511 100644 --- a/.gitlab/ci/configure_cuda12.2_nvidia.cmake +++ b/.gitlab/ci/configure_cuda12.2_nvidia.cmake @@ -1,4 +1,5 @@ set(CMake_TEST_CUDA "NVIDIA" CACHE STRING "") set(CMake_TEST_CUDA_CUPTI "ON" CACHE STRING "") +set(CMake_TEST_CUDA_STANDARDS "03;11;14;17;20" CACHE STRING "") include("${CMAKE_CURRENT_LIST_DIR}/configure_external_test.cmake") diff --git a/Help/envvar/OBJCFLAGS.rst b/Help/envvar/OBJCFLAGS.rst new file mode 100644 index 0000000..2f30807 --- /dev/null +++ b/Help/envvar/OBJCFLAGS.rst @@ -0,0 +1,14 @@ +OBJCFLAGS +--------- + +.. versionadded:: 3.16 + +.. include:: ENV_VAR.txt + +Add default compilation flags to be used when compiling ``Objective C`` files. + +.. |CMAKE_LANG_FLAGS| replace:: :variable:`CMAKE_OBJC_FLAGS <CMAKE_<LANG>_FLAGS>` +.. |LANG| replace:: ``OBJC`` +.. include:: LANG_FLAGS.txt + +See also :variable:`CMAKE_OBJC_FLAGS_INIT <CMAKE_<LANG>_FLAGS_INIT>`. diff --git a/Help/envvar/OBJCXXFLAGS.rst b/Help/envvar/OBJCXXFLAGS.rst new file mode 100644 index 0000000..089222a --- /dev/null +++ b/Help/envvar/OBJCXXFLAGS.rst @@ -0,0 +1,14 @@ +OBJCXXFLAGS +----------- + +.. versionadded:: 3.16 + +.. include:: ENV_VAR.txt + +Add default compilation flags to be used when compiling ``Objective C++`` (.mm) files. + +.. |CMAKE_LANG_FLAGS| replace:: :variable:`CMAKE_OBJCXX_FLAGS <CMAKE_<LANG>_FLAGS>` +.. |LANG| replace:: ``OBJCXX`` +.. include:: LANG_FLAGS.txt + +See also :variable:`CMAKE_OBJCXX_FLAGS_INIT <CMAKE_<LANG>_FLAGS_INIT>`. diff --git a/Help/manual/cmake-cxxmodules.7.rst b/Help/manual/cmake-cxxmodules.7.rst index 8f4ff44..840d65f 100644 --- a/Help/manual/cmake-cxxmodules.7.rst +++ b/Help/manual/cmake-cxxmodules.7.rst @@ -96,6 +96,9 @@ library combinations: * MSVC toolset 14.36 and newer (provided with Visual Studio 17.6 Preview 2 and newer) +The :variable:`CMAKE_CXX_COMPILER_IMPORT_STD` variable may be used to detect +support for a standard level with the active C++ toolchain. + .. note :: This support is provided only when experimental support for diff --git a/Help/manual/cmake-env-variables.7.rst b/Help/manual/cmake-env-variables.7.rst index e693e4c..a69ace6 100644 --- a/Help/manual/cmake-env-variables.7.rst +++ b/Help/manual/cmake-env-variables.7.rst @@ -92,7 +92,9 @@ Environment Variables for Languages /envvar/ISPC /envvar/ISPCFLAGS /envvar/OBJC + /envvar/OBJCFLAGS /envvar/OBJCXX + /envvar/OBJCXXFLAGS /envvar/RC /envvar/RCFLAGS /envvar/SWIFTC diff --git a/Help/manual/cmake-variables.7.rst b/Help/manual/cmake-variables.7.rst index 6ae7d1c..92da82a 100644 --- a/Help/manual/cmake-variables.7.rst +++ b/Help/manual/cmake-variables.7.rst @@ -580,6 +580,7 @@ Variables for Languages /variable/CMAKE_CUDA_STANDARD_REQUIRED /variable/CMAKE_CUDA_TOOLKIT_INCLUDE_DIRECTORIES /variable/CMAKE_CXX_COMPILE_FEATURES + /variable/CMAKE_CXX_COMPILER_IMPORT_STD /variable/CMAKE_CXX_EXTENSIONS /variable/CMAKE_CXX_STANDARD /variable/CMAKE_CXX_STANDARD_REQUIRED diff --git a/Help/prop_tgt/OBJC_STANDARD.rst b/Help/prop_tgt/OBJC_STANDARD.rst index 0609239..a3c5653 100644 --- a/Help/prop_tgt/OBJC_STANDARD.rst +++ b/Help/prop_tgt/OBJC_STANDARD.rst @@ -20,6 +20,16 @@ Supported values are: ``11`` Objective C11 +``17`` + .. versionadded:: 3.21 + + Objective C17 + +``23`` + .. versionadded:: 3.21 + + Objective C23 + If the value requested does not result in a compile flag being added for the compiler in use, a previous standard flag will be added instead. This means that using: diff --git a/Help/variable/CMAKE_CXX_COMPILER_IMPORT_STD.rst b/Help/variable/CMAKE_CXX_COMPILER_IMPORT_STD.rst new file mode 100644 index 0000000..384b5eb --- /dev/null +++ b/Help/variable/CMAKE_CXX_COMPILER_IMPORT_STD.rst @@ -0,0 +1,14 @@ +CMAKE_CXX_COMPILER_IMPORT_STD +----------------------------- + +.. versionadded:: 3.30 + +A list of C++ standard levels for which ``import std`` support exists for the +current C++ toolchain. Support for C++\<NN\> may be detected using a +``<NN> IN_LIST CMAKE_CXX_COMPILER_IMPORT_STD`` predicate with the +:command:`if` command. + +.. note :: + + This variable is meaningful only when experimental support for ``import + std;`` has been enabled by the ``CMAKE_EXPERIMENTAL_CXX_IMPORT_STD`` gate. diff --git a/Help/variable/CMAKE_INSTALL_PREFIX_INITIALIZED_TO_DEFAULT.rst b/Help/variable/CMAKE_INSTALL_PREFIX_INITIALIZED_TO_DEFAULT.rst index 316fea2..9d34170 100644 --- a/Help/variable/CMAKE_INSTALL_PREFIX_INITIALIZED_TO_DEFAULT.rst +++ b/Help/variable/CMAKE_INSTALL_PREFIX_INITIALIZED_TO_DEFAULT.rst @@ -13,5 +13,5 @@ by project code to change the default without overriding a user-provided value: .. code-block:: cmake if(CMAKE_INSTALL_PREFIX_INITIALIZED_TO_DEFAULT) - set(CMAKE_INSTALL_PREFIX "/my/default" CACHE PATH "..." FORCE) + set_property(CACHE CMAKE_INSTALL_PREFIX PROPERTY VALUE "/my/default") endif() diff --git a/Help/variable/CMAKE_LANG_FLAGS.rst b/Help/variable/CMAKE_LANG_FLAGS.rst index 909a001..4f8f469 100644 --- a/Help/variable/CMAKE_LANG_FLAGS.rst +++ b/Help/variable/CMAKE_LANG_FLAGS.rst @@ -24,6 +24,10 @@ combination with CMake's builtin defaults for the toolchain: Initialized by the :envvar:`HIPFLAGS` environment variable. * ``CMAKE_ISPC_FLAGS``: Initialized by the :envvar:`ISPCFLAGS` environment variable. +* ``CMAKE_OBJC_FLAGS``: + Initialized by the :envvar:`OBJCFLAGS` environment variable. +* ``CMAKE_OBJCXX_FLAGS``: + Initialized by the :envvar:`OBJCXXFLAGS` environment variable. This value is a command-line string fragment. Therefore, multiple options should be separated by spaces, and options with spaces should be quoted. diff --git a/Modules/CMakeCUDACompilerId.cu.in b/Modules/CMakeCUDACompilerId.cu.in index d5a3b03..cecb948 100644 --- a/Modules/CMakeCUDACompilerId.cu.in +++ b/Modules/CMakeCUDACompilerId.cu.in @@ -16,16 +16,34 @@ char const* info_simulate = "INFO" ":" "simulate[" SIMULATE_ID "]"; @CMAKE_CUDA_COMPILER_ID_PLATFORM_CONTENT@ @CMAKE_CUDA_COMPILER_ID_ERROR_FOR_TEST@ +#define CXX_STD_11 201103L +#define CXX_STD_14 201402L +#define CXX_STD_17 201703L +#define CXX_STD_20 202002L +#define CXX_STD_23 202302L + +#if defined(_MSC_VER) && defined(_MSVC_LANG) +# if _MSVC_LANG > __cplusplus +# define CXX_STD _MSVC_LANG +# else +# define CXX_STD __cplusplus +# endif +#else +# define CXX_STD __cplusplus +#endif + const char* info_language_standard_default = "INFO" ":" "standard_default[" -#if __cplusplus > 202002L +#if CXX_STD > CXX_STD_23 + "26" +#elif CXX_STD > CXX_STD_20 "23" -#elif __cplusplus > 201703L +#elif CXX_STD > CXX_STD_17 "20" -#elif __cplusplus >= 201703L +#elif CXX_STD > CXX_STD_14 "17" -#elif __cplusplus >= 201402L +#elif CXX_STD > CXX_STD_11 "14" -#elif __cplusplus >= 201103L +#elif CXX_STD >= CXX_STD_11 "11" #else "03" diff --git a/Modules/CMakeCXXCompiler.cmake.in b/Modules/CMakeCXXCompiler.cmake.in index e0c5f8b..1064e7c 100644 --- a/Modules/CMakeCXXCompiler.cmake.in +++ b/Modules/CMakeCXXCompiler.cmake.in @@ -92,4 +92,5 @@ set(CMAKE_CXX_IMPLICIT_LINK_DIRECTORIES "@CMAKE_CXX_IMPLICIT_LINK_DIRECTORIES@") set(CMAKE_CXX_IMPLICIT_LINK_FRAMEWORK_DIRECTORIES "@CMAKE_CXX_IMPLICIT_LINK_FRAMEWORK_DIRECTORIES@") set(CMAKE_CXX_COMPILER_CLANG_RESOURCE_DIR "@CMAKE_CXX_COMPILER_CLANG_RESOURCE_DIR@") +set(CMAKE_CXX_COMPILER_IMPORT_STD "") @CMAKE_CXX_IMPORT_STD@ diff --git a/Modules/CMakeCXXCompilerId.cpp.in b/Modules/CMakeCXXCompilerId.cpp.in index 6df15ac..1cd8006 100644 --- a/Modules/CMakeCXXCompilerId.cpp.in +++ b/Modules/CMakeCXXCompilerId.cpp.in @@ -89,7 +89,9 @@ char const *info_cray = "INFO" ":" "compiler_wrapper[CrayPrgEnv]"; #endif const char* info_language_standard_default = "INFO" ":" "standard_default[" -#if CXX_STD > CXX_STD_20 +#if CXX_STD > CXX_STD_23 + "26" +#elif CXX_STD > CXX_STD_20 "23" #elif CXX_STD > CXX_STD_17 "20" diff --git a/Modules/CMakeHIPCompilerId.hip.in b/Modules/CMakeHIPCompilerId.hip.in index 4ac0f30..fa97667 100644 --- a/Modules/CMakeHIPCompilerId.hip.in +++ b/Modules/CMakeHIPCompilerId.hip.in @@ -16,16 +16,27 @@ char const* info_simulate = "INFO" ":" "simulate[" SIMULATE_ID "]"; @CMAKE_HIP_COMPILER_ID_PLATFORM_CONTENT@ @CMAKE_HIP_COMPILER_ID_ERROR_FOR_TEST@ +#define CXX_STD_98 199711L +#define CXX_STD_11 201103L +#define CXX_STD_14 201402L +#define CXX_STD_17 201703L +#define CXX_STD_20 202002L +#define CXX_STD_23 202302L + +#define CXX_STD __cplusplus + const char* info_language_standard_default = "INFO" ":" "standard_default[" -#if __cplusplus > 202002L +#if CXX_STD > CXX_STD_23 + "26" +#elif CXX_STD > CXX_STD_20 "23" -#elif __cplusplus > 201703L +#elif CXX_STD > CXX_STD_17 "20" -#elif __cplusplus >= 201703L +#elif CXX_STD > CXX_STD_14 "17" -#elif __cplusplus >= 201402L +#elif CXX_STD > CXX_STD_11 "14" -#elif __cplusplus >= 201103L +#elif CXX_STD >= CXX_STD_11 "11" #else "98" diff --git a/Modules/CMakeOBJCCompilerId.m.in b/Modules/CMakeOBJCCompilerId.m.in index 89bfe02..e88bb6f 100644 --- a/Modules/CMakeOBJCCompilerId.m.in +++ b/Modules/CMakeOBJCCompilerId.m.in @@ -20,20 +20,28 @@ char const* qnxnto = "INFO" ":" "qnxnto[]"; @CMAKE_OBJC_COMPILER_ID_PLATFORM_CONTENT@ @CMAKE_OBJC_COMPILER_ID_ERROR_FOR_TEST@ +#define C_STD_99 199901L +#define C_STD_11 201112L +#define C_STD_17 201710L +#define C_STD_23 202311L + +#ifdef __STDC_VERSION__ +# define C_STD __STDC_VERSION__ +#endif + #if !defined(__STDC__) -# if (defined(_MSC_VER) && !defined(__clang__)) \ - || (defined(__ibmxl__) || defined(__IBMC__)) +# if defined(__ibmxl__) || defined(__IBMC__) # define C_VERSION "90" # else # define C_VERSION # endif -#elif __STDC_VERSION__ > 201710L +#elif C_STD > C_STD_17 # define C_VERSION "23" -#elif __STDC_VERSION__ >= 201710L +#elif C_STD > C_STD_11 # define C_VERSION "17" -#elif __STDC_VERSION__ >= 201000L +#elif C_STD > C_STD_99 # define C_VERSION "11" -#elif __STDC_VERSION__ >= 199901L +#elif C_STD >= C_STD_99 # define C_VERSION "99" #else # define C_VERSION "90" diff --git a/Modules/CMakeOBJCXXCompilerId.mm.in b/Modules/CMakeOBJCXXCompilerId.mm.in index 2145b40..cadbaff 100644 --- a/Modules/CMakeOBJCXXCompilerId.mm.in +++ b/Modules/CMakeOBJCXXCompilerId.mm.in @@ -23,22 +23,27 @@ char const* qnxnto = "INFO" ":" "qnxnto[]"; @CMAKE_OBJCXX_COMPILER_ID_PLATFORM_CONTENT@ @CMAKE_OBJCXX_COMPILER_ID_ERROR_FOR_TEST@ -#if defined(_MSC_VER) && defined(_MSVC_LANG) -#define CXX_STD _MSVC_LANG -#else +#define CXX_STD_98 199711L +#define CXX_STD_11 201103L +#define CXX_STD_14 201402L +#define CXX_STD_17 201703L +#define CXX_STD_20 202002L +#define CXX_STD_23 202302L + #define CXX_STD __cplusplus -#endif const char* info_language_standard_default = "INFO" ":" "standard_default[" -#if CXX_STD > 202002L +#if CXX_STD > CXX_STD_23 + "26" +#elif CXX_STD > CXX_STD_20 "23" -#elfif CXX_STD > 201703L +#elif CXX_STD > CXX_STD_17 "20" -#elif CXX_STD >= 201703L +#elif CXX_STD > CXX_STD_14 "17" -#elif CXX_STD >= 201402L +#elif CXX_STD > CXX_STD_11 "14" -#elif CXX_STD >= 201103L +#elif CXX_STD >= CXX_STD_11 "11" #else "98" diff --git a/Modules/CMakePackageConfigHelpers.cmake b/Modules/CMakePackageConfigHelpers.cmake index dfe1ec7..7d038d4 100644 --- a/Modules/CMakePackageConfigHelpers.cmake +++ b/Modules/CMakePackageConfigHelpers.cmake @@ -5,7 +5,7 @@ CMakePackageConfigHelpers ------------------------- -Helpers functions for creating config files that can be included by other +Helper functions for creating config files that can be included by other projects to find and use a package. Generating a Package Configuration File @@ -26,11 +26,11 @@ Generating a Package Configuration File ``configure_package_config_file()`` should be used instead of the plain :command:`configure_file()` command when creating the ``<PackageName>Config.cmake`` or ``<PackageName>-config.cmake`` file for installing a project or library. -It helps making the resulting package relocatable by avoiding hardcoded paths -in the installed ``Config.cmake`` file. +It helps make the resulting package relocatable by avoiding hardcoded paths +in the installed ``<PackageName>Config.cmake`` file. In a ``FooConfig.cmake`` file there may be code like this to make the install -destinations know to the using project: +destinations known to the using project: .. code-block:: cmake @@ -40,27 +40,25 @@ destinations know to the using project: #...logic to determine installedPrefix from the own location... set(FOO_CONFIG_DIR "${installedPrefix}/@CONFIG_INSTALL_DIR@" ) -All 4 options shown above are not sufficient, since the first 3 hardcode the -absolute directory locations, and the 4th case works only if the logic to +All four options shown above are not sufficient The first three hardcode the +absolute directory locations. The fourth case works only if the logic to determine the ``installedPrefix`` is correct, and if ``CONFIG_INSTALL_DIR`` contains a relative path, which in general cannot be guaranteed. This has the effect that the resulting ``FooConfig.cmake`` file would work poorly under -Windows and OSX, where users are used to choose the install location of a +Windows and macOS, where users are used to choosing the install location of a binary package at install time, independent from how :variable:`CMAKE_INSTALL_PREFIX` was set at build/cmake time. -Using ``configure_package_config_file`` helps. If used correctly, it makes +Using ``configure_package_config_file()`` helps. If used correctly, it makes the resulting ``FooConfig.cmake`` file relocatable. Usage: -1. write a ``FooConfig.cmake.in`` file as you are used to -2. insert a line containing only the string ``@PACKAGE_INIT@`` -3. instead of ``set(FOO_DIR "@SOME_INSTALL_DIR@")``, use +1. Write a ``FooConfig.cmake.in`` file as you are used to. +2. Insert a line at the top containing only the string ``@PACKAGE_INIT@``. +3. Instead of ``set(FOO_DIR "@SOME_INSTALL_DIR@")``, use ``set(FOO_DIR "@PACKAGE_SOME_INSTALL_DIR@")`` (this must be after the - ``@PACKAGE_INIT@`` line) -4. instead of using the normal :command:`configure_file()`, use - ``configure_package_config_file()`` - - + ``@PACKAGE_INIT@`` line). +4. Instead of using the normal :command:`configure_file()` command, use + ``configure_package_config_file()``. The ``<input>`` and ``<output>`` arguments are the input and output file, the same way as in :command:`configure_file()`. @@ -70,48 +68,64 @@ the ``FooConfig.cmake`` file will be installed to. This path can either be absolute, or relative to the ``INSTALL_PREFIX`` path. The variables ``<var1>`` to ``<varN>`` given as ``PATH_VARS`` are the -variables which contain install destinations. For each of them the macro will +variables which contain install destinations. For each of them, the macro will create a helper variable ``PACKAGE_<var...>``. These helper variables must be used in the ``FooConfig.cmake.in`` file for setting the installed location. -They are calculated by ``configure_package_config_file`` so that they are +They are calculated by ``configure_package_config_file()`` so that they are always relative to the installed location of the package. This works both for -relative and also for absolute locations. For absolute locations it works +relative and also for absolute locations. For absolute locations, it works only if the absolute location is a subdirectory of ``INSTALL_PREFIX``. +.. versionadded:: 3.30 + The variable ``PACKAGE_PREFIX_DIR`` will always be defined after the + ``@PACKAGE_INIT@`` line. It will hold the value of the base install + location. In general, variables defined via the ``PATH_VARS`` mechanism + should be used instead, but ``PACKAGE_PREFIX_DIR`` can be used for those + cases not easily handled by ``PATH_VARS``, such as for files installed + directly to the base install location rather than a subdirectory of it. + + .. note:: + When consumers of the generated file use CMake 3.29 or older, the value + of ``PACKAGE_PREFIX_DIR`` can be changed by a call to + :command:`find_dependency` or :command:`find_package`. + If a project relies on ``PACKAGE_PREFIX_DIR``, it is the project's + responsibility to ensure that the value of ``PACKAGE_PREFIX_DIR`` is + preserved across any such calls, or any other calls which might include + another file generated by ``configure_package_config_file()``. + .. versionadded:: 3.1 - If the ``INSTALL_PREFIX`` argument is passed, this is used as base path to + If the ``INSTALL_PREFIX`` argument is passed, this is used as the base path to calculate all the relative paths. The ``<path>`` argument must be an absolute path. If this argument is not passed, the :variable:`CMAKE_INSTALL_PREFIX` variable will be used instead. The default value is good when generating a - FooConfig.cmake file to use your package from the install tree. When - generating a FooConfig.cmake file to use your package from the build tree this - option should be used. + ``FooConfig.cmake`` file to use your package from the install tree. When + generating a ``FooConfig.cmake`` file to use your package from the build tree, + this option should be used. -By default ``configure_package_config_file`` also generates two helper macros, -``set_and_check()`` and ``check_required_components()`` into the +By default, ``configure_package_config_file()`` also generates two helper +macros, ``set_and_check()`` and ``check_required_components()``, into the ``FooConfig.cmake`` file. -``set_and_check()`` should be used instead of the normal ``set()`` command for -setting directories and file locations. Additionally to setting the variable -it also checks that the referenced file or directory actually exists and fails -with a ``FATAL_ERROR`` otherwise. This makes sure that the created +``set_and_check()`` should be used instead of the normal :command:`set` command +for setting directories and file locations. In addition to setting the +variable, it also checks that the referenced file or directory actually exists +and fails with a fatal error if it doesn't. This ensures that the generated ``FooConfig.cmake`` file does not contain wrong references. -When using the ``NO_SET_AND_CHECK_MACRO``, this macro is not generated -into the ``FooConfig.cmake`` file. +Add the ``NO_SET_AND_CHECK_MACRO`` option to prevent the generation of the +``set_and_check()`` macro in the ``FooConfig.cmake`` file. ``check_required_components(<PackageName>)`` should be called at the end of the ``FooConfig.cmake`` file. This macro checks whether all requested, -non-optional components have been found, and if this is not the case, sets -the ``Foo_FOUND`` variable to ``FALSE``, so that the package is considered to +non-optional components have been found, and if this is not the case, it sets +the ``Foo_FOUND`` variable to ``FALSE`` so that the package is considered to be not found. It does that by testing the ``Foo_<Component>_FOUND`` variables for all requested required components. This macro should be called even if the package doesn't provide any components to make sure -users are not specifying components erroneously. When using the -``NO_CHECK_REQUIRED_COMPONENTS_MACRO`` option, this macro is not generated -into the ``FooConfig.cmake`` file. +users are not specifying components erroneously. Add the +``NO_CHECK_REQUIRED_COMPONENTS_MACRO`` option to prevent the generation of the +``check_required_components()`` macro in the ``FooConfig.cmake`` file. -For an example see below the documentation for -:command:`write_basic_package_version_file()`. +See also :ref:`CMakePackageConfigHelpers Examples`. Generating a Package Version File ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -126,11 +140,11 @@ Generating a Package Version File [ARCH_INDEPENDENT] ) -Writes a file for use as ``<PackageName>ConfigVersion.cmake`` file to +Writes a file for use as a ``<PackageName>ConfigVersion.cmake`` file to ``<filename>``. See the documentation of :command:`find_package()` for -details on this. +details on such files. -``<filename>`` is the output filename, it should be in the build tree. +``<filename>`` is the output filename, which should be in the build tree. ``<major.minor.patch>`` is the version number of the project to be installed. If no ``VERSION`` is given, the :variable:`PROJECT_VERSION` variable is used. @@ -153,9 +167,9 @@ the requested version matches exactly its own version number (not considering the tweak version). For example, version 1.2.3 of a package is only considered compatible to requested version 1.2.3. This mode is for packages without compatibility guarantees. -If your project has more elaborated version matching rules, you will need to -write your own custom ``ConfigVersion.cmake`` file instead of using this -macro. +If your project has more elaborate version matching rules, you will need to +write your own custom ``<PackageName>ConfigVersion.cmake`` file instead of +using this macro. .. versionadded:: 3.11 The ``SameMinorVersion`` compatibility mode. @@ -170,13 +184,13 @@ macro. unless ``ARCH_INDEPENDENT`` is given, in which case the package is considered compatible on any architecture. -.. note:: ``ARCH_INDEPENDENT`` is intended for header-only libraries or similar - packages with no binaries. + .. note:: ``ARCH_INDEPENDENT`` is intended for header-only libraries or + similar packages with no binaries. .. versionadded:: 3.19 The version file generated by ``AnyNewerVersion``, ``SameMajorVersion`` and - ``SameMinorVersion`` arguments of ``COMPATIBILITY`` handle the version range - if any is specified (see :command:`find_package` command for the details). + ``SameMinorVersion`` arguments of ``COMPATIBILITY`` handle the version range, + if one is specified (see :command:`find_package` command for the details). ``ExactVersion`` mode is incompatible with version ranges and will display an author warning if one is specified. @@ -184,8 +198,9 @@ Internally, this macro executes :command:`configure_file()` to create the resulting version file. Depending on the ``COMPATIBILITY``, the corresponding ``BasicConfigVersion-<COMPATIBILITY>.cmake.in`` file is used. Please note that these files are internal to CMake and you should not call -:command:`configure_file()` on them yourself, but they can be used as starting -point to create more sophisticated custom ``ConfigVersion.cmake`` files. +:command:`configure_file()` on them yourself, but they can be used as a starting +point to create more sophisticated custom ``<PackageName>ConfigVersion.cmake`` +files. Generating an Apple Platform Selection File ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -268,6 +283,9 @@ Generating an Apple Platform Selection File consider the platform to be unsupported. The behavior is determined by the ``ERROR_VARIABLE`` option. +Generating an Apple Architecture Selection File +^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + .. command:: generate_apple_architecture_selection_file .. versionadded:: 3.29 @@ -328,15 +346,16 @@ Generating an Apple Platform Selection File information to pretend the package was not found. If this option is not given, the default behavior is to issue a fatal error. +.. _`CMakePackageConfigHelpers Examples`: + Example Generating Package Files ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ -Example using both :command:`configure_package_config_file` and -``write_basic_package_version_file()``: - -``CMakeLists.txt``: +Example using both the :command:`configure_package_config_file` and +:command:`write_basic_package_version_file()` commands: .. code-block:: cmake + :caption: ``CMakeLists.txt`` include(GNUInstallDirs) set(INCLUDE_INSTALL_DIR ${CMAKE_INSTALL_INCLUDEDIR}/Foo @@ -357,9 +376,9 @@ Example using both :command:`configure_package_config_file` and ${CMAKE_CURRENT_BINARY_DIR}/FooConfigVersion.cmake DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake/Foo ) -``FooConfig.cmake.in``: - -:: +.. code-block:: cmake + :caption: ``FooConfig.cmake.in`` + :force: set(FOO_VERSION x.y.z) ... @@ -597,8 +616,15 @@ function(generate_apple_architecture_selection_file _output_file) ) endif() string(APPEND _branch_code - "endif()\n" + "endif()\n\n" + "set(_cmake_apple_archs \"\${CMAKE_OSX_ARCHITECTURES}\")\n" ) + if(NOT "${_gasf_UNIVERSAL_ARCHITECTURES}" STREQUAL "") + string(APPEND _branch_code "list(REMOVE_ITEM _cmake_apple_archs ${_gasf_UNIVERSAL_ARCHITECTURES})\n") + endif() + string(APPEND _branch_code "\n") + + set(maybe_else "") foreach(pair IN ZIP_LISTS _gasf_SINGLE_ARCHITECTURES _gasf_SINGLE_ARCHITECTURE_INCLUDE_FILES) set(arch "${pair_0}") @@ -607,40 +633,45 @@ function(generate_apple_architecture_selection_file _output_file) string(PREPEND config_file [[${PACKAGE_PREFIX_DIR}/]]) endif() string(APPEND _branch_code - "\n" - "if(CMAKE_OSX_ARCHITECTURES STREQUAL \"${arch}\")\n" + "${maybe_else}if(CMAKE_OSX_ARCHITECTURES STREQUAL \"${arch}\")\n" " include(\"${config_file}\")\n" - " return()\n" - "endif()\n" ) + set(maybe_else else) endforeach() if(_gasf_UNIVERSAL_ARCHITECTURES AND _gasf_UNIVERSAL_INCLUDE_FILE) - string(JOIN " " universal_archs "${_gasf_UNIVERSAL_ARCHITECTURES}") set(config_file "${_gasf_UNIVERSAL_INCLUDE_FILE}") if(NOT IS_ABSOLUTE "${config_file}") string(PREPEND config_file [[${PACKAGE_PREFIX_DIR}/]]) endif() string(APPEND _branch_code - "\n" - "set(_cmake_apple_archs \"\${CMAKE_OSX_ARCHITECTURES}\")\n" - "list(REMOVE_ITEM _cmake_apple_archs ${universal_archs})\n" - "if(NOT _cmake_apple_archs)\n" + "${maybe_else}if(NOT _cmake_apple_archs)\n" " include(\"${config_file}\")\n" - " return()\n" - "endif()\n" ) + set(maybe_else else) elseif(_gasf_UNIVERSAL_ARCHITECTURES) message(FATAL_ERROR "UNIVERSAL_INCLUDE_FILE requires UNIVERSAL_ARCHITECTURES") elseif(_gasf_UNIVERSAL_INCLUDE_FILE) message(FATAL_ERROR "UNIVERSAL_ARCHITECTURES requires UNIVERSAL_INCLUDE_FILE") endif() - string(APPEND _branch_code "\n") + if(maybe_else) + string(APPEND _branch_code "else()\n") + set(_indent " ") + else() + set(_indent "") + endif() if(_gasf_ERROR_VARIABLE) - string(APPEND _branch_code "set(\"${_gasf_ERROR_VARIABLE}\" \"Architecture not supported\")") + string(APPEND _branch_code + "${_indent}set(\"${_gasf_ERROR_VARIABLE}\" \"Architecture not supported\")\n" + ) else() - string(APPEND _branch_code "message(FATAL_ERROR \"Architecture not supported\")") + string(APPEND _branch_code + "${_indent}message(FATAL_ERROR \"Architecture not supported\")\n" + ) + endif() + if(maybe_else) + string(APPEND _branch_code "endif()\n") endif() configure_package_config_file("${CMAKE_CURRENT_FUNCTION_LIST_DIR}/Internal/AppleArchitectureSelection.cmake.in" "${_output_file}" diff --git a/Modules/Compiler/CMakeCommonCompilerMacros.cmake b/Modules/Compiler/CMakeCommonCompilerMacros.cmake index 0b5df0d..9eead20 100644 --- a/Modules/Compiler/CMakeCommonCompilerMacros.cmake +++ b/Modules/Compiler/CMakeCommonCompilerMacros.cmake @@ -244,6 +244,9 @@ function(cmake_create_cxx_import_std std variable) string(CONCAT guarded_target_definition "if (NOT TARGET \"__CMAKE::CXX${std}\")\n" "${target_definition}" + "endif ()\n" + "if (TARGET \"__CMAKE::CXX${std}\")\n" + " list(APPEND CMAKE_CXX_COMPILER_IMPORT_STD \"${std}\")\n" "endif ()\n") set("${variable}" "${guarded_target_definition}" PARENT_SCOPE) endfunction() diff --git a/Modules/Compiler/GNU.cmake b/Modules/Compiler/GNU.cmake index fa199b4..1113e9a 100644 --- a/Modules/Compiler/GNU.cmake +++ b/Modules/Compiler/GNU.cmake @@ -293,4 +293,9 @@ macro(__compiler_gnu_cxx_standards lang) set(CMAKE_${lang}20_STANDARD_COMPILE_OPTION "-std=c++2a") set(CMAKE_${lang}20_EXTENSION_COMPILE_OPTION "-std=gnu++2a") endif() + + if(CMAKE_${lang}_COMPILER_VERSION VERSION_GREATER_EQUAL 14.0) + set(CMAKE_${lang}26_STANDARD_COMPILE_OPTION "-std=c++26") + set(CMAKE_${lang}26_EXTENSION_COMPILE_OPTION "-std=gnu++26") + endif() endmacro() diff --git a/Modules/FindBoost.cmake b/Modules/FindBoost.cmake index 11a38df..df71350 100644 --- a/Modules/FindBoost.cmake +++ b/Modules/FindBoost.cmake @@ -1395,7 +1395,7 @@ function(_Boost_COMPONENT_DEPENDENCIES component _ret) set(_Boost_THREAD_DEPENDENCIES chrono atomic) set(_Boost_WAVE_DEPENDENCIES filesystem serialization thread chrono atomic) set(_Boost_WSERIALIZATION_DEPENDENCIES serialization) - if(Boost_VERSION_STRING VERSION_GREATER_EQUAL 1.85.0 AND NOT Boost_NO_WARN_NEW_VERSIONS) + if(Boost_VERSION_STRING VERSION_GREATER_EQUAL 1.86.0 AND NOT Boost_NO_WARN_NEW_VERSIONS) message(WARNING "New Boost version may have incorrect or missing dependencies and imported targets") endif() endif() @@ -1670,7 +1670,7 @@ else() # _Boost_COMPONENT_HEADERS. See the instructions at the top of # _Boost_COMPONENT_DEPENDENCIES. set(_Boost_KNOWN_VERSIONS ${Boost_ADDITIONAL_VERSIONS} - "1.84.0" "1.84" + "1.85.0" "1.85" "1.84.0" "1.84" "1.83.0" "1.83" "1.82.0" "1.82" "1.81.0" "1.81" "1.80.0" "1.80" "1.79.0" "1.79" "1.78.0" "1.78" "1.77.0" "1.77" "1.76.0" "1.76" "1.75.0" "1.75" "1.74.0" "1.74" "1.73.0" "1.73" "1.72.0" "1.72" "1.71.0" "1.71" "1.70.0" "1.70" "1.69.0" "1.69" diff --git a/Modules/Internal/AppleArchitectureSelection.cmake.in b/Modules/Internal/AppleArchitectureSelection.cmake.in index b7315b6..0c3a3a2 100644 --- a/Modules/Internal/AppleArchitectureSelection.cmake.in +++ b/Modules/Internal/AppleArchitectureSelection.cmake.in @@ -1,2 +1,23 @@ +# Save this now so we can restore it before returning +if(NOT DEFINED PACKAGE_PREFIX_DIR) + list(APPEND _gasf_PACKAGE_PREFIX_DIR "<__CMAKE_UNDEFINED__>") +elseif("${PACKAGE_PREFIX_DIR}" STREQUAL "") + list(APPEND _gasf_PACKAGE_PREFIX_DIR "<__CMAKE_EMPTY__>") +else() + list(APPEND _gasf_PACKAGE_PREFIX_DIR "${PACKAGE_PREFIX_DIR}") +endif() + @PACKAGE_INIT@ @_branch_code@ + +# Restore PACKAGE_PREFIX_DIR +list(LENGTH _gasf_PACKAGE_PREFIX_DIR _gasf_tmp) +math(EXPR _gasf_tmp "${_gasf_tmp} - 1") +list(GET _gasf_PACKAGE_PREFIX_DIR ${_gasf_tmp} PACKAGE_PREFIX_DIR) +list(REMOVE_AT _gasf_PACKAGE_PREFIX_DIR ${_gasf_tmp}) +unset(_gasf_tmp) +if("${PACKAGE_PREFIX_DIR}" STREQUAL "<__CMAKE_UNDEFINED__>") + unset(PACKAGE_PREFIX_DIR) +elseif("${PACKAGE_PREFIX_DIR}" STREQUAL "<__CMAKE_EMPTY__>") + set(PACKAGE_PREFIX_DIR "") +endif() diff --git a/Modules/Internal/ApplePlatformSelection.cmake.in b/Modules/Internal/ApplePlatformSelection.cmake.in index 6c03ab6..c07f139 100644 --- a/Modules/Internal/ApplePlatformSelection.cmake.in +++ b/Modules/Internal/ApplePlatformSelection.cmake.in @@ -1,3 +1,12 @@ +# Save this now so we can restore it before returning +if(NOT DEFINED PACKAGE_PREFIX_DIR) + list(APPEND _gpsf_PACKAGE_PREFIX_DIR "<__CMAKE_UNDEFINED__>") +elseif("${PACKAGE_PREFIX_DIR}" STREQUAL "") + list(APPEND _gpsf_PACKAGE_PREFIX_DIR "<__CMAKE_EMPTY__>") +else() + list(APPEND _gpsf_PACKAGE_PREFIX_DIR "${PACKAGE_PREFIX_DIR}") +endif() + @PACKAGE_INIT@ string(TOLOWER "${CMAKE_OSX_SYSROOT}" _CMAKE_OSX_SYSROOT_LOWER) @@ -23,3 +32,15 @@ elseif(CMAKE_SYSTEM_NAME STREQUAL "Darwin") else() @_branch_ELSE@ endif() + +# Restore PACKAGE_PREFIX_DIR +list(LENGTH _gpsf_PACKAGE_PREFIX_DIR _gpsf_tmp) +math(EXPR _gpsf_tmp "${_gpsf_tmp} - 1") +list(GET _gpsf_PACKAGE_PREFIX_DIR ${_gpsf_tmp} PACKAGE_PREFIX_DIR) +list(REMOVE_AT _gpsf_PACKAGE_PREFIX_DIR ${_gpsf_tmp}) +unset(_gpsf_tmp) +if("${PACKAGE_PREFIX_DIR}" STREQUAL "<__CMAKE_UNDEFINED__>") + unset(PACKAGE_PREFIX_DIR) +elseif("${PACKAGE_PREFIX_DIR}" STREQUAL "<__CMAKE_EMPTY__>") + set(PACKAGE_PREFIX_DIR "") +endif() diff --git a/Source/CMakeVersion.cmake b/Source/CMakeVersion.cmake index 226f3a0..b457ec4 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 29) -set(CMake_VERSION_PATCH 20240416) +set(CMake_VERSION_PATCH 20240423) #set(CMake_VERSION_RC 0) set(CMake_VERSION_IS_DIRTY 0) diff --git a/Source/cmCTest.cxx b/Source/cmCTest.cxx index 29bf311..498fd6e 100644 --- a/Source/cmCTest.cxx +++ b/Source/cmCTest.cxx @@ -760,9 +760,7 @@ bool cmCTest::UpdateCTestConfiguration() } if (!this->GetCTestConfiguration("BuildDirectory").empty()) { this->Impl->BinaryDir = this->GetCTestConfiguration("BuildDirectory"); - if (this->Impl->TestDir.empty()) { - cmSystemTools::ChangeDirectory(this->Impl->BinaryDir); - } + cmSystemTools::ChangeDirectory(this->Impl->BinaryDir); } this->Impl->TimeOut = std::chrono::seconds(atoi(this->GetCTestConfiguration("TimeOut").c_str())); @@ -2830,7 +2828,8 @@ int cmCTest::Run(std::vector<std::string>& args, std::string* output) if (!validArg && cmHasLiteralPrefix(arg, "-") && !cmHasLiteralPrefix(arg, "--preset")) { - cmSystemTools::Error(cmStrCat("Invalid argument: ", arg)); + cmSystemTools::Error(cmStrCat("Unknown argument: ", arg)); + cmSystemTools::Error("Run 'ctest --help' for all supported options."); return 1; } } // the close of the for argument loop diff --git a/Source/cmFindPackageCommand.cxx b/Source/cmFindPackageCommand.cxx index d730339..6349302 100644 --- a/Source/cmFindPackageCommand.cxx +++ b/Source/cmFindPackageCommand.cxx @@ -982,6 +982,36 @@ bool cmFindPackageCommand::InitialPass(std::vector<std::string> const& args) return true; } + // Restore PACKAGE_PREFIX_DIR to its pre-call value when we return. If our + // caller is a file generated by configure_package_config_file(), and if + // the package we are about to load also has a config file created by that + // command, it will overwrite PACKAGE_PREFIX_DIR. We need to restore it in + // case something still refers to it in our caller's scope after we return. + class RestoreVariableOnLeavingScope + { + cmMakefile* makefile_; + cm::optional<std::string> value_; + + public: + RestoreVariableOnLeavingScope(cmMakefile* makefile) + : makefile_(makefile) + { + cmValue v = makefile->GetDefinition("PACKAGE_PREFIX_DIR"); + if (v) { + value_ = *v; + } + } + ~RestoreVariableOnLeavingScope() + { + if (this->value_) { + makefile_->AddDefinition("PACKAGE_PREFIX_DIR", *value_); + } else { + makefile_->RemoveDefinition("PACKAGE_PREFIX_DIR"); + } + } + }; + RestoreVariableOnLeavingScope restorePackagePrefixDir(this->Makefile); + // Now choose what method(s) we will use to satisfy the request. Note that // we still want all the above checking of arguments, etc. regardless of the // method used. This will ensure ill-formed arguments are caught earlier, diff --git a/Tests/CMakeLists.txt b/Tests/CMakeLists.txt index fa388e0..5d9d193 100644 --- a/Tests/CMakeLists.txt +++ b/Tests/CMakeLists.txt @@ -395,11 +395,15 @@ if(BUILD_TESTING) string(REPLACE ";" "$<SEMICOLON>" TEST_STDS_C "${CMake_TEST_C_STANDARDS}") string(REPLACE ";" "$<SEMICOLON>" TEST_STDS_CXX "${CMake_TEST_CXX_STANDARDS}") + string(REPLACE ";" "$<SEMICOLON>" TEST_STDS_CUDA "${CMake_TEST_CUDA_STANDARDS}") set(CompileFeatures_BUILD_OPTIONS -DCMake_TEST_C_STANDARDS=${TEST_STDS_C} -DCMake_TEST_CXX_STANDARDS=${TEST_STDS_CXX} + -DCMake_TEST_CUDA=${CMake_TEST_CUDA} + -DCMake_TEST_CUDA_STANDARDS=${TEST_STDS_CUDA} ) ADD_TEST_MACRO(CompileFeatures CompileFeatures) + set_property(TEST CompileFeatures APPEND PROPERTY LABELS "CUDA") ADD_TEST_MACRO(CMakeCommands.target_compile_features) diff --git a/Tests/CompileFeatures/CMakeLists.txt b/Tests/CompileFeatures/CMakeLists.txt index e206e70..469a085 100644 --- a/Tests/CompileFeatures/CMakeLists.txt +++ b/Tests/CompileFeatures/CMakeLists.txt @@ -9,7 +9,13 @@ set(ext_CXX cpp) set(std_C 90 99 11 17 23) set(std_CXX 98 11 14 17 20 23 26) -foreach(lang C CXX) +if(CMake_TEST_CUDA) + enable_language(CUDA) + set(ext_CUDA cu) + set(std_CUDA 03 11 14 17 20 23 26) +endif() + +foreach(lang C CXX CUDA) foreach(std IN LISTS std_${lang}) string(TOLOWER "${lang}_std_${std}" feature) if("${std}" IN_LIST CMake_TEST_${lang}_STANDARDS @@ -286,6 +292,7 @@ if (CMAKE_CXX_COMPILE_FEATURES) if (std_flag_idx EQUAL -1) add_executable(default_dialect default_dialect.cpp) target_compile_definitions(default_dialect PRIVATE + DEFAULT_CXX26=$<EQUAL:${CMAKE_CXX_STANDARD_DEFAULT},26> DEFAULT_CXX23=$<EQUAL:${CMAKE_CXX_STANDARD_DEFAULT},23> DEFAULT_CXX20=$<EQUAL:${CMAKE_CXX_STANDARD_DEFAULT},20> DEFAULT_CXX17=$<EQUAL:${CMAKE_CXX_STANDARD_DEFAULT},17> @@ -297,6 +304,22 @@ if (CMAKE_CXX_COMPILE_FEATURES) endif() endif () +if (CMake_TEST_CUDA + AND CMAKE_CUDA_COMPILE_FEATURES + AND CMAKE_CUDA_STANDARD_DEFAULT + AND NOT CMAKE_CUDA_FLAGS MATCHES "-std=") + add_executable(default_dialect_cuda default_dialect.cu) + target_compile_definitions(default_dialect_cuda PRIVATE + DEFAULT_CXX26=$<EQUAL:${CMAKE_CUDA_STANDARD_DEFAULT},26> + DEFAULT_CXX23=$<EQUAL:${CMAKE_CUDA_STANDARD_DEFAULT},23> + DEFAULT_CXX20=$<EQUAL:${CMAKE_CUDA_STANDARD_DEFAULT},20> + DEFAULT_CXX17=$<EQUAL:${CMAKE_CUDA_STANDARD_DEFAULT},17> + DEFAULT_CXX14=$<EQUAL:${CMAKE_CUDA_STANDARD_DEFAULT},14> + DEFAULT_CXX11=$<EQUAL:${CMAKE_CUDA_STANDARD_DEFAULT},11> + DEFAULT_CXX98=$<EQUAL:${CMAKE_CUDA_STANDARD_DEFAULT},03> + ) +endif () + # always add a target "CompileFeatures" if ((NOT CXX_expected_features) OR (NOT cxx_auto_type IN_LIST CXX_expected_features)) diff --git a/Tests/CompileFeatures/c_std_23.c b/Tests/CompileFeatures/c_std_23.c index 6073b552..a60a16e 100644 --- a/Tests/CompileFeatures/c_std_23.c +++ b/Tests/CompileFeatures/c_std_23.c @@ -1,6 +1,5 @@ #include "c_std.h" #if defined(C_STD) && C_STD <= C_STD_17 && \ - !(C_STD == C_STD_17 && defined(__apple_build_version__) && \ - defined(__clang_major__) && __clang_major__ < 14) + !(C_STD == C_STD_17 && defined(__clang_major__) && __clang_major__ < 14) # error "c_std_23 not honored" #endif diff --git a/Tests/CompileFeatures/cuda_std_03.cu b/Tests/CompileFeatures/cuda_std_03.cu new file mode 100644 index 0000000..e69de29 --- /dev/null +++ b/Tests/CompileFeatures/cuda_std_03.cu diff --git a/Tests/CompileFeatures/cuda_std_11.cu b/Tests/CompileFeatures/cuda_std_11.cu new file mode 100644 index 0000000..76813fd --- /dev/null +++ b/Tests/CompileFeatures/cuda_std_11.cu @@ -0,0 +1,4 @@ +#include "cxx_std.h" +#if defined(CXX_STD) && CXX_STD < CXX_STD_11 +# error "cuda_std_11 not honored" +#endif diff --git a/Tests/CompileFeatures/cuda_std_14.cu b/Tests/CompileFeatures/cuda_std_14.cu new file mode 100644 index 0000000..53e23c8 --- /dev/null +++ b/Tests/CompileFeatures/cuda_std_14.cu @@ -0,0 +1,4 @@ +#include "cxx_std.h" +#if defined(CXX_STD) && CXX_STD <= CXX_STD_11 +# error "cuda_std_14 not honored" +#endif diff --git a/Tests/CompileFeatures/cuda_std_17.cu b/Tests/CompileFeatures/cuda_std_17.cu new file mode 100644 index 0000000..502defb --- /dev/null +++ b/Tests/CompileFeatures/cuda_std_17.cu @@ -0,0 +1,4 @@ +#include "cxx_std.h" +#if defined(CXX_STD) && CXX_STD <= CXX_STD_14 +# error "cuda_std_17 not honored" +#endif diff --git a/Tests/CompileFeatures/cuda_std_20.cu b/Tests/CompileFeatures/cuda_std_20.cu new file mode 100644 index 0000000..afdd3ba --- /dev/null +++ b/Tests/CompileFeatures/cuda_std_20.cu @@ -0,0 +1,4 @@ +#include "cxx_std.h" +#if defined(CXX_STD) && CXX_STD <= CXX_STD_17 +# error "cuda_std_20 not honored" +#endif diff --git a/Tests/CompileFeatures/cuda_std_23.cu b/Tests/CompileFeatures/cuda_std_23.cu new file mode 100644 index 0000000..6bdaeb9 --- /dev/null +++ b/Tests/CompileFeatures/cuda_std_23.cu @@ -0,0 +1,4 @@ +#include "cxx_std.h" +#if defined(CXX_STD) && CXX_STD <= CXX_STD_20 +# error "cuda_std_23 not honored" +#endif diff --git a/Tests/CompileFeatures/cuda_std_26.cu b/Tests/CompileFeatures/cuda_std_26.cu new file mode 100644 index 0000000..efeca8d --- /dev/null +++ b/Tests/CompileFeatures/cuda_std_26.cu @@ -0,0 +1,4 @@ +#include "cxx_std.h" +#if defined(CXX_STD) && CXX_STD <= CXX_STD_23 +# error "cuda_std_26 not honored" +#endif diff --git a/Tests/CompileFeatures/default_dialect.cpp b/Tests/CompileFeatures/default_dialect.cpp index c0cc1b6..b873b14 100644 --- a/Tests/CompileFeatures/default_dialect.cpp +++ b/Tests/CompileFeatures/default_dialect.cpp @@ -3,7 +3,11 @@ template <long l> struct Outputter; -#if DEFAULT_CXX23 +#if DEFAULT_CXX26 +# if CXX_STD <= CXX_STD_23 +Outputter<CXX_STD> o; +# endif +#elif DEFAULT_CXX23 # if CXX_STD <= CXX_STD_20 Outputter<CXX_STD> o; # endif diff --git a/Tests/CompileFeatures/default_dialect.cu b/Tests/CompileFeatures/default_dialect.cu new file mode 100644 index 0000000..a549a5c --- /dev/null +++ b/Tests/CompileFeatures/default_dialect.cu @@ -0,0 +1 @@ +#include "default_dialect.cpp" diff --git a/Tests/FindBacktrace/Test/backtrace.c b/Tests/FindBacktrace/Test/backtrace.c index 1a60b14..e143bc7 100644 --- a/Tests/FindBacktrace/Test/backtrace.c +++ b/Tests/FindBacktrace/Test/backtrace.c @@ -13,6 +13,7 @@ void myfunc3(void) int nptrs; void* buffer[BT_BUF_SIZE]; char** strings; + size_t j; nptrs = backtrace(buffer, BT_BUF_SIZE); printf("backtrace() returned %d addresses\n", nptrs); @@ -26,8 +27,9 @@ void myfunc3(void) exit(EXIT_FAILURE); } - for (size_t j = 0; j < nptrs; j++) + for (j = 0; j < nptrs; j++) { printf("%s\n", strings[j]); + } free(strings); } @@ -40,10 +42,11 @@ myfunc2(void) void myfunc(int ncalls) { - if (ncalls > 1) + if (ncalls > 1) { myfunc(ncalls - 1); - else + } else { myfunc2(); + } } int main(int argc, char* argv[]) diff --git a/Tests/FindGTK2/gdk/main.c b/Tests/FindGTK2/gdk/main.c index 71f523b..2d03fbe 100644 --- a/Tests/FindGTK2/gdk/main.c +++ b/Tests/FindGTK2/gdk/main.c @@ -2,6 +2,6 @@ int main(int argc, char* argv[]) { - gdk_init(argc, argv); + gdk_init(&argc, &argv); return 0; } diff --git a/Tests/RunCMake/CMakePackage/ApplePlatformGenSubdir-stdout.txt b/Tests/RunCMake/CMakePackage/ApplePlatformGenSubdir-stdout.txt new file mode 100644 index 0000000..8821dad --- /dev/null +++ b/Tests/RunCMake/CMakePackage/ApplePlatformGenSubdir-stdout.txt @@ -0,0 +1,3 @@ +(-- )?Hello from platform switch +(-- )?Hello from arch switch +(-- )?Hello from pkg_a diff --git a/Tests/RunCMake/CMakePackage/ApplePlatformGenSubdir.cmake b/Tests/RunCMake/CMakePackage/ApplePlatformGenSubdir.cmake new file mode 100644 index 0000000..e472665 --- /dev/null +++ b/Tests/RunCMake/CMakePackage/ApplePlatformGenSubdir.cmake @@ -0,0 +1,50 @@ +set(CMAKE_INSTALL_DATADIR share) +set(SWITCH_DIR platform/cmake) + +include(CMakePackageConfigHelpers) + +file(WRITE ${CMAKE_CURRENT_BINARY_DIR}/pkg_a-config.cmake.in [[ +@PACKAGE_INIT@ +include("@PACKAGE_SWITCH_DIR@/platform-switch.cmake") +include("@PACKAGE_CMAKE_INSTALL_DATADIR@/pkg_a_included.cmake") +]]) +configure_package_config_file( + ${CMAKE_CURRENT_BINARY_DIR}/pkg_a-config.cmake.in + ${CMAKE_CURRENT_BINARY_DIR}/install/pkg_a-config.cmake + INSTALL_DESTINATION . + PATH_VARS CMAKE_INSTALL_DATADIR SWITCH_DIR +) +file(WRITE ${CMAKE_CURRENT_BINARY_DIR}/install/${CMAKE_INSTALL_DATADIR}/pkg_a_included.cmake + [[message(STATUS "Hello from pkg_a")]] +) + +# To expose re-using the same package prefix variable, we need to use a +# different install prefix. This is really contrived and not representative of +# what a package should do. +generate_apple_platform_selection_file( + ${CMAKE_CURRENT_BINARY_DIR}/install/platform/cmake/platform-switch.cmake + INSTALL_PREFIX ${CMAKE_INSTALL_PREFIX}/platform + INSTALL_DESTINATION cmake + MACOS_INCLUDE_FILE cmake/switch_included.cmake # relative to install prefix +) +file(WRITE ${CMAKE_CURRENT_BINARY_DIR}/install/platform/cmake/switch_included.cmake +[[ +message(STATUS "Hello from platform switch") +include("${CMAKE_CURRENT_LIST_DIR}/../arch/cmake/arch-switch.cmake") +]] +) + +generate_apple_architecture_selection_file( + ${CMAKE_CURRENT_BINARY_DIR}/install/platform/arch/cmake/arch-switch.cmake + INSTALL_PREFIX ${CMAKE_INSTALL_PREFIX}/platform/arch + INSTALL_DESTINATION cmake + UNIVERSAL_ARCHITECTURES i386 x86_64 arm64 $(ARCHS_STANDARD) + UNIVERSAL_INCLUDE_FILE cmake/switch_included.cmake # relative to install prefix +) +file(WRITE ${CMAKE_CURRENT_BINARY_DIR}/install/platform/arch/cmake/switch_included.cmake + [[message(STATUS "Hello from arch switch")]] +) + +find_package(pkg_a REQUIRED NO_DEFAULT_PATH + PATHS ${CMAKE_CURRENT_BINARY_DIR}/install +) diff --git a/Tests/RunCMake/CMakePackage/NestedConfigFile-stdout.txt b/Tests/RunCMake/CMakePackage/NestedConfigFile-stdout.txt new file mode 100644 index 0000000..cdb3384 --- /dev/null +++ b/Tests/RunCMake/CMakePackage/NestedConfigFile-stdout.txt @@ -0,0 +1,6 @@ +(-- )?Before find_dependency: PACKAGE_PREFIX_DIR = .*/Tests/RunCMake/CMakePackage/NestedConfigFile-build/install_pkg_b +(-- )?Hello from pkg_a +(-- )?Leaving pkg_a-config\.cmake with PACKAGE_PREFIX_DIR = .*/Tests/RunCMake/CMakePackage/NestedConfigFile-build/install_pkg_a +(-- )?After find_dependency: PACKAGE_PREFIX_DIR = .*/Tests/RunCMake/CMakePackage/NestedConfigFile-build/install_pkg_b +(-- )?Hello from pkg_b +(-- )?Leaving pkg_b-config\.cmake with PACKAGE_PREFIX_DIR = .*/Tests/RunCMake/CMakePackage/NestedConfigFile-build/install_pkg_b diff --git a/Tests/RunCMake/CMakePackage/NestedConfigFile.cmake b/Tests/RunCMake/CMakePackage/NestedConfigFile.cmake new file mode 100644 index 0000000..2eeaebb --- /dev/null +++ b/Tests/RunCMake/CMakePackage/NestedConfigFile.cmake @@ -0,0 +1,43 @@ +set(CMAKE_INSTALL_DATADIR share) + +include(CMakePackageConfigHelpers) + +file(WRITE ${CMAKE_CURRENT_BINARY_DIR}/pkg_a-config.cmake.in [[ +@PACKAGE_INIT@ +include("@PACKAGE_CMAKE_INSTALL_DATADIR@/pkg_a_included.cmake") +message(STATUS "Leaving pkg_a-config.cmake with PACKAGE_PREFIX_DIR = ${PACKAGE_PREFIX_DIR}") +]]) +configure_package_config_file( + ${CMAKE_CURRENT_BINARY_DIR}/pkg_a-config.cmake.in + ${CMAKE_CURRENT_BINARY_DIR}/install_pkg_a/pkg_a-config.cmake + INSTALL_DESTINATION . + PATH_VARS CMAKE_INSTALL_DATADIR +) +file(WRITE ${CMAKE_CURRENT_BINARY_DIR}/install_pkg_a/share/pkg_a_included.cmake + [[message(STATUS "Hello from pkg_a")]] +) + +file(WRITE ${CMAKE_CURRENT_BINARY_DIR}/pkg_b-config.cmake.in [[ +@PACKAGE_INIT@ +include(CMakeFindDependencyMacro) +message(STATUS "Before find_dependency: PACKAGE_PREFIX_DIR = ${PACKAGE_PREFIX_DIR}") +find_dependency(pkg_a NO_DEFAULT_PATH + PATHS "@CMAKE_CURRENT_BINARY_DIR@/install_pkg_a" +) +message(STATUS "After find_dependency: PACKAGE_PREFIX_DIR = ${PACKAGE_PREFIX_DIR}") +include("@PACKAGE_CMAKE_INSTALL_DATADIR@/pkg_b_included.cmake") +message(STATUS "Leaving pkg_b-config.cmake with PACKAGE_PREFIX_DIR = ${PACKAGE_PREFIX_DIR}") +]]) +configure_package_config_file( + ${CMAKE_CURRENT_BINARY_DIR}/pkg_b-config.cmake.in + ${CMAKE_CURRENT_BINARY_DIR}/install_pkg_b/pkg_b-config.cmake + INSTALL_DESTINATION . + PATH_VARS CMAKE_INSTALL_DATADIR +) +file(WRITE ${CMAKE_CURRENT_BINARY_DIR}/install_pkg_b/share/pkg_b_included.cmake + [[message(STATUS "Hello from pkg_b")]] +) + +find_package(pkg_b REQUIRED NO_DEFAULT_PATH + PATHS ${CMAKE_CURRENT_BINARY_DIR}/install_pkg_b +) diff --git a/Tests/RunCMake/CMakePackage/RunCMakeTest.cmake b/Tests/RunCMake/CMakePackage/RunCMakeTest.cmake index 1551b55..c4a05e3 100644 --- a/Tests/RunCMake/CMakePackage/RunCMakeTest.cmake +++ b/Tests/RunCMake/CMakePackage/RunCMakeTest.cmake @@ -4,6 +4,8 @@ if(NOT RunCMake_GENERATOR_IS_MULTI_CONFIG) set(maybe_CMAKE_BUILD_TYPE -DCMAKE_BUILD_TYPE=Release) endif() +run_cmake_with_options(NestedConfigFile ${maybe_CMAKE_BUILD_TYPE}) + function(apple_export platform system_name archs sysroot) set(RunCMake_TEST_BINARY_DIR ${RunCMake_BINARY_DIR}/apple-export-${platform}-build) string(REPLACE ";" "\\;" archs "${archs}") @@ -48,9 +50,6 @@ if(APPLE) endif() if(APPLE AND CMAKE_C_COMPILER_ID STREQUAL "AppleClang") - set(apple_install ${RunCMake_BINARY_DIR}/apple-install) - file(REMOVE_RECURSE "${apple_install}") - if(CMake_TEST_XCODE_VERSION VERSION_GREATER_EQUAL 12) set(macos_archs "x86_64;arm64") set(tvos_sim_archs "x86_64;arm64") @@ -78,6 +77,17 @@ if(APPLE AND CMAKE_C_COMPILER_ID STREQUAL "AppleClang") set(enable_visionos 1) endif() + string(REPLACE ";" "\\;" macos_archs_for_cmd "${macos_archs}") + run_cmake_with_options(ApplePlatformGenSubdir + "-DCMAKE_OSX_ARCHITECTURES=${macos_archs_for_cmd}" + ${maybe_CMAKE_BUILD_TYPE} + ) + unset(macos_archs_for_cmd) + + # Place all export/import steps in a single install prefix. + set(apple_install ${RunCMake_BINARY_DIR}/apple-install) + file(REMOVE_RECURSE "${apple_install}") + apple_export(macos Darwin "${macos_archs}" macosx) apple_export(ios iOS "arm64" iphoneos) apple_export(tvos tvOS "arm64" appletvos) diff --git a/Tests/RunCMake/CTestCommandLine/invalid-ctest-argument-stderr.txt b/Tests/RunCMake/CTestCommandLine/invalid-ctest-argument-stderr.txt index 4de2e77..3304a26 100644 --- a/Tests/RunCMake/CTestCommandLine/invalid-ctest-argument-stderr.txt +++ b/Tests/RunCMake/CTestCommandLine/invalid-ctest-argument-stderr.txt @@ -1 +1,2 @@ -CMake Error: Invalid argument: --not-a-valid-ctest-argument +CMake Error: Unknown argument: --not-a-valid-ctest-argument +CMake Error: Run 'ctest --help' for all supported options. diff --git a/Tests/RunCMake/CXXModules/Inspect.cmake b/Tests/RunCMake/CXXModules/Inspect.cmake index 1597bd8..e648e8c 100644 --- a/Tests/RunCMake/CXXModules/Inspect.cmake +++ b/Tests/RunCMake/CXXModules/Inspect.cmake @@ -15,10 +15,21 @@ if (CMAKE_CXX_FLAGS MATCHES "-std=") set(forced_cxx_standard 1) endif () -set(have_cxx23_import_std 0) -if (TARGET "__CMAKE::CXX23") - set(have_cxx23_import_std 1) -endif () +macro (cxx_check_import_std version) + set(have_cxx${version}_import_std 0) + if ("${version}" IN_LIST CMAKE_CXX_COMPILER_IMPORT_STD) + set(have_cxx${version}_import_std 1) + endif () + + if (TARGET "__CMAKE:CXX${version}" AND NOT have_cxx${version}_import_std) + message(FATAL_ERROR + "The toolchain's C++${version} target exists, but the user variable does " + "not indicate it.") + endif () +endmacro () + +cxx_check_import_std(23) +cxx_check_import_std(26) # Forward information about the C++ compile features. string(APPEND info "\ diff --git a/Tests/RunCMake/CompileFeatures/compiler_introspection.cmake b/Tests/RunCMake/CompileFeatures/compiler_introspection.cmake index f3360c7..1cfa27e 100644 --- a/Tests/RunCMake/CompileFeatures/compiler_introspection.cmake +++ b/Tests/RunCMake/CompileFeatures/compiler_introspection.cmake @@ -40,6 +40,6 @@ set(${lang}${standard}_EXT_FLAG ${CMAKE_${lang}${standard}_EXTENSION_COMPILE_OPT endforeach() endmacro() -info(C 90 99 11 17 23) -info(CXX 98 11 14 17 20 23) +info(C 90 99 11 17 23 26) +info(CXX 98 11 14 17 20 23 26) file(WRITE "${CMAKE_CURRENT_BINARY_DIR}/info.cmake" "${info}") |