CPack External generator runs CPACK_EXTERNAL_PACKAGE_SCRIPT before creating JSON metadata


I’m having some trouble understanding how the CPack external generator is supposed to work. I’m running CPack via the CMake “package” target. In CMake I’m setting CPACK_EXTERNAL_PACKAGE_SCRIPT to point to a CMake script that invokes an external tool using execute_process. I want the external process to read the metadata from the CPack generated JSON file and use it to package my library. However, when I run a clean build, the external script runs before the JSON metadata is created causing my packaging step to fail. Is there a way to instruct CPack to generate the JSON metadata before my external script is executed?


It looks like the package.json is written out before the script is executed. Could you get a trace of why the package.json is disappearing perhaps?