-
Notifications
You must be signed in to change notification settings - Fork 8
/
Copy pathCMakeLists.txt
92 lines (74 loc) · 2 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
87
88
89
90
91
92
cmake_minimum_required(VERSION 3.0.0)
set(CMAKE_TRY_COMPILE_TARGET_TYPE STATIC_LIBRARY)
project(microlb C CXX)
set(CMAKE_CXX_STANDARD 17)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
set(CMAKE_CXX_EXTENSIONS OFF)
if (NOT ARCH)
set(ARCH ${CMAKE_SYSTEM_PROCESSOR})
endif()
add_definitions(-DARCH_${ARCH})
add_definitions(-DARCH="${ARCH}")
set(TRIPLE "${ARCH}-pc-linux-elf")
set(CMAKE_CXX_COMPILER_TARGET ${TRIPLE})
set(CMAKE_C_COMPILER_TARGET ${TRIPLE})
option(LIVEUPDATE "Enable liveupdate" ON)
option(TLS "Enable secure connections" ON)
if (EXISTS ${CMAKE_CURRENT_BINARY_DIR}/conanbuildinfo.cmake)
include(${CMAKE_CURRENT_BINARY_DIR}/conanbuildinfo.cmake)
conan_basic_setup()
else()
if (NOT CMAKE_BUILD_TYPE)
set(CMAKE_BUILD_TYPE Release)
endif()
if (CONAN_PROFILE)
set(CONANPROFILE PROFILE ${CONAN_PROFILE})
endif()
if(NOT EXISTS "${CMAKE_BINARY_DIR}/conan.cmake")
message(STATUS "Downloading conan.cmake from https://github.com/conan-io/cmake-conan")
file(DOWNLOAD "https://github.com/conan-io/cmake-conan/raw/v0.13/conan.cmake"
"${CMAKE_BINARY_DIR}/conan.cmake")
endif()
include(${CMAKE_BINARY_DIR}/conan.cmake)
conan_cmake_run(
CONANFILE conanfile.py
BASIC_SETUP
${CONANPROFILE}
)
endif()
include_directories(${CMAKE_CURRENT_SOURCE_DIR}/include)
set(LIBRARY_SRCS
src/autoconf.cpp
src/balancer.cpp
src/defaults.cpp
src/node.cpp
src/nodes.cpp
src/session.cpp
)
if (TLS)
list(APPEND LIBRARY_SRCS
src/openssl.cpp
)
endif()
if (LIVEUPDATE)
list(APPEND LIBRARY_SRCS
src/serialize.cpp
)
endif()
set(HDRS
include/microLB
include/balancer.hpp
include/node.hpp
include/nodes.hpp
include/session.hpp
)
# microLB static library
add_library(microlb STATIC ${LIBRARY_SRCS})
if (LIVEUPDATE)
set_target_properties(microlb PROPERTIES COMPILE_DEFINITIONS "LIVEUPDATE")
endif()
set_target_properties(microlb PROPERTIES PUBLIC_HEADER "${HDRS}")
install(TARGETS microlb
ARCHIVE DESTINATION lib
PUBLIC_HEADER DESTINATION include
)