You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

69 lines
2.4 KiB

3 years ago
  1. cmake_minimum_required(VERSION 3.13)
  2. set(CMAKE_EXPORT_COMPILE_COMMANDS ON)
  3. set(CMAKE_SYSTEM_NAME Linux)
  4. set(CMAKE_BUILD_TYPE Debug)
  5. set(CMAKE_SKIP_BUILD_RPATH FALSE)
  6. set(CMAKE_BUILD_WITH_INSTALL_RPATH FALSE)
  7. set(CMAKE_INSTALL_RPATH_USE_LINK_PATH TRUE)
  8. set(CMAKE_INSTALL_PREFIX "./")
  9. include(zcmake/zcmake.cmake)
  10. project(app)
  11. # 设置ccache加速C++编译速度
  12. set_property(GLOBAL PROPERTY RULE_LAUNCH_COMPILE ccache)
  13. set_property(GLOBAL PROPERTY RULE_LAUNCH_LINK ccache)
  14. # 设置通用编译选项
  15. set(C_CPP_FLAGS "${C_CPP_FLAGS} ")
  16. set(C_CPP_FLAGS
  17. "${C_CPP_FLAGS} -Wno-unused-local-typedefs -Wno-unused-but-set-variable -Wno-deprecated-declarations -Wno-unused-variable"
  18. )
  19. set(C_CPP_FLAGS
  20. "${C_CPP_FLAGS} -Wno-unused-local-typedefs -Wno-unused-but-set-variable -Wno-deprecated-declarations -Wno-unused-variable"
  21. )
  22. set(C_CPP_FLAGS
  23. "${C_CPP_FLAGS} -Werror=return-type -Werror=parentheses -Wfatal-errors -Wno-comment"
  24. )
  25. set(C_CPP_FLAGS "${C_CPP_FLAGS} -Wno-format-overflow")
  26. set(C_CPP_FLAGS "${C_CPP_FLAGS} -O0 -g3 -fPIC -Wall")
  27. # 设置C编译选项
  28. set(CMAKE_C_FLAGS "${C_CPP_FLAGS}")
  29. message("CMAKE_C_FLAGS : ${CMAKE_C_FLAGS}")
  30. # 设置CPP编译选项
  31. set(CMAKE_CXX_FLAGS "${C_CPP_FLAGS}")
  32. set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wno-pessimizing-move -Wno-reorder")
  33. set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++14")
  34. message("CMAKE_CXX_FLAGS: ${CMAKE_CXX_FLAGS}")
  35. message("PROJECT_NAME: ${PROJECT_NAME}")
  36. # 添加相应的依赖代码
  37. include(dep/iflytopcpp/module.cmake)
  38. include(dep/asio1.12.2/module.cmake)
  39. include(dep/websocketpp/module.cmake)
  40. include(dep/zservice_container/module.cmake)
  41. include(dep/zwebservice/module.cmake)
  42. include(dep/zlinuxcomponents/module.cmake)
  43. # 设置当前工程依赖的头文件路径和链接的库文件
  44. set(DEP_INCLUDE ${DEP_INCLUDE} ./dep/)
  45. set(DEP_LINK_LIBRARIES ${DEP_LINK_LIBRARIES} asound pthread)
  46. # 添加编译的目标文件
  47. zadd_executable_simple(
  48. TARGET
  49. app.out
  50. SRC
  51. src/main.cpp
  52. src/service/device_io_service.cpp
  53. src/service/device_io_service_mock.cpp
  54. src/service/main_control_service.cpp
  55. src/service/light_control_service.cpp
  56. src/service/report_service.cpp)
  57. zadd_executable_simple(TARGET alsaplayer_main.out SRC
  58. dep/zlinuxcomponents/alsaplayer/alsaplayer_main.cpp)
  59. zadd_executable_simple(TARGET audio_recorder_main.out SRC
  60. dep/zlinuxcomponents/audio/audio_recorder_main.cpp)