# how to exclude the compile definitions inherited from the linked library

**URL:** <https://discourse.cmake.org/t/how-to-exclude-the-compile-definitions-inherited-from-the-linked-library/8694>\
**Category:** Code\
**Created:** [August 8, 2023, 9:04am UTC](https://discourse.cmake.org/t/how-to-exclude-the-compile-definitions-inherited-from-the-linked-library/8694 "2023-08-08T09:04:29Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![Malaz99](https://discourse.cmake.org/letter_avatar_proxy/v4/letter/m/3ab097/32.png) [@Malaz99](https://discourse.cmake.org/u/Malaz99)\
**Post date:** [August 8, 2023, 9:04am UTC](https://discourse.cmake.org/t/how-to-exclude-the-compile-definitions-inherited-from-the-linked-library/8694/1 "2023-08-08T09:04:29Z")

</div>

The find\_package command automatically sets up the necessary preprocessor definitions, and also sets up other configurations for its linked target.

I want a way to exclude some compile definitions inherited from the linked library.

**Example:**

**CMakelists.txt**

cmake\_minimum\_required(VERSION 3.27)

project(qt\_opengl\_test)

find\_package(Qt6 COMPONENTS OpenGL OpenGLWidgets REQUIRED QUIET)

link\_libraries(Qt6::OpenGL Qt6::OpenGLWidgets)

add\_executable(“proj1” main.cpp)

Qt OpenGL adds (WIN32, \_ENABLE\_EXTENDED\_ALIGNED\_STORAGE, WIN64, and \_WIN64) compile definitions to Proj1, how can I prevent this from happening?

 ![](https://discourse.cmake.org/uploads/default/original/2X/e/e91ad3bdfcbd79c0ed0885a2575ca20058784ad0.png)

---

<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:** [August 8, 2023, 1:37pm UTC](https://discourse.cmake.org/t/how-to-exclude-the-compile-definitions-inherited-from-the-linked-library/8694/2 "2023-08-08T13:37:59Z")

</div>

No, there’s no way to drop them (without also dropping `-I` flags by wrapping the target in `$<LINK_ONLY>`). File [an issue with Qt](https://bugreports.qt.io/) to not add those as `PUBLIC` compile definitions.
