aboutsummaryrefslogtreecommitdiff
path: root/docs/examples/vcpkg_android_example_cmake
diff options
context:
space:
mode:
Diffstat (limited to 'docs/examples/vcpkg_android_example_cmake')
-rw-r--r--docs/examples/vcpkg_android_example_cmake/.gitignore1
-rw-r--r--docs/examples/vcpkg_android_example_cmake/CMakeLists.txt5
-rwxr-xr-xdocs/examples/vcpkg_android_example_cmake/compile.sh54
-rw-r--r--docs/examples/vcpkg_android_example_cmake/my_lib.cpp8
4 files changed, 68 insertions, 0 deletions
diff --git a/docs/examples/vcpkg_android_example_cmake/.gitignore b/docs/examples/vcpkg_android_example_cmake/.gitignore
new file mode 100644
index 000000000..378eac25d
--- /dev/null
+++ b/docs/examples/vcpkg_android_example_cmake/.gitignore
@@ -0,0 +1 @@
+build
diff --git a/docs/examples/vcpkg_android_example_cmake/CMakeLists.txt b/docs/examples/vcpkg_android_example_cmake/CMakeLists.txt
new file mode 100644
index 000000000..7572bbbc8
--- /dev/null
+++ b/docs/examples/vcpkg_android_example_cmake/CMakeLists.txt
@@ -0,0 +1,5 @@
+cmake_minimum_required(VERSION 3.0)
+project(test)
+find_package(jsoncpp CONFIG REQUIRED)
+add_library(my_lib my_lib.cpp)
+target_link_libraries(my_lib jsoncpp_lib)
diff --git a/docs/examples/vcpkg_android_example_cmake/compile.sh b/docs/examples/vcpkg_android_example_cmake/compile.sh
new file mode 100755
index 000000000..1d1aa60a9
--- /dev/null
+++ b/docs/examples/vcpkg_android_example_cmake/compile.sh
@@ -0,0 +1,54 @@
+#
+# 1. Check the presence of required environment variables
+#
+if [ -z ${ANDROID_NDK_HOME+x} ]; then
+ echo "Please set ANDROID_NDK_HOME"
+ exit 1
+fi
+if [ -z ${VCPKG_ROOT+x} ]; then
+ echo "Please set VCPKG_ROOT"
+ exit 1
+fi
+
+#
+# 2. Set the path to the toolchains
+#
+vcpkg_toolchain_file=$VCPKG_ROOT/scripts/buildsystems/vcpkg.cmake
+android_toolchain_file=$ANDROID_NDK_HOME/build/cmake/android.toolchain.cmake
+
+
+#
+# 3. Select a pair "Android abi" / "vcpkg triplet"
+# Uncomment one of the four possibilities below
+#
+
+android_abi=armeabi-v7a
+vcpkg_target_triplet=arm-android
+
+# android_abi=x86
+# vcpkg_target_triplet=x86-android
+
+# android_abi=arm64-v8a
+# vcpkg_target_triplet=arm64-android
+
+# android_abi=x86_64
+# vcpkg_target_triplet=x64-android
+
+
+#
+# 4. Install the library via vcpkg
+#
+$VCPKG_ROOT/vcpkg install jsoncpp:$vcpkg_target_triplet
+
+#
+# 5. Test the build
+#
+rm -rf build
+mkdir build
+cd build
+cmake .. \
+ -DCMAKE_TOOLCHAIN_FILE=$vcpkg_toolchain_file \
+ -DVCPKG_CHAINLOAD_TOOLCHAIN_FILE=$android_toolchain_file \
+ -DVCPKG_TARGET_TRIPLET=$vcpkg_target_triplet \
+ -DANDROID_ABI=$android_abi
+make
diff --git a/docs/examples/vcpkg_android_example_cmake/my_lib.cpp b/docs/examples/vcpkg_android_example_cmake/my_lib.cpp
new file mode 100644
index 000000000..f0165d72d
--- /dev/null
+++ b/docs/examples/vcpkg_android_example_cmake/my_lib.cpp
@@ -0,0 +1,8 @@
+#include <json/json.h>
+
+int answer()
+{
+ Json::Value meaning_of;
+ meaning_of["everything"] = 42;
+ return meaning_of["everything"].asInt();
+}