CMakeLists.txt 1.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556
  1. # Smartbotic Database Client Library
  2. if(BUILD_SHARED_LIBS)
  3. add_library(smartbotic-db-client SHARED
  4. src/client.cpp
  5. $<TARGET_OBJECTS:smartbotic_db_proto>
  6. )
  7. set_target_properties(smartbotic-db-client PROPERTIES
  8. VERSION ${SMARTBOTIC_DB_VERSION}
  9. SOVERSION 2
  10. )
  11. else()
  12. add_library(smartbotic-db-client STATIC
  13. src/client.cpp
  14. )
  15. endif()
  16. target_include_directories(smartbotic-db-client PUBLIC
  17. $<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/include>
  18. $<INSTALL_INTERFACE:include>
  19. )
  20. # Link dependencies
  21. target_link_libraries(smartbotic-db-client PUBLIC
  22. smartbotic_db_proto
  23. )
  24. if(TARGET nlohmann_json::nlohmann_json)
  25. target_link_libraries(smartbotic-db-client PUBLIC nlohmann_json::nlohmann_json)
  26. else()
  27. target_include_directories(smartbotic-db-client PUBLIC ${NLOHMANN_JSON_INCLUDE_DIRS})
  28. endif()
  29. if(TARGET spdlog::spdlog)
  30. target_link_libraries(smartbotic-db-client PUBLIC spdlog::spdlog)
  31. else()
  32. target_link_libraries(smartbotic-db-client PUBLIC ${SPDLOG_LIBRARIES})
  33. target_include_directories(smartbotic-db-client PUBLIC ${SPDLOG_INCLUDE_DIRS})
  34. endif()
  35. # Export alias
  36. add_library(smartbotic::db-client ALIAS smartbotic-db-client)
  37. # Installation (standalone/packaging only)
  38. if(SMARTBOTIC_DB_STANDALONE)
  39. include(GNUInstallDirs)
  40. install(TARGETS smartbotic-db-client
  41. LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}
  42. ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR}
  43. )
  44. install(DIRECTORY include/smartbotic
  45. DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}
  46. )
  47. endif()