From 6317176d7e890292cb40d6add96a1c81e8eeb08f Mon Sep 17 00:00:00 2001 From: Tiger Wang Date: Thu, 21 May 2020 23:52:19 +0100 Subject: More CMake cleanup --- .travis.yml | 28 ++- CMake/AddDependencies.cmake | 81 +++++++ CMake/StampBuild.cmake | 60 ++++++ CMakeLists.txt | 232 ++------------------ Server/Install/PackWindowsExecutables.cmd | 26 ++- SetFlags.cmake | 302 +++++++-------------------- Tools/AnvilStats/CMakeLists.txt | 6 - Tools/GrownBiomeGenVisualiser/CMakeLists.txt | 14 +- Tools/MCADefrag/CMakeLists.txt | 11 +- Tools/NoiseSpeedTest/CMakeLists.txt | 5 - Tools/ProtoProxy/CMakeLists.txt | 9 +- appveyor.yml | 77 ++----- clang-tidy.sh | 2 +- tests/Network/CMakeLists.txt | 8 +- travisbuild.sh | 15 +- 15 files changed, 311 insertions(+), 565 deletions(-) create mode 100644 CMake/AddDependencies.cmake create mode 100644 CMake/StampBuild.cmake 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$<$: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 0buildinfo.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 0buildinfo.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..." -- cgit v1.2.3