2012-09-22 03:28:47 +04:00
|
|
|
|
|
|
|
macro(configure_msvc_runtime)
|
|
|
|
if(MSVC)
|
|
|
|
# Default to statically-linked runtime.
|
|
|
|
if("${MSVC_RUNTIME}" STREQUAL "")
|
|
|
|
set(MSVC_RUNTIME "dynamic")
|
|
|
|
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")
|
2012-09-23 01:10:08 +04:00
|
|
|
message(STATUS "MSVC: using statically-linked runtime (/MT and /MTd).")
|
2012-09-22 03:28:47 +04:00
|
|
|
foreach(variable ${variables})
|
|
|
|
if(${variable} MATCHES "/MD")
|
|
|
|
string(REGEX REPLACE "/MD" "/MT" ${variable} "${${variable}}")
|
|
|
|
endif()
|
|
|
|
endforeach()
|
|
|
|
else()
|
2012-09-23 01:10:08 +04:00
|
|
|
message(STATUS "MSVC: using dynamically-linked runtime (/MD and /MDd).")
|
2012-09-22 03:28:47 +04:00
|
|
|
foreach(variable ${variables})
|
|
|
|
if(${variable} MATCHES "/MT")
|
|
|
|
string(REGEX REPLACE "/MT" "/MD" ${variable} "${${variable}}")
|
|
|
|
endif()
|
|
|
|
endforeach()
|
|
|
|
endif()
|
2012-09-23 01:10:08 +04:00
|
|
|
foreach(variable ${variables})
|
|
|
|
set(${variable} "${${variable}}" CACHE STRING "MSVC_${variable}" FORCE)
|
|
|
|
endforeach()
|
2012-09-22 03:28:47 +04:00
|
|
|
endif()
|
|
|
|
endmacro(configure_msvc_runtime)
|