-
Notifications
You must be signed in to change notification settings - Fork 6
/
Copy pathCMakeLists.txt
167 lines (137 loc) · 5.31 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
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
cmake_minimum_required(VERSION 3.13)
project(cspot VERSION 2.0.0)
set(CMAKE_EXPORT_COMPILE_COMMANDS ON)
set(CMAKE_POSITION_INDEPENDENT_CODE ON)
set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/lib)
set(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/lib)
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/bin)
set(BUILD_SHARED_LIBS OFF)
option(ENABLE_PYCSPOT "Enable cspot python bindings" OFF)
option(ENABLE_FEATURE_REPAIR "Enable repair" OFF)
if (CMAKE_CXX_COMPILER_ID MATCHES "GNU")
message(STATUS "Emitting static binaries")
set(CMAKE_EXE_LINKER_FLAGS "-static -static-libgcc -static-libstdc++ -Wl,-Bstatic")
set(CMAKE_C_FLAGS "-ffunction-sections -fdata-sections")
set(CMAKE_CXX_FLAGS "-std=gnu++17 -ffunction-sections -fdata-sections -Wl,-Bstatic")
# if (CMAKE_BUILD_TYPE MATCHES "Release")
# set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -flto")
# set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -flto")
# set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -flto")
# endif()
endif ()
add_subdirectory(deps)
add_subdirectory(src)
add_library(woof
src/log.cpp
src/include/log.h
src/woofc.cpp
include/woofc.h
src/woofc-access.cpp
src/include/woofc-access.h
src/event.cpp
src/include/event.h
src/host.c
src/include/host.h
src/lsema.c
src/include/lsema.h
src/debug.cpp
src/include/debug.h
src/include/global.h
src/global.cpp
src/include/woofc-priv.h
src/net.cpp
src/woofc-host.cpp
)
add_library(woof-mqtt
include/woofc-mqtt.h
src/woofc-mqtt.cpp
)
target_include_directories(woof PRIVATE
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/src/include>
)
target_include_directories(woof PUBLIC
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/include>
$<INSTALL_INTERFACE:include>
)
target_include_directories(woof-mqtt PRIVATE
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/src/include>
)
target_include_directories(woof-mqtt PUBLIC
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/include>
$<INSTALL_INTERFACE:include>
)
find_package(Threads REQUIRED)
target_link_libraries(woof PUBLIC mio euca_utils m Threads::Threads uriparser2 fmt::fmt woof_zmq_net)
target_compile_features(woof PUBLIC cxx_std_17)
target_link_libraries(woof-mqtt PUBLIC euca_utils m uriparser2)
target_compile_features(woof-mqtt PUBLIC cxx_std_17)
if (${CMAKE_BUILD_TYPE} MATCHES Debug)
target_compile_definitions(woof PUBLIC DEBUG=1)
endif ()
if (ENABLE_FEATURE_REPAIR)
target_compile_definitions(woof PUBLIC REPAIR=1)
target_sources(woof PRIVATE src/repair.c)
endif ()
if (CMAKE_CXX_COMPILER_ID MATCHES "GNU")
target_compile_options(woof PUBLIC -Wall -Wextra)
endif ()
add_executable(woofc-namespace-platform src/woofc-namespace-platform.cpp)
target_link_libraries(woofc-namespace-platform woof)
target_include_directories(woofc-namespace-platform PRIVATE src/include)
add_executable(woofc-container src/woofc-container.cpp)
target_link_libraries(woofc-container PRIVATE woof)
target_include_directories(woofc-container PRIVATE src/include)
add_executable(woofc-forker-helper src/woofc-forker-helper.cpp)
target_link_libraries(woofc-forker-helper PRIVATE woof)
target_include_directories(woofc-forker-helper PRIVATE src/include)
add_library(woofc-shepherd src/woofc-shepherd.cpp)
target_link_libraries(woofc-shepherd PUBLIC woof)
target_include_directories(woofc-shepherd PRIVATE src/include)
#add_executable(woofc-mqtt-gateway src/woofc-mqtt-gateway.cpp)
add_executable(woofc-mqtt-gateway src/woofc-mqtt-gateway.c)
target_link_libraries(woofc-mqtt-gateway woof woof-mqtt)
target_include_directories(woofc-mqtt-gateway PRIVATE src/include)
function (add_handler name)
file(WRITE ${CMAKE_CURRENT_BINARY_DIR}/${name}_handler_fwd.cpp
"#include \"woofc.h\"\n \
\
extern \"C\" { \
int ${name}(WOOF* wf, unsigned long seq_no, void* ptr); \
\
int handler(WOOF* wf, unsigned long seq_no, void* ptr) { \
return ${name}(wf, seq_no, ptr); \
} \
} \
")
add_executable(${name} ${ARGV})
target_link_libraries(${name} PRIVATE woofc-shepherd)
target_sources(${name} PRIVATE "${CMAKE_CURRENT_BINARY_DIR}/${name}_handler_fwd.cpp")
endfunction()
add_subdirectory(apps)
set(CMAKE_EXPORT_PACKAGE_REGISTRY ON)
install(
TARGETS woof mio euca_utils uriparser2 fmt woof_zmq_net
EXPORT woof
DESTINATION lib
)
install(
TARGETS woofc-shepherd woofc-container woofc-namespace-platform woofc-mqtt-gateway
EXPORT woof
DESTINATION bin
)
#install(TARGETS czmq-static EXPORT woof DESTINATION lib)
install(EXPORT woof DESTINATION lib/cmake/woof)
#install(EXPORT czmq-targets DESTINATION lib)
#install(EXPORT ZeroMQ-targets DESTINATION lib)
install(FILES include/woofc.h DESTINATION include)
install(FILES woof-config.cmake DESTINATION lib/cmake/woof)
set(CPACK_GENERATOR "DEB;RPM;TGZ;STGZ")
set(CPACK_PACKAGE_VENDOR "Mayhem Lab")
set(CPACK_PACKAGE_DESCRIPTION_SUMMARY "Cspot")
set(CPACK_DEBIAN_PACKAGE_MAINTAINER "Fatih")
set(CPACK_PACKAGE_VERSION_MAJOR ${PROJECT_VERSION_MAJOR})
set(CPACK_PACKAGE_VERSION_MINOR ${PROJECT_VERSION_MINOR})
set(CPACK_PACKAGE_VERSION_PATCH ${PROJECT_VERSION_PATCH})
set(CPACK_RESOURCE_FILE_LICENSE "${CMAKE_CURRENT_SOURCE_DIR}/LICENSE")
set(CPACK_RESOURCE_FILE_README "${CMAKE_CURRENT_SOURCE_DIR}/Readme.adoc")
include(CPack)