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

Start to modernize the code #4

Draft
wants to merge 12 commits into
base: main
Choose a base branch
from

Conversation

ClausKlein
Copy link
Contributor

@ClausKlein ClausKlein commented Sep 5, 2024

@bernedom what is your preferred c++ code style?

I have prepared a .lang-format config file as proposal.
You may see the result at ClausKlein#1

@bernedom
Copy link
Collaborator

bernedom commented Sep 7, 2024

@ClausKlein please do not use cmake-format in this repo. The CMake files are formatted like they are so they match the style presented in the book.

@bernedom
Copy link
Collaborator

bernedom commented Sep 7, 2024

@ClausKlein i generally use the llvm style.

@ClausKlein ClausKlein marked this pull request as draft September 7, 2024 09:26
@ClausKlein
Copy link
Contributor Author

ClausKlein commented Sep 7, 2024

@ClausKlein please do not use cmake-format in this repo. The CMake files are formatted like they are so they match the style presented in the book.

Is the book already published?

If so, is it planned to continue with a 3th edition?

I would have a lot of suggestions to improve the examples:

  • use modern CMake features like FILE_SET
  • use automatic code formatting while with CMake while build
  • use codespell to check typos
  • add examples for newer C++ language features like C++20 modules
  • upgrade to modern conan and other SW packages used like fmt to current versions
  • split the cmake presets into OS platform specific files and use include
  • use cmake-lint to check/fix CMake naming conventions
  • use run-clang-tidy -fix ... to modernize the C++ code examples
  • ...

@bernedom
Copy link
Collaborator

bernedom commented Sep 7, 2024

Is the book already published?

If so, is it planned to continue with a 3th edition?

Yes, the second edition of the book was published on August 30th 2024 and should hit the stores in the next few weeks. However, I we gladly take up the feedback for an eventual 3rd edition. At the moment this is not planned and it depends on a few factors if a 3rd edition will happen or not. If it is OK, I would contact you directly as a reviewer to include you into the writing process directly.

Creating a new edition takes ~half a year, so we're unfortunately always missing out the latest features.

To your input:

I would have a lot of suggestions to improve the examples:

* [ ]  use modern CMake features like `FILE_SET`

This is one of the features that has great potential to become a best practice, at the time of the rewrite there was not yet an established way of using file sets that would make us confident to write them as a preferred way of handling source files. I expect that to change for the next edition, especially if C++ modules are also firmly established by then.

* [ ]  use automatic code formatting while with CMake while build

Where to enforce code formatting is somewhat controversial. My personal stance is that code formatting does not belong into the build process, but either into the IDE, commit rule or into CI. So I don't consider using CMake to format the code a good practice.

* [ ]  use `codespell` to check typos

Good idea, this belongs into CI/CD or me, will add it there.

* [ ]  add examples for newer C++ language features like `C++20 modules`

The focus of the book and the repo is to show CMake features not C++ language features, with the possible exception of modules. Handling of modules was not yet mature enough at the time of writing.

* [ ]  upgrade to modern `conan` and other SW packages used like `fmt` to current versions

the examples in the book are tailored to conan 2 with using conan as dependency provider as the preferred way to interact with CMake. Are we missing something specific?

* [ ]  split the `cmake presets` into OS platform specific files and use `include`

This was considered, but not done for lack of time.

* [ ]  use `cmake-lint` to check/fix `CMake naming conventions`

Good idea, this should go into CI/CD or into a commit hook.

* [ ]  use `run-lang-tidy -fix ...` to modernize the C++ code examples

See the focus of the book, but nothing prevents us from applying it.

@ClausKlein
Copy link
Contributor Author

ClausKlein commented Sep 7, 2024

You may have a look at https://github.com/ClausKlein/cmake-init-modules

It prepare/have most of the features.

P.S.: the conan example is commented out.

And the git module cmake-conan is not needed anymore, or not?

@ClausKlein
Copy link
Contributor Author

Do you know https://github.com/TheLartians/Format.cmake ?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

2 participants