cmake.global 1.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940
  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. macro(INSTALL_EXEC_CMD _COMMAND _FAILMSG)
  24. install(CODE "
  25. execute_process(COMMAND ${_COMMAND} RESULT_VARIABLE install_exec_res)
  26. if (NOT \"\${install_exec_res}\" STREQUAL \"0\")
  27. message(WARNING \"WARNING: ${_COMMAND} failed: \${install_exec_res}\n${_FAILMSG}\n\")
  28. else (NOT \"\${install_exec_res}\" STREQUAL \"0\")
  29. message(STATUS \"${_COMMAND}: \${install_exec_res}\")
  30. endif (NOT \"\${install_exec_res}\" STREQUAL \"0\")
  31. ")
  32. endmacro(INSTALL_EXEC_CMD)