-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathCMakeLists.txt
More file actions
124 lines (92 loc) · 2.77 KB
/
CMakeLists.txt
File metadata and controls
124 lines (92 loc) · 2.77 KB
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
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
cmake_minimum_required(VERSION 3.10)
include("cmake/module/icu_sample_upload_config.cmake")
include("cmake/HunterGate.cmake")
HunterGate(
URL "https://github.com/ruslo/hunter/archive/07dbd7563f87c54de738f13a1391347a427c0be0.zip"
SHA1 "c501a9ce42f5a8c447781141b8d53a6b7b8dfdf6"
LOCAL
)
project(icu_sample)
string(COMPARE EQUAL "${CMAKE_SYSTEM_NAME}" "WindowsStore" is_windows_store)
option(ARCHIVE_MODE "ICU data archive mode" OFF)
if(CMAKE_CROSSCOMPILING)
# When cross-compiling pkgdata/icupkg tools build with host toolchain
include(hunter_experimental_add_host_project)
hunter_experimental_add_host_project(cmake/host)
if(WIN32)
set(suffix .exe)
else()
set(suffix "")
endif()
set(ICU_PKGDATA_EXECUTABLE "${HUNTER_HOST_ROOT}/bin/pkgdata${suffix}")
set(ICU_ICUPKG_EXECUTABLE "${HUNTER_HOST_ROOT}/bin/icupkg${suffix}")
else()
# Variables ICU_*_EXECUTABLE provided by package itself
endif()
hunter_add_package(ICU)
find_package(ICU CONFIG REQUIRED)
# Check imported targets {
if(ANDROID OR IOS OR is_windows_store)
set(tu_lib "")
else()
set(tu_lib tu)
endif()
foreach(i data i18n le lx ${tu_lib} uc)
if(NOT TARGET ICU::${i})
message(FATAL_ERROR "ICU::${i} target not found")
endif()
endforeach()
# }
# Check variables {
if(NOT EXISTS "${ICU_PKGDATA_EXECUTABLE}")
message(FATAL_ERROR "pkgdata not found")
endif()
if(NOT EXISTS "${ICU_ICUPKG_EXECUTABLE}")
message(FATAL_ERROR "icupkg not found")
endif()
# }
add_executable(foo convsamp.cpp flagcb.c flagcb.h)
target_link_libraries(foo PUBLIC ICU::uc)
if(ARCHIVE_MODE)
target_compile_definitions(foo PRIVATE ARCHIVE_MODE)
endif()
# Run native tests {
hunter_add_package(gauze)
find_package(gauze CONFIG REQUIRED)
enable_testing()
if(IOS AND IGNORE_IOS_TEST)
# ignore native test, just link to avoid build error
target_link_libraries(foo PUBLIC gauze::gauze)
else()
if(ARCHIVE_MODE)
set(args $<GAUZE_RESOURCE_FILE:${ICU_DATA_FILE}>)
else()
set(args "")
endif()
if(is_windows_store)
# TODO: How to run test?
target_link_libraries(foo PUBLIC gauze::gauze)
else()
gauze_add_test(NAME foo COMMAND foo ${args})
if(WIN32 OR CYGWIN)
set(new_path "${ICU_ROOT}/bin")
list(APPEND new_path $ENV{PATH})
if(WIN32)
string(REPLACE ";" "\;" new_path "${new_path}")
elseif(CYGWIN)
string(REPLACE ";" ":" new_path "${new_path}")
else()
message(FATAL_ERROR "Unreachable")
endif()
set_tests_properties(
foo PROPERTIES ENVIRONMENT "PATH=${new_path}"
)
endif()
endif()
endif()
# }
# Run host tools {
add_test(NAME pkgdata_help COMMAND ${ICU_PKGDATA_EXECUTABLE} --help)
set_tests_properties(pkgdata_help PROPERTIES WILL_FAIL TRUE)
add_test(NAME icupkg_help COMMAND ${ICU_ICUPKG_EXECUTABLE} --help)
# }