diff --git a/CMakeLists.txt b/CMakeLists.txt index 12f5020c..2ebfed10 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -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 +) + diff --git a/cmake/ConkyBuildOptions.cmake b/cmake/ConkyBuildOptions.cmake index ee44aab9..88a586e0 100644 --- a/cmake/ConkyBuildOptions.cmake +++ b/cmake/ConkyBuildOptions.cmake @@ -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) diff --git a/cmake/ConkyPlatformChecks.cmake b/cmake/ConkyPlatformChecks.cmake index 4f02487a..14bd0559 100644 --- a/cmake/ConkyPlatformChecks.cmake +++ b/cmake/ConkyPlatformChecks.cmake @@ -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) + diff --git a/cmake/ToLua.cmake b/cmake/ToLua.cmake new file mode 100644 index 00000000..a5209c08 --- /dev/null +++ b/cmake/ToLua.cmake @@ -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) diff --git a/lua/CMakeLists.txt b/lua/CMakeLists.txt index e69de29b..6af95f80 100644 --- a/lua/CMakeLists.txt +++ b/lua/CMakeLists.txt @@ -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 +) diff --git a/lua/cairo.pkg b/lua/cairo.pkg index 2a6a6cfd..65019bc2 100644 --- a/lua/cairo.pkg +++ b/lua/cairo.pkg @@ -3,7 +3,7 @@ $#include $#include $#include $#include -$#include "libcairo-helper.h" +$#include /* * 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. diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 64fc6d78..b7930016 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -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 +)