From c769c798788d9117179c756a3ba3232b6eba5bd4 Mon Sep 17 00:00:00 2001 From: Ghislain MARY Date: Wed, 8 Mar 2017 13:11:24 +0100 Subject: [PATCH] Fix build with CMake Android toolchain. --- cmake/FindCpuFeatures.cmake | 38 +++++++++++++++++++++++++++++++++++++ cmake/FindSupport.cmake | 38 +++++++++++++++++++++++++++++++++++++ coreapi/CMakeLists.txt | 11 ++++++++--- tester/CMakeLists.txt | 2 +- 4 files changed, 85 insertions(+), 4 deletions(-) create mode 100644 cmake/FindCpuFeatures.cmake create mode 100644 cmake/FindSupport.cmake diff --git a/cmake/FindCpuFeatures.cmake b/cmake/FindCpuFeatures.cmake new file mode 100644 index 000000000..2753e74e9 --- /dev/null +++ b/cmake/FindCpuFeatures.cmake @@ -0,0 +1,38 @@ +############################################################################ +# FindCpuFeatures.cmake +# Copyright (C) 2017 Belledonne Communications, Grenoble France +# +############################################################################ +# +# This program is free software; you can redistribute it and/or +# modify it under the terms of the GNU General Public License +# as published by the Free Software Foundation; either version 2 +# of the License, or (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program; if not, write to the Free Software +# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. +# +############################################################################ +# +# - Find the Android cpufeatures include file and library +# +# CPUFEATURES_FOUND - system has libcpufeatures +# CPUFEATURES_LIBRARIES - The libraries needed to use libcpufeatures + +find_library(CPUFEATURES_LIBRARIES + NAMES cpufeatures +) + +include(FindPackageHandleStandardArgs) +find_package_handle_standard_args(CpuFeatures + DEFAULT_MSG + CPUFEATURES_LIBRARIES +) + +mark_as_advanced(CPUFEATURES_LIBRARIES) diff --git a/cmake/FindSupport.cmake b/cmake/FindSupport.cmake new file mode 100644 index 000000000..74992ab9e --- /dev/null +++ b/cmake/FindSupport.cmake @@ -0,0 +1,38 @@ +############################################################################ +# FindSupport.cmake +# Copyright (C) 2017 Belledonne Communications, Grenoble France +# +############################################################################ +# +# This program is free software; you can redistribute it and/or +# modify it under the terms of the GNU General Public License +# as published by the Free Software Foundation; either version 2 +# of the License, or (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program; if not, write to the Free Software +# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. +# +############################################################################ +# +# - Find the Android support include file and library +# +# SUPPORT_FOUND - system has libsupport +# SUPPORT_LIBRARIES - The libraries needed to use libsupport + +find_library(SUPPORT_LIBRARIES + NAMES support +) + +include(FindPackageHandleStandardArgs) +find_package_handle_standard_args(Support + DEFAULT_MSG + SUPPORT_LIBRARIES +) + +mark_as_advanced(SUPPORT_LIBRARIES) diff --git a/coreapi/CMakeLists.txt b/coreapi/CMakeLists.txt index c66c93e71..5be25d9a6 100644 --- a/coreapi/CMakeLists.txt +++ b/coreapi/CMakeLists.txt @@ -28,6 +28,10 @@ endif() if(NOT WIN32) find_package(Iconv QUIET) endif() +if(ANDROID) + find_package(CpuFeatures REQUIRED) + find_package(Support REQUIRED) +endif() set(LINPHONE_PRIVATE_HEADER_FILES @@ -213,8 +217,8 @@ if(ENABLE_SHARED) if(BELCARD_FOUND) if(APPLE) - set_target_properties(linphone PROPERTIES LINK_FLAGS "-stdlib=libc++") - endif() + set_target_properties(linphone PROPERTIES LINK_FLAGS "-stdlib=libc++") + endif() endif() set_target_properties(linphone PROPERTIES LINKER_LANGUAGE CXX) @@ -227,7 +231,8 @@ if(ENABLE_SHARED) if(WIN32 AND CMAKE_SYSTEM_NAME STREQUAL "WindowsPhone" AND NOT CMAKE_SYSTEM_NAME STREQUAL "WindowsStore") set_target_properties(linphone PROPERTIES PREFIX "lib") elseif(ANDROID) - set_target_properties(linphone PROPERTIES OUTPUT_NAME "linphone-${NDK_ARCHITECTURE}") + target_link_libraries(linphone PUBLIC "log" ${SUPPORT_LIBRARIES} ${CPUFEATURES_LIBRARIES}) + set_target_properties(linphone PROPERTIES OUTPUT_NAME "linphone-${CMAKE_ANDROID_ARCH_ABI}") add_dependencies(linphone linphonecore-jni-header) endif() if(MSVC) diff --git a/tester/CMakeLists.txt b/tester/CMakeLists.txt index 0eef36426..e6073ef7c 100644 --- a/tester/CMakeLists.txt +++ b/tester/CMakeLists.txt @@ -221,7 +221,7 @@ endif() if(ANDROID OR IOS) if(ANDROID) add_library(linphonetester SHARED ${SOURCE_FILES_C}) - set_target_properties(linphonetester PROPERTIES OUTPUT_NAME "linphonetester-${NDK_ARCHITECTURE}") + set_target_properties(linphonetester PROPERTIES OUTPUT_NAME "linphonetester-${CMAKE_ANDROID_ARCH_ABI}") endif() if(IOS) add_library(linphonetester STATIC ${SOURCE_FILES_C})