十万个为什么 [cmake]] cmake二三事
# if else
if (条件)
# 做一些事
elseif(条件)
# 做一些事
endif()
# 判断是否Release编译类型
if (CMAKE_BUILD_TYPE STREQUAL "Release")
endif()
# 头文件目录
include_directories(
# 各种目录
)
# 要编译的目标的源文件
add_executable(${PROJECT_NAME}
# 各个源文件
)
cmake_minimum_required(VERSION 3.5.0)
project (lua VERSION 0.0.1)
set(CMAKE_C_FLAGS "-Wall -O2 -std=gnu11 -m32")
set(CMAKE_CXX_FLAGS "-Wall -O2 -std=gnu++11 -m32")
include_directories(
)
add_library(lua5.5 SHARED
lapi.c
lauxlib.c
lbaselib.c
lcode.c
lcorolib.c
lctype.c
ldblib.c
ldebug.c
ldo.c
ldump.c
lfunc.c
lgc.c
linit.c
liolib.c
llex.c
lmathlib.c
lmem.c
loadlib.c
lobject.c
lopcodes.c
loslib.c
lparser.c
lstate.c
lstring.c
lstrlib.c
ltable.c
ltablib.c
ltests.c
ltm.c
lundump.c
lutf8lib.c
lvm.c
lzio.c
)
link_directories(${PROJECT_NAME}
build
)
add_executable(${PROJECT_NAME}
lua.c
)
target_link_libraries(${PROJECT_NAME}
lua5.5
)
add_custom_command(TARGET ${PROJECT_NAME} POST_BUILD
COMMAND strip liblua5.5.dll
COMMAND strip "$<TARGET_FILE:${PROJECT_NAME}>"
)