mirror of
https://github.com/build-cpp/cmkr
synced 2026-06-08 13:22:55 +00:00
Merge pull request #111 from anthonyprintup/fetch-content-system
Fix #110
This commit is contained in:
@@ -151,6 +151,7 @@ condition = "mycondition"
|
||||
git = "https://github.com/myuser/gitcontent"
|
||||
tag = "v0.1"
|
||||
shallow = false
|
||||
system = false
|
||||
|
||||
[fetch-content.svncontent]
|
||||
condition = "mycondition"
|
||||
|
||||
@@ -155,6 +155,7 @@ struct Content {
|
||||
Condition<std::string> cmake_after;
|
||||
ConditionVector include_before;
|
||||
ConditionVector include_after;
|
||||
bool system;
|
||||
};
|
||||
|
||||
enum MsvcRuntimeType {
|
||||
|
||||
@@ -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);
|
||||
|
||||
@@ -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;
|
||||
|
||||
Reference in New Issue
Block a user