Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 1 addition & 2 deletions docs/maintainers/vcpkg_replace_string.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,8 @@ The latest version of this document lives in the [vcpkg repo](https://github.com
Replace a string in a file.

```cmake
vcpkg_replace_string(filename match_string replace_string)
vcpkg_replace_string(<filename> <match> <replace>)
```


## Source
[scripts/cmake/vcpkg\_replace\_string.cmake](https://github.com/Microsoft/vcpkg/blob/master/scripts/cmake/vcpkg_replace_string.cmake)
11 changes: 5 additions & 6 deletions scripts/cmake/vcpkg_replace_string.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,12 @@
Replace a string in a file.

```cmake
vcpkg_replace_string(filename match_string replace_string)
vcpkg_replace_string(<filename> <match> <replace>)
```

#]===]

function(vcpkg_replace_string filename match_string replace_string)
file(READ ${filename} _contents)
string(REPLACE "${match_string}" "${replace_string}" _contents "${_contents}")
file(WRITE ${filename} "${_contents}")
function(vcpkg_replace_string filename match replace)
file(READ "${filename}" contents)
string(REPLACE "${match}" "${replace}" contents "${contents}")
file(WRITE "${filename}" "${contents}")
endfunction()