diff options
271 files changed, 3826 insertions, 1128 deletions
diff --git a/.gitlab/ci/borland.ps1 b/.gitlab/ci/borland.ps1 index 146a047..c8daafd 100644 --- a/.gitlab/ci/borland.ps1 +++ b/.gitlab/ci/borland.ps1 @@ -28,6 +28,7 @@ if ($hash.Hash -ne $sha256sum) { Add-Type -AssemblyName System.IO.Compression.FileSystem [System.IO.Compression.ZipFile]::ExtractToDirectory("$outdir\$tarball", "$outdir") Move-Item -Path "$outdir\$filename" -Destination "$outdir\bcc" +Remove-Item "$outdir\$tarball" $tools = "bcc32", "ilink32" foreach ($tool in $tools) { diff --git a/.gitlab/ci/clang.ps1 b/.gitlab/ci/clang.ps1 index e455ebc..204bff5 100644 --- a/.gitlab/ci/clang.ps1 +++ b/.gitlab/ci/clang.ps1 @@ -23,6 +23,7 @@ if ($hash.Hash -ne $sha256sum) { Add-Type -AssemblyName System.IO.Compression.FileSystem [System.IO.Compression.ZipFile]::ExtractToDirectory("$outdir\$tarball", "$outdir") Move-Item -Path "$outdir\$filename" -Destination "$outdir\llvm" +Remove-Item "$outdir\$tarball" $bin = "$outdir\llvm\bin" $lib = "$outdir\llvm\lib" diff --git a/.gitlab/ci/cmake.ps1 b/.gitlab/ci/cmake.ps1 index 89b7d1b..7afcb36 100644 --- a/.gitlab/ci/cmake.ps1 +++ b/.gitlab/ci/cmake.ps1 @@ -27,3 +27,4 @@ if ($hash.Hash -ne $sha256sum) { Add-Type -AssemblyName System.IO.Compression.FileSystem [System.IO.Compression.ZipFile]::ExtractToDirectory("$outdir\$tarball", "$outdir") Move-Item -Path "$outdir\$filename" -Destination "$outdir\cmake" +Remove-Item "$outdir\$tarball" diff --git a/.gitlab/ci/cmake.sh b/.gitlab/ci/cmake.sh index 477c1193..7bc8cd8 100755 --- a/.gitlab/ci/cmake.sh +++ b/.gitlab/ci/cmake.sh @@ -39,6 +39,7 @@ curl -OL "https://github.com/Kitware/CMake/releases/download/v$version/$tarball" $shatool --check cmake.sha256sum tar xf "$tarball" mv "$filename" cmake +rm "$tarball" cmake.sha256sum if [ "$( uname -s )" = "Darwin" ]; then ln -s CMake.app/Contents/bin cmake/bin diff --git a/.gitlab/ci/download_qt.cmake b/.gitlab/ci/download_qt.cmake index 28a3e27..d2a00bd 100644 --- a/.gitlab/ci/download_qt.cmake +++ b/.gitlab/ci/download_qt.cmake @@ -122,6 +122,7 @@ foreach (qt_file IN LISTS qt_files) message(FATAL_ERROR "Failed to extract ${qt_file}: ${err}") endif () + file(REMOVE "${qt_file}") endforeach () # The Windows tarballs have some unfortunate permissions in them that prevent diff --git a/.gitlab/ci/ispc.ps1 b/.gitlab/ci/ispc.ps1 index 524896f..d390061 100644 --- a/.gitlab/ci/ispc.ps1 +++ b/.gitlab/ci/ispc.ps1 @@ -17,3 +17,4 @@ if ($hash.Hash -ne $sha256sum) { Add-Type -AssemblyName System.IO.Compression.FileSystem [System.IO.Compression.ZipFile]::ExtractToDirectory("$outdir\$tarball", "$outdir") Move-Item -Path "$outdir\$filename" -Destination "$outdir\ispc" +Remove-Item "$outdir\$tarball" diff --git a/.gitlab/ci/ispc.sh b/.gitlab/ci/ispc.sh index c1e3793..7728c32 100755 --- a/.gitlab/ci/ispc.sh +++ b/.gitlab/ci/ispc.sh @@ -39,3 +39,4 @@ curl -OL "https://github.com/ispc/ispc/releases/download/v$version/$tarball" $shatool --check ispc.sha256sum tar xf "$tarball" mv "$filename" ispc +rm "$tarball" ispc.sha256sum diff --git a/.gitlab/ci/jom.ps1 b/.gitlab/ci/jom.ps1 index 6c28005..430d323 100644 --- a/.gitlab/ci/jom.ps1 +++ b/.gitlab/ci/jom.ps1 @@ -13,3 +13,4 @@ if ($hash.Hash -ne $sha256sum) { } Expand-Archive -Path "$outdir\$tarball" -DestinationPath "$outdir\jom" +Remove-Item "$outdir\$tarball" diff --git a/.gitlab/ci/msvc.ps1 b/.gitlab/ci/msvc.ps1 index e8388a4..a6b6fbf 100644 --- a/.gitlab/ci/msvc.ps1 +++ b/.gitlab/ci/msvc.ps1 @@ -23,6 +23,7 @@ if ($hash.Hash -ne $sha256sum) { Add-Type -AssemblyName System.IO.Compression.FileSystem [System.IO.Compression.ZipFile]::ExtractToDirectory("$outdir\$tarball", "$outdir") Move-Item -Path "$outdir\$filename" -Destination "$outdir\msvc" +Remove-Item "$outdir\$tarball" $bat = Get-Content -path "$outdir\msvc\$vcvars.in" -Raw $bat = $bat -replace "@VS_ROOT@","$outdir\msvc" diff --git a/.gitlab/ci/ninja.ps1 b/.gitlab/ci/ninja.ps1 index 0af3b4f..4c4d675 100644 --- a/.gitlab/ci/ninja.ps1 +++ b/.gitlab/ci/ninja.ps1 @@ -21,3 +21,4 @@ if ($hash.Hash -ne $sha256sum) { Add-Type -AssemblyName System.IO.Compression.FileSystem [System.IO.Compression.ZipFile]::ExtractToDirectory("$outdir\$tarball", "$outdir") +Remove-Item "$outdir\$tarball" diff --git a/.gitlab/ci/ninja.sh b/.gitlab/ci/ninja.sh index ce39b46..753596b 100755 --- a/.gitlab/ci/ninja.sh +++ b/.gitlab/ci/ninja.sh @@ -43,3 +43,4 @@ echo "$sha256sum $tarball" > ninja.sha256sum curl -OL "$baseurl/$tarball" $shatool --check ninja.sha256sum ./cmake/bin/cmake -E tar xf "$tarball" +rm "$tarball" ninja.sha256sum diff --git a/.gitlab/ci/openwatcom.ps1 b/.gitlab/ci/openwatcom.ps1 index 4f1012c..eb617c3 100644 --- a/.gitlab/ci/openwatcom.ps1 +++ b/.gitlab/ci/openwatcom.ps1 @@ -23,3 +23,4 @@ if ($hash.Hash -ne $sha256sum) { Add-Type -AssemblyName System.IO.Compression.FileSystem [System.IO.Compression.ZipFile]::ExtractToDirectory("$outdir\$tarball", "$outdir") Move-Item -Path "$outdir\$filename" -Destination "$outdir\watcom" +Remove-Item "$outdir\$tarball" diff --git a/Auxiliary/vim/syntax/cmake.vim b/Auxiliary/vim/syntax/cmake.vim index 5d412c2..f9efd9e 100644 --- a/Auxiliary/vim/syntax/cmake.vim +++ b/Auxiliary/vim/syntax/cmake.vim @@ -416,6 +416,7 @@ syn keyword cmakeProperty contained \ VS_DOTNET_STARTUP_OBJECT \ VS_DOTNET_TARGET_FRAMEWORK_VERSION \ VS_DPI_AWARE + \ VS_FRAMEWORK_REFERENCES \ VS_GLOBAL_KEYWORD \ VS_GLOBAL_PROJECT_TYPES \ VS_GLOBAL_ROOTNAMESPACE diff --git a/CMakeLists.txt b/CMakeLists.txt index 081bd7d..51c2b3f 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,7 +1,7 @@ # Distributed under the OSI-approved BSD 3-Clause License. See accompanying # file Copyright.txt or https://cmake.org/licensing for details. -cmake_minimum_required(VERSION 3.13...3.28 FATAL_ERROR) +cmake_minimum_required(VERSION 3.13...3.29 FATAL_ERROR) set(CMAKE_USER_MAKE_RULES_OVERRIDE_C ${CMAKE_CURRENT_SOURCE_DIR}/Source/Modules/OverrideC.cmake) set(CMAKE_USER_MAKE_RULES_OVERRIDE_CXX ${CMAKE_CURRENT_SOURCE_DIR}/Source/Modules/OverrideCXX.cmake) diff --git a/CONTRIBUTING.rst b/CONTRIBUTING.rst index 81f26f5..88f39f1 100644 --- a/CONTRIBUTING.rst +++ b/CONTRIBUTING.rst @@ -26,7 +26,8 @@ To contribute patches: #. Fork the upstream `CMake Repository`_ into a personal account. #. Run `Utilities/SetupForDevelopment.sh`_ for local git configuration. #. See `Building CMake`_ for building CMake locally. -#. See the `CMake Source Code Guide`_ for coding guidelines. +#. See the `CMake Source Code Guide`_ for coding guidelines + and the `CMake Testing Guide`_ for testing instructions. #. Create a topic branch named suitably for your work. Base all new work on the upstream ``master`` branch. Base work on the upstream ``release`` branch only if it fixes a @@ -49,6 +50,7 @@ The merge request will enter the `CMake Review Process`_ for consideration. .. _`Utilities/SetupForDevelopment.sh`: Utilities/SetupForDevelopment.sh .. _`Building CMake`: README.rst#building-cmake .. _`CMake Source Code Guide`: Help/dev/source.rst +.. _`CMake Testing Guide`: Help/dev/testing.rst .. _`commit messages`: Help/dev/review.rst#commit-messages .. _`CMake Review Process`: Help/dev/review.rst @@ -61,10 +63,10 @@ drive testing and submit results to the `CMake CDash Page`_. Anyone is welcome to provide testing machines in order to help keep support for their platforms working. -See documentation on `CMake Testing Process`_ for more information. +See documentation on `CMake Integration Testing`_ for more information. .. _`CMake CDash Page`: https://open.cdash.org/index.php?project=CMake -.. _`CMake Testing Process`: Help/dev/testing.rst +.. _`CMake Integration Testing`: Help/dev/integration-testing.rst License ======= diff --git a/Help/command/add_custom_command.rst b/Help/command/add_custom_command.rst index 77357c0..6169038 100644 --- a/Help/command/add_custom_command.rst +++ b/Help/command/add_custom_command.rst @@ -26,6 +26,7 @@ The first signature is for adding a custom command to produce an output: [JOB_POOL job_pool] [JOB_SERVER_AWARE <bool>] [VERBATIM] [APPEND] [USES_TERMINAL] + [CODEGEN] [COMMAND_EXPAND_LISTS] [DEPENDS_EXPLICIT_ONLY]) @@ -203,6 +204,18 @@ The options are: ``${CC} "-I$<JOIN:$<TARGET_PROPERTY:foo,INCLUDE_DIRECTORIES>,;-I>" foo.cc`` to be properly expanded. +``CODEGEN`` + .. versionadded:: 3.31 + + Adds the custom command to a global ``codegen`` target that can be + used to execute the custom command while avoiding the majority of the + build graph. + + This option is supported only by :ref:`Ninja Generators` and + :ref:`Makefile Generators`, and is ignored by other generators. + Furthermore, this option is allowed only if policy :policy:`CMP0171` + is set to ``NEW``. + ``IMPLICIT_DEPENDS`` Request scanning of implicit dependencies of an input file. The language given specifies the programming language whose @@ -454,6 +467,25 @@ will re-run whenever ``in.txt`` changes. where ``<config>`` is the build configuration, and then compile the generated source as part of a library. +.. versionadded:: 3.31 + Use the ``CODEGEN`` option to add a custom command's outputs to the builtin + ``codegen`` target. This is useful to make generated code available for + static analysis without building the entire project. For example: + + .. code-block:: cmake + + add_executable(someTool someTool.c) + + add_custom_command( + OUTPUT out.c + COMMAND someTool -o out.c + CODEGEN) + + add_library(myLib out.c) + + A user may build the ``codegen`` target to generate ``out.c``. + ``someTool`` is built as dependency, but ``myLib`` is not built at all. + Example: Generating Files for Multiple Targets """""""""""""""""""""""""""""""""""""""""""""" diff --git a/Help/command/file.rst b/Help/command/file.rst index 5b9dfac..ede95a1 100644 --- a/Help/command/file.rst +++ b/Help/command/file.rst @@ -398,10 +398,19 @@ Filesystem ============== ====================================================== .. signature:: - file(MAKE_DIRECTORY <directories>...) + file(MAKE_DIRECTORY <directories>... [RESULT <result>]) Create the given directories and their parents as needed. + The options are: + + ``RESULT <result>`` + .. versionadded:: 3.31 + + Set ``<result>`` variable to ``0`` on success or an error message + otherwise. If ``RESULT`` is not specified and the operation fails, + an error is emitted. + .. versionchanged:: 3.30 ``<directories>`` can be an empty list. CMake 3.29 and earlier required at least one directory to be given. diff --git a/Help/cpack_gen/archive.rst b/Help/cpack_gen/archive.rst index 7f7921d..5836f91 100644 --- a/Help/cpack_gen/archive.rst +++ b/Help/cpack_gen/archive.rst @@ -91,14 +91,10 @@ CPack generators which are essentially archives at their core. These include: .. versionadded:: 3.18 - :Default: ``1`` + :Default: value of :variable:`CPACK_THREADS` If set to ``0``, the number of available cores on the machine will be used instead. - The default is ``1`` which limits compression to a single thread. Note that - not all compression modes support threading in all environments. Currently, - only the XZ compression may support it. - - See also the :variable:`CPACK_THREADS` variable. + Note that not all compression modes support threading in all environments. .. versionadded:: 3.21 diff --git a/Help/cpack_gen/deb.rst b/Help/cpack_gen/deb.rst index 23436de..a4063d9 100644 --- a/Help/cpack_gen/deb.rst +++ b/Help/cpack_gen/deb.rst @@ -654,6 +654,31 @@ List of CPack DEB generator specific variables: This value is not interpreted. It is possible to pass an optional revision number of the referenced source package as well. +.. variable:: CPACK_DEBIAN_PACKAGE_MULTIARCH + CPACK_DEBIAN_<COMPONENT>_PACKAGE_MULTIARCH + + Sets the `Multi-Arch` field of the Debian package. + Packages can declare in their control file how they should handle + situations, where packages for different architectures are being installed + on the same machine. + + :Mandatory: No + :Default: + + - An empty string for non-component based installations + - :variable:`CPACK_DEBIAN_PACKAGE_MULTIARCH` for component-based + installations. + + .. versionadded:: 3.31 + Per-component :variable:`!CPACK_DEBIAN_<COMPONENT>_PACKAGE_MULTIARCH` variables. + + See https://wiki.debian.org/MultiArch/Hints + + .. note:: + + This value is validated. It must be one of the following values: + ``same``, ``foreign``, ``allowed``. + Packaging of debug information ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ diff --git a/Help/cpack_gen/rpm.rst b/Help/cpack_gen/rpm.rst index 4a2ce5f..ebd3766 100644 --- a/Help/cpack_gen/rpm.rst +++ b/Help/cpack_gen/rpm.rst @@ -246,9 +246,8 @@ List of CPack RPM generator specific variables: :Default: (system default) May be used to override RPM compression type to be used to build the - RPM. For example some Linux distribution now default to ``lzma`` or ``xz`` - compression whereas older cannot use such RPM. Using this one can enforce - compression type to be used. + RPM. For example some Linux distributions default to ``xz`` or ``zstd``. + Using this, one can specify a specific compression type to be used. Possible values are: @@ -264,6 +263,11 @@ List of CPack RPM generator specific variables: ``gzip`` GNU Gzip compression + ``zstd`` + .. versionadded:: 3.31 + + Zstandard compression + .. variable:: CPACK_RPM_PACKAGE_AUTOREQ CPACK_RPM_<component>_PACKAGE_AUTOREQ diff --git a/Help/dev/README.rst b/Help/dev/README.rst index 9c3878b..2a2d32d 100644 --- a/Help/dev/README.rst +++ b/Help/dev/README.rst @@ -23,12 +23,13 @@ branches and tags. Upstream development processes are covered by the following documents: * The `CMake Review Process`_ manages integration of changes. -* The `CMake Testing Process`_ drives integration testing. +* The `CMake Integration Testing`_ infrastructure tests changes + before and after merging. .. _`Kitware's GitLab Instance`: https://gitlab.kitware.com .. _`CMake Repository`: https://gitlab.kitware.com/cmake/cmake .. _`CMake Review Process`: review.rst -.. _`CMake Testing Process`: testing.rst +.. _`CMake Integration Testing`: integration-testing.rst Developer Documentation ======================= @@ -37,10 +38,12 @@ CMake developer documentation is provided by the following documents: * The `CMake Source Code Guide`_. * The `CMake Documentation Guide`_. +* The `CMake Testing Guide`_. * The `CMake Experimental Features Guide`_. .. _`CMake Source Code Guide`: source.rst .. _`CMake Documentation Guide`: documentation.rst +.. _`CMake Testing Guide`: testing.rst .. _`CMake Experimental Features Guide`: experimental.rst Maintainer Documentation diff --git a/Help/dev/documentation.rst b/Help/dev/documentation.rst index 00413e1..8270bb1 100644 --- a/Help/dev/documentation.rst +++ b/Help/dev/documentation.rst @@ -310,17 +310,17 @@ are suppressed inside of square- or angle-brackets. This behavior can be controlled using the ``:break:`` option; note, however, that there is no way to *force* a line break. The default value is 'smart'. Allowable values are: - ``all`` - Allow line breaks at any whitespace. +``all`` + Allow line breaks at any whitespace. - ``smart`` (default) - Allow line breaks at whitespace, except between matched square- or - angle-brackets. For example, if a signature contains the text - ``<input>... [OUTPUT_VARIABLE <out-var>]``, a line break would be allowed - after ``<input>...`` but not between ``OUTPUT_VARIABLE`` and ``<out-var>``. +``smart`` (default) + Allow line breaks at whitespace, except between matched square- or + angle-brackets. For example, if a signature contains the text + ``<input>... [OUTPUT_VARIABLE <out-var>]``, a line break would be allowed + after ``<input>...`` but not between ``OUTPUT_VARIABLE`` and ``<out-var>``. - ``verbatim`` - Allow line breaks only where the source document contains a newline. +``verbatim`` + Allow line breaks only where the source document contains a newline. The directive treats its content as the documentation of the signature(s). Indent the signature documentation accordingly. diff --git a/Help/dev/integration-testing.rst b/Help/dev/integration-testing.rst new file mode 100644 index 0000000..434cf23 --- /dev/null +++ b/Help/dev/integration-testing.rst @@ -0,0 +1,46 @@ +CMake Integration Testing +************************* + +The following documents how to run integration testing builds. +See documentation on `CMake Development`_ for more information. + +See the `CMake Testing Guide`_ for running the test suite locally. + +.. _`CMake Development`: README.rst +.. _`CMake Testing Guide`: testing.rst + +CMake Dashboard Scripts +======================= + +The *integration testing* step of the `CMake Review Process`_ uses a set of +testing machines that follow an integration branch on their own schedule to +drive testing and submit results to the `CMake CDash Page`_. Anyone is +welcome to provide testing machines in order to help keep support for their +platforms working. + +The `CMake Dashboard Scripts Repository`_ provides CTest scripts to drive +nightly, continuous, and experimental testing of CMake. Use the following +commands to set up a new integration testing client: + +.. code-block:: console + + $ mkdir -p ~/Dashboards + $ cd ~/Dashboards + $ git clone https://gitlab.kitware.com/cmake/dashboard-scripts.git CMakeScripts + $ cd CMakeScripts + +The `cmake_common.cmake`_ script contains comments at the top with +instructions to set up a testing client. As it instructs, create a +CTest script with local settings and include ``cmake_common.cmake``. + +.. _`CMake Review Process`: review.rst +.. _`CMake CDash Page`: https://open.cdash.org/index.php?project=CMake +.. _`CMake Dashboard Scripts Repository`: https://gitlab.kitware.com/cmake/dashboard-scripts +.. _`cmake_common.cmake`: https://gitlab.kitware.com/cmake/dashboard-scripts/-/blob/master/cmake_common.cmake + +Nightly Start Time +------------------ + +The ``cmake_common.cmake`` script expects its includer to be run from a +nightly scheduled task (cron job). Schedule such tasks for sometime after +``1:00am UTC``, the time at which our nightly testing branches fast-forward. diff --git a/Help/dev/make_directory-optional-result.rst b/Help/dev/make_directory-optional-result.rst new file mode 100644 index 0000000..be842fe --- /dev/null +++ b/Help/dev/make_directory-optional-result.rst @@ -0,0 +1,5 @@ +make_directory-optional-result +------------------------------ + +* The :command:`file(MAKE_DIRECTORY)` learned to +optionally capture failure in a result variable. diff --git a/Help/dev/review.rst b/Help/dev/review.rst index 34796a1..40bf3e5 100644 --- a/Help/dev/review.rst +++ b/Help/dev/review.rst @@ -348,7 +348,7 @@ Integration Testing The above `topic testing`_ tests the MR topic independent of other merge requests and on only a few key platforms and configurations. -The `CMake Testing Process`_ also has a large number of machines +`CMake Integration Testing`_ also uses a large number of machines provided by Kitware and generous volunteers that cover nearly all supported platforms, generators, and configurations. In order to avoid overwhelming these resources, they do not test every MR @@ -403,7 +403,7 @@ until one of the following occurs: Once a MR has been removed from the topic stage a new ``Do: stage`` command is needed to stage it again. -.. _`CMake Testing Process`: testing.rst +.. _`CMake Integration Testing`: integration-testing.rst Resolve ======= diff --git a/Help/dev/source.rst b/Help/dev/source.rst index fa7d620..c3d7ac3 100644 --- a/Help/dev/source.rst +++ b/Help/dev/source.rst @@ -310,6 +310,7 @@ The CMake source tree is organized as follows. * ``Tests/``: The test suite. See `Tests/README.rst`_. + To run the tests, see the `CMake Testing Guide`_. * ``Utilities/``: Scripts, third-party source code. @@ -331,5 +332,6 @@ The CMake source tree is organized as follows. See `Utilities/Release/README.rst`_. .. _`CMake Documentation Guide`: documentation.rst +.. _`CMake Testing Guide`: testing.rst .. _`Tests/README.rst`: ../../Tests/README.rst .. _`Utilities/Release/README.rst`: ../../Utilities/Release/README.rst diff --git a/Help/dev/testing.rst b/Help/dev/testing.rst index 279e4b2..f90cef7 100644 --- a/Help/dev/testing.rst +++ b/Help/dev/testing.rst @@ -1,43 +1,111 @@ -CMake Testing Process -********************* +CMake Testing Guide +******************* -The following documents the process for running integration testing builds. +The following is a guide to the CMake test suite for developers. See documentation on `CMake Development`_ for more information. +See `CMake Integration Testing`_ for running integration testing builds. + +See `Tests/README.rst`_ for the test suite layout in the source tree. + .. _`CMake Development`: README.rst +.. _`CMake Integration Testing`: integration-testing.rst +.. _`Tests/README.rst`: ../../Tests/README.rst + +Running Tests in the Build Tree +=============================== + +After `Building CMake`_, one may run the test suite in the build tree +using `ctest(1)`_: + +* With a single-configuration CMake generator, such as ``Ninja`` + or ``Unix Makefiles``, one may simply run ``ctest``: + + .. code-block:: console + + $ ctest + +* With a multi-configuration CMake generator, such as + ``Ninja Multi-Config``, ``Visual Studio``, or ``Xcode``, + one must tell ``ctest`` which configuration to test + by passing the ``-C <config>`` option: + + .. code-block:: console + + $ ctest -C Debug + +Some useful `ctest(1)`_ options include: + +``-N`` + List test names without running them. + +``-V`` + Show verbose output from each test. + +``-j <N>`` + Run to run up to ``N`` tests concurrently. -CMake Dashboard Scripts -======================= +``-R <regex>`` + Select tests for which the regular expression matches a substring + of their name. -The *integration testing* step of the `CMake Review Process`_ uses a set of -testing machines that follow an integration branch on their own schedule to -drive testing and submit results to the `CMake CDash Page`_. Anyone is -welcome to provide testing machines in order to help keep support for their -platforms working. +Cleaning Test Build Trees +------------------------- -The `CMake Dashboard Scripts Repository`_ provides CTest scripts to drive -nightly, continuous, and experimental testing of CMake. Use the following -commands to set up a new integration testing client: +Many CMake tests create their own test project build trees underneath +the ``Tests/`` directory at the top of the CMake build tree. These +build trees are left behind after testing completes in order to +facilitate manual investigation of results. Many of the tests do *not* +clean their build trees if they are run again, with the exception of +tests using the `RunCMake`_ infrastructure. + +In order to clear test build trees, drive the ``test_clean`` custom target +in the CMake build tree: + +.. code-block:: console + + $ cmake --build . --target test_clean + +This removes the ``Tests/`` subdirectories created by individual tests +so they will use a fresh directory next time they run. + +.. _`Building CMake`: ../../README.rst#building-cmake +.. _`ctest(1)`: https://cmake.org/cmake/help/latest/manual/ctest.1.html +.. _`RunCMake`: ../../Tests/RunCMake/README.rst + +Running Tests with a Different Generator +======================================== + +After `Building CMake`_ with one CMake generator, one may configure the +test suite using a different generator in a separate build tree, without +building CMake itself again, by defining ``CMake_TEST_EXTERNAL_CMAKE`` +to be the absolute path to the ``bin`` directory containing the ``cmake``, +``ctest``, and ``cpack`` executables. + +For example, after building CMake with the ``Ninja`` generator: .. code-block:: console - $ mkdir -p ~/Dashboards - $ cd ~/Dashboards - $ git clone https://gitlab.kitware.com/cmake/dashboard-scripts.git CMakeScripts - $ cd CMakeScripts + $ cmake -B build-ninja -G Ninja -DCMAKE_BUILD_TYPE=Debug + $ cmake --build build-ninja -The `cmake_common.cmake`_ script contains comments at the top with -instructions to set up a testing client. As it instructs, create a -CTest script with local settings and include ``cmake_common.cmake``. +one may configure a second build tree to drive tests with the +``Ninja Multi-Config`` generator: + +.. code-block:: console -.. _`CMake Review Process`: review.rst -.. _`CMake CDash Page`: https://open.cdash.org/index.php?project=CMake -.. _`CMake Dashboard Scripts Repository`: https://gitlab.kitware.com/cmake/dashboard-scripts -.. _`cmake_common.cmake`: https://gitlab.kitware.com/cmake/dashboard-scripts/-/blob/master/cmake_common.cmake + $ cmake -B build-nmc-tests -G "Ninja Multi-Config" \ + -DCMake_TEST_EXTERNAL_CMAKE="$PWD/build-ninja/bin" + $ cmake --build build-nmc-tests --config Release + +The second build tree does not build CMake itself, but does configure +the test suite and build test binaries. One may then run tests normally: + +.. code-block:: console -Nightly Start Time ------------------- + $ cd build-nmc-tests + $ ctest -C Release -The ``cmake_common.cmake`` script expects its includer to be run from a -nightly scheduled task (cron job). Schedule such tasks for sometime after -``1:00am UTC``, the time at which our nightly testing branches fast-forward. +Note that the configuration with which one drives tests in the second +build tree is independent of the configuration with which CMake was +built in the first. diff --git a/Help/manual/cmake-policies.7.rst b/Help/manual/cmake-policies.7.rst index 7155404..90c71b7 100644 --- a/Help/manual/cmake-policies.7.rst +++ b/Help/manual/cmake-policies.7.rst @@ -51,6 +51,14 @@ The :variable:`CMAKE_MINIMUM_REQUIRED_VERSION` variable may also be used to determine whether to report an error on use of deprecated macros or functions. +Policies Introduced by CMake 3.31 +================================= + +.. toctree:: + :maxdepth: 1 + + CMP0171: 'codegen' is a reserved target name. </policy/CMP0171> + Policies Introduced by CMake 3.30 ================================= diff --git a/Help/manual/cmake-presets.7.rst b/Help/manual/cmake-presets.7.rst index 59b34c6..ee348c1 100644 --- a/Help/manual/cmake-presets.7.rst +++ b/Help/manual/cmake-presets.7.rst @@ -39,6 +39,9 @@ The files are a JSON document with an object as the root: .. literalinclude:: presets/example.json :language: json +Preset files specifying version ``10`` or above may include comments using the +key ``$comment`` at any level within the JSON object to provide documentation. + The root object recognizes the following fields: ``$schema`` @@ -81,6 +84,9 @@ The root object recognizes the following fields: ``9`` .. versionadded:: 3.30 + ``10`` + .. versionadded:: 3.31 + ``cmakeMinimumRequired`` An optional object representing the minimum version of CMake needed to build this project. This object consists of the following fields: diff --git a/Help/manual/cmake-properties.7.rst b/Help/manual/cmake-properties.7.rst index 673bc7c..fea661a 100644 --- a/Help/manual/cmake-properties.7.rst +++ b/Help/manual/cmake-properties.7.rst @@ -430,6 +430,7 @@ Properties on Targets /prop_tgt/VS_DOTNET_STARTUP_OBJECT /prop_tgt/VS_DOTNET_TARGET_FRAMEWORK_VERSION /prop_tgt/VS_DPI_AWARE + /prop_tgt/VS_FRAMEWORK_REFERENCES /prop_tgt/VS_GLOBAL_KEYWORD /prop_tgt/VS_GLOBAL_PROJECT_TYPES /prop_tgt/VS_GLOBAL_ROOTNAMESPACE diff --git a/Help/manual/presets/example.json b/Help/manual/presets/example.json index 696ab47..96fccb2 100644 --- a/Help/manual/presets/example.json +++ b/Help/manual/presets/example.json @@ -1,16 +1,22 @@ { - "version": 6, + "version": 10, "cmakeMinimumRequired": { "major": 3, "minor": 23, "patch": 0 }, + "$comment": "An example CMakePresets.json file", "include": [ "otherThings.json", "moreThings.json" ], "configurePresets": [ { + "$comment": [ + "This is a comment row.", + "This is another comment,", + "just because we can do it" + ], "name": "default", "displayName": "Default Config", "description": "Default build using Ninja generator", diff --git a/Help/manual/presets/schema.json b/Help/manual/presets/schema.json index f80685c..a7aee63 100644 --- a/Help/manual/presets/schema.json +++ b/Help/manual/presets/schema.json @@ -9,7 +9,7 @@ "const": 1, "description": "A required integer representing the version of the JSON schema." }, - "cmakeMinimumRequired": { "$ref": "#/definitions/cmakeMinimumRequired" }, + "cmakeMinimumRequired": { "$ref": "#/definitions/cmakeMinimumRequiredV1" }, "vendor": { "$ref": "#/definitions/vendor" }, "configurePresets": { "$ref": "#/definitions/configurePresetsV1" } }, @@ -21,7 +21,7 @@ "const": 2, "description": "A required integer representing the version of the JSON schema." }, - "cmakeMinimumRequired": { "$ref": "#/definitions/cmakeMinimumRequired" }, + "cmakeMinimumRequired": { "$ref": "#/definitions/cmakeMinimumRequiredV1" }, "vendor": { "$ref": "#/definitions/vendor" }, "configurePresets": { "$ref": "#/definitions/configurePresetsV1" }, "buildPresets": { "$ref": "#/definitions/buildPresetsV2" }, @@ -35,7 +35,7 @@ "const": 3, "description": "A required integer representing the version of the JSON schema." }, - "cmakeMinimumRequired": { "$ref": "#/definitions/cmakeMinimumRequired" }, + "cmakeMinimumRequired": { "$ref": "#/definitions/cmakeMinimumRequiredV1" }, "vendor": { "$ref": "#/definitions/vendor" }, "configurePresets": { "$ref": "#/definitions/configurePresetsV3" }, "buildPresets": { "$ref": "#/definitions/buildPresetsV3" }, @@ -49,7 +49,7 @@ "const": 4, "description": "A required integer representing the version of the JSON schema." }, - "cmakeMinimumRequired": { "$ref": "#/definitions/cmakeMinimumRequired" }, + "cmakeMinimumRequired": { "$ref": "#/definitions/cmakeMinimumRequiredV1" }, "vendor": { "$ref": "#/definitions/vendor" }, "configurePresets": { "$ref": "#/definitions/configurePresetsV3" }, "buildPresets": { "$ref": "#/definitions/buildPresetsV4" }, @@ -64,7 +64,7 @@ "const": 5, "description": "A required integer representing the version of the JSON schema." }, - "cmakeMinimumRequired": { "$ref": "#/definitions/cmakeMinimumRequired" }, + "cmakeMinimumRequired": { "$ref": "#/definitions/cmakeMinimumRequiredV1" }, "vendor": { "$ref": "#/definitions/vendor" }, "configurePresets": { "$ref": "#/definitions/configurePresetsV3" }, "buildPresets": { "$ref": "#/definitions/buildPresetsV4" }, @@ -79,7 +79,7 @@ "const": 6, "description": "A required integer representing the version of the JSON schema." }, - "cmakeMinimumRequired": { "$ref": "#/definitions/cmakeMinimumRequired" }, + "cmakeMinimumRequired": { "$ref": "#/definitions/cmakeMinimumRequiredV1" }, "vendor": { "$ref": "#/definitions/vendor" }, "configurePresets": { "$ref": "#/definitions/configurePresetsV3" }, "buildPresets": { "$ref": "#/definitions/buildPresetsV4" }, @@ -96,7 +96,7 @@ "const": 7, "description": "A required integer representing the version of the JSON schema." }, - "cmakeMinimumRequired": { "$ref": "#/definitions/cmakeMinimumRequired" }, + "cmakeMinimumRequired": { "$ref": "#/definitions/cmakeMinimumRequiredV1" }, "vendor": { "$ref": "#/definitions/vendor" }, "configurePresets": { "$ref": "#/definitions/configurePresetsV7" }, "buildPresets": { "$ref": "#/definitions/buildPresetsV4" }, @@ -114,7 +114,7 @@ "const": 8, "description": "A required integer representing the version of the JSON schema." }, - "cmakeMinimumRequired": { "$ref": "#/definitions/cmakeMinimumRequired" }, + "cmakeMinimumRequired": { "$ref": "#/definitions/cmakeMinimumRequiredV1" }, "vendor": { "$ref": "#/definitions/vendor" }, "configurePresets": { "$ref": "#/definitions/configurePresetsV7" }, "buildPresets": { "$ref": "#/definitions/buildPresetsV4" }, @@ -132,7 +132,7 @@ "const": 9, "description": "A required integer representing the version of the JSON schema." }, - "cmakeMinimumRequired": { "$ref": "#/definitions/cmakeMinimumRequired" }, + "cmakeMinimumRequired": { "$ref": "#/definitions/cmakeMinimumRequiredV1" }, "vendor": { "$ref": "#/definitions/vendor" }, "configurePresets": { "$ref": "#/definitions/configurePresetsV7" }, "buildPresets": { "$ref": "#/definitions/buildPresetsV4" }, @@ -142,6 +142,25 @@ "include": { "$ref": "#/definitions/include" } }, "additionalProperties": false + }, + { + "properties": { + "$schema": { "$ref": "#/definitions/$schema" }, + "$comment": { "$ref": "#/definitions/$comment" }, + "version": { + "const": 10, + "description": "A required integer representing the version of the JSON schema." + }, + "cmakeMinimumRequired": { "$ref": "#/definitions/cmakeMinimumRequiredV10" }, + "vendor": { "$ref": "#/definitions/vendor" }, + "configurePresets": { "$ref": "#/definitions/configurePresetsV10" }, + "buildPresets": { "$ref": "#/definitions/buildPresetsV10" }, + "testPresets": { "$ref": "#/definitions/testPresetsV10" }, + "packagePresets": { "$ref": "#/definitions/packagePresetsV10" }, + "workflowPresets": { "$ref": "#/definitions/workflowPresetsV10" }, + "include": { "$ref": "#/definitions/include" } + }, + "additionalProperties": false } ], "required": [ @@ -153,9 +172,33 @@ "description": "The schema against which to verify this document.", "format": "uri-reference" }, - "cmakeMinimumRequired": { + "$comment": { + "anyOf": [ + { + "type": "string", + "description": "The single-line comment" + }, + { + "type": "array", + "description": "The multi-line comment", + "minItems": 1, + "items": { + "type": "string", + "description": "One line of the multi-line comment" + } + } + ] + }, + "cmakeMinimumRequiredPropertiesV10": { + "type": "object", + "description": "An optional object representing the minimum version of CMake needed to build this project. Available in version 10 and higher.", + "properties": { + "$comment": { "$ref": "#/definitions/$comment" } + } + }, + "cmakeMinimumRequiredPropertiesV1": { "type": "object", - "description": "An optional object representing the minimum version of CMake needed to build this project.", + "description": "An optional object representing the minimum version of CMake needed to build this project. Available in version 1 and higher.", "properties": { "major": { "type": "integer", @@ -169,6 +212,33 @@ "type": "integer", "description": "An optional integer representing the patch version." } + } + }, + "cmakeMinimumRequiredV10": { + "type": "object", + "description": "An optional object representing the minimum version of CMake needed to build this project. Available in version 10 and higher.", + "allOf": [ + { "$ref": "#/definitions/cmakeMinimumRequiredPropertiesV10" }, + { "$ref": "#/definitions/cmakeMinimumRequiredPropertiesV1" } + ], + "properties": { + "$comment": {}, + "major": {}, + "minor": {}, + "patch": {} + }, + "additionalProperties": false + }, + "cmakeMinimumRequiredV1": { + "type": "object", + "description": "An optional object representing the minimum version of CMake needed to build this project. Available in version 1 and higher.", + "allOf": [ + { "$ref": "#/definitions/cmakeMinimumRequiredPropertiesV1" } + ], + "properties": { + "major": {}, + "minor": {}, + "patch": {} }, "additionalProperties": false }, @@ -177,12 +247,260 @@ "description": "An optional map containing vendor-specific information. CMake does not interpret the contents of this field except to verify that it is a map if it does exist. However, the keys should be a vendor-specific domain name followed by a /-separated path. For example, the Example IDE 1.0 could use example.com/ExampleIDE/1.0. The value of each field can be anything desired by the vendor, though will typically be a map.", "properties": {} }, + "configurePresetsArchitectureAsStringV1": { + "type": "string", + "description": "An optional string representing the platform for generators that support it." + }, + "configurePresetsArchitectureAsObjectV10": { + "type": "object", + "description": "An optional object representing the platform for generators that support it. Available in version 10 and higher.", + "properties": { + "$comment": { "$ref": "#/definitions/$comment" } + } + }, + "configurePresetsArchitectureAsObjectV1": { + "type": "object", + "description": "An optional object representing the platform for generators that support it. Available in version 1 and higher.", + "properties": { + "value": { + "type": "string", + "description": "An optional string representing the value." + }, + "strategy": { + "type": "string", + "description": "An optional string telling CMake how to handle the field. Valid values are: \"set\" Set the respective value. This will result in an error for generators that do not support the respective field. \"external\" Do not set the value, even if the generator supports it. This is useful if, for example, a preset uses the Ninja generator, and an IDE knows how to set up the Visual C++ environment from the architecture and toolset fields. In that case, CMake will ignore the field, but the IDE can use them to set up the environment before invoking CMake.", + "enum": [ + "set", + "external" + ] + } + } + }, + "configurePresetsArchitectureV10": { + "anyOf": [ + { "$ref": "#/definitions/configurePresetsArchitectureAsStringV1" }, + { + "type": "object", + "description": "An optional object representing the platform for generators that support it. Available in version 10 and higher.", + "allOf": [ + { "$ref": "#/definitions/configurePresetsArchitectureAsObjectV10" }, + { "$ref": "#/definitions/configurePresetsArchitectureAsObjectV1" } + ], + "properties": { + "$comment": {}, + "value": {}, + "strategy": {} + }, + "additionalProperties": false + } + ] + }, + "configurePresetsArchitectureV1": { + "anyOf": [ + { "$ref": "#/definitions/configurePresetsArchitectureAsStringV1" }, + { + "type": "object", + "description": "An optional object representing the platform for generators that support it. Available in version 1 and higher.", + "allOf": [ + { "$ref": "#/definitions/configurePresetsArchitectureAsObjectV1" } + ], + "properties": { + "value": {}, + "strategy": {} + }, + "additionalProperties": false + } + ] + }, + "configurePresetsToolsetAsStringV1": { + "type": "string", + "description": "An optional string representing the toolset for generators that support it." + }, + "configurePresetsToolsetAsObjectV10": { + "type": "object", + "description": "An optional object representing the toolset for generators that support it. Available in version 10 and higher.", + "properties": { + "$comment": { "$ref": "#/definitions/$comment" } + } + }, + "configurePresetsToolsetAsObjectV1": { + "type": "object", + "description": "An optional object representing the toolset for generators that support it. Available in version 1 and higher.", + "properties": { + "value": { + "type": "string", + "description": "An optional string representing the value." + }, + "strategy": { + "type": "string", + "description": "An optional string telling CMake how to handle the field. Valid values are: \"set\" Set the respective value. This will result in an error for generators that do not support the respective field. \"external\" Do not set the value, even if the generator supports it. This is useful if, for example, a preset uses the Ninja generator, and an IDE knows how to set up the Visual C++ environment from the architecture and toolset fields. In that case, CMake will ignore the field, but the IDE can use them to set up the environment before invoking CMake.", + "enum": [ + "set", + "external" + ] + } + } + }, + "configurePresetsToolsetV10": { + "anyOf": [ + { "$ref": "#/definitions/configurePresetsToolsetAsStringV1" }, + { + "type": "object", + "description": "An optional object representing the toolset for generators that support it. Available in version 10 and higher.", + "allOf": [ + { "$ref": "#/definitions/configurePresetsToolsetAsObjectV10" }, + { "$ref": "#/definitions/configurePresetsToolsetAsObjectV1" } + ], + "properties": { + "$comment": {}, + "value": {}, + "strategy": {} + }, + "additionalProperties": false + } + ] + }, + "configurePresetsToolsetV1": { + "anyOf": [ + { "$ref": "#/definitions/configurePresetsToolsetAsStringV1" }, + { + "type": "object", + "description": "An optional object representing the toolset for generators that support it. Available in version 1 and higher.", + "allOf": [ + { "$ref": "#/definitions/configurePresetsToolsetAsObjectV1" } + ], + "properties": { + "value": {}, + "strategy": {} + }, + "additionalProperties": false + } + ] + }, + "configurePresetsCacheVariablesAdditionalPropertiesAsNullV1": { + "type": "null", + "description": "Setting a variable to null causes it to not be set, even if a value was inherited from another preset." + }, + "configurePresetsCacheVariablesAdditionalPropertiesAsBooleanV1": { + "type": "boolean", + "description": "A boolean representing the value of the variable. Equivalent to \"TRUE\" or \"FALSE\"." + }, + "configurePresetsCacheVariablesAdditionalPropertiesAsStringV1": { + "type": "string", + "description": "A string representing the value of the variable (which supports macro expansion)." + }, + "configurePresetsCacheVariablesAdditionalPropertiesAsObjectV10": { + "type": "object", + "description": "An optional object representing the cache variables for generators that support it. Available in version 10 and higher.", + "properties": { + "$comment": { "$ref": "#/definitions/$comment" } + } + }, + "configurePresetsCacheVariablesAdditionalPropertiesAsObjectV1": { + "type": "object", + "description": "An optional object representing the cache variables for generators that support it. Available in version 1 and higher.", + "properties": { + "type": { + "type": "string", + "description": "An optional string representing the type of the variable. It should be BOOL, FILEPATH, PATH, STRING, or INTERNAL." + }, + "value": { + "anyOf": [ + { + "type": "boolean", + "description": "A required boolean representing the value of the variable. Equivalent to \"TRUE\" or \"FALSE\"." + }, + { + "type": "string", + "description": "A required string representing the value of the variable. This field supports macro expansion." + } + ] + } + } + }, + "configurePresetsCacheVariablesAdditionalPropertiesV10": { + "anyOf": [ + { "$ref": "#/definitions/configurePresetsCacheVariablesAdditionalPropertiesAsNullV1" }, + { "$ref": "#/definitions/configurePresetsCacheVariablesAdditionalPropertiesAsBooleanV1" }, + { "$ref": "#/definitions/configurePresetsCacheVariablesAdditionalPropertiesAsStringV1" }, + { + "type": "object", + "description": "An object representing the type and value of the variable. Available in version 10 and higher.", + "allOf": [ + { "$ref": "#/definitions/configurePresetsCacheVariablesAdditionalPropertiesAsObjectV10" }, + { "$ref": "#/definitions/configurePresetsCacheVariablesAdditionalPropertiesAsObjectV1" } + ], + "properties": { + "$comment": {}, + "type": {}, + "value": {} + }, + "required": [ + "value" + ], + "additionalProperties": false + } + ] + }, + "configurePresetsCacheVariablesAdditionalPropertiesV1": { + "anyOf": [ + { "$ref": "#/definitions/configurePresetsCacheVariablesAdditionalPropertiesAsNullV1" }, + { "$ref": "#/definitions/configurePresetsCacheVariablesAdditionalPropertiesAsBooleanV1" }, + { "$ref": "#/definitions/configurePresetsCacheVariablesAdditionalPropertiesAsStringV1" }, + { + "type": "object", + "description": "An object representing the type and value of the variable. Available in version 1 and higher.", + "allOf": [ + { "$ref": "#/definitions/configurePresetsCacheVariablesAdditionalPropertiesAsObjectV1" } + ], + "properties": { + "type": {}, + "value": {} + }, + "required": [ + "value" + ], + "additionalProperties": false + } + ] + }, + "configurePresetsItemsV10": { + "type": "array", + "description": "An optional array of configure preset objects. Available in version 10 and higher.", + "items": { + "type": "object", + "description": "A configure preset object. Available in version 10 and higher.", + "properties": { + "$comment": { "$ref": "#/definitions/$comment" }, + "warnings": { + "properties": { + "$comment": { "$ref": "#/definitions/$comment" } + } + }, + "errors": { + "properties": { + "$comment": { "$ref": "#/definitions/$comment" } + } + }, + "debug": { + "properties": { + "$comment": { "$ref": "#/definitions/$comment" } + } + }, + "trace": { + "properties": { + "$comment": { "$ref": "#/definitions/$comment" } + } + } + } + } + }, "configurePresetsItemsV7": { "type": "array", - "description": "A configure preset object.", + "description": "An optional array of configure preset objects. Available in version 7 and higher.", "items": { "type": "object", - "description": "A configure preset object.", + "description": "A configure preset object. Available in version 7 and higher.", "properties": { "trace": { "type": "object", @@ -224,18 +542,17 @@ "type": "string", "description": "An optional string specifying a path to a trace output file." } - }, - "additionalProperties": false + } } } } }, "configurePresetsItemsV3": { "type": "array", - "description": "A configure preset object.", + "description": "An optional array of configure preset objects. Available in version 3 and higher.", "items": { "type": "object", - "description": "A configure preset object.", + "description": "A configure preset object. Available in version 3 and higher.", "properties": { "binaryDir": { "type": "string", @@ -252,17 +569,16 @@ "installDir": { "type": "string", "description": "An optional string representing the path to the installation directory. This field supports macro expansion. If a relative path is specified, it is calculated relative to the source directory." - }, - "condition": { "$ref": "#/definitions/topCondition" } + } } } }, "configurePresetsItemsV1": { "type": "array", - "description": "An optional array of configure preset objects.", + "description": "An optional array of configure preset objects. Available in version 1 and higher.", "items": { "type": "object", - "description": "A configure preset object.", + "description": "A configure preset object. Available in version 1 and higher.", "properties": { "name": { "type": "string", @@ -308,60 +624,6 @@ "type": "string", "description": "An optional string representing the generator to use for the preset. If generator is not specified, it must be inherited from the inherits preset (unless this preset is hidden). Note that for Visual Studio generators, unlike in the command line -G argument, you cannot include the platform name in the generator name. Use the architecture field instead." }, - "architecture": { - "anyOf": [ - { - "type": "string", - "description": "An optional string representing the platform for generators that support it." - }, - { - "type": "object", - "description": "An optional object representing the platform for generators that support it.", - "properties": { - "value": { - "type": "string", - "description": "An optional string representing the value." - }, - "strategy": { - "type": "string", - "description": "An optional string telling CMake how to handle the field. Valid values are: \"set\" Set the respective value. This will result in an error for generators that do not support the respective field. \"external\" Do not set the value, even if the generator supports it. This is useful if, for example, a preset uses the Ninja generator, and an IDE knows how to set up the Visual C++ environment from the architecture and toolset fields. In that case, CMake will ignore the field, but the IDE can use them to set up the environment before invoking CMake.", - "enum": [ - "set", - "external" - ] - } - }, - "additionalProperties": false - } - ] - }, - "toolset": { - "anyOf": [ - { - "type": "string", - "description": "An optional string representing the toolset for generators that support it." - }, - { - "type": "object", - "description": "An optional object representing the toolset for generators that support it.", - "properties": { - "value": { - "type": "string", - "description": "An optional string representing the value." - }, - "strategy": { - "type": "string", - "description": "An optional string telling CMake how to handle the field. Valid values are: \"set\" Set the respective value. This will result in an error for generators that do not support the respective field. \"external\" Do not set the value, even if the generator supports it. This is useful if, for example, a preset uses the Ninja generator, and an IDE knows how to set up the Visual C++ environment from the architecture and toolset fields. In that case, CMake will ignore the field, but the IDE can use them to set up the environment before invoking CMake.", - "enum": [ - "set", - "external" - ] - } - }, - "additionalProperties": false - } - ] - }, "binaryDir": { "type": "string", "description": "An optional string representing the path to the output binary directory. This field supports macro expansion. If a relative path is specified, it is calculated relative to the source directory. If binaryDir is not specified, it must be inherited from the inherits preset (unless this preset is hidden)." @@ -374,48 +636,6 @@ "type": "object", "description": "An optional map of cache variables. The key is the variable name (which must not be an empty string). Cache variables are inherited through the inherits field, and the preset's variables will be the union of its own cacheVariables and the cacheVariables from all its parents. If multiple presets in this union define the same variable, the standard rules of inherits are applied.", "properties": {}, - "additionalProperties": { - "anyOf": [ - { - "type": "null", - "description": "Setting a variable to null causes it to not be set, even if a value was inherited from another preset." - }, - { - "type": "boolean", - "description": "A boolean representing the value of the variable. Equivalent to \"TRUE\" or \"FALSE\"." - }, - { - "type": "string", - "description": "A string representing the value of the variable (which supports macro expansion)." - }, - { - "type": "object", - "description": "An object representing the type and value of the variable.", - "properties": { - "type": { - "type": "string", - "description": "An optional string representing the type of the variable. It should be BOOL, FILEPATH, PATH, STRING, or INTERNAL." - }, - "value": { - "anyOf": [ - { - "type": "boolean", - "description": "A required boolean representing the value of the variable. Equivalent to \"TRUE\" or \"FALSE\"." - }, - { - "type": "string", - "description": "A required string representing the value of the variable. This field supports macro expansion." - } - ] - } - }, - "required": [ - "value" - ], - "additionalProperties": false - } - ] - }, "propertyNames": { "pattern": "^.+$" } @@ -464,8 +684,7 @@ "type": "boolean", "description": "An optional boolean. Setting this to true is equivalent to passing --check-system-vars on the command line." } - }, - "additionalProperties": false + } }, "errors": { "type": "object", @@ -479,8 +698,7 @@ "type": "boolean", "description": "An optional boolean. Equivalent to passing -Werror=deprecated or -Wno-error=deprecated on the command line. This may not be set to true if warnings.deprecated is set to false." } - }, - "additionalProperties": false + } }, "debug": { "type": "object", @@ -498,19 +716,93 @@ "type": "boolean", "description": "An optional boolean. Setting this to true is equivalent to passing --debug-find on the command line." } + } + } + } + } + }, + "configurePresetsV10": { + "type": "array", + "description": "An optional array of configure preset objects. Available in version 10 and higher.", + "allOf": [ + { "$ref": "#/definitions/configurePresetsItemsV10" }, + { "$ref": "#/definitions/configurePresetsItemsV7" }, + { "$ref": "#/definitions/configurePresetsItemsV3" }, + { "$ref": "#/definitions/configurePresetsItemsV1" } + ], + "items": { + "properties": { + "$comment": {}, + "name": {}, + "hidden": {}, + "inherits": {}, + "vendor": {}, + "displayName": {}, + "description": {}, + "generator": {}, + "architecture": { "$ref": "#/definitions/configurePresetsArchitectureV10" }, + "toolset": { "$ref": "#/definitions/configurePresetsToolsetV10" }, + "toolchainFile": {}, + "binaryDir": {}, + "installDir": {}, + "cmakeExecutable": {}, + "cacheVariables": { + "additionalProperties": { "$ref": "#/definitions/configurePresetsCacheVariablesAdditionalPropertiesV10" } + }, + "environment": {}, + "warnings": { + "properties": { + "$comment": {}, + "dev": {}, + "deprecated": {}, + "uninitialized": {}, + "unusedCli": {}, + "systemVars": {} + }, + "additionalProperties": false + }, + "errors": { + "properties": { + "$comment": {}, + "dev": {}, + "deprecated": {} + }, + "additionalProperties": false + }, + "debug": { + "properties": { + "$comment": {}, + "output": {}, + "tryCompile": {}, + "find": {} + }, + "additionalProperties": false + }, + "condition": { "$ref": "#/definitions/topConditionV10" }, + "trace": { + "properties": { + "$comment": {}, + "mode": {}, + "format": {}, + "source": {}, + "redirect": {} }, "additionalProperties": false } - } + }, + "required": [ + "name" + ], + "additionalProperties": false } }, "configurePresetsV7": { "type": "array", - "description": "An optional array of configure preset objects.", + "description": "An optional array of configure preset objects. Available in version 7 and higher.", "allOf": [ - { "$ref": "#/definitions/configurePresetsItemsV1" }, + { "$ref": "#/definitions/configurePresetsItemsV7" }, { "$ref": "#/definitions/configurePresetsItemsV3" }, - { "$ref": "#/definitions/configurePresetsItemsV7" } + { "$ref": "#/definitions/configurePresetsItemsV1" } ], "items": { "properties": { @@ -521,19 +813,51 @@ "displayName": {}, "description": {}, "generator": {}, - "architecture": {}, - "toolset": {}, + "architecture": { "$ref": "#/definitions/configurePresetsArchitectureV1" }, + "toolset": { "$ref": "#/definitions/configurePresetsToolsetV1" }, "toolchainFile": {}, "binaryDir": {}, "installDir": {}, "cmakeExecutable": {}, - "cacheVariables": {}, + "cacheVariables": { + "additionalProperties": { "$ref": "#/definitions/configurePresetsCacheVariablesAdditionalPropertiesV1" } + }, "environment": {}, - "warnings": {}, - "errors": {}, - "debug": {}, - "condition": {}, - "trace": {} + "warnings": { + "properties": { + "dev": {}, + "deprecated": {}, + "uninitialized": {}, + "unusedCli": {}, + "systemVars": {} + }, + "additionalProperties": false + }, + "errors": { + "properties": { + "dev": {}, + "deprecated": {} + }, + "additionalProperties": false + }, + "debug": { + "properties": { + "output": {}, + "tryCompile": {}, + "find": {} + }, + "additionalProperties": false + }, + "condition": { "$ref": "#/definitions/topConditionV3" }, + "trace": { + "properties": { + "mode": {}, + "format": {}, + "source": {}, + "redirect": {} + }, + "additionalProperties": false + } }, "required": [ "name" @@ -543,10 +867,10 @@ }, "configurePresetsV3": { "type": "array", - "description": "An optional array of configure preset objects.", + "description": "An optional array of configure preset objects. Available in version 3 and higher.", "allOf": [ - { "$ref": "#/definitions/configurePresetsItemsV1" }, - { "$ref": "#/definitions/configurePresetsItemsV3" } + { "$ref": "#/definitions/configurePresetsItemsV3" }, + { "$ref": "#/definitions/configurePresetsItemsV1" } ], "items": { "properties": { @@ -557,18 +881,42 @@ "displayName": {}, "description": {}, "generator": {}, - "architecture": {}, - "toolset": {}, + "architecture": { "$ref": "#/definitions/configurePresetsArchitectureV1" }, + "toolset": { "$ref": "#/definitions/configurePresetsToolsetV1" }, "toolchainFile": {}, "binaryDir": {}, "installDir": {}, "cmakeExecutable": {}, - "cacheVariables": {}, + "cacheVariables": { + "additionalProperties": { "$ref": "#/definitions/configurePresetsCacheVariablesAdditionalPropertiesV1" } + }, "environment": {}, - "warnings": {}, - "errors": {}, - "debug": {}, - "condition": {} + "warnings": { + "properties": { + "dev": {}, + "deprecated": {}, + "uninitialized": {}, + "unusedCli": {}, + "systemVars": {} + }, + "additionalProperties": false + }, + "errors": { + "properties": { + "dev": {}, + "deprecated": {} + }, + "additionalProperties": false + }, + "debug": { + "properties": { + "output": {}, + "tryCompile": {}, + "find": {} + }, + "additionalProperties": false + }, + "condition": { "$ref": "#/definitions/topConditionV3" } }, "required": [ "name" @@ -578,7 +926,7 @@ }, "configurePresetsV1": { "type": "array", - "description": "An optional array of configure preset objects.", + "description": "An optional array of configure preset objects. Available in version 1 and higher.", "allOf": [ { "$ref": "#/definitions/configurePresetsItemsV1" } ], @@ -591,15 +939,39 @@ "displayName": {}, "description": {}, "generator": {}, - "architecture": {}, - "toolset": {}, + "architecture": { "$ref": "#/definitions/configurePresetsArchitectureV1" }, + "toolset": { "$ref": "#/definitions/configurePresetsToolsetV1" }, "binaryDir": {}, "cmakeExecutable": {}, - "cacheVariables": {}, + "cacheVariables": { + "additionalProperties": { "$ref": "#/definitions/configurePresetsCacheVariablesAdditionalPropertiesV1" } + }, "environment": {}, - "warnings": {}, - "errors": {}, - "debug": {} + "warnings": { + "properties": { + "dev": {}, + "deprecated": {}, + "uninitialized": {}, + "unusedCli": {}, + "systemVars": {} + }, + "additionalProperties": false + }, + "errors": { + "properties": { + "dev": {}, + "deprecated": {} + }, + "additionalProperties": false + }, + "debug": { + "properties": { + "output": {}, + "tryCompile": {}, + "find": {} + }, + "additionalProperties": false + } }, "required": [ "name" @@ -607,6 +979,16 @@ "additionalProperties": false } }, + "buildPresetsItemsV10": { + "type": "array", + "description": "An optional array of build preset objects. Used to specify arguments to cmake --build. Available in version 10 and higher.", + "items": { + "type": "object", + "properties": { + "$comment": { "$ref": "#/definitions/$comment" } + } + } + }, "buildPresetsItemsV4": { "type": "array", "description": "An optional array of build preset objects. Used to specify arguments to cmake --build. Available in version 4 and higher.", @@ -625,13 +1007,7 @@ }, "buildPresetsItemsV3": { "type": "array", - "description": "An optional array of build preset objects. Used to specify arguments to cmake --build. Available in version 3 and higher.", - "items": { - "type": "object", - "properties": { - "condition": { "$ref": "#/definitions/topCondition" } - } - } + "description": "An optional array of build preset objects. Used to specify arguments to cmake --build. Available in version 3 and higher." }, "buildPresetsItemsV2": { "type": "array", @@ -748,10 +1124,44 @@ "description": "An optional string representing an option to pass after -- on the command line." } } + } + } + }, + "buildPresetsV10": { + "type": "array", + "description": "An optional array of build preset objects. Used to specify arguments to cmake --build. Available in version 10 and higher.", + "allOf": [ + { "$ref": "#/definitions/buildPresetsItemsV10" }, + { "$ref": "#/definitions/buildPresetsItemsV4" }, + { "$ref": "#/definitions/buildPresetsItemsV3" }, + { "$ref": "#/definitions/buildPresetsItemsV2" } + ], + "items": { + "type": "object", + "properties": { + "$comment": {}, + "name": {}, + "hidden": {}, + "inherits": {}, + "configurePreset": {}, + "vendor": {}, + "displayName": {}, + "description": {}, + "inheritConfigureEnvironment": {}, + "environment": {}, + "jobs": {}, + "targets": {}, + "configuration": {}, + "cleanFirst": {}, + "resolvePackageReferences": {}, + "verbose": {}, + "nativeToolOptions": {}, + "condition": { "$ref": "#/definitions/topConditionV10" } }, "required": [ "name" - ] + ], + "additionalProperties": false } }, "buildPresetsV4": { @@ -781,7 +1191,7 @@ "resolvePackageReferences": {}, "verbose": {}, "nativeToolOptions": {}, - "condition": {} + "condition": { "$ref": "#/definitions/topConditionV3" } }, "required": [ "name" @@ -814,7 +1224,7 @@ "cleanFirst": {}, "verbose": {}, "nativeToolOptions": {}, - "condition": {} + "condition": { "$ref": "#/definitions/topConditionV3" } }, "required": [ "name" @@ -853,6 +1263,129 @@ "additionalProperties": false } }, + "testPresetsFilterIncludeIndexAsStringV2": { + "type": "string", + "description": "An optional string specifying a file with the command line syntax for --tests-information. Available in version 2 and higher." + }, + "testPresetsFilterIncludeIndexAsObjectV10": { + "type": "object", + "description": "An optional object specifying tests to include by test index. Available in version 10 and higher.", + "properties": { + "$comment": { "$ref": "#/definitions/$comment" } + } + }, + "testPresetsFilterIncludeIndexAsObjectV2": { + "type": "object", + "description": "An optional object specifying tests to include by test index. Available in version 2 and higher.", + "properties": { + "start": { + "type": "integer", + "description": "An optional integer specifying a test index to start testing at." + }, + "end": { + "type": "integer", + "description": "An optional integer specifying a test index to stop testing at." + }, + "stride": { + "type": "integer", + "description": "An optional integer specifying the increment." + }, + "specificTests": { + "type": "array", + "description": "An optional array of integers specifying specific test indices to run.", + "items": { + "type": "integer", + "description": "An integer specifying the test to run by index." + } + } + } + }, + "testPresetsFilterIncludeIndexV10": { + "anyOf": [ + { "$ref": "#/definitions/testPresetsFilterIncludeIndexAsStringV2" }, + { + "type": "object", + "description": "An optional object specifying test preset filters. Available in version 10 and higher.", + "allOf": [ + { "$ref": "#/definitions/testPresetsFilterIncludeIndexAsObjectV10" }, + { "$ref": "#/definitions/testPresetsFilterIncludeIndexAsObjectV2" } + ], + "properties": { + "$comment": {}, + "start": {}, + "end": {}, + "stride": {}, + "specificTests": {} + }, + "additionalProperties": false + } + ] + }, + "testPresetsFilterIncludeIndexV2": { + "anyOf": [ + { "$ref": "#/definitions/testPresetsFilterIncludeIndexAsStringV2" }, + { + "type": "object", + "description": "An optional object specifying test preset filters. Available in version 2 and higher.", + "allOf": [ + { "$ref": "#/definitions/testPresetsFilterIncludeIndexAsObjectV2" } + ], + "properties": { + "start": {}, + "end": {}, + "stride": {}, + "specificTests": {} + }, + "additionalProperties": false + } + ] + }, + "testPresetsItemsV10": { + "type": "array", + "description": "An optional array of test preset objects. Used to specify arguments to ctest. Available in version 10 and higher.", + "items": { + "type": "object", + "properties": { + "$comment": { "$ref": "#/definitions/$comment" }, + "filter": { + "type": "object", + "properties": { + "$comment": { "$ref": "#/definitions/$comment" }, + "include": { + "type": "object", + "properties": { + "$comment": { "$ref": "#/definitions/$comment" } + } + }, + "exclude": { + "type": "object", + "properties": { + "$comment": { "$ref": "#/definitions/$comment" }, + "fixtures": { + "type": "object", + "properties": { + "$comment": { "$ref": "#/definitions/$comment" } + } + } + } + } + } + }, + "execution": { + "type": "object", + "properties": { + "$comment": { "$ref": "#/definitions/$comment" }, + "repeat": { + "type": "object", + "properties": { + "$comment": { "$ref": "#/definitions/$comment" } + } + } + } + } + } + } + }, "testPresetsItemsV6": { "type": "array", "description": "An optional array of test preset objects. Used to specify arguments to ctest. Available in version 6 and higher.", @@ -896,13 +1429,7 @@ }, "testPresetsItemsV3": { "type": "array", - "description": "An optional array of test preset objects. Used to specify arguments to ctest. Available in version 3 and higher.", - "items": { - "type": "object", - "properties": { - "condition": { "$ref": "#/definitions/topCondition" } - } - } + "description": "An optional array of test preset objects. Used to specify arguments to ctest. Available in version 3 and higher." }, "testPresetsItemsV2": { "type": "array", @@ -1060,47 +1587,11 @@ "type": "string", "description": "An optional string specifying a regex for test labels. Equivalent to passing --label-regex on the command line." }, - "index": { - "anyOf": [ - { - "type": "object", - "description": "An optional object specifying tests to include by test index.", - "properties": { - "start": { - "type": "integer", - "description": "An optional integer specifying a test index to start testing at." - }, - "end": { - "type": "integer", - "description": "An optional integer specifying a test index to stop testing at." - }, - "stride": { - "type": "integer", - "description": "An optional integer specifying the increment." - }, - "specificTests": { - "type": "array", - "description": "An optional array of integers specifying specific test indices to run.", - "items": { - "type": "integer", - "description": "An integer specifying the test to run by index." - } - } - }, - "additionalProperties": false - }, - { - "type": "string", - "description": "An optional string specifying a file with the command line syntax for --tests-information." - } - ] - }, "useUnion": { "type": "boolean", "description": "An optional boolean. Equivalent to passing --union on the command line." } - }, - "additionalProperties": false + } }, "exclude": { "type": "object", @@ -1130,13 +1621,11 @@ "type": "string", "description": "An optional string specifying a regex for text fixtures to exclude from adding cleanup tests. Equivalent to --fixture-exclude-cleanup on the command line." } - }, - "additionalProperties": false + } } } } - }, - "additionalProperties": false + } }, "execution": { "type": "object", @@ -1184,11 +1673,7 @@ "type": "integer", "description": "A required integer." } - }, - "required": [ - "mode", "count" - ], - "additionalProperties": false + } }, "interactiveDebugging": { "type": "boolean", @@ -1209,23 +1694,137 @@ "default", "error", "ignore" ] } + } + } + } + } + }, + "testPresetsV10": { + "type": "array", + "description": "An optional array of test preset objects. Used to specify arguments to ctest. Available in version 10 and higher.", + "allOf": [ + { "$ref": "#/definitions/testPresetsItemsV10" }, + { "$ref": "#/definitions/testPresetsItemsV6" }, + { "$ref": "#/definitions/testPresetsItemsV5" }, + { "$ref": "#/definitions/testPresetsItemsV3" }, + { "$ref": "#/definitions/testPresetsItemsV2" } + ], + "items": { + "type": "object", + "properties": { + "$comment": {}, + "name": {}, + "hidden": {}, + "inherits": {}, + "configurePreset": {}, + "vendor": {}, + "displayName": {}, + "description": {}, + "inheritConfigureEnvironment": {}, + "environment": {}, + "configuration": {}, + "overwriteConfigurationFile": {}, + "output": { + "type": "object", + "properties": { + "shortProgress": {}, + "verbosity": {}, + "debug": {}, + "outputOnFailure": {}, + "quiet": {}, + "outputLogFile": {}, + "outputJUnitFile": {}, + "labelSummary": {}, + "subprojectSummary": {}, + "maxPassedTestOutputSize": {}, + "maxFailedTestOutputSize": {}, + "maxTestNameWidth": {}, + "testOutputTruncation": {} }, "additionalProperties": false - } + }, + "filter": { + "type": "object", + "properties": { + "$comment": {}, + "include": { + "type": "object", + "properties": { + "$comment": {}, + "name": {}, + "label": {}, + "useUnion": {}, + "index": { "$ref": "#/definitions/testPresetsFilterIncludeIndexV10" } + }, + "additionalProperties": false + }, + "exclude": { + "type": "object", + "properties": { + "$comment": {}, + "name": {}, + "label": {}, + "fixtures": { + "type": "object", + "properties": { + "$comment": {}, + "any": {}, + "setup": {}, + "cleanup": {} + }, + "additionalProperties": false + } + }, + "additionalProperties": false + } + }, + "additionalProperties": false + }, + "execution": { + "type": "object", + "properties": { + "$comment": {}, + "stopOnFailure": {}, + "enableFailover": {}, + "jobs": {}, + "resourceSpecFile": {}, + "testLoad": {}, + "showOnly": {}, + "repeat": { + "type": "object", + "properties": { + "$comment": {}, + "mode": {}, + "count": {} + }, + "required": [ + "mode", "count" + ], + "additionalProperties": false + }, + "interactiveDebugging": {}, + "scheduleRandom": {}, + "timeout": {}, + "noTestsAction": {} + }, + "additionalProperties": false + }, + "condition": { "$ref": "#/definitions/topConditionV10" } }, "required": [ "name" - ] + ], + "additionalProperties": false } }, "testPresetsV6": { "type": "array", "description": "An optional array of test preset objects. Used to specify arguments to ctest. Available in version 6 and higher.", "allOf": [ - { "$ref": "#/definitions/testPresetsItemsV2" }, - { "$ref": "#/definitions/testPresetsItemsV3" }, + { "$ref": "#/definitions/testPresetsItemsV6" }, { "$ref": "#/definitions/testPresetsItemsV5" }, - { "$ref": "#/definitions/testPresetsItemsV6" } + { "$ref": "#/definitions/testPresetsItemsV3" }, + { "$ref": "#/definitions/testPresetsItemsV2" } ], "items": { "type": "object", @@ -1260,9 +1859,67 @@ }, "additionalProperties": false }, - "filter": {}, - "execution": {}, - "condition": {} + "filter": { + "type": "object", + "properties": { + "include": { + "type": "object", + "properties": { + "name": {}, + "label": {}, + "useUnion": {}, + "index": { "$ref": "#/definitions/testPresetsFilterIncludeIndexV2" } + }, + "additionalProperties": false + }, + "exclude": { + "type": "object", + "properties": { + "name": {}, + "label": {}, + "fixtures": { + "type": "object", + "properties": { + "any": {}, + "setup": {}, + "cleanup": {} + }, + "additionalProperties": false + } + }, + "additionalProperties": false + } + }, + "additionalProperties": false + }, + "execution": { + "type": "object", + "properties": { + "stopOnFailure": {}, + "enableFailover": {}, + "jobs": {}, + "resourceSpecFile": {}, + "testLoad": {}, + "showOnly": {}, + "repeat": { + "type": "object", + "properties": { + "mode": {}, + "count": {} + }, + "required": [ + "mode", "count" + ], + "additionalProperties": false + }, + "interactiveDebugging": {}, + "scheduleRandom": {}, + "timeout": {}, + "noTestsAction": {} + }, + "additionalProperties": false + }, + "condition": { "$ref": "#/definitions/topConditionV3" } }, "required": [ "name" @@ -1274,9 +1931,9 @@ "type": "array", "description": "An optional array of test preset objects. Used to specify arguments to ctest. Available in version 5 and higher.", "allOf": [ - { "$ref": "#/definitions/testPresetsItemsV2" }, + { "$ref": "#/definitions/testPresetsItemsV5" }, { "$ref": "#/definitions/testPresetsItemsV3" }, - { "$ref": "#/definitions/testPresetsItemsV5" } + { "$ref": "#/definitions/testPresetsItemsV2" } ], "items": { "type": "object", @@ -1310,9 +1967,67 @@ }, "additionalProperties": false }, - "filter": {}, - "execution": {}, - "condition": {} + "filter": { + "type": "object", + "properties": { + "include": { + "type": "object", + "properties": { + "name": {}, + "label": {}, + "useUnion": {}, + "index": { "$ref": "#/definitions/testPresetsFilterIncludeIndexV2" } + }, + "additionalProperties": false + }, + "exclude": { + "type": "object", + "properties": { + "name": {}, + "label": {}, + "fixtures": { + "type": "object", + "properties": { + "any": {}, + "setup": {}, + "cleanup": {} + }, + "additionalProperties": false + } + }, + "additionalProperties": false + } + }, + "additionalProperties": false + }, + "execution": { + "type": "object", + "properties": { + "stopOnFailure": {}, + "enableFailover": {}, + "jobs": {}, + "resourceSpecFile": {}, + "testLoad": {}, + "showOnly": {}, + "repeat": { + "type": "object", + "properties": { + "mode": {}, + "count": {} + }, + "required": [ + "mode", "count" + ], + "additionalProperties": false + }, + "interactiveDebugging": {}, + "scheduleRandom": {}, + "timeout": {}, + "noTestsAction": {} + }, + "additionalProperties": false + }, + "condition": { "$ref": "#/definitions/topConditionV3" } }, "required": [ "name" @@ -1324,8 +2039,8 @@ "type": "array", "description": "An optional array of test preset objects. Used to specify arguments to ctest. Available in version 3 and higher.", "allOf": [ - { "$ref": "#/definitions/testPresetsItemsV2" }, - { "$ref": "#/definitions/testPresetsItemsV3" } + { "$ref": "#/definitions/testPresetsItemsV3" }, + { "$ref": "#/definitions/testPresetsItemsV2" } ], "items": { "type": "object", @@ -1358,9 +2073,67 @@ }, "additionalProperties": false }, - "filter": {}, - "execution": {}, - "condition": {} + "filter": { + "type": "object", + "properties": { + "include": { + "type": "object", + "properties": { + "name": {}, + "label": {}, + "useUnion": {}, + "index": { "$ref": "#/definitions/testPresetsFilterIncludeIndexV2" } + }, + "additionalProperties": false + }, + "exclude": { + "type": "object", + "properties": { + "name": {}, + "label": {}, + "fixtures": { + "type": "object", + "properties": { + "any": {}, + "setup": {}, + "cleanup": {} + }, + "additionalProperties": false + } + }, + "additionalProperties": false + } + }, + "additionalProperties": false + }, + "execution": { + "type": "object", + "properties": { + "stopOnFailure": {}, + "enableFailover": {}, + "jobs": {}, + "resourceSpecFile": {}, + "testLoad": {}, + "showOnly": {}, + "repeat": { + "type": "object", + "properties": { + "mode": {}, + "count": {} + }, + "required": [ + "mode", "count" + ], + "additionalProperties": false + }, + "interactiveDebugging": {}, + "scheduleRandom": {}, + "timeout": {}, + "noTestsAction": {} + }, + "additionalProperties": false + }, + "condition": { "$ref": "#/definitions/topConditionV3" } }, "required": [ "name" @@ -1405,8 +2178,66 @@ }, "additionalProperties": false }, - "filter": {}, - "execution": {} + "filter": { + "type": "object", + "properties": { + "include": { + "type": "object", + "properties": { + "name": {}, + "label": {}, + "useUnion": {}, + "index": { "$ref": "#/definitions/testPresetsFilterIncludeIndexV2" } + }, + "additionalProperties": false + }, + "exclude": { + "type": "object", + "properties": { + "name": {}, + "label": {}, + "fixtures": { + "type": "object", + "properties": { + "any": {}, + "setup": {}, + "cleanup": {} + }, + "additionalProperties": false + } + }, + "additionalProperties": false + } + }, + "additionalProperties": false + }, + "execution": { + "type": "object", + "properties": { + "stopOnFailure": {}, + "enableFailover": {}, + "jobs": {}, + "resourceSpecFile": {}, + "testLoad": {}, + "showOnly": {}, + "repeat": { + "type": "object", + "properties": { + "mode": {}, + "count": {} + }, + "required": [ + "mode", "count" + ], + "additionalProperties": false + }, + "interactiveDebugging": {}, + "scheduleRandom": {}, + "timeout": {}, + "noTestsAction": {} + }, + "additionalProperties": false + } }, "required": [ "name" @@ -1414,6 +2245,22 @@ "additionalProperties": false } }, + "packagePresetsItemsV10": { + "type": "array", + "description": "An optional array of package preset objects. Used to specify arguments to cpack. Available in version 10 and higher.", + "items": { + "type": "object", + "properties": { + "$comment": { "$ref": "#/definitions/$comment" }, + "output": { + "type": "object", + "properties": { + "$comment": { "$ref": "#/definitions/$comment" } + } + } + } + } + }, "packagePresetsItemsV6": { "type": "array", "description": "An optional array of package preset objects. Used to specify arguments to cpack. Available in version 6 and higher.", @@ -1489,7 +2336,6 @@ "pattern": "^.+$" } }, - "condition": { "$ref": "#/definitions/topCondition" }, "generators": { "type": "array", "description": "An optional list of strings representing generators for CPack to use.", @@ -1530,8 +2376,7 @@ "type": "boolean", "description": "An optional boolean specifying whether or not to print verbosely. A value of true is equivalent to passing --verbose on the command line." } - }, - "additionalProperties": false + } }, "packageName": { "type": "string", @@ -1549,10 +2394,52 @@ "type": "string", "description": "An optional string representing the vendor name." } + } + } + }, + "packagePresetsV10": { + "type": "array", + "description": "An optional array of package preset objects. Used to specify arguments to cpack. Available in version 10 and higher.", + "allOf": [ + { "$ref": "#/definitions/packagePresetsItemsV10" }, + { "$ref": "#/definitions/packagePresetsItemsV6" } + ], + "items": { + "type": "object", + "properties": { + "$comment": {}, + "name": {}, + "hidden": {}, + "inherits": {}, + "configurePreset": {}, + "vendor": {}, + "displayName": {}, + "description": {}, + "inheritConfigureEnvironment": {}, + "environment": {}, + "condition": { "$ref": "#/definitions/topConditionV10" }, + "generators": {}, + "configurations": {}, + "variables": {}, + "configFile": {}, + "output": { + "type": "object", + "properties": { + "$comment": {}, + "debug": {}, + "verbose": {} + }, + "additionalProperties": false + }, + "packageName": {}, + "packageVersion": {}, + "packageDirectory": {}, + "vendorName": {} }, "required": [ "name" - ] + ], + "additionalProperties": false } }, "packagePresetsV6": { @@ -1573,12 +2460,19 @@ "description": {}, "inheritConfigureEnvironment": {}, "environment": {}, - "condition": {}, + "condition": { "$ref": "#/definitions/topConditionV3" }, "generators": {}, "configurations": {}, "variables": {}, "configFile": {}, - "output": {}, + "output": { + "type": "object", + "properties": { + "debug": {}, + "verbose": {} + }, + "additionalProperties": false + }, "packageName": {}, "packageVersion": {}, "packageDirectory": {}, @@ -1590,6 +2484,25 @@ "additionalProperties": false } }, + "workflowPresetsItemsV10": { + "type": "array", + "description": "An optional array of workflow preset objects. Used to execute configure, build, test, and package presets in order. Available in version 10 and higher.", + "items": { + "type": "object", + "properties": { + "$comment": { "$ref": "#/definitions/$comment" }, + "steps": { + "type": "array", + "items": { + "type": "object", + "properties": { + "$comment": { "$ref": "#/definitions/$comment" } + } + } + } + } + } + }, "workflowPresetsItemsV6": { "type": "array", "description": "An optional array of workflow preset objects. Used to execute configure, build, test, and package presets in order. Available in version 6 and higher.", @@ -1630,6 +2543,35 @@ "description": "A required string representing the name of the configure, build, test, or package preset to run as this workflow step.", "minLength": 1 } + } + } + } + } + } + }, + "workflowPresetsV10": { + "type": "array", + "description": "An optional array of workflow preset objects. Used to execute configure, build, test, and package presets in order. Available in version 10 and higher.", + "allOf": [ + { "$ref": "#/definitions/workflowPresetsItemsV10" }, + { "$ref": "#/definitions/workflowPresetsItemsV6" } + ], + "items": { + "type": "object", + "properties": { + "$comment": {}, + "name": {}, + "vendor": {}, + "displayName": {}, + "description": {}, + "steps": { + "type": "array", + "items": { + "type": "object", + "properties": { + "$comment": {}, + "type": {}, + "name": {} }, "required": [ "type", @@ -1659,7 +2601,21 @@ "vendor": {}, "displayName": {}, "description": {}, - "steps": {} + "steps": { + "type": "array", + "items": { + "type": "object", + "properties": { + "type": {}, + "name": {} + }, + "required": [ + "type", + "name" + ], + "additionalProperties": false + } + } }, "required": [ "name", @@ -1668,24 +2624,154 @@ "additionalProperties": false } }, - "condition": { - "anyOf": [ - { + "conditionAsBooleanV3": { + "type": "boolean", + "description": "A boolean which provides a constant value for the condition's evaluation." + }, + "conditionAsObjectConstV10": { + "type": "object", + "properties": { + "$comment": { "$ref": "#/definitions/$comment" } + } + }, + "conditionAsObjectConstV3": { + "type": "object", + "properties": { + "type": { + "type": "string", + "description": "A required string specifying the type of the condition.", + "const": "const" + }, + "value": { "type": "boolean", - "description": "A boolean which provides a constant value for the condition's evaluation." + "description": "A required boolean which provides a constant value for the condition's evaluation." + } + } + }, + "conditionAsObjectEqualsV10": { + "type": "object", + "properties": { + "$comment": { "$ref": "#/definitions/$comment" } + } + }, + "conditionAsObjectEqualsV3": { + "type": "object", + "properties": { + "type": { + "type": "string", + "description": "A required string specifying the type of the condition.", + "enum": [ "equals", "notEquals" ] + }, + "lhs": { + "type": "string", + "description": "First string to compare. This field supports macro expansion." + }, + "rhs": { + "type": "string", + "description": "Second string to compare. This field supports macro expansion." + } + } + }, + "conditionAsObjectInListV10": { + "type": "object", + "properties": { + "$comment": { "$ref": "#/definitions/$comment" } + } + }, + "conditionAsObjectInListV3": { + "type": "object", + "properties": { + "type": { + "type": "string", + "description": "A required string specifying the type of the condition.", + "enum": [ "inList", "notInList" ] + }, + "string": { + "type": "string", + "description": "A required string to search for. This field supports macro expansion." + }, + "list": { + "type": "array", + "description": "A required list of strings to search. This field supports macro expansion, and uses short-circuit evaluation.", + "items": { + "type": "string" + } + } + } + }, + "conditionAsObjectMatchesV10": { + "type": "object", + "properties": { + "$comment": { "$ref": "#/definitions/$comment" } + } + }, + "conditionAsObjectMatchesV3": { + "type": "object", + "properties": { + "type": { + "type": "string", + "description": "A required string specifying the type of the condition.", + "enum": [ "matches", "notMatches" ] + }, + "string": { + "type": "string", + "description": "A required string to search. This field supports macro expansion." + }, + "regex": { + "type": "string", + "description": "A required regular expression to search for. This field supports macro expansion." + } + } + }, + "conditionAsObjectAggregationV10": { + "type": "object", + "properties": { + "$comment": { "$ref": "#/definitions/$comment" } + } + }, + "conditionAsObjectAggregationV3": { + "type": "object", + "properties": { + "type": { + "type": "string", + "description": "A required string specifying the type of the condition.", + "enum": [ "anyOf", "allOf" ] }, + "conditions": { + "type": "array", + "description": "A required array of condition objects. These conditions use short-circuit evaluation." + } + } + }, + "conditionAsObjectNotV10": { + "type": "object", + "properties": { + "$comment": { "$ref": "#/definitions/$comment" } + } + }, + "conditionAsObjectNotV3": { + "type": "object", + "properties": { + "type": { + "type": "string", + "description": "A required string specifying the type of the condition.", + "const": "not" + } + } + }, + "conditionV10": { + "anyOf": [ + { "$ref": "#/definitions/conditionAsBooleanV3" }, { "type": "object", + "allOf": [ + { "$ref": "#/definitions/conditionAsObjectConstV10" }, + { "$ref": "#/definitions/conditionAsObjectConstV3" } + ], "properties": { - "type": { - "type": "string", - "description": "A required string specifying the type of the condition.", - "const": "const" - }, - "value": { - "type": "boolean", - "description": "A required boolean which provides a constant value for the condition's evaluation." - } + "$comment": {}, + "type": {}, + "value": {} }, "required": [ "type", @@ -1695,20 +2781,15 @@ }, { "type": "object", + "allOf": [ + { "$ref": "#/definitions/conditionAsObjectEqualsV10" }, + { "$ref": "#/definitions/conditionAsObjectEqualsV3" } + ], "properties": { - "type": { - "type": "string", - "description": "A required string specifying the type of the condition.", - "const": "equals" - }, - "lhs": { - "type": "string", - "description": "First string to compare. This field supports macro expansion." - }, - "rhs": { - "type": "string", - "description": "Second string to compare. This field supports macro expansion." - } + "$comment": {}, + "type": {}, + "lhs": {}, + "rhs": {} }, "required": [ "type", @@ -1719,162 +2800,160 @@ }, { "type": "object", + "allOf": [ + { "$ref": "#/definitions/conditionAsObjectInListV10" }, + { "$ref": "#/definitions/conditionAsObjectInListV3" } + ], "properties": { - "type": { - "type": "string", - "description": "A required string specifying the type of the condition.", - "const": "notEquals" - }, - "lhs": { - "type": "string", - "description": "First string to compare. This field supports macro expansion." - }, - "rhs": { - "type": "string", - "description": "Second string to compare. This field supports macro expansion." - } + "$comment": {}, + "type": {}, + "string": {}, + "list": {} }, "required": [ "type", - "lhs", - "rhs" + "string", + "list" ], "additionalProperties": false }, { "type": "object", + "allOf": [ + { "$ref": "#/definitions/conditionAsObjectMatchesV10" }, + { "$ref": "#/definitions/conditionAsObjectMatchesV3" } + ], "properties": { - "type": { - "type": "string", - "description": "A required string specifying the type of the condition.", - "const": "inList" - }, - "string": { - "type": "string", - "description": "A required string to search for. This field supports macro expansion." - }, - "list": { - "type": "array", - "description": "A required list of strings to search. This field supports macro expansion, and uses short-circuit evaluation.", - "items": { - "type": "string" - } - } + "$comment": {}, + "type": {}, + "string": {}, + "regex": {} }, "required": [ "type", "string", - "list" + "regex" ], "additionalProperties": false }, { "type": "object", + "allOf": [ + { "$ref": "#/definitions/conditionAsObjectAggregationV10" }, + { "$ref": "#/definitions/conditionAsObjectAggregationV3" } + ], "properties": { - "type": { - "type": "string", - "description": "A required string specifying the type of the condition.", - "const": "notInList" - }, - "string": { - "type": "string", - "description": "A required string to search for. This field supports macro expansion." - }, - "list": { + "$comment": {}, + "type": {}, + "conditions": { "type": "array", - "description": "A required list of strings to search. This field supports macro expansion, and uses short-circuit evaluation.", - "items": { - "type": "string" - } + "items": { "$ref": "#/definitions/conditionV10" } } }, "required": [ "type", - "string", - "list" + "conditions" ], "additionalProperties": false }, { "type": "object", + "allOf": [ + { "$ref": "#/definitions/conditionAsObjectNotV10" }, + { "$ref": "#/definitions/conditionAsObjectNotV3" } + ], "properties": { - "type": { - "type": "string", - "description": "A required string specifying the type of the condition.", - "const": "matches" - }, - "string": { - "type": "string", - "description": "A required string to search. This field supports macro expansion." - }, - "regex": { - "type": "string", - "description": "A required regular expression to search for. This field supports macro expansion." - } + "$comment": {}, + "type": {}, + "condition": { "$ref": "#/definitions/conditionV10" } }, "required": [ "type", - "string", - "regex" + "condition" + ], + "additionalProperties": false + } + ] + }, + "conditionV3": { + "anyOf": [ + { "$ref": "#/definitions/conditionAsBooleanV3" }, + { + "type": "object", + "allOf": [ + { "$ref": "#/definitions/conditionAsObjectConstV3" } + ], + "properties": { + "type": {}, + "value": {} + }, + "required": [ + "type", + "value" ], "additionalProperties": false }, { "type": "object", + "allOf": [ + { "$ref": "#/definitions/conditionAsObjectEqualsV3" } + ], "properties": { - "type": { - "type": "string", - "description": "A required string specifying the type of the condition.", - "const": "notMatches" - }, - "string": { - "type": "string", - "description": "A required string to search. This field supports macro expansion." - }, - "regex": { - "type": "string", - "description": "A required regular expression to search for. This field supports macro expansion." - } + "type": {}, + "lhs": {}, + "rhs": {} + }, + "required": [ + "type", + "lhs", + "rhs" + ], + "additionalProperties": false + }, + { + "type": "object", + "allOf": [ + { "$ref": "#/definitions/conditionAsObjectInListV3" } + ], + "properties": { + "type": {}, + "string": {}, + "list": {} }, "required": [ "type", "string", - "regex" + "list" ], "additionalProperties": false }, { "type": "object", + "allOf": [ + { "$ref": "#/definitions/conditionAsObjectMatchesV3" } + ], "properties": { - "type": { - "type": "string", - "description": "A required string specifying the type of the condition.", - "const": "anyOf" - }, - "conditions": { - "type": "array", - "description": "A required array of condition objects. These conditions use short-circuit evaluation.", - "items": { "$ref": "#/definitions/condition" } - } + "type": {}, + "string": {}, + "regex": {} }, "required": [ "type", - "conditions" + "string", + "regex" ], "additionalProperties": false }, { "type": "object", + "allOf": [ + { "$ref": "#/definitions/conditionAsObjectAggregationV3" } + ], "properties": { - "type": { - "type": "string", - "description": "A required string specifying the type of the condition.", - "const": "allOf" - }, + "type": {}, "conditions": { "type": "array", - "description": "A required array of condition objects. These conditions use short-circuit evaluation.", - "items": { "$ref": "#/definitions/condition" } + "items": { "$ref": "#/definitions/conditionV3" } } }, "required": [ @@ -1885,13 +2964,12 @@ }, { "type": "object", + "allOf": [ + { "$ref": "#/definitions/conditionAsObjectNotV3" } + ], "properties": { - "type": { - "type": "string", - "description": "A required string specifying the type of the condition.", - "const": "not" - }, - "condition": { "$ref": "#/definitions/condition" } + "type": {}, + "condition": { "$ref": "#/definitions/conditionV3" } }, "required": [ "type", @@ -1901,13 +2979,20 @@ } ] }, - "topCondition": { + "topConditionAsNullV3": { + "type": "null", + "description": "Null indicates that the condition always evaluates to true and is not inherited." + }, + "topConditionV10": { "anyOf": [ - { "$ref": "#/definitions/condition" }, - { - "type": "null", - "description": "Null indicates that the condition always evaluates to true and is not inherited." - } + { "$ref": "#/definitions/conditionV10" }, + { "$ref": "#/definitions/topConditionAsNullV3" } + ] + }, + "topConditionV3": { + "anyOf": [ + { "$ref": "#/definitions/conditionV3" }, + { "$ref": "#/definitions/topConditionAsNullV3" } ] }, "include": { diff --git a/Help/policy/CMP0171.rst b/Help/policy/CMP0171.rst new file mode 100644 index 0000000..c364bf4 --- /dev/null +++ b/Help/policy/CMP0171.rst @@ -0,0 +1,26 @@ +CMP0171 +------- + +.. versionadded:: 3.31 + +``codegen`` is a reserved target name. + +CMake 3.30 and earlier did not reserve ``codegen`` as a builtin target name, +leaving projects free to create their own target with that name. +CMake 3.31 and later prefer to reserve ``codegen`` as a builtin target name +to drive custom commands created with the ``CODEGEN`` option to +:command:`add_custom_command`. In order to support building the ``codegen`` +target in scripted environments, e.g., ``cmake --build . --target codegen``, +the ``codegen`` target needs to be generated even if no custom commands +use the ``CODEGEN`` option. This policy provides compatibility for projects +that have not been updated to avoid creating a target named ``codegen``. + +The ``OLD`` behavior of this policy allows projects to create a target +with the name ``codegen``. The ``NEW`` behavior halts with a fatal error +if a target with the name ``codegen`` is created. + +.. |INTRODUCED_IN_CMAKE_VERSION| replace:: 3.31 +.. |WARNS_OR_DOES_NOT_WARN| replace:: warns +.. include:: STANDARD_ADVICE.txt + +.. include:: DEPRECATED.txt diff --git a/Help/prop_tgt/MACOSX_FRAMEWORK_INFO_PLIST.rst b/Help/prop_tgt/MACOSX_FRAMEWORK_INFO_PLIST.rst index 82fdcc0..a1f7c66 100644 --- a/Help/prop_tgt/MACOSX_FRAMEWORK_INFO_PLIST.rst +++ b/Help/prop_tgt/MACOSX_FRAMEWORK_INFO_PLIST.rst @@ -12,12 +12,20 @@ file name which may be a full path. The following target properties may be set to specify content to be configured into the file: +``MACOSX_FRAMEWORK_BUNDLE_NAME`` + .. versionadded:: 3.31 + + Sets ``CFBundleName``. + ``MACOSX_FRAMEWORK_BUNDLE_VERSION`` Sets ``CFBundleVersion``. + ``MACOSX_FRAMEWORK_ICON_FILE`` Sets ``CFBundleIconFile``. + ``MACOSX_FRAMEWORK_IDENTIFIER`` Sets ``CFBundleIdentifier``. + ``MACOSX_FRAMEWORK_SHORT_VERSION_STRING`` Sets ``CFBundleShortVersionString``. diff --git a/Help/prop_tgt/VS_FRAMEWORK_REFERENCES.rst b/Help/prop_tgt/VS_FRAMEWORK_REFERENCES.rst new file mode 100644 index 0000000..925ac68 --- /dev/null +++ b/Help/prop_tgt/VS_FRAMEWORK_REFERENCES.rst @@ -0,0 +1,12 @@ +VS_FRAMEWORK_REFERENCES +----------------------- + +.. versionadded:: 3.31 + +Visual Studio framework references. +Specify a :ref:`semicolon-separated list <CMake Language Lists>` of framework references +to be added to a generated Visual Studio project. For example: + +* "Microsoft.WindowsDesktop.App.WPF" for WPF applications +* "Microsoft.WindowsDesktop.App.WindowsForms" for WinForms applications +* "Microsoft.WindowsDesktop.App" for applications using both frameworks diff --git a/Help/release/dev/0-sample-topic.rst b/Help/release/dev/0-sample-topic.rst new file mode 100644 index 0000000..e4cc01e --- /dev/null +++ b/Help/release/dev/0-sample-topic.rst @@ -0,0 +1,7 @@ +0-sample-topic +-------------- + +* This is a sample release note for the change in a topic. + Developers should add similar notes for each topic branch + making a noteworthy change. Each document should be named + and titled to match the topic name to avoid merge conflicts. diff --git a/Help/release/dev/apple-framework-bundle-name.rst b/Help/release/dev/apple-framework-bundle-name.rst new file mode 100644 index 0000000..541845b --- /dev/null +++ b/Help/release/dev/apple-framework-bundle-name.rst @@ -0,0 +1,6 @@ +apple-framework-bundle-name +--------------------------- + +* The :prop_tgt:`MACOSX_FRAMEWORK_BUNDLE_NAME <MACOSX_FRAMEWORK_INFO_PLIST>` + target property was added to set the ``CFBundleName`` key in an Apple + :prop_tgt:`FRAMEWORK`'s ``Info.plist`` file. diff --git a/Help/release/dev/codegen.rst b/Help/release/dev/codegen.rst new file mode 100644 index 0000000..e8b61c9 --- /dev/null +++ b/Help/release/dev/codegen.rst @@ -0,0 +1,10 @@ +codegen +------- + +* The :ref:`Ninja Generators` and :ref:`Makefile Generators` now produce + a ``codegen`` build target. See policy :policy:`CMP0171`. It drives a + subset of the build graph sufficient to run custom commands created with + :command:`add_custom_command`'s new ``CODEGEN`` option. + +* The :command:`add_custom_command` command gained a ``CODEGEN`` option + to mark a custom commands outputs as dependencies of a ``codegen`` target. diff --git a/Help/release/dev/cpack-debian-multiarch.rst b/Help/release/dev/cpack-debian-multiarch.rst new file mode 100644 index 0000000..f593103 --- /dev/null +++ b/Help/release/dev/cpack-debian-multiarch.rst @@ -0,0 +1,6 @@ +cpack-debian-multiarch +---------------------- + +* The :cpack_gen:`CPack DEB Generator` gained a + :variable:`CPACK_DEBIAN_PACKAGE_MULTIARCH` option + to support multi-arch packages. diff --git a/Help/release/dev/cpack-rpm-zstd.rst b/Help/release/dev/cpack-rpm-zstd.rst new file mode 100644 index 0000000..828d5f6 --- /dev/null +++ b/Help/release/dev/cpack-rpm-zstd.rst @@ -0,0 +1,5 @@ +cpack-rpm-zstd +-------------- + +* The :cpack_gen:`CPack RPM Generator` gained support for ``zstd`` as a + :variable:`CPACK_RPM_COMPRESSION_TYPE` value. diff --git a/Help/release/dev/preset-comments.rst b/Help/release/dev/preset-comments.rst new file mode 100644 index 0000000..0d0e768 --- /dev/null +++ b/Help/release/dev/preset-comments.rst @@ -0,0 +1,5 @@ +preset-comments +--------------- + +* Preset files may now include comments using the key ``$comment`` + at any level within the JSON object to provide documentation. diff --git a/Help/release/dev/vs-framework-references.rst b/Help/release/dev/vs-framework-references.rst new file mode 100644 index 0000000..1f50b50 --- /dev/null +++ b/Help/release/dev/vs-framework-references.rst @@ -0,0 +1,5 @@ +vs-framework-references +----------------------- + +* The :prop_tgt:`VS_FRAMEWORK_REFERENCES` target property was added + to tell :ref:`Visual Studio Generators` to add framework references. diff --git a/Help/release/index.rst b/Help/release/index.rst index 56bbf50..fbff07b 100644 --- a/Help/release/index.rst +++ b/Help/release/index.rst @@ -7,6 +7,8 @@ CMake Release Notes This file should include the adjacent "dev.txt" file in development versions but not in release versions. +.. include:: dev.txt + Releases ======== diff --git a/Modules/CMakeASM_MARMASMInformation.cmake b/Modules/CMakeASM_MARMASMInformation.cmake index a47f7c2..51bd313 100644 --- a/Modules/CMakeASM_MARMASMInformation.cmake +++ b/Modules/CMakeASM_MARMASMInformation.cmake @@ -9,6 +9,7 @@ set(ASM_DIALECT "_MARMASM") set(CMAKE_ASM${ASM_DIALECT}_SOURCE_FILE_EXTENSIONS asm) set(CMAKE_ASM${ASM_DIALECT}_COMPILE_OBJECT "<CMAKE_ASM${ASM_DIALECT}_COMPILER> <INCLUDES> <FLAGS> -o <OBJECT> <SOURCE>") +set(CMAKE_ASM${ASM_DIALECT}_CREATE_STATIC_LIBRARY "<CMAKE_AR> <LINK_FLAGS> /out:<TARGET> <OBJECTS> ") # The ASM_MARMASM compiler id for this compiler is "MSVC", so fill out the runtime library table. set(CMAKE_ASM${ASM_DIALECT}_COMPILE_OPTIONS_MSVC_RUNTIME_LIBRARY_MultiThreaded "") diff --git a/Modules/CMakeASM_MASMInformation.cmake b/Modules/CMakeASM_MASMInformation.cmake index 11b83662..64ae070 100644 --- a/Modules/CMakeASM_MASMInformation.cmake +++ b/Modules/CMakeASM_MASMInformation.cmake @@ -9,6 +9,7 @@ set(ASM_DIALECT "_MASM") set(CMAKE_ASM${ASM_DIALECT}_SOURCE_FILE_EXTENSIONS asm) set(CMAKE_ASM${ASM_DIALECT}_COMPILE_OBJECT "<CMAKE_ASM${ASM_DIALECT}_COMPILER> <DEFINES> <INCLUDES> <FLAGS> -c -Fo <OBJECT> <SOURCE>") +set(CMAKE_ASM${ASM_DIALECT}_CREATE_STATIC_LIBRARY "<CMAKE_AR> <LINK_FLAGS> /out:<TARGET> <OBJECTS> ") # The ASM_MASM compiler id for this compiler is "MSVC", so fill out the runtime library table. set(CMAKE_ASM${ASM_DIALECT}_COMPILE_OPTIONS_MSVC_RUNTIME_LIBRARY_MultiThreaded "") diff --git a/Modules/Compiler/SunPro-C.cmake b/Modules/Compiler/SunPro-C.cmake index 7b4478c..35dbdcd 100644 --- a/Modules/Compiler/SunPro-C.cmake +++ b/Modules/Compiler/SunPro-C.cmake @@ -65,5 +65,9 @@ endif() __compiler_check_default_language_standard(C 5.11 90 5.14 11) +if (CMAKE_C_COMPILER_VERSION VERSION_GREATER_EQUAL 5.15) + set(CMAKE_C_COMPILE_OPTIONS_VISIBILITY "-fvisibility=") +endif() + set(CMAKE_C_CREATE_PREPROCESSED_SOURCE "<CMAKE_C_COMPILER> <DEFINES> <INCLUDES> <FLAGS> -E <SOURCE> > <PREPROCESSED_SOURCE>") set(CMAKE_C_CREATE_ASSEMBLY_SOURCE "<CMAKE_C_COMPILER> <DEFINES> <INCLUDES> <FLAGS> -S <SOURCE> -o <ASSEMBLY_SOURCE>") diff --git a/Modules/Compiler/SunPro-CXX.cmake b/Modules/Compiler/SunPro-CXX.cmake index 1db6aa7..33ce9fc 100644 --- a/Modules/Compiler/SunPro-CXX.cmake +++ b/Modules/Compiler/SunPro-CXX.cmake @@ -69,3 +69,7 @@ else() endif() __compiler_check_default_language_standard(CXX 1 98) + +if (CMAKE_CXX_COMPILER_VERSION VERSION_GREATER_EQUAL 5.15) + set(CMAKE_CXX_COMPILE_OPTIONS_VISIBILITY "-fvisibility=") +endif() diff --git a/Modules/FindImageMagick.cmake b/Modules/FindImageMagick.cmake index 6baf471..50f6e46 100644 --- a/Modules/FindImageMagick.cmake +++ b/Modules/FindImageMagick.cmake @@ -93,6 +93,8 @@ Result Variables Compile options of <component>. ``ImageMagick_<component>_LIBRARIES`` + .. versionadded:: 3.31 + Full path to <component> libraries. @@ -168,6 +170,12 @@ function(FIND_IMAGEMAGICK_API component header) set(ImageMagick_${component}_INCLUDE_DIRS ${ImageMagick_${component}_INCLUDE_DIRS} PARENT_SCOPE) + set(ImageMagick_${component}_LIBRARIES + ${ImageMagick_${component}_LIBRARY} + ) + set(ImageMagick_${component}_LIBRARIES + ${ImageMagick_${component}_LIBRARIES} PARENT_SCOPE) + set(ImageMagick_${component}_COMPILE_OPTIONS ${PC_${component}_CFLAGS_OTHER}) # Add the per-component include directories to the full include dirs. @@ -185,11 +193,13 @@ function(FIND_IMAGEMAGICK_API component header) ) set(ImageMagick_COMPILE_OPTIONS ${ImageMagick_COMPILE_OPTIONS} PARENT_SCOPE) - add_library(ImageMagick::${component} UNKNOWN IMPORTED) - set_target_properties(ImageMagick::${component} PROPERTIES - INTERFACE_INCLUDE_DIRECTORIES "${ImageMagick_${component}_INCLUDE_DIRS}" - INTERFACE_COMPILE_OPTIONS "${ImageMagick_${component}_COMPILE_OPTIONS}" - IMPORTED_LOCATION "${ImageMagick_${component}_LIBRARY}") + if(NOT TARGET ImageMagick::${component}) + add_library(ImageMagick::${component} UNKNOWN IMPORTED) + set_target_properties(ImageMagick::${component} PROPERTIES + INTERFACE_INCLUDE_DIRECTORIES "${ImageMagick_${component}_INCLUDE_DIRS}" + INTERFACE_COMPILE_OPTIONS "${ImageMagick_${component}_COMPILE_OPTIONS}" + IMPORTED_LOCATION "${ImageMagick_${component}_LIBRARY}") + endif() endif() endfunction() diff --git a/Modules/FindMPI.cmake b/Modules/FindMPI.cmake index aa322ac..0f06c57 100644 --- a/Modules/FindMPI.cmake +++ b/Modules/FindMPI.cmake @@ -683,7 +683,7 @@ function (_MPI_interrogate_compiler LANG) endforeach() # Extract include paths from compile command line - string(REGEX MATCHALL "(^| )${_MPI_PREPROCESSOR_FLAG_REGEX}${CMAKE_INCLUDE_FLAG_${LANG}} *([^\" ]+|\"[^\"]+\")" + string(REGEX MATCHALL "(^|\n| )${_MPI_PREPROCESSOR_FLAG_REGEX}${CMAKE_INCLUDE_FLAG_${LANG}} *([^\" ]+|\"[^\"]+\")" MPI_ALL_INCLUDE_PATHS "${MPI_COMPILE_CMDLINE}") # If extracting failed to work, we'll try using -showme:incdirs. @@ -698,6 +698,7 @@ function (_MPI_interrogate_compiler LANG) foreach(_MPI_INCLUDE_PATH IN LISTS MPI_ALL_INCLUDE_PATHS) string(REGEX REPLACE "^ ?${_MPI_PREPROCESSOR_FLAG_REGEX}${CMAKE_INCLUDE_FLAG_${LANG}} *" "" _MPI_INCLUDE_PATH "${_MPI_INCLUDE_PATH}") + string(REPLACE "\n" "" _MPI_INCLUDE_PATH "${_MPI_INCLUDE_PATH}") string(REPLACE "\"" "" _MPI_INCLUDE_PATH "${_MPI_INCLUDE_PATH}") string(REPLACE "'" "" _MPI_INCLUDE_PATH "${_MPI_INCLUDE_PATH}") get_filename_component(_MPI_INCLUDE_PATH "${_MPI_INCLUDE_PATH}" REALPATH) diff --git a/Modules/Internal/CPack/CPackDeb.cmake b/Modules/Internal/CPack/CPackDeb.cmake index d4a47e4..2b58ab1 100644 --- a/Modules/Internal/CPack/CPackDeb.cmake +++ b/Modules/Internal/CPack/CPackDeb.cmake @@ -567,7 +567,7 @@ function(cpack_deb_prepare_package_vars) # if per-component variable, overrides the global CPACK_DEBIAN_PACKAGE_${variable_type_} # automatic dependency discovery will be performed afterwards. if(CPACK_DEB_PACKAGE_COMPONENT) - foreach(value_type_ IN ITEMS DEPENDS RECOMMENDS SUGGESTS PREDEPENDS ENHANCES BREAKS CONFLICTS PROVIDES REPLACES SOURCE SECTION PRIORITY NAME) + foreach(value_type_ IN ITEMS DEPENDS RECOMMENDS SUGGESTS PREDEPENDS ENHANCES BREAKS CONFLICTS PROVIDES REPLACES MULTIARCH SOURCE SECTION PRIORITY NAME) set(_component_var "CPACK_DEBIAN_${_local_component_name}_PACKAGE_${value_type_}") # if set, overrides the global variable @@ -862,6 +862,7 @@ function(cpack_deb_prepare_package_vars) set(GEN_CPACK_DEBIAN_PACKAGE_CONFLICTS "${CPACK_DEBIAN_PACKAGE_CONFLICTS}" PARENT_SCOPE) set(GEN_CPACK_DEBIAN_PACKAGE_PROVIDES "${CPACK_DEBIAN_PACKAGE_PROVIDES}" PARENT_SCOPE) set(GEN_CPACK_DEBIAN_PACKAGE_REPLACES "${CPACK_DEBIAN_PACKAGE_REPLACES}" PARENT_SCOPE) + set(GEN_CPACK_DEBIAN_PACKAGE_MULTIARCH "${CPACK_DEBIAN_PACKAGE_MULTIARCH}" PARENT_SCOPE) set(GEN_CPACK_DEBIAN_PACKAGE_SHLIBS "${CPACK_DEBIAN_PACKAGE_SHLIBS_LIST}" PARENT_SCOPE) set(GEN_CPACK_DEBIAN_PACKAGE_CONTROL_EXTRA "${CPACK_DEBIAN_PACKAGE_CONTROL_EXTRA}" PARENT_SCOPE) set(GEN_CPACK_DEBIAN_PACKAGE_CONTROL_STRICT_PERMISSION diff --git a/Modules/Internal/CPack/CPackRPM.cmake b/Modules/Internal/CPack/CPackRPM.cmake index 4a741ee..e3f8f5e 100644 --- a/Modules/Internal/CPack/CPackRPM.cmake +++ b/Modules/Internal/CPack/CPackRPM.cmake @@ -1034,27 +1034,32 @@ function(cpack_rpm_generate_package) # CPACK_RPM_COMPRESSION_TYPE # if (CPACK_RPM_COMPRESSION_TYPE) - if(CPACK_RPM_PACKAGE_DEBUG) - message("CPackRPM:Debug: User Specified RPM compression type: ${CPACK_RPM_COMPRESSION_TYPE}") - endif() - if(CPACK_RPM_COMPRESSION_TYPE STREQUAL "lzma") - set(CPACK_RPM_COMPRESSION_TYPE_TMP "%define _binary_payload w9.lzdio") - endif() - if(CPACK_RPM_COMPRESSION_TYPE STREQUAL "xz") - if(CPACK_THREADS GREATER "0") - set(CPACK_RPM_COMPRESSION_TYPE_TMP "%define _binary_payload w7T${CPACK_THREADS}.xzdio") - else() - set(CPACK_RPM_COMPRESSION_TYPE_TMP "%define _binary_payload w7T.xzdio") - endif() - endif() - if(CPACK_RPM_COMPRESSION_TYPE STREQUAL "bzip2") - set(CPACK_RPM_COMPRESSION_TYPE_TMP "%define _binary_payload w9.bzdio") - endif() - if(CPACK_RPM_COMPRESSION_TYPE STREQUAL "gzip") - set(CPACK_RPM_COMPRESSION_TYPE_TMP "%define _binary_payload w9.gzdio") - endif() + if(CPACK_RPM_PACKAGE_DEBUG) + message("CPackRPM:Debug: User Specified RPM compression type: ${CPACK_RPM_COMPRESSION_TYPE}") + endif() + if(CPACK_RPM_COMPRESSION_TYPE STREQUAL "lzma") + set(CPACK_RPM_COMPRESSION_TYPE_TMP "%define _binary_payload w9.lzdio") + elseif(CPACK_RPM_COMPRESSION_TYPE STREQUAL "xz") + if(CPACK_THREADS GREATER "0") + set(CPACK_RPM_COMPRESSION_TYPE_TMP "%define _binary_payload w7T${CPACK_THREADS}.xzdio") + else() + set(CPACK_RPM_COMPRESSION_TYPE_TMP "%define _binary_payload w7T.xzdio") + endif() + elseif(CPACK_RPM_COMPRESSION_TYPE STREQUAL "bzip2") + set(CPACK_RPM_COMPRESSION_TYPE_TMP "%define _binary_payload w9.bzdio") + elseif(CPACK_RPM_COMPRESSION_TYPE STREQUAL "gzip") + set(CPACK_RPM_COMPRESSION_TYPE_TMP "%define _binary_payload w9.gzdio") + elseif(CPACK_RPM_COMPRESSION_TYPE STREQUAL "zstd") + if(CPACK_THREADS GREATER "0") + set(CPACK_RPM_COMPRESSION_TYPE_TMP "%define _binary_payload w19T${CPACK_THREADS}.zstdio") + else() + set(CPACK_RPM_COMPRESSION_TYPE_TMP "%define _binary_payload w19T0.zstdio") + endif() + else() + message(FATAL_ERROR "Specified CPACK_RPM_COMPRESSION_TYPE value is not supported: ${CPACK_RPM_COMPRESSION_TYPE}") + endif() else() - set(CPACK_RPM_COMPRESSION_TYPE_TMP "") + set(CPACK_RPM_COMPRESSION_TYPE_TMP "") endif() if(NOT CPACK_RPM_PACKAGE_SOURCES) diff --git a/Modules/MacOSXFrameworkInfo.plist.in b/Modules/MacOSXFrameworkInfo.plist.in index 18eaef2..f053fda 100644 --- a/Modules/MacOSXFrameworkInfo.plist.in +++ b/Modules/MacOSXFrameworkInfo.plist.in @@ -12,6 +12,8 @@ <string>${MACOSX_FRAMEWORK_IDENTIFIER}</string> <key>CFBundleInfoDictionaryVersion</key> <string>6.0</string> + <key>CFBundleName</key> + <string>${MACOSX_FRAMEWORK_BUNDLE_NAME}</string> <key>CFBundlePackageType</key> <string>FMWK</string> <key>CFBundleSignature</key> diff --git a/Modules/Platform/Linux.cmake b/Modules/Platform/Linux.cmake index b9801ee..a73bbf7 100644 --- a/Modules/Platform/Linux.cmake +++ b/Modules/Platform/Linux.cmake @@ -84,7 +84,7 @@ include(Platform/UnixPaths) # Debian has lib32 and lib64 paths only for compatibility so they should not be # searched. -if(NOT CMAKE_CROSSCOMPILING) +if(NOT CMAKE_CROSSCOMPILING AND NOT CMAKE_COMPILER_SYSROOT) if (EXISTS "/etc/debian_version") set_property(GLOBAL PROPERTY FIND_LIBRARY_USE_LIB32_PATHS FALSE) set_property(GLOBAL PROPERTY FIND_LIBRARY_USE_LIB64_PATHS FALSE) diff --git a/Modules/UseJava/javaTargets.cmake.in b/Modules/UseJava/javaTargets.cmake.in index dc20c82..6002d4e 100644 --- a/Modules/UseJava/javaTargets.cmake.in +++ b/Modules/UseJava/javaTargets.cmake.in @@ -1,5 +1,5 @@ cmake_policy(PUSH) -cmake_policy(VERSION 2.8.12...3.28) +cmake_policy(VERSION 2.8.12...3.29) #---------------------------------------------------------------- # Generated CMake Java target import file. @@ -51,18 +51,19 @@ Building CMake with CMake ------------------------- You can build CMake as any other project with a CMake-based build system: -run the installed CMake on the sources of this CMake with your preferred -options and generators. Then build it and install it. -For instructions how to do this, see documentation on `Running CMake`_. - -.. _`Running CMake`: https://cmake.org/runningcmake +run an already-installed CMake on this source tree with your preferred +generator and options. Then build it and install it. To build the documentation, install `Sphinx`_ and configure CMake with ``-DSPHINX_HTML=ON`` and/or ``-DSPHINX_MAN=ON`` to enable the "html" or "man" builder. Add ``-DSPHINX_EXECUTABLE=/path/to/sphinx-build`` if the tool is not found automatically. +To run the test suite, run ``ctest`` in the CMake build directory after +building. See the `CMake Testing Guide`_ for details. + .. _`Sphinx`: https://sphinx-doc.org +.. _`CMake Testing Guide`: Help/dev/testing.rst Building CMake from Scratch --------------------------- diff --git a/Source/CMakeVersion.cmake b/Source/CMakeVersion.cmake index 0e65085..5b8fa1b 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 30) -set(CMake_VERSION_PATCH 0) +set(CMake_VERSION_PATCH 20240704) #set(CMake_VERSION_RC 0) set(CMake_VERSION_IS_DIRTY 0) diff --git a/Source/CPack/cmCPackDebGenerator.cxx b/Source/CPack/cmCPackDebGenerator.cxx index 31191a9..d721cf1 100644 --- a/Source/CPack/cmCPackDebGenerator.cxx +++ b/Source/CPack/cmCPackDebGenerator.cxx @@ -789,6 +789,21 @@ bool cmCPackDebGenerator::createDeb() if (cmNonempty(debian_pkg_replaces)) { controlValues["Replaces"] = *debian_pkg_replaces; } + cmValue debian_pkg_multiarch = + this->GetOption("GEN_CPACK_DEBIAN_PACKAGE_MULTIARCH"); + if (cmNonempty(debian_pkg_multiarch)) { + // check for valid values: same, foreign, allowed + if (*debian_pkg_multiarch != "same" && + *debian_pkg_multiarch != "foreign" && + *debian_pkg_multiarch != "allowed") { + cmCPackLogger(cmCPackLog::LOG_ERROR, + "Error: invalid value for Multi-Arch: " + << *debian_pkg_multiarch + << ". Valid values are: same, foreign, allowed\n"); + return false; + } + controlValues["Multi-Arch"] = *debian_pkg_multiarch; + } const std::string strGenWDIR(this->GetOption("GEN_WDIR")); const std::string shlibsfilename = strGenWDIR + "/shlibs"; diff --git a/Source/Checks/Curses/CMakeLists.txt b/Source/Checks/Curses/CMakeLists.txt index 5d0e240..bd7c415 100644 --- a/Source/Checks/Curses/CMakeLists.txt +++ b/Source/Checks/Curses/CMakeLists.txt @@ -1,4 +1,4 @@ -cmake_minimum_required(VERSION 3.13...3.28 FATAL_ERROR) +cmake_minimum_required(VERSION 3.13...3.29 FATAL_ERROR) project(CheckCurses C) set(CURSES_NEED_NCURSES TRUE) diff --git a/Source/cmAddCustomCommandCommand.cxx b/Source/cmAddCustomCommandCommand.cxx index d943011..d5adba7 100644 --- a/Source/cmAddCustomCommandCommand.cxx +++ b/Source/cmAddCustomCommandCommand.cxx @@ -53,6 +53,7 @@ bool cmAddCustomCommandCommand(std::vector<std::string> const& args, bool command_expand_lists = false; bool depends_explicit_only = mf.IsOn("CMAKE_ADD_CUSTOM_COMMAND_DEPENDS_EXPLICIT_ONLY"); + bool codegen = false; std::string implicit_depends_lang; cmImplicitDependsList implicit_depends; @@ -111,6 +112,7 @@ bool cmAddCustomCommandCommand(std::vector<std::string> const& args, MAKE_STATIC_KEYWORD(VERBATIM); MAKE_STATIC_KEYWORD(WORKING_DIRECTORY); MAKE_STATIC_KEYWORD(DEPENDS_EXPLICIT_ONLY); + MAKE_STATIC_KEYWORD(CODEGEN); #undef MAKE_STATIC_KEYWORD static std::unordered_set<std::string> const keywords{ keyAPPEND, @@ -135,7 +137,8 @@ bool cmAddCustomCommandCommand(std::vector<std::string> const& args, keyUSES_TERMINAL, keyVERBATIM, keyWORKING_DIRECTORY, - keyDEPENDS_EXPLICIT_ONLY + keyDEPENDS_EXPLICIT_ONLY, + keyCODEGEN }; for (std::string const& copy : args) { @@ -166,6 +169,8 @@ bool cmAddCustomCommandCommand(std::vector<std::string> const& args, command_expand_lists = true; } else if (copy == keyDEPENDS_EXPLICIT_ONLY) { depends_explicit_only = true; + } else if (copy == keyCODEGEN) { + codegen = true; } else if (copy == keyTARGET) { doing = doing_target; } else if (copy == keyARGS) { @@ -322,6 +327,28 @@ bool cmAddCustomCommandCommand(std::vector<std::string> const& args, return false; } + if (codegen) { + if (output.empty()) { + status.SetError("CODEGEN requires at least 1 OUTPUT."); + return false; + } + + if (append) { + status.SetError("CODEGEN may not be used with APPEND."); + return false; + } + + if (!implicit_depends.empty()) { + status.SetError("CODEGEN is not compatible with IMPLICIT_DEPENDS."); + return false; + } + + if (mf.GetPolicyStatus(cmPolicies::CMP0171) != cmPolicies::NEW) { + status.SetError("CODEGEN option requires policy CMP0171 be set to NEW!"); + return false; + } + } + // Check for an append request. if (append) { mf.AppendCustomCommandToOutput(output[0], depends, implicit_depends, @@ -355,6 +382,7 @@ bool cmAddCustomCommandCommand(std::vector<std::string> const& args, cc->SetOutputs(output); cc->SetMainDependency(main_dependency); cc->SetDepends(depends); + cc->SetCodegen(codegen); cc->SetImplicitDepends(implicit_depends); mf.AddCustomCommandToOutput(std::move(cc)); } else { diff --git a/Source/cmAddDependenciesCommand.cxx b/Source/cmAddDependenciesCommand.cxx index 2d55a5a..aa04018 100644 --- a/Source/cmAddDependenciesCommand.cxx +++ b/Source/cmAddDependenciesCommand.cxx @@ -30,6 +30,7 @@ bool cmAddDependenciesCommand(std::vector<std::string> const& args, // skip over target_name for (std::string const& arg : cmMakeRange(args).advance(1)) { target->AddUtility(arg, false, &mf); + target->AddCodegenDependency(arg); } } else { mf.IssueMessage( diff --git a/Source/cmCMakePresetsGraphReadJSON.cxx b/Source/cmCMakePresetsGraphReadJSON.cxx index 1cf9500..108dfa2 100644 --- a/Source/cmCMakePresetsGraphReadJSON.cxx +++ b/Source/cmCMakePresetsGraphReadJSON.cxx @@ -40,7 +40,7 @@ using cmCMakePresetsGraphInternal::BaseMacroExpander; using cmCMakePresetsGraphInternal::ExpandMacros; constexpr int MIN_VERSION = 1; -constexpr int MAX_VERSION = 9; +constexpr int MAX_VERSION = 10; struct CMakeVersion { @@ -528,6 +528,9 @@ bool cmCMakePresetsGraph::ReadJSONFile(const std::string& filename, return false; } + // Support for $comment added in version 10. + this->parseState.allowComments = (v >= 10); + RootPresets presets; if ((result = RootPresetsHelper(presets, &root, &parseState)) != true) { return result; diff --git a/Source/cmCustomCommand.h b/Source/cmCustomCommand.h index 167e601..6f63d0a 100644 --- a/Source/cmCustomCommand.h +++ b/Source/cmCustomCommand.h @@ -132,6 +132,10 @@ public: const std::string& GetTarget() const; void SetTarget(const std::string& target); + /** Record if the custom command can be used for code generation. */ + bool GetCodegen() const { return Codegen; } + void SetCodegen(bool b) { Codegen = b; } + private: std::vector<std::string> Outputs; std::vector<std::string> Byproducts; @@ -153,6 +157,7 @@ private: bool StdPipesUTF8 = false; bool HasMainDependency_ = false; bool DependsExplicitOnly = false; + bool Codegen = false; // Policies are NEW for synthesized custom commands, and set by cmMakefile for // user-created custom commands. diff --git a/Source/cmELF.cxx b/Source/cmELF.cxx index a71e5f1..003f47b 100644 --- a/Source/cmELF.cxx +++ b/Source/cmELF.cxx @@ -112,6 +112,9 @@ public: virtual bool IsMips() const = 0; virtual void PrintInfo(std::ostream& os) const = 0; + /** Returns true if the ELF file has a dynamic section **/ + bool HasDynamicSection() const { return this->DynamicSectionIndex >= 0; } + // Lookup the SONAME in the DYNAMIC section. StringEntry const* GetSOName() { @@ -461,7 +464,7 @@ template <class Types> bool cmELFInternalImpl<Types>::LoadDynamicSection() { // If there is no dynamic section we are done. - if (this->DynamicSectionIndex < 0) { + if (!this->HasDynamicSection()) { return false; } @@ -772,6 +775,11 @@ std::vector<char> cmELF::EncodeDynamicEntries( return std::vector<char>(); } +bool cmELF::HasDynamicSection() const +{ + return this->Valid() && this->Internal->HasDynamicSection(); +} + bool cmELF::GetSOName(std::string& soname) { if (StringEntry const* se = this->GetSOName()) { diff --git a/Source/cmELF.h b/Source/cmELF.h index ce8bd7f..dd37c65 100644 --- a/Source/cmELF.h +++ b/Source/cmELF.h @@ -88,6 +88,9 @@ public: std::vector<char> EncodeDynamicEntries( const DynamicEntryList& entries) const; + /** Returns true if the ELF file has a dynamic section **/ + bool HasDynamicSection() const; + /** Get the SONAME field if any. */ bool GetSOName(std::string& soname); StringEntry const* GetSOName(); diff --git a/Source/cmExportFileGenerator.cxx b/Source/cmExportFileGenerator.cxx index a5348f2..afc571d 100644 --- a/Source/cmExportFileGenerator.cxx +++ b/Source/cmExportFileGenerator.cxx @@ -1009,7 +1009,7 @@ void cmExportFileGenerator::GeneratePolicyHeaderCode(std::ostream& os) // Isolate the file policy level. // Support CMake versions as far back as the // RequiredCMakeVersion{Major,Minor,Patch}, but also support using NEW - // policy settings for up to CMake 3.28 (this upper limit may be reviewed + // policy settings for up to CMake 3.29 (this upper limit may be reviewed // and increased from time to time). This reduces the opportunity for CMake // warnings when an older export file is later used with newer CMake // versions. @@ -1018,7 +1018,7 @@ void cmExportFileGenerator::GeneratePolicyHeaderCode(std::ostream& os) << "cmake_policy(VERSION " << this->RequiredCMakeVersionMajor << '.' << this->RequiredCMakeVersionMinor << '.' - << this->RequiredCMakeVersionPatch << "...3.28)\n"; + << this->RequiredCMakeVersionPatch << "...3.29)\n"; /* clang-format on */ } diff --git a/Source/cmFileCommand.cxx b/Source/cmFileCommand.cxx index ce8cc2a..88555b6 100644 --- a/Source/cmFileCommand.cxx +++ b/Source/cmFileCommand.cxx @@ -8,6 +8,7 @@ #include <cmath> #include <cstdio> #include <cstdlib> +#include <iterator> #include <map> #include <set> #include <sstream> @@ -881,6 +882,42 @@ bool HandleMakeDirectoryCommand(std::vector<std::string> const& args, // Projects might pass a dynamically generated list of directories, and it // could be an empty list. We should not assume there is at least one. + cmRange<std::vector<std::string>::const_iterator> argsRange = + cmMakeRange(args).advance(1); // Get rid of subcommand + + struct Arguments : public ArgumentParser::ParseResult + { + std::string Result; + }; + Arguments arguments; + + auto resultPosItr = + std::find(cm::begin(argsRange), cm::end(argsRange), "RESULT"); + if (resultPosItr != cm::end(argsRange)) { + static auto const parser = + cmArgumentParser<Arguments>{}.Bind("RESULT"_s, &Arguments::Result); + std::vector<std::string> unparsedArguments; + auto resultDistanceFromBegin = + std::distance(cm::begin(argsRange), resultPosItr); + arguments = + parser.Parse(cmMakeRange(argsRange).advance(resultDistanceFromBegin), + &unparsedArguments); + + if (!unparsedArguments.empty()) { + std::string unexpectedArgsStr = cmJoin( + cmMakeRange(cm::begin(unparsedArguments), cm::end(unparsedArguments)), + "\n"); + status.SetError("MAKE_DIRECTORY called with unexpected\n" + "arguments:\n" + + unexpectedArgsStr); + return false; + } + + auto resultDistanceFromEnd = + std::distance(cm::end(argsRange), resultPosItr); + argsRange = argsRange.retreat(-resultDistanceFromEnd); + } + std::string expr; for (std::string const& arg : cmMakeRange(args).advance(1)) // Get rid of subcommand @@ -892,20 +929,34 @@ bool HandleMakeDirectoryCommand(std::vector<std::string> const& args, cdir = &expr; } if (!status.GetMakefile().CanIWriteThisFile(*cdir)) { - std::string e = "attempted to create a directory: " + *cdir + - " into a source directory."; - status.SetError(e); - cmSystemTools::SetFatalErrorOccurred(); - return false; + std::string e = cmStrCat("attempted to create a directory: ", *cdir, + " into a source directory."); + if (arguments.Result.empty()) { + status.SetError(e); + cmSystemTools::SetFatalErrorOccurred(); + return false; + } + status.GetMakefile().AddDefinition(arguments.Result, e); + return true; } cmsys::Status mkdirStatus = cmSystemTools::MakeDirectory(*cdir); if (!mkdirStatus) { - std::string error = cmStrCat("failed to create directory:\n ", *cdir, - "\nbecause: ", mkdirStatus.GetString()); - status.SetError(error); - return false; + if (arguments.Result.empty()) { + std::string errorOutput = + cmStrCat("failed to create directory:\n ", *cdir, + "\nbecause: ", mkdirStatus.GetString()); + status.SetError(errorOutput); + return false; + } + std::string errorResult = cmStrCat("Failed to create directory: ", *cdir, + " Error: ", mkdirStatus.GetString()); + status.GetMakefile().AddDefinition(arguments.Result, errorResult); + return true; } } + if (!arguments.Result.empty()) { + status.GetMakefile().AddDefinition(arguments.Result, "0"); + } return true; } diff --git a/Source/cmGlobalGenerator.cxx b/Source/cmGlobalGenerator.cxx index 019271b..bf2f0fc 100644 --- a/Source/cmGlobalGenerator.cxx +++ b/Source/cmGlobalGenerator.cxx @@ -1398,6 +1398,8 @@ void cmGlobalGenerator::Configure() } } + this->ReserveGlobalTargetCodegen(); + // update the cache entry for the number of local generators, this is used // for progress this->GetCMakeInstance()->AddCacheEntry( @@ -2914,6 +2916,53 @@ void cmGlobalGenerator::AddGlobalTarget_Test( targets.push_back(std::move(gti)); } +void cmGlobalGenerator::ReserveGlobalTargetCodegen() +{ + // Read the policy value at the end of the top-level CMakeLists.txt file + // since it's a global policy that affects the whole project. + auto& mf = this->Makefiles[0]; + const auto policyStatus = mf->GetPolicyStatus(cmPolicies::CMP0171); + + this->AllowGlobalTargetCodegen = (policyStatus == cmPolicies::NEW); + + cmTarget* tgt = this->FindTarget("codegen"); + if (!tgt) { + return; + } + + MessageType messageType = MessageType::AUTHOR_WARNING; + std::ostringstream e; + bool issueMessage = false; + switch (policyStatus) { + case cmPolicies::WARN: + e << cmPolicies::GetPolicyWarning(cmPolicies::CMP0171) << "\n"; + issueMessage = true; + CM_FALLTHROUGH; + case cmPolicies::OLD: + break; + case cmPolicies::NEW: + case cmPolicies::REQUIRED_IF_USED: + case cmPolicies::REQUIRED_ALWAYS: + issueMessage = true; + messageType = MessageType::FATAL_ERROR; + break; + } + if (issueMessage) { + e << "The target name \"codegen\" is reserved."; + this->GetCMakeInstance()->IssueMessage(messageType, e.str(), + tgt->GetBacktrace()); + if (messageType == MessageType::FATAL_ERROR) { + cmSystemTools::SetFatalErrorOccurred(); + return; + } + } +} + +bool cmGlobalGenerator::CheckCMP0171() const +{ + return this->AllowGlobalTargetCodegen; +} + void cmGlobalGenerator::AddGlobalTarget_EditCache( std::vector<GlobalTargetInfo>& targets) const { diff --git a/Source/cmGlobalGenerator.h b/Source/cmGlobalGenerator.h index 1ca02d9..33c9889 100644 --- a/Source/cmGlobalGenerator.h +++ b/Source/cmGlobalGenerator.h @@ -653,6 +653,8 @@ public: virtual std::string& EncodeLiteral(std::string& lit) { return lit; } + bool CheckCMP0171() const; + protected: // for a project collect all its targets by following depend // information, and also collect all the targets @@ -719,6 +721,8 @@ protected: void AddGlobalTarget_Install(std::vector<GlobalTargetInfo>& targets); void CreateGlobalTarget(GlobalTargetInfo const& gti, cmMakefile* mf); + void ReserveGlobalTargetCodegen(); + std::string FindMakeProgramFile; std::string ConfiguredFilesPath; cmake* CMakeInstance; @@ -891,4 +895,5 @@ protected: bool ToolSupportsColor; bool InstallTargetEnabled; bool ConfigureDoneCMP0026AndCMP0024; + bool AllowGlobalTargetCodegen; }; diff --git a/Source/cmGlobalNinjaGenerator.cxx b/Source/cmGlobalNinjaGenerator.cxx index 96c8f25..7d62fa8 100644 --- a/Source/cmGlobalNinjaGenerator.cxx +++ b/Source/cmGlobalNinjaGenerator.cxx @@ -25,6 +25,7 @@ #include "cmsys/FStream.hxx" +#include "cmCustomCommand.h" #include "cmCxxModuleMapper.h" #include "cmDyndepCollation.h" #include "cmFortranParser.h" @@ -43,6 +44,7 @@ #include "cmOutputConverter.h" #include "cmRange.h" #include "cmScanDepFormat.h" +#include "cmSourceFile.h" #include "cmState.h" #include "cmStateDirectory.h" #include "cmStateSnapshot.h" @@ -1627,6 +1629,90 @@ void cmGlobalNinjaGenerator::WriteFolderTargets(std::ostream& os) std::map<std::string, DirectoryTarget> dirTargets = this->ComputeDirectoryTargets(); + // Codegen target + if (this->CheckCMP0171()) { + for (auto const& it : dirTargets) { + cmNinjaBuild build("phony"); + cmGlobalNinjaGenerator::WriteDivider(os); + std::string const& currentBinaryDir = it.first; + DirectoryTarget const& dt = it.second; + std::vector<std::string> configs = + dt.LG->GetMakefile()->GetGeneratorConfigs( + cmMakefile::IncludeEmptyConfig); + + // Setup target + cmNinjaDeps configDeps; + build.Comment = cmStrCat("Folder: ", currentBinaryDir); + build.Outputs.emplace_back(); + std::string const buildDirAllTarget = + this->ConvertToNinjaPath(cmStrCat(currentBinaryDir, "/codegen")); + + cmNinjaDeps& explicitDeps = build.ExplicitDeps; + + for (auto const& config : configs) { + explicitDeps.clear(); + + for (DirectoryTarget::Target const& t : dt.Targets) { + if (this->IsExcludedFromAllInConfig(t, config)) { + continue; + } + + std::vector<cmSourceFile const*> customCommandSources; + t.GT->GetCustomCommands(customCommandSources, config); + for (cmSourceFile const* sf : customCommandSources) { + cmCustomCommand const* cc = sf->GetCustomCommand(); + if (cc->GetCodegen()) { + auto const& outputs = cc->GetOutputs(); + + std::transform(outputs.begin(), outputs.end(), + std::back_inserter(explicitDeps), + this->MapToNinjaPath()); + } + } + } + + build.Outputs.front() = this->BuildAlias(buildDirAllTarget, config); + // Write target + this->WriteBuild(this->EnableCrossConfigBuild() && + this->CrossConfigs.count(config) + ? os + : *this->GetImplFileStream(config), + build); + } + + // Add shortcut target + if (this->IsMultiConfig()) { + for (auto const& config : configs) { + build.ExplicitDeps = { this->BuildAlias(buildDirAllTarget, config) }; + build.Outputs.front() = buildDirAllTarget; + this->WriteBuild(*this->GetConfigFileStream(config), build); + } + + if (!this->DefaultFileConfig.empty()) { + build.ExplicitDeps.clear(); + for (auto const& config : this->DefaultConfigs) { + build.ExplicitDeps.push_back( + this->BuildAlias(buildDirAllTarget, config)); + } + build.Outputs.front() = buildDirAllTarget; + this->WriteBuild(*this->GetDefaultFileStream(), build); + } + } + + // Add target for all configs + if (this->EnableCrossConfigBuild()) { + build.ExplicitDeps.clear(); + for (auto const& config : this->CrossConfigs) { + build.ExplicitDeps.push_back( + this->BuildAlias(buildDirAllTarget, config)); + } + build.Outputs.front() = this->BuildAlias(buildDirAllTarget, "codegen"); + this->WriteBuild(os, build); + } + } + } + + // All target for (auto const& it : dirTargets) { cmNinjaBuild build("phony"); cmGlobalNinjaGenerator::WriteDivider(os); diff --git a/Source/cmGlobalUnixMakefileGenerator3.cxx b/Source/cmGlobalUnixMakefileGenerator3.cxx index 56748a5..38cc4f6 100644 --- a/Source/cmGlobalUnixMakefileGenerator3.cxx +++ b/Source/cmGlobalUnixMakefileGenerator3.cxx @@ -23,6 +23,7 @@ #include "cmStateTypes.h" #include "cmStringAlgorithms.h" #include "cmSystemTools.h" +#include "cmTarget.h" #include "cmTargetDepend.h" #include "cmValue.h" #include "cmake.h" @@ -438,6 +439,10 @@ void cmGlobalUnixMakefileGenerator3::WriteDirectoryRules2( // Write directory-level rules for "all". this->WriteDirectoryRule2(ruleFileStream, rootLG, dt, "all", true, false); + // Write directory-level rules for "codegen". + this->WriteDirectoryRule2(ruleFileStream, rootLG, dt, "codegen", true, + false); + // Write directory-level rules for "preinstall". this->WriteDirectoryRule2(ruleFileStream, rootLG, dt, "preinstall", true, true); @@ -765,6 +770,17 @@ void cmGlobalUnixMakefileGenerator3::WriteConvenienceRules2( depends, commands, true); } + // add the codegen rule + localName = lg.GetRelativeTargetDirectory(gtarget.get()); + depends.clear(); + commands.clear(); + makeTargetName = cmStrCat(localName, "/codegen"); + commands.push_back( + lg.GetRecursiveMakeCall(makefileName, makeTargetName)); + this->AppendCodegenTargetDepends(depends, gtarget.get()); + rootLG.WriteMakeRule(ruleFileStream, "codegen rule for target.", + makeTargetName, depends, commands, true); + // add the clean rule localName = lg.GetRelativeTargetDirectory(gtarget.get()); makeTargetName = cmStrCat(localName, "/clean"); @@ -893,6 +909,29 @@ void cmGlobalUnixMakefileGenerator3::AppendGlobalTargetDepends( } } +void cmGlobalUnixMakefileGenerator3::AppendCodegenTargetDepends( + std::vector<std::string>& depends, cmGeneratorTarget* target) +{ + const std::set<std::string>& codegen_depends = + target->Target->GetCodegenDeps(); + + for (cmTargetDepend const& i : this->GetTargetDirectDepends(target)) { + // Create the target-level dependency. + cmGeneratorTarget const* dep = i; + if (!dep->IsInBuildSystem()) { + continue; + } + if (codegen_depends.find(dep->GetName()) != codegen_depends.end()) { + cmLocalUnixMakefileGenerator3* lg3 = + static_cast<cmLocalUnixMakefileGenerator3*>(dep->GetLocalGenerator()); + std::string tgtName = cmStrCat( + lg3->GetRelativeTargetDirectory(const_cast<cmGeneratorTarget*>(dep)), + "/all"); + depends.push_back(tgtName); + } + } +} + void cmGlobalUnixMakefileGenerator3::WriteHelpRule( std::ostream& ruleFileStream, cmLocalUnixMakefileGenerator3* lg) { diff --git a/Source/cmGlobalUnixMakefileGenerator3.h b/Source/cmGlobalUnixMakefileGenerator3.h index ee78351..d4fcf88 100644 --- a/Source/cmGlobalUnixMakefileGenerator3.h +++ b/Source/cmGlobalUnixMakefileGenerator3.h @@ -223,6 +223,9 @@ protected: void AppendGlobalTargetDepends(std::vector<std::string>& depends, cmGeneratorTarget* target); + void AppendCodegenTargetDepends(std::vector<std::string>& depends, + cmGeneratorTarget* target); + // Target name hooks for superclass. const char* GetAllTargetName() const override { return "all"; } const char* GetInstallTargetName() const override { return "install"; } diff --git a/Source/cmJSONHelpers.h b/Source/cmJSONHelpers.h index 24884ed..368a0df 100644 --- a/Source/cmJSONHelpers.h +++ b/Source/cmJSONHelpers.h @@ -119,6 +119,12 @@ struct cmJSONHelperBuilder extraFields = value->getMemberNames(); } + if (state->allowComments) { + extraFields.erase( + std::remove(extraFields.begin(), extraFields.end(), "$comment"), + extraFields.end()); + } + for (auto const& m : this->Members) { std::string name(m.Name.data(), m.Name.size()); state->push_stack(name, value); diff --git a/Source/cmJSONState.h b/Source/cmJSONState.h index 9071268..ccf2b71 100644 --- a/Source/cmJSONState.h +++ b/Source/cmJSONState.h @@ -65,6 +65,7 @@ public: std::vector<JsonPair> parseStack; std::vector<Error> errors; std::string doc; + bool allowComments; private: std::string GetJsonContext(Location loc); diff --git a/Source/cmLocalGenerator.cxx b/Source/cmLocalGenerator.cxx index 94e62ff..e6d56d3 100644 --- a/Source/cmLocalGenerator.cxx +++ b/Source/cmLocalGenerator.cxx @@ -4369,6 +4369,7 @@ void cmLocalGenerator::GenerateFrameworkInfoPList( cmLGInfoProp(mf, target, "MACOSX_FRAMEWORK_ICON_FILE"); cmLGInfoProp(mf, target, "MACOSX_FRAMEWORK_IDENTIFIER"); cmLGInfoProp(mf, target, "MACOSX_FRAMEWORK_SHORT_VERSION_STRING"); + cmLGInfoProp(mf, target, "MACOSX_FRAMEWORK_BUNDLE_NAME"); cmLGInfoProp(mf, target, "MACOSX_FRAMEWORK_BUNDLE_VERSION"); mf->ConfigureFile(inFile, fname, false, false, false); } @@ -4625,6 +4626,12 @@ void AppendCustomCommandToOutput(cmLocalGenerator& lg, if (cmCustomCommand* cc = sf->GetCustomCommand()) { cc->AppendCommands(commandLines); cc->AppendDepends(depends); + if (cc->GetCodegen() && !implicit_depends.empty()) { + lg.GetCMakeInstance()->IssueMessage( + MessageType::FATAL_ERROR, + "Cannot append IMPLICIT_DEPENDS to existing CODEGEN custom " + "command."); + } cc->AppendImplicitDepends(implicit_depends); return; } diff --git a/Source/cmLocalUnixMakefileGenerator3.cxx b/Source/cmLocalUnixMakefileGenerator3.cxx index 7def1fe..4a776b4 100644 --- a/Source/cmLocalUnixMakefileGenerator3.cxx +++ b/Source/cmLocalUnixMakefileGenerator3.cxx @@ -1763,6 +1763,21 @@ void cmLocalUnixMakefileGenerator3::WriteLocalAllRules( this->WriteMakeRule(ruleFileStream, "The main all target", "all", depends, commands, true); + // Write the codegen rule. + if (this->GetGlobalGenerator()->CheckCMP0171()) { + recursiveTarget = cmStrCat(this->GetCurrentBinaryDirectory(), "/codegen"); + depends.clear(); + commands.clear(); + if (regenerate) { + depends.emplace_back("cmake_check_build_system"); + } + commands.push_back(this->GetRecursiveMakeCall(mf2Dir, recursiveTarget)); + AppendEcho(commands, "Finished generating code", + cmLocalUnixMakefileGenerator3::EchoColor::EchoGenerate); + this->WriteMakeRule(ruleFileStream, "The main codegen target", "codegen", + depends, commands, true); + } + // Write the clean rule. recursiveTarget = cmStrCat(this->GetCurrentBinaryDirectory(), "/clean"); commands.clear(); diff --git a/Source/cmMakefile.cxx b/Source/cmMakefile.cxx index ba9fab5..b8a59a3 100644 --- a/Source/cmMakefile.cxx +++ b/Source/cmMakefile.cxx @@ -4657,7 +4657,7 @@ bool cmMakefile::SetPolicy(cmPolicies::PolicyID id, } // Deprecate old policies. - if (status == cmPolicies::OLD && id <= cmPolicies::CMP0128 && + if (status == cmPolicies::OLD && id <= cmPolicies::CMP0129 && !(this->GetCMakeInstance()->GetIsInTryCompile() && ( // Policies set by cmCoreTryCompile::TryCompileCode. diff --git a/Source/cmMakefileTargetGenerator.cxx b/Source/cmMakefileTargetGenerator.cxx index d5c50bc..9ff0a4a 100644 --- a/Source/cmMakefileTargetGenerator.cxx +++ b/Source/cmMakefileTargetGenerator.cxx @@ -251,6 +251,8 @@ void cmMakefileTargetGenerator::WriteTargetBuildRules() std::vector<cmSourceFile const*> customCommands; this->GeneratorTarget->GetCustomCommands(customCommands, this->GetConfigName()); + std::vector<std::string> codegen_depends; + codegen_depends.reserve(customCommands.size()); for (cmSourceFile const* sf : customCommands) { if (this->CMP0113New && !this->LocalGenerator->GetCommandsVisited(this->GeneratorTarget) @@ -273,6 +275,33 @@ void cmMakefileTargetGenerator::WriteTargetBuildRules() this->LocalGenerator->MaybeRelativeToCurBinDir(byproduct)); } } + + if (ccg.GetCC().GetCodegen()) { + std::string const& output = ccg.GetOutputs().front(); + + // We always attach the actual commands to the first output. + codegen_depends.emplace_back(output); + } + } + + // Some make tools need a special dependency for an empty rule. + if (codegen_depends.empty()) { + std::string hack = this->GlobalGenerator->GetEmptyRuleHackDepends(); + if (!hack.empty()) { + codegen_depends.emplace_back(std::move(hack)); + } + } + + // Construct the codegen target. + { + std::string const codegenTarget = cmStrCat( + this->LocalGenerator->GetRelativeTargetDirectory(this->GeneratorTarget), + "/codegen"); + + // Write the rule. + this->LocalGenerator->WriteMakeRule(*this->BuildFileStream, nullptr, + codegenTarget, codegen_depends, {}, + true); } // Add byproducts from build events to the clean rules diff --git a/Source/cmPolicies.h b/Source/cmPolicies.h index d893c44..85f3293 100644 --- a/Source/cmPolicies.h +++ b/Source/cmPolicies.h @@ -525,7 +525,9 @@ class cmMakefile; 3, 30, 0, cmPolicies::WARN) \ SELECT(POLICY, CMP0170, \ "FETCHCONTENT_FULLY_DISCONNECTED requirements are enforced.", 3, 30, \ - 0, cmPolicies::WARN) + 0, cmPolicies::WARN) \ + SELECT(POLICY, CMP0171, "'codegen' is a reserved target name.", 3, 31, 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/cmQtAutoGenInitializer.cxx b/Source/cmQtAutoGenInitializer.cxx index ee53a8e..d646cce 100644 --- a/Source/cmQtAutoGenInitializer.cxx +++ b/Source/cmQtAutoGenInitializer.cxx @@ -1480,6 +1480,16 @@ bool cmQtAutoGenInitializer::InitAutogenTarget() } } + // For the Ninja, Makefile and Qt >= 5.15, add custom commands that create + // XXX_autogen/timestamp files. Those custom commands have a depfile + // assigned that is generated from the depfiles that were created by moc. + // + // The XXX_autogen targets merely wrap the XXX_autogen/timestamp custom + // commands. + // The dependency tree would then look like + // the original dependencies of '_autogen' target <-'/timestamp' file + // <- '_autogen' target + cmTarget* timestampTarget = nullptr; std::vector<std::string> dependencies( this->AutogenTarget.DependFiles.begin(), @@ -1487,40 +1497,6 @@ bool cmQtAutoGenInitializer::InitAutogenTarget() if (useDepfile) { // Create a custom command that generates a timestamp file and // has a depfile assigned. The depfile is created by JobDepFilesMergeT. - // - // Also create an additional '_autogen_timestamp_deps' that the custom - // command will depend on. It will have no sources or commands to - // execute, but it will have dependencies that would originally be - // assigned to the pre-Qt 5.15 'autogen' target. These dependencies will - // serve as a list of order-only dependencies for the custom command, - // without forcing the custom command to re-execute. - // - // The dependency tree would then look like - // '_autogen_timestamp_deps (order-only)' <- '/timestamp' file <- - // '_autogen' target. - const auto timestampTargetName = - cmStrCat(this->GenTarget->GetName(), "_autogen_timestamp_deps"); - - auto cc = cm::make_unique<cmCustomCommand>(); - cc->SetWorkingDirectory(this->Dir.Work.c_str()); - cc->SetDepends(dependencies); - cc->SetEscapeOldStyle(false); - timestampTarget = this->LocalGen->AddUtilityCommand(timestampTargetName, - true, std::move(cc)); - - this->LocalGen->AddGeneratorTarget( - cm::make_unique<cmGeneratorTarget>(timestampTarget, this->LocalGen)); - - // Set FOLDER property on the timestamp target, so it appears in the - // appropriate folder in an IDE or in the file api. - if (!this->TargetsFolder.empty()) { - timestampTarget->SetProperty("FOLDER", this->TargetsFolder); - } - - // Make '/timestamp' file depend on '_autogen_timestamp_deps' and on the - // moc and uic executables (whichever are enabled). - dependencies.clear(); - dependencies.push_back(timestampTargetName); AddAutogenExecutableToDependencies(this->Moc, dependencies); AddAutogenExecutableToDependencies(this->Uic, dependencies); @@ -1565,7 +1541,7 @@ bool cmQtAutoGenInitializer::InitAutogenTarget() { cmSystemTools::GetCMakeCommand(), "-E", "touch", outputFile })); this->AddGeneratedSource(outputFile, this->Moc); } - cc = cm::make_unique<cmCustomCommand>(); + auto cc = cm::make_unique<cmCustomCommand>(); cc->SetOutputs(outputFile); cc->SetByproducts(timestampByproducts); cc->SetDepends(dependencies); @@ -1671,13 +1647,10 @@ bool cmQtAutoGenInitializer::InitRccTargets() sf->SetProperty("SKIP_UNITY_BUILD_INCLUSION", "On"); } - std::vector<std::string> ccOutput; - ccOutput.push_back(qrc.OutputFile); + std::vector<std::string> ccOutput{ qrc.OutputFile }; - std::vector<std::string> ccDepends; // Add the .qrc and info file to the custom command dependencies - ccDepends.push_back(qrc.QrcFile); - ccDepends.push_back(qrc.InfoFile); + std::vector<std::string> ccDepends{ qrc.QrcFile, qrc.InfoFile }; cmCustomCommandLines commandLines; AddCMakeProcessToCommandLines(qrc.InfoFile, "cmake_autorcc", commandLines); @@ -1700,13 +1673,43 @@ bool cmQtAutoGenInitializer::InitRccTargets() if (!qrc.Unique) { ccName += cmStrCat('_', qrc.QrcPathChecksum); } - - cc->SetByproducts(ccOutput); - cc->SetDepends(ccDepends); - cc->SetEscapeOldStyle(false); - cmTarget* autoRccTarget = - this->LocalGen->AddUtilityCommand(ccName, true, std::move(cc)); - + cmTarget* autoRccTarget = nullptr; + // When CMAKE_GLOBAL_AUTORCC_TARGET is ON and qrc is not generated, + // Add generate a timestamp file and a custom command to touch it. + // This will ensure that the global autorcc target is run only when the + // qrc file changes. + if (!qrc.Generated && this->Rcc.GlobalTarget) { + cm::string_view const timestampFileName = "global_rcc_timestamp"; + auto const outputFile = + cmStrCat(this->Dir.Build, "/", timestampFileName); + commandLines.push_back(cmMakeCommandLine( + { cmSystemTools::GetCMakeCommand(), "-E", "touch", outputFile })); + cc->SetByproducts(ccOutput); + cc->SetDepends(ccDepends); + cc->SetEscapeOldStyle(false); + cc->SetOutputs(outputFile); + cc->SetCommandLines(commandLines); + this->LocalGen->AddCustomCommandToOutput(std::move(cc)); + this->AddGeneratedSource(outputFile, this->Rcc); + ccDepends.clear(); + ccDepends.push_back(outputFile); + + auto ccRccTarget = cm::make_unique<cmCustomCommand>(); + ccRccTarget->SetWorkingDirectory(this->Dir.Work.c_str()); + ccRccTarget->SetComment(ccComment.c_str()); + ccRccTarget->SetStdPipesUTF8(true); + ccRccTarget->SetDepends(ccDepends); + ccRccTarget->SetEscapeOldStyle(false); + + autoRccTarget = this->LocalGen->AddUtilityCommand( + ccName, true, std::move(ccRccTarget)); + } else { + cc->SetByproducts(ccOutput); + cc->SetDepends(ccDepends); + cc->SetEscapeOldStyle(false); + autoRccTarget = + this->LocalGen->AddUtilityCommand(ccName, true, std::move(cc)); + } // Create autogen generator target this->LocalGen->AddGeneratorTarget( cm::make_unique<cmGeneratorTarget>(autoRccTarget, this->LocalGen)); diff --git a/Source/cmSystemTools.cxx b/Source/cmSystemTools.cxx index 093a18b..3affef0 100644 --- a/Source/cmSystemTools.cxx +++ b/Source/cmSystemTools.cxx @@ -2817,6 +2817,10 @@ cm::optional<bool> AdjustRPathELF(std::string const& file, return cm::nullopt; // Not a valid ELF file. } + if (!elf.HasDynamicSection()) { + return true; // No dynamic section to update. + } + // Get the RPATH and RUNPATH entries from it. int se_count = 0; cmELF::StringEntry const* se[2] = { nullptr, nullptr }; diff --git a/Source/cmTarget.cxx b/Source/cmTarget.cxx index 1284130..a6e6984 100644 --- a/Source/cmTarget.cxx +++ b/Source/cmTarget.cxx @@ -657,6 +657,7 @@ public: bool PerConfig; cmTarget::Visibility TargetVisibility; std::set<BT<std::pair<std::string, bool>>> Utilities; + std::set<std::string> CodegenDependencies; std::vector<cmCustomCommand> PreBuildCommands; std::vector<cmCustomCommand> PreLinkCommands; std::vector<cmCustomCommand> PostBuildCommands; @@ -1238,6 +1239,16 @@ void cmTarget::AddUtility(BT<std::pair<std::string, bool>> util) this->impl->Utilities.emplace(std::move(util)); } +void cmTarget::AddCodegenDependency(std::string const& name) +{ + this->impl->CodegenDependencies.emplace(name); +} + +std::set<std::string> const& cmTarget::GetCodegenDeps() const +{ + return this->impl->CodegenDependencies; +} + std::set<BT<std::pair<std::string, bool>>> const& cmTarget::GetUtilities() const { diff --git a/Source/cmTarget.h b/Source/cmTarget.h index 385dfe7..220ac13 100644 --- a/Source/cmTarget.h +++ b/Source/cmTarget.h @@ -173,6 +173,11 @@ public: void AddUtility(std::string const& name, bool cross, cmMakefile const* mf = nullptr); void AddUtility(BT<std::pair<std::string, bool>> util); + + void AddCodegenDependency(std::string const& name); + + std::set<std::string> const& GetCodegenDeps() const; + //! Get the utilities used by this target std::set<BT<std::pair<std::string, bool>>> const& GetUtilities() const; diff --git a/Source/cmTargetTraceDependencies.cxx b/Source/cmTargetTraceDependencies.cxx index cc91a42..f14cfbf 100644 --- a/Source/cmTargetTraceDependencies.cxx +++ b/Source/cmTargetTraceDependencies.cxx @@ -7,10 +7,12 @@ #include <cmext/algorithm> +#include "cmCustomCommand.h" #include "cmCustomCommandGenerator.h" #include "cmGeneratorTarget.h" #include "cmGlobalGenerator.h" #include "cmList.h" +#include "cmListFileCache.h" #include "cmMakefile.h" #include "cmMessageType.h" #include "cmSourceFile.h" @@ -132,6 +134,8 @@ void cmTargetTraceDependencies::FollowName(std::string const& name) // The name is a byproduct of a utility target or a PRE_BUILD, PRE_LINK, or // POST_BUILD command. this->GeneratorTarget->Target->AddUtility(t->GetName(), false); + + this->GeneratorTarget->Target->AddCodegenDependency(t->GetName()); } if (cmSourceFile* sf = i->second.Source) { // For now only follow the dependency if the source file is not a @@ -213,6 +217,11 @@ void cmTargetTraceDependencies::CheckCustomCommand(cmCustomCommand const& cc) // Collect target-level dependencies referenced in command lines. for (auto const& util : ccg.GetUtilities()) { this->GeneratorTarget->Target->AddUtility(util); + + if (ccg.GetCC().GetCodegen()) { + this->GeneratorTarget->Target->AddCodegenDependency( + util.Value.first); + } } // Collect file-level dependencies referenced in DEPENDS. @@ -226,6 +235,8 @@ void cmTargetTraceDependencies::CheckCustomCommand(cmCustomCommand const& cc) // The dependency does not name a target and may be a file we // know how to generate. Queue it. this->FollowName(dep); + } else { + this->GeneratorTarget->Target->AddCodegenDependency(dep); } } } diff --git a/Source/cmVisualStudio10TargetGenerator.cxx b/Source/cmVisualStudio10TargetGenerator.cxx index 0fb8bae..eb14e24 100644 --- a/Source/cmVisualStudio10TargetGenerator.cxx +++ b/Source/cmVisualStudio10TargetGenerator.cxx @@ -813,6 +813,7 @@ void cmVisualStudio10TargetGenerator::WriteClassicMsBuildProjectFile( this->WriteCustomCommands(e0); this->WriteAllSources(e0); this->WriteDotNetReferences(e0); + this->WriteFrameworkReferences(e0); this->WritePackageReferences(e0); this->WriteImports(e0); this->WriteEmbeddedResourceGroup(e0); @@ -1187,6 +1188,21 @@ void cmVisualStudio10TargetGenerator::WriteDotNetReference( this->WriteDotNetReferenceCustomTags(e2, ref); } +void cmVisualStudio10TargetGenerator::WriteFrameworkReferences(Elem& e0) +{ + cmList references; + if (cmValue vsFrameworkReferences = + this->GeneratorTarget->GetProperty("VS_FRAMEWORK_REFERENCES")) { + references.assign(*vsFrameworkReferences); + } + + Elem e1(e0, "ItemGroup"); + for (auto const& ref : references) { + Elem e2(e1, "FrameworkReference"); + e2.Attribute("Include", ref); + } +} + void cmVisualStudio10TargetGenerator::WriteImports(Elem& e0) { cmValue imports = diff --git a/Source/cmVisualStudio10TargetGenerator.h b/Source/cmVisualStudio10TargetGenerator.h index 056f426..53eb1af 100644 --- a/Source/cmVisualStudio10TargetGenerator.h +++ b/Source/cmVisualStudio10TargetGenerator.h @@ -91,6 +91,7 @@ private: void WriteDotNetReference(Elem& e1, std::string const& ref, std::string const& hint, std::string const& config); + void WriteFrameworkReferences(Elem& e0); void WriteDotNetDocumentationFile(Elem& e0); void WriteImports(Elem& e0); void WriteDotNetReferenceCustomTags(Elem& e2, std::string const& ref); diff --git a/Tests/README.rst b/Tests/README.rst index 2810fec..4bbbce1 100644 --- a/Tests/README.rst +++ b/Tests/README.rst @@ -2,8 +2,9 @@ CMake Tests Directory ********************* This directory contains the CMake test suite. -See also the `CMake Source Code Guide`_. +See also the `CMake Testing Guide`_ and the `CMake Source Code Guide`_. +.. _`CMake Testing Guide`: ../Help/dev/testing.rst .. _`CMake Source Code Guide`: ../Help/dev/source.rst Many tests exist as immediate subdirectories, but some tests diff --git a/Tests/RunCMake/Autogen/RunCMakeTest.cmake b/Tests/RunCMake/Autogen/RunCMakeTest.cmake deleted file mode 100644 index 0036551..0000000 --- a/Tests/RunCMake/Autogen/RunCMakeTest.cmake +++ /dev/null @@ -1,487 +0,0 @@ -include(RunCMake) - -run_cmake(NoQt) -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) - - run_cmake(CMP0111-imported-target-full) - run_cmake(CMP0111-imported-target-libname) - run_cmake(CMP0111-imported-target-implib-only) - - block() - set(RunCMake_TEST_BINARY_DIR ${RunCMake_BINARY_DIR}/MocPredefs-build) - run_cmake(MocPredefs) - set(RunCMake_TEST_NO_CLEAN 1) - run_cmake_command(MocPredefs-build ${CMAKE_COMMAND} --build . --config Debug) - endblock() - - # Detect information from the toolchain: - # - CMAKE_INCLUDE_FLAG_CXX - # - CMAKE_INCLUDE_SYSTEM_FLAG_CXX - run_cmake(Inspect) - include("${RunCMake_BINARY_DIR}/Inspect-build/info.cmake") - - if(CMAKE_INCLUDE_SYSTEM_FLAG_CXX) - if(RunCMake_GENERATOR MATCHES "Visual Studio") - string(REGEX REPLACE "^-" "/" test_expect_stdout "${CMAKE_INCLUDE_SYSTEM_FLAG_CXX}") - else() - set(test_expect_stdout "-*${CMAKE_INCLUDE_SYSTEM_FLAG_CXX}") - endif() - string(APPEND test_expect_stdout " *(\"[^\"]*|([^ ]|\\ )*)[\\/]dummy_autogen[\\/]include") - if(RunCMake_GENERATOR_IS_MULTI_CONFIG) - string(APPEND test_expect_stdout "_Debug") - endif() - - block() - set(RunCMake_TEST_BINARY_DIR ${RunCMake_BINARY_DIR}/CMP0151-new-build) - run_cmake_with_options(CMP0151-new ${RunCMake_TEST_OPTIONS} -DCMAKE_POLICY_DEFAULT_CMP0151=NEW) - set(RunCMake_TEST_NO_CLEAN 1) - set(RunCMake_TEST_EXPECT_stdout "${test_expect_stdout}") - message(STATUS "RunCMake_TEST_EXPECT_stdout: ${RunCMake_TEST_EXPECT_stdout}") - run_cmake_command(CMP0151-new-build ${CMAKE_COMMAND} --build . --config Debug --verbose) - endblock() - - block() - set(RunCMake_TEST_BINARY_DIR ${RunCMake_BINARY_DIR}/AutogenUseSystemIncludeOn-build) - run_cmake_with_options(AutogenUseSystemIncludeOn ${RunCMake_TEST_OPTIONS} -DCMAKE_POLICY_DEFAULT_CMP0151=NEW) - set(RunCMake_TEST_NO_CLEAN 1) - set(RunCMake_TEST_EXPECT_stdout "${test_expect_stdout}") - message(STATUS "RunCMake_TEST_EXPECT_stdout: ${RunCMake_TEST_EXPECT_stdout}") - run_cmake_command(AutogenUseSystemIncludeOn ${CMAKE_COMMAND} --build . --config Debug --verbose) - endblock() - endif() - - if(CMAKE_INCLUDE_FLAG_CXX) - if(RunCMake_GENERATOR MATCHES "Visual Studio") - string(REGEX REPLACE "^-" "/" test_expect_stdout "${CMAKE_INCLUDE_FLAG_CXX}") - else() - set(test_expect_stdout "-*${CMAKE_INCLUDE_FLAG_CXX}") - endif() - string(APPEND test_expect_stdout " *(\"[^\"]*|([^ ]|\\ )*)[\\/]dummy_autogen[\\/]include") - if(RunCMake_GENERATOR_IS_MULTI_CONFIG) - string(APPEND test_expect_stdout "_Debug") - endif() - - block() - set(RunCMake_TEST_BINARY_DIR ${RunCMake_BINARY_DIR}/CMP0151-old-build) - run_cmake_with_options(CMP0151-old ${RunCMake_TEST_OPTIONS} -DCMAKE_POLICY_DEFAULT_CMP0151=OLD) - set(RunCMake_TEST_NO_CLEAN 1) - set(RunCMake_TEST_EXPECT_stdout "${test_expect_stdout}") - message(STATUS "RunCMake_TEST_EXPECT_stdout: ${RunCMake_TEST_EXPECT_stdout}") - run_cmake_command(CMP0151-old-build ${CMAKE_COMMAND} --build . --config Debug --verbose) - endblock() - - block() - set(RunCMake_TEST_BINARY_DIR ${RunCMake_BINARY_DIR}/AutogenUseSystemIncludeOff-build) - run_cmake_with_options(AutogenUseSystemIncludeOff ${RunCMake_TEST_OPTIONS} -DCMAKE_POLICY_DEFAULT_CMP0151=NEW) - set(RunCMake_TEST_NO_CLEAN 1) - set(RunCMake_TEST_EXPECT_stdout "${test_expect_stdout}") - message(STATUS "RunCMake_TEST_EXPECT_stdout: ${RunCMake_TEST_EXPECT_stdout}") - run_cmake_command(AutogenUseSystemIncludeOff ${CMAKE_COMMAND} --build . --config Debug --verbose) - endblock() - - if(RunCMake_GENERATOR MATCHES "Make|Ninja") - block() - set(RunCMake_TEST_BINARY_DIR ${RunCMake_BINARY_DIR}/AutogenSkipLinting-build) - list(APPEND RunCMake_TEST_OPTIONS - "-DPSEUDO_CPPCHECK=${PSEUDO_CPPCHECK}" - "-DPSEUDO_CPPLINT=${PSEUDO_CPPLINT}" - "-DPSEUDO_IWYU=${PSEUDO_IWYU}" - "-DPSEUDO_TIDY=${PSEUDO_TIDY}") - - run_cmake(AutogenSkipLinting) - set(RunCMake_TEST_NO_CLEAN 1) - run_cmake_command(AutogenSkipLinting-build ${CMAKE_COMMAND} --build . --config Debug --verbose) - endblock() - endif() - endif() - - if(RunCMake_GENERATOR_IS_MULTI_CONFIG AND NOT RunCMake_GENERATOR MATCHES "Xcode") - block() - set(RunCMake_TEST_BINARY_DIR ${RunCMake_BINARY_DIR}/MocGeneratedFile-build) - run_cmake(MocGeneratedFile) - set(RunCMake_TEST_NO_CLEAN 1) - run_cmake_command(MocGeneratedFile-build ${CMAKE_COMMAND} --build . --config Debug --verbose) - endblock() - if(RunCMake_GENERATOR MATCHES "Ninja Multi-Config") - block() - set(RunCMake_TEST_BINARY_DIR ${RunCMake_BINARY_DIR}/MocGeneratedFile-cross-config-build) - list(APPEND RunCMake_TEST_OPTIONS -DCMAKE_CROSS_CONFIGS=all) - run_cmake(MocGeneratedFile) - set(RunCMake_TEST_NO_CLEAN 1) - run_cmake_command(MocGeneratedFile-cross-config-build ${CMAKE_COMMAND} --build . --config Release --target libgen:Debug) - run_cmake_command(MocGeneratedFile-cross-config-build ${CMAKE_COMMAND} --build . --config Debug --target libgen:Release) - endblock() - endif() - endif() - - if(RunCMake_GENERATOR MATCHES "Make|Ninja") - block() - if(QtCore_VERSION VERSION_GREATER_EQUAL 5.15.0) - if (RunCMake_GENERATOR MATCHES "Ninja Multi-Config") - set(config_list Debug Release RelWithDebInfo) - set(use_better_graph_list ON OFF) - else() - set(config_list single-config) - set(use_better_graph_list OFF) - endif() - - foreach(use_better_graph IN ITEMS ${use_better_graph_list}) - foreach(config IN ITEMS ${config_list}) - block() - if (config STREQUAL "single-config") - set(config_suffix "") - else() - set(config_path "_${config}") - if (use_better_graph) - set(config_suffix "_${config}") - endif() - endif() - - set(RunCMake_TEST_BINARY_DIR ${RunCMake_BINARY_DIR}/QtAutoMocDeps${config_path}-build) - run_cmake_with_options(QtAutoMocDeps ${RunCMake_TEST_OPTIONS} -DCMAKE_AUTOGEN_BETTER_GRAPH_MULTI_CONFIG=${use_better_graph}) - set(RunCMake_TEST_NO_CLEAN 1) - # Build the project. - if (config STREQUAL "single-config") - set(config_param "") - else() - set(config_param "--config ${config}") - endif() - run_cmake_command(QtAutoMocDeps-build ${CMAKE_COMMAND} --build . --verbose ${config_param}) - # Touch just the library source file, which shouldn't cause a rerun of AUTOMOC - # for app_with_qt target. - file(TOUCH "${RunCMake_SOURCE_DIR}/simple_lib.cpp") - set(RunCMake_TEST_NOT_EXPECT_stdout "Automatic MOC for target app_with_qt|\ -Automatic MOC for target sub_exe_1|\ -Automatic MOC for target sub_exe_2") - set(RunCMake_TEST_VARIANT_DESCRIPTION "-Don't execute AUTOMOC for 'app_with_qt', 'sub_exe_1' and 'sub_exe_2'") - # Build and assert that AUTOMOC was not run for app_with_qt, sub_exe_1 and sub_exe_2. - run_cmake_command(QtAutoMocDeps-build ${CMAKE_COMMAND} --build . --verbose ${config_param}) - unset(RunCMake_TEST_VARIANT_DESCRIPTION) - unset(RunCMake_TEST_NOT_EXPECT_stdout) - - macro(check_file_exists file) - if (EXISTS "${file}") - set(check_result "PASSED") - set(message_type "STATUS") - else() - set(check_result "FAILED") - set(message_type "FATAL_ERROR") - endif() - - message(${message_type} "QtAutoMocDeps-build-\"${file}\" was generated - ${check_result}") - endmacro() - - check_file_exists("${RunCMake_TEST_BINARY_DIR}/app_with_qt_autogen/deps${config_suffix}") - check_file_exists("${RunCMake_TEST_BINARY_DIR}/QtSubDir1/sub_exe_1_autogen/deps${config_suffix}") - check_file_exists("${RunCMake_TEST_BINARY_DIR}/QtSubDir2/sub_exe_2_autogen/deps${config_suffix}") - - check_file_exists("${RunCMake_TEST_BINARY_DIR}/app_with_qt_autogen/timestamp${config_suffix}") - check_file_exists("${RunCMake_TEST_BINARY_DIR}/QtSubDir1/sub_exe_1_autogen/timestamp${config_suffix}") - check_file_exists("${RunCMake_TEST_BINARY_DIR}/QtSubDir2/sub_exe_2_autogen/timestamp${config_suffix}") - - # Touch a header file to make sure an automoc dependency cycle is not introduced. - file(TOUCH "${RunCMake_SOURCE_DIR}/MyWindow.h") - set(RunCMake_TEST_VARIANT_DESCRIPTION "-First build after touch to detect dependency cycle") - run_cmake_command(QtAutoMocDeps-build ${CMAKE_COMMAND} --build . --verbose) - # Need to run a second time to hit the dependency cycle. - set(RunCMake_TEST_VARIANT_DESCRIPTION "-Don't hit dependency cycle") - run_cmake_command(QtAutoMocDeps-build ${CMAKE_COMMAND} --build . --verbose) - endblock() - endforeach() - endforeach() - endif() - endblock() - endif() - - function(run_make_program dir) - execute_process( - COMMAND "${RunCMake_MAKE_PROGRAM}" ${ARGN} - WORKING_DIRECTORY "${dir}" - OUTPUT_VARIABLE make_program_stdout - ERROR_VARIABLE make_program_stderr - RESULT_VARIABLE make_program_result - ) - if (NOT DEFINED RunMakeProgram_expected_result) - set(RunMakeProgram_expected_result 0) - endif() - if(NOT "${make_program_result}" MATCHES "${RunMakeProgram_expected_result}") - message(STATUS " -============ beginning of ${RunCMake_MAKE_PROGRAM}'s stdout ============ -${make_program_stdout} -=============== end of ${RunCMake_MAKE_PROGRAM}'s stdout =============== -") - message(STATUS " -============ beginning of ${RunCMake_MAKE_PROGRAM}'s stderr ============ -${make_program_stderr} -=============== end of ${RunCMake_MAKE_PROGRAM}'s stderr =============== -") - message(FATAL_ERROR - "top ${RunCMake_MAKE_PROGRAM} build failed exited with status ${make_program_result}") - endif() - set(make_program_stdout "${make_program_stdout}" PARENT_SCOPE) - endfunction(run_make_program) - - function(count_substring STRING SUBSTRING COUNT_VAR) - string(LENGTH "${STRING}" STRING_LENGTH) - string(LENGTH "${SUBSTRING}" SUBSTRING_LENGTH) - if (SUBSTRING_LENGTH EQUAL 0) - message(FATAL_ERROR "SUBSTRING_LENGTH is 0") - endif() - - if (STRING_LENGTH EQUAL 0) - message(FATAL_ERROR "STRING_LENGTH is 0") - endif() - - if (STRING_LENGTH LESS SUBSTRING_LENGTH) - message(FATAL_ERROR "STRING_LENGTH is less than SUBSTRING_LENGTH") - endif() - - set(COUNT 0) - string(FIND "${STRING}" "${SUBSTRING}" SUBSTRING_START) - while(SUBSTRING_START GREATER_EQUAL 0) - math(EXPR COUNT "${COUNT} + 1") - math(EXPR SUBSTRING_START "${SUBSTRING_START} + ${SUBSTRING_LENGTH}") - string(SUBSTRING "${STRING}" ${SUBSTRING_START} -1 STRING) - string(FIND "${STRING}" "${SUBSTRING}" SUBSTRING_START) - endwhile() - - set(${COUNT_VAR} ${COUNT} PARENT_SCOPE) - endfunction() - - function(expect_only_once make_program_stdout expected_output test_name) - count_substring("${make_program_stdout}" "${expected_output}" count) - if(NOT count EQUAL 1) - message(STATUS "${test_name}-expect_only_once - FAILED") - message(FATAL_ERROR "Expected to find ${expected_output} exactly once in ${make_program_stdout} but found ${count} occurrences of ${expected_output}") - else() - message(STATUS "${test_name}-expect_only_once - PASSED") - endif() - endfunction() - - function(expect_n_times string_to_check expected_output expected_count test_name) - count_substring("${string_to_check}" "${expected_output}" count) - if(NOT count EQUAL ${expected_count}) - message(STATUS "${test_name}-expect_${expected_count}_times - FAILED") - message(FATAL_ERROR "Expected to find ${expected_output} exactly ${expected_count} times in ${string_to_check} but found ${count} occurrences of ${expected_output}") - else() - message(STATUS "${test_name}-expect_${expected_count}_times - PASSED") - endif() - endfunction() - - function(not_expect make_program_stdout unexpected_output test_name) - count_substring("${make_program_stdout}" "${unexpected_output}" count) - if(NOT count EQUAL 0) - message(STATUS "${test_name}-not_expect - FAILED") - message(FATAL_ERROR "Expected to find ${unexpected_output} exactly 0 times in ${make_program_stdout} but found ${count} occurrences of ${unexpected_output}") - else() - message(STATUS "${test_name}-not_expect - PASSED") - endif() - endfunction() - - if (QtCore_VERSION VERSION_GREATER_EQUAL 5.15.0) - foreach(exe IN ITEMS Moc Uic Rcc) - if(RunCMake_GENERATOR MATCHES "Ninja Multi-Config") - block() - set(RunCMake_TEST_VARIANT_DESCRIPTION "-CMake-configure") - set(RunCMake_TEST_BINARY_DIR ${RunCMake_BINARY_DIR}/Auto${exe}ExecutableConfig-multi-config-build) - run_cmake_with_options(Auto${exe}ExecutableConfig ${RunCMake_TEST_OPTIONS} -DCMAKE_AUTOGEN_VERBOSE=ON -DCMAKE_AUTOGEN_BETTER_GRAPH_MULTI_CONFIG=ON) - unset(RunCMake_TEST_VARIANT_DESCRIPTION) - set(RunCMake_TEST_NO_CLEAN 1) - foreach(config IN ITEMS Debug Release RelWithDebInfo) - block() - set(RunCMake_TEST_EXPECT_stdout ".*running_exe_${config}*") - set(RunCMake_TEST_VARIANT_DESCRIPTION "-${config}-expect_running_exe_${config}") - run_cmake_command(Auto${exe}ExecutableConfig-multi-config-build ${CMAKE_COMMAND} --build . --config ${config}) - endblock() - endforeach() - set(RunCMake_TEST_EXPECT_stdout "ninja: no work to do") - foreach(config IN ITEMS Debug Release RelWithDebInfo) - block() - set(RunCMake_TEST_VARIANT_DESCRIPTION "-${config}-expect_no_work_to_do") - run_cmake_command(Auto${exe}ExecutableConfig-multi-config-build ${CMAKE_COMMAND} --build . --config ${config}) - endblock() - endforeach() - endblock() - block() - set(RunCMake_TEST_BINARY_DIR ${RunCMake_BINARY_DIR}/Auto${exe}ExecutableConfig-build) - run_cmake_with_options(Auto${exe}ExecutableConfig ${RunCMake_TEST_OPTIONS} -DCMAKE_AUTOGEN_VERBOSE=ON -DCMAKE_AUTOGEN_BETTER_GRAPH_MULTI_CONFIG=ON) - foreach(config IN ITEMS Debug Release RelWithDebInfo) - block() - run_make_program(${RunCMake_TEST_BINARY_DIR} --verbose -f build-${config}.ninja) - - set(expected_output "running_exe_${config}") - expect_only_once("${make_program_stdout}" "${expected_output}" "Auto${exe}ExecutableConfig-${config}-${expected_output}") - - foreach(sub_config IN ITEMS Debug Release RelWithDebInfo) - if(NOT sub_config STREQUAL config) - set(unexpected_output "running_exe_${sub_config}") - not_expect("${make_program_stdout}" "${unexpected_output}" "Auto${exe}ExecutableConfig-${config}-${unexpected_output}") - endif() - endforeach() - - if (exe STREQUAL "Moc" OR exe STREQUAL "Uic") - set(expected_output "cmake_autogen") - else() - set(expected_output "cmake_autorcc") - endif() - expect_only_once("${make_program_stdout}" "${expected_output}" "Auto${exe}ExecutableConfig-${config}-${expected_output}") - endblock() - endforeach() - endblock() - block() - foreach(ninja_config IN ITEMS Debug Release RelWithDebInfo) - foreach(target_config IN ITEMS Debug Release RelWithDebInfo) - block() - set(TEST_SUFFIX "-CrossConfig-${ninja_config}-${target_config}") - set(RunCMake_TEST_BINARY_DIR ${RunCMake_BINARY_DIR}/Auto${exe}ExecutableConfig${TEST_SUFFIX}-build) - set(RunCMake_TEST_VARIANT_DESCRIPTION ${TEST_SUFFIX}) - run_cmake_with_options(Auto${exe}ExecutableConfig ${RunCMake_TEST_OPTIONS} -DCMAKE_CROSS_CONFIGS=all -DCMAKE_DEFAULT_BUILD_TYPE=${ninja_config} -DCMAKE_AUTOGEN_BETTER_GRAPH_MULTI_CONFIG=ON) - unset(RunCMake_TEST_VARIANT_DESCRIPTION) - - run_make_program(${RunCMake_TEST_BINARY_DIR} --verbose -f build-${ninja_config}.ninja dummy:${target_config}) - - set(expected_output "running_exe_${ninja_config}") - expect_only_once("${make_program_stdout}" "${expected_output}" "Auto${exe}ExecutableConfig${TEST_SUFFIX}-${expected_output}") - - foreach(sub_config IN ITEMS Debug Release RelWithDebInfo) - if(NOT sub_config STREQUAL ninja_config) - set(unexpected_output "running_exe_${sub_config}") - not_expect("${make_program_stdout}" "${unexpected_output}" "Auto${exe}ExecutableConfig${TEST_SUFFIX}-${unexpected_output}") - endif() - endforeach() - - if (exe STREQUAL "Moc" OR exe STREQUAL "Uic") - set(expected_output "cmake_autogen") - else() - set(expected_output "cmake_autorcc") - endif() - expect_only_once("${make_program_stdout}" "${expected_output}" "Auto${exe}ExecutableConfig${TEST_SUFFIX}-${expected_output}") - endblock() - endforeach() - endforeach() - endblock() - block() - foreach(ninja_config IN ITEMS Debug Release RelWithDebInfo) - set(TEST_SUFFIX "-CrossConfig-${ninja_config}-all-all") - set(RunCMake_TEST_BINARY_DIR ${RunCMake_BINARY_DIR}/Auto${exe}ExecutableConfig${TEST_SUFFIX}-build) - set(RunCMake_TEST_VARIANT_DESCRIPTION ${TEST_SUFFIX}) - run_cmake_with_options(Auto${exe}ExecutableConfig ${RunCMake_TEST_OPTIONS} -DCMAKE_CROSS_CONFIGS=all -DCMAKE_AUTOGEN_BETTER_GRAPH_MULTI_CONFIG=ON) - unset(RunCMake_TEST_VARIANT_DESCRIPTION) - run_make_program(${RunCMake_TEST_BINARY_DIR} --verbose -f build-${ninja_config}.ninja all:all) - endforeach() - endblock() - elseif (RunCMake_GENERATOR MATCHES "Ninja|Make") - block() - set(RunCMake_TEST_BINARY_DIR ${RunCMake_BINARY_DIR}/Auto${exe}ExecutableConfig-build) - foreach(config IN ITEMS Debug Release RelWithDebInfo) - block() - set(RunCMake_TEST_VARIANT_DESCRIPTION "-${config}") - run_cmake_with_options(Auto${exe}ExecutableConfig ${RunCMake_TEST_OPTIONS} -DCMAKE_BUILD_TYPE=${config} -DCMAKE_AUTOGEN_VERBOSE=ON) - unset(RunCMake_TEST_VARIANT_DESCRIPTION) - set(RunCMake_TEST_NO_CLEAN 1) - set(RunCMake_TEST_EXPECT_stdout ".*running_exe_${config}*") - run_cmake_command(Auto${exe}ExecutableConfig-${config}-build ${CMAKE_COMMAND} --build .) - endblock() - endforeach() - endblock() - endif() - endforeach() - endif() - - # Visual Studio specific dependency tests - if (RunCMake_GENERATOR MATCHES "Visual Studio") - foreach(exe IN ITEMS Moc Uic Rcc) - block() - set(RunCMake_TEST_BINARY_DIR ${RunCMake_BINARY_DIR}/${exe}Example-build) - set(RunCMake_TEST_VARIANT_DESCRIPTION "-CMake-configure") - run_cmake_with_options(${exe}Example ${RunCMake_TEST_OPTIONS} -DCMAKE_AUTOGEN_VERBOSE=ON) - unset(RunCMake_TEST_VARIANT_DESCRIPTION) - set(RunCMake_TEST_NO_CLEAN 1) - foreach(config IN ITEMS Debug Release RelWithDebInfo) - block() - set(RunCMake_TEST_VARIANT_DESCRIPTION "-${config}-first-build") - run_cmake_command(${exe}Example-build ${CMAKE_COMMAND} --build . --config ${config}) - endblock() - endforeach() - foreach(config IN ITEMS Debug Release RelWithDebInfo) - block() - if (exe STREQUAL "Moc" OR exe STREQUAL "Uic") - set(RunCMake_TEST_NOT_EXPECT_stdout "Auto${exe}") - set(not_expect_descripton "Auto${exe}") - else () - set(RunCMake_TEST_NOT_EXPECT_stdout "Auto${exe}") - set(not_expect_descripton "Auto${exe}") - endif() - set(RunCMake_TEST_VARIANT_DESCRIPTION "-second-build-${config}_expect_no_${not_expect_descripton}") - run_cmake_command(${exe}Example-build ${CMAKE_COMMAND} --build . --config ${config}) - endblock() - endforeach() - endblock() - endforeach() - endif() - - if (RunCMake_GENERATOR MATCHES "Xcode") - foreach(exe IN ITEMS Moc Uic Rcc) - block() - set(RunCMake_TEST_BINARY_DIR ${RunCMake_BINARY_DIR}/${exe}Example-build) - set(RunCMake_TEST_VARIANT_DESCRIPTION "-CMake-configure") - set(RunCMake_TEST_EXPECT_stderr ".*") - run_cmake_with_options(${exe}Example ${RunCMake_TEST_OPTIONS} -DCMAKE_AUTOGEN_VERBOSE=ON) - set(RunCMake_TEST_NO_CLEAN 1) - set(RunCMake_MAKE_PROGRAM ${CMAKE_COMMAND}) - run_make_program(${RunCMake_TEST_BINARY_DIR} --build . --config Debug) - if (exe STREQUAL "Moc") - set(expected_count 16) - elseif (exe STREQUAL "Uic") - set(expected_count 4) - else() - set(expected_count 12) - endif() - expect_n_times("${make_program_stdout}" "Auto${exe}:" ${expected_count} "${exe}Example-build-Auto${exe}") - expect_n_times("${make_program_stdout}" "Auto${exe}:" ${expected_count} "${exe}Example-build-Auto${exe}") - - if (exe STREQUAL "Moc" OR exe STREQUAL "Uic") - expect_n_times("${make_program_stdout}" "AutoGen:" 20 "${exe}Example-build-AutoGen:") - endif() - - foreach(config IN ITEMS Debug Release RelWithDebInfo) - block() - run_make_program(${RunCMake_TEST_BINARY_DIR} --build . --config ${config}) - not_expect("${make_program_stdout}" "Auto${exe}" "${exe}Example-${config}_Auto${exe}") - not_expect("${make_program_stdout}" "AutoGen:" "${exe}Example-${config}_AutoGen") - endblock() - endforeach() - endblock() - endforeach() - endif() - - if (QtCore_VERSION VERSION_GREATER_EQUAL 6) - if (RunCMake_GENERATOR MATCHES "Make|Ninja") - foreach(value IN ITEMS ON OFF) - block() - set(RunCMake_TEST_BINARY_DIR - ${RunCMake_BINARY_DIR}/RccNoZTSD-${value}-build) - run_cmake_with_options(RccExample ${RunCMake_TEST_OPTIONS} - -DCMAKE_AUTOGEN_VERBOSE=ON -DZSTD_VALUE=${value}) - if (value STREQUAL "OFF") - set(RunCMake_TEST_EXPECT_stdout "--no-zstd") - else() - set(RunCMake_TEST_NOT_EXPECT_stdout "--no-zstd") - endif() - set(RunCMake_TEST_NO_CLEAN 1) - run_cmake_command(RccNoZTSD-${value}-build ${CMAKE_COMMAND} - --build . --config Debug) - endblock() - endforeach() - endif() - endif() -endif () diff --git a/Tests/RunCMake/Autogen/AutogenSkipLinting-build-stderr.txt b/Tests/RunCMake/Autogen_1/AutogenSkipLinting-build-stderr.txt index 8d98f9d..8d98f9d 100644 --- a/Tests/RunCMake/Autogen/AutogenSkipLinting-build-stderr.txt +++ b/Tests/RunCMake/Autogen_1/AutogenSkipLinting-build-stderr.txt diff --git a/Tests/RunCMake/Autogen/AutogenSkipLinting.cmake b/Tests/RunCMake/Autogen_1/AutogenSkipLinting.cmake index 3ce2092..3ce2092 100644 --- a/Tests/RunCMake/Autogen/AutogenSkipLinting.cmake +++ b/Tests/RunCMake/Autogen_1/AutogenSkipLinting.cmake diff --git a/Tests/RunCMake/Autogen/AutogenUseSystemIncludeCommon.cmake b/Tests/RunCMake/Autogen_1/AutogenUseSystemIncludeCommon.cmake index bbefd5f..bbefd5f 100644 --- a/Tests/RunCMake/Autogen/AutogenUseSystemIncludeCommon.cmake +++ b/Tests/RunCMake/Autogen_1/AutogenUseSystemIncludeCommon.cmake diff --git a/Tests/RunCMake/Autogen/AutogenUseSystemIncludeOff.cmake b/Tests/RunCMake/Autogen_1/AutogenUseSystemIncludeOff.cmake index dfdbb98..dfdbb98 100644 --- a/Tests/RunCMake/Autogen/AutogenUseSystemIncludeOff.cmake +++ b/Tests/RunCMake/Autogen_1/AutogenUseSystemIncludeOff.cmake diff --git a/Tests/RunCMake/Autogen/AutogenUseSystemIncludeOn.cmake b/Tests/RunCMake/Autogen_1/AutogenUseSystemIncludeOn.cmake index f556ed4..f556ed4 100644 --- a/Tests/RunCMake/Autogen/AutogenUseSystemIncludeOn.cmake +++ b/Tests/RunCMake/Autogen_1/AutogenUseSystemIncludeOn.cmake diff --git a/Tests/RunCMake/Autogen/CMP0111-imported-target-full.cmake b/Tests/RunCMake/Autogen_1/CMP0111-imported-target-full.cmake index 331da64..331da64 100644 --- a/Tests/RunCMake/Autogen/CMP0111-imported-target-full.cmake +++ b/Tests/RunCMake/Autogen_1/CMP0111-imported-target-full.cmake diff --git a/Tests/RunCMake/Autogen/CMP0111-imported-target-implib-only.cmake b/Tests/RunCMake/Autogen_1/CMP0111-imported-target-implib-only.cmake index 8640fdc..8640fdc 100644 --- a/Tests/RunCMake/Autogen/CMP0111-imported-target-implib-only.cmake +++ b/Tests/RunCMake/Autogen_1/CMP0111-imported-target-implib-only.cmake diff --git a/Tests/RunCMake/Autogen/CMP0111-imported-target-libname.cmake b/Tests/RunCMake/Autogen_1/CMP0111-imported-target-libname.cmake index e1318c2..e1318c2 100644 --- a/Tests/RunCMake/Autogen/CMP0111-imported-target-libname.cmake +++ b/Tests/RunCMake/Autogen_1/CMP0111-imported-target-libname.cmake diff --git a/Tests/RunCMake/Autogen/CMP0111-imported-target-prelude.cmake b/Tests/RunCMake/Autogen_1/CMP0111-imported-target-prelude.cmake index 6d26f99..6d26f99 100644 --- a/Tests/RunCMake/Autogen/CMP0111-imported-target-prelude.cmake +++ b/Tests/RunCMake/Autogen_1/CMP0111-imported-target-prelude.cmake diff --git a/Tests/RunCMake/Autogen/CMP0151-common.cmake b/Tests/RunCMake/Autogen_1/CMP0151-common.cmake index bbefd5f..bbefd5f 100644 --- a/Tests/RunCMake/Autogen/CMP0151-common.cmake +++ b/Tests/RunCMake/Autogen_1/CMP0151-common.cmake diff --git a/Tests/RunCMake/Autogen/CMP0151-new.cmake b/Tests/RunCMake/Autogen_1/CMP0151-new.cmake index 9c77e58..9c77e58 100644 --- a/Tests/RunCMake/Autogen/CMP0151-new.cmake +++ b/Tests/RunCMake/Autogen_1/CMP0151-new.cmake diff --git a/Tests/RunCMake/Autogen/CMP0151-old.cmake b/Tests/RunCMake/Autogen_1/CMP0151-old.cmake index 9c77e58..9c77e58 100644 --- a/Tests/RunCMake/Autogen/CMP0151-old.cmake +++ b/Tests/RunCMake/Autogen_1/CMP0151-old.cmake diff --git a/Tests/RunCMake/Autogen/CMakeLists.txt b/Tests/RunCMake/Autogen_1/CMakeLists.txt index 2632ffa..2632ffa 100644 --- a/Tests/RunCMake/Autogen/CMakeLists.txt +++ b/Tests/RunCMake/Autogen_1/CMakeLists.txt diff --git a/Tests/RunCMake/Autogen/Inspect.cmake b/Tests/RunCMake/Autogen_1/Inspect.cmake index d5dc4b4..d5dc4b4 100644 --- a/Tests/RunCMake/Autogen/Inspect.cmake +++ b/Tests/RunCMake/Autogen_1/Inspect.cmake diff --git a/Tests/RunCMake/Autogen/MocGeneratedFile.cmake b/Tests/RunCMake/Autogen_1/MocGeneratedFile.cmake index 7bb55e9..7bb55e9 100644 --- a/Tests/RunCMake/Autogen/MocGeneratedFile.cmake +++ b/Tests/RunCMake/Autogen_1/MocGeneratedFile.cmake diff --git a/Tests/RunCMake/Autogen/MocPredefs-build-stderr.txt b/Tests/RunCMake/Autogen_1/MocPredefs-build-stderr.txt index 8d98f9d..8d98f9d 100644 --- a/Tests/RunCMake/Autogen/MocPredefs-build-stderr.txt +++ b/Tests/RunCMake/Autogen_1/MocPredefs-build-stderr.txt diff --git a/Tests/RunCMake/Autogen/MocPredefs-check.cxx b/Tests/RunCMake/Autogen_1/MocPredefs-check.cxx index 2b4791f..2b4791f 100644 --- a/Tests/RunCMake/Autogen/MocPredefs-check.cxx +++ b/Tests/RunCMake/Autogen_1/MocPredefs-check.cxx diff --git a/Tests/RunCMake/Autogen/MocPredefs-prefix.cmake b/Tests/RunCMake/Autogen_1/MocPredefs-prefix.cmake index 460a05d..460a05d 100644 --- a/Tests/RunCMake/Autogen/MocPredefs-prefix.cmake +++ b/Tests/RunCMake/Autogen_1/MocPredefs-prefix.cmake diff --git a/Tests/RunCMake/Autogen/MocPredefs.cmake b/Tests/RunCMake/Autogen_1/MocPredefs.cmake index 8307e04..8307e04 100644 --- a/Tests/RunCMake/Autogen/MocPredefs.cmake +++ b/Tests/RunCMake/Autogen_1/MocPredefs.cmake diff --git a/Tests/RunCMake/Autogen/MocPredefs.cxx b/Tests/RunCMake/Autogen_1/MocPredefs.cxx index b27cec5..b27cec5 100644 --- a/Tests/RunCMake/Autogen/MocPredefs.cxx +++ b/Tests/RunCMake/Autogen_1/MocPredefs.cxx diff --git a/Tests/RunCMake/Autogen/NoQt-stderr.txt b/Tests/RunCMake/Autogen_1/NoQt-stderr.txt index 1c6660a..1c6660a 100644 --- a/Tests/RunCMake/Autogen/NoQt-stderr.txt +++ b/Tests/RunCMake/Autogen_1/NoQt-stderr.txt diff --git a/Tests/RunCMake/Autogen/NoQt.cmake b/Tests/RunCMake/Autogen_1/NoQt.cmake index b2d375a..b2d375a 100644 --- a/Tests/RunCMake/Autogen/NoQt.cmake +++ b/Tests/RunCMake/Autogen_1/NoQt.cmake diff --git a/Tests/RunCMake/Autogen/QtInFunction.cmake b/Tests/RunCMake/Autogen_1/QtInFunction.cmake index 6c42cc2..6c42cc2 100644 --- a/Tests/RunCMake/Autogen/QtInFunction.cmake +++ b/Tests/RunCMake/Autogen_1/QtInFunction.cmake diff --git a/Tests/RunCMake/Autogen/QtInFunctionNested-stderr.txt b/Tests/RunCMake/Autogen_1/QtInFunctionNested-stderr.txt index 1c6660a..1c6660a 100644 --- a/Tests/RunCMake/Autogen/QtInFunctionNested-stderr.txt +++ b/Tests/RunCMake/Autogen_1/QtInFunctionNested-stderr.txt diff --git a/Tests/RunCMake/Autogen/QtInFunctionNested.cmake b/Tests/RunCMake/Autogen_1/QtInFunctionNested.cmake index 2e7b8ad..2e7b8ad 100644 --- a/Tests/RunCMake/Autogen/QtInFunctionNested.cmake +++ b/Tests/RunCMake/Autogen_1/QtInFunctionNested.cmake diff --git a/Tests/RunCMake/Autogen/QtInFunctionProperty.cmake b/Tests/RunCMake/Autogen_1/QtInFunctionProperty.cmake index d9296c4..d9296c4 100644 --- a/Tests/RunCMake/Autogen/QtInFunctionProperty.cmake +++ b/Tests/RunCMake/Autogen_1/QtInFunctionProperty.cmake diff --git a/Tests/RunCMake/Autogen_1/RunCMakeTest.cmake b/Tests/RunCMake/Autogen_1/RunCMakeTest.cmake new file mode 100644 index 0000000..64add97 --- /dev/null +++ b/Tests/RunCMake/Autogen_1/RunCMakeTest.cmake @@ -0,0 +1,125 @@ +include(RunCMake) + +run_cmake(NoQt) +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) + + run_cmake(CMP0111-imported-target-full) + run_cmake(CMP0111-imported-target-libname) + run_cmake(CMP0111-imported-target-implib-only) + + block() + set(RunCMake_TEST_BINARY_DIR ${RunCMake_BINARY_DIR}/MocPredefs-build) + run_cmake(MocPredefs) + set(RunCMake_TEST_NO_CLEAN 1) + run_cmake_command(MocPredefs-build ${CMAKE_COMMAND} --build . --config Debug) + endblock() + + # Detect information from the toolchain: + # - CMAKE_INCLUDE_FLAG_CXX + # - CMAKE_INCLUDE_SYSTEM_FLAG_CXX + run_cmake(Inspect) + include("${RunCMake_BINARY_DIR}/Inspect-build/info.cmake") + + if(CMAKE_INCLUDE_SYSTEM_FLAG_CXX) + if(RunCMake_GENERATOR MATCHES "Visual Studio") + string(REGEX REPLACE "^-" "/" test_expect_stdout "${CMAKE_INCLUDE_SYSTEM_FLAG_CXX}") + else() + set(test_expect_stdout "-*${CMAKE_INCLUDE_SYSTEM_FLAG_CXX}") + endif() + string(APPEND test_expect_stdout " *(\"[^\"]*|([^ ]|\\ )*)[\\/]dummy_autogen[\\/]include") + if(RunCMake_GENERATOR_IS_MULTI_CONFIG) + string(APPEND test_expect_stdout "_Debug") + endif() + + block() + set(RunCMake_TEST_BINARY_DIR ${RunCMake_BINARY_DIR}/CMP0151-new-build) + run_cmake_with_options(CMP0151-new ${RunCMake_TEST_OPTIONS} -DCMAKE_POLICY_DEFAULT_CMP0151=NEW) + set(RunCMake_TEST_NO_CLEAN 1) + set(RunCMake_TEST_EXPECT_stdout "${test_expect_stdout}") + run_cmake_command(CMP0151-new-build ${CMAKE_COMMAND} --build . --config Debug --verbose) + endblock() + + block() + set(RunCMake_TEST_BINARY_DIR ${RunCMake_BINARY_DIR}/AutogenUseSystemIncludeOn-build) + run_cmake_with_options(AutogenUseSystemIncludeOn ${RunCMake_TEST_OPTIONS} -DCMAKE_POLICY_DEFAULT_CMP0151=NEW) + set(RunCMake_TEST_NO_CLEAN 1) + set(RunCMake_TEST_EXPECT_stdout "${test_expect_stdout}") + run_cmake_command(AutogenUseSystemIncludeOn ${CMAKE_COMMAND} --build . --config Debug --verbose) + endblock() + endif() + + if(CMAKE_INCLUDE_FLAG_CXX) + if(RunCMake_GENERATOR MATCHES "Visual Studio") + string(REGEX REPLACE "^-" "/" test_expect_stdout "${CMAKE_INCLUDE_FLAG_CXX}") + else() + set(test_expect_stdout "-*${CMAKE_INCLUDE_FLAG_CXX}") + endif() + string(APPEND test_expect_stdout " *(\"[^\"]*|([^ ]|\\ )*)[\\/]dummy_autogen[\\/]include") + if(RunCMake_GENERATOR_IS_MULTI_CONFIG) + string(APPEND test_expect_stdout "_Debug") + endif() + + block() + set(RunCMake_TEST_BINARY_DIR ${RunCMake_BINARY_DIR}/CMP0151-old-build) + run_cmake_with_options(CMP0151-old ${RunCMake_TEST_OPTIONS} -DCMAKE_POLICY_DEFAULT_CMP0151=OLD) + set(RunCMake_TEST_NO_CLEAN 1) + set(RunCMake_TEST_EXPECT_stdout "${test_expect_stdout}") + run_cmake_command(CMP0151-old-build ${CMAKE_COMMAND} --build . --config Debug --verbose) + endblock() + + block() + set(RunCMake_TEST_BINARY_DIR ${RunCMake_BINARY_DIR}/AutogenUseSystemIncludeOff-build) + run_cmake_with_options(AutogenUseSystemIncludeOff ${RunCMake_TEST_OPTIONS} -DCMAKE_POLICY_DEFAULT_CMP0151=NEW) + set(RunCMake_TEST_NO_CLEAN 1) + set(RunCMake_TEST_EXPECT_stdout "${test_expect_stdout}") + run_cmake_command(AutogenUseSystemIncludeOff ${CMAKE_COMMAND} --build . --config Debug --verbose) + endblock() + + if(RunCMake_GENERATOR MATCHES "Make|Ninja") + block() + set(RunCMake_TEST_BINARY_DIR ${RunCMake_BINARY_DIR}/AutogenSkipLinting-build) + list(APPEND RunCMake_TEST_OPTIONS + "-DPSEUDO_CPPCHECK=${PSEUDO_CPPCHECK}" + "-DPSEUDO_CPPLINT=${PSEUDO_CPPLINT}" + "-DPSEUDO_IWYU=${PSEUDO_IWYU}" + "-DPSEUDO_TIDY=${PSEUDO_TIDY}") + + run_cmake(AutogenSkipLinting) + set(RunCMake_TEST_NO_CLEAN 1) + run_cmake_command(AutogenSkipLinting-build ${CMAKE_COMMAND} --build . --config Debug --verbose) + endblock() + endif() + endif() + + if(RunCMake_GENERATOR_IS_MULTI_CONFIG AND NOT RunCMake_GENERATOR MATCHES "Xcode") + block() + set(RunCMake_TEST_BINARY_DIR ${RunCMake_BINARY_DIR}/MocGeneratedFile-build) + run_cmake(MocGeneratedFile) + set(RunCMake_TEST_NO_CLEAN 1) + run_cmake_command(MocGeneratedFile-build ${CMAKE_COMMAND} --build . --config Debug --verbose) + endblock() + if(RunCMake_GENERATOR MATCHES "Ninja Multi-Config") + block() + set(RunCMake_TEST_BINARY_DIR ${RunCMake_BINARY_DIR}/MocGeneratedFile-cross-config-build) + list(APPEND RunCMake_TEST_OPTIONS -DCMAKE_CROSS_CONFIGS=all) + set(RunCMake_TEST_VARIANT_DESCRIPTION "-CMAKE_CROSS_CONFIGS-all") + run_cmake(MocGeneratedFile) + set(RunCMake_TEST_NO_CLEAN 1) + set(RunCMake_TEST_VARIANT_DESCRIPTION "-Release") + run_cmake_command(MocGeneratedFile-cross-config-build ${CMAKE_COMMAND} --build . --config Release --target libgen:Debug) + set(RunCMake_TEST_VARIANT_DESCRIPTION "-Debug") + run_cmake_command(MocGeneratedFile-cross-config-build ${CMAKE_COMMAND} --build . --config Debug --target libgen:Release) + unset(RunCMake_TEST_VARIANT_DESCRIPTION) + endblock() + endif() + endif() +endif () diff --git a/Tests/RunCMake/Autogen/SkipLinting.cxx b/Tests/RunCMake/Autogen_1/SkipLinting.cxx index 9e09b27..9e09b27 100644 --- a/Tests/RunCMake/Autogen/SkipLinting.cxx +++ b/Tests/RunCMake/Autogen_1/SkipLinting.cxx diff --git a/Tests/RunCMake/Autogen/SkipLinting.h b/Tests/RunCMake/Autogen_1/SkipLinting.h index def56a0..def56a0 100644 --- a/Tests/RunCMake/Autogen/SkipLinting.h +++ b/Tests/RunCMake/Autogen_1/SkipLinting.h diff --git a/Tests/RunCMake/Autogen/empty.cpp b/Tests/RunCMake/Autogen_1/empty.cpp index e69de29..e69de29 100644 --- a/Tests/RunCMake/Autogen/empty.cpp +++ b/Tests/RunCMake/Autogen_1/empty.cpp diff --git a/Tests/RunCMake/Autogen_2/CMakeLists.txt b/Tests/RunCMake/Autogen_2/CMakeLists.txt new file mode 100644 index 0000000..2632ffa --- /dev/null +++ b/Tests/RunCMake/Autogen_2/CMakeLists.txt @@ -0,0 +1,3 @@ +cmake_minimum_required(VERSION 3.16) +project(${RunCMake_TEST} NONE) +include(${RunCMake_TEST}.cmake) diff --git a/Tests/RunCMake/Autogen/MyWindow.cpp b/Tests/RunCMake/Autogen_2/MyWindow.cpp index d87c2e9..d87c2e9 100644 --- a/Tests/RunCMake/Autogen/MyWindow.cpp +++ b/Tests/RunCMake/Autogen_2/MyWindow.cpp diff --git a/Tests/RunCMake/Autogen/MyWindow.h b/Tests/RunCMake/Autogen_2/MyWindow.h index c267610..c267610 100644 --- a/Tests/RunCMake/Autogen/MyWindow.h +++ b/Tests/RunCMake/Autogen_2/MyWindow.h diff --git a/Tests/RunCMake/Autogen/MyWindow.ui b/Tests/RunCMake/Autogen_2/MyWindow.ui index fbf294c..fbf294c 100644 --- a/Tests/RunCMake/Autogen/MyWindow.ui +++ b/Tests/RunCMake/Autogen_2/MyWindow.ui diff --git a/Tests/RunCMake/Autogen/QtAutoMocDeps-stderr.txt b/Tests/RunCMake/Autogen_2/QtAutoMocDeps-stderr.txt index 6024984..6024984 100644 --- a/Tests/RunCMake/Autogen/QtAutoMocDeps-stderr.txt +++ b/Tests/RunCMake/Autogen_2/QtAutoMocDeps-stderr.txt diff --git a/Tests/RunCMake/Autogen/QtAutoMocDeps.cmake b/Tests/RunCMake/Autogen_2/QtAutoMocDeps.cmake index fc3b2f2..fc3b2f2 100644 --- a/Tests/RunCMake/Autogen/QtAutoMocDeps.cmake +++ b/Tests/RunCMake/Autogen_2/QtAutoMocDeps.cmake diff --git a/Tests/RunCMake/Autogen/QtSubDir1/CMakeLists.txt b/Tests/RunCMake/Autogen_2/QtSubDir1/CMakeLists.txt index f215b9e..f215b9e 100644 --- a/Tests/RunCMake/Autogen/QtSubDir1/CMakeLists.txt +++ b/Tests/RunCMake/Autogen_2/QtSubDir1/CMakeLists.txt diff --git a/Tests/RunCMake/Autogen/QtSubDir2/CMakeLists.txt b/Tests/RunCMake/Autogen_2/QtSubDir2/CMakeLists.txt index cccb1e0..cccb1e0 100644 --- a/Tests/RunCMake/Autogen/QtSubDir2/CMakeLists.txt +++ b/Tests/RunCMake/Autogen_2/QtSubDir2/CMakeLists.txt diff --git a/Tests/RunCMake/Autogen/QtSubDir3/CMakeLists.txt b/Tests/RunCMake/Autogen_2/QtSubDir3/CMakeLists.txt index d268bfe..d268bfe 100644 --- a/Tests/RunCMake/Autogen/QtSubDir3/CMakeLists.txt +++ b/Tests/RunCMake/Autogen_2/QtSubDir3/CMakeLists.txt diff --git a/Tests/RunCMake/Autogen_2/RunCMakeTest.cmake b/Tests/RunCMake/Autogen_2/RunCMakeTest.cmake new file mode 100644 index 0000000..e97e896 --- /dev/null +++ b/Tests/RunCMake/Autogen_2/RunCMakeTest.cmake @@ -0,0 +1,87 @@ +include(RunCMake) + +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}" + ) + if(RunCMake_GENERATOR MATCHES "Make|Ninja") + block() + if(QtCore_VERSION VERSION_GREATER_EQUAL 5.15.0) + if (RunCMake_GENERATOR MATCHES "Ninja Multi-Config") + set(config_list Debug Release RelWithDebInfo) + set(use_better_graph_list ON OFF) + else() + set(config_list single-config) + set(use_better_graph_list OFF) + endif() + + foreach(use_better_graph IN ITEMS ${use_better_graph_list}) + foreach(config IN ITEMS ${config_list}) + block() + if (config STREQUAL "single-config") + set(config_suffix "") + else() + set(config_path "_${config}") + if (use_better_graph) + set(config_suffix "_${config}") + endif() + endif() + + set(RunCMake_TEST_BINARY_DIR ${RunCMake_BINARY_DIR}/QtAutoMocDeps${config_path}-build) + run_cmake_with_options(QtAutoMocDeps ${RunCMake_TEST_OPTIONS} -DCMAKE_AUTOGEN_BETTER_GRAPH_MULTI_CONFIG=${use_better_graph}) + set(RunCMake_TEST_NO_CLEAN 1) + # Build the project. + if (config STREQUAL "single-config") + set(config_param "") + else() + set(config_param "--config ${config}") + endif() + run_cmake_command(QtAutoMocDeps-build ${CMAKE_COMMAND} --build . --verbose ${config_param}) + # Touch just the library source file, which shouldn't cause a rerun of AUTOMOC + # for app_with_qt target. + file(TOUCH "${RunCMake_SOURCE_DIR}/simple_lib.cpp") + set(RunCMake_TEST_NOT_EXPECT_stdout "Automatic MOC for target app_with_qt|\ +Automatic MOC for target sub_exe_1|\ +Automatic MOC for target sub_exe_2") + set(RunCMake_TEST_VARIANT_DESCRIPTION "-Don't execute AUTOMOC for 'app_with_qt', 'sub_exe_1' and 'sub_exe_2'") + # Build and assert that AUTOMOC was not run for app_with_qt, sub_exe_1 and sub_exe_2. + run_cmake_command(QtAutoMocDeps-build ${CMAKE_COMMAND} --build . --verbose ${config_param}) + unset(RunCMake_TEST_VARIANT_DESCRIPTION) + unset(RunCMake_TEST_NOT_EXPECT_stdout) + + macro(check_file_exists file) + if (EXISTS "${file}") + set(check_result "PASSED") + set(message_type "STATUS") + else() + set(check_result "FAILED") + set(message_type "FATAL_ERROR") + endif() + + message(${message_type} "QtAutoMocDeps-build-\"${file}\" was generated - ${check_result}") + endmacro() + + check_file_exists("${RunCMake_TEST_BINARY_DIR}/app_with_qt_autogen/deps${config_suffix}") + check_file_exists("${RunCMake_TEST_BINARY_DIR}/QtSubDir1/sub_exe_1_autogen/deps${config_suffix}") + check_file_exists("${RunCMake_TEST_BINARY_DIR}/QtSubDir2/sub_exe_2_autogen/deps${config_suffix}") + + check_file_exists("${RunCMake_TEST_BINARY_DIR}/app_with_qt_autogen/timestamp${config_suffix}") + check_file_exists("${RunCMake_TEST_BINARY_DIR}/QtSubDir1/sub_exe_1_autogen/timestamp${config_suffix}") + check_file_exists("${RunCMake_TEST_BINARY_DIR}/QtSubDir2/sub_exe_2_autogen/timestamp${config_suffix}") + + # Touch a header file to make sure an automoc dependency cycle is not introduced. + file(TOUCH "${RunCMake_SOURCE_DIR}/MyWindow.h") + set(RunCMake_TEST_VARIANT_DESCRIPTION "-First build after touch to detect dependency cycle") + run_cmake_command(QtAutoMocDeps-build ${CMAKE_COMMAND} --build . --verbose) + # Need to run a second time to hit the dependency cycle. + set(RunCMake_TEST_VARIANT_DESCRIPTION "-Don't hit dependency cycle") + run_cmake_command(QtAutoMocDeps-build ${CMAKE_COMMAND} --build . --verbose) + endblock() + endforeach() + endforeach() + endif() + endblock() + endif() +endif () diff --git a/Tests/RunCMake/Autogen/app.cpp b/Tests/RunCMake/Autogen_2/app.cpp index 57380e4..57380e4 100644 --- a/Tests/RunCMake/Autogen/app.cpp +++ b/Tests/RunCMake/Autogen_2/app.cpp diff --git a/Tests/RunCMake/Autogen/app_qt.cpp b/Tests/RunCMake/Autogen_2/app_qt.cpp index 302c672..302c672 100644 --- a/Tests/RunCMake/Autogen/app_qt.cpp +++ b/Tests/RunCMake/Autogen_2/app_qt.cpp diff --git a/Tests/RunCMake/Autogen/simple_lib.cpp b/Tests/RunCMake/Autogen_2/simple_lib.cpp index cf8d689..cf8d689 100644 --- a/Tests/RunCMake/Autogen/simple_lib.cpp +++ b/Tests/RunCMake/Autogen_2/simple_lib.cpp diff --git a/Tests/RunCMake/Autogen/AutoMocExecutableConfig.cmake b/Tests/RunCMake/Autogen_3/AutoMocExecutableConfig.cmake index 3ee9be9..fc6ed7f 100644 --- a/Tests/RunCMake/Autogen/AutoMocExecutableConfig.cmake +++ b/Tests/RunCMake/Autogen_3/AutoMocExecutableConfig.cmake @@ -7,9 +7,9 @@ endif() get_target_property(moc_location Qt${with_qt_version}::moc IMPORTED_LOCATION) set_target_properties(dummy PROPERTIES AUTOMOC_MOC_OPTIONS "EXE_PATH=${moc_location}") -add_executable(mymoc $<$<CONFIG:Debug>:exe_debug.cpp> - $<$<CONFIG:Release>:exe_release.cpp> - $<$<CONFIG:RelWithDebInfo>:exe_relwithdebinfo.cpp> +add_executable(mymoc $<$<CONFIG:Debug>:../Autogen_common/exe_debug.cpp> + $<$<CONFIG:Release>:../Autogen_common/exe_release.cpp> + $<$<CONFIG:RelWithDebInfo>:../Autogen_common/exe_relwithdebinfo.cpp> ) set_target_properties(dummy PROPERTIES AUTOMOC_EXECUTABLE $<TARGET_FILE:mymoc>) diff --git a/Tests/RunCMake/Autogen_3/CMakeLists.txt b/Tests/RunCMake/Autogen_3/CMakeLists.txt new file mode 100644 index 0000000..2632ffa --- /dev/null +++ b/Tests/RunCMake/Autogen_3/CMakeLists.txt @@ -0,0 +1,3 @@ +cmake_minimum_required(VERSION 3.16) +project(${RunCMake_TEST} NONE) +include(${RunCMake_TEST}.cmake) diff --git a/Tests/RunCMake/Autogen/MocExample.cmake b/Tests/RunCMake/Autogen_3/MocExample.cmake index f06f8f6..b4f4729 100644 --- a/Tests/RunCMake/Autogen/MocExample.cmake +++ b/Tests/RunCMake/Autogen_3/MocExample.cmake @@ -3,7 +3,7 @@ enable_language(CXX) set(CMAKE_CXX_STANDARD 11) find_package(Qt${with_qt_version} REQUIRED COMPONENTS Core Widgets Gui) -add_library(dummy STATIC example.cpp) +add_library(dummy STATIC ../Autogen_common/example.cpp) target_link_libraries(dummy Qt${with_qt_version}::Core Qt${with_qt_version}::Widgets Qt${with_qt_version}::Gui) diff --git a/Tests/RunCMake/Autogen_3/RunCMakeTest.cmake b/Tests/RunCMake/Autogen_3/RunCMakeTest.cmake new file mode 100644 index 0000000..a2fb3df --- /dev/null +++ b/Tests/RunCMake/Autogen_3/RunCMakeTest.cmake @@ -0,0 +1,11 @@ +include(RunCMake) +include(Autogen_common/utils) + +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}" + ) + autogen_executable_test(Moc) +endif () diff --git a/Tests/RunCMake/Autogen/AutoUicExecutableConfig.cmake b/Tests/RunCMake/Autogen_4/AutoUicExecutableConfig.cmake index 55b88b8..72a0d9f 100644 --- a/Tests/RunCMake/Autogen/AutoUicExecutableConfig.cmake +++ b/Tests/RunCMake/Autogen_4/AutoUicExecutableConfig.cmake @@ -7,9 +7,9 @@ endif() get_target_property(uic_location Qt${with_qt_version}::uic IMPORTED_LOCATION) set_target_properties(dummy PROPERTIES AUTOUIC_OPTIONS "EXE_PATH=${uic_location}") -add_executable(myuic $<$<CONFIG:Debug>:exe_debug.cpp> - $<$<CONFIG:Release>:exe_release.cpp> - $<$<CONFIG:RelWithDebInfo>:exe_relwithdebinfo.cpp> +add_executable(myuic $<$<CONFIG:Debug>:../Autogen_common/exe_debug.cpp> + $<$<CONFIG:Release>:../Autogen_common/exe_release.cpp> + $<$<CONFIG:RelWithDebInfo>:../Autogen_common/exe_relwithdebinfo.cpp> ) set_target_properties(dummy PROPERTIES AUTOUIC_EXECUTABLE $<TARGET_FILE:myuic>) diff --git a/Tests/RunCMake/Autogen_4/CMakeLists.txt b/Tests/RunCMake/Autogen_4/CMakeLists.txt new file mode 100644 index 0000000..2632ffa --- /dev/null +++ b/Tests/RunCMake/Autogen_4/CMakeLists.txt @@ -0,0 +1,3 @@ +cmake_minimum_required(VERSION 3.16) +project(${RunCMake_TEST} NONE) +include(${RunCMake_TEST}.cmake) diff --git a/Tests/RunCMake/Autogen_4/RunCMakeTest.cmake b/Tests/RunCMake/Autogen_4/RunCMakeTest.cmake new file mode 100644 index 0000000..ac8c5d4 --- /dev/null +++ b/Tests/RunCMake/Autogen_4/RunCMakeTest.cmake @@ -0,0 +1,11 @@ +include(RunCMake) +include(Autogen_common/utils) + +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}" + ) + autogen_executable_test(Uic) +endif () diff --git a/Tests/RunCMake/Autogen/UicExample.cmake b/Tests/RunCMake/Autogen_4/UicExample.cmake index 4b1f8c1..4b1f8c1 100644 --- a/Tests/RunCMake/Autogen/UicExample.cmake +++ b/Tests/RunCMake/Autogen_4/UicExample.cmake diff --git a/Tests/RunCMake/Autogen/example_ui.cpp b/Tests/RunCMake/Autogen_4/example_ui.cpp index fb97c32..fb97c32 100644 --- a/Tests/RunCMake/Autogen/example_ui.cpp +++ b/Tests/RunCMake/Autogen_4/example_ui.cpp diff --git a/Tests/RunCMake/Autogen/example_ui.h b/Tests/RunCMake/Autogen_4/example_ui.h index d691133..d691133 100644 --- a/Tests/RunCMake/Autogen/example_ui.h +++ b/Tests/RunCMake/Autogen_4/example_ui.h diff --git a/Tests/RunCMake/Autogen/uiA.ui b/Tests/RunCMake/Autogen_4/uiA.ui index 4c5762e..4c5762e 100644 --- a/Tests/RunCMake/Autogen/uiA.ui +++ b/Tests/RunCMake/Autogen_4/uiA.ui diff --git a/Tests/RunCMake/Autogen/AutoRccExecutableConfig.cmake b/Tests/RunCMake/Autogen_5/AutoRccExecutableConfig.cmake index 0e46420..b15dd72 100644 --- a/Tests/RunCMake/Autogen/AutoRccExecutableConfig.cmake +++ b/Tests/RunCMake/Autogen_5/AutoRccExecutableConfig.cmake @@ -7,9 +7,9 @@ endif() get_target_property(rcc_location Qt${with_qt_version}::rcc IMPORTED_LOCATION) set_target_properties(dummy PROPERTIES AUTORCC_OPTIONS "EXE_PATH=${rcc_location}") -add_executable(myrcc $<$<CONFIG:Debug>:exe_debug.cpp> - $<$<CONFIG:Release>:exe_release.cpp> - $<$<CONFIG:RelWithDebInfo>:exe_relwithdebinfo.cpp> +add_executable(myrcc $<$<CONFIG:Debug>:../Autogen_common/exe_debug.cpp> + $<$<CONFIG:Release>:../Autogen_common/exe_release.cpp> + $<$<CONFIG:RelWithDebInfo>:../Autogen_common/exe_relwithdebinfo.cpp> ) set_target_properties(dummy PROPERTIES AUTORCC_EXECUTABLE $<TARGET_FILE:myrcc>) diff --git a/Tests/RunCMake/Autogen_5/CMakeLists.txt b/Tests/RunCMake/Autogen_5/CMakeLists.txt new file mode 100644 index 0000000..2632ffa --- /dev/null +++ b/Tests/RunCMake/Autogen_5/CMakeLists.txt @@ -0,0 +1,3 @@ +cmake_minimum_required(VERSION 3.16) +project(${RunCMake_TEST} NONE) +include(${RunCMake_TEST}.cmake) diff --git a/Tests/RunCMake/Autogen/RccExample.cmake b/Tests/RunCMake/Autogen_5/RccExample.cmake index ade0fef..9f8dc59 100644 --- a/Tests/RunCMake/Autogen/RccExample.cmake +++ b/Tests/RunCMake/Autogen_5/RccExample.cmake @@ -3,7 +3,7 @@ enable_language(CXX) set(CMAKE_CXX_STANDARD 11) find_package(Qt${with_qt_version} REQUIRED COMPONENTS Core Widgets Gui) -add_library(dummy STATIC example.cpp data.qrc) +add_library(dummy STATIC ../Autogen_common/example.cpp data.qrc) target_link_libraries(dummy Qt${with_qt_version}::Core Qt${with_qt_version}::Widgets Qt${with_qt_version}::Gui) diff --git a/Tests/RunCMake/Autogen_5/RunCMakeTest.cmake b/Tests/RunCMake/Autogen_5/RunCMakeTest.cmake new file mode 100644 index 0000000..1f6f7d4 --- /dev/null +++ b/Tests/RunCMake/Autogen_5/RunCMakeTest.cmake @@ -0,0 +1,47 @@ +include(RunCMake) +include(Autogen_common/utils) + +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}" + ) + autogen_executable_test(Rcc) + if (QtCore_VERSION VERSION_GREATER_EQUAL 6) + if (RunCMake_GENERATOR MATCHES "Make|Ninja") + foreach(value IN ITEMS ON OFF) + block() + set(RunCMake_TEST_BINARY_DIR + ${RunCMake_BINARY_DIR}/RccNoZTSD-${value}-build) + run_cmake_with_options(RccExample ${RunCMake_TEST_OPTIONS} + -DCMAKE_AUTOGEN_VERBOSE=ON -DZSTD_VALUE=${value}) + if (value STREQUAL "OFF") + set(RunCMake_TEST_EXPECT_stdout "--no-zstd") + else() + set(RunCMake_TEST_NOT_EXPECT_stdout "--no-zstd") + endif() + set(RunCMake_TEST_NO_CLEAN 1) + run_cmake_command(RccNoZTSD-${value}-build ${CMAKE_COMMAND} + --build . --config Debug) + endblock() + endforeach() + endif() + if (RunCMake_GENERATOR MATCHES "Ninja") + block() + set(RunCMake_TEST_BINARY_DIR + ${RunCMake_BINARY_DIR}/RccGlobalAutoRcc-build) + run_cmake_with_options(RccExample ${RunCMake_TEST_OPTIONS} + -DCMAKE_GLOBAL_AUTORCC_TARGET=ON) + set(RunCMake_TEST_NO_CLEAN 1) + set(RunCMake_TEST_VARIANT_DESCRIPTION "-First-build") + run_cmake_command(RccGlobalAutoRcc-build ${CMAKE_COMMAND} + --build . --config Debug) + set(RunCMake_TEST_VARIANT_DESCRIPTION "-Second-build-nothing-to-do") + set(RunCMake_TEST_NOT_EXPECT_stdout "Automatic RCC for data.qrc") + run_cmake_command(RccGlobalAutoRcc-build ${CMAKE_COMMAND} + --build . --config Debug) + endblock() + endif() + endif() +endif () diff --git a/Tests/RunCMake/Autogen/data.qrc b/Tests/RunCMake/Autogen_5/data.qrc index 9bd068c..9bd068c 100644 --- a/Tests/RunCMake/Autogen/data.qrc +++ b/Tests/RunCMake/Autogen_5/data.qrc diff --git a/Tests/RunCMake/Autogen/example.cpp b/Tests/RunCMake/Autogen_common/example.cpp index 7f1a781..7f1a781 100644 --- a/Tests/RunCMake/Autogen/example.cpp +++ b/Tests/RunCMake/Autogen_common/example.cpp diff --git a/Tests/RunCMake/Autogen/example.h b/Tests/RunCMake/Autogen_common/example.h index e8bfa42..e8bfa42 100644 --- a/Tests/RunCMake/Autogen/example.h +++ b/Tests/RunCMake/Autogen_common/example.h diff --git a/Tests/RunCMake/Autogen/exe_common.h b/Tests/RunCMake/Autogen_common/exe_common.h index 15311c6..15311c6 100644 --- a/Tests/RunCMake/Autogen/exe_common.h +++ b/Tests/RunCMake/Autogen_common/exe_common.h diff --git a/Tests/RunCMake/Autogen/exe_debug.cpp b/Tests/RunCMake/Autogen_common/exe_debug.cpp index ae5185b..ae5185b 100644 --- a/Tests/RunCMake/Autogen/exe_debug.cpp +++ b/Tests/RunCMake/Autogen_common/exe_debug.cpp diff --git a/Tests/RunCMake/Autogen/exe_release.cpp b/Tests/RunCMake/Autogen_common/exe_release.cpp index 384c992..384c992 100644 --- a/Tests/RunCMake/Autogen/exe_release.cpp +++ b/Tests/RunCMake/Autogen_common/exe_release.cpp diff --git a/Tests/RunCMake/Autogen/exe_relwithdebinfo.cpp b/Tests/RunCMake/Autogen_common/exe_relwithdebinfo.cpp index aa6c558..aa6c558 100644 --- a/Tests/RunCMake/Autogen/exe_relwithdebinfo.cpp +++ b/Tests/RunCMake/Autogen_common/exe_relwithdebinfo.cpp diff --git a/Tests/RunCMake/Autogen_common/utils.cmake b/Tests/RunCMake/Autogen_common/utils.cmake new file mode 100644 index 0000000..86efa85 --- /dev/null +++ b/Tests/RunCMake/Autogen_common/utils.cmake @@ -0,0 +1,259 @@ +function(run_make_program dir) + execute_process( + COMMAND "${RunCMake_MAKE_PROGRAM}" ${ARGN} + WORKING_DIRECTORY "${dir}" + OUTPUT_VARIABLE make_program_stdout + ERROR_VARIABLE make_program_stderr + RESULT_VARIABLE make_program_result + ) + if (NOT DEFINED RunMakeProgram_expected_result) + set(RunMakeProgram_expected_result 0) + endif() + if(NOT "${make_program_result}" MATCHES "${RunMakeProgram_expected_result}") + message(STATUS " +============ beginning of ${RunCMake_MAKE_PROGRAM}'s stdout ============ +${make_program_stdout} +=============== end of ${RunCMake_MAKE_PROGRAM}'s stdout =============== +") + message(STATUS " +============ beginning of ${RunCMake_MAKE_PROGRAM}'s stderr ============ +${make_program_stderr} +=============== end of ${RunCMake_MAKE_PROGRAM}'s stderr =============== +") + message(FATAL_ERROR + "top ${RunCMake_MAKE_PROGRAM} build failed exited with status ${make_program_result}") + endif() + set(make_program_stdout "${make_program_stdout}" PARENT_SCOPE) +endfunction(run_make_program) + +function(count_substring STRING SUBSTRING COUNT_VAR) + string(LENGTH "${STRING}" STRING_LENGTH) + string(LENGTH "${SUBSTRING}" SUBSTRING_LENGTH) + if (SUBSTRING_LENGTH EQUAL 0) + message(FATAL_ERROR "SUBSTRING_LENGTH is 0") + endif() + + if (STRING_LENGTH EQUAL 0) + message(FATAL_ERROR "STRING_LENGTH is 0") + endif() + + if (STRING_LENGTH LESS SUBSTRING_LENGTH) + message(FATAL_ERROR "STRING_LENGTH is less than SUBSTRING_LENGTH") + endif() + + set(COUNT 0) + string(FIND "${STRING}" "${SUBSTRING}" SUBSTRING_START) + while(SUBSTRING_START GREATER_EQUAL 0) + math(EXPR COUNT "${COUNT} + 1") + math(EXPR SUBSTRING_START "${SUBSTRING_START} + ${SUBSTRING_LENGTH}") + string(SUBSTRING "${STRING}" ${SUBSTRING_START} -1 STRING) + string(FIND "${STRING}" "${SUBSTRING}" SUBSTRING_START) + endwhile() + + set(${COUNT_VAR} ${COUNT} PARENT_SCOPE) +endfunction() + +function(not_expect make_program_stdout unexpected_output test_name) + count_substring("${make_program_stdout}" "${unexpected_output}" count) + if(NOT count EQUAL 0) + message(STATUS "${test_name}-not_expect - FAILED") + message(FATAL_ERROR "Expected to find ${unexpected_output} exactly 0 times in ${make_program_stdout} but found ${count} occurrences of ${unexpected_output}") + else() + message(STATUS "${test_name}-not_expect - PASSED") + endif() +endfunction() + +function(expect_only_once make_program_stdout expected_output test_name) + count_substring("${make_program_stdout}" "${expected_output}" count) + if(NOT count EQUAL 1) + message(STATUS "${test_name}-expect_only_once - FAILED") + message(FATAL_ERROR "Expected to find ${expected_output} exactly once in ${make_program_stdout} but found ${count} occurrences of ${expected_output}") + else() + message(STATUS "${test_name}-expect_only_once - PASSED") + endif() +endfunction() + +function(expect_n_times string_to_check expected_output expected_count test_name) + count_substring("${string_to_check}" "${expected_output}" count) + if(NOT count EQUAL ${expected_count}) + message(STATUS "${test_name}-expect_${expected_count}_times - FAILED") + message(FATAL_ERROR "Expected to find ${expected_output} exactly ${expected_count} times in ${string_to_check} but found ${count} occurrences of ${expected_output}") + else() + message(STATUS "${test_name}-expect_${expected_count}_times - PASSED") + endif() +endfunction() + +function(autogen_executable_test exe) + if (QtCore_VERSION VERSION_GREATER_EQUAL 5.15.0) + if(RunCMake_GENERATOR MATCHES "Ninja Multi-Config") + block() + set(RunCMake_TEST_VARIANT_DESCRIPTION "-CMake-configure") + set(RunCMake_TEST_BINARY_DIR ${RunCMake_BINARY_DIR}/Auto${exe}ExecutableConfig-multi-config-build) + run_cmake_with_options(Auto${exe}ExecutableConfig ${RunCMake_TEST_OPTIONS} -DCMAKE_AUTOGEN_VERBOSE=ON -DCMAKE_AUTOGEN_BETTER_GRAPH_MULTI_CONFIG=ON) + unset(RunCMake_TEST_VARIANT_DESCRIPTION) + set(RunCMake_TEST_NO_CLEAN 1) + foreach(config IN ITEMS Debug Release RelWithDebInfo) + block() + set(RunCMake_TEST_EXPECT_stdout ".*running_exe_${config}*") + set(RunCMake_TEST_VARIANT_DESCRIPTION "-${config}-expect_running_exe_${config}") + run_cmake_command(Auto${exe}ExecutableConfig-multi-config-build ${CMAKE_COMMAND} --build . --config ${config}) + endblock() + endforeach() + set(RunCMake_TEST_EXPECT_stdout "ninja: no work to do") + foreach(config IN ITEMS Debug Release RelWithDebInfo) + block() + set(RunCMake_TEST_VARIANT_DESCRIPTION "-${config}-expect_no_work_to_do") + run_cmake_command(Auto${exe}ExecutableConfig-multi-config-build ${CMAKE_COMMAND} --build . --config ${config}) + endblock() + endforeach() + endblock() + block() + set(RunCMake_TEST_BINARY_DIR ${RunCMake_BINARY_DIR}/Auto${exe}ExecutableConfig-build) + run_cmake_with_options(Auto${exe}ExecutableConfig ${RunCMake_TEST_OPTIONS} -DCMAKE_AUTOGEN_VERBOSE=ON -DCMAKE_AUTOGEN_BETTER_GRAPH_MULTI_CONFIG=ON) + foreach(config IN ITEMS Debug Release RelWithDebInfo) + block() + run_make_program(${RunCMake_TEST_BINARY_DIR} --verbose -f build-${config}.ninja) + + set(expected_output "running_exe_${config}") + expect_only_once("${make_program_stdout}" "${expected_output}" "Auto${exe}ExecutableConfig-${config}-${expected_output}") + + foreach(sub_config IN ITEMS Debug Release RelWithDebInfo) + if(NOT sub_config STREQUAL config) + set(unexpected_output "running_exe_${sub_config}") + not_expect("${make_program_stdout}" "${unexpected_output}" "Auto${exe}ExecutableConfig-${config}-${unexpected_output}") + endif() + endforeach() + + if (exe STREQUAL "Moc" OR exe STREQUAL "Uic") + set(expected_output "cmake_autogen") + else() + set(expected_output "cmake_autorcc") + endif() + expect_only_once("${make_program_stdout}" "${expected_output}" "Auto${exe}ExecutableConfig-${config}-${expected_output}") + endblock() + endforeach() + endblock() + block() + foreach(ninja_config IN ITEMS Debug Release RelWithDebInfo) + foreach(target_config IN ITEMS Debug Release RelWithDebInfo) + block() + set(TEST_SUFFIX "-CrossConfig-${ninja_config}-${target_config}") + set(RunCMake_TEST_BINARY_DIR ${RunCMake_BINARY_DIR}/Auto${exe}ExecutableConfig${TEST_SUFFIX}-build) + set(RunCMake_TEST_VARIANT_DESCRIPTION ${TEST_SUFFIX}) + run_cmake_with_options(Auto${exe}ExecutableConfig ${RunCMake_TEST_OPTIONS} -DCMAKE_CROSS_CONFIGS=all -DCMAKE_DEFAULT_BUILD_TYPE=${ninja_config} -DCMAKE_AUTOGEN_BETTER_GRAPH_MULTI_CONFIG=ON) + unset(RunCMake_TEST_VARIANT_DESCRIPTION) + + run_make_program(${RunCMake_TEST_BINARY_DIR} --verbose -f build-${ninja_config}.ninja dummy:${target_config}) + + set(expected_output "running_exe_${ninja_config}") + expect_only_once("${make_program_stdout}" "${expected_output}" "Auto${exe}ExecutableConfig${TEST_SUFFIX}-${expected_output}") + + foreach(sub_config IN ITEMS Debug Release RelWithDebInfo) + if(NOT sub_config STREQUAL ninja_config) + set(unexpected_output "running_exe_${sub_config}") + not_expect("${make_program_stdout}" "${unexpected_output}" "Auto${exe}ExecutableConfig${TEST_SUFFIX}-${unexpected_output}") + endif() + endforeach() + + if (exe STREQUAL "Moc" OR exe STREQUAL "Uic") + set(expected_output "cmake_autogen") + else() + set(expected_output "cmake_autorcc") + endif() + expect_only_once("${make_program_stdout}" "${expected_output}" "Auto${exe}ExecutableConfig${TEST_SUFFIX}-${expected_output}") + endblock() + endforeach() + endforeach() + endblock() + block() + foreach(ninja_config IN ITEMS Debug Release RelWithDebInfo) + set(TEST_SUFFIX "-CrossConfig-${ninja_config}-all-all") + set(RunCMake_TEST_BINARY_DIR ${RunCMake_BINARY_DIR}/Auto${exe}ExecutableConfig${TEST_SUFFIX}-build) + set(RunCMake_TEST_VARIANT_DESCRIPTION ${TEST_SUFFIX}) + run_cmake_with_options(Auto${exe}ExecutableConfig ${RunCMake_TEST_OPTIONS} -DCMAKE_CROSS_CONFIGS=all -DCMAKE_AUTOGEN_BETTER_GRAPH_MULTI_CONFIG=ON) + unset(RunCMake_TEST_VARIANT_DESCRIPTION) + run_make_program(${RunCMake_TEST_BINARY_DIR} --verbose -f build-${ninja_config}.ninja all:all) + endforeach() + endblock() + elseif (RunCMake_GENERATOR MATCHES "Ninja|Make") + block() + set(RunCMake_TEST_BINARY_DIR ${RunCMake_BINARY_DIR}/Auto${exe}ExecutableConfig-build) + foreach(config IN ITEMS Debug Release RelWithDebInfo) + block() + set(RunCMake_TEST_VARIANT_DESCRIPTION "-${config}") + run_cmake_with_options(Auto${exe}ExecutableConfig ${RunCMake_TEST_OPTIONS} -DCMAKE_BUILD_TYPE=${config} -DCMAKE_AUTOGEN_VERBOSE=ON) + unset(RunCMake_TEST_VARIANT_DESCRIPTION) + set(RunCMake_TEST_NO_CLEAN 1) + set(RunCMake_TEST_EXPECT_stdout ".*running_exe_${config}*") + run_cmake_command(Auto${exe}ExecutableConfig-${config}-build ${CMAKE_COMMAND} --build .) + endblock() + endforeach() + endblock() + endif() + endif() + + # Visual Studio specific dependency tests + if (RunCMake_GENERATOR MATCHES "Visual Studio") + block() + set(RunCMake_TEST_BINARY_DIR ${RunCMake_BINARY_DIR}/${exe}Example-build) + set(RunCMake_TEST_VARIANT_DESCRIPTION "-CMake-configure") + run_cmake_with_options(${exe}Example ${RunCMake_TEST_OPTIONS} -DCMAKE_AUTOGEN_VERBOSE=ON) + unset(RunCMake_TEST_VARIANT_DESCRIPTION) + set(RunCMake_TEST_NO_CLEAN 1) + foreach(config IN ITEMS Debug Release RelWithDebInfo) + block() + set(RunCMake_TEST_VARIANT_DESCRIPTION "-${config}-first-build") + run_cmake_command(${exe}Example-build ${CMAKE_COMMAND} --build . --config ${config}) + endblock() + endforeach() + foreach(config IN ITEMS Debug Release RelWithDebInfo) + block() + if (exe STREQUAL "Moc" OR exe STREQUAL "Uic") + set(RunCMake_TEST_NOT_EXPECT_stdout "Auto${exe}") + set(not_expect_descripton "Auto${exe}") + else () + set(RunCMake_TEST_NOT_EXPECT_stdout "Auto${exe}") + set(not_expect_descripton "Auto${exe}") + endif() + set(RunCMake_TEST_VARIANT_DESCRIPTION "-second-build-${config}_expect_no_${not_expect_descripton}") + run_cmake_command(${exe}Example-build ${CMAKE_COMMAND} --build . --config ${config}) + endblock() + endforeach() + endblock() + endif() + + if (RunCMake_GENERATOR MATCHES "Xcode") + foreach(exe IN ITEMS Moc Uic Rcc) + block() + set(RunCMake_TEST_BINARY_DIR ${RunCMake_BINARY_DIR}/${exe}Example-build) + set(RunCMake_TEST_VARIANT_DESCRIPTION "-CMake-configure") + set(RunCMake_TEST_EXPECT_stderr ".*") + run_cmake_with_options(${exe}Example ${RunCMake_TEST_OPTIONS} -DCMAKE_AUTOGEN_VERBOSE=ON) + set(RunCMake_TEST_NO_CLEAN 1) + set(RunCMake_MAKE_PROGRAM ${CMAKE_COMMAND}) + run_make_program(${RunCMake_TEST_BINARY_DIR} --build . --config Debug) + if (exe STREQUAL "Moc") + set(expected_count 16) + elseif (exe STREQUAL "Uic") + set(expected_count 4) + else() + set(expected_count 12) + endif() + expect_n_times("${make_program_stdout}" "Auto${exe}:" ${expected_count} "${exe}Example-build-Auto${exe}") + expect_n_times("${make_program_stdout}" "Auto${exe}:" ${expected_count} "${exe}Example-build-Auto${exe}") + + if (exe STREQUAL "Moc" OR exe STREQUAL "Uic") + expect_n_times("${make_program_stdout}" "AutoGen:" 20 "${exe}Example-build-AutoGen:") + endif() + + foreach(config IN ITEMS Debug Release RelWithDebInfo) + block() + run_make_program(${RunCMake_TEST_BINARY_DIR} --build . --config ${config}) + not_expect("${make_program_stdout}" "Auto${exe}" "${exe}Example-${config}_Auto${exe}") + not_expect("${make_program_stdout}" "AutoGen:" "${exe}Example-${config}_AutoGen") + endblock() + endforeach() + endblock() + endforeach() + endif() +endfunction() diff --git a/Tests/RunCMake/CMP0129/C-NEW.cmake b/Tests/RunCMake/CMP0129/C-NEW.cmake new file mode 100644 index 0000000..1c8f4c0 --- /dev/null +++ b/Tests/RunCMake/CMP0129/C-NEW.cmake @@ -0,0 +1,2 @@ +cmake_policy(SET CMP0129 NEW) +include(C-common.cmake) diff --git a/Tests/RunCMake/CMP0129/C-OLD-stderr.txt b/Tests/RunCMake/CMP0129/C-OLD-stderr.txt new file mode 100644 index 0000000..5c622d2 --- /dev/null +++ b/Tests/RunCMake/CMP0129/C-OLD-stderr.txt @@ -0,0 +1,10 @@ +^CMake Deprecation Warning at C-OLD\.cmake:[0-9]+ \(cmake_policy\): + The OLD behavior for policy CMP0129 will be removed from a future version + of CMake\. + + The cmake-policies\(7\) manual explains that the OLD behaviors of all + policies are deprecated and that a policy should be set to OLD only under + specific short-term circumstances\. Projects should be ported to the NEW + behavior and not rely on setting a policy to OLD\. +Call Stack \(most recent call first\): + CMakeLists\.txt:[0-9]+ \(include\)$ diff --git a/Tests/RunCMake/CMP0129/C-OLD.cmake b/Tests/RunCMake/CMP0129/C-OLD.cmake new file mode 100644 index 0000000..789bf64 --- /dev/null +++ b/Tests/RunCMake/CMP0129/C-OLD.cmake @@ -0,0 +1,2 @@ +cmake_policy(SET CMP0129 OLD) +include(C-common.cmake) diff --git a/Tests/RunCMake/CMP0129/C-WARN.cmake b/Tests/RunCMake/CMP0129/C-WARN.cmake new file mode 100644 index 0000000..09b5167 --- /dev/null +++ b/Tests/RunCMake/CMP0129/C-WARN.cmake @@ -0,0 +1 @@ +include(C-common.cmake) diff --git a/Tests/RunCMake/CMP0129/C.cmake b/Tests/RunCMake/CMP0129/C-common.cmake index e9ebe90..1e91327 100644 --- a/Tests/RunCMake/CMP0129/C.cmake +++ b/Tests/RunCMake/CMP0129/C-common.cmake @@ -1,7 +1,3 @@ -if(SET_CMP0129) - cmake_policy(SET CMP0129 ${SET_CMP0129}) -endif() - enable_language(C) set(CMAKE_VERBOSE_MAKEFILE TRUE) include(CompareCompilerVersion.cmake) diff --git a/Tests/RunCMake/CMP0129/CMakeLists.txt b/Tests/RunCMake/CMP0129/CMakeLists.txt index d8200fc..f5cf5b7 100644 --- a/Tests/RunCMake/CMP0129/CMakeLists.txt +++ b/Tests/RunCMake/CMP0129/CMakeLists.txt @@ -1,3 +1,3 @@ cmake_minimum_required(VERSION 3.22) project(${RunCMake_TEST} NONE) -include(${RunCMake_TEST}.cmake) +include(${RunCMake_TEST}.cmake NO_POLICY_SCOPE) diff --git a/Tests/RunCMake/CMP0129/CXX-NEW.cmake b/Tests/RunCMake/CMP0129/CXX-NEW.cmake new file mode 100644 index 0000000..00cd7c5 --- /dev/null +++ b/Tests/RunCMake/CMP0129/CXX-NEW.cmake @@ -0,0 +1,2 @@ +cmake_policy(SET CMP0129 NEW) +include(CXX-common.cmake) diff --git a/Tests/RunCMake/CMP0129/CXX-OLD-stderr.txt b/Tests/RunCMake/CMP0129/CXX-OLD-stderr.txt new file mode 100644 index 0000000..71a1ecf --- /dev/null +++ b/Tests/RunCMake/CMP0129/CXX-OLD-stderr.txt @@ -0,0 +1,10 @@ +^CMake Deprecation Warning at CXX-OLD\.cmake:[0-9]+ \(cmake_policy\): + The OLD behavior for policy CMP0129 will be removed from a future version + of CMake\. + + The cmake-policies\(7\) manual explains that the OLD behaviors of all + policies are deprecated and that a policy should be set to OLD only under + specific short-term circumstances\. Projects should be ported to the NEW + behavior and not rely on setting a policy to OLD\. +Call Stack \(most recent call first\): + CMakeLists\.txt:[0-9]+ \(include\)$ diff --git a/Tests/RunCMake/CMP0129/CXX-OLD.cmake b/Tests/RunCMake/CMP0129/CXX-OLD.cmake new file mode 100644 index 0000000..b7d8641 --- /dev/null +++ b/Tests/RunCMake/CMP0129/CXX-OLD.cmake @@ -0,0 +1,2 @@ +cmake_policy(SET CMP0129 OLD) +include(CXX-common.cmake) diff --git a/Tests/RunCMake/CMP0129/CXX-WARN.cmake b/Tests/RunCMake/CMP0129/CXX-WARN.cmake new file mode 100644 index 0000000..db36956 --- /dev/null +++ b/Tests/RunCMake/CMP0129/CXX-WARN.cmake @@ -0,0 +1 @@ +include(CXX-common.cmake) diff --git a/Tests/RunCMake/CMP0129/CXX.cmake b/Tests/RunCMake/CMP0129/CXX-common.cmake index ffb81b8..016e8ff 100644 --- a/Tests/RunCMake/CMP0129/CXX.cmake +++ b/Tests/RunCMake/CMP0129/CXX-common.cmake @@ -1,7 +1,3 @@ -if(SET_CMP0129) - cmake_policy(SET CMP0129 ${SET_CMP0129}) -endif() - enable_language(CXX) set(CMAKE_VERBOSE_MAKEFILE TRUE) include(CompareCompilerVersion.cmake) diff --git a/Tests/RunCMake/CMP0129/Fortran-NEW.cmake b/Tests/RunCMake/CMP0129/Fortran-NEW.cmake new file mode 100644 index 0000000..6ac9cb9 --- /dev/null +++ b/Tests/RunCMake/CMP0129/Fortran-NEW.cmake @@ -0,0 +1,2 @@ +cmake_policy(SET CMP0129 NEW) +include(Fortran-common.cmake) diff --git a/Tests/RunCMake/CMP0129/Fortran-OLD-stderr.txt b/Tests/RunCMake/CMP0129/Fortran-OLD-stderr.txt new file mode 100644 index 0000000..01260c0 --- /dev/null +++ b/Tests/RunCMake/CMP0129/Fortran-OLD-stderr.txt @@ -0,0 +1,10 @@ +^CMake Deprecation Warning at Fortran-OLD\.cmake:[0-9]+ \(cmake_policy\): + The OLD behavior for policy CMP0129 will be removed from a future version + of CMake\. + + The cmake-policies\(7\) manual explains that the OLD behaviors of all + policies are deprecated and that a policy should be set to OLD only under + specific short-term circumstances\. Projects should be ported to the NEW + behavior and not rely on setting a policy to OLD\. +Call Stack \(most recent call first\): + CMakeLists\.txt:[0-9]+ \(include\)$ diff --git a/Tests/RunCMake/CMP0129/Fortran-OLD.cmake b/Tests/RunCMake/CMP0129/Fortran-OLD.cmake new file mode 100644 index 0000000..df6ca83 --- /dev/null +++ b/Tests/RunCMake/CMP0129/Fortran-OLD.cmake @@ -0,0 +1,2 @@ +cmake_policy(SET CMP0129 OLD) +include(Fortran-common.cmake) diff --git a/Tests/RunCMake/CMP0129/Fortran-WARN.cmake b/Tests/RunCMake/CMP0129/Fortran-WARN.cmake new file mode 100644 index 0000000..3dc27c3 --- /dev/null +++ b/Tests/RunCMake/CMP0129/Fortran-WARN.cmake @@ -0,0 +1 @@ +include(Fortran-common.cmake) diff --git a/Tests/RunCMake/CMP0129/Fortran-common.cmake b/Tests/RunCMake/CMP0129/Fortran-common.cmake new file mode 100644 index 0000000..7b6ecc7 --- /dev/null +++ b/Tests/RunCMake/CMP0129/Fortran-common.cmake @@ -0,0 +1,4 @@ +enable_language(Fortran) +set(CMAKE_VERBOSE_MAKEFILE TRUE) +include(CompareCompilerVersion.cmake) +compare_compiler_version(Fortran) diff --git a/Tests/RunCMake/CMP0129/Fortran.cmake b/Tests/RunCMake/CMP0129/Fortran.cmake deleted file mode 100644 index abaca7e..0000000 --- a/Tests/RunCMake/CMP0129/Fortran.cmake +++ /dev/null @@ -1,15 +0,0 @@ -include(CheckLanguage) -check_language(Fortran) -if(NOT CMAKE_Fortran_COMPILER) - # No Fortran compiler, skipping Fortran test - return() -endif() - -if(SET_CMP0129) - cmake_policy(SET CMP0129 ${SET_CMP0129}) -endif() - -enable_language(Fortran) -set(CMAKE_VERBOSE_MAKEFILE TRUE) -include(CompareCompilerVersion.cmake) -compare_compiler_version(Fortran) diff --git a/Tests/RunCMake/CMP0129/RunCMakeTest.cmake b/Tests/RunCMake/CMP0129/RunCMakeTest.cmake index 1b0e11b..c147352 100644 --- a/Tests/RunCMake/CMP0129/RunCMakeTest.cmake +++ b/Tests/RunCMake/CMP0129/RunCMakeTest.cmake @@ -1,8 +1,14 @@ set(RunCMake_TEST_NO_CMP0129 ON) include(RunCMake) -foreach(lang C CXX Fortran) - run_cmake(${lang}) - run_cmake_with_options(${lang} "-DSET_CMP0129=NEW") - run_cmake_with_options(${lang} "-DSET_CMP0129=OLD") -endforeach() +run_cmake(C-WARN) +run_cmake(C-OLD) +run_cmake(C-NEW) +run_cmake(CXX-WARN) +run_cmake(CXX-OLD) +run_cmake(CXX-NEW) +if(CMake_TEST_Fortran) + run_cmake(Fortran-WARN) + run_cmake(Fortran-OLD) + run_cmake(Fortran-NEW) +endif() diff --git a/Tests/RunCMake/file/MAKE_DIRECTORY-fail-result.txt b/Tests/RunCMake/CMP0171/CMP0171-NEW-result.txt index d00491f..d00491f 100644 --- a/Tests/RunCMake/file/MAKE_DIRECTORY-fail-result.txt +++ b/Tests/RunCMake/CMP0171/CMP0171-NEW-result.txt diff --git a/Tests/RunCMake/CMP0171/CMP0171-NEW-stderr.txt b/Tests/RunCMake/CMP0171/CMP0171-NEW-stderr.txt new file mode 100644 index 0000000..155ddd2 --- /dev/null +++ b/Tests/RunCMake/CMP0171/CMP0171-NEW-stderr.txt @@ -0,0 +1,4 @@ +CMake Error at CMP0171-NEW\.cmake:[0-9]+ \(add_custom_target\): + The target name "codegen" is reserved\. +Call Stack \(most recent call first\): + CMakeLists\.txt:[0-9]+ \(include\) diff --git a/Tests/RunCMake/CMP0171/CMP0171-NEW.cmake b/Tests/RunCMake/CMP0171/CMP0171-NEW.cmake new file mode 100644 index 0000000..547f6c0 --- /dev/null +++ b/Tests/RunCMake/CMP0171/CMP0171-NEW.cmake @@ -0,0 +1,6 @@ +# codegen is now a reserved name and this will cause an error since the policy is new. +add_custom_target(codegen + COMMAND ${CMAKE_COMMAND} -E copy + ${CMAKE_CURRENT_SOURCE_DIR}/generated.h.in + ${CMAKE_CURRENT_BINARY_DIR}/generated.h +) diff --git a/Tests/RunCMake/CMP0171/CMP0171-OLD-result.txt b/Tests/RunCMake/CMP0171/CMP0171-OLD-result.txt new file mode 100644 index 0000000..d00491f --- /dev/null +++ b/Tests/RunCMake/CMP0171/CMP0171-OLD-result.txt @@ -0,0 +1 @@ +1 diff --git a/Tests/RunCMake/CMP0171/CMP0171-OLD-stderr.txt b/Tests/RunCMake/CMP0171/CMP0171-OLD-stderr.txt new file mode 100644 index 0000000..1ae3318 --- /dev/null +++ b/Tests/RunCMake/CMP0171/CMP0171-OLD-stderr.txt @@ -0,0 +1,4 @@ +CMake Error at CMP0171-OLD\.cmake:[0-9]+ \(add_custom_command\): + add_custom_command CODEGEN option requires policy CMP0171 be set to NEW\! +Call Stack \(most recent call first\): + CMakeLists\.txt:[0-9]+ \(include\) diff --git a/Tests/RunCMake/CMP0171/CMP0171-OLD.cmake b/Tests/RunCMake/CMP0171/CMP0171-OLD.cmake new file mode 100644 index 0000000..c34b3fb --- /dev/null +++ b/Tests/RunCMake/CMP0171/CMP0171-OLD.cmake @@ -0,0 +1,9 @@ +add_custom_command( + OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/generated.hpp + COMMAND ${CMAKE_COMMAND} -E copy + ${CMAKE_CURRENT_SOURCE_DIR}/generated.h.in + ${CMAKE_CURRENT_BINARY_DIR}/generated.hpp + # This will cause an error since the CODEGEN option + # requires that CMP0171 is set to NEW + CODEGEN +) diff --git a/Tests/RunCMake/CMP0171/CMP0171-WARN-stderr.txt b/Tests/RunCMake/CMP0171/CMP0171-WARN-stderr.txt new file mode 100644 index 0000000..ee79553 --- /dev/null +++ b/Tests/RunCMake/CMP0171/CMP0171-WARN-stderr.txt @@ -0,0 +1,9 @@ +CMake Warning \(dev\) at CMP0171-WARN\.cmake:[0-9]+ \(add_custom_target\): + Policy CMP0171 is not set: 'codegen' is a reserved target name\. Run "cmake + --help-policy CMP0171" for policy details. Use the cmake_policy command to + set the policy and suppress this warning\. + + The target name "codegen" is reserved\. +Call Stack \(most recent call first\): + CMakeLists.txt:[0-9]+ \(include\) +This warning is for project developers\. Use -Wno-dev to suppress it\. diff --git a/Tests/RunCMake/CMP0171/CMP0171-WARN.cmake b/Tests/RunCMake/CMP0171/CMP0171-WARN.cmake new file mode 100644 index 0000000..6d61723 --- /dev/null +++ b/Tests/RunCMake/CMP0171/CMP0171-WARN.cmake @@ -0,0 +1,6 @@ +# CMake should warn the user if they have a target named codegen. +add_custom_target(codegen + COMMAND ${CMAKE_COMMAND} -E copy + ${CMAKE_CURRENT_SOURCE_DIR}/generated.h.in + ${CMAKE_CURRENT_BINARY_DIR}/generated.h +) diff --git a/Tests/RunCMake/CMP0171/CMP0171-codegen-build-result.txt b/Tests/RunCMake/CMP0171/CMP0171-codegen-build-result.txt new file mode 100644 index 0000000..d197c91 --- /dev/null +++ b/Tests/RunCMake/CMP0171/CMP0171-codegen-build-result.txt @@ -0,0 +1 @@ +[^0] diff --git a/Tests/RunCMake/CMP0171/CMP0171-codegen.cmake b/Tests/RunCMake/CMP0171/CMP0171-codegen.cmake new file mode 100644 index 0000000..e69de29 --- /dev/null +++ b/Tests/RunCMake/CMP0171/CMP0171-codegen.cmake diff --git a/Tests/RunCMake/CMP0171/CMakeLists.txt b/Tests/RunCMake/CMP0171/CMakeLists.txt new file mode 100644 index 0000000..1a5755c --- /dev/null +++ b/Tests/RunCMake/CMP0171/CMakeLists.txt @@ -0,0 +1,6 @@ +cmake_minimum_required(VERSION 3.29) +project(${RunCMake_TEST} LANGUAGES C) + +include(${RunCMake_TEST}.cmake) + +enable_testing() diff --git a/Tests/RunCMake/CMP0171/RunCMakeTest.cmake b/Tests/RunCMake/CMP0171/RunCMakeTest.cmake new file mode 100644 index 0000000..75941d7 --- /dev/null +++ b/Tests/RunCMake/CMP0171/RunCMakeTest.cmake @@ -0,0 +1,18 @@ +include(RunCMake) + +run_cmake("CMP0171-WARN") + +run_cmake_with_options(CMP0171-OLD "-DCMAKE_POLICY_DEFAULT_CMP0171=OLD") + +run_cmake_with_options(CMP0171-NEW "-DCMAKE_POLICY_DEFAULT_CMP0171=NEW") + +# The entire point of this test is to ensure the codegen target is not created +# unintentionally. It can only be created if CMP0171 is NEW. +block() + set(RunCMake_TEST_BINARY_DIR ${RunCMake_BINARY_DIR}/CMP0171-codegen-build) + run_cmake(CMP0171-codegen) + set(RunCMake_TEST_NO_CLEAN 1) + set(RunCMake_TEST_OUTPUT_MERGE 1) + # This command will fail with either 1 or 2 depending. + run_cmake_command(CMP0171-codegen-build ${CMAKE_COMMAND} --build . --config Debug --target codegen) +endblock() diff --git a/Tests/RunCMake/CMakeLists.txt b/Tests/RunCMake/CMakeLists.txt index e205d9f..db5ef96 100644 --- a/Tests/RunCMake/CMakeLists.txt +++ b/Tests/RunCMake/CMakeLists.txt @@ -153,6 +153,9 @@ add_RunCMake_test(CMP0126) if("${CMAKE_C_COMPILER_ID}" STREQUAL "LCC" OR "${CMAKE_CXX_COMPILER_ID}" STREQUAL "LCC" OR "${CMAKE_Fortran_COMPILER_ID}" STREQUAL "LCC") + if(CMAKE_Fortran_COMPILER) + list(APPEND CMP0129_ARGS -DCMake_TEST_Fortran=1) + endif() add_RunCMake_test("CMP0129") set_property(TEST RunCMake.CMP0129 APPEND PROPERTY LABELS "Fortran") endif() @@ -177,6 +180,7 @@ add_RunCMake_test(CMP0163) add_RunCMake_test(CMP0165) add_RunCMake_test(CMP0169) add_RunCMake_test(CMP0170) +add_RunCMake_test(CMP0171) # The test for Policy 65 requires the use of the # CMAKE_SHARED_LIBRARY_LINK_CXX_FLAGS variable, which both the VS and Xcode @@ -285,28 +289,35 @@ if(CMake_TEST_Qt6 AND Qt6Widgets_FOUND) 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 - -DQtCore_VERSION=${Qt6Core_VERSION} - "-DQt6_DIR:PATH=${Qt6_DIR}" - "-DCMAKE_PREFIX_PATH:STRING=${base_dir}" - -DPSEUDO_TIDY=$<TARGET_FILE:pseudo_tidy> - -DPSEUDO_IWYU=$<TARGET_FILE:pseudo_iwyu> - -DPSEUDO_CPPLINT=$<TARGET_FILE:pseudo_cpplint> - -DPSEUDO_CPPCHECK=$<TARGET_FILE:pseudo_cppcheck> - ) + # Note: Since RunCMake.Autogen tests cause time out on some CI, + # we split the tests. + set(autogen_test_number 1 2 3 4 5) + foreach(val IN ITEMS ${autogen_test_number}) + add_RunCMake_test("Autogen_Qt6_${val}" TEST_DIR "Autogen_${val}" + -Dwith_qt_version=6 + -DQtCore_VERSION=${Qt6Core_VERSION} + "-DQt6_DIR:PATH=${Qt6_DIR}" + "-DCMAKE_PREFIX_PATH:STRING=${base_dir}" + -DPSEUDO_TIDY=$<TARGET_FILE:pseudo_tidy> + -DPSEUDO_IWYU=$<TARGET_FILE:pseudo_iwyu> + -DPSEUDO_CPPLINT=$<TARGET_FILE:pseudo_cpplint> + -DPSEUDO_CPPCHECK=$<TARGET_FILE:pseudo_cppcheck> + ) + endforeach() set(want_NoQt_test FALSE) endif () if(CMake_TEST_Qt5 AND Qt5Widgets_FOUND) - add_RunCMake_test(AutogenQt5 TEST_DIR Autogen - -Dwith_qt_version=5 - -DQtCore_VERSION=${Qt5Core_VERSION} - "-DQt5_DIR:PATH=${Qt5_DIR}" - ) + foreach(val IN ITEMS ${autogen_test_number}) + add_RunCMake_test("Autogen_Qt5_${val}" TEST_DIR "Autogen_${val}" + -Dwith_qt_version=5 + -DQtCore_VERSION=${Qt5Core_VERSION} + "-DQt5_DIR:PATH=${Qt5_DIR}" + ) + endforeach() set(want_NoQt_test FALSE) endif () if(want_NoQt_test) - add_RunCMake_test(AutogenNoQt TEST_DIR Autogen) + add_RunCMake_test(AutogenNoQt TEST_DIR Autogen_1) endif() if(NOT DEFINED CMake_TEST_BuildDepends_GNU_AS @@ -585,6 +596,7 @@ foreach(var endif() endforeach() add_RunCMake_test(file-DOWNLOAD) +add_RunCMake_test(file-MAKE_DIRECTORY) add_RunCMake_test(file-RPATH -DCMAKE_SYSTEM_NAME=${CMAKE_SYSTEM_NAME} -DCMake_TEST_ELF_LARGE=${CMake_TEST_ELF_LARGE} @@ -1056,6 +1068,7 @@ set(cpack_tests DEB.DEB_DESCRIPTION DEB.PROJECT_META DEB.COMPONENT_WITH_SPECIAL_CHARS + DEB.MULTIARCH RPM.AUTO_SUFFIXES RPM.CUSTOM_BINARY_SPEC_FILE @@ -1216,7 +1229,8 @@ add_RunCMake_test(CMakePresetsWorkflow add_RunCMake_test(VerifyHeaderSets) add_RunCMake_test(set_tests_properties) -if(${CMAKE_GENERATOR} MATCHES "Make|Ninja") +if(CMAKE_GENERATOR MATCHES "Make|Ninja") + add_RunCMake_test(Codegen) add_RunCMake_test(TransformDepfile) endif() diff --git a/Tests/RunCMake/CMakePresets/CommentValid-result.txt b/Tests/RunCMake/CMakePresets/CommentValid-result.txt new file mode 100644 index 0000000..573541a --- /dev/null +++ b/Tests/RunCMake/CMakePresets/CommentValid-result.txt @@ -0,0 +1 @@ +0 diff --git a/Tests/RunCMake/CMakePresets/CommentValid.cmake b/Tests/RunCMake/CMakePresets/CommentValid.cmake new file mode 100644 index 0000000..e69de29 --- /dev/null +++ b/Tests/RunCMake/CMakePresets/CommentValid.cmake diff --git a/Tests/RunCMake/CMakePresets/CommentValid.json.in b/Tests/RunCMake/CMakePresets/CommentValid.json.in new file mode 100644 index 0000000..1206ded --- /dev/null +++ b/Tests/RunCMake/CMakePresets/CommentValid.json.in @@ -0,0 +1,14 @@ +{ + "$comment": [ + "example comment", + "with an array of strings" + ], + "version": 10, + "configurePresets": [ + { + "name": "CommentValid", + "generator": "@RunCMake_GENERATOR@", + "binaryDir": "${sourceDir}/build" + } + ] +} diff --git a/Tests/RunCMake/CMakePresets/CommentValidFull-result.txt b/Tests/RunCMake/CMakePresets/CommentValidFull-result.txt new file mode 100644 index 0000000..573541a --- /dev/null +++ b/Tests/RunCMake/CMakePresets/CommentValidFull-result.txt @@ -0,0 +1 @@ +0 diff --git a/Tests/RunCMake/CMakePresets/CommentValidFull.cmake b/Tests/RunCMake/CMakePresets/CommentValidFull.cmake new file mode 100644 index 0000000..e69de29 --- /dev/null +++ b/Tests/RunCMake/CMakePresets/CommentValidFull.cmake diff --git a/Tests/RunCMake/CMakePresets/CommentValidFull.json.in b/Tests/RunCMake/CMakePresets/CommentValidFull.json.in new file mode 100644 index 0000000..40bab97 --- /dev/null +++ b/Tests/RunCMake/CMakePresets/CommentValidFull.json.in @@ -0,0 +1,179 @@ +{ + "$comment": [ + "example comment", + "with an array of strings" + ], + "version": 10, + "cmakeMinimumRequired": { + "$comment": "We can add comments in version" + }, + "configurePresets": [ + { + "name": "CommentValidFull", + "$comment": "example comment", + "generator": "@RunCMake_GENERATOR@", + "binaryDir": "${sourceDir}/build", + "architecture": { + "$comment": "We can add comments in architecture", + "value": "v143", + "strategy": "external" + }, + "toolset": { + "$comment": "We can add comments in toolset", + "value": "x64", + "strategy": "external" + }, + "cacheVariables": { + "SOME_VARIABLE": { + "$comment": "We can add comments in every cacheVariable, that we created", + "value": "SOME_VALUE" + } + }, + "warnings": { + "$comment": "We can add comments in warnings", + "dev": false + }, + "errors": { + "$comment": "We can add comments in errors", + "dev": false + }, + "debug": { + "$comment": "We can add comments in debug", + "find": false + }, + "trace": { + "$comment": "We can add comments in trace", + "mode": "off" + } + } + ], + "buildPresets": [ + { + "$comment": "example comment", + "name": "default", + "condition": { + "$comment": "We can add comments in condition", + "type": "const", + "value": false + }, + "configurePreset": "CommentValidFull" + } + ], + "testPresets": [ + { + "name": "default", + "configurePreset": "CommentValidFull", + "filter": { + "$comment": "We can add comments in filter", + "include": { + "$comment": ["example comment", "with an array of strings", "inside include"], + "index": { + "$comment": ["example comment", "with an array of strings"], + "start": 0 + } + }, + "exclude": { + "$comment": ["example comment", "with an array of strings", "inside exclude"], + "fixtures": { + "$comment": ["example comment", "with an array of strings"], + "any": ".*full.*" + } + } + }, + "execution": { + "$comment": ["example comment", "with an array of strings"], + "repeat": { + "$comment": "Some comments here", + "mode": "until-fail", + "count": 1 + } + }, + "condition": { + "$comment": "We can add comments in equal & non-equal conditions", + "type": "equals", + "lhs": "test1", + "rhs": "test2" + }, + "$comment": ["example comment", "with an array of strings"] + } + ], + "packagePresets": [ + { + "name": "CommentValidFull", + "$comment": ["example comment", "with an array of strings"], + "configurePreset": "CommentValidFull", + "condition": { + "$comment": "We can add comments in list check conditions", + "type": "notInList", + "list": [ + "test1", + "test2" + ], + "string": "test1" + }, + "output": { + "$comment": "Hello, World!", + "debug": false + } + }, + { + "name": "CommentValidFull1", + "configurePreset": "CommentValidFull", + "condition": { + "$comment": "We can add comments in aggregation conditions", + "type": "allOf", + "conditions": [ + { + "$comment": "We can add comments in regex match conditions", + "type": "matches", + "regex": ".*tests.*", + "string": "test1" + }, + { + "type": "matches", + "regex": ".*tests.*", + "string": "test2" + }, + { + "type": "not", + "$comment": "We can add comments in not conditions", + "condition": { + "type": "matches", + "regex": ".*tests.*", + "string": "test3" + } + } + ] + }, + "output": { + "$comment": "Hello, World 123!", + "verbose": false + } + } + ], + "workflowPresets": [ + { + "name": "CommentValidFull", + "$comment": ["example comment", "with an array of strings"], + "steps": [ + { + "type": "configure", + "name": "CommentValidFull" + }, + { + "type": "build", + "name": "default" + }, + { + "$comment": "We must test it before we can package it", + "type": "test", + "name": "default" + }, + { + "type": "package", + "name": "CommentValidFull" + } + ] + } + ] +} diff --git a/Tests/RunCMake/CMakePresets/CommentValidOldSchema-result.txt b/Tests/RunCMake/CMakePresets/CommentValidOldSchema-result.txt new file mode 100644 index 0000000..d00491f --- /dev/null +++ b/Tests/RunCMake/CMakePresets/CommentValidOldSchema-result.txt @@ -0,0 +1 @@ +1 diff --git a/Tests/RunCMake/CMakePresets/CommentValidOldSchema-stderr.txt b/Tests/RunCMake/CMakePresets/CommentValidOldSchema-stderr.txt new file mode 100644 index 0000000..b102f5b --- /dev/null +++ b/Tests/RunCMake/CMakePresets/CommentValidOldSchema-stderr.txt @@ -0,0 +1,2 @@ +^CMake Error: Could not read presets from .* +Error: @2,15: Invalid extra field \"\$comment\" in root object diff --git a/Tests/RunCMake/CMakePresets/CommentValidOldSchema.cmake b/Tests/RunCMake/CMakePresets/CommentValidOldSchema.cmake new file mode 100644 index 0000000..e69de29 --- /dev/null +++ b/Tests/RunCMake/CMakePresets/CommentValidOldSchema.cmake diff --git a/Tests/RunCMake/CMakePresets/CommentValidOldSchema.json.in b/Tests/RunCMake/CMakePresets/CommentValidOldSchema.json.in new file mode 100644 index 0000000..d92ee1d --- /dev/null +++ b/Tests/RunCMake/CMakePresets/CommentValidOldSchema.json.in @@ -0,0 +1,14 @@ +{ + "$comment": [ + "invalid comment", + "version less than 10" + ], + "version": 9, + "configurePresets": [ + { + "name": "CommentValidOldSchema", + "generator": "@RunCMake_GENERATOR@", + "binaryDir": "${sourceDir}/build" + } + ] +} diff --git a/Tests/RunCMake/CMakePresets/NoCommentValid-result.txt b/Tests/RunCMake/CMakePresets/NoCommentValid-result.txt new file mode 100644 index 0000000..573541a --- /dev/null +++ b/Tests/RunCMake/CMakePresets/NoCommentValid-result.txt @@ -0,0 +1 @@ +0 diff --git a/Tests/RunCMake/CMakePresets/NoCommentValid.cmake b/Tests/RunCMake/CMakePresets/NoCommentValid.cmake new file mode 100644 index 0000000..e69de29 --- /dev/null +++ b/Tests/RunCMake/CMakePresets/NoCommentValid.cmake diff --git a/Tests/RunCMake/CMakePresets/NoCommentValid.json.in b/Tests/RunCMake/CMakePresets/NoCommentValid.json.in new file mode 100644 index 0000000..cf10ee2 --- /dev/null +++ b/Tests/RunCMake/CMakePresets/NoCommentValid.json.in @@ -0,0 +1,10 @@ +{ + "version": 10, + "configurePresets": [ + { + "name": "NoCommentValid", + "generator": "@RunCMake_GENERATOR@", + "binaryDir": "${sourceDir}/build" + } + ] +} diff --git a/Tests/RunCMake/CMakePresets/RunCMakeTest.cmake b/Tests/RunCMake/CMakePresets/RunCMakeTest.cmake index 2ec0a43..081f3bb 100644 --- a/Tests/RunCMake/CMakePresets/RunCMakeTest.cmake +++ b/Tests/RunCMake/CMakePresets/RunCMakeTest.cmake @@ -92,6 +92,12 @@ endfunction() set(CMakePresets_SCHEMA_EXPECTED_RESULT 1) run_cmake_presets(NoCMakePresets) run_cmake_presets(Comment) +set(CMakePresets_SCHEMA_EXPECTED_RESULT 0) +run_cmake_presets(NoCommentValid) +run_cmake_presets(CommentValid) +run_cmake_presets(CommentValidFull) +set(CMakePresets_SCHEMA_EXPECTED_RESULT 1) +run_cmake_presets(CommentValidOldSchema) run_cmake_presets(JSONParseError) run_cmake_presets(InvalidRoot) run_cmake_presets(NoVersion) diff --git a/Tests/RunCMake/CPack/README.txt b/Tests/RunCMake/CPack/README.txt index 2165125..d403db0 100644 --- a/Tests/RunCMake/CPack/README.txt +++ b/Tests/RunCMake/CPack/README.txt @@ -10,8 +10,8 @@ CPack test root directory: 'Tests/RunCMake/CPack/tests'. All phases are executed separately for each generator that is bound to a test. Tests for each generator are subtests of test 'RunCMake.CPack_<generator_name>'. -Each test must also be added to 'RunCMakeTest.cmake' script located in CPack -test root directory. +Each test must be added to list "cpack_tests" in 'Tests/RunCMake/CMakeLists.txt' +and also to 'RunCMakeTest.cmake' script located in 'Tests/RunCMake/CPack/'. Line that adds a test is: run_cpack_test(<test_name> "<generator_name_list>" <compile_stage> @@ -53,7 +53,7 @@ Test consists of - verification of generated files The phases are executed once per specified generator, packaging type and subtest -combinatiion. +combination. test prerequirements phase (optional): -------------------------------------- @@ -136,7 +136,7 @@ this step and must contain - EXPECTED_FILES_COUNT variable that contains the number of expected files that will be generated (0 or more) -- EXPECTED_FILE_<file_number_starting_with_1> that contains globing expression +- EXPECTED_FILE_<file_number_starting_with_1> that contains globbing expression that uniquely defines expected file name (will be used to find expected file) and should be present once for each expected file. NOTE: This variable should be used only as last resort as it sets generator diff --git a/Tests/RunCMake/CPack/RunCMakeTest.cmake b/Tests/RunCMake/CPack/RunCMakeTest.cmake index 5d32404..54671aa 100644 --- a/Tests/RunCMake/CPack/RunCMakeTest.cmake +++ b/Tests/RunCMake/CPack/RunCMakeTest.cmake @@ -73,3 +73,4 @@ run_cpack_test_package_target(PRE_POST_SCRIPTS "ZIP" false "MONOLITHIC;COMPONENT run_cpack_test_subtests(DUPLICATE_FILE "success;conflict_file;conflict_symlink" "TGZ" false "COMPONENT;GROUP") run_cpack_test(COMPONENT_WITH_SPECIAL_CHARS "RPM.COMPONENT_WITH_SPECIAL_CHARS;DEB.COMPONENT_WITH_SPECIAL_CHARS;7Z;TBZ2;TGZ;TXZ;TZ;ZIP;STGZ" false "MONOLITHIC;COMPONENT;GROUP") run_cpack_test_package_target(COMPONENT_WITH_SPECIAL_CHARS "RPM.COMPONENT_WITH_SPECIAL_CHARS;DEB.COMPONENT_WITH_SPECIAL_CHARS;7Z;TBZ2;TGZ;TXZ;TZ;ZIP;STGZ" false "MONOLITHIC;COMPONENT;GROUP") +run_cpack_test_subtests(MULTIARCH "same;foreign;allowed;fail" "DEB.MULTIARCH" false "MONOLITHIC;COMPONENT") diff --git a/Tests/RunCMake/CPack/tests/MULTIARCH/DEB-fail-stderr.txt b/Tests/RunCMake/CPack/tests/MULTIARCH/DEB-fail-stderr.txt new file mode 100644 index 0000000..8164e83 --- /dev/null +++ b/Tests/RunCMake/CPack/tests/MULTIARCH/DEB-fail-stderr.txt @@ -0,0 +1 @@ +Error: invalid value for Multi-Arch: fail\. Valid values are: same, foreign, allowed diff --git a/Tests/RunCMake/CPack/tests/MULTIARCH/ExpectedFiles.cmake b/Tests/RunCMake/CPack/tests/MULTIARCH/ExpectedFiles.cmake new file mode 100644 index 0000000..14b898f --- /dev/null +++ b/Tests/RunCMake/CPack/tests/MULTIARCH/ExpectedFiles.cmake @@ -0,0 +1,5 @@ +set(EXPECTED_FILES_COUNT "0") +if(NOT ${RunCMake_SUBTEST_SUFFIX} STREQUAL "fail") + set(EXPECTED_FILES_COUNT "1") + set(EXPECTED_FILE_CONTENT_1_LIST "/foo;/foo/CMakeLists.txt") +endif () diff --git a/Tests/RunCMake/CPack/tests/MULTIARCH/VerifyResult.cmake b/Tests/RunCMake/CPack/tests/MULTIARCH/VerifyResult.cmake new file mode 100644 index 0000000..f4e8050 --- /dev/null +++ b/Tests/RunCMake/CPack/tests/MULTIARCH/VerifyResult.cmake @@ -0,0 +1,4 @@ +if(NOT ${RunCMake_SUBTEST_SUFFIX} STREQUAL "fail") + set(MULTIARCH_control "Multi-Arch: ${RunCMake_SUBTEST_SUFFIX}") + verifyDebControl("${FOUND_FILE_1}" "MULTIARCH" "control") +endif () diff --git a/Tests/RunCMake/CPack/tests/MULTIARCH/test.cmake b/Tests/RunCMake/CPack/tests/MULTIARCH/test.cmake new file mode 100644 index 0000000..9784342 --- /dev/null +++ b/Tests/RunCMake/CPack/tests/MULTIARCH/test.cmake @@ -0,0 +1,7 @@ +install(FILES CMakeLists.txt DESTINATION foo COMPONENT test) + +set(CPACK_DEBIAN_PACKAGE_MULTIARCH ${RunCMake_SUBTEST_SUFFIX}) + +if(PACKAGING_TYPE STREQUAL "COMPONENT") + set(CPACK_COMPONENTS_ALL test) +endif() diff --git a/Tests/RunCMake/Codegen/CMakeLists.txt b/Tests/RunCMake/Codegen/CMakeLists.txt new file mode 100644 index 0000000..f65150d --- /dev/null +++ b/Tests/RunCMake/Codegen/CMakeLists.txt @@ -0,0 +1,7 @@ +cmake_minimum_required(VERSION 3.29) +project(${RunCMake_TEST} LANGUAGES C) + +# This value is read from the top level CMakeLists.txt +cmake_policy(SET CMP0171 NEW) + +include(${RunCMake_TEST}.cmake) diff --git a/Tests/RunCMake/Codegen/RunCMakeTest.cmake b/Tests/RunCMake/Codegen/RunCMakeTest.cmake new file mode 100644 index 0000000..bbd70b0 --- /dev/null +++ b/Tests/RunCMake/Codegen/RunCMakeTest.cmake @@ -0,0 +1,33 @@ +include(RunCMake) + +function(run_codegen case) + set(RunCMake_TEST_BINARY_DIR ${RunCMake_BINARY_DIR}/${case}-build) + + run_cmake(${case}) + + set(RunCMake_TEST_NO_CLEAN 1) + + run_cmake_command(${case}-build ${CMAKE_COMMAND} --build . --target codegen --config Debug) +endfunction() + +# Builds codegen target when there are no custom commands marked codegen +run_codegen("no-codegen") + +# We don't want codegen to drive parts of the project that are EXCLUDE_FROM_ALL +run_codegen("exclude-from-all") + +# Ensures codegen builds minimal build graphs +run_codegen("min-graph-1") +run_codegen("min-graph-2") +run_codegen("min-graph-3") + +# Handle specific cases that can affect codegen +run_codegen("add-dependencies") +run_codegen("add-custom-command-depends") +run_codegen("byproducts") + +# Error handling +run_cmake("implicit-depends") +run_cmake("implicit-depends-append-codegen") +run_cmake("append-implicit-depends") +run_cmake("no-output") diff --git a/Tests/RunCMake/Codegen/add-custom-command-depends-build-check.cmake b/Tests/RunCMake/Codegen/add-custom-command-depends-build-check.cmake new file mode 100644 index 0000000..d371d73 --- /dev/null +++ b/Tests/RunCMake/Codegen/add-custom-command-depends-build-check.cmake @@ -0,0 +1,5 @@ +set(filename "${RunCMake_TEST_BINARY_DIR}/generated.hpp") +if (NOT EXISTS "${filename}") + set(RunCMake_TEST_FAILED "expected file NOT created:\n ${filename}") + return() +endif() diff --git a/Tests/RunCMake/Codegen/add-custom-command-depends.cmake b/Tests/RunCMake/Codegen/add-custom-command-depends.cmake new file mode 100644 index 0000000..793ab5f --- /dev/null +++ b/Tests/RunCMake/Codegen/add-custom-command-depends.cmake @@ -0,0 +1,16 @@ +add_custom_target(foobar + COMMAND ${CMAKE_COMMAND} -E copy + ${CMAKE_CURRENT_SOURCE_DIR}/generated.h.in + ${CMAKE_CURRENT_BINARY_DIR}/generated.h +) + +add_custom_command( + OUTPUT generated.hpp + # This test will fail if DEPENDS isn't accounted for in the codegen build graph + DEPENDS foobar + COMMAND ${CMAKE_COMMAND} -E copy ${CMAKE_CURRENT_BINARY_DIR}/generated.h + ${CMAKE_CURRENT_BINARY_DIR}/generated.hpp + CODEGEN +) + +add_custom_target(hpp_creator ALL DEPENDS ${CMAKE_CURRENT_BINARY_DIR}/generated.hpp) diff --git a/Tests/RunCMake/Codegen/add-dependencies-build-check.cmake b/Tests/RunCMake/Codegen/add-dependencies-build-check.cmake new file mode 100644 index 0000000..d371d73 --- /dev/null +++ b/Tests/RunCMake/Codegen/add-dependencies-build-check.cmake @@ -0,0 +1,5 @@ +set(filename "${RunCMake_TEST_BINARY_DIR}/generated.hpp") +if (NOT EXISTS "${filename}") + set(RunCMake_TEST_FAILED "expected file NOT created:\n ${filename}") + return() +endif() diff --git a/Tests/RunCMake/Codegen/add-dependencies.cmake b/Tests/RunCMake/Codegen/add-dependencies.cmake new file mode 100644 index 0000000..fbb7e99 --- /dev/null +++ b/Tests/RunCMake/Codegen/add-dependencies.cmake @@ -0,0 +1,18 @@ +add_custom_target(foobar + COMMAND ${CMAKE_COMMAND} -E copy + ${CMAKE_CURRENT_SOURCE_DIR}/generated.h.in + ${CMAKE_CURRENT_BINARY_DIR}/generated.h +) + +add_custom_command( + OUTPUT generated.hpp + COMMAND ${CMAKE_COMMAND} -E copy ${CMAKE_CURRENT_BINARY_DIR}/generated.h + ${CMAKE_CURRENT_BINARY_DIR}/generated.hpp + CODEGEN +) + +add_custom_target(hpp_creator ALL DEPENDS ${CMAKE_CURRENT_BINARY_DIR}/generated.hpp) + +# This test will fail if add_dependencies isn't account for in the +# codegen build graph +add_dependencies(hpp_creator foobar) diff --git a/Tests/RunCMake/Codegen/append-implicit-depends-result.txt b/Tests/RunCMake/Codegen/append-implicit-depends-result.txt new file mode 100644 index 0000000..d00491f --- /dev/null +++ b/Tests/RunCMake/Codegen/append-implicit-depends-result.txt @@ -0,0 +1 @@ +1 diff --git a/Tests/RunCMake/Codegen/append-implicit-depends-stderr.txt b/Tests/RunCMake/Codegen/append-implicit-depends-stderr.txt new file mode 100644 index 0000000..c8ef03e --- /dev/null +++ b/Tests/RunCMake/Codegen/append-implicit-depends-stderr.txt @@ -0,0 +1,2 @@ +CMake Error: + Cannot append IMPLICIT_DEPENDS to existing CODEGEN custom command\. diff --git a/Tests/RunCMake/Codegen/append-implicit-depends.cmake b/Tests/RunCMake/Codegen/append-implicit-depends.cmake new file mode 100644 index 0000000..d212fe5 --- /dev/null +++ b/Tests/RunCMake/Codegen/append-implicit-depends.cmake @@ -0,0 +1,19 @@ +add_custom_command( + OUTPUT + ${CMAKE_CURRENT_BINARY_DIR}/main.cpp + COMMAND + ${CMAKE_COMMAND} -E + copy ${CMAKE_CURRENT_SOURCE_DIR}/error.c + ${CMAKE_CURRENT_BINARY_DIR}/main.cpp + CODEGEN +) + +add_custom_command( + OUTPUT + ${CMAKE_CURRENT_BINARY_DIR}/main.cpp + + # ERROR out if IMPLICIT_DEPENDS is used with CODEGEN + IMPLICIT_DEPENDS C main.c + + APPEND +) diff --git a/Tests/RunCMake/Codegen/byproducts-build-check.cmake b/Tests/RunCMake/Codegen/byproducts-build-check.cmake new file mode 100644 index 0000000..d371d73 --- /dev/null +++ b/Tests/RunCMake/Codegen/byproducts-build-check.cmake @@ -0,0 +1,5 @@ +set(filename "${RunCMake_TEST_BINARY_DIR}/generated.hpp") +if (NOT EXISTS "${filename}") + set(RunCMake_TEST_FAILED "expected file NOT created:\n ${filename}") + return() +endif() diff --git a/Tests/RunCMake/Codegen/byproducts.cmake b/Tests/RunCMake/Codegen/byproducts.cmake new file mode 100644 index 0000000..ea0b6c7 --- /dev/null +++ b/Tests/RunCMake/Codegen/byproducts.cmake @@ -0,0 +1,19 @@ +add_custom_target(foobar + COMMAND ${CMAKE_COMMAND} -E copy + ${CMAKE_CURRENT_SOURCE_DIR}/generated.h.in + ${CMAKE_CURRENT_BINARY_DIR}/generated.h + BYPRODUCTS + ${CMAKE_CURRENT_BINARY_DIR}/generated.h +) + +# This codegen step relies on the BYPRODUCTS of the previous command. +# If foobar isn't properly accounted for as a dependency it will fail. +add_custom_command( + OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/generated.hpp + DEPENDS ${CMAKE_CURRENT_BINARY_DIR}/generated.h + COMMAND ${CMAKE_COMMAND} -E copy ${CMAKE_CURRENT_BINARY_DIR}/generated.h + ${CMAKE_CURRENT_BINARY_DIR}/generated.hpp + CODEGEN +) + +add_custom_target(hpp_creator ALL DEPENDS ${CMAKE_CURRENT_BINARY_DIR}/generated.hpp) diff --git a/Tests/RunCMake/Codegen/error.c b/Tests/RunCMake/Codegen/error.c new file mode 100644 index 0000000..34cb350 --- /dev/null +++ b/Tests/RunCMake/Codegen/error.c @@ -0,0 +1 @@ +#error "This file should not be compiled" diff --git a/Tests/RunCMake/Codegen/exclude-from-all.cmake b/Tests/RunCMake/Codegen/exclude-from-all.cmake new file mode 100644 index 0000000..bcd4ac0 --- /dev/null +++ b/Tests/RunCMake/Codegen/exclude-from-all.cmake @@ -0,0 +1,11 @@ +add_custom_command( + OUTPUT + ${CMAKE_CURRENT_BINARY_DIR}/generated.h + COMMAND + ${CMAKE_COMMAND} -E false + CODEGEN +) + +# We don't want codegen to drive parts of the project that are EXCLUDE_FROM_ALL. +# This tests that foobar is properly excluded from the codegen build. +add_executable(foobar EXCLUDE_FROM_ALL error.c ${CMAKE_CURRENT_BINARY_DIR}/generated.h) diff --git a/Tests/RunCMake/Codegen/generated.h.in b/Tests/RunCMake/Codegen/generated.h.in new file mode 100644 index 0000000..82ccf67 --- /dev/null +++ b/Tests/RunCMake/Codegen/generated.h.in @@ -0,0 +1 @@ +// hello diff --git a/Tests/RunCMake/Codegen/implicit-depends-append-codegen-result.txt b/Tests/RunCMake/Codegen/implicit-depends-append-codegen-result.txt new file mode 100644 index 0000000..d00491f --- /dev/null +++ b/Tests/RunCMake/Codegen/implicit-depends-append-codegen-result.txt @@ -0,0 +1 @@ +1 diff --git a/Tests/RunCMake/Codegen/implicit-depends-append-codegen-stderr.txt b/Tests/RunCMake/Codegen/implicit-depends-append-codegen-stderr.txt new file mode 100644 index 0000000..570cf62 --- /dev/null +++ b/Tests/RunCMake/Codegen/implicit-depends-append-codegen-stderr.txt @@ -0,0 +1,4 @@ +^CMake Error at implicit-depends-append-codegen\.cmake:[0-9]+ \(add_custom_command\): + add_custom_command CODEGEN may not be used with APPEND\. +Call Stack \(most recent call first\): + CMakeLists\.txt:[0-9]+ \(include\)$ diff --git a/Tests/RunCMake/Codegen/implicit-depends-append-codegen.cmake b/Tests/RunCMake/Codegen/implicit-depends-append-codegen.cmake new file mode 100644 index 0000000..76151cc --- /dev/null +++ b/Tests/RunCMake/Codegen/implicit-depends-append-codegen.cmake @@ -0,0 +1,18 @@ +add_custom_command( + OUTPUT + ${CMAKE_CURRENT_BINARY_DIR}/main.cpp + + # ERROR out if IMPLICIT_DEPENDS is used with CODEGEN + IMPLICIT_DEPENDS C main.c +) + +add_custom_command( + OUTPUT + ${CMAKE_CURRENT_BINARY_DIR}/main.cpp + COMMAND + ${CMAKE_COMMAND} -E + copy ${CMAKE_CURRENT_SOURCE_DIR}/error.c + ${CMAKE_CURRENT_BINARY_DIR}/main.cpp + CODEGEN + APPEND +) diff --git a/Tests/RunCMake/Codegen/implicit-depends-result.txt b/Tests/RunCMake/Codegen/implicit-depends-result.txt new file mode 100644 index 0000000..d00491f --- /dev/null +++ b/Tests/RunCMake/Codegen/implicit-depends-result.txt @@ -0,0 +1 @@ +1 diff --git a/Tests/RunCMake/Codegen/implicit-depends-stderr.txt b/Tests/RunCMake/Codegen/implicit-depends-stderr.txt new file mode 100644 index 0000000..b9ea8f4 --- /dev/null +++ b/Tests/RunCMake/Codegen/implicit-depends-stderr.txt @@ -0,0 +1,4 @@ +CMake Error at implicit-depends\.cmake:[0-9]+ \(add_custom_command\): + add_custom_command CODEGEN is not compatible with IMPLICIT_DEPENDS\. +Call Stack \(most recent call first\): + CMakeLists\.txt:[0-9]+ \(include\) diff --git a/Tests/RunCMake/Codegen/implicit-depends.cmake b/Tests/RunCMake/Codegen/implicit-depends.cmake new file mode 100644 index 0000000..011d4b3 --- /dev/null +++ b/Tests/RunCMake/Codegen/implicit-depends.cmake @@ -0,0 +1,11 @@ +add_custom_command( + OUTPUT + ${CMAKE_CURRENT_BINARY_DIR}/main.cpp + COMMAND + ${CMAKE_COMMAND} -E + copy ${CMAKE_CURRENT_SOURCE_DIR}/error.c + ${CMAKE_CURRENT_BINARY_DIR}/main.cpp + CODEGEN + # ERROR out if IMPLICIT_DEPENDS is used with CODEGEN + IMPLICIT_DEPENDS C main.c +) diff --git a/Tests/RunCMake/Autogen/exe.cpp b/Tests/RunCMake/Codegen/main.c index f8b643a..8488f4e 100644 --- a/Tests/RunCMake/Autogen/exe.cpp +++ b/Tests/RunCMake/Codegen/main.c @@ -1,4 +1,4 @@ -int main() +int main(void) { return 0; } diff --git a/Tests/RunCMake/Codegen/min-graph-1-build-check.cmake b/Tests/RunCMake/Codegen/min-graph-1-build-check.cmake new file mode 100644 index 0000000..32e1557 --- /dev/null +++ b/Tests/RunCMake/Codegen/min-graph-1-build-check.cmake @@ -0,0 +1,13 @@ +set(filename "${RunCMake_TEST_BINARY_DIR}/generated.h") +if (NOT EXISTS "${filename}") + set(RunCMake_TEST_FAILED "expected file NOT created:\n ${filename}") + return() +endif() + +# foobar should be built since it was needed +# by the code generation +set(filename "${RunCMake_TEST_BINARY_DIR}/foobar.txt") +if (NOT EXISTS "${filename}") + set(RunCMake_TEST_FAILED "expected file NOT created:\n ${filename}") + return() +endif() diff --git a/Tests/RunCMake/Codegen/min-graph-1.cmake b/Tests/RunCMake/Codegen/min-graph-1.cmake new file mode 100644 index 0000000..ea47b8f --- /dev/null +++ b/Tests/RunCMake/Codegen/min-graph-1.cmake @@ -0,0 +1,26 @@ +add_executable(foobar main.c) +add_custom_command( + TARGET foobar POST_BUILD + COMMAND ${CMAKE_COMMAND} -E + copy ${CMAKE_CURRENT_SOURCE_DIR}/generated.h.in + ${CMAKE_CURRENT_BINARY_DIR}/foobar.txt +) + +add_custom_command( + OUTPUT + ${CMAKE_CURRENT_BINARY_DIR}/generated.h + COMMAND + ${CMAKE_COMMAND} -E + copy ${CMAKE_CURRENT_SOURCE_DIR}/generated.h.in + ${CMAKE_CURRENT_BINARY_DIR}/generated.h + COMMAND + # Generate a header file that requires foobar + foobar + CODEGEN +) + +add_library(errorlib + # If this library is built error.c will cause the build to fail + error.c + ${CMAKE_CURRENT_BINARY_DIR}/generated.h +) diff --git a/Tests/RunCMake/Codegen/min-graph-2-build-check.cmake b/Tests/RunCMake/Codegen/min-graph-2-build-check.cmake new file mode 100644 index 0000000..fab168b --- /dev/null +++ b/Tests/RunCMake/Codegen/min-graph-2-build-check.cmake @@ -0,0 +1,5 @@ +set(filename "${RunCMake_TEST_BINARY_DIR}/generated.h") +if (NOT EXISTS "${filename}") + set(RunCMake_TEST_FAILED "expected file NOT created:\n ${filename}") + return() +endif() diff --git a/Tests/RunCMake/Codegen/min-graph-2.cmake b/Tests/RunCMake/Codegen/min-graph-2.cmake new file mode 100644 index 0000000..277a901 --- /dev/null +++ b/Tests/RunCMake/Codegen/min-graph-2.cmake @@ -0,0 +1,18 @@ +add_custom_command( + OUTPUT + ${CMAKE_CURRENT_BINARY_DIR}/generated.h + COMMAND + ${CMAKE_COMMAND} -E + copy ${CMAKE_CURRENT_SOURCE_DIR}/generated.h.in + ${CMAKE_CURRENT_BINARY_DIR}/generated.h + CODEGEN +) + +# This target should not be built. It has no reason +# to be part of the codegen build graph +add_custom_target(error_custom_target ALL + DEPENDS ${CMAKE_CURRENT_BINARY_DIR}/generated.h + + # Cause the build to fail + COMMAND ${CMAKE_COMMAND} -E false +) diff --git a/Tests/RunCMake/Codegen/min-graph-3-build-check.cmake b/Tests/RunCMake/Codegen/min-graph-3-build-check.cmake new file mode 100644 index 0000000..734777b --- /dev/null +++ b/Tests/RunCMake/Codegen/min-graph-3-build-check.cmake @@ -0,0 +1,5 @@ +set(filename "${RunCMake_TEST_BINARY_DIR}/error_lib.c") +if (NOT EXISTS "${filename}") + set(RunCMake_TEST_FAILED "expected file NOT created:\n ${filename}") + return() +endif() diff --git a/Tests/RunCMake/Codegen/min-graph-3.cmake b/Tests/RunCMake/Codegen/min-graph-3.cmake new file mode 100644 index 0000000..c7d61dc --- /dev/null +++ b/Tests/RunCMake/Codegen/min-graph-3.cmake @@ -0,0 +1,12 @@ +add_custom_command( + OUTPUT + ${CMAKE_CURRENT_BINARY_DIR}/error_lib.c + COMMAND + ${CMAKE_COMMAND} -E + copy ${CMAKE_CURRENT_SOURCE_DIR}/error.c + ${CMAKE_CURRENT_BINARY_DIR}/error_lib.c + CODEGEN +) + +# This test will fail if error_lib.c is actually compiled +add_executable(foobar ${CMAKE_CURRENT_BINARY_DIR}/error_lib.c) diff --git a/Tests/RunCMake/Codegen/no-codegen-check.cmake b/Tests/RunCMake/Codegen/no-codegen-check.cmake new file mode 100644 index 0000000..97fc46b --- /dev/null +++ b/Tests/RunCMake/Codegen/no-codegen-check.cmake @@ -0,0 +1,5 @@ +# Verify generated.hpp was NOT created +set(unexpected "${RunCMake_TEST_BINARY_DIR}/generated.hpp") +if(EXISTS "${unexpected}") + set(RunCMake_TEST_FAILED "unexpected file created:\n ${unexpected}") +endif() diff --git a/Tests/RunCMake/Codegen/no-codegen.cmake b/Tests/RunCMake/Codegen/no-codegen.cmake new file mode 100644 index 0000000..00ddd03 --- /dev/null +++ b/Tests/RunCMake/Codegen/no-codegen.cmake @@ -0,0 +1,6 @@ +add_custom_command( + OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/generated.hpp + COMMAND ${CMAKE_COMMAND} -E copy + ${CMAKE_CURRENT_SOURCE_DIR}/generated.h.in + ${CMAKE_CURRENT_BINARY_DIR}/generated.hpp +) diff --git a/Tests/RunCMake/Codegen/no-output-result.txt b/Tests/RunCMake/Codegen/no-output-result.txt new file mode 100644 index 0000000..d00491f --- /dev/null +++ b/Tests/RunCMake/Codegen/no-output-result.txt @@ -0,0 +1 @@ +1 diff --git a/Tests/RunCMake/Codegen/no-output-stderr.txt b/Tests/RunCMake/Codegen/no-output-stderr.txt new file mode 100644 index 0000000..7aad679 --- /dev/null +++ b/Tests/RunCMake/Codegen/no-output-stderr.txt @@ -0,0 +1,4 @@ +CMake Error at no-output\.cmake:[0-9]+ \(add_custom_command\): + add_custom_command CODEGEN requires at least 1 OUTPUT\. +Call Stack \(most recent call first\): + CMakeLists\.txt:[0-9]+ \(include\) diff --git a/Tests/RunCMake/Codegen/no-output.cmake b/Tests/RunCMake/Codegen/no-output.cmake new file mode 100644 index 0000000..61eb83c --- /dev/null +++ b/Tests/RunCMake/Codegen/no-output.cmake @@ -0,0 +1,11 @@ +add_custom_target(foobar + COMMAND ${CMAKE_COMMAND} -E copy + ${CMAKE_CURRENT_SOURCE_DIR}/generated.h.in + ${CMAKE_CURRENT_BINARY_DIR}/generated.h +) + +add_custom_command(TARGET foobar POST_BUILD + COMMAND + ${CMAKE_COMMAND} -E true + CODEGEN +) diff --git a/Tests/RunCMake/Framework/FrameworkLayout-check-common.cmake b/Tests/RunCMake/Framework/FrameworkLayout-check-common.cmake new file mode 100644 index 0000000..13a91df --- /dev/null +++ b/Tests/RunCMake/Framework/FrameworkLayout-check-common.cmake @@ -0,0 +1,24 @@ +macro(check_plist key expect) + execute_process( + COMMAND plutil -extract "${key}" xml1 "${plist-file}" -o - + RESULT_VARIABLE result + OUTPUT_VARIABLE actual + OUTPUT_STRIP_TRAILING_WHITESPACE + ) + if(actual MATCHES "<string>([^<>]*)</string>") + set(actual "${CMAKE_MATCH_1}") + endif() + if(NOT "${actual}" STREQUAL "${expect}") + string(CONCAT RunCMake_TEST_FAILED + "Framework Info.plist key \"${key}\" has value:\n" + " \"${actual}\"\n" + "but we expected:\n" + " \"${expect}\"" + ) + endif() +endmacro() + +check_plist(CFBundleIdentifier MyFrameworkId) +check_plist(CFBundleName MyFrameworkBundleName) +check_plist(CFBundleVersion 3.2.1) +check_plist(CFBundleShortVersionString 3) diff --git a/Tests/RunCMake/Framework/FrameworkLayout.cmake b/Tests/RunCMake/Framework/FrameworkLayout.cmake index d09e8a0..e230e07 100644 --- a/Tests/RunCMake/Framework/FrameworkLayout.cmake +++ b/Tests/RunCMake/Framework/FrameworkLayout.cmake @@ -15,6 +15,10 @@ if("${CMAKE_FRAMEWORK}" STREQUAL "") FRAMEWORK TRUE) endif() set_target_properties(Framework PROPERTIES + MACOSX_FRAMEWORK_BUNDLE_NAME MyFrameworkBundleName + MACOSX_FRAMEWORK_BUNDLE_VERSION 3.2.1 + MACOSX_FRAMEWORK_SHORT_VERSION_STRING 3 + MACOSX_FRAMEWORK_IDENTIFIER MyFrameworkId PUBLIC_HEADER foo.h RESOURCE "res.txt") set_source_files_properties(flatresource.txt PROPERTIES MACOSX_PACKAGE_LOCATION Resources) diff --git a/Tests/RunCMake/Framework/FrameworkMultiConfigPostfix-build-final-check.cmake b/Tests/RunCMake/Framework/FrameworkMultiConfigPostfix-build-final-check.cmake index 76fe6b8..7a1d70e 100644 --- a/Tests/RunCMake/Framework/FrameworkMultiConfigPostfix-build-final-check.cmake +++ b/Tests/RunCMake/Framework/FrameworkMultiConfigPostfix-build-final-check.cmake @@ -20,26 +20,32 @@ else() endif() if(NOT IS_DIRECTORY ${framework_dir}) - message(SEND_ERROR "Framework dir not found at ${framework_dir}") + set(RunCMake_TEST_FAILED "Framework dir not found at \n ${framework_dir}") + return() endif() if(IS_DIRECTORY ${non_existent_debug_framework_dir}) - message(SEND_ERROR - "A framework dir with a debug suffix should not exist at ${non_existent_debug_framework_dir}") + set(RunCMake_TEST_FAILED + "A framework dir with a debug suffix should not exist at \n ${non_existent_debug_framework_dir}") + return() endif() if(NOT IS_SYMLINK "${symlink_release_path}") - message(SEND_ERROR "Release framework symlink not found at ${symlink_release_path}") + set(RunCMake_TEST_FAILED "Release framework symlink not found at \n ${symlink_release_path}") + return() endif() if(NOT IS_SYMLINK "${symlink_debug_path}") - message(SEND_ERROR "Debug framework symlink not found at ${symlink_debug_path}") + set(RunCMake_TEST_FAILED "Debug framework symlink not found at \n ${symlink_debug_path}") + return() endif() if(NOT EXISTS "${framework_release_path}") - message(SEND_ERROR "Release framework not found at ${framework_release_path}") + set(RunCMake_TEST_FAILED "Release framework not found at \n ${framework_release_path}") + return() endif() if(NOT EXISTS "${framework_debug_path}") - message(SEND_ERROR "Debug framework not found at ${framework_debug_path}") + set(RunCMake_TEST_FAILED "Debug framework not found at \n ${framework_debug_path}") + return() endif() diff --git a/Tests/RunCMake/Framework/OSXFrameworkLayout-build-check.cmake b/Tests/RunCMake/Framework/OSXFrameworkLayout-build-check.cmake index eb71394..b436128 100644 --- a/Tests/RunCMake/Framework/OSXFrameworkLayout-build-check.cmake +++ b/Tests/RunCMake/Framework/OSXFrameworkLayout-build-check.cmake @@ -10,41 +10,53 @@ set(plist-file "${framework-resources}/Info.plist") set(framework-header "${framework-dir}/Headers/foo.h") if(NOT IS_DIRECTORY ${framework-dir}) - message(SEND_ERROR "Framework not found at ${framework-dir}") + set(RunCMake_TEST_FAILED "Framework not found at \n ${framework-dir}") + return() endif() if(NOT EXISTS ${plist-file}) - message(SEND_ERROR "plist file not found at ${plist-file}") + set(RunCMake_TEST_FAILED "plist file not found at \n ${plist-file}") + return() endif() if(NOT EXISTS ${framework-library}) - message(SEND_ERROR "Framework library not found at ${framework-library}") + set(RunCMake_TEST_FAILED "Framework library not found at \n ${framework-library}") + return() endif() if(NOT EXISTS ${framework-resource-file}) - message(SEND_ERROR "Framework resource file not found at ${framework-resource-file}") + set(RunCMake_TEST_FAILED "Framework resource file not found at \n ${framework-resource-file}") + return() endif() if(NOT EXISTS ${framework-flat-resource-file}) - message(SEND_ERROR "Framework flat resource file not found at ${framework-flat-resource-file}") + set(RunCMake_TEST_FAILED "Framework flat resource file not found at \n ${framework-flat-resource-file}") + return() endif() if(NOT EXISTS ${framework-deep-resource-file}) - message(SEND_ERROR "Framework deep resource file not found at ${framework-deep-resource-file}") + set(RunCMake_TEST_FAILED "Framework deep resource file not found at \n ${framework-deep-resource-file}") + return() endif() if(NOT EXISTS ${framework-some-file}) - message(SEND_ERROR "Framework some file not found at ${framework-some-file}") + set(RunCMake_TEST_FAILED "Framework some file not found at \n ${framework-some-file}") + return() endif() if(NOT EXISTS ${framework-versions}) - message(SEND_ERROR "Framework versions not found at ${framework-versions}") + set(RunCMake_TEST_FAILED "Framework versions not found at \n ${framework-versions}") + return() endif() if(NOT EXISTS ${framework-resources}) - message(SEND_ERROR "Framework Resources not found at ${framework-resources}") + set(RunCMake_TEST_FAILED "Framework Resources not found at \n ${framework-resources}") + return() endif() if(NOT EXISTS ${framework-header}) - message(SEND_ERROR "Framework header file not found at ${framework-header}") + set(RunCMake_TEST_FAILED "Framework header file not found at \n ${framework-header}") + return() endif() + +include(${CMAKE_CURRENT_LIST_DIR}/FrameworkLayout-check-common.cmake) diff --git a/Tests/RunCMake/Framework/iOSFrameworkLayout-build-check.cmake b/Tests/RunCMake/Framework/iOSFrameworkLayout-build-check.cmake index 2da60d2..be9a5fe 100644 --- a/Tests/RunCMake/Framework/iOSFrameworkLayout-build-check.cmake +++ b/Tests/RunCMake/Framework/iOSFrameworkLayout-build-check.cmake @@ -10,41 +10,53 @@ set(plist-file "${framework-dir}/Info.plist") set(framework-header "${framework-dir}/Headers/foo.h") if(NOT IS_DIRECTORY ${framework-dir}) - message(SEND_ERROR "Framework not found at ${framework-dir}") + set(RunCMake_TEST_FAILED "Framework not found at\n ${framework-dir}") + return() endif() if(NOT EXISTS ${plist-file}) - message(SEND_ERROR "plist file not found at ${plist-file}") + set(RunCMake_TEST_FAILED "plist file not found at\n ${plist-file}") + return() endif() if(NOT EXISTS ${framework-library}) - message(SEND_ERROR "Framework library not found at ${framework-library}") + set(RunCMake_TEST_FAILED "Framework library not found at\n ${framework-library}") + return() endif() if(NOT EXISTS ${framework-resource-file}) - message(SEND_ERROR "Framework resource file not found at ${framework-resource-file}") + set(RunCMake_TEST_FAILED "Framework resource file not found at\n ${framework-resource-file}") + return() endif() if(NOT EXISTS ${framework-flat-resource-file}) - message(SEND_ERROR "Framework flat resource file not found at ${framework-flat-resource-file}") + set(RunCMake_TEST_FAILED "Framework flat resource file not found at\n ${framework-flat-resource-file}") + return() endif() if(NOT EXISTS ${framework-deep-resource-file}) - message(SEND_ERROR "Framework deep resource file not found at ${framework-deep-resource-file}") + set(RunCMake_TEST_FAILED "Framework deep resource file not found at\n ${framework-deep-resource-file}") + return() endif() if(NOT EXISTS ${framework-some-file}) - message(SEND_ERROR "Framework some file not found at ${framework-some-file}") + set(RunCMake_TEST_FAILED "Framework some file not found at\n ${framework-some-file}") + return() endif() if(EXISTS ${framework-versions}) - message(SEND_ERROR "Framework versions found at ${framework-versions}") + set(RunCMake_TEST_FAILED "Framework versions found at\n ${framework-versions}") + return() endif() if(EXISTS ${framework-resources}) - message(SEND_ERROR "Framework Resources found at ${framework-resources}") + set(RunCMake_TEST_FAILED "Framework Resources found at\n ${framework-resources}") + return() endif() if(NOT EXISTS ${framework-header}) - message(SEND_ERROR "Framework headers not found at ${framework-header}") + set(RunCMake_TEST_FAILED "Framework headers not found at\n ${framework-header}") + return() endif() + +include(${CMAKE_CURRENT_LIST_DIR}/FrameworkLayout-check-common.cmake) diff --git a/Tests/RunCMake/NinjaMultiConfig/RunCMakeTest.cmake b/Tests/RunCMake/NinjaMultiConfig/RunCMakeTest.cmake index 88fd1e8..f1e8b30 100644 --- a/Tests/RunCMake/NinjaMultiConfig/RunCMakeTest.cmake +++ b/Tests/RunCMake/NinjaMultiConfig/RunCMakeTest.cmake @@ -17,7 +17,7 @@ function(check_files dir) list(SORT expected) file(GLOB_RECURSE actual "${dir}/*") - list(FILTER actual EXCLUDE REGEX "/CMakeFiles/|\\.ninja$|/CMakeCache\\.txt$|/target_files[^/]*\\.cmake$|/\\.ninja_[^/]*$|/cmake_install\\.cmake$|\\.ilk$|\\.manifest$|\\.odx$|\\.pdb$|\\.exp$|/install_manifest\\.txt$|/\\.qt/QtDeploySupport[^/]*\\.cmake$") + list(FILTER actual EXCLUDE REGEX "/CMakeFiles/|\\.ninja$|/CMakeCache\\.txt$|/target_files[^/]*\\.cmake$|/\\.ninja_[^/]*$|/cmake_install\\.cmake$|\\.ilk$|\\.manifest$|\\.odx$|\\.pdb$|\\.exp$|/install_manifest\\.txt$|/\\.qt/(QtDeploySupport|QtDeployTargets)[^/]*\\.cmake$") foreach(f IN LISTS _check_files_INCLUDE _check_files_EXCLUDE) if(EXISTS ${f}) list(APPEND actual ${f}) diff --git a/Tests/RunCMake/README.rst b/Tests/RunCMake/README.rst index ea6db54..f4bcc57 100644 --- a/Tests/RunCMake/README.rst +++ b/Tests/RunCMake/README.rst @@ -6,9 +6,11 @@ precisely checking their return code and stdout/stderr content. The RunCMake infrastructure is useful for testing error cases and diagnostic output. -See also `../README.rst`_ and the `CMake Source Code Guide`_. +See also `../README.rst`_, the `CMake Testing Guide`_, +and the `CMake Source Code Guide`_. .. _`../README.rst`: ../README.rst +.. _`CMake Testing Guide`: ../../Help/dev/testing.rst .. _`CMake Source Code Guide`: ../../Help/dev/source.rst .. _`CMakeLists.txt`: CMakeLists.txt diff --git a/Tests/RunCMake/VS10Project/RunCMakeTest.cmake b/Tests/RunCMake/VS10Project/RunCMakeTest.cmake index e0d74cf..85fefbf 100644 --- a/Tests/RunCMake/VS10Project/RunCMakeTest.cmake +++ b/Tests/RunCMake/VS10Project/RunCMakeTest.cmake @@ -98,6 +98,7 @@ run_cmake(DebugInformationFormat) run_cmake(VsCLREmpty) run_cmake(VsCLRPure) run_cmake(VsCLRSafe) +run_cmake(VsFrameworkReference) if(CMAKE_C_COMPILER_VERSION VERSION_GREATER_EQUAL 19.20) run_cmake(VsCLRNetcore) diff --git a/Tests/RunCMake/VS10Project/VsFrameworkReference-check.cmake b/Tests/RunCMake/VS10Project/VsFrameworkReference-check.cmake new file mode 100644 index 0000000..7abe8a0 --- /dev/null +++ b/Tests/RunCMake/VS10Project/VsFrameworkReference-check.cmake @@ -0,0 +1,24 @@ +set(vcProjectFile "${RunCMake_TEST_BINARY_DIR}/foo.vcxproj") +if(NOT EXISTS "${vcProjectFile}") + set(RunCMake_TEST_FAILED "Project file ${vcProjectFile} does not exist.") + return() +endif() + +set(frameworkReferenceSet FALSE) + +file(STRINGS "${vcProjectFile}" lines) +foreach(line IN LISTS lines) + if(line MATCHES "^ *<FrameworkReference Include=\"([^\"]*)\" />$") + if("${CMAKE_MATCH_1}" STREQUAL "Microsoft.WindowsDesktop.App.WPF") + message(STATUS "foo.vcxproj has FrameworkReference set") + set(frameworkReferenceSet TRUE) + else() + message(STATUS "foo.vcxproj has FrameworkReference incorrectly set to ${CMAKE_MATCH_1}") + endif() + endif() +endforeach() + +if(NOT frameworkReferenceSet) + set(RunCMake_TEST_FAILED "FrameworkReference not found or not set correctly.") + return() +endif() diff --git a/Tests/RunCMake/VS10Project/VsFrameworkReference.cmake b/Tests/RunCMake/VS10Project/VsFrameworkReference.cmake new file mode 100644 index 0000000..0e4d6fb --- /dev/null +++ b/Tests/RunCMake/VS10Project/VsFrameworkReference.cmake @@ -0,0 +1,8 @@ +enable_language(CXX) + +add_executable(foo foo.cpp) + +set_target_properties(foo PROPERTIES + COMMON_LANGUAGE_RUNTIME "netcore" + DOTNET_TARGET_FRAMEWORK "net8.0-windows" + VS_FRAMEWORK_REFERENCES "Microsoft.WindowsDesktop.App.WPF") diff --git a/Tests/RunCMake/file-MAKE_DIRECTORY/CMakeLists.txt b/Tests/RunCMake/file-MAKE_DIRECTORY/CMakeLists.txt new file mode 100644 index 0000000..93ee9df --- /dev/null +++ b/Tests/RunCMake/file-MAKE_DIRECTORY/CMakeLists.txt @@ -0,0 +1,3 @@ +cmake_minimum_required(VERSION 3.5) +project(${RunCMake_TEST} NONE) +include(${RunCMake_TEST}.cmake) diff --git a/Tests/RunCMake/file-MAKE_DIRECTORY/MAKE_DIRECTORY-Result-many-dirs-FAIL-stdout.txt b/Tests/RunCMake/file-MAKE_DIRECTORY/MAKE_DIRECTORY-Result-many-dirs-FAIL-stdout.txt new file mode 100644 index 0000000..63d46fd --- /dev/null +++ b/Tests/RunCMake/file-MAKE_DIRECTORY/MAKE_DIRECTORY-Result-many-dirs-FAIL-stdout.txt @@ -0,0 +1,3 @@ +^-- Result=Failed to create directory: [^ +]*/Tests/RunCMake/file-MAKE_DIRECTORY/MAKE_DIRECTORY-Result-many-dirs-FAIL-build/file/directory0 Error: [^ +]*$ diff --git a/Tests/RunCMake/file-MAKE_DIRECTORY/MAKE_DIRECTORY-Result-many-dirs-FAIL.cmake b/Tests/RunCMake/file-MAKE_DIRECTORY/MAKE_DIRECTORY-Result-many-dirs-FAIL.cmake new file mode 100644 index 0000000..0cfccbf --- /dev/null +++ b/Tests/RunCMake/file-MAKE_DIRECTORY/MAKE_DIRECTORY-Result-many-dirs-FAIL.cmake @@ -0,0 +1,9 @@ +file(WRITE "${CMAKE_CURRENT_BINARY_DIR}/file" "") + +file(MAKE_DIRECTORY + "${CMAKE_CURRENT_BINARY_DIR}/file/directory0" + "${CMAKE_CURRENT_BINARY_DIR}/file/directory1" + "${CMAKE_CURRENT_BINARY_DIR}/file/directory2" + RESULT resultVal +) +message(STATUS "Result=${resultVal}") diff --git a/Tests/RunCMake/file-MAKE_DIRECTORY/MAKE_DIRECTORY-Result-many-dirs-SUCCESS-stdout.txt b/Tests/RunCMake/file-MAKE_DIRECTORY/MAKE_DIRECTORY-Result-many-dirs-SUCCESS-stdout.txt new file mode 100644 index 0000000..09df4f9 --- /dev/null +++ b/Tests/RunCMake/file-MAKE_DIRECTORY/MAKE_DIRECTORY-Result-many-dirs-SUCCESS-stdout.txt @@ -0,0 +1 @@ +^-- Result=0 diff --git a/Tests/RunCMake/file-MAKE_DIRECTORY/MAKE_DIRECTORY-Result-many-dirs-SUCCESS.cmake b/Tests/RunCMake/file-MAKE_DIRECTORY/MAKE_DIRECTORY-Result-many-dirs-SUCCESS.cmake new file mode 100644 index 0000000..e0781ce --- /dev/null +++ b/Tests/RunCMake/file-MAKE_DIRECTORY/MAKE_DIRECTORY-Result-many-dirs-SUCCESS.cmake @@ -0,0 +1,7 @@ +file(MAKE_DIRECTORY + "${CMAKE_CURRENT_BINARY_DIR}/file/directory0" + "${CMAKE_CURRENT_BINARY_DIR}/file/directory1" + "${CMAKE_CURRENT_BINARY_DIR}/file/directory2" + RESULT resultVal +) +message(STATUS "Result=${resultVal}") diff --git a/Tests/RunCMake/file-MAKE_DIRECTORY/MAKE_DIRECTORY-Result-one-dir-FAIL-stdout.txt b/Tests/RunCMake/file-MAKE_DIRECTORY/MAKE_DIRECTORY-Result-one-dir-FAIL-stdout.txt new file mode 100644 index 0000000..5d16178 --- /dev/null +++ b/Tests/RunCMake/file-MAKE_DIRECTORY/MAKE_DIRECTORY-Result-one-dir-FAIL-stdout.txt @@ -0,0 +1,3 @@ +^-- Result=Failed to create directory: [^ +]*/Tests/RunCMake/file-MAKE_DIRECTORY/MAKE_DIRECTORY-Result-one-dir-FAIL-build/file/directory Error: [^ +]*$ diff --git a/Tests/RunCMake/file-MAKE_DIRECTORY/MAKE_DIRECTORY-Result-one-dir-FAIL.cmake b/Tests/RunCMake/file-MAKE_DIRECTORY/MAKE_DIRECTORY-Result-one-dir-FAIL.cmake new file mode 100644 index 0000000..0287d67 --- /dev/null +++ b/Tests/RunCMake/file-MAKE_DIRECTORY/MAKE_DIRECTORY-Result-one-dir-FAIL.cmake @@ -0,0 +1,3 @@ +file(WRITE "${CMAKE_CURRENT_BINARY_DIR}/file" "") +file(MAKE_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}/file/directory" RESULT resultVal) +message(STATUS "Result=${resultVal}") diff --git a/Tests/RunCMake/file-MAKE_DIRECTORY/MAKE_DIRECTORY-Result-one-dir-SUCCESS-stdout.txt b/Tests/RunCMake/file-MAKE_DIRECTORY/MAKE_DIRECTORY-Result-one-dir-SUCCESS-stdout.txt new file mode 100644 index 0000000..09df4f9 --- /dev/null +++ b/Tests/RunCMake/file-MAKE_DIRECTORY/MAKE_DIRECTORY-Result-one-dir-SUCCESS-stdout.txt @@ -0,0 +1 @@ +^-- Result=0 diff --git a/Tests/RunCMake/file-MAKE_DIRECTORY/MAKE_DIRECTORY-Result-one-dir-SUCCESS.cmake b/Tests/RunCMake/file-MAKE_DIRECTORY/MAKE_DIRECTORY-Result-one-dir-SUCCESS.cmake new file mode 100644 index 0000000..3005b83 --- /dev/null +++ b/Tests/RunCMake/file-MAKE_DIRECTORY/MAKE_DIRECTORY-Result-one-dir-SUCCESS.cmake @@ -0,0 +1,2 @@ +file(MAKE_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}/file/directory" RESULT resultVal) +message(STATUS "Result=${resultVal}") diff --git a/Tests/RunCMake/file-MAKE_DIRECTORY/MAKE_DIRECTORY-one-dir-FAIL-result.txt b/Tests/RunCMake/file-MAKE_DIRECTORY/MAKE_DIRECTORY-one-dir-FAIL-result.txt new file mode 100644 index 0000000..d00491f --- /dev/null +++ b/Tests/RunCMake/file-MAKE_DIRECTORY/MAKE_DIRECTORY-one-dir-FAIL-result.txt @@ -0,0 +1 @@ +1 diff --git a/Tests/RunCMake/file-MAKE_DIRECTORY/MAKE_DIRECTORY-one-dir-FAIL-stderr.txt b/Tests/RunCMake/file-MAKE_DIRECTORY/MAKE_DIRECTORY-one-dir-FAIL-stderr.txt new file mode 100644 index 0000000..2bc275c --- /dev/null +++ b/Tests/RunCMake/file-MAKE_DIRECTORY/MAKE_DIRECTORY-one-dir-FAIL-stderr.txt @@ -0,0 +1,9 @@ +^CMake Error at [^ +]*/MAKE_DIRECTORY-one-dir-FAIL.cmake:[0-9]+ \(file\): + file failed to create directory: + + [^ +]*/Tests/RunCMake/file-MAKE_DIRECTORY/MAKE_DIRECTORY-one-dir-FAIL-build/file/directory + + because: [^ +]+$ diff --git a/Tests/RunCMake/file/MAKE_DIRECTORY-fail.cmake b/Tests/RunCMake/file-MAKE_DIRECTORY/MAKE_DIRECTORY-one-dir-FAIL.cmake index 57a68e5..57a68e5 100644 --- a/Tests/RunCMake/file/MAKE_DIRECTORY-fail.cmake +++ b/Tests/RunCMake/file-MAKE_DIRECTORY/MAKE_DIRECTORY-one-dir-FAIL.cmake diff --git a/Tests/RunCMake/file-MAKE_DIRECTORY/RunCMakeTest.cmake b/Tests/RunCMake/file-MAKE_DIRECTORY/RunCMakeTest.cmake new file mode 100644 index 0000000..1eacd90 --- /dev/null +++ b/Tests/RunCMake/file-MAKE_DIRECTORY/RunCMakeTest.cmake @@ -0,0 +1,7 @@ +include(RunCMake) + +run_cmake_script(MAKE_DIRECTORY-one-dir-FAIL) +run_cmake_script(MAKE_DIRECTORY-Result-one-dir-FAIL) +run_cmake_script(MAKE_DIRECTORY-Result-one-dir-SUCCESS) +run_cmake_script(MAKE_DIRECTORY-Result-many-dirs-FAIL) +run_cmake_script(MAKE_DIRECTORY-Result-many-dirs-SUCCESS) diff --git a/Tests/RunCMake/file-RPATH/Common.cmake b/Tests/RunCMake/file-RPATH/Common.cmake index 7034aad..d6d3eeb 100644 --- a/Tests/RunCMake/file-RPATH/Common.cmake +++ b/Tests/RunCMake/file-RPATH/Common.cmake @@ -1,12 +1,16 @@ # Prepare binaries on which to operate. set(in "${CMAKE_CURRENT_LIST_DIR}/${format}") set(out "${CMAKE_CURRENT_BINARY_DIR}") -foreach(f ${names}) +foreach(f ${dynamic}) file(COPY ${in}/${f} DESTINATION ${out} NO_SOURCE_PERMISSIONS) - list(APPEND files "${out}/${f}") + list(APPEND dynamic_files "${out}/${f}") +endforeach() +foreach(f ${static}) + file(COPY ${in}/${f} DESTINATION ${out} NO_SOURCE_PERMISSIONS) + list(APPEND static_files "${out}/${f}") endforeach() -foreach(f ${files}) +foreach(f ${dynamic_files}) # Check for the initial RPATH. file(RPATH_CHECK FILE "${f}" RPATH "/sample/rpath") if(NOT EXISTS "${f}") @@ -65,11 +69,11 @@ endforeach() # TODO Implement RPATH_SET in XCOFF. if(format STREQUAL "ELF") - foreach(f ${names}) + foreach(f ${dynamic}) file(COPY ${in}/${f} DESTINATION ${out} NO_SOURCE_PERMISSIONS) endforeach() - foreach(f ${files}) + foreach(f ${dynamic_files}) # Set the RPATH. file(RPATH_SET FILE "${f}" NEW_RPATH "/new/rpath") @@ -99,3 +103,8 @@ if(format STREQUAL "ELF") endif() endforeach() endif() + +# Verify that modifying rpaths on a static library is a no-op +foreach(f ${static_files}) + file(RPATH_CHANGE FILE "${f}" OLD_RPATH "/rpath/foo" NEW_RPATH "/rpath/bar") +endforeach() diff --git a/Tests/RunCMake/file-RPATH/ELF.cmake b/Tests/RunCMake/file-RPATH/ELF.cmake index 558b2e2..b8919ef 100644 --- a/Tests/RunCMake/file-RPATH/ELF.cmake +++ b/Tests/RunCMake/file-RPATH/ELF.cmake @@ -1,9 +1,12 @@ -set(names +set(dynamic elf32lsb.bin elf32msb.bin elf64lsb.bin elf64msb.bin ) +set(static + elf64lsb-static.bin + ) set(format ELF) include(${CMAKE_CURRENT_LIST_DIR}/Common.cmake) diff --git a/Tests/RunCMake/file-RPATH/ELF/elf64lsb-static.bin b/Tests/RunCMake/file-RPATH/ELF/elf64lsb-static.bin Binary files differnew file mode 100755 index 0000000..b48c4f3 --- /dev/null +++ b/Tests/RunCMake/file-RPATH/ELF/elf64lsb-static.bin diff --git a/Tests/RunCMake/file-RPATH/XCOFF.cmake b/Tests/RunCMake/file-RPATH/XCOFF.cmake index b570920..f7464c2 100644 --- a/Tests/RunCMake/file-RPATH/XCOFF.cmake +++ b/Tests/RunCMake/file-RPATH/XCOFF.cmake @@ -1,4 +1,4 @@ -set(names +set(dynamic xcoff32.bin xcoff64.bin ) diff --git a/Tests/RunCMake/file/MAKE_DIRECTORY-fail-stderr.txt b/Tests/RunCMake/file/MAKE_DIRECTORY-fail-stderr.txt deleted file mode 100644 index 95fccdf..0000000 --- a/Tests/RunCMake/file/MAKE_DIRECTORY-fail-stderr.txt +++ /dev/null @@ -1,9 +0,0 @@ -^CMake Error at [^ -]*/MAKE_DIRECTORY-fail.cmake:[0-9]+ \(file\): - file failed to create directory: - - [^ -]*/Tests/RunCMake/file/MAKE_DIRECTORY-fail-build/file/directory - - because: [^ -]+$ diff --git a/Tests/RunCMake/file/RunCMakeTest.cmake b/Tests/RunCMake/file/RunCMakeTest.cmake index be8ee7c..524636d 100644 --- a/Tests/RunCMake/file/RunCMakeTest.cmake +++ b/Tests/RunCMake/file/RunCMakeTest.cmake @@ -62,8 +62,6 @@ run_cmake_script(COPY_FILE-arg-unknown) run_cmake_script(COPY_FILE-input-missing) run_cmake_script(COPY_FILE-output-missing) -run_cmake_script(MAKE_DIRECTORY-fail) - run_cmake_script(RENAME-file-replace) run_cmake_script(RENAME-file-to-file) run_cmake_script(RENAME-file-to-dir-capture) diff --git a/Tests/VSMARMASM/CMakeLists.txt b/Tests/VSMARMASM/CMakeLists.txt index 85740de..7498461 100644 --- a/Tests/VSMARMASM/CMakeLists.txt +++ b/Tests/VSMARMASM/CMakeLists.txt @@ -4,3 +4,4 @@ add_executable(VSMARMASM main.c foo.asm) target_compile_options(VSMARMASM PRIVATE "$<$<COMPILE_LANGUAGE:ASM_MARMASM>:SHELL:-predefine \"zero SETA 0\">" ) +add_library(empty STATIC empty.asm) diff --git a/Tests/VSMARMASM/empty.asm b/Tests/VSMARMASM/empty.asm new file mode 100644 index 0000000..a6a9baf --- /dev/null +++ b/Tests/VSMARMASM/empty.asm @@ -0,0 +1 @@ +end diff --git a/Tests/VSMASM/CMakeLists.txt b/Tests/VSMASM/CMakeLists.txt index 49bd24a..bf9a4b8 100644 --- a/Tests/VSMASM/CMakeLists.txt +++ b/Tests/VSMASM/CMakeLists.txt @@ -10,3 +10,4 @@ include_directories(${CMAKE_CURRENT_SOURCE_DIR}/include) add_executable(VSMASM main.c foo.asm) target_compile_definitions(VSMASM PUBLIC DEF_FOO) target_compile_options(VSMASM PUBLIC -DDEF_BAR) +add_library(empty STATIC empty.asm) diff --git a/Tests/VSMASM/empty.asm b/Tests/VSMASM/empty.asm new file mode 100644 index 0000000..a6a9baf --- /dev/null +++ b/Tests/VSMASM/empty.asm @@ -0,0 +1 @@ +end diff --git a/Utilities/Doxygen/CMakeLists.txt b/Utilities/Doxygen/CMakeLists.txt index 8bf591b..111bd6f 100644 --- a/Utilities/Doxygen/CMakeLists.txt +++ b/Utilities/Doxygen/CMakeLists.txt @@ -3,7 +3,7 @@ if(NOT CMake_SOURCE_DIR) set(CMakeDeveloperReference_STANDALONE 1) - cmake_minimum_required(VERSION 3.13...3.28 FATAL_ERROR) + cmake_minimum_required(VERSION 3.13...3.29 FATAL_ERROR) get_filename_component(tmp "${CMAKE_CURRENT_SOURCE_DIR}" PATH) get_filename_component(CMake_SOURCE_DIR "${tmp}" PATH) include(${CMake_SOURCE_DIR}/Modules/CTestUseLaunchers.cmake) diff --git a/Utilities/Sphinx/CMakeLists.txt b/Utilities/Sphinx/CMakeLists.txt index 746c872..ed7b631 100644 --- a/Utilities/Sphinx/CMakeLists.txt +++ b/Utilities/Sphinx/CMakeLists.txt @@ -3,7 +3,7 @@ if(NOT CMake_SOURCE_DIR) set(CMakeHelp_STANDALONE 1) - cmake_minimum_required(VERSION 3.13...3.28 FATAL_ERROR) + cmake_minimum_required(VERSION 3.13...3.29 FATAL_ERROR) get_filename_component(tmp "${CMAKE_CURRENT_SOURCE_DIR}" PATH) get_filename_component(CMake_SOURCE_DIR "${tmp}" PATH) include(${CMake_SOURCE_DIR}/Modules/CTestUseLaunchers.cmake) |