From a451047c17cd121a2b16a9bcb3884bfa66cf092b Mon Sep 17 00:00:00 2001 From: Marcel Lauhoff Date: Thu, 16 Jan 2025 10:18:02 +0100 Subject: [PATCH] cmake: Make breakpad build conditional (WITH_BREAKPAD) Add option WITH_BREAKPAD defaulting to TRUE on non-windows platforms. Signed-off-by: Marcel Lauhoff --- CMakeLists.txt | 12 +++++++++ src/CMakeLists.txt | 49 +++++++++++++++++++++-------------- src/crimson/CMakeLists.txt | 4 ++- src/include/config-h.in.cmake | 3 +++ src/rgw/CMakeLists.txt | 6 +++-- 5 files changed, 51 insertions(+), 23 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 8ded471e2de..472f87787d0 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -539,6 +539,18 @@ if(WITH_CATCH2) message("-- Enabled Catch2 support") endif() +if(WIN32) + set(WITH_BREAKPAD_DEFAULT OFF) +else() + set(WITH_BREAKPAD_DEFAULT ON) +endif() + +option(WITH_BREAKPAD "Build with Google Breakpad crash reporter" ${WITH_BREAKPAD_DEFAULT}) +if(WITH_BREAKPAD) + set(HAVE_BREAKPAD ON) + message("-- Enabled Google Breakpad crash reporter") +endif() + #option for RGW option(WITH_RADOSGW "RADOS Gateway is enabled" ON) option(WITH_RADOSGW_BEAST_OPENSSL "RADOS Gateway's Beast frontend uses OpenSSL" ON) diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 124e5ff9063..97683ee5333 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -326,16 +326,17 @@ if (WITH_BLKIN) endif(WITH_BLKIN) ## breakpad -set(breakpad_SOURCE_DIR ${CMAKE_SOURCE_DIR}/src/breakpad) -set(lss_SOURCE_DIR ${CMAKE_SOURCE_DIR}/src/lss) +if(WITH_BREAKPAD) + set(breakpad_SOURCE_DIR ${CMAKE_SOURCE_DIR}/src/breakpad) + set(lss_SOURCE_DIR ${CMAKE_SOURCE_DIR}/src/lss) -add_custom_target(breakpad_lss_symlink) -add_custom_command( + add_custom_target(breakpad_lss_symlink) + add_custom_command( TARGET breakpad_lss_symlink COMMAND ${CMAKE_COMMAND} -E create_symlink ${lss_SOURCE_DIR} ${breakpad_SOURCE_DIR}/src/third_party/lss COMMENT "Creating symbolic link lss -> breakpad third party" -) -ExternalProject_Add( + ) + ExternalProject_Add( breakpad_project SOURCE_DIR "${breakpad_SOURCE_DIR}" CONFIGURE_COMMAND @@ -347,20 +348,20 @@ ExternalProject_Add( BUILD_IN_SOURCE ON DEPENDS breakpad_lss_symlink BUILD_BYPRODUCTS "${breakpad_SOURCE_DIR}/src/libbreakpad.a;${breakpad_SOURCE_DIR}/src/client/linux/libbreakpad_client.a" -) - -add_library(libbreakpad STATIC IMPORTED GLOBAL) -set_property(TARGET libbreakpad PROPERTY IMPORTED_LOCATION ${breakpad_SOURCE_DIR}/src/libbreakpad.a) -add_library(libbreakpad_client STATIC IMPORTED GLOBAL) -set_property(TARGET libbreakpad_client PROPERTY IMPORTED_LOCATION ${breakpad_SOURCE_DIR}/src/client/linux/libbreakpad_client.a) + ) -include_directories(SYSTEM "${breakpad_SOURCE_DIR}/src") -add_dependencies(libbreakpad breakpad_project) -add_dependencies(libbreakpad_client breakpad_project) + add_library(libbreakpad STATIC IMPORTED GLOBAL) + set_property(TARGET libbreakpad PROPERTY IMPORTED_LOCATION ${breakpad_SOURCE_DIR}/src/libbreakpad.a) + add_library(libbreakpad_client STATIC IMPORTED GLOBAL) + set_property(TARGET libbreakpad_client PROPERTY IMPORTED_LOCATION ${breakpad_SOURCE_DIR}/src/client/linux/libbreakpad_client.a) -add_library(breakpad INTERFACE) -target_link_libraries(breakpad INTERFACE libbreakpad libbreakpad_client) + include_directories(SYSTEM "${breakpad_SOURCE_DIR}/src") + add_dependencies(libbreakpad breakpad_project) + add_dependencies(libbreakpad_client breakpad_project) + add_library(breakpad INTERFACE) + target_link_libraries(breakpad INTERFACE libbreakpad libbreakpad_client) +endif(WITH_BREAKPAD) if(WITH_JAEGER) find_package(thrift 0.13.0 REQUIRED) @@ -518,8 +519,10 @@ if(WITH_JAEGER) target_link_libraries(common-objs jaeger_base) endif() -add_dependencies(common-objs breakpad_project) -target_link_libraries(common-objs breakpad) +if(WITH_BREAKPAD) + add_dependencies(common-objs breakpad_project) + target_link_libraries(common-objs breakpad) +endif() CHECK_C_COMPILER_FLAG("-fvar-tracking-assignments" HAS_VTA) add_subdirectory(auth) @@ -582,7 +585,9 @@ if(WITH_JAEGER) list(APPEND ceph_common_deps jaeger_base) endif() -list(APPEND ceph_common_deps breakpad) +if(WITH_BREAKPAD) + list(APPEND ceph_common_deps breakpad) +endif() if(WIN32) list(APPEND ceph_common_deps ws2_32 mswsock iphlpapi bcrypt) @@ -620,7 +625,9 @@ if(WITH_JAEGER) add_dependencies(common jaeger_base) endif() +if(WITH_BREAKPAD) add_dependencies(common breakpad_project) +endif() if (WIN32) # Statically building ceph-common on Windows fails. We're temporarily @@ -641,7 +648,9 @@ if(WITH_JAEGER) add_dependencies(ceph-common jaeger_base) endif() +if(WITH_BREAKPAD) add_dependencies(ceph-common breakpad_project) +endif() # appease dpkg-shlibdeps set_target_properties(ceph-common PROPERTIES diff --git a/src/crimson/CMakeLists.txt b/src/crimson/CMakeLists.txt index dbf564ddd49..09903ff7954 100644 --- a/src/crimson/CMakeLists.txt +++ b/src/crimson/CMakeLists.txt @@ -137,7 +137,9 @@ if(WITH_JAEGER) list(APPEND crimson_common_public_deps jaeger_base) endif() -list(APPEND crimson_common_public_deps breakpad) +if(WITH_BREAKPAD) + list(APPEND crimson_common_public_deps breakpad) +endif() if(NOT WITH_SYSTEM_BOOST) list(APPEND crimson_common_deps ${ZLIB_LIBRARIES}) diff --git a/src/include/config-h.in.cmake b/src/include/config-h.in.cmake index bc85aac22ee..35e85573e43 100644 --- a/src/include/config-h.in.cmake +++ b/src/include/config-h.in.cmake @@ -405,4 +405,7 @@ /* libexec directory path */ #cmakedefine CMAKE_INSTALL_LIBEXECDIR "@CMAKE_INSTALL_LIBEXECDIR@" +/* Define if breakpad is available */ +#cmakedefine HAVE_BREAKPAD + #endif /* CONFIG_H */ diff --git a/src/rgw/CMakeLists.txt b/src/rgw/CMakeLists.txt index 568c17ea56d..3b294bf1571 100644 --- a/src/rgw/CMakeLists.txt +++ b/src/rgw/CMakeLists.txt @@ -358,8 +358,10 @@ if(WITH_JAEGER) target_link_libraries(rgw_common PUBLIC jaeger_base) endif() -add_dependencies(rgw_common breakpad_project) -target_link_libraries(rgw_common PUBLIC breakpad) +if(WITH_BREAKPAD) + add_dependencies(rgw_common breakpad_project) + target_link_libraries(rgw_common PUBLIC breakpad) +endif() if(WITH_RADOSGW_DBSTORE) target_link_libraries(rgw_common PRIVATE global dbstore) -- 2.39.5