[CMake] Re-configuration, ExternalProjects, etc.
Pau Garcia i Quiles
pgquiles at elpauer.org
Thu Sep 30 15:25:20 EDT 2010
On Wed, Sep 29, 2010 at 8:09 PM, Clifford Yapp <cliffyapp at gmail.com> wrote:
> 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.
Have you tried to set CMAKE_FIND_ROOT_PATH? It works for all the find_* commands
find_library(
<VAR>
name | NAMES name1 [name2 ...]
[HINTS path1 [path2 ... ENV var]]
[PATHS path1 [path2 ... ENV var]]
[PATH_SUFFIXES suffix1 [suffix2 ...]]
[DOC "cache documentation string"]
[NO_DEFAULT_PATH]
[NO_CMAKE_ENVIRONMENT_PATH]
[NO_CMAKE_PATH]
[NO_SYSTEM_ENVIRONMENT_PATH]
[NO_CMAKE_SYSTEM_PATH]
[CMAKE_FIND_ROOT_PATH_BOTH |
ONLY_CMAKE_FIND_ROOT_PATH |
NO_CMAKE_FIND_ROOT_PATH]
)
[...]
The CMake variable CMAKE_FIND_ROOT_PATH specifies one or more
directories to be prepended to all other search directories. This
effectively "re-roots" the entire search under given locations. By
default it is empty. It is especially useful when cross-compiling to
point to the root directory of the target environment and CMake will
search there too. By default at first the directories listed in
CMAKE_FIND_ROOT_PATH and then the non-rooted directories will be
searched. The default behavior can be adjusted by setting
CMAKE_FIND_ROOT_PATH_MODE_LIBRARY. This behavior can be manually
overridden on a per-call basis. By using CMAKE_FIND_ROOT_PATH_BOTH
the search order will be as described above. If
NO_CMAKE_FIND_ROOT_PATH is used then CMAKE_FIND_ROOT_PATH will not be
used. If ONLY_CMAKE_FIND_ROOT_PATH is used then only the re-rooted
directories will be searched.
--
Pau Garcia i Quiles
http://www.elpauer.org
(Due to my workload, I may need 10 days to answer)
More information about the CMake
mailing list