summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSebastian Pipping <sebastian@pipping.org>2019-01-20 03:06:19 +0100
committerSebastian Pipping <sebastian@pipping.org>2019-01-20 03:31:56 +0100
commit02f43bef1606111ea0905793aa43f2039f695bf6 (patch)
tree77077862798ef0ac3d3a2dbd984b02402c41f554
parentd79fb16e431851b7db990d605452e647451e10ce (diff)
downloaduriparser-02f43bef1606111ea0905793aa43f2039f695bf6.tar.gz
cmake: Add string option URIPARSER_MSVC_RUNTIME
-rw-r--r--CMakeLists.txt15
-rw-r--r--README.md3
2 files changed, 18 insertions, 0 deletions
diff --git a/CMakeLists.txt b/CMakeLists.txt
index 6686945..35b4035 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -61,6 +61,7 @@ option(URIPARSER_BUILD_TESTS "Build test suite (requires GTest >=1.8.1)" ON)
option(URIPARSER_BUILD_TOOLS "Build tools (e.g. CLI \"uriparse\")" ON)
option(URIPARSER_BUILD_CHAR "Build code supporting data type 'char'" ON)
option(URIPARSER_BUILD_WCHAR_T "Build code supporting data type 'wchar_t'" ON)
+set(URIPARSER_MSVC_RUNTIME "" CACHE STRING "Use of specific runtime library (/MT /MTd /MD /MDd) with MSVC")
if(NOT URIPARSER_BUILD_CHAR AND NOT URIPARSER_BUILD_WCHAR_T)
message(SEND_ERROR "One or more of URIPARSER_BUILD_CHAR and URIPARSER_BUILD_WCHAR_T needs to be enabled.")
@@ -72,6 +73,20 @@ if(URIPARSER_BUILD_TOOLS AND NOT URIPARSER_BUILD_CHAR)
message(SEND_ERROR "URIPARSER_BUILD_TOOLS=ON requires URIPARSER_BUILD_CHAR=ON.")
endif()
+if(MSVC AND URIPARSER_MSVC_RUNTIME)
+ set(_refs
+ CMAKE_CXX_FLAGS
+ CMAKE_CXX_FLAGS_DEBUG
+ CMAKE_CXX_FLAGS_RELEASE
+ CMAKE_C_FLAGS
+ CMAKE_C_FLAGS_DEBUG
+ CMAKE_C_FLAGS_RELEASE
+ )
+ foreach(_ref ${_refs})
+ string(REGEX REPLACE "/M[DT]d?" ${URIPARSER_MSVC_RUNTIME} ${_ref} "${${_ref}}")
+ endforeach()
+endif()
+
#
# config.h
#
diff --git a/README.md b/README.md
index fc185f4..a28d47e 100644
--- a/README.md
+++ b/README.md
@@ -64,4 +64,7 @@ URIPARSER_BUILD_TOOLS:BOOL=ON
--
// Build code supporting data type 'wchar_t'
URIPARSER_BUILD_WCHAR_T:BOOL=ON
+--
+// Use of specific runtime library (/MT /MTd /MD /MDd) with MSVC
+URIPARSER_MSVC_RUNTIME:STRING=
```