-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathCMakeLists.txt
More file actions
90 lines (72 loc) · 2.46 KB
/
Copy pathCMakeLists.txt
File metadata and controls
90 lines (72 loc) · 2.46 KB
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
cmake_minimum_required(VERSION 3.16)
project(Coldbite CXX)
project(Masterball VERSION 1.0)
set(CMAKE_CXX_STANDARD 17)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
set(CMAKE_CXX_EXTENSIONS OFF)
# Force MinGW g++ compiler
set(CMAKE_CXX_COMPILER g++)
set(CMAKE_C_COMPILER gcc)
# Engine Core Library
file(GLOB_RECURSE ENGINE_SOURCES CONFIGURE_DEPENDS
"Engine/*.cpp"
"Engine/*.h"
#"Engine/*/.gitkeep"
)
file(GLOB_RECURSE GAME_SOURCES CONFIGURE_DEPENDS
"Game/*.cpp"
"Game/*.h"
"Game/Game.conf"
# "Game/*/.gitkeep"
)
# Create Engine library
add_library(Engine STATIC ${ENGINE_SOURCES})
target_include_directories(Engine PUBLIC Engine/Core)
# Depencies
set(STB_DIR "${CMAKE_SOURCE_DIR}/Depencies/stb")
target_include_directories(Engine PUBLIC ${STB_DIR})
set(FREETYPE_DIR "${CMAKE_SOURCE_DIR}/Depencies/FreeType")
target_include_directories(Engine PUBLIC ${FREETYPE_DIR}/include)
find_library(FREETYPE_LIBRARY
NAMES freetype
HINTS ${FREETYPE_DIR}/lib
)
if(FREETYPE_LIBRARY)
target_link_libraries(Engine PRIVATE ${FREETYPE_LIBRARY})
else()
message(FATAL_ERROR "[Error] Can't find FreeType in /Depencies/")
endif()
# Game executable
add_executable(Masterball ${GAME_SOURCES})
target_link_libraries(Masterball PRIVATE Engine)
# Always copy Game.conf to build directory
add_custom_target(copy_config ALL
COMMAND ${CMAKE_COMMAND} -E copy
"${CMAKE_SOURCE_DIR}/Game/Game.conf"
"${CMAKE_CURRENT_BINARY_DIR}/Game.conf"
DEPENDS "${CMAKE_SOURCE_DIR}/Game/Game.conf"
COMMENT "Copying Game.conf to build directory"
)
# Make Masterball depend on config copy
add_dependencies(Masterball copy_config)
# Enable threading support
find_package(Threads REQUIRED)
target_link_libraries(Engine PRIVATE Threads::Threads)
# OpenGL support for NativeWindow
find_package(OpenGL REQUIRED)
target_link_libraries(Engine PRIVATE ${OPENGL_LIBRARIES})
# Windows-specific libraries for window management
if(WIN32)
target_link_libraries(Engine PRIVATE gdi32 user32 kernel32)
endif()
# Compiler specific settings
target_compile_options(Engine PRIVATE -Wall -Wextra -pedantic)
target_compile_options(Masterball PRIVATE -Wall -Wextra -pedantic)
# Debug/Release settings
if(CMAKE_BUILD_TYPE STREQUAL "Debug")
target_compile_definitions(Engine PRIVATE DEBUG)
target_compile_definitions(Masterball PRIVATE DEBUG)
endif()
message(STATUS "Configured Event-based Multithreaded Engine")
message(STATUS "Build type: ${CMAKE_BUILD_TYPE}")
message(STATUS "C++ Standard: ${CMAKE_CXX_STANDARD}")