diff options
author | Brad King <brad.king@kitware.com> | 2021-10-28 13:57:53 (GMT) |
---|---|---|
committer | Kitware Robot <kwrobot@kitware.com> | 2021-10-28 13:58:13 (GMT) |
commit | 51e9d93c9c8f45aeebb5566cace2e0d3d7da2fda (patch) | |
tree | 3587b246f886cb40a65a6b413e064c01c1bbd2f4 /Tests | |
parent | a3791b24c9a84788ae426697c768f5126fab8c75 (diff) | |
parent | a7c71b9f035175def9a3e53ed12112c6bb4862e5 (diff) | |
download | CMake-51e9d93c9c8f45aeebb5566cace2e0d3d7da2fda.zip CMake-51e9d93c9c8f45aeebb5566cace2e0d3d7da2fda.tar.gz CMake-51e9d93c9c8f45aeebb5566cace2e0d3d7da2fda.tar.bz2 |
Merge topic 'target-sources-file-set'
a7c71b9f03 Tests: Add tests for target_sources(FILE_SET) and associated functionality
4b0ee4e338 Help: Add documentation for target_sources(FILE_SET) and associated properties
3c3698b0e4 FileAPI: Add information on file set installers
8a09723bff cmGeneratorTarget: Integrate file sets into calculated sources
2a78d47b16 install(EXPORT): Install file sets
9b479124cc install(TARGETS): Add FILE_SET mode
d8af2d954f target_sources(): Add FILE_SET mode
f2bd022468 cmTargetSources: Refactor to add enum class parameters
...
Acked-by: Kitware Robot <kwrobot@kitware.com>
Tested-by: buildbot <buildbot@kitware.com>
Merge-request: !6653
Diffstat (limited to 'Tests')
84 files changed, 1068 insertions, 25 deletions
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 --- /dev/null +++ b/Tests/RunCMake/FileAPI/fileset/dir/h2.h diff --git a/Tests/RunCMake/FileAPI/fileset/empty.c b/Tests/RunCMake/FileAPI/fileset/empty.c new file mode 100644 index 0000000..e69de29 --- /dev/null +++ b/Tests/RunCMake/FileAPI/fileset/empty.c 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 --- /dev/null +++ b/Tests/RunCMake/FileAPI/fileset/h1.h diff --git a/Tests/RunCMake/FileAPI/fileset/h3.h b/Tests/RunCMake/FileAPI/fileset/h3.h new file mode 100644 index 0000000..e69de29 --- /dev/null +++ b/Tests/RunCMake/FileAPI/fileset/h3.h diff --git a/Tests/RunCMake/FileAPI/fileset/other.c b/Tests/RunCMake/FileAPI/fileset/other.c new file mode 100644 index 0000000..e69de29 --- /dev/null +++ b/Tests/RunCMake/FileAPI/fileset/other.c diff --git a/Tests/RunCMake/target_sources/FileSetChangeScope-result.txt b/Tests/RunCMake/target_sources/FileSetChangeScope-result.txt new file mode 100644 index 0000000..d00491f --- /dev/null +++ b/Tests/RunCMake/target_sources/FileSetChangeScope-result.txt @@ -0,0 +1 @@ +1 diff --git a/Tests/RunCMake/target_sources/FileSetChangeScope-stderr.txt b/Tests/RunCMake/target_sources/FileSetChangeScope-stderr.txt new file mode 100644 index 0000000..600d006 --- /dev/null +++ b/Tests/RunCMake/target_sources/FileSetChangeScope-stderr.txt @@ -0,0 +1,5 @@ +^CMake Error at FileSetChangeScope\.cmake:[0-9]+ \(target_sources\): + target_sources Scope PUBLIC for file set "a" does not match original scope + INTERFACE +Call Stack \(most recent call first\): + CMakeLists\.txt:[0-9]+ \(include\)$ diff --git a/Tests/RunCMake/target_sources/FileSetChangeScope.cmake b/Tests/RunCMake/target_sources/FileSetChangeScope.cmake new file mode 100644 index 0000000..9d835fe --- /dev/null +++ b/Tests/RunCMake/target_sources/FileSetChangeScope.cmake @@ -0,0 +1,5 @@ +enable_language(C) + +add_library(lib1 STATIC empty.c) +target_sources(lib1 INTERFACE FILE_SET a TYPE HEADERS) +target_sources(lib1 PUBLIC FILE_SET a) diff --git a/Tests/RunCMake/target_sources/FileSetChangeType-result.txt b/Tests/RunCMake/target_sources/FileSetChangeType-result.txt new file mode 100644 index 0000000..d00491f --- /dev/null +++ b/Tests/RunCMake/target_sources/FileSetChangeType-result.txt @@ -0,0 +1 @@ +1 diff --git a/Tests/RunCMake/target_sources/FileSetChangeType-stderr.txt b/Tests/RunCMake/target_sources/FileSetChangeType-stderr.txt new file mode 100644 index 0000000..85fc718 --- /dev/null +++ b/Tests/RunCMake/target_sources/FileSetChangeType-stderr.txt @@ -0,0 +1,5 @@ +^CMake Error at FileSetChangeType\.cmake:[0-9]+ \(target_sources\): + target_sources Type "RESOURCES" for file set "a" does not match original + type "HEADERS" +Call Stack \(most recent call first\): + CMakeLists\.txt:[0-9]+ \(include\)$ diff --git a/Tests/RunCMake/target_sources/FileSetChangeType.cmake b/Tests/RunCMake/target_sources/FileSetChangeType.cmake new file mode 100644 index 0000000..69eb6bc --- /dev/null +++ b/Tests/RunCMake/target_sources/FileSetChangeType.cmake @@ -0,0 +1,5 @@ +enable_language(C) + +add_library(lib1 STATIC empty.c) +target_sources(lib1 PRIVATE FILE_SET a TYPE HEADERS) +target_sources(lib1 PRIVATE FILE_SET a TYPE RESOURCES) diff --git a/Tests/RunCMake/target_sources/FileSetDefaultWrongType-result.txt b/Tests/RunCMake/target_sources/FileSetDefaultWrongType-result.txt new file mode 100644 index 0000000..d00491f --- /dev/null +++ b/Tests/RunCMake/target_sources/FileSetDefaultWrongType-result.txt @@ -0,0 +1 @@ +1 diff --git a/Tests/RunCMake/target_sources/FileSetDefaultWrongType-stderr.txt b/Tests/RunCMake/target_sources/FileSetDefaultWrongType-stderr.txt new file mode 100644 index 0000000..faf0f5a --- /dev/null +++ b/Tests/RunCMake/target_sources/FileSetDefaultWrongType-stderr.txt @@ -0,0 +1,4 @@ +^CMake Error at FileSetDefaultWrongType\.cmake:[0-9]+ \(target_sources\): + target_sources File set TYPE may only be "HEADERS" +Call Stack \(most recent call first\): + CMakeLists\.txt:[0-9]+ \(include\)$ diff --git a/Tests/RunCMake/target_sources/FileSetDefaultWrongType.cmake b/Tests/RunCMake/target_sources/FileSetDefaultWrongType.cmake new file mode 100644 index 0000000..c810d66 --- /dev/null +++ b/Tests/RunCMake/target_sources/FileSetDefaultWrongType.cmake @@ -0,0 +1,4 @@ +enable_language(C) + +add_library(lib1 STATIC empty.c) +target_sources(lib1 PRIVATE FILE_SET UNKNOWN) diff --git a/Tests/RunCMake/target_sources/FileSetDirectories.cmake b/Tests/RunCMake/target_sources/FileSetDirectories.cmake new file mode 100644 index 0000000..af30b1e --- /dev/null +++ b/Tests/RunCMake/target_sources/FileSetDirectories.cmake @@ -0,0 +1,4 @@ +enable_language(C) + +add_subdirectory(dir3) +add_subdirectory(dir4) diff --git a/Tests/RunCMake/target_sources/FileSetExport.cmake b/Tests/RunCMake/target_sources/FileSetExport.cmake new file mode 100644 index 0000000..cde826a --- /dev/null +++ b/Tests/RunCMake/target_sources/FileSetExport.cmake @@ -0,0 +1,21 @@ +enable_language(C) + +add_library(lib1 STATIC lib1.c) +target_sources(lib1 + PUBLIC FILE_SET HEADERS BASE_DIRS ${CMAKE_CURRENT_SOURCE_DIR} FILES error.c + PRIVATE FILE_SET a TYPE HEADERS BASE_DIRS ${CMAKE_CURRENT_SOURCE_DIR} FILES h1.h + PUBLIC FILE_SET b TYPE HEADERS BASE_DIRS ${CMAKE_CURRENT_SOURCE_DIR} FILES h2.h + INTERFACE FILE_SET c TYPE HEADERS BASE_DIRS "$<1:${CMAKE_CURRENT_SOURCE_DIR}/dir>" FILES "$<1:dir/dir.h>" + INTERFACE FILE_SET d TYPE HEADERS BASE_DIRS FILES "${CMAKE_CURRENT_SOURCE_DIR}/$<IF:$<CONFIG:Debug>,debug,release>/empty.h" + INTERFACE FILE_SET e TYPE HEADERS BASE_DIRS "${CMAKE_CURRENT_SOURCE_DIR}/$<IF:$<CONFIG:Debug>,debug,release>" FILES "${CMAKE_CURRENT_SOURCE_DIR}/$<IF:$<CONFIG:Debug>,debug,release>/empty2.h" + INTERFACE FILE_SET f TYPE HEADERS BASE_DIRS "${CMAKE_CURRENT_SOURCE_DIR}" FILES "${CMAKE_CURRENT_SOURCE_DIR}/empty3.h" + INTERFACE FILE_SET g TYPE HEADERS BASE_DIRS "${CMAKE_CURRENT_SOURCE_DIR}/dir1" "${CMAKE_CURRENT_SOURCE_DIR}/dir2" FILES "${CMAKE_CURRENT_SOURCE_DIR}/dir1/file1.h" "${CMAKE_CURRENT_SOURCE_DIR}/dir2/file2.h" + INTERFACE FILE_SET dir3 TYPE HEADERS BASE_DIRS "${CMAKE_CURRENT_SOURCE_DIR}/dir3" FILES dir3/dir3.h + ) + +install(TARGETS lib1 EXPORT export FILE_SET HEADERS FILE_SET a FILE_SET b FILE_SET c DESTINATION include/dir FILE_SET d FILE_SET e FILE_SET f DESTINATION include/$<IF:$<CONFIG:Debug>,debug,release> FILE_SET g FILE_SET dir3 DESTINATION include/dir3) +install(EXPORT export FILE export.cmake NAMESPACE install:: DESTINATION lib/cmake) +export(EXPORT export FILE export.cmake NAMESPACE export::) + +add_library(lib2 STATIC lib2.c) +target_link_libraries(lib2 PRIVATE lib1) diff --git a/Tests/RunCMake/target_sources/FileSetFileNoExist-result.txt b/Tests/RunCMake/target_sources/FileSetFileNoExist-result.txt new file mode 100644 index 0000000..d00491f --- /dev/null +++ b/Tests/RunCMake/target_sources/FileSetFileNoExist-result.txt @@ -0,0 +1 @@ +1 diff --git a/Tests/RunCMake/target_sources/FileSetFileNoExist-stderr.txt b/Tests/RunCMake/target_sources/FileSetFileNoExist-stderr.txt new file mode 100644 index 0000000..9a2ca6a --- /dev/null +++ b/Tests/RunCMake/target_sources/FileSetFileNoExist-stderr.txt @@ -0,0 +1,10 @@ +^CMake Error at FileSetFileNoExist\.cmake:[0-9]+ \(add_library\): + Cannot find source file: + + [^ +]*/Tests/RunCMake/target_sources/noexist\.h +Call Stack \(most recent call first\): + CMakeLists\.txt:[0-9]+ \(include\) + + +CMake Generate step failed\. Build files cannot be regenerated correctly\.$ diff --git a/Tests/RunCMake/target_sources/FileSetFileNoExist.cmake b/Tests/RunCMake/target_sources/FileSetFileNoExist.cmake new file mode 100644 index 0000000..0df8186 --- /dev/null +++ b/Tests/RunCMake/target_sources/FileSetFileNoExist.cmake @@ -0,0 +1,4 @@ +enable_language(C) + +add_library(lib1 STATIC empty.c) +target_sources(lib1 PRIVATE FILE_SET HEADERS BASE_DIRS ${CMAKE_CURRENT_SOURCE_DIR} FILES noexist.h) diff --git a/Tests/RunCMake/target_sources/FileSetImport.cmake b/Tests/RunCMake/target_sources/FileSetImport.cmake new file mode 100644 index 0000000..9c7358a --- /dev/null +++ b/Tests/RunCMake/target_sources/FileSetImport.cmake @@ -0,0 +1,97 @@ +enable_language(C) + +get_property(_multi_config GLOBAL PROPERTY GENERATOR_IS_MULTI_CONFIG) + +function(assert_prop_eq tgt prop value) + unset(actual_value) + get_property(actual_value TARGET ${tgt} PROPERTY ${prop}) + if(NOT actual_value STREQUAL value) + message(SEND_ERROR "Expected value of ${prop}:\n ${value}\nActual value:\n ${actual_value}") + endif() +endfunction() + +get_filename_component(export_build_dir "${CMAKE_BINARY_DIR}" DIRECTORY) +string(APPEND export_build_dir "/FileSetExport-build") + +include("${export_build_dir}/export.cmake") +include("${export_build_dir}/install/lib/cmake/export.cmake") + +assert_prop_eq(export::lib1 HEADER_SETS "") +assert_prop_eq(export::lib1 INTERFACE_HEADER_SETS "HEADERS;b;c;d;e;f;g;dir3") +assert_prop_eq(export::lib1 HEADER_SET "${CMAKE_CURRENT_SOURCE_DIR}/error.c") +assert_prop_eq(export::lib1 HEADER_DIRS "${CMAKE_CURRENT_SOURCE_DIR}") +assert_prop_eq(export::lib1 HEADER_SET_b "${CMAKE_CURRENT_SOURCE_DIR}/h2.h") +assert_prop_eq(export::lib1 HEADER_DIRS_b "${CMAKE_CURRENT_SOURCE_DIR}") +assert_prop_eq(export::lib1 HEADER_SET_c "$<1:dir/dir.h>") +assert_prop_eq(export::lib1 HEADER_DIRS_c "$<1:${CMAKE_CURRENT_SOURCE_DIR}/dir>") +assert_prop_eq(export::lib1 HEADER_SET_d "${CMAKE_CURRENT_SOURCE_DIR}/$<IF:$<CONFIG:Debug>,debug,release>/empty.h") +assert_prop_eq(export::lib1 HEADER_DIRS_d "${CMAKE_CURRENT_SOURCE_DIR}") +assert_prop_eq(export::lib1 HEADER_SET_e "${CMAKE_CURRENT_SOURCE_DIR}/$<IF:$<CONFIG:Debug>,debug,release>/empty2.h") +assert_prop_eq(export::lib1 HEADER_DIRS_e "${CMAKE_CURRENT_SOURCE_DIR}/$<IF:$<CONFIG:Debug>,debug,release>") +assert_prop_eq(export::lib1 HEADER_SET_f "${CMAKE_CURRENT_SOURCE_DIR}/empty3.h") +assert_prop_eq(export::lib1 HEADER_DIRS_f "${CMAKE_CURRENT_SOURCE_DIR}") +assert_prop_eq(export::lib1 HEADER_SET_g "${CMAKE_CURRENT_SOURCE_DIR}/dir1/file1.h;${CMAKE_CURRENT_SOURCE_DIR}/dir2/file2.h") +assert_prop_eq(export::lib1 HEADER_DIRS_g "${CMAKE_CURRENT_SOURCE_DIR}/dir1;${CMAKE_CURRENT_SOURCE_DIR}/dir2") +assert_prop_eq(export::lib1 INTERFACE_INCLUDE_DIRECTORIES "${CMAKE_CURRENT_SOURCE_DIR};${CMAKE_CURRENT_SOURCE_DIR};$<1:${CMAKE_CURRENT_SOURCE_DIR}/dir>;${CMAKE_CURRENT_SOURCE_DIR};${CMAKE_CURRENT_SOURCE_DIR}/$<IF:$<CONFIG:Debug>,debug,release>;${CMAKE_CURRENT_SOURCE_DIR};${CMAKE_CURRENT_SOURCE_DIR}/dir1;${CMAKE_CURRENT_SOURCE_DIR}/dir2;${CMAKE_CURRENT_SOURCE_DIR}/dir3;$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}>;$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}>;$<BUILD_INTERFACE:$<1:${CMAKE_CURRENT_SOURCE_DIR}/dir>>;$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}>;$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/$<IF:$<CONFIG:Debug>,debug,release>>;$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}>;$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/dir1>;$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/dir2>;$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/dir3>") + +assert_prop_eq(install::lib1 HEADER_SETS "") +assert_prop_eq(install::lib1 INTERFACE_HEADER_SETS "HEADERS;b;c;d;e;f;g;dir3") +assert_prop_eq(install::lib1 HEADER_SET "${export_build_dir}/install/include/error.c") +assert_prop_eq(install::lib1 HEADER_DIRS "${export_build_dir}/install/include") +assert_prop_eq(install::lib1 HEADER_SET_b "${export_build_dir}/install/include/h2.h") +assert_prop_eq(install::lib1 HEADER_DIRS_b "${export_build_dir}/install/include") +assert_prop_eq(install::lib1 HEADER_SET_c "${export_build_dir}/install/include/dir/dir.h") +assert_prop_eq(install::lib1 HEADER_DIRS_c "${export_build_dir}/install/include/dir") +if(_multi_config) + assert_prop_eq(install::lib1 HEADER_SET_d "$<$<CONFIG:Debug>:${export_build_dir}/install/include/debug/empty.h>;$<$<CONFIG:Release>:${export_build_dir}/install/include/release/empty.h>") +else() + assert_prop_eq(install::lib1 HEADER_SET_d "${export_build_dir}/install/include/debug/empty.h") +endif() +assert_prop_eq(install::lib1 HEADER_DIRS_d "${export_build_dir}/install/include") +if(_multi_config) + assert_prop_eq(install::lib1 HEADER_SET_e "$<$<CONFIG:Debug>:${export_build_dir}/install/include/empty2.h>;$<$<CONFIG:Release>:${export_build_dir}/install/include/empty2.h>") +else() + assert_prop_eq(install::lib1 HEADER_SET_e "${export_build_dir}/install/include/empty2.h") +endif() +assert_prop_eq(install::lib1 HEADER_DIRS_e "${export_build_dir}/install/include") +if(_multi_config) + assert_prop_eq(install::lib1 HEADER_SET_f "$<$<CONFIG:Debug>:${export_build_dir}/install/include/debug/empty3.h>;$<$<CONFIG:Release>:${export_build_dir}/install/include/release/empty3.h>") + assert_prop_eq(install::lib1 HEADER_DIRS_f "$<$<CONFIG:Debug>:${export_build_dir}/install/include/debug>;$<$<CONFIG:Release>:${export_build_dir}/install/include/release>") +else() + assert_prop_eq(install::lib1 HEADER_SET_f "${export_build_dir}/install/include/debug/empty3.h") + assert_prop_eq(install::lib1 HEADER_DIRS_f "${export_build_dir}/install/include/debug") +endif() +assert_prop_eq(install::lib1 HEADER_SET_g "${export_build_dir}/install/include/file1.h;${export_build_dir}/install/include/file2.h") +assert_prop_eq(install::lib1 HEADER_DIRS_g "${export_build_dir}/install/include") +if(_multi_config) + assert_prop_eq(install::lib1 INTERFACE_INCLUDE_DIRECTORIES "$<BUILD_INTERFACE:${export_build_dir}/install/include>;$<BUILD_INTERFACE:${export_build_dir}/install/include>;$<BUILD_INTERFACE:${export_build_dir}/install/include/dir>;$<BUILD_INTERFACE:${export_build_dir}/install/include>;$<BUILD_INTERFACE:${export_build_dir}/install/include>;$<BUILD_INTERFACE:$<$<CONFIG:Debug>:${export_build_dir}/install/include/debug>>;$<BUILD_INTERFACE:$<$<CONFIG:Release>:${export_build_dir}/install/include/release>>;$<BUILD_INTERFACE:${export_build_dir}/install/include>;$<BUILD_INTERFACE:${export_build_dir}/install/include/dir3>") +else() + assert_prop_eq(install::lib1 INTERFACE_INCLUDE_DIRECTORIES "$<BUILD_INTERFACE:${export_build_dir}/install/include>;$<BUILD_INTERFACE:${export_build_dir}/install/include>;$<BUILD_INTERFACE:${export_build_dir}/install/include/dir>;$<BUILD_INTERFACE:${export_build_dir}/install/include>;$<BUILD_INTERFACE:${export_build_dir}/install/include>;$<BUILD_INTERFACE:${export_build_dir}/install/include/debug>;$<BUILD_INTERFACE:${export_build_dir}/install/include>;$<BUILD_INTERFACE:${export_build_dir}/install/include/dir3>") +endif() + +file(GLOB_RECURSE actual + LIST_DIRECTORIES TRUE + RELATIVE "${CMAKE_BINARY_DIR}/../FileSetExport-build/install/include" + "${CMAKE_BINARY_DIR}/../FileSetExport-build/install/include/*" + ) +if(actual) + list(SORT actual) +endif() +if(_multi_config) + set(expect "^debug;debug/empty\\.h;debug/empty3\\.h;dir;dir/dir\\.h;dir3;dir3/dir3\.h;empty2\\.h;error\\.c;file1\\.h;file2\\.h;h2\\.h;release;release/empty\\.h;release/empty3\\.h$") +else() + set(expect "^debug;debug/empty\\.h;debug/empty3\\.h;dir;dir/dir\\.h;dir3;dir3/dir3\.h;empty2\\.h;error\\.c;file1\\.h;file2\\.h;h2\\.h$") +endif() +if(NOT "${actual}" MATCHES "${expect}") + message(SEND_ERROR "Installed files: + ${actual} +do not match what we expected: + ${expect} +in directory: + ${CMAKE_INSTALL_PREFIX}") +endif() + +add_library(lib2_export STATIC lib2.c) +target_link_libraries(lib2_export PRIVATE export::lib1) +add_library(lib2_install STATIC lib2.c) +target_link_libraries(lib2_install PRIVATE install::lib1) diff --git a/Tests/RunCMake/target_sources/FileSetInstallMissingSetsInterface-result.txt b/Tests/RunCMake/target_sources/FileSetInstallMissingSetsInterface-result.txt new file mode 100644 index 0000000..d00491f --- /dev/null +++ b/Tests/RunCMake/target_sources/FileSetInstallMissingSetsInterface-result.txt @@ -0,0 +1 @@ +1 diff --git a/Tests/RunCMake/target_sources/FileSetInstallMissingSetsInterface-stderr.txt b/Tests/RunCMake/target_sources/FileSetInstallMissingSetsInterface-stderr.txt new file mode 100644 index 0000000..694f227 --- /dev/null +++ b/Tests/RunCMake/target_sources/FileSetInstallMissingSetsInterface-stderr.txt @@ -0,0 +1,5 @@ +^CMake Error at FileSetInstallMissingSetsInterface\.cmake:[0-9]+ \(install\): + install TARGETS target lib1 is exported but not all of its file sets are + installed +Call Stack \(most recent call first\): + CMakeLists\.txt:[0-9]+ \(include\)$ diff --git a/Tests/RunCMake/target_sources/FileSetInstallMissingSetsInterface.cmake b/Tests/RunCMake/target_sources/FileSetInstallMissingSetsInterface.cmake new file mode 100644 index 0000000..face69e --- /dev/null +++ b/Tests/RunCMake/target_sources/FileSetInstallMissingSetsInterface.cmake @@ -0,0 +1,5 @@ +enable_language(C) + +add_library(lib1 STATIC empty.c) +target_sources(lib1 INTERFACE FILE_SET a TYPE HEADERS BASE_DIRS ${CMAKE_CURRENT_SOURCE_DIR} FILES h1.h) +install(TARGETS lib1 EXPORT a) diff --git a/Tests/RunCMake/target_sources/FileSetInstallMissingSetsPrivate.cmake b/Tests/RunCMake/target_sources/FileSetInstallMissingSetsPrivate.cmake new file mode 100644 index 0000000..84778d1 --- /dev/null +++ b/Tests/RunCMake/target_sources/FileSetInstallMissingSetsPrivate.cmake @@ -0,0 +1,9 @@ +enable_language(C) + +add_library(lib1 STATIC empty.c) +target_sources(lib1 PRIVATE FILE_SET a TYPE HEADERS BASE_DIRS ${CMAKE_CURRENT_SOURCE_DIR} FILES h1.h) +install(TARGETS lib1 EXPORT a) + +add_library(lib2 STATIC empty.c) +target_sources(lib2 INTERFACE FILE_SET a TYPE HEADERS BASE_DIRS ${CMAKE_CURRENT_SOURCE_DIR} FILES h1.h) +install(TARGETS lib2) diff --git a/Tests/RunCMake/target_sources/FileSetNoExistInterface-result.txt b/Tests/RunCMake/target_sources/FileSetNoExistInterface-result.txt new file mode 100644 index 0000000..d00491f --- /dev/null +++ b/Tests/RunCMake/target_sources/FileSetNoExistInterface-result.txt @@ -0,0 +1 @@ +1 diff --git a/Tests/RunCMake/target_sources/FileSetNoExistInterface-stderr.txt b/Tests/RunCMake/target_sources/FileSetNoExistInterface-stderr.txt new file mode 100644 index 0000000..3972c89 --- /dev/null +++ b/Tests/RunCMake/target_sources/FileSetNoExistInterface-stderr.txt @@ -0,0 +1,4 @@ +^CMake Error at FileSetNoExistInterface\.cmake:[0-9]+ \(set_property\): + Header set "a" has not yet been created\. +Call Stack \(most recent call first\): + CMakeLists\.txt:[0-9]+ \(include\)$ diff --git a/Tests/RunCMake/target_sources/FileSetNoExistInterface.cmake b/Tests/RunCMake/target_sources/FileSetNoExistInterface.cmake new file mode 100644 index 0000000..266bc61 --- /dev/null +++ b/Tests/RunCMake/target_sources/FileSetNoExistInterface.cmake @@ -0,0 +1,7 @@ +enable_language(C) + +add_library(lib1 STATIC empty.c) +set_property(TARGET lib1 PROPERTY INTERFACE_HEADER_SETS "a") + +# Error happens at configure-time, so this doesn't help. +target_sources(lib1 INTERFACE FILE_SET a TYPE HEADERS) diff --git a/Tests/RunCMake/target_sources/FileSetNoExistPrivate-result.txt b/Tests/RunCMake/target_sources/FileSetNoExistPrivate-result.txt new file mode 100644 index 0000000..d00491f --- /dev/null +++ b/Tests/RunCMake/target_sources/FileSetNoExistPrivate-result.txt @@ -0,0 +1 @@ +1 diff --git a/Tests/RunCMake/target_sources/FileSetNoExistPrivate-stderr.txt b/Tests/RunCMake/target_sources/FileSetNoExistPrivate-stderr.txt new file mode 100644 index 0000000..336bafe --- /dev/null +++ b/Tests/RunCMake/target_sources/FileSetNoExistPrivate-stderr.txt @@ -0,0 +1,4 @@ +^CMake Error at FileSetNoExistPrivate\.cmake:[0-9]+ \(set_property\): + Header set "a" has not yet been created\. +Call Stack \(most recent call first\): + CMakeLists\.txt:[0-9]+ \(include\)$ diff --git a/Tests/RunCMake/target_sources/FileSetNoExistPrivate.cmake b/Tests/RunCMake/target_sources/FileSetNoExistPrivate.cmake new file mode 100644 index 0000000..f501912 --- /dev/null +++ b/Tests/RunCMake/target_sources/FileSetNoExistPrivate.cmake @@ -0,0 +1,7 @@ +enable_language(C) + +add_library(lib1 STATIC empty.c) +set_property(TARGET lib1 PROPERTY HEADER_SETS "a") + +# Error happens at configure-time, so this doesn't help. +target_sources(lib1 PRIVATE FILE_SET a TYPE HEADERS) diff --git a/Tests/RunCMake/target_sources/FileSetNoScope-result.txt b/Tests/RunCMake/target_sources/FileSetNoScope-result.txt new file mode 100644 index 0000000..d00491f --- /dev/null +++ b/Tests/RunCMake/target_sources/FileSetNoScope-result.txt @@ -0,0 +1 @@ +1 diff --git a/Tests/RunCMake/target_sources/FileSetNoScope-stderr.txt b/Tests/RunCMake/target_sources/FileSetNoScope-stderr.txt new file mode 100644 index 0000000..835ffe7 --- /dev/null +++ b/Tests/RunCMake/target_sources/FileSetNoScope-stderr.txt @@ -0,0 +1,4 @@ +^CMake Error at FileSetNoScope\.cmake:[0-9]+ \(target_sources\): + target_sources File set "a" is not in HEADER_SETS or INTERFACE_HEADER_SETS +Call Stack \(most recent call first\): + CMakeLists\.txt:[0-9]+ \(include\)$ diff --git a/Tests/RunCMake/target_sources/FileSetNoScope.cmake b/Tests/RunCMake/target_sources/FileSetNoScope.cmake new file mode 100644 index 0000000..79ff341 --- /dev/null +++ b/Tests/RunCMake/target_sources/FileSetNoScope.cmake @@ -0,0 +1,6 @@ +enable_language(C) + +add_library(lib1 STATIC empty.c) +target_sources(lib1 PRIVATE FILE_SET a TYPE HEADERS BASE_DIRS ${CMAKE_CURRENT_SOURCE_DIR} FILES h1.h) +set_property(TARGET lib1 PROPERTY HEADER_SETS) +target_sources(lib1 PRIVATE FILE_SET a TYPE HEADERS FILES h2.h) diff --git a/Tests/RunCMake/target_sources/FileSetNoType-result.txt b/Tests/RunCMake/target_sources/FileSetNoType-result.txt new file mode 100644 index 0000000..d00491f --- /dev/null +++ b/Tests/RunCMake/target_sources/FileSetNoType-result.txt @@ -0,0 +1 @@ +1 diff --git a/Tests/RunCMake/target_sources/FileSetNoType-stderr.txt b/Tests/RunCMake/target_sources/FileSetNoType-stderr.txt new file mode 100644 index 0000000..5405fdb --- /dev/null +++ b/Tests/RunCMake/target_sources/FileSetNoType-stderr.txt @@ -0,0 +1,4 @@ +^CMake Error at FileSetNoType\.cmake:[0-9]+ \(target_sources\): + target_sources Must specify a TYPE when creating file set +Call Stack \(most recent call first\): + CMakeLists\.txt:[0-9]+ \(include\)$ diff --git a/Tests/RunCMake/target_sources/FileSetNoType.cmake b/Tests/RunCMake/target_sources/FileSetNoType.cmake new file mode 100644 index 0000000..961525d --- /dev/null +++ b/Tests/RunCMake/target_sources/FileSetNoType.cmake @@ -0,0 +1,4 @@ +enable_language(C) + +add_library(lib1 STATIC empty.c) +target_sources(lib1 PRIVATE FILE_SET a) diff --git a/Tests/RunCMake/target_sources/FileSetOverlappingBaseDirs-result.txt b/Tests/RunCMake/target_sources/FileSetOverlappingBaseDirs-result.txt new file mode 100644 index 0000000..d00491f --- /dev/null +++ b/Tests/RunCMake/target_sources/FileSetOverlappingBaseDirs-result.txt @@ -0,0 +1 @@ +1 diff --git a/Tests/RunCMake/target_sources/FileSetOverlappingBaseDirs-stderr.txt b/Tests/RunCMake/target_sources/FileSetOverlappingBaseDirs-stderr.txt new file mode 100644 index 0000000..551b9e7 --- /dev/null +++ b/Tests/RunCMake/target_sources/FileSetOverlappingBaseDirs-stderr.txt @@ -0,0 +1,9 @@ +CMake Error at FileSetOverlappingBaseDirs\.cmake:[0-9]+ \(target_sources\): + Base directories in file set cannot be subdirectories of each other: + + [^ +]*/Tests/RunCMake/target_sources/\. + [^ +]*/Tests/RunCMake/target_sources/dir3 +Call Stack \(most recent call first\): + CMakeLists\.txt:[0-9]+ \(include\) diff --git a/Tests/RunCMake/target_sources/FileSetOverlappingBaseDirs.cmake b/Tests/RunCMake/target_sources/FileSetOverlappingBaseDirs.cmake new file mode 100644 index 0000000..eba4191 --- /dev/null +++ b/Tests/RunCMake/target_sources/FileSetOverlappingBaseDirs.cmake @@ -0,0 +1,4 @@ +enable_language(C) + +add_library(lib1 STATIC empty.c) +target_sources(lib1 PRIVATE FILE_SET a TYPE HEADERS BASE_DIRS $<1:${CMAKE_CURRENT_SOURCE_DIR}/.$<SEMICOLON>${CMAKE_CURRENT_SOURCE_DIR}/dir3> FILES h1.h) diff --git a/Tests/RunCMake/target_sources/FileSetProperties.cmake b/Tests/RunCMake/target_sources/FileSetProperties.cmake new file mode 100644 index 0000000..ce010a3 --- /dev/null +++ b/Tests/RunCMake/target_sources/FileSetProperties.cmake @@ -0,0 +1,67 @@ +enable_language(C) + +function(assert_prop_undef tgt prop) + unset(actual_value) + get_property(actual_value TARGET ${tgt} PROPERTY ${prop}) + if(DEFINED actual_value) + message(SEND_ERROR "${prop} should be undefined, actual value:\n ${actual_value}") + endif() +endfunction() + +function(assert_prop_eq tgt prop value) + unset(actual_value) + get_property(actual_value TARGET ${tgt} PROPERTY ${prop}) + if(NOT actual_value STREQUAL value) + message(SEND_ERROR "Expected value of ${prop}:\n ${value}\nActual value:\n ${actual_value}") + endif() +endfunction() + +add_library(lib1 STATIC empty.c) +assert_prop_eq(lib1 HEADER_SETS "") +assert_prop_eq(lib1 INTERFACE_HEADER_SETS "") +assert_prop_undef(lib1 INCLUDE_DIRECTORIES) +assert_prop_undef(lib1 INTERFACE_INCLUDE_DIRECTORIES) + +target_sources(lib1 PUBLIC FILE_SET a TYPE HEADERS BASE_DIRS "." FILES h1.h h2.h) +assert_prop_eq(lib1 HEADER_SETS "a") +assert_prop_eq(lib1 INTERFACE_HEADER_SETS "a") +assert_prop_eq(lib1 HEADER_DIRS_a "${CMAKE_CURRENT_SOURCE_DIR}/.") +assert_prop_eq(lib1 HEADER_SET_a "${CMAKE_CURRENT_SOURCE_DIR}/h1.h;${CMAKE_CURRENT_SOURCE_DIR}/h2.h") +assert_prop_eq(lib1 INCLUDE_DIRECTORIES "$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/.>") +assert_prop_eq(lib1 INTERFACE_INCLUDE_DIRECTORIES "$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/.>") + +target_sources(lib1 PUBLIC FILE_SET a FILES h3.h) +assert_prop_eq(lib1 HEADER_SETS "a") +assert_prop_eq(lib1 INTERFACE_HEADER_SETS "a") +assert_prop_eq(lib1 HEADER_DIRS_a "${CMAKE_CURRENT_SOURCE_DIR}/.") +assert_prop_eq(lib1 HEADER_SET_a "${CMAKE_CURRENT_SOURCE_DIR}/h1.h;${CMAKE_CURRENT_SOURCE_DIR}/h2.h;${CMAKE_CURRENT_SOURCE_DIR}/h3.h") +assert_prop_eq(lib1 INCLUDE_DIRECTORIES "$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/.>") +assert_prop_eq(lib1 INTERFACE_INCLUDE_DIRECTORIES "$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/.>") + +target_sources(lib1 PRIVATE FILE_SET b TYPE HEADERS BASE_DIRS "${CMAKE_CURRENT_SOURCE_DIR}/dir" FILES dir/dir.h) +assert_prop_eq(lib1 HEADER_SETS "a;b") +assert_prop_eq(lib1 INTERFACE_HEADER_SETS "a") +assert_prop_eq(lib1 HEADER_DIRS_b "${CMAKE_CURRENT_SOURCE_DIR}/dir") +assert_prop_eq(lib1 HEADER_SET_b "${CMAKE_CURRENT_SOURCE_DIR}/dir/dir.h") +assert_prop_eq(lib1 INCLUDE_DIRECTORIES "$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/.>;$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/dir>") +assert_prop_eq(lib1 INTERFACE_INCLUDE_DIRECTORIES "$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/.>") + +target_sources(lib1 INTERFACE FILE_SET c TYPE HEADERS) +assert_prop_eq(lib1 HEADER_SETS "a;b") +assert_prop_eq(lib1 INTERFACE_HEADER_SETS "a;c") +assert_prop_eq(lib1 HEADER_DIRS_c "${CMAKE_CURRENT_SOURCE_DIR}") +assert_prop_eq(lib1 HEADER_SET_c "") +assert_prop_eq(lib1 INCLUDE_DIRECTORIES "$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/.>;$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/dir>") +assert_prop_eq(lib1 INTERFACE_INCLUDE_DIRECTORIES "$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/.>;$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}>") + +target_sources(lib1 PUBLIC FILE_SET HEADERS BASE_DIRS "${CMAKE_CURRENT_SOURCE_DIR}" FILES h1.h) +assert_prop_eq(lib1 HEADER_DIRS "${CMAKE_CURRENT_SOURCE_DIR}") +assert_prop_eq(lib1 HEADER_SET "${CMAKE_CURRENT_SOURCE_DIR}/h1.h") +assert_prop_eq(lib1 INCLUDE_DIRECTORIES "$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/.>;$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/dir>;$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}>") +assert_prop_eq(lib1 INTERFACE_INCLUDE_DIRECTORIES "$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/.>;$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}>;$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}>") + +target_sources(lib1 PUBLIC FILE_SET HEADERS FILES h2.h) +assert_prop_eq(lib1 HEADER_DIRS "${CMAKE_CURRENT_SOURCE_DIR}") +assert_prop_eq(lib1 HEADER_SET "${CMAKE_CURRENT_SOURCE_DIR}/h1.h;${CMAKE_CURRENT_SOURCE_DIR}/h2.h") +assert_prop_eq(lib1 INCLUDE_DIRECTORIES "$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/.>;$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/dir>;$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}>") +assert_prop_eq(lib1 INTERFACE_INCLUDE_DIRECTORIES "$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/.>;$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}>;$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}>") diff --git a/Tests/RunCMake/target_sources/FileSetWrongBaseDirs-result.txt b/Tests/RunCMake/target_sources/FileSetWrongBaseDirs-result.txt new file mode 100644 index 0000000..d00491f --- /dev/null +++ b/Tests/RunCMake/target_sources/FileSetWrongBaseDirs-result.txt @@ -0,0 +1 @@ +1 diff --git a/Tests/RunCMake/target_sources/FileSetWrongBaseDirs-stderr.txt b/Tests/RunCMake/target_sources/FileSetWrongBaseDirs-stderr.txt new file mode 100644 index 0000000..f4bd447 --- /dev/null +++ b/Tests/RunCMake/target_sources/FileSetWrongBaseDirs-stderr.txt @@ -0,0 +1,12 @@ +CMake Error at FileSetWrongBaseDirs\.cmake:[0-9]+ \(target_sources\): + File: + + [^ +]*/Tests/RunCMake/target_sources/h1\.h + + must be in one of the file set's base directories: + + [^ +]*/Tests/RunCMake/target_sources/dir3 +Call Stack \(most recent call first\): + CMakeLists\.txt:[0-9]+ \(include\) diff --git a/Tests/RunCMake/target_sources/FileSetWrongBaseDirs.cmake b/Tests/RunCMake/target_sources/FileSetWrongBaseDirs.cmake new file mode 100644 index 0000000..38d3abd --- /dev/null +++ b/Tests/RunCMake/target_sources/FileSetWrongBaseDirs.cmake @@ -0,0 +1,4 @@ +enable_language(C) + +add_library(lib1 STATIC empty.c) +target_sources(lib1 PRIVATE FILE_SET a TYPE HEADERS BASE_DIRS ${CMAKE_CURRENT_SOURCE_DIR}/dir3 FILES h1.h) diff --git a/Tests/RunCMake/target_sources/FileSetWrongBaseDirsRelative-result.txt b/Tests/RunCMake/target_sources/FileSetWrongBaseDirsRelative-result.txt new file mode 100644 index 0000000..d00491f --- /dev/null +++ b/Tests/RunCMake/target_sources/FileSetWrongBaseDirsRelative-result.txt @@ -0,0 +1 @@ +1 diff --git a/Tests/RunCMake/target_sources/FileSetWrongBaseDirsRelative-stderr.txt b/Tests/RunCMake/target_sources/FileSetWrongBaseDirsRelative-stderr.txt new file mode 100644 index 0000000..6bb0ec6 --- /dev/null +++ b/Tests/RunCMake/target_sources/FileSetWrongBaseDirsRelative-stderr.txt @@ -0,0 +1,10 @@ +CMake Error at reldir/CMakeLists\.txt:[0-9]+ \(target_sources\): + File: + + [^ +]*/Tests/RunCMake/target_sources/reldir/\.\./h1\.h + + must be in one of the file set's base directories: + + [^ +]*/Tests/RunCMake/target_sources/reldir/\. diff --git a/Tests/RunCMake/target_sources/FileSetWrongBaseDirsRelative.cmake b/Tests/RunCMake/target_sources/FileSetWrongBaseDirsRelative.cmake new file mode 100644 index 0000000..2ca8a8e --- /dev/null +++ b/Tests/RunCMake/target_sources/FileSetWrongBaseDirsRelative.cmake @@ -0,0 +1,3 @@ +enable_language(C) + +add_subdirectory(reldir) diff --git a/Tests/RunCMake/target_sources/FileSetWrongType-result.txt b/Tests/RunCMake/target_sources/FileSetWrongType-result.txt new file mode 100644 index 0000000..d00491f --- /dev/null +++ b/Tests/RunCMake/target_sources/FileSetWrongType-result.txt @@ -0,0 +1 @@ +1 diff --git a/Tests/RunCMake/target_sources/FileSetWrongType-stderr.txt b/Tests/RunCMake/target_sources/FileSetWrongType-stderr.txt new file mode 100644 index 0000000..8ffa786 --- /dev/null +++ b/Tests/RunCMake/target_sources/FileSetWrongType-stderr.txt @@ -0,0 +1,4 @@ +^CMake Error at FileSetWrongType\.cmake:[0-9]+ \(target_sources\): + target_sources File set TYPE may only be "HEADERS" +Call Stack \(most recent call first\): + CMakeLists\.txt:[0-9]+ \(include\)$ diff --git a/Tests/RunCMake/target_sources/FileSetWrongType.cmake b/Tests/RunCMake/target_sources/FileSetWrongType.cmake new file mode 100644 index 0000000..b7dee72 --- /dev/null +++ b/Tests/RunCMake/target_sources/FileSetWrongType.cmake @@ -0,0 +1,4 @@ +enable_language(C) + +add_library(lib1 STATIC empty.c) +target_sources(lib1 PRIVATE FILE_SET a TYPE UNKNOWN) diff --git a/Tests/RunCMake/target_sources/RunCMakeTest.cmake b/Tests/RunCMake/target_sources/RunCMakeTest.cmake index 9d64927..9828fa2 100644 --- a/Tests/RunCMake/target_sources/RunCMakeTest.cmake +++ b/Tests/RunCMake/target_sources/RunCMakeTest.cmake @@ -21,3 +21,60 @@ run_cmake(AddCustomTargetInterfaceSources) run_cmake(AddCustomTargetSources) run_cmake(AddCustomTargetCheckProperty) run_cmake(AddCustomTargetGenx) + +run_cmake(FileSetProperties) +run_cmake(FileSetNoType) +run_cmake(FileSetWrongType) +run_cmake(FileSetDefaultWrongType) +run_cmake(FileSetChangeScope) +run_cmake(FileSetChangeType) +run_cmake(FileSetWrongBaseDirs) +run_cmake(FileSetWrongBaseDirsRelative) +run_cmake(FileSetOverlappingBaseDirs) +run_cmake(FileSetInstallMissingSetsPrivate) +run_cmake(FileSetInstallMissingSetsInterface) +run_cmake(FileSetNoScope) +run_cmake(FileSetNoExistPrivate) +run_cmake(FileSetNoExistInterface) +run_cmake(FileSetDirectories) + +set(RunCMake_TEST_OPTIONS -DCMAKE_POLICY_DEFAULT_CMP0115=NEW) +run_cmake(FileSetFileNoExist) +unset(RunCMake_TEST_OPTIONS) + +function(run_export_import name) + if(RunCMake_GENERATOR_IS_MULTI_CONFIG) + set(_config_options "-DCMAKE_CONFIGURATION_TYPES=Debug\\\\;Release") + else() + set(_config_options -DCMAKE_BUILD_TYPE=Debug) + endif() + + set(RunCMake_TEST_NO_CLEAN 1) + set(RunCMake_TEST_BINARY_DIR "${RunCMake_BINARY_DIR}/${name}Export-build") + set(RunCMake_TEST_OPTIONS "--install-prefix=${RunCMake_TEST_BINARY_DIR}/install" ${_config_options}) + file(REMOVE_RECURSE "${RunCMake_TEST_BINARY_DIR}") + file(MAKE_DIRECTORY "${RunCMake_TEST_BINARY_DIR}") + run_cmake(${name}Export) + run_cmake_command(${name}Export-build ${CMAKE_COMMAND} --build . --config Debug) + run_cmake_command(${name}Export-build ${CMAKE_COMMAND} --install . --config Debug) + if(RunCMake_GENERATOR_IS_MULTI_CONFIG) + run_cmake_command(${name}Export-build ${CMAKE_COMMAND} --build . --config Release) + run_cmake_command(${name}Export-build ${CMAKE_COMMAND} --install . --config Release) + endif() + unset(RunCMake_TEST_OPTIONS) + + set(RunCMake_TEST_BINARY_DIR "${RunCMake_BINARY_DIR}/${name}Import-build") + unset(RunCMake_TEST_OPTIONS) + file(REMOVE_RECURSE "${RunCMake_TEST_BINARY_DIR}") + file(MAKE_DIRECTORY "${RunCMake_TEST_BINARY_DIR}") + run_cmake(${name}Import) + run_cmake_command(${name}Import-build ${CMAKE_COMMAND} --build . --config Debug) + if(RunCMake_GENERATOR_IS_MULTI_CONFIG) + run_cmake_command(${name}Import-build ${CMAKE_COMMAND} --build . --config Release) + endif() + + unset(RunCMake_TEST_BINARY_DIR) + unset(RunCMake_TEST_NO_CLEAN) +endfunction() + +run_export_import(FileSet) diff --git a/Tests/RunCMake/target_sources/debug/empty.h b/Tests/RunCMake/target_sources/debug/empty.h new file mode 100644 index 0000000..e69de29 --- /dev/null +++ b/Tests/RunCMake/target_sources/debug/empty.h diff --git a/Tests/RunCMake/target_sources/debug/empty2.h b/Tests/RunCMake/target_sources/debug/empty2.h new file mode 100644 index 0000000..e69de29 --- /dev/null +++ b/Tests/RunCMake/target_sources/debug/empty2.h diff --git a/Tests/RunCMake/target_sources/dir/dir.h b/Tests/RunCMake/target_sources/dir/dir.h new file mode 100644 index 0000000..e69de29 --- /dev/null +++ b/Tests/RunCMake/target_sources/dir/dir.h diff --git a/Tests/RunCMake/target_sources/dir1/file1.h b/Tests/RunCMake/target_sources/dir1/file1.h new file mode 100644 index 0000000..e69de29 --- /dev/null +++ b/Tests/RunCMake/target_sources/dir1/file1.h diff --git a/Tests/RunCMake/target_sources/dir2/file2.h b/Tests/RunCMake/target_sources/dir2/file2.h new file mode 100644 index 0000000..e69de29 --- /dev/null +++ b/Tests/RunCMake/target_sources/dir2/file2.h diff --git a/Tests/RunCMake/target_sources/dir3/CMakeLists.txt b/Tests/RunCMake/target_sources/dir3/CMakeLists.txt new file mode 100644 index 0000000..e23ceb8 --- /dev/null +++ b/Tests/RunCMake/target_sources/dir3/CMakeLists.txt @@ -0,0 +1 @@ +add_library(lib1 STATIC ../empty.c) diff --git a/Tests/RunCMake/target_sources/dir3/dir3.h b/Tests/RunCMake/target_sources/dir3/dir3.h new file mode 100644 index 0000000..e45c25a --- /dev/null +++ b/Tests/RunCMake/target_sources/dir3/dir3.h @@ -0,0 +1,4 @@ +#ifndef DIR3_H +#define DIR3_H + +#endif diff --git a/Tests/RunCMake/target_sources/dir4/CMakeLists.txt b/Tests/RunCMake/target_sources/dir4/CMakeLists.txt new file mode 100644 index 0000000..6475685 --- /dev/null +++ b/Tests/RunCMake/target_sources/dir4/CMakeLists.txt @@ -0,0 +1,4 @@ +target_sources(lib1 PRIVATE FILE_SET HEADERS BASE_DIRS ${CMAKE_SOURCE_DIR} FILES + $<1:dir3.h> + dir4.h + ) diff --git a/Tests/RunCMake/target_sources/dir4/dir4.h b/Tests/RunCMake/target_sources/dir4/dir4.h new file mode 100644 index 0000000..e69de29 --- /dev/null +++ b/Tests/RunCMake/target_sources/dir4/dir4.h diff --git a/Tests/RunCMake/target_sources/empty.c b/Tests/RunCMake/target_sources/empty.c new file mode 100644 index 0000000..e69de29 --- /dev/null +++ b/Tests/RunCMake/target_sources/empty.c diff --git a/Tests/RunCMake/target_sources/empty3.h b/Tests/RunCMake/target_sources/empty3.h new file mode 100644 index 0000000..e69de29 --- /dev/null +++ b/Tests/RunCMake/target_sources/empty3.h diff --git a/Tests/RunCMake/target_sources/error.c b/Tests/RunCMake/target_sources/error.c new file mode 100644 index 0000000..f10e687 --- /dev/null +++ b/Tests/RunCMake/target_sources/error.c @@ -0,0 +1 @@ +#error "This should not be compiled" diff --git a/Tests/RunCMake/target_sources/h1.h b/Tests/RunCMake/target_sources/h1.h new file mode 100644 index 0000000..e69de29 --- /dev/null +++ b/Tests/RunCMake/target_sources/h1.h diff --git a/Tests/RunCMake/target_sources/h2.h b/Tests/RunCMake/target_sources/h2.h new file mode 100644 index 0000000..e69de29 --- /dev/null +++ b/Tests/RunCMake/target_sources/h2.h diff --git a/Tests/RunCMake/target_sources/h3.h b/Tests/RunCMake/target_sources/h3.h new file mode 100644 index 0000000..e69de29 --- /dev/null +++ b/Tests/RunCMake/target_sources/h3.h diff --git a/Tests/RunCMake/target_sources/lib1.c b/Tests/RunCMake/target_sources/lib1.c new file mode 100644 index 0000000..95042de --- /dev/null +++ b/Tests/RunCMake/target_sources/lib1.c @@ -0,0 +1,6 @@ +#ifdef _WIN32 +__declspec(dllexport) +#endif + void lib1(void) +{ +} diff --git a/Tests/RunCMake/target_sources/lib2.c b/Tests/RunCMake/target_sources/lib2.c new file mode 100644 index 0000000..a060dc9 --- /dev/null +++ b/Tests/RunCMake/target_sources/lib2.c @@ -0,0 +1,8 @@ +#include <dir3.h> + +#ifdef _WIN32 +__declspec(dllexport) +#endif + void lib2(void) +{ +} diff --git a/Tests/RunCMake/target_sources/reldir/CMakeLists.txt b/Tests/RunCMake/target_sources/reldir/CMakeLists.txt new file mode 100644 index 0000000..df22b25 --- /dev/null +++ b/Tests/RunCMake/target_sources/reldir/CMakeLists.txt @@ -0,0 +1,2 @@ +add_library(lib1 STATIC ../empty.c) +target_sources(lib1 PRIVATE FILE_SET HEADERS BASE_DIRS . FILES ../h1.h) diff --git a/Tests/RunCMake/target_sources/release/empty.h b/Tests/RunCMake/target_sources/release/empty.h new file mode 100644 index 0000000..e69de29 --- /dev/null +++ b/Tests/RunCMake/target_sources/release/empty.h diff --git a/Tests/RunCMake/target_sources/release/empty2.h b/Tests/RunCMake/target_sources/release/empty2.h new file mode 100644 index 0000000..e69de29 --- /dev/null +++ b/Tests/RunCMake/target_sources/release/empty2.h |