File tree Expand file tree Collapse file tree 2 files changed +9
-4
lines changed
Expand file tree Collapse file tree 2 files changed +9
-4
lines changed Original file line number Diff line number Diff line change @@ -18,6 +18,7 @@ set(OPENPNP_CAPTURE_LIB_SOVERSION "0" CACHE STRING "openpnp-capture library sove
1818# Library type options
1919option (BUILD_SHARED_LIBS "Build shared library" ON )
2020option (BUILD_STATIC_LIBS "Build static library" OFF )
21+ option (LINK_DYNAMIC_MSVC_RUNTIME "Link MSVC runtime statically" OFF )
2122
2223# Validate library type options
2324if (BUILD_STATIC_LIBS AND BUILD_SHARED_LIBS )
@@ -93,10 +94,13 @@ set_target_properties(openpnp-capture PROPERTIES
9394
9495IF (WIN32 )
9596 if (MSVC )
96- # build with static runtime rather than DLL based so that we
97- # don't have to distribute it
98- set (CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} /MT" )
99- set (CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} /MTd" )
97+ if (LINK_DYNAMIC_MSVC_RUNTIME)
98+ set (CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} /MD" )
99+ set (CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} /MDd" )
100+ else ()
101+ set (CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} /MT" )
102+ set (CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} /MTd" )
103+ endif ()
100104 endif ()
101105
102106 # set the platform identification string
Original file line number Diff line number Diff line change @@ -45,6 +45,7 @@ cmake -DCMAKE_BUILD_TYPE=Debug -DBUILD_SHARED_LIBS=OFF -DBUILD_STATIC_LIBS=ON -G
4545
4646- ` BUILD_SHARED_LIBS ` : Build shared library (default: ON)
4747- ` BUILD_STATIC_LIBS ` : Build static library (default: OFF)
48+ - ` LINK_DYNAMIC_MSVC_RUNTIME ` : Link MSVC runtime statically, aka ` \MD ` . Otherwise ` \MT ` . (default: OFF)
4849
4950** Note** : If both options are enabled, the build will default to static library with a warning.
5051
You can’t perform that action at this time.
0 commit comments