1 Star 0 Fork 0

彭辅军/lua

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
克隆/下载
CMakeLists.txt 8.88 KB
一键复制 编辑 原始数据 按行查看 历史
# Copyright (C) 2007-2011 LuaDist.
# Created by Peter Drahoš, Peter Kapec
# Redistribution and use of this file is allowed according to the terms of the MIT license.
# For details see the COPYRIGHT file distributed with LuaDist.
# Please note that the package source code is licensed under its own license.
# Changed by Vinicius Jarina (viniciusjarina@gmail.com)
PROJECT ( lua CXX )
CMAKE_MINIMUM_REQUIRED ( VERSION 2.8.7 )
IF (CMAKE_SIZEOF_VOID_P EQUAL 8)
SET (LIB_SUFFIX "64" CACHE STRING "Suffix of the directory name, e.g. 64 for lib64")
ELSE (CMAKE_SIZEOF_VOID_P EQUAL 8)
SET (LIB_SUFFIX "" CACHE STRING "Suffix of the directory name, e.g. 64 for lib64")
ENDIF (CMAKE_SIZEOF_VOID_P EQUAL 8)
SET(CMAKE_DEBUG_POSTFIX "d")
SET(LIBRARY_OUTPUT_PATH "${CMAKE_BINARY_DIR}/lib${LIB_SUFFIX}")
SET(CMAKE_LIBRARY_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/lib${LIB_SUFFIX}" CACHE STRING "Library build output directory")
SET(CMAKE_ARCHIVE_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/lib${LIB_SUFFIX}")
SET(CMAKE_RUNTIME_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/bin${LIB_SUFFIX}")
SET(EXECUTABLE_OUTPUT_PATH "${CMAKE_BINARY_DIR}/bin${LIB_SUFFIX}")
SET (LIB_LUA_VER "51" CACHE STRING "Suffix of version (for library name) e.g lua51")
#
# Include dir COPY
# If the source dir and the binary dir are not equals,
# copy the content of lua/inlude to $/include
#
IF(NOT ${PROJECT_SOURCE_DIR} STREQUAL ${PROJECT_BINARY_DIR})
SET(TEMP_INCLUDE_LUA_DIR_FROM "${PROJECT_SOURCE_DIR}/include")
SET(TEMP_INCLUDE_LUA_DIR_TO "${PROJECT_BINARY_DIR}")
MESSAGE(STATUS "Copying include dirs from ${TEMP_INCLUDE_LUA_DIR_FROM} to ${TEMP_INCLUDE_LUA_DIR_TO}")
FILE ( COPY ${TEMP_INCLUDE_LUA_DIR_FROM} DESTINATION ${TEMP_INCLUDE_LUA_DIR_TO})
ENDIF()
IF ( WIN32 AND NOT CYGWIN )
# Windows systems
OPTION ( LUA_WIN "Windows specific build." ON )
OPTION ( LUA_BUILD_AS_DLL "Build Lua library as Dll." ON )
ELSE ()
# Posix systems (incl. Cygwin)
OPTION ( LUA_USE_POSIX "Use POSIX functionality." ON )
OPTION ( LUA_USE_DLOPEN "Use dynamic linker to load modules." ON )
ENDIF ()
IF ( LUA_USE_POSIX )
# On POSIX Lua links to standard math library "m"
LIST ( APPEND LIBS m )
ENDIF ()
IF ( LUA_USE_DLOPEN )
# Link to dynamic linker library "dl"
LIST ( APPEND LIBS dl )
ENDIF ()
IF ( LUA_WIN )
# Add extra rc files to the windows build
IF ( MSVC OR MINGW )
SET ( LUA_DLL_RC src/lua_dll.rc )
SET ( LUA_RC src/lua.rc )
SET ( LUAC_RC src/luac.rc )
ENDIF ()
ENDIF ()
# Sources and headers
INCLUDE_DIRECTORIES ( include )
SET ( SRC_LIB
src/lapi.cpp
src/lauxlib.cpp
src/lbaselib.cpp
src/lcode.cpp
src/ldblib.cpp
src/ldebug.cpp
src/ldo.cpp
src/ldump.cpp
src/lfunc.cpp
src/lgc.cpp
src/linit.cpp
src/liolib.cpp
src/llex.cpp
src/lmathlib.cpp
src/lmem.cpp
src/loadlib.cpp
src/lobject.cpp
src/lopcodes.cpp
src/loslib.cpp
src/lparser.cpp
src/lstate.cpp
src/lstring.cpp
src/lstrlib.cpp
src/ltable.cpp
src/ltablib.cpp
src/ltm.cpp
src/lundump.cpp
src/lvm.cpp
src/lzio.cpp
src/print.cpp
src/lnet.cpp
)
SET ( SRC_LUA src/lua.cpp )
SET ( SRC_LUAC src/luac.cpp )
## BUILD
# Create dynamic library (dll, so)
ADD_LIBRARY ( liblua SHARED ${SRC_LIB} ${LUA_DLL_RC})
TARGET_LINK_LIBRARIES ( liblua ${LIBS} )
SET_TARGET_PROPERTIES ( liblua PROPERTIES OUTPUT_NAME lua${LIB_LUA_VER} CLEAN_DIRECT_OUTPUT 1 )
if ( LUA_WIN )
SET_TARGET_PROPERTIES ( liblua PROPERTIES COMPILE_FLAGS -DLUA_BUILD_AS_DLL)
endif ( LUA_WIN )
SET_TARGET_PROPERTIES( liblua PROPERTIES ARCHIVE_OUTPUT_DIRECTORY_MINSIZEREL ${PROJECT_BINARY_DIR}/lib${LIB_SUFFIX} )
SET_TARGET_PROPERTIES( liblua PROPERTIES LIBRARY_OUTPUT_DIRECTORY_MINSIZEREL ${PROJECT_BINARY_DIR}/lib${LIB_SUFFIX} )
SET_TARGET_PROPERTIES( liblua PROPERTIES RUNTIME_OUTPUT_DIRECTORY_MINSIZEREL ${PROJECT_BINARY_DIR}/bin${LIB_SUFFIX} )
SET_TARGET_PROPERTIES( liblua PROPERTIES ARCHIVE_OUTPUT_DIRECTORY_RELEASE ${PROJECT_BINARY_DIR}/lib${LIB_SUFFIX} )
SET_TARGET_PROPERTIES( liblua PROPERTIES LIBRARY_OUTPUT_DIRECTORY_RELEASE ${PROJECT_BINARY_DIR}/lib${LIB_SUFFIX} )
SET_TARGET_PROPERTIES( liblua PROPERTIES RUNTIME_OUTPUT_DIRECTORY_RELEASE ${PROJECT_BINARY_DIR}/bin${LIB_SUFFIX} )
SET_TARGET_PROPERTIES( liblua PROPERTIES ARCHIVE_OUTPUT_DIRECTORY_RELWITHDEBINFO ${PROJECT_BINARY_DIR}/lib${LIB_SUFFIX} )
SET_TARGET_PROPERTIES( liblua PROPERTIES LIBRARY_OUTPUT_DIRECTORY_RELWITHDEBINFO ${PROJECT_BINARY_DIR}/lib${LIB_SUFFIX} )
SET_TARGET_PROPERTIES( liblua PROPERTIES RUNTIME_OUTPUT_DIRECTORY_RELWITHDEBINFO ${PROJECT_BINARY_DIR}/bin${LIB_SUFFIX} )
SET_TARGET_PROPERTIES( liblua PROPERTIES ARCHIVE_OUTPUT_DIRECTORY_DEBUG ${PROJECT_BINARY_DIR}/lib${LIB_SUFFIX} )
SET_TARGET_PROPERTIES( liblua PROPERTIES LIBRARY_OUTPUT_DIRECTORY_DEBUG ${PROJECT_BINARY_DIR}/lib${LIB_SUFFIX} )
SET_TARGET_PROPERTIES( liblua PROPERTIES RUNTIME_OUTPUT_DIRECTORY_DEBUG ${PROJECT_BINARY_DIR}/bin${LIB_SUFFIX} )
# Create static library, this is needed to compile luac in the 5.1.x, 5.2 Lua series
ADD_LIBRARY ( liblua_static STATIC ${SRC_LIB} )
TARGET_LINK_LIBRARIES ( liblua_static ${LIBS} )
SET_TARGET_PROPERTIES ( liblua_static PROPERTIES OUTPUT_NAME lua${LIB_LUA_VER}_static CLEAN_DIRECT_OUTPUT 1 )
SET_TARGET_PROPERTIES( liblua_static PROPERTIES ARCHIVE_OUTPUT_DIRECTORY_MINSIZEREL ${PROJECT_BINARY_DIR}/lib${LIB_SUFFIX} )
SET_TARGET_PROPERTIES( liblua_static PROPERTIES LIBRARY_OUTPUT_DIRECTORY_MINSIZEREL ${PROJECT_BINARY_DIR}/lib${LIB_SUFFIX} )
SET_TARGET_PROPERTIES( liblua_static PROPERTIES ARCHIVE_OUTPUT_DIRECTORY_RELEASE ${PROJECT_BINARY_DIR}/lib${LIB_SUFFIX} )
SET_TARGET_PROPERTIES( liblua_static PROPERTIES LIBRARY_OUTPUT_DIRECTORY_RELEASE ${PROJECT_BINARY_DIR}/lib${LIB_SUFFIX} )
SET_TARGET_PROPERTIES( liblua_static PROPERTIES ARCHIVE_OUTPUT_DIRECTORY_RELWITHDEBINFO ${PROJECT_BINARY_DIR}/lib${LIB_SUFFIX} )
SET_TARGET_PROPERTIES( liblua_static PROPERTIES LIBRARY_OUTPUT_DIRECTORY_RELWITHDEBINFO ${PROJECT_BINARY_DIR}/lib${LIB_SUFFIX} )
SET_TARGET_PROPERTIES( liblua_static PROPERTIES ARCHIVE_OUTPUT_DIRECTORY_DEBUG ${PROJECT_BINARY_DIR}/lib${LIB_SUFFIX} )
SET_TARGET_PROPERTIES( liblua_static PROPERTIES LIBRARY_OUTPUT_DIRECTORY_DEBUG ${PROJECT_BINARY_DIR}/lib${LIB_SUFFIX} )
ADD_EXECUTABLE ( lua ${SRC_LUA} ${LUA_RC})
TARGET_LINK_LIBRARIES ( lua liblua )
SET_TARGET_PROPERTIES ( lua PROPERTIES DEBUG_POSTFIX d)
SET_TARGET_PROPERTIES ( lua PROPERTIES RUNTIME_OUTPUT_DIRECTORY_DEBUG ${PROJECT_BINARY_DIR}/bin )
SET_TARGET_PROPERTIES ( lua PROPERTIES RUNTIME_OUTPUT_DIRECTORY_RELWITHDEBINFO ${PROJECT_BINARY_DIR}/bin${LIB_SUFFIX} )
SET_TARGET_PROPERTIES ( lua PROPERTIES RUNTIME_OUTPUT_DIRECTORY_RELEASE ${PROJECT_BINARY_DIR}/bin${LIB_SUFFIX} )
SET_TARGET_PROPERTIES ( lua PROPERTIES RUNTIME_OUTPUT_DIRECTORY_MINSIZEREL ${PROJECT_BINARY_DIR}/bin${LIB_SUFFIX} )
ADD_EXECUTABLE ( luac ${SRC_LUAC} ${LUAC_RC} )
TARGET_LINK_LIBRARIES ( luac liblua_static )
SET_TARGET_PROPERTIES ( luac PROPERTIES DEBUG_POSTFIX d)
SET_TARGET_PROPERTIES ( luac PROPERTIES RUNTIME_OUTPUT_DIRECTORY_DEBUG ${PROJECT_BINARY_DIR}/bin${LIB_SUFFIX} )
SET_TARGET_PROPERTIES ( luac PROPERTIES RUNTIME_OUTPUT_DIRECTORY_RELWITHDEBINFO ${PROJECT_BINARY_DIR}/bin${LIB_SUFFIX} )
SET_TARGET_PROPERTIES ( luac PROPERTIES RUNTIME_OUTPUT_DIRECTORY_RELEASE ${PROJECT_BINARY_DIR}/bin${LIB_SUFFIX} )
SET_TARGET_PROPERTIES ( luac PROPERTIES RUNTIME_OUTPUT_DIRECTORY_MINSIZEREL ${PROJECT_BINARY_DIR}/bin${LIB_SUFFIX} )
ENABLE_TESTING()
ADD_TEST(NAME bisect
WORKING_DIRECTORY ${PROJECT_SOURCE_DIR}/test
COMMAND lua ${PROJECT_SOURCE_DIR}/test/bisect.lua)
ADD_TEST(NAME cf
WORKING_DIRECTORY ${PROJECT_SOURCE_DIR}/test
COMMAND lua ${PROJECT_SOURCE_DIR}/test/cf.lua)
ADD_TEST(NAME echo
WORKING_DIRECTORY ${PROJECT_SOURCE_DIR}/test
COMMAND lua ${PROJECT_SOURCE_DIR}/test/echo.lua)
ADD_TEST(NAME env
WORKING_DIRECTORY ${PROJECT_SOURCE_DIR}/test
COMMAND lua ${PROJECT_SOURCE_DIR}/test/env.lua)
ADD_TEST(NAME factorial
WORKING_DIRECTORY ${PROJECT_SOURCE_DIR}/test
COMMAND lua ${PROJECT_SOURCE_DIR}/test/factorial.lua)
ADD_TEST(NAME fib
WORKING_DIRECTORY ${PROJECT_SOURCE_DIR}/test
COMMAND lua ${PROJECT_SOURCE_DIR}/test/fib.lua)
ADD_TEST(NAME fibfor
WORKING_DIRECTORY ${PROJECT_SOURCE_DIR}/test
COMMAND lua ${PROJECT_SOURCE_DIR}/test/fibfor.lua)
ADD_TEST(NAME hello
WORKING_DIRECTORY ${PROJECT_SOURCE_DIR}/test
COMMAND lua ${PROJECT_SOURCE_DIR}/test/hello.lua)
ADD_TEST(NAME printf
WORKING_DIRECTORY ${PROJECT_SOURCE_DIR}/test
COMMAND lua ${PROJECT_SOURCE_DIR}/test/printf.lua)
ADD_TEST(NAME sieve
WORKING_DIRECTORY ${PROJECT_SOURCE_DIR}/test
COMMAND lua ${PROJECT_SOURCE_DIR}/test/sieve.lua)
ADD_TEST(NAME sort
WORKING_DIRECTORY ${PROJECT_SOURCE_DIR}/test
COMMAND lua ${PROJECT_SOURCE_DIR}/test/sort.lua)
ADD_TEST(NAME trace-calls
WORKING_DIRECTORY ${PROJECT_SOURCE_DIR}/test
COMMAND lua ${PROJECT_SOURCE_DIR}/test/trace-calls.lua)
ADD_TEST(NAME trace-globals
WORKING_DIRECTORY ${PROJECT_SOURCE_DIR}/test
COMMAND lua ${PROJECT_SOURCE_DIR}/test/trace-globals.lua)
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
1
https://gitee.com/peng_fu_jun/lua.git
git@gitee.com:peng_fu_jun/lua.git
peng_fu_jun
lua
lua
lua-5.1

搜索帮助