-
Notifications
You must be signed in to change notification settings - Fork 34
/
Copy pathCMakeLists.txt
73 lines (53 loc) · 2.26 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
cmake_minimum_required(VERSION 3.9)
project(Parser-Verilog LANGUAGES CXX)
include(CTest)
# Turn on the verbose
set(CMAKE_VERBOSE_MAKEFILE ON)
set(CMAKE_CXX_STANDARD 17)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall -O2")
# add the binary tree to the search path for include files
include_directories(${PROJECT_SOURCE_DIR})
include_directories(parser-verilog)
# -----------------------------------------------------------------------------
# Flex & Bison
# -----------------------------------------------------------------------------
find_package(BISON REQUIRED)
find_package(FLEX REQUIRED)
BISON_TARGET(verilog_parser
${PROJECT_SOURCE_DIR}/parser-verilog/verilog_parser.yy
${CMAKE_CURRENT_BINARY_DIR}/verilog_parser.tab.cc)
FLEX_TARGET(verilog_lexer
${PROJECT_SOURCE_DIR}/parser-verilog/verilog_lexer.l
${CMAKE_CURRENT_BINARY_DIR}/verilog_lexer.yy.cc)
ADD_FLEX_BISON_DEPENDENCY(verilog_lexer verilog_parser)
# -----------------------------------------------------------------------------
# Example program
# -----------------------------------------------------------------------------
# Set the output folder to example
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${PROJECT_SOURCE_DIR}/example)
# A sample parser
add_executable(sample_parser
${PROJECT_SOURCE_DIR}/example/sample_parser.cpp
${FLEX_verilog_lexer_OUTPUTS}
${BISON_verilog_parser_OUTPUTS}
)
target_link_libraries(sample_parser stdc++fs)
# A drop-in replacement OpenTimer Verilog parser
add_executable(ot_parser
${PROJECT_SOURCE_DIR}/example/ot_parser.cpp
${FLEX_verilog_lexer_OUTPUTS}
${BISON_verilog_parser_OUTPUTS}
)
target_link_libraries(ot_parser stdc++fs)
# -----------------------------------------------------------------------------
# Unittest
# -----------------------------------------------------------------------------
enable_testing()
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${PROJECT_SOURCE_DIR}/unittest)
# Regression
set(VP_UTEST_DIR ${PROJECT_SOURCE_DIR}/unittest)
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${VP_UTEST_DIR})
add_executable(regression unittest/regression.cpp ${FLEX_verilog_lexer_OUTPUTS} ${BISON_verilog_parser_OUTPUTS})
target_link_libraries(regression stdc++fs)
add_test(regression ${VP_UTEST_DIR}/regression)