forked from heavyai/heavydb
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathCMakeLists.txt
85 lines (69 loc) · 2.61 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
set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${CMAKE_SOURCE_DIR}/cmake/Modules/")
find_package(Bisonpp REQUIRED)
find_package(Flexpp REQUIRED)
set(BisonppOutput ${CMAKE_CURRENT_BINARY_DIR}/Parser_with_register.cpp)
add_custom_command(
OUTPUT
${BisonppOutput}
${CMAKE_CURRENT_BINARY_DIR}/parser.h
COMMAND ${BISONPP_EXECUTABLE}
-d
-h${CMAKE_CURRENT_BINARY_DIR}/parser.h
-o${BisonppOutput}
${CMAKE_CURRENT_SOURCE_DIR}/parser.y
DEPENDS parser.y
COMMENT "Generating Parser.cpp"
)
set(FlexppOutput ${CMAKE_CURRENT_BINARY_DIR}/Scanner_with_register.cpp)
add_custom_command(
OUTPUT ${FlexppOutput}
COMMAND ${FLEXPP_EXECUTABLE}
-d
-i
-o${FlexppOutput}
${CMAKE_CURRENT_SOURCE_DIR}/scanner.l
DEPENDS scanner.l
COMMENT "Generating Scanner.cpp"
)
# C++17 removes the 'register' keyword and it is no longer allowed to
# suppress the warning, so patch the generated scanner and parser files
# to remove the register keyword, and also patch embedded filename strings
# so they match the final file
set(ParserPatched ${CMAKE_CURRENT_BINARY_DIR}/Parser.cpp)
set(ScannerPatched ${CMAKE_CURRENT_BINARY_DIR}/Scanner.cpp)
add_custom_command(
OUTPUT ${ParserPatched}
COMMAND sed
-e "s/register //g"
-e "s/Parser_with_register/Parser/g"
${BisonppOutput} > ${ParserPatched}
DEPENDS ${BisonppOutput}
COMMENT "Patching Parser.cpp to remove register keyword"
)
add_custom_command(
OUTPUT ${ScannerPatched}
COMMAND sed
-e "s/register //g"
-e "s/Scanner_with_register/Scanner/g"
${FlexppOutput} > ${ScannerPatched}
DEPENDS ${FlexppOutput}
COMMENT "Patching Scanner.cpp to remove register keyword"
)
add_custom_target(ParserFiles DEPENDS ${BisonppOutput})
add_custom_target(ScannerFiles DEPENDS ${FlexppOutput})
add_custom_target(PatchParser DEPENDS ${ParserPatched})
add_custom_target(PatchScanner DEPENDS ${ScannerPatched})
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wno-write-strings -Wno-unused-function -Wno-unused-label -Wno-sign-compare")
set(parser_source_files
ParserNode.cpp
ParserNode.h
ParserWrapper.cpp
ParserWrapper.h
)
add_library(ParserGenerated ${ParserPatched} ${ScannerPatched})
add_library(Parser ${CMAKE_CURRENT_BINARY_DIR}/parser.h ${parser_source_files})
add_dependencies(PatchParser ParserFiles)
add_dependencies(PatchScanner ScannerFiles)
add_dependencies(Parser PatchParser PatchScanner)
target_link_libraries(Parser ParserGenerated Shared Analyzer QueryEngine Catalog DataMgr LockMgr)
include_directories(${CMAKE_CURRENT_SOURCE_DIR} ${CMAKE_CURRENT_BINARY_DIR})