diff options
-rw-r--r-- | Help/variable/CMAKE_LINK_DEPENDS_USE_LINKER.rst | 8 | ||||
-rw-r--r-- | Modules/Compiler/GNU.cmake | 13 | ||||
-rw-r--r-- | Modules/Compiler/NVHPC-Fortran.cmake | 4 | ||||
-rw-r--r-- | Modules/FindCxxTest.cmake | 175 | ||||
-rw-r--r-- | Tests/RunCMake/BuildDepends/LinkDependsCheck.cmake | 3 | ||||
-rw-r--r-- | Tests/RunCMake/BuildDepends/RunCMakeTest.cmake | 4 | ||||
-rw-r--r-- | Tests/RunCMake/CMakeLists.txt | 2 | ||||
-rw-r--r-- | Tests/RunCMake/add_subdirectory/RunCMakeTest.cmake | 2 | ||||
-rw-r--r-- | Tests/RunCMake/add_subdirectory/System.cmake | 3 | ||||
-rw-r--r-- | Tests/RunCMake/add_subdirectory/System/CMakeLists.txt | 5 | ||||
-rw-r--r-- | Tests/RunCMake/add_subdirectory/System/SubSub1/CMakeLists.txt | 1 | ||||
-rw-r--r-- | Tests/RunCMake/add_subdirectory/System/zap.f | 0 |
12 files changed, 117 insertions, 103 deletions
diff --git a/Help/variable/CMAKE_LINK_DEPENDS_USE_LINKER.rst b/Help/variable/CMAKE_LINK_DEPENDS_USE_LINKER.rst index e1b37a5..1867ad8 100644 --- a/Help/variable/CMAKE_LINK_DEPENDS_USE_LINKER.rst +++ b/Help/variable/CMAKE_LINK_DEPENDS_USE_LINKER.rst @@ -10,3 +10,11 @@ variable with value ``FALSE``, you can deactivate this feature. This feature is also deactivated if the :prop_tgt:`LINK_DEPENDS_NO_SHARED` target property is true. + +.. note:: + + CMake version |release| defaults this variable to ``FALSE`` because + GNU binutils linkers (``ld``, ``ld.bfd``, ``ld.gold``) generate spurious + dependencies on temporary files when LTO is enabled. See `GNU bug 30568`_. + +.. _`GNU bug 30568`: https://sourceware.org/bugzilla/show_bug.cgi?id=30568 diff --git a/Modules/Compiler/GNU.cmake b/Modules/Compiler/GNU.cmake index 251e05a..d01054b 100644 --- a/Modules/Compiler/GNU.cmake +++ b/Modules/Compiler/GNU.cmake @@ -53,6 +53,9 @@ macro(__compiler_gnu lang) endif() # define flags for linker depfile generation + set(CMAKE_${lang}_LINKER_DEPFILE_FLAGS "LINKER:--dependency-file,<DEP_FILE>") + set(CMAKE_${lang}_LINKER_DEPFILE_FORMAT gcc) + if(NOT DEFINED CMAKE_${lang}_LINKER_DEPFILE_SUPPORTED) ## Ensure ninja tool is recent enough... if(CMAKE_GENERATOR MATCHES "^Ninja") @@ -82,15 +85,19 @@ macro(__compiler_gnu lang) unset(_linker_capabilities) endif() endif() - if (CMAKE_${lang}_LINKER_DEPFILE_SUPPORTED) - set(CMAKE_${lang}_LINKER_DEPFILE_FLAGS "LINKER:--dependency-file,<DEP_FILE>") - set(CMAKE_${lang}_LINKER_DEPFILE_FORMAT gcc) set(CMAKE_${lang}_LINK_DEPENDS_USE_LINKER TRUE) else() unset(CMAKE_${lang}_LINK_DEPENDS_USE_LINKER) endif() + # For now, due to GNU binutils ld bug when LTO is enabled (see GNU bug + # `30568 <https://sourceware.org/bugzilla/show_bug.cgi?id=30568>`_), + # deactivate this feature. + if (NOT DEFINED CMAKE_LINK_DEPENDS_USE_LINKER) + set(CMAKE_LINK_DEPENDS_USE_LINKER FALSE) + endif() + # Initial configuration flags. string(APPEND CMAKE_${lang}_FLAGS_INIT " ") string(APPEND CMAKE_${lang}_FLAGS_DEBUG_INIT " -g") diff --git a/Modules/Compiler/NVHPC-Fortran.cmake b/Modules/Compiler/NVHPC-Fortran.cmake index 59755b3..ca5f1b2 100644 --- a/Modules/Compiler/NVHPC-Fortran.cmake +++ b/Modules/Compiler/NVHPC-Fortran.cmake @@ -1,3 +1,7 @@ include(Compiler/PGI-Fortran) include(Compiler/NVHPC) __compiler_nvhpc(Fortran) +if(CMAKE_Fortran_COMPILER_VERSION VERSION_LESS 21.7) + # Before NVHPC 21.7 nvfortran didn't support isystem + unset(CMAKE_INCLUDE_SYSTEM_FLAG_Fortran) +endif() diff --git a/Modules/FindCxxTest.cmake b/Modules/FindCxxTest.cmake index 04f8b59..714927f 100644 --- a/Modules/FindCxxTest.cmake +++ b/Modules/FindCxxTest.cmake @@ -7,136 +7,119 @@ FindCxxTest Find CxxTest unit testing framework. -Find the CxxTest suite and declare a helper macro for creating unit -tests and integrating them with CTest. For more details on CxxTest -see https://cxxtest.com +Find the `CxxTest`_ suite and declare a helper macro for creating +unit tests and integrating them with CTest. -INPUT Variables +.. _`CxxTest`: https://github.com/CxxTest/cxxtest#readme -:: +Input Variables +^^^^^^^^^^^^^^^ - CXXTEST_USE_PYTHON [deprecated since 1.3] - Only used in the case both Python & Perl - are detected on the system to control - which CxxTest code generator is used. - Valid only for CxxTest version 3. +``CXXTEST_USE_PYTHON`` + .. deprecated:: 1.3 + Only used in the case both Python & Perl + are detected on the system to control + which CxxTest code generator is used. + Valid only for CxxTest version 3. + In older versions of this Find Module, + this variable controlled if the Python test + generator was used instead of the Perl one, + regardless of which scripting language the + user had installed. -:: +``CXXTEST_TESTGEN_ARGS`` + .. versionadded:: 2.8.3 - NOTE: In older versions of this Find Module, - this variable controlled if the Python test - generator was used instead of the Perl one, - regardless of which scripting language the - user had installed. + Specify a list of options to pass to the CxxTest code + generator. If not defined, ``--error-printer`` is passed. +Result Variables +^^^^^^^^^^^^^^^^ +``CXXTEST_FOUND`` + True if the CxxTest framework was found -:: +``CXXTEST_INCLUDE_DIRS`` + Where to find the CxxTest include directory - CXXTEST_TESTGEN_ARGS (since CMake 2.8.3) - Specify a list of options to pass to the CxxTest code - generator. If not defined, --error-printer is - passed. +``CXXTEST_PERL_TESTGEN_EXECUTABLE`` + The perl-based test generator +``CXXTEST_PYTHON_TESTGEN_EXECUTABLE`` + The python-based test generator +``CXXTEST_TESTGEN_EXECUTABLE`` + .. versionadded:: 2.8.3 -OUTPUT Variables + The test generator that is actually used (chosen using user preferences + and interpreters found in the system) -:: +``CXXTEST_TESTGEN_INTERPRETER`` + .. versionadded:: 2.8.3 - CXXTEST_FOUND - True if the CxxTest framework was found - CXXTEST_INCLUDE_DIRS - Where to find the CxxTest include directory - CXXTEST_PERL_TESTGEN_EXECUTABLE - The perl-based test generator - CXXTEST_PYTHON_TESTGEN_EXECUTABLE - The python-based test generator - CXXTEST_TESTGEN_EXECUTABLE (since CMake 2.8.3) - The test generator that is actually used (chosen using user preferences - and interpreters found in the system) - CXXTEST_TESTGEN_INTERPRETER (since CMake 2.8.3) - The full path to the Perl or Python executable on the system, on - platforms where the script cannot be executed using its shebang line. + The full path to the Perl or Python executable on the system, on + platforms where the script cannot be executed using its shebang line. +Module Commands +^^^^^^^^^^^^^^^ -MACROS for optional use by CMake users: +.. command:: cxxtest_add_test -:: + Create a CxxTest runner and adds it to the CTest testing suite:: - CXXTEST_ADD_TEST(<test_name> <gen_source_file> <input_files_to_testgen...>) - Creates a CxxTest runner and adds it to the CTest testing suite - Parameters: - test_name The name of the test - gen_source_file The generated source filename to be - generated by CxxTest - input_files_to_testgen The list of header files containing the - CxxTest::TestSuite's to be included in - this runner + CXXTEST_ADD_TEST(<test_name> <gen_source_file> + <input_files_to_testgen>...) + Parameters: + ``test_name`` + The name of the test -:: + ``gen_source_file`` + The generated source filename to be generated by CxxTest - #============== - Example Usage: + ``input_files_to_testgen`` + The list of header files containing the CxxTest::TestSuite's + to be included in this runner +Example Usage +^^^^^^^^^^^^^ +The following example, if CxxTest is found, will: -:: +* Invoke the testgen executable to autogenerate foo_test.cc in the + binary tree from "foo_test.h" in the current source directory. +* Create an executable and test called unittest_foo. - find_package(CxxTest) - if(CXXTEST_FOUND) - include_directories(${CXXTEST_INCLUDE_DIR}) - enable_testing() +.. code-block:: cmake + find_package(CxxTest) + if(CXXTEST_FOUND) + include_directories(${CXXTEST_INCLUDE_DIR}) + enable_testing() + CXXTEST_ADD_TEST(unittest_foo foo_test.cc + ${CMAKE_CURRENT_SOURCE_DIR}/foo_test.h) + target_link_libraries(unittest_foo foo) # as needed + endif() +``foo_test.h`` contains: -:: - - CXXTEST_ADD_TEST(unittest_foo foo_test.cc - ${CMAKE_CURRENT_SOURCE_DIR}/foo_test.h) - target_link_libraries(unittest_foo foo) # as needed - endif() - - - -:: - - This will (if CxxTest is found): - 1. Invoke the testgen executable to autogenerate foo_test.cc in the - binary tree from "foo_test.h" in the current source directory. - 2. Create an executable and test called unittest_foo. - - - -:: - - #============= - Example foo_test.h: - - - -:: - - #include <cxxtest/TestSuite.h> - - +.. code-block:: c++ -:: + #include <cxxtest/TestSuite.h> + class MyTestSuite : public CxxTest::TestSuite + { + public: + void testAddition( void ) + { + TS_ASSERT( 1 + 1 > 1 ); + TS_ASSERT_EQUALS( 1 + 1, 2 ); + } + }; - class MyTestSuite : public CxxTest::TestSuite - { - public: - void testAddition( void ) - { - TS_ASSERT( 1 + 1 > 1 ); - TS_ASSERT_EQUALS( 1 + 1, 2 ); - } - }; #]=======================================================================] # Version 1.4 (11/18/10) (CMake 2.8.4) diff --git a/Tests/RunCMake/BuildDepends/LinkDependsCheck.cmake b/Tests/RunCMake/BuildDepends/LinkDependsCheck.cmake index a21096b..596e1eb 100644 --- a/Tests/RunCMake/BuildDepends/LinkDependsCheck.cmake +++ b/Tests/RunCMake/BuildDepends/LinkDependsCheck.cmake @@ -2,7 +2,8 @@ enable_language(C) file(WRITE "${CMAKE_BINARY_DIR}/LinkDependsUseLinker.cmake" - "set(CMAKE_C_LINK_DEPENDS_USE_LINKER \"${CMAKE_C_LINK_DEPENDS_USE_LINKER}\")\n") + "set(CMAKE_LINK_DEPENDS_USE_LINKER ${CMAKE_LINK_DEPENDS_USE_LINKER}) +set(CMAKE_C_LINK_DEPENDS_USE_LINKER ${CMAKE_C_LINK_DEPENDS_USE_LINKER})\n") file(GENERATE OUTPUT "${CMAKE_CURRENT_BINARY_DIR}/check-$<LOWER_CASE:$<CONFIG>>.cmake" diff --git a/Tests/RunCMake/BuildDepends/RunCMakeTest.cmake b/Tests/RunCMake/BuildDepends/RunCMakeTest.cmake index dfa4f49..fada37a 100644 --- a/Tests/RunCMake/BuildDepends/RunCMakeTest.cmake +++ b/Tests/RunCMake/BuildDepends/RunCMakeTest.cmake @@ -199,12 +199,12 @@ endif() run_BuildDepends(CustomCommandUnityBuild) unset(run_BuildDepends_skip_step_2) -#if (RunCMake_GENERATOR MATCHES "Make|Ninja" AND CMAKE_C_LINK_DEPENDS_USE_LINKER) if (RunCMake_GENERATOR MATCHES "Make|Ninja") set(run_BuildDepends_skip_step_2 1) run_BuildDepends(LinkDependsCheck) include("${RunCMake_BINARY_DIR}/LinkDependsCheck-build/LinkDependsUseLinker.cmake") - if (CMAKE_C_LINK_DEPENDS_USE_LINKER) + if ((NOT DEFINED CMAKE_LINK_DEPENDS_USE_LINKER OR CMAKE_LINK_DEPENDS_USE_LINKER) + AND CMAKE_C_LINK_DEPENDS_USE_LINKER) run_BuildDepends(LinkDependsExternalLibrary) unset(run_BuildDepends_skip_step_2) run_BuildDepends(LinkDepends) diff --git a/Tests/RunCMake/CMakeLists.txt b/Tests/RunCMake/CMakeLists.txt index f089a96..63b7568 100644 --- a/Tests/RunCMake/CMakeLists.txt +++ b/Tests/RunCMake/CMakeLists.txt @@ -452,7 +452,7 @@ add_RunCMake_test(add_custom_target) add_RunCMake_test(add_dependencies) add_RunCMake_test(add_executable) add_RunCMake_test(add_library) -add_RunCMake_test(add_subdirectory) +add_RunCMake_test(add_subdirectory -DCMAKE_Fortran_COMPILER=${CMAKE_Fortran_COMPILER}) add_RunCMake_test(add_test) add_RunCMake_test(build_command) add_executable(exit_code exit_code.c) diff --git a/Tests/RunCMake/add_subdirectory/RunCMakeTest.cmake b/Tests/RunCMake/add_subdirectory/RunCMakeTest.cmake index ddf45af..3c70d07 100644 --- a/Tests/RunCMake/add_subdirectory/RunCMakeTest.cmake +++ b/Tests/RunCMake/add_subdirectory/RunCMakeTest.cmake @@ -3,7 +3,9 @@ include(RunCMake) run_cmake(DoesNotExist) run_cmake(Missing) run_cmake(Function) +set(RunCMake_TEST_OPTIONS -DCMAKE_Fortran_COMPILER=${CMAKE_Fortran_COMPILER}) run_cmake(System) +unset(RunCMake_TEST_OPTIONS) macro(run_cmake_install case) set(RunCMake_TEST_BINARY_DIR ${RunCMake_BINARY_DIR}/${case}-build) diff --git a/Tests/RunCMake/add_subdirectory/System.cmake b/Tests/RunCMake/add_subdirectory/System.cmake index 45d7d9a..1048a7a 100644 --- a/Tests/RunCMake/add_subdirectory/System.cmake +++ b/Tests/RunCMake/add_subdirectory/System.cmake @@ -1,4 +1,7 @@ enable_language(CXX) +if(CMAKE_Fortran_COMPILER) + enable_language(Fortran) +endif() add_subdirectory(System SYSTEM) diff --git a/Tests/RunCMake/add_subdirectory/System/CMakeLists.txt b/Tests/RunCMake/add_subdirectory/System/CMakeLists.txt index ef74e80..8653b6f 100644 --- a/Tests/RunCMake/add_subdirectory/System/CMakeLists.txt +++ b/Tests/RunCMake/add_subdirectory/System/CMakeLists.txt @@ -4,6 +4,11 @@ add_subdirectory(SubSub1 SYSTEM) add_subdirectory(SubSub2) add_library(bar STATIC bar.cpp) +if(CMAKE_Fortran_COMPILER) + target_sources(bar PRIVATE zap.f) +endif() +# Verify CMAKE_INCLUDE_SYSTEM_FLAG_<LANG> works +target_link_libraries(bar PRIVATE subsub1bar) add_library(foo STATIC foo.cpp) set_target_properties(foo PROPERTIES SYSTEM OFF) diff --git a/Tests/RunCMake/add_subdirectory/System/SubSub1/CMakeLists.txt b/Tests/RunCMake/add_subdirectory/System/SubSub1/CMakeLists.txt index 291339b..24105b0 100644 --- a/Tests/RunCMake/add_subdirectory/System/SubSub1/CMakeLists.txt +++ b/Tests/RunCMake/add_subdirectory/System/SubSub1/CMakeLists.txt @@ -1,4 +1,5 @@ add_library(subsub1bar STATIC bar.cpp) +target_include_directories(subsub1bar PUBLIC ${CMAKE_CURRENT_BINARY_DIR}) add_library(subsub1foo STATIC foo.cpp) set_target_properties(subsub1foo PROPERTIES SYSTEM OFF) diff --git a/Tests/RunCMake/add_subdirectory/System/zap.f b/Tests/RunCMake/add_subdirectory/System/zap.f new file mode 100644 index 0000000..e69de29 --- /dev/null +++ b/Tests/RunCMake/add_subdirectory/System/zap.f |