2015-11-06 21:03:18 +03:00
|
|
|
macro(configure_msvc_runtime)
|
2020-01-18 17:36:49 +03:00
|
|
|
# Default to statically-linked runtime.
|
|
|
|
if("${MSVC_RUNTIME}" STREQUAL "")
|
|
|
|
set(MSVC_RUNTIME "static")
|
|
|
|
endif()
|
|
|
|
# Set compiler options.
|
|
|
|
set(variables
|
|
|
|
CMAKE_C_FLAGS_DEBUG
|
|
|
|
CMAKE_C_FLAGS_MINSIZEREL
|
|
|
|
CMAKE_C_FLAGS_RELEASE
|
|
|
|
CMAKE_C_FLAGS_RELWITHDEBINFO
|
|
|
|
CMAKE_CXX_FLAGS_DEBUG
|
|
|
|
CMAKE_CXX_FLAGS_MINSIZEREL
|
|
|
|
CMAKE_CXX_FLAGS_RELEASE
|
|
|
|
CMAKE_CXX_FLAGS_RELWITHDEBINFO
|
|
|
|
)
|
|
|
|
if(${MSVC_RUNTIME} STREQUAL "static")
|
|
|
|
message(STATUS
|
|
|
|
"MSVC -> forcing use of statically-linked runtime."
|
|
|
|
)
|
|
|
|
foreach(variable ${variables})
|
|
|
|
if(${variable} MATCHES "/MD")
|
|
|
|
string(REGEX REPLACE "/MD" "/MT" ${variable} "${${variable}}")
|
|
|
|
endif()
|
|
|
|
endforeach()
|
|
|
|
else()
|
|
|
|
message(STATUS
|
|
|
|
"MSVC -> forcing use of dynamically-linked runtime."
|
2015-11-06 21:03:18 +03:00
|
|
|
)
|
2020-01-18 17:36:49 +03:00
|
|
|
foreach(variable ${variables})
|
|
|
|
if(${variable} MATCHES "/MT")
|
|
|
|
string(REGEX REPLACE "/MT" "/MD" ${variable} "${${variable}}")
|
|
|
|
endif()
|
|
|
|
endforeach()
|
2015-11-06 21:03:18 +03:00
|
|
|
endif()
|
|
|
|
endmacro()
|