Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Get Android CMake build working #1871

Merged
merged 1 commit into from
Aug 24, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 24 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -86,3 +86,27 @@ jobs:
- uses: actions/checkout@v3
- name: ndk-build
run: python scripts/github_ci_android.py --abi ${{ matrix.abi }}

android-cmake:
runs-on: ubuntu-22.04
steps:
- uses: actions/checkout@v3
- uses: actions/setup-python@v4
with:
python-version: '3.8'
- uses: lukka/get-cmake@latest
- name: Configure
run: |
cmake -S . -B build/ --toolchain $ANDROID_NDK_ROOT/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"
- name: Build
run: cmake --build build
- name: Install
run: cmake --install build --prefix build/install

14 changes: 13 additions & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -72,9 +72,21 @@ if (CMAKE_SYSTEM_NAME STREQUAL "Windows" OR

option(BUILD_LAYERMGR "Build Vulkan Configurator" ON)

elseif(ANDROID)

# Currently the Android build only build the API dump and screen shot layer.
# - libVkLayer_api_dump.so
# - libVkLayer_screenshot.so
option(BUILD_APIDUMP "Build api_dump layer" ON)
set(BUILD_MONITOR OFF)
option(BUILD_SCREENSHOT "Build screenshot layer" ON)
set(BUILD_DEMOS OFF)
set(BUILD_VKJSON OFF)
set(BUILD_VIA OFF)
set(BUILD_LAYERMGR OFF)

elseif (CMAKE_SYSTEM_NAME STREQUAL "Darwin")

option(BUILD_LOADER OFF)
option(BUILD_APIDUMP "Build api_dump layer" ON)
option(BUILD_MONITOR "Build monitor layer" ON)
option(BUILD_SCREENSHOT "Build screenshot layer" ON)
Expand Down
8 changes: 7 additions & 1 deletion layersvt/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,9 @@ else()
if (NOT APPLE)
set_target_properties(VkLayer_${target} PROPERTIES LINK_FLAGS "-Wl,-Bsymbolic")
endif ()
if (ANDROID)
target_link_Libraries(VkLayer_${target} log)
endif()
install(TARGETS VkLayer_${target} DESTINATION ${CMAKE_INSTALL_LIBDIR})
endmacro()
endif()
Expand Down Expand Up @@ -170,7 +173,10 @@ if (NOT APPLE)
endif ()
endif ()

# json file creation
if (ANDROID)
message(DEBUG "Android doesn't use json manifests.")
return()
endif()

# The output file needs Unix "/" separators or Windows "\" separators
# Windows paths need to start with ".\", Unix paths do not.
Expand Down
5 changes: 5 additions & 0 deletions scripts/known_good.json
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,11 @@
"var_name": "VULKAN_HEADERS_INSTALL_DIR",
"repo_name": "Vulkan-Headers"
}
],
"build_platforms": [
"windows",
"linux",
"darwin"
]
},
{
Expand Down
3 changes: 1 addition & 2 deletions vku/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,7 @@ if(WIN32)
else()
set (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11")
endif()
install(TARGETS vku DESTINATION ${CMAKE_INSTALL_LIBDIR})

set_target_properties(vku PROPERTIES LINKER_LANGUAGE CXX)
include_directories(${CMAKE_CURRENT_SOURCE_DIR}
${CMAKE_CURRENT_SOURCE_DIR}/generated)