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.py ${CMAKE_CURRENT_SOURCE_DIR}/${out} 6 DEPENDS ${CMAKE_CURRENT_SOURCE_DIR}/generate-dispatch-table.py 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.cpp 25 Game.h 26 Helpers.h 27 HelpersDispatchTable.cpp 28 HelpersDispatchTable.h 29 Smoke.cpp 30 Smoke.h 31 Smoke.frag.h 32 Smoke.vert.h 33 Smoke.push_constant.vert.h 34 Main.cpp 35 Meshes.cpp 36 Meshes.h 37 Meshes.teapot.h 38 Simulation.cpp 39 Simulation.h 40 Shell.cpp 41 Shell.h 42 ) 43 44set(definitions 45 PRIVATE -DVK_NO_PROTOTYPES 46 PRIVATE -DGLM_FORCE_RADIANS) 47 48set(includes 49 PRIVATE ${GLMINC_PREFIX} 50 PRIVATE ${CMAKE_CURRENT_BINARY_DIR}) 51 52set(libraries PRIVATE ${CMAKE_THREAD_LIBS_INIT}) 53 54if(TARGET vulkan) 55 list(APPEND definitions PRIVATE -DUNINSTALLED_LOADER="$<TARGET_FILE:vulkan>") 56endif() 57 58if(WIN32) 59 list(APPEND definitions PRIVATE -DVK_USE_PLATFORM_WIN32_KHR) 60 list(APPEND definitions PRIVATE -DWIN32_LEAN_AND_MEAN) 61 62 list(APPEND sources ShellWin32.cpp ShellWin32.h) 63else() 64 list(APPEND libraries PRIVATE -ldl -lrt) 65 66 if(BUILD_WSI_XCB_SUPPORT AND DEMOS_WSI_SELECTION STREQUAL "XCB") 67 find_package(XCB REQUIRED) 68 69 list(APPEND sources ShellXcb.cpp ShellXcb.h) 70 list(APPEND definitions PRIVATE -DVK_USE_PLATFORM_XCB_KHR) 71 list(APPEND includes PRIVATE ${XCB_INCLUDES}) 72 list(APPEND libraries PRIVATE ${XCB_LIBRARIES}) 73 elseif(BUILD_WSI_WAYLAND_SUPPORT AND DEMOS_WSI_SELECTION STREQUAL "WAYLAND") 74 find_package(Wayland REQUIRED) 75 76 list(APPEND sources ShellWayland.cpp ShellWayland.h) 77 list(APPEND definitions PRIVATE -DVK_USE_PLATFORM_WAYLAND_KHR) 78 list(APPEND includes PRIVATE ${WAYLAND_CLIENT_INCLUDE_DIR}) 79 list(APPEND libraries PRIVATE ${WAYLAND_CLIENT_LIBRARIES}) 80 endif() 81endif() 82 83set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/..) 84 85add_executable(smoketest ${sources}) 86target_compile_definitions(smoketest ${definitions}) 87target_include_directories(smoketest ${includes}) 88target_link_libraries(smoketest ${libraries}) 89 90if(UNIX) 91 if(INSTALL_LVL_FILES) 92 install(TARGETS smoketest DESTINATION ${CMAKE_INSTALL_BINDIR}) 93 endif() 94endif() 95