From af29da2545b7ec71ae857dbf99ea7cac974c2cf8 Mon Sep 17 00:00:00 2001 From: Ryan Pavlik Date: Wed, 29 Mar 2023 13:52:43 -0500 Subject: [PATCH] gradle: Use static C++ runtime library by default when building Monado, for compatibility. We do not export any C++ symbols. Added property to allow selection of shared C++ standard lib. --- src/xrt/targets/openxr_android/build.gradle | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/src/xrt/targets/openxr_android/build.gradle b/src/xrt/targets/openxr_android/build.gradle index a38a7ea2e..1a2c9f925 100644 --- a/src/xrt/targets/openxr_android/build.gradle +++ b/src/xrt/targets/openxr_android/build.gradle @@ -80,6 +80,15 @@ if (!(new File(project.file(project.eigenIncludeDir), "Eigen/Core")).exists()) { unpackEigen.enabled = false } +// Pass -PsharedStl=true on the gradle command line to build with the shared runtime library. +// This has potential compatibility issues and should only be used if you're consuming another +// library that exposes a C++ interface. +project.ext.stl = "c++_static" +if (project.hasProperty("sharedStl") && project.getProperty("sharedStl")) { + project.ext.stl = "c++_shared" + println "Using SHARED C++ standard library" +} + android { compileSdk project.sharedCompileSdk buildToolsVersion buildToolsVersion @@ -102,7 +111,7 @@ android { externalNativeBuild { cmake { - arguments "-DEIGEN3_INCLUDE_DIR=${project.eigenIncludeDir}", "-DANDROID_PLATFORM=26", "-DANDROID_STL=c++_shared", "-DANDROID_ARM_NEON=TRUE" + arguments "-DEIGEN3_INCLUDE_DIR=${project.eigenIncludeDir}", "-DANDROID_PLATFORM=${project.sharedMinSdk}", "-DANDROID_STL=${project.stl}", "-DANDROID_ARM_NEON=TRUE" } if (project.pythonBinary != null) {