1
0
mirror of https://github.com/Llewellynvdm/conky.git synced 2024-10-02 23:19:08 +00:00

Add CMake build support for Lua bindings.

This commit is contained in:
Brenden Matthews 2009-12-17 19:46:26 -08:00
parent 32c5f451b9
commit fb33419cd4
7 changed files with 97 additions and 1 deletions

View File

@ -28,3 +28,10 @@ add_subdirectory(src)
add_subdirectory(lua)
add_subdirectory(doc)
# Install README into share dir (is this even the right spot? need to revisit
# this at some point)
install(FILES
README
DESTINATION share/doc/conky
)

View File

@ -72,6 +72,10 @@ if(BUILD_X11)
endif(BUILD_X11)
option(BUILD_LUA "Build Lua support" true)
if(BUILD_LUA)
option(BUILD_LUA_CAIRO "Build cairo bindings for Lua" false)
option(BUILD_LUA_IMLIB2 "Build Imlib2 bindings for Lua" false)
endif(BUILD_LUA)
option(BUILD_AUDACIOUS "Build audacious (music player) support" false)
if(BUILD_AUDACIOUS)

View File

@ -149,6 +149,18 @@ if(BUILD_LUA)
pkg_search_module(LUA REQUIRED lua>=5.1 lua-5.1>=5.1 lua5.1>=5.1)
set(conky_libs ${conky_libs} ${LUA_LIBRARIES})
set(conky_includes ${conky_includes} ${LUA_INCLUDE_DIRS})
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})
endif(BUILD_LUA_CAIRO)
if(BUILD_LUA_IMLIB2)
set(WANT_TOLUA true)
pkg_check_modules(IMLIB2 imlib2)
set(luaimlib2_libs ${IMLIB2_LIB} ${LUA_LIBRARIES})
set(luaimlib2_includes ${IMLIB2_INCLUDE_PATH} ${LUA_INCLUDE_DIRS})
endif(BUILD_LUA_IMLIB2)
endif(BUILD_LUA)
if(BUILD_AUDACIOUS)
@ -244,3 +256,17 @@ if(WANT_LIBXML2)
set(conky_includes ${conky_includes} ${LIBXML2_INCLUDE_DIRS})
endif(WANT_LIBXML2)
if(WANT_TOLUA)
find_program(APP_TOLUA tolua++)
if(NOT APP_TOLUA)
message(FATAL_ERROR "Unable to find program 'tolua++'")
endif(NOT APP_TOLUA)
find_library(TOLUA_LIBS NAMES tolua++ tolua++5.1)
find_path(TOLUA_INCLUDE_PATH tolua++.h ${INCLUDE_SEARCH_PATH})
if(TOLUA_INCLUDE_PATH AND TOLUA_LIBS)
set(TOLUA_FOUND true)
else(TOLUA_INCLUDE_PATH AND TOLUA_LIBS)
message(FATAL_ERROR "Unable to find tolua++ library")
endif(TOLUA_INCLUDE_PATH AND TOLUA_LIBS)
endif(WANT_TOLUA)

24
cmake/ToLua.cmake Normal file
View File

@ -0,0 +1,24 @@
function(wrap_tolua VAR)
if(NOT ARGN)
message(SEND_ERROR "Error: wrap_tolua called without any files")
return()
endif(NOT ARGN)
SET(INCL)
SET(${VAR})
FOREACH(FIL ${ARGN})
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")
ADD_CUSTOM_COMMAND( OUTPUT ${${VAR}} ${INCL} COMMAND ${APP_TOLUA} -n
${FIL_WE} -o ${CMAKE_CURRENT_BINARY_DIR}/lib${FIL_WE}.c ${ABS_FIL} DEPENDS
${ABS_FIL} COMMENT "Running tolua++ on ${FIL}"
VERBATIM )
SET_SOURCE_FILES_PROPERTIES(${${VAR}} ${INCL} PROPERTIES GENERATED TRUE)
ENDFOREACH(FIL)
SET(${VAR} ${${VAR}} PARENT_SCOPE)
endfunction(wrap_tolua)

View File

@ -0,0 +1,27 @@
include(ToLua)
if(BUILD_LUA_CAIRO)
include_directories(${luacairo_includes} ${CMAKE_CURRENT_SOURCE_DIR})
wrap_tolua(luacairo_src cairo.pkg)
add_library(cairo SHARED ${luacairo_src})
target_link_libraries(cairo ${luacairo_libs} ${TOLUA_LIBS})
set(lua_libs ${lua_libs} cairo)
endif(BUILD_LUA_CAIRO)
if(BUILD_LUA_IMLIB2)
include_directories(${luaimlib2_includes} ${CMAKE_CURRENT_SOURCE_DIR})
wrap_tolua(luaimlib2_src imlib2.pkg)
add_library(imlib2 SHARED ${luaimlib2_src})
target_link_libraries(imlib2 ${luaimlib2_libs} ${TOLUA_LIBS})
set(lua_libs ${lua_libs} imlib2)
endif(BUILD_LUA_IMLIB2)
install(TARGETS
${lua_libs}
LIBRARY DESTINATION lib/conky
ARCHIVE DESTINATION lib/conky
)

View File

@ -3,7 +3,7 @@ $#include <cairo-deprecated.h>
$#include <cairo.h>
$#include <cairo-xlib.h>
$#include <X11/Xlib.h>
$#include "libcairo-helper.h"
$#include <libcairo-helper.h>
/*
* This code was mostly copied from cairo.h and cairo-xlib.h with comments
* removed. The licence noticed below is present for the sake of clarity.

View File

@ -143,3 +143,11 @@ endif(BUILD_CONFIG_OUTPUT)
add_executable(conky ${conky_sources} ${optional_sources})
target_link_libraries(conky ${conky_libs})
# Install libtcp-portmon too?
install(TARGETS
conky
RUNTIME DESTINATION bin
LIBRARY DESTINATION lib
ARCHIVE DESTINATION lib
)