summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--.gitlab/.gitignore16
-rw-r--r--Help/guide/tutorial/Adding Export Configuration.rst2
-rw-r--r--Help/guide/tutorial/Adding Generator Expressions.rst1
-rw-r--r--Help/guide/tutorial/Adding System Introspection.rst2
-rw-r--r--Help/guide/tutorial/Adding a Custom Command and Generated File.rst2
-rw-r--r--Help/guide/tutorial/Complete/MathFunctions/CMakeLists.txt3
-rw-r--r--Help/guide/tutorial/Installing and Testing.rst313
-rw-r--r--Help/guide/tutorial/Packaging Debug and Release.rst2
-rw-r--r--Help/guide/tutorial/Step10/MathFunctions/CMakeLists.txt3
-rw-r--r--Help/guide/tutorial/Step11/MathFunctions/CMakeLists.txt3
-rw-r--r--Help/guide/tutorial/Step12/MathFunctions/CMakeLists.txt3
-rw-r--r--Help/guide/tutorial/Step5/CMakeLists.txt24
-rw-r--r--Help/guide/tutorial/Step5/MathFunctions/CMakeLists.txt8
-rw-r--r--Help/guide/tutorial/Step6/MathFunctions/CMakeLists.txt3
-rw-r--r--Help/guide/tutorial/Step7/MathFunctions/CMakeLists.txt3
-rw-r--r--Help/guide/tutorial/Step8/MathFunctions/CMakeLists.txt3
-rw-r--r--Help/guide/tutorial/Step9/MathFunctions/CMakeLists.txt3
-rw-r--r--Help/manual/cmake.1.rst5
-rw-r--r--Help/release/dev/try_compile-signatures.rst5
-rw-r--r--Modules/CPackIFW.cmake1
-rw-r--r--Source/CMakeVersion.cmake2
-rw-r--r--Source/cmCoreTryCompile.cxx7
-rw-r--r--Source/cmFileCommand.cxx20
-rw-r--r--Source/cmFileCopier.cxx44
-rw-r--r--Source/cmQtAutoGenInitializer.cxx22
-rw-r--r--Source/cmQtAutoGenInitializer.h2
-rw-r--r--Source/cmSystemTools.cxx43
-rw-r--r--Source/cmSystemTools.h10
-rw-r--r--Source/cmcmd.cxx7
-rw-r--r--Tests/CMakeLists.txt8
-rw-r--r--Tests/CMakeTests/CMakeLists.txt15
-rw-r--r--Tests/CMakeTests/CheckSourceTreeTest.cmake.in365
-rw-r--r--Tests/CheckSourceTree/CMakeLists.txt6
-rw-r--r--Tests/CheckSourceTree/check.cmake22
-rw-r--r--Tests/RunCMake/CheckCompilerFlag/CheckCCompilerFlag.cmake38
-rw-r--r--Tests/RunCMake/CheckCompilerFlag/CheckCXXCompilerFlag.cmake27
-rw-r--r--Tests/RunCMake/CheckCompilerFlag/CheckCompilerFlagC.cmake33
-rw-r--r--Tests/RunCMake/CheckCompilerFlag/CheckCompilerFlagCUDA.cmake (renamed from Tests/RunCMake/CheckCompilerFlag/CheckCUDACompilerFlag.cmake)0
-rw-r--r--Tests/RunCMake/CheckCompilerFlag/CheckCompilerFlagCXX.cmake26
-rw-r--r--Tests/RunCMake/CheckCompilerFlag/CheckCompilerFlagFortran.cmake (renamed from Tests/RunCMake/CheckCompilerFlag/CheckFortranCompilerFlag.cmake)0
-rw-r--r--Tests/RunCMake/CheckCompilerFlag/CheckCompilerFlagHIP.cmake (renamed from Tests/RunCMake/CheckCompilerFlag/CheckHIPCompilerFlag.cmake)0
-rw-r--r--Tests/RunCMake/CheckCompilerFlag/CheckCompilerFlagISPC.cmake (renamed from Tests/RunCMake/CheckCompilerFlag/CheckISPCCompilerFlag.cmake)0
-rw-r--r--Tests/RunCMake/CheckCompilerFlag/CheckCompilerFlagOBJC.cmake (renamed from Tests/RunCMake/CheckCompilerFlag/CheckOBJCCompilerFlag.cmake)0
-rw-r--r--Tests/RunCMake/CheckCompilerFlag/CheckCompilerFlagOBJCXX.cmake (renamed from Tests/RunCMake/CheckCompilerFlag/CheckOBJCXXCompilerFlag.cmake)0
-rw-r--r--Tests/RunCMake/CheckCompilerFlag/RunCMakeTest.cmake16
-rw-r--r--Tests/RunCMake/CheckLinkerFlag/CheckLinkerFlagC.cmake (renamed from Tests/RunCMake/CheckLinkerFlag/CheckCLinkerFlag.cmake)0
-rw-r--r--Tests/RunCMake/CheckLinkerFlag/CheckLinkerFlagCUDA.cmake (renamed from Tests/RunCMake/CheckLinkerFlag/CheckCUDALinkerFlag.cmake)0
-rw-r--r--Tests/RunCMake/CheckLinkerFlag/CheckLinkerFlagCXX.cmake (renamed from Tests/RunCMake/CheckLinkerFlag/CheckCXXLinkerFlag.cmake)0
-rw-r--r--Tests/RunCMake/CheckLinkerFlag/CheckLinkerFlagFortran.cmake (renamed from Tests/RunCMake/CheckLinkerFlag/CheckFortranLinkerFlag.cmake)0
-rw-r--r--Tests/RunCMake/CheckLinkerFlag/CheckLinkerFlagHIP.cmake (renamed from Tests/RunCMake/CheckLinkerFlag/CheckHIPLinkerFlag.cmake)0
-rw-r--r--Tests/RunCMake/CheckLinkerFlag/CheckLinkerFlagOBJC.cmake (renamed from Tests/RunCMake/CheckLinkerFlag/CheckOBJCLinkerFlag.cmake)0
-rw-r--r--Tests/RunCMake/CheckLinkerFlag/CheckLinkerFlagOBJCXX.cmake (renamed from Tests/RunCMake/CheckLinkerFlag/CheckOBJCXXLinkerFlag.cmake)0
-rw-r--r--Tests/RunCMake/CheckLinkerFlag/RunCMakeTest.cmake14
-rw-r--r--Tests/RunCMake/CheckSourceCompiles/CheckCSourceCompiles.cmake6
-rw-r--r--Tests/RunCMake/CheckSourceCompiles/CheckCXXSourceCompiles.cmake10
-rw-r--r--Tests/RunCMake/CheckSourceCompiles/CheckOBJCSourceCompiles.cmake9
-rw-r--r--Tests/RunCMake/CheckSourceCompiles/CheckOBJCXXSourceCompiles.cmake9
-rw-r--r--Tests/RunCMake/CheckSourceCompiles/CheckSourceCompilesC.cmake15
-rw-r--r--Tests/RunCMake/CheckSourceCompiles/CheckSourceCompilesCUDA.cmake (renamed from Tests/RunCMake/CheckSourceCompiles/CheckCUDASourceCompiles.cmake)0
-rw-r--r--Tests/RunCMake/CheckSourceCompiles/CheckSourceCompilesCXX.cmake28
-rw-r--r--Tests/RunCMake/CheckSourceCompiles/CheckSourceCompilesFortran.cmake (renamed from Tests/RunCMake/CheckSourceCompiles/CheckFortranSourceCompiles.cmake)0
-rw-r--r--Tests/RunCMake/CheckSourceCompiles/CheckSourceCompilesHIP.cmake (renamed from Tests/RunCMake/CheckSourceCompiles/CheckHIPSourceCompiles.cmake)0
-rw-r--r--Tests/RunCMake/CheckSourceCompiles/CheckSourceCompilesISPC.cmake (renamed from Tests/RunCMake/CheckSourceCompiles/CheckISPCSourceCompiles.cmake)0
-rw-r--r--Tests/RunCMake/CheckSourceCompiles/CheckSourceCompilesOBJC.cmake16
-rw-r--r--Tests/RunCMake/CheckSourceCompiles/CheckSourceCompilesOBJCXX.cmake19
-rw-r--r--Tests/RunCMake/CheckSourceCompiles/RunCMakeTest.cmake12
-rw-r--r--Tests/RunCMake/CheckSourceRuns/CheckCSourceRuns.cmake10
-rw-r--r--Tests/RunCMake/CheckSourceRuns/CheckCXXSourceRuns.cmake10
-rw-r--r--Tests/RunCMake/CheckSourceRuns/CheckOBJCSourceRuns.cmake9
-rw-r--r--Tests/RunCMake/CheckSourceRuns/CheckOBJCXXSourceRuns.cmake9
-rw-r--r--Tests/RunCMake/CheckSourceRuns/CheckSourceRunsC.cmake15
-rw-r--r--Tests/RunCMake/CheckSourceRuns/CheckSourceRunsCUDA.cmake (renamed from Tests/RunCMake/CheckSourceRuns/CheckCUDASourceRuns.cmake)0
-rw-r--r--Tests/RunCMake/CheckSourceRuns/CheckSourceRunsCXX.cmake22
-rw-r--r--Tests/RunCMake/CheckSourceRuns/CheckSourceRunsFortran.cmake (renamed from Tests/RunCMake/CheckSourceRuns/CheckFortranSourceRuns.cmake)0
-rw-r--r--Tests/RunCMake/CheckSourceRuns/CheckSourceRunsHIP.cmake (renamed from Tests/RunCMake/CheckSourceRuns/CheckHIPSourceRuns.cmake)0
-rw-r--r--Tests/RunCMake/CheckSourceRuns/CheckSourceRunsOBJC.cmake16
-rw-r--r--Tests/RunCMake/CheckSourceRuns/CheckSourceRunsOBJCXX.cmake19
-rw-r--r--Tests/RunCMake/CheckSourceRuns/RunCMakeTest.cmake10
-rw-r--r--Tests/RunCMake/CommandLine/debug-trycompile-stderr.txt11
-rw-r--r--Tests/RunCMake/Ninja/QtAutoMocSkipPch.cmake17
-rw-r--r--Tests/RunCMake/Ninja/RunCMakeTest.cmake16
-rw-r--r--Tests/RunCMake/install/DIRECTORY-symlink-clobber-all-result.txt1
-rw-r--r--Tests/RunCMake/install/DIRECTORY-symlink-clobber-all-stderr.txt12
-rw-r--r--Tests/RunCMake/install/DIRECTORY-symlink-clobber-all-stdout.txt12
-rw-r--r--Tests/RunCMake/install/DIRECTORY-symlink-clobber.cmake11
-rw-r--r--Tests/RunCMake/install/RunCMakeTest.cmake4
-rw-r--r--Tests/RunCMake/try_compile/PlatformVariables-stderr.txt11
-rw-r--r--Tests/RunCMake/try_compile/WarnDeprecated-stderr.txt11
-rw-r--r--Tests/TryCompile/CMakeLists.txt144
89 files changed, 909 insertions, 717 deletions
diff --git a/.gitlab/.gitignore b/.gitlab/.gitignore
new file mode 100644
index 0000000..d62e477
--- /dev/null
+++ b/.gitlab/.gitignore
@@ -0,0 +1,16 @@
+# Ignore files known to be downloaded by CI jobs.
+/5.15.1-0-202009071110*
+/bcc*
+/cmake*
+/ispc*
+/jom
+/llvm*
+/msvc*
+/ninja*
+/open-watcom*
+/python*
+/qt*
+/sccache*
+/unstable-jom*
+/watcom
+/wix*
diff --git a/Help/guide/tutorial/Adding Export Configuration.rst b/Help/guide/tutorial/Adding Export Configuration.rst
index 3bd6d64..eb14f42 100644
--- a/Help/guide/tutorial/Adding Export Configuration.rst
+++ b/Help/guide/tutorial/Adding Export Configuration.rst
@@ -21,7 +21,7 @@ in ``MathFunctions/CMakeLists.txt`` to look like:
:caption: MathFunctions/CMakeLists.txt
:name: MathFunctions/CMakeLists.txt-install-TARGETS-EXPORT
:language: cmake
- :start-after: # install rules
+ :start-after: # install libs
Now that we have ``MathFunctions`` being exported, we also need to explicitly
install the generated ``MathFunctionsTargets.cmake`` file. This is done by
diff --git a/Help/guide/tutorial/Adding Generator Expressions.rst b/Help/guide/tutorial/Adding Generator Expressions.rst
index ba728bd..6f9714e 100644
--- a/Help/guide/tutorial/Adding Generator Expressions.rst
+++ b/Help/guide/tutorial/Adding Generator Expressions.rst
@@ -158,6 +158,7 @@ and this:
:name: MathFunctions-CMakeLists.txt-target_link_libraries-step4
:language: cmake
:start-after: # link our compiler flags interface library
+ :end-before: # TODO 1
.. raw:: html
diff --git a/Help/guide/tutorial/Adding System Introspection.rst b/Help/guide/tutorial/Adding System Introspection.rst
index 4f3e808..ba91df4 100644
--- a/Help/guide/tutorial/Adding System Introspection.rst
+++ b/Help/guide/tutorial/Adding System Introspection.rst
@@ -30,7 +30,7 @@ If available, use :command:`target_compile_definitions` to specify
:name: MathFunctions/CMakeLists.txt-target_compile_definitions
:language: cmake
:start-after: # add compile definitions
- :end-before: # install rules
+ :end-before: # install libs
If ``log`` and ``exp`` are available on the system, then we will use them to
compute the square root in the ``mysqrt`` function. Add the following code to
diff --git a/Help/guide/tutorial/Adding a Custom Command and Generated File.rst b/Help/guide/tutorial/Adding a Custom Command and Generated File.rst
index 343979e..b1f9840 100644
--- a/Help/guide/tutorial/Adding a Custom Command and Generated File.rst
+++ b/Help/guide/tutorial/Adding a Custom Command and Generated File.rst
@@ -62,7 +62,7 @@ directories so that ``Table.h`` can be found and included by ``mysqrt.cxx``.
:name: MathFunctions/CMakeLists.txt-target_include_directories-Table.h
:language: cmake
:start-after: # state that we depend on our bin
- :end-before: # install rules
+ :end-before: # install libs
Now let's use the generated table. First, modify ``mysqrt.cxx`` to include
``Table.h``. Next, we can rewrite the ``mysqrt`` function to use the table:
diff --git a/Help/guide/tutorial/Complete/MathFunctions/CMakeLists.txt b/Help/guide/tutorial/Complete/MathFunctions/CMakeLists.txt
index 40b9fd2..d256db2 100644
--- a/Help/guide/tutorial/Complete/MathFunctions/CMakeLists.txt
+++ b/Help/guide/tutorial/Complete/MathFunctions/CMakeLists.txt
@@ -56,7 +56,7 @@ target_compile_definitions(MathFunctions PRIVATE "EXPORTING_MYMATH")
set_property(TARGET MathFunctions PROPERTY VERSION "1.0.0")
set_property(TARGET MathFunctions PROPERTY SOVERSION "1")
-# install rules
+# install libs
set(installable_libs MathFunctions tutorial_compiler_flags)
if(TARGET SqrtLibrary)
list(APPEND installable_libs SqrtLibrary)
@@ -64,4 +64,5 @@ endif()
install(TARGETS ${installable_libs}
EXPORT MathFunctionsTargets
DESTINATION lib)
+# install include headers
install(FILES MathFunctions.h DESTINATION include)
diff --git a/Help/guide/tutorial/Installing and Testing.rst b/Help/guide/tutorial/Installing and Testing.rst
index 8daf5aa..3969192 100644
--- a/Help/guide/tutorial/Installing and Testing.rst
+++ b/Help/guide/tutorial/Installing and Testing.rst
@@ -1,50 +1,80 @@
Step 5: Installing and Testing
==============================
-Now we can start adding install rules and testing support to our project.
+.. _`Tutorial Testing Support`:
+
+Exercise 1 - Install Rules
+^^^^^^^^^^^^^^^^^^^^^^^^^^
+
+Often, it is not enough to only build an executable, it should also be
+installable. With CMake, we can specify install rules using the
+:command:`install` command. Supporting local installations for your builds in
+CMake is often as simple as specifying an install location and the targets and
+files to be installed.
+
+Goal
+----
+
+Install the ``Tutorial`` executable and the ``MathFunctions`` library.
+
+Helpful Materials
+-----------------
+
+* :command:`install`
-Install Rules
+Files to Edit
-------------
-The install rules are fairly simple: for ``MathFunctions`` we want to install
-the library and header file and for the application we want to install the
-executable and configured header.
+* ``MathFunctions/CMakeLists.txt``
+* ``CMakeLists.txt``
-So to the end of ``MathFunctions/CMakeLists.txt`` we add:
+Getting Started
+---------------
-.. literalinclude:: Step6/MathFunctions/CMakeLists.txt
- :caption: MathFunctions/CMakeLists.txt
- :name: MathFunctions/CMakeLists.txt-install-TARGETS
- :language: cmake
- :start-after: # install rules
+The starting code is provided in the ``Step5`` directory. In this
+exercise, complete ``TODO 1`` through ``TODO 4``.
-And to the end of the top-level ``CMakeLists.txt`` we add:
+First, update ``MathFunctions/CMakeLists.txt`` to install the
+``MathFunctions`` and ``tutorial_compiler_flags`` libraries to the ``lib``
+directory. In that same file, specify the install rules needed to install
+``MathFunctions.h`` to the ``include`` directory.
-.. literalinclude:: Step6/CMakeLists.txt
- :caption: CMakeLists.txt
- :name: CMakeLists.txt-install-TARGETS
- :language: cmake
- :start-after: # add the install targets
- :end-before: # enable testing
+Then, update the top level ``CMakeLists.txt`` to install
+the ``Tutorial`` executable to the ``bin`` directory. Lastly, any header files
+should be installed to the ``include`` directory. Remember that
+``TutorialConfig.h`` is in the :variable:`PROJECT_BINARY_DIR`.
-That is all that is needed to create a basic local install of the tutorial.
+Build and Run
+-------------
-Now run the :manual:`cmake <cmake(1)>` executable or the
+Make a new directory called ``Step5_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.
-Then run the install step by using the ``install`` option of the
+Then, run the install step by using the ``install`` option of the
:manual:`cmake <cmake(1)>` command (introduced in 3.15, older versions of
-CMake must use ``make install``) from the command line. For
-multi-configuration tools, don't forget to use the ``--config`` argument to
-specify the configuration. If using an IDE, simply build the ``INSTALL``
-target. This step will install the appropriate header files, libraries, and
-executables. For example:
+CMake must use ``make install``) from the command line. This step will
+install the appropriate header files, libraries, and executables. For example:
.. code-block:: console
cmake --install .
+For multi-configuration tools, don't forget to use the ``--config`` argument to
+specify the configuration.
+
+.. code-block:: console
+
+ cmake --install . --config Release
+
+If using an IDE, simply build the ``INSTALL`` target. You can build the same
+install target from the command line like the following:
+
+.. code-block:: console
+
+ cmake --build . --target install --config Debug
+
The CMake variable :variable:`CMAKE_INSTALL_PREFIX` is used to determine the
root of where the files will be installed. If using the ``cmake --install``
command, the installation prefix can be overridden via the ``--prefix``
@@ -54,42 +84,227 @@ argument. For example:
cmake --install . --prefix "/home/myuser/installdir"
-Navigate to the install directory and verify that the installed Tutorial runs.
+Navigate to the install directory and verify that the installed ``Tutorial``
+runs.
-.. _`Tutorial Testing Support`:
+Solution
+--------
-Testing Support
----------------
+The install rules for our project are fairly simple:
-Next let's test our application. At the end of the top-level ``CMakeLists.txt``
-file we can enable testing and then add a number of basic tests to verify that
-the application is working correctly.
+* For ``MathFunctions``, we want to install the libraries and header file to
+ the ``lib`` and ``include`` directories respectively.
+
+* For the ``Tutorial`` executable, we want to install the executable and
+ configured header file to the ``bin`` and ``include`` directories
+ respectively.
+
+So to the end of ``MathFunctions/CMakeLists.txt`` we add:
+
+.. raw:: html
+
+ <details><summary>TODO 1: Click to show/hide answer</summary>
+
+.. literalinclude:: Step6/MathFunctions/CMakeLists.txt
+ :caption: TODO 1: MathFunctions/CMakeLists.txt
+ :name: MathFunctions/CMakeLists.txt-install-TARGETS
+ :language: cmake
+ :start-after: # install libs
+ :end-before: # install include headers
+
+.. raw:: html
+
+ </details>
+
+and
+
+.. raw:: html
+
+ <details><summary>TODO 2: Click to show/hide answer</summary>
+
+.. literalinclude:: Step6/MathFunctions/CMakeLists.txt
+ :caption: TODO 2: MathFunctions/CMakeLists.txt
+ :name: MathFunctions/CMakeLists.txt-install-headers
+ :language: cmake
+ :start-after: # install include headers
+
+.. raw:: html
+
+ </details>
+
+The install rules for the ``Tutorial`` executable and configured header file
+are similar. To the end of the top-level ``CMakeLists.txt`` we add:
+
+.. raw:: html
+
+ <details><summary>TODO 3,4: Click to show/hide answer</summary>
.. literalinclude:: Step6/CMakeLists.txt
:caption: CMakeLists.txt
- :name: CMakeLists.txt-enable_testing
+ :name: TODO 3,4: CMakeLists.txt-install-TARGETS
:language: cmake
- :start-after: # enable testing
+ :start-after: # add the install targets
+ :end-before: # enable testing
+
+.. raw:: html
+
+ </details>
-The first test simply verifies that the application runs, does not segfault or
-otherwise crash, and has a zero return value. This is the basic form of a
-CTest test.
+That is all that is needed to create a basic local
+install of the tutorial.
-The next test makes use of the :prop_test:`PASS_REGULAR_EXPRESSION` test
-property to verify that the output of the test contains certain strings. In
-this case, verifying that the usage message is printed when an incorrect number
-of arguments are provided.
+Exercise 2 - Testing Support
+^^^^^^^^^^^^^^^^^^^^^^^^^^^^
-Lastly, we have a function called ``do_test`` that runs the application and
-verifies that the computed square root is correct for given input. For each
-invocation of ``do_test``, another test is added to the project with a name,
-input, and expected results based on the passed arguments.
+CTest offers a way to easily manage tests for your project. Tests can be
+added through the :command:`add_test` command. Although it is not
+explicitly covered in this tutorial, there is a lot of compatibility
+between CTest and other testing frameworks such as :module:`GoogleTest`.
-Rebuild the application and then cd to the binary directory and run the
+Goal
+----
+
+Create unit tests for our executable using CTest.
+
+Helpful Materials
+-----------------
+
+* :command:`enable_testing`
+* :command:`add_test`
+* :command:`function`
+* :command:`set_tests_properties`
+* :manual:`ctest <ctest(1)>`
+
+Files to Edit
+-------------
+
+* ``CMakeLists.txt``
+
+Getting Started
+---------------
+
+The starting source code is provided in the ``Step5`` directory. In this
+exercise, complete ``TODO 5`` through ``TODO 9``.
+
+First, we need to enable testing. Next, begin adding tests to our project
+using :command:`add_test`. We will work through adding 3 simple tests and
+then you can add additional testing as you see fit.
+
+Build and Run
+-------------
+
+Navigate to the build directory and rebuild the application. Then, run the
:manual:`ctest <ctest(1)>` executable: ``ctest -N`` and ``ctest -VV``. For
multi-config generators (e.g. Visual Studio), the configuration type must be
specified with the ``-C <mode>`` flag. For example, to run tests in Debug
-mode use ``ctest -C Debug -VV`` from the binary directory
+mode use ``ctest -C Debug -VV`` from the build directory
(not the Debug subdirectory!). Release mode would be executed from the same
-location but with a ``-C Release``. Alternatively, build the ``RUN_TESTS``
+location but with a ``-C Release``. Alternatively, build the ``RUN_TESTS``
target from the IDE.
+
+Solution
+--------
+
+Let's test our application. At the end of the top-level ``CMakeLists.txt``
+file we first need to enable testing with the
+:command:`enable_testing` command.
+
+.. raw:: html
+
+ <details><summary>TODO 5: Click to show/hide answer</summary>
+
+.. literalinclude:: Step6/CMakeLists.txt
+ :caption: TODO 5: CMakeLists.txt
+ :name: CMakeLists.txt-enable_testing
+ :language: cmake
+ :start-after: # enable testing
+ :end-before: # does the application run
+
+.. raw:: html
+
+ </details>
+
+With testing enabled, we will add a number of basic tests to verify
+that the application is working correctly. First, we create a test using
+:command:`add_test` which runs the ``Tutorial`` executable with the
+parameter 25 passed in. For this test, we are not going to check the
+executable's computed answer. This test will verify that
+application runs, does not segfault or otherwise crash, and has a zero
+return value. This is the basic form of a CTest test.
+
+.. raw:: html
+
+ <details><summary>TODO 6: Click to show/hide answer</summary>
+
+.. literalinclude:: Step6/CMakeLists.txt
+ :caption: TODO 6: CMakeLists.txt
+ :name: CMakeLists.txt-test-runs
+ :language: cmake
+ :start-after: # does the application run
+ :end-before: # does the usage message work
+
+.. raw:: html
+
+ </details>
+
+Next, let's use the :prop_test:`PASS_REGULAR_EXPRESSION` test property to
+verify that the output of the test contains certain strings. In this case,
+verifying that the usage message is printed when an incorrect number of
+arguments are provided.
+
+.. raw:: html
+
+ <details><summary>TODO 7: Click to show/hide answer</summary>
+
+.. literalinclude:: Step6/CMakeLists.txt
+ :caption: TODO 7: CMakeLists.txt
+ :name: CMakeLists.txt-test-usage
+ :language: cmake
+ :start-after: # does the usage message work?
+ :end-before: # define a function to simplify adding tests
+
+.. raw:: html
+
+ </details>
+
+The next test we will add verifies the computed value is truly the
+square root.
+
+.. raw:: html
+
+ <details><summary>TODO 8: Click to show/hide answer</summary>
+
+.. code-block:: cmake
+ :caption: TODO 8: CMakeLists.txt
+ :name: CMakeLists.txt-test-standard
+
+ add_test(NAME StandardUse COMMAND Tutorial 4)
+ set_tests_properties(StandardUse
+ PROPERTIES PASS_REGULAR_EXPRESSION "4 is 2"
+ )
+
+.. raw:: html
+
+ </details>
+
+This one test is not enough to give us confidence that it will
+work for all values passed in. We should add more tests to verify this.
+To easily add more tests, we make a function called ``do_test`` that runs the
+application and verifies that the computed square root is correct for
+given input. For each invocation of ``do_test``, another test is added to
+the project with a name, input, and expected results based on the passed
+arguments.
+
+.. raw:: html
+
+ <details><summary>TODO 9: Click to show/hide answer</summary>
+
+.. literalinclude:: Step6/CMakeLists.txt
+ :caption: TODO 9: CMakeLists.txt
+ :name: CMakeLists.txt-generalized-tests
+ :language: cmake
+ :start-after: # define a function to simplify adding tests
+
+.. raw:: html
+
+ </details>
diff --git a/Help/guide/tutorial/Packaging Debug and Release.rst b/Help/guide/tutorial/Packaging Debug and Release.rst
index fc2050e..8c660a3 100644
--- a/Help/guide/tutorial/Packaging Debug and Release.rst
+++ b/Help/guide/tutorial/Packaging Debug and Release.rst
@@ -41,7 +41,7 @@ Let's also add version numbering to the ``MathFunctions`` library. In
:name: MathFunctions/CMakeLists.txt-VERSION-properties
:language: cmake
:start-after: # setup the version numbering
- :end-before: # install rules
+ :end-before: # install libs
From the ``Step12`` directory, create ``debug`` and ``release``
subdirectories. The layout will look like:
diff --git a/Help/guide/tutorial/Step10/MathFunctions/CMakeLists.txt b/Help/guide/tutorial/Step10/MathFunctions/CMakeLists.txt
index d7f30d6..fa73321 100644
--- a/Help/guide/tutorial/Step10/MathFunctions/CMakeLists.txt
+++ b/Help/guide/tutorial/Step10/MathFunctions/CMakeLists.txt
@@ -25,7 +25,8 @@ target_include_directories(MathFunctions
# link our compiler flags interface library
target_link_libraries(MathFunctions tutorial_compiler_flags)
-# install rules
+# install libs
set(installable_libs MathFunctions tutorial_compiler_flags)
install(TARGETS ${installable_libs} DESTINATION lib)
+# install include headers
install(FILES MathFunctions.h DESTINATION include)
diff --git a/Help/guide/tutorial/Step11/MathFunctions/CMakeLists.txt b/Help/guide/tutorial/Step11/MathFunctions/CMakeLists.txt
index 0e86a12..a60fb63 100644
--- a/Help/guide/tutorial/Step11/MathFunctions/CMakeLists.txt
+++ b/Help/guide/tutorial/Step11/MathFunctions/CMakeLists.txt
@@ -50,10 +50,11 @@ target_link_libraries(MathFunctions PUBLIC tutorial_compiler_flags)
# building on windows
target_compile_definitions(MathFunctions PRIVATE "EXPORTING_MYMATH")
-# install rules
+# install libs
set(installable_libs MathFunctions tutorial_compiler_flags)
if(TARGET SqrtLibrary)
list(APPEND installable_libs SqrtLibrary)
endif()
install(TARGETS ${installable_libs} DESTINATION lib)
+# install include headers
install(FILES MathFunctions.h DESTINATION include)
diff --git a/Help/guide/tutorial/Step12/MathFunctions/CMakeLists.txt b/Help/guide/tutorial/Step12/MathFunctions/CMakeLists.txt
index d5961da..a85f3cb 100644
--- a/Help/guide/tutorial/Step12/MathFunctions/CMakeLists.txt
+++ b/Help/guide/tutorial/Step12/MathFunctions/CMakeLists.txt
@@ -52,7 +52,7 @@ target_link_libraries(MathFunctions PUBLIC tutorial_compiler_flags)
# building on windows
target_compile_definitions(MathFunctions PRIVATE "EXPORTING_MYMATH")
-# install rules
+# install libs
set(installable_libs MathFunctions tutorial_compiler_flags)
if(TARGET SqrtLibrary)
list(APPEND installable_libs SqrtLibrary)
@@ -60,4 +60,5 @@ endif()
install(TARGETS ${installable_libs}
EXPORT MathFunctionsTargets
DESTINATION lib)
+# install include headers
install(FILES MathFunctions.h DESTINATION include)
diff --git a/Help/guide/tutorial/Step5/CMakeLists.txt b/Help/guide/tutorial/Step5/CMakeLists.txt
index 4003c21..a8f241a 100644
--- a/Help/guide/tutorial/Step5/CMakeLists.txt
+++ b/Help/guide/tutorial/Step5/CMakeLists.txt
@@ -38,3 +38,27 @@ target_link_libraries(Tutorial PUBLIC ${EXTRA_LIBS} tutorial_compiler_flags)
target_include_directories(Tutorial PUBLIC
"${PROJECT_BINARY_DIR}"
)
+
+# TODO 3: Install Tutorial in the bin directory
+# Hint: Use the TARGETS and DESTINATION parameters
+
+# TODO 4: Install Tutorial.h to the include directory
+# Hint: Use the FILES and DESTINATION parameters
+
+# TODO 5: Enable testing
+
+# TODO 6: Add a test called Runs which runs the following command:
+# $ Tutorial 25
+
+# TODO 7: Add a test called Usage which runs the following command:
+# $ Tutorial
+# Make sure the expected output is displayed.
+# Hint: Use the PASS_REGULAR_EXPRESSION property with "Usage.*number"
+
+# TODO 8: Add a test which runs the following command:
+# $ Tutorial 4
+# Make sure the result is correct.
+# Hint: Use the PASS_REGULAR_EXPRESSION property with "4 is 2"
+
+# TODO 9: Add more tests. Create a function called do_test to avoid copy +
+# paste. Test the following values: 4, 9, 5, 7, 25, -25 and 0.00001.
diff --git a/Help/guide/tutorial/Step5/MathFunctions/CMakeLists.txt b/Help/guide/tutorial/Step5/MathFunctions/CMakeLists.txt
index fc932af..6cd88d7 100644
--- a/Help/guide/tutorial/Step5/MathFunctions/CMakeLists.txt
+++ b/Help/guide/tutorial/Step5/MathFunctions/CMakeLists.txt
@@ -8,3 +8,11 @@ target_include_directories(MathFunctions
# link our compiler flags interface library
target_link_libraries(MathFunctions tutorial_compiler_flags)
+
+# TODO 1: Create a variable called installable_libs that is a list of all
+# libraries we want to install (e.g. MathFunctions and tutorial_compiler_flags)
+# Then install the installable libraries to the lib folder.
+# Hint: Use the TARGETS and DESTINATION parameters
+
+# TODO 2: Install the library headers to the include folder.
+# Hint: Use the FILES and DESTINATION parameters
diff --git a/Help/guide/tutorial/Step6/MathFunctions/CMakeLists.txt b/Help/guide/tutorial/Step6/MathFunctions/CMakeLists.txt
index e7667ab..b4724c4 100644
--- a/Help/guide/tutorial/Step6/MathFunctions/CMakeLists.txt
+++ b/Help/guide/tutorial/Step6/MathFunctions/CMakeLists.txt
@@ -9,7 +9,8 @@ target_include_directories(MathFunctions
# link our compiler flags interface library
target_link_libraries(MathFunctions tutorial_compiler_flags)
-# install rules
+# install libs
set(installable_libs MathFunctions tutorial_compiler_flags)
install(TARGETS ${installable_libs} DESTINATION lib)
+# install include headers
install(FILES MathFunctions.h DESTINATION include)
diff --git a/Help/guide/tutorial/Step7/MathFunctions/CMakeLists.txt b/Help/guide/tutorial/Step7/MathFunctions/CMakeLists.txt
index e7667ab..b4724c4 100644
--- a/Help/guide/tutorial/Step7/MathFunctions/CMakeLists.txt
+++ b/Help/guide/tutorial/Step7/MathFunctions/CMakeLists.txt
@@ -9,7 +9,8 @@ target_include_directories(MathFunctions
# link our compiler flags interface library
target_link_libraries(MathFunctions tutorial_compiler_flags)
-# install rules
+# install libs
set(installable_libs MathFunctions tutorial_compiler_flags)
install(TARGETS ${installable_libs} DESTINATION lib)
+# install include headers
install(FILES MathFunctions.h DESTINATION include)
diff --git a/Help/guide/tutorial/Step8/MathFunctions/CMakeLists.txt b/Help/guide/tutorial/Step8/MathFunctions/CMakeLists.txt
index 4a19684..f81b563 100644
--- a/Help/guide/tutorial/Step8/MathFunctions/CMakeLists.txt
+++ b/Help/guide/tutorial/Step8/MathFunctions/CMakeLists.txt
@@ -32,7 +32,8 @@ if(HAVE_LOG AND HAVE_EXP)
PRIVATE "HAVE_LOG" "HAVE_EXP")
endif()
-# install rules
+# install libs
set(installable_libs MathFunctions tutorial_compiler_flags)
install(TARGETS ${installable_libs} DESTINATION lib)
+# install include headers
install(FILES MathFunctions.h DESTINATION include)
diff --git a/Help/guide/tutorial/Step9/MathFunctions/CMakeLists.txt b/Help/guide/tutorial/Step9/MathFunctions/CMakeLists.txt
index 6a1a108..8e04f97 100644
--- a/Help/guide/tutorial/Step9/MathFunctions/CMakeLists.txt
+++ b/Help/guide/tutorial/Step9/MathFunctions/CMakeLists.txt
@@ -27,7 +27,8 @@ target_include_directories(MathFunctions
# link our compiler flags interface library
target_link_libraries(MathFunctions tutorial_compiler_flags)
-# install rules
+# install libs
set(installable_libs MathFunctions tutorial_compiler_flags)
install(TARGETS ${installable_libs} DESTINATION lib)
+# install include headers
install(FILES MathFunctions.h DESTINATION include)
diff --git a/Help/manual/cmake.1.rst b/Help/manual/cmake.1.rst
index d22317e..879ad0b 100644
--- a/Help/manual/cmake.1.rst
+++ b/Help/manual/cmake.1.rst
@@ -292,6 +292,11 @@ Options
is effectively a :command:`try_compile`. Any combination of the two
is subject to the potential issues described.)
+ .. versionadded:: 3.25
+
+ When this option is enabled, every try-compile check prints a log
+ message reporting the directory in which the check is performed.
+
.. option:: --debug-output
Put cmake in a debug mode.
diff --git a/Help/release/dev/try_compile-signatures.rst b/Help/release/dev/try_compile-signatures.rst
index d477d989..c32babd 100644
--- a/Help/release/dev/try_compile-signatures.rst
+++ b/Help/release/dev/try_compile-signatures.rst
@@ -5,4 +5,7 @@ try_compile-signatures
signatures that more consistently use keyword dispatch and do not require a
binary directory to be specified. Additionally, these signatures use a
unique directory for each invocation, which allows multiple outputs to be
- preserved when using ``--debug-trycompile``.
+ preserved when using :option:`--debug-trycompile <cmake --debug-trycompile>`.
+
+* The :option:`cmake --debug-trycompile` option now prints log messages
+ reporting the directory in which each try-compile check is done.
diff --git a/Modules/CPackIFW.cmake b/Modules/CPackIFW.cmake
index 003cf3f..a4bfe1d 100644
--- a/Modules/CPackIFW.cmake
+++ b/Modules/CPackIFW.cmake
@@ -439,6 +439,7 @@ set(_CPACK_IFW_PREFIXES
"QtIFW-")
set(_CPACK_IFW_VERSIONS
+ "4.4"
"4.3"
"4.2"
"4.1"
diff --git a/Source/CMakeVersion.cmake b/Source/CMakeVersion.cmake
index 51d6be4..45504d4 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 20221006)
+set(CMake_VERSION_PATCH 20221007)
#set(CMake_VERSION_RC 0)
set(CMake_VERSION_IS_DIRTY 0)
diff --git a/Source/cmCoreTryCompile.cxx b/Source/cmCoreTryCompile.cxx
index cdf8efa..588f44a 100644
--- a/Source/cmCoreTryCompile.cxx
+++ b/Source/cmCoreTryCompile.cxx
@@ -1050,6 +1050,13 @@ bool cmCoreTryCompile::TryCompileCode(Arguments& arguments,
}
}
+ if (this->Makefile->GetCMakeInstance()->GetDebugTryCompile()) {
+ auto msg =
+ cmStrCat("Executing try_compile (", *arguments.CompileResultVariable,
+ ") in:\n ", this->BinaryDirectory);
+ this->Makefile->IssueMessage(MessageType::LOG, msg);
+ }
+
bool erroroc = cmSystemTools::GetErrorOccurredFlag();
cmSystemTools::ResetErrorOccurredFlag();
std::string output;
diff --git a/Source/cmFileCommand.cxx b/Source/cmFileCommand.cxx
index bec9fb2..421ff12 100644
--- a/Source/cmFileCommand.cxx
+++ b/Source/cmFileCommand.cxx
@@ -2960,11 +2960,23 @@ bool HandleCreateLinkCommand(std::vector<std::string> const& args,
// Check if the command requires a symbolic link.
if (arguments.Symbolic) {
- completed = static_cast<bool>(
- cmSystemTools::CreateSymlink(fileName, newFileName, &result));
+ cmsys::Status linked =
+ cmSystemTools::CreateSymlinkQuietly(fileName, newFileName);
+ if (linked) {
+ completed = true;
+ } else {
+ result = cmStrCat("failed to create symbolic link '", newFileName,
+ "': ", linked.GetString());
+ }
} else {
- completed = static_cast<bool>(
- cmSystemTools::CreateLink(fileName, newFileName, &result));
+ cmsys::Status linked =
+ cmSystemTools::CreateLinkQuietly(fileName, newFileName);
+ if (linked) {
+ completed = true;
+ } else {
+ result = cmStrCat("failed to create link '", newFileName,
+ "': ", linked.GetString());
+ }
}
// Check if copy-on-error is enabled in the arguments.
diff --git a/Source/cmFileCopier.cxx b/Source/cmFileCopier.cxx
index 1667807..ef55abf 100644
--- a/Source/cmFileCopier.cxx
+++ b/Source/cmFileCopier.cxx
@@ -15,7 +15,11 @@
#include "cmValue.h"
#ifdef _WIN32
+# include <winerror.h>
+
# include "cmsys/FStream.hxx"
+#else
+# include <cerrno>
#endif
#include <cstring>
@@ -504,11 +508,12 @@ bool cmFileCopier::InstallSymlinkChain(std::string& fromFile,
cmSystemTools::RemoveFile(toFile);
cmSystemTools::MakeDirectory(toFilePath);
- if (!cmSystemTools::CreateSymlink(symlinkTarget, toFile)) {
- std::ostringstream e;
- e << this->Name << " cannot create symlink \"" << toFile
- << "\": " << cmSystemTools::GetLastSystemError() << ".";
- this->Status.SetError(e.str());
+ cmsys::Status status =
+ cmSystemTools::CreateSymlinkQuietly(symlinkTarget, toFile);
+ if (!status) {
+ std::string e = cmStrCat(this->Name, " cannot create symlink\n ",
+ toFile, "\nbecause: ", status.GetString());
+ this->Status.SetError(e);
return false;
}
}
@@ -557,12 +562,24 @@ bool cmFileCopier::InstallSymlink(const std::string& fromFile,
cmSystemTools::MakeDirectory(cmSystemTools::GetFilenamePath(toFile));
// Create the symlink.
- if (!cmSystemTools::CreateSymlink(symlinkTarget, toFile)) {
- std::ostringstream e;
- e << this->Name << " cannot duplicate symlink \"" << fromFile
- << "\" at \"" << toFile
- << "\": " << cmSystemTools::GetLastSystemError() << ".";
- this->Status.SetError(e.str());
+ cmsys::Status status =
+ cmSystemTools::CreateSymlinkQuietly(symlinkTarget, toFile);
+ if (!status) {
+#ifdef _WIN32
+ bool const errorFileExists = status.GetWindows() == ERROR_FILE_EXISTS;
+#else
+ bool const errorFileExists = status.GetPOSIX() == EEXIST;
+#endif
+ std::string reason;
+ if (errorFileExists && cmSystemTools::FileIsDirectory(toFile)) {
+ reason = "A directory already exists at that location";
+ } else {
+ reason = status.GetString();
+ }
+ std::string e =
+ cmStrCat(this->Name, " cannot duplicate symlink\n ", fromFile,
+ "\nat\n ", toFile, "\nbecause: ", reason);
+ this->Status.SetError(e);
return false;
}
}
@@ -630,7 +647,10 @@ bool cmFileCopier::InstallDirectory(const std::string& source,
{
// Inform the user about this directory installation.
this->ReportCopy(destination, TypeDir,
- !cmSystemTools::FileIsDirectory(destination));
+ !( // Report "Up-to-date:" for existing directories,
+ // but not symlinks to them.
+ cmSystemTools::FileIsDirectory(destination) &&
+ !cmSystemTools::FileIsSymlink(destination)));
// check if default dir creation permissions were set
mode_t default_dir_mode_v = 0;
diff --git a/Source/cmQtAutoGenInitializer.cxx b/Source/cmQtAutoGenInitializer.cxx
index 6c500b0..96649ab 100644
--- a/Source/cmQtAutoGenInitializer.cxx
+++ b/Source/cmQtAutoGenInitializer.cxx
@@ -1792,13 +1792,16 @@ void cmQtAutoGenInitializer::AddGeneratedSource(ConfigString const& filename,
// XXX(xcode-per-cfg-src): Drop the Xcode-specific part of the condition
// when the Xcode generator supports per-config sources.
if (!this->MultiConfig || this->GlobalGen->IsXcode()) {
- this->AddGeneratedSource(filename.Default, genVars, prepend);
+ cmSourceFile* sf =
+ this->AddGeneratedSource(filename.Default, genVars, prepend);
+ handleSkipPch(sf);
return;
}
for (auto const& cfg : this->ConfigsList) {
std::string const& filenameCfg = filename.Config.at(cfg);
// Register source at makefile
- this->RegisterGeneratedSource(filenameCfg);
+ cmSourceFile* sf = this->RegisterGeneratedSource(filenameCfg);
+ handleSkipPch(sf);
// Add source file to target for this configuration.
this->GenTarget->AddSource(
cmStrCat("$<$<CONFIG:"_s, cfg, ">:"_s, filenameCfg, ">"_s), prepend);
@@ -2158,3 +2161,18 @@ bool cmQtAutoGenInitializer::GetQtExecutable(GenVarsT& genVars,
return true;
}
+
+void cmQtAutoGenInitializer::handleSkipPch(cmSourceFile* sf)
+{
+ bool skipPch = true;
+ for (auto const& pair : this->AutogenTarget.Sources) {
+ if (!pair.first->GetIsGenerated() &&
+ !pair.first->GetProperty("SKIP_PRECOMPILE_HEADERS")) {
+ skipPch = false;
+ }
+ }
+
+ if (skipPch) {
+ sf->SetProperty("SKIP_PRECOMPILE_HEADERS", "ON");
+ }
+}
diff --git a/Source/cmQtAutoGenInitializer.h b/Source/cmQtAutoGenInitializer.h
index 33749ba..6d5261a 100644
--- a/Source/cmQtAutoGenInitializer.h
+++ b/Source/cmQtAutoGenInitializer.h
@@ -154,6 +154,8 @@ private:
bool GetQtExecutable(GenVarsT& genVars, const std::string& executable,
bool ignoreMissingTarget) const;
+ void handleSkipPch(cmSourceFile* sf);
+
cmQtAutoGenGlobalInitializer* GlobalInitializer = nullptr;
cmGeneratorTarget* GenTarget = nullptr;
cmGlobalGenerator* GlobalGen = nullptr;
diff --git a/Source/cmSystemTools.cxx b/Source/cmSystemTools.cxx
index 5737cc1..ee74908 100644
--- a/Source/cmSystemTools.cxx
+++ b/Source/cmSystemTools.cxx
@@ -3590,8 +3590,19 @@ std::string cmSystemTools::EncodeURL(std::string const& in, bool escapeSlashes)
}
cmsys::Status cmSystemTools::CreateSymlink(std::string const& origName,
- std::string const& newName,
- std::string* errorMessage)
+ std::string const& newName)
+{
+ cmsys::Status status =
+ cmSystemTools::CreateSymlinkQuietly(origName, newName);
+ if (!status) {
+ cmSystemTools::Error(cmStrCat("failed to create symbolic link '", newName,
+ "': ", status.GetString()));
+ }
+ return status;
+}
+
+cmsys::Status cmSystemTools::CreateSymlinkQuietly(std::string const& origName,
+ std::string const& newName)
{
uv_fs_t req;
int flags = 0;
@@ -3611,20 +3622,23 @@ cmsys::Status cmSystemTools::CreateSymlink(std::string const& origName,
#else
status = cmsys::Status::POSIX(-err);
#endif
- std::string e = cmStrCat("failed to create symbolic link '", newName,
- "': ", status.GetString());
- if (errorMessage) {
- *errorMessage = std::move(e);
- } else {
- cmSystemTools::Error(e);
- }
}
return status;
}
cmsys::Status cmSystemTools::CreateLink(std::string const& origName,
- std::string const& newName,
- std::string* errorMessage)
+ std::string const& newName)
+{
+ cmsys::Status status = cmSystemTools::CreateLinkQuietly(origName, newName);
+ if (!status) {
+ cmSystemTools::Error(
+ cmStrCat("failed to create link '", newName, "': ", status.GetString()));
+ }
+ return status;
+}
+
+cmsys::Status cmSystemTools::CreateLinkQuietly(std::string const& origName,
+ std::string const& newName)
{
uv_fs_t req;
int err =
@@ -3638,13 +3652,6 @@ cmsys::Status cmSystemTools::CreateLink(std::string const& origName,
#else
status = cmsys::Status::POSIX(-err);
#endif
- std::string e =
- cmStrCat("failed to create link '", newName, "': ", status.GetString());
- if (errorMessage) {
- *errorMessage = std::move(e);
- } else {
- cmSystemTools::Error(e);
- }
}
return status;
}
diff --git a/Source/cmSystemTools.h b/Source/cmSystemTools.h
index b02a977..87b354c 100644
--- a/Source/cmSystemTools.h
+++ b/Source/cmSystemTools.h
@@ -595,14 +595,16 @@ public:
/** Create a symbolic link if the platform supports it. Returns whether
creation succeeded. */
static cmsys::Status CreateSymlink(std::string const& origName,
- std::string const& newName,
- std::string* errorMessage = nullptr);
+ std::string const& newName);
+ static cmsys::Status CreateSymlinkQuietly(std::string const& origName,
+ std::string const& newName);
/** Create a hard link if the platform supports it. Returns whether
creation succeeded. */
static cmsys::Status CreateLink(std::string const& origName,
- std::string const& newName,
- std::string* errorMessage = nullptr);
+ std::string const& newName);
+ static cmsys::Status CreateLinkQuietly(std::string const& origName,
+ std::string const& newName);
/** Get the system name. */
static cm::string_view GetSystemName();
diff --git a/Source/cmcmd.cxx b/Source/cmcmd.cxx
index 4ba8d36..67394f9 100644
--- a/Source/cmcmd.cxx
+++ b/Source/cmcmd.cxx
@@ -1712,16 +1712,15 @@ cmsys::Status cmcmd::SymlinkInternal(std::string const& file,
}
std::string linktext = cmSystemTools::GetFilenameName(file);
#if defined(_WIN32) && !defined(__CYGWIN__)
- std::string errorMessage;
- cmsys::Status status =
- cmSystemTools::CreateSymlink(linktext, link, &errorMessage);
+ cmsys::Status status = cmSystemTools::CreateSymlinkQuietly(linktext, link);
// Creating a symlink will fail with ERROR_PRIVILEGE_NOT_HELD if the user
// does not have SeCreateSymbolicLinkPrivilege, or if developer mode is not
// active. In that case, we try to copy the file.
if (status.GetWindows() == ERROR_PRIVILEGE_NOT_HELD) {
status = cmSystemTools::CopyFileAlways(file, link);
} else if (!status) {
- cmSystemTools::Error(errorMessage);
+ cmSystemTools::Error(cmStrCat("failed to create symbolic link '", link,
+ "': ", status.GetString()));
}
return status;
#else
diff --git a/Tests/CMakeLists.txt b/Tests/CMakeLists.txt
index da87213..10242fd 100644
--- a/Tests/CMakeLists.txt
+++ b/Tests/CMakeLists.txt
@@ -3616,6 +3616,14 @@ if(BUILD_TESTING)
add_subdirectory(CMakeGUI)
endif()
+ # Run CheckSourceTree as the very last test in the CMake/CTest/CPack test
+ # suite. It detects if any changes have been made to the CMake source tree
+ # by any previous configure, build or test steps.
+ if(GIT_EXECUTABLE AND EXISTS "${CMake_SOURCE_DIR}/.git"
+ AND NOT "${CMake_SOURCE_DIR}" STREQUAL "${CMake_BINARY_DIR}")
+ add_subdirectory(CheckSourceTree)
+ endif()
+
# If this is not an in-source build, provide a target to wipe out
# all the test build directories. This must come at the end after
# all the above logic has finished adding to TEST_BUILD_DIRS
diff --git a/Tests/CMakeTests/CMakeLists.txt b/Tests/CMakeTests/CMakeLists.txt
index 9e0b891..bd2dd7e 100644
--- a/Tests/CMakeTests/CMakeLists.txt
+++ b/Tests/CMakeTests/CMakeLists.txt
@@ -59,18 +59,3 @@ if(GIT_EXECUTABLE)
)
AddCMakeTest(PolicyCheck "${PolicyCheck_PreArgs}")
endif()
-
-# Run CheckSourceTree as the very last test in the CMake/CTest/CPack test
-# suite. It detects if any changes have been made to the CMake source tree
-# by any previous configure, build or test steps.
-#
-if(GIT_EXECUTABLE)
- string(REPLACE "\\" "/" ENV_HOME "$ENV{HOME}")
- set(CheckSourceTree_PreArgs
- "-DCMake_BINARY_DIR:PATH=${CMake_BINARY_DIR}"
- "-DCMake_SOURCE_DIR:PATH=${CMake_SOURCE_DIR}"
- "-DGIT_EXECUTABLE:STRING=${GIT_EXECUTABLE}"
- "-DHOME:STRING=${ENV_HOME}"
- )
- AddCMakeTest(CheckSourceTree "${CheckSourceTree_PreArgs}")
-endif()
diff --git a/Tests/CMakeTests/CheckSourceTreeTest.cmake.in b/Tests/CMakeTests/CheckSourceTreeTest.cmake.in
deleted file mode 100644
index 4f2aaea..0000000
--- a/Tests/CMakeTests/CheckSourceTreeTest.cmake.in
+++ /dev/null
@@ -1,365 +0,0 @@
-# Check the CMake source tree and report anything suspicious...
-#
-message("=============================================================================")
-message("CTEST_FULL_OUTPUT (Avoid ctest truncation of output)")
-message("")
-message("CMake_BINARY_DIR='${CMake_BINARY_DIR}'")
-message("CMake_SOURCE_DIR='${CMake_SOURCE_DIR}'")
-message("GIT_EXECUTABLE='${GIT_EXECUTABLE}'")
-message("HOME='${HOME}'")
-message("ENV{DASHBOARD_TEST_FROM_CTEST}='$ENV{DASHBOARD_TEST_FROM_CTEST}'")
-message("")
-string(REPLACE "\\" "\\\\" HOME "${HOME}")
-
-
-# Is the build directory the same as or underneath the source directory?
-# (i.e. - is it an "in source" build?)
-#
-set(in_source_build 0)
-set(build_under_source 0)
-
-string(FIND "${CMake_BINARY_DIR}" "${CMake_SOURCE_DIR}/" pos)
-if(pos EQUAL 0)
- message("build dir is *inside* source dir")
- set(build_under_source 1)
-elseif(CMake_SOURCE_DIR STREQUAL "${CMake_BINARY_DIR}")
- message("build dir *is* source dir")
- set(in_source_build 1)
-else()
- string(LENGTH "${CMake_SOURCE_DIR}" src_len)
- string(LENGTH "${CMake_BINARY_DIR}" bin_len)
-
- if(bin_len GREATER src_len)
- math(EXPR substr_len "${src_len}+1")
- string(SUBSTRING "${CMake_BINARY_DIR}" 0 ${substr_len} bin_dir)
- if(bin_dir STREQUAL "${CMake_SOURCE_DIR}/")
- message("build dir is under source dir")
- set(in_source_build 1)
- endif()
- endif()
-endif()
-
-message("src_len='${src_len}'")
-message("bin_len='${bin_len}'")
-message("substr_len='${substr_len}'")
-message("bin_dir='${bin_dir}'")
-message("in_source_build='${in_source_build}'")
-message("build_under_source='${build_under_source}'")
-message("")
-
-if(build_under_source)
- message(STATUS "Skipping rest of test because build tree is under source tree")
- return()
-endif()
-
-# If this does not appear to be a git checkout, just pass the test here
-# and now. (Do not let the test fail if it is run in a tree *exported* from a
-# repository or unpacked from a .zip file source installer...)
-#
-set(is_git_checkout 0)
-if(EXISTS "${CMake_SOURCE_DIR}/.git")
- set(is_git_checkout 1)
-endif()
-
-message("is_git_checkout='${is_git_checkout}'")
-message("")
-
-if(NOT is_git_checkout)
- message("source tree is not a git checkout... test passes by early return...")
- return()
-endif()
-
-# This test looks for the following types of changes in the source tree:
-#
-set(additions 0)
-set(conflicts 0)
-set(modifications 0)
-set(nonadditions 0)
-
-# ov == output variable... conditionally filled in by either git below:
-#
-set(cmd "")
-set(ov "")
-set(ev "")
-set(rv "")
-
-# If no GIT_EXECUTABLE, see if we can figure out which git was used
-# for the ctest_update step on this dashboard...
-#
-if(is_git_checkout AND NOT GIT_EXECUTABLE)
- set(ctest_ini_file "")
- set(exe "")
-
- # Use the old name:
- if(EXISTS "${CMake_BINARY_DIR}/DartConfiguration.tcl")
- set(ctest_ini_file "${CMake_BINARY_DIR}/DartConfiguration.tcl")
- endif()
-
- # But if it exists, prefer the new name:
- if(EXISTS "${CMake_BINARY_DIR}/CTestConfiguration.ini")
- set(ctest_ini_file "${CMake_BINARY_DIR}/CTestConfiguration.ini")
- endif()
-
- # If there is a ctest ini file, read the update command or git command
- # from it:
- #
- if(ctest_ini_file)
- file(STRINGS "${ctest_ini_file}" line REGEX "^GITCommand: (.*)$")
- string(REGEX REPLACE "^GITCommand: (.*)$" "\\1" line "${line}")
- if("${line}" MATCHES "^\"")
- string(REGEX REPLACE "^\"([^\"]+)\" *.*$" "\\1" line "${line}")
- else()
- string(REGEX REPLACE "^([^ ]+) *.*$" "\\1" line "${line}")
- endif()
- set(exe "${line}")
- if("${exe}" STREQUAL "GITCOMMAND-NOTFOUND")
- set(exe "")
- endif()
- if(exe)
- message("info: GIT_EXECUTABLE set by 'GITCommand:' from '${ctest_ini_file}'")
- endif()
-
- if(NOT exe)
- file(STRINGS "${ctest_ini_file}" line REGEX "^UpdateCommand: (.*)$")
- string(REGEX REPLACE "^UpdateCommand: (.*)$" "\\1" line "${line}")
- if("${line}" MATCHES "^\"")
- string(REGEX REPLACE "^\"([^\"]+)\" *.*$" "\\1" line "${line}")
- else()
- string(REGEX REPLACE "^([^ ]+) *.*$" "\\1" line "${line}")
- endif()
- set(exe "${line}")
- if("${exe}" STREQUAL "GITCOMMAND-NOTFOUND")
- set(exe "")
- endif()
- if(exe)
- message("info: GIT_EXECUTABLE set by 'UpdateCommand:' from '${ctest_ini_file}'")
- endif()
- endif()
- else()
- message("info: no DartConfiguration.tcl or CTestConfiguration.ini file...")
- endif()
-
- # If we have still not grokked the exe, look in the Update.xml file to see
- # if we can parse it from there...
- #
- if(NOT exe)
- file(GLOB_RECURSE update_xml_file "${CMake_BINARY_DIR}/Testing/Update.xml")
- if(update_xml_file)
- file(STRINGS "${update_xml_file}" line
- REGEX "^.*<UpdateCommand>(.*)</UpdateCommand>$" LIMIT_COUNT 1)
- string(REPLACE "&quot\;" "\"" line "${line}")
- string(REGEX REPLACE "^.*<UpdateCommand>(.*)</UpdateCommand>$" "\\1" line "${line}")
- if("${line}" MATCHES "^\"")
- string(REGEX REPLACE "^\"([^\"]+)\" *.*$" "\\1" line "${line}")
- else()
- string(REGEX REPLACE "^([^ ]+) *.*$" "\\1" line "${line}")
- endif()
- if(line)
- set(exe "${line}")
- endif()
- if(exe)
- message("info: GIT_EXECUTABLE set by '<UpdateCommand>' from '${update_xml_file}'")
- endif()
- else()
- message("info: no Update.xml file...")
- endif()
- endif()
-
- if(exe)
- set(GIT_EXECUTABLE "${exe}")
- message("GIT_EXECUTABLE='${GIT_EXECUTABLE}'")
- message("")
-
- if(NOT EXISTS "${GIT_EXECUTABLE}")
- message(FATAL_ERROR "GIT_EXECUTABLE does not exist...")
- endif()
- else()
- message(FATAL_ERROR "could not determine GIT_EXECUTABLE...")
- endif()
-endif()
-
-
-if(is_git_checkout AND GIT_EXECUTABLE)
- # Check with "git status" if there are any local modifications to the
- # CMake source tree:
- #
- message("=============================================================================")
- message("This is a git checkout, using git to verify source tree....")
- message("")
-
- execute_process(COMMAND ${GIT_EXECUTABLE} --version
- WORKING_DIRECTORY ${CMake_SOURCE_DIR}
- OUTPUT_VARIABLE version_output
- OUTPUT_STRIP_TRAILING_WHITESPACE)
- message("=== output of 'git --version' ===")
- message("${version_output}")
- message("=== end output ===")
- message("")
-
- execute_process(COMMAND ${GIT_EXECUTABLE} branch -a
- WORKING_DIRECTORY ${CMake_SOURCE_DIR}
- OUTPUT_VARIABLE git_branch_output
- OUTPUT_STRIP_TRAILING_WHITESPACE)
- message("=== output of 'git branch -a' ===")
- message("${git_branch_output}")
- message("=== end output ===")
- message("")
-
- execute_process(COMMAND ${GIT_EXECUTABLE} log -1
- WORKING_DIRECTORY ${CMake_SOURCE_DIR}
- OUTPUT_VARIABLE git_log_output
- OUTPUT_STRIP_TRAILING_WHITESPACE)
- message("=== output of 'git log -1' ===")
- message("${git_log_output}")
- message("=== end output ===")
- message("")
-
- message("Copy/paste this command to reproduce:")
- message("cd \"${CMake_SOURCE_DIR}\" && \"${GIT_EXECUTABLE}\" status")
- message("")
-
- set(cmd ${GIT_EXECUTABLE} status)
-endif()
-
-
-if(cmd)
- # Use the HOME value passed in to the script for calling git so it can
- # find its user/global config settings...
- #
- set(original_ENV_HOME "$ENV{HOME}")
- set(ENV{HOME} "${HOME}")
-
- execute_process(COMMAND ${cmd}
- WORKING_DIRECTORY ${CMake_SOURCE_DIR}
- OUTPUT_VARIABLE ov
- ERROR_VARIABLE ev
- RESULT_VARIABLE rv)
-
- set(ENV{HOME} "${original_ENV_HOME}")
-
- message("Results of running ${cmd}")
- message("rv='${rv}'")
- message("ov='${ov}'")
- message("ev='${ev}'")
- message("")
-
- if(NOT rv STREQUAL 0)
- if(is_git_checkout AND (rv STREQUAL "1"))
- # Many builds of git return "1" from a "nothing is changed" git status call...
- # Do not fail with an error for rv==1 with git...
- else()
- message(FATAL_ERROR "error: ${cmd} attempt failed... (see output above)")
- endif()
- endif()
-else()
- message(FATAL_ERROR "error: no COMMAND to run to analyze source tree...")
-endif()
-
-
-# Analyze output:
-#
-if(NOT ov STREQUAL "")
- string(REPLACE ";" "\\\\;" lines "${ov}")
- string(REPLACE "\n" "E;" lines "${lines}")
-
- foreach(line ${lines})
- message("'${line}'")
-
- # But do not consider files that exist just because some user poked around
- # the file system with Windows Explorer or with the Finder from a Mac...
- # ('Thumbs.db' and '.DS_Store' files...)
- #
- set(consider 1)
- set(ignore_files_regex "^(. |.*(/|\\\\))(\\.DS_Store|Thumbs.db)E$")
- if(line MATCHES "${ignore_files_regex}")
- message(" line matches '${ignore_files_regex}' -- not considered")
- set(consider 0)
- endif()
-
- if(consider)
- if(is_git_checkout)
- if(line MATCHES "^#?[ \t]*modified:")
- message(" locally modified file detected...")
- set(modifications 1)
- endif()
-
- if(line MATCHES "^(# )?Untracked")
- message(" locally non-added file/directory detected...")
- set(nonadditions 1)
- endif()
- endif()
- endif()
- endforeach()
-endif()
-
-
-message("=============================================================================")
-message("additions='${additions}'")
-message("conflicts='${conflicts}'")
-message("modifications='${modifications}'")
-message("nonadditions='${nonadditions}'")
-message("")
-
-
-# Decide if the test passes or fails:
-#
-message("=============================================================================")
-
-if("$ENV{DASHBOARD_TEST_FROM_CTEST}" STREQUAL "")
-
- # developers are allowed to have local additions and modifications...
- message("interactive test run")
- message("")
-
-else()
-
- message("dashboard test run")
- message("")
-
- # but dashboard machines are not allowed to have local additions or modifications...
- if(additions)
- message(FATAL_ERROR "test fails: local source tree additions")
- endif()
-
- if(modifications)
- message(FATAL_ERROR "test fails: local source tree modifications")
- endif()
-
- #
- # It's a dashboard run if ctest was run with '-D ExperimentalTest' or some
- # other -D arg on its command line or if ctest is running a -S script to run
- # a dashboard... Running ctest like that sets the DASHBOARD_TEST_FROM_CTEST
- # env var.
- #
-
-endif()
-
-
-# ...and nobody is allowed to have local non-additions or conflicts...
-# Not even developers.
-#
-if(nonadditions)
- if(in_source_build)
- message("
-warning: test results confounded because this is an 'in-source' build - cannot
-distinguish between non-added files that are in-source build products and
-non-added source files that somebody forgot to 'git add'... - this is only ok
-if this is intentionally an in-source dashboard build... Developers should
-use out-of-source builds to verify a clean source tree with this test...
-
-Allowing test to pass despite the warning message...
-")
- else()
- message(FATAL_ERROR "test fails: local source tree non-additions: use git add before committing, or remove the files from the source tree")
- endif()
-endif()
-
-if(conflicts)
- message(FATAL_ERROR "test fails: local source tree conflicts: resolve before committing")
-endif()
-
-
-# Still here? Good then...
-#
-message("test passes")
-message("")
diff --git a/Tests/CheckSourceTree/CMakeLists.txt b/Tests/CheckSourceTree/CMakeLists.txt
new file mode 100644
index 0000000..d5019d2
--- /dev/null
+++ b/Tests/CheckSourceTree/CMakeLists.txt
@@ -0,0 +1,6 @@
+add_test(NAME CMake.CheckSourceTree
+ COMMAND ${CMAKE_COMMAND} -D GIT_EXECUTABLE=${GIT_EXECUTABLE}
+ -D CMake_SOURCE_DIR=${CMake_SOURCE_DIR}
+ -P ${CMAKE_CURRENT_LIST_DIR}/check.cmake
+ )
+set_property(TEST CMake.CheckSourceTree PROPERTY RUN_SERIAL 1)
diff --git a/Tests/CheckSourceTree/check.cmake b/Tests/CheckSourceTree/check.cmake
new file mode 100644
index 0000000..c2e3529
--- /dev/null
+++ b/Tests/CheckSourceTree/check.cmake
@@ -0,0 +1,22 @@
+# Give Git access to the real home directory to get user's settings.
+if(DEFINED ENV{CTEST_REAL_HOME})
+ set(ENV{HOME} "$ENV{CTEST_REAL_HOME}")
+endif()
+
+execute_process(
+ COMMAND "${GIT_EXECUTABLE}" status
+ WORKING_DIRECTORY "${CMake_SOURCE_DIR}"
+ OUTPUT_VARIABLE output
+ ERROR_VARIABLE output
+ RESULT_VARIABLE result
+ )
+string(REPLACE "\n" "\n " output " ${output}")
+if(NOT result EQUAL 0)
+ message(FATAL_ERROR "'git status' failed (${result}):\n${output}")
+endif()
+
+if(output MATCHES "\n[ \t#]*(Changes |new file:|modified:|Untracked )")
+ message(FATAL_ERROR "The source tree is not clean. 'git status' reports:\n${output}")
+endif()
+
+message(STATUS "The source tree is clean.")
diff --git a/Tests/RunCMake/CheckCompilerFlag/CheckCCompilerFlag.cmake b/Tests/RunCMake/CheckCompilerFlag/CheckCCompilerFlag.cmake
index 276158c..bfb6f72 100644
--- a/Tests/RunCMake/CheckCompilerFlag/CheckCCompilerFlag.cmake
+++ b/Tests/RunCMake/CheckCompilerFlag/CheckCCompilerFlag.cmake
@@ -1,33 +1,27 @@
enable_language (C)
-include(CheckCompilerFlag)
+include(CheckCCompilerFlag)
set(C 1) # test that this is tolerated
-# test that the check uses an isolated locale
-set(_env_LC_ALL "${LC_ALL}")
-set(ENV{LC_ALL} "BAD")
-
-check_compiler_flag(C "-_this_is_not_a_flag_" SHOULD_FAIL)
-if(SHOULD_FAIL)
- message(SEND_ERROR "invalid C compile flag didn't fail.")
+if(NOT CMAKE_C_COMPILER_ID STREQUAL "PathScale")
+ set(DD --)
endif()
-if(CMAKE_C_COMPILER_ID MATCHES "GNU|LCC|Clang" AND NOT "x${CMAKE_C_SIMULATE_ID}" STREQUAL "xMSVC")
- check_compiler_flag(C "-x c" SHOULD_WORK)
- if(NOT SHOULD_WORK)
- message(SEND_ERROR "${CMAKE_C_COMPILER_ID} compiler flag '-x c' check failed")
- endif()
+check_c_compiler_flag("${DD}-_this_is_not_a_flag_" C_BOGUS_FLAG)
+if(C_BOGUS_FLAG)
+ message(SEND_ERROR "CHECK_C_COMPILER_FLAG() succeeded, but should have failed")
endif()
-
-if(CMAKE_C_COMPILER_ID STREQUAL "GNU") # LCC C compiler silently ignore -frtti instead of failing, so skip it here.
- check_compiler_flag(C "-frtti" SHOULD_FAIL_RTTI)
- if(SHOULD_FAIL_RTTI)
- message(SEND_ERROR "${CMAKE_C_COMPILER_ID} compiler flag '-frtti' check passed but should have failed")
- endif()
+unset(C_BOGUS_FLAG CACHE)
+if(DEFINED C_BOGUS_FLAG)
+ # Verify that CHECK_C_COMPILER_FLAG didn't construct a normal variable
+ message(SEND_ERROR "CHECK_C_COMPILER_FLAG shouldn't construct C_BOGUS_FLAG as a normal variable")
endif()
-if(NOT "$ENV{LC_ALL}" STREQUAL "BAD")
- message(SEND_ERROR "ENV{LC_ALL} was not preserved by check_compiler_flag")
+if(CMAKE_C_COMPILER_ID STREQUAL "GNU" OR CMAKE_C_COMPILER_ID STREQUAL "LCC")
+ unset(C_STRICT_PROTOTYPES CACHE)
+ CHECK_C_COMPILER_FLAG("-Werror;-Wstrict-prototypes" C_STRICT_PROTOTYPES)
+ if(NOT C_STRICT_PROTOTYPES)
+ message(SEND_ERROR "CHECK_C_COMPILER_FLAG failed -Werror -Wstrict-prototypes")
+ endif()
endif()
-set(ENV{LC_ALL} ${_env_LC_ALL})
diff --git a/Tests/RunCMake/CheckCompilerFlag/CheckCXXCompilerFlag.cmake b/Tests/RunCMake/CheckCompilerFlag/CheckCXXCompilerFlag.cmake
index dec31ec..eb20eb4 100644
--- a/Tests/RunCMake/CheckCompilerFlag/CheckCXXCompilerFlag.cmake
+++ b/Tests/RunCMake/CheckCompilerFlag/CheckCXXCompilerFlag.cmake
@@ -1,26 +1,19 @@
enable_language (CXX)
-include(CheckCompilerFlag)
+include(CheckCXXCompilerFlag)
set(CXX 1) # test that this is tolerated
-# test that the check uses an isolated locale
-set(_env_LC_ALL "${LC_ALL}")
-set(ENV{LC_ALL} "BAD")
-
-check_compiler_flag(CXX "-_this_is_not_a_flag_" SHOULD_FAIL)
-if(SHOULD_FAIL)
- message(SEND_ERROR "invalid CXX compile flag didn't fail.")
+if(NOT CMAKE_CXX_COMPILER_ID STREQUAL "PathScale")
+ set(DD --)
endif()
-if(CMAKE_CXX_COMPILER_ID MATCHES "GNU|LCC|Clang" AND NOT "x${CMAKE_CXX_SIMULATE_ID}" STREQUAL "xMSVC")
- check_compiler_flag(CXX "-x c++" SHOULD_WORK)
- if(NOT SHOULD_WORK)
- message(SEND_ERROR "${CMAKE_CXX_COMPILER_ID} compiler flag '-x c++' check failed")
- endif()
+check_cxx_compiler_flag("${DD}-_this_is_not_a_flag_" CXX_BOGUS_FLAG)
+if(CXX_BOGUS_FLAG)
+ message(SEND_ERROR "CHECK_CXX_COMPILER_FLAG() succeeded, but should have failed")
endif()
-
-if(NOT "$ENV{LC_ALL}" STREQUAL "BAD")
- message(SEND_ERROR "ENV{LC_ALL} was not preserved by check_compiler_flag")
+unset(CXX_BOGUS_FLAG CACHE)
+if(DEFINED CXX_BOGUS_FLAG)
+ # Verify that CHECK_CXX_COMPILER_FLAG didn't construct a normal variable
+ message(SEND_ERROR "CHECK_CXX_COMPILER_FLAG shouldn't construct CXX_BOGUS_FLAG as a normal variable")
endif()
-set(ENV{LC_ALL} ${_env_LC_ALL})
diff --git a/Tests/RunCMake/CheckCompilerFlag/CheckCompilerFlagC.cmake b/Tests/RunCMake/CheckCompilerFlag/CheckCompilerFlagC.cmake
new file mode 100644
index 0000000..276158c
--- /dev/null
+++ b/Tests/RunCMake/CheckCompilerFlag/CheckCompilerFlagC.cmake
@@ -0,0 +1,33 @@
+
+enable_language (C)
+include(CheckCompilerFlag)
+
+set(C 1) # test that this is tolerated
+
+# test that the check uses an isolated locale
+set(_env_LC_ALL "${LC_ALL}")
+set(ENV{LC_ALL} "BAD")
+
+check_compiler_flag(C "-_this_is_not_a_flag_" SHOULD_FAIL)
+if(SHOULD_FAIL)
+ message(SEND_ERROR "invalid C compile flag didn't fail.")
+endif()
+
+if(CMAKE_C_COMPILER_ID MATCHES "GNU|LCC|Clang" AND NOT "x${CMAKE_C_SIMULATE_ID}" STREQUAL "xMSVC")
+ check_compiler_flag(C "-x c" SHOULD_WORK)
+ if(NOT SHOULD_WORK)
+ message(SEND_ERROR "${CMAKE_C_COMPILER_ID} compiler flag '-x c' check failed")
+ endif()
+endif()
+
+if(CMAKE_C_COMPILER_ID STREQUAL "GNU") # LCC C compiler silently ignore -frtti instead of failing, so skip it here.
+ check_compiler_flag(C "-frtti" SHOULD_FAIL_RTTI)
+ if(SHOULD_FAIL_RTTI)
+ message(SEND_ERROR "${CMAKE_C_COMPILER_ID} compiler flag '-frtti' check passed but should have failed")
+ endif()
+endif()
+
+if(NOT "$ENV{LC_ALL}" STREQUAL "BAD")
+ message(SEND_ERROR "ENV{LC_ALL} was not preserved by check_compiler_flag")
+endif()
+set(ENV{LC_ALL} ${_env_LC_ALL})
diff --git a/Tests/RunCMake/CheckCompilerFlag/CheckCUDACompilerFlag.cmake b/Tests/RunCMake/CheckCompilerFlag/CheckCompilerFlagCUDA.cmake
index 681a546..681a546 100644
--- a/Tests/RunCMake/CheckCompilerFlag/CheckCUDACompilerFlag.cmake
+++ b/Tests/RunCMake/CheckCompilerFlag/CheckCompilerFlagCUDA.cmake
diff --git a/Tests/RunCMake/CheckCompilerFlag/CheckCompilerFlagCXX.cmake b/Tests/RunCMake/CheckCompilerFlag/CheckCompilerFlagCXX.cmake
new file mode 100644
index 0000000..dec31ec
--- /dev/null
+++ b/Tests/RunCMake/CheckCompilerFlag/CheckCompilerFlagCXX.cmake
@@ -0,0 +1,26 @@
+
+enable_language (CXX)
+include(CheckCompilerFlag)
+
+set(CXX 1) # test that this is tolerated
+
+# test that the check uses an isolated locale
+set(_env_LC_ALL "${LC_ALL}")
+set(ENV{LC_ALL} "BAD")
+
+check_compiler_flag(CXX "-_this_is_not_a_flag_" SHOULD_FAIL)
+if(SHOULD_FAIL)
+ message(SEND_ERROR "invalid CXX compile flag didn't fail.")
+endif()
+
+if(CMAKE_CXX_COMPILER_ID MATCHES "GNU|LCC|Clang" AND NOT "x${CMAKE_CXX_SIMULATE_ID}" STREQUAL "xMSVC")
+ check_compiler_flag(CXX "-x c++" SHOULD_WORK)
+ if(NOT SHOULD_WORK)
+ message(SEND_ERROR "${CMAKE_CXX_COMPILER_ID} compiler flag '-x c++' check failed")
+ endif()
+endif()
+
+if(NOT "$ENV{LC_ALL}" STREQUAL "BAD")
+ message(SEND_ERROR "ENV{LC_ALL} was not preserved by check_compiler_flag")
+endif()
+set(ENV{LC_ALL} ${_env_LC_ALL})
diff --git a/Tests/RunCMake/CheckCompilerFlag/CheckFortranCompilerFlag.cmake b/Tests/RunCMake/CheckCompilerFlag/CheckCompilerFlagFortran.cmake
index 236f37b..236f37b 100644
--- a/Tests/RunCMake/CheckCompilerFlag/CheckFortranCompilerFlag.cmake
+++ b/Tests/RunCMake/CheckCompilerFlag/CheckCompilerFlagFortran.cmake
diff --git a/Tests/RunCMake/CheckCompilerFlag/CheckHIPCompilerFlag.cmake b/Tests/RunCMake/CheckCompilerFlag/CheckCompilerFlagHIP.cmake
index 339ce18..339ce18 100644
--- a/Tests/RunCMake/CheckCompilerFlag/CheckHIPCompilerFlag.cmake
+++ b/Tests/RunCMake/CheckCompilerFlag/CheckCompilerFlagHIP.cmake
diff --git a/Tests/RunCMake/CheckCompilerFlag/CheckISPCCompilerFlag.cmake b/Tests/RunCMake/CheckCompilerFlag/CheckCompilerFlagISPC.cmake
index 662319a..662319a 100644
--- a/Tests/RunCMake/CheckCompilerFlag/CheckISPCCompilerFlag.cmake
+++ b/Tests/RunCMake/CheckCompilerFlag/CheckCompilerFlagISPC.cmake
diff --git a/Tests/RunCMake/CheckCompilerFlag/CheckOBJCCompilerFlag.cmake b/Tests/RunCMake/CheckCompilerFlag/CheckCompilerFlagOBJC.cmake
index f250f8d..f250f8d 100644
--- a/Tests/RunCMake/CheckCompilerFlag/CheckOBJCCompilerFlag.cmake
+++ b/Tests/RunCMake/CheckCompilerFlag/CheckCompilerFlagOBJC.cmake
diff --git a/Tests/RunCMake/CheckCompilerFlag/CheckOBJCXXCompilerFlag.cmake b/Tests/RunCMake/CheckCompilerFlag/CheckCompilerFlagOBJCXX.cmake
index bc940a6..bc940a6 100644
--- a/Tests/RunCMake/CheckCompilerFlag/CheckOBJCXXCompilerFlag.cmake
+++ b/Tests/RunCMake/CheckCompilerFlag/CheckCompilerFlagOBJCXX.cmake
diff --git a/Tests/RunCMake/CheckCompilerFlag/RunCMakeTest.cmake b/Tests/RunCMake/CheckCompilerFlag/RunCMakeTest.cmake
index df2b667..b0e025c 100644
--- a/Tests/RunCMake/CheckCompilerFlag/RunCMakeTest.cmake
+++ b/Tests/RunCMake/CheckCompilerFlag/RunCMakeTest.cmake
@@ -5,28 +5,30 @@ run_cmake(NonExistentLanguage)
run_cmake(CheckCCompilerFlag)
run_cmake(CheckCXXCompilerFlag)
+run_cmake(CheckCompilerFlagC)
+run_cmake(CheckCompilerFlagCXX)
if (APPLE)
- run_cmake(CheckOBJCCompilerFlag)
- run_cmake(CheckOBJCXXCompilerFlag)
+ run_cmake(CheckCompilerFlagOBJC)
+ run_cmake(CheckCompilerFlagOBJCXX)
endif()
if (CMAKE_Fortran_COMPILER_ID)
- run_cmake(CheckFortranCompilerFlag)
+ run_cmake(CheckCompilerFlagFortran)
endif()
if (CMake_TEST_CUDA)
- run_cmake(CheckCUDACompilerFlag)
+ run_cmake(CheckCompilerFlagCUDA)
endif()
if(CMake_TEST_ISPC)
- run_cmake(CheckISPCCompilerFlag)
+ run_cmake(CheckCompilerFlagISPC)
endif()
if(CMake_TEST_HIP)
- run_cmake(CheckHIPCompilerFlag)
+ run_cmake(CheckCompilerFlagHIP)
endif()
if(APPLE)
- run_cmake_with_options(HeaderpadWorkaround --debug-trycompile)
+ run_cmake(HeaderpadWorkaround)
endif()
diff --git a/Tests/RunCMake/CheckLinkerFlag/CheckCLinkerFlag.cmake b/Tests/RunCMake/CheckLinkerFlag/CheckLinkerFlagC.cmake
index c8e87a4..c8e87a4 100644
--- a/Tests/RunCMake/CheckLinkerFlag/CheckCLinkerFlag.cmake
+++ b/Tests/RunCMake/CheckLinkerFlag/CheckLinkerFlagC.cmake
diff --git a/Tests/RunCMake/CheckLinkerFlag/CheckCUDALinkerFlag.cmake b/Tests/RunCMake/CheckLinkerFlag/CheckLinkerFlagCUDA.cmake
index 84d6dd9..84d6dd9 100644
--- a/Tests/RunCMake/CheckLinkerFlag/CheckCUDALinkerFlag.cmake
+++ b/Tests/RunCMake/CheckLinkerFlag/CheckLinkerFlagCUDA.cmake
diff --git a/Tests/RunCMake/CheckLinkerFlag/CheckCXXLinkerFlag.cmake b/Tests/RunCMake/CheckLinkerFlag/CheckLinkerFlagCXX.cmake
index 4e299b9..4e299b9 100644
--- a/Tests/RunCMake/CheckLinkerFlag/CheckCXXLinkerFlag.cmake
+++ b/Tests/RunCMake/CheckLinkerFlag/CheckLinkerFlagCXX.cmake
diff --git a/Tests/RunCMake/CheckLinkerFlag/CheckFortranLinkerFlag.cmake b/Tests/RunCMake/CheckLinkerFlag/CheckLinkerFlagFortran.cmake
index bca288e..bca288e 100644
--- a/Tests/RunCMake/CheckLinkerFlag/CheckFortranLinkerFlag.cmake
+++ b/Tests/RunCMake/CheckLinkerFlag/CheckLinkerFlagFortran.cmake
diff --git a/Tests/RunCMake/CheckLinkerFlag/CheckHIPLinkerFlag.cmake b/Tests/RunCMake/CheckLinkerFlag/CheckLinkerFlagHIP.cmake
index 3bf3b30..3bf3b30 100644
--- a/Tests/RunCMake/CheckLinkerFlag/CheckHIPLinkerFlag.cmake
+++ b/Tests/RunCMake/CheckLinkerFlag/CheckLinkerFlagHIP.cmake
diff --git a/Tests/RunCMake/CheckLinkerFlag/CheckOBJCLinkerFlag.cmake b/Tests/RunCMake/CheckLinkerFlag/CheckLinkerFlagOBJC.cmake
index fa1d18e..fa1d18e 100644
--- a/Tests/RunCMake/CheckLinkerFlag/CheckOBJCLinkerFlag.cmake
+++ b/Tests/RunCMake/CheckLinkerFlag/CheckLinkerFlagOBJC.cmake
diff --git a/Tests/RunCMake/CheckLinkerFlag/CheckOBJCXXLinkerFlag.cmake b/Tests/RunCMake/CheckLinkerFlag/CheckLinkerFlagOBJCXX.cmake
index 414efb8..414efb8 100644
--- a/Tests/RunCMake/CheckLinkerFlag/CheckOBJCXXLinkerFlag.cmake
+++ b/Tests/RunCMake/CheckLinkerFlag/CheckLinkerFlagOBJCXX.cmake
diff --git a/Tests/RunCMake/CheckLinkerFlag/RunCMakeTest.cmake b/Tests/RunCMake/CheckLinkerFlag/RunCMakeTest.cmake
index 39fc430..5915ba1 100644
--- a/Tests/RunCMake/CheckLinkerFlag/RunCMakeTest.cmake
+++ b/Tests/RunCMake/CheckLinkerFlag/RunCMakeTest.cmake
@@ -1,22 +1,22 @@
include(RunCMake)
if (CMAKE_C_COMPILER_ID MATCHES "Clang|GNU|LCC")
- run_cmake(CheckCLinkerFlag)
- run_cmake(CheckCXXLinkerFlag)
+ run_cmake(CheckLinkerFlagC)
+ run_cmake(CheckLinkerFlagCXX)
if (APPLE)
- run_cmake(CheckOBJCLinkerFlag)
- run_cmake(CheckOBJCXXLinkerFlag)
+ run_cmake(CheckLinkerFlagOBJC)
+ run_cmake(CheckLinkerFlagOBJCXX)
endif()
endif()
if (CMAKE_Fortran_COMPILER_ID MATCHES "GNU|LCC")
- run_cmake(CheckFortranLinkerFlag)
+ run_cmake(CheckLinkerFlagFortran)
endif()
if (CMake_TEST_CUDA)
- run_cmake(CheckCUDALinkerFlag)
+ run_cmake(CheckLinkerFlagCUDA)
endif()
if (CMake_TEST_HIP)
- run_cmake(CheckHIPLinkerFlag)
+ run_cmake(CheckLinkerFlagHIP)
endif()
diff --git a/Tests/RunCMake/CheckSourceCompiles/CheckCSourceCompiles.cmake b/Tests/RunCMake/CheckSourceCompiles/CheckCSourceCompiles.cmake
index 4f73622..7104650 100644
--- a/Tests/RunCMake/CheckSourceCompiles/CheckCSourceCompiles.cmake
+++ b/Tests/RunCMake/CheckSourceCompiles/CheckCSourceCompiles.cmake
@@ -1,15 +1,15 @@
enable_language (C)
-include(CheckSourceCompiles)
+include(CheckCSourceCompiles)
set(C 1) # test that this is tolerated
-check_source_compiles(C "I don't build" SHOULD_FAIL)
+check_c_source_compiles("I don't build" SHOULD_FAIL)
if(SHOULD_FAIL)
message(SEND_ERROR "invalid C source didn't fail.")
endif()
-check_source_compiles(C "int main() {return 0;}" SHOULD_BUILD)
+check_c_source_compiles("int main() {return 0;}" SHOULD_BUILD)
if(NOT SHOULD_BUILD)
message(SEND_ERROR "Test fail for valid C source.")
endif()
diff --git a/Tests/RunCMake/CheckSourceCompiles/CheckCXXSourceCompiles.cmake b/Tests/RunCMake/CheckSourceCompiles/CheckCXXSourceCompiles.cmake
index 97c9c30..7c9830a 100644
--- a/Tests/RunCMake/CheckSourceCompiles/CheckCXXSourceCompiles.cmake
+++ b/Tests/RunCMake/CheckSourceCompiles/CheckCXXSourceCompiles.cmake
@@ -1,15 +1,15 @@
enable_language (CXX)
-include(CheckSourceCompiles)
+include(CheckCXXSourceCompiles)
set(CXX 1) # test that this is tolerated
-check_source_compiles(CXX "I don't build" SHOULD_FAIL)
+check_cxx_source_compiles("I don't build" SHOULD_FAIL)
if(SHOULD_FAIL)
message(SEND_ERROR "invalid CXX source didn't fail.")
endif()
-check_source_compiles(CXX [=[
+check_cxx_source_compiles([=[
#include <vector>
int main() {
return 0;
@@ -20,8 +20,8 @@ if(NOT SHOULD_BUILD)
message(SEND_ERROR "Test fail for valid CXX source.")
endif()
-check_source_compiles(CXX "void l(char const (&x)[2]){}; int main() { l(\"\\n\"); return 0;}"
- SHOULD_BUILD_COMPLEX)
+CHECK_CXX_SOURCE_COMPILES("void l(char const (&x)[2]){}; int main() { l(\"\\\\n\"); return 0;}"
+ SHOULD_BUILD_COMPLEX)
if(NOT SHOULD_BUILD_COMPLEX)
message(SEND_ERROR "Test fail for valid CXX complex source.")
diff --git a/Tests/RunCMake/CheckSourceCompiles/CheckOBJCSourceCompiles.cmake b/Tests/RunCMake/CheckSourceCompiles/CheckOBJCSourceCompiles.cmake
index 76a5009..ac43a1e 100644
--- a/Tests/RunCMake/CheckSourceCompiles/CheckOBJCSourceCompiles.cmake
+++ b/Tests/RunCMake/CheckSourceCompiles/CheckOBJCSourceCompiles.cmake
@@ -1,9 +1,14 @@
enable_language (OBJC)
-include(CheckSourceCompiles)
+include(CheckOBJCSourceCompiles)
set(OBJC 1) # test that this is tolerated
-check_source_compiles(OBJC [[
+check_objc_source_compiles("I don't build in Objective-C" SHOULD_FAIL)
+if(SHOULD_FAIL)
+ message(SEND_ERROR "invalid OBJC source didn't fail.")
+endif()
+
+check_objc_source_compiles([[
#import <Foundation/Foundation.h>
int main() {
NSObject *foo;
diff --git a/Tests/RunCMake/CheckSourceCompiles/CheckOBJCXXSourceCompiles.cmake b/Tests/RunCMake/CheckSourceCompiles/CheckOBJCXXSourceCompiles.cmake
index 814237e..0088956 100644
--- a/Tests/RunCMake/CheckSourceCompiles/CheckOBJCXXSourceCompiles.cmake
+++ b/Tests/RunCMake/CheckSourceCompiles/CheckOBJCXXSourceCompiles.cmake
@@ -1,9 +1,14 @@
enable_language (OBJCXX)
-include(CheckSourceCompiles)
+include(CheckOBJCXXSourceCompiles)
set(OBJCXX 1) # test that this is tolerated
-check_source_compiles(OBJCXX [[
+check_objcxx_source_compiles("I don't build in Objective-C++" SHOULD_FAIL)
+if(SHOULD_FAIL)
+ message(SEND_ERROR "invalid OBJCXX source didn't fail.")
+endif()
+
+check_objcxx_source_compiles([[
#include <vector>
#import <Foundation/Foundation.h>
int main() {
diff --git a/Tests/RunCMake/CheckSourceCompiles/CheckSourceCompilesC.cmake b/Tests/RunCMake/CheckSourceCompiles/CheckSourceCompilesC.cmake
new file mode 100644
index 0000000..4f73622
--- /dev/null
+++ b/Tests/RunCMake/CheckSourceCompiles/CheckSourceCompilesC.cmake
@@ -0,0 +1,15 @@
+
+enable_language (C)
+include(CheckSourceCompiles)
+
+set(C 1) # test that this is tolerated
+
+check_source_compiles(C "I don't build" SHOULD_FAIL)
+if(SHOULD_FAIL)
+ message(SEND_ERROR "invalid C source didn't fail.")
+endif()
+
+check_source_compiles(C "int main() {return 0;}" SHOULD_BUILD)
+if(NOT SHOULD_BUILD)
+ message(SEND_ERROR "Test fail for valid C source.")
+endif()
diff --git a/Tests/RunCMake/CheckSourceCompiles/CheckCUDASourceCompiles.cmake b/Tests/RunCMake/CheckSourceCompiles/CheckSourceCompilesCUDA.cmake
index 2190649..2190649 100644
--- a/Tests/RunCMake/CheckSourceCompiles/CheckCUDASourceCompiles.cmake
+++ b/Tests/RunCMake/CheckSourceCompiles/CheckSourceCompilesCUDA.cmake
diff --git a/Tests/RunCMake/CheckSourceCompiles/CheckSourceCompilesCXX.cmake b/Tests/RunCMake/CheckSourceCompiles/CheckSourceCompilesCXX.cmake
new file mode 100644
index 0000000..97c9c30
--- /dev/null
+++ b/Tests/RunCMake/CheckSourceCompiles/CheckSourceCompilesCXX.cmake
@@ -0,0 +1,28 @@
+
+enable_language (CXX)
+include(CheckSourceCompiles)
+
+set(CXX 1) # test that this is tolerated
+
+check_source_compiles(CXX "I don't build" SHOULD_FAIL)
+if(SHOULD_FAIL)
+ message(SEND_ERROR "invalid CXX source didn't fail.")
+endif()
+
+check_source_compiles(CXX [=[
+ #include <vector>
+ int main() {
+ return 0;
+ }
+]=]
+ SHOULD_BUILD)
+if(NOT SHOULD_BUILD)
+ message(SEND_ERROR "Test fail for valid CXX source.")
+endif()
+
+check_source_compiles(CXX "void l(char const (&x)[2]){}; int main() { l(\"\\n\"); return 0;}"
+ SHOULD_BUILD_COMPLEX)
+
+if(NOT SHOULD_BUILD_COMPLEX)
+ message(SEND_ERROR "Test fail for valid CXX complex source.")
+endif()
diff --git a/Tests/RunCMake/CheckSourceCompiles/CheckFortranSourceCompiles.cmake b/Tests/RunCMake/CheckSourceCompiles/CheckSourceCompilesFortran.cmake
index 48dc525..48dc525 100644
--- a/Tests/RunCMake/CheckSourceCompiles/CheckFortranSourceCompiles.cmake
+++ b/Tests/RunCMake/CheckSourceCompiles/CheckSourceCompilesFortran.cmake
diff --git a/Tests/RunCMake/CheckSourceCompiles/CheckHIPSourceCompiles.cmake b/Tests/RunCMake/CheckSourceCompiles/CheckSourceCompilesHIP.cmake
index 911a0d7..911a0d7 100644
--- a/Tests/RunCMake/CheckSourceCompiles/CheckHIPSourceCompiles.cmake
+++ b/Tests/RunCMake/CheckSourceCompiles/CheckSourceCompilesHIP.cmake
diff --git a/Tests/RunCMake/CheckSourceCompiles/CheckISPCSourceCompiles.cmake b/Tests/RunCMake/CheckSourceCompiles/CheckSourceCompilesISPC.cmake
index 74b83c0..74b83c0 100644
--- a/Tests/RunCMake/CheckSourceCompiles/CheckISPCSourceCompiles.cmake
+++ b/Tests/RunCMake/CheckSourceCompiles/CheckSourceCompilesISPC.cmake
diff --git a/Tests/RunCMake/CheckSourceCompiles/CheckSourceCompilesOBJC.cmake b/Tests/RunCMake/CheckSourceCompiles/CheckSourceCompilesOBJC.cmake
new file mode 100644
index 0000000..76a5009
--- /dev/null
+++ b/Tests/RunCMake/CheckSourceCompiles/CheckSourceCompilesOBJC.cmake
@@ -0,0 +1,16 @@
+enable_language (OBJC)
+include(CheckSourceCompiles)
+
+set(OBJC 1) # test that this is tolerated
+
+check_source_compiles(OBJC [[
+ #import <Foundation/Foundation.h>
+ int main() {
+ NSObject *foo;
+ return 0;
+ }
+]] SHOULD_BUILD)
+
+if(NOT SHOULD_BUILD)
+ message(SEND_ERROR "Test fail for valid OBJC source.")
+endif()
diff --git a/Tests/RunCMake/CheckSourceCompiles/CheckSourceCompilesOBJCXX.cmake b/Tests/RunCMake/CheckSourceCompiles/CheckSourceCompilesOBJCXX.cmake
new file mode 100644
index 0000000..814237e
--- /dev/null
+++ b/Tests/RunCMake/CheckSourceCompiles/CheckSourceCompilesOBJCXX.cmake
@@ -0,0 +1,19 @@
+enable_language (OBJCXX)
+include(CheckSourceCompiles)
+
+set(OBJCXX 1) # test that this is tolerated
+
+check_source_compiles(OBJCXX [[
+ #include <vector>
+ #import <Foundation/Foundation.h>
+ int main() {
+ std::vector<int> v;
+ NSObject *foo;
+ return 0;
+ }
+]] SHOULD_BUILD)
+
+
+if(NOT SHOULD_BUILD)
+ message(SEND_ERROR "Test fail for OBJCXX source.")
+endif()
diff --git a/Tests/RunCMake/CheckSourceCompiles/RunCMakeTest.cmake b/Tests/RunCMake/CheckSourceCompiles/RunCMakeTest.cmake
index 530f133..df77d3d 100644
--- a/Tests/RunCMake/CheckSourceCompiles/RunCMakeTest.cmake
+++ b/Tests/RunCMake/CheckSourceCompiles/RunCMakeTest.cmake
@@ -6,24 +6,28 @@ run_cmake(UnknownArgument)
run_cmake(CheckCSourceCompiles)
run_cmake(CheckCXXSourceCompiles)
+run_cmake(CheckSourceCompilesC)
+run_cmake(CheckSourceCompilesCXX)
if (APPLE)
run_cmake(CheckOBJCSourceCompiles)
run_cmake(CheckOBJCXXSourceCompiles)
+ run_cmake(CheckSourceCompilesOBJC)
+ run_cmake(CheckSourceCompilesOBJCXX)
endif()
if (CMAKE_Fortran_COMPILER_ID)
- run_cmake(CheckFortranSourceCompiles)
+ run_cmake(CheckSourceCompilesFortran)
endif()
if (CMake_TEST_CUDA)
- run_cmake(CheckCUDASourceCompiles)
+ run_cmake(CheckSourceCompilesCUDA)
endif()
if(CMake_TEST_ISPC)
- run_cmake(CheckISPCSourceCompiles)
+ run_cmake(CheckSourceCompilesISPC)
endif()
if(CMake_TEST_HIP)
- run_cmake(CheckHIPSourceCompiles)
+ run_cmake(CheckSourceCompilesHIP)
endif()
diff --git a/Tests/RunCMake/CheckSourceRuns/CheckCSourceRuns.cmake b/Tests/RunCMake/CheckSourceRuns/CheckCSourceRuns.cmake
index 96a1027..c0f9463 100644
--- a/Tests/RunCMake/CheckSourceRuns/CheckCSourceRuns.cmake
+++ b/Tests/RunCMake/CheckSourceRuns/CheckCSourceRuns.cmake
@@ -1,15 +1,15 @@
enable_language (C)
-include(CheckSourceRuns)
+include(CheckCSourceRuns)
set(C 1) # test that this is tolerated
-check_source_runs(C "int main() {return 2;}" SHOULD_FAIL)
+check_c_source_runs("int main() {return 2;}" SHOULD_FAIL)
if(SHOULD_FAIL)
- message(SEND_ERROR "C check_source_runs succeeded, but should have failed.")
+ message(SEND_ERROR "check_c_source_runs succeeded, but should have failed.")
endif()
-check_source_runs(C "int main() {return 0;}" SHOULD_RUN)
+check_c_source_runs("int main() {return 0;}" SHOULD_RUN)
if(NOT SHOULD_RUN)
- message(SEND_ERROR "C check_source_runs failed for valid C executable.")
+ message(SEND_ERROR "check_c_source_runs failed for valid C executable.")
endif()
diff --git a/Tests/RunCMake/CheckSourceRuns/CheckCXXSourceRuns.cmake b/Tests/RunCMake/CheckSourceRuns/CheckCXXSourceRuns.cmake
index c4bef6e..c4c9026 100644
--- a/Tests/RunCMake/CheckSourceRuns/CheckCXXSourceRuns.cmake
+++ b/Tests/RunCMake/CheckSourceRuns/CheckCXXSourceRuns.cmake
@@ -1,15 +1,15 @@
enable_language (CXX)
-include(CheckSourceRuns)
+include(CheckCXXSourceRuns)
set(CXX 1) # test that this is tolerated
-check_source_runs(CXX "int main() {return 2;}" SHOULD_FAIL)
+check_cxx_source_runs("int main() {return 2;}" SHOULD_FAIL)
if(SHOULD_FAIL)
- message(SEND_ERROR "CXX check_source_runs succeeded, but should have failed.")
+ message(SEND_ERROR "check_cxx_source_runs succeeded, but should have failed.")
endif()
-check_source_runs(CXX
+check_cxx_source_runs(
[=[
#include <vector>
int main() {
@@ -18,5 +18,5 @@ check_source_runs(CXX
]=]
SHOULD_RUN)
if(NOT SHOULD_RUN)
- message(SEND_ERROR "CXX check_source_runs failed for valid C executable.")
+ message(SEND_ERROR "check_cxx_source_runs failed for valid C executable.")
endif()
diff --git a/Tests/RunCMake/CheckSourceRuns/CheckOBJCSourceRuns.cmake b/Tests/RunCMake/CheckSourceRuns/CheckOBJCSourceRuns.cmake
index b828352..604b2a1 100644
--- a/Tests/RunCMake/CheckSourceRuns/CheckOBJCSourceRuns.cmake
+++ b/Tests/RunCMake/CheckSourceRuns/CheckOBJCSourceRuns.cmake
@@ -1,9 +1,14 @@
enable_language (OBJC)
-include(CheckSourceRuns)
+include(CheckOBJCSourceRuns)
set(OBJC 1) # test that this is tolerated
-check_source_runs(OBJC [[
+check_objc_source_runs("int main() {return 2;}" SHOULD_FAIL)
+if(SHOULD_FAIL)
+ message(SEND_ERROR "check_objc_source_runs succeeded, but should have failed.")
+endif()
+
+check_objc_source_runs([[
#import <Foundation/Foundation.h>
int main() {
NSObject *foo;
diff --git a/Tests/RunCMake/CheckSourceRuns/CheckOBJCXXSourceRuns.cmake b/Tests/RunCMake/CheckSourceRuns/CheckOBJCXXSourceRuns.cmake
index 8a56f13..b220166 100644
--- a/Tests/RunCMake/CheckSourceRuns/CheckOBJCXXSourceRuns.cmake
+++ b/Tests/RunCMake/CheckSourceRuns/CheckOBJCXXSourceRuns.cmake
@@ -1,9 +1,14 @@
enable_language (OBJCXX)
-include(CheckSourceRuns)
+include(CheckOBJCXXSourceRuns)
set(OBJCXX 1) # test that this is tolerated
-check_source_runs(OBJCXX [[
+check_objcxx_source_runs("int main() {return 2;}" SHOULD_FAIL)
+if(SHOULD_FAIL)
+ message(SEND_ERROR "check_objcxx_source_runs succeeded, but should have failed.")
+endif()
+
+check_objcxx_source_runs([[
#include <vector>
#import <Foundation/Foundation.h>
int main() {
diff --git a/Tests/RunCMake/CheckSourceRuns/CheckSourceRunsC.cmake b/Tests/RunCMake/CheckSourceRuns/CheckSourceRunsC.cmake
new file mode 100644
index 0000000..96a1027
--- /dev/null
+++ b/Tests/RunCMake/CheckSourceRuns/CheckSourceRunsC.cmake
@@ -0,0 +1,15 @@
+
+enable_language (C)
+include(CheckSourceRuns)
+
+set(C 1) # test that this is tolerated
+
+check_source_runs(C "int main() {return 2;}" SHOULD_FAIL)
+if(SHOULD_FAIL)
+ message(SEND_ERROR "C check_source_runs succeeded, but should have failed.")
+endif()
+
+check_source_runs(C "int main() {return 0;}" SHOULD_RUN)
+if(NOT SHOULD_RUN)
+ message(SEND_ERROR "C check_source_runs failed for valid C executable.")
+endif()
diff --git a/Tests/RunCMake/CheckSourceRuns/CheckCUDASourceRuns.cmake b/Tests/RunCMake/CheckSourceRuns/CheckSourceRunsCUDA.cmake
index ea5f4f9..ea5f4f9 100644
--- a/Tests/RunCMake/CheckSourceRuns/CheckCUDASourceRuns.cmake
+++ b/Tests/RunCMake/CheckSourceRuns/CheckSourceRunsCUDA.cmake
diff --git a/Tests/RunCMake/CheckSourceRuns/CheckSourceRunsCXX.cmake b/Tests/RunCMake/CheckSourceRuns/CheckSourceRunsCXX.cmake
new file mode 100644
index 0000000..c4bef6e
--- /dev/null
+++ b/Tests/RunCMake/CheckSourceRuns/CheckSourceRunsCXX.cmake
@@ -0,0 +1,22 @@
+
+enable_language (CXX)
+include(CheckSourceRuns)
+
+set(CXX 1) # test that this is tolerated
+
+check_source_runs(CXX "int main() {return 2;}" SHOULD_FAIL)
+if(SHOULD_FAIL)
+ message(SEND_ERROR "CXX check_source_runs succeeded, but should have failed.")
+endif()
+
+check_source_runs(CXX
+[=[
+ #include <vector>
+ int main() {
+ return 0;
+ }
+]=]
+ SHOULD_RUN)
+if(NOT SHOULD_RUN)
+ message(SEND_ERROR "CXX check_source_runs failed for valid C executable.")
+endif()
diff --git a/Tests/RunCMake/CheckSourceRuns/CheckFortranSourceRuns.cmake b/Tests/RunCMake/CheckSourceRuns/CheckSourceRunsFortran.cmake
index 50e8ec8..50e8ec8 100644
--- a/Tests/RunCMake/CheckSourceRuns/CheckFortranSourceRuns.cmake
+++ b/Tests/RunCMake/CheckSourceRuns/CheckSourceRunsFortran.cmake
diff --git a/Tests/RunCMake/CheckSourceRuns/CheckHIPSourceRuns.cmake b/Tests/RunCMake/CheckSourceRuns/CheckSourceRunsHIP.cmake
index d9fb8c2..d9fb8c2 100644
--- a/Tests/RunCMake/CheckSourceRuns/CheckHIPSourceRuns.cmake
+++ b/Tests/RunCMake/CheckSourceRuns/CheckSourceRunsHIP.cmake
diff --git a/Tests/RunCMake/CheckSourceRuns/CheckSourceRunsOBJC.cmake b/Tests/RunCMake/CheckSourceRuns/CheckSourceRunsOBJC.cmake
new file mode 100644
index 0000000..b828352
--- /dev/null
+++ b/Tests/RunCMake/CheckSourceRuns/CheckSourceRunsOBJC.cmake
@@ -0,0 +1,16 @@
+enable_language (OBJC)
+include(CheckSourceRuns)
+
+set(OBJC 1) # test that this is tolerated
+
+check_source_runs(OBJC [[
+ #import <Foundation/Foundation.h>
+ int main() {
+ NSObject *foo;
+ return 0;
+ }
+]] SHOULD_BUILD)
+
+if(NOT SHOULD_BUILD)
+ message(SEND_ERROR "Test fail for valid OBJC source.")
+endif()
diff --git a/Tests/RunCMake/CheckSourceRuns/CheckSourceRunsOBJCXX.cmake b/Tests/RunCMake/CheckSourceRuns/CheckSourceRunsOBJCXX.cmake
new file mode 100644
index 0000000..8a56f13
--- /dev/null
+++ b/Tests/RunCMake/CheckSourceRuns/CheckSourceRunsOBJCXX.cmake
@@ -0,0 +1,19 @@
+enable_language (OBJCXX)
+include(CheckSourceRuns)
+
+set(OBJCXX 1) # test that this is tolerated
+
+check_source_runs(OBJCXX [[
+ #include <vector>
+ #import <Foundation/Foundation.h>
+ int main() {
+ std::vector<int> v;
+ NSObject *foo;
+ return 0;
+ }
+]] SHOULD_BUILD)
+
+
+if(NOT SHOULD_BUILD)
+ message(SEND_ERROR "Test fail for OBJCXX source.")
+endif()
diff --git a/Tests/RunCMake/CheckSourceRuns/RunCMakeTest.cmake b/Tests/RunCMake/CheckSourceRuns/RunCMakeTest.cmake
index 4784103..64cecfc 100644
--- a/Tests/RunCMake/CheckSourceRuns/RunCMakeTest.cmake
+++ b/Tests/RunCMake/CheckSourceRuns/RunCMakeTest.cmake
@@ -6,20 +6,24 @@ run_cmake(UnknownArgument)
run_cmake(CheckCSourceRuns)
run_cmake(CheckCXXSourceRuns)
+run_cmake(CheckSourceRunsC)
+run_cmake(CheckSourceRunsCXX)
if (APPLE)
run_cmake(CheckOBJCSourceRuns)
run_cmake(CheckOBJCXXSourceRuns)
+ run_cmake(CheckSourceRunsOBJC)
+ run_cmake(CheckSourceRunsOBJCXX)
endif()
if (CMAKE_Fortran_COMPILER_ID)
- run_cmake(CheckFortranSourceRuns)
+ run_cmake(CheckSourceRunsFortran)
endif()
if (CMake_TEST_CUDA)
- run_cmake(CheckCUDASourceRuns)
+ run_cmake(CheckSourceRunsCUDA)
endif()
if (CMake_TEST_HIP)
- run_cmake(CheckHIPSourceRuns)
+ run_cmake(CheckSourceRunsHIP)
endif()
diff --git a/Tests/RunCMake/CommandLine/debug-trycompile-stderr.txt b/Tests/RunCMake/CommandLine/debug-trycompile-stderr.txt
new file mode 100644
index 0000000..e987300
--- /dev/null
+++ b/Tests/RunCMake/CommandLine/debug-trycompile-stderr.txt
@@ -0,0 +1,11 @@
+^CMake Debug Log at [^
+]*/Modules/CMakeDetermineCompilerABI.cmake:[0-9]+ \(try_compile\):
+ Executing try_compile \(CMAKE_C_ABI_COMPILED\) in:
+
+ [^
+]*/Tests/RunCMake/CommandLine/debug-trycompile-build/CMakeFiles/CMakeScratch/TryCompile-[^/]+
+Call Stack \(most recent call first\):
+ [^
+]*/Modules/CMakeTestCCompiler.cmake:[0-9]+ \(CMAKE_DETERMINE_COMPILER_ABI\)
+ debug-trycompile.cmake:[0-9]+ \(enable_language\)
+ CMakeLists.txt:[0-9]+ \(include\)
diff --git a/Tests/RunCMake/Ninja/QtAutoMocSkipPch.cmake b/Tests/RunCMake/Ninja/QtAutoMocSkipPch.cmake
new file mode 100644
index 0000000..059b917
--- /dev/null
+++ b/Tests/RunCMake/Ninja/QtAutoMocSkipPch.cmake
@@ -0,0 +1,17 @@
+enable_language(CXX)
+
+set(QtX Qt${with_qt_version})
+
+find_package(${QtX} REQUIRED COMPONENTS Core)
+
+set(CMAKE_AUTOMOC ON)
+
+add_library(simple_lib SHARED simple_lib.cpp)
+add_executable(app_with_qt app.cpp app_qt.cpp)
+
+target_link_libraries(app_with_qt PRIVATE simple_lib ${QtX}::Core)
+
+set_source_files_properties(app.cpp app_qt.cpp
+ PROPERTIES SKIP_PRECOMPILE_HEADERS ON)
+
+target_precompile_headers(app_with_qt PRIVATE [["QObject"]])
diff --git a/Tests/RunCMake/Ninja/RunCMakeTest.cmake b/Tests/RunCMake/Ninja/RunCMakeTest.cmake
index 2a5b556..9f078e6 100644
--- a/Tests/RunCMake/Ninja/RunCMakeTest.cmake
+++ b/Tests/RunCMake/Ninja/RunCMakeTest.cmake
@@ -357,6 +357,22 @@ function(run_QtAutoMocDeps)
run_ninja("${RunCMake_TEST_BINARY_DIR}")
endif()
endfunction()
+
+function(run_QtAutoMocSkipPch)
+ set(QtX Qt${CMake_TEST_Qt_version})
+ if(CMake_TEST_${QtX}Core_Version VERSION_GREATER_EQUAL 5.15.0)
+ set(RunCMake_TEST_BINARY_DIR ${RunCMake_BINARY_DIR}/QtAutoMocSkipPch-build)
+ run_cmake_with_options(QtAutoMocSkipPch
+ "-Dwith_qt_version=${CMake_TEST_Qt_version}"
+ "-D${QtX}_DIR=${${QtX}_DIR}"
+ "-D${QtX}Core_DIR=${${QtX}Core_DIR}"
+ "-DCMAKE_PREFIX_PATH:STRING=${CMAKE_PREFIX_PATH}"
+ )
+ # Build the project.
+ run_ninja("${RunCMake_TEST_BINARY_DIR}")
+ endif()
+endfunction()
if(CMake_TEST_Qt_version)
run_QtAutoMocDeps()
+ run_QtAutoMocSkipPch()
endif()
diff --git a/Tests/RunCMake/install/DIRECTORY-symlink-clobber-all-result.txt b/Tests/RunCMake/install/DIRECTORY-symlink-clobber-all-result.txt
new file mode 100644
index 0000000..d00491f
--- /dev/null
+++ b/Tests/RunCMake/install/DIRECTORY-symlink-clobber-all-result.txt
@@ -0,0 +1 @@
+1
diff --git a/Tests/RunCMake/install/DIRECTORY-symlink-clobber-all-stderr.txt b/Tests/RunCMake/install/DIRECTORY-symlink-clobber-all-stderr.txt
new file mode 100644
index 0000000..d082b8a
--- /dev/null
+++ b/Tests/RunCMake/install/DIRECTORY-symlink-clobber-all-stderr.txt
@@ -0,0 +1,12 @@
+^CMake Error at cmake_install.cmake:[0-9]+ \(file\):
+ file INSTALL cannot duplicate symlink
+
+ [^
+]*/Tests/RunCMake/install/DIRECTORY-symlink-clobber-build/new/dir
+
+ at
+
+ [^
+]*/Tests/RunCMake/install/DIRECTORY-symlink-clobber-build/root-all/dest/dir
+
+ because: A directory already exists at that location
diff --git a/Tests/RunCMake/install/DIRECTORY-symlink-clobber-all-stdout.txt b/Tests/RunCMake/install/DIRECTORY-symlink-clobber-all-stdout.txt
new file mode 100644
index 0000000..db8ca10
--- /dev/null
+++ b/Tests/RunCMake/install/DIRECTORY-symlink-clobber-all-stdout.txt
@@ -0,0 +1,12 @@
+-- Installing: [^
+]*/Tests/RunCMake/install/DIRECTORY-symlink-clobber-build/root-all/dest/dir
+-- Installing: [^
+]*/Tests/RunCMake/install/DIRECTORY-symlink-clobber-build/root-all/dest/dir/file
+-- Installing: [^
+]*/Tests/RunCMake/install/DIRECTORY-symlink-clobber-build/root-all/dest/lnk
+-- Installing: [^
+]*/Tests/RunCMake/install/DIRECTORY-symlink-clobber-build/root-all/dest/lnk
+-- Up-to-date: [^
+]*/Tests/RunCMake/install/DIRECTORY-symlink-clobber-build/root-all/dest/lnk/file
+-- Installing: [^
+]*/Tests/RunCMake/install/DIRECTORY-symlink-clobber-build/root-all/dest/dir
diff --git a/Tests/RunCMake/install/DIRECTORY-symlink-clobber.cmake b/Tests/RunCMake/install/DIRECTORY-symlink-clobber.cmake
new file mode 100644
index 0000000..ac7a2cf
--- /dev/null
+++ b/Tests/RunCMake/install/DIRECTORY-symlink-clobber.cmake
@@ -0,0 +1,11 @@
+file(MAKE_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/old/dir)
+file(WRITE ${CMAKE_CURRENT_BINARY_DIR}/old/dir/file "")
+file(CREATE_LINK dir ${CMAKE_CURRENT_BINARY_DIR}/old/lnk SYMBOLIC)
+install(DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/old/dir DESTINATION dest)
+install(FILES ${CMAKE_CURRENT_BINARY_DIR}/old/lnk DESTINATION dest)
+
+file(MAKE_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/new/lnk)
+file(WRITE ${CMAKE_CURRENT_BINARY_DIR}/new/lnk/file "")
+file(CREATE_LINK lnk ${CMAKE_CURRENT_BINARY_DIR}/new/dir SYMBOLIC)
+install(DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/new/lnk DESTINATION dest)
+install(FILES ${CMAKE_CURRENT_BINARY_DIR}/new/dir DESTINATION dest)
diff --git a/Tests/RunCMake/install/RunCMakeTest.cmake b/Tests/RunCMake/install/RunCMakeTest.cmake
index 7c12d4a..477ffe0 100644
--- a/Tests/RunCMake/install/RunCMakeTest.cmake
+++ b/Tests/RunCMake/install/RunCMakeTest.cmake
@@ -175,6 +175,10 @@ run_install_test(FILES-PERMISSIONS)
run_install_test(TARGETS-RPATH)
run_install_test(InstallRequiredSystemLibraries)
+if(UNIX)
+ run_install_test(DIRECTORY-symlink-clobber)
+endif()
+
if(CMAKE_SYSTEM_NAME STREQUAL "Darwin")
run_cmake(TARGETS-RUNTIME_DEPENDENCIES-macos-two-bundle)
run_cmake(TARGETS-RUNTIME_DEPENDENCIES-macos-no-framework)
diff --git a/Tests/RunCMake/try_compile/PlatformVariables-stderr.txt b/Tests/RunCMake/try_compile/PlatformVariables-stderr.txt
new file mode 100644
index 0000000..4a42b2d
--- /dev/null
+++ b/Tests/RunCMake/try_compile/PlatformVariables-stderr.txt
@@ -0,0 +1,11 @@
+^CMake Debug Log at [^
+]*/Modules/CMakeDetermineCompilerABI.cmake:[0-9]+ \(try_compile\):
+ Executing try_compile \(CMAKE_C_ABI_COMPILED\) in:
+
+ [^
+]*/Tests/RunCMake/try_compile/PlatformVariables-build/CMakeFiles/CMakeScratch/TryCompile-[^/]+
+Call Stack \(most recent call first\):
+ [^
+]*/Modules/CMakeTestCCompiler.cmake:[0-9]+ \(CMAKE_DETERMINE_COMPILER_ABI\)
+ PlatformVariables.cmake:[0-9]+ \(enable_language\)
+ CMakeLists.txt:[0-9]+ \(include\)
diff --git a/Tests/RunCMake/try_compile/WarnDeprecated-stderr.txt b/Tests/RunCMake/try_compile/WarnDeprecated-stderr.txt
new file mode 100644
index 0000000..6474990
--- /dev/null
+++ b/Tests/RunCMake/try_compile/WarnDeprecated-stderr.txt
@@ -0,0 +1,11 @@
+^CMake Debug Log at [^
+]*/Modules/CMakeDetermineCompilerABI.cmake:[0-9]+ \(try_compile\):
+ Executing try_compile \(CMAKE_C_ABI_COMPILED\) in:
+
+ [^
+]*/Tests/RunCMake/try_compile/WarnDeprecated-build/CMakeFiles/CMakeScratch/TryCompile-[^/]+
+Call Stack \(most recent call first\):
+ [^
+]*/Modules/CMakeTestCCompiler.cmake:[0-9]+ \(CMAKE_DETERMINE_COMPILER_ABI\)
+ WarnDeprecated.cmake:[0-9]+ \(enable_language\)
+ CMakeLists.txt:[0-9]+ \(include\)
diff --git a/Tests/TryCompile/CMakeLists.txt b/Tests/TryCompile/CMakeLists.txt
index 5f540e9..3e46ed5 100644
--- a/Tests/TryCompile/CMakeLists.txt
+++ b/Tests/TryCompile/CMakeLists.txt
@@ -34,30 +34,6 @@ macro(TEST_ASSERT value msg)
endif ()
endmacro()
-macro(TEST_FAIL value msg)
- if (${value})
- message (SEND_ERROR "Failing test succeeded:" ${msg} )
- endif ()
-endmacro()
-
-macro(TEST_EXPECT_EXACT command expected)
- if(NOT "x${result}" STREQUAL "x${expected}")
- message(SEND_ERROR "${CMAKE_CURRENT_LIST_LINE}: TEST \"${command}\" failed: \"${result}\" expected: \"${expected}\"")
- endif()
-endmacro()
-
-macro(TEST_EXPECT_CONTAINS command expected)
- if(NOT "${result}" MATCHES "${expected}")
- message(SEND_ERROR "${CMAKE_CURRENT_LIST_LINE}: TEST \"${command}\" failed: \"${result}\" expected: \"${expected}\"")
- endif()
-endmacro()
-
-if (APPLE)
- enable_language(OBJC)
- enable_language(OBJCXX)
-endif()
-
-
# run old signature tests
set(try_compile_bindir_or_SOURCES ${TryCompile_BINARY_DIR})
set(try_compile_redundant_SOURCES SOURCES)
@@ -138,126 +114,6 @@ add_executable(TryCompile pass.c)
#######################################################################
#
-# also test that the CHECK_C_SOURCE_COMPILES, CHECK_CXX_SOURCE_COMPILES
-# CHECK_C_SOURCE_RUNS and CHECK_CXX_SOURCE_RUNS macros work
-
-include(CheckCSourceCompiles)
-include(CheckCXXSourceCompiles)
-include(CheckCSourceRuns)
-include(CheckCXXSourceRuns)
-
-CHECK_C_SOURCE_COMPILES("I don't build" C_BUILD_SHOULD_FAIL)
-CHECK_C_SOURCE_COMPILES("int main() {return 0;}" C_BUILD_SHOULD_WORK)
-CHECK_C_SOURCE_RUNS("int main() {return 1;}" C_RUN_SHOULD_FAIL)
-CHECK_C_SOURCE_RUNS("int main() {return 0;}" C_RUN_SHOULD_WORK)
-
-TEST_FAIL(C_BUILD_SHOULD_FAIL "CHECK_C_SOURCE_COMPILES() succeeded, but should have failed")
-TEST_ASSERT(C_BUILD_SHOULD_WORK "CHECK_C_SOURCE_COMPILES() failed")
-TEST_FAIL(C_RUN_SHOULD_FAIL "CHECK_C_SOURCE_RUNS() succeeded, but should have failed")
-TEST_ASSERT(C_RUN_SHOULD_WORK "CHECK_C_SOURCE_RUNS() failed")
-
-CHECK_CXX_SOURCE_COMPILES("I don't build" CXX_BUILD_SHOULD_FAIL)
-CHECK_CXX_SOURCE_COMPILES("int main() {return 0;}" CXX_BUILD_SHOULD_WORK)
-CHECK_CXX_SOURCE_COMPILES("void l(char const (&x)[2]){}; int main() { l(\"\\\\n\"); return 0;}"
- CXX_BUILD_SHOULD_WORK_COMPLEX)
-
-CHECK_CXX_SOURCE_RUNS("int main() {return 2;}" CXX_RUN_SHOULD_FAIL)
-CHECK_CXX_SOURCE_RUNS("int main() {return 0;}" CXX_RUN_SHOULD_WORK)
-
-TEST_FAIL(CXX_BUILD_SHOULD_FAIL "CHECK_CXX_SOURCE_COMPILES() succeeded, but should have failed")
-TEST_ASSERT(CXX_BUILD_SHOULD_WORK "CHECK_CXX_SOURCE_COMPILES() failed")
-TEST_ASSERT(CXX_BUILD_SHOULD_WORK_COMPLEX "CHECK_CXX_SOURCE_COMPILES() failed")
-TEST_FAIL(CXX_RUN_SHOULD_FAIL "CHECK_CXX_SOURCE_RUNS() succeeded, but should have failed")
-TEST_ASSERT(CXX_RUN_SHOULD_WORK "CHECK_CXX_SOURCE_RUNS() failed")
-
-foreach(lang C CXX)
- if(NOT CMAKE_${lang}_COMPILER_ID STREQUAL "PathScale")
- set(${lang}_DD --)
- endif()
-endforeach()
-
-unset(C_BOGUS_FLAG CACHE)
-include(CheckCCompilerFlag)
-CHECK_C_COMPILER_FLAG(${C_DD}-_this_is_not_a_flag_ C_BOGUS_FLAG)
-TEST_FAIL(C_BOGUS_FLAG "CHECK_C_COMPILER_FLAG() succeeded, but should have failed")
-unset(C_BOGUS_FLAG CACHE)
-if(DEFINED C_BOGUS_FLAG)
- # Verify that CHECK_C_COMPILER_FLAG didn't construct a normal variable
- message(SEND_ERROR "CHECK_C_COMPILER_FLAG shouldn't construct C_BOGUS_FLAG as a normal variable")
-endif()
-
-unset(CXX_BOGUS_FLAG CACHE)
-include(CheckCXXCompilerFlag)
-CHECK_CXX_COMPILER_FLAG(${CXX_DD}-_this_is_not_a_flag_ CXX_BOGUS_FLAG)
-TEST_FAIL(CXX_BOGUS_FLAG "CHECK_CXX_COMPILER_FLAG() succeeded, but should have failed")
-unset(CXX_BOGUS_FLAG CACHE)
-if(DEFINED CXX_BOGUS_FLAG)
- # Verify that CHECK_C_COMPILER_FLAG didn't construct a normal variable
- message(SEND_ERROR "CHECK_CXX_COMPILER_FLAG shouldn't construct CXX_BOGUS_FLAG as a normal variable")
-endif()
-
-if(CMAKE_C_COMPILER_ID STREQUAL "GNU" OR CMAKE_C_COMPILER_ID STREQUAL "LCC")
- unset(C_STRICT_PROTOTYPES CACHE)
- CHECK_C_COMPILER_FLAG("-Werror;-Wstrict-prototypes" C_STRICT_PROTOTYPES)
- TEST_ASSERT(C_STRICT_PROTOTYPES "CHECK_C_COMPILER_FLAG failed -Werror -Wstrict-prototypes")
-endif()
-
-#########################################################################
-#
-# Test that the CHECK_OBJCC_SOURCE_COMPILES, CHECK_OBJCXX_SOURCE_COMPILES
-# CHECK_OBJC_SOURCE_RUNS and CHECK_OBJCXX_SOURCE_RUNS macros work
-
-if (APPLE)
- enable_language(OBJC)
- enable_language(OBJCXX)
-
- include(CheckOBJCSourceCompiles)
- include(CheckOBJCXXSourceCompiles)
- include(CheckOBJCSourceRuns)
- include(CheckOBJCXXSourceRuns)
-
- CHECK_OBJC_SOURCE_COMPILES("I don't build in Objective-C" OBJC_BUILD_SHOULD_FAIL)
- CHECK_OBJC_SOURCE_COMPILES("int main() { return 0; }" SIMPLE_OBJC_BUILD_SHOULD_WORK)
-
- TEST_FAIL(OBJC_BUILD_SHOULD_FAIL "CHECK_OBJC_SOURCE_COMPILES() succeeded, but should have failed")
- TEST_ASSERT(SIMPLE_OBJC_BUILD_SHOULD_WORK "CHECK_OBJC_SOURCE_COMPILES() failed, but should have succeeded")
-
- set(CMAKE_REQUIRED_LIBRARIES "-framework Foundation")
-
- CHECK_OBJC_SOURCE_COMPILES("#import <Foundation/Foundation.h>\nint main()\n{\nNSObject *foo;\nreturn 0;\n}\n" OBJC_BUILD_SHOULD_WORK)
- CHECK_OBJC_SOURCE_RUNS("int main() { return 2; }" SIMPLE_OBJC_RUN_SHOULD_FAIL)
- CHECK_OBJC_SOURCE_RUNS("int main() { return 0; }" SIMPLE_OBJC_RUN_SHOULD_WORK)
- CHECK_OBJC_SOURCE_RUNS("#import <Foundation/Foundation.h>\nint main()\n{\nNSObject *foo;\nreturn 2;\n}\n" OBJC_RUN_SHOULD_FAIL)
- CHECK_OBJC_SOURCE_RUNS("#import <Foundation/Foundation.h>\nint main()\n{\nNSObject *foo;\nreturn 0;\n}\n" OBJC_RUN_SHOULD_WORK)
-
- TEST_ASSERT(OBJC_BUILD_SHOULD_WORK "CHECK_OBJC_SOURCE_COMPILES() failed, but should have succeeded")
- TEST_FAIL(SIMPLE_OBJC_RUN_SHOULD_FAIL "CHECK_OBJC_SOURC_RUNS() succeeds, but should have failed")
- TEST_ASSERT(SIMPLE_OBJC_RUN_SHOULD_WORK "CHECK_OBJC_SOURCE_RUNS() failed, but should have succeeded")
- TEST_FAIL(OBJC_RUN_SHOULD_FAIL "CHECK_OBJC_SOURCE_RUNS() succeeds, but should have failed")
- TEST_ASSERT(OBJC_RUN_SHOULD_WORK "CHECK_OBJC_SOURCE_RUNS() failed, but should have succeeded")
-
-
- CHECK_OBJCXX_SOURCE_COMPILES("I don't build in Objective-C++" OBJCXX_BUILD_SHOULD_FAIL)
- CHECK_OBJCXX_SOURCE_COMPILES("int main() { return 0; }" SIMPLE_OBJCXX_BUILD_SHOULD_WORK)
-
- TEST_FAIL(OBJCXX_BUILD_SHOULD_FAIL "CHECK_OBJCXX_SOURCE_COMPILES() succeeded, but should have failed")
- TEST_ASSERT(SIMPLE_OBJCXX_BUILD_SHOULD_WORK "CHECK_OBJCXX_SOURCE_COMPILES() failed, but should have succeeded")
-
- CHECK_OBJCXX_SOURCE_COMPILES("#import <Foundation/Foundation.h>\n#include <iostream>\nint main()\n{\nNSObject *foo;\nstd::cout << \"Hello\" << std::endl;\nreturn 0;\n}\n" OBJCXX_BUILD_SHOULD_WORK)
- CHECK_OBJCXX_SOURCE_RUNS("int main() { return 2; }" SIMPLE_OBJCXX_RUN_SHOULD_FAIL)
- CHECK_OBJCXX_SOURCE_RUNS("int main() { return 0; }" SIMPLE_OBJCXX_RUN_SHOULD_WORK)
- CHECK_OBJCXX_SOURCE_RUNS("#import <Foundation/Foundation.h>\n#include <vector>\nint main()\n{\nNSObject *foo;\nstd::vector<int> bar;\nreturn 2;\n}\n" OBJCXX_RUN_SHOULD_FAIL)
- CHECK_OBJCXX_SOURCE_RUNS("#import <Foundation/Foundation.h>\n#include <vector>\nint main()\n{\nNSObject *foo;\nstd::vector<int> bar;\nreturn 0;\n}\n" OBJCXX_RUN_SHOULD_WORK)
-
- TEST_ASSERT(OBJCXX_BUILD_SHOULD_WORK "CHECK_OBJCXX_SOURCE_COMPILES() failed, but should have succeeded")
- TEST_FAIL(SIMPLE_OBJCXX_RUN_SHOULD_FAIL "CHECK_OBJCXX_SOURC_RUNS() succeeds, but should have failed")
- TEST_ASSERT(SIMPLE_OBJCXX_RUN_SHOULD_WORK "CHECK_OBJCXX_SOURCE_RUNS() failed, but should have succeeded")
- TEST_FAIL(OBJCXX_RUN_SHOULD_FAIL "CHECK_OBJCXX_SOURCE_RUNS() succeeds, but should have failed")
- TEST_ASSERT(OBJCXX_RUN_SHOULD_WORK "CHECK_OBJCXX_SOURCE_RUNS() failed, but should have succeeded")
-endif()
-
-#######################################################################
-#
# also test that the check_prototype_definition macro works
include(CheckPrototypeDefinition)