Ninja and ExternalProject_Add

Hello!
In my project grok, I add libjpeg-turbo dependency via
ExternalProject_Add. Here are the relevant lines:

  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.

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

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!

1 Like

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.

1 Like