Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

source: code/branches/buildsystem/cmake/UseTolua.cmake @ 1883

Last change on this file since 1883 was 1883, checked in by adrfried, 16 years ago

Fix for older CMake versions. Works on Tardis.

File size: 2.2 KB
Line 
1#    UseTolua.cmake - CMake Module to generate LUA Bindings with tolua
2#    Copyright (C) 2008  Adrian Friedli
3#
4#    This program is free software; you can redistribute it and/or modify
5#    it under the terms of the GNU General Public License as published by
6#    the Free Software Foundation; either version 2 of the License, or
7#    (at your option) any later version.
8#
9#    This program is distributed in the hope that it will be useful,
10#    but WITHOUT ANY WARRANTY; without even the implied warranty of
11#    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
12#    GNU General Public License for more details.
13#
14#    You should have received a copy of the GNU General Public License
15#    along with this program; if not, write to the Free Software
16#    Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA
17
18SET(_tolua_executable_name tolua_orxonox)
19GET_TARGET_PROPERTY(TOLUA_EXECUTABLE "${_tolua_executable_name}" LOCATION)
20
21SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -iquote ${CMAKE_CURRENT_SOURCE_DIR} -iquote ${CMAKE_CURRENT_BINARY_DIR}")
22SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -iquote ${CMAKE_CURRENT_SOURCE_DIR} -iquote ${CMAKE_CURRENT_BINARY_DIR}")
23
24MACRO(TOLUA _tolua_package _tolua_srcfiles_varname)
25  # TODO: cleaner arguments handling
26  SET(_tolua_inputfiles ${ARGN})
27  LIST(REMOVE_ITEM _tolua_inputfiles "INPUTFILES")
28
29  SET(_tolua_pkgfile "${CMAKE_CURRENT_BINARY_DIR}/tolua.pkg")
30  SET(_tolua_cxxfile "${CMAKE_CURRENT_BINARY_DIR}/tolua_bind.cc")
31  SET(_tolua_hfile "${CMAKE_CURRENT_BINARY_DIR}/tolua_bind.h")
32  SET(${_tolua_srcfiles_varname} ${${_tolua_srcfiles_varname}} "${_tolua_cxxfile}")
33
34  # TODO: check secureness of this temporary file
35  FILE(REMOVE "${_tolua_pkgfile}")
36  FOREACH(_tolua_inputfile ${_tolua_inputfiles})
37    FILE(APPEND "${_tolua_pkgfile}" "\$cfile \"${_tolua_inputfile}\"\n")
38  ENDFOREACH(_tolua_inputfile)
39
40  ADD_CUSTOM_COMMAND(
41    OUTPUT "${_tolua_cxxfile}" "${_tolua_hfile}"
42    COMMAND "${TOLUA_EXECUTABLE}" -n "${_tolua_package}" -o "${_tolua_cxxfile}" -H "${_tolua_hfile}" "${_tolua_pkgfile}"
43    DEPENDS "${_tolua_executable_name}" ${_tolua_inputfiles}
44    WORKING_DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}"
45  )
46ENDMACRO(TOLUA)
Note: See TracBrowser for help on using the repository browser.