1set (GLMINC_PREFIX ${PROJECT_SOURCE_DIR}/libs)
2
3macro(generate_dispatch_table out)
4    add_custom_command(OUTPUT ${CMAKE_CURRENT_SOURCE_DIR}/${out}
5        COMMAND ${PYTHON_EXECUTABLE} ${CMAKE_CURRENT_SOURCE_DIR}/generate-dispatch-table ${CMAKE_CURRENT_SOURCE_DIR}/${out}
6        DEPENDS ${CMAKE_CURRENT_SOURCE_DIR}/generate-dispatch-table
7        )
8endmacro()
9
10macro(glsl_to_spirv src)
11    add_custom_command(OUTPUT ${src}.h
12        COMMAND ${PYTHON_EXECUTABLE} ${CMAKE_CURRENT_SOURCE_DIR}/glsl-to-spirv ${CMAKE_CURRENT_SOURCE_DIR}/${src} ${src}.h ${GLSLANG_VALIDATOR}
13        DEPENDS ${CMAKE_CURRENT_SOURCE_DIR}/glsl-to-spirv ${CMAKE_CURRENT_SOURCE_DIR}/${src} ${GLSLANG_VALIDATOR}
14        )
15endmacro()
16
17generate_dispatch_table(HelpersDispatchTable.h)
18generate_dispatch_table(HelpersDispatchTable.cpp)
19glsl_to_spirv(Smoke.frag)
20glsl_to_spirv(Smoke.vert)
21glsl_to_spirv(Smoke.push_constant.vert)
22
23set(sources
24    Game.h
25    Helpers.h
26    HelpersDispatchTable.cpp
27    HelpersDispatchTable.h
28    Smoke.cpp
29    Smoke.h
30    Smoke.frag.h
31    Smoke.vert.h
32    Smoke.push_constant.vert.h
33    Main.cpp
34    Meshes.cpp
35    Meshes.h
36    Meshes.teapot.h
37    Simulation.cpp
38    Simulation.h
39    Shell.cpp
40    Shell.h
41    )
42
43set(definitions
44    PRIVATE -DVK_NO_PROTOTYPES
45    PRIVATE -DGLM_FORCE_RADIANS)
46
47set(includes
48    PRIVATE ${GLMINC_PREFIX}
49    PRIVATE ${CMAKE_CURRENT_BINARY_DIR})
50
51set(libraries PRIVATE ${CMAKE_THREAD_LIBS_INIT})
52
53if(TARGET vulkan)
54    list(APPEND definitions PRIVATE -DUNINSTALLED_LOADER="$<TARGET_FILE:vulkan>")
55endif()
56
57if(WIN32)
58    list(APPEND definitions PRIVATE -DVK_USE_PLATFORM_WIN32_KHR)
59    list(APPEND definitions PRIVATE -DWIN32_LEAN_AND_MEAN)
60
61    list(APPEND sources ShellWin32.cpp ShellWin32.h)
62else()
63    list(APPEND libraries PRIVATE -ldl)
64
65    find_package(XCB REQUIRED)
66
67    list(APPEND sources ShellXcb.cpp ShellXcb.h)
68    list(APPEND definitions PRIVATE -DVK_USE_PLATFORM_XCB_KHR)
69    list(APPEND includes PRIVATE ${XCB_INCLUDES})
70    list(APPEND libraries PRIVATE ${XCB_LIBRARIES})
71endif()
72
73set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/demos)
74
75add_executable(smoketest ${sources})
76target_compile_definitions(smoketest ${definitions})
77target_include_directories(smoketest ${includes})
78target_link_libraries(smoketest ${libraries})
79