diff options
42 files changed, 364 insertions, 56 deletions
diff --git a/.gitlab/ci/docker/fedora36/Dockerfile b/.gitlab/ci/docker/fedora36/Dockerfile index 26f8e3e..299d48a 100644 --- a/.gitlab/ci/docker/fedora36/Dockerfile +++ b/.gitlab/ci/docker/fedora36/Dockerfile @@ -4,6 +4,12 @@ MAINTAINER Ben Boeckel <ben.boeckel@kitware.com> COPY install_rvm.sh /root/install_rvm.sh RUN sh /root/install_rvm.sh +FROM fedora:36 AS clang-tidy-headers +MAINTAINER Kyle Edwards <kyle.edwards@kitware.com> + +COPY install_clang_tidy_headers.sh /root/install_clang_tidy_headers.sh +RUN sh /root/install_clang_tidy_headers.sh + FROM fedora:36 MAINTAINER Ben Boeckel <ben.boeckel@kitware.com> @@ -13,3 +19,6 @@ RUN sh /root/install_deps.sh COPY --from=rvm-build /root/rvm.tar /root/rvm.tar RUN tar -C /usr/local -xf /root/rvm.tar \ && rm /root/rvm.tar +COPY --from=clang-tidy-headers /root/clang-tidy-headers.tar /root/clang-tidy-headers.tar +RUN tar -C /usr/include -xf /root/clang-tidy-headers.tar \ + && rm /root/clang-tidy-headers.tar diff --git a/.gitlab/ci/docker/fedora36/install_clang_tidy_headers.sh b/.gitlab/ci/docker/fedora36/install_clang_tidy_headers.sh new file mode 100755 index 0000000..b9883f4 --- /dev/null +++ b/.gitlab/ci/docker/fedora36/install_clang_tidy_headers.sh @@ -0,0 +1,18 @@ +#!/bin/sh + +set -e + +# Packages for building the clang-tidy plugin. +# TODO: Upstream this as a proper Fedora package. +dnf install --setopt=install_weak_deps=False -y \ + 'dnf-command(download)' \ + rpm-build \ + python3-devel \ + clang-tools-extra +clang_source_rpm=$(rpm -q --queryformat '%{SOURCERPM}' clang-tools-extra) +clang_version=$(rpm -q --queryformat '%{VERSION}' clang-tools-extra) +dnf download --source -y clang +rpm -i "$clang_source_rpm" +rpmbuild -bp /root/rpmbuild/SPECS/clang.spec +cd "/root/rpmbuild/BUILD/clang-tools-extra-$clang_version.src" +find clang-tidy -name '*.h' | tar -cf /root/clang-tidy-headers.tar -T - diff --git a/.gitlab/os-linux.yml b/.gitlab/os-linux.yml index 74af444..a46ec22 100644 --- a/.gitlab/os-linux.yml +++ b/.gitlab/os-linux.yml @@ -69,7 +69,7 @@ ### Fedora .fedora36: - image: "kitware/cmake:ci-fedora36-x86_64-2022-08-30" + image: "kitware/cmake:ci-fedora36-x86_64-2022-08-31" variables: GIT_CLONE_PATH: "$CI_BUILDS_DIR/cmake ci/long file name for testing purposes" diff --git a/Help/guide/tutorial/Adding Usage Requirements for a Library.rst b/Help/guide/tutorial/Adding Usage Requirements for a Library.rst index a8e914e..b521896 100644 --- a/Help/guide/tutorial/Adding Usage Requirements for a Library.rst +++ b/Help/guide/tutorial/Adding Usage Requirements for a Library.rst @@ -1,52 +1,142 @@ Step 3: Adding Usage Requirements for a Library =============================================== -Usage requirements allow for far better control over a library or executable's -link and include line while also giving more control over the transitive -property of targets inside CMake. The primary commands that leverage usage -requirements are: - - - :command:`target_compile_definitions` - - :command:`target_compile_options` - - :command:`target_include_directories` - - :command:`target_link_libraries` - -Let's refactor our code from :guide:`tutorial/Adding a Library` to use the -modern CMake approach of usage requirements. We first state that anybody -linking to ``MathFunctions`` needs to include the current source directory, -while ``MathFunctions`` itself doesn't. So this can become an ``INTERFACE`` -usage requirement. - -Remember ``INTERFACE`` means things that consumers require but the producer -doesn't. Add the following lines to the end of -``MathFunctions/CMakeLists.txt``: +Exercise 1 - Adding Usage Requirements for a Library +^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +Usage requirements allow for far better control over a library or +executable's link and include line while also giving more control over the +transitive property of targets inside CMake. The primary commands that +leverage usage requirements are: + +* :command:`target_compile_definitions` +* :command:`target_compile_options` +* :command:`target_include_directories` +* :command:`target_link_libraries` + +Goal +---- + +Add usage requirements for a library. + +Helpful Materials +----------------- + +* :command:`target_include_directories` +* :variable:`CMAKE_CURRENT_SOURCE_DIR` + +Files to Edit +------------- + +* ``MathFunctions/CMakeLists.txt`` +* ``CMakeLists.txt`` + +Getting Started +--------------- + +In this exercise, we will refactor our code from +:guide:`tutorial/Adding a Library` to use the modern CMake approach. We will +let our library define its own usage requirements so they are passed +transitively to other targets as necessary. In this case, ``MathFunctions`` +will specify any needed include directories itself. Then, the consuming target +``Tutorial`` simply needs to link to ``MathFunctions`` and not worry about +any additional include directories. + +The starting source code is provided in the ``Step3`` directory. In this +exercise, complete ``TODO 1`` through ``TODO 3``. + +First, add a call to :command:`target_include_directories` in +``MathFunctions/CMakeLists``. Remember that +:variable:`CMAKE_CURRENT_SOURCE_DIR` is the path to the source directory +currently being processed. + +Then, update (and simplify!) the call to +:command:`target_include_directories` in the top-level ``CMakeLists.txt``. + +Build and Run +------------- + +Make a new directory called ``Step3_build``, run the :manual:`cmake +<cmake(1)>` executable or the :manual:`cmake-gui <cmake-gui(1)>` to +configure the project and then build it with your chosen build tool or by +using ``cmake --build .`` from the build directory. Here's a refresher of +what that looks like from the command line: + +.. code-block:: console + + mkdir Step3_build + cd Step3_build + cmake ../Step3 + cmake --build . + +Next, use the newly built ``Tutorial`` and verify that it is working as +expected. + +Solution +-------- + +Let's update the code from the previous step to use the modern CMake +approach of usage requirements. + +We want to state that anybody linking to ``MathFunctions`` needs to include +the current source directory, while ``MathFunctions`` itself doesn't. This +can be expressed with an ``INTERFACE`` usage requirement. Remember +``INTERFACE`` means things that consumers require but the producer doesn't. + +At the end of ``MathFunctions/CMakeLists.txt``, use +:command:`target_include_directories` with the ``INTERFACE`` keyword, as +follows: + +.. raw:: html + + <details><summary>TODO 1: Click to show/hide answer</summary> .. literalinclude:: Step4/MathFunctions/CMakeLists.txt - :caption: MathFunctions/CMakeLists.txt + :caption: TODO 1: MathFunctions/CMakeLists.txt :name: MathFunctions/CMakeLists.txt-target_include_directories-INTERFACE :language: cmake :start-after: # to find MathFunctions.h -Now that we've specified usage requirements for ``MathFunctions`` we can safely -remove our uses of the ``EXTRA_INCLUDES`` variable from the top-level +.. raw:: html + + </details> + +Now that we've specified usage requirements for ``MathFunctions`` we can +safely remove our uses of the ``EXTRA_INCLUDES`` variable from the top-level ``CMakeLists.txt``, here: +.. raw:: html + + <details><summary>TODO 2: Click to show/hide answer</summary> + .. literalinclude:: Step4/CMakeLists.txt - :caption: CMakeLists.txt + :caption: TODO 2: CMakeLists.txt :name: CMakeLists.txt-remove-EXTRA_INCLUDES :language: cmake :start-after: # add the MathFunctions library :end-before: # add the executable +.. raw:: html + + </details> + And here: +.. raw:: html + + <details><summary>TODO 3: Click to show/hide answer</summary> + .. literalinclude:: Step4/CMakeLists.txt - :caption: CMakeLists.txt + :caption: TODO 3: CMakeLists.txt :name: CMakeLists.txt-target_include_directories-remove-EXTRA_INCLUDES :language: cmake :start-after: # so that we will find TutorialConfig.h -Once this is done, run the :manual:`cmake <cmake(1)>` executable or the -:manual:`cmake-gui <cmake-gui(1)>` to configure the project and then build it -with your chosen build tool or by using ``cmake --build .`` from the build -directory. +.. raw:: html + + </details> + +Notice that with this technique, the only thing our executable target does to +use our library is call :command:`target_link_libraries` with the name +of the library target. In larger projects, the classic method of specifying +library dependencies manually becomes very complicated very quickly. diff --git a/Help/guide/tutorial/Adding a Library.rst b/Help/guide/tutorial/Adding a Library.rst index 9b81894..46a8909 100644 --- a/Help/guide/tutorial/Adding a Library.rst +++ b/Help/guide/tutorial/Adding a Library.rst @@ -102,6 +102,7 @@ source file for the library is passed as an argument to :caption: TODO 1: MathFunctions/CMakeLists.txt :name: MathFunctions/CMakeLists.txt-add_library :language: cmake + :end-before: # TODO 1 .. raw:: html @@ -351,7 +352,7 @@ library names with ``EXTRA_LIBS``. This looks like the following: :name: CMakeLists.txt-target_link_libraries-EXTRA_LIBS :language: cmake :start-after: add_executable(Tutorial tutorial.cxx) - :end-before: # add the binary tree to the search path for include files + :end-before: # TODO 3 .. raw:: html diff --git a/Help/guide/tutorial/Step3/CMakeLists.txt b/Help/guide/tutorial/Step3/CMakeLists.txt index 1c12816..007770a 100644 --- a/Help/guide/tutorial/Step3/CMakeLists.txt +++ b/Help/guide/tutorial/Step3/CMakeLists.txt @@ -14,6 +14,8 @@ option(USE_MYMATH "Use tutorial provided math implementation" ON) # to the source code configure_file(TutorialConfig.h.in TutorialConfig.h) +# TODO 2: Remove EXTRA_INCLUDES list + # add the MathFunctions library if(USE_MYMATH) add_subdirectory(MathFunctions) @@ -26,6 +28,8 @@ add_executable(Tutorial tutorial.cxx) target_link_libraries(Tutorial PUBLIC ${EXTRA_LIBS}) +# TODO 3: Remove use of EXTRA_INCLUDES + # add the binary tree to the search path for include files # so that we will find TutorialConfig.h target_include_directories(Tutorial PUBLIC diff --git a/Help/guide/tutorial/Step3/MathFunctions/CMakeLists.txt b/Help/guide/tutorial/Step3/MathFunctions/CMakeLists.txt index 8b443a6..7bf05e0 100644 --- a/Help/guide/tutorial/Step3/MathFunctions/CMakeLists.txt +++ b/Help/guide/tutorial/Step3/MathFunctions/CMakeLists.txt @@ -1 +1,5 @@ add_library(MathFunctions mysqrt.cxx) + +# TODO 1: State that anybody linking to MathFunctions needs to include the +# current source directory, while MathFunctions itself doesn't. +# Hint: Use target_include_directories with the INTERFACE keyword diff --git a/Help/prop_gbl/CMAKE_CUDA_KNOWN_FEATURES.rst b/Help/prop_gbl/CMAKE_CUDA_KNOWN_FEATURES.rst index d93a9c1..a31ee3a 100644 --- a/Help/prop_gbl/CMAKE_CUDA_KNOWN_FEATURES.rst +++ b/Help/prop_gbl/CMAKE_CUDA_KNOWN_FEATURES.rst @@ -36,4 +36,9 @@ The features known to this version of CMake are: Compiler mode is at least CUDA/C++ 23. +``cuda_std_26`` + .. versionadded:: 3.25 + + Compiler mode is at least CUDA/C++ 26. + .. include:: CMAKE_LANG_STD_FLAGS.txt diff --git a/Help/prop_gbl/CMAKE_CXX_KNOWN_FEATURES.rst b/Help/prop_gbl/CMAKE_CXX_KNOWN_FEATURES.rst index 6846850..3832f1a 100644 --- a/Help/prop_gbl/CMAKE_CXX_KNOWN_FEATURES.rst +++ b/Help/prop_gbl/CMAKE_CXX_KNOWN_FEATURES.rst @@ -46,6 +46,11 @@ but it does not necessarily imply complete conformance to that standard. Compiler mode is at least C++ 23. +``cxx_std_26`` + .. versionadded:: 3.25 + + Compiler mode is at least C++ 26. + .. include:: CMAKE_LANG_STD_FLAGS.txt Low level individual compile features diff --git a/Help/prop_tgt/CUDA_STANDARD.rst b/Help/prop_tgt/CUDA_STANDARD.rst index 950ba12..ada69b9 100644 --- a/Help/prop_tgt/CUDA_STANDARD.rst +++ b/Help/prop_tgt/CUDA_STANDARD.rst @@ -39,6 +39,12 @@ Supported values are: CUDA C++23 +``26`` + .. versionadded:: 3.25 + + CUDA C++26. CMake 3.25 and later *recognize* ``26`` as a valid value, + no version has support for any compiler. + 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/prop_tgt/CXX_STANDARD.rst b/Help/prop_tgt/CXX_STANDARD.rst index b10d201..9b381e4 100644 --- a/Help/prop_tgt/CXX_STANDARD.rst +++ b/Help/prop_tgt/CXX_STANDARD.rst @@ -37,6 +37,12 @@ Supported values are: C++23 +``26`` + .. versionadded:: 3.25 + + C++26. CMake 3.25 and later *recognize* ``26`` as a valid value, + no version has support for any compiler. + 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/prop_tgt/HIP_STANDARD.rst b/Help/prop_tgt/HIP_STANDARD.rst index 0c767c6..9de8730 100644 --- a/Help/prop_tgt/HIP_STANDARD.rst +++ b/Help/prop_tgt/HIP_STANDARD.rst @@ -25,6 +25,12 @@ Supported values are: ``23`` HIP C++23 +``26`` + .. versionadded:: 3.25 + + HIP C++26. CMake 3.25 and later *recognize* ``26`` as a valid value, + no version has support for any compiler. + 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/prop_tgt/LANG_COMPILER_LAUNCHER.rst b/Help/prop_tgt/LANG_COMPILER_LAUNCHER.rst index cba8ac9..2e039bd 100644 --- a/Help/prop_tgt/LANG_COMPILER_LAUNCHER.rst +++ b/Help/prop_tgt/LANG_COMPILER_LAUNCHER.rst @@ -14,3 +14,8 @@ its arguments to the tool. Some example tools are distcc and ccache. This property is initialized by the value of the :variable:`CMAKE_<LANG>_COMPILER_LAUNCHER` variable if it is set when a target is created. + +.. versionadded:: 3.25 + + The property value may use + :manual:`generator expressions <cmake-generator-expressions(7)>`. diff --git a/Help/prop_tgt/OBJCXX_STANDARD.rst b/Help/prop_tgt/OBJCXX_STANDARD.rst index 654e687..6ac8216 100644 --- a/Help/prop_tgt/OBJCXX_STANDARD.rst +++ b/Help/prop_tgt/OBJCXX_STANDARD.rst @@ -31,6 +31,12 @@ Supported values are: Objective C++23 +``26`` + .. versionadded:: 3.25 + + Objective C++26. CMake 3.25 and later *recognize* ``26`` as a valid value, + no version has support for any compiler. + 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/release/dev/compiler-launcher-genexp.rst b/Help/release/dev/compiler-launcher-genexp.rst new file mode 100644 index 0000000..0e79992 --- /dev/null +++ b/Help/release/dev/compiler-launcher-genexp.rst @@ -0,0 +1,5 @@ +compiler-launcher-genexp +------------------------ + +* The :prop_tgt:`<LANG>_COMPILER_LAUNCHER` target property now supports + :manual:`generator expressions <cmake-generator-expressions(7)>`. diff --git a/Help/release/dev/cxx_std_26.rst b/Help/release/dev/cxx_std_26.rst new file mode 100644 index 0000000..831f567 --- /dev/null +++ b/Help/release/dev/cxx_std_26.rst @@ -0,0 +1,8 @@ +cxx_std_26 +---------- + +* C++26 compiler modes may now be specified via the :prop_tgt:`CXX_STANDARD`, + :prop_tgt:`CUDA_STANDARD`, :prop_tgt:`HIP_STANDARD`, or + :prop_tgt:`OBJCXX_STANDARD` target properties, + or via the :manual:`Compile Features <cmake-compile-features(7)>` + functionality's ``cxx_std_26`` meta-feature. diff --git a/Modules/CMakeDetermineCompileFeatures.cmake b/Modules/CMakeDetermineCompileFeatures.cmake index a08e597..09de7b1 100644 --- a/Modules/CMakeDetermineCompileFeatures.cmake +++ b/Modules/CMakeDetermineCompileFeatures.cmake @@ -63,6 +63,7 @@ function(cmake_determine_compile_features lang) set(CMAKE_CXX17_COMPILE_FEATURES) set(CMAKE_CXX20_COMPILE_FEATURES) set(CMAKE_CXX23_COMPILE_FEATURES) + set(CMAKE_CXX26_COMPILE_FEATURES) include("${CMAKE_ROOT}/Modules/Internal/FeatureTesting.cmake") @@ -73,6 +74,9 @@ function(cmake_determine_compile_features lang) return() endif() + if (CMAKE_CXX23_COMPILE_FEATURES AND CMAKE_CXX26_COMPILE_FEATURES) + list(REMOVE_ITEM CMAKE_CXX26_COMPILE_FEATURES ${CMAKE_CXX23_COMPILE_FEATURES}) + endif() if (CMAKE_CXX20_COMPILE_FEATURES AND CMAKE_CXX23_COMPILE_FEATURES) list(REMOVE_ITEM CMAKE_CXX23_COMPILE_FEATURES ${CMAKE_CXX20_COMPILE_FEATURES}) endif() @@ -97,6 +101,7 @@ function(cmake_determine_compile_features lang) ${CMAKE_CXX17_COMPILE_FEATURES} ${CMAKE_CXX20_COMPILE_FEATURES} ${CMAKE_CXX23_COMPILE_FEATURES} + ${CMAKE_CXX26_COMPILE_FEATURES} ) endif() @@ -107,6 +112,7 @@ function(cmake_determine_compile_features lang) set(CMAKE_CXX17_COMPILE_FEATURES ${CMAKE_CXX17_COMPILE_FEATURES} PARENT_SCOPE) set(CMAKE_CXX20_COMPILE_FEATURES ${CMAKE_CXX20_COMPILE_FEATURES} PARENT_SCOPE) set(CMAKE_CXX23_COMPILE_FEATURES ${CMAKE_CXX23_COMPILE_FEATURES} PARENT_SCOPE) + set(CMAKE_CXX26_COMPILE_FEATURES ${CMAKE_CXX26_COMPILE_FEATURES} PARENT_SCOPE) message(CHECK_PASS "done") @@ -119,6 +125,7 @@ function(cmake_determine_compile_features lang) set(CMAKE_CUDA17_COMPILE_FEATURES) set(CMAKE_CUDA20_COMPILE_FEATURES) set(CMAKE_CUDA23_COMPILE_FEATURES) + set(CMAKE_CUDA26_COMPILE_FEATURES) include("${CMAKE_ROOT}/Modules/Internal/FeatureTesting.cmake") @@ -129,6 +136,9 @@ function(cmake_determine_compile_features lang) return() endif() + if (CMAKE_CUDA23_COMPILE_FEATURES AND CMAKE_CUDA26_COMPILE_FEATURES) + list(REMOVE_ITEM CMAKE_CUDA26_COMPILE_FEATURES ${CMAKE_CUDA23_COMPILE_FEATURES}) + endif() if (CMAKE_CUDA20_COMPILE_FEATURES AND CMAKE_CUDA23_COMPILE_FEATURES) list(REMOVE_ITEM CMAKE_CUDA23_COMPILE_FEATURES ${CMAKE_CUDA20_COMPILE_FEATURES}) endif() @@ -153,6 +163,7 @@ function(cmake_determine_compile_features lang) ${CMAKE_CUDA17_COMPILE_FEATURES} ${CMAKE_CUDA20_COMPILE_FEATURES} ${CMAKE_CUDA23_COMPILE_FEATURES} + ${CMAKE_CUDA26_COMPILE_FEATURES} ) endif() @@ -163,6 +174,7 @@ function(cmake_determine_compile_features lang) set(CMAKE_CUDA17_COMPILE_FEATURES ${CMAKE_CUDA17_COMPILE_FEATURES} PARENT_SCOPE) set(CMAKE_CUDA20_COMPILE_FEATURES ${CMAKE_CUDA20_COMPILE_FEATURES} PARENT_SCOPE) set(CMAKE_CUDA23_COMPILE_FEATURES ${CMAKE_CUDA23_COMPILE_FEATURES} PARENT_SCOPE) + set(CMAKE_CUDA26_COMPILE_FEATURES ${CMAKE_CUDA26_COMPILE_FEATURES} PARENT_SCOPE) message(CHECK_PASS "done") @@ -175,6 +187,8 @@ function(cmake_determine_compile_features lang) set(CMAKE_HIP17_COMPILE_FEATURES) set(CMAKE_HIP20_COMPILE_FEATURES) set(CMAKE_HIP23_COMPILE_FEATURES) + set(CMAKE_HIP26_COMPILE_FEATURES) + include("${CMAKE_ROOT}/Modules/Internal/FeatureTesting.cmake") @@ -185,6 +199,9 @@ function(cmake_determine_compile_features lang) return() endif() + if (CMAKE_HIP23_COMPILE_FEATURES AND CMAKE_HIP26_COMPILE_FEATURES) + list(REMOVE_ITEM CMAKE_HIP26_COMPILE_FEATURES ${CMAKE_HIP23_COMPILE_FEATURES}) + endif() if (CMAKE_HIP20_COMPILE_FEATURES AND CMAKE_HIP23_COMPILE_FEATURES) list(REMOVE_ITEM CMAKE_HIP23_COMPILE_FEATURES ${CMAKE_HIP20_COMPILE_FEATURES}) endif() @@ -209,6 +226,7 @@ function(cmake_determine_compile_features lang) ${CMAKE_HIP17_COMPILE_FEATURES} ${CMAKE_HIP20_COMPILE_FEATURES} ${CMAKE_HIP23_COMPILE_FEATURES} + ${CMAKE_HIP26_COMPILE_FEATURES} ) endif() @@ -219,6 +237,7 @@ function(cmake_determine_compile_features lang) set(CMAKE_HIP17_COMPILE_FEATURES ${CMAKE_HIP17_COMPILE_FEATURES} PARENT_SCOPE) set(CMAKE_HIP20_COMPILE_FEATURES ${CMAKE_HIP20_COMPILE_FEATURES} PARENT_SCOPE) set(CMAKE_HIP23_COMPILE_FEATURES ${CMAKE_HIP23_COMPILE_FEATURES} PARENT_SCOPE) + set(CMAKE_HIP26_COMPILE_FEATURES ${CMAKE_HIP26_COMPILE_FEATURES} PARENT_SCOPE) message(CHECK_PASS "done") diff --git a/Modules/Compiler/Clang.cmake b/Modules/Compiler/Clang.cmake index df115d3..257402a 100644 --- a/Modules/Compiler/Clang.cmake +++ b/Modules/Compiler/Clang.cmake @@ -255,6 +255,7 @@ macro(__compiler_clang_cxx_standards lang) cxx_std_17 cxx_std_20 cxx_std_23 + cxx_std_26 ) _record_compiler_features(${lang} "" CMAKE_${lang}_COMPILE_FEATURES) endmacro() diff --git a/Modules/Compiler/MSVC-CXX.cmake b/Modules/Compiler/MSVC-CXX.cmake index 75165fd..60d13f1 100644 --- a/Modules/Compiler/MSVC-CXX.cmake +++ b/Modules/Compiler/MSVC-CXX.cmake @@ -72,6 +72,7 @@ elseif (CMAKE_CXX_COMPILER_VERSION VERSION_GREATER_EQUAL 16.0) cxx_std_17 cxx_std_20 cxx_std_23 + cxx_std_26 ) _record_compiler_features(CXX "" CMAKE_CXX_COMPILE_FEATURES) endmacro() diff --git a/Modules/FindMatlab.cmake b/Modules/FindMatlab.cmake index 48ef5eb..ec2c345 100644 --- a/Modules/FindMatlab.cmake +++ b/Modules/FindMatlab.cmake @@ -85,10 +85,18 @@ Module Input Variables Users or projects may set the following variables to configure the module behavior: +:variable:`Matlab_ROOT <<PackageName>_ROOT>` + .. versionadded:: 3.25 + + Default value for :variable:`Matlab_ROOT_DIR`, the root of the Matlab + installation. + :variable:`Matlab_ROOT_DIR` - the root of the Matlab installation. + The root of the Matlab installation. + :variable:`MATLAB_FIND_DEBUG` outputs debug information + :variable:`MATLAB_ADDITIONAL_VERSIONS` additional versions of Matlab for the automatic retrieval of the installed versions. @@ -843,6 +851,15 @@ function(matlab_get_version_from_matlab_run matlab_binary_program matlab_list_ve endif() endif() + if(NOT EXISTS "${_matlab_temporary_folder}/matlabVersionLog.cmaketmp") + # last resort check as some HPC with "module load matlab" not enacted fail to catch in earlier checks + # and error CMake configure even if find_package(Matlab) is not REQUIRED + if(MATLAB_FIND_DEBUG) + message(WARNING "[MATLAB] Unable to determine the version of Matlab. The version log file does not exist.") + endif() + return() + endif() + # if successful, read back the log file(READ "${_matlab_temporary_folder}/matlabVersionLog.cmaketmp" _matlab_version_from_cmd) file(REMOVE "${_matlab_temporary_folder}/matlabVersionLog.cmaketmp") @@ -1572,6 +1589,13 @@ endfunction() # this variable will get all Matlab installations found in the current system. set(_matlab_possible_roots) +if(NOT DEFINED Matlab_ROOT AND DEFINED ENV{Matlab_ROOT}) + set(Matlab_ROOT $ENV{Matlab_ROOT}) +endif() +if(DEFINED Matlab_ROOT) + set(Matlab_ROOT_DIR ${Matlab_ROOT}) +endif() + if(Matlab_ROOT_DIR) # if the user specifies a possible root, we keep this one diff --git a/Modules/FindPostgreSQL.cmake b/Modules/FindPostgreSQL.cmake index 2233aa0..c92fbdc 100644 --- a/Modules/FindPostgreSQL.cmake +++ b/Modules/FindPostgreSQL.cmake @@ -121,13 +121,16 @@ foreach(suffix ${PostgreSQL_KNOWN_VERSIONS}) if(UNIX) list(APPEND PostgreSQL_LIBRARY_ADDITIONAL_SEARCH_SUFFIXES "postgresql${suffix}" + "postgresql@${suffix}" "pgsql-${suffix}/lib") list(APPEND PostgreSQL_INCLUDE_ADDITIONAL_SEARCH_SUFFIXES "postgresql${suffix}" + "postgresql@${suffix}" "postgresql/${suffix}" "pgsql-${suffix}/include") list(APPEND PostgreSQL_TYPE_ADDITIONAL_SEARCH_SUFFIXES "postgresql${suffix}/server" + "postgresql@${suffix}/server" "postgresql/${suffix}/server" "pgsql-${suffix}/include/server") endif() diff --git a/Source/CMakeVersion.cmake b/Source/CMakeVersion.cmake index f4f676c..6845c6c 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 24) -set(CMake_VERSION_PATCH 20220901) +set(CMake_VERSION_PATCH 20220902) #set(CMake_VERSION_RC 0) set(CMake_VERSION_IS_DIRTY 0) diff --git a/Source/cmGlobalXCodeGenerator.cxx b/Source/cmGlobalXCodeGenerator.cxx index 7523662..eb85b47 100644 --- a/Source/cmGlobalXCodeGenerator.cxx +++ b/Source/cmGlobalXCodeGenerator.cxx @@ -3650,6 +3650,7 @@ void cmGlobalXCodeGenerator::AddDependAndLinkInformation(cmXCodeObject* target) } } } else { + linkDir = cmSystemTools::GetParentDirectory(linkDir); if (std::find(linkSearchPaths.begin(), linkSearchPaths.end(), linkDir) == linkSearchPaths.end()) { linkSearchPaths.push_back(linkDir); diff --git a/Source/cmMakefileTargetGenerator.cxx b/Source/cmMakefileTargetGenerator.cxx index 1e1df79..d19bbb9 100644 --- a/Source/cmMakefileTargetGenerator.cxx +++ b/Source/cmMakefileTargetGenerator.cxx @@ -1042,8 +1042,10 @@ void cmMakefileTargetGenerator::WriteObjectRuleFiles( lang == "OBJCXX")) { std::string const clauncher_prop = lang + "_COMPILER_LAUNCHER"; cmValue clauncher = this->GeneratorTarget->GetProperty(clauncher_prop); - if (cmNonempty(clauncher)) { - compilerLauncher = *clauncher; + std::string evaluatedClauncher = cmGeneratorExpression::Evaluate( + *clauncher, this->LocalGenerator, config); + if (!evaluatedClauncher.empty()) { + compilerLauncher = evaluatedClauncher; } } diff --git a/Source/cmNinjaTargetGenerator.cxx b/Source/cmNinjaTargetGenerator.cxx index a4080d8..e4427f5 100644 --- a/Source/cmNinjaTargetGenerator.cxx +++ b/Source/cmNinjaTargetGenerator.cxx @@ -912,8 +912,10 @@ void cmNinjaTargetGenerator::WriteCompileRule(const std::string& lang, lang == "OBJCXX")) { std::string const clauncher_prop = cmStrCat(lang, "_COMPILER_LAUNCHER"); cmValue clauncher = this->GeneratorTarget->GetProperty(clauncher_prop); - if (cmNonempty(clauncher)) { - compilerLauncher = *clauncher; + std::string evaluatedClauncher = cmGeneratorExpression::Evaluate( + *clauncher, this->LocalGenerator, config); + if (!evaluatedClauncher.empty()) { + compilerLauncher = evaluatedClauncher; } } diff --git a/Source/cmStandardLevelResolver.cxx b/Source/cmStandardLevelResolver.cxx index be15288..d2eac0c 100644 --- a/Source/cmStandardLevelResolver.cxx +++ b/Source/cmStandardLevelResolver.cxx @@ -379,25 +379,29 @@ std::unordered_map<std::string, StandardLevelComputer> "C", std::vector<int>{ 90, 99, 11, 17, 23 }, std::vector<std::string>{ "90", "99", "11", "17", "23" } } }, { "CXX", - StandardLevelComputer{ - "CXX", std::vector<int>{ 98, 11, 14, 17, 20, 23 }, - std::vector<std::string>{ "98", "11", "14", "17", "20", "23" } } }, + StandardLevelComputer{ "CXX", + std::vector<int>{ 98, 11, 14, 17, 20, 23, 26 }, + std::vector<std::string>{ "98", "11", "14", "17", + "20", "23", "26" } } }, { "CUDA", - StandardLevelComputer{ - "CUDA", std::vector<int>{ 03, 11, 14, 17, 20, 23 }, - std::vector<std::string>{ "03", "11", "14", "17", "20", "23" } } }, + StandardLevelComputer{ "CUDA", + std::vector<int>{ 03, 11, 14, 17, 20, 23, 26 }, + std::vector<std::string>{ "03", "11", "14", "17", + "20", "23", "26" } } }, { "OBJC", StandardLevelComputer{ "OBJC", std::vector<int>{ 90, 99, 11, 17, 23 }, std::vector<std::string>{ "90", "99", "11", "17", "23" } } }, { "OBJCXX", - StandardLevelComputer{ - "OBJCXX", std::vector<int>{ 98, 11, 14, 17, 20, 23 }, - std::vector<std::string>{ "98", "11", "14", "17", "20", "23" } } }, + StandardLevelComputer{ "OBJCXX", + std::vector<int>{ 98, 11, 14, 17, 20, 23, 26 }, + std::vector<std::string>{ "98", "11", "14", "17", + "20", "23", "26" } } }, { "HIP", - StandardLevelComputer{ - "HIP", std::vector<int>{ 98, 11, 14, 17, 20, 23 }, - std::vector<std::string>{ "98", "11", "14", "17", "20", "23" } } } + StandardLevelComputer{ "HIP", + std::vector<int>{ 98, 11, 14, 17, 20, 23, 26 }, + std::vector<std::string>{ "98", "11", "14", "17", + "20", "23", "26" } } } }; } diff --git a/Source/cmake.h b/Source/cmake.h index a631647..8c0fece 100644 --- a/Source/cmake.h +++ b/Source/cmake.h @@ -861,6 +861,7 @@ private: F(cxx_std_17) \ F(cxx_std_20) \ F(cxx_std_23) \ + F(cxx_std_26) \ FOR_EACH_CXX98_FEATURE(F) \ FOR_EACH_CXX11_FEATURE(F) \ FOR_EACH_CXX14_FEATURE(F) @@ -871,7 +872,8 @@ private: F(cuda_std_14) \ F(cuda_std_17) \ F(cuda_std_20) \ - F(cuda_std_23) + F(cuda_std_23) \ + F(cuda_std_26) #define FOR_EACH_HIP_FEATURE(F) \ F(hip_std_98) \ @@ -879,4 +881,5 @@ private: F(hip_std_14) \ F(hip_std_17) \ F(hip_std_20) \ - F(hip_std_23) + F(hip_std_23) \ + F(hip_std_26) diff --git a/Tests/CompileFeatures/CMakeLists.txt b/Tests/CompileFeatures/CMakeLists.txt index c6d1e8a..f3d3a73 100644 --- a/Tests/CompileFeatures/CMakeLists.txt +++ b/Tests/CompileFeatures/CMakeLists.txt @@ -356,6 +356,7 @@ else() HAVE_CXX_STD_17=$<COMPILE_FEATURES:cxx_std_17> HAVE_CXX_STD_20=$<COMPILE_FEATURES:cxx_std_20> HAVE_CXX_STD_23=$<COMPILE_FEATURES:cxx_std_23> + HAVE_CXX_STD_26=$<COMPILE_FEATURES:cxx_std_26> ) endif() diff --git a/Tests/CompileFeatures/genex_test.cpp b/Tests/CompileFeatures/genex_test.cpp index 9c3910e..048f3de 100644 --- a/Tests/CompileFeatures/genex_test.cpp +++ b/Tests/CompileFeatures/genex_test.cpp @@ -27,6 +27,9 @@ # if HAVE_CXX_STD_23 && !defined(ALLOW_LATER_STANDARDS) # error HAVE_CXX_STD_23 is true with CXX_STANDARD == 11 # endif +# if HAVE_CXX_STD_26 && !defined(ALLOW_LATER_STANDARDS) +# error HAVE_CXX_STD_26 is true with CXX_STANDARD == 11 +# endif #endif #if !HAVE_OVERRIDE_CONTROL diff --git a/Tests/Complex/CMakeLists.txt b/Tests/Complex/CMakeLists.txt index 5df22d2..9493a2f 100644 --- a/Tests/Complex/CMakeLists.txt +++ b/Tests/Complex/CMakeLists.txt @@ -5,6 +5,14 @@ cmake_minimum_required(VERSION 2.4) cmake_policy(SET CMP0054 NEW) project (Complex) +# Inform the test if the debug configuration is getting built. +string(APPEND CMAKE_C_FLAGS_RELEASE " -DCOMPLEX_NDEBUG") +string(APPEND CMAKE_CXX_FLAGS_RELEASE " -DCOMPLEX_NDEBUG") +string(APPEND CMAKE_C_FLAGS_RELWITHDEBINFO " -DCOMPLEX_NDEBUG") +string(APPEND CMAKE_CXX_FLAGS_RELWITHDEBINFO " -DCOMPLEX_NDEBUG") +string(APPEND CMAKE_C_FLAGS_MINSIZEREL " -DCOMPLEX_NDEBUG") +string(APPEND CMAKE_CXX_FLAGS_MINSIZEREL " -DCOMPLEX_NDEBUG") + # Test that renaming a built-in works when configured multiple times. message("message") function(message) diff --git a/Tests/Complex/Executable/complex.cxx b/Tests/Complex/Executable/complex.cxx index 49e97d5..67a1645 100644 --- a/Tests/Complex/Executable/complex.cxx +++ b/Tests/Complex/Executable/complex.cxx @@ -62,7 +62,7 @@ void cmPassed(const char* Message, const char* m2 = "") # error This is a problem. Looks like ADD_DEFINITIONS and REMOVE_DEFINITIONS does not work #endif -#if defined(NDEBUG) && !defined(CMAKE_IS_FUN_IN_RELEASE_MODE) +#if defined(COMPLEX_NDEBUG) && !defined(CMAKE_IS_FUN_IN_RELEASE_MODE) # error Per-configuration directory-level definition not inherited. #endif diff --git a/Tests/ComplexOneConfig/CMakeLists.txt b/Tests/ComplexOneConfig/CMakeLists.txt index 5a4134d..e4fdc68 100644 --- a/Tests/ComplexOneConfig/CMakeLists.txt +++ b/Tests/ComplexOneConfig/CMakeLists.txt @@ -5,6 +5,14 @@ cmake_minimum_required(VERSION 2.4) cmake_policy(SET CMP0054 NEW) project (Complex) +# Inform the test if the debug configuration is getting built. +string(APPEND CMAKE_C_FLAGS_RELEASE " -DCOMPLEX_NDEBUG") +string(APPEND CMAKE_CXX_FLAGS_RELEASE " -DCOMPLEX_NDEBUG") +string(APPEND CMAKE_C_FLAGS_RELWITHDEBINFO " -DCOMPLEX_NDEBUG") +string(APPEND CMAKE_CXX_FLAGS_RELWITHDEBINFO " -DCOMPLEX_NDEBUG") +string(APPEND CMAKE_C_FLAGS_MINSIZEREL " -DCOMPLEX_NDEBUG") +string(APPEND CMAKE_CXX_FLAGS_MINSIZEREL " -DCOMPLEX_NDEBUG") + # Try setting a new policy. The IF test is for coverage. if(POLICY CMP0003) cmake_policy(SET CMP0003 NEW) diff --git a/Tests/ComplexOneConfig/Executable/complex.cxx b/Tests/ComplexOneConfig/Executable/complex.cxx index 54c18f4..097668b 100644 --- a/Tests/ComplexOneConfig/Executable/complex.cxx +++ b/Tests/ComplexOneConfig/Executable/complex.cxx @@ -62,7 +62,7 @@ void cmPassed(const char* Message, const char* m2 = "") # error This is a problem. Looks like ADD_DEFINITIONS and REMOVE_DEFINITIONS does not work #endif -#if defined(NDEBUG) && !defined(CMAKE_IS_FUN_IN_RELEASE_MODE) +#if defined(COMPLEX_NDEBUG) && !defined(CMAKE_IS_FUN_IN_RELEASE_MODE) # error Per-configuration directory-level definition not inherited. #endif diff --git a/Tests/Preprocess/CMakeLists.txt b/Tests/Preprocess/CMakeLists.txt index 4347459..84ca5e8 100644 --- a/Tests/Preprocess/CMakeLists.txt +++ b/Tests/Preprocess/CMakeLists.txt @@ -197,9 +197,14 @@ endif() #----------------------------------------------------------------------------- # Inform the test if the debug configuration is getting built. -# The NDEBUG definition takes care of this for release. string(APPEND CMAKE_C_FLAGS_DEBUG " -DPREPROCESS_DEBUG") string(APPEND CMAKE_CXX_FLAGS_DEBUG " -DPREPROCESS_DEBUG") +string(APPEND CMAKE_C_FLAGS_RELEASE " -DPREPROCESS_NDEBUG") +string(APPEND CMAKE_CXX_FLAGS_RELEASE " -DPREPROCESS_NDEBUG") +string(APPEND CMAKE_C_FLAGS_RELWITHDEBINFO " -DPREPROCESS_NDEBUG") +string(APPEND CMAKE_CXX_FLAGS_RELWITHDEBINFO " -DPREPROCESS_NDEBUG") +string(APPEND CMAKE_C_FLAGS_MINSIZEREL " -DPREPROCESS_NDEBUG") +string(APPEND CMAKE_CXX_FLAGS_MINSIZEREL " -DPREPROCESS_NDEBUG") # Inform the test if it built from Xcode. if(PP_XCODE) diff --git a/Tests/Preprocess/preprocess.c b/Tests/Preprocess/preprocess.c index b3117da..88f9e97 100644 --- a/Tests/Preprocess/preprocess.c +++ b/Tests/Preprocess/preprocess.c @@ -33,7 +33,7 @@ int check_defines_C(void) result = 0; } } -#ifdef NDEBUG +#ifdef PREPROCESS_NDEBUG # ifdef FILE_DEF_DEBUG { fprintf(stderr, "FILE_DEF_DEBUG should not be defined in C\n"); diff --git a/Tests/Preprocess/preprocess.cxx b/Tests/Preprocess/preprocess.cxx index f2fffef..50150d1 100644 --- a/Tests/Preprocess/preprocess.cxx +++ b/Tests/Preprocess/preprocess.cxx @@ -35,7 +35,7 @@ int check_defines_CXX() result = 0; } } -#ifdef NDEBUG +#ifdef PREPROCESS_NDEBUG # ifdef FILE_DEF_DEBUG { fprintf(stderr, "FILE_DEF_DEBUG should not be defined in CXX\n"); diff --git a/Tests/RunCMake/CompilerLauncher/RunCMakeTest.cmake b/Tests/RunCMake/CompilerLauncher/RunCMakeTest.cmake index 84d0479..e6a2605 100644 --- a/Tests/RunCMake/CompilerLauncher/RunCMakeTest.cmake +++ b/Tests/RunCMake/CompilerLauncher/RunCMakeTest.cmake @@ -17,7 +17,8 @@ endfunction() function(run_compiler_launcher_env lang) string(REGEX REPLACE "-.*" "" core_lang "${lang}") - set(ENV{CMAKE_${core_lang}_COMPILER_LAUNCHER} "${CMAKE_COMMAND};-E;env;USED_LAUNCHER=1") + # Use the noop genexp $<PATH:...> genexp to validate genexp support. + set(ENV{CMAKE_${core_lang}_COMPILER_LAUNCHER} "$<PATH:CMAKE_PATH,${CMAKE_COMMAND}>;-E;env;USED_LAUNCHER=1") run_compiler_launcher(${lang}) unset(ENV{CMAKE_${core_lang}_COMPILER_LAUNCHER}) endfunction() diff --git a/Tests/RunCMake/XcodeProject/BundleLinkBundle.cmake b/Tests/RunCMake/XcodeProject/BundleLinkBundle.cmake new file mode 100644 index 0000000..1f3c19d --- /dev/null +++ b/Tests/RunCMake/XcodeProject/BundleLinkBundle.cmake @@ -0,0 +1,14 @@ +cmake_minimum_required(VERSION 3.23) + +project(BundleLinkBundle CXX) + +add_subdirectory(lib_bundle) + +add_executable(MainBundle MACOSX_BUNDLE main_bundle.cpp) + +target_link_libraries(MainBundle PRIVATE LibBundle) + +set_target_properties(MainBundle PROPERTIES + MACOSX_BUNDLE "YES" + XCODE_LINK_BUILD_PHASE_MODE BUILT_ONLY +) diff --git a/Tests/RunCMake/XcodeProject/RunCMakeTest.cmake b/Tests/RunCMake/XcodeProject/RunCMakeTest.cmake index 80c6b73..d20f5a6 100644 --- a/Tests/RunCMake/XcodeProject/RunCMakeTest.cmake +++ b/Tests/RunCMake/XcodeProject/RunCMakeTest.cmake @@ -151,6 +151,16 @@ endfunction() XcodeXCConfig() +function(BundleLinkBundle) + set(RunCMake_TEST_BINARY_DIR ${RunCMake_BINARY_DIR}/BundleLinkBundle-build) + run_cmake(BundleLinkBundle) + set(RunCMake_TEST_NO_CLEAN 1) + run_cmake_command(BundleLinkBundle-build ${CMAKE_COMMAND} --build .) +endfunction() + +BundleLinkBundle() + + # Isolate device tests from host architecture selection. unset(ENV{CMAKE_OSX_ARCHITECTURES}) diff --git a/Tests/RunCMake/XcodeProject/lib_bundle/CMakeLIsts.txt b/Tests/RunCMake/XcodeProject/lib_bundle/CMakeLIsts.txt new file mode 100644 index 0000000..7a50ce8 --- /dev/null +++ b/Tests/RunCMake/XcodeProject/lib_bundle/CMakeLIsts.txt @@ -0,0 +1,5 @@ + +add_library(LibBundle lib_bundle.cpp) + +set_target_properties(LibBundle PROPERTIES + MACOSX_BUNDLE YES) diff --git a/Tests/RunCMake/XcodeProject/lib_bundle/lib_bundle.cpp b/Tests/RunCMake/XcodeProject/lib_bundle/lib_bundle.cpp new file mode 100644 index 0000000..9f74584 --- /dev/null +++ b/Tests/RunCMake/XcodeProject/lib_bundle/lib_bundle.cpp @@ -0,0 +1,6 @@ +#include <iostream> + +void foo() +{ + std::cout << "foobar" << std::endl; +} diff --git a/Tests/RunCMake/XcodeProject/main_bundle.cpp b/Tests/RunCMake/XcodeProject/main_bundle.cpp new file mode 100644 index 0000000..11834ac --- /dev/null +++ b/Tests/RunCMake/XcodeProject/main_bundle.cpp @@ -0,0 +1,9 @@ + +extern void foo(); + +int main() +{ + + foo(); + return 0; +} |