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?
A long time has passed since the OP, but I’m seeing the same problem, when running the CPACK_EXTERNAL_PACKAGE_SCRIPT the JSON metadata file is present, but with partial contents. Running the same script later/manually works without problems i.e. after cpack has finished. I also tried just copying the JSON metadata file to another location at that point and it has partial content at that time.
Could there be some race condition/file flush issue making the script run before the JSON metadata file is fully completed and/or flushed to disk?
We see the same issue here. @ben.boeckel , it’s not that the file does not exist, it does but as @t1-nva mentions it is not complete, like it has not been fully flushed.