1 set(OBJECTS $<TARGET_OBJECTS:a>)
4 include(${CMAKE_CURRENT_LIST_DIR}/lua.cmake)
5 add_subdirectory(${LUA_SOURCE_DIR} ${LUA_BINARY_DIR})
6 option(LUA_ISOCLINE "Enable/Disable isocline in Lua" 1)
8 if(EXISTS ${CMAKE_CURRENT_LIST_DIR}/isocline/src/isocline.c AND LUA_ISOCLINE)
9 file(RELATIVE_PATH LUA_READLINE_C ${LUA_SOURCE_DIR}/src ${CMAKE_CURRENT_LIST_DIR}/isocline.c)
10 target_compile_definitions(lua PRIVATE LUA_READLINE_C="${LUA_READLINE_C}")
13 set(LUA_LIBRARIES lualib)
14 set(LUA_EXECUTABLE ${CMAKE_CROSSCOMPILING_EMULATOR} $<TARGET_FILE:lua>)
15 string(REGEX MATCHALL "[0-9]+" VERSION "${LUA_VERSION}.0.0")
16 list(GET VERSION 0 LUA_VERSION_MAJOR)
17 list(GET VERSION 1 LUA_VERSION_MINOR)
20 target_compile_sanitize(PUBLIC liblua lualib lua.o)
21 target_link_sanitize(PUBLIC liblua lualib lua luac)
22 set(OBJECTS $<TARGET_OBJECTS:asan>)
27 file_scaner(SOURCES RECURSE src EXT c h cc hh cpp hpp)
29 file_scaner(SOURCES RECURSE src EXT c h)
32 set(CMAKE_SHARED_MODULE_PREFIX "")
33 add_library(alua MODULE ${OBJECTS} ${SOURCES})
34 set_target_properties(alua PROPERTIES DEFINE_SYMBOL A_EXPORTS OUTPUT_NAME ${PROJECT_NAME})
35 target_link_libraries(alua PRIVATE ${LUA_LIBRARIES})
36 add_library_properties(alua PRIVATE alib)
37 set_library_options(alua)
39 if("${LIBA_INSTALL}" MATCHES "^[Ll]ua$")
41 ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR}
42 LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}
43 RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}
47 ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR}/lua/${LUA_VERSION_MAJOR}.${LUA_VERSION_MINOR}
48 LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}/lua/${LUA_VERSION_MAJOR}.${LUA_VERSION_MINOR}
49 RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}/lua/${LUA_VERSION_MAJOR}.${LUA_VERSION_MINOR}
53 if(PROJECT_IS_TOP_LEVEL AND BUILD_TESTING)
54 file(GLOB_RECURSE SOURCES test/*.lua)
60 add_stylua(afmt.lua VERBOSE ${ARGN})
61 add_dependencies(afmt afmt.lua)
65 find_package(LuaFormat)
68 add_lua_format(afmt.lua VERBOSE ${ARGN})
69 add_dependencies(afmt afmt.lua)
74 find_format(WORKING_DIRECTORY ${PROJECT_SOURCE_DIR} ${SOURCES})
77 option(LIBA_LDOC "Enable/Disable ffi ldoc" 0)
83 if(LIBA_LDOC AND LDOC_FOUND)
84 file(GENERATE OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/LDoc
85 CONTENT "project = '${PROJECT_NAME}'
86 description = '${PROJECT_DESCRIPTION}'
89 create_ldoc(adoc.lua CONFIG ${CMAKE_CURRENT_BINARY_DIR}/LDoc
90 OPTIONS --not_luadoc ${CMAKE_CURRENT_SOURCE_DIR}/src
92 add_dependencies(adoc adoc.lua)
95 if(EXISTS ${CMAKE_CURRENT_LIST_DIR}/test/CMakeLists.txt AND LUA_EXECUTABLE)
96 get_property(IS_MULTI_CONFIG GLOBAL PROPERTY GENERATOR_IS_MULTI_CONFIG)
98 if(NOT CMAKE_VERSION VERSION_LESS 3.0)
99 set(WORKING_DIRECTORY $<TARGET_FILE_DIR:alua>)
100 elseif(IS_MULTI_CONFIG)
101 set(WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/$<CONFIG>)
103 set(WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR})
106 add_subdirectory(test)