The command configure_file can copy files and replace their contents with variable values. In our example, we used configure_file to both modify the contents of our template file and copy it to a location where it could then be compiled into our executable. Let us look at our invocation of configure_file:
configure_file(print_info.c.in print_info.c @ONLY)
The first argument is the name of the scaffold: print_info.c.in. CMake assumes that the input file is located relative to the root directory of the project; that is, in ${CMAKE_CURRENT_SOURCE_DIR}/print_info.c.in. The second argument is the name of the configured file, which we chose to be print_info.c. The output file is assumed to be located relative to the project build directory; that is, in ${CMAKE_CURRENT_BINARY_DIR}/print_info.c.
When limiting the invocation to just two arguments, the input and output files, CMake will not only configure variables of the form @VAR@, but also those of the form ${VAR}. This can be inconvenient when ${VAR} is part of the syntax and should not be touched (such as in shell scripts). To instruct CMake in this regard, the option @ONLY should be passed to the invocation of configure_file, as we illustrated previously.