Apple Silicon, CMake, Homebrew, Libicu

Okay, as you can guess from the subject header this is a complex question spanning multiple systems but I think the problem is with cmake.

For a project, a small interpreter named egel, I now develop on a Macbook Air M1, an Apple Silicon system. The project compiles fine on various Linuxes and BSDs. Not so much on Apple Silicon.

I install the project with git clone. I install the dependencies with homebrew, those go under /opt/homebrew. Libicu (or icu4c as it’s called as a package) goes there.

Everything is compiled out of source in a ‘build’ directory. To make cmake aware what libicu it needs I run ‘cmake … -DCMAKE_PREFIX_PATH=/opt/homebrew/opt/icu4c’. That produces the necessary makefiles.

However, make returns ’ /Users/username/Programming/egel/src/runtime.hpp:13:10: fatal error: ‘unicode/unistr.h’ file not found’, i.e., clang fails to find the necessary libicu headers.

My conclusion is that the makefiles generated do not point at the right headers, and probably also not at the right libicu system library, due to those (on Apple Silicon) being installed under /opt/homebrew/… instead of under /opt/include.

Is that correct? How can I fix this?

Thanks in advance, sprout

What CMake code do you have to actually use libicu? Is it just the CMAKE_PREFIX_PATH setting?

The libicu plugin to find the packages and components introduced.

find_package(ICU 60.0 REQUIRED COMPONENTS data i18n io tu uc)

add_executable(egel $<TARGET_OBJECTS:objlib>)
target_link_libraries(egel ${CMAKE_DL_LIBS} fmt::fmt Threads::Threads ICU::uc ICU::i18n ICU::io)

This does not add the include directories when compiling objects in objlib

Oh great, is that the mistake? Can you please then tell me how to fix this?

Btw, this is how the objects are compiled:

add_library(objlib OBJECT ${EGEL_SOURCES}
target_link_libraries(objlib fmt::fmt Threads::Threads ICU::uc ICU::i18n ICU::io)

Never mind. I fixed it with ‘include_directories’ command. Thanks for all the help, this can now be closed.

The ICU libraries should have a usage requirement of their include directories. It sounds like an issue with whatever config file or find module is used.

Yah, as a post-mortem: The application has three dependencies (fmt, libicu, threads). It’s plain weird that cmake functions for the other two packages but not libicu.

But I have my fix. Maybe a FindICU maintainer can look at this once.

Thanks all, sprout

What FindICU is being used?

Looks like that what ships with homebrew latest (3.23), FindICU (3.11?) made by Roger Leigh.

OK, thanks. Could you file an issue about this situation please?


Thanks, I see this issue.