mirror of
https://github.com/GPUOpen-LibrariesAndSDKs/VulkanMemoryAllocator
synced 2024-11-05 12:20:07 +00:00
Add CMake support
This commit is contained in:
parent
cc47fcf867
commit
69747a2bdb
12
CMakeLists.txt
Normal file
12
CMakeLists.txt
Normal file
@ -0,0 +1,12 @@
|
|||||||
|
cmake_minimum_required(VERSION 3.9)
|
||||||
|
|
||||||
|
project(VulkanMemoryAllocator)
|
||||||
|
|
||||||
|
set(CMAKE_DISABLE_IN_SOURCE_BUILD ON)
|
||||||
|
|
||||||
|
find_package(Vulkan REQUIRED)
|
||||||
|
|
||||||
|
# Put binaries into bin folder
|
||||||
|
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${PROJECT_SOURCE_DIR}/bin)
|
||||||
|
|
||||||
|
add_subdirectory(src)
|
112
src/CMakeLists.txt
Normal file
112
src/CMakeLists.txt
Normal file
@ -0,0 +1,112 @@
|
|||||||
|
add_subdirectory(Shaders)
|
||||||
|
add_subdirectory(VmaReplay)
|
||||||
|
|
||||||
|
set(VMA_LIBRARY_SOURCE_FILES
|
||||||
|
VmaUsage.cpp
|
||||||
|
)
|
||||||
|
|
||||||
|
# Use folder structure as filters in project map
|
||||||
|
foreach(FILE ${VMA_LIBRARY_SOURCE_FILES})
|
||||||
|
get_filename_component(PARENT_DIR "${FILE}" PATH)
|
||||||
|
|
||||||
|
string(REPLACE "/" "\\" GROUP "${PARENT_DIR}")
|
||||||
|
|
||||||
|
if("${FILE}" MATCHES ".*\\.cpp")
|
||||||
|
set(GROUP "Source Files\\${GROUP}")
|
||||||
|
elseif("${FILE}" MATCHES ".*\\.hpp")
|
||||||
|
set(GROUP "Header Files\\${GROUP}")
|
||||||
|
endif()
|
||||||
|
|
||||||
|
source_group("${GROUP}" FILES "${FILE}")
|
||||||
|
endforeach()
|
||||||
|
|
||||||
|
add_library(VmaLibrary ${VMA_LIBRARY_SOURCE_FILES})
|
||||||
|
|
||||||
|
set_target_properties(
|
||||||
|
VmaLibrary PROPERTIES
|
||||||
|
|
||||||
|
CXX_EXTENSIONS OFF
|
||||||
|
# Use C++14
|
||||||
|
CXX_STANDARD 14
|
||||||
|
CXX_STANDARD_REQUIRED ON
|
||||||
|
)
|
||||||
|
|
||||||
|
target_include_directories(
|
||||||
|
VmaLibrary
|
||||||
|
|
||||||
|
PUBLIC
|
||||||
|
${PROJECT_SOURCE_DIR}/include
|
||||||
|
)
|
||||||
|
|
||||||
|
target_link_libraries(
|
||||||
|
VmaLibrary
|
||||||
|
|
||||||
|
PUBLIC
|
||||||
|
Vulkan::Vulkan
|
||||||
|
)
|
||||||
|
|
||||||
|
set(VMA_EXAMPLE_SOURCE_FILES
|
||||||
|
Common.cpp
|
||||||
|
SparseBindingTest.cpp
|
||||||
|
Tests.cpp
|
||||||
|
VulkanSample.cpp
|
||||||
|
)
|
||||||
|
|
||||||
|
# Use folder structure as filters in project map
|
||||||
|
foreach(FILE ${VMA_EXAMPLE_SOURCE_FILES})
|
||||||
|
get_filename_component(PARENT_DIR "${FILE}" PATH)
|
||||||
|
|
||||||
|
string(REPLACE "/" "\\" GROUP "${PARENT_DIR}")
|
||||||
|
|
||||||
|
if("${FILE}" MATCHES ".*\\.cpp")
|
||||||
|
set(GROUP "Source Files\\${GROUP}")
|
||||||
|
elseif("${FILE}" MATCHES ".*\\.hpp")
|
||||||
|
set(GROUP "Header Files\\${GROUP}")
|
||||||
|
endif()
|
||||||
|
|
||||||
|
source_group("${GROUP}" FILES "${FILE}")
|
||||||
|
endforeach()
|
||||||
|
|
||||||
|
IF (WIN32)
|
||||||
|
add_executable(VmaExample ${VMA_EXAMPLE_SOURCE_FILES})
|
||||||
|
|
||||||
|
# Make sure to compile shaders when compiling the example
|
||||||
|
add_dependencies(VmaExample VmaShaders)
|
||||||
|
|
||||||
|
# Visual Studio specific settings
|
||||||
|
if(${CMAKE_GENERATOR} MATCHES "Visual Studio.*")
|
||||||
|
# Use Unicode instead of multibyte set
|
||||||
|
add_definitions(-DUNICODE -D_UNICODE)
|
||||||
|
|
||||||
|
# Set VmaExample as startup project
|
||||||
|
set_property(DIRECTORY ${PROJECT_SOURCE_DIR} PROPERTY VS_STARTUP_PROJECT "VmaExample")
|
||||||
|
|
||||||
|
# Enable multithreaded compiling
|
||||||
|
target_compile_options(VmaExample PRIVATE "/MP")
|
||||||
|
|
||||||
|
# Set working directory for Visual Studio debugger
|
||||||
|
set_target_properties(
|
||||||
|
VmaExample
|
||||||
|
PROPERTIES VS_DEBUGGER_WORKING_DIRECTORY "${PROJECT_SOURCE_DIR}/bin"
|
||||||
|
)
|
||||||
|
endif()
|
||||||
|
|
||||||
|
set_target_properties(
|
||||||
|
VmaExample PROPERTIES
|
||||||
|
|
||||||
|
CXX_EXTENSIONS OFF
|
||||||
|
# Use C++14
|
||||||
|
CXX_STANDARD 14
|
||||||
|
CXX_STANDARD_REQUIRED ON
|
||||||
|
)
|
||||||
|
|
||||||
|
target_link_libraries(
|
||||||
|
VmaExample
|
||||||
|
|
||||||
|
PRIVATE
|
||||||
|
VmaLibrary
|
||||||
|
)
|
||||||
|
|
||||||
|
ELSE()
|
||||||
|
message(STATUS "VmaExample application is not supported to Linux")
|
||||||
|
ENDIF()
|
30
src/Shaders/CMakeLists.txt
Normal file
30
src/Shaders/CMakeLists.txt
Normal file
@ -0,0 +1,30 @@
|
|||||||
|
find_program(GLSL_VALIDATOR glslangValidator REQUIRED)
|
||||||
|
|
||||||
|
if(NOT GLSL_VALIDATOR)
|
||||||
|
message(FATAL_ERROR "glslangValidator not found!")
|
||||||
|
endif()
|
||||||
|
|
||||||
|
set(SHADERS
|
||||||
|
Shader.vert
|
||||||
|
Shader.frag
|
||||||
|
SparseBindingTest.comp
|
||||||
|
)
|
||||||
|
|
||||||
|
# Compile each shader using glslangValidator
|
||||||
|
foreach(SHADER ${SHADERS})
|
||||||
|
get_filename_component(FILE_NAME ${SHADER} NAME)
|
||||||
|
|
||||||
|
# Put the .spv files into the bin folder
|
||||||
|
set(SPIRV ${PROJECT_SOURCE_DIR}/bin/${FILE_NAME}.spv)
|
||||||
|
|
||||||
|
add_custom_command(
|
||||||
|
OUTPUT ${SPIRV}
|
||||||
|
# Use the same file name and append .spv to the compiled shader
|
||||||
|
COMMAND ${GLSL_VALIDATOR} -V ${CMAKE_CURRENT_SOURCE_DIR}/${SHADER} -o ${SPIRV}
|
||||||
|
DEPENDS ${SHADER}
|
||||||
|
)
|
||||||
|
|
||||||
|
list(APPEND SPIRV_FILES ${SPIRV})
|
||||||
|
endforeach()
|
||||||
|
|
||||||
|
add_custom_target(VmaShaders DEPENDS ${SPIRV_FILES})
|
19
src/VmaReplay/CMakeLists.txt
Normal file
19
src/VmaReplay/CMakeLists.txt
Normal file
@ -0,0 +1,19 @@
|
|||||||
|
IF (WIN32)
|
||||||
|
set(VMA_REPLAY_SOURCE_FILES
|
||||||
|
Common.cpp
|
||||||
|
Constants.cpp
|
||||||
|
VmaReplay.cpp
|
||||||
|
VmaUsage.cpp
|
||||||
|
)
|
||||||
|
|
||||||
|
add_executable(VmaReplay ${VMA_REPLAY_SOURCE_FILES})
|
||||||
|
|
||||||
|
target_link_libraries(
|
||||||
|
VmaReplay
|
||||||
|
|
||||||
|
PRIVATE
|
||||||
|
Vulkan::Vulkan
|
||||||
|
)
|
||||||
|
ELSE()
|
||||||
|
message(STATUS "VmaReplay is not supported on Linux")
|
||||||
|
ENDIF()
|
Loading…
Reference in New Issue
Block a user