[1882] | 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 | |
---|
| 18 | MACRO(TOLUA _tolua_package _tolua_srcfiles_varname) |
---|
| 19 | # TODO: cleaner arguments handling |
---|
| 20 | SET(_tolua_inputfiles ${ARGN}) |
---|
| 21 | LIST(REMOVE_ITEM _tolua_inputfiles "INPUTFILES") |
---|
| 22 | |
---|
| 23 | SET(_tolua_pkgfile "${CMAKE_CURRENT_BINARY_DIR}/tolua.pkg") |
---|
[2239] | 24 | SET(_tolua_cxxfile "${CMAKE_CURRENT_BINARY_DIR}/ToluaBind${_tolua_package}.cc") |
---|
| 25 | SET(_tolua_hfile "${CMAKE_CURRENT_BINARY_DIR}/ToluaBind${_tolua_package}.h") |
---|
[2519] | 26 | SET(${_tolua_srcfiles_varname} ${${_tolua_srcfiles_varname}} ${_tolua_cxxfile}) |
---|
[1882] | 27 | |
---|
| 28 | # TODO: check secureness of this temporary file |
---|
[2519] | 29 | FILE(REMOVE ${_tolua_pkgfile}) |
---|
[1882] | 30 | FOREACH(_tolua_inputfile ${_tolua_inputfiles}) |
---|
[2519] | 31 | FILE(APPEND ${_tolua_pkgfile} "\$cfile \"${_tolua_inputfile}\"\n") |
---|
[1882] | 32 | ENDFOREACH(_tolua_inputfile) |
---|
| 33 | |
---|
[2519] | 34 | # Note: Some of the variables are already defined in src/tolua/CMakeLists.txt |
---|
[2583] | 35 | # or in the platform config |
---|
[1882] | 36 | ADD_CUSTOM_COMMAND( |
---|
[2519] | 37 | OUTPUT ${_tolua_cxxfile} ${_tolua_hfile} |
---|
[2583] | 38 | COMMAND toluaexe_orxonox -n ${_tolua_package} |
---|
| 39 | -w ${CMAKE_CURRENT_SOURCE_DIR} |
---|
| 40 | -o ${_tolua_cxxfile} |
---|
| 41 | -H ${_tolua_hfile} |
---|
| 42 | -s ${TOLUA_PARSER_SOURCE} |
---|
| 43 | ${_tolua_pkgfile} |
---|
| 44 | DEPENDS ${TOLUA_PARSER_DEPENDENCIES} |
---|
[2243] | 45 | IMPLICIT_DEPENDS CXX ${_tolua_inputfiles} |
---|
[2583] | 46 | WORKING_DIRECTORY ${TOLUA_PARSER_WORKING_DIRECTORY} |
---|
| 47 | COMMENT "Generating tolua bind files for package ${_tolua_package}" |
---|
[1882] | 48 | ) |
---|
| 49 | ENDMACRO(TOLUA) |
---|