Skip to content

Commit

Permalink
Require Lua 5.1 when building the Lua bindings
Browse files Browse the repository at this point in the history
The cairo/imlib2/rsvg bindings require tolua++ [1], which is currently only
compatible with Lua 5.1 or earlier. We need to force Conky to compile against
Lua 5.1 if the user chooses to build the bindings.

This commit adds a separate pkg_search_module command specifically for Lua 5.1,
along with a note in the documentation. The original pkg_search_module command
was updated to include (and prefer) Lua 5.3+. Also, I threw in two other minor
random fixes to the docs while I was at it.

[1] https://github.com/LuaDist/toluapp
  • Loading branch information
marcpayne committed Dec 11, 2015
1 parent 2fab2d3 commit 0dbd27d
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 15 deletions.
24 changes: 19 additions & 5 deletions cmake/ConkyPlatformChecks.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -250,12 +250,28 @@ if(BUILD_X11)
endif(X11_FOUND)
endif(BUILD_X11)

pkg_search_module(LUA REQUIRED lua5.2 lua-5.2 lua>=5.1 lua5.1 lua-5.1)
# Check whether we want Lua bindings
if(BUILD_LUA_CAIRO OR BUILD_LUA_IMLIB2 OR BUILD_LUA_RSVG)
set(WANT_TOLUA true)
endif(BUILD_LUA_CAIRO OR BUILD_LUA_IMLIB2 OR BUILD_LUA_RSVG)

# Check for Lua itself
if(WANT_TOLUA)
# If we need tolua++, we must compile against Lua 5.1
pkg_search_module(LUA REQUIRED lua5.1 lua-5.1 lua51 lua)
if(NOT LUA_VERSION VERSION_LESS 5.2.0)
message(FATAL_ERROR "Unable to find Lua 5.1.x")
endif(NOT LUA_VERSION VERSION_LESS 5.2.0)
else(WANT_TOLUA)
# Otherwise, use the most recent Lua version
pkg_search_module(LUA REQUIRED lua>=5.3 lua5.3 lua-5.3 lua53 lua5.2 lua-5.2 lua52 lua5.1 lua-5.1 lua51 lua>=5.1)
endif(WANT_TOLUA)
set(conky_libs ${conky_libs} ${LUA_LIBRARIES})
set(conky_includes ${conky_includes} ${LUA_INCLUDE_DIRS})
link_directories(${LUA_LIBRARY_DIRS})

# Check for libraries used by Lua bindings
if(BUILD_LUA_CAIRO)
set(WANT_TOLUA true)
pkg_check_modules(CAIRO REQUIRED cairo cairo-xlib)
set(luacairo_libs ${CAIRO_LIBRARIES} ${LUA_LIBRARIES})
set(luacairo_includes ${CAIRO_INCLUDE_DIRS} ${LUA_INCLUDE_DIRS})
Expand All @@ -265,13 +281,11 @@ if(BUILD_LUA_CAIRO)
endif(NOT APP_PATCH)
endif(BUILD_LUA_CAIRO)
if(BUILD_LUA_IMLIB2)
set(WANT_TOLUA true)
pkg_check_modules(IMLIB2 imlib2)
pkg_search_module(IMLIB2 REQUIRED imlib2 Imlib2)
set(luaimlib2_libs ${IMLIB2_LIB} ${LUA_LIBRARIES})
set(luaimlib2_includes ${IMLIB2_INCLUDE_PATH} ${LUA_INCLUDE_DIRS})
endif(BUILD_LUA_IMLIB2)
if(BUILD_LUA_RSVG)
set(WANT_TOLUA true)
pkg_check_modules(RSVG REQUIRED librsvg-2.0)
set(luarsvg_libs ${RSVG_LIBRARIES} ${LUA_LIBRARIES})
set(luarsvg_includes ${RSVG_INCLUDE_DIRS} ${LUA_INCLUDE_DIRS})
Expand Down
20 changes: 10 additions & 10 deletions doc/docs.xml
Original file line number Diff line number Diff line change
Expand Up @@ -192,15 +192,15 @@
<refsect1>
<title>Lua API</title>
<para>Conky features a Lua Programming API, and also ships with Lua
bindings for some useful libraries. Conky defines certain global
functions and variables which can be accessed from Lua code running
in Conky.
bindings for some useful libraries. Note that the bindings require
tolua++, which currently only compiles against Lua 5.1.
</para>
<para>To use Lua Conky, you first need to make sure you have a version of Conky
with Lua support enabled (``conky -v'' will report this). Scripts
must first be loaded using the lua_load configuration option. You
then call functions in Lua via Conky's $lua, $lua_read, and Lua
hooks.
with Lua support enabled (``conky -v'' will report this). Conky defines
certain global functions and variables which can be accessed from Lua
code running in Conky. Scripts must first be loaded using the lua_load
configuration option. You then call functions in Lua via Conky's $lua,
$lua_read, and Lua hooks.
</para>
<para>
Be careful when creating threaded objects through the Lua API. You
Expand Down Expand Up @@ -263,7 +263,7 @@
</varlistentry>
<varlistentry>
<term>
<filename>~/.config/conky/rc</filename>
<filename>~/.config/conky/conky.conf</filename>
</term>
<listitem>Default personal configuration
file.</listitem>
Expand Down Expand Up @@ -308,8 +308,8 @@
the BSD license (see LICENSE.BSD for a copy). All code
written since the fork of torsmo is licensed under the GPL
(see LICENSE.GPL for a copy), except where noted
differently (such as in portmon and audacious code which are LGPL, and
prss which is an MIT-style license).</para>
differently (such as in portmon and audacious code which are LGPL, and
prss which is an MIT-style license).</para>
</refsect1>
<refsect1>
<title>Authors</title>
Expand Down

0 comments on commit 0dbd27d

Please sign in to comment.