[poppler] Using Poppler as a subproject from a CMake project

Bilal Durrani bilal33 at hotmail.com
Sat Sep 18 20:47:49 UTC 2021


I'm new to CMake to I'm not sure what I'm doing.


I'm using poppler as a library via CMake for my application. I've imported it as a submodule.


If I include popper in my top-level CMake file using add_subdirectory(...), it gets the following errors

[cmake] CMake Error at external/poppler/CMakeLists.txt:7 (include):
[cmake]   include could not find requested file:
[cmake]
[cmake]     PopplerDefaults
[cmake]
[cmake]
[cmake] CMake Error at external/poppler/CMakeLists.txt:8 (include):


This is most likely because the CMAKE_MODULE_PATH is incorrect.


After some digging, it looks like poppler is setting the module path instead of appending to it.

https://gitlab.freedesktop.org/poppler/poppler/-/blob/master/CMakeLists.txt#L5


So I can't really override it.


My (probably overly complicated) setup is here, which the poppler line commented out. https://github.com/bdurrani/cmake-test/blob/master/CMakeLists.txt#L69


This works fine if I run cmake from within the poppler folder.

Are there any examples of consuming the poppler build from another CMake project?

I did tweak the CMake file to use list APPEND​ instead of set, but that triggers other path issues

```
[cmake] CMake Error at external/poppler/utils/CMakeLists.txt:39 (add_executable):
[cmake]   Cannot find source file:
[cmake]
[cmake]     /home/bdurrani/deletethis/cmake-test/poppler/CairoFontEngine.cc
[cmake]
[cmake]   Tried extensions .c .C .c++ .cc .cpp .cxx .cu .mpp .m .M .mm .ixx .cppm .h
[cmake]   .hh .h++ .hm .hpp .hxx .in .txx .f .F .for .f77 .f90 .f95 .f03 .hip .ispc
```

Thanks for your help!
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.freedesktop.org/archives/poppler/attachments/20210918/fafc800b/attachment.htm>


More information about the poppler mailing list