[CMake] Get errors when executing shell scripts in post_build process as custom targets

David Cole david.cole at kitware.com
Tue Nov 29 17:44:20 EST 2011


The double quoting is wrong.

Do this (no quotes necessary):

  COMMAND /usr/bin/macdeployqt ${BUNDLE_IDENTIFIER}

Not this:

  COMMAND "/usr/bin/macdeployqt ${BUNDLE_IDENTIFIER}"


HTH,
David


On Tue, Nov 29, 2011 at 5:37 PM, NoRulez <norulez at me.com> wrote:
> Hi,
>
>
>
> I want to do something after the bundle is created (POST_BUILD). For this I
> tried the following:
>
>
>
> ADD_EXECUTABLE(...)
>
> TARGET_LINK_LIBRARIES(...)
>
> ADD_DEPENDECIES(...)
>
>
>
> IF (APPLE)
>
>         SET(BUNDLE_IDENTIFIER
> "${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/${PROJECT_NAME}.app")
>
>
>
>         ADD_CUSTOM_TARGET(Custom1 ALL DEPENDS ${BUNDLE_IDENTIFIER})
>
>
>
>         ADD_CUSTOM_COMMAND(TARGET Custom1 POST_BUILD
>
>                            COMMAND "/usr/bin/macdeployqt
> ${PROJECT_NAME}.app"
>
>                            #COMMAND "/usr/bin/macdeployqt
> ${BUNDLE_IDENTIFIER}"
>
>                            WORKING_DIRECTORY
> "${CMAKE_RUNTIME_OUTPUT_DIRECTORY}"
>
>                            COMMENT “Prepare for deployment”
>
>                            VERBATIM)
>
>         ADD_CUSTOM_COMMAND(TARGET Custom1 POST_BUILD
>
>                            COMMAND /usr/bin/security
> $ENV{HOME}/Library/Keychains/login.keychain"
>
>                            COMMENT “Unlock the keychain”
>
>                            VERBATIM)
>
>         ADD_CUSTOM_COMMAND(TARGET Custom1 POST_BUILD
>
>                            COMMAND /usr/bin/codesign --force --verbose
> --verify --sign \"${APPLICATION_CERTIFICATE}\" ${BUNDLE_IDENTIFIER}"
>
>                            COMMENT “Sign the application bundle”
>
>                            VERBATIM)
>
>         ADD_CUSTOM_COMMAND(TARGET Custom1 POST_BUILD
>
>                            COMMAND /usr/bin/productbuild --component
> \"${BUNDLE_IDENTIFIER}\" /Applications --sign \"${INSTALLER_CERTIFICATE}\"
> --product \"${BUNDLE_IDENTIFIER}/Contents/Info.plist\" ${PROJECT_NAME}.pkg"
>
>                            WORKING_DIRECTORY
> "${CMAKE_RUNTIME_OUTPUT_DIRECTORY}"
>
>                            COMMENT “Build package”
>
>                            VERBATIM)
>
> ENDIF(APPLE)
>
>
>
> But I get the the following error:
>
> /bin/sh: /usr/bin/macdeployqt MyApp.app: No such file or directory
>
> make[2]: *** [Custom1] Error 127
>
> make[1]: *** [app/CMakeFiles/Custom1.dir/all] Error 2
>
> make: *** [all] Error 2
>
>
>
> I also tried to use the full path to the bundle but I get the same error.
>
>
>
> Does anyone know where could be the problem?
>
> Maybe this can also be done with the BundleUtilities?
>
>
>
> Thanks in advance
>
>
>
> Best Regards
>
> NoRulez
>
>
> --
>
> Powered by www.kitware.com
>
> Visit other Kitware open-source projects at
> http://www.kitware.com/opensource/opensource.html
>
> Please keep messages on-topic and check the CMake FAQ at:
> http://www.cmake.org/Wiki/CMake_FAQ
>
> Follow this link to subscribe/unsubscribe:
> http://www.cmake.org/mailman/listinfo/cmake


More information about the CMake mailing list