Search code examples
macoscmakecpack

Using CPack, when building on OSX, how to avoid ending up with the suffix Darwin in the package/bundle filename?


When I build using CPack on OSX, my resulting package name has "Darwin" in the filename. I don't want it there as it serves no purpose these days. How do I tell CPack not to add that?

cmake -G "Unix Makefiles" ..
make && ctest && cpack -G "Bundle

And I get:

myapp-1.2.3-Darwin.dmg

I want instead:

myapp-1.2.3.dmg

Solution

  • The file name is controlled by the CPACK_PACKAGE_FILE_NAME variable, which you need to set before you call include(CPack). The default value for this is:

    ${CPACK_PACKAGE_NAME}-${CPACK_PACKAGE_VERSION}-${CPACK_SYSTEM_NAME}
    

    In your case, you want something like this (assuming you've already set CPACK_PACKAGE_NAME and CPACK_PACKAGE_VERSION):

    set(CPACK_PACKAGE_FILE_NAME "${CPACK_PACKAGE_NAME}-${CPACK_PACKAGE_VERSION}")
    

    These variables and more are discussed in the CMake docs for the CPack module.