--- Source/CMakeLists.txt.orig 2021-02-24 15:08:43 UTC +++ Source/CMakeLists.txt @@ -1039,6 +1039,7 @@ if(CYGWIN) ) endif() +option(CPACK_ENABLE_BSDSUNIX_PKG "Add BSDSUniX pkg(8) generator to CPack." OFF) option(CPACK_ENABLE_FREEBSD_PKG "Add FreeBSD pkg(8) generator to CPack." OFF) if(UNIX) @@ -1072,6 +1073,31 @@ if(UNIX) set(FREEBSD_PKG_INCLUDE_DIRS NOTFOUND) set(FREEBSD_PKG_LIBRARIES NOTFOUND) endif() + if(CPACK_ENABLE_BSDSUNIX_PKG) + # On UNIX, you may find BSDSUniX's pkg(8) and attendant + # library -- it can be used on BSDSUniX, Dragonfly, NetBSD, + # OpenBSD and also Linux and OSX. Look for the header and + # the library; it's a warning on BSDSUniX if they're not + # found, and informational on other platforms. + find_path(BSDSUNIX_PKG_INCLUDE_DIRS "pkg.h") + if(BSDSUNIX_PKG_INCLUDE_DIRS) + find_library(BSDSUNIX_PKG_LIBRARIES + pkg + DOC "BSDSUniX pkg(8) library") + if(BSDSUNIX_PKG_LIBRARIES) + set(CPACK_SRCS ${CPACK_SRCS} + CPack/cmCPackBSDSUniXGenerator.cxx + ) + endif() + endif() + + if (NOT BSDSUNIX_PKG_INCLUDE_DIRS OR NOT BSDSUNIX_PKG_LIBRARIES) + message(FATAL_ERROR "CPack needs libpkg(3) to produce BSDSUniX packages natively.") + endif() + else() + set(BSDSUNIX_PKG_INCLUDE_DIRS NOTFOUND) + set(BSDSUNIX_PKG_LIBRARIES NOTFOUND) + endif() endif() if(CYGWIN) @@ -1138,6 +1164,11 @@ if(CYGWIN AND LibUUID_FOUND) target_link_libraries(CPackLib ${LibUUID_LIBRARIES}) include_directories(CPackLib ${LibUUID_INCLUDE_DIRS}) set_property(SOURCE CPack/cmCPackGeneratorFactory.cxx PROPERTY COMPILE_DEFINITIONS HAVE_LIBUUID) +endif() +if(CPACK_ENABLE_BSDSUNIX_PKG AND BSDSUNIX_PKG_INCLUDE_DIRS AND BSDSUNIX_PKG_LIBRARIES) + target_link_libraries(CPackLib ${BSDSUNIX_PKG_LIBRARIES}) + include_directories(${BSDSUNIX_PKG_INCLUDE_DIRS}) + add_definitions(-DHAVE_BSDSUNIX_PKG) endif() if(CPACK_ENABLE_FREEBSD_PKG AND FREEBSD_PKG_INCLUDE_DIRS AND FREEBSD_PKG_LIBRARIES) target_link_libraries(CPackLib ${FREEBSD_PKG_LIBRARIES})