Sunday, February 28, 2021

Re: cmake.port.mk cmake-configure-args improvement

On Sat, Feb 27, 2021 at 09:43:15AM +0100, Rafael Sadowski wrote:
> Before I push it into a bulk build I would like to know what you guys
> think. In some places we have such a workaround to help CMake to use the
> needed FLAGS or compiler.
>
> FreeBSD does something similar and I was inspired by it.
>
> -DTHREADS_HAVE_PTHREAD_ARG: This causes cmake to add -pthread to the
> depends list in stead of -lpthread.

This looks good to me, in fact I just stole a little bit of it to coerce
some port to use LDFLAGS.

Of course, it will require a full bulk.

I think some of it would like some comments, specifically
-DTHREADS_HAVE_PTHREAD_ARG

probably the style ought to be more of

# comment for some args
_MODCMAKE_ARGS += args \
more args

# comment for more args
_MODCMAKE_ARGS += more args \
more args

...

in any case, it should start with
_MODCMAKE_ARG =

not +=

> Index: cmake.port.mk
> ===================================================================
> RCS file: /cvs/ports/devel/cmake/cmake.port.mk,v
> retrieving revision 1.70
> diff -u -p -r1.70 cmake.port.mk
> --- cmake.port.mk 23 Nov 2020 18:35:03 -0000 1.70
> +++ cmake.port.mk 27 Feb 2021 08:33:48 -0000
> @@ -98,12 +98,26 @@ MODCMAKE_DEBUG ?= No
> .if empty(CONFIGURE_STYLE)
> CONFIGURE_STYLE = cmake
> .endif
> +
> +_MODCMAKE_ARGS += -DCMAKE_C_COMPILER="${CC}" \
> + -DCMAKE_CXX_COMPILER="${CXX}" \
> + -DCMAKE_C_FLAGS="${CFLAGS}" \
> + -DCMAKE_C_FLAGS_DEBUG="${CFLAGS}" \
> + -DCMAKE_C_FLAGS_RELEASE="${CFLAGS}" \
> + -DCMAKE_CXX_FLAGS="${CXXFLAGS}" \
> + -DCMAKE_CXX_FLAGS_DEBUG="${CXXFLAGS}" \
> + -DCMAKE_CXX_FLAGS_RELEASE="${CXXFLAGS}" \
> + -DCMAKE_EXE_LINKER_FLAGS="${LDFLAGS}" \
> + -DCMAKE_MODULE_LINKER_FLAGS="${LDFLAGS}" \
> + -DCMAKE_SHARED_LINKER_FLAGS="${LDFLAGS}" \
> + -DTHREADS_HAVE_PTHREAD_ARG=ON \
> + -DCMAKE_INSTALL_RPATH_USE_LINK_PATH=ON \
> + -DCMAKE_VERBOSE_MAKEFILE=ON \
> + -DCMAKE_SKIP_INSTALL_ALL_DEPENDENCY=ON
> +
> MODCMAKE_configure = cd ${WRKBUILD} && ${SETENV} \
> - CC="${CC}" CFLAGS="${CFLAGS}" \
> - CXX="${CXX}" CXXFLAGS="${CXXFLAGS}" \
> ${CONFIGURE_ENV} ${LOCALBASE}/bin/cmake \
> - -DCMAKE_SKIP_INSTALL_ALL_DEPENDENCY=ON \
> - -G ${_MODCMAKE_GEN} ${CONFIGURE_ARGS} ${WRKSRC}
> + ${_MODCMAKE_ARGS} -G ${_MODCMAKE_GEN} ${CONFIGURE_ARGS} ${WRKSRC}
>
> .if !defined(CONFIGURE_ARGS) || ! ${CONFIGURE_ARGS:M*CMAKE_BUILD_TYPE*}
> . if ${MODCMAKE_DEBUG:L} == "yes"
>
>

No comments:

Post a Comment