Restore support for target names with '+' (#13986)

Extend the range of valid target names with the + sign.  This character
can commonly be used for target names, such as those containing 'c++'.
Add a test but skip it for Borland and Watcom tools which do not support
the character.

Suggested-By: Benjamin Kloster
This commit is contained in:
Stephen Kelly 2013-03-06 17:26:40 +01:00 committed by Brad King
parent 254687d31f
commit 1bdd167577
3 changed files with 9 additions and 1 deletions

View File

@ -393,7 +393,7 @@ bool cmGeneratorExpression::IsValidTargetName(const std::string &input)
cmsys::RegularExpression targetNameValidator; cmsys::RegularExpression targetNameValidator;
// The ':' is supported to allow use with IMPORTED targets. At least // The ':' is supported to allow use with IMPORTED targets. At least
// Qt 4 and 5 IMPORTED targets use ':' as the namespace delimiter. // Qt 4 and 5 IMPORTED targets use ':' as the namespace delimiter.
targetNameValidator.compile("^[A-Za-z0-9_.:-]+$"); targetNameValidator.compile("^[A-Za-z0-9_.:+-]+$");
return targetNameValidator.find(input.c_str()); return targetNameValidator.find(input.c_str());
} }

View File

@ -102,7 +102,14 @@ target_compile_definitions(depG INTERFACE
TEST_DEF TEST_DEF
) )
add_executable(targetC targetC.cpp) add_executable(targetC targetC.cpp)
if(NOT BORLAND AND NOT WATCOM)
# Linking to a target containing a + should be non-fatal, though it does
# not work at all on Borland or watcom
add_library(wrapc++ empty.cpp)
target_link_libraries(targetC wrapc++)
endif()
# The TARGET_PROPERTY expression is duplicated below to test that there is no # The TARGET_PROPERTY expression is duplicated below to test that there is no
# shortcutting of the evaluation by returning an empty string. # shortcutting of the evaluation by returning an empty string.
set(_exe_test $<STREQUAL:$<TARGET_PROPERTY:TYPE>,EXECUTABLE>) set(_exe_test $<STREQUAL:$<TARGET_PROPERTY:TYPE>,EXECUTABLE>)

View File

@ -0,0 +1 @@
// No content