• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1if(NOT WIN32)
2    find_package(XCB REQUIRED)
3endif()
4
5file(GLOB TEXTURES
6  "${PROJECT_SOURCE_DIR}/demos/*.ppm"
7  )
8file(COPY ${TEXTURES} DESTINATION ${CMAKE_BINARY_DIR}/demos)
9
10set (CMAKE_C_FLAGS "${CMAKE_C_FLAGS}")
11set (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS}")
12
13if(WIN32)
14  set (LIBRARIES "vulkan-${MAJOR}")
15elseif(UNIX)
16  set (LIBRARIES "vulkan")
17else()
18endif()
19
20if(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)
53else()
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       )
71endif()
72
73if(NOT WIN32)
74    include_directories (
75       ${XCB_INCLUDE_DIRS}
76       "${PROJECT_SOURCE_DIR}/icd/common"
77       )
78
79    link_libraries(${XCB_LIBRARIES} vulkan m)
80endif()
81if(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")
88endif()
89
90add_executable(vulkaninfo vulkaninfo.c)
91target_link_libraries(vulkaninfo ${LIBRARIES})
92
93if(UNIX)
94    add_executable(tri tri.c ${CMAKE_BINARY_DIR}/demos/tri-vert.spv ${CMAKE_BINARY_DIR}/demos/tri-frag.spv)
95else()
96    add_executable(tri WIN32 tri.c ${CMAKE_BINARY_DIR}/demos/tri-vert.spv ${CMAKE_BINARY_DIR}/demos/tri-frag.spv)
97endif()
98target_link_libraries(tri ${LIBRARIES})
99
100if(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})
103else()
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} )
112endif()
113
114add_subdirectory(smoke)
115
116