### Install Linux Build Dependencies Source: https://github.com/khronosgroup/vulkan-tools/blob/main/BUILD.md Install essential build tools and WSI system libraries required for building on Ubuntu LTS. ```bash sudo apt-get install git build-essential python3 cmake # Linux WSI system libraries sudo apt-get install libwayland-dev xorg-dev ``` -------------------------------- ### Install 32-bit Linux Build Dependencies Source: https://github.com/khronosgroup/vulkan-tools/blob/main/BUILD.md Install necessary 32-bit libraries and configure environment variables for building 32-bit targets on a 64-bit Ubuntu system. ```bash # 32-bit libs # your PKG_CONFIG configuration may be different, depending on your distribution sudo apt-get install gcc-multilib g++-multilib libx11-dev:i386 export ASFLAGS=--32 export CFLAGS=-m32 export CXXFLAGS=-m32 export PKG_CONFIG_LIBDIR=/usr/lib/i386-linux-gnu ``` -------------------------------- ### Install Vulkaninfo Target Source: https://github.com/khronosgroup/vulkan-tools/blob/main/vulkaninfo/CMakeLists.txt Installs the built vulkaninfo target. ```cmake install(TARGETS vulkaninfo) ``` -------------------------------- ### Install Java Runtime Environment Source: https://github.com/khronosgroup/vulkan-tools/blob/main/BUILD.md Installs the default Java Runtime Environment on Debian-based systems if 'apksigner' reports a 'java: not found' error, indicating Java is not in the system's PATH. ```bash sudo apt install default-jre ``` -------------------------------- ### Install vkcubepp Source: https://github.com/khronosgroup/vulkan-tools/blob/main/cube/CMakeLists.txt Installs the vkcubepp executable. For Apple platforms, it includes runtime dependencies and sets the install rpath. Otherwise, it installs the target directly. ```cmake if(APPLE) install( TARGETS vkcubepp # Install runtime dependencies like the Vulkan::Loader so the app is self-contained RUNTIME_DEPENDENCIES DESTINATION "cube/vkcubepp.app/Contents/Frameworks/" BUNDLE DESTINATION "cube" ) set_target_properties(vkcubepp PROPERTIES INSTALL_RPATH @executable_path/../Frameworks ) else() install(TARGETS vkcubepp) endif() ``` -------------------------------- ### Install Mock ICD Option Source: https://github.com/khronosgroup/vulkan-tools/blob/main/icd/CMakeLists.txt An option to control whether the mock ICD should be installed. By default, installation is disabled to avoid installing an incomplete implementation. ```cmake option(INSTALL_ICD "Install Mock icd") if (INSTALL_ICD) message(NOTICE "INSTALL_ICD enabled!") else() return() endif() ``` -------------------------------- ### Install and Run vkcube on Android Source: https://github.com/khronosgroup/vulkan-tools/blob/main/tests/README.md Installs the vkcube APK onto an Android device and launches the application. Ensure Vulkan-Tools is built for Android first. ```sh cd Vulkan-Tools cd build-android # Optional adb uninstall com.example.VkCube adb install -r -g --no-incremental bin/VkCube.apk adb shell am start com.example.VkCube/android.app.NativeActivity ``` -------------------------------- ### Run Vulkan Info (Default) Source: https://github.com/khronosgroup/vulkan-tools/blob/main/vulkaninfo/vulkaninfo.md Execute the vulkaninfo program without any arguments to get human-readable output to the console. This is the default behavior. ```bash vulkaninfo ``` -------------------------------- ### Install Release Artifacts using CMake Source: https://github.com/khronosgroup/vulkan-tools/blob/main/BUILD.md Use this command to install the built Release artifacts into a specified directory. The `--config` flag is only necessary for multi-configuration generators like Visual Studio or Xcode. ```sh cmake --install build/ --config Release --prefix build/install ``` -------------------------------- ### Install vkcube Source: https://github.com/khronosgroup/vulkan-tools/blob/main/cube/CMakeLists.txt Installs the vkcube executable based on the target platform. For Android, it's installed to the library directory. For Apple, it includes runtime dependencies and sets the install rpath. ```cmake if (ANDROID) install(TARGETS vkcube DESTINATION ${CMAKE_INSTALL_LIBDIR}) elseif(APPLE) install( TARGETS vkcube # Install runtime dependencies like the Vulkan::Loader so the app is self-contained RUNTIME_DEPENDENCIES DESTINATION "cube/vkcube.app/Contents/Frameworks/" BUNDLE DESTINATION "cube" ) set_target_properties(vkcube PROPERTIES INSTALL_RPATH @executable_path/../Frameworks ) else() install(TARGETS vkcube) endif() ``` -------------------------------- ### Install Shared STL Libraries for Android Source: https://github.com/khronosgroup/vulkan-tools/blob/main/cube/android/CMakeLists.txt Conditionally installs the libc++_shared.so library if CMAKE_ANDROID_STL_TYPE is set to 'shared'. It reads NDK meta information to determine the correct path. ```cmake if ("${CMAKE_ANDROID_STL_TYPE}" MATCHES "shared") file(READ "${CMAKE_ANDROID_NDK}/meta/abis.json" JSON_FILE) string(JSON TRIPLE GET "${JSON_FILE}" "${CMAKE_ANDROID_ARCH_ABI}" "triple") install(FILES "${CMAKE_SYSROOT}/usr/lib/${TRIPLE}/libc++_shared.so" DESTINATION "${CMAKE_INSTALL_LIBDIR}") endif() ``` -------------------------------- ### Generate Visual Studio Project Files with CMake Source: https://github.com/khronosgroup/vulkan-tools/blob/main/BUILD.md Use CMake to generate Visual Studio project files for Windows development. CMake typically defaults to the latest installed Visual Studio version. ```bash # NOTE: By default CMake picks the latest version of Visual Studio as the default generator. cmake -S . -B build ``` -------------------------------- ### UNIX Library Path Adjustment Source: https://github.com/khronosgroup/vulkan-tools/blob/main/icd/CMakeLists.txt Adjusts the library path for UNIX-based systems to remove relative path indicators before installation. This ensures correct system paths. ```cmake # For UNIX-based systems, `library_path` should not contain a relative path (indicated by "./") before installing to system directories ``` -------------------------------- ### macOS MoltenVK ICD Configuration Source: https://github.com/khronosgroup/vulkan-tools/blob/main/cube/CMakeLists.txt Configures the MoltenVK ICD (Installable Client Driver) for macOS, adjusting the library path in the JSON file to correctly point to the Frameworks directory. ```cmake if(APPLE) option(APPLE_USE_SYSTEM_ICD "Use system Vulkan loader for ICD discovery" OFF) if(APPLE_USE_SYSTEM_ICD) message(STATUS "Using system Vulkan loader for ICD discovery") else() set(MOLTENVK_REPO_ROOT "MOLTENVK-NOTFOUND" CACHE PATH "Absolute path to a MoltenVK repo directory") if(NOT MOLTENVK_REPO_ROOT) message(FATAL_ERROR "Must define location of MoltenVK repo -- see BUILD.md") endif() message(STATUS "Using MoltenVK repo location at ${MOLTENVK_REPO_ROOT}") # Source for the MoltenVK ICD library and JSON file set(MOLTENVK_DIR ${MOLTENVK_REPO_ROOT}) # MoltenVK JSON File execute_process(COMMAND mkdir -p ${PROJECT_BINARY_DIR}/staging-json) execute_process(COMMAND sed -e "/\"library_path\":/s$:[[:space:]]*\"[[:space:]]*[\.\/]*$: \"..\/..\/..\/Frameworks\/$" ${MOLTENVK_DIR}/MoltenVK/icd/MoltenVK_icd.json OUTPUT_FILE ${PROJECT_BINARY_DIR}/staging-json/MoltenVK_icd.json) # ~~ # Modify the ICD JSON file to adjust the library path. # The ICD JSON file goes in the Resources/vulkan/icd.d directory, so adjust the # library_path to the relative path to the Frameworks directory in the bundle. # The regex does: substitute ':"' with: # ': "../../../Frameworks/' # ~~ add_custom_target(MoltenVK_icd-staging-json ALL COMMAND mkdir -p ${PROJECT_BINARY_DIR}/staging-json COMMAND sed -e "/\"library_path\":/s$:[[:space:]]*\"[[:space:]]*[\.\/]*$: \"..\/..\/..\/Frameworks\/$" ${MOLTENVK_REPO_ROOT}/MoltenVK/icd/MoltenVK_icd.json > ${PROJECT_BINARY_DIR}/staging-json/MoltenVK_icd.json VERBATIM DEPENDS "${MOLTENVK_REPO_ROOT}/MoltenVK/icd/MoltenVK_icd.json" ) set_source_files_properties(${PROJECT_BINARY_DIR}/staging-json/MoltenVK_icd.json PROPERTIES GENERATED TRUE) endif() find_library(COCOA NAMES Cocoa) # Locate Interface Builder Tool, needed to build things like Storyboards outside of Xcode. if(NOT XCODE) # Make sure we can find the 'ibtool' program. If we can NOT find it we skip generation of this project. find_program(IBTOOL ibtool HINTS "/usr/bin" "${OSX_DEVELOPER_ROOT}/usr/bin") if(${IBTOOL} STREQUAL "IBTOOL-NOTFOUND") message(SEND_ERROR "ibtool can not be found and is needed to compile the .xib files. " "It should have been installed with the Apple developer tools. " "The default system paths were searched in addition to ${OSX_DEVELOPER_ROOT}/usr/bin.") endif() endif() endif() ``` -------------------------------- ### Basic Build Overview with CMake Source: https://github.com/khronosgroup/vulkan-tools/blob/main/BUILD.md Clone the repository and configure CMake with common build options. This is sufficient for most users. ```bash git clone https://github.com/KhronosGroup/Vulkan-Tools.git cd Vulkan-Tools cmake -S . -B build -D UPDATE_DEPS=ON -D BUILD_WERROR=ON -D BUILD_TESTS=ON -D CMAKE_BUILD_TYPE=Debug cmake --build build --config Debug ``` -------------------------------- ### Run Vulkan Info (JSON Output) Source: https://github.com/khronosgroup/vulkan-tools/blob/main/vulkaninfo/vulkaninfo.md Generate a JSON version of Vulkan Info output conforming to the Vulkan Profiles schema. By default, it targets the first GPU. The output file is named "VP_VULKANINFO_[DEVICE_NAME]_[DRIVER_VERSION].json". ```bash vulkaninfo --json ``` -------------------------------- ### Run Vulkan Info (HTML Output) Source: https://github.com/khronosgroup/vulkan-tools/blob/main/vulkaninfo/vulkaninfo.md Use the --html option to generate an HTML version of the Vulkan Info output. The output is saved to a file named "vulkaninfo.html" in the current directory. ```bash vulkaninfo --html ``` -------------------------------- ### Run vulkaninfo Source: https://github.com/khronosgroup/vulkan-tools/blob/main/CONTRIBUTING.md Execute the vulkaninfo tool to display Vulkan device information. This is a Linux-specific instruction. ```bash vulkaninfo ``` -------------------------------- ### Linux WSI Support Options Source: https://github.com/khronosgroup/vulkan-tools/blob/main/vulkaninfo/CMakeLists.txt Configures build options for Window System Integration (WSI) support on Linux systems, including XCB, Xlib, Wayland, and DirectFB. Defaults are set, and specific libraries are checked using PkgConfig. ```cmake if (CMAKE_SYSTEM_NAME MATCHES "Linux|BSD|GNU") option(BUILD_WSI_XCB_SUPPORT "Build XCB WSI support" ON) option(BUILD_WSI_XLIB_SUPPORT "Build Xlib WSI support" ON) option(BUILD_WSI_WAYLAND_SUPPORT "Build Wayland WSI support" ON) option(BUILD_WSI_DIRECTFB_SUPPORT "Build DirectFB WSI support" OFF) find_package(PkgConfig REQUIRED QUIET) # Use PkgConfig to find Linux system libraries if(BUILD_WSI_XCB_SUPPORT) pkg_check_modules(XCB REQUIRED QUIET IMPORTED_TARGET xcb) target_compile_definitions(vulkaninfo PRIVATE VK_USE_PLATFORM_XCB_KHR) target_link_libraries(vulkaninfo PRIVATE PkgConfig::XCB) endif() if(BUILD_WSI_XLIB_SUPPORT) pkg_check_modules(X11 REQUIRED QUIET IMPORTED_TARGET x11) target_compile_definitions(vulkaninfo PRIVATE VK_USE_PLATFORM_XLIB_KHR) target_link_libraries(vulkaninfo PRIVATE PkgConfig::X11) endif() if(BUILD_WSI_WAYLAND_SUPPORT) pkg_check_modules(WAYLAND_CLIENT REQUIRED IMPORTED_TARGET wayland-client) target_compile_definitions(vulkaninfo PRIVATE VK_USE_PLATFORM_WAYLAND_KHR) target_link_libraries(vulkaninfo PRIVATE PkgConfig::WAYLAND_CLIENT) endif() if(BUILD_WSI_DIRECTFB_SUPPORT) pkg_check_modules(DirectFB REQUIRED QUIET IMPORTED_TARGET directfb) target_compile_definitions(vulkaninfo PRIVATE VK_USE_PLATFORM_DIRECTFB_EXT) target_link_libraries(vulkaninfo PRIVATE PkgConfig::DirectFB) endif() target_compile_definitions(vulkaninfo PRIVATE VK_USE_PLATFORM_DISPLAY) endif() ``` -------------------------------- ### Vulkan Info Command Line Options Source: https://github.com/khronosgroup/vulkan-tools/blob/main/vulkaninfo/vulkaninfo.md Display a comprehensive list of available options for the vulkaninfo command, including output formats, filtering, and help. ```bash vulkaninfo - Summarize Vulkan information in relation to the current environment. USAGE: vulkaninfo --summary vulkaninfo -o | --output vulkaninfo -j | -j= | --json | --json= vulkaninfo --text vulkaninfo --html vulkaninfo --show-all vulkaninfo --show-formats OPTIONS: [-h, --help] Print this help. [--summary] Show a summary of the instance and GPU's on a system. [-o , --output ] Print output to a new file whose name is specified by filename. File will be written to the current working directory. [--text] Produce a text version of vulkaninfo output to stdout. This is the default output. [--html] Produce an html version of vulkaninfo output, saved as "vulkaninfo.html" in the directory in which the command is run. [-j, --json] Produce a json version of vulkaninfo output conforming to the Vulkan Profiles schema, saved as "VP_VULKANINFO_[DEVICE_NAME]_[DRIVER_VERSION].json" of the first gpu in the system. [-j=, --json=] For a multi-gpu system, a single gpu can be targeted by specifying the gpu-number associated with the gpu of interest. This number can be determined by running vulkaninfo without any options specified. [--show-all] Show everything (includes all the below options) [--show-formats] Display the format properties of each physical device. Note: This only affects text output. [--show-tool-props] Show the active VkPhysicalDeviceToolPropertiesEXT that vulkaninfo finds. [--show-promoted-structs] Include structs promoted to core in pNext Chains. [--show-video-props] Display the video profile info, video capabilities and video format properties of each video profile supported by each physical device. Note: This only affects text output which by default only contains the list of supported video profile names. ``` -------------------------------- ### Create and Open Xcode Project Source: https://github.com/khronosgroup/vulkan-tools/blob/main/BUILD.md Generates an Xcode project for macOS development and then opens it. This command is used when targeting macOS with the Xcode generator. ```bash cmake -S . -B build -G Xcode cmake --open build ``` -------------------------------- ### WSI Display Support Option Source: https://github.com/khronosgroup/vulkan-tools/blob/main/cube/CMakeLists.txt Sets the default value for the BUILD_WSI_DISPLAY_SUPPORT option based on the operating system. It's ON by default for Linux/BSD/GNU and OFF for Android/macOS. ```cmake if(ANDROID OR APPLE) set(WSI_DISPLAY_DEFAULT_SETTING "OFF") else() set(WSI_DISPLAY_DEFAULT_SETTING "ON") endif() option(BUILD_WSI_DISPLAY_SUPPORT "Build DISPLAY WSI support" ${WSI_DISPLAY_DEFAULT_SETTING}) ``` -------------------------------- ### Common vkcubepp Build Configurations Source: https://github.com/khronosgroup/vulkan-tools/blob/main/cube/CMakeLists.txt Applies common include directories and compile definitions for vkcubepp, and links essential libraries. ```cmake target_include_directories(vkcubepp PRIVATE .) target_compile_definitions(vkcubepp PRIVATE ${ENABLED_CUBE_PLATFORMS}) target_link_libraries(vkcubepp ${CMAKE_DL_LIBS} Vulkan::Headers) ``` -------------------------------- ### Run Vulkan Info (JSON Output for Specific GPU) Source: https://github.com/khronosgroup/vulkan-tools/blob/main/vulkaninfo/vulkaninfo.md For systems with multiple GPUs, target a specific GPU for JSON output using the --json= option. The GPU number can be determined by running vulkaninfo without options first. ```bash vulkaninfo -j=0 ``` -------------------------------- ### Build Android Release Binaries for All ABIs with android.py Source: https://github.com/khronosgroup/vulkan-tools/blob/main/BUILD.md Builds release binaries for multiple Android ABIs (Application Binary Interfaces) using the android.py script. This command streamlines building for various architectures. ```bash # Build release binaries for all ABIs python3 scripts/android.py --config Release --app-abi 'armeabi-v7a arm64-v8a x86 x86_64' --app-stl c++_static ``` -------------------------------- ### Open Visual Studio Solution Source: https://github.com/khronosgroup/vulkan-tools/blob/main/BUILD.md Opens the generated Visual Studio solution file. Ensure CMake is configured to use a Visual Studio generator. ```bash cmake --open build ``` -------------------------------- ### Define Linux/BSD Xlib Platform Source: https://github.com/khronosgroup/vulkan-tools/blob/main/cube/CMakeLists.txt Enables the VK_USE_PLATFORM_XLIB_KHR extension for Vulkan WSI on Linux/BSD systems using Xlib. ```cmake list(APPEND ENABLED_CUBE_PLATFORMS VK_USE_PLATFORM_XLIB_KHR) ``` -------------------------------- ### Build Android Debug APK with android.py Source: https://github.com/khronosgroup/vulkan-tools/blob/main/BUILD.md Creates a complete Android APK with debug binaries for all specified ABIs using the android.py script. This command is used for building and packaging the application. ```bash # Build a complete APK with debug binaries for all ABIS python3 scripts/android.py --config Debug --app-abi 'armeabi-v7a arm64-v8a x86 x86_64' --app-stl c++_shared --apk ``` -------------------------------- ### Build Android Release APK with android.py and Clean Source: https://github.com/khronosgroup/vulkan-tools/blob/main/BUILD.md Builds a clean Android APK with release binaries for arm64-v8a using the android.py script. The --clean flag ensures a fresh build process. ```bash # Build a clean APK with release binaries for arm64-v8a python3 scripts/android.py --config Release --app-abi arm64-v8a --app-stl c++_shared --apk --clean ``` -------------------------------- ### Define Linux/BSD XCB Platform Source: https://github.com/khronosgroup/vulkan-tools/blob/main/cube/CMakeLists.txt Enables the VK_USE_PLATFORM_XCB_KHR extension for Vulkan WSI on Linux/BSD systems using XCB. ```cmake list(APPEND ENABLED_CUBE_PLATFORMS VK_USE_PLATFORM_XCB_KHR) ``` -------------------------------- ### Run vulkaninfo on Android Source: https://github.com/khronosgroup/vulkan-tools/blob/main/tests/README.md Builds vulkaninfo for Android, pushes it to the device, executes it to generate JSON output, and pulls the output file. This method does not require creating an APK. ```sh cd Vulkan-Tools scripts/android.py --config Release --app-abi arm64-v8a --app-stl c++_static --clean adb push build-android/cmake/arm64-v8a/vulkaninfo/vulkaninfo /data/local/tmp adb shell /data/local/tmp/vulkaninfo --json --output /data/local/tmp/foobar.json adb pull /data/local/tmp/foobar.json ``` -------------------------------- ### Build Android Release Binaries with android.py Source: https://github.com/khronosgroup/vulkan-tools/blob/main/BUILD.md Uses the android.py script to build release binaries for the arm64-v8a architecture. This is an alternative to direct CMake invocation for building binaries. ```bash # Build release binaries for arm64-v8a python3 scripts/android.py --config Release --app-abi arm64-v8a --app-stl c++_static ``` -------------------------------- ### Common vkcube Build Configurations Source: https://github.com/khronosgroup/vulkan-tools/blob/main/cube/CMakeLists.txt Applies common compile definitions and include directories for vkcube, and links essential libraries. ```cmake target_compile_definitions(vkcube PRIVATE ${ENABLED_CUBE_PLATFORMS}) target_include_directories(vkcube PRIVATE .) target_link_libraries(vkcube ${CMAKE_DL_LIBS} Vulkan::Headers) ``` -------------------------------- ### Define Linux/BSD Wayland Platform Source: https://github.com/khronosgroup/vulkan-tools/blob/main/cube/CMakeLists.txt Enables the VK_USE_PLATFORM_WAYLAND_KHR extension for Vulkan WSI on Linux/BSD systems using Wayland. ```cmake list(APPEND ENABLED_CUBE_PLATFORMS VK_USE_PLATFORM_WAYLAND_KHR) ``` -------------------------------- ### Define Apple (Metal) Platform Source: https://github.com/khronosgroup/vulkan-tools/blob/main/cube/CMakeLists.txt Enables the VK_USE_PLATFORM_METAL_EXT extension for Vulkan WSI on Apple platforms. ```cmake list(APPEND ENABLED_CUBE_PLATFORMS VK_USE_PLATFORM_METAL_EXT) ``` -------------------------------- ### Build Mock ICD Library Source: https://github.com/khronosgroup/vulkan-tools/blob/main/icd/CMakeLists.txt Configures the mock ICD library, including sources, Vulkan headers, and include directories. Adjust compile options for different compilers. ```cmake add_library(VkICD_mock_icd MODULE) target_sources(VkICD_mock_icd PRIVATE mock_icd.cpp) target_link_libraries(VkICD_mock_icd PRIVATE Vulkan::Headers) target_include_directories(VkICD_mock_icd PRIVATE ${GENERATED} . ) ``` -------------------------------- ### Define Linux/BSD DirectFB Platform Source: https://github.com/khronosgroup/vulkan-tools/blob/main/cube/CMakeLists.txt Enables the VK_USE_PLATFORM_DIRECTFB_EXT extension for Vulkan WSI on Linux/BSD systems using DirectFB. ```cmake list(APPEND ENABLED_CUBE_PLATFORMS VK_USE_PLATFORM_DIRECTFB_EXT) ``` -------------------------------- ### Linux/BSD WSI Support Options Source: https://github.com/khronosgroup/vulkan-tools/blob/main/cube/CMakeLists.txt Enables or disables various Window System Integration (WSI) support options for Linux, BSD, and GNU systems. XCB, Xlib, and Wayland are enabled by default, while DirectFB is disabled. ```cmake if (CMAKE_SYSTEM_NAME MATCHES "Linux|BSD|GNU") option(BUILD_WSI_XCB_SUPPORT "Build XCB WSI support" ON) option(BUILD_WSI_XLIB_SUPPORT "Build Xlib WSI support" ON) option(BUILD_WSI_WAYLAND_SUPPORT "Build Wayland WSI support" ON) option(BUILD_WSI_DIRECTFB_SUPPORT "Build DirectFB WSI support" OFF) find_package(PkgConfig REQUIRED QUIET) # Use PkgConfig to find Linux system libraries if(BUILD_WSI_XCB_SUPPORT) pkg_check_modules(XCB REQUIRED QUIET IMPORTED_TARGET xcb) pkg_get_variable(XCB_INCLUDE_DIRS xcb includedir) message(DEBUG "XCB_INCLUDE_DIRS = ${XCB_INCLUDE_DIRS}") endif() if(BUILD_WSI_XLIB_SUPPORT) pkg_check_modules(X11 REQUIRED QUIET IMPORTED_TARGET x11) pkg_get_variable(XLIB_INCLUDE_DIRS x11 includedir) message(DEBUG "XLIB_INCLUDE_DIRS = ${XLIB_INCLUDE_DIRS}") endif() if(BUILD_WSI_WAYLAND_SUPPORT) pkg_check_modules(WAYLAND_CLIENT REQUIRED IMPORTED_TARGET wayland-client) pkg_get_variable(WAYLAND_INCLUDE_DIRS wayland-client includedir) pkg_check_modules(WAYLAND_SCANNER REQUIRED wayland-scanner) pkg_get_variable(WAYLAND_SCANNER_EXECUTABLE wayland-scanner wayland_scanner) message(DEBUG "WAYLAND_SCANNER_EXECUTABLE = ${WAYLAND_SCANNER_EXECUTABLE}") pkg_get_variable(WAYLAND_CLIENT_PATH wayland-client pkgdatadir) message(DEBUG "WAYLAND_CLIENT_PATH = ${WAYLAND_CLIENT_PATH}") set(WAYLAND_CODE_PROTOCOL ${WAYLAND_CLIENT_PATH}/wayland.xml) pkg_check_modules(WAYLAND_PROTOCOLS REQUIRED wayland-protocols) pkg_get_variable(WAYLAND_PROTOCOLS_PATH wayland-protocols pkgdatadir) message(DEBUG "WAYLAND_PROTOCOLS_PATH = ${WAYLAND_PROTOCOLS_PATH}") set(XDG_SHELL_PROTOCOL ${WAYLAND_PROTOCOLS_PATH}/stable/xdg-shell/xdg-shell.xml) add_custom_command(COMMENT "Generating wayland client protocol dispatch data" OUTPUT wayland-client.c ``` -------------------------------- ### macOS Framework Linking and Sources Source: https://github.com/khronosgroup/vulkan-tools/blob/main/vulkaninfo/CMakeLists.txt Links the vulkaninfo target against AppKit and QuartzCore frameworks on macOS and includes platform-specific source files and include directories for Metal view integration. ```cmake if(APPLE) # We do this so vulkaninfo is linked to an individual library and NOT a framework. target_link_libraries(vulkaninfo PRIVATE "-framework AppKit -framework QuartzCore") target_include_directories(vulkaninfo PRIVATE macOS/vulkaninfo) target_sources(vulkaninfo PRIVATE macOS/vulkaninfo/metal_view.mm macOS/vulkaninfo/metal_view.h ) endif() ``` -------------------------------- ### Define Win32 Platform Source: https://github.com/khronosgroup/vulkan-tools/blob/main/cube/CMakeLists.txt Adds definitions for Win32 compilation and enables the VK_USE_PLATFORM_WIN32_KHR extension. This is for Windows-specific Vulkan WSI. ```cmake add_definitions(-DWIN32_LEAN_AND_MEAN -DNOMINMAX) list(APPEND ENABLED_CUBE_PLATFORMS VK_USE_PLATFORM_WIN32_KHR) ``` -------------------------------- ### Configure vkcubepp for Linux/BSD/GNU Source: https://github.com/khronosgroup/vulkan-tools/blob/main/cube/CMakeLists.txt Configures the vkcubepp executable for Linux, BSD, and GNU systems, including source files and linking necessary libraries. ```cmake add_executable(vkcubepp cube.cpp ${PROJECT_SOURCE_DIR}/cube/cube.vert ${PROJECT_SOURCE_DIR}/cube/cube.frag cube.vert.inc cube.frag.inc) target_link_libraries(vkcubepp Threads::Threads) if(BUILD_WSI_XCB_SUPPORT) target_sources(vkcubepp PRIVATE xcb_loader.h) target_include_directories(vkcubepp PRIVATE ${xcb_INCLUDE_DIRS}) endif() if(BUILD_WSI_XLIB_SUPPORT) target_sources(vkcubepp PRIVATE xlib_loader.h) target_include_directories(vkcubepp PRIVATE ${XLIB_INCLUDE_DIRS}) endif() if(BUILD_WSI_WAYLAND_SUPPORT) target_include_directories(vkcubepp PRIVATE ${WAYLAND_INCLUDE_DIRS} ${CMAKE_CURRENT_BINARY_DIR}) target_sources(vkcubepp PRIVATE ${WAYLAND_ADDITIONAL_SOURCES}) endif() if(BUILD_WSI_DIRECTFB_SUPPORT) target_link_libraries(vkcubepp PkgConfig::DirectFB) endif() ``` -------------------------------- ### Build Android Native App Glue Library Source: https://github.com/khronosgroup/vulkan-tools/blob/main/cube/android/CMakeLists.txt Creates an object library named 'android_glue' from the Android Native App Glue source files. ```cmake add_library(android_glue OBJECT) target_include_directories(android_glue PUBLIC ${native_app_glue_dir}) target_sources(android_glue PRIVATE ${native_app_glue_dir}/android_native_app_glue.c ${native_app_glue_dir}/android_native_app_glue.h ) ``` -------------------------------- ### Core Vulkan and Dynamic Library Linking Source: https://github.com/khronosgroup/vulkan-tools/blob/main/vulkaninfo/CMakeLists.txt Links the vulkaninfo target against the Vulkan::Headers target and the system's dynamic loading library. ```cmake target_link_libraries(vulkaninfo PRIVATE Vulkan::Headers ${CMAKE_DL_LIBS} ) ``` -------------------------------- ### Set Android Environment Variables Source: https://github.com/khronosgroup/vulkan-tools/blob/main/BUILD.md Configures essential environment variables for Android development, including SDK and NDK paths, and adds build tools to the system's PATH. Replace 'X.Y.Z' with your NDK version. ```bash # Set environment variables # https://github.com/actions/runner-images/blob/main/images/linux/Ubuntu2204-Readme.md#environment-variables-2 export ANDROID_SDK_ROOT=$HOME/Android/Sdk export ANDROID_NDK_HOME=$ANDROID_SDK_ROOT/ndk/X.Y.Z # Modify path export PATH=$ANDROID_SDK_ROOT/build-tools/X.Y.Z:$PATH # (Optional if you have new enough version of CMake + Ninja) export PATH=$ANDROID_SDK_ROOT/cmake/3.22.1/bin:$PATH # Verify SDK build-tools is set correctly which aapt # Verify CMake/Ninja are in the path which cmake which ninja # Check apksigner apksigner --help ``` -------------------------------- ### Link Math Library Source: https://github.com/khronosgroup/vulkan-tools/blob/main/cube/CMakeLists.txt Links the standard math library (m) to the executable. This is common for C/C++ applications on Unix-like systems. ```cmake link_libraries(${API_LOWERCASE} m) ``` -------------------------------- ### Configure vkcube for Windows Source: https://github.com/khronosgroup/vulkan-tools/blob/main/cube/CMakeLists.txt Configures the vkcube executable for Windows systems, specifying source files. ```cmake add_executable(vkcube WIN32) target_sources(vkcube PRIVATE cube.c ${PROJECT_SOURCE_DIR}/cube/cube.vert ${PROJECT_SOURCE_DIR}/cube/cube.frag cube.vert.inc cube.frag.inc ) ``` -------------------------------- ### Platform-Specific Definitions Source: https://github.com/khronosgroup/vulkan-tools/blob/main/icd/CMakeLists.txt Defines Vulkan platform extensions based on the operating system. Use these definitions to enable platform-specific WSI support. ```cmake if(WIN32) add_definitions(-DVK_USE_PLATFORM_WIN32_KHR -DVK_USE_PLATFORM_WIN32_KHX -DWIN32_LEAN_AND_MEAN) elseif(APPLE) add_definitions(-DVK_USE_PLATFORM_METAL_EXT) if (IOS) add_definitions(-DVK_USE_PLATFORM_IOS_MVK) else() add_definitions(-DVK_USE_PLATFORM_MACOS_MVK) endif() elseif(BUILD_MOCK_ANDROID_SUPPORT) add_definitions(-DVK_USE_PLATFORM_ANDROID_KHR) elseif(CMAKE_SYSTEM_NAME MATCHES "Linux|BSD|GNU") if(BUILD_WSI_XCB_SUPPORT) add_definitions(-DVK_USE_PLATFORM_XCB_KHR -DVK_USE_PLATFORM_XCB_KHX) endif() if(BUILD_WSI_XLIB_SUPPORT) add_definitions(-DVK_USE_PLATFORM_XLIB_KHR -DVK_USE_PLATFORM_XLIB_KHX -DVK_USE_PLATFORM_XLIB_XRANDR_EXT) endif() if(BUILD_WSI_WAYLAND_SUPPORT) add_definitions(-DVK_USE_PLATFORM_WAYLAND_KHR -DVK_USE_PLATFORM_WAYLAND_KHX) endif() else() message(FATAL_ERROR "Unsupported Platform!") endif() ``` -------------------------------- ### Define Android Platform Source: https://github.com/khronosgroup/vulkan-tools/blob/main/cube/CMakeLists.txt Enables the VK_USE_PLATFORM_ANDROID_KHR extension for Android Vulkan WSI support. ```cmake list(APPEND ENABLED_CUBE_PLATFORMS VK_USE_PLATFORM_ANDROID_KHR) ``` -------------------------------- ### Run vkcube with Validation Layers Source: https://github.com/khronosgroup/vulkan-tools/blob/main/CONTRIBUTING.md Execute the vkcube application with validation layers enabled to check for regressions. This is a Linux-specific instruction. ```bash vkcube vkcube --validate ``` -------------------------------- ### Format Changes with Git Clang-Format Source: https://github.com/khronosgroup/vulkan-tools/blob/main/CONTRIBUTING.md Use this command to format your code changes according to the repository's .clang-format file. Ensure you stage your changes before running the command. ```bash # Make changes to the source. git add -u . git clang-format --style=file # Check to see if clang-format made any changes and if they are OK. git add -u . git commit ``` -------------------------------- ### Generate XDG Decoration Client Header Source: https://github.com/khronosgroup/vulkan-tools/blob/main/cube/CMakeLists.txt Generates a client header file for the XDG decoration protocol. This provides Wayland client interfaces for XDG decoration. ```cmake COMMAND ${WAYLAND_SCANNER_EXECUTABLE} client-header ${XDG_DECORATION_PROTOCOL} ${CMAKE_CURRENT_BINARY_DIR}/xdg-decoration-client-header.h MAIN_DEPENDENCY ${XDG_DECORATION_PROTOCOL} DEPENDS ${XDG_DECORATION_PROTOCOL} ${WAYLAND_SCANNER_EXECUTABLE}) ``` -------------------------------- ### Compile Fragment Shader with glslangValidator Source: https://github.com/khronosgroup/vulkan-tools/blob/main/cube/CMakeLists.txt Uses a custom command to compile the fragment shader. Ensure glslangValidator is available in the build environment. ```cmake add_custom_command(COMMENT "Compiling cube fragment shader" OUTPUT ${CMAKE_CURRENT_SOURCE_DIR}/cube.frag.inc COMMAND ${GLSLANG_VALIDATOR} -V -x -o ${CMAKE_CURRENT_SOURCE_DIR}/cube.frag.inc ${PROJECT_SOURCE_DIR}/cube/cube.frag MAIN_DEPENDENCY ${PROJECT_SOURCE_DIR}/cube/cube.frag DEPENDS ${PROJECT_SOURCE_DIR}/cube/cube.frag ${GLSLANG_VALIDATOR}) ``` -------------------------------- ### Windows Platform-Specific Compile Definitions Source: https://github.com/khronosgroup/vulkan-tools/blob/main/cube/CMakeLists.txt Adds preprocessor definitions for Windows builds to handle secure C runtime warnings and math constants. ```cmake if(WIN32) add_compile_definitions(_CRT_SECURE_NO_WARNINGS) # vkcube / vkcube make use of M_PI and various other math defines. add_compile_definitions(_USE_MATH_DEFINES) endif() ``` -------------------------------- ### Configure vkcubepp for Windows Source: https://github.com/khronosgroup/vulkan-tools/blob/main/cube/CMakeLists.txt Configures the vkcubepp executable for Windows systems, specifying source files and WIN32 target. ```cmake add_executable(vkcubepp WIN32 cube.cpp ${PROJECT_SOURCE_DIR}/cube/cube.vert ${PROJECT_SOURCE_DIR}/cube/cube.frag cube.vert.inc cube.frag.inc) ``` -------------------------------- ### Windows DLL Version Info Configuration Source: https://github.com/khronosgroup/vulkan-tools/blob/main/vulkaninfo/CMakeLists.txt Configures version strings for the vulkaninfo DLL on Windows, defaulting to 'Dev Build' if not explicitly provided. It sets up copyright and file version information based on VulkanHeaders version or a custom cache variable. ```cmake if(WIN32) set(VULKANINFO_BUILD_DLL_VERSIONINFO "default" CACHE STRING "Set the version to be used in the vulkaninfo.rc file") string(TIMESTAMP CURRENT_YEAR "%Y") set(VULKANINFO_CUR_COPYRIGHT_STR "${CURRENT_YEAR}") if ("$CACHE{VULKANINFO_BUILD_DLL_VERSIONINFO}" STREQUAL "default") message(DEBUG "Setting RC version based on VulkanHeaders Version") set(VULKANINFO_RC_VERSION "${VulkanHeaders_VERSION}") set(VULKANINFO_VER_FILE_VERSION_STR "\"${VULKANINFO_RC_VERSION}.Dev Build\"") set(VULKANINFO_VER_FILE_DESCRIPTION_STR "\"Vulkaninfo - Dev Build\"") else() message(DEBUG "Setting RC version based on VULKANINFO_BUILD_DLL_VERSIONINFO") set(VULKANINFO_RC_VERSION "$CACHE{VULKANINFO_BUILD_DLL_VERSIONINFO}") set(VULKANINFO_VER_FILE_VERSION_STR "\"${VULKANINFO_RC_VERSION}\"") set(VULKANINFO_VER_FILE_DESCRIPTION_STR "\"vulkaninfo\"") endif() # RC file wants the value of FILEVERSION to separated by commas string(REPLACE "." ", " VULKANINFO_VER_FILE_VERSION "${VULKANINFO_RC_VERSION}") # Configure the file to include the versioning info configure_file(vulkaninfo.rc.in ${CMAKE_CURRENT_BINARY_DIR}/vulkaninfo.rc) target_sources(vulkaninfo PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/vulkaninfo.rc) endif() ``` -------------------------------- ### Build Android Release Binary with CMake Source: https://github.com/khronosgroup/vulkan-tools/blob/main/BUILD.md Compiles a release binary for the arm64-v8a architecture using CMake with the Android NDK toolchain. This command builds the binaries but not an APK. ```bash # Build release binary for arm64-v8a cmake -S . -B build \ -D CMAKE_TOOLCHAIN_FILE=$ANDROID_NDK_HOME/build/cmake/android.toolchain.cmake \ -D ANDROID_PLATFORM=26 \ -D CMAKE_ANDROID_ARCH_ABI=arm64-v8a \ -D CMAKE_ANDROID_STL_TYPE=c++_static \ -D ANDROID_USE_LEGACY_TOOLCHAIN_FILE=NO \ -D CMAKE_BUILD_TYPE=Release \ -D UPDATE_DEPS=ON \ -G Ninja cmake --build build cmake --install build --prefix build/install ``` -------------------------------- ### Set Wayland Additional Sources Source: https://github.com/khronosgroup/vulkan-tools/blob/main/cube/CMakeLists.txt Appends generated Wayland client and XDG shell/decoration C source and header files to the list of additional sources for the build. ```cmake set(WAYLAND_ADDITIONAL_SOURCES ${CMAKE_CURRENT_BINARY_DIR}/wayland-client.c ${CMAKE_CURRENT_BINARY_DIR}/xdg-shell-code.c ${CMAKE_CURRENT_BINARY_DIR}/xdg-shell-client-header.h ${CMAKE_CURRENT_BINARY_DIR}/xdg-decoration-code.c ${CMAKE_CURRENT_BINARY_DIR}/xdg-decoration-client-header.h) ``` -------------------------------- ### Configure Mock ICD JSON File Source: https://github.com/khronosgroup/vulkan-tools/blob/main/icd/CMakeLists.txt Configures the mock ICD's JSON manifest file using a template. This ensures the correct library path is set for different platforms. ```cmake set(INPUT_FILE "${CMAKE_CURRENT_SOURCE_DIR}/${MOCK_ICD_NAME}.json.in") set(INTERMEDIATE_FILE "${CMAKE_CURRENT_BINARY_DIR}/json/mock_icd.json") set(OUTPUT_FILE_FINAL_NAME "${MOCK_ICD_NAME}.json") set(LAYER_INSTALL_DIR ${CMAKE_INSTALL_LIBDIR}) if (WIN32) set(LAYER_INSTALL_DIR ${CMAKE_INSTALL_BINDIR}) # WIN32 expect the dll in the `bin` dir, this matches our WIN32 SDK process endif() if (WIN32) set(JSON_LIBRARY_PATH ".\\${MOCK_ICD_NAME}.dll") elseif(APPLE) set(JSON_LIBRARY_PATH "./lib${MOCK_ICD_NAME}.dylib") else() set(JSON_LIBRARY_PATH "./lib${MOCK_ICD_NAME}.so") endif() configure_file(${INPUT_FILE} ${INTERMEDIATE_FILE} @ONLY) ``` -------------------------------- ### Configure vkcube for Linux/BSD/GNU Source: https://github.com/khronosgroup/vulkan-tools/blob/main/cube/CMakeLists.txt Configures the vkcube executable for Linux, BSD, and GNU systems, including source files and linking necessary libraries. ```cmake add_executable(vkcube) target_sources(vkcube PRIVATE cube.c ${PROJECT_SOURCE_DIR}/cube/cube.vert ${PROJECT_SOURCE_DIR}/cube/cube.frag cube.vert.inc cube.frag.inc ) target_link_libraries(vkcube Threads::Threads) if(BUILD_WSI_XCB_SUPPORT) target_sources(vkcube PRIVATE xcb_loader.h) target_include_directories(vkcube PRIVATE ${xcb_INCLUDE_DIRS}) endif() if(BUILD_WSI_XLIB_SUPPORT) target_sources(vkcube PRIVATE xlib_loader.h) target_include_directories(vkcube PRIVATE ${XLIB_INCLUDE_DIRS}) endif() if(BUILD_WSI_WAYLAND_SUPPORT) target_include_directories(vkcubepp PRIVATE ${WAYLAND_INCLUDE_DIRS} ${CMAKE_CURRENT_BINARY_DIR}) target_sources(vkcubepp PRIVATE ${WAYLAND_ADDITIONAL_SOURCES}) endif() if(BUILD_WSI_DIRECTFB_SUPPORT) target_link_libraries(vkcube PkgConfig::DirectFB) endif() include(CheckLibraryExists) CHECK_LIBRARY_EXISTS("rt" clock_gettime "" NEED_RT) if (NEED_RT) target_link_libraries(vkcube rt) endif() ``` -------------------------------- ### Compile Vertex Shader with glslangValidator Source: https://github.com/khronosgroup/vulkan-tools/blob/main/cube/CMakeLists.txt Uses a custom command to compile the vertex shader. Ensure glslangValidator is available in the build environment. ```cmake add_custom_command(COMMENT "Compiling cube vertex shader" OUTPUT ${CMAKE_CURRENT_SOURCE_DIR}/cube.vert.inc COMMAND ${GLSLANG_VALIDATOR} -V -x -o ${CMAKE_CURRENT_SOURCE_DIR}/cube.vert.inc ${PROJECT_SOURCE_DIR}/cube/cube.vert MAIN_DEPENDENCY ${PROJECT_SOURCE_DIR}/cube/cube.vert DEPENDS ${PROJECT_SOURCE_DIR}/cube/cube.vert ${GLSLANG_VALIDATOR}) ``` -------------------------------- ### Post-Build Copy Command for JSON Source: https://github.com/khronosgroup/vulkan-tools/blob/main/icd/CMakeLists.txt Copies the generated JSON manifest file to the target directory after the mock ICD library is built. This ensures the JSON is available alongside the library. ```cmake add_custom_command(TARGET VkICD_mock_icd POST_BUILD COMMAND ${CMAKE_COMMAND} -E copy_if_different ${INTERMEDIATE_FILE} $/${OUTPUT_FILE_FINAL_NAME} ) ``` -------------------------------- ### Compile Cube Vertex Shader Source: https://github.com/khronosgroup/vulkan-tools/blob/main/cube/CMakeLists.txt Defines a custom command to compile the cube vertex shader. The output is expected to be a .inc file. ```cmake add_custom_command(COMMENT "Compiling cube vertex shader" OUTPUT ${CMAKE_CURRENT_SOURCE_DIR}/cube.vert.inc ``` -------------------------------- ### Configure CMake for New Dependency Versions Source: https://github.com/khronosgroup/vulkan-tools/blob/main/BUILD.md When testing new dependency versions, you can modify CMAKE_PREFIX_PATH. Remember to delete CMakeCache.txt to clear cached find_* results. ```bash # Delete the CMakeCache.txt which will cache find_* results rm -rf build/ cmake -S . -B build/ ... -D CMAKE_PREFIX_PATH=~/foobar/vulkan_headers_install/ ... ``` -------------------------------- ### Generate Source Code with CMake Source: https://github.com/khronosgroup/vulkan-tools/blob/main/BUILD.md Use this target to invoke the code generation script from the build directory. Ensure TOOLS_CODEGEN is set to ON. ```bash cmake -S . -B build -D TOOLS_CODEGEN=ON cmake --build build --target tools_codegen ``` -------------------------------- ### Generate Wayland Client Code Source: https://github.com/khronosgroup/vulkan-tools/blob/main/cube/CMakeLists.txt Generates Wayland client C code from a protocol definition using the wayland-scanner executable. This is typically used for Wayland-specific client interactions. ```cmake COMMAND ${WAYLAND_SCANNER_EXECUTABLE} private-code ${WAYLAND_CODE_PROTOCOL} ${CMAKE_CURRENT_BINARY_DIR}/wayland-client.c MAIN_DEPENDENCY ${WAYLAND_CODE_PROTOCOL} DEPENDS ${WAYLAND_CODE_PROTOCOL} ${WAYLAND_SCANNER_EXECUTABLE}) ``` -------------------------------- ### Locate Android Native App Glue Source: https://github.com/khronosgroup/vulkan-tools/blob/main/cube/android/CMakeLists.txt Defines the path to the Android Native App Glue directory and checks if it exists, failing the build if not found. ```cmake set(native_app_glue_dir "${CMAKE_ANDROID_NDK}/sources/android/native_app_glue") if (NOT EXISTS ${native_app_glue_dir}) message(FATAL_ERROR "Couldn't find Android Native Glue directory!") endif() ``` -------------------------------- ### Set Output Name and Version Definitions Source: https://github.com/khronosgroup/vulkan-tools/blob/main/icd/CMakeLists.txt Sets the output name for the mock ICD library and conditionally adds Git branch and tag information as compile definitions. ```cmake set_target_properties(VkICD_mock_icd PROPERTIES OUTPUT_NAME ${MOCK_ICD_NAME}) if (DEFINED GIT_BRANCH_NAME AND DEFINED GIT_TAG_INFO) target_compile_definitions(VkICD_mock_icd PRIVATE GIT_BRANCH_NAME="${GIT_BRANCH_NAME}" GIT_TAG_INFO="${GIT_TAG_INFO}") endif() ``` -------------------------------- ### Platform-Specific Compile Definitions Source: https://github.com/khronosgroup/vulkan-tools/blob/main/vulkaninfo/CMakeLists.txt Sets platform-specific compile definitions for vulkaninfo. On Windows, it enables WIN32 KHR, WIN32_LEAN_AND_MEAN, and disables secure warnings. On Apple platforms, it enables Metal extensions and specific iOS/macOS MVK definitions. ```cmake if(WIN32) target_compile_definitions(vulkaninfo PRIVATE VK_USE_PLATFORM_WIN32_KHR WIN32_LEAN_AND_MEAN _CRT_SECURE_NO_WARNINGS ) elseif(APPLE) target_compile_definitions(vulkaninfo PRIVATE VK_USE_PLATFORM_METAL_EXT) if (IOS) target_compile_definitions(vulkaninfo PRIVATE VK_USE_PLATFORM_IOS_MVK) else() target_compile_definitions(vulkaninfo PRIVATE VK_USE_PLATFORM_MACOS_MVK) endif() endif() ``` -------------------------------- ### Check for DirectFB Source: https://github.com/khronosgroup/vulkan-tools/blob/main/cube/CMakeLists.txt Checks if DirectFB is available on the system and imports its targets. This is used for DirectFB WSI support. ```cmake pkg_check_modules(DirectFB REQUIRED QUIET IMPORTED_TARGET directfb) ``` -------------------------------- ### Generate XDG Decoration Protocol Dispatch Data Source: https://github.com/khronosgroup/vulkan-tools/blob/main/cube/CMakeLists.txt Generates C code for XDG decoration protocol dispatch data. This command processes the XDG decoration protocol XML file. ```cmake COMMAND ${WAYLAND_SCANNER_EXECUTABLE} private-code ${XDG_DECORATION_PROTOCOL} ${CMAKE_CURRENT_BINARY_DIR}/xdg-decoration-code.c MAIN_DEPENDENCY ${XDG_DECORATION_PROTOCOL} DEPENDS ${XDG_DECORATION_PROTOCOL} ${WAYLAND_SCANNER_EXECUTABLE}) ``` -------------------------------- ### Set vkcube Include Directory Source: https://github.com/khronosgroup/vulkan-tools/blob/main/cube/android/CMakeLists.txt Sets the current directory as a public include directory for the vkcube target. ```cmake target_include_directories(vkcube PRIVATE . ) ``` -------------------------------- ### Link Libraries for vkcube Source: https://github.com/khronosgroup/vulkan-tools/blob/main/cube/android/CMakeLists.txt Links the vkcube target with the android_glue library, the log library, and the android library. ```cmake target_link_libraries(vkcube android_glue log android ) ``` -------------------------------- ### Compiler-Specific Options Source: https://github.com/khronosgroup/vulkan-tools/blob/main/icd/CMakeLists.txt Applies specific compile options for GNU/Clang compilers and MSVC. This includes warning flags and definitions. ```cmake if(${CMAKE_CXX_COMPILER_ID} MATCHES "GNU|Clang") target_compile_options(VkICD_mock_icd PRIVATE -Wpointer-arith -Wno-unused-function -Wno-sign-compare ) endif() if(MSVC) target_compile_options(VkICD_mock_icd PRIVATE /bigobj) target_compile_definitions(VkICD_mock_icd PRIVATE _CRT_SECURE_NO_WARNINGS) target_link_options(VkICD_mock_icd PRIVATE /DEF:${CMAKE_CURRENT_SOURCE_DIR}/${MOCK_ICD_NAME}.def) else() if(APPLE) set_target_properties(VkICD_mock_icd PROPERTIES SUFFIX ".dylib") endif() message(DEBUG "Mock ICD Functions are exported via EXPORT") endif() ``` -------------------------------- ### Add Android Sources to vkcube Target Source: https://github.com/khronosgroup/vulkan-tools/blob/main/cube/android/CMakeLists.txt Includes the android_util.cpp and android_util.h files as private sources for the vkcube target. ```cmake target_sources(vkcube PRIVATE android_util.cpp android_util.h ) ``` -------------------------------- ### Generate XDG Shell Client Header Source: https://github.com/khronosgroup/vulkan-tools/blob/main/cube/CMakeLists.txt Generates a client header file for the XDG shell protocol. This is used to provide Wayland client interfaces for the XDG shell. ```cmake COMMAND ${WAYLAND_SCANNER_EXECUTABLE} client-header ${XDG_SHELL_PROTOCOL} ${CMAKE_CURRENT_BINARY_DIR}/xdg-shell-client-header.h MAIN_DEPENDENCY ${XDG_SHELL_PROTOCOL} DEPENDS ${XDG_SHELL_PROTOCOL} ${WAYLAND_SCANNER_EXECUTABLE}) ``` -------------------------------- ### Find glslangValidator Source: https://github.com/khronosgroup/vulkan-tools/blob/main/cube/CMakeLists.txt Searches for the glslangValidator executable in system paths, or within specified SDK directories if VULKAN_SDK is set. This is required for compiling GLSL shaders. ```cmake find_program(GLSLANG_VALIDATOR names glslang glslangValidator HINTS $ENV{GLSLANG_INSTALL_DIR} $ENV{VULKAN_SDK}/bin $ENV{VULKAN_SDK}/Bin) ``` -------------------------------- ### Find Vulkan Threads Library Source: https://github.com/khronosgroup/vulkan-tools/blob/main/cube/CMakeLists.txt Finds the Threads library, which is required for validation layers on older Ubuntu versions. ```cmake if (CMAKE_SYSTEM_NAME MATCHES "Linux|BSD|GNU") find_package(Threads REQUIRED) endif() ```