cmakesymlink-traversal

Do CMake's find_<something> commands traverse symlinks?


I'm writing a Find<library>.cmake module, because no good one exists for the library in question. This necessitates usage of the find_path and find_library commands. I'm testing it on macOS El Capitan.

Through means that are not relevant to this question, I determine that on macOS, this library is installed in /usr/local/opt/<brew formula name>, which is in fact a symlink to somewhere else (the exact location isn't relevant). Let's call this path MYLIB_BREW_ROOT.

The headers and dylib's for this formula are available in ${MYLIB_BREW_ROOT}/include and ${MYLIB_BREW_ROOT}/lib, respectively. I add these paths, as written here, to the relevant find command search paths. So why isn't CMake finding them? Does CMake traverse symlinks? If so, how do I enable it? If not, how do I work around it?


Solution

  • Ultimately, the answer is yes. Symlinks work exactly as I expected them to. The real problem I had was unrelated to CMake; it had to do with pkg-config and the relevant libraries not having entries for it.