From e2dd08a93e7cb738478e447541ae9d1846df8ad6 Mon Sep 17 00:00:00 2001 From: Axel Kohlmeyer Date: Thu, 26 May 2022 21:40:33 -0400 Subject: [PATCH] Better handle file- or path-names with spaces --- cmake/Modules/generate_lmpgitversion.cmake | 6 ++++-- unittest/formats/compressed_dump_test.h | 2 +- unittest/formats/test_dump_atom.cpp | 2 +- unittest/formats/test_dump_custom.cpp | 2 +- 4 files changed, 7 insertions(+), 5 deletions(-) diff --git a/cmake/Modules/generate_lmpgitversion.cmake b/cmake/Modules/generate_lmpgitversion.cmake index f066269723..32aaf6f2c5 100644 --- a/cmake/Modules/generate_lmpgitversion.cmake +++ b/cmake/Modules/generate_lmpgitversion.cmake @@ -31,5 +31,7 @@ set(temp "${temp}const char *LAMMPS_NS::LAMMPS::git_descriptor() { return \"${te set(temp "${temp}#endif\n\n") message(STATUS "Generating lmpgitversion.h...") -file(WRITE "${LAMMPS_STYLE_HEADERS_DIR}/lmpgitversion.h.tmp" "${temp}" ) -execute_process(COMMAND ${CMAKE_COMMAND} -E copy_if_different "${LAMMPS_STYLE_HEADERS_DIR}/lmpgitversion.h.tmp" "${LAMMPS_STYLE_HEADERS_DIR}/lmpgitversion.h") + +string(REPLACE "\\ " " " LAMMPS_GIT_HEADER "${LAMMPS_STYLE_HEADERS_DIR}/lmpgitversion.h") +file(WRITE "${LAMMPS_GIT_HEADER}.tmp" "${temp}" ) +execute_process(COMMAND ${CMAKE_COMMAND} -E copy_if_different "${LAMMPS_GIT_HEADER}.tmp" "${LAMMPS_GIT_HEADER}") diff --git a/unittest/formats/compressed_dump_test.h b/unittest/formats/compressed_dump_test.h index d9803005e5..b209097264 100644 --- a/unittest/formats/compressed_dump_test.h +++ b/unittest/formats/compressed_dump_test.h @@ -102,7 +102,7 @@ public: BEGIN_HIDE_OUTPUT(); std::string converted_file = compressed_file.substr(0, compressed_file.find_last_of('.')); std::string cmdline = - fmt::format("{} -d -c {} > {}", COMPRESS_EXECUTABLE, compressed_file, converted_file); + fmt::format("\"{}\" -d -c {} > {}", COMPRESS_EXECUTABLE, compressed_file, converted_file); system(cmdline.c_str()); END_HIDE_OUTPUT(); return converted_file; diff --git a/unittest/formats/test_dump_atom.cpp b/unittest/formats/test_dump_atom.cpp index c9e5223f19..d1b22d7827 100644 --- a/unittest/formats/test_dump_atom.cpp +++ b/unittest/formats/test_dump_atom.cpp @@ -100,7 +100,7 @@ public: std::string convert_binary_to_text(std::string binary_file) { BEGIN_HIDE_OUTPUT(); - std::string cmdline = fmt::format("{} {}", BINARY2TXT_EXECUTABLE, binary_file); + std::string cmdline = fmt::format("\"{}\" {}", BINARY2TXT_EXECUTABLE, binary_file); system(cmdline.c_str()); END_HIDE_OUTPUT(); return fmt::format("{}.txt", binary_file); diff --git a/unittest/formats/test_dump_custom.cpp b/unittest/formats/test_dump_custom.cpp index ee297b194e..39cb4ffd27 100644 --- a/unittest/formats/test_dump_custom.cpp +++ b/unittest/formats/test_dump_custom.cpp @@ -100,7 +100,7 @@ public: std::string convert_binary_to_text(std::string binary_file) { BEGIN_HIDE_OUTPUT(); - std::string cmdline = fmt::format("{} {}", BINARY2TXT_EXECUTABLE, binary_file); + std::string cmdline = fmt::format("\"{}\" {}", BINARY2TXT_EXECUTABLE, binary_file); system(cmdline.c_str()); END_HIDE_OUTPUT(); return fmt::format("{}.txt", binary_file);