capicxx-core-runtime icon indicating copy to clipboard operation
capicxx-core-runtime copied to clipboard

cmake: Modernize exported CMake config files

Open neverpanic opened this issue 6 years ago • 2 comments

The CMake configuration files exported by CommonAPI require users to add the ${COMMONAPI_INCLUDE_DIRS} variable to their project's include directories. This was done to support building against a build tree of CommonAPI by generating two different CommonAPIConfig.cmake files that defined this variable with different values.

This is now no longer necessary since CMake supports the $<BUILD_INTERFACE> and $<INSTALL_INTERFACE> generator expressions which can be used to make the same distinction with only a single CommonAPIConfig.cmake file.

This also allows users of CommonAPI to get the required include directories into their build by using

target_link_libraries(${target} CommonAPI)

since the exported CommonAPI CMake target now has the required include directories set as a property. This is much more idiomatic for users of CMake and is thus preferred.

Additionally, this enables downstream projects that build CommonAPI interface libraries to no longer care about what the CommonAPI include directories are, which simplifies writing CMake config files for them.

I've locally compiled vSomeIP, CommonAPI, CommonAPI-SomeIP and a test project using CommonAPI-SomeIP to test this.

neverpanic avatar Oct 22 '18 15:10 neverpanic

@neverpanic The dlt-daemon should use modern cmake too, so we got the transitive dependency here. Only linking against CommonAPI and automatically linking against dlt-daemon. Do you have a patch for this too?

One addition: I would be good, to link against like this, via target alias, target_link_libraries(${target} CommonAPI::CommonAPI) so we would get a cmake config error, when it is not available.

derived-coder avatar Apr 14 '20 11:04 derived-coder

I like this PR. I'm also working on a similar PR to modernize the vsomeip CMakeList files.

kheaactua avatar Jun 21 '24 14:06 kheaactua