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
This commit is contained in:
Brad King
2023-02-28 13:31:58 +00:00
committed by Kitware Robot
8 changed files with 43 additions and 0 deletions
+8
View File
@@ -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 {
@@ -0,0 +1 @@
1
@@ -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\)
@@ -0,0 +1,3 @@
enable_language(C)
add_library(lib1 STATIC empty.c FILE_SET h1.h TYPE HEADERS)
@@ -0,0 +1 @@
1
@@ -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\)
@@ -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()