2021-03-06 23:14:48 +08:00
|
|
|
# # # # sol2
|
2017-12-24 09:34:34 +08:00
|
|
|
# The MIT License (MIT)
|
|
|
|
#
|
2022-06-25 16:00:53 +08:00
|
|
|
# Copyright (c) 2013-2022 Rapptz, ThePhD, and contributors
|
2017-12-24 09:34:34 +08:00
|
|
|
#
|
|
|
|
# Permission is hereby granted, free of charge, to any person obtaining a copy of
|
|
|
|
# this software and associated documentation files (the "Software"), to deal in
|
|
|
|
# the Software without restriction, including without limitation the rights to
|
|
|
|
# use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
|
|
|
|
# the Software, and to permit persons to whom the Software is furnished to do so,
|
|
|
|
# subject to the following conditions:
|
|
|
|
#
|
|
|
|
# The above copyright notice and this permission notice shall be included in all
|
|
|
|
# copies or substantial portions of the Software.
|
|
|
|
#
|
|
|
|
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
|
|
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
|
|
|
|
# FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
|
|
|
|
# COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
|
|
|
|
# IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
|
|
|
|
# CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
|
|
|
|
2018-01-24 01:07:22 +08:00
|
|
|
# Include guard
|
|
|
|
if(_lua_vanilla_build_included)
|
|
|
|
return()
|
|
|
|
endif(_lua_vanilla_build_included)
|
|
|
|
set(_lua_vanilla_build_included true)
|
|
|
|
|
2017-12-24 09:34:34 +08:00
|
|
|
# import necessary standard modules
|
|
|
|
include(ExternalProject)
|
2018-02-11 05:24:17 +08:00
|
|
|
# import other modules
|
|
|
|
include(Common/Core)
|
2017-12-24 09:34:34 +08:00
|
|
|
|
|
|
|
# Latest versions for specific sub-versions of Lua
|
|
|
|
set(LUA_VANILLA_5.1_LATEST_VERSION 5.1.5)
|
|
|
|
set(LUA_VANILLA_5.2_LATEST_VERSION 5.2.4)
|
2022-06-24 09:43:37 +08:00
|
|
|
set(LUA_VANILLA_5.3_LATEST_VERSION 5.3.6)
|
|
|
|
set(LUA_VANILLA_5.4_LATEST_VERSION 5.4.4)
|
2017-12-24 09:34:34 +08:00
|
|
|
|
|
|
|
# Clean up some variables
|
|
|
|
if (LUA_VERSION MATCHES "^([0-9]+)\\.([0-9]+)\\.([0-9]+)$")
|
|
|
|
# probably okay!
|
|
|
|
set(LUA_VANILLA_VERSION ${CMAKE_MATCH_1}.${CMAKE_MATCH_2}.${CMAKE_MATCH_3})
|
|
|
|
elseif (LUA_VERSION MATCHES "([0-9]+)\\.([0-9]+)")
|
|
|
|
# extend version number with prefix
|
|
|
|
if (${CMAKE_MATCH_1} EQUAL 5)
|
|
|
|
if (${CMAKE_MATCH_2} EQUAL 1)
|
2018-02-20 11:36:53 +08:00
|
|
|
set(LUA_VANILLA_VERSION ${LUA_VANILLA_5.1_LATEST_VERSION})
|
2017-12-24 09:34:34 +08:00
|
|
|
elseif (${CMAKE_MATCH_2} EQUAL 2)
|
2018-02-20 11:36:53 +08:00
|
|
|
set(LUA_VANILLA_VERSION ${LUA_VANILLA_5.2_LATEST_VERSION})
|
2017-12-24 09:34:34 +08:00
|
|
|
elseif (${CMAKE_MATCH_2} EQUAL 3)
|
2018-02-20 11:36:53 +08:00
|
|
|
set(LUA_VANILLA_VERSION ${LUA_VANILLA_5.3_LATEST_VERSION})
|
2018-12-20 12:17:15 +08:00
|
|
|
elseif (${CMAKE_MATCH_2} EQUAL 4)
|
|
|
|
set(LUA_VANILLA_VERSION ${LUA_VANILLA_5.4_LATEST_VERSION})
|
2017-12-24 09:34:34 +08:00
|
|
|
else()
|
|
|
|
# default to whatever the first two
|
|
|
|
# numbers happen to be, plus build 0
|
|
|
|
set(LUA_VANILLA_VERSION ${CMAKE_MATCH_1}.${CMAKE_MATCH_2}.0)
|
|
|
|
endif()
|
|
|
|
endif()
|
|
|
|
if(NOT LUA_VANILLA_VERSION)
|
|
|
|
# default to whatever the first two
|
|
|
|
# numbers happen to be, plus build 0
|
|
|
|
set(LUA_VANILLA_VERSION ${CMAKE_MATCH_1}.${CMAKE_MATCH_2}.0)
|
|
|
|
endif()
|
|
|
|
else()
|
2017-12-30 07:47:48 +08:00
|
|
|
message(FATAL_ERROR "Cannot deduce the proper Lua version from ${LUA_VERSION}")
|
2017-12-24 09:34:34 +08:00
|
|
|
endif()
|
|
|
|
|
2019-12-23 22:09:23 +08:00
|
|
|
if (BUILD_LUA_AS_CXX)
|
|
|
|
set(LUA_VANILLA_LANGUAGE CXX)
|
|
|
|
set(LUA_VANILLA_LANGUAGE_STANDARD 98)
|
|
|
|
else()
|
|
|
|
set(LUA_VANILLA_LANGUAGE C)
|
|
|
|
set(LUA_VANILLA_LANGUAGE_STANDARD 99)
|
|
|
|
endif()
|
|
|
|
|
2018-01-24 01:07:22 +08:00
|
|
|
FIND_PACKAGE_MESSAGE(LUABUILD
|
2019-12-23 22:09:23 +08:00
|
|
|
"Selecting PUC-RIO Lua ${LUA_VANILLA_VERSION} from '${LUA_VERSION}' and building a ${LUA_BUILD_LIBRARY_TYPE} library with ${LUA_VANILLA_LANGUAGE} linkage..."
|
|
|
|
"[${LUA_VANILLA_VERSION}][${LUA_VERSION}][${LUA_BUILD_LIBRARY_TYPE}][${LUA_VANILLA_LANGUAGE}]")
|
2017-12-24 09:34:34 +08:00
|
|
|
|
|
|
|
# # # Makefile and self-build configurations
|
|
|
|
|
|
|
|
# # Potential compiler variables
|
|
|
|
if (MSVC)
|
|
|
|
if (BUILD_LUA_AS_DLL)
|
|
|
|
set(LUA_VANILLA_DLL_DEFINE LUA_BUILD_AS_DLL)
|
|
|
|
else()
|
|
|
|
set(LUA_VANILLA_DLL_DEFINE "")
|
|
|
|
endif()
|
|
|
|
else()
|
|
|
|
set(LUA_VANILLA_LUALIB_COMPILER_OPTIONS "")
|
|
|
|
set(LUA_VANILLA_DLL_DEFINE "")
|
|
|
|
endif()
|
|
|
|
|
|
|
|
# # Source files for natural build, if we have to go that far
|
|
|
|
# retrieve source files
|
2018-12-20 12:17:15 +08:00
|
|
|
set(LUA_VANILLA_DOWNLOAD_URL https://www.lua.org/ftp/lua-${LUA_VANILLA_VERSION}.tar.gz)
|
2017-12-26 00:44:04 +08:00
|
|
|
if (LUA_VANILLA_VERSION MATCHES "^5\\.1")
|
2017-12-24 09:34:34 +08:00
|
|
|
set(LUA_VANILLA_LIB_SOURCES lapi.c lcode.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 ldblib.c liolib.c lmathlib.c loslib.c ltablib.c
|
2017-12-25 06:59:45 +08:00
|
|
|
lstrlib.c loadlib.c linit.c)
|
2017-12-24 09:34:34 +08:00
|
|
|
set(LUA_VANILLA_LUA_SOURCES lua.c )
|
2019-08-13 02:07:25 +08:00
|
|
|
if (LUA_BUILD_LUA_COMPILER)
|
2017-12-24 09:34:34 +08:00
|
|
|
set(LUA_VANILLA_LUAC_SOURCES luac.c print.c )
|
2019-08-13 02:07:25 +08:00
|
|
|
endif()
|
2017-12-25 06:59:45 +08:00
|
|
|
set(LUA_VANILLA_GENERATE_LUA_HPP true)
|
2017-12-26 00:44:04 +08:00
|
|
|
elseif (LUA_VANILLA_VERSION MATCHES "^5\\.2")
|
2017-12-24 09:34:34 +08:00
|
|
|
set(LUA_VANILLA_LIB_SOURCES 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
|
2022-09-28 13:56:26 +08:00
|
|
|
lauxlib.c lbaselib.c lcorolib.c ldblib.c liolib.c
|
2017-12-25 06:59:45 +08:00
|
|
|
lmathlib.c loslib.c lstrlib.c ltablib.c loadlib.c linit.c)
|
2017-12-24 09:34:34 +08:00
|
|
|
set(LUA_VANILLA_LUA_SOURCES lua.c )
|
2019-08-13 02:07:25 +08:00
|
|
|
if (LUA_BUILD_LUA_COMPILER)
|
2017-12-24 09:34:34 +08:00
|
|
|
set(LUA_VANILLA_LUAC_SOURCES luac.c )
|
2019-08-13 02:07:25 +08:00
|
|
|
endif()
|
2017-12-25 06:59:45 +08:00
|
|
|
set(LUA_VANILLA_GENERATE_LUA_HPP false)
|
2018-12-20 12:17:15 +08:00
|
|
|
elseif (LUA_VANILLA_VERSION MATCHES "^5\\.3")
|
2017-12-24 09:34:34 +08:00
|
|
|
set(LUA_VANILLA_LIB_SOURCES 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)
|
|
|
|
set(LUA_VANILLA_LUA_SOURCES lua.c )
|
2019-08-13 02:07:25 +08:00
|
|
|
if (LUA_BUILD_LUA_COMPILER)
|
2017-12-24 09:34:34 +08:00
|
|
|
set(LUA_VANILLA_LUAC_SOURCES luac.c )
|
2019-08-13 02:07:25 +08:00
|
|
|
endif()
|
2017-12-25 06:59:45 +08:00
|
|
|
set(LUA_VANILLA_GENERATE_LUA_HPP false)
|
2018-12-20 12:17:15 +08:00
|
|
|
elseif (LUA_VANILLA_VERSION MATCHES "^5\\.4")
|
2020-03-31 12:22:46 +08:00
|
|
|
if (LUA_VANILLA_VERSION MATCHES "work" OR LUA_VANILLA_VERSION MATCHES "alpha" OR LUA_VANILLA_VERSION MATCHES "beta")
|
2018-12-20 12:17:15 +08:00
|
|
|
set(LUA_VANILLA_DOWNLOAD_URL https://www.lua.org/work/lua-${LUA_VANILLA_VERSION}.tar.gz)
|
|
|
|
endif()
|
|
|
|
set(LUA_VANILLA_LIB_SOURCES 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 ltm.c lundump.c
|
|
|
|
lutf8lib.c lvm.c lzio.c)
|
|
|
|
set(LUA_VANILLA_LUA_SOURCES lua.c )
|
2019-08-13 02:07:25 +08:00
|
|
|
if (LUA_BUILD_LUA_COMPILER)
|
2018-12-20 12:17:15 +08:00
|
|
|
set(LUA_VANILLA_LUAC_SOURCES luac.c )
|
2019-08-13 02:07:25 +08:00
|
|
|
endif()
|
2018-12-20 12:17:15 +08:00
|
|
|
set(LUA_VANILLA_GENERATE_LUA_HPP false)
|
|
|
|
else()
|
2022-09-28 13:56:26 +08:00
|
|
|
MESSAGE(WARNING "Using Lua 5.4.4 file list for ${LUA_VERSION} version")
|
2018-12-20 12:17:15 +08:00
|
|
|
set(LUA_VANILLA_LIB_SOURCES 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 ltm.c lundump.c
|
|
|
|
lutf8lib.c lvm.c lzio.c)
|
|
|
|
set(LUA_VANILLA_LUA_SOURCES lua.c )
|
2019-08-13 02:07:25 +08:00
|
|
|
if (LUA_BUILD_LUA_COMPILER)
|
2018-12-20 12:17:15 +08:00
|
|
|
set(LUA_VANILLA_LUAC_SOURCES luac.c )
|
2019-08-13 02:07:25 +08:00
|
|
|
endif()
|
2018-12-20 12:17:15 +08:00
|
|
|
set(LUA_VANILLA_GENERATE_LUA_HPP false)
|
2017-12-24 09:34:34 +08:00
|
|
|
endif()
|
|
|
|
|
|
|
|
# download, just for the sake of download + extract
|
2019-01-05 18:48:51 +08:00
|
|
|
# or pull from local folder
|
|
|
|
if (LUA_LOCAL_DIR)
|
2022-09-28 13:56:26 +08:00
|
|
|
set(LUA_VANILLA_SOURCE_DIR ${LUA_BUILD_TOPLEVEL}-src)
|
|
|
|
list(TRANSFORM LUA_VANILLA_LIB_SOURCES PREPEND "${LUA_VANILLA_SOURCE_DIR}/src/")
|
|
|
|
list(TRANSFORM LUA_VANILLA_LUA_SOURCES PREPEND "${LUA_VANILLA_SOURCE_DIR}/src/")
|
2019-01-05 18:48:51 +08:00
|
|
|
file(COPY "${LUA_LOCAL_DIR}/src"
|
2022-09-28 13:56:26 +08:00
|
|
|
DESTINATION "${LUA_VANILLA_SOURCE_DIR}/")
|
2019-01-05 18:48:51 +08:00
|
|
|
file(COPY "${LUA_LOCAL_DIR}/include"
|
2022-09-28 13:56:26 +08:00
|
|
|
DESTINATION "${LUA_VANILLA_SOURCE_DIR}/")
|
2019-01-05 18:48:51 +08:00
|
|
|
add_custom_target(LUA_VANILLA
|
2019-08-13 02:07:25 +08:00
|
|
|
DEPENDS "${LUA_VANILLA_LIB_SOURCES}" "${LUA_VANILLA_LUA_SOURCES}")
|
2022-09-28 13:56:26 +08:00
|
|
|
set(LUA_VANILLA_INCLUDE_DIRS ${LUA_VANILLA_INCLUDE_DIRS} "${LUA_VANILLA_SOURCE_DIR}/include")
|
2019-01-05 18:48:51 +08:00
|
|
|
else()
|
2022-09-28 13:56:26 +08:00
|
|
|
include(FetchContent)
|
|
|
|
FetchContent_Declare(
|
|
|
|
lua-vanilla
|
|
|
|
URL ${LUA_VANILLA_DOWNLOAD_URL})
|
|
|
|
FetchContent_GetProperties(lua-vanilla)
|
|
|
|
if ( NOT lua-vanilla_POPULATED)
|
|
|
|
# Fetch the content using previously declared details
|
|
|
|
FetchContent_Populate(lua-vanilla)
|
|
|
|
# do not add_subdirectory / build: we are JUST using ti as a download step!
|
|
|
|
endif()
|
|
|
|
list(TRANSFORM LUA_VANILLA_LIB_SOURCES PREPEND "${lua-vanilla_SOURCE_DIR}/src/")
|
|
|
|
list(TRANSFORM LUA_VANILLA_LUA_SOURCES PREPEND "${lua-vanilla_SOURCE_DIR}/src/")
|
|
|
|
# make a quick lua.hpp for targets that don't have it
|
2019-01-05 18:48:51 +08:00
|
|
|
if (LUA_VANILLA_GENERATE_LUA_HPP)
|
|
|
|
set(LUA_VANILLA_LUA_HPP_CONTENT "// lua.hpp
|
2017-12-25 06:59:45 +08:00
|
|
|
// Lua header files for C++
|
|
|
|
// <<extern \"C\">> not supplied automatically because Lua also compiles as C++
|
|
|
|
extern \"C\" {
|
|
|
|
#include \"lua.h\"
|
2017-12-26 12:27:22 +08:00
|
|
|
#include \"lualib.h\"
|
2017-12-25 06:59:45 +08:00
|
|
|
#include \"lauxlib.h\"
|
|
|
|
}
|
|
|
|
")
|
2022-09-28 13:56:26 +08:00
|
|
|
set(LUA_VANILLA_SOURCE_LUA_HPP "${lua-vanilla_SOURCE_DIR}/include/lua.hpp")
|
|
|
|
file(CONFIGURE OUTPUT "${LUA_VANILLA_SOURCE_LUA_HPP}" CONTENT "${LUA_VANILLA_LUA_HPP_CONTENT}" @ONLY)
|
2019-01-05 18:48:51 +08:00
|
|
|
file(TO_NATIVE_PATH "${LUA_VANILLA_SOURCE_LUA_HPP}" LUA_VANILLA_SOURCE_LUA_HPP)
|
|
|
|
endif()
|
2017-12-24 09:34:34 +08:00
|
|
|
|
2022-09-28 13:56:26 +08:00
|
|
|
set(LUA_VANILLA_INCLUDE_DIRS ${lua-vanilla_SOURCE_DIR}/include)
|
2019-01-05 18:48:51 +08:00
|
|
|
endif()
|
2019-01-06 02:56:21 +08:00
|
|
|
|
2017-12-24 09:34:34 +08:00
|
|
|
# # Target names
|
2017-12-26 00:44:04 +08:00
|
|
|
set(liblua "liblua-${LUA_VANILLA_VERSION}")
|
|
|
|
set(luainterpreter "lua-${LUA_VANILLA_VERSION}")
|
|
|
|
set(luacompiler "luac-${LUA_VANILLA_VERSION}")
|
2017-12-24 09:34:34 +08:00
|
|
|
|
2017-12-25 06:59:45 +08:00
|
|
|
# Lua does not out-of-the-box support building
|
|
|
|
# a shared library: http://lua-users.org/lists/lua-l/2006-10/msg00098.html
|
|
|
|
# in this case, we essentially need to
|
|
|
|
# build Lua for our purposes, which is annoying
|
|
|
|
# the external project is just a dummy to get and extract the file:
|
|
|
|
# after that, we define actual targets...!
|
2017-12-24 09:34:34 +08:00
|
|
|
|
2017-12-25 06:59:45 +08:00
|
|
|
# make an actual, buildable target
|
|
|
|
# that other parts of the code can depend on
|
2022-09-28 13:56:26 +08:00
|
|
|
add_library(${liblua} ${LUA_BUILD_LIBRARY_TYPE} ${LUA_VANILLA_LIB_SOURCES})
|
2017-12-26 00:44:04 +08:00
|
|
|
set_target_properties(${liblua}
|
2017-12-25 06:59:45 +08:00
|
|
|
PROPERTIES
|
2019-12-23 22:09:23 +08:00
|
|
|
LANGUAGE ${LUA_VANILLA_LANGUAGE}
|
|
|
|
LINKER_LANGUAGE ${LUA_VANILLA_LANGUAGE}
|
|
|
|
${LUA_VANILLA_LANGUAGE}_STANDARD ${LUA_VANILLA_LANGUAGE_STANDARD}
|
|
|
|
${LUA_VANILLA_LANGUAGE}_EXTENSIONS TRUE
|
2017-12-25 06:59:45 +08:00
|
|
|
POSITION_INDEPENDENT_CODE TRUE
|
|
|
|
OUTPUT_NAME ${LUA_BUILD_LIBNAME}
|
|
|
|
RUNTIME_OUTPUT_NAME ${LUA_BUILD_LIBNAME}
|
|
|
|
LIBRARY_OUTPUT_NAME ${LUA_BUILD_LIBNAME}
|
|
|
|
ARCHIVE_OUTPUT_NAME ${LUA_BUILD_LIBNAME})
|
2019-12-23 22:09:23 +08:00
|
|
|
set_source_files_properties(${LUA_VANILLA_LIB_SOURCES}
|
|
|
|
PROPERTIES LANGUAGE ${LUA_VANILLA_LANGUAGE})
|
2017-12-26 00:44:04 +08:00
|
|
|
target_include_directories(${liblua}
|
2019-01-05 18:48:51 +08:00
|
|
|
PUBLIC "${LUA_VANILLA_INCLUDE_DIRS}")
|
2017-12-26 00:44:04 +08:00
|
|
|
target_compile_definitions(${liblua}
|
2018-02-17 13:18:26 +08:00
|
|
|
PUBLIC LUA_COMPAT_ALL ${LUA_VANILLA_DLL_DEFINE})
|
2017-12-25 06:59:45 +08:00
|
|
|
if (MSVC)
|
2017-12-26 00:44:04 +08:00
|
|
|
target_compile_options(${liblua}
|
2017-12-25 06:59:45 +08:00
|
|
|
PRIVATE /W1)
|
2018-01-01 10:15:43 +08:00
|
|
|
else()
|
|
|
|
target_compile_options(${liblua}
|
2018-02-12 16:55:14 +08:00
|
|
|
PRIVATE -w)
|
2017-12-25 06:59:45 +08:00
|
|
|
endif()
|
|
|
|
if (WIN32)
|
|
|
|
else()
|
2017-12-26 00:44:04 +08:00
|
|
|
target_compile_definitions(${liblua}
|
2017-12-25 06:59:45 +08:00
|
|
|
PRIVATE LUA_USE_LINUX)
|
|
|
|
endif()
|
2017-12-26 00:44:04 +08:00
|
|
|
target_compile_options(${liblua}
|
2017-12-25 06:59:45 +08:00
|
|
|
PRIVATE ${LUA_VANILLA_LUALIB_COMPILER_OPTIONS})
|
2017-12-26 00:44:04 +08:00
|
|
|
add_dependencies(${liblua} LUA_VANILLA)
|
2021-03-06 14:03:23 +08:00
|
|
|
target_link_libraries(${liblua} PRIVATE ${CMAKE_DL_LIBS})
|
2017-12-25 06:59:45 +08:00
|
|
|
if (UNIX)
|
2018-12-28 01:37:56 +08:00
|
|
|
target_link_libraries(${liblua} PRIVATE m)
|
2017-12-25 06:59:45 +08:00
|
|
|
endif()
|
2017-12-24 09:34:34 +08:00
|
|
|
|
2017-12-25 06:59:45 +08:00
|
|
|
# we don't really need this section...
|
|
|
|
# Lua Interpreter
|
2019-12-23 22:09:23 +08:00
|
|
|
if (LUA_BUILD_LUA_INTERPRETER)
|
|
|
|
add_executable(${luainterpreter} ${LUA_VANILLA_LUA_SOURCES})
|
|
|
|
set_target_properties(${luainterpreter}
|
|
|
|
PROPERTIES
|
|
|
|
LANGUAGE ${LUA_VANILLA_LANGUAGE}
|
|
|
|
LINKER_LANGUAGE ${LUA_VANILLA_LANGUAGE}
|
|
|
|
${LUA_VANILLA_LANGUAGE}_STANDARD ${LUA_VANILLA_LANGUAGE_STANDARD}
|
|
|
|
${LUA_VANILLA_LANGUAGE}_EXTENSIONS TRUE
|
|
|
|
OUTPUT_NAME lua-${LUA_VANILLA_VERSION})
|
|
|
|
set_source_files_properties(${LUA_VANILLA_LUA_SOURCES}
|
|
|
|
PROPERTIES LANGUAGE ${LUA_VANILLA_LANGUAGE})
|
|
|
|
target_include_directories(${luainterpreter}
|
|
|
|
PRIVATE "${LUA_VANILLA_INCLUDE_DIRS}")
|
|
|
|
target_compile_definitions(${luainterpreter}
|
|
|
|
PUBLIC LUA_COMPAT_ALL ${LUA_VANILLA_DLL_DEFINE}
|
|
|
|
PRIVATE LUA_COMPAT_ALL ${LUA_VANILLA_DLL_DEFINE})
|
|
|
|
if (MSVC)
|
|
|
|
target_compile_options(${luainterpreter}
|
|
|
|
PRIVATE /W1)
|
|
|
|
else()
|
|
|
|
target_compile_options(${luainterpreter}
|
|
|
|
PRIVATE -w)
|
|
|
|
endif()
|
|
|
|
if (WIN32)
|
|
|
|
#target_compile_definitions(${luainterpreter}
|
|
|
|
# PRIVATE LUA_USE_WINDOWS)
|
|
|
|
else()
|
|
|
|
target_compile_definitions(${luainterpreter}
|
|
|
|
PRIVATE LUA_USE_LINUX)
|
|
|
|
endif()
|
2021-03-06 14:03:23 +08:00
|
|
|
target_link_libraries(${luainterpreter} PRIVATE ${liblua} ${CMAKE_DL_LIBS})
|
2019-12-23 22:09:23 +08:00
|
|
|
if (UNIX)
|
|
|
|
target_link_libraries(${luainterpreter} PRIVATE m readline)
|
|
|
|
endif()
|
2017-12-25 06:59:45 +08:00
|
|
|
endif()
|
2017-12-24 09:34:34 +08:00
|
|
|
|
2017-12-25 06:59:45 +08:00
|
|
|
# LuaC Compiler
|
2019-08-13 02:07:25 +08:00
|
|
|
if (LUA_BUILD_LUA_COMPILER)
|
2019-12-23 22:09:23 +08:00
|
|
|
add_executable(${luainterpreter} ${LUA_VANILLA_LUA_SOURCES})
|
2019-08-13 02:07:25 +08:00
|
|
|
set_target_properties(${luacompiler}
|
|
|
|
PROPERTIES
|
2019-12-23 22:09:23 +08:00
|
|
|
LANGUAGE ${LUA_VANILLA_LANGUAGE}
|
|
|
|
LINKER_LANGUAGE ${LUA_VANILLA_LANGUAGE}
|
2019-08-13 02:07:25 +08:00
|
|
|
OUTPUT_NAME luac-${LUA_VANILLA_VERSION})
|
2019-12-23 22:09:23 +08:00
|
|
|
set_source_files_properties(${LUA_VANILLA_LIB_SOURCES}
|
|
|
|
PROPERTIES LANGUAGE ${LUA_VANILLA_LANGUAGE})
|
2019-08-13 02:07:25 +08:00
|
|
|
target_include_directories(${luacompiler}
|
|
|
|
PRIVATE "${LUA_VANILLA_INCLUDE_DIRS}")
|
|
|
|
target_compile_definitions(${luacompiler}
|
|
|
|
PUBLIC LUA_COMPAT_ALL ${LUA_VANILLA_DLL_DEFINE}
|
|
|
|
PRIVATE LUA_COMPAT_ALL ${LUA_VANILLA_DLL_DEFINE})
|
|
|
|
if (MSVC)
|
|
|
|
target_compile_options(${luacompiler}
|
|
|
|
PRIVATE /W1)
|
|
|
|
else()
|
|
|
|
target_compile_options(${luacompiler}
|
|
|
|
PRIVATE -w)
|
|
|
|
endif()
|
|
|
|
if (WIN32)
|
|
|
|
#target_compile_definitions(${luacompiler}
|
|
|
|
# PRIVATE LUA_USE_WINDOWS)
|
|
|
|
else()
|
|
|
|
target_compile_definitions(${luacompiler}
|
|
|
|
PRIVATE LUA_USE_LINUX)
|
|
|
|
endif()
|
2021-03-06 14:03:23 +08:00
|
|
|
target_link_libraries(${luacompiler} PRIVATE ${liblua} ${CMAKE_DL_LIBS})
|
2019-08-13 02:07:25 +08:00
|
|
|
if (UNIX)
|
|
|
|
# TODO: make readline optional?
|
|
|
|
target_link_libraries(${luacompiler} PRIVATE m readline)
|
|
|
|
endif()
|
2017-12-25 06:59:45 +08:00
|
|
|
endif()
|
|
|
|
|
|
|
|
# set externally-visible target indicator
|
2017-12-26 00:44:04 +08:00
|
|
|
set(LUA_LIBRARIES ${liblua})
|
2018-01-24 01:07:22 +08:00
|
|
|
set(LUA_INTERPRETER ${luainterpreter})
|
2019-08-13 02:07:25 +08:00
|
|
|
if (LUA_BUILD_LUA_COMPILER)
|
|
|
|
set(LUA_COMPILER ${luacompiler})
|
|
|
|
endif()
|
2022-09-28 13:56:26 +08:00
|
|
|
set(LUA_INCLUDE_DIRS ${LUA_VANILLA_INCLUDE_DIRS})
|