-
Notifications
You must be signed in to change notification settings - Fork 8
/
Copy pathCMakeLists.txt
77 lines (65 loc) · 2.55 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
69
70
71
72
73
74
75
76
77
cmake_minimum_required(VERSION 3.10)
project(fcitx5-lua VERSION 5.0.13)
find_package(ECM REQUIRED 1.0.0)
set(CMAKE_MODULE_PATH ${ECM_MODULE_PATH} "${CMAKE_CURRENT_SOURCE_DIR}/cmake" ${CMAKE_MODULE_PATH})
include(FeatureSummary)
include(GNUInstallDirs)
include(ECMSetupVersion)
include(ECMUninstallTarget)
find_package(Lua 5.3 REQUIRED)
find_package(Fcitx5Core 5.1.12 REQUIRED)
find_package(Gettext REQUIRED)
find_package(Pthread REQUIRED)
find_package(Fcitx5Module REQUIRED COMPONENTS QuickPhrase)
option(USE_DLOPEN "Use dlopen to load lua library." On)
option(ENABLE_TEST "Build Test" On)
include("${FCITX_INSTALL_CMAKECONFIG_DIR}/Fcitx5Utils/Fcitx5CompilerSettings.cmake")
if (NOT TARGET Lua::_LuaLibrary)
if (USE_DLOPEN)
add_library(Lua::_LuaLibrary IMPORTED INTERFACE)
set_target_properties(Lua::_LuaLibrary PROPERTIES
INTERFACE_INCLUDE_DIRECTORIES ${LUA_INCLUDE_DIR})
else()
add_library(Lua::_LuaLibrary UNKNOWN IMPORTED ${LUA_LIBRARY})
set_target_properties(Lua::_LuaLibrary PROPERTIES
INTERFACE_INCLUDE_DIRECTORIES ${LUA_INCLUDE_DIR}
IMPORTED_LOCATION ${LUA_LIBRARY})
endif()
endif()
function(_RESOLVE_LIBRARY_PATH _FILE_NAME _LIBRARY_PATH)
if (CMAKE_OBJDUMP)
execute_process (
COMMAND ${CMAKE_OBJDUMP} -p "${_LIBRARY_PATH}"
RESULT_VARIABLE STATUS
OUTPUT_VARIABLE OBJDUMP_RESULT
ERROR_QUIET
)
string(REGEX REPLACE ".*SONAME +([^ ]+)\n.*$" "\\1" SONAME_OUT "${OBJDUMP_RESULT}")
if (SONAME_OUT)
set(_FILE_NAME_OUT "${SONAME_OUT}")
endif ()
endif()
if (NOT _FILE_NAME_OUT)
get_filename_component(_FILE_NAME_OUT "${_LIBRARY_PATH}" NAME)
endif()
set(${_FILE_NAME} ${_FILE_NAME_OUT} PARENT_SCOPE)
endfunction()
if(USE_DLOPEN)
_RESOLVE_LIBRARY_PATH(LUA_LIBRARY_PATH ${LUA_LIBRARY})
endif()
configure_file(config.h.in config.h)
include_directories(${CMAKE_CURRENT_BINARY_DIR})
add_definitions(-DFCITX_GETTEXT_DOMAIN=\"fcitx5-lua\")
fcitx5_add_i18n_definition()
add_subdirectory(src)
add_subdirectory(po)
if (ENABLE_TEST)
find_package(Fcitx5ModuleTestFrontend REQUIRED)
find_package(Fcitx5ModuleTestIM REQUIRED)
enable_testing()
add_subdirectory(test)
endif()
fcitx5_translate_desktop_file(org.fcitx.Fcitx5.Addon.Lua.metainfo.xml.in
org.fcitx.Fcitx5.Addon.Lua.metainfo.xml XML)
install(FILES "${CMAKE_CURRENT_BINARY_DIR}/org.fcitx.Fcitx5.Addon.Lua.metainfo.xml" DESTINATION ${CMAKE_INSTALL_DATADIR}/metainfo)
feature_summary(WHAT ALL FATAL_ON_MISSING_REQUIRED_PACKAGES)