1
0
Fork 0

Funktions

This commit is contained in:
Tiger Wang 2020-05-27 23:48:49 +01:00
parent 6317176d7e
commit 2c0fc395ba
6 changed files with 292 additions and 279 deletions

View File

@ -1,81 +1,83 @@
# Set options for SQLiteCpp, disable all their tests and lints: function(build_dependencies TARGET)
set(SQLITECPP_RUN_CPPLINT OFF CACHE BOOL "Run cpplint.py tool for Google C++ StyleGuide.") # Set options for SQLiteCpp, disable all their tests and lints:
set(SQLITECPP_RUN_CPPCHECK OFF CACHE BOOL "Run cppcheck C++ static analysis tool.") set(SQLITECPP_RUN_CPPLINT OFF CACHE BOOL "Run cpplint.py tool for Google C++ StyleGuide.")
set(SQLITECPP_RUN_DOXYGEN OFF CACHE BOOL "Run Doxygen C++ documentation tool.") set(SQLITECPP_RUN_CPPCHECK OFF CACHE BOOL "Run cppcheck C++ static analysis tool.")
set(SQLITECPP_BUILD_EXAMPLES OFF CACHE BOOL "Build examples.") set(SQLITECPP_RUN_DOXYGEN OFF CACHE BOOL "Run Doxygen C++ documentation tool.")
set(SQLITECPP_BUILD_TESTS OFF CACHE BOOL "Build and run tests.") set(SQLITECPP_BUILD_EXAMPLES OFF CACHE BOOL "Build examples.")
set(SQLITECPP_INTERNAL_SQLITE ON CACHE BOOL "Add the internal SQLite3 source to the project.") set(SQLITECPP_BUILD_TESTS OFF CACHE BOOL "Build and run tests.")
set(SQLITE_ENABLE_COLUMN_METADATA OFF CACHE BOOL "Enable Column::getColumnOriginName(). Require support from sqlite3 library.") 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 options for LibEvent, disable all their tests and benchmarks:
set(EVENT__DISABLE_OPENSSL YES CACHE BOOL "Disable OpenSSL in LibEvent") set(EVENT__DISABLE_OPENSSL YES CACHE BOOL "Disable OpenSSL in LibEvent")
set(EVENT__DISABLE_BENCHMARK YES CACHE BOOL "Disable LibEvent benchmarks") set(EVENT__DISABLE_BENCHMARK YES CACHE BOOL "Disable LibEvent benchmarks")
set(EVENT__DISABLE_TESTS YES CACHE BOOL "Disable LibEvent tests") set(EVENT__DISABLE_TESTS YES CACHE BOOL "Disable LibEvent tests")
set(EVENT__DISABLE_REGRESS YES CACHE BOOL "Disable LibEvent regression tests") set(EVENT__DISABLE_REGRESS YES CACHE BOOL "Disable LibEvent regression tests")
set(EVENT__DISABLE_SAMPLES YES CACHE BOOL "Disable LibEvent samples") set(EVENT__DISABLE_SAMPLES YES CACHE BOOL "Disable LibEvent samples")
set(EVENT__LIBRARY_TYPE "STATIC" CACHE STRING "Use static LibEvent libraries") set(EVENT__LIBRARY_TYPE "STATIC" CACHE STRING "Use static LibEvent libraries")
# Set options for JsonCPP, disabling all of their tests: # 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_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_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(JSONCPP_WITH_PKGCONFIG_SUPPORT OFF CACHE BOOL "Generate and install .pc files")
# Set options for mbedtls: # Set options for mbedtls:
set(ENABLE_PROGRAMS OFF CACHE BOOL "Build mbed TLS programs.") set(ENABLE_PROGRAMS OFF CACHE BOOL "Build mbed TLS programs.")
set(ENABLE_TESTING OFF CACHE BOOL "Build mbed TLS tests.") set(ENABLE_TESTING OFF CACHE BOOL "Build mbed TLS tests.")
# Enumerate all submodule libraries # Enumerate all submodule libraries
# SQLiteCpp needs to be included before sqlite so the lsqlite target is available: # 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) set(DEPENDENCIES expat fmt jsoncpp libevent lua luaexpat mbedtls SQLiteCpp sqlite tolua++ zlib)
foreach(DEPENDENCY ${DEPENDENCIES}) foreach(DEPENDENCY ${DEPENDENCIES})
# Check that the libraries are present: # Check that the libraries are present:
if (NOT EXISTS "${PROJECT_SOURCE_DIR}/lib/${DEPENDENCY}/CMakeLists.txt") 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?") 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()
# 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(
${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(${TARGET} PRIVATE Psapi.lib)
endif() endif()
# Include all the libraries # Special case handling for libevent pthreads:
# We use EXCLUDE_FROM_ALL so that only the explicit dependencies are compiled if(NOT WIN32)
# (mbedTLS also has test and example programs in their CMakeLists.txt, we don't want those): target_link_libraries(${TARGET} PRIVATE event_pthreads)
add_subdirectory("lib/${DEPENDENCY}" EXCLUDE_FROM_ALL) endif()
endforeach()
# Add required includes: # Prettify jsoncpp_lib name in VS solution explorer:
target_include_directories( set_property(TARGET jsoncpp_lib PROPERTY PROJECT_LABEL "jsoncpp")
${CMAKE_PROJECT_NAME} SYSTEM PRIVATE
lib/mbedtls/include
lib/TCLAP/include
lib # TODO fix files including zlib/x instead of x
)
# Link dependencies as private: if (WIN32)
target_link_libraries( add_subdirectory(lib/luaproxy)
${CMAKE_PROJECT_NAME} PRIVATE endif()
event_core endfunction()
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()
# Special case handling for libevent pthreads:
if(NOT WIN32)
target_link_libraries(${CMAKE_PROJECT_NAME} PRIVATE event_pthreads)
endif()
# Prettify jsoncpp_lib name in VS solution explorer:
set_property(TARGET jsoncpp_lib PROPERTY PROJECT_LABEL "jsoncpp")
if (WIN32)
add_subdirectory(lib/luaproxy)
endif()

View File

@ -1,14 +1,16 @@
# TODO these should be in the submodules function(emit_fixups)
# Under Windows, we need Lua as DLL; on *nix we need it linked statically: # TODO these should be in the submodules
if (WIN32) # Under Windows, we need Lua as DLL; on *nix we need it linked statically:
target_compile_definitions(lua PUBLIC LUA_BUILD_AS_DLL) if (WIN32)
endif() 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: # Let Lua use additional checks on its C API. This is only compiled into Debug builds:
target_compile_definitions(lua PRIVATE LUA_USE_APICHECK) target_compile_definitions(lua PRIVATE LUA_USE_APICHECK)
if(NOT MSVC AND "${CMAKE_SYSTEM_PROCESSOR}" MATCHES "arm") if(NOT MSVC AND "${CMAKE_SYSTEM_PROCESSOR}" MATCHES "arm")
# mbed TLS uses the frame pointer's register in inline assembly for its bignum implementation: # 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 # https://tls.mbed.org/kb/development/arm-thumb-error-r7-cannot-be-used-in-asm-here
target_compile_options(mbedcrypto PRIVATE -fomit-frame-pointer) target_compile_options(mbedcrypto PRIVATE -fomit-frame-pointer)
endif() endif()
endfunction()

View File

@ -1,112 +1,114 @@
# Enumerate every Lua-exported class. function(enable_bindings_generation)
# Changes to these files will cause binding regen: # Enumerate every Lua-exported class.
set(BINDING_DEPENDENCIES # Changes to these files will cause binding regen:
Bindings/AllToLua.pkg set(BINDING_DEPENDENCIES
Bindings/BindingsProcessor.lua Bindings/AllToLua.pkg
Bindings/LuaFunctions.h Bindings/BindingsProcessor.lua
Bindings/LuaWindow.h Bindings/LuaFunctions.h
Bindings/Plugin.h Bindings/LuaWindow.h
Bindings/PluginLua.h Bindings/Plugin.h
Bindings/PluginManager.h Bindings/PluginLua.h
BiomeDef.h Bindings/PluginManager.h
BlockArea.h BiomeDef.h
BlockEntities/BeaconEntity.h BlockArea.h
BlockEntities/BedEntity.h BlockEntities/BeaconEntity.h
BlockEntities/BlockEntity.h BlockEntities/BedEntity.h
BlockEntities/BlockEntityWithItems.h BlockEntities/BlockEntity.h
BlockEntities/BrewingstandEntity.h BlockEntities/BlockEntityWithItems.h
BlockEntities/ChestEntity.h BlockEntities/BrewingstandEntity.h
BlockEntities/CommandBlockEntity.h BlockEntities/ChestEntity.h
BlockEntities/DispenserEntity.h BlockEntities/CommandBlockEntity.h
BlockEntities/DropSpenserEntity.h BlockEntities/DispenserEntity.h
BlockEntities/DropperEntity.h BlockEntities/DropSpenserEntity.h
BlockEntities/FurnaceEntity.h BlockEntities/DropperEntity.h
BlockEntities/HopperEntity.h BlockEntities/FurnaceEntity.h
BlockEntities/JukeboxEntity.h BlockEntities/HopperEntity.h
BlockEntities/MobSpawnerEntity.h BlockEntities/JukeboxEntity.h
BlockEntities/NoteEntity.h BlockEntities/MobSpawnerEntity.h
BlockEntities/SignEntity.h BlockEntities/NoteEntity.h
BlockEntities/MobHeadEntity.h BlockEntities/SignEntity.h
BlockEntities/FlowerPotEntity.h BlockEntities/MobHeadEntity.h
BlockType.h BlockEntities/FlowerPotEntity.h
BlockInfo.h BlockType.h
BoundingBox.h BlockInfo.h
ChatColor.h BoundingBox.h
ChunkDef.h ChatColor.h
ClientHandle.h ChunkDef.h
Color.h ClientHandle.h
CompositeChat.h Color.h
CraftingRecipes.h CompositeChat.h
Cuboid.h CraftingRecipes.h
Defines.h Cuboid.h
EffectID.h Defines.h
Enchantments.h EffectID.h
Entities/Boat.h Enchantments.h
Entities/ArrowEntity.h Entities/Boat.h
Entities/Entity.h Entities/ArrowEntity.h
Entities/ExpOrb.h Entities/Entity.h
Entities/EntityEffect.h Entities/ExpOrb.h
Entities/ExpBottleEntity.h Entities/EntityEffect.h
Entities/FallingBlock.h Entities/ExpBottleEntity.h
Entities/FireChargeEntity.h Entities/FallingBlock.h
Entities/FireworkEntity.h Entities/FireChargeEntity.h
Entities/Floater.h Entities/FireworkEntity.h
Entities/GhastFireballEntity.h Entities/Floater.h
Entities/HangingEntity.h Entities/GhastFireballEntity.h
Entities/ItemFrame.h Entities/HangingEntity.h
Entities/LeashKnot.h Entities/ItemFrame.h
Entities/Pawn.h Entities/LeashKnot.h
Entities/Player.h Entities/Pawn.h
Entities/Painting.h Entities/Player.h
Entities/Pickup.h Entities/Painting.h
Entities/ProjectileEntity.h Entities/Pickup.h
Entities/SplashPotionEntity.h Entities/ProjectileEntity.h
Entities/ThrownEggEntity.h Entities/SplashPotionEntity.h
Entities/ThrownEnderPearlEntity.h Entities/ThrownEggEntity.h
Entities/ThrownSnowballEntity.h Entities/ThrownEnderPearlEntity.h
Entities/TNTEntity.h Entities/ThrownSnowballEntity.h
Entities/WitherSkullEntity.h Entities/TNTEntity.h
Generating/ChunkDesc.h Entities/WitherSkullEntity.h
IniFile.h Generating/ChunkDesc.h
Inventory.h IniFile.h
Item.h Inventory.h
ItemGrid.h Item.h
Map.h ItemGrid.h
MapManager.h Map.h
Mobs/Monster.h MapManager.h
Mobs/MonsterTypes.h Mobs/Monster.h
OSSupport/File.h Mobs/MonsterTypes.h
Protocol/MojangAPI.h OSSupport/File.h
Root.h Protocol/MojangAPI.h
Scoreboard.h Root.h
Server.h Scoreboard.h
Statistics.h Server.h
StringUtils.h Statistics.h
UI/Window.h StringUtils.h
UUID.h UI/Window.h
Vector3.h UUID.h
WebAdmin.h Vector3.h
World.h WebAdmin.h
) World.h
)
# List all the files that are generated as part of the Bindings build process: # List all the files that are generated as part of the Bindings build process:
set(BINDING_OUTPUTS set(BINDING_OUTPUTS
Bindings.cpp Bindings.cpp
Bindings.h Bindings.h
LuaState_Declaration.inc LuaState_Declaration.inc
LuaState_Implementation.cpp LuaState_Implementation.cpp
LuaState_Typedefs.inc LuaState_Typedefs.inc
) )
# Make the file paths absolute and pointing to the bindings folder: # Make the file paths absolute and pointing to the bindings folder:
set(BINDINGS_FOLDER "${PROJECT_SOURCE_DIR}/src/Bindings/") set(BINDINGS_FOLDER "${PROJECT_SOURCE_DIR}/src/Bindings/")
list(TRANSFORM BINDING_OUTPUTS PREPEND ${BINDINGS_FOLDER}) list(TRANSFORM BINDING_OUTPUTS PREPEND ${BINDINGS_FOLDER})
list(TRANSFORM BINDING_DEPENDENCIES PREPEND "${PROJECT_SOURCE_DIR}/src/") list(TRANSFORM BINDING_DEPENDENCIES PREPEND "${PROJECT_SOURCE_DIR}/src/")
# Generate the bindings: # Generate the bindings:
add_custom_command( add_custom_command(
OUTPUT ${BINDING_OUTPUTS} OUTPUT ${BINDING_OUTPUTS}
COMMAND luaexe BindingsProcessor.lua COMMAND luaexe BindingsProcessor.lua
WORKING_DIRECTORY ${BINDINGS_FOLDER} WORKING_DIRECTORY ${BINDINGS_FOLDER}
DEPENDS ${BINDING_DEPENDENCIES} luaexe DEPENDS ${BINDING_DEPENDENCIES} luaexe
) )
endfunction()

View File

@ -1,42 +1,44 @@
# Enable the support for solution folders in MSVC function(group_sources)
set_property(GLOBAL PROPERTY USE_FOLDERS ON) # Enable the support for solution folders in MSVC
set_property(GLOBAL PROPERTY USE_FOLDERS ON)
# Put projects into solution folders in MSVC: # 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( set_target_properties(
luaproxy event_core_static
PROPERTIES FOLDER Support event_extra_static
expat
fmt
jsoncpp_lib
lua
luaexpat
mbedcrypto
mbedtls
mbedx509
lsqlite
sqlite3
SQLiteCpp
tolualib
zlib
PROPERTIES FOLDER Libraries
) )
endif()
if(${BUILD_TOOLS}) # luaproxy not generated on anything else
set_target_properties( if(WIN32)
MCADefrag set_target_properties(
ProtoProxy luaproxy
PROPERTIES FOLDER Tools PROPERTIES FOLDER Support
) )
endif() endif()
# Put all files into one project, separate by the folders: if(${BUILD_TOOLS})
get_property(TARGET_SOURCE_FILES TARGET ${CMAKE_PROJECT_NAME} PROPERTY SOURCES) set_target_properties(
source_group(TREE "${PROJECT_SOURCE_DIR}/src" FILES ${TARGET_SOURCE_FILES}) 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})
endfunction()

View File

@ -28,7 +28,19 @@ option(PRECOMPILE_HEADERS "Enable precompiled headers for faster builds" ON)
option(SELF_TEST "Enables testing code to be built" OFF) option(SELF_TEST "Enables testing code to be built" OFF)
option(UNITY_BUILDS "Enables source aggregation for faster builds" ON) option(UNITY_BUILDS "Enables source aggregation for faster builds" ON)
# We need C++17 features include("CMake/AddDependencies.cmake")
include("CMake/Fixups.cmake")
include("CMake/GenerateBindings.cmake")
include("CMake/GroupSources.cmake")
include("SetFlags.cmake")
# Add build timestamp and details:
include("CMake/StampBuild.cmake")
# TODO: set_build_stamp()
set_global_flags()
# We need C++17 features:
set(CMAKE_CXX_STANDARD 17) set(CMAKE_CXX_STANDARD 17)
set(CMAKE_CXX_STANDARD_REQUIRED ON) set(CMAKE_CXX_STANDARD_REQUIRED ON)
set(CMAKE_CXX_EXTENSIONS OFF) set(CMAKE_CXX_EXTENSIONS OFF)
@ -40,15 +52,15 @@ if(WHOLE_PROGRAM_OPTIMISATION)
set(CMAKE_INTERPROCEDURAL_OPTIMIZATION_RELEASE ${IPO_SUPPORTED}) set(CMAKE_INTERPROCEDURAL_OPTIMIZATION_RELEASE ${IPO_SUPPORTED})
endif() endif()
# Static CRT # Static CRT:
set(CMAKE_MSVC_RUNTIME_LIBRARY "MultiThreaded$<$<CONFIG:Debug>:Debug>") set(CMAKE_MSVC_RUNTIME_LIBRARY "MultiThreaded$<$<CONFIG:Debug>:Debug>")
# Add build timestamp and details:
include("CMake/StampBuild.cmake")
add_executable(${CMAKE_PROJECT_NAME}) add_executable(${CMAKE_PROJECT_NAME})
add_subdirectory(src) add_subdirectory(src)
enable_warnings(${CMAKE_PROJECT_NAME})
build_dependencies(${CMAKE_PROJECT_NAME})
# Set the startup project to Cuberite, and the debugger dir: # Set the startup project to Cuberite, and the debugger dir:
set_property(DIRECTORY PROPERTY VS_STARTUP_PROJECT ${CMAKE_PROJECT_NAME}) set_property(DIRECTORY PROPERTY VS_STARTUP_PROJECT ${CMAKE_PROJECT_NAME})
set_target_properties(${CMAKE_PROJECT_NAME} PROPERTIES VS_DEBUGGER_WORKING_DIRECTORY "${CMAKE_BINARY_DIR}/Server") set_target_properties(${CMAKE_PROJECT_NAME} PROPERTIES VS_DEBUGGER_WORKING_DIRECTORY "${CMAKE_BINARY_DIR}/Server")
@ -93,8 +105,6 @@ if(${SELF_TEST})
add_subdirectory(tests) add_subdirectory(tests)
endif() endif()
include("CMake/AddDependencies.cmake") emit_fixups()
include("CMake/Fixups.cmake") group_sources()
include("CMake/GenerateBindings.cmake") enable_bindings_generation()
include("CMake/GroupSources.cmake")
include("SetFlags.cmake")

View File

@ -81,38 +81,44 @@ macro(enable_profile)
endif() endif()
endmacro() endmacro()
# Add coverage processing, if requested: function(set_global_flags)
if (NOT MSVC) if(MSVC)
# Make build use multiple threads under MSVC:
add_compile_options(/MP)
if (CMAKE_BUILD_TYPE STREQUAL "COVERAGE") # Make build use Unicode:
message("Including CodeCoverage") add_compile_definitions(UNICODE _UNICODE)
set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${CMAKE_SOURCE_DIR}/lib/cmake-coverage/") else()
include(CodeCoverage) # TODO: is this needed? NDEBUG is standard. Also, why are we using _DEBUG?
# Add the preprocessor macros used for distinguishing between debug and release builds (CMake does this automatically for MSVC):
set(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} -D_DEBUG")
set(CMAKE_C_FLAGS_DEBUG "${CMAKE_C_FLAGS_DEBUG} -D_DEBUG")
set(CMAKE_CXX_FLAGS_COVERAGE "${CMAKE_CXX_FLAGS_COVERAGE} -D_DEBUG")
set(CMAKE_C_FLAGS_COVERAGE "${CMAKE_C_FLAGS_COVERAGE} -D_DEBUG")
set(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} -DNDEBUG")
set(CMAKE_C_FLAGS_RELEASE "${CMAKE_C_FLAGS_RELEASE} -DNDEBUG")
endif() endif()
endif()
# TODO: is this needed? NDEBUG is standard. Also, why are we using _DEBUG? # Allow for a forced 32-bit build under 64-bit OS:
# Add the preprocessor macros used for distinguishing between debug and release builds (CMake does this automatically for MSVC): if (FORCE_32)
if (NOT MSVC) add_compile_options(-m32)
set(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} -D_DEBUG") add_link_options(-m32)
set(CMAKE_C_FLAGS_DEBUG "${CMAKE_C_FLAGS_DEBUG} -D_DEBUG") endif()
set(CMAKE_CXX_FLAGS_COVERAGE "${CMAKE_CXX_FLAGS_COVERAGE} -D_DEBUG")
set(CMAKE_C_FLAGS_COVERAGE "${CMAKE_C_FLAGS_COVERAGE} -D_DEBUG")
set(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} -DNDEBUG")
set(CMAKE_C_FLAGS_RELEASE "${CMAKE_C_FLAGS_RELEASE} -DNDEBUG")
endif()
if(MSVC) # Have the compiler generate code specifically targeted at the current machine on Linux:
# Make build use multiple threads under MSVC: if(LINUX AND NOT NO_NATIVE_OPTIMIZATION)
add_compile_options(/MP) add_compile_options(-march=native)
endif()
endfunction()
# Make build use Unicode: function(enable_warnings TARGET)
add_compile_definitions(UNICODE _UNICODE) if (MSVC)
# TODO: MSVC level 4, warnings as errors
return ()
endif()
# TODO: level 4, warnings as errors
else()
target_compile_options( target_compile_options(
${CMAKE_PROJECT_NAME} PRIVATE ${TARGET} PRIVATE
# We use a signed char (fixes #640 on RasPi) # We use a signed char (fixes #640 on RasPi)
# TODO: specify this in code, not a compile flag: # TODO: specify this in code, not a compile flag:
@ -135,7 +141,7 @@ else()
if(CMAKE_CXX_COMPILE_ID STREQUAL "Clang") if(CMAKE_CXX_COMPILE_ID STREQUAL "Clang")
target_compile_options( target_compile_options(
${CMAKE_PROJECT_NAME}Cuberite PRIVATE ${TARGET} PRIVATE
# Warnings-as-errors only on Clang for now: # Warnings-as-errors only on Clang for now:
-Werror -Werror
@ -147,15 +153,4 @@ else()
-Wno-error=unused-command-line-argument -Wno-error=unused-command-line-argument
) )
endif() endif()
endif() endfunction()
# Allow for a forced 32-bit build under 64-bit OS:
if (FORCE_32)
add_flags_cxx("-m32")
add_flags_lnk("-m32")
endif()
# Have the compiler generate code specifically targeted at the current machine on Linux:
if(LINUX AND NOT NO_NATIVE_OPTIMIZATION)
add_flags_cxx("-march=native")
endif()