This repository has been archived by the owner on May 14, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 83
/
CMakeLists.txt
126 lines (105 loc) · 3.24 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
cmake_minimum_required(VERSION 3.10)
project(eevm)
set(CMAKE_CXX_STANDARD 17)
if(MSVC)
# Set Windows compiler options.
add_compile_options(/W3 /std:c latest)
else()
# Set Linux compiler options
add_compile_options(-Wall -Werror)
if("${CMAKE_CXX_COMPILER_ID}" STREQUAL "GNU")
separate_arguments(COVERAGE_FLAGS UNIX_COMMAND "--coverage -fprofile-arcs -ftest-coverage")
set(PLATFORM_SPECIFIC_TEST_LIBS "gcov")
else()
separate_arguments(COVERAGE_FLAGS UNIX_COMMAND "-fprofile-instr-generate -fcoverage-mapping")
set(PLATFORM_SPECIFIC_TEST_LIBS "-fprofile-instr-generate")
endif()
endif()
file(GLOB KECCAK_SOURCES
3rdparty/keccak/*.c
)
add_subdirectory(3rdparty)
# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
# Options
# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
option(RECORD_TRACE "Record a detailed trace of EVM execution during test runs" OFF)
if(RECORD_TRACE)
add_definitions(-DRECORD_TRACE)
endif(RECORD_TRACE)
# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
# Common variables
# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
set(EEVM_INCLUDE_DIRS
${CMAKE_CURRENT_SOURCE_DIR}/3rdparty
${CMAKE_CURRENT_SOURCE_DIR}/include
)
set(EEVM_CORE_SRCS
src/disassembler.cpp
src/processor.cpp
src/stack.cpp
src/transaction.cpp
src/util.cpp
)
set(EEVM_SIMPLE_SRCS
src/simple/simpleaccount.cpp
src/simple/simpleglobalstate.cpp
src/simple/simplestorage.cpp
)
# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
# Libraries
# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
add_library(eevm STATIC
${EEVM_CORE_SRCS}
${KECCAK_SOURCES}
)
target_include_directories(eevm PRIVATE
${EEVM_INCLUDE_DIRS}
)
target_link_libraries(eevm
intx::intx
)
# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
# Executables
# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
add_executable(eevm_tests
tests/main.cpp
tests/harness.cpp
tests/rlp.cpp
${EEVM_SIMPLE_SRCS}
)
target_include_directories(eevm_tests PRIVATE
${EEVM_INCLUDE_DIRS}
)
target_compile_options(eevm_tests PRIVATE ${COVERAGE_FLAGS})
target_link_libraries(eevm_tests eevm ${PLATFORM_SPECIFIC_TEST_LIBS})
# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
# Tests
# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
enable_testing()
add_test(
NAME eevm_tests
COMMAND ${CMAKE_CURRENT_SOURCE_DIR}/tests/unit_test_wrapper.sh eevm_tests
)
if(NOT ENV{TEST_DIR})
set_tests_properties(eevm_tests
PROPERTIES
ENVIRONMENT TEST_DIR=${CMAKE_CURRENT_SOURCE_DIR}/3rdparty/test_cases
)
endif()
# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
# Samples
# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
function(add_sample name)
add_executable(${name}
samples/${name}/main.cpp
${EEVM_SIMPLE_SRCS}
)
target_include_directories(${name} PRIVATE
${EEVM_INCLUDE_DIRS}
)
target_link_libraries(${name} eevm)
endfunction()
add_sample(hello_world)
add_sample(sum)
add_sample(erc20)
add_sample(disassembler)