Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to get android build type (debug, release) as a variable in a CMakeLists.txt file for external native build in android studio?

I need to reference the android build type (debug, release) into a CMakeLists.txt file I use for building an external native library. More exactly:

set_target_properties( # Specifies the target library.
                   mylibname

                   # Specifies the parameter you want to define.
                   PROPERTIES IMPORTED_LOCATION

                   # Provides the path to the library you want to import.                                                            

                   $ENV{LIBRARY_HOME}/${ANDROID_BUILD_TYPE}/libs/${ANDROID_ABI}/libMylib.a

I need the equivalent of ${ANDROID_ABI}, which changes the build per abi type, in place of ${ANDROID_BUILD_TYPE} which is, of course, a name of example. That is: which is the name of that variable? And, more generally, is there a list of them all somewhere?

like image 975
Kabu Avatar asked Apr 13 '17 15:04

Kabu


People also ask

Where do I find CMakeLists txt?

The CMakeLists. txt file is at the top directory of the ROOT git repository. If you don't have that file, then there is a problem with your git checkout. Please make sure that the path you provide to CMake is the path to the top directory of the repository, and that the file is there.

Does CMake default to debug or release?

It will now default to using a debug build if the source directory is a git clone, or a release build if not. It is also quite easy to customize its behavior according to the preferences of your project.

What is CMake build type?

Specifies the build type on single-configuration generators (e.g. Makefile Generators or Ninja ). Typical values include Debug , Release , RelWithDebInfo and MinSizeRel , but custom build types can also be defined.


1 Answers

I found that you can use ${CMAKE_BUILD_TYPE} for this, which evaluates to Release or Debug. I'm not sure if this is the same thing as the actual Android build configurations or a separate configuration for CMake, but at least for the simple case of debug/release configurations it works. On case-sensitive platforms you might have to convert the result to lowercase.

The build arguments listed at https://developer.android.com/ndk/guides/cmake are probably named directly after the variables they set.

like image 81
KeloCube Avatar answered Nov 15 '22 04:11

KeloCube