-
Notifications
You must be signed in to change notification settings - Fork 1
/
CMakeLists.txt
182 lines (156 loc) · 4.56 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
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
#CMAKE BUILD 1.3
#Usage in CLI: "cmake .","make"; executables are in "/build" folder
CMAKE_MINIMUM_REQUIRED(VERSION 2.6.2)
SET(CMAKE_COLOR_MAKEFILE ON)
SET(CMAKE_VERBOSE_MAKEFILE ON)
SET(CMAKE_INCLUDE_CURRENT_DIR TRUE)
PROJECT(rds)
SET(rds_VERSION_MAJOR 0)
SET(rds_VERSION_MINOR 2)
SET(rds_VERSION_BUILD 0)
SET(rds_VERSION
"${rds_VERSION_MAJOR}.${rds_VERSION_MINOR}.${rds_VERSION_BUILD}")
SET(PACKAGE_VERSION
"${rds_VERSION_MAJOR}.${rds_VERSION_MINOR}.${rds_VERSION_BUILD}")
set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${PROJECT_SOURCE_DIR}/cmake/Modules/")
#pkg-config is needed to find and properly link some libraries
FIND_PACKAGE(PkgConfig)
INCLUDE(FindPkgConfig)
#GLIB-2.0
PKG_CHECK_MODULES(GLIB2 glib-2.0 REQUIRED)
if (NOT GLIB2_FOUND)
message(FATAL_ERROR "Library Glib-2.0 not found.")
else (NOT GLIB2_FOUND)
include_directories(${GLIB2_INCLUDE_DIRS})
endif(NOT GLIB2_FOUND)
#JSON-GLIB-1.0
PKG_CHECK_MODULES(JSON json-glib-1.0 REQUIRED)
if(NOT JSON_FOUND)
message(FATAL_ERROR "Library json-glib-devel not found.")
else (NOT JSON_FOUND)
include_directories(${JSON_INCLUDE_DIRS})
endif(NOT JSON_FOUND)
#HAWKEY - 0.5.7
PKG_CHECK_MODULES(LIBDNF libdnf REQUIRED)
if(NOT LIBDNF_FOUND)
message(FATAL_ERROR "Library libdnf not found.")
else(NOT LIBDNF_FOUND)
include_directories(${HAWKEY_INCLUDE_DIRS})
endif(NOT LIBDNF_FOUND)
#LIBREPO
PKG_CHECK_MODULES(LIBREPO librepo REQUIRED)
if(NOT LIBREPO_FOUND)
message(FATAL_ERROR "Library librepo not found.")
else (NOT LIBREPO_FOUND)
include_directories(${LIBREPO_INCLUDE_DIRS})
endif(NOT LIBREPO_FOUND)
#CHECK
find_package(Check REQUIRED)
include_directories(${CHECKLIB_INCLUDE_DIRS})
#HAWKEY VERSION
configure_file(${PROJECT_SOURCE_DIR}/cmake/Config/version_conf.h.in ${PROJECT_SOURCE_DIR}/cmake/Config/version_conf.h)
include_directories(${PROJECT_SOURCE_DIR}/cmake/Config)
if(CMAKE_COMPILER_IS_GNUCC)
set(CMAKE_C_FLAGS ${CMAKE_C_FLAGS} "-O2 -g -Wall -Wextra -pedantic -std=c11 -fmessage-length=0 -L/usr/include/librepo/ -lrepo -lz -lm -ldl -lpthread -lhawkey -lgobject-2.0 -lrpm -lrpmio -lssl -lcrypto -L/usr/lib")
#original flags for boost lib: -I/usr/local/include -L/usr/local/lib
set(CMAKE_EXE_LINKER_FLAGS "-s") ## Strip binary
endif()
file(GLOB SRCS *.c *.h)
#COMMON
set (rds_common_srcs
src/common/util.c
src/common/json_read.c
src/common/json_create.c
src/common/repo_metadata.c
src/common/repo_handler.c
src/common/solving.c
src/common/log_handler.c
src/common/network_util.c
src/common/params.c
src/common/packages.c
src/common/mem_management.c
src/common/cfg_parsing.c
src/common/detect_missing_repos.c
src/common/network_security.c)
set (rds_common_headers
src/common/includes.h
src/common/json_handler.h
src/common/repo_handler.h
src/common/solving.h
src/common/log_handler.h
src/common/network_util.h
src/common/params.h
src/common/packages.h
src/common/mem_management.h
src/common/cfg_parsing.h
src/common/errors.h
src/common/detect_missing_repos.h
src/common/network_security.h)
add_library(lib_rds_common SHARED ${rds_common_srcs} ${rds_common_headers})
target_link_libraries(lib_rds_common
${LIBS}
${GLIB2_LDFLAGS}
${JSON_LDFLAGS}
${HAWKEY_LDFLAGS}
${LIBREPO_LDFLAGS}
${CHECK_LDFLAGS})
#SERVER
set (rds_server_srcs
src/server/server_main.c
src/server/server.c)
set (rds_server_headers
src/server/server.h)
add_library(lib_rds_server STATIC ${rds_server_srcs} ${rds_server_headers})
target_link_libraries(lib_rds_server
lib_rds_common
${LIBS}
${GLIB2_LDFLAGS}
${JSON_LDFLAGS}
${HAWKEY_LDFLAGS}
${LIBREPO_LDFLAGS}
${CHECK_LDFLAGS})
#CLIENT
set (rds_client_srcs
src/client/client_main.c
src/client/client.c)
set (rds_client_headers
src/client/client.h)
add_library(lib_rds_client STATIC ${rds_client_srcs} ${rds_client_headers})
target_link_libraries(lib_rds_client
lib_rds_common
${LIBS}
${GLIB2_LDFLAGS}
${JSON_LDFLAGS}
${HAWKEY_LDFLAGS}
${LIBREPO_LDFLAGS}
${CHECK_LDFLAGS})
PROJECT(rds-server)
add_executable(rds-server
${rds_server_srcs}
${rds_common_srcs})
target_compile_definitions(rds-server PUBLIC __CASE_SERVER)
#add_library(lib_serv SHARED ${SERVSRC})
target_link_libraries(
rds-server
${LIBS}
${GLIB2_LDFLAGS}
${JSON_LDFLAGS}
${HAWKEY_LDFLAGS}
${LIBREPO_LDFLAGS}
${CHECK_LDFLAGS})
PROJECT(rds-client)
add_executable(rds-client
${rds_client_srcs}
${rds_common_srcs})
target_compile_definitions(rds-client PUBLIC __CASE_CLIENT)
target_link_libraries(rds-client
${LIBS}
${GLIB2_LDFLAGS}
${JSON_LDFLAGS}
${HAWKEY_LDFLAGS}
${LIBREPO_LDFLAGS}
${CHECK_LDFLAGS})
file(MAKE_DIRECTORY /tmp/rds/)
#file(MAKE_DIRECTORY /var/cache/rds/packages/)
enable_testing()
add_subdirectory(tests)