diff --git a/CMakeLists.txt b/CMakeLists.txt index c94db5e0..2bd6d754 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -7,6 +7,7 @@ endif() if (WIN32) enable_language(ASM_MASM) + option(STATIC_RUNTIME "Enable linking against the static MSVC runtime library" OFF) else () enable_language(ASM) endif () diff --git a/client/CMakeLists.txt b/client/CMakeLists.txt index f3ed2896..985ad38d 100644 --- a/client/CMakeLists.txt +++ b/client/CMakeLists.txt @@ -45,8 +45,24 @@ if (WIN32) ) endif (WIN32) +if (WIN32 AND STATIC_RUNTIME) + add_compile_options( + $<$:/MTd> + $<$:/MT> + $<$:/MT> + $<$:/MT> + ) + add_compile_definitions( + $<$:_ITERATOR_DEBUG_LEVEL=0> + ) +endif (WIN32 AND STATIC_RUNTIME) + add_library(client STATIC ${CRASHPAD_CLIENT_LIBRARY_FILES}) +if (WIN32 AND STATIC_RUNTIME) + set_target_properties(client PROPERTIES STATIC_LIBRARY_OPTIONS "/NODEFAULTLIB;") +endif (WIN32 AND STATIC_RUNTIME) + target_compile_features(client PUBLIC cxx_std_14) target_link_libraries(client PUBLIC mini_chromium util compat) diff --git a/compat/CMakeLists.txt b/compat/CMakeLists.txt index c0bfdf68..56a15a6d 100644 --- a/compat/CMakeLists.txt +++ b/compat/CMakeLists.txt @@ -52,9 +52,25 @@ if (WIN32) ) endif (WIN32) +if (WIN32 AND STATIC_RUNTIME) + add_compile_options( + $<$:/MTd> + $<$:/MT> + $<$:/MT> + $<$:/MT> + ) + add_compile_definitions( + $<$:_ITERATOR_DEBUG_LEVEL=0> + ) +endif (WIN32 AND STATIC_RUNTIME) + add_library(compat_incl INTERFACE) add_library(compat OBJECT) +if (WIN32 AND STATIC_RUNTIME) + set_target_properties(compat PROPERTIES STATIC_LIBRARY_OPTIONS "/NODEFAULTLIB;") +endif (WIN32 AND STATIC_RUNTIME) + target_sources(compat PRIVATE ${CRASHPAD_COMPAT_LIBRARY_FILES}) target_link_libraries(compat PUBLIC util compat_incl) diff --git a/handler/CMakeLists.txt b/handler/CMakeLists.txt index 05c1c530..14b1764d 100644 --- a/handler/CMakeLists.txt +++ b/handler/CMakeLists.txt @@ -44,6 +44,18 @@ if (ANDROID) ) endif (ANDROID) +if (WIN32 AND STATIC_RUNTIME) + add_compile_options( + $<$:/MTd> + $<$:/MT> + $<$:/MT> + $<$:/MT> + ) + add_compile_definitions( + $<$:_ITERATOR_DEBUG_LEVEL=0> + ) +endif (WIN32 AND STATIC_RUNTIME) + add_executable(handler main.cc) target_sources(handler PRIVATE ${CRASHPAD_HANDLER_LIBRARY_FILES}) target_compile_features(handler PUBLIC cxx_std_17) diff --git a/minidump/CMakeLists.txt b/minidump/CMakeLists.txt index 1c7009ce..d3440893 100644 --- a/minidump/CMakeLists.txt +++ b/minidump/CMakeLists.txt @@ -54,7 +54,24 @@ set(CRASHPAD_MINIDUMP_LIBRARY_FILES ./minidump_writer_util.h ) +if (WIN32 AND STATIC_RUNTIME) + add_compile_options( + $<$:/MTd> + $<$:/MT> + $<$:/MT> + $<$:/MT> + ) + add_compile_definitions( + $<$:_ITERATOR_DEBUG_LEVEL=0> + ) +endif (WIN32 AND STATIC_RUNTIME) + add_library(minidump OBJECT ${CRASHPAD_MINIDUMP_LIBRARY_FILES}) + +if (WIN32 AND STATIC_RUNTIME) + set_target_properties(minidump PROPERTIES STATIC_LIBRARY_OPTIONS "/NODEFAULTLIB;") +endif (WIN32 AND STATIC_RUNTIME) + target_compile_features(minidump PUBLIC cxx_std_14) target_include_directories(minidump PRIVATE ..) target_link_libraries(minidump PUBLIC mini_chromium compat) diff --git a/snapshot/CMakeLists.txt b/snapshot/CMakeLists.txt index cacc5912..8b8ad73d 100644 --- a/snapshot/CMakeLists.txt +++ b/snapshot/CMakeLists.txt @@ -166,8 +166,24 @@ if (WIN32) ) endif (WIN32) +if (WIN32 AND STATIC_RUNTIME) + add_compile_options( + $<$:/MTd> + $<$:/MT> + $<$:/MT> + $<$:/MT> + ) + add_compile_definitions( + $<$:_ITERATOR_DEBUG_LEVEL=0> + ) +endif (WIN32 AND STATIC_RUNTIME) + add_library(snapshot OBJECT ${CRASHPAD_SNAPSHOT_LIBRARY_FILES}) +if (WIN32 AND STATIC_RUNTIME) + set_target_properties(snapshot PROPERTIES STATIC_LIBRARY_OPTIONS "/NODEFAULTLIB;") +endif (WIN32 AND STATIC_RUNTIME) + if (ANDROID) target_compile_features(snapshot PUBLIC cxx_std_17) else() diff --git a/third_party/getopt/CMakeLists.txt b/third_party/getopt/CMakeLists.txt index 33e68b7e..bf3e327e 100755 --- a/third_party/getopt/CMakeLists.txt +++ b/third_party/getopt/CMakeLists.txt @@ -3,7 +3,24 @@ set(CRASHPAD_GETOPT_LIBRARY_FILES getopt.h ) +if (WIN32 AND STATIC_RUNTIME) + add_compile_options( + $<$:/MTd> + $<$:/MT> + $<$:/MT> + $<$:/MT> + ) + add_compile_definitions( + $<$:_ITERATOR_DEBUG_LEVEL=0> + ) +endif (WIN32 AND STATIC_RUNTIME) + add_library(crashpad_getopt OBJECT) + +if (WIN32 AND STATIC_RUNTIME) + set_target_properties(crashpad_getopt PROPERTIES STATIC_LIBRARY_OPTIONS "/NODEFAULTLIB;") +endif (WIN32 AND STATIC_RUNTIME) + target_sources(crashpad_getopt PRIVATE ${CRASHPAD_GETOPT_LIBRARY_FILES}) target_compile_features(crashpad_getopt PUBLIC cxx_std_14) diff --git a/third_party/mini_chromium/CMakeLists.txt b/third_party/mini_chromium/CMakeLists.txt index f6c49e13..da6a03e4 100644 --- a/third_party/mini_chromium/CMakeLists.txt +++ b/third_party/mini_chromium/CMakeLists.txt @@ -116,7 +116,24 @@ if (WIN32) ) endif (WIN32) +if (WIN32 AND STATIC_RUNTIME) + add_compile_options( + $<$:/MTd> + $<$:/MT> + $<$:/MT> + $<$:/MT> + ) + add_compile_definitions( + $<$:_ITERATOR_DEBUG_LEVEL=0> + ) +endif (WIN32 AND STATIC_RUNTIME) + add_library(mini_chromium OBJECT ${CRASHPAD_MINI_CHROMIUM_LIBRARY_FILES}) + +if (WIN32 AND STATIC_RUNTIME) + set_target_properties(mini_chromium PROPERTIES STATIC_LIBRARY_OPTIONS "/NODEFAULTLIB;") +endif (WIN32 AND STATIC_RUNTIME) + target_compile_features(mini_chromium PUBLIC cxx_std_14) target_include_directories(mini_chromium PUBLIC mini_chromium) diff --git a/third_party/zlib/CMakeLists.txt b/third_party/zlib/CMakeLists.txt index 698b7b7a..a5cc2955 100644 --- a/third_party/zlib/CMakeLists.txt +++ b/third_party/zlib/CMakeLists.txt @@ -37,10 +37,27 @@ if (${CMAKE_SYSTEM_PROCESSOR} MATCHES "(x86_64)|(AMD64)") ) endif () +if (WIN32 AND STATIC_RUNTIME) + add_compile_options( + $<$:/MTd> + $<$:/MT> + $<$:/MT> + $<$:/MT> + ) + add_compile_definitions( + $<$:_ITERATOR_DEBUG_LEVEL=0> + ) +endif (WIN32 AND STATIC_RUNTIME) + add_library(zlib STATIC) target_sources(zlib PRIVATE ${CRASHPAD_ZLIB_LIBRARY_FILES} ) + +if (WIN32 AND STATIC_RUNTIME) + set_target_properties(zlib PROPERTIES STATIC_LIBRARY_OPTIONS "/NODEFAULTLIB;") +endif (WIN32 AND STATIC_RUNTIME) + target_compile_features(zlib PUBLIC cxx_std_14) target_compile_definitions(zlib PUBLIC CRASHPAD_ZLIB_SOURCE_EMBEDDED) diff --git a/tools/CMakeLists.txt b/tools/CMakeLists.txt index d4466cbf..7304ac48 100644 --- a/tools/CMakeLists.txt +++ b/tools/CMakeLists.txt @@ -3,7 +3,24 @@ set(CRASHPAD_TOOLS_LIBRARY_FILES ./tool_support.h ) +if (WIN32 AND STATIC_RUNTIME) + add_compile_options( + $<$:/MTd> + $<$:/MT> + $<$:/MT> + $<$:/MT> + ) + add_compile_definitions( + $<$:_ITERATOR_DEBUG_LEVEL=0> + ) +endif (WIN32 AND STATIC_RUNTIME) + add_library(tools OBJECT ${CRASHPAD_TOOLS_LIBRARY_FILES}) + +if (WIN32 AND STATIC_RUNTIME) + set_target_properties(tools PROPERTIES STATIC_LIBRARY_OPTIONS "/NODEFAULTLIB;") +endif (WIN32 AND STATIC_RUNTIME) + target_compile_features(tools PUBLIC cxx_std_14) target_include_directories(tools PUBLIC ..) diff --git a/util/CMakeLists.txt b/util/CMakeLists.txt index 0fda8b40..0eafee43 100644 --- a/util/CMakeLists.txt +++ b/util/CMakeLists.txt @@ -309,8 +309,24 @@ if (WIN32) endif () endif (WIN32) +if (WIN32 AND STATIC_RUNTIME) + add_compile_options( + $<$:/MTd> + $<$:/MT> + $<$:/MT> + $<$:/MT> + ) + add_compile_definitions( + $<$:_ITERATOR_DEBUG_LEVEL=0> + ) +endif (WIN32 AND STATIC_RUNTIME) add_library(util OBJECT ${CRASHPAD_UTIL_LIBRARY_FILES}) + +if (WIN32 AND STATIC_RUNTIME) + set_target_properties(util PROPERTIES STATIC_LIBRARY_OPTIONS "/NODEFAULTLIB;") +endif (WIN32 AND STATIC_RUNTIME) + target_compile_features(util PUBLIC cxx_std_17) if (APPLE)