0

I was wondering if there's any specific command that performs codesign for application bundle or even a single executable file in macOS. The only way I've found out so far is using the generic add_custom_command but perhaps there's an ad-hoc directive in cmake for this purpose which is also cross-platform (which means that in windows it will call signtool and in macOS/iPhone it will call codesign)

add_custom_command(TARGET myTarget POST_BUILD COMMAND ${CODESIGN_COMMANDLINE})
zaufi
  • 6,811
  • 26
  • 34
Zohar81
  • 4,554
  • 5
  • 29
  • 82
  • 1
    Note: I'm neither familiar with macOs bundles nor with codesign, but usually anything that builds some kind of package is handled by `cpack`; You may be able to achieve the desired result using the bundle using the [CPack Bundle Generator](https://cmake.org/cmake/help/latest/cpack_gen/bundle.html). The linked site mentions a `CPACK_BUNDLE_APPLE_CODESIGN_FILES` variable which may indicate that this generator could work for you, but with my lack of experience in this regard I won't be able to tell myself (without spending more effort on a stackoverflow question than I'm willing to). – fabian Sep 14 '21 at 18:38
  • 1
    Does this answer your question? [CMake and Code Signing in XCode 8 for iOS projects](https://stackoverflow.com/questions/40664125/cmake-and-code-signing-in-xcode-8-for-ios-projects) – Matthieu Brucher Dec 14 '22 at 10:59

1 Answers1

0

CMake (CPack) does not have any unified or cross-platform support for signing anything.

However, since CMake 3.19 there is the CPACK_POST_BUILD_SCRIPTS variable that can be used to perform any actions right after CPack finished building a package. For example, one can provide a CMake script to sign the package using whatever tool. It just makes unnecessary any special custom targets for package signing.

zaufi
  • 6,811
  • 26
  • 34