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
cmake: Refactor targets export variable and improve comments #789
Conversation
This is consistent with other usages of the file. PROJECT_NAME is only useful if there are subprojects, and there aren't any here.
Previously, it was totally unused.
The `export()` command purely exports a cmake script into the build directory; it is not related to find_package at all. It is technically not necessary. The main use case would be a user copying it into their internal cmake/ dir in their project, and then using `include()`'ing that file in their cmake. The `install(EXPORT...` command is what actually generates a cmake module that is put on the filesystem in a location that can be found by `find_package` when in config mode.
Pinging some potential reviewers: @jasjuang @leethomason @comargo @lsolanka |
I would rather not create a new variable |
I think that's a fair point but I'll just point out that the variable was already there, just unused :) I would say I have a slight preference towards the variable, since I don't see a strong reason to avoid it, and I think it makes the code more maintainable. |
What do you mean by |
Ah, the actual variable is |
I see, if it were me I will simply delete the line that creates |
Hi, this PR does the following:
TARGETS_EXPORT_NAME
variable. Previously it was completely unused and there were multiple instances of${CMAKE_PROJECT_NAME}Targets
copied around the file. This moves the variable definition to the top, and then replaces those all the copy-pasted code with the variable.export()
command that mentionedfind_package
. It's actually theinstall(EXPORT...
at the bottom that's related tofind_package
. Theexport
command purely generates a script in the build dir.