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

build(cmake): Use crashpad targets #207

Merged
merged 3 commits into from
Apr 2, 2020
Merged
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
37 changes: 21 additions & 16 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -264,24 +264,29 @@ if(SENTRY_WITH_LIBUNWINDSTACK)
endif()

if(SENTRY_BACKEND_CRASHPAD)
add_subdirectory(external/crashpad EXCLUDE_FROM_ALL)
target_include_directories(sentry PRIVATE
"$<BUILD_INTERFACE:${PROJECT_SOURCE_DIR}/external/crashpad>"
"$<BUILD_INTERFACE:${PROJECT_SOURCE_DIR}/external/crashpad/third_party/mini_chromium/mini_chromium>"
)
# we include a crashpad header, which itself needs C++14 support
target_compile_features(sentry PUBLIC cxx_std_14)
Swatinem marked this conversation as resolved.
Show resolved Hide resolved
target_link_libraries(sentry PRIVATE crashpad_client crashpad_util)
if(NOT BUILD_SHARED_LIBS)
sentry_install(TARGETS crashpad_client crashpad_util crashpad_compat getopt mini_chromium zlib EXPORT sentry
LIBRARY DESTINATION "${CMAKE_INSTALL_LIBDIR}"
ARCHIVE DESTINATION "${CMAKE_INSTALL_LIBDIR}"
option(SENTRY_CRASHPAD_SYSTEM "Use system crashpad" OFF)
Swatinem marked this conversation as resolved.
Show resolved Hide resolved
if(SENTRY_CRASHPAD_SYSTEM)
find_package(crashpad REQUIRED)
target_link_libraries(sentry PUBLIC crashpad::client)
else()
# FIXME: required for cmake 3.12 and lower:
# - NEW behavior lets normal variable override option
cmake_policy(SET CMP0077 NEW)
if(BUILD_SHARED_LIBS)
set(CRASHPAD_ENABLE_INSTALL OFF CACHE BOOL "Enable crashpad installation" FORCE)
else()
set(CRASHPAD_ENABLE_INSTALL ON CACHE BOOL "Enable crashpad installation" FORCE)
endif()
add_subdirectory(external/crashpad crashpad_build)
target_link_libraries(sentry PUBLIC
$<BUILD_INTERFACE:crashpad::client>
$<INSTALL_INTERFACE:sentry_crashpad::client>
)
install(EXPORT crashpad_export NAMESPACE sentry_crashpad:: FILE sentry_crashpad-targets.cmake
DESTINATION "${CMAKE_INSTALL_CMAKEDIR}"
)
endif()
sentry_install(TARGETS crashpad_handler EXPORT sentry
RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}
)
add_dependencies(sentry crashpad_handler)
add_dependencies(sentry crashpad::handler)
elseif(SENTRY_BACKEND_BREAKPAD)
add_subdirectory(external)
target_include_directories(sentry PRIVATE
Expand Down
8 changes: 8 additions & 0 deletions sentry-config.cmake.in
Original file line number Diff line number Diff line change
@@ -1,6 +1,14 @@
set(SENTRY_BACKEND @SENTRY_BACKEND@)
set(SENTRY_TRANSPORT @SENTRY_TRANSPORT@)

if(SENTRY_BACKEND STREQUAL "crashpad")
if(@SENTRY_CRASHPAD_SYSTEM@)
find_package(crashpad REQUIRED)
else()
include("${CMAKE_CURRENT_LIST_DIR}/sentry_crashpad-targets.cmake")
endif()
endif()

include("${CMAKE_CURRENT_LIST_DIR}/sentry-targets.cmake")

if(SENTRY_TRANSPORT STREQUAL "curl" AND NOT @BUILD_SHARED_LIBS@)
Expand Down
4 changes: 3 additions & 1 deletion tests/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,9 @@ def cmake(cwd, targets, options=None):
configcmd.append("-D{}={}".format(key, value))
if sys.platform == "win32" and os.environ.get("TEST_X86"):
configcmd.append("-AWin32")
configcmd.append(os.getcwd())

cmakelists_dir = os.path.dirname(os.path.dirname(os.path.realpath(__file__)))
configcmd.append(cmakelists_dir)

print("\n{} > {}".format(cwd, " ".join(configcmd)), flush=True)
subprocess.run(configcmd, cwd=cwd, check=True)
Expand Down
4 changes: 3 additions & 1 deletion tests/conftest.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import os
import pytest
import re
from . import cmake, run
Expand All @@ -6,7 +7,8 @@
def enumerate_unittests():
regexp = re.compile("XX\((.*?)\)")
# TODO: actually generate the `tests.inc` file with python
with open("tests/unit/tests.inc", "r") as testsfile:
curdir = os.path.dirname(os.path.realpath(__file__))
with open(os.path.join(curdir, "unit/tests.inc"), "r") as testsfile:
for line in testsfile:
match = regexp.match(line)
if match:
Expand Down