# Alternative entry points down in the directory hierarchy

**URL:** https://discourse.cmake.org/t/alternative-entry-points-down-in-the-directory-hierarchy/15342
**Category:** Usage
**Created:** [November 24, 2025, 6:32pm UTC](https://discourse.cmake.org/t/alternative-entry-points-down-in-the-directory-hierarchy/15342 "2025-11-24T18:32:21Z")
**Posts on this page:** 1
**Page:** 1

<div class="post-metadata">

### Author: ![alexshpilkin](https://discourse.cmake.org/user_avatar/discourse.cmake.org/alexshpilkin/32/5920_2.png) [@alexshpilkin](https://discourse.cmake.org/u/alexshpilkin)
#### Post date: [November 24, 2025, 6:32pm UTC](https://discourse.cmake.org/t/alternative-entry-points-down-in-the-directory-hierarchy/15342/1 "2025-11-24T18:32:21Z")

</div>

Suppose I have the following directory hierarchy:

```plaintext
include/
    <common utility headers>
src/
    aexe/
        <sources and private headers of aexe>
    bexe/
        <sources and private headers of bexe>
    clib/
        <headers for clib>
        src/
            <sources and private headers of clib>
    dlib/
        <headers for dlib>
        src/
            <sources and private headers of dlib>

```

Here the libraries are not really exported to the outside world, but can be used by each other and the executables with no particular restrictions other than keeping it acyclic (and even that not entirely, to my chagrin).

My plan for a build system is to have a `CMakeLists.txt` at the root and for each executable and library, and collect the targets from all of them inside the root file, so if you want a single executable you still configure the whole thing and then just ask for the target you want.

However, both developers and existing CI configuration expect to be able to configure inside e.g. `aexe` and to get only that executable as a result. (I don’t want to describe the current CMake build system, let’s leave it at that.) Is there a way to have that happen, too, at least as an interim solution? My impression is that it could be arranged by testing for `PROJECT_IS_TOP_LEVEL` or the like, but try as I might I haven’t been able to determine what the implications are of having a sub`project()` rather than a plain `add_subdirectory()` and whether I could take advantage of them to get what I want. Anyways, that still wouldn’t solve everything as it seems that I essentially want to pull in the top level from the children `CMakeLists.txt` but then only expose a trimmed-down `all`, if and only if the child was configured directly (“compatibility mode”), but do the usual things if it’s instead pulled in as a subdirectory from the root (including recursively when the root has been initially pulled in by the child in “compatibility mode”).
