From 3c3698b0e47277db2721cd78e499f4b4a22f7e00 Mon Sep 17 00:00:00 2001 From: Kyle Edwards Date: Tue, 13 Jul 2021 14:20:07 -0400 Subject: FileAPI: Add information on file set installers --- Help/manual/cmake-file-api.7.rst | 46 +++- Source/cmFileAPI.cxx | 3 +- Source/cmFileAPICodemodel.cxx | 49 +++++ .../RunCMake/CommandLine/E_capabilities-stdout.txt | 2 +- Tests/RunCMake/FileAPI/codemodel-v2-check.py | 31 ++- .../codemodel-v2-data/directories/fileset.json | 203 ++++++++++++++++++ .../FileAPI/codemodel-v2-data/directories/top.json | 29 +-- .../codemodel-v2-data/projects/codemodel-v2.json | 7 +- .../codemodel-v2-data/targets/all_build_top.json | 8 + .../codemodel-v2-data/targets/c_headers_1.json | 231 +++++++++++++++++++++ .../codemodel-v2-data/targets/c_headers_2.json | 105 ++++++++++ .../codemodel-v2-data/targets/c_shared_lib.json | 6 +- .../FileAPI/codemodel-v2-data/targets/cxx_exe.json | 2 +- .../codemodel-v2-data/targets/cxx_shared_lib.json | 6 +- Tests/RunCMake/FileAPI/codemodel-v2.cmake | 1 + Tests/RunCMake/FileAPI/fileset/CMakeLists.txt | 25 +++ Tests/RunCMake/FileAPI/fileset/dir/h2.h | 0 Tests/RunCMake/FileAPI/fileset/empty.c | 0 Tests/RunCMake/FileAPI/fileset/error.c | 1 + Tests/RunCMake/FileAPI/fileset/h1.h | 0 Tests/RunCMake/FileAPI/fileset/h3.h | 0 Tests/RunCMake/FileAPI/fileset/other.c | 0 22 files changed, 728 insertions(+), 27 deletions(-) create mode 100644 Tests/RunCMake/FileAPI/codemodel-v2-data/directories/fileset.json create mode 100644 Tests/RunCMake/FileAPI/codemodel-v2-data/targets/c_headers_1.json create mode 100644 Tests/RunCMake/FileAPI/codemodel-v2-data/targets/c_headers_2.json create mode 100644 Tests/RunCMake/FileAPI/fileset/CMakeLists.txt create mode 100644 Tests/RunCMake/FileAPI/fileset/dir/h2.h create mode 100644 Tests/RunCMake/FileAPI/fileset/empty.c create mode 100644 Tests/RunCMake/FileAPI/fileset/error.c create mode 100644 Tests/RunCMake/FileAPI/fileset/h1.h create mode 100644 Tests/RunCMake/FileAPI/fileset/h3.h create mode 100644 Tests/RunCMake/FileAPI/fileset/other.c diff --git a/Help/manual/cmake-file-api.7.rst b/Help/manual/cmake-file-api.7.rst index 5e22ea9..4b8ac65 100644 --- a/Help/manual/cmake-file-api.7.rst +++ b/Help/manual/cmake-file-api.7.rst @@ -425,7 +425,7 @@ Version 1 does not exist to avoid confusion with that from { "kind": "codemodel", - "version": { "major": 2, "minor": 2 }, + "version": { "major": 2, "minor": 4 }, "paths": { "source": "/path/to/top-level-source-dir", "build": "/path/to/top-level-build-dir" @@ -758,6 +758,15 @@ with members: ``destination`` member is populated. This type has additional members ``runtimeDependencySetName`` and ``runtimeDependencySetType``. + ``fileSet`` + An :command:`install(TARGETS)` call with ``FILE_SET``. + The ``destination`` and ``paths`` members are populated. + The ``isOptional`` member may exist. + This type has additional members ``fileSetName``, ``fileSetType``, + ``fileSetDirectories``, and ``fileSetTarget``. + + This type was added in codemodel version 2.4. + ``isExcludeFromAll`` Optional member that is present with boolean value ``true`` when :command:`install` is called with the ``EXCLUDE_FROM_ALL`` option. @@ -835,6 +844,41 @@ with members: Indicates that this installer installs dependencies that are macOS frameworks. + ``fileSetName`` + Optional member that is present when ``type`` is ``fileSet``. The value is + a string with the name of the file set. + + This field was added in codemodel version 2.4. + + ``fileSetType`` + Optional member that is present when ``type`` is ``fileSet``. The value is + a string with the type of the file set. + + This field was added in codemodel version 2.4. + + ``fileSetDirectories`` + Optional member that is present when ``type`` is ``fileSet``. The value + is a list of strings with the file set's base directories (determined by + genex-evaluation of :prop_tgt:`HEADER_DIRS` or + :prop_tgt:`HEADER_DIRS_`). + + This field was added in codemodel version 2.4. + + ``fileSetTarget`` + Optional member that is present when ``type`` is ``fileSet``. The value + is a JSON object with members: + + ``id`` + A string uniquely identifying the target. This matches + the ``id`` member of the target in the main "codemodel" + object's ``targets`` array. + + ``index`` + An unsigned integer 0-based index into the main "codemodel" + object's ``targets`` array for the target. + + This field was added in codemodel version 2.4. + ``scriptFile`` Optional member that is present when ``type`` is ``script``. The value is a string specifying the path to the script file on disk, diff --git a/Source/cmFileAPI.cxx b/Source/cmFileAPI.cxx index d529f52..c1df992 100644 --- a/Source/cmFileAPI.cxx +++ b/Source/cmFileAPI.cxx @@ -686,7 +686,8 @@ std::string cmFileAPI::NoSupportedVersion( // The "codemodel" object kind. -static unsigned int const CodeModelV2Minor = 3; +// Update Help/manual/cmake-file-api.7.rst when updating this constant. +static unsigned int const CodeModelV2Minor = 4; void cmFileAPI::BuildClientRequestCodeModel( ClientRequest& r, std::vector const& versions) diff --git a/Source/cmFileAPICodemodel.cxx b/Source/cmFileAPICodemodel.cxx index 147181e..40e1d2e 100644 --- a/Source/cmFileAPICodemodel.cxx +++ b/Source/cmFileAPICodemodel.cxx @@ -23,11 +23,13 @@ #include "cmCryptoHash.h" #include "cmExportSet.h" #include "cmFileAPI.h" +#include "cmFileSet.h" #include "cmGeneratorExpression.h" #include "cmGeneratorTarget.h" #include "cmGlobalGenerator.h" #include "cmInstallDirectoryGenerator.h" #include "cmInstallExportGenerator.h" +#include "cmInstallFileSetGenerator.h" #include "cmInstallFilesGenerator.h" #include "cmInstallGenerator.h" #include "cmInstallGetRuntimeDependenciesGenerator.h" @@ -1043,6 +1045,53 @@ Json::Value DirectoryObject::DumpInstaller(cmInstallGenerator* gen) installer["runtimeDependencySetType"] = "library"; break; } + } else if (auto* installFileSet = + dynamic_cast(gen)) { + installer["type"] = "fileSet"; + installer["destination"] = installFileSet->GetDestination(this->Config); + + auto* fileSet = installFileSet->GetFileSet(); + auto* target = installFileSet->GetTarget(); + + auto dirCges = fileSet->CompileDirectoryEntries(); + auto dirs = fileSet->EvaluateDirectoryEntries( + dirCges, target->GetLocalGenerator(), this->Config, target); + + auto entryCges = fileSet->CompileFileEntries(); + std::map> entries; + for (auto const& entryCge : entryCges) { + fileSet->EvaluateFileEntry(dirs, entries, entryCge, + target->GetLocalGenerator(), this->Config, + target); + } + + Json::Value files = Json::arrayValue; + for (auto const& it : entries) { + auto dir = it.first; + if (!dir.empty()) { + dir += '/'; + } + for (auto const& file : it.second) { + files.append(this->DumpInstallerPath( + this->TopSource, file, + cmStrCat(dir, cmSystemTools::GetFilenameName(file)))); + } + } + installer["paths"] = std::move(files); + installer["fileSetName"] = fileSet->GetName(); + installer["fileSetType"] = fileSet->GetType(); + installer["fileSetDirectories"] = Json::arrayValue; + for (auto const& dir : dirs) { + installer["fileSetDirectories"].append( + RelativeIfUnder(this->TopSource, dir)); + } + installer["fileSetTarget"] = Json::objectValue; + installer["fileSetTarget"]["id"] = TargetId(target, this->TopBuild); + installer["fileSetTarget"]["index"] = this->TargetIndexMap[target]; + + if (installFileSet->GetOptional()) { + installer["isOptional"] = true; + } } // Add fields common to all install generators. diff --git a/Tests/RunCMake/CommandLine/E_capabilities-stdout.txt b/Tests/RunCMake/CommandLine/E_capabilities-stdout.txt index 3df3e52..6a932f1 100644 --- a/Tests/RunCMake/CommandLine/E_capabilities-stdout.txt +++ b/Tests/RunCMake/CommandLine/E_capabilities-stdout.txt @@ -1 +1 @@ -^{"fileApi":{"requests":\[{"kind":"codemodel","version":\[{"major":2,"minor":3}]},{"kind":"cache","version":\[{"major":2,"minor":0}]},{"kind":"cmakeFiles","version":\[{"major":1,"minor":0}]},{"kind":"toolchains","version":\[{"major":1,"minor":0}]}]},"generators":\[.*\],"serverMode":false,"version":{.*}}$ +^{"fileApi":{"requests":\[{"kind":"codemodel","version":\[{"major":2,"minor":4}]},{"kind":"cache","version":\[{"major":2,"minor":0}]},{"kind":"cmakeFiles","version":\[{"major":1,"minor":0}]},{"kind":"toolchains","version":\[{"major":1,"minor":0}]}]},"generators":\[.*\],"serverMode":false,"version":{.*}}$ diff --git a/Tests/RunCMake/FileAPI/codemodel-v2-check.py b/Tests/RunCMake/FileAPI/codemodel-v2-check.py index 92a64f9..b31088d 100644 --- a/Tests/RunCMake/FileAPI/codemodel-v2-check.py +++ b/Tests/RunCMake/FileAPI/codemodel-v2-check.py @@ -12,7 +12,7 @@ def read_codemodel_json_data(filename): def check_objects(o, g): assert is_list(o) assert len(o) == 1 - check_index_object(o[0], "codemodel", 2, 3, check_object_codemodel(g)) + check_index_object(o[0], "codemodel", 2, 4, check_object_codemodel(g)) def check_backtrace(t, b, backtrace): btg = t["backtraceGraph"] @@ -188,6 +188,31 @@ def check_directory(c): expected_keys.append("runtimeDependencySetType") assert is_string(a["runtimeDependencySetType"], e["runtimeDependencySetType"]) + if e.get("fileSetName", None) is not None: + expected_keys.append("fileSetName") + assert is_string(a["fileSetName"], e["fileSetName"]) + + if e.get("fileSetType", None) is not None: + expected_keys.append("fileSetType") + assert is_string(a["fileSetType"], e["fileSetType"]) + + if e.get("fileSetDirectories", None) is not None: + expected_keys.append("fileSetDirectories") + assert is_list(a["fileSetDirectories"]) + assert len(a["fileSetDirectories"]) == len(e["fileSetDirectories"]) + for ad, ed in zip(a["fileSetDirectories"], e["fileSetDirectories"]): + assert matches(ad, ed) + + if e.get("fileSetTarget", None) is not None: + expected_keys.append("fileSetTarget") + et = e["fileSetTarget"] + at = a["fileSetTarget"] + assert is_dict(at) + assert sorted(at.keys()) == ["id", "index"] + assert matches(at["id"], et["id"]) + assert is_int(at["index"]) + assert c["targets"][at["index"]]["name"] == et["index"] + if e["backtrace"] is not None: expected_keys.append("backtrace") check_backtrace(d, a["backtrace"], e["backtrace"]) @@ -628,6 +653,7 @@ def gen_check_directories(c, g): read_codemodel_json_data("directories/dir.json"), read_codemodel_json_data("directories/dir_dir.json"), read_codemodel_json_data("directories/external.json"), + read_codemodel_json_data("directories/fileset.json"), ] if matches(g["name"], "^Visual Studio "): @@ -729,6 +755,9 @@ def gen_check_targets(c, g, inSource): read_codemodel_json_data("targets/all_build_external.json"), read_codemodel_json_data("targets/zero_check_external.json"), read_codemodel_json_data("targets/generated_exe.json"), + + read_codemodel_json_data("targets/c_headers_1.json"), + read_codemodel_json_data("targets/c_headers_2.json"), ] if cxx_compiler_id in ['Clang', 'AppleClang', 'LCC', 'GNU', 'Intel', 'IntelLLVM', 'MSVC', 'Embarcadero'] and g["name"] != "Xcode": diff --git a/Tests/RunCMake/FileAPI/codemodel-v2-data/directories/fileset.json b/Tests/RunCMake/FileAPI/codemodel-v2-data/directories/fileset.json new file mode 100644 index 0000000..4774a13 --- /dev/null +++ b/Tests/RunCMake/FileAPI/codemodel-v2-data/directories/fileset.json @@ -0,0 +1,203 @@ +{ + "source": "^fileset$", + "build": "^fileset$", + "parentSource": "^\\.$", + "childSources": null, + "targetIds": [ + "^c_headers_1::@6b8db101d64c125f29fe$", + "^c_headers_2::@6b8db101d64c125f29fe$" + ], + "projectName": "codemodel-v2", + "minimumCMakeVersion": "3.12", + "hasInstallRule": true, + "installers": [ + { + "component": "Unspecified", + "type": "target", + "destination": "lib", + "paths": [ + "^fileset/((Debug|Release|MinSizeRel|RelWithDebInfo)/)?(lib)?c_headers_1\\.(a|lib)?$" + ], + "isExcludeFromAll": null, + "isForAllComponents": null, + "isOptional": null, + "targetId": "^c_headers_1::@6b8db101d64c125f29fe$", + "targetIndex": "c_headers_1", + "targetIsImportLibrary": null, + "targetInstallNamelink": null, + "exportName": null, + "exportTargets": null, + "scriptFile": null, + "backtrace": [ + { + "file": "^fileset/CMakeLists\\.txt$", + "line": 20, + "command": "install", + "hasParent": true + }, + { + "file": "^fileset/CMakeLists\\.txt$", + "line": null, + "command": null, + "hasParent": false + } + ] + }, + { + "component": "Headers", + "type": "fileSet", + "destination": "include", + "paths": [ + "^fileset/error\\.c$", + "^fileset/other\\.c$" + ], + "isExcludeFromAll": null, + "isForAllComponents": null, + "isOptional": null, + "targetId": null, + "targetIndex": null, + "targetIsImportLibrary": null, + "targetInstallNamelink": null, + "exportName": null, + "exportTargets": null, + "scriptFile": null, + "fileSetName": "HEADERS", + "fileSetType": "HEADERS", + "fileSetDirectories": [ + "^fileset$" + ], + "fileSetTarget": { + "id": "^c_headers_1::@6b8db101d64c125f29fe$", + "index": "c_headers_1" + }, + "backtrace": [ + { + "file": "^fileset/CMakeLists\\.txt$", + "line": 20, + "command": "install", + "hasParent": true + }, + { + "file": "^fileset/CMakeLists\\.txt$", + "line": null, + "command": null, + "hasParent": false + } + ] + }, + { + "component": "Unspecified", + "type": "fileSet", + "destination": "include/dir", + "paths": [ + "^fileset/dir/h2\\.h$" + ], + "isExcludeFromAll": null, + "isForAllComponents": null, + "isOptional": null, + "targetId": null, + "targetIndex": null, + "targetIsImportLibrary": null, + "targetInstallNamelink": null, + "exportName": null, + "exportTargets": null, + "scriptFile": null, + "fileSetName": "b", + "fileSetType": "HEADERS", + "fileSetDirectories": [ + "^fileset/dir$" + ], + "fileSetTarget": { + "id": "^c_headers_1::@6b8db101d64c125f29fe$", + "index": "c_headers_1" + }, + "backtrace": [ + { + "file": "^fileset/CMakeLists\\.txt$", + "line": 20, + "command": "install", + "hasParent": true + }, + { + "file": "^fileset/CMakeLists\\.txt$", + "line": null, + "command": null, + "hasParent": false + } + ] + }, + { + "component": "Unspecified", + "type": "fileSet", + "destination": "include", + "paths": [ + "^fileset/h3\\.h$" + ], + "isExcludeFromAll": null, + "isForAllComponents": null, + "isOptional": null, + "targetId": null, + "targetIndex": null, + "targetIsImportLibrary": null, + "targetInstallNamelink": null, + "exportName": null, + "exportTargets": null, + "scriptFile": null, + "fileSetName": "c", + "fileSetType": "HEADERS", + "fileSetDirectories": [ + "^fileset$" + ], + "fileSetTarget": { + "id": "^c_headers_1::@6b8db101d64c125f29fe$", + "index": "c_headers_1" + }, + "backtrace": [ + { + "file": "^fileset/CMakeLists\\.txt$", + "line": 20, + "command": "install", + "hasParent": true + }, + { + "file": "^fileset/CMakeLists\\.txt$", + "line": null, + "command": null, + "hasParent": false + } + ] + }, + { + "component": "Unspecified", + "type": "target", + "destination": "lib", + "paths": [ + "^fileset/((Debug|Release|MinSizeRel|RelWithDebInfo)/)?(lib)?c_headers_2\\.(a|lib)?$" + ], + "isExcludeFromAll": null, + "isForAllComponents": null, + "isOptional": null, + "targetId": "^c_headers_2::@6b8db101d64c125f29fe$", + "targetIndex": "c_headers_2", + "targetIsImportLibrary": null, + "targetInstallNamelink": null, + "exportName": null, + "exportTargets": null, + "scriptFile": null, + "backtrace": [ + { + "file": "^fileset/CMakeLists\\.txt$", + "line": 25, + "command": "install", + "hasParent": true + }, + { + "file": "^fileset/CMakeLists\\.txt$", + "line": null, + "command": null, + "hasParent": false + } + ] + } + ] +} diff --git a/Tests/RunCMake/FileAPI/codemodel-v2-data/directories/top.json b/Tests/RunCMake/FileAPI/codemodel-v2-data/directories/top.json index 99287fb..22b4536 100644 --- a/Tests/RunCMake/FileAPI/codemodel-v2-data/directories/top.json +++ b/Tests/RunCMake/FileAPI/codemodel-v2-data/directories/top.json @@ -10,7 +10,8 @@ "^interface$", "^object$", "^.*/Tests/RunCMake/FileAPIExternalSource$", - "^dir$" + "^dir$", + "^fileset$" ], "targetIds": [ "^ALL_BUILD::@6890427a1f51a3e7e1df$", @@ -47,7 +48,7 @@ "backtrace": [ { "file": "^codemodel-v2\\.cmake$", - "line": 38, + "line": 39, "command": "install", "hasParent": true }, @@ -92,7 +93,7 @@ "backtrace": [ { "file": "^codemodel-v2\\.cmake$", - "line": 41, + "line": 42, "command": "install", "hasParent": true }, @@ -140,7 +141,7 @@ "backtrace": [ { "file": "^codemodel-v2\\.cmake$", - "line": 41, + "line": 42, "command": "install", "hasParent": true }, @@ -185,7 +186,7 @@ "backtrace": [ { "file": "^codemodel-v2\\.cmake$", - "line": 41, + "line": 42, "command": "install", "hasParent": true }, @@ -229,7 +230,7 @@ "backtrace": [ { "file": "^codemodel-v2\\.cmake$", - "line": 41, + "line": 42, "command": "install", "hasParent": true }, @@ -273,7 +274,7 @@ "backtrace": [ { "file": "^codemodel-v2\\.cmake$", - "line": 46, + "line": 47, "command": "install", "hasParent": true }, @@ -320,7 +321,7 @@ "backtrace": [ { "file": "^codemodel-v2\\.cmake$", - "line": 48, + "line": 49, "command": "install", "hasParent": true }, @@ -365,7 +366,7 @@ "backtrace": [ { "file": "^codemodel-v2\\.cmake$", - "line": 49, + "line": 50, "command": "install", "hasParent": true }, @@ -414,7 +415,7 @@ "backtrace": [ { "file": "^codemodel-v2\\.cmake$", - "line": 50, + "line": 51, "command": "install", "hasParent": true }, @@ -466,7 +467,7 @@ "backtrace": [ { "file": "^codemodel-v2\\.cmake$", - "line": 51, + "line": 52, "command": "install", "hasParent": true }, @@ -515,7 +516,7 @@ "backtrace": [ { "file": "^codemodel-v2\\.cmake$", - "line": 52, + "line": 53, "command": "install", "hasParent": true }, @@ -557,7 +558,7 @@ "backtrace": [ { "file": "^codemodel-v2\\.cmake$", - "line": 53, + "line": 54, "command": "install", "hasParent": true }, @@ -599,7 +600,7 @@ "backtrace": [ { "file": "^codemodel-v2\\.cmake$", - "line": 54, + "line": 55, "command": "install", "hasParent": true }, diff --git a/Tests/RunCMake/FileAPI/codemodel-v2-data/projects/codemodel-v2.json b/Tests/RunCMake/FileAPI/codemodel-v2-data/projects/codemodel-v2.json index 4d0cdc0..0d6c4a1 100644 --- a/Tests/RunCMake/FileAPI/codemodel-v2-data/projects/codemodel-v2.json +++ b/Tests/RunCMake/FileAPI/codemodel-v2-data/projects/codemodel-v2.json @@ -13,7 +13,8 @@ "directorySources": [ "^\\.$", "^dir$", - "^dir/dir$" + "^dir/dir$", + "^fileset$" ], "targetIds": [ "^ALL_BUILD::@6890427a1f51a3e7e1df$", @@ -24,6 +25,8 @@ "^c_shared_lib::@6890427a1f51a3e7e1df$", "^c_shared_exe::@6890427a1f51a3e7e1df$", "^c_static_lib::@6890427a1f51a3e7e1df$", - "^c_static_exe::@6890427a1f51a3e7e1df$" + "^c_static_exe::@6890427a1f51a3e7e1df$", + "^c_headers_1::@6b8db101d64c125f29fe$", + "^c_headers_2::@6b8db101d64c125f29fe$" ] } diff --git a/Tests/RunCMake/FileAPI/codemodel-v2-data/targets/all_build_top.json b/Tests/RunCMake/FileAPI/codemodel-v2-data/targets/all_build_top.json index d023f99..4e772a7 100644 --- a/Tests/RunCMake/FileAPI/codemodel-v2-data/targets/all_build_top.json +++ b/Tests/RunCMake/FileAPI/codemodel-v2-data/targets/all_build_top.json @@ -186,6 +186,14 @@ { "id": "^generated_exe::@[0-9a-f]+$", "backtrace": null + }, + { + "id": "^c_headers_1::@6b8db101d64c125f29fe$", + "backtrace": null + }, + { + "id": "^c_headers_2::@6b8db101d64c125f29fe$", + "backtrace": null } ] } 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 new file mode 100644 index 0000000..c189623 --- /dev/null +++ b/Tests/RunCMake/FileAPI/codemodel-v2-data/targets/c_headers_1.json @@ -0,0 +1,231 @@ +{ + "name": "c_headers_1", + "id": "^c_headers_1::@6b8db101d64c125f29fe$", + "directorySource": "^fileset$", + "projectName": "codemodel-v2", + "type": "STATIC_LIBRARY", + "isGeneratorProvided": null, + "sources": [ + { + "path": "^fileset/empty\\.c$", + "isGenerated": null, + "sourceGroupName": "Source Files", + "compileGroupLanguage": "C", + "backtrace": [ + { + "file": "^fileset/CMakeLists\\.txt$", + "line": 1, + "command": "add_library", + "hasParent": true + }, + { + "file": "^fileset/CMakeLists\\.txt$", + "line": null, + "command": null, + "hasParent": false + } + ] + }, + { + "path": "^fileset/error\\.c$", + "isGenerated": null, + "sourceGroupName": "Header Files", + "compileGroupLanguage": null, + "backtrace": [ + { + "file": "^fileset/CMakeLists\\.txt$", + "line": 3, + "command": "target_sources", + "hasParent": true + }, + { + "file": "^fileset/CMakeLists\\.txt$", + "line": null, + "command": null, + "hasParent": false + } + ] + }, + { + "path": "^fileset/other\\.c$", + "isGenerated": null, + "sourceGroupName": "Source Files", + "compileGroupLanguage": null, + "backtrace": [ + { + "file": "^fileset/CMakeLists\\.txt$", + "line": 3, + "command": "target_sources", + "hasParent": true + }, + { + "file": "^fileset/CMakeLists\\.txt$", + "line": null, + "command": null, + "hasParent": false + } + ] + }, + { + "path": "^fileset/h1\\.h$", + "isGenerated": null, + "sourceGroupName": "Header Files", + "compileGroupLanguage": null, + "backtrace": [ + { + "file": "^fileset/CMakeLists\\.txt$", + "line": 3, + "command": "target_sources", + "hasParent": true + }, + { + "file": "^fileset/CMakeLists\\.txt$", + "line": null, + "command": null, + "hasParent": false + } + ] + }, + { + "path": "^fileset/dir/h2\\.h$", + "isGenerated": null, + "sourceGroupName": "Header Files", + "compileGroupLanguage": null, + "backtrace": [ + { + "file": "^fileset/CMakeLists\\.txt$", + "line": 7, + "command": "target_sources", + "hasParent": true + }, + { + "file": "^fileset/CMakeLists\\.txt$", + "line": null, + "command": null, + "hasParent": false + } + ] + } + ], + "sourceGroups": [ + { + "name": "Source Files", + "sourcePaths": [ + "^fileset/empty\\.c$", + "^fileset/other\\.c$" + ] + }, + { + "name": "Header Files", + "sourcePaths": [ + "^fileset/error\\.c$", + "^fileset/h1\\.h$", + "^fileset/dir/h2\\.h$" + ] + } + ], + "compileGroups": [ + { + "language": "C", + "sourcePaths": [ + "^fileset/empty\\.c$" + ], + "includes": [ + { + "path": "^.*/Tests/RunCMake/FileAPI/fileset$", + "isSystem": null, + "backtrace": [ + { + "file": "^fileset/CMakeLists\\.txt$", + "line": 3, + "command": "target_sources", + "hasParent": true + }, + { + "file": "^fileset/CMakeLists\\.txt$", + "line": null, + "command": null, + "hasParent": false + } + ] + }, + { + "path": "^.*/Tests/RunCMake/FileAPI/fileset/dir$", + "isSystem": null, + "backtrace": [ + { + "file": "^fileset/CMakeLists\\.txt$", + "line": 7, + "command": "target_sources", + "hasParent": true + }, + { + "file": "^fileset/CMakeLists\\.txt$", + "line": null, + "command": null, + "hasParent": false + } + ] + } + ], + "defines": null, + "compileCommandFragments": null + } + ], + "backtrace": [ + { + "file": "^fileset/CMakeLists\\.txt$", + "line": 1, + "command": "add_library", + "hasParent": true + }, + { + "file": "^fileset/CMakeLists\\.txt$", + "line": null, + "command": null, + "hasParent": false + } + ], + "folder": null, + "nameOnDisk": "^(lib)?c_headers_1\\.(a|lib)$", + "artifacts": [ + { + "path": "^fileset/((Debug|Release|RelWithDebInfo|MinSizeRel)/)?(lib)?c_headers_1\\.(a|lib)$", + "_dllExtra": false + } + ], + "build": "^fileset$", + "source": "^fileset$", + "install": { + "prefix": "^(/usr/local|[A-Za-z]:.*/codemodel-v2)$", + "destinations": [ + { + "path": "lib", + "backtrace": [ + { + "file": "^fileset/CMakeLists\\.txt$", + "line": 20, + "command": "install", + "hasParent": true + }, + { + "file": "^fileset/CMakeLists\\.txt$", + "line": null, + "command": null, + "hasParent": false + } + ] + } + ] + }, + "link": null, + "archive": { + "lto": null + }, + "dependencies": [ + { + "id": "^ZERO_CHECK::@6890427a1f51a3e7e1df$", + "backtrace": null + } + ] +} 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 new file mode 100644 index 0000000..75fe58c --- /dev/null +++ b/Tests/RunCMake/FileAPI/codemodel-v2-data/targets/c_headers_2.json @@ -0,0 +1,105 @@ +{ + "name": "c_headers_2", + "id": "^c_headers_2::@6b8db101d64c125f29fe$", + "directorySource": "^fileset$", + "projectName": "codemodel-v2", + "type": "STATIC_LIBRARY", + "isGeneratorProvided": null, + "sources": [ + { + "path": "^fileset/empty\\.c$", + "isGenerated": null, + "sourceGroupName": "Source Files", + "compileGroupLanguage": "C", + "backtrace": [ + { + "file": "^fileset/CMakeLists\\.txt$", + "line": 15, + "command": "add_library", + "hasParent": true + }, + { + "file": "^fileset/CMakeLists\\.txt$", + "line": null, + "command": null, + "hasParent": false + } + ] + } + ], + "sourceGroups": [ + { + "name": "Source Files", + "sourcePaths": [ + "^fileset/empty\\.c$" + ] + } + ], + "compileGroups": [ + { + "language": "C", + "sourcePaths": [ + "^fileset/empty\\.c$" + ], + "includes": null, + "defines": null, + "compileCommandFragments": null + } + ], + "backtrace": [ + { + "file": "^fileset/CMakeLists\\.txt$", + "line": 15, + "command": "add_library", + "hasParent": true + }, + { + "file": "^fileset/CMakeLists\\.txt$", + "line": null, + "command": null, + "hasParent": false + } + ], + "folder": null, + "nameOnDisk": "^(lib)?c_headers_2\\.(a|lib)$", + "artifacts": [ + { + "path": "^fileset/((Debug|Release|RelWithDebInfo|MinSizeRel)/)?(lib)?c_headers_2\\.(a|lib)$", + "_dllExtra": false + } + ], + "build": "^fileset$", + "source": "^fileset$", + "install": { + "prefix": "^(/usr/local|[A-Za-z]:.*/codemodel-v2)$", + "destinations": [ + { + "path": "lib", + "backtrace": [ + { + "file": "^fileset/CMakeLists\\.txt$", + "line": 25, + "command": "install", + "hasParent": true + }, + { + "file": "^fileset/CMakeLists\\.txt$", + "line": null, + "command": null, + "hasParent": false + } + ] + } + ] + }, + "link": null, + "archive": { + "lto": null + }, + "dependencies": [ + { + "id": "^ZERO_CHECK::@6890427a1f51a3e7e1df$", + "backtrace": null + } + ] +} diff --git a/Tests/RunCMake/FileAPI/codemodel-v2-data/targets/c_shared_lib.json b/Tests/RunCMake/FileAPI/codemodel-v2-data/targets/c_shared_lib.json index e3a8d0b..b4318dd 100644 --- a/Tests/RunCMake/FileAPI/codemodel-v2-data/targets/c_shared_lib.json +++ b/Tests/RunCMake/FileAPI/codemodel-v2-data/targets/c_shared_lib.json @@ -115,7 +115,7 @@ "backtrace": [ { "file": "^codemodel-v2\\.cmake$", - "line": 41, + "line": 42, "command": "install", "hasParent": true }, @@ -145,7 +145,7 @@ "backtrace": [ { "file": "^codemodel-v2\\.cmake$", - "line": 41, + "line": 42, "command": "install", "hasParent": true }, @@ -175,7 +175,7 @@ "backtrace": [ { "file": "^codemodel-v2\\.cmake$", - "line": 46, + "line": 47, "command": "install", "hasParent": true }, diff --git a/Tests/RunCMake/FileAPI/codemodel-v2-data/targets/cxx_exe.json b/Tests/RunCMake/FileAPI/codemodel-v2-data/targets/cxx_exe.json index 385fa62..5769f0c 100644 --- a/Tests/RunCMake/FileAPI/codemodel-v2-data/targets/cxx_exe.json +++ b/Tests/RunCMake/FileAPI/codemodel-v2-data/targets/cxx_exe.json @@ -136,7 +136,7 @@ "backtrace": [ { "file": "^codemodel-v2\\.cmake$", - "line": 38, + "line": 39, "command": "install", "hasParent": true }, diff --git a/Tests/RunCMake/FileAPI/codemodel-v2-data/targets/cxx_shared_lib.json b/Tests/RunCMake/FileAPI/codemodel-v2-data/targets/cxx_shared_lib.json index 73e8e12..1fe4d67 100644 --- a/Tests/RunCMake/FileAPI/codemodel-v2-data/targets/cxx_shared_lib.json +++ b/Tests/RunCMake/FileAPI/codemodel-v2-data/targets/cxx_shared_lib.json @@ -91,7 +91,7 @@ "backtrace": [ { "file": "^codemodel-v2\\.cmake$", - "line": 41, + "line": 42, "command": "install", "hasParent": true }, @@ -121,7 +121,7 @@ "backtrace": [ { "file": "^codemodel-v2\\.cmake$", - "line": 41, + "line": 42, "command": "install", "hasParent": true }, @@ -151,7 +151,7 @@ "backtrace": [ { "file": "^codemodel-v2\\.cmake$", - "line": 46, + "line": 47, "command": "install", "hasParent": true }, diff --git a/Tests/RunCMake/FileAPI/codemodel-v2.cmake b/Tests/RunCMake/FileAPI/codemodel-v2.cmake index da928eb..019eb87 100644 --- a/Tests/RunCMake/FileAPI/codemodel-v2.cmake +++ b/Tests/RunCMake/FileAPI/codemodel-v2.cmake @@ -22,6 +22,7 @@ add_subdirectory(interface) add_subdirectory(custom) add_subdirectory("${CMAKE_CURRENT_SOURCE_DIR}/../FileAPIExternalSource" "${CMAKE_CURRENT_BINARY_DIR}/../FileAPIExternalBuild") add_subdirectory(dir) +add_subdirectory(fileset) set_property(TARGET c_shared_lib PROPERTY LIBRARY_OUTPUT_DIRECTORY lib) set_property(TARGET c_shared_lib PROPERTY RUNTIME_OUTPUT_DIRECTORY lib) diff --git a/Tests/RunCMake/FileAPI/fileset/CMakeLists.txt b/Tests/RunCMake/FileAPI/fileset/CMakeLists.txt new file mode 100644 index 0000000..f80f12b --- /dev/null +++ b/Tests/RunCMake/FileAPI/fileset/CMakeLists.txt @@ -0,0 +1,25 @@ +add_library(c_headers_1 STATIC empty.c) + +target_sources(c_headers_1 + PUBLIC FILE_SET HEADERS BASE_DIRS "${CMAKE_CURRENT_SOURCE_DIR}" FILES error.c other.c + PRIVATE FILE_SET a TYPE HEADERS BASE_DIRS "${CMAKE_CURRENT_SOURCE_DIR}" FILES h1.h + ) +target_sources(c_headers_1 + PUBLIC FILE_SET b TYPE HEADERS BASE_DIRS "$<1:${CMAKE_CURRENT_SOURCE_DIR}/dir>" FILES "$<1:${CMAKE_CURRENT_SOURCE_DIR}/dir/h2.h>" + ) +target_sources(c_headers_1 + INTERFACE FILE_SET c TYPE HEADERS BASE_DIRS "${CMAKE_CURRENT_SOURCE_DIR}" FILES h3.h + ) +source_group("Source Files" FILES "${CMAKE_CURRENT_SOURCE_DIR}/other.c") + +add_library(c_headers_2 STATIC empty.c) +target_sources(c_headers_2 + INTERFACE FILE_SET HEADERS BASE_DIRS "${CMAKE_CURRENT_SOURCE_DIR}" FILES h1.h + ) + +install(TARGETS c_headers_1 + FILE_SET HEADERS DESTINATION include COMPONENT Headers + FILE_SET b DESTINATION include/dir + FILE_SET c + ) +install(TARGETS c_headers_2) diff --git a/Tests/RunCMake/FileAPI/fileset/dir/h2.h b/Tests/RunCMake/FileAPI/fileset/dir/h2.h new file mode 100644 index 0000000..e69de29 diff --git a/Tests/RunCMake/FileAPI/fileset/empty.c b/Tests/RunCMake/FileAPI/fileset/empty.c new file mode 100644 index 0000000..e69de29 diff --git a/Tests/RunCMake/FileAPI/fileset/error.c b/Tests/RunCMake/FileAPI/fileset/error.c new file mode 100644 index 0000000..f10e687 --- /dev/null +++ b/Tests/RunCMake/FileAPI/fileset/error.c @@ -0,0 +1 @@ +#error "This should not be compiled" diff --git a/Tests/RunCMake/FileAPI/fileset/h1.h b/Tests/RunCMake/FileAPI/fileset/h1.h new file mode 100644 index 0000000..e69de29 diff --git a/Tests/RunCMake/FileAPI/fileset/h3.h b/Tests/RunCMake/FileAPI/fileset/h3.h new file mode 100644 index 0000000..e69de29 diff --git a/Tests/RunCMake/FileAPI/fileset/other.c b/Tests/RunCMake/FileAPI/fileset/other.c new file mode 100644 index 0000000..e69de29 -- cgit v0.12