[CMake] find_package: how to require same directory prefix for both lib and header files?

don la dieu nega at icecube.umd.edu
Wed Jun 6 19:50:24 EDT 2012


On Jun 6, 2012, at 7:20 PM, Natalie Tasman wrote:

[...]

> 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,

[...]

I solved this some time ago by not using find_package(). The following works for Linux system pkgs (Ubuntu & ScientificLinux), FreeBSD's system libarchive and OS X without pkg-config.

find_package(PkgConfig)
pkg_check_modules(PC_LA libarchive)

find_library(LIBARCHIVE_LIBRARIES archive
             HINTS /opt/local/lib
                   ${PC_LA_LIBDIR}
                   ${PC_LA_LIBRARY_DIRS}
                   NO_DEFAULT_PATH)

find_path(LIBARCHIVE_INCLUDE_DIR archive.h
          HINTS /opt/local/include
                ${PC_LA_INCLUDEDIR}
                ${PC_LA_INCLUDE_DIRS})

We have a fairly rigid environment, so YMMV.

don



More information about the CMake mailing list