2014-09-06 08:30:04 -07:00
|
|
|
cmake_minimum_required (VERSION 2.8.7)
|
2013-12-10 10:41:43 -08:00
|
|
|
|
2013-12-28 13:46:23 -08:00
|
|
|
# Without this, the MSVC variable isn't defined for MSVC builds ( http://www.cmake.org/pipermail/cmake/2011-November/047130.html )
|
|
|
|
enable_language(CXX C)
|
|
|
|
|
2014-03-10 13:52:13 -07:00
|
|
|
# These env variables are used for configuring Travis CI builds.
|
|
|
|
# See https://github.com/mc-server/MCServer/pull/767
|
|
|
|
if(DEFINED ENV{TRAVIS_MCSERVER_BUILD_TYPE})
|
|
|
|
message("Setting build type to $ENV{TRAVIS_MCSERVER_BUILD_TYPE}")
|
|
|
|
set(CMAKE_BUILD_TYPE $ENV{TRAVIS_MCSERVER_BUILD_TYPE})
|
2014-03-07 12:16:16 -08:00
|
|
|
endif()
|
|
|
|
|
2014-03-10 13:52:13 -07:00
|
|
|
if(DEFINED ENV{TRAVIS_MCSERVER_FORCE32})
|
|
|
|
set(FORCE32 $ENV{TRAVIS_MCSERVER_FORCE32})
|
2014-03-07 12:16:16 -08:00
|
|
|
endif()
|
|
|
|
|
2014-05-10 05:03:36 -07:00
|
|
|
if(DEFINED ENV{TRAVIS_BUILD_WITH_COVERAGE})
|
|
|
|
set(BUILD_WITH_COVERAGE $ENV{TRAVIS_BUILD_WITH_COVERAGE})
|
|
|
|
endif()
|
|
|
|
|
2014-09-10 10:08:50 -07:00
|
|
|
if(DEFINED ENV{MCSERVER_BUILD_ID})
|
|
|
|
set(BUILD_ID $ENV{MCSERVER_BUILD_ID})
|
|
|
|
set(BUILD_SERIES_NAME $ENV{MCSERVER_BUILD_SERIES_NAME})
|
|
|
|
set(BUILD_DATETIME $ENV{MCSERVER_BUILD_DATETIME})
|
|
|
|
if(DEFINED ENV{MCSERVER_BUILD_COMMIT_ID})
|
|
|
|
set(BUILD_COMMIT_ID $ENV{MCSERVER_BUILD_COMMIT_ID})
|
2014-09-10 08:07:00 -07:00
|
|
|
else()
|
|
|
|
message("Commit id not set, attempting to determine id from git")
|
|
|
|
execute_process(
|
|
|
|
COMMAND git rev-parse HEAD
|
|
|
|
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()
|
|
|
|
endif()
|
|
|
|
|
2014-11-02 00:09:22 -07:00
|
|
|
# We need C++11 features, Visual Studio has those from VS2012, but it needs a new platform toolset for those; VS2013 supports them natively:
|
|
|
|
# Adapted from http://binglongx.wordpress.com/2013/06/28/set-non-default-platform-toolset-in-cmake/
|
|
|
|
if(MSVC OR MSVC_IDE)
|
|
|
|
if( MSVC_VERSION LESS 1700 ) # VC10- / VS2010-
|
|
|
|
message(FATAL_ERROR "The project requires C++11 features. "
|
|
|
|
"You need at least Visual Studio 11 (Microsoft Visual Studio 2012), "
|
|
|
|
"with Microsoft Visual C++ Compiler Nov 2012 CTP (v120_CTP_Nov2012).")
|
|
|
|
elseif( MSVC_VERSION EQUAL 1700 ) # VC11 / VS2012
|
|
|
|
message( "VC11: using Microsoft Visual Studio 2012 "
|
|
|
|
"with Microsoft Visual C++ Compiler Nov 2012 CTP (v120_CTP_Nov2012)" )
|
|
|
|
set(CMAKE_GENERATOR_TOOLSET "v120_CTP_Nov2012" CACHE STRING "Platform Toolset" FORCE)
|
|
|
|
else() # VC12+, assuming C++11 supported.
|
|
|
|
endif()
|
|
|
|
endif()
|
|
|
|
|
2014-02-16 05:55:37 -08:00
|
|
|
# This has to be done before any flags have been set up.
|
2014-02-16 03:37:31 -08:00
|
|
|
if(${BUILD_TOOLS})
|
|
|
|
add_subdirectory(Tools/MCADefrag/)
|
2014-02-16 04:30:45 -08:00
|
|
|
add_subdirectory(Tools/ProtoProxy/)
|
2014-02-16 03:37:31 -08:00
|
|
|
endif()
|
|
|
|
|
|
|
|
if(${BUILD_UNSTABLE_TOOLS})
|
|
|
|
add_subdirectory(Tools/GeneratorPerformanceTest/)
|
|
|
|
endif()
|
|
|
|
|
2014-02-15 15:17:58 -08:00
|
|
|
include(SetFlags.cmake)
|
|
|
|
set_flags()
|
|
|
|
set_lib_flags()
|
|
|
|
enable_profile()
|
2014-01-14 02:05:57 -08:00
|
|
|
|
2013-12-27 03:01:45 -08:00
|
|
|
# Under Windows, we need Lua as DLL; on *nix we need it linked statically:
|
|
|
|
if (WIN32)
|
|
|
|
add_definitions(-DLUA_BUILD_AS_DLL)
|
|
|
|
endif()
|
|
|
|
|
2014-01-14 02:05:57 -08:00
|
|
|
|
2013-12-27 03:01:45 -08:00
|
|
|
# The Expat library is linked in statically, make the source files aware of that:
|
2013-12-27 02:51:08 -08:00
|
|
|
add_definitions(-DXML_STATIC)
|
2013-12-21 05:45:27 -08:00
|
|
|
|
2014-02-05 10:10:45 -08:00
|
|
|
# Self Test Mode enables extra checks at startup
|
|
|
|
if(${SELF_TEST})
|
|
|
|
add_definitions(-DSELF_TEST)
|
|
|
|
endif()
|
2013-12-28 13:46:23 -08:00
|
|
|
|
|
|
|
|
2014-01-14 02:05:57 -08:00
|
|
|
|
2014-02-15 15:17:58 -08:00
|
|
|
|
|
|
|
|
2013-12-28 13:46:23 -08:00
|
|
|
project (MCServer)
|
|
|
|
|
2014-07-28 10:59:53 -07:00
|
|
|
# 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 OFF CACHE BOOL "Add the internal SQLite3 source to the project." FORCE)
|
|
|
|
|
2013-12-28 07:03:57 -08:00
|
|
|
# Include all the libraries:
|
2013-12-10 13:39:20 -08:00
|
|
|
add_subdirectory(lib/jsoncpp/)
|
2013-12-10 15:26:55 -08:00
|
|
|
add_subdirectory(lib/zlib/)
|
2013-12-18 15:14:11 -08:00
|
|
|
add_subdirectory(lib/lua/)
|
2013-12-18 15:54:55 -08:00
|
|
|
add_subdirectory(lib/tolua++/)
|
2013-12-18 16:28:48 -08:00
|
|
|
add_subdirectory(lib/sqlite/)
|
2014-07-28 10:59:53 -07:00
|
|
|
add_subdirectory(lib/SQLiteCpp/)
|
2013-12-18 16:52:52 -08:00
|
|
|
add_subdirectory(lib/expat/)
|
|
|
|
add_subdirectory(lib/luaexpat/)
|
2013-12-10 13:39:20 -08:00
|
|
|
|
2014-07-28 11:16:24 -07:00
|
|
|
# Add proper include directories so that SQLiteCpp can find SQLite3:
|
|
|
|
get_property(SQLITECPP_INCLUDES DIRECTORY "lib/SQLiteCpp/" PROPERTY INCLUDE_DIRECTORIES)
|
|
|
|
set(SQLITECPP_INCLUDES "${SQLITECPP_INCLUDES}" "${CMAKE_CURRENT_SOURCE_DIR}/lib/sqlite/")
|
|
|
|
set_property(DIRECTORY lib/SQLiteCpp/ PROPERTY INCLUDE_DIRECTORIES "${SQLITECPP_INCLUDES}")
|
2014-07-28 13:06:47 -07:00
|
|
|
set_property(TARGET SQLiteCpp PROPERTY INCLUDE_DIRECTORIES "${SQLITECPP_INCLUDES}")
|
2014-07-28 11:16:24 -07:00
|
|
|
|
2014-06-24 05:48:18 -07:00
|
|
|
if (WIN32)
|
|
|
|
add_subdirectory(lib/luaproxy/)
|
|
|
|
endif()
|
|
|
|
|
2014-01-22 13:19:33 -08:00
|
|
|
|
|
|
|
# We use EXCLUDE_FROM_ALL so that only the explicit dependencies are used
|
|
|
|
# (PolarSSL also has test and example programs in their CMakeLists.txt, we don't want those)
|
2014-02-16 04:30:45 -08:00
|
|
|
include(lib/polarssl.cmake)
|
2014-01-22 13:19:33 -08:00
|
|
|
|
2014-02-15 15:17:58 -08:00
|
|
|
set_exe_flags()
|
2013-12-27 02:51:08 -08:00
|
|
|
|
2014-01-15 04:54:06 -08:00
|
|
|
add_subdirectory (src)
|
2013-12-10 10:41:43 -08:00
|
|
|
|
2014-04-27 12:25:03 -07:00
|
|
|
if(${SELF_TEST})
|
|
|
|
enable_testing()
|
|
|
|
add_subdirectory (tests)
|
|
|
|
endif()
|
|
|
|
|