Using cmake 2.8.8, I know that I can add "backup" or "fallback" search
directories for find_package, using

 INCLUDE_DIRECTORIES(/opt/local/include)
 LINK_DIRECTORIES(/opt/local/lib)

In this case, cmake first searches its default paths and THEN the
specified alternate.

However, I would like a way to tell find_package that it must find
both the library and header files from the same prefix.  Specifically,
using method 2) above, cmake finds LibArchive's lib file in /usr, does
NOT find the header under /usr, and then finds the header under /opt,
and returns success.  I am looking for a way to tell find_package to
ignore the lib in /usr because it does not have a corresponding
header, and then search another directory (here, /opt/local) for a
matching set of lib and header files.

-Natalie


On Tue, Jun 5, 2012 at 11:25 PM, Andreas Mohr <[email protected]> wrote:
> Hi,
>
> On Tue, Jun 05, 2012 at 11:11:44AM -0400, [email protected] wrote:
>> Date: Mon, 4 Jun 2012 17:01:34 -0700
>> From: Natalie Tasman <[email protected]>
>> I'm writing a CMakeLists.txt file, and I'm having problems getting
>> find_package to choose libraries under /opt/local rather than
>> /usr/local.  Specifically, I've installed libarchive using macports
>> and CMake cannot find it.  When CMake configuration finds the the
>> library in /usr/lib (/usr/lib/libarchive.dylib) but no corresponding
>> header, it fails, and I would like to find a way to tell CMake to fall
>> back to /opt/local, where a version of the library as well as the
>> archive.h header is installed.
>
> I believe that this is covered by the (now very lengthy)
> description of find_package() in man cmakecommands
> (or, to mention the main one-stop docs solution,
> "cmake --help-command find_package").
> You possibly need to set (well, probably _extend_)
> CMAKE_PREFIX_PATH or CMAKE_FRAMEWORK_PATH, probably in outer shell environment
> (or perhaps only on CMake script side, should work fine, too).
>
> [[background explanation:
> I believe the deeper intention behind these global-switch mechanisms
> is to let the user manually specify which specific architecture
> a build should be done for, i.e. you could have a full toolchain/library set
> for a specific embedded architecture (ARM, MIPS, ..., i.e. NOT
> compatible with the usually activated x86 libraries on your CMake setup),
> and by properly predefining these settings (which for special platforms
> should probably be cleanly carried out in user-custom CMake Platform setup
> files?), CMake knows which library paths to reference (i.e. below which
> PREFIX[es]).]]
>
> I've actually successfully done the same thing on my Mac setup
> (where things provided by e.g. macports/Fink/... need to be referenced 
> additionally),
> and I've simply extended configuration in the script file that
> holds all my main config settings of the project (sorry,
> cannot provide code at the moment).
> (ok, well, in fact I think it's indeed preferable to extend these things
> on script side rather than shell side, since many users would fail
> to *manually* set up shell side config correctly, and after all
> the project config itself knows best what it needs on certain platforms).
>
>> Solutions tried I've so far: Based on other related posts, I've tried
>> things like declaring INCLUDE_DIRECTORIES(/opt/local/include) and
>
> BTW CMake >= 2.8.8 (AFAIR) now finally has a target-specific (i.e.
> non-directory scope) INCLUDE_DIRECTORIES property for specifying these
> things.
>
> HTH,
>
> Andreas Mohr
--

Powered by www.kitware.com

Visit other Kitware open-source projects at 
http://www.kitware.com/opensource/opensource.html

Please keep messages on-topic and check the CMake FAQ at: 
http://www.cmake.org/Wiki/CMake_FAQ

Follow this link to subscribe/unsubscribe:
http://www.cmake.org/mailman/listinfo/cmake

Reply via email to