-
Notifications
You must be signed in to change notification settings - Fork 2
/
CMakeLists.txt
127 lines (108 loc) · 5.26 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
cmake_minimum_required(VERSION 3.8)
project(ContainerBuilder)
set(CMAKE_CXX_STANDARD 14)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
SET(CMAKE_SKIP_INSTALL_ALL_DEPENDENCY TRUE)
include_directories(BuilderQueue/include Builder/include Client/include Common/include)
set(SOURCE_FILES_QUEUE
BuilderQueue/src/main.cpp
BuilderQueue/src/Connection.cpp
BuilderQueue/src/BuilderQueue.cpp
BuilderQueue/include/Connection.h
BuilderQueue/include/BuilderQueue.h
Common/include/BuilderData.h
Common/src/Logger.cpp
Common/include/Logger.h
BuilderQueue/include/OpenStack.h
Common/src/BuilderData.cpp
Common/include/ClientData.h
BuilderQueue/include/Server.h
BuilderQueue/include/Docker.h)
set(SOURCE_FILES_BUILDER
Builder/src/main.cpp
Common/include/BuilderData.h
Common/src/Logger.cpp
Common/include/Logger.h
)
set(SOURCE_FILES_CLIENT
Client/src/main.cpp
Client/include/WaitingAnimation.h
Common/include/BuilderData.h
Common/src/Logger.cpp
Common/include/Logger.h
Common/src/BuilderData.cpp
Common/include/ClientData.h)
set(SOURCE_FILES_STATUS
Client/src/status.cpp
Client/include/WaitingAnimation.h
Common/include/BuilderData.h
Common/src/Logger.cpp
Common/include/Logger.h
Common/src/BuilderData.cpp
Common/include/ClientData.h)
set(SOURCE_FILES_IMAGES
Client/src/images.cpp
Client/include/WaitingAnimation.h
Common/src/Logger.cpp
Common/include/Logger.h
Common/include/ClientData.h)
# Scripts required for runtime
set(BUILDER_SCRIPTS
Builder/scripts/singularity-builder-backend.sh
Builder/scripts/docker-builder-backend.sh)
set(QUEUE_SCRIPTS
BuilderQueue/scripts/create-builder.sh
BuilderQueue/scripts/destroy-builder.sh
BuilderQueue/scripts/list-images.sh)
# Create executables
add_executable(builder-queue ${SOURCE_FILES_QUEUE})
add_executable(builder-server ${SOURCE_FILES_BUILDER})
add_executable(container-builder ${SOURCE_FILES_CLIENT})
add_executable(cb-status ${SOURCE_FILES_STATUS})
add_executable(cb-images ${SOURCE_FILES_IMAGES})
# Ignore system boost and use module system boost
set(Boost_NO_BOOST_CMAKE TRUE)
#set(Boost_USE_STATIC_LIBS OFF)
# Add compile time hardening
set(HARDENING_FLAGS "-Wall -Wextra -fstack-protector-strong -D_FORTIFY_SOURCE=2 -fPIE -fpie -fno-omit-frame-pointer \
-fsanitize=address,undefined -fno-sanitize=vptr")
if ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "GNU")
set(HARDENING_FLAGS "${HADENING_FLAGS} -Wl,-z,noexecstack,-z,now,-z,relro,-z,nodlopen")
endif()
set_target_properties(builder-queue PROPERTIES COMPILE_FLAGS "${COMPILE_FLAGS} ${HARDENING_FLAGS}")
set_target_properties(builder-queue PROPERTIES LINK_FLAGS "${LINK_FLAGS} ${HARDENING_FLAGS}")
set_target_properties(builder-server PROPERTIES COMPILE_FLAGS "${COMPILE_FLAGS} ${HARDENING_FLAGS}")
set_target_properties(builder-server PROPERTIES LINK_FLAGS "${LINK_FLAGS} ${HARDENING_FLAGS}")
set_target_properties(container-builder PROPERTIES COMPILE_FLAGS "${COMPILE_FLAGS} ${HARDENING_FLAGS}")
set_target_properties(container-builder PROPERTIES LINK_FLAGS "${LINK_FLAGS} ${HARDENING_FLAGS}")
set_target_properties(cb-status PROPERTIES COMPILE_FLAGS "${COMPILE_FLAGS} ${HARDENING_FLAGS}")
set_target_properties(cb-status PROPERTIES LINK_FLAGS "${LINK_FLAGS} ${HARDENING_FLAGS}")
set_target_properties(cb-images PROPERTIES COMPILE_FLAGS "${COMPILE_FLAGS} ${HARDENING_FLAGS}")
set_target_properties(cb-images PROPERTIES LINK_FLAGS "${LINK_FLAGS} ${HARDENING_FLAGS}")
set(THREADS_PREFER_PTHREAD_FLAG ON)
find_package(Threads REQUIRED)
target_link_libraries(builder-queue ${CMAKE_THREAD_LIBS_INIT})
target_link_libraries(builder-server ${CMAKE_THREAD_LIBS_INIT})
target_link_libraries(container-builder ${CMAKE_THREAD_LIBS_INIT})
target_link_libraries(cb-status ${CMAKE_THREAD_LIBS_INIT})
target_link_libraries(cb-images ${CMAKE_THREAD_LIBS_INIT})
find_package(Boost 1.66.0 COMPONENTS system filesystem serialization regex thread program_options REQUIRED)
include_directories(${Boost_INCLUDE_DIRS})
target_link_libraries(builder-queue ${Boost_LIBRARIES})
target_link_libraries(builder-server ${Boost_LIBRARIES})
target_link_libraries(container-builder ${Boost_LIBRARIES})
target_link_libraries(cb-status ${Boost_LIBRARIES})
target_link_libraries(cb-images ${Boost_LIBRARIES})
# Install executables
install(TARGETS builder-queue COMPONENT builder-queue DESTINATION bin OPTIONAL)
install(TARGETS builder-server COMPONENT builder-server DESTINATION bin OPTIONAL)
install(TARGETS container-builder COMPONENT client DESTINATION bin OPTIONAL)
install(TARGETS cb-status COMPONENT client DESTINATION bin OPTIONAL)
install(TARGETS cb-images COMPONENT client DESTINATION bin OPTIONAL)
# Install scripts
install(FILES ${BUILDER_SCRIPTS}
PERMISSIONS OWNER_READ OWNER_WRITE OWNER_EXECUTE GROUP_READ GROUP_WRITE GROUP_EXECUTE WORLD_READ
WORLD_EXECUTE DESTINATION "${CMAKE_INSTALL_PREFIX}/bin" COMPONENT builder-server OPTIONAL)
install(FILES ${QUEUE_SCRIPTS}
PERMISSIONS OWNER_READ OWNER_WRITE OWNER_EXECUTE GROUP_READ GROUP_WRITE GROUP_EXECUTE WORLD_READ
WORLD_EXECUTE DESTINATION "${CMAKE_INSTALL_PREFIX}/bin" COMPONENT builder-queue OPTIONAL)