summaryrefslogtreecommitdiffstats
path: root/Tests/RunCMake
diff options
context:
space:
mode:
authorBrad King <brad.king@kitware.com>2019-09-11 15:38:40 (GMT)
committerKitware Robot <kwrobot@kitware.com>2019-09-11 15:38:58 (GMT)
commit46629d6a49d8a12378778b39bc8827ae2808f3dd (patch)
tree5259f503de23d773dbba2f82a43826aa783b130a /Tests/RunCMake
parent7f46e4a73a4d7aaa4029a04c532d2c99635383b9 (diff)
parent30006e199bb6ac3649332b26c94ccf864e1416b1 (diff)
downloadCMake-46629d6a49d8a12378778b39bc8827ae2808f3dd.zip
CMake-46629d6a49d8a12378778b39bc8827ae2808f3dd.tar.gz
CMake-46629d6a49d8a12378778b39bc8827ae2808f3dd.tar.bz2
Merge topic 'fileapiAddMoreBacktraces'
30006e199b fileapi: add backtraces for compile/link options 291c83f063 cmLocalGenerator: Add GetTargetCompileFlags overload with backtraces 8e973b8e8d cmLocalGenerator: Add GetTargetFlags overload with backtraces 4d5bbb7704 cmLocalGenerator: Add GetStaticLibraryFlags overload with backtraces 1f6a436bf4 cmLocalGenerator: Add AddCompileOptions overload with backtraces 5355a60fd0 cmLocalGenerator: Add AppendCompileOptions overload with backtraces a20d2c85d0 cmLocalGenerator: Add AppendFlags overload with backtraces b13207910e cmLocalGenerator: Clarify AddCompileOptions filter logic ... Acked-by: Kitware Robot <kwrobot@kitware.com> Merge-request: !3775
Diffstat (limited to 'Tests/RunCMake')
-rw-r--r--Tests/RunCMake/FileAPI/codemodel-v2-check.py130
-rw-r--r--Tests/RunCMake/FileAPI/cxx/CMakeLists.txt3
2 files changed, 129 insertions, 4 deletions
diff --git a/Tests/RunCMake/FileAPI/codemodel-v2-check.py b/Tests/RunCMake/FileAPI/codemodel-v2-check.py
index 89f63d0..2a24421 100644
--- a/Tests/RunCMake/FileAPI/codemodel-v2-check.py
+++ b/Tests/RunCMake/FileAPI/codemodel-v2-check.py
@@ -232,17 +232,37 @@ def check_target(c):
assert is_string(obj["link"]["language"], expected["link"]["language"])
- # FIXME: Properly test commandFragments
if "commandFragments" in obj["link"]:
link_keys.append("commandFragments")
assert is_list(obj["link"]["commandFragments"])
for f in obj["link"]["commandFragments"]:
assert is_dict(f)
- assert sorted(f.keys()) == ["fragment", "role"]
+ assert sorted(f.keys()) == ["fragment", "role"] or sorted(f.keys()) == ["backtrace", "fragment", "role"]
assert is_string(f["fragment"])
assert is_string(f["role"])
assert f["role"] in ("flags", "libraries", "libraryPath", "frameworkPath")
+ if expected["link"]["commandFragments"] is not None:
+ def check_link_command_fragments(actual, expected):
+ assert is_dict(actual)
+ expected_keys = ["fragment", "role"]
+
+ if expected["backtrace"] is not None:
+ expected_keys.append("backtrace")
+ assert actual["fragment"] == expected["fragment"]
+ assert actual["role"] == expected["role"]
+ check_backtrace(obj, actual["backtrace"], expected["backtrace"])
+
+ assert sorted(actual.keys()) == sorted(expected_keys)
+
+ check_list_match(lambda a, e: is_string(a["fragment"], e["fragment"]),
+ obj["link"]["commandFragments"], expected["link"]["commandFragments"],
+ check=check_link_command_fragments,
+ check_exception=lambda a, e: "Link fragment: %s" % a["fragment"],
+ missing_exception=lambda e: "Link fragment: %s" % e["fragment"],
+ extra_exception=lambda a: "Link fragment: %s" % a["fragment"],
+ allow_extra=True)
+
if expected["link"]["lto"] is not None:
link_keys.append("lto")
assert is_bool(obj["link"]["lto"], expected["link"]["lto"])
@@ -327,15 +347,33 @@ def check_target(c):
missing_exception=lambda e: "Source path: %s" % e,
extra_exception=lambda a: "Source path: %s" % obj["sources"][a]["path"])
- # FIXME: Properly test compileCommandFragments
if "compileCommandFragments" in actual:
expected_keys.append("compileCommandFragments")
assert is_list(actual["compileCommandFragments"])
for f in actual["compileCommandFragments"]:
assert is_dict(f)
- assert sorted(f.keys()) == ["fragment"]
assert is_string(f["fragment"])
+ if expected["compileCommandFragments"] is not None:
+ def check_compile_command_fragments(actual, expected):
+ assert is_dict(actual)
+ expected_keys = ["fragment"]
+
+ if expected["backtrace"] is not None:
+ expected_keys.append("backtrace")
+ assert actual["fragment"] == expected["fragment"]
+ check_backtrace(obj, actual["backtrace"], expected["backtrace"])
+
+ assert sorted(actual.keys()) == sorted(expected_keys)
+
+ check_list_match(lambda a, e: is_string(a["fragment"], e["fragment"]),
+ actual["compileCommandFragments"], expected["compileCommandFragments"],
+ check=check_compile_command_fragments,
+ check_exception=lambda a, e: "Compile fragment: %s" % a["fragment"],
+ missing_exception=lambda e: "Compile fragment: %s" % e["fragment"],
+ extra_exception=lambda a: "Compile fragment: %s" % a["fragment"],
+ allow_extra=True)
+
if expected["includes"] is not None:
expected_keys.append("includes")
@@ -931,6 +969,7 @@ def gen_check_targets(c, g, inSource):
"backtrace": None,
},
],
+ "compileCommandFragments": None,
},
],
"backtrace": [
@@ -998,6 +1037,7 @@ def gen_check_targets(c, g, inSource):
"link": {
"language": "C",
"lto": None,
+ "commandFragments": None,
},
"archive": None,
"dependencies": [
@@ -1064,6 +1104,7 @@ def gen_check_targets(c, g, inSource):
],
"includes": None,
"defines": None,
+ "compileCommandFragments": None,
},
],
"backtrace": [
@@ -1171,6 +1212,7 @@ def gen_check_targets(c, g, inSource):
],
"includes": None,
"defines": None,
+ "compileCommandFragments": None,
},
],
"backtrace": [
@@ -1217,6 +1259,7 @@ def gen_check_targets(c, g, inSource):
"link": {
"language": "C",
"lto": None,
+ "commandFragments": None,
},
"archive": None,
"dependencies": [
@@ -1317,6 +1360,7 @@ def gen_check_targets(c, g, inSource):
"backtrace": None,
},
],
+ "compileCommandFragments": None,
},
],
"backtrace": [
@@ -1367,6 +1411,7 @@ def gen_check_targets(c, g, inSource):
"link": {
"language": "C",
"lto": True,
+ "commandFragments": None,
},
"archive": None,
"dependencies": [
@@ -1433,6 +1478,7 @@ def gen_check_targets(c, g, inSource):
],
"includes": None,
"defines": None,
+ "compileCommandFragments": None,
},
],
"backtrace": [
@@ -1479,6 +1525,7 @@ def gen_check_targets(c, g, inSource):
"link": {
"language": "C",
"lto": True,
+ "commandFragments": None,
},
"archive": None,
"dependencies": [
@@ -1574,6 +1621,7 @@ def gen_check_targets(c, g, inSource):
],
"includes": None,
"defines": None,
+ "compileCommandFragments": None,
},
],
"backtrace": [
@@ -1681,6 +1729,7 @@ def gen_check_targets(c, g, inSource):
],
"includes": None,
"defines": None,
+ "compileCommandFragments": None,
},
],
"backtrace": [
@@ -1727,6 +1776,7 @@ def gen_check_targets(c, g, inSource):
"link": {
"language": "C",
"lto": None,
+ "commandFragments": None,
},
"archive": None,
"dependencies": [
@@ -1979,6 +2029,7 @@ def gen_check_targets(c, g, inSource):
],
"includes": None,
"defines": None,
+ "compileCommandFragments": None,
},
],
"backtrace": [
@@ -2062,6 +2113,25 @@ def gen_check_targets(c, g, inSource):
],
"includes": None,
"defines": None,
+ "compileCommandFragments": [
+ {
+ "fragment" : "TargetCompileOptions",
+ "backtrace": [
+ {
+ "file": "^cxx/CMakeLists\\.txt$",
+ "line": 17,
+ "command": "target_compile_options",
+ "hasParent": True,
+ },
+ {
+ "file" : "^cxx/CMakeLists\\.txt$",
+ "line": None,
+ "command": None,
+ "hasParent": False,
+ },
+ ],
+ }
+ ],
},
],
"backtrace": [
@@ -2129,6 +2199,26 @@ def gen_check_targets(c, g, inSource):
"link": {
"language": "CXX",
"lto": None,
+ "commandFragments": [
+ {
+ "fragment" : "TargetLinkOptions",
+ "role" : "flags",
+ "backtrace": [
+ {
+ "file": "^cxx/CMakeLists\\.txt$",
+ "line": 18,
+ "command": "target_link_options",
+ "hasParent": True,
+ },
+ {
+ "file" : "^cxx/CMakeLists\\.txt$",
+ "line": None,
+ "command": None,
+ "hasParent": False,
+ },
+ ],
+ },
+ ],
},
"archive": None,
"dependencies": [
@@ -2205,6 +2295,7 @@ def gen_check_targets(c, g, inSource):
"backtrace": None,
},
],
+ "compileCommandFragments": None,
},
],
"backtrace": [
@@ -2243,6 +2334,7 @@ def gen_check_targets(c, g, inSource):
"link": {
"language": "CXX",
"lto": None,
+ "commandFragments": None,
},
"archive": None,
"dependencies": [
@@ -2297,6 +2389,7 @@ def gen_check_targets(c, g, inSource):
],
"includes": None,
"defines": None,
+ "compileCommandFragments": None,
},
],
"backtrace": [
@@ -2331,6 +2424,7 @@ def gen_check_targets(c, g, inSource):
"link": {
"language": "CXX",
"lto": None,
+ "commandFragments": None,
},
"archive": None,
"dependencies": [
@@ -2402,6 +2496,7 @@ def gen_check_targets(c, g, inSource):
],
"includes": None,
"defines": None,
+ "compileCommandFragments": None,
},
],
"backtrace": [
@@ -2485,6 +2580,7 @@ def gen_check_targets(c, g, inSource):
],
"includes": None,
"defines": None,
+ "compileCommandFragments": None,
},
],
"backtrace": [
@@ -2519,6 +2615,7 @@ def gen_check_targets(c, g, inSource):
"link": {
"language": "CXX",
"lto": None,
+ "commandFragments": None,
},
"archive": None,
"dependencies": [
@@ -2743,6 +2840,7 @@ def gen_check_targets(c, g, inSource):
],
"includes": None,
"defines": None,
+ "compileCommandFragments": None,
},
],
"backtrace": [
@@ -2777,6 +2875,7 @@ def gen_check_targets(c, g, inSource):
"link": {
"language": "C",
"lto": None,
+ "commandFragments": None,
},
"archive": None,
"dependencies": [
@@ -2848,6 +2947,7 @@ def gen_check_targets(c, g, inSource):
],
"includes": None,
"defines": None,
+ "compileCommandFragments": None,
},
],
"backtrace": [
@@ -2882,6 +2982,7 @@ def gen_check_targets(c, g, inSource):
"link": {
"language": "CXX",
"lto": None,
+ "commandFragments": None,
},
"archive": None,
"dependencies": [
@@ -3114,6 +3215,7 @@ def gen_check_targets(c, g, inSource):
],
"includes": None,
"defines": None,
+ "compileCommandFragments": None,
},
],
"backtrace": [
@@ -3221,6 +3323,7 @@ def gen_check_targets(c, g, inSource):
],
"includes": None,
"defines": None,
+ "compileCommandFragments": None,
},
],
"backtrace": [
@@ -3276,6 +3379,7 @@ def gen_check_targets(c, g, inSource):
"link": {
"language": "C",
"lto": None,
+ "commandFragments": None,
},
"archive": None,
"dependencies": [
@@ -3337,6 +3441,7 @@ def gen_check_targets(c, g, inSource):
],
"includes": None,
"defines": None,
+ "compileCommandFragments": None,
},
],
"backtrace": [
@@ -3444,6 +3549,7 @@ def gen_check_targets(c, g, inSource):
],
"includes": None,
"defines": None,
+ "compileCommandFragments": None,
},
],
"backtrace": [
@@ -3499,6 +3605,7 @@ def gen_check_targets(c, g, inSource):
"link": {
"language": "CXX",
"lto": None,
+ "commandFragments": None,
},
"archive": None,
"dependencies": [
@@ -3725,6 +3832,7 @@ def gen_check_targets(c, g, inSource):
],
"includes": None,
"defines": None,
+ "compileCommandFragments": None,
},
],
"backtrace": [
@@ -3759,6 +3867,7 @@ def gen_check_targets(c, g, inSource):
"link": {
"language": "C",
"lto": None,
+ "commandFragments": None,
},
"archive": None,
"dependencies": [
@@ -3813,6 +3922,7 @@ def gen_check_targets(c, g, inSource):
],
"includes": None,
"defines": None,
+ "compileCommandFragments": None,
},
],
"backtrace": [
@@ -3847,6 +3957,7 @@ def gen_check_targets(c, g, inSource):
"link": {
"language": "C",
"lto": None,
+ "commandFragments": None,
},
"archive": None,
"dependencies": [
@@ -3901,6 +4012,7 @@ def gen_check_targets(c, g, inSource):
],
"includes": None,
"defines": None,
+ "compileCommandFragments": None,
},
],
"backtrace": [
@@ -3935,6 +4047,7 @@ def gen_check_targets(c, g, inSource):
"link": {
"language": "C",
"lto": None,
+ "commandFragments": None,
},
"archive": None,
"dependencies": [
@@ -3989,6 +4102,7 @@ def gen_check_targets(c, g, inSource):
],
"includes": None,
"defines": None,
+ "compileCommandFragments": None,
},
],
"backtrace": [
@@ -4023,6 +4137,7 @@ def gen_check_targets(c, g, inSource):
"link": {
"language": "C",
"lto": None,
+ "commandFragments": None,
},
"archive": None,
"dependencies": [
@@ -4077,6 +4192,7 @@ def gen_check_targets(c, g, inSource):
],
"includes": None,
"defines": None,
+ "compileCommandFragments": None,
},
],
"backtrace": [
@@ -4111,6 +4227,7 @@ def gen_check_targets(c, g, inSource):
"link": {
"language": "C",
"lto": None,
+ "commandFragments": None,
},
"archive": None,
"dependencies": [
@@ -4401,6 +4518,7 @@ def gen_check_targets(c, g, inSource):
],
"includes": None,
"defines": None,
+ "compileCommandFragments": None,
},
],
"backtrace": [
@@ -4435,6 +4553,7 @@ def gen_check_targets(c, g, inSource):
"link": {
"language": "C",
"lto": None,
+ "commandFragments": None,
},
"archive": None,
"dependencies": [
@@ -4748,6 +4867,7 @@ def gen_check_targets(c, g, inSource):
],
},
],
+ "compileCommandFragments": None,
},
{
"language": "CXX",
@@ -4810,6 +4930,7 @@ def gen_check_targets(c, g, inSource):
],
},
],
+ "compileCommandFragments": None,
},
],
"backtrace": [
@@ -4844,6 +4965,7 @@ def gen_check_targets(c, g, inSource):
"link": {
"language": "CXX",
"lto": None,
+ "commandFragments": None,
},
"archive": None,
"dependencies": [
diff --git a/Tests/RunCMake/FileAPI/cxx/CMakeLists.txt b/Tests/RunCMake/FileAPI/cxx/CMakeLists.txt
index 29b61b8..17ff455 100644
--- a/Tests/RunCMake/FileAPI/cxx/CMakeLists.txt
+++ b/Tests/RunCMake/FileAPI/cxx/CMakeLists.txt
@@ -13,3 +13,6 @@ target_link_libraries(cxx_shared_exe PRIVATE cxx_shared_lib)
add_library(cxx_static_lib STATIC ../empty.cxx)
add_executable(cxx_static_exe ../empty.cxx)
target_link_libraries(cxx_static_exe PRIVATE cxx_static_lib)
+
+target_compile_options(cxx_exe PUBLIC TargetCompileOptions)
+target_link_options(cxx_exe PUBLIC TargetLinkOptions)