You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
My question is given the above linked project as an example how can we apply modern cmake practices using conan. I am specifically interested in how to setup the tests folder CMakeLists to access the library through an alias.
The text was updated successfully, but these errors were encountered:
shavesha
changed the title
How to add an alias so that the library can be used out the build
How to add an alias so that the library can be used outside the build
Jun 21, 2021
There is also some ongoing work to automate this a bit more: #8533, but the underlying tool will be that set_property with the "cmake_build_module".
In any case, I am not so sure that is a good practice. The non-namespaced jsonutils made sense to provide some kind of backwards compatibility to older findxxx.cmake scripts, but modern cmake packages define package::target targets, with namespace. I'd probably avoid that altogether, specially if you are going to consume the packages yourself.
My library is setup in a very similar manner to this:
modern cmake sample. I use an alias target in the top level CMakeLists file:
add_library(JSONUtils::jsonutils ALIAS jsonutils)
Then in the test folder CMakeLists I use the target:
target_link_libraries(json_utils_test gtest_main JSONUtils::jsonutils)
My question is given the above linked project as an example how can we apply modern cmake practices using conan. I am specifically interested in how to setup the tests folder CMakeLists to access the library through an alias.
The text was updated successfully, but these errors were encountered: