2017-12-20 17:58:32 +08:00
|
|
|
# # # # sol2
|
|
|
|
# The MIT License (MIT)
|
|
|
|
#
|
|
|
|
# Copyright (c) 2013-2017 Rapptz, ThePhD, and contributors
|
|
|
|
#
|
|
|
|
# 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.
|
|
|
|
|
2017-12-24 09:34:34 +08:00
|
|
|
# # # Variables
|
|
|
|
# # Core Paths
|
|
|
|
string(TOLOWER ${LUA_VERSION} LUA_BUILD_NORMALIZED_LUA_VERSION)
|
|
|
|
if (LUA_BUILD_NORMALIZED_LUA_VERSION MATCHES "luajit")
|
|
|
|
set(LUA_BUILD_LIBNAME ${LUA_VERSION})
|
2018-01-20 04:03:22 +08:00
|
|
|
elseif (BUILD_LUAJIT)
|
2017-12-24 09:34:34 +08:00
|
|
|
set(LUA_BUILD_LIBNAME luajit-${LUA_VERSION})
|
|
|
|
elseif (LUA_BUILD_NORMALIZED_LUA_VERSION MATCHES "lua")
|
|
|
|
set(LUA_BUILD_LIBNAME ${LUA_VERSION})
|
2018-01-20 04:03:22 +08:00
|
|
|
elseif (BUILD_LUA)
|
2017-12-24 09:34:34 +08:00
|
|
|
set(LUA_BUILD_LIBNAME lua-${LUA_VERSION})
|
|
|
|
else()
|
|
|
|
set(LUA_BUILD_LIBNAME lua-${LUA_VERSION})
|
2017-12-20 17:58:32 +08:00
|
|
|
endif()
|
2017-12-24 09:34:34 +08:00
|
|
|
set(LUA_BUILD_TOPLEVEL "${CMAKE_BINARY_DIR}/vendor/${LUA_BUILD_LIBNAME}")
|
2017-12-25 01:32:23 +08:00
|
|
|
set(LUA_BUILD_INSTALL_DIR "${LUA_BUILD_TOPLEVEL}")
|
2017-12-24 09:34:34 +08:00
|
|
|
# # Misc needed variables
|
|
|
|
set(LUA_BUILD_LIBRARY_DESCRIPTION "The base name of the library to build either the static or the dynamic library")
|
2017-12-20 17:58:32 +08:00
|
|
|
|
2017-12-24 09:34:34 +08:00
|
|
|
# Object file suffixes
|
|
|
|
if (MSVC)
|
|
|
|
set(LUA_BUILD_BUILD_DLL_DEFAULT ON)
|
|
|
|
set(LUA_BUILD_OBJECT_FILE_SUFFIX .obj)
|
2017-12-20 17:58:32 +08:00
|
|
|
else()
|
2017-12-24 09:34:34 +08:00
|
|
|
set(LUA_BUILD_BUILD_DLL_DEFAULT OFF)
|
|
|
|
set(LUA_BUILD_OBJECT_FILE_SUFFIX .o)
|
2017-12-20 17:58:32 +08:00
|
|
|
endif()
|
|
|
|
|
|
|
|
|
2017-12-24 09:34:34 +08:00
|
|
|
# # # Options
|
|
|
|
option(BUILD_LUA_AS_DLL ${LUA_BUILD_BUILD_DLL_DEFAULT} "Build Lua or LuaJIT as a Shared/Dynamic Link Library")
|
|
|
|
|
|
|
|
STRING(TOLOWER ${LUA_BUILD_LIBNAME} LUA_BUILD_NORMALIZED_LIBNAME)
|
2018-01-20 04:03:22 +08:00
|
|
|
if (NOT LUA_LIBRARY_NAME)
|
|
|
|
if (LUA_BUILD_NORMALIZED_LIBNAME MATCHES "luajit")
|
|
|
|
set(LUA_LIBRARY luajit)
|
|
|
|
else()
|
|
|
|
set(LUA_LIBRARY ${LUA_BUILD_LIBNAME})
|
|
|
|
endif()
|
2017-12-20 17:58:32 +08:00
|
|
|
else()
|
2018-01-20 04:03:22 +08:00
|
|
|
set(LUA_LIBRARY_NAME ${LUA_LIBRARY_NAME}
|
2017-12-24 09:34:34 +08:00
|
|
|
CACHE STRING
|
2018-01-20 04:03:22 +08:00
|
|
|
${LUA_BUILD_LIBRARY_DESCRIPTION})
|
2017-12-20 17:58:32 +08:00
|
|
|
endif()
|
2017-12-24 09:34:34 +08:00
|
|
|
# # Dependent Variables
|
|
|
|
# If we're building a DLL, then set the library type to SHARED
|
|
|
|
if (BUILD_LUA_AS_DLL)
|
|
|
|
set(LUA_BUILD_LIBRARY_TYPE SHARED)
|
2017-12-20 17:58:32 +08:00
|
|
|
else()
|
2017-12-24 09:34:34 +08:00
|
|
|
set(LUA_BUILD_LIBRARY_TYPE STATIC)
|
2017-12-20 17:58:32 +08:00
|
|
|
endif()
|
|
|
|
|
|
|
|
|
2017-12-24 09:34:34 +08:00
|
|
|
# # # Build Lua
|
|
|
|
# # Select either LuaJIT or Vanilla Lua here, based on what we discover
|
|
|
|
if (BUILD_LUAJIT OR LUA_BUILD_NORMALIZED_LUA_VERSION MATCHES "luajit")
|
|
|
|
include(LuaJITBuild)
|
|
|
|
else()
|
|
|
|
include(LuaVanillaBuild)
|
2017-12-20 17:58:32 +08:00
|
|
|
endif()
|
|
|
|
|
2017-12-24 09:34:34 +08:00
|
|
|
# # # Variable cleanup
|
|
|
|
unset(LUA_BUILD_LIBNAME)
|
|
|
|
unset(LUA_BUILD_NORMALIZED_LUA_VERSION)
|
|
|
|
unset(LUA_BUILD_LIBRARY_DESCRIPTION)
|
|
|
|
unset(LUA_BUILD_DYNAMIC_LIBRARY_DESCRIPTION)
|
|
|
|
unset(LUA_BUILD_BUILD_DLL_DEFAULT)
|
|
|
|
unset(LUA_BUILD_OBJECT_FILE_SUFFIX)
|
|
|
|
unset(LUA_BUILD_LIBRARY_TYPE)
|