summaryrefslogtreecommitdiffstats
path: root/CMakeLists.txt
diff options
context:
space:
mode:
Diffstat (limited to 'CMakeLists.txt')
-rw-r--r--CMakeLists.txt106
1 files changed, 103 insertions, 3 deletions
diff --git a/CMakeLists.txt b/CMakeLists.txt
index 2bb780eba..a02c9b4fd 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -3,6 +3,11 @@ cmake_minimum_required (VERSION 2.8.7)
# 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)
+# Enable the support for solution folders in MSVC
+if (MSVC)
+ set_property(GLOBAL PROPERTY USE_FOLDERS ON)
+endif()
+
# 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})
@@ -19,6 +24,7 @@ if(DEFINED ENV{TRAVIS_BUILD_WITH_COVERAGE})
endif()
if(DEFINED ENV{MCSERVER_BUILD_ID})
+ # The build info is defined by the build system (Travis / Jenkins)
set(BUILD_ID $ENV{MCSERVER_BUILD_ID})
set(BUILD_SERIES_NAME $ENV{MCSERVER_BUILD_SERIES_NAME})
set(BUILD_DATETIME $ENV{MCSERVER_BUILD_DATETIME})
@@ -29,12 +35,41 @@ if(DEFINED ENV{MCSERVER_BUILD_ID})
execute_process(
COMMAND git rev-parse HEAD
RESULT_VARIABLE GIT_EXECUTED
- OUTPUT_VARIABLE BUILD_COMMIT_ID)
- string(STRIP ${BUILD_COMMIT_ID} BUILD_COMMIT_ID)
+ 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
+ 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
+ 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++11 features, Visual Studio has those from VS2012, but it needs a new platform toolset for those; VS2013 supports them natively:
@@ -52,6 +87,9 @@ if(MSVC OR MSVC_IDE)
endif()
endif()
+set(BUILD_TOOLS OFF CACHE BOOL "")
+set(SELF_TEST OFF CACHE BOOL "")
+
# This has to be done before any flags have been set up.
if(${BUILD_TOOLS})
message("Building tools")
@@ -64,6 +102,7 @@ if(${BUILD_UNSTABLE_TOOLS})
add_subdirectory(Tools/GeneratorPerformanceTest/)
endif()
+include(CheckCXXCompilerFlag)
include(SetFlags.cmake)
set_flags()
set_lib_flags()
@@ -99,6 +138,7 @@ set(SQLITECPP_RUN_DOXYGEN OFF CACHE BOOL "Run Doxygen C++ documentation tool
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)
+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)
@@ -107,6 +147,13 @@ set(EVENT__DISABLE_TESTS YES CACHE BOOL "Disable LibEvent tests"
set(EVENT__DISABLE_REGRESS YES CACHE BOOL "Disable LibEvent regression tests" FORCE)
set(EVENT__DISABLE_SAMPLES YES CACHE BOOL "Disable LibEvent samples" FORCE)
+# Set options for JsonCPP, disabling all of their tests
+# Additionally, their library is output to a strange location; make sure the linker knows where to find it
+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")
+link_directories(lib/jsoncpp/src/lib_json)
+
# Check that the libraries are present:
if (NOT EXISTS ${CMAKE_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?")
@@ -127,7 +174,7 @@ add_subdirectory(lib/sqlite/)
add_subdirectory(lib/SQLiteCpp/)
add_subdirectory(lib/expat/)
add_subdirectory(lib/luaexpat/)
-add_subdirectory(lib/libevent/)
+add_subdirectory(lib/libevent/ EXCLUDE_FROM_ALL)
# Add proper include directories so that SQLiteCpp can find SQLite3:
get_property(SQLITECPP_INCLUDES DIRECTORY "lib/SQLiteCpp/" PROPERTY INCLUDE_DIRECTORIES)
@@ -138,6 +185,9 @@ set_property(TARGET SQLiteCpp PROPERTY INCLUDE_DIRECTORIES "${SQLITECPP_INCLUDES
# Add proper includes for LibEvent's event-config.h header:
include_directories(SYSTEM ${LIBEVENT_INCLUDE_DIRS})
+# Prettify jsoncpp_lib_static name in VS solution explorer
+set_property(TARGET jsoncpp_lib_static PROPERTY PROJECT_LABEL "jsoncpp")
+
if (WIN32)
add_subdirectory(lib/luaproxy/)
endif()
@@ -157,3 +207,53 @@ if(${SELF_TEST})
add_subdirectory (tests)
endif()
+# Put projects into solution folders in MSVC:
+if (MSVC)
+ set_target_properties(
+ event_core
+ event_extra
+ expat
+ jsoncpp_lib_static
+ lua
+ luaexpat
+ mbedtls
+ sqlite
+ SQLiteCpp
+ tolualib
+ zlib
+ PROPERTIES FOLDER Lib
+ )
+ set_target_properties(
+ luaproxy
+ tolua
+ PROPERTIES FOLDER Support
+ )
+ if (${SELF_TEST})
+ set_target_properties(
+ Network
+ PROPERTIES FOLDER Lib
+ )
+ set_target_properties(
+ arraystocoords-exe
+ ChunkBuffer
+ coordinates-exe
+ copies-exe
+ copyblocks-exe
+ creatable-exe
+ EchoServer
+ Google-exe
+ LoadablePieces
+ NameLookup
+ PROPERTIES FOLDER Tests
+ )
+ endif()
+
+ if(${BUILD_TOOLS})
+ set_target_properties(
+ MCADefrag
+ ProtoProxy
+ PROPERTIES FOLDER Tools
+ )
+ endif()
+endif()
+