Alternate build directory for CMake-based port?

Mojca Miklavec mojca.miklavec.lists at gmail.com
Thu Aug 23 07:45:24 PDT 2012


On Thu, Aug 23, 2012 at 4:39 PM, Kevin Reid wrote:
> I am interested in getting the GNU Radio ports (gnuradio-*) updated to the latest version. (Relevant ticket: <https://trac.macports.org/ticket/31475>. The maintainer has acknowledged the problem but no work has been done for 11 months.) I have not seriously attempted to work on portfiles before.
>
> GNU Radio 3.6.* has switched exclusively to a CMake-based build system. For the most part, I have been able to simply apply the cmake PortGroup and modify the configuration parameters to CMake style.
>
> However, GNU Radio also insists that the build directory be different from the source directory; the CMakeLists.txt file contains:
>
> if(${CMAKE_SOURCE_DIR} STREQUAL ${CMAKE_BINARY_DIR})
>     message(FATAL_ERROR "Prevented in-tree build. This is bad practice.")
> endif(${CMAKE_SOURCE_DIR} STREQUAL ${CMAKE_BINARY_DIR})
>
> I could of course patch out this condition, but that seems unnecessarily fragile if it even works. How can I tell MacPorts to use distinct source and build directories for a CMake-based port?
>
> The official build instructions are to do
>   (in gnuradio source)
>   mkdir build
>   cd build
>   cmake ../
>   make
> but since MacPorts takes care of these commands via its own infrastructure I don't know where to "just" insert a cd command and tweak the pathnames.

The "clhep" Portfile does that among others:

worksrcdir          ${version}/CLHEP

configure.dir       ${workpath}/build
build.dir           ${configure.dir}

post-extract {
    file mkdir ${configure.dir}
}

configure.post_args ${worksrcpath}

I don't claim that it's the proper way to do it, but it can serve as an example.

Mojca

PS: I would suggest to add out-of-the-box support for out-of-source
builds to CMake group.


More information about the macports-dev mailing list