diff --git a/CMakeLists.txt b/CMakeLists.txt index fa2ed7f12..9c318f7df 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -69,6 +69,13 @@ set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wstrict-overflow") set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wstrict-aliasing") set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Werror") +# avoid timestamps in binary for reproducible builds, not added until GCC 4.9 +include(CheckCXXCompilerFlag) +CHECK_CXX_COMPILER_FLAG(-Wdate-time COMPILER_SUPPORTS_WDATE_TIME) +if(COMPILER_SUPPORTS_WDATE_TIME) + set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wdate-time") +endif() + if (NOT WIN32) set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fstack-protector-all") set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wstack-protector") @@ -101,6 +108,15 @@ include_directories(${CMAKE_SOURCE_DIR}) include(Dependencies) +if(NOT Qt5Widgets_VERSION VERSION_LESS "5.9") + # Drop the file modification time of source files from generated files + # to help with reproducible builds. We do not use QFileInfo.lastModified + # so this has no unwanted side effects. This mtime started appearing in + # Qt 5.8. The option to force the old file format without mtime was + # added in Qt 5.9. See https://bugreports.qt.io/browse/QTBUG-58769 + set(RCC_OPTIONS ${RCC_OPTIONS} -format-version 1) +endif() + ################################################################################ # # :: qTox main library sources diff --git a/cmake/Dependencies.cmake b/cmake/Dependencies.cmake index ac3fa5de8..544916202 100644 --- a/cmake/Dependencies.cmake +++ b/cmake/Dependencies.cmake @@ -199,14 +199,6 @@ add_definitions( -DGIT_VERSION="${GIT_VERSION}" ) -if (NOT TIMESTAMP) - execute_process( - COMMAND date +%s - OUTPUT_VARIABLE TIMESTAMP - OUTPUT_STRIP_TRAILING_WHITESPACE - ) -endif() - set(APPLE_EXT False) if (FOUNDATION_FOUND AND IOKIT_FOUND) set(APPLE_EXT True) @@ -230,6 +222,5 @@ if (PLATFORM_EXTENSIONS) endif() add_definitions( - -DTIMESTAMP=${TIMESTAMP} -DLOG_TO_FILE=1 )