summaryrefslogtreecommitdiffstats
path: root/Tests/RunCMake/NinjaMultiConfig/CompileCommands-check.cmake
blob: 730adf9029a44726a6f8cd7c9645b8ea90ad1931 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
set(expected_compile_commands
[==[^\[
{
  "directory": "[^
]*/Tests/RunCMake/NinjaMultiConfig/CompileCommands-build",
  "command": "[^
]*Debug[^
]*",
  "file": "[^
]*/Tests/RunCMake/NinjaMultiConfig/main\.c",
  "output": "[^
]*/CMakeFiles/exe\.dir/Debug/main\.c\.(obj|o)"
},
{
  "directory": "[^
]*/Tests/RunCMake/NinjaMultiConfig/CompileCommands-build",
  "command": "[^
]*Release[^
]*",
  "file": "[^
]*/Tests/RunCMake/NinjaMultiConfig/main\.c",
  "output": "[^
]*/CMakeFiles/exe\.dir/Release/main\.c\.(obj|o)"
}
]
$]==])

file(READ "${RunCMake_TEST_BINARY_DIR}/compile_commands.json" actual_compile_commands)
if(NOT actual_compile_commands MATCHES "${expected_compile_commands}")
  string(REPLACE "\n" "\n  " expected_compile_commands_formatted "${expected_compile_commands}")
  string(REPLACE "\n" "\n  " actual_compile_commands_formatted "${actual_compile_commands}")
  string(APPEND RunCMake_TEST_FAILED "Expected compile_commands.json to match:\n  ${expected_compile_commands_formatted}\nActual compile_commands.json:\n  ${actual_compile_commands_formatted}\n")
endif()