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

Conversation

tmadlener
Copy link
Collaborator

@tmadlener tmadlener commented Jul 5, 2024

BEGINRELEASENOTES

  • Fix minor issue in the CMake config to make error message for users more useful.

ENDRELEASENOTES

Previously, if the c++ standard was not 17 or 20 it was not detected, and we failed hard with ROOT C++ could not be detected, which doesn't tell the user anything. Demoting that to a warning makes the actually useful message that we have appear.

CMakeLists.txt Outdated
Comment on lines 96 to 99
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.

CMakeLists.txt Outdated
set(ROOT_CXX_STANDARD 17)
elseif("cxx_std_20" IN_LIST ROOT_COMPILE_FEATURES)
set(ROOT_CXX_STANDARD 20)
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.

@tmadlener tmadlener merged commit 1fc075d into AIDASoft:master Jul 8, 2024
18 checks passed
@tmadlener tmadlener deleted the root-compliance-cmake branch July 8, 2024 12:34
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants