diff options
author | Brad King <brad.king@kitware.com> | 2017-11-21 19:40:42 (GMT) |
---|---|---|
committer | Brad King <brad.king@kitware.com> | 2017-11-21 19:44:01 (GMT) |
commit | f19c70c3d29f277f82f18820d36ca17e9ba398ae (patch) | |
tree | c6f63181636533d673dcf4d9ad9c85679f94e77e | |
parent | baa19f658f947047dddac0228bcd52591829983d (diff) | |
download | CMake-f19c70c3d29f277f82f18820d36ca17e9ba398ae.zip CMake-f19c70c3d29f277f82f18820d36ca17e9ba398ae.tar.gz CMake-f19c70c3d29f277f82f18820d36ca17e9ba398ae.tar.bz2 |
Fortran: Add option to run the compiler through launcher tools
Add a `Fortran_COMPILER_LAUNCHER` target property like those added for C
and CXX by commit v3.4.0-rc1~450^2 (Add options to launch the compiler
through tools like ccache or distcc, 2015-06-04) and CUDA by commit
v3.10.0-rc1~531^2 (CUDA: Add option to run the compiler through launcher
tools, 2017-06-09).
Fixes: #17499
-rw-r--r-- | Help/prop_tgt/LANG_COMPILER_LAUNCHER.rst | 2 | ||||
-rw-r--r-- | Help/release/dev/fortran-compiler-launcher.rst | 8 | ||||
-rw-r--r-- | Help/variable/CMAKE_LANG_COMPILER_LAUNCHER.rst | 3 | ||||
-rw-r--r-- | Source/cmMakefileTargetGenerator.cxx | 4 | ||||
-rw-r--r-- | Source/cmNinjaTargetGenerator.cxx | 2 | ||||
-rw-r--r-- | Source/cmTarget.cxx | 1 | ||||
-rw-r--r-- | Tests/RunCMake/CMakeLists.txt | 3 | ||||
-rw-r--r-- | Tests/RunCMake/CompilerLauncher/Fortran-Build-stdout.txt | 1 | ||||
-rw-r--r-- | Tests/RunCMake/CompilerLauncher/Fortran-launch-Build-stdout.txt | 1 | ||||
-rw-r--r-- | Tests/RunCMake/CompilerLauncher/Fortran-launch.cmake | 3 | ||||
-rw-r--r-- | Tests/RunCMake/CompilerLauncher/Fortran.cmake | 4 | ||||
-rw-r--r-- | Tests/RunCMake/CompilerLauncher/RunCMakeTest.cmake | 3 | ||||
-rw-r--r-- | Tests/RunCMake/CompilerLauncher/main.F | 2 |
13 files changed, 32 insertions, 5 deletions
diff --git a/Help/prop_tgt/LANG_COMPILER_LAUNCHER.rst b/Help/prop_tgt/LANG_COMPILER_LAUNCHER.rst index 28925fc..b63d6d7 100644 --- a/Help/prop_tgt/LANG_COMPILER_LAUNCHER.rst +++ b/Help/prop_tgt/LANG_COMPILER_LAUNCHER.rst @@ -2,7 +2,7 @@ ------------------------ This property is implemented only when ``<LANG>`` is ``C``, ``CXX``, -or ``CUDA``. +``Fortran``, or ``CUDA``. Specify a :ref:`;-list <CMake Language Lists>` containing a command line for a compiler launching tool. The :ref:`Makefile Generators` and the diff --git a/Help/release/dev/fortran-compiler-launcher.rst b/Help/release/dev/fortran-compiler-launcher.rst new file mode 100644 index 0000000..ce254f1 --- /dev/null +++ b/Help/release/dev/fortran-compiler-launcher.rst @@ -0,0 +1,8 @@ +fortran-compiler-launcher +------------------------- + +* The :ref:`Makefile Generators` and the :generator:`Ninja` generator learned + to add compiler launcher tools along with the compiler for the ``Fortran`` + language (``C``, ``CXX``, and ``CUDA`` were supported previously). + See the :variable:`CMAKE_<LANG>_COMPILER_LAUNCHER` variable and + :prop_tgt:`<LANG>_COMPILER_LAUNCHER` target property for details. diff --git a/Help/variable/CMAKE_LANG_COMPILER_LAUNCHER.rst b/Help/variable/CMAKE_LANG_COMPILER_LAUNCHER.rst index f4e2ba5..e6c8bb5 100644 --- a/Help/variable/CMAKE_LANG_COMPILER_LAUNCHER.rst +++ b/Help/variable/CMAKE_LANG_COMPILER_LAUNCHER.rst @@ -3,4 +3,5 @@ CMAKE_<LANG>_COMPILER_LAUNCHER Default value for :prop_tgt:`<LANG>_COMPILER_LAUNCHER` target property. This variable is used to initialize the property on each target as it is -created. This is done only when ``<LANG>`` is ``C``, ``CXX``, or ``CUDA``. +created. This is done only when ``<LANG>`` is ``C``, ``CXX``, ``Fortran``, +or ``CUDA``. diff --git a/Source/cmMakefileTargetGenerator.cxx b/Source/cmMakefileTargetGenerator.cxx index 7db010c..dd8a373 100644 --- a/Source/cmMakefileTargetGenerator.cxx +++ b/Source/cmMakefileTargetGenerator.cxx @@ -657,8 +657,8 @@ void cmMakefileTargetGenerator::WriteObjectBuildFile( } // Maybe insert a compiler launcher like ccache or distcc - if (!compileCommands.empty() && - (lang == "C" || lang == "CXX" || lang == "CUDA")) { + if (!compileCommands.empty() && (lang == "C" || lang == "CXX" || + lang == "Fortran" || lang == "CUDA")) { std::string const clauncher_prop = lang + "_COMPILER_LAUNCHER"; const char* clauncher = this->GeneratorTarget->GetProperty(clauncher_prop); diff --git a/Source/cmNinjaTargetGenerator.cxx b/Source/cmNinjaTargetGenerator.cxx index 5805259..0262b3c 100644 --- a/Source/cmNinjaTargetGenerator.cxx +++ b/Source/cmNinjaTargetGenerator.cxx @@ -647,7 +647,7 @@ void cmNinjaTargetGenerator::WriteCompileRule(const std::string& lang) // Maybe insert a compiler launcher like ccache or distcc if (!compileCmds.empty() && - (lang == "C" || lang == "CXX" || lang == "CUDA")) { + (lang == "C" || lang == "CXX" || lang == "Fortran" || lang == "CUDA")) { std::string const clauncher_prop = lang + "_COMPILER_LAUNCHER"; const char* clauncher = this->GeneratorTarget->GetProperty(clauncher_prop); if (clauncher && *clauncher) { diff --git a/Source/cmTarget.cxx b/Source/cmTarget.cxx index bf36074..9df8798 100644 --- a/Source/cmTarget.cxx +++ b/Source/cmTarget.cxx @@ -238,6 +238,7 @@ cmTarget::cmTarget(std::string const& name, cmStateEnums::TargetType type, this->SetPropertyDefault("COMPILE_PDB_OUTPUT_DIRECTORY", nullptr); this->SetPropertyDefault("Fortran_FORMAT", nullptr); this->SetPropertyDefault("Fortran_MODULE_DIRECTORY", nullptr); + this->SetPropertyDefault("Fortran_COMPILER_LAUNCHER", nullptr); this->SetPropertyDefault("GNUtoMS", nullptr); this->SetPropertyDefault("OSX_ARCHITECTURES", nullptr); this->SetPropertyDefault("IOS_INSTALL_COMBINED", nullptr); diff --git a/Tests/RunCMake/CMakeLists.txt b/Tests/RunCMake/CMakeLists.txt index f306200..aa075b0 100644 --- a/Tests/RunCMake/CMakeLists.txt +++ b/Tests/RunCMake/CMakeLists.txt @@ -385,6 +385,9 @@ if("${CMAKE_GENERATOR}" MATCHES "Make|Ninja") if(DEFINED CMake_TEST_CUDA) list(APPEND CompilerLauncher_ARGS -DCMake_TEST_CUDA=${CMake_TEST_CUDA}) endif() + if(CMAKE_Fortran_COMPILER) + list(APPEND CompilerLauncher_ARGS -DCMake_TEST_Fortran=1) + endif() add_RunCMake_test(CompilerLauncher) add_RunCMake_test(ctest_labels_for_subprojects) endif() diff --git a/Tests/RunCMake/CompilerLauncher/Fortran-Build-stdout.txt b/Tests/RunCMake/CompilerLauncher/Fortran-Build-stdout.txt new file mode 100644 index 0000000..3313e31 --- /dev/null +++ b/Tests/RunCMake/CompilerLauncher/Fortran-Build-stdout.txt @@ -0,0 +1 @@ +.*-E env USED_LAUNCHER=1.* diff --git a/Tests/RunCMake/CompilerLauncher/Fortran-launch-Build-stdout.txt b/Tests/RunCMake/CompilerLauncher/Fortran-launch-Build-stdout.txt new file mode 100644 index 0000000..3313e31 --- /dev/null +++ b/Tests/RunCMake/CompilerLauncher/Fortran-launch-Build-stdout.txt @@ -0,0 +1 @@ +.*-E env USED_LAUNCHER=1.* diff --git a/Tests/RunCMake/CompilerLauncher/Fortran-launch.cmake b/Tests/RunCMake/CompilerLauncher/Fortran-launch.cmake new file mode 100644 index 0000000..7e9a564 --- /dev/null +++ b/Tests/RunCMake/CompilerLauncher/Fortran-launch.cmake @@ -0,0 +1,3 @@ +set(CTEST_USE_LAUNCHERS 1) +include(CTestUseLaunchers) +include(Fortran.cmake) diff --git a/Tests/RunCMake/CompilerLauncher/Fortran.cmake b/Tests/RunCMake/CompilerLauncher/Fortran.cmake new file mode 100644 index 0000000..72cc03e --- /dev/null +++ b/Tests/RunCMake/CompilerLauncher/Fortran.cmake @@ -0,0 +1,4 @@ +enable_language(Fortran) +set(CMAKE_Fortran_COMPILER_LAUNCHER "${CMAKE_COMMAND};-E;env;USED_LAUNCHER=1") +set(CMAKE_VERBOSE_MAKEFILE TRUE) +add_executable(main main.F) diff --git a/Tests/RunCMake/CompilerLauncher/RunCMakeTest.cmake b/Tests/RunCMake/CompilerLauncher/RunCMakeTest.cmake index ab26512..bb8da03 100644 --- a/Tests/RunCMake/CompilerLauncher/RunCMakeTest.cmake +++ b/Tests/RunCMake/CompilerLauncher/RunCMakeTest.cmake @@ -19,6 +19,9 @@ set(langs C CXX) if(CMake_TEST_CUDA) list(APPEND langs CUDA) endif() +if(CMake_TEST_Fortran) + list(APPEND langs Fortran) +endif() foreach(lang ${langs}) run_compiler_launcher(${lang}) diff --git a/Tests/RunCMake/CompilerLauncher/main.F b/Tests/RunCMake/CompilerLauncher/main.F new file mode 100644 index 0000000..53ec0d1 --- /dev/null +++ b/Tests/RunCMake/CompilerLauncher/main.F @@ -0,0 +1,2 @@ + PROGRAM MAIN + END |