diff options
-rw-r--r-- | Help/cpack_gen/dmg.rst | 21 | ||||
-rw-r--r-- | Help/release/dev/cpack-dmg-sla.rst | 9 | ||||
-rw-r--r-- | Modules/CPack.cmake | 5 | ||||
-rw-r--r-- | Source/CPack/cmCPackDragNDropGenerator.cxx | 10 | ||||
-rw-r--r-- | Tests/RunCMake/CPack/RunCMakeTest.cmake | 2 | ||||
-rw-r--r-- | Tests/RunCMake/CPack/tests/DMG_SLA_FILE/Example.txt | 4 | ||||
-rw-r--r-- | Tests/RunCMake/CPack/tests/DMG_SLA_FILE/ExpectedFiles.cmake | 2 | ||||
-rw-r--r-- | Tests/RunCMake/CPack/tests/DMG_SLA_FILE/VerifyResult.cmake | 22 | ||||
-rw-r--r-- | Tests/RunCMake/CPack/tests/DMG_SLA_FILE/test.cmake | 2 | ||||
-rw-r--r-- | Tests/RunCMake/CPack/tests/DMG_SLA_OFF/Example.txt | 4 | ||||
-rw-r--r-- | Tests/RunCMake/CPack/tests/DMG_SLA_OFF/ExpectedFiles.cmake | 2 | ||||
-rw-r--r-- | Tests/RunCMake/CPack/tests/DMG_SLA_OFF/VerifyResult.cmake | 12 | ||||
-rw-r--r-- | Tests/RunCMake/CPack/tests/DMG_SLA_OFF/test.cmake | 3 |
13 files changed, 95 insertions, 3 deletions
diff --git a/Help/cpack_gen/dmg.rst b/Help/cpack_gen/dmg.rst index 1f05618..b4ef5a2 100644 --- a/Help/cpack_gen/dmg.rst +++ b/Help/cpack_gen/dmg.rst @@ -54,6 +54,27 @@ on macOS: Default behavior is to include a symlink to ``/Applications`` in the DMG. Set this option to ``ON`` to avoid adding the symlink. +.. variable:: CPACK_DMG_SLA_USE_RESOURCE_FILE_LICENSE + + .. versionadded:: 3.23 + + Control whether :variable:`CPACK_RESOURCE_FILE_LICENSE`, if set to a + non-default value, is used as the license agreement provided when + mounting the DMG. If ``CPACK_DMG_SLA_USE_RESOURCE_FILE_LICENSE`` is + not set, :manual:`cpack(1)` defaults to off. + + In a CMake project that uses the :module:`CPack` module to generate + ``CPackConfig.cmake``, ``CPACK_DMG_SLA_USE_RESOURCE_FILE_LICENSE`` + is automatically enabled by default if it is not set and + :variable:`CPACK_RESOURCE_FILE_LICENSE` is set to a non-default value. + + .. note:: + + This option was added in response to macOS 12.0's deprecation of + the ``hdiutil udifrez`` command to make its use optional. + CPack 3.22 and below always use :variable:`CPACK_RESOURCE_FILE_LICENSE`, + if set to a non-default value, as the DMG license. + .. variable:: CPACK_DMG_SLA_DIR .. versionadded:: 3.5 diff --git a/Help/release/dev/cpack-dmg-sla.rst b/Help/release/dev/cpack-dmg-sla.rst new file mode 100644 index 0000000..c6a3596 --- /dev/null +++ b/Help/release/dev/cpack-dmg-sla.rst @@ -0,0 +1,9 @@ +cpack-dmg-sla +------------- + +* The :cpack_gen:`CPack DragNDrop Generator` no longer attaches + :variable:`CPACK_RESOURCE_FILE_LICENSE` as the license agreement in + the generated ``.dmg`` unless explicitly activated by a + :variable:`CPACK_DMG_SLA_USE_RESOURCE_FILE_LICENSE` option. + In CMake projects, the :module:`CPack` module enables the option + by default for compatibility. diff --git a/Modules/CPack.cmake b/Modules/CPack.cmake index 50a9525..6650f7c 100644 --- a/Modules/CPack.cmake +++ b/Modules/CPack.cmake @@ -805,6 +805,11 @@ _cpack_set_default(CPACK_INSTALL_PREFIX "${CMAKE_INSTALL_PREFIX}") _cpack_set_default(CPACK_NSIS_INSTALLER_ICON_CODE "") _cpack_set_default(CPACK_NSIS_INSTALLER_MUI_ICON_CODE "") +# DragNDrop specific variables +if(CPACK_RESOURCE_FILE_LICENSE AND NOT CPACK_RESOURCE_FILE_LICENSE STREQUAL "${CMAKE_ROOT}/Templates/CPack.GenericLicense.txt") + _cpack_set_default(CPACK_DMG_SLA_USE_RESOURCE_FILE_LICENSE ON) +endif() + # WiX specific variables _cpack_set_default(CPACK_WIX_SIZEOF_VOID_P "${CMAKE_SIZEOF_VOID_P}") diff --git a/Source/CPack/cmCPackDragNDropGenerator.cxx b/Source/CPack/cmCPackDragNDropGenerator.cxx index 9385a5a..0f7acfb 100644 --- a/Source/CPack/cmCPackDragNDropGenerator.cxx +++ b/Source/CPack/cmCPackDragNDropGenerator.cxx @@ -98,7 +98,9 @@ int cmCPackDragNDropGenerator::InitializeInternal() if (this->IsSet("CPACK_DMG_SLA_DIR")) { slaDirectory = this->GetOption("CPACK_DMG_SLA_DIR"); - if (!slaDirectory.empty() && this->IsSet("CPACK_RESOURCE_FILE_LICENSE")) { + if (!slaDirectory.empty() && + this->IsOn("CPACK_DMG_SLA_USE_RESOURCE_FILE_LICENSE") && + this->IsSet("CPACK_RESOURCE_FILE_LICENSE")) { std::string license_file = this->GetOption("CPACK_RESOURCE_FILE_LICENSE"); if (!license_file.empty() && @@ -278,8 +280,10 @@ int cmCPackDragNDropGenerator::CreateDMG(const std::string& src_dir, : "HFS+"; // Get optional arguments ... - std::string cpack_license_file = - *this->GetOption("CPACK_RESOURCE_FILE_LICENSE"); + std::string cpack_license_file; + if (this->IsOn("CPACK_DMG_SLA_USE_RESOURCE_FILE_LICENSE")) { + cpack_license_file = *this->GetOption("CPACK_RESOURCE_FILE_LICENSE"); + } cmValue cpack_dmg_background_image = this->GetOption("CPACK_DMG_BACKGROUND_IMAGE"); diff --git a/Tests/RunCMake/CPack/RunCMakeTest.cmake b/Tests/RunCMake/CPack/RunCMakeTest.cmake index eb9ff03..ef4cf5e 100644 --- a/Tests/RunCMake/CPack/RunCMakeTest.cmake +++ b/Tests/RunCMake/CPack/RunCMakeTest.cmake @@ -21,6 +21,8 @@ if(NOT "${DEBUGEDIT}" STREQUAL "DEBUGEDIT-NOTFOUND") endif() run_cpack_test(DIST "RPM.DIST" false "MONOLITHIC") run_cpack_test(DMG_SLA "DragNDrop" false "MONOLITHIC") +run_cpack_test(DMG_SLA_FILE "DragNDrop" false "MONOLITHIC") +run_cpack_test(DMG_SLA_OFF "DragNDrop" false "MONOLITHIC") run_cpack_test(EMPTY_DIR "RPM.EMPTY_DIR;DEB.EMPTY_DIR;TGZ" true "MONOLITHIC;COMPONENT") run_cpack_test(VERSION "RPM.VERSION;DEB.VERSION" false "MONOLITHIC;COMPONENT") run_cpack_test(EXTRA "DEB.EXTRA" false "COMPONENT") diff --git a/Tests/RunCMake/CPack/tests/DMG_SLA_FILE/Example.txt b/Tests/RunCMake/CPack/tests/DMG_SLA_FILE/Example.txt new file mode 100644 index 0000000..94b19c3 --- /dev/null +++ b/Tests/RunCMake/CPack/tests/DMG_SLA_FILE/Example.txt @@ -0,0 +1,4 @@ +Example License File +-------------------- + +This is an example license file for a DMG. diff --git a/Tests/RunCMake/CPack/tests/DMG_SLA_FILE/ExpectedFiles.cmake b/Tests/RunCMake/CPack/tests/DMG_SLA_FILE/ExpectedFiles.cmake new file mode 100644 index 0000000..d1a3a5f --- /dev/null +++ b/Tests/RunCMake/CPack/tests/DMG_SLA_FILE/ExpectedFiles.cmake @@ -0,0 +1,2 @@ +set(EXPECTED_FILES_COUNT "1") +set(EXPECTED_FILE_CONTENT_1_LIST "/foo;/foo/CMakeLists.txt") diff --git a/Tests/RunCMake/CPack/tests/DMG_SLA_FILE/VerifyResult.cmake b/Tests/RunCMake/CPack/tests/DMG_SLA_FILE/VerifyResult.cmake new file mode 100644 index 0000000..55fb3fb --- /dev/null +++ b/Tests/RunCMake/CPack/tests/DMG_SLA_FILE/VerifyResult.cmake @@ -0,0 +1,22 @@ +set(dmg "${bin_dir}/${FOUND_FILE_1}") +execute_process(COMMAND hdiutil udifderez -xml "${dmg}" OUTPUT_VARIABLE out ERROR_VARIABLE err RESULT_VARIABLE res) +if(NOT res EQUAL 0) + string(REPLACE "\n" "\n " err " ${err}") + message(FATAL_ERROR "Running 'hdiutil udifderez -xml' on\n ${dmg}\nfailed with:\n${err}") +endif() +foreach(key "LPic" "STR#" "TEXT") + if(NOT out MATCHES "<key>${key}</key>") + string(REPLACE "\n" "\n " out " ${out}") + message(FATAL_ERROR "error: running 'hdiutil udifderez -xml' on\n ${dmg}\ndid not show '${key}' key:\n${out}") + endif() +endforeach() +foreach(line + # TEXT first and last base64 lines + "\tRXhhbXBsZSBMaWNlbnNlIEZpbGUNLS0tLS0tLS0tLS0tLS0tLS0t\n" + "\tYSBETUcuDQ0=\n" + ) + if(NOT out MATCHES "${line}") + string(REPLACE "\n" "\n " out " ${out}") + message(FATAL_ERROR "error: running 'hdiutil udifderez -xml' on\n ${dmg}\ndid not show '${line}':\n${out}") + endif() +endforeach() diff --git a/Tests/RunCMake/CPack/tests/DMG_SLA_FILE/test.cmake b/Tests/RunCMake/CPack/tests/DMG_SLA_FILE/test.cmake new file mode 100644 index 0000000..eac820e --- /dev/null +++ b/Tests/RunCMake/CPack/tests/DMG_SLA_FILE/test.cmake @@ -0,0 +1,2 @@ +install(FILES CMakeLists.txt DESTINATION foo) +set(CPACK_RESOURCE_FILE_LICENSE "${CMAKE_CURRENT_LIST_DIR}/Example.txt") diff --git a/Tests/RunCMake/CPack/tests/DMG_SLA_OFF/Example.txt b/Tests/RunCMake/CPack/tests/DMG_SLA_OFF/Example.txt new file mode 100644 index 0000000..94b19c3 --- /dev/null +++ b/Tests/RunCMake/CPack/tests/DMG_SLA_OFF/Example.txt @@ -0,0 +1,4 @@ +Example License File +-------------------- + +This is an example license file for a DMG. diff --git a/Tests/RunCMake/CPack/tests/DMG_SLA_OFF/ExpectedFiles.cmake b/Tests/RunCMake/CPack/tests/DMG_SLA_OFF/ExpectedFiles.cmake new file mode 100644 index 0000000..d1a3a5f --- /dev/null +++ b/Tests/RunCMake/CPack/tests/DMG_SLA_OFF/ExpectedFiles.cmake @@ -0,0 +1,2 @@ +set(EXPECTED_FILES_COUNT "1") +set(EXPECTED_FILE_CONTENT_1_LIST "/foo;/foo/CMakeLists.txt") diff --git a/Tests/RunCMake/CPack/tests/DMG_SLA_OFF/VerifyResult.cmake b/Tests/RunCMake/CPack/tests/DMG_SLA_OFF/VerifyResult.cmake new file mode 100644 index 0000000..571a4df --- /dev/null +++ b/Tests/RunCMake/CPack/tests/DMG_SLA_OFF/VerifyResult.cmake @@ -0,0 +1,12 @@ +set(dmg "${bin_dir}/${FOUND_FILE_1}") +execute_process(COMMAND hdiutil udifderez -xml "${dmg}" OUTPUT_VARIABLE out ERROR_VARIABLE err RESULT_VARIABLE res) +if(NOT res EQUAL 0) + string(REPLACE "\n" "\n " err " ${err}") + message(FATAL_ERROR "Running 'hdiutil udifderez -xml' on\n ${dmg}\nfailed with:\n${err}") +endif() +foreach(key "LPic" "STR#" "TEXT") + if(out MATCHES "<key>${key}</key>") + string(REPLACE "\n" "\n " out " ${out}") + message(FATAL_ERROR "error: running 'hdiutil udifderez -xml' on\n ${dmg}\nhas unexpected '${key}' key:\n${out}") + endif() +endforeach() diff --git a/Tests/RunCMake/CPack/tests/DMG_SLA_OFF/test.cmake b/Tests/RunCMake/CPack/tests/DMG_SLA_OFF/test.cmake new file mode 100644 index 0000000..2b09cab --- /dev/null +++ b/Tests/RunCMake/CPack/tests/DMG_SLA_OFF/test.cmake @@ -0,0 +1,3 @@ +install(FILES CMakeLists.txt DESTINATION foo) +set(CPACK_RESOURCE_FILE_LICENSE "${CMAKE_CURRENT_LIST_DIR}/Example.txt") +set(CPACK_DMG_SLA_USE_RESOURCE_FILE_LICENSE OFF) |