-
Notifications
You must be signed in to change notification settings - Fork 101
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
Prepare first release using Geant4 units (mm,ns,MeV) #772
Prepare first release using Geant4 units (mm,ns,MeV) #772
Conversation
@andresailer Could you please have a look to the changes in cmake ? This is not really my strength.... |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't understand why the manual propagation of DD4HEP_DEBUG is necessary, unless you have something that doesn't link (transitively) against DDCore?
DDCore/src/plugins/ShapePlugins.cpp
Outdated
@@ -950,8 +957,8 @@ void* shape_mesh_verifier(Detector& description, int argc, char** argv) { | |||
solid.setDimensions(params); | |||
} | |||
else if ( isInstance<PseudoTrap>(solid) ) { | |||
auto params = solid.dimensions(); | |||
solid.setDimensions(params); | |||
//auto params = solid.dimensions(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why this change?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ohh. This was a mistake.
cmake/DD4hepBuild.cmake
Outdated
@@ -565,6 +570,10 @@ function(dd4hep_add_dictionary dictionary ) | |||
LIST(APPEND comp_defs ${def}) | |||
endforeach() | |||
|
|||
if(DD4HEP_BUILD_DEBUG) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
if(DD4HEP_BUILD_DEBUG) | |
if(DD4HEP_BUILD_DEBUG) |
But is this really necessary?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Apparently yes. ROOT data streaming simply crashed for conditions, where this flag actually changes the structure layout.
Also the TStreamerInfo was wrong.
For this reason the compile flag must be passed to rootcling.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The idea is that rootcling is being passed this information from one of the targets (or USE parameter?), if you can tell me more details I will investigate.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I do not know. The very best would probably be to generate some "config.h", which contains all relevant compile parameters.
This would ensure that such parameters, which cannot be changed for one release build are also properly propagated
to all client projects....
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Seems to me this
Line 43 in c179ef4
USES DDParsers ${XML_LIBRARIES} ${TBB_IMPORTED_TARGETS} |
is missing DDCore and thus not inheriting the DD4HEP_DEBUG.
I did get crashes for various tests without DDCore here when DD4HEP_BUILD_DEBUG was ON
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
And probably also in the other dictionaries in DDCore/CMakeLists.txt
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes. These are exactly the dictionaries in question.
But how can DDCore depend on DDCore ?
So your claim is:
If the flags are set in DD4hep explicitly, the statement:
IF(DD4HEP_BUILD_DEBUG MATCHES "ON" OR (CMAKE_BUILD_TYPE MATCHES "DEBUG|Debug" AND NOT DD4HEP_BUILD_DEBUG MATCHES "OFF"))
target_compile_definitions(DDCore PUBLIC DD4HEP_DEBUG=1)
ENDIF()
Would do all the job ?
However, it then must move to cmake/DD4hepBuild.cmake so that it is picked up by all clients.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The properties are stored in DD4hepConfig-targets.cmake there is no need to move this anywhere else
# Create imported target DD4hep::DDCore
add_library(DD4hep::DDCore SHARED IMPORTED)
set_target_properties(DD4hep::DDCore PROPERTIES
INTERFACE_COMPILE_DEFINITIONS "DD4HEP_DEBUG=1"
INTERFACE_COMPILE_FEATURES "cxx_std_14"
INTERFACE_INCLUDE_DIRECTORIES "${_IMPORT_PREFIX}/include"
INTERFACE_LINK_LIBRARIES "DD4hep::DDParsers;ROOT::Core;ROOT::Rint;ROOT::Tree;ROOT::Physics;ROOT::Geom;ROOT::GenVector;XercesC::XercesC;dl"
)
But how can DDCore depend on DDCore ?
Thanks to the generator expressions which are evaluated at build time
DD4hep/cmake/DD4hepBuild.cmake
Line 572 in c179ef4
LIST(APPEND comp_defs $<TARGET_PROPERTY:${DEP},INTERFACE_COMPILE_DEFINITIONS>) |
CMakeLists.txt
Outdated
IF(DD4HEP_BUILD_DEBUG MATCHES "ON" OR (CMAKE_BUILD_TYPE MATCHES "DEBUG|Debug" AND NOT DD4HEP_BUILD_DEBUG MATCHES "OFF")) | ||
message(STATUS "BUILD DD4HEP with debug extensions") | ||
set(DD4HEP_BUILD_DEBUG ON) | ||
add_compile_definitions(DD4HEP_DEBUG=1) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why is this needed? The definition for the DDCore target should be inherited by anything that links against DDCore, which should be everything, no? (This should also propagate to any project using DDCore outside of DD4hep)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hmm. Must retest this.
cmake/DD4hepConfig.cmake.in
Outdated
@@ -50,6 +52,10 @@ endif() | |||
FIND_DEPENDENCY(Boost REQUIRED) | |||
DD4HEP_SETUP_BOOST_TARGETS() | |||
|
|||
if(DD4HEP_BUILD_DEBUG) | |||
add_compile_definitions(DD4HEP_DEBUG=1) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Necessary?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
YES. Absolutely.
Everything depending on DDCore (better including DD4hep/detail/ConditionsInterna.h) needs this flag.
Otherwise you have conflicting object layouts.
cmake/DD4hepBuild.cmake
Outdated
@@ -43,6 +43,11 @@ macro(dd4hep_set_compiler_flags) | |||
set ( COMPILER_FLAGS ${COMPILER_FLAGS} -Winconsistent-missing-override -Wno-c++1z-extensions -Wheader-hygiene ) | |||
endif() | |||
|
|||
IF( DD4HEP_USE_GEANT4_UNITS ) | |||
MESSAGE(STATUS "+++ Building DD4hep with Geant4 units......") | |||
add_compile_definitions(DD4HEP_USE_GEANT4_UNITS=1) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This should just be added as a target_compile_definitions
to DDG4(?)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe.
Then it also must enter in cmake/DD4hepConfig.cmake.in because DD4hepUnits.h must be consistently used for all
depending code.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Which it would because of the transitivity of the cmake target properties.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think I misunderstood your comment.
The flag DD4HEP_USE_GEANT4_UNITS has nothing to do with Geant4.
It tells dd4hep to instruct TGeo to natively compute all quantities in the same units as Geant4 has (mm,ns,MeV).
This is independent of DDG4. I will try to do the same thing as with DD4HEP_DEBUG
…sults in both unit schemes.
…sults in both unit schemes.
2c304f4
to
bf7d17f
Compare
BEGINRELEASENOTES
-DDD4HEP_USE_GEANT4_UNITS=ON
. Once set, the flag is automatically propagated to depending projects in the generatedDD4hepConfig.cmake
. It programs TGeo to use the Geant4 units system. The unit system is applied also to depending quantities like interaction lengths etc.DD4HEP_BUILD_DEBUG
to depending projects. This flag affects some object layouts and hence MUST be applied also to depending projects.Plugins.h
from being processed by rootcling. Plugins.h uses#include <any>
, which cannot be processed.ENDRELEASENOTES