mirror of
https://github.com/cuberite/libevent.git
synced 2025-09-09 04:19:10 -04:00
cmake: support static runtime (MSVC)
Fixes: #737 (cherry picked from commit 246f44041e0782f728fa5ff2d39113005a1ab02d)
This commit is contained in:
parent
61fb055a43
commit
c8b3ec1711
@ -221,6 +221,34 @@ else()
|
||||
message(FATAL_ERROR "${EVENT_LIBRARY_TYPE} is not supported")
|
||||
endif()
|
||||
|
||||
if (${MSVC})
|
||||
set(msvc_static_runtime OFF)
|
||||
if ("${EVENT_LIBRARY_TYPE}" STREQUAL "STATIC")
|
||||
set(msvc_static_runtime ON)
|
||||
endif()
|
||||
|
||||
# For more info:
|
||||
# - https://docs.microsoft.com/en-us/cpp/build/reference/md-mt-ld-use-run-time-library?view=vs-2017
|
||||
# - https://gitlab.kitware.com/cmake/community/wikis/FAQ#how-can-i-build-my-msvc-application-with-a-static-runtime
|
||||
option(EVENT__MSVC_STATIC_RUNTIME
|
||||
"Link static runtime libraries"
|
||||
${msvc_static_runtime})
|
||||
|
||||
if (EVENT__MSVC_STATIC_RUNTIME)
|
||||
foreach (flag_var
|
||||
CMAKE_C_FLAGS
|
||||
CMAKE_C_FLAGS_DEBUG
|
||||
CMAKE_C_FLAGS_RELEASE
|
||||
CMAKE_C_FLAGS_MINSIZEREL
|
||||
CMAKE_C_FLAGS_RELWITHDEBINFO
|
||||
)
|
||||
if (${flag_var} MATCHES "/MD")
|
||||
string(REGEX REPLACE "/MD" "/MT" ${flag_var} "${${flag_var}}")
|
||||
endif()
|
||||
endforeach()
|
||||
endif()
|
||||
endif()
|
||||
|
||||
# GNUC specific options.
|
||||
if (${GNUC})
|
||||
option(EVENT__DISABLE_GCC_WARNINGS "Disable verbose warnings with GCC" OFF)
|
||||
|
Loading…
x
Reference in New Issue
Block a user