2017-01-19 14:40:12 +11:00
|
|
|
###############################################################################
|
2021-03-17 09:50:20 +11:00
|
|
|
cmake_minimum_required(VERSION 3.18.0)
|
2017-01-19 14:40:12 +11:00
|
|
|
project(cruft-vulkan CXX)
|
|
|
|
|
|
|
|
|
|
|
|
###############################################################################
|
2017-09-05 17:20:17 +10:00
|
|
|
find_package (PythonInterp 3 REQUIRED)
|
|
|
|
find_package (glfw3 REQUIRED)
|
2017-01-19 14:40:12 +11:00
|
|
|
|
2021-03-17 09:50:20 +11:00
|
|
|
find_program (GLSLANG glslangValidator REQUIRED)
|
2017-09-07 12:52:42 +10:00
|
|
|
|
2017-01-19 14:40:12 +11:00
|
|
|
|
|
|
|
###############################################################################
|
2019-06-20 11:38:55 +10:00
|
|
|
set (GENERATED_BASE "${CMAKE_CURRENT_BINARY_DIR}/prefix")
|
|
|
|
set (GENERATED_PREFIX "${GENERATED_BASE}/cruft/vk/")
|
2019-03-03 11:53:31 +11:00
|
|
|
file (MAKE_DIRECTORY "${GENERATED_PREFIX}/load")
|
2019-03-04 10:51:47 +11:00
|
|
|
file (MAKE_DIRECTORY "${GENERATED_PREFIX}/tools")
|
2017-01-19 14:40:12 +11:00
|
|
|
|
|
|
|
|
2018-08-23 13:56:12 +10:00
|
|
|
if (WIN32)
|
|
|
|
set(VK_PLATFORM "win32")
|
|
|
|
elseif(LINUX)
|
|
|
|
set(VK_PLATFORM "xcb")
|
|
|
|
else()
|
|
|
|
message(FATAL_ERROR "unhandled platform")
|
|
|
|
endif()
|
|
|
|
|
|
|
|
|
2017-01-19 14:40:12 +11:00
|
|
|
##-----------------------------------------------------------------------------
|
|
|
|
add_custom_command (
|
|
|
|
OUTPUT
|
2019-01-05 23:30:52 +11:00
|
|
|
"${GENERATED_PREFIX}/vk.hpp"
|
2019-03-03 11:53:31 +11:00
|
|
|
"${GENERATED_PREFIX}/load/dispatch.cpp"
|
|
|
|
"${GENERATED_PREFIX}/load/vtable.hpp"
|
2019-03-04 10:51:47 +11:00
|
|
|
"${GENERATED_PREFIX}/tools/trace.cpp"
|
2017-01-19 14:40:12 +11:00
|
|
|
COMMENT
|
2017-09-04 15:08:36 +10:00
|
|
|
"[spec.py] vk.hpp"
|
2017-01-19 14:40:12 +11:00
|
|
|
COMMAND
|
2017-09-04 15:08:36 +10:00
|
|
|
"${PYTHON_EXECUTABLE}"
|
|
|
|
"${CMAKE_CURRENT_SOURCE_DIR}/tools/spec.py"
|
2018-08-23 13:56:12 +10:00
|
|
|
"--src" "${CMAKE_CURRENT_SOURCE_DIR}/specs/xml/vk.xml"
|
2019-01-05 23:30:52 +11:00
|
|
|
"--dst" "${GENERATED_PREFIX}/vk.hpp"
|
2019-03-03 11:53:31 +11:00
|
|
|
"--load" "${GENERATED_PREFIX}/load/vtable.hpp"
|
|
|
|
"--dispatch" "${GENERATED_PREFIX}/load/dispatch.cpp"
|
2019-03-04 10:51:47 +11:00
|
|
|
"--trace" "${GENERATED_PREFIX}/tools/trace.cpp"
|
2018-08-23 13:56:12 +10:00
|
|
|
"--platform" "${VK_PLATFORM}"
|
2017-01-19 14:40:12 +11:00
|
|
|
DEPENDS
|
2017-09-04 15:08:36 +10:00
|
|
|
"${CMAKE_CURRENT_SOURCE_DIR}/tools/spec.py"
|
2018-06-11 14:55:49 +10:00
|
|
|
"${CMAKE_CURRENT_SOURCE_DIR}/specs/xml/vk.xml"
|
2017-01-19 14:40:12 +11:00
|
|
|
)
|
|
|
|
|
2018-06-11 14:55:49 +10:00
|
|
|
|
2017-01-19 14:40:12 +11:00
|
|
|
|
2018-08-24 17:33:09 +10:00
|
|
|
###############################################################################
|
|
|
|
if (WIN32)
|
|
|
|
set(VK_LOADER_VENDOR win32)
|
|
|
|
elseif (LINUX)
|
|
|
|
set(VK_LOADER_VENDOR posix)
|
|
|
|
else ()
|
|
|
|
message (FATAL_ERROR "unhandled vk-loader platform")
|
|
|
|
endif()
|
|
|
|
|
|
|
|
|
2017-01-19 14:40:12 +11:00
|
|
|
##-----------------------------------------------------------------------------
|
2019-03-03 12:18:58 +11:00
|
|
|
list (APPEND VK_LOAD_SOURCES
|
2019-03-03 11:53:31 +11:00
|
|
|
load/fwd.hpp
|
|
|
|
${GENERATED_PREFIX}/load/vtable.hpp
|
|
|
|
${GENERATED_PREFIX}/load/dispatch.cpp
|
|
|
|
load/dispatch.hpp
|
2019-03-03 12:59:51 +11:00
|
|
|
load/init.cpp
|
2019-03-03 11:53:31 +11:00
|
|
|
load/ostream.cpp
|
|
|
|
load/ostream.hpp
|
|
|
|
load/vendor.hpp
|
|
|
|
load/vendor.cpp
|
2021-04-27 13:20:58 +10:00
|
|
|
load/vendor_${VK_LOADER_VENDOR}.cpp
|
2019-03-03 11:53:31 +11:00
|
|
|
load/vtable.cpp
|
2018-08-24 17:33:09 +10:00
|
|
|
)
|
|
|
|
|
2018-11-05 15:04:04 +11:00
|
|
|
|
2019-03-03 12:18:58 +11:00
|
|
|
add_library (vulkan SHARED ${VK_LOAD_SOURCES})
|
|
|
|
set_target_properties(vulkan PROPERTIES VERSION 1.1.98)
|
|
|
|
set_target_properties(vulkan PROPERTIES SOVERSION 1)
|
|
|
|
|
|
|
|
add_library (cruft-vk-load STATIC ${VK_LOAD_SOURCES})
|
|
|
|
|
|
|
|
foreach (lib vulkan cruft-vk-load)
|
|
|
|
target_include_directories (${lib}
|
|
|
|
PUBLIC
|
|
|
|
"${CMAKE_CURRENT_SOURCE_DIR}"
|
2019-06-20 11:38:55 +10:00
|
|
|
"${GENERATED_PREFIX}"
|
2019-03-03 12:18:58 +11:00
|
|
|
"${CMAKE_CURRENT_SOURCE_DIR}/specs/include/vulkan"
|
|
|
|
)
|
|
|
|
|
|
|
|
target_link_libraries (${lib} cruft-json cruft)
|
|
|
|
endforeach ()
|
2018-08-24 17:33:09 +10:00
|
|
|
|
|
|
|
###############################################################################
|
2017-01-19 14:40:12 +11:00
|
|
|
list (APPEND sources
|
2019-01-05 23:30:52 +11:00
|
|
|
"${GENERATED_PREFIX}/vk.hpp"
|
2017-09-14 00:31:23 +10:00
|
|
|
|
2017-01-19 14:40:12 +11:00
|
|
|
fwd.hpp
|
|
|
|
object.cpp
|
|
|
|
object.hpp
|
2017-09-14 00:31:23 +10:00
|
|
|
|
2017-01-19 14:40:12 +11:00
|
|
|
buffer.cpp
|
|
|
|
buffer.hpp
|
2017-09-14 00:31:23 +10:00
|
|
|
callback.hpp
|
2017-01-19 14:40:12 +11:00
|
|
|
command_buffer.cpp
|
|
|
|
command_buffer.hpp
|
|
|
|
command_pool.cpp
|
|
|
|
command_pool.hpp
|
|
|
|
device.cpp
|
|
|
|
device.hpp
|
|
|
|
device_memory.cpp
|
|
|
|
device_memory.hpp
|
|
|
|
event.cpp
|
|
|
|
event.hpp
|
|
|
|
except.cpp
|
|
|
|
except.hpp
|
|
|
|
fence.cpp
|
|
|
|
fence.hpp
|
|
|
|
framebuffer.cpp
|
|
|
|
framebuffer.hpp
|
|
|
|
instance.cpp
|
|
|
|
instance.hpp
|
|
|
|
image.cpp
|
|
|
|
image.hpp
|
2017-09-09 15:46:08 +10:00
|
|
|
image_view.hpp
|
2017-05-26 16:33:05 +10:00
|
|
|
ostream.cpp
|
|
|
|
ostream.hpp
|
2017-01-19 14:40:12 +11:00
|
|
|
physical_device.cpp
|
|
|
|
physical_device.hpp
|
|
|
|
pipeline.cpp
|
|
|
|
pipeline.hpp
|
|
|
|
pipeline_cache.cpp
|
|
|
|
pipeline_cache.hpp
|
2017-09-10 13:54:27 +10:00
|
|
|
pipeline_layout.cpp
|
|
|
|
pipeline_layout.hpp
|
2017-01-19 14:40:12 +11:00
|
|
|
queue.cpp
|
|
|
|
queue.hpp
|
|
|
|
render_pass.cpp
|
|
|
|
render_pass.hpp
|
|
|
|
semaphore.cpp
|
|
|
|
semaphore.hpp
|
|
|
|
shader_module.cpp
|
|
|
|
shader_module.hpp
|
2017-09-07 15:51:51 +10:00
|
|
|
surface.cpp
|
|
|
|
surface.hpp
|
2017-09-10 13:54:27 +10:00
|
|
|
swapchain.hpp
|
2017-09-08 17:05:59 +10:00
|
|
|
traits.cpp
|
2017-01-19 14:40:12 +11:00
|
|
|
traits.hpp
|
2019-06-20 11:42:25 +10:00
|
|
|
|
|
|
|
meta/info.cpp
|
|
|
|
meta/info.hpp
|
2017-01-19 14:40:12 +11:00
|
|
|
)
|
|
|
|
|
|
|
|
|
|
|
|
##-----------------------------------------------------------------------------
|
|
|
|
add_library (cruft-vk STATIC ${sources})
|
2019-03-03 13:19:11 +11:00
|
|
|
target_link_libraries (cruft-vk cruft)
|
2018-11-05 15:04:04 +11:00
|
|
|
target_include_directories (cruft-vk
|
2019-03-03 13:19:11 +11:00
|
|
|
PUBLIC
|
2018-11-05 15:04:04 +11:00
|
|
|
"${CMAKE_CURRENT_SOURCE_DIR}"
|
2019-01-05 23:30:52 +11:00
|
|
|
"${GENERATED_PREFIX}"
|
2018-11-05 15:04:04 +11:00
|
|
|
"${CMAKE_CURRENT_SOURCE_DIR}/specs/include/vulkan"
|
2019-03-03 13:19:11 +11:00
|
|
|
)
|
2017-05-26 16:33:29 +10:00
|
|
|
|
2017-01-19 14:40:12 +11:00
|
|
|
|
2017-09-07 12:52:42 +10:00
|
|
|
###############################################################################
|
|
|
|
list (APPEND shaders
|
|
|
|
tools/hello/shader.vert
|
|
|
|
tools/hello/shader.frag
|
|
|
|
)
|
|
|
|
|
|
|
|
foreach (src ${shaders})
|
|
|
|
set(src "${CMAKE_CURRENT_SOURCE_DIR}/${src}")
|
|
|
|
get_filename_component(ext ${src} EXT)
|
|
|
|
|
|
|
|
get_filename_component(name ${src} DIRECTORY)
|
|
|
|
get_filename_component(name ${name} NAME)
|
|
|
|
|
|
|
|
set(label "${name}${ext}.spv")
|
|
|
|
set(dst "${CMAKE_CURRENT_BINARY_DIR}/tools/${label}")
|
|
|
|
|
|
|
|
add_custom_command(
|
|
|
|
OUTPUT ${dst}
|
|
|
|
COMMAND ${GLSLANG} -s -o ${dst} -V100 ${src}
|
|
|
|
DEPENDS ${src}
|
|
|
|
COMMENT "[glslang] ${label}"
|
|
|
|
VERBATIM
|
|
|
|
)
|
|
|
|
|
|
|
|
add_custom_target(${label} DEPENDS ${dst})
|
|
|
|
endforeach ()
|
|
|
|
|
|
|
|
|
2017-05-26 16:33:29 +10:00
|
|
|
###############################################################################
|
2017-09-05 17:20:17 +10:00
|
|
|
foreach (t info hello)
|
2017-05-26 16:33:29 +10:00
|
|
|
add_executable (vk_${t} "tools/${t}.cpp")
|
2019-03-03 13:19:11 +11:00
|
|
|
set_target_properties(vk_${t} PROPERTIES
|
|
|
|
OUTPUT_NAME
|
|
|
|
${t})
|
|
|
|
set_target_properties(vk_${t} PROPERTIES
|
|
|
|
RUNTIME_OUTPUT_DIRECTORY
|
|
|
|
"${CMAKE_CURRENT_BINARY_DIR}/tools")
|
2017-05-26 16:33:29 +10:00
|
|
|
endforeach ()
|
|
|
|
|
2019-03-03 12:18:58 +11:00
|
|
|
target_link_libraries (vk_info cruft-vk cruft-vk-load)
|
2019-03-03 13:19:11 +11:00
|
|
|
target_link_libraries (vk_hello ${NC_CXX_STDCXXFS} cruft cruft-vk glfw vulkan)
|
2019-03-03 12:18:58 +11:00
|
|
|
|
2019-03-04 10:51:47 +11:00
|
|
|
add_library (trace SHARED
|
|
|
|
"${GENERATED_PREFIX}/tools/trace.cpp"
|
|
|
|
)
|
|
|
|
|
|
|
|
target_include_directories (trace
|
|
|
|
PUBLIC
|
|
|
|
"${CMAKE_CURRENT_SOURCE_DIR}"
|
|
|
|
"${CMAKE_CURRENT_BINARY_DIR}"
|
|
|
|
"${CMAKE_CURRENT_SOURCE_DIR}/specs/include/vulkan"
|
|
|
|
)
|
|
|
|
|
|
|
|
target_link_libraries(trace cruft-vk)
|
2017-09-07 12:52:42 +10:00
|
|
|
|
|
|
|
##-----------------------------------------------------------------------------
|
|
|
|
add_dependencies (vk_hello hello.vert.spv hello.frag.spv)
|
|
|
|
|
|
|
|
|
2017-01-19 14:40:12 +11:00
|
|
|
###############################################################################
|
2018-08-06 14:18:43 +10:00
|
|
|
configure_file(libcruft-vk.pc.in libcruft-vk.pc)
|
2017-01-19 14:40:12 +11:00
|
|
|
configure_file(Doxyfile.in Doxyfile)
|