summaryrefslogtreecommitdiffstats
path: root/Tests/MSVCRuntimeLibrary/Fortran/CMakeLists.txt
diff options
context:
space:
mode:
authorBrad King <brad.king@kitware.com>2019-04-17 15:01:03 (GMT)
committerKitware Robot <kwrobot@kitware.com>2019-04-17 15:01:37 (GMT)
commit2ed688a863671d58513055ad56ab04d6be05295b (patch)
tree91c01b78176bf39f6058fe3b9c1676dbb57cbcad /Tests/MSVCRuntimeLibrary/Fortran/CMakeLists.txt
parent5cd187147ecbd29a0afc5a6b49f2232b61a1ab8c (diff)
parentfb3370b6a1681190ffd8daf63975c44ce8fc1c49 (diff)
downloadCMake-2ed688a863671d58513055ad56ab04d6be05295b.zip
CMake-2ed688a863671d58513055ad56ab04d6be05295b.tar.gz
CMake-2ed688a863671d58513055ad56ab04d6be05295b.tar.bz2
Merge topic 'msvc-runtime-library'
fb3370b6a1 MSVC: Add abstraction for runtime library selection f621e7fa5d VS: Fix Fortran runtime library flag map special case for '-' options Acked-by: Kitware Robot <kwrobot@kitware.com> Acked-by: Ben Boeckel <ben.boeckel@kitware.com> Acked-by: Leonid Pospelov <pospelovlm@yandex.ru> Merge-request: !3211
Diffstat (limited to 'Tests/MSVCRuntimeLibrary/Fortran/CMakeLists.txt')
-rw-r--r--Tests/MSVCRuntimeLibrary/Fortran/CMakeLists.txt50
1 files changed, 50 insertions, 0 deletions
diff --git a/Tests/MSVCRuntimeLibrary/Fortran/CMakeLists.txt b/Tests/MSVCRuntimeLibrary/Fortran/CMakeLists.txt
new file mode 100644
index 0000000..169ba07
--- /dev/null
+++ b/Tests/MSVCRuntimeLibrary/Fortran/CMakeLists.txt
@@ -0,0 +1,50 @@
+cmake_minimum_required(VERSION 3.14)
+cmake_policy(SET CMP0091 NEW)
+project(MSVCRuntimeLibraryFortran Fortran)
+
+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}}")
+ endforeach()
+ endforeach()
+endforeach()
+string(APPEND CMAKE_Fortran_FLAGS " -w")
+
+function(verify_combinations threads lang src)
+ set(verify_tc_config_ Release)
+ set(verify_tc_config_Debug Debug)
+ set(verify_def_MultiThreaded -DVERIFY_MT)
+ set(verify_def_Debug -DVERIFY_DEBUG)
+ set(verify_def_DLL -DVERIFY_DLL)
+ foreach(dbg "" Debug)
+ foreach(dll "" DLL)
+ # Construct the name of this runtime library combination.
+ set(rtl "${threads}${dbg}${dll}")
+
+ # Test that targets build with this RTL.
+ set(CMAKE_MSVC_RUNTIME_LIBRARY "$<$<BOOL:$<TARGET_PROPERTY:BOOL_TRUE>>:${rtl}>$<$<BOOL:$<TARGET_PROPERTY:BOOL_FALSE>>:BadContent>")
+ add_library(${rtl}-${lang} ${src})
+ set_property(TARGET ${rtl}-${lang} PROPERTY BOOL_TRUE TRUE)
+ target_compile_definitions(${rtl}-${lang} PRIVATE ${verify_def_${threads}} ${verify_def_${dbg}} ${verify_def_${dll}})
+ endforeach()
+ endforeach()
+endfunction()
+
+include_directories(${CMAKE_CURRENT_SOURCE_DIR})
+
+function(verify lang src)
+ add_library(default-${lang} ${src})
+ target_compile_definitions(default-${lang} PRIVATE VERIFY_MT VERIFY_DLL "$<$<CONFIG:Debug>:VERIFY_DEBUG>")
+ verify_combinations(MultiThreaded ${lang} ${src})
+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")
+ verify_combinations(SingleThreaded Fortran verify.F90)
+endif()