mirror of
https://github.com/reactos/CMake.git
synced 2024-11-24 12:09:48 +00:00
Merge topic 'cpack-dmg-rtf-for-sla'
9571929701
CPack/DragNDrop: Support RTF licenses
Acked-by: Kitware Robot <kwrobot@kitware.com>
Merge-request: !4270
This commit is contained in:
commit
d5f5496783
@ -54,10 +54,12 @@ on macOS:
|
||||
|
||||
Directory where license and menu files for different languages are stored.
|
||||
Setting this causes CPack to look for a ``<language>.menu.txt`` and
|
||||
``<language>.license.txt`` file for every language defined in
|
||||
``CPACK_DMG_SLA_LANGUAGES``. If both this variable and
|
||||
``<language>.license.txt`` or ``<language>.license.rtf`` file for every
|
||||
language defined in ``CPACK_DMG_SLA_LANGUAGES``. If both this variable and
|
||||
``CPACK_RESOURCE_FILE_LICENSE`` are set, CPack will only look for the menu
|
||||
files and use the same license file for all languages.
|
||||
files and use the same license file for all languages. If both
|
||||
``<language>.license.txt`` and ``<language>.license.rtf`` exist, the ``.txt``
|
||||
file will be used.
|
||||
|
||||
.. variable:: CPACK_DMG_SLA_LANGUAGES
|
||||
|
||||
|
8
Help/release/dev/cpack-dmg-rtf-for-sla.rst
Normal file
8
Help/release/dev/cpack-dmg-rtf-for-sla.rst
Normal file
@ -0,0 +1,8 @@
|
||||
cpack-dmg-rtf-for-sla
|
||||
---------------------
|
||||
|
||||
* The :cpack_gen:`CPack DragNDrop Generator` learned to handle
|
||||
RTF formatted license files. When :variable:`CPACK_DMG_SLA_DIR`
|
||||
variable is set, <language>.license.rtf is considered, but
|
||||
only as a fallback when the plaintext (.txt) file is not found
|
||||
in order to maintain backwards compatibility.
|
@ -138,11 +138,16 @@ int cmCPackDragNDropGenerator::InitializeInternal()
|
||||
}
|
||||
for (auto const& language : languages) {
|
||||
std::string license = slaDirectory + "/" + language + ".license.txt";
|
||||
if (!singleLicense && !cmSystemTools::FileExists(license)) {
|
||||
cmCPackLogger(cmCPackLog::LOG_ERROR,
|
||||
"Missing license file " << language << ".license.txt"
|
||||
<< std::endl);
|
||||
return 0;
|
||||
std::string license_rtf = slaDirectory + "/" + language + ".license.rtf";
|
||||
if (!singleLicense) {
|
||||
if (!cmSystemTools::FileExists(license) &&
|
||||
!cmSystemTools::FileExists(license_rtf)) {
|
||||
cmCPackLogger(cmCPackLog::LOG_ERROR,
|
||||
"Missing license file "
|
||||
<< language << ".license.txt"
|
||||
<< " / " << language << ".license.rtf" << std::endl);
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
std::string menu = slaDirectory + "/" + language + ".menu.txt";
|
||||
if (!cmSystemTools::FileExists(menu)) {
|
||||
@ -793,13 +798,29 @@ bool cmCPackDragNDropGenerator::WriteLicense(
|
||||
licenseLanguage = "English";
|
||||
}
|
||||
|
||||
// License file
|
||||
std::string license_format = "TEXT";
|
||||
std::string actual_license;
|
||||
if (!licenseFile.empty()) {
|
||||
if (cmHasLiteralSuffix(licenseFile, ".rtf")) {
|
||||
license_format = "RTF ";
|
||||
}
|
||||
actual_license = licenseFile;
|
||||
} else {
|
||||
std::string license_wo_ext =
|
||||
slaDirectory + "/" + licenseLanguage + ".license";
|
||||
if (cmSystemTools::FileExists(license_wo_ext + ".txt")) {
|
||||
actual_license = license_wo_ext + ".txt";
|
||||
} else {
|
||||
license_format = "RTF ";
|
||||
actual_license = license_wo_ext + ".rtf";
|
||||
}
|
||||
}
|
||||
|
||||
// License header
|
||||
outputStream << "data 'TEXT' (" << licenseNumber << ", \"" << licenseLanguage
|
||||
<< "\") {\n";
|
||||
outputStream << "data '" << license_format << "' (" << licenseNumber
|
||||
<< ", \"" << licenseLanguage << "\") {\n";
|
||||
// License body
|
||||
std::string actual_license = !licenseFile.empty()
|
||||
? licenseFile
|
||||
: (slaDirectory + "/" + licenseLanguage + ".license.txt");
|
||||
cmsys::ifstream license_ifs;
|
||||
license_ifs.open(actual_license.c_str());
|
||||
if (license_ifs.is_open()) {
|
||||
|
Loading…
Reference in New Issue
Block a user