aboutsummaryrefslogtreecommitdiffstats
path: root/CMakeLists.txt
diff options
context:
space:
mode:
Diffstat (limited to 'CMakeLists.txt')
-rw-r--r--CMakeLists.txt39
1 files changed, 39 insertions, 0 deletions
diff --git a/CMakeLists.txt b/CMakeLists.txt
index 9b4426c..e3cf82b 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -11,6 +11,12 @@ set(CMAKE_AUTORCC ON)
# that ships.
option(QTMAILDIR_BUILD_TESTS "Build the test suite" ON)
+# A dev build counts its own rebuilds so one binary of an unreleased X.Y.Z can
+# be told from another (item 167). OFF for a release: the version a release
+# prints must be a clean X.Y.Z, which the release procedure checks and the
+# SlackBuild builds from a tarball that carries no counter at all.
+option(QTMAILDIR_BUILD_NUMBER "Number each build of a dev tree" ON)
+
set(QTMAILDIR_QT_COMPONENTS Widgets Svg WebEngineWidgets)
if(QTMAILDIR_BUILD_TESTS)
list(APPEND QTMAILDIR_QT_COMPONENTS Test)
@@ -58,6 +64,39 @@ configure_file(
${CMAKE_CURRENT_BINARY_DIR}/generated/qtmaildir/version.h
@ONLY)
+# buildnumber.h is generated separately, and by a BUILD step rather than by
+# configure_file: this whole block runs once per cmake run, so a counter
+# written here would not move when the user rebuilt after a fix, which is the
+# defect item 167 describes. The header always exists so version.h can include
+# it unconditionally; in a release build it is empty and
+# QTMAILDIR_VERSION_DISPLAY collapses to the plain version.
+set(QTMAILDIR_BUILD_NUMBER_HEADER
+ ${CMAKE_CURRENT_BINARY_DIR}/generated/qtmaildir/buildnumber.h)
+
+if(QTMAILDIR_BUILD_NUMBER)
+ # Once now, so the header exists before the first compile of a fresh build
+ # directory, and then again on every build.
+ execute_process(COMMAND ${CMAKE_COMMAND}
+ -DCOUNTER_FILE=${CMAKE_CURRENT_BINARY_DIR}/build-number
+ -DHEADER_FILE=${QTMAILDIR_BUILD_NUMBER_HEADER}
+ -P ${CMAKE_CURRENT_SOURCE_DIR}/cmake/BuildNumber.cmake)
+
+ add_custom_target(qtmaildir_buildnumber ALL
+ COMMAND ${CMAKE_COMMAND}
+ -DCOUNTER_FILE=${CMAKE_CURRENT_BINARY_DIR}/build-number
+ -DHEADER_FILE=${QTMAILDIR_BUILD_NUMBER_HEADER}
+ -P ${CMAKE_CURRENT_SOURCE_DIR}/cmake/BuildNumber.cmake
+ BYPRODUCTS ${QTMAILDIR_BUILD_NUMBER_HEADER}
+ COMMENT "Numbering this build"
+ VERBATIM)
+else()
+ file(WRITE ${QTMAILDIR_BUILD_NUMBER_HEADER}
+ "// Release build: no counter, so QTMAILDIR_VERSION_DISPLAY is the
+// plain version. Generated by the top-level CMakeLists.txt.
+#pragma once
+")
+endif()
+
add_subdirectory(src)
if(QTMAILDIR_BUILD_TESTS)
enable_testing()