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

Remove unneeded standard passing #869

Merged
merged 5 commits into from
Aug 1, 2024

Conversation

killerbot242
Copy link
Contributor

based upon the CMAKE_CXX_STANDARD, cmake can generate an option like : -std=c++17, -std=c++20, ...
Just before the try_compile sections are exectued, the following happens:

  • CMAKE_REQUIRED_DEFINITIONS is back-up-ed
  • next it gets adjusted, to contain the cmpiler option to specif the language standard, this is done by setting ${CMAKE_CXX${CMAKE_CXX_STANDARD}_STANDARD_COMPILE_OPTION}
  • some exampes of that are: CMAKE_CXX17_STANDARD_COMPILE_OPTION: -std=c++17 , CMAKE_CXX20_STANDARD_COMPILE_OPTION: -std=c++20
  • and that value becomes the new value for CMAKE_REQUIRED_DEFINITIONS
  • next all the try_compile statements are issued
  • and afterwards the CMAKE_REQUIRED_DEFINITIONS is restored

Now all of that is not needed, since the minimum cmake required is 3.8.
And in cmake 3.8 an adjustment was made so the standard selection compile option is passed to try_compile invocations.
See here : https://cmake.org/cmake/help/latest/policy/CMP0067.html#policy:CMP0067 : Honor language standard in try_compile() source-file signature.
This means that any cmake version >= 3.8 is using by default this new behavior (unless someone would overrule it and put it explicitly to old).
I have done experiments with this, toether with the changed cmake_minimum_required syntax (it can have range), whic allowed me to have newer cmake behave as 3.7 and 3.8 ... , and in 3.7 the lnaguag standard indeed was not passed on, but in 3.8 it is.

Conclusion : this entire process mentioned above is not needed, this is the default behavior of cmake (since 3.8).

The following comments explains why it was added, and that indeed it is no longer needed, as such.
jtv#851 (comment)

Note that neither of these 2 cmake modules are for public use, they are internal cmake stuff.
Nothing on the outside should use it. This was feedback given by kitware developers.
Revert "remove a use added for a purpose which is gone in the meantime."

This reverts commit 7fdd2f8.
…: -std=c++17, -std=c++20, ...

Just before the try_compile sections are exectued, the following happens:
- CMAKE_REQUIRED_DEFINITIONS is back-up-ed
- next it gets adjusted, to contain the cmpiler option to specif the language standard, this is done by setting ${CMAKE_CXX${CMAKE_CXX_STANDARD}_STANDARD_COMPILE_OPTION}
- some exampes of that are: CMAKE_CXX17_STANDARD_COMPILE_OPTION: -std=c++17 , CMAKE_CXX20_STANDARD_COMPILE_OPTION: -std=c++20
- and that value becomes the new value for CMAKE_REQUIRED_DEFINITIONS
- next all the try_compile statements are issued
- and afterwards the CMAKE_REQUIRED_DEFINITIONS is restored

Now all of that is not needed, since the minimum cmake required is 3.8.
And in cmake 3.8 an adjustment was made so the standard selection compile option is passed to try_compile invocations.
See here : https://cmake.org/cmake/help/latest/policy/CMP0067.html#policy:CMP0067 : Honor language standard in try_compile() source-file signature.
This means that any cmake version >= 3.8 is using by default this new behavior (unless someone would overrule it and put it explicitly to old).
I have done experiments with this, toether with the changed cmake_minimum_required syntax (it can have range), whic allowed me to have newer cmake behave as 3.7 and 3.8 ... , and in 3.7 the lnaguag standard indeed was not passed on, but in 3.8 it is.

Conclusion : this entire process mentioned above is not needed, this is the default behavior of cmake (since 3.8).
@killerbot242
Copy link
Contributor Author

is anything prohibiting this PR to be merged ?
I would like to bring after this one, my next little PR ;-)

@jtv
Copy link
Owner

jtv commented Jul 28, 2024

Life has been intervening. Trying to get to it!

@jtv jtv merged commit d26e9c2 into jtv:master Aug 1, 2024
6 checks passed
@jtv
Copy link
Owner

jtv commented Aug 1, 2024

Sorry about the delay @killerbot242, and thanks for the fix. I hope next we can do a release.

@jtv
Copy link
Owner

jtv commented Aug 1, 2024

@killerbot242 I've just released 7.9.2, including this change.

@killerbot242
Copy link
Contributor Author

I have like 3 or 4 more PR coming up

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.

2 participants