cpm-cmake / CPM.cmake

📦 CMake's missing package manager. A small CMake script for setup-free, cross-platform, reproducible dependency management.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Add support for ExternalProject_Add() / libjpeg

tehKaiN opened this issue · comments

commented

Hi,

I tried incorporating https://github.com/libjpeg-turbo/libjpeg-turbo into my project with CPM, but failed miserably. I'd create that issue on their repository, but they're not really into changing state of their CMakeLists.txt, to the point that following:

CPMAddPackage(
	NAME JPG
	GIT_REPOSITORY https://github.com/libjpeg-turbo/libjpeg-turbo
	GIT_TAG 3.0.2
)

gives following custom-written error:

[cmake] CMake Error at build/_deps/jpg-src/CMakeLists.txt:59 (message):
[cmake]   The libjpeg-turbo build system cannot be integrated into another build
[cmake]   system using add_subdirectory().  Use ExternalProject_Add() instead.

Also their BUILDING.md has same note and searching for issues relating to it gives wontfix vibes.

Typically, I'd just ignore their unwillingness for cooperation and use other JPG library, like the stb-jpeg, but some other libraries I'm using can detect libjpeg and use it for extended features (e.g. libtiff).

So, is there support for ExternalProject_Add() planned? I know that I can call that CMake thingy directly, and that's probably what I'm going to do, but having CPM as unified interface for all the package kinds would be great!

I think probably not, as ExternalProject_Add uses a very different mechanism for fetching and building dependencies. Most importantly, afaik it wont forward toolchains and can lead to duplicate dependencies when to dependencies have the same sub-dependency.

See this comment:

Downstream projects that wish to integrate libjpeg-turbo as a subdirectory should either use ExternalProject_Add() or make downstream modifications to the libjpeg-turbo build system to suit their specific needs.

The right answer for you, @tehKaiN, is to figure out what changes you need to make to the CMakeLists.txt file to allow it's incorporation into your project and then maintain a patch. That's what patches are for in a Package Manager after all! :-)

Basically, you'll fork the jpeg-turbo project, set CPM to your fork, and then fiddle with it until you get a good build. After that you create the patches and incorporate them using PATCH_COMMAND. You can check out PR #558 for a slightly easier way to add patches, but it also has code to find the patch executable.

And when you do get this working with CPM, add a PR with the example!

I recommend closing this issue.

commented

I went with https://github.com/csparker247/jpeg-cmake/ which skipped all those extra steps. I'd probably do what you suggest, but quite recently the decision was made to scrap jpeg format support in my project, so I don't need it anymore.

Thanks for tips, though!