]> git.lizzy.rs Git - dragonnet-example.git/blob - CMakeLists.txt
Merge branch 'master' of github.com:dragonblocks/dragonnet-example
[dragonnet-example.git] / CMakeLists.txt
1 cmake_minimum_required(VERSION 3.12)
2
3 project(DragonnetExample)
4
5 set(CMAKE_BUILD_TYPE Debug)
6
7 link_libraries(
8         pthread
9 )
10
11 set(DEPS_DIR "${CMAKE_SOURCE_DIR}/deps/")
12
13 add_compile_definitions(DRAGONTYPE_ENDIAN_HEADER="${DEPS_DIR}/endian.h/endian.h")
14
15 include_directories(SYSTEM
16         ${DEPS_DIR}
17 )
18
19 add_compile_options(-Wall -Wextra -Werror -fmax-errors=4)
20
21 set(SOURCES_COMMON
22         "${DEPS_DIR}/dragontype/implementation.c"
23         "${DEPS_DIR}/dragonport/asprintf.c"
24         "${DEPS_DIR}/dragonnet/addr.c"
25         "${DEPS_DIR}/dragonnet/listen.c"
26         "${DEPS_DIR}/dragonnet/peer.c"
27         "${DEPS_DIR}/dragonnet/recv_thread.c"
28 )
29
30 add_executable(DragonnetGenMessages
31         ${SOURCES_COMMON}
32         "${DEPS_DIR}/dragonnet/gen_messages.c"
33 )
34
35 add_custom_command(
36         OUTPUT "${CMAKE_SOURCE_DIR}/messages.h"
37         COMMAND "${CMAKE_BINARY_DIR}/DragonnetGenMessages"
38         MAIN_DEPENDENCY "${CMAKE_SOURCE_DIR}/messages.dnet"
39         DEPENDS DragonnetGenMessages
40         WORKING_DIRECTORY "${CMAKE_SOURCE_DIR}"
41 )
42
43 add_custom_target(ExampleMessages
44         DEPENDS "${CMAKE_SOURCE_DIR}/messages.h"
45 )
46
47 add_executable(ExampleClient
48         ${SOURCES_COMMON}
49         client.c
50 )
51
52 add_dependencies(ExampleClient ExampleMessages)
53
54 add_executable(ExampleServer
55         ${SOURCES_COMMON}
56         server.c
57 )
58
59 add_dependencies(ExampleServer ExampleMessages)