-
Notifications
You must be signed in to change notification settings - Fork 1
/
CMakeLists.txt
141 lines (124 loc) · 4.36 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
project(khaotica)
cmake_minimum_required(VERSION 3.6)
set(CMAKE_CXX_EXTENSIONS OFF)
find_package(gtest CONFIG PATHS deps)
find_package(boost CONFIG PATHS deps)
find_package(BISON 3.0 REQUIRED)
find_package(FLEX REQUIRED)
set(GRAMMAR_DIR ${CMAKE_CURRENT_BINARY_DIR}/generated)
file(MAKE_DIRECTORY ${GRAMMAR_DIR})
set(BisonOutput grammar_mpeg2_parser.cpp)
set(BisonOutputH grammar_mpeg2_parser.hpp)
set(BisonInput src/grammar_mpeg2_parser.yy)
add_custom_command(
DEPENDS ${BisonInput}
OUTPUT ${GRAMMAR_DIR}/${BisonOutput} ${GRAMMAR_DIR}/${BisonOutputH}
WORKING_DIRECTORY ${GRAMMAR_DIR}
COMMAND ${BISON_EXECUTABLE}
ARGS
--output=${BisonOutput}
--defines=${BisonOutputH}
--graph
${CMAKE_CURRENT_LIST_DIR}/${BisonInput}
)
set(FlexOutput grammar_mpeg2_lexer.cpp)
set(FlexInput src/grammar_mpeg2_lexer.ll)
add_custom_command(
DEPENDS ${FlexInput} ${GRAMMAR_DIR}/${BisonOutput} ${GRAMMAR_DIR}/${BisonOutputH}
OUTPUT ${GRAMMAR_DIR}/${FlexOutput}
WORKING_DIRECTORY ${GRAMMAR_DIR}
COMMAND ${FLEX_EXECUTABLE}
ARGS
--outfile=${FlexOutput}
-L
${CMAKE_CURRENT_LIST_DIR}/${FlexInput}
)
add_custom_target(dummy
echo "Dummy target to show Bison/Flex/Flavor files in projects"
SOURCES
${FlexInput}
${BisonInput}
${CMAKE_CURRENT_LIST}
flex/FlexLexer.h
)
add_library(core
${GRAMMAR_DIR}/${BisonOutput} ${GRAMMAR_DIR}/${BisonOutputH}
${GRAMMAR_DIR}/${FlexOutput} src/grammar_mpeg2_lexer.h
src/eval_default.cpp src/eval_default.h
src/eval_conditional.cpp src/eval_conditional.h
src/eval_logical.cpp src/eval_logical.h
src/eval_comparison.cpp src/eval_comparison.h
src/eval_equality.cpp src/eval_equality.h
src/eval_bitwise.cpp src/eval_bitwise.h
src/eval_arithmetic.cpp src/eval_arithmetic.h
api/khaotica/mpeg2_interpreter.h
src/mpeg2_types.cpp api/khaotica/mpeg2_types.h
src/mpeg2_syntax.cpp api/khaotica/mpeg2_syntax.h
src/printer.cpp src/printer.h
src/grammar_mpeg2_impl.cpp src/grammar_mpeg2_impl.h
src/mpeg2_reader.cpp api/khaotica/mpeg2_reader.h
src/mpeg2_sax.cpp api/khaotica/mpeg2_sax.h
src/bitreader.cpp api/khaotica/bitreader.h
src/type_conversion.h
src/logging.cpp src/logging.h
api/khaotica/scope.h
src/mpeg2_interpreter_impl.cpp src/mpeg2_interpreter_impl.h src/type_conversion.cpp)
target_compile_features(core PUBLIC cxx_std_17)
target_include_directories(core
PUBLIC api/
PRIVATE api/khaotica
PRIVATE src/
PRIVATE flex/
PRIVATE ${GRAMMAR_DIR})
target_link_libraries(core ${boost_LIBRARIES})
target_include_directories(core
PRIVATE src/
PRIVATE ${boost_INCLUDE_DIRECTORIES})
target_compile_definitions(core PRIVATE ${boost_COMPILE_DEFINITIONS})
add_executable(khaotica
src/khaotica.cpp
src/options.cpp src/options.h src/scanner.cpp src/scanner.h)
target_compile_features(khaotica PUBLIC cxx_std_17)
target_link_libraries(khaotica core ${boost_LIBRARIES})
target_include_directories(khaotica
PRIVATE src/
PRIVATE ${boost_INCLUDE_DIRECTORIES})
target_compile_definitions(khaotica PRIVATE ${boost_COMPILE_DEFINITIONS})
install(TARGETS khaotica
RUNTIME DESTINATION bin
LIBRARY DESTINATION lib
ARCHIVE DESTINATION lib/static/khaotica
)
install(DIRECTORY res DESTINATION share/khaotica)
add_executable(khaotica_gtest test/dummy.cpp
${GRAMMAR_DIR}/${BisonOutput} ${GRAMMAR_DIR}/${BisonOutputH}
${GRAMMAR_DIR}/${FlexOutput} src/grammar_mpeg2_lexer.h
src/logging.cpp src/logging.h
src/bitreader.cpp api/khaotica/bitreader.h
test/ut_bitreader.cpp
test/ut_bit.cpp
test/ut_parser.cpp)
target_compile_features(khaotica_gtest PUBLIC cxx_std_17)
target_link_libraries(khaotica_gtest
${boost_LIBRARIES}
${GTEST_LIBRARIES}
)
target_include_directories(khaotica_gtest
PRIVATE api/
PRIVATE api/khaotica
PRIVATE src/
PRIVATE test/
PRIVATE flex/
PRIVATE ${GTEST_INCLUDE_DIRECTORIES}
PRIVATE ${boost_INCLUDE_DIRECTORIES}
PRIVATE ${GRAMMAR_DIR})
target_compile_definitions(khaotica_gtest PRIVATE ${boost_COMPILE_DEFINITIONS})
if (UNIX)
configure_file("${CMAKE_CURRENT_LIST_DIR}/pvs.cfg.in" "${CMAKE_CURRENT_BINARY_DIR}/pvs.cfg" @ONLY)
include(deps/PVS-Studio.cmake)
pvs_studio_add_target(TARGET analyze
OUTPUT FORMAT errorfile
LOG "report.plog"
ANALYZE khaotica
CONFIG "${CMAKE_CURRENT_BINARY_DIR}/pvs.cfg")
endif (UNIX)