From ea0294c281b27b4aff968d94dda98989b0f16e39 Mon Sep 17 00:00:00 2001 From: Brad King Date: Fri, 9 Aug 2019 09:55:05 -0400 Subject: Flang: Implement MSVC runtime library abstraction In commit fb3370b6a1 (MSVC: Add abstraction for runtime library selection, 2019-04-10, v3.15.0-rc1~229^2) we overlooked updating flags for Flang on Windows. Add them now and update the MSVCRuntimeLibrary Fortran test to work with Flang. Base the flags on those we already use for the GNU-like Clang targeting the MSVC ABI. Fixes: #19583 --- Modules/Platform/Windows-Flang-Fortran.cmake | 5 +++++ Tests/MSVCRuntimeLibrary/Fortran/CMakeLists.txt | 16 ++++++++++++---- 2 files changed, 17 insertions(+), 4 deletions(-) diff --git a/Modules/Platform/Windows-Flang-Fortran.cmake b/Modules/Platform/Windows-Flang-Fortran.cmake index a4b1cf1..c4420f7 100644 --- a/Modules/Platform/Windows-Flang-Fortran.cmake +++ b/Modules/Platform/Windows-Flang-Fortran.cmake @@ -1,3 +1,8 @@ include(Platform/Windows-MSVC) __windows_compiler_msvc(Fortran) set(CMAKE_Fortran_COMPILE_OBJECT " ${_COMPILE_Fortran} -o -c ") + +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) diff --git a/Tests/MSVCRuntimeLibrary/Fortran/CMakeLists.txt b/Tests/MSVCRuntimeLibrary/Fortran/CMakeLists.txt index 169ba07..27838a4 100644 --- a/Tests/MSVCRuntimeLibrary/Fortran/CMakeLists.txt +++ b/Tests/MSVCRuntimeLibrary/Fortran/CMakeLists.txt @@ -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() -- cgit v0.12