Skip to content

Commit 6ef322f

Browse files
committed
Codesign OpenStudioApp.app only (not the OpenStudio / EnergyPlus stuff...)
1 parent f8b8b0b commit 6ef322f

File tree

3 files changed

+34
-20
lines changed

3 files changed

+34
-20
lines changed

CMake/CodeSigning.cmake

Lines changed: 14 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ This module defines functions to codesign, notarize and staple macOS files.
1010
1111
codesign_files_macos(
1212
SIGNING_IDENTITY <identity>
13-
[FORCE] [VERBOSE]
13+
[FORCE] [VERBOSE] [DEEP]
1414
[IDENTIFIER <identifier>]
1515
[PREFIX <prefix>]
1616
[OPTIONS <options>...]
@@ -34,6 +34,9 @@ This module defines functions to codesign, notarize and staple macOS files.
3434
``FORCE``
3535
If specified, will append ``--force``
3636
37+
``DEEP``
38+
If specified, will append ``--deep``. Note that this is supposedly deprecated by the ``codesign`` utility.
39+
3740
``OPTIONS options...``
3841
Specifies the options to pass to ``--options``. If not specified, uses ``--options runtime``
3942
@@ -142,7 +145,7 @@ endfunction()
142145
#------------------------------------------------------------------------------
143146
function(codesign_files_macos)
144147
set(prefix "")
145-
set(valueLessKeywords FORCE VERBOSE)
148+
set(valueLessKeywords FORCE VERBOSE DEEP)
146149
set(singleValueKeywords SIGNING_IDENTITY IDENTIFIER PREFIX)
147150
set(multiValueKeywords FILES OPTIONS)
148151
cmake_parse_arguments(
@@ -189,6 +192,10 @@ function(codesign_files_macos)
189192
list(APPEND cmd --force)
190193
endif()
191194

195+
if(_DEEP)
196+
list(APPEND cmd --deep)
197+
endif()
198+
192199
list(APPEND cmd --timestamp)
193200
list(APPEND cmd --options "${options_str}")
194201

@@ -387,12 +394,13 @@ function(register_install_codesign_target TARGET_NAME DESTINATION COMPONENT)
387394
CODE "
388395
include(\"${CMAKE_CURRENT_FUNCTION_LIST_FILE}\")
389396
codesign_files_macos(
390-
FILES \"\${CMAKE_INSTALL_PREFIX}/${DESTINATION}/$<TARGET_FILE_NAME:${TARGET_NAME}>\"
397+
FILES \"\${CMAKE_INSTALL_PREFIX}/${DESTINATION}/$<IF:$<BOOL:$<TARGET_PROPERTY:${TARGET_NAME},MACOSX_BUNDLE>>,$<TARGET_BUNDLE_DIR_NAME:${TARGET_NAME}>,$<TARGET_FILE_NAME:${TARGET_NAME}>>\"
391398
SIGNING_IDENTITY \"${CPACK_CODESIGNING_DEVELOPPER_ID_APPLICATION}\"
392399
IDENTIFIER \"${CPACK_CODESIGNING_MACOS_IDENTIFIER}.${TARGET_NAME}\"
393-
FORCE VERBOSE
400+
FORCE VERBOSE $<$<BOOL:$<TARGET_PROPERTY:${TARGET_NAME},MACOSX_BUNDLE>>:DEEP>
394401
)
395-
"
396-
COMPONENT ${COMPONENT})
402+
"
403+
COMPONENT ${COMPONENT}
404+
)
397405

398406
endfunction()

CMakeLists.txt

Lines changed: 15 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -344,20 +344,6 @@ include("${PROJECT_SOURCE_DIR}/ProjectMacros.cmake")
344344
# Start with ROOT, then PROJECT_BINARY_DIR
345345
list(APPEND CMAKE_MODULE_PATH "${CMAKE_BINARY_DIR} ${PROJECT_BINARY_DIR}" "${PROJECT_SOURCE_DIR}/CMake")
346346

347-
if(APPLE)
348-
349-
include(${CMAKE_CURRENT_LIST_DIR}/CMake/CodeSigning.cmake)
350-
351-
# Defines CPACK_CODESIGNING_DEVELOPPER_ID_APPLICATION and CPACK_CODESIGNING_NOTARY_PROFILE_NAME
352-
setup_macos_codesigning_variables()
353-
354-
if(CPACK_CODESIGNING_DEVELOPPER_ID_APPLICATION)
355-
# Register the CPACK_POST_BUILD_SCRIPTS
356-
set(CPACK_POST_BUILD_SCRIPTS "${CMAKE_CURRENT_LIST_DIR}/CMake/CPackSignAndNotarizeDmg.cmake")
357-
endif()
358-
359-
endif()
360-
361347
# Use CTest
362348
set(ALL_TESTING_TARGETS "") # global list
363349
if(BUILD_TESTING)
@@ -936,6 +922,21 @@ elseif(WIN32)
936922
set(CPACK_BINARY_NSIS OFF CACHE BOOL "Enable to build NSIS packages")
937923
endif()
938924

925+
926+
if(APPLE)
927+
928+
include(${CMAKE_CURRENT_LIST_DIR}/CMake/CodeSigning.cmake)
929+
930+
# Defines CPACK_CODESIGNING_DEVELOPPER_ID_APPLICATION and CPACK_CODESIGNING_NOTARY_PROFILE_NAME
931+
setup_macos_codesigning_variables()
932+
933+
if(CPACK_CODESIGNING_DEVELOPPER_ID_APPLICATION)
934+
# Register the CPACK_POST_BUILD_SCRIPTS
935+
set(CPACK_POST_BUILD_SCRIPTS "${CMAKE_CURRENT_LIST_DIR}/CMake/CPackSignAndNotarizeDmg.cmake")
936+
endif()
937+
938+
endif()
939+
939940
######################################################################################################################################################
940941
# P A C K A G I N G & C O M P O N E N T S #
941942
######################################################################################################################################################

src/openstudio_app/CMakeLists.txt

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -536,3 +536,8 @@ if(BUILD_TESTING)
536536
#)
537537

538538
endif()
539+
540+
if(APPLE AND CPACK_CODESIGNING_DEVELOPPER_ID_APPLICATION)
541+
include("${CMAKE_CURRENT_SOURCE_DIR}/../../cmake/CodeSigning.cmake")
542+
register_install_codesign_target(${target_name} "." "OpenStudioApp")
543+
endif()

0 commit comments

Comments
 (0)