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

cmake: CMAKE_CXX_STANDARD overruled by Geant4_CXX_FLAGS in DDG4 #1185

Closed
vvolkl opened this issue Nov 1, 2023 · 2 comments
Closed

cmake: CMAKE_CXX_STANDARD overruled by Geant4_CXX_FLAGS in DDG4 #1185

vvolkl opened this issue Nov 1, 2023 · 2 comments
Labels

Comments

@vvolkl
Copy link
Contributor

vvolkl commented Nov 1, 2023

When building DD4hep against a Geant4 installation that was built with a different CXX_STANDARD, the Geant4 one will be used to compile DDG4, as it becomes part of Geant4_CXX_FLAGS, which are in turn used to compile DDG4, at least in my build:

-- D++> [DD4hep] Geant4 CXX_FLAGS -W -Wall -pedantic -Wno-non-virtual-dtor -Wno-long-long -Wwrite-strings -Wpointer-arith -Woverloaded-virtual -Wno-variadic-macros 
-Wshadow -pipe -pthread -ftls-model=global-dynamic -std=c++14


This can lead to build errors when this is not compatible with the one used by ROOT.

root/spack/lib/spack/env/gcc/g++ -DBOOST_SPIRIT_USE_PHOENIX_V3 -DDD4HEP_USE_TINYXML -DDDG4_EXPORTS -DG4LIB_BUILD_DLL -DG4UI_USE_TCSH -I/tmp/root/spack-stage/spack-stage-dd4hep-1.27-tpk4d52f757bndwiuyx2binippaeonbi/spack-src/DDG4/include -I/tmp/root/spack-stage/spack-stage-dd4hep-1.27-tpk4d52f757bndwiuyx2binippaeonbi/spack-src/DDCore/include -I/tmp/root/spack-stage/spack-stage-dd4hep-1.27-tpk4d52f757bndwiuyx2binippaeonbi/spack-src/DDParsers/include -isystem /root/spack/opt/spack/linux-almalinux9-broadwell/gcc-11.3.1/root-6.28.06-3ynbwb3imflq2qnrl3ophmt7o7knilmz/include/root -isystem /root/spack/opt/spack/linux-almalinux9-broadwell/gcc-11.3.1/boost-1.83.0-zvpm7l67mphzg6bs733aqqysfnwyauzp/include -isystem /root/spack/opt/spack/linux-almalinux9-broadwell/gcc-11.3.1/geant4-10.7.4-wrl76wz3d4xy5rxbtfow5yn6vswl2xyn/include/Geant4 -isystem /root/spack/opt/spack/linux-almalinux9-broadwell/gcc-11.3.1/clhep-2.4.6.4-schzolggr2q3rt2pyz5wnsc6os6idxyu/include -isystem /root/spack/opt/spack/linux-almalinux9-broadwell/gcc-11.3.1/zlib-ng-2.1.4-43pipt6aq3bztdhamxiy2jzxu4miaoox/include -isystem /root/spack/opt/spack/linux-almalinux9-broadwell/gcc-11.3.1/expat-2.5.0-chqhbuyyswtm7knv46x3lozm4prsufie/include -isystem /root/spack/opt/spack/linux-almalinux9-broadwell/gcc-11.3.1/xerces-c-3.2.4-hwqxluk7hv42im7wp3ukpkyo6hrq67ev/include -ftls-model=global-dynamic -Wno-psabi -pedantic -Wextra -Wall -fdiagnostics-color=auto -Wdeprecated -Wno-long-long -Wformat-security -Wshadow            -pthread -O3 -DNDEBUG -std=c++17 -fPIC -W -Wall -pedantic -Wno-non-virtual-dtor -Wno-long-long -Wwrite-strings -Wpointer-arith -Woverloaded-virtual -Wno-variadic-macros -Wshadow -pipe -pthread -ftls-model=global-dynamic -std=c++14 -MD -MT DDG4/CMakeFiles/DDG4.dir/src/Geant4Converter.cpp.o -MF DDG4/CMakeFiles/DDG4.dir/src/Geant4Converter.cpp.o.d -o DDG4/CMakeFiles/DDG4.dir/src/Geant4Converter.cpp.o -c /tmp/root/spack-stage/spack-stage-dd4hep-1.27-tpk4d52f757bndwiuyx2binippaeonbi/spack-src/DDG4/src/Geant4Converter.cpp

...

/root/spack/opt/spack/linux-almalinux9-broadwell/gcc-11.3.1/root-6.28.06-3ynbwb3imflq2qnrl3ophmt7o7knilmz/include/root/TString.h:869:32: note: 'std::string_view' is only available from C++17 onwards
  869 |   std::string printValue(const std::string_view* val);
      |                                ^~~
/tmp/root/spack-stage/spack-stage-dd4hep-1.27-tpk4d52f757bndwiuyx2binippaeonbi/spack-src/DDG4/src/Geant4Converter.cpp: In member function 'void dd4hep::sim::Geant4Converter::handleProperties(dd4hep::Detector::Properties&) const':
/tmp/root/spack-stage/spack-stage-dd4hep-1.27-tpk4d52f757bndwiuyx2binippaeonbi/spack-src/DDG4/src/Geant4Converter.cpp:1222:20: warning: structured bindings only available with '-std=c++17' or '-std=gnu++17'
 1222 |   for( const auto& [nam, vals] : prp ) { 

I saw this as part of a spack build but should not be spack-specific in any way. It's not a bug per se, but I would have expected that the DD4hep CXX STANDARD is used throughout. Also, in my case, it's very possible to build DD4hep (cxxstd=17) against ROOT (cxxstd=17) and Geant4 (cxxstd=14) with some tweaks to the cmake config.

  • OS version: alma9
  • Compiler version: GCC 11.3.1
  • Package version: 01-27
  • Reproduced by: cmake .. ( using ROOT cxxstd=17 and Geant4 cxxstd=14 )
  • Output:see text
  • Goal: build DD4hep against ROOT cxxstd=17 and Geant4 cxxstd=14
@vvolkl vvolkl added the bug label Nov 1, 2023
@andresailer
Copy link
Member

Fixed by #1191 in the sense that cmake now fails if the Geant4 standard differs from the DD4hep one.

@jmcarcell
Copy link
Member

jmcarcell commented Nov 21, 2023

Aha I didn't remember this. In my case it was Geant4 with c++11 and then building with c++17 doesn't work because DD4hep needs at least c++14. To begin with, I'm not sure gcc should be happy when you pass --std=c++17 --std=c++11 and then keeps the second one, but it is 🤷

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

No branches or pull requests

3 participants