Fix build with CMake Android toolchain.

This commit is contained in:
Ghislain MARY 2017-03-08 13:11:24 +01:00
parent fb21732c38
commit c769c79878
4 changed files with 85 additions and 4 deletions

View file

@ -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)

38
cmake/FindSupport.cmake Normal file
View file

@ -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)

View file

@ -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)

View file

@ -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})