diff options
author | Kyle Edwards <kyle.edwards@kitware.com> | 2021-06-02 18:55:43 (GMT) |
---|---|---|
committer | Kyle Edwards <kyle.edwards@kitware.com> | 2021-06-04 19:25:18 (GMT) |
commit | 8d898cb3e10d6ad44bbe542b7b219a0b788b2a0d (patch) | |
tree | a51dcab0e25d6b932fe82450b3f660d682907993 | |
parent | 72f2448e82d8b3e90fa733cb6c631298083ae06b (diff) | |
download | CMake-8d898cb3e10d6ad44bbe542b7b219a0b788b2a0d.zip CMake-8d898cb3e10d6ad44bbe542b7b219a0b788b2a0d.tar.gz CMake-8d898cb3e10d6ad44bbe542b7b219a0b788b2a0d.tar.bz2 |
FileAPI: Add integration for runtime dependency installers
-rw-r--r-- | Help/manual/cmake-file-api.7.rst | 24 | ||||
-rw-r--r-- | Source/cmFileAPICodemodel.cxx | 28 | ||||
-rw-r--r-- | Tests/RunCMake/FileAPI/codemodel-v2-check.py | 16 | ||||
-rw-r--r-- | Tests/RunCMake/FileAPI/codemodel-v2-data/directories/cxx.json | 163 | ||||
-rw-r--r-- | Tests/RunCMake/FileAPI/codemodel-v2-data/targets/cxx_exe.json | 17 | ||||
-rw-r--r-- | Tests/RunCMake/FileAPI/cxx/CMakeLists.txt | 15 |
6 files changed, 259 insertions, 4 deletions
diff --git a/Help/manual/cmake-file-api.7.rst b/Help/manual/cmake-file-api.7.rst index e7d78c3..5e22ea9 100644 --- a/Help/manual/cmake-file-api.7.rst +++ b/Help/manual/cmake-file-api.7.rst @@ -752,6 +752,12 @@ with members: The ``destination`` member is populated. The ``isOptional`` member may exist. This type has no additional members. + ``runtimeDependencySet`` + An :command:`install(RUNTIME_DEPENDENCY_SET)` call or an + :command:`install(TARGETS)` call with ``RUNTIME_DEPENDENCIES``. The + ``destination`` member is populated. This type has additional members + ``runtimeDependencySetName`` and ``runtimeDependencySetType``. + ``isExcludeFromAll`` Optional member that is present with boolean value ``true`` when :command:`install` is called with the ``EXCLUDE_FROM_ALL`` option. @@ -811,6 +817,24 @@ with members: An unsigned integer 0-based index into the main "codemodel" object's ``targets`` array for the target. + ``runtimeDependencySetName`` + Optional member that is present when ``type`` is ``runtimeDependencySet`` + and the installer was created by an + :command:`install(RUNTIME_DEPENDENCY_SET)` call. The value is a string + specifying the name of the runtime dependency set that was installed. + + ``runtimeDependencySetType`` + Optional member that is present when ``type`` is ``runtimeDependencySet``. + The value is a string with one of the following values: + + ``library`` + Indicates that this installer installs dependencies that are not macOS + frameworks. + + ``framework`` + Indicates that this installer installs dependencies that are macOS + frameworks. + ``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/cmFileAPICodemodel.cxx b/Source/cmFileAPICodemodel.cxx index ff11f4a..2c15c25 100644 --- a/Source/cmFileAPICodemodel.cxx +++ b/Source/cmFileAPICodemodel.cxx @@ -15,6 +15,7 @@ #include <utility> #include <vector> +#include <cm/string_view> #include <cmext/algorithm> #include <cm3p/json/value.h> @@ -29,7 +30,10 @@ #include "cmInstallExportGenerator.h" #include "cmInstallFilesGenerator.h" #include "cmInstallGenerator.h" +#include "cmInstallGetRuntimeDependenciesGenerator.h" #include "cmInstallImportedRuntimeArtifactsGenerator.h" +#include "cmInstallRuntimeDependencySet.h" +#include "cmInstallRuntimeDependencySetGenerator.h" #include "cmInstallScriptGenerator.h" #include "cmInstallSubdirectoryGenerator.h" #include "cmInstallTargetGenerator.h" @@ -876,8 +880,10 @@ Json::Value DirectoryObject::DumpInstaller(cmInstallGenerator* gen) { Json::Value installer = Json::objectValue; - // Exclude subdirectory installers. They are implementation details. - if (dynamic_cast<cmInstallSubdirectoryGenerator*>(gen)) { + // Exclude subdirectory installers and file(GET_RUNTIME_DEPENDENCIES) + // installers. They are implementation details. + if (dynamic_cast<cmInstallSubdirectoryGenerator*>(gen) || + dynamic_cast<cmInstallGetRuntimeDependenciesGenerator*>(gen)) { return installer; } @@ -1019,6 +1025,24 @@ Json::Value DirectoryObject::DumpInstaller(cmInstallGenerator* gen) if (installImportedRuntimeArtifacts->GetOptional()) { installer["isOptional"] = true; } + } else if (auto* installRuntimeDependencySet = + dynamic_cast<cmInstallRuntimeDependencySetGenerator*>(gen)) { + installer["type"] = "runtimeDependencySet"; + installer["destination"] = + installRuntimeDependencySet->GetDestination(this->Config); + std::string name( + installRuntimeDependencySet->GetRuntimeDependencySet()->GetName()); + if (!name.empty()) { + installer["runtimeDependencySetName"] = name; + } + switch (installRuntimeDependencySet->GetDependencyType()) { + case cmInstallRuntimeDependencySetGenerator::DependencyType::Framework: + installer["runtimeDependencySetType"] = "framework"; + break; + case cmInstallRuntimeDependencySetGenerator::DependencyType::Library: + installer["runtimeDependencySetType"] = "library"; + break; + } } // Add fields common to all install generators. diff --git a/Tests/RunCMake/FileAPI/codemodel-v2-check.py b/Tests/RunCMake/FileAPI/codemodel-v2-check.py index 9911ad5..6cf57a3 100644 --- a/Tests/RunCMake/FileAPI/codemodel-v2-check.py +++ b/Tests/RunCMake/FileAPI/codemodel-v2-check.py @@ -180,6 +180,14 @@ def check_directory(c): expected_keys.append("scriptFile") assert is_string(a["scriptFile"], e["scriptFile"]) + if e.get("runtimeDependencySetName", None) is not None: + expected_keys.append("runtimeDependencySetName") + assert is_string(a["runtimeDependencySetName"], e["runtimeDependencySetName"]) + + if e.get("runtimeDependencySetType", None) is not None: + expected_keys.append("runtimeDependencySetType") + assert is_string(a["runtimeDependencySetType"], e["runtimeDependencySetType"]) + if e["backtrace"] is not None: expected_keys.append("backtrace") check_backtrace(d, a["backtrace"], e["backtrace"]) @@ -650,6 +658,14 @@ def gen_check_directories(c, g): if "pathsNamelink" in i: i["paths"] = i["pathsNamelink"] + if sys.platform not in ("win32", "darwin") and "linux" not in sys.platform: + for e in expected: + e["installers"] = list(filter(lambda i: i["type"] != "runtimeDependencySet", e["installers"])) + + if sys.platform != "darwin": + for e in expected: + e["installers"] = list(filter(lambda i: i.get("runtimeDependencySetType", None) != "framework", e["installers"])) + return expected def check_directories(c, g): diff --git a/Tests/RunCMake/FileAPI/codemodel-v2-data/directories/cxx.json b/Tests/RunCMake/FileAPI/codemodel-v2-data/directories/cxx.json index 7168306..8052c1a 100644 --- a/Tests/RunCMake/FileAPI/codemodel-v2-data/directories/cxx.json +++ b/Tests/RunCMake/FileAPI/codemodel-v2-data/directories/cxx.json @@ -17,6 +17,165 @@ ], "projectName": "Cxx", "minimumCMakeVersion": "3.12", - "hasInstallRule": null, - "installers": [] + "hasInstallRule": true, + "installers": [ + { + "component": "Unspecified", + "type": "target", + "destination": "lib", + "paths": [ + "^cxx/((Debug|Release|MinSizeRel|RelWithDebInfo)/)?cxx_exe(\\.exe)?$" + ], + "isExcludeFromAll": null, + "isForAllComponents": null, + "isOptional": null, + "targetId": "^cxx_exe::@a56b12a3f5c0529fb296$", + "targetIndex": "cxx_exe", + "targetIsImportLibrary": null, + "targetInstallNamelink": null, + "exportName": null, + "exportTargets": null, + "scriptFile": null, + "backtrace": [ + { + "file": "^cxx/CMakeLists\\.txt$", + "line": 38, + "command": "install", + "hasParent": true + }, + { + "file": "^cxx/CMakeLists\\.txt$", + "line": null, + "command": null, + "hasParent": false + } + ] + }, + { + "component": "Unspecified", + "type": "runtimeDependencySet", + "destination": "lib", + "paths": null, + "isExcludeFromAll": null, + "isForAllComponents": null, + "isOptional": null, + "targetId": null, + "targetIndex": null, + "targetIsImportLibrary": null, + "targetInstallNamelink": null, + "exportName": null, + "exportTargets": null, + "scriptFile": null, + "runtimeDependencySetType": "library", + "backtrace": [ + { + "file": "^cxx/CMakeLists\\.txt$", + "line": 38, + "command": "install", + "hasParent": true + }, + { + "file": "^cxx/CMakeLists\\.txt$", + "line": null, + "command": null, + "hasParent": false + } + ] + }, + { + "component": "Unspecified", + "type": "runtimeDependencySet", + "destination": "fw", + "paths": null, + "isExcludeFromAll": null, + "isForAllComponents": null, + "isOptional": null, + "targetId": null, + "targetIndex": null, + "targetIsImportLibrary": null, + "targetInstallNamelink": null, + "exportName": null, + "exportTargets": null, + "scriptFile": null, + "runtimeDependencySetType": "framework", + "backtrace": [ + { + "file": "^cxx/CMakeLists\\.txt$", + "line": 38, + "command": "install", + "hasParent": true + }, + { + "file": "^cxx/CMakeLists\\.txt$", + "line": null, + "command": null, + "hasParent": false + } + ] + }, + { + "component": "Unspecified", + "type": "runtimeDependencySet", + "destination": "lib", + "paths": null, + "isExcludeFromAll": null, + "isForAllComponents": null, + "isOptional": null, + "targetId": null, + "targetIndex": null, + "targetIsImportLibrary": null, + "targetInstallNamelink": null, + "exportName": null, + "exportTargets": null, + "scriptFile": null, + "runtimeDependencySetType": "library", + "runtimeDependencySetName": "deps", + "backtrace": [ + { + "file": "^cxx/CMakeLists\\.txt$", + "line": 43, + "command": "install", + "hasParent": true + }, + { + "file": "^cxx/CMakeLists\\.txt$", + "line": null, + "command": null, + "hasParent": false + } + ] + }, + { + "component": "Unspecified", + "type": "runtimeDependencySet", + "destination": "fw", + "paths": null, + "isExcludeFromAll": null, + "isForAllComponents": null, + "isOptional": null, + "targetId": null, + "targetIndex": null, + "targetIsImportLibrary": null, + "targetInstallNamelink": null, + "exportName": null, + "exportTargets": null, + "scriptFile": null, + "runtimeDependencySetType": "framework", + "runtimeDependencySetName": "deps", + "backtrace": [ + { + "file": "^cxx/CMakeLists\\.txt$", + "line": 43, + "command": "install", + "hasParent": true + }, + { + "file": "^cxx/CMakeLists\\.txt$", + "line": null, + "command": null, + "hasParent": false + } + ] + } + ] } 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 c9e652b..385fa62 100644 --- a/Tests/RunCMake/FileAPI/codemodel-v2-data/targets/cxx_exe.json +++ b/Tests/RunCMake/FileAPI/codemodel-v2-data/targets/cxx_exe.json @@ -115,6 +115,23 @@ "prefix": "^(/usr/local|[A-Za-z]:.*/codemodel-v2)$", "destinations": [ { + "path": "lib", + "backtrace": [ + { + "file": "^cxx/CMakeLists\\.txt$", + "line": 38, + "command": "install", + "hasParent": true + }, + { + "file": "^cxx/CMakeLists\\.txt$", + "line": null, + "command": null, + "hasParent": false + } + ] + }, + { "path": "bin", "backtrace": [ { diff --git a/Tests/RunCMake/FileAPI/cxx/CMakeLists.txt b/Tests/RunCMake/FileAPI/cxx/CMakeLists.txt index 95c803f..3ae3b60 100644 --- a/Tests/RunCMake/FileAPI/cxx/CMakeLists.txt +++ b/Tests/RunCMake/FileAPI/cxx/CMakeLists.txt @@ -30,3 +30,18 @@ if(CMAKE_CXX_STANDARD_DEFAULT AND DEFINED CMAKE_CXX11_STANDARD_COMPILE_OPTION) target_compile_features(cxx_standard_compile_feature_exe PRIVATE cxx_decltype) file(WRITE "${CMAKE_CURRENT_BINARY_DIR}/cxx_std_11.txt" "") endif() + +set(_rdeps) +if(CMAKE_SYSTEM_NAME MATCHES "^(Linux|Windows|Darwin)$") + set(_rdeps RUNTIME_DEPENDENCIES) +endif() +install(TARGETS cxx_exe ${_rdeps} + DESTINATION lib + FRAMEWORK DESTINATION fw + ) +if(_rdeps) + install(RUNTIME_DEPENDENCY_SET deps + DESTINATION lib + FRAMEWORK DESTINATION fw + ) +endif() |