summaryrefslogtreecommitdiffstats
path: root/CMake
diff options
context:
space:
mode:
Diffstat (limited to 'CMake')
-rw-r--r--CMake/Fixups.cmake14
-rw-r--r--CMake/GenerateBindings.cmake112
-rw-r--r--CMake/GroupSources.cmake42
3 files changed, 168 insertions, 0 deletions
diff --git a/CMake/Fixups.cmake b/CMake/Fixups.cmake
new file mode 100644
index 000000000..5abff5abd
--- /dev/null
+++ b/CMake/Fixups.cmake
@@ -0,0 +1,14 @@
+# 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)
+
+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()
diff --git a/CMake/GenerateBindings.cmake b/CMake/GenerateBindings.cmake
new file mode 100644
index 000000000..153f1a58a
--- /dev/null
+++ b/CMake/GenerateBindings.cmake
@@ -0,0 +1,112 @@
+# 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
+)
+
+# 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
+)
diff --git a/CMake/GroupSources.cmake b/CMake/GroupSources.cmake
new file mode 100644
index 000000000..0f1762110
--- /dev/null
+++ b/CMake/GroupSources.cmake
@@ -0,0 +1,42 @@
+# 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)
+ 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})