diff options
author | Brad King <brad.king@kitware.com> | 2022-08-22 15:40:07 (GMT) |
---|---|---|
committer | Brad King <brad.king@kitware.com> | 2022-08-22 18:51:16 (GMT) |
commit | 0d64c3abd13a0b14f1a14b7717dbac8988d12256 (patch) | |
tree | c925eb0e3a51350002d4e0ca294db5e5f39d431b /Tests/RunCMake/FileAPI | |
parent | ef6a4240babe28fdb7f678288aade9f962b7ec11 (diff) | |
download | CMake-0d64c3abd13a0b14f1a14b7717dbac8988d12256.zip CMake-0d64c3abd13a0b14f1a14b7717dbac8988d12256.tar.gz CMake-0d64c3abd13a0b14f1a14b7717dbac8988d12256.tar.bz2 |
Tests: Add FileAPI case for cross-directory target_* commands
The backtraces for some of the commands incorrectly come from the
target's directory instead of the caller's directory. Expect the
incorrect backtraces in test results for now.
Increase the minimum required version of CMake in the test case
to enable policy CMP0079 to support cross-directory calls.
Issue: #23873
Diffstat (limited to 'Tests/RunCMake/FileAPI')
22 files changed, 247 insertions, 33 deletions
diff --git a/Tests/RunCMake/FileAPI/CMakeLists.txt b/Tests/RunCMake/FileAPI/CMakeLists.txt index 44025d3..9a66cde 100644 --- a/Tests/RunCMake/FileAPI/CMakeLists.txt +++ b/Tests/RunCMake/FileAPI/CMakeLists.txt @@ -1,3 +1,3 @@ -cmake_minimum_required(VERSION 3.12) +cmake_minimum_required(VERSION 3.13) project(${RunCMake_TEST} NONE) include(${RunCMake_TEST}.cmake) diff --git a/Tests/RunCMake/FileAPI/codemodel-v2-check.py b/Tests/RunCMake/FileAPI/codemodel-v2-check.py index 01a004c..b7623de 100644 --- a/Tests/RunCMake/FileAPI/codemodel-v2-check.py +++ b/Tests/RunCMake/FileAPI/codemodel-v2-check.py @@ -664,6 +664,7 @@ def gen_check_directories(c, g): read_codemodel_json_data("directories/dir_dir.json"), read_codemodel_json_data("directories/external.json"), read_codemodel_json_data("directories/fileset.json"), + read_codemodel_json_data("directories/subdir.json"), ] if matches(g["name"], "^Visual Studio "): @@ -722,6 +723,7 @@ def gen_check_targets(c, g, inSource): read_codemodel_json_data("targets/c_shared_exe.json"), read_codemodel_json_data("targets/c_static_lib.json"), read_codemodel_json_data("targets/c_static_exe.json"), + read_codemodel_json_data("targets/c_subdir.json"), read_codemodel_json_data("targets/all_build_cxx.json"), read_codemodel_json_data("targets/zero_check_cxx.json"), diff --git a/Tests/RunCMake/FileAPI/codemodel-v2-data/directories/alias.json b/Tests/RunCMake/FileAPI/codemodel-v2-data/directories/alias.json index 6514910..de8b177 100644 --- a/Tests/RunCMake/FileAPI/codemodel-v2-data/directories/alias.json +++ b/Tests/RunCMake/FileAPI/codemodel-v2-data/directories/alias.json @@ -10,7 +10,7 @@ "^cxx_alias_exe::@53632cba2752272bb008$" ], "projectName": "Alias", - "minimumCMakeVersion": "3.12", + "minimumCMakeVersion": "3.13", "hasInstallRule": null, "installers": [] } diff --git a/Tests/RunCMake/FileAPI/codemodel-v2-data/directories/custom.json b/Tests/RunCMake/FileAPI/codemodel-v2-data/directories/custom.json index c89e4f9..e57191c 100644 --- a/Tests/RunCMake/FileAPI/codemodel-v2-data/directories/custom.json +++ b/Tests/RunCMake/FileAPI/codemodel-v2-data/directories/custom.json @@ -10,7 +10,7 @@ "^custom_tgt::@c11385ffed57b860da63$" ], "projectName": "Custom", - "minimumCMakeVersion": "3.12", + "minimumCMakeVersion": "3.13", "hasInstallRule": null, "installers": [] } diff --git a/Tests/RunCMake/FileAPI/codemodel-v2-data/directories/cxx.json b/Tests/RunCMake/FileAPI/codemodel-v2-data/directories/cxx.json index 8052c1a..28f2b99 100644 --- a/Tests/RunCMake/FileAPI/codemodel-v2-data/directories/cxx.json +++ b/Tests/RunCMake/FileAPI/codemodel-v2-data/directories/cxx.json @@ -16,7 +16,7 @@ "^cxx_static_lib::@a56b12a3f5c0529fb296$" ], "projectName": "Cxx", - "minimumCMakeVersion": "3.12", + "minimumCMakeVersion": "3.13", "hasInstallRule": true, "installers": [ { diff --git a/Tests/RunCMake/FileAPI/codemodel-v2-data/directories/dir.json b/Tests/RunCMake/FileAPI/codemodel-v2-data/directories/dir.json index 8509f08..2a3756e 100644 --- a/Tests/RunCMake/FileAPI/codemodel-v2-data/directories/dir.json +++ b/Tests/RunCMake/FileAPI/codemodel-v2-data/directories/dir.json @@ -7,7 +7,7 @@ ], "targetIds": null, "projectName": "codemodel-v2", - "minimumCMakeVersion": "3.12", + "minimumCMakeVersion": "3.13", "hasInstallRule": null, "installers": [] } diff --git a/Tests/RunCMake/FileAPI/codemodel-v2-data/directories/dir_dir.json b/Tests/RunCMake/FileAPI/codemodel-v2-data/directories/dir_dir.json index 27184cd..12677f2 100644 --- a/Tests/RunCMake/FileAPI/codemodel-v2-data/directories/dir_dir.json +++ b/Tests/RunCMake/FileAPI/codemodel-v2-data/directories/dir_dir.json @@ -5,7 +5,7 @@ "childSources": null, "targetIds": null, "projectName": "codemodel-v2", - "minimumCMakeVersion": "3.12", + "minimumCMakeVersion": "3.13", "hasInstallRule": null, "installers": [] } diff --git a/Tests/RunCMake/FileAPI/codemodel-v2-data/directories/external.json b/Tests/RunCMake/FileAPI/codemodel-v2-data/directories/external.json index 6d2952d..f1199c3 100644 --- a/Tests/RunCMake/FileAPI/codemodel-v2-data/directories/external.json +++ b/Tests/RunCMake/FileAPI/codemodel-v2-data/directories/external.json @@ -9,7 +9,7 @@ "^generated_exe::@[0-9a-f]+$" ], "projectName": "External", - "minimumCMakeVersion": "3.12", + "minimumCMakeVersion": "3.13", "hasInstallRule": true, "installers": [ { diff --git a/Tests/RunCMake/FileAPI/codemodel-v2-data/directories/fileset.json b/Tests/RunCMake/FileAPI/codemodel-v2-data/directories/fileset.json index 4774a13..c4df2ec 100644 --- a/Tests/RunCMake/FileAPI/codemodel-v2-data/directories/fileset.json +++ b/Tests/RunCMake/FileAPI/codemodel-v2-data/directories/fileset.json @@ -8,7 +8,7 @@ "^c_headers_2::@6b8db101d64c125f29fe$" ], "projectName": "codemodel-v2", - "minimumCMakeVersion": "3.12", + "minimumCMakeVersion": "3.13", "hasInstallRule": true, "installers": [ { diff --git a/Tests/RunCMake/FileAPI/codemodel-v2-data/directories/imported.json b/Tests/RunCMake/FileAPI/codemodel-v2-data/directories/imported.json index 92b9526..8210d7f 100644 --- a/Tests/RunCMake/FileAPI/codemodel-v2-data/directories/imported.json +++ b/Tests/RunCMake/FileAPI/codemodel-v2-data/directories/imported.json @@ -13,7 +13,7 @@ "^link_imported_static_exe::@ba7eb709d0b48779c6c8$" ], "projectName": "Imported", - "minimumCMakeVersion": "3.12", + "minimumCMakeVersion": "3.13", "hasInstallRule": true, "installers": [ { diff --git a/Tests/RunCMake/FileAPI/codemodel-v2-data/directories/interface.json b/Tests/RunCMake/FileAPI/codemodel-v2-data/directories/interface.json index 90664dc..08edd64 100644 --- a/Tests/RunCMake/FileAPI/codemodel-v2-data/directories/interface.json +++ b/Tests/RunCMake/FileAPI/codemodel-v2-data/directories/interface.json @@ -9,7 +9,7 @@ "^iface_srcs::@25b7fa8ea00134654b85$" ], "projectName": "Interface", - "minimumCMakeVersion": "3.12", + "minimumCMakeVersion": "3.13", "hasInstallRule": null, "installers": [] } diff --git a/Tests/RunCMake/FileAPI/codemodel-v2-data/directories/subdir.json b/Tests/RunCMake/FileAPI/codemodel-v2-data/directories/subdir.json new file mode 100644 index 0000000..996da47 --- /dev/null +++ b/Tests/RunCMake/FileAPI/codemodel-v2-data/directories/subdir.json @@ -0,0 +1,11 @@ +{ + "source": "^subdir$", + "build": "^subdir$", + "parentSource": "^\\.$", + "childSources": null, + "targetIds": null, + "projectName": "codemodel-v2", + "minimumCMakeVersion": "3.13", + "hasInstallRule": null, + "installers": [] +} diff --git a/Tests/RunCMake/FileAPI/codemodel-v2-data/directories/top.json b/Tests/RunCMake/FileAPI/codemodel-v2-data/directories/top.json index e7b146f..aed07e2 100644 --- a/Tests/RunCMake/FileAPI/codemodel-v2-data/directories/top.json +++ b/Tests/RunCMake/FileAPI/codemodel-v2-data/directories/top.json @@ -11,7 +11,8 @@ "^object$", "^.*/Tests/RunCMake/FileAPIExternalSource$", "^dir$", - "^fileset$" + "^fileset$", + "^subdir$" ], "targetIds": [ "^ALL_BUILD::@6890427a1f51a3e7e1df$", @@ -22,10 +23,11 @@ "^c_shared_lib::@6890427a1f51a3e7e1df$", "^c_static_exe::@6890427a1f51a3e7e1df$", "^c_static_lib::@6890427a1f51a3e7e1df$", + "^c_subdir::@6890427a1f51a3e7e1df$", "^interface_exe::@6890427a1f51a3e7e1df$" ], "projectName": "codemodel-v2", - "minimumCMakeVersion": "3.12", + "minimumCMakeVersion": "3.13", "hasInstallRule": true, "installers": [ { @@ -48,7 +50,7 @@ "backtrace": [ { "file": "^codemodel-v2\\.cmake$", - "line": 39, + "line": 42, "command": "install", "hasParent": true }, @@ -93,7 +95,7 @@ "backtrace": [ { "file": "^codemodel-v2\\.cmake$", - "line": 42, + "line": 45, "command": "install", "hasParent": true }, @@ -141,7 +143,7 @@ "backtrace": [ { "file": "^codemodel-v2\\.cmake$", - "line": 42, + "line": 45, "command": "install", "hasParent": true }, @@ -186,7 +188,7 @@ "backtrace": [ { "file": "^codemodel-v2\\.cmake$", - "line": 42, + "line": 45, "command": "install", "hasParent": true }, @@ -230,7 +232,7 @@ "backtrace": [ { "file": "^codemodel-v2\\.cmake$", - "line": 42, + "line": 45, "command": "install", "hasParent": true }, @@ -274,7 +276,7 @@ "backtrace": [ { "file": "^codemodel-v2\\.cmake$", - "line": 47, + "line": 50, "command": "install", "hasParent": true }, @@ -321,7 +323,7 @@ "backtrace": [ { "file": "^codemodel-v2\\.cmake$", - "line": 49, + "line": 52, "command": "install", "hasParent": true }, @@ -366,7 +368,7 @@ "backtrace": [ { "file": "^codemodel-v2\\.cmake$", - "line": 50, + "line": 53, "command": "install", "hasParent": true }, @@ -415,7 +417,7 @@ "backtrace": [ { "file": "^codemodel-v2\\.cmake$", - "line": 51, + "line": 54, "command": "install", "hasParent": true }, @@ -467,7 +469,7 @@ "backtrace": [ { "file": "^codemodel-v2\\.cmake$", - "line": 52, + "line": 55, "command": "install", "hasParent": true }, @@ -516,7 +518,7 @@ "backtrace": [ { "file": "^codemodel-v2\\.cmake$", - "line": 53, + "line": 56, "command": "install", "hasParent": true }, @@ -558,7 +560,7 @@ "backtrace": [ { "file": "^codemodel-v2\\.cmake$", - "line": 54, + "line": 57, "command": "install", "hasParent": true }, @@ -600,7 +602,7 @@ "backtrace": [ { "file": "^codemodel-v2\\.cmake$", - "line": 55, + "line": 58, "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 0d6c4a1..151c0a8 100644 --- a/Tests/RunCMake/FileAPI/codemodel-v2-data/projects/codemodel-v2.json +++ b/Tests/RunCMake/FileAPI/codemodel-v2-data/projects/codemodel-v2.json @@ -14,7 +14,8 @@ "^\\.$", "^dir$", "^dir/dir$", - "^fileset$" + "^fileset$", + "^subdir$" ], "targetIds": [ "^ALL_BUILD::@6890427a1f51a3e7e1df$", @@ -26,6 +27,7 @@ "^c_shared_exe::@6890427a1f51a3e7e1df$", "^c_static_lib::@6890427a1f51a3e7e1df$", "^c_static_exe::@6890427a1f51a3e7e1df$", + "^c_subdir::@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 4e772a7..0d45d07 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 @@ -96,6 +96,10 @@ "backtrace": null }, { + "id": "^c_subdir::@6890427a1f51a3e7e1df$", + "backtrace": null + }, + { "id": "^c_static_exe::@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 b4318dd..9a210ff 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": 42, + "line": 45, "command": "install", "hasParent": true }, @@ -145,7 +145,7 @@ "backtrace": [ { "file": "^codemodel-v2\\.cmake$", - "line": 42, + "line": 45, "command": "install", "hasParent": true }, @@ -175,7 +175,7 @@ "backtrace": [ { "file": "^codemodel-v2\\.cmake$", - "line": 47, + "line": 50, "command": "install", "hasParent": true }, diff --git a/Tests/RunCMake/FileAPI/codemodel-v2-data/targets/c_subdir.json b/Tests/RunCMake/FileAPI/codemodel-v2-data/targets/c_subdir.json new file mode 100644 index 0000000..799c21e --- /dev/null +++ b/Tests/RunCMake/FileAPI/codemodel-v2-data/targets/c_subdir.json @@ -0,0 +1,186 @@ +{ + "name": "c_subdir", + "id": "^c_subdir::@6890427a1f51a3e7e1df$", + "directorySource": "^\\.$", + "projectName": "codemodel-v2", + "type": "STATIC_LIBRARY", + "isGeneratorProvided": null, + "sources": [ + { + "path": "^subdir/empty\\.c$", + "isGenerated": null, + "sourceGroupName": "Source Files", + "compileGroupLanguage": "C", + "backtrace": [ + { + "file": "^codemodel-v2\\.cmake$", + "line": 18, + "command": "add_subdirectory", + "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 + } + ] + } + ], + "sourceGroups": [ + { + "name": "Source Files", + "sourcePaths": [ + "^subdir/empty\\.c$" + ] + } + ], + "compileGroups": [ + { + "language": "C", + "sourcePaths": [ + "^subdir/empty\\.c$" + ], + "includes": [ + { + "path": "^.*/Tests/RunCMake/FileAPI/subdir$", + "isSystem": null, + "backtrace": [ + { + "file": "^subdir/CMakeLists\\.txt$", + "line": 2, + "command": "target_include_directories", + "hasParent": true + }, + { + "file": "^subdir/CMakeLists\\.txt$", + "line": null, + "command": null, + "hasParent": false + } + ] + } + ], + "defines": [ + { + "define": "SUBDIR", + "backtrace": [ + { + "file": "^codemodel-v2\\.cmake$", + "line": 18, + "command": "add_subdirectory", + "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 + } + ] + } + ], + "compileCommandFragments": null + } + ], + "backtrace": [ + { + "file": "^codemodel-v2\\.cmake$", + "line": 17, + "command": "add_library", + "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 + } + ], + "folder": null, + "nameOnDisk": "^(lib)?c_subdir\\.(a|lib)$", + "artifacts": [ + { + "path": "^((Debug|Release|RelWithDebInfo|MinSizeRel)/)?(lib)?c_subdir\\.(a|lib)$", + "_dllExtra": false + } + ], + "build": "^\\.$", + "source": "^\\.$", + "install": null, + "link": null, + "archive": { + "lto": null + }, + "dependencies": [ + { + "id": "^c_lib::@6890427a1f51a3e7e1df$", + "backtrace": [ + { + "file": "^codemodel-v2\\.cmake$", + "line": 18, + "command": "add_subdirectory", + "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 + } + ] + }, + { + "id": "^ZERO_CHECK::@6890427a1f51a3e7e1df$", + "backtrace": null + } + ] +} 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 5769f0c..16d074a 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": 39, + "line": 42, "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 1fe4d67..03f4cb9 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": 42, + "line": 45, "command": "install", "hasParent": true }, @@ -121,7 +121,7 @@ "backtrace": [ { "file": "^codemodel-v2\\.cmake$", - "line": 42, + "line": 45, "command": "install", "hasParent": true }, @@ -151,7 +151,7 @@ "backtrace": [ { "file": "^codemodel-v2\\.cmake$", - "line": 47, + "line": 50, "command": "install", "hasParent": true }, diff --git a/Tests/RunCMake/FileAPI/codemodel-v2.cmake b/Tests/RunCMake/FileAPI/codemodel-v2.cmake index 019eb87..09db216 100644 --- a/Tests/RunCMake/FileAPI/codemodel-v2.cmake +++ b/Tests/RunCMake/FileAPI/codemodel-v2.cmake @@ -14,6 +14,9 @@ add_library(c_static_lib STATIC empty.c) add_executable(c_static_exe empty.c) target_link_libraries(c_static_exe PRIVATE c_static_lib) +add_library(c_subdir STATIC) +add_subdirectory(subdir) + add_subdirectory(cxx) add_subdirectory(alias) add_subdirectory(object) diff --git a/Tests/RunCMake/FileAPI/subdir/CMakeLists.txt b/Tests/RunCMake/FileAPI/subdir/CMakeLists.txt new file mode 100644 index 0000000..b8f4550 --- /dev/null +++ b/Tests/RunCMake/FileAPI/subdir/CMakeLists.txt @@ -0,0 +1,4 @@ +target_compile_definitions(c_subdir PRIVATE SUBDIR) +target_include_directories(c_subdir PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}) +target_link_libraries(c_subdir PRIVATE c_lib) +target_sources(c_subdir PRIVATE empty.c) diff --git a/Tests/RunCMake/FileAPI/subdir/empty.c b/Tests/RunCMake/FileAPI/subdir/empty.c new file mode 100644 index 0000000..e69de29 --- /dev/null +++ b/Tests/RunCMake/FileAPI/subdir/empty.c |