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 | FUNCTION(GENERATE_TOLUA_BINDINGS _tolua_package _target_source_files) |
---|
19 | SET(_tolua_inputfiles ${ARGN}) |
---|
20 | LIST(REMOVE_ITEM _tolua_inputfiles "INPUTFILES") |
---|
21 | |
---|
22 | SET(_tolua_pkgfile "${CMAKE_CURRENT_BINARY_DIR}/tolua.pkg") |
---|
23 | SET(_tolua_cxxfile "${CMAKE_CURRENT_BINARY_DIR}/ToluaBind${_tolua_package}.cc") |
---|
24 | SET(_tolua_hfile "${CMAKE_CURRENT_BINARY_DIR}/ToluaBind${_tolua_package}.h") |
---|
25 | |
---|
26 | SET(${_target_source_files} |
---|
27 | ${${_target_source_files}} |
---|
28 | ${_tolua_cxxfile} |
---|
29 | ${_tolua_hfile} |
---|
30 | PARENT_SCOPE |
---|
31 | ) |
---|
32 | SOURCE_GROUP("Tolua" FILES ${_tolua_cxxfile} ${_tolua_hfile}) |
---|
33 | |
---|
34 | # Create temporary package 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++app_orxonox -n ${_tolua_package} |
---|
43 | -w ${CMAKE_CURRENT_SOURCE_DIR} |
---|
44 | -o ${_tolua_cxxfile} |
---|
45 | -H ${_tolua_hfile} |
---|
46 | -s ${TOLUA_PARSER_SOURCE} |
---|
47 | ${_tolua_pkgfile} |
---|
48 | DEPENDS ${TOLUA_PARSER_DEPENDENCIES} |
---|
49 | IMPLICIT_DEPENDS CXX ${_tolua_inputfiles} |
---|
50 | WORKING_DIRECTORY ${ORXONOX_RUNTIME_LIBRARY_DIRECTORY} |
---|
51 | COMMENT "Generating tolua bind files for package ${_tolua_package}" |
---|
52 | ) |
---|
53 | ENDFUNCTION(GENERATE_TOLUA_BINDINGS) |
---|