1 set(OBJECTS $<TARGET_OBJECTS:a>)
4 set(CMAKE_SHARED_MODULE_PREFIX lib)
8 include(${CMAKE_CURRENT_LIST_DIR}/lua.cmake)
9 option(LUA_ISOCLINE "Enable/Disable isocline in Lua" 1)
12 file(RELATIVE_PATH LUA_READLINE_C ${LUA_ARCHIVE_DIR}/src ${CMAKE_CURRENT_LIST_DIR}/isocline.c)
13 target_compile_definitions(lua PRIVATE LUA_READLINE_C="${LUA_READLINE_C}")
16 set(LUA_LIBRARIES lualib)
17 set(LUA_EXECUTABLE ${CMAKE_CROSSCOMPILING_EMULATOR} $<TARGET_FILE:lua>)
18 string(REGEX REPLACE "^([0-9]).*" "\\1" LUA_VERSION_MAJOR "${LUA_VERSION}")
19 string(REGEX REPLACE "^[0-9]+\\.([0-9]).*" "\\1" LUA_VERSION_MINOR "${LUA_VERSION}")
22 target_compile_sanitize(PUBLIC liblua lualib lua.o)
23 target_link_sanitize(PUBLIC liblua lualib)
24 set(OBJECTS $<TARGET_OBJECTS:asan>)
29 file_scaner(SOURCES RECURSE src EXT c h cc hh cpp hpp)
31 file_scaner(SOURCES RECURSE src EXT c h)
34 add_library(alua MODULE ${OBJECTS} ${SOURCES})
35 set_target_properties(alua PROPERTIES DEFINE_SYMBOL A_EXPORTS OUTPUT_NAME a)
36 target_link_libraries(alua PRIVATE ${LUA_LIBRARIES})
37 add_library_properties(alua PRIVATE alib)
38 set_library_options(alua)
40 if(LIBA_INSTALL MATCHES "[Ll]ua")
42 ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR}
43 LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}
44 RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}
48 ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR}/lua/${LUA_VERSION_MAJOR}.${LUA_VERSION_MINOR}
49 LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}/lua/${LUA_VERSION_MAJOR}.${LUA_VERSION_MINOR}
50 RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}/lua/${LUA_VERSION_MAJOR}.${LUA_VERSION_MINOR}
54 if(PROJECT_IS_TOP_LEVEL)
55 file(GLOB_RECURSE SOURCES test/*.lua)
61 add_stylua(astylua VERBOSE ${ARGN})
62 add_dependencies(afmt astylua)
66 find_package(LuaFormat)
69 add_lua_format(aluaformat VERBOSE ${ARGN})
70 add_dependencies(afmt aluaformat)
75 find_format(WORKING_DIRECTORY ${PROJECT_SOURCE_DIR} ${SOURCES})
78 option(LIBA_LDOC "Enable/Disable ffi ldoc" 0)
84 if(LIBA_LDOC AND LDOC_FOUND)
85 file(GENERATE OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/LDoc
86 CONTENT "project = '${PROJECT_NAME}'
87 description = '${PROJECT_DESCRIPTION}'
90 create_ldoc(aldoc CONFIG ${CMAKE_CURRENT_BINARY_DIR}/LDoc
91 OPTIONS --not_luadoc ${CMAKE_CURRENT_SOURCE_DIR}/src
93 add_dependencies(adoc aldoc)
96 if(EXISTS ${CMAKE_CURRENT_LIST_DIR}/test/CMakeLists.txt AND LUA_EXECUTABLE)
97 get_property(IS_MULTI_CONFIG GLOBAL PROPERTY GENERATOR_IS_MULTI_CONFIG)
99 if(NOT CMAKE_VERSION VERSION_LESS 3.0)
100 set(WORKING_DIRECTORY $<TARGET_FILE_DIR:alua>)
101 elseif(IS_MULTI_CONFIG)
102 set(WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/$<CONFIG>)
104 set(WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR})
107 add_subdirectory(test)