mirror of
https://github.com/reactos/CMake.git
synced 2025-02-01 01:22:58 +00:00
include: Ignore empty string as file name (#13388)
Previously CMake silently accepted the empty string and added a bogus dependency on the current directory. Instead warn about the empty file name and ignore it. We cannot make this an error because there may be existing projects that accidentally depend on the old behavior. Add a RunCMake.include test to cover this case.
This commit is contained in:
parent
6274ca6f91
commit
2e99949ccb
@ -70,6 +70,13 @@ bool cmIncludeCommand
|
||||
}
|
||||
}
|
||||
|
||||
if(fname.empty())
|
||||
{
|
||||
this->Makefile->IssueMessage(cmake::AUTHOR_WARNING,
|
||||
"include() given empty file name (ignored).");
|
||||
return true;
|
||||
}
|
||||
|
||||
if(!cmSystemTools::FileIsFullPath(fname.c_str()))
|
||||
{
|
||||
// Not a path. Maybe module.
|
||||
|
@ -50,6 +50,7 @@ add_RunCMake_test(ObjectLibrary)
|
||||
|
||||
add_RunCMake_test(build_command)
|
||||
add_RunCMake_test(find_package)
|
||||
add_RunCMake_test(include)
|
||||
add_RunCMake_test(list)
|
||||
|
||||
if("${CMAKE_TEST_GENERATOR}" MATCHES "Visual Studio [^6]")
|
||||
|
3
Tests/RunCMake/include/CMakeLists.txt
Normal file
3
Tests/RunCMake/include/CMakeLists.txt
Normal file
@ -0,0 +1,3 @@
|
||||
cmake_minimum_required(VERSION 2.8)
|
||||
project(${RunCMake_TEST} NONE)
|
||||
include(${RunCMake_TEST}.cmake)
|
5
Tests/RunCMake/include/EmptyString-stderr.txt
Normal file
5
Tests/RunCMake/include/EmptyString-stderr.txt
Normal file
@ -0,0 +1,5 @@
|
||||
CMake Warning \(dev\) at EmptyString.cmake:1 \(include\):
|
||||
include\(\) given empty file name \(ignored\).
|
||||
Call Stack \(most recent call first\):
|
||||
CMakeLists.txt:3 \(include\)
|
||||
This warning is for project developers. Use -Wno-dev to suppress it.
|
1
Tests/RunCMake/include/EmptyString.cmake
Normal file
1
Tests/RunCMake/include/EmptyString.cmake
Normal file
@ -0,0 +1 @@
|
||||
include("")
|
5
Tests/RunCMake/include/EmptyStringOptional-stderr.txt
Normal file
5
Tests/RunCMake/include/EmptyStringOptional-stderr.txt
Normal file
@ -0,0 +1,5 @@
|
||||
CMake Warning \(dev\) at EmptyStringOptional.cmake:1 \(include\):
|
||||
include\(\) given empty file name \(ignored\).
|
||||
Call Stack \(most recent call first\):
|
||||
CMakeLists.txt:3 \(include\)
|
||||
This warning is for project developers. Use -Wno-dev to suppress it.
|
1
Tests/RunCMake/include/EmptyStringOptional.cmake
Normal file
1
Tests/RunCMake/include/EmptyStringOptional.cmake
Normal file
@ -0,0 +1 @@
|
||||
include("" OPTIONAL)
|
4
Tests/RunCMake/include/RunCMakeTest.cmake
Normal file
4
Tests/RunCMake/include/RunCMakeTest.cmake
Normal file
@ -0,0 +1,4 @@
|
||||
include(RunCMake)
|
||||
|
||||
run_cmake(EmptyString)
|
||||
run_cmake(EmptyStringOptional)
|
Loading…
x
Reference in New Issue
Block a user