This repository has been archived on 2020-09-07. You can view files and clone it. You cannot open issues or pull requests or push a commit.
Files
libs/qad/QADDeploy.cmake

57 lines
2.3 KiB
CMake

# create make target "deploy"
#
# use "CMAKE_OTOOL" or "CMAKE_OBJDUMP" variable,
# depends on target platform
# use "RELEASE_DIR" variable, where can be found
# * executable on Windows, Linux
# * <T>.app directory with installed executable on MacOS
# can use "DEPLOY_ADD_LIBPATH" variable as additional
# library search path
#
macro(deploy_target _T full_app_name version icon label copyright info)
get_filename_component(_ICON_NAME "${icon}" NAME)
get_filename_component(_ICON_FN "${icon}" ABSOLUTE BASE_DIR "${CMAKE_CURRENT_SOURCE_DIR}")
set(_TV "${_T}-${version}")
set(_DEP_LIBPATH)
get_target_property(_LL ${_T} LINK_LIBRARIES)
foreach (_L ${_LL})
if (TARGET ${_L})
get_target_property(_II ${_L} IMPORTED)
if (NOT _II)
#message("depend on ${_L}")
set(_DEP_LIBPATH "${_DEP_LIBPATH}\;$<TARGET_FILE_DIR:${_L}>")
endif()
endif()
endforeach()
message("app depend libpath ${_DEP_LIBPATH}")
if (APPLE)
set(MACOSX_BUNDLE_GUI_IDENTIFIER "${full_app_name}")
set(MACOSX_BUNDLE_SHORT_VERSION_STRING "${version}")
set(MACOSX_BUNDLE_LONG_VERSION_STRING "${version}")
set(MACOSX_BUNDLE_ICON_FILE "${_ICON_NAME}")
set(MACOSX_BUNDLE_BUNDLE_NAME "${label}")
set(MACOSX_BUNDLE_COPYRIGHT "${copyright}")
set(MACOSX_BUNDLE_INFO_STRING "${info}")
set(MACOSX_BUNDLE_BUNDLE_VERSION "6.0")
set_target_properties(${_T} PROPERTIES MACOSX_BUNDLE TRUE)
set(_AGD "${RELEASE_DIR}/${_T}.app")
set(_DMG "${CMAKE_CURRENT_BINARY_DIR}/dmg")
add_custom_target(deploy
# gather .app dir
COMMAND mkdir -p ${_AGD}/Contents/Resources
COMMAND mkdir -p ${_AGD}/Contents/Frameworks
COMMAND cp ${_ICON_FN} ${_AGD}/Contents/Resources
COMMAND deploy_tool -M "${CMAKE_OTOOL}" -P cocoa -S mac -q ${Qt5_ROOT} -s \"${CMAKE_PREFIX_PATH}/lib\;${DEPLOY_ADD_LIBPATH}${_DEP_LIBPATH}\" -o ${_AGD}/Contents/Frameworks -p ${_AGD}/Contents/PlugIns ${_AGD}/Contents/MacOS/${_T}
# prepare dmg dir
COMMAND rm -rf ${_DMG}
COMMAND mkdir -p ${_DMG}
COMMAND cp -r ${_AGD} ${_DMG}
COMMAND ln --symbolic /Applications ${_DMG}
# generate dmg
COMMAND genisoimage -quiet -V ${_T} -D -R -apple -no-pad -o ${RELEASE_DIR}/${_TV}.dmg ${_DMG}
COMMENT "Generating ${_TV}.dmg"
)
endif()
endmacro()