Saturday, February 27, 2021

cmake.port.mk cmake-configure-args improvement

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.

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