On Tue, Jul 04, 2017 at 01:21:48PM +0300, Vadim Zhukov wrote:
> >>
> >> a port i'm working on (pgpointcloud) uses cmake to detect libxml2:
> >>
> >> https://github.com/pgpointcloud/pointcloud/blob/master/CMakeLists.txt#L91
> >>
> >> with this CMakeLists the build fails because -I/usr/local/include is not
> >> on the CFLAGS:
> >>
> >> /usr/obj/ports/pgpointcloud-1.1.0pre0/bin/cc -I/usr/local/include/libxml2 
> >> -Ilib -O2 -pipe -DNDEBUG   -fPIC
> >> -MD -MT lib/CMakeFiles/libpc-static.dir/pc_schema.c.o -MF 
> >> lib/CMakeFiles/libpc-static.dir/pc_schema.c.o.d -o
> >> lib/CMakeFiles/libpc-static.dir/pc_schema.c.o   -c
> >> /usr/obj/ports/pgpointcloud-1.1.0pre0/pointcloud-0130a1c49dc3f8c3beaa5f033c66691bdc422987/lib/pc_schema.c
> >> In file included from 
> >> /usr/obj/ports/pgpointcloud-1.1.0pre0/pointcloud-0130a1c49dc3f8c3beaa5f033c66691bdc422987/lib/pc_schema.c:13
> >> In file included from /usr/local/include/libxml2/libxml/parser.h:810:
> >> /usr/local/include/libxml2/libxml/encoding.h:28:10: fatal error: 'iconv.h' 
> >> file not found
> >> #include <iconv.h>
> >>
> >> What i dont understand is that libxml-2.0.pc sets it:
> >>
> >> $pkg-config --cflags libxml-2.0
> >> -I/usr/local/include/libxml2 -I/usr/local/include
> >>
> >> And afaik our FindLibxml2.cmake module in
> >> /usr/local/share/cmake/Modules/FindLibXml2.cmake uses that:
> >> ===========
> >> find_package(PkgConfig QUIET)
> >> PKG_CHECK_MODULES(PC_LIBXML QUIET libxml-2.0)
> >> set(LIBXML2_DEFINITIONS ${PC_LIBXML_CFLAGS_OTHER})
> >>
> >> find_path(LIBXML2_INCLUDE_DIR NAMES libxml/xpath.h
> >>    HINTS
> >>    ${PC_LIBXML_INCLUDEDIR}
> >>    ${PC_LIBXML_INCLUDE_DIRS}
> >>    PATH_SUFFIXES libxml2
> >>    )
> >>
> >> find_library(LIBXML2_LIBRARIES NAMES xml2 libxml2
> >>    HINTS
> >>    ${PC_LIBXML_LIBDIR}
> >>    ${PC_LIBXML_LIBRARY_DIRS}
> >>    )
> >>
> >> ===========
> >>
> >> So with my limited cmake-fu, i'm puzzled as to why usr/local/include
> >> isnt part of the include paths. It 'works' if i patch the CmakeLists.txt
> >> this way:
> >>
> >>  find_package (LibXml2 REQUIRED)
> >>  mark_as_advanced (CLEAR LIBXML2_INCLUDE_DIR)
> >>  mark_as_advanced (CLEAR LIBXML2_LIBRARIES)
> >>  include_directories (${LIBXML2_INCLUDE_DIR})
> >> +include_directories (/usr/local/include)
> >>
> >> But that's of course ugly, so i'm looking for help to figure out if this
> >> is a problem in FindLibxml2.cmake or in pgpointcloud's CMakeLists.txt..
> >>
> >
> > It's definitely not a FindLibxml2.cmake problem because
> > "find_package(LibXml2)" works fine with akonadi-17.04.1 (kf5 port on
> > openbsd-wip).
> 
> It's definitely the FindLibXml2.cmake problem, since it doesn't
> provide LIBXML2_INCLUDE_DIRS (notice the 'S'), and only LIBXML_INCLUDE_DIR.
> This should be fixed upstream with patch like below; I'll need to recover
> my Kitware account password, though... :)
> 
> After that applied, you'll need to tweak the pgpointcloud port to use
> the ${LIBXML2_INCLUDE_DIRS} instead of ${LIBXML2_INCLUDE_DIR}.

Fwiw, with your patch and this in pgpointcloud:

 find_package (LibXml2 REQUIRED)
-mark_as_advanced (CLEAR LIBXML2_INCLUDE_DIR)
+mark_as_advanced (CLEAR LIBXML2_INCLUDE_DIRS)
 mark_as_advanced (CLEAR LIBXML2_LIBRARIES)
-include_directories (${LIBXML2_INCLUDE_DIR})
+include_directories (${LIBXML2_INCLUDE_DIRS})

it builds fine. Ok for me too on the cmake diff - with the link to the
upstream report/pushback..

Reply via email to