aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGregory M. Turner <gmt@be-evil.net>2013-10-07 21:17:53 -0700
committerGregory M. Turner <gmt@be-evil.net>2013-10-07 21:17:53 -0700
commitb866d9e7842b481f15790f34b06e6da461d48eca (patch)
tree2eaf72c51088d65f79a67e1cdc8a87ad57375024 /eclass/cmake-utils.eclass
parenteclass/cmake-{multilib,utils}.eclass: clone upstream (diff)
downloadgmt-b866d9e7842b481f15790f34b06e6da461d48eca.tar.gz
gmt-b866d9e7842b481f15790f34b06e6da461d48eca.tar.bz2
gmt-b866d9e7842b481f15790f34b06e6da461d48eca.zip
eclass/cmake-{utils,multilib}: various backward-compatible enhancements
This adds several minor features to the cmake framework which add up to a great simplification of porting ebuilds to multilib: PKG_CONFIG_LIBDIR is injected into the cmake-exported configure-time environment if present and non-empty during configure. This resolves all kinds of broken lib-paths and resulting link-time disasters in one easy "fell swoop". ehooks for cmake-multilib debug-printing and pretty-printed arrays for meaningful output of configure arguments potentially containing spaces configure-time @GET_LIBDIR@ substitution Signed-off-by: Gregory M. Turner <gmt@be-evil.net>
Diffstat (limited to 'eclass/cmake-utils.eclass')
-rw-r--r--eclass/cmake-utils.eclass56
1 files changed, 54 insertions, 2 deletions
diff --git a/eclass/cmake-utils.eclass b/eclass/cmake-utils.eclass
index 9e9206d..fd83af9 100644
--- a/eclass/cmake-utils.eclass
+++ b/eclass/cmake-utils.eclass
@@ -101,6 +101,33 @@ CMAKEDEPEND+=" userland_GNU? ( >=sys-apps/findutils-4.4.0 )"
DEPEND="${CMAKEDEPEND}"
unset CMAKEDEPEND
+# pretty printer for configure-type arguments
+cmake-utils_my_god_its_full_of_quotation_marks() {
+ local foo bar
+ for foo in "$@" ; do
+ bar="${bar}${bar:+ }"
+ case $foo in
+ "")
+ bar="${bar}\"\""
+ ;;
+ *\ *=*)
+ # jesus, wtf
+ bar="${bar}\"${foo}\""
+ ;;
+ *=*)
+ bar="${bar}${foo%%=*}=\"${foo#*=}\""
+ ;;
+ *\ *)
+ bar="${bar}\"${foo}\""
+ ;;
+ *)
+ bar="${bar}${foo}"
+ ;;
+ esac
+ done
+ echo "${bar}"
+}
+
# Internal functions used by cmake-utils_use_*
_use_me_now() {
debug-print-function ${FUNCNAME} "$@"
@@ -470,6 +497,16 @@ enable_cmake-utils_src_configure() {
_EOF_
[[ "${NOCOLOR}" = true || "${NOCOLOR}" = yes ]] && echo 'SET (CMAKE_COLOR_MAKEFILE OFF CACHE BOOL "pretty colors during make" FORCE)' >> "${common_config}"
+ # For reasons I can't fathom (too new feature?) cmake does not at all respect
+ # PKG_CONFIG_LIBDIR from the ebuild environment. Shove it down cmakes' throat.
+ # Hopefully at least PKG_CONFIG_PATH is respected (but if not, here would be a
+ # fine place to add it following the same pattern as below).
+ # Note that there's no "caching" of environment variables such as this --
+ # the variable dies at compile-time, but by then hopefully pkg-config has
+ # worked it's magic and all is well in the universe.
+ [[ -n ${PKG_CONFIG_LIBDIR} ]] && \
+ echo "SET (ENV{PKG_CONFIG_LIBDIR} \"${PKG_CONFIG_LIBDIR}\")" >> ${common_config}
+
# Convert mycmakeargs to an array, for backwards compatibility
# Make the array a local variable since <=portage-2.1.6.x does not
# support global arrays (see bug #297255).
@@ -500,9 +537,24 @@ enable_cmake-utils_src_configure() {
"${MYCMAKEARGS}"
)
+ # do any libdir substitution here at the last possible moment
+ local oldcmakearg newcmakearg
+ declare -a scratchargs=( )
+ for oldcmakearg in "${cmakeargs[@]}" ; do
+ newcmakearg=$(get_libdir_subst "${oldcmakearg}")
+ [[ ${oldcmakearg} != ${newcmakearg} ]] && \
+ einfo "Substituted cmake argument \"${newcmakearg}\" for \"${oldcmakearg}\" (ABI=${ABI})"
+ scratchargs+=("${newcmakearg}")
+ done
+ cmakeargs=("${scratchargs[@]}")
+ unset scratchargs
+
pushd "${BUILD_DIR}" > /dev/null
- debug-print "${LINENO} ${ECLASS} ${FUNCNAME}: mycmakeargs is ${mycmakeargs_local[*]}"
- echo "${CMAKE_BINARY}" "${cmakeargs[@]}" "${CMAKE_USE_DIR}"
+ debug-print "${LINENO} ${ECLASS} ${FUNCNAME}: mycmakeargs is ($(
+ cmake-utils_my_god_its_full_of_quotation_marks "${mycmakeargs_local[*]}" ))"
+ einfo "From $(pwd): running ${CMAKE_BINARY} $(
+ cmake-utils_my_god_its_full_of_quotation_marks "${cmakeargs[@]}" "${CMAKE_USE_DIR}"
+ )"
"${CMAKE_BINARY}" "${cmakeargs[@]}" "${CMAKE_USE_DIR}" || die "cmake failed"
popd > /dev/null
}