diff --git a/Help/manual/cmake-instrumentation.7.rst b/Help/manual/cmake-instrumentation.7.rst index d36bf6238d..2a16a552d5 100644 --- a/Help/manual/cmake-instrumentation.7.rst +++ b/Help/manual/cmake-instrumentation.7.rst @@ -369,7 +369,7 @@ Example: { "version": 1, - "command" : "/usr/bin/c++ -MD -MT CMakeFiles/main.dir/main.cxx.o -MF CMakeFiles/main.dir/main.cxx.o.d -o CMakeFiles/main.dir/main.cxx.o -c /main.cxx", + "command" : "\"/usr/bin/c++\" \"-MD\" \"-MT\" \"CMakeFiles/main.dir/main.cxx.o\" \"-MF\" \"CMakeFiles/main.dir/main.cxx.o.d\" \"-o\" \"CMakeFiles/main.dir/main.cxx.o\" \"-c\" \"/main.cxx\"", "role" : "compile", "return" : 1, "target": "main", diff --git a/Source/cmInstrumentation.cxx b/Source/cmInstrumentation.cxx index 2c4414f55b..dff389debf 100644 --- a/Source/cmInstrumentation.cxx +++ b/Source/cmInstrumentation.cxx @@ -538,7 +538,7 @@ std::string cmInstrumentation::GetCommandStr( { std::string command_str; for (size_t i = 0; i < args.size(); ++i) { - command_str = cmStrCat(command_str, args[i]); + command_str = cmStrCat(command_str, '"', args[i], '"'); if (i < args.size() - 1) { command_str = cmStrCat(command_str, ' '); } diff --git a/Tests/RunCMake/Instrumentation/check-data-dir.cmake b/Tests/RunCMake/Instrumentation/check-data-dir.cmake index a20d2cdfa4..e21eb66d9e 100644 --- a/Tests/RunCMake/Instrumentation/check-data-dir.cmake +++ b/Tests/RunCMake/Instrumentation/check-data-dir.cmake @@ -111,7 +111,7 @@ foreach(snippet IN LISTS snippets) # Verify command args were passed if (filename MATCHES "^cmakeBuild|^ctest") string(JSON command GET "${contents}" command) - if (NOT command MATCHES "-.* Debug") + if (NOT command MATCHES "Debug") snippet_error(${snippet} "Command value missing passed arguments") endif() endif() diff --git a/Tests/RunCMake/Instrumentation/query/cmake-command-make-program.cmake b/Tests/RunCMake/Instrumentation/query/cmake-command-make-program.cmake index 807d9915b5..9e88561a7c 100644 --- a/Tests/RunCMake/Instrumentation/query/cmake-command-make-program.cmake +++ b/Tests/RunCMake/Instrumentation/query/cmake-command-make-program.cmake @@ -3,5 +3,5 @@ cmake_instrumentation( API_VERSION 1 DATA_VERSION 1 HOOKS preBuild postBuild - CALLBACK "\"${CMAKE_COMMAND}\" -P \"${hook_path}\" 0" + CALLBACK ${CMAKE_COMMAND} -P ${hook_path} 0 ) diff --git a/Tests/RunCMake/Instrumentation/query/cmake-command.cmake b/Tests/RunCMake/Instrumentation/query/cmake-command.cmake index 3f66de5f3d..72e9b41d0b 100644 --- a/Tests/RunCMake/Instrumentation/query/cmake-command.cmake +++ b/Tests/RunCMake/Instrumentation/query/cmake-command.cmake @@ -8,7 +8,7 @@ API_VERSION 1 DATA_VERSION 1 HOOKS postGenerate - CALLBACK \"${CMAKE_COMMAND}\" -E echo callback1 + CALLBACK ${CMAKE_COMMAND} -E echo callback1 ) # Query 2 cmake_instrumentation( @@ -16,6 +16,6 @@ DATA_VERSION 1 HOOKS postCMakeBuild QUERIES staticSystemInformation dynamicSystemInformation - CALLBACK \"${CMAKE_COMMAND}\" -E echo callback2 - CALLBACK \"${CMAKE_COMMAND}\" -E echo callback3 + CALLBACK ${CMAKE_COMMAND} -E echo callback2 + CALLBACK ${CMAKE_COMMAND} -E echo callback3 ) diff --git a/Tests/RunCMake/Instrumentation/query/generated/query-1.json.in b/Tests/RunCMake/Instrumentation/query/generated/query-1.json.in index 996a91b471..e5e6c35be8 100644 --- a/Tests/RunCMake/Instrumentation/query/generated/query-1.json.in +++ b/Tests/RunCMake/Instrumentation/query/generated/query-1.json.in @@ -1,7 +1,7 @@ { "callbacks" : [ - "\"@CMAKE_COMMAND@\" -E echo callback1" + "\"@CMAKE_COMMAND@\" \"-E\" \"echo\" \"callback1\"" ], "hooks" : [ diff --git a/Tests/RunCMake/Instrumentation/query/generated/query-2.json.in b/Tests/RunCMake/Instrumentation/query/generated/query-2.json.in index 3591633222..58db59fa34 100644 --- a/Tests/RunCMake/Instrumentation/query/generated/query-2.json.in +++ b/Tests/RunCMake/Instrumentation/query/generated/query-2.json.in @@ -1,8 +1,8 @@ { "callbacks" : [ - "\"@CMAKE_COMMAND@\" -E echo callback2", - "\"@CMAKE_COMMAND@\" -E echo callback3" + "\"@CMAKE_COMMAND@\" \"-E\" \"echo\" \"callback2\"", + "\"@CMAKE_COMMAND@\" \"-E\" \"echo\" \"callback3\"" ], "hooks" : [