BreakpadSymbols.cmake 1.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344
  1. include(CMakeDependentOption)
  2. set(ENABLE_CRASHDUMP ON)
  3. set(CRASHDUMP_SECRET "" CACHE STRING "Secret for the crashdump uploader")
  4. if (NOT CRASHDUMP_SECRET)
  5. message(STATUS "Crashdump secret not supplied, disabling crashdump uploading")
  6. set(ENABLE_CRASHDUMP OFF)
  7. else(NOT CRASHDUMP_SECRET)
  8. message(STATUS "Enabling crashdump uploader")
  9. endif(NOT CRASHDUMP_SECRET)
  10. cmake_dependent_option(GENERATE_SYMBOLS "Should we generate symbols for binaries?" ON "ENABLE_CRASHDUMP" OFF)
  11. function(dumpsyms target symfile)
  12. find_program(DUMP_SYMS dump_syms HINTS /usr/bin/ PATH_SUFFIXES lib bin)
  13. if(GENERATE_SYMBOLS AND NOT DUMP_SYMS)
  14. message(WARNING "dump_syms not found")
  15. endif()
  16. if(GENERATE_SYMBOLS AND DUMP_SYMS)
  17. if(APPLE)
  18. add_custom_command(TARGET ${target} POST_BUILD
  19. COMMAND dsymutil -o ${MAIN_NAME}.dSYM $<TARGET_FILE:${MAIN_TARGET}>
  20. COMMENT Generating ${MAIN_NAME}.dSYM
  21. BYPRODUCTS ${MAIN_NAME}.dSYM/Contents/Resources/DWARF/${target} ${MAIN_NAME}.dSYM/Contents/Info.plist
  22. )
  23. set(EXTRA_DUMPSYMS_ARGS -g "${CMAKE_CURRENT_BINARY_DIR}/${MAIN_NAME}.dSYM")
  24. endif(APPLE)
  25. set(TARGET_FILE $<TARGET_FILE:${target}>)
  26. if(WIN32)
  27. set(TARGET_FILE $<TARGET_PDB_FILE:${target}>)
  28. endif(WIN32)
  29. file(TO_NATIVE_PATH ${PYTHON_EXECUTABLE} PYTHON_EXE)
  30. file(TO_NATIVE_PATH ${PROJECT_SOURCE_DIR}/scripts/compress.py SCRIPT_PATH)
  31. add_custom_command(
  32. TARGET ${target} POST_BUILD
  33. BYPRODUCTS ${symfile}.bz2
  34. COMMAND ${DUMP_SYMS} ${EXTRA_DUMPSYMS_ARGS} ${TARGET_FILE} | ${PYTHON_EXE} -u ${SCRIPT_PATH} > ${symfile}.bz2
  35. COMMENT Generating symbols
  36. )
  37. endif(GENERATE_SYMBOLS AND DUMP_SYMS)
  38. endfunction()