Skip to content

Commit

Permalink
Merge pull request #111 from anthonyprintup/fetch-content-system
Browse files Browse the repository at this point in the history
Fix #110
  • Loading branch information
mrexodia authored Jun 12, 2023
2 parents 7b1d333 + bcaa60c commit cfee3bb
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 1 deletion.
1 change: 1 addition & 0 deletions docs/cmake-toml.md
Original file line number Diff line number Diff line change
Expand Up @@ -151,6 +151,7 @@ condition = "mycondition"
git = "https://github.com/myuser/gitcontent"
tag = "v0.1"
shallow = false
system = false

[fetch-content.svncontent]
condition = "mycondition"
Expand Down
1 change: 1 addition & 0 deletions include/project_parser.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -155,6 +155,7 @@ struct Content {
Condition<std::string> cmake_after;
ConditionVector include_before;
ConditionVector include_after;
bool system;
};

enum MsvcRuntimeType {
Expand Down
6 changes: 5 additions & 1 deletion src/cmake_generator.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -917,7 +917,11 @@ void generate_cmake(const char *path, const parser::Project *parent_project) {
version_info = " (" + content.arguments.at("SVN_REVISION") + ")";
}
cmd("message")("STATUS", "Fetching " + content.name + version_info + "...");
cmd("FetchContent_Declare")(content.name, content.arguments);
if (content.system) {
cmd("FetchContent_Declare")(content.name, "SYSTEM", content.arguments);
} else {
cmd("FetchContent_Declare")(content.name, content.arguments);
}
cmd("FetchContent_MakeAvailable")(content.name).endl();

gen.conditional_includes(content.include_after);
Expand Down
9 changes: 9 additions & 0 deletions src/project_parser.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -443,6 +443,15 @@ Project::Project(const Project *parent, const std::string &path, bool build) : p
c.optional("cmake-after", content.cmake_after);
c.optional("include-before", content.include_before);
c.optional("include-after", content.include_after);
c.optional("system", content.system);

// Check if the minimum version requirement is satisfied (CMake 3.25)
if (c.contains("system") && !this->cmake_minimum_version(3, 25)) {
throw_key_error("The system argument is only supported on CMake version 3.25 and above.\nSet the CMake version in cmake.toml:\n"
"[cmake]\n"
"version = \"3.25\"\n",
"system", "");
}

for (const auto &argItr : itr.second.as_table()) {
std::string value;
Expand Down

0 comments on commit cfee3bb

Please sign in to comment.