diff options
author | Brad King <brad.king@kitware.com> | 2016-06-08 16:56:07 (GMT) |
---|---|---|
committer | CMake Topic Stage <kwrobot@kitware.com> | 2016-06-08 16:56:07 (GMT) |
commit | fb8b8dd1060f78729da7b79c7eea06601681b678 (patch) | |
tree | b020f28939c1da24c2018b633095c5a7a09391f6 /Tests | |
parent | 5804068c220e2f9870dbcb24ee68eb610c9b4ff4 (diff) | |
parent | adf4df28caf621569d9d0d62011fc38773710319 (diff) | |
download | CMake-fb8b8dd1060f78729da7b79c7eea06601681b678.zip CMake-fb8b8dd1060f78729da7b79c7eea06601681b678.tar.gz CMake-fb8b8dd1060f78729da7b79c7eea06601681b678.tar.bz2 |
Merge topic 'add-FindVulkan'
adf4df28 Add FindVulkan.cmake.
Diffstat (limited to 'Tests')
-rw-r--r-- | Tests/CMakeLists.txt | 4 | ||||
-rw-r--r-- | Tests/FindVulkan/CMakeLists.txt | 10 | ||||
-rw-r--r-- | Tests/FindVulkan/Test/CMakeLists.txt | 15 | ||||
-rw-r--r-- | Tests/FindVulkan/Test/main.c | 29 |
4 files changed, 58 insertions, 0 deletions
diff --git a/Tests/CMakeLists.txt b/Tests/CMakeLists.txt index 9442ea7..bb24b33 100644 --- a/Tests/CMakeLists.txt +++ b/Tests/CMakeLists.txt @@ -1405,6 +1405,10 @@ ${CMake_BINARY_DIR}/bin/cmake -DDIR=dev -P ${CMake_SOURCE_DIR}/Utilities/Release add_subdirectory(FindTIFF) endif() + if(CMake_TEST_FindVulkan) + add_subdirectory(FindVulkan) + endif() + if(CMake_TEST_FindXalanC) add_subdirectory(FindXalanC) endif() diff --git a/Tests/FindVulkan/CMakeLists.txt b/Tests/FindVulkan/CMakeLists.txt new file mode 100644 index 0000000..46ce1c6 --- /dev/null +++ b/Tests/FindVulkan/CMakeLists.txt @@ -0,0 +1,10 @@ +add_test(NAME FindVulkan.Test COMMAND + ${CMAKE_CTEST_COMMAND} -C $<CONFIGURATION> + --build-and-test + "${CMake_SOURCE_DIR}/Tests/FindVulkan/Test" + "${CMake_BINARY_DIR}/Tests/FindVulkan/Test" + ${build_generator_args} + --build-project TestFindVulkan + --build-options ${build_options} + --test-command ${CMAKE_CTEST_COMMAND} -V -C $<CONFIGURATION> + ) diff --git a/Tests/FindVulkan/Test/CMakeLists.txt b/Tests/FindVulkan/Test/CMakeLists.txt new file mode 100644 index 0000000..0b13d53 --- /dev/null +++ b/Tests/FindVulkan/Test/CMakeLists.txt @@ -0,0 +1,15 @@ +cmake_minimum_required(VERSION 3.4) +project(TestFindVulkan C) +include(CTest) + +SET(CMAKE_MODULE_PATH ${PROJECT_SOURCE_DIR}/../../) +find_package(Vulkan REQUIRED) + +add_executable(test_tgt main.c) +target_link_libraries(test_tgt Vulkan::Vulkan) +add_test(NAME test_tgt COMMAND test_tgt) + +add_executable(test_var main.c) +target_include_directories(test_var PRIVATE ${Vulkan_INCLUDE_DIRS}) +target_link_libraries(test_var PRIVATE ${Vulkan_LIBRARIES}) +add_test(NAME test_var COMMAND test_var) diff --git a/Tests/FindVulkan/Test/main.c b/Tests/FindVulkan/Test/main.c new file mode 100644 index 0000000..78dcb65 --- /dev/null +++ b/Tests/FindVulkan/Test/main.c @@ -0,0 +1,29 @@ +#include <vulkan/vulkan.h> + +int main() +{ + VkInstanceCreateInfo instanceCreateInfo = {}; + instanceCreateInfo.sType = VK_STRUCTURE_TYPE_INSTANCE_CREATE_INFO; + + VkApplicationInfo applicationInfo = {}; + applicationInfo.sType = VK_STRUCTURE_TYPE_APPLICATION_INFO; + applicationInfo.apiVersion = VK_API_VERSION_1_0; + applicationInfo.applicationVersion = VK_MAKE_VERSION(1, 0, 0); + applicationInfo.engineVersion = VK_MAKE_VERSION(1, 0, 0); + applicationInfo.pApplicationName = "CMake Test application"; + applicationInfo.pEngineName = "CMake Test Engine"; + + instanceCreateInfo.pApplicationInfo = &applicationInfo; + + VkInstance instance = VK_NULL_HANDLE; + vkCreateInstance(&instanceCreateInfo, NULL, &instance); + + // We can't assert here because in general vkCreateInstance will return an + // error if no driver is found - but if we get here, FindVulkan is working + + if (instance != VK_NULL_HANDLE) { + vkDestroyInstance (instance, NULL); + } + + return 0; +} |