Skip to content

Commit d317a1c

Browse files
committed
Enable toml 1.1.0 support
1 parent d22e3ff commit d317a1c

File tree

3 files changed

+30
-2
lines changed

3 files changed

+30
-2
lines changed

src/project_parser.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -215,7 +215,7 @@ Project::Project(const Project *parent, const std::string &path, bool build) : p
215215
if (!fs::exists(toml_path)) {
216216
throw std::runtime_error("File not found '" + toml_path.string() + "'");
217217
}
218-
const auto toml = toml::parse<toml::ordered_type_config>(toml_path.string());
218+
const auto toml = toml::parse<toml::ordered_type_config>(toml_path.string(), toml::spec::v(1, 1, 0));
219219
if (toml.size() == 0) {
220220
throw std::runtime_error("Empty TOML '" + toml_path.string() + "'");
221221
}
@@ -924,7 +924,7 @@ bool is_root_path(const std::string &path) {
924924
if (!fs::exists(toml_path)) {
925925
return false;
926926
}
927-
const auto toml = toml::parse<toml::ordered_type_config>(toml_path.string());
927+
const auto toml = toml::parse<toml::ordered_type_config>(toml_path.string(), toml::spec::v(1, 1, 0));
928928
return toml.contains("project");
929929
}
930930

tests/toml11-test/cmake.toml

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
# Test TOML 1.1.0 features
2+
3+
[project]
4+
name = "toml11-test"
5+
6+
# Test trailing comma in inline table (TOML 1.1.0 feature)
7+
[target.test]
8+
type = "executable"
9+
sources = ["main.cpp"]
10+
compile-definitions = {DEBUG = true, VERSION = "1.0",} # trailing comma here
11+
12+
# Test newlines in inline tables (TOML 1.1.0 feature)
13+
[target.test2]
14+
type = "library"
15+
properties = {
16+
CXX_STANDARD = "17",
17+
POSITION_INDEPENDENT_CODE = true,
18+
}
19+
20+
# Test escape sequence \e (TOML 1.1.0 feature)
21+
[variables]
22+
escape-test = "Hello\eWorld"
23+
24+
# Test escape sequence \x (TOML 1.1.0 feature)
25+
hex-escape = "Test\x20value"

tests/toml11-test/src/main.cpp

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
int main() {
2+
return 0;
3+
}

0 commit comments

Comments
 (0)