# Generator expression for project name?

**URL:** https://discourse.cmake.org/t/generator-expression-for-project-name/15857
**Category:** Code
**Created:** [September 30, 2026, 3:41pm UTC](https://discourse.cmake.org/t/generator-expression-for-project-name/15857 "2026-09-30T15:41:09Z")
**Posts on this page:** 1
**Page:** 1

<div class="post-metadata">

### Author: ![CsatiZoltan](https://discourse.cmake.org/user_avatar/discourse.cmake.org/csatizoltan/32/5488_2.png) [@CsatiZoltan](https://discourse.cmake.org/u/CsatiZoltan)
#### Post date: [September 30, 2026, 3:41pm UTC](https://discourse.cmake.org/t/generator-expression-for-project-name/15857/1 "2026-09-30T15:41:09Z")

</div>

I use the superbuild approach to build and install dependencies with `ExternalProject_Add`. Since I have some common CMake options, I factor them out in the main CMakeLists.txt. For instance, to install the dependencies in a common directory _install/_, and within that directory under the subdirectory based on the project name, I add

```auto
"-DCMAKE_INSTALL_PREFIX=${CMAKE_SOURCE_DIR}/install/$<PROJECT_NAME>"

```

to `CMAKE_ARGS`, expecting an install tree like this:

```auto
${CMAKE_SOURCE_DIR}
|- install
| |- depencency1 # the name depencency1 deduced from PROJECT_NAME
| | |- ... # installed artifacts
| |- ...
| |- dependencyN # the name depencencyN deduced from PROJECT_NAME
| | |- ... # installed artifacts

```

Unfortunately, `PROJECT_NAME` is not accepted as a generator expression.  
How can I achieve the desired install tree structure above?  
An alternative is to add

```auto
"-DCMAKE_INSTALL_PREFIX=${CMAKE_SOURCE_DIR}/install/${PROJECT_NAME}"

```

to `CMAKE_ARGS` **in the subprojects** , but that would mean duplication for each subproject, so I would have to modify all of them if I change my mind and choose a different base install directory.
