Changeset View
Standalone View
toolchain/Android.cmake
Show First 20 Lines • Show All 161 Lines • ▼ Show 20 Line(s) | |||||
162 | set(ANDROID_SDK_BUILD_TOOLS_REVISION "${_default_sdk}" CACHE STRING "Android API Level") | 162 | set(ANDROID_SDK_BUILD_TOOLS_REVISION "${_default_sdk}" CACHE STRING "Android API Level") | ||
163 | 163 | | |||
164 | set(CMAKE_SYSTEM_VERSION ${CMAKE_ANDROID_API}) | 164 | set(CMAKE_SYSTEM_VERSION ${CMAKE_ANDROID_API}) | ||
165 | set(CMAKE_SYSTEM_NAME Android) | 165 | set(CMAKE_SYSTEM_NAME Android) | ||
166 | if (NOT CMAKE_ANDROID_STL_TYPE) | 166 | if (NOT CMAKE_ANDROID_STL_TYPE) | ||
167 | set(CMAKE_ANDROID_STL_TYPE c++_shared) | 167 | set(CMAKE_ANDROID_STL_TYPE c++_shared) | ||
168 | endif() | 168 | endif() | ||
169 | 169 | | |||
170 | include(${CMAKE_ROOT}/Modules/Platform/Android-Clang.cmake REQUIRED) | 170 | # let the Android NDK toolchain file do the actual work | ||
171 | include(${CMAKE_ROOT}/Modules/Platform/Android-Initialize.cmake REQUIRED) | 171 | set(ANDROID_PLATFORM "android-${CMAKE_ANDROID_API}") | ||
172 | set(ANDROID_STL ${CMAKE_ANDROID_STL_TYPE}) | ||||
173 | include(${CMAKE_ANDROID_NDK}/build/cmake/android.toolchain.cmake REQUIRED) | ||||
apol: Why's this better? Or how is it different? | |||||
It's "better" in the way that it actually works with NDK r20, while CMake 3.16 failed to even pass the basic compiler checks. For a toolchain file shipped with a toolchain making adjustments for toolchain changes is of course possible immediately, while with CMake we have to wait for the next release if such changes are necessary. It's unfortunately different in various variable names as well in some details of what it sets or doesn't set. That's where most of the changes in this file come from. The main reason we didn't use this right from the start, and probably also the reason the toolchain file in CMake exists is that the NDK didn't have CMake support in older versions. vkrause: It's "better" in the way that it actually works with NDK r20, while CMake 3.16 failed to even… | |||||
apol: I did some testing and for me it works for arm64 but not for arm32. | |||||
I actually didn't test 64bit ARM here, only armv7 and x86, both work. What does break for you there? vkrause: I actually didn't test 64bit ARM here, only armv7 and x86, both work. What does break for you… | |||||
apol: I'm not sure what was going on, seems to work now. | |||||
174 | | ||||
175 | # these aren't set yet at this point by the Android toolchain, but without | ||||
176 | # those the find_package() call in ECMAndroidDeployQt will fail | ||||
177 | set(CMAKE_FIND_LIBRARY_PREFIXES "lib") | ||||
178 | set(CMAKE_FIND_LIBRARY_SUFFIXES ".so" ".a") | ||||
179 | | ||||
180 | # determine STL architecture, which is using a different format than ANDROID_ARCH_ABI | ||||
181 | string(REGEX REPLACE "-(clang)?([0-9].[0-9])?$" "" ECM_ANDROID_STL_ARCH ${ANDROID_TOOLCHAIN_NAME}) | ||||
172 | 182 | | |||
173 | if (NOT DEFINED ECM_ADDITIONAL_FIND_ROOT_PATH) | 183 | if (NOT DEFINED ECM_ADDITIONAL_FIND_ROOT_PATH) | ||
174 | SET(ECM_ADDITIONAL_FIND_ROOT_PATH ${CMAKE_PREFIX_PATH}) | 184 | SET(ECM_ADDITIONAL_FIND_ROOT_PATH ${CMAKE_PREFIX_PATH}) | ||
175 | endif() | 185 | endif() | ||
176 | 186 | | |||
177 | SET(CMAKE_FIND_ROOT_PATH ${CMAKE_ANDROID_NDK} ${CMAKE_ANDROID_NDK}/sysroot ${CMAKE_SYSROOT} ${ECM_ADDITIONAL_FIND_ROOT_PATH}) | 187 | LIST(APPEND CMAKE_FIND_ROOT_PATH ${ECM_ADDITIONAL_FIND_ROOT_PATH}) | ||
178 | SET(CMAKE_FIND_ROOT_PATH_MODE_PROGRAM NEVER) | | |||
179 | set(CMAKE_FIND_ROOT_PATH_MODE_LIBRARY ONLY) | | |||
180 | set(CMAKE_FIND_ROOT_PATH_MODE_INCLUDE ONLY) | | |||
181 | set(CMAKE_FIND_ROOT_PATH_MODE_PACKAGE ONLY) | | |||
182 | 188 | | |||
183 | #we want executables to be shared libraries, hooks will invoke the exported cmake function | 189 | #we want executables to be shared libraries, hooks will invoke the exported cmake function | ||
184 | set(CMAKE_CXX_LINK_EXECUTABLE | 190 | set(CMAKE_CXX_LINK_EXECUTABLE | ||
185 | "<CMAKE_CXX_COMPILER> <CMAKE_SHARED_LIBRARY_CXX_FLAGS> <LINK_FLAGS> <CMAKE_SHARED_LIBRARY_CREATE_CXX_FLAGS> <SONAME_FLAG><TARGET_SONAME> -o <TARGET> <OBJECTS> <LINK_LIBRARIES>" | 191 | "<CMAKE_CXX_COMPILER> <CMAKE_SHARED_LIBRARY_CXX_FLAGS> <LINK_FLAGS> <CMAKE_SHARED_LIBRARY_CREATE_CXX_FLAGS> <SONAME_FLAG><TARGET_SONAME> -o <TARGET> <OBJECTS> <LINK_LIBRARIES>" | ||
186 | ) | 192 | ) | ||
187 | 193 | | |||
188 | set(ECM_DIR "${CMAKE_CURRENT_LIST_DIR}/../cmake" CACHE STRING "") | 194 | set(ECM_DIR "${CMAKE_CURRENT_LIST_DIR}/../cmake" CACHE STRING "") | ||
189 | 195 | | |||
Show All 27 Lines |
Why's this better? Or how is it different?