diff options
author | Tiger Wang <ziwei.tiger@outlook.com> | 2020-05-22 00:52:19 +0200 |
---|---|---|
committer | Tiger Wang <ziwei.tiger@outlook.com> | 2020-07-12 23:00:07 +0200 |
commit | 6317176d7e890292cb40d6add96a1c81e8eeb08f (patch) | |
tree | 6660c0df2d36933c2abe88e8f949eb552cf63c1e | |
parent | Remove Schematic Chunk height limitation (diff) | |
download | cuberite-6317176d7e890292cb40d6add96a1c81e8eeb08f.tar cuberite-6317176d7e890292cb40d6add96a1c81e8eeb08f.tar.gz cuberite-6317176d7e890292cb40d6add96a1c81e8eeb08f.tar.bz2 cuberite-6317176d7e890292cb40d6add96a1c81e8eeb08f.tar.lz cuberite-6317176d7e890292cb40d6add96a1c81e8eeb08f.tar.xz cuberite-6317176d7e890292cb40d6add96a1c81e8eeb08f.tar.zst cuberite-6317176d7e890292cb40d6add96a1c81e8eeb08f.zip |
Diffstat (limited to '')
-rw-r--r-- | .travis.yml | 28 | ||||
-rw-r--r-- | CMake/AddDependencies.cmake | 81 | ||||
-rw-r--r-- | CMake/StampBuild.cmake | 60 | ||||
-rw-r--r-- | CMakeLists.txt | 232 | ||||
-rw-r--r-- | Server/Install/PackWindowsExecutables.cmd | 26 | ||||
-rw-r--r-- | SetFlags.cmake | 302 | ||||
-rw-r--r-- | Tools/AnvilStats/CMakeLists.txt | 6 | ||||
-rw-r--r-- | Tools/GrownBiomeGenVisualiser/CMakeLists.txt | 14 | ||||
-rw-r--r-- | Tools/MCADefrag/CMakeLists.txt | 11 | ||||
-rw-r--r-- | Tools/NoiseSpeedTest/CMakeLists.txt | 5 | ||||
-rw-r--r-- | Tools/ProtoProxy/CMakeLists.txt | 9 | ||||
-rw-r--r-- | appveyor.yml | 77 | ||||
-rwxr-xr-x | clang-tidy.sh | 2 | ||||
-rw-r--r-- | tests/Network/CMakeLists.txt | 8 | ||||
-rwxr-xr-x | travisbuild.sh | 15 |
15 files changed, 311 insertions, 565 deletions
diff --git a/.travis.yml b/.travis.yml index a2a518751..79e51593a 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,22 +1,28 @@ language: cpp -cache: ccache +cache: + ccache: true + directories: + # Store ctest cost data + - Testing # Use Linux by default os: linux dist: bionic -# TODO: add ARM64, PPC, IBM builds when we find CMake for them +# TODO: add IBM builds when we find CMake for them +# add PowerPC builds when sqlite3 crashing is fixed jobs: include: - # OSX workers are slower to start up. Having these first in the build matrix makes travis faster overall. - - name: "AppleClang - Release" - os: osx - osx_image: xcode11.3 + # ARM workers are the slowest. Having these first in the build matrix makes travis faster overall. + - name: "Clang 6.0 - Debug" + arch: arm64 + compiler: clang before_install: - - HOMEBREW_NO_AUTO_UPDATE=1 brew install ccache - env: &Release - - TRAVIS_CUBERITE_BUILD_TYPE=Release + - wget --output-document=${HOME}/CMake http://anaconda.org/conda-forge/cmake/3.17.0/download/linux-aarch64/cmake-3.17.0-h28c56e5_0.tar.bz2 + - tar --extract --one-top-level=${HOME}/SeeMake --file ${HOME}/CMake + - export PATH=${HOME}/SeeMake/bin/:${PATH} + env: *Debug - name: "AppleClang - Debug" os: osx @@ -54,14 +60,14 @@ jobs: before_install: *use-cmake env: *Debug -before_script: - - export PATH=$(echo "$PATH" | sed -e 's/:\/usr\/lib\/ccache//') +# Run the build and tests script: ./travisbuild.sh notifications: email: on_success: change on_failure: always + branches: only: - master diff --git a/CMake/AddDependencies.cmake b/CMake/AddDependencies.cmake new file mode 100644 index 000000000..72eead340 --- /dev/null +++ b/CMake/AddDependencies.cmake @@ -0,0 +1,81 @@ +# 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 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.") + +# 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() + +# 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 +) + +# 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 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() diff --git a/CMake/StampBuild.cmake b/CMake/StampBuild.cmake new file mode 100644 index 000000000..db234b761 --- /dev/null +++ b/CMake/StampBuild.cmake @@ -0,0 +1,60 @@ +# These env variables are used for configuring Travis CI builds. +if(DEFINED ENV{TRAVIS_CUBERITE_FORCE32}) + set(FORCE32 $ENV{TRAVIS_CUBERITE_FORCE32}) +endif() + +if(DEFINED ENV{TRAVIS_BUILD_WITH_COVERAGE}) + set(BUILD_WITH_COVERAGE $ENV{TRAVIS_BUILD_WITH_COVERAGE}) +endif() + +if(DEFINED ENV{CUBERITE_BUILD_ID}) + # The build info is defined by the build system (Travis / Jenkins) + set(BUILD_ID $ENV{CUBERITE_BUILD_ID}) + set(BUILD_SERIES_NAME $ENV{CUBERITE_BUILD_SERIES_NAME}) + set(BUILD_DATETIME $ENV{CUBERITE_BUILD_DATETIME}) + if(DEFINED ENV{CUBERITE_BUILD_COMMIT_ID}) + set(BUILD_COMMIT_ID $ENV{CUBERITE_BUILD_COMMIT_ID}) + else() + message("Commit id not set, attempting to determine id from git") + execute_process( + COMMAND git rev-parse HEAD + WORKING_DIRECTORY ${CMAKE_CURRENT_LIST_DIR} + RESULT_VARIABLE GIT_EXECUTED + OUTPUT_VARIABLE BUILD_COMMIT_ID + ) + string(STRIP ${BUILD_COMMIT_ID} BUILD_COMMIT_ID) + if (NOT (GIT_EXECUTED EQUAL 0)) + message(FATAL_ERROR "Could not identifiy git commit id") + endif() + endif() +else() + # This is a local build, stuff in some basic info: + set(BUILD_ID "Unknown") + set(BUILD_SERIES_NAME "local build") + execute_process( + COMMAND git rev-parse HEAD + WORKING_DIRECTORY ${CMAKE_CURRENT_LIST_DIR} + RESULT_VARIABLE GIT_EXECUTED + OUTPUT_VARIABLE BUILD_COMMIT_ID + ) + if (NOT(GIT_EXECUTED EQUAL 0)) + set(BUILD_COMMIT_ID "Unknown") + endif() + string(STRIP ${BUILD_COMMIT_ID} BUILD_COMMIT_ID) + execute_process( + COMMAND git log -1 --date=iso --pretty=format:%ai + WORKING_DIRECTORY ${CMAKE_CURRENT_LIST_DIR} + RESULT_VARIABLE GIT_EXECUTED + OUTPUT_VARIABLE BUILD_DATETIME + ) + if (NOT(GIT_EXECUTED EQUAL 0)) + set(BUILD_DATETIME "Unknown") + endif() + string(STRIP ${BUILD_DATETIME} BUILD_DATETIME) + + # The BUILD_COMMIT_ID and BUILD_DATETIME aren't updated on each repo pull + # They are only updated when cmake re-configures the project + # Therefore mark them as "approx: " + set(BUILD_COMMIT_ID "approx: ${BUILD_COMMIT_ID}") + set(BUILD_DATETIME "approx: ${BUILD_DATETIME}") +endif() diff --git a/CMakeLists.txt b/CMakeLists.txt index 9f58696fe..f31f33f13 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -14,6 +14,7 @@ cmake_minimum_required (VERSION 3.13) +cmake_policy(VERSION 3.13...3.17.2) project( Cuberite DESCRIPTION "A lightweight, fast and extensible game server for Minecraft" @@ -22,76 +23,11 @@ project( ) option(BUILD_TOOLS "Sets up additional executables to be built along with the server" OFF) +option(WHOLE_PROGRAM_OPTIMISATION "Enables link time optimisation for Release" ON) option(PRECOMPILE_HEADERS "Enable precompiled headers for faster builds" ON) option(SELF_TEST "Enables testing code to be built" OFF) option(UNITY_BUILDS "Enables source aggregation for faster builds" ON) -# These env variables are used for configuring Travis CI builds. -if(DEFINED ENV{TRAVIS_CUBERITE_BUILD_TYPE}) - message("Setting build type to $ENV{TRAVIS_CUBERITE_BUILD_TYPE}") - set(CMAKE_BUILD_TYPE $ENV{TRAVIS_CUBERITE_BUILD_TYPE}) -endif() - -if(DEFINED ENV{TRAVIS_CUBERITE_FORCE32}) - set(FORCE32 $ENV{TRAVIS_CUBERITE_FORCE32}) -endif() - -if(DEFINED ENV{TRAVIS_BUILD_WITH_COVERAGE}) - set(BUILD_WITH_COVERAGE $ENV{TRAVIS_BUILD_WITH_COVERAGE}) -endif() - -if(DEFINED ENV{CUBERITE_BUILD_ID}) - # The build info is defined by the build system (Travis / Jenkins) - set(BUILD_ID $ENV{CUBERITE_BUILD_ID}) - set(BUILD_SERIES_NAME $ENV{CUBERITE_BUILD_SERIES_NAME}) - set(BUILD_DATETIME $ENV{CUBERITE_BUILD_DATETIME}) - if(DEFINED ENV{CUBERITE_BUILD_COMMIT_ID}) - set(BUILD_COMMIT_ID $ENV{CUBERITE_BUILD_COMMIT_ID}) - else() - message("Commit id not set, attempting to determine id from git") - execute_process( - COMMAND git rev-parse HEAD - WORKING_DIRECTORY ${CMAKE_CURRENT_LIST_DIR} - RESULT_VARIABLE GIT_EXECUTED - OUTPUT_VARIABLE BUILD_COMMIT_ID - ) - string(STRIP ${BUILD_COMMIT_ID} BUILD_COMMIT_ID) - if (NOT (GIT_EXECUTED EQUAL 0)) - message(FATAL_ERROR "Could not identifiy git commit id") - endif() - endif() -else() - # This is a local build, stuff in some basic info: - set(BUILD_ID "Unknown") - set(BUILD_SERIES_NAME "local build") - execute_process( - COMMAND git rev-parse HEAD - WORKING_DIRECTORY ${CMAKE_CURRENT_LIST_DIR} - RESULT_VARIABLE GIT_EXECUTED - OUTPUT_VARIABLE BUILD_COMMIT_ID - ) - if (NOT(GIT_EXECUTED EQUAL 0)) - set(BUILD_COMMIT_ID "Unknown") - endif() - string(STRIP ${BUILD_COMMIT_ID} BUILD_COMMIT_ID) - execute_process( - COMMAND git log -1 --date=iso --pretty=format:%ai - WORKING_DIRECTORY ${CMAKE_CURRENT_LIST_DIR} - RESULT_VARIABLE GIT_EXECUTED - OUTPUT_VARIABLE BUILD_DATETIME - ) - if (NOT(GIT_EXECUTED EQUAL 0)) - set(BUILD_DATETIME "Unknown") - endif() - string(STRIP ${BUILD_DATETIME} BUILD_DATETIME) - - # The BUILD_COMMIT_ID and BUILD_DATETIME aren't updated on each repo pull - # They are only updated when cmake re-configures the project - # Therefore mark them as "approx: " - set(BUILD_COMMIT_ID "approx: ${BUILD_COMMIT_ID}") - set(BUILD_DATETIME "approx: ${BUILD_DATETIME}") -endif() - # We need C++17 features set(CMAKE_CXX_STANDARD 17) set(CMAKE_CXX_STANDARD_REQUIRED ON) @@ -107,108 +43,9 @@ endif() # Static CRT set(CMAKE_MSVC_RUNTIME_LIBRARY "MultiThreaded$<$<CONFIG:Debug>:Debug>") -# This has to be done before any flags have been set up. -if(${BUILD_TOOLS}) - message("Building tools") - add_subdirectory(Tools/GrownBiomeGenVisualiser/) - add_subdirectory(Tools/MCADefrag/) - add_subdirectory(Tools/NoiseSpeedTest/) - add_subdirectory(Tools/ProtoProxy/) -endif() - -if(${BUILD_UNSTABLE_TOOLS}) - message("Building unstable tools") - add_subdirectory(Tools/GeneratorPerformanceTest/) -endif() - -include(SetFlags.cmake) -set_flags() -set_lib_flags() -enable_profile() - -# 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." FORCE) -set(SQLITECPP_RUN_CPPCHECK OFF CACHE BOOL "Run cppcheck C++ static analysis tool." FORCE) -set(SQLITECPP_RUN_DOXYGEN OFF CACHE BOOL "Run Doxygen C++ documentation tool." FORCE) -set(SQLITECPP_BUILD_EXAMPLES OFF CACHE BOOL "Build examples." FORCE) -set(SQLITECPP_BUILD_TESTS OFF CACHE BOOL "Build and run tests." FORCE) -set(SQLITECPP_INTERNAL_SQLITE ON CACHE BOOL "Add the internal SQLite3 source to the project." FORCE) -set(SQLITE_ENABLE_COLUMN_METADATA OFF CACHE BOOL "" FORCE) - -# Set options for LibEvent, disable all their tests and benchmarks: -set(EVENT__DISABLE_OPENSSL YES CACHE BOOL "Disable OpenSSL in LibEvent" FORCE) -set(EVENT__DISABLE_BENCHMARK YES CACHE BOOL "Disable LibEvent benchmarks" FORCE) -set(EVENT__DISABLE_TESTS YES CACHE BOOL "Disable LibEvent tests" FORCE) -set(EVENT__DISABLE_REGRESS YES CACHE BOOL "Disable LibEvent regression tests" FORCE) -set(EVENT__DISABLE_SAMPLES YES CACHE BOOL "Disable LibEvent samples" FORCE) -set(EVENT__LIBRARY_TYPE "STATIC" CACHE STRING "Use static LibEvent libraries" FORCE) - -# 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.") - -# Check that the libraries are present: -if (NOT EXISTS ${PROJECT_SOURCE_DIR}/lib/SQLiteCpp/CMakeLists.txt) - message(FATAL_ERROR "SQLiteCpp is missing in folder lib/SQLiteCpp. Have you initialized the submodules / downloaded the extra libraries?") -endif() -if (NOT EXISTS ${PROJECT_SOURCE_DIR}/lib/mbedtls/CMakeLists.txt) - message(FATAL_ERROR "mbedTLS is missing in folder lib/mbedtls. Have you initialized the submodules / downloaded the extra libraries?") -endif() -if (NOT EXISTS ${PROJECT_SOURCE_DIR}/lib/libevent/CMakeLists.txt) - message(FATAL_ERROR "LibEvent is missing in folder lib/libevent. Have you initialized and updated the submodules / downloaded the extra libraries?") -endif() -if (NOT EXISTS ${PROJECT_SOURCE_DIR}/lib/jsoncpp/CMakeLists.txt) - message(FATAL_ERROR "JsonCPP is missing in folder lib/jsoncpp. Have you initialized and updated the submodules / downloaded the extra libraries?") -endif() -if (NOT EXISTS ${PROJECT_SOURCE_DIR}/lib/cmake-coverage/CodeCoverage.cmake) - message(FATAL_ERROR "cmake-coverage is missing in folder lib/cmake-coverage. Have you initialized and updated the submodules / downloaded the extra libraries?") -endif() -if (NOT EXISTS ${PROJECT_SOURCE_DIR}/lib/expat/CMakeLists.txt) - message(FATAL_ERROR "expat is missing in folder lib/expat. Have you initialized and updated the submodules / downloaded the extra libraries?") -endif() -if (NOT EXISTS ${PROJECT_SOURCE_DIR}/lib/fmt/CMakeLists.txt) - message(FATAL_ERROR "fmt is missing in folder lib/fmt. Have you initialized and updated the submodules / downloaded the extra libraries?") -endif() -if (NOT EXISTS ${PROJECT_SOURCE_DIR}/lib/lua/CMakeLists.txt) - message(FATAL_ERROR "lua is missing in folder lib/lua. Have you initialized and updated the submodules / downloaded the extra libraries?") -endif() -if (NOT EXISTS ${PROJECT_SOURCE_DIR}/lib/luaexpat/CMakeLists.txt) - message(FATAL_ERROR "luaexpat is missing in folder lib/luaexpat. Have you initialized and updated the submodules / downloaded the extra libraries?") -endif() -if (NOT EXISTS ${PROJECT_SOURCE_DIR}/lib/luaproxy/CMakeLists.txt) - message(FATAL_ERROR "luaproxy is missing in folder lib/luaproxy. Have you initialized and updated the submodules / downloaded the extra libraries?") -endif() -if (NOT EXISTS ${PROJECT_SOURCE_DIR}/lib/sqlite/CMakeLists.txt) - message(FATAL_ERROR "sqlite is missing in folder lib/sqlite. Have you initialized and updated the submodules / downloaded the extra libraries?") -endif() -if (NOT EXISTS ${PROJECT_SOURCE_DIR}/lib/tolua++/CMakeLists.txt) - message(FATAL_ERROR "tolua++ is missing in folder lib/tolua++. Have you initialized and updated the submodules / downloaded the extra libraries?") -endif() -if (NOT EXISTS ${PROJECT_SOURCE_DIR}/lib/zlib/CMakeLists.txt) - message(FATAL_ERROR "zlib is missing in folder lib/zlib. 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/expat) -add_subdirectory(lib/fmt) -add_subdirectory(lib/jsoncpp EXCLUDE_FROM_ALL) -add_subdirectory(lib/libevent EXCLUDE_FROM_ALL) -add_subdirectory(lib/lua) -add_subdirectory(lib/luaexpat) -add_subdirectory(lib/mbedtls) -add_subdirectory(lib/SQLiteCpp) # SQLiteCpp needs to be included before sqlite so the lsqlite target is available -add_subdirectory(lib/sqlite) -add_subdirectory(lib/tolua++ EXCLUDE_FROM_ALL) -add_subdirectory(lib/zlib) +# Add build timestamp and details: +include("CMake/StampBuild.cmake") -set_exe_flags() add_executable(${CMAKE_PROJECT_NAME}) add_subdirectory(src) @@ -222,54 +59,11 @@ if (CMAKE_VERSION VERSION_GREATER_EQUAL "3.16") target_precompile_headers(${CMAKE_PROJECT_NAME} PRIVATE src/Globals.h) endif() - if (UNITY_BUILDS) - set_target_properties(${CMAKE_PROJECT_NAME} PROPERTIES UNITY_BUILD ON) - endif() + set_target_properties(${CMAKE_PROJECT_NAME} PROPERTIES UNITY_BUILD ${UNITY_BUILDS}) else() message(WARNING "Precompiled headers for FASTER BUILDS not enabled, upgrade to CMake 1.16 or newer!") endif() -# 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 -) - -# 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 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_static) -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() - # Selectively disable warnings in the level where the target is created: if(CMAKE_CXX_COMPILER_ID STREQUAL "Clang") # Generated file has old-style casts, missing prototypes, and deprecated declarations @@ -279,6 +73,19 @@ if(CMAKE_CXX_COMPILER_ID STREQUAL "Clang") set_source_files_properties("${CMAKE_SOURCE_DIR}/src/IniFile.cpp" PROPERTIES COMPILE_OPTIONS -Wno-header-hygiene) endif() +if(${BUILD_TOOLS}) + message("Building tools") + add_subdirectory(Tools/GrownBiomeGenVisualiser/) + add_subdirectory(Tools/MCADefrag/) + add_subdirectory(Tools/NoiseSpeedTest/) + add_subdirectory(Tools/ProtoProxy/) +endif() + +if(${BUILD_UNSTABLE_TOOLS}) + message("Building unstable tools") + add_subdirectory(Tools/GeneratorPerformanceTest/) +endif() + # Self Test Mode enables extra checks at startup if(${SELF_TEST}) message("Tests enabled") @@ -286,7 +93,8 @@ if(${SELF_TEST}) add_subdirectory(tests) endif() +include("CMake/AddDependencies.cmake") include("CMake/Fixups.cmake") include("CMake/GenerateBindings.cmake") include("CMake/GroupSources.cmake") -# TODO: include("CMake/SetCompilerFlags.cmake") +include("SetFlags.cmake") diff --git a/Server/Install/PackWindowsExecutables.cmd b/Server/Install/PackWindowsExecutables.cmd index 2909f1c40..3697afe2c 100644 --- a/Server/Install/PackWindowsExecutables.cmd +++ b/Server/Install/PackWindowsExecutables.cmd @@ -3,13 +3,20 @@ :: It is expected to be run with the Server folder as the current working dir @echo on -del Cuberite.zip -del PDBs.zip -del ManualAPI.zip -del AutoAPI.zip -rd /q /s Plugins\ManualApiDump +:: Only test that the server runs for pull requests +:: Don't upload any artifacts until it's merged into master +if defined APPVEYOR_PULL_REQUEST_NUMBER ( + echo stop 1>>cmds.txt + Cuberite --port 32767 0<cmds.txt + exit /b +) + +:: Main executables +echo Cuberite %APPVEYOR_JOB_NAME%-#%APPVEYOR_BUILD_NUMBER% 1>buildinfo.txt 7z a -tzip -y Cuberite.zip -scsWIN -i@Install\WindowsExecutables.list -xr!*.git* 7z a -tzip -y PDBs.zip -scsWIN -i@Install/WindowsPDBs.list -xr!*.git* + +:: Generate API documentation git clone https://github.com/madmaxoft/ManualApiDump Plugins/ManualApiDump echo load ManualApiDump 1>cmds.txt echo manualapi 1>>cmds.txt @@ -17,5 +24,14 @@ echo load APIDump 1>>cmds.txt echo api 1>>cmds.txt echo stop 1>>cmds.txt Cuberite --port 32767 0<cmds.txt + +:: API documentation 7z a -tzip -y ManualAPI.zip -scsWIN "ManualAPI.lua" 7z a -tzip -y AutoAPI.zip -scsWIN ".\BindingsDocs\*.lua" -x!_raw.lua + +:: Upload artifacts +appveyor PushArtifact Cuberite.zip +appveyor PushArtifact PDBs.zip +appveyor PushArtifact AutoAPI.zip +appveyor PushArtifact ManualAPI.zip +appveyor PushArtifact .luacheckrc diff --git a/SetFlags.cmake b/SetFlags.cmake index 1a154dd24..a65f3ecd7 100644 --- a/SetFlags.cmake +++ b/SetFlags.cmake @@ -1,5 +1,3 @@ - - macro (add_flags_lnk FLAGS) set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} ${FLAGS}") set(CMAKE_EXE_LINKER_FLAGS_DEBUG "${CMAKE_EXE_LINKER_FLAGS_DEBUG} ${FLAGS}") @@ -20,156 +18,6 @@ macro(add_flags_cxx FLAGS) set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${FLAGS}") endmacro() - -#this is a hack because we can't use cmake 2.8.10 because of travis -macro(get_clang_version) - execute_process( - COMMAND "${CMAKE_CXX_COMPILER}" "--version" - OUTPUT_VARIABLE CLANG_VERSION_OUTPUT) - string(REGEX MATCH "version ([0-9]+\\.[0-9]+)" x ${CLANG_VERSION_OUTPUT}) - set(CLANG_VERSION ${CMAKE_MATCH_1}) -endmacro() - - -macro(set_flags) - # Add coverage processing, if requested: - if (NOT MSVC) - - if (CMAKE_BUILD_TYPE STREQUAL "COVERAGE") - message("Including CodeCoverage") - set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${CMAKE_SOURCE_DIR}/lib/cmake-coverage/") - include(CodeCoverage) - endif() - endif() - - # Add the preprocessor macros used for distinguishing between debug and release builds (CMake does this automatically for MSVC): - if (NOT 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() - - if(MSVC) - # Make build use multiple threads under MSVC: - add_flags_cxx("/MP") - - # Make release builds use link-time code generation: - set(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} /GL") - set(CMAKE_C_FLAGS_RELEASE "${CMAKE_C_FLAGS_RELEASE} /GL") - set(CMAKE_EXE_LINKER_FLAGS_RELEASE "${CMAKE_EXE_LINKER_FLAGS_RELEASE} /LTCG") - set(CMAKE_SHARED_LINKER_FLAGS_RELEASE "${CMAKE_SHARED_LINKER_FLAGS_RELEASE} /LTCG") - set(CMAKE_MODULE_LINKER_FLAGS_RELEASE "${CMAKE_MODULE_LINKER_FLAGS_RELEASE} /LTCG") - - # Make MSVC generate the PDB files even for the release build - # (TODO: have AppVeyor build RelWithDebInfo and remove): - 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") - - # Make build use Unicode: - add_definitions(-DUNICODE -D_UNICODE) - elseif(APPLE) - - if("${CMAKE_CXX_COMPILER_ID}" STREQUAL "GNU") - execute_process( - COMMAND ${CMAKE_C_COMPILER} -dumpversion - OUTPUT_VARIABLE GCC_VERSION - ) - endif() - - #on os x clang adds pthread for us but we need to add it for gcc - if ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "Clang") - add_flags_cxx("-stdlib=libc++") - add_flags_lnk("-stdlib=libc++") - else() - add_flags_cxx("-pthread") - endif() - elseif (ANDROID) - add_flags_cxx("-fsigned-char") - else() - # Let gcc / clang know that we're compiling a multi-threaded app: - if (${UNIX}) - add_flags_cxx("-pthread") - add_flags_lnk("-pthread") - endif() - - if("${CMAKE_CXX_COMPILER_ID}" STREQUAL "GNU") - execute_process( - COMMAND ${CMAKE_C_COMPILER} -dumpversion - OUTPUT_VARIABLE GCC_VERSION - ) - endif() - - # We use a signed char (fixes #640 on RasPi) - add_flags_cxx("-fsigned-char") - - endif() - - - # 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() - - if(CROSSCOMPILE) - message(FATAL_ERROR "The CROSSCOMPILE flag has been renamed to NO_NATIVE_OPTIMIZATION. Please update your build scripts to compile Cuberite.") - endif() - - if ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "Clang") - get_clang_version() - endif() - - - # Use static CRT in MSVC builds: - if (MSVC) - string(REPLACE "/MD" "/MT" CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE}") - string(REPLACE "/MD" "/MT" CMAKE_C_FLAGS_RELEASE "${CMAKE_C_FLAGS_RELEASE}") - string(REPLACE "/MDd" "/MTd" CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG}") - string(REPLACE "/MDd" "/MTd" CMAKE_C_FLAGS_DEBUG "${CMAKE_C_FLAGS_DEBUG}") - endif() -endmacro() - -macro(set_lib_flags) - # Set lower warnings-level for the libraries: - if (MSVC) - # Remove /W3 from command line -- cannot just cancel it later with /w like in unix, MSVC produces a D9025 warning (option1 overriden by option2) - string(REPLACE "/W3" "" CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE}") - string(REPLACE "/W3" "" CMAKE_C_FLAGS_RELEASE "${CMAKE_C_FLAGS_RELEASE}") - string(REPLACE "/W3" "" CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG}") - string(REPLACE "/W3" "" CMAKE_C_FLAGS_DEBUG "${CMAKE_C_FLAGS_DEBUG}") - else() - set(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} -w") - set(CMAKE_C_FLAGS_RELEASE "${CMAKE_C_FLAGS_RELEASE} -w") - set(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} -w") - set(CMAKE_C_FLAGS_DEBUG "${CMAKE_C_FLAGS_DEBUG} -w") - set(CMAKE_CXX_FLAGS_COVERAGE "${CMAKE_CXX_FLAGS_COVERAGE} -w") - set(CMAKE_C_FLAGS_COVERAGE "${CMAKE_C_FLAGS_COVERAGE} -w") - endif() - - # On Unix we use two dynamic loading libraries dl and ltdl. - # Preference is for dl on unknown systems as it is specified in POSIX - # the dynamic loader is used by lua and sqllite. - if (UNIX) - if(${CMAKE_SYSTEM_NAME} STREQUAL "FreeBSD") - set(DYNAMIC_LOADER ltdl) - else() - set(DYNAMIC_LOADER dl) - endif() - endif() -endmacro() - macro(enable_profile) # Declare the flags used for profiling builds: if (MSVC) @@ -233,87 +81,81 @@ macro(enable_profile) endif() endmacro() -macro(set_exe_flags) - # Remove disabling the maximum warning level: - # clang does not like a command line that reads -Wall -Wextra -w -Wall -Wextra and does not output any warnings - # We do not do that for MSVC since MSVC produces an awful lot of warnings for its own STL headers; - # the important warnings are turned on using #pragma in Globals.h - if (NOT MSVC) - string(REPLACE "-w" "" CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE}") - string(REPLACE "-w" "" CMAKE_C_FLAGS_RELEASE "${CMAKE_C_FLAGS_RELEASE}") - string(REPLACE "-w" "" CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG}") - string(REPLACE "-w" "" CMAKE_C_FLAGS_DEBUG "${CMAKE_C_FLAGS_DEBUG}") - string(REPLACE "-w" "" CMAKE_CXX_FLAGS_COVERAGE "${CMAKE_CXX_FLAGS_COVERAGE}") - string(REPLACE "-w" "" CMAKE_C_FLAGS_COVERAGE "${CMAKE_C_FLAGS_COVERAGE}") - add_flags_cxx("-Wall -Wextra -Wno-unused-parameter -Wno-missing-noreturn") +# Add coverage processing, if requested: +if (NOT MSVC) - # we support non-IEEE 754 fpus so can make no guarentees about error - add_flags_cxx("-ffast-math") + if (CMAKE_BUILD_TYPE STREQUAL "COVERAGE") + message("Including CodeCoverage") + set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${CMAKE_SOURCE_DIR}/lib/cmake-coverage/") + include(CodeCoverage) + endif() +endif() + +# 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): +if (NOT 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() + +if(MSVC) + # Make build use multiple threads under MSVC: + add_compile_options(/MP) + + # Make build use Unicode: + add_compile_definitions(UNICODE _UNICODE) + + # TODO: level 4, warnings as errors +else() + target_compile_options( + ${CMAKE_PROJECT_NAME} PRIVATE - if(${CMAKE_SYSTEM_NAME} STREQUAL "FreeBSD") - # backtrace() and friends are in libexecinfo - add_flags_lnk("-lexecinfo") - endif() + # We use a signed char (fixes #640 on RasPi) + # TODO: specify this in code, not a compile flag: + -fsigned-char - if ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "Clang") - if ("${CLANG_VERSION}" VERSION_LESS 3.0) - message(FATAL_ERROR "Cuberite requires clang version 3.0 or higher, your version is ${CLANG_VERSION}") - endif() - # clang does not provide the __extern_always_inline macro and a part of libm depends on this when using fast-math - add_flags_cxx("-D__extern_always_inline=inline") - add_flags_cxx("-Weverything -Werror -Wno-c++98-compat-pedantic -Wno-string-conversion") - add_flags_cxx("-Wno-exit-time-destructors -Wno-padded -Wno-weak-vtables") - add_flags_cxx("-Wno-switch-enum") # This is a pretty useless warning, we've already got -Wswitch which is what we need - if ("${CLANG_VERSION}" VERSION_GREATER 3.0) - # flags that are not present in 3.0 - add_flags_cxx("-Wno-implicit-fallthrough") - endif() - if ("${CLANG_VERSION}" VERSION_GREATER 3.1) - # flags introduced in 3.2 - add_flags_cxx("-Wno-documentation") - endif() - if ("${CLANG_VERSION}" VERSION_GREATER 3.4) - add_flags_cxx("-Wno-error=disabled-macro-expansion") - endif() - if ("${CLANG_VERSION}" VERSION_GREATER 3.5) - include(CheckCXXCompilerFlag) - check_cxx_compiler_flag(-Wno-reserved-id-macro HAS_NO_RESERVED_ID_MACRO) - check_cxx_compiler_flag(-Wno-documentation-unknown-command HAS_NO_DOCUMENTATION_UNKNOWN) - if (HAS_NO_RESERVED_ID_MACRO) - # Use this flag to ignore error for a reserved macro problem in sqlite 3 - add_flags_cxx("-Wno-reserved-id-macro") - endif() - if (HAS_NO_DOCUMENTATION_UNKNOWN) - # Ignore another problem in sqlite - add_flags_cxx("-Wno-documentation-unknown-command") - endif() - endif() - if ("${CLANG_VERSION}" VERSION_GREATER 3.7) - check_cxx_compiler_flag(-Wno-double-promotion HAS_NO_DOUBLE_PROMOTION) - if (HAS_NO_DOUBLE_PROMOTION) - add_flags_cxx("-Wno-double-promotion") - endif() - endif() - add_flags_cxx("-Wno-error=unused-command-line-argument") - add_flags_cxx("-Wno-documentation-unknown-command") - endif() - endif() + # We support non-IEEE 754 FPUs so can make no guarantees about error: + -ffast-math -endmacro() + # All warnings: + -Wall -Wextra + + # TODO: actually fix the warnings instead of disabling them + # or at least disable on a file-level basis: + -Wno-unused-parameter -Wno-missing-noreturn -Wno-padded -Wno-implicit-fallthrough + -Wno-double-promotion -# if("${CMAKE_CXX_COMPILER_ID}" STREQUAL "Clang") -# foreach(FILENAME ${ARGN}) -# message("downgrade_warnings for ${FILENAME}") -# set_source_files_properties(${FILENAME} PROPERTIES COMPILE_FLAGS "-Wno-error=sign-conversion -Wno-error=conversion") -# set_source_files_properties(${FILENAME} PROPERTIES COMPILE_FLAGS "-Wno-error=missing-prototypes -Wno-error=deprecated") -# set_source_files_properties(${FILENAME} PROPERTIES COMPILE_FLAGS "-Wno-error=shadow -Wno-error=old-style-cast -Wno-error=switch-enum -Wno-error=switch") -# set_source_files_properties(${FILENAME} PROPERTIES COMPILE_FLAGS "-Wno-error=float-equal -Wno-error=global-constructors") + # This is a pretty useless warning, we've already got -Wswitch which is what we need: + -Wno-switch-enum + ) -# if ("${CLANG_VERSION}" VERSION_GREATER 3.0) -# # flags that are not present in 3.0 -# set_source_files_properties(${FILENAME} PROPERTIES COMPILE_FLAGS "-Wno-error=covered-switch-default ") -# set_source_files_properties(${FILENAME} PROPERTIES COMPILE_FLAGS "-Wno-implicit-fallthrough -Wno-error=extra-semi") -# set_source_files_properties(${FILENAME} PROPERTIES COMPILE_FLAGS "-Wno-error=missing-variable-declarations") -# endif() -# endforeach() -# endif() + if(CMAKE_CXX_COMPILE_ID STREQUAL "Clang") + target_compile_options( + ${CMAKE_PROJECT_NAME}Cuberite PRIVATE + + # Warnings-as-errors only on Clang for now: + -Werror + + # Weverything with Clang exceptions: + -Weverything -Wno-error=disabled-macro-expansion -Wno-weak-vtables + -Wno-exit-time-destructors -Wno-string-conversion -Wno-c++98-compat-pedantic + -Wno-documentation -Wno-documentation-unknown-command -Wno-reserved-id-macro + -Wno-error=unused-command-line-argument + ) + endif() +endif() + +# 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() diff --git a/Tools/AnvilStats/CMakeLists.txt b/Tools/AnvilStats/CMakeLists.txt index 865414a6d..a5cf4b9e7 100644 --- a/Tools/AnvilStats/CMakeLists.txt +++ b/Tools/AnvilStats/CMakeLists.txt @@ -2,10 +2,6 @@ project (AnvilStats) include(../../SetFlags.cmake) -set_flags() -set_lib_flags() - - # Set include paths to the used libraries: include_directories("../../lib") include_directories("../../src") @@ -23,8 +19,6 @@ endfunction() add_subdirectory(../../lib/zlib ${CMAKE_CURRENT_BINARY_DIR}/${CMAKE_FILES_DIRECTORY}/lib/zlib) -set_exe_flags() - # Include the shared files: set(SHARED_SRC ../../src/ByteBuffer.cpp diff --git a/Tools/GrownBiomeGenVisualiser/CMakeLists.txt b/Tools/GrownBiomeGenVisualiser/CMakeLists.txt index c3fa4ac32..ed8cd5d1d 100644 --- a/Tools/GrownBiomeGenVisualiser/CMakeLists.txt +++ b/Tools/GrownBiomeGenVisualiser/CMakeLists.txt @@ -1,13 +1,7 @@ project (GrownBiomeGenVisualiser) - -# Without this, the MSVC variable isn't defined for MSVC builds ( https://www.cmake.org/pipermail/cmake/2011-November/047130.html ) -enable_language(CXX C) +find_package(Threads REQUIRED) include(../../SetFlags.cmake) -set_flags() -set_lib_flags() -enable_profile() - # Set include paths to the used libraries: include_directories(SYSTEM "../../lib") @@ -24,10 +18,6 @@ function(flatten_files arg1) endfunction() -# Include the libraries: - -set_exe_flags() - # Include the shared files: set(SHARED_SRC ../../src/StringUtils.cpp @@ -89,6 +79,6 @@ add_executable(GrownBiomeGenVisualiser ${SHARED_OSS_HDR} ) -target_link_libraries(GrownBiomeGenVisualiser fmt::fmt) +target_link_libraries(GrownBiomeGenVisualiser fmt::fmt Threads::Threads) set_target_properties(GrownBiomeGenVisualiser PROPERTIES FOLDER Tools) diff --git a/Tools/MCADefrag/CMakeLists.txt b/Tools/MCADefrag/CMakeLists.txt index 05b7ff8bc..b093a759b 100644 --- a/Tools/MCADefrag/CMakeLists.txt +++ b/Tools/MCADefrag/CMakeLists.txt @@ -1,13 +1,8 @@ cmake_minimum_required(VERSION 3.13) project (MCADefrag) - -# Without this, the MSVC variable isn't defined for MSVC builds ( https://www.cmake.org/pipermail/cmake/2011-November/047130.html ) -enable_language(CXX C) +find_package(Threads REQUIRED) include(../../SetFlags.cmake) -set_flags() -set_lib_flags() -enable_profile() # Set include paths to the used libraries: include_directories(SYSTEM "../../lib") @@ -28,8 +23,6 @@ endfunction() add_subdirectory(../../lib/zlib ${CMAKE_CURRENT_BINARY_DIR}/${CMAKE_FILES_DIRECTORY}/lib/zlib) -set_exe_flags() - # Include the shared files: set(SHARED_SRC ../../src/StringCompression.cpp @@ -93,4 +86,4 @@ add_executable(MCADefrag ${SHARED_OSS_HDR} ) -target_link_libraries(MCADefrag zlib fmt::fmt) +target_link_libraries(MCADefrag zlib fmt::fmt Threads::Threads) diff --git a/Tools/NoiseSpeedTest/CMakeLists.txt b/Tools/NoiseSpeedTest/CMakeLists.txt index b451a61d3..f207cead3 100644 --- a/Tools/NoiseSpeedTest/CMakeLists.txt +++ b/Tools/NoiseSpeedTest/CMakeLists.txt @@ -1,16 +1,11 @@ project (NoiseSpeedTest) include(../../SetFlags.cmake) -set_flags() -set_lib_flags() -enable_profile() # Set include paths to the used libraries: include_directories(SYSTEM "../../lib") include_directories("../../src") -set_exe_flags() - # Include the shared files: set(SHARED_SRC ../../src/Logger.cpp diff --git a/Tools/ProtoProxy/CMakeLists.txt b/Tools/ProtoProxy/CMakeLists.txt index 431c29daa..8f3228a47 100644 --- a/Tools/ProtoProxy/CMakeLists.txt +++ b/Tools/ProtoProxy/CMakeLists.txt @@ -1,11 +1,8 @@ project (ProtoProxy) +find_package(Threads REQUIRED) include(../../SetFlags.cmake) -set_flags() -set_lib_flags() - - # Set include paths to the used libraries: include_directories(SYSTEM "../../lib") include_directories(SYSTEM "../../lib/mbedtls/include") @@ -22,8 +19,6 @@ endfunction() add_subdirectory(../../lib/zlib ${CMAKE_CURRENT_BINARY_DIR}/${CMAKE_FILES_DIRECTORY}/lib/zlib) -set_exe_flags() - # Include the shared files: set(SHARED_SRC ../../src/ByteBuffer.cpp @@ -99,5 +94,5 @@ add_executable(ProtoProxy ${SHARED_OSS_HDR} ) -target_link_libraries(ProtoProxy zlib mbedtls fmt::fmt) +target_link_libraries(ProtoProxy zlib mbedtls fmt::fmt Threads::Threads) diff --git a/appveyor.yml b/appveyor.yml index bb3847585..ac6ef7c1a 100644 --- a/appveyor.yml +++ b/appveyor.yml @@ -5,6 +5,10 @@ image: - Visual Studio 2019 - Visual Studio 2017 +branches: + only: + - master + # Set up environment variables for build info environment: CUBERITE_BUILD_SERIES_NAME: AppVeyor @@ -12,17 +16,17 @@ environment: CUBERITE_BUILD_DATETIME: "%APPVEYOR_REPO_COMMIT_TIMESTAMP%" matrix: - - job_name: Windows-x64-debug + - job_name: Windows-x64-Debug configuration: Debug - BUILD_DIR: Debug-x64 + BUILD_DIR: Debug x64 - job_name: Windows-x86 configuration: Release - BUILD_DIR: Release-x86 + BUILD_DIR: Release x86 - job_name: Windows-x64 configuration: Release - BUILD_DIR: Release-x64 + BUILD_DIR: Release x64 matrix: exclude: @@ -31,10 +35,18 @@ matrix: - image: Visual Studio 2019 configuration: Debug +build: + project: '%BUILD_DIR%\Cuberite.sln' + parallel: true + verbosity: minimal + +pull_requests: + do_not_increment_build_number: true install: -- echo %TIME% - git submodule update --init +- if not exist "%BUILD_DIR%" mkdir "%BUILD_DIR%" +- cd "%BUILD_DIR%" for: ############################## @@ -43,21 +55,11 @@ for: - matrix: only: - - job_name: Windows-x64-debug + - job_name: Windows-x64-Debug before_build: - - if not exist %BUILD_DIR% mkdir %BUILD_DIR% - - cd %BUILD_DIR% - - echo %TIME% # TODO: re-add -DSELF_TEST=YES -DBUILD_TOOLS=YES once PCH for tools enabled (too slow otherwise) - - cmake -G "Visual Studio 15 2017" -A "x64" -DSELF_TEST=NO -DBUILD_TOOLS=NO .. - - echo %TIME% - - cd .. - - build: - project: Debug-x64\Cuberite.sln - parallel: true - verbosity: minimal + - cmake -G "Visual Studio 15 2017" -DSELF_TEST=No -DBUILD_TOOLS=No .. ################################ # Windows 32-bit release build # @@ -67,22 +69,8 @@ for: only: - job_name: Windows-x86 - branches: - only: - - master - before_build: - - if not exist %BUILD_DIR% mkdir %BUILD_DIR% - - cd %BUILD_DIR% - - echo %TIME% - cmake -G "Visual Studio 16 2019" .. - - echo %TIME% - - cd .. - - build: - project: Release-x86\Cuberite.sln - parallel: true - verbosity: minimal ################################ # Windows 64-bit release build # @@ -92,41 +80,18 @@ for: only: - job_name: Windows-x64 - branches: - only: - - master - before_build: - - if not exist %BUILD_DIR% mkdir %BUILD_DIR% - - cd %BUILD_DIR% - - echo %TIME% - cmake -G "Visual Studio 16 2019" -A "x64" .. - - echo %TIME% - - cd .. - - build: - project: Release-x64\Cuberite.sln - parallel: true - verbosity: minimal ########################################### # Cache for speeding up subsequent builds # ########################################### cache: - - Debug-x64\CMakeCache.txt - - Release-x86\CMakeCache.txt - - Release-x64\CMakeCache.txt + - '%BUILD_DIR%\CMakeCache.txt' ##################### # Package artifacts # ##################### - after_build: -- cd %BUILD_DIR%\Server -- echo Cuberite %APPVEYOR_JOB_NAME%-#%APPVEYOR_BUILD_NUMBER% 1>buildinfo.txt +- cd Server - Install\PackWindowsExecutables.cmd -- appveyor PushArtifact Cuberite.zip -FileName Cuberite.zip -- appveyor PushArtifact PDBs.zip -FileName PDBs.zip -- appveyor PushArtifact AutoAPI.zip -FileName AutoAPI.zip -- appveyor PushArtifact ManualAPI.zip -FileName ManualAPI.zip -- appveyor PushArtifact .luacheckrc -FileName .luacheckrc diff --git a/clang-tidy.sh b/clang-tidy.sh index fb99bc189..8527ae02d 100755 --- a/clang-tidy.sh +++ b/clang-tidy.sh @@ -12,7 +12,7 @@ cd tidy-build # Disable precompiled headers since they aren't generated during linting which causes an error # Disable unity builds since clang-tidy needs the full list of compiled files to check each one -cmake --target Cuberite -DCMAKE_EXPORT_COMPILE_COMMANDS=ON -DPRECOMPILE_HEADERS=OFF -DUNITY_BUILDS=OFF .. +cmake --target Cuberite -DCMAKE_EXPORT_COMPILE_COMMANDS=Yes -DPRECOMPILE_HEADERS=No -DUNITY_BUILDS=No .. # Ensure LuaState_Typedefs.inc has been generated (cd ../src/Bindings && lua BindingsProcessor.lua) diff --git a/tests/Network/CMakeLists.txt b/tests/Network/CMakeLists.txt index 12759558e..8bbe6294d 100644 --- a/tests/Network/CMakeLists.txt +++ b/tests/Network/CMakeLists.txt @@ -1,6 +1,8 @@ include_directories(${CMAKE_SOURCE_DIR}/src/) include_directories(SYSTEM ${CMAKE_SOURCE_DIR}/lib/mbedtls/include) +find_package(Threads REQUIRED) + # Create a single Network library that contains all the networking code: set (Network_SRCS ${CMAKE_SOURCE_DIR}/src/OSSupport/CriticalSection.cpp @@ -54,10 +56,8 @@ add_library(Network ) target_link_libraries(Network event_core event_extra fmt::fmt mbedtls) -if (WIN32) - target_link_libraries(Network ws2_32.lib) -else() - target_link_libraries(Network event_pthreads_static) +if(NOT WIN32) + target_link_libraries(Network event_pthreads Threads::Threads) endif() diff --git a/travisbuild.sh b/travisbuild.sh index d1a535e72..9b93e35e8 100755 --- a/travisbuild.sh +++ b/travisbuild.sh @@ -16,16 +16,17 @@ if [ `which ccache` ]; then CACHE_ARGS="-DCMAKE_C_COMPILER_LAUNCHER=ccache -DCMAKE_CXX_COMPILER_LAUNCHER=ccache" echo "Using ccache installed at $(which ccache)" - ccache --max-size=3G - ccache -z # Zero statistics + ccache --max-size=1G + ccache --zero-stats fi # Work around a Clang + ccache issue with failing builds by disabling # precompiled headers. Turn off LTO for faster build speeds -cmake . -DBUILD_TOOLS=YES \ - -DPRECOMPILE_HEADERS=NO \ - -DUNITY_BUILDS=${TRAVIS_CUBERITE_UNITY_BUILDS-YES} \ - -DSELF_TEST=YES \ +cmake . -DCMAKE_BUILD_TYPE=${TRAVIS_CUBERITE_BUILD_TYPE} \ + -DBUILD_TOOLS=Yes \ + -DPRECOMPILE_HEADERS=No \ + -DSELF_TEST=Yes \ + -DUNITY_BUILDS=${TRAVIS_CUBERITE_UNITY_BUILDS-Yes} \ -DWHOLE_PROGRAM_OPTIMISATION=No \ ${CACHE_ARGS}; @@ -34,7 +35,7 @@ cmake --build . --parallel 2; if [ `which ccache` ]; then echo "Built with ccache, outputting cache stats..." - ccache -s + ccache --show-stats fi echo "Testing..." |