-
Notifications
You must be signed in to change notification settings - Fork 2
/
CMakeLists.txt
81 lines (64 loc) · 1.78 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
cmake_minimum_required(VERSION 3.4 FATAL_ERROR)
project("sum")
option(SHADER_LANGUAGE "building GLSL or HLSL shader")
message(NOTICE "shader language: ${SHADER_LANGUAGE}")
if (CMAKE_BUILD_TYPE STREQUAL "DEBUG")
set(DEBUG TRUE)
endif ()
set(ELT_COUNT 1024)
set(WORKGROUP_SIZE 32)
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR})
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS}\
-DELT_COUNT=${ELT_COUNT}\
-DWORKGROUP_SIZE=${WORKGROUP_SIZE}"
)
set(CMAKE_C_FLAGS_DEBUG "\
${CMAKE_C_FLAGS_DEBUG}\
-Wall \
-Wextra \
-Wno-unused-parameter \
-Wno-unused-function \
-g \
-O0 \
-fdiagnostics-color=always \
-Werror"
)
set(CMAKE_C_FLAGS_RELEASE "\
${CMAKE_C_FLAGS_RELEASE}\
-O0\
-g"
)
if (DEBUG)
message("build-type: debug")
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${CMAKE_C_FLAGS_DEBUG} -DDEBUG")
else()
message("build-type: release")
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${CMAKE_C_FLAGS_RELEASE} -DRELEASE")
endif()
# dependencies
if ("${SHADER_LANGUAGE}" MATCHES "GLSL")
message("compiler: glslang")
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -DUSE_GLSLANG")
find_program(GLSLANG glslangValidator)
if (NOT GLSLANG)
message(FATAL_ERROR "GlslangValidator is missing.")
endif()
elseif ("${SHADER_LANGUAGE}" MATCHES "HLSL")
message("compiler: dxc")
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -DUSE_DXC")
find_program(DXC dxc)
if (NOT DXC)
message(FATAL_ERROR "DXC is missing.")
endif()
elseif ("${SHADER_LANGUAGE}" MATCHES "WGSL")
message("compiler: tint")
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -DUSE_WGSL")
find_program(TINT tint)
if (NOT TINT)
message(FATAL_ERROR "Tint is missing.")
endif()
else ()
message(FATAL_ERROR "set SHADER_LANGUAGE to either GLSL,HLSL or WGSL.")
endif ()
link_libraries(vulkan)
add_subdirectory(src)