Am Mittwoch, 6. Juni 2012, 16:15:52 schrieb Natalie Tasman:
> Andreas, thank you for your help. Not surprisingly (for someone new
> to cmake) I was getting tripped up with the cmake cache, in part.
> Here's what I've found using cmake 2.8.8:
>
> 0) One can get tripped up working with the both GUI and the command
> line. I was manually clearing cache files from the commandline and
> re-generating the cmake project with the GUI. I didn't realize that
> you had to use the GUI's "delete cache" as well (or just skip the
> GUI.)
>
> 1) to force an alternate location (such as /opt/local for me), use
> set(CMAKE_PREFIX_PATH /opt/local ${CMAKE_PREFIX_PATH})
>
> In this case, cmake ONLY searches the alternate
>
> 2) to add a "backup" or "fallback" location, use
> INCLUDE_DIRECTORIES(/opt/local/include)
> LINK_DIRECTORIES(/opt/local/lib)
This is sortof wrong. You need to specify include_directories() anyway to tell
the compiler where to search for the libraries. And you for sure should not be
using link_directories at all as it bypasses the normal link directory
ordering of CMake.
I assume you want to be able to tell CMake about a location from outside (i.e.
without touching the CMakeLists.txt anymore) and be sure that CMake finds the
library in the same place as the header. Try something like the following
(untested):
find_library(MYLIB foobar HINTS ENV FOOBAR_PREFIX)
#get's the path
get_filename_component(MYLIB_PREFIX "${MYLIB}" PATH)
#goes one leven upwards, e.g. cuts the "/lib"
get_filename_component(MYLIB_PREFIX "${MYLIB}" PATH)
find_path(MYHDR foo.h HINTS ${MYLIB_PREFIX
PATH_SUFFIXES include
NO_DEFAULT_PATH NO_CMAKE_ENVIRONMENT_PATH
NO_SYSTEM_ENVIRONMENT_PATH NO_CMAKE_SYSTEM_PATH)
To find out what all those options do have a look at "cmake --help-command
find_library" and "cmake --help-command find_path".
Eike
signature.asc
Description: This is a digitally signed message part.
-- 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
