From 771c80a41a410ea92c41e79581fdf4700d4a4816 Mon Sep 17 00:00:00 2001 From: Duncan Ogilvie Date: Thu, 9 Nov 2023 13:28:29 +0100 Subject: [PATCH] Add [fetch-content].subdir Closes #98 --- docs/cmake-toml.md | 3 +++ include/project_parser.hpp | 1 + src/project_parser.cpp | 2 ++ 3 files changed, 6 insertions(+) diff --git a/docs/cmake-toml.md b/docs/cmake-toml.md index 1aa48a7..5967302 100644 --- a/docs/cmake-toml.md +++ b/docs/cmake-toml.md @@ -180,6 +180,7 @@ git = "https://github.com/myuser/gitcontent" tag = "v0.1" shallow = false system = false +subdir = "" [fetch-content.svncontent] condition = "mycondition" @@ -195,6 +196,8 @@ hash = "SHA1 502a4e25b8b209889c99c7fa0732102682c2e4ff" sha1 = "502a4e25b8b209889c99c7fa0732102682c2e4ff" ``` +Table keys that match CMake variable names (`[A-Z_]+`) will be passed to the [`FetchContent_Declare`](https://cmake.org/cmake/help/latest/module/FetchContent.html#command:fetchcontent_declare) command. + ## Targets ```toml diff --git a/include/project_parser.hpp b/include/project_parser.hpp index 52ca8c2..6ffcc4f 100644 --- a/include/project_parser.hpp +++ b/include/project_parser.hpp @@ -156,6 +156,7 @@ struct Content { ConditionVector include_before; ConditionVector include_after; bool system; + std::string subdir; }; enum MsvcRuntimeType { diff --git a/src/project_parser.cpp b/src/project_parser.cpp index 218b44c..050aec6 100644 --- a/src/project_parser.cpp +++ b/src/project_parser.cpp @@ -507,6 +507,8 @@ Project::Project(const Project *parent, const std::string &path, bool build) : p value = algo + "=" + value; } else if (key == "hash") { key = "URL_HASH"; + } else if (key == "subdir") { + key = "SOURCE_SUBDIR"; } else if (is_cmake_arg(key)) { // allow passthrough of ExternalProject options } else if (!c.visisted(key)) {