diff --git a/CMake/FindBreakpad.cmake b/CMake/FindBreakpad.cmake index 59dda86a67..1438613ba8 100644 --- a/CMake/FindBreakpad.cmake +++ b/CMake/FindBreakpad.cmake @@ -1,101 +1,111 @@ function(checkWindowsCompilerFlags) # TODO simplify this with foreach and some string functions set (WINDOWS_CXX_FLAGS_OK_ZI 0) if ( CMAKE_CXX_FLAGS_DEBUG MATCHES .*/Zi.* ) set(WINDOWS_CXX_FLAGS_OK_ZI 1) endif() if ( CMAKE_CXX_FLAGS_RELEASE MATCHES .*/Zi.* ) set(WINDOWS_CXX_FLAGS_OK_ZI 1) endif() if ( CMAKE_CXX_FLAGS MATCHES .*/Zi.* ) set(WINDOWS_CXX_FLAGS_OK_ZI 1) endif() set (WINDOWS_C_FLAGS_OK_ZI 0) if ( CMAKE_C_FLAGS_DEBUG MATCHES .*/Zi.* ) set(WINDOWS_C_FLAGS_OK_ZI 1) endif() if ( CMAKE_C_FLAGS_RELEASE MATCHES .*/Zi.* ) set(WINDOWS_C_FLAGS_OK_ZI 1) endif() if ( CMAKE_C_FLAGS MATCHES .*/Zi.* ) set(WINDOWS_C_FLAGS_OK_ZI 1) endif() if (NOT WINDOWS_CXX_FLAGS_OK_ZI) message(WARNING "When using the breakpad crash reporting module, you should use the /Zi flag in CMAKE_CXX_FLAGS (_RELEASE)") endif() if (NOT WINDOWS_C_FLAGS_OK_ZI) message(WARNING "When using the breakpad crash reporting module, you should use the /Zi flag in CMAKE_C_FLAGS (_RELEASE)") endif() endfunction() function(checkLinuxCompilerFlags) # TODO simplify this with foreach and some string functions set (LINUX_CXX_FLAGS_OK_G 0) if ( CMAKE_CXX_FLAGS_DEBUG MATCHES .*-g.* ) set(LINUX_CXX_FLAGS_OK_G 1) endif() if ( CMAKE_CXX_FLAGS_RELEASE MATCHES .*-g.* ) set(LINUX_CXX_FLAGS_OK_G 1) endif() if ( CMAKE_CXX_FLAGS MATCHES .*-g.* ) set(LINUX_CXX_FLAGS_OK_G 1) endif() set (LINUX_C_FLAGS_OK_G 0) if ( CMAKE_C_FLAGS_DEBUG MATCHES .*-g.* ) set(LINUX_C_FLAGS_OK_G 1) endif() if ( CMAKE_C_FLAGS_RELEASE MATCHES .*-g.* ) set(LINUX_C_FLAGS_OK_G 1) endif() if ( CMAKE_C_FLAGS MATCHES .*-g.* ) set(LINUX_C_FLAGS_OK_G 1) endif() if (NOT LINUX_CXX_FLAGS_OK_G) message(WARNING "When using the breakpad crash reporting module, you should use the -g flag in CMAKE_CXX_FLAGS (_RELEASE)") endif() if (NOT LINUX_C_FLAGS_OK_G) message(WARNING "When using the breakpad crash reporting module, you should use the -g flag in CMAKE_C_FLAGS (_RELEASE)") endif() endfunction() # -------------------- end functions ---------------------------- find_path(Breakpad_INCLUDE_DIR breakpad_googletest_includes.h DOC "Directory breakpad/src/" PATHS ${Breakpad_SRC}/src ${Breakpad_DIR}) if(CMAKE_SYSTEM MATCHES "Windows") + message(STATUS "Checking Windows build requirements for breakpad") + checkWindowsCompilerFlags() # without debug information, Breakpad makes not much sense, so inform developer - find_library(Breakpad_CLIENT_LIB breakpad_client PATHS ${Breakpad_SRC}/src ${Breakpad_DIR} PATH_SUFFIXES Release Debug) + find_library(Breakpad_CLIENT_LIB crash_generation_client PATHS ${Breakpad_SRC}/src ${Breakpad_DIR} PATH_SUFFIXES Release Debug) + find_library(Breakpad_SERVER_LIB crash_generation_server PATHS ${Breakpad_SRC}/src ${Breakpad_DIR} PATH_SUFFIXES Release Debug) + find_library(Breakpad_EXCEPTIONHANDLER_LIB exception_handler PATHS ${Breakpad_SRC}/src ${Breakpad_DIR} PATH_SUFFIXES Release Debug) + find_library(Breakpad_COMMON_LIB common PATHS ${Breakpad_SRC}/src ${Breakpad_DIR} PATH_SUFFIXES Release Debug) set(Breakpad_LIBRARIES ${Breakpad_CLIENT_LIB} + ${Breakpad_SERVER_LIB} + ${Breakpad_EXCEPTIONHANDLER_LIB} + ${Breakpad_COMMON_LIB} ) elseif(CMAKE_SYSTEM MATCHES "Linux") + message(STATUS "Checking Linux build requirements for breakpad") + checkLinuxCompilerFlags() # without debug information, Breakpad makes not much sense, so inform developer find_library(Breakpad_CLIENT_LIB breakpad_client PATHS ${Breakpad_SRC}/src ${Breakpad_DIR}) set(Breakpad_LIBRARIES ${Breakpad_CLIENT_LIB} ) else() message(FATAL_ERROR "Unsupported platform for Breakpad crash reporting: ${CMAKE_SYSTEM}") endif() message(STATUS "FindBreakpad...") message(STATUS " .. include at ${Breakpad_INCLUDE_DIR}") message(STATUS " .. link libraries ${Breakpad_LIBRARIES}") diff --git a/CMakeExternals/build-breakpad.cmake b/CMakeExternals/build-breakpad.cmake index 2727c3a799..99f277eda2 100644 --- a/CMakeExternals/build-breakpad.cmake +++ b/CMakeExternals/build-breakpad.cmake @@ -1,111 +1,111 @@ # CMakeLists.txt for Breakpad # - supports builds on Windows and Linux only # - needs to keep updated when updating the SVN revision in Breakpad.cmake +# - imitates the library structure of google's build system +# - does not build libraries which are not required by the MITK breakpad module cmake_minimum_required(VERSION 2.8) project (BreakpadForMITK CXX) if (WIN32) include_directories(src) # Windows... - set(client_CPPs - src/client/windows/sender/crash_report_sender.cc + set(exceptionhandler_CPPs src/client/windows/handler/exception_handler.cc + ) + + set(server_CPPs + src/client/windows/crash_generation/client_info.cc src/client/windows/crash_generation/crash_generation_server.cc - src/client/windows/crash_generation/crash_generation_client.cc src/client/windows/crash_generation/minidump_generator.cc - src/client/windows/crash_generation/client_info.cc + ) + + set(client_CPPs + src/client/windows/crash_generation/crash_generation_client.cc ) set(common_CPPs src/common/convert_UTF.c - #src/common/md5.cc src/common/language.cc - #src/common/dwarf_cfi_to_module.cc - #src/common/dwarf_line_to_module.cc src/common/string_conversion.cc src/common/module.cc - #src/common/dwarf_cu_to_module.cc # requires stdint.h src/common/windows/http_upload.cc src/common/windows/string_utils.cc src/common/windows/guid_string.cc - #src/common/windows/pdb_source_line_writer.cc # requires MS Debug Interface Access SDK dia ) # this was copied from http://svn.code.sf.net/p/safir/svn/safir_sdk_core/trunk/src/lluf/lluf_crash_reporter.ss/src/google-breakpad/build-breakpad-windows.cmake # check if this is actually required or not add_definitions(-DBREAKPAD_NO_TERMINATE_THREAD) add_definitions(-DUNICODE -D_UNICODE) add_definitions(/wd4127 /wd4245) set_source_files_properties(src/common/convert_UTF.c PROPERTIES LANGUAGE CXX) # seems more simple than tell CMake about two compilers # following line is inspired by breakpad issue 465 where the following definition was suggested as a patch for MSVC 2005/8 # TODO: do we need a if MSVC2005/8? (check MITK requirements) set_source_files_properties(src/client/windows/handler/exception_handler.cc PROPERTIES COMPILE_DEFINITIONS "STATUS_INVALID_PARAMETER=((DWORD)0xC000000DL)") include_directories(src) - add_library(breakpad_client STATIC - ${client_CPPs} - ${common_CPPs} - ) + add_library(common STATIC ${common_CPPs}) + add_library(crash_generation_client STATIC ${client_CPPs}) + add_library(crash_generation_server STATIC ${server_CPPs}) + add_library(exception_handler STATIC ${exceptionhandler_CPPs}) else() # Linux # commented code is not required right now and depends on other libraries (e.g. glog) set(client_CPPs src/client/minidump_file_writer.cc - #src/client/linux/sender/google_crash_report_sender.cc src/client/linux/handler/minidump_descriptor.cc src/client/linux/handler/exception_handler.cc src/client/linux/log/log.cc src/client/linux/minidump_writer/linux_core_dumper.cc src/client/linux/minidump_writer/linux_ptrace_dumper.cc src/client/linux/minidump_writer/linux_dumper.cc src/client/linux/minidump_writer/minidump_writer.cc src/client/linux/crash_generation/crash_generation_server.cc src/client/linux/crash_generation/crash_generation_client.cc ) set(common_CPPs src/common/convert_UTF.c src/common/md5.cc src/common/language.cc src/common/dwarf_cfi_to_module.cc src/common/dwarf_line_to_module.cc src/common/string_conversion.cc - #src/common/stabs_reader.cc src/common/module.cc src/common/dwarf_cu_to_module.cc src/common/stabs_to_module.cc src/common/linux/libcurl_wrapper.cc src/common/linux/safe_readlink.cc src/common/linux/http_upload.cc src/common/linux/google_crashdump_uploader.cc src/common/linux/elf_symbols_to_module.cc src/common/linux/guid_creator.cc src/common/linux/memory_mapped_file.cc src/common/linux/linux_libc_support.cc src/common/linux/dump_symbols.cc src/common/linux/file_id.cc src/common/linux/synth_elf.cc src/common/linux/elfutils.cc src/common/linux/elf_core_dump.cc ) # commented code is not required right now and depends on other libraries (e.g. glog) set_source_files_properties(src/common/convert_UTF.c PROPERTIES LANGUAGE CXX) # seems more simple than tell CMake about two compilers include_directories(src) add_definitions(-fPIC) add_library(breakpad_client STATIC ${client_CPPs} ${common_CPPs} ) endif() diff --git a/Modules/BreakpadCrashReporting/CMakeLists.txt b/Modules/BreakpadCrashReporting/CMakeLists.txt index 7e723bf1a2..4c90269035 100644 --- a/Modules/BreakpadCrashReporting/CMakeLists.txt +++ b/Modules/BreakpadCrashReporting/CMakeLists.txt @@ -1,43 +1,29 @@ # TODOs # LATER nicer separation of Linux/Window/.. code # OK test should check existence of dump file # - find nice script to use linux symbol writer tool dump_.. on all relevant libraries # - update documentation # OK check buildtype (O2/-g/..) in cmake # - use the same library structure in "our" cmake script as google uses in their build # - otherwise we cannot switch between custom-built versions of breakpad and our superbuild version if(MITK_USE_BREAKPAD) find_package(Breakpad) - if(CMAKE_SYSTEM MATCHES "Windows") - set(ADDITIONAL_LIBS ${ADDITIONAL_LIBS} - ${Breakpad_DIR}/Debug/breakpad_client.lib -# ${Breakpad_DIR}/Release/common.lib # ?? -# ${Breakpad_DIR}/Release/crash_generation_client.lib # ??? -# ${Breakpad_DIR}/Release/crash_generation_server.lib # out-of-process dump generator -# ${Breakpad_DIR}/Release/exception_handler.lib # dump creator (ExceptionHandler) -# ${Breakpad_DIR}/Release/crash_report_sender.lib - ) # ??? unused, I guess - - set(EXECUTABLE_PROPERTY WIN32) - - endif() - MITK_CREATE_MODULE(BreakpadCrashReporting INTERNAL_INCLUDE_DIRS ${Breakpad_INCLUDE_DIR} EXPORT_DEFINE MITK_BREAKPAD_EXPORT ADDITIONAL_LIBS ${Breakpad_LIBRARIES} PACKAGE_DEPENDS QT ) if(CMAKE_SYSTEM MATCHES "Windows") - add_executable(CrashReportingServer ${EXECUTABLE_PROPERTY} mitkCrashReportingServer.cpp ${SERVER_MOC_CPP}) + add_executable(CrashReportingServer WIN32 mitkCrashReportingServer.cpp ${SERVER_MOC_CPP}) target_link_libraries(CrashReportingServer ${ALL_LIBRARIES} ${QT_QTMAIN_LIBRARY} BreakpadCrashReporting) endif() add_subdirectory(Testing) endif(MITK_USE_BREAKPAD)