Is it possible to inser text from a CMakeLists.txt into a file in a specific line (and move one line down the rest of the lines).
I have read the FILE function documentation http://www.cmake.org/cmake/help/v3.0/command/file.html but I cannot find anything.
Objective: From CMake, I want to modify a HTML file so that the directory of the index.html is wrote in this HTML file (potentially as a link). I am creating a file to log different things (output files directories). For example:
File before running cmake:
<html>
<head>
</head>
<body>
<!-- Insert text here -->
</body>
</html>
File after runing a CMakeLists.txt with something like
file((insert in line 6) ${DOC_DIR}/log.txt "<p>Inserted text.</p>")
<html>
<head>
</head>
<body>
<!-- Insert text here -->
<p>This text is normal.</p>
</body>
</html>
You can use configure_file
to fill a template with CMake variables.
Simple example:
test.html.in
<html>
<head>
</head>
<body>
@html_string@
</body>
</html>
CMakeLists.txt
project(test)
set(html_string "<p>Inserted text.</p>")
configure_file(test.html.in test.html)
Running cmake
results in a file test.html with the following contents to be created:
<html>
<head>
</head>
<body>
<p>Inserted text.</p>
</body>
</html>
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.