[CMake] Re-configuration, ExternalProjects, etc.

Clifford Yapp cliffyapp at gmail.com
Wed Sep 29 14:09:46 EDT 2010


After working for a while at converting a project to CMake, I would
like to ask a question/suggest a feature for CMake.

The project I am working on (BRL-CAD) includes various external
libraries that it relies on on a subdirectory, with a variety of
options for enabling and disabling use of the local and system copies.
 One of my biggest challenges when expressing our build logic in CMake
was supporting the ability to "turn on" and "turn off" these third
party builds cleanly and robustly.  I have (more or less) managed to
get this working with macros (although I have yet to set it up for
MSVC - gulp), but I have a few quirks I'd like to ask for opinions on:

1. CMake has an extremely annoying habit of looking for libraries in
the CMAKE_INSTALL_PREFIX directory after it is defined and picking up
old versions of libraries from previous make install results in those
directories.  In order to get it not to do this I literally had to
force CMAKE_INSTALL_PREFIX to be empty in the Cache file, which
doesn't feel right.  I'd MUCH rather set some option that tells CMake
to not look for anything in the CMAKE_INSTALL_PREFIX directory (which
for BRL-CAD is often different from system paths) with any of it's
Find* commands. If this is supported I have yet to spot the option -
can anyone enlighten me?  Am I making some obvious mistake?  It seems
like a problem people would have had to solve before this, but maybe
I'm doing something wrong.

2.  Because ExternalProject_Add does a full build and install prior to
building other targets (which I think is fine) I sometimes put myself
in the annoying position of building the whole system, then realizing
I forgot to clean an old build out of the install directory prior to
performing the build.  Then I do the classic rm -rf to clear it, only
to realize I just wiped out all of my ExternalProject install results.
 This wouldn't be a problem, except I can't find a way to get the
build logic to check that the external projects are installed when
make install is run and re-do the install if necessary - they think
they're done because all steps were completed.  Admittedly this is a
minor annoyance, but if there is a way to avoid having to re-do  the
whole thing because I messed up clearing out the install directory
ahead of time I would be grateful :-)

3.  I'm in the process of writing CMake macros to replace things like
AC_HEADER_STDC, AC_HEADER_DIRENT, etc. - is there already a macro
package that defines CMAKE_HEADER_STDC and friends to replace these
common autoconf macros?

Cheers,
CY


More information about the CMake mailing list