CMakeLists.txt
changeset 148 b222f4d111d9
parent 147 66a63c9609de
child 151 5d90caa7fb2c
equal deleted inserted replaced
147:66a63c9609de 148:b222f4d111d9
     1 ## Copyright 2009-2012 Myhailo Danylenko
     1 ## Copyright 2009-2016 Myhailo Danylenko
     2 # This file is part of mcabber-lua.
     2 # This file is part of mcabber-lua.
     3 #
     3 #
     4 # mcabber-lua is free software: you can redistribute it and/or modify
     4 # mcabber-lua is free software: you can redistribute it and/or modify
     5 # it under the terms of the GNU General Public License as published by
     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
     6 # the Free Software Foundation, either version 2 of the License, or
    14 # You should have received a copy of the GNU General Public License
    14 # You should have received a copy of the GNU General Public License
    15 # along with this program.  If not, see <http://www.gnu.org/licenses/>.
    15 # along with this program.  If not, see <http://www.gnu.org/licenses/>.
    16 
    16 
    17 cmake_minimum_required(VERSION 2.6)
    17 cmake_minimum_required(VERSION 2.6)
    18 project(lua C)
    18 project(lua C)
    19 set(PROJECT_VERSION "0.0.3")
    19 set(PROJECT_VERSION "0.0.4")
    20 
    20 
    21 ## User options
    21 ## User options
    22 option(DEBUG                 "Enable debugging output"                                                           ON)
    22 option(DEBUG                 "Enable debugging output"                                                           ON)
    23 option(WANT_LUA52            "Use lua 5.2 instead of 5.1"                                                       OFF)
       
    24 option(ENABLE_LUA_ALIAS      "Enable aliasing command '/lua' to corresponding '/lua5.x' at module loading time"  ON)
    23 option(ENABLE_LUA_ALIAS      "Enable aliasing command '/lua' to corresponding '/lua5.x' at module loading time"  ON)
    25 option(LLM_CONNECTION_ENABLE "Enable exposing of mcabber loudmouth connection to lua"                            ON)
    24 option(LLM_CONNECTION_ENABLE "Enable exposing of mcabber loudmouth connection to lua"                            ON)
    26 option(LLM_LOG_HANDLER       "Enable registration of log messages handler for lua-loudmouth library's messages"  ON)
    25 option(LLM_LOG_HANDLER       "Enable registration of log messages handler for lua-loudmouth library's messages"  ON)
    27 set(ML_SOURCE_PRIORITY G_PRIORITY_HIGH_IDLE CACHE STRING "Glib event source priority for timeout and bgread")
    26 set(ML_SOURCE_PRIORITY G_PRIORITY_HIGH_IDLE CACHE STRING "Glib event source priority for timeout and bgread")
    28 set(ML_BGREAD_BUFFER   4096                 CACHE STRING "Background pipe reading buffer size")
    27 set(ML_BGREAD_BUFFER   4096                 CACHE STRING "Background pipe reading buffer size")
    29 set(OPT_MLUA_RC        "lua_init_filename"  CACHE STRING "Mcabber option name to specify lua initialization file")
    28 set(OPT_MLUA_RC        "lua_init_filename"  CACHE STRING "Mcabber option name to specify lua initialization file")
    30 set(OPT_MLUA_LM_DEBUG  "lua_lm_debug"       CACHE STRING "Mcabber option name to enable/disable lua logging of LM messages")
    29 set(OPT_MLUA_LM_DEBUG  "lua_lm_debug"       CACHE STRING "Mcabber option name to enable/disable lua logging of LM messages")
       
    30 set(WANT_LUA           "AUTO" CACHE STRING "Lua version to use (You'll have to define this with -DWANT_LUA=LUAX.X)")
       
    31 set_property(CACHE WANT_LUA PROPERTY STRINGS "AUTO" "LUA5.1" "LUA5.2" "LUA5.3")
    31 
    32 
    32 ## Gather information about system
    33 ## Gather information about system
    33 find_package(PkgConfig REQUIRED)
    34 find_package(PkgConfig REQUIRED)
    34 if(NOT WANT_LUA52)
    35 if(WANT_LUA STREQUAL "LUA5.3")
    35 	find_package(Lua51)
    36 	find_package(Lua 5.3 EXACT REQUIRED)
       
    37 elseif(WANT_LUA STREQUAL "LUA5.2")
       
    38 	find_package(Lua 5.2 EXACT REQUIRED)
       
    39 elseif(WANT_LUA STREQUAL "LUA5.1")
       
    40 	find_package(Lua 5.1 EXACT REQUIRED)
       
    41 else()
       
    42 	find_package(Lua 5.1 REQUIRED)
    36 endif()
    43 endif()
    37 if(WANT_LUA52 OR NOT LUA51_FOUND)
    44 set(LUA_VERSION "${LUA_VERSION_MAJOR}.${LUA_VERSION_MINOR}")
    38 	pkg_check_modules(LUA REQUIRED lua5.2)
    45 set(LUA_MODULENAME "lua${LUA_VERSION_MAJOR}${LUA_VERSION_MINOR}")
    39 	set(LUA_VERSION "5.2")
    46 if(LUA_VERSION VERSION_EQUAL "5.1")
    40 	set(HAVE_LUA52  "1")
    47 	set(LUA51_COMPATIBILITY TRUE)
    41 else()
       
    42 	set(LUA_VERSION "5.1")
       
    43 	set(LUA_INCLUDE_DIRS ${LUA_INCLUDE_DIR})
       
    44 endif()
    48 endif()
    45 string(REPLACE "." "" LUA_MODULENAME "lua${LUA_VERSION}")
       
    46 pkg_check_modules(GLIB REQUIRED glib-2.0)
    49 pkg_check_modules(GLIB REQUIRED glib-2.0)
    47 pkg_check_modules(GMODULE REQUIRED gmodule-2.0)
    50 pkg_check_modules(GMODULE REQUIRED gmodule-2.0)
    48 pkg_check_modules(MCABBER REQUIRED mcabber)
    51 pkg_check_modules(MCABBER REQUIRED mcabber)
    49 find_program(DOCGEN_EXECUTABLE NAMES docgen.pl docgen DOC "Docgen documentation generator script (optional)")
    52 find_program(DOCGEN_EXECUTABLE NAMES docgen.pl docgen DOC "Docgen documentation generator script (optional)")
    50 include(CheckCSourceCompiles)
    53 include(CheckCSourceCompiles)
    68 add_library(lua MODULE lua.c util.c)
    71 add_library(lua MODULE lua.c util.c)
    69 get_target_property(lua_SOURCES lua SOURCES)
    72 get_target_property(lua_SOURCES lua SOURCES)
    70 
    73 
    71 ## Set up compiler
    74 ## Set up compiler
    72 configure_file(config.h.in config.h ESCAPE_QUOTES)
    75 configure_file(config.h.in config.h ESCAPE_QUOTES)
    73 include_directories(SYSTEM ${LUA_INCLUDE_DIRS}
    76 include_directories(SYSTEM ${LUA_INCLUDE_DIR}
    74 					${GLIB_INCLUDE_DIRS}
    77 					${GLIB_INCLUDE_DIRS}
    75 					${GMODULE_INCLUDE_DIRS}
    78 					${GMODULE_INCLUDE_DIRS}
    76 					${MCABBER_INCLUDE_DIRS})
    79 					${MCABBER_INCLUDE_DIRS})
    77 target_link_libraries(lua ${LUA_LIBRARIES}
    80 target_link_libraries(lua ${LUA_LIBRARIES}
    78 					  ${GLIB_LIBRARIES}
    81 					  ${GLIB_LIBRARIES}
    79 					  ${GMODULE_LIBRARIES}
    82 					  ${GMODULE_LIBRARIES}
    80 					  ${MCABBER_LIBRARRIES})
    83 					  ${MCABBER_LIBRARRIES})
    81 include_directories(${lua_SOURCE_DIR}
    84 include_directories(${lua_SOURCE_DIR}
    82 					${lua_BINARY_DIR})
    85 					${lua_BINARY_DIR})
    83 set_target_properties(lua PROPERTIES COMPILE_FLAGS "-Wall" OUTPUT_NAME "${LUA_MODULENAME}")
    86 set_target_properties(lua PROPERTIES
       
    87                       COMPILE_FLAGS "-Wall"
       
    88 					  OUTPUT_NAME "${LUA_MODULENAME}")
    84 
    89 
    85 ## Extra targets
    90 ## Extra targets
    86 if(DOCGEN_EXECUTABLE)
    91 if(DOCGEN_EXECUTABLE)
    87 	add_custom_command(OUTPUT ${lua_BINARY_DIR}/lua.html      COMMAND ${DOCGEN_EXECUTABLE} -f html -t "Documentation for Lua module for MCabber" -o ${lua_BINARY_DIR}/lua.html      -- ${lua_SOURCES} DEPENDS ${DOCGEN_EXECUTABLE} ${lua_SOURCES} WORKING_DIRECTORY ${lua_SOURCE_DIR})
    92 	add_custom_command(OUTPUT ${lua_BINARY_DIR}/lua.html      COMMAND ${DOCGEN_EXECUTABLE} -f html -t "Documentation for Lua module for MCabber" -o ${lua_BINARY_DIR}/lua.html      -- ${lua_SOURCES} DEPENDS ${DOCGEN_EXECUTABLE} ${lua_SOURCES} WORKING_DIRECTORY ${lua_SOURCE_DIR})
    88 	add_custom_target(doc    ALL DEPENDS ${lua_BINARY_DIR}/lua.html)
    93 	add_custom_target(doc    ALL DEPENDS ${lua_BINARY_DIR}/lua.html)
   130 if(DOCGEN_EXECUTABLE)
   135 if(DOCGEN_EXECUTABLE)
   131 	install(FILES ${lua_BINARY_DIR}/lua.html    DESTINATION share/doc/${CPACK_PACKAGE_NAME})
   136 	install(FILES ${lua_BINARY_DIR}/lua.html    DESTINATION share/doc/${CPACK_PACKAGE_NAME})
   132 endif()
   137 endif()
   133 install(DIRECTORY examples                      DESTINATION share/doc/${CPACK_PACKAGE_NAME} PATTERN "*~" EXCLUDE)
   138 install(DIRECTORY examples                      DESTINATION share/doc/${CPACK_PACKAGE_NAME} PATTERN "*~" EXCLUDE)
   134 install(FILES     docs/readme.mdwn docs/todo.mdwn COPYING DESTINATION share/doc/${CPACK_PACKAGE_NAME})
   139 install(FILES     docs/readme.mdwn docs/todo.mdwn COPYING DESTINATION share/doc/${CPACK_PACKAGE_NAME})
   135 install(FILES     help/en/hlp_lua.txt           DESTINATION share/mcabber RENAME hlp_lua${LUA_VERSION}.txt) # XXX localizations/other help
   140 install(FILES     help/en/hlp_lua.txt           DESTINATION share/mcabber RENAME hlp_lua${LUA_MODULENAME}.txt) # XXX localizations/other help
   136 install(FILES     ${PROJECT_BINARY_DIR}/${LUA_MODULENAME}.avv DESTINATION share/mcabber/avv/modules RENAME ${LUA_MODULENAME})
   141 install(FILES     ${PROJECT_BINARY_DIR}/${LUA_MODULENAME}.avv DESTINATION share/mcabber/avv/modules RENAME ${LUA_MODULENAME})
   137 
   142 
   138 ## The End ## vim: se ts=4 sw=4: ##
   143 ## The End ## vim: se ts=4 sw=4: ##