Commit dda6775c authored by Brad King's avatar Brad King 💬
Browse files

Android: Record use of C++ by static libs in exported Android.mk files

When a `PREBUILT_STATIC_LIBRARY` uses C++ in its sources then the `.a`
file will have a link-time dependency on the C++ runtime libraries.
Android NDK r14 will add a way to give this information to the NDK build
system by adding a `LOCAL_HAS_CPP` setting to the `Android.mk` file.
Add this for exported static libraries that use C++.
parent b99bbfe8
Pipeline #29860 passed with stage
...@@ -9,6 +9,8 @@ ...@@ -9,6 +9,8 @@
#include "cmMakefile.h" #include "cmMakefile.h"
#include "cmTargetExport.h" #include "cmTargetExport.h"
#include <algorithm>
cmExportBuildAndroidMKGenerator::cmExportBuildAndroidMKGenerator() cmExportBuildAndroidMKGenerator::cmExportBuildAndroidMKGenerator()
{ {
this->LG = CM_NULLPTR; this->LG = CM_NULLPTR;
...@@ -164,6 +166,16 @@ void cmExportBuildAndroidMKGenerator::GenerateInterfaceProperties( ...@@ -164,6 +166,16 @@ void cmExportBuildAndroidMKGenerator::GenerateInterfaceProperties(
} }
} }
} }
// Tell the NDK build system if prebuilt static libraries use C++.
if (target->GetType() == cmState::STATIC_LIBRARY) {
cmLinkImplementation const* li = target->GetLinkImplementation(config);
if (std::find(li->Languages.begin(), li->Languages.end(), "CXX") !=
li->Languages.end()) {
os << "LOCAL_HAS_CPP := true\n";
}
}
switch (target->GetType()) { switch (target->GetType()) {
case cmState::SHARED_LIBRARY: case cmState::SHARED_LIBRARY:
case cmState::MODULE_LIBRARY: case cmState::MODULE_LIBRARY:
......
...@@ -2,7 +2,7 @@ project(build) ...@@ -2,7 +2,7 @@ project(build)
set(CMAKE_BUILD_TYPE Debug) set(CMAKE_BUILD_TYPE Debug)
add_library(foo foo.cxx) add_library(foo foo.cxx)
add_library(car foo.cxx) add_library(car foo.cxx)
add_library(bar foo.cxx) add_library(bar bar.c)
add_library(dog foo.cxx) add_library(dog foo.cxx)
target_link_libraries(foo car bar dog debug -lm) target_link_libraries(foo car bar dog debug -lm)
export(TARGETS bar dog car foo ANDROID_MK export(TARGETS bar dog car foo ANDROID_MK
......
...@@ -7,11 +7,13 @@ include.*PREBUILT_STATIC_LIBRARY.* ...@@ -7,11 +7,13 @@ include.*PREBUILT_STATIC_LIBRARY.*
include.*CLEAR_VARS.* include.*CLEAR_VARS.*
LOCAL_MODULE.*dog LOCAL_MODULE.*dog
LOCAL_SRC_FILES.*.*dog.* LOCAL_SRC_FILES.*.*dog.*
LOCAL_HAS_CPP := true
include.*PREBUILT_STATIC_LIBRARY.* include.*PREBUILT_STATIC_LIBRARY.*
.* .*
include.*CLEAR_VARS.* include.*CLEAR_VARS.*
LOCAL_MODULE.*car LOCAL_MODULE.*car
LOCAL_SRC_FILES.*.*car.* LOCAL_SRC_FILES.*.*car.*
LOCAL_HAS_CPP := true
include.*PREBUILT_STATIC_LIBRARY.* include.*PREBUILT_STATIC_LIBRARY.*
.* .*
include.*CLEAR_VARS.* include.*CLEAR_VARS.*
...@@ -20,4 +22,5 @@ LOCAL_SRC_FILES.*.*foo.* ...@@ -20,4 +22,5 @@ LOCAL_SRC_FILES.*.*foo.*
LOCAL_CPP_FEATURES.*rtti exceptions LOCAL_CPP_FEATURES.*rtti exceptions
LOCAL_STATIC_LIBRARIES.*car bar dog LOCAL_STATIC_LIBRARIES.*car bar dog
LOCAL_EXPORT_LDLIBS := -lm LOCAL_EXPORT_LDLIBS := -lm
LOCAL_HAS_CPP := true
include.*PREBUILT_STATIC_LIBRARY.* include.*PREBUILT_STATIC_LIBRARY.*
...@@ -9,11 +9,13 @@ include.*PREBUILT_STATIC_LIBRARY.* ...@@ -9,11 +9,13 @@ include.*PREBUILT_STATIC_LIBRARY.*
include.*CLEAR_VARS. include.*CLEAR_VARS.
LOCAL_MODULE.*dog LOCAL_MODULE.*dog
LOCAL_SRC_FILES.*_IMPORT_PREFIX./lib.*dog.* LOCAL_SRC_FILES.*_IMPORT_PREFIX./lib.*dog.*
LOCAL_HAS_CPP := true
include.*PREBUILT_STATIC_LIBRARY.* include.*PREBUILT_STATIC_LIBRARY.*
include.*CLEAR_VARS.* include.*CLEAR_VARS.*
LOCAL_MODULE.*car LOCAL_MODULE.*car
LOCAL_SRC_FILES.*_IMPORT_PREFIX./lib.*car.* LOCAL_SRC_FILES.*_IMPORT_PREFIX./lib.*car.*
LOCAL_HAS_CPP := true
include.*PREBUILT_STATIC_LIBRARY.* include.*PREBUILT_STATIC_LIBRARY.*
include.*CLEAR_VARS.* include.*CLEAR_VARS.*
...@@ -22,4 +24,5 @@ LOCAL_SRC_FILES.*_IMPORT_PREFIX\)/lib.*foo.* ...@@ -22,4 +24,5 @@ LOCAL_SRC_FILES.*_IMPORT_PREFIX\)/lib.*foo.*
LOCAL_CPP_FEATURES.*rtti exceptions LOCAL_CPP_FEATURES.*rtti exceptions
LOCAL_STATIC_LIBRARIES.*car bar dog LOCAL_STATIC_LIBRARIES.*car bar dog
LOCAL_EXPORT_LDLIBS := -lm LOCAL_EXPORT_LDLIBS := -lm
LOCAL_HAS_CPP := true
include.*PREBUILT_STATIC_LIBRARY.* include.*PREBUILT_STATIC_LIBRARY.*
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment