BreakpadSymbols.cmake 1.9 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152
  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/ ${DEPENDENCY_ROOT}/bin ${DEPENDENCY_ROOT}/lib)
  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. unset(COMPRESS)
  26. find_program(COMPRESS_XZ xz HINTS c:/mingw /usr/local/bin)
  27. find_program(COMPRESS_BZ bzip2 HINTS c:/mingw /usr/local/bin)
  28. if(COMPRESS_XZ)
  29. set(COMPRESS_EXT xz)
  30. file(TO_NATIVE_PATH ${COMPRESS_XZ} COMPRESS)
  31. elseif(COMPRESS_BZ)
  32. set(COMPRESS_EXT bz2)
  33. file(TO_NATIVE_PATH ${COMPRESS_BZ} COMPRESS)
  34. endif(COMPRESS_XZ)
  35. set(TARGET_FILE $<TARGET_FILE:${target}>)
  36. if(WIN32)
  37. set(TARGET_FILE $<TARGET_PDB_FILE:${target}>)
  38. endif(WIN32)
  39. add_custom_command(
  40. TARGET ${target} POST_BUILD
  41. BYPRODUCTS ${symfile}.${COMPRESS_EXT}
  42. COMMAND ${DUMP_SYMS} ${EXTRA_DUMPSYMS_ARGS} ${TARGET_FILE} | ${COMPRESS} > ${symfile}.${COMPRESS_EXT}
  43. COMMENT Generating symbols
  44. )
  45. endif(GENERATE_SYMBOLS AND DUMP_SYMS)
  46. endfunction()