Merge topic 'msvc-runtime-library-flang'

ea0294c281 Flang: Implement MSVC runtime library abstraction

Acked-by: Kitware Robot <kwrobot@kitware.com>
Merge-request: !3674
This commit is contained in:
Brad King 2019-08-19 18:53:10 +00:00 committed by Kitware Robot
commit 29488892e5
2 changed files with 17 additions and 4 deletions

View File

@ -1,3 +1,8 @@
include(Platform/Windows-MSVC)
__windows_compiler_msvc(Fortran)
set(CMAKE_Fortran_COMPILE_OBJECT "<CMAKE_Fortran_COMPILER> ${_COMPILE_Fortran} <DEFINES> <INCLUDES> <FLAGS> -o <OBJECT> -c <SOURCE>")
set(CMAKE_Fortran_COMPILE_OPTIONS_MSVC_RUNTIME_LIBRARY_MultiThreaded -Xclang --dependent-lib=libcmt)
set(CMAKE_Fortran_COMPILE_OPTIONS_MSVC_RUNTIME_LIBRARY_MultiThreadedDLL -Xclang --dependent-lib=msvcrt)
set(CMAKE_Fortran_COMPILE_OPTIONS_MSVC_RUNTIME_LIBRARY_MultiThreadedDebug -Xclang --dependent-lib=libcmtd)
set(CMAKE_Fortran_COMPILE_OPTIONS_MSVC_RUNTIME_LIBRARY_MultiThreadedDebugDLL -Xclang --dependent-lib=msvcrtd)

View File

@ -6,9 +6,17 @@ foreach(t MultiThreaded SingleThreaded)
foreach(dbg "" Debug)
foreach(dll "" DLL)
set(var "CMAKE_Fortran_COMPILE_OPTIONS_MSVC_RUNTIME_LIBRARY_${t}${dbg}${dll}")
# ifort does not actually define these, so inject them
string(REPLACE "-threads" "-threads;-D_MT" "${var}" "${${var}}")
string(REPLACE "-dbglibs" "-dbglibs;-D_DEBUG" "${var}" "${${var}}")
if(CMAKE_Fortran_COMPILER_ID STREQUAL "Intel")
# ifort does not actually define these, so inject them
string(REPLACE "-threads" "-threads;-D_MT" "${var}" "${${var}}")
string(REPLACE "-dbglibs" "-dbglibs;-D_DEBUG" "${var}" "${${var}}")
elseif(CMAKE_Fortran_COMPILER_ID STREQUAL "Flang")
# flang does not actually define these, so inject them
string(REPLACE ";--dependent-lib=libcmt;" ";--dependent-lib=libcmt;-D_MT;" "${var}" ";${${var}};")
string(REPLACE ";--dependent-lib=msvcrt;" ";--dependent-lib=msvcrt;-D_MT;-D_DLL;" "${var}" ";${${var}};")
string(REPLACE ";--dependent-lib=libcmtd;" ";--dependent-lib=libcmtd;-D_MT;-D_DEBUG;" "${var}" ";${${var}};")
string(REPLACE ";--dependent-lib=msvcrtd;" ";--dependent-lib=msvcrtd;-D_MT;-D_DEBUG;-D_DLL;" "${var}" ";${${var}};")
endif()
endforeach()
endforeach()
endforeach()
@ -45,6 +53,6 @@ endfunction()
verify(Fortran verify.F90)
# Intel Fortran for Windows supports single-threaded RTL but it is
# not implemented by the Visual Studio integration.
if(NOT CMAKE_GENERATOR MATCHES "Visual Studio")
if(CMAKE_Fortran_COMPILER_ID STREQUAL "Intel" AND NOT CMAKE_GENERATOR MATCHES "Visual Studio")
verify_combinations(SingleThreaded Fortran verify.F90)
endif()