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

Detect more c++ standards and make sure useful message actually appears #635

Merged
merged 4 commits into from
Jul 8, 2024
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 5 additions & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -93,8 +93,12 @@ if(NOT DEFINED ROOT_CXX_STANDARD)
set(ROOT_CXX_STANDARD 17)
elseif("cxx_std_20" IN_LIST ROOT_COMPILE_FEATURES)
set(ROOT_CXX_STANDARD 20)
elseif("cxx_std_14" IN_LIST ROOT_COMPILE_FEATURES)
set(ROOT_CXX_STANDARD 14)
elseif("cxx_std_11" IN_LIST ROOT_COMPILE_FEATURES)
set(ROOT_CXX_STANDARD 11)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is there a reason not to put these in order? 11, 14, 17, 20, else

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Mainly laziness. ;) I will order them

Copy link
Member

@jmcarcell jmcarcell Jul 5, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Or simply a loop

foreach(std IN ITEMS 20 17 14 11)
  if("cxx_std_${std}" IN_LIST ROOT_COMPILE_FEATURES)
    set(ROOT_CXX_STANDARD ${std})
    break()
  endif()
endforeach()

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's a loop now.

else()
message(FATAL_ERROR "ROOT C++ could not be detected")
message(WARNING "ROOT c++ standard could not be detected")
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This I don't understand, if the standard can't be detected then that's possibly going to cause some problems later on, no? And after 11 to 20 are included this shouldn't happen anyway? Didn't ROOT change not too long ago how they define the standard? That now would build fine but with maybe different standards in ROOT and podio.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

IIUC an undefined ROOT_CXX_STANDARD would be caught by this:

podio/CMakeLists.txt

Lines 101 to 103 in 76990a9

if(ROOT_CXX_STANDARD VERSION_LESS 17)
message(FATAL_ERROR "You are trying to build podio against a version of ROOT that has not been built with a sufficient c++ standard. podio requires c++17 or higher")
endif()

Which would at least tell people what a potential problem could be rather, than a rather cryptic error about not being able to detect a c++ standard.

The ROOT_CXX_STANDARD is only available from 6.32 onwards. So we still need this determination. From 6.30 onwards c++17 is required. I can't remember now when they switched the default c++ standard to 17, but given that I got an email today that someone ran into this issue with 6.28, I suppose not too long ago.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah yes I was thinking cxx_std had been changed but it was ROOT_CXX_STANDARD: #540.

endif()
endif()

Expand Down