Commit 2e5cf2e8 authored by Julien Schueller's avatar Julien Schueller Committed by Davis E. King
Browse files

Add an option to force static runtime (#1847)

* dos2unix tell_visual_studio_to_use_static_runtime.cmake

* Add an option to force static runtime
parent e89e28b9
# Including this cmake script into your cmake project will cause visual studio # Including this cmake script into your cmake project will cause visual studio
# to build your project against the static C runtime. # to build your project against the static C runtime.
cmake_minimum_required(VERSION 2.8.12) cmake_minimum_required(VERSION 2.8.12)
if (POLICY CMP0054) if (POLICY CMP0054)
cmake_policy(SET CMP0054 NEW) cmake_policy(SET CMP0054 NEW)
endif() endif()
if (MSVC OR "${CMAKE_CXX_COMPILER_ID}" STREQUAL "MSVC") if (MSVC OR "${CMAKE_CXX_COMPILER_ID}" STREQUAL "MSVC")
foreach(flag_var option (DLIB_FORCE_MSVC_STATIC_RUNTIME "use static runtime" ON)
CMAKE_CXX_FLAGS CMAKE_CXX_FLAGS_DEBUG CMAKE_CXX_FLAGS_RELEASE if (DLIB_FORCE_MSVC_STATIC_RUNTIME)
CMAKE_CXX_FLAGS_MINSIZEREL CMAKE_CXX_FLAGS_RELWITHDEBINFO) foreach(flag_var
if(${flag_var} MATCHES "/MD") CMAKE_CXX_FLAGS CMAKE_CXX_FLAGS_DEBUG CMAKE_CXX_FLAGS_RELEASE
string(REGEX REPLACE "/MD" "/MT" ${flag_var} "${${flag_var}}") CMAKE_CXX_FLAGS_MINSIZEREL CMAKE_CXX_FLAGS_RELWITHDEBINFO)
endif() if(${flag_var} MATCHES "/MD")
endforeach(flag_var) string(REGEX REPLACE "/MD" "/MT" ${flag_var} "${${flag_var}}")
endif() endif()
endforeach(flag_var)
endif ()
endif()
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment