-
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathCMakeLists.txt
56 lines (40 loc) · 1.62 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
cmake_minimum_required(VERSION 3.10)
# Project configuration
project(Silver VERSION 0.5.1)
# Set C++ standard
set(CMAKE_CXX_STANDARD 17)
set(CMAKE_CXX_STANDARD_REQUIRED True)
set(CMAKE_CXX_EXTENSIONS False)
# Paths for headers
include_directories(${CMAKE_SOURCE_DIR}/include)
# Precompiled header setup
set(PCH_HEADER ${CMAKE_SOURCE_DIR}/include/Silver.hpp)
set(PCH_OUTPUT_DIR ${CMAKE_BINARY_DIR}/pch)
set(PCH_COMPILED ${PCH_OUTPUT_DIR}/Silver_pch.hpp.gch)
add_custom_command(
OUTPUT ${PCH_COMPILED}
COMMAND ${CMAKE_CXX_COMPILER} -std=c++17 -x c++-header -o ${PCH_COMPILED} ${PCH_HEADER}
DEPENDS ${PCH_HEADER}
)
# ---------- Library: Silver ----------
# Include all .cpp files from the src directory
file(GLOB SILVER_SRC ${CMAKE_SOURCE_DIR}/src/*.cpp)
add_library(Silver STATIC ${SILVER_SRC})
# Precompiled header for Silver library
target_compile_options(Silver PRIVATE -include ${PCH_HEADER})
# ---------- Include miniaudio ----------
# Include miniaudio header (no need to link anything separately)
include_directories(${CMAKE_SOURCE_DIR}/include)
# ---------- Executable: MyGame ----------
# Include all .cpp files from the src directory for the executable
file(GLOB MYGAME_SRC ${CMAKE_SOURCE_DIR}/src/*.cpp)
add_executable(MyGame ${MYGAME_SRC})
# Precompiled header for MyGame executable
target_compile_options(MyGame PRIVATE -include ${PCH_HEADER})
# Link libraries to MyGame
target_link_libraries(MyGame PRIVATE
Silver # Link to your static library
pthread # POSIX threading support
)
# ---------- Build Messages ----------
message(STATUS "Miniaudio included from: ${CMAKE_SOURCE_DIR}/include/miniaudio.h")