BxCppDev / Bayeux

Core Persistency, Geometry and Data Processing C++ Library for Particle and Nuclear Physics Experiments
GNU General Public License v3.0
4 stars 9 forks source link

Prevent override of CMAKE_CXX_FLAGS by Geant4 #64

Closed drbenmorgan closed 4 years ago

drbenmorgan commented 4 years ago

As reported in #63, Inclusion of Geant4's "use file" resulted in a hard overwrite of the CMAKE_CXX_FLAGS of Bayeux, making it impossible to add/remove flags on demand. The "use file" is only intended for use by simple pure Geant4 applications rather than frameworks like Bayeux.

Remove inclusion of Geant4 use file. Mark Geant4 include directories as SYSTEM to suppress warnings from these. Apply Geant4_CXX_FLAGS as private compile options of Bayeux_mctools_geant4 to ensure their application without onward transmission. These flags are likely not required as they are for the compilation of Geant4 itself, but we apply them for consistency.

Note that this change exposes a couple of extra warnings in Bayeux that will likely result in the CI failing. These are seen on Clang, so good to get confirmation on GCC as well, then can be fixed up through discussion here.

fmauger commented 4 years ago

Let's merge for the minimal CI is ok. I'll checked the full stuff on my box.

drbenmorgan commented 4 years ago

O.k., for reference, the warnings/errors on Clang were mostly shadowing:

[  3%] Building CXX object source/CMakeFiles/Bayeux.dir/bxbayeux/detail/bayeux_library.cc.o
In file included from .../source/bxbayeux/detail/bayeux_library.cc:87:
.../build/BuildProducts/include/bayeux/datatools/kernel.h:130:7: fatal error: declaration
      shadows a variable in namespace 'datatools' [-Wshadow]
      init_no_help             = datatools::init_no_help,
      ^
.../build/BuildProducts/include/bayeux/datatools/datatools_init.h:16:5: note: previous
      declaration is here
    init_no_help             = datatools::bit_mask::bit00, //!< Inhibit help screen about kernel switches from the CLI terminal
    ^
1 error generated.
make[2]: *** [source/CMakeFiles/Bayeux.dir/bxbayeux/detail/bayeux_library.cc.o] Error 1
make[1]: *** [source/CMakeFiles/Bayeux.dir/all] Error 2
make: *** [all] Error 2

and similar for other entries in the kernel.h and data tools_init.h files. Plus:

.../source/bxgeomtools/src/logical_volume_selector.cc:200:34: warning: declaration shadows a
      local variable [-Wshadow]
        for (const std::string & mat_name : _lv_materials_) {
                                 ^
.../source/bxgeomtools/src/logical_volume_selector.cc:199:21: note: previous declaration is
      here
        std::string mat_name;
                    ^
.../source/bxgeomtools/src/logical_volume_selector.cc:246:34: warning: declaration shadows a
      local variable [-Wshadow]
        for (const std::string & mat_name : _lv_materials_excluded_) {
                                 ^
.../source/bxgeomtools/src/logical_volume_selector.cc:245:21: note: previous declaration is
      here
        std::string mat_name;
                    ^

and the same virtual destructor issue, but in the local genbb_help:

In file included from .../source/bxgenbb_help/src/wdecay0.cc:23:
In file included from .../build/BuildProducts/include/bayeux/genbb_help/wdecay0.h:36:
In file included from /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/../include/c++/v1/iostream:37:
In file included from /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/../include/c++/v1/ios:215:
In file included from /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/../include/c++/v1/__locale:14:
In file included from /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/../include/c++/v1/string:504:
In file included from /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/../include/c++/v1/string_view:175:
In file included from /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/../include/c++/v1/__string:57:
In file included from /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/../include/c++/v1/algorithm:643:
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/../include/c++/v1/memory:2368:5: warning: delete called on
      non-final 'genbb::gsl_random' that has virtual functions but non-virtual destructor [-Wdelete-non-abstract-non-virtual-dtor]
    delete __ptr;
    ^
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/../include/c++/v1/memory:2623:7: note: in instantiation of
      member function 'std::__1::default_delete<genbb::gsl_random>::operator()' requested here
      __ptr_.second()(__tmp);
      ^
.../source/bxgenbb_help/src/wdecay0.cc:175:21: note: in instantiation of member function
      'std::__1::unique_ptr<genbb::gsl_random, std::__1::default_delete<genbb::gsl_random> >::reset' requested here
      _pimpl_->prng.reset();
                    ^
fmauger commented 4 years ago

yes I have such things too on my side. I fix them step by step...