-
Notifications
You must be signed in to change notification settings - Fork 0
/
CMakeLists.txt
177 lines (147 loc) · 5.43 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
cmake_minimum_required(VERSION 3.5)
project(PLOTSCRIPT CXX)
# EDIT
# add any files you create related to the interpreter here
# excluding unit tests
set(interpreter_src
token.hpp token.cpp
atom.hpp atom.cpp
environment.hpp environment.cpp
expression.hpp expression.cpp
parse.hpp parse.cpp
interpreter.hpp interpreter.cpp
)
# EDIT
# add any files you create related to interpreter unit testing here
set(unittest_src
catch.hpp
atom_tests.cpp
environment_tests.cpp
expression_tests.cpp
interpreter_tests.cpp
parse_tests.cpp
semantic_error.hpp
token_tests.cpp
unit_tests.cpp
)
# EDIT
# add source for any TUI modules here
set(tui_src
message_queue.h
cntlc_tracer.hpp
)
# EDIT
# add source for any GUI modules here
set(gui_src
input_widget.hpp input_widget.cpp
output_widget.hpp output_widget.cpp
notebook_app.hpp notebook_app.cpp
message_queue.h
)
# EDIT
# add source for any GUI tests here
set(gui_test_src
notebook_test.cpp
)
set(STARTUP_FILE ${CMAKE_SOURCE_DIR}/startup.pls)
configure_file(${CMAKE_SOURCE_DIR}/startup_config.hpp.in ${CMAKE_BINARY_DIR}/startup_config.hpp)
include_directories(${CMAKE_BINARY_DIR})
# ------------------------------------------------
# You should not need to edit any files below here
# ------------------------------------------------
# main entry point for TUI interface
set(tui_main
plotscript.cpp
)
# main entry point for GUI interface
set(gui_main
notebook.cpp
)
# try to prevent accidental in-source builds, these cause lots of problems
if(${CMAKE_SOURCE_DIR} STREQUAL ${CMAKE_BINARY_DIR})
message(FATAL_ERROR "In-source builds not allowed. Remove any files created thus far and use a different directory for the build.")
endif()
# require a C++11 compiler for all targets
set(CMAKE_CXX_STANDARD 11)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
# configure Qt
find_package(Qt5 COMPONENTS Widgets Test QUIET)
if (Qt5Widgets_FOUND AND Qt5Test_FOUND)
set(CMAKE_AUTOMOC ON)
set(CMAKE_INCLUDE_CURRENT_DIR ON)
endif()
# optional strict mode
if(UNIX AND STRICT)
message("-- Enabling strict compilation mode")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall -Wextra -Werror")
endif()
# build interpreter library
add_library(interpreter ${interpreter_src})
# create the plotscript executable
add_executable(plotscript ${tui_main} ${tui_src})
target_link_libraries(plotscript interpreter)
# create the unit_tests executable
add_executable(unit_tests ${unittest_src})
target_link_libraries(unit_tests interpreter)
enable_testing()
add_test(unit_tests unit_tests)
# In the reference environment enable coverage on tests
if(DEFINED ENV{ECE3574_REFERENCE_ENV})
message("-- Enabling test coverage")
set(GCC_COVERAGE_COMPILE_FLAGS "-g -O0 -fprofile-arcs -ftest-coverage")
set_target_properties(interpreter PROPERTIES COMPILE_FLAGS ${GCC_COVERAGE_COMPILE_FLAGS} )
set_target_properties(unit_tests PROPERTIES COMPILE_FLAGS ${GCC_COVERAGE_COMPILE_FLAGS} )
target_link_libraries(unit_tests interpreter pthread gcov)
target_link_libraries(plotscript interpreter pthread gcov)
add_custom_target(coverage
COMMAND ${CMAKE_COMMAND} -E env "ROOT=${CMAKE_CURRENT_SOURCE_DIR}"
${CMAKE_CURRENT_SOURCE_DIR}/scripts/coverage.sh)
endif()
# In the reference environment enable memory checking on tests
if(DEFINED ENV{ECE3574_REFERENCE_ENV})
message("-- Enabling memory checks")
add_custom_target(memtest
COMMAND valgrind ${CMAKE_BINARY_DIR}/unit_tests)
endif()
# In the reference environment enable tui tests
if(DEFINED ENV{ECE3574_REFERENCE_ENV})
add_test(plotscript_test python3 ${CMAKE_SOURCE_DIR}/scripts/integration_test.py)
endif()
# --------------------------------------------------------
# Build the notebook executable and tests if Qt is available
# --------------------------------------------------------
if (Qt5Widgets_FOUND AND Qt5Test_FOUND)
add_executable(notebook ${gui_main} ${gui_src})
if(UNIX AND NOT APPLE AND CMAKE_COMPILER_IS_GNUCXX)
target_link_libraries(notebook interpreter Qt5::Widgets pthread gcov)
else(UNIX AND NOT APPLE AND CMAKE_COMPILER_IS_GNUCXX)
target_link_libraries(notebook interpreter Qt5::Widgets)
endif()
add_executable(notebook_test ${gui_test_src} ${gui_src})
if(UNIX AND NOT APPLE AND CMAKE_COMPILER_IS_GNUCXX)
target_link_libraries(notebook_test interpreter Qt5::Widgets Qt5::Test pthread gcov)
else(UNIX AND NOT APPLE AND CMAKE_COMPILER_IS_GNUCXX)
target_link_libraries(notebook_test interpreter Qt5::Widgets Qt5::Test)
endif()
add_test(notebook_test notebook_test)
else (Qt5Widgets_FOUND AND Qt5Test_FOUND)
message("Qt >= 5.9 needs to be installed to build the notebook interface and related tests.")
endif (Qt5Widgets_FOUND AND Qt5Test_FOUND)
# --------------------------------------------------------
# Build the Documentation if possible
# --------------------------------------------------------
find_package(Doxygen)
if (DOXYGEN_FOUND)
# set input and output files
set(DOXYGEN_IN ${CMAKE_CURRENT_SOURCE_DIR}/doc/Doxyfile.in)
set(DOXYGEN_OUT ${CMAKE_CURRENT_BINARY_DIR}/Doxyfile)
# request to configure the file
configure_file(${DOXYGEN_IN} ${DOXYGEN_OUT} @ONLY)
# note the option ALL which allows to build the docs together with the application
add_custom_target( doc
COMMAND ${DOXYGEN_EXECUTABLE} ${DOXYGEN_OUT}
WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}
VERBATIM )
else (DOXYGEN_FOUND)
message("Doxygen need to be installed to generate the doxygen documentation")
endif (DOXYGEN_FOUND)