mirror of
https://github.com/NVIDIA/nvbench.git
synced 2026-04-29 19:21:14 +00:00
Avoid recompiling option_parser every time cmake runs.
Switch to `configure_file`, which won't touch the output file unless the contents change.
This commit is contained in:
@@ -3,11 +3,13 @@
|
|||||||
# Create a C++ file `file_out` that defines a string named `string_name` in
|
# Create a C++ file `file_out` that defines a string named `string_name` in
|
||||||
# `namespace`, which contains the contents of `file_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)
|
function(file_to_string file_in file_out namespace string_name)
|
||||||
file(READ "${file_in}" file_in_contents)
|
file(READ "${file_in}" file_in_contents)
|
||||||
|
|
||||||
set(file_out_contents)
|
set(file_out_contents)
|
||||||
string(APPEND file_out_contents
|
string(APPEND file_to_string_payload
|
||||||
"#include <string>\n"
|
"#include <string>\n"
|
||||||
"namespace ${namespace} {\n"
|
"namespace ${namespace} {\n"
|
||||||
"const std::string ${string_name} =\n"
|
"const std::string ${string_name} =\n"
|
||||||
@@ -15,5 +17,5 @@ function(file_to_string file_in file_out namespace string_name)
|
|||||||
"}\n"
|
"}\n"
|
||||||
)
|
)
|
||||||
|
|
||||||
file(WRITE "${file_out}" "${file_out_contents}")
|
configure_file("${_nvbench_file_to_string_path}" "${file_out}")
|
||||||
endfunction()
|
endfunction()
|
||||||
|
|||||||
1
cmake/FileToString.in
Normal file
1
cmake/FileToString.in
Normal file
@@ -0,0 +1 @@
|
|||||||
|
${file_to_string_payload}
|
||||||
Reference in New Issue
Block a user