postinstall with cmake

How to create a postinstall or preinstall with cmake (macOS

How to create a postinstall or preinstall with cmake (macOS
For example,
I use the
CPACK_PREFLIGHT_SCRIPT or CPACK_POSTFLIGHT_SCRIPT
But it doesnt work .

cmakelist
set(CPACK_PREFLIGHT_SCRIPT “${PROJECT_BINARY_DIR}/preinstall.sh”)
set(CPACK_POSTFLIGHT_SCRIPT “${PROJECT_SOURCE_DIR}/scripts/postinstall.sh”)

preinstall.sh
#!/bin/sh
mkdir -p /User/user/Desktop/123
echo “Here is do the post install”
exit 0

https://cmake.org/cmake/help/latest/command/add_custom_command.html#build-events

https://cmake.org/cmake/help/latest/module/CPack.html#variable:CPACK_PRE_BUILD_SCRIPTS

Please post a complete, minimal example that demonstrates the problem. Include the commands you are running. The links you provided are for different variables to the ones you say are not working.

The above message is just the sample that I find. In fact, I dont have any idea.
I dont have the experience of preinstall and postistall. Could you give me a advance and sample for preinstall and post install?
How to create a postinstall or preinstall with cmake (macOS
Thanks.