# CMake error with external freetype

**URL:** https://discourse.vtk.org/t/cmake-error-with-external-freetype/13138
**Category:** Support
**Created:** [January 24, 2024, 12:51am UTC](https://discourse.vtk.org/t/cmake-error-with-external-freetype/13138 "2024-01-24T00:51:40Z")
**Posts on this page:** 8
**Page:** 1

<div class="post-metadata">

### Author: ![Juan\_Jose\_Casafranca](https://discourse.vtk.org/user_avatar/discourse.vtk.org/juan_jose_casafranca/32/7942_2.png) [@Juan\_Jose\_Casafranca](https://discourse.vtk.org/u/Juan_Jose_Casafranca)
#### Post date: [January 24, 2024, 12:51am UTC](https://discourse.vtk.org/t/cmake-error-with-external-freetype/13138/1 "2024-01-24T00:51:40Z")

</div>

I am trying to compile VTK using conan for installing the dependencies. However, the packages generated by conan already provide freetype, as its a dependency of Qt, and when I try to configure VTK, I get the following error:

```auto
[cmake] CMake Error at VTK/CMake/vtkModule.cmake:4139 (add_library):
[cmake] add_library cannot create target "freetype" because an imported target with
[cmake] the same name already exists.
[cmake] Call Stack (most recent call first):
[cmake] VTK/ThirdParty/freetype/vtkfreetype/CMakeLists.txt:54 (vtk_module_add_module)

```

I have tried to set VTK\_MODULE\_USE\_EXTERNAL\_vtkfreetype and VTK\_MODULE\_USE\_EXTERNAL\_freetype to true, without success.

Is there anyway to compile VTK with external freetype?

---

<div class="post-metadata">

### Author: ![Paulo\_Carvalho](https://discourse.vtk.org/user_avatar/discourse.vtk.org/paulo_carvalho/32/370_2.png) [@Paulo\_Carvalho](https://discourse.vtk.org/u/Paulo_Carvalho)
#### Post date: [January 24, 2024, 9:37pm UTC](https://discourse.vtk.org/t/cmake-error-with-external-freetype/13138/2 "2024-01-24T21:37:41Z")

</div>

Hello,

If `freetype` is being build by Conan independently, then I believe you need to disable it in VTK configuration and add `freetype` as a required package in the VTK’s Conan recipe. If you enable it in VTK’s CMakeLists.txt, then `freetype` will be built again with likely adverse results.

best,

PC

---

<div class="post-metadata">

### Author: ![Juan\_Jose\_Casafranca](https://discourse.vtk.org/user_avatar/discourse.vtk.org/juan_jose_casafranca/32/7942_2.png) [@Juan\_Jose\_Casafranca](https://discourse.vtk.org/u/Juan_Jose_Casafranca)
#### Post date: [January 24, 2024, 10:23pm UTC](https://discourse.vtk.org/t/cmake-error-with-external-freetype/13138/3 "2024-01-24T22:23:10Z")

</div>

I am not sure I understand. What do you mean with VTKs conan recipe? I havent found any recipe for VTK. What I did was to create a conanfile to specify VTK dependencies, mainly Qt6, and when I tried to use the Qt6Config package generated by Conan, that included freetype.

How can I disable freetype in VTK CMakeLists? I tried VTK\_MODULE\_USE\_EXTERNAL\_freetype/vtkfreetype, but none of them work. I could of course rework a lot of parts of VTKs CMakeLists to fetch an external freetype, but I was expecting some supported way of using an external freetype.

---

<div class="post-metadata">

### Author: ![Paulo\_Carvalho](https://discourse.vtk.org/user_avatar/discourse.vtk.org/paulo_carvalho/32/370_2.png) [@Paulo\_Carvalho](https://discourse.vtk.org/u/Paulo_Carvalho)
#### Post date: [January 25, 2024, 3:16pm UTC](https://discourse.vtk.org/t/cmake-error-with-external-freetype/13138/4 "2024-01-25T15:16:36Z")

</div>

How do you use Conan to build VTK?

---

<div class="post-metadata">

### Author: ![Juan\_Jose\_Casafranca](https://discourse.vtk.org/user_avatar/discourse.vtk.org/juan_jose_casafranca/32/7942_2.png) [@Juan\_Jose\_Casafranca](https://discourse.vtk.org/u/Juan_Jose_Casafranca)
#### Post date: [January 25, 2024, 3:48pm UTC](https://discourse.vtk.org/t/cmake-error-with-external-freetype/13138/5 "2024-01-25T15:48:55Z")

</div>

Actually I am building ParaView, so I created a conanfile to specify Qt as a dependency. Then I just run cmake normally, but specifying the conan\_toolchain file produced by conan, which makes cmake use the FooConfig.cmake packages created by conan.

That brings freetype (Qt has a dependency on freetype), and VTK compilation fails because it sees there is already an external freetype and it can’t compile its own

---

<div class="post-metadata">

### Author: ![Paulo\_Carvalho](https://discourse.vtk.org/user_avatar/discourse.vtk.org/paulo_carvalho/32/370_2.png) [@Paulo\_Carvalho](https://discourse.vtk.org/u/Paulo_Carvalho)
#### Post date: [January 25, 2024, 9:21pm UTC](https://discourse.vtk.org/t/cmake-error-with-external-freetype/13138/6 "2024-01-25T21:21:42Z")

</div>

Well, then you need to disable it when running CMake to configure VTK. You know you can pass CMake varibales via command line. E.g.: `cmake ... -DVTK_MODULE_USE_EXTERNAL_vtkfreetype=true -D...`, right?

---

<div class="post-metadata">

### Author: ![Juan\_Jose\_Casafranca](https://discourse.vtk.org/user_avatar/discourse.vtk.org/juan_jose_casafranca/32/7942_2.png) [@Juan\_Jose\_Casafranca](https://discourse.vtk.org/u/Juan_Jose_Casafranca)
#### Post date: [January 25, 2024, 9:53pm UTC](https://discourse.vtk.org/t/cmake-error-with-external-freetype/13138/7 "2024-01-25T21:53:39Z")

</div>

Not sure if you read my question, but I clearly said I tried using that option without success…

---

<div class="post-metadata">

### Author: ![ben.boeckel](https://discourse.vtk.org/letter_avatar_proxy/v4/letter/b/ea5d25/32.png) [@ben.boeckel](https://discourse.vtk.org/u/ben.boeckel)
#### Post date: [February 7, 2024, 8:59pm UTC](https://discourse.vtk.org/t/cmake-error-with-external-freetype/13138/8 "2024-02-07T20:59:33Z")

</div>

This is because the target name for `VTK::freetype` is `freetype` internally. Fixing [this issue](https://gitlab.kitware.com/vtk/vtk/-/issues/17679) would resolve it. I suppose it is higher priority now.
