eclass/ros-catkin.eclass: Add CATKIN_IN_SOURCE_BUILD support.
authorAlexis Ballier <aballier@gentoo.org>
Thu, 2 Mar 2017 09:01:03 +0000 (10:01 +0100)
committerAlexis Ballier <aballier@gentoo.org>
Thu, 2 Mar 2017 09:17:01 +0000 (10:17 +0100)
eclass/ros-catkin.eclass

index 3daee77b56369b13035e3876ab4c4e2cb45cb300..b427e0861b828e762ea8fcf8bfd367aa5827e8cd 100644 (file)
@@ -32,6 +32,11 @@ EGIT_REPO_URI="${ROS_REPO_URI}"
 # Usually, a repository contains several packages, hence a typical value is:
 # ROS_SUBDIR=${PN}
 
+# @ECLASS-VARIABLE: CATKIN_IN_SOURCE_BUILD
+# @DEFAULT_UNSET
+# @DESCRIPTION:
+# Set to enable in-source build.
+
 SCM=""
 if [ "${PV#9999}" != "${PV}" ] ; then
        SCM="git-r3"
@@ -140,12 +145,18 @@ HOMEPAGE="http://wiki.ros.org/${PN}"
 # Calls cmake-utils_src_prepare (so that PATCHES array is handled there) and initialises the workspace
 # by installing a recursive CMakeLists.txt to handle bundles.
 ros-catkin_src_prepare() {
+       # If no multibuild, just use cmake IN_SOURCE support
+       [ -n "${CATKIN_IN_SOURCE_BUILD}" ] && [ -z "${CATKIN_DO_PYTHON_MULTIBUILD}" ] && export CMAKE_IN_SOURCE_BUILD=yes
+
        cmake-utils_src_prepare
 
        if [ ! -f "${S}/CMakeLists.txt" ] ; then
                catkin_init_workspace || die
        fi
 
+       # If python multibuild, copy the sources
+       [ -n "${CATKIN_IN_SOURCE_BUILD}" ] && [ -n "${CATKIN_DO_PYTHON_MULTIBUILD}" ] && python_copy_sources
+
        # Most packages require C++11 these days. Do it here, in src_prepare so that
        # ebuilds can override it in src_configure.
        append-cxxflags '-std=c++11'
@@ -163,6 +174,9 @@ ros-catkin_src_configure_internal() {
                        -DPYTHON_INSTALL_DIR="${sitedir#${EPREFIX}/usr/}"
                )
                python_export PYTHON_SCRIPTDIR
+               if [ -n "${CATKIN_IN_SOURCE_BUILD}" ] ; then
+                       export CMAKE_USE_DIR="${BUILD_DIR}"
+               fi
        fi
        cmake-utils_src_configure "${@}"
 }
@@ -206,6 +220,9 @@ ros-catkin_src_configure() {
 # Builds a catkin-based package.
 ros-catkin_src_compile() {
        if [ -n "${CATKIN_DO_PYTHON_MULTIBUILD}" ] ; then
+               if [ -n "${CATKIN_IN_SOURCE_BUILD}" ] ; then
+                       export CMAKE_USE_DIR="${BUILD_DIR}"
+               fi
                python_foreach_impl cmake-utils_src_compile "${@}"
        else
                cmake-utils_src_compile "${@}"
@@ -246,6 +263,9 @@ ros-catkin_src_test() {
 # Decorator around cmake-utils_src_install to ensure python scripts are properly handled w.r.t. python-exec2.
 ros-catkin_src_install_with_python() {
        python_export PYTHON_SCRIPTDIR
+       if [ -n "${CATKIN_IN_SOURCE_BUILD}" ] ; then
+               export CMAKE_USE_DIR="${BUILD_DIR}"
+       fi
        cmake-utils_src_install "${@}"
        if [ ! -f "${T}/.catkin_python_symlinks_generated" -a -d "${D}/${PYTHON_SCRIPTDIR}" ]; then
                dodir /usr/bin