Add an option to force static runtime (#1847)

* dos2unix tell_visual_studio_to_use_static_runtime.cmake

* Add an option to force static runtime
This commit is contained in:
Julien Schueller 2019-09-01 15:06:38 +02:00 committed by Davis E. King
parent e89e28b94e
commit 2e5cf2e8e4

View File

@ -1,19 +1,22 @@
# Including this cmake script into your cmake project will cause visual studio
# to build your project against the static C runtime.
cmake_minimum_required(VERSION 2.8.12)
if (POLICY CMP0054)
cmake_policy(SET CMP0054 NEW)
endif()
if (MSVC OR "${CMAKE_CXX_COMPILER_ID}" STREQUAL "MSVC")
foreach(flag_var
CMAKE_CXX_FLAGS CMAKE_CXX_FLAGS_DEBUG CMAKE_CXX_FLAGS_RELEASE
CMAKE_CXX_FLAGS_MINSIZEREL CMAKE_CXX_FLAGS_RELWITHDEBINFO)
if(${flag_var} MATCHES "/MD")
string(REGEX REPLACE "/MD" "/MT" ${flag_var} "${${flag_var}}")
endif()
endforeach(flag_var)
endif()
# Including this cmake script into your cmake project will cause visual studio
# to build your project against the static C runtime.
cmake_minimum_required(VERSION 2.8.12)
if (POLICY CMP0054)
cmake_policy(SET CMP0054 NEW)
endif()
if (MSVC OR "${CMAKE_CXX_COMPILER_ID}" STREQUAL "MSVC")
option (DLIB_FORCE_MSVC_STATIC_RUNTIME "use static runtime" ON)
if (DLIB_FORCE_MSVC_STATIC_RUNTIME)
foreach(flag_var
CMAKE_CXX_FLAGS CMAKE_CXX_FLAGS_DEBUG CMAKE_CXX_FLAGS_RELEASE
CMAKE_CXX_FLAGS_MINSIZEREL CMAKE_CXX_FLAGS_RELWITHDEBINFO)
if(${flag_var} MATCHES "/MD")
string(REGEX REPLACE "/MD" "/MT" ${flag_var} "${${flag_var}}")
endif()
endforeach(flag_var)
endif ()
endif()