From 1966c76ba7a9146761a6e2ef5c54574ad962a08c Mon Sep 17 00:00:00 2001 From: karliss Date: Sat, 5 Sep 2020 11:25:34 +0300 Subject: [PATCH] Update windows CMake breakpad code. (#2421) --- .github/workflows/ccpp.yml | 3 ++ src/CMakeLists.txt | 3 +- src/cmake/FindBreakpad.cmake | 64 ++++++++++++++++++++++-------------- 3 files changed, 43 insertions(+), 27 deletions(-) diff --git a/.github/workflows/ccpp.yml b/.github/workflows/ccpp.yml index eff0bde9..d75906ac 100644 --- a/.github/workflows/ccpp.yml +++ b/.github/workflows/ccpp.yml @@ -107,9 +107,11 @@ jobs: if: contains(matrix.os, 'windows-latest') shell: cmd run: | + set ARCH=x64 set CUTTER_DEPS=%CD%\cutter-deps set PATH=%CD%\cutter-deps\qt\bin;%PATH% call "C:\Program Files (x86)\Microsoft Visual Studio\2019\Enterprise\VC\Auxiliary\Build\vcvarsall.bat" x64 + call scripts\prepare_breakpad.bat cd mkdir build cd build @@ -121,6 +123,7 @@ jobs: -DCUTTER_ENABLE_PYTHON_BINDINGS=ON ^ -DCUTTER_PACKAGE_DEPENDENCIES=ON ^ -DCUTTER_ENABLE_DEPENDENCY_DOWNLOADS=ON ^ + -DCUTTER_ENABLE_CRASH_REPORTS=ON ^ -DCMAKE_PREFIX_PATH="%CUTTER_DEPS%\pyside" ^ -DCPACK_PACKAGE_FILE_NAME=%PACKAGE_NAME% ^ -G Ninja ^ diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index ed084533..135851f4 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -208,8 +208,7 @@ if(CUTTER_ENABLE_CRASH_REPORTS) target_link_libraries(Cutter PRIVATE "-framework Breakpad") else() find_package(Breakpad REQUIRED) - include_directories(${BREAKPAD_INCLUDE_DIRS}) - target_link_libraries(Cutter PRIVATE ${BREAKPAD_LINK_LIBRARIES}) + target_link_libraries(Cutter PRIVATE Breakpad::client) endif() endif() diff --git a/src/cmake/FindBreakpad.cmake b/src/cmake/FindBreakpad.cmake index fc38e479..c6bc5424 100644 --- a/src/cmake/FindBreakpad.cmake +++ b/src/cmake/FindBreakpad.cmake @@ -1,46 +1,60 @@ # - Find Breakpad # -# BREAKPAD_FOUND - True if Breakpad has been found. -# BREAKPAD_INCLUDE_DIRS - Breakpad include directory -# BREAKPAD_LIBRARIES - List of libraries when using Breakpad. -# BREAKPAD_LIBRARY_DIRS - Breakpad library directories +# Breakpad_FOUND - True if Breakpad has been found. +# Breakpad_INCLUDE_DIRS - Breakpad include directory +# Breakpad_LIBRARIES - List of libraries when using Breakpad. +set(Breakpad_LIBRARIES_VARS "") if(WIN32) - find_path(BREAKPAD_INCLUDE_DIRS + find_path(Breakpad_INCLUDE_DIRS + client/windows/handler/exception_handler.h HINTS - "${CMAKE_CURRENT_SOURCE_DIR}/breakpad/prefix/include/breakpad") + "${CMAKE_CURRENT_SOURCE_DIR}/Breakpad/src/src") - set(BREAKPAD_LIBRARY_NAMES - BREAKPAD_CLIENT - BREAKPAD) + set(Breakpad_LIBRARY_NAMES + exception_handler + crash_generation_client + common + ) - set(BREAKPAD_LIBRARIES "") - set(BREAKPAD_LIBRARIES_VARS "") - foreach(libname ${BREAKPAD_LIBRARY_NAMES}) - find_library(BREAKPAD_LIBRARY_${libname} + set(Breakpad_LIBRARIES "") + + foreach(libname ${Breakpad_LIBRARY_NAMES}) + find_library(Breakpad_LIBRARY_${libname} ${libname} HINTS - "${CMAKE_CURRENT_SOURCE_DIR}/breakpad/prefix/lib") + "${CMAKE_CURRENT_SOURCE_DIR}/Breakpad/src/src/client/windows/Release/lib" + REQUIRED) - list(APPEND BREAKPAD_LIBRARIES ${BREAKPAD_LIBRARY_${libname}}) - list(APPEND BREAKPAD_LIBRARIES_VARS "BREAKPAD_LIBRARY_${libname}") + list(APPEND Breakpad_LIBRARIES ${Breakpad_LIBRARY_${libname}}) + list(APPEND Breakpad_LIBRARIES_VARS "Breakpad_LIBRARY_${libname}") endforeach() + + set (Breakpad_LINK_LIBRARIES ${Breakpad_LIBRARIES}) - set(BREAKPAD_LIBRARY_DIRS "") + set(Breakpad_LIBRARY_DIRS "") else() - set(BREAKPAD_CMAKE_PREFIX_PATH_TEMP ${CMAKE_PREFIX_PATH}) - list(APPEND CMAKE_PREFIX_PATH "${CMAKE_CURRENT_SOURCE_DIR}/breakpad/prefix") + set(Breakpad_CMAKE_PREFIX_PATH_TEMP ${CMAKE_PREFIX_PATH}) + list(APPEND CMAKE_PREFIX_PATH "${CMAKE_CURRENT_SOURCE_DIR}/Breakpad/prefix") find_package(PkgConfig REQUIRED) - pkg_search_module(BREAKPAD REQUIRED breakpad-client) + pkg_search_module(Breakpad REQUIRED breakpad-client) # reset CMAKE_PREFIX_PATH - set(CMAKE_PREFIX_PATH ${BREAKPAD_CMAKE_PREFIX_PATH_TEMP}) - mark_as_advanced(BREAKPAD_CMAKE_PREFIX_PATH_TEMP) + set(CMAKE_PREFIX_PATH ${Breakpad_CMAKE_PREFIX_PATH_TEMP}) + mark_as_advanced(Breakpad_CMAKE_PREFIX_PATH_TEMP) endif() -include(FindPackageHandleStandardArgs) -find_package_handle_standard_args(BREAKPAD REQUIRED_VARS BREAKPAD_LIBRARIES BREAKPAD_INCLUDE_DIRS) +# could be simplified in > cmake 3.11 using pkg_search_module IMPORTED_TARGET [GLOBAL] but this would still be required for windows +add_library(Breakpad::client INTERFACE IMPORTED) +set_target_properties(Breakpad::client PROPERTIES + INTERFACE_INCLUDE_DIRECTORIES "${Breakpad_INCLUDE_DIRS}") +set_target_properties(Breakpad::client PROPERTIES + INTERFACE_LINK_LIBRARIES "${Breakpad_LINK_LIBRARIES}") -mark_as_advanced(BREAKPAD_LIBRARIES_VARS) + +include(FindPackageHandleStandardArgs) +find_package_handle_standard_args(Breakpad REQUIRED_VARS Breakpad_LIBRARIES Breakpad_INCLUDE_DIRS ${Breakpad_LIBRARIES_VARS}) + +mark_as_advanced(Breakpad_LIBRARIES_VARS)