Skip to content

Commit

Permalink
ref: make build clangcl compatible
Browse files Browse the repository at this point in the history
  • Loading branch information
supervacuus committed Apr 19, 2023
1 parent 1230009 commit 5cc8bf2
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 21 deletions.
17 changes: 6 additions & 11 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ endif()

#read sentry-native version
file(READ "include/sentry.h" _SENTRY_HEADER_CONTENT)
string(REGEX MATCH "#define SENTRY_SDK_VERSION \"([0-9\.]+)\"" _SENTRY_VERSION_MATCH "${_SENTRY_HEADER_CONTENT}")
string(REGEX MATCH "#define SENTRY_SDK_VERSION \"([0-9.]+)\"" _SENTRY_VERSION_MATCH "${_SENTRY_HEADER_CONTENT}")
set(SENTRY_VERSION "${CMAKE_MATCH_1}")
unset(_SENTRY_HEADER_CONTENT)
unset(_SENTRY_VERSION_MATCH)
Expand Down Expand Up @@ -300,9 +300,7 @@ if(MSVC)
set(CMAKE_ASM_MASM_FLAGS "${CMAKE_ASM_MASM_FLAGS} /safeseh")
endif()

# using `/Wall` is not feasible, as it spews tons of warnings from windows headers
# supress C5105, introduced in VS 16.8, which breaks on the Windows SDKs own `winbase.h` header
target_compile_options(sentry PRIVATE $<BUILD_INTERFACE:/W4 /wd5105>)
target_compile_options(sentry PRIVATE $<BUILD_INTERFACE:/W4>)
# ignore all warnings for mpack
set_source_files_properties(
"${PROJECT_SOURCE_DIR}/vendor/mpack.c"
Expand Down Expand Up @@ -578,15 +576,12 @@ if(SENTRY_BUILD_EXAMPLES)
add_executable(sentry_example examples/example.c)
target_link_libraries(sentry_example PRIVATE sentry)

if(MSVC)
target_compile_options(sentry_example PRIVATE $<BUILD_INTERFACE:/wd5105>)
if(CRASHPAD_WER_ENABLED)
# to test handling SEH by-passing exceptions we need to enable the control flow guard
target_compile_options(sentry_example PRIVATE $<BUILD_INTERFACE:/guard:cf>)
endif()
if(CRASHPAD_WER_ENABLED)
# to test handling SEH by-passing exceptions we need to enable the control flow guard
target_compile_options(sentry_example PRIVATE $<BUILD_INTERFACE:/guard:cf>)
endif()

# set static runtime if enabled
# set static runtime if enablede
if(SENTRY_BUILD_RUNTIMESTATIC AND MSVC)
set_property(TARGET sentry_example PROPERTY MSVC_RUNTIME_LIBRARY "MultiThreaded$<$<CONFIG:Debug>:Debug>")
endif()
Expand Down
2 changes: 1 addition & 1 deletion src/sentry_core.h
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
# define MUST_USE
#endif

#if defined(__GNUC__)
#if defined(__GNUC__) || (defined(_MSC_VER) && __clang__)
# define UNUSED(x) UNUSED_##x __attribute__((__unused__))
#elif defined(_MSC_VER)
# define UNUSED(x) UNUSED_##x __pragma(warning(suppress : 4100))
Expand Down
8 changes: 0 additions & 8 deletions tests/unit/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -73,10 +73,6 @@ if(MINGW)
)
endif()

if(MSVC)
target_compile_options(sentry_test_unit PRIVATE $<BUILD_INTERFACE:/wd5105>)
endif()

# set static runtime if enabled
if(SENTRY_BUILD_RUNTIMESTATIC AND MSVC)
set_property(TARGET sentry_test_unit PROPERTY MSVC_RUNTIME_LIBRARY "MultiThreaded$<$<CONFIG:Debug>:Debug>")
Expand All @@ -103,10 +99,6 @@ target_link_libraries(sentry_fuzz_json PRIVATE
"$<$<PLATFORM_ID:Linux>:rt>"
)

if(MSVC)
target_compile_options(sentry_fuzz_json PRIVATE $<BUILD_INTERFACE:/wd5105>)
endif()

# set static runtime if enabled
if (SENTRY_BUILD_RUNTIMESTATIC AND MSVC)
set_property(TARGET sentry_fuzz_json PROPERTY MSVC_RUNTIME_LIBRARY "MultiThreaded$<$<CONFIG:Debug>:Debug>")
Expand Down

0 comments on commit 5cc8bf2

Please sign in to comment.