- 根目录
cmake_minimum_required(VERSION 3.5)
project(lua)
add_subdirectory(src) set(EXECUTABLE_OUTPUT_PATH ${PROJECT_BINARY_DIR}/build/bin) include_directories(src) set(interpreter lua.c) set(luacomplier luac.c) #虽然对生成的lib进行了重新命名,但还是可以使用去最初的名字 add_executable(luai ${interpreter}) target_link_libraries(luai luastatic) add_executable(luac ${luacomplier}) target_link_libraries(luac luastatic)
- src/
set(LIBRARY_OUTPUT_PATH ${PROJECT_BINARY_DIR}/build/lib)
aux_source_directory(. tobelib) add_library(luastatic STATIC ${tobelib})
set_target_properties(luastatic PROPERTIES OUTPUT_NAME "lua")
- 编译后的文件如何使用:
bin:lua luac
include:lua.h luaconf.h lualib.h lauxlib.h lua.hpp
lib:liblua.a
man/man1:lua.1 luac.1
在工程里使用的时候,只需要include和lib就可以。
- 工程编译组织:
library:
lapi.c lcode.c lctype.c ldebug.c ldo.c ldump.c lfunc.c lgc.c llex.c lmem.c lobject.c lopcodes.c lparser.c lstate.c lstring.c ltable.c ltm.c lundump.c lvm.c lzio.c lauxlib.c lbaselib.c lbitlib.c lcorolib.c ldblib.c liolib.c lmathlib.c loslib.c lstrlib.c ltablib.c lutf8lib.c loadlib.c linit.c
interpreter:library, lua.c
compiler:library, luac.c