1 if(NOT WIN32) 2 find_package(XCB REQUIRED) 3 endif() 4 5 file(GLOB TEXTURES 6 "${PROJECT_SOURCE_DIR}/demos/*.ppm" 7 ) 8 file(COPY ${TEXTURES} DESTINATION ${CMAKE_BINARY_DIR}/demos) 9 10 set (CMAKE_C_FLAGS "${CMAKE_C_FLAGS}") 11 set (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS}") 12 13 if(WIN32) 14 set (LIBRARIES "vulkan-${MAJOR}") 15 elseif(UNIX) 16 set (LIBRARIES "vulkan") 17 else() 18 endif() 19 20 if(WIN32) 21 # For Windows, since 32-bit and 64-bit items can co-exist, we build each in its own build directory. 22 # 32-bit target data goes in build32, and 64-bit target data goes into build. So, include/link the 23 # appropriate data at build time. 24 if (CMAKE_CL_64) 25 set (BUILDTGT_DIR build) 26 else () 27 set (BUILDTGT_DIR build32) 28 endif() 29 30 add_custom_command(OUTPUT ${CMAKE_BINARY_DIR}/demos/tri-vert.spv 31 COMMAND ${GLSLANG_VALIDATOR} -s -V ${PROJECT_SOURCE_DIR}/demos/tri.vert 32 COMMAND move vert.spv ${CMAKE_BINARY_DIR}/demos/tri-vert.spv 33 DEPENDS tri.vert ${GLSLANG_VALIDATOR} 34 ) 35 add_custom_command(OUTPUT ${CMAKE_BINARY_DIR}/demos/tri-frag.spv 36 COMMAND ${GLSLANG_VALIDATOR} -s -V ${PROJECT_SOURCE_DIR}/demos/tri.frag 37 COMMAND move frag.spv ${CMAKE_BINARY_DIR}/demos/tri-frag.spv 38 DEPENDS tri.frag ${GLSLANG_VALIDATOR} 39 ) 40 add_custom_command(OUTPUT ${CMAKE_BINARY_DIR}/demos/cube-vert.spv 41 COMMAND ${GLSLANG_VALIDATOR} -s -V ${PROJECT_SOURCE_DIR}/demos/cube.vert 42 COMMAND move vert.spv ${CMAKE_BINARY_DIR}/demos/cube-vert.spv 43 DEPENDS cube.vert ${GLSLANG_VALIDATOR} 44 ) 45 add_custom_command(OUTPUT ${CMAKE_BINARY_DIR}/demos/cube-frag.spv 46 COMMAND ${GLSLANG_VALIDATOR} -s -V ${PROJECT_SOURCE_DIR}/demos/cube.frag 47 COMMAND move frag.spv ${CMAKE_BINARY_DIR}/demos/cube-frag.spv 48 DEPENDS cube.frag ${GLSLANG_VALIDATOR} 49 ) 50 file(COPY cube.vcxproj.user DESTINATION ${CMAKE_BINARY_DIR}/demos) 51 file(COPY tri.vcxproj.user DESTINATION ${CMAKE_BINARY_DIR}/demos) 52 file(COPY vulkaninfo.vcxproj.user DESTINATION ${CMAKE_BINARY_DIR}/demos) 53 else() 54 add_custom_command(OUTPUT ${CMAKE_BINARY_DIR}/demos/tri-vert.spv 55 COMMAND ${GLSLANG_VALIDATOR} -s -V -o tri-vert.spv ${PROJECT_SOURCE_DIR}/demos/tri.vert 56 DEPENDS tri.vert ${GLSLANG_VALIDATOR} 57 ) 58 add_custom_command(OUTPUT ${CMAKE_BINARY_DIR}/demos/tri-frag.spv 59 COMMAND ${GLSLANG_VALIDATOR} -s -V -o tri-frag.spv ${PROJECT_SOURCE_DIR}/demos/tri.frag 60 DEPENDS tri.frag ${GLSLANG_VALIDATOR} 61 ) 62 add_custom_command(OUTPUT ${CMAKE_BINARY_DIR}/demos/cube-vert.spv 63 COMMAND ${GLSLANG_VALIDATOR} -s -V -o cube-vert.spv ${PROJECT_SOURCE_DIR}/demos/cube.vert 64 DEPENDS cube.vert ${GLSLANG_VALIDATOR} 65 ) 66 67 add_custom_command(OUTPUT ${CMAKE_BINARY_DIR}/demos/cube-frag.spv 68 COMMAND ${GLSLANG_VALIDATOR} -s -V -o cube-frag.spv ${PROJECT_SOURCE_DIR}/demos/cube.frag 69 DEPENDS cube.frag ${GLSLANG_VALIDATOR} 70 ) 71 endif() 72 73 if(NOT WIN32) 74 include_directories ( 75 ${XCB_INCLUDE_DIRS} 76 "${PROJECT_SOURCE_DIR}/icd/common" 77 ) 78 79 link_libraries(${XCB_LIBRARIES} vulkan m) 80 endif() 81 if(WIN32) 82 include_directories ( 83 "${PROJECT_SOURCE_DIR}/icd/common" 84 ) 85 86 set (CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -D_CRT_SECURE_NO_WARNINGS -D_USE_MATH_DEFINES") 87 set (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -D_CRT_SECURE_NO_WARNINGS -D_USE_MATH_DEFINES") 88 endif() 89 90 add_executable(vulkaninfo vulkaninfo.c) 91 target_link_libraries(vulkaninfo ${LIBRARIES}) 92 93 if(UNIX) 94 add_executable(tri tri.c ${CMAKE_BINARY_DIR}/demos/tri-vert.spv ${CMAKE_BINARY_DIR}/demos/tri-frag.spv) 95 else() 96 add_executable(tri WIN32 tri.c ${CMAKE_BINARY_DIR}/demos/tri-vert.spv ${CMAKE_BINARY_DIR}/demos/tri-frag.spv) 97 endif() 98 target_link_libraries(tri ${LIBRARIES}) 99 100 if(NOT WIN32) 101 add_executable(cube cube.c ${CMAKE_BINARY_DIR}/demos/cube-vert.spv ${CMAKE_BINARY_DIR}/demos/cube-frag.spv) 102 target_link_libraries(cube ${LIBRARIES}) 103 else() 104 if (CMAKE_CL_64) 105 set (LIB_DIR "Win64") 106 else() 107 set (LIB_DIR "Win32") 108 endif() 109 110 add_executable(cube WIN32 cube.c ${CMAKE_BINARY_DIR}/demos/cube-vert.spv ${CMAKE_BINARY_DIR}/demos/cube-frag.spv) 111 target_link_libraries(cube ${LIBRARIES} ) 112 endif() 113 114 add_subdirectory(smoke) 115 116