mirror of
https://github.com/reactos/CMake.git
synced 2025-02-12 14:58:45 +00:00
MSVC: Document and test behavior of empty MSVC_RUNTIME_LIBRARY
Extend tests added by commit fb3370b6a1 (MSVC: Add abstraction for runtime library selection, 2019-04-10) to cover an empty value for the property. It should result in no specific setting. Issue: #19108
This commit is contained in:
parent
8542152626
commit
61f70e81a7
@ -13,3 +13,8 @@
|
||||
|
||||
The value is ignored on non-MSVC compilers but an unsupported value will
|
||||
be rejected as an error when using a compiler targeting the MSVC ABI.
|
||||
|
||||
The value may also be the empty string (``""``) in which case no runtime
|
||||
library selection flag will be added explicitly by CMake. Note that with
|
||||
:ref:`Visual Studio Generators` the native build system may choose to
|
||||
add its own default runtime library selection flag.
|
||||
|
@ -42,7 +42,22 @@ endfunction()
|
||||
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})
|
||||
|
||||
# Test known MSVC default behavior when no flag is given.
|
||||
if(CMAKE_${lang}_COMPILER_ID STREQUAL "MSVC")
|
||||
set(CMAKE_MSVC_RUNTIME_LIBRARY "")
|
||||
add_library(empty-${lang} ${src})
|
||||
if(CMAKE_${lang}_COMPILER_VERSION VERSION_GREATER_EQUAL 14)
|
||||
# VS 2005 and above default to multi-threaded.
|
||||
target_compile_definitions(empty-${lang} PRIVATE VERIFY_MT)
|
||||
endif()
|
||||
if(CMAKE_GENERATOR MATCHES "Visual Studio ([^9]|9[0-9])")
|
||||
# VS 2010 and above have a different default runtime library for projects than 'cl'.
|
||||
target_compile_definitions(empty-${lang} PRIVATE VERIFY_DLL)
|
||||
endif()
|
||||
endif()
|
||||
endfunction()
|
||||
|
||||
verify(C verify.c)
|
||||
|
@ -20,7 +20,7 @@ macro(RuntimeLibrary_check tgt rtl_expect)
|
||||
endif()
|
||||
endforeach()
|
||||
|
||||
if(NOT HAVE_Runtimelibrary)
|
||||
if(NOT HAVE_Runtimelibrary AND NOT "${rtl_expect}" STREQUAL "")
|
||||
set(RunCMake_TEST_FAILED "Project file ${tgt}.vcxproj does not have a RuntimeLibrary field.")
|
||||
return()
|
||||
endif()
|
||||
@ -28,6 +28,8 @@ endmacro()
|
||||
|
||||
RuntimeLibrary_check(default-C MultiThreadedDebugDLL)
|
||||
RuntimeLibrary_check(default-CXX MultiThreadedDebugDLL)
|
||||
RuntimeLibrary_check(empty-C "")
|
||||
RuntimeLibrary_check(empty-CXX "")
|
||||
RuntimeLibrary_check(MTd-C MultiThreadedDebug)
|
||||
RuntimeLibrary_check(MTd-CXX MultiThreadedDebug)
|
||||
RuntimeLibrary_check(MT-C MultiThreaded)
|
||||
|
@ -6,6 +6,10 @@ enable_language(CXX)
|
||||
add_library(default-C empty.c)
|
||||
add_library(default-CXX empty.cxx)
|
||||
|
||||
set(CMAKE_MSVC_RUNTIME_LIBRARY "")
|
||||
add_library(empty-C empty.c)
|
||||
add_library(empty-CXX empty.cxx)
|
||||
|
||||
set(CMAKE_MSVC_RUNTIME_LIBRARY "MultiThreadedDebug")
|
||||
add_library(MTd-C empty.c)
|
||||
add_library(MTd-CXX empty.cxx)
|
||||
|
Loading…
x
Reference in New Issue
Block a user