forked from MailCore/mailcore2
-
Notifications
You must be signed in to change notification settings - Fork 1
/
CMakeLists.txt
184 lines (142 loc) · 3.83 KB
/
CMakeLists.txt
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
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
cmake_minimum_required (VERSION 2.6)
project (mailcore2)
IF(APPLE)
set(CMAKE_CXX__FLAGS "-std=c++11 -stdlib=libc++")
set(CMAKE_EXE_LINKER_FLAGS "-lc++ -stdlib=libc++")
set(additional_lib_searchpath
"${CMAKE_CURRENT_SOURCE_DIR}/Externals/ctemplate-osx/lib"
"${CMAKE_CURRENT_SOURCE_DIR}/Externals/libetpan-osx/lib"
)
execute_process(COMMAND xcrun --sdk macosx --show-sdk-path OUTPUT_VARIABLE sdkpath)
string(STRIP "${sdkpath}" sdkpath)
set(additional_includes
"${CMAKE_CURRENT_SOURCE_DIR}/Externals/ctemplate-osx/include"
"${CMAKE_CURRENT_SOURCE_DIR}/Externals/libetpan-osx/include"
/usr/include/tidy
/usr/include/libxml2
"${sdkpath}/usr/include/tidy"
"${sdkpath}/usr/include/libxml2"
)
message(STATUS "${additional_includes}")
set(mac_libraries iconv)
ELSEIF(${CMAKE_SYSTEM_NAME} MATCHES "Linux")
set(CMAKE_CXX_FLAGS "-std=gnu++0x")
set(additional_includes
/usr/include/tidy
/usr/include/libxml2
)
set(icu_libraries icudata icui18n icuio icule iculx icutest icutu icuuc)
set(linux_libraries ${icu_libraries} pthread uuid)
ENDIF()
IF(${CMAKE_SYSTEM_NAME} MATCHES "Linux")
find_package(PkgConfig)
pkg_check_modules (GLIB2 glib-2.0)
ENDIF()
IF(APPLE)
find_library(FOUNDATIONFRAMEWORK NAMES Foundation)
find_library(SECURITYFRAMEWORK NAMES Security)
find_library(CORESERVICESFRAMEWORK NAMES CoreServices)
ENDIF()
if(NOT APPLE)
# detect icu
find_path(ICU4C_INCLUDE_DIR
NAMES unicode/utf8.h
PATHS ${additional_includes}
)
find_library(ICU4C_LIBRARY
NAMES icudata icui18n icuio icule iculx icutest icutu icuuc
PATHS ${additional_lib_searchpath}
)
if(NOT ICU4C_INCLUDE_DIR OR NOT ICU4C_LIBRARY)
message(FATAL_ERROR "ERROR: Could not find icu4c")
else()
message(STATUS "Found icu4c")
endif()
endif()
IF(ANDROID)
message(STATUS "Android platform")
ELSE()
# detect ctemplate
find_path(CTEMPLATE_INCLUDE_DIR
NAMES ctemplate/template.h
PATHS ${additional_includes}
)
find_library(CTEMPLATE_LIBRARY
NAMES ctemplate
PATHS ${additional_lib_searchpath}
)
if(NOT CTEMPLATE_INCLUDE_DIR OR NOT CTEMPLATE_LIBRARY)
message(FATAL_ERROR "ERROR: Could not find ctemplate")
else()
message(STATUS "Found ctemplate")
endif()
# detect libetpan
find_path(LIBETPAN_INCLUDE_DIR
NAMES libetpan/libetpan.h
PATHS ${additional_includes}
)
find_library(LIBETPAN_LIBRARY
NAMES etpan
PATHS ${additional_lib_searchpath}
)
if(NOT LIBETPAN_INCLUDE_DIR OR NOT LIBETPAN_LIBRARY)
message(FATAL_ERROR "ERROR: Could not find libetpan")
else()
message(STATUS "Found libetpan")
endif()
# detect tidy
find_path(TIDY_INCLUDE_DIR
NAMES tidy.h
PATHS ${additional_includes}
)
find_library(TIDY_LIBRARY
NAMES tidy
PATHS ${additional_lib_searchpath}
)
if(NOT TIDY_INCLUDE_DIR OR NOT TIDY_LIBRARY)
message(FATAL_ERROR "ERROR: Could not find tidy")
else()
message(STATUS "Found tidy")
endif()
# detect uuid
find_path(UUID_INCLUDE_DIR
NAMES uuid/uuid.h
PATHS ${additional_includes}
)
if(NOT UUID_INCLUDE_DIR)
message(FATAL_ERROR "ERROR: Could not find uuid")
else()
message(STATUS "Found uuid")
endif()
# detect libxml2
find_path(LIBXML_INCLUDE_DIR
NAMES libxml/xmlreader.h
PATHS ${additional_includes}
)
find_library(LIBXML_LIBRARY
NAMES xml2
PATHS ${additional_lib_searchpath}
)
if(NOT LIBXML_INCLUDE_DIR OR NOT LIBXML_LIBRARY)
message(FATAL_ERROR "ERROR: Could not find libxml2")
else()
message(STATUS "Found libxml2")
endif()
# detect zlib
find_path(ZLIB_INCLUDE_DIR
NAMES zlib.h
PATHS ${additional_includes}
)
find_library(ZLIB_LIBRARY
NAMES z
PATHS ${additional_lib_searchpath}
)
if(NOT ZLIB_INCLUDE_DIR OR NOT ZLIB_LIBRARY)
message(FATAL_ERROR "ERROR: Could not find zlib")
else()
message(STATUS "Found zlib")
endif()
ENDIF() # Android platform
add_subdirectory (src)
add_subdirectory (tests)
add_subdirectory (unittest)