-
Notifications
You must be signed in to change notification settings - Fork 0
/
CMakelists.txt
77 lines (59 loc) · 2.71 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
cmake_minimum_required(VERSION 3.27.2)
project(Baal VERSION 1.0.0)
set(CMAKE_CXX_STANDARD 20)
include_directories(${PROJECT_SOURCE_DIR}/include)
file(GLOB_RECURSE SOURCES "${PROJECT_SOURCE_DIR}/src/*.cpp")
# Define the root directory for resources
set(BAAL_MODELS_DIR "${PROJECT_SOURCE_DIR}/src/resources/models/")
set(BAAL_SHADERS_DIR "${PROJECT_SOURCE_DIR}/src/resources/shaders/")
set(BAAL_TEXTURES_DIR "${PROJECT_SOURCE_DIR}/src/resources/textures/")
if (CMAKE_SOURCE_DIR STREQUAL CMAKE_CURRENT_SOURCE_DIR)
# This is the main project
add_executable(Baal ${SOURCES})
else()
# This is a subproject
add_library(Baal STATIC ${SOURCES})
endif()
target_include_directories(Baal PRIVATE ${PROJECT_SOURCE_DIR}/include)
target_include_directories(Baal PUBLIC
"$<BUILD_INTERFACE:${PROJECT_SOURCE_DIR}/include>"
"$<INSTALL_INTERFACE:${CMAKE_INSTALL_INCLUDEDIR}>")
target_include_directories(Baal PRIVATE
"${PROJECT_SOURCE_DIR}/src"
"${CMAKE_BINARY_DIR}/src")
# Pass the resource directory to the compiler
target_compile_definitions(Baal PRIVATE BAAL_MODELS_DIR="${BAAL_MODELS_DIR}")
target_compile_definitions(Baal PRIVATE BAAL_SHADERS_DIR="${BAAL_SHADERS_DIR}")
target_compile_definitions(Baal PRIVATE BAAL_TEXTURES_DIR="${BAAL_TEXTURES_DIR}")
# Path to the Mjolnir repository
set(MJOLNIR_PATH ${PROJECT_SOURCE_DIR}/../Mjolnir)
add_subdirectory(${MJOLNIR_PATH} ${CMAKE_BINARY_DIR}/Mjolnir)
target_link_libraries(Baal PRIVATE Mjolnir)
# Linking with Vulkan library
find_package(Vulkan REQUIRED)
target_link_libraries(Baal PRIVATE Vulkan::Vulkan)
# Path to the GLFW repository
set(GLFW_PATH ${PROJECT_SOURCE_DIR}/../glfw)
# Configure GLFW
set(GLFW_BUILD_EXAMPLES OFF)
set(GLFW_BUILD_TESTS OFF)
set(GLFW_BUILD_DOCS OFF)
set(GLFW_INSTALL OFF)
# Add GLFW as a subdirectory
add_subdirectory(${GLFW_PATH} ${CMAKE_BINARY_DIR}/glfw)
target_link_libraries(Baal PRIVATE glfw)
# Path to the TinyOBJ repository
set(TINYOBJ_PATH ${PROJECT_SOURCE_DIR}/../tinyobjloader)
add_subdirectory(${TINYOBJ_PATH} ${CMAKE_BINARY_DIR}/tinyobjloader)
target_link_libraries(Baal PRIVATE tinyobjloader)
# Path to the glslang repository
set(GLSLANG_PATH ${PROJECT_SOURCE_DIR}/../glslang)
set(ENABLE_OPT 0)
add_subdirectory(${GLSLANG_PATH} ${CMAKE_BINARY_DIR}/glslang)
target_link_libraries(Baal PRIVATE glslang SPIRV glslang-default-resource-limits)
# Path to the VMA repository
set(VMA_PATH ${PROJECT_SOURCE_DIR}/../VulkanMemoryAllocator)
add_subdirectory(${VMA_PATH} ${CMAKE_BINARY_DIR}/VulkanMemoryAllocator)
target_link_libraries(Baal PRIVATE GPUOpen::VulkanMemoryAllocator )
# Print a final message
message(STATUS "CMake configuration for Baal project is complete.")