Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Re-added fix for generating <include_file>.h
git-svn-id: http://svn.osgeo.org/qgis/branches/Release-0_8_0@6688 c8812cc2-4d05-0410-92ff-de0c093fc19c
  • Loading branch information
homann committed Feb 24, 2007
1 parent b77b381 commit 1044eb8
Showing 1 changed file with 49 additions and 36 deletions.
85 changes: 49 additions & 36 deletions cmake/Bison.cmake
@@ -1,12 +1,12 @@
# use bison for .yy files

# search for bison
MACRO(FIND_BISON)
IF(NOT BISON_EXECUTABLE)
FIND_PROGRAM(BISON_EXECUTABLE bison)
IF (NOT BISON_EXECUTABLE)
# use bison for .yy files

# search for bison
MACRO(FIND_BISON)
IF(NOT BISON_EXECUTABLE)
FIND_PROGRAM(BISON_EXECUTABLE bison)
IF (NOT BISON_EXECUTABLE)

MESSAGE(FATAL_ERROR "Bison not found - aborting")
MESSAGE(FATAL_ERROR "Bison not found - aborting")

ELSE (NOT BISON_EXECUTABLE)

Expand All @@ -20,35 +20,48 @@ MACRO(FIND_BISON)
MESSAGE (FATAL_ERROR "Bison version is too old (${BISON_VERSION_MAJOR}.${BISON_VERSION_MINOR}). Use 2.0 or higher.")
ENDIF (BISON_VERSION_MAJOR LESS 2)

ENDIF (NOT BISON_EXECUTABLE)
ENDIF(NOT BISON_EXECUTABLE)

ENDMACRO(FIND_BISON)

MACRO(ADD_BISON_FILES _sources )
FIND_BISON()

FOREACH (_current_FILE ${ARGN})
GET_FILENAME_COMPONENT(_in ${_current_FILE} ABSOLUTE)
GET_FILENAME_COMPONENT(_basename ${_current_FILE} NAME_WE)

SET(_out ${CMAKE_CURRENT_BINARY_DIR}/${_basename}.cpp)


ENDIF (NOT BISON_EXECUTABLE)
ENDIF(NOT BISON_EXECUTABLE)

ENDMACRO(FIND_BISON)

MACRO(ADD_BISON_FILES _sources )
FIND_BISON()

FOREACH (_current_FILE ${ARGN})
GET_FILENAME_COMPONENT(_in ${_current_FILE} ABSOLUTE)
GET_FILENAME_COMPONENT(_basename ${_current_FILE} NAME_WE)

SET(_out ${CMAKE_CURRENT_BINARY_DIR}/${_basename}.cpp)
SET(_out_h ${CMAKE_CURRENT_BINARY_DIR}/${_basename}.h)
SET(_out_hpp ${CMAKE_CURRENT_BINARY_DIR}/${_basename}.hpp)

# bison options:
# -t add debugging facilities
# -d produce additional header file (used in parser.l)
# -v produce additional *.output file with parser states

ADD_CUSTOM_COMMAND(
OUTPUT ${_out}
COMMAND ${BISON_EXECUTABLE}
ARGS
-o${_out} -d -v -t
${_in}
DEPENDS ${_in}
)

SET(${_sources} ${${_sources}} ${_out} )
ENDFOREACH (_current_FILE)
ENDMACRO(ADD_BISON_FILES)

ADD_CUSTOM_COMMAND(
OUTPUT ${_out}
COMMAND ${BISON_EXECUTABLE}
ARGS
-o${_out} -d -v -t
${_in}
DEPENDS ${_in}
)

# Hack to change output file name to <include_file>.h
# instead of <include_file>.hpp
# (Instead of changing source code)

ADD_CUSTOM_COMMAND(
OUTPUT ${_out_h}
COMMAND ${CMAKE_COMMAND}
ARGS
-E copy ${_out_hpp} ${_out_h}
DEPENDS ${_out}
)

SET(${_sources} ${${_sources}} ${_out} ${_out_h} )
ENDFOREACH (_current_FILE)
ENDMACRO(ADD_BISON_FILES)

0 comments on commit 1044eb8

Please sign in to comment.