Skip to content

build: support having more than one ICU in use #3205

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jun 29, 2016
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 11 additions & 8 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -154,17 +154,20 @@ set(SWIFT_ANDROID_NDK_GCC_VERSION "" CACHE STRING
"The GCC version to use when building for Android. Currently only 4.9 is supported.")
set(SWIFT_ANDROID_SDK_PATH "" CACHE STRING
"Path to the directory that contains the Android SDK tools that will be passed to the swiftc frontend")
set(SWIFT_ANDROID_ICU_UC "" CACHE STRING
"Path to a directory containing libicuuc.so")
set(SWIFT_ANDROID_ICU_UC_INCLUDE "" CACHE STRING
"Path to a directory containing headers for libicuuc")
set(SWIFT_ANDROID_ICU_I18N "" CACHE STRING
"Path to a directory containing libicui18n.so")
set(SWIFT_ANDROID_ICU_I18N_INCLUDE "" CACHE STRING
"Path to a directory containing headers libicui18n")
set(SWIFT_ANDROID_DEPLOY_DEVICE_PATH "" CACHE STRING
"Path on an Android device where build products will be pushed. These are used when running the test suite against the device")

foreach(sdk ANDROID;FREEBSD;LINUX)
set(SWIFT_${sdk}_ICU_UC "" CACHE STRING
"Path to a directory containing the icuuc library for ${sdk}")
set(SWIFT_${sdk}_ICU_UC_INCLUDE "" CACHE STRING
"Path to a directory containing headers for icuuc for ${sdk}")
set(SWIFT_${sdk}_ICU_I18N "" CACHE STRING
"Path to a directory containing the icui18n library for ${sdk}")
set(SWIFT_${sdk}_ICU_I18N_INCLUDE "" CACHE STRING
"Path to a directory containing headers icui18n for ${sdk}")
endforeach()

#
# User-configurable Darwin-specific options.
#
Expand Down
23 changes: 20 additions & 3 deletions cmake/modules/AddSwift.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -291,12 +291,18 @@ function(_add_variant_link_flags)
list(APPEND result
"-ldl"
"-L${SWIFT_ANDROID_NDK_PATH}/toolchains/arm-linux-androideabi-${SWIFT_ANDROID_NDK_GCC_VERSION}/prebuilt/linux-x86_64/lib/gcc/arm-linux-androideabi/${SWIFT_ANDROID_NDK_GCC_VERSION}.x"
"${SWIFT_ANDROID_NDK_PATH}/sources/cxx-stl/llvm-libc++/libs/armeabi-v7a/libc++_shared.so"
"-L${SWIFT_ANDROID_ICU_UC}" "-L${SWIFT_ANDROID_ICU_I18N}")
"${SWIFT_ANDROID_NDK_PATH}/sources/cxx-stl/llvm-libc++/libs/armeabi-v7a/libc++_shared.so")
else()
list(APPEND result "-lobjc")
endif()

if(NOT "${SWIFT_${LFLAGS_SDK}_ICU_UC}" STREQUAL "")
list(APPEND result "-L${SWIFT_${sdk}_ICU_UC}")
endif()
if(NOT "${SWIFT_${LFLAGS_SDK}_ICU_I18N}" STREQUAL "")
list(APPEND result "-L${SWIFT_${sdk}_ICU_I18N}")
endif()

set("${LFLAGS_RESULT_VAR_NAME}" "${result}" PARENT_SCOPE)
endfunction()

Expand Down Expand Up @@ -513,7 +519,7 @@ function(_add_swift_library_single target name)
message(FATAL_ERROR
"Either SHARED, STATIC, or OBJECT_LIBRARY must be specified")
endif()

# Determine the subdirectory where this library will be installed.
set(SWIFTLIB_SINGLE_SUBDIR
"${SWIFT_SDK_${SWIFTLIB_SINGLE_SDK}_LIB_SUBDIR}/${SWIFTLIB_SINGLE_ARCHITECTURE}")
Expand Down Expand Up @@ -651,6 +657,17 @@ function(_add_swift_library_single target name)
${SWIFTLIB_SINGLE_XCODE_WORKAROUND_SOURCES}
${SWIFT_SECTIONS_OBJECT_END})

if(SWIFTLIB_SINGLE_TARGET_LIBRARY)
if(NOT "${SWIFT_${SWIFTLIB_SINGLE_SDK}_ICU_UC_INCLUDE}" STREQUAL "")
set_property(TARGET "${target}" APPEND_STRING
PROPERTY INCLUDE_DIRECTORIES "${SWIFT_${SWIFTLIB_SINGLE_SDK}_ICU_UC_INCLUDE}")
endif()
if(NOT "${SWIFT_${SWIFTLIB_SINGLE_SDK}_ICU_I18N_INCLUDE}" STREQUAL "")
set_property(TARGET "${target}" APPEND_STRING
PROPERTY INCLUDE_DIRECTORIES "${SWIFT_${SWIFTLIB_SINGLE_SDK}_ICU_I18N_INCLUDE}")
endif()
endif()

# The section metadata objects are generated sources, and we need to tell CMake
# not to expect to find them prior to their generation.
if("${SWIFTLIB_SINGLE_SDK}" STREQUAL "LINUX" OR
Expand Down
16 changes: 10 additions & 6 deletions cmake/modules/FindICU.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -25,12 +25,16 @@ foreach(MODULE ${ICU_FIND_COMPONENTS})
endif()
endforeach()

if(NOT "${SWIFT_ANDROID_ICU_UC_INCLUDE}" STREQUAL "")
set(ICU_UC_INCLUDE_DIR "${SWIFT_ANDROID_ICU_UC_INCLUDE}")
endif()
if(NOT "${SWIFT_ANDROID_ICU_I18N_INCLUDE}" STREQUAL "")
set(ICU_I18N_INCLUDE_DIR "${SWIFT_ANDROID_ICU_I18N_INCLUDE}")
endif()
foreach(sdk ANDROID;FREEBSD;LINUX)
foreach(MODULE ${ICU_FIND_COMPONENTS})
if("${SWIFT_${sdk}_ICU_${MODULE}_INCLUDE}" STREQUAL "")
set(SWIFT_${sdk}_ICU_${MODULE}_INCLUDE ${ICU_${MODULE}_INCLUDE_DIRS})
endif()
if("${SWIFT_${sdk}_ICU_${MODULE}}" STREQUAL "")
set(SWIFT_${sdk}_ICU_${MODULE} ${ICU_${MODULE}_LIBRARY})
endif()
endforeach()
endforeach()

find_package_handle_standard_args(ICU DEFAULT_MSG ${ICU_REQUIRED})
mark_as_advanced(${ICU_REQUIRED})
2 changes: 0 additions & 2 deletions stdlib/public/stubs/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,6 @@ else()
find_package(ICU REQUIRED COMPONENTS uc i18n)
set(swift_stubs_unicode_normalization_sources
UnicodeNormalization.cpp)
include_directories(
${ICU_UC_INCLUDE_DIR} ${ICU_I18N_INCLUDE_DIR})
endif()

add_swift_library(swiftStdlibStubs OBJECT_LIBRARY TARGET_LIBRARY
Expand Down