Swift: compile_commands.json contains invalid `"command": ":"`
Swift files have an incorrect "command"
entry in generated compilation databases (compile_commands.json) when using -DCMAKE_EXPORT_COMPILE_COMMANDS=1
.
{
"directory": "/tmp/swift-cmake-demo/build",
"command": ":",
"file": "/tmp/swift-cmake-demo/Source/HelloWorld/HelloWorld.swift"
}
Reproduced using cmake-3.15.0-rc3-Darwin-x86_64
:
$ git clone https://github.com/compnerd/swift-cmake-demo.git
$ cd swift-cmake-demo/
$ mkdir build && cd build
$ cmake -G Ninja -DCMAKE_BUILD_TYPE=Debug -DCMAKE_EXPORT_COMPILE_COMMANDS=1 ..
-- The C compiler identification is AppleClang 11.0.0.11000020
-- The Swift compiler identification is Apple 5.1
-- Check for working C compiler: /Xcodes/11.0/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/cc
-- Check for working C compiler: /Xcodes/11.0/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/cc -- works
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - done
-- Detecting C compile features
-- Detecting C compile features - done
-- Check for working Swift compiler: /Xcodes/11.0/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/swiftc
-- Check for working Swift compiler: /Xcodes/11.0/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/swiftc -- works
-- Configuring done
-- Generating done
-- Build files have been written to: /tmp/swift-cmake-demo/build
$ ninja
[4/4] Linking Swift executable Source/HelloWorld/HelloWorld
$ cat compile_commands.json
[
{
"directory": "/tmp/swift-cmake-demo/build",
"command": "/Xcodes/11.0/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/cc -DL_EXPORTS -g -isysroot /Xcodes/11.0/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.15.sdk -mmacosx-version-min=10.14 -fPIC -o Source/CLibrary/CMakeFiles/L.dir/Library.c.o -c /tmp/swift-cmake-demo/Source/CLibrary/Library.c",
"file": "/tmp/swift-cmake-demo/Source/CLibrary/Library.c"
},
{
"directory": "/tmp/swift-cmake-demo/build",
"command": ":",
"file": "/tmp/swift-cmake-demo/Source/HelloWorldCore/_HelloWorldCore.swift"
},
{
"directory": "/tmp/swift-cmake-demo/build",
"command": ":",
"file": "/tmp/swift-cmake-demo/Source/HelloWorldCore/HelloWorldCore.swift"
},
{
"directory": "/tmp/swift-cmake-demo/build",
"command": ":",
"file": "/tmp/swift-cmake-demo/Source/HelloWorld/HelloWorld.swift"
}
]