build: take the project version from the VERSION file, and read it once

PROJECT() carried a hardcoded 1.0.0 next to a JFJOCH_VERSION read from the VERSION file,
so PROJECT_VERSION was free to drift from the version everything else uses. It cannot
simply be handed the same string - project(VERSION) accepts numeric major.minor.patch
only, and rejects a pre-release suffix such as -rc.161 - so cut the numeric part out of
the same file instead of writing it down a second time.

common/ then read ../VERSION again into PACKAGE_VERSION, purely to interpolate it into
GitInfo.cpp. That is the same file read twice with two variable names, one of them a
common enough name to be set by something else in the parent scope. Use JFJOCH_VERSION,
which is already in scope there.

The CUDA architecture note claimed the list "embeds no PTX". A bare entry in
CMAKE_CUDA_ARCHITECTURES emits SASS and PTX both, so the newest entry has been the
forward-compatibility path all along: on a GPU newer than anything listed, the driver
JIT-compiles that PTX at first launch. Adding sm_121 still buys native code on Spark
instead of a JIT, which is what the comment should have said.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
This commit is contained in:
2026-08-03 20:52:09 +02:00
co-authored by Claude Opus 5
parent 0003acf2e4
commit 22d75e2f01
3 changed files with 15 additions and 6 deletions
+13 -3
View File
@@ -1,8 +1,14 @@
CMAKE_MINIMUM_REQUIRED(VERSION 3.26)
# The VERSION file is the single source of truth for the version, and JFJOCH_VERSION carries it
# verbatim - including a pre-release suffix such as "-rc.161" - into the package names, the DKMS
# install path and the version every binary reports. PROJECT(VERSION) cannot hold that string: it
# only accepts numeric major.minor.patch, so the numeric part is cut out of the same file rather
# than written out a second time, and PROJECT_VERSION can never drift from VERSION.
FILE(STRINGS VERSION JFJOCH_VERSION)
STRING(REGEX MATCH "^[0-9]+\\.[0-9]+\\.[0-9]+" JFJOCH_VERSION_NUMERIC "${JFJOCH_VERSION}")
PROJECT(jfjoch VERSION 1.0.0 LANGUAGES C CXX)
PROJECT(jfjoch VERSION ${JFJOCH_VERSION_NUMERIC} LANGUAGES C CXX)
SET(CMAKE_POLICY_DEFAULT_CMP0077 NEW)
SET(CMAKE_CXX_STANDARD 20)
@@ -62,7 +68,11 @@ ENDIF()
CHECK_LANGUAGE(CUDA)
SET(CMAKE_CUDA_ARCHITECTURES 75 80 86 89 90 100 120) # T4, A100, RTX A4000, L4
# GPU architectures to generate device code for: Turing (T4), Ampere (A100; RTX A4000), Ada (L4),
# Hopper, and Blackwell in both its data-centre and consumer forms. A bare entry emits SASS *and*
# PTX for that architecture, so the newest one here also covers any future GPU: the driver
# JIT-compiles its PTX on first launch.
SET(CMAKE_CUDA_ARCHITECTURES 75 80 86 89 90 100 120)
SET(CMAKE_CUDA_STANDARD 20)
SET(CMAKE_CUDA_STANDARD_REQUIRED True)
SET(CMAKE_CUDA_FLAGS_RELEASE "-O3 -lineinfo")
@@ -79,7 +89,7 @@ IF (CMAKE_CUDA_COMPILER)
ADD_COMPILE_DEFINITIONS(JFJOCH_USE_CUDA)
SET(JFJOCH_CUDA_AVAILABLE ON)
# Blackwell GB10 (DGX Spark) is sm_121, only known to nvcc >= 12.9; add it there so the
# binary launches natively on Spark (the list above tops out at sm_120 and embeds no PTX).
# binary runs natively on Spark instead of having the driver JIT sm_120 PTX for it.
IF (CMAKE_CUDA_COMPILER_VERSION VERSION_GREATER_EQUAL "12.9")
LIST(APPEND CMAKE_CUDA_ARCHITECTURES 121)
ENDIF()
+1 -2
View File
@@ -19,10 +19,9 @@ EXECUTE_PROCESS(COMMAND
set (THREADS_PREFER_PTHREAD_FLAG ON)
find_package (Threads REQUIRED)
FILE(STRINGS ../VERSION PACKAGE_VERSION)
MESSAGE(STATUS "Jungfraujoch git SHA1: ${GIT_SHA1}")
MESSAGE(STATUS "Jungfraujoch git date: ${GIT_DATE}")
MESSAGE(STATUS "Jungfraujoch version: ${PACKAGE_VERSION}")
MESSAGE(STATUS "Jungfraujoch version: ${JFJOCH_VERSION}")
CONFIGURE_FILE("${CMAKE_CURRENT_SOURCE_DIR}/GitInfo.cpp.in" "${CMAKE_CURRENT_BINARY_DIR}/GitInfo.cpp" @ONLY)
+1 -1
View File
@@ -12,5 +12,5 @@ std::string jfjoch_git_date() {
}
std::string jfjoch_version() {
return "@PACKAGE_VERSION@";
return "@JFJOCH_VERSION@";
}