Bug 177059 - devel/cmake: /usr/share/cmake/Modules/FindLibXml2.cmake should include ${LOCAL_BASE}/include in LIBXML2_INCLUDE_DIR
Summary: devel/cmake: /usr/share/cmake/Modules/FindLibXml2.cmake should include ${LOCA...
Status: Closed Overcome By Events
Alias: None
Product: Ports & Packages
Classification: Unclassified
Component: Individual Port(s) (show other bugs)
Version: Latest
Hardware: Any Any
: Normal Affects Only Me
Assignee: freebsd-kde (group)
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2013-03-17 22:40 UTC by Stephen Checkoway
Modified: 2018-10-20 20:46 UTC (History)
3 users (show)

See Also:
rakuco: maintainer-feedback+


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Stephen Checkoway 2013-03-17 22:40:00 UTC
Cmake's find_package(LibXml2) does not properly include /usr/local/include and it should because one of the header files depends on iconv.h which lives in /usr/local/include.

SDL also depends on iconv.h and /usr/share/cmake/Modules/FindSDL.cmake contains the following lines:
# On FreeBSD SDL depends on libiconv and SDL_stdinc.h includes iconv.h, which is
# located in ${LOCALBASE}/include. Append {LOCALBASE}/include to
# the SDL_INCLUDE_DIR, thus allow to build SDL apps out of box.
LIST(APPEND SDL_INCLUDE_DIR /usr/local/include)

/usr/share/cmake/Modules/FindLibXml2.cmake should almost certainly contain a similar line.

Fix: 

I don't know cmake well, but I assume adding a line like
LIST(APPEND LIBXML2_INCLUDE_DIR /usr/local/include)
to /usr/share/cmake/Modules/FindLibXml2.cmake would suffice.
How-To-Repeat: git clone http://llvm.org/git/llvm.git
cd llvm
git checkout release_32
cd tools
git clone http://llvm.org/git/clang.git
cd clang
git checkout release_32
cd ../../..
mkdir llvm-build
cd llvm-build
cmake -G Ninja ../llvm
ninja bin/c-index-test
Comment 1 Edwin Groothuis freebsd_committer freebsd_triage 2013-03-18 10:41:04 UTC
Responsible Changed
From-To: freebsd-ports-bugs->kde

Over to maintainer (via the GNATS Auto Assign Tool)
Comment 2 Carlo Strub freebsd_committer freebsd_triage 2014-09-11 20:13:03 UTC
Is this PR still relevant?
Comment 3 Raphael Kubo da Costa freebsd_committer freebsd_triage 2015-12-22 13:12:38 UTC
I think it's still relevant, I remember noticing that several ports needed USES=iconv just because they pulled some libxml2 header that included iconv.h in bug 202798.

However, I'm not sure just adding ${LOCALBASE}/include to LIBXML2_INCLUDE_DIR is the right solution here: whether iconv from base or ports needs to be used depends on the FreeBSD version, the iconv features being required and whether the iconv port is already installed. See the logic in Mk/Uses/iconv.mk that is needed to deal with all those differences.
Comment 4 Adriaan de Groot freebsd_committer freebsd_triage 2017-10-12 10:31:25 UTC
The logic in Uses/iconv.mk adds variables ICONV_INCLUDE_DIR and LIBICONV_INCLUDE_DIR (set to identical values) which a port could use.

I suppose we *could* patch FindLibXml2.cmake to add ICONV_INCLUDE_DIR to the LIBXML2_INCLUDE_DIR, so that ports doing
    find_package(LibXml2 REQUIRED)
    include_directories(${LIBXML2_INCLUDE_DIR})
    add_definitions(${LIBXML2_DEFINITIONS})
will get the   right directories included.
Comment 5 Tobias C. Berner freebsd_committer freebsd_triage 2017-10-12 11:40:20 UTC
But you have to be careful. 
If you are unlucky, this may lead header files in ${LOCALBASE}/include being picked up, when you actually wanted the ones in ${WRKSRC}/* and break ports in unxpected ways :D
Comment 6 Tobias C. Berner freebsd_committer freebsd_triage 2018-10-20 18:29:50 UTC
Is this still an issue?
Comment 7 Stephen Checkoway 2018-10-20 18:40:23 UTC
I have long since forgotten how I encountered this. I don't know if it ever got fixed, but it's certainly not an issue for me any more so if you want to close the bug, that's fine with me.
Comment 8 Tobias C. Berner freebsd_committer freebsd_triage 2018-10-20 20:46:23 UTC
Please feel free to reopen it at any time, if it reoccurs.


mfg Tobias