public inbox for gentoo-dev@lists.gentoo.org
 help / color / mirror / Atom feed
* [gentoo-dev] [PATCH 1/4] cmake.eclass: Support EAPI-8
@ 2021-08-19 17:43 Andreas Sturmlechner
  2021-08-19 17:44 ` [gentoo-dev] [PATCH 2/4] cmake.eclass: Enforce CMAKE_REMOVE_MODULES_LIST be an array Andreas Sturmlechner
  2021-08-19 17:45 ` [gentoo-dev] [PATCH 4/4] cmake.eclass: Default CMAKE_BUILD_TYPE=RelWithDebInfo in EAPI 8 Andreas Sturmlechner
  0 siblings, 2 replies; 7+ messages in thread
From: Andreas Sturmlechner @ 2021-08-19 17:43 UTC (permalink / raw
  To: gentoo-dev

[-- Attachment #1: Type: text/plain, Size: 6902 bytes --]

Move supported EAPI check and EXPORT_FUNCTIONS on top.

Switch to using current working directory instead of ${S}
when initializing ${CMAKE_USE_DIR} and ${BUILD_DIR}.

Raise baseline cmake version to 3.20.

Bug: https://bugs.gentoo.org/704524
Thanks-to: Arfrever Frehtes Taifersar Arahesis <Arfrever@Apache.Org>
Signed-off-by: Andreas Sturmlechner <asturm@gentoo.org>
---
 eclass/cmake.eclass | 91 ++++++++++++++++++++++++++++++---------------
 1 file changed, 60 insertions(+), 31 deletions(-)

diff --git a/eclass/cmake.eclass b/eclass/cmake.eclass
index 4bd09459ea6..43635d0ddf7 100644
--- a/eclass/cmake.eclass
+++ b/eclass/cmake.eclass
@@ -9,7 +9,7 @@
 # Maciej Mrozowski <reavertm@gentoo.org>
 # (undisclosed contributors)
 # Original author: Zephyrus (zephyrus@mirach.it)
-# @SUPPORTED_EAPIS: 7
+# @SUPPORTED_EAPIS: 7 8
 # @BLURB: common ebuild functions for cmake-based packages
 # @DESCRIPTION:
 # The cmake eclass makes creating ebuilds for cmake-based packages much easier.
@@ -17,16 +17,25 @@
 # out-of-source builds (default), in-source builds and an implementation of the
 # well-known use_enable function for CMake.
 
+case ${EAPI} in
+	7|8) ;;
+	*) die "EAPI=${EAPI:-0} is not supported" ;;
+esac
+
+EXPORT_FUNCTIONS src_prepare src_configure src_compile src_test src_install
+
 if [[ -z ${_CMAKE_ECLASS} ]]; then
 _CMAKE_ECLASS=1
 
 # @ECLASS-VARIABLE: BUILD_DIR
+# @DEFAULT_UNSET
 # @DESCRIPTION:
 # Build directory where all cmake processed files should be generated.
 # For in-source build it's fixed to ${CMAKE_USE_DIR}.
 # For out-of-source build it can be overridden, by default it uses
-# ${WORKDIR}/${P}_build.
-: ${BUILD_DIR:=${WORKDIR}/${P}_build}
+# ${CMAKE_USE_DIR}_build (in EAPI-7: ${WORKDIR}/${P}_build).
+[[ ${EAPI} == 7 ]] && : ${BUILD_DIR:=${WORKDIR}/${P}_build}
+# EAPI-8: set inside _cmake_check_build_dir
 
 # @ECLASS-VARIABLE: CMAKE_BINARY
 # @DESCRIPTION:
@@ -58,16 +67,16 @@ _CMAKE_ECLASS=1
 
 # @ECLASS-VARIABLE: CMAKE_REMOVE_MODULES_LIST
 # @DESCRIPTION:
-# Array of CMake modules that will be removed in $S during src_prepare,
-# in order to force packages to use the system version.
-# Set to "none" to disable removing modules entirely.
+# Array of CMake modules that will be removed in ${CMAKE_USE_DIR}
+# (in EAPI-7: ${S}) during src_prepare, in order to force packages to use the
+# system version.  Set to empty to disable removing modules entirely.
 : ${CMAKE_REMOVE_MODULES_LIST:=FindBLAS FindLAPACK}
 
 # @ECLASS-VARIABLE: CMAKE_USE_DIR
 # @DESCRIPTION:
 # Sets the directory where we are working with cmake, for example when
 # application uses autotools and only one plugin needs to be done by cmake.
-# By default it uses ${S}.
+# By default it uses current working directory (in EAPI-7: ${S}).
 
 # @ECLASS-VARIABLE: CMAKE_VERBOSE
 # @DESCRIPTION:
@@ -93,19 +102,12 @@ _CMAKE_ECLASS=1
 # @USER_VARIABLE
 # @DEFAULT_UNSET
 # @DESCRIPTION:
-# After running cmake_src_prepare, sets ${S} to read-only. This is
-# a user flag and should under _no circumstances_ be set in the ebuild.
-# Helps in improving QA of build systems that write to source tree.
-
-case ${EAPI} in
-	7) ;;
-	*) die "EAPI=${EAPI:-0} is not supported" ;;
-esac
+# After running cmake_src_prepare, sets ${CMAKE_USE_DIR} (in EAPI-7: ${S}) to
+# read-only. This is a user flag and should under _no circumstances_ be set in
+# the ebuild. Helps in improving QA of build systems that write to source tree.
 
 inherit toolchain-funcs ninja-utils flag-o-matic multiprocessing xdg-utils
 
-EXPORT_FUNCTIONS src_prepare src_configure src_compile src_test src_install
-
 [[ ${CMAKE_MIN_VERSION} ]] && die "CMAKE_MIN_VERSION is banned; if necessary, set BDEPEND=\">=dev-util/cmake-${CMAKE_MIN_VERSION}\" directly"
 [[ ${CMAKE_BUILD_DIR} ]] && die "The ebuild must be migrated to BUILD_DIR"
 [[ ${CMAKE_REMOVE_MODULES} ]] && die "CMAKE_REMOVE_MODULES is banned, set CMAKE_REMOVE_MODULES_LIST=\"\" instead"
@@ -127,7 +129,7 @@ case ${CMAKE_MAKEFILE_GENERATOR} in
 esac
 
 if [[ ${PN} != cmake ]]; then
-	BDEPEND+=" dev-util/cmake"
+	BDEPEND+=" >=dev-util/cmake-3.20"
 fi
 
 # @FUNCTION: cmake_run_in
@@ -264,14 +266,22 @@ cmake-utils_useno() { _cmake_banned_func "" "$@" ; }
 # @DESCRIPTION:
 # Determine using IN or OUT source build
 _cmake_check_build_dir() {
-	: ${CMAKE_USE_DIR:=${S}}
+	if [[ ${EAPI} == 7 ]]; then
+		: ${CMAKE_USE_DIR:=${S}}
+	else
+		: ${CMAKE_USE_DIR:=${PWD}}
+	fi
 	if [[ -n ${CMAKE_IN_SOURCE_BUILD} ]]; then
 		# we build in source dir
 		BUILD_DIR="${CMAKE_USE_DIR}"
+	else
+		: ${BUILD_DIR:=${CMAKE_USE_DIR}_build}
 	fi
 
+	einfo "Source directory (CMAKE_USE_DIR): \"${CMAKE_USE_DIR}\""
+	einfo "Build directory  (BUILD_DIR):     \"${BUILD_DIR}\""
+
 	mkdir -p "${BUILD_DIR}" || die
-	einfo "Working in BUILD_DIR: \"$BUILD_DIR\""
 }
 
 # @FUNCTION: _cmake_modify-cmakelists
@@ -320,12 +330,14 @@ _cmake_modify-cmakelists() {
 cmake_src_prepare() {
 	debug-print-function ${FUNCNAME} "$@"
 
-	# FIXME: workaround from cmake-utils; use current working directory instead, bug #704524
-	# esp. test with 'special' pkgs like: app-arch/brotli, media-gfx/gmic, net-libs/quiche
-	pushd "${S}" > /dev/null || die
+	if [[ ${EAPI} == 7 ]]; then
+		pushd "${S}" > /dev/null || die # workaround from cmake-utils
+		# in EAPI-8, we use current working directory instead, bug #704524
+		# esp. test with 'special' pkgs like: app-arch/brotli, media-gfx/gmic, net-libs/quiche
+	fi
+	_cmake_check_build_dir
 
 	default_src_prepare
-	_cmake_check_build_dir
 
 	# check if CMakeLists.txt exist and if no then die
 	if [[ ! -e ${CMAKE_USE_DIR}/CMakeLists.txt ]] ; then
@@ -351,17 +363,28 @@ cmake_src_prepare() {
 
 	local name
 	for name in "${modules_list[@]}" ; do
-		find "${S}" -name ${name}.cmake -exec rm -v {} + || die
+		if [[ ${EAPI} == 7 ]]; then
+			find "${S}" -name ${name}.cmake -exec rm -v {} + || die
+		else
+			find -name "${name}.cmake" -exec rm -v {} + || die
+		fi
 	done
 
 	# Remove dangerous things.
 	_cmake_modify-cmakelists
 
-	popd > /dev/null || die
+	if [[ ${EAPI} == 7 ]]; then
+		popd > /dev/null || die
+	fi
 
-	# make ${S} read-only in order to detect broken build-systems
+	# Make ${CMAKE_USE_DIR} (in EAPI-7: ${S}) read-only in order to detect
+	# broken build systems.
 	if [[ ${CMAKE_QA_SRC_DIR_READONLY} && ! ${CMAKE_IN_SOURCE_BUILD} ]]; then
-		chmod -R a-w "${S}"
+		if [[ ${EAPI} == 7 ]]; then
+			chmod -R a-w "${S}"
+		else
+			chmod -R a-w "${CMAKE_USE_DIR}"
+		fi
 	fi
 
 	_CMAKE_SRC_PREPARE_HAS_RUN=1
@@ -657,9 +680,15 @@ cmake_src_install() {
 		die "died running ${CMAKE_MAKEFILE_GENERATOR} install"
 	popd > /dev/null || die
 
-	pushd "${S}" > /dev/null || die
-	einstalldocs
-	popd > /dev/null || die
+	if [[ ${EAPI} == 7 ]]; then
+		pushd "${S}" > /dev/null || die
+		einstalldocs
+		popd > /dev/null || die
+	else
+		pushd "${CMAKE_USE_DIR}" > /dev/null || die
+		einstalldocs
+		popd > /dev/null || die
+	fi
 }
 
 fi
-- 
2.33.0


[-- Attachment #2: This is a digitally signed message part. --]
[-- Type: application/pgp-signature, Size: 618 bytes --]

^ permalink raw reply related	[flat|nested] 7+ messages in thread

* [gentoo-dev] [PATCH 2/4] cmake.eclass: Enforce CMAKE_REMOVE_MODULES_LIST be an array
  2021-08-19 17:43 [gentoo-dev] [PATCH 1/4] cmake.eclass: Support EAPI-8 Andreas Sturmlechner
@ 2021-08-19 17:44 ` Andreas Sturmlechner
  2021-08-19 17:44   ` Andreas Sturmlechner
  2021-08-19 17:46   ` [gentoo-dev] [PATCH 3/4] cmake.eclass: Enable CMAKE_INSTALL_ALWAYS Andreas Sturmlechner
  2021-08-19 17:45 ` [gentoo-dev] [PATCH 4/4] cmake.eclass: Default CMAKE_BUILD_TYPE=RelWithDebInfo in EAPI 8 Andreas Sturmlechner
  1 sibling, 2 replies; 7+ messages in thread
From: Andreas Sturmlechner @ 2021-08-19 17:44 UTC (permalink / raw
  To: gentoo-dev

[-- Attachment #1: Type: text/plain, Size: 1858 bytes --]

Signed-off-by: Andreas Sturmlechner <asturm@gentoo.org>
---
 eclass/cmake.eclass | 26 +++++++++++++++++++-------
 1 file changed, 19 insertions(+), 7 deletions(-)

diff --git a/eclass/cmake.eclass b/eclass/cmake.eclass
index 43635d0ddf7..3c611071821 100644
--- a/eclass/cmake.eclass
+++ b/eclass/cmake.eclass
@@ -66,11 +66,23 @@ _CMAKE_ECLASS=1
 : ${CMAKE_MAKEFILE_GENERATOR:=ninja}
 
 # @ECLASS-VARIABLE: CMAKE_REMOVE_MODULES_LIST
+# @PRE_INHERIT
+# @DEFAULT_UNSET
 # @DESCRIPTION:
-# Array of CMake modules that will be removed in ${CMAKE_USE_DIR}
-# (in EAPI-7: ${S}) during src_prepare, in order to force packages to use the
-# system version.  Set to empty to disable removing modules entirely.
-: ${CMAKE_REMOVE_MODULES_LIST:=FindBLAS FindLAPACK}
+# Array of .cmake modules to be removed in ${CMAKE_USE_DIR} (in EAPI-7: ${S})
+# during src_prepare, in order to force packages to use the system version.
+# By default, contains "FindBLAS" and "FindLAPACK".
+# Set to empty to disable removing modules entirely.
+if [[ ${CMAKE_REMOVE_MODULES_LIST} ]]; then
+	if [[ ${EAPI} != 7 ]]; then
+		[[ ${CMAKE_REMOVE_MODULES_LIST@a} == *a* ]] ||
+			die "CMAKE_REMOVE_MODULES_LIST must be an array"
+	fi
+else
+	if ! [[ ${CMAKE_REMOVE_MODULES_LIST@a} == *a* && ${#CMAKE_REMOVE_MODULES_LIST[@]} -eq 0 ]]; then
+		CMAKE_REMOVE_MODULES_LIST=( FindBLAS FindLAPACK )
+	fi
+fi
 
 # @ECLASS-VARIABLE: CMAKE_USE_DIR
 # @DESCRIPTION:
@@ -355,10 +367,10 @@ cmake_src_prepare() {
 	fi
 
 	local modules_list
-	if [[ $(declare -p CMAKE_REMOVE_MODULES_LIST) == "declare -a"* ]]; then
-		modules_list=( "${CMAKE_REMOVE_MODULES_LIST[@]}" )
-	else
+	if [[ ${EAPI} == 7 && $(declare -p CMAKE_REMOVE_MODULES_LIST) != "declare -a"* ]]; then
 		modules_list=( ${CMAKE_REMOVE_MODULES_LIST} )
+	else
+		modules_list=( "${CMAKE_REMOVE_MODULES_LIST[@]}" )
 	fi
 
 	local name
-- 
2.33.0

[-- Attachment #2: This is a digitally signed message part. --]
[-- Type: application/pgp-signature, Size: 618 bytes --]

^ permalink raw reply related	[flat|nested] 7+ messages in thread

* Re: [gentoo-dev] [PATCH 2/4] cmake.eclass: Enforce CMAKE_REMOVE_MODULES_LIST be an array
  2021-08-19 17:44 ` [gentoo-dev] [PATCH 2/4] cmake.eclass: Enforce CMAKE_REMOVE_MODULES_LIST be an array Andreas Sturmlechner
@ 2021-08-19 17:44   ` Andreas Sturmlechner
  2021-08-19 17:46   ` [gentoo-dev] [PATCH 3/4] cmake.eclass: Enable CMAKE_INSTALL_ALWAYS Andreas Sturmlechner
  1 sibling, 0 replies; 7+ messages in thread
From: Andreas Sturmlechner @ 2021-08-19 17:44 UTC (permalink / raw
  To: gentoo-dev

[-- Attachment #1: Type: text/plain, Size: 806 bytes --]

[PATCH 3/4] cmake.eclass: Enable CMAKE_INSTALL_ALWAYS

Bug: https://bugs.gentoo.org/735820
Signed-off-by: Andreas Sturmlechner <asturm@gentoo.org>
---
 eclass/cmake.eclass | 5 +++++
 1 file changed, 5 insertions(+)

diff --git a/eclass/cmake.eclass b/eclass/cmake.eclass
index 3c611071821..8befd9e5a9f 100644
--- a/eclass/cmake.eclass
+++ b/eclass/cmake.eclass
@@ -537,6 +537,11 @@ cmake_src_configure() {
 		echo 'set(CMAKE_COLOR_MAKEFILE OFF CACHE BOOL "pretty colors during make" FORCE)' >> "${common_config}" || die
 	fi
 
+	# See bug 735820
+	if [[ ${EAPI} != 7 ]]; then
+		echo 'set(CMAKE_INSTALL_ALWAYS 1)' >> "${common_config}" || die
+	fi
+
 	# Wipe the default optimization flags out of CMake
 	if [[ ${CMAKE_BUILD_TYPE} != Gentoo ]]; then
 		cat >> ${common_config} <<- _EOF_ || die
-- 
2.33.0


[-- Attachment #2: This is a digitally signed message part. --]
[-- Type: application/pgp-signature, Size: 618 bytes --]

^ permalink raw reply related	[flat|nested] 7+ messages in thread

* [gentoo-dev] [PATCH 4/4] cmake.eclass: Default CMAKE_BUILD_TYPE=RelWithDebInfo in EAPI 8
  2021-08-19 17:43 [gentoo-dev] [PATCH 1/4] cmake.eclass: Support EAPI-8 Andreas Sturmlechner
  2021-08-19 17:44 ` [gentoo-dev] [PATCH 2/4] cmake.eclass: Enforce CMAKE_REMOVE_MODULES_LIST be an array Andreas Sturmlechner
@ 2021-08-19 17:45 ` Andreas Sturmlechner
  2021-08-20  7:46   ` Guilherme Amadio
  1 sibling, 1 reply; 7+ messages in thread
From: Andreas Sturmlechner @ 2021-08-19 17:45 UTC (permalink / raw
  To: gentoo-dev

[-- Attachment #1: Type: text/plain, Size: 1388 bytes --]

Signed-off-by: Michał Górny <mgorny@gentoo.org>
Signed-off-by: Andreas Sturmlechner <asturm@gentoo.org>
---
 eclass/cmake.eclass | 11 ++++++++---
 1 file changed, 8 insertions(+), 3 deletions(-)

diff --git a/eclass/cmake.eclass b/eclass/cmake.eclass
index 8befd9e5a9f..3021a3a2b1e 100644
--- a/eclass/cmake.eclass
+++ b/eclass/cmake.eclass
@@ -42,14 +42,19 @@ _CMAKE_ECLASS=1
 # Eclass can use different cmake binary than the one provided in by system.
 : ${CMAKE_BINARY:=cmake}
 
+[[ ${EAPI} == 7 ]] && : ${CMAKE_BUILD_TYPE:=Gentoo}
 # @ECLASS-VARIABLE: CMAKE_BUILD_TYPE
 # @DESCRIPTION:
 # Set to override default CMAKE_BUILD_TYPE. Only useful for packages
 # known to make use of "if (CMAKE_BUILD_TYPE MATCHES xxx)".
 # If about to be set - needs to be set before invoking cmake_src_configure.
-# You usually do *NOT* want nor need to set it as it pulls CMake default
-# build-type specific compiler flags overriding make.conf.
-: ${CMAKE_BUILD_TYPE:=Gentoo}
+#
+# The default is RelWithDebInfo as that is least likely to append undesirable
+# flags. However, you may still need to sed CMake files or choose a different
+# build type to achieve desirable results.
+#
+# In EAPI 7, the default was non-standard build type of Gentoo.
+: ${CMAKE_BUILD_TYPE:=RelWithDebInfo}
 
 # @ECLASS-VARIABLE: CMAKE_IN_SOURCE_BUILD
 # @DEFAULT_UNSET
-- 
2.33.0


[-- Attachment #2: This is a digitally signed message part. --]
[-- Type: application/pgp-signature, Size: 618 bytes --]

^ permalink raw reply related	[flat|nested] 7+ messages in thread

* [gentoo-dev] [PATCH 3/4] cmake.eclass: Enable CMAKE_INSTALL_ALWAYS
  2021-08-19 17:44 ` [gentoo-dev] [PATCH 2/4] cmake.eclass: Enforce CMAKE_REMOVE_MODULES_LIST be an array Andreas Sturmlechner
  2021-08-19 17:44   ` Andreas Sturmlechner
@ 2021-08-19 17:46   ` Andreas Sturmlechner
  1 sibling, 0 replies; 7+ messages in thread
From: Andreas Sturmlechner @ 2021-08-19 17:46 UTC (permalink / raw
  To: gentoo-dev

[-- Attachment #1: Type: text/plain, Size: 751 bytes --]

Bug: https://bugs.gentoo.org/735820
Signed-off-by: Andreas Sturmlechner <asturm@gentoo.org>
---
 eclass/cmake.eclass | 5 +++++
 1 file changed, 5 insertions(+)

diff --git a/eclass/cmake.eclass b/eclass/cmake.eclass
index 3c611071821..8befd9e5a9f 100644
--- a/eclass/cmake.eclass
+++ b/eclass/cmake.eclass
@@ -537,6 +537,11 @@ cmake_src_configure() {
 		echo 'set(CMAKE_COLOR_MAKEFILE OFF CACHE BOOL "pretty colors 
during make" FORCE)' >> "${common_config}" || die
 	fi
 
+	# See bug 735820
+	if [[ ${EAPI} != 7 ]]; then
+		echo 'set(CMAKE_INSTALL_ALWAYS 1)' >> "${common_config}" || die
+	fi
+
 	# Wipe the default optimization flags out of CMake
 	if [[ ${CMAKE_BUILD_TYPE} != Gentoo ]]; then
 		cat >> ${common_config} <<- _EOF_ || die
-- 
2.33.0

[-- Attachment #2: This is a digitally signed message part. --]
[-- Type: application/pgp-signature, Size: 618 bytes --]

^ permalink raw reply related	[flat|nested] 7+ messages in thread

* Re: [gentoo-dev] [PATCH 4/4] cmake.eclass: Default CMAKE_BUILD_TYPE=RelWithDebInfo in EAPI 8
  2021-08-19 17:45 ` [gentoo-dev] [PATCH 4/4] cmake.eclass: Default CMAKE_BUILD_TYPE=RelWithDebInfo in EAPI 8 Andreas Sturmlechner
@ 2021-08-20  7:46   ` Guilherme Amadio
  2021-08-20  8:10     ` Michał Górny
  0 siblings, 1 reply; 7+ messages in thread
From: Guilherme Amadio @ 2021-08-20  7:46 UTC (permalink / raw
  To: gentoo-dev

Hi,

On Thu, Aug 19, 2021 at 07:45:16PM +0200, Andreas Sturmlechner wrote:
> Signed-off-by: Michał Górny <mgorny@gentoo.org>
> Signed-off-by: Andreas Sturmlechner <asturm@gentoo.org>
> ---
>  eclass/cmake.eclass | 11 ++++++++---
>  1 file changed, 8 insertions(+), 3 deletions(-)
> 
> diff --git a/eclass/cmake.eclass b/eclass/cmake.eclass
> index 8befd9e5a9f..3021a3a2b1e 100644
> --- a/eclass/cmake.eclass
> +++ b/eclass/cmake.eclass
> @@ -42,14 +42,19 @@ _CMAKE_ECLASS=1
>  # Eclass can use different cmake binary than the one provided in by system.
>  : ${CMAKE_BINARY:=cmake}
>  
> +[[ ${EAPI} == 7 ]] && : ${CMAKE_BUILD_TYPE:=Gentoo}
>  # @ECLASS-VARIABLE: CMAKE_BUILD_TYPE
>  # @DESCRIPTION:
>  # Set to override default CMAKE_BUILD_TYPE. Only useful for packages
>  # known to make use of "if (CMAKE_BUILD_TYPE MATCHES xxx)".
>  # If about to be set - needs to be set before invoking cmake_src_configure.
> -# You usually do *NOT* want nor need to set it as it pulls CMake default
> -# build-type specific compiler flags overriding make.conf.
> -: ${CMAKE_BUILD_TYPE:=Gentoo}
> +#
> +# The default is RelWithDebInfo as that is least likely to append undesirable
> +# flags. However, you may still need to sed CMake files or choose a different
> +# build type to achieve desirable results.
> +#
> +# In EAPI 7, the default was non-standard build type of Gentoo.
> +: ${CMAKE_BUILD_TYPE:=RelWithDebInfo}

Although I think this is better than the "Gentoo" build type we had, I
think that even better is to just leave this blank and set a default on
a per-ebuild basis, as I commented on bug 802786[1]. Repeating my
comment from there, build type flags always come after CMAKE_<LANG>_FLAGS,
which then override make.conf settings. Moreover, setting a build type
can also have funny behavior with multi-config generators (possible with
ninja on Linux too now) because it has no meaning in that context. For
instance, this may override make.conf flags with "-O2 -g" in most cases,
preventing people from changing the optimization level of any CMake-based
package, or disabling compilation of debug info (which is then stripped
anyway). This is probably why we had the "Gentoo" build in the first place.

For ebuilds that must have a CMAKE_BUILD_TYPE set, we should probably
use Release and override CMAKE_<LANG>_FLAGS_RELEASE with settings from
make.conf, or make CMAKE_<LANG>_FLAGS contain settings from make.conf
and enforce CMAKE_<LANG>_FLAGS_<BUILD_TYPE> is empty for all build types.

Cheers,
-Guilherme

1. https://bugs.gentoo.org/802786

>  
>  # @ECLASS-VARIABLE: CMAKE_IN_SOURCE_BUILD
>  # @DEFAULT_UNSET
> -- 
> 2.33.0
> 




^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [gentoo-dev] [PATCH 4/4] cmake.eclass: Default CMAKE_BUILD_TYPE=RelWithDebInfo in EAPI 8
  2021-08-20  7:46   ` Guilherme Amadio
@ 2021-08-20  8:10     ` Michał Górny
  0 siblings, 0 replies; 7+ messages in thread
From: Michał Górny @ 2021-08-20  8:10 UTC (permalink / raw
  To: gentoo-dev

On Fri, 2021-08-20 at 09:46 +0200, Guilherme Amadio wrote:
> Hi,
> 
> On Thu, Aug 19, 2021 at 07:45:16PM +0200, Andreas Sturmlechner wrote:
> > Signed-off-by: Michał Górny <mgorny@gentoo.org>
> > Signed-off-by: Andreas Sturmlechner <asturm@gentoo.org>
> > ---
> >  eclass/cmake.eclass | 11 ++++++++---
> >  1 file changed, 8 insertions(+), 3 deletions(-)
> > 
> > diff --git a/eclass/cmake.eclass b/eclass/cmake.eclass
> > index 8befd9e5a9f..3021a3a2b1e 100644
> > --- a/eclass/cmake.eclass
> > +++ b/eclass/cmake.eclass
> > @@ -42,14 +42,19 @@ _CMAKE_ECLASS=1
> >  # Eclass can use different cmake binary than the one provided in by system.
> >  : ${CMAKE_BINARY:=cmake}
> >  
> > +[[ ${EAPI} == 7 ]] && : ${CMAKE_BUILD_TYPE:=Gentoo}
> >  # @ECLASS-VARIABLE: CMAKE_BUILD_TYPE
> >  # @DESCRIPTION:
> >  # Set to override default CMAKE_BUILD_TYPE. Only useful for packages
> >  # known to make use of "if (CMAKE_BUILD_TYPE MATCHES xxx)".
> >  # If about to be set - needs to be set before invoking cmake_src_configure.
> > -# You usually do *NOT* want nor need to set it as it pulls CMake default
> > -# build-type specific compiler flags overriding make.conf.
> > -: ${CMAKE_BUILD_TYPE:=Gentoo}
> > +#
> > +# The default is RelWithDebInfo as that is least likely to append undesirable
> > +# flags. However, you may still need to sed CMake files or choose a different
> > +# build type to achieve desirable results.
> > +#
> > +# In EAPI 7, the default was non-standard build type of Gentoo.
> > +: ${CMAKE_BUILD_TYPE:=RelWithDebInfo}
> 
> Although I think this is better than the "Gentoo" build type we had, I
> think that even better is to just leave this blank and set a default on
> a per-ebuild basis, as I commented on bug 802786[1]. Repeating my
> comment from there, build type flags always come after CMAKE_<LANG>_FLAGS,
> which then override make.conf settings. Moreover, setting a build type
> can also have funny behavior with multi-config generators (possible with
> ninja on Linux too now) because it has no meaning in that context. For
> instance, this may override make.conf flags with "-O2 -g" in most cases,
> preventing people from changing the optimization level of any CMake-based
> package, or disabling compilation of debug info (which is then stripped
> anyway). This is probably why we had the "Gentoo" build in the first place.
> 
> For ebuilds that must have a CMAKE_BUILD_TYPE set, we should probably
> use Release and override CMAKE_<LANG>_FLAGS_RELEASE with settings from
> make.conf, or make CMAKE_<LANG>_FLAGS contain settings from make.conf
> and enforce CMAKE_<LANG>_FLAGS_<BUILD_TYPE> is empty for all build types.
> 

No, we shouldn't.  Release often has unexpected side effects. 
RelWithDebInfo is the moderate type that is least likely to have side
effects.

The eclasses are stripping default build type flags since 2016.  Please
do some research and/or testing before posting.

-- 
Best regards,
Michał Górny




^ permalink raw reply	[flat|nested] 7+ messages in thread

end of thread, other threads:[~2021-08-20  8:10 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2021-08-19 17:43 [gentoo-dev] [PATCH 1/4] cmake.eclass: Support EAPI-8 Andreas Sturmlechner
2021-08-19 17:44 ` [gentoo-dev] [PATCH 2/4] cmake.eclass: Enforce CMAKE_REMOVE_MODULES_LIST be an array Andreas Sturmlechner
2021-08-19 17:44   ` Andreas Sturmlechner
2021-08-19 17:46   ` [gentoo-dev] [PATCH 3/4] cmake.eclass: Enable CMAKE_INSTALL_ALWAYS Andreas Sturmlechner
2021-08-19 17:45 ` [gentoo-dev] [PATCH 4/4] cmake.eclass: Default CMAKE_BUILD_TYPE=RelWithDebInfo in EAPI 8 Andreas Sturmlechner
2021-08-20  7:46   ` Guilherme Amadio
2021-08-20  8:10     ` Michał Górny

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox