From 4a461efae6fa36aeb50e61e381dc2ecf95b83d23 Mon Sep 17 00:00:00 2001 From: Albrecht Schlosser Date: Sat, 25 Nov 2023 20:30:58 +0100 Subject: [PATCH] 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. --- CMake/options.cmake | 18 ++++++++++++++++++ README.CMake.txt | 5 +++++ 2 files changed, 23 insertions(+) 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$<$:Debug>DLL") + else () + set (CMAKE_MSVC_RUNTIME_LIBRARY "MultiThreaded$<$: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.