- 
                Notifications
    
You must be signed in to change notification settings  - Fork 135
 
Bump cmake version, fix clang-cl #99
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
base: master
Are you sure you want to change the base?
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There are a lot of changes that are unrelated to increase the minimum CMake version, and many of those changes are non-obvious, that require much more explanation of their motivation and effects IMHO.
| @@ -1,69 +1,58 @@ | |||
| cmake_minimum_required(VERSION 3.0.0 FATAL_ERROR) | |||
| cmake_minimum_required(VERSION 3.21.0) | |||
| if(POLICY CMP0177) | |||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is CMake 3.31+ only and could unexpectely change behaviour based on CMake version https://cmake.org/cmake/help/v3.31/policy/CMP0177.html
Seems unnecessary
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The thing is, we already have CMake 4.x and CMake doesn't support this POLICY at some point. So it issues many warnings. It seems to work fine with the new policy if available.
I can test other ways to silence those warnings. Maybe setting that POLICY explicitly to OLD.
| 
               | 
          ||
| if(NOT MSVC) | ||
| message( WARNING "Visual Studio Build supported only" ) | ||
| message(FATAL_ERROR "Visual Studio Build supported only" ) | 
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This might break exotic configurations that actually work, for basically no advantage.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ok, will remove it.
| @@ -0,0 +1,5 @@ | |||
| mkdir CMakeBuildClangCl | |||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think we should stop adding more of those bat files. In times where CMake is well integrated in editors, we really shouldn't need them. There are highly unflexible anyway
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ok, I'll remove it, shall I remove the others too?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just my make my role here clear: I contributed to winflexbison before, but I have no official say here in any way. So I am stating my own personal opinions here.
I am not sure if someone still relies on the existing bat files, but since the development of winflexbison is mostly dead, it can't affect too many people for sure, if we would remove all of them. But maybe this is something for another pull request.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Another pull request it is... concerning cmake I'll let @Croydon decide, for the rest... stay compatible :-)
| 
               | 
          ||
| extern int strverscmp(const char* s1, const char* s2); | ||
| 
               | 
          ||
| struct obstack; | 
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why does a CMake version increase require a code change like this?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not the cmake bump itself, but that code boils out with clang-cl.
The declaration of struct obstack in the functions parameter list is not visible to the outside. It is basically static.
clang is more strict and interprets it as a different declaration each time this file is included and linked. Therefore we get ODR violations on link time.
| #define _MODE_T_ | ||
| typedef int mode_t; | ||
| #endif | ||
| #endif /* _MODE_T_ */ | 
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Seems reasonable, although unrelated.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's not unrelated, since it's required to work with clang-cl.
Clang-cl uses vcruntime and MSVC-STL so no mode_t is defined, but clang obviously defines clang.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sorry, my bad. I was too focused on CMake version adaptations, so I forgot that you want to fix clang-cl midway.
| @@ -1,4 +1,4 @@ | |||
| cmake_minimum_required(VERSION 3.0.0 FATAL_ERROR) | |||
| cmake_minimum_required(VERSION 3.20.0) | |||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why do you use 3.20.0 here, if you propose 3.21.0 for the parent project and bison?
| add_compile_definitions("__extension__=") | ||
| endif() | ||
| 
               | 
          ||
| #if (MSVC) | 
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Those comments can easily be interpreted as actual code and are confusing.
| set(CMAKE_RUNTIME_OUTPUT_DIRECTORY_RELEASE "${CMAKE_CURRENT_BINARY_DIR}/bin/Release") | ||
| set(CMAKE_RUNTIME_OUTPUT_DIRECTORY_RELWITHDEBINFO "${CMAKE_CURRENT_BINARY_DIR}/bin/RelWithDebInfo") | ||
| endif() | ||
| # Only apply to MSVC frontend (not clang frontends) | 
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Spacing is off
| set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} /W3 /EHsc") | ||
| set(CMAKE_C_FLAGS_RELEASE "${CMAKE_C_FLAGS_RELEASE} /GL /Oi /Gy") | 
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
changed this from CXX to C, since all projects are C projects. Those settings had zero effect before.
Shall I remove those lines (behavior unchanged) or use the new flags (lot of warnings, most likely unused intended behavior).
Fixes #98