# zlib target defined issue when building with cpr

**URL:** <https://discourse.itk.org/t/zlib-target-defined-issue-when-building-with-cpr/6456>\
**Category:** Engineering\
**Created:** [February 19, 2024, 4:59pm UTC](https://discourse.itk.org/t/zlib-target-defined-issue-when-building-with-cpr/6456 "2024-02-19T16:59:05Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![jilei-hao](https://discourse.itk.org/user_avatar/discourse.itk.org/jilei-hao/32/2876_2.png) [@jilei-hao](https://discourse.itk.org/u/jilei-hao)\
**Post date:** [February 19, 2024, 4:59pm UTC](https://discourse.itk.org/t/zlib-target-defined-issue-when-building-with-cpr/6456/1 "2024-02-19T16:59:06Z")

</div>

Hi,

I’m building a project with ITK 5.4rc02 with cpr library and I’m getting following error during configuration:

"CMake Error at /Users/tk/itk/installed/lib/cmake/ITK-5.4/ITKTargets.cmake:42 (message):  
Some (but not all) targets in this export set were already defined.

Targets Defined: zlib  
…  
"

It was fine with ITK 5.2. ITK 5.3 also has this issue.

I’m referencing cpr using fetch\_content, would that be the cause? How can I fix this without changing ITK source code?

Thanks!

---

<div class="post-metadata">

**Author:** ![dzenanz](https://discourse.itk.org/user_avatar/discourse.itk.org/dzenanz/32/1093_2.png) [@dzenanz](https://discourse.itk.org/u/dzenanz)\
**Post date:** [February 19, 2024, 6:15pm UTC](https://discourse.itk.org/t/zlib-target-defined-issue-when-building-with-cpr/6456/2 "2024-02-19T18:15:03Z")

</div>

Try setting `ITK_USE_SYSTEM_ZLIB=ON`. Or if there is a similar switch in “cpr”, try toggling it.

---

<div class="post-metadata">

**Author:** ![jilei-hao](https://discourse.itk.org/user_avatar/discourse.itk.org/jilei-hao/32/2876_2.png) [@jilei-hao](https://discourse.itk.org/u/jilei-hao)\
**Post date:** [February 19, 2024, 6:54pm UTC](https://discourse.itk.org/t/zlib-target-defined-issue-when-building-with-cpr/6456/3 "2024-02-19T18:54:01Z")

</div>

It worked! Thank you so much!
