# Difficulties using a third-party cmake projects: missing \<package\>\_INCLUDE\_DIR(S) (and other)

**URL:** <https://discourse.cmake.org/t/difficulties-using-a-third-party-cmake-projects-missing-package-include-dir-s-and-other/15298>\
**Category:** Code\
**Created:** [November 12, 2025, 7:04pm UTC](https://discourse.cmake.org/t/difficulties-using-a-third-party-cmake-projects-missing-package-include-dir-s-and-other/15298 "2025-11-12T19:04:14Z")\
**Posts on this page:** 9\
**Page:** 1

<div class="post-metadata">

**Author:** ![adaldev](https://discourse.cmake.org/letter_avatar_proxy/v4/letter/a/9dc877/32.png) [@adaldev](https://discourse.cmake.org/u/adaldev)\
**Post date:** [November 12, 2025, 7:04pm UTC](https://discourse.cmake.org/t/difficulties-using-a-third-party-cmake-projects-missing-package-include-dir-s-and-other/15298/1 "2025-11-12T19:04:14Z")

</div>

I’m trying to use a library named Alglib which has no CMake support. Such support is provided here: [https://github.com/S-Dafarra/alglib-cmake](https://github.com/S-Dafarra/alglib-cmake).

My issue is that it generates a target `Alglib` without namespace and, in my own framework I expect only dependencies in the form `package::component`. Whenever I’m finding a target without namespace, I create a fake (`INTERFACE IMPORTED`) configuring it from the original target `_INCLUDE_DIR(S)` and `LIBRARY` or `LIBRARIES`. This strategy has worked, so far, with all third-party library I encountered.

But in the case of `alglib-cmake` it seems that none of these variables exists and I don’t get why.

So far my obvious workaround has been to modify the provided CMakeLists.txt to create `Alglib::Alglib` but I’d like to understand why I don’t get the expected variables and if I should adapt my strategy for this situation (and how).

Thanks in advance, regards,

A.

---

<div class="post-metadata">

**Author:** ![fenrir](https://discourse.cmake.org/user_avatar/discourse.cmake.org/fenrir/32/734_2.png) [@fenrir](https://discourse.cmake.org/u/fenrir)\
**Post date:** [November 13, 2025, 6:29am UTC](https://discourse.cmake.org/t/difficulties-using-a-third-party-cmake-projects-missing-package-include-dir-s-and-other/15298/2 "2025-11-13T06:29:57Z")

</div>

Why not use an `ALIAS` library instead?

[https://cmake.org/cmake/help/latest/command/add\_library.html#alias-libraries](https://cmake.org/cmake/help/latest/command/add_library.html#alias-libraries)

---

<div class="post-metadata">

**Author:** ![adaldev](https://discourse.cmake.org/letter_avatar_proxy/v4/letter/a/9dc877/32.png) [@adaldev](https://discourse.cmake.org/u/adaldev)\
**Post date:** [November 13, 2025, 8:11am UTC](https://discourse.cmake.org/t/difficulties-using-a-third-party-cmake-projects-missing-package-include-dir-s-and-other/15298/3 "2025-11-13T08:11:01Z")

</div>

Hi

I wanted to enforce the format `package::component`. Does `ALIAS` allows something like `add_library(Alglib::Alglib ALIAS Alglib)`?. In this case it will simplify a great lot my wrapping 🙂 .

Regards,

A.

---

<div class="post-metadata">

**Author:** ![fenrir](https://discourse.cmake.org/user_avatar/discourse.cmake.org/fenrir/32/734_2.png) [@fenrir](https://discourse.cmake.org/u/fenrir)\
**Post date:** [November 13, 2025, 1:16pm UTC](https://discourse.cmake.org/t/difficulties-using-a-third-party-cmake-projects-missing-package-include-dir-s-and-other/15298/4 "2025-11-13T13:16:22Z")

</div>

Yes, it does. I’m using this feature extensively.

---

<div class="post-metadata">

**Author:** ![adaldev](https://discourse.cmake.org/letter_avatar_proxy/v4/letter/a/9dc877/32.png) [@adaldev](https://discourse.cmake.org/u/adaldev)\
**Post date:** [November 13, 2025, 2:24pm UTC](https://discourse.cmake.org/t/difficulties-using-a-third-party-cmake-projects-missing-package-include-dir-s-and-other/15298/5 "2025-11-13T14:24:27Z")

</div>

Thanks a lot.  
I’m trying something like:

```cmake
# ${CompName} is set to ${PackName} by default
# ${TargetName} the target that will link ${PackName}
# ${Inheritance} is one of PUBLIC/PRIVATE/INTERFACE
if(NOT(${PackName}_FOUND))
	# No one has called find_package previously
	find_package(${PackName} REQUIRED)
endif()
# ${CompName} is set to ${PackName} by default
if(${PackName}_FOUND AND NOT TARGET ${PackName}::${CompName})
	message("${PackName} found")
	add_library(${PackName}::${PackName} ALIAS ${PackName})
	target_link_libraries(${TargetName} ${Inheritance} ${PackName}::${PackName})
endif()

```

But, for instance, with `OpenSSL` as `${PackName}`, I’m getting

> OpenSSL found

Then an error on `add_library`:

> add\_library cannot create ALIAS target “OpenSSL::OpenSSL” because target  
> “OpenSSL” does not already exist

What am I missing?

---

<div class="post-metadata">

**Author:** ![fenrir](https://discourse.cmake.org/user_avatar/discourse.cmake.org/fenrir/32/734_2.png) [@fenrir](https://discourse.cmake.org/u/fenrir)\
**Post date:** [November 13, 2025, 3:23pm UTC](https://discourse.cmake.org/t/difficulties-using-a-third-party-cmake-projects-missing-package-include-dir-s-and-other/15298/6 "2025-11-13T15:23:01Z")

</div>

`find_package(OpenSSL)` creates two targets for me: `OpenSSL::Crypto` and `OpenSSL::SSL`

---

<div class="post-metadata">

**Author:** ![adaldev](https://discourse.cmake.org/letter_avatar_proxy/v4/letter/a/9dc877/32.png) [@adaldev](https://discourse.cmake.org/u/adaldev)\
**Post date:** [November 13, 2025, 3:28pm UTC](https://discourse.cmake.org/t/difficulties-using-a-third-party-cmake-projects-missing-package-include-dir-s-and-other/15298/7 "2025-11-13T15:28:08Z")

</div>

ah maybe. It’s a situation I didn’t think about.  
I’ll check and if it’s the case I’ll need a different strategy:  
Is there a way to enumerate the components found and merge them into a single one? (ie merging `OpenSSL::Crypto` and `OpenSSL::SSL` into `OpenSSL::OpenSSL`).

Thanks again for your precious help.

---

<div class="post-metadata">

**Author:** ![fenrir](https://discourse.cmake.org/user_avatar/discourse.cmake.org/fenrir/32/734_2.png) [@fenrir](https://discourse.cmake.org/u/fenrir)\
**Post date:** [November 14, 2025, 7:49am UTC](https://discourse.cmake.org/t/difficulties-using-a-third-party-cmake-projects-missing-package-include-dir-s-and-other/15298/8 "2025-11-14T07:49:17Z")

</div>

Well… Maybe something like this (untested)?

```cmake
get_property(importedTargets DIRECTORY "${CMAKE_SOURCE_DIR}" PROPERTY IMPORTED_TARGETS)

find_package(OpenSSL REQUIRED)

get_property(importedTargetsAfter DIRECTORY "${CMAKE_SOURCE_DIR}" PROPERTY IMPORTED_TARGETS)
list(REMOVE_ITEM importedTargetsAfter ${importedTargets})

add_library(OpenSSL::OpenSSL INTERFACE)
target_link_libraries(OpenSSL::OpenSSL INTERFACE ${importedTargetsAfter})

```

You’ll probably have to play around with that to get what you want.  
Otherwise I typically just get the possible targets from the documentation and give up on automatic discovery.

---

<div class="post-metadata">

**Author:** ![adaldev](https://discourse.cmake.org/letter_avatar_proxy/v4/letter/a/9dc877/32.png) [@adaldev](https://discourse.cmake.org/u/adaldev)\
**Post date:** [November 17, 2025, 10:30am UTC](https://discourse.cmake.org/t/difficulties-using-a-third-party-cmake-projects-missing-package-include-dir-s-and-other/15298/9 "2025-11-17T10:30:45Z")

</div>

Thanks Jakub. Mixing your proposal and [mistral codestral’s one](https://mistral.ai/fr/news/codestral) I’m getting:

```cmake
get_property(ImportedTargets DIRECTORY "${CMAKE_SOURCE_DIR}" PROPERTY IMPORTED_TARGETS)
list(FILTER ImportedTargets INCLUDE REGEX "^${PackName}::")

if(ImportedTargets)

	# Creating the main component
	add_library(${PackName}::${PackName} INTERFACE IMPORTED)
	# Adding the found components as dependencies
	if(ImportedTargets)
		target_link_libraries(${PackName}::${PackName} INTERFACE ${ImportedTargets})
	endif()

endif()

```
