Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add support for ExternalProject_Add() / libjpeg #550

Closed
tehKaiN opened this issue Mar 17, 2024 · 3 comments
Closed

Add support for ExternalProject_Add() / libjpeg #550

tehKaiN opened this issue Mar 17, 2024 · 3 comments

Comments

@tehKaiN
Copy link

tehKaiN commented Mar 17, 2024

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!

@TheLartians
Copy link
Member

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.

@ScottBailey
Copy link
Contributor

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.

@tehKaiN
Copy link
Author

tehKaiN commented Apr 26, 2024

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!

@tehKaiN tehKaiN closed this as completed Apr 26, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants