Browse Source

Add 'ANDROID_API' target property to set Android Target API

Also add a 'CMAKE_ANDROID_API' variable to set the property default.
Brad King 11 years ago
parent
commit
c12e46991e

+ 1 - 0
Help/manual/cmake-properties.7.rst

@@ -79,6 +79,7 @@ Properties on Targets
    :maxdepth: 1
 
    /prop_tgt/ALIASED_TARGET
+   /prop_tgt/ANDROID_API
    /prop_tgt/ANDROID_GUI
    /prop_tgt/ARCHIVE_OUTPUT_DIRECTORY_CONFIG
    /prop_tgt/ARCHIVE_OUTPUT_DIRECTORY

+ 1 - 0
Help/manual/cmake-variables.7.rst

@@ -204,6 +204,7 @@ Variables that Control the Build
 .. toctree::
    :maxdepth: 1
 
+   /variable/CMAKE_ANDROID_API
    /variable/CMAKE_ANDROID_GUI
    /variable/CMAKE_ARCHIVE_OUTPUT_DIRECTORY
    /variable/CMAKE_AUTOMOC_MOC_OPTIONS

+ 7 - 0
Help/prop_tgt/ANDROID_API.rst

@@ -0,0 +1,7 @@
+ANDROID_API
+-----------
+
+Set the Android Target API version (e.g. ``15``).  The version number
+must be a positive decimal integer.  This property is initialized by
+the value of the :variable:`CMAKE_ANDROID_API` variable if it is set
+when a target is created.

+ 5 - 0
Help/variable/CMAKE_ANDROID_API.rst

@@ -0,0 +1,5 @@
+CMAKE_ANDROID_API
+-----------------
+
+Default value for the :prop_tgt:`ANDROID_API` target property.
+See that target property for additional information.

+ 1 - 0
Source/cmTarget.cxx

@@ -324,6 +324,7 @@ void cmTarget::SetMakefile(cmMakefile* mf)
   // Setup default property values.
   if (this->GetType() != INTERFACE_LIBRARY && this->GetType() != UTILITY)
     {
+    this->SetPropertyDefault("ANDROID_API", 0);
     this->SetPropertyDefault("INSTALL_NAME_DIR", 0);
     this->SetPropertyDefault("INSTALL_RPATH", "");
     this->SetPropertyDefault("INSTALL_RPATH_USE_LINK_PATH", "OFF");

+ 6 - 0
Source/cmVisualStudio10TargetGenerator.cxx

@@ -724,6 +724,12 @@ void cmVisualStudio10TargetGenerator
   ntv += toolset? toolset : "Default";
   ntv += "</NdkToolchainVersion>\n";
   this->WriteString(ntv.c_str(), 2);
+  if(const char* api = this->Target->GetProperty("ANDROID_API"))
+    {
+    this->WriteString("<AndroidTargetAPI>", 2);
+    (*this->BuildFileStream ) <<
+      "android-" << cmVS10EscapeXML(api) << "</AndroidTargetAPI>\n";
+    }
 }
 
 void cmVisualStudio10TargetGenerator::WriteCustomCommands()