-
Notifications
You must be signed in to change notification settings - Fork 1.7k
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
AVRO-3088: [C++] Export CMake package config file #3299
base: main
Are you sure you want to change the base?
Conversation
find_package (Boost 1.70 REQUIRED CONFIG COMPONENTS system) | ||
if (TARGET Boost::system) | ||
message("Found Boost version: ${Boost_VERSION}") | ||
else () | ||
message(FATAL_ERROR "Boost::system not found") | ||
endif () |
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.
You mark this dependency as required. I think this check if target exists is not needed. CMake will fail if it does not find Boost and all requested components.
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 just want to make sure that the target with Boost::
namespace exists. Same for Snappy::snappy
and ZLIB::ZLIB
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.
Snappy and ZLIB are not marked as required.
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.
Boost is not required. It is required only when AVRO_BUILD_TESTS
or AVRO_USE_BOOST
is enabled.
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 think what @mitjap was trying to say is that this if
statement is superfluous as find_package
is called with a REQUIRED
keyword. It will fail by itself when Boost::system
is not found, no need for doing it explicitly
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.
This is slightly different. CMIW, sometimes Boost::system
target is not available even if Boost_FOUND
is true since older Boost distributions may not add Boost::
namespace.
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'd say in that case maybe reflect this in an error message? At this point Boost::system
is definitely available. But it would not be available as a target.
Not sure however what would be the best error message in that case.
configure_package_config_file( | ||
"${CMAKE_CURRENT_SOURCE_DIR}/cmake/AvroConfig.cmake.in" | ||
"${CMAKE_CURRENT_BINARY_DIR}/AvroConfig.cmake" | ||
INSTALL_DESTINATION lib/cmake/Avro |
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 see an inconsistency here. The headers are installed in include/avro
while cmake files are in lib/cmake/Avro
. Maybe it should be lib/cmake/avro
instead?
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.
This is a case-sensitive package name and it affects the behavior of calling find_package
by downstream.
lib/cmake/avro
->find_package(avro)
lib/cmake/Avro
->find_package(Avro)
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'm actually not sure which one is more preferable here. I'll probably want to hear from the committers to this repo regarding the naming.
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.
In my (poor) experience the convention is to use the one with the capital letter.
What is the purpose of the change
Verifying this change
I have manually verified that the exported config file can be used by downstream projects like below:
Documentation