CMake fixes

master
SamCZ 2021-09-01 21:18:21 +02:00
parent c89a945363
commit 5364d12013
7 changed files with 71 additions and 353 deletions

View File

@ -6,6 +6,17 @@ set(CMAKE_CXX_STANDARD 17)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
set(CMAKE_CXX_EXTENSIONS OFF)
if(CMAKE_BUILD_TYPE STREQUAL "Debug")
set(ZP_BUILD_SHARED_LIBS ON)
else()
set(ZP_BUILD_SHARED_LIBS OFF)
endif()
if(ZP_BUILD_SHARED_LIBS)
set(BUILD_SHARED_LIBS ON)
set(RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR})
endif()
# Set warnings
if ((CMAKE_CXX_COMPILER_ID STREQUAL "GNU") OR (CMAKE_CXX_COMPILER_ID STREQUAL "Clang"))
add_compile_options(
@ -22,10 +33,29 @@ set(MAIN_EXEC_NAME "Zepha")
project(${PROJECT_NAME})
set(CMAKE_POLICY_DEFAULT_CMP0077 NEW)
add_subdirectory(lib)
set(BUILD_SHARED_LIBS OFF)
add_subdirectory(src)
file(GLOB_RECURSE SOURCE_FILES src/*.hpp src/*.cpp)
add_executable(${MAIN_EXEC_NAME} src/Main.cpp)
target_link_libraries(${MAIN_EXEC_NAME} Zepha_Core)
add_executable(${MAIN_EXEC_NAME} ${SOURCE_FILES})
target_include_directories(${MAIN_EXEC_NAME} PUBLIC src)
target_link_libraries(${MAIN_EXEC_NAME} PUBLIC glfw glm enet glad assimp FastNoise nothings-stb gzip cute_headers nlohmann_json)
target_link_libraries(${MAIN_EXEC_NAME} PUBLIC lua sol2)
if(WIN32)
target_link_libraries(${MAIN_EXEC_NAME} PUBLIC opengl32 gdi32)
endif()
if(WIN32)
foreach(DLL ${ZEPHA_DLL_TO_COPY})
add_custom_command(TARGET ${MAIN_EXEC_NAME} POST_BUILD
COMMAND "${CMAKE_COMMAND}" -E copy
${DLL}
${CMAKE_CURRENT_BINARY_DIR}
COMMENT "Copying dll ${DLL} to output directory")
endforeach(DLL)
endif(WIN32)

View File

@ -9,6 +9,9 @@ if(NOT TARGET glfw AND NOT PLATFORM_ANDROID)
set(GLFW_BUILD_DOCS OFF)
set(BUILD_SHARED_LIBS OFF)
set(GLFW_USE_HYBRID_HPG ON)
set(BUILD_SHARED_LIBS OFF)
add_subdirectory(glfw)
set_property(TARGET glfw PROPERTY FOLDER "GameLib")
endif()
@ -18,6 +21,7 @@ endif()
# Game mathematics library
#------------------------------
if(NOT TARGET glm)
set(BUILD_SHARED_LIBS OFF)
add_subdirectory(glm)
set_property(TARGET glm PROPERTY FOLDER "GameLib")
endif()
@ -27,6 +31,14 @@ endif()
# ENet reliable UDP networking library
#------------------------------
if(NOT TARGET enet)
if(ZP_BUILD_SHARED_LIBS)
set(ENET_STATIC OFF)
set(ENET_SHARED ON)
else()
set(ENET_STATIC ON)
set(ENET_SHARED OFF)
endif()
add_subdirectory(enet)
set_property(TARGET enet PROPERTY FOLDER "GameLib")
endif()
@ -36,6 +48,7 @@ endif()
# OpenGL
#------------------------------
if(NOT TARGET glad AND NOT PLATFORM_ANDROID)
set(BUILD_SHARED_LIBS OFF)
add_subdirectory(glad)
set_property(TARGET glad PROPERTY FOLDER "GameLib")
endif()
@ -61,7 +74,14 @@ if(NOT TARGET sol2)
set(SOL2_TESTS_EXAMPLES OFF)
set(SOL2_TESTS_INTEROP_EXAMPLES OFF)
set(BUILD_LUA_AS_DLL OFF)
set(SOL2_BUILD_LUA ON)
set(SOL2_BUILD_LUA OFF)
if(ZP_BUILD_SHARED_LIBS)
set(BUILD_SHARED_LIBS ON)
else()
set(BUILD_SHARED_LIBS OFF)
endif()
add_subdirectory(sol2)
set_property(TARGET sol2 PROPERTY FOLDER "GameLib")
endif()
@ -71,14 +91,12 @@ endif()
# Model loading library
#------------------------------
if(NOT TARGET assimp)
if (CMAKE_BUILD_TYPE STREQUAL Debug)
if(ZP_BUILD_SHARED_LIBS)
set(BUILD_SHARED_LIBS ON)
else()
set(BUILD_SHARED_LIBS OFF)
endif()
set(BUILD_SHARED_LIBS ON)
cmake_policy(SET CMP0077 NEW) # set() overrides option()
set(ASM686 OFF)
@ -153,8 +171,6 @@ if(NOT TARGET assimp)
endif(WIN32)
endif()
endif()
set(BUILD_SHARED_LIBS OFF)
endif()
#------------------------------
@ -162,6 +178,7 @@ endif()
# Modular node based noise generation library using SIMD, C++17 and templates
#------------------------------
if(NOT TARGET FastNoise)
set(BUILD_SHARED_LIBS OFF)
set(FASTNOISE2_NOISETOOL OFF)
add_subdirectory(FastNoise2)
endif()

View File

@ -1,338 +0,0 @@
add_library(Zepha_Core STATIC
client/Client.cpp
client/Client.h
client/conn/ClientNetworkInterpreter.cpp
client/conn/ClientNetworkInterpreter.h
client/conn/ServerConnection.cpp
client/conn/ServerConnection.h
client/entity/ParticleEntity.cpp
client/entity/ParticleEntity.h
client/entity/PlayerEntity.h
client/entity/WireframeEntity.cpp
client/entity/WireframeEntity.h
client/graph/Camera.cpp
client/graph/Camera.h
client/graph/Drawable.h
client/graph/DrawableGroup.cpp
client/graph/DrawableGroup.h
client/graph/Font.cpp
client/graph/Font.h
client/graph/mesh/ChunkMeshGenerator.cpp
client/graph/mesh/ChunkMeshGenerator.h
client/graph/mesh/ChunkRenderElem.h
client/graph/mesh/EntityMesh.cpp
client/graph/mesh/EntityMesh.h
client/graph/mesh/EntityVertex.h
client/graph/mesh/Mesh.cpp
client/graph/mesh/Mesh.h
client/graph/mesh/MeshChunk.cpp
client/graph/mesh/MeshChunk.h
client/graph/Model.cpp
client/graph/Model.h
client/graph/ModelAnimation.cpp
client/graph/ModelAnimation.h
client/graph/ModelBone.cpp
client/graph/ModelBone.h
client/graph/Renderer.cpp
client/graph/Renderer.h
client/graph/shader/BlurShader.cpp
client/graph/shader/BlurShader.h
client/graph/shader/EntityGeometryShader.cpp
client/graph/shader/EntityGeometryShader.h
client/graph/shader/GuiUniforms.h
client/graph/shader/LightingShader.cpp
client/graph/shader/LightingShader.h
client/graph/shader/Shader.cpp
client/graph/shader/Shader.h
client/graph/shader/SSAOShader.cpp
client/graph/shader/SSAOShader.h
client/graph/shader/WorldGeometryShader.cpp
client/graph/shader/WorldGeometryShader.h
client/graph/Texture.cpp
client/graph/Texture.h
client/gui/basic/GuiContainer.cpp
client/gui/basic/GuiContainer.h
client/gui/basic/GuiGraph.cpp
client/gui/basic/GuiGraph.h
client/gui/basic/GuiMeter.cpp
client/gui/basic/GuiMeter.h
client/gui/basic/GuiInventoryItem.cpp
client/gui/basic/GuiInventoryItem.h
client/gui/basic/GuiModel.cpp
client/gui/basic/GuiModel.h
client/gui/basic/GuiRect.cpp
client/gui/basic/GuiRect.h
client/gui/basic/GuiText.cpp
client/gui/basic/GuiText.h
client/gui/compound/GuiImageButton.cpp
client/gui/compound/GuiImageButton.h
client/gui/compound/GuiInventoryList.cpp
client/gui/compound/GuiInventoryList.h
client/gui/compound/GuiLabelledGraph.cpp
client/gui/compound/GuiLabelledGraph.cpp
client/gui/DebugGui.cpp
client/gui/DebugGui.h
client/gui/GameGui.cpp
client/gui/GameGui.h
client/gui/Element.cpp
client/gui/Element.h
client/Input.cpp
client/Input.h
client/LocalServerInstance.cpp
client/LocalServerInstance.h
client/menu/MenuSandbox.cpp
client/menu/MenuSandbox.h
client/menu/SubgameConfig.h
client/menu/SubgameDef.h
client/scene/ConnectScene.cpp
client/scene/ConnectScene.h
client/scene/GameScene.cpp
client/scene/GameScene.h
client/scene/LuaErrorScene.cpp
client/scene/LuaErrorScene.h
client/scene/MainMenuScene.cpp
client/scene/MainMenuScene.h
client/scene/Scene.h
client/scene/SceneManager.cpp
client/scene/SceneManager.h
client/stream/MeshChunkDetails.h
client/stream/MeshGenStream.cpp
client/stream/MeshGenStream.h
client/stream/WorldInterpolationStream.cpp
client/stream/WorldInterpolationStream.h
client/Window.cpp
client/Window.h
game/atlas/asset/AssetStorage.h
game/atlas/asset/AssetType.h
game/atlas/asset/AtlasRef.h
game/atlas/asset/ModelStore.h
game/atlas/asset/SerializedModel.h
game/atlas/asset/ServerTexture.h
game/atlas/BiomeAtlas.cpp
game/atlas/BiomeAtlas.h
game/atlas/DefinitionAtlas.cpp
game/atlas/DefinitionAtlas.h
game/atlas/LocalBiomeAtlas.cpp
game/atlas/LocalBiomeAtlas.h
game/atlas/LocalDefinitionAtlas.cpp
game/atlas/LocalDefinitionAtlas.h
game/atlas/ServerBiomeAtlas.cpp
game/atlas/ServerBiomeAtlas.h
game/atlas/ServerDefinitionAtlas.cpp
game/atlas/ServerDefinitionAtlas.h
game/atlas/TextureAtlas.cpp
game/atlas/TextureAtlas.h
game/def/BiomeDef.h
game/def/BlockDef.cpp
game/def/BlockDef.h
game/def/CraftItemDef.cpp
game/def/CraftItemDef.h
game/def/ItemDef.h
game/def/mesh/BlockModel.cpp
game/def/mesh/BlockModel.h
game/def/mesh/BlockModelVertex.h
game/def/mesh/MeshPart.cpp
game/def/mesh/MeshPart.h
game/def/mesh/SelectionBox.h
game/def/mesh/ShaderMod.h
game/LocalSubgame.cpp
game/LocalSubgame.h
game/ServerSubgame.cpp
game/ServerSubgame.h
game/Subgame.h
lua/Callback.h
lua/customization/vec3.hpp
lua/ErrorFormatter.cpp
lua/ErrorFormatter.h
lua/LocalLuaParser.cpp
lua/LocalLuaParser.h
lua/LocalModHandler.cpp
lua/LocalModHandler.h
lua/LuaKeybindHandler.cpp
lua/LuaKeybindHandler.h
lua/LuaMod.cpp
lua/LuaMod.h
lua/LuaParser.cpp
lua/LuaParser.h
lua/modules/BaseModule.h
lua/modules/Dimension.cpp
lua/modules/Dimension.h
lua/modules/mSetGui.h
lua/modules/mStartGame.h
lua/modules/SubgameModule.cpp
lua/modules/SubgameModule.h
lua/modules/Time.cpp
lua/modules/Time.h
lua/register/RegisterBiome.h
lua/register/RegisterBlock.h
lua/register/RegisterItem.h
lua/register/RegisterKeybind.h
lua/ServerLuaParser.cpp
lua/ServerLuaParser.h
lua/ServerModHandler.cpp
lua/ServerModHandler.h
lua/usertype/AnimationManager.cpp
lua/usertype/AnimationManager.h
lua/usertype/BaseUsertype.h
lua/usertype/Dimension.cpp
lua/usertype/Dimension.h
lua/usertype/Entity.cpp
lua/usertype/Entity.h
lua/usertype/Inventory.cpp
lua/usertype/Inventory.h
lua/usertype/InventoryList.cpp
lua/usertype/InventoryList.h
lua/usertype/ItemStack.cpp
lua/usertype/ItemStack.h
lua/usertype/LuaGuiElement.cpp
lua/usertype/LuaGuiElement.h
lua/usertype/Player.cpp
lua/usertype/Player.h
lua/usertype/SubgameUsertype.h
lua/usertype/Target.cpp
lua/usertype/Target.h
server/Server.cpp
server/Server.h
server/ServerClient.h
server/ServerClients.cpp
server/ServerClients.h
server/ServerInfoSender.cpp
server/ServerInfoSender.h
server/stream/ServerGenStream.cpp
server/stream/ServerGenStream.h
server/stream/ServerPacketStream.cpp
server/stream/ServerPacketStream.h
StartGame.h
util/Any.h
util/CovariantPtr.h
util/frustum/Frustum.cpp
util/frustum/Frustum.h
util/frustum/FrustumAABB.cpp
util/frustum/FrustumAABB.h
util/frustum/FrustumPlane.cpp
util/frustum/FrustumPlane.h
util/Interp.h
util/Lockable.h
util/Log.h
util/Mat4Conv.h
util/net/Address.h
util/net/Deserializer.h
util/net/NetHandler.cpp
util/net/NetHandler.h
util/net/NetState.h
util/net/Packet.cpp
util/net/Packet.h
util/net/PacketView.cpp
util/net/PacketView.h
util/net/Serializer.h
util/Ray.cpp
util/Ray.h
util/RIE.h
util/Structure.cpp
util/Structure.h
util/Space.h
util/Target.cpp
util/Target.h
util/Timer.cpp
util/Timer.h
util/Util.h
util/Vec.h
util/Voronoi3D.cpp
util/Voronoi3D.h
world/dim/chunk/Chunk.cpp
world/dim/chunk/Chunk.h
world/dim/chunk/MapBlock.cpp
world/dim/chunk/MapBlock.h
world/dim/chunk/Region.cpp
world/dim/chunk/Region.h
world/dim/Dimension.cpp
world/dim/Dimension.h
world/dim/DimensionBase.cpp
world/dim/DimensionBase.h
world/dim/ent/AnimationSegment.h
world/dim/ent/AnimationState.cpp
world/dim/ent/AnimationState.h
world/dim/ent/AnimChannel.cpp
world/dim/ent/AnimChannel.h
world/dim/ent/Collision.cpp
world/dim/ent/Collision.h
world/dim/ent/DrawableEntity.cpp
world/dim/ent/DrawableEntity.h
world/dim/ent/Entity.cpp
world/dim/ent/Entity.h
world/dim/ent/LocalLuaEntity.cpp
world/dim/ent/LocalLuaEntity.h
world/dim/ent/LuaEntity.h
world/dim/ent/ServerLuaEntity.cpp
world/dim/ent/ServerLuaEntity.h
world/dim/file/FileManipulator.cpp
world/dim/file/FileManipulator.h
world/dim/LocalDimension.cpp
world/dim/LocalDimension.h
world/dim/ServerDimension.cpp
world/dim/ServerDimension.h
world/gen/MapGen.cpp
world/gen/MapGen.h
world/gen/MapGenProps.cpp
world/gen/MapGenProps.h
world/gen/NoiseSample.cpp
world/gen/NoiseSample.h
world/inv/Inventory.cpp
world/inv/Inventory.h
world/inv/InventoryList.cpp
world/inv/InventoryList.h
world/inv/InventoryRefs.cpp
world/inv/InventoryRefs.h
world/inv/ItemStack.cpp
world/inv/ItemStack.h
world/inv/LocalInventory.cpp
world/inv/LocalInventory.h
world/inv/LocalInventoryRefs.cpp
world/inv/LocalInventoryRefs.h
world/inv/ServerInventory.cpp
world/inv/ServerInventory.h
world/inv/ServerInventoryList.cpp
world/inv/ServerInventoryList.h
world/inv/ServerInventoryRefs.cpp
world/inv/ServerInventoryRefs.h
world/LocalWorld.cpp
world/LocalWorld.h
world/player/LocalPlayer.cpp
world/player/LocalPlayer.h
world/player/Player.cpp
world/player/Player.h
world/player/ServerPlayer.cpp
world/player/ServerPlayer.h
world/ServerWorld.cpp
world/ServerWorld.h
world/World.cpp
world/World.h
util/net/Address.cpp
util/Bounds.cpp
util/Bounds.h
lua/register/CreateRegister.h
lua/register/CreateRegister.cpp
lua/modules/Structure.cpp
lua/modules/Structure.h
lua/modules/Message.cpp
lua/modules/Message.h
lua/NoiseFromLua.cpp
lua/NoiseFromLua.h
util/Types.h
util/PerfTimer.cpp
util/PerfTimer.h
client/gui/compound/GuiPerfGraph.cpp
client/gui/compound/GuiPerfGraph.h
client/gui/compound/GuiCellGraph.cpp
client/gui/compound/GuiCellGraph.h
client/gui/basic/GuiCells.cpp
client/gui/basic/GuiCells.h client/gui/Gui.h client/gui/Root.cpp client/gui/Root.h client/gui/BoxElement.cpp client/gui/BoxElement.h client/gui/Gui.cpp client/gui/Style.h client/gui/TextElement.cpp client/gui/TextElement.h client/gui/Expression.cpp client/gui/Expression.h client/gui/Style.cpp client/CallbackGroup.h)
target_include_directories(Zepha_Core PUBLIC .)
target_link_libraries(Zepha_Core glfw glm enet glad assimp FastNoise nothings-stb gzip cute_headers nlohmann_json)
target_link_libraries(Zepha_Core lua sol2)
if(WIN32)
target_link_libraries(Zepha_Core opengl32 gdi32)
endif()

View File

@ -107,8 +107,14 @@ int StartGame(int argc, char* argv[]) {
"\t\t(____)(____)(__) \\_)(_/\\_/\\_/\n" << std::endl;
}
if (mode == Mode::CLIENT) Client({ 1366, 768 });
else Server(port, subgame);
if (mode == Mode::CLIENT)
{
Client({ 1366, 768 });
}
else
{
Server(port, subgame);
}
return 0;
}

View File

@ -17,7 +17,10 @@ Client::Client(ivec2 window) :
std::cout << Log::info << "Starting Zepha Client." << Log::endl;
scene.setScene(make_unique<MainMenuScene>(*this));
while (!renderer.window.shouldClose()) loop();
while (!renderer.window.shouldClose())
{
loop();
}
}
f64 Client::getDelta() {

View File

@ -58,7 +58,7 @@ void Renderer::update(double delta) {
elapsedTime += delta;
window.update();
world.updateSwayMap(delta);
//world.updateSwayMap(delta);
}
void Renderer::beginChunkDeferredCalls() {

View File

@ -4,7 +4,7 @@
#include "LocalInventory.h"
#include "LocalInventoryList.cpp"
#include "LocalInventoryList.h"
#include "client/conn/ClientNetworkInterpreter.h"
InventoryListPtr LocalInventory::getList(const std::string& name) {