summaryrefslogtreecommitdiffstats
path: root/Source/cmExportInstallAndroidMKGenerator.cxx
diff options
context:
space:
mode:
authorBill Hoffman <bill.hoffman@kitware.com>2016-07-12 17:26:55 (GMT)
committerBrad King <brad.king@kitware.com>2016-09-13 16:47:43 (GMT)
commit42ce9f1e7178b3535726c0c885cc7c9f760cc8b6 (patch)
tree6ebd228d18eb0b08ff2d950900574dd29caad95d /Source/cmExportInstallAndroidMKGenerator.cxx
parentd5257063b04a95aca3d144f860698a3c7181e554 (diff)
downloadCMake-42ce9f1e7178b3535726c0c885cc7c9f760cc8b6.zip
CMake-42ce9f1e7178b3535726c0c885cc7c9f760cc8b6.tar.gz
CMake-42ce9f1e7178b3535726c0c885cc7c9f760cc8b6.tar.bz2
Add support for creating prebuilt Android.mk files
Add options to the `install()` and `export()` commands to export the targets we build into Android.mk files that reference them as prebuilt libraries with associated usage requirements (compile definitions, include directories, link libraries). This will allow CMake-built projects to be imported into projects using the Android NDK build system. Closes: #15562
Diffstat (limited to 'Source/cmExportInstallAndroidMKGenerator.cxx')
-rw-r--r--Source/cmExportInstallAndroidMKGenerator.cxx146
1 files changed, 146 insertions, 0 deletions
diff --git a/Source/cmExportInstallAndroidMKGenerator.cxx b/Source/cmExportInstallAndroidMKGenerator.cxx
new file mode 100644
index 0000000..8f815b7
--- /dev/null
+++ b/Source/cmExportInstallAndroidMKGenerator.cxx
@@ -0,0 +1,146 @@
+/*============================================================================
+ CMake - Cross Platform Makefile Generator
+ Copyright 2000-2009 Kitware, Inc., Insight Software Consortium
+
+ Distributed under the OSI-approved BSD License (the "License");
+ see accompanying file Copyright.txt for details.
+
+ This software is distributed WITHOUT ANY WARRANTY; without even the
+ implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
+ See the License for more information.
+============================================================================*/
+#include "cmExportInstallAndroidMKGenerator.h"
+
+#include "cmAlgorithms.h"
+#include "cmExportBuildAndroidMKGenerator.h"
+#include "cmExportSet.h"
+#include "cmExportSetMap.h"
+#include "cmGeneratedFileStream.h"
+#include "cmGeneratorTarget.h"
+#include "cmGlobalGenerator.h"
+#include "cmInstallExportGenerator.h"
+#include "cmInstallTargetGenerator.h"
+#include "cmLocalGenerator.h"
+#include "cmTargetExport.h"
+
+cmExportInstallAndroidMKGenerator::cmExportInstallAndroidMKGenerator(
+ cmInstallExportGenerator* iegen)
+ : cmExportInstallFileGenerator(iegen)
+{
+}
+
+void cmExportInstallAndroidMKGenerator::GenerateImportHeaderCode(
+ std::ostream& os, const std::string&)
+{
+ std::string installDir = this->IEGen->GetDestination();
+ os << "LOCAL_PATH := $(call my-dir)\n";
+ size_t numDotDot = cmSystemTools::CountChar(installDir.c_str(), '/');
+ numDotDot += (installDir.size() > 0) ? 1 : 0;
+ std::string path;
+ for (size_t n = 0; n < numDotDot; n++) {
+ path += "/..";
+ }
+ os << "_IMPORT_PREFIX := "
+ << "$(LOCAL_PATH)" << path << "\n\n";
+ for (std::vector<cmTargetExport*>::const_iterator tei =
+ this->IEGen->GetExportSet()->GetTargetExports()->begin();
+ tei != this->IEGen->GetExportSet()->GetTargetExports()->end(); ++tei) {
+ // Collect import properties for this target.
+ cmTargetExport const* te = *tei;
+ if (te->Target->GetType() == cmState::INTERFACE_LIBRARY) {
+ continue;
+ }
+ std::string dest;
+ if (te->LibraryGenerator) {
+ dest = te->LibraryGenerator->GetDestination("");
+ }
+ if (te->ArchiveGenerator) {
+ dest = te->ArchiveGenerator->GetDestination("");
+ }
+ te->Target->Target->SetProperty("__dest", dest.c_str());
+ }
+}
+
+void cmExportInstallAndroidMKGenerator::GenerateImportFooterCode(std::ostream&)
+{
+}
+
+void cmExportInstallAndroidMKGenerator::GenerateImportTargetCode(
+ std::ostream& os, const cmGeneratorTarget* target)
+{
+ std::string targetName = this->Namespace;
+ targetName += target->GetExportName();
+ os << "include $(CLEAR_VARS)\n";
+ os << "LOCAL_MODULE := ";
+ os << targetName << "\n";
+ os << "LOCAL_SRC_FILES := $(_IMPORT_PREFIX)/";
+ os << target->Target->GetProperty("__dest") << "/";
+ std::string config = "";
+ if (this->Configurations.size()) {
+ config = this->Configurations[0];
+ }
+ os << target->GetFullName(config) << "\n";
+}
+
+void cmExportInstallAndroidMKGenerator::GenerateExpectedTargetsCode(
+ std::ostream&, const std::string&)
+{
+}
+
+void cmExportInstallAndroidMKGenerator::GenerateImportPropertyCode(
+ std::ostream&, const std::string&, cmGeneratorTarget const*,
+ ImportPropertyMap const&)
+{
+}
+
+void cmExportInstallAndroidMKGenerator::GenerateMissingTargetsCheckCode(
+ std::ostream&, const std::vector<std::string>&)
+{
+}
+
+void cmExportInstallAndroidMKGenerator::GenerateInterfaceProperties(
+ cmGeneratorTarget const* target, std::ostream& os,
+ const ImportPropertyMap& properties)
+{
+ std::string config = "";
+ if (this->Configurations.size()) {
+ config = this->Configurations[0];
+ }
+ cmExportBuildAndroidMKGenerator::GenerateInterfaceProperties(
+ target, os, properties, cmExportBuildAndroidMKGenerator::INSTALL, config);
+}
+
+void cmExportInstallAndroidMKGenerator::LoadConfigFiles(std::ostream&)
+{
+}
+
+void cmExportInstallAndroidMKGenerator::GenerateImportPrefix(std::ostream&)
+{
+}
+
+void cmExportInstallAndroidMKGenerator::GenerateRequiredCMakeVersion(
+ std::ostream&, const char*)
+{
+}
+
+void cmExportInstallAndroidMKGenerator::CleanupTemporaryVariables(
+ std::ostream&)
+{
+}
+
+void cmExportInstallAndroidMKGenerator::GenerateImportedFileCheckLoop(
+ std::ostream&)
+{
+}
+
+void cmExportInstallAndroidMKGenerator::GenerateImportedFileChecksCode(
+ std::ostream&, cmGeneratorTarget*, ImportPropertyMap const&,
+ const std::set<std::string>&)
+{
+}
+
+bool cmExportInstallAndroidMKGenerator::GenerateImportFileConfig(
+ const std::string&, std::vector<std::string>&)
+{
+ return true;
+}