-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathCMakeLists.txt
107 lines (84 loc) · 3.54 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
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
cmake_minimum_required(VERSION 3.10)
project(vulkan_bot)
set(CMAKE_CXX_STANDARD 20)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
find_package(Vulkan REQUIRED COMPONENTS glslangValidator SPIRV-Tools)
find_package(glslang REQUIRED)
find_package(glm REQUIRED)
file(GLOB_RECURSE sources src/*.cpp src/*.h external/lodepng/lodepng.cpp)
file(GLOB_RECURSE shaders shaders/*.vert shaders/*.frag shaders/*.comp)
file(GLOB_RECURSE shader_includes shader_include/*.glsl)
add_executable(vulkan_bot ${sources})
target_include_directories(vulkan_bot PUBLIC include/)
target_include_directories(vulkan_bot PUBLIC external/lodepng)
include(FetchContent)
function(FetchContent_MakeAvailable_ExcludeFromAll)
if(CMAKE_VERSION VERSION_LESS "3.28.0")
foreach(_name ${ARGN})
FetchContent_GetProperties(${_name})
if(NOT ${_name}_POPULATED)
FetchContent_Populate(${_name})
add_subdirectory(${${_name}_SOURCE_DIR} ${${_name}_BINARY_DIR} EXCLUDE_FROM_ALL)
endif()
endforeach()
else()
FetchContent_MakeAvailable(${ARGN})
endif()
endfunction()
FetchContent_Declare(DPP
GIT_REPOSITORY https://github.com/brainboxdotcc/DPP.git
GIT_TAG v10.0.35
EXCLUDE_FROM_ALL
)
FetchContent_Declare(json URL https://github.com/nlohmann/json/releases/download/v3.11.2/json.tar.xz EXCLUDE_FROM_ALL)
FetchContent_Declare(avcpp
GIT_REPOSITORY https://github.com/h4tr3d/avcpp.git
GIT_TAG v2.4.0
EXCLUDE_FROM_ALL
)
set(BUILD_SHARED_LIBS ON CACHE BOOL "" FORCE)
set(BUILD_VOICE_SUPPORT OFF CACHE BOOL "" FORCE)
set(DPP_USE_PCH ON CACHE BOOL "" FORCE)
FetchContent_MakeAvailable_ExcludeFromAll(json avcpp)
option(USE_INSTALLED_DPP "Use preinstalled DPP" OFF)
if(USE_INSTALLED_DPP)
find_package(dpp REQUIRED)
else()
FetchContent_MakeAvailable_ExcludeFromAll(DPP)
add_library(dpp::dpp ALIAS dpp)
endif(USE_INSTALLED_DPP)
message(STATUS "Found GLSL compiler: ${Vulkan_GLSLANG_VALIDATOR_EXECUTABLE}")
function(add_shader TARGET SHADER)
file(RELATIVE_PATH rel ${CMAKE_CURRENT_SOURCE_DIR} ${SHADER})
set(output ${CMAKE_BINARY_DIR}/${rel}.spv)
get_filename_component(output-dir ${output} DIRECTORY)
file(MAKE_DIRECTORY ${output-dir})
add_custom_command(
OUTPUT ${output}
COMMAND ${Vulkan_GLSLANG_VALIDATOR_EXECUTABLE} -V -o ${output} ${SHADER}
DEPENDS ${SHADER}
VERBATIM)
set_source_files_properties(${output} PROPERTIES GENERATED TRUE)
target_sources(${TARGET} PRIVATE ${output})
endfunction(add_shader)
foreach(shader ${shaders})
add_shader(vulkan_bot ${shader})
endforeach()
foreach(shader_include ${shader_includes})
file(RELATIVE_PATH rel ${CMAKE_CURRENT_SOURCE_DIR} ${shader_include})
configure_file(${rel} ${rel} COPYONLY)
endforeach()
target_link_libraries(vulkan_bot PUBLIC Vulkan::Vulkan)
target_link_libraries(vulkan_bot PUBLIC glslang::SPIRV glslang::glslang-default-resource-limits)
target_link_libraries(vulkan_bot PUBLIC dpp::dpp nlohmann_json::nlohmann_json)
target_link_libraries(vulkan_bot PUBLIC avcpp::avcpp-static)
target_link_libraries(vulkan_bot PUBLIC glm::glm)
target_compile_features(vulkan_bot PUBLIC cxx_std_23)
if(USE_INSTALLED_DPP) # DPP doesn't properly export include directories nor libraries
target_include_directories(vulkan_bot PUBLIC ${dpp_DIR}/../../../include)
target_link_libraries(vulkan_bot PUBLIC nlohmann_json::nlohmann_json)
target_link_libraries(vulkan_bot PUBLIC crypto ssl)
endif(USE_INSTALLED_DPP)
install(TARGETS vulkan_bot)
install(DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/shaders DESTINATION share/vulkan_bot)
install(DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/shader_include DESTINATION share/vulkan_bot)