From: Tim Goya Date: Sat, 29 Sep 2007 00:49:50 +0000 (+0000) Subject: Fix OpenGL detection and miniswig wrapper generation for CMake X-Git-Url: https://git.verplant.org/?a=commitdiff_plain;h=2d4bda804822bd8d08bd5120f1e7b94d38ce3aee;p=supertux.git Fix OpenGL detection and miniswig wrapper generation for CMake SVN-Revision: 5159 --- diff --git a/CMakeLists.txt b/CMakeLists.txt index ab32f9b78..d519ffc45 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -34,8 +34,6 @@ # # FIXME: create config.h from config.h.in -# FIXME: compile miniswig -# FIXME: use miniswig to create squirrel wrappers # FIXME: create messages.pot for levels # FIXME: provide working install target # @@ -55,6 +53,7 @@ set(DEBUG 0 CACHE BOOL "Build with debugging options") set(ENABLE_BINRELOC 0 CACHE BOOL "Enable autopackage's BINRELOC features") set(APPDATADIR "" CACHE STRING "APPDATADIR for autopackage's BINRELOC features") set(ENABLE_SQDBG 0 CACHE BOOL "Build squirrel script interpreter with debugging options") +set(ENABLE_OPENGL 1 CACHE BOOL "Enable OpenGL support") ## Search here for additional cmake modules (for finding deps) @@ -70,9 +69,12 @@ FIND_PACKAGE(SDL_image REQUIRED) INCLUDE_DIRECTORIES(${SDLIMAGE_INCLUDE_DIR}) LINK_LIBRARIES(${SDLIMAGE_LIBRARY}) -FIND_PACKAGE(OpenGL REQUIRED) -INCLUDE_DIRECTORIES(${OPENGL_INCLUDE_DIR}) -LINK_LIBRARIES(${OPENGL_LIBRARY}) +IF(ENABLE_OPENGL) + FIND_PACKAGE(OpenGL) + INCLUDE_DIRECTORIES(${OPENGL_INCLUDE_DIR}) + LINK_LIBRARIES(${OPENGL_LIBRARY}) + SET(HAVE_OPENGL OPENGL_FOUND) +ENDIF(ENABLE_OPENGL) FIND_PACKAGE(OpenAL REQUIRED) INCLUDE_DIRECTORIES(${OPENAL_INCLUDE_DIR}) @@ -99,6 +101,9 @@ INCLUDE(ConfigureChecks) configure_file(config.h.cmake ${CMAKE_BINARY_DIR}/config.h ) include_directories (${CMAKE_BINARY_DIR}/) +## Also execute instructions in tools/miniswig/CMakeLists.txt +ADD_SUBDIRECTORY(tools/miniswig) + ## Also execute instructions in src/squirrel/CMakeLists.txt ADD_SUBDIRECTORY(src/squirrel) @@ -116,6 +121,17 @@ include_directories (${SUPERTUX_SOURCE_DIR}/src/squirrel/include/) FILE(GLOB SUPERTUX_SOURCES RELATIVE ${SUPERTUX_SOURCE_DIR} src/*.cpp src/audio/*.cpp src/badguy/*.cpp src/binreloc/*.cpp src/control/*.cpp src/gui/*.cpp src/lisp/*.cpp src/math/*.cpp src/object/*.cpp src/physfs/*.cpp src/sprite/*.cpp src/tinygettext/*.cpp src/trigger/*.cpp src/video/*.cpp src/worldmap/*.cpp src/scripting/*.cpp) +## Generate miniswig wrapper + +ADD_CUSTOM_COMMAND( + OUTPUT ${SUPERTUX_SOURCE_DIR}/src/scripting/wrapper.cpp ${SUPERTUX_SOURCE_DIR}/src/scripting/wrapper.hpp + COMMAND ${CMAKE_CXX_COMPILER} + ARGS -x "c++" -E -CC -DSCRIPTING_API -I${SUPERTUX_SOURCE_DIR}/src/ -I${SUPERTUX_SOURCE_DIR}/src/squirrel/include/ ${SUPERTUX_SOURCE_DIR}/src/scripting/wrapper.interface.hpp -o miniswig.tmp + COMMAND tools/miniswig/miniswig + ARGS --input miniswig.tmp --output-cpp ${SUPERTUX_SOURCE_DIR}/src/scripting/wrapper.cpp --output-hpp ${SUPERTUX_SOURCE_DIR}/src/scripting/wrapper.hpp --module supertux --select-namespace Scripting + DEPENDS src/scripting/wrapper.interface.hpp tools/miniswig/miniswig +) + ## If xgettext is available, generate messages.pot for sources FIND_PROGRAM( @@ -142,18 +158,18 @@ ADD_DEFINITIONS(-O2 -fno-strict-aliasing) ## Add target for supertux binary -ADD_EXECUTABLE(supertux ${SUPERTUX_SOURCES} ) +ADD_EXECUTABLE(supertux2 ${SUPERTUX_SOURCES} ) ## Link supertux binary with squirrel -TARGET_LINK_LIBRARIES(supertux squirrel) +TARGET_LINK_LIBRARIES(supertux2 squirrel) ## After building, copy binary to source root ADD_CUSTOM_COMMAND( - TARGET supertux + TARGET supertux2 POST_BUILD COMMAND ${CMAKE_COMMAND} - ARGS -E copy supertux ${SUPERTUX_SOURCE_DIR}/supertux + ARGS -E copy supertux2 ${SUPERTUX_SOURCE_DIR}/supertux2 ) diff --git a/config.h.cmake b/config.h.cmake index 3838a396e..fda85c87e 100644 --- a/config.h.cmake +++ b/config.h.cmake @@ -21,3 +21,4 @@ #define ICONV_CONST #endif +#cmakedefine HAVE_OPENGL diff --git a/tools/miniswig/CMakeLists.txt b/tools/miniswig/CMakeLists.txt new file mode 100644 index 000000000..de255c24d --- /dev/null +++ b/tools/miniswig/CMakeLists.txt @@ -0,0 +1,60 @@ +# +# SuperTux - miniswig build script +# Copyright (C) 2007 Timothy Goya +# +# 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)