summaryrefslogtreecommitdiff
path: root/src/corefx/System.Globalization.Native/CMakeLists.txt
blob: 5e38c6bd12144fabeec2ff351e9be539d9493290 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
project(System.Globalization.Native C)

set(CMAKE_INCLUDE_CURRENT_DIR ON)

add_definitions(-DPIC=1)
add_definitions(-DBIT64=1)

set(ICU_HOMEBREW_INC_PATH "/usr/local/opt/icu4c/include")

find_path(UTYPES_H "unicode/utypes.h" PATHS ${ICU_HOMEBREW_INC_PATH})
if(UTYPES_H STREQUAL UTYPES_H-NOTFOUND)
    message(FATAL_ERROR "Cannot find utypes.h, try installing libicu-dev (or the appropriate package for your platform)")
    return()
endif()

if (NOT CLR_CMAKE_PLATFORM_DARWIN)
    find_library(ICUUC icuuc)
    if(ICUUC STREQUAL ICUUC-NOTFOUND)
        message(FATAL_ERROR "Cannot find libicuuc, try installing libicu-dev (or the appropriate package for your platform)")
        return()
    endif()

    find_library(ICUI18N icui18n)
        if(ICUI18N STREQUAL ICUI18N-NOTFOUND)
        message(FATAL_ERROR "Cannot find libicui18n, try installing libicu-dev (or the appropriate package for your platform)")
        return()
    endif()
else()
    find_library(ICUCORE icucore)
    if(ICUI18N STREQUAL ICUCORE-NOTFOUND)
        message(FATAL_ERROR "Cannot find libicucore, skipping build for System.Globalization.Native. .NET globalization is not expected to function.")
        return()
    endif()

    add_definitions(-DOSX_ICU_LIBRARY_PATH=\"${ICUCORE}\")
endif()

include(configure.cmake)

add_compile_options(-fPIC)
add_compile_options(-Wno-incompatible-pointer-types-discards-qualifiers)

set(NATIVEGLOBALIZATION_SOURCES
    pal_calendarData.c
    pal_casing.c
    pal_collation.c
    pal_idna.c
    pal_locale.c
    pal_localeNumberData.c
    pal_localeStringData.c
    pal_normalization.c
    pal_timeZoneInfo.c
    pal_icushim.c
)

include_directories(${UTYPES_H})

_add_library(System.Globalization.Native
    SHARED
    ${NATIVEGLOBALIZATION_SOURCES}
)

_add_library(System.Globalization.Native_Static
    STATIC
    ${NATIVEGLOBALIZATION_SOURCES}
)

# Disable the "lib" prefix.
set_target_properties(System.Globalization.Native PROPERTIES PREFIX "")

# Disable the "lib" prefix and override default name
set_target_properties(System.Globalization.Native_Static PROPERTIES PREFIX "")
set_target_properties(System.Globalization.Native_Static PROPERTIES OUTPUT_NAME System.Globalization.Native)

if(NOT CLR_CMAKE_PLATFORM_DARWIN)
    if (NOT CMAKE_SYSTEM_NAME STREQUAL FreeBSD AND NOT CMAKE_SYSTEM_NAME STREQUAL NetBSD)
        target_link_libraries(System.Globalization.Native
            dl
        )
        target_link_libraries(System.Globalization.Native_Static
            dl
        )
    endif()
else()
    target_link_libraries(System.Globalization.Native
        dl
    )

    add_definitions(-DU_DISABLE_RENAMING=1)
endif()

verify_dependencies(
    System.Globalization.Native
    "Verification failed. System.Globalization.Native.so has undefined dependencies. These are likely ICU APIs that need to be added to icushim.h."
)

# add the install targets
install_clr(System.Globalization.Native)
install(TARGETS System.Globalization.Native_Static DESTINATION .)