[CMake] nested variables with @ONLY: ${${PROJECT}_FLAGS} vs. @@PROJECT at _FLAGS@
Nico Schlömer
nico.schloemer at gmail.com
Fri Aug 10 14:01:03 EDT 2012
When templating ProjectConfig.cmake files, I like to have
${MY_CMAKE_VARIABLE} stuff in the output, so I use @ONLY at configure
time, e.g.,
configure_file(ProjectConfig.cmake.in
"${PROJECT_BINARY_DIR}/ProjectConfig.cmake" @ONLY)
The @-syntax in ProjectConfig.cmake.in works okay most of the time,
but fails when there are nested variables. Withotu @ONLY, a statement
like
${${PROJECT_NAME}_FLAGS}
would first be expanded to
${MyProject_FLAGS}
and then
<whatever the flags are>.
The syntax
@@PROJECT_NAME at _FLAGS@
merely expands @PROJECT_NAME@, though.
Is there are workaround for this?
Cheers,
Nico
More information about the CMake
mailing list