Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

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

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

tolua fixed for mingw, libtolua linked statically

  • Property svn:eol-style set to native
File size: 2.4 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 toluaexe_orxonox)
19GET_TARGET_PROPERTY(TOLUA_EXECUTABLE "${_tolua_executable_name}" LOCATION)
20IF(MINGW_LIBRARY_DIR)
21  SET(_tolua_command_wd "WORKING_DIRECTORY;${MINGW_LIBRARY_DIR}/lua-5.1.3/lib")
22ELSE(MINGW_LIBRARY_DIR)
23  SET(_tolua_command_wd)
24ENDIF(MINGW_LIBRARY_DIR)
25
26MACRO(TOLUA _tolua_package _tolua_srcfiles_varname)
27  # TODO: cleaner arguments handling
28  SET(_tolua_inputfiles ${ARGN})
29  LIST(REMOVE_ITEM _tolua_inputfiles "INPUTFILES")
30
31  SET(_tolua_pkgfile "${CMAKE_CURRENT_BINARY_DIR}/tolua.pkg")
32  SET(_tolua_cxxfile "${CMAKE_CURRENT_BINARY_DIR}/ToluaBind${_tolua_package}.cc")
33  SET(_tolua_hfile   "${CMAKE_CURRENT_BINARY_DIR}/ToluaBind${_tolua_package}.h")
34  SET(${_tolua_srcfiles_varname} ${${_tolua_srcfiles_varname}} "${_tolua_cxxfile}")
35
36  # TODO: check secureness of this temporary file
37  FILE(REMOVE "${_tolua_pkgfile}")
38  FOREACH(_tolua_inputfile ${_tolua_inputfiles})
39    FILE(APPEND "${_tolua_pkgfile}" "\$cfile \"${_tolua_inputfile}\"\n")
40  ENDFOREACH(_tolua_inputfile)
41
42  ADD_CUSTOM_COMMAND(
43    OUTPUT "${_tolua_cxxfile}" "${_tolua_hfile}"
44    COMMAND "${TOLUA_EXECUTABLE}" -n "${_tolua_package}"
45                                  -w "${CMAKE_CURRENT_SOURCE_DIR}"
46                                  -o "${_tolua_cxxfile}"
47                                  -H "${_tolua_hfile}"
48                                  -s "${TOLUA_PARSER_SOURCE}"
49                                     "${_tolua_pkgfile}"
50    DEPENDS "${_tolua_executable_name}" ${TOLUA_PARSER_DEPENDENCIES}
51    IMPLICIT_DEPENDS CXX ${_tolua_inputfiles}
52    ${_tolua_command_wd}
53  )
54ENDMACRO(TOLUA)
Note: See TracBrowser for help on using the repository browser.