cpack
authorMichael Wallner <mike@php.net>
Fri, 11 Dec 2020 21:13:58 +0000 (22:13 +0100)
committerMichael Wallner <mike@php.net>
Fri, 11 Dec 2020 21:13:58 +0000 (22:13 +0100)
CMakeLists.txt
CPack.txt
CPackDEB.txt [new file with mode: 0644]
CPackRPM.txt [new file with mode: 0644]

index d8217f0805c17e1e8447e691f99c0f1d018b2a11..57509844a83d0803348fc62df2a8227da921baf9 100644 (file)
@@ -11,6 +11,7 @@ project(libmemcached
         HOMEPAGE_URL "https://github.com/m6w6/libmemcached"
         DESCRIPTION "libmemcached, a C/C++ memcached client library"
         )
+set(PROJECT_CONTACT "Michael Wallner <mike@php.net>")
 
 set(CXX_STANDARD 11)
 set(CMAKE_POSITION_INDEPENDENT_CODE ON)
index 2e31163bbb2cbc69662bd0c319884185710f4f60..c39732923206e4baac96d8db3a3d64c61011842c 100644 (file)
--- a/CPack.txt
+++ b/CPack.txt
@@ -1,26 +1,15 @@
-# options
-
-# DEBs
-if(EXISTS /usr/bin/dpkg)
-    message(STATUS "Enabling Debian packages")
-    set(CPACK_BINARY_DEB ON)
-endif()
-
-# BSDs
-if(CMAKE_SYSTEM_NAME MATCHES BSD AND EXISTS CPackFreeBSD.txt)
-    message(STATUS "Enabling FreeBSD packages")
-    set(CPACK_BINARY_FREEBSD ON)
-    include(CPackFreeBSD.txt)
-endif()
-
-# RPMs
-if(EXISTS /usr/bin/dnf OR EXISTS /usr/bin/yum OR EXISTS /usr/bin/rpm-build)
-    message(STATUS "Enabling RPM packages")
-    set(CPACK_BINARY_RPM ON)
-endif()
-
-if (EXISTS CPackNSIS.txt)
-    include(CPackNSIS.txt)
+# default options
+
+macro(cpack_include_if GENERATOR)
+    message(STATUS "Checking ${GENERATOR} package configuration ...")
+    if(EXISTS ${CMAKE_SOURCE_DIR}/CPack${GENERATOR}.txt)
+        message(STATUS "  Sourcing ${CMAKE_SOURCE_DIR}/CPack${GENERATOR}.txt")
+        include(${CMAKE_SOURCE_DIR}/CPack${GENERATOR}.txt)
+    elseif(EXISTS ${CMAKE_BINARY_DIR}/CPack${GENERATOR}.txt)
+        message(STATUS "  Sourcing ${CMAKE_BINARY_DIR}/CPack${GENERATOR}.txt")
+        include(${CMAKE_BINARY_DIR}/CPack${GENERATOR}.txt)
+    endif()
+endmacro()
 
 # shell installer
 set(CPACK_BINARY_STGZ ${UNIX})
@@ -31,6 +20,8 @@ set(CPACK_BINARY_TGZ ${UNIX})
 set(CPACK_BINARY_TXZ 0)
 set(CPACK_BINARY_TZ 0)
 set(CPACK_BINARY_ZIP ${WIN32})
+set(CPACK_BINARY_NSIS ${WIN32})
+set(CPACK_BINARY_NUGET ${WIN32})
 
 # source archive
 set(CPACK_SOURCE_TBZ2 0)
@@ -39,6 +30,21 @@ set(CPACK_SOURCE_TXZ 0)
 set(CPACK_SOURCE_TZ 0)
 set(CPACK_SOURCE_ZIP ${WIN32})
 
+# DEBs
+if(EXISTS /usr/bin/dpkg)
+    cpack_include_if(DEB)
+endif()
+
+# BSDs
+if(CMAKE_SYSTEM_NAME MATCHES BSD)
+    cpack_include_if(BSD)
+endif()
+
+# RPMs
+if(EXISTS /usr/bin/dnf OR EXISTS /usr/bin/yum OR EXISTS /usr/bin/rpmbuild)
+    cpack_include_if(RPM)
+endif()
+
 # project internals
 set(CPACK_PACKAGE_VENDOR ${CMAKE_PROJECT_HOMEPAGE_URL})
 set(CPACK_PACKAGE_DESCRIPTION_FILE "${CMAKE_SOURCE_DIR}/README.md")
@@ -47,4 +53,5 @@ set(CPACK_PACKAGE_CHECKSUM SHA1)
 set(CPACK_RESOURCE_FILE_LICENSE "${CMAKE_SOURCE_DIR}/LICENSE")
 set(CPACK_RESOURCE_FILE_README "${CMAKE_SOURCE_DIR}/README.md")
 
+# keep last
 include(CPack)
diff --git a/CPackDEB.txt b/CPackDEB.txt
new file mode 100644 (file)
index 0000000..85668a1
--- /dev/null
@@ -0,0 +1,11 @@
+set(CPACK_BINARY_DEB ON)
+set(CPACK_PACKAGE_CONTACT "${PROJECT_CONTACT}")
+if(HAVE_LIBSASL)
+    string(APPEND CPACK_DEBIAN_PACKAGE_DEPENDS " libsasl2")
+endif()
+if(HAVE_TBB)
+    string(APPEND CPACK_DEBIAN_PACKAGE_DEPENDS " tbb")
+endif()
+if(HAVE_LIBEVENT)
+    string(APPEND CPACK_DEBIAN_PACKAGE_DEPENDS " libevent")
+endif()
diff --git a/CPackRPM.txt b/CPackRPM.txt
new file mode 100644 (file)
index 0000000..9c092cf
--- /dev/null
@@ -0,0 +1 @@
+set(CPACK_BINARY_RPM ON)