+#
+# SuperTux - miniswig build script
+# Copyright (C) 2007 Timothy Goya <tuxdev103@gmail.com>
+#
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 2 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write to the Free Software
+# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+#
+
+## Project name to use as command prefix
+
+PROJECT(MINISWIG)
+
+## add additional compiler switches
+
+ADD_DEFINITIONS(-include ${CMAKE_BINARY_DIR}/config.h)
+
+## Add target for bison parser generation
+
+FIND_PROGRAM(BISON_EXECUTABLE bison)
+IF (NOT BISON_EXECUTABLE)
+ MESSAGE(FATAL_ERROR "bison not found - aborting")
+ENDIF (NOT BISON_EXECUTABLE)
+ADD_CUSTOM_COMMAND(
+ OUTPUT ${MINISWIG_SOURCE_DIR}/parser.cpp ${MINISWIG_SOURCE_DIR}/parser.hpp
+ COMMAND ${BISON_EXECUTABLE}
+ ARGS -d -o ${MINISWIG_SOURCE_DIR}/parser.cpp ${MINISWIG_SOURCE_DIR}/parser.yy
+ DEPENDS parser.yy
+)
+
+## Add target for flex lexical analyzer generation
+
+FIND_PROGRAM(FLEX_EXECUTABLE flex)
+IF (NOT FLEX_EXECUTABLE)
+ MESSAGE(FATAL_ERROR "flex not found - aborting")
+ENDIF (NOT FLEX_EXECUTABLE)
+ADD_CUSTOM_COMMAND(
+ OUTPUT ${MINISWIG_SOURCE_DIR}/lexer.cpp
+ COMMAND ${FLEX_EXECUTABLE}
+ ARGS -o ${MINISWIG_SOURCE_DIR}/lexer.cpp ${MINISWIG_SOURCE_DIR}/lexer.ll
+ DEPENDS lexer.ll ${MINISWIG_SOURCE_DIR}/parser.hpp
+)
+
+## build list of source files
+
+FILE(GLOB MINISWIG_SOURCES RELATIVE ${MINISWIG_SOURCE_DIR} *.cpp)
+
+## Add target for miniswig binary
+
+ADD_EXECUTABLE(miniswig ${MINISWIG_SOURCES} ${MINISWIG_SOURCE_DIR}/parser.cpp ${MINISWIG_SOURCE_DIR}/lexer.cpp)