mirror of https://gitee.com/cxasm/notepad--.git
cmake/platforms: 对 MacOS 平台构建简单支持(CPack)
This commit is contained in:
parent
efe773a92d
commit
98a49ef22a
|
@ -46,16 +46,15 @@ option(WINDOWS_DEPLOY_QT6 "通用 Windows 平台指定 Qt6 部署 windeployqt
|
|||
option(USE_LINUX_UNIVERSAL "通用 Linux 平台构建" OFF)
|
||||
option(USE_LINUX_DEBIAN "通用 Debian Linux 平台构建" OFF)
|
||||
option(USE_LINUX_APPIMAGE "通用 Appimage Linux 平台构建" OFF)
|
||||
#
|
||||
option(USE_LINUX_UOS "独立 Linux 平台的 Uos 构建" OFF)
|
||||
#
|
||||
option(USE_MACOS_UNIVERSAL "通用 MacOS 平台构建" OFF)
|
||||
option(USE_MACOSX_UNIVERSAL "通用 MacOSX 平台构建" OFF)
|
||||
|
||||
# 使用 windows.cmake / linux.cmake / macos.cmake 维护构建.
|
||||
|
||||
# 在 Windows 中此处将由通用构建、MinGW 构建、MSVC 构建组成
|
||||
if(WIN32)
|
||||
|
||||
|
||||
# 通用 Windows 平台构建,一切的起始
|
||||
if(USE_WINDOWS_UNIVERSAL)
|
||||
include(cmake/platforms/windows-universal.cmake)
|
||||
|
@ -104,10 +103,15 @@ elseif(UNIX AND NOT APPLE AND NOT WIN32 AND NOT ANDROID)
|
|||
# include(cmake/platforms/linux-other.cmake)
|
||||
endif(USE_LINUX_UNIVERSAL)
|
||||
|
||||
# 通用 MacOS 平台的构建(一个无具体实现的空构建)
|
||||
# 通用 MacOSX 平台的构建
|
||||
elseif(APPLE)
|
||||
|
||||
# include(cmake/platforms/macos.cmake)
|
||||
# 通用 MacOSX 平台构建,一切的起始
|
||||
if(USE_MACOSX_UNIVERSAL)
|
||||
include(cmake/platforms/macos-universal.cmake)
|
||||
|
||||
endif(USE_MACOSX_UNIVERSAL)
|
||||
|
||||
endif()
|
||||
|
||||
# ----------------- Notepad-- 其它主线构建相关 ----------------- #
|
||||
|
|
|
@ -39,10 +39,18 @@ if(TRUE)
|
|||
target_link_qt6_Core5Compat(QSci)
|
||||
target_link_qt6_PrintSupport(QSci)
|
||||
target_link_qt6_Concurrent(QSci)
|
||||
if(APPLE)
|
||||
# Is there anything missing?
|
||||
# MacExtras?
|
||||
endif(APPLE)
|
||||
else()
|
||||
target_link_qt5(QSci)
|
||||
target_link_qt5_PrintSupport(QSci)
|
||||
target_link_qt5_Concurrent(QSci)
|
||||
if(APPLE)
|
||||
find_package(Qt5 COMPONENTS MacExtras)
|
||||
target_link_libraries(QSci Qt5::MacExtras)
|
||||
endif(APPLE)
|
||||
endif(USE_QT6)
|
||||
endif(TRUE)
|
||||
|
||||
|
|
|
@ -0,0 +1,78 @@
|
|||
# macos-deployqt.cmake
|
||||
|
||||
# NOTE: 未提供可用性判断
|
||||
|
||||
# option(MACOSX_DEPLOY_QT "为 MacOS 中构建的应用进行 macdeployqt" OFF)
|
||||
# option(MACOSX_DEPLOY_QT5 "为 MacOS 中构建的 QT5 应用进行 macdeployqt" OFF)
|
||||
# option(MACOSX_DEPLOY_QT6 "为 MacOS 中构建的 QT6 应用进行 macdeployqt" OFF)
|
||||
|
||||
# if(USE_MACOSX_DEPLOY_QT)
|
||||
# if(MACOSX_DEPLOY_QT5)
|
||||
# # 当使用 MACOSX_DEPLOY_QT5 配方时,将使用来源于 Qt5 中提供的路径
|
||||
# set(MACOSX_QT_DIR "${Qt5_DIR}")
|
||||
# elseif(MACOSX_DEPLOY_QT6)
|
||||
# # 当使用 MACOSX_DEPLOY_QT6 配方时,将使用来源于 Qt6 中提供的路径
|
||||
# set(MACOSX_QT_DIR "${Qt6_DIR}")
|
||||
# endif()
|
||||
|
||||
# if (MACOSX_DEPLOY_QT5 OR MACOSX_DEPLOY_QT6)
|
||||
|
||||
# if(USE_QT6)
|
||||
# set(MACOSX_QT_DIR "${Qt6_DIR}")
|
||||
# endif(USE_QT6)
|
||||
|
||||
# #/opt/homebrew/Cellar/qt@5/5.15.10_1/bin/macdeployqt
|
||||
# set(MACOS_APPLICATION_DEPLOY_PATH
|
||||
# ${CMAKE_BINARY_DIR}/macos-deployqt)
|
||||
|
||||
# set(MACOS_APPLICATION_BUNDLE_PATH
|
||||
# ${MACOS_APPLICATION_DEPLOY_PATH}/${PROJECT_NAME}.app)
|
||||
|
||||
# # set_target_properties(${PROJECT_NAME}
|
||||
# # PROPERTIES
|
||||
# # 可执行文件生成目录
|
||||
# # MACOSX_BUNDLE TRUE
|
||||
# # RUNTIME_OUTPUT_DIRECTORY ${MACOS_APPLICATION_DEPLOY_PATH})
|
||||
# # RUNTIME_OUTPUT_DIRECTORY ${MACOS_APPLICATION_DEPLOY_PATH}/Contents/MacOS)
|
||||
|
||||
# message("MACOS_QT_DIR: ${MACOS_QT_DIR}")
|
||||
|
||||
|
||||
# # install(FILES src/mac.icns
|
||||
# # DESTINATION
|
||||
# # ${MACOS_APPLICATION_DEPLOY_PATH}/Contents/Resources)
|
||||
|
||||
# # add_custom_command(TARGET ${PROJECT_NAME}
|
||||
# # # 在构建之后计划进行执行以下命令
|
||||
# # POST_BUILD
|
||||
# # # 即将在构建目录中
|
||||
# # WORKING_DIRECTORY ${CMAKE_BINARY_DIR}
|
||||
# # # COMMAND ${CMAKE_COMMAND} -E make_directory
|
||||
# # # ${MACOS_APPLICATION_BUNDLE_PATH}/Contents/Resources/
|
||||
# # # COMMAND ${CMAKE_COMMAND} -E copy
|
||||
# # # ${CMAKE_SOURCE_DIR}/src/mac.icns
|
||||
# # # ${MACOS_APPLICATION_BUNDLE_PATH}/Contents/Resources/
|
||||
# # # 执行以下命令进行 windeployqt
|
||||
# # COMMAND ${MACOS_QT_DIR}/../../../bin/macdeployqt
|
||||
# # #
|
||||
# # ${MACOS_APPLICATION_BUNDLE_PATH}
|
||||
|
||||
# # # 扫描QML-从目录开始导入。
|
||||
# # #--qmlimport=${MACOS_QT_DIR}/../../../qml
|
||||
# # # 部署编译器运行时(仅限桌面)。
|
||||
# # #--compiler-runtime
|
||||
# # # 详细级别(0-2)
|
||||
# # #--verbose=2
|
||||
# # # 部署运行时使用指定的目录
|
||||
# # # --dir ${MACOS_APPLICATION_DEPLOY_PATH}
|
||||
# # )
|
||||
|
||||
# if(USE_MAC_DEPLOYQT)
|
||||
# include(cmake/platforms/utils.cmake)
|
||||
# macdeployqt_install(${PROJECT_NAME})
|
||||
# endif(USE_MAC_DEPLOYQT)
|
||||
|
||||
# include(CPack)
|
||||
|
||||
# endif(MACOSX_DEPLOY_QT5 OR MACOSX_DEPLOY_QT6)
|
||||
# endif(USE_MACOSX_DEPLOY_QT)
|
|
@ -1,5 +1,25 @@
|
|||
# macos-universal.cmake
|
||||
|
||||
if(USE_MACOS_UNIVERSAL)
|
||||
# 此构建表示,在 MacOSX 中以通用平台的构建方式进行构建此内容
|
||||
# 为 Notepad-- 通用构建的设计安装结构
|
||||
#
|
||||
# Contents/ 在 MacOSX 中标准的包目录
|
||||
# MacOS/
|
||||
# Notepad-- 在 MacOSX 中标准的程序位置
|
||||
#
|
||||
# Resources/
|
||||
# ...
|
||||
|
||||
endif(USE_MACOS_UNIVERSAL)
|
||||
if(CMAKE_HOST_APPLE)
|
||||
|
||||
set(CPACK_GENERATOR "Bundle")
|
||||
set(CPACK_BUNDLE_NAME ${PROJECT_NAME})
|
||||
set(CPACK_BUNDLE_ICON ${CMAKE_SOURCE_DIR}/src/mac.icns)
|
||||
set(CPACK_BUNDLE_PLIST ${CMAKE_SOURCE_DIR}/cmake/platforms/macos/cpack/Info.plist)
|
||||
|
||||
# 程序安装位置
|
||||
install(TARGETS ${PROJECT_NAME} DESTINATION ../MacOS)
|
||||
# 安装 themes
|
||||
install(DIRECTORY src/themes DESTINATION ../MacOS)
|
||||
|
||||
endif(CMAKE_HOST_APPLE)
|
||||
|
|
|
@ -0,0 +1,161 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
|
||||
<plist version="1.0">
|
||||
<dict>
|
||||
<key>CFBundleExecutable</key>
|
||||
<string>Notepad--</string>
|
||||
<key>CFBundleGetInfoString</key>
|
||||
<string>Created by zuoweiyin</string>
|
||||
<key>CFBundleDocumentTypes</key>
|
||||
<array>
|
||||
<dict>
|
||||
<key>CFBundleTypeExtensions</key>
|
||||
<array>
|
||||
<string>txt</string>
|
||||
</array>
|
||||
<key>CFBundleTypeIconFile</key>
|
||||
<string>txt.png</string>
|
||||
<key>CFBundleTypeName</key>
|
||||
<string>abc file</string>
|
||||
<key>CFBundleTypeRole</key>
|
||||
<string>Editor</string>
|
||||
<key>LSTypeIsPackage</key>
|
||||
<true/>
|
||||
<key>NSPersistentStoreTypeKey</key>
|
||||
<string>XML</string>
|
||||
</dict>
|
||||
<dict>
|
||||
<key>CFBundleTypeExtensions</key>
|
||||
<array>
|
||||
<string>cpp</string>
|
||||
</array>
|
||||
<key>CFBundleTypeIconFile</key>
|
||||
<string>cpp.png</string>
|
||||
<key>CFBundleTypeName</key>
|
||||
<string>cpp file</string>
|
||||
<key>CFBundleTypeRole</key>
|
||||
<string>Editor</string>
|
||||
<key>LSTypeIsPackage</key>
|
||||
<true/>
|
||||
<key>NSPersistentStoreTypeKey</key>
|
||||
<string>xml</string>
|
||||
</dict>
|
||||
<dict>
|
||||
<key>CFBundleTypeExtensions</key>
|
||||
<array>
|
||||
<string>c</string>
|
||||
</array>
|
||||
<key>CFBundleTypeIconFile</key>
|
||||
<string>c.png</string>
|
||||
<key>CFBundleTypeName</key>
|
||||
<string>c file</string>
|
||||
<key>CFBundleTypeRole</key>
|
||||
<string>Editor</string>
|
||||
<key>LSTypeIsPackage</key>
|
||||
<true/>
|
||||
<key>NSPersistentStoreTypeKey</key>
|
||||
<string>xml</string>
|
||||
</dict>
|
||||
<dict>
|
||||
<key>CFBundleTypeExtensions</key>
|
||||
<array>
|
||||
<string>h</string>
|
||||
</array>
|
||||
<key>CFBundleTypeIconFile</key>
|
||||
<string>h.png</string>
|
||||
<key>CFBundleTypeName</key>
|
||||
<string>h file</string>
|
||||
<key>CFBundleTypeRole</key>
|
||||
<string>Editor</string>
|
||||
<key>LSTypeIsPackage</key>
|
||||
<true/>
|
||||
<key>NSPersistentStoreTypeKey</key>
|
||||
<string>XML</string>
|
||||
</dict>
|
||||
<dict>
|
||||
<key>CFBundleTypeExtensions</key>
|
||||
<array>
|
||||
<string>html</string>
|
||||
</array>
|
||||
<key>CFBundleTypeIconFile</key>
|
||||
<string>html.png</string>
|
||||
<key>CFBundleTypeName</key>
|
||||
<string>html file</string>
|
||||
<key>CFBundleTypeRole</key>
|
||||
<string>Editor</string>
|
||||
<key>LSTypeIsPackage</key>
|
||||
<true/>
|
||||
<key>NSPersistentStoreTypeKey</key>
|
||||
<string>XML</string>
|
||||
</dict>
|
||||
<dict>
|
||||
<key>CFBundleTypeExtensions</key>
|
||||
<array>
|
||||
<string>ini</string>
|
||||
<string>go</string>
|
||||
<string>java</string>
|
||||
<string>js</string>
|
||||
<string>json</string>
|
||||
<string>xml</string>
|
||||
<string>pro</string>
|
||||
<string>pri</string>
|
||||
<string>php</string>
|
||||
<string>asp</string>
|
||||
<string>bat</string>
|
||||
<string>asm</string>
|
||||
<string>html</string>
|
||||
<string>yml</string>
|
||||
<string>js</string>
|
||||
<string>sh</string>
|
||||
<string>log</string>
|
||||
<string>csv</string>
|
||||
<string>json</string>
|
||||
</array>
|
||||
<key>CFBundleTypeIconFile</key>
|
||||
<string>*.png</string>
|
||||
<key>CFBundleTypeName</key>
|
||||
<string>* file</string>
|
||||
<key>CFBundleTypeRole</key>
|
||||
<string>Editor</string>
|
||||
<key>LSTypeIsPackage</key>
|
||||
<true/>
|
||||
<key>NSPersistentStoreTypeKey</key>
|
||||
<string>XML</string>
|
||||
</dict>
|
||||
<dict>
|
||||
<key>CFBundleTypeExtensions</key>
|
||||
<array>
|
||||
<string>html</string>
|
||||
</array>
|
||||
<key>CFBundleTypeIconFile</key>
|
||||
<string>html.png</string>
|
||||
<key>CFBundleTypeName</key>
|
||||
<string>html file</string>
|
||||
<key>CFBundleTypeRole</key>
|
||||
<string>Editor</string>
|
||||
<key>LSTypeIsPackage</key>
|
||||
<true/>
|
||||
<key>NSPersistentStoreTypeKey</key>
|
||||
<string>XML</string>
|
||||
</dict>
|
||||
</array>
|
||||
<key>CFBundleIconFile</key>
|
||||
<string>Notepad--.icns</string>
|
||||
<key>CFBundleIdentifier</key>
|
||||
<string>www.itdp.cn.Notepad--</string>
|
||||
<key>CFBundlePackageType</key>
|
||||
<string>APPL</string>
|
||||
<key>CFBundleSignature</key>
|
||||
<string>????</string>
|
||||
<key>LSMinimumSystemVersion</key>
|
||||
<string>14.1</string>
|
||||
<key>NOTE</key>
|
||||
<string>This file was generated by Qt/QMake.</string>
|
||||
<key>NSPrincipalClass</key>
|
||||
<string>NSApplication</string>
|
||||
<key>NSSupportsAutomaticGraphicsSwitching</key>
|
||||
<true/>
|
||||
<key>NSRequiresAquaSystemAppearance</key>
|
||||
<true/>
|
||||
</dict>
|
||||
</plist>
|
|
@ -5,7 +5,7 @@
|
|||
# _VAR 用于存储内容的变量
|
||||
# _IS_IS_SHREAD 是否为共享库
|
||||
# _LIB 目标名称
|
||||
function(get_current_platform_lib_name _VAR _IS_SHREAD _LIB)
|
||||
function(get_current_platform_lib_name _VAR _IS_SHREAD _LIB)
|
||||
set(_LIB_NAME "")
|
||||
if(WIN32)
|
||||
set(_LIB_NAME ${_LIB}.lib)
|
||||
|
@ -101,3 +101,37 @@ function(windeployqt_install TARGET)
|
|||
"
|
||||
)
|
||||
endfunction(windeployqt_install TARGET)
|
||||
|
||||
#
|
||||
# [UnTested]macdeployqt_install
|
||||
# MacOSX 在 install 目标时进行 macdeployqt 的自动化
|
||||
# 由于
|
||||
function(macdeployqt_install _target)
|
||||
set(MACDEPLOYQT_EXECUTABLE "${MACOS_QT_DIR}/../../../bin/macdeployqt")
|
||||
#
|
||||
file(GENERATE OUTPUT "${CMAKE_BINARY_DIR}/${_target}_PATH"
|
||||
# CONTENT "$<TARGET_FILE:${_target}>"
|
||||
CONTENT "${CMAKE_BINARY_DIR}/_CPack_Packages/Darwin/Bundle/${_target}-${PROJECT_VERSION}-Darwin/${_target}.app"
|
||||
)
|
||||
install(CODE
|
||||
"
|
||||
file(READ \"${CMAKE_BINARY_DIR}/${_target}_PATH\" _file)
|
||||
execute_process(
|
||||
COMMAND \"${MACDEPLOYQT_EXECUTABLE}\"
|
||||
# 虚假的运行 macdeployqt 而不复制任何内容
|
||||
--dry-run
|
||||
# 扫描QML-从目录开始导入。
|
||||
#--qmlimport=${MACOS_QT_DIR}/../../../qml
|
||||
# 部署编译器运行时(仅限桌面)。
|
||||
#--compiler-runtime
|
||||
# 以源 目标的输出形成映射关系,以便用于解析内容
|
||||
#--list mapping
|
||||
#-no-plugins
|
||||
#-timestamp
|
||||
\${_file}
|
||||
OUTPUT_VARIABLE _output
|
||||
OUTPUT_STRIP_TRAILING_WHITESPACE
|
||||
)
|
||||
"
|
||||
)
|
||||
endfunction(macdeployqt_install _target)
|
||||
|
|
20
macos.mk
20
macos.mk
|
@ -1,4 +1,24 @@
|
|||
Msg := 'Build with the following configuration:'
|
||||
One := '1. make macosx-universal'
|
||||
Two := '1. make macosx-universal-release'
|
||||
|
||||
all:
|
||||
@echo $(Msg)
|
||||
@echo $(One) "\n\t默认的通用 MacOSX 平台构建(Debug)."
|
||||
@echo $(Two) "\n\t默认的通用 MacOSX 平台构建(Release)."
|
||||
|
||||
builddir := build/macosx-universal
|
||||
sourcedir := .
|
||||
CMAKE_DEBUG := -DCMAKE_BUILD_TYPE=Debug
|
||||
CMAKE_RELEASE := -DCMAKE_BUILD_TYPE=Release
|
||||
CMAKE_OPTIONS := -DUSE_MACOSX_UNIVERSAL=ON
|
||||
|
||||
CPUS=8
|
||||
|
||||
macosx-universal:
|
||||
cmake -B$(builddir) $(CMAKE_OPTIONS) $(CMAKE_DEBUG)
|
||||
cmake --build $(builddir) -- -j$(CPUS)
|
||||
|
||||
macosx-universal-release:
|
||||
cmake -B$(builddir) $(CMAKE_OPTIONS) $(CMAKE_RELEASE)
|
||||
cmake --build $(builddir) -- -j$(CPUS)
|
||||
|
|
Loading…
Reference in New Issue