# CMake is working wierdly in terms of searching and adding libraries

**URL:** https://discourse.cmake.org/t/cmake-is-working-wierdly-in-terms-of-searching-and-adding-libraries/15399
**Category:** Usage
**Tags:** os:linux, gen:makefiles
**Created:** [December 13, 2025, 9:46am UTC](https://discourse.cmake.org/t/cmake-is-working-wierdly-in-terms-of-searching-and-adding-libraries/15399 "2025-12-13T09:46:57Z")
**Posts on this page:** 3
**Page:** 1

<div class="post-metadata">

### Author: ![soumyadghosh](https://discourse.cmake.org/letter_avatar_proxy/v4/letter/s/9fc348/32.png) [@soumyadghosh](https://discourse.cmake.org/u/soumyadghosh)
#### Post date: [December 13, 2025, 9:46am UTC](https://discourse.cmake.org/t/cmake-is-working-wierdly-in-terms-of-searching-and-adding-libraries/15399/1 "2025-12-13T09:46:58Z")

</div>

I am building `openboard` from source, with an SDK for Qt libraries and building `poppler` from the latest release. Now, while compiling `openboard` it looks for poppler and finds the correct `poppler==25.12` using `pkg-config`which is located in `/root/stage/usr/include/poppler`. The SDK also contains an installaton of `poppler==24.02`. From [PR](https://github.com/OpenBoard-org/OpenBoard/pull/1387)#1387 at openboard,

> Poppler 25.12 allows string\_view and char\* for GooString. QByteArray can be converted to both, so choose one explicitly to avoid the “call of overloaded ‘GooString(QByteArray)’ is ambiguous” error:  
> ```  
> /build/openboard-git/src/OpenBoard/src/pdf/XPDFRenderer.cpp:65:55: required from here  
> 65 | mDocument = new PDFDoc(std::make\_unique(filename.toLocal8Bit()));  
> | ~~~^~~~  
> /usr/include/c++/15.2.1/bits/unique\_ptr.h:1084:30: error: call of overloaded ‘GooString(QByteArray)’ is ambiguous  
> 1084 | { return unique\_ptr\<\_Tp\>(new \_Tp(std::forward\<\_Args\>(\_\_args)…)); }  
> | ^ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~  
> /usr/include/c++/15.2.1/bits/unique\_ptr.h:1084:30: note: there are 9 candidates  
> In file included from /usr/include/poppler/Object.h:46,  
> from /build/openboard-git/src/OpenBoard/src/pdf/XPDFRenderer.h:41:  
> /usr/include/poppler/goo/GooString.h:91:14: note: candidate 1: ‘GooString::GooString(std::string\_view)’  
> 91 | explicit GooString(std::string\_view str) : std::string(str) { }  
> | ^ ~~~~~~~~  
> /usr/include/poppler/goo/GooString.h:73:14: note: candidate 2: ‘GooString::GooString(const char\*)’  
> 73 | explicit GooString(const char \*sA) : std::string(sA ? sA : “”) { }  
> | ^ ~~~~~~~~  
> ```

Now, when compiling here in my case, openboard is picking the goo libraries from `/root/stage/usr/include/poppler/goo` for the new headers of GooString, but when needing to look for `poppler-version.h`it is fallbacking and reading version `24.02` which is served by the SDK. Why is this happening? I did make sure that the `CMAKE_PREIFX_PATH=/root/stage/usr:/snap/kde-qt6-core24-sdk/current/usr:/snap/kf6-core24-sdk/current/usr:/usr:/root/stage` which makes sure that the `/root/stage/usr` prefixed is looked into first. Then why is this anomoly showing up? Can someone kindly help me figure this problem out and understand CMake properly?

EDIT: I treid this with CMake 4.2.1 also, and it is still the same

---

<div class="post-metadata">

### Author: ![soumyadghosh](https://discourse.cmake.org/letter_avatar_proxy/v4/letter/s/9fc348/32.png) [@soumyadghosh](https://discourse.cmake.org/u/soumyadghosh)
#### Post date: [December 13, 2025, 3:11pm UTC](https://discourse.cmake.org/t/cmake-is-working-wierdly-in-terms-of-searching-and-adding-libraries/15399/2 "2025-12-13T15:11:11Z")

</div>

To shed some light on the possible fix, the pkg-config from poppler has cflags which adds the custom installation prefix only upto `/root/stage/usr/include/poppler` but doesn’t add `/root/stage/usr/include`. From [here](https://github.com/OpenBoard-org/OpenBoard/blob/master/src/pdf/XPDFRenderer.cpp#L35), if I remove the `poppler` from the include definition, i.e changing

```cpp
#include <poppler/cpp/poppler-version.h>

```

to

```cpp
#include <cpp/poppler-version.h>

```

fixes the search path.

For now, I am adding `-I/root/stage/usr/include` in `DCMAKE_C_FLAGS` and `DCMAKE_CXX_FLAGS`.

---

<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: [February 9, 2026, 5:18am UTC](https://discourse.cmake.org/t/cmake-is-working-wierdly-in-terms-of-searching-and-adding-libraries/15399/3 "2026-02-09T05:18:27Z")

</div>

Whatever is providing the poppler include paths needs to search for `poppler/cpp/poppler-version.h` instead of looking in `poppler` directories for `cpp/poppler-version.h`. The bits given to `find_file(NAMES)` are the bits that are expected to be used in include directives.
