-
Notifications
You must be signed in to change notification settings - Fork 0
/
CMakeLists.txt
72 lines (57 loc) · 2.38 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
# Set the minimum required CMake version
cmake_minimum_required(VERSION 3.10)
# Set the project name
project(SandroRun)
# Set the C++ standard
set(CMAKE_CXX_STANDARD 17)
# Set the path to header files
include_directories(headers)
# Find required packages
find_package(glfw3 REQUIRED)
find_package(Vulkan REQUIRED)
find_package(glm REQUIRED)
# Create a list of header files
file(GLOB HEADER_FILES headers/*.hpp headers/*.h)
# Create a list of source files
file(GLOB SOURCE_FILES src/*.cpp src/*.c)
# Add the main source file in the root folder
list(APPEND SOURCE_FILES main.cpp)
# Create the executable
set(TARGET_BINARY_NAME sandro_run)
add_executable(${TARGET_BINARY_NAME} ${HEADER_FILES}
Starter.hpp BuildModels.hpp HandleCommands.hpp ${SOURCE_FILES}
Vehicles.hpp
Audio.hpp)
# Set the output directory for the executable
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/bin)
set_target_properties(${TARGET_BINARY_NAME} PROPERTIES RUNTIME_OUTPUT_DIRECTORY ${CMAKE_RUNTIME_OUTPUT_DIRECTORY})
# Create directory for shaders
file(MAKE_DIRECTORY ${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/shaders)
# Compile fragment shaders
file(GLOB SHADER_FILES ${CMAKE_CURRENT_SOURCE_DIR}/shaders/*.frag)
foreach (FILE ${SHADER_FILES})
string(REGEX REPLACE ".*/(.*)" "\\1" FILE_NAME ${FILE})
string(REGEX REPLACE ".frag" "" FILE_NAME ${FILE_NAME})
execute_process(
COMMAND glslc ${FILE} -o ${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/shaders/${FILE_NAME}Frag.spv
)
endforeach ()
# Compile vertex shaders
file(GLOB SHADER_FILES ${CMAKE_CURRENT_SOURCE_DIR}/shaders/*.vert)
foreach (FILE ${SHADER_FILES})
string(REGEX REPLACE ".*/(.*)" "\\1" FILE_NAME ${FILE})
string(REGEX REPLACE ".vert" "" FILE_NAME ${FILE_NAME})
execute_process(
COMMAND glslc ${FILE} -o ${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/shaders/${FILE_NAME}Vert.spv
)
endforeach ()
# Copy models and textures to the binary directory
file(COPY ${CMAKE_CURRENT_SOURCE_DIR}/models
DESTINATION ${CMAKE_RUNTIME_OUTPUT_DIRECTORY})
file(COPY ${CMAKE_CURRENT_SOURCE_DIR}/textures
DESTINATION ${CMAKE_RUNTIME_OUTPUT_DIRECTORY})
# Copy audio files to the binary directory
file(COPY ${CMAKE_CURRENT_SOURCE_DIR}/sounds
DESTINATION ${CMAKE_RUNTIME_OUTPUT_DIRECTORY})
# Link libraries
target_link_libraries(${TARGET_BINARY_NAME} glfw Vulkan::Vulkan glm::glm ao sndfile dl pthread X11 Xxf86vm Xrandr Xi)