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
This property is implemented only when ``<LANG>`` is ``C``, ``CXX``,
``OBJC``, or ``OBJCXX``
This property is implemented only when ``<LANG>`` is one of:
* ``C``
* ``CXX``
* ``OBJC``
* ``OBJCXX``
* ``Fortran``
.. versionadded:: 4.1
Specify a :ref:`semicolon-separated list <CMake Language Lists>` containing a
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
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`
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.")
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)
_cmake_common_language_platform_flags(Fortran)

View File

@@ -457,6 +457,8 @@ TargetProperty const StaticTargetProperties[] = {
{ "OBJC_LINKER_LAUNCHER"_s, IC::CanCompileSources },
// ---- Objective C++
{ "OBJCXX_LINKER_LAUNCHER"_s, IC::CanCompileSources },
// ---- Fortran
{ "Fortran_LINKER_LAUNCHER"_s, IC::CanCompileSources },
// Static analysis
// -- 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()
set(langs C CXX)
if(CMake_TEST_Fortran)
list(APPEND langs Fortran)
endif()
if(CMake_TEST_OBJC)
list(APPEND langs OBJC OBJCXX)
endif()

View File

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