diff options
author | worktycho <work.tycho@gmail.com> | 2015-06-05 14:04:28 +0200 |
---|---|---|
committer | worktycho <work.tycho@gmail.com> | 2015-06-05 14:04:28 +0200 |
commit | 519fd1d36de921599e93f6359c3545b014cd2923 (patch) | |
tree | 0939a4e561aaa2b8ed56225ad65da6e31b615bde /CMakeLists.txt | |
parent | Merge pull request #2207 from mc-server/LineBlockTracerFix (diff) | |
parent | CMake: Added buildinfo workaround for src packs / systems without git. (diff) | |
download | cuberite-519fd1d36de921599e93f6359c3545b014cd2923.tar cuberite-519fd1d36de921599e93f6359c3545b014cd2923.tar.gz cuberite-519fd1d36de921599e93f6359c3545b014cd2923.tar.bz2 cuberite-519fd1d36de921599e93f6359c3545b014cd2923.tar.lz cuberite-519fd1d36de921599e93f6359c3545b014cd2923.tar.xz cuberite-519fd1d36de921599e93f6359c3545b014cd2923.tar.zst cuberite-519fd1d36de921599e93f6359c3545b014cd2923.zip |
Diffstat (limited to 'CMakeLists.txt')
-rw-r--r-- | CMakeLists.txt | 34 |
1 files changed, 32 insertions, 2 deletions
diff --git a/CMakeLists.txt b/CMakeLists.txt index e3af054ed..d03690865 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -24,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}) @@ -34,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: |