CMakeLists.txt 1.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758
  1. project(test_redis++)
  2. cmake_minimum_required(VERSION 3.1)
  3. set(REDIS_PLUS_PLUS_TEST_SOURCES src/sw/redis++/test_main.cpp)
  4. add_executable(${PROJECT_NAME} ${REDIS_PLUS_PLUS_TEST_SOURCES})
  5. # hiredis dependency
  6. find_path(HIREDIS_HEADER hiredis REQUIRED)
  7. target_include_directories(${PROJECT_NAME} PRIVATE $<BUILD_INTERFACE:${HIREDIS_HEADER}>)
  8. find_library(TEST_HIREDIS_LIB libhiredis.a)
  9. if(NOT TEST_HIREDIS_LIB)
  10. find_library(TEST_HIREDIS_LIB libhiredis_static.a)
  11. if(NOT TEST_HIREDIS_LIB)
  12. find_library(TEST_HIREDIS_LIB hiredis)
  13. endif()
  14. endif()
  15. target_link_libraries(${PROJECT_NAME} ${TEST_HIREDIS_LIB})
  16. if(REDIS_PLUS_PLUS_USE_TLS)
  17. find_package(OpenSSL REQUIRED)
  18. find_library(TEST_HIREDIS_TLS_LIB libhiredis_ssl.a)
  19. if(NOT TEST_HIREDIS_TLS_LIB)
  20. find_library(TEST_HIREDIS_TLS_LIB libhiredis_ssl_static.a)
  21. if(NOT TEST_HIREDIS_TLS_LIB)
  22. find_library(TEST_HIREDIS_TLS_LIB hiredis_ssl)
  23. endif()
  24. endif()
  25. target_link_libraries(${PROJECT_NAME} ${TEST_HIREDIS_TLS_LIB} ${OPENSSL_LIBRARIES})
  26. endif()
  27. # redis++ dependency
  28. target_include_directories(${PROJECT_NAME} PRIVATE
  29. $<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/../src>
  30. $<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/../${TLS_SUB_DIR}>
  31. $<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/../${CXX_UTILS_DIR}>)
  32. # solaris socket dependency
  33. if(CMAKE_SYSTEM_NAME MATCHES "(Solaris|SunOS)")
  34. target_link_libraries(${PROJECT_NAME} -lsocket)
  35. endif(CMAKE_SYSTEM_NAME MATCHES "(Solaris|SunOS)")
  36. # Windows socket dependency
  37. if(WIN32)
  38. target_link_libraries(${PROJECT_NAME} ws2_32)
  39. endif()
  40. find_package(Threads REQUIRED)
  41. if(REDIS_PLUS_PLUS_BUILD_STATIC)
  42. set(REDIS_PLUS_PLUS_LIB redis++_static)
  43. else()
  44. set(REDIS_PLUS_PLUS_LIB redis++)
  45. endif()
  46. target_link_libraries(${PROJECT_NAME} ${REDIS_PLUS_PLUS_LIB} ${CMAKE_THREAD_LIBS_INIT})