-
Notifications
You must be signed in to change notification settings - Fork 10
/
CMakeLists.txt
174 lines (145 loc) · 5.59 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
cmake_minimum_required(VERSION 2.8.4)
set (CMAKE_USER_MAKE_RULES_OVERRIDE "${CMAKE_SOURCE_DIR}/cmake/variables.cmake")
set (CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/cmake")
set (LLVM_PACKAGE_VERSION 3.3)
project(llst)
find_package(Threads REQUIRED QUIET)
find_package(READLINE)
find_package(LLVM ${LLVM_PACKAGE_VERSION} EXACT)
find_package(POD2MAN)
find_package(GZIP REQUIRED)
option(USE_READLINE "Should we use the GNU readline and history libraries?" ON)
option(USE_LLVM "Should we use LLVM to build JIT?" OFF)
option(USE_POD2MAN "Should we use pod2man to build the documentation (we will create empty docs otherwise)?" ON)
if (USE_LLVM)
if (LLVM_FOUND)
message(STATUS "Using LLVM ${LLVM_VERSION}")
# LLVM generates loads of warnings...
set (CMAKE_CXX_FLAGS "${LLVM_CPP_FLAGS} ${CMAKE_CXX_FLAGS} -Wno-unused-parameter")
set (LLVM_LIBS_TO_LINK ${LLVM_LIBS})
link_directories(${LLVM_LIB_DIR})
add_definitions(-DLLVM)
else()
message(FATAL_ERROR "\nInstall llvm-${LLVM_PACKAGE_VERSION}-dev:i386 and try again.")
endif()
else()
message(STATUS "LLVM is disabled")
unset(LLVM_LIBS_TO_LINK)
endif()
if (USE_READLINE)
if (READLINE_FOUND)
message(STATUS "Using readline library")
set_source_files_properties(src/CompletionEngine.cpp PROPERTIES COMPILE_DEFINITIONS USE_READLINE)
set (READLINE_LIBS_TO_LINK ${READLINE_LIBRARIES})
else()
if(NOT READLINE_FOUND)
message(SEND_ERROR "Library readline is not found.\nYou may configure with -DUSE_READLINE=OFF.")
endif()
endif()
else()
message(STATUS "Readline library is disabled")
unset(READLINE_LIBS_TO_LINK)
endif()
if (USE_POD2MAN)
if (POD2MAN_FOUND)
message(STATUS "Using pod2man to build the documentation")
else()
message(FATAL_ERROR "\npod2man is not found.\nYou may configure with -DUSE_POD2MAN=OFF.")
endif()
function(get_pod2man_cmd OUT)
get_pod2man_cmd_wrapper(CMD ${ARGN})
set("${OUT}" "${CMD}" PARENT_SCOPE)
endfunction()
else()
message(STATUS "Pod2man is disabled")
function(get_pod2man_cmd OUT)
get_pod2man_cmd_wrapper(CMD ${ARGN} STUB)
set("${OUT}" "${CMD}" PARENT_SCOPE)
endfunction()
endif()
option(BUILD_TESTS "Should we build tests?" OFF)
if (BUILD_TESTS)
enable_testing()
configure_file( "${CMAKE_SOURCE_DIR}/cmake/CTestCustom.cmake.in" "${CMAKE_BINARY_DIR}/CTestCustom.cmake" @ONLY)
set (CTEST_SUBMIT_RETRY_DELAY 0 CACHE STRING "How long to wait between timed-out CTest submissions.")
set (CTEST_SUBMIT_RETRY_COUNT 0 CACHE STRING "How many times to retry timed-out CTest submissions.")
include(CTest)
add_subdirectory(tests)
endif()
add_subdirectory(doc)
add_subdirectory(image)
add_subdirectory(src)
add_subdirectory(include)
include_directories(include)
add_library(stapi
src/ParsedBytecode.cpp
src/ParsedMethod.cpp
src/ParsedBlock.cpp
src/ControlGraph.cpp
src/ControlGraphVisualizer.cpp
)
set(MM_CPP_FILES
src/BakerMemoryManager.cpp
src/GenerationalMemoryManager.cpp
src/NonCollectMemoryManager.cpp
)
if (USE_LLVM)
list(APPEND MM_CPP_FILES src/LLVMMemoryManager.cpp)
endif()
add_library(memory_managers ${MM_CPP_FILES})
# Base set of sources needed in every build
add_library(standard_set
src/vm.cpp
src/args.cpp
src/CompletionEngine.cpp
src/Image.cpp
src/primitives.cpp
src/TDictionary.cpp
src/TSymbol.cpp
src/TSmalltalkInstruction.cpp
src/InstructionDecoder.cpp
src/Timer.cpp
src/GCLogger.cpp
)
if (USE_LLVM)
add_library(jit
src/MethodCompiler.cpp
src/JITRuntime.cpp
src/llstPass.cpp
src/llstDebuggingPass.cpp
)
endif()
add_executable(llst src/main.cpp)
add_dependencies(llst image)
if (USE_LLVM)
target_link_libraries(llst jit ${LLVM_LIBS} ${LLVM_LD_FLAGS})
endif()
target_link_libraries(llst standard_set memory_managers stapi ${READLINE_LIBS_TO_LINK} ${CMAKE_THREAD_LIBS_INIT} ${CMAKE_DL_LIBS})
set(changelog_compressed "${CMAKE_CURRENT_BINARY_DIR}/changelog.gz")
gzip_compress("compress_changelog" "${CMAKE_CURRENT_SOURCE_DIR}/ChangeLog" ${changelog_compressed})
install(TARGETS llst DESTINATION bin)
install(FILES LICENSE DESTINATION share/doc/${PROJECT_NAME} RENAME copyright)
install(FILES ${changelog_compressed} DESTINATION share/doc/${PROJECT_NAME})
install(FILES misc/bash-completion.sh DESTINATION share/bash-completion/completions RENAME llst)
set (CPACK_PACKAGE_DESCRIPTION_SUMMARY "LLVM powered Little Smalltalk")
set (CPACK_DEBIAN_PACKAGE_DESCRIPTION # The format of Description: http://www.debian.org/doc/debian-policy/ch-controlfields.html#s-f-Description
"LLVM powered Little Smalltalk
LLST is a virtual machine with integrated JIT.
")
set (CPACK_PACKAGE_CONTACT "[email protected]")
set (CPACK_PACKAGE_VERSION_MAJOR "0")
set (CPACK_PACKAGE_VERSION_MINOR "4")
set (CPACK_PACKAGE_VERSION_PATCH "0")
set (CPACK_RESOURCE_FILE_LICENSE "${CMAKE_CURRENT_SOURCE_DIR}/LICENSE")
set (CPACK_SOURCE_GENERATOR "TGZ")
set (CPACK_SOURCE_IGNORE_FILES "build/" "\\\\.kdev.*" "\\\\.git.*" "\\\\.hgignore" ".*\\\\.image")
set (CPACK_STRIP_FILES "llst")
set (CPACK_GENERATOR "DEB")
set (CPACK_DEBIAN_PACKAGE_HOMEPAGE "http://llst.org")
set (CPACK_DEBIAN_PACKAGE_MAINTAINER "Team <[email protected]>")
set (CPACK_DEBIAN_PACKAGE_ARCHITECTURE "i386")
set (CPACK_DEBIAN_PACKAGE_DEPENDS "libc6:i386, libgcc1:i386, libstdc++6:i386, libreadline6:i386, libtinfo5:i386")
include(CPack)
# uninstall target
configure_file( "${CMAKE_SOURCE_DIR}/cmake/uninstall.cmake.in" uninstall.cmake @ONLY)
add_custom_target(uninstall COMMAND ${CMAKE_COMMAND} -P uninstall.cmake)