CMakeLists.txt 4.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104
  1. cmake_minimum_required(VERSION 3.13)
  2. if(${CMAKE_VERSION} VERSION_GREATER_EQUAL 3.12)
  3. cmake_policy(SET CMP0074 NEW)
  4. endif()
  5. set(ROTOR_LIGHT_VERSION "0.01")
  6. project (rotor_light LANGUAGES CXX VERSION ${ROTOR_LIGHT_VERSION})
  7. set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${CMAKE_SOURCE_DIR}/cmake/Modules/")
  8. if (NOT DEFINED CMAKE_CXX_VISIBILITY_PRESET AND
  9. NOT DEFINED CMAKE_VISIBILITY_INLINES_HIDDEN)
  10. set(CMAKE_CXX_VISIBILITY_PRESET hidden)
  11. set(CMAKE_VISIBILITY_INLINES_HIDDEN YES)
  12. endif ()
  13. set(ROTOR_LIGHT_DOC OFF CACHE BOOL "generate docs using doxygen")
  14. set(ROTOR_LIGHT_ACTOR "uint64_t" CACHE STRING "ActorId type [default: uint64_t]")
  15. set(ROTOR_LIGHT_TIMEPOINT "int64_t" CACHE STRING "TimePoint type [default: int64_t]")
  16. set(ROTOR_LIGHT_DURATION "std::int_fast32_t" CACHE STRING "Duration type [default: std::int_fast32_t]")
  17. set(ROTOR_LIGHT_MESSAGE "std::uint_fast16_t" CACHE STRING "Message id type [default: std::uint_fast16_t]")
  18. set(ROTOR_LIGHT_EVENT "std::uint16_t" CACHE STRING "Event id type [default: std::uint16_t]")
  19. set(ROTOR_LIGHT_INDEX "std::uint_fast8_t" CACHE STRING "Queue indexing type [default: std::uint_fast8_t]")
  20. set(ROTOR_LIGHT_FW_QUEUE "0" CACHE STRING "Default queue/priority for rotor light framework messages [default: 0]")
  21. include(CMakePrintHelpers)
  22. include(GenerateExportHeader)
  23. if ("${CMAKE_SYSTEM_PROCESSOR}" STREQUAL "AVR")
  24. set(ROTOR_LIGHT_BSP_DIR "avr")
  25. elseif ("${TOOLCHAIN_PREFIX}" MATCHES "^arm-.*")
  26. set(ROTOR_LIGHT_BSP_DIR "arm")
  27. elseif ("${TOOLCHAIN_PREFIX}" STREQUAL "mb-")
  28. set(ROTOR_LIGHT_BSP_DIR "mb")
  29. elseif ("${TOOLCHAIN_PREFIX}" STREQUAL "")
  30. set(ROTOR_LIGHT_BSP_DIR "host")
  31. endif()
  32. set(ROTOR_LIGHT_BSP_PATH "include/rotor-light/bsp/${ROTOR_LIGHT_BSP_DIR}")
  33. add_library(rotor_light_bsp INTERFACE)
  34. target_include_directories(rotor_light_bsp INTERFACE
  35. $<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/${ROTOR_LIGHT_BSP_PATH}>
  36. $<BUILD_INTERFACE:${CMAKE_CURRENT_BINARY_DIR}/${ROTOR_LIGHT_BSP_PATH}>
  37. $<INSTALL_INTERFACE:include/${ROTOR_LIGHT_BSP_PATH}>
  38. )
  39. add_library(rotor_light
  40. src/rotor-light/actor.cpp
  41. src/rotor-light/misc.cpp
  42. src/rotor-light/queue.cpp
  43. src/rotor-light/planner.cpp
  44. src/rotor-light/supervisor.cpp
  45. )
  46. target_include_directories(rotor_light PUBLIC
  47. $<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/include>
  48. $<BUILD_INTERFACE:${CMAKE_CURRENT_BINARY_DIR}/include>
  49. $<INSTALL_INTERFACE:include>
  50. )
  51. target_compile_features(rotor_light PUBLIC cxx_std_17)
  52. set_target_properties(rotor_light PROPERTIES
  53. CXX_STANDARD 17
  54. CXX_STANDARD_REQUIRED YES
  55. CXX_EXTENSIONS NO
  56. )
  57. target_compile_definitions(rotor_light PUBLIC
  58. "ROTOR_LIGHT_ACTOR=${ROTOR_LIGHT_ACTOR}"
  59. "ROTOR_LIGHT_TIMEPOINT=${ROTOR_LIGHT_TIMEPOINT}"
  60. "ROTOR_LIGHT_DURATION=${ROTOR_LIGHT_DURATION}"
  61. "ROTOR_LIGHT_MESSAGE=${ROTOR_LIGHT_MESSAGE}"
  62. "ROTOR_LIGHT_EVENT=${ROTOR_LIGHT_EVENT}"
  63. "ROTOR_LIGHT_INDEX=${ROTOR_LIGHT_INDEX}"
  64. "ROTOR_LIGHT_FW_QUEUE=${ROTOR_LIGHT_FW_QUEUE}"
  65. )
  66. target_link_libraries(rotor_light rotor_light_bsp)
  67. if (CMAKE_PROJECT_NAME STREQUAL PROJECT_NAME)
  68. add_subdirectory("examples")
  69. if ("${TOOLCHAIN_PREFIX}" STREQUAL "")
  70. include(CTest)
  71. if (BUILD_TESTING)
  72. add_subdirectory("tests")
  73. endif()
  74. endif()
  75. find_package(Doxygen)
  76. if (DOXYGEN_FOUND AND ${ROTOR_LIGHT_DOC})
  77. set(DOXYGEN_IN ${CMAKE_CURRENT_SOURCE_DIR}/docs/Doxyfile.in)
  78. set(DOXYGEN_OUT ${CMAKE_CURRENT_BINARY_DIR}/Doxyfile)
  79. configure_file(${DOXYGEN_IN} ${DOXYGEN_OUT} @ONLY)
  80. add_custom_target( doc_doxygen ALL
  81. COMMAND ${DOXYGEN_EXECUTABLE} ${DOXYGEN_OUT}
  82. WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}
  83. COMMENT "Generating API documentation with Doxygen"
  84. VERBATIM)
  85. file(GLOB DOC_IMAGES CONFIGURE_DEPENDS ${CMAKE_CURRENT_SOURCE_DIR}/docs/*.png)
  86. file(COPY ${DOC_IMAGES} DESTINATION ${CMAKE_CURRENT_SOURCE_DIR}/doxygen)
  87. message("Doxygen need to be installed to generate the doxygen documentation")
  88. endif()
  89. endif()