ENH: Re-enable diagnosis of non-unique target names.

- Re-enable enforcement in cmMakefile::EnforceUniqueName
  - Improve error message to help user resolve the problem
  - Fix Modules/CTestTargets.cmake to not duplicate testing targets
  - Move commands used by the changes to Modules/CTestTargets.cmake
    to build during bootstrap: DEFINE_PROPERTY, GET_PROPERTY
This commit is contained in:
Brad King 2008-02-14 11:58:32 -05:00
parent 8375bb4768
commit 5b02a4a864
4 changed files with 37 additions and 35 deletions

View File

@ -35,32 +35,35 @@ IF(CMAKE_CONFIGURATION_TYPES)
SET(__conf_types -C "${CMAKE_CFG_INTDIR}")
ENDIF(CMAKE_CONFIGURATION_TYPES)
# add testing targets
IF(${CMAKE_MAKE_PROGRAM} MATCHES make)
FOREACH(mode Experimental Nightly Continuous NightlyMemoryCheck)
ADD_CUSTOM_TARGET(${mode} ${CMAKE_CTEST_COMMAND} ${__conf_types} -D ${mode})
ENDFOREACH(mode)
ELSE(${CMAKE_MAKE_PROGRAM} MATCHES make)
# for IDE only add them once for nested projects
IF (NOT DART_COMMON_TARGETS_ADDED)
FOREACH(mode Experimental Nightly Continuous NightlyMemoryCheck)
ADD_CUSTOM_TARGET(${mode} ${CMAKE_CTEST_COMMAND} ${__conf_types} -D ${mode})
ENDFOREACH(mode)
SET (DART_COMMON_TARGETS_ADDED 1)
ENDIF (NOT DART_COMMON_TARGETS_ADDED)
ENDIF(${CMAKE_MAKE_PROGRAM} MATCHES make)
# Add convenience targets. Do this at most once in case of nested
# projects.
DEFINE_PROPERTY(CTEST_TARGETS_ADDED GLOBAL
"Internal property used by CTestTargets module."
"Set by the CTestTargets module to track addition of testing targets."
FALSE)
GET_PROPERTY(_CTEST_TARGETS_ADDED GLOBAL PROPERTY CTEST_TARGETS_ADDED)
IF(NOT _CTEST_TARGETS_ADDED)
SET_PROPERTY(GLOBAL PROPERTY CTEST_TARGETS_ADDED 1)
# For all generators add basic testing targets.
FOREACH(mode Experimental Nightly Continuous NightlyMemoryCheck)
ADD_CUSTOM_TARGET(${mode}
${CMAKE_CTEST_COMMAND} ${__conf_types} -D ${mode}
)
ENDFOREACH(mode)
# for non IDE based builds nmake and make
# add all these extra targets
IF(${CMAKE_MAKE_PROGRAM} MATCHES make)
# For Makefile generators add more granular targets.
IF("${CMAKE_GENERATOR}" MATCHES Make)
# Make targets for Experimental builds
FOREACH(mode Nightly Experimental Continuous)
FOREACH(testtype Start Update Configure Build Test Coverage MemCheck Submit)
FOREACH(testtype
Start Update Configure Build Test Coverage MemCheck Submit
# missing purify
)
ADD_CUSTOM_TARGET(${mode}${testtype}
${CMAKE_CTEST_COMMAND} ${__conf_types} -D ${mode}${testtype})
${CMAKE_CTEST_COMMAND} ${__conf_types} -D ${mode}${testtype}
)
ENDFOREACH(testtype)
ENDFOREACH(mode)
ENDIF (${CMAKE_MAKE_PROGRAM} MATCHES make)
ENDIF("${CMAKE_GENERATOR}" MATCHES Make)
ENDIF(NOT _CTEST_TARGETS_ADDED)

View File

@ -34,6 +34,7 @@
#include "cmConfigureFileCommand.cxx"
#include "cmCoreTryCompile.cxx"
#include "cmCreateTestSourceList.cxx"
#include "cmDefinePropertyCommand.cxx"
#include "cmElseCommand.cxx"
#include "cmEnableTestingCommand.cxx"
#include "cmEndForEachCommand.cxx"
@ -56,6 +57,7 @@
#include "cmGetCMakePropertyCommand.cxx"
#include "cmGetDirectoryPropertyCommand.cxx"
#include "cmGetFilenameComponentCommand.cxx"
#include "cmGetPropertyCommand.cxx"
#include "cmGetSourceFilePropertyCommand.cxx"
#include "cmGetTargetPropertyCommand.cxx"
#include "cmHexFileConverter.cxx"
@ -103,6 +105,7 @@ void GetBootstrapCommands(std::list<cmCommand*>& commands)
commands.push_back(new cmCMakeMinimumRequired);
commands.push_back(new cmConfigureFileCommand);
commands.push_back(new cmCreateTestSourceList);
commands.push_back(new cmDefinePropertyCommand);
commands.push_back(new cmElseCommand);
commands.push_back(new cmEnableTestingCommand);
commands.push_back(new cmEndForEachCommand);
@ -122,6 +125,7 @@ void GetBootstrapCommands(std::list<cmCommand*>& commands)
commands.push_back(new cmGetCMakePropertyCommand);
commands.push_back(new cmGetDirectoryPropertyCommand);
commands.push_back(new cmGetFilenameComponentCommand);
commands.push_back(new cmGetPropertyCommand);
commands.push_back(new cmGetSourceFilePropertyCommand);
commands.push_back(new cmGetTargetPropertyCommand);
commands.push_back(new cmIfCommand);

View File

@ -18,14 +18,12 @@
#if defined(CMAKE_BUILD_WITH_CMAKE)
#include "cmAuxSourceDirectoryCommand.cxx"
#include "cmBuildNameCommand.cxx"
#include "cmDefinePropertyCommand.cxx"
#include "cmElseIfCommand.cxx"
#include "cmEnableLanguageCommand.cxx"
#include "cmEndWhileCommand.cxx"
#include "cmExportCommand.cxx"
#include "cmExportLibraryDependencies.cxx"
#include "cmFLTKWrapUICommand.cxx"
#include "cmGetPropertyCommand.cxx"
#include "cmGetTestPropertyCommand.cxx"
#include "cmIncludeExternalMSProjectCommand.cxx"
#include "cmInstallCommand.cxx"
@ -64,14 +62,12 @@ void GetPredefinedCommands(std::list<cmCommand*>&
#if defined(CMAKE_BUILD_WITH_CMAKE)
commands.push_back(new cmAuxSourceDirectoryCommand);
commands.push_back(new cmBuildNameCommand);
commands.push_back(new cmDefinePropertyCommand);
commands.push_back(new cmElseIfCommand);
commands.push_back(new cmEnableLanguageCommand);
commands.push_back(new cmEndWhileCommand);
commands.push_back(new cmExportCommand);
commands.push_back(new cmExportLibraryDependenciesCommand);
commands.push_back(new cmFLTKWrapUICommand);
commands.push_back(new cmGetPropertyCommand);
commands.push_back(new cmGetTestPropertyCommand);
commands.push_back(new cmIncludeExternalMSProjectCommand);
commands.push_back(new cmInstallCommand);

View File

@ -3156,7 +3156,6 @@ bool cmMakefile::EnforceUniqueName(std::string const& name, std::string& msg)
msg = e.str();
return false;
}
#if 0 /* disable until CTestTargets can be fixed */
else if(!this->NeedBackwardsCompatibility(2, 4))
{
// The conflict is with a non-imported target. Produce an error
@ -3165,9 +3164,10 @@ bool cmMakefile::EnforceUniqueName(std::string const& name, std::string& msg)
e << "cannot create target \"" << name
<< "\" because another target with the same name already exists. "
<< "Logical target names must be globally unique. "
<< "Consider using the OUTPUT_NAME target property to create "
<< "two targets with the same physical name while keeping logical "
<< "names distinct.\n"
<< "For executables and libraries, consider using the OUTPUT_NAME "
<< "target property to create two targets with the same physical "
<< "name while keeping logical names distinct. "
<< "Custom targets must simply have globally unique names.\n"
<< "If you are building an older project it is possible that "
<< "it violated this rule but was working accidentally. "
<< "Set CMAKE_BACKWARDS_COMPATIBILITY to 2.4 or lower to disable "
@ -3175,7 +3175,6 @@ bool cmMakefile::EnforceUniqueName(std::string const& name, std::string& msg)
msg = e.str();
return false;
}
#endif
}
return true;
}