Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added the option to statically link against the MSVC runtime library … #17

Open
wants to merge 2 commits into
base: backtrace
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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 ()
Expand Down
16 changes: 16 additions & 0 deletions client/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -45,8 +45,24 @@ if (WIN32)
)
endif (WIN32)

if (WIN32 AND STATIC_RUNTIME)
add_compile_options(
$<$<CONFIG:Debug>:/MTd>
$<$<CONFIG:MinSizeRel>:/MT>
$<$<CONFIG:Release>:/MT>
$<$<CONFIG:RelWithDebInfo>:/MT>
)
add_compile_definitions(
$<$<CONFIG:Debug>:_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)
Expand Down
16 changes: 16 additions & 0 deletions compat/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -52,9 +52,25 @@ if (WIN32)
)
endif (WIN32)

if (WIN32 AND STATIC_RUNTIME)
add_compile_options(
$<$<CONFIG:Debug>:/MTd>
$<$<CONFIG:MinSizeRel>:/MT>
$<$<CONFIG:Release>:/MT>
$<$<CONFIG:RelWithDebInfo>:/MT>
)
add_compile_definitions(
$<$<CONFIG:Debug>:_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)

Expand Down
12 changes: 12 additions & 0 deletions handler/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,18 @@ if (ANDROID)
)
endif (ANDROID)

if (WIN32 AND STATIC_RUNTIME)
add_compile_options(
$<$<CONFIG:Debug>:/MTd>
$<$<CONFIG:MinSizeRel>:/MT>
$<$<CONFIG:Release>:/MT>
$<$<CONFIG:RelWithDebInfo>:/MT>
)
add_compile_definitions(
$<$<CONFIG:Debug>:_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)
Expand Down
17 changes: 17 additions & 0 deletions minidump/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,24 @@ set(CRASHPAD_MINIDUMP_LIBRARY_FILES
./minidump_writer_util.h
)

if (WIN32 AND STATIC_RUNTIME)
add_compile_options(
$<$<CONFIG:Debug>:/MTd>
$<$<CONFIG:MinSizeRel>:/MT>
$<$<CONFIG:Release>:/MT>
$<$<CONFIG:RelWithDebInfo>:/MT>
)
add_compile_definitions(
$<$<CONFIG:Debug>:_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)
Expand Down
16 changes: 16 additions & 0 deletions snapshot/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -166,8 +166,24 @@ if (WIN32)
)
endif (WIN32)

if (WIN32 AND STATIC_RUNTIME)
add_compile_options(
$<$<CONFIG:Debug>:/MTd>
$<$<CONFIG:MinSizeRel>:/MT>
$<$<CONFIG:Release>:/MT>
$<$<CONFIG:RelWithDebInfo>:/MT>
)
add_compile_definitions(
$<$<CONFIG:Debug>:_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()
Expand Down
17 changes: 17 additions & 0 deletions third_party/getopt/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,24 @@ set(CRASHPAD_GETOPT_LIBRARY_FILES
getopt.h
)

if (WIN32 AND STATIC_RUNTIME)
add_compile_options(
$<$<CONFIG:Debug>:/MTd>
$<$<CONFIG:MinSizeRel>:/MT>
$<$<CONFIG:Release>:/MT>
$<$<CONFIG:RelWithDebInfo>:/MT>
)
add_compile_definitions(
$<$<CONFIG:Debug>:_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)
Expand Down
17 changes: 17 additions & 0 deletions third_party/mini_chromium/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,24 @@ if (WIN32)
)
endif (WIN32)

if (WIN32 AND STATIC_RUNTIME)
add_compile_options(
$<$<CONFIG:Debug>:/MTd>
$<$<CONFIG:MinSizeRel>:/MT>
$<$<CONFIG:Release>:/MT>
$<$<CONFIG:RelWithDebInfo>:/MT>
)
add_compile_definitions(
$<$<CONFIG:Debug>:_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)

Expand Down
17 changes: 17 additions & 0 deletions third_party/zlib/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -37,10 +37,27 @@ if (${CMAKE_SYSTEM_PROCESSOR} MATCHES "(x86_64)|(AMD64)")
)
endif ()

if (WIN32 AND STATIC_RUNTIME)
add_compile_options(
$<$<CONFIG:Debug>:/MTd>
$<$<CONFIG:MinSizeRel>:/MT>
$<$<CONFIG:Release>:/MT>
$<$<CONFIG:RelWithDebInfo>:/MT>
)
add_compile_definitions(
$<$<CONFIG:Debug>:_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)
Expand Down
17 changes: 17 additions & 0 deletions tools/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,24 @@ set(CRASHPAD_TOOLS_LIBRARY_FILES
./tool_support.h
)

if (WIN32 AND STATIC_RUNTIME)
add_compile_options(
$<$<CONFIG:Debug>:/MTd>
$<$<CONFIG:MinSizeRel>:/MT>
$<$<CONFIG:Release>:/MT>
$<$<CONFIG:RelWithDebInfo>:/MT>
)
add_compile_definitions(
$<$<CONFIG:Debug>:_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 ..)
Expand Down
16 changes: 16 additions & 0 deletions util/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -309,8 +309,24 @@ if (WIN32)
endif ()
endif (WIN32)

if (WIN32 AND STATIC_RUNTIME)
add_compile_options(
$<$<CONFIG:Debug>:/MTd>
$<$<CONFIG:MinSizeRel>:/MT>
$<$<CONFIG:Release>:/MT>
$<$<CONFIG:RelWithDebInfo>:/MT>
)
add_compile_definitions(
$<$<CONFIG:Debug>:_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)
Expand Down