Fortran: Add support for [CMAKE_]Fortran_LINKER_LAUNCHER

`CMAKE_<LANG>_LINKER_LAUNCHER` and `<LANG>_LINKER_LAUNCHER` are
already support for C, CXX, OBJC, and OBJCXX.  Add Fortran.

Closes: #26951
This commit is contained in:
Maximilian Sander
2025-05-26 21:42:22 +02:00
committed by Brad King
parent 38bcc1d014
commit d176a8c5ce
16 changed files with 55 additions and 3 deletions

View File

@@ -3,8 +3,15 @@
.. versionadded:: 3.21 .. versionadded:: 3.21
This property is implemented only when ``<LANG>`` is ``C``, ``CXX``, This property is implemented only when ``<LANG>`` is one of:
``OBJC``, or ``OBJCXX``
* ``C``
* ``CXX``
* ``OBJC``
* ``OBJCXX``
* ``Fortran``
.. versionadded:: 4.1
Specify a :ref:`semicolon-separated list <CMake Language Lists>` containing a Specify a :ref:`semicolon-separated list <CMake Language Lists>` containing a
command line for a linker launching tool. The :ref:`Makefile Generators` and the command line for a linker launching tool. The :ref:`Makefile Generators` and the

View File

@@ -0,0 +1,7 @@
linker-launcher
---------------
* :ref:`Makefile Generators` and :ref:`Ninja Generators` gained support
for adding a linker launcher with ``Fortran``.
See the :variable:`CMAKE_<LANG>_LINKER_LAUNCHER` variable
and :prop_tgt:`<LANG>_LINKER_LAUNCHER` target property for details.

View File

@@ -5,7 +5,15 @@ CMAKE_<LANG>_LINKER_LAUNCHER
Default value for :prop_tgt:`<LANG>_LINKER_LAUNCHER` target property. This Default value for :prop_tgt:`<LANG>_LINKER_LAUNCHER` target property. This
variable is used to initialize the property on each target as it is created. variable is used to initialize the property on each target as it is created.
This is done only when ``<LANG>`` is ``C``, ``CXX``, ``OBJC``, or ``OBJCXX``. This is done only when ``<LANG>`` is one of:
* ``C``
* ``CXX``
* ``OBJC``
* ``OBJCXX``
* ``Fortran``
.. versionadded:: 4.1
This variable is initialized to the :envvar:`CMAKE_<LANG>_LINKER_LAUNCHER` This variable is initialized to the :envvar:`CMAKE_<LANG>_LINKER_LAUNCHER`
environment variable if it is set. environment variable if it is set.

View File

@@ -78,6 +78,11 @@ if(NOT CMAKE_Fortran_COMPILER_LAUNCHER AND DEFINED ENV{CMAKE_Fortran_COMPILER_LA
CACHE STRING "Compiler launcher for Fortran.") CACHE STRING "Compiler launcher for Fortran.")
endif() endif()
if(NOT CMAKE_Fortran_LINKER_LAUNCHER AND DEFINED ENV{CMAKE_Fortran_LINKER_LAUNCHER})
set(CMAKE_Fortran_LINKER_LAUNCHER "$ENV{CMAKE_Fortran_LINKER_LAUNCHER}"
CACHE STRING "Linker launcher for Fortran.")
endif()
include(CMakeCommonLanguageInclude) include(CMakeCommonLanguageInclude)
_cmake_common_language_platform_flags(Fortran) _cmake_common_language_platform_flags(Fortran)

View File

@@ -457,6 +457,8 @@ TargetProperty const StaticTargetProperties[] = {
{ "OBJC_LINKER_LAUNCHER"_s, IC::CanCompileSources }, { "OBJC_LINKER_LAUNCHER"_s, IC::CanCompileSources },
// ---- Objective C++ // ---- Objective C++
{ "OBJCXX_LINKER_LAUNCHER"_s, IC::CanCompileSources }, { "OBJCXX_LINKER_LAUNCHER"_s, IC::CanCompileSources },
// ---- Fortran
{ "Fortran_LINKER_LAUNCHER"_s, IC::CanCompileSources },
// Static analysis // Static analysis
// -- C // -- C

View File

@@ -0,0 +1 @@
.*-E env USED_LAUNCHER=1.*

View File

@@ -0,0 +1,3 @@
enable_language(Fortran)
set(CMAKE_VERBOSE_MAKEFILE TRUE)
add_executable(main main.f90)

View File

@@ -0,0 +1 @@
.*-E env USED_LAUNCHER=1 TARGET_NAME=main LANGUAGE=Fortran.*

View File

@@ -0,0 +1 @@
include(Fortran-common.cmake)

View File

@@ -0,0 +1 @@
.*-E env USED_LAUNCHER=1.*

View File

@@ -0,0 +1 @@
.*-E env USED_LAUNCHER=1 TARGET_NAME=main LANGUAGE=Fortran.*

View File

@@ -0,0 +1,3 @@
set(CTEST_USE_LAUNCHERS 1)
include(CTestUseLaunchers)
include(Fortran-env.cmake)

View File

@@ -0,0 +1,3 @@
set(CTEST_USE_LAUNCHERS 1)
include(CTestUseLaunchers)
include(Fortran.cmake)

View File

@@ -0,0 +1,2 @@
set(CMAKE_Fortran_LINKER_LAUNCHER "${CMAKE_COMMAND};-E;env;USED_LAUNCHER=1")
include(Fortran-common.cmake)

View File

@@ -24,6 +24,9 @@ function(run_linker_launcher_env lang)
endfunction() endfunction()
set(langs C CXX) set(langs C CXX)
if(CMake_TEST_Fortran)
list(APPEND langs Fortran)
endif()
if(CMake_TEST_OBJC) if(CMake_TEST_OBJC)
list(APPEND langs OBJC OBJCXX) list(APPEND langs OBJC OBJCXX)
endif() endif()

View File

@@ -0,0 +1,4 @@
program main
implicit none
! Do nothing
end program main