CPack: Detect more URLs in CPACK_NSIS_MENU_LINKS (#10644)
Previously, only strings containing "http:" qualified as URLs when found in CPACK_NSIS_MENU_LINKS. Now, we use a regex to detect strings beginning with any of the following: ftp:// ftps:// http:// https:// news:// mailto: This commit also moves the caller of CreateMenuLinks outside the "if (cpackPackageExecutables)" block, allowing clients to use CPACK_NSIS_MENU_LINKS without also having CPACK_PACKAGE_EXECUTABLES defined. That bit of this commit fixes the remainder of the issue described in http://public.kitware.com/Bug/view.php?id=7828 Also, added a set(CPACK_NSIS_MENU_LINKS ...) to the CPackComponents test to enable verifying that all of this actually works.
This commit is contained in:
parent
4b05a21302
commit
1bbe4e6917
|
@ -440,12 +440,14 @@ int cmCPackNSISGenerator::InitializeInternal()
|
||||||
cmCPackLogger(cmCPackLog::LOG_DEBUG, "CPACK_CREATE_DESKTOP_LINKS: "
|
cmCPackLogger(cmCPackLog::LOG_DEBUG, "CPACK_CREATE_DESKTOP_LINKS: "
|
||||||
<< "not set" << std::endl);
|
<< "not set" << std::endl);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
cmOStringStream str;
|
||||||
|
cmOStringStream deleteStr;
|
||||||
|
|
||||||
if ( cpackPackageExecutables )
|
if ( cpackPackageExecutables )
|
||||||
{
|
{
|
||||||
cmCPackLogger(cmCPackLog::LOG_DEBUG, "The cpackPackageExecutables: "
|
cmCPackLogger(cmCPackLog::LOG_DEBUG, "The cpackPackageExecutables: "
|
||||||
<< cpackPackageExecutables << "." << std::endl);
|
<< cpackPackageExecutables << "." << std::endl);
|
||||||
cmOStringStream str;
|
|
||||||
cmOStringStream deleteStr;
|
|
||||||
std::vector<std::string> cpackPackageExecutablesVector;
|
std::vector<std::string> cpackPackageExecutablesVector;
|
||||||
cmSystemTools::ExpandListArgument(cpackPackageExecutables,
|
cmSystemTools::ExpandListArgument(cpackPackageExecutables,
|
||||||
cpackPackageExecutablesVector);
|
cpackPackageExecutablesVector);
|
||||||
|
@ -486,11 +488,13 @@ int cmCPackNSISGenerator::InitializeInternal()
|
||||||
<< ".lnk\"" << std::endl;
|
<< ".lnk\"" << std::endl;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
this->CreateMenuLinks(str, deleteStr);
|
this->CreateMenuLinks(str, deleteStr);
|
||||||
this->SetOptionIfNotSet("CPACK_NSIS_CREATE_ICONS", str.str().c_str());
|
this->SetOptionIfNotSet("CPACK_NSIS_CREATE_ICONS", str.str().c_str());
|
||||||
this->SetOptionIfNotSet("CPACK_NSIS_DELETE_ICONS",
|
this->SetOptionIfNotSet("CPACK_NSIS_DELETE_ICONS",
|
||||||
deleteStr.str().c_str());
|
deleteStr.str().c_str());
|
||||||
}
|
|
||||||
this->SetOptionIfNotSet("CPACK_NSIS_COMPRESSOR", "lzma");
|
this->SetOptionIfNotSet("CPACK_NSIS_COMPRESSOR", "lzma");
|
||||||
|
|
||||||
return this->Superclass::InitializeInternal();
|
return this->Superclass::InitializeInternal();
|
||||||
|
@ -519,22 +523,25 @@ void cmCPackNSISGenerator::CreateMenuLinks( cmOStringStream& str,
|
||||||
"<icon name>." << std::endl);
|
"<icon name>." << std::endl);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
cmsys::RegularExpression urlRegex;
|
||||||
|
urlRegex.compile("^(mailto:|(ftps?|https?|news)://).*$");
|
||||||
|
|
||||||
std::vector<std::string>::iterator it;
|
std::vector<std::string>::iterator it;
|
||||||
for ( it = cpackMenuLinksVector.begin();
|
for ( it = cpackMenuLinksVector.begin();
|
||||||
it != cpackMenuLinksVector.end();
|
it != cpackMenuLinksVector.end();
|
||||||
++it )
|
++it )
|
||||||
{
|
{
|
||||||
std::string sourceName = *it;
|
std::string sourceName = *it;
|
||||||
bool url = false;
|
const bool url = urlRegex.find(sourceName);
|
||||||
if(sourceName.find("http:") == 0)
|
|
||||||
{
|
// Convert / to \ in filenames, but not in urls:
|
||||||
url = true;
|
//
|
||||||
}
|
|
||||||
/* convert / to \\ */
|
|
||||||
if(!url)
|
if(!url)
|
||||||
{
|
{
|
||||||
cmSystemTools::ReplaceString(sourceName, "/", "\\");
|
cmSystemTools::ReplaceString(sourceName, "/", "\\");
|
||||||
}
|
}
|
||||||
|
|
||||||
++ it;
|
++ it;
|
||||||
std::string linkName = *it;
|
std::string linkName = *it;
|
||||||
if(!url)
|
if(!url)
|
||||||
|
|
|
@ -68,6 +68,16 @@ set(CPACK_PACKAGE_VERSION_MINOR "0")
|
||||||
set(CPACK_PACKAGE_VERSION_PATCH "0")
|
set(CPACK_PACKAGE_VERSION_PATCH "0")
|
||||||
set(CPACK_PACKAGE_INSTALL_DIRECTORY "CPack Component Example")
|
set(CPACK_PACKAGE_INSTALL_DIRECTORY "CPack Component Example")
|
||||||
|
|
||||||
|
# Settings used when building NSIS installers
|
||||||
|
set(CPACK_NSIS_MENU_LINKS
|
||||||
|
"ftp://ftpserver" "Test Ftp Link"
|
||||||
|
"ftps://ftpsserver" "Test Ftps Link"
|
||||||
|
"http://www.cmake.org" "CMake Web Site"
|
||||||
|
"https://github.com/" "Test Https Link"
|
||||||
|
"mailto:kitware@kitware.com" "Test MailTo Link"
|
||||||
|
"news://newsserver" "Test News Link"
|
||||||
|
)
|
||||||
|
|
||||||
# Include CPack to introduce the appropriate targets
|
# Include CPack to introduce the appropriate targets
|
||||||
include(CPack)
|
include(CPack)
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue