[cmake-developers] Undocumented effect of CMAKE_INSTALL_PREFIX on find commands

Alan W. Irwin irwin at beluga.phys.uvic.ca
Fri Jun 14 15:35:37 EDT 2013


I have the qhull binary, header, and library
installed with an idiosyncratic prefix as a result of one build_projects
build:

/home/wine/newstart/build_script/install-linux_ninja/bin/qhull
/home/wine/newstart/build_script/install-linux_ninja/include/qhull/qhull_a.h
/home/wine/newstart/build_script/install-linux_ninja/lib/libqhull.so

If one attempts to find that binary, header and library using the following simple
test project:

project(test_find NONE)
cmake_minimum_required(VERSION 2.8.10.2)

find_program(QHULL_EXECUTABLE qhull)
find_path(QHULL_INCLUDE_DIR qhull/qhull_a.h)
find_library(QHULL_LIBRARY NAMES qhull)

message(STATUS "QHULL_EXECUTABLE = ${QHULL_EXECUTABLE}")
message(STATUS "QHULL_INCLUDE_DIR = ${QHULL_INCLUDE_DIR}")
message(STATUS "QHULL_LIBRARY = ${QHULL_LIBRARY}")

those finds ordinarily fail because of the idiosyncratic install
prefix. However, much to my surprise (and pleasure) if I specify
CMAKE_INSTALL_PREFIX they succeed:

wine at raven> cmake \
-DCMAKE_INSTALL_PREFIX:PATH=/home/wine/newstart/build_script/install-linux_ninja \
..
-- QHULL_EXECUTABLE = /home/wine/newstart/build_script/install-linux_ninja/bin/qhull
-- QHULL_INCLUDE_DIR = /home/wine/newstart/build_script/install-linux_ninja/include
-- QHULL_LIBRARY = /home/wine/newstart/build_script/install-linux_ninja/lib/libqhull.so
-- Configuring done
-- Generating done
-- Build files have been written to: /home/wine/newstart/test_find_path/build_dir

I discovered this undocumented behaviour by accident with the
build_projects project (where all builds have a common install
prefix specified by CMAKE_INSTALL_PREFIX).

If this behaviour is to be relied upon (which I hope is the case)
it should be documented.

Alan
__________________________
Alan W. Irwin

Astronomical research affiliation with Department of Physics and Astronomy,
University of Victoria (astrowww.phys.uvic.ca).

Programming affiliations with the FreeEOS equation-of-state
implementation for stellar interiors (freeeos.sf.net); the Time
Ephemerides project (timeephem.sf.net); PLplot scientific plotting
software package (plplot.sf.net); the libLASi project
(unifont.org/lasi); the Loads of Linux Links project (loll.sf.net);
and the Linux Brochure Project (lbproject.sf.net).
__________________________

Linux-powered Science
__________________________



More information about the cmake-developers mailing list