diff options
170 files changed, 1286 insertions, 435 deletions
diff --git a/.gitlab/artifacts.yml b/.gitlab/artifacts.yml index 45e4c5b..982f50b 100644 --- a/.gitlab/artifacts.yml +++ b/.gitlab/artifacts.yml @@ -56,7 +56,7 @@ # Test directories. - build/Tests/CTest* - build/Tests/Find* - - build/Tests/Qt5* + - build/Tests/Qt* - build/Tests/RunCMake/ - build/Tests/CMakeOnly/ - build/Tests/CMakeTests/ diff --git a/.gitlab/ci/docker/cuda9.2/install_deps.sh b/.gitlab/ci/docker/cuda9.2/install_deps.sh index 146f982..0dcb507 100755 --- a/.gitlab/ci/docker/cuda9.2/install_deps.sh +++ b/.gitlab/ci/docker/cuda9.2/install_deps.sh @@ -4,6 +4,12 @@ set -e apt-get update +# Update base packages. +apt-get install -y \ + libgnutls30 \ + libssl1.0.0 \ + openssl + # Install development tools. apt-get install -y \ g++ \ diff --git a/.gitlab/os-linux.yml b/.gitlab/os-linux.yml index 1513c90..948775c 100644 --- a/.gitlab/os-linux.yml +++ b/.gitlab/os-linux.yml @@ -209,7 +209,7 @@ ### CUDA builds .cuda9.2: - image: "kitware/cmake:ci-cuda9.2-x86_64-2021-07-01" + image: "kitware/cmake:ci-cuda9.2-x86_64-2021-10-01" variables: GIT_CLONE_PATH: "$CI_BUILDS_DIR/cmake ci" diff --git a/Help/guide/tutorial/A Basic Starting Point.rst b/Help/guide/tutorial/A Basic Starting Point.rst index 41e8479..cf1ec01 100644 --- a/Help/guide/tutorial/A Basic Starting Point.rst +++ b/Help/guide/tutorial/A Basic Starting Point.rst @@ -24,6 +24,45 @@ Upper, lower, and mixed case commands are supported by CMake. The source code for ``tutorial.cxx`` is provided in the ``Step1`` directory and can be used to compute the square root of a number. +Build and Run +------------- + +That's all that is needed - we can build and run our project now! First, 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. + +For example, from the command line we could navigate to the +``Help/guide/tutorial`` directory of the CMake source code tree and create a +build directory: + +.. code-block:: console + + mkdir Step1_build + +Next, navigate to the build directory and run CMake to configure the project +and generate a native build system: + +.. code-block:: console + + cd Step1_build + cmake ../Step1 + +Then call that build system to actually compile/link the project: + +.. code-block:: console + + cmake --build . + +Finally, try to use the newly built ``Tutorial`` with these commands: + +.. code-block:: console + + Tutorial 4294967296 + Tutorial 10 + Tutorial + + Adding a Version Number and Configured Header File -------------------------------------------------- @@ -113,39 +152,24 @@ call to ``add_executable``. :language: cmake :end-before: # configure a header file to pass some of the CMake settings -Build and Test --------------- - -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. - -For example, from the command line we could navigate to the -``Help/guide/tutorial`` directory of the CMake source code tree and create a -build directory: - -.. code-block:: console +Rebuild +------- - mkdir Step1_build - -Next, navigate to the build directory and run CMake to configure the project -and generate a native build system: +Let's build our project again. We already created a build directory and ran +CMake, so we can skip to the build step: .. code-block:: console cd Step1_build - cmake ../Step1 - -Then call that build system to actually compile/link the project: - -.. code-block:: console - cmake --build . -Finally, try to use the newly built ``Tutorial`` with these commands: +Now we can try to use the newly built ``Tutorial`` with same commands as before: .. code-block:: console Tutorial 4294967296 Tutorial 10 Tutorial + +Check that the version number is now reported when running the executable without +any arguments. diff --git a/Help/guide/tutorial/Adding Export Configuration.rst b/Help/guide/tutorial/Adding Export Configuration.rst index e5ab6a2..3bd6d64 100644 --- a/Help/guide/tutorial/Adding Export Configuration.rst +++ b/Help/guide/tutorial/Adding Export Configuration.rst @@ -12,10 +12,10 @@ packaged. The first step is to update our :command:`install(TARGETS)` commands to not only specify a ``DESTINATION`` but also an ``EXPORT``. The ``EXPORT`` keyword -generates and installs a CMake file containing code to import all targets -listed in the install command from the installation tree. So let's go ahead and -explicitly ``EXPORT`` the ``MathFunctions`` library by updating the ``install`` -command in ``MathFunctions/CMakeLists.txt`` to look like: +generates a CMake file containing code to import all targets listed in the +install command from the installation tree. So let's go ahead and explicitly +``EXPORT`` the ``MathFunctions`` library by updating the ``install`` command +in ``MathFunctions/CMakeLists.txt`` to look like: .. literalinclude:: Complete/MathFunctions/CMakeLists.txt :caption: MathFunctions/CMakeLists.txt @@ -82,6 +82,46 @@ bottom of the top-level ``CMakeLists.txt``: :name: CMakeLists.txt-install-Config.cmake :language: cmake :start-after: # install the configuration targets + :end-before: # generate the config file + + +Next, we execute the :command:`configure_package_config_file`. This command +will configure a provided file but with a few specific differences from the +standard :command:`configure_file` way. +To properly utilize this function, the input file should have a single line +with the text ``@PACKAGE_INIT@`` in addition to the content that is desired. +That variable will be replaced with a block of code which turns set values into +relative paths. These values which are new can be referenced by the same name +but prepended with a ``PACKAGE_`` prefix. + +.. literalinclude:: Step12/CMakeLists.txt + :caption: CMakeLists.txt + :name: CMakeLists.txt-configure-package-config.cmake + :language: cmake + :start-after: # install the configuration targets + :end-before: # generate the version file + +The :command:`write_basic_package_version_file` is next. This command writes +a file which is used by the "find_package" document the version and +compatibility of the desired package. Here, we use the ``Tutorial_VERSION_*`` +variables and say that it is compatible with ``AnyNewerVersion``, which +denotes that this version or any higher one are compatible with the requested +version. + +.. literalinclude:: Step12/CMakeLists.txt + :caption: CMakeLists.txt + :name: CMakeLists.txt-basic-version-file.cmake + :language: cmake + :start-after: # generate the version file + :end-before: # install the generated configuration files + +Finally, set both generated files to be installed: + +.. literalinclude:: Step12/CMakeLists.txt + :caption: CMakeLists.txt + :name: CMakeLists.txt-install-configured-files.cmake + :language: cmake + :start-after: # install the generated configuration files :end-before: # generate the export At this point, we have generated a relocatable CMake Configuration for our diff --git a/Help/guide/tutorial/Adding System Introspection.rst b/Help/guide/tutorial/Adding System Introspection.rst index 7210a8d..e149110 100644 --- a/Help/guide/tutorial/Adding System Introspection.rst +++ b/Help/guide/tutorial/Adding System Introspection.rst @@ -14,11 +14,14 @@ these functions using the :module:`CheckSymbolExists` module in the ``m`` library. If ``log`` and ``exp`` are not initially found, require the ``m`` library and try again. +Add the checks for ``log`` and ``exp`` to ``MathFunctions/CMakeLists.txt``, +after the call to :command:`target_include_directories`: + .. literalinclude:: Step6/MathFunctions/CMakeLists.txt :caption: MathFunctions/CMakeLists.txt :name: MathFunctions/CMakeLists.txt-check_symbol_exists :language: cmake - :start-after: # does this system provide the log and exp functions? + :start-after: # to find MathFunctions.h, while we don't. :end-before: # add compile definitions If available, use :command:`target_compile_definitions` to specify diff --git a/Help/guide/tutorial/Complete/CMakeLists.txt b/Help/guide/tutorial/Complete/CMakeLists.txt index 4d8a3ad..ec6ff16 100644 --- a/Help/guide/tutorial/Complete/CMakeLists.txt +++ b/Help/guide/tutorial/Complete/CMakeLists.txt @@ -81,7 +81,7 @@ do_test(Tutorial 9 "9 is 3") do_test(Tutorial 5 "5 is 2.236") do_test(Tutorial 7 "7 is 2.645") do_test(Tutorial 25 "25 is 5") -do_test(Tutorial -25 "-25 is [-nan|nan|0]") +do_test(Tutorial -25 "-25 is (-nan|nan|0)") do_test(Tutorial 0.0001 "0.0001 is 0.01") include(InstallRequiredSystemLibraries) diff --git a/Help/guide/tutorial/Step10/CMakeLists.txt b/Help/guide/tutorial/Step10/CMakeLists.txt index 34ae70c..f4f9e05 100644 --- a/Help/guide/tutorial/Step10/CMakeLists.txt +++ b/Help/guide/tutorial/Step10/CMakeLists.txt @@ -63,7 +63,7 @@ do_test(Tutorial 9 "9 is 3") do_test(Tutorial 5 "5 is 2.236") do_test(Tutorial 7 "7 is 2.645") do_test(Tutorial 25 "25 is 5") -do_test(Tutorial -25 "-25 is [-nan|nan|0]") +do_test(Tutorial -25 "-25 is (-nan|nan|0)") do_test(Tutorial 0.0001 "0.0001 is 0.01") include(InstallRequiredSystemLibraries) diff --git a/Help/guide/tutorial/Step11/CMakeLists.txt b/Help/guide/tutorial/Step11/CMakeLists.txt index 4763951..30580e6 100644 --- a/Help/guide/tutorial/Step11/CMakeLists.txt +++ b/Help/guide/tutorial/Step11/CMakeLists.txt @@ -71,7 +71,7 @@ do_test(Tutorial 9 "9 is 3") do_test(Tutorial 5 "5 is 2.236") do_test(Tutorial 7 "7 is 2.645") do_test(Tutorial 25 "25 is 5") -do_test(Tutorial -25 "-25 is [-nan|nan|0]") +do_test(Tutorial -25 "-25 is (-nan|nan|0)") do_test(Tutorial 0.0001 "0.0001 is 0.01") include(InstallRequiredSystemLibraries) diff --git a/Help/guide/tutorial/Step12/CMakeLists.txt b/Help/guide/tutorial/Step12/CMakeLists.txt index 1b0c826..53dccd7 100644 --- a/Help/guide/tutorial/Step12/CMakeLists.txt +++ b/Help/guide/tutorial/Step12/CMakeLists.txt @@ -77,7 +77,7 @@ do_test(Tutorial 9 "9 is 3") do_test(Tutorial 5 "5 is 2.236") do_test(Tutorial 7 "7 is 2.645") do_test(Tutorial 25 "25 is 5") -do_test(Tutorial -25 "-25 is [-nan|nan|0]") +do_test(Tutorial -25 "-25 is (-nan|nan|0)") do_test(Tutorial 0.0001 "0.0001 is 0.01") include(InstallRequiredSystemLibraries) @@ -107,7 +107,7 @@ write_basic_package_version_file( COMPATIBILITY AnyNewerVersion ) -# install the configuration file +# install the generated configuration files install(FILES ${CMAKE_CURRENT_BINARY_DIR}/MathFunctionsConfig.cmake ${CMAKE_CURRENT_BINARY_DIR}/MathFunctionsConfigVersion.cmake diff --git a/Help/guide/tutorial/Step5/CMakeLists.txt b/Help/guide/tutorial/Step5/CMakeLists.txt index c3b375a..fb10f57 100644 --- a/Help/guide/tutorial/Step5/CMakeLists.txt +++ b/Help/guide/tutorial/Step5/CMakeLists.txt @@ -62,5 +62,5 @@ do_test(Tutorial 9 "9 is 3") do_test(Tutorial 5 "5 is 2.236") do_test(Tutorial 7 "7 is 2.645") do_test(Tutorial 25 "25 is 5") -do_test(Tutorial -25 "-25 is [-nan|nan|0]") +do_test(Tutorial -25 "-25 is (-nan|nan|0)") do_test(Tutorial 0.0001 "0.0001 is 0.01") diff --git a/Help/guide/tutorial/Step6/CMakeLists.txt b/Help/guide/tutorial/Step6/CMakeLists.txt index c3b375a..fb10f57 100644 --- a/Help/guide/tutorial/Step6/CMakeLists.txt +++ b/Help/guide/tutorial/Step6/CMakeLists.txt @@ -62,5 +62,5 @@ do_test(Tutorial 9 "9 is 3") do_test(Tutorial 5 "5 is 2.236") do_test(Tutorial 7 "7 is 2.645") do_test(Tutorial 25 "25 is 5") -do_test(Tutorial -25 "-25 is [-nan|nan|0]") +do_test(Tutorial -25 "-25 is (-nan|nan|0)") do_test(Tutorial 0.0001 "0.0001 is 0.01") diff --git a/Help/guide/tutorial/Step7/CMakeLists.txt b/Help/guide/tutorial/Step7/CMakeLists.txt index c3b375a..fb10f57 100644 --- a/Help/guide/tutorial/Step7/CMakeLists.txt +++ b/Help/guide/tutorial/Step7/CMakeLists.txt @@ -62,5 +62,5 @@ do_test(Tutorial 9 "9 is 3") do_test(Tutorial 5 "5 is 2.236") do_test(Tutorial 7 "7 is 2.645") do_test(Tutorial 25 "25 is 5") -do_test(Tutorial -25 "-25 is [-nan|nan|0]") +do_test(Tutorial -25 "-25 is (-nan|nan|0)") do_test(Tutorial 0.0001 "0.0001 is 0.01") diff --git a/Help/guide/tutorial/Step8/CMakeLists.txt b/Help/guide/tutorial/Step8/CMakeLists.txt index 19b9913..89972fb 100644 --- a/Help/guide/tutorial/Step8/CMakeLists.txt +++ b/Help/guide/tutorial/Step8/CMakeLists.txt @@ -62,7 +62,7 @@ do_test(Tutorial 9 "9 is 3") do_test(Tutorial 5 "5 is 2.236") do_test(Tutorial 7 "7 is 2.645") do_test(Tutorial 25 "25 is 5") -do_test(Tutorial -25 "-25 is [-nan|nan|0]") +do_test(Tutorial -25 "-25 is (-nan|nan|0)") do_test(Tutorial 0.0001 "0.0001 is 0.01") # setup installer diff --git a/Help/guide/tutorial/Step9/CMakeLists.txt b/Help/guide/tutorial/Step9/CMakeLists.txt index d5f1cc8..d67209a 100644 --- a/Help/guide/tutorial/Step9/CMakeLists.txt +++ b/Help/guide/tutorial/Step9/CMakeLists.txt @@ -62,7 +62,7 @@ do_test(Tutorial 9 "9 is 3") do_test(Tutorial 5 "5 is 2.236") do_test(Tutorial 7 "7 is 2.645") do_test(Tutorial 25 "25 is 5") -do_test(Tutorial -25 "-25 is [-nan|nan|0]") +do_test(Tutorial -25 "-25 is (-nan|nan|0)") do_test(Tutorial 0.0001 "0.0001 is 0.01") include(InstallRequiredSystemLibraries) diff --git a/Help/manual/cmake-compile-features.7.rst b/Help/manual/cmake-compile-features.7.rst index 2b0de11..a0459fa 100644 --- a/Help/manual/cmake-compile-features.7.rst +++ b/Help/manual/cmake-compile-features.7.rst @@ -118,14 +118,13 @@ as well as any dependents (that may include headers from ``mylib``). Availability of Compiler Extensions ----------------------------------- -Because the :prop_tgt:`CXX_EXTENSIONS` target property is ``ON`` by default, -CMake uses extended variants of language dialects by default, such as -``-std=gnu++11`` instead of ``-std=c++11``. That target property may be -set to ``OFF`` to use the non-extended variant of the dialect flag. Note -that because most compilers enable extensions by default, this could -expose cross-platform bugs in user code or in the headers of third-party +The :prop_tgt:`<LANG>_EXTENSIONS` target property defaults to the compiler's +efault. Note that because most compilers enable extensions by default, this +may expose cross-platform bugs in user code or in the headers of third-party dependencies. +:prop_tgt:`<LANG>_EXTENSIONS` used to default to ``ON``. See :policy:`CMP0128`. + Optional Compile Features ========================= diff --git a/Help/manual/cmake-policies.7.rst b/Help/manual/cmake-policies.7.rst index 0f0c0ab..3df4f9f 100644 --- a/Help/manual/cmake-policies.7.rst +++ b/Help/manual/cmake-policies.7.rst @@ -57,6 +57,7 @@ Policies Introduced by CMake 3.22 .. toctree:: :maxdepth: 1 + CMP0128: Selection of language standard and extension flags improved. </policy/CMP0128> CMP0127: cmake_dependent_option() supports full Condition Syntax. </policy/CMP0127> Policies Introduced by CMake 3.21 diff --git a/Help/manual/cmake-properties.7.rst b/Help/manual/cmake-properties.7.rst index c71e8ff..bb5dba3 100644 --- a/Help/manual/cmake-properties.7.rst +++ b/Help/manual/cmake-properties.7.rst @@ -215,6 +215,9 @@ Properties on Targets /prop_tgt/GNUtoMS /prop_tgt/HAS_CXX /prop_tgt/HIP_ARCHITECTURES + /prop_tgt/HIP_EXTENSIONS + /prop_tgt/HIP_STANDARD + /prop_tgt/HIP_STANDARD_REQUIRED /prop_tgt/IMPLICIT_DEPENDS_INCLUDE_TRANSFORM /prop_tgt/IMPORTED /prop_tgt/IMPORTED_COMMON_LANGUAGE_RUNTIME @@ -274,8 +277,11 @@ Properties on Targets /prop_tgt/LANG_COMPILER_LAUNCHER /prop_tgt/LANG_CPPCHECK /prop_tgt/LANG_CPPLINT + /prop_tgt/LANG_EXTENSIONS /prop_tgt/LANG_INCLUDE_WHAT_YOU_USE /prop_tgt/LANG_LINKER_LAUNCHER + /prop_tgt/LANG_STANDARD + /prop_tgt/LANG_STANDARD_REQUIRED /prop_tgt/LANG_VISIBILITY_PRESET /prop_tgt/LIBRARY_OUTPUT_DIRECTORY /prop_tgt/LIBRARY_OUTPUT_DIRECTORY_CONFIG diff --git a/Help/manual/cmake-variables.7.rst b/Help/manual/cmake-variables.7.rst index 63ea5ac..17f04ab 100644 --- a/Help/manual/cmake-variables.7.rst +++ b/Help/manual/cmake-variables.7.rst @@ -529,6 +529,9 @@ Variables for Languages /variable/CMAKE_Fortran_MODDIR_FLAG /variable/CMAKE_Fortran_MODOUT_FLAG /variable/CMAKE_HIP_ARCHITECTURES + /variable/CMAKE_HIP_EXTENSIONS + /variable/CMAKE_HIP_STANDARD + /variable/CMAKE_HIP_STANDARD_REQUIRED /variable/CMAKE_ISPC_HEADER_DIRECTORY /variable/CMAKE_ISPC_HEADER_SUFFIX /variable/CMAKE_ISPC_INSTRUCTION_SETS @@ -550,6 +553,8 @@ Variables for Languages /variable/CMAKE_LANG_CREATE_SHARED_LIBRARY /variable/CMAKE_LANG_CREATE_SHARED_MODULE /variable/CMAKE_LANG_CREATE_STATIC_LIBRARY + /variable/CMAKE_LANG_EXTENSIONS + /variable/CMAKE_LANG_EXTENSIONS_DEFAULT /variable/CMAKE_LANG_FLAGS /variable/CMAKE_LANG_FLAGS_CONFIG /variable/CMAKE_LANG_FLAGS_CONFIG_INIT @@ -578,8 +583,11 @@ Variables for Languages /variable/CMAKE_LANG_SIMULATE_VERSION /variable/CMAKE_LANG_SIZEOF_DATA_PTR /variable/CMAKE_LANG_SOURCE_FILE_EXTENSIONS + /variable/CMAKE_LANG_STANDARD + /variable/CMAKE_LANG_STANDARD_DEFAULT /variable/CMAKE_LANG_STANDARD_INCLUDE_DIRECTORIES /variable/CMAKE_LANG_STANDARD_LIBRARIES + /variable/CMAKE_LANG_STANDARD_REQUIRED /variable/CMAKE_OBJC_EXTENSIONS /variable/CMAKE_OBJC_STANDARD /variable/CMAKE_OBJC_STANDARD_REQUIRED diff --git a/Help/policy/CMP0128.rst b/Help/policy/CMP0128.rst new file mode 100644 index 0000000..f341f24 --- /dev/null +++ b/Help/policy/CMP0128.rst @@ -0,0 +1,78 @@ +CMP0128 +------- + +.. versionadded:: 3.22 + +When this policy is set to ``NEW``: + +* :prop_tgt:`<LANG>_EXTENSIONS` is initialized to + :variable:`CMAKE_<LANG>_EXTENSIONS_DEFAULT`. + +* Extensions are correctly disabled/enabled if :prop_tgt:`<LANG>_STANDARD` is + unset. + +* Standard mode-affecting flags aren't added unless necessary to achieve the + specified mode. + +The ``OLD`` behavior: + +* Initializes :prop_tgt:`<LANG>_EXTENSIONS` to ``ON``. + +* Always adds a flag if :prop_tgt:`<LANG>_STANDARD` is set and + :prop_tgt:`<LANG>_STANDARD_REQUIRED` is ``OFF``. + +* If :prop_tgt:`<LANG>_STANDARD` is unset: + + * Doesn't disable extensions even if :prop_tgt:`<LANG>_EXTENSIONS` is + ``OFF``. + + * Fails to enable extensions if :prop_tgt:`<LANG>_EXTENSIONS` is ``ON`` + except for the ``IAR`` compiler. + +Code may need to be updated for the ``NEW`` behavior in the following cases: + +* If :prop_tgt:`<LANG>_EXTENSIONS` matches + :variable:`CMAKE_<LANG>_EXTENSIONS_DEFAULT` or is unset and the compiler's + default satisfies :prop_tgt:`<LANG>_STANDARD` but the compiled code requires + the exact standard specified. + Such code should set :prop_tgt:`<LANG>_STANDARD_REQUIRED` to ``ON``. + + For example: + + .. code-block:: cmake + + cmake_minimum_required(VERSION |release|) + project(example C) + + add_executable(exe main.c) + set_property(TARGET exe PROPERTY C_STANDARD 99) + + If the compiler defaults to C11 then the standard specification for C99 is + satisfied and CMake will pass no flags. ``main.c`` will no longer compile if + it is incompatible with C11. + +* If a standard mode flag previously overridden by CMake's and not used during + compiler detection now takes effect due to CMake no longer adding one as the + default detected is appropriate. + + Such code should be converted to either: + + * Use :prop_tgt:`<LANG>_STANDARD` and :prop_tgt:`<LANG>_EXTENSIONS` instead + of manually adding flags. + + * Or ensure the manually-specified flags are used during compiler detection. + +If compiler flags affecting the standard mode are used during compiler +detection (for example in :manual:`a toolchain file <cmake-toolchains(7)>` +using :variable:`CMAKE_<LANG>_FLAGS_INIT`) then they will affect the detected +default :variable:`standard <CMAKE_<LANG>_STANDARD_DEFAULT>` and +:variable:`extensions <CMAKE_<LANG>_EXTENSIONS_DEFAULT>`. + +Unlike many policies, CMake version |release| does *not* warn when the policy +is not set and simply uses the ``OLD`` behavior. Use the +:command:`cmake_policy` command to set it to ``OLD`` or ``NEW`` explicitly. +See documentation of the +:variable:`CMAKE_POLICY_WARNING_CMP0128 <CMAKE_POLICY_WARNING_CMP<NNNN>>` +variable to control the warning. + +.. include:: DEPRECATED.txt diff --git a/Help/prop_gbl/CMAKE_CUDA_KNOWN_FEATURES.rst b/Help/prop_gbl/CMAKE_CUDA_KNOWN_FEATURES.rst index 6bbb870..3a17973 100644 --- a/Help/prop_gbl/CMAKE_CUDA_KNOWN_FEATURES.rst +++ b/Help/prop_gbl/CMAKE_CUDA_KNOWN_FEATURES.rst @@ -32,4 +32,6 @@ The features known to this version of CMake are: Compiler mode is at least CUDA/C++ 20. ``cuda_std_23`` + .. versionadded:: 3.20 + Compiler mode is at least CUDA/C++ 23. diff --git a/Help/prop_gbl/CMAKE_CXX_KNOWN_FEATURES.rst b/Help/prop_gbl/CMAKE_CXX_KNOWN_FEATURES.rst index 73c0b34..1a913fb 100644 --- a/Help/prop_gbl/CMAKE_CXX_KNOWN_FEATURES.rst +++ b/Help/prop_gbl/CMAKE_CXX_KNOWN_FEATURES.rst @@ -18,6 +18,8 @@ The features known to this version of CMake are listed below. High level meta features indicating C++ standard support ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +.. versionadded:: 3.8 + The following meta features indicate general support for the associated language standard. It reflects the language support claimed by the compiler, but it does not necessarily imply complete conformance to that standard. @@ -35,9 +37,13 @@ but it does not necessarily imply complete conformance to that standard. Compiler mode is at least C++ 17. ``cxx_std_20`` + .. versionadded:: 3.12 + Compiler mode is at least C++ 20. ``cxx_std_23`` + .. versionadded:: 3.20 + Compiler mode is at least C++ 23. Low level individual compile features diff --git a/Help/prop_gbl/CMAKE_C_KNOWN_FEATURES.rst b/Help/prop_gbl/CMAKE_C_KNOWN_FEATURES.rst index 2bd0feb..97da697 100644 --- a/Help/prop_gbl/CMAKE_C_KNOWN_FEATURES.rst +++ b/Help/prop_gbl/CMAKE_C_KNOWN_FEATURES.rst @@ -13,7 +13,12 @@ The features listed here may be used with the :command:`target_compile_features` command. See the :manual:`cmake-compile-features(7)` manual for information on compile features and a list of supported compilers. -The features known to this version of CMake are: +The features known to this version of CMake are listed below. + +High level meta features indicating C standard support +^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +.. versionadded:: 3.8 ``c_std_90`` Compiler mode is at least C 90. @@ -25,11 +30,18 @@ The features known to this version of CMake are: Compiler mode is at least C 11. ``c_std_17`` + .. versionadded:: 3.21 + Compiler mode is at least C 17. ``c_std_23`` + .. versionadded:: 3.21 + Compiler mode is at least C 23. +Low level individual compile features +^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + ``c_function_prototypes`` Function prototypes, as defined in ``ISO/IEC 9899:1990``. diff --git a/Help/prop_tgt/HIP_EXTENSIONS.rst b/Help/prop_tgt/HIP_EXTENSIONS.rst new file mode 100644 index 0000000..b731753 --- /dev/null +++ b/Help/prop_tgt/HIP_EXTENSIONS.rst @@ -0,0 +1,19 @@ +HIP_EXTENSIONS +-------------- + +.. versionadded:: 3.21 + +Boolean specifying whether compiler specific extensions are requested. + +This property specifies whether compiler specific extensions should be +used. For some compilers, this results in adding a flag such +as ``-std=gnu++11`` instead of ``-std=c++11`` to the compile line. This +property is ``ON`` by default. The basic HIP/C++ standard level is +controlled by the :prop_tgt:`HIP_STANDARD` target property. + +See the :manual:`cmake-compile-features(7)` manual for information on +compile features and a list of supported compilers. + +This property is initialized by the value of +the :variable:`CMAKE_HIP_EXTENSIONS` variable if it is set when a target +is created. diff --git a/Help/prop_tgt/HIP_STANDARD.rst b/Help/prop_tgt/HIP_STANDARD.rst new file mode 100644 index 0000000..0c767c6 --- /dev/null +++ b/Help/prop_tgt/HIP_STANDARD.rst @@ -0,0 +1,48 @@ +HIP_STANDARD +------------ + +.. versionadded:: 3.21 + +The HIP/C++ standard requested to build this target. + +Supported values are: + +``98`` + HIP C++98 + +``11`` + HIP C++11 + +``14`` + HIP C++14 + +``17`` + HIP C++17 + +``20`` + HIP C++20 + +``23`` + HIP C++23 + +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: + +.. code-block:: cmake + + set_property(TARGET tgt PROPERTY HIP_STANDARD 11) + +with a compiler which does not support ``-std=gnu++11`` or an equivalent +flag will not result in an error or warning, but will instead add the +``-std=gnu++98`` flag if supported. This "decay" behavior may be controlled +with the :prop_tgt:`HIP_STANDARD_REQUIRED` target property. +Additionally, the :prop_tgt:`HIP_EXTENSIONS` target property may be used to +control whether compiler-specific extensions are enabled on a per-target basis. + +See the :manual:`cmake-compile-features(7)` manual for information on +compile features and a list of supported compilers. + +This property is initialized by the value of +the :variable:`CMAKE_HIP_STANDARD` variable if it is set when a target +is created. diff --git a/Help/prop_tgt/HIP_STANDARD_REQUIRED.rst b/Help/prop_tgt/HIP_STANDARD_REQUIRED.rst new file mode 100644 index 0000000..e56209a --- /dev/null +++ b/Help/prop_tgt/HIP_STANDARD_REQUIRED.rst @@ -0,0 +1,19 @@ +HIP_STANDARD_REQUIRED +--------------------- + +.. versionadded:: 3.21 + +Boolean describing whether the value of :prop_tgt:`HIP_STANDARD` is a requirement. + +If this property is set to ``ON``, then the value of the +:prop_tgt:`HIP_STANDARD` target property is treated as a requirement. If this +property is ``OFF`` or unset, the :prop_tgt:`HIP_STANDARD` target property is +treated as optional and may "decay" to a previous standard if the requested is +not available. + +See the :manual:`cmake-compile-features(7)` manual for information on +compile features and a list of supported compilers. + +This property is initialized by the value of +the :variable:`CMAKE_HIP_STANDARD_REQUIRED` variable if it is set when a +target is created. diff --git a/Help/prop_tgt/LANG_EXTENSIONS.rst b/Help/prop_tgt/LANG_EXTENSIONS.rst new file mode 100644 index 0000000..2add21d --- /dev/null +++ b/Help/prop_tgt/LANG_EXTENSIONS.rst @@ -0,0 +1,23 @@ +<LANG>_EXTENSIONS +----------------- + +The variations are: + +* :prop_tgt:`C_EXTENSIONS` +* :prop_tgt:`CXX_EXTENSIONS` +* :prop_tgt:`CUDA_EXTENSIONS` +* :prop_tgt:`HIP_EXTENSIONS` +* :prop_tgt:`OBJC_EXTENSIONS` +* :prop_tgt:`OBJCXX_EXTENSIONS` + +These properties specify whether compiler-specific extensions are requested. + +These properties are initialized by the value of the +:variable:`CMAKE_<LANG>_EXTENSIONS` variable if it is set when a target is +created. + +For supported CMake versions see the respective pages. +To control language standard versions see :prop_tgt:`<LANG>_STANDARD`. + +See the :manual:`cmake-compile-features(7)` manual for information on +compile features and a list of supported compilers. diff --git a/Help/prop_tgt/LANG_STANDARD.rst b/Help/prop_tgt/LANG_STANDARD.rst new file mode 100644 index 0000000..bd377ec --- /dev/null +++ b/Help/prop_tgt/LANG_STANDARD.rst @@ -0,0 +1,26 @@ +<LANG>_STANDARD +--------------- + +The variations are: + +* :prop_tgt:`C_STANDARD` +* :prop_tgt:`CXX_STANDARD` +* :prop_tgt:`CUDA_STANDARD` +* :prop_tgt:`HIP_STANDARD` +* :prop_tgt:`OBJC_STANDARD` +* :prop_tgt:`OBJCXX_STANDARD` + +These properties specify language standard versions which are requested. When a +newer standard is specified than is supported by the compiler, then it will +fallback to the latest supported standard. This "decay" behavior may be +controlled with the :prop_tgt:`<LANG>_STANDARD_REQUIRED` target property. + +These properties are initialized by the value of the +:variable:`CMAKE_<LANG>_STANDARD` variable if it is set when a target is +created. + +For supported values and CMake versions see the respective pages. +To control compiler-specific extensions see :prop_tgt:`<LANG>_EXTENSIONS`. + +See the :manual:`cmake-compile-features(7)` manual for information on +compile features and a list of supported compilers. diff --git a/Help/prop_tgt/LANG_STANDARD_REQUIRED.rst b/Help/prop_tgt/LANG_STANDARD_REQUIRED.rst new file mode 100644 index 0000000..56ecef8 --- /dev/null +++ b/Help/prop_tgt/LANG_STANDARD_REQUIRED.rst @@ -0,0 +1,26 @@ +<LANG>_STANDARD_REQUIRED +------------------------ + +The variations are: + +* :prop_tgt:`C_STANDARD_REQUIRED` +* :prop_tgt:`CXX_STANDARD_REQUIRED` +* :prop_tgt:`CUDA_STANDARD_REQUIRED` +* :prop_tgt:`HIP_STANDARD_REQUIRED` +* :prop_tgt:`OBJC_STANDARD_REQUIRED` +* :prop_tgt:`OBJCXX_STANDARD_REQUIRED` + +These properties specify whether the value of :prop_tgt:`<LANG>_STANDARD` is a +requirement. When ``OFF`` or unset, the :prop_tgt:`<LANG>_STANDARD` target +property is treated as optional and may "decay" to a previous standard if the +requested is not available. + +These properties are initialized by the value of the +:variable:`CMAKE_<LANG>_STANDARD_REQUIRED` variable if it is set when a target +is created. + +For supported CMake versions see the respective pages. +To control language standard versions see :prop_tgt:`<LANG>_STANDARD`. + +See the :manual:`cmake-compile-features(7)` manual for information on +compile features and a list of supported compilers. diff --git a/Help/release/dev/compile-features-standard-logic-rework.rst b/Help/release/dev/compile-features-standard-logic-rework.rst new file mode 100644 index 0000000..432a756 --- /dev/null +++ b/Help/release/dev/compile-features-standard-logic-rework.rst @@ -0,0 +1,10 @@ +compile-features-standard-logic-rework +-------------------------------------- + +* The :manual:`Compile Features <cmake-compile-features(7)>` functionality now + correctly disables or enables compiler extensions when no standard level is + specified and avoids unnecessarily adding language standard flags if the + requested settings match the compiler's defaults. See :policy:`CMP0128`. + +* :prop_tgt:`<LANG>_EXTENSIONS` is initialized to + :variable:`CMAKE_<LANG>_EXTENSIONS_DEFAULT`. See :policy:`CMP0128`. diff --git a/Help/variable/CMAKE_CUDA_EXTENSIONS.rst b/Help/variable/CMAKE_CUDA_EXTENSIONS.rst index b86c0ea..12749ce 100644 --- a/Help/variable/CMAKE_CUDA_EXTENSIONS.rst +++ b/Help/variable/CMAKE_CUDA_EXTENSIONS.rst @@ -3,11 +3,8 @@ CMAKE_CUDA_EXTENSIONS .. versionadded:: 3.8 -Default value for :prop_tgt:`CUDA_EXTENSIONS` property of targets. - -This variable is used to initialize the :prop_tgt:`CUDA_EXTENSIONS` -property on all targets. See that target property for additional -information. +Default value for :prop_tgt:`CUDA_EXTENSIONS` target property if set when a +target is created. See the :manual:`cmake-compile-features(7)` manual for information on compile features and a list of supported compilers. diff --git a/Help/variable/CMAKE_CUDA_STANDARD.rst b/Help/variable/CMAKE_CUDA_STANDARD.rst index 798ab1e..ee9395a 100644 --- a/Help/variable/CMAKE_CUDA_STANDARD.rst +++ b/Help/variable/CMAKE_CUDA_STANDARD.rst @@ -3,11 +3,8 @@ CMAKE_CUDA_STANDARD .. versionadded:: 3.8 -Default value for :prop_tgt:`CUDA_STANDARD` property of targets. - -This variable is used to initialize the :prop_tgt:`CUDA_STANDARD` -property on all targets. See that target property for additional -information. +Default value for :prop_tgt:`CUDA_STANDARD` target property if set when a +target is created. See the :manual:`cmake-compile-features(7)` manual for information on compile features and a list of supported compilers. diff --git a/Help/variable/CMAKE_CUDA_STANDARD_REQUIRED.rst b/Help/variable/CMAKE_CUDA_STANDARD_REQUIRED.rst index ae2f52f..0c85a04d 100644 --- a/Help/variable/CMAKE_CUDA_STANDARD_REQUIRED.rst +++ b/Help/variable/CMAKE_CUDA_STANDARD_REQUIRED.rst @@ -3,11 +3,8 @@ CMAKE_CUDA_STANDARD_REQUIRED .. versionadded:: 3.8 -Default value for :prop_tgt:`CUDA_STANDARD_REQUIRED` property of targets. - -This variable is used to initialize the :prop_tgt:`CUDA_STANDARD_REQUIRED` -property on all targets. See that target property for additional -information. +Default value for :prop_tgt:`CUDA_STANDARD_REQUIRED` target property if set +when a target is created. See the :manual:`cmake-compile-features(7)` manual for information on compile features and a list of supported compilers. diff --git a/Help/variable/CMAKE_CXX_EXTENSIONS.rst b/Help/variable/CMAKE_CXX_EXTENSIONS.rst index ea8c4be..017f503 100644 --- a/Help/variable/CMAKE_CXX_EXTENSIONS.rst +++ b/Help/variable/CMAKE_CXX_EXTENSIONS.rst @@ -3,11 +3,8 @@ CMAKE_CXX_EXTENSIONS .. versionadded:: 3.1 -Default value for :prop_tgt:`CXX_EXTENSIONS` property of targets. - -This variable is used to initialize the :prop_tgt:`CXX_EXTENSIONS` -property on all targets. See that target property for additional -information. +Default value for :prop_tgt:`CXX_EXTENSIONS` target property if set when a +target is created. See the :manual:`cmake-compile-features(7)` manual for information on compile features and a list of supported compilers. diff --git a/Help/variable/CMAKE_CXX_STANDARD.rst b/Help/variable/CMAKE_CXX_STANDARD.rst index 8ef8c80..33eb89e 100644 --- a/Help/variable/CMAKE_CXX_STANDARD.rst +++ b/Help/variable/CMAKE_CXX_STANDARD.rst @@ -3,11 +3,8 @@ CMAKE_CXX_STANDARD .. versionadded:: 3.1 -Default value for :prop_tgt:`CXX_STANDARD` property of targets. - -This variable is used to initialize the :prop_tgt:`CXX_STANDARD` -property on all targets. See that target property for additional -information. +Default value for :prop_tgt:`CXX_STANDARD` target property if set when a target +is created. See the :manual:`cmake-compile-features(7)` manual for information on compile features and a list of supported compilers. diff --git a/Help/variable/CMAKE_CXX_STANDARD_REQUIRED.rst b/Help/variable/CMAKE_CXX_STANDARD_REQUIRED.rst index f7b2ae9..1c6c0cc 100644 --- a/Help/variable/CMAKE_CXX_STANDARD_REQUIRED.rst +++ b/Help/variable/CMAKE_CXX_STANDARD_REQUIRED.rst @@ -3,11 +3,8 @@ CMAKE_CXX_STANDARD_REQUIRED .. versionadded:: 3.1 -Default value for :prop_tgt:`CXX_STANDARD_REQUIRED` property of targets. - -This variable is used to initialize the :prop_tgt:`CXX_STANDARD_REQUIRED` -property on all targets. See that target property for additional -information. +Default value for :prop_tgt:`CXX_STANDARD_REQUIRED` target property if set when +a target is created. See the :manual:`cmake-compile-features(7)` manual for information on compile features and a list of supported compilers. diff --git a/Help/variable/CMAKE_C_EXTENSIONS.rst b/Help/variable/CMAKE_C_EXTENSIONS.rst index fce8fc7..6680521 100644 --- a/Help/variable/CMAKE_C_EXTENSIONS.rst +++ b/Help/variable/CMAKE_C_EXTENSIONS.rst @@ -3,11 +3,8 @@ CMAKE_C_EXTENSIONS .. versionadded:: 3.1 -Default value for :prop_tgt:`C_EXTENSIONS` property of targets. - -This variable is used to initialize the :prop_tgt:`C_EXTENSIONS` -property on all targets. See that target property for additional -information. +Default value for :prop_tgt:`C_EXTENSIONS` target property if set when a target +is created. See the :manual:`cmake-compile-features(7)` manual for information on compile features and a list of supported compilers. diff --git a/Help/variable/CMAKE_C_STANDARD.rst b/Help/variable/CMAKE_C_STANDARD.rst index 64ef8ce..ec1e513 100644 --- a/Help/variable/CMAKE_C_STANDARD.rst +++ b/Help/variable/CMAKE_C_STANDARD.rst @@ -3,11 +3,8 @@ CMAKE_C_STANDARD .. versionadded:: 3.1 -Default value for :prop_tgt:`C_STANDARD` property of targets. - -This variable is used to initialize the :prop_tgt:`C_STANDARD` -property on all targets. See that target property for additional -information. +Default value for :prop_tgt:`C_STANDARD` target property if set when a target +is created. See the :manual:`cmake-compile-features(7)` manual for information on compile features and a list of supported compilers. diff --git a/Help/variable/CMAKE_C_STANDARD_REQUIRED.rst b/Help/variable/CMAKE_C_STANDARD_REQUIRED.rst index e70b6bd..2bd9d51 100644 --- a/Help/variable/CMAKE_C_STANDARD_REQUIRED.rst +++ b/Help/variable/CMAKE_C_STANDARD_REQUIRED.rst @@ -3,11 +3,8 @@ CMAKE_C_STANDARD_REQUIRED .. versionadded:: 3.1 -Default value for :prop_tgt:`C_STANDARD_REQUIRED` property of targets. - -This variable is used to initialize the :prop_tgt:`C_STANDARD_REQUIRED` -property on all targets. See that target property for additional -information. +Default value for :prop_tgt:`C_STANDARD_REQUIRED` target property if set when +a target is created. See the :manual:`cmake-compile-features(7)` manual for information on compile features and a list of supported compilers. diff --git a/Help/variable/CMAKE_HIP_EXTENSIONS.rst b/Help/variable/CMAKE_HIP_EXTENSIONS.rst new file mode 100644 index 0000000..13987dc --- /dev/null +++ b/Help/variable/CMAKE_HIP_EXTENSIONS.rst @@ -0,0 +1,10 @@ +CMAKE_HIP_EXTENSIONS +-------------------- + +.. versionadded:: 3.21 + +Default value for :prop_tgt:`HIP_EXTENSIONS` target property if set when a +target is created. + +See the :manual:`cmake-compile-features(7)` manual for information on +compile features and a list of supported compilers. diff --git a/Help/variable/CMAKE_HIP_STANDARD.rst b/Help/variable/CMAKE_HIP_STANDARD.rst new file mode 100644 index 0000000..5f15145 --- /dev/null +++ b/Help/variable/CMAKE_HIP_STANDARD.rst @@ -0,0 +1,10 @@ +CMAKE_HIP_STANDARD +------------------ + +.. versionadded:: 3.21 + +Default value for :prop_tgt:`HIP_STANDARD` target property if set when a target +is created. + +See the :manual:`cmake-compile-features(7)` manual for information on +compile features and a list of supported compilers. diff --git a/Help/variable/CMAKE_HIP_STANDARD_REQUIRED.rst b/Help/variable/CMAKE_HIP_STANDARD_REQUIRED.rst new file mode 100644 index 0000000..5d35e4e --- /dev/null +++ b/Help/variable/CMAKE_HIP_STANDARD_REQUIRED.rst @@ -0,0 +1,10 @@ +CMAKE_HIP_STANDARD_REQUIRED +--------------------------- + +.. versionadded:: 3.21 + +Default value for :prop_tgt:`HIP_STANDARD_REQUIRED` target property if set when +a target is created. + +See the :manual:`cmake-compile-features(7)` manual for information on +compile features and a list of supported compilers. diff --git a/Help/variable/CMAKE_LANG_EXTENSIONS.rst b/Help/variable/CMAKE_LANG_EXTENSIONS.rst new file mode 100644 index 0000000..84e5e3a --- /dev/null +++ b/Help/variable/CMAKE_LANG_EXTENSIONS.rst @@ -0,0 +1,19 @@ +CMAKE_<LANG>_EXTENSIONS +----------------------- + +The variations are: + +* :variable:`CMAKE_C_EXTENSIONS` +* :variable:`CMAKE_CXX_EXTENSIONS` +* :variable:`CMAKE_CUDA_EXTENSIONS` +* :variable:`CMAKE_HIP_EXTENSIONS` +* :variable:`CMAKE_OBJC_EXTENSIONS` +* :variable:`CMAKE_OBJCXX_EXTENSIONS` + +Default values for :prop_tgt:`<LANG>_EXTENSIONS` target properties if set when +a target is created. + +For supported CMake versions see the respective pages. + +See the :manual:`cmake-compile-features(7)` manual for information on +compile features and a list of supported compilers. diff --git a/Help/variable/CMAKE_LANG_EXTENSIONS_DEFAULT.rst b/Help/variable/CMAKE_LANG_EXTENSIONS_DEFAULT.rst new file mode 100644 index 0000000..6783eb5 --- /dev/null +++ b/Help/variable/CMAKE_LANG_EXTENSIONS_DEFAULT.rst @@ -0,0 +1,7 @@ +CMAKE_<LANG>_EXTENSIONS_DEFAULT +------------------------------- + +.. versionadded:: 3.22 + +Default value used when the :prop_tgt:`<LANG>_EXTENSIONS` target property is +not set. Initialized during compiler detection to the compiler's default. diff --git a/Help/variable/CMAKE_LANG_STANDARD.rst b/Help/variable/CMAKE_LANG_STANDARD.rst new file mode 100644 index 0000000..0c41e19 --- /dev/null +++ b/Help/variable/CMAKE_LANG_STANDARD.rst @@ -0,0 +1,19 @@ +CMAKE_<LANG>_STANDARD +--------------------- + +The variations are: + +* :variable:`CMAKE_C_STANDARD` +* :variable:`CMAKE_CXX_STANDARD` +* :variable:`CMAKE_CUDA_STANDARD` +* :variable:`CMAKE_HIP_STANDARD` +* :variable:`CMAKE_OBJC_STANDARD` +* :variable:`CMAKE_OBJCXX_STANDARD` + +Default values for :prop_tgt:`<LANG>_STANDARD` target properties if set when a +target is created. + +For supported CMake versions see the respective pages. + +See the :manual:`cmake-compile-features(7)` manual for information on +compile features and a list of supported compilers. diff --git a/Help/variable/CMAKE_LANG_STANDARD_DEFAULT.rst b/Help/variable/CMAKE_LANG_STANDARD_DEFAULT.rst new file mode 100644 index 0000000..eb63d20 --- /dev/null +++ b/Help/variable/CMAKE_LANG_STANDARD_DEFAULT.rst @@ -0,0 +1,7 @@ +CMAKE_<LANG>_STANDARD_DEFAULT +----------------------------- + +.. versionadded:: 3.9 + +The compiler's default standard for the language ``<LANG>``. Empty if the +compiler has no conception of standard levels. diff --git a/Help/variable/CMAKE_LANG_STANDARD_REQUIRED.rst b/Help/variable/CMAKE_LANG_STANDARD_REQUIRED.rst new file mode 100644 index 0000000..d7fa9b6 --- /dev/null +++ b/Help/variable/CMAKE_LANG_STANDARD_REQUIRED.rst @@ -0,0 +1,19 @@ +CMAKE_<LANG>_STANDARD_REQUIRED +------------------------------ + +The variations are: + +* :variable:`CMAKE_C_STANDARD_REQUIRED` +* :variable:`CMAKE_CXX_STANDARD_REQUIRED` +* :variable:`CMAKE_CUDA_STANDARD_REQUIRED` +* :variable:`CMAKE_HIP_STANDARD_REQUIRED` +* :variable:`CMAKE_OBJC_STANDARD_REQUIRED` +* :variable:`CMAKE_OBJCXX_STANDARD_REQUIRED` + +Default values for :prop_tgt:`<LANG>_STANDARD_REQUIRED` target properties if +set when a target is created. + +For supported CMake versions see the respective pages. + +See the :manual:`cmake-compile-features(7)` manual for information on +compile features and a list of supported compilers. diff --git a/Help/variable/CMAKE_OBJCXX_EXTENSIONS.rst b/Help/variable/CMAKE_OBJCXX_EXTENSIONS.rst index b5225ea..46736aa 100644 --- a/Help/variable/CMAKE_OBJCXX_EXTENSIONS.rst +++ b/Help/variable/CMAKE_OBJCXX_EXTENSIONS.rst @@ -3,11 +3,8 @@ CMAKE_OBJCXX_EXTENSIONS .. versionadded:: 3.16 -Default value for :prop_tgt:`OBJCXX_EXTENSIONS` property of targets. - -This variable is used to initialize the :prop_tgt:`OBJCXX_EXTENSIONS` -property on all targets. See that target property for additional -information. +Default value for :prop_tgt:`OBJCXX_EXTENSIONS` target property if set when a +target is created. See the :manual:`cmake-compile-features(7)` manual for information on compile features and a list of supported compilers. diff --git a/Help/variable/CMAKE_OBJCXX_STANDARD.rst b/Help/variable/CMAKE_OBJCXX_STANDARD.rst index 98e4624..0913382 100644 --- a/Help/variable/CMAKE_OBJCXX_STANDARD.rst +++ b/Help/variable/CMAKE_OBJCXX_STANDARD.rst @@ -3,11 +3,8 @@ CMAKE_OBJCXX_STANDARD .. versionadded:: 3.16 -Default value for :prop_tgt:`OBJCXX_STANDARD` property of targets. - -This variable is used to initialize the :prop_tgt:`OBJCXX_STANDARD` -property on all targets. See that target property for additional -information. +Default value for :prop_tgt:`OBJCXX_STANDARD` target property if set when a +target is created. See the :manual:`cmake-compile-features(7)` manual for information on compile features and a list of supported compilers. diff --git a/Help/variable/CMAKE_OBJCXX_STANDARD_REQUIRED.rst b/Help/variable/CMAKE_OBJCXX_STANDARD_REQUIRED.rst index 4b5e77c..9afc4ea 100644 --- a/Help/variable/CMAKE_OBJCXX_STANDARD_REQUIRED.rst +++ b/Help/variable/CMAKE_OBJCXX_STANDARD_REQUIRED.rst @@ -3,11 +3,8 @@ CMAKE_OBJCXX_STANDARD_REQUIRED .. versionadded:: 3.16 -Default value for :prop_tgt:`OBJCXX_STANDARD_REQUIRED` property of targets. - -This variable is used to initialize the :prop_tgt:`OBJCXX_STANDARD_REQUIRED` -property on all targets. See that target property for additional -information. +Default value for :prop_tgt:`OBJCXX_STANDARD_REQUIRED` target property if set +when a target is created. See the :manual:`cmake-compile-features(7)` manual for information on compile features and a list of supported compilers. diff --git a/Help/variable/CMAKE_OBJC_EXTENSIONS.rst b/Help/variable/CMAKE_OBJC_EXTENSIONS.rst index d6e3c7d..9df11f1 100644 --- a/Help/variable/CMAKE_OBJC_EXTENSIONS.rst +++ b/Help/variable/CMAKE_OBJC_EXTENSIONS.rst @@ -3,11 +3,8 @@ CMAKE_OBJC_EXTENSIONS .. versionadded:: 3.16 -Default value for :prop_tgt:`OBJC_EXTENSIONS` property of targets. - -This variable is used to initialize the :prop_tgt:`OBJC_EXTENSIONS` -property on all targets. See that target property for additional -information. +Default value for :prop_tgt:`OBJC_EXTENSIONS` target property if set when a +target is created. See the :manual:`cmake-compile-features(7)` manual for information on compile features and a list of supported compilers. diff --git a/Help/variable/CMAKE_OBJC_STANDARD.rst b/Help/variable/CMAKE_OBJC_STANDARD.rst index fde367d..0b9b63f 100644 --- a/Help/variable/CMAKE_OBJC_STANDARD.rst +++ b/Help/variable/CMAKE_OBJC_STANDARD.rst @@ -3,11 +3,8 @@ CMAKE_OBJC_STANDARD .. versionadded:: 3.16 -Default value for :prop_tgt:`OBJC_STANDARD` property of targets. - -This variable is used to initialize the :prop_tgt:`OBJC_STANDARD` -property on all targets. See that target property for additional -information. +Default value for :prop_tgt:`OBJC_STANDARD` target property if set when a +target is created. See the :manual:`cmake-compile-features(7)` manual for information on compile features and a list of supported compilers. diff --git a/Help/variable/CMAKE_OBJC_STANDARD_REQUIRED.rst b/Help/variable/CMAKE_OBJC_STANDARD_REQUIRED.rst index 8d26d95..c74db55 100644 --- a/Help/variable/CMAKE_OBJC_STANDARD_REQUIRED.rst +++ b/Help/variable/CMAKE_OBJC_STANDARD_REQUIRED.rst @@ -3,11 +3,8 @@ CMAKE_OBJC_STANDARD_REQUIRED .. versionadded:: 3.16 -Default value for :prop_tgt:`OBJC_STANDARD_REQUIRED` property of targets. - -This variable is used to initialize the :prop_tgt:`OBJC_STANDARD_REQUIRED` -property on all targets. See that target property for additional -information. +Default value for :prop_tgt:`OBJC_STANDARD_REQUIRED` target property if set +when a target is created. See the :manual:`cmake-compile-features(7)` manual for information on compile features and a list of supported compilers. diff --git a/Help/variable/CMAKE_POLICY_WARNING_CMPNNNN.rst b/Help/variable/CMAKE_POLICY_WARNING_CMPNNNN.rst index 11dd194..0231668 100644 --- a/Help/variable/CMAKE_POLICY_WARNING_CMPNNNN.rst +++ b/Help/variable/CMAKE_POLICY_WARNING_CMPNNNN.rst @@ -32,6 +32,8 @@ only for the policies that do not warn by default: policy :policy:`CMP0116`. * ``CMAKE_POLICY_WARNING_CMP0126`` controls the warning for policy :policy:`CMP0126`. +* ``CMAKE_POLICY_WARNING_CMP0128`` controls the warning for + policy :policy:`CMP0128`. This variable should not be set by a project in CMake code. Project developers running CMake may set this variable in their cache to diff --git a/Modules/CMakeCCompiler.cmake.in b/Modules/CMakeCCompiler.cmake.in index 6818381..2b24ff2 100644 --- a/Modules/CMakeCCompiler.cmake.in +++ b/Modules/CMakeCCompiler.cmake.in @@ -5,6 +5,7 @@ set(CMAKE_C_COMPILER_VERSION "@CMAKE_C_COMPILER_VERSION@") set(CMAKE_C_COMPILER_VERSION_INTERNAL "@CMAKE_C_COMPILER_VERSION_INTERNAL@") set(CMAKE_C_COMPILER_WRAPPER "@CMAKE_C_COMPILER_WRAPPER@") set(CMAKE_C_STANDARD_COMPUTED_DEFAULT "@CMAKE_C_STANDARD_COMPUTED_DEFAULT@") +set(CMAKE_C_EXTENSIONS_COMPUTED_DEFAULT "@CMAKE_C_EXTENSIONS_COMPUTED_DEFAULT@") set(CMAKE_C_COMPILE_FEATURES "@CMAKE_C_COMPILE_FEATURES@") set(CMAKE_C90_COMPILE_FEATURES "@CMAKE_C90_COMPILE_FEATURES@") set(CMAKE_C99_COMPILE_FEATURES "@CMAKE_C99_COMPILE_FEATURES@") diff --git a/Modules/CMakeCCompilerId.c.in b/Modules/CMakeCCompilerId.c.in index 1f19c00..43ede3e 100644 --- a/Modules/CMakeCCompilerId.c.in +++ b/Modules/CMakeCCompilerId.c.in @@ -41,23 +41,34 @@ char const *info_cray = "INFO" ":" "compiler_wrapper[CrayPrgEnv]"; #if !defined(__STDC__) && !defined(__clang__) # if defined(_MSC_VER) || defined(__ibmxl__) || defined(__IBMC__) -# define C_DIALECT "90" +# define C_VERSION "90" # else -# define C_DIALECT +# define C_VERSION # endif #elif __STDC_VERSION__ > 201710L -# define C_DIALECT "23" +# define C_VERSION "23" #elif __STDC_VERSION__ >= 201710L -# define C_DIALECT "17" +# define C_VERSION "17" #elif __STDC_VERSION__ >= 201000L -# define C_DIALECT "11" +# define C_VERSION "11" #elif __STDC_VERSION__ >= 199901L -# define C_DIALECT "99" +# define C_VERSION "99" #else -# define C_DIALECT "90" +# define C_VERSION "90" #endif -const char* info_language_dialect_default = - "INFO" ":" "dialect_default[" C_DIALECT "]"; +const char* info_language_standard_default = + "INFO" ":" "standard_default[" C_VERSION "]"; + +const char* info_language_extensions_default = "INFO" ":" "extensions_default[" +// !defined(_MSC_VER) to exclude Clang's MSVC compatibility mode. +#if (defined(__clang__) || defined(__GNUC__) || \ + defined(__TI_COMPILER_VERSION__)) && \ + !defined(__STRICT_ANSI__) && !defined(_MSC_VER) + "ON" +#else + "OFF" +#endif +"]"; /*--------------------------------------------------------------------------*/ @@ -89,7 +100,8 @@ int main(int argc, char* argv[]) #if defined(__CRAYXT_COMPUTE_LINUX_TARGET) require += info_cray[argc]; #endif - require += info_language_dialect_default[argc]; + require += info_language_standard_default[argc]; + require += info_language_extensions_default[argc]; (void)argv; return require; } diff --git a/Modules/CMakeCUDACompiler.cmake.in b/Modules/CMakeCUDACompiler.cmake.in index 56ae732..2f3e9a8 100644 --- a/Modules/CMakeCUDACompiler.cmake.in +++ b/Modules/CMakeCUDACompiler.cmake.in @@ -6,6 +6,7 @@ set(CMAKE_CUDA_COMPILER_VERSION "@CMAKE_CUDA_COMPILER_VERSION@") set(CMAKE_CUDA_DEVICE_LINKER "@CMAKE_CUDA_DEVICE_LINKER@") set(CMAKE_CUDA_FATBINARY "@CMAKE_CUDA_FATBINARY@") set(CMAKE_CUDA_STANDARD_COMPUTED_DEFAULT "@CMAKE_CUDA_STANDARD_COMPUTED_DEFAULT@") +set(CMAKE_CUDA_EXTENSIONS_COMPUTED_DEFAULT "@CMAKE_CUDA_EXTENSIONS_COMPUTED_DEFAULT@") set(CMAKE_CUDA_COMPILE_FEATURES "@CMAKE_CUDA_COMPILE_FEATURES@") set(CMAKE_CUDA03_COMPILE_FEATURES "@CMAKE_CUDA03_COMPILE_FEATURES@") set(CMAKE_CUDA11_COMPILE_FEATURES "@CMAKE_CUDA11_COMPILE_FEATURES@") diff --git a/Modules/CMakeCUDACompilerId.cu.in b/Modules/CMakeCUDACompilerId.cu.in index 91039e5..bc685a7 100644 --- a/Modules/CMakeCUDACompilerId.cu.in +++ b/Modules/CMakeCUDACompilerId.cu.in @@ -16,7 +16,7 @@ char const* info_simulate = "INFO" ":" "simulate[" SIMULATE_ID "]"; @CMAKE_CUDA_COMPILER_ID_PLATFORM_CONTENT@ @CMAKE_CUDA_COMPILER_ID_ERROR_FOR_TEST@ -const char* info_language_dialect_default = "INFO" ":" "dialect_default[" +const char* info_language_standard_default = "INFO" ":" "standard_default[" #if __cplusplus > 202002L "23" #elif __cplusplus > 201703L @@ -32,6 +32,16 @@ const char* info_language_dialect_default = "INFO" ":" "dialect_default[" #endif "]"; +const char* info_language_extensions_default = "INFO" ":" "extensions_default[" +// !defined(_MSC_VER) to exclude Clang's MSVC compatibility mode. +#if (defined(__clang__) || defined(__GNUC__)) && !defined(__STRICT_ANSI__) && \ + !defined(_MSC_VER) + "ON" +#else + "OFF" +#endif +"]"; + /*--------------------------------------------------------------------------*/ int main(int argc, char* argv[]) @@ -48,7 +58,8 @@ int main(int argc, char* argv[]) #ifdef SIMULATE_VERSION_MAJOR require += info_simulate_version[argc]; #endif - require += info_language_dialect_default[argc]; + require += info_language_standard_default[argc]; + require += info_language_extensions_default[argc]; (void)argv; return require; } diff --git a/Modules/CMakeCXXCompiler.cmake.in b/Modules/CMakeCXXCompiler.cmake.in index 7aad9e2..534e960 100644 --- a/Modules/CMakeCXXCompiler.cmake.in +++ b/Modules/CMakeCXXCompiler.cmake.in @@ -5,6 +5,7 @@ set(CMAKE_CXX_COMPILER_VERSION "@CMAKE_CXX_COMPILER_VERSION@") set(CMAKE_CXX_COMPILER_VERSION_INTERNAL "@CMAKE_CXX_COMPILER_VERSION_INTERNAL@") set(CMAKE_CXX_COMPILER_WRAPPER "@CMAKE_CXX_COMPILER_WRAPPER@") set(CMAKE_CXX_STANDARD_COMPUTED_DEFAULT "@CMAKE_CXX_STANDARD_COMPUTED_DEFAULT@") +set(CMAKE_CXX_EXTENSIONS_COMPUTED_DEFAULT "@CMAKE_CXX_EXTENSIONS_COMPUTED_DEFAULT@") set(CMAKE_CXX_COMPILE_FEATURES "@CMAKE_CXX_COMPILE_FEATURES@") set(CMAKE_CXX98_COMPILE_FEATURES "@CMAKE_CXX98_COMPILE_FEATURES@") set(CMAKE_CXX11_COMPILE_FEATURES "@CMAKE_CXX11_COMPILE_FEATURES@") diff --git a/Modules/CMakeCXXCompilerId.cpp.in b/Modules/CMakeCXXCompilerId.cpp.in index 7362a08..cdf9c18 100644 --- a/Modules/CMakeCXXCompilerId.cpp.in +++ b/Modules/CMakeCXXCompilerId.cpp.in @@ -49,7 +49,7 @@ char const *info_cray = "INFO" ":" "compiler_wrapper[CrayPrgEnv]"; # define CXX_STD __cplusplus #endif -const char* info_language_dialect_default = "INFO" ":" "dialect_default[" +const char* info_language_standard_default = "INFO" ":" "standard_default[" #if CXX_STD > 202002L "23" #elif CXX_STD > 201703L @@ -65,6 +65,17 @@ const char* info_language_dialect_default = "INFO" ":" "dialect_default[" #endif "]"; +const char* info_language_extensions_default = "INFO" ":" "extensions_default[" +// !defined(_MSC_VER) to exclude Clang's MSVC compatibility mode. +#if (defined(__clang__) || defined(__GNUC__) || \ + defined(__TI_COMPILER_VERSION__)) && \ + !defined(__STRICT_ANSI__) && !defined(_MSC_VER) + "ON" +#else + "OFF" +#endif +"]"; + /*--------------------------------------------------------------------------*/ int main(int argc, char* argv[]) @@ -87,7 +98,8 @@ int main(int argc, char* argv[]) #if defined(__CRAYXT_COMPUTE_LINUX_TARGET) require += info_cray[argc]; #endif - require += info_language_dialect_default[argc]; + require += info_language_standard_default[argc]; + require += info_language_extensions_default[argc]; (void)argv; return require; } diff --git a/Modules/CMakeDetermineCUDACompiler.cmake b/Modules/CMakeDetermineCUDACompiler.cmake index 342425c..d06315e 100644 --- a/Modules/CMakeDetermineCUDACompiler.cmake +++ b/Modules/CMakeDetermineCUDACompiler.cmake @@ -441,9 +441,10 @@ elseif(CMAKE_CUDA_COMPILER_ID STREQUAL "NVIDIA") if("${_nvcc_output_line}" MATCHES "^ *nvlink") string(APPEND _nvcc_log " ignoring nvlink line\n") elseif(_nvcc_libraries) - if("${_nvcc_output_line}" MATCHES "(@\"?tmp/a\\.exe\\.res\"?)") + if("${_nvcc_output_line}" MATCHES "(@\"?((tmp/)?a\\.exe\\.res)\"?)") set(_nvcc_link_res_arg "${CMAKE_MATCH_1}") - set(_nvcc_link_res "${CMAKE_PLATFORM_INFO_DIR}/CompilerIdCUDA/tmp/a.exe.res") + set(_nvcc_link_res_file "${CMAKE_MATCH_2}") + set(_nvcc_link_res "${CMAKE_PLATFORM_INFO_DIR}/CompilerIdCUDA/${_nvcc_link_res_file}") if(EXISTS "${_nvcc_link_res}") file(READ "${_nvcc_link_res}" _nvcc_link_res_content) string(REPLACE "${_nvcc_link_res_arg}" "${_nvcc_link_res_content}" _nvcc_output_line "${_nvcc_output_line}") diff --git a/Modules/CMakeDetermineCompilerId.cmake b/Modules/CMakeDetermineCompilerId.cmake index d54e2b0..b38de8a 100644 --- a/Modules/CMakeDetermineCompilerId.cmake +++ b/Modules/CMakeDetermineCompilerId.cmake @@ -267,6 +267,7 @@ function(CMAKE_DETERMINE_COMPILER_ID lang flagvar src) set(CMAKE_${lang}_SIMULATE_ID "${CMAKE_${lang}_SIMULATE_ID}" PARENT_SCOPE) set(CMAKE_${lang}_SIMULATE_VERSION "${CMAKE_${lang}_SIMULATE_VERSION}" PARENT_SCOPE) set(CMAKE_${lang}_STANDARD_COMPUTED_DEFAULT "${CMAKE_${lang}_STANDARD_COMPUTED_DEFAULT}" PARENT_SCOPE) + set(CMAKE_${lang}_EXTENSIONS_COMPUTED_DEFAULT "${CMAKE_${lang}_EXTENSIONS_COMPUTED_DEFAULT}" PARENT_SCOPE) set(CMAKE_${lang}_COMPILER_PRODUCED_OUTPUT "${COMPILER_${lang}_PRODUCED_OUTPUT}" PARENT_SCOPE) set(CMAKE_${lang}_COMPILER_PRODUCED_FILES "${COMPILER_${lang}_PRODUCED_FILES}" PARENT_SCOPE) endfunction() @@ -881,9 +882,12 @@ function(CMAKE_DETERMINE_COMPILER_ID_CHECK lang file) if("${info}" MATCHES "INFO:qnxnto\\[\\]") set(COMPILER_QNXNTO 1) endif() - if("${info}" MATCHES "INFO:dialect_default\\[([^]\"]*)\\]") + if("${info}" MATCHES "INFO:standard_default\\[([^]\"]*)\\]") set(CMAKE_${lang}_STANDARD_COMPUTED_DEFAULT "${CMAKE_MATCH_1}") endif() + if("${info}" MATCHES "INFO:extensions_default\\[([^]\"]*)\\]") + set(CMAKE_${lang}_EXTENSIONS_COMPUTED_DEFAULT "${CMAKE_MATCH_1}") + endif() endforeach() # Construct compiler version from components if needed. @@ -993,6 +997,7 @@ function(CMAKE_DETERMINE_COMPILER_ID_CHECK lang file) set(CMAKE_${lang}_SIMULATE_VERSION "${CMAKE_${lang}_SIMULATE_VERSION}" PARENT_SCOPE) set(COMPILER_QNXNTO "${COMPILER_QNXNTO}" PARENT_SCOPE) set(CMAKE_${lang}_STANDARD_COMPUTED_DEFAULT "${CMAKE_${lang}_STANDARD_COMPUTED_DEFAULT}" PARENT_SCOPE) + set(CMAKE_${lang}_EXTENSIONS_COMPUTED_DEFAULT "${CMAKE_${lang}_EXTENSIONS_COMPUTED_DEFAULT}" PARENT_SCOPE) endfunction() #----------------------------------------------------------------------------- diff --git a/Modules/CMakeHIPCompiler.cmake.in b/Modules/CMakeHIPCompiler.cmake.in index 17633a8..ce4e2cf 100644 --- a/Modules/CMakeHIPCompiler.cmake.in +++ b/Modules/CMakeHIPCompiler.cmake.in @@ -2,6 +2,7 @@ set(CMAKE_HIP_COMPILER "@CMAKE_HIP_COMPILER@") set(CMAKE_HIP_COMPILER_ID "@CMAKE_HIP_COMPILER_ID@") set(CMAKE_HIP_COMPILER_VERSION "@CMAKE_HIP_COMPILER_VERSION@") set(CMAKE_HIP_STANDARD_COMPUTED_DEFAULT "@CMAKE_HIP_STANDARD_COMPUTED_DEFAULT@") +set(CMAKE_HIP_EXTENSIONS_COMPUTED_DEFAULT "@CMAKE_HIP_EXTENSIONS_COMPUTED_DEFAULT@") set(CMAKE_HIP_COMPILE_FEATURES "@CMAKE_HIP_COMPILE_FEATURES@") set(CMAKE_HIP98_COMPILE_FEATURES "@CMAKE_HIP03_COMPILE_FEATURES@") set(CMAKE_HIP11_COMPILE_FEATURES "@CMAKE_HIP11_COMPILE_FEATURES@") diff --git a/Modules/CMakeHIPCompilerId.hip.in b/Modules/CMakeHIPCompilerId.hip.in index 5258efb..3c4a1d4 100644 --- a/Modules/CMakeHIPCompilerId.hip.in +++ b/Modules/CMakeHIPCompilerId.hip.in @@ -16,7 +16,7 @@ char const* info_simulate = "INFO" ":" "simulate[" SIMULATE_ID "]"; @CMAKE_HIP_COMPILER_ID_PLATFORM_CONTENT@ @CMAKE_HIP_COMPILER_ID_ERROR_FOR_TEST@ -const char* info_language_dialect_default = "INFO" ":" "dialect_default[" +const char* info_language_standard_default = "INFO" ":" "standard_default[" #if __cplusplus > 202002L "23" #elif __cplusplus > 201703L @@ -32,6 +32,14 @@ const char* info_language_dialect_default = "INFO" ":" "dialect_default[" #endif "]"; +const char* info_language_extensions_default = "INFO" ":" "extensions_default[" +#if (defined(__clang__) || defined(__GNUC__)) && !defined(__STRICT_ANSI__) + "ON" +#else + "OFF" +#endif +"]"; + /*--------------------------------------------------------------------------*/ int main(int argc, char* argv[]) @@ -48,7 +56,8 @@ int main(int argc, char* argv[]) #ifdef SIMULATE_VERSION_MAJOR require += info_simulate_version[argc]; #endif - require += info_language_dialect_default[argc]; + require += info_language_standard_default[argc]; + require += info_language_extensions_default[argc]; (void)argv; return require; } diff --git a/Modules/CMakeOBJCCompiler.cmake.in b/Modules/CMakeOBJCCompiler.cmake.in index ab67bf3..36f6ec1 100644 --- a/Modules/CMakeOBJCCompiler.cmake.in +++ b/Modules/CMakeOBJCCompiler.cmake.in @@ -5,6 +5,7 @@ set(CMAKE_OBJC_COMPILER_VERSION "@CMAKE_OBJC_COMPILER_VERSION@") set(CMAKE_OBJC_COMPILER_VERSION_INTERNAL "@CMAKE_OBJC_COMPILER_VERSION_INTERNAL@") set(CMAKE_OBJC_COMPILER_WRAPPER "@CMAKE_OBJC_COMPILER_WRAPPER@") set(CMAKE_OBJC_STANDARD_COMPUTED_DEFAULT "@CMAKE_OBJC_STANDARD_COMPUTED_DEFAULT@") +set(CMAKE_OBJC_EXTENSIONS_COMPUTED_DEFAULT "@CMAKE_OBJC_EXTENSIONS_COMPUTED_DEFAULT@") set(CMAKE_OBJC_COMPILE_FEATURES "@CMAKE_OBJC_COMPILE_FEATURES@") set(CMAKE_OBJC90_COMPILE_FEATURES "@CMAKE_OBJC90_COMPILE_FEATURES@") set(CMAKE_OBJC99_COMPILE_FEATURES "@CMAKE_OBJC99_COMPILE_FEATURES@") diff --git a/Modules/CMakeOBJCCompilerId.m.in b/Modules/CMakeOBJCCompilerId.m.in index 418fd48..89bfe02 100644 --- a/Modules/CMakeOBJCCompilerId.m.in +++ b/Modules/CMakeOBJCCompilerId.m.in @@ -23,23 +23,31 @@ char const* qnxnto = "INFO" ":" "qnxnto[]"; #if !defined(__STDC__) # if (defined(_MSC_VER) && !defined(__clang__)) \ || (defined(__ibmxl__) || defined(__IBMC__)) -# define C_DIALECT "90" +# define C_VERSION "90" # else -# define C_DIALECT +# define C_VERSION # endif #elif __STDC_VERSION__ > 201710L -# define C_DIALECT "23" +# define C_VERSION "23" #elif __STDC_VERSION__ >= 201710L -# define C_DIALECT "17" +# define C_VERSION "17" #elif __STDC_VERSION__ >= 201000L -# define C_DIALECT "11" +# define C_VERSION "11" #elif __STDC_VERSION__ >= 199901L -# define C_DIALECT "99" +# define C_VERSION "99" #else -# define C_DIALECT "90" +# define C_VERSION "90" #endif -const char* info_language_dialect_default = - "INFO" ":" "dialect_default[" C_DIALECT "]"; +const char* info_language_standard_default = + "INFO" ":" "standard_default[" C_VERSION "]"; + +const char* info_language_extensions_default = "INFO" ":" "extensions_default[" +#if (defined(__clang__) || defined(__GNUC__)) && !defined(__STRICT_ANSI__) + "ON" +#else + "OFF" +#endif +"]"; /*--------------------------------------------------------------------------*/ @@ -61,7 +69,8 @@ int main(int argc, char* argv[]) #ifdef SIMULATE_VERSION_MAJOR require += info_simulate_version[argc]; #endif - require += info_language_dialect_default[argc]; + require += info_language_standard_default[argc]; + require += info_language_extensions_default[argc]; (void)argv; return require; } diff --git a/Modules/CMakeOBJCXXCompiler.cmake.in b/Modules/CMakeOBJCXXCompiler.cmake.in index a24582b..4f27100 100644 --- a/Modules/CMakeOBJCXXCompiler.cmake.in +++ b/Modules/CMakeOBJCXXCompiler.cmake.in @@ -5,6 +5,7 @@ set(CMAKE_OBJCXX_COMPILER_VERSION "@CMAKE_OBJCXX_COMPILER_VERSION@") set(CMAKE_OBJCXX_COMPILER_VERSION_INTERNAL "@CMAKE_OBJCXX_COMPILER_VERSION_INTERNAL@") set(CMAKE_OBJCXX_COMPILER_WRAPPER "@CMAKE_OBJCXX_COMPILER_WRAPPER@") set(CMAKE_OBJCXX_STANDARD_COMPUTED_DEFAULT "@CMAKE_OBJCXX_STANDARD_COMPUTED_DEFAULT@") +set(CMAKE_OBJCXX_EXTENSIONS_COMPUTED_DEFAULT "@CMAKE_OBJCXX_EXTENSIONS_COMPUTED_DEFAULT@") set(CMAKE_OBJCXX_COMPILE_FEATURES "@CMAKE_OBJCXX_COMPILE_FEATURES@") set(CMAKE_OBJCXX98_COMPILE_FEATURES "@CMAKE_OBJCXX98_COMPILE_FEATURES@") set(CMAKE_OBJCXX11_COMPILE_FEATURES "@CMAKE_OBJCXX11_COMPILE_FEATURES@") diff --git a/Modules/CMakeOBJCXXCompilerId.mm.in b/Modules/CMakeOBJCXXCompilerId.mm.in index e2ac35d..2145b40 100644 --- a/Modules/CMakeOBJCXXCompilerId.mm.in +++ b/Modules/CMakeOBJCXXCompilerId.mm.in @@ -29,7 +29,7 @@ char const* qnxnto = "INFO" ":" "qnxnto[]"; #define CXX_STD __cplusplus #endif -const char* info_language_dialect_default = "INFO" ":" "dialect_default[" +const char* info_language_standard_default = "INFO" ":" "standard_default[" #if CXX_STD > 202002L "23" #elfif CXX_STD > 201703L @@ -45,6 +45,14 @@ const char* info_language_dialect_default = "INFO" ":" "dialect_default[" #endif "]"; +const char* info_language_extensions_default = "INFO" ":" "extensions_default[" +#if (defined(__clang__) || defined(__GNUC__)) && !defined(__STRICT_ANSI__) + "ON" +#else + "OFF" +#endif +"]"; + /*--------------------------------------------------------------------------*/ int main(int argc, char* argv[]) @@ -64,7 +72,8 @@ int main(int argc, char* argv[]) #ifdef SIMULATE_VERSION_MAJOR require += info_simulate_version[argc]; #endif - require += info_language_dialect_default[argc]; + require += info_language_standard_default[argc]; + require += info_language_extensions_default[argc]; (void)argv; return require; } diff --git a/Modules/Compiler/CMakeCommonCompilerMacros.cmake b/Modules/Compiler/CMakeCommonCompilerMacros.cmake index c86af98..2f220d4 100644 --- a/Modules/Compiler/CMakeCommonCompilerMacros.cmake +++ b/Modules/Compiler/CMakeCommonCompilerMacros.cmake @@ -38,20 +38,26 @@ macro(__compiler_check_default_language_standard lang stdver1 std1) # support for language standards, then don't bother. if (CMAKE_${lang}_COMPILER_VERSION VERSION_GREATER_EQUAL "${stdver1}") if (NOT CMAKE_${lang}_COMPILER_FORCED) - if (NOT CMAKE_${lang}_STANDARD_COMPUTED_DEFAULT) - message(FATAL_ERROR "CMAKE_${lang}_STANDARD_COMPUTED_DEFAULT should be set for ${CMAKE_${lang}_COMPILER_ID} (${CMAKE_${lang}_COMPILER}) version ${CMAKE_${lang}_COMPILER_VERSION}") + if (NOT CMAKE_${lang}_STANDARD_COMPUTED_DEFAULT OR NOT DEFINED CMAKE_${lang}_EXTENSIONS_COMPUTED_DEFAULT) + message(FATAL_ERROR "CMAKE_${lang}_STANDARD_COMPUTED_DEFAULT and CMAKE_${lang}_EXTENSIONS_COMPUTED_DEFAULT should be set for ${CMAKE_${lang}_COMPILER_ID} (${CMAKE_${lang}_COMPILER}) version ${CMAKE_${lang}_COMPILER_VERSION}") endif () set(CMAKE_${lang}_STANDARD_DEFAULT ${CMAKE_${lang}_STANDARD_COMPUTED_DEFAULT}) + set(CMAKE_${lang}_EXTENSIONS_DEFAULT ${CMAKE_${lang}_EXTENSIONS_COMPUTED_DEFAULT}) else () list(REVERSE __std_ver_pairs) foreach (__std_ver_pair IN LISTS __std_ver_pairs) string(REGEX MATCH "([^ ]+) (.+)" __std_ver_pair "${__std_ver_pair}") set(__stdver ${CMAKE_MATCH_1}) set(__std ${CMAKE_MATCH_2}) - if (CMAKE_${lang}_COMPILER_VERSION VERSION_GREATER_EQUAL __stdver AND - NOT DEFINED CMAKE_${lang}_STANDARD_DEFAULT) - # Compiler id was forced so just guess the default standard level. - set(CMAKE_${lang}_STANDARD_DEFAULT ${__std}) + # Compiler id was forced so just guess the defaults. + if (CMAKE_${lang}_COMPILER_VERSION VERSION_GREATER_EQUAL __stdver) + if(NOT DEFINED CMAKE_${lang}_EXTENSIONS_DEFAULT) + # Currently known compilers default to enabling extensions. + set(CMAKE_${lang}_EXTENSIONS_DEFAULT ON) + endif() + if(NOT DEFINED CMAKE_${lang}_STANDARD_DEFAULT) + set(CMAKE_${lang}_STANDARD_DEFAULT ${__std}) + endif() endif () unset(__std) unset(__stdver) diff --git a/Modules/Compiler/IAR-ASM.cmake b/Modules/Compiler/IAR-ASM.cmake index 750ac2f..bae0fbd 100644 --- a/Modules/Compiler/IAR-ASM.cmake +++ b/Modules/Compiler/IAR-ASM.cmake @@ -25,7 +25,7 @@ set(CMAKE_ASM_COMPILE_OBJECT "<CMAKE_ASM_COMPILER> ${_CMAKE_IAR_SILENCER_FLAG} < if("${CMAKE_ASM${ASM_DIALECT}_COMPILER_ARCHITECTURE_ID}" IN_LIST _CMAKE_IAR_ITOOLS) __compiler_iar_ilink(ASM) - set(CMAKE_ASM_SOURCE_FILE_EXTENSIONS s;asm;msa) + set(CMAKE_ASM_SOURCE_FILE_EXTENSIONS s;asm;msa;S) elseif("${CMAKE_ASM${ASM_DIALECT}_COMPILER_ARCHITECTURE_ID}" IN_LIST _CMAKE_IAR_XTOOLS) __compiler_iar_xlink(ASM) diff --git a/Modules/Compiler/IAR-C.cmake b/Modules/Compiler/IAR-C.cmake index 9629279..0ef1a2a 100644 --- a/Modules/Compiler/IAR-C.cmake +++ b/Modules/Compiler/IAR-C.cmake @@ -14,6 +14,7 @@ if(NOT DEFINED CMAKE_C_COMPILER_VERSION) message(FATAL_ERROR "CMAKE_C_COMPILER_VERSION not detected. This should be automatic.") endif() +# Unused after CMP0128 set(CMAKE_C_EXTENSION_COMPILE_OPTION -e) if(CMAKE_C_COMPILER_VERSION_INTERNAL VERSION_GREATER 7) diff --git a/Modules/Compiler/IAR-CXX.cmake b/Modules/Compiler/IAR-CXX.cmake index b102aa6..a3f1dbc 100644 --- a/Modules/Compiler/IAR-CXX.cmake +++ b/Modules/Compiler/IAR-CXX.cmake @@ -27,7 +27,7 @@ if(NOT CMAKE_IAR_CXX_FLAG) endif() set(CMAKE_CXX_STANDARD_COMPILE_OPTION "") -set(CMAKE_CXX_EXTENSION_COMPILE_OPTION -e) +set(CMAKE_CXX_EXTENSION_COMPILE_OPTION -e) # Unused after CMP0128 set(CMAKE_CXX${CMAKE_CXX_STANDARD_COMPUTED_DEFAULT}_STANDARD_COMPILE_OPTION "") set(CMAKE_CXX${CMAKE_CXX_STANDARD_COMPUTED_DEFAULT}_EXTENSION_COMPILE_OPTION -e) diff --git a/Modules/FortranCInterface/Detect.cmake b/Modules/FortranCInterface/Detect.cmake index 9e5726b..4d3cb00 100644 --- a/Modules/FortranCInterface/Detect.cmake +++ b/Modules/FortranCInterface/Detect.cmake @@ -8,11 +8,10 @@ configure_file(${FortranCInterface_SOURCE_DIR}/Input.cmake.in # configuration changes. if(NOT EXISTS ${FortranCInterface_BINARY_DIR}/Output.cmake OR NOT EXISTS ${FortranCInterface_BINARY_DIR}/Input.cmake - OR NOT EXISTS ${FortranCInterface_BINARY_DIR}/Output.cmake.in OR NOT ${FortranCInterface_BINARY_DIR}/Output.cmake IS_NEWER_THAN ${FortranCInterface_BINARY_DIR}/Input.cmake OR NOT ${FortranCInterface_SOURCE_DIR}/Output.cmake - IS_NEWER_THAN ${FortranCInterface_BINARY_DIR}/Output.cmake.in + IS_NEWER_THAN ${FortranCInterface_SOURCE_DIR}/Output.cmake.in OR NOT ${FortranCInterface_BINARY_DIR}/Output.cmake IS_NEWER_THAN ${FortranCInterface_SOURCE_DIR}/CMakeLists.txt OR NOT ${FortranCInterface_BINARY_DIR}/Output.cmake diff --git a/Source/CMakeVersion.cmake b/Source/CMakeVersion.cmake index cf85089..cff4806 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 21) -set(CMake_VERSION_PATCH 20211001) +set(CMake_VERSION_PATCH 20211006) #set(CMake_VERSION_RC 0) set(CMake_VERSION_IS_DIRTY 0) diff --git a/Source/cmInstallTargetGenerator.cxx b/Source/cmInstallTargetGenerator.cxx index 2f974c4..ae11afc 100644 --- a/Source/cmInstallTargetGenerator.cxx +++ b/Source/cmInstallTargetGenerator.cxx @@ -2,11 +2,13 @@ file Copyright.txt or https://cmake.org/licensing for details. */ #include "cmInstallTargetGenerator.h" +#include <algorithm> #include <cassert> #include <map> #include <set> #include <sstream> #include <utility> +#include <vector> #include "cmComputeLinkInformation.h" #include "cmGeneratorExpression.h" @@ -680,33 +682,52 @@ void cmInstallTargetGenerator::AddChrpathPatchRule( " this limitation."; mf->IssueMessage(MessageType::WARNING, msg.str()); } else { - // Note: These paths are kept unique to avoid - // install_name_tool corruption. - std::set<std::string> runpaths; - for (std::string const& i : oldRuntimeDirs) { - std::string runpath = - mf->GetGlobalGenerator()->ExpandCFGIntDir(i, config); - - if (runpaths.find(runpath) == runpaths.end()) { - runpaths.insert(runpath); - os << indent << "execute_process(COMMAND " << installNameTool - << "\n"; - os << indent << " -delete_rpath \"" << runpath << "\"\n"; - os << indent << " \"" << toDestDirPath << "\")\n"; + // To be consistent with older versions, runpath changes must be ordered, + // deleted first, then added, *and* the same path must only appear once. + std::map<std::string, std::string> runpath_change; + std::vector<std::string> ordered; + for (std::string const& dir : oldRuntimeDirs) { + // Normalize path and add to map of changes to make + auto iter_inserted = runpath_change.insert( + { mf->GetGlobalGenerator()->ExpandCFGIntDir(dir, config), + "delete" }); + if (iter_inserted.second) { + // Add path to ordered list of changes + ordered.push_back(iter_inserted.first->first); } } - runpaths.clear(); - for (std::string const& i : newRuntimeDirs) { - std::string runpath = - mf->GetGlobalGenerator()->ExpandCFGIntDir(i, config); + for (std::string const& dir : newRuntimeDirs) { + // Normalize path and add to map of changes to make + auto iter_inserted = runpath_change.insert( + { mf->GetGlobalGenerator()->ExpandCFGIntDir(dir, config), "add" }); + if (iter_inserted.second) { + // Add path to ordered list of changes + ordered.push_back(iter_inserted.first->first); + } else if (iter_inserted.first->second != "add") { + // Rpath was requested to be deleted and then later re-added. Drop it + // from the list by marking as an empty value. + iter_inserted.first->second.clear(); + } + } - if (runpaths.find(runpath) == runpaths.end()) { - os << indent << "execute_process(COMMAND " << installNameTool - << "\n"; - os << indent << " -add_rpath \"" << runpath << "\"\n"; - os << indent << " \"" << toDestDirPath << "\")\n"; + // Remove rpaths that are unchanged (value was set to empty) + ordered.erase( + std::remove_if(ordered.begin(), ordered.end(), + [&runpath_change](const std::string& runpath) { + return runpath_change.find(runpath)->second.empty(); + }), + ordered.end()); + + if (!ordered.empty()) { + os << indent << "execute_process(COMMAND " << installNameTool << "\n"; + for (std::string const& runpath : ordered) { + // Either 'add_rpath' or 'delete_rpath' since we've removed empty + // entries + os << indent << " -" << runpath_change.find(runpath)->second + << "_rpath \"" << runpath << "\"\n"; } + os << indent << " \"" << toDestDirPath << "\")\n"; } } } else { diff --git a/Source/cmMakefile.cxx b/Source/cmMakefile.cxx index a490dac..83984f7 100644 --- a/Source/cmMakefile.cxx +++ b/Source/cmMakefile.cxx @@ -3982,11 +3982,10 @@ cmValue cmMakefile::GetProperty(const std::string& prop) const if (prop == "TESTS") { std::vector<std::string> keys; // get list of keys - std::transform(this->Tests.begin(), this->Tests.end(), - std::back_inserter(keys), - [](decltype(this->Tests)::value_type const& pair) { - return pair.first; - }); + const auto* t = this; + std::transform( + t->Tests.begin(), t->Tests.end(), std::back_inserter(keys), + [](decltype(t->Tests)::value_type const& pair) { return pair.first; }); output = cmJoin(keys, ";"); return cmValue(output); } diff --git a/Source/cmPolicies.h b/Source/cmPolicies.h index a98e6c6..ce04117 100644 --- a/Source/cmPolicies.h +++ b/Source/cmPolicies.h @@ -382,7 +382,10 @@ class cmMakefile; 21, 0, cmPolicies::WARN) \ SELECT(POLICY, CMP0127, \ "cmake_dependent_option() supports full Condition Syntax.", 3, 22, \ - 0, cmPolicies::WARN) + 0, cmPolicies::WARN) \ + SELECT(POLICY, CMP0128, \ + "Selection of language standard and extension flags improved.", 3, \ + 22, 0, cmPolicies::WARN) #define CM_SELECT_ID(F, A1, A2, A3, A4, A5, A6) F(A1) #define CM_FOR_EACH_POLICY_ID(POLICY) \ diff --git a/Source/cmStandardLevelResolver.cxx b/Source/cmStandardLevelResolver.cxx index c73f53a..957f4ca 100644 --- a/Source/cmStandardLevelResolver.cxx +++ b/Source/cmStandardLevelResolver.cxx @@ -20,6 +20,7 @@ #include "cmGlobalGenerator.h" #include "cmMakefile.h" #include "cmMessageType.h" +#include "cmPolicies.h" #include "cmStringAlgorithms.h" #include "cmTarget.h" #include "cmValue.h" @@ -83,25 +84,62 @@ struct StandardLevelComputer return std::string{}; } + cmPolicies::PolicyStatus const cmp0128{ makefile->GetPolicyStatus( + cmPolicies::CMP0128) }; + bool const defaultExt{ cmIsOn(*makefile->GetDefinition( + cmStrCat("CMAKE_", this->Language, "_EXTENSIONS_DEFAULT"))) }; bool ext = true; + + if (cmp0128 == cmPolicies::NEW) { + ext = defaultExt; + } + if (cmValue extPropValue = target->GetLanguageExtensions(this->Language)) { - if (cmIsOff(*extPropValue)) { - ext = false; - } + ext = cmIsOn(*extPropValue); } + std::string const type{ ext ? "EXTENSION" : "STANDARD" }; + cmValue standardProp = target->GetLanguageStandard(this->Language, config); if (!standardProp) { - if (ext) { - // No language standard is specified and extensions are not disabled. - // Check if this compiler needs a flag to enable extensions. - return cmStrCat("CMAKE_", this->Language, "_EXTENSION_COMPILE_OPTION"); + if (cmp0128 == cmPolicies::NEW) { + // Add extension flag if compiler's default doesn't match. + if (ext != defaultExt) { + return cmStrCat("CMAKE_", this->Language, *defaultStd, "_", type, + "_COMPILE_OPTION"); + } + } else { + if (cmp0128 == cmPolicies::WARN && + makefile->PolicyOptionalWarningEnabled( + "CMAKE_POLICY_WARNING_CMP0128") && + ext != defaultExt) { + const char* state{}; + if (ext) { + if (!makefile->GetDefinition(cmStrCat( + "CMAKE_", this->Language, "_EXTENSION_COMPILE_OPTION"))) { + state = "enabled"; + } + } else { + state = "disabled"; + } + if (state) { + makefile->IssueMessage( + MessageType::AUTHOR_WARNING, + cmStrCat(cmPolicies::GetPolicyWarning(cmPolicies::CMP0128), + "\nFor compatibility with older versions of CMake, " + "compiler extensions won't be ", + state, ".")); + } + } + + if (ext) { + return cmStrCat("CMAKE_", this->Language, + "_EXTENSION_COMPILE_OPTION"); + } } return std::string{}; } - std::string const type = ext ? "EXTENSION" : "STANDARD"; - if (target->GetLanguageStandardRequired(this->Language)) { std::string option_flag = cmStrCat( "CMAKE_", this->Language, *standardProp, "_", type, "_COMPILE_OPTION"); @@ -121,6 +159,25 @@ struct StandardLevelComputer return option_flag; } + // If the request matches the compiler's defaults we don't need to add + // anything. + if (*standardProp == *defaultStd && ext == defaultExt) { + if (cmp0128 == cmPolicies::NEW) { + return std::string{}; + } + + if (cmp0128 == cmPolicies::WARN && + makefile->PolicyOptionalWarningEnabled( + "CMAKE_POLICY_WARNING_CMP0128")) { + makefile->IssueMessage( + MessageType::AUTHOR_WARNING, + cmStrCat(cmPolicies::GetPolicyWarning(cmPolicies::CMP0128), + "\nFor compatibility with older versions of CMake, " + "unnecessary flags for language standard or compiler " + "extensions may be added.")); + } + } + std::string standardStr(*standardProp); if (this->Language == "CUDA" && standardStr == "98") { standardStr = "03"; @@ -147,17 +204,17 @@ struct StandardLevelComputer return std::string{}; } - // If the standard requested is older than the compiler's default - // then we need to use a flag to change it. - if (stdIt <= defaultStdIt) { + // If the standard requested is older than the compiler's default or the + // extension mode doesn't match then we need to use a flag. + if (stdIt < defaultStdIt) { auto offset = std::distance(cm::cbegin(stds), stdIt); return cmStrCat("CMAKE_", this->Language, stdsStrings[offset], "_", type, "_COMPILE_OPTION"); } - // The standard requested is at least as new as the compiler's default, - // and the standard request is not required. Decay to the newest standard - // for which a flag is defined. + // The compiler's default is at least as new as the requested standard, + // and the requested standard is not required. Decay to the newest + // standard for which a flag is defined. for (; defaultStdIt < stdIt; --stdIt) { auto offset = std::distance(cm::cbegin(stds), stdIt); std::string option_flag = diff --git a/Templates/TestDriver.cxx.in b/Templates/TestDriver.cxx.in index 6ced800..632bb80 100644 --- a/Templates/TestDriver.cxx.in +++ b/Templates/TestDriver.cxx.in @@ -138,7 +138,7 @@ int main(int ac, char* av[]) t = clock() - t; status_message = (status == -1) ? "not ok" : "ok"; { - double time_taken = ((double)t) / CLOCKS_PER_SEC; + double time_taken = CM_CAST(double, t) / CLOCKS_PER_SEC; printf("%s %d %s # %f\n", status_message, i + 1, name, time_taken); } } diff --git a/Tests/CMakeLists.txt b/Tests/CMakeLists.txt index da6b670..20b6e25 100644 --- a/Tests/CMakeLists.txt +++ b/Tests/CMakeLists.txt @@ -257,6 +257,13 @@ if(BUILD_TESTING) #--------------------------------------------------------------------------- # Add tests below here. + if(NOT DEFINED CMake_TEST_Qt6) + set(CMake_TEST_Qt6 1) + endif() + if(CMake_TEST_Qt6) + find_package(Qt6 COMPONENTS Core Widgets QUIET NO_MODULE) + endif() + if(NOT DEFINED CMake_TEST_Qt5) set(CMake_TEST_Qt5 1) endif() @@ -1384,6 +1391,9 @@ if(BUILD_TESTING) ) list(APPEND TEST_BUILD_DIRS "${CMake_BINARY_DIR}/Tests/QtAutomocNoQt") + if(CMake_TEST_Qt6 AND Qt6Widgets_FOUND) + add_subdirectory(Qt6Autogen) + endif() if(CMake_TEST_Qt5 AND Qt5Widgets_FOUND) add_subdirectory(Qt5Autogen) endif() diff --git a/Tests/Qt6Autogen/CMakeLists.txt b/Tests/Qt6Autogen/CMakeLists.txt new file mode 100644 index 0000000..a603b50 --- /dev/null +++ b/Tests/Qt6Autogen/CMakeLists.txt @@ -0,0 +1,8 @@ +# Set Qt test version and include the Autogen test macros +set(QT_TEST_VERSION 6) +include("../QtAutogen/TestMacros.cmake") + +# Common tests +include("../QtAutogen/Tests.cmake") + +set(TEST_BUILD_DIRS "${TEST_BUILD_DIRS}" PARENT_SCOPE) diff --git a/Tests/QtAutogen/AutogenCoreTest.cmake b/Tests/QtAutogen/AutogenCoreTest.cmake index 5803859..e62a6aa 100644 --- a/Tests/QtAutogen/AutogenCoreTest.cmake +++ b/Tests/QtAutogen/AutogenCoreTest.cmake @@ -21,27 +21,27 @@ if (QT_TEST_VERSION EQUAL 4) qt4_generate_moc(${ARGN}) endmacro() -elseif(QT_TEST_VERSION EQUAL 5) +elseif(QT_TEST_VERSION GREATER_EQUAL 5) - find_package(Qt5Core REQUIRED) + find_package(Qt${QT_TEST_VERSION}Core REQUIRED) - set(QT_QTCORE_TARGET Qt5::Core) - set(QT_LIBRARIES Qt5::Core) + set(QT_QTCORE_TARGET Qt${QT_TEST_VERSION}::Core) + set(QT_LIBRARIES Qt${QT_TEST_VERSION}::Core) # Include directories - include_directories(${Qt5Core_INCLUDE_DIRS}) + include_directories(${Qt${QT_TEST_VERSION}Core_INCLUDE_DIRS}) # Definitions - if(Qt5_POSITION_INDEPENDENT_CODE AND CMAKE_CXX_COMPILE_OPTIONS_PIC) + if(Qt${QT_TEST_VERSION}_POSITION_INDEPENDENT_CODE AND CMAKE_CXX_COMPILE_OPTIONS_PIC) add_definitions(${CMAKE_CXX_COMPILE_OPTIONS_PIC}) endif() # Qt macros macro(qtx_wrap_cpp) - qt5_wrap_cpp(${ARGN}) + cmake_language(CALL qt${QT_TEST_VERSION}_wrap_cpp ${ARGN}) endmacro() macro(qtx_generate_moc) - qt5_generate_moc(${ARGN}) + cmake_language(CALL qt${QT_TEST_VERSION}_generate_moc ${ARGN}) endmacro() else() diff --git a/Tests/QtAutogen/AutogenGuiTest.cmake b/Tests/QtAutogen/AutogenGuiTest.cmake index b76d341..e5eb751 100644 --- a/Tests/QtAutogen/AutogenGuiTest.cmake +++ b/Tests/QtAutogen/AutogenGuiTest.cmake @@ -21,27 +21,27 @@ if (QT_TEST_VERSION EQUAL 4) qt4_generate_moc(${ARGN}) endmacro() -elseif(QT_TEST_VERSION EQUAL 5) +elseif(QT_TEST_VERSION GREATER_EQUAL 5) - find_package(Qt5Widgets REQUIRED) + find_package(Qt${QT_TEST_VERSION}Widgets REQUIRED) - set(QT_QTCORE_TARGET Qt5::Core) - set(QT_LIBRARIES Qt5::Widgets) + set(QT_QTCORE_TARGET Qt${QT_TEST_VERSION}::Core) + set(QT_LIBRARIES Qt${QT_TEST_VERSION}::Widgets) # Include directories - include_directories(${Qt5Widgets_INCLUDE_DIRS}) + include_directories(${Qt${QT_TEST_VERSION}Widgets_INCLUDE_DIRS}) # Definitions - if(Qt5_POSITION_INDEPENDENT_CODE AND CMAKE_CXX_COMPILE_OPTIONS_PIC) + if(Qt${QT_TEST_VERSION}_POSITION_INDEPENDENT_CODE AND CMAKE_CXX_COMPILE_OPTIONS_PIC) add_definitions(${CMAKE_CXX_COMPILE_OPTIONS_PIC}) endif() # Qt macros macro(qtx_wrap_cpp) - qt5_wrap_cpp(${ARGN}) + cmake_language(CALL qt${QT_TEST_VERSION}_wrap_cpp ${ARGN}) endmacro() macro(qtx_generate_moc) - qt5_generate_moc(${ARGN}) + cmake_language(CALL qt${QT_TEST_VERSION}_generate_moc ${ARGN}) endmacro() else() diff --git a/Tests/QtAutogen/AutogenOriginDependsOff/CMakeLists.txt b/Tests/QtAutogen/AutogenOriginDependsOff/CMakeLists.txt index 17855ff..cac680f 100644 --- a/Tests/QtAutogen/AutogenOriginDependsOff/CMakeLists.txt +++ b/Tests/QtAutogen/AutogenOriginDependsOff/CMakeLists.txt @@ -1,4 +1,4 @@ -cmake_minimum_required(VERSION 3.11) +cmake_minimum_required(VERSION 3.16) project(AutogenOriginDependsOff) include("../AutogenCoreTest.cmake") diff --git a/Tests/QtAutogen/AutogenOriginDependsOn/CMakeLists.txt b/Tests/QtAutogen/AutogenOriginDependsOn/CMakeLists.txt index 5aabe0e..37ce90b 100644 --- a/Tests/QtAutogen/AutogenOriginDependsOn/CMakeLists.txt +++ b/Tests/QtAutogen/AutogenOriginDependsOn/CMakeLists.txt @@ -1,4 +1,4 @@ -cmake_minimum_required(VERSION 3.10) +cmake_minimum_required(VERSION 3.16) project(AutogenOriginDependsOn) include("../AutogenCoreTest.cmake") diff --git a/Tests/QtAutogen/AutogenTargetDepends/CMakeLists.txt b/Tests/QtAutogen/AutogenTargetDepends/CMakeLists.txt index 492b5db..cf3f155 100644 --- a/Tests/QtAutogen/AutogenTargetDepends/CMakeLists.txt +++ b/Tests/QtAutogen/AutogenTargetDepends/CMakeLists.txt @@ -1,4 +1,4 @@ -cmake_minimum_required(VERSION 3.10) +cmake_minimum_required(VERSION 3.16) project(AutogenTargetDepends) include("../AutogenCoreTest.cmake") diff --git a/Tests/QtAutogen/Complex/CMakeLists.txt b/Tests/QtAutogen/Complex/CMakeLists.txt index d9fdf5c..8a9a5d2 100644 --- a/Tests/QtAutogen/Complex/CMakeLists.txt +++ b/Tests/QtAutogen/Complex/CMakeLists.txt @@ -1,4 +1,4 @@ -cmake_minimum_required(VERSION 3.10) +cmake_minimum_required(VERSION 3.16) project(Complex) include("../AutogenGuiTest.cmake") @@ -16,6 +16,8 @@ add_library(privateSlot OBJECT private_slot.cpp) # Pass Qt compiler features to targets that don't link against Qt target_compile_features(codeeditorLib PRIVATE ${QT_COMPILE_FEATURES}) target_compile_features(privateSlot PRIVATE ${QT_COMPILE_FEATURES}) +target_link_libraries(codeeditorLib PRIVATE ${QT_LIBRARIES}) +target_link_libraries(privateSlot PRIVATE ${QT_LIBRARIES}) configure_file(generated_resource.qrc.in generated_resource.qrc @ONLY) add_custom_command( diff --git a/Tests/QtAutogen/Complex/codeeditor.cpp b/Tests/QtAutogen/Complex/codeeditor.cpp index 80d6a55..9c9dbc3 100644 --- a/Tests/QtAutogen/Complex/codeeditor.cpp +++ b/Tests/QtAutogen/Complex/codeeditor.cpp @@ -70,7 +70,11 @@ int CodeEditor::lineNumberAreaWidth() ++digits; } +#if (QT_VERSION >= QT_VERSION_CHECK(5, 11, 0)) + int space = 3 + fontMetrics().horizontalAdvance(QLatin1Char('9')) * digits; +#else int space = 3 + fontMetrics().width(QLatin1Char('9')) * digits; +#endif return space; } diff --git a/Tests/QtAutogen/GlobalAutogenTarget/CMakeLists.txt b/Tests/QtAutogen/GlobalAutogenTarget/CMakeLists.txt index e95c626..5c70e43 100644 --- a/Tests/QtAutogen/GlobalAutogenTarget/CMakeLists.txt +++ b/Tests/QtAutogen/GlobalAutogenTarget/CMakeLists.txt @@ -1,4 +1,4 @@ -cmake_minimum_required(VERSION 3.12) +cmake_minimum_required(VERSION 3.16) project(GlobalAutogenTarget) include("../AutogenCoreTest.cmake") @@ -74,6 +74,7 @@ execute_process( -T "${CMAKE_GENERATOR_TOOLSET}" "-DQT_TEST_VERSION=${QT_TEST_VERSION}" "-DCMAKE_AUTOGEN_VERBOSE=${CMAKE_AUTOGEN_VERBOSE}" + "-DCMAKE_PREFIX_PATH:STRING=${CMAKE_PREFIX_PATH}" "-DQT_QMAKE_EXECUTABLE:FILEPATH=${QT_QMAKE_EXECUTABLE}" WORKING_DIRECTORY "${GAT_BDIR}" OUTPUT_VARIABLE output diff --git a/Tests/QtAutogen/GlobalAutogenTarget/GAT/CMakeLists.txt b/Tests/QtAutogen/GlobalAutogenTarget/GAT/CMakeLists.txt index 3925197..0e3df6f 100644 --- a/Tests/QtAutogen/GlobalAutogenTarget/GAT/CMakeLists.txt +++ b/Tests/QtAutogen/GlobalAutogenTarget/GAT/CMakeLists.txt @@ -1,4 +1,4 @@ -cmake_minimum_required(VERSION 3.12) +cmake_minimum_required(VERSION 3.16) project(GAT) include("../../AutogenCoreTest.cmake") @@ -9,7 +9,7 @@ include_directories(${CMAKE_CURRENT_SOURCE_DIR}) set(CMAKE_AUTOMOC ON) set(CMAKE_AUTOUIC ON) set(CMAKE_AUTORCC ON) -# Disable ORIGN_DEPENDS and enable AUTOGEN global targets +# Disable ORIGIN_DEPENDS and enable AUTOGEN global targets set(CMAKE_AUTOGEN_ORIGIN_DEPENDS OFF) set(CMAKE_GLOBAL_AUTOGEN_TARGET ON) set(CMAKE_GLOBAL_AUTORCC_TARGET ON) diff --git a/Tests/QtAutogen/MacOsFW/CMakeLists.txt b/Tests/QtAutogen/MacOsFW/CMakeLists.txt index c08efc4..27c5f43 100644 --- a/Tests/QtAutogen/MacOsFW/CMakeLists.txt +++ b/Tests/QtAutogen/MacOsFW/CMakeLists.txt @@ -1,21 +1,23 @@ -cmake_minimum_required(VERSION 3.10) +cmake_minimum_required(VERSION 3.16) project(MacOsFW) include("../AutogenGuiTest.cmake") -find_package(Qt5Test REQUIRED) +find_package(Qt${QT_TEST_VERSION}Test REQUIRED) + +if(QT_TEST_VERSION EQUAL 5) + set(CMAKE_CXX_STANDARD 11) +elseif(QT_TEST_VERSION EQUAL 6) + set(CMAKE_CXX_STANDARD 17) +else() + message(FATAL_ERROR "Unsupported Qt version: ${QT_TEST_VERSION}") +endif() -set(CMAKE_CXX_STANDARD 11) set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/output/bin) set(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/output/lib) set(CMAKE_INSTALL_NAME_DIR ${CMAKE_BINARY_DIR}/output/lib) -if(POLICY CMP0042) # in CMake 3.0.0+ - set (CMAKE_MACOSX_RPATH OFF) # otherwise ON by default -endif(POLICY CMP0042) - -if(POLICY CMP0068) # in CMake 3.9+ - cmake_policy(SET CMP0068 NEW) -endif(POLICY CMP0068) +set (CMAKE_MACOSX_RPATH OFF) # otherwise ON by default +cmake_policy(SET CMP0068 NEW) add_subdirectory(src) add_subdirectory(test) diff --git a/Tests/QtAutogen/MacOsFW/src/CMakeLists.txt b/Tests/QtAutogen/MacOsFW/src/CMakeLists.txt index a02be00..67e2c8a 100644 --- a/Tests/QtAutogen/MacOsFW/src/CMakeLists.txt +++ b/Tests/QtAutogen/MacOsFW/src/CMakeLists.txt @@ -9,7 +9,7 @@ set(MACOS_FW_LIB_HDRS include_directories( ${CMAKE_CURRENT_SOURCE_DIR} ${CMAKE_CURRENT_BINARY_DIR} - ${Qt5Core_INCLUDE_DIRS} + ${Qt${QT_TEST_VERSION}Core_INCLUDE_DIRS} ) add_library(macos_fw_lib SHARED @@ -28,6 +28,4 @@ set_target_properties(macos_fw_lib PROPERTIES POSITION_INDEPENDENT_CODE ON PUBLIC_HEADER "${MACOS_FW_LIB_HDRS}" ) -target_link_libraries(macos_fw_lib - Qt5::Core -) +target_link_libraries(macos_fw_lib PRIVATE ${QT_QTCORE_TARGET}) diff --git a/Tests/QtAutogen/MacOsFW/test/CMakeLists.txt b/Tests/QtAutogen/MacOsFW/test/CMakeLists.txt index 521c184..8cb1bc5 100644 --- a/Tests/QtAutogen/MacOsFW/test/CMakeLists.txt +++ b/Tests/QtAutogen/MacOsFW/test/CMakeLists.txt @@ -4,16 +4,16 @@ include_directories( ${CMAKE_CURRENT_SOURCE_DIR}/../src ) include_directories(SYSTEM - ${Qt5Core_INCLUDE_DIRS} - ${Qt5Widgets_INCLUDE_DIRS} + ${Qt${QT_TEST_VERSION}Core_INCLUDE_DIRS} + ${Qt${QT_TEST_VERSION}Widgets_INCLUDE_DIRS} ) set(testname AutomocMacosFWLib) add_executable(${testname} testMacosFWLib.cpp) set_target_properties(${testname} PROPERTIES AUTOMOC TRUE) -target_link_libraries(${testname} - Qt5::Core - Qt5::Widgets - Qt5::Test +target_link_libraries(${testname} PRIVATE + Qt${QT_TEST_VERSION}::Core + Qt${QT_TEST_VERSION}::Widgets + Qt${QT_TEST_VERSION}::Test macos_fw_lib ) diff --git a/Tests/QtAutogen/ManySources/CMakeLists.txt b/Tests/QtAutogen/ManySources/CMakeLists.txt index df8a2a6..f9ac7db 100644 --- a/Tests/QtAutogen/ManySources/CMakeLists.txt +++ b/Tests/QtAutogen/ManySources/CMakeLists.txt @@ -1,4 +1,4 @@ -cmake_minimum_required(VERSION 3.10) +cmake_minimum_required(VERSION 3.16) project(ManySources) include("../AutogenGuiTest.cmake") diff --git a/Tests/QtAutogen/MocCMP0071/CMakeLists.txt b/Tests/QtAutogen/MocCMP0071/CMakeLists.txt index 5c58a82..7ab3a8e 100644 --- a/Tests/QtAutogen/MocCMP0071/CMakeLists.txt +++ b/Tests/QtAutogen/MocCMP0071/CMakeLists.txt @@ -1,4 +1,4 @@ -cmake_minimum_required(VERSION 3.10) +cmake_minimum_required(VERSION 3.16) project(MocCMP0071) include("../AutogenCoreTest.cmake") diff --git a/Tests/QtAutogen/MocCMP0071/NEW/CMakeLists.txt b/Tests/QtAutogen/MocCMP0071/NEW/CMakeLists.txt index 954fe3d..4375b17 100644 --- a/Tests/QtAutogen/MocCMP0071/NEW/CMakeLists.txt +++ b/Tests/QtAutogen/MocCMP0071/NEW/CMakeLists.txt @@ -1,4 +1,3 @@ -cmake_minimum_required(VERSION 3.10) cmake_policy(SET CMP0071 NEW) # *Generate* files diff --git a/Tests/QtAutogen/MocCMP0071/OLD/CMakeLists.txt b/Tests/QtAutogen/MocCMP0071/OLD/CMakeLists.txt index 68fa067..3771487 100644 --- a/Tests/QtAutogen/MocCMP0071/OLD/CMakeLists.txt +++ b/Tests/QtAutogen/MocCMP0071/OLD/CMakeLists.txt @@ -1,4 +1,3 @@ -cmake_minimum_required(VERSION 3.10) cmake_policy(SET CMP0071 OLD) # *Generate* files diff --git a/Tests/QtAutogen/MocCMP0100/CMakeLists.txt b/Tests/QtAutogen/MocCMP0100/CMakeLists.txt index 559cffe..b19dc6a 100644 --- a/Tests/QtAutogen/MocCMP0100/CMakeLists.txt +++ b/Tests/QtAutogen/MocCMP0100/CMakeLists.txt @@ -1,4 +1,4 @@ -cmake_minimum_required(VERSION 3.10) +cmake_minimum_required(VERSION 3.16) project(MocCMP0100) include("../AutogenCoreTest.cmake") diff --git a/Tests/QtAutogen/MocCMP0100/NEW/CMakeLists.txt b/Tests/QtAutogen/MocCMP0100/NEW/CMakeLists.txt index 654b31e..aaaf7fb 100644 --- a/Tests/QtAutogen/MocCMP0100/NEW/CMakeLists.txt +++ b/Tests/QtAutogen/MocCMP0100/NEW/CMakeLists.txt @@ -1,4 +1,3 @@ -cmake_minimum_required(VERSION 3.16) cmake_policy(SET CMP0100 NEW) add_executable(mocCMP0100New diff --git a/Tests/QtAutogen/MocCMP0100/OLD/CMakeLists.txt b/Tests/QtAutogen/MocCMP0100/OLD/CMakeLists.txt index 2be0535..006cda1 100644 --- a/Tests/QtAutogen/MocCMP0100/OLD/CMakeLists.txt +++ b/Tests/QtAutogen/MocCMP0100/OLD/CMakeLists.txt @@ -1,4 +1,3 @@ -cmake_minimum_required(VERSION 3.16) cmake_policy(SET CMP0100 OLD) # Generate moc files externally. diff --git a/Tests/QtAutogen/MocInclude/CMakeLists.txt b/Tests/QtAutogen/MocInclude/CMakeLists.txt index 04c8baf..4224d2f 100644 --- a/Tests/QtAutogen/MocInclude/CMakeLists.txt +++ b/Tests/QtAutogen/MocInclude/CMakeLists.txt @@ -1,4 +1,4 @@ -cmake_minimum_required(VERSION 3.15) +cmake_minimum_required(VERSION 3.16) project(MocInclude) get_filename_component(CS_REAL ${CMAKE_CURRENT_SOURCE_DIR} REALPATH) include("${CS_REAL}/../AutogenCoreTest.cmake") diff --git a/Tests/QtAutogen/MocIncludeSymlink/CMakeLists.txt b/Tests/QtAutogen/MocIncludeSymlink/CMakeLists.txt index 8b11b46..c28616b 100644 --- a/Tests/QtAutogen/MocIncludeSymlink/CMakeLists.txt +++ b/Tests/QtAutogen/MocIncludeSymlink/CMakeLists.txt @@ -1,4 +1,4 @@ -cmake_minimum_required(VERSION 3.15) +cmake_minimum_required(VERSION 3.16) project(MocIncludeSymlink) include("../AutogenCoreTest.cmake") @@ -63,6 +63,7 @@ macro(buildMocInclude sourceDir binaryDir) CMAKE_FLAGS "-DQT_TEST_VERSION=${QT_TEST_VERSION}" "-DCMAKE_AUTOMOC_PATH_PREFIX=ON" "-DCMAKE_AUTOGEN_VERBOSE=${CMAKE_AUTOGEN_VERBOSE}" + "-DCMAKE_PREFIX_PATH:STRING=${CMAKE_PREFIX_PATH}" "-DQT_QMAKE_EXECUTABLE:FILEPATH=${QT_QMAKE_EXECUTABLE}" OUTPUT_VARIABLE output ) diff --git a/Tests/QtAutogen/MocMacroName/CMakeLists.txt b/Tests/QtAutogen/MocMacroName/CMakeLists.txt index bf13d18..d8dc4a3 100644 --- a/Tests/QtAutogen/MocMacroName/CMakeLists.txt +++ b/Tests/QtAutogen/MocMacroName/CMakeLists.txt @@ -1,4 +1,4 @@ -cmake_minimum_required(VERSION 3.10) +cmake_minimum_required(VERSION 3.16) project(MocMacroName) include("../AutogenCoreTest.cmake") diff --git a/Tests/QtAutogen/MocOnly/CMakeLists.txt b/Tests/QtAutogen/MocOnly/CMakeLists.txt index f4fde58..b5d405a 100644 --- a/Tests/QtAutogen/MocOnly/CMakeLists.txt +++ b/Tests/QtAutogen/MocOnly/CMakeLists.txt @@ -1,4 +1,4 @@ -cmake_minimum_required(VERSION 3.10) +cmake_minimum_required(VERSION 3.16) project(MocOnly) include("../AutogenCoreTest.cmake") diff --git a/Tests/QtAutogen/MocOptions/CMakeLists.txt b/Tests/QtAutogen/MocOptions/CMakeLists.txt index 19ee658..169e6cb 100644 --- a/Tests/QtAutogen/MocOptions/CMakeLists.txt +++ b/Tests/QtAutogen/MocOptions/CMakeLists.txt @@ -1,4 +1,4 @@ -cmake_minimum_required(VERSION 3.10) +cmake_minimum_required(VERSION 3.16) project(MocOptions) include("../AutogenCoreTest.cmake") diff --git a/Tests/QtAutogen/MocOsMacros/CMakeLists.txt b/Tests/QtAutogen/MocOsMacros/CMakeLists.txt index b0125f6..db44da3 100644 --- a/Tests/QtAutogen/MocOsMacros/CMakeLists.txt +++ b/Tests/QtAutogen/MocOsMacros/CMakeLists.txt @@ -1,10 +1,10 @@ -cmake_minimum_required(VERSION 3.11) +cmake_minimum_required(VERSION 3.16) project(MocOsMacros) include("../AutogenCoreTest.cmake") # Tests if moc processes Q_OS_XXX macros -message( "Qt5Core_VERSION: ${Qt5Core_VERSION}" ) +message( "Qt${QT_TEST_VERSION}Core_VERSION: ${Qt${QT_TEST_VERSION}Core_VERSION}" ) message( "CMAKE_CXX_COMPILER_PREDEFINES_COMMAND: " ${CMAKE_CXX_COMPILER_PREDEFINES_COMMAND} ) @@ -12,7 +12,7 @@ message( # On some platforms (e.g. MAC) Q_OS_XXX requires moc to include moc_predefs.h # which is supported since Qt 5.8 and requires # CMAKE_CXX_COMPILER_PREDEFINES_COMMAND to be defined. -if( ( ${Qt5Core_VERSION} VERSION_GREATER_EQUAL "5.8" ) AND +if( ( ${Qt${QT_TEST_VERSION}Core_VERSION} VERSION_GREATER_EQUAL "5.8" ) AND DEFINED CMAKE_CXX_COMPILER_PREDEFINES_COMMAND ) message( "Test enabled!" ) diff --git a/Tests/QtAutogen/MocSkipSource/CMakeLists.txt b/Tests/QtAutogen/MocSkipSource/CMakeLists.txt index c886736..b9e20c8 100644 --- a/Tests/QtAutogen/MocSkipSource/CMakeLists.txt +++ b/Tests/QtAutogen/MocSkipSource/CMakeLists.txt @@ -1,4 +1,4 @@ -cmake_minimum_required(VERSION 3.10) +cmake_minimum_required(VERSION 3.16) project(MocSkipSource) include("../AutogenCoreTest.cmake") diff --git a/Tests/QtAutogen/ObjectLibrary/CMakeLists.txt b/Tests/QtAutogen/ObjectLibrary/CMakeLists.txt index e8af6c9..88d0998 100644 --- a/Tests/QtAutogen/ObjectLibrary/CMakeLists.txt +++ b/Tests/QtAutogen/ObjectLibrary/CMakeLists.txt @@ -1,4 +1,4 @@ -cmake_minimum_required(VERSION 3.10) +cmake_minimum_required(VERSION 3.16) project(ObjectLibrary) include("../AutogenCoreTest.cmake") @@ -11,7 +11,7 @@ add_subdirectory(a) # Object library b defined locally include_directories(b) add_library(b OBJECT b/classb.cpp) -target_compile_features(b PRIVATE ${QT_COMPILE_FEATURES}) +target_link_libraries(b PRIVATE ${QT_LIBRARIES}) # Executable with OBJECT library generator expressions add_executable(someProgram main.cpp $<TARGET_OBJECTS:a> $<TARGET_OBJECTS:b>) diff --git a/Tests/QtAutogen/ObjectLibrary/a/CMakeLists.txt b/Tests/QtAutogen/ObjectLibrary/a/CMakeLists.txt index fe76ac3..5ace3ae 100644 --- a/Tests/QtAutogen/ObjectLibrary/a/CMakeLists.txt +++ b/Tests/QtAutogen/ObjectLibrary/a/CMakeLists.txt @@ -1,2 +1,2 @@ add_library(a OBJECT classa.cpp) -target_compile_features(a PRIVATE ${QT_COMPILE_FEATURES}) +target_link_libraries(a PRIVATE ${QT_LIBRARIES}) diff --git a/Tests/QtAutogen/Parallel/CMakeLists.txt b/Tests/QtAutogen/Parallel/CMakeLists.txt index 299bcbf..29628eb 100644 --- a/Tests/QtAutogen/Parallel/CMakeLists.txt +++ b/Tests/QtAutogen/Parallel/CMakeLists.txt @@ -1,4 +1,4 @@ -cmake_minimum_required(VERSION 3.10) +cmake_minimum_required(VERSION 3.16) project(Parallel) include("../AutogenGuiTest.cmake") diff --git a/Tests/QtAutogen/Parallel1/CMakeLists.txt b/Tests/QtAutogen/Parallel1/CMakeLists.txt index 5c7d547..d94aba5 100644 --- a/Tests/QtAutogen/Parallel1/CMakeLists.txt +++ b/Tests/QtAutogen/Parallel1/CMakeLists.txt @@ -1,4 +1,4 @@ -cmake_minimum_required(VERSION 3.10) +cmake_minimum_required(VERSION 3.16) project(Parallel1) include("../AutogenGuiTest.cmake") diff --git a/Tests/QtAutogen/Parallel2/CMakeLists.txt b/Tests/QtAutogen/Parallel2/CMakeLists.txt index 668aea4..58667a8 100644 --- a/Tests/QtAutogen/Parallel2/CMakeLists.txt +++ b/Tests/QtAutogen/Parallel2/CMakeLists.txt @@ -1,4 +1,4 @@ -cmake_minimum_required(VERSION 3.10) +cmake_minimum_required(VERSION 3.16) project(Parallel2) include("../AutogenGuiTest.cmake") diff --git a/Tests/QtAutogen/Parallel3/CMakeLists.txt b/Tests/QtAutogen/Parallel3/CMakeLists.txt index 5c50f5e..cc3aae0 100644 --- a/Tests/QtAutogen/Parallel3/CMakeLists.txt +++ b/Tests/QtAutogen/Parallel3/CMakeLists.txt @@ -1,4 +1,4 @@ -cmake_minimum_required(VERSION 3.10) +cmake_minimum_required(VERSION 3.16) project(Parallel3) include("../AutogenGuiTest.cmake") diff --git a/Tests/QtAutogen/Parallel4/CMakeLists.txt b/Tests/QtAutogen/Parallel4/CMakeLists.txt index 2c40c6a..2b81e98 100644 --- a/Tests/QtAutogen/Parallel4/CMakeLists.txt +++ b/Tests/QtAutogen/Parallel4/CMakeLists.txt @@ -1,4 +1,4 @@ -cmake_minimum_required(VERSION 3.10) +cmake_minimum_required(VERSION 3.16) project(Parallel4) include("../AutogenGuiTest.cmake") diff --git a/Tests/QtAutogen/ParallelAUTO/CMakeLists.txt b/Tests/QtAutogen/ParallelAUTO/CMakeLists.txt index cddece3..5543b9a 100644 --- a/Tests/QtAutogen/ParallelAUTO/CMakeLists.txt +++ b/Tests/QtAutogen/ParallelAUTO/CMakeLists.txt @@ -1,4 +1,4 @@ -cmake_minimum_required(VERSION 3.10) +cmake_minimum_required(VERSION 3.16) project(ParallelAUTO) include("../AutogenGuiTest.cmake") diff --git a/Tests/QtAutogen/RccEmpty/CMakeLists.txt b/Tests/QtAutogen/RccEmpty/CMakeLists.txt index a8e2af1..c8f9d17 100644 --- a/Tests/QtAutogen/RccEmpty/CMakeLists.txt +++ b/Tests/QtAutogen/RccEmpty/CMakeLists.txt @@ -1,4 +1,4 @@ -cmake_minimum_required(VERSION 3.10) +cmake_minimum_required(VERSION 3.16) project(RccEmpty) include("../AutogenCoreTest.cmake") diff --git a/Tests/QtAutogen/RccOffMocLibrary/CMakeLists.txt b/Tests/QtAutogen/RccOffMocLibrary/CMakeLists.txt index 61b9601..b44973d 100644 --- a/Tests/QtAutogen/RccOffMocLibrary/CMakeLists.txt +++ b/Tests/QtAutogen/RccOffMocLibrary/CMakeLists.txt @@ -1,4 +1,4 @@ -cmake_minimum_required(VERSION 3.10) +cmake_minimum_required(VERSION 3.16) project(RccOffMocLibrary) include("../AutogenCoreTest.cmake") @@ -9,9 +9,7 @@ include("../AutogenCoreTest.cmake") add_library(empty STATIC empty.cpp not_generated_file.qrc) set_target_properties(empty PROPERTIES AUTORCC OFF) set_target_properties(empty PROPERTIES AUTOMOC TRUE) -target_link_libraries(empty no_link_language) +target_link_libraries(empty PRIVATE no_link_language ${QT_LIBRARIES}) add_library(no_link_language STATIC empty.h) set_target_properties(no_link_language PROPERTIES AUTOMOC TRUE) -# Pass Qt compiler features to targets that don't link against Qt -target_compile_features(no_link_language PRIVATE ${QT_COMPILE_FEATURES}) -target_compile_features(empty PRIVATE ${QT_COMPILE_FEATURES}) +target_link_libraries(no_link_language PRIVATE ${QT_LIBRARIES}) diff --git a/Tests/QtAutogen/RccOnly/CMakeLists.txt b/Tests/QtAutogen/RccOnly/CMakeLists.txt index f3776f5..f3271e0 100644 --- a/Tests/QtAutogen/RccOnly/CMakeLists.txt +++ b/Tests/QtAutogen/RccOnly/CMakeLists.txt @@ -1,4 +1,4 @@ -cmake_minimum_required(VERSION 3.10) +cmake_minimum_required(VERSION 3.16) project(RccOnly) include("../AutogenCoreTest.cmake") diff --git a/Tests/QtAutogen/RccSkipSource/CMakeLists.txt b/Tests/QtAutogen/RccSkipSource/CMakeLists.txt index 4223274..a79177f 100644 --- a/Tests/QtAutogen/RccSkipSource/CMakeLists.txt +++ b/Tests/QtAutogen/RccSkipSource/CMakeLists.txt @@ -1,4 +1,4 @@ -cmake_minimum_required(VERSION 3.10) +cmake_minimum_required(VERSION 3.16) project(RccSkipSource) include("../AutogenCoreTest.cmake") diff --git a/Tests/QtAutogen/RerunMocBasic/CMakeLists.txt b/Tests/QtAutogen/RerunMocBasic/CMakeLists.txt index c53e857..76dbdf5 100644 --- a/Tests/QtAutogen/RerunMocBasic/CMakeLists.txt +++ b/Tests/QtAutogen/RerunMocBasic/CMakeLists.txt @@ -1,4 +1,4 @@ -cmake_minimum_required(VERSION 3.10) +cmake_minimum_required(VERSION 3.16) project(RerunMocBasic) include("../AutogenCoreTest.cmake") @@ -63,6 +63,7 @@ execute_process( ${_D_CMAKE_GENERATOR_INSTANCE} "-DQT_TEST_VERSION=${QT_TEST_VERSION}" "-DCMAKE_AUTOGEN_VERBOSE=${CMAKE_AUTOGEN_VERBOSE}" + "-DCMAKE_PREFIX_PATH:STRING=${CMAKE_PREFIX_PATH}" "-DQT_QMAKE_EXECUTABLE:FILEPATH=${QT_QMAKE_EXECUTABLE}" RESULT_VARIABLE exit_code OUTPUT_VARIABLE output diff --git a/Tests/QtAutogen/RerunMocBasic/MocBasic/CMakeLists.txt b/Tests/QtAutogen/RerunMocBasic/MocBasic/CMakeLists.txt index 42f2f57..e27a824 100644 --- a/Tests/QtAutogen/RerunMocBasic/MocBasic/CMakeLists.txt +++ b/Tests/QtAutogen/RerunMocBasic/MocBasic/CMakeLists.txt @@ -1,4 +1,4 @@ -cmake_minimum_required(VERSION 3.10) +cmake_minimum_required(VERSION 3.16) project(MocBasic) include("../../AutogenCoreTest.cmake") diff --git a/Tests/QtAutogen/RerunMocOnAddFile/CMakeLists.txt b/Tests/QtAutogen/RerunMocOnAddFile/CMakeLists.txt index 2677659..3a9244d 100644 --- a/Tests/QtAutogen/RerunMocOnAddFile/CMakeLists.txt +++ b/Tests/QtAutogen/RerunMocOnAddFile/CMakeLists.txt @@ -1,6 +1,6 @@ # This test checks whether adding a source file to the project triggers an AUTOMOC re-run. -cmake_minimum_required(VERSION 3.10) +cmake_minimum_required(VERSION 3.16) project(RerunMocOnAddFile) include("../AutogenCoreTest.cmake") @@ -64,6 +64,7 @@ try_compile(MOC_RERUN MocOnAddFile CMAKE_FLAGS "-DQT_TEST_VERSION=${QT_TEST_VERSION}" "-DCMAKE_AUTOGEN_VERBOSE=${CMAKE_AUTOGEN_VERBOSE}" + "-DCMAKE_PREFIX_PATH:STRING=${CMAKE_PREFIX_PATH}" "-DQT_QMAKE_EXECUTABLE:FILEPATH=${QT_QMAKE_EXECUTABLE}" OUTPUT_VARIABLE output ) diff --git a/Tests/QtAutogen/RerunMocOnAddFile/MocOnAddFile/CMakeLists.txt.in b/Tests/QtAutogen/RerunMocOnAddFile/MocOnAddFile/CMakeLists.txt.in index 9e5e21c..e600137 100644 --- a/Tests/QtAutogen/RerunMocOnAddFile/MocOnAddFile/CMakeLists.txt.in +++ b/Tests/QtAutogen/RerunMocOnAddFile/MocOnAddFile/CMakeLists.txt.in @@ -1,4 +1,4 @@ -cmake_minimum_required(VERSION 3.10) +cmake_minimum_required(VERSION 3.16) project(MocOnAddFile) include("@CMAKE_CURRENT_LIST_DIR@/../AutogenCoreTest.cmake") diff --git a/Tests/QtAutogen/RerunMocOnMissingDependency/CMakeLists.txt b/Tests/QtAutogen/RerunMocOnMissingDependency/CMakeLists.txt index c5811eb..b17e4c5 100644 --- a/Tests/QtAutogen/RerunMocOnMissingDependency/CMakeLists.txt +++ b/Tests/QtAutogen/RerunMocOnMissingDependency/CMakeLists.txt @@ -1,6 +1,6 @@ # This test checks whether a missing dependency of the moc output triggers an AUTOMOC re-run. -cmake_minimum_required(VERSION 3.10) +cmake_minimum_required(VERSION 3.16) project(RerunMocOnMissingDependency) include("../AutogenCoreTest.cmake") @@ -13,10 +13,10 @@ add_executable(exe "${main_source}") set(testProjectTemplateDir "${CMAKE_CURRENT_SOURCE_DIR}/MocOnMissingDependency") set(testProjectSrc "${CMAKE_CURRENT_BINARY_DIR}/MocOnMissingDependency") set(testProjectBinDir "${CMAKE_CURRENT_BINARY_DIR}/MocOnMissingDependency-build") -if(DEFINED Qt5Core_VERSION AND Qt5Core_VERSION VERSION_GREATER_EQUAL "5.15.0") - set(moc_depfiles_supported TRUE) +if(DEFINED Qt${QT_TEST_VERSION}Core_VERSION AND Qt${QT_TEST_VERSION}Core_VERSION VERSION_GREATER_EQUAL "5.15.0") + set(moc_depfiles_supported TRUE) else() - set(moc_depfiles_supported FALSE) + set(moc_depfiles_supported FALSE) endif() # Utility macros @@ -48,6 +48,7 @@ try_compile(MOC_RERUN MocOnMissingDependency CMAKE_FLAGS "-DQT_TEST_VERSION=${QT_TEST_VERSION}" "-DCMAKE_AUTOGEN_VERBOSE=ON" + "-DCMAKE_PREFIX_PATH:STRING=${CMAKE_PREFIX_PATH}" "-DQT_QMAKE_EXECUTABLE:FILEPATH=${QT_QMAKE_EXECUTABLE}" OUTPUT_VARIABLE output ) diff --git a/Tests/QtAutogen/RerunMocPlugin/CMakeLists.txt b/Tests/QtAutogen/RerunMocPlugin/CMakeLists.txt index a7fb2d7..2d2edb4 100644 --- a/Tests/QtAutogen/RerunMocPlugin/CMakeLists.txt +++ b/Tests/QtAutogen/RerunMocPlugin/CMakeLists.txt @@ -1,4 +1,4 @@ -cmake_minimum_required(VERSION 3.10) +cmake_minimum_required(VERSION 3.16) project(RerunMocPlugin) include("../AutogenCoreTest.cmake") @@ -63,6 +63,7 @@ try_compile(MOC_PLUGIN MocPlugin CMAKE_FLAGS "-DQT_TEST_VERSION=${QT_TEST_VERSION}" "-DCMAKE_AUTOGEN_VERBOSE=${CMAKE_AUTOGEN_VERBOSE}" + "-DCMAKE_PREFIX_PATH:STRING=${CMAKE_PREFIX_PATH}" "-DQT_QMAKE_EXECUTABLE:FILEPATH=${QT_QMAKE_EXECUTABLE}" OUTPUT_VARIABLE output ) diff --git a/Tests/QtAutogen/RerunMocPlugin/MocPlugin/CMakeLists.txt b/Tests/QtAutogen/RerunMocPlugin/MocPlugin/CMakeLists.txt index 5068289..8097fd0 100644 --- a/Tests/QtAutogen/RerunMocPlugin/MocPlugin/CMakeLists.txt +++ b/Tests/QtAutogen/RerunMocPlugin/MocPlugin/CMakeLists.txt @@ -1,4 +1,4 @@ -cmake_minimum_required(VERSION 3.10) +cmake_minimum_required(VERSION 3.16) project(MocPlugin) include("../../AutogenGuiTest.cmake") @@ -22,7 +22,7 @@ configure_file(jsonIn/StyleE.json jsonFiles/StyleE_Custom.json) set(CMAKE_AUTOMOC TRUE) include_directories("${CMAKE_CURRENT_BINARY_DIR}/jsonFiles") -link_libraries(Qt5::Widgets) +link_libraries(Qt${QT_TEST_VERSION}::Widgets) add_library(PlugA STATIC StyleA.cpp) add_library(PlugB STATIC StyleB.cpp) diff --git a/Tests/QtAutogen/RerunRccConfigChange/CMakeLists.txt b/Tests/QtAutogen/RerunRccConfigChange/CMakeLists.txt index 33c01ac..1598bfd 100644 --- a/Tests/QtAutogen/RerunRccConfigChange/CMakeLists.txt +++ b/Tests/QtAutogen/RerunRccConfigChange/CMakeLists.txt @@ -1,4 +1,4 @@ -cmake_minimum_required(VERSION 3.11.2) +cmake_minimum_required(VERSION 3.16) project(RerunRccConfigChange) include("../AutogenCoreTest.cmake") @@ -33,6 +33,7 @@ try_compile(RCC_DEPENDS RccConfigChange CMAKE_FLAGS "-DQT_TEST_VERSION=${QT_TEST_VERSION}" "-DCMAKE_AUTOGEN_VERBOSE=${CMAKE_AUTOGEN_VERBOSE}" + "-DCMAKE_PREFIX_PATH:STRING=${CMAKE_PREFIX_PATH}" "-DQT_QMAKE_EXECUTABLE:FILEPATH=${QT_QMAKE_EXECUTABLE}" OUTPUT_VARIABLE output ) diff --git a/Tests/QtAutogen/RerunRccConfigChange/RccConfigChange/CMakeLists.txt b/Tests/QtAutogen/RerunRccConfigChange/RccConfigChange/CMakeLists.txt index e2dd0ac..83f3a45 100644 --- a/Tests/QtAutogen/RerunRccConfigChange/RccConfigChange/CMakeLists.txt +++ b/Tests/QtAutogen/RerunRccConfigChange/RccConfigChange/CMakeLists.txt @@ -1,4 +1,4 @@ -cmake_minimum_required(VERSION 3.11.2) +cmake_minimum_required(VERSION 3.16) project(RccConfigChange) include("../../AutogenCoreTest.cmake") diff --git a/Tests/QtAutogen/RerunRccDepends/CMakeLists.txt b/Tests/QtAutogen/RerunRccDepends/CMakeLists.txt index 1301550..15e38db 100644 --- a/Tests/QtAutogen/RerunRccDepends/CMakeLists.txt +++ b/Tests/QtAutogen/RerunRccDepends/CMakeLists.txt @@ -1,4 +1,4 @@ -cmake_minimum_required(VERSION 3.10) +cmake_minimum_required(VERSION 3.16) project(RerunRccDepends) include("../AutogenCoreTest.cmake") @@ -66,6 +66,7 @@ try_compile(RCC_DEPENDS RccDepends CMAKE_FLAGS "-DQT_TEST_VERSION=${QT_TEST_VERSION}" "-DCMAKE_AUTOGEN_VERBOSE=${CMAKE_AUTOGEN_VERBOSE}" + "-DCMAKE_PREFIX_PATH:STRING=${CMAKE_PREFIX_PATH}" "-DQT_QMAKE_EXECUTABLE:FILEPATH=${QT_QMAKE_EXECUTABLE}" OUTPUT_VARIABLE output ) diff --git a/Tests/QtAutogen/RerunRccDepends/RccDepends/CMakeLists.txt b/Tests/QtAutogen/RerunRccDepends/RccDepends/CMakeLists.txt index 150f849..6bba163 100644 --- a/Tests/QtAutogen/RerunRccDepends/RccDepends/CMakeLists.txt +++ b/Tests/QtAutogen/RerunRccDepends/RccDepends/CMakeLists.txt @@ -1,4 +1,4 @@ -cmake_minimum_required(VERSION 3.10) +cmake_minimum_required(VERSION 3.16) project(RccDepends) include("../../AutogenCoreTest.cmake") diff --git a/Tests/QtAutogen/RerunUicOnFileChange/CMakeLists.txt b/Tests/QtAutogen/RerunUicOnFileChange/CMakeLists.txt index 9b114e9..979e878 100644 --- a/Tests/QtAutogen/RerunUicOnFileChange/CMakeLists.txt +++ b/Tests/QtAutogen/RerunUicOnFileChange/CMakeLists.txt @@ -66,6 +66,7 @@ execute_process( "${build_type_extra}" "-DQT_TEST_VERSION=${QT_TEST_VERSION}" "-DCMAKE_AUTOGEN_VERBOSE=${CMAKE_AUTOGEN_VERBOSE}" + "-DCMAKE_PREFIX_PATH:STRING=${CMAKE_PREFIX_PATH}" "-DQT_QMAKE_EXECUTABLE:FILEPATH=${QT_QMAKE_EXECUTABLE}" RESULT_VARIABLE exit_code OUTPUT_VARIABLE output diff --git a/Tests/QtAutogen/RerunUicOnFileChange/UicOnFileChange/CMakeLists.txt.in b/Tests/QtAutogen/RerunUicOnFileChange/UicOnFileChange/CMakeLists.txt.in index c787db1..1775725 100644 --- a/Tests/QtAutogen/RerunUicOnFileChange/UicOnFileChange/CMakeLists.txt.in +++ b/Tests/QtAutogen/RerunUicOnFileChange/UicOnFileChange/CMakeLists.txt.in @@ -1,4 +1,4 @@ -cmake_minimum_required(VERSION 3.10) +cmake_minimum_required(VERSION 3.16) project(UicOnFileChange) include("@CMAKE_CURRENT_LIST_DIR@/../AutogenGuiTest.cmake") diff --git a/Tests/QtAutogen/StaticLibraryCycle/CMakeLists.txt b/Tests/QtAutogen/StaticLibraryCycle/CMakeLists.txt index f3536ba..25ea822 100644 --- a/Tests/QtAutogen/StaticLibraryCycle/CMakeLists.txt +++ b/Tests/QtAutogen/StaticLibraryCycle/CMakeLists.txt @@ -1,4 +1,4 @@ -cmake_minimum_required(VERSION 3.10) +cmake_minimum_required(VERSION 3.16) project(StaticLibraryCycle) include("../AutogenCoreTest.cmake") diff --git a/Tests/QtAutogen/TestMacros.cmake b/Tests/QtAutogen/TestMacros.cmake index 9dcf31f..529592e 100644 --- a/Tests/QtAutogen/TestMacros.cmake +++ b/Tests/QtAutogen/TestMacros.cmake @@ -7,8 +7,17 @@ else() endif() list(APPEND Autogen_BUILD_OPTIONS "-DCMAKE_AUTOGEN_VERBOSE=1" - "-DQT_QMAKE_EXECUTABLE:FILEPATH=${QT_QMAKE_EXECUTABLE}" ) +if(Qt${QT_TEST_VERSION}Core_DIR) + get_filename_component(prefix "${Qt${QT_TEST_VERSION}Core_DIR}" DIRECTORY) + get_filename_component(prefix "${prefix}" DIRECTORY) + get_filename_component(prefix "${prefix}" DIRECTORY) + list(APPEND Autogen_BUILD_OPTIONS "-DCMAKE_PREFIX_PATH:STRING=${prefix}") +else() + list(APPEND Autogen_BUILD_OPTIONS + "-DQT_QMAKE_EXECUTABLE:FILEPATH=${QT_QMAKE_EXECUTABLE}" + ) +endif() # XXX(xcode-per-cfg-src): Drop the NO_PER_CONFIG_SOURCES exclusion # when the Xcode generator supports per-config sources. if(CMAKE_GENERATOR STREQUAL "Xcode") diff --git a/Tests/QtAutogen/UicInclude/CMakeLists.txt b/Tests/QtAutogen/UicInclude/CMakeLists.txt index 929868b..042d18f 100644 --- a/Tests/QtAutogen/UicInclude/CMakeLists.txt +++ b/Tests/QtAutogen/UicInclude/CMakeLists.txt @@ -1,4 +1,4 @@ -cmake_minimum_required(VERSION 3.10) +cmake_minimum_required(VERSION 3.16) project(UicInclude) include("../AutogenGuiTest.cmake") diff --git a/Tests/QtAutogen/UicInterface/CMakeLists.txt b/Tests/QtAutogen/UicInterface/CMakeLists.txt index e022764..167ae49 100644 --- a/Tests/QtAutogen/UicInterface/CMakeLists.txt +++ b/Tests/QtAutogen/UicInterface/CMakeLists.txt @@ -1,4 +1,4 @@ -cmake_minimum_required(VERSION 3.10) +cmake_minimum_required(VERSION 3.16) project(UicInterface) include("../AutogenGuiTest.cmake") @@ -11,12 +11,12 @@ set(CMAKE_AUTOUIC ON) set(CMAKE_VERBOSE_MAKEFILE ON) add_library(KI18n klocalizedstring.cpp) -target_link_libraries(KI18n ${QT_QTCORE_TARGET}) +target_link_libraries(KI18n PRIVATE ${QT_QTCORE_TARGET}) set(autouic_options -tr tr2$<$<NOT:$<BOOL:$<TARGET_PROPERTY:NO_KUIT_SEMANTIC>>>:x>i18n ) -if (NOT Qt5Widgets_VERSION VERSION_LESS 5.3.0) +if (NOT Qt${QT_TEST_VERSION}Widgets_VERSION VERSION_LESS 5.3.0) list(APPEND autouic_options -include klocalizedstring.h) endif() diff --git a/Tests/QtAutogen/UicNoGui/CMakeLists.txt b/Tests/QtAutogen/UicNoGui/CMakeLists.txt index 076299d..b938a17 100644 --- a/Tests/QtAutogen/UicNoGui/CMakeLists.txt +++ b/Tests/QtAutogen/UicNoGui/CMakeLists.txt @@ -1,4 +1,4 @@ -cmake_minimum_required(VERSION 3.13) +cmake_minimum_required(VERSION 3.16) project(UicNoGui) include("../AutogenCoreTest.cmake") diff --git a/Tests/QtAutogen/UicOnly/CMakeLists.txt b/Tests/QtAutogen/UicOnly/CMakeLists.txt index b163254..e25b44d 100644 --- a/Tests/QtAutogen/UicOnly/CMakeLists.txt +++ b/Tests/QtAutogen/UicOnly/CMakeLists.txt @@ -1,4 +1,4 @@ -cmake_minimum_required(VERSION 3.10) +cmake_minimum_required(VERSION 3.16) project(UicOnly) include("../AutogenGuiTest.cmake") diff --git a/Tests/QtAutogen/UicSkipSource/CMakeLists.txt b/Tests/QtAutogen/UicSkipSource/CMakeLists.txt index dc3b7d4e..15dfe65 100644 --- a/Tests/QtAutogen/UicSkipSource/CMakeLists.txt +++ b/Tests/QtAutogen/UicSkipSource/CMakeLists.txt @@ -1,4 +1,4 @@ -cmake_minimum_required(VERSION 3.10) +cmake_minimum_required(VERSION 3.16) project(UicSkipSource) include("../AutogenGuiTest.cmake") diff --git a/Tests/RunCMake/Autogen/CMP0111-imported-target-prelude.cmake b/Tests/RunCMake/Autogen/CMP0111-imported-target-prelude.cmake index 8fa6041..6d26f99 100644 --- a/Tests/RunCMake/Autogen/CMP0111-imported-target-prelude.cmake +++ b/Tests/RunCMake/Autogen/CMP0111-imported-target-prelude.cmake @@ -1,6 +1,6 @@ enable_language(CXX) -find_package(Qt5 REQUIRED COMPONENTS Core) +find_package(Qt${with_qt_version} REQUIRED COMPONENTS Core) # Detect `-NOTFOUND` libraries at generate time. cmake_policy(SET CMP0111 NEW) diff --git a/Tests/RunCMake/Autogen/CMakeLists.txt b/Tests/RunCMake/Autogen/CMakeLists.txt index 9a66cde..2632ffa 100644 --- a/Tests/RunCMake/Autogen/CMakeLists.txt +++ b/Tests/RunCMake/Autogen/CMakeLists.txt @@ -1,3 +1,3 @@ -cmake_minimum_required(VERSION 3.13) +cmake_minimum_required(VERSION 3.16) project(${RunCMake_TEST} NONE) include(${RunCMake_TEST}.cmake) diff --git a/Tests/RunCMake/Autogen/QtInFunction.cmake b/Tests/RunCMake/Autogen/QtInFunction.cmake index a44bc5a..6c42cc2 100644 --- a/Tests/RunCMake/Autogen/QtInFunction.cmake +++ b/Tests/RunCMake/Autogen/QtInFunction.cmake @@ -1,9 +1,9 @@ enable_language(CXX) function (use_autogen target) - find_package(Qt5 REQUIRED COMPONENTS Core Widgets) - set(Qt5Core_VERSION_MAJOR "${Qt5Core_VERSION_MAJOR}" PARENT_SCOPE) - set(Qt5Core_VERSION_MINOR "${Qt5Core_VERSION_MINOR}" PARENT_SCOPE) + find_package(Qt${with_qt_version} REQUIRED COMPONENTS Core Widgets) + set(Qt${with_qt_version}Core_VERSION_MAJOR "${Qt${with_qt_version}Core_VERSION_MAJOR}" PARENT_SCOPE) + set(Qt${with_qt_version}Core_VERSION_MINOR "${Qt${with_qt_version}Core_VERSION_MINOR}" PARENT_SCOPE) set_property(TARGET "${target}" PROPERTY AUTOMOC 1) set_property(TARGET "${target}" PROPERTY AUTORCC 1) set_property(TARGET "${target}" PROPERTY AUTOUIC 1) diff --git a/Tests/RunCMake/Autogen/QtInFunctionNested.cmake b/Tests/RunCMake/Autogen/QtInFunctionNested.cmake index 5421ba0..2e7b8ad 100644 --- a/Tests/RunCMake/Autogen/QtInFunctionNested.cmake +++ b/Tests/RunCMake/Autogen/QtInFunctionNested.cmake @@ -1,9 +1,9 @@ enable_language(CXX) function (use_autogen target) - find_package(Qt5 REQUIRED COMPONENTS Core Widgets) - set(Qt5Core_VERSION_MAJOR "${Qt5Core_VERSION_MAJOR}" PARENT_SCOPE) - set(Qt5Core_VERSION_MINOR "${Qt5Core_VERSION_MINOR}" PARENT_SCOPE) + find_package(Qt${with_qt_version} REQUIRED COMPONENTS Core Widgets) + set(Qt${with_qt_version}Core_VERSION_MAJOR "${Qt${with_qt_version}Core_VERSION_MAJOR}" PARENT_SCOPE) + set(Qt${with_qt_version}Core_VERSION_MINOR "${Qt${with_qt_version}Core_VERSION_MINOR}" PARENT_SCOPE) set_property(TARGET "${target}" PROPERTY AUTOMOC 1) set_property(TARGET "${target}" PROPERTY AUTORCC 1) set_property(TARGET "${target}" PROPERTY AUTOUIC 1) diff --git a/Tests/RunCMake/Autogen/QtInFunctionProperty.cmake b/Tests/RunCMake/Autogen/QtInFunctionProperty.cmake index 35f1cd1..d9296c4 100644 --- a/Tests/RunCMake/Autogen/QtInFunctionProperty.cmake +++ b/Tests/RunCMake/Autogen/QtInFunctionProperty.cmake @@ -1,13 +1,13 @@ enable_language(CXX) function (use_autogen target) - find_package(Qt5 REQUIRED COMPONENTS Core Widgets) + find_package(Qt${with_qt_version} REQUIRED COMPONENTS Core Widgets) set_property(DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}" PROPERTY - Qt5Core_VERSION_MAJOR "${Qt5Core_VERSION_MAJOR}") + Qt${with_qt_version}Core_VERSION_MAJOR "${Qt${with_qt_version}Core_VERSION_MAJOR}") set_property(DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}" PROPERTY - Qt5Core_VERSION_MINOR "${Qt5Core_VERSION_MINOR}") + Qt${with_qt_version}Core_VERSION_MINOR "${Qt${with_qt_version}Core_VERSION_MINOR}") set_property(TARGET "${target}" PROPERTY AUTOMOC 1) set_property(TARGET "${target}" PROPERTY AUTORCC 1) set_property(TARGET "${target}" PROPERTY AUTOUIC 1) diff --git a/Tests/RunCMake/Autogen/RunCMakeTest.cmake b/Tests/RunCMake/Autogen/RunCMakeTest.cmake index bbcbd5e..e4c5811 100644 --- a/Tests/RunCMake/Autogen/RunCMakeTest.cmake +++ b/Tests/RunCMake/Autogen/RunCMakeTest.cmake @@ -1,7 +1,13 @@ include(RunCMake) run_cmake(NoQt) -if (with_qt5) +if (DEFINED with_qt_version) + set(RunCMake_TEST_OPTIONS + -Dwith_qt_version=${with_qt_version} + "-DQt${with_qt_version}_DIR:PATH=${Qt${with_qt_version}_DIR}" + "-DCMAKE_PREFIX_PATH:STRING=${CMAKE_PREFIX_PATH}" + ) + run_cmake(QtInFunction) run_cmake(QtInFunctionNested) run_cmake(QtInFunctionProperty) diff --git a/Tests/RunCMake/CMakeLists.txt b/Tests/RunCMake/CMakeLists.txt index eb2c2d9..b7d38fb 100644 --- a/Tests/RunCMake/CMakeLists.txt +++ b/Tests/RunCMake/CMakeLists.txt @@ -151,8 +151,23 @@ endif() if(CMAKE_GENERATOR MATCHES "Make") add_RunCMake_test(Make -DMAKE_IS_GNU=${MAKE_IS_GNU}) endif() -if(CMake_TEST_Qt5) +unset(ninja_test_with_qt_version) +unset(ninja_qt_args) +if(CMake_TEST_Qt6) + find_package(Qt6Widgets QUIET NO_MODULE) + if(Qt6Widgets_FOUND) + set(ninja_test_with_qt_version 6) + # Work around Qt6 not finding sibling dependencies without CMAKE_PREFIX_PATH + cmake_path(GET Qt6_DIR PARENT_PATH base_dir) # <base>/lib/cmake + cmake_path(GET base_dir PARENT_PATH base_dir) # <base>/lib + cmake_path(GET base_dir PARENT_PATH base_dir) # <base> + set(ninja_qt_args -DCMAKE_PREFIX_PATH=${base_dir}) + endif() +elseif(CMake_TEST_Qt5) find_package(Qt5Widgets QUIET NO_MODULE) + if(Qt5Widgets_FOUND) + set(ninja_test_with_qt_version 5) + endif() endif() if(CMAKE_GENERATOR MATCHES "Ninja") set(Ninja_ARGS @@ -162,18 +177,27 @@ if(CMAKE_GENERATOR MATCHES "Ninja") if(CMAKE_Fortran_COMPILER) list(APPEND Ninja_ARGS -DTEST_Fortran=1) endif() - if(CMake_TEST_Qt5 AND Qt5Core_FOUND) - list(APPEND Ninja_ARGS -DCMake_TEST_Qt5=1 -DQt5Core_DIR=${Qt5Core_DIR} -DCMAKE_TEST_Qt5Core_Version=${Qt5Core_VERSION}) - if(Qt5Widgets_FOUND) - list(APPEND Ninja_ARGS -DQt5Widgets_DIR=${Qt5Widgets_DIR}) - endif() + if(ninja_test_with_qt_version) + list(APPEND Ninja_ARGS + -DCMake_TEST_Qt_version=${ninja_test_with_qt_version} + -DQt${ninja_test_with_qt_version}_DIR=${Qt${ninja_test_with_qt_version}_DIR} + -DQt${ninja_test_with_qt_version}Core_DIR=${Qt${ninja_test_with_qt_version}Core_DIR} + -DCMake_TEST_Qt${ninja_test_with_qt_version}Core_Version=${Qt${ninja_test_with_qt_version}Core_VERSION} + -DQt${ninja_test_with_qt_version}Widgets_DIR=${Qt${ninja_test_with_qt_version}Widgets_DIR} + ${ninja_qt_args} + ) endif() add_RunCMake_test(Ninja) set(NinjaMultiConfig_ARGS -DCYGWIN=${CYGWIN} -DMSYS=${MSYS} ) - if(CMake_TEST_Qt5 AND Qt5Core_FOUND) - list(APPEND NinjaMultiConfig_ARGS -DCMake_TEST_Qt5=1 -DQt5Core_DIR=${Qt5Core_DIR} -DCMAKE_TEST_Qt5Core_Version=${Qt5Core_VERSION}) + if(ninja_test_with_qt_version) + list(APPEND NinjaMultiConfig_ARGS + -DCMake_TEST_Qt_version=${ninja_test_with_qt_version} + -DQt${ninja_test_with_qt_version}Core_DIR=${Qt${ninja_test_with_qt_version}Core_DIR} + -DCMake_TEST_Qt${ninja_test_with_qt_version}Core_Version=${Qt${ninja_test_with_qt_version}Core_VERSION} + ${ninja_qt_args} + ) endif() if(DEFINED CMake_TEST_CUDA) list(APPEND NinjaMultiConfig_ARGS -DCMake_TEST_CUDA=${CMake_TEST_CUDA}) @@ -205,11 +229,29 @@ add_RunCMake_test(AndroidTestUtilities) if(CMake_TEST_APPLE_SILICON) add_RunCMake_test(AppleSilicon) endif() -set(autogen_with_qt5 FALSE) +set(want_NoQt_test TRUE) +if(CMake_TEST_Qt6 AND Qt6Widgets_FOUND) + # Work around Qt6 not finding sibling dependencies without CMAKE_PREFIX_PATH + cmake_path(GET Qt6_DIR PARENT_PATH base_dir) # <base>/lib/cmake + cmake_path(GET base_dir PARENT_PATH base_dir) # <base>/lib + cmake_path(GET base_dir PARENT_PATH base_dir) # <base> + add_RunCMake_test(AutogenQt6 TEST_DIR Autogen + -Dwith_qt_version=6 + "-DQt6_DIR:PATH=${Qt6_DIR}" + "-DCMAKE_PREFIX_PATH:STRING=${base_dir}" + ) + set(want_NoQt_test FALSE) +endif () if(CMake_TEST_Qt5 AND Qt5Widgets_FOUND) - set(autogen_with_qt5 TRUE) + add_RunCMake_test(AutogenQt5 TEST_DIR Autogen + -Dwith_qt_version=5 + "-DQt5_DIR:PATH=${Qt5_DIR}" + ) + set(want_NoQt_test FALSE) endif () -add_RunCMake_test(Autogen -Dwith_qt5=${autogen_with_qt5}) +if(want_NoQt_test) + add_RunCMake_test(AutogenNoQt TEST_DIR Autogen) +endif() add_RunCMake_test(ArtifactOutputDirs) @@ -310,7 +352,7 @@ add_RunCMake_test(TargetProperties) add_RunCMake_test(ToolchainFile) add_RunCMake_test(find_dependency) add_RunCMake_test(CompileDefinitions) -add_RunCMake_test(CompileFeatures) +add_RunCMake_test(CompileFeatures -DCMake_NO_C_STANDARD=${CMake_NO_C_STANDARD} -DCMake_NO_CXX_STANDARD=${CMake_NO_CXX_STANDARD}) add_RunCMake_test(Policy) add_RunCMake_test(PolicyScope) add_RunCMake_test(WriteBasicConfigVersionFile) diff --git a/Tests/RunCMake/CompileFeatures/CMP0128WarnMatch-stderr.txt b/Tests/RunCMake/CompileFeatures/CMP0128WarnMatch-stderr.txt new file mode 100644 index 0000000..320c2ba --- /dev/null +++ b/Tests/RunCMake/CompileFeatures/CMP0128WarnMatch-stderr.txt @@ -0,0 +1,8 @@ +CMake Warning \(dev\) in CMakeLists\.txt: + Policy CMP0128 is not set: Selection of language standard and extension + flags improved\. Run "cmake --help-policy CMP0128" for policy details\. Use + the cmake_policy command to set the policy and suppress this warning\. + + For compatibility with older versions of CMake, unnecessary flags for + language standard or compiler extensions may be added. +This warning is for project developers\. Use -Wno-dev to suppress it\. diff --git a/Tests/RunCMake/CompileFeatures/CMP0128WarnMatch.cmake b/Tests/RunCMake/CompileFeatures/CMP0128WarnMatch.cmake new file mode 100644 index 0000000..0a5606a --- /dev/null +++ b/Tests/RunCMake/CompileFeatures/CMP0128WarnMatch.cmake @@ -0,0 +1,7 @@ +enable_language(@lang@) +cmake_policy(SET CMP0128 OLD) +set(CMAKE_POLICY_WARNING_CMP0128 ON) + +set(CMAKE_@lang@_EXTENSIONS @extensions_default@) +set(CMAKE_@lang@_STANDARD @standard_default@) +add_library(foo "@RunCMake_SOURCE_DIR@/empty.@ext@") diff --git a/Tests/RunCMake/CompileFeatures/CMP0128WarnUnset-stderr.txt b/Tests/RunCMake/CompileFeatures/CMP0128WarnUnset-stderr.txt new file mode 100644 index 0000000..068cba9 --- /dev/null +++ b/Tests/RunCMake/CompileFeatures/CMP0128WarnUnset-stderr.txt @@ -0,0 +1,8 @@ +CMake Warning \(dev\) in CMakeLists\.txt: + Policy CMP0128 is not set: Selection of language standard and extension + flags improved\. Run "cmake --help-policy CMP0128" for policy details\. Use + the cmake_policy command to set the policy and suppress this warning\. + + For compatibility with older versions of CMake, compiler extensions won't + be @opposite@\. +This warning is for project developers\. Use -Wno-dev to suppress it\. diff --git a/Tests/RunCMake/CompileFeatures/CMP0128WarnUnset.cmake b/Tests/RunCMake/CompileFeatures/CMP0128WarnUnset.cmake new file mode 100644 index 0000000..cd7af2c --- /dev/null +++ b/Tests/RunCMake/CompileFeatures/CMP0128WarnUnset.cmake @@ -0,0 +1,6 @@ +enable_language(@lang@) +cmake_policy(SET CMP0128 OLD) +set(CMAKE_POLICY_WARNING_CMP0128 ON) + +set(CMAKE_@lang@_EXTENSIONS @extensions_opposite@) +add_library(foo "@RunCMake_SOURCE_DIR@/empty.@ext@") diff --git a/Tests/RunCMake/CompileFeatures/NoUnnecessaryFlag-build-check.cmake b/Tests/RunCMake/CompileFeatures/NoUnnecessaryFlag-build-check.cmake new file mode 100644 index 0000000..4f767fa --- /dev/null +++ b/Tests/RunCMake/CompileFeatures/NoUnnecessaryFlag-build-check.cmake @@ -0,0 +1,8 @@ +foreach(flag @flags@) + string(FIND "${actual_stdout}" "${flag}" position) + + if(NOT position EQUAL -1) + set(RunCMake_TEST_FAILED "\"${flag}\" compile flag found.") + break() + endif() +endforeach() diff --git a/Tests/RunCMake/CompileFeatures/NoUnnecessaryFlag.cmake b/Tests/RunCMake/CompileFeatures/NoUnnecessaryFlag.cmake new file mode 100644 index 0000000..8ef3a72 --- /dev/null +++ b/Tests/RunCMake/CompileFeatures/NoUnnecessaryFlag.cmake @@ -0,0 +1,9 @@ +enable_language(@lang@) + +# Make sure the compile command is not hidden. +string(REPLACE "${CMAKE_START_TEMP_FILE}" "" CMAKE_@lang@_COMPILE_OBJECT "${CMAKE_@lang@_COMPILE_OBJECT}") +string(REPLACE "${CMAKE_END_TEMP_FILE}" "" CMAKE_@lang@_COMPILE_OBJECT "${CMAKE_@lang@_COMPILE_OBJECT}") + +set(CMAKE_@lang@_EXTENSIONS @extensions_default@) +set(CMAKE_@lang@_STANDARD @standard_default@) +add_library(foo "@RunCMake_SOURCE_DIR@/empty.@ext@") diff --git a/Tests/RunCMake/CompileFeatures/RunCMakeTest.cmake b/Tests/RunCMake/CompileFeatures/RunCMakeTest.cmake index 5a70da2..3bfd211 100644 --- a/Tests/RunCMake/CompileFeatures/RunCMakeTest.cmake +++ b/Tests/RunCMake/CompileFeatures/RunCMakeTest.cmake @@ -9,17 +9,8 @@ run_cmake(NotAFeature_OriginDebugGenex) run_cmake(NotAFeature_OriginDebugTransitive) run_cmake(NotAFeature_OriginDebugCommand) -run_cmake(generate_feature_list) -file(READ - "${RunCMake_BINARY_DIR}/generate_feature_list-build/c_features.txt" - C_FEATURES -) -file(READ - "${RunCMake_BINARY_DIR}/generate_feature_list-build/cxx_features.txt" - CXX_FEATURES -) -include("${RunCMake_BINARY_DIR}/generate_feature_list-build/c_standard_default.cmake") -include("${RunCMake_BINARY_DIR}/generate_feature_list-build/cxx_standard_default.cmake") +run_cmake(compiler_introspection) +include("${RunCMake_BINARY_DIR}/compiler_introspection-build/info.cmake") if (NOT C_FEATURES) run_cmake(NoSupportedCFeatures) @@ -43,21 +34,133 @@ elseif (cxx_std_98 IN_LIST CXX_FEATURES AND cxx_std_11 IN_LIST CXX_FEATURES) unset(RunCMake_TEST_OPTIONS) endif() +configure_file("${RunCMake_SOURCE_DIR}/CMakeLists.txt" "${RunCMake_BINARY_DIR}/CMakeLists.txt" COPYONLY) + +macro(test_build) + set(test ${name}-${lang}) + + configure_file("${RunCMake_SOURCE_DIR}/${name}.cmake" "${RunCMake_BINARY_DIR}/${test}.cmake" @ONLY) + if(EXISTS "${RunCMake_SOURCE_DIR}/${name}-build-check.cmake") + configure_file("${RunCMake_SOURCE_DIR}/${name}-build-check.cmake" "${RunCMake_BINARY_DIR}/${test}-build-check.cmake" @ONLY) + endif() + if(EXISTS "${RunCMake_SOURCE_DIR}/${name}-stderr.txt") + configure_file("${RunCMake_SOURCE_DIR}/${name}-stderr.txt" "${RunCMake_BINARY_DIR}/${test}-stderr.txt" @ONLY) + endif() + + set(RunCMake_SOURCE_DIR "${RunCMake_BINARY_DIR}") + set(RunCMake_TEST_BINARY_DIR "${RunCMake_BINARY_DIR}/${test}-build") + run_cmake(${test}) + set(RunCMake_TEST_NO_CLEAN 1) + run_cmake_command(${test}-build ${CMAKE_COMMAND} --build . ${ARGN}) +endmacro() + +# Mangle flags such as they're in verbose build output. +macro(mangle_flags variable) + set(result "${${variable}}") + + if(RunCMake_GENERATOR MATCHES "Visual Studio" AND MSVC_TOOLSET_VERSION GREATER_EQUAL 141) + string(REPLACE "-" "/" result "${result}") + elseif(RunCMake_GENERATOR STREQUAL "Xcode" AND CMAKE_XCODE_BUILD_SYSTEM GREATER_EQUAL 12) + string(REPLACE "=" [[\\=]] result "${result}") + endif() + + string(REPLACE ";" " " result "${result}") + list(APPEND flags "${result}") +endmacro() + +function(test_unset_standard) + if(extensions_opposite) + set(flag_ext "_EXT") + endif() + + set(flag "${${lang}${${lang}_STANDARD_DEFAULT}${flag_ext}_FLAG}") + + if(NOT flag) + return() + endif() + + mangle_flags(flag) + + set(name UnsetStandard) + set(RunCMake_TEST_OPTIONS -DCMAKE_POLICY_DEFAULT_CMP0128=NEW) + test_build(--verbose) +endfunction() + +function(test_no_unnecessary_flag) + set(standard_flag "${${lang}${${lang}_STANDARD_DEFAULT}_FLAG}") + set(extension_flag "${${lang}${${lang}_STANDARD_DEFAULT}_EXT_FLAG}") + + if(NOT standard_flag AND NOT extension_flag) + return() + endif() + + mangle_flags(standard_flag) + mangle_flags(extension_flag) + + set(name NoUnnecessaryFlag) + set(RunCMake_TEST_OPTIONS -DCMAKE_POLICY_DEFAULT_CMP0128=NEW) + test_build(--verbose) +endfunction() + +function(test_cmp0128_warn_match) + set(name CMP0128WarnMatch) + test_build() +endfunction() + +function(test_cmp0128_warn_unset) + # For compilers that had CMAKE_<LANG>_EXTENSION_COMPILE_OPTION (only IAR) + # there is no behavioural change and thus no warning. + if(NOT "${${lang}_EXT_FLAG}" STREQUAL "") + return() + endif() + + if(extensions_opposite) + set(opposite "enabled") + else() + set(opposite "disabled") + endif() + + set(name CMP0128WarnUnset) + test_build() +endfunction() + +function(test_lang lang ext) + if(CMake_NO_${lang}_STANDARD) + return() + endif() + + set(extensions_default "${${lang}_EXTENSIONS_DEFAULT}") + set(standard_default "${${lang}_STANDARD_DEFAULT}") + + if(extensions_default) + set(extensions_opposite OFF) + else() + set(extensions_opposite ON) + endif() + + test_unset_standard() + test_no_unnecessary_flag() + test_cmp0128_warn_match() + test_cmp0128_warn_unset() +endfunction() + +if(C_STANDARD_DEFAULT) + test_lang(C c) +endif() + if(CXX_STANDARD_DEFAULT) run_cmake(NotAStandard) foreach(standard 98 11) - file(READ - "${RunCMake_BINARY_DIR}/generate_feature_list-build/cxx${standard}_flag.txt" - CXX${standard}_FLAG - ) if (CXX${standard}_FLAG STREQUAL NOTFOUND) run_cmake(RequireCXX${standard}) run_cmake(RequireCXX${standard}Variable) endif() - if (CXX${standard}EXT_FLAG STREQUAL NOTFOUND) + if (CXX${standard}_EXT_FLAG STREQUAL NOTFOUND) run_cmake(RequireCXX${standard}Ext) run_cmake(RequireCXX${standard}ExtVariable) endif() endforeach() + + test_lang(CXX cpp) endif() diff --git a/Tests/RunCMake/CompileFeatures/UnsetStandard-build-check.cmake b/Tests/RunCMake/CompileFeatures/UnsetStandard-build-check.cmake new file mode 100644 index 0000000..abe293c --- /dev/null +++ b/Tests/RunCMake/CompileFeatures/UnsetStandard-build-check.cmake @@ -0,0 +1,12 @@ +foreach(flag @flags@) + string(FIND "${actual_stdout}" "${flag}" position) + + if(NOT position EQUAL -1) + set(found TRUE) + break() + endif() +endforeach() + +if(NOT found) + set(RunCMake_TEST_FAILED "No compile flags from \"@flags@\" found for CMAKE_@lang@_EXTENSIONS=@extensions_opposite@.") +endif() diff --git a/Tests/RunCMake/CompileFeatures/UnsetStandard.cmake b/Tests/RunCMake/CompileFeatures/UnsetStandard.cmake new file mode 100644 index 0000000..99bb3f0 --- /dev/null +++ b/Tests/RunCMake/CompileFeatures/UnsetStandard.cmake @@ -0,0 +1,8 @@ +enable_language(@lang@) + +# Make sure the compile command is not hidden. +string(REPLACE "${CMAKE_START_TEMP_FILE}" "" CMAKE_@lang@_COMPILE_OBJECT "${CMAKE_@lang@_COMPILE_OBJECT}") +string(REPLACE "${CMAKE_END_TEMP_FILE}" "" CMAKE_@lang@_COMPILE_OBJECT "${CMAKE_@lang@_COMPILE_OBJECT}") + +set(CMAKE_@lang@_EXTENSIONS @extensions_opposite@) +add_library(foo "@RunCMake_SOURCE_DIR@/empty.@ext@") diff --git a/Tests/RunCMake/CompileFeatures/compiler_introspection.cmake b/Tests/RunCMake/CompileFeatures/compiler_introspection.cmake new file mode 100644 index 0000000..5691344 --- /dev/null +++ b/Tests/RunCMake/CompileFeatures/compiler_introspection.cmake @@ -0,0 +1,38 @@ +enable_language(C CXX) + +set(info "") + +if(MSVC_TOOLSET_VERSION) + string(APPEND info " +set(MSVC_TOOLSET_VERSION ${MSVC_TOOLSET_VERSION}) + +") +endif() + +if(CMAKE_XCODE_BUILD_SYSTEM) + string(APPEND info " +set(CMAKE_XCODE_BUILD_SYSTEM ${CMAKE_XCODE_BUILD_SYSTEM}) + +") +endif() + +macro(info lang) + string(APPEND info "\ +set(${lang}_STANDARD_DEFAULT ${CMAKE_${lang}_STANDARD_DEFAULT}) +set(${lang}_EXTENSIONS_DEFAULT ${CMAKE_${lang}_EXTENSIONS_DEFAULT}) +set(${lang}_FEATURES ${CMAKE_${lang}_COMPILE_FEATURES}) + +set(${lang}_EXT_FLAG ${CMAKE_${lang}_EXTENSION_COMPILE_OPTION}) +") + + foreach(standard ${ARGN}) + string(APPEND info "\ +set(${lang}${standard}_FLAG ${CMAKE_${lang}${standard}_STANDARD_COMPILE_OPTION}) +set(${lang}${standard}_EXT_FLAG ${CMAKE_${lang}${standard}_EXTENSION_COMPILE_OPTION}) +") + endforeach() +endmacro() + +info(C 90 99 11 17 23) +info(CXX 98 11 14 17 20 23) +file(WRITE "${CMAKE_CURRENT_BINARY_DIR}/info.cmake" "${info}") diff --git a/Tests/RunCMake/CompileFeatures/empty.c b/Tests/RunCMake/CompileFeatures/empty.c index 11ec041..8d91e77 100644 --- a/Tests/RunCMake/CompileFeatures/empty.c +++ b/Tests/RunCMake/CompileFeatures/empty.c @@ -1,7 +1,7 @@ #ifdef _WIN32 __declspec(dllexport) #endif - int empty() + int empty(void) { return 0; } diff --git a/Tests/RunCMake/CompileFeatures/generate_feature_list.cmake b/Tests/RunCMake/CompileFeatures/generate_feature_list.cmake deleted file mode 100644 index 5c58052..0000000 --- a/Tests/RunCMake/CompileFeatures/generate_feature_list.cmake +++ /dev/null @@ -1,43 +0,0 @@ - -enable_language(C) - -file(WRITE "${CMAKE_CURRENT_BINARY_DIR}/c_features.txt" - "${CMAKE_C_COMPILE_FEATURES}" -) - -file(WRITE "${CMAKE_CURRENT_BINARY_DIR}/cxx_features.txt" - "${CMAKE_CXX_COMPILE_FEATURES}" -) - -if(DEFINED CMAKE_C_STANDARD_DEFAULT) - set(c_standard_default_code "set(C_STANDARD_DEFAULT \"${CMAKE_C_STANDARD_DEFAULT}\")\n") -else() - set(c_standard_default_code "unset(C_STANDARD_DEFAULT)\n") -endif() -file(WRITE "${CMAKE_CURRENT_BINARY_DIR}/c_standard_default.cmake" "${c_standard_default_code}") - -if(DEFINED CMAKE_CXX_STANDARD_DEFAULT) - set(cxx_standard_default_code "set(CXX_STANDARD_DEFAULT \"${CMAKE_CXX_STANDARD_DEFAULT}\")\n") -else() - set(cxx_standard_default_code "unset(CXX_STANDARD_DEFAULT)\n") -endif() -file(WRITE "${CMAKE_CURRENT_BINARY_DIR}/cxx_standard_default.cmake" "${cxx_standard_default_code}") - -foreach(standard 98 11) - set(CXX${standard}_FLAG NOTFOUND) - if (DEFINED CMAKE_CXX${standard}_STANDARD_COMPILE_OPTION) - set(CXX${standard}_FLAG ${CMAKE_CXX${standard}_STANDARD_COMPILE_OPTION}) - endif() - - file(WRITE "${CMAKE_CURRENT_BINARY_DIR}/cxx${standard}_flag.txt" - "${CXX${standard}_FLAG}" - ) - set(CXX${standard}EXT_FLAG NOTFOUND) - if (DEFINED CMAKE_CXX${standard}_EXTENSION_COMPILE_OPTION) - set(CXX${standard}EXT_FLAG ${CMAKE_CXX${standard}_EXTENSION_COMPILE_OPTION}) - endif() - - file(WRITE "${CMAKE_CURRENT_BINARY_DIR}/cxx${standard}ext_flag.txt" - "${CXX${standard}EXT_FLAG}" - ) -endforeach() diff --git a/Tests/RunCMake/Ninja/Qt5AutoMocDeps.cmake b/Tests/RunCMake/Ninja/Qt5AutoMocDeps.cmake deleted file mode 100644 index 46b840f..0000000 --- a/Tests/RunCMake/Ninja/Qt5AutoMocDeps.cmake +++ /dev/null @@ -1,21 +0,0 @@ -enable_language(CXX) - -find_package(Qt5Core REQUIRED) - -set(CMAKE_AUTOMOC ON) - -add_library(simple_lib SHARED simple_lib.cpp) -add_executable(app_with_qt app.cpp app_qt.cpp) -target_link_libraries(app_with_qt PRIVATE simple_lib Qt5::Core) - -if(Qt5Widgets_DIR) - find_package(Qt5Widgets REQUIRED) - qt5_wrap_ui(_headers MyWindow.ui) - add_executable(app_with_widget app.cpp MyWindow.cpp ${_headers}) - target_link_libraries(app_with_widget PRIVATE Qt5::Widgets) - target_include_directories(app_with_widget PRIVATE "${CMAKE_BINARY_DIR}") -endif() - -add_subdirectory(QtSubDir1) -add_subdirectory(QtSubDir2) -add_subdirectory(QtSubDir3) diff --git a/Tests/RunCMake/Ninja/QtAutoMocDeps.cmake b/Tests/RunCMake/Ninja/QtAutoMocDeps.cmake new file mode 100644 index 0000000..c441169 --- /dev/null +++ b/Tests/RunCMake/Ninja/QtAutoMocDeps.cmake @@ -0,0 +1,27 @@ +enable_language(CXX) + +set(QtX Qt${with_qt_version}) + +find_package(${QtX} REQUIRED COMPONENTS Core) + +set(CMAKE_AUTOMOC ON) + +add_library(simple_lib SHARED simple_lib.cpp) +add_executable(app_with_qt app.cpp app_qt.cpp) +target_link_libraries(app_with_qt PRIVATE simple_lib ${QtX}::Core) + +if(${QtX}Widgets_DIR) + find_package(${QtX} REQUIRED COMPONENTS Widgets) + if(with_qt_version STREQUAL 5) + qt5_wrap_ui(_headers MyWindow.ui) + else() + qt_wrap_ui(_headers MyWindow.ui) + endif() + add_executable(app_with_widget app.cpp MyWindow.cpp ${_headers}) + target_link_libraries(app_with_widget PRIVATE ${QtX}::Widgets) + target_include_directories(app_with_widget PRIVATE "${CMAKE_BINARY_DIR}") +endif() + +add_subdirectory(QtSubDir1) +add_subdirectory(QtSubDir2) +add_subdirectory(QtSubDir3) diff --git a/Tests/RunCMake/Ninja/QtSubDir1/CMakeLists.txt b/Tests/RunCMake/Ninja/QtSubDir1/CMakeLists.txt index 64016b6..3a12dcd 100644 --- a/Tests/RunCMake/Ninja/QtSubDir1/CMakeLists.txt +++ b/Tests/RunCMake/Ninja/QtSubDir1/CMakeLists.txt @@ -1,4 +1,4 @@ cmake_policy(SET CMP0116 OLD) add_executable(sub_exe_1 ../app.cpp) -target_link_libraries(sub_exe_1 PRIVATE Qt5::Core) +target_link_libraries(sub_exe_1 PRIVATE ${QtX}::Core) diff --git a/Tests/RunCMake/Ninja/QtSubDir2/CMakeLists.txt b/Tests/RunCMake/Ninja/QtSubDir2/CMakeLists.txt index 3176426..a2f77e4 100644 --- a/Tests/RunCMake/Ninja/QtSubDir2/CMakeLists.txt +++ b/Tests/RunCMake/Ninja/QtSubDir2/CMakeLists.txt @@ -1,4 +1,4 @@ cmake_policy(SET CMP0116 NEW) add_executable(sub_exe_2 ../app.cpp) -target_link_libraries(sub_exe_2 PRIVATE Qt5::Core) +target_link_libraries(sub_exe_2 PRIVATE ${QtX}::Core) diff --git a/Tests/RunCMake/Ninja/QtSubDir3/CMakeLists.txt b/Tests/RunCMake/Ninja/QtSubDir3/CMakeLists.txt index d38cfe0..70644fa 100644 --- a/Tests/RunCMake/Ninja/QtSubDir3/CMakeLists.txt +++ b/Tests/RunCMake/Ninja/QtSubDir3/CMakeLists.txt @@ -1,2 +1,2 @@ add_executable(sub_exe_3 ../app.cpp) -target_link_libraries(sub_exe_3 PRIVATE Qt5::Core) +target_link_libraries(sub_exe_3 PRIVATE ${QtX}::Core) diff --git a/Tests/RunCMake/Ninja/RunCMakeTest.cmake b/Tests/RunCMake/Ninja/RunCMakeTest.cmake index 3f239b9..2a5b556 100644 --- a/Tests/RunCMake/Ninja/RunCMakeTest.cmake +++ b/Tests/RunCMake/Ninja/RunCMakeTest.cmake @@ -319,12 +319,17 @@ function (run_ChangeBuildType) endfunction() run_ChangeBuildType() -function(run_Qt5AutoMocDeps) - if(CMake_TEST_Qt5 AND CMAKE_TEST_Qt5Core_Version VERSION_GREATER_EQUAL 5.15.0) - set(RunCMake_TEST_BINARY_DIR ${RunCMake_BINARY_DIR}/Qt5AutoMocDeps-build) - set(RunCMake_TEST_OPTIONS "-DQt5Core_DIR=${Qt5Core_DIR}" "-DQt5Widgets_DIR=${Qt5Widgets_DIR}") - run_cmake(Qt5AutoMocDeps) - unset(RunCMake_TEST_OPTIONS) +function(run_QtAutoMocDeps) + set(QtX Qt${CMake_TEST_Qt_version}) + if(CMake_TEST_${QtX}Core_Version VERSION_GREATER_EQUAL 5.15.0) + set(RunCMake_TEST_BINARY_DIR ${RunCMake_BINARY_DIR}/QtAutoMocDeps-build) + run_cmake_with_options(QtAutoMocDeps + "-Dwith_qt_version=${CMake_TEST_Qt_version}" + "-D${QtX}_DIR=${${QtX}_DIR}" + "-D${QtX}Core_DIR=${${QtX}Core_DIR}" + "-D${QtX}Widgets_DIR=${${QtX}Widgets_DIR}" + "-DCMAKE_PREFIX_PATH:STRING=${CMAKE_PREFIX_PATH}" + ) # Build the project. run_ninja("${RunCMake_TEST_BINARY_DIR}") # Touch just the library source file, which shouldn't cause a rerun of AUTOMOC @@ -352,4 +357,6 @@ function(run_Qt5AutoMocDeps) run_ninja("${RunCMake_TEST_BINARY_DIR}") endif() endfunction() -run_Qt5AutoMocDeps() +if(CMake_TEST_Qt_version) + run_QtAutoMocDeps() +endif() diff --git a/Tests/RunCMake/NinjaMultiConfig/Qt5-automoc-check-ninja-stdout.txt b/Tests/RunCMake/NinjaMultiConfig/QtX-automoc-check-ninja-stdout.txt index 85d5fdc..85d5fdc 100644 --- a/Tests/RunCMake/NinjaMultiConfig/Qt5-automoc-check-ninja-stdout.txt +++ b/Tests/RunCMake/NinjaMultiConfig/QtX-automoc-check-ninja-stdout.txt diff --git a/Tests/RunCMake/NinjaMultiConfig/Qt5-debug-in-release-graph-build-check.cmake b/Tests/RunCMake/NinjaMultiConfig/QtX-debug-in-release-graph-build-check.cmake index 2d8df13..2d8df13 100644 --- a/Tests/RunCMake/NinjaMultiConfig/Qt5-debug-in-release-graph-build-check.cmake +++ b/Tests/RunCMake/NinjaMultiConfig/QtX-debug-in-release-graph-build-check.cmake diff --git a/Tests/RunCMake/NinjaMultiConfig/Qt5.cmake b/Tests/RunCMake/NinjaMultiConfig/QtX.cmake index 578256a..130f883 100644 --- a/Tests/RunCMake/NinjaMultiConfig/Qt5.cmake +++ b/Tests/RunCMake/NinjaMultiConfig/QtX.cmake @@ -1,18 +1,21 @@ enable_language(CXX) -find_package(Qt5Core REQUIRED) +set(QtX Qt${with_qt_version}) + +find_package(${QtX} REQUIRED COMPONENTS Core) set(CMAKE_AUTOMOC ON) set(CMAKE_AUTOMOC_COMPILER_PREDEFINES OFF) +# Source files are always named qt5.* for simplicity but apply to Qt5 and later add_executable(exe qt5.cxx) -target_link_libraries(exe PRIVATE Qt5::Core) +target_link_libraries(exe PRIVATE ${QtX}::Core) include(${CMAKE_CURRENT_LIST_DIR}/Common.cmake) generate_output_files(exe) set(moc_writes_depfiles 0) -if(Qt5Core_VERSION VERSION_GREATER_EQUAL "5.15.0") +if(${QtX}Core_VERSION VERSION_GREATER_EQUAL "5.15.0") set(moc_writes_depfiles 1) endif() diff --git a/Tests/RunCMake/NinjaMultiConfig/RunCMakeTest.cmake b/Tests/RunCMake/NinjaMultiConfig/RunCMakeTest.cmake index 7c100eb..c7b876c 100644 --- a/Tests/RunCMake/NinjaMultiConfig/RunCMakeTest.cmake +++ b/Tests/RunCMake/NinjaMultiConfig/RunCMakeTest.cmake @@ -446,14 +446,20 @@ if(CMake_TEST_CUDA AND NOT CMake_TEST_CUDA STREQUAL "Clang") run_ninja(CudaSimple all-clean build-Debug.ninja clean:Debug) endif() -if(CMake_TEST_Qt5) - set(RunCMake_TEST_BINARY_DIR ${RunCMake_BINARY_DIR}/Qt5-build) - set(RunCMake_TEST_OPTIONS "-DCMAKE_CROSS_CONFIGS=all" "-DQt5Core_DIR=${Qt5Core_DIR}") - run_cmake_configure(Qt5) +if(CMake_TEST_Qt_version) + set(QtX Qt${CMake_TEST_Qt_version}) + set(RunCMake_TEST_BINARY_DIR ${RunCMake_BINARY_DIR}/QtX-build) + set(RunCMake_TEST_OPTIONS + "-DCMAKE_CROSS_CONFIGS=all" + "-Dwith_qt_version:STRING=${CMake_TEST_Qt_version}" + "-D${QtX}Core_DIR=${${QtX}Core_DIR}" + "-DCMAKE_PREFIX_PATH:STRING=${CMAKE_PREFIX_PATH}" + ) + run_cmake_configure(QtX) unset(RunCMake_TEST_OPTIONS) include(${RunCMake_TEST_BINARY_DIR}/target_files.cmake) - run_cmake_build(Qt5 debug-in-release-graph Release exe:Debug) - if(CMAKE_TEST_Qt5Core_Version VERSION_GREATER_EQUAL 5.15.0) - run_ninja(Qt5 automoc-check build-Debug.ninja -t query exe_autogen/timestamp) + run_cmake_build(QtX debug-in-release-graph Release exe:Debug) + if(CMake_TEST_${QtX}Core_Version VERSION_GREATER_EQUAL 5.15.0) + run_ninja(QtX automoc-check build-Debug.ninja -t query exe_autogen/timestamp) endif() endif() diff --git a/Utilities/Sphinx/CMakeLists.txt b/Utilities/Sphinx/CMakeLists.txt index a71dfcd..c8a970d 100644 --- a/Utilities/Sphinx/CMakeLists.txt +++ b/Utilities/Sphinx/CMakeLists.txt @@ -58,6 +58,13 @@ configure_file(conf.py.in conf.py @ONLY) set(doc_formats "") if(SPHINX_HTML) list(APPEND doc_formats html) + + # we provide the path to the produced html output in the console + # for tools that support URI protocol schemes + set(html_extra_commands + COMMAND ${CMAKE_COMMAND} -E echo "sphinx-build html: HTML documentation generated in file://${CMAKE_CURRENT_BINARY_DIR}/html/index.html" + ) + endif() if(SPHINX_MAN) list(APPEND doc_formats man) diff --git a/Utilities/cmzstd/lib/common/compiler.h b/Utilities/cmzstd/lib/common/compiler.h index 95e9483..1b864ea 100644 --- a/Utilities/cmzstd/lib/common/compiler.h +++ b/Utilities/cmzstd/lib/common/compiler.h @@ -139,7 +139,7 @@ /* vectorization * older GCC (pre gcc-4.3 picked as the cutoff) uses a different syntax */ -#if !defined(__INTEL_COMPILER) && !defined(__clang__) && defined(__GNUC__) +#if !defined(__INTEL_COMPILER) && !defined(__clang__) && !defined(__LCC__) && defined(__GNUC__) # if (__GNUC__ == 4 && __GNUC_MINOR__ > 3) || (__GNUC__ >= 5) # define DONT_VECTORIZE __attribute__((optimize("no-tree-vectorize"))) # else |