Install 3rd party macOS installer package

I am using CPack module in CMake to generate the product installer on macOS. I am trying to install a 3rd party macOS installer package as a prerequisite to our product installer. I tried -

add_executable(
    XYZ
    IMPORTED
)

set_property(
    TARGET XYZ PROPERTY
    IMPORTED_LOCATION ${CMAKE_BINARY_DIR}/import/redist/XYZ.pkg 
)

install(
    IMPORTED_RUNTIME_ARTIFACTS
        XYZ
    COMPONENT
        XYZ
)

However, this doesn’t install the XYZ.pkg though it is part of my final product installer pkg file. Is this the correct way to embed and install 3rd party installer package from my product package installer ?

Edit: Instead of executing the XYZ.pkg installer to install it’s components, my product installer is copying it to my product’s destination folder. I was expecting to chain the install instead.

In my understanding your usage can‘t work.

See install(IMPORTED_RUNTIME_ARTIFACTS...) does not work on Darwin (OSX) for an example

AFAIK, there is no mechanism to install a .pkg file without interaction that works universally. In any case, CMake doesn’t have a way to install such a package automatically. If .pkg supports chaining to other .pkg files, that is something very CPack-generator-specific rather than generic CMake infrastructure.

If you are using the productbuild CPack generator, you may be able to get the behavior you’re after using CPACK_PREFLIGHT_<COMP>_SCRIPT or CPACK_POSTFLIGHT_<COMP>_SCRIPT.