diff options
125 files changed, 1833 insertions, 213 deletions
diff --git a/Help/generator/Visual Studio 10 2010.rst b/Help/generator/Visual Studio 10 2010.rst index ee44514..888164f 100644 --- a/Help/generator/Visual Studio 10 2010.rst +++ b/Help/generator/Visual Studio 10 2010.rst @@ -3,6 +3,6 @@ Visual Studio 10 2010 Removed. This once generated Visual Studio 10 2010 project files, but the generator has been removed since CMake 3.25. It is still possible -to build with VS 10 2010 tools using the :generator:`Visual Studio 11 2012` +to build with VS 10 2010 tools using the :generator:`Visual Studio 12 2013` (or above) generator with :variable:`CMAKE_GENERATOR_TOOLSET` set to ``v100``, or by using the :generator:`NMake Makefiles` generator. diff --git a/Help/generator/Visual Studio 11 2012.rst b/Help/generator/Visual Studio 11 2012.rst index adbd1af..4e7195c 100644 --- a/Help/generator/Visual Studio 11 2012.rst +++ b/Help/generator/Visual Studio 11 2012.rst @@ -1,7 +1,14 @@ Visual Studio 11 2012 --------------------- -Generates Visual Studio 11 (VS 2012) project files. +Deprecated. Generates Visual Studio 11 (VS 2012) project files. + +.. note:: + This generator is deprecated and will be removed in a future version + of CMake. It will still be possible to build with VS 11 2012 tools + using the :generator:`Visual Studio 12 2013` (or above) generator + with :variable:`CMAKE_GENERATOR_TOOLSET` set to ``v110``, or by + using the :generator:`NMake Makefiles` generator. For compatibility with CMake versions prior to 3.0, one may specify this generator using the name "Visual Studio 11" without the year component. diff --git a/Help/guide/tutorial/Adding Generator Expressions.rst b/Help/guide/tutorial/Adding Generator Expressions.rst index 0efce8d..ba728bd 100644 --- a/Help/guide/tutorial/Adding Generator Expressions.rst +++ b/Help/guide/tutorial/Adding Generator Expressions.rst @@ -27,58 +27,279 @@ expressions are the ``0`` and ``1`` expressions. A ``$<0:...>`` results in the empty string, and ``<1:...>`` results in the content of ``...``. They can also be nested. -A common usage of -:manual:`generator expressions <cmake-generator-expressions(7)>` is to -conditionally add compiler flags, such as those for language levels or -warnings. A nice pattern is to associate this information to an ``INTERFACE`` -target allowing this information to propagate. Let's start by constructing an -``INTERFACE`` target and specifying the required C++ standard level of ``11`` -instead of using :variable:`CMAKE_CXX_STANDARD`. +Exercise 1 - Setting the C++ Standard with Interface Libraries +^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +Before we use :manual:`generator expressions <cmake-generator-expressions(7)>` +let's refactor our existing code to use an ``INTERFACE`` library. We will +use that library in the next step to demonstrate a common use for +:manual:`generator expressions <cmake-generator-expressions(7)>`. + +Goal +---- + +Add an ``INTERFACE`` library target to specify the required C++ standard. + +Helpful Resources +----------------- + +* :command:`add_library` +* :command:`target_compile_features` +* :command:`target_link_libraries` + +Files to Edit +------------- + +* ``CMakeLists.txt`` +* ``MathFunctions/CMakeLists.txt`` + +Getting Started +--------------- + +In this exercise, we will refactor our code to use an ``INTERFACE`` library to +specify the C++ standard. + +The starting source code is provided in the ``Step4`` directory. In this +exercise, complete ``TODO 1`` through ``TODO 3``. + +Start by editing the top level ``CMakeLists.txt`` file. Construct an +``INTERFACE`` library target called ``tutorial_compiler_flags`` and +specify ``cxx_std_11`` as a target compiler feature. + +Modify ``CMakeLists.txt`` and ``MathFunctions/CMakeLists.txt`` so that all +targets have a :command:`target_link_libraries` call to +``tutorial_compiler_flags``. + +Build and Run +------------- + +Make a new directory called ``Step4_build``, run the :manual:`cmake <cmake(1)>` +executable or the :manual:`cmake-gui <cmake-gui(1)>` to configure the project +and then build it with your chosen build tool or by using ``cmake --build .`` +from the build directory. + +Here's a refresher of what that looks like from the command line: + +.. code-block:: console + + mkdir Step4_build + cd Step4_build + cmake ../Step4 + cmake --build . + +Next, use the newly built ``Tutorial`` and verify that it is working as +expected. + +Solution +-------- + +Let's update our code from the previous step to use interface libraries +to set our C++ requirements. -So the following code: +To start, we need to remove the two :command:`set` calls on the variables +:variable:`CMAKE_CXX_STANDARD` and :variable:`CMAKE_CXX_STANDARD_REQUIRED`. +The specific lines to remove are as follows: .. literalinclude:: Step4/CMakeLists.txt :caption: CMakeLists.txt :name: CMakeLists.txt-CXX_STANDARD-variable-remove :language: cmake - :start-after: project(Tutorial VERSION 1.0) - :end-before: # should we use our own math functions + :start-after: # specify the C++ standard + :end-before: # TODO 5: Create helper variables + +Next, we need to create an interface library, ``tutorial_compiler_flags``. And +then use :command:`target_compile_features` to add the compiler feature +``cxx_std_11``. + -Would be replaced with: +.. raw:: html + + <details><summary>TODO 1: Click to show/hide answer</summary> .. literalinclude:: Step5/CMakeLists.txt - :caption: CMakeLists.txt + :caption: TODO 1: CMakeLists.txt :name: CMakeLists.txt-cxx_std-feature :language: cmake - :start-after: project(Tutorial VERSION 1.0) - :end-before: # add compiler warning flags just when building this project via + :start-after: # specify the C++ standard + :end-before: # add compiler warning flags just + +.. raw:: html + + </details> + +Finally, with our interface library set up, we need to link our +executable ``Target`` and our ``MathFunctions`` library to our new +``tutorial_compiler_flags`` library. Respectively, the code will look like +this: + +.. raw:: html + + <details><summary>TODO 2: Click to show/hide answer</summary> + +.. literalinclude:: Step5/CMakeLists.txt + :caption: TODO 2: CMakeLists.txt + :name: CMakeLists.txt-target_link_libraries-step4 + :language: cmake + :start-after: add_executable(Tutorial tutorial.cxx) + :end-before: # add the binary tree to the search path for include file + +.. raw:: html + + </details> + +and this: + +.. raw:: html + + <details><summary>TODO 3: Click to show/hide answer</summary> + +.. literalinclude:: Step5/MathFunctions/CMakeLists.txt + :caption: TODO 3: MathFunctions/CMakeLists.txt + :name: MathFunctions-CMakeLists.txt-target_link_libraries-step4 + :language: cmake + :start-after: # link our compiler flags interface library + +.. raw:: html + + </details> + +With this, all of our code still requires C++ 11 to build. Notice +though that with this method, it gives us the ability to be specific about +which targets get specific requirements. In addition, we create a single +source of truth in our interface library. + +Exercise 2 - Adding Compiler Warning Flags with Generator Expressions +^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +A common usage of +:manual:`generator expressions <cmake-generator-expressions(7)>` is to +conditionally add compiler flags, such as those for language levels or +warnings. A nice pattern is to associate this information to an ``INTERFACE`` +target allowing this information to propagate. + +Goal +---- + +Add compiler warning flags when building but not for installed versions. + +Helpful Resources +----------------- + +* :manual:`cmake-generator-expressions(7)` +* :command:`cmake_minimum_required` +* :command:`set` +* :command:`target_compile_options` + +Files to Edit +------------- + +* ``CMakeLists.txt`` + +Getting Started +--------------- + +Start with the resulting files from Exercise 1. Complete ``TODO 4`` through +``TODO 7``. + +First, in the top level ``CMakeLists.txt`` file, we need to set the +:command:`cmake_minimum_required` to ``3.15``. In this exercise we are going +to use a generator expression which was introduced in CMake 3.15. + +Next we add the desired compiler warning flags that we want for our project. +As warning flags vary based on the compiler, we use the +``COMPILE_LANG_AND_ID`` generator expression to control which flags to apply +given a language and a set of compiler ids. + +Build and Run +------------- + +Since we have our build directory already configured from Exercise 1, simply +rebuild our code by calling the following: + +.. code-block:: console + + cd Step4_build + cmake --build . + +Solution +-------- + +Update the :command:`cmake_minimum_required` to require at least CMake +version ``3.15``: + +.. raw:: html + + <details><summary>TODO 4: Click to show/hide answer</summary> + +.. literalinclude:: Step5/CMakeLists.txt + :caption: TODO 4: CMakeLists.txt + :name: MathFunctions-CMakeLists.txt-minimum-required-step4 + :language: cmake + :end-before: # set the project name and version + +.. raw:: html + + </details> + +Next we determine which compiler our system is currently using to build +since warning flags vary based on the compiler we use. This is done with +the ``COMPILE_LANG_AND_ID`` generator expression. We set the result in the +variables ``gcc_like_cxx`` and ``msvc_cxx`` as follows: + +.. raw:: html + + <details><summary>TODO 5: Click to show/hide answer</summary> + +.. literalinclude:: Step5/CMakeLists.txt + :caption: TODO 5: CMakeLists.txt + :name: CMakeLists.txt-compile_lang_and_id + :language: cmake + :start-after: # the BUILD_INTERFACE genex + :end-before: target_compile_options(tutorial_compiler_flags INTERFACE -**Note**: This upcoming section will require a change to the -:command:`cmake_minimum_required` usage in the code. The Generator Expression -that is about to be used was introduced in `3.15`. Update the call to require -that more recent version: +.. raw:: html + + </details> + +Next we add the desired compiler warning flags that we want for our project. +Using our variables ``gcc_like_cxx`` and ``msvc_cxx``, we can use another +generator expression to apply the respective flags only when the variables are +true. We use :command:`target_compile_options` to apply these flags to our +interface library. + +.. raw:: html + + <details><summary>TODO 6: Click to show/hide answer</summary> .. code-block:: cmake - :caption: CMakeLists.txt - :name: CMakeLists.txt-version-update + :caption: TODO 6: CMakeLists.txt + :name: CMakeLists.txt-compile_flags + + target_compile_options(tutorial_compiler_flags INTERFACE + "$<${gcc_like_cxx}:-Wall;-Wextra;-Wshadow;-Wformat=2;-Wunused>" + "$<${msvc_cxx}:-W3>" + ) - cmake_minimum_required(VERSION 3.15) +.. raw:: html -Next we add the desired compiler warning flags that we want for our project. As -warning flags vary based on the compiler we use the ``COMPILE_LANG_AND_ID`` -generator expression to control which flags to apply given a language and a set -of compiler ids as seen below: + </details> + +Lastly, we only want these warning flags to be used during builds. Consumers +of our installed project should not inherit our warning flags. To specify +this, we wrap our flags in a generator expression using the ``BUILD_INTERFACE`` +condition. The resulting full code looks like the following: + +.. raw:: html + + <details><summary>TODO 7: Click to show/hide answer</summary> .. literalinclude:: Step5/CMakeLists.txt - :caption: CMakeLists.txt + :caption: TODO 7: CMakeLists.txt :name: CMakeLists.txt-target_compile_options-genex :language: cmake - :start-after: # the BUILD_INTERFACE genex + :start-after: set(msvc_cxx "$<COMPILE_LANG_AND_ID:CXX,MSVC>") :end-before: # should we use our own math functions -Looking at this we see that the warning flags are encapsulated inside a -``BUILD_INTERFACE`` condition. This is done so that consumers of our installed -project will not inherit our warning flags. +.. raw:: html -**Exercise**: Modify ``MathFunctions/CMakeLists.txt`` so that all targets have -a :command:`target_link_libraries` call to ``tutorial_compiler_flags``. + </details> diff --git a/Help/guide/tutorial/Adding Usage Requirements for a Library.rst b/Help/guide/tutorial/Adding Usage Requirements for a Library.rst index 9d3bf64..f9dc7cc 100644 --- a/Help/guide/tutorial/Adding Usage Requirements for a Library.rst +++ b/Help/guide/tutorial/Adding Usage Requirements for a Library.rst @@ -100,6 +100,7 @@ follows: :name: MathFunctions/CMakeLists.txt-target_include_directories-INTERFACE :language: cmake :start-after: # to find MathFunctions.h + :end-before: # TODO 3: Link to .. raw:: html diff --git a/Help/guide/tutorial/Step10/MathFunctions/CMakeLists.txt b/Help/guide/tutorial/Step10/MathFunctions/CMakeLists.txt index 746f966..d7f30d6 100644 --- a/Help/guide/tutorial/Step10/MathFunctions/CMakeLists.txt +++ b/Help/guide/tutorial/Step10/MathFunctions/CMakeLists.txt @@ -22,6 +22,7 @@ target_include_directories(MathFunctions PRIVATE ${CMAKE_CURRENT_BINARY_DIR} ) +# link our compiler flags interface library target_link_libraries(MathFunctions tutorial_compiler_flags) # install rules diff --git a/Help/guide/tutorial/Step4/CMakeLists.txt b/Help/guide/tutorial/Step4/CMakeLists.txt index 38e9b1f..fa4aab2 100644 --- a/Help/guide/tutorial/Step4/CMakeLists.txt +++ b/Help/guide/tutorial/Step4/CMakeLists.txt @@ -1,12 +1,36 @@ +# TODO 4: Update the minimum required version to 3.15 + cmake_minimum_required(VERSION 3.10) # set the project name and version project(Tutorial VERSION 1.0) +# TODO 1: Replace the following code by: +# * Creating an interface library called tutorial_compiler_flags +# Hint: use add_library() with the INTERFACE signature +# * Add compiler feature cxx_std_11 to tutorial_compiler_flags +# Hint: Use target_compile_features() + # specify the C++ standard set(CMAKE_CXX_STANDARD 11) set(CMAKE_CXX_STANDARD_REQUIRED True) +# TODO 5: Create helper variables to determine which compiler we are using: +# * Create a new variable gcc_like_cxx that is true if we are using CXX and +# any of the following compilers: ARMClang, AppleClang, Clang, GNU, LCC +# * Create a new variable msvc_cxx that is true if we are using CXX and MSVC +# Hint: Use set() and COMPILE_LANG_AND_ID + +# TODO 6: Add warning flag compile options to the interface library +# tutorial_compiler_flags. +# * For gcc_like_cxx, add flags -Wall;-Wextra;-Wshadow;-Wformat=2;-Wunused +# * For msvc_cxx, add flags -W3 +# Hint: Use target_compile_options() + +# TODO 7: With nested generator expressions, only use the flags for the +# build-tree +# Hint: Use BUILD_INTERFACE + # should we use our own math functions option(USE_MYMATH "Use tutorial provided math implementation" ON) @@ -23,6 +47,8 @@ endif() # add the executable add_executable(Tutorial tutorial.cxx) +# TODO 2: Link to tutorial_compiler_flags + target_link_libraries(Tutorial PUBLIC ${EXTRA_LIBS}) # add the binary tree to the search path for include files diff --git a/Help/guide/tutorial/Step4/MathFunctions/CMakeLists.txt b/Help/guide/tutorial/Step4/MathFunctions/CMakeLists.txt index 0515852..5f7369c 100644 --- a/Help/guide/tutorial/Step4/MathFunctions/CMakeLists.txt +++ b/Help/guide/tutorial/Step4/MathFunctions/CMakeLists.txt @@ -5,3 +5,5 @@ add_library(MathFunctions mysqrt.cxx) target_include_directories(MathFunctions INTERFACE ${CMAKE_CURRENT_SOURCE_DIR} ) + +# TODO 3: Link to tutorial_compiler_flags diff --git a/Help/guide/tutorial/Step5/MathFunctions/CMakeLists.txt b/Help/guide/tutorial/Step5/MathFunctions/CMakeLists.txt index e02f211..fc932af 100644 --- a/Help/guide/tutorial/Step5/MathFunctions/CMakeLists.txt +++ b/Help/guide/tutorial/Step5/MathFunctions/CMakeLists.txt @@ -6,4 +6,5 @@ target_include_directories(MathFunctions INTERFACE ${CMAKE_CURRENT_SOURCE_DIR} ) +# link our compiler flags interface library target_link_libraries(MathFunctions tutorial_compiler_flags) diff --git a/Help/guide/tutorial/Step6/MathFunctions/CMakeLists.txt b/Help/guide/tutorial/Step6/MathFunctions/CMakeLists.txt index 226099a..e7667ab 100644 --- a/Help/guide/tutorial/Step6/MathFunctions/CMakeLists.txt +++ b/Help/guide/tutorial/Step6/MathFunctions/CMakeLists.txt @@ -6,6 +6,7 @@ target_include_directories(MathFunctions INTERFACE ${CMAKE_CURRENT_SOURCE_DIR} ) +# link our compiler flags interface library target_link_libraries(MathFunctions tutorial_compiler_flags) # install rules diff --git a/Help/guide/tutorial/Step7/MathFunctions/CMakeLists.txt b/Help/guide/tutorial/Step7/MathFunctions/CMakeLists.txt index 226099a..e7667ab 100644 --- a/Help/guide/tutorial/Step7/MathFunctions/CMakeLists.txt +++ b/Help/guide/tutorial/Step7/MathFunctions/CMakeLists.txt @@ -6,6 +6,7 @@ target_include_directories(MathFunctions INTERFACE ${CMAKE_CURRENT_SOURCE_DIR} ) +# link our compiler flags interface library target_link_libraries(MathFunctions tutorial_compiler_flags) # install rules diff --git a/Help/guide/tutorial/Step8/MathFunctions/CMakeLists.txt b/Help/guide/tutorial/Step8/MathFunctions/CMakeLists.txt index a832003..4a19684 100644 --- a/Help/guide/tutorial/Step8/MathFunctions/CMakeLists.txt +++ b/Help/guide/tutorial/Step8/MathFunctions/CMakeLists.txt @@ -6,6 +6,7 @@ target_include_directories(MathFunctions INTERFACE ${CMAKE_CURRENT_SOURCE_DIR} ) +# link our compiler flags interface library target_link_libraries(MathFunctions tutorial_compiler_flags) # does this system provide the log and exp functions? diff --git a/Help/guide/tutorial/Step9/MathFunctions/CMakeLists.txt b/Help/guide/tutorial/Step9/MathFunctions/CMakeLists.txt index 8a08157..6a1a108 100644 --- a/Help/guide/tutorial/Step9/MathFunctions/CMakeLists.txt +++ b/Help/guide/tutorial/Step9/MathFunctions/CMakeLists.txt @@ -24,6 +24,7 @@ target_include_directories(MathFunctions PRIVATE ${CMAKE_CURRENT_BINARY_DIR} ) +# link our compiler flags interface library target_link_libraries(MathFunctions tutorial_compiler_flags) # install rules diff --git a/Help/manual/cmake-presets.7.rst b/Help/manual/cmake-presets.7.rst index d5319f2..93f929e 100644 --- a/Help/manual/cmake-presets.7.rst +++ b/Help/manual/cmake-presets.7.rst @@ -106,6 +106,10 @@ The root object recognizes the following fields: An optional array of `Package Preset`_ objects. This is allowed in preset files specifying version ``6`` or above. +``workflowPresets`` + An optional array of `Workflow Preset`_ objects. + This is allowed in preset files specifying version ``6`` or above. + Includes ^^^^^^^^ @@ -137,8 +141,8 @@ that may contain the following fields: This identifier is used in the :ref:`cmake --preset <CMake Options>` option. There must not be two configure presets in the union of ``CMakePresets.json`` and ``CMakeUserPresets.json`` in the same directory with the same name. - However, a configure preset may have the same name as a build, test, or - package preset. + However, a configure preset may have the same name as a build, test, + package, or workflow preset. ``hidden`` An optional boolean specifying whether or not a preset should be hidden. @@ -364,8 +368,8 @@ that may contain the following fields: :ref:`cmake --build --preset <Build Tool Mode>` option. There must not be two build presets in the union of ``CMakePresets.json`` and ``CMakeUserPresets.json`` in the same directory with the same name. - However, a build preset may have the same name as a configure, test, or - package preset. + However, a build preset may have the same name as a configure, test, + package, or workflow preset. ``hidden`` An optional boolean specifying whether or not a preset should be hidden. @@ -525,8 +529,8 @@ that may contain the following fields: This identifier is used in the :option:`ctest --preset` option. There must not be two test presets in the union of ``CMakePresets.json`` and ``CMakeUserPresets.json`` in the same directory with the same name. - However, a test preset may have the same name as a configure, build, or - package preset. + However, a test preset may have the same name as a configure, build, + package, or workflow preset. ``hidden`` An optional boolean specifying whether or not a preset should be hidden. @@ -861,8 +865,8 @@ fields: This identifier is used in the :option:`cpack --preset` option. There must not be two package presets in the union of ``CMakePresets.json`` and ``CMakeUserPresets.json`` in the same directory with the same name. - However, a package preset may have the same name as a configure, build, or - test preset. + However, a package preset may have the same name as a configure, build, + test, or workflow preset. ``hidden`` An optional boolean specifying whether or not a preset should be hidden. @@ -977,6 +981,42 @@ fields: ``vendorName`` An optional string representing the vendor name. +Workflow Preset +^^^^^^^^^^^^^^^ + +Workflow presets may be used in schema version ``6`` or above. Each entry of +the ``workflowPresets`` array is a JSON object that may contain the following +fields: + +``name`` + A required string representing the machine-friendly name of the preset. + This identifier is used in the + :ref:`cmake --workflow --preset <Workflow Mode>` option. There must not be + two workflow presets in the union of ``CMakePresets.json`` and + ``CMakeUserPresets.json`` in the same directory with the same name. However, + a workflow preset may have the same name as a configure, build, test, or + package preset. + +``displayName`` + An optional string with a human-friendly name of the preset. + +``description`` + An optional string with a human-friendly description of the preset. + +``steps`` + A required array of objects describing the steps of the workflow. The first + step must be a configure preset, and all subsequent steps must be non- + configure presets whose ``configurePreset`` field matches the starting + configure preset. Each object may contain the following fields: + + ``type`` + A required string. The first step must be ``configure``. Subsequent steps + must be either ``build``, ``test``, or ``package``. + + ``name`` + A required string representing the name of the configure, build, test, or + package preset to run as this workflow step. + Condition ^^^^^^^^^ diff --git a/Help/manual/cmake.1.rst b/Help/manual/cmake.1.rst index 98655e5..c05f3c8 100644 --- a/Help/manual/cmake.1.rst +++ b/Help/manual/cmake.1.rst @@ -30,6 +30,9 @@ Synopsis `Run the Find-Package Tool`_ cmake --find-package [<options>] + `Run a Workflow Preset`_ + cmake --workflow [<options>] + `View Help`_ cmake --help[-<topic>] @@ -1177,6 +1180,25 @@ autoconf-based projects (via ``share/aclocal/cmake.m4``). This mode is not well-supported due to some technical limitations. It is kept for compatibility but should not be used in new projects. +.. _`Workflow Mode`: + +Run a Workflow Preset +===================== + +:manual:`CMake Presets <cmake-presets(7)>` provides a way to execute multiple +build steps in order: + +.. option:: --preset <preset>, --preset=<preset> + + Use a workflow preset to specify a workflow. The project binary directory + is inferred from the initial configure preset. The current working directory + must contain CMake preset files. + See :manual:`preset <cmake-presets(7)>` for more details. + +.. option:: --list-presets + + Lists the available workflow presets. The current working directory must + contain CMake preset files. View Help ========= diff --git a/Help/manual/presets/example.json b/Help/manual/presets/example.json index 06a1112..696ab47 100644 --- a/Help/manual/presets/example.json +++ b/Help/manual/presets/example.json @@ -75,6 +75,29 @@ ] } ], + "workflowPresets": [ + { + "name": "default", + "steps": [ + { + "type": "configure", + "name": "default" + }, + { + "type": "build", + "name": "default" + }, + { + "type": "test", + "name": "default" + }, + { + "type": "package", + "name": "default" + } + ] + } + ], "vendor": { "example.com/ExampleIDE/1.0": { "autoFormat": false diff --git a/Help/manual/presets/schema.json b/Help/manual/presets/schema.json index f3a7532..b4db700 100644 --- a/Help/manual/presets/schema.json +++ b/Help/manual/presets/schema.json @@ -85,6 +85,7 @@ "buildPresets": { "$ref": "#/definitions/buildPresetsV4"}, "testPresets": { "$ref": "#/definitions/testPresetsV5"}, "packagePresets": { "$ref": "#/definitions/packagePresetsV6"}, + "workflowPresets": { "$ref": "#/definitions/workflowPresetsV6" }, "include": { "$ref": "#/definitions/include"} }, "additionalProperties": false @@ -492,7 +493,7 @@ "properties": { "name": { "type": "string", - "description": "A required string representing the machine-friendly name of the preset. This identifier is used in the --preset argument. There must not be two presets (configure, build, test, or package) in the union of CMakePresets.json and CMakeUserPresets.json in the same directory with the same name.", + "description": "A required string representing the machine-friendly name of the preset. This identifier is used in the --preset argument. There must not be two presets (configure, build, test, package, or workflow) in the union of CMakePresets.json and CMakeUserPresets.json in the same directory with the same name.", "minLength": 1 }, "hidden": { @@ -744,7 +745,7 @@ "properties": { "name": { "type": "string", - "description": "A required string representing the machine-friendly name of the preset. This identifier is used in the --preset argument. There must not be two presets (configure, build, test, or package) in the union of CMakePresets.json and CMakeUserPresets.json in the same directory with the same name.", + "description": "A required string representing the machine-friendly name of the preset. This identifier is used in the --preset argument. There must not be two presets (configure, build, test, package, or workflow) in the union of CMakePresets.json and CMakeUserPresets.json in the same directory with the same name.", "minLength": 1 }, "hidden": { @@ -1153,7 +1154,7 @@ "properties": { "name": { "type": "string", - "description": "A required string representing the machine-friendly name of the preset. This identifier is used in the --preset argument. There must not be two presets (configure, build, test, or package) in the union of CMakePresets.json and CMakeUserPresets.json in the same directory with the same name.", + "description": "A required string representing the machine-friendly name of the preset. This identifier is used in the --preset argument. There must not be two presets (configure, build, test, package, or workflow) in the union of CMakePresets.json and CMakeUserPresets.json in the same directory with the same name.", "minLength": 1 }, "hidden": { @@ -1321,6 +1322,84 @@ "additionalProperties": false } }, + "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.", + "items": { + "type": "object", + "properties": { + "name": { + "type": "string", + "description": "A required string representing the machine-friendly name of the preset. This identifier is used in the --preset argument. There must not be two presets (configure, build, test, package, or workflow) in the union of CMakePresets.json and CMakeUserPresets.json in the same directory with the same name.", + "minLength": 1 + }, + "vendor": { + "type": "object", + "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, it should follow the same conventions as the root-level vendor field.", + "properties": {} + }, + "displayName": { + "type": "string", + "description": "An optional string with a human-friendly name of the preset." + }, + "description": { + "type": "string", + "description": "An optional string with a human-friendly description of the preset." + }, + "steps": { + "type": "array", + "description": "A required array of objects describing the steps of the workflow. The first step must be a configure preset, and all subsequent steps must be non-configure presets whose configurePreset field matches the starting configure preset.", + "items": { + "type": "object", + "properties": { + "type": { + "type": "string", + "description": "A required string. The first step must be configure. Subsequent steps must be either build, test, or package.", + "enum": ["configure", "build", "test", "package"] + }, + "name": { + "type": "string", + "description": "A required string representing the name of the configure, build, test, or package preset to run as this workflow step.", + "minLength": 1 + } + }, + "required": [ + "type", + "name" + ], + "additionalProperties": false + } + } + }, + "required": [ + "name", + "steps" + ], + "additionalProperties": false + } + }, + "workflowPresetsV6": { + "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.", + "allOf": [ + { "$ref": "#/definitions/workflowPresetsItemsV6" } + ], + "items": { + "type": "object", + "properties": { + "name": {}, + "vendor": {}, + "displayName": {}, + "description": {}, + "steps": {} + }, + "required": [ + "name", + "steps" + ], + "additionalProperties": false + } + }, "condition": { "anyOf": [ { diff --git a/Help/release/dev/cmake-presets-workflow.rst b/Help/release/dev/cmake-presets-workflow.rst new file mode 100644 index 0000000..db93d72 --- /dev/null +++ b/Help/release/dev/cmake-presets-workflow.rst @@ -0,0 +1,4 @@ +cmake-presets-workflow +---------------------- + +* The :manual:`cmake-presets(7)` format now supports a ``workflowPresets`` field. diff --git a/Help/release/dev/vs11-deprecate.rst b/Help/release/dev/vs11-deprecate.rst new file mode 100644 index 0000000..2ee69bb --- /dev/null +++ b/Help/release/dev/vs11-deprecate.rst @@ -0,0 +1,5 @@ +vs11-deprecate +-------------- + +* The :generator:`Visual Studio 11 2012` generator is now deprecated + and will be removed in a future version of CMake. diff --git a/Modules/CMakeTestCCompiler.cmake b/Modules/CMakeTestCCompiler.cmake index 102b638..a706767 100644 --- a/Modules/CMakeTestCCompiler.cmake +++ b/Modules/CMakeTestCCompiler.cmake @@ -38,7 +38,7 @@ endif() if(NOT CMAKE_C_COMPILER_WORKS) PrintTestCompilerStatus("C") __TestCompiler_setTryCompileTargetType() - file(WRITE ${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeTmp/testCCompiler.c + string(CONCAT __TestCompiler_testCCompilerSource "#ifdef __cplusplus\n" "# error \"The CMAKE_C_COMPILER is set to a C++ compiler\"\n" "#endif\n" @@ -54,8 +54,9 @@ if(NOT CMAKE_C_COMPILER_WORKS) unset(CMAKE_C_COMPILER_WORKS) # Puts test result in cache variable. try_compile(CMAKE_C_COMPILER_WORKS - SOURCES ${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeTmp/testCCompiler.c + SOURCE_FROM_VAR testCCompiler.c __TestCompiler_testCCompilerSource OUTPUT_VARIABLE __CMAKE_C_COMPILER_OUTPUT) + unset(__TestCompiler_testCCompilerSource) # Move result from cache to normal variable. set(CMAKE_C_COMPILER_WORKS ${CMAKE_C_COMPILER_WORKS}) unset(CMAKE_C_COMPILER_WORKS CACHE) diff --git a/Modules/CMakeTestCSharpCompiler.cmake b/Modules/CMakeTestCSharpCompiler.cmake index d7a0bb5..1c9e249 100644 --- a/Modules/CMakeTestCSharpCompiler.cmake +++ b/Modules/CMakeTestCSharpCompiler.cmake @@ -12,8 +12,6 @@ include(CMakeTestCompilerCommon) unset(CMAKE_CSharp_COMPILER_WORKS CACHE) -set(test_compile_file "${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeTmp/testCSharpCompiler.cs") - # This file is used by EnableLanguage in cmGlobalGenerator to # determine that the selected C# compiler can actually compile # and link the most basic of programs. If not, a fatal error @@ -23,20 +21,21 @@ if(NOT CMAKE_CSharp_COMPILER_WORKS) # Don't call PrintTestCompilerStatus() because the "C#" we want to pass # as the LANG doesn't match with the variable name "CMAKE_CSharp_COMPILER" message(CHECK_START "Check for working C# compiler: ${CMAKE_CSharp_COMPILER}") - file(WRITE "${test_compile_file}" - "namespace Test {" - " public class CSharp {" - " static void Main(string[] args) {}" - " }" - "}" + string(CONCAT __TestCompiler_testCSharpCompilerSource + "namespace Test {\n" + " public class CSharp {\n" + " static void Main(string[] args) {}\n" + " }\n" + "}\n" ) # Clear result from normal variable. unset(CMAKE_CSharp_COMPILER_WORKS) # Puts test result in cache variable. try_compile(CMAKE_CSharp_COMPILER_WORKS - SOURCES "${test_compile_file}" + SOURCE_FROM_VAR testCSharpCompiler.cs __TestCompiler_testCSharpCompilerSource OUTPUT_VARIABLE __CMAKE_CSharp_COMPILER_OUTPUT ) + unset(__TestCompiler_testCSharpCompilerSource) # Move result from cache to normal variable. set(CMAKE_CSharp_COMPILER_WORKS ${CMAKE_CSharp_COMPILER_WORKS}) unset(CMAKE_CSharp_COMPILER_WORKS CACHE) diff --git a/Modules/CMakeTestCUDACompiler.cmake b/Modules/CMakeTestCUDACompiler.cmake index 9c49f5d..a89182b 100644 --- a/Modules/CMakeTestCUDACompiler.cmake +++ b/Modules/CMakeTestCUDACompiler.cmake @@ -76,7 +76,7 @@ endif() # any makefiles or projects. if(NOT CMAKE_CUDA_COMPILER_WORKS) PrintTestCompilerStatus("CUDA") - file(WRITE ${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeTmp/main.cu + string(CONCAT __TestCompiler_testCudaCompilerSource "#ifndef __CUDACC__\n" "# error \"The CMAKE_CUDA_COMPILER is set to an invalid CUDA compiler\"\n" "#endif\n" @@ -87,8 +87,9 @@ if(NOT CMAKE_CUDA_COMPILER_WORKS) # Puts test result in cache variable. try_compile(CMAKE_CUDA_COMPILER_WORKS - SOURCES ${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeTmp/main.cu + SOURCE_FROM_VAR main.cu __TestCompiler_testCudaCompilerSource OUTPUT_VARIABLE __CMAKE_CUDA_COMPILER_OUTPUT) + unset(__TestCompiler_testCudaCompilerSource) # Move result from cache to normal variable. set(CMAKE_CUDA_COMPILER_WORKS ${CMAKE_CUDA_COMPILER_WORKS}) diff --git a/Modules/CMakeTestCXXCompiler.cmake b/Modules/CMakeTestCXXCompiler.cmake index 9a3638f..fa4016a 100644 --- a/Modules/CMakeTestCXXCompiler.cmake +++ b/Modules/CMakeTestCXXCompiler.cmake @@ -38,7 +38,7 @@ endif() if(NOT CMAKE_CXX_COMPILER_WORKS) PrintTestCompilerStatus("CXX") __TestCompiler_setTryCompileTargetType() - file(WRITE ${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeTmp/testCXXCompiler.cxx + string(CONCAT __TestCompiler_testCXXCompilerSource "#ifndef __cplusplus\n" "# error \"The CMAKE_CXX_COMPILER is set to a C compiler\"\n" "#endif\n" @@ -47,8 +47,9 @@ if(NOT CMAKE_CXX_COMPILER_WORKS) unset(CMAKE_CXX_COMPILER_WORKS) # Puts test result in cache variable. try_compile(CMAKE_CXX_COMPILER_WORKS - SOURCES ${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeTmp/testCXXCompiler.cxx + SOURCE_FROM_VAR testCXXCompiler.cxx __TestCompiler_testCXXCompilerSource OUTPUT_VARIABLE __CMAKE_CXX_COMPILER_OUTPUT) + unset(__TestCompiler_testCXXCompilerSource) # Move result from cache to normal variable. set(CMAKE_CXX_COMPILER_WORKS ${CMAKE_CXX_COMPILER_WORKS}) unset(CMAKE_CXX_COMPILER_WORKS CACHE) @@ -56,7 +57,7 @@ if(NOT CMAKE_CXX_COMPILER_WORKS) if(NOT CMAKE_CXX_COMPILER_WORKS) PrintTestCompilerResult(CHECK_FAIL "broken") file(APPEND ${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeError.log - "Determining if the CXX compiler works failed with " + "Determining if the C++ compiler works failed with " "the following output:\n${__CMAKE_CXX_COMPILER_OUTPUT}\n\n") string(REPLACE "\n" "\n " _output "${__CMAKE_CXX_COMPILER_OUTPUT}") message(FATAL_ERROR "The C++ compiler\n \"${CMAKE_CXX_COMPILER}\"\n" @@ -66,7 +67,7 @@ if(NOT CMAKE_CXX_COMPILER_WORKS) endif() PrintTestCompilerResult(CHECK_PASS "works") file(APPEND ${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeOutput.log - "Determining if the CXX compiler works passed with " + "Determining if the C++ compiler works passed with " "the following output:\n${__CMAKE_CXX_COMPILER_OUTPUT}\n\n") endif() diff --git a/Modules/CMakeTestFortranCompiler.cmake b/Modules/CMakeTestFortranCompiler.cmake index 4e413af..e6d1f6d 100644 --- a/Modules/CMakeTestFortranCompiler.cmake +++ b/Modules/CMakeTestFortranCompiler.cmake @@ -38,7 +38,7 @@ endif() # any makefiles or projects. if(NOT CMAKE_Fortran_COMPILER_WORKS) PrintTestCompilerStatus("Fortran") - file(WRITE ${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeTmp/testFortranCompiler.f " + set(__TestCompiler_testFortranCompilerSource " PROGRAM TESTFortran PRINT *, 'Hello' END @@ -47,8 +47,9 @@ if(NOT CMAKE_Fortran_COMPILER_WORKS) unset(CMAKE_Fortran_COMPILER_WORKS) # Puts test result in cache variable. try_compile(CMAKE_Fortran_COMPILER_WORKS - SOURCES ${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeTmp/testFortranCompiler.f + SOURCE_FROM_VAR testFortranCompiler.f __TestCompiler_testFortranCompilerSource OUTPUT_VARIABLE OUTPUT) + unset(__TestCompiler_testFortranCompilerSource) # Move result from cache to normal variable. set(CMAKE_Fortran_COMPILER_WORKS ${CMAKE_Fortran_COMPILER_WORKS}) unset(CMAKE_Fortran_COMPILER_WORKS CACHE) @@ -72,14 +73,15 @@ endif() # Test for Fortran 90 support by using an f90-specific construct. if(NOT DEFINED CMAKE_Fortran_COMPILER_SUPPORTS_F90) message(CHECK_START "Checking whether ${CMAKE_Fortran_COMPILER} supports Fortran 90") - file(WRITE ${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeTmp/testFortranCompilerF90.f90 " + set(__TestCompiler_testFortranCompilerSource " PROGRAM TESTFortran90 integer stop ; stop = 1 ; do while ( stop .eq. 0 ) ; end do END PROGRAM TESTFortran90 ") try_compile(CMAKE_Fortran_COMPILER_SUPPORTS_F90 - SOURCES ${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeTmp/testFortranCompilerF90.f90 + SOURCE_FROM_VAR testFortranCompilerF90.f90 __TestCompiler_testFortranCompilerF90Source OUTPUT_VARIABLE OUTPUT) + unset(__TestCompiler_testFortranCompilerF90Source) if(CMAKE_Fortran_COMPILER_SUPPORTS_F90) message(CHECK_PASS "yes") file(APPEND ${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeOutput.log diff --git a/Modules/CMakeTestHIPCompiler.cmake b/Modules/CMakeTestHIPCompiler.cmake index a0b6bfd..1da0ae4 100644 --- a/Modules/CMakeTestHIPCompiler.cmake +++ b/Modules/CMakeTestHIPCompiler.cmake @@ -41,7 +41,7 @@ endif() if(NOT CMAKE_HIP_COMPILER_WORKS) PrintTestCompilerStatus("HIP") __TestCompiler_setTryCompileTargetType() - file(WRITE ${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeTmp/testHIPCompiler.hip + string(CONCAT __TestCompiler_testHIPCompilerSource "#ifndef __HIP__\n" "# error \"The CMAKE_HIP_COMPILER is set to a C/CXX compiler\"\n" "#endif\n" @@ -50,8 +50,9 @@ if(NOT CMAKE_HIP_COMPILER_WORKS) unset(CMAKE_HIP_COMPILER_WORKS) # Puts test result in cache variable. try_compile(CMAKE_HIP_COMPILER_WORKS - SOURCES ${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeTmp/testHIPCompiler.hip + SOURCE_FROM_VAR testHIPCompiler.hip __TestCompiler_testHIPCompilerSource OUTPUT_VARIABLE __CMAKE_HIP_COMPILER_OUTPUT) + unset(__TestCompiler_testHIPCompilerSource) # Move result from cache to normal variable. set(CMAKE_HIP_COMPILER_WORKS ${CMAKE_HIP_COMPILER_WORKS}) unset(CMAKE_HIP_COMPILER_WORKS CACHE) diff --git a/Modules/CMakeTestOBJCCompiler.cmake b/Modules/CMakeTestOBJCCompiler.cmake index a8e6319..bbc90a7 100644 --- a/Modules/CMakeTestOBJCCompiler.cmake +++ b/Modules/CMakeTestOBJCCompiler.cmake @@ -38,7 +38,7 @@ endif() if(NOT CMAKE_OBJC_COMPILER_WORKS) PrintTestCompilerStatus("OBJC") __TestCompiler_setTryCompileTargetType() - file(WRITE ${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeTmp/testOBJCCompiler.m + string(CONCAT __TestCompiler_testObjCCompilerSource "#ifdef __cplusplus\n" "# error \"The CMAKE_OBJC_COMPILER is set to a C++ compiler\"\n" "#endif\n" @@ -51,8 +51,9 @@ if(NOT CMAKE_OBJC_COMPILER_WORKS) unset(CMAKE_OBJC_COMPILER_WORKS) # Puts test result in cache variable. try_compile(CMAKE_OBJC_COMPILER_WORKS - SOURCES ${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeTmp/testOBJCCompiler.m + SOURCE_FROM_VAR testObjCCompiler.m __TestCompiler_testObjCCompilerSource OUTPUT_VARIABLE __CMAKE_OBJC_COMPILER_OUTPUT) + unset(__TestCompiler_testObjCCompilerSource) # Move result from cache to normal variable. set(CMAKE_OBJC_COMPILER_WORKS ${CMAKE_OBJC_COMPILER_WORKS}) unset(CMAKE_OBJC_COMPILER_WORKS CACHE) diff --git a/Modules/CMakeTestOBJCXXCompiler.cmake b/Modules/CMakeTestOBJCXXCompiler.cmake index afa053f..aceb939 100644 --- a/Modules/CMakeTestOBJCXXCompiler.cmake +++ b/Modules/CMakeTestOBJCXXCompiler.cmake @@ -38,7 +38,7 @@ endif() if(NOT CMAKE_OBJCXX_COMPILER_WORKS) PrintTestCompilerStatus("OBJCXX") __TestCompiler_setTryCompileTargetType() - file(WRITE ${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeTmp/testOBJCXXCompiler.mm + string(CONCAT __TestCompiler_testObjCXXCompilerSource "#ifndef __cplusplus\n" "# error \"The CMAKE_OBJCXX_COMPILER is set to a C compiler\"\n" "#endif\n" @@ -50,8 +50,9 @@ if(NOT CMAKE_OBJCXX_COMPILER_WORKS) unset(CMAKE_OBJCXX_COMPILER_WORKS) # Puts test result in cache variable. try_compile(CMAKE_OBJCXX_COMPILER_WORKS - SOURCES ${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeTmp/testOBJCXXCompiler.mm + SOURCE_FROM_VAR testObjCXXCompiler.mm __TestCompiler_testObjCXXCompilerSource OUTPUT_VARIABLE __CMAKE_OBJCXX_COMPILER_OUTPUT) + unset(__TestCompiler_testObjCXXCompilerSource) # Move result from cache to normal variable. set(CMAKE_OBJCXX_COMPILER_WORKS ${CMAKE_OBJCXX_COMPILER_WORKS}) unset(CMAKE_OBJCXX_COMPILER_WORKS CACHE) diff --git a/Modules/CMakeTestSwiftCompiler.cmake b/Modules/CMakeTestSwiftCompiler.cmake index 4982819..88a864c 100644 --- a/Modules/CMakeTestSwiftCompiler.cmake +++ b/Modules/CMakeTestSwiftCompiler.cmake @@ -21,13 +21,12 @@ unset(CMAKE_Swift_COMPILER_WORKS CACHE) # any makefiles or projects. if(NOT CMAKE_Swift_COMPILER_WORKS) PrintTestCompilerStatus("Swift") - file(WRITE ${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeTmp/main.swift - "print(\"CMake\")\n") # Clear result from normal variable. unset(CMAKE_Swift_COMPILER_WORKS) # Puts test result in cache variable. + set(__CMAKE_Swift_TEST_SOURCE "print(\"CMake\")\n") try_compile(CMAKE_Swift_COMPILER_WORKS - SOURCES ${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeTmp/main.swift + SOURCE_FROM_VAR main.swift __CMAKE_Swift_TEST_SOURCE OUTPUT_VARIABLE __CMAKE_Swift_COMPILER_OUTPUT) # Move result from cache to normal variable. set(CMAKE_Swift_COMPILER_WORKS ${CMAKE_Swift_COMPILER_WORKS}) @@ -64,4 +63,5 @@ else() include(${CMAKE_PLATFORM_INFO_DIR}/CMakeSwiftCompiler.cmake) endif() +unset(__CMAKE_Swift_TEST_SOURCE) unset(__CMAKE_Swift_COMPILER_OUTPUT) diff --git a/Modules/CheckCXXSymbolExists.cmake b/Modules/CheckCXXSymbolExists.cmake index 7b13c3a..1fa0898 100644 --- a/Modules/CheckCXXSymbolExists.cmake +++ b/Modules/CheckCXXSymbolExists.cmake @@ -74,5 +74,5 @@ include_guard(GLOBAL) include(CheckSymbolExists) macro(CHECK_CXX_SYMBOL_EXISTS SYMBOL FILES VARIABLE) - __CHECK_SYMBOL_EXISTS_IMPL("${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeTmp/CheckSymbolExists.cxx" "${SYMBOL}" "${FILES}" "${VARIABLE}" ) + __CHECK_SYMBOL_EXISTS_IMPL(CheckSymbolExists.cxx "${SYMBOL}" "${FILES}" "${VARIABLE}" ) endmacro() diff --git a/Modules/CheckFortranFunctionExists.cmake b/Modules/CheckFortranFunctionExists.cmake index f82399a..7e3a7ee 100644 --- a/Modules/CheckFortranFunctionExists.cmake +++ b/Modules/CheckFortranFunctionExists.cmake @@ -58,8 +58,7 @@ macro(CHECK_FORTRAN_FUNCTION_EXISTS FUNCTION VARIABLE) else() set(CHECK_FUNCTION_EXISTS_ADD_LIBRARIES) endif() - file(WRITE - ${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeTmp/testFortranCompiler.f + set(__CheckFunction_testFortranCompilerSource " program TESTFortran external ${FUNCTION} @@ -68,11 +67,12 @@ macro(CHECK_FORTRAN_FUNCTION_EXISTS FUNCTION VARIABLE) " ) try_compile(${VARIABLE} - SOURCES ${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeTmp/testFortranCompiler.f + SOURCE_FROM_VAR testFortranCompiler.f __CheckFunction_testFortranCompilerSource ${CHECK_FUNCTION_EXISTS_ADD_LINK_OPTIONS} ${CHECK_FUNCTION_EXISTS_ADD_LIBRARIES} OUTPUT_VARIABLE OUTPUT ) + unset(__CheckFunction_testFortranCompilerSource) if(${VARIABLE}) set(${VARIABLE} 1 CACHE INTERNAL "Have Fortran function ${FUNCTION}") message(CHECK_PASS "found") diff --git a/Modules/CheckFunctionExists.cmake b/Modules/CheckFunctionExists.cmake index 0135218..60f0184 100644 --- a/Modules/CheckFunctionExists.cmake +++ b/Modules/CheckFunctionExists.cmake @@ -81,16 +81,15 @@ macro(CHECK_FUNCTION_EXISTS FUNCTION VARIABLE) endif() if(CMAKE_C_COMPILER_LOADED) - set(_cfe_source ${CMAKE_ROOT}/Modules/CheckFunctionExists.c) + set(_cfe_source CheckFunctionExists.c) elseif(CMAKE_CXX_COMPILER_LOADED) - set(_cfe_source ${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CheckFunctionExists/CheckFunctionExists.cxx) - configure_file(${CMAKE_ROOT}/Modules/CheckFunctionExists.c "${_cfe_source}" COPYONLY) + set(_cfe_source CheckFunctionExists.cxx) else() message(FATAL_ERROR "CHECK_FUNCTION_EXISTS needs either C or CXX language enabled") endif() try_compile(${VARIABLE} - SOURCES ${_cfe_source} + SOURCE_FROM_FILE "${_cfe_source}" "${CMAKE_ROOT}/Modules/CheckFunctionExists.c" COMPILE_DEFINITIONS ${CMAKE_REQUIRED_DEFINITIONS} ${CHECK_FUNCTION_EXISTS_ADD_LINK_OPTIONS} ${CHECK_FUNCTION_EXISTS_ADD_LIBRARIES} diff --git a/Modules/CheckIncludeFile.cmake b/Modules/CheckIncludeFile.cmake index 2253fab..4cba91b 100644 --- a/Modules/CheckIncludeFile.cmake +++ b/Modules/CheckIncludeFile.cmake @@ -54,8 +54,8 @@ macro(CHECK_INCLUDE_FILE INCLUDE VARIABLE) endif() set(MACRO_CHECK_INCLUDE_FILE_FLAGS ${CMAKE_REQUIRED_FLAGS}) set(CHECK_INCLUDE_FILE_VAR ${INCLUDE}) - configure_file(${CMAKE_ROOT}/Modules/CheckIncludeFile.c.in - ${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeTmp/CheckIncludeFile.c) + file(READ ${CMAKE_ROOT}/Modules/CheckIncludeFile.c.in _CIF_SOURCE_CONTENT) + string(CONFIGURE "${_CIF_SOURCE_CONTENT}" _CIF_SOURCE_CONTENT) if(NOT CMAKE_REQUIRED_QUIET) message(CHECK_START "Looking for ${INCLUDE}") endif() @@ -93,7 +93,7 @@ macro(CHECK_INCLUDE_FILE INCLUDE VARIABLE) endif() try_compile(${VARIABLE} - SOURCES ${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeTmp/CheckIncludeFile.c + SOURCE_FROM_VAR CheckIncludeFile.c _CIF_SOURCE_CONTENT COMPILE_DEFINITIONS ${CMAKE_REQUIRED_DEFINITIONS} ${_CIF_LINK_OPTIONS} ${_CIF_LINK_LIBRARIES} diff --git a/Modules/CheckIncludeFileCXX.cmake b/Modules/CheckIncludeFileCXX.cmake index 453751e..f6af036 100644 --- a/Modules/CheckIncludeFileCXX.cmake +++ b/Modules/CheckIncludeFileCXX.cmake @@ -53,8 +53,8 @@ macro(CHECK_INCLUDE_FILE_CXX INCLUDE VARIABLE) endif() set(MACRO_CHECK_INCLUDE_FILE_FLAGS ${CMAKE_REQUIRED_FLAGS}) set(CHECK_INCLUDE_FILE_VAR ${INCLUDE}) - configure_file(${CMAKE_ROOT}/Modules/CheckIncludeFile.cxx.in - ${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeTmp/CheckIncludeFile.cxx) + file(READ ${CMAKE_ROOT}/Modules/CheckIncludeFile.cxx.in _CIF_SOURCE_CONTENT) + string(CONFIGURE "${_CIF_SOURCE_CONTENT}" _CIF_SOURCE_CONTENT) if(NOT CMAKE_REQUIRED_QUIET) message(CHECK_START "Looking for C++ include ${INCLUDE}") endif() @@ -92,7 +92,7 @@ macro(CHECK_INCLUDE_FILE_CXX INCLUDE VARIABLE) endif() try_compile(${VARIABLE} - SOURCES ${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeTmp/CheckIncludeFile.cxx + SOURCE_FROM_VAR CheckIncludeFile.cxx _CIF_SOURCE_CONTENT COMPILE_DEFINITIONS ${CMAKE_REQUIRED_DEFINITIONS} ${_CIF_LINK_OPTIONS} ${_CIF_LINK_LIBRARIES} diff --git a/Modules/CheckIncludeFiles.cmake b/Modules/CheckIncludeFiles.cmake index 22af4f2..8e82859 100644 --- a/Modules/CheckIncludeFiles.cmake +++ b/Modules/CheckIncludeFiles.cmake @@ -52,7 +52,7 @@ include_guard(GLOBAL) macro(CHECK_INCLUDE_FILES INCLUDE VARIABLE) if(NOT DEFINED "${VARIABLE}") - set(CMAKE_CONFIGURABLE_FILE_CONTENT "/* */\n") + set(_src_content "/* */\n") if("x${ARGN}" STREQUAL "x") if(CMAKE_C_COMPILER_LOADED) @@ -71,9 +71,9 @@ macro(CHECK_INCLUDE_FILES INCLUDE VARIABLE) endif() if(_lang STREQUAL "C") - set(src ${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CheckIncludeFiles/${VARIABLE}.c) + set(src ${VARIABLE}.c) elseif(_lang STREQUAL "CXX") - set(src ${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CheckIncludeFiles/${VARIABLE}.cpp) + set(src ${VARIABLE}.cpp) else() message(FATAL_ERROR "Unknown language:\n ${_lang}\nSupported languages: C, CXX.\n") endif() @@ -86,13 +86,11 @@ macro(CHECK_INCLUDE_FILES INCLUDE VARIABLE) set(CHECK_INCLUDE_FILES_CONTENT "/* */\n") set(MACRO_CHECK_INCLUDE_FILES_FLAGS ${CMAKE_REQUIRED_FLAGS}) foreach(FILE ${INCLUDE}) - string(APPEND CMAKE_CONFIGURABLE_FILE_CONTENT + string(APPEND _src_content "#include <${FILE}>\n") endforeach() - string(APPEND CMAKE_CONFIGURABLE_FILE_CONTENT + string(APPEND _src_content "\n\nint main(void){return 0;}\n") - configure_file("${CMAKE_ROOT}/Modules/CMakeConfigurableFile.in" - "${src}" @ONLY) set(_INCLUDE ${INCLUDE}) # remove empty elements if("${_INCLUDE}" MATCHES "^([^;]+);.+;([^;]+)$") @@ -136,7 +134,7 @@ macro(CHECK_INCLUDE_FILES INCLUDE VARIABLE) message(CHECK_START "Looking for ${_description}") endif() try_compile(${VARIABLE} - SOURCES ${src} + SOURCE_FROM_VAR "${src}" _src_content COMPILE_DEFINITIONS ${CMAKE_REQUIRED_DEFINITIONS} ${_CIF_LINK_OPTIONS} ${_CIF_LINK_LIBRARIES} @@ -163,7 +161,7 @@ macro(CHECK_INCLUDE_FILES INCLUDE VARIABLE) file(APPEND ${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeError.log "Determining if files ${INCLUDE} " "exist failed with the following output:\n" - "${OUTPUT}\nSource:\n${CMAKE_CONFIGURABLE_FILE_CONTENT}\n") + "${OUTPUT}\nSource:\n${_src_content}\n") endif() endif() endmacro() diff --git a/Modules/CheckLibraryExists.cmake b/Modules/CheckLibraryExists.cmake index e126f70..56424ac 100644 --- a/Modules/CheckLibraryExists.cmake +++ b/Modules/CheckLibraryExists.cmake @@ -61,16 +61,15 @@ macro(CHECK_LIBRARY_EXISTS LIBRARY FUNCTION LOCATION VARIABLE) endif() if(CMAKE_C_COMPILER_LOADED) - set(_cle_source ${CMAKE_ROOT}/Modules/CheckFunctionExists.c) + set(_cle_source CheckFunctionExists.c) elseif(CMAKE_CXX_COMPILER_LOADED) - set(_cle_source ${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CheckLibraryExists/CheckFunctionExists.cxx) - configure_file(${CMAKE_ROOT}/Modules/CheckFunctionExists.c "${_cle_source}" COPYONLY) + set(_cle_source CheckFunctionExists.cxx) else() message(FATAL_ERROR "CHECK_FUNCTION_EXISTS needs either C or CXX language enabled") endif() try_compile(${VARIABLE} - SOURCES ${_cle_source} + SOURCE_FROM_FILE "${_cle_source}" "${CMAKE_ROOT}/Modules/CheckFunctionExists.c" COMPILE_DEFINITIONS ${CMAKE_REQUIRED_DEFINITIONS} ${CHECK_LIBRARY_EXISTS_LINK_OPTIONS} LINK_LIBRARIES ${CHECK_LIBRARY_EXISTS_LIBRARIES} diff --git a/Modules/CheckPrototypeDefinition.cmake b/Modules/CheckPrototypeDefinition.cmake index 5a07502..12f4e86 100644 --- a/Modules/CheckPrototypeDefinition.cmake +++ b/Modules/CheckPrototypeDefinition.cmake @@ -94,13 +94,11 @@ function(check_prototype_definition _FUNCTION _PROTOTYPE _RETURN _HEADER _VARIAB set(CHECK_PROTOTYPE_DEFINITION_PROTO ${_PROTOTYPE}) set(CHECK_PROTOTYPE_DEFINITION_RETURN ${_RETURN}) - configure_file("${__check_proto_def_dir}/CheckPrototypeDefinition.c.in" - "${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeTmp/CheckPrototypeDefinition.c" @ONLY) - - file(READ ${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeTmp/CheckPrototypeDefinition.c _SOURCE) + file(READ ${__check_proto_def_dir}/CheckPrototypeDefinition.c.in _SOURCE) + string(CONFIGURE "${_SOURCE}" _SOURCE @ONLY) try_compile(${_VARIABLE} - SOURCES ${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeTmp/CheckPrototypeDefinition.c + SOURCE_FROM_VAR CheckPrototypeDefinition.c _SOURCE COMPILE_DEFINITIONS ${CMAKE_REQUIRED_DEFINITIONS} ${CHECK_PROTOTYPE_DEFINITION_LINK_OPTIONS} ${CHECK_PROTOTYPE_DEFINITION_LIBS} diff --git a/Modules/CheckSymbolExists.cmake b/Modules/CheckSymbolExists.cmake index ebaeb7c..0d44d56 100644 --- a/Modules/CheckSymbolExists.cmake +++ b/Modules/CheckSymbolExists.cmake @@ -68,11 +68,11 @@ cmake_policy(SET CMP0054 NEW) # if() quoted variables not dereferenced macro(CHECK_SYMBOL_EXISTS SYMBOL FILES VARIABLE) if(CMAKE_C_COMPILER_LOADED) __CHECK_SYMBOL_EXISTS_FILTER_FLAGS(C) - __CHECK_SYMBOL_EXISTS_IMPL("${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeTmp/CheckSymbolExists.c" "${SYMBOL}" "${FILES}" "${VARIABLE}" ) + __CHECK_SYMBOL_EXISTS_IMPL(CheckSymbolExists.c "${SYMBOL}" "${FILES}" "${VARIABLE}" ) __CHECK_SYMBOL_EXISTS_RESTORE_FLAGS(C) elseif(CMAKE_CXX_COMPILER_LOADED) __CHECK_SYMBOL_EXISTS_FILTER_FLAGS(CXX) - __CHECK_SYMBOL_EXISTS_IMPL("${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeTmp/CheckSymbolExists.cxx" "${SYMBOL}" "${FILES}" "${VARIABLE}" ) + __CHECK_SYMBOL_EXISTS_IMPL(CheckSymbolExists.cxx "${SYMBOL}" "${FILES}" "${VARIABLE}" ) __CHECK_SYMBOL_EXISTS_RESTORE_FLAGS(CXX) else() message(FATAL_ERROR "CHECK_SYMBOL_EXISTS needs either C or CXX language enabled") @@ -92,7 +92,7 @@ endmacro() macro(__CHECK_SYMBOL_EXISTS_IMPL SOURCEFILE SYMBOL FILES VARIABLE) if(NOT DEFINED "${VARIABLE}" OR "x${${VARIABLE}}" STREQUAL "x${VARIABLE}") - set(CMAKE_CONFIGURABLE_FILE_CONTENT "/* */\n") + set(_CSE_SOURCE "/* */\n") set(MACRO_CHECK_SYMBOL_EXISTS_FLAGS ${CMAKE_REQUIRED_FLAGS}) if(CMAKE_REQUIRED_LINK_OPTIONS) set(CHECK_SYMBOL_EXISTS_LINK_OPTIONS @@ -113,17 +113,17 @@ macro(__CHECK_SYMBOL_EXISTS_IMPL SOURCEFILE SYMBOL FILES VARIABLE) set(CMAKE_SYMBOL_EXISTS_INCLUDES) endif() foreach(FILE ${FILES}) - string(APPEND CMAKE_CONFIGURABLE_FILE_CONTENT + string(APPEND _CSE_SOURCE "#include <${FILE}>\n") endforeach() - string(APPEND CMAKE_CONFIGURABLE_FILE_CONTENT " + string(APPEND _CSE_SOURCE " int main(int argc, char** argv) { (void)argv;") set(_CSE_CHECK_NON_MACRO "return ((int*)(&${SYMBOL}))[argc];") if("${SYMBOL}" MATCHES "^[a-zA-Z_][a-zA-Z0-9_]*$") # The SYMBOL has a legal macro name. Test whether it exists as a macro. - string(APPEND CMAKE_CONFIGURABLE_FILE_CONTENT " + string(APPEND _CSE_SOURCE " #ifndef ${SYMBOL} ${_CSE_CHECK_NON_MACRO} #else @@ -132,21 +132,18 @@ int main(int argc, char** argv) #endif") else() # The SYMBOL cannot be a macro (e.g., a template function). - string(APPEND CMAKE_CONFIGURABLE_FILE_CONTENT " + string(APPEND _CSE_SOURCE " ${_CSE_CHECK_NON_MACRO}") endif() - string(APPEND CMAKE_CONFIGURABLE_FILE_CONTENT " + string(APPEND _CSE_SOURCE " }") unset(_CSE_CHECK_NON_MACRO) - configure_file("${CMAKE_ROOT}/Modules/CMakeConfigurableFile.in" - "${SOURCEFILE}" @ONLY) - if(NOT CMAKE_REQUIRED_QUIET) message(CHECK_START "Looking for ${SYMBOL}") endif() try_compile(${VARIABLE} - SOURCES "${SOURCEFILE}" + SOURCE_FROM_VAR "${SOURCEFILE}" _CSE_SOURCE COMPILE_DEFINITIONS ${CMAKE_REQUIRED_DEFINITIONS} ${CHECK_SYMBOL_EXISTS_LINK_OPTIONS} ${CHECK_SYMBOL_EXISTS_LIBS} @@ -163,7 +160,7 @@ int main(int argc, char** argv) "Determining if the ${SYMBOL} " "exist passed with the following output:\n" "${OUTPUT}\nFile ${SOURCEFILE}:\n" - "${CMAKE_CONFIGURABLE_FILE_CONTENT}\n") + "${_CSE_SOURCE}\n") else() if(NOT CMAKE_REQUIRED_QUIET) message(CHECK_FAIL "not found") @@ -173,9 +170,9 @@ int main(int argc, char** argv) "Determining if the ${SYMBOL} " "exist failed with the following output:\n" "${OUTPUT}\nFile ${SOURCEFILE}:\n" - "${CMAKE_CONFIGURABLE_FILE_CONTENT}\n") + "${_CSE_SOURCE}\n") endif() - unset(CMAKE_CONFIGURABLE_FILE_CONTENT) + unset(_CSE_SOURCE) endif() endmacro() diff --git a/Modules/CheckTypeSize.cmake b/Modules/CheckTypeSize.cmake index 4cffa1a..b14ab06 100644 --- a/Modules/CheckTypeSize.cmake +++ b/Modules/CheckTypeSize.cmake @@ -104,9 +104,9 @@ function(__check_type_size_impl type var map builtin language) # Perform language check if(language STREQUAL "C") - set(src ${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CheckTypeSize/${var}.c) + set(src ${var}.c) elseif(language STREQUAL "CXX") - set(src ${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CheckTypeSize/${var}.cpp) + set(src ${var}.cpp) else() message(FATAL_ERROR "Unknown language:\n ${language}\nSupported languages: C, CXX.\n") endif() @@ -142,8 +142,9 @@ function(__check_type_size_impl type var map builtin language) # Perform the check. set(bin ${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CheckTypeSize/${var}.bin) - configure_file(${__check_type_size_dir}/CheckTypeSize.c.in ${src} @ONLY) - try_compile(HAVE_${var} SOURCES ${src} + file(READ ${__check_type_size_dir}/CheckTypeSize.c.in src_content) + string(CONFIGURE "${src_content}" src_content @ONLY) + try_compile(HAVE_${var} SOURCE_FROM_VAR "${src}" src_content COMPILE_DEFINITIONS ${CMAKE_REQUIRED_DEFINITIONS} LINK_OPTIONS ${CMAKE_REQUIRED_LINK_OPTIONS} LINK_LIBRARIES ${CMAKE_REQUIRED_LIBRARIES} @@ -209,9 +210,8 @@ function(__check_type_size_impl type var map builtin language) if(NOT CMAKE_REQUIRED_QUIET) message(CHECK_FAIL "failed") endif() - file(READ ${src} content) file(APPEND ${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeError.log - "Determining size of ${type} failed with the following output:\n${output}\n${src}:\n${content}\n\n") + "Determining size of ${type} failed with the following output:\n${output}\n${src}:\n${src_content}\n\n") set(${var} "" CACHE INTERNAL "CHECK_TYPE_SIZE: ${type} unknown") file(REMOVE ${map}) endif() diff --git a/Modules/FindGLUT.cmake b/Modules/FindGLUT.cmake index 320ddad..6934089 100644 --- a/Modules/FindGLUT.cmake +++ b/Modules/FindGLUT.cmake @@ -95,7 +95,10 @@ function(_add_glut_target_simple) endfunction() find_package(PkgConfig QUIET) -if(PKG_CONFIG_FOUND) +get_property(_isMultiConfig GLOBAL PROPERTY GENERATOR_IS_MULTI_CONFIG) +# On WIN32 and when using a multiple config generator, pkg-config +# is not used as it cannot distinguish between release and debug libraries +if(PKG_CONFIG_FOUND AND NOT (_isMultiConfig AND WIN32)) # Tell pkg-config not to strip any -I flags to make sure GLUT_INCLUDE_DIRS # will be defined. if(DEFINED ENV{PKG_CONFIG_ALLOW_SYSTEM_CFLAGS}) diff --git a/Modules/FindMFC.cmake b/Modules/FindMFC.cmake index 0574ab5..2d5de89 100644 --- a/Modules/FindMFC.cmake +++ b/Modules/FindMFC.cmake @@ -29,21 +29,19 @@ endif() if(MFC_ATTEMPT_TRY_COMPILE) if(NOT DEFINED MFC_HAVE_MFC) set(CHECK_INCLUDE_FILE_VAR "afxwin.h") - configure_file(${CMAKE_ROOT}/Modules/CheckIncludeFile.cxx.in - ${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeTmp/CheckIncludeFile.cxx) + file(READ ${CMAKE_ROOT}/Modules/CheckIncludeFile.cxx.in _CIF_SOURCE_CONTENT) + string(CONFIGURE "${_CIF_SOURCE_CONTENT}" _CIF_SOURCE_CONTENT) message(CHECK_START "Looking for MFC") # Try both shared and static as the root project may have set the /MT flag try_compile(MFC_HAVE_MFC - SOURCES ${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeTmp/CheckIncludeFile.cxx + SOURCE_FROM_VAR CheckIncludeFile.cxx _CIF_SOURCE_CONTENT CMAKE_FLAGS -DCMAKE_MFC_FLAG:STRING=2 -DCOMPILE_DEFINITIONS:STRING=-D_AFXDLL OUTPUT_VARIABLE OUTPUT) if(NOT MFC_HAVE_MFC) - configure_file(${CMAKE_ROOT}/Modules/CheckIncludeFile.cxx.in - ${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeTmp/CheckIncludeFile.cxx) try_compile(MFC_HAVE_MFC - SOURCES ${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeTmp/CheckIncludeFile.cxx + SOURCE_FROM_VAR CheckIncludeFile.cxx _CIF_SOURCE_CONTENT CMAKE_FLAGS -DCMAKE_MFC_FLAG:STRING=1 OUTPUT_VARIABLE OUTPUT) diff --git a/Modules/FindMPI.cmake b/Modules/FindMPI.cmake index 2faab0e..e15be91 100644 --- a/Modules/FindMPI.cmake +++ b/Modules/FindMPI.cmake @@ -1246,20 +1246,22 @@ function(_MPI_try_staged_settings LANG MPI_TEST_FILE_NAME MODE RUN_BINARY SUPPRE else() # F77 header set(MPI_Fortran_INCLUDE_LINE "implicit none\n include 'mpif.h'") endif() - configure_file("${SRC_DIR}/${MPI_TEST_FILE_NAME}.f90.in" "${WORK_DIR}/${MPI_TEST_FILE_NAME}.f90" @ONLY) - set(MPI_TEST_SOURCE_FILE "${WORK_DIR}/${MPI_TEST_FILE_NAME}.f90") + file(READ "${SRC_DIR}/${MPI_TEST_FILE_NAME}.f90.in" MPI_TEST_SOURCE_CONTENT) + string(CONFIGURE "${MPI_TEST_SOURCE_CONTENT}" MPI_TEST_SOURCE_CONTENT) + set(MPI_TEST_SOURCE_FILE "${MPI_TEST_FILE_NAME}.f90") elseif(LANG STREQUAL "CXX") - configure_file("${SRC_DIR}/${MPI_TEST_FILE_NAME}.c" "${WORK_DIR}/${MPI_TEST_FILE_NAME}.cpp" COPYONLY) - set(MPI_TEST_SOURCE_FILE "${WORK_DIR}/${MPI_TEST_FILE_NAME}.cpp") + file(READ "${SRC_DIR}/${MPI_TEST_FILE_NAME}.c" MPI_TEST_SOURCE_CONTENT) + set(MPI_TEST_SOURCE_FILE "${MPI_TEST_FILE_NAME}.cpp") if(MODE STREQUAL "TEST_MPICXX") set(MPI_TEST_COMPILE_DEFINITIONS TEST_MPI_MPICXX) endif() else() # C - set(MPI_TEST_SOURCE_FILE "${SRC_DIR}/${MPI_TEST_FILE_NAME}.c") + file(READ "${SRC_DIR}/${MPI_TEST_FILE_NAME}.c" MPI_TEST_SOURCE_CONTENT) + set(MPI_TEST_SOURCE_FILE "${MPI_TEST_FILE_NAME}.c") endif() if(RUN_BINARY) try_run(MPI_RUN_RESULT_${LANG}_${MPI_TEST_FILE_NAME}_${MODE} MPI_RESULT_${LANG}_${MPI_TEST_FILE_NAME}_${MODE} - SOURCES "${MPI_TEST_SOURCE_FILE}" + SOURCE_FROM_VAR "${MPI_TEST_SOURCE_FILE}" MPI_TEST_SOURCE_CONTENT COMPILE_DEFINITIONS ${MPI_TEST_COMPILE_DEFINITIONS} LINK_LIBRARIES MPI::MPI_${LANG} RUN_OUTPUT_VARIABLE MPI_RUN_OUTPUT_${LANG}_${MPI_TEST_FILE_NAME}_${MODE} @@ -1267,7 +1269,7 @@ function(_MPI_try_staged_settings LANG MPI_TEST_FILE_NAME MODE RUN_BINARY SUPPRE set(MPI_RUN_OUTPUT_${LANG}_${MPI_TEST_FILE_NAME}_${MODE} "${MPI_RUN_OUTPUT_${LANG}_${MPI_TEST_FILE_NAME}_${MODE}}" PARENT_SCOPE) else() try_compile(MPI_RESULT_${LANG}_${MPI_TEST_FILE_NAME}_${MODE} - SOURCES "${MPI_TEST_SOURCE_FILE}" + SOURCE_FROM_VAR "${MPI_TEST_SOURCE_FILE}" MPI_TEST_SOURCE_CONTENT COMPILE_DEFINITIONS ${MPI_TEST_COMPILE_DEFINITIONS} LINK_LIBRARIES MPI::MPI_${LANG} COPY_FILE "${BIN_FILE}" diff --git a/Modules/FindOpenACC.cmake b/Modules/FindOpenACC.cmake index e05d0c6..00e42b8 100644 --- a/Modules/FindOpenACC.cmake +++ b/Modules/FindOpenACC.cmake @@ -128,21 +128,18 @@ set(OpenACC_Fortran_CHECK_VERSION_SOURCE ) -function(_OPENACC_WRITE_SOURCE_FILE LANG SRC_FILE_CONTENT_VAR SRC_FILE_NAME SRC_FILE_FULLPATH) - set(WORK_DIR ${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/FindOpenACC) +macro(_OPENACC_PREPARE_SOURCE LANG CONTENT_ID NAME_PREFIX FULLNAME_VAR CONTENT_VAR) if("${LANG}" STREQUAL "C") - set(SRC_FILE "${WORK_DIR}/${SRC_FILE_NAME}.c") - file(WRITE "${SRC_FILE}" "${OpenACC_C_CXX_${SRC_FILE_CONTENT_VAR}}") + set(${FULLNAME_VAR} "${NAME_PREFIX}.c") + set(${CONTENT_VAR} "${OpenACC_C_CXX_${CONTENT_ID}}") elseif("${LANG}" STREQUAL "CXX") - set(SRC_FILE "${WORK_DIR}/${SRC_FILE_NAME}.cpp") - file(WRITE "${SRC_FILE}" "${OpenACC_C_CXX_${SRC_FILE_CONTENT_VAR}}") + set(${FULLNAME_VAR} "${NAME_PREFIX}.cpp") + set(${CONTENT_VAR} "${OpenACC_C_CXX_${CONTENT_ID}}") elseif("${LANG}" STREQUAL "Fortran") - set(SRC_FILE "${WORK_DIR}/${SRC_FILE_NAME}.F90") - file(WRITE "${SRC_FILE}_in" "${OpenACC_Fortran_${SRC_FILE_CONTENT_VAR}}") - configure_file("${SRC_FILE}_in" "${SRC_FILE}" @ONLY) + set(${FULLNAME_VAR} "${NAME_PREFIX}.F90") + set(${CONTENT_VAR} "${OpenACC_Fortran_${CONTENT_ID}}") endif() - set(${SRC_FILE_FULLPATH} "${SRC_FILE}" PARENT_SCOPE) -endfunction() +endmacro() function(_OPENACC_GET_FLAGS_CANDIDATE LANG FLAG_VAR) @@ -184,10 +181,12 @@ endfunction() function(_OPENACC_GET_FLAGS LANG FLAG_VAR) set(FLAG_CANDIDATES "") _OPENACC_GET_FLAGS_CANDIDATE("${LANG}" FLAG_CANDIDATES) - _OPENACC_WRITE_SOURCE_FILE("${LANG}" "TEST_SOURCE" OpenACCTryFlag _OPENACC_TEST_SRC) + _OPENACC_PREPARE_SOURCE("${LANG}" TEST_SOURCE OpenACCTryFlag + _OPENACC_TEST_SRC_NAME _OPENACC_TEST_SRC_CONTENT) foreach(FLAG IN LISTS FLAG_CANDIDATES) - try_compile(OpenACC_FLAG_TEST_RESULT SOURCES ${_OPENACC_TEST_SRC} + try_compile(OpenACC_FLAG_TEST_RESULT + SOURCE_FROM_VAR "${_OPENACC_TEST_SRC_NAME}" _OPENACC_TEST_SRC_CONTENT CMAKE_FLAGS "-DCOMPILE_DEFINITIONS:STRING=${FLAG}" OUTPUT_VARIABLE OpenACC_TRY_COMPILE_OUTPUT ) @@ -212,13 +211,15 @@ endfunction() function(_OPENACC_GET_SPEC_DATE LANG SPEC_DATE) - _OPENACC_WRITE_SOURCE_FILE("${LANG}" "CHECK_VERSION_SOURCE" OpenACCCheckVersion _OPENACC_TEST_SRC) + _OPENACC_PREPARE_SOURCE(${LANG} CHECK_VERSION_SOURCE OpenACCCheckVersion + _OPENACC_TEST_SRC_NAME _OPENACC_TEST_SRC_CONTENT) set(BIN_FILE "${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/FindOpenACC/accver_${LANG}.bin") - try_compile(OpenACC_SPECTEST_${LANG} SOURCES "${_OPENACC_TEST_SRC}" - CMAKE_FLAGS "-DCOMPILE_DEFINITIONS:STRING=${OpenACC_${LANG}_FLAGS}" - COPY_FILE ${BIN_FILE} - OUTPUT_VARIABLE OUTPUT) + try_compile(OpenACC_SPECTEST_${LANG} + SOURCE_FROM_VAR "${_OPENACC_TEST_SRC_NAME}" _OPENACC_TEST_SRC_CONTENT + CMAKE_FLAGS "-DCOMPILE_DEFINITIONS:STRING=${OpenACC_${LANG}_FLAGS}" + COPY_FILE "${BIN_FILE}" + OUTPUT_VARIABLE OUTPUT) if(${OpenACC_SPECTEST_${LANG}}) file(STRINGS ${BIN_FILE} specstr LIMIT_COUNT 1 REGEX "INFO:OpenACC-date") diff --git a/Modules/FindOpenMP.cmake b/Modules/FindOpenMP.cmake index 040cbe9..9e24925 100644 --- a/Modules/FindOpenMP.cmake +++ b/Modules/FindOpenMP.cmake @@ -178,27 +178,25 @@ set(OpenMP_Fortran_TEST_SOURCE " ) -function(_OPENMP_WRITE_SOURCE_FILE LANG SRC_FILE_CONTENT_VAR SRC_FILE_NAME SRC_FILE_FULLPATH) - set(WORK_DIR ${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/FindOpenMP) +macro(_OPENMP_PREPARE_SOURCE LANG CONTENT_ID NAME_PREFIX FULLNAME_VAR CONTENT_VAR) if("${LANG}" STREQUAL "C") - set(SRC_FILE "${WORK_DIR}/${SRC_FILE_NAME}.c") - file(WRITE "${SRC_FILE}" "${OpenMP_C_CXX_${SRC_FILE_CONTENT_VAR}}") + set(${FULLNAME_VAR} "${NAME_PREFIX}.c") + set(${CONTENT_VAR} "${OpenMP_C_CXX_${CONTENT_ID}}") elseif("${LANG}" STREQUAL "CXX") - set(SRC_FILE "${WORK_DIR}/${SRC_FILE_NAME}.cpp") - file(WRITE "${SRC_FILE}" "${OpenMP_C_CXX_${SRC_FILE_CONTENT_VAR}}") + set(${FULLNAME_VAR} "${NAME_PREFIX}.cpp") + set(${CONTENT_VAR} "${OpenMP_C_CXX_${CONTENT_ID}}") elseif("${LANG}" STREQUAL "Fortran") - set(SRC_FILE "${WORK_DIR}/${SRC_FILE_NAME}.f90") - file(WRITE "${SRC_FILE}_in" "${OpenMP_Fortran_${SRC_FILE_CONTENT_VAR}}") - configure_file("${SRC_FILE}_in" "${SRC_FILE}" @ONLY) + set(${FULLNAME_VAR} "${NAME_PREFIX}.F90") + string(CONFIGURE "${OpenMP_Fortran_${CONTENT_ID}}" ${CONTENT_VAR} @ONLY) endif() - set(${SRC_FILE_FULLPATH} "${SRC_FILE}" PARENT_SCOPE) -endfunction() +endmacro() include(${CMAKE_CURRENT_LIST_DIR}/CMakeParseImplicitLinkInfo.cmake) function(_OPENMP_GET_FLAGS LANG FLAG_MODE OPENMP_FLAG_VAR OPENMP_LIB_NAMES_VAR) _OPENMP_FLAG_CANDIDATES("${LANG}") - _OPENMP_WRITE_SOURCE_FILE("${LANG}" "TEST_SOURCE" OpenMPTryFlag _OPENMP_TEST_SRC) + _OPENMP_PREPARE_SOURCE("${LANG}" TEST_SOURCE OpenMPTryFlag + _OPENMP_TEST_SRC_NAME _OPENMP_TEST_SRC_CONTENT) unset(OpenMP_VERBOSE_COMPILE_OPTIONS) separate_arguments(OpenMP_VERBOSE_OPTIONS NATIVE_COMMAND "${CMAKE_${LANG}_VERBOSE_FLAG}") @@ -215,7 +213,7 @@ function(_OPENMP_GET_FLAGS LANG FLAG_MODE OPENMP_FLAG_VAR OPENMP_LIB_NAMES_VAR) endif() string(REGEX REPLACE "[-/=+]" "" OPENMP_PLAIN_FLAG "${OPENMP_FLAG}") try_compile( OpenMP_COMPILE_RESULT_${FLAG_MODE}_${OPENMP_PLAIN_FLAG} - SOURCES ${_OPENMP_TEST_SRC} + SOURCE_FROM_VAR "${_OPENMP_TEST_SRC_NAME}" _OPENMP_TEST_SRC_CONTENT CMAKE_FLAGS "-DCOMPILE_DEFINITIONS:STRING=${OPENMP_FLAGS_TEST}" LINK_LIBRARIES ${CMAKE_${LANG}_VERBOSE_FLAG} OUTPUT_VARIABLE OpenMP_TRY_COMPILE_OUTPUT @@ -313,7 +311,7 @@ function(_OPENMP_GET_FLAGS LANG FLAG_MODE OPENMP_FLAG_VAR OPENMP_LIB_NAMES_VAR) # explicitly add a search path if the header can't be found on the # default header search path already. try_compile( OpenMP_COMPILE_RESULT_${FLAG_MODE}_${OPENMP_PLAIN_FLAG} - SOURCES ${_OPENMP_TEST_SRC} + SOURCE_FROM_VAR "${_OPENMP_TEST_SRC_NAME}" _OPENMP_TEST_SRC_CONTENT CMAKE_FLAGS "-DCOMPILE_DEFINITIONS:STRING=${OPENMP_FLAGS_TEST}" LINK_LIBRARIES ${CMAKE_${LANG}_VERBOSE_FLAG} ${OpenMP_libomp_LIBRARY} OUTPUT_VARIABLE OpenMP_TRY_COMPILE_OUTPUT @@ -324,7 +322,7 @@ function(_OPENMP_GET_FLAGS LANG FLAG_MODE OPENMP_FLAG_VAR OPENMP_LIB_NAMES_VAR) set(OpenMP_${LANG}_INCLUDE_DIR "${OpenMP_${LANG}_INCLUDE_DIR}" PARENT_SCOPE) if(OpenMP_${LANG}_INCLUDE_DIR) try_compile( OpenMP_COMPILE_RESULT_${FLAG_MODE}_${OPENMP_PLAIN_FLAG} - SOURCES ${_OPENMP_TEST_SRC} + SOURCE_FROM_VAR "${_OPENMP_TEST_SRC_NAME}" _OPENMP_TEST_SRC_CONTENT CMAKE_FLAGS "-DCOMPILE_DEFINITIONS:STRING=${OPENMP_FLAGS_TEST}" "-DINCLUDE_DIRECTORIES:STRING=${OpenMP_${LANG}_INCLUDE_DIR}" LINK_LIBRARIES ${CMAKE_${LANG}_VERBOSE_FLAG} ${OpenMP_libomp_LIBRARY} @@ -347,7 +345,7 @@ function(_OPENMP_GET_FLAGS LANG FLAG_MODE OPENMP_FLAG_VAR OPENMP_LIB_NAMES_VAR) mark_as_advanced(OpenMP_libomp_LIBRARY) if(OpenMP_libomp_LIBRARY) try_compile( OpenMP_COMPILE_RESULT_${FLAG_MODE}_${OPENMP_PLAIN_FLAG} - SOURCES ${_OPENMP_TEST_SRC} + SOURCE_FROM_VAR "${_OPENMP_TEST_SRC_NAME}" _OPENMP_TEST_SRC_CONTENT CMAKE_FLAGS "-DCOMPILE_DEFINITIONS:STRING=${OPENMP_FLAGS_TEST}" LINK_LIBRARIES ${CMAKE_${LANG}_VERBOSE_FLAG} ${OpenMP_libomp_LIBRARY} OUTPUT_VARIABLE OpenMP_TRY_COMPILE_OUTPUT @@ -409,7 +407,8 @@ set(OpenMP_Fortran_CHECK_VERSION_SOURCE ") function(_OPENMP_GET_SPEC_DATE LANG SPEC_DATE) - _OPENMP_WRITE_SOURCE_FILE("${LANG}" "CHECK_VERSION_SOURCE" OpenMPCheckVersion _OPENMP_TEST_SRC) + _OPENMP_PREPARE_SOURCE("${LANG}" CHECK_VERSION_SOURCE OpenMPCheckVersion + _OPENMP_TEST_SRC_NAME _OPENMP_TEST_SRC_CONTENT) unset(_includeDirFlags) if(OpenMP_${LANG}_INCLUDE_DIR) @@ -419,10 +418,10 @@ function(_OPENMP_GET_SPEC_DATE LANG SPEC_DATE) set(BIN_FILE "${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/FindOpenMP/ompver_${LANG}.bin") string(REGEX REPLACE "[-/=+]" "" OPENMP_PLAIN_FLAG "${OPENMP_FLAG}") try_compile(OpenMP_SPECTEST_${LANG}_${OPENMP_PLAIN_FLAG} - SOURCES "${_OPENMP_TEST_SRC}" - CMAKE_FLAGS "-DCOMPILE_DEFINITIONS:STRING=${OpenMP_${LANG}_FLAGS}" ${_includeDirFlags} - COPY_FILE ${BIN_FILE} - OUTPUT_VARIABLE OpenMP_TRY_COMPILE_OUTPUT) + SOURCE_FROM_VAR "${_OPENMP_TEST_SRC_NAME}" _OPENMP_TEST_SRC_CONTENT + CMAKE_FLAGS "-DCOMPILE_DEFINITIONS:STRING=${OpenMP_${LANG}_FLAGS}" ${_includeDirFlags} + COPY_FILE "${BIN_FILE}" + OUTPUT_VARIABLE OpenMP_TRY_COMPILE_OUTPUT) if(${OpenMP_SPECTEST_${LANG}_${OPENMP_PLAIN_FLAG}}) file(STRINGS ${BIN_FILE} specstr LIMIT_COUNT 1 REGEX "INFO:OpenMP-date") diff --git a/Modules/FindThreads.cmake b/Modules/FindThreads.cmake index f9ffb40..7326ef9 100644 --- a/Modules/FindThreads.cmake +++ b/Modules/FindThreads.cmake @@ -129,13 +129,12 @@ macro(_threads_check_flag_pthread) elseif(NOT DEFINED THREADS_HAVE_PTHREAD_ARG) message(CHECK_START "Check if compiler accepts -pthread") if(CMAKE_C_COMPILER_LOADED) - set(_threads_src ${CMAKE_CURRENT_LIST_DIR}/CheckForPthreads.c) + set(_threads_src CheckForPthreads.c) elseif(CMAKE_CXX_COMPILER_LOADED) - set(_threads_src ${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/FindThreads/CheckForPthreads.cxx) - configure_file(${CMAKE_CURRENT_LIST_DIR}/CheckForPthreads.c "${_threads_src}" COPYONLY) + set(_threads_src CheckForPthreads.cxx) endif() try_compile(THREADS_HAVE_PTHREAD_ARG - SOURCES ${_threads_src} + SOURCE_FROM_FILE "${_threads_src}" "${CMAKE_CURRENT_LIST_DIR}/CheckForPthreads.c" CMAKE_FLAGS -DLINK_LIBRARIES:STRING=-pthread OUTPUT_VARIABLE _cmake_check_pthreads_output) diff --git a/Modules/Internal/CheckSourceCompiles.cmake b/Modules/Internal/CheckSourceCompiles.cmake index a4415c4..eadf3da 100644 --- a/Modules/Internal/CheckSourceCompiles.cmake +++ b/Modules/Internal/CheckSourceCompiles.cmake @@ -86,14 +86,13 @@ function(CMAKE_CHECK_SOURCE_COMPILES _lang _source _var) else() set(CHECK_${LANG}_SOURCE_COMPILES_ADD_INCLUDES) endif() - file(WRITE "${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeTmp/src.${_SRC_EXT}" - "${_source}\n") if(NOT CMAKE_REQUIRED_QUIET) message(CHECK_START "Performing Test ${_var}") endif() + string(APPEND _source "\n") try_compile(${_var} - SOURCES ${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeTmp/src.${_SRC_EXT} + SOURCE_FROM_VAR "src.${_SRC_EXT}" _source COMPILE_DEFINITIONS -D${_var} ${CMAKE_REQUIRED_DEFINITIONS} ${CHECK_${LANG}_SOURCE_COMPILES_ADD_LINK_OPTIONS} ${CHECK_${LANG}_SOURCE_COMPILES_ADD_LIBRARIES} diff --git a/Modules/Internal/CheckSourceRuns.cmake b/Modules/Internal/CheckSourceRuns.cmake index 4d58bb6..09c85c5 100644 --- a/Modules/Internal/CheckSourceRuns.cmake +++ b/Modules/Internal/CheckSourceRuns.cmake @@ -85,14 +85,13 @@ function(CMAKE_CHECK_SOURCE_RUNS _lang _source _var) else() set(CHECK_${_lang}_SOURCE_COMPILES_ADD_INCLUDES) endif() - file(WRITE "${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeTmp/src.${_SRC_EXT}" - "${_source}\n") if(NOT CMAKE_REQUIRED_QUIET) message(CHECK_START "Performing Test ${_var}") endif() + string(APPEND _source "\n") try_run(${_var}_EXITCODE ${_var}_COMPILED - SOURCES ${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeTmp/src.${_SRC_EXT} + SOURCE_FROM_VAR "src.${_SRC_EXT}" _source COMPILE_DEFINITIONS -D${_var} ${CMAKE_REQUIRED_DEFINITIONS} ${CHECK_${_lang}_SOURCE_COMPILES_ADD_LINK_OPTIONS} ${CHECK_${_lang}_SOURCE_COMPILES_ADD_LIBRARIES} diff --git a/Modules/Internal/FeatureTesting.cmake b/Modules/Internal/FeatureTesting.cmake index 0b10032..5c144ec 100644 --- a/Modules/Internal/FeatureTesting.cmake +++ b/Modules/Internal/FeatureTesting.cmake @@ -4,7 +4,7 @@ macro(_record_compiler_features lang compile_flags feature_list) string(TOLOWER ${lang} lang_lc) file(REMOVE "${CMAKE_BINARY_DIR}/CMakeFiles/feature_tests.bin") - file(WRITE "${CMAKE_BINARY_DIR}/CMakeFiles/feature_tests.${lang_lc}" " + set(_content " const char features[] = {\"\\n\"\n") get_property(known_features GLOBAL PROPERTY CMAKE_${lang}_KNOWN_FEATURES) @@ -16,10 +16,11 @@ macro(_record_compiler_features lang compile_flags feature_list) else() set(_feature_condition "#if ${_cmake_feature_test_${feature}}\n\"1\"\n#else\n\"0\"\n#endif\n") endif() - file(APPEND "${CMAKE_BINARY_DIR}/CMakeFiles/feature_tests.${lang_lc}" "\"${lang}_FEATURE:\"\n${_feature_condition}\"${feature}\\n\"\n") + string(APPEND _content + "\"${lang}_FEATURE:\"\n${_feature_condition}\"${feature}\\n\"\n") endif() endforeach() - file(APPEND "${CMAKE_BINARY_DIR}/CMakeFiles/feature_tests.${lang_lc}" + string(APPEND _content "\n};\n\nint main(int argc, char** argv) { (void)argv; return features[argc]; }\n") if(CMAKE_${lang}_LINK_WITH_STANDARD_COMPILE_OPTION) @@ -31,7 +32,7 @@ macro(_record_compiler_features lang compile_flags feature_list) endif() try_compile(CMAKE_${lang}_FEATURE_TEST - SOURCES "${CMAKE_BINARY_DIR}/CMakeFiles/feature_tests.${lang_lc}" + SOURCE_FROM_VAR "feature_tests.${lang_lc}" _content COMPILE_DEFINITIONS "${compile_flags}" LINK_LIBRARIES "${compile_flags_for_link}" OUTPUT_VARIABLE _output diff --git a/Modules/TestBigEndian.cmake b/Modules/TestBigEndian.cmake index e738d32..096c90c 100644 --- a/Modules/TestBigEndian.cmake +++ b/Modules/TestBigEndian.cmake @@ -77,19 +77,16 @@ macro(__TEST_BIG_ENDIAN_LEGACY_IMPL VARIABLE) endif() if(_test_language STREQUAL "CXX") - set(_test_file "${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeTmp/TestEndianess.cpp") + set(_test_file TestEndianess.cpp) else() - set(_test_file "${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeTmp/TestEndianess.c") + set(_test_file TestEndianess.c) endif() - configure_file("${CMAKE_ROOT}/Modules/TestEndianess.c.in" - ${_test_file} - @ONLY) - - file(READ ${_test_file} TEST_ENDIANESS_FILE_CONTENT) + file(READ "${CMAKE_ROOT}/Modules/TestEndianess.c.in" TEST_ENDIANESS_FILE_CONTENT) + string(CONFIGURE "${TEST_ENDIANESS_FILE_CONTENT}" TEST_ENDIANESS_FILE_CONTENT @ONLY) try_compile(HAVE_${VARIABLE} - SOURCES ${_test_file} + SOURCE_FROM_VAR "${_test_file}" TEST_ENDIANESS_FILE_CONTENT OUTPUT_VARIABLE OUTPUT COPY_FILE "${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/TestEndianess.bin" ) @@ -130,12 +127,12 @@ macro(__TEST_BIG_ENDIAN_LEGACY_IMPL VARIABLE) endif() file(APPEND ${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeOutput.log - "Determining if the system is big endian passed with the following output:\n${OUTPUT}\nTestEndianess.c:\n${TEST_ENDIANESS_FILE_CONTENT}\n\n") + "Determining if the system is big endian passed with the following output:\n${OUTPUT}\n${_test_file}:\n${TEST_ENDIANESS_FILE_CONTENT}\n\n") else() message(CHECK_FAIL "failed") file(APPEND ${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeError.log - "Determining if the system is big endian failed with the following output:\n${OUTPUT}\nTestEndianess.c:\n${TEST_ENDIANESS_FILE_CONTENT}\n\n") + "Determining if the system is big endian failed with the following output:\n${OUTPUT}\n${_test_file}:\n${TEST_ENDIANESS_FILE_CONTENT}\n\n") set(${VARIABLE}) endif() endif() diff --git a/Source/CMakeLists.txt b/Source/CMakeLists.txt index 32bd341..8f2a5cb 100644 --- a/Source/CMakeLists.txt +++ b/Source/CMakeLists.txt @@ -148,6 +148,7 @@ add_library( cmCMakePresetsGraphReadJSONConfigurePresets.cxx cmCMakePresetsGraphReadJSONPackagePresets.cxx cmCMakePresetsGraphReadJSONTestPresets.cxx + cmCMakePresetsGraphReadJSONWorkflowPresets.cxx cmCommandArgumentParserHelper.cxx cmCommonTargetGenerator.cxx cmCommonTargetGenerator.h diff --git a/Source/CMakeVersion.cmake b/Source/CMakeVersion.cmake index b9c72f1..0868d28 100644 --- a/Source/CMakeVersion.cmake +++ b/Source/CMakeVersion.cmake @@ -1,7 +1,7 @@ # CMake version number components. set(CMake_VERSION_MAJOR 3) set(CMake_VERSION_MINOR 24) -set(CMake_VERSION_PATCH 20220927) +set(CMake_VERSION_PATCH 20220929) #set(CMake_VERSION_RC 0) set(CMake_VERSION_IS_DIRTY 0) diff --git a/Source/cmCMakePresetsGraph.cxx b/Source/cmCMakePresetsGraph.cxx index 7fbcdab..fb3d042 100644 --- a/Source/cmCMakePresetsGraph.cxx +++ b/Source/cmCMakePresetsGraph.cxx @@ -44,6 +44,9 @@ using ConfigurePreset = cmCMakePresetsGraph::ConfigurePreset; using BuildPreset = cmCMakePresetsGraph::BuildPreset; using TestPreset = cmCMakePresetsGraph::TestPreset; using PackagePreset = cmCMakePresetsGraph::PackagePreset; +using WorkflowPreset = cmCMakePresetsGraph::WorkflowPreset; +template <typename T> +using PresetPair = cmCMakePresetsGraph::PresetPair<T>; using ExpandMacroResult = cmCMakePresetsGraphInternal::ExpandMacroResult; using MacroExpander = cmCMakePresetsGraphInternal::MacroExpander; @@ -324,6 +327,14 @@ bool ExpandMacros(const cmCMakePresetsGraph& graph, return true; } +bool ExpandMacros(const cmCMakePresetsGraph& /*graph*/, + const WorkflowPreset& /*preset*/, + cm::optional<WorkflowPreset>& /*out*/, + const std::vector<MacroExpander>& /*macroExpanders*/) +{ + return true; +} + template <class T> bool ExpandMacros(const cmCMakePresetsGraph& graph, const T& preset, cm::optional<T>& out) @@ -579,6 +590,42 @@ ExpandMacroResult ExpandMacro(std::string& out, return ExpandMacroResult::Error; } + +template <typename T> +ReadFileResult SetupWorkflowConfigurePreset( + const T& preset, const ConfigurePreset*& configurePreset) +{ + if (preset.ConfigurePreset != configurePreset->Name) { + return ReadFileResult::INVALID_WORKFLOW_STEPS; + } + return ReadFileResult::READ_OK; +} + +template <> +ReadFileResult SetupWorkflowConfigurePreset<ConfigurePreset>( + const ConfigurePreset& preset, const ConfigurePreset*& configurePreset) +{ + configurePreset = &preset; + return ReadFileResult::READ_OK; +} + +template <typename T> +ReadFileResult TryReachPresetFromWorkflow( + const WorkflowPreset& origin, + const std::map<std::string, PresetPair<T>>& presets, const std::string& name, + const ConfigurePreset*& configurePreset) +{ + auto it = presets.find(name); + if (it == presets.end()) { + return ReadFileResult::INVALID_WORKFLOW_STEPS; + } + if (!origin.OriginFile->ReachableFiles.count( + it->second.Unexpanded.OriginFile)) { + return ReadFileResult::WORKFLOW_STEP_UNREACHABLE_FROM_FILE; + } + return SetupWorkflowConfigurePreset<T>(it->second.Unexpanded, + configurePreset); +} } bool cmCMakePresetsGraphInternal::EqualsCondition::Evaluate( @@ -929,6 +976,19 @@ cmCMakePresetsGraph::PackagePreset::VisitPresetAfterInherit(int /* version */) return ReadFileResult::READ_OK; } +cmCMakePresetsGraph::ReadFileResult +cmCMakePresetsGraph::WorkflowPreset::VisitPresetInherit( + const cmCMakePresetsGraph::Preset& /*parentPreset*/) +{ + return ReadFileResult::READ_OK; +} + +cmCMakePresetsGraph::ReadFileResult +cmCMakePresetsGraph::WorkflowPreset::VisitPresetAfterInherit(int /* version */) +{ + return ReadFileResult::READ_OK; +} + std::string cmCMakePresetsGraph::GetFilename(const std::string& sourceDir) { return cmStrCat(sourceDir, "/CMakePresets.json"); @@ -992,6 +1052,7 @@ cmCMakePresetsGraph::ReadProjectPresetsInternal(bool allowNoFiles) CHECK_OK(ComputePresetInheritance(this->BuildPresets, *this)); CHECK_OK(ComputePresetInheritance(this->TestPresets, *this)); CHECK_OK(ComputePresetInheritance(this->PackagePresets, *this)); + CHECK_OK(ComputePresetInheritance(this->WorkflowPresets, *this)); for (auto& it : this->ConfigurePresets) { if (!ExpandMacros(*this, it.second.Unexpanded, it.second.Expanded)) { @@ -1071,6 +1132,55 @@ cmCMakePresetsGraph::ReadProjectPresetsInternal(bool allowNoFiles) } } + for (auto& it : this->WorkflowPresets) { + using Type = WorkflowPreset::WorkflowStep::Type; + + const ConfigurePreset* configurePreset = nullptr; + for (auto const& step : it.second.Unexpanded.Steps) { + if (configurePreset == nullptr && step.PresetType != Type::Configure) { + return ReadFileResult::INVALID_WORKFLOW_STEPS; + } + if (configurePreset != nullptr && step.PresetType == Type::Configure) { + return ReadFileResult::INVALID_WORKFLOW_STEPS; + } + + ReadFileResult result; + switch (step.PresetType) { + case Type::Configure: + result = TryReachPresetFromWorkflow( + it.second.Unexpanded, this->ConfigurePresets, step.PresetName, + configurePreset); + break; + case Type::Build: + result = TryReachPresetFromWorkflow( + it.second.Unexpanded, this->BuildPresets, step.PresetName, + configurePreset); + break; + case Type::Test: + result = + TryReachPresetFromWorkflow(it.second.Unexpanded, this->TestPresets, + step.PresetName, configurePreset); + break; + case Type::Package: + result = TryReachPresetFromWorkflow( + it.second.Unexpanded, this->PackagePresets, step.PresetName, + configurePreset); + break; + } + if (result != ReadFileResult::READ_OK) { + return result; + } + } + + if (configurePreset == nullptr) { + return ReadFileResult::INVALID_WORKFLOW_STEPS; + } + + if (!ExpandMacros(*this, it.second.Unexpanded, it.second.Expanded)) { + return ReadFileResult::INVALID_MACRO_EXPANSION; + } + } + return ReadFileResult::READ_OK; } @@ -1116,6 +1226,8 @@ const char* cmCMakePresetsGraph::ResultToString(ReadFileResult result) "support."; case ReadFileResult::PACKAGE_PRESETS_UNSUPPORTED: return "File version must be 6 or higher for package preset support"; + case ReadFileResult::WORKFLOW_PRESETS_UNSUPPORTED: + return "File version must be 6 or higher for workflow preset support"; case ReadFileResult::INCLUDE_UNSUPPORTED: return "File version must be 4 or higher for include support"; case ReadFileResult::INVALID_INCLUDE: @@ -1137,6 +1249,10 @@ const char* cmCMakePresetsGraph::ResultToString(ReadFileResult result) case ReadFileResult::TEST_OUTPUT_TRUNCATION_UNSUPPORTED: return "File version must be 5 or higher for testOutputTruncation " "preset support."; + case ReadFileResult::INVALID_WORKFLOW_STEPS: + return "Invalid workflow steps"; + case ReadFileResult::WORKFLOW_STEP_UNREACHABLE_FROM_FILE: + return "Workflow step is unreachable from preset's file"; } return "Unknown error"; @@ -1148,11 +1264,13 @@ void cmCMakePresetsGraph::ClearPresets() this->BuildPresets.clear(); this->TestPresets.clear(); this->PackagePresets.clear(); + this->WorkflowPresets.clear(); this->ConfigurePresetOrder.clear(); this->BuildPresetOrder.clear(); this->TestPresetOrder.clear(); this->PackagePresetOrder.clear(); + this->WorkflowPresetOrder.clear(); this->Files.clear(); } @@ -1291,6 +1409,26 @@ void cmCMakePresetsGraph::PrintPackagePresetList( } } +void cmCMakePresetsGraph::PrintWorkflowPresetList( + PrintPrecedingNewline* newline) const +{ + std::vector<const cmCMakePresetsGraph::Preset*> presets; + for (auto const& p : this->WorkflowPresetOrder) { + auto const& preset = this->WorkflowPresets.at(p); + if (!preset.Unexpanded.Hidden && preset.Expanded && + preset.Expanded->ConditionResult) { + presets.push_back( + static_cast<const cmCMakePresetsGraph::Preset*>(&preset.Unexpanded)); + } + } + + if (!presets.empty()) { + printPrecedingNewline(newline); + std::cout << "Available workflow presets:\n\n"; + cmCMakePresetsGraph::PrintPresets(presets); + } +} + void cmCMakePresetsGraph::PrintAllPresets() const { PrintPrecedingNewline newline = PrintPrecedingNewline::False; @@ -1298,4 +1436,5 @@ void cmCMakePresetsGraph::PrintAllPresets() const this->PrintBuildPresetList(&newline); this->PrintTestPresetList(&newline); this->PrintPackagePresetList(&newline); + this->PrintWorkflowPresetList(&newline); } diff --git a/Source/cmCMakePresetsGraph.h b/Source/cmCMakePresetsGraph.h index 806a36d..5b3e812 100644 --- a/Source/cmCMakePresetsGraph.h +++ b/Source/cmCMakePresetsGraph.h @@ -42,6 +42,7 @@ public: INVALID_MACRO_EXPANSION, BUILD_TEST_PRESETS_UNSUPPORTED, PACKAGE_PRESETS_UNSUPPORTED, + WORKFLOW_PRESETS_UNSUPPORTED, INCLUDE_UNSUPPORTED, INVALID_INCLUDE, INVALID_CONFIGURE_PRESET, @@ -51,6 +52,8 @@ public: TOOLCHAIN_FILE_UNSUPPORTED, CYCLIC_INCLUDE, TEST_OUTPUT_TRUNCATION_UNSUPPORTED, + INVALID_WORKFLOW_STEPS, + WORKFLOW_STEP_UNREACHABLE_FROM_FILE, }; std::string errors; @@ -97,7 +100,7 @@ public: std::string Name; std::vector<std::string> Inherits; - bool Hidden; + bool Hidden = false; File* OriginFile; std::string DisplayName; std::string Description; @@ -363,6 +366,43 @@ public: ReadFileResult VisitPresetAfterInherit(int /* version */) override; }; + class WorkflowPreset : public Preset + { + public: + WorkflowPreset() = default; + WorkflowPreset(WorkflowPreset&& /*other*/) = default; + WorkflowPreset(const WorkflowPreset& /*other*/) = default; + WorkflowPreset& operator=(const WorkflowPreset& /*other*/) = default; + ~WorkflowPreset() override = default; +#if __cplusplus >= 201703L || (defined(_MSVC_LANG) && _MSVC_LANG >= 201703L) + WorkflowPreset& operator=(WorkflowPreset&& /*other*/) = default; +#else + // The move assignment operators for several STL classes did not become + // noexcept until C++17, which causes some tools to warn about this move + // assignment operator throwing an exception when it shouldn't. + WorkflowPreset& operator=(WorkflowPreset&& /*other*/) = delete; +#endif + + class WorkflowStep + { + public: + enum class Type + { + Configure, + Build, + Test, + Package, + }; + Type PresetType; + std::string PresetName; + }; + + std::vector<WorkflowStep> Steps; + + ReadFileResult VisitPresetInherit(const Preset& parent) override; + ReadFileResult VisitPresetAfterInherit(int /* version */) override; + }; + template <class T> class PresetPair { @@ -375,11 +415,13 @@ public: std::map<std::string, PresetPair<BuildPreset>> BuildPresets; std::map<std::string, PresetPair<TestPreset>> TestPresets; std::map<std::string, PresetPair<PackagePreset>> PackagePresets; + std::map<std::string, PresetPair<WorkflowPreset>> WorkflowPresets; std::vector<std::string> ConfigurePresetOrder; std::vector<std::string> BuildPresetOrder; std::vector<std::string> TestPresetOrder; std::vector<std::string> PackagePresetOrder; + std::vector<std::string> WorkflowPresetOrder; std::string SourceDir; std::vector<std::unique_ptr<File>> Files; @@ -442,6 +484,7 @@ public: void PrintPackagePresetList( const std::function<bool(const PackagePreset&)>& filter, PrintPrecedingNewline* newline = nullptr) const; + void PrintWorkflowPresetList(PrintPrecedingNewline* newline = nullptr) const; void PrintAllPresets() const; private: diff --git a/Source/cmCMakePresetsGraphInternal.h b/Source/cmCMakePresetsGraphInternal.h index 40af356..9e47a69 100644 --- a/Source/cmCMakePresetsGraphInternal.h +++ b/Source/cmCMakePresetsGraphInternal.h @@ -151,6 +151,10 @@ cmCMakePresetsGraph::ReadFileResult PackagePresetsHelper( std::vector<cmCMakePresetsGraph::PackagePreset>& out, const Json::Value* value); +cmCMakePresetsGraph::ReadFileResult WorkflowPresetsHelper( + std::vector<cmCMakePresetsGraph::WorkflowPreset>& out, + const Json::Value* value); + cmJSONHelper<std::nullptr_t, cmCMakePresetsGraph::ReadFileResult> VendorHelper( cmCMakePresetsGraph::ReadFileResult error); diff --git a/Source/cmCMakePresetsGraphReadJSON.cxx b/Source/cmCMakePresetsGraphReadJSON.cxx index 4fba7d9..5aa4284 100644 --- a/Source/cmCMakePresetsGraphReadJSON.cxx +++ b/Source/cmCMakePresetsGraphReadJSON.cxx @@ -30,6 +30,8 @@ using CacheVariable = cmCMakePresetsGraph::CacheVariable; using ConfigurePreset = cmCMakePresetsGraph::ConfigurePreset; using BuildPreset = cmCMakePresetsGraph::BuildPreset; using TestPreset = cmCMakePresetsGraph::TestPreset; +using PackagePreset = cmCMakePresetsGraph::PackagePreset; +using WorkflowPreset = cmCMakePresetsGraph::WorkflowPreset; using ArchToolsetStrategy = cmCMakePresetsGraph::ArchToolsetStrategy; using JSONHelperBuilder = cmJSONHelperBuilder<ReadFileResult>; @@ -46,10 +48,11 @@ struct CMakeVersion struct RootPresets { CMakeVersion CMakeMinimumRequired; - std::vector<cmCMakePresetsGraph::ConfigurePreset> ConfigurePresets; - std::vector<cmCMakePresetsGraph::BuildPreset> BuildPresets; - std::vector<cmCMakePresetsGraph::TestPreset> TestPresets; - std::vector<cmCMakePresetsGraph::PackagePreset> PackagePresets; + std::vector<ConfigurePreset> ConfigurePresets; + std::vector<BuildPreset> BuildPresets; + std::vector<TestPreset> TestPresets; + std::vector<PackagePreset> PackagePresets; + std::vector<WorkflowPreset> WorkflowPresets; std::vector<std::string> Include; }; @@ -284,6 +287,8 @@ auto const RootPresetsHelper = cmCMakePresetsGraphInternal::TestPresetsHelper, false) .Bind("packagePresets"_s, &RootPresets::PackagePresets, cmCMakePresetsGraphInternal::PackagePresetsHelper, false) + .Bind("workflowPresets"_s, &RootPresets::WorkflowPresets, + cmCMakePresetsGraphInternal::WorkflowPresetsHelper, false) .Bind("cmakeMinimumRequired"_s, &RootPresets::CMakeMinimumRequired, CMakeVersionHelper, false) .Bind("include"_s, &RootPresets::Include, IncludeVectorHelper, false) @@ -466,6 +471,11 @@ cmCMakePresetsGraph::ReadFileResult cmCMakePresetsGraph::ReadJSONFile( return ReadFileResult::PACKAGE_PRESETS_UNSUPPORTED; } + // Support for workflow presets added in version 6. + if (v < 6 && root.isMember("workflowPresets")) { + return ReadFileResult::WORKFLOW_PRESETS_UNSUPPORTED; + } + // Support for include added in version 4. if (v < 4 && root.isMember("include")) { return ReadFileResult::INCLUDE_UNSUPPORTED; @@ -600,6 +610,25 @@ cmCMakePresetsGraph::ReadFileResult cmCMakePresetsGraph::ReadJSONFile( this->PackagePresetOrder.push_back(preset.Name); } + for (auto& preset : presets.WorkflowPresets) { + preset.OriginFile = file; + if (preset.Name.empty()) { + return ReadFileResult::INVALID_PRESET; + } + + PresetPair<WorkflowPreset> presetPair; + presetPair.Unexpanded = preset; + presetPair.Expanded = cm::nullopt; + if (!this->WorkflowPresets.emplace(preset.Name, presetPair).second) { + return ReadFileResult::DUPLICATE_PRESETS; + } + + // Support for conditions added in version 3, but this requires version 6 + // already, so no action needed. + + this->WorkflowPresetOrder.push_back(preset.Name); + } + auto const includeFile = [this, &inProgressFiles, file]( const std::string& include, RootType rootType2, ReadReason readReason2, diff --git a/Source/cmCMakePresetsGraphReadJSONWorkflowPresets.cxx b/Source/cmCMakePresetsGraphReadJSONWorkflowPresets.cxx new file mode 100644 index 0000000..33680a1 --- /dev/null +++ b/Source/cmCMakePresetsGraphReadJSONWorkflowPresets.cxx @@ -0,0 +1,95 @@ +/* Distributed under the OSI-approved BSD 3-Clause License. See accompanying + file Copyright.txt or https://cmake.org/licensing for details. */ +#include <cstddef> +#include <functional> +#include <string> +#include <vector> + +#include <cmext/string_view> + +#include <cm3p/json/value.h> + +#include "cmCMakePresetsGraph.h" +#include "cmCMakePresetsGraphInternal.h" +#include "cmJSONHelpers.h" + +namespace { +using ReadFileResult = cmCMakePresetsGraph::ReadFileResult; +using WorkflowPreset = cmCMakePresetsGraph::WorkflowPreset; + +ReadFileResult WorkflowStepTypeHelper(WorkflowPreset::WorkflowStep::Type& out, + const Json::Value* value) +{ + if (!value) { + return ReadFileResult::INVALID_PRESET; + } + + if (!value->isString()) { + return ReadFileResult::INVALID_PRESET; + } + + if (value->asString() == "configure") { + out = WorkflowPreset::WorkflowStep::Type::Configure; + return ReadFileResult::READ_OK; + } + + if (value->asString() == "build") { + out = WorkflowPreset::WorkflowStep::Type::Build; + return ReadFileResult::READ_OK; + } + + if (value->asString() == "test") { + out = WorkflowPreset::WorkflowStep::Type::Test; + return ReadFileResult::READ_OK; + } + + if (value->asString() == "package") { + out = WorkflowPreset::WorkflowStep::Type::Package; + return ReadFileResult::READ_OK; + } + + return ReadFileResult::INVALID_PRESET; +} + +auto const WorkflowStepHelper = + cmJSONHelperBuilder<ReadFileResult>::Object<WorkflowPreset::WorkflowStep>( + ReadFileResult::READ_OK, ReadFileResult::INVALID_PRESET, false) + .Bind("type"_s, &WorkflowPreset::WorkflowStep::PresetType, + WorkflowStepTypeHelper) + .Bind("name"_s, &WorkflowPreset::WorkflowStep::PresetName, + cmCMakePresetsGraphInternal::PresetStringHelper); + +auto const WorkflowStepsHelper = + cmJSONHelperBuilder<ReadFileResult>::Vector<WorkflowPreset::WorkflowStep>( + ReadFileResult::READ_OK, ReadFileResult::INVALID_PRESET, + WorkflowStepHelper); + +auto const WorkflowPresetHelper = + cmJSONHelperBuilder<ReadFileResult>::Object<WorkflowPreset>( + ReadFileResult::READ_OK, ReadFileResult::INVALID_PRESET, false) + .Bind("name"_s, &WorkflowPreset::Name, + cmCMakePresetsGraphInternal::PresetStringHelper) + .Bind<std::nullptr_t>("vendor"_s, nullptr, + cmCMakePresetsGraphInternal::VendorHelper( + ReadFileResult::INVALID_PRESET), + false) + .Bind("displayName"_s, &WorkflowPreset::DisplayName, + cmCMakePresetsGraphInternal::PresetStringHelper, false) + .Bind("description"_s, &WorkflowPreset::Description, + cmCMakePresetsGraphInternal::PresetStringHelper, false) + .Bind("steps"_s, &WorkflowPreset::Steps, WorkflowStepsHelper); +} + +namespace cmCMakePresetsGraphInternal { +cmCMakePresetsGraph::ReadFileResult WorkflowPresetsHelper( + std::vector<cmCMakePresetsGraph::WorkflowPreset>& out, + const Json::Value* value) +{ + static auto const helper = + cmJSONHelperBuilder<ReadFileResult>::Vector<WorkflowPreset>( + ReadFileResult::READ_OK, ReadFileResult::INVALID_PRESETS, + WorkflowPresetHelper); + + return helper(out, value); +} +} diff --git a/Source/cmGlobalVisualStudio11Generator.cxx b/Source/cmGlobalVisualStudio11Generator.cxx index 10dc258..086d3af 100644 --- a/Source/cmGlobalVisualStudio11Generator.cxx +++ b/Source/cmGlobalVisualStudio11Generator.cxx @@ -77,7 +77,7 @@ public: void GetDocumentation(cmDocumentationEntry& entry) const override { entry.Name = std::string(vs11generatorName) + " [arch]"; - entry.Brief = "Generates Visual Studio 2012 project files. " + entry.Brief = "Deprecated. Generates Visual Studio 2012 project files. " "Optional [arch] can be \"Win64\" or \"ARM\"."; } diff --git a/Source/cmGlobalVisualStudio7Generator.cxx b/Source/cmGlobalVisualStudio7Generator.cxx index 7bf3c3a..ff76762 100644 --- a/Source/cmGlobalVisualStudio7Generator.cxx +++ b/Source/cmGlobalVisualStudio7Generator.cxx @@ -303,6 +303,26 @@ void cmGlobalVisualStudio7Generator::Generate() this->CallVisualStudioMacro(MacroReload, GetSLNFile(this->LocalGenerators[0].get())); } + + if (this->Version == VSVersion::VS11 && + !this->CMakeInstance->GetIsInTryCompile()) { + std::string cmakeWarnVS11; + if (cmValue cached = this->CMakeInstance->GetState()->GetCacheEntryValue( + "CMAKE_WARN_VS11")) { + this->CMakeInstance->MarkCliAsUsed("CMAKE_WARN_VS11"); + cmakeWarnVS11 = *cached; + } else { + cmSystemTools::GetEnv("CMAKE_WARN_VS11", cmakeWarnVS11); + } + if (cmakeWarnVS11.empty() || !cmIsOff(cmakeWarnVS11)) { + this->CMakeInstance->IssueMessage( + MessageType::WARNING, + "The \"Visual Studio 11 2012\" generator is deprecated " + "and will be removed in a future version of CMake." + "\n" + "Add CMAKE_WARN_VS11=OFF to the cache to disable this warning."); + } + } } void cmGlobalVisualStudio7Generator::OutputSLNFile( diff --git a/Source/cmake.cxx b/Source/cmake.cxx index 28b25c1..8800792 100644 --- a/Source/cmake.cxx +++ b/Source/cmake.cxx @@ -23,6 +23,10 @@ #include <cmext/algorithm> #include <cmext/string_view> +#if !defined(CMAKE_BOOTSTRAP) && !defined(_WIN32) +# include <unistd.h> +#endif + #include "cmsys/FStream.hxx" #include "cmsys/Glob.hxx" #include "cmsys/RegularExpression.hxx" @@ -56,6 +60,7 @@ #include "cmSystemTools.h" #include "cmTarget.h" #include "cmTargetLinkLibraryType.h" +#include "cmUVProcessChain.h" #include "cmUtils.hxx" #include "cmVersionConfig.h" #include "cmWorkingDirectory.h" @@ -3662,6 +3667,210 @@ bool cmake::Open(const std::string& dir, bool dryRun) return gen->Open(dir, *cachedProjectName, dryRun); } +#if !defined(CMAKE_BOOTSTRAP) +template <typename T> +const T* cmake::FindPresetForWorkflow( + cm::static_string_view type, + const std::map<std::string, cmCMakePresetsGraph::PresetPair<T>>& presets, + const cmCMakePresetsGraph::WorkflowPreset::WorkflowStep& step) +{ + auto it = presets.find(step.PresetName); + if (it == presets.end()) { + cmSystemTools::Error(cmStrCat("No such ", type, " preset in ", + this->GetHomeDirectory(), ": \"", + step.PresetName, '"')); + return nullptr; + } + + if (it->second.Unexpanded.Hidden) { + cmSystemTools::Error(cmStrCat("Cannot use hidden ", type, " preset in ", + this->GetHomeDirectory(), ": \"", + step.PresetName, '"')); + return nullptr; + } + + if (!it->second.Expanded) { + cmSystemTools::Error(cmStrCat("Could not evaluate ", type, " preset \"", + step.PresetName, + "\": Invalid macro expansion")); + return nullptr; + } + + if (!it->second.Expanded->ConditionResult) { + cmSystemTools::Error(cmStrCat("Cannot use disabled ", type, " preset in ", + this->GetHomeDirectory(), ": \"", + step.PresetName, '"')); + return nullptr; + } + + return &*it->second.Expanded; +} + +std::function<int()> cmake::BuildWorkflowStep( + const std::vector<std::string>& args) +{ + cmUVProcessChainBuilder builder; + builder + .AddCommand(args) +# ifdef _WIN32 + .SetExternalStream(cmUVProcessChainBuilder::Stream_OUTPUT, _fileno(stdout)) + .SetExternalStream(cmUVProcessChainBuilder::Stream_ERROR, _fileno(stderr)); +# else + .SetExternalStream(cmUVProcessChainBuilder::Stream_OUTPUT, STDOUT_FILENO) + .SetExternalStream(cmUVProcessChainBuilder::Stream_ERROR, STDERR_FILENO); +# endif + return [builder]() -> int { + auto chain = builder.Start(); + chain.Wait(); + return static_cast<int>(chain.GetStatus().front()->ExitStatus); + }; +} +#endif + +int cmake::Workflow(const std::string& presetName, bool listPresets) +{ +#ifndef CMAKE_BOOTSTRAP + this->SetHomeDirectory(cmSystemTools::GetCurrentWorkingDirectory()); + this->SetHomeOutputDirectory(cmSystemTools::GetCurrentWorkingDirectory()); + + cmCMakePresetsGraph settingsFile; + auto result = settingsFile.ReadProjectPresets(this->GetHomeDirectory()); + if (result != cmCMakePresetsGraph::ReadFileResult::READ_OK) { + cmSystemTools::Error( + cmStrCat("Could not read presets from ", this->GetHomeDirectory(), ": ", + cmCMakePresetsGraph::ResultToString(result))); + return 1; + } + + if (listPresets) { + settingsFile.PrintWorkflowPresetList(); + return 0; + } + + auto presetPair = settingsFile.WorkflowPresets.find(presetName); + if (presetPair == settingsFile.WorkflowPresets.end()) { + cmSystemTools::Error(cmStrCat("No such workflow preset in ", + this->GetHomeDirectory(), ": \"", presetName, + '"')); + settingsFile.PrintWorkflowPresetList(); + return 1; + } + + if (presetPair->second.Unexpanded.Hidden) { + cmSystemTools::Error(cmStrCat("Cannot use hidden workflow preset in ", + this->GetHomeDirectory(), ": \"", presetName, + '"')); + settingsFile.PrintWorkflowPresetList(); + return 1; + } + + auto const& expandedPreset = presetPair->second.Expanded; + if (!expandedPreset) { + cmSystemTools::Error(cmStrCat("Could not evaluate workflow preset \"", + presetName, "\": Invalid macro expansion")); + settingsFile.PrintWorkflowPresetList(); + return 1; + } + + if (!expandedPreset->ConditionResult) { + cmSystemTools::Error(cmStrCat("Cannot use disabled workflow preset in ", + this->GetHomeDirectory(), ": \"", presetName, + '"')); + settingsFile.PrintWorkflowPresetList(); + return 1; + } + + struct CalculatedStep + { + int StepNumber; + cm::static_string_view Type; + std::string Name; + std::function<int()> Action; + + CalculatedStep(int stepNumber, cm::static_string_view type, + std::string name, std::function<int()> action) + : StepNumber(stepNumber) + , Type(type) + , Name(std::move(name)) + , Action(std::move(action)) + { + } + }; + + std::vector<CalculatedStep> steps; + steps.reserve(expandedPreset->Steps.size()); + int stepNumber = 1; + for (auto const& step : expandedPreset->Steps) { + switch (step.PresetType) { + case cmCMakePresetsGraph::WorkflowPreset::WorkflowStep::Type:: + Configure: { + auto const* configurePreset = this->FindPresetForWorkflow( + "configure"_s, settingsFile.ConfigurePresets, step); + if (!configurePreset) { + return 1; + } + steps.emplace_back( + stepNumber, "configure"_s, step.PresetName, + this->BuildWorkflowStep({ cmSystemTools::GetCMakeCommand(), + "--preset", step.PresetName })); + } break; + case cmCMakePresetsGraph::WorkflowPreset::WorkflowStep::Type::Build: { + auto const* buildPreset = this->FindPresetForWorkflow( + "build"_s, settingsFile.BuildPresets, step); + if (!buildPreset) { + return 1; + } + steps.emplace_back( + stepNumber, "build"_s, step.PresetName, + this->BuildWorkflowStep({ cmSystemTools::GetCMakeCommand(), + "--build", "--preset", step.PresetName })); + } break; + case cmCMakePresetsGraph::WorkflowPreset::WorkflowStep::Type::Test: { + auto const* testPreset = this->FindPresetForWorkflow( + "test"_s, settingsFile.TestPresets, step); + if (!testPreset) { + return 1; + } + steps.emplace_back( + stepNumber, "test"_s, step.PresetName, + this->BuildWorkflowStep({ cmSystemTools::GetCTestCommand(), + "--preset", step.PresetName })); + } break; + case cmCMakePresetsGraph::WorkflowPreset::WorkflowStep::Type::Package: { + auto const* packagePreset = this->FindPresetForWorkflow( + "package"_s, settingsFile.PackagePresets, step); + if (!packagePreset) { + return 1; + } + steps.emplace_back( + stepNumber, "package"_s, step.PresetName, + this->BuildWorkflowStep({ cmSystemTools::GetCPackCommand(), + "--preset", step.PresetName })); + } break; + } + stepNumber++; + } + + int stepResult; + bool first = true; + for (auto const& step : steps) { + if (!first) { + std::cout << "\n"; + } + std::cout << "Executing workflow step " << step.StepNumber << " of " + << steps.size() << ": " << step.Type << " preset \"" << step.Name + << "\"\n\n" + << std::flush; + if ((stepResult = step.Action()) != 0) { + return stepResult; + } + first = false; + } +#endif + + return 0; +} + void cmake::WatchUnusedCli(const std::string& var) { #ifndef CMAKE_BOOTSTRAP diff --git a/Source/cmake.h b/Source/cmake.h index 8c0fece..54d0bb5 100644 --- a/Source/cmake.h +++ b/Source/cmake.h @@ -16,6 +16,7 @@ #include <vector> #include <cm/string_view> +#include <cmext/string_view> #include "cmGeneratedFileStream.h" #include "cmInstalledFile.h" @@ -600,6 +601,9 @@ public: //! run the --open option bool Open(const std::string& dir, bool dryRun); + //! run the --workflow option + int Workflow(const std::string& presetName, bool listPresets); + void UnwatchUnusedCli(const std::string& var); void WatchUnusedCli(const std::string& var); @@ -740,6 +744,16 @@ private: void AppendExtraGeneratorsDocumentation(std::vector<cmDocumentationEntry>&); #if !defined(CMAKE_BOOTSTRAP) + template <typename T> + const T* FindPresetForWorkflow( + cm::static_string_view type, + const std::map<std::string, cmCMakePresetsGraph::PresetPair<T>>& presets, + const cmCMakePresetsGraph::WorkflowPreset::WorkflowStep& step); + + std::function<int()> BuildWorkflowStep(const std::vector<std::string>& args); +#endif + +#if !defined(CMAKE_BOOTSTRAP) std::unique_ptr<cmMakefileProfilingData> ProfilingOutput; #endif }; diff --git a/Source/cmakemain.cxx b/Source/cmakemain.cxx index 6f3d0eb..b754b72 100644 --- a/Source/cmakemain.cxx +++ b/Source/cmakemain.cxx @@ -911,6 +911,68 @@ int do_install(int ac, char const* const* av) #endif } +int do_workflow(int ac, char const* const* av) +{ +#ifdef CMAKE_BOOTSTRAP + std::cerr << "This cmake does not support --workflow\n"; + return -1; +#else + std::string presetName; + bool listPresets = false; + + using CommandArgument = + cmCommandLineArgument<bool(std::string const& value)>; + + std::vector<CommandArgument> arguments = { + CommandArgument{ "--preset", CommandArgument::Values::One, + CommandArgument::setToValue(presetName) }, + CommandArgument{ "--list-presets", CommandArgument::Values::Zero, + CommandArgument::setToTrue(listPresets) } + }; + + std::vector<std::string> inputArgs; + + inputArgs.reserve(ac - 2); + cm::append(inputArgs, av + 2, av + ac); + + decltype(inputArgs.size()) i = 0; + for (; i < inputArgs.size(); ++i) { + std::string const& arg = inputArgs[i]; + bool matched = false; + bool parsed = false; + for (auto const& m : arguments) { + matched = m.matches(arg); + if (matched) { + parsed = m.parse(arg, i, inputArgs); + break; + } + } + if (!(matched && parsed)) { + if (!matched) { + std::cerr << "Unknown argument " << arg << std::endl; + } + break; + } + } + + if (presetName.empty() && !listPresets) { + std::cerr << "TODO: Usage\n"; + return 1; + } + + cmake cm(cmake::RoleInternal, cmState::Project); + cmSystemTools::SetMessageCallback( + [&cm](const std::string& msg, const cmMessageMetadata& md) { + cmakemainMessageCallback(msg, md, &cm); + }); + cm.SetProgressCallback([&cm](const std::string& msg, float prog) { + cmakemainProgressCallback(msg, prog, &cm); + }); + + return cm.Workflow(presetName, listPresets); +#endif +} + int do_open(int ac, char const* const* av) { #ifdef CMAKE_BOOTSTRAP @@ -980,6 +1042,9 @@ int main(int ac, char const* const* av) if (strcmp(av[1], "--open") == 0) { return do_open(ac, av); } + if (strcmp(av[1], "--workflow") == 0) { + return do_workflow(ac, av); + } if (strcmp(av[1], "-E") == 0) { return do_command(ac, av, std::move(consoleBuf)); } diff --git a/Tests/CMakeLists.txt b/Tests/CMakeLists.txt index 934f054..da87213 100644 --- a/Tests/CMakeLists.txt +++ b/Tests/CMakeLists.txt @@ -39,6 +39,13 @@ set(ENV{HOME} \"${TEST_HOME}\") ") endif() +# Suppress generator deprecation warnings in test suite. +if(CMAKE_GENERATOR MATCHES "^Visual Studio 11 2012") + set(TEST_WARN_VS11_CODE "set(ENV{CMAKE_WARN_VS11} OFF)") +else() + set(TEST_WARN_VS11_CODE "") +endif() + # 3.9 or later provides a definitive answer to whether we are multi-config # through a global property. Prior to 3.9, CMAKE_CONFIGURATION_TYPES being set # is assumed to mean multi-config, but developers might modify it so it is diff --git a/Tests/EnforceConfig.cmake.in b/Tests/EnforceConfig.cmake.in index 10f8461..7722d7d 100644 --- a/Tests/EnforceConfig.cmake.in +++ b/Tests/EnforceConfig.cmake.in @@ -36,4 +36,4 @@ unset(ENV{CMAKE_GENERATOR_TOOLSET}) unset(ENV{CMAKE_EXPORT_COMPILE_COMMANDS}) @TEST_HOME_ENV_CODE@ -@TEST_WARN_VS10_CODE@ +@TEST_WARN_VS11_CODE@ diff --git a/Tests/RunCMake/CMakeLists.txt b/Tests/RunCMake/CMakeLists.txt index 2f5bc87..428bbff 100644 --- a/Tests/RunCMake/CMakeLists.txt +++ b/Tests/RunCMake/CMakeLists.txt @@ -295,6 +295,10 @@ if(UNIX AND "${CMAKE_GENERATOR}" MATCHES "Unix Makefiles|Ninja") add_RunCMake_test(CompilerChange) endif() add_RunCMake_test(CompilerNotFound) +if (APPLE AND CMAKE_C_COMPILER_ID MATCHES "Clang|GNU") + list(APPEND CompilerTest_ARGS -DCMake_TEST_OBJC=1) +endif() +add_RunCMake_test(CompilerTest) add_RunCMake_test(Configure -DMSVC_IDE=${MSVC_IDE}) add_RunCMake_test(DisallowedCommands) if("${CMAKE_GENERATOR}" MATCHES "Unix Makefiles|Ninja") @@ -1008,6 +1012,10 @@ add_RunCMake_test(CMakePresetsPackage -DPython_EXECUTABLE=${Python_EXECUTABLE} -DCMake_TEST_JSON_SCHEMA=${CMake_TEST_JSON_SCHEMA} ) +add_RunCMake_test(CMakePresetsWorkflow + -DPython_EXECUTABLE=${Python_EXECUTABLE} + -DCMake_TEST_JSON_SCHEMA=${CMake_TEST_JSON_SCHEMA} + ) add_RunCMake_test(VerifyHeaderSets) diff --git a/Tests/RunCMake/CMakePresets/DocumentationExampleListAllPresets-stdout.txt b/Tests/RunCMake/CMakePresets/DocumentationExampleListAllPresets-stdout.txt index b1fcc28..57b714d 100644 --- a/Tests/RunCMake/CMakePresets/DocumentationExampleListAllPresets-stdout.txt +++ b/Tests/RunCMake/CMakePresets/DocumentationExampleListAllPresets-stdout.txt @@ -15,4 +15,8 @@ Available test presets: Available package presets: + "default" + +Available workflow presets: + "default"$ diff --git a/Tests/RunCMake/CMakePresetsWorkflow/BadExitCode-result.txt b/Tests/RunCMake/CMakePresetsWorkflow/BadExitCode-result.txt new file mode 100644 index 0000000..45a4fb7 --- /dev/null +++ b/Tests/RunCMake/CMakePresetsWorkflow/BadExitCode-result.txt @@ -0,0 +1 @@ +8 diff --git a/Tests/RunCMake/CMakePresetsWorkflow/BadExitCode-stderr.txt b/Tests/RunCMake/CMakePresetsWorkflow/BadExitCode-stderr.txt new file mode 100644 index 0000000..0690c69 --- /dev/null +++ b/Tests/RunCMake/CMakePresetsWorkflow/BadExitCode-stderr.txt @@ -0,0 +1,4 @@ +^Errors while running CTest +Output from these tests are in: [^ +]*/Tests/RunCMake/CMakePresetsWorkflow/BadExitCode/build/Testing/Temporary/LastTest\.log +Use "--rerun-failed --output-on-failure" to re-run the failed cases verbosely\.$ diff --git a/Tests/RunCMake/CMakePresetsWorkflow/BadExitCode-stdout.txt b/Tests/RunCMake/CMakePresetsWorkflow/BadExitCode-stdout.txt new file mode 100644 index 0000000..2f23f88 --- /dev/null +++ b/Tests/RunCMake/CMakePresetsWorkflow/BadExitCode-stdout.txt @@ -0,0 +1,17 @@ +^Executing workflow step 1 of 4: configure preset "default" + +.*Testing the configure step at [^ +]*/Tests/RunCMake/CMakePresetsWorkflow/BadExitCode/build.* + +Executing workflow step 2 of 4: build preset "default" + +.*Testing the build step at [^ +]*[\\/]Tests[\\/]RunCMake[\\/]CMakePresetsWorkflow[\\/]BadExitCode[\\/]build.* + +Executing workflow step 3 of 4: test preset "default" + +.*Testing the test step at [^ +]*/Tests/RunCMake/CMakePresetsWorkflow/BadExitCode/build.* + +The following tests FAILED: +.* +1 - EchoTest \(Failed\)$ diff --git a/Tests/RunCMake/CMakePresetsWorkflow/BadExitCode.cmake b/Tests/RunCMake/CMakePresetsWorkflow/BadExitCode.cmake new file mode 100644 index 0000000..10b46e3 --- /dev/null +++ b/Tests/RunCMake/CMakePresetsWorkflow/BadExitCode.cmake @@ -0,0 +1,8 @@ +message(STATUS "Testing the configure step at ${CMAKE_BINARY_DIR}") + +add_custom_target(echo_test ALL COMMAND ${CMAKE_COMMAND} -E echo "Testing the build step at ${CMAKE_BINARY_DIR}") + +enable_testing() +add_test(NAME EchoTest COMMAND ${CMAKE_COMMAND} -P "${CMAKE_CURRENT_LIST_DIR}/BadExitCodeTest.cmake") + +include(CPack) diff --git a/Tests/RunCMake/CMakePresetsWorkflow/BadExitCodeTest.cmake b/Tests/RunCMake/CMakePresetsWorkflow/BadExitCodeTest.cmake new file mode 100644 index 0000000..59f683e --- /dev/null +++ b/Tests/RunCMake/CMakePresetsWorkflow/BadExitCodeTest.cmake @@ -0,0 +1 @@ +message(FATAL_ERROR " Testing the test step at ${CMAKE_BINARY_DIR}") diff --git a/Tests/RunCMake/CMakePresetsWorkflow/CMakeLists.txt.in b/Tests/RunCMake/CMakePresetsWorkflow/CMakeLists.txt.in new file mode 100644 index 0000000..129184a --- /dev/null +++ b/Tests/RunCMake/CMakePresetsWorkflow/CMakeLists.txt.in @@ -0,0 +1,3 @@ +cmake_minimum_required(VERSION 3.19) +project("@CASE_NAME@" NONE) +include("@CASE_SOURCE_DIR@/@CASE_NAME@.cmake") diff --git a/Tests/RunCMake/CMakePresetsWorkflow/ConfigureStepMismatch-result.txt b/Tests/RunCMake/CMakePresetsWorkflow/ConfigureStepMismatch-result.txt new file mode 100644 index 0000000..d00491f --- /dev/null +++ b/Tests/RunCMake/CMakePresetsWorkflow/ConfigureStepMismatch-result.txt @@ -0,0 +1 @@ +1 diff --git a/Tests/RunCMake/CMakePresetsWorkflow/ConfigureStepMismatch-stderr.txt b/Tests/RunCMake/CMakePresetsWorkflow/ConfigureStepMismatch-stderr.txt new file mode 100644 index 0000000..22ca94d --- /dev/null +++ b/Tests/RunCMake/CMakePresetsWorkflow/ConfigureStepMismatch-stderr.txt @@ -0,0 +1,2 @@ +^CMake Error: Could not read presets from [^ +]*/Tests/RunCMake/CMakePresetsWorkflow/ConfigureStepMismatch: Invalid workflow steps$ diff --git a/Tests/RunCMake/CMakePresetsWorkflow/ConfigureStepMismatch.json.in b/Tests/RunCMake/CMakePresetsWorkflow/ConfigureStepMismatch.json.in new file mode 100644 index 0000000..0864149 --- /dev/null +++ b/Tests/RunCMake/CMakePresetsWorkflow/ConfigureStepMismatch.json.in @@ -0,0 +1,32 @@ +{ + "version": 6, + "configurePresets": [ + { + "name": "default" + }, + { + "name": "mismatch" + } + ], + "buildPresets": [ + { + "name": "mismatch", + "configurePreset": "mismatch" + } + ], + "workflowPresets": [ + { + "name": "default", + "steps": [ + { + "type": "configure", + "name": "default" + }, + { + "type": "build", + "name": "mismatch" + } + ] + } + ] +} diff --git a/Tests/RunCMake/CommandLine/DeprecateVS10-WARN-ON.cmake b/Tests/RunCMake/CMakePresetsWorkflow/FirstStepNotConfigure-result.txt index e69de29..e69de29 100644 --- a/Tests/RunCMake/CommandLine/DeprecateVS10-WARN-ON.cmake +++ b/Tests/RunCMake/CMakePresetsWorkflow/FirstStepNotConfigure-result.txt diff --git a/Tests/RunCMake/CMakePresetsWorkflow/FirstStepNotConfigure-stderr.txt b/Tests/RunCMake/CMakePresetsWorkflow/FirstStepNotConfigure-stderr.txt new file mode 100644 index 0000000..cbfee5a --- /dev/null +++ b/Tests/RunCMake/CMakePresetsWorkflow/FirstStepNotConfigure-stderr.txt @@ -0,0 +1,2 @@ +^CMake Error: Could not read presets from [^ +]*/Tests/RunCMake/CMakePresetsWorkflow/FirstStepNotConfigure: Invalid workflow steps$ diff --git a/Tests/RunCMake/CMakePresetsWorkflow/FirstStepNotConfigure.json.in b/Tests/RunCMake/CMakePresetsWorkflow/FirstStepNotConfigure.json.in new file mode 100644 index 0000000..2c121a8 --- /dev/null +++ b/Tests/RunCMake/CMakePresetsWorkflow/FirstStepNotConfigure.json.in @@ -0,0 +1,27 @@ +{ + "version": 6, + "configurePresets": [ + { + "name": "default", + "binaryDir": "${sourceDir}/build", + "generator": "@RunCMake_GENERATOR@" + } + ], + "buildPresets": [ + { + "name": "default", + "configurePreset": "default" + } + ], + "workflowPresets": [ + { + "name": "default", + "steps": [ + { + "type": "build", + "name": "default" + } + ] + } + ] +} diff --git a/Tests/RunCMake/CMakePresetsWorkflow/Good-stdout.txt b/Tests/RunCMake/CMakePresetsWorkflow/Good-stdout.txt new file mode 100644 index 0000000..a04d7ea --- /dev/null +++ b/Tests/RunCMake/CMakePresetsWorkflow/Good-stdout.txt @@ -0,0 +1,19 @@ +^Executing workflow step 1 of 4: configure preset "default" + +.*Testing the configure step at [^ +]*/Tests/RunCMake/CMakePresetsWorkflow/Good/build.* + +Executing workflow step 2 of 4: build preset "default" + +.*Testing the build step at [^ +]*[\\/]Tests[\\/]RunCMake[\\/]CMakePresetsWorkflow[\\/]Good[\\/]build.* + +Executing workflow step 3 of 4: test preset "default" + +.*Testing the test step at [^ +]*/Tests/RunCMake/CMakePresetsWorkflow/Good/build.* + +Executing workflow step 4 of 4: package preset "default" + +.*Testing the package step at [^ +]*/Tests/RunCMake/CMakePresetsWorkflow/Good/build.* diff --git a/Tests/RunCMake/CMakePresetsWorkflow/Good.cmake b/Tests/RunCMake/CMakePresetsWorkflow/Good.cmake new file mode 100644 index 0000000..31ce7ff --- /dev/null +++ b/Tests/RunCMake/CMakePresetsWorkflow/Good.cmake @@ -0,0 +1,8 @@ +message(STATUS "Testing the configure step at ${CMAKE_BINARY_DIR}") + +add_custom_target(echo_test ALL COMMAND ${CMAKE_COMMAND} -E echo "Testing the build step at ${CMAKE_BINARY_DIR}") + +enable_testing() +add_test(NAME EchoTest COMMAND ${CMAKE_COMMAND} -E echo "Testing the test step at ${CMAKE_BINARY_DIR}") + +include(CPack) diff --git a/Tests/RunCMake/CMakePresetsWorkflow/Good.json.in b/Tests/RunCMake/CMakePresetsWorkflow/Good.json.in new file mode 100644 index 0000000..87e2936 --- /dev/null +++ b/Tests/RunCMake/CMakePresetsWorkflow/Good.json.in @@ -0,0 +1,87 @@ +{ + "version": 6, + "configurePresets": [ + { + "name": "default", + "binaryDir": "${sourceDir}/build", + "generator": "@RunCMake_GENERATOR@" + } + ], + "buildPresets": [ + { + "name": "default", + "configurePreset": "default", + "configuration": "Debug" + } + ], + "testPresets": [ + { + "name": "default", + "configurePreset": "default", + "output": { + "verbosity": "verbose" + }, + "configuration": "Debug" + } + ], + "packagePresets": [ + { + "name": "default", + "configurePreset": "default", + "generators": [ + "External" + ], + "variables": { + "CPACK_EXTERNAL_PACKAGE_SCRIPT": "${sourceDir}/cpack_staging.cmake" + }, + "configurations": ["Debug"] + } + ], + "workflowPresets": [ + { + "name": "Good", + "displayName": "Good Workflow Preset", + "description": "This workflow preset works properly.", + "vendor": {}, + "steps": [ + { + "type": "configure", + "name": "default" + }, + { + "type": "build", + "name": "default" + }, + { + "type": "test", + "name": "default" + }, + { + "type": "package", + "name": "default" + } + ] + }, + { + "name": "BadExitCode", + "steps": [ + { + "type": "configure", + "name": "default" + }, + { + "type": "build", + "name": "default" + }, + { + "type": "test", + "name": "default" + }, + { + "type": "package", + "name": "default" + } + ] + } + ] +} diff --git a/Tests/RunCMake/CMakePresetsWorkflow/GoodUser-stdout.txt b/Tests/RunCMake/CMakePresetsWorkflow/GoodUser-stdout.txt new file mode 100644 index 0000000..1014915 --- /dev/null +++ b/Tests/RunCMake/CMakePresetsWorkflow/GoodUser-stdout.txt @@ -0,0 +1,2 @@ +-- Testing the configure step at [^ +]*/Tests/RunCMake/CMakePresetsWorkflow/GoodUser/build diff --git a/Tests/RunCMake/CMakePresetsWorkflow/GoodUser.cmake b/Tests/RunCMake/CMakePresetsWorkflow/GoodUser.cmake new file mode 100644 index 0000000..9143e00 --- /dev/null +++ b/Tests/RunCMake/CMakePresetsWorkflow/GoodUser.cmake @@ -0,0 +1 @@ +message(STATUS "Testing the configure step at ${CMAKE_BINARY_DIR}") diff --git a/Tests/RunCMake/CMakePresetsWorkflow/GoodUser.json.in b/Tests/RunCMake/CMakePresetsWorkflow/GoodUser.json.in new file mode 100644 index 0000000..e71b4ea --- /dev/null +++ b/Tests/RunCMake/CMakePresetsWorkflow/GoodUser.json.in @@ -0,0 +1,14 @@ +{ + "version": 6, + "workflowPresets": [ + { + "name": "GoodUser", + "steps": [ + { + "type": "configure", + "name": "default" + } + ] + } + ] +} diff --git a/Tests/RunCMake/CMakePresetsWorkflow/ListPresets-stdout.txt b/Tests/RunCMake/CMakePresetsWorkflow/ListPresets-stdout.txt new file mode 100644 index 0000000..57f30a4 --- /dev/null +++ b/Tests/RunCMake/CMakePresetsWorkflow/ListPresets-stdout.txt @@ -0,0 +1,4 @@ +^Available workflow presets: + + "default" + "with-description" - With Description$ diff --git a/Tests/RunCMake/CMakePresetsWorkflow/ListPresets.json.in b/Tests/RunCMake/CMakePresetsWorkflow/ListPresets.json.in new file mode 100644 index 0000000..9a7d5a6 --- /dev/null +++ b/Tests/RunCMake/CMakePresetsWorkflow/ListPresets.json.in @@ -0,0 +1,30 @@ +{ + "version": 6, + "configurePresets": [ + { + "name": "default" + } + ], + "workflowPresets": [ + { + "name": "default", + "steps": [ + { + "type": "configure", + "name": "default" + } + ] + }, + { + "name": "with-description", + "displayName": "With Description", + "description": "This preset has a description.", + "steps": [ + { + "type": "configure", + "name": "default" + } + ] + } + ] +} diff --git a/Tests/RunCMake/CMakePresetsWorkflow/NoWorkflowSteps-result.txt b/Tests/RunCMake/CMakePresetsWorkflow/NoWorkflowSteps-result.txt new file mode 100644 index 0000000..d00491f --- /dev/null +++ b/Tests/RunCMake/CMakePresetsWorkflow/NoWorkflowSteps-result.txt @@ -0,0 +1 @@ +1 diff --git a/Tests/RunCMake/CMakePresetsWorkflow/NoWorkflowSteps-stderr.txt b/Tests/RunCMake/CMakePresetsWorkflow/NoWorkflowSteps-stderr.txt new file mode 100644 index 0000000..049ed6b --- /dev/null +++ b/Tests/RunCMake/CMakePresetsWorkflow/NoWorkflowSteps-stderr.txt @@ -0,0 +1,2 @@ +^CMake Error: Could not read presets from [^ +]*/Tests/RunCMake/CMakePresetsWorkflow/NoWorkflowSteps: Invalid workflow steps$ diff --git a/Tests/RunCMake/CMakePresetsWorkflow/NoWorkflowSteps.json.in b/Tests/RunCMake/CMakePresetsWorkflow/NoWorkflowSteps.json.in new file mode 100644 index 0000000..2757197 --- /dev/null +++ b/Tests/RunCMake/CMakePresetsWorkflow/NoWorkflowSteps.json.in @@ -0,0 +1,9 @@ +{ + "version": 6, + "workflowPresets": [ + { + "name": "default", + "steps": [] + } + ] +} diff --git a/Tests/RunCMake/CMakePresetsWorkflow/NonexistentStep-result.txt b/Tests/RunCMake/CMakePresetsWorkflow/NonexistentStep-result.txt new file mode 100644 index 0000000..d00491f --- /dev/null +++ b/Tests/RunCMake/CMakePresetsWorkflow/NonexistentStep-result.txt @@ -0,0 +1 @@ +1 diff --git a/Tests/RunCMake/CMakePresetsWorkflow/NonexistentStep-stderr.txt b/Tests/RunCMake/CMakePresetsWorkflow/NonexistentStep-stderr.txt new file mode 100644 index 0000000..c522b84 --- /dev/null +++ b/Tests/RunCMake/CMakePresetsWorkflow/NonexistentStep-stderr.txt @@ -0,0 +1,2 @@ +^CMake Error: Could not read presets from [^ +]*/Tests/RunCMake/CMakePresetsWorkflow/NonexistentStep: Invalid workflow steps$ diff --git a/Tests/RunCMake/CMakePresetsWorkflow/NonexistentStep.json.in b/Tests/RunCMake/CMakePresetsWorkflow/NonexistentStep.json.in new file mode 100644 index 0000000..235398b --- /dev/null +++ b/Tests/RunCMake/CMakePresetsWorkflow/NonexistentStep.json.in @@ -0,0 +1,14 @@ +{ + "version": 6, + "workflowPresets": [ + { + "name": "default", + "steps": [ + { + "type": "configure", + "name": "default" + } + ] + } + ] +} diff --git a/Tests/RunCMake/CMakePresetsWorkflow/RunCMakeTest.cmake b/Tests/RunCMake/CMakePresetsWorkflow/RunCMakeTest.cmake new file mode 100644 index 0000000..b89a11a --- /dev/null +++ b/Tests/RunCMake/CMakePresetsWorkflow/RunCMakeTest.cmake @@ -0,0 +1,79 @@ +include(RunCMake) + +# Presets do not support legacy VS generator name architecture suffix. +if(RunCMake_GENERATOR MATCHES "^(Visual Studio [0-9]+ [0-9]+) ") + set(RunCMake_GENERATOR "${CMAKE_MATCH_1}") +endif() + +function(run_cmake_workflow_presets name) + set(RunCMake_TEST_SOURCE_DIR "${RunCMake_BINARY_DIR}/${name}") + set(RunCMake_TEST_BINARY_DIR "${RunCMake_TEST_SOURCE_DIR}/build") + set(RunCMake_TEST_COMMAND_WORKING_DIRECTORY "${RunCMake_TEST_SOURCE_DIR}") + + set(RunCMake_TEST_NO_CLEAN TRUE) + + file(REMOVE_RECURSE "${RunCMake_TEST_SOURCE_DIR}") + file(MAKE_DIRECTORY "${RunCMake_TEST_SOURCE_DIR}") + + set(CASE_NAME "${name}") + set(CASE_SOURCE_DIR "${RunCMake_SOURCE_DIR}") + configure_file("${RunCMake_SOURCE_DIR}/CMakeLists.txt.in" "${RunCMake_TEST_SOURCE_DIR}/CMakeLists.txt" @ONLY) + + if(NOT CMakePresets_FILE) + set(CMakePresets_FILE "${RunCMake_SOURCE_DIR}/${name}.json.in") + endif() + if(EXISTS "${CMakePresets_FILE}") + configure_file("${CMakePresets_FILE}" "${RunCMake_TEST_SOURCE_DIR}/CMakePresets.json" @ONLY) + endif() + + if(NOT CMakeUserPresets_FILE) + set(CMakeUserPresets_FILE "${RunCMake_SOURCE_DIR}/${name}User.json.in") + endif() + if(EXISTS "${CMakeUserPresets_FILE}") + configure_file("${CMakeUserPresets_FILE}" "${RunCMake_TEST_SOURCE_DIR}/CMakeUserPresets.json" @ONLY) + endif() + + foreach(ASSET ${CMakePresets_ASSETS}) + configure_file("${RunCMake_SOURCE_DIR}/${ASSET}.in" "${RunCMake_TEST_SOURCE_DIR}/${ASSET}" @ONLY) + endforeach() + + if(EXISTS "${RunCMake_SOURCE_DIR}/${name}-check.cmake") + set(RunCMake-check-file "${name}-check.cmake") + else() + set(RunCMake-check-file "check.cmake") + endif() + + if(eq) + set(eq 0 PARENT_SCOPE) + set(preset_arg "--preset=${name}") + else() + set(eq 1 PARENT_SCOPE) + set(preset_arg "--preset" "${name}") + endif() + run_cmake_command("${name}" "${CMAKE_COMMAND}" "--workflow" ${preset_arg} ${ARGN}) +endfunction() + +set(CMakePresets_SCHEMA_EXPECTED_RESULT 1) +run_cmake_workflow_presets(UnsupportedVersion) +set(CMakePresets_SCHEMA_EXPECTED_RESULT 0) +run_cmake_workflow_presets(NoWorkflowSteps) +run_cmake_workflow_presets(FirstStepNotConfigure) +run_cmake_workflow_presets(SecondStepConfigure) +run_cmake_workflow_presets(NonexistentStep) +run_cmake_workflow_presets(UnreachableStep) +run_cmake_workflow_presets(WorkflowStepHidden) +run_cmake_workflow_presets(WorkflowStepDisabled) +run_cmake_workflow_presets(WorkflowStepInvalidMacro) +run_cmake_workflow_presets(ConfigureStepMismatch) + +set(CMakePresets_FILE "${RunCMake_SOURCE_DIR}/Good.json.in") +set(CMakeUserPresets_FILE "${RunCMake_SOURCE_DIR}/GoodUser.json.in") +set(CMakePresets_ASSETS cpack_staging.cmake) +run_cmake_workflow_presets(Good) +run_cmake_workflow_presets(GoodUser) +run_cmake_workflow_presets(BadExitCode) +unset(CMakePresets_FILE) +unset(CMakeUserPresets_FILE) +unset(CMakePresets_ASSETS) + +run_cmake_workflow_presets(ListPresets --list-presets) diff --git a/Tests/RunCMake/CMakePresetsWorkflow/SecondStepConfigure-result.txt b/Tests/RunCMake/CMakePresetsWorkflow/SecondStepConfigure-result.txt new file mode 100644 index 0000000..d00491f --- /dev/null +++ b/Tests/RunCMake/CMakePresetsWorkflow/SecondStepConfigure-result.txt @@ -0,0 +1 @@ +1 diff --git a/Tests/RunCMake/CMakePresetsWorkflow/SecondStepConfigure-stderr.txt b/Tests/RunCMake/CMakePresetsWorkflow/SecondStepConfigure-stderr.txt new file mode 100644 index 0000000..b0ad7d5 --- /dev/null +++ b/Tests/RunCMake/CMakePresetsWorkflow/SecondStepConfigure-stderr.txt @@ -0,0 +1,2 @@ +^CMake Error: Could not read presets from [^ +]*/Tests/RunCMake/CMakePresetsWorkflow/SecondStepConfigure: Invalid workflow steps$ diff --git a/Tests/RunCMake/CMakePresetsWorkflow/SecondStepConfigure.json.in b/Tests/RunCMake/CMakePresetsWorkflow/SecondStepConfigure.json.in new file mode 100644 index 0000000..44e1582 --- /dev/null +++ b/Tests/RunCMake/CMakePresetsWorkflow/SecondStepConfigure.json.in @@ -0,0 +1,25 @@ +{ + "version": 6, + "configurePresets": [ + { + "name": "default", + "binaryDir": "${sourceDir}/build", + "generator": "@RunCMake_GENERATOR@" + } + ], + "workflowPresets": [ + { + "name": "default", + "steps": [ + { + "type": "configure", + "name": "default" + }, + { + "type": "configure", + "name": "default" + } + ] + } + ] +} diff --git a/Tests/RunCMake/CMakePresetsWorkflow/UnreachableStep-result.txt b/Tests/RunCMake/CMakePresetsWorkflow/UnreachableStep-result.txt new file mode 100644 index 0000000..d00491f --- /dev/null +++ b/Tests/RunCMake/CMakePresetsWorkflow/UnreachableStep-result.txt @@ -0,0 +1 @@ +1 diff --git a/Tests/RunCMake/CMakePresetsWorkflow/UnreachableStep-stderr.txt b/Tests/RunCMake/CMakePresetsWorkflow/UnreachableStep-stderr.txt new file mode 100644 index 0000000..425e719 --- /dev/null +++ b/Tests/RunCMake/CMakePresetsWorkflow/UnreachableStep-stderr.txt @@ -0,0 +1,2 @@ +^CMake Error: Could not read presets from [^ +]*/Tests/RunCMake/CMakePresetsWorkflow/UnreachableStep: Workflow step is unreachable from preset's file$ diff --git a/Tests/RunCMake/CMakePresetsWorkflow/UnreachableStep.json.in b/Tests/RunCMake/CMakePresetsWorkflow/UnreachableStep.json.in new file mode 100644 index 0000000..235398b --- /dev/null +++ b/Tests/RunCMake/CMakePresetsWorkflow/UnreachableStep.json.in @@ -0,0 +1,14 @@ +{ + "version": 6, + "workflowPresets": [ + { + "name": "default", + "steps": [ + { + "type": "configure", + "name": "default" + } + ] + } + ] +} diff --git a/Tests/RunCMake/CMakePresetsWorkflow/UnreachableStepUser.json.in b/Tests/RunCMake/CMakePresetsWorkflow/UnreachableStepUser.json.in new file mode 100644 index 0000000..39b6835 --- /dev/null +++ b/Tests/RunCMake/CMakePresetsWorkflow/UnreachableStepUser.json.in @@ -0,0 +1,8 @@ +{ + "version": 6, + "configurePresets": [ + { + "name": "default" + } + ] +} diff --git a/Tests/RunCMake/CMakePresetsWorkflow/UnsupportedVersion-result.txt b/Tests/RunCMake/CMakePresetsWorkflow/UnsupportedVersion-result.txt new file mode 100644 index 0000000..d00491f --- /dev/null +++ b/Tests/RunCMake/CMakePresetsWorkflow/UnsupportedVersion-result.txt @@ -0,0 +1 @@ +1 diff --git a/Tests/RunCMake/CMakePresetsWorkflow/UnsupportedVersion-stderr.txt b/Tests/RunCMake/CMakePresetsWorkflow/UnsupportedVersion-stderr.txt new file mode 100644 index 0000000..5cf01aa --- /dev/null +++ b/Tests/RunCMake/CMakePresetsWorkflow/UnsupportedVersion-stderr.txt @@ -0,0 +1,2 @@ +^CMake Error: Could not read presets from [^ +]*/Tests/RunCMake/CMakePresetsWorkflow/UnsupportedVersion: File version must be 6 or higher for workflow preset support$ diff --git a/Tests/RunCMake/CMakePresetsWorkflow/UnsupportedVersion.json.in b/Tests/RunCMake/CMakePresetsWorkflow/UnsupportedVersion.json.in new file mode 100644 index 0000000..4ebaa8e --- /dev/null +++ b/Tests/RunCMake/CMakePresetsWorkflow/UnsupportedVersion.json.in @@ -0,0 +1,4 @@ +{ + "version": 5, + "workflowPresets": [] +} diff --git a/Tests/RunCMake/CMakePresetsWorkflow/WorkflowStepDisabled-result.txt b/Tests/RunCMake/CMakePresetsWorkflow/WorkflowStepDisabled-result.txt new file mode 100644 index 0000000..d00491f --- /dev/null +++ b/Tests/RunCMake/CMakePresetsWorkflow/WorkflowStepDisabled-result.txt @@ -0,0 +1 @@ +1 diff --git a/Tests/RunCMake/CMakePresetsWorkflow/WorkflowStepDisabled-stderr.txt b/Tests/RunCMake/CMakePresetsWorkflow/WorkflowStepDisabled-stderr.txt new file mode 100644 index 0000000..b598b27 --- /dev/null +++ b/Tests/RunCMake/CMakePresetsWorkflow/WorkflowStepDisabled-stderr.txt @@ -0,0 +1,2 @@ +^CMake Error: Cannot use disabled configure preset in [^ +]*/Tests/RunCMake/CMakePresetsWorkflow/WorkflowStepDisabled: "default"$ diff --git a/Tests/RunCMake/CMakePresetsWorkflow/WorkflowStepDisabled.json.in b/Tests/RunCMake/CMakePresetsWorkflow/WorkflowStepDisabled.json.in new file mode 100644 index 0000000..a3b6783 --- /dev/null +++ b/Tests/RunCMake/CMakePresetsWorkflow/WorkflowStepDisabled.json.in @@ -0,0 +1,23 @@ +{ + "version": 6, + "configurePresets": [ + { + "name": "default", + "condition": { + "type": "const", + "value": false + } + } + ], + "workflowPresets": [ + { + "name": "WorkflowStepDisabled", + "steps": [ + { + "type": "configure", + "name": "default" + } + ] + } + ] +} diff --git a/Tests/RunCMake/CMakePresetsWorkflow/WorkflowStepHidden-result.txt b/Tests/RunCMake/CMakePresetsWorkflow/WorkflowStepHidden-result.txt new file mode 100644 index 0000000..d00491f --- /dev/null +++ b/Tests/RunCMake/CMakePresetsWorkflow/WorkflowStepHidden-result.txt @@ -0,0 +1 @@ +1 diff --git a/Tests/RunCMake/CMakePresetsWorkflow/WorkflowStepHidden-stderr.txt b/Tests/RunCMake/CMakePresetsWorkflow/WorkflowStepHidden-stderr.txt new file mode 100644 index 0000000..838ded5 --- /dev/null +++ b/Tests/RunCMake/CMakePresetsWorkflow/WorkflowStepHidden-stderr.txt @@ -0,0 +1,2 @@ +^CMake Error: Cannot use hidden configure preset in [^ +]*/Tests/RunCMake/CMakePresetsWorkflow/WorkflowStepHidden: "default"$ diff --git a/Tests/RunCMake/CMakePresetsWorkflow/WorkflowStepHidden.json.in b/Tests/RunCMake/CMakePresetsWorkflow/WorkflowStepHidden.json.in new file mode 100644 index 0000000..07c4105 --- /dev/null +++ b/Tests/RunCMake/CMakePresetsWorkflow/WorkflowStepHidden.json.in @@ -0,0 +1,20 @@ +{ + "version": 6, + "configurePresets": [ + { + "name": "default", + "hidden": true + } + ], + "workflowPresets": [ + { + "name": "WorkflowStepHidden", + "steps": [ + { + "type": "configure", + "name": "default" + } + ] + } + ] +} diff --git a/Tests/RunCMake/CMakePresetsWorkflow/WorkflowStepInvalidMacro-result.txt b/Tests/RunCMake/CMakePresetsWorkflow/WorkflowStepInvalidMacro-result.txt new file mode 100644 index 0000000..d00491f --- /dev/null +++ b/Tests/RunCMake/CMakePresetsWorkflow/WorkflowStepInvalidMacro-result.txt @@ -0,0 +1 @@ +1 diff --git a/Tests/RunCMake/CMakePresetsWorkflow/WorkflowStepInvalidMacro-stderr.txt b/Tests/RunCMake/CMakePresetsWorkflow/WorkflowStepInvalidMacro-stderr.txt new file mode 100644 index 0000000..f132a93 --- /dev/null +++ b/Tests/RunCMake/CMakePresetsWorkflow/WorkflowStepInvalidMacro-stderr.txt @@ -0,0 +1 @@ +^CMake Error: Could not evaluate configure preset "default": Invalid macro expansion$ diff --git a/Tests/RunCMake/CMakePresetsWorkflow/WorkflowStepInvalidMacro.json.in b/Tests/RunCMake/CMakePresetsWorkflow/WorkflowStepInvalidMacro.json.in new file mode 100644 index 0000000..6aec0e3 --- /dev/null +++ b/Tests/RunCMake/CMakePresetsWorkflow/WorkflowStepInvalidMacro.json.in @@ -0,0 +1,20 @@ +{ + "version": 6, + "configurePresets": [ + { + "name": "default", + "binaryDir": "$vendor{invalidMacro}" + } + ], + "workflowPresets": [ + { + "name": "WorkflowStepInvalidMacro", + "steps": [ + { + "type": "configure", + "name": "default" + } + ] + } + ] +} diff --git a/Tests/RunCMake/CMakePresetsWorkflow/check.cmake b/Tests/RunCMake/CMakePresetsWorkflow/check.cmake new file mode 100644 index 0000000..e79c4f1 --- /dev/null +++ b/Tests/RunCMake/CMakePresetsWorkflow/check.cmake @@ -0,0 +1,3 @@ +set(CMakePresets_VALIDATE_SCRIPT_PATH "${RunCMake_SOURCE_DIR}/../CMakePresets/validate_schema.py") +include("${RunCMake_SOURCE_DIR}/../CMakePresets/validate_schema.cmake") +include("${RunCMake_SOURCE_DIR}/../CMakePresets/check.cmake") diff --git a/Tests/RunCMake/CMakePresetsWorkflow/cpack_staging.cmake.in b/Tests/RunCMake/CMakePresetsWorkflow/cpack_staging.cmake.in new file mode 100644 index 0000000..4030dfb --- /dev/null +++ b/Tests/RunCMake/CMakePresetsWorkflow/cpack_staging.cmake.in @@ -0,0 +1 @@ +message(STATUS "Testing the package step at @RunCMake_TEST_BINARY_DIR@") diff --git a/Tests/RunCMake/CommandLine/DeprecateVS10-WARN-OFF.cmake b/Tests/RunCMake/CommandLine/DeprecateVS11-WARN-OFF.cmake index e69de29..e69de29 100644 --- a/Tests/RunCMake/CommandLine/DeprecateVS10-WARN-OFF.cmake +++ b/Tests/RunCMake/CommandLine/DeprecateVS11-WARN-OFF.cmake diff --git a/Tests/RunCMake/CommandLine/DeprecateVS11-WARN-ON-stderr.txt b/Tests/RunCMake/CommandLine/DeprecateVS11-WARN-ON-stderr.txt new file mode 100644 index 0000000..9080942 --- /dev/null +++ b/Tests/RunCMake/CommandLine/DeprecateVS11-WARN-ON-stderr.txt @@ -0,0 +1,5 @@ +^CMake Warning: + The "Visual Studio 11 2012" generator is deprecated and will be removed in + a future version of CMake. + + Add CMAKE_WARN_VS11=OFF to the cache to disable this warning.$ diff --git a/Tests/RunCMake/CommandLine/DeprecateVS11-WARN-ON.cmake b/Tests/RunCMake/CommandLine/DeprecateVS11-WARN-ON.cmake new file mode 100644 index 0000000..e69de29 --- /dev/null +++ b/Tests/RunCMake/CommandLine/DeprecateVS11-WARN-ON.cmake diff --git a/Tests/RunCMake/CommandLine/RunCMakeTest.cmake b/Tests/RunCMake/CommandLine/RunCMakeTest.cmake index dc61759..a2eeddf 100644 --- a/Tests/RunCMake/CommandLine/RunCMakeTest.cmake +++ b/Tests/RunCMake/CommandLine/RunCMakeTest.cmake @@ -1071,3 +1071,10 @@ set(ProfilingTestOutput ${RunCMake_TEST_BINARY_DIR}/output.json) set(RunCMake_TEST_OPTIONS --profiling-format=google-trace --profiling-output=${ProfilingTestOutput}) run_cmake(ProfilingTest) unset(RunCMake_TEST_OPTIONS) + +if(RunCMake_GENERATOR MATCHES "^Visual Studio 11 2012") + run_cmake_with_options(DeprecateVS11-WARN-ON -DCMAKE_WARN_VS11=ON) + unset(ENV{CMAKE_WARN_VS11}) + run_cmake(DeprecateVS11-WARN-ON) + run_cmake_with_options(DeprecateVS11-WARN-OFF -DCMAKE_WARN_VS11=OFF) +endif() diff --git a/Tests/RunCMake/CompilerTest/C-stdout.txt b/Tests/RunCMake/CompilerTest/C-stdout.txt new file mode 100644 index 0000000..ce5d80e --- /dev/null +++ b/Tests/RunCMake/CompilerTest/C-stdout.txt @@ -0,0 +1,2 @@ +-- Check for working C compiler: [^ +]* - works diff --git a/Tests/RunCMake/CompilerTest/C.cmake b/Tests/RunCMake/CompilerTest/C.cmake new file mode 100644 index 0000000..8e9d70c --- /dev/null +++ b/Tests/RunCMake/CompilerTest/C.cmake @@ -0,0 +1,3 @@ +# Pretend the ABI check failed in order to force the fall-back test to run. +set(CMAKE_C_ABI_COMPILED FALSE) +enable_language(C) diff --git a/Tests/RunCMake/CompilerTest/CMakeLists.txt b/Tests/RunCMake/CompilerTest/CMakeLists.txt new file mode 100644 index 0000000..aba1016 --- /dev/null +++ b/Tests/RunCMake/CompilerTest/CMakeLists.txt @@ -0,0 +1,3 @@ +cmake_minimum_required(VERSION 3.24) +project(${RunCMake_TEST} NONE) +include(${RunCMake_TEST}.cmake) diff --git a/Tests/RunCMake/CompilerTest/CXX-stdout.txt b/Tests/RunCMake/CompilerTest/CXX-stdout.txt new file mode 100644 index 0000000..513fd85 --- /dev/null +++ b/Tests/RunCMake/CompilerTest/CXX-stdout.txt @@ -0,0 +1,2 @@ +-- Check for working CXX compiler: [^ +]* - works diff --git a/Tests/RunCMake/CompilerTest/CXX.cmake b/Tests/RunCMake/CompilerTest/CXX.cmake new file mode 100644 index 0000000..e17cc9d --- /dev/null +++ b/Tests/RunCMake/CompilerTest/CXX.cmake @@ -0,0 +1,3 @@ +# Pretend the ABI check failed in order to force the fall-back test to run. +set(CMAKE_CXX_ABI_COMPILED FALSE) +enable_language(CXX) diff --git a/Tests/RunCMake/CompilerTest/OBJC-stdout.txt b/Tests/RunCMake/CompilerTest/OBJC-stdout.txt new file mode 100644 index 0000000..23f5120 --- /dev/null +++ b/Tests/RunCMake/CompilerTest/OBJC-stdout.txt @@ -0,0 +1,2 @@ +-- Check for working OBJC compiler: [^ +]* - works diff --git a/Tests/RunCMake/CompilerTest/OBJC.cmake b/Tests/RunCMake/CompilerTest/OBJC.cmake new file mode 100644 index 0000000..5ec842c --- /dev/null +++ b/Tests/RunCMake/CompilerTest/OBJC.cmake @@ -0,0 +1,3 @@ +# Pretend the ABI check failed in order to force the fall-back test to run. +set(CMAKE_OBJC_ABI_COMPILED FALSE) +enable_language(OBJC) diff --git a/Tests/RunCMake/CompilerTest/OBJCXX-stdout.txt b/Tests/RunCMake/CompilerTest/OBJCXX-stdout.txt new file mode 100644 index 0000000..8291904 --- /dev/null +++ b/Tests/RunCMake/CompilerTest/OBJCXX-stdout.txt @@ -0,0 +1,2 @@ +-- Check for working OBJCXX compiler: [^ +]* - works diff --git a/Tests/RunCMake/CompilerTest/OBJCXX.cmake b/Tests/RunCMake/CompilerTest/OBJCXX.cmake new file mode 100644 index 0000000..49df0aa --- /dev/null +++ b/Tests/RunCMake/CompilerTest/OBJCXX.cmake @@ -0,0 +1,3 @@ +# Pretend the ABI check failed in order to force the fall-back test to run. +set(CMAKE_OBJCXX_ABI_COMPILED FALSE) +enable_language(OBJCXX) diff --git a/Tests/RunCMake/CompilerTest/RunCMakeTest.cmake b/Tests/RunCMake/CompilerTest/RunCMakeTest.cmake new file mode 100644 index 0000000..995296a --- /dev/null +++ b/Tests/RunCMake/CompilerTest/RunCMakeTest.cmake @@ -0,0 +1,9 @@ +include(RunCMake) + +run_cmake(C) +run_cmake(CXX) + +if(CMake_TEST_OBJC) + run_cmake(OBJC) + run_cmake(OBJCXX) +endif() |