Commit bb12afe6 authored by Nicolas Michon's avatar Nicolas Michon

Cmake changes for cross-compilation and better use of imported targets

parent 47945043
......@@ -20,7 +20,7 @@
#
############################################################################
cmake_minimum_required(VERSION 3.0)
cmake_minimum_required(VERSION 3.1)
include(FeatureSummary)
......
......@@ -35,7 +35,7 @@ if(ENABLE_TUNNEL)
lcb_dependencies("tunnel")
endif()
if(NOT APPLE AND NOT ANDROID AND NOT QNX)
if(NOT APPLE AND NOT ANDROID AND NOT QNX AND ENABLE_ZLIB)
lcb_dependencies("zlib")
endif()
......
......@@ -31,8 +31,13 @@ lcb_spec_file("bzrtp.spec")
lcb_dependencies("bctoolbox")
if(NOT APPLE)
# Do not build xml2 neither sqlite3 on Apple systems (Mac OS X and iOS), they are provided by the system
lcb_dependencies("xml2" "sqlite3")
# Do not build xml2 neither sqlite3 on Apple systems (Mac OS X and iOS), they are provided by the system
if (ENABLE_SQLITE)
lcb_dependencies("sqlite3")
endif()
if (ENABLE_XML2)
lcb_dependencies("xml2")
endif()
endif()
if(ENABLE_UNIT_TESTS)
lcb_dependencies("bcunit")
......
......@@ -25,4 +25,6 @@ lcb_external_source_paths("externals/jose")
lcb_spec_file("jose.spec")
lcb_dependencies("jansson")
lcb_dependencies("zlib")
if (ENABLE_ZLIB)
lcb_dependencies("zlib")
endif()
......@@ -34,5 +34,6 @@ if(ENABLE_UNIT_TESTS)
endif()
lcb_cmake_options(
"-DENABLE_C_INTERFACE=yes"
"-DENABLE_C_INTERFACE=yes"
"-DENABLE_UNIT_TESTS=${ENABLE_UNIT_TESTS}"
)
......@@ -50,8 +50,13 @@ endif()
if(NOT APPLE)
# Do not build sqlite3, xml2 and zlib on Apple systems (Mac OS X and iOS), they are provided by the system
lcb_dependencies("sqlite3" "xml2")
if(NOT ANDROID AND NOT QNX)
if (ENABLE_SQLITE)
lcb_dependencies("sqlite3")
endif()
if (ENABLE_XML2)
lcb_dependencies("xml2")
endif()
if(NOT ANDROID AND NOT QNX AND ENABLE_ZLIB)
lcb_dependencies("zlib")
endif()
endif()
......
......@@ -26,7 +26,9 @@ lcb_git_tag("d65cd2ea9d740f62884e0beaf8ab86740620c783")
lcb_external_source_paths("externals/minizip")
lcb_spec_file("minizip.spec")
lcb_dependencies("zlib")
if (ENABLE_ZLIB)
lcb_dependencies("zlib")
endif()
lcb_cmake_options(
"-DUSE_AES=NO"
......
......@@ -23,14 +23,20 @@
lcb_git_repository("https://gitlab.linphone.org/BC/public/external/soci.git")
lcb_external_source_paths("externals/soci" "external/soci")
if(NOT APPLE)
# Do not build sqlite3 on Apple systems (Mac OS X and iOS), it is provided by the system
lcb_dependencies("sqlite3")
# Do not build sqlite3 on Apple systems (Mac OS X and iOS), it is provided by the system
if (ENABLE_SQLITE)
lcb_dependencies("sqlite3")
endif()
endif()
lcb_cmake_options(
"-DSOCI_TESTS=NO"
"-DWITH_SQLITE3=YES"
)
if (ENABLE_SOCI_MYSQL)
lcb_cmake_options("-DWITH_MYSQL=YES")
endif()
lcb_package_source(YES)
lcb_spec_file("soci.spec")
lcb_linking_type("-DSOCI_SHARED=YES" "-DSOCI_STATIC=NO")
......
......@@ -148,10 +148,13 @@ else()
"--disable-runtime-cpu-detect"
)
list(REMOVE_ITEM EP_vpx_CONFIGURE_OPTIONS "--enable-multithread")
else()
else()
lcb_use_c_compiler_for_assembler(NO)
if(CMAKE_SYSTEM_PROCESSOR STREQUAL "armv7l")
set(VPX_TARGET "armv7-linux-gcc")
elseif(CMAKE_SYSTEM_PROCESSOR STREQUAL "arm")
#A bit hacky, but CMAKE_SYSTEM_PROCESSOR sometimes doesn't include abi version so assume `armv7` by default
set(VPX_TARGET "armv7-linux-gcc")
else()
if(CMAKE_SIZEOF_VOID_P EQUAL 8)
set(VPX_TARGET "x86_64-linux-gcc")
......@@ -165,6 +168,7 @@ else()
if(USE_TARGET)
lcb_cross_compilation_options(
"--prefix=${CMAKE_INSTALL_PREFIX}"
"--libdir=${CMAKE_INSTALL_PREFIX}/lib"
"--target=${VPX_TARGET}"
)
else()
......
......@@ -60,8 +60,10 @@ macro(linphone_builder_expand_external_project_vars)
set(target_info_list ${target_info_list})
list(GET varname_and_vartype 0 _varname)
list(GET varname_and_vartype 1 _vartype)
list(APPEND LINPHONE_BUILDER_EP_ARGS -D${_varname}:${_vartype}=${${_varname}})
list(APPEND LINPHONE_BUILDER_EP_VARNAMES ${_varname})
if (DEFINED ${_varname})
list(APPEND LINPHONE_BUILDER_EP_ARGS -D${_varname}:${_vartype}=${${_varname}})
list(APPEND LINPHONE_BUILDER_EP_VARNAMES ${_varname})
endif()
endforeach()
endmacro()
......@@ -75,11 +77,14 @@ list(APPEND LINPHONE_BUILDER_EP_VARS
CMAKE_C_FLAGS_MINSIZEREL:STRING
CMAKE_C_FLAGS_RELEASE:STRING
CMAKE_C_FLAGS_RELWITHDEBINFO:STRING
CMAKE_C_IMPLICIT_INCLUDE_DIRECTORIES:LIST
CMAKE_CXX_COMPILER_LAUNCHER:PATH
CMAKE_CXX_FLAGS_DEBUG:STRING
CMAKE_CXX_FLAGS_MINSIZEREL:STRING
CMAKE_CXX_FLAGS_RELEASE:STRING
CMAKE_CXX_FLAGS_RELWITHDEBINFO:STRING
CMAKE_CXX_IMPLICIT_INCLUDE_DIRECTORIES:LIST
CMAKE_EXE_LINKER_FLAGS:STRING
CMAKE_EXE_LINKER_FLAGS_DEBUG:STRING
CMAKE_EXE_LINKER_FLAGS_MINSIZEREL:STRING
CMAKE_EXE_LINKER_FLAGS_RELEASE:STRING
......@@ -88,6 +93,7 @@ list(APPEND LINPHONE_BUILDER_EP_VARS
CMAKE_GENERATOR_PLATFORM:STRING
CMAKE_INSTALL_MESSAGE:STRING
CMAKE_INSTALL_PREFIX:PATH
CMAKE_SYSTEM_PREFIX_PATH:LIST
CMAKE_INSTALL_RPATH:PATH
CMAKE_INSTALL_RPATH_USE_LINK_PATH:BOOL
CMAKE_LIBRARY_OUTPUT_DIRECTORY:PATH
......@@ -99,6 +105,7 @@ list(APPEND LINPHONE_BUILDER_EP_VARS
CMAKE_NO_BUILD_TYPE:BOOL
CMAKE_NO_SYSTEM_FROM_IMPORTED:BOOL
CMAKE_PREFIX_PATH:STRING
CMAKE_STAGING_PREFIX:STRING
CMAKE_PROGRAM_PATH:STRING
CMAKE_RUNTIME_OUTPUT_DIRECTORY:PATH
CMAKE_SHARED_LINKER_FLAGS_DEBUG:STRING
......
......@@ -78,7 +78,8 @@ if(WIN32)
endif()
find_program(PATCH_PROGRAM
NAMES patch patch.exe
NAMES patch patch.exe
CMAKE_FIND_ROOT_PATH_BOTH
)
if(NOT PATCH_PROGRAM)
if(WIN32)
......@@ -89,7 +90,8 @@ if(NOT PATCH_PROGRAM)
endif()
find_program(SED_PROGRAM
NAMES sed sed.exe
NAMES sed sed.exe
CMAKE_FIND_ROOT_PATH_BOTH
)
if(NOT SED_PROGRAM)
if(WIN32)
......
......@@ -137,11 +137,10 @@ lcb_builder_linking_type(vpx "--enable-static" "--disable-shared")
lcb_builder_linking_type(x264 "--enable-static" "--enable-pic")
lcb_builder_install_target(x264 "install-lib-static")
#Copy c++ library to install prefix
#The library has to be present for cmake dependencies and before the install target
file(COPY "${CMAKE_ANDROID_NDK}/sources/cxx-stl/llvm-libc++/libs/${CMAKE_ANDROID_ARCH_ABI}/libc++_shared.so" DESTINATION "${CMAKE_INSTALL_PREFIX}/lib/")
# Copy c++ library to install prefix
file(COPY "${CMAKE_ANDROID_NDK}/sources/cxx-stl/llvm-libc++/libs/${CMAKE_ANDROID_ARCH_ABI}/libc++_shared.so"
DESTINATION "${CMAKE_INSTALL_PREFIX}/lib"
)
if(ENABLE_SANITIZER)
set(SANITIZER_ARCH ${CMAKE_SYSTEM_PROCESSOR})
if(SANITIZER_ARCH MATCHES "^arm")
......
......@@ -54,4 +54,8 @@ set(DEFAULT_VALUE_ENABLE_WEBRTC_AEC ON)
set(DEFAULT_VALUE_ENABLE_ZRTP ON)
set(DEFAULT_VALUE_ENABLE_TOOLS OFF)
set(ENABLE_NLS NO CACHE BOOL "" FORCE)
set(DEFAULT_VALUE_ENABLE_ASSETS ON)
\ No newline at end of file
set(DEFAULT_VALUE_ENABLE_ASSETS ON)
if ((NOT DEFINED CMAKE_INSTALL_PREFIX) OR CMAKE_INSTALL_PREFIX_INITIALIZED_TO_DEFAULT)
set(CMAKE_INSTALL_PREFIX "${CMAKE_BINARY_DIR}/linphone-sdk/desktop" CACHE PATH "Default linphone-sdk installation prefix" FORCE)
endif()
......@@ -49,4 +49,8 @@ set(DEFAULT_VALUE_ENABLE_VPX ON)
set(DEFAULT_VALUE_ENABLE_WASAPI ON)
set(DEFAULT_VALUE_ENABLE_WEBRTC_AEC ON)
set(DEFAULT_VALUE_ENABLE_ZRTP ON)
set(DEFAULT_VALUE_ENABLE_ASSETS ON)
\ No newline at end of file
set(DEFAULT_VALUE_ENABLE_ASSETS ON)
if ((NOT DEFINED CMAKE_INSTALL_PREFIX) OR CMAKE_INSTALL_PREFIX_INITIALIZED_TO_DEFAULT)
set(CMAKE_INSTALL_PREFIX "${CMAKE_BINARY_DIR}/linphone-sdk/desktop" CACHE PATH "Default linphone-sdk installation prefix" FORCE)
endif()
......@@ -48,3 +48,7 @@ set(DEFAULT_VALUE_ENABLE_TOOLS OFF)
set(DEFAULT_VALUE_ENABLE_UPDATE_CHECK ON)
set(DEFAULT_VALUE_ENABLE_ASSETS ON)
set(DEFAULT_VALUE_ENABLE_SWIFT_WRAPPER ON)
if ((NOT DEFINED CMAKE_INSTALL_PREFIX) OR CMAKE_INSTALL_PREFIX_INITIALIZED_TO_DEFAULT)
set(CMAKE_INSTALL_PREFIX "${CMAKE_BINARY_DIR}/linphone-sdk" CACHE PATH "Default linphone-sdk installation prefix" FORCE)
endif()
......@@ -47,3 +47,7 @@ set(DEFAULT_VALUE_ENABLE_WEBRTC_AECM ON)
set(DEFAULT_VALUE_ENABLE_ZRTP ON)
set(ENABLE_NLS NO CACHE BOOL "" FORCE)
set(DEFAULT_VALUE_ENABLE_ASSETS ON)
if ((NOT DEFINED CMAKE_INSTALL_PREFIX) OR CMAKE_INSTALL_PREFIX_INITIALIZED_TO_DEFAULT)
set(CMAKE_INSTALL_PREFIX "${CMAKE_BINARY_DIR}/linphone-sdk" CACHE PATH "Default linphone-sdk installation prefix" FORCE)
endif()
......@@ -27,6 +27,10 @@ lcb_add_option("Debug logs" "Enable debug level logs in libinphone and mediastre
lcb_add_option("Doc" "Enable documentation generation with Doxygen and Sphinx" NO)
lcb_add_option("Tools" "Enable tools binary compilation." "${DEFAULT_VALUE_ENABLE_TOOLS}")
lcb_add_option("unmaintained" "Allow inclusion of unmaintained code in the build." OFF)
lcb_add_option("Xml2" "Enable bc version of libxml2" ON)
lcb_add_option("Sqlite" "Enable bc version of sqlite3" ON)
lcb_add_option("Zlib" "Enable bc version of zlib" ON)
lcb_add_option("Soci mysql" "Enable mysql support of SOCI" OFF)
if(CMAKE_CXX_COMPILER_ID MATCHES "Clang" AND NOT IOS AND NOT ANDROID)
lcb_add_option("Sanitizer" "Enable Clang sanitizer" "${DEFAULT_VALUE_ENABLE_SANITIZER}")
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment