# About compilation flags with CMAKE

**URL:** <https://forum.juce.com/t/about-compilation-flags-with-cmake/68175>\
**Category:** CMake\
**Created:** [February 12, 2026, 6:18am UTC](https://forum.juce.com/t/about-compilation-flags-with-cmake/68175 "2026-02-12T06:18:41Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![nicolasdanet](https://sea2.discourse-cdn.com/flex026/user_avatar/forum.juce.com/nicolasdanet/32/56_2.png) [@nicolasdanet](https://forum.juce.com/u/nicolasdanet)\
**Post date:** [February 12, 2026, 6:18am UTC](https://forum.juce.com/t/about-compilation-flags-with-cmake/68175/1 "2026-02-12T06:18:41Z")

</div>

New to CMAKE i need an enlightenment. 🥴

> target\_link\_libraries(AppExample  
> PRIVATE  
> juce::juce\_core  
> my::module  
> PUBLIC  
> juce::juce\_recommended\_config\_flags  
> juce::juce\_recommended\_warning\_flags)

1. Is that linking with `PUBLIC` `juce::juce_recommended_config_flags` target implies that sibling `PRIVATE` JUCE modules use those flags at compilation?
2. Is the flags are applied also for `my::module` (added with `juce_add_module`)?

Thanks.

---

<div class="post-metadata">

**Author:** ![benvining](https://sea2.discourse-cdn.com/flex026/user_avatar/forum.juce.com/benvining/32/9922_2.png) [@benvining](https://forum.juce.com/u/benvining)\
**Post date:** [February 12, 2026, 7:12am UTC](https://forum.juce.com/t/about-compilation-flags-with-cmake/68175/2 "2026-02-12T07:12:34Z")

</div>

This one isn’t a simple yes/no answer because JUCE modules are “interface libraries”. Let me first provide an example with a “normal” library:

```auto
add_library (foo STATIC)

add_executable (bar main.cpp)

target_compile_options (bar PRIVATE -ffoo -wbar)

target_link_libraries (bar PRIVATE foo)

```

In the above example, _only_ the `bar` executable’s source files (ie `main.cpp`) will be compiled with the `-ffoo -wbar` flags, the compilation of static/shared libraries that the executable links will not be affected by those flags.

_However_, the way interface libraries work is that their source files are basically added to your target as if they belong to your target. The canonical use case is header-only libraries, but it’s legal to have cpp files in interface libraries too, which is what JUCE modules do. So the module source files are compiled as part of your target, meaning they inherit any flags your target has set on it.

To answer your specific questions, the sources for all juce modules added to `AppExample` will be compiled using the `juce_recommended_config_flags` and `juce_recommended_warning_flags`.

---

<div class="post-metadata">

**Author:** ![nicolasdanet](https://sea2.discourse-cdn.com/flex026/user_avatar/forum.juce.com/nicolasdanet/32/56_2.png) [@nicolasdanet](https://forum.juce.com/u/nicolasdanet)\
**Post date:** [February 12, 2026, 7:25am UTC](https://forum.juce.com/t/about-compilation-flags-with-cmake/68175/3 "2026-02-12T07:25:10Z")

</div>

> [@benvining](#):
>
> So the module source files are compiled as part of your target, meaning they inherit any flags your target has set on it.

Ok, so my assumption was (of course) wrong (anyway it would have been weird to have dependencies with sibling stuff). I thought that modules were built first then linked (and I couldn’t find any compilations options in JUCE’s `.cmake` machinery). I understand now! 😆

Thanks!
