Notes |
|
(0037180)
|
Brad King
|
2014-11-11 13:05
|
|
In an add_custom_command one can do
cmake -E echo text > file.txt |
|
|
(0037182)
|
Rolf Eike Beer
|
2014-11-11 13:27
|
|
or put into foo.cmake:
file(WRITE ...)
And then run cmake -P foo.cmake. |
|
|
(0037183)
|
Ilya
|
2014-11-11 13:45
|
|
The problem with cmake -P solution is that one will have to supply additional file which is less intuitive then having a line in code. From the perspective of someone who will need to understand build scripts it will raise more questions than answers
As of the shell redirect operator: as I was pointed out in IRC it does not work under all contexts. |
|
|
(0037184)
|
Brad King
|
2014-11-11 13:51
|
|
Re 0015242:0037183: In what context do you need this to work in which shell redirection does not work? I've used it in many projects. |
|
|
(0037232)
|
Ilya
|
2014-11-18 13:42
|
|
When it's started out of shell. |
|
|
(0037234)
|
Brad King
|
2014-11-19 10:31
|
|
Please provide a code example. |
|
|
(0039134)
|
dbanet
|
2015-07-14 03:49
|
|
|
|
(0039138)
|
Ilya
|
2015-07-14 10:45
|
|
E.g. when you start cmake from Python:
import subprocess
subprocess.check_call(['cmake', …], shell=False)
Note, that it's from a comment from IRC made (I believe) by one of developers. |
|
|
(0039139)
|
Brad King
|
2015-07-14 11:07
|
|
Re 0015242:0039138: Try:
import subprocess
out = open('output.txt', 'w')
subprocess.check_call(['cmake', '-E', 'echo', 'message'], shell=False, stdout=out)
out.close()
|
|
|
(0039140)
|
Ilya
|
2015-07-14 12:46
|
|
Brad, sorry for misleading you.
I wanted to use cmake -E echo from cmake scripts to write to a file at build time. My cmake scripts can be run from something like python.
|
|
|
(0039141)
|
Brad King
|
2015-07-14 13:12
|
|
Re 0015242:0039140: I do not understand what you're trying to do. Please provide a sample source tarball showing your use case with a comment where you'd like the new option to be used.
Even the bash "echo" command does not support explicit options for writing to a file because one can always redirect stdout. It is not the job of every tool to have an option to write output to a file. |
|
|
(0039142)
|
Ilya
|
2015-07-14 13:14
|
|
Bash's echo does not have an option for writing to a file, because it's supposed to be run in bash.
My case is that one of custom commands in cmake script needs to write something to a file. That cmake script can be started out of shell.
If > is guaranteed to work in this scenario, then ok, but I was just pointe in IRC that it may not work. |
|
|
(0039143)
|
Brad King
|
2015-07-14 13:29
|
|
Re 0015242:0039142: Without an example source tarball to show your use case concretely I cannot help further. |
|
|
(0042663)
|
Kitware Robot
|
2016-06-10 14:29
|
|
Resolving issue as `moved`.
This issue tracker is no longer used. Further discussion of this issue may take place in the current CMake Issues page linked in the banner at the top of this page. |
|