CMakeLists.txt 1.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546
  1. cmake_minimum_required(VERSION 2.8.12)
  2. project(cspot)
  3. # Configurable options
  4. set(CSPOT_EXTERNAL_BELL "" CACHE STRING "External bell library target name, optional")
  5. # CMake options
  6. set(CMAKE_CXX_STANDARD 17)
  7. # Main library sources
  8. file(GLOB SOURCES "src/*.cpp" "src/*.c")
  9. # Use externally specified bell library or the submodule
  10. if(CSPOT_EXTERNAL_BELL)
  11. list(APPEND EXTRA_LIBS ${CSPOT_EXTERNAL_BELL})
  12. else()
  13. add_subdirectory(${CMAKE_CURRENT_SOURCE_DIR}/bell)
  14. list(APPEND EXTRA_LIBS bell)
  15. endif()
  16. # Add Apple Bonjour compatibility library for Linux
  17. if(UNIX AND NOT APPLE)
  18. list(APPEND EXTRA_LIBS dns_sd)
  19. # TODO: migrate from this to native linux mDNS
  20. endif()
  21. # Build protobuf code
  22. #set(NANOPB_OPTIONS "-I${CMAKE_CURRENT_SOURCE_DIR}")
  23. #file(GLOB PROTOS protobuf/*.proto)
  24. #nanopb_generate_cpp(PROTO_SRCS PROTO_HDRS RELPATH ${CMAKE_CURRENT_SOURCE_DIR} ${PROTOS})
  25. #add_custom_target(generate_proto_sources DEPENDS ${PROTO_SRCS} ${PROTO_HDRS})
  26. #set_source_files_properties(${PROTO_SRCS} ${PROTO_HDRS}
  27. # PROPERTIES GENERATED TRUE)
  28. file(GLOB SOURCES "src/*.cpp" "src/*.c" "protobuf/*.c")
  29. message("BEWARE => NOT GENERATING PROTOBUF")
  30. set(GENERATED_INCLUDES ".")
  31. add_library(cspot STATIC ${SOURCES} ${PROTO_SRCS})
  32. # PUBLIC to propagate includes from bell to cspot dependents
  33. target_compile_definitions(bell PUBLIC PB_ENABLE_MALLOC)
  34. target_compile_definitions(bell PUBLIC PB_FIELD_32BIT)
  35. target_link_libraries(cspot PUBLIC ${EXTRA_LIBS})
  36. #target_include_directories(cspot PUBLIC "include" ${CMAKE_CURRENT_BINARY_DIR} ${NANOPB_INCLUDE_DIRS})
  37. target_include_directories(cspot PUBLIC "include" ${GENERATED_INCLUDES} ${NANOPB_INCLUDE_DIRS})