From 66936f20870490bedf99614877b609c944b5ba69 Mon Sep 17 00:00:00 2001 From: TellowKrinkle Date: Fri, 17 Mar 2023 01:19:56 -0500 Subject: [PATCH 1/2] CMake: Use generator expressions to get codesigning targets Also works around a bug where CMake's ninja generator doesn't properly handle ||'s on POST_BUILD commands, making the || apply to the whole build like ` && custom0 || custom1` --- Source/Core/DolphinQt/CMakeLists.txt | 14 ++------------ Source/Core/MacUpdater/CMakeLists.txt | 10 +--------- 2 files changed, 3 insertions(+), 21 deletions(-) diff --git a/Source/Core/DolphinQt/CMakeLists.txt b/Source/Core/DolphinQt/CMakeLists.txt index e9d24bc4d1..4002d5f913 100644 --- a/Source/Core/DolphinQt/CMakeLists.txt +++ b/Source/Core/DolphinQt/CMakeLists.txt @@ -616,18 +616,8 @@ if(APPLE) if(MACOS_CODE_SIGNING) # Code sign make file builds - add_custom_command(TARGET dolphin-emu - POST_BUILD COMMAND - /usr/bin/codesign -f -s "${MACOS_CODE_SIGNING_IDENTITY}" --deep --options=runtime --entitlements "${CMAKE_SOURCE_DIR}/Source/Core/DolphinQt/DolphinEmu$<$:Debug>.entitlements" "${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/Dolphin.app" || true) - - # Code sign builds for build systems that do have release/debug variants (Xcode) - add_custom_command(TARGET dolphin-emu - POST_BUILD COMMAND - /usr/bin/codesign -f -s "${MACOS_CODE_SIGNING_IDENTITY}" --deep --options=runtime --entitlements "${CMAKE_SOURCE_DIR}/Source/Core/DolphinQt/DolphinEmuDebug.entitlements" "${CMAKE_RUNTIME_OUTPUT_DIRECTORY_DEBUG}/Dolphin.app" || true) - - add_custom_command(TARGET dolphin-emu - POST_BUILD COMMAND - /usr/bin/codesign -f -s "${MACOS_CODE_SIGNING_IDENTITY}" --deep --options=runtime --entitlements "${CMAKE_SOURCE_DIR}/Source/Core/DolphinQt/DolphinEmu.entitlements" "${CMAKE_RUNTIME_OUTPUT_DIRECTORY_RELEASE}/Dolphin.app" || true) + add_custom_command(TARGET dolphin-emu POST_BUILD + COMMAND /usr/bin/codesign -f -s "${MACOS_CODE_SIGNING_IDENTITY}" --deep --options=runtime --entitlements "${CMAKE_SOURCE_DIR}/Source/Core/DolphinQt/DolphinEmu$<$:Debug>.entitlements" "$") endif() else() install(TARGETS dolphin-emu RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}) diff --git a/Source/Core/MacUpdater/CMakeLists.txt b/Source/Core/MacUpdater/CMakeLists.txt index dc09866822..e0023f3870 100644 --- a/Source/Core/MacUpdater/CMakeLists.txt +++ b/Source/Core/MacUpdater/CMakeLists.txt @@ -65,14 +65,6 @@ if(MACOS_CODE_SIGNING) set(MACOS_CODE_SIGNING_IDENTITY_UPDATER "${MACOS_CODE_SIGNING_IDENTITY}") endif() - # Make file build code sign add_custom_command(TARGET MacUpdater POST_BUILD - COMMAND test ${MacUpdater_BUNDLE_PATH} || /usr/bin/codesign -f -s "${MACOS_CODE_SIGNING_IDENTITY_UPDATER}" --deep --options runtime ${MacUpdater_BUNDLE_PATH}) - - # Xcode build code sign - add_custom_command(TARGET MacUpdater POST_BUILD - COMMAND test "${CMAKE_RUNTIME_OUTPUT_DIRECTORY_DEBUG}/${MacUpdater_NAME}.app" || /usr/bin/codesign -f -s "${MACOS_CODE_SIGNING_IDENTITY_UPDATER}" --deep --options runtime "${CMAKE_RUNTIME_OUTPUT_DIRECTORY_DEBUG}/${MacUpdater_NAME}.app") - - add_custom_command(TARGET MacUpdater POST_BUILD - COMMAND test "${CMAKE_RUNTIME_OUTPUT_DIRECTORY_RELEASE}/${MacUpdater_NAME}.app" || /usr/bin/codesign -f -s "${MACOS_CODE_SIGNING_IDENTITY_UPDATER}" --deep --options runtime "${CMAKE_RUNTIME_OUTPUT_DIRECTORY_RELEASE}/${MacUpdater_NAME}.app") + COMMAND /usr/bin/codesign -f -s "${MACOS_CODE_SIGNING_IDENTITY_UPDATER}" --deep --options runtime $) endif() From d037c60caff4c4773738fd8dd3d1159cc8ed101b Mon Sep 17 00:00:00 2001 From: TellowKrinkle Date: Fri, 17 Mar 2023 01:20:27 -0500 Subject: [PATCH 2/2] CMake: Use proper dependency tracking command for storyboard compiling --- Source/Core/MacUpdater/CMakeLists.txt | 19 ++++++++----------- 1 file changed, 8 insertions(+), 11 deletions(-) diff --git a/Source/Core/MacUpdater/CMakeLists.txt b/Source/Core/MacUpdater/CMakeLists.txt index e0023f3870..d610a02bfa 100644 --- a/Source/Core/MacUpdater/CMakeLists.txt +++ b/Source/Core/MacUpdater/CMakeLists.txt @@ -47,17 +47,14 @@ if (${IBTOOL} STREQUAL "IBTOOL-NOTFOUND") endif() foreach(sb ${STORYBOARDS}) - set(MacUpdater_BIN_DIR ${CMAKE_BINARY_DIR}/Binaries) - - if (CMAKE_GENERATOR STREQUAL Xcode) - string(APPEND MacUpdater_BIN_DIR "/\${CONFIGURATION}") - endif() - - add_custom_command(TARGET MacUpdater POST_BUILD - COMMAND ${IBTOOL} --errors --warnings --notices --output-format human-readable-text - --compile ${MacUpdater_BUNDLE_PATH}/Contents/Resources/${sb}c - ${CMAKE_CURRENT_SOURCE_DIR}/${sb} - COMMENT "Compiling Storyboard ${sb}...") + set(output ${CMAKE_CURRENT_BINARY_DIR}/${sb}c) + set(input ${CMAKE_CURRENT_SOURCE_DIR}/${sb}) + add_custom_command(OUTPUT ${output} + COMMAND ${IBTOOL} --errors --warnings --notices --output-format human-readable-text --compile ${output} ${input} + DEPENDS ${input} + COMMENT "Compiling Storyboard ${sb}...") + target_sources(MacUpdater PRIVATE ${output}) + set_source_files_properties(${output} PROPERTIES MACOSX_PACKAGE_LOCATION Resources) endforeach() if(MACOS_CODE_SIGNING)