EricGT
(EricGT)
March 21, 2023, 11:59am
1
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
foreach(def ${CUDA_NVCC_COMPILE_DEFINITIONS})
list(APPEND nvcc_flags "-D${def}")
endforeach()
if(build_cubin AND NOT generated_cubin_file)
message(FATAL_ERROR "You must specify generated_cubin_file on the command line")
endif()
# This is the list of host compilation flags. It C or CXX should already have
# been chosen by FindCUDA.cmake.
@CUDA_HOST_FLAGS@
# Take the compiler flags and package them up to be sent to the compiler via -Xcompiler
set(nvcc_host_compiler_flags "")
# If we weren't given a build_configuration, use Debug.
if(NOT build_configuration)
set(build_configuration Debug)
endif()
string(TOUPPER "${build_configuration}" build_configuration)
#message("CUDA_NVCC_HOST_COMPILER_FLAGS = ${CUDA_NVCC_HOST_COMPILER_FLAGS}")
foreach(flag ${CMAKE_HOST_FLAGS} ${CMAKE_HOST_FLAGS_${build_configuration}})
@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?
fenrir
(Jakub Zakrzewski)
March 21, 2023, 12:17pm
2
This file is actually an input to `configure_file´ (see FindCUDA.cmake). It’s just not reflected in the extension.
EricGT
(EricGT)
March 21, 2023, 12:20pm
3
Jakub Zakrzewski:
see FindCUDA.cmake
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.