diff options
author | Brad King <brad.king@kitware.com> | 2023-02-28 13:31:58 (GMT) |
---|---|---|
committer | Kitware Robot <kwrobot@kitware.com> | 2023-02-28 13:32:04 (GMT) |
commit | 12d041b8f7718d9ec48fd3621ddc866a1d3c77cf (patch) | |
tree | c47eb8095ec5e7927ba8798a17ef03db6873e352 | |
parent | 8190d5e40ba0ec61bc49bd565881bf11529b4ddc (diff) | |
parent | 7e3f9aa1b22fe44e7c077b9d8c56cc9eee375958 (diff) | |
download | CMake-12d041b8f7718d9ec48fd3621ddc866a1d3c77cf.zip CMake-12d041b8f7718d9ec48fd3621ddc866a1d3c77cf.tar.gz CMake-12d041b8f7718d9ec48fd3621ddc866a1d3c77cf.tar.bz2 |
Merge topic 'target_sources-file_set-no-exist'
7e3f9aa1b2 target_sources: give a hint when a file named `FILE_SET` is not found
Acked-by: Kitware Robot <kwrobot@kitware.com>
Tested-by: buildbot <buildbot@kitware.com>
Merge-request: !8253
8 files changed, 43 insertions, 0 deletions
diff --git a/Source/cmSourceFile.cxx b/Source/cmSourceFile.cxx index 3fa0051..6224d0e 100644 --- a/Source/cmSourceFile.cxx +++ b/Source/cmSourceFile.cxx @@ -4,6 +4,9 @@ #include <utility> +#include <cm/string_view> +#include <cmext/string_view> + #include "cmGlobalGenerator.h" #include "cmListFileCache.h" #include "cmMakefile.h" @@ -221,6 +224,11 @@ bool cmSourceFile::FindFullPath(std::string* error, case cmPolicies::NEW: break; } + if (lPath == "FILE_SET"_s) { + err += "\nHint: the FILE_SET keyword may only appear after a visibility " + "specifier or another FILE_SET within the target_sources() " + "command."; + } if (error != nullptr) { *error = std::move(err); } else { diff --git a/Tests/RunCMake/target_sources/FileSetDirect-result.txt b/Tests/RunCMake/target_sources/FileSetDirect-result.txt new file mode 100644 index 0000000..d00491f --- /dev/null +++ b/Tests/RunCMake/target_sources/FileSetDirect-result.txt @@ -0,0 +1 @@ +1 diff --git a/Tests/RunCMake/target_sources/FileSetDirect-stderr.txt b/Tests/RunCMake/target_sources/FileSetDirect-stderr.txt new file mode 100644 index 0000000..c1f7635 --- /dev/null +++ b/Tests/RunCMake/target_sources/FileSetDirect-stderr.txt @@ -0,0 +1,12 @@ +CMake Error at FileSetDirect.cmake:3 \(add_library\): + Cannot find source file: + + FILE_SET + + Tried extensions .c .C .c\+\+ .cc .cpp .cxx .cu .mpp .m .M .mm .ixx .cppm .h + .hh .h\+\+ .hm .hpp .hxx .in .txx .f .F .for .f77 .f90 .f95 .f03 .hip .ispc + + Hint: the FILE_SET keyword may only appear after a visibility specifier or + another FILE_SET within the target_sources\(\) command. +Call Stack \(most recent call first\): + CMakeLists.txt:3 \(include\) diff --git a/Tests/RunCMake/target_sources/FileSetDirect.cmake b/Tests/RunCMake/target_sources/FileSetDirect.cmake new file mode 100644 index 0000000..9f412c8 --- /dev/null +++ b/Tests/RunCMake/target_sources/FileSetDirect.cmake @@ -0,0 +1,3 @@ +enable_language(C) + +add_library(lib1 STATIC empty.c FILE_SET h1.h TYPE HEADERS) diff --git a/Tests/RunCMake/target_sources/FileSetWrongSyntax-result.txt b/Tests/RunCMake/target_sources/FileSetWrongSyntax-result.txt new file mode 100644 index 0000000..d00491f --- /dev/null +++ b/Tests/RunCMake/target_sources/FileSetWrongSyntax-result.txt @@ -0,0 +1 @@ +1 diff --git a/Tests/RunCMake/target_sources/FileSetWrongSyntax-stderr.txt b/Tests/RunCMake/target_sources/FileSetWrongSyntax-stderr.txt new file mode 100644 index 0000000..8722347 --- /dev/null +++ b/Tests/RunCMake/target_sources/FileSetWrongSyntax-stderr.txt @@ -0,0 +1,12 @@ +CMake Error at FileSetWrongSyntax.cmake:3 \(add_library\): + Cannot find source file: + + FILE_SET + + Tried extensions .c .C .c\+\+ .cc .cpp .cxx .cu .mpp .m .M .mm .ixx .cppm .h + .hh .h\+\+ .hm .hpp .hxx .in .txx .f .F .for .f77 .f90 .f95 .f03 .hip .ispc + + Hint: the FILE_SET keyword may only appear after a visibility specifier or + another FILE_SET within the target_sources\(\) command. +Call Stack \(most recent call first\): + CMakeLists.txt:3 \(include\) diff --git a/Tests/RunCMake/target_sources/FileSetWrongSyntax.cmake b/Tests/RunCMake/target_sources/FileSetWrongSyntax.cmake new file mode 100644 index 0000000..709fb23 --- /dev/null +++ b/Tests/RunCMake/target_sources/FileSetWrongSyntax.cmake @@ -0,0 +1,4 @@ +enable_language(C) + +add_library(lib1 STATIC) +target_sources(lib1 PRIVATE empty.c FILE_SET h1.h TYPE HEADERS) diff --git a/Tests/RunCMake/target_sources/RunCMakeTest.cmake b/Tests/RunCMake/target_sources/RunCMakeTest.cmake index 7c67c3f..c1314f7 100644 --- a/Tests/RunCMake/target_sources/RunCMakeTest.cmake +++ b/Tests/RunCMake/target_sources/RunCMakeTest.cmake @@ -43,6 +43,8 @@ run_cmake(FileSetNoExistInstall) run_cmake(FileSetDirectories) run_cmake(FileSetCustomTarget) run_cmake(FileSetBadName) +run_cmake(FileSetWrongSyntax) +run_cmake(FileSetDirect) if(APPLE) run_cmake(FileSetFramework) endif() |