vsomeip icon indicating copy to clipboard operation
vsomeip copied to clipboard

Modernize CMake code

Open kheaactua opened this issue 1 year ago • 10 comments

Status

For the moment this is still a WIP. I would love community feedback on this PR so that we can produce a modern CMake setup that functions well for everyone.

I suspect the cleanest way to organize the commits would be to squash them.

Description

General CMakeLists improvements - cmake v2→v3

  • Included a .cmake-format file, and ran applied it to the main CMakeList files in this project.
    • The format file does a poor job on if and foreach blocks, but I believe overall it does a better job that the default settings. The main benefit is a consistent format
  • Use targets instead of lib/include variables in CMake
  • [Conditionally] Linking DLT as a target
  • Write internal.hpp to build directory instead of source to prevent needless rebuilds
    • The include directives for this file are also updated in the code to use include paths rather than relative paths.
  • Remove hard coded CMAKE_VERBOSE_MAKEFILE, this should be injected by the user if so desired
  • "wrap"ing (ld's --wrap option) the "socket" symbol, see wrappers.cpp
  • Added install directive to vsomeip/example/hello_world and vsomeip_ctrl
  • Platform conditional socket lib linkage
  • hello_world code uses ENABLE_SIGNALS, but its setting was missing in CMake
  • Improve setup for boost stacktrace, really only helps on Linux and requires the backtrace.h file
  • Added QNX platform section, though the credential code changes for QNX are not included in this commit.
  • Use a CACHE variable for VSOMEIP_BASE_PATH. Upstream defaults this to /var for QNX which is a very bad choice.

Misc

  • Added more ignore rules to for common IDEs

kheaactua avatar Jun 28 '24 15:06 kheaactua

I am still working on this PR, I'll likely rebase to Fabio's 3.5.x branch. Stuff just takes time. :)

kheaactua avatar Aug 09 '24 14:08 kheaactua

I am still working on this PR, I'll likely rebase to Fabio's 3.5.x branch. Stuff just takes time. :)

In that case maybe i will check this PR later! great job anyway, it has interesting improvements

duartenfonseca avatar Aug 09 '24 14:08 duartenfonseca

@kheaactua tried to build this new CMake code and got a failure. I did : cmake -B build cmake --build build

I have ubuntu 22.04, gcc version 11.4

the error i got was the following: /home/duartef/repos/covesa/vsomeip_duarte/vsomeip/implementation/endpoints/src/../../routing/include/../../endpoints/include/netlink_connector.hpp:197:47: error: ‘VSOMEIP_MAX_NETLINK_RETRIES’ was not declared in this scope 197 | static const std::uint32_t max_retries_ = VSOMEIP_MAX_NETLINK_RETRIES;

duartenfonseca avatar Sep 09 '24 17:09 duartenfonseca

@duartenfonseca I'll take a look! Was this on Fabio's 3.5.x? He did push a change to the network tests a few days back.

I'll also fix that conflict that appeared.

kheaactua avatar Sep 09 '24 17:09 kheaactua

@kheaactua i just did a checkout to your branch and tried to build!

duartenfonseca avatar Sep 10 '24 09:09 duartenfonseca

@kheaactua is the increase of minimum version on cmake is really necessary? from our side, we would like to avoid that

duartenfonseca avatar Sep 25 '24 10:09 duartenfonseca

@kheaactua is the increase of minimum version on cmake is really necessary? from our side, we would like to avoid that

I raised it to 3.15 to accommodate Conan 2.0. From the author:

Conan 2.0 requires at least CMake 3.15.

Though not yet posted, I've been prepping covesa/capi-conan, covesa/capi-docker, and some others that all use Conan to set up CommonAPI environments.

Curious though, what would be desirable about staying at 3.13? With 3.23 vsomeip could use file sets for a cleaner install of the includes

Locally I jack it up to 3.30 :)

kheaactua avatar Sep 25 '24 12:09 kheaactua

@kheaactua is the increase of minimum version on cmake is really necessary? from our side, we would like to avoid that

I raised it to 3.15 to accommodate Conan 2.0. From the author:

Conan 2.0 requires at least CMake 3.15.

Though not yet posted, I've been prepping covesa/capi-conan, covesa/capi-docker, and some others that all use Conan to set up CommonAPI environments.

Curious though, what would be desirable about staying at 3.13? With 3.23 vsomeip could use file sets for a cleaner install of the includes

Locally I jack it up to 3.30 :)

I understand your reasons, but if we could find a way to keep the CMake changes without increasing from 3.13 would be best. From our internal process, increasing this there would need to be a strong justification for this change.

duartenfonseca avatar Oct 16 '24 12:10 duartenfonseca

@kheaactua is the increase of minimum version on cmake is really necessary? from our side, we would like to avoid that

I raised it to 3.15 to accommodate Conan 2.0. From the author:

Conan 2.0 requires at least CMake 3.15.

Though not yet posted, I've been prepping covesa/capi-conan, covesa/capi-docker, and some others that all use Conan to set up CommonAPI environments. Curious though, what would be desirable about staying at 3.13? With 3.23 vsomeip could use file sets for a cleaner install of the includes Locally I jack it up to 3.30 :)

I understand your reasons, but if we could find a way to keep the CMake changes without increasing from 3.13 would be best. From our internal process, increasing this there would need to be a strong justification for this change.

I could make Conan apply a patch, that would solve the issue with Conan. I'll give it a try with 3.13 as soon as I can. I may have to remove some of the generator expressions to support 3.13 as well.

Also, for me the Docker setup for the network tests fails with CMake 3.22 and below.

That said, I would strongly encourage the update.

  • 3.26 supports LTO detection on QNX
  • 3.26 improves the debug on try_compile - really helpful when trying to build on new systems
  • 3.23 brings target_source( FILE_SET ) for better installation
  • 3.18 and 3.30 improve how Boost is found (even as far back as 3.16 find_package(boost) is harder than it should be)
  • 3.15 improves generator expressions
  • 3.14 and 3.27 improve the build debug
  • ~3.30 (I think) improves handling of generated files (helpful for CommonAPI)

Just a tonne of updates that help both with QNX and really just in general.

kheaactua avatar Oct 16 '24 12:10 kheaactua

The build error is weird.. Though I do get a similar one locally:

Run on (40 X 4800 MHz CPU s)
CPU Caches:
  L1 Data 48 KiB (x20)
  L1 Instruction 32 KiB (x20)
  L2 Unified 2048 KiB (x20)
  L3 Unified 38400 KiB (x1)
Load Average: 2.77, 3.31, 3.34
***WARNING*** CPU scaling is enabled, the benchmark real time measurements may be noisy and will incur extra overhead.
-----------------------------------------------------------------------------------------------------------------
Benchmark                                                                       Time             CPU   Iterations
-----------------------------------------------------------------------------------------------------------------
BM_check_credentials_policies_not_loaded                                     2.82 ns         2.82 ns    265491910
BM_check_credentials_policies_loaded_invalid_values                          2.66 ns         2.66 ns    259855302
BM_check_credentials_policies_loaded_valid_values                            3.09 ns         3.09 ns    243618071
BM_check_credentials_policies_loaded_audit_mode_invalid_values               3.17 ns         3.17 ns    221014699
BM_check_credentials_policies_loaded_audit_mode_valid_values                 3.12 ns         3.12 ns    227970630
BM_check_routing_credentials_policies_not_loaded                              399 ns          399 ns      1713574
BM_check_routing_credentials_policies_loaded_invalid_values                   407 ns          407 ns      1777926
BM_check_routing_credentials_policies_loaded_valid_values                     409 ns          409 ns      1706650
BM_check_routing_credentials_policies_loaded_lazy_load_invalid_values         399 ns          398 ns      1760846
BM_check_routing_credentials_policies_loaded_lazy_load_valid_values           403 ns          403 ns      1712075
BM_get_client_to_sec_client_mapping_valid_values                             17.0 ns         17.0 ns     41920684
BM_get_client_to_sec_client_mapping_invalid_values                           14.2 ns         14.2 ns     49793167
BM_get_clients                                                               32.7 ns         32.7 ns     21492018
BM_get_sec_client_to_clients_mapping_valid_values                            35.1 ns         35.1 ns     19821518
BM_get_sec_client_to_clients_mapping_invalid_values                          18.8 ns         18.8 ns     36769476
BM_is_client_allowed_policies_not_loaded                                     3.18 ns         3.18 ns    218177708
BM_is_client_allowed_policies_loaded_valid_values                            2.90 ns         2.90 ns    241320837
BM_is_client_allowed_cache_policies_loaded                                   2.89 ns         2.89 ns    241970142
BM_is_client_allowed_policies_loaded_invalid_values                          2.99 ns         2.99 ns    234260981
BM_is_client_allowed_policies_loaded_deny_valid_values                       2.96 ns         2.96 ns    231424899
BM_is_client_allowed_policies_loaded_audit_mode_valid_values                 2.91 ns         2.91 ns    239781608
BM_is_client_allowed_cache_policies_loaded_audit_mode                        2.90 ns         2.90 ns    240085452
BM_is_client_allowed_policies_loaded_audit_mode_invalid_values               2.94 ns         2.94 ns    234957408
BM_is_client_allowed_policies_loaded_audit_mode_deny_valid_values            3.19 ns         3.19 ns    217727636
BM_is_offer_allowed_policies_not_loaded                                      3.49 ns         3.49 ns    195235638
BM_is_offer_allowed_policies_loaded_valid_values                             3.51 ns         3.51 ns    199208643
BM_is_offer_allowed_policies_loaded_invalid_values                           3.52 ns         3.52 ns    200094570
BM_is_offer_allowed_policies_loaded_deny_valid_values                        3.55 ns         3.55 ns    199501975
BM_is_offer_allowed_policies_loaded_audit_mode_valid_values                  3.52 ns         3.52 ns    200815148
BM_is_offer_allowed_policies_loaded_audit_mode_invalid_values                3.55 ns         3.55 ns    200287792
BM_is_offer_allowed_policies_loaded_audit_mode_deny_valid_values             3.56 ns         3.56 ns    196855102
terminate called after throwing an instance of 'std::out_of_range'
  what():  vector::_M_range_check: __n (which is 0) >= this->size() (which is 0)
zsh: IOT instruction (core dumped)

Not sure what the cause is, will investigate.

kheaactua avatar Jan 16 '25 21:01 kheaactua