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

Updated CMake and used [[maybe_unused]] if available. #168

Open
wants to merge 3 commits into
base: master
Choose a base branch
from

Conversation

wermos
Copy link
Contributor

@wermos wermos commented Mar 12, 2023

In the top-level, CMakeLists.txt I specificed the project language and also put the C++ version language as 14 because in Fastor/config/config.h, the compilation is set to error out if the compiler doesn't at least support C++14.

I also modified the test for C++20 because after the release of C++20, the proper way to check for support is to check if __cplusplus is defined to be 202002L or not.

Finally, I changed the use of the [[gnu::unused]] to [[maybe_unused]] if available and compiler-specific pragmas otherwise, because [[gnu::unused]] was emitting error C5030 on MSVC v19.35 (attribute 'gnu::unused' is not recognized).

@wermos
Copy link
Contributor Author

wermos commented Mar 12, 2023

Currently, there is no way to have CMake do something like "use C++20 if available, but if it's not, then fallback to 17, and if that's not available, fall back to 14, and if that's not available, then abort compilation." This "decaying" behavior is available, but it's all or nothing: If we enable it (which is what it's currently doing), then it keeps decaying until it finds a version that the compiler supports (which might be, say, C++11 or even C++98).

There is however, one thing we can do: set the value of CMAKE_CXX_STANDARD to 20, and allow CMake to decay it. Coupled with the aborting behavior defined in Fastor/config/config.h, this should be able to achieve the behavior we want.

@wermos
Copy link
Contributor Author

wermos commented Mar 12, 2023

Not sure why the build is failing. What version of C++ does "Visual Studio 16 2019" have?

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.

None yet

1 participant