summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorTiger Wang <ziwei.tiger@outlook.com>2020-05-16 21:59:10 +0200
committerGitHub <noreply@github.com>2020-05-16 21:59:10 +0200
commit9e8598fb1ca359143600d6bb2e8b317126a86bcc (patch)
tree677c51b708937ee8fbcdb2da8e180e874878d77a /src
parentTravis: Fix ccache on debug builds (#4741) (diff)
downloadcuberite-9e8598fb1ca359143600d6bb2e8b317126a86bcc.tar
cuberite-9e8598fb1ca359143600d6bb2e8b317126a86bcc.tar.gz
cuberite-9e8598fb1ca359143600d6bb2e8b317126a86bcc.tar.bz2
cuberite-9e8598fb1ca359143600d6bb2e8b317126a86bcc.tar.lz
cuberite-9e8598fb1ca359143600d6bb2e8b317126a86bcc.tar.xz
cuberite-9e8598fb1ca359143600d6bb2e8b317126a86bcc.tar.zst
cuberite-9e8598fb1ca359143600d6bb2e8b317126a86bcc.zip
Diffstat (limited to 'src')
-rw-r--r--src/Bindings/CMakeLists.txt135
-rw-r--r--src/Bindings/CheckBindingsDependencies.lua19
-rw-r--r--src/BlockEntities/CMakeLists.txt10
-rw-r--r--src/Blocks/CMakeLists.txt13
-rw-r--r--src/CMakeLists.txt220
-rw-r--r--src/Entities/CMakeLists.txt14
-rw-r--r--src/Generating/CMakeLists.txt10
-rw-r--r--src/Generating/FinishGen.h2
-rw-r--r--src/Globals.h6
-rw-r--r--src/HTTP/CMakeLists.txt10
-rw-r--r--src/Items/CMakeLists.txt10
-rw-r--r--src/LinearUpscale.h7
-rw-r--r--src/Mobs/CMakeLists.txt14
-rw-r--r--src/Noise/CMakeLists.txt10
-rw-r--r--src/OSSupport/CMakeLists.txt13
-rw-r--r--src/Protocol/CMakeLists.txt11
-rw-r--r--src/Simulator/CMakeLists.txt10
-rw-r--r--src/Simulator/IncrementalRedstoneSimulator/CMakeLists.txt11
-rw-r--r--src/UI/CMakeLists.txt14
-rw-r--r--src/WorldStorage/CMakeLists.txt10
-rw-r--r--src/mbedTLS++/CMakeLists.txt10
21 files changed, 93 insertions, 466 deletions
diff --git a/src/Bindings/CMakeLists.txt b/src/Bindings/CMakeLists.txt
index f5896f02d..3e7101cbf 100644
--- a/src/Bindings/CMakeLists.txt
+++ b/src/Bindings/CMakeLists.txt
@@ -1,5 +1,6 @@
+target_sources(
+ ${CMAKE_PROJECT_NAME} PRIVATE
-SET (SRCS
Bindings.cpp
DeprecatedBindings.cpp
LuaChunkStay.cpp
@@ -19,9 +20,7 @@ SET (SRCS
Plugin.cpp
PluginLua.cpp
PluginManager.cpp
-)
-SET (HDRS
Bindings.h
DeprecatedBindings.h
LuaChunkStay.h
@@ -41,133 +40,3 @@ SET (HDRS
PluginManager.h
tolua++.h
)
-
-# List all the files that are generated as part of the Bindings build process
-set (BINDING_OUTPUTS
- ${CMAKE_CURRENT_SOURCE_DIR}/Bindings.cpp
- ${CMAKE_CURRENT_SOURCE_DIR}/Bindings.h
- ${CMAKE_CURRENT_SOURCE_DIR}/LuaState_Declaration.inc
- ${CMAKE_CURRENT_SOURCE_DIR}/LuaState_Implementation.cpp
- ${CMAKE_CURRENT_SOURCE_DIR}/LuaState_Typedefs.inc
-)
-
-set(BINDING_DEPENDENCIES
- ../Bindings/AllToLua.pkg
- ../Bindings/BindingsProcessor.lua
- ../Bindings/LuaFunctions.h
- ../Bindings/LuaWindow.h
- ../Bindings/Plugin.h
- ../Bindings/PluginLua.h
- ../Bindings/PluginManager.h
- ../BiomeDef.h
- ../BlockArea.h
- ../BlockEntities/BeaconEntity.h
- ../BlockEntities/BedEntity.h
- ../BlockEntities/BlockEntity.h
- ../BlockEntities/BlockEntityWithItems.h
- ../BlockEntities/BrewingstandEntity.h
- ../BlockEntities/ChestEntity.h
- ../BlockEntities/CommandBlockEntity.h
- ../BlockEntities/DispenserEntity.h
- ../BlockEntities/DropSpenserEntity.h
- ../BlockEntities/DropperEntity.h
- ../BlockEntities/FurnaceEntity.h
- ../BlockEntities/HopperEntity.h
- ../BlockEntities/JukeboxEntity.h
- ../BlockEntities/MobSpawnerEntity.h
- ../BlockEntities/NoteEntity.h
- ../BlockEntities/SignEntity.h
- ../BlockEntities/MobHeadEntity.h
- ../BlockEntities/FlowerPotEntity.h
- ../BlockType.h
- ../BlockInfo.h
- ../BoundingBox.h
- ../ChatColor.h
- ../ChunkDef.h
- ../ClientHandle.h
- ../Color.h
- ../CompositeChat.h
- ../CraftingRecipes.h
- ../Cuboid.h
- ../Defines.h
- ../EffectID.h
- ../Enchantments.h
- ../Entities/Boat.h
- ../Entities/ArrowEntity.h
- ../Entities/Entity.h
- ../Entities/ExpOrb.h
- ../Entities/EntityEffect.h
- ../Entities/ExpBottleEntity.h
- ../Entities/FallingBlock.h
- ../Entities/FireChargeEntity.h
- ../Entities/FireworkEntity.h
- ../Entities/Floater.h
- ../Entities/GhastFireballEntity.h
- ../Entities/HangingEntity.h
- ../Entities/ItemFrame.h
- ../Entities/LeashKnot.h
- ../Entities/Pawn.h
- ../Entities/Player.h
- ../Entities/Painting.h
- ../Entities/Pickup.h
- ../Entities/ProjectileEntity.h
- ../Entities/SplashPotionEntity.h
- ../Entities/ThrownEggEntity.h
- ../Entities/ThrownEnderPearlEntity.h
- ../Entities/ThrownSnowballEntity.h
- ../Entities/TNTEntity.h
- ../Entities/WitherSkullEntity.h
- ../Generating/ChunkDesc.h
- ../IniFile.h
- ../Inventory.h
- ../Item.h
- ../ItemGrid.h
- ../Map.h
- ../MapManager.h
- ../Mobs/Monster.h
- ../Mobs/MonsterTypes.h
- ../OSSupport/File.h
- ../Protocol/MojangAPI.h
- ../Root.h
- ../Scoreboard.h
- ../Server.h
- ../Statistics.h
- ../StringUtils.h
- ../UI/Window.h
- ../UUID.h
- ../Vector3.h
- ../WebAdmin.h
- ../World.h
-)
-
-if (NOT MSVC)
- if (USE_SYSTEM_LUA)
- ADD_CUSTOM_COMMAND(
- OUTPUT ${BINDING_OUTPUTS}
- COMMAND lua BindingsProcessor.lua
- WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}
- DEPENDS ${BINDING_DEPENDENCIES}
- )
- else()
- ADD_CUSTOM_COMMAND(
- OUTPUT ${BINDING_OUTPUTS}
- COMMAND luaexe BindingsProcessor.lua
- WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}
- DEPENDS ${BINDING_DEPENDENCIES} luaexe
- )
- endif()
-endif ()
-
-set_source_files_properties(${BINDING_OUTPUTS} PROPERTIES GENERATED TRUE)
-
-set_source_files_properties(${CMAKE_SOURCE_DIR}/src/Bindings/Bindings.cpp PROPERTIES COMPILE_FLAGS -Wno-error)
-
-if(CMAKE_CXX_COMPILER_ID STREQUAL "Clang")
- set_source_files_properties(Bindings.cpp PROPERTIES COMPILE_FLAGS
- "-Wno-old-style-cast -Wno-missing-prototypes -Wno-deprecated-declarations")
-endif()
-
-if(NOT MSVC)
- add_library(Bindings ${SRCS} ${HDRS})
- target_link_libraries(Bindings fmt::fmt lua lsqlite tolualib mbedtls HTTPServer SQLiteCpp)
-endif()
diff --git a/src/Bindings/CheckBindingsDependencies.lua b/src/Bindings/CheckBindingsDependencies.lua
index c0565ead8..50e915311 100644
--- a/src/Bindings/CheckBindingsDependencies.lua
+++ b/src/Bindings/CheckBindingsDependencies.lua
@@ -19,8 +19,8 @@ local g_ShouldIgnorePkg =
local g_ShouldIgnoreCMake =
{
["tolua"] = true,
- ["../Bindings/AllToLua.pkg"] = true,
- ["../Bindings/BindingsProcessor.lua"] = true,
+ ["Bindings/AllToLua.pkg"] = true,
+ ["Bindings/BindingsProcessor.lua"] = true,
}
@@ -37,7 +37,17 @@ local function getAllToLuaPkgFiles()
if (g_ShouldIgnorePkg[a_FileName]) then
return
end
- a_FileName = a_FileName:gsub("../Bindings/", "") -- Normalize the path
+
+ -- Normalize the path: AllToLua is relative to src\Bindings
+ -- but the CMake dependencies list is relative to src\
+ a_FileName, cnt = a_FileName:gsub("%.%./", "")
+
+ -- If no replacements were done, this entry must point to a file
+ -- inside the Bindings folder; normalize it
+ if cnt == 0 then
+ a_FileName = "Bindings/" .. a_FileName
+ end
+
table.insert(res, a_FileName)
res[a_FileName] = true
end
@@ -54,7 +64,7 @@ end
--- Returns a sorted list of all files listed as dependencies in CMakeLists.txt
-- The returned table has both an array part (list of files) and a dictionary part ("filename" -> true)
local function getCMakeListsFiles()
- local f = assert(io.open("CMakeLists.txt", "r"))
+ local f = assert(io.open("../../CMake/GenerateBindings.cmake", "r"))
local contents = f:read("*all")
f:close()
local res = {}
@@ -69,7 +79,6 @@ local function getCMakeListsFiles()
if (g_ShouldIgnoreCMake[a_FileName]) then
return
end
- a_FileName = a_FileName:gsub("../Bindings/", "") -- Normalize the path
table.insert(res, a_FileName)
res[a_FileName] = true
end
diff --git a/src/BlockEntities/CMakeLists.txt b/src/BlockEntities/CMakeLists.txt
index 6e88ef128..b0e456da3 100644
--- a/src/BlockEntities/CMakeLists.txt
+++ b/src/BlockEntities/CMakeLists.txt
@@ -1,5 +1,6 @@
+target_sources(
+ ${CMAKE_PROJECT_NAME} PRIVATE
-SET (SRCS
BeaconEntity.cpp
BedEntity.cpp
BlockEntity.cpp
@@ -19,9 +20,7 @@ SET (SRCS
MobSpawnerEntity.cpp
NoteEntity.cpp
SignEntity.cpp
-)
-SET (HDRS
BeaconEntity.h
BedEntity.h
BlockEntity.h
@@ -42,8 +41,3 @@ SET (HDRS
NoteEntity.h
SignEntity.h
)
-
-if(NOT MSVC)
- add_library(BlockEntities ${SRCS} ${HDRS})
- target_link_libraries(BlockEntities fmt::fmt SQLiteCpp)
-endif()
diff --git a/src/Blocks/CMakeLists.txt b/src/Blocks/CMakeLists.txt
index 9d9f07b52..1026848df 100644
--- a/src/Blocks/CMakeLists.txt
+++ b/src/Blocks/CMakeLists.txt
@@ -1,16 +1,12 @@
-project (Cuberite)
+target_sources(
+ ${CMAKE_PROJECT_NAME} PRIVATE
-include_directories ("${PROJECT_SOURCE_DIR}/../")
-
-SET (SRCS
BlockBed.cpp
BlockDoor.cpp
BlockHandler.cpp
BlockPiston.cpp
ChunkInterface.cpp
-)
-SET (HDRS
BlockAnvil.h
BlockBed.h
BlockBigFlower.h
@@ -105,8 +101,3 @@ SET (HDRS
Mixins.h
WorldInterface.h
)
-
-if(NOT MSVC)
- add_library(Blocks ${SRCS} ${HDRS})
- target_link_libraries(Blocks fmt::fmt SQLiteCpp)
-endif()
diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt
index e10e8e8ca..c452ca7e2 100644
--- a/src/CMakeLists.txt
+++ b/src/CMakeLists.txt
@@ -1,18 +1,8 @@
-project (Cuberite)
+target_sources(
+ ${CMAKE_PROJECT_NAME} PRIVATE
+ Resources/Cuberite.rc
-include_directories (SYSTEM "${CMAKE_CURRENT_SOURCE_DIR}/../lib/")
-include_directories (SYSTEM "${CMAKE_CURRENT_SOURCE_DIR}/../lib/jsoncpp/include")
-include_directories (SYSTEM "${CMAKE_CURRENT_SOURCE_DIR}/../lib/mbedtls/include")
-include_directories (SYSTEM "${CMAKE_CURRENT_SOURCE_DIR}/../lib/libevent/include")
-
-set(FOLDERS
- OSSupport HTTP Items Blocks Protocol Generating mbedTLS++ Bindings
- WorldStorage Mobs Entities Simulator Simulator/IncrementalRedstoneSimulator
- BlockEntities UI Noise
-)
-
-SET (SRCS
BiomeDef.cpp
BlockArea.cpp
BlockInfo.cpp
@@ -80,9 +70,7 @@ SET (SRCS
WebAdmin.cpp
World.cpp
main.cpp
-)
-SET (HDRS
AllocationPool.h
BiomeDef.h
BlockArea.h
@@ -169,156 +157,33 @@ SET (HDRS
XMLParser.h
)
-file(WRITE "${CMAKE_BINARY_DIR}/include/Globals.h"
- "/* This file allows Globals.h to be included with an absolute path */\n#include \"${PROJECT_SOURCE_DIR}/Globals.h\"\n")
-
-include_directories("${CMAKE_BINARY_DIR}/include")
-include_directories (SYSTEM "${CMAKE_CURRENT_SOURCE_DIR}/../lib/TCLAP/include")
-
-configure_file("BuildInfo.h.cmake" "${CMAKE_BINARY_DIR}/include/BuildInfo.h")
-
-if (NOT MSVC)
- # Bindings need to reference other folders, so they are done here instead
- # lib dependencies are not included
- include_directories ("${CMAKE_CURRENT_SOURCE_DIR}/../lib/mbedtls/include")
-
- foreach(folder ${FOLDERS})
- add_subdirectory(${folder})
- endforeach(folder)
-
- get_directory_property(BINDING_DEPENDENCIES DIRECTORY "Bindings" DEFINITION BINDING_DEPENDENCIES)
-
- #clear file
- file(WRITE ${CMAKE_CURRENT_SOURCE_DIR}/Bindings/BindingDependencies.txt)
- foreach(dependency ${BINDING_DEPENDENCIES})
- #write each dependency on a seperate line
- file(APPEND ${CMAKE_CURRENT_SOURCE_DIR}/Bindings/BindingDependencies.txt "${dependency}\n")
- endforeach()
-
- set_directory_properties(PROPERTIES ADDITIONAL_MAKE_CLEAN_FILES "Bindings.cpp Bindings.h")
-
- list(APPEND SOURCE "${SRCS}")
- list(APPEND SOURCE "${HDRS}")
-
- # If building a windows version, but not using MSVC, add the resources directly to the makefile:
- if (WIN32)
- list(APPEND SOURCE "Resources/Cuberite.rc")
- endif()
-else ()
- # MSVC-specific handling: Put all files into one project, separate by the folders:
-
- source_group(Bindings FILES "Bindings/Bindings.cpp" "Bindings/Bindings.h")
-
- # Add all subfolders as solution-folders:
- function(includefolder PATH)
- FILE(GLOB FOLDER_FILES
- "${PATH}/*.cpp"
- "${PATH}/*.h"
- "${PATH}/*.rc"
- "${PATH}/*.pkg"
- )
- string(REPLACE "/" "\\" PROJECT_PATH ${PATH})
- source_group("${PROJECT_PATH}" FILES ${FOLDER_FILES})
- endfunction(includefolder)
-
- foreach(folder ${FOLDERS})
- add_subdirectory(${folder})
- includefolder(${folder})
-
- # Get all source files in this folder:
- get_directory_property(FOLDER_SRCS DIRECTORY ${folder} DEFINITION SRCS)
- foreach (src ${FOLDER_SRCS})
- list(APPEND SOURCE "${folder}/${src}")
- endforeach(src)
-
- # Get all headers in this folder:
- get_directory_property(FOLDER_HDRS DIRECTORY ${folder} DEFINITION HDRS)
- foreach (hdr ${FOLDER_HDRS})
- list(APPEND SOURCE "${folder}/${hdr}")
- endforeach(hdr)
-
- # Include this folder's CMakeLists.txt in the project:
- list(APPEND SOURCE "${folder}/CMakeLists.txt")
- source_group("${folder}" FILES "${folder}/CMakeLists.txt")
- endforeach(folder)
-
- list(APPEND SOURCE "${SRCS}")
- list(APPEND SOURCE "${HDRS}")
- list(APPEND SOURCE "Bindings/AllToLua.pkg")
-
- includefolder("Resources")
- source_group("" FILES ${SOURCE})
-
- # Precompiled headers (1st part)
- SET_SOURCE_FILES_PROPERTIES(
- 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\""
- )
- list(APPEND SOURCE "Resources/Cuberite.rc")
-
- # Make MSVC generate the PDB files even for the release build:
- set(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} /Zi")
- set(CMAKE_C_FLAGS_RELEASE "${CMAKE_C_FLAGS_RELEASE} /Zi")
- set(CMAKE_EXE_LINKER_FLAGS_RELEASE "${CMAKE_EXE_LINKER_FLAGS_RELEASE} /DEBUG")
- set(CMAKE_SHARED_LINKER_FLAGS_RELEASE "${CMAKE_SHARED_LINKER_FLAGS_RELEASE} /DEBUG")
- set(CMAKE_MODULE_LINKER_FLAGS_RELEASE "${CMAKE_MODULE_LINKER_FLAGS_RELEASE} /DEBUG")
-endif()
-
+set(FOLDERS
+ OSSupport HTTP Items Blocks Protocol Generating mbedTLS++ Bindings
+ WorldStorage Mobs Entities Simulator Simulator/IncrementalRedstoneSimulator
+ BlockEntities UI Noise
+)
-# Generate a list of all source files:
-set(ALLFILES "${SRCS}" "${HDRS}")
+# Add all child source directories:
foreach(folder ${FOLDERS})
- get_directory_property(FOLDER_SRCS DIRECTORY ${folder} DEFINITION SRCS)
- foreach (src ${FOLDER_SRCS})
- list(APPEND ALLFILES "${folder}/${src}")
- endforeach(src)
-
- get_directory_property(FOLDER_HDRS DIRECTORY ${folder} DEFINITION HDRS)
- foreach (hdr ${FOLDER_HDRS})
- list(APPEND ALLFILES "${folder}/${hdr}")
- endforeach(hdr)
+ add_subdirectory(${folder})
endforeach(folder)
-foreach(arg ${ALLFILES})
- set(ALLFILESLINES "${ALLFILESLINES}${arg}\n")
-endforeach()
-FILE(WRITE "AllFiles.lst" "${ALLFILESLINES}")
-
-if (MSVC)
- get_directory_property(BINDING_OUTPUTS DIRECTORY "Bindings" DEFINITION BINDING_OUTPUTS)
- get_directory_property(BINDING_DEPENDENCIES DIRECTORY "Bindings" DEFINITION BINDING_DEPENDENCIES)
-
- # The paths in BINDING_DEPENDENCIES are relative to the Bindings folder, convert them relative to this folder:
- foreach (dep ${BINDING_DEPENDENCIES})
- list (APPEND BINDINGS_DEPENDENCIES "Bindings/${dep}")
- endforeach(dep)
-
- if (USE_SYSTEM_LUA)
- ADD_CUSTOM_COMMAND(
- OUTPUT ${BINDING_OUTPUTS}
- COMMAND lua BindingsProcessor.lua
- WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/Bindings/
- DEPENDS ${BINDINGS_DEPENDENCIES}
- )
- else()
- ADD_CUSTOM_COMMAND(
- OUTPUT ${BINDING_OUTPUTS}
-
- # Regenerate bindings:
- COMMAND luaexe BindingsProcessor.lua
- WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/Bindings/
- DEPENDS ${BINDINGS_DEPENDENCIES} luaexe
- )
- endif()
-endif()
-
+file(WRITE "${CMAKE_BINARY_DIR}/include/Globals.h"
+ "/* This file allows Globals.h to be included with an absolute path */\n#include \"${PROJECT_SOURCE_DIR}/src/Globals.h\"\n")
+configure_file("BuildInfo.h.cmake" "${CMAKE_BINARY_DIR}/include/BuildInfo.h")
+target_include_directories(${CMAKE_PROJECT_NAME} PRIVATE "${CMAKE_BINARY_DIR}/include/")
+# Generate AllFiles.lst for CheckBasicStyle.lua
+get_target_property(ALL_FILES ${CMAKE_PROJECT_NAME} SOURCES)
+foreach(FILE ${ALL_FILES})
+ # target_sources converts to absolute but CheckBasicStyle expects relative
+ file(RELATIVE_PATH RELATIVE "${CMAKE_CURRENT_SOURCE_DIR}" ${FILE})
-add_executable(${CMAKE_PROJECT_NAME} ${SOURCE})
+ # Convert CMake list into newline-delimited string
+ set(ALL_FILES_AS_LINES "${ALL_FILES_AS_LINES}${RELATIVE}\n")
+endforeach()
+file(WRITE AllFiles.lst "${ALL_FILES_AS_LINES}")
# Output the executable into the $/Server folder, so that it has access to external resources:
SET_TARGET_PROPERTIES(${CMAKE_PROJECT_NAME} PROPERTIES
@@ -402,45 +267,6 @@ make_symlink("${CMAKE_CURRENT_SOURCE_DIR}/../CONTRIBUTORS"
make_symlink("${CMAKE_CURRENT_SOURCE_DIR}/../LICENSE" "${CMAKE_BINARY_DIR}/Server/LICENSE")
make_symlink("${CMAKE_CURRENT_SOURCE_DIR}/../Server/Install/ThirdPartyLicenses" "${CMAKE_BINARY_DIR}/Server/ThirdPartyLicenses")
-
-
-
-# Precompiled headers (2nd part)
-if (MSVC)
- SET_TARGET_PROPERTIES(
- ${CMAKE_PROJECT_NAME} PROPERTIES COMPILE_FLAGS "/Yu\"Globals.h\""
- OBJECT_DEPENDS "$(IntDir)/$(TargetName.pch)"
- )
-endif ()
-
-
-if (NOT MSVC)
- target_link_libraries(${CMAKE_PROJECT_NAME}
- OSSupport HTTPServer Bindings Items Blocks Noise
- Protocol Generating WorldStorage
- Mobs Entities Simulator IncrementalRedstoneSimulator
- BlockEntities UI mbedTLS++
- )
-endif ()
-
-if (WIN32)
- target_link_libraries(${CMAKE_PROJECT_NAME} expat tolualib ws2_32.lib Psapi.lib)
-endif()
-
-if (${CMAKE_SYSTEM_NAME} STREQUAL "FreeBSD")
- add_flags_lnk(-L/usr/local/lib)
- add_flags_lnk(-L/usr/ports/devel)
-endif()
-
-target_link_libraries(${CMAKE_PROJECT_NAME} luaexpat jsoncpp_lib mbedtls zlib lsqlite lua SQLiteCpp event_core event_extra fmt::fmt)
-
# Create a folder for Bindings' documentation:
FILE(MAKE_DIRECTORY "Bindings/docs")
make_symlink("${CMAKE_CURRENT_SOURCE_DIR}/Bindings/docs" "${CMAKE_BINARY_DIR}/Server/BindingsDocs")
-
-
-# For MSVC, set the startup project to Cuberite, and the debugger dir:
-if (MSVC)
- set_property(DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR} PROPERTY VS_STARTUP_PROJECT ${CMAKE_PROJECT_NAME})
- set_target_properties(${CMAKE_PROJECT_NAME} PROPERTIES VS_DEBUGGER_WORKING_DIRECTORY "${CMAKE_BINARY_DIR}/Server")
-endif()
diff --git a/src/Entities/CMakeLists.txt b/src/Entities/CMakeLists.txt
index 1a6e78af5..87c9ff790 100644
--- a/src/Entities/CMakeLists.txt
+++ b/src/Entities/CMakeLists.txt
@@ -1,5 +1,6 @@
+target_sources(
+ ${CMAKE_PROJECT_NAME} PRIVATE
-SET (SRCS
ArrowEntity.cpp
Boat.cpp
EnderCrystal.cpp
@@ -26,9 +27,8 @@ SET (SRCS
ThrownEggEntity.cpp
ThrownEnderPearlEntity.cpp
ThrownSnowballEntity.cpp
- WitherSkullEntity.cpp)
+ WitherSkullEntity.cpp
-SET (HDRS
ArrowEntity.h
Boat.h
EnderCrystal.h
@@ -55,9 +55,5 @@ SET (HDRS
ThrownEggEntity.h
ThrownEnderPearlEntity.h
ThrownSnowballEntity.h
- WitherSkullEntity.h)
-
-if(NOT MSVC)
- add_library(Entities ${SRCS} ${HDRS})
- target_link_libraries(Entities fmt::fmt WorldStorage SQLiteCpp)
-endif()
+ WitherSkullEntity.h
+)
diff --git a/src/Generating/CMakeLists.txt b/src/Generating/CMakeLists.txt
index 713e5b8c9..d6f0ce2fb 100644
--- a/src/Generating/CMakeLists.txt
+++ b/src/Generating/CMakeLists.txt
@@ -1,5 +1,6 @@
+target_sources(
+ ${CMAKE_PROJECT_NAME} PRIVATE
-SET (SRCS
BioGen.cpp
Caves.cpp
ChunkDesc.cpp
@@ -29,9 +30,7 @@ SET (SRCS
VerticalLimit.cpp
VerticalStrategy.cpp
VillageGen.cpp
-)
-SET (HDRS
BioGen.h
Caves.h
ChunkDesc.h
@@ -66,8 +65,3 @@ SET (HDRS
VerticalStrategy.h
VillageGen.h
)
-
-if(NOT MSVC)
- add_library(Generating ${SRCS} ${HDRS})
- target_link_libraries(Generating fmt::fmt OSSupport Blocks Bindings)
-endif()
diff --git a/src/Generating/FinishGen.h b/src/Generating/FinishGen.h
index 22292d924..c12bc2392 100644
--- a/src/Generating/FinishGen.h
+++ b/src/Generating/FinishGen.h
@@ -15,6 +15,8 @@
+#pragma once
+
#include "ComposableGenerator.h"
#include "../Noise/Noise.h"
#include "../ProbabDistrib.h"
diff --git a/src/Globals.h b/src/Globals.h
index 778bfe2b9..c0686c5b5 100644
--- a/src/Globals.h
+++ b/src/Globals.h
@@ -8,6 +8,12 @@
+#pragma once
+
+
+
+
+
// Compiler-dependent stuff:
#if defined(_MSC_VER)
// Disable some warnings that we don't care about:
diff --git a/src/HTTP/CMakeLists.txt b/src/HTTP/CMakeLists.txt
index 1bd311dc4..46165af3f 100644
--- a/src/HTTP/CMakeLists.txt
+++ b/src/HTTP/CMakeLists.txt
@@ -1,5 +1,6 @@
+target_sources(
+ ${CMAKE_PROJECT_NAME} PRIVATE
-SET (SRCS
EnvelopeParser.cpp
HTTPFormParser.cpp
HTTPMessage.cpp
@@ -12,9 +13,7 @@ SET (SRCS
TransferEncodingParser.cpp
UrlClient.cpp
UrlParser.cpp
-)
-SET (HDRS
EnvelopeParser.h
HTTPFormParser.h
HTTPMessage.h
@@ -28,8 +27,3 @@ SET (HDRS
UrlClient.h
UrlParser.h
)
-
-if(NOT MSVC)
- add_library(HTTPServer ${SRCS} ${HDRS})
- target_link_libraries(HTTPServer fmt::fmt)
-endif()
diff --git a/src/Items/CMakeLists.txt b/src/Items/CMakeLists.txt
index 9deec08c7..e5f65fb3b 100644
--- a/src/Items/CMakeLists.txt
+++ b/src/Items/CMakeLists.txt
@@ -1,9 +1,8 @@
+target_sources(
+ ${CMAKE_PROJECT_NAME} PRIVATE
-SET (SRCS
ItemHandler.cpp
-)
-SET (HDRS
ItemArmor.h
ItemAxe.h
ItemBed.h
@@ -62,8 +61,3 @@ SET (HDRS
ItemSword.h
ItemThrowable.h
)
-
-if(NOT MSVC)
- add_library(Items ${SRCS} ${HDRS})
- target_link_libraries(Items fmt::fmt SQLiteCpp)
-endif()
diff --git a/src/LinearUpscale.h b/src/LinearUpscale.h
index d0c2bb41a..349a3a55d 100644
--- a/src/LinearUpscale.h
+++ b/src/LinearUpscale.h
@@ -26,6 +26,13 @@ Regular upscaling takes two arrays and "moves" the input from src to dst; src is
+
+#pragma once
+
+
+
+
+
/**
Linearly interpolates values in the array between the equidistant anchor points (upscales).
Works in-place (input is already present at the correct output coords)
diff --git a/src/Mobs/CMakeLists.txt b/src/Mobs/CMakeLists.txt
index aada8f3a8..6508e1814 100644
--- a/src/Mobs/CMakeLists.txt
+++ b/src/Mobs/CMakeLists.txt
@@ -1,5 +1,6 @@
+target_sources(
+ ${CMAKE_PROJECT_NAME} PRIVATE
-SET (SRCS
AggressiveMonster.cpp
Bat.cpp
Blaze.cpp
@@ -37,9 +38,8 @@ SET (SRCS
Wolf.cpp
Zombie.cpp
ZombiePigman.cpp
- ZombieVillager.cpp)
+ ZombieVillager.cpp
-SET (HDRS
AggressiveMonster.h
Bat.h
Blaze.h
@@ -80,9 +80,5 @@ SET (HDRS
Wolf.h
Zombie.h
ZombiePigman.h
- ZombieVillager.h)
-
-if(NOT MSVC)
- add_library(Mobs ${SRCS} ${HDRS})
- target_link_libraries(Mobs fmt::fmt SQLiteCpp)
-endif()
+ ZombieVillager.h
+)
diff --git a/src/Noise/CMakeLists.txt b/src/Noise/CMakeLists.txt
index b099c1766..85b3e2b8e 100644
--- a/src/Noise/CMakeLists.txt
+++ b/src/Noise/CMakeLists.txt
@@ -1,16 +1,10 @@
+target_sources(
+ ${CMAKE_PROJECT_NAME} PRIVATE
-SET (SRCS
Noise.cpp
-)
-SET (HDRS
InterpolNoise.h
Noise.h
OctavedNoise.h
RidgedNoise.h
)
-
-if(NOT MSVC)
- add_library(Noise ${SRCS} ${HDRS})
- target_link_libraries(Noise fmt::fmt OSSupport)
-endif()
diff --git a/src/OSSupport/CMakeLists.txt b/src/OSSupport/CMakeLists.txt
index 62ad9c475..1b853c202 100644
--- a/src/OSSupport/CMakeLists.txt
+++ b/src/OSSupport/CMakeLists.txt
@@ -1,5 +1,6 @@
+target_sources(
+ ${CMAKE_PROJECT_NAME} PRIVATE
-SET (SRCS
CriticalSection.cpp
Errors.cpp
Event.cpp
@@ -16,9 +17,7 @@ SET (SRCS
TCPLinkImpl.cpp
UDPEndpointImpl.cpp
WinStackWalker.cpp
-)
-SET (HDRS
AtomicUniquePtr.h
CriticalSection.h
Errors.h
@@ -40,11 +39,3 @@ SET (HDRS
WinStackWalker.h
)
-if(NOT MSVC)
- add_library(OSSupport ${SRCS} ${HDRS})
- target_link_libraries(OSSupport fmt::fmt)
-
- if(NOT WIN32)
- target_link_libraries(OSSupport event_pthreads_static)
- endif()
-endif()
diff --git a/src/Protocol/CMakeLists.txt b/src/Protocol/CMakeLists.txt
index 0f22e531f..e197853cb 100644
--- a/src/Protocol/CMakeLists.txt
+++ b/src/Protocol/CMakeLists.txt
@@ -1,6 +1,6 @@
-include_directories (SYSTEM "../../lib/jsoncpp/include")
+target_sources(
+ ${CMAKE_PROJECT_NAME} PRIVATE
-SET (SRCS
Authenticator.cpp
ChunkDataSerializer.cpp
ForgeHandshake.cpp
@@ -14,9 +14,7 @@ SET (SRCS
Protocol_1_13.cpp
ProtocolPalettes.cpp
ProtocolRecognizer.cpp
-)
-SET (HDRS
Authenticator.h
ChunkDataSerializer.h
ForgeHandshake.h
@@ -32,8 +30,3 @@ SET (HDRS
ProtocolPalettes.h
ProtocolRecognizer.h
)
-
-if (NOT MSVC)
- add_library(Protocol ${SRCS} ${HDRS})
- target_link_libraries(Protocol fmt::fmt SQLiteCpp)
-endif()
diff --git a/src/Simulator/CMakeLists.txt b/src/Simulator/CMakeLists.txt
index a8efc988c..2acaa2031 100644
--- a/src/Simulator/CMakeLists.txt
+++ b/src/Simulator/CMakeLists.txt
@@ -1,5 +1,6 @@
+target_sources(
+ ${CMAKE_PROJECT_NAME} PRIVATE
-SET (SRCS
DelayedFluidSimulator.cpp
FireSimulator.cpp
FloodyFluidSimulator.cpp
@@ -9,9 +10,7 @@ SET (SRCS
SimulatorManager.cpp
VanillaFluidSimulator.cpp
VaporizeFluidSimulator.cpp
-)
-SET (HDRS
DelayedFluidSimulator.h
FireSimulator.h
FloodyFluidSimulator.h
@@ -25,8 +24,3 @@ SET (HDRS
VanillaFluidSimulator.h
VaporizeFluidSimulator.h
)
-
-if(NOT MSVC)
- add_library(Simulator ${SRCS} ${HDRS})
- target_link_libraries(Simulator fmt::fmt SQLiteCpp)
-endif()
diff --git a/src/Simulator/IncrementalRedstoneSimulator/CMakeLists.txt b/src/Simulator/IncrementalRedstoneSimulator/CMakeLists.txt
index 0c2346322..1857a115a 100644
--- a/src/Simulator/IncrementalRedstoneSimulator/CMakeLists.txt
+++ b/src/Simulator/IncrementalRedstoneSimulator/CMakeLists.txt
@@ -1,9 +1,8 @@
+target_sources(
+ ${CMAKE_PROJECT_NAME} PRIVATE
-set (SRCS
IncrementalRedstoneSimulator.cpp
-)
-set (HDRS
CommandBlockHandler.h
DoorHandler.h
DropSpenserHandler.h
@@ -29,9 +28,3 @@ set (HDRS
PoweredRailHandler.h
PressurePlateHandler.h
)
-
-if(NOT MSVC)
- add_library(IncrementalRedstoneSimulator ${SRCS} ${HDRS})
- target_link_libraries(IncrementalRedstoneSimulator fmt::fmt)
-endif()
-
diff --git a/src/UI/CMakeLists.txt b/src/UI/CMakeLists.txt
index 16c70f6fe..b87a7fe47 100644
--- a/src/UI/CMakeLists.txt
+++ b/src/UI/CMakeLists.txt
@@ -1,5 +1,6 @@
+target_sources(
+ ${CMAKE_PROJECT_NAME} PRIVATE
-SET (SRCS
SlotArea.cpp
Window.cpp
AnvilWindow.cpp
@@ -13,9 +14,8 @@ SET (SRCS
FurnaceWindow.cpp
HopperWindow.cpp
HorseWindow.cpp
- InventoryWindow.cpp)
+ InventoryWindow.cpp
-SET (HDRS
SlotArea.h
Window.h
AnvilWindow.h
@@ -31,9 +31,5 @@ SET (HDRS
HorseWindow.h
InventoryWindow.h
MinecartWithChestWindow.h
- WindowOwner.h)
-
-if(NOT MSVC)
- add_library(UI ${SRCS} ${HDRS})
- target_link_libraries(UI fmt::fmt SQLiteCpp)
-endif()
+ WindowOwner.h
+)
diff --git a/src/WorldStorage/CMakeLists.txt b/src/WorldStorage/CMakeLists.txt
index 341d88e68..68fdd31bc 100644
--- a/src/WorldStorage/CMakeLists.txt
+++ b/src/WorldStorage/CMakeLists.txt
@@ -1,5 +1,6 @@
+target_sources(
+ ${CMAKE_PROJECT_NAME} PRIVATE
-SET (SRCS
EnchantmentSerializer.cpp
FastNBT.cpp
FireworksSerializer.cpp
@@ -10,9 +11,7 @@ SET (SRCS
StatSerializer.cpp
WSSAnvil.cpp
WorldStorage.cpp
-)
-SET (HDRS
EnchantmentSerializer.h
FastNBT.h
FireworksSerializer.h
@@ -24,8 +23,3 @@ SET (HDRS
WSSAnvil.h
WorldStorage.h
)
-
-if(NOT MSVC)
- add_library(WorldStorage ${SRCS} ${HDRS})
- target_link_libraries(WorldStorage fmt::fmt OSSupport SQLiteCpp)
-endif()
diff --git a/src/mbedTLS++/CMakeLists.txt b/src/mbedTLS++/CMakeLists.txt
index 29c323cc6..42e0fc8b2 100644
--- a/src/mbedTLS++/CMakeLists.txt
+++ b/src/mbedTLS++/CMakeLists.txt
@@ -1,5 +1,6 @@
+target_sources(
+ ${CMAKE_PROJECT_NAME} PRIVATE
-set(SRCS
AesCfb128Decryptor.cpp
AesCfb128Encryptor.cpp
BlockingSslClientSocket.cpp
@@ -13,9 +14,7 @@ set(SRCS
SslConfig.cpp
SslContext.cpp
X509Cert.cpp
-)
-set(HDRS
AesCfb128Decryptor.h
AesCfb128Encryptor.h
BlockingSslClientSocket.h
@@ -31,8 +30,3 @@ set(HDRS
Sha1Checksum.h
X509Cert.h
)
-
-if(NOT MSVC)
- add_library(mbedTLS++ ${SRCS} ${HDRS})
- target_link_libraries(mbedTLS++ fmt::fmt mbedtls)
-endif()