# How to use FindICU, tell it where to search?

**URL:** https://discourse.cmake.org/t/how-to-use-findicu-tell-it-where-to-search/6461
**Category:** Usage
**Created:** [September 11, 2022, 3:51pm UTC](https://discourse.cmake.org/t/how-to-use-findicu-tell-it-where-to-search/6461 "2022-09-11T15:51:10Z")
**Posts on this page:** 5
**Page:** 1

<div class="post-metadata">

### Author: ![RobN](https://discourse.cmake.org/letter_avatar_proxy/v4/letter/r/e9bcb4/32.png) [@RobN](https://discourse.cmake.org/u/RobN)
#### Post date: [September 11, 2022, 3:51pm UTC](https://discourse.cmake.org/t/how-to-use-findicu-tell-it-where-to-search/6461/1 "2022-09-11T15:51:10Z")

</div>

I’m trying to link my C++ project with ICU. I found this documentation: [FindICU](https://cmake.org/cmake/help/latest/module/FindICU.html).

I used [brew](https://brew.sh) to install `icu4c` on my macOS system. It put it in `/usr/local/opt/icu4c`.

In my CMakeLists.txt, I try:

```nohighlight
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.

---

<div class="post-metadata">

### Author: ![marc.chevrier](https://discourse.cmake.org/letter_avatar_proxy/v4/letter/m/ecb155/32.png) [@marc.chevrier](https://discourse.cmake.org/u/marc.chevrier)
#### Post date: [September 11, 2022, 8:46pm UTC](https://discourse.cmake.org/t/how-to-use-findicu-tell-it-where-to-search/6461/2 "2022-09-11T20:46:40Z")

</div>

To load a module, use the [find\_package](https://cmake.org/cmake/help/latest/command/find_package.html) command:

```cmake
set(ICU_DEBUG ON)
find_package(ICU)

```

---

<div class="post-metadata">

### Author: ![RobN](https://discourse.cmake.org/letter_avatar_proxy/v4/letter/r/e9bcb4/32.png) [@RobN](https://discourse.cmake.org/u/RobN)
#### Post date: [September 11, 2022, 9:09pm UTC](https://discourse.cmake.org/t/how-to-use-findicu-tell-it-where-to-search/6461/3 "2022-09-11T21:09:42Z")

</div>

Okay, I tried:

```auto
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:

```nohighlight
-- --------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
...

```

---

<div class="post-metadata">

### Author: ![marc.chevrier](https://discourse.cmake.org/letter_avatar_proxy/v4/letter/m/ecb155/32.png) [@marc.chevrier](https://discourse.cmake.org/u/marc.chevrier)
#### Post date: [September 13, 2022, 3:02pm UTC](https://discourse.cmake.org/t/how-to-use-findicu-tell-it-where-to-search/6461/4 "2022-09-13T15:02:10Z")

</div>

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:

```cmake
set(ICU_DEBUG ON)
set(ICU_ROOT /usr/local/opt/icu4c)
find_package(ICU COMPONENTS data)

```

---

<div class="post-metadata">

### Author: ![RobN](https://discourse.cmake.org/letter_avatar_proxy/v4/letter/r/e9bcb4/32.png) [@RobN](https://discourse.cmake.org/u/RobN)
#### Post date: [September 14, 2022, 11:39pm UTC](https://discourse.cmake.org/t/how-to-use-findicu-tell-it-where-to-search/6461/5 "2022-09-14T23:39:48Z")

</div>

Thanks! Naming the specific components makes the difference. - `find_package(ICU COMPONENTS data ...)`
