forked from joova/rest_server
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathCMakeLists.txt
86 lines (70 loc) · 3.73 KB
/
CMakeLists.txt
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
cmake_minimum_required(VERSION 3.7)
project(rest-server)
find_package(Boost REQUIRED COMPONENTS system thread log program_options chrono)
find_package(Threads REQUIRED)
file(GLOB OPENSSL_ROOT_DIR /usr/local/Cellar/openssl/*)
list(REVERSE OPENSSL_ROOT_DIR)
find_package(OpenSSL 1.0.2 REQUIRED)
find_package(cpprestsdk REQUIRED)
find_package(libmongocxx REQUIRED)
find_package(libbsoncxx REQUIRED)
set(CMAKE_CXX_STANDARD 11)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -DBOOST_LOG_DYN_LINK")
add_executable( ${PROJECT_NAME} source/main.cpp
source/db_pool_singleton.cpp
source/user_manager.cpp
source/auth_handler.cpp
source/basic_controller.cpp
source/microsvc_controller.cpp
source/crypto_utils.cpp
source/health_handler.cpp
source/user_handler.cpp)
# message(BOOST_LIBS " ${Boost_LIBRARIES}")
# message(OPENSSL_LIBS " ${OPENSSL_LIBRARIES}")
# message(CPPRESTSDK_INCLUDE_DIR " ${CPPRESTSDK_INCLUDE_DIR}")
set(MICROSERVICE_INCLUDE_DIR "source")
set(JWT_INCLUDE_DIR "include")
file(GLOB COMMON_LIBRARIES ${LIBMONGOCXX_LIBRARIES}
${LIBBSONCXX_LIBRARIES}
${OPENSSL_LIBRARIES}
${Boost_LIBRARIES}
${ZIP_LIBRARY})
file(GLOB COMMON_INCLUDES ${LIBMONGOCXX_INCLUDE_DIRS}
${LIBBSONCXX_INCLUDE_DIRS}
${Boost_INCLUDE_DIR}
${OPENSSL_INCLUDE_DIR}
${MICROSERVICE_INCLUDE_DIR}
${JWT_INCLUDE_DIR})
target_include_directories(${PROJECT_NAME} PUBLIC ${COMMON_INCLUDES})
# target_include_directories(${PROJECT_NAME} PUBLIC ${Boost_INCLUDE_DIR})
# target_include_directories(${PROJECT_NAME} PUBLIC ${OPENSSL_INCLUDE_DIR})
# target_include_directories(${PROJECT_NAME} PRIVATE ${MICROSERVICE_INCLUDE_DIR})
target_link_libraries(${PROJECT_NAME} PUBLIC ${COMMON_LIBRARIES})
# target_link_libraries(${PROJECT_NAME} PUBLIC ${OPENSSL_LIBRARIES})
# target_link_libraries(${PROJECT_NAME} PUBLIC ${Boost_LIBRARIES})
# target_link_libraries(${PROJECT_NAME} PUBLIC ${ZIP_LIBRARY})
target_link_libraries(${PROJECT_NAME} PRIVATE cpprestsdk::cpprest
cpprestsdk::cpprestsdk_zlib_internal
cpprestsdk::cpprestsdk_boost_internal
cpprestsdk::cpprestsdk_openssl_internal)
# Locate GTest
find_package(GTest REQUIRED)
# Link rest_test with what we want to test and the GTest and pthread library
add_executable(rest-test test/main_test.cpp
test/user_manager_test.cpp
test/crypto_utils_test.cpp
test/auth_handler_test.cpp
source/db_pool_singleton.cpp
source/user_manager.cpp
source/auth_handler.cpp
source/crypto_utils.cpp
source/health_handler.cpp
source/user_handler.cpp)
target_include_directories(rest-test PUBLIC ${COMMON_INCLUDES}
${GTEST_INCLUDE_DIRS})
target_link_libraries(rest-test PRIVATE ${GTEST_LIBRARIES}
${COMMON_LIBRARIES}
cpprestsdk::cpprest
cpprestsdk::cpprestsdk_zlib_internal
cpprestsdk::cpprestsdk_boost_internal
cpprestsdk::cpprestsdk_openssl_internal)