I’ve searched through cmake source files trying to understand why this is happening, and even changed every occurrence of c++11 and CXX11 I found and reran cmake, but the result is the same.
Thanks Gene, that’s indeed “weird” on LLVM’s side. They seem to use LLVM_CXX_STD instead of CMAKE_CXX_STANDARD. So you probably need to configure with -DLLVM_CXX_STD=c++17.
Thanks for bringing this up, we also need to fix this on the ROOT side
Changing -DCMAKE_CXX_STANDARD=17 to -DLLVM_CXX_STD=17 results in the following cmake error.
CMake Error at cmake/modules/HandleLLVMOptions.cmake:462 (message):
The host compiler does not support '-std=17'.
Interestingly using -DCMAKE_CXX_STANDARD=14 or -DCMAKE_CXX_STANDARD=11 produces the exact same error for those standards.
While reading the cmake code to try and understand this error I realized that if it’s been too long since I’ve had a headache, all I need to do is read cmake code.
So I just searched for c++11 in cmake files and found/replaced it in:
src/tools/cling/CMakeLists.txt
src/cmake/modules/HandleLLVMOptions.cmake
src/cmake/modules/CheckAtomic.cmake
src/cmake/modules/AddLLVM.cmake
This reduced, but did not eliminate the occurrence of -std-c++11 on the compile lines shown in obj/CMakeFiles/CMakeOutput.log
-DCMAKE_CXX_FLAGS=’-std=c++17’ simply adds an additional -std=c++17 at the beginning of each compile line, so it’s not really valuable since the compile lines don’t lack for -std= flags.
It’s obvious that the author of the cmake code wanted to ensure c++11. Perhaps c++17 is not viable?
In LLVM there is LLVM_CXX_STD, which should be either c++1y or c++1z, and LLVM_ENABLE_CXX1Y or LLVM_ENABLE_CXX1Z options (bool). In ROOT they are all automatically set by the CMAKE_CXX_STANDARD option. Maybe changing the option on an existing build could mix those values, and re-configuring from scratch could fix the issue. I can try to check how it works in stand-alone cling on Friday.
P.S. If you open a cmake-gui you can see those options
@bellenot also cxx17 etc are supported - they just don’t have even more dedicated funny LLVM CMake variables but are simply covered by LLVM_CXX_STD. See my PR - it does what you’d expect it to do.
Some /usr/bin/c++ lines in CMakeOutput.log and CMakeError.log have only -std=c++11, some have only -std=c++17, some have both, and some have no “-std=”.
CMakeOutput.log and CMakeError.log from this second run are attached.