forked from ethereum/aleth
-
Notifications
You must be signed in to change notification settings - Fork 0
/
CMakeLists.txt
514 lines (434 loc) · 13 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
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
# cmake global
cmake_minimum_required(VERSION 2.8.12)
set(PROJECT_VERSION "0.9.41")
if (${CMAKE_VERSION} VERSION_GREATER 3.0)
cmake_policy(SET CMP0042 OLD) # fix MACOSX_RPATH
cmake_policy(SET CMP0048 NEW) # allow VERSION argument in project()
project(ethereum VERSION ${PROJECT_VERSION})
else()
project(ethereum)
endif()
set(CMAKE_AUTOMOC ON)
# link_directories interprate relative paths with respect to CMAKE_CURRENT_SOURCE_DIR
cmake_policy(SET CMP0015 NEW)
# let cmake autolink dependencies on windows
# it's specified globally, cause qt libraries requires that on windows and they are also found globally
cmake_policy(SET CMP0020 NEW)
# 3.1 and above
if ((${CMAKE_MAJOR_VERSION} GREATER 2) AND (${CMAKE_MINOR_VERSION} GREATER 0))
# implicitly dereference variables (deprecated in 3.1)
cmake_policy(SET CMP0054 NEW)
endif()
list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/cmake")
######################################################################################################
# note: The value "default" which provides the defaults is just a fake value
# which lets us keep the default values of all build options and is set at
# the beginning of this file.
# TODO: Abstract into something sensible and move into a function.
if ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "MSVC")
set(DECENT_PLATFORM OFF)
else ()
set(DECENT_PLATFORM ON)
endif ()
#defaults:
set(D_CMAKE_BUILD_TYPE "RelWithDebInfo")
set(D_SERPENT ${DECENT_PLATFORM})
set(D_SOLIDITY ON)
set(D_USENPM OFF)
set(D_GUI ON)
set(D_TOOLS ON)
set(D_TESTS ON)
set(D_FATDB ON)
set(D_ETHASHCL ON)
set(D_EVMJIT ON)
set(D_JSCONSOLE ON)
set(D_JSONRPC ON)
set(D_VMTRACE OFF)
set(D_PARANOID OFF)
set(D_PROFILING OFF)
set(D_ROCKSDB OFF)
set(D_NOBOOST OFF)
set(D_OLYMPIC OFF)
set(D_MINER ON)
set(D_ETHKEY ON)
if (BUNDLE STREQUAL "minimal")
set(D_SERPENT OFF)
set(D_SOLIDITY OFF)
set(D_USENPM OFF)
set(D_GUI OFF)
set(D_TOOLS ON)
set(D_TESTS OFF)
elseif (BUNDLE STREQUAL "full")
set(D_SERPENT ${DECENT_PLATFORM})
set(D_SOLIDITY ON)
set(D_USENPM ON)
set(D_GUI ON)
set(D_TOOLS ON)
set(D_TESTS ON)
set(D_FATDB ON)
elseif (BUNDLE STREQUAL "cli")
set(D_SERPENT ${DECENT_PLATFORM})
set(D_SOLIDITY ON)
set(D_USENPM ON)
set(D_GUI OFF)
set(D_TOOLS ON)
set(D_TESTS ON)
set(D_FATDB ON)
elseif (BUNDLE STREQUAL "core")
set(D_SERPENT OFF)
set(D_SOLIDITY ON)
set(D_USENPM OFF)
set(D_GUI ON)
set(D_TOOLS ON)
set(D_TESTS OFF)
set(D_FATDB ON)
elseif (BUNDLE STREQUAL "tests")
set(D_SERPENT ${DECENT_PLATFORM})
set(D_SOLIDITY ON)
set(D_USENPM OFF)
set(D_GUI OFF)
set(D_TOOLS OFF)
set(D_TESTS ON)
set(D_FATDB ON)
elseif (BUNDLE STREQUAL "user")
set(D_SERPENT OFF)
set(D_SOLIDITY OFF)
set(D_USENPM OFF)
set(D_GUI ON)
set(D_TOOLS ON)
set(D_TESTS OFF)
elseif (BUNDLE STREQUAL "wallet")
set(D_SERPENT OFF)
set(D_SOLIDITY OFF)
set(D_USENPM OFF)
set(D_GUI OFF)
set(D_TOOLS OFF)
set(D_TESTS OFF)
set(D_ETHKEY ON)
set(D_MINER OFF)
set(D_ETHASHCL OFF)
set(D_FATDB OFF)
set(D_JSONRPC OFF)
set(D_JSCONSOLE OFF)
set(D_EVMJIT OFF)
elseif (BUNDLE STREQUAL "miner")
set(D_SERPENT OFF)
set(D_SOLIDITY OFF)
set(D_USENPM OFF)
set(D_GUI OFF)
set(D_TOOLS OFF)
set(D_TESTS OFF)
set(D_ETHKEY OFF)
set(D_MINER ON)
set(D_ETHASHCL ON)
set(D_FATDB OFF)
set(D_JSONRPC OFF)
set(D_JSCONSOLE OFF)
set(D_EVMJIT OFF)
elseif (BUNDLE STREQUAL "release") # release builds
set(D_SERPENT ${DECENT_PLATFORM})
set(D_SOLIDITY ON)
set(D_USENPM OFF)
set(D_GUI ON)
set(D_TOOLS ON)
set(D_TESTS OFF)
set(D_FATDB OFF)
set(D_ETHASHCL ON)
set(D_EVMJIT ON)
set(D_JSCONSOLE ON)
set(D_JSONRPC ON)
set(D_CMAKE_BUILD_TYPE "Release")
endif ()
if ("${CMAKE_BUILD_TYPE}" STREQUAL "")
set(CMAKE_BUILD_TYPE ${D_CMAKE_BUILD_TYPE})
endif ()
# propagates CMake configuration options to the compiler
function(configureProject)
if (PARANOID)
add_definitions(-DETH_PARANOIA)
endif ()
if (VMTRACE)
add_definitions(-DETH_VMTRACE)
endif ()
if (ETHASHCL)
add_definitions(-DETH_ETHASHCL)
endif()
if (EVMJIT)
add_definitions(-DETH_EVMJIT)
endif()
if (FATDB)
add_definitions(-DETH_FATDB)
endif()
if (SOLIDITY)
add_definitions(-DETH_SOLIDITY)
endif()
if (GUI)
add_definitions(-DETH_GUI)
endif()
if (CPUID_FOUND)
add_definitions(-DETH_CPUID)
endif()
if (CURL_FOUND)
add_definitions(-DETH_CURL)
endif()
if (NOBOOST)
add_definitions(-DNOBOOST)
endif()
if (OLYMPIC)
add_definitions(-DETH_OLYMPIC)
else()
add_definitions(-DETH_FRONTIER)
endif()
add_definitions(-DETH_TRUE)
endfunction()
set(CPPETHEREUM 1)
function(createBuildInfo)
# Set build platform; to be written to BuildInfo.h
set(ETH_BUILD_PLATFORM "${TARGET_PLATFORM}")
if (CMAKE_COMPILER_IS_MINGW)
set(ETH_BUILD_PLATFORM "${ETH_BUILD_PLATFORM}/mingw")
elseif (CMAKE_COMPILER_IS_MSYS)
set(ETH_BUILD_PLATFORM "${ETH_BUILD_PLATFORM}/msys")
elseif (CMAKE_COMPILER_IS_GNUCXX)
set(ETH_BUILD_PLATFORM "${ETH_BUILD_PLATFORM}/g++")
elseif ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "MSVC")
set(ETH_BUILD_PLATFORM "${ETH_BUILD_PLATFORM}/msvc")
elseif ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "Clang")
set(ETH_BUILD_PLATFORM "${ETH_BUILD_PLATFORM}/clang")
else ()
set(ETH_BUILD_PLATFORM "${ETH_BUILD_PLATFORM}/unknown")
endif ()
if (EVMJIT)
set(ETH_BUILD_PLATFORM "${ETH_BUILD_PLATFORM}/JIT")
else ()
set(ETH_BUILD_PLATFORM "${ETH_BUILD_PLATFORM}/int")
endif ()
if (PARANOID)
set(ETH_BUILD_PLATFORM "${ETH_BUILD_PLATFORM}/PARA")
endif ()
#cmake build type may be not specified when using msvc
if (CMAKE_BUILD_TYPE)
set(_cmake_build_type ${CMAKE_BUILD_TYPE})
else()
set(_cmake_build_type "${CMAKE_CFG_INTDIR}")
endif()
message("createBuildInfo()")
# Generate header file containing useful build information
add_custom_target(BuildInfo.h ALL
WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}
COMMAND ${CMAKE_COMMAND} -DETH_SOURCE_DIR="${CMAKE_SOURCE_DIR}" -DETH_DST_DIR="${CMAKE_BINARY_DIR}"
-DETH_BUILD_TYPE="${_cmake_build_type}" -DETH_BUILD_PLATFORM="${ETH_BUILD_PLATFORM}"
-DPROJECT_VERSION="${PROJECT_VERSION}" -DETH_FATDB="${FATDB}"
-P "${ETH_SCRIPTS_DIR}/buildinfo.cmake"
)
include_directories(${CMAKE_CURRENT_BINARY_DIR})
set(CMAKE_INCLUDE_CURRENT_DIR ON)
set(SRC_LIST BuildInfo.h)
endfunction()
######################################################################################################
# Clear invalid option
if ("${CMAKE_BUILD_TYPE}" STREQUAL "Release")
if (PARANOID)
message("Paranoia requires debug - disabling for release build.")
set(PARANOID OFF)
endif ()
if (VMTRACE)
message("VM Tracing requires debug - disabling for release build.")
set (VMTRACE OFF)
endif ()
endif ()
# Force chromium.
set (ETH_HAVE_WEBENGINE 1)
# Backwards compatibility
if (HEADLESS)
message("*** WARNING: -DHEADLESS=1 option is DEPRECATED! Use -DBUNDLE=minimal or -DGUI=0")
set(GUI OFF)
endif ()
macro(eth_format_option O)
if (${${O}})
set(${O} ON)
elseif ("${${O}}" STREQUAL "" AND ${D_${O}})
set(${O} ON)
else()
set(${O} OFF)
endif()
endmacro()
# Normalise build options
eth_format_option(PARANOID)
eth_format_option(VMTRACE)
eth_format_option(EVMJIT)
eth_format_option(FATDB)
eth_format_option(JSONRPC)
eth_format_option(MINER)
eth_format_option(USENPM)
eth_format_option(PROFILING)
eth_format_option(SOLIDITY)
eth_format_option(ROCKSDB)
eth_format_option(GUI)
eth_format_option(TESTS)
eth_format_option(NOBOOST)
eth_format_option(ROCKSDB)
eth_format_option(TOOLS)
eth_format_option(ETHKEY)
eth_format_option(ETHASHCL)
eth_format_option(JSCONSOLE)
eth_format_option(OLYMPIC)
eth_format_option(SERPENT)
if (JSCONSOLE)
set(JSONRPC ON)
endif()
if (GUI)
set(JSONRPC ON)
endif()
# Default CMAKE_BUILD_TYPE accordingly.
set(CMAKE_BUILD_TYPE CACHE STRING ${D_CMAKE_BUILD_TYPE})
# Default TARGET_PLATFORM to ${CMAKE_SYSTEM_NAME}
# change this once we support cross compiling
set(TARGET_PLATFORM CACHE STRING ${CMAKE_SYSTEM_NAME})
if ("x${TARGET_PLATFORM}" STREQUAL "x")
set(TARGET_PLATFORM ${CMAKE_SYSTEM_NAME})
endif ()
include(EthDependencies)
configureProject()
message("------------------------------------------------------------------------")
message("-- CMake Version ${CMAKE_VERSION}")
message("-- CMAKE_BUILD_TYPE Build type ${CMAKE_BUILD_TYPE}")
message("-- TARGET_PLATFORM Target platform ${TARGET_PLATFORM}")
message("-- BUNDLE Build bundle ${BUNDLE}")
message("--------------------------------------------------------------- features")
message("-- Chromium support ${ETH_HAVE_WEBENGINE}")
message("-- Hardware identification support ${CPUID_FOUND}")
message("-- HTTP Request support ${CURL_FOUND}")
message("-- VMTRACE VM execution tracing ${VMTRACE}")
message("-- PROFILING Profiling support ${PROFILING}")
message("-- NOBOOST No BOOST macros in test functions ${NOBOOST}")
message("-- FATDB Full database exploring ${FATDB}")
message("-- JSONRPC JSON-RPC support ${JSONRPC}")
message("-- USENPM Javascript source building ${USENPM}")
message("-- ROCKSDB Prefer rocksdb to leveldb ${ROCKSDB}")
message("-- OLYMPIC Default to the Olympic network ${OLYMPIC}")
message("------------------------------------------------------------- components")
message("-- MINER Build miner ${MINER}")
message("-- ETHKEY Build wallet tools ${ETHKEY}")
message("-- TOOLS Build basic tools ${TOOLS}")
message("-- SOLIDITY Build Solidity language components ${SOLIDITY}")
message("-- SERPENT Build Serpent language components ${SERPENT}")
message("-- GUI Build GUI components ${GUI}")
message("-- TESTS Build tests ${TESTS}")
message("-- ETHASHCL Build OpenCL components ${ETHASHCL}")
message("-- JSCONSOLE Build with javascript console ${JSCONSOLE}")
message("-- EVMJIT Build LLVM-based JIT EVM ${EVMJIT}")
message("------------------------------------------------------------------------")
message("")
set(CMAKE_THREAD_LIBS_INIT pthread)
include(EthCompilerSettings)
message("-- CXXFLAGS: ${CMAKE_CXX_FLAGS}")
# this must be an include, as a function it would mess up with variable scope!
include(EthExecutableHelper)
message("creating build info...")
createBuildInfo()
if (ROCKSDB AND ROCKSDB_FOUND)
set(DB_INCLUDE_DIRS ${ROCKSDB_INCLUDE_DIRS})
set(DB_LIBRARIES ${ROCKSDB_LIBRARIES})
add_definitions(-DETH_ROCKSDB)
else()
set(DB_INCLUDE_DIRS ${LEVELDB_INCLUDE_DIRS})
set(DB_LIBRARIES ${LEVELDB_LIBRARIES})
endif()
if (EVMJIT)
if (NOT DEFINED LLVM_DIR)
if (CMAKE_SYSTEM_NAME STREQUAL "Windows")
set(LLVM_DIR "${CMAKE_SOURCE_DIR}/extdep/install/windows/x64/share/llvm/cmake")
elseif(CMAKE_SYSTEM_NAME STREQUAL "Darwin")
set(LLVM_DIR "/usr/local/opt/llvm/share/llvm/cmake")
endif()
endif()
set(EVMJIT_CPP TRUE) # include CPP-JIT connector
add_subdirectory(evmjit)
if ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "MSVC")
set(EVMJIT_DLLS_LOCAL $<TARGET_FILE:evmjit>)
set(EVMJIT_DLLS optimized ${EVMJIT_DLLS_LOCAL} debug ${EVMJIT_DLLS_LOCAL})
endif()
endif()
if (TOOLS OR GUI OR SOLIDITY OR TESTS)
set(GENERAL 1)
else ()
set(GENERAL 0)
endif ()
add_subdirectory(libdevcore)
if (GENERAL)
add_subdirectory(libevmcore)
add_subdirectory(libevmasm)
add_subdirectory(liblll)
endif ()
if (SERPENT)
add_subdirectory(libserpent)
add_subdirectory(sc)
endif ()
if (SOLIDITY)
add_subdirectory(libsolidity)
endif ()
if (TOOLS)
add_subdirectory(lllc)
if (SOLIDITY)
add_subdirectory(solc)
endif ()
endif ()
if (JSONRPC AND GENERAL)
add_subdirectory(libweb3jsonrpc)
endif ()
if (JSCONSOLE)
add_subdirectory(libjsengine)
add_subdirectory(libjsconsole)
add_subdirectory(ethconsole)
endif ()
if (NOT WIN32)
add_definitions(-DETH_HAVE_SECP256K1)
add_subdirectory(secp256k1)
endif ()
add_subdirectory(libscrypt)
add_subdirectory(libdevcrypto)
if (GENERAL)
add_subdirectory(libp2p)
add_subdirectory(libwhisper)
endif ()
if (GENERAL OR MINER)
add_subdirectory(libethash)
if (ETHASHCL)
add_subdirectory(libethash-cl)
endif ()
endif ()
add_subdirectory(libethcore)
if (GENERAL)
add_subdirectory(libevm)
add_subdirectory(libethereum)
add_subdirectory(libwebthree)
endif ()
if (MINER OR TOOLS)
add_subdirectory(ethminer)
endif ()
if (ETHKEY OR TOOLS)
add_subdirectory(ethkey)
endif ()
if (TESTS)
add_subdirectory(libtestutils)
add_subdirectory(test)
if (JSONRPC)
add_subdirectory(ethrpctest)
endif ()
endif ()
if (TOOLS)
add_subdirectory(rlp)
add_subdirectory(abi)
add_subdirectory(ethvm)
add_subdirectory(eth)
if("x${CMAKE_BUILD_TYPE}" STREQUAL "xDebug")
add_subdirectory(exp)
endif ()
endif()
if (GUI)
add_subdirectory(libnatspec)
add_subdirectory(libjsqrc)
add_subdirectory(alethzero)
add_subdirectory(mix)
endif()