[CMake] find_package with NO_DEFAULT_PATH issue
Philip Lowman
philip at yhbt.com
Mon Oct 19 08:35:00 EDT 2009
On Mon, Oct 19, 2009 at 5:52 AM, Alexey Tkachenko
<alek.tkachenko at gmail.com>wrote:
> Hi,
> I'm trying to search Boost with find_package as it's said in manual:
> # first I try to search boost in my folder
> find_package(Boost PATHS /path/to/my/libs NO_DEFAULT_PATH)
> #then I try to search in standard paths
> find_package(Boost)
>
> but cmake shoes warning message on first find_package:
> ----------
> CMake Warning at CMakeLists.txt:41 (find_package):
> Could not find a configuration file for package Boost.
>
> Set Boost_DIR to the directory containing a CMake configuration file for
> Boost. The file will have one of the following names:
>
> BoostConfig.cmake
> boost-config.cmake
> ---------
>
> How can I suppress search in standard paths? Thanks in advance for any
> help.
>
You can set BOOST_ROOT which will cause FindBoost to search that path first,
but it will still fallback to the standard paths. There is a bug for this
in the tracker. I believe most people who use BOOST_ROOT simply rely on
manual inspection to work around this potential problem.
NO_DEFAULT_PATH is not legal on a find_package() call which explains your
problems above. To suppress the fallback behavior, you could add a
conditional to FindBoost.cmake to include NO_DEFAULT_PATH anywhere there is
a find_path() or find_library() call. E.g.
if(Boost_SET_NO_DEFAULT_PATH)
set(_boost_find_options NO_DEFAULT_PATH)
endif()
...
find_library(..... ${_boost_find_options} ...)
The only reason this hasn't been fixed is I keep wondering if we could just
make FindBoost do this automatically if BOOST_ROOT is being used. But
ultimately this will probably break some builds of people who rely on
BOOST_ROOT as a "use it if it's there" feature so fixing it via a public
conditional (defaulting off) is probably the only way to go.
--
Philip Lowman
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.cmake.org/pipermail/cmake/attachments/20091019/4db6b800/attachment.htm>
More information about the CMake
mailing list