Commit 2e2b398f authored by Ghislain MARY's avatar Ghislain MARY

Clean IOS toolchain.

parent e0f344c0
......@@ -93,7 +93,7 @@ else()
"--disable-iconv"
"--enable-cross-compile"
"--cross-prefix=${SDK_BIN_PATH}/"
"--sysroot=${SYSROOT_PATH}"
"--sysroot=${CMAKE_OSX_SYSROOT}"
"--ar=\$AR"
"--cc=\$CC"
"--nm=\$NM"
......
......@@ -21,8 +21,8 @@
############################################################################
set(OSX_FLAGS "")
if(NOT "@LINPHONE_BUILDER_OSX_ARCHITECTURES@" STREQUAL "")
set(OSX_FLAGS "${OSX_FLAGS} -arch @LINPHONE_BUILDER_OSX_ARCHITECTURES@")
if(NOT "@CMAKE_OSX_ARCHITECTURES@" STREQUAL "")
set(OSX_FLAGS "${OSX_FLAGS} -arch @CMAKE_OSX_ARCHITECTURES@")
endif()
if(NOT "@CMAKE_OSX_SYSROOT@" STREQUAL "")
set(OSX_FLAGS "${OSX_FLAGS} -isysroot @CMAKE_OSX_SYSROOT@")
......
......@@ -143,8 +143,8 @@ function(linphone_builder_get_autotools_configuration)
if(CMAKE_TOOLCHAIN_FILE)
list(APPEND _autotools_command "-DCMAKE_TOOLCHAIN_FILE=${CMAKE_TOOLCHAIN_FILE}")
endif()
if(LINPHONE_BUILDER_OSX_ARCHITECTURES)
list(APPEND _autotools_command "-DLINPHONE_BUILDER_OSX_ARCHITECTURES=${LINPHONE_BUILDER_OSX_ARCHITECTURES}")
if(CMAKE_OSX_ARCHITECTURES)
list(APPEND _autotools_command "-DCMAKE_OSX_ARCHITECTURES=${CMAKE_OSX_ARCHITECTURES}")
endif()
list(APPEND _autotools_command "${CMAKE_CURRENT_SOURCE_DIR}/cmake/Autotools/")
execute_process(COMMAND ${CMAKE_COMMAND} -E make_directory ${CMAKE_BINARY_DIR}/Autotools)
......@@ -223,54 +223,59 @@ endmacro()
macro(linphone_builder_apply_flags)
foreach(BUILD_CONFIG "" "_DEBUG" "_MINSIZEREL" "_RELEASE" "_RELWITHDEBINFO")
set(BUILD_TYPES "Debug" "Release" "RelWithDebInfo" "MinSizeRel")
list(FIND BUILD_TYPES "${CMAKE_BUILD_TYPE}" BUILD_TYPE_FOUND)
set(BUILD_TYPE_SUFFIX "")
if(NOT ${BUILD_TYPE_FOUND} EQUAL -1)
string(TOUPPER "${CMAKE_BUILD_TYPE}" UPPER_BUILD_TYPE)
set(BUILD_TYPE_SUFFIX "_${UPPER_BUILD_TYPE}")
endif()
set(BUILD_TYPE_SUFFIX "")
if(LINPHONE_BUILDER_OSX_ARCHITECTURES)
set(CMAKE_OSX_ARCHITECTURES ${LINPHONE_BUILDER_OSX_ARCHITECTURES})
set(AUTOTOOLS_ARCH "-arch ${CMAKE_OSX_ARCHITECTURES}")
set(AUTOTOOLS_C_FLAGS "${AUTOTOOLS_C_FLAGS} ${AUTOTOOLS_ARCH}")
set(AUTOTOOLS_CXX_FLAGS "${AUTOTOOLS_CXX_FLAGS} ${AUTOTOOLS_ARCH}")
set(AUTOTOOLS_OBJC_FLAGS "${AUTOTOOLS_OBJC_FLAGS} ${AUTOTOOLS_ARCH}")
set(AUTOTOOLS_LINKER_FLAGS "${AUTOTOOLS_LINKER_FLAGS} ${AUTOTOOLS_ARCH}")
endif()
if(LINPHONE_BUILDER_CPPFLAGS)
set(CMAKE_C_FLAGS${BUILD_CONFIG} "${CMAKE_C_FLAGS${BUILD_CONFIG}} ${LINPHONE_BUILDER_CPPFLAGS}")
set(CMAKE_CXX_FLAGS${BUILD_CONFIG} "${CMAKE_CXX_FLAGS${BUILD_CONFIG}} ${LINPHONE_BUILDER_CPPFLAGS}")
set(AUTOTOOLS_C_FLAGS${BUILD_CONFIG} "${AUTOTOOLS_C_FLAGS${BUILD_CONFIG}} ${LINPHONE_BUILDER_CPPFLAGS}")
set(AUTOTOOLS_CXX_FLAGS${BUILD_CONFIG} "${AUTOTOOLS_CXX_FLAGS${BUILD_CONFIG}} ${LINPHONE_BUILDER_CPPFLAGS}")
set(CMAKE_C_FLAGS${BUILD_TYPE_SUFFIX} "${CMAKE_C_FLAGS${BUILD_TYPE_SUFFIX}} ${LINPHONE_BUILDER_CPPFLAGS}")
set(CMAKE_CXX_FLAGS${BUILD_TYPE_SUFFIX} "${CMAKE_CXX_FLAGS${BUILD_TYPE_SUFFIX}} ${LINPHONE_BUILDER_CPPFLAGS}")
set(AUTOTOOLS_C_FLAGS "${AUTOTOOLS_C_FLAGS} ${LINPHONE_BUILDER_CPPFLAGS}")
set(AUTOTOOLS_CXX_FLAGS "${AUTOTOOLS_CXX_FLAGS} ${LINPHONE_BUILDER_CPPFLAGS}")
endif()
if(LINPHONE_BUILDER_CFLAGS)
set(CMAKE_C_FLAGS${BUILD_CONFIG} "${CMAKE_C_FLAGS${BUILD_CONFIG}} ${LINPHONE_BUILDER_CFLAGS}")
set(AUTOTOOLS_C_FLAGS${BUILD_CONFIG} "${AUTOTOOLS_C_FLAGS${BUILD_CONFIG}} ${LINPHONE_BUILDER_CFLAGS}")
set(CMAKE_C_FLAGS${BUILD_TYPE_SUFFIX} "${CMAKE_C_FLAGS${BUILD_TYPE_SUFFIX}} ${LINPHONE_BUILDER_CFLAGS}")
set(AUTOTOOLS_C_FLAGS "${AUTOTOOLS_C_FLAGS} ${LINPHONE_BUILDER_CFLAGS}")
endif()
if(LINPHONE_BUILDER_CXXFLAGS)
set(CMAKE_CXX_FLAGS${BUILD_CONFIG} "${CMAKE_CXX_FLAGS${BUILD_CONFIG}} ${LINPHONE_BUILDER_CXXFLAGS}")
set(AUTOTOOLS_CXX_FLAGS${BUILD_CONFIG} "{AUTOTOOLS_CXX_FLAGS${BUILD_CONFIG}} ${LINPHONE_BUILDER_CXX_FLAGS}")
set(CMAKE_CXX_FLAGS${BUILD_TYPE_SUFFIX} "${CMAKE_CXX_FLAGS${BUILD_TYPE_SUFFIX}} ${LINPHONE_BUILDER_CXXFLAGS}")
set(AUTOTOOLS_CXX_FLAGS "{AUTOTOOLS_CXX_FLAGS} ${LINPHONE_BUILDER_CXX_FLAGS}")
endif()
if(LINPHONE_BUILDER_OBJCFLAGS)
set(CMAKE_C_FLAGS${BUILD_CONFIG} "${CMAKE_C_FLAGS${BUILD_CONFIG}} ${LINPHONE_BUILDER_OBJCFLAGS}")
set(AUTOTOOLS_OBJC_FLAGS${BUILD_CONFIG} "${AUTOTOOLS_OBJC_FLAGS${BUILD_CONFIG}} ${LINPHONE_BUILDER_OBJCFLAGS}")
set(CMAKE_C_FLAGS${BUILD_TYPE_SUFFIX} "${CMAKE_C_FLAGS${BUILD_TYPE_SUFFIX}} ${LINPHONE_BUILDER_OBJCFLAGS}")
set(AUTOTOOLS_OBJC_FLAGS "${AUTOTOOLS_OBJC_FLAGS} ${LINPHONE_BUILDER_OBJCFLAGS}")
endif()
if(LINPHONE_BUILDER_LDFLAGS)
# TODO: The two following lines should not be here
set(CMAKE_C_FLAGS${BUILD_CONFIG} "${CMAKE_C_FLAGS${BUILD_CONFIG}} ${LINPHONE_BUILDER_LDFLAGS}")
set(CMAKE_CXX_FLAGS${BUILD_CONFIG} "${CMAKE_CXX_FLAGS${BUILD_CONFIG}} ${LINPHONE_BUILDER_LDFLAGS}")
set(CMAKE_EXE_LINKER_FLAGS${BUILD_CONFIG} "${CMAKE_EXE_LINKER_FLAGS${BUILD_CONFIG}} ${LINPHONE_BUILDER_LDFLAGS}")
set(CMAKE_MODULE_LINKER_FLAGS${BUILD_CONFIG} "${CMAKE_MODULE_LINKER_FLAGS${BUILD_CONFIG}} ${LINPHONE_BUILDER_LDFLAGS}")
set(CMAKE_SHARED_LINKER_FLAGS${BUILD_CONFIG} "${CMAKE_SHARED_LINKER_FLAGS${BUILD_CONFIG}} ${LINPHONE_BUILDER_LDFLAGS}")
set(AUTOTOOLS_LINKER_FLAGS${BUILD_CONFIG} "${AUTOTOOLS_LINKER_FLAGS${BUILD_CONFIG}} ${LINPHONE_BUILDER_LDFLAGS}")
set(CMAKE_EXE_LINKER_FLAGS${BUILD_TYPE_SUFFIX} "${CMAKE_EXE_LINKER_FLAGS${BUILD_TYPE_SUFFIX}} ${LINPHONE_BUILDER_LDFLAGS}")
set(CMAKE_MODULE_LINKER_FLAGS${BUILD_TYPE_SUFFIX} "${CMAKE_MODULE_LINKER_FLAGS${BUILD_TYPE_SUFFIX}} ${LINPHONE_BUILDER_LDFLAGS}")
set(CMAKE_SHARED_LINKER_FLAGS${BUILD_TYPE_SUFFIX} "${CMAKE_SHARED_LINKER_FLAGS${BUILD_TYPE_SUFFIX}} ${LINPHONE_BUILDER_LDFLAGS}")
set(AUTOTOOLS_LINKER_FLAGS "${AUTOTOOLS_LINKER_FLAGS} ${LINPHONE_BUILDER_LDFLAGS}")
endif()
endforeach()
endmacro()
macro(linphone_builder_apply_cmake_flags_to_autotools_project PROJNAME)
if(EP_${PROJNAME}_BUILD_METHOD STREQUAL "autotools")
set(BUILD_TYPES "Debug" "Release" "RelWithDebInfo" "MinSizeRel")
list(FIND BUILD_TYPES "${CMAKE_BUILD_TYPE}" BUILD_TYPE_FOUND)
set(BUILD_TYPE_SUFFIX "")
if(NOT ${BUILD_TYPE_FOUND} EQUAL -1)
string(TOUPPER "${CMAKE_BUILD_TYPE}" UPPER_BUILD_TYPE)
set(BUILD_TYPE_SUFFIX "_${UPPER_BUILD_TYPE}")
endif()
set(ep_asflags "${AUTOTOOLS_AS_FLAGS${BUILD_TYPE_SUFFIX}}")
set(ep_cppflags "${AUTOTOOLS_CPP_FLAGS${BUILD_TYPE_SUFFIX}}")
set(ep_cflags "${AUTOTOOLS_C_FLAGS${BUILD_TYPE_SUFFIX}}")
set(ep_cxxflags "${AUTOTOOLS_CXX_FLAGS${BUILD_TYPE_SUFFIX}}")
set(ep_objcflags "${AUTOTOOLS_OBJC_FLAGS${BUILD_TYPE_SUFFIX}}")
set(ep_ldflags "${AUTOTOOLS_LINKER_FLAGS${BUILD_TYPE_SUFFIX}}")
set(ep_asflags "${AUTOTOOLS_AS_FLAGS}")
set(ep_cppflags "${AUTOTOOLS_CPP_FLAGS}")
set(ep_cflags "${AUTOTOOLS_C_FLAGS}")
set(ep_cxxflags "${AUTOTOOLS_CXX_FLAGS}")
set(ep_objcflags "${AUTOTOOLS_OBJC_FLAGS}")
set(ep_ldflags "${AUTOTOOLS_LINKER_FLAGS}")
endif()
endmacro()
......@@ -746,7 +751,7 @@ endfunction()
macro(linphone_builder_add_dummy_libraries_generation)
if(LINPHONE_BUILDER_DUMMY_LIBRARIES)
linphone_builder_apply_flags()
# linphone_builder_apply_flags()
linphone_builder_set_ep_directories(dummy_libraries)
linphone_builder_expand_external_project_vars()
ExternalProject_Add(EP_dummy_libraries
......
......@@ -58,9 +58,6 @@ if(APPLE)
set(CMAKE_OSX_ARCHITECTURES "i386")
set(LINPHONE_BUILDER_HOST "i686-apple-darwin")
endif()
set(LINPHONE_BUILDER_CPPFLAGS "-arch ${CMAKE_OSX_ARCHITECTURES}")
set(LINPHONE_BUILDER_OBJCFLAGS "-arch ${CMAKE_OSX_ARCHITECTURES}")
set(LINPHONE_BUILDER_LDFLAGS "-arch ${CMAKE_OSX_ARCHITECTURES}")
set(CMAKE_MACOSX_RPATH 1)
endif()
if(WIN32)
......
......@@ -51,7 +51,7 @@ if("${PLATFORM}" MATCHES "Simulator")
else()
set(CLANG_TARGET_SPECIFIER "iphoneos-version-min")
endif()
set(COMMON_FLAGS "-arch ${LINPHONE_BUILDER_OSX_ARCHITECTURES} -m${CLANG_TARGET_SPECIFIER}=${LINPHONE_IOS_DEPLOYMENT_TARGET} -DTARGET_OS_IPHONE=1 -D__IOS -fms-extensions")
set(COMMON_FLAGS "-m${CLANG_TARGET_SPECIFIER}=${LINPHONE_IOS_DEPLOYMENT_TARGET} -DTARGET_OS_IPHONE=1 -D__IOS -fms-extensions")
set(LINPHONE_BUILDER_CPPFLAGS "${COMMON_FLAGS} -Dasm=__asm")
set(LINPHONE_BUILDER_LDFLAGS "${COMMON_FLAGS}")
set(LINPHONE_BUILDER_PKG_CONFIG_LIBDIR ${CMAKE_INSTALL_PREFIX}/lib/pkgconfig) # Restrict pkg-config to search in the install directory
......
#!/bin/bash
xcrun @TOOLNAME@ $*
......@@ -25,48 +25,57 @@ if(NOT APPLE)
message(FATAL_ERROR "You need to build using a Mac OS X system")
endif()
execute_process(COMMAND xcode-select -print-path OUTPUT_VARIABLE XCODE_PATH OUTPUT_STRIP_TRAILING_WHITESPACE)
execute_process(COMMAND xcode-select -print-path
RESULT_VARIABLE XCODE_SELECT_RESULT
OUTPUT_VARIABLE XCODE_PATH
OUTPUT_STRIP_TRAILING_WHITESPACE
)
if(NOT ${XCODE_SELECT_RESULT} EQUAL 0)
message(FATAL_ERROR "xcode-select failed: ${XCODE_SELECT_RESULT}. You may need to install Xcode.")
endif()
string(TOLOWER ${PLATFORM} PLATFORM_LOWER)
execute_process(COMMAND xcrun --sdk iphone${PLATFORM_LOWER} --show-sdk-version RESULT_VARIABLE IOS_SDK_VERSION OUTPUT_VARIABLE XCODE_SDK_VERSION OUTPUT_STRIP_TRAILING_WHITESPACE)
if(NOT ${XCRUN_RESULT} EQUAL 0)
message(FATAL_ERROR "xcrun failed: ${XCRUN_RESULT}. You may need to install Xcode.")
else ()
set(IOS_SDK_VERSION "${XCODE_SDK_VERSION}")
execute_process(COMMAND xcrun --sdk iphone${PLATFORM_LOWER} --show-sdk-version
RESULT_VARIABLE XCRUN_SHOW_SDK_VERSION_RESULT
OUTPUT_VARIABLE IOS_SDK_VERSION
OUTPUT_STRIP_TRAILING_WHITESPACE
)
if(NOT ${XCRUN_SHOW_SDK_VERSION_RESULT} EQUAL 0)
message(FATAL_ERROR "xcrun failed: ${XCRUN_SHOW_SDK_VERSION_RESULT}. You may need to install Xcode.")
endif()
if(EXISTS "${XCODE_PATH}/Platforms/iPhone${PLATFORM}.platform/Developer/SDKs/")
# New path with Xcode 4.3
file(GLOB SDK_PATH_LIST "${XCODE_PATH}/Platforms/iPhone${PLATFORM}.platform/Developer/SDKs/iPhone${PLATFORM}*.sdk")
set(SDK_BIN_PATH "${XCODE_PATH}/Platforms/iPhone${PLATFORM}.platform/Developer/usr/bin")
else()
file(GLOB SDK_PATH_LIST "/Developer/Platforms/iPhone${PLATFORM}.platform/Developer/SDKs/iPhone${PLATFORM}*.sdk")
set(SDK_BIN_PATH "/Developer/Platforms/iPhone${PLATFORM}.platform/Developer/usr/bin")
execute_process(COMMAND xcrun --sdk iphone${PLATFORM_LOWER} --show-sdk-path
RESULT_VARIABLE XCRUN_SHOW_SDK_PATH_RESULT
OUTPUT_VARIABLE CMAKE_OSX_SYSROOT
OUTPUT_STRIP_TRAILING_WHITESPACE
)
if(NOT ${XCRUN_SHOW_SDK_PATH_RESULT} EQUAL 0)
message(FATAL_ERROR "xcrun failed: ${XCRUN_SHOW_SDK_PATH_RESULT}. You may need to install Xcode.")
endif()
list(SORT SDK_PATH_LIST)
list(REVERSE SDK_PATH_LIST)
list(GET SDK_PATH_LIST 0 CMAKE_OSX_SYSROOT)
message(STATUS "Using sysroot path: ${CMAKE_OSX_SYSROOT}")
message(STATUS "Using sdk version: ${IOS_SDK_VERSION}")
set(IOS_TOOLCHAIN_HOST ${COMPILER_PREFIX})
foreach(TOOLNAME clang clang++ ld ar ranlib strip nm)
configure_file(${CMAKE_CURRENT_LIST_DIR}/tool_wrapper.cmake ${CMAKE_CURRENT_BINARY_DIR}/${IOS_TOOLCHAIN_HOST}-${TOOLNAME})
endforeach(TOOLNAME)
execute_process(COMMAND xcrun --sdk iphone${PLATFORM_LOWER} --find clang
RESULT_VARIABLE XCRUN_FIND_CLANG_RESULT
OUTPUT_VARIABLE IOS_CLANG_PATH
OUTPUT_STRIP_TRAILING_WHITESPACE
)
if(NOT ${XCRUN_FIND_CLANG_RESULT} EQUAL 0)
message(FATAL_ERROR "xcrun failed: ${XCRUN_FIND_CLANG_RESULT}. You may need to install Xcode.")
endif()
get_filename_component(IOS_TOOLCHAIN_PATH "${IOS_CLANG_PATH}" DIRECTORY)
set(IOS_TOOLCHAIN_CC "${CMAKE_CURRENT_BINARY_DIR}/${IOS_TOOLCHAIN_HOST}-clang")
set(IOS_TOOLCHAIN_CXX "${CMAKE_CURRENT_BINARY_DIR}/${IOS_TOOLCHAIN_HOST}-clang++")
set(IOS_TOOLCHAIN_OBJC "${CMAKE_CURRENT_BINARY_DIR}/${IOS_TOOLCHAIN_HOST}-clang")
set(IOS_TOOLCHAIN_LD "${CMAKE_CURRENT_BINARY_DIR}/${IOS_TOOLCHAIN_HOST}-ld")
set(IOS_TOOLCHAIN_AR "${CMAKE_CURRENT_BINARY_DIR}/${IOS_TOOLCHAIN_HOST}-ar")
set(IOS_TOOLCHAIN_RANLIB "${CMAKE_CURRENT_BINARY_DIR}/${IOS_TOOLCHAIN_HOST}-ranlib")
set(IOS_TOOLCHAIN_STRIP "${CMAKE_CURRENT_BINARY_DIR}/${IOS_TOOLCHAIN_HOST}-strip")
set(IOS_TOOLCHAIN_NM "${CMAKE_CURRENT_BINARY_DIR}/${IOS_TOOLCHAIN_HOST}-nm")
message(STATUS "Using sysroot path: ${CMAKE_OSX_SYSROOT}")
message(STATUS "Using sdk version: ${IOS_SDK_VERSION}")
set(SDK_BIN_PATH "${CMAKE_OSX_SYSROOT}/../../usr/bin")
set(IOS_TOOLCHAIN_CC "${IOS_TOOLCHAIN_PATH}/clang")
set(IOS_TOOLCHAIN_CXX "${IOS_TOOLCHAIN_PATH}/clang++")
set(IOS_TOOLCHAIN_OBJC "${IOS_TOOLCHAIN_PATH}/clang")
set(IOS_TOOLCHAIN_LD "${IOS_TOOLCHAIN_PATH}/ld")
set(IOS_TOOLCHAIN_AR "${IOS_TOOLCHAIN_PATH}/ar")
set(IOS_TOOLCHAIN_RANLIB "${IOS_TOOLCHAIN_PATH}/ranlib")
set(IOS_TOOLCHAIN_STRIP "${IOS_TOOLCHAIN_PATH}/strip")
set(IOS_TOOLCHAIN_NM "${IOS_TOOLCHAIN_PATH}/nm")
execute_process(COMMAND xcodebuild -version OUTPUT_VARIABLE XCODE_VERSION_RAW OUTPUT_STRIP_TRAILING_WHITESPACE)
STRING(REGEX REPLACE "Xcode ([^\n]*).*" "\\1" XCODE_VERSION "${XCODE_VERSION_RAW}")
......
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