mirror of
https://github.com/Kitware/CMake.git
synced 2026-04-23 14:48:19 -05:00
Merge topic 'feat/cmake-project-module'
b37b912e8f CMAKE_PROJECT_INCLUDE: Allow to run module files
Acked-by: Kitware Robot <kwrobot@kitware.com>
Acked-by: buildbot <buildbot@kitware.com>
Merge-request: !8894
This commit is contained in:
@@ -694,7 +694,22 @@ void cmGlobalGenerator::EnableLanguage(
|
||||
std::string includes =
|
||||
mf->GetSafeDefinition("CMAKE_PROJECT_TOP_LEVEL_INCLUDES");
|
||||
cmList includesList{ includes };
|
||||
for (std::string const& setupFile : includesList) {
|
||||
for (std::string setupFile : includesList) {
|
||||
// Any relative path without a .cmake extension is checked for valid
|
||||
// cmake modules. This logic should be consistent with CMake's include()
|
||||
// command. Otherwise default to checking relative path w.r.t. source
|
||||
// directory
|
||||
if (!cmSystemTools::FileIsFullPath(setupFile) &&
|
||||
!cmHasLiteralSuffix(setupFile, ".cmake")) {
|
||||
std::string mfile = mf->GetModulesFile(cmStrCat(setupFile, ".cmake"));
|
||||
if (mfile.empty()) {
|
||||
cmSystemTools::Error(cmStrCat(
|
||||
"CMAKE_PROJECT_TOP_LEVEL_INCLUDES module:\n ", setupFile));
|
||||
mf->GetState()->SetInTopLevelIncludes(false);
|
||||
return;
|
||||
}
|
||||
setupFile = mfile;
|
||||
}
|
||||
std::string absSetupFile = cmSystemTools::CollapseFullPath(
|
||||
setupFile, mf->GetCurrentSourceDirectory());
|
||||
if (!cmSystemTools::FileExists(absSetupFile)) {
|
||||
|
||||
@@ -375,7 +375,21 @@ static bool IncludeByVariable(cmExecutionStatus& status,
|
||||
cmList includeFiles{ *include };
|
||||
|
||||
bool failed = false;
|
||||
for (auto const& filePath : includeFiles) {
|
||||
for (auto filePath : includeFiles) {
|
||||
// Any relative path without a .cmake extension is checked for valid cmake
|
||||
// modules. This logic should be consistent with CMake's include() command.
|
||||
// Otherwise default to checking relative path w.r.t. source directory
|
||||
if (!cmSystemTools::FileIsFullPath(filePath) &&
|
||||
!cmHasLiteralSuffix(filePath, ".cmake")) {
|
||||
std::string mfile = mf.GetModulesFile(cmStrCat(filePath, ".cmake"));
|
||||
if (mfile.empty()) {
|
||||
status.SetError(
|
||||
cmStrCat("could not find requested module:\n ", filePath));
|
||||
failed = true;
|
||||
continue;
|
||||
}
|
||||
filePath = mfile;
|
||||
}
|
||||
std::string includeFile = cmSystemTools::CollapseFullPath(
|
||||
filePath, mf.GetCurrentSourceDirectory());
|
||||
if (!cmSystemTools::FileExists(includeFile)) {
|
||||
|
||||
Reference in New Issue
Block a user