summaryrefslogtreecommitdiffstats
path: root/cmake/MSVCRuntime.cmake
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-05-04 01:24:41 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-05-04 01:24:41 +0000
commita9bcc81f821d7c66f623779fa5147e728eb3c388 (patch)
tree98676963bcdd537ae5908a067a8eb110b93486a6 /cmake/MSVCRuntime.cmake
parentInitial commit. (diff)
downloadfreerdp3-a9bcc81f821d7c66f623779fa5147e728eb3c388.tar.xz
freerdp3-a9bcc81f821d7c66f623779fa5147e728eb3c388.zip
Adding upstream version 3.3.0+dfsg1.upstream/3.3.0+dfsg1
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to '')
-rw-r--r--cmake/MSVCRuntime.cmake47
1 files changed, 47 insertions, 0 deletions
diff --git a/cmake/MSVCRuntime.cmake b/cmake/MSVCRuntime.cmake
new file mode 100644
index 0000000..f3fb97b
--- /dev/null
+++ b/cmake/MSVCRuntime.cmake
@@ -0,0 +1,47 @@
+if (WIN32)
+ if (CMAKE_VERSION VERSION_LESS 3.15.0)
+ message(FATAL_ERROR "windows builds require CMake >= 3.15")
+ endif()
+ if(NOT DEFINED CMAKE_MSVC_RUNTIME_LIBRARY)
+ if (MSVC_RUNTIME STREQUAL "dynamic")
+ set(MSVC_DEFAULT_RUNTIME "MultiThreadedDLL")
+ elseif(MSVC_RUNTIME STREQUAL "static")
+ set(MSVC_DEFAULT_RUNTIME "MultiThreaded")
+ else()
+ message(WARNING "invalid MSVC_RUNTIME (deprecated) value '${MSVC_RUNTIME}', ignoring")
+ endif()
+
+ if(MSVC_DEFAULT_RUNTIME)
+ message("Using CMAKE_MSVC_RUNTIME_LIBRARY=${MSVC_DEFAULT_RUNTIME} (derived from MSVC_RUNTIME (deprecated) value '${MSVC_RUNTIME}')" )
+ else()
+ set(MSVC_DEFAULT_RUNTIME "MultiThreaded")
+
+ if (CMAKE_BUILD_TYPE STREQUAL "Debug")
+ string(APPEND MSVC_DEFAULT_RUNTIME "Debug")
+ endif()
+
+ if (BUILD_SHARED_LIBS)
+ string(APPEND MSVC_DEFAULT_RUNTIME "DLL")
+ endif()
+ message("Using CMAKE_MSVC_RUNTIME_LIBRARY=${MSVC_DEFAULT_RUNTIME}" )
+ endif()
+
+ set(CMAKE_MSVC_RUNTIME_LIBRARY ${MSVC_DEFAULT_RUNTIME} CACHE STRING "MSVC runtime")
+ endif()
+
+ message("build is using MSVC runtime ${CMAKE_MSVC_RUNTIME_LIBRARY}")
+
+ string(FIND ${CMAKE_MSVC_RUNTIME_LIBRARY} "DLL" IS_SHARED)
+ if(IS_SHARED STREQUAL "-1")
+ if(BUILD_SHARED_LIBS)
+ message(FATAL_ERROR "Static CRT is only supported in a fully static build")
+ endif()
+ message(STATUS "Use the MSVC static runtime option carefully!")
+ message(STATUS "OpenSSL uses /MD by default, and is very picky")
+ message(STATUS "Random freeing errors are a common sign of runtime issues")
+ endif()
+
+ if(NOT DEFINED CMAKE_SUPPRESS_REGENERATION)
+ set(CMAKE_SUPPRESS_REGENERATION ON)
+ endif()
+endif()