forked from kmarkus/lsdbus
-
Notifications
You must be signed in to change notification settings - Fork 0
/
CMakeLists.txt
68 lines (54 loc) · 2.11 KB
/
CMakeLists.txt
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
cmake_minimum_required(VERSION 3.20)
project(sdbus-lua VERSION 0.0.1 LANGUAGES C)
set(CMAKE_C_STANDARD 11)
include(GNUInstallDirs)
find_package(PkgConfig REQUIRED)
pkg_check_modules(SYSTEMD REQUIRED libsystemd>=242)
pkg_check_modules(MXML REQUIRED mxml)
set(CONFIG_LUA_VER "" CACHE STRING "build for exact Lua version")
if(NOT "${CONFIG_LUA_VER}" STREQUAL "")
pkg_search_module(LUA "lua${CONFIG_LUA_VER}" REQUIRED)
else()
pkg_search_module(LUA lua5.4 lua5.3 luajit lua5.2 lua5.1 lua REQUIRED)
endif()
if ("${LUA_MODULE_NAME}" STREQUAL "luajit")
pkg_get_variable(LUA_VER ${LUA_MODULE_NAME} abiver)
else()
# remove minor version (meta-oe pc file has no major_version)
pkg_get_variable(LUA_VER ${LUA_MODULE_NAME} version)
string(REGEX MATCH "^([0-9]+\\.[0-9]+)" LUA_VER ${LUA_VERSION})
endif()
message(STATUS "Found ${LUA_MODULE_NAME} (${LUA_VER})")
if( "${LUA_VER}" STREQUAL "5.1" OR "${LUA_VER}" STREQUAL "5.2" )
find_file(COMPAT53 compat-5.3.h PATH_SUFFIXES "lua${LUA_VER}")
if(NOT COMPAT53)
message(FATAL_ERROR "failed to find compat-5.3.h for lua${LUA_VER}, please install lua-compat53-dev")
else()
message(STATUS "lua-compat53 found")
endif()
cmake_path(GET COMPAT53 PARENT_PATH COMPAT53_DIR)
endif()
set(LSDBUS_SRCS src/lsdbus.c src/message.c src/introspect.c src/evl.c src/vtab.c)
set(LSDBUS_INST_DIR
${CMAKE_INSTALL_PREFIX}/lib/lua/${LUA_VER}/lsdbus/)
add_library(core SHARED ${LSDBUS_SRCS})
target_compile_options(core PRIVATE -Wall -Wextra)
target_compile_definitions(core PRIVATE LIBSYSTEMD_VERSION=${SYSTEMD_VERSION})
target_include_directories(core PRIVATE ${LUA_INCLUDE_DIRS} ${COMPAT53_DIR})
target_link_libraries(core ${SYSTEMD_LIBRARIES} ${MXML_LIBRARIES} )
set_target_properties(core PROPERTIES PREFIX "")
install(TARGETS core LIBRARY DESTINATION ${LSDBUS_INST_DIR})
install(FILES
src/lsdbus/init.lua
src/lsdbus/proxy.lua
src/lsdbus/server.lua
src/lsdbus/common.lua
src/lsdbus/error.lua
DESTINATION ${CMAKE_INSTALL_PREFIX}/share/lua/${LUA_VER}/lsdbus/
)
install(PROGRAMS
tools/lsdb-mon
tools/lsdb-call
tools/lsdb-emit
tools/lsdb-info
DESTINATION ${CMAKE_INSTALL_BINDIR})