summaryrefslogtreecommitdiffstats
path: root/src/server/CMakeLists.txt
blob: 47dda5315974907f287f7dca89456f99bed50d76 (plain) (blame)
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
cmake_minimum_required(VERSION 3.10)

# set the project name
project(dnbd3-server)

# find Jansson package required by the dnbd3-server
find_package(Jansson)
if(NOT JANSSON_FOUND)
    message(FATAL_ERROR "*** No jansson lib found, can't build dnbd3-server!")
endif(NOT JANSSON_FOUND)

# add compile option to enable enhanced POSIX features
add_definitions(-D_GNU_SOURCE)

# export project build type to source code
add_definitions(-DBUILD_TYPE=${CMAKE_BUILD_TYPE})

if(DNBD3_SERVER_AFL)
    # build dnbd3-server with AFL support
    message(STATUS "Building dnbd3-server with AFL support")
    add_definitions(-DDNBD3_SERVER_AFL)
endif(DNBD3_SERVER_AFL)

add_executable(dnbd3-server ${CMAKE_CURRENT_SOURCE_DIR}/altservers.c
                            ${CMAKE_CURRENT_SOURCE_DIR}/fileutil.c
                            ${CMAKE_CURRENT_SOURCE_DIR}/fuse.c
                            ${CMAKE_CURRENT_SOURCE_DIR}/globals.c
                            ${CMAKE_CURRENT_SOURCE_DIR}/helper.c
                            ${CMAKE_CURRENT_SOURCE_DIR}/image.c
                            ${CMAKE_CURRENT_SOURCE_DIR}/ini.c
                            ${CMAKE_CURRENT_SOURCE_DIR}/integrity.c
                            ${CMAKE_CURRENT_SOURCE_DIR}/locks.c
                            ${CMAKE_CURRENT_SOURCE_DIR}/net.c
                            ${CMAKE_CURRENT_SOURCE_DIR}/picohttpparser/picohttpparser.c
                            ${CMAKE_CURRENT_SOURCE_DIR}/reference.c
                            ${CMAKE_CURRENT_SOURCE_DIR}/rpc.c
                            ${CMAKE_CURRENT_SOURCE_DIR}/server.c
                            ${CMAKE_CURRENT_SOURCE_DIR}/threadpool.c
                            ${CMAKE_CURRENT_SOURCE_DIR}/uplink.c
                            ${CMAKE_CURRENT_SOURCE_DIR}/urldecode.c)
target_include_directories(dnbd3-server PRIVATE ${JANSSON_INCLUDE_DIR})
target_link_libraries(dnbd3-server dnbd3-version dnbd3-shared ${CMAKE_THREAD_LIBS_INIT} ${JANSSON_LIBRARIES})

if(DNBD3_SERVER_FUSE)
    # include Fuse headers and link with Fuse library
    target_compile_options(dnbd3-server PRIVATE DNBD3_SERVER_FUSE)
    target_include_directories(dnbd3-server PRIVATE ${FUSE_INCLUDE_DIRS})
    target_link_libraries(dnbd3-server ${FUSE_LIBRARIES})
endif(DNBD3_SERVER_FUSE)

if(UNIX AND NOT APPLE)
    # link dnbd3-server with librt if server is compiled for a Unix system
    target_link_libraries(dnbd3-server rt)
endif(UNIX AND NOT APPLE)

if(DNBD3_SERVER_DEBUG_LOCKS)
    # enable debugging of locks used in the dnbd3-server
    target_compile_options(dnbd3-server DNBD3_SERVER_DEBUG_LOCKS)
endif(DNBD3_SERVER_DEBUG_LOCKS)

if(DNBD3_SERVER_DEBUG_THREADS)
    # enable debugging of threads used in the dnbd3-server
    target_compile_options(dnbd3-server DNBD3_SERVER_DEBUG_THREADS)
endif(DNBD3_SERVER_DEBUG_THREADS)

install(TARGETS dnbd3-server RUNTIME DESTINATION bin)