Trying to set up a Android project with CMakeLists

Has anyone made/found a tutorial on how to set up a Vulkan project in Android studio with CMake?

I set up a project to use CMake based on Android’s site labeled add-native-code.html .
Now I’ve been trying to use the VulkanSDK samples in Android studio to learn how to get Vulkan working in my newly created project…
Currently the project cannot find the Vulkan library.

I’m trying to find somewhere that sets up a project cleanly with a recent version of cmake.

===Copy and paste attempt with cmake (doesn’t work)===

cmake_minimum_required(VERSION 3.7)
project(native-lib)

set(VULKAN_HEADERS_INSTALL_DIR "HEADERS-NOTFOUND" CACHE PATH "Absolute path to a Vulkan-Headers install directory")
set(VULKAN_LOADER_INSTALL_DIR "LOADER-NOTFOUND" CACHE PATH "Absolute path to a Vulkan-Loader install directory")
set(CMAKE_PREFIX_PATH ${CMAKE_PREFIX_PATH};${VULKAN_HEADERS_INSTALL_DIR};${VULKAN_LOADER_INSTALL_DIR};
$ENV{VULKAN_HEADERS_INSTALL_DIR};$ENV{VULKAN_LOADER_INSTALL_DIR})

set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${CMAKE_CURRENT_SOURCE_DIR}/cmake")
message(STATUS "Using find_package to locate Vulkan")
find_package(Vulkan)
message(STATUS "Vulkan FOUND = ${Vulkan_FOUND}")
message(STATUS "Vulkan Include = ${Vulkan_INCLUDE_DIR}")
message(STATUS "Vulkan Lib = ${Vulkan_LIBRARY}")

add_executable(native-lib native-lib.cpp)
target_include_directories(native-lib PRIVATE Vulkan::Vulkan)
target_link_libraries(native-lib Vulkan::Vulkan)

Not really a direct solution but, I decided to use WSIWindow’s examples to use as a base and customize it.

I have also found this as a good example of using CMake for Android

This topic was automatically closed 183 days after the last reply. New replies are no longer allowed.