diff --git a/eclass/ecm.eclass b/eclass/ecm.eclass index 2ca2b3a9e5..78a28adda2 100644 --- a/eclass/ecm.eclass +++ b/eclass/ecm.eclass @@ -595,6 +595,18 @@ ecm_src_prepare() { fi } +# @FUNCTION: _ecm_handbook_optional +# @DESCRIPTION: +# Use with ECM_HANDBOOK=optional; ticks either -DBUILD_DOC if available, +# or -DCMAKE_DISABLE_FIND_PACKAGE_KF${_KFSLOT}DocTools +_ecm_handbook_optional() { + if grep -Eq "option.*BUILD_DOC" CMakeLists.txt; then + echo "-DBUILD_DOC=$(usex handbook)" + else + echo "-DCMAKE_DISABLE_FIND_PACKAGE_KF${_KFSLOT}DocTools=$(usex !handbook)" + fi +} + # @FUNCTION: ecm_src_configure # @DESCRIPTION: # Wrapper for cmake_src_configure with extra logic for magic handling of @@ -621,7 +633,7 @@ ecm_src_configure() { fi if [[ ${ECM_HANDBOOK} = optional ]] ; then - cmakeargs+=( -DCMAKE_DISABLE_FIND_PACKAGE_KF${_KFSLOT}DocTools=$(usex !handbook) ) + cmakeargs+=( $(_ecm_handbook_optional) ) fi if in_iuse designer && [[ ${ECM_DESIGNERPLUGIN} = true ]]; then