With newest dd4hep version we need to add an additional -DCMAKE_CXX_STANDARD=17 flag to the detector build call
-DCMAKE_CXX_STANDARD=17