summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorKyle Edwards <kyle.edwards@kitware.com>2023-11-16 19:36:25 (GMT)
committerBrad King <brad.king@kitware.com>2023-11-17 12:59:05 (GMT)
commita3a85524cd133888288689871e69da76f2267eda (patch)
tree1d0cccdf4bc6e94ad9a4317fc950082d6aa2f129
parentd6c81467aad117a68ce80f76c9df811d18675a42 (diff)
downloadCMake-a3a85524cd133888288689871e69da76f2267eda.zip
CMake-a3a85524cd133888288689871e69da76f2267eda.tar.gz
CMake-a3a85524cd133888288689871e69da76f2267eda.tar.bz2
fileapi: Fix file sets' base directories relative to top source
This field was added by commit b3e9fb67bb (file-api: support exporting file set information, 2022-11-03, v3.26.0-rc1~389^2) but the relative path convention used elsewhere was accidentally left out. Fixes: #25422
-rw-r--r--Help/manual/cmake-file-api.7.rst4
-rw-r--r--Source/cmFileAPICodemodel.cxx2
-rw-r--r--Tests/RunCMake/FileAPI/codemodel-v2-data/targets/c_headers_1.json8
-rw-r--r--Tests/RunCMake/FileAPI/codemodel-v2-data/targets/c_headers_2.json2
4 files changed, 9 insertions, 7 deletions
diff --git a/Help/manual/cmake-file-api.7.rst b/Help/manual/cmake-file-api.7.rst
index 7ff9728..878a174 100644
--- a/Help/manual/cmake-file-api.7.rst
+++ b/Help/manual/cmake-file-api.7.rst
@@ -1088,7 +1088,9 @@ with members:
``baseDirectories``
A JSON array of strings specifying the base directories containing sources
- in the file set.
+ in the file set. If the file is inside the top-level source directory
+ then the path is specified relative to that directory. Otherwise the path
+ is absolute.
This field was added in codemodel version 2.5.
diff --git a/Source/cmFileAPICodemodel.cxx b/Source/cmFileAPICodemodel.cxx
index d3683d4..ee09cc3 100644
--- a/Source/cmFileAPICodemodel.cxx
+++ b/Source/cmFileAPICodemodel.cxx
@@ -1611,7 +1611,7 @@ Json::Value Target::DumpFileSet(cmFileSet const* fs,
Json::Value baseDirs = Json::arrayValue;
for (auto const& directory : directories) {
- baseDirs.append(directory);
+ baseDirs.append(RelativeIfUnder(this->TopSource, directory));
}
fileSet["baseDirectories"] = baseDirs;
diff --git a/Tests/RunCMake/FileAPI/codemodel-v2-data/targets/c_headers_1.json b/Tests/RunCMake/FileAPI/codemodel-v2-data/targets/c_headers_1.json
index 715514d..aad3a94 100644
--- a/Tests/RunCMake/FileAPI/codemodel-v2-data/targets/c_headers_1.json
+++ b/Tests/RunCMake/FileAPI/codemodel-v2-data/targets/c_headers_1.json
@@ -10,25 +10,25 @@
"name": "HEADERS",
"type": "HEADERS",
"visibility": "PUBLIC",
- "baseDirectories": [".*/Tests/RunCMake/FileAPI/fileset$"]
+ "baseDirectories": ["^fileset$"]
},
{
"name": "a",
"type": "HEADERS",
"visibility": "PRIVATE",
- "baseDirectories": [".*/Tests/RunCMake/FileAPI/fileset$"]
+ "baseDirectories": ["^fileset$"]
},
{
"name": "b",
"type": "HEADERS",
"visibility": "PUBLIC",
- "baseDirectories": [".*/Tests/RunCMake/FileAPI/fileset/dir$"]
+ "baseDirectories": ["^fileset/dir$"]
},
{
"name": "c",
"type": "HEADERS",
"visibility": "INTERFACE",
- "baseDirectories": [".*/Tests/RunCMake/FileAPI/fileset$"]
+ "baseDirectories": ["^fileset$"]
}
],
"sources": [
diff --git a/Tests/RunCMake/FileAPI/codemodel-v2-data/targets/c_headers_2.json b/Tests/RunCMake/FileAPI/codemodel-v2-data/targets/c_headers_2.json
index 4757a9c..3f95a0b 100644
--- a/Tests/RunCMake/FileAPI/codemodel-v2-data/targets/c_headers_2.json
+++ b/Tests/RunCMake/FileAPI/codemodel-v2-data/targets/c_headers_2.json
@@ -10,7 +10,7 @@
"name": "HEADERS",
"type": "HEADERS",
"visibility": "INTERFACE",
- "baseDirectories": [".*/Tests/RunCMake/FileAPI/fileset$"]
+ "baseDirectories": ["^fileset$"]
}
],
"sources": [