cmake.global 1.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950
  1. find_program(PYTHON "python3")
  2. include(TestBigEndian)
  3. test_big_endian(BIGENDIAN)
  4. if (BIGENDIAN)
  5. add_definitions(-DBIG_ENDIAN_HOST)
  6. else (BIGENDIAN)
  7. add_definitions(-DLITTLE_ENDIAN_HOST)
  8. endif (BIGENDIAN)
  9. add_definitions("-D_GNU_SOURCE")
  10. add_definitions("-D_BSD_SOURCE")
  11. add_definitions("-D_DEFAULT_SOURCE")
  12. add_definitions("-DRAZERCFG_BUILD")
  13. add_definitions("-D_FORTIFY_SOURCE=2")
  14. set(WARNING_COMPILE_FLAGS "-Wall -Wformat -Wformat-security -Wextra -Wno-unused-parameter -Wsuggest-attribute=noreturn -Wundef -Wpointer-arith -Wcast-qual -Wlogical-op -Wshadow")
  15. set(GENERIC_COMPILE_FLAGS "-O2 -std=c99 -fstack-protector -fstack-check ${WARNING_COMPILE_FLAGS}")
  16. set(CMAKE_C_FLAGS_DEBUG "${CMAKE_C_FLAGS_DEBUG} -DDEBUG -fsanitize=undefined -fsanitize=float-divide-by-zero -fsanitize=float-cast-overflow -fsanitize=address")
  17. find_path(LIBUSB_INCLUDE_PATH
  18. NAMES libusb.h
  19. PATHS "/usr/include/libusb" "/usr/include/libusb-1.0"
  20. )
  21. include_directories(AFTER ${LIBUSB_INCLUDE_PATH})
  22. set(CMAKE_REQUIRED_INCLUDES "${LIBUSB_INCLUDE_PATH};${CMAKE_REQUIRED_INCLUDES}")
  23. execute_process(COMMAND pkg-config --variable=systemdsystemunitdir systemd
  24. OUTPUT_VARIABLE SYSTEMD_UNIT_DIR
  25. ERROR_QUIET
  26. OUTPUT_STRIP_TRAILING_WHITESPACE)
  27. execute_process(COMMAND pkg-config --variable=udevdir udev
  28. OUTPUT_VARIABLE UDEV_DIR
  29. ERROR_QUIET
  30. OUTPUT_STRIP_TRAILING_WHITESPACE)
  31. macro(INSTALL_EXEC_CMD _COMMAND _FAILMSG)
  32. install(CODE "
  33. execute_process(COMMAND ${_COMMAND} RESULT_VARIABLE install_exec_res)
  34. if (NOT \"\${install_exec_res}\" STREQUAL \"0\")
  35. message(WARNING \"WARNING: ${_COMMAND} failed: \${install_exec_res}\n${_FAILMSG}\n\")
  36. else (NOT \"\${install_exec_res}\" STREQUAL \"0\")
  37. message(STATUS \"${_COMMAND}: \${install_exec_res}\")
  38. endif (NOT \"\${install_exec_res}\" STREQUAL \"0\")
  39. ")
  40. endmacro(INSTALL_EXEC_CMD)