install(EXPORT ...) and install(EXPORT_ANDROID_MK ...) cannot coexist. why?

Hi, I want to build my library for Android AOSP.
I want to build it as a library and install it with android.mk

this is my CMake script:

cmake_minimum_required(VERSION 3.22.1)
# test output
set(CMAKE_INSTALL_PREFIX "${CMAKE_BINARY_DIR}/install")

include(GNUInstallDirs)
include(CMakePackageConfigHelpers)

# to make it easy, I use tinyxml2 as dependency
set(tinyxml2_BUILD_TESTING FALSE)
include(FetchContent)
FetchContent_Declare(
    tinyxml2
    GIT_REPOSITORY https://github.com/leethomason/tinyxml2.git
    GIT_TAG        1dee28e51f9175a31955b9791c74c430fe13dc82 # Release 9.0.0
)
FetchContent_MakeAvailable(tinyxml2)

# now I need android.mk for dependency
install(
    EXPORT_ANDROID_MK tinyxml2-targets
    DESTINATION ${CMAKE_INSTALL_LIBDIR}/ndk-modules/tinyxml2
)


# then I have my library using tinyxml2
project(some_lib)
add_library(some_lib some_lib.cpp)
add_library(some_lib::some_lib ALIAS some_lib)
target_link_libraries(some_lib PRIVATE tinyxml2::tinyxml2)

install(
    TARGETS some_lib
    EXPORT some_libConfig
    CONFIGURATIONS Release Debug
    DESTINATION ${CMAKE_INSTALL_LIBDIR}
)
install(
    EXPORT_ANDROID_MK some_libConfig
    DESTINATION ${CMAKE_INSTALL_LIBDIR}/ndk-modules/some_lib
)

the runtime issue:

> cmake -B out -S .
-- The C compiler identification is GNU 13.2.1
-- The CXX compiler identification is GNU 13.2.1
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - done
-- Check for working C compiler: /usr/bin/cc - skipped
-- Detecting C compile features
-- Detecting C compile features - done
-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - done
-- Check for working CXX compiler: /usr/bin/c++ - skipped
-- Detecting CXX compile features
-- Detecting CXX compile features - done
-- Configuring done (1.4s)
CMake Error: install(EXPORT "some_libConfig" ...) includes target "some_lib" which requires target "tinyxml2" that is not in this export set, but in multiple other export sets: lib/cmake/tinyxml2/tinyxml2-static-targets.cmake, lib/ndk-modules/tinyxml2/Android.mk.
An exported target cannot depend upon another target which is exported multiple times. Consider consolidating the exports of the "tinyxml2" target to a single export.
-- Generating done (0.0s)
CMake Generate step failed.  Build files cannot be regenerated correctly.

why cannot we have two exports, one from the library for find_package and one for Android?
is there a way to work around this issue?

Hmm, yes. It might make sense to consider ANDROID_MK and CMake exports as completely separate. I don’t think there’s a workaround right now, but a feature request would be good.

will do
[08.02.2024] done https://gitlab.kitware.com/cmake/cmake/-/issues/25663