| 159 | } |
| 160 | |
| 161 | static std::string read_file(const fs::path &path) { |
| 162 | std::ifstream ifs(path, std::ios::binary); |
| 163 | if (!ifs) { |
| 164 | throw std::runtime_error("Failed to read " + path.string()); |
| 165 | } |
| 166 | std::string contents; |
| 167 | ifs.seekg(0, std::ios::end); |
| 168 | contents.resize(ifs.tellg()); |
| 169 | ifs.seekg(0, std::ios::beg); |
| 170 | ifs.read(&contents[0], contents.size()); |
| 171 | return contents; |
| 172 | } |
| 173 | |
| 174 | // CMake target name rules: https://cmake.org/cmake/help/latest/policy/CMP0037.html [A-Za-z0-9_.+\-] |
| 175 | // TOML bare keys: non-empty strings composed only of [A-Za-z0-9_-] |