From c36481f4ef8bb0693e9c53984688e2f75d947f8d Mon Sep 17 00:00:00 2001 From: Quentin Bazin Date: Wed, 9 Jan 2019 19:32:28 +0100 Subject: [PATCH] [CMakeLists.txt] Improved build for client/server architecture. --- .gitignore | 3 +- CMakeLists.txt | 51 ++-------------- client/CMakeLists.txt | 59 +++++++++++++++++++ {source => client/source}/main.cpp | 0 common/CMakeLists.txt | 43 ++++++++++++++ .../include}/core/Application.hpp | 0 {include => common/include}/core/Color.hpp | 0 {include => common/include}/core/Config.hpp | 0 {include => common/include}/core/Registry.hpp | 0 .../include}/core/input/GameKey.hpp | 0 .../include}/core/input/KeyboardHandler.hpp | 0 .../include}/display/Skybox.hpp | 0 .../include}/gui/CraftingWidget.hpp | 0 {include => common/include}/gui/Cube.hpp | 0 .../include}/gui/FurnaceWidget.hpp | 0 .../include}/gui/InventoryWidget.hpp | 0 .../include}/gui/ItemWidget.hpp | 0 .../include}/gui/MenuWidget.hpp | 0 .../include}/gui/MouseItemWidget.hpp | 0 .../include}/gui/PlayerInventoryWidget.hpp | 0 {include => common/include}/gui/Text.hpp | 0 .../include}/gui/TextButton.hpp | 0 {include => common/include}/gui/Widget.hpp | 0 .../include}/hud/BlockCursor.hpp | 0 .../include}/hud/BlockInfoWidget.hpp | 0 {include => common/include}/hud/Crosshair.hpp | 0 .../include}/hud/DebugOverlay.hpp | 0 {include => common/include}/hud/HUD.hpp | 0 {include => common/include}/hud/Hotbar.hpp | 0 .../include}/inventory/BlockType.hpp | 0 .../include}/inventory/CraftingRecipe.hpp | 0 .../include}/inventory/Inventory.hpp | 0 .../include}/inventory/Item.hpp | 0 .../include}/inventory/ItemStack.hpp | 0 .../include}/inventory/ItemType.hpp | 0 .../include}/inventory/Recipe.hpp | 0 .../include}/inventory/SmeltingRecipe.hpp | 0 {include => common/include}/lua/LuaCore.hpp | 0 {include => common/include}/lua/LuaGUI.hpp | 0 {include => common/include}/lua/LuaMod.hpp | 0 .../include}/lua/LuaWidgetDef.hpp | 0 .../include}/lua/ScriptEngine.hpp | 0 .../include}/resource/TextureLoader.hpp | 0 .../include}/states/GameState.hpp | 0 .../include}/states/InventoryState.hpp | 0 .../include}/states/LuaGUIState.hpp | 0 .../include}/states/PauseMenuState.hpp | 0 .../include}/states/SettingsMenuState.hpp | 0 {include => common/include}/world/Block.hpp | 0 .../include}/world/BlockData.hpp | 0 .../include}/world/BlockWater.hpp | 0 {include => common/include}/world/Chunk.hpp | 0 .../include}/world/ChunkBuilder.hpp | 0 .../include}/world/ChunkLightmap.hpp | 0 {include => common/include}/world/Player.hpp | 0 {include => common/include}/world/World.hpp | 0 .../include}/world/gen/TerrainGenerator.hpp | 0 .../source}/core/Application.cpp | 0 {source => common/source}/core/Config.cpp | 0 {source => common/source}/core/Registry.cpp | 0 .../source}/core/input/KeyboardHandler.cpp | 0 {source => common/source}/display/Skybox.cpp | 0 .../source}/gui/CraftingWidget.cpp | 0 {source => common/source}/gui/Cube.cpp | 0 .../source}/gui/FurnaceWidget.cpp | 0 .../source}/gui/InventoryWidget.cpp | 0 {source => common/source}/gui/ItemWidget.cpp | 0 {source => common/source}/gui/MenuWidget.cpp | 0 .../source}/gui/MouseItemWidget.cpp | 0 .../source}/gui/PlayerInventoryWidget.cpp | 0 {source => common/source}/gui/Text.cpp | 0 {source => common/source}/gui/TextButton.cpp | 0 {source => common/source}/gui/Widget.cpp | 0 {source => common/source}/hud/BlockCursor.cpp | 0 .../source}/hud/BlockInfoWidget.cpp | 0 {source => common/source}/hud/Crosshair.cpp | 0 .../source}/hud/DebugOverlay.cpp | 0 {source => common/source}/hud/HUD.cpp | 0 {source => common/source}/hud/Hotbar.cpp | 0 .../source}/inventory/CraftingRecipe.cpp | 0 .../source}/inventory/Inventory.cpp | 0 {source => common/source}/inventory/Item.cpp | 0 .../source}/inventory/ItemStack.cpp | 0 .../source}/inventory/SmeltingRecipe.cpp | 0 {source => common/source}/lua/LuaCore.cpp | 0 {source => common/source}/lua/LuaGUI.cpp | 0 {source => common/source}/lua/LuaMod.cpp | 0 .../source}/lua/ScriptEngine.cpp | 0 .../source}/resource/TextureLoader.cpp | 0 .../source}/states/GameState.cpp | 0 .../source}/states/InventoryState.cpp | 0 .../source}/states/LuaGUIState.cpp | 0 .../source}/states/PauseMenuState.cpp | 0 .../source}/states/SettingsMenuState.cpp | 0 {source => common/source}/world/Block.cpp | 0 .../source}/world/BlockWater.cpp | 0 {source => common/source}/world/Chunk.cpp | 0 .../source}/world/ChunkBuilder.cpp | 0 .../source}/world/ChunkLightmap.cpp | 0 {source => common/source}/world/Player.cpp | 0 {source => common/source}/world/World.cpp | 0 .../source}/world/gen/TerrainGenerator.cpp | 0 server/CMakeLists.txt | 59 +++++++++++++++++++ server/source/main.cpp | 22 +++++++ 104 files changed, 190 insertions(+), 47 deletions(-) create mode 100644 client/CMakeLists.txt rename {source => client/source}/main.cpp (100%) create mode 100644 common/CMakeLists.txt rename {include => common/include}/core/Application.hpp (100%) rename {include => common/include}/core/Color.hpp (100%) rename {include => common/include}/core/Config.hpp (100%) rename {include => common/include}/core/Registry.hpp (100%) rename {include => common/include}/core/input/GameKey.hpp (100%) rename {include => common/include}/core/input/KeyboardHandler.hpp (100%) rename {include => common/include}/display/Skybox.hpp (100%) rename {include => common/include}/gui/CraftingWidget.hpp (100%) rename {include => common/include}/gui/Cube.hpp (100%) rename {include => common/include}/gui/FurnaceWidget.hpp (100%) rename {include => common/include}/gui/InventoryWidget.hpp (100%) rename {include => common/include}/gui/ItemWidget.hpp (100%) rename {include => common/include}/gui/MenuWidget.hpp (100%) rename {include => common/include}/gui/MouseItemWidget.hpp (100%) rename {include => common/include}/gui/PlayerInventoryWidget.hpp (100%) rename {include => common/include}/gui/Text.hpp (100%) rename {include => common/include}/gui/TextButton.hpp (100%) rename {include => common/include}/gui/Widget.hpp (100%) rename {include => common/include}/hud/BlockCursor.hpp (100%) rename {include => common/include}/hud/BlockInfoWidget.hpp (100%) rename {include => common/include}/hud/Crosshair.hpp (100%) rename {include => common/include}/hud/DebugOverlay.hpp (100%) rename {include => common/include}/hud/HUD.hpp (100%) rename {include => common/include}/hud/Hotbar.hpp (100%) rename {include => common/include}/inventory/BlockType.hpp (100%) rename {include => common/include}/inventory/CraftingRecipe.hpp (100%) rename {include => common/include}/inventory/Inventory.hpp (100%) rename {include => common/include}/inventory/Item.hpp (100%) rename {include => common/include}/inventory/ItemStack.hpp (100%) rename {include => common/include}/inventory/ItemType.hpp (100%) rename {include => common/include}/inventory/Recipe.hpp (100%) rename {include => common/include}/inventory/SmeltingRecipe.hpp (100%) rename {include => common/include}/lua/LuaCore.hpp (100%) rename {include => common/include}/lua/LuaGUI.hpp (100%) rename {include => common/include}/lua/LuaMod.hpp (100%) rename {include => common/include}/lua/LuaWidgetDef.hpp (100%) rename {include => common/include}/lua/ScriptEngine.hpp (100%) rename {include => common/include}/resource/TextureLoader.hpp (100%) rename {include => common/include}/states/GameState.hpp (100%) rename {include => common/include}/states/InventoryState.hpp (100%) rename {include => common/include}/states/LuaGUIState.hpp (100%) rename {include => common/include}/states/PauseMenuState.hpp (100%) rename {include => common/include}/states/SettingsMenuState.hpp (100%) rename {include => common/include}/world/Block.hpp (100%) rename {include => common/include}/world/BlockData.hpp (100%) rename {include => common/include}/world/BlockWater.hpp (100%) rename {include => common/include}/world/Chunk.hpp (100%) rename {include => common/include}/world/ChunkBuilder.hpp (100%) rename {include => common/include}/world/ChunkLightmap.hpp (100%) rename {include => common/include}/world/Player.hpp (100%) rename {include => common/include}/world/World.hpp (100%) rename {include => common/include}/world/gen/TerrainGenerator.hpp (100%) rename {source => common/source}/core/Application.cpp (100%) rename {source => common/source}/core/Config.cpp (100%) rename {source => common/source}/core/Registry.cpp (100%) rename {source => common/source}/core/input/KeyboardHandler.cpp (100%) rename {source => common/source}/display/Skybox.cpp (100%) rename {source => common/source}/gui/CraftingWidget.cpp (100%) rename {source => common/source}/gui/Cube.cpp (100%) rename {source => common/source}/gui/FurnaceWidget.cpp (100%) rename {source => common/source}/gui/InventoryWidget.cpp (100%) rename {source => common/source}/gui/ItemWidget.cpp (100%) rename {source => common/source}/gui/MenuWidget.cpp (100%) rename {source => common/source}/gui/MouseItemWidget.cpp (100%) rename {source => common/source}/gui/PlayerInventoryWidget.cpp (100%) rename {source => common/source}/gui/Text.cpp (100%) rename {source => common/source}/gui/TextButton.cpp (100%) rename {source => common/source}/gui/Widget.cpp (100%) rename {source => common/source}/hud/BlockCursor.cpp (100%) rename {source => common/source}/hud/BlockInfoWidget.cpp (100%) rename {source => common/source}/hud/Crosshair.cpp (100%) rename {source => common/source}/hud/DebugOverlay.cpp (100%) rename {source => common/source}/hud/HUD.cpp (100%) rename {source => common/source}/hud/Hotbar.cpp (100%) rename {source => common/source}/inventory/CraftingRecipe.cpp (100%) rename {source => common/source}/inventory/Inventory.cpp (100%) rename {source => common/source}/inventory/Item.cpp (100%) rename {source => common/source}/inventory/ItemStack.cpp (100%) rename {source => common/source}/inventory/SmeltingRecipe.cpp (100%) rename {source => common/source}/lua/LuaCore.cpp (100%) rename {source => common/source}/lua/LuaGUI.cpp (100%) rename {source => common/source}/lua/LuaMod.cpp (100%) rename {source => common/source}/lua/ScriptEngine.cpp (100%) rename {source => common/source}/resource/TextureLoader.cpp (100%) rename {source => common/source}/states/GameState.cpp (100%) rename {source => common/source}/states/InventoryState.cpp (100%) rename {source => common/source}/states/LuaGUIState.cpp (100%) rename {source => common/source}/states/PauseMenuState.cpp (100%) rename {source => common/source}/states/SettingsMenuState.cpp (100%) rename {source => common/source}/world/Block.cpp (100%) rename {source => common/source}/world/BlockWater.cpp (100%) rename {source => common/source}/world/Chunk.cpp (100%) rename {source => common/source}/world/ChunkBuilder.cpp (100%) rename {source => common/source}/world/ChunkLightmap.cpp (100%) rename {source => common/source}/world/Player.cpp (100%) rename {source => common/source}/world/World.cpp (100%) rename {source => common/source}/world/gen/TerrainGenerator.cpp (100%) create mode 100644 server/CMakeLists.txt create mode 100644 server/source/main.cpp diff --git a/.gitignore b/.gitignore index d98c2847..de6a9cd6 100644 --- a/.gitignore +++ b/.gitignore @@ -30,7 +30,8 @@ doc/html doc/latex # Binaries -OpenMiner +client/openminer +server/openminer_server *.exe # Misc diff --git a/CMakeLists.txt b/CMakeLists.txt index a680839a..af9d27e9 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -3,46 +3,12 @@ #------------------------------------------------------------------------------ cmake_minimum_required(VERSION 3.1) -project(OpenMiner VERSION 0.0.1 LANGUAGES CXX) +project(openminer) set(CMAKE_EXPORT_COMPILE_COMMANDS ON) list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/cmake") -#------------------------------------------------------------------------------ -# Get source files -#------------------------------------------------------------------------------ -file(GLOB_RECURSE SOURCE_FILES source/*.cpp external/*.cpp) -file(GLOB_RECURSE HEADER_FILES include/*.hpp external/*.hpp) - -foreach(HEADER_FILE ${HEADER_FILES}) - get_filename_component(HEADER_DIRECTORY ${HEADER_FILE} DIRECTORY) - include_directories(${HEADER_DIRECTORY}) -endforeach(HEADER_FILE) - -#------------------------------------------------------------------------------ -# Create executable target -#------------------------------------------------------------------------------ -add_executable(${CMAKE_PROJECT_NAME} ${SOURCE_FILES}) - -#------------------------------------------------------------------------------ -# Compiler flags -#------------------------------------------------------------------------------ -target_compile_options(${CMAKE_PROJECT_NAME} PRIVATE -O3 -ffast-math) -target_compile_options(${CMAKE_PROJECT_NAME} PRIVATE -g -Wall -Wextra -Wfatal-errors -Wno-variadic-macros) -target_compile_options(${CMAKE_PROJECT_NAME} PRIVATE -DDEBUG_ENABLED) -target_compile_options(${CMAKE_PROJECT_NAME} PRIVATE -DSOL_CHECK_ARGUMENTS - # -DSOL_SAFE_USERTYPE=1 - # -DSOL_SAFE_REFERENCES=1 - # -DSOL_SAFE_FUNCTION_CALLS=1 - # -DSOL_SAFE_FUNCTION=1 - # -DSOL_SAFE_NUMERICS=1 - # -DSOL_SAFE_GETTER=1 - # -DSOL_PRINT_ERRORS=1 -) - -target_compile_features(${CMAKE_PROJECT_NAME} PRIVATE cxx_std_17) - #------------------------------------------------------------------------------ # Packages #------------------------------------------------------------------------------ @@ -138,16 +104,9 @@ endif() include_directories(${SFML_INCLUDE_DIRS}) #------------------------------------------------------------------------------ -# Link options +# Subdirectories #------------------------------------------------------------------------------ -target_link_libraries(${CMAKE_PROJECT_NAME} - ${LUA_LIBRARIES} - ${GAMEKIT_LIBRARIES} - ${TINYXML2_LIBRARIES} - ${OPENGL_LIBRARIES} - ${SDL2_LIBRARIES} - ${SDL2IMAGE_LIBRARIES} - ${SDL2MIXER_LIBRARIES} - ${SDL2TTF_LIBRARIES} - sfml-network) +add_subdirectory(common) +add_subdirectory(client) +add_subdirectory(server) diff --git a/client/CMakeLists.txt b/client/CMakeLists.txt new file mode 100644 index 00000000..c8add9cd --- /dev/null +++ b/client/CMakeLists.txt @@ -0,0 +1,59 @@ +#------------------------------------------------------------------------------ +# CMakeLists.txt +#------------------------------------------------------------------------------ +cmake_minimum_required(VERSION 2.8) + +project(openminer) + +set(CMAKE_EXPORT_COMPILE_COMMANDS ON) + +#------------------------------------------------------------------------------ +# Get source files +#------------------------------------------------------------------------------ +file(GLOB_RECURSE SOURCE_FILES source/*.cpp) +file(GLOB_RECURSE HEADER_FILES include/*.hpp ../common/*.hpp ../external/*.hpp) + +foreach(HEADER_FILE ${HEADER_FILES}) + get_filename_component(HEADER_DIRECTORY ${HEADER_FILE} DIRECTORY) + include_directories(${HEADER_DIRECTORY}) +endforeach(HEADER_FILE) + +#------------------------------------------------------------------------------ +# Add executables +#------------------------------------------------------------------------------ +add_executable(${CMAKE_PROJECT_NAME} ${SOURCE_FILES}) +add_dependencies(${CMAKE_PROJECT_NAME} ${CMAKE_PROJECT_NAME}_common) + +#------------------------------------------------------------------------------ +# Compiler flags +#------------------------------------------------------------------------------ +target_compile_options(${CMAKE_PROJECT_NAME} PRIVATE -O3 -ffast-math) +target_compile_options(${CMAKE_PROJECT_NAME} PRIVATE -g -Wall -Wextra -Wfatal-errors -Wno-variadic-macros) +target_compile_options(${CMAKE_PROJECT_NAME} PRIVATE -DDEBUG_ENABLED) +target_compile_options(${CMAKE_PROJECT_NAME} PRIVATE -DSOL_CHECK_ARGUMENTS + # -DSOL_SAFE_USERTYPE=1 + # -DSOL_SAFE_REFERENCES=1 + # -DSOL_SAFE_FUNCTION_CALLS=1 + # -DSOL_SAFE_FUNCTION=1 + # -DSOL_SAFE_NUMERICS=1 + # -DSOL_SAFE_GETTER=1 + # -DSOL_PRINT_ERRORS=1 +) + +target_compile_features(${CMAKE_PROJECT_NAME} PRIVATE cxx_std_17) + +#------------------------------------------------------------------------------ +# Link options +#------------------------------------------------------------------------------ +target_link_libraries(${CMAKE_PROJECT_NAME} + ${OPENGL_LIBRARIES} + ${SDL2_LIBRARIES} + ${SDL2IMAGE_LIBRARIES} + ${SDL2MIXER_LIBRARIES} + ${SDL2TTF_LIBRARIES} + ${TINYXML2_LIBRARIES} + ${GAMEKIT_LIBRARIES} + ${LUA_LIBRARIES} + sfml-network + ${CMAKE_PROJECT_NAME}_common) + diff --git a/source/main.cpp b/client/source/main.cpp similarity index 100% rename from source/main.cpp rename to client/source/main.cpp diff --git a/common/CMakeLists.txt b/common/CMakeLists.txt new file mode 100644 index 00000000..11719da2 --- /dev/null +++ b/common/CMakeLists.txt @@ -0,0 +1,43 @@ +#------------------------------------------------------------------------------ +# CMakeLists.txt +#------------------------------------------------------------------------------ +cmake_minimum_required(VERSION 2.8) + +project(openminer) + +set(CMAKE_EXPORT_COMPILE_COMMANDS ON) + +#------------------------------------------------------------------------------ +# Get source files +#------------------------------------------------------------------------------ +file(GLOB_RECURSE SOURCE_FILES source/*.cpp) +file(GLOB_RECURSE HEADER_FILES include/*.hpp ../external/*.hpp) + +foreach(HEADER_FILE ${HEADER_FILES}) + get_filename_component(HEADER_DIRECTORY ${HEADER_FILE} DIRECTORY) + include_directories(${HEADER_DIRECTORY}) +endforeach(HEADER_FILE) + +#------------------------------------------------------------------------------ +# Add library +#------------------------------------------------------------------------------ +add_library(${CMAKE_PROJECT_NAME}_common STATIC ${SOURCE_FILES}) + +#------------------------------------------------------------------------------ +# Compiler flags +#------------------------------------------------------------------------------ +target_compile_options(${CMAKE_PROJECT_NAME}_common PRIVATE -O3 -ffast-math) +target_compile_options(${CMAKE_PROJECT_NAME}_common PRIVATE -g -Wall -Wextra -Wfatal-errors -Wno-variadic-macros) +target_compile_options(${CMAKE_PROJECT_NAME}_common PRIVATE -DDEBUG_ENABLED) +target_compile_options(${CMAKE_PROJECT_NAME}_common PRIVATE -DSOL_CHECK_ARGUMENTS + # -DSOL_SAFE_USERTYPE=1 + # -DSOL_SAFE_REFERENCES=1 + # -DSOL_SAFE_FUNCTION_CALLS=1 + # -DSOL_SAFE_FUNCTION=1 + # -DSOL_SAFE_NUMERICS=1 + # -DSOL_SAFE_GETTER=1 + # -DSOL_PRINT_ERRORS=1 +) + +target_compile_features(${CMAKE_PROJECT_NAME}_common PRIVATE cxx_std_17) + diff --git a/include/core/Application.hpp b/common/include/core/Application.hpp similarity index 100% rename from include/core/Application.hpp rename to common/include/core/Application.hpp diff --git a/include/core/Color.hpp b/common/include/core/Color.hpp similarity index 100% rename from include/core/Color.hpp rename to common/include/core/Color.hpp diff --git a/include/core/Config.hpp b/common/include/core/Config.hpp similarity index 100% rename from include/core/Config.hpp rename to common/include/core/Config.hpp diff --git a/include/core/Registry.hpp b/common/include/core/Registry.hpp similarity index 100% rename from include/core/Registry.hpp rename to common/include/core/Registry.hpp diff --git a/include/core/input/GameKey.hpp b/common/include/core/input/GameKey.hpp similarity index 100% rename from include/core/input/GameKey.hpp rename to common/include/core/input/GameKey.hpp diff --git a/include/core/input/KeyboardHandler.hpp b/common/include/core/input/KeyboardHandler.hpp similarity index 100% rename from include/core/input/KeyboardHandler.hpp rename to common/include/core/input/KeyboardHandler.hpp diff --git a/include/display/Skybox.hpp b/common/include/display/Skybox.hpp similarity index 100% rename from include/display/Skybox.hpp rename to common/include/display/Skybox.hpp diff --git a/include/gui/CraftingWidget.hpp b/common/include/gui/CraftingWidget.hpp similarity index 100% rename from include/gui/CraftingWidget.hpp rename to common/include/gui/CraftingWidget.hpp diff --git a/include/gui/Cube.hpp b/common/include/gui/Cube.hpp similarity index 100% rename from include/gui/Cube.hpp rename to common/include/gui/Cube.hpp diff --git a/include/gui/FurnaceWidget.hpp b/common/include/gui/FurnaceWidget.hpp similarity index 100% rename from include/gui/FurnaceWidget.hpp rename to common/include/gui/FurnaceWidget.hpp diff --git a/include/gui/InventoryWidget.hpp b/common/include/gui/InventoryWidget.hpp similarity index 100% rename from include/gui/InventoryWidget.hpp rename to common/include/gui/InventoryWidget.hpp diff --git a/include/gui/ItemWidget.hpp b/common/include/gui/ItemWidget.hpp similarity index 100% rename from include/gui/ItemWidget.hpp rename to common/include/gui/ItemWidget.hpp diff --git a/include/gui/MenuWidget.hpp b/common/include/gui/MenuWidget.hpp similarity index 100% rename from include/gui/MenuWidget.hpp rename to common/include/gui/MenuWidget.hpp diff --git a/include/gui/MouseItemWidget.hpp b/common/include/gui/MouseItemWidget.hpp similarity index 100% rename from include/gui/MouseItemWidget.hpp rename to common/include/gui/MouseItemWidget.hpp diff --git a/include/gui/PlayerInventoryWidget.hpp b/common/include/gui/PlayerInventoryWidget.hpp similarity index 100% rename from include/gui/PlayerInventoryWidget.hpp rename to common/include/gui/PlayerInventoryWidget.hpp diff --git a/include/gui/Text.hpp b/common/include/gui/Text.hpp similarity index 100% rename from include/gui/Text.hpp rename to common/include/gui/Text.hpp diff --git a/include/gui/TextButton.hpp b/common/include/gui/TextButton.hpp similarity index 100% rename from include/gui/TextButton.hpp rename to common/include/gui/TextButton.hpp diff --git a/include/gui/Widget.hpp b/common/include/gui/Widget.hpp similarity index 100% rename from include/gui/Widget.hpp rename to common/include/gui/Widget.hpp diff --git a/include/hud/BlockCursor.hpp b/common/include/hud/BlockCursor.hpp similarity index 100% rename from include/hud/BlockCursor.hpp rename to common/include/hud/BlockCursor.hpp diff --git a/include/hud/BlockInfoWidget.hpp b/common/include/hud/BlockInfoWidget.hpp similarity index 100% rename from include/hud/BlockInfoWidget.hpp rename to common/include/hud/BlockInfoWidget.hpp diff --git a/include/hud/Crosshair.hpp b/common/include/hud/Crosshair.hpp similarity index 100% rename from include/hud/Crosshair.hpp rename to common/include/hud/Crosshair.hpp diff --git a/include/hud/DebugOverlay.hpp b/common/include/hud/DebugOverlay.hpp similarity index 100% rename from include/hud/DebugOverlay.hpp rename to common/include/hud/DebugOverlay.hpp diff --git a/include/hud/HUD.hpp b/common/include/hud/HUD.hpp similarity index 100% rename from include/hud/HUD.hpp rename to common/include/hud/HUD.hpp diff --git a/include/hud/Hotbar.hpp b/common/include/hud/Hotbar.hpp similarity index 100% rename from include/hud/Hotbar.hpp rename to common/include/hud/Hotbar.hpp diff --git a/include/inventory/BlockType.hpp b/common/include/inventory/BlockType.hpp similarity index 100% rename from include/inventory/BlockType.hpp rename to common/include/inventory/BlockType.hpp diff --git a/include/inventory/CraftingRecipe.hpp b/common/include/inventory/CraftingRecipe.hpp similarity index 100% rename from include/inventory/CraftingRecipe.hpp rename to common/include/inventory/CraftingRecipe.hpp diff --git a/include/inventory/Inventory.hpp b/common/include/inventory/Inventory.hpp similarity index 100% rename from include/inventory/Inventory.hpp rename to common/include/inventory/Inventory.hpp diff --git a/include/inventory/Item.hpp b/common/include/inventory/Item.hpp similarity index 100% rename from include/inventory/Item.hpp rename to common/include/inventory/Item.hpp diff --git a/include/inventory/ItemStack.hpp b/common/include/inventory/ItemStack.hpp similarity index 100% rename from include/inventory/ItemStack.hpp rename to common/include/inventory/ItemStack.hpp diff --git a/include/inventory/ItemType.hpp b/common/include/inventory/ItemType.hpp similarity index 100% rename from include/inventory/ItemType.hpp rename to common/include/inventory/ItemType.hpp diff --git a/include/inventory/Recipe.hpp b/common/include/inventory/Recipe.hpp similarity index 100% rename from include/inventory/Recipe.hpp rename to common/include/inventory/Recipe.hpp diff --git a/include/inventory/SmeltingRecipe.hpp b/common/include/inventory/SmeltingRecipe.hpp similarity index 100% rename from include/inventory/SmeltingRecipe.hpp rename to common/include/inventory/SmeltingRecipe.hpp diff --git a/include/lua/LuaCore.hpp b/common/include/lua/LuaCore.hpp similarity index 100% rename from include/lua/LuaCore.hpp rename to common/include/lua/LuaCore.hpp diff --git a/include/lua/LuaGUI.hpp b/common/include/lua/LuaGUI.hpp similarity index 100% rename from include/lua/LuaGUI.hpp rename to common/include/lua/LuaGUI.hpp diff --git a/include/lua/LuaMod.hpp b/common/include/lua/LuaMod.hpp similarity index 100% rename from include/lua/LuaMod.hpp rename to common/include/lua/LuaMod.hpp diff --git a/include/lua/LuaWidgetDef.hpp b/common/include/lua/LuaWidgetDef.hpp similarity index 100% rename from include/lua/LuaWidgetDef.hpp rename to common/include/lua/LuaWidgetDef.hpp diff --git a/include/lua/ScriptEngine.hpp b/common/include/lua/ScriptEngine.hpp similarity index 100% rename from include/lua/ScriptEngine.hpp rename to common/include/lua/ScriptEngine.hpp diff --git a/include/resource/TextureLoader.hpp b/common/include/resource/TextureLoader.hpp similarity index 100% rename from include/resource/TextureLoader.hpp rename to common/include/resource/TextureLoader.hpp diff --git a/include/states/GameState.hpp b/common/include/states/GameState.hpp similarity index 100% rename from include/states/GameState.hpp rename to common/include/states/GameState.hpp diff --git a/include/states/InventoryState.hpp b/common/include/states/InventoryState.hpp similarity index 100% rename from include/states/InventoryState.hpp rename to common/include/states/InventoryState.hpp diff --git a/include/states/LuaGUIState.hpp b/common/include/states/LuaGUIState.hpp similarity index 100% rename from include/states/LuaGUIState.hpp rename to common/include/states/LuaGUIState.hpp diff --git a/include/states/PauseMenuState.hpp b/common/include/states/PauseMenuState.hpp similarity index 100% rename from include/states/PauseMenuState.hpp rename to common/include/states/PauseMenuState.hpp diff --git a/include/states/SettingsMenuState.hpp b/common/include/states/SettingsMenuState.hpp similarity index 100% rename from include/states/SettingsMenuState.hpp rename to common/include/states/SettingsMenuState.hpp diff --git a/include/world/Block.hpp b/common/include/world/Block.hpp similarity index 100% rename from include/world/Block.hpp rename to common/include/world/Block.hpp diff --git a/include/world/BlockData.hpp b/common/include/world/BlockData.hpp similarity index 100% rename from include/world/BlockData.hpp rename to common/include/world/BlockData.hpp diff --git a/include/world/BlockWater.hpp b/common/include/world/BlockWater.hpp similarity index 100% rename from include/world/BlockWater.hpp rename to common/include/world/BlockWater.hpp diff --git a/include/world/Chunk.hpp b/common/include/world/Chunk.hpp similarity index 100% rename from include/world/Chunk.hpp rename to common/include/world/Chunk.hpp diff --git a/include/world/ChunkBuilder.hpp b/common/include/world/ChunkBuilder.hpp similarity index 100% rename from include/world/ChunkBuilder.hpp rename to common/include/world/ChunkBuilder.hpp diff --git a/include/world/ChunkLightmap.hpp b/common/include/world/ChunkLightmap.hpp similarity index 100% rename from include/world/ChunkLightmap.hpp rename to common/include/world/ChunkLightmap.hpp diff --git a/include/world/Player.hpp b/common/include/world/Player.hpp similarity index 100% rename from include/world/Player.hpp rename to common/include/world/Player.hpp diff --git a/include/world/World.hpp b/common/include/world/World.hpp similarity index 100% rename from include/world/World.hpp rename to common/include/world/World.hpp diff --git a/include/world/gen/TerrainGenerator.hpp b/common/include/world/gen/TerrainGenerator.hpp similarity index 100% rename from include/world/gen/TerrainGenerator.hpp rename to common/include/world/gen/TerrainGenerator.hpp diff --git a/source/core/Application.cpp b/common/source/core/Application.cpp similarity index 100% rename from source/core/Application.cpp rename to common/source/core/Application.cpp diff --git a/source/core/Config.cpp b/common/source/core/Config.cpp similarity index 100% rename from source/core/Config.cpp rename to common/source/core/Config.cpp diff --git a/source/core/Registry.cpp b/common/source/core/Registry.cpp similarity index 100% rename from source/core/Registry.cpp rename to common/source/core/Registry.cpp diff --git a/source/core/input/KeyboardHandler.cpp b/common/source/core/input/KeyboardHandler.cpp similarity index 100% rename from source/core/input/KeyboardHandler.cpp rename to common/source/core/input/KeyboardHandler.cpp diff --git a/source/display/Skybox.cpp b/common/source/display/Skybox.cpp similarity index 100% rename from source/display/Skybox.cpp rename to common/source/display/Skybox.cpp diff --git a/source/gui/CraftingWidget.cpp b/common/source/gui/CraftingWidget.cpp similarity index 100% rename from source/gui/CraftingWidget.cpp rename to common/source/gui/CraftingWidget.cpp diff --git a/source/gui/Cube.cpp b/common/source/gui/Cube.cpp similarity index 100% rename from source/gui/Cube.cpp rename to common/source/gui/Cube.cpp diff --git a/source/gui/FurnaceWidget.cpp b/common/source/gui/FurnaceWidget.cpp similarity index 100% rename from source/gui/FurnaceWidget.cpp rename to common/source/gui/FurnaceWidget.cpp diff --git a/source/gui/InventoryWidget.cpp b/common/source/gui/InventoryWidget.cpp similarity index 100% rename from source/gui/InventoryWidget.cpp rename to common/source/gui/InventoryWidget.cpp diff --git a/source/gui/ItemWidget.cpp b/common/source/gui/ItemWidget.cpp similarity index 100% rename from source/gui/ItemWidget.cpp rename to common/source/gui/ItemWidget.cpp diff --git a/source/gui/MenuWidget.cpp b/common/source/gui/MenuWidget.cpp similarity index 100% rename from source/gui/MenuWidget.cpp rename to common/source/gui/MenuWidget.cpp diff --git a/source/gui/MouseItemWidget.cpp b/common/source/gui/MouseItemWidget.cpp similarity index 100% rename from source/gui/MouseItemWidget.cpp rename to common/source/gui/MouseItemWidget.cpp diff --git a/source/gui/PlayerInventoryWidget.cpp b/common/source/gui/PlayerInventoryWidget.cpp similarity index 100% rename from source/gui/PlayerInventoryWidget.cpp rename to common/source/gui/PlayerInventoryWidget.cpp diff --git a/source/gui/Text.cpp b/common/source/gui/Text.cpp similarity index 100% rename from source/gui/Text.cpp rename to common/source/gui/Text.cpp diff --git a/source/gui/TextButton.cpp b/common/source/gui/TextButton.cpp similarity index 100% rename from source/gui/TextButton.cpp rename to common/source/gui/TextButton.cpp diff --git a/source/gui/Widget.cpp b/common/source/gui/Widget.cpp similarity index 100% rename from source/gui/Widget.cpp rename to common/source/gui/Widget.cpp diff --git a/source/hud/BlockCursor.cpp b/common/source/hud/BlockCursor.cpp similarity index 100% rename from source/hud/BlockCursor.cpp rename to common/source/hud/BlockCursor.cpp diff --git a/source/hud/BlockInfoWidget.cpp b/common/source/hud/BlockInfoWidget.cpp similarity index 100% rename from source/hud/BlockInfoWidget.cpp rename to common/source/hud/BlockInfoWidget.cpp diff --git a/source/hud/Crosshair.cpp b/common/source/hud/Crosshair.cpp similarity index 100% rename from source/hud/Crosshair.cpp rename to common/source/hud/Crosshair.cpp diff --git a/source/hud/DebugOverlay.cpp b/common/source/hud/DebugOverlay.cpp similarity index 100% rename from source/hud/DebugOverlay.cpp rename to common/source/hud/DebugOverlay.cpp diff --git a/source/hud/HUD.cpp b/common/source/hud/HUD.cpp similarity index 100% rename from source/hud/HUD.cpp rename to common/source/hud/HUD.cpp diff --git a/source/hud/Hotbar.cpp b/common/source/hud/Hotbar.cpp similarity index 100% rename from source/hud/Hotbar.cpp rename to common/source/hud/Hotbar.cpp diff --git a/source/inventory/CraftingRecipe.cpp b/common/source/inventory/CraftingRecipe.cpp similarity index 100% rename from source/inventory/CraftingRecipe.cpp rename to common/source/inventory/CraftingRecipe.cpp diff --git a/source/inventory/Inventory.cpp b/common/source/inventory/Inventory.cpp similarity index 100% rename from source/inventory/Inventory.cpp rename to common/source/inventory/Inventory.cpp diff --git a/source/inventory/Item.cpp b/common/source/inventory/Item.cpp similarity index 100% rename from source/inventory/Item.cpp rename to common/source/inventory/Item.cpp diff --git a/source/inventory/ItemStack.cpp b/common/source/inventory/ItemStack.cpp similarity index 100% rename from source/inventory/ItemStack.cpp rename to common/source/inventory/ItemStack.cpp diff --git a/source/inventory/SmeltingRecipe.cpp b/common/source/inventory/SmeltingRecipe.cpp similarity index 100% rename from source/inventory/SmeltingRecipe.cpp rename to common/source/inventory/SmeltingRecipe.cpp diff --git a/source/lua/LuaCore.cpp b/common/source/lua/LuaCore.cpp similarity index 100% rename from source/lua/LuaCore.cpp rename to common/source/lua/LuaCore.cpp diff --git a/source/lua/LuaGUI.cpp b/common/source/lua/LuaGUI.cpp similarity index 100% rename from source/lua/LuaGUI.cpp rename to common/source/lua/LuaGUI.cpp diff --git a/source/lua/LuaMod.cpp b/common/source/lua/LuaMod.cpp similarity index 100% rename from source/lua/LuaMod.cpp rename to common/source/lua/LuaMod.cpp diff --git a/source/lua/ScriptEngine.cpp b/common/source/lua/ScriptEngine.cpp similarity index 100% rename from source/lua/ScriptEngine.cpp rename to common/source/lua/ScriptEngine.cpp diff --git a/source/resource/TextureLoader.cpp b/common/source/resource/TextureLoader.cpp similarity index 100% rename from source/resource/TextureLoader.cpp rename to common/source/resource/TextureLoader.cpp diff --git a/source/states/GameState.cpp b/common/source/states/GameState.cpp similarity index 100% rename from source/states/GameState.cpp rename to common/source/states/GameState.cpp diff --git a/source/states/InventoryState.cpp b/common/source/states/InventoryState.cpp similarity index 100% rename from source/states/InventoryState.cpp rename to common/source/states/InventoryState.cpp diff --git a/source/states/LuaGUIState.cpp b/common/source/states/LuaGUIState.cpp similarity index 100% rename from source/states/LuaGUIState.cpp rename to common/source/states/LuaGUIState.cpp diff --git a/source/states/PauseMenuState.cpp b/common/source/states/PauseMenuState.cpp similarity index 100% rename from source/states/PauseMenuState.cpp rename to common/source/states/PauseMenuState.cpp diff --git a/source/states/SettingsMenuState.cpp b/common/source/states/SettingsMenuState.cpp similarity index 100% rename from source/states/SettingsMenuState.cpp rename to common/source/states/SettingsMenuState.cpp diff --git a/source/world/Block.cpp b/common/source/world/Block.cpp similarity index 100% rename from source/world/Block.cpp rename to common/source/world/Block.cpp diff --git a/source/world/BlockWater.cpp b/common/source/world/BlockWater.cpp similarity index 100% rename from source/world/BlockWater.cpp rename to common/source/world/BlockWater.cpp diff --git a/source/world/Chunk.cpp b/common/source/world/Chunk.cpp similarity index 100% rename from source/world/Chunk.cpp rename to common/source/world/Chunk.cpp diff --git a/source/world/ChunkBuilder.cpp b/common/source/world/ChunkBuilder.cpp similarity index 100% rename from source/world/ChunkBuilder.cpp rename to common/source/world/ChunkBuilder.cpp diff --git a/source/world/ChunkLightmap.cpp b/common/source/world/ChunkLightmap.cpp similarity index 100% rename from source/world/ChunkLightmap.cpp rename to common/source/world/ChunkLightmap.cpp diff --git a/source/world/Player.cpp b/common/source/world/Player.cpp similarity index 100% rename from source/world/Player.cpp rename to common/source/world/Player.cpp diff --git a/source/world/World.cpp b/common/source/world/World.cpp similarity index 100% rename from source/world/World.cpp rename to common/source/world/World.cpp diff --git a/source/world/gen/TerrainGenerator.cpp b/common/source/world/gen/TerrainGenerator.cpp similarity index 100% rename from source/world/gen/TerrainGenerator.cpp rename to common/source/world/gen/TerrainGenerator.cpp diff --git a/server/CMakeLists.txt b/server/CMakeLists.txt new file mode 100644 index 00000000..1e44205d --- /dev/null +++ b/server/CMakeLists.txt @@ -0,0 +1,59 @@ +#------------------------------------------------------------------------------ +# CMakeLists.txt +#------------------------------------------------------------------------------ +cmake_minimum_required(VERSION 2.8) + +project(openminer) + +set(CMAKE_EXPORT_COMPILE_COMMANDS ON) + +#------------------------------------------------------------------------------ +# Get source files +#------------------------------------------------------------------------------ +file(GLOB_RECURSE SOURCE_FILES source/*.cpp) +file(GLOB_RECURSE HEADER_FILES include/*.hpp ../common/*.hpp ../external/*.hpp) + +foreach(HEADER_FILE ${HEADER_FILES}) + get_filename_component(HEADER_DIRECTORY ${HEADER_FILE} DIRECTORY) + include_directories(${HEADER_DIRECTORY}) +endforeach(HEADER_FILE) + +#------------------------------------------------------------------------------ +# Add executables +#------------------------------------------------------------------------------ +add_executable(${CMAKE_PROJECT_NAME}_server ${SOURCE_FILES}) +add_dependencies(${CMAKE_PROJECT_NAME}_server ${CMAKE_PROJECT_NAME}_common) + +#------------------------------------------------------------------------------ +# Compiler flags +#------------------------------------------------------------------------------ +target_compile_options(${CMAKE_PROJECT_NAME}_server PRIVATE -O3 -ffast-math) +target_compile_options(${CMAKE_PROJECT_NAME}_server PRIVATE -g -Wall -Wextra -Wfatal-errors -Wno-variadic-macros) +target_compile_options(${CMAKE_PROJECT_NAME}_server PRIVATE -DDEBUG_ENABLED) +target_compile_options(${CMAKE_PROJECT_NAME}_server PRIVATE -DSOL_CHECK_ARGUMENTS + # -DSOL_SAFE_USERTYPE=1 + # -DSOL_SAFE_REFERENCES=1 + # -DSOL_SAFE_FUNCTION_CALLS=1 + # -DSOL_SAFE_FUNCTION=1 + # -DSOL_SAFE_NUMERICS=1 + # -DSOL_SAFE_GETTER=1 + # -DSOL_PRINT_ERRORS=1 +) + +target_compile_features(${CMAKE_PROJECT_NAME}_server PRIVATE cxx_std_17) + +#------------------------------------------------------------------------------ +# Link options +#------------------------------------------------------------------------------ +target_link_libraries(${CMAKE_PROJECT_NAME}_server + ${OPENGL_LIBRARIES} + ${SDL2_LIBRARIES} + ${SDL2IMAGE_LIBRARIES} + ${SDL2MIXER_LIBRARIES} + ${SDL2TTF_LIBRARIES} + ${TINYXML2_LIBRARIES} + ${GAMEKIT_LIBRARIES} + ${LUA_LIBRARIES} + sfml-network + ${CMAKE_PROJECT_NAME}_common) + diff --git a/server/source/main.cpp b/server/source/main.cpp new file mode 100644 index 00000000..0c27986f --- /dev/null +++ b/server/source/main.cpp @@ -0,0 +1,22 @@ +/* + * ===================================================================================== + * + * Filename: main.cpp + * + * Description: + * + * Created: 13/12/2014 20:49:00 + * + * Author: Quentin Bazin, + * + * ===================================================================================== + */ +#include "Application.hpp" + +int main(int argc, char **argv) { + Application app(argc, argv); + app.run(); + + return 0; +} +