Commit 167a96f2 authored by adridg's avatar adridg
Browse files

Add support for USES=cmake:testing

CMake-based ports have a "standard" way of controlling whether
testing should be built, by passing -DBUILD_TESTING=ON at the
configure stage (with some footnotes). Add a :testing modifier
for USES=cmake that enables a boilerplate do-test target that
rebuilds with testing enabled, and then runs the tests.

Individual ports need to buy in to this explicitly (because
tests might not be non-destructive).

Submitted and explained well by yuri@

PR:		249024
Submitted by:	yuri
parent 2a8016cb
......@@ -4,7 +4,7 @@
#
# Feature: cmake
# Usage: USES=cmake or USES=cmake:ARGS
# Valid ARGS: insource, run, noninja
# Valid ARGS: insource, run, noninja, testing
# ARGS description:
# insource do not perform an out-of-source build
# noninja don't use ninja instead of make
......@@ -16,6 +16,9 @@
# 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.
#
#
# Additional variables that affect cmake behaviour:
......@@ -46,7 +49,7 @@
.if !defined(_INCLUDE_USES_CMAKE_MK)
_INCLUDE_USES_CMAKE_MK= yes
_valid_ARGS= insource run noninja
_valid_ARGS= insource run noninja testing
# Sanity check
.for arg in ${cmake_ARGS}
......@@ -140,4 +143,22 @@ do-configure:
@cd ${CONFIGURE_WRKSRC}; ${SETENV} ${CONFIGURE_ENV} ${CMAKE_BIN} ${CMAKE_ARGS} ${CMAKE_SOURCE_PATH}
.endif
.if !target(do-test) && ${cmake_ARGS:Mtesting}
CMAKE_TESTING_ON?= BUILD_TESTING
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} && \
${SETENV} ${CONFIGURE_ENV} ${CMAKE_BIN} ${CMAKE_ARGS} ${CMAKE_TESTING_ARGS} ${CMAKE_SOURCE_PATH} && \
${SETENV} ${MAKE_ENV} ${MAKE_CMD} ${MAKE_ARGS} ${ALL_TARGET} && \
${SETENV} ${MAKE_ENV} ${MAKE_CMD} ${MAKE_ARGS} ${CMAKE_TESTING_TARGET}
.endif
.endif #!defined(_INCLUDE_USES_CMAKE_MK)
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment