mirror of
https://github.com/NVIDIA/nvbench.git
synced 2026-03-14 20:27:24 +00:00
Switch to `configure_file`, which won't touch the output file unless the contents change.
22 lines
755 B
CMake
22 lines
755 B
CMake
# file_to_string(file_in file_out string_name)
|
|
#
|
|
# Create a C++ file `file_out` that defines a string named `string_name` in
|
|
# `namespace`, which contains the contents of `file_in`.
|
|
|
|
# Cache this so we can access it from wherever file_to_string is called.
|
|
set(_nvbench_file_to_string_path "${CMAKE_CURRENT_LIST_DIR}/FileToString.in")
|
|
function(file_to_string file_in file_out namespace string_name)
|
|
file(READ "${file_in}" file_in_contents)
|
|
|
|
set(file_out_contents)
|
|
string(APPEND file_to_string_payload
|
|
"#include <string>\n"
|
|
"namespace ${namespace} {\n"
|
|
"const std::string ${string_name} =\n"
|
|
"R\"expected(${file_in_contents})expected\";\n"
|
|
"}\n"
|
|
)
|
|
|
|
configure_file("${_nvbench_file_to_string_path}" "${file_out}")
|
|
endfunction()
|