Merge topic 'warn-no-internal-modules'

d3bb3cafe9 Modules: not produce warnings for CMake internals

Acked-by: Kitware Robot <kwrobot@kitware.com>
Tested-by: buildbot <buildbot@kitware.com>
Merge-request: !12275
This commit is contained in:
Brad King
2026-07-17 10:32:36 -04:00
committed by Kitware Robot
5 changed files with 51 additions and 0 deletions
+7
View File
@@ -2533,6 +2533,13 @@ struct t_lookup
bool cmMakefile::IsProjectFile(char const* filename) const
{
std::string const& cmakeRoot = cmSystemTools::GetCMakeRoot();
if (cmSystemTools::IsSubDirectory(filename, cmakeRoot) &&
(cmSystemTools::IsSubDirectory(cmakeRoot, this->GetHomeDirectory()) ||
cmSystemTools::IsSubDirectory(cmakeRoot,
this->GetHomeOutputDirectory()))) {
return false;
}
return cmSystemTools::IsSubDirectory(filename, this->GetHomeDirectory()) ||
(cmSystemTools::IsSubDirectory(filename, this->GetHomeOutputDirectory()) &&
!cmSystemTools::IsSubDirectory(filename, "/CMakeFiles"));
@@ -1118,6 +1118,7 @@ unset(RunCMake_TEST_OPTIONS)
set(RunCMake_TEST_OPTIONS -Wno-deprecated -Wuninitialized)
run_cmake(Wuninitialized)
run_cmake(WuninitializedCMakeRoot)
unset(RunCMake_TEST_OPTIONS)
run_cmake_command(W_bad-arg1 ${CMAKE_COMMAND} -B DummyBuildDir -W)
@@ -0,0 +1,2 @@
set(CMAKE_COMMAND "${WuninitializedCMakeRoot_SAVED_CMAKE_COMMAND}")
set(ENV{PATH} "${WuninitializedCMakeRoot_SAVED_PATH}")
@@ -0,0 +1,38 @@
# Place CMAKE_ROOT under the project source and run that nested cmake.
set(WuninitializedCMakeRoot_SAVED_CMAKE_COMMAND "${CMAKE_COMMAND}")
set(WuninitializedCMakeRoot_SAVED_PATH "$ENV{PATH}")
set(RunCMake_TEST_SOURCE_DIR "${RunCMake_BINARY_DIR}/WuninitializedCMakeRoot-src")
set(nested "${RunCMake_TEST_SOURCE_DIR}/nested")
set(cmake_root "${RunCMake_TEST_SOURCE_DIR}/cmake_root")
file(REMOVE_RECURSE "${RunCMake_TEST_SOURCE_DIR}")
file(MAKE_DIRECTORY "${RunCMake_TEST_SOURCE_DIR}" "${nested}/bin" "${nested}/CMakeFiles")
file(COPY "${RunCMake_SOURCE_DIR}/CMakeLists.txt"
"${RunCMake_SOURCE_DIR}/WuninitializedCMakeRoot.cmake"
DESTINATION "${RunCMake_TEST_SOURCE_DIR}")
file(CREATE_LINK "${CMAKE_ROOT}" "${cmake_root}" SYMBOLIC RESULT _link_result)
if(_link_result)
file(COPY "${CMAKE_ROOT}/Modules" DESTINATION "${cmake_root}")
endif()
file(WRITE "${nested}/CMakeFiles/CMakeSourceDir.txt" "${cmake_root}\n")
# Use the same file name as CMAKE_COMMAND (script mode may leave
# CMAKE_EXECUTABLE_SUFFIX empty).
get_filename_component(_cmake_name "${CMAKE_COMMAND}" NAME)
set(_nested_cmake "${nested}/bin/${_cmake_name}")
file(CREATE_LINK "${CMAKE_COMMAND}" "${_nested_cmake}" COPY_ON_ERROR RESULT _link_result)
if(_link_result)
message(FATAL_ERROR "Failed to link/copy cmake for WuninitializedCMakeRoot: ${_link_result}")
endif()
get_filename_component(_cmake_bin_dir "${CMAKE_COMMAND}" DIRECTORY)
if(CMAKE_HOST_WIN32)
set(ENV{PATH} "${_cmake_bin_dir};$ENV{PATH}")
else()
set(ENV{PATH} "${_cmake_bin_dir}:$ENV{PATH}")
endif()
set(CMAKE_COMMAND "${_nested_cmake}")
@@ -0,0 +1,3 @@
# Issue 27896: configuring with -Wuninitialized must not warn for Modules
# when CMAKE_ROOT lives inside the project source tree.
# Setup is in WuninitializedCMakeRoot-prep.cmake.