diff options
author | Campbell Barton <ideasman42@gmail.com> | 2016-05-10 19:43:58 +0300 |
---|---|---|
committer | Campbell Barton <ideasman42@gmail.com> | 2016-05-10 19:47:38 +0300 |
commit | a18f4d2bc69aa4707fb0efa92d28297d06be060e (patch) | |
tree | 1ca0bfde3265c507fcb46de8e2422b84fe748e92 | |
parent | c1e4aaa289f64748093d4cd7590f5836b8873466 (diff) |
CMake: optional date/time overrides for reproducible builds
-rw-r--r-- | CMakeLists.txt | 4 | ||||
-rw-r--r-- | build_files/cmake/buildinfo.cmake | 26 | ||||
-rw-r--r-- | source/creator/CMakeLists.txt | 3 |
3 files changed, 26 insertions, 7 deletions
diff --git a/CMakeLists.txt b/CMakeLists.txt index 6fc4ca2729d..af457de21fa 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -218,6 +218,10 @@ if(${CMAKE_VERSION} VERSION_LESS 2.8.8) # add_library OBJECT arg unsupported set(WITH_BUILDINFO OFF) endif() +set(BUILDINFO_OVERRIDE_DATE "" CACHE STRING "Use instead of the current date for reproducable builds (empty string disables this option)") +set(BUILDINFO_OVERRIDE_TIME "" CACHE STRING "Use instead of the current time for reproducable builds (empty string disables this option)") +mark_as_advanced(BUILDINFO_OVERRIDE_DATE) +mark_as_advanced(BUILDINFO_OVERRIDE_TIME) option(WITH_IK_ITASC "Enable ITASC IK solver (only disable for development & for incompatible C++ compilers)" ON) option(WITH_IK_SOLVER "Enable Legacy IK solver (only disable for development)" ON) diff --git a/build_files/cmake/buildinfo.cmake b/build_files/cmake/buildinfo.cmake index 4caa4a954ea..af0ccd250e8 100644 --- a/build_files/cmake/buildinfo.cmake +++ b/build_files/cmake/buildinfo.cmake @@ -1,5 +1,10 @@ -# This is called by cmake as an extermal process from +# This is called by cmake as an external process from # ./source/creator/CMakeLists.txt to write ./source/creator/buildinfo.h +# Caller must define: +# SOURCE_DIR +# Optional overrides: +# BUILD_DATE +# BUILD_TIME # Extract working copy information for SOURCE_DIR into MY_XXX variables # with a default in case anything fails, for example when using git-svn @@ -128,12 +133,19 @@ endif() # BUILD_PLATFORM and BUILD_PLATFORM are taken from CMake # but BUILD_DATE and BUILD_TIME are platform dependent if(UNIX) - execute_process(COMMAND date "+%Y-%m-%d" OUTPUT_VARIABLE BUILD_DATE OUTPUT_STRIP_TRAILING_WHITESPACE) - execute_process(COMMAND date "+%H:%M:%S" OUTPUT_VARIABLE BUILD_TIME OUTPUT_STRIP_TRAILING_WHITESPACE) -endif() -if(WIN32) - execute_process(COMMAND cmd /c date /t OUTPUT_VARIABLE BUILD_DATE OUTPUT_STRIP_TRAILING_WHITESPACE) - execute_process(COMMAND cmd /c time /t OUTPUT_VARIABLE BUILD_TIME OUTPUT_STRIP_TRAILING_WHITESPACE) + if(NOT BUILD_DATE) + execute_process(COMMAND date "+%Y-%m-%d" OUTPUT_VARIABLE BUILD_DATE OUTPUT_STRIP_TRAILING_WHITESPACE) + endif() + if(NOT BUILD_TIME) + execute_process(COMMAND date "+%H:%M:%S" OUTPUT_VARIABLE BUILD_TIME OUTPUT_STRIP_TRAILING_WHITESPACE) + endif() +elseif(WIN32) + if(NOT BUILD_DATE) + execute_process(COMMAND cmd /c date /t OUTPUT_VARIABLE BUILD_DATE OUTPUT_STRIP_TRAILING_WHITESPACE) + endif() + if(NOT BUILD_TIME) + execute_process(COMMAND cmd /c time /t OUTPUT_VARIABLE BUILD_TIME OUTPUT_STRIP_TRAILING_WHITESPACE) + endif() endif() # Write a file with the BUILD_HASH define diff --git a/source/creator/CMakeLists.txt b/source/creator/CMakeLists.txt index b7d8381639d..daba01e33c7 100644 --- a/source/creator/CMakeLists.txt +++ b/source/creator/CMakeLists.txt @@ -186,6 +186,9 @@ if(WITH_BUILDINFO) add_custom_command(OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/_buildinfo.h COMMAND ${CMAKE_COMMAND} -DSOURCE_DIR=${CMAKE_SOURCE_DIR} + # overrides only used when non-empty strings + -DBUILD_DATE=${BUILDINFO_OVERRIDE_DATE} + -DBUILD_TIME=${BUILDINFO_OVERRIDE_TIME} -P ${CMAKE_SOURCE_DIR}/build_files/cmake/buildinfo.cmake) # buildinfo.h is a generated file |