1

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?

usr1234567
  • 17,173
  • 10
  • 96
  • 112
JesseTG
  • 1,723
  • 1
  • 19
  • 40
  • Where is the Find.cmake script located? – Robert Prévost Sep 16 '16 at 00:23
  • @RobertPrévost In the `cmake` directory of a project of mine that's using it. That is, its path is `/cmake/Find.cmake`. – JesseTG Sep 16 '16 at 02:12
  • By using find_path and find_library are you able to update CMAKE_MODULE_PATH before you call find_package(...)? – Robert Prévost Sep 16 '16 at 02:24
  • 1
    @RobertPrévost Are you asking if my `Find.cmake` is being called in the first place? If so, it definitely is; I can get printout just fine, and I can even find libraries and headers *not* referred to via symlink. – JesseTG Sep 16 '16 at 03:26
  • I would expect CMake to just `open()` directory *${MYLIB_BREW_ROOT}/include*, and then search inside it. So, whether path to directory contains symlinks or not is opaque for CMake - it is OS who should care about opening such path. Please, provide [mcve]: `CMakeLists.txt` file which contains `find_path()` call and path to the file which is intended to be found. – Tsyvarev Sep 16 '16 at 08:40

1 Answers1

0

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.

JesseTG
  • 1,723
  • 1
  • 19
  • 40