-
Notifications
You must be signed in to change notification settings - Fork 129
/
CMakeLists.txt
85 lines (65 loc) · 3.21 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
cmake_minimum_required(VERSION 3.0)
project(micro-service)
# Configure required libraries ...
if(UNIX) # Darwing or Linux
find_package(Boost REQUIRED COMPONENTS system thread log program_options chrono)
find_package(Threads REQUIRED)
if(APPLE)
# Prefer a homebrew version of OpenSSL over the one in /usr/lib
file(GLOB OPENSSL_ROOT_DIR /usr/local/Cellar/openssl/*)
# Prefer the latest (make the latest one first)
list(REVERSE OPENSSL_ROOT_DIR)
find_package(OpenSSL 1.0.2 REQUIRED)
set(OPENSSL_VERSION "1.0.2s")
else()
find_package(OpenSSL 1.0.1 REQUIRED)
set(OPENSSL_VERSION "1.0.1")
endif()
elseif(WIN32) # Windows systems including Win64.
message(FATAL_ERROR "-- Windows is not supported for now.")
else()
message(FATAL_ERROR "-- Unsupported platform sorry! :( ")
endif()
# Configure compiler options ...
if(CMAKE_CXX_COMPILER_ID MATCHES "Clang")
message("-- configuring clang options")
set(CMAKE_CXX_FLAGS "-arch x86_64 -std=c++11 -stdlib=libc++ -DBOOST_LOG_DYN_LINK -Wno-deprecated-declarations")
elseif(CMAKE_CXX_COMPILER_ID MATCHES "GNU")
message("-- configuring gcc options")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=gnu++11 -DBOOST_LOG_DYN_LINK")
endif()
# Project construction ...
# source files ...
add_executable(${PROJECT_NAME} ./source/main.cpp
./source/microsvc_controller.cpp
./source/foundation/network_utils.cpp
./source/foundation/basic_controller.cpp)
# headers search paths ...
set(CPPRESTSDK_INCLUDE_DIR "./libs/cpprestsdk/Release/include")
set(MICROSERVICE_INCLUDE_DIR "./source/foundation/include")
message(MICROSERVICE " ${MICROSERVICE_INCLUDE_DIR}")
set(HEADER_SEARCH_PATHS ${CPPRESTSDK_INCLUDE_DIR} ${MICROSERVICE_INCLUDE_DIR} ${Boost_INCLUDE_DIR} ${OPENSSL_INCLUDE_DIR})
# library search paths ...
if(APPLE)
set(OPENSSL_LIBS "/usr/local/Cellar/openssl/${OPENSSL_VERSION}/lib/libssl.1.0.0.dylib;/usr/local/Cellar/openssl/${OPENSSL_VERSION}/lib/libcrypto.1.0.0.dylib")
set(CPPRESTSDK_LIBRARY "${PROJECT_SOURCE_DIR}/libs/cpprestsdk/build.release/Binaries/libcpprest.a")
set(ZIP_LIBRARY "/usr/local/Cellar/zlib/1.2.11/lib/libz.dylib")
set(LIBRARIES_SEARCH_PATHS ${OPENSSL_LIBS} ${Boost_LIBRARIES} ${CPPRESTSDK_LIBRARY} ${ZIP_LIBRARY})
else()
set(OPENSSL_LIBS "${OPENSSL_LIBRARIES}")
set(CPPRESTSDK_LIBRARY "${PROJECT_SOURCE_DIR}/libs/cpprestsdk/build.release/Binaries/libcpprest.a")
set(LIBRARIES_SEARCH_PATHS ${CPPRESTSDK_LIBRARY} ${OPENSSL_LIBS} ${Boost_LIBRARIES})
endif()
message(BOOST_LIBS " ${Boost_LIBRARIES}")
message(OPENSSL_LIBS " ${OPENSSL_LIBRARIES}")
message(CPPRESTSDK_LIBRARY " ${CPPRESTSDK_LIBRARY}")
message(LIBRARIES_SEARCH_PATHS " ${LIBRARIES_SEARCH_PATHS}")
include_directories(${HEADER_SEARCH_PATHS})
if (APPLE)
target_link_libraries(${PROJECT_NAME} "-framework CoreFoundation")
target_link_libraries(${PROJECT_NAME} "-framework Security")
target_link_libraries(${PROJECT_NAME} ${LIBRARIES_SEARCH_PATHS})
set_target_properties(${PROJECT_NAME} PROPERTIES LINK_FLAGS "-W1, -F/Library/Frameworks")
else()
target_link_libraries(${PROJECT_NAME} ${LIBRARIES_SEARCH_PATHS})
endif()