forked from SOM-st/SOMpp
-
Notifications
You must be signed in to change notification settings - Fork 3
/
CMakeLists.txt
172 lines (137 loc) · 5.17 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
# Copyright (c) 2019 Stefan Marr <[email protected]>
#
# Permission is hereby granted, free of charge, to any person obtaining a copy
# of this software and associated documentation files (the "Software"), to deal
# in the Software without restriction, including without limitation the rights
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
# copies of the Software, and to permit persons to whom the Software is
# furnished to do so, subject to the following conditions:
#
# The above copyright notice and this permission notice shall be included in
# all copies or substantial portions of the Software.
#
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
# THE SOFTWARE.
cmake_minimum_required (VERSION 3.12)
project(SOMpp LANGUAGES CXX)
set(CMAKE_PROJECT_ROOT ${CMAKE_CURRENT_SOURCE_DIR})
set(CMAKE_CXX_STANDARD 14)
set(ROOT_DIR "${CMAKE_CURRENT_SOURCE_DIR}")
set(SRC_DIR "${ROOT_DIR}/src")
set(COMPILER_DIR "${SRC_DIR}/compiler")
set(INTERPRETER_DIR "${SRC_DIR}/interpreter")
set(MEMORY_DIR "${SRC_DIR}/memory")
set(MISC_DIR "${SRC_DIR}/misc")
set(VM_DIR "${SRC_DIR}/vm")
set(VMOBJECTS_DIR "${SRC_DIR}/vmobjects")
set(UNITTEST_DIR "${SRC_DIR}/unitTests")
set(PRIMITIVES_DIR "${SRC_DIR}/primitives")
set(PRIMITIVESCORE_DIR "${SRC_DIR}/primitivesCore")
file(GLOB COMPILER_SRC ${COMPILER_DIR}/*.cpp)
file(GLOB INTERPRETER_SRC ${INTERPRETER_DIR}/*.cpp)
file(GLOB MEMORY_SRC ${MEMORY_DIR}/*.cpp)
file(GLOB MISC_SRC ${MISC_DIR}/*.cpp)
file(GLOB VM_SRC ${VM_DIR}/*.cpp)
file(GLOB VMOBJECTS_SRC ${VMOBJECTS_DIR}/*.cpp)
file(GLOB MAIN_SRC ${SRC_DIR}/*.cpp)
file(GLOB PRIMITIVES_SRC ${PRIMITIVES_DIR}/*.cpp)
file(GLOB PRIMITIVESCORE_SRC ${PRIMITIVESCORE_DIR}/*.cpp)
file(GLOB UNITTEST_SRC ${UNITTEST_DIR}/*.cpp)
option(USE_TAGGING "Enable immediate integers using tagging" FALSE)
set(GC_TYPE "COPYING" CACHE STRING "Select the type of GC to be used: COPYING, MARK_SWEEP, GENERATIONAL")
option(CACHE_INTEGER "Enable caching of boxed integers" FALSE)
set(INT_CACHE_MIN_VALUE -5 CACHE STRING "Lower bound of cached integers")
set(INT_CACHE_MAX_VALUE 100 CACHE STRING "Upper bound of cached integers")
option(GENERATE_INTEGER_HISTOGRAM "Generate histogram of allocated integers" FALSE)
option(GENERATE_ALLOCATION_STATISTICS "Generate allocation statistics" FALSE)
option(LOG_RECEIVER_TYPES "Log types of receivers" FALSE)
option(UNSAFE_FRAME_OPTIMIZATION "Enable unsafe frame optimization" FALSE)
option(ADDITIONAL_ALLOCATION "Enable additional allocations" FALSE)
option(FOR_PROFILING "Compile for profiling" FALSE)
if (USE_TAGGING)
add_definitions(-DUSE_TAGGING)
if (CACHE_INTEGER)
message(FATAL_ERROR "CACHE_INTEGER needs to be disabled when tagging is used.")
endif ()
endif()
if (CACHE_INTEGER)
add_definitions(
-DCACHE_INTEGER
-DINT_CACHE_MIN_VALUE=${INT_CACHE_MIN_VALUE}
-DINT_CACHE_MAX_VALUE=${INT_CACHE_MAX_VALUE})
endif ()
if (GENERATE_INTEGER_HISTOGRAM)
add_definitions(-DGENERATE_INTEGER_HISTOGRAM)
endif ()
if (GENERATE_ALLOCATION_STATISTICS)
add_definitions(-DGENERATE_ALLOCATION_STATISTICS)
endif ()
if (UNSAFE_FRAME_OPTIMIZATION)
add_definitions(-DUNSAFE_FRAME_OPTIMIZATION)
endif ()
if (LOG_RECEIVER_TYPES)
add_definitions(-DLOG_RECEIVER_TYPES)
endif ()
if (ADDITIONAL_ALLOCATION)
add_definitions(-DADDITIONAL_ALLOCATION)
endif ()
if (FOR_PROFILING)
add_definitions(-g -pg)
endif ()
add_definitions(-DGC_TYPE=${GC_TYPE})
add_executable(SOM++ "")
target_sources(SOM++ PRIVATE
${COMPILER_SRC}
${INTERPRETER_SRC}
${MEMORY_SRC}
${MISC_SRC}
${VM_SRC}
${VMOBJECTS_SRC}
${MAIN_SRC}
${PRIMITIVES_SRC}
${PRIMITIVESCORE_SRC})
target_compile_options(SOM++ PRIVATE
-m64
-Wno-endif-labels)
target_include_directories(SOM++ PRIVATE ${SRC_DIR})
target_link_libraries(SOM++)
add_executable(unittests "")
target_sources(unittests PRIVATE
${COMPILER_SRC}
${INTERPRETER_SRC}
${MEMORY_SRC}
${MISC_SRC}
${VM_SRC}
${VMOBJECTS_SRC}
${PRIMITIVES_SRC}
${PRIMITIVESCORE_SRC}
${UNITTEST_SRC})
target_compile_options(unittests PRIVATE
-DDEBUG -O0 -g -DUNITTESTS)
find_library(LIB_CPPUNIT
NAMES cppunit
HINTS /opt/local/lib)
find_path(LIB_CPPUNIT_INCLUDE_DIR cppunit/TestCase.h
/opt/local/include
/usr/local/include
/usr/include
)
target_include_directories(unittests PRIVATE
${SRC_DIR}
${LIB_CPPUNIT_INCLUDE_DIR})
target_link_libraries(unittests ${LIB_CPPUNIT})
enable_testing()
add_test(
NAME unittests
COMMAND unittests -cp ${ROOT_DIR}/Smalltalk ${ROOT_DIR}/Examples/Hello.som)
add_test(
NAME som-tests
COMMAND SOM++ -cp ${ROOT_DIR}/Smalltalk ${ROOT_DIR}/TestSuite/TestHarness.som)
add_test(
NAME benchmarks
COMMAND SOM++ -cp ${ROOT_DIR}/Smalltalk:${ROOT_DIR}/Examples/Benchmarks/LanguageFeatures ${ROOT_DIR}/Examples/Benchmarks/All.som)