source: git/modules/BisonMacros.cmake @ fec53d

fieker-DuValspielwiese
Last change on this file since fec53d was 8cc501, checked in by Kai Krüger <krueger@…>, 14 years ago
Added files to compile with cmake. Still experimental. Might not work git-svn-id: file:///usr/local/Singular/svn/trunk@13240 2c84dea3-7e68-4137-9b89-c4e89433aadc
  • Property mode set to 100644
File size: 2.0 KB
Line 
1# -*- mode: cmake; -*-
2#
3#
4#
5
6function(add_grammar  GEN_TARGET GEN_CPP_FILE GEN_H_FILE INFILE)
7  string(REGEX REPLACE "^.*/" "" FILE ${INFILE})
8  string(REPLACE ".y" "" NAME ${FILE})
9  set(_GEN_TARGET      "bison-${NAME}")
10  set(_GEN_CPP_FILE    ${CMAKE_CURRENT_BINARY_DIR}/${NAME}.cpp)
11  set(_GEN_H_FILE      ${CMAKE_CURRENT_BINARY_DIR}/${NAME}.h)
12  set(_GEN_GRAPH_FILE  ${CMAKE_CURRENT_BINARY_DIR}/${NAME}.graph)
13  set(_GEN_XML_FILE    ${CMAKE_CURRENT_BINARY_DIR}/${NAME}.xml)
14  set(_GEN_REPORT_FILE ${CMAKE_CURRENT_BINARY_DIR}/${NAME}.report)
15  set(_SOURCE_CPP_FILE ${CMAKE_CURRENT_SOURCE_DIR}/${NAME}.cc)
16  set(_SOURCE_H_FILE   ${CMAKE_CURRENT_SOURCE_DIR}/${NAME}.h)
17  #set(_OPT "-y -d -t")
18  # -y, --yacc : emulate POSIX Yacc
19  # -t, --debug: instrument the parser for debugging
20  # -d : likewise but cannot specify FILE (for POSIX Yacc)
21  # -r, --report
22  # --report-file=FILE
23  # --graph=FILE
24  # --xml=FILE
25  set(_OPT -y -d -t)
26  #set(_OPT ${_OPT} --warning=all)
27  #set(_OPT ${_OPT} --xml=${_GEN_XML_FILE})
28  #set(_OPT ${_OPT} --graph=${_GEN_GRAPH_FILE})
29  #set(_OPT ${_OPT} --report=all --report-file=${_GEN_REPORT_FILE})
30
31  set(BISON bison)
32
33  message("add_yacc ${_GEN_CPP_FILE} ${INFILE}...")
34  message("add_yacc ${_GEN_H_FILE} ${INFILE}...")
35  message("add_yacc ${NAME}...")
36
37#    COMMAND chmod a+x ${CMAKE_CURRENT_SOURCE_DIR}/testgh
38#    COMMAND ${CMAKE_CURRENT_SOURCE_DIR}/testgh
39  add_custom_command(OUTPUT ${_GEN_CPP_FILE}
40    COMMAND ${BISON} ${_OPT} -o ${_GEN_CPP_FILE} ${INFILE}
41    COMMAND mv ${NAME}.hpp ${_GEN_H_FILE}
42     
43    COMMAND ${CMAKE_COMMAND} -E copy_if_different ${_SOURCE_CPP_FILE} ${_GEN_CPP_FILE}
44    COMMAND ${CMAKE_COMMAND} -E copy_if_different ${_SOURCE_H_FILE} ${_GEN_H_FILE}
45
46    DEPENDS ${INFILE}
47    COMMENT "Compiling '${INFILE}'..."
48    COMMENT "run ${BISON} ${_OPT} -o ${_GEN_CPP_FILE} ${INFILE}"
49    )
50
51  set(${GEN_TARGET} ${_GEN_TARGET} PARENT_SCOPE)
52  set(${GEN_CPP_FILE} ${_GEN_CPP_FILE} PARENT_SCOPE)
53  set(${GEN_H_FILE}   ${_GEN_H_FILE}   PARENT_SCOPE)
54endfunction()
55
Note: See TracBrowser for help on using the repository browser.