forked from eclipse-omr/omr
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathCMakeLists.txt
472 lines (400 loc) · 10.7 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
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
###############################################################################
# Copyright IBM Corp. and others 2017
#
# This program and the accompanying materials are made available under
# the terms of the Eclipse Public License 2.0 which accompanies this
# distribution and is available at https://www.eclipse.org/legal/epl-2.0/
# or the Apache License, Version 2.0 which accompanies this distribution and
# is available at https://www.apache.org/licenses/LICENSE-2.0.
#
# This Source Code may also be made available under the following
# Secondary Licenses when the conditions for such availability set
# forth in the Eclipse Public License, v. 2.0 are satisfied: GNU
# General Public License, version 2 with the GNU Classpath
# Exception [1] and GNU General Public License, version 2 with the
# OpenJDK Assembly Exception [2].
#
# [1] https://www.gnu.org/software/classpath/license.html
# [2] https://openjdk.org/legal/assembly-exception.html
#
# SPDX-License-Identifier: EPL-2.0 OR Apache-2.0 OR GPL-2.0-only WITH Classpath-exception-2.0 OR GPL-2.0-only WITH OpenJDK-assembly-exception-1.0
###############################################################################
include(OmrFindFiles)
if(OMR_OPT_CUDA)
find_package(OmrCuda REQUIRED)
endif()
if(OMR_OS_ZOS)
include(OmrMetalC)
endif()
set(OBJECTS "")
set(VPATH "")
include_directories(${CMAKE_CURRENT_SOURCE_DIR} ${CMAKE_CURRENT_BINARY_DIR})
add_tracegen(common/omrport.tdf)
# Logic below will set the target_includes, and supplement the
# target_sources
omr_add_library(omrport_obj OBJECT
${CMAKE_CURRENT_BINARY_DIR}/ut_omrport.c
)
target_include_directories(omrport_obj
PUBLIC
$<TARGET_PROPERTY:omr_base,INTERFACE_INCLUDE_DIRECTORIES>
)
if(OMR_OPT_CUDA)
target_include_directories(omrport_obj
PRIVATE
${OmrCuda_INCLUDE_DIRS}
)
endif()
target_compile_definitions(omrport_obj
PUBLIC
$<TARGET_PROPERTY:omr_base,INTERFACE_COMPILE_DEFINITIONS>
)
if(OMR_OS_AIX)
list(APPEND OBJECTS omrgetsp.s)
endif()
if(OMR_OS_ZOS)
omr_compile_metalc(
zos390/omrlpdat.mc
zos390/omrlpdat.o
)
# Older versions of CMake don't let you add pre-compiled objects to object-libraries.
# Instead create a new static library for the metal c files
omr_add_library(omrport_metalc STATIC
${CMAKE_CURRENT_BINARY_DIR}/zos390/omrlpdat.o
)
set_target_properties(omrport_metalc PROPERTIES LINKER_LANGUAGE C)
list(APPEND OBJECTS
omrgenerate_ieat_dump.s
omrget_large_pageable_pages_supported.s
omrwto.s
omrpgser_release.s
omrgetuserid.c
omrsysinfo_get_number_CPUs.s
omrjobname.s
omruserid.s
omrzfs.c
)
#TODO more objects here. See port_objects.mk:55
if(OMR_ENV_DATA64)
list(APPEND OBJECTS
omrget_large_pages_supported.s
omrget_large_2gb_pages_supported.s
omrvmem_support_above_bar.s
omrvmem_support_below_bar_64.s
omript_ttoken64.s
omrcel4ro31.c
)
else()
list(APPEND OBJECTS omrvmem_support_below_bar_31.s)
endif()
endif()
list(APPEND OBJECTS
protect_helpers.c
omrgetasid.c
omrgetjobid.c
omrgetjobname.c
omrgetsysname.c
)
if(OMR_ARCH_S390)
list(APPEND OBJECTS omrrttime.s)
elseif(OMR_ARCH_POWER AND OMR_ENV_DATA64 AND OMR_OS_LINUX)
list(APPEND OBJECTS omrrttime.s)
endif()
if(OMR_ARCH_S390)
if(OMR_OS_LINUX)
list(APPEND OBJECTS omrgetstfle.s)
else()
if(OMR_ENV_DATA64)
list(APPEND OBJECTS omrgetstfle64.s)
else()
list(APPEND OBJECTS omrgetstfle31.s)
endif()
endif()
endif()
#TODO another if block @port_objects.mk:89
if(OMR_OS_AIX)
list(APPEND OBJECTS
rt_divu64.s
rt_time.s
)
endif()
list(APPEND OBJECTS
omrcpu.c
omrerror.c
omrerrorhelpers.c
omrexit.c
omrfile.c
omrfiletext.c
omrfilestream.c
omrfilestreamtext.c
)
if(NOT OMR_OS_WINDOWS)
list(APPEND OBJECTS omriconvhelpers.c)
endif()
list(APPEND OBJECTS omrfile_blockingasync.c)
if(OMR_OS_WINDOWS)
list(APPEND OBJECTS omrfilehelpers.c)
endif()
if(OMR_ENV_DATA64)
list(APPEND OBJECTS omrmem32helpers.c)
endif()
list(APPEND OBJECTS
omrheap.c
omrmem.c
omrmemtag.c
omrmemcategories.c
omrport.c
omrmmap.c
j9nls.c
j9nlshelpers.c
omrosbacktrace.c
omrosbacktrace_impl.c
omrintrospect.c
omrintrospect_common.c
omrosdump.c
omrportcontrol.c
omrportptb.c
omrsignal.c
omrsock.c
omrsockptb.c
)
if(NOT OMR_OS_WINDOWS)
list(APPEND OBJECTS omrsignal_context.c)
endif()
list(APPEND OBJECTS
omrsl.c
omrstr.c
omrsysinfo.c
)
list(APPEND OBJECTS omrsysinfo_helpers.c)
list(APPEND OBJECTS omrsyslog.c)
if(OMR_OS_WINDOWS)
#TODO hack to compile mc files
enable_language(RC)
add_custom_command(
OUTPUT ${CMAKE_CURRENT_SOURCE_DIR}/win32/omrsyslogmessages.rc
COMMAND ${CMAKE_MC_COMPILER} ${CMAKE_CURRENT_SOURCE_DIR}/win32/omrsyslogmessages.mc
DEPENDS win32/omrsyslogmessages.mc
WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/win32
)
#TODO need to handle res files properly
#list(APPEND OBJECTS omrsyslogmessages.res)
endif()
list(APPEND OBJECTS
omrtime.c
omrtlshelpers.c
omrtty.c
omrvmem.c
omrmemtag_checks.c
)
if(OMR_OS_AIX)
list(APPEND OBJECTS omrosdump_helpers.c)
elseif(OMR_OS_LINUX)
list(APPEND OBJECTS omrosdump_helpers.c)
elseif(OMR_OS_OSX)
list(APPEND OBJECTS omrosdump_helpers.c)
elseif(OMR_OS_ZOS)
if(NOT OMR_ENV_DATA64)
list(APPEND OBJECTS
omrsignal_ceehdlr.c
omrsignal_context_ceehdlr.c
)
endif()
endif()
if(OMR_HOST_ARCH STREQUAL ppc)
if(OMR_OS_LINUX)
list(APPEND OBJECTS auxv.c)
endif()
elseif(OMR_ARCH_S390)
if(OMR_OS_LINUX)
list(APPEND OBJECTS auxv.c)
endif()
elseif(OMR_ARCH_AARCH64)
if(OMR_OS_LINUX)
list(APPEND OBJECTS auxv.c)
endif()
endif()
if(OMR_OPT_CUDA)
list(APPEND OBJECTS omrcuda.cpp)
endif()
if(NOT OMR_OS_WINDOWS)
list(APPEND OBJECTS
omrsysv_ipcwrappers.c
omrsharedhelper.c
omrshsem.c
omrshsem_deprecated.c
omrshmem.c
)
endif()
#Setup paths and include directories
if(OMR_OS_ZOS)
list(APPEND VPATH zos390)
target_include_directories(omrport_obj PRIVATE zos390)
endif()
if(OMR_OS_WINDOWS)
if(OMR_ENV_DATA64)
list(APPEND VPATH win64amd)
target_include_directories(omrport_obj PRIVATE win64amd)
endif()
endif()
if(OMR_OS_AIX)
if(CMAKE_C_COMPILER_IS_OPENXL)
list(APPEND OMR_C_WARNINGS_AS_ERROR_FLAG -Wno-implicit-function-declaration)
target_compile_options(omrport_obj PUBLIC -Wno-implicit-function-declaration)
endif()
#ifdef I5_VERSION
#ifeq (1,$(OMR_ENV_DATA64))
#vpath % $(PORT_SRCDIR)iseries64
#MODULE_INCLUDES += $(PORT_SRCDIR)iseries64
#endif
#vpath % $(PORT_SRCDIR)iseries
#MODULE_INCLUDES += $(PORT_SRCDIR)iseries
#endif
if(OMR_ENV_DATA64)
list(APPEND VPATH aix64)
target_include_directories(omrport_obj PRIVATE aix64)
endif()
list(APPEND VPATH aix)
target_include_directories(omrport_obj PRIVATE aix)
endif()
if(OMR_OS_LINUX)
if(OMR_ARCH_ARM)
list(APPEND VPATH linuxarm)
target_include_directories(omrport_obj PRIVATE linuxarm)
endif()
if(OMR_ARCH_AARCH64)
list(APPEND VPATH linuxaarch64)
target_include_directories(omrport_obj PRIVATE linuxaarch64)
endif()
if(OMR_ARCH_X86)
if(OMR_ENV_DATA64)
list(APPEND VPATH linuxamd64)
target_include_directories(omrport_obj PRIVATE linuxamd64)
else()
list(APPEND VPATH linux386)
target_include_directories(omrport_obj PRIVATE linux386)
endif()
endif()
if(OMR_ARCH_POWER)
if(OMR_ENV_DATA64)
if(OMR_ENV_LITTLE_ENDIAN)
list(APPEND VPATH linuxppc64le)
target_include_directories(omrport_obj PRIVATE linuxppc64le)
endif()
list(APPEND VPATH linuxppc64)
target_include_directories(omrport_obj PRIVATE linuxppc64)
endif()
list(APPEND VPATH linuxppc)
target_include_directories(omrport_obj PRIVATE linuxppc)
endif()
if(OMR_ARCH_RISCV)
if(OMR_ENV_DATA64)
list(APPEND VPATH linuxriscv64)
target_include_directories(omrport_obj PRIVATE linuxriscv64)
else()
list(APPEND VPATH linuxriscv32)
target_include_directories(omrport_obj PRIVATE linuxriscv32)
endif()
endif()
if(OMR_ARCH_S390)
if(OMR_ENV_DATA64)
list(APPEND VPATH linuxs39064)
target_include_directories(omrport_obj PRIVATE linuxs39064)
endif()
list(APPEND VPATH linuxs390)
target_include_directories(omrport_obj PRIVATE linuxs390)
endif()
if(OMR_ARCH_RISCV)
if(OMR_ENV_DATA64)
list(APPEND VPATH linuxriscv64)
target_include_directories(omrport_obj PRIVATE linuxriscv64)
else()
list(APPEND VPATH linuxriscv32)
target_include_directories(omrport_obj PRIVATE linuxriscv32)
endif()
endif()
list(APPEND VPATH linux)
target_include_directories(omrport_obj PRIVATE linux)
endif()
if(OMR_OS_OSX)
list(APPEND VPATH osx)
target_include_directories(omrport_obj PRIVATE osx)
endif()
if(OMR_OS_WINDOWS)
list(APPEND VPATH win32_include win32)
target_include_directories(omrport_obj PRIVATE win32_include win32)
else()
list(APPEND VPATH unix)
target_include_directories(omrport_obj PRIVATE unix unix_include)
endif()
list(APPEND VPATH common include)
target_include_directories(omrport_obj PRIVATE common include)
#TODO need to set some flags and etc see line 300
omr_find_files(resolvedPaths
PATHS ${VPATH}
FILES ${OBJECTS}
)
if(OMR_OS_WINDOWS)
list(APPEND resolvedPaths win32/omrsyslogmessages.rc)
endif()
target_sources(omrport_obj PRIVATE ${resolvedPaths})
target_include_directories(omrport_obj PRIVATE
../nls
)
# Ensure that we pull in options associated with omr_base.
target_compile_options(omrport_obj PUBLIC $<TARGET_PROPERTY:omr_base,INTERFACE_COMPILE_OPTIONS>)
target_compile_definitions(omrport_obj PUBLIC $<TARGET_PROPERTY:omr_base,INTERFACE_COMPILE_DEFINITIONS>)
target_include_directories(omrport_obj PRIVATE $<TARGET_PROPERTY:omr_base,INTERFACE_INCLUDE_DIRECTORIES>)
# This flag indicates that we are compiling the port library
target_compile_definitions(omrport_obj PRIVATE -DOMRPORT_LIBRARY_DEFINE)
if(OMR_OS_AIX AND OMR_ENV_DATA64)
target_compile_definitions(omrport_obj PRIVATE -D__EXTABI__)
endif()
omr_add_exports(omrport_obj
omrport_allocate_library
omrport_create_library
omrport_getSize
omrport_getVersion
omrport_init_library
omrport_isCompatible
omrport_startup_library
)
target_enable_ddr(omrport_obj)
ddr_add_headers(omrport_obj
${omr_SOURCE_DIR}/include_core/omrport.h
)
ddr_set_add_targets(omrddr omrport_obj)
###
### omrport static lib
###
omr_add_library(omrport STATIC
$<TARGET_OBJECTS:omrport_obj>
)
# Duplicate the export list onto the static library version
get_target_property(port_exports omrport_obj EXPORTED_SYMBOLS)
omr_add_exports(omrport ${port_exports})
target_link_libraries(omrport
PUBLIC
omr_base
PRIVATE
j9avl
j9hashtable
j9pool
${OMR_THREAD_LIB}
${CMAKE_DL_LIBS}
)
if(OMR_OS_ZOS)
target_link_libraries(omrport PRIVATE omrport_metalc)
endif()
if(OMRPORT_OMRSIG_SUPPORT)
target_link_libraries(omrport PRIVATE omrsig)
endif()
if(OMR_OS_LINUX)
target_link_libraries(omrport PRIVATE rt)
endif()
if(OMR_OS_OSX)
target_link_libraries(omrport PRIVATE iconv)
endif()
if(OMR_OS_WINDOWS)
target_link_libraries(omrport PRIVATE psapi pdh)
endif()