2007-01-07 17:19:45 +00:00
|
|
|
################################################################
|
|
|
|
# Name: ScannerParser.cmake
|
|
|
|
# Purpose: If flex/bison are available, generate parser and scanner
|
|
|
|
# Author: Cas Cremers
|
|
|
|
################################################################
|
|
|
|
|
|
|
|
# Make the scanner using flex, if it can be found
|
|
|
|
include(FindFLEX.cmake)
|
|
|
|
if (FLEX_FOUND)
|
|
|
|
set_source_files_properties(scanner.c PROPERTIES GENERATED true)
|
|
|
|
ADD_CUSTOM_COMMAND (
|
|
|
|
OUTPUT scanner.c
|
|
|
|
DEPENDS scanner.l
|
|
|
|
COMMAND ${FLEX_EXECUTABLE}
|
|
|
|
# TODO: I should look up from which version the -o
|
|
|
|
# switch works, might not be portable.
|
2007-01-08 13:24:37 +00:00
|
|
|
ARGS -oscanner.c scanner.l
|
2007-01-07 17:19:45 +00:00
|
|
|
COMMENT "Building scanner.c from scanner.l using flex"
|
|
|
|
)
|
|
|
|
else (FLEX_FOUND)
|
|
|
|
message (STATUS "Because flex is not found, we will use the existing scanner.c")
|
|
|
|
endif (FLEX_FOUND)
|
|
|
|
|
|
|
|
# Make the parser using bison, if it can be found
|
|
|
|
include(FindBISON.cmake)
|
|
|
|
if (BISON_FOUND)
|
|
|
|
set_source_files_properties(parser.c PROPERTIES GENERATED true)
|
|
|
|
ADD_CUSTOM_COMMAND (
|
|
|
|
OUTPUT parser.c
|
|
|
|
DEPENDS parser.y
|
|
|
|
COMMAND ${BISON_EXECUTABLE}
|
|
|
|
# TODO: I should look up from which version the -o
|
|
|
|
# switch works, might not be portable.
|
2007-01-08 13:24:37 +00:00
|
|
|
ARGS -oparser.c parser.y
|
2007-01-07 17:19:45 +00:00
|
|
|
COMMENT "Building parser.c from parser.y using bison"
|
|
|
|
)
|
|
|
|
else (BISON_FOUND)
|
|
|
|
message (STATUS "Because bison is not found, we will use the existing parser.c")
|
|
|
|
endif (BISON_FOUND)
|
|
|
|
|
|
|
|
|