This repository has been archived by the owner on Nov 13, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 6
/
CMakeLists.txt
91 lines (81 loc) · 2.73 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
project(nuklear-vulkan C CXX)
cmake_minimum_required(VERSION 3.1)
set(CMAKE_C_STANDARD 90)
set(CMAKE_CXX_STANDARD 11)
set(GLFW_BUILD_EXAMPLES OFF CACHE STRING "" FORCE)
set(GLFW_BUILD_TESTS OFF CACHE STRING "" FORCE)
set(GLFW_INSTALL OFF CACHE STRING "" FORCE)
add_subdirectory(glfw-3.2.1)
find_program(GLSL_VALIDATOR
glslangValidator
PATHS $ENV{VULKAN_SDK}/bin
)
if (NOT GLSL_VALIDATOR)
message(FATAL_ERROR "glsllangValidator executable not found! make sure that the environment defines VULKAN_SDK correctly")
endif()
find_program(XXD
xxd
)
if (NOT XXD)
message(FATAL_ERROR "xxd executable not found! On windows this is part of the GIT distribution")
endif()
file(MAKE_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/demoshaders)
file(MAKE_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/nuklearshaders)
set(SHADERS
demoshaders/triangle.frag
demoshaders/triangle.vert
demoshaders/overlay.frag
demoshaders/overlay.vert
nuklearshaders/nuklear.frag
nuklearshaders/nuklear.vert
)
list(APPEND SHADER_HEADERS "")
foreach (SHADER ${SHADERS})
SET(SPV_FILENAME ${SHADER}.spv)
add_custom_command(
OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/${SPV_FILENAME}
COMMAND ${GLSL_VALIDATOR} -V ${CMAKE_CURRENT_SOURCE_DIR}/${SHADER} -o ${CMAKE_CURRENT_BINARY_DIR}/${SPV_FILENAME}
DEPENDS ${CMAKE_CURRENT_SOURCE_DIR}/${SHADER}
)
add_custom_command(
OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/${SHADER}.h
COMMAND ${XXD} -i ${SHADER}.spv ${CMAKE_CURRENT_BINARY_DIR}/${SHADER}.h
DEPENDS ${CMAKE_CURRENT_BINARY_DIR}/${SPV_FILENAME}
)
list(APPEND SHADER_HEADERS ${CMAKE_CURRENT_BINARY_DIR}/${SHADER}.h)
endforeach()
configure_file(generate-inlined-include.cmake.in ${CMAKE_CURRENT_BINARY_DIR}/generate-inlined-include.cmake @ONLY)
add_custom_target(release_header
COMMAND ${CMAKE_COMMAND} -P ${CMAKE_CURRENT_BINARY_DIR}/generate-inlined-include.cmake
DEPENDS
${CMAKE_CURRENT_BINARY_DIR}/nuklearshaders/nuklear.frag.h
${CMAKE_CURRENT_BINARY_DIR}/nuklearshaders/nuklear.vert.h
${CMAKE_CURRENT_SOURCE_DIR}/nuklear-glfw-vulkan.h
)
file(WRITE "${CMAKE_CURRENT_BINARY_DIR}/release/test.c" "#include \"nuklear-glfw-vulkan.h\"\nint main() { return 0;}")
add_library(release
EXCLUDE_FROM_ALL
${CMAKE_CURRENT_BINARY_DIR}/release/test.c
)
add_dependencies(release release_header)
target_include_directories(release PRIVATE
${CMAKE_CURRENT_BINARY_DIR}/release
nuklear
glfw-3.2.1/include
${VULKAN_INCLUDE_DIR}
)
add_executable(demo
demo.cpp
overlay.c
${SHADER_HEADERS}
)
target_link_libraries(demo
glfw
${VULKAN_LIBRARY}
)
target_include_directories(demo PRIVATE
nuklear
glfw-3.2.1/include
${VULKAN_INCLUDE_DIR}
${CMAKE_CURRENT_BINARY_DIR}
)