-
Notifications
You must be signed in to change notification settings - Fork 15.5k
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
Build examples in CMake #1643
Build examples in CMake #1643
Conversation
Thanks for your pull request. The automated tests will run as soon as one of the admins verifies this change is ok to test. |
127824a
to
95a7d1f
Compare
@@ -100,9 +101,19 @@ configure_file(protobuf-config-version.cmake.in | |||
configure_file(protobuf-module.cmake.in | |||
protobuf-module.cmake @ONLY) | |||
|
|||
# Allows the build directory to be used as a find directory. | |||
export(EXPORT protobuf-targets | |||
NAMESPACE protobuf::) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
d4d1685
to
0897056
Compare
@podsvirov Comments addressed. |
69a1352
to
54c84fe
Compare
Tested working with MSVC 2015 nmake files and CMake 2.8.12 |
329ea6a
to
c018288
Compare
"${protobuf_BINARY_DIR}/protobuf-config-version.cmake" | ||
"${protobuf_BINARY_DIR}/protobuf-module.cmake" | ||
# Allows the build directory to be used as a find directory. | ||
export(TARGETS libprotobuf-lite libprotobuf libprotoc protoc |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No! CMP0024.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
CMP0024 refers specifically to using the include command on the output of export(...). It disallows it because in cmake 3+, the file generated by the export command is not reliably available at configuration time.
This is required to allow using the build directory in the same way you would an install directory
Ex:
In protobuf-build: cmake ../protobuf/cmake
, then build all
then, in protobuf-build-examples: cmake ../protobuf/examples -Dprotobuf_DIR="../protobuf-build/cmake"
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Agree with @yeswalrus on this one. export
is a totally legitimate concept, and there is nothing in this particular use of export
that would prevent it from being used in either the new preferred manner or in the legacy manner.
A series of improvements: - Improved Protobuf module compatibility (disabled by default); - Hide advanced settings; - Added build tree configuration; - Added build of examples.
82b5f98
to
dd94731
Compare
Ready to merge. @xfxyjwf @podsvirov If we can't agree on something between this and #1642, The first commit in this PR could stand on it's own by allowing CMake builds to install examples that could then be built using cmake. |
@podsvirov I could close this and submit a pr directly to your #1642 branch if you prefer? |
It does a good job. There were many discussions and corrections. Tool of PRs allows people to communicate and make changes. Also @yeswalrus in branch yeswalrus:topic-cmake-project-updates you merge with my changes, but "git rebase..." more elegant solution. |
We found a Contributor License Agreement for you (the sender of this pull request) and all commit authors, but as best as we can tell these commits were authored by someone else. If that's the case, please add them to this pull request and have them confirm that they're okay with these commits being contributed to Google. If we're mistaken and you did author these commits, just reply here to confirm. |
Done! @podsvirov, mind appeasing the googlebot? |
Thanks @yeswalrus and googlebot is obsolutly wrong (try repeat instructions). |
@googlebot Confirming |
@podsvirov I think you have to confirm that you're ok with your commits being included in this PR |
# Options | ||
option(protobuf_VERBOSE "Enable for verbose output" OFF) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I was under the impression that you need to define the option before using it. No?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
if you check it before it's defined, it evaluates as false. In this case that's OK since it defaults to off, so if it's on it will either already be defined from the command line or will be set in the cache.
@googlebot add me to this pull request |
@xfxyjwf I do not know how to get @googlebot to take my consent. |
googlebot is probably trying to find some special keywords in your message. I don't know what exact works it's expecting either. |
Updated the label manually and merging... |
Based on https://github.com/podsvirov/protobuf/tree/topic-cmake-project
Examples may be built separately or as part of a full build of protobuf using protobuf_BUILD_EXAMPLES. This is done using ExternalProject_Add to help ensure that building the examples as part of a full build is as close as possible to building them independently.
protobuf_BUILD_EXAMPLES_MULTICONFIG adds 3 additional targets useful for testing the cmake configuration files.
@podsvirov This addresses my comments on #1642 and is much more limited in scope so should be easier to merge.
On using sub_directory
Originally I used sub_directory to include the examples repo, however there was a cascade of issues caused by calling find_package on a project that is currently in the configuration step, particularly with protobuf_MODULE_COMPATILBITY set.
If the additional complexity in protobuf-config and protobuf-module is acceptable, or if we're ok not supporting protobuf_MODULE_COMPATIBILTIY when generating in that mode, sub_directory might be worth reconsidering