summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorBrad King <brad.king@kitware.com>2006-09-13 15:39:46 (GMT)
committerBrad King <brad.king@kitware.com>2006-09-13 15:39:46 (GMT)
commit6ce165de4394303719fc1c06e035e027a3cf69a7 (patch)
treeb9459801c7d441fa9289ee92752fa70ced6ab108
parentff46146dfc87b7689c809de51c0d87b38c023c52 (diff)
downloadCMake-6ce165de4394303719fc1c06e035e027a3cf69a7.zip
CMake-6ce165de4394303719fc1c06e035e027a3cf69a7.tar.gz
CMake-6ce165de4394303719fc1c06e035e027a3cf69a7.tar.bz2
ENH: Added diagnosis of bad target names.
-rw-r--r--Source/cmAddCustomTargetCommand.cxx23
1 files changed, 23 insertions, 0 deletions
diff --git a/Source/cmAddCustomTargetCommand.cxx b/Source/cmAddCustomTargetCommand.cxx
index f98ca26..ccdc8a9 100644
--- a/Source/cmAddCustomTargetCommand.cxx
+++ b/Source/cmAddCustomTargetCommand.cxx
@@ -26,6 +26,29 @@ bool cmAddCustomTargetCommand::InitialPass(
return false;
}
+ // Check the target name.
+ if(args[0].find_first_of("/\\") != args[0].npos)
+ {
+ int major = 0;
+ int minor = 0;
+ if(const char* versionValue =
+ this->Makefile->GetDefinition("CMAKE_BACKWARDS_COMPATIBILITY"))
+ {
+ sscanf(versionValue, "%d.%d", &major, &minor);
+ }
+ if(!major || major > 3 || (major == 2 && minor > 2))
+ {
+ cmOStringStream e;
+ e << "called with invalid target name \"" << args[0]
+ << "\". Target names may not contain a slash. "
+ << "Use ADD_CUSTOM_COMMAND to generate files. "
+ << "Set CMAKE_BACKWARDS_COMPATIBILITY to 2.2 "
+ << "or lower to skip this check.";
+ this->SetError(e.str().c_str());
+ return false;
+ }
+ }
+
// Accumulate one command line at a time.
cmCustomCommandLine currentLine;