Skip to content

Commit d560e21

Browse files
authored
[Infrastructure,Common] Fix precompiled header creation (#17521)
1 parent 9942ce0 commit d560e21

2 files changed

Lines changed: 16 additions & 2 deletions

File tree

Common/Core/CMakeLists.txt

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,8 +30,12 @@ o2physics_add_library(AnalysisCore
3030
# Skipped under recc, which caches compilations remotely instead -- the two do
3131
# not combine, as a PCH is a local artefact of one compiler invocation.
3232
#
33-
# The link libraries have to match what the reusing targets compile with, so
34-
# this carries only what every workflow already links.
33+
# The reusing targets must compile with the same preprocessor state as this
34+
# carrier, which does not follow from the link list: AnalysisCore reaches
35+
# O2::rANS and its INTERFACE -DRANS_ENABLE_JSON, whereas a bare workflow links
36+
# only O2::Framework. o2physics_add_dpl_workflow therefore copies this target's
37+
# compile definitions onto every consumer; keep that in mind when changing what
38+
# is linked here.
3539
add_library(AnalysisPCH OBJECT analysisPCH.cxx)
3640
target_link_libraries(AnalysisPCH PUBLIC O2::Framework O2Physics::AnalysisCore)
3741
if(NOT DEFINED ENV{USE_RECC})

cmake/O2PhysicsAddWorkflow.cmake

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,16 @@ function(o2physics_add_dpl_workflow baseTargetName)
6464
# A target cannot reuse its own PCH, and the carrier is not built when recc
6565
# is caching compilations remotely instead.
6666
if(_pch AND NOT _pch STREQUAL targetExeName AND NOT DEFINED ENV{USE_RECC})
67+
# GCC refuses a PCH built with a different preprocessor state than the
68+
# consumer's, and -Werror turns that refusal into a build failure:
69+
# cmake_pch.hxx.gch: not used because `RANS_ENABLE_JSON' not defined
70+
# The carrier links O2Physics::AnalysisCore, which reaches O2::rANS and its
71+
# 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>)
6777
target_precompile_headers(${targetExeName} REUSE_FROM ${_pch})
6878
endif()
6979

0 commit comments

Comments
 (0)