CMakeLists.txt 1.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243
  1. set(LIBRARY_NAME librabbitmq)
  2. unset(OPTION_ENABLE_TEST_CODE CACHE)
  3. option(OPTION_ENABLE_TEST_CODE "Whether enable test code." OFF)
  4. message("<=${LIBRARY_NAME}=> test: " ${OPTION_ENABLE_TEST_CODE})
  5. set(LIBRARY_SOURCE_LIST
  6. ${CMAKE_CURRENT_LIST_DIR}/rabbitmq_base.h
  7. ${CMAKE_CURRENT_LIST_DIR}/rabbitmq_base.cpp
  8. ${CMAKE_CURRENT_LIST_DIR}/rabbitmq_message.h
  9. ${CMAKE_CURRENT_LIST_DIR}/rabbitmq_message.cpp
  10. ${CMAKE_CURRENT_LIST_DIR}/rabbitmq.pb.cc
  11. ${CMAKE_CURRENT_LIST_DIR}/rabbitmq.pb.h
  12. )
  13. if(CMAKE_SYSTEM_PROCESSOR MATCHES "aarch64")
  14. set(Rabbitmq
  15. /usr/lib/aarch64-linux-gnu/librabbitmq.a
  16. )
  17. else()
  18. set(Rabbitmq
  19. /usr/local/lib/librabbitmq.a
  20. )
  21. endif()
  22. set(LIBRARY_DEPEND_LIST
  23. libthread
  24. ${Rabbitmq}
  25. ${PROTOBUF_LIBRARIES}
  26. )
  27. add_library(${LIBRARY_NAME} ${LIBRARY_SOURCE_LIST})
  28. target_link_libraries(${LIBRARY_NAME} PUBLIC ${LIBRARY_DEPEND_LIST})
  29. if (OPTION_ENABLE_TEST_CODE)
  30. set(LIBRARY_TEST_NAME "${LIBRARY_NAME}_test")
  31. set(LIBRARY_TEST_SOURCE_LIST
  32. ${CMAKE_CURRENT_LIST_DIR}/test.h
  33. ${CMAKE_CURRENT_LIST_DIR}/test.cpp
  34. )
  35. add_executable(${LIBRARY_TEST_NAME} ${LIBRARY_TEST_SOURCE_LIST})
  36. target_link_libraries(${LIBRARY_TEST_NAME} ${LIBRARY_NAME} )
  37. endif ()