diff options
author | Brad King <brad.king@kitware.com> | 2023-11-20 19:15:05 (GMT) |
---|---|---|
committer | Brad King <brad.king@kitware.com> | 2023-12-06 14:42:07 (GMT) |
commit | 48302b469e10f37b8961b6556080df66ba11289f (patch) | |
tree | 3bd0aebacced4032487c22c6ac8b64204a019c20 /Modules/Platform | |
parent | 1c07758ca2ee8dfbd43ca582d16f36a97177b24c (diff) | |
download | CMake-48302b469e10f37b8961b6556080df66ba11289f.zip CMake-48302b469e10f37b8961b6556080df66ba11289f.tar.gz CMake-48302b469e10f37b8961b6556080df66ba11289f.tar.bz2 |
LLVMFlang: Update MSVC runtime library selection for LLVMFlang 18.0
LLVMFlang 18.0 adds MSVC runtime library selection flags and associated
Fortran runtime library variants. Resolve the corresponding FIXME left
by commit 26bf32cdc6 (LLVMFlang: Add support for targeting MSVC ABI on
Windows, 2023-09-28, v3.28.0-rc1~10^2).
Issue: #24840
Diffstat (limited to 'Modules/Platform')
-rw-r--r-- | Modules/Platform/Windows-LLVMFlang-Fortran.cmake | 27 |
1 files changed, 16 insertions, 11 deletions
diff --git a/Modules/Platform/Windows-LLVMFlang-Fortran.cmake b/Modules/Platform/Windows-LLVMFlang-Fortran.cmake index 57e36c6..10e3b2c 100644 --- a/Modules/Platform/Windows-LLVMFlang-Fortran.cmake +++ b/Modules/Platform/Windows-LLVMFlang-Fortran.cmake @@ -5,17 +5,22 @@ elseif("x${CMAKE_Fortran_SIMULATE_ID}" STREQUAL "xMSVC") include(Platform/Windows-MSVC) __windows_compiler_msvc(Fortran) - # FIXME(LLVMFlang): It does not provides MSVC runtime library selection flags. - # It should be given a flag like classic Flang's `-Xclang --dependent-lib=`, or a - # dedicated flag to select among multiple `Fortran*.lib` runtime library variants - # that each depend on a different MSVC runtime library. For now, LLVMFlang's - # `Fortran*.lib` runtime libraries hard-code use of msvcrt (MultiThreadedDLL), - # so we link to it ourselves. - set(_LLVMFlang_LINK_RUNTIME "-defaultlib:msvcrt") - set(CMAKE_Fortran_COMPILE_OPTIONS_MSVC_RUNTIME_LIBRARY_MultiThreaded "") - set(CMAKE_Fortran_COMPILE_OPTIONS_MSVC_RUNTIME_LIBRARY_MultiThreadedDLL "") - set(CMAKE_Fortran_COMPILE_OPTIONS_MSVC_RUNTIME_LIBRARY_MultiThreadedDebug "") - set(CMAKE_Fortran_COMPILE_OPTIONS_MSVC_RUNTIME_LIBRARY_MultiThreadedDebugDLL "") + if(CMAKE_Fortran_COMPILER_VERSION VERSION_GREATER_EQUAL 18.0) + set(_LLVMFlang_LINK_RUNTIME "") + set(CMAKE_Fortran_COMPILE_OPTIONS_MSVC_RUNTIME_LIBRARY_MultiThreaded "-fms-runtime-lib=static") + set(CMAKE_Fortran_COMPILE_OPTIONS_MSVC_RUNTIME_LIBRARY_MultiThreadedDLL "-fms-runtime-lib=dll") + set(CMAKE_Fortran_COMPILE_OPTIONS_MSVC_RUNTIME_LIBRARY_MultiThreadedDebug "-fms-runtime-lib=static_dbg") + set(CMAKE_Fortran_COMPILE_OPTIONS_MSVC_RUNTIME_LIBRARY_MultiThreadedDebugDLL "-fms-runtime-lib=dll_dbg") + else() + # LLVMFlang < 18.0 does not have MSVC runtime library selection flags. + # The official distrubtion's `Fortran*.lib` runtime libraries hard-code + # use of msvcrt (MultiThreadedDLL), so we link to it ourselves. + set(_LLVMFlang_LINK_RUNTIME "-defaultlib:msvcrt") + set(CMAKE_Fortran_COMPILE_OPTIONS_MSVC_RUNTIME_LIBRARY_MultiThreaded "") + set(CMAKE_Fortran_COMPILE_OPTIONS_MSVC_RUNTIME_LIBRARY_MultiThreadedDLL "") + set(CMAKE_Fortran_COMPILE_OPTIONS_MSVC_RUNTIME_LIBRARY_MultiThreadedDebug "") + set(CMAKE_Fortran_COMPILE_OPTIONS_MSVC_RUNTIME_LIBRARY_MultiThreadedDebugDLL "") + endif() # LLVMFlang, like Clang, does not provide all debug information format flags. # In order to provide easy integration with C and C++ projects that use the |