target_sources: give a hint when a file named FILE_SET
is not found
`FILE_SET` is only supported within `target_sources()` and only directly after a visibility keyword or another `FILE_SET`. Give a hint as to what might be wrong if a file named `FILE_SET` cannot be found for any reason. Fixes: #24539
This commit is contained in:
parent
35ca2d524b
commit
7e3f9aa1b2
@ -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 {
|
||||
|
1
Tests/RunCMake/target_sources/FileSetDirect-result.txt
Normal file
1
Tests/RunCMake/target_sources/FileSetDirect-result.txt
Normal file
@ -0,0 +1 @@
|
||||
1
|
12
Tests/RunCMake/target_sources/FileSetDirect-stderr.txt
Normal file
12
Tests/RunCMake/target_sources/FileSetDirect-stderr.txt
Normal file
@ -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\)
|
3
Tests/RunCMake/target_sources/FileSetDirect.cmake
Normal file
3
Tests/RunCMake/target_sources/FileSetDirect.cmake
Normal file
@ -0,0 +1,3 @@
|
||||
enable_language(C)
|
||||
|
||||
add_library(lib1 STATIC empty.c FILE_SET h1.h TYPE HEADERS)
|
@ -0,0 +1 @@
|
||||
1
|
12
Tests/RunCMake/target_sources/FileSetWrongSyntax-stderr.txt
Normal file
12
Tests/RunCMake/target_sources/FileSetWrongSyntax-stderr.txt
Normal file
@ -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\)
|
4
Tests/RunCMake/target_sources/FileSetWrongSyntax.cmake
Normal file
4
Tests/RunCMake/target_sources/FileSetWrongSyntax.cmake
Normal file
@ -0,0 +1,4 @@
|
||||
enable_language(C)
|
||||
|
||||
add_library(lib1 STATIC)
|
||||
target_sources(lib1 PRIVATE empty.c FILE_SET h1.h TYPE HEADERS)
|
@ -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()
|
||||
|
Loading…
Reference in New Issue
Block a user