forked from Hopson97/open-builder
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathCMakeLists.txt
111 lines (94 loc) · 2.07 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
cmake_minimum_required(VERSION 3.10)
#Set up project
project(open-builder
VERSION 1.0
)
function (set_flags target)
#Set C++17
target_compile_features(${target}
PUBLIC
cxx_std_17
)
set_target_properties(${target}
PROPERTIES
CXX_EXTENSIONS OFF
)
#Set flags
if(MSVC)
target_compile_options(${target}
PRIVATE
/W4
/WX
)
else()
target_compile_options(${target}
PRIVATE
-Wall
-Wextra
-pedantic
-Wshadow
-Wpointer-arith
# -Werror
)
endif()
endfunction(set_flags)
function (include_dirs target)
target_include_directories(${target}
PRIVATE
${CMAKE_CURRENT_SOURCE_DIR}/deps/
${CMAKE_CURRENT_SOURCE_DIR}/src/common/
)
endfunction(include_dirs)
#
# Link an executables to all the libraries
#
function (link_exe target)
target_link_libraries(${target}
ob-common
ob-client
ob-server
glad
enet
${CMAKE_DL_LIBS}
)
endfunction(link_exe)
#Set module path
set(
CMAKE_MODULE_PATH
"${CMAKE_SOURCE_DIR}/cmake_modules"
${CMAKE_MODULE_PATH}
)
# Find libraries
find_package(Threads)
find_package(SFML REQUIRED audio network graphics window system)
find_package(glm REQUIRED)
# Add local libraries
add_subdirectory(deps)
add_subdirectory(src/common/common)
add_subdirectory(src/client)
add_subdirectory(src/server)
add_executable(${PROJECT_NAME}
src/main.cpp
)
target_include_directories(ob-common
PRIVATE
${CMAKE_CURRENT_SOURCE_DIR}/deps/
)
set_flags(${PROJECT_NAME})
include_dirs(${PROJECT_NAME})
include_dirs(ob-client)
include_dirs(ob-server)
link_exe(${PROJECT_NAME})
function (do_tests)
#Create the unit test executable
add_executable(tests
tests/tests.cpp
)
include_dirs(tests)
target_include_directories(tests
PRIVATE
${CMAKE_CURRENT_SOURCE_DIR}/src/
)
link_exe(tests)
endfunction(do_tests)
do_tests()