I would like to play around with the CMake server mode from the Linux command line. The documentation tells me to start CMake like the following:
cmake -E server (--debug|--pipe <NAMED_PIPE>)
But for me it works only this way:
cmake -E server --experimental --debug
[== "CMake Server" ==[
{"supportedProtocolVersions":[{"isExperimental":true,"major":1,"minor":0}],"type":"hello"}
]== "CMake Server" ==]
I tried to send a request to the server, but I get only the hello response:
cat request.txt | cmake -E server --experimental --debug
[== "CMake Server" ==[
{"supportedProtocolVersions":[{"isExperimental":true,"major":1,"minor":0}],"type":"hello"}
]== "CMake Server" ==]
How can I send requests to the CMake server?
The CMake server will be expecting messages of either
--debug
or--pipe
mode in the following format:...your message...
The CMake server help page has more examples, but here is something that will help you get started.
For the following examples, I used CMake 3.10, if you are using an older version you may have to modify the
"protocolVersion":{"major":1}
to{"major":0}
.You'll also need to have a CMake project and know the source directory where the
CMakeLists.txt
file is and a build folder where the out of tree files will be placed by cmake.If you want to try the
--debug --experimental
flags, the server will be expecting to get input from standard input. So right after you runcmake -E server --debug --experimental
, input the following:It should respond with a bunch of information and the build folder should containt some files now.
If you want to use a named pipe instead, you'll have to use something like netcat. Using your command as an example, after running the
cmake -E server --pipe=pipe --experimental
in the background, you can use the following command:At this point, nc will be expecting input in the standard input as well, so you will be able to input the same json messages as before and get the same response.