# what's the meaing of this sentence?

**URL:** https://discourse.cmake.org/t/whats-the-meaing-of-this-sentence/15735
**Category:** Usage
**Created:** [July 5, 2026, 7:55am UTC](https://discourse.cmake.org/t/whats-the-meaing-of-this-sentence/15735 "2026-07-05T07:55:29Z")
**Posts on this page:** 3
**Page:** 1

<div class="post-metadata">

### Author: ![yushang](https://discourse.cmake.org/user_avatar/discourse.cmake.org/yushang/32/4574_2.png) [@yushang](https://discourse.cmake.org/u/yushang)
#### Post date: [July 5, 2026, 7:55am UTC](https://discourse.cmake.org/t/whats-the-meaing-of-this-sentence/15735/1 "2026-07-05T07:55:29Z")

</div>

Hi guys,

in this page [https://cmake.org/cmake/help/latest/command/set\_directory\_properties.html](https://cmake.org/cmake/help/latest/command/set_directory_properties.html) there is a sentence

`Sets properties of the current directory and its subdirectories in key-value pairs.`

I’m trying to verify it by (in parent `CMakeLists.txt`)

```auto
set_directory_properties(PROPERTIES prop1 value1)
add_subdirectory(sub)

```

and

```auto
add_subdirectory(sub)
set_directory_properties(PROPERTIES prop1 value1)

```

in `sub/CMakeLists.txt`

```auto
get_directory_property(x prop1)
message("prop1 `${x}`")

```

in both case I cannot read `prop1` , any suggestion?

---

<div class="post-metadata">

### Author: ![ferdnyc](https://discourse.cmake.org/user_avatar/discourse.cmake.org/ferdnyc/32/267_2.png) [@ferdnyc](https://discourse.cmake.org/u/ferdnyc)
#### Post date: [July 7, 2026, 7:52am UTC](https://discourse.cmake.org/t/whats-the-meaing-of-this-sentence/15735/2 "2026-07-07T07:52:14Z")

</div>

OK, so it turns out that statement is a bit misleading.

CMake _will_ propagate _ **some** _ properties to subdirectories, but only when they are:

1. on the list of Properties on Directories (i.e. not the ones you define yourself)
2. Not documented as read-only, on that list
3. And, documented as also affecting subdirectories, on that list

[LABELS](https://cmake.org/cmake/help/latest/prop_dir/LABELS.html), for example, is documented as allowing you to:

> Specify a list of text labels associated with a directory and all of its subdirectories.

So, if you run this in a parent directory (BEFORE the `add_subdirectory()`, that part’s important):

```cmake
set_directory_properties(PROPERTIES
    CLEAN_NO_CUSTOM TRUE
    LABELS "test"
    MY_SPECIAL_PROP "is a special prop"
)
add_subdirectory(sub)

```

Then, in your subdirectory `LABELS`will be set, but neither `CLEAN_NO_CUSTOM` nor `MY_SPECIAL_PROP` will be.

The list of propagated directory properties is actually very short, `LABELS` is the only one I’ve found so far.

Note that you _can_ also set properties on subdirectories, **directly** , using `set_property()`:

```cmake
# In the root CMakeLists.txt
add_subdirectory(sub)
set_property(DIRECTORY sub
  PROPERTY
    CLEAN_NO_CUSTOM TRUE
)

```

Then, `CLEAN_NO_CUSTOM` will be set in `sub/`. Note that in that case, though, the `set_property()` has to come **after** the `add_subdirectory()`.

---

<div class="post-metadata">

### Author: ![ferdnyc](https://discourse.cmake.org/user_avatar/discourse.cmake.org/ferdnyc/32/267_2.png) [@ferdnyc](https://discourse.cmake.org/u/ferdnyc)
#### Post date: [July 7, 2026, 8:10am UTC](https://discourse.cmake.org/t/whats-the-meaing-of-this-sentence/15735/3 "2026-07-07T08:10:02Z")

</div>

Aha! You can, however, create your own properties that will be propagated to subdirectories, using `define_property()` with the `INHERITED` argument.

```auto
define_property(DIRECTORY
  PROPERTY MY_SPECIAL_PROP
  INHERITED
  BRIEF_DOCS "A propagated special property"
)
set_directory_properties(PROPERTIES
  LABELS "test"
  MY_SPECIAL_PROP "is a special prop"
)
add_subdirectory(sub)

```

…Will result in `MY_SPECIAL_PROP` being set in `sub/` as well.

(Interestingly, the documentation for `INHERITED` describes it as working in completely the opposite way — it’s not that `MY_SPECIAL_PROP` will _also be set_ in `sub/` when you set it at the root level, it’s that **requests** for `MY_SPECIAL_PROP` in `sub/` will automatically look for properties in the parent scope when they’re not defined in the current scope, as long as they’re marked `INHERITED`.

I don’t know if that really means `INHERITED` properties are different from the propagating ones like `LABELS`, or if `LABELS` is also an `INHERITED` property that’s just described more simplistically in the documentation. I also don’t know if it really makes any practical difference whether they work the same way or not.)
