android / android/ndk

Native App Glue requires a C compiler

Open
#1,906 4 comments 0 reactions 0 assignees View on GitHub
enhancement
Dominant language
No language data
Stars
2.3k
Forks
310
PR merge metrics
No merged PRs in 30d

Description

### Description

Our project only enables the CXX compiler by default.

```cmake
project(VVL LANGUAGES CXX) # <- Are project is pure C++
```

However, for the Android build we have some [awkward CMake code](https://github.com/KhronosGroup/Vulkan-ValidationLayers/blob/2ce44f7f1928edb981adc587d8d3e2fb0f41e975/tests/android/CMakeLists.txt#L46):

```cmake
enable_language(C) # NOTE: We need to enable the C language for android_native_app_glue.c

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()

add_library(android_glue STATIC)

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
)
```

As you can see we need to enable a C compiler in order to use native app glue. This CMake isn't ideal and is confusing to look at unless you know what is going on. Ideally this process would be more streamlined.

Thoughts?

Contributor guide

Open the contributing guide

Research direction

Start with the project(VVL LANGUAGES CXX) declaration and tests/android/CMakeLists.txt, especially the enable_language(C) and android_native_app_glue.c setup. Determine a more streamlined, documented CMake arrangement for the Android native app glue, then verify that the Android build still configures and compiles successfully.

Written by the indexing model from the issue text.

Assessment

Tech stack
android, c, cmake
Domain
build-system, mobile-dev
Issue type
Refactor
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
42/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.