zlib target defined issue when building with cpr


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?


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

1 Like

It worked! Thank you so much!

1 Like