blob: ecb1251860a81fcddacdb0c3fcfce6e8285907bf [file] [log] [blame]
From 56feaa90d070a5011f380d3ae47c01643b9fafe0 Mon Sep 17 00:00:00 2001
From: Rui Costa <rui.ms.costa@ctw.bmwgroup.com>
Date: Fri, 22 Mar 2024 13:27:38 +0000
Subject: [PATCH 2/2] Add package configuration files
Upstream-Status: Pending
---
lang/c++/CMakeLists.txt | 35 +++++++++++++++++++++++++++---
lang/c++/cmake/AvroCppConfig.cmake | 5 +++++
2 files changed, 37 insertions(+), 3 deletions(-)
create mode 100644 lang/c++/cmake/AvroCppConfig.cmake
diff --git a/CMakeLists.txt b/CMakeLists.txt
index d94ba42d3..2e5a394cb 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -140,12 +140,16 @@ set (CPACK_PACKAGE_FILE_NAME "avrocpp-${AVRO_VERSION_MAJOR}")
include (CPack)
-install (TARGETS avrocpp avrocpp_s
+install (TARGETS avrocpp
+ EXPORT AvroCppTargets
LIBRARY DESTINATION lib
ARCHIVE DESTINATION lib
- RUNTIME DESTINATION lib)
+ RUNTIME DESTINATION lib
+ INCLUDES DESTINATION include)
-install (TARGETS avrogencpp RUNTIME DESTINATION bin)
+install (TARGETS avrogencpp
+ EXPORT AvroCppTargets
+ RUNTIME DESTINATION bin)
install (DIRECTORY api/ DESTINATION include/avro
FILES_MATCHING PATTERN *.hh)
@@ -155,3 +159,28 @@ if (NOT CMAKE_BUILD_TYPE)
"Choose the type of build, options are: None Debug Release RelWithDebInfo MinSizeRel."
FORCE)
endif (NOT CMAKE_BUILD_TYPE)
+
+# Create cmake config files
+include(CMakePackageConfigHelpers)
+write_basic_package_version_file(
+ "${CMAKE_CURRENT_BINARY_DIR}/AvroCppConfigVersion.cmake"
+ VERSION ${AVRO_VERSION_MAJOR}.${AVRO_VERSION_MINOR}.${AVRO_VERSION_PATCH}
+ COMPATIBILITY AnyNewerVersion
+)
+
+configure_file(cmake/AvroCppConfig.cmake
+ "${CMAKE_CURRENT_BINARY_DIR}/AvroCppConfig.cmake"
+ COPYONLY
+)
+
+set(ConfigPackageLocation lib/cmake/avrocpp)
+install(EXPORT AvroCppTargets
+ FILE AvroCppTargets.cmake
+ NAMESPACE AvroCpp::
+ DESTINATION ${ConfigPackageLocation}
+)
+install(FILES
+ "cmake/AvroCppConfig.cmake"
+ "${CMAKE_CURRENT_BINARY_DIR}/AvroCppConfigVersion.cmake"
+ DESTINATION ${ConfigPackageLocation}
+ COMPONENT Devel)
diff --git a/cmake/AvroCppConfig.cmake b/cmake/AvroCppConfig.cmake
new file mode 100644
index 000000000..deb8aaa31
--- /dev/null
+++ b/cmake/AvroCppConfig.cmake
@@ -0,0 +1,5 @@
+include(CMakeFindDependencyMacro)
+find_dependency(Boost 1.38 REQUIRED
+ COMPONENTS filesystem iostreams program_options regex system)
+
+include("${CMAKE_CURRENT_LIST_DIR}/AvroCppTargets.cmake")
--
2.44.0