summaryrefslogtreecommitdiffstats
path: root/CMake
diff options
context:
space:
mode:
Diffstat (limited to 'CMake')
-rw-r--r--CMake/AddDependencies.cmake142
-rw-r--r--CMake/Fixups.cmake26
-rw-r--r--CMake/GenerateBindings.cmake220
-rw-r--r--CMake/GroupSources.cmake76
4 files changed, 236 insertions, 228 deletions
diff --git a/CMake/AddDependencies.cmake b/CMake/AddDependencies.cmake
index 72eead340..ecf18dd27 100644
--- a/CMake/AddDependencies.cmake
+++ b/CMake/AddDependencies.cmake
@@ -1,81 +1,83 @@
-# Set options for SQLiteCpp, disable all their tests and lints:
-set(SQLITECPP_RUN_CPPLINT OFF CACHE BOOL "Run cpplint.py tool for Google C++ StyleGuide.")
-set(SQLITECPP_RUN_CPPCHECK OFF CACHE BOOL "Run cppcheck C++ static analysis tool.")
-set(SQLITECPP_RUN_DOXYGEN OFF CACHE BOOL "Run Doxygen C++ documentation tool.")
-set(SQLITECPP_BUILD_EXAMPLES OFF CACHE BOOL "Build examples.")
-set(SQLITECPP_BUILD_TESTS OFF CACHE BOOL "Build and run tests.")
-set(SQLITECPP_INTERNAL_SQLITE ON CACHE BOOL "Add the internal SQLite3 source to the project.")
-set(SQLITE_ENABLE_COLUMN_METADATA OFF CACHE BOOL "Enable Column::getColumnOriginName(). Require support from sqlite3 library.")
+function(build_dependencies TARGET)
+ # Set options for SQLiteCpp, disable all their tests and lints:
+ set(SQLITECPP_RUN_CPPLINT OFF CACHE BOOL "Run cpplint.py tool for Google C++ StyleGuide.")
+ set(SQLITECPP_RUN_CPPCHECK OFF CACHE BOOL "Run cppcheck C++ static analysis tool.")
+ set(SQLITECPP_RUN_DOXYGEN OFF CACHE BOOL "Run Doxygen C++ documentation tool.")
+ set(SQLITECPP_BUILD_EXAMPLES OFF CACHE BOOL "Build examples.")
+ set(SQLITECPP_BUILD_TESTS OFF CACHE BOOL "Build and run tests.")
+ set(SQLITECPP_INTERNAL_SQLITE ON CACHE BOOL "Add the internal SQLite3 source to the project.")
+ set(SQLITE_ENABLE_COLUMN_METADATA OFF CACHE BOOL "Enable Column::getColumnOriginName(). Require support from sqlite3 library.")
-# Set options for LibEvent, disable all their tests and benchmarks:
-set(EVENT__DISABLE_OPENSSL YES CACHE BOOL "Disable OpenSSL in LibEvent")
-set(EVENT__DISABLE_BENCHMARK YES CACHE BOOL "Disable LibEvent benchmarks")
-set(EVENT__DISABLE_TESTS YES CACHE BOOL "Disable LibEvent tests")
-set(EVENT__DISABLE_REGRESS YES CACHE BOOL "Disable LibEvent regression tests")
-set(EVENT__DISABLE_SAMPLES YES CACHE BOOL "Disable LibEvent samples")
-set(EVENT__LIBRARY_TYPE "STATIC" CACHE STRING "Use static LibEvent libraries")
+ # Set options for LibEvent, disable all their tests and benchmarks:
+ set(EVENT__DISABLE_OPENSSL YES CACHE BOOL "Disable OpenSSL in LibEvent")
+ set(EVENT__DISABLE_BENCHMARK YES CACHE BOOL "Disable LibEvent benchmarks")
+ set(EVENT__DISABLE_TESTS YES CACHE BOOL "Disable LibEvent tests")
+ set(EVENT__DISABLE_REGRESS YES CACHE BOOL "Disable LibEvent regression tests")
+ set(EVENT__DISABLE_SAMPLES YES CACHE BOOL "Disable LibEvent samples")
+ set(EVENT__LIBRARY_TYPE "STATIC" CACHE STRING "Use static LibEvent libraries")
-# Set options for JsonCPP, disabling all of their tests:
-set(JSONCPP_WITH_TESTS OFF CACHE BOOL "Compile and (for jsoncpp_check) run JsonCpp test executables")
-set(JSONCPP_WITH_POST_BUILD_UNITTEST OFF CACHE BOOL "Automatically run unit-tests as a post build step")
-set(JSONCPP_WITH_PKGCONFIG_SUPPORT OFF CACHE BOOL "Generate and install .pc files")
+ # Set options for JsonCPP, disabling all of their tests:
+ set(JSONCPP_WITH_TESTS OFF CACHE BOOL "Compile and (for jsoncpp_check) run JsonCpp test executables")
+ set(JSONCPP_WITH_POST_BUILD_UNITTEST OFF CACHE BOOL "Automatically run unit-tests as a post build step")
+ set(JSONCPP_WITH_PKGCONFIG_SUPPORT OFF CACHE BOOL "Generate and install .pc files")
-# Set options for mbedtls:
-set(ENABLE_PROGRAMS OFF CACHE BOOL "Build mbed TLS programs.")
-set(ENABLE_TESTING OFF CACHE BOOL "Build mbed TLS tests.")
+ # Set options for mbedtls:
+ set(ENABLE_PROGRAMS OFF CACHE BOOL "Build mbed TLS programs.")
+ set(ENABLE_TESTING OFF CACHE BOOL "Build mbed TLS tests.")
-# Enumerate all submodule libraries
-# SQLiteCpp needs to be included before sqlite so the lsqlite target is available:
-set(DEPENDENCIES expat fmt jsoncpp libevent lua luaexpat mbedtls SQLiteCpp sqlite tolua++ zlib)
-foreach(DEPENDENCY ${DEPENDENCIES})
- # Check that the libraries are present:
- if (NOT EXISTS "${PROJECT_SOURCE_DIR}/lib/${DEPENDENCY}/CMakeLists.txt")
- message(FATAL_ERROR "${DEPENDENCY} is missing in folder lib/${DEPENDENCY}. Have you initialized and updated the submodules / downloaded the extra libraries?")
- endif()
+ # Enumerate all submodule libraries
+ # SQLiteCpp needs to be included before sqlite so the lsqlite target is available:
+ set(DEPENDENCIES expat fmt jsoncpp libevent lua luaexpat mbedtls SQLiteCpp sqlite tolua++ zlib)
+ foreach(DEPENDENCY ${DEPENDENCIES})
+ # Check that the libraries are present:
+ if (NOT EXISTS "${PROJECT_SOURCE_DIR}/lib/${DEPENDENCY}/CMakeLists.txt")
+ message(FATAL_ERROR "${DEPENDENCY} is missing in folder lib/${DEPENDENCY}. Have you initialized and updated the submodules / downloaded the extra libraries?")
+ endif()
- # Include all the libraries
- # We use EXCLUDE_FROM_ALL so that only the explicit dependencies are compiled
- # (mbedTLS also has test and example programs in their CMakeLists.txt, we don't want those):
- add_subdirectory("lib/${DEPENDENCY}" EXCLUDE_FROM_ALL)
-endforeach()
+ # Include all the libraries
+ # We use EXCLUDE_FROM_ALL so that only the explicit dependencies are compiled
+ # (mbedTLS also has test and example programs in their CMakeLists.txt, we don't want those):
+ add_subdirectory("lib/${DEPENDENCY}" EXCLUDE_FROM_ALL)
+ endforeach()
-# Add required includes:
-target_include_directories(
- ${CMAKE_PROJECT_NAME} SYSTEM PRIVATE
- lib/mbedtls/include
- lib/TCLAP/include
- lib # TODO fix files including zlib/x instead of x
-)
+ # Add required includes:
+ target_include_directories(
+ ${TARGET} SYSTEM PRIVATE
+ lib/mbedtls/include
+ lib/TCLAP/include
+ lib # TODO fix files including zlib/x instead of x
+ )
-# Link dependencies as private:
-target_link_libraries(
- ${CMAKE_PROJECT_NAME} PRIVATE
- event_core
- event_extra
- fmt::fmt
- jsoncpp_lib
- lsqlite
- lua
- luaexpat
- mbedtls
- SQLiteCpp
- tolualib
- zlib
-)
+ # Link dependencies as private:
+ target_link_libraries(
+ ${TARGET} PRIVATE
+ event_core
+ event_extra
+ fmt::fmt
+ jsoncpp_lib
+ lsqlite
+ lua
+ luaexpat
+ mbedtls
+ SQLiteCpp
+ tolualib
+ zlib
+ )
-# Link process information library:
-if (WIN32)
- target_link_libraries(${CMAKE_PROJECT_NAME} PRIVATE Psapi.lib)
-endif()
+ # Link process information library:
+ if (WIN32)
+ target_link_libraries(${TARGET} PRIVATE Psapi.lib)
+ endif()
-# Special case handling for libevent pthreads:
-if(NOT WIN32)
- target_link_libraries(${CMAKE_PROJECT_NAME} PRIVATE event_pthreads)
-endif()
+ # Special case handling for libevent pthreads:
+ if(NOT WIN32)
+ target_link_libraries(${TARGET} PRIVATE event_pthreads)
+ endif()
-# Prettify jsoncpp_lib name in VS solution explorer:
-set_property(TARGET jsoncpp_lib PROPERTY PROJECT_LABEL "jsoncpp")
+ # Prettify jsoncpp_lib name in VS solution explorer:
+ set_property(TARGET jsoncpp_lib PROPERTY PROJECT_LABEL "jsoncpp")
-if (WIN32)
- add_subdirectory(lib/luaproxy)
-endif()
+ if (WIN32)
+ add_subdirectory(lib/luaproxy)
+ endif()
+endfunction()
diff --git a/CMake/Fixups.cmake b/CMake/Fixups.cmake
index 5abff5abd..374196d09 100644
--- a/CMake/Fixups.cmake
+++ b/CMake/Fixups.cmake
@@ -1,14 +1,16 @@
-# TODO these should be in the submodules
-# Under Windows, we need Lua as DLL; on *nix we need it linked statically:
-if (WIN32)
- target_compile_definitions(lua PUBLIC LUA_BUILD_AS_DLL)
-endif()
+function(emit_fixups)
+ # TODO these should be in the submodules
+ # Under Windows, we need Lua as DLL; on *nix we need it linked statically:
+ if (WIN32)
+ target_compile_definitions(lua PUBLIC LUA_BUILD_AS_DLL)
+ endif()
-# Let Lua use additional checks on its C API. This is only compiled into Debug builds:
-target_compile_definitions(lua PRIVATE LUA_USE_APICHECK)
+ # Let Lua use additional checks on its C API. This is only compiled into Debug builds:
+ target_compile_definitions(lua PRIVATE LUA_USE_APICHECK)
-if(NOT MSVC AND "${CMAKE_SYSTEM_PROCESSOR}" MATCHES "arm")
- # mbed TLS uses the frame pointer's register in inline assembly for its bignum implementation:
- # https://tls.mbed.org/kb/development/arm-thumb-error-r7-cannot-be-used-in-asm-here
- target_compile_options(mbedcrypto PRIVATE -fomit-frame-pointer)
-endif()
+ if(NOT MSVC AND "${CMAKE_SYSTEM_PROCESSOR}" MATCHES "arm")
+ # mbed TLS uses the frame pointer's register in inline assembly for its bignum implementation:
+ # https://tls.mbed.org/kb/development/arm-thumb-error-r7-cannot-be-used-in-asm-here
+ target_compile_options(mbedcrypto PRIVATE -fomit-frame-pointer)
+ endif()
+endfunction()
diff --git a/CMake/GenerateBindings.cmake b/CMake/GenerateBindings.cmake
index 153f1a58a..584ad1b66 100644
--- a/CMake/GenerateBindings.cmake
+++ b/CMake/GenerateBindings.cmake
@@ -1,112 +1,114 @@
-# Enumerate every Lua-exported class.
-# Changes to these files will cause binding regen:
-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
-)
+function(enable_bindings_generation)
+ # Enumerate every Lua-exported class.
+ # Changes to these files will cause binding regen:
+ 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
+ )
-# List all the files that are generated as part of the Bindings build process:
-set(BINDING_OUTPUTS
- Bindings.cpp
- Bindings.h
- LuaState_Declaration.inc
- LuaState_Implementation.cpp
- LuaState_Typedefs.inc
-)
+ # List all the files that are generated as part of the Bindings build process:
+ set(BINDING_OUTPUTS
+ Bindings.cpp
+ Bindings.h
+ LuaState_Declaration.inc
+ LuaState_Implementation.cpp
+ LuaState_Typedefs.inc
+ )
-# Make the file paths absolute and pointing to the bindings folder:
-set(BINDINGS_FOLDER "${PROJECT_SOURCE_DIR}/src/Bindings/")
-list(TRANSFORM BINDING_OUTPUTS PREPEND ${BINDINGS_FOLDER})
-list(TRANSFORM BINDING_DEPENDENCIES PREPEND "${PROJECT_SOURCE_DIR}/src/")
+ # Make the file paths absolute and pointing to the bindings folder:
+ set(BINDINGS_FOLDER "${PROJECT_SOURCE_DIR}/src/Bindings/")
+ list(TRANSFORM BINDING_OUTPUTS PREPEND ${BINDINGS_FOLDER})
+ list(TRANSFORM BINDING_DEPENDENCIES PREPEND "${PROJECT_SOURCE_DIR}/src/")
-# Generate the bindings:
-add_custom_command(
- OUTPUT ${BINDING_OUTPUTS}
- COMMAND luaexe BindingsProcessor.lua
- WORKING_DIRECTORY ${BINDINGS_FOLDER}
- DEPENDS ${BINDING_DEPENDENCIES} luaexe
-)
+ # Generate the bindings:
+ add_custom_command(
+ OUTPUT ${BINDING_OUTPUTS}
+ COMMAND luaexe BindingsProcessor.lua
+ WORKING_DIRECTORY ${BINDINGS_FOLDER}
+ DEPENDS ${BINDING_DEPENDENCIES} luaexe
+ )
+endfunction()
diff --git a/CMake/GroupSources.cmake b/CMake/GroupSources.cmake
index 0f1762110..a8706794d 100644
--- a/CMake/GroupSources.cmake
+++ b/CMake/GroupSources.cmake
@@ -1,42 +1,44 @@
-# Enable the support for solution folders in MSVC
-set_property(GLOBAL PROPERTY USE_FOLDERS ON)
+function(group_sources)
+ # Enable the support for solution folders in MSVC
+ set_property(GLOBAL PROPERTY USE_FOLDERS ON)
-# Put projects into solution folders in MSVC:
-set_target_properties(
- event_core_static
- event_extra_static
- expat
- fmt
- jsoncpp_lib
- lua
- luaexpat
- mbedcrypto
- mbedtls
- mbedx509
- lsqlite
- sqlite3
- SQLiteCpp
- tolualib
- zlib
- PROPERTIES FOLDER Libraries
-)
-
-# luaproxy not generated on anything else
-if(WIN32)
+ # Put projects into solution folders in MSVC:
set_target_properties(
- luaproxy
- PROPERTIES FOLDER Support
+ event_core_static
+ event_extra_static
+ expat
+ fmt
+ jsoncpp_lib
+ lua
+ luaexpat
+ mbedcrypto
+ mbedtls
+ mbedx509
+ lsqlite
+ sqlite3
+ SQLiteCpp
+ tolualib
+ zlib
+ PROPERTIES FOLDER Libraries
)
-endif()
-if(${BUILD_TOOLS})
- set_target_properties(
- MCADefrag
- ProtoProxy
- PROPERTIES FOLDER Tools
- )
-endif()
+ # luaproxy not generated on anything else
+ if(WIN32)
+ set_target_properties(
+ luaproxy
+ PROPERTIES FOLDER Support
+ )
+ endif()
+
+ if(${BUILD_TOOLS})
+ set_target_properties(
+ MCADefrag
+ ProtoProxy
+ PROPERTIES FOLDER Tools
+ )
+ endif()
-# Put all files into one project, separate by the folders:
-get_property(TARGET_SOURCE_FILES TARGET ${CMAKE_PROJECT_NAME} PROPERTY SOURCES)
-source_group(TREE "${PROJECT_SOURCE_DIR}/src" FILES ${TARGET_SOURCE_FILES})
+ # Put all files into one project, separate by the folders:
+ get_property(TARGET_SOURCE_FILES TARGET ${CMAKE_PROJECT_NAME} PROPERTY SOURCES)
+ source_group(TREE "${PROJECT_SOURCE_DIR}/src" FILES ${TARGET_SOURCE_FILES})
+endfunction()