CMakeLists.txt 2.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687
  1. #
  2. # Copyright (C) 2014 Pavel Kirienko <pavel.kirienko@gmail.com>
  3. #
  4. cmake_minimum_required(VERSION 2.8)
  5. project(uavcan C CXX)
  6. #
  7. # Build options
  8. #
  9. if(${CMAKE_SYSTEM_NAME} STREQUAL "Linux")
  10. set(DEFAULT_UAVCAN_PLATFORM "linux")
  11. endif()
  12. # options are listed in a table format below
  13. set(opts
  14. # name: type: default value: string options list : description
  15. "CMAKE_BUILD_TYPE:STRING:RelWithDebInfo:Debug Release RelWithDebInfo MinSizeRel:Build type."
  16. "CMAKE_CXX_FLAGS:STRING:::C++ flags."
  17. "CMAKE_C_FLAGS:STRING:::C flags."
  18. "UAVCAN_USE_CPP03:BOOL:OFF::Use C++03 standard."
  19. "UAVCAN_PLATFORM:STRING:generic:generic linux stm32:Platform."
  20. "CONTINUOUS_INTEGRATION_BUILD:BOOL:OFF::Disable error redirection and timing tests"
  21. "UAVCAN_CMAKE_VERBOSE:BOOL:OFF::Verbose CMake configure output"
  22. )
  23. foreach(_opt ${opts})
  24. # arguments are : delimited
  25. string(REPLACE ":" ";" _opt ${_opt})
  26. list(GET _opt 0 _name)
  27. list(GET _opt 1 _type)
  28. list(GET _opt 2 _default)
  29. list(GET _opt 3 _options)
  30. list(GET _opt 4 _descr)
  31. # options are space delimited
  32. string(REPLACE " " ";" _options "${_options}")
  33. # if a default has not already been defined, use default from table
  34. if(NOT DEFINED DEFAULT_${_name})
  35. set(DEFAULT_${_name} ${_default})
  36. endif()
  37. # option has not been set already or it is empty, set it with the default
  38. if(NOT DEFINED ${_name} OR ${_name} STREQUAL "")
  39. set(${_name} ${DEFAULT_${_name}})
  40. endif()
  41. # create a cache from the variable and force it to set
  42. if(UAVCAN_CMAKE_VERBOSE)
  43. message(STATUS "${_name}\t: ${${_name}} : ${_descr}")
  44. endif()
  45. set("${_name}" "${${_name}}" CACHE "${_type}" "${_descr}" FORCE)
  46. # if an options list is provided for the cache, set it
  47. if("${_type}" STREQUAL "STRING" AND NOT "${_options}" STREQUAL "")
  48. set_property(CACHE ${_name} PROPERTY STRINGS ${_options})
  49. endif()
  50. endforeach()
  51. #
  52. # Set flags
  53. #
  54. include_directories(
  55. ./libuavcan/include/
  56. ./libuavcan/include/dsdlc_generated
  57. )
  58. #
  59. # Install
  60. #
  61. # DSDL definitions
  62. install(DIRECTORY dsdl DESTINATION share/uavcan)
  63. #
  64. # Subdirectories
  65. #
  66. # library
  67. add_subdirectory(libuavcan)
  68. # drivers
  69. if (${UAVCAN_PLATFORM} STREQUAL "linux")
  70. message(STATUS "Adding UAVCAN Linux platform driver")
  71. add_subdirectory(libuavcan_drivers/posix)
  72. add_subdirectory(libuavcan_drivers/linux)
  73. elseif(${UAVCAN_PLATFORM} STREQUAL "stm32")
  74. message(STATUS "Adding UAVCAN STM32 platform driver")
  75. add_subdirectory(libuavcan_drivers/posix)
  76. add_subdirectory(libuavcan_drivers/stm32/driver)
  77. endif()
  78. # vim: set et ft=cmake fenc=utf-8 ff=unix sts=4 sw=4 ts=4 :