--- /dev/null
+file(READ @CMAKE_CURRENT_BINARY_DIR@/grammar.h file_contents)
+string(REPLACE "yy" "aag" file_contents "${file_contents}")
+string(REPLACE "unsigned long int" "uint_64_t" file_contents "${file_contents}")
+string(REPLACE "unsigned long" "uint_64_t" file_contents "${file_contents}")
+file(WRITE @CMAKE_CURRENT_BINARY_DIR@/grammar.h "${file_contents}")
+
+file(READ @CMAKE_CURRENT_BINARY_DIR@/grammar.c file_contents)
+string(REPLACE "yy" "aag" file_contents "${file_contents}")
+string(REPLACE "unsigned long int" "uint_64_t" file_contents "${file_contents}")
+string(REPLACE "unsigned long" "uint_64_t" file_contents "${file_contents}")
+file(WRITE @CMAKE_CURRENT_BINARY_DIR@/grammar.c "${file_contents}")
--- /dev/null
+file(READ @CMAKE_CURRENT_BINARY_DIR@/scan.c file_contents)
+string(REPLACE "yy" "aag" file_contents "${file_contents}")
+string(REPLACE "extern int isatty (int );" "" file_contents "${file_contents}")
+file(WRITE @CMAKE_CURRENT_BINARY_DIR@/scan.c "${file_contents}")
FLEX_TARGET(Scan scan.l ${CMAKE_CURRENT_BINARY_DIR}/scan.c)
ADD_FLEX_BISON_DEPENDENCY(Scan Grammar)
+# Modify files generated by Bison and Flex, to match the Autotools build.
+# - Replace "yy" with "aag" in all three files
+# - Replace "unsigned long int" with "uint64_t" in grammar.h and grammar.c
+# - Replace "unsigned long" with "uint64_t" in grammar.h and grammar.c
+# - Remove declaration of the "isatty()" function from scan.c
+configure_file(
+ "${TOP_SOURCE_DIR}/cmake/modify_cgraph_grammar.cmake.in"
+ "${CMAKE_CURRENT_BINARY_DIR}/modify_cgraph_grammar.cmake"
+ @ONLY
+)
+configure_file(
+ "${TOP_SOURCE_DIR}/cmake/modify_cgraph_scan.cmake.in"
+ "${CMAKE_CURRENT_BINARY_DIR}/modify_cgraph_scan.cmake"
+ @ONLY
+)
+add_custom_command(
+ OUTPUT ${BISON_Grammar_OUTPUTS}
+ COMMAND ${CMAKE_COMMAND} -P ${CMAKE_CURRENT_BINARY_DIR}/modify_cgraph_grammar.cmake
+ APPEND
+)
+add_custom_command(
+ OUTPUT ${FLEX_Scan_OUTPUTS}
+ COMMAND ${CMAKE_COMMAND} -P ${CMAKE_CURRENT_BINARY_DIR}/modify_cgraph_scan.cmake
+ APPEND
+)
+
+
add_definitions(-DCGRAPH_EXPORTS -DYY_NO_UNISTD_H)
include_directories(