1
0

More CMake cleanup

This commit is contained in:
Tiger Wang 2020-05-21 23:52:19 +01:00
parent d0f38f52cb
commit 6317176d7e
15 changed files with 312 additions and 566 deletions

View File

@ -1,22 +1,28 @@
language: cpp language: cpp
cache: ccache cache:
ccache: true
directories:
# Store ctest cost data
- Testing
# Use Linux by default # Use Linux by default
os: linux os: linux
dist: bionic 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: jobs:
include: include:
# OSX workers are slower to start up. Having these first in the build matrix makes travis faster overall. # ARM workers are the slowest. Having these first in the build matrix makes travis faster overall.
- name: "AppleClang - Release" - name: "Clang 6.0 - Debug"
os: osx arch: arm64
osx_image: xcode11.3 compiler: clang
before_install: before_install:
- HOMEBREW_NO_AUTO_UPDATE=1 brew install ccache - 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
env: &Release - tar --extract --one-top-level=${HOME}/SeeMake --file ${HOME}/CMake
- TRAVIS_CUBERITE_BUILD_TYPE=Release - export PATH=${HOME}/SeeMake/bin/:${PATH}
env: *Debug
- name: "AppleClang - Debug" - name: "AppleClang - Debug"
os: osx os: osx
@ -54,14 +60,14 @@ jobs:
before_install: *use-cmake before_install: *use-cmake
env: *Debug env: *Debug
before_script: # Run the build and tests
- export PATH=$(echo "$PATH" | sed -e 's/:\/usr\/lib\/ccache//')
script: ./travisbuild.sh script: ./travisbuild.sh
notifications: notifications:
email: email:
on_success: change on_success: change
on_failure: always on_failure: always
branches: branches:
only: only:
- master - master

View File

@ -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()

60
CMake/StampBuild.cmake Normal file
View File

@ -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()

View File

@ -14,6 +14,7 @@
cmake_minimum_required (VERSION 3.13) cmake_minimum_required (VERSION 3.13)
cmake_policy(VERSION 3.13...3.17.2)
project( project(
Cuberite Cuberite
DESCRIPTION "A lightweight, fast and extensible game server for Minecraft" 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(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(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)
# 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 # 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)
@ -107,108 +43,9 @@ endif()
# Static CRT # Static CRT
set(CMAKE_MSVC_RUNTIME_LIBRARY "MultiThreaded$<$<CONFIG:Debug>:Debug>") set(CMAKE_MSVC_RUNTIME_LIBRARY "MultiThreaded$<$<CONFIG:Debug>:Debug>")
# This has to be done before any flags have been set up. # Add build timestamp and details:
if(${BUILD_TOOLS}) include("CMake/StampBuild.cmake")
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)
set_exe_flags()
add_executable(${CMAKE_PROJECT_NAME}) add_executable(${CMAKE_PROJECT_NAME})
add_subdirectory(src) 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) target_precompile_headers(${CMAKE_PROJECT_NAME} PRIVATE src/Globals.h)
endif() endif()
if (UNITY_BUILDS) set_target_properties(${CMAKE_PROJECT_NAME} PROPERTIES UNITY_BUILD ${UNITY_BUILDS})
set_target_properties(${CMAKE_PROJECT_NAME} PROPERTIES UNITY_BUILD ON)
endif()
else() else()
message(WARNING "Precompiled headers for FASTER BUILDS not enabled, upgrade to CMake 1.16 or newer!") message(WARNING "Precompiled headers for FASTER BUILDS not enabled, upgrade to CMake 1.16 or newer!")
endif() 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: # Selectively disable warnings in the level where the target is created:
if(CMAKE_CXX_COMPILER_ID STREQUAL "Clang") if(CMAKE_CXX_COMPILER_ID STREQUAL "Clang")
# Generated file has old-style casts, missing prototypes, and deprecated declarations # 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) set_source_files_properties("${CMAKE_SOURCE_DIR}/src/IniFile.cpp" PROPERTIES COMPILE_OPTIONS -Wno-header-hygiene)
endif() 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 # Self Test Mode enables extra checks at startup
if(${SELF_TEST}) if(${SELF_TEST})
message("Tests enabled") message("Tests enabled")
@ -286,7 +93,8 @@ if(${SELF_TEST})
add_subdirectory(tests) add_subdirectory(tests)
endif() endif()
include("CMake/AddDependencies.cmake")
include("CMake/Fixups.cmake") include("CMake/Fixups.cmake")
include("CMake/GenerateBindings.cmake") include("CMake/GenerateBindings.cmake")
include("CMake/GroupSources.cmake") include("CMake/GroupSources.cmake")
# TODO: include("CMake/SetCompilerFlags.cmake") include("SetFlags.cmake")

View File

@ -3,13 +3,20 @@
:: It is expected to be run with the Server folder as the current working dir :: It is expected to be run with the Server folder as the current working dir
@echo on @echo on
del Cuberite.zip :: Only test that the server runs for pull requests
del PDBs.zip :: Don't upload any artifacts until it's merged into master
del ManualAPI.zip if defined APPVEYOR_PULL_REQUEST_NUMBER (
del AutoAPI.zip echo stop 1>>cmds.txt
rd /q /s Plugins\ManualApiDump 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 Cuberite.zip -scsWIN -i@Install\WindowsExecutables.list -xr!*.git*
7z a -tzip -y PDBs.zip -scsWIN -i@Install/WindowsPDBs.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 git clone https://github.com/madmaxoft/ManualApiDump Plugins/ManualApiDump
echo load ManualApiDump 1>cmds.txt echo load ManualApiDump 1>cmds.txt
echo manualapi 1>>cmds.txt echo manualapi 1>>cmds.txt
@ -17,5 +24,14 @@ echo load APIDump 1>>cmds.txt
echo api 1>>cmds.txt echo api 1>>cmds.txt
echo stop 1>>cmds.txt echo stop 1>>cmds.txt
Cuberite --port 32767 0<cmds.txt Cuberite --port 32767 0<cmds.txt
:: API documentation
7z a -tzip -y ManualAPI.zip -scsWIN "ManualAPI.lua" 7z a -tzip -y ManualAPI.zip -scsWIN "ManualAPI.lua"
7z a -tzip -y AutoAPI.zip -scsWIN ".\BindingsDocs\*.lua" -x!_raw.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

View File

@ -1,5 +1,3 @@
macro (add_flags_lnk FLAGS) macro (add_flags_lnk FLAGS)
set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} ${FLAGS}") set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} ${FLAGS}")
set(CMAKE_EXE_LINKER_FLAGS_DEBUG "${CMAKE_EXE_LINKER_FLAGS_DEBUG} ${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}") set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${FLAGS}")
endmacro() 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) macro(enable_profile)
# Declare the flags used for profiling builds: # Declare the flags used for profiling builds:
if (MSVC) if (MSVC)
@ -233,87 +81,81 @@ macro(enable_profile)
endif() endif()
endmacro() endmacro()
macro(set_exe_flags) # Add coverage processing, if requested:
# Remove disabling the maximum warning level: if (NOT MSVC)
# 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")
# we support non-IEEE 754 fpus so can make no guarentees about error if (CMAKE_BUILD_TYPE STREQUAL "COVERAGE")
add_flags_cxx("-ffast-math") message("Including CodeCoverage")
set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${CMAKE_SOURCE_DIR}/lib/cmake-coverage/")
include(CodeCoverage)
endif()
endif()
if(${CMAKE_SYSTEM_NAME} STREQUAL "FreeBSD") # TODO: is this needed? NDEBUG is standard. Also, why are we using _DEBUG?
# backtrace() and friends are in libexecinfo # Add the preprocessor macros used for distinguishing between debug and release builds (CMake does this automatically for MSVC):
add_flags_lnk("-lexecinfo") if (NOT MSVC)
endif() 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 ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "Clang") if(MSVC)
if ("${CLANG_VERSION}" VERSION_LESS 3.0) # Make build use multiple threads under MSVC:
message(FATAL_ERROR "Cuberite requires clang version 3.0 or higher, your version is ${CLANG_VERSION}") add_compile_options(/MP)
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()
endmacro() # Make build use Unicode:
add_compile_definitions(UNICODE _UNICODE)
# if("${CMAKE_CXX_COMPILER_ID}" STREQUAL "Clang") # TODO: level 4, warnings as errors
# foreach(FILENAME ${ARGN}) else()
# message("downgrade_warnings for ${FILENAME}") target_compile_options(
# set_source_files_properties(${FILENAME} PROPERTIES COMPILE_FLAGS "-Wno-error=sign-conversion -Wno-error=conversion") ${CMAKE_PROJECT_NAME} PRIVATE
# 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")
# if ("${CLANG_VERSION}" VERSION_GREATER 3.0) # We use a signed char (fixes #640 on RasPi)
# # flags that are not present in 3.0 # TODO: specify this in code, not a compile flag:
# set_source_files_properties(${FILENAME} PROPERTIES COMPILE_FLAGS "-Wno-error=covered-switch-default ") -fsigned-char
# 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") # We support non-IEEE 754 FPUs so can make no guarantees about error:
# endif() -ffast-math
# endforeach()
# endif() # 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
# This is a pretty useless warning, we've already got -Wswitch which is what we need:
-Wno-switch-enum
)
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()

View File

@ -2,10 +2,6 @@ project (AnvilStats)
include(../../SetFlags.cmake) include(../../SetFlags.cmake)
set_flags()
set_lib_flags()
# Set include paths to the used libraries: # Set include paths to the used libraries:
include_directories("../../lib") include_directories("../../lib")
include_directories("../../src") include_directories("../../src")
@ -23,8 +19,6 @@ endfunction()
add_subdirectory(../../lib/zlib ${CMAKE_CURRENT_BINARY_DIR}/${CMAKE_FILES_DIRECTORY}/lib/zlib) add_subdirectory(../../lib/zlib ${CMAKE_CURRENT_BINARY_DIR}/${CMAKE_FILES_DIRECTORY}/lib/zlib)
set_exe_flags()
# Include the shared files: # Include the shared files:
set(SHARED_SRC set(SHARED_SRC
../../src/ByteBuffer.cpp ../../src/ByteBuffer.cpp

View File

@ -1,13 +1,7 @@
project (GrownBiomeGenVisualiser) project (GrownBiomeGenVisualiser)
find_package(Threads REQUIRED)
# 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)
include(../../SetFlags.cmake) include(../../SetFlags.cmake)
set_flags()
set_lib_flags()
enable_profile()
# Set include paths to the used libraries: # Set include paths to the used libraries:
include_directories(SYSTEM "../../lib") include_directories(SYSTEM "../../lib")
@ -24,10 +18,6 @@ function(flatten_files arg1)
endfunction() endfunction()
# Include the libraries:
set_exe_flags()
# Include the shared files: # Include the shared files:
set(SHARED_SRC set(SHARED_SRC
../../src/StringUtils.cpp ../../src/StringUtils.cpp
@ -89,6 +79,6 @@ add_executable(GrownBiomeGenVisualiser
${SHARED_OSS_HDR} ${SHARED_OSS_HDR}
) )
target_link_libraries(GrownBiomeGenVisualiser fmt::fmt) target_link_libraries(GrownBiomeGenVisualiser fmt::fmt Threads::Threads)
set_target_properties(GrownBiomeGenVisualiser PROPERTIES FOLDER Tools) set_target_properties(GrownBiomeGenVisualiser PROPERTIES FOLDER Tools)

View File

@ -1,13 +1,8 @@
cmake_minimum_required(VERSION 3.13) cmake_minimum_required(VERSION 3.13)
project (MCADefrag) project (MCADefrag)
find_package(Threads REQUIRED)
# 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)
include(../../SetFlags.cmake) include(../../SetFlags.cmake)
set_flags()
set_lib_flags()
enable_profile()
# Set include paths to the used libraries: # Set include paths to the used libraries:
include_directories(SYSTEM "../../lib") include_directories(SYSTEM "../../lib")
@ -28,8 +23,6 @@ endfunction()
add_subdirectory(../../lib/zlib ${CMAKE_CURRENT_BINARY_DIR}/${CMAKE_FILES_DIRECTORY}/lib/zlib) add_subdirectory(../../lib/zlib ${CMAKE_CURRENT_BINARY_DIR}/${CMAKE_FILES_DIRECTORY}/lib/zlib)
set_exe_flags()
# Include the shared files: # Include the shared files:
set(SHARED_SRC set(SHARED_SRC
../../src/StringCompression.cpp ../../src/StringCompression.cpp
@ -93,4 +86,4 @@ add_executable(MCADefrag
${SHARED_OSS_HDR} ${SHARED_OSS_HDR}
) )
target_link_libraries(MCADefrag zlib fmt::fmt) target_link_libraries(MCADefrag zlib fmt::fmt Threads::Threads)

View File

@ -1,16 +1,11 @@
project (NoiseSpeedTest) project (NoiseSpeedTest)
include(../../SetFlags.cmake) include(../../SetFlags.cmake)
set_flags()
set_lib_flags()
enable_profile()
# Set include paths to the used libraries: # Set include paths to the used libraries:
include_directories(SYSTEM "../../lib") include_directories(SYSTEM "../../lib")
include_directories("../../src") include_directories("../../src")
set_exe_flags()
# Include the shared files: # Include the shared files:
set(SHARED_SRC set(SHARED_SRC
../../src/Logger.cpp ../../src/Logger.cpp

View File

@ -1,11 +1,8 @@
project (ProtoProxy) project (ProtoProxy)
find_package(Threads REQUIRED)
include(../../SetFlags.cmake) include(../../SetFlags.cmake)
set_flags()
set_lib_flags()
# Set include paths to the used libraries: # Set include paths to the used libraries:
include_directories(SYSTEM "../../lib") include_directories(SYSTEM "../../lib")
include_directories(SYSTEM "../../lib/mbedtls/include") include_directories(SYSTEM "../../lib/mbedtls/include")
@ -22,8 +19,6 @@ endfunction()
add_subdirectory(../../lib/zlib ${CMAKE_CURRENT_BINARY_DIR}/${CMAKE_FILES_DIRECTORY}/lib/zlib) add_subdirectory(../../lib/zlib ${CMAKE_CURRENT_BINARY_DIR}/${CMAKE_FILES_DIRECTORY}/lib/zlib)
set_exe_flags()
# Include the shared files: # Include the shared files:
set(SHARED_SRC set(SHARED_SRC
../../src/ByteBuffer.cpp ../../src/ByteBuffer.cpp
@ -99,5 +94,5 @@ add_executable(ProtoProxy
${SHARED_OSS_HDR} ${SHARED_OSS_HDR}
) )
target_link_libraries(ProtoProxy zlib mbedtls fmt::fmt) target_link_libraries(ProtoProxy zlib mbedtls fmt::fmt Threads::Threads)

View File

@ -5,6 +5,10 @@ image:
- Visual Studio 2019 - Visual Studio 2019
- Visual Studio 2017 - Visual Studio 2017
branches:
only:
- master
# Set up environment variables for build info # Set up environment variables for build info
environment: environment:
CUBERITE_BUILD_SERIES_NAME: AppVeyor CUBERITE_BUILD_SERIES_NAME: AppVeyor
@ -12,17 +16,17 @@ environment:
CUBERITE_BUILD_DATETIME: "%APPVEYOR_REPO_COMMIT_TIMESTAMP%" CUBERITE_BUILD_DATETIME: "%APPVEYOR_REPO_COMMIT_TIMESTAMP%"
matrix: matrix:
- job_name: Windows-x64-debug - job_name: Windows-x64-Debug
configuration: Debug configuration: Debug
BUILD_DIR: Debug-x64 BUILD_DIR: Debug x64
- job_name: Windows-x86 - job_name: Windows-x86
configuration: Release configuration: Release
BUILD_DIR: Release-x86 BUILD_DIR: Release x86
- job_name: Windows-x64 - job_name: Windows-x64
configuration: Release configuration: Release
BUILD_DIR: Release-x64 BUILD_DIR: Release x64
matrix: matrix:
exclude: exclude:
@ -31,10 +35,18 @@ matrix:
- image: Visual Studio 2019 - image: Visual Studio 2019
configuration: Debug configuration: Debug
build:
project: '%BUILD_DIR%\Cuberite.sln'
parallel: true
verbosity: minimal
pull_requests:
do_not_increment_build_number: true
install: install:
- echo %TIME%
- git submodule update --init - git submodule update --init
- if not exist "%BUILD_DIR%" mkdir "%BUILD_DIR%"
- cd "%BUILD_DIR%"
for: for:
############################## ##############################
@ -43,21 +55,11 @@ for:
- -
matrix: matrix:
only: only:
- job_name: Windows-x64-debug - job_name: Windows-x64-Debug
before_build: 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) # 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 .. - cmake -G "Visual Studio 15 2017" -DSELF_TEST=No -DBUILD_TOOLS=No ..
- echo %TIME%
- cd ..
build:
project: Debug-x64\Cuberite.sln
parallel: true
verbosity: minimal
################################ ################################
# Windows 32-bit release build # # Windows 32-bit release build #
@ -67,22 +69,8 @@ for:
only: only:
- job_name: Windows-x86 - job_name: Windows-x86
branches:
only:
- master
before_build: before_build:
- if not exist %BUILD_DIR% mkdir %BUILD_DIR%
- cd %BUILD_DIR%
- echo %TIME%
- cmake -G "Visual Studio 16 2019" .. - cmake -G "Visual Studio 16 2019" ..
- echo %TIME%
- cd ..
build:
project: Release-x86\Cuberite.sln
parallel: true
verbosity: minimal
################################ ################################
# Windows 64-bit release build # # Windows 64-bit release build #
@ -92,41 +80,18 @@ for:
only: only:
- job_name: Windows-x64 - job_name: Windows-x64
branches:
only:
- master
before_build: before_build:
- if not exist %BUILD_DIR% mkdir %BUILD_DIR%
- cd %BUILD_DIR%
- echo %TIME%
- cmake -G "Visual Studio 16 2019" -A "x64" .. - 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 for speeding up subsequent builds #
########################################### ###########################################
cache: cache:
- Debug-x64\CMakeCache.txt - '%BUILD_DIR%\CMakeCache.txt'
- Release-x86\CMakeCache.txt
- Release-x64\CMakeCache.txt
##################### #####################
# Package artifacts # # Package artifacts #
##################### #####################
after_build: after_build:
- cd %BUILD_DIR%\Server - cd Server
- echo Cuberite %APPVEYOR_JOB_NAME%-#%APPVEYOR_BUILD_NUMBER% 1>buildinfo.txt
- Install\PackWindowsExecutables.cmd - 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

View File

@ -12,7 +12,7 @@ cd tidy-build
# Disable precompiled headers since they aren't generated during linting which causes an error # 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 # 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 # Ensure LuaState_Typedefs.inc has been generated
(cd ../src/Bindings && lua BindingsProcessor.lua) (cd ../src/Bindings && lua BindingsProcessor.lua)

View File

@ -1,6 +1,8 @@
include_directories(${CMAKE_SOURCE_DIR}/src/) include_directories(${CMAKE_SOURCE_DIR}/src/)
include_directories(SYSTEM ${CMAKE_SOURCE_DIR}/lib/mbedtls/include) include_directories(SYSTEM ${CMAKE_SOURCE_DIR}/lib/mbedtls/include)
find_package(Threads REQUIRED)
# Create a single Network library that contains all the networking code: # Create a single Network library that contains all the networking code:
set (Network_SRCS set (Network_SRCS
${CMAKE_SOURCE_DIR}/src/OSSupport/CriticalSection.cpp ${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) target_link_libraries(Network event_core event_extra fmt::fmt mbedtls)
if (WIN32) if(NOT WIN32)
target_link_libraries(Network ws2_32.lib) target_link_libraries(Network event_pthreads Threads::Threads)
else()
target_link_libraries(Network event_pthreads_static)
endif() endif()

View File

@ -16,16 +16,17 @@ if [ `which ccache` ]; then
CACHE_ARGS="-DCMAKE_C_COMPILER_LAUNCHER=ccache -DCMAKE_CXX_COMPILER_LAUNCHER=ccache" CACHE_ARGS="-DCMAKE_C_COMPILER_LAUNCHER=ccache -DCMAKE_CXX_COMPILER_LAUNCHER=ccache"
echo "Using ccache installed at $(which ccache)" echo "Using ccache installed at $(which ccache)"
ccache --max-size=3G ccache --max-size=1G
ccache -z # Zero statistics ccache --zero-stats
fi fi
# Work around a Clang + ccache issue with failing builds by disabling # Work around a Clang + ccache issue with failing builds by disabling
# precompiled headers. Turn off LTO for faster build speeds # precompiled headers. Turn off LTO for faster build speeds
cmake . -DBUILD_TOOLS=YES \ cmake . -DCMAKE_BUILD_TYPE=${TRAVIS_CUBERITE_BUILD_TYPE} \
-DPRECOMPILE_HEADERS=NO \ -DBUILD_TOOLS=Yes \
-DUNITY_BUILDS=${TRAVIS_CUBERITE_UNITY_BUILDS-YES} \ -DPRECOMPILE_HEADERS=No \
-DSELF_TEST=YES \ -DSELF_TEST=Yes \
-DUNITY_BUILDS=${TRAVIS_CUBERITE_UNITY_BUILDS-Yes} \
-DWHOLE_PROGRAM_OPTIMISATION=No \ -DWHOLE_PROGRAM_OPTIMISATION=No \
${CACHE_ARGS}; ${CACHE_ARGS};
@ -34,7 +35,7 @@ cmake --build . --parallel 2;
if [ `which ccache` ]; then if [ `which ccache` ]; then
echo "Built with ccache, outputting cache stats..." echo "Built with ccache, outputting cache stats..."
ccache -s ccache --show-stats
fi fi
echo "Testing..." echo "Testing..."