From e6a4529e591ae1688aa995732f2f729bffb3226a Mon Sep 17 00:00:00 2001 From: Danny Robson Date: Fri, 26 May 2017 16:33:29 +1000 Subject: [PATCH] info-tool: add simple json-like information query --- CMakeLists.txt | 14 ++++++++++++++ tools/info.cpp | 36 ++++++++++++++++++++++++++++++++++++ 2 files changed, 50 insertions(+) create mode 100644 tools/info.cpp diff --git a/CMakeLists.txt b/CMakeLists.txt index ed8a606..61a76d3 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -91,6 +91,8 @@ list (APPEND sources ##----------------------------------------------------------------------------- add_library (cruft-vk STATIC ${sources}) +target_link_libraries (cruft-vk cruft-util vulkan) + ############################################################################### get_directory_property (HAS_PARENT PARENT_DIRECTORY) @@ -99,6 +101,18 @@ if (HAS_PARENT) endif () +############################################################################### +foreach (t info) + add_executable (vk_${t} "tools/${t}.cpp") + set_target_properties(vk_${t} PROPERTIES + OUTPUT_NAME + ${t}) + set_target_properties(vk_${t} PROPERTIES + RUNTIME_OUTPUT_DIRECTORY + "${CMAKE_CURRENT_BINARY_DIR}/tools") + target_link_libraries (vk_${t} cruft-vk) +endforeach () + ############################################################################### configure_file(libcruft-vk-system.pc.in libcruft-vk.pc) configure_file(Doxyfile.in Doxyfile) diff --git a/tools/info.cpp b/tools/info.cpp new file mode 100644 index 0000000..2c2a760 --- /dev/null +++ b/tools/info.cpp @@ -0,0 +1,36 @@ +/* + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + * Copyright: + * 2017, Danny Robson + */ + +#include +#include +#include + +#include + +/////////////////////////////////////////////////////////////////////////////// +int +main (int, char**) +{ + cruft::vk::instance instance (cruft::vk::instance::create_info {}); + std::cout << "instance: " << instance << '\n'; + + auto devices = cruft::vk::physical_device::find (instance); + + for (const auto &d: devices) { + std::cout << d << '\n'; + } +} \ No newline at end of file