You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@avro.apache.org by "wgtmac (via GitHub)" <gi...@apache.org> on 2025/01/22 15:37:10 UTC
[PR] AVRO-3088: [C++] Export CMake package config file [avro]
wgtmac opened a new pull request, #3299:
URL: https://github.com/apache/avro/pull/3299
## What is the purpose of the change
- Apply modern CMake practice to use target-oriented functions.
- Export and install CMake package configuration file.
## Verifying this change
I have manually verified that the exported config file can be used by downstream projects like below:
```
find_package(Avro CONFIG REQUIRED)
target_link_libraries(xxx PRIVATE Avro::avrocpp_shared)
target_link_libraries(xxx PRIVATE Avro::avrocpp_static)
```
## Documentation
- Does this pull request introduce a new feature? (yes / no)
- If yes, how is the feature documented? (not applicable / docs / JavaDocs / not documented)
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: dev-unsubscribe@avro.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] AVRO-3088: [C++] Export CMake package config file [avro]
Posted by "wgtmac (via GitHub)" <gi...@apache.org>.
wgtmac commented on PR #3299:
URL: https://github.com/apache/avro/pull/3299#issuecomment-2628745305
@thiru-mg @martin-g @Fokko Could you help merge this? iceberg-cpp is depending on my fork which is unavailable after rebasing: https://github.com/apache/iceberg-cpp/blob/c0bf8ce28e4879f674f9fe39160e0a1bae6845f4/cmake_modules/IcebergThirdpartyToolchain.cmake#L153-L154
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: issues-unsubscribe@avro.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] AVRO-3088: [C++] Export CMake package config file [avro]
Posted by "martin-g (via GitHub)" <gi...@apache.org>.
martin-g commented on code in PR #3299:
URL: https://github.com/apache/avro/pull/3299#discussion_r1926994495
##########
lang/c++/CMakeLists.txt:
##########
@@ -264,3 +266,28 @@ if (NOT CMAKE_BUILD_TYPE)
"Choose the type of build, options are: None Debug Release RelWithDebInfo MinSizeRel."
FORCE)
endif (NOT CMAKE_BUILD_TYPE)
+
+include(CMakePackageConfigHelpers)
+
+write_basic_package_version_file(
+ "${CMAKE_CURRENT_BINARY_DIR}/AvroConfigVersion.cmake"
+ VERSION ${AVRO_VERSION}
+ COMPATIBILITY SameMajorVersion)
+
+configure_package_config_file(
+ "${CMAKE_CURRENT_SOURCE_DIR}/cmake/AvroConfig.cmake.in"
+ "${CMAKE_CURRENT_BINARY_DIR}/AvroConfig.cmake"
+ INSTALL_DESTINATION lib/cmake/Avro
Review Comment:
In my (poor) experience the convention is to use the one with the capital letter.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: issues-unsubscribe@avro.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] AVRO-3088: [C++] Export CMake package config file [avro]
Posted by "mkmkme (via GitHub)" <gi...@apache.org>.
mkmkme commented on code in PR #3299:
URL: https://github.com/apache/avro/pull/3299#discussion_r1926907407
##########
lang/c++/CMakeLists.txt:
##########
@@ -69,17 +70,16 @@ endif()
if (CMAKE_COMPILER_IS_GNUCXX)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall -Wextra -Wduplicated-cond -Wduplicated-branches -Wlogical-op -Wuseless-cast -Wconversion -pedantic -Werror")
-if (AVRO_ADD_PROTECTOR_FLAGS)
- set(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} -fstack-protector-all -D_GLIBCXX_DEBUG")
- # Unset _GLIBCXX_DEBUG for avrogencpp.cc because using Boost Program Options
- # leads to linking errors when compiling with _GLIBCXX_DEBUG as described on
- # https://stackoverflow.com/questions/19729036/
- set_source_files_properties(impl/avrogencpp.cc PROPERTIES COMPILE_FLAGS "-U_GLIBCXX_DEBUG")
-endif ()
endif ()
if (AVRO_BUILD_TESTS OR AVRO_USE_BOOST)
- find_package (Boost 1.38 REQUIRED COMPONENTS system)
+ # Boost 1.70 and above provide a BoostConfig.cmake package configuration file.
+ 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 ()
Review Comment:
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.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: issues-unsubscribe@avro.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] AVRO-3088: [C++] Export CMake package config file [avro]
Posted by "mkmkme (via GitHub)" <gi...@apache.org>.
mkmkme commented on code in PR #3299:
URL: https://github.com/apache/avro/pull/3299#discussion_r1927226386
##########
lang/c++/CMakeLists.txt:
##########
@@ -69,17 +70,18 @@ endif()
if (CMAKE_COMPILER_IS_GNUCXX)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall -Wextra -Wduplicated-cond -Wduplicated-branches -Wlogical-op -Wuseless-cast -Wconversion -pedantic -Werror")
-if (AVRO_ADD_PROTECTOR_FLAGS)
- set(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} -fstack-protector-all -D_GLIBCXX_DEBUG")
- # Unset _GLIBCXX_DEBUG for avrogencpp.cc because using Boost Program Options
- # leads to linking errors when compiling with _GLIBCXX_DEBUG as described on
- # https://stackoverflow.com/questions/19729036/
- set_source_files_properties(impl/avrogencpp.cc PROPERTIES COMPILE_FLAGS "-U_GLIBCXX_DEBUG")
-endif ()
endif ()
if (AVRO_BUILD_TESTS OR AVRO_USE_BOOST)
- find_package (Boost 1.38 REQUIRED COMPONENTS system)
+ # Boost 1.70 and above provide a BoostConfig.cmake package configuration file.
+ # It guarantees that Boost::system target exists if found.
+ # See https://cmake.org/cmake/help/latest/policy/CMP0167.html
+ find_package (Boost 1.70 REQUIRED CONFIG COMPONENTS system)
+ if (Boost_FOUND)
Review Comment:
Now this if-statement says `if (Boost_FOUND)` instead of `if (TARGET Boost::system)`. Is this change intentional?
**EDIT:** I see. It is. In this case this if-statement is superfluous :)
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: issues-unsubscribe@avro.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] AVRO-3088: [C++] Export CMake package config file [avro]
Posted by "thiru-mg (via GitHub)" <gi...@apache.org>.
thiru-mg merged PR #3299:
URL: https://github.com/apache/avro/pull/3299
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: dev-unsubscribe@avro.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] AVRO-3088: [C++] Export CMake package config file [avro]
Posted by "wgtmac (via GitHub)" <gi...@apache.org>.
wgtmac commented on code in PR #3299:
URL: https://github.com/apache/avro/pull/3299#discussion_r1927097673
##########
lang/c++/CMakeLists.txt:
##########
@@ -264,3 +266,28 @@ if (NOT CMAKE_BUILD_TYPE)
"Choose the type of build, options are: None Debug Release RelWithDebInfo MinSizeRel."
FORCE)
endif (NOT CMAKE_BUILD_TYPE)
+
+include(CMakePackageConfigHelpers)
+
+write_basic_package_version_file(
+ "${CMAKE_CURRENT_BINARY_DIR}/AvroConfigVersion.cmake"
+ VERSION ${AVRO_VERSION}
+ COMPATIBILITY SameMajorVersion)
+
+configure_package_config_file(
+ "${CMAKE_CURRENT_SOURCE_DIR}/cmake/AvroConfig.cmake.in"
+ "${CMAKE_CURRENT_BINARY_DIR}/AvroConfig.cmake"
+ INSTALL_DESTINATION lib/cmake/Avro
Review Comment:
Agreed. It is adopted by many libraries like Boost, Snappy and Arrow.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: issues-unsubscribe@avro.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] AVRO-3088: [C++] Export CMake package config file [avro]
Posted by "wgtmac (via GitHub)" <gi...@apache.org>.
wgtmac commented on PR #3299:
URL: https://github.com/apache/avro/pull/3299#issuecomment-2607682219
@mitjap @mkmkme @thiru-mg Could you help review this? Thanks!
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: issues-unsubscribe@avro.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] AVRO-3088: [C++] Export CMake package config file [avro]
Posted by "wgtmac (via GitHub)" <gi...@apache.org>.
wgtmac commented on code in PR #3299:
URL: https://github.com/apache/avro/pull/3299#discussion_r1926927764
##########
lang/c++/CMakeLists.txt:
##########
@@ -264,3 +266,28 @@ if (NOT CMAKE_BUILD_TYPE)
"Choose the type of build, options are: None Debug Release RelWithDebInfo MinSizeRel."
FORCE)
endif (NOT CMAKE_BUILD_TYPE)
+
+include(CMakePackageConfigHelpers)
+
+write_basic_package_version_file(
+ "${CMAKE_CURRENT_BINARY_DIR}/AvroConfigVersion.cmake"
+ VERSION ${AVRO_VERSION}
+ COMPATIBILITY SameMajorVersion)
+
+configure_package_config_file(
+ "${CMAKE_CURRENT_SOURCE_DIR}/cmake/AvroConfig.cmake.in"
+ "${CMAKE_CURRENT_BINARY_DIR}/AvroConfig.cmake"
+ INSTALL_DESTINATION lib/cmake/Avro
Review Comment:
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)`
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: issues-unsubscribe@avro.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] AVRO-3088: [C++] Export CMake package config file [avro]
Posted by "wgtmac (via GitHub)" <gi...@apache.org>.
wgtmac commented on code in PR #3299:
URL: https://github.com/apache/avro/pull/3299#discussion_r1926247643
##########
lang/c++/CMakeLists.txt:
##########
@@ -69,17 +70,16 @@ endif()
if (CMAKE_COMPILER_IS_GNUCXX)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall -Wextra -Wduplicated-cond -Wduplicated-branches -Wlogical-op -Wuseless-cast -Wconversion -pedantic -Werror")
-if (AVRO_ADD_PROTECTOR_FLAGS)
- set(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} -fstack-protector-all -D_GLIBCXX_DEBUG")
- # Unset _GLIBCXX_DEBUG for avrogencpp.cc because using Boost Program Options
- # leads to linking errors when compiling with _GLIBCXX_DEBUG as described on
- # https://stackoverflow.com/questions/19729036/
- set_source_files_properties(impl/avrogencpp.cc PROPERTIES COMPILE_FLAGS "-U_GLIBCXX_DEBUG")
-endif ()
endif ()
if (AVRO_BUILD_TESTS OR AVRO_USE_BOOST)
- find_package (Boost 1.38 REQUIRED COMPONENTS system)
+ # Boost 1.70 and above provide a BoostConfig.cmake package configuration file.
+ 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 ()
Review Comment:
Boost is not required. It is required only when `AVRO_BUILD_TESTS` or `AVRO_USE_BOOST` is enabled.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: issues-unsubscribe@avro.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] AVRO-3088: [C++] Export CMake package config file [avro]
Posted by "mkmkme (via GitHub)" <gi...@apache.org>.
mkmkme commented on code in PR #3299:
URL: https://github.com/apache/avro/pull/3299#discussion_r1927226386
##########
lang/c++/CMakeLists.txt:
##########
@@ -69,17 +70,18 @@ endif()
if (CMAKE_COMPILER_IS_GNUCXX)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall -Wextra -Wduplicated-cond -Wduplicated-branches -Wlogical-op -Wuseless-cast -Wconversion -pedantic -Werror")
-if (AVRO_ADD_PROTECTOR_FLAGS)
- set(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} -fstack-protector-all -D_GLIBCXX_DEBUG")
- # Unset _GLIBCXX_DEBUG for avrogencpp.cc because using Boost Program Options
- # leads to linking errors when compiling with _GLIBCXX_DEBUG as described on
- # https://stackoverflow.com/questions/19729036/
- set_source_files_properties(impl/avrogencpp.cc PROPERTIES COMPILE_FLAGS "-U_GLIBCXX_DEBUG")
-endif ()
endif ()
if (AVRO_BUILD_TESTS OR AVRO_USE_BOOST)
- find_package (Boost 1.38 REQUIRED COMPONENTS system)
+ # Boost 1.70 and above provide a BoostConfig.cmake package configuration file.
+ # It guarantees that Boost::system target exists if found.
+ # See https://cmake.org/cmake/help/latest/policy/CMP0167.html
+ find_package (Boost 1.70 REQUIRED CONFIG COMPONENTS system)
+ if (Boost_FOUND)
Review Comment:
Now this if-statement says `if (Boost_FOUND)` instead of `if (TARGET Boost::system)`. Is this change intentional?
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: issues-unsubscribe@avro.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] AVRO-3088: [C++] Export CMake package config file [avro]
Posted by "wgtmac (via GitHub)" <gi...@apache.org>.
wgtmac commented on code in PR #3299:
URL: https://github.com/apache/avro/pull/3299#discussion_r1926648161
##########
lang/c++/CMakeLists.txt:
##########
@@ -69,17 +70,16 @@ endif()
if (CMAKE_COMPILER_IS_GNUCXX)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall -Wextra -Wduplicated-cond -Wduplicated-branches -Wlogical-op -Wuseless-cast -Wconversion -pedantic -Werror")
-if (AVRO_ADD_PROTECTOR_FLAGS)
- set(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} -fstack-protector-all -D_GLIBCXX_DEBUG")
- # Unset _GLIBCXX_DEBUG for avrogencpp.cc because using Boost Program Options
- # leads to linking errors when compiling with _GLIBCXX_DEBUG as described on
- # https://stackoverflow.com/questions/19729036/
- set_source_files_properties(impl/avrogencpp.cc PROPERTIES COMPILE_FLAGS "-U_GLIBCXX_DEBUG")
-endif ()
endif ()
if (AVRO_BUILD_TESTS OR AVRO_USE_BOOST)
- find_package (Boost 1.38 REQUIRED COMPONENTS system)
+ # Boost 1.70 and above provide a BoostConfig.cmake package configuration file.
+ 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 ()
Review Comment:
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.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: issues-unsubscribe@avro.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] AVRO-3088: [C++] Export CMake package config file [avro]
Posted by "wgtmac (via GitHub)" <gi...@apache.org>.
wgtmac commented on code in PR #3299:
URL: https://github.com/apache/avro/pull/3299#discussion_r1927197861
##########
lang/c++/CMakeLists.txt:
##########
@@ -69,17 +70,16 @@ endif()
if (CMAKE_COMPILER_IS_GNUCXX)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall -Wextra -Wduplicated-cond -Wduplicated-branches -Wlogical-op -Wuseless-cast -Wconversion -pedantic -Werror")
-if (AVRO_ADD_PROTECTOR_FLAGS)
- set(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} -fstack-protector-all -D_GLIBCXX_DEBUG")
- # Unset _GLIBCXX_DEBUG for avrogencpp.cc because using Boost Program Options
- # leads to linking errors when compiling with _GLIBCXX_DEBUG as described on
- # https://stackoverflow.com/questions/19729036/
- set_source_files_properties(impl/avrogencpp.cc PROPERTIES COMPILE_FLAGS "-U_GLIBCXX_DEBUG")
-endif ()
endif ()
if (AVRO_BUILD_TESTS OR AVRO_USE_BOOST)
- find_package (Boost 1.38 REQUIRED COMPONENTS system)
+ # Boost 1.70 and above provide a BoostConfig.cmake package configuration file.
+ 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 ()
Review Comment:
I have changed the message. Please check again.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: issues-unsubscribe@avro.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] AVRO-3088: [C++] Export CMake package config file [avro]
Posted by "wgtmac (via GitHub)" <gi...@apache.org>.
wgtmac commented on code in PR #3299:
URL: https://github.com/apache/avro/pull/3299#discussion_r1930275129
##########
lang/c++/CMakeLists.txt:
##########
@@ -202,15 +196,16 @@ if (AVRO_BUILD_EXECUTABLES)
gen (union_redundant_types redundant_types)
add_executable (avrogencpp impl/avrogencpp.cc)
- target_link_libraries (avrogencpp avrocpp_s ${Boost_LIBRARIES})
+ target_link_libraries (avrogencpp avrocpp_s)
+ target_compile_definitions(avrogencpp PRIVATE AVRO_VERSION="${AVRO_VERSION}")
endif ()
if (AVRO_BUILD_TESTS)
enable_testing()
macro (unittest name)
add_executable (${name} test/${name}.cc)
- target_link_libraries (${name} avrocpp_s ${Boost_LIBRARIES} ${SNAPPY_LIBRARIES} ${ZLIB_LIBRARIES})
+ target_link_libraries (${name} avrocpp_s Boost::system ZLIB::ZLIB $<$<TARGET_EXISTS:Snappy::snappy>:Snappy::snappy>)
Review Comment:
Yes, that's better. I have switched to use `TARGET_NAME_IF_EXISTS`. At the same time, the minimum CMake version has been bumped to 3.12 to use it: https://cmake.org/cmake/help/v3.12/release/3.12.html?highlight=target_name_if_exists#generator-expressions
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: issues-unsubscribe@avro.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] AVRO-3088: [C++] Export CMake package config file [avro]
Posted by "mkmkme (via GitHub)" <gi...@apache.org>.
mkmkme commented on code in PR #3299:
URL: https://github.com/apache/avro/pull/3299#discussion_r1926590348
##########
lang/c++/CMakeLists.txt:
##########
@@ -69,17 +70,16 @@ endif()
if (CMAKE_COMPILER_IS_GNUCXX)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall -Wextra -Wduplicated-cond -Wduplicated-branches -Wlogical-op -Wuseless-cast -Wconversion -pedantic -Werror")
-if (AVRO_ADD_PROTECTOR_FLAGS)
- set(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} -fstack-protector-all -D_GLIBCXX_DEBUG")
- # Unset _GLIBCXX_DEBUG for avrogencpp.cc because using Boost Program Options
- # leads to linking errors when compiling with _GLIBCXX_DEBUG as described on
- # https://stackoverflow.com/questions/19729036/
- set_source_files_properties(impl/avrogencpp.cc PROPERTIES COMPILE_FLAGS "-U_GLIBCXX_DEBUG")
-endif ()
endif ()
if (AVRO_BUILD_TESTS OR AVRO_USE_BOOST)
- find_package (Boost 1.38 REQUIRED COMPONENTS system)
+ # Boost 1.70 and above provide a BoostConfig.cmake package configuration file.
+ 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 ()
Review Comment:
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
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: issues-unsubscribe@avro.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] AVRO-3088: [C++] Export CMake package config file [avro]
Posted by "mkmkme (via GitHub)" <gi...@apache.org>.
mkmkme commented on code in PR #3299:
URL: https://github.com/apache/avro/pull/3299#discussion_r1926986239
##########
lang/c++/CMakeLists.txt:
##########
@@ -264,3 +266,28 @@ if (NOT CMAKE_BUILD_TYPE)
"Choose the type of build, options are: None Debug Release RelWithDebInfo MinSizeRel."
FORCE)
endif (NOT CMAKE_BUILD_TYPE)
+
+include(CMakePackageConfigHelpers)
+
+write_basic_package_version_file(
+ "${CMAKE_CURRENT_BINARY_DIR}/AvroConfigVersion.cmake"
+ VERSION ${AVRO_VERSION}
+ COMPATIBILITY SameMajorVersion)
+
+configure_package_config_file(
+ "${CMAKE_CURRENT_SOURCE_DIR}/cmake/AvroConfig.cmake.in"
+ "${CMAKE_CURRENT_BINARY_DIR}/AvroConfig.cmake"
+ INSTALL_DESTINATION lib/cmake/Avro
Review Comment:
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.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: issues-unsubscribe@avro.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] AVRO-3088: [C++] Export CMake package config file [avro]
Posted by "wgtmac (via GitHub)" <gi...@apache.org>.
wgtmac commented on code in PR #3299:
URL: https://github.com/apache/avro/pull/3299#discussion_r1928051310
##########
lang/c++/CMakeLists.txt:
##########
@@ -69,17 +70,18 @@ endif()
if (CMAKE_COMPILER_IS_GNUCXX)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall -Wextra -Wduplicated-cond -Wduplicated-branches -Wlogical-op -Wuseless-cast -Wconversion -pedantic -Werror")
-if (AVRO_ADD_PROTECTOR_FLAGS)
- set(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} -fstack-protector-all -D_GLIBCXX_DEBUG")
- # Unset _GLIBCXX_DEBUG for avrogencpp.cc because using Boost Program Options
- # leads to linking errors when compiling with _GLIBCXX_DEBUG as described on
- # https://stackoverflow.com/questions/19729036/
- set_source_files_properties(impl/avrogencpp.cc PROPERTIES COMPILE_FLAGS "-U_GLIBCXX_DEBUG")
-endif ()
endif ()
if (AVRO_BUILD_TESTS OR AVRO_USE_BOOST)
- find_package (Boost 1.38 REQUIRED COMPONENTS system)
+ # Boost 1.70 and above provide a BoostConfig.cmake package configuration file.
+ # It guarantees that Boost::system target exists if found.
+ # See https://cmake.org/cmake/help/latest/policy/CMP0167.html
+ find_package (Boost 1.70 REQUIRED CONFIG COMPONENTS system)
+ if (Boost_FOUND)
Review Comment:
Fixed. Please take a look again.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: issues-unsubscribe@avro.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] AVRO-3088: [C++] Export CMake package config file [avro]
Posted by "wgtmac (via GitHub)" <gi...@apache.org>.
wgtmac commented on PR #3299:
URL: https://github.com/apache/avro/pull/3299#issuecomment-2628720160
Thanks for the review! @mkmkme @martin-g
Now I have resolved the conflict.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: issues-unsubscribe@avro.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] AVRO-3088: [C++] Export CMake package config file [avro]
Posted by "wgtmac (via GitHub)" <gi...@apache.org>.
wgtmac commented on PR #3299:
URL: https://github.com/apache/avro/pull/3299#issuecomment-2628749356
Thanks for merging it! @thiru-mg
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: issues-unsubscribe@avro.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] AVRO-3088: [C++] Export CMake package config file [avro]
Posted by "Fokko (via GitHub)" <gi...@apache.org>.
Fokko commented on PR #3299:
URL: https://github.com/apache/avro/pull/3299#issuecomment-2630549190
I see that @thiru-mg beat met to it (which is a good thing), thanks for adding this @wgtmac 🙌
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: issues-unsubscribe@avro.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] AVRO-3088: [C++] Export CMake package config file [avro]
Posted by "wgtmac (via GitHub)" <gi...@apache.org>.
wgtmac commented on code in PR #3299:
URL: https://github.com/apache/avro/pull/3299#discussion_r1927261894
##########
lang/c++/CMakeLists.txt:
##########
@@ -69,17 +70,18 @@ endif()
if (CMAKE_COMPILER_IS_GNUCXX)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall -Wextra -Wduplicated-cond -Wduplicated-branches -Wlogical-op -Wuseless-cast -Wconversion -pedantic -Werror")
-if (AVRO_ADD_PROTECTOR_FLAGS)
- set(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} -fstack-protector-all -D_GLIBCXX_DEBUG")
- # Unset _GLIBCXX_DEBUG for avrogencpp.cc because using Boost Program Options
- # leads to linking errors when compiling with _GLIBCXX_DEBUG as described on
- # https://stackoverflow.com/questions/19729036/
- set_source_files_properties(impl/avrogencpp.cc PROPERTIES COMPILE_FLAGS "-U_GLIBCXX_DEBUG")
-endif ()
endif ()
if (AVRO_BUILD_TESTS OR AVRO_USE_BOOST)
- find_package (Boost 1.38 REQUIRED COMPONENTS system)
+ # Boost 1.70 and above provide a BoostConfig.cmake package configuration file.
+ # It guarantees that Boost::system target exists if found.
+ # See https://cmake.org/cmake/help/latest/policy/CMP0167.html
+ find_package (Boost 1.70 REQUIRED CONFIG COMPONENTS system)
+ if (Boost_FOUND)
Review Comment:
OK, let me remove it.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: issues-unsubscribe@avro.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] AVRO-3088: [C++] Export CMake package config file [avro]
Posted by "mitjap (via GitHub)" <gi...@apache.org>.
mitjap commented on code in PR #3299:
URL: https://github.com/apache/avro/pull/3299#discussion_r1925610597
##########
lang/c++/CMakeLists.txt:
##########
@@ -69,17 +70,16 @@ endif()
if (CMAKE_COMPILER_IS_GNUCXX)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall -Wextra -Wduplicated-cond -Wduplicated-branches -Wlogical-op -Wuseless-cast -Wconversion -pedantic -Werror")
-if (AVRO_ADD_PROTECTOR_FLAGS)
- set(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} -fstack-protector-all -D_GLIBCXX_DEBUG")
- # Unset _GLIBCXX_DEBUG for avrogencpp.cc because using Boost Program Options
- # leads to linking errors when compiling with _GLIBCXX_DEBUG as described on
- # https://stackoverflow.com/questions/19729036/
- set_source_files_properties(impl/avrogencpp.cc PROPERTIES COMPILE_FLAGS "-U_GLIBCXX_DEBUG")
-endif ()
endif ()
if (AVRO_BUILD_TESTS OR AVRO_USE_BOOST)
- find_package (Boost 1.38 REQUIRED COMPONENTS system)
+ # Boost 1.70 and above provide a BoostConfig.cmake package configuration file.
+ 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 ()
Review Comment:
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.
##########
lang/c++/CMakeLists.txt:
##########
@@ -202,15 +203,16 @@ if (AVRO_BUILD_EXECUTABLES)
gen (union_redundant_types redundant_types)
add_executable (avrogencpp impl/avrogencpp.cc)
- target_link_libraries (avrogencpp avrocpp_s ${Boost_LIBRARIES})
+ target_link_libraries (avrogencpp avrocpp_s)
+ target_compile_definitions(avrogencpp PRIVATE AVRO_VERSION="${AVRO_VERSION}")
endif ()
if (AVRO_BUILD_TESTS)
enable_testing()
macro (unittest name)
add_executable (${name} test/${name}.cc)
- target_link_libraries (${name} avrocpp_s ${Boost_LIBRARIES} ${SNAPPY_LIBRARIES} ${ZLIB_LIBRARIES})
+ target_link_libraries (${name} avrocpp_s Boost::system ZLIB::ZLIB $<IF:$<TARGET_EXISTS:Snappy::snappy>,Snappy::snappy,>)
Review Comment:
I think this should work. Might be more readable with simple `if` expression.
##########
lang/c++/CMakeLists.txt:
##########
@@ -135,26 +127,35 @@ set (AVRO_SOURCE_FILES
impl/CustomAttributes.cc
)
-add_library (avrocpp SHARED ${AVRO_SOURCE_FILES})
-
-set_property (TARGET avrocpp
- APPEND PROPERTY COMPILE_DEFINITIONS AVRO_DYN_LINK)
-
+add_library (avrocpp SHARED ${AVRO_SOURCE_FILES})
Review Comment:
```suggestion
add_library (avrocpp SHARED ${AVRO_SOURCE_FILES})
```
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: issues-unsubscribe@avro.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] AVRO-3088: [C++] Export CMake package config file [avro]
Posted by "wgtmac (via GitHub)" <gi...@apache.org>.
wgtmac commented on code in PR #3299:
URL: https://github.com/apache/avro/pull/3299#discussion_r1925633788
##########
lang/c++/CMakeLists.txt:
##########
@@ -69,17 +70,16 @@ endif()
if (CMAKE_COMPILER_IS_GNUCXX)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall -Wextra -Wduplicated-cond -Wduplicated-branches -Wlogical-op -Wuseless-cast -Wconversion -pedantic -Werror")
-if (AVRO_ADD_PROTECTOR_FLAGS)
- set(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} -fstack-protector-all -D_GLIBCXX_DEBUG")
- # Unset _GLIBCXX_DEBUG for avrogencpp.cc because using Boost Program Options
- # leads to linking errors when compiling with _GLIBCXX_DEBUG as described on
- # https://stackoverflow.com/questions/19729036/
- set_source_files_properties(impl/avrogencpp.cc PROPERTIES COMPILE_FLAGS "-U_GLIBCXX_DEBUG")
-endif ()
endif ()
if (AVRO_BUILD_TESTS OR AVRO_USE_BOOST)
- find_package (Boost 1.38 REQUIRED COMPONENTS system)
+ # Boost 1.70 and above provide a BoostConfig.cmake package configuration file.
+ 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 ()
Review Comment:
I just want to make sure that the target with `Boost::` namespace exists. Same for `Snappy::snappy` and `ZLIB::ZLIB`
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: issues-unsubscribe@avro.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] AVRO-3088: [C++] Export CMake package config file [avro]
Posted by "mitjap (via GitHub)" <gi...@apache.org>.
mitjap commented on code in PR #3299:
URL: https://github.com/apache/avro/pull/3299#discussion_r1925686018
##########
lang/c++/CMakeLists.txt:
##########
@@ -69,17 +70,16 @@ endif()
if (CMAKE_COMPILER_IS_GNUCXX)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall -Wextra -Wduplicated-cond -Wduplicated-branches -Wlogical-op -Wuseless-cast -Wconversion -pedantic -Werror")
-if (AVRO_ADD_PROTECTOR_FLAGS)
- set(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} -fstack-protector-all -D_GLIBCXX_DEBUG")
- # Unset _GLIBCXX_DEBUG for avrogencpp.cc because using Boost Program Options
- # leads to linking errors when compiling with _GLIBCXX_DEBUG as described on
- # https://stackoverflow.com/questions/19729036/
- set_source_files_properties(impl/avrogencpp.cc PROPERTIES COMPILE_FLAGS "-U_GLIBCXX_DEBUG")
-endif ()
endif ()
if (AVRO_BUILD_TESTS OR AVRO_USE_BOOST)
- find_package (Boost 1.38 REQUIRED COMPONENTS system)
+ # Boost 1.70 and above provide a BoostConfig.cmake package configuration file.
+ 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 ()
Review Comment:
Snappy and ZLIB are not marked as required.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: issues-unsubscribe@avro.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] AVRO-3088: [C++] Export CMake package config file [avro]
Posted by "mkmkme (via GitHub)" <gi...@apache.org>.
mkmkme commented on code in PR #3299:
URL: https://github.com/apache/avro/pull/3299#discussion_r1926920962
##########
lang/c++/CMakeLists.txt:
##########
@@ -264,3 +266,28 @@ if (NOT CMAKE_BUILD_TYPE)
"Choose the type of build, options are: None Debug Release RelWithDebInfo MinSizeRel."
FORCE)
endif (NOT CMAKE_BUILD_TYPE)
+
+include(CMakePackageConfigHelpers)
+
+write_basic_package_version_file(
+ "${CMAKE_CURRENT_BINARY_DIR}/AvroConfigVersion.cmake"
+ VERSION ${AVRO_VERSION}
+ COMPATIBILITY SameMajorVersion)
+
+configure_package_config_file(
+ "${CMAKE_CURRENT_SOURCE_DIR}/cmake/AvroConfig.cmake.in"
+ "${CMAKE_CURRENT_BINARY_DIR}/AvroConfig.cmake"
+ INSTALL_DESTINATION lib/cmake/Avro
Review Comment:
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?
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: issues-unsubscribe@avro.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] AVRO-3088: [C++] Export CMake package config file [avro]
Posted by "mkmkme (via GitHub)" <gi...@apache.org>.
mkmkme commented on code in PR #3299:
URL: https://github.com/apache/avro/pull/3299#discussion_r1930137523
##########
lang/c++/CMakeLists.txt:
##########
@@ -202,15 +196,16 @@ if (AVRO_BUILD_EXECUTABLES)
gen (union_redundant_types redundant_types)
add_executable (avrogencpp impl/avrogencpp.cc)
- target_link_libraries (avrogencpp avrocpp_s ${Boost_LIBRARIES})
+ target_link_libraries (avrogencpp avrocpp_s)
+ target_compile_definitions(avrogencpp PRIVATE AVRO_VERSION="${AVRO_VERSION}")
endif ()
if (AVRO_BUILD_TESTS)
enable_testing()
macro (unittest name)
add_executable (${name} test/${name}.cc)
- target_link_libraries (${name} avrocpp_s ${Boost_LIBRARIES} ${SNAPPY_LIBRARIES} ${ZLIB_LIBRARIES})
+ target_link_libraries (${name} avrocpp_s Boost::system ZLIB::ZLIB $<$<TARGET_EXISTS:Snappy::snappy>:Snappy::snappy>)
Review Comment:
Can't we use `$<TARGET_NAME_IF_EXISTS:Snappy::snappy>` here as well instead of `$<$<TARGET_EXISTS:Snappy::snappy>:Snappy::snappy>`?
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: issues-unsubscribe@avro.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org