Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

dd4hep_add_dictionary fails when INTERFACE_COMPILE_DEFINITIONS contains COMPILE_LANGUAGE cmake genex #1239

Closed
1 task done
wdconinc opened this issue Mar 10, 2024 · 2 comments · Fixed by #1241
Closed
1 task done
Labels

Comments

@wdconinc
Copy link
Contributor

Check duplicate issues.

  • Checked for duplicates

Goal

I have Geant4 compiled with TiMemory profiling (GEANT4_USE_TIMEMORY=ON), and I use this Geant4 version to compile DD4hep (DD4HEP_USE_GEANT4=ON). The compile definitions and options from TiMemory contain $<COMPILE_LANGUAGE:CXX> generator expressions in their CMake config files. These generator expressions are not accepted in all contexts 1, in particular not in the add_custom_command that is used to call rootcling in dd4hep_add_dictionary 2.

Operating System and Version

Ubuntu 23.10

compiler

gcc 13.2.0

ROOT Version

6.30.04

DD4hep Version

master c72c530

Reproducer

  1. Install TiMemory and Geant4. I used TiMemory@develop and Geant4@11.2.1 in spack with the PR geant4: new variant timemory spack/spack#43111, but doing this 'by hand' should work as well.
$ spack install geant4 +timemory ^timemory@develop
  1. Configure DD4hep to use Geant4:
$ cmake -Bbuild -S. -DDD4HEP_USE_GEANT4:BOOL=ON -DDD4HEP_DEBUG_CMAKE:BOOL=ON --fresh

This returns the dd4hep-configure-log.txt The recurring error message is:

CMake Error at cmake/DD4hepBuild.cmake:596 (add_custom_command):
  Error evaluating generator expression:

    $<COMPILE_LANGUAGE:CXX>

  $<COMPILE_LANGUAGE:...> may only be used to specify include directories,
  compile definitions, compile options, and to evaluate components of the
  file(GENERATE) command.
Call Stack (most recent call first):
  DDDigi/CMakeLists.txt:56 (dd4hep_add_dictionary)

Additional context

I've tried a few things, without luck:

  • using $<TARGET_GENEX_EVAL:tgt,expr> around the relevant expressions, but this still didn't work
  • using string(GENEX_STRIP) seems too aggressive
  • using file(GENERATE) to write the command in a script and then call that script: this doesn't evaluate the CMake variables

I think the last option seemed most promising.

@wdconinc wdconinc added the bug label Mar 10, 2024
@wdconinc wdconinc changed the title dd4hep_add_dictionary fails when INTERFACE_COMPILE_DEFINITIONS container COMPILE_LANGUAGE cmake genex dd4hep_add_dictionary fails when INTERFACE_COMPILE_DEFINITIONS contains COMPILE_LANGUAGE cmake genex Mar 10, 2024
@wdconinc
Copy link
Contributor Author

A sufficient workaround (but not a fix) for now appears to be:

diff --git a/cmake/DD4hepBuild.cmake b/cmake/DD4hepBuild.cmake
index ef84a22d..33b86710 100644
--- a/cmake/DD4hepBuild.cmake
+++ b/cmake/DD4hepBuild.cmake
@@ -574,7 +574,11 @@ function(dd4hep_add_dictionary dictionary )
     # Get INCLUDE DIRECTORIES from Dependencies
     LIST(APPEND inc_dirs $<TARGET_PROPERTY:${DEP},INTERFACE_INCLUDE_DIRECTORIES>)
     # Get COMPILE DEFINITIONS from Dependencies
-    LIST(APPEND comp_defs $<TARGET_PROPERTY:${DEP},INTERFACE_COMPILE_DEFINITIONS>)
+    if (NOT ${DEP} MATCHES "Geant4::Interface" AND NOT ${DEP} MATCHES "DD4hep::DDG4")
+      LIST(APPEND comp_defs $<TARGET_PROPERTY:${DEP},INTERFACE_COMPILE_DEFINITIONS>)
+    else()
+      message(STATUS "${DEP} INTERFACE_COMPILE_DEFINITIONS skipped")
+    endif()
   endforeach()
 
   #

@andresailer
Copy link
Member

  • file(GENERATE doesn't have COMMAND_EXPAND_LISTS, so the genex to join definitions etc. doesn't work
  • In my debug build timemory defines DEBUG which clashes with a DEBUG enum in dd4hep
FAILED: DD4hep/DDG4/G__DDG4.cxx DD4hep/lib/G__DDG4_rdict.pcm /home/sailer/software/MetaMarlin/build103/DD4hep/DDG4/G__DDG4.cxx /home/sailer/software/MetaMarlin/build103/DD4hep/lib/G__DDG4_rdict.pcm 
cd /home/sailer/software/MetaMarlin/build103/DD4hep/DDG4 && /bin/bash fixed_create_G__DDG4_DebugCXX.sh
In file included from input_line_8:32:
In file included from /home/sailer/software/MetaMarlin/DD4hep/DDG4/include/DDG4/Geant4Config.h:102:
In file included from /home/sailer/software/MetaMarlin/DD4hep/DDG4/include/DDG4/Geant4Kernel.h:17:
In file included from /home/sailer/software/MetaMarlin/DD4hep/DDG4/include/DDG4/Geant4ActionContainer.h:17:
In file included from /cvmfs/sft.cern.ch/lcg/views/LCG_103/x86_64-centos7-gcc11-opt/include/DD4hep/Printout.h:21:
/cvmfs/sft.cern.ch/lcg/views/LCG_103/x86_64-centos7-gcc11-opt/include/Parsers/Printout.h:41:5: error: expected identifier
    DEBUG    = 2,
    ^
<command line>:4:15: note: expanded from here
#define DEBUG 1

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
2 participants