Bug 12391 - CMake-based host package fails to include output/host/include
Summary: CMake-based host package fails to include output/host/include
Status: RESOLVED WONTFIX
Alias: None
Product: buildroot
Classification: Unclassified
Component: Other (show other bugs)
Version: 2019.08.1
Hardware: All Linux
: P5 normal
Target Milestone: ---
Assignee: unassigned
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2019-12-09 22:04 UTC by thirtythreeforty
Modified: 2020-05-20 13:47 UTC (History)
1 user (show)

See Also:
Host:
Target:
Build:


Attachments
Work-in-progress package to replicate the issue (2.23 KB, application/zip)
2019-12-09 22:04 UTC, thirtythreeforty
Details

Note You need to log in before you can comment on or make changes to this bug.
Description thirtythreeforty 2019-12-09 22:04:46 UTC
Created attachment 8311 [details]
Work-in-progress package to replicate the issue

I am struggling to package a new version of mfgtools.  My work-in-progress is attached; ideally you can extract this into your working directory and replicate my error.

mfgtools depends on bzlib.h while building.  The compiler (/usr/bin/gcc) cannot find the bzlib.h file, which at first doesn't make sense... it's in output/host/include where bzip2 puts it.

/home/ghilliard/Code/buildroot/output/build/host-mfgtools-1.3.102/libuuu/buffer.cpp:43:10: fatal error: bzlib.h: No such file or directory
 #include "bzlib.h"
          ^~~~~~~~~

The problem is that even though Buildroot passes -Imy/buildroot/output/host/include into CMake, CMake detects this as an "implicit include directory" because GCC reports it as such (I think GCC notices that it has "system" include files, but honestly I am not exactly sure about its logic).  Then, when the compiler is actually called, this include is omitted by CMake. Without the include, the compiler doesn't implicitly include the directory at all, and the build fails.

This hasn't been hit before because there are no bzip2-dependant host packages in the tree that are built with CMake.  I do not think this is specific to mfgtools; rather, it will be hit by the first package that does all of the following:

- Be a host package
- Use CMake to build
- Include a file in output/host/include, not one of its subdirectories
Comment 1 Thomas Petazzoni 2020-05-19 21:26:53 UTC
Thanks for your bug report.

However, it is really the mfgtools code that is broken: in libuuu/CMakeLists.txt it overwrites CMAKE_CXX_FLAGS, which means it ignores the value Buildroot is passing, which contains -I$(HOST_DIR)/include.

If you change:

libuuu/CMakeLists.txt:set(CMAKE_CXX_FLAGS "-O2 ${UUUSSL}")

to:

libuuu/CMakeLists.txt:set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -O2 ${UUUSSL}")

suddenly, it will work.
Comment 2 Fabrice Fontaine 2020-05-20 13:47:09 UTC
FYI, I sent the fix suggested by Thomas and it was merged upstream: https://github.com/NXPmicro/mfgtools/commit/ea8eb862ce2445c17bb8dd55587d6a2581d20b68