-
Notifications
You must be signed in to change notification settings - Fork 0
/
CMakeLists.txt
69 lines (66 loc) · 2.52 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
cmake_minimum_required(VERSION 3.11)
project(rsgame)
option(BUILD_LOCALCLIENT "build localclient" ON)
option(BUILD_NETCLIENT "build netclient" ON)
option(BUILD_SERVER "build server" ON)
if (BUILD_LOCALCLIENT OR BUILD_NETCLIENT)
find_package(SDL2 REQUIRED)
find_package(OpenGL REQUIRED)
find_package(ZLIB REQUIRED)
find_package(PNG REQUIRED)
find_package(epoxy)
if(NOT(epoxy_FOUND))
find_package(PkgConfig REQUIRED)
pkg_check_modules(EPOXY REQUIRED IMPORTED_TARGET epoxy)
add_library(epoxy::epoxy INTERFACE IMPORTED)
target_link_libraries(epoxy::epoxy INTERFACE PkgConfig::EPOXY)
endif()
endif()
add_subdirectory(extlib/glm)
add_library(rsgame_common INTERFACE IMPORTED)
if(MSVC)
set_target_properties(rsgame_common PROPERTIES
INTERFACE_COMPILE_OPTIONS "/Zc:__cplusplus;/D_CRT_SECURE_NO_WARNINGS;/W3;/wd4267;/wd4244")
else()
set_target_properties(rsgame_common PROPERTIES
INTERFACE_COMPILE_OPTIONS "-Wall;-Wextra;-Wno-parentheses")
endif()
set_target_properties(rsgame_common PROPERTIES
INTERFACE_COMPILE_FEATURES cxx_std_17)
if(WIN32)
option(RSGAME_BUNDLE "look for assets within the exe file" OFF)
set_target_properties(rsgame_common PROPERTIES
INTERFACE_COMPILE_DEFINITIONS "WINVER=0x0600;_WIN32_WINNT=0x0600;$<$<BOOL:${RSGAME_BUNDLE}>:RSGAME_BUNDLE>")
endif()
if(NOT(CMAKE_VERSION VERSION_LESS 3.16.0))
set_target_properties(rsgame_common PROPERTIES
INTERFACE_PRECOMPILE_HEADERS "${CMAKE_CURRENT_SOURCE_DIR}/src/common.hh")
endif()
set(SOURCES_COMMON
src/common.hh
src/level.cc src/level.hh
src/tile.cc src/tile.hh)
set(SOURCES_CLIENT
src/main.cc
src/render.cc src/render.hh
src/util.cc src/util.hh
src/glutil.cc src/glutil.hh
src/raycast.cc src/raycast.hh
$<$<BOOL:${WIN32}>:src/resource.rc>)
set(SOURCES_SERVER
src/maind.cc
src/net.hh)
if(BUILD_LOCALCLIENT)
add_executable(rsgame ${SOURCES_COMMON} ${SOURCES_CLIENT})
target_link_libraries(rsgame PRIVATE rsgame_common SDL2::SDL2 SDL2::SDL2main OpenGL::GL epoxy::epoxy glm::glm PNG::PNG ZLIB::ZLIB)
endif()
if(BUILD_NETCLIENT)
add_executable(rsgamec ${SOURCES_COMMON} ${SOURCES_CLIENT} src/net.hh)
target_link_libraries(rsgamec PRIVATE rsgame_common SDL2::SDL2 SDL2::SDL2main OpenGL::GL epoxy::epoxy glm::glm PNG::PNG ZLIB::ZLIB $<$<BOOL:${WIN32}>:ws2_32>)
target_compile_definitions(rsgamec PRIVATE RSGAME_NETCLIENT)
endif()
if(BUILD_SERVER)
add_executable(rsgamed ${SOURCES_COMMON} ${SOURCES_SERVER})
target_link_libraries(rsgamed PRIVATE rsgame_common glm::glm ZLIB::ZLIB $<$<BOOL:${WIN32}>:ws2_32>)
target_compile_definitions(rsgamed PRIVATE RSGAME_SERVER)
endif()