Problem with -soname and NO_SONAME when cross-compiling for Android on Linux using SWIG
We are building Java wrapper around our C++ library using CMake and SWIG.
Seems like after the issue 14815 was resolved, our cross-compilation of this wrapper for Android platform on Linux build box stopped working:
/opt/android/android-ndk-r10e/toolchains/x86-4.9/prebuilt/linux-x86_64/bin/../lib/gcc/i686-linux-android/4.9/../../../../i686-linux-android/bin/ld:
fatal error:
-soname: must take a non-empty argument
Using VERBOSE=1 make
showed that empty -soname
option is passed:
/opt/android/android-ndk-r10e/toolchains/x86-4.9/prebuilt/linux-x86_64/bin/i686-linux-android-g++ ....... -shared -Wl,-soname, -o libJavaWrapper.so .........
To fix it, we specified property NO_SONAME=OFF
for the wrapper target:
set_target_properties (JavaWrapper PROPERTIES
CXX_STANDARD 11
NO_SONAME OFF
COMPILE_DEFINITIONS ${STATIC_DEFINE}
)
This worked until CMake 3.4, which seems ignores NO_SONAME
property because in either case (ON or OFF) we get -soname: must take a non-empty argument
error.
As far as I understand we have two problems here:
- Empty
-soname
option in linker command line in case ofNO_SONAME=ON
. Entire-soname
option should be omitted, not just its argument. - Ignoring property
NO_SONAME
since CMake 3.4.