# A @ variable reference on a line by itself, what does it mean and where can @ variable references occur?

**URL:** <https://discourse.cmake.org/t/a-variable-reference-on-a-line-by-itself-what-does-it-mean-and-where-can-variable-references-occur/7734>\
**Category:** Code\
**Created:** [March 21, 2023, 11:59am UTC](https://discourse.cmake.org/t/a-variable-reference-on-a-line-by-itself-what-does-it-mean-and-where-can-variable-references-occur/7734 "2023-03-21T11:59:32Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![EricGT](https://discourse.cmake.org/letter_avatar_proxy/v4/letter/e/f1d935/32.png) [@EricGT](https://discourse.cmake.org/u/EricGT)\
**Post date:** [March 21, 2023, 11:59am UTC](https://discourse.cmake.org/t/a-variable-reference-on-a-line-by-itself-what-does-it-mean-and-where-can-variable-references-occur/7734/1 "2023-03-21T11:59:32Z")

</div>

Creating a parser for CMake files and used the CMake files from the [CMake GitHub repository](https://github.com/Kitware/CMake/tree/master) for testing.

In [run\_nvcc.cmake](https://github.com/Kitware/CMake/blob/master/Modules/FindCUDA/run_nvcc.cmake) this line failed

> <https://github.com/Kitware/CMake/blob/master/Modules/FindCUDA/run_nvcc.cmake#L104>

`@CUDA_HOST_FLAGS@`

The [syntax page](https://cmake.org/cmake/help/latest/manual/cmake-language.7.html) from the web documentation does not note what this is however `Professional CMake` notes it as `@-syntax` and mentions `configure_file` for which the web documenation has a page.

[https://cmake.org/cmake/help/latest/command/configure\_file.html?highlight=configure\_file](https://cmake.org/cmake/help/latest/command/configure_file.html?highlight=configure_file)

The web documentation for variable references only notes

> A _variable reference_ has the form `${<variable>}` and is evaluated inside a [Quoted Argument](https://cmake.org/cmake/help/latest/manual/cmake-language.7.html#quoted-argument) or an [Unquoted Argument](https://cmake.org/cmake/help/latest/manual/cmake-language.7.html#unquoted-argument).

So where can these @-syntax varaible references appear in a CMake file before substituion occurs?

---

<div class="post-metadata">

**Author:** ![fenrir](https://discourse.cmake.org/user_avatar/discourse.cmake.org/fenrir/32/734_2.png) [@fenrir](https://discourse.cmake.org/u/fenrir)\
**Post date:** [March 21, 2023, 12:17pm UTC](https://discourse.cmake.org/t/a-variable-reference-on-a-line-by-itself-what-does-it-mean-and-where-can-variable-references-occur/7734/2 "2023-03-21T12:17:10Z")

</div>

This file is actually an input to `configure\_file´ (see FindCUDA.cmake). It’s just not reflected in the extension.

---

<div class="post-metadata">

**Author:** ![EricGT](https://discourse.cmake.org/letter_avatar_proxy/v4/letter/e/f1d935/32.png) [@EricGT](https://discourse.cmake.org/u/EricGT)\
**Post date:** [March 21, 2023, 12:20pm UTC](https://discourse.cmake.org/t/a-variable-reference-on-a-line-by-itself-what-does-it-mean-and-where-can-variable-references-occur/7734/3 "2023-03-21T12:20:42Z")

</div>

> [@fenrir](#):
>
> see FindCUDA.cmake

FYI

For others looking for findCUDA

[https://cmake.org/cmake/help/latest/module/FindCUDA.html?highlight=findcuda](https://cmake.org/cmake/help/latest/module/FindCUDA.html?highlight=findcuda)

* * *

> [@fenrir](#):
>
> It’s just not reflected in the extension.

I take that to mean that a file name like `run_nvcc.cmake.in` would have made more sense to most programmers.

* * *

While the specifics of `@CUDA_HOST_FLAGS@` have been noted, still have the main quesiton.

> Where can these @-syntax varaible references appear in a CMake file before substituion occurs?

---

<div class="post-metadata">

**Author:** ![benthevining](https://discourse.cmake.org/user_avatar/discourse.cmake.org/benthevining/32/1924_2.png) [@benthevining](https://discourse.cmake.org/u/benthevining)\
**Post date:** [March 21, 2023, 8:18pm UTC](https://discourse.cmake.org/t/a-variable-reference-on-a-line-by-itself-what-does-it-mean-and-where-can-variable-references-occur/7734/4 "2023-03-21T20:18:54Z")

</div>

> [@EricGT](#):
>
> Where can these @-syntax varaible references appear in a CMake file before substituion occurs?

Nowhere. @ reference syntax is only valid in input files to `configure_file`.

---

<div class="post-metadata">

**Author:** ![ben.boeckel](https://discourse.cmake.org/letter_avatar_proxy/v4/letter/b/ea5d25/32.png) [@ben.boeckel](https://discourse.cmake.org/u/ben.boeckel)\
**Post date:** [March 22, 2023, 12:17pm UTC](https://discourse.cmake.org/t/a-variable-reference-on-a-line-by-itself-what-does-it-mean-and-where-can-variable-references-occur/7734/5 "2023-03-22T12:17:29Z")

</div>

Technically, pre-`CMP0053`, `@` variables work in normal CMake code too (with weird caveats as any unintentional behavior is wont to have). However, you can ignore that for anything modern.
