This repository has been archived by the owner on Mar 23, 2021. It is now read-only.
forked from TiForward/HAL
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathCMakeLists.txt
337 lines (290 loc) · 10.1 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
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
# HAL
#
# Copyright (c) 2014 by Appcelerator, Inc. All Rights Reserved.
# Licensed under the terms of the Apache Public License.
# Please see the LICENSE included with this distribution for details.
cmake_minimum_required(VERSION 3.0.0)
project(HAL)
set(HAL_VERSION 0.5.0)
set(CMAKE_INCLUDE_CURRENT_DIR ON)
set(CMAKE_INCLUDE_CURRENT_DIR_IN_INTERFACE ON)
option(HAL_DISABLE_TESTS "Disable compiling the tests" OFF)
option(HAL_DEFINE_JSCLASSDEFINITIONEMPTY "Define HAL_DEFINE_JSCLASSDEFINITIONEMPTY" ON)
option(HAL_RENAME_AXWAYHAL "Rename DLL to AXWAYHAL" OFF)
option(HAL_USE_STRING_BOOLEAN_CONVERSION "Use Java-like string-boolean conversion" ON)
# Define helper functions and macros.
include(${PROJECT_SOURCE_DIR}/cmake/internal_utils.cmake)
# Target architecture, only available for iOS
set(ARCH "i386" CACHE STRING "Target Architecture")
# Target platform, only available on Xcode
# "macosx", "iphoneos" or "iphonesimulator"
set(PLATFORM "macosx" CACHE STRING "Target Platform")
# Build shared library by default
set(LIBRARY_BUILD_TYPE SHARED)
# Defined in internal_utils.cmake.
config_compiler_and_linker()
# Prepare SDK configuration for iOS
if (NOT WIN32 AND ${PLATFORM} STREQUAL "iphoneos" OR ${PLATFORM} STREQUAL "iphonesimulator")
set(LIBRARY_BUILD_TYPE STATIC)
config_cmake_system_framework_path(${PLATFORM})
endif()
# Allow "make test" to work.
enable_testing()
# We have a custom finder for HAL.
list(INSERT CMAKE_MODULE_PATH 0 ${PROJECT_SOURCE_DIR}/cmake)
find_package(JavaScriptCore REQUIRED)
set(SOURCE_HAL
include/HAL/HAL.hpp
include/HAL/JSString.hpp
src/JSString.cpp
)
set(SOURCE_HAL_detail
include/HAL/detail/JSBase.hpp
src/detail/JSBase.cpp
include/HAL/detail/JSUtil.hpp
src/detail/JSUtil.cpp
include/HAL/detail/HashUtilities.hpp
include/HAL/detail/JSPerformanceCounter.hpp
include/HAL/detail/JSPerformanceCounterPrinter.hpp
)
set(SOURCE_JSExport
include/HAL/JSExport.hpp
include/HAL/JSExportObject.hpp
src/JSExportObject.cpp
)
set(SOURCE_JSExport_detail
include/HAL/detail/JSExportClassDefinition.hpp
include/HAL/detail/JSExportClassDefinitionBuilder.hpp
include/HAL/detail/JSExportClass.hpp
include/HAL/detail/JSExportCallbacks.hpp
include/HAL/detail/JSExportNamedFunctionPropertyCallback.hpp
include/HAL/detail/JSExportNamedValuePropertyCallback.hpp
include/HAL/detail/JSValueUtil.hpp
src/detail/JSValueUtil.cpp
)
set(SOURCE_JSClass
include/HAL/JSClassDefinition.hpp
src/JSClassDefinition.cpp
include/HAL/JSClassAttribute.hpp
include/HAL/JSClass.hpp
src/JSClass.cpp
)
set(SOURCE_JSClass_detail
include/HAL/detail/JSPropertyCallback.hpp
src/detail/JSPropertyCallback.cpp
include/HAL/detail/JSStaticValue.hpp
src/detail/JSStaticValue.cpp
include/HAL/detail/JSStaticFunction.hpp
src/detail/JSStaticFunction.cpp
)
set(SOURCE_JSContext
include/HAL/JSContextGroup.hpp
src/JSContextGroup.cpp
include/HAL/JSContext.hpp
src/JSContext.cpp
)
set(SOURCE_JSValue
include/HAL/JSValue.hpp
src/JSValue.cpp
include/HAL/JSUndefined.hpp
include/HAL/JSNull.hpp
include/HAL/JSBoolean.hpp
include/HAL/JSNumber.hpp
)
set(SOURCE_JSObject
include/HAL/JSPropertyAttribute.hpp
include/HAL/JSPropertyNameArray.hpp
src/JSPropertyNameArray.cpp
include/HAL/JSObject.hpp
src/JSObject.cpp
include/HAL/JSArray.hpp
src/JSArray.cpp
include/HAL/JSDate.hpp
src/JSDate.cpp
include/HAL/JSError.hpp
src/JSError.cpp
include/HAL/JSRegExp.hpp
src/JSRegExp.cpp
include/HAL/JSFunction.hpp
src/JSFunction.cpp
)
set(SOURCE_JSObject_detail
include/HAL/detail/JSPropertyNameAccumulator.hpp
)
set(SOURCE_JSLogger_detail
include/HAL/detail/JSLogger.hpp
include/HAL/detail/JSLoggerPolicyInterface.hpp
include/HAL/detail/JSLoggerPolicyConsole.hpp
include/HAL/detail/JSLoggerPolicyFile.hpp
include/HAL/detail/JSLoggerPimpl.hpp
src/detail/JSLoggerPimpl.cpp
)
source_group(HAL FILES ${SOURCE_HAL})
source_group(HAL\\detail FILES ${SOURCE_HAL_detail})
source_group(HAL\\JSExport FILES ${SOURCE_JSExport})
source_group(HAL\\JSExport\\detail FILES ${SOURCE_JSExport_detail})
source_group(HAL\\JSClass FILES ${SOURCE_JSClass})
source_group(HAL\\JSClass\\detail FILES ${SOURCE_JSClass_detail})
source_group(HAL\\JSContext FILES ${SOURCE_JSContext})
source_group(HAL\\JSValue FILES ${SOURCE_JSValue})
source_group(HAL\\JSObject FILES ${SOURCE_JSObject})
source_group(HAL\\JSObject\\detail FILES ${SOURCE_JSObject_detail})
source_group(HAL\\JSLogger\\detail FILES ${SOURCE_JSLogger_detail})
#set(CMAKE_CXX_VISIBILITY_PRESET hidden)
#set(CMAKE_VISIBILITY_INLINES_HIDDEN 1)
add_library(HAL ${LIBRARY_BUILD_TYPE}
${SOURCE_HAL}
${SOURCE_HAL_detail}
${SOURCE_JSExport}
${SOURCE_JSExport_detail}
${SOURCE_JSClass}
${SOURCE_JSClass_detail}
${SOURCE_JSContext}
${SOURCE_JSValue}
${SOURCE_JSObject}
${SOURCE_JSObject_detail}
${SOURCE_JSLogger_detail}
)
include(GenerateExportHeader)
generate_export_header(HAL)
target_compile_definitions(HAL PRIVATE HAL_EXPORTS)
#target_compile_definitions(HAL PUBLIC HAL_STATIC_DEFINE)
target_compile_definitions(HAL PRIVATE STATICALLY_LINKED_WITH_JavaScriptCore)
target_include_directories(HAL PUBLIC
${PROJECT_SOURCE_DIR}/include
${JavaScriptCore_INCLUDE_DIRS}
)
target_link_libraries(HAL
${JavaScriptCore_LIBRARIES}
)
if (WIN32)
# Silence this warning when lnking with the JavaScriptCore static
# library:
#
# "warning LNK4099: PDB 'vc120.pdb' was not found with
# 'JavaScriptCore-Debug.lib(...)' ...".
set_property(TARGET HAL APPEND PROPERTY LINK_FLAGS "/IGNORE:4099")
# Silence this warning when lnking with the JavaScriptCore static
# library for the i386 emulator:
#
# "JavaScriptCore-Debug.lib(JSStringRef.obj) : warning LNK4075:
# ignoring '/EDITANDCONTINUE' due to '/SAFESEH' specification".
#
# According to "/IGNORE (Ignore Specific Warnings)" (see
# http://msdn.microsoft.com/en-us/library/dn782850.aspx) some linker
# warnings cannot be ignored and LNK4075 is one of them. However,
# according to "/SAFESEH (Image has Safe Exception Handlers)" (see
# http://msdn.microsoft.com/en-us/library/9a89h429.aspx):
#
# "/SAFESEH is only valid when linking for x86 targets."
#
# Therefore we test for the processor architecture we are targeting
# and if its i386 (i.e. the emulator) then we pass /SAFESEH:NO to
# the linker.
#
# If target platform is Windows Phone/Store,
# we should not disable SAFESEH otherwise Windows App Certification will fail.
#
if (NOT CMAKE_SYSTEM_NAME MATCHES "^Windows(Phone|Store)$")
include(${PROJECT_SOURCE_DIR}/cmake/TargetArch.cmake)
target_architecture(target_architecture)
if (${target_architecture} STREQUAL i386)
set_property(TARGET HAL APPEND_STRING PROPERTY LINK_FLAGS " /SAFESEH:NO")
endif()
endif()
# Silence this warning when lnking the Debug configuration:
#
# "LINK : warning LNK4075: ignoring '/INCREMENTAL' due to '/OPT:ICF'
# specification ..."
#
# According to "/IGNORE (Ignore Specific Warnings)" (see
# http://msdn.microsoft.com/en-us/library/dn782850.aspx) some linker
# warnings cannot be ignored and LNK4075 is one of them. However,
# according to "/INCREMENTAL (Link Incrementally)" (see
# http://msdn.microsoft.com/en-us/library/4khtbfyf.aspx):
#
# "Most programs can be linked incrementally. However, some changes
# are too great, and some options are incompatible with incremental
# linking. LINK performs a full link if any of the following options
# are specified:
# ...
# /OPT:REF is selected
# /OPT:ICF is selected
# ..."
#
# And according to "/OPT (Optimizations)" (see
# http://msdn.microsoft.com/en-us/library/bxwfs976.aspx):
#
# "If /DEBUG is specified, the default for /OPT is NOREF, and all
# functions are preserved in the image."
#
# As well as:
#
# "... we do not recommend that you use /OPT:ICF in debug builds ..."
#
# Therefore we disable /OPT:REF and /OPT:ICF for the Debug
# configuration.
set_property(TARGET HAL APPEND_STRING PROPERTY LINK_FLAGS_DEBUG "/OPT:NOREF /OPT:NOICF")
# When building against Release version of JSC, we see a warning from the linker:
# JavaScriptCore-Release.lib(JSStringRef.obj) : MSIL .netmodule or module compiled with /GL found; restarting link # with /LTCG; add /LTCG to the link command line to improve linker performance
#
# Hence we'll turn on LTCG for release builds of HAL...
set_property(TARGET HAL APPEND_STRING PROPERTY LINK_FLAGS_RELEASE "/LTCG")
endif()
if (HAL_DEFINE_JSCLASSDEFINITIONEMPTY)
add_definitions("-DHAL_DEFINE_JSCLASSDEFINITIONEMPTY")
endif()
if (NOT HAL_DISABLE_TESTS)
include(${PROJECT_SOURCE_DIR}/cmake/test.cmake)
add_subdirectory(examples)
add_subdirectory(test)
endif()
if (HAL_RENAME_AXWAYHAL)
set_target_properties(HAL PROPERTIES OUTPUT_NAME "AXWAYHAL")
endif()
if (HAL_USE_STRING_BOOLEAN_CONVERSION)
add_definitions("-DHAL_USE_STRING_BOOLEAN_CONVERSION")
endif()
# Support find_package(HAL 0.5 REQUIRED)
set_property(TARGET HAL PROPERTY VERSION ${HAL_VERSION})
set_property(TARGET HAL PROPERTY SOVERSION 0)
set_property(TARGET HAL PROPERTY INTERFACE_HAL_MAJOR_VERSION 0)
set_property(TARGET HAL APPEND PROPERTY
COMPATIBLE_INTERFACE_STRING HAL_MAJOR_VERSION
)
install(TARGETS HAL EXPORT HALTargets
LIBRARY DESTINATION lib
ARCHIVE DESTINATION lib
RUNTIME DESTINATION bin
INCLUDES DESTINATION include
)
export(EXPORT HALTargets
FILE "${CMAKE_BINARY_DIR}/HALTargets.cmake"
)
configure_file(cmake/HALConfig.cmake
"${CMAKE_BINARY_DIR}/HALConfig.cmake"
COPYONLY
)
include(CMakePackageConfigHelpers)
write_basic_package_version_file(
"${CMAKE_BINARY_DIR}/HALConfigVersion.cmake"
VERSION ${HAL_VERSION}
COMPATIBILITY AnyNewerVersion
)
# Store the current build directory in the CMake user package registry
# so that find_package(HAL) works.
export(PACKAGE HAL)
#[[
# TODO: Install files to external locations.
set(ConfigPackageLocation lib/cmake/HAL)
install(EXPORT HALTargets
DESTINATION ${ConfigPackageLocation}
)
install(
FILES
"${CMAKE_CURRENT_BINARY_DIR}/HALConfig.cmake"
"${CMAKE_CURRENT_BINARY_DIR}/HALConfigVersion.cmake"
DESTINATION ${ConfigPackageLocation}
COMPONENT Devel
)
]]