Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

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

Last change on this file since 2236 was 2236, checked in by rgrieder, 15 years ago
  • Changed working directory for tolua generator to library_output_path. That resolves windows issues with dlls.
  • Removed the need to create a second tolua application. There is only one now called toluaexe_orxonox.
  • 'w' (working directory) option of tolua extends to -L, pkg-file, -o and -H if of course -w is present
  • 's' option added to tolua: Tells which file contains the bindfile generator. In our case this is src/tolua/all.lua all.lua replaces tolua-5.1.pkg. We can still choose that file from CMake (TOLUA_PARSER_SOURCE)
  • Generator dependencies are declared in src/tolua/CMakeLists.txt and used in UseTolua.cmake (PARENT_SCOPE)
  • Fixed a bug when writing the header file inclusion in package.lua
File size: 2.5 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)
20
21MACRO(INCLUDE_DIRECTORIES_QUOTES)
22  FOREACH(_tolua_quote_dir ${ARGN})
23    SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -iquote ${_tolua_quote_dir}")
24    SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -iquote ${_tolua_quote_dir}")
25  ENDFOREACH(_tolua_quote_dir)
26ENDMACRO(INCLUDE_DIRECTORIES_QUOTES)
27
28MACRO(TOLUA _tolua_package _tolua_srcfiles_varname)
29  # TODO: cleaner arguments handling
30  SET(_tolua_inputfiles ${ARGN})
31  LIST(REMOVE_ITEM _tolua_inputfiles "INPUTFILES")
32
33  SET(_tolua_pkgfile "${CMAKE_CURRENT_BINARY_DIR}/tolua.pkg")
34  SET(_tolua_cxxfile "${CMAKE_CURRENT_BINARY_DIR}/tolua_bind.cc")
35  SET(_tolua_hfile   "${CMAKE_CURRENT_BINARY_DIR}/tolua_bind.h")
36  SET(${_tolua_srcfiles_varname} ${${_tolua_srcfiles_varname}} "${_tolua_cxxfile}")
37
38  # TODO: check secureness of this temporary file
39  FILE(REMOVE "${_tolua_pkgfile}")
40  FOREACH(_tolua_inputfile ${_tolua_inputfiles})
41    FILE(APPEND "${_tolua_pkgfile}" "\$cfile \"${_tolua_inputfile}\"\n")
42  ENDFOREACH(_tolua_inputfile)
43
44  ADD_CUSTOM_COMMAND(
45    OUTPUT "${_tolua_cxxfile}" "${_tolua_hfile}"
46    COMMAND "${TOLUA_EXECUTABLE}" -n "${_tolua_package}"
47                                  -w "${CMAKE_CURRENT_SOURCE_DIR}"
48                                  -o "${_tolua_cxxfile}"
49                                  -H "${_tolua_hfile}"
50                                  -s "${TOLUA_PARSER_SOURCE}"
51                                     "${_tolua_pkgfile}"
52    DEPENDS "${_tolua_executable_name}" ${_tolua_inputfiles} ${TOLUA_PARSER_DEPENDENCIES}
53    WORKING_DIRECTORY "${LIBRARY_OUTPUT_PATH}"
54  )
55ENDMACRO(TOLUA)
Note: See TracBrowser for help on using the repository browser.