# Retrieving imported preprocessor definition

**URL:** https://discourse.cmake.org/t/retrieving-imported-preprocessor-definition/4342
**Category:** Usage
**Created:** [October 26, 2021, 7:11am UTC](https://discourse.cmake.org/t/retrieving-imported-preprocessor-definition/4342 "2021-10-26T07:11:16Z")
**Posts on this page:** 1
**Showing post:** 2

<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: [October 26, 2021, 7:43am UTC](https://discourse.cmake.org/t/retrieving-imported-preprocessor-definition/4342/2 "2021-10-26T07:43:29Z")

</div>

My issue may be a bit more complicated than anticipated and related to another issue: [Findmodule transitivity?](https://discourse.cmake.org/t/findmodule-transitivity/4333)  
What I want exactly do is:  
L may depend on a third party library TP that is not properly packaged.  
If L uses TP, it imports TP with a FindTP.cmake file and defines a compile definition TPNEEDED

What I’d like to do is, when, in A, I find\_package(L) then TP is automatically linked with A, but only if L actually needed TP.

the FindTP.cmake does not seem to be used “transitively”, and I can’t retrieve if TPNEEDED is defined so far. Besides, I suppose that it may be only defined after find\_package(L) that will generate an error because TP is not found, before I can do anything about it.

Thus, what would be the proper way to manage this optional dependency?

Thanks,  
A.

---

_[View the full topic](https://discourse.cmake.org/t/retrieving-imported-preprocessor-definition/4342)._
