[CMake] Proper way to find system copy of libxml2 on macOS

Eric Noulard eric.noulard at gmail.com
Wed Oct 12 12:15:58 EDT 2016


2016-10-12 18:04 GMT+02:00 Konstantin Tokarev <annulen at yandex.ru>:

>
>
> 12.10.2016, 18:48, "Eric Noulard" <eric.noulard at gmail.com>:
> > 2016-10-12 17:28 GMT+02:00 Konstantin Tokarev <annulen at yandex.ru>:
>
> >
> > My guess is that your find_package call end up in "Module mode"  because
> there is a FindLibXml2.cmake module bundled with cmake does not honor all
> options of the find_package when in this mode.
> >
> > So I bet FindLibXml2.cmake does not handle the given
> > "PATHS "/usr" NO_DEFAULT_PATH" part.
> >
> > Which are handled by find_package when running in "Config mode".
> >
> > I suggest you to try patch and update the FindLibXml2.cmake module.
>
> Could anyone point me to module example that handles NO_DEFAULT_PATH
> correctly?
>

Wait for other answers but from my understanding the "Module" mode does not
handle such find_package parameter.


>
> > Or simply craft your own
> >
> > find_library(...) call.if you only need the libxml2.
>
> That's not an elegant solution as I need to find include dir as well, and
> also do the same for libxslt which is in the same boat.
>

I see.
Then provided that module mode does not handle the "NO_DEFAULT_PATH" you
may need to do something similar to whats is done
by the FindZLIB.cmake module:

# A user may set ``ZLIB_ROOT`` to a zlib installation root to tell this
# module where to look.

set(_ZLIB_SEARCHES)

# Search ZLIB_ROOT first if it is set.
if(ZLIB_ROOT)
  set(_ZLIB_SEARCH_ROOT PATHS ${ZLIB_ROOT} NO_DEFAULT_PATH)
  list(APPEND _ZLIB_SEARCHES _ZLIB_SEARCH_ROOT)
endif()



-- 
Eric
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://public.kitware.com/pipermail/cmake/attachments/20161012/7f2e82cf/attachment.html>


More information about the CMake mailing list