CMakeLists.txt 3.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899
  1. #
  2. # Copyright (C) 2014 Pavel Kirienko <pavel.kirienko@gmail.com>
  3. #
  4. cmake_minimum_required(VERSION 2.8)
  5. project(libuavcan_linux)
  6. #
  7. # Library (header only)
  8. #
  9. install(DIRECTORY include/uavcan_linux DESTINATION include)
  10. #
  11. # Scripts
  12. #
  13. install(DIRECTORY scripts/
  14. USE_SOURCE_PERMISSIONS
  15. DESTINATION bin)
  16. #
  17. # System dependecies
  18. #
  19. find_package(Threads REQUIRED)
  20. #
  21. # Finding libuavcan - it will be a target if we're running from the top-level CMakeLists.txt,
  22. # otherwise try to find it in the system directories.
  23. #
  24. if (TARGET uavcan)
  25. message(STATUS "Using uavcan target; source dir: ${libuavcan_SOURCE_DIR}")
  26. set(UAVCAN_LIB uavcan)
  27. include_directories(${libuavcan_SOURCE_DIR}/include
  28. ${libuavcan_SOURCE_DIR}/include/dsdlc_generated)
  29. message(STATUS "POSIX source dir: ${libuavcan_posix_SOURCE_DIR}")
  30. include_directories(${libuavcan_posix_SOURCE_DIR}/include)
  31. else ()
  32. message(STATUS "Using installed uavcan library")
  33. find_library(UAVCAN_LIB uavcan REQUIRED)
  34. endif ()
  35. #
  36. # Applications - tests, tools.
  37. #
  38. include_directories(include)
  39. set(CMAKE_CXX_FLAGS "-Wall -Wextra -pedantic -std=c++11") # GCC or Clang
  40. if(CMAKE_BUILD_TYPE STREQUAL "Debug")
  41. add_definitions(-DUAVCAN_DEBUG=1)
  42. endif()
  43. #
  44. # Tests
  45. # These aren't installed, an average library user should not care about them.
  46. #
  47. add_executable(test_clock apps/test_clock.cpp)
  48. target_link_libraries(test_clock ${UAVCAN_LIB} rt ${CMAKE_THREAD_LIBS_INIT})
  49. add_executable(test_socket apps/test_socket.cpp)
  50. target_link_libraries(test_socket ${UAVCAN_LIB} rt ${CMAKE_THREAD_LIBS_INIT})
  51. add_executable(test_node apps/test_node.cpp)
  52. target_link_libraries(test_node ${UAVCAN_LIB} rt ${CMAKE_THREAD_LIBS_INIT})
  53. add_executable(test_time_sync apps/test_time_sync.cpp)
  54. target_link_libraries(test_time_sync ${UAVCAN_LIB} rt ${CMAKE_THREAD_LIBS_INIT})
  55. add_executable(test_system_utils apps/test_system_utils.cpp)
  56. target_link_libraries(test_system_utils ${UAVCAN_LIB} rt ${CMAKE_THREAD_LIBS_INIT})
  57. add_executable(test_posix apps/test_posix.cpp)
  58. target_link_libraries(test_posix ${UAVCAN_LIB} rt ${CMAKE_THREAD_LIBS_INIT})
  59. add_executable(test_dynamic_node_id_client apps/test_dynamic_node_id_client.cpp)
  60. target_link_libraries(test_dynamic_node_id_client ${UAVCAN_LIB} rt ${CMAKE_THREAD_LIBS_INIT})
  61. add_executable(test_file_server apps/test_file_server.cpp)
  62. target_link_libraries(test_file_server ${UAVCAN_LIB} rt ${CMAKE_THREAD_LIBS_INIT})
  63. add_executable(test_multithreading apps/test_multithreading.cpp)
  64. target_link_libraries(test_multithreading ${UAVCAN_LIB} rt ${CMAKE_THREAD_LIBS_INIT})
  65. #
  66. # Tools
  67. #
  68. add_executable(uavcan_monitor apps/uavcan_monitor.cpp)
  69. target_link_libraries(uavcan_monitor ${UAVCAN_LIB} rt ${CMAKE_THREAD_LIBS_INIT})
  70. add_executable(uavcan_nodetool apps/uavcan_nodetool.cpp)
  71. target_link_libraries(uavcan_nodetool ${UAVCAN_LIB} rt ${CMAKE_THREAD_LIBS_INIT})
  72. add_executable(uavcan_dynamic_node_id_server apps/uavcan_dynamic_node_id_server.cpp)
  73. target_link_libraries(uavcan_dynamic_node_id_server ${UAVCAN_LIB} rt ${CMAKE_THREAD_LIBS_INIT})
  74. install(TARGETS uavcan_monitor
  75. uavcan_nodetool
  76. uavcan_dynamic_node_id_server
  77. RUNTIME DESTINATION bin)