[CMake] Having find_library et al. search within OS X SDK root directory

Matthew LeRoy MLeRoy at minitab.com
Thu Mar 14 15:39:53 EDT 2013


Hi,

Forgive me if this issue has been discussed or is documented elsewhere,
but after some thorough perusal of the archives I didn't find anything.

When using the Xcode generator, is there a way to get find_library() and related
commands to search within the SDK directory specified by CMAKE_OSX_SYSROOT,
rather than the default system path /usr? It would seem to make sense that
if I've specified a target SDK, CMake should search for libraries within
that SDK rather than what is actually installed on my system; I wouldn't want
CMake finding/using a library from my system that doesn't exist in my target SDK,
or that is of a different version, etc.

I understand that the Xcode generator employs the -isysroot flag so that at compile
and link time paths are searched relative to the specified directory... but I don't
believe that has any affect on the search algorithm performed by the find_XXX functions
at CMake time. Of course, that does pose a potential problem; if find_library() were
to search within the SDK directory and set the corresponding variable to the full path
within that directory, but -isysroot were specified in conjuction with the full path to
the found library at compile/link time, might that be a problem?

I perused through the various platform files for Darwin and found what looks to be
all of the logic for determining the SDK directory, but the directory doesn't get
added to any of the likely CMAKE variables that affect the find_XXX functions.
I'm guessing CMAKE_SYSTEM_PREFIX_PATH would be the correct variable to add the SDK
directory to.

Of course, maybe I'm thinking about this the wrong way. Either way, I appreciate
whatever help anyone can provide.

Matt


More information about the CMake mailing list