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

Creating a parser for CMake files and used the CMake files from the CMake GitHub repository for testing.

In run_nvcc.cmake this line failed

@CUDA_HOST_FLAGS@

The syntax page 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

The web documentation for variable references only notes

A variable reference has the form ${<variable>} and is evaluated inside a Quoted Argument or an Unquoted Argument.

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

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

FYI

For others looking for findCUDA

https://cmake.org/cmake/help/latest/module/FindCUDA.html?highlight=findcuda


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?

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

1 Like

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.