2013-12-10 13:41:43 -05:00
|
|
|
|
2014-01-16 12:33:28 -05:00
|
|
|
cmake_minimum_required (VERSION 2.8.2)
|
2013-12-10 13:41:43 -05:00
|
|
|
project (MCServer)
|
|
|
|
|
|
|
|
include_directories (SYSTEM "${PROJECT_SOURCE_DIR}/../lib/")
|
2013-12-10 16:39:20 -05:00
|
|
|
include_directories (SYSTEM "${PROJECT_SOURCE_DIR}/../lib/jsoncpp/include")
|
|
|
|
|
2013-12-19 10:07:45 -05:00
|
|
|
set(FOLDERS OSSupport HTTPServer Bindings Items Blocks Protocol Generating)
|
|
|
|
set(FOLDERS ${FOLDERS} WorldStorage Mobs Entities Simulator UI BlockEntities)
|
2013-12-10 18:20:39 -05:00
|
|
|
|
2013-12-19 10:07:45 -05:00
|
|
|
|
2013-12-10 13:41:43 -05:00
|
|
|
|
2013-12-28 08:42:11 -05:00
|
|
|
if (NOT MSVC)
|
2014-01-23 13:41:08 -05:00
|
|
|
|
|
|
|
#Bindings needs to reference other folders so are done here
|
|
|
|
|
|
|
|
#lib dependecies are not included
|
|
|
|
|
|
|
|
set(BINDING_DEPENDECIES ${CMAKE_CURRENT_SOURCE_DIR}/Bindings/virtual_method_hooks.lua)
|
|
|
|
set(BINDING_DEPENDECIES ${BINDING_DEPENDECIES} ${CMAKE_CURRENT_SOURCE_DIR}/Bindings/AllToLua.pkg)
|
2014-01-23 14:00:36 -05:00
|
|
|
set(BINDING_DEPENDECIES ${BINDING_DEPENDECIES} ChunkDef.h BiomeDef.h)
|
2014-01-23 13:41:08 -05:00
|
|
|
set(BINDING_DEPENDECIES ${BINDING_DEPENDECIES} OSSupport/File.h Bindings/LuaFunctions.h)
|
|
|
|
set(BINDING_DEPENDECIES ${BINDING_DEPENDECIES} Bindings/PluginManager.h Bindings/Plugin.h)
|
|
|
|
set(BINDING_DEPENDECIES ${BINDING_DEPENDECIES} Bindings/PluginLua.h Bindings/WebPlugin.h)
|
|
|
|
set(BINDING_DEPENDECIES ${BINDING_DEPENDECIES} Bindings/LuaWindow.h BlockID.h StringUtils.h)
|
|
|
|
set(BINDING_DEPENDECIES ${BINDING_DEPENDECIES} Defines.h ChatColor.h ClientHandle.h)
|
|
|
|
set(BINDING_DEPENDECIES ${BINDING_DEPENDECIES} Entities/Entity.h Entities/Floater.h )
|
|
|
|
set(BINDING_DEPENDECIES ${BINDING_DEPENDECIES} Entities/Pawn.h Entities/Player.h)
|
|
|
|
set(BINDING_DEPENDECIES ${BINDING_DEPENDECIES} Entities/Pickup.h Entities/ProjectileEntity.h)
|
|
|
|
set(BINDING_DEPENDECIES ${BINDING_DEPENDECIES} Entities/TNTEntity.h Entities/Effects.h)
|
|
|
|
set(BINDING_DEPENDECIES ${BINDING_DEPENDECIES} Server.h World.h Inventory.h Enchantments.h)
|
|
|
|
set(BINDING_DEPENDECIES ${BINDING_DEPENDECIES} Item.h ItemGrid.h BlockEntities/BlockEntity.h)
|
|
|
|
set(BINDING_DEPENDECIES ${BINDING_DEPENDECIES} BlockEntities/BlockEntityWithItems.h)
|
|
|
|
set(BINDING_DEPENDECIES ${BINDING_DEPENDECIES} BlockEntities/ChestEntity.h)
|
|
|
|
set(BINDING_DEPENDECIES ${BINDING_DEPENDECIES} BlockEntities/DropSpenserEntity.h)
|
|
|
|
set(BINDING_DEPENDECIES ${BINDING_DEPENDECIES} BlockEntities/DispenserEntity.h)
|
|
|
|
set(BINDING_DEPENDECIES ${BINDING_DEPENDECIES} BlockEntities/DropperEntity.h)
|
|
|
|
set(BINDING_DEPENDECIES ${BINDING_DEPENDECIES} BlockEntities/FurnaceEntity.h)
|
|
|
|
set(BINDING_DEPENDECIES ${BINDING_DEPENDECIES} BlockEntities/HopperEntity.h)
|
|
|
|
set(BINDING_DEPENDECIES ${BINDING_DEPENDECIES} BlockEntities/JukeboxEntity.h)
|
|
|
|
set(BINDING_DEPENDECIES ${BINDING_DEPENDECIES} BlockEntities/NoteEntity.h)
|
|
|
|
set(BINDING_DEPENDECIES ${BINDING_DEPENDECIES} BlockEntities/SignEntity.h WebAdmin.h Root.h)
|
|
|
|
set(BINDING_DEPENDECIES ${BINDING_DEPENDECIES} Vector3f.h Vector3d.h Vector3i.h Matrix4f.h)
|
|
|
|
set(BINDING_DEPENDECIES ${BINDING_DEPENDECIES} Cuboid.h BoundingBox.h Tracer.h Group.h)
|
|
|
|
set(BINDING_DEPENDECIES ${BINDING_DEPENDECIES} BlockArea.h Generating/ChunkDesc.h)
|
|
|
|
set(BINDING_DEPENDECIES ${BINDING_DEPENDECIES} CraftingRecipes.h UI/Window.h Mobs/Monster.h)
|
|
|
|
|
2014-01-23 14:00:36 -05:00
|
|
|
include_directories(Bindings)
|
|
|
|
include_directories(.)
|
|
|
|
|
2014-01-23 13:41:08 -05:00
|
|
|
ADD_CUSTOM_COMMAND(
|
|
|
|
# add any new generated bindings here
|
|
|
|
OUTPUT ${CMAKE_CURRENT_SOURCE_DIR}/Bindings/Bindings.cpp ${CMAKE_CURRENT_SOURCE_DIR}/Bindings/Bindings.h
|
|
|
|
|
|
|
|
# command execuded to regerate bindings
|
2014-01-23 14:00:36 -05:00
|
|
|
COMMAND tolua -L virtual_method_hooks.lua -o Bindings.cpp -H Bindings.h AllToLua.pkg
|
2014-01-23 13:41:08 -05:00
|
|
|
WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/Bindings/
|
|
|
|
|
|
|
|
# add any new generation dependencies here
|
|
|
|
DEPENDS ${BINDING_DEPENDECIES}
|
|
|
|
)
|
2014-01-23 14:00:36 -05:00
|
|
|
#add cpp files here
|
|
|
|
add_library(Bindings Bindings/PluginManager Bindings/LuaState Bindings/WebPlugin Bindings/Bindings Bindings/ManualBindings Bindings/LuaWindow Bindings/Plugin Bindings/PluginLua Bindings/WebPlugin)
|
|
|
|
|
|
|
|
target_link_libraries(Bindings lua sqlite tolualib)
|
2014-01-23 13:41:08 -05:00
|
|
|
|
2013-12-26 08:54:46 -05:00
|
|
|
foreach(folder ${FOLDERS})
|
|
|
|
add_subdirectory(${folder})
|
|
|
|
endforeach(folder)
|
2013-12-19 10:07:45 -05:00
|
|
|
|
2013-12-26 08:54:46 -05:00
|
|
|
file(GLOB SOURCE
|
|
|
|
"*.cpp"
|
2013-12-19 10:07:45 -05:00
|
|
|
)
|
2013-12-19 19:22:06 -05:00
|
|
|
|
2013-12-26 08:54:46 -05:00
|
|
|
list(REMOVE_ITEM SOURCE "${PROJECT_SOURCE_DIR}/StackWalker.cpp" "${PROJECT_SOURCE_DIR}/LeakFinder.cpp")
|
2013-12-19 10:07:45 -05:00
|
|
|
|
2014-01-13 11:15:34 -05:00
|
|
|
# If building a windows version, but not using MSVC, add the resources directly to the makefile:
|
|
|
|
if (WIN32)
|
|
|
|
FILE(GLOB ResourceFiles
|
|
|
|
"Resources/*.rc"
|
|
|
|
)
|
|
|
|
list(APPEND SOURCE "${ResourceFiles}")
|
|
|
|
endif()
|
|
|
|
|
|
|
|
|
2013-12-26 08:54:46 -05:00
|
|
|
else ()
|
2013-12-19 10:07:45 -05:00
|
|
|
|
2014-01-12 11:20:14 -05:00
|
|
|
# Generate the Bindings if they don't exist:
|
|
|
|
if (NOT EXISTS "${PROJECT_SOURCE_DIR}/Bindings/Bindings.cpp")
|
|
|
|
message("Bindings.cpp not found, generating now")
|
|
|
|
set(tolua_executable ${PROJECT_SOURCE_DIR}/Bindings/tolua++.exe)
|
|
|
|
execute_process(
|
|
|
|
COMMAND ${tolua_executable} -L virtual_method_hooks.lua -o Bindings.cpp -H Bindings.h AllToLua.pkg
|
|
|
|
WORKING_DIRECTORY ${PROJECT_SOURCE_DIR}/Bindings
|
|
|
|
)
|
|
|
|
endif()
|
|
|
|
|
2014-01-13 11:15:34 -05:00
|
|
|
# Add all subfolders as solution-folders:
|
|
|
|
list(APPEND FOLDERS "Resources")
|
2013-12-26 08:54:46 -05:00
|
|
|
function(includefolder PATH)
|
|
|
|
FILE(GLOB FOLDER_FILES
|
|
|
|
"${PATH}/*.cpp"
|
|
|
|
"${PATH}/*.h"
|
2014-01-13 11:15:34 -05:00
|
|
|
"${PATH}/*.rc"
|
2013-12-26 08:54:46 -05:00
|
|
|
)
|
|
|
|
source_group("${PATH}" FILES ${FOLDER_FILES})
|
|
|
|
endfunction(includefolder)
|
2013-12-19 10:07:45 -05:00
|
|
|
|
2013-12-26 08:54:46 -05:00
|
|
|
foreach(folder ${FOLDERS})
|
|
|
|
includefolder(${folder})
|
|
|
|
endforeach(folder)
|
2013-12-19 19:31:52 -05:00
|
|
|
|
2013-12-26 08:54:46 -05:00
|
|
|
file(GLOB_RECURSE SOURCE
|
|
|
|
"*.cpp"
|
|
|
|
"*.h"
|
|
|
|
)
|
2013-12-20 11:05:12 -05:00
|
|
|
|
2013-12-26 08:54:46 -05:00
|
|
|
include_directories("${PROJECT_SOURCE_DIR}")
|
2013-12-20 11:05:12 -05:00
|
|
|
|
2013-12-26 08:54:46 -05:00
|
|
|
source_group("" FILES ${SOURCE})
|
2013-12-20 11:05:12 -05:00
|
|
|
|
2013-12-26 08:54:46 -05:00
|
|
|
# Precompiled headers (1st part)
|
|
|
|
SET_SOURCE_FILES_PROPERTIES(
|
2013-12-27 05:51:08 -05:00
|
|
|
Globals.cpp PROPERTIES COMPILE_FLAGS "/Yc\"Globals.h\""
|
|
|
|
)
|
|
|
|
# CMake cannot "remove" the precompiled header flags, so we use a dummy precompiled header compatible with just this one file:
|
|
|
|
SET_SOURCE_FILES_PROPERTIES(
|
|
|
|
Bindings/Bindings.cpp PROPERTIES COMPILE_FLAGS "/Yc\"string.h\" /Fp\"$(IntDir)/Bindings.pch\""
|
|
|
|
)
|
|
|
|
SET_SOURCE_FILES_PROPERTIES(
|
|
|
|
"StackWalker.cpp LeakFinder.h" PROPERTIES COMPILE_FLAGS "/Yc\"Globals.h\""
|
2013-12-26 08:54:46 -05:00
|
|
|
)
|
2014-01-13 11:15:34 -05:00
|
|
|
list(APPEND SOURCE "Resources/MCServer.rc")
|
2013-12-19 10:07:45 -05:00
|
|
|
endif()
|
2013-12-10 13:41:43 -05:00
|
|
|
|
2013-12-28 08:42:11 -05:00
|
|
|
set(EXECUTABLE MCServer)
|
2013-12-19 19:22:06 -05:00
|
|
|
|
|
|
|
add_executable(${EXECUTABLE} ${SOURCE})
|
2013-12-10 13:41:43 -05:00
|
|
|
|
2013-12-28 08:42:11 -05:00
|
|
|
|
2014-01-16 12:33:28 -05:00
|
|
|
# Output the executable into the $/MCServer folder, so that it has access to external resources:
|
|
|
|
set(EXECUTABLE_OUTPUT_PATH ${CMAKE_SOURCE_DIR}/MCServer)
|
|
|
|
SET_TARGET_PROPERTIES(${EXECUTABLE} PROPERTIES
|
|
|
|
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
|
|
|
|
)
|
2013-12-28 08:42:11 -05:00
|
|
|
|
|
|
|
|
|
|
|
# Make the debug executable have a "_debug" suffix
|
|
|
|
SET_TARGET_PROPERTIES(${EXECUTABLE} PROPERTIES DEBUG_POSTFIX "_debug")
|
|
|
|
|
2014-01-14 03:32:43 -05:00
|
|
|
# Make the profiled executables have a "_profile" postfix
|
|
|
|
SET_TARGET_PROPERTIES(${EXECUTABLE} PROPERTIES DEBUGPROFILE_POSTFIX "_debug_profile")
|
|
|
|
SET_TARGET_PROPERTIES(${EXECUTABLE} PROPERTIES RELEASEPROFILE_POSTFIX "_profile")
|
|
|
|
|
2013-12-26 08:54:46 -05:00
|
|
|
|
2013-12-27 05:51:08 -05:00
|
|
|
# Precompiled headers (2nd part)
|
2013-12-28 08:42:11 -05:00
|
|
|
if (MSVC)
|
2013-12-26 08:54:46 -05:00
|
|
|
SET_TARGET_PROPERTIES(
|
2013-12-27 05:51:08 -05:00
|
|
|
${EXECUTABLE} PROPERTIES COMPILE_FLAGS "/Yu\"Globals.h\""
|
|
|
|
OBJECT_DEPENDS "$(IntDir)/$(TargetName.pch)"
|
2013-12-26 08:54:46 -05:00
|
|
|
)
|
|
|
|
endif ()
|
|
|
|
|
|
|
|
|
2013-12-28 08:42:11 -05:00
|
|
|
if (NOT MSVC)
|
2013-12-26 08:54:46 -05:00
|
|
|
target_link_libraries(${EXECUTABLE} OSSupport HTTPServer Bindings Items Blocks)
|
|
|
|
target_link_libraries(${EXECUTABLE} Protocol Generating WorldStorage)
|
|
|
|
target_link_libraries(${EXECUTABLE} Mobs Entities Simulator UI BlockEntities)
|
|
|
|
endif ()
|
2013-12-27 05:51:08 -05:00
|
|
|
if (WIN32)
|
|
|
|
target_link_libraries(${EXECUTABLE} expat tolualib ws2_32.lib Psapi.lib)
|
|
|
|
endif()
|
|
|
|
target_link_libraries(${EXECUTABLE} md5 luaexpat iniFile jsoncpp cryptopp zlib lua sqlite)
|