-
Notifications
You must be signed in to change notification settings - Fork 39
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
cmake: Simplify compiler options with Cable #770
Conversation
Codecov Report
@@ Coverage Diff @@
## master #770 +/- ##
==========================================
+ Coverage 99.14% 99.28% +0.13%
==========================================
Files 80 77 -3
Lines 12374 11953 -421
==========================================
- Hits 12268 11867 -401
+ Misses 106 86 -20
Flags with carried forward coverage won't be shown. Click here to find out more.
|
e4a1d0c
to
fc4a3e4
Compare
-Wcast-qual | ||
-Wcast-align | ||
-Wmissing-declarations | ||
$<$<COMPILE_LANGUAGE:CXX>:-Wextra-semi> | ||
$<$<COMPILE_LANGUAGE:CXX>:-Wold-style-cast> | ||
IF_SUPPORTED |
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.
So anything below the IF_SUPPORTED
magic is only enabled if the compiler supports it?
How about ONLY_IF_SUPPORTED
?
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.
Yes, these are optional and enabled if compiler of a particular language supports it.
-Wcast-qual | ||
-Wcast-align | ||
-Wmissing-declarations | ||
$<$<COMPILE_LANGUAGE:CXX>:-Wextra-semi> | ||
$<$<COMPILE_LANGUAGE:CXX>:-Wold-style-cast> |
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.
Does COMPILE_LANGUAGE:CXX
means if the file is cpp or if the compiler is run in c++ mode?
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 means C++ compilation determined by CMake by the source file extension (the fact that this is the same tool for C and C++ is only coincidence).
set(result_var "${lang}${flag_id}") | ||
|
||
# Check if the flag works in the lang's compiler. | ||
# In CMake 3.18+ cmake_language(CALL ...) can be used. |
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 means the file does not require 3.18+? What version is required, can we put a min version on the top?
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 don't know what the minimal CMake version required is. Hard to tell without testing it with multiple versions. And I don't think it is possible to put cmake_minimum_required()
in this file because this will affect the project that loads this file.
cable_add_cxx_compiler_flag_if_supported(-Wduplicated-cond) | ||
cable_add_cxx_compiler_flag_if_supported(-Wduplicate-enum) | ||
cable_add_cxx_compiler_flag_if_supported(-Wlogical-op) | ||
cable_add_cxx_compiler_flag_if_supported(-Wno-unknown-attributes) | ||
|
||
if(CMAKE_CXX_COMPILER_ID MATCHES Clang) | ||
option(WEVERYTHING "Enable almost all compiler warnings" OFF) |
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.
Would it make sense having another helper/case, i.e.
cable_add_compile_option(
-Weverything
IF_PRESENT # If the first option(s) works try adding all these?
-Wno-c++98-compat
...
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 very easy to guess what it does IMHO
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.
What exactly?
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.
@axic's suggestion. Your change looks fine I think.
Since the holdup here is to check if this works with Solidity, there we'd need something like this:
Would this work? |
And how would you simplify the following using the new option:
|
This work.
This cannot be replaced. |
This is not documented, but So simplified version would be cable_add_compile_options(IF_SUPPORTED -fstack-protector -fstack-protector-strong) |
Other good news is that |
Here are the potential changes/simplifications in Solidity: https://github.com/ethereum/solidity/tree/cmake-options |
3f4f4ad
to
c177dd3
Compare
c177dd3
to
1260d7b
Compare
No description provided.