Index: head/devel/cmake/Makefile =================================================================== --- head/devel/cmake/Makefile +++ head/devel/cmake/Makefile @@ -4,6 +4,7 @@ PORTNAME= cmake # Remember to update devel/cmake-doc and devel/cmake-gui as well. DISTVERSION= 3.11.4 +PORTREVISION= 1 CATEGORIES= devel MASTER_SITES= https://www.cmake.org/files/v${PORTVERSION:R}/ @@ -19,7 +20,7 @@ libuv.so:devel/libuv \ librhash.so:security/rhash -USES= compiler:c++11-lang libarchive ncurses +USES= compiler:c++11-lang ncurses HAS_CONFIGURE= yes CONFIGURE_ENV= MAKE=make @@ -28,9 +29,9 @@ --docdir="/${DOCSDIR_REL}" \ --system-libs \ --parallel=${MAKE_JOBS_NUMBER} \ - --init="${PATCHDIR}/InitialCache.cmake" + --init="${WRKSRC}/InitialCache.cmake" -OPTIONS_DEFINE= DOCS MANPAGES +OPTIONS_DEFINE= DOCS MANPAGES CPACK OPTIONS_DEFAULT=MANPAGES OPTIONS_SUB= yes @@ -38,6 +39,11 @@ MANPAGES_BUILD_DEPENDS= ${PYTHON_PKGNAMEPREFIX}sphinx>0:textproc/py-sphinx@${PY_FLAVOR} MANPAGES_CONFIGURE_ON= --sphinx-man +CPACK_DESC= Enable FreeBSD generator in CPack (experimental) +CPACK_LIB_DEPENDS= libpkg.so:ports-mgmt/pkg +CPACK_USES_OFF= libarchive +# When CPACK is on, uses base libarchive and won't pass stage-qa + CONFLICTS_INSTALL= cmake-modules-* .include @@ -45,6 +51,25 @@ .if defined(STRIP) && ${STRIP} != "" && !defined(WITH_DEBUG) INSTALL_TARGET= install/strip .endif + +# Before running configure, substitute in the values of options +# for the build. CMake's configure doesn't accept --with-foo +# or similar options: it expects them to be set in CMake-style +# syntax in the initial cache. +pre-configure: + @${CP} "${FILESDIR}/InitialCache.cmake" "${WRKSRC}/InitialCache.cmake" + +pre-configure-CPACK-on: + @${REINPLACE_CMD} \ + -e 's/@@CPACK_OPTION_VALUE@@/ON/' \ + -e 's/@@CPACK_OPTION_COMMENT@@//' \ + "${WRKSRC}/InitialCache.cmake" + +pre-configure-CPACK-off: + @${REINPLACE_CMD} \ + -e 's/@@CPACK_OPTION_VALUE@@/OFF/' \ + -e 's/@@CPACK_OPTION_COMMENT@@/# /' \ + "${WRKSRC}/InitialCache.cmake" post-patch: @(${FIND} ${WRKSRC}/Modules -name "*.cmake" -print0; \ Index: head/devel/cmake/files/InitialCache.cmake =================================================================== --- head/devel/cmake/files/InitialCache.cmake +++ head/devel/cmake/files/InitialCache.cmake @@ -15,5 +15,15 @@ set(LIBLZMA_LIBRARY "/usr/lib/liblzma.so" CACHE PATH "LibLZMA library to link against.") -# Don't even try -set(CPACK_ENABLE_FREEBSD_PKG OFF CACHE BOOL "Enable pkg(8) generator in CPack") +# Set (or not) by the CPACK option by replacing @@CPACK_OPTION_VALUE@@ +# with the value of the option itself. +# +set(CPACK_ENABLE_FREEBSD_PKG @@CPACK_OPTION_VALUE@@ CACHE BOOL "Enable pkg(8) generator in CPack") +# Use base libarchive instead of ports, because libpkg uses base +@@CPACK_OPTION_COMMENT@@set(LibArchive_INCLUDE_DIR "/usr/include" CACHE PATH +@@CPACK_OPTION_COMMENT@@ "Directory where LibArchive headers are located.") +# Hack to (a) prevent using either ports libarchive or the bundled version +# and (b) libpkg links to base libarchive. +@@CPACK_OPTION_COMMENT@@set(LibArchive_LIBRARY "/usr/lib/libthr.so;/usr/lib/libarchive.so" CACHE PATH +@@CPACK_OPTION_COMMENT@@ "LibArchive library to link against.") + Index: head/devel/cmake/files/patch-Source_CPack_cmCPackFreeBSDGenerator.cxx =================================================================== --- head/devel/cmake/files/patch-Source_CPack_cmCPackFreeBSDGenerator.cxx +++ head/devel/cmake/files/patch-Source_CPack_cmCPackFreeBSDGenerator.cxx @@ -0,0 +1,18 @@ +diff --git Source/CPack/cmCPackFreeBSDGenerator.cxx Source/CPack/cmCPackFreeBSDGenerator.cxx +index 91ae1a23f..a676302e7 100644 +--- Source/CPack/cmCPackFreeBSDGenerator.cxx ++++ Source/CPack/cmCPackFreeBSDGenerator.cxx +@@ -339,6 +339,13 @@ int cmCPackFreeBSDGenerator::PackageFiles() + + std::string output_dir = + cmSystemTools::CollapseCombinedPath(toplevel, "../"); ++ if (!pkg_initialized() && pkg_init(NULL, NULL) != EPKG_OK) ++ { ++ cmCPackLogger(cmCPackLog::LOG_ERROR, ++ "Can not initialize libpkg." << std::endl); ++ return 0; ++ } ++ + pkg_create_from_manifest(output_dir.c_str(), ::TXZ, toplevel.c_str(), + manifestname.c_str(), NULL); +