Make building shaders, VMA example application and VMA replay app optional

This commit is contained in:
Johannes Schneider 2021-05-28 01:43:56 +02:00
parent 69747a2bdb
commit e32721df9e
No known key found for this signature in database
GPG Key ID: 630166982479CCF3
4 changed files with 58 additions and 46 deletions

View File

@ -9,4 +9,9 @@ find_package(Vulkan REQUIRED)
# Put binaries into bin folder
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${PROJECT_SOURCE_DIR}/bin)
# VulkanMemoryAllocator contains an example application and VmaReplay which are not build by default
option(VMA_BUILD_EXAMPLE_APP "Build VulkanMemoryAllocator example application" OFF)
option(VMA_BUILD_EXAMPLE_APP_SHADERS "Build VulkanMemoryAllocator example application's shaders" OFF)
option(VMA_BUILD_REPLAY_APP "Build VulkanMemoryAllocator replay application" OFF)
add_subdirectory(src)

View File

@ -1,5 +1,10 @@
add_subdirectory(Shaders)
add_subdirectory(VmaReplay)
if(VMA_BUILD_EXAMPLE_APP_SHADERS)
add_subdirectory(Shaders)
endif()
if(VMA_BUILD_REPLAY_APP)
add_subdirectory(VmaReplay)
endif()
set(VMA_LIBRARY_SOURCE_FILES
VmaUsage.cpp
@ -20,10 +25,10 @@ foreach(FILE ${VMA_LIBRARY_SOURCE_FILES})
source_group("${GROUP}" FILES "${FILE}")
endforeach()
add_library(VmaLibrary ${VMA_LIBRARY_SOURCE_FILES})
add_library(VulkanMemoryAllocator ${VMA_LIBRARY_SOURCE_FILES})
set_target_properties(
VmaLibrary PROPERTIES
VulkanMemoryAllocator PROPERTIES
CXX_EXTENSIONS OFF
# Use C++14
@ -32,14 +37,14 @@ set_target_properties(
)
target_include_directories(
VmaLibrary
VulkanMemoryAllocator
PUBLIC
${PROJECT_SOURCE_DIR}/include
)
target_link_libraries(
VmaLibrary
VulkanMemoryAllocator
PUBLIC
Vulkan::Vulkan
@ -67,12 +72,10 @@ foreach(FILE ${VMA_EXAMPLE_SOURCE_FILES})
source_group("${GROUP}" FILES "${FILE}")
endforeach()
IF (WIN32)
if (VMA_BUILD_EXAMPLE_APP)
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
@ -106,7 +109,7 @@ IF (WIN32)
PRIVATE
VmaLibrary
)
ELSE()
else()
message(STATUS "VmaExample application is not supported to Linux")
ENDIF()
endif()
endif()

View File

@ -1,3 +1,5 @@
# This file will only be executed if VMA_BUILD_EXAMPLE_APP_SHADERS is set to ON
find_program(GLSL_VALIDATOR glslangValidator REQUIRED)
if(NOT GLSL_VALIDATOR)

View File

@ -1,4 +1,6 @@
IF (WIN32)
# This file will only be executed if VMA_BUILD_REPLAY_APP is set to ON
if (WIN32)
set(VMA_REPLAY_SOURCE_FILES
Common.cpp
Constants.cpp
@ -14,6 +16,6 @@ IF (WIN32)
PRIVATE
Vulkan::Vulkan
)
ELSE()
else()
message(STATUS "VmaReplay is not supported on Linux")
ENDIF()
endif()