diff options
author | Brad King <brad.king@kitware.com> | 2021-01-14 20:10:49 (GMT) |
---|---|---|
committer | Brad King <brad.king@kitware.com> | 2021-03-16 20:47:43 (GMT) |
commit | a12d7f70b1b97f74293d9861a1827c88ef46ec39 (patch) | |
tree | cc6e798f5ad63468679ef7a3abcb21438173d12a /Tests/RunCMake/FileAPI | |
parent | fd30bd93e6f4334a9cd317a1e5eb8181fffa7a42 (diff) | |
download | CMake-a12d7f70b1b97f74293d9861a1827c88ef46ec39.zip CMake-a12d7f70b1b97f74293d9861a1827c88ef46ec39.tar.gz CMake-a12d7f70b1b97f74293d9861a1827c88ef46ec39.tar.bz2 |
fileapi: Add a "directory" object to codemodel-v2
This object will contain more detailed directory-level information.
Co-Authored-by: Kyle Edwards <kyle.edwards@kitware.com>
Diffstat (limited to 'Tests/RunCMake/FileAPI')
9 files changed, 232 insertions, 10 deletions
diff --git a/Tests/RunCMake/FileAPI/codemodel-v2-ClientStateful-check.cmake b/Tests/RunCMake/FileAPI/codemodel-v2-ClientStateful-check.cmake index fb78e87..91cdf7c 100644 --- a/Tests/RunCMake/FileAPI/codemodel-v2-ClientStateful-check.cmake +++ b/Tests/RunCMake/FileAPI/codemodel-v2-ClientStateful-check.cmake @@ -4,6 +4,7 @@ set(expect query/client-foo/query.json reply reply/codemodel-v2-[0-9a-f]+\\.json + .* reply/index-[0-9.T-]+\\.json .* ) diff --git a/Tests/RunCMake/FileAPI/codemodel-v2-ClientStateless-check.cmake b/Tests/RunCMake/FileAPI/codemodel-v2-ClientStateless-check.cmake index 7c6a35a..9aa9e4a 100644 --- a/Tests/RunCMake/FileAPI/codemodel-v2-ClientStateless-check.cmake +++ b/Tests/RunCMake/FileAPI/codemodel-v2-ClientStateless-check.cmake @@ -4,6 +4,7 @@ set(expect query/client-foo/codemodel-v2 reply reply/codemodel-v2-[0-9a-f]+\\.json + .* reply/index-[0-9.T-]+\\.json .* ) diff --git a/Tests/RunCMake/FileAPI/codemodel-v2-SharedStateless-check.cmake b/Tests/RunCMake/FileAPI/codemodel-v2-SharedStateless-check.cmake index cc2f31b..43d1a0b 100644 --- a/Tests/RunCMake/FileAPI/codemodel-v2-SharedStateless-check.cmake +++ b/Tests/RunCMake/FileAPI/codemodel-v2-SharedStateless-check.cmake @@ -3,6 +3,7 @@ set(expect query/codemodel-v2 reply reply/codemodel-v2-[0-9a-f]+\\.json + .* reply/index-[0-9.T-]+\\.json .* ) diff --git a/Tests/RunCMake/FileAPI/codemodel-v2-check.py b/Tests/RunCMake/FileAPI/codemodel-v2-check.py index e155037..0e5b3b9 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, 2, check_object_codemodel(g)) + check_index_object(o[0], "codemodel", 2, 3, check_object_codemodel(g)) def check_backtrace(t, b, backtrace): btg = t["backtraceGraph"] @@ -55,7 +55,7 @@ def check_backtraces(t, actual, expected): def check_directory(c): def _check(actual, expected): assert is_dict(actual) - expected_keys = ["build", "source", "projectIndex"] + expected_keys = ["build", "jsonFile", "source", "projectIndex"] assert matches(actual["build"], expected["build"]) assert is_int(actual["projectIndex"]) @@ -92,6 +92,17 @@ def check_directory(c): assert sorted(actual.keys()) == sorted(expected_keys) + assert is_string(actual["jsonFile"]) + filepath = os.path.join(reply_dir, actual["jsonFile"]) + with open(filepath) as f: + d = json.load(f) + + assert is_dict(d) + assert sorted(d.keys()) == ["paths"] + + assert is_string(d["paths"]["source"], actual["source"]) + assert is_string(d["paths"]["build"], actual["build"]) + return _check def check_backtrace_graph(btg): @@ -704,6 +715,13 @@ def gen_check_targets(c, g, inSource): if sys.platform not in ("win32", "cygwin", "msys"): for e in expected: e["artifacts"] = filter_list(lambda a: not a["_dllExtra"], e["artifacts"]) + if e["install"] is not None: + e["install"]["destinations"] = filter_list(lambda d: "_dllExtra" not in d or not d["_dllExtra"], e["install"]["destinations"]) + + else: + for e in expected: + if e["install"] is not None: + e["install"]["destinations"] = filter_list(lambda d: "_namelink" not in d or not d["_namelink"], e["install"]["destinations"]) if "aix" not in sys.platform: for e in expected: diff --git a/Tests/RunCMake/FileAPI/codemodel-v2-data/directories/external.json b/Tests/RunCMake/FileAPI/codemodel-v2-data/directories/external.json index 521e3c7..0d3161c 100644 --- a/Tests/RunCMake/FileAPI/codemodel-v2-data/directories/external.json +++ b/Tests/RunCMake/FileAPI/codemodel-v2-data/directories/external.json @@ -10,5 +10,5 @@ ], "projectName": "External", "minimumCMakeVersion": "3.12", - "hasInstallRule": null + "hasInstallRule": true } 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 176a857..5588bd5 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 @@ -90,10 +90,10 @@ } ], "folder": null, - "nameOnDisk": "^(lib|cyg)?c_shared_lib\\.(so|dylib|dll)$", + "nameOnDisk": "^(lib|cyg)?c_shared_lib(-1)?\\.(so|dylib|dll)$", "artifacts": [ { - "path": "^lib/((Debug|Release|RelWithDebInfo|MinSizeRel)/)?(lib|cyg)?c_shared_lib\\.(so|dylib|dll)$", + "path": "^lib/((Debug|Release|RelWithDebInfo|MinSizeRel)/)?(lib|cyg)?c_shared_lib(-1)?\\.(so|dylib|dll)$", "_dllExtra": false }, { @@ -101,13 +101,106 @@ "_dllExtra": true }, { - "path": "^lib/((Debug|Release|RelWithDebInfo|MinSizeRel)/)?(lib|cyg)?c_shared_lib\\.pdb$", + "path": "^lib/((Debug|Release|RelWithDebInfo|MinSizeRel)/)?(lib|cyg)?c_shared_lib(-1)?\\.pdb$", "_dllExtra": true } ], "build": "^\\.$", "source": "^\\.$", - "install": null, + "install": { + "prefix": "^(/usr/local|[A-Za-z]:.*/codemodel-v2)$", + "destinations": [ + { + "path": "lib", + "backtrace": [ + { + "file": "^codemodel-v2\\.cmake$", + "line": 41, + "command": "install", + "hasParent": true + }, + { + "file": "^codemodel-v2\\.cmake$", + "line": null, + "command": null, + "hasParent": true + }, + { + "file": "^CMakeLists\\.txt$", + "line": 3, + "command": "include", + "hasParent": true + }, + { + "file": "^CMakeLists\\.txt$", + "line": null, + "command": null, + "hasParent": false + } + ] + }, + { + "path": "lib", + "_dllExtra": true, + "backtrace": [ + { + "file": "^codemodel-v2\\.cmake$", + "line": 41, + "command": "install", + "hasParent": true + }, + { + "file": "^codemodel-v2\\.cmake$", + "line": null, + "command": null, + "hasParent": true + }, + { + "file": "^CMakeLists\\.txt$", + "line": 3, + "command": "include", + "hasParent": true + }, + { + "file": "^CMakeLists\\.txt$", + "line": null, + "command": null, + "hasParent": false + } + ] + }, + { + "path": "lib", + "_namelink": true, + "backtrace": [ + { + "file": "^codemodel-v2\\.cmake$", + "line": 46, + "command": "install", + "hasParent": true + }, + { + "file": "^codemodel-v2\\.cmake$", + "line": null, + "command": null, + "hasParent": true + }, + { + "file": "^CMakeLists\\.txt$", + "line": 3, + "command": "include", + "hasParent": true + }, + { + "file": "^CMakeLists\\.txt$", + "line": null, + "command": null, + "hasParent": false + } + ] + } + ] + }, "link": { "language": "C", "lto": 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 171a4f5..e5e1d0d 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 @@ -83,7 +83,100 @@ ], "build": "^cxx$", "source": "^cxx$", - "install": null, + "install": { + "prefix": "^(/usr/local|[A-Za-z]:.*/codemodel-v2)$", + "destinations": [ + { + "path": "lib", + "backtrace": [ + { + "file": "^codemodel-v2\\.cmake$", + "line": 41, + "command": "install", + "hasParent": true + }, + { + "file": "^codemodel-v2\\.cmake$", + "line": null, + "command": null, + "hasParent": true + }, + { + "file": "^CMakeLists\\.txt$", + "line": 3, + "command": "include", + "hasParent": true + }, + { + "file": "^CMakeLists\\.txt$", + "line": null, + "command": null, + "hasParent": false + } + ] + }, + { + "path": "lib", + "_dllExtra": true, + "backtrace": [ + { + "file": "^codemodel-v2\\.cmake$", + "line": 41, + "command": "install", + "hasParent": true + }, + { + "file": "^codemodel-v2\\.cmake$", + "line": null, + "command": null, + "hasParent": true + }, + { + "file": "^CMakeLists\\.txt$", + "line": 3, + "command": "include", + "hasParent": true + }, + { + "file": "^CMakeLists\\.txt$", + "line": null, + "command": null, + "hasParent": false + } + ] + }, + { + "path": "lib", + "_namelink": true, + "backtrace": [ + { + "file": "^codemodel-v2\\.cmake$", + "line": 46, + "command": "install", + "hasParent": true + }, + { + "file": "^codemodel-v2\\.cmake$", + "line": null, + "command": null, + "hasParent": true + }, + { + "file": "^CMakeLists\\.txt$", + "line": 3, + "command": "include", + "hasParent": true + }, + { + "file": "^CMakeLists\\.txt$", + "line": null, + "command": null, + "hasParent": false + } + ] + } + ] + }, "link": { "language": "CXX", "lto": null, diff --git a/Tests/RunCMake/FileAPI/codemodel-v2.cmake b/Tests/RunCMake/FileAPI/codemodel-v2.cmake index 2405954..528f075 100644 --- a/Tests/RunCMake/FileAPI/codemodel-v2.cmake +++ b/Tests/RunCMake/FileAPI/codemodel-v2.cmake @@ -35,4 +35,19 @@ if(_ipo) file(WRITE "${CMAKE_BINARY_DIR}/ipo_enabled.txt" "") endif() -install(TARGETS cxx_exe) +install(TARGETS cxx_exe COMPONENT Tools EXPORT FooTargets) + +set_target_properties(c_shared_lib PROPERTIES VERSION 1.2.3 SOVERSION 1) +install(TARGETS c_shared_lib cxx_shared_lib + ARCHIVE DESTINATION lib + RUNTIME DESTINATION lib + LIBRARY DESTINATION lib NAMELINK_SKIP + ) +install(TARGETS c_shared_lib cxx_shared_lib LIBRARY NAMELINK_ONLY) + +install(FILES empty.h TYPE INCLUDE RENAME empty-renamed.h OPTIONAL) +install(FILES codemodel-v2.cmake empty.h DESTINATION include) +install(DIRECTORY . dir cxx/ OPTIONAL DESTINATION dir1) +install(DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}" "${CMAKE_CURRENT_SOURCE_DIR}/dir" "${CMAKE_CURRENT_SOURCE_DIR}/cxx/" DESTINATION dir2) +install(EXPORT FooTargets DESTINATION lib/cmake/foo) +install(SCRIPT InstallScript.cmake) diff --git a/Tests/RunCMake/FileAPI/cxx/CMakeLists.txt b/Tests/RunCMake/FileAPI/cxx/CMakeLists.txt index 76235f5..95c803f 100644 --- a/Tests/RunCMake/FileAPI/cxx/CMakeLists.txt +++ b/Tests/RunCMake/FileAPI/cxx/CMakeLists.txt @@ -16,7 +16,7 @@ target_link_libraries(cxx_static_exe PRIVATE cxx_static_lib) target_compile_options(cxx_exe PUBLIC TargetCompileOptions) target_link_options(cxx_exe PUBLIC TargetLinkOptions) -target_link_directories(cxx_exe PUBLIC "${CMAKE_BINARY_DIR}/TargetLinkDir") +target_link_directories(cxx_exe PUBLIC "$<BUILD_INTERFACE:${CMAKE_BINARY_DIR}/TargetLinkDir>") target_precompile_headers(cxx_exe PUBLIC ../empty.h) |