tech-pkg archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
Always do out-of-tree builds with CMake?
Hi,
The vast majority of projects I've seen in the wild which use CMake
state in their documentation to do something along the lines of:
$ mkdir build
$ cd build
$ cmake ..
I.e., they recommend doing an out-of-tree build.
In many cases you can get away with not needing to make that extra
'build' directory -- cmake.mk does this by default. But sometimes, you
simply can't. Out-of-tree builds are *required* in several instances.
My point is: this out-of-tree behavior is NOT what cmake.mk implements.
So here's a proposal: change 'USE_CMAKE=yes' to *always* do out-of-tree
builds.
Here's how it'd look at a high level:
- USE_CMAKE=yes would imply creating a new build directory at configure
time (default: "${WRKDIR}/build").
- CMAKE_ARG_PATH would default to ${WRKSRC} instead of '.'
Besides, it could be argued that this is what we *should* be doing
anyway, taking into consideration:
- it's how most upstream maintainers *want* you to do to build their
code
- Kitware's tutorials tell you do this [1]
- (I swear I've seen a document from Kitware that says out-of-tree
builds are more than a mere suggestion -- but I might have dreamed
it.)
And I can't imagine this change *in principle* to negatively affect our
existing CMake-based packages. Like, some CMake-based packages require
out-of-tree builds but I don't think there's such thing as one which
requires an *in-tree* build, see what I mean?
But maybe getting rid of all of those 'pre-configure:'s that we've added
to accommodate out-of-tree builds in the first place -- that might cause
a lot of trouble. Maybe not.
What do we think?
Charlotte
-----
[1] https://cmake.org/cmake/help/latest/guide/tutorial/A%20Basic%20Starting%20Point.html
Home |
Main Index |
Thread Index |
Old Index