# install(EXPORT ...) and install(EXPORT\_ANDROID\_MK ...) cannot coexist. why?

**URL:** https://discourse.cmake.org/t/install-export-and-install-export-android-mk-cannot-coexist-why/10024
**Category:** Code
**Tags:** os:android
**Created:** [February 7, 2024, 1:41pm UTC](https://discourse.cmake.org/t/install-export-and-install-export-android-mk-cannot-coexist-why/10024 "2024-02-07T13:41:55Z")
**Posts on this page:** 3
**Page:** 1

<div class="post-metadata">

### Author: ![Lukasz\_Tyrala](https://discourse.cmake.org/user_avatar/discourse.cmake.org/lukasz_tyrala/32/1216_2.png) [@Lukasz\_Tyrala](https://discourse.cmake.org/u/Lukasz_Tyrala)
#### Post date: [February 7, 2024, 1:41pm UTC](https://discourse.cmake.org/t/install-export-and-install-export-android-mk-cannot-coexist-why/10024/1 "2024-02-07T13:41:56Z")

</div>

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
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:

```bash
> 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?

---

<div class="post-metadata">

### Author: ![ben.boeckel](https://discourse.cmake.org/letter_avatar_proxy/v4/letter/b/ea5d25/32.png) [@ben.boeckel](https://discourse.cmake.org/u/ben.boeckel)
#### Post date: [February 7, 2024, 8:49pm UTC](https://discourse.cmake.org/t/install-export-and-install-export-android-mk-cannot-coexist-why/10024/2 "2024-02-07T20:49:20Z")

</div>

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](https://gitlab.kitware.com/cmake/cmake/-/issues) would be good.

---

<div class="post-metadata">

### Author: ![Lukasz\_Tyrala](https://discourse.cmake.org/user_avatar/discourse.cmake.org/lukasz_tyrala/32/1216_2.png) [@Lukasz\_Tyrala](https://discourse.cmake.org/u/Lukasz_Tyrala)
#### Post date: [February 7, 2024, 8:53pm UTC](https://discourse.cmake.org/t/install-export-and-install-export-android-mk-cannot-coexist-why/10024/3 "2024-02-07T20:53:09Z")

</div>

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