# Ninja and ExternalProject\_Add

**URL:** https://discourse.cmake.org/t/ninja-and-externalproject-add/9590
**Category:** Code
**Created:** [December 8, 2023, 11:45pm UTC](https://discourse.cmake.org/t/ninja-and-externalproject-add/9590 "2023-12-08T23:45:16Z")
**Posts on this page:** 2
**Page:** 1

<div class="post-metadata">

### Author: ![boxerab](https://discourse.cmake.org/user_avatar/discourse.cmake.org/boxerab/32/718_2.png) [@boxerab](https://discourse.cmake.org/u/boxerab)
#### Post date: [December 8, 2023, 11:45pm UTC](https://discourse.cmake.org/t/ninja-and-externalproject-add/9590/1 "2023-12-08T23:45:16Z")

</div>

Hello!  
In my project [grok](https://github.com/GrokImageCompression/grok), I add libjpeg-turbo dependency via  
`ExternalProject_Add`. Here are the relevant lines:

```auto
  ExternalProject_Add(libjpeg-turbo
                      CMAKE_ARGS
                        -DENABLE_SHARED=OFF
                        -DENABLE_STATIC=ON
                        -DCMAKE_INSTALL_PREFIX=${CMAKE_CURRENT_BINARY_DIR}/libjpeg-turbo
                        -DCMAKE_INSTALL_LIBDIR=${CMAKE_CURRENT_BINARY_DIR}/bin
                        -DCMAKE_POSITION_INDEPENDENT_CODE=ON
                        -DWITH_TURBOJPEG=0
  				      GIT_REPOSITORY https://github.com/libjpeg-turbo/libjpeg-turbo.git
  					  GIT_TAG 2.1.5.1)

```

which can be found [here](https://github.com/GrokImageCompression/grok/blob/master/thirdparty/CMakeLists.txt#L23).

This works fine with make generator, but with ninja, it errors out with

```auto
ninja -v -j12 -l12
ninja: error: 'thirdparty/bin/libjpeg.a', needed by 'bin/libgrokj2kcodec.so.11.0.0', missing and no known rule to make it

```

Even if I add a BUILD\_BYPRODUCTS entry, it still fails to run cmake configuration on the libjpeg-turbo source folder. Any advice on what I am missing ?

Thanks!

---

<div class="post-metadata">

### Author: ![ben.boeckel](https://discourse.cmake.org/letter_avatar_proxy/v4/letter/b/ea5d25/32.png) [@ben.boeckel](https://discourse.cmake.org/u/ben.boeckel)
#### Post date: [December 11, 2023, 3:47pm UTC](https://discourse.cmake.org/t/ninja-and-externalproject-add/9590/2 "2023-12-11T15:47:16Z")

</div>

Mixing `ExternalProject` with “normal” targets is not well supported. I would suggest using `FetchContent` or using `find_package` and using a superbuild to drive the builds using `ExternalProject` for each.
