pkgsrc-WIP-changes archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

heatshrink: Switch to cmake to satisfy libbgcode.



Module Name:	pkgsrc-wip
Committed By:	Paul Ripke <stix%stix.id.au@localhost>
Pushed By:	stix
Date:		Sat Dec 2 15:14:44 2023 +1100
Changeset:	640ebc690e6c3d581a1965c38bf889614aa3df54

Modified Files:
	heatshrink/DESCR
	heatshrink/Makefile
	heatshrink/PLIST
Added Files:
	heatshrink/buildlink3.mk
	heatshrink/files/CMakeLists.txt
	heatshrink/files/Config.cmake.in

Log Message:
heatshrink: Switch to cmake to satisfy libbgcode.

To see a diff of this commit:
https://wip.pkgsrc.org/cgi-bin/gitweb.cgi?p=pkgsrc-wip.git;a=commitdiff;h=640ebc690e6c3d581a1965c38bf889614aa3df54

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

diffstat:
 heatshrink/DESCR                 |  2 +-
 heatshrink/Makefile              |  6 ++-
 heatshrink/PLIST                 | 16 ++++---
 heatshrink/buildlink3.mk         | 12 ++++++
 heatshrink/files/CMakeLists.txt  | 93 ++++++++++++++++++++++++++++++++++++++++
 heatshrink/files/Config.cmake.in |  5 +++
 6 files changed, 126 insertions(+), 8 deletions(-)

diffs:
diff --git a/heatshrink/DESCR b/heatshrink/DESCR
index 4f5b6d0968..62bdfcc15f 100644
--- a/heatshrink/DESCR
+++ b/heatshrink/DESCR
@@ -1,3 +1,3 @@
 heatshrink is a data compression/decompression library for embedded/real-time
-systems witrh memory usage as low as 50 bytes, incremental, bouded CPU use,
+systems with memory usage as low as 50 bytes, incremental, bouded CPU use,
 static or dynamic memory allocation and released under the ISC license.
diff --git a/heatshrink/Makefile b/heatshrink/Makefile
index 1d20b246c6..e12e6c97c6 100644
--- a/heatshrink/Makefile
+++ b/heatshrink/Makefile
@@ -11,7 +11,11 @@ HOMEPAGE=	https://github.com/atomicobject/heatshrink
 COMMENT=	Data compression library for embedded/real-time systems
 LICENSE=	isc
 
-USE_TOOLS+=		gmake
+USE_CMAKE=		yes
+USE_TOOLS+=		cmake gmake
 INSTALLATION_DIRS+=	bin include lib
 
+post-extract:
+	${CP} ${FILESDIR}/CMakeLists.txt ${FILESDIR}/Config.cmake.in ${WRKSRC}/
+
 .include "../../mk/bsd.pkg.mk"
diff --git a/heatshrink/PLIST b/heatshrink/PLIST
index b34c123154..ab70e38e7f 100644
--- a/heatshrink/PLIST
+++ b/heatshrink/PLIST
@@ -1,8 +1,12 @@
 @comment $NetBSD$
 bin/heatshrink
-include/heatshrink_common.h
-include/heatshrink_config.h
-include/heatshrink_decoder.h
-include/heatshrink_encoder.h
-lib/libheatshrink_dynamic.a
-lib/libheatshrink_static.a
+include/heatshrink/heatshrink_common.h
+include/heatshrink/heatshrink_config.h
+include/heatshrink/heatshrink_decoder.h
+include/heatshrink/heatshrink_encoder.h
+lib/cmake/heatshrink/heatshrinkConfig.cmake
+lib/cmake/heatshrink/heatshrinkConfigVersion.cmake
+lib/cmake/heatshrink/heatshrinkTargets-noconfig.cmake
+lib/cmake/heatshrink/heatshrinkTargets.cmake
+lib/libheatshrink.a
+lib/libheatshrink_dynalloc.a
diff --git a/heatshrink/buildlink3.mk b/heatshrink/buildlink3.mk
new file mode 100644
index 0000000000..5145dbdcb2
--- /dev/null
+++ b/heatshrink/buildlink3.mk
@@ -0,0 +1,12 @@
+# $NetBSD$
+
+BUILDLINK_TREE+=	heatshrink
+
+.if !defined(HEATSHRINK_BUILDLINK3_MK)
+HEATSHRINK_BUILDLINK3_MK:=
+
+BUILDLINK_API_DEPENDS.heatshrink+=	heatshrink>=0.4.0
+BUILDLINK_PKGSRCDIR.heatshrink?=	../../wip/heatshrink
+.endif	# HEATSHRINK_BUILDLINK3_MK
+
+BUILDLINK_TREE+=	-heatshrink
diff --git a/heatshrink/files/CMakeLists.txt b/heatshrink/files/CMakeLists.txt
new file mode 100644
index 0000000000..f304a48959
--- /dev/null
+++ b/heatshrink/files/CMakeLists.txt
@@ -0,0 +1,93 @@
+cmake_minimum_required(VERSION 3.10)
+
+project(heatshrink LANGUAGES C VERSION 0.4.1)
+
+set(CMAKE_C_STANDARD 99)
+set(CMAKE_C_STANDARD_REQUIRED ON)
+set(CMAKE_WINDOWS_EXPORT_ALL_SYMBOLS ON)
+
+add_library(${PROJECT_NAME} heatshrink_decoder.c heatshrink_encoder.c)
+add_library(${PROJECT_NAME}_dynalloc heatshrink_decoder.c heatshrink_encoder.c)
+
+find_library(MATH_LIBRARY m) # Business as usual
+if(MATH_LIBRARY)
+    target_link_libraries(${PROJECT_NAME} PUBLIC ${MATH_LIBRARY})
+endif()
+
+target_include_directories(${PROJECT_NAME} PUBLIC $<INSTALL_INTERFACE:include>)
+target_include_directories(${PROJECT_NAME}_dynalloc PUBLIC $<INSTALL_INTERFACE:include>)
+
+target_compile_definitions(${PROJECT_NAME} PUBLIC HEATSHRINK_DYNAMIC_ALLOC=0)
+target_compile_definitions(${PROJECT_NAME}_dynalloc PUBLIC HEATSHRINK_DYNAMIC_ALLOC=1)
+
+if (UNIX)
+  add_executable(${PROJECT_NAME}_cmd heatshrink.c)
+  target_link_libraries(${PROJECT_NAME}_cmd ${PROJECT_NAME}_dynalloc)
+  set_target_properties(${PROJECT_NAME}_cmd PROPERTIES OUTPUT_NAME ${PROJECT_NAME})
+endif ()
+
+foreach (tgt ${PROJECT_NAME} ${PROJECT_NAME}_dynalloc)
+  set_target_properties(${tgt}
+    PROPERTIES
+    VERSION ${PROJECT_VERSION}
+    SOVERSION ${PROJECT_VERSION})
+endforeach()
+
+# Installation and export:
+
+include(CMakePackageConfigHelpers)
+
+write_basic_package_version_file(
+    "${CMAKE_CURRENT_BINARY_DIR}/${PROJECT_NAME}ConfigVersion.cmake"
+    VERSION ${PROJECT_VERSION}
+    COMPATIBILITY AnyNewerVersion
+)
+
+set(_exported_targets ${PROJECT_NAME} ${PROJECT_NAME}_dynalloc)
+if (UNIX)
+  list(APPEND _exported_targets ${PROJECT_NAME}_cmd)
+endif ()
+
+install(TARGETS ${_exported_targets}
+        EXPORT ${PROJECT_NAME}Targets
+)
+
+export(EXPORT ${PROJECT_NAME}Targets 
+       FILE "${CMAKE_CURRENT_BINARY_DIR}/${PROJECT_NAME}Targets.cmake" 
+       NAMESPACE ${PROJECT_NAME}::
+)
+
+include(GNUInstallDirs)
+set(ConfigPackageLocation ${CMAKE_INSTALL_LIBDIR}/cmake/${PROJECT_NAME})
+
+configure_package_config_file(${CMAKE_CURRENT_SOURCE_DIR}/Config.cmake.in
+  "${CMAKE_CURRENT_BINARY_DIR}/${PROJECT_NAME}Config.cmake"
+  INSTALL_DESTINATION ${ConfigPackageLocation}
+)
+
+install(
+    FILES
+      heatshrink_common.h
+      heatshrink_config.h
+      heatshrink_encoder.h
+      heatshrink_decoder.h
+    DESTINATION
+      include/${PROJECT_NAME}
+  )
+
+install(EXPORT ${PROJECT_NAME}Targets
+  FILE
+    ${PROJECT_NAME}Targets.cmake
+  NAMESPACE
+    ${PROJECT_NAME}::
+  DESTINATION
+    ${ConfigPackageLocation}
+)
+
+install(
+  FILES
+    "${CMAKE_CURRENT_BINARY_DIR}/${PROJECT_NAME}Config.cmake"
+    "${CMAKE_CURRENT_BINARY_DIR}/${PROJECT_NAME}ConfigVersion.cmake"
+  DESTINATION
+    ${ConfigPackageLocation}
+)
\ No newline at end of file
diff --git a/heatshrink/files/Config.cmake.in b/heatshrink/files/Config.cmake.in
new file mode 100644
index 0000000000..7ace8c5c1d
--- /dev/null
+++ b/heatshrink/files/Config.cmake.in
@@ -0,0 +1,5 @@
+@PACKAGE_INIT@
+
+if (EXISTS ${CMAKE_CURRENT_LIST_DIR}/@PROJECT_NAME@Targets.cmake)
+    include("${CMAKE_CURRENT_LIST_DIR}/@PROJECT_NAME@Targets.cmake")
+endif ()
\ No newline at end of file


Home | Main Index | Thread Index | Old Index