-
Notifications
You must be signed in to change notification settings - Fork 0
/
CMakeLists.txt
126 lines (101 loc) · 3.75 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
cmake_minimum_required(VERSION 3.20)
set(CMAKE_C_COMPILER "/usr/bin/clang") # <-------- set compiler path or remove this line to detect automatically
project(ExchatgeDesktopClient C)
set(CMAKE_C_STANDARD 11)
add_compile_options("-Wall")
add_compile_options("-Wextra")
add_compile_options("-Wpedantic")
add_compile_options("-Wno-nullability-completeness")
add_compile_options("-Wno-nullability-extension")
add_compile_options("-Wno-unknown-pragmas")
add_compile_options("-fms-extensions")
add_compile_options("-Wno-gnu-folding-constant")
add_compile_options("-Wno-microsoft-anon-tag")
add_compile_options("-Wno-gnu-empty-initializer")
add_compile_options("-Wno-language-extension-token")
add_compile_options("-Wno-microsoft-fixed-enum")
add_compile_options("-Wno-empty-body")
add_compile_options("-Wno-c2x-extensions")
add_compile_options("-Wno-gnu-empty-struct")
add_compile_options("-Wno-gnu-pointer-arith")
add_compile_options("-std=gnu11")
add_compile_options("-Ofast") # -O3
set(DEBUG false)
if(NOT DEBUG)
add_link_options("-s")
else()
add_link_options("-rdynamic") # for use with backtrace_symbols()
endif()
file(GLOB sources CONFIGURE_DEPENDS "src/*.c" "src/*.h")
add_executable(${PROJECT_NAME} ${sources})
# SDL2_Net included
include_directories(libs/sdl/include)
file(GLOB sdl_binaries CONFIGURE_DEPENDS "${CMAKE_SOURCE_DIR}/libs/sdl/bin/*")
target_link_libraries(${PROJECT_NAME} ${sdl_binaries})
include_directories(libs/sodium/include)
file(GLOB sodium_binaries CONFIGURE_DEPENDS "${CMAKE_SOURCE_DIR}/libs/sodium/bin/*")
target_link_libraries(${PROJECT_NAME} ${sodium_binaries})
set(LIB_RENDER_NAME "render")
add_subdirectory(src/render)
target_link_libraries(${PROJECT_NAME} ${LIB_RENDER_NAME})
set(LIB_COLLECTIONS_NAME "collections")
add_subdirectory(src/collections)
target_link_libraries(${PROJECT_NAME} ${LIB_COLLECTIONS_NAME})
set(LIB_DATABASE_NAME "database")
add_subdirectory(src/database)
target_link_libraries(${PROJECT_NAME} ${LIB_DATABASE_NAME})
set(LIB_UTILS_NAME "utils")
add_subdirectory(src/utils)
target_link_libraries(${PROJECT_NAME} ${LIB_UTILS_NAME})
file(COPY options.txt DESTINATION ${CMAKE_BINARY_DIR})
set(FONT_FILE RobotoMono-Regular_GoogleFonts_ApacheLicense2_0.ttf) # Google Fonts, Apache License 2.0
file(COPY ${FONT_FILE} DESTINATION ${CMAKE_BINARY_DIR})
file(RENAME ${CMAKE_BINARY_DIR}/${FONT_FILE} ${CMAKE_BINARY_DIR}/font.ttf)
set(ICON_FILE exchatgeIcon.bmp)
file(COPY ${ICON_FILE} DESTINATION ${CMAKE_BINARY_DIR})
file(RENAME ${CMAKE_BINARY_DIR}/${ICON_FILE} ${CMAKE_BINARY_DIR}/icon.bmp)
if(NOT CMAKE_SIZEOF_VOID_P EQUAL 8)
message(SEND_ERROR "Target is not 64 bits")
endif()
if(NOT CMAKE_C_BYTE_ORDER STREQUAL LITTLE_ENDIAN)
message(SEND_ERROR "Target is not little endian")
endif()
if(NOT LINUX)
message(SEND_ERROR "Target is not linux")
endif()
if(NOT CMAKE_C_COMPILER_ID STREQUAL "Clang" AND NOT CMAKE_C_COMPILER_ID STREQUAL "GNU")
message(SEND_ERROR "GNU extensions are used")
endif()
#
# libs
# nuklear
# include
# <.h>
# sdl # sdl2 and sdl2-net
# bin
# <.so|.a>
# include
# <.h>
# sodium
# bin
# <.so|.a>
# include
# <.h>
# sqlite3
# bin
# <.so|.a>
# include
# <.h>
#
set(ENABLE_TESTS true)
if(ENABLE_TESTS)
file(GLOB test_sources CONFIGURE_DEPENDS "test/*" "src/defs.*" "src/crypto.*" "src/net.*")
set(LIB_TESTS "tests")
add_executable(${LIB_TESTS} ${test_sources})
target_link_libraries(${LIB_TESTS} ${sdl_binaries} ${sodium_binaries} ${LIB_COLLECTIONS_NAME} ${LIB_UTILS_NAME})
enable_testing()
add_compile_definitions(TESTING)
foreach(INDEX RANGE 16)
add_test(NAME test${INDEX} COMMAND $<TARGET_FILE:${LIB_TESTS}> ${INDEX})
endforeach()
endif()