From cc6170c4946a30106676e5718066316148deec04 Mon Sep 17 00:00:00 2001 From: Ken Martin Date: Wed, 8 Jun 2005 16:39:29 -0400 Subject: ENH: better error checking for add library or executable with no source files --- Source/cmAddExecutableCommand.cxx | 6 ++++++ Source/cmAddLibraryCommand.cxx | 9 ++++++++- 2 files changed, 14 insertions(+), 1 deletion(-) diff --git a/Source/cmAddExecutableCommand.cxx b/Source/cmAddExecutableCommand.cxx index 0bc2a7a..f70e790 100644 --- a/Source/cmAddExecutableCommand.cxx +++ b/Source/cmAddExecutableCommand.cxx @@ -49,6 +49,12 @@ bool cmAddExecutableCommand::InitialPass(std::vector const& args) } } + if (s == args.end()) + { + this->SetError("called with incorrect number of arguments, no sources provided"); + return false; + } + std::vector srclists(s, args.end()); cmTarget* tgt = m_Makefile->AddExecutable(exename.c_str(), srclists); if ( use_win32 ) diff --git a/Source/cmAddLibraryCommand.cxx b/Source/cmAddLibraryCommand.cxx index cb7c2d7..9af872c 100644 --- a/Source/cmAddLibraryCommand.cxx +++ b/Source/cmAddLibraryCommand.cxx @@ -26,7 +26,8 @@ bool cmAddLibraryCommand::InitialPass(std::vector const& args) } // Library type defaults to value of BUILD_SHARED_LIBS, if it exists, // otherwise it defaults to static library. - int shared = !cmSystemTools::IsOff(m_Makefile->GetDefinition("BUILD_SHARED_LIBS")); + int shared = + !cmSystemTools::IsOff(m_Makefile->GetDefinition("BUILD_SHARED_LIBS")); std::vector::const_iterator s = args.begin(); @@ -57,6 +58,12 @@ bool cmAddLibraryCommand::InitialPass(std::vector const& args) } } + if (s == args.end()) + { + this->SetError("called with incorrect number of arguments, no sources provided"); + return false; + } + std::vector srclists; while (s != args.end()) { -- cgit v0.12