Skip to content

Commit f968d19

Browse files
authored
[Infrastructure] More fixes to precompiled headers (#17524)
1 parent 02abccc commit f968d19

2 files changed

Lines changed: 23 additions & 6 deletions

File tree

CMakeLists.txt

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,10 @@
99
# granted to it by virtue of its status as an Intergovernmental Organization
1010
# or submit itself to any jurisdiction.
1111

12-
cmake_minimum_required(VERSION 3.23 FATAL_ERROR)
12+
# 3.27 for $<COMPILE_ONLY:>, which O2PhysicsAddWorkflow.cmake uses to give a
13+
# workflow the precompiled header carrier's compile usage requirements without
14+
# also putting it on the link line. Builds use CMake 4.1 (alidist cmake.sh).
15+
cmake_minimum_required(VERSION 3.27 FATAL_ERROR)
1316

1417
project(O2Physics
1518
VERSION 0.0.1

cmake/O2PhysicsAddWorkflow.cmake

Lines changed: 19 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -69,11 +69,25 @@ function(o2physics_add_dpl_workflow baseTargetName)
6969
# cmake_pch.hxx.gch: not used because `RANS_ENABLE_JSON' not defined
7070
# The carrier links O2Physics::AnalysisCore, which reaches O2::rANS and its
7171
# INTERFACE -DRANS_ENABLE_JSON, while a workflow that links only
72-
# O2::Framework (the converters, the tutorials) never sees it. Hand every
73-
# consumer the carrier's definitions so the two agree. Definitions only --
74-
# this must not add link dependencies to targets that do not want them.
75-
target_compile_definitions(${targetExeName} PRIVATE
76-
$<TARGET_PROPERTY:${_pch},COMPILE_DEFINITIONS>)
72+
# O2::Framework (the converters, the tutorials) never sees it.
73+
#
74+
# Copying COMPILE_DEFINITIONS fixed that case and revealed another: CI then
75+
# failed on `_REENTRANT' not defined, on a compile line that DID carry
76+
# -DRANS_ENABLE_JSON -- so the copy was working and simply does not reach
77+
# far enough. Whatever supplies _REENTRANT arrives at the carrier as
78+
# something other than a compile definition (-pthread, which travels in
79+
# INTERFACE_COMPILE_OPTIONS, is the likely route), so adding options alone
80+
# would only move the goalposts to whichever kind of usage requirement goes
81+
# missing next.
82+
#
83+
# $<COMPILE_ONLY:> applies a target's *compile* usage requirements --
84+
# definitions, options, include directories, features -- without placing it
85+
# on the link line or creating a link dependency, which is the constraint
86+
# that ruled out simply linking the carrier. It transfers the whole
87+
# preprocessor state the carrier compiled with, and that state is exactly
88+
# what GCC compares, rather than one property of it at a time.
89+
# Requires CMake >= 3.27.
90+
target_link_libraries(${targetExeName} PRIVATE $<COMPILE_ONLY:${_pch}>)
7791
target_precompile_headers(${targetExeName} REUSE_FROM ${_pch})
7892
endif()
7993

0 commit comments

Comments
 (0)