-
Notifications
You must be signed in to change notification settings - Fork 45
/
CMakeLists.txt
50 lines (47 loc) · 1.75 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
set(LUA_VERSION "lua" CACHE STRING "lua version")
if(NOT EXISTS "${CMAKE_CURRENT_SOURCE_DIR}/thirdparty/lua5.4/lua.h")
find_package(PkgConfig)
if(PkgConfig_FOUND)
foreach(pkg ${LUA_VERSION} lua54 lua53 lua52 luajit lua51)
pkg_check_modules(LUA IMPORTED_TARGET GLOBAL ${pkg})
if(LUA_FOUND)
break()
endif()
endforeach()
endif()
if(LUA_FOUND)
set(LUA_TARGET PkgConfig::LUA)
include_directories(${LUA_INCLUDE_DIRS})
else()
message(FATAL_ERROR "Lua not found, consider using `bash action-install.sh` to download.")
endif()
else()
message(STATUS "Using in-tree lua source")
include_directories(thirdparty/lua5.4)
aux_source_directory(thirdparty/lua5.4 LUA_SRC)
add_definitions(-DLUA_COMPAT_5_3)
if(WIN32)
set_property(SOURCE ${LUA_SRC} PROPERTY COMPILE_DEFINITIONS LUA_BUILD_AS_DLL)
else()
set_property(SOURCE ${LUA_SRC} PROPERTY COMPILE_DEFINITIONS LUA_USE_POSIX;LUA_USE_DLOPEN)
execute_process(
COMMAND ${CMAKE_C_COMPILER} -print-multiarch
OUTPUT_VARIABLE multiarch
ERROR_QUIET)
if(multiarch)
string(REGEX REPLACE "[\r\n]" "" multiarch ${multiarch})
add_definitions(-DLUA_MULTIARCH=\"${multiarch}\")
message(STATUS "with multiarch: ${multiarch}")
endif()
endif()
endif()
aux_source_directory(src RIME_LUA_SRC)
aux_source_directory(src/lib RIME_LUA_LIB_SRC)
add_library(rime-lua-objs OBJECT ${RIME_LUA_SRC} ${RIME_LUA_LIB_SRC} ${LUA_SRC})
if(BUILD_SHARED_LIBS)
set_target_properties(rime-lua-objs PROPERTIES POSITION_INDEPENDENT_CODE ON)
endif()
set(plugin_name "rime-lua" PARENT_SCOPE)
set(plugin_objs $<TARGET_OBJECTS:rime-lua-objs> PARENT_SCOPE)
set(plugin_deps ${LUA_TARGET} ${rime_library} ${rime_gears_library} PARENT_SCOPE)
set(plugin_modules "lua" PARENT_SCOPE)