-
Notifications
You must be signed in to change notification settings - Fork 0
/
ebcpp.cmake
88 lines (69 loc) · 2.54 KB
/
ebcpp.cmake
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
87
88
# Require C++17 Standard
set(CMAKE_CXX_STANDARD 17)
set(CMAKE_CXX_STANDARD_REQUIRED True)
message("EBCPP source dir: ${CMAKE_CURRENT_LIST_DIR}/src")
include_directories(${CMAKE_CURRENT_LIST_DIR}/src)
if(WIN32)
# Add defines for windows
set(WINDOWS_VERSION 0x0A00)
add_definitions(-DWINVER=${WINDOWS_VERSION})
add_definitions(-D_WIN32_WINNT=${WINDOWS_VERSION})
add_definitions(-DNTDDI_VERSION=0x06010000)
endif()
if(EBCPP_STATIC)
set(EBCPP_LIBS ${EBCPP_LIBS} -static-libstdc++ -static-libgcc -Wl,-Bstatic -lstdc++ -lpthread -Wl,-Bdynamic)
endif()
##########################
# OpenSSL
##########################
if(EBCPP_USE_SSL)
message("EBCPP_USE_SSL => Try to find openssl!")
# Set OpenSSL directory (for windows)
set(OPENSSL_ROOT_DIR ${CMAKE_CURRENT_LIST_DIR}/dep/openssl)
message("Open ssl root directory: ${OPENSSL_ROOT_DIR}")
if(EBCPP_USE_SSL_STATIC)
message("EBCPP_USE_SSL_STATIC => ON")
set(OPENSSL_USE_STATIC_LIBS TRUE)
else()
message("EBCPP_USE_SSL_STATIC => OFF")
endif()
find_package(OpenSSL)
if(OPENSSL_FOUND)
message("Used OpenSSL_VERSION: ${OPENSSL_VERSION}")
message("Used OpenSSL_INCLUDE_DIR: ${OPENSSL_INCLUDE_DIR}")
message("Used OpenSSL_LIBRARIES: ${OPENSSL_LIBRARIES}")
if(WIN32)
set(EBCPP_LIBS ${EBCPP_LIBS} OpenSSL::Crypto OpenSSL::SSL wsock32 ws2_32)
else()
set(EBCPP_LIBS ${EBCPP_LIBS} OpenSSL::Crypto OpenSSL::SSL)
endif()
else()
message(FATAL_ERROR "Can not find OpenSSL binaries. Have you compiled openssl for EBCpp?")
endif()
else()
message("EBCPP_USE_SSL => Off")
endif()
##########################
# SQLITE
##########################
if(EBCPP_USE_SQLITE)
message("Try to find SQLite3")
find_package (SQLite3)
if(SQLite3_FOUND)
include_directories(${SQLite3_INCLUDE_DIRS})
set(EBCPP_LIBS ${EBCPP_LIBS} ${SQLite3_LIBRARIES})
else()
if(EXISTS "${CMAKE_CURRENT_LIST_DIR}/external/sqlite/sqlite3.c")
add_library(SQLITE
${CMAKE_CURRENT_LIST_DIR}/external/sqlite/sqlite3.c
)
set_target_properties(SQLITE PROPERTIES LINKER_LANGUAGE CXX)
include_directories(${CMAKE_CURRENT_LIST_DIR}/external/sqlite)
set(EBCPP_LIBS ${EBCPP_LIBS} SQLITE)
else()
message(FATAL_ERROR "Can not find SQLite. Did you install SQLite? See external/setupSQLite.bat for windows!")
endif()
endif()
else()
message("EBCPP_USE_SQLITE => Off")
endif()