RobN
September 11, 2022, 3:51pm
1
I’m trying to link my C++ project with ICU. I found this documentation: FindICU .
I used brew to install icu4c
on my macOS system. It put it in /usr/local/opt/icu4c
.
In my CMakeLists.txt, I try:
set(ICU_DEBUG ON)
# set(ICU_ROOT /usr/local/opt/icu4c)
include(FindICU)
And it can’t find it. How do I tell it where to look? I thought maybe setting that ICU_ROOT variable would help, but it didn’t.
To load a module, use the find_package command:
set(ICU_DEBUG ON)
find_package(ICU)
RobN
September 11, 2022, 9:09pm
3
Okay, I tried:
set(ICU_DEBUG ON)
set(ICU_ROOT /usr/local/opt/icu4c) # also tried without this
find_package(ICU)
And it still seems confused. How do I point it at the include and lib dirs under /usr/local/opt/icu4c, that brew
installed? It prints:
-- --------FindICU.cmake results debug--------
-- ICU found: FALSE
-- ICU_VERSION number: 70.1
-- ICU_ROOT directory: /usr/local/opt/icu4c
-- ICU_INCLUDE_DIR directory: /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX12.3.sdk/usr/include
-- ICU_LIBRARIES:
-- gencnval program: ICU_GENCNVAL_EXECUTABLE=/usr/local/opt/icu4c/bin/gencnval
...
From your log, I think you re-launch the configuration step without cleaning up the environment which explain why you have artifacts from different installations (i.e. native one + brew). At least remove CMakeCache.txt
file or, if you have version 3.24, you can use the --fresh
option.
Now, on macOS, it seems not all components are installed (i.e. component lx
seems missing), so the ICU
is not fully founded. Try a query with an explicit list of components:
set(ICU_DEBUG ON)
set(ICU_ROOT /usr/local/opt/icu4c)
find_package(ICU COMPONENTS data)
RobN
September 14, 2022, 11:39pm
5
Thanks! Naming the specific components makes the difference. - find_package(ICU COMPONENTS data ...)