Reputation: 1508
I've written a CMake module to find libclang:
find_path(LibClang_INCLUDE_DIR clang-c/Index.h)
find_library(LibClang_LIBRARY NAMES clang)
But I've installed libclang via MacPorts to /opt/local/libexec/llvm-3.0/lib
and /opt/local/libexec/llvm-3.0/include
. Since this isn't a normal system location, CMake doesn't find it.
What's the best way to show CMake where it is? How can I find out where CMake is searching? I don't think moving the library to a more normal location is an option because I don't want to move things away from where MacPorts put them, and I also have Apple's official clang binaries (not including libclang) on my system.
Upvotes: 1
Views: 2545
Reputation: 15100
Add the HINTS or PATHS flag to suggest locations for it to search.
If you want to make a general way to include non-standard locations, you can do two things. One is make sure the users know to put the non-standard location on the LD_LIBRARY_PATH
environment variable and then suggest that as a HINT to find_path
and find_library
with ENV LD_LIBRARY_PATH
.
The other option is to put a custom environment variable and tell users to set that if it's non-standard. For instance, CLANG_ROOT
, and include that in the HINTS.
Of course, you can do both and it would be the most general.
Upvotes: 1