Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 17 additions & 2 deletions src/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -30,13 +30,23 @@ endif(DOXYGEN_FOUND)

# Add a bison target named 'parser'.
macro(generic_bison name)
set(bison_header "${name}_y.tab.h")
if(EXISTS "${CMAKE_CURRENT_SOURCE_DIR}/${bison_header}")
message(FATAL_ERROR "Generated file ${bison_header} found in source tree. If you previously built with `make`, run `make clean` and try again")
endif()

set(bison_source "${name}_y.tab.cpp")
if(EXISTS "${CMAKE_CURRENT_SOURCE_DIR}/${bison_source}")
message(FATAL_ERROR "Generated file ${bison_source} found in source tree. If you previously built with `make`, run `make clean` and try again")
endif()

bison_target(
parser
"${CMAKE_CURRENT_SOURCE_DIR}/parser.y"
"${CMAKE_CURRENT_BINARY_DIR}/${name}_y.tab.cpp"
"${CMAKE_CURRENT_BINARY_DIR}/${bison_source}"
COMPILE_FLAGS "-pyy${name}"
)
set(renamed_parser_header "${CMAKE_CURRENT_BINARY_DIR}/${name}_y.tab.h")
set(renamed_parser_header "${CMAKE_CURRENT_BINARY_DIR}/${bison_header}")
add_custom_command(OUTPUT "${renamed_parser_header}"
COMMAND "${CMAKE_COMMAND}" -E copy "${BISON_parser_OUTPUT_HEADER}" "${renamed_parser_header}"
MAIN_DEPENDENCY "${BISON_parser_OUTPUT_HEADER}"
Expand All @@ -47,6 +57,11 @@ endmacro(generic_bison)

# Add a flex target named 'scanner'
macro(generic_flex name)
set(flex_source "${name}_lex.yy.cpp")
if(EXISTS "${CMAKE_CURRENT_SOURCE_DIR}/${flex_source}")
message(FATAL_ERROR "Generated file ${flex_source} found in source tree. If you previously built with `make`, run `make clean` and try again")
endif()

flex_target(
scanner
"${CMAKE_CURRENT_SOURCE_DIR}/scanner.l"
Expand Down