@@ -30,13 +30,23 @@ endif(DOXYGEN_FOUND)
30
30
31
31
# Add a bison target named 'parser'.
32
32
macro (generic_bison name )
33
+ set (bison_header "${name} _y.tab.h" )
34
+ if (EXISTS "${CMAKE_CURRENT_SOURCE_DIR} /${bison_header} " )
35
+ message (FATAL_ERROR "Generated file ${bison_header} found in source tree. If you previously built with `make`, run `make clean` and try again" )
36
+ endif ()
37
+
38
+ set (bison_source "${name} _y.tab.cpp" )
39
+ if (EXISTS "${CMAKE_CURRENT_SOURCE_DIR} /${bison_source} " )
40
+ message (FATAL_ERROR "Generated file ${bison_source} found in source tree. If you previously built with `make`, run `make clean` and try again" )
41
+ endif ()
42
+
33
43
bison_target(
34
44
parser
35
45
"${CMAKE_CURRENT_SOURCE_DIR} /parser.y"
36
- "${CMAKE_CURRENT_BINARY_DIR} /${name} _y.tab.cpp "
46
+ "${CMAKE_CURRENT_BINARY_DIR} /${bison_source} "
37
47
COMPILE_FLAGS "-pyy${name} "
38
48
)
39
- set (renamed_parser_header "${CMAKE_CURRENT_BINARY_DIR} /${name} _y.tab.h " )
49
+ set (renamed_parser_header "${CMAKE_CURRENT_BINARY_DIR} /${bison_header} " )
40
50
add_custom_command (OUTPUT "${renamed_parser_header} "
41
51
COMMAND "${CMAKE_COMMAND} " -E copy "${BISON_parser_OUTPUT_HEADER} " "${renamed_parser_header} "
42
52
MAIN_DEPENDENCY "${BISON_parser_OUTPUT_HEADER} "
@@ -47,6 +57,11 @@ endmacro(generic_bison)
47
57
48
58
# Add a flex target named 'scanner'
49
59
macro (generic_flex name )
60
+ set (flex_source "${name} _lex.yy.cpp" )
61
+ if (EXISTS "${CMAKE_CURRENT_SOURCE_DIR} /${flex_source} " )
62
+ message (FATAL_ERROR "Generated file ${flex_source} found in source tree. If you previously built with `make`, run `make clean` and try again" )
63
+ endif ()
64
+
50
65
flex_target(
51
66
scanner
52
67
"${CMAKE_CURRENT_SOURCE_DIR} /scanner.l"
0 commit comments