# How to set option to a library but only when used by examples

**URL:** https://discourse.cmake.org/t/how-to-set-option-to-a-library-but-only-when-used-by-examples/481
**Category:** Code
**Created:** [January 11, 2020, 2:12pm UTC](https://discourse.cmake.org/t/how-to-set-option-to-a-library-but-only-when-used-by-examples/481 "2020-01-11T14:12:39Z")
**Posts on this page:** 1
**Showing post:** 2

<div class="post-metadata">

### Author: ![erk](https://discourse.cmake.org/user_avatar/discourse.cmake.org/erk/32/114_2.png) [@erk](https://discourse.cmake.org/u/erk)
#### Post date: [January 13, 2020, 10:27pm UTC](https://discourse.cmake.org/t/how-to-set-option-to-a-library-but-only-when-used-by-examples/481/2 "2020-01-13T22:27:23Z")

</div>

Did you read that topic: [Is target specific stuff transitive to dependencies?](https://discourse.cmake.org/t/is-target-specific-stuff-transitive-to-dependencies/336/8)  
AFAIU you seem to pursue a similar functional goal: _compiling a library depending on its usage_.

---

_[View the full topic](https://discourse.cmake.org/t/how-to-set-option-to-a-library-but-only-when-used-by-examples/481)._
