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

Modernize CMake #653

Conversation

rettichschnidi
Copy link
Contributor

@rettichschnidi rettichschnidi commented Jan 30, 2022

Before this, the build system set many flags and defines globally,
making it hard-to-impossible to build binaries with freely chosen
combinations of defines in the same build tree.

With this new design, compilation flags are bound to their targets,
which is the preferred style since CMake ~3.0.

Pro:

  • Unit tests and compilation checks can cover arbitrary (all!) defines
  • Simplified usage when including Wakaama in a CMake based project:
    • include wakaama.cmake
    • add_executable(your-binary ...)
    • target_compile_definitions(your-binary ...)
    • target_sources_wakaama(your-binary)
  • DTLS enabled example client built next to the plaintext one. This
    will make it easier to integrate both binaries in the same
    integration test run.

Con:

  • Building the example client project requires the tinydtls submodule
    to be checked out. Same goes for the top level "wakaama" project,
    which includes the example client.

As most CMake files had to be changed to implement, I also integrated CMake code formatting enforcement as discussed in #574.

There is no need for declaring another ret variable.
sanititzed -> sanitized
This should work equally well and does not waste resources on multiple
checkouts.
@rettichschnidi rettichschnidi marked this pull request as draft January 31, 2022 07:33
@rettichschnidi rettichschnidi removed the request for review from mlasch January 31, 2022 07:33
Before this, the build system set many flags and defines globally,
making it hard-to-impossible to build binaries with freely chosen
combinations of defines in the same build tree.

With this new design, compilation flags are bound to their targets,
which is the preferred style since CMake ~3.0.

Pro:
 - Unit tests and compilation checks can cover arbitrary (all!) defines
 - Simplified usage when including Wakaama in a CMake based project:
   - include wakaama.cmake
   - add_executable(your-binary ...)
   - target_compile_definitions(your-binary ...)
   - target_sources_wakaama(your-binary)
 - DTLS enabled example client built next to the plaintext one. This
   will make it easier to integrate both binaries in the same
   integration test run.

Con:
 - Building the example client project requires the tinydtls submodule
   to be checked out. Same goes for the top level "wakaama" project,
   which includes the example client.
cmake-format ensures that our CMake code adheres to the format accepted
by cmake-format.

The code style is based on default one, with some minor adjustments.
@rettichschnidi rettichschnidi marked this pull request as ready for review January 31, 2022 14:51
Copy link
Contributor

@mlasch mlasch left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good with cmake-format in place.

@rettichschnidi rettichschnidi merged commit d57d547 into eclipse-wakaama:master Feb 4, 2022
@rettichschnidi rettichschnidi deleted the gardena/rs/modernize-cmake branch February 4, 2022 17:04
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

2 participants