2013-12-18 18:14:11 -05:00
|
|
|
|
2014-01-17 02:09:03 -05:00
|
|
|
cmake_minimum_required (VERSION 2.8.2)
|
2013-12-18 18:14:11 -05:00
|
|
|
project (lua)
|
|
|
|
|
|
|
|
include_directories ("${PROJECT_SOURCE_DIR}/../../src/")
|
|
|
|
|
|
|
|
file(GLOB SOURCE
|
2013-12-18 18:54:55 -05:00
|
|
|
"src/*.c"
|
2013-12-18 18:14:11 -05:00
|
|
|
)
|
|
|
|
|
2013-12-27 05:51:08 -05:00
|
|
|
list(REMOVE_ITEM SOURCE "${PROJECT_SOURCE_DIR}/src/lua.c" "${PROJECT_SOURCE_DIR}/src/luac.c")
|
|
|
|
|
|
|
|
# add headers to MSVC project files:
|
|
|
|
if (WIN32)
|
|
|
|
file(GLOB HEADERS "src/*.h")
|
|
|
|
list(REMOVE_ITEM SOURCE "${PROJECT_SOURCE_DIR}/src/lua.h" "${PROJECT_SOURCE_DIR}/src/luac.h")
|
|
|
|
set(SOURCE ${SOURCE} ${HEADERS})
|
|
|
|
source_group("Sources" FILES ${SOURCE})
|
|
|
|
endif()
|
|
|
|
|
|
|
|
# Lua needs to be linked dynamically on Windows and statically on *nix, so that LuaRocks work
|
|
|
|
if (WIN32)
|
|
|
|
add_library(lua SHARED ${SOURCE})
|
2014-01-13 04:59:37 -05:00
|
|
|
set(LIBRARY_OUTPUT_PATH ${CMAKE_SOURCE_DIR}/MCServer)
|
|
|
|
|
2014-01-16 12:33:28 -05:00
|
|
|
# Output the executable into the $/MCServer folder, so that MCServer can find it:
|
|
|
|
set(EXECUTABLE_OUTPUT_PATH ${CMAKE_SOURCE_DIR}/MCServer)
|
2014-01-17 02:09:03 -05:00
|
|
|
SET_TARGET_PROPERTIES(lua PROPERTIES
|
|
|
|
ARCHIVE_OUTPUT_DIRECTORY_DEBUG ${CMAKE_SOURCE_DIR}/MCServer
|
|
|
|
ARCHIVE_OUTPUT_DIRECTORY_RELEASE ${CMAKE_SOURCE_DIR}/MCServer
|
|
|
|
ARCHIVE_OUTPUT_DIRECTORY_DEBUGPROFILE ${CMAKE_SOURCE_DIR}/MCServer
|
|
|
|
ARCHIVE_OUTPUT_DIRECTORY_RELEASEPROFILE ${CMAKE_SOURCE_DIR}/MCServer
|
|
|
|
LIBRARY_OUTPUT_DIRECTORY_DEBUG ${CMAKE_SOURCE_DIR}/MCServer
|
|
|
|
LIBRARY_OUTPUT_DIRECTORY_RELEASE ${CMAKE_SOURCE_DIR}/MCServer
|
|
|
|
LIBRARY_OUTPUT_DIRECTORY_DEBUGPROFILE ${CMAKE_SOURCE_DIR}/MCServer
|
|
|
|
LIBRARY_OUTPUT_DIRECTORY_RELEASEPROFILE ${CMAKE_SOURCE_DIR}/MCServer
|
2014-01-16 12:33:28 -05:00
|
|
|
RUNTIME_OUTPUT_DIRECTORY_DEBUG ${CMAKE_SOURCE_DIR}/MCServer
|
|
|
|
RUNTIME_OUTPUT_DIRECTORY_RELEASE ${CMAKE_SOURCE_DIR}/MCServer
|
|
|
|
RUNTIME_OUTPUT_DIRECTORY_DEBUGPROFILE ${CMAKE_SOURCE_DIR}/MCServer
|
|
|
|
RUNTIME_OUTPUT_DIRECTORY_RELEASEPROFILE ${CMAKE_SOURCE_DIR}/MCServer
|
|
|
|
)
|
|
|
|
|
|
|
|
if (MSVC)
|
2014-01-15 06:01:03 -05:00
|
|
|
# Remove SCL warnings, we expect this library to have been tested safe
|
2014-01-13 04:59:37 -05:00
|
|
|
SET_TARGET_PROPERTIES(
|
|
|
|
lua PROPERTIES COMPILE_FLAGS "-D_CRT_SECURE_NO_WARNINGS"
|
|
|
|
)
|
|
|
|
endif()
|
2014-01-17 02:09:03 -05:00
|
|
|
|
2014-02-28 02:26:39 -05:00
|
|
|
set_target_properties(lua PROPERTIES OUTPUT_NAME "lua51")
|
|
|
|
|
2014-01-17 02:09:03 -05:00
|
|
|
# NOTE: The DLL for each configuration is stored at the same place, thus overwriting each other.
|
2014-02-28 02:26:39 -05:00
|
|
|
# This is known, however such behavior is needed for LuaRocks - they always load "lua5.1.dll" or "lua51.dll"
|
|
|
|
# We make it work by compiling to "lua51.dll" and providing a proxy-DLL "lua5.1.dll"
|
|
|
|
# See http://lua-users.org/wiki/LuaProxyDllFour for details
|
2013-12-20 10:29:34 -05:00
|
|
|
else()
|
2013-12-27 05:51:08 -05:00
|
|
|
add_library(lua ${SOURCE})
|
2013-12-20 10:29:34 -05:00
|
|
|
endif()
|
2013-12-18 18:14:11 -05:00
|
|
|
|
2014-01-09 02:05:08 -05:00
|
|
|
# Tell Lua what dynamic loader to use (for LuaRocks):
|
|
|
|
if (UNIX)
|
2014-01-10 04:03:39 -05:00
|
|
|
add_definitions(-DLUA_USE_DLOPEN)
|
2014-01-09 02:05:08 -05:00
|
|
|
endif()
|
|
|
|
|
2013-12-27 05:51:08 -05:00
|
|
|
if (UNIX)
|
2014-01-07 08:08:58 -05:00
|
|
|
target_link_libraries(lua m ${DYNAMIC_LOADER})
|
2013-12-21 08:50:32 -05:00
|
|
|
endif()
|
2014-01-13 04:59:37 -05:00
|
|
|
|