How to sign my code using CMake

I didn’t find out how I can sign my code during build. I tried to pass the “-DCMAKE_XCODE_ATTRIBUTE_CODE_SIGN_IDENTITY” parameter to CMake but I only got the following result:

CMake Warning:
Manually-specified variables were not used by the project:

CMAKE_XCODE_ATTRIBUTE_CODE_SIGN_IDENTITY

What am I doing wrong?

Thanks in advance :slight_smile:

Hello to the forum!
This cmake variable will only work if you’re using the XCode generator (which will use xcodebuild), e.g. if you export your program using -G Xcode. If you’re not passing any generator flag, you will probably be using make, with will simply ignore the flag!

In case you don’t want to be using xcodebuild you can try to sign your app manually, e.g. using
codesign --sign <sign_id> --timestamp <app>.
Or alternatively, you can use a post-build cmake command to achieve this too:
add_custom_command (TARGET <TARGET> POST_BUILD COMMAND codesign ....)

1 Like

Ok great, I will try this. Thank you very much :slight_smile: