-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathCMakeLists.txt
126 lines (109 loc) · 3.67 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.8)
# Setup project, languages and standards
project(ebe)
set(CMAKE_CXX_STANDARD 17)
if(NOT CMAKE_BUILD_TYPE)
set(CMAKE_BUILD_TYPE Release)
endif()
set(CMAKE_CXX_FLAGS_DEBUG "-O3 -g -DDEVELOPER")
set(CMAKE_CXX_FLAGS_RELEASE "-O3")
# Includes for headers
include_directories(.)
include_directories(backend)
include_directories(engine)
include_directories(frontend)
include_directories(gp)
include_directories(midend)
include_directories(utils)
# Source files excluding main
set(SOURCES
backend/compiler.cpp
backend/instruction.cpp
backend/interpreter.cpp
backend/symbol_table.cpp
engine/engine.cpp
engine/engine_jenn.cpp
engine/engine_miRANDa.cpp
engine/engine_taylor.cpp
frontend/lexer_text.cpp
frontend/parser_text.cpp
frontend/scanner_text.cpp
frontend/lexer_ebel.cpp
frontend/parser_ebel.cpp
frontend/scanner_ebel.cpp
frontend/pragmas.cpp
frontend/preprocessor.cpp
frontend/scanner.cpp
gp/gp.cpp
gp/fitness.cpp
midend/ir.cpp
midend/tree.cpp
midend/expression.cpp
utils/arg_parser.cpp
utils/exceptions.cpp
utils/logging.cpp
utils/rng.cpp
utils/utils.cpp
)
# Targets
# ebe target
add_executable(
${PROJECT_NAME}
ebe.cpp
${SOURCES}
)
target_link_libraries(${PROJECT_NAME} m)
# ebetests target
if(CMAKE_BUILD_TYPE STREQUAL "Debug")
# Test source files
set(TEST_SRCS
tests/test_utils.cpp
tests/test_interpreter.cpp
tests/test_scanner.cpp
tests/test_argparse.cpp
tests/test_pragmas.cpp
)
# Enable gtest
enable_testing()
add_subdirectory(tests/googletest)
add_executable(
ebetests
${TEST_SRCS}
${SOURCES}
)
target_link_libraries(
ebetests
gtest_main
)
# GTest include
include(GoogleTest)
gtest_discover_tests(ebetests)
# Docs build
# docs target
find_package(Doxygen REQUIRED dot)
if(DOXYGEN_FOUND)
set(DOXYGEN_IN ${CMAKE_CURRENT_SOURCE_DIR}/docs/Doxyfile)
set(DOXYGEN_OUT ${CMAKE_CURRENT_BINARY_DIR}/Doxyfile)
configure_file(${DOXYGEN_IN} ${DOXYGEN_OUT} @ONLY)
add_custom_target( docs ALL
COMMAND ${DOXYGEN_EXECUTABLE} ${DOXYGEN_OUT}
WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}
COMMENT "Generating API documentation with Doxygen"
VERBATIM )
else (DOXYGEN_FOUND)
message("Doxygen need to be installed to generate the doxygen documentation")
endif (DOXYGEN_FOUND)
# Rebuilding lexer and parser when files don't exist and flex and bison are present
find_package(BISON REQUIRED)
find_package(FLEX REQUIRED)
if(BISON_FOUND)
if(FLEX_FOUND)
bison_target(parser_text ${CMAKE_CURRENT_SOURCE_DIR}/frontend/grammars/parser_text.yy ${CMAKE_CURRENT_SOURCE_DIR}/frontend/parser_text.cpp)
flex_target(lexer_text ${CMAKE_CURRENT_SOURCE_DIR}/frontend/grammars/lexer_text.ll ${CMAKE_CURRENT_SOURCE_DIR}/frontend/lexer_text.cpp COMPILE_FLAGS "--header-file=frontend/lexer_text.hpp")
ADD_FLEX_BISON_DEPENDENCY(lexer_text parser_text)
bison_target(parser_ebel ${CMAKE_CURRENT_SOURCE_DIR}/frontend/grammars/parser_ebel.yy ${CMAKE_CURRENT_SOURCE_DIR}/frontend/parser_ebel.cpp COMPILE_FLAGS "-p ee")
flex_target(lexer_ebel ${CMAKE_CURRENT_SOURCE_DIR}/frontend/grammars/lexer_ebel.ll ${CMAKE_CURRENT_SOURCE_DIR}/frontend/lexer_ebel.cpp COMPILE_FLAGS "-P ee --header-file=frontend/lexer_ebel.hpp")
ADD_FLEX_BISON_DEPENDENCY(lexer_ebel parser_ebel)
endif(FLEX_FOUND)
endif (BISON_FOUND)
endif(CMAKE_BUILD_TYPE STREQUAL "Debug")