aboutsummaryrefslogtreecommitdiff
path: root/toolchain
diff options
context:
space:
mode:
authorVolker Krause <vkrause@kde.org>2020-06-01 16:19:21 +0200
committerAleix Pol Gonzalez <aleixpol@kde.org>2020-06-22 00:00:28 +0000
commit13a1161d445cbd31f2e83cfc31564a387c3d7f5f (patch)
treeb9337e2813c19c552868ab7650dbe60150592f63 /toolchain
parent8f26aba22be46099e0bb443ab27de4eb8c4d8a06 (diff)
downloadextra-cmake-modules-13a1161d445cbd31f2e83cfc31564a387c3d7f5f.tar.gz
extra-cmake-modules-13a1161d445cbd31f2e83cfc31564a387c3d7f5f.tar.bz2
Deal with Qt's CMake code modifying CMAKE_SHARED_LIBRARY_SUFFIX
Qt adds the Android ABI to the suffix there unconditionally, without also adjusting CMAKE_FIND_LIBRARY_SUFFIXES accordingly, breaking find_library() for things built that way. Unfortunately we can't just set this in our toolchain file, as CMAKE_FIND_LIBRARY_SUFFIXES is overwritten by CMake after evaluating the toolchain file. So we need to use the variable_watch hack for this here, thanks to Aleix for the idea. With this, find_library() works for both suffixed and un-suffixed libraries again, such as Poppler built with or without Qt support.
Diffstat (limited to 'toolchain')
-rw-r--r--toolchain/Android.cmake12
1 files changed, 11 insertions, 1 deletions
diff --git a/toolchain/Android.cmake b/toolchain/Android.cmake
index 2b06e4a9..3e6a877c 100644
--- a/toolchain/Android.cmake
+++ b/toolchain/Android.cmake
@@ -155,7 +155,17 @@ include(${CMAKE_ANDROID_NDK}/build/cmake/android.toolchain.cmake REQUIRED)
# these aren't set yet at this point by the Android toolchain, but without
# those the find_package() call in ECMAndroidDeployQt will fail
set(CMAKE_FIND_LIBRARY_PREFIXES "lib")
-set(CMAKE_FIND_LIBRARY_SUFFIXES ".so" ".a")
+set(CMAKE_FIND_LIBRARY_SUFFIXES "_${CMAKE_ANDROID_ARCH_ABI}.so" ".so" ".a")
+
+# Work around Qt messing with CMAKE_SHARED_LIBRARY_SUFFIX and thus breaking find_library()
+# Unfortunately, just setting CMAKE_FIND_LIBRARY_SUFFIXES here won't help, as this will
+# be subsequently overwritten.
+macro(addAbiSuffix _var _access)
+ if (${_access} STREQUAL "MODIFIED_ACCESS")
+ list(PREPEND CMAKE_FIND_LIBRARY_SUFFIXES "_${CMAKE_ANDROID_ARCH_ABI}.so")
+ endif()
+endmacro()
+variable_watch(CMAKE_FIND_LIBRARY_SUFFIXES addAbiSuffix)
# determine STL architecture, which is using a different format than ANDROID_ARCH_ABI
string(REGEX REPLACE "-(clang)?([0-9].[0-9])?$" "" ECM_ANDROID_STL_ARCH ${ANDROID_TOOLCHAIN_NAME})