1
0
mirror of https://github.com/Llewellynvdm/conky.git synced 2024-12-26 20:31:17 +00:00
conky/cmake/ToLua.cmake
Brenden Matthews bb8723dd36
Add toluapp subtree (#712)
* First commit!

* Import to git

* Droping down CMake requirement

* Corrected installation of libraries

* Adding travis build

* Updated cmake macros

* Fixed find package

* Updated travis hook

* Updated travis hook

* Patch to support Lua 5.3.

* Fix Lua header include directives in tolua++.h

Use angle bracket rather than double quotes when including Lua headers in the tolua++ header. This fixes a problem on systems that default to a Lua version newer than 5.1 and install the tolua++ header to the same directory as newer Lua headers.

As there are (usually) no Lua headers in the same directory when building tolua++ itself, the preprocessor will look to the include directories passed to the compiler, one of which would be the Lua 5.1 include directory, and tolua++ will build with those (correct) headers. Then the tolua++ header is usually installed in the default include directory, alongside the newer Lua headers, which you wouldn't expect to cause any trouble.

But it does cause trouble when trying to build other programs that include the tolua++ header, because now the preprocessor does find Lua headers in the same directory as the tolua++ header, which are the newer (incorrect) headers. Now the program will either fail to compile, because it doesn't support the newer headers, or fail to link with the tolua++ shared object because they were compiled against different Lua headers.

Using angle brackets instead of double quotes in the include directives will fix the problem, because then the preprocessor will look to the include directories passed to the compiler first.

See http://www.cegui.org.uk/forum/viewtopic.php?f=10&t=7195

* Remove email notifications.

* Update travis build.

* Build shared and static libs.

* Patch toluapp to support Lua 5.3.

With this change, support for Lua 5.1 is dropped.

This resolve #116.

* Add some comments to clarify the toluapp handling.

* Add minor sonar fix.
2018-12-20 15:18:51 -05:00

58 lines
2.0 KiB
CMake

#
# Conky, a system monitor, based on torsmo
#
# Please see COPYING for details
#
# Copyright (c) 2005-2018 Brenden Matthews, et. al. (see AUTHORS)
# All rights reserved.
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
#
function(wrap_tolua VAR FIL)
SET(INCL)
SET(${VAR})
GET_FILENAME_COMPONENT(ABS_FIL ${FIL} ABSOLUTE)
GET_FILENAME_COMPONENT(FIL_WE ${FIL} NAME_WE)
LIST(APPEND ${VAR} "${CMAKE_CURRENT_BINARY_DIR}/lib${FIL_WE}.c")
if(DEFINED ARGV2)
GET_FILENAME_COMPONENT(PATCH ${ARGV2} ABSOLUTE)
SET(TOLUA_OUT ${CMAKE_CURRENT_BINARY_DIR}/lib${FIL_WE}-orig.c)
ADD_CUSTOM_COMMAND( OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/lib${FIL_WE}.c
COMMAND ${APP_PATCH} -s ${TOLUA_OUT} ${PATCH} -o ${CMAKE_CURRENT_BINARY_DIR}/lib${FIL_WE}.c
DEPENDS ${TOLUA_OUT} ${PATCH}
COMMENT "Patching lib${FIL_WE}-orig.c"
VERBATIM)
SET_SOURCE_FILES_PROPERTIES(${TOLUA_OUT} PROPERTIES GENERATED TRUE)
else()
SET(TOLUA_OUT ${CMAKE_CURRENT_BINARY_DIR}/lib${FIL_WE}.c)
endif(DEFINED ARGV2)
# Call toluapp from 3rdparty/ path directly.
# The last argument to toluapp is the path to the tolua Lua sources.
ADD_CUSTOM_COMMAND( OUTPUT ${TOLUA_OUT} ${INCL} COMMAND
toluapp -n
${FIL_WE} -o ${TOLUA_OUT} ${ABS_FIL}
${CMAKE_SOURCE_DIR}/3rdparty/toluapp/src/bin/lua/
DEPENDS ${ABS_FIL} COMMENT "Running tolua++ on ${FIL}"
VERBATIM )
SET_SOURCE_FILES_PROPERTIES(${${VAR}} ${INCL} PROPERTIES GENERATED TRUE)
SET(${VAR} ${${VAR}} PARENT_SCOPE)
endfunction(wrap_tolua)