Skip to content
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-cpp] Fix static build #32854

Merged
merged 2 commits into from
Aug 2, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
99 changes: 99 additions & 0 deletions ports/avro-cpp/fix-cmake.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,99 @@
diff --git a/lang/c++/CMakeLists.txt b/lang/c++/CMakeLists.txt
index 472684f4c..edde09e40 100644
--- a/lang/c++/CMakeLists.txt
+++ b/lang/c++/CMakeLists.txt
@@ -51,20 +51,16 @@ list(GET AVRO_VERSION 2 AVRO_VERSION_PATCH)
project (Avro-cpp)
set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} ${CMAKE_SOURCE_DIR})

+find_package(ZLIB REQUIRED)
+
if (WIN32 AND NOT CYGWIN AND NOT MSYS)
add_definitions (/EHa)
- add_definitions (
- -DNOMINMAX
- -DBOOST_REGEX_DYN_LINK
- -DBOOST_FILESYSTEM_DYN_LINK
- -DBOOST_SYSTEM_DYN_LINK
- -DBOOST_IOSTREAMS_DYN_LINK
- -DBOOST_PROGRAM_OPTIONS_DYN_LINK
- -DBOOST_ALL_NO_LIB)
+ add_definitions (-DNOMINMAX)
endif()

if (CMAKE_COMPILER_IS_GNUCXX)
- set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall -pedantic -Werror")
+ # Remove " -Werror" because of warning from boost-math (will require C++ 14 soon)
+ set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall -pedantic")
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
@@ -114,7 +110,7 @@ set (AVRO_SOURCE_FILES
impl/CustomAttributes.cc
)

-add_library (avrocpp SHARED ${AVRO_SOURCE_FILES})
+add_library (avrocpp ${AVRO_SOURCE_FILES})

set_property (TARGET avrocpp
APPEND PROPERTY COMPILE_DEFINITIONS AVRO_DYN_LINK)
@@ -131,12 +127,12 @@ set_target_properties (avrocpp PROPERTIES
set_target_properties (avrocpp_s PROPERTIES
VERSION ${AVRO_VERSION_MAJOR}.${AVRO_VERSION_MINOR}.${AVRO_VERSION_PATCH})

-target_link_libraries (avrocpp ${Boost_LIBRARIES} ${SNAPPY_LIBRARIES})
+target_link_libraries (avrocpp ${Boost_LIBRARIES} ${SNAPPY_LIBRARIES} ZLIB::ZLIB)
xiaozhuai marked this conversation as resolved.
Show resolved Hide resolved
target_include_directories(avrocpp PRIVATE ${SNAPPY_INCLUDE_DIR})

add_executable (precompile test/precompile.cc)

-target_link_libraries (precompile avrocpp_s ${Boost_LIBRARIES} ${SNAPPY_LIBRARIES})
+target_link_libraries (precompile avrocpp_s ${Boost_LIBRARIES} ${SNAPPY_LIBRARIES} ZLIB::ZLIB)

macro (gen file ns)
add_custom_command (OUTPUT ${file}.hh
@@ -166,13 +162,14 @@ gen (primitivetypes pt)
gen (cpp_reserved_words cppres)

add_executable (avrogencpp impl/avrogencpp.cc)
-target_link_libraries (avrogencpp avrocpp_s ${Boost_LIBRARIES} ${SNAPPY_LIBRARIES})
+target_link_libraries (avrogencpp avrocpp_s ${Boost_LIBRARIES} ${SNAPPY_LIBRARIES} ZLIB::ZLIB)

+if(BUILD_TESTING)
enable_testing()

macro (unittest name)
- add_executable (${name} test/${name}.cc)
- target_link_libraries (${name} avrocpp ${Boost_LIBRARIES} ${SNAPPY_LIBRARIES})
+ add_executable (${name} test/${name}.cc impl/json/JsonIO.cc impl/json/JsonDom.cc)
+ target_link_libraries (${name} avrocpp ${Boost_LIBRARIES} ${SNAPPY_LIBRARIES} ZLIB::ZLIB)
add_test (NAME ${name} WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}
COMMAND ${CMAKE_CURRENT_BINARY_DIR}/${name})
endmacro (unittest)
@@ -197,6 +194,7 @@ add_dependencies (AvrogencppTests bigrecord_hh bigrecord_r_hh bigrecord2_hh
union_array_union_hh union_map_union_hh union_conflict_hh
recursive_hh reuse_hh circulardep_hh tree1_hh tree2_hh crossref_hh
primitivetypes_hh empty_record_hh)
+endif()

include (InstallRequiredSystemLibraries)

@@ -204,10 +202,14 @@ set (CPACK_PACKAGE_FILE_NAME "avrocpp-${AVRO_VERSION_MAJOR}")

include (CPack)

-install (TARGETS avrocpp avrocpp_s
- LIBRARY DESTINATION lib
- ARCHIVE DESTINATION lib
- RUNTIME DESTINATION lib)
+install(TARGETS avrocpp EXPORT unofficial-avro-cpp)
+
+install(
+ EXPORT unofficial-avro-cpp
+ FILE unofficial-avro-cpp-config.cmake
+ DESTINATION share/unofficial-avro-cpp
+ NAMESPACE unofficial::avro-cpp::
+)

install (TARGETS avrogencpp RUNTIME DESTINATION bin)

116 changes: 0 additions & 116 deletions ports/avro-cpp/install.patch

This file was deleted.

30 changes: 23 additions & 7 deletions ports/avro-cpp/portfile.cmake
Original file line number Diff line number Diff line change
@@ -1,33 +1,49 @@
vcpkg_check_linkage(ONLY_DYNAMIC_LIBRARY)

vcpkg_from_github(
OUT_SOURCE_PATH SOURCE_PATH
REPO apache/avro
REF e44b680621328c4e6524bd2983af1ce11afeebed
SHA512 932f642f272997b5c0be467d3a3ccc354c6edf425c36b33aa7e61984f67312c712bb1d74cb1a5fd8066169104851e73830f0ed3fdb450e005a5c5bef33c34f20
HEAD_REF master
PATCHES
install.patch
fix-cmake.patch
)

vcpkg_check_features(OUT_FEATURE_OPTIONS FEATURE_OPTIONS
FEATURES
test BUILD_TESTING
INVERTED_FEATURES
snappy CMAKE_DISABLE_FIND_PACKAGE_Snappy
)

vcpkg_cmake_configure(
SOURCE_PATH "${SOURCE_PATH}/lang/c++"
OPTIONS
-DBUILD_TESTING=OFF
${FEATURE_OPTIONS}
)

vcpkg_cmake_install(ADD_BIN_TO_PATH)
vcpkg_cmake_install()
vcpkg_cmake_config_fixup(PACKAGE_NAME unofficial-${PORT})

file(READ "${CURRENT_PACKAGES_DIR}/share/unofficial-avro-cpp/unofficial-avro-cpp-config.cmake" cmake_config)
if("snappy" IN_LIST FEATURES)
file(WRITE "${CURRENT_PACKAGES_DIR}/share/unofficial-avro-cpp/unofficial-avro-cpp-config.cmake"
"include(CMakeFindDependencyMacro)
find_dependency(ZLIB)
find_dependency(Snappy)
${cmake_config}
")
else()
file(WRITE "${CURRENT_PACKAGES_DIR}/share/unofficial-avro-cpp/unofficial-avro-cpp-config.cmake"
"include(CMakeFindDependencyMacro)
find_dependency(ZLIB)
${cmake_config}
")
endif()

vcpkg_copy_pdbs()
vcpkg_copy_tools(TOOL_NAMES avrogencpp AUTO_CLEAN)

file(REMOVE_RECURSE "${CURRENT_PACKAGES_DIR}/debug/include")
file(REMOVE_RECURSE "${CURRENT_PACKAGES_DIR}/debug/share")

file(INSTALL "${SOURCE_PATH}/lang/c++/LICENSE" DESTINATION "${CURRENT_PACKAGES_DIR}/share/${PORT}" RENAME copyright)
vcpkg_install_copyright(FILE_LIST "${SOURCE_PATH}/lang/c++/LICENSE")
file(INSTALL "${CMAKE_CURRENT_LIST_DIR}/usage" DESTINATION "${CURRENT_PACKAGES_DIR}/share/${PORT}")
11 changes: 3 additions & 8 deletions ports/avro-cpp/usage
Original file line number Diff line number Diff line change
@@ -1,9 +1,4 @@
The package avro-cpp can be used from CMake via:
avro-cpp provides CMake targets:

find_path(AVROCPP_INCLUDE_DIR avro/Encoder.hh)
find_library(AVROCPP_LIBRARY_DEBUG avrocpp PATH_SUFFIXES "debug/lib" REQUIRED)
get_filename_component(AVROCPP_ROOT_FIND_DIR ${AVROCPP_INCLUDE_DIR} DIRECTORY)
find_library(AVROCPP_LIBRARY_RELEASE avrocpp PATHS "${AVROCPP_ROOT_FIND_DIR}/lib/" REQUIRED NO_DEFAULT_PATH)

target_include_directories(main PRIVATE "${AVROCPP_INCLUDE_DIR}")
target_link_libraries(main PRIVATE optimized "${AVROCPP_LIBRARY_RELEASE}" debug "${AVROCPP_LIBRARY_DEBUG}")
find_package(unofficial-avro-cpp CONFIG REQUIRED)
target_link_libraries(main PRIVATE unofficial::avro-cpp::avrocpp)
16 changes: 5 additions & 11 deletions ports/avro-cpp/vcpkg.json
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
{
"name": "avro-cpp",
"version-date": "2022-11-07",
"port-version": 1,
"description": "Apache Avro is a data serialization system",
"homepage": "https://github.com/apache/avro",
"license": "Apache-2.0",
"supports": "!(windows & static)",
"dependencies": [
"boost-algorithm",
"boost-any",
Expand All @@ -21,6 +21,10 @@
"name": "vcpkg-cmake",
"host": true
},
{
"name": "vcpkg-cmake-config",
"host": true
},
"zlib"
],
"features": {
Expand All @@ -29,16 +33,6 @@
"dependencies": [
"snappy"
]
},
"test": {
"description": "Build tests",
"dependencies": [
"boost-asio",
"boost-bind",
"boost-smart-ptr",
"boost-test",
"boost-thread"
]
}
}
}
3 changes: 0 additions & 3 deletions scripts/ci.baseline.txt
Original file line number Diff line number Diff line change
Expand Up @@ -62,9 +62,6 @@ assimp:arm-neon-android=fail
avro-c:arm-neon-android=fail
avro-c:arm64-android=fail
avro-c:x64-android=fail
avro-cpp:arm-neon-android=fail
avro-cpp:arm64-android=fail
avro-cpp:x64-android=fail
azure-identity-cpp:arm-neon-android=fail
azure-identity-cpp:arm64-android=fail
azure-identity-cpp:x64-android=fail
Expand Down
5 changes: 5 additions & 0 deletions versions/a-/avro-cpp.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,10 @@
{
"versions": [
{
"git-tree": "0f04b2076c299b830bfdd3a698db754f4f8cf269",
"version-date": "2022-11-07",
"port-version": 1
},
{
"git-tree": "08f82323ee0bb00a297cc1318c04dd3bce5d963e",
"version-date": "2022-11-07",
Expand Down
2 changes: 1 addition & 1 deletion versions/baseline.json
Original file line number Diff line number Diff line change
Expand Up @@ -338,7 +338,7 @@
},
"avro-cpp": {
"baseline": "2022-11-07",
"port-version": 0
"port-version": 1
},
"aws-c-auth": {
"baseline": "0.6.22",
Expand Down