diff --git a/Mk/Uses/cmake.mk b/Mk/Uses/cmake.mk index 26504eda516f..f467bc7f9dd5 100644 --- a/Mk/Uses/cmake.mk +++ b/Mk/Uses/cmake.mk @@ -1,201 +1,203 @@ # Provide support for CMake based projects # # Feature: cmake # Usage: USES=cmake or USES=cmake:ARGS # Valid ARGS: indirect, insource, noninja, run, testing # ARGS description: # indirect do not run cmake for configure step, only add build dependency. # This should be set only for ports which use other build systems, # e.g. pep517 or meson, but rely internally on cmake. # insource do not perform an out-of-source build # noninja do not use ninja instead of make # Setting this should be an exception, and hints to an issue # inside the ports build system. # A few corner cases never use ninja, and are handled, to reduce # the usage of 'noninja'.: # 1) fortran ports # 2) ports that set BUILD_- or INSTALL_WRKSRC to # something different than CONFIGURE_WRKSRC # run add a runtime dependency on cmake # testing add the test target based on ctest # Additionally, CMAKE_TESTING_ON, CMAKE_TESTING_OFF, CMAKE_TESTING_ARGS, CMAKE_TESTING_TARGET # can be defined to override the default values. # _internal Not to be used by any other ports than the ones created from the release-tarball of cmake # # # Additional variables that affect cmake behaviour: # # User defined variables: # CMAKE_NOCOLOR - Disable colour build output # Default: not set, unless BATCH or PACKAGE_BUILDING is defined # # Variables for ports: # CMAKE_ON Appends -D:bool=ON to the CMAKE_ARGS, # CMAKE_OFF Appends -D:bool=OFF to the CMAKE_ARGS. # CMAKE_ARGS - Arguments passed to cmake # Default: see below # Variables for ports which use cmake for configure # CMAKE_BUILD_TYPE - Type of build (cmake predefined build types). # Projects may have their own build profiles. # CMake supports the following types: Debug, # Release, RelWithDebInfo and MinSizeRel. # Debug and Release profiles respect system # CFLAGS, RelWithDebInfo and MinSizeRel will set # CFLAGS to "-O2 -g" and "-Os -DNDEBUG". # Default: Release, if neither WITH_DEBUG nor WITH_DEBUGINFO is set, # RelWithDebInfo, if WITH_DEBUGINFO is set, # Debug, if WITH_DEBUG is set. # CMAKE_SOURCE_PATH - Path to the source directory # Default: ${WRKSRC} # Variables for ports which use cmake for testing # CMAKE_TESTING_ARGS - Additional arguments passed to cmake on test target. # CMAKE_TESTING_ON Appends -D:bool=ON to the CMAKE_TESTING_ARGS. # Default: BUILD_TESTING # CMAKE_TESTING_OFF Appends -D:bool=OFF to the CMAKE_TESTING_ARGS. # Default: empty # CMAKE_TESTING_TARGET - Name of the test target. Default: test # # MAINTAINER: kde@FreeBSD.org .if !defined(_INCLUDE_USES_CMAKE_MK) _INCLUDE_USES_CMAKE_MK= yes _valid_ARGS= indirect insource noninja run testing _internal +# Reminder: devel/cmake-core, devel/cmake-doc, devel/cmake-gui, and devel/cmake-man +# are all affected by changing _CMAKE_VERSION. Please check each of these ports. _CMAKE_VERSION= 3.30.2 CMAKE_BIN= ${LOCALBASE}/bin/cmake # Sanity check . for arg in ${cmake_ARGS} . if empty(_valid_ARGS:M${arg}) IGNORE= Incorrect 'USES+= cmake:${cmake_ARGS}' usage: argument [${arg}] is not recognized . endif . endfor . if !empty(cmake_ARGS:M_internal) # _internal is intended only for devel/cmake-core MASTER_SITES?= https://github.com/Kitware/CMake/releases/download/v${DISTVERSION}/ \ https://www.cmake.org/files/v${DISTVERSION}/ . else BUILD_DEPENDS+= ${CMAKE_BIN}:devel/cmake-core . if !empty(cmake_ARGS:Mrun) RUN_DEPENDS+= ${CMAKE_BIN}:devel/cmake-core . endif . if defined(WITH_DEBUG) CMAKE_BUILD_TYPE?= Debug . elif defined(WITH_DEBUGINFO) CMAKE_BUILD_TYPE?= RelWithDebInfo . else CMAKE_BUILD_TYPE?= Release . endif #defined(WITH_DEBUG) CMAKE_ARGS+= -DCMAKE_C_COMPILER:STRING="${CC}" \ -DCMAKE_CXX_COMPILER:STRING="${CXX}" \ -DCMAKE_C_FLAGS:STRING="${CFLAGS}" \ -DCMAKE_C_FLAGS_DEBUG:STRING="${CFLAGS}" \ -DCMAKE_C_FLAGS_RELEASE:STRING="${CFLAGS} -DNDEBUG" \ -DCMAKE_CXX_FLAGS:STRING="${CXXFLAGS}" \ -DCMAKE_CXX_FLAGS_DEBUG:STRING="${CXXFLAGS}" \ -DCMAKE_CXX_FLAGS_RELEASE:STRING="${CXXFLAGS} -DNDEBUG" \ -DCMAKE_EXE_LINKER_FLAGS:STRING="${LDFLAGS}" \ -DCMAKE_MODULE_LINKER_FLAGS:STRING="${LDFLAGS}" \ -DCMAKE_SHARED_LINKER_FLAGS:STRING="${LDFLAGS}" \ -DCMAKE_INSTALL_PREFIX:PATH="${CMAKE_INSTALL_PREFIX}" \ -DCMAKE_AUTOGEN_PARALLEL:STRING="${MAKE_JOBS_NUMBER}" \ -DCMAKE_BUILD_TYPE:STRING="${CMAKE_BUILD_TYPE}" \ -DTHREADS_HAVE_PTHREAD_ARG:BOOL=YES \ -DCMAKE_INSTALL_RPATH_USE_LINK_PATH=YES \ -DCMAKE_VERBOSE_MAKEFILE:BOOL=ON \ -DFETCHCONTENT_FULLY_DISCONNECTED:BOOL=ON # Handle the option-like CMAKE_ON and CMAKE_OFF lists. . for _bool_kind in ON OFF . if defined(CMAKE_${_bool_kind}) CMAKE_ARGS+= ${CMAKE_${_bool_kind}:C/.*/-D&:BOOL=${_bool_kind}/} . endif . endfor CMAKE_INSTALL_PREFIX?= ${PREFIX} . if defined(BATCH) || defined(PACKAGE_BUILDING) CMAKE_NOCOLOR= yes . endif . if defined(CMAKE_NOCOLOR) CMAKE_ARGS+= -DCMAKE_COLOR_MAKEFILE:BOOL=OFF . endif . endif . if empty(cmake_ARGS:Mindirect) . if defined(STRIP) && ${STRIP} != "" && !defined(WITH_DEBUG) && !defined(WITH_DEBUGINFO) INSTALL_TARGET?= install/strip . endif . endif # Use cmake for configure stage and for testing . if empty(cmake_ARGS:M_internal) && empty(cmake_ARGS:Mindirect) PLIST_SUB+= CMAKE_BUILD_TYPE="${CMAKE_BUILD_TYPE:tl}" _CMAKE_MSG= "===> Performing in-source build" CMAKE_SOURCE_PATH?= ${WRKSRC} . if empty(cmake_ARGS:Minsource) _CMAKE_MSG= "===> Performing out-of-source build" CONFIGURE_WRKSRC= ${WRKDIR}/.build BUILD_WRKSRC?= ${CONFIGURE_WRKSRC} INSTALL_WRKSRC?= ${CONFIGURE_WRKSRC} TEST_WRKSRC?= ${CONFIGURE_WRKSRC} . endif # By default we use the ninja generator. # Except, if cmake:run is set (cmake not wanted as generator) # fortran is used, as the ninja-generator does not handle it. # or if CONFIGURE_WRKSRC does not match BUILD_WRKSRC or INSTALL_WRKSRC # as the build.ninja file won't be where ninja expects it. . if empty(cmake_ARGS:Mnoninja) && empty(cmake_ARGS:Mrun) && empty(USES:Mfortran) . if "${CONFIGURE_WRKSRC}" == "${BUILD_WRKSRC}" && "${CONFIGURE_WRKSRC}" == "${INSTALL_WRKSRC}" # USES=gmake sets MAKE_CMD and ninja.mk does too (it also messes with MAKEFILE and MAKE_CMD). . if ! empty(USES:Mgmake) BROKEN= USES=gmake is incompatible with cmake's ninja-generator (try cmake:noninja) . endif # USES=emacs appends EMACS= to MAKE_ARGS, which then get passed to ninja. # Since ninja doesn't support that kind of variable-setting on the command-line, # it errors out. . if ! empty(USES:Memacs) BROKEN= USES=emacs is incompatible with cmake's ninja-generator (try cmake:noninja) . endif . include "${USESDIR}/ninja.mk" . endif . endif . if !target(do-configure) do-configure: @${ECHO_MSG} ${_CMAKE_MSG} ${MKDIR} ${CONFIGURE_WRKSRC} @cd ${CONFIGURE_WRKSRC}; ${SETENVI} ${WRK_ENV} ${CONFIGURE_ENV} ${CMAKE_BIN} \ ${CMAKE_ARGS} ${CMAKE_SOURCE_PATH} . endif . if !target(do-test) && ${cmake_ARGS:Mtesting} CMAKE_TESTING_ON?= BUILD_TESTING CMAKE_TESTING_PARALLEL_LEVEL?= ${MAKE_JOBS_NUMBER} CMAKE_TESTING_TARGET?= test # Handle the option-like CMAKE_TESTING_ON and CMAKE_TESTING_OFF lists. . for _bool_kind in ON OFF . if defined(CMAKE_TESTING_${_bool_kind}) CMAKE_TESTING_ARGS+= ${CMAKE_TESTING_${_bool_kind}:C/.*/-D&:BOOL=${_bool_kind}/} . endif . endfor do-test: @cd ${BUILD_WRKSRC} && \ ${SETENVI} ${WRK_ENV} ${CONFIGURE_ENV} ${CMAKE_BIN} ${CMAKE_ARGS} ${CMAKE_TESTING_ARGS} ${CMAKE_SOURCE_PATH} && \ ${SETENVI} ${WRK_ENV} ${MAKE_ENV} ${MAKE_CMD} ${_MAKE_JOBS} ${MAKE_ARGS} ${ALL_TARGET} && \ ${SETENVI} ${WRK_ENV} ${TEST_ENV} CTEST_PARALLEL_LEVEL=${CMAKE_TESTING_PARALLEL_LEVEL} ${MAKE_CMD} ${MAKE_ARGS} ${CMAKE_TESTING_TARGET} . endif . endif .endif #!defined(_INCLUDE_USES_CMAKE_MK) diff --git a/devel/cmake-core/Makefile b/devel/cmake-core/Makefile index 9c2d40f285a0..2048f1a6092d 100644 --- a/devel/cmake-core/Makefile +++ b/devel/cmake-core/Makefile @@ -1,106 +1,100 @@ PORTNAME= cmake -# Remember to update devel/cmake-doc and devel/cmake-gui as well. DISTVERSION= ${_CMAKE_VERSION} CATEGORIES= devel PKGNAMESUFFIX= -core MAINTAINER= kde@FreeBSD.org COMMENT= Cross-platform Makefile generator WWW= https://www.cmake.org/ LICENSE= BSD3CLAUSE LICENSE_FILE= ${WRKSRC}/Copyright.txt LIB_DEPENDS= libexpat.so:textproc/expat2 \ libjsoncpp.so:devel/jsoncpp \ - libuv.so:devel/libuv \ - librhash.so:security/rhash + librhash.so:security/rhash \ + libuv.so:devel/libuv -USES= cmake:_internal compiler:c++11-lang cpe localbase ncurses ssl +USES= cmake:_internal compiler:c++17-lang cpe localbase ncurses ssl CPE_VENDOR= cmake_project HAS_CONFIGURE= yes +CONFIGURE_CMD= ${WRKSRC}/bootstrap +CONFIGURE_LOG= Bootstrap.cmk/cmake_bootstrap.log CONFIGURE_ARGS= --prefix=${PREFIX} \ --datadir="/${DATADIR_REL}" \ --docdir="/${DOCSDIR_REL}" \ + --init="${BUILD_WRKSRC}/InitialCache.cmake" \ + --parallel=${MAKE_JOBS_NUMBER} \ + --system-bzip2 \ --system-expat \ --system-jsoncpp \ - --system-zlib \ - --system-zstd \ - --system-bzip2 \ --system-liblzma \ --system-libarchive \ --system-librhash \ --system-libuv \ + --system-zlib \ + --system-zstd \ --no-system-cppdap \ --no-system-curl \ --no-system-nghttp2 \ - --parallel=${MAKE_JOBS_NUMBER} \ - --verbose \ - --init="${WRKSRC}/InitialCache.cmake" + --verbose .if defined(WITH_CCACHE_BUILD) CONFIGURE_ARGS+= --enable-ccache .endif CONFIGURE_ENV= MAKE=${MAKE} # Quick fix to enable build with non-base SSL (CFLAGS/LDFLAGS only) (PR: 274512) CFLAGS+= -I${OPENSSLINC} CXXFLAGS+= -D__BSD_VISIBLE LDFLAGS+= -L${OPENSSLLIB} +SUB_FILES= InitialCache.cmake + +BUILD_WRKSRC= ${WRKDIR}/.build +CONFIGURE_WRKSRC= ${BUILD_WRKSRC} +INSTALL_WRKSRC= ${BUILD_WRKSRC} + OPTIONS_DEFINE= DOCS CPACK OPTIONS_DEFAULT= CPACK OPTIONS_SUB= yes CPACK_DESC= Enable FreeBSD generator in CPack CPACK_LIB_DEPENDS= libpkg.so:${PKG_ORIGIN} - -# 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" - @${FIND} ${WRKSRC} -name "*.bak" -delete -o -name "*.orig" -delete - -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" +CPACK_SUB_LIST= CPACK_OPTION_VALUE="ON" +CPACK_SUB_LIST_OFF= CPACK_OPTION_VALUE="OFF" post-patch: @(${FIND} ${WRKSRC}/Modules -name "*.cmake" -print0; \ ${FIND} ${WRKSRC}/Tests -name "CMakeLists.txt" -print0 ) | \ - ${XARGS} -0 -n 100 ${REINPLACE_CMD} -e 's,/usr/local,${LOCALBASE},g; \ - s,/usr/X11R6,${LOCALBASE},g' - @${REINPLACE_CMD} -e 's,/usr/local,${LOCALBASE},g' \ + ${XARGS} -0 -n 100 ${REINPLACE_CMD} -e 's|/usr/local|${LOCALBASE}|g; \ + s|/usr/X11R6|${LOCALBASE}|g' + @${REINPLACE_CMD} -e 's|/usr/local|${LOCALBASE}|g' \ ${WRKSRC}/Source/cmLocalGenerator.cxx \ ${WRKSRC}/Source/CPack/cmCPackGenerator.cxx \ ${WRKSRC}/bootstrap - @${REINPLACE_CMD} -e 's,/opt/kde4,${PREFIX},g' \ - ${WRKSRC}/Modules/FindKDE4.cmake - @${REINPLACE_CMD} -e 's,/usr/include,${LOCALBASE}/include,' \ + @${REINPLACE_CMD} -e 's|_compiler=\"ccache|_compiler="${CCACHE_BIN}|g' \ + ${WRKSRC}/bootstrap + @${REINPLACE_CMD} -e 's|/usr/include|${LOCALBASE}/include|' \ ${WRKSRC}/Modules/FindDCMTK.cmake @${REINPLACE_CMD} -e 's|%%LOCALBASE%%|${LOCALBASE}|g' \ ${WRKSRC}/Modules/FindFLEX.cmake - @${REINPLACE_CMD} -e 's|_compiler=\"ccache|_compiler="${CCACHE_BIN}|g' \ - ${WRKSRC}/bootstrap + @${REINPLACE_CMD} -e 's|/opt/kde4|${PREFIX}|g' \ + ${WRKSRC}/Modules/FindKDE4.cmake # cmake-gui(1) is installed by devel/cmake-gui. Remove the man page's source to # prevent it from being built/installed by devel/cmake. - ${RM} ${WRKSRC}/Help/manual/cmake-gui.1.rst + @${RM} ${WRKSRC}/Help/manual/cmake-gui.1.rst + +pre-configure: + @${MKDIR} ${BUILD_WRKSRC} +# 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. + @${CP} ${WRKDIR}/InitialCache.cmake ${BUILD_WRKSRC} post-install: ${INSTALL_DATA} ${WRKSRC}/Auxiliary/cmake-mode.el ${STAGEDIR}${PREFIX}/share/emacs/site-lisp - # The .NoDartCoverage is supposed to suppress testing in the - # source directories, but gets accidentally installed. - @${FIND} ${STAGEDIR}${PREFIX} -name ".NoDartCoverage" -delete .include diff --git a/devel/cmake-core/files/InitialCache.cmake b/devel/cmake-core/files/InitialCache.cmake deleted file mode 100644 index 38e354586af1..000000000000 --- a/devel/cmake-core/files/InitialCache.cmake +++ /dev/null @@ -1,29 +0,0 @@ -# Disable CMake's tests while building. We are not interested in them when -# building packages/ports, and it may create problems if part of some -# dependencies are installed (for example, devel/qmake4 is installed, but -# devel/qt4-corelib is not). -# See https://mail.kde.org/pipermail/kde-freebsd/2013-July/015703.html -set(BUILD_TESTING OFF CACHE BOOL "Build the testing tree.") - -# Force CMake to look for base's liblzma, otherwise the configuration process -# will fail if archivers/lzmalib is installed, as CMake will try to use its -# liblzma.so. -# Note that this is necessary only for `make configure' to work, as liblzma is -# only ever used if CMake's bundled libarchive is being used. -set(LIBLZMA_INCLUDE_DIR "/usr/include" CACHE PATH - "Directory where LibLZMA headers are located.") -set(LIBLZMA_LIBRARY "/usr/lib/liblzma.so" CACHE PATH - "LibLZMA library to link against.") - -# 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/libarchive.so" CACHE PATH -@@CPACK_OPTION_COMMENT@@ "LibArchive library to link against.") - diff --git a/devel/cmake-core/files/InitialCache.cmake.in b/devel/cmake-core/files/InitialCache.cmake.in new file mode 100644 index 000000000000..7532a7832dc9 --- /dev/null +++ b/devel/cmake-core/files/InitialCache.cmake.in @@ -0,0 +1,17 @@ +# TODO: Add TEST option to enable regression tests. The tests require +# additional packages to be installed and a small amount of patching +# to account for our local changes. +set(BUILD_TESTING OFF CACHE BOOL "Build the testing tree.") + +# Toggled by the CPACK option. Set to ON by default. +set(CPACK_ENABLE_FREEBSD_PKG %%CPACK_OPTION_VALUE%% CACHE BOOL + "Enable pkg(8) generator in CPack") + +if(CPACK_ENABLE_FREEBSD_PKG) +# Use base libarchive instead of the ports or bundled version, because +# libpkg links against base. + set(LibArchive_INCLUDE_DIR "/usr/include" CACHE PATH + "Directory where LibArchive headers are located.") + set(LibArchive_LIBRARY "/usr/lib/libarchive.so" CACHE PATH + "LibArchive library to link against.") +endif(CPACK_ENABLE_FREEBSD_PKG)