don't crash in automoc with empty COMPILE_DEFINITIONS property

Reported by Laszlo Papp:
http://www.cmake.org/pipermail/cmake/2011-October/047089.html

Alex
This commit is contained in:
Alex Neundorf 2011-10-31 22:07:12 +01:00
parent 07e88ae449
commit 8c8305f286
1 changed files with 8 additions and 7 deletions

View File

@ -124,21 +124,22 @@ void cmQtAutomoc::SetupAutomocTarget(cmTarget* target)
} }
} }
std::string _moc_incs = makefile->GetProperty("INCLUDE_DIRECTORIES"); const char* _moc_incs = makefile->GetProperty("INCLUDE_DIRECTORIES");
std::string _moc_defs = makefile->GetProperty("DEFINITIONS"); const char* _moc_defs = makefile->GetProperty("DEFINITIONS");
std::string _moc_compile_defs = makefile->GetProperty("COMPILE_DEFINITIONS"); const char* _moc_compile_defs = makefile->GetProperty("COMPILE_DEFINITIONS");
// forget the variables added here afterwards again: // forget the variables added here afterwards again:
cmMakefile::ScopePushPop varScope(makefile); cmMakefile::ScopePushPop varScope(makefile);
static_cast<void>(varScope); static_cast<void>(varScope);
makefile->AddDefinition("_moc_target_name", automocTargetName.c_str()); makefile->AddDefinition("_moc_target_name", automocTargetName.c_str());
makefile->AddDefinition("_moc_incs", _moc_incs.c_str()); makefile->AddDefinition("_moc_incs", _moc_incs!=0 ? _moc_incs : "");
makefile->AddDefinition("_moc_defs", _moc_defs.c_str()); makefile->AddDefinition("_moc_defs", _moc_defs!=0 ? _moc_defs : "");
makefile->AddDefinition("_moc_compile_defs", _moc_compile_defs.c_str()); makefile->AddDefinition("_moc_compile_defs",
_moc_compile_defs!=0 ? _moc_compile_defs : "");
makefile->AddDefinition("_moc_files", _moc_files.c_str()); makefile->AddDefinition("_moc_files", _moc_files.c_str());
makefile->AddDefinition("_moc_headers", _moc_headers.c_str()); makefile->AddDefinition("_moc_headers", _moc_headers.c_str());
const char* cmakeRoot = makefile->GetDefinition("CMAKE_ROOT"); const char* cmakeRoot = makefile->GetSafeDefinition("CMAKE_ROOT");
std::string inputFile = cmakeRoot; std::string inputFile = cmakeRoot;
inputFile += "/Modules/AutomocInfo.cmake.in"; inputFile += "/Modules/AutomocInfo.cmake.in";
std::string outputFile = targetDir; std::string outputFile = targetDir;