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: use temporary file to create dictionary, needed for reasons (was 'Args') #1241

Merged
merged 3 commits into from
Mar 13, 2024

Conversation

andresailer
Copy link
Member

@andresailer andresailer commented Mar 11, 2024

BEGINRELEASENOTES

ENDRELEASENOTES

Copy link

github-actions bot commented Mar 11, 2024

Test Results

    8 files      8 suites   3h 37m 44s ⏱️
  361 tests   360 ✅ 0 💤 1 ❌
1 420 runs  1 419 ✅ 0 💤 1 ❌

For more details on these failures, see this check.

Results for commit 2b8a3b6.

♻️ This comment has been updated with latest results.

@wdconinc
Copy link
Contributor

wdconinc commented Mar 12, 2024

I also needed the following diff on my system to make this work:

diff --git a/DDDigi/CMakeLists.txt b/DDDigi/CMakeLists.txt
index ed180e53..855231b3 100644
--- a/DDDigi/CMakeLists.txt
+++ b/DDDigi/CMakeLists.txt
@@ -54,6 +54,7 @@ set(DDDigiIO_DEFINITIONS)
 if(DD4HEP_USE_GEANT4)
   list(APPEND DDDigiIO_DEFINITIONS "DD4HEP_USE_DDG4=1")
   dd4hep_add_dictionary(G__DDDigi_DDG4_IO
+    TARGET DDDigiPlugins
     SOURCES     ../DDCore/include/ROOT/Warnings.h io/DDG4IO.cpp
     LINKDEF     ../DDCore/include/ROOT/LinkDef.h
     USES        DD4hep::DDG4 DD4hep::DDCore
diff --git a/DDEve/CMakeLists.txt b/DDEve/CMakeLists.txt
index ab702943..3b67b9cb 100644
--- a/DDEve/CMakeLists.txt
+++ b/DDEve/CMakeLists.txt
@@ -52,6 +52,7 @@ dd4hep_add_plugin(DDEvePlugins SOURCES src/*.cpp ${DDEVE_LCIO_SOURCES} ${DDEVE_R

 if(DD4HEP_USE_GEANT4)
   dd4hep_add_dictionary(G__DDG4IO
+    TARGET DDEvePlugins
     SOURCES ../DDCore/include/ROOT/Warnings.h DDEve/DDG4IO.C
     LINKDEF ../DDCore/include/ROOT/LinkDef.h
     USES    DD4hep::DDG4
@@ -78,4 +79,4 @@ install(TARGETS ddeve DDEvePlugins DDEve_Interface EXPORT DD4hep
   ARCHIVE DESTINATION lib
   LIBRARY DESTINATION lib
   RUNTIME DESTINATION bin
-  )
\ No newline at end of file
+  )
diff --git a/DDG4/CMakeLists.txt b/DDG4/CMakeLists.txt
index 5970ca03..95633409 100644
--- a/DDG4/CMakeLists.txt
+++ b/DDG4/CMakeLists.txt
@@ -57,10 +57,12 @@ dd4hep_add_dictionary( G__DDG4
 if(TARGET Python::Python AND TARGET ${DD4HEP_ROOT_PYTHON})
   dd4hep_print("|++> Python found, creating DDG4Python Dictionary")
   dd4hep_add_dictionary(G__DDG4Python
+    TARGET  DDG4Plugins
     SOURCES src/python/DDG4Python.C
     USES    DD4hep::DDCore DD4hep::DDParsers DD4hep::DDG4 ROOT::Core Geant4::Interface
     )
   dd4hep_add_dictionary(G__DDPython
+    TARGET   DDG4Plugins
     SOURCES  tpython/DDPython.C
     USES     DD4hep::DDCore Python::Python
     )
diff --git a/examples/DDG4_MySensDet/CMakeLists.txt b/examples/DDG4_MySensDet/CMakeLists.txt
index 912fcf00..4b056bd0 100644
--- a/examples/DDG4_MySensDet/CMakeLists.txt
+++ b/examples/DDG4_MySensDet/CMakeLists.txt
@@ -36,12 +36,6 @@ include(CTest)
 #
 if (DD4HEP_USE_GEANT4)
   #---------------------------  Plugin library for the simulation framework  ---------
-  dd4hep_add_dictionary(G__DDG4_MySensDet
-    SOURCES ${DD4hep_DIR}/include/ROOT/Warnings.h src/MyTrackerHit.h
-    LINKDEF ${DD4hep_DIR}/include/ROOT/LinkDef.h
-    OUTPUT  ${LIBRARY_OUTPUT_PATH}
-    USES    DD4hep::DDCore DD4hep::DDG4 Geant4::Interface
-    )

   #----  Example of a client library with user defined plugins  --------------------
   dd4hep_add_plugin( DDG4_MySensDet
@@ -49,6 +43,10 @@ if (DD4HEP_USE_GEANT4)
     SOURCES   src/*.cpp
     USES      DD4hep::DDCore DD4hep::DDG4 Geant4::Interface ROOT::Core ROOT::Geom ROOT::GenVector ROOT::RIO
     )
+  dd4hep_add_dictionary(G__DDG4_MySensDet
+    TARGET DDG4_MySensDet
+    SOURCES ${DD4hep_DIR}/include/ROOT/Warnings.h src/MyTrackerHit.h
+    LINKDEF ${DD4hep_DIR}/include/ROOT/LinkDef.h
+    OUTPUT  ${LIBRARY_OUTPUT_PATH}
+    USES    DD4hep::DDCore DD4hep::DDG4 Geant4::Interface
+    )
   install(TARGETS DDG4_MySensDet DESTINATION lib)

   # Geant4 material scan. From position=0,0,0 to end-of-world

@andresailer
Copy link
Member Author

Thanks @wdconinc !

Now I have to figure out why the dependency resolution in the CI doesn't work

@andresailer
Copy link
Member Author

Not a dependency issue. ENV{SHELL} isn't set

cd /home/runner/work/DD4hep/DD4hep/build/DDG4 && fixed_create_G__DDG4_ReleaseCXX.sh

Nothing before fixed...

@andresailer
Copy link
Member Author

We don't actually have to pass a target to file(GENERATE it just creates the file N-times for C and CXX, and we can just use the CXX one to continue.

because add_custom_command does not know the COMPILE_LANGUAGE we are not allowed to treat definitions with that genex inside.
We cannot use add_custom_command(TARGET because that fails with the same error, even though it maybe shouldn't

For compatibility with ninja(?) we need to use these $<CONFIG>$<COMPILE_LANGUAGE> shenanigans

add USE_COMMAND_FOR_GENERATION to fall back to old way
@andresailer andresailer changed the title WIP: Args dd4hep_add_dictionary: use temporary file to create dictionary, needed for reasons (was 'Args') Mar 12, 2024
@andresailer andresailer marked this pull request as ready for review March 12, 2024 16:22
@andresailer
Copy link
Member Author

Given we don't need a target in the end, I made the temporary file solution the default (args), so this should work without further changes.

Could you try this again @wdconinc ?

@wdconinc
Copy link
Contributor

This indeed works now. Thanks!

cmake/DD4hepBuild.cmake Outdated Show resolved Hide resolved
…y when any input changes


I hope this will work fine. If the list of headers or linkdefs changes, then cmake should re-run anyway and that will call the file(Generate) to recreate the script, and if only the file content of headers or linkdefs changes, we only have to re-run the shell script.
@andresailer andresailer merged commit e52af7f into AIDASoft:master Mar 13, 2024
12 of 14 checks passed
@andresailer andresailer deleted the args branch March 13, 2024 13:08
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

dd4hep_add_dictionary fails when INTERFACE_COMPILE_DEFINITIONS contains COMPILE_LANGUAGE cmake genex
2 participants