-
Notifications
You must be signed in to change notification settings - Fork 0
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
Fully embrace a target-driven approach in CMake exported config #44
Comments
Hint: |
Note: interface targets may set their own dependencies, too. Example: ICartesianControl.h depends on |
Disclaimer: |
See roboticslab-uc3m/developer-manual#18 (comment) regarding YCM integration. |
I've touched several repos, but the most relevant changes happened here:
The usual
In both cases, usage requirements will propagate uniformly through
We barely use utility modules (e.g. InstallOpenravePlugin.cmake), most are find-modules that should not be |
In some legacy code, we were used to see
<Project>Config.cmake(.in)
files with contents that resembled the following lines (source):These are now relics from the pre-target era, and as such, the
<project>_INCLUDE_DIRS
,<project>_LINK_DIRS
and<project>_DEFINES
variables (holding what is better known as usage requirements) no longer make sense when a<project>Targets.cmake
file is finally being generated and exported by CMake along with each successful configuration. The<project>_LIBRARIES
var is a mere alias for all exported targets, created plainly for convenience, but might (and perhaps should) be dropped in order to favour explicitness in downstream calls totarget_link_libraries()
.This is how said
<package>Config.cmake.in
template file looks now (source):The main focus lies now on the following line:
A configuration file might be as simple as that, see CMake docs. Apart from said line, there is some safety boilerplate, as well as the aforementioned
<package>_LIBRARIES
alias and more checks and sets for<package>_INCLUDE_DIRS
.The reason behind keeping a variable to point at where headers are stored is linked to the essence of YARP interfaces. In fact, files such as
ICartesianControl.h
,ICartesianSolver.h
, etc. (ref) do not belong to a specific library and therefore didn't undergo the common target mechanism standardization. However, CMake supports the so-called interface targets, suited for header-only libraries that do not generate any output binaries.In this issue, I propose introducing interface targets for YARP stand-alone interface headers and dropping any exported variable that can be fully replaced by the target mechanism.
Also, the
<package>_MODULE_PATH
variable setter could be rewritten as one or more calls to theinclude()
command, one per module directory. It is to be considered whether such behavior (automatic inclusion upon returning fromfind_package()
) is desired.The text was updated successfully, but these errors were encountered: