diff --git a/CMakeLists.txt b/CMakeLists.txt index 4e84840..fed0436 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -42,7 +42,6 @@ option( VULKAN_HPP_RUN_GENERATOR "Run the HPP generator" OFF ) option( VULKAN_HPP_GENERATOR_BUILD "Build the HPP generator" ${PROJECT_IS_TOP_LEVEL} ) option( VULKAN_HPP_SAMPLES_BUILD "Build samples" OFF ) option( VULKAN_HPP_TESTS_BUILD "Build tests" OFF ) -option( VULKAN_HPP_SAMPLES_BUILD_ONLY_DYNAMIC "Build only dynamic. Required in case the Vulkan SDK is not available" OFF ) option( VULKAN_HPP_BUILD_WITH_LOCAL_VULKAN_HPP "Build with local Vulkan headers" ON ) option( VULKAN_HPP_ENABLE_CPP20_MODULES "Build Vulkan-Hpp as C++20 module; requires minimum CMake version 3.28" OFF ) option( VULKAN_HPP_ENABLE_STD_MODULE "Build Vulkan-Hpp with import std; requires minimum CMake version 3.30" OFF ) @@ -424,7 +423,7 @@ function( vulkan_hpp__setup_sample ) set( multiValueArgs HEADERS LIBS PCH SOURCES ) cmake_parse_arguments( TARGET "${options}" "${oneValueArgs}" "${multiValueArgs}" ${ARGN} ) - if( NOT (VULKAN_HPP_SAMPLES_BUILD_ONLY_DYNAMIC AND VULKAN_HPP_BUILD_WITH_LOCAL_VULKAN_HPP) ) + if( NOT VULKAN_HPP_BUILD_WITH_LOCAL_VULKAN_HPP ) find_package( Vulkan REQUIRED ) endif() @@ -461,22 +460,20 @@ function( vulkan_hpp__setup_sample_static ) set( multiValueArgs ) cmake_parse_arguments( TARGET "${options}" "${oneValueArgs}" "${multiValueArgs}" ${ARGN} ) - if( NOT VULKAN_HPP_SAMPLES_BUILD_ONLY_DYNAMIC ) - if( NOT TARGET_NAME ) - message( FATAL_ERROR "NAME must be defined in vulkan_hpp__setup_sample_static" ) - endif() - - find_package( Vulkan REQUIRED ) - - vulkan_hpp__setup_sample( - NAME ${TARGET_NAME} - FOLDER Samples - PCH - SOURCES ${TARGET_NAME}.cpp - LIBS ${Vulkan_LIBRARIES} ) - - target_compile_definitions( ${TARGET_NAME} PUBLIC VULKAN_HPP_DISPATCH_LOADER_DYNAMIC=0 ) + if( NOT TARGET_NAME ) + message( FATAL_ERROR "NAME must be defined in vulkan_hpp__setup_sample_static" ) endif() + + find_package( Vulkan REQUIRED ) + + vulkan_hpp__setup_sample( + NAME ${TARGET_NAME} + FOLDER Samples + PCH + SOURCES ${TARGET_NAME}.cpp + LIBS ${Vulkan_LIBRARIES} ) + + target_compile_definitions( ${TARGET_NAME} PUBLIC VULKAN_HPP_DISPATCH_LOADER_DYNAMIC=0 ) endfunction() function( vulkan_hpp__setup_sample_dynamic ) diff --git a/samples/01_InitInstance/CMakeLists.txt b/samples/01_InitInstance/CMakeLists.txt index 32d9db4..bae13fc 100644 --- a/samples/01_InitInstance/CMakeLists.txt +++ b/samples/01_InitInstance/CMakeLists.txt @@ -12,4 +12,7 @@ # See the License for the specific language governing permissions and # limitations under the License. -vulkan_hpp__setup_sample_static( NAME 01_InitInstance ) +find_package( Vulkan QUIET ) +if ( Vulkan_FOUND ) + vulkan_hpp__setup_sample_static( NAME 01_InitInstance ) +endif() diff --git a/samples/CreateDebugUtilsMessenger/CMakeLists.txt b/samples/CreateDebugUtilsMessenger/CMakeLists.txt index bd9614b..6f03883 100644 --- a/samples/CreateDebugUtilsMessenger/CMakeLists.txt +++ b/samples/CreateDebugUtilsMessenger/CMakeLists.txt @@ -12,4 +12,7 @@ # See the License for the specific language governing permissions and # limitations under the License. -vulkan_hpp__setup_sample_static( NAME CreateDebugUtilsMessenger ) +find_package( Vulkan QUIET ) +if ( Vulkan_FOUND ) + vulkan_hpp__setup_sample_static( NAME CreateDebugUtilsMessenger ) +endif() diff --git a/samples/InstanceExtensionProperties/CMakeLists.txt b/samples/InstanceExtensionProperties/CMakeLists.txt index 635ea2b..2f35c19 100644 --- a/samples/InstanceExtensionProperties/CMakeLists.txt +++ b/samples/InstanceExtensionProperties/CMakeLists.txt @@ -12,4 +12,7 @@ # See the License for the specific language governing permissions and # limitations under the License. -vulkan_hpp__setup_sample_static( NAME InstanceExtensionProperties ) +find_package( Vulkan QUIET ) +if ( Vulkan_FOUND ) + vulkan_hpp__setup_sample_static( NAME InstanceExtensionProperties ) +endif() diff --git a/samples/InstanceLayerExtensionProperties/CMakeLists.txt b/samples/InstanceLayerExtensionProperties/CMakeLists.txt index 1af3441..d92a748 100644 --- a/samples/InstanceLayerExtensionProperties/CMakeLists.txt +++ b/samples/InstanceLayerExtensionProperties/CMakeLists.txt @@ -12,4 +12,7 @@ # See the License for the specific language governing permissions and # limitations under the License. -vulkan_hpp__setup_sample_static( NAME InstanceLayerExtensionProperties ) +find_package( Vulkan QUIET ) +if ( Vulkan_FOUND ) + vulkan_hpp__setup_sample_static( NAME InstanceLayerExtensionProperties ) +endif() diff --git a/samples/InstanceLayerProperties/CMakeLists.txt b/samples/InstanceLayerProperties/CMakeLists.txt index f3080f7..1e74286 100644 --- a/samples/InstanceLayerProperties/CMakeLists.txt +++ b/samples/InstanceLayerProperties/CMakeLists.txt @@ -12,4 +12,7 @@ # See the License for the specific language governing permissions and # limitations under the License. -vulkan_hpp__setup_sample_static( NAME InstanceLayerProperties ) +find_package( Vulkan QUIET ) +if ( Vulkan_FOUND ) + vulkan_hpp__setup_sample_static( NAME InstanceLayerProperties ) +endif() diff --git a/samples/InstanceVersion/CMakeLists.txt b/samples/InstanceVersion/CMakeLists.txt index b6cfbf4..46ee1ee 100644 --- a/samples/InstanceVersion/CMakeLists.txt +++ b/samples/InstanceVersion/CMakeLists.txt @@ -12,4 +12,7 @@ # See the License for the specific language governing permissions and # limitations under the License. -vulkan_hpp__setup_sample_static( NAME InstanceVersion ) +find_package( Vulkan QUIET ) +if ( Vulkan_FOUND ) + vulkan_hpp__setup_sample_static( NAME InstanceVersion ) +endif()