-
Notifications
You must be signed in to change notification settings - Fork 11
Feature/modernize cmake #33
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
Conversation
122a417 to
39703ac
Compare
CMakeLists.txt
Outdated
| "$<$<COMPILE_FEATURES:cxx_std_23>:cxx_std_23>" | ||
| "$<$<NOT:$<COMPILE_FEATURES:cxx_std_23>>:cxx_std_20>" |
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.
Please remove these flags. For right now, I believe the Beman standard is to control the C++ standard version via CMAKE_CXX_STANDARD
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.
CMAKE_CXX_STANDARD set it for build time, and it is not set.
But this exports your min required cxx_std on this machine.
see #35
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.
inplace_vector targets a min standard of C++17 I believe.
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.
Note from CI workflow: Needs C++ 20 as C++17 selectively disables ranges and concepts related functionalities!
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.
CK is right here regarding the C++ version.
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 am waiting for a pragmatic decision ...
I will mention this at the meeting tomorrow.
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.
Mentioned... waiting for someone to come in and review....
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 has been discussed at length elsewhere. We're going with the rule that depending on a Beman target should not change the compiler flags of the dependent. Doing so makes it impossible to build a large project with consistent flags.
If this library requires certain compiler + flag combinations, it should run a feature check at CMake time like what was done with iterator_interface and error out with a good message if there isn't a reasonable workaround.
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.
see my example #33 (comment)
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 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 minor comments to address.
|
@wusatosi This PR was requested from you. Any notes? |
Thanks! You made this a lot easier to review :P Thank you for taking my feedback. I am not familiar with this part of CMake I will leave the review up to @DeveloperPaul123 . |
wusatosi
left a comment
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 confirm this PR fixes the install command and enables all_verify_interface_header_sets.
Nice job @ClausKlein , I will leave the details to @DeveloperPaul123 .
ecd405a to
b6eefec
Compare
b6eefec to
d06a5dc
Compare
CMakeLists.txt
Outdated
| # cmake-format: on | ||
|
|
||
| cmake_minimum_required(VERSION 3.23) | ||
| set(CMAKE_SKIP_TEST_ALL_DEPENDENCY FALSE) |
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 wouldn't we want the default here?
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.
With this setting, it is possible to do make test without make all before.
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'd like to see how my suggestion to change the default in CMake plays out. If they're okay with changing the default, I'd be okay with leaving this line in as a temporary solution.
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 discussion there has lead me the conclusion that it is not a good practice to use set(CMAKE_SKIP_TEST_ALL_DEPENDENCY FALSE). See this comment for a rationale summary.
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.
That is your interpretation, not a fact!
| cmake_minimum_required(VERSION 3.23) | ||
| set(CMAKE_SKIP_TEST_ALL_DEPENDENCY FALSE) | ||
|
|
||
| cmake_minimum_required(VERSION 3.25...3.31) |
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 a range? Why this particular range?
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.
To prevent policy warnings if you use a newer CMake version than v.3.25
I would use 3.30...3.31 today.
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 aren't any policies that impact the CMake code in this repository so this isn't needed IIUC.
My preference is to keep the simple cmake_minimum_required(VERSION 3.23) and switch to the ... only in the case that we have a particular CMake policy warning we need to suppress, which hopefully is rare.
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 possible!
| if(${CMAKE_SOURCE_DIR} STREQUAL ${CMAKE_BINARY_DIR}) | ||
| message(FATAL_ERROR "In-source builds are not allowed!") | ||
| endif() |
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 think this check is worth the additional complexity. If people follow our build instructions (e.g. using presets), they should be fine. If this is a big stumbling block, then perhaps this kind of warning should be up-streamed to the Kitware people.
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.
If this is not desired across beman, we should close bemanproject/exemplar#67 .
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 is an open issue at CMake to deny in-source builds.
if you do cmake . -L in source_dir instead in binary_dir, please note the generated files in source tree!
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.
@ClausKlein please stop falsely marking conversations as resolved.
| ${PROJECT_IS_TOP_LEVEL} | ||
| ) | ||
|
|
||
| set(CPACK_GENERATOR TGZ) |
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 set this? Shouldn't the CMake invoker have the decision of what CPack generator to use?
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 no restriction, he user has still the choice to use cpack -G ZIP ...
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 see a benefit of changing the default here, but I see a cost in complexity.
| add_library(beman::inplace_vector ALIAS beman.inplace_vector) | ||
|
|
||
| target_include_directories( | ||
| target_sources( |
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 this code would be better placed in src/beman/inplace_vector/CMakeLists.txt for consistency with beman.exemplar.
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 possible, the BASE_DIR is the current directory!
target_sources(
beman.inplace_vector
PUBLIC
FILE_SET inplace_vector_public_headers
TYPE HEADERS
BASE_DIRS ${CMAKE_CURRENT_SOURCE_DIR}/include
FILES
"${CMAKE_CURRENT_SOURCE_DIR}/include/beman/inplace_vector/inplace_vector.hpp"
)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 understand that. See what is done in exemplar.
CMakeLists.txt
Outdated
| "$<$<COMPILE_FEATURES:cxx_std_23>:cxx_std_23>" | ||
| "$<$<NOT:$<COMPILE_FEATURES:cxx_std_23>>:cxx_std_20>" |
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 has been discussed at length elsewhere. We're going with the rule that depending on a Beman target should not change the compiler flags of the dependent. Doing so makes it impossible to build a large project with consistent flags.
If this library requires certain compiler + flag combinations, it should run a feature check at CMake time like what was done with iterator_interface and error out with a good message if there isn't a reasonable workaround.
| CMakeCache.txt | ||
| CMakeFiles/ |
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 these files?
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.
Garbage generated be in-source build which cmake .
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 think we should add to our .gitignore to cover cases where users do unsupported things.
Every line of code we add has an associated maintenance cost and an overhead for readers. I don't think, in this instance, the cost justifies the benefit.
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.
see #33 (comment)
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'm still unconvinced adding these lines is worth the complexity.
Use FILE_SET HEADERS for simplify installation Set VERIFY_INTERFACE_HEADER_SETS property Prevent use of include(CTest) Prepare CPack to easy distribution Add all_verify_interface_header_sets to CI builds Prevent in-source builds Ignore cmake configure trash
Co-authored-by: David Sankel <[email protected]>
e430e9b to
d462d55
Compare
|
This is a never ending strory, I Think, you will make it you way. |
Use
FILE_SET HEADERSfor simplify installation.Use
VERIFY_INTERFACE_HEADER_SETSPrevent use of
include(CTest).Prepare CPack to easy distribution.
NOTE: This is first of a series of PR based on #14
This fix #35