summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAlbrecht Schlosser <albrechts.fltk@online.de>2023-11-25 20:30:58 +0100
committerAlbrecht Schlosser <albrechts.fltk@online.de>2023-11-25 21:03:23 +0100
commit4a461efae6fa36aeb50e61e381dc2ecf95b83d23 (patch)
tree2d8e40631cfda8ddeda05da5c39089f00abeb082
parente8ad00d9fe3522480b26b4f8660f5398a9140716 (diff)
CMake/Windows/MSVC: Add option to select MSVC Runtime
Selects MSVC compiler/build options known as /MT, /MTd, /MD, or /MDd. This applies to "Visual Studio" (IDE) and "NMake Makefiles" builds.
-rw-r--r--CMake/options.cmake18
-rw-r--r--README.CMake.txt5
2 files changed, 23 insertions, 0 deletions
diff --git a/CMake/options.cmake b/CMake/options.cmake
index 6e2443cfb..5dad843d0 100644
--- a/CMake/options.cmake
+++ b/CMake/options.cmake
@@ -77,6 +77,24 @@ set (OPTION_ABI_VERSION ""
)
set (FL_ABI_VERSION ${OPTION_ABI_VERSION})
+
+#######################################################################
+# Select MSVC (Visual Studio) Runtime: DLL (/MDx) or static (/MTx)
+# where x = 'd' for Debug builds, empty ('') for non-Debug builds.
+# Note: this might be handled better by the 'MSVC_RUNTIME_LIBRARY'
+# target property for each target rather than setting a global
+# CMake variable - but this version does the latter.
+#######################################################################
+
+if (MSVC)
+ option (FLTK_MSVC_RUNTIME_DLL "use MSVC Runtime-DLL (/MDx)" ON)
+ if (FLTK_MSVC_RUNTIME_DLL)
+ set (CMAKE_MSVC_RUNTIME_LIBRARY "MultiThreaded$<$<CONFIG:Debug>:Debug>DLL")
+ else ()
+ set (CMAKE_MSVC_RUNTIME_LIBRARY "MultiThreaded$<$<CONFIG:Debug>:Debug>")
+ endif ()
+endif (MSVC)
+
#######################################################################
# Bundled Library Options
#######################################################################
diff --git a/README.CMake.txt b/README.CMake.txt
index 7ada4cefc..c64c0c75c 100644
--- a/README.CMake.txt
+++ b/README.CMake.txt
@@ -133,6 +133,11 @@ FLTK_BUILD_TEST - default ON
FLTK_BUILD_EXAMPLES - default OFF
Builds the example programs in the 'examples' directory.
+FLTK_MSVC_RUNTIME_DLL - default ON (only for Visual Studio and NMake).
+ Selects whether the build uses the MS runtime DLL or not.
+ Default is ON: either /MD or /MDd for Release or Debug, respectively.
+ Select OFF for either /MT or /MTd for Release or Debug, respectively.
+
OPTION_CAIRO - default OFF
Enables support of class Fl_Cairo_Window (all platforms, requires the
Cairo library) - see README.Cairo.txt.