Merge pull request #111 from anthonyprintup/fetch-content-system

Fix #110
This commit is contained in:
Duncan Ogilvie
2023-06-12 17:48:54 +02:00
committed by GitHub
4 changed files with 16 additions and 1 deletions
+1
View File
@@ -151,6 +151,7 @@ condition = "mycondition"
git = "https://github.com/myuser/gitcontent"
tag = "v0.1"
shallow = false
system = false
[fetch-content.svncontent]
condition = "mycondition"
+1
View File
@@ -155,6 +155,7 @@ struct Content {
Condition<std::string> cmake_after;
ConditionVector include_before;
ConditionVector include_after;
bool system;
};
enum MsvcRuntimeType {
+5 -1
View File
@@ -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);
+9
View File
@@ -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;