-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathCMakeLists.txt
112 lines (103 loc) · 2.48 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
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
CMAKE_MINIMUM_REQUIRED(VERSION 3.2)
project(lizard)
set(VERSION 0.1)
include (${CUSTOM_CMAKE_MODULES}/common.mk)
option(BUILD_DEBUG "debug or release" OFF)
option(BUILD_DEMO "build demo and test programs" OFF)
findPackage(mutils REQUIRED
HINTS ${mutilsPrefix}
HEADERS uri.h rlog.h
INC_PATH_SUFFIX include/misc include/log
STATIC_LIBS misc
SHARED_LIBS rlog
)
if (SSL_LINK STREQUAL "shared")
set(findPackageArgs "VERSION_SHARED_LIBS;${SSL_LIB};VERSIONS;1.3.17")
else()
set(findPackageArgs "STATIC_LIBS;${SSL_LIB}")
endif()
if (SSL_LIB STREQUAL "mbedtls")
findPackage(ssl REQUIRED
HINTS ${mbedtlsPrefix}
HEADERS ssl.h
INC_PATH_SUFFIX include/polarssl
${findPackageArgs}
)
set(lizardCXXFLAGS "-DHAS_SSL")
endif()
set(CMAKE_CXX_STANDARD 11)
if (BUILD_DEBUG)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -g -O0 -DLIZARD_DEBUG -DROKID_LOG_ENABLED=1")
else()
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Os")
endif()
if (CROSS_COMPILE_CXXFLAGS)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${CROSS_COMPILE_CXXFLAGS}")
endif()
file(GLOB_RECURSE lizard_SOURCES
include/*.h
src/*.cpp
)
add_library(lizard SHARED
${lizard_SOURCES}
)
target_compile_options(lizard PRIVATE ${lizardCXXFLAGS})
target_include_directories(lizard PRIVATE
include
${mutils_INCLUDE_DIRS}
${ssl_INCLUDE_DIRS}
)
target_link_libraries(lizard
${mutils_LIBRARIES}
${ssl_LIBRARIES}
)
add_library(lizard_static STATIC
${lizard_SOURCES}
)
set_target_properties(lizard_static PROPERTIES
OUTPUT_NAME lizard
POSITION_INDEPENDENT_CODE ON
)
target_compile_options(lizard_static PRIVATE ${lizardCXXFLAGS})
target_include_directories(lizard_static PRIVATE
include
${mutils_INCLUDE_DIRS}
${ssl_INCLUDE_DIRS}
)
# install include files.
file(GLOB lizard_HEADERS
include/*.h
)
install(FILES ${lizard_HEADERS}
DESTINATION include/lizard
PERMISSIONS OWNER_READ OWNER_WRITE GROUP_READ WORLD_READ
)
install(TARGETS lizard lizard_static
LIBRARY DESTINATION lib
ARCHIVE DESTINATION lib
)
if (BUILD_DEMO)
add_executable(simple-sock demo/examples/simple-sock.cpp)
target_include_directories(simple-sock PRIVATE
include
${mutils_INCLUDE_DIRS}
)
target_link_libraries(simple-sock
${mutils_LIBRARIES}
lizard
)
add_executable(websocket demo/examples/websocket.cpp)
target_include_directories(websocket PRIVATE
include
${mutils_INCLUDE_DIRS}
${ssl_INCLUDE_DIRS}
)
target_link_libraries(websocket
${mutils_LIBRARIES}
${ssl_LIBRARIES}
lizard
)
install(TARGETS simple-sock websocket
RUNTIME DESTINATION bin
)
endif(BUILD_DEMO)