mirror of
https://github.com/Kitware/CMake.git
synced 2026-02-17 12:40:40 -06:00
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
This commit is contained in:
@@ -2,7 +2,7 @@
|
|||||||
------------------------
|
------------------------
|
||||||
|
|
||||||
This property is implemented only when ``<LANG>`` is ``C``, ``CXX``,
|
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
|
Specify a :ref:`;-list <CMake Language Lists>` containing a command line
|
||||||
for a compiler launching tool. The :ref:`Makefile Generators` and the
|
for a compiler launching tool. The :ref:`Makefile Generators` and the
|
||||||
|
|||||||
8
Help/release/dev/fortran-compiler-launcher.rst
Normal file
8
Help/release/dev/fortran-compiler-launcher.rst
Normal file
@@ -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.
|
||||||
@@ -3,4 +3,5 @@ CMAKE_<LANG>_COMPILER_LAUNCHER
|
|||||||
|
|
||||||
Default value for :prop_tgt:`<LANG>_COMPILER_LAUNCHER` target property.
|
Default value for :prop_tgt:`<LANG>_COMPILER_LAUNCHER` target property.
|
||||||
This variable is used to initialize the property on each target as it is
|
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``.
|
||||||
|
|||||||
@@ -657,8 +657,8 @@ void cmMakefileTargetGenerator::WriteObjectBuildFile(
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Maybe insert a compiler launcher like ccache or distcc
|
// Maybe insert a compiler launcher like ccache or distcc
|
||||||
if (!compileCommands.empty() &&
|
if (!compileCommands.empty() && (lang == "C" || lang == "CXX" ||
|
||||||
(lang == "C" || lang == "CXX" || lang == "CUDA")) {
|
lang == "Fortran" || lang == "CUDA")) {
|
||||||
std::string const clauncher_prop = lang + "_COMPILER_LAUNCHER";
|
std::string const clauncher_prop = lang + "_COMPILER_LAUNCHER";
|
||||||
const char* clauncher =
|
const char* clauncher =
|
||||||
this->GeneratorTarget->GetProperty(clauncher_prop);
|
this->GeneratorTarget->GetProperty(clauncher_prop);
|
||||||
|
|||||||
@@ -647,7 +647,7 @@ void cmNinjaTargetGenerator::WriteCompileRule(const std::string& lang)
|
|||||||
|
|
||||||
// Maybe insert a compiler launcher like ccache or distcc
|
// Maybe insert a compiler launcher like ccache or distcc
|
||||||
if (!compileCmds.empty() &&
|
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";
|
std::string const clauncher_prop = lang + "_COMPILER_LAUNCHER";
|
||||||
const char* clauncher = this->GeneratorTarget->GetProperty(clauncher_prop);
|
const char* clauncher = this->GeneratorTarget->GetProperty(clauncher_prop);
|
||||||
if (clauncher && *clauncher) {
|
if (clauncher && *clauncher) {
|
||||||
|
|||||||
@@ -238,6 +238,7 @@ cmTarget::cmTarget(std::string const& name, cmStateEnums::TargetType type,
|
|||||||
this->SetPropertyDefault("COMPILE_PDB_OUTPUT_DIRECTORY", nullptr);
|
this->SetPropertyDefault("COMPILE_PDB_OUTPUT_DIRECTORY", nullptr);
|
||||||
this->SetPropertyDefault("Fortran_FORMAT", nullptr);
|
this->SetPropertyDefault("Fortran_FORMAT", nullptr);
|
||||||
this->SetPropertyDefault("Fortran_MODULE_DIRECTORY", nullptr);
|
this->SetPropertyDefault("Fortran_MODULE_DIRECTORY", nullptr);
|
||||||
|
this->SetPropertyDefault("Fortran_COMPILER_LAUNCHER", nullptr);
|
||||||
this->SetPropertyDefault("GNUtoMS", nullptr);
|
this->SetPropertyDefault("GNUtoMS", nullptr);
|
||||||
this->SetPropertyDefault("OSX_ARCHITECTURES", nullptr);
|
this->SetPropertyDefault("OSX_ARCHITECTURES", nullptr);
|
||||||
this->SetPropertyDefault("IOS_INSTALL_COMBINED", nullptr);
|
this->SetPropertyDefault("IOS_INSTALL_COMBINED", nullptr);
|
||||||
|
|||||||
@@ -385,6 +385,9 @@ if("${CMAKE_GENERATOR}" MATCHES "Make|Ninja")
|
|||||||
if(DEFINED CMake_TEST_CUDA)
|
if(DEFINED CMake_TEST_CUDA)
|
||||||
list(APPEND CompilerLauncher_ARGS -DCMake_TEST_CUDA=${CMake_TEST_CUDA})
|
list(APPEND CompilerLauncher_ARGS -DCMake_TEST_CUDA=${CMake_TEST_CUDA})
|
||||||
endif()
|
endif()
|
||||||
|
if(CMAKE_Fortran_COMPILER)
|
||||||
|
list(APPEND CompilerLauncher_ARGS -DCMake_TEST_Fortran=1)
|
||||||
|
endif()
|
||||||
add_RunCMake_test(CompilerLauncher)
|
add_RunCMake_test(CompilerLauncher)
|
||||||
add_RunCMake_test(ctest_labels_for_subprojects)
|
add_RunCMake_test(ctest_labels_for_subprojects)
|
||||||
endif()
|
endif()
|
||||||
|
|||||||
1
Tests/RunCMake/CompilerLauncher/Fortran-Build-stdout.txt
Normal file
1
Tests/RunCMake/CompilerLauncher/Fortran-Build-stdout.txt
Normal file
@@ -0,0 +1 @@
|
|||||||
|
.*-E env USED_LAUNCHER=1.*
|
||||||
@@ -0,0 +1 @@
|
|||||||
|
.*-E env USED_LAUNCHER=1.*
|
||||||
3
Tests/RunCMake/CompilerLauncher/Fortran-launch.cmake
Normal file
3
Tests/RunCMake/CompilerLauncher/Fortran-launch.cmake
Normal file
@@ -0,0 +1,3 @@
|
|||||||
|
set(CTEST_USE_LAUNCHERS 1)
|
||||||
|
include(CTestUseLaunchers)
|
||||||
|
include(Fortran.cmake)
|
||||||
4
Tests/RunCMake/CompilerLauncher/Fortran.cmake
Normal file
4
Tests/RunCMake/CompilerLauncher/Fortran.cmake
Normal file
@@ -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)
|
||||||
@@ -19,6 +19,9 @@ set(langs C CXX)
|
|||||||
if(CMake_TEST_CUDA)
|
if(CMake_TEST_CUDA)
|
||||||
list(APPEND langs CUDA)
|
list(APPEND langs CUDA)
|
||||||
endif()
|
endif()
|
||||||
|
if(CMake_TEST_Fortran)
|
||||||
|
list(APPEND langs Fortran)
|
||||||
|
endif()
|
||||||
|
|
||||||
foreach(lang ${langs})
|
foreach(lang ${langs})
|
||||||
run_compiler_launcher(${lang})
|
run_compiler_launcher(${lang})
|
||||||
|
|||||||
2
Tests/RunCMake/CompilerLauncher/main.F
Normal file
2
Tests/RunCMake/CompilerLauncher/main.F
Normal file
@@ -0,0 +1,2 @@
|
|||||||
|
PROGRAM MAIN
|
||||||
|
END
|
||||||
Reference in New Issue
Block a user