!21 Cmake兼容Win和Linux下编译

* 文件编码同步
* !1 部分注释合并
* 修正注释显示异常
* 1. 修改win.mk中Qt_MSVC/MINGW_PREFIX_PATH变量后可以直接进行编译打包
* 优化打包流程
* 支持Win下连同插件一起打包
* Merge branch 'master' of gitee.com:XiaoPb/notepad--
* 优化插件打包脚本
* update linux.mk
* update define "NDD_EXPORT" of Linux
* 1. 去除SPARK依赖
* 1. 优化CMake
* 1. rc文件适配MinGw编译器
* 去除不必要的打印
* 修复linux.mk不兼容CMakeLists.txt问题
* 更正linux.mk的调用
* python版本需要3以上
* 支持到Win下使用Cmake编译
* update CMakeLists.txt
* 修改部分即将废除的api用法
* cmake-version: 将版本降到 3.22 以适用于 cmake 构建
* repo: 对 desktop 文件添加 %F 参数,以保证可正确传入参数
* desktop: 为 desktop 添加文本文件的相关 MimeType
* repo: 引入 Spark 构建,支持构建 Appimage
* repo: 引入 Spark 构建,支持构建 deb
* add cmake support
This commit is contained in:
XiaoPb 2023-02-07 12:49:17 +00:00 committed by 爬山虎
parent 061aaf6067
commit 01a40bf7c3
17 changed files with 391 additions and 56 deletions

44
.gitignore vendored
View File

@ -9,7 +9,7 @@
*.user *.user
*.userosscache *.userosscache
*.sln.docstates *.sln.docstates
build
# User-specific files (MonoDevelop/Xamarin Studio) # User-specific files (MonoDevelop/Xamarin Studio)
*.userprefs *.userprefs
@ -390,9 +390,39 @@ FodyWeavers.xsd
# Windows Installer files from build outputs # Windows Installer files from build outputs
*.cab *.cab
*.msi *.msi
*.msix *.msix
*.msm *.msm
*.msp *.msp
# JetBrains Rider # JetBrains Rider
*.sln.iml *.sln.iml
# Ignore the build directory generated by the vsocde cmake extension
build/
# Ignore the build directory generated by the vsocde clangd extension
.cache
# Created by https://www.toptal.com/developers/gitignore/api/cmake
# Edit at https://www.toptal.com/developers/gitignore?templates=cmake
### CMake ###
CMakeLists.txt.user
CMakeCache.txt
CMakeFiles
CMakeScripts
Testing
Makefile
cmake_install.cmake
install_manifest.txt
compile_commands.json
CTestTestfile.cmake
_deps
### CMake Patch ###
# External projects
*-prefix/
# End of https://www.toptal.com/developers/gitignore/api/cmake
!/Makefile

View File

@ -1,5 +1,5 @@
cmake_minimum_required(VERSION 3.16) cmake_minimum_required(VERSION 3.16)
project(notepad--) project(NotePad-- VERSION 1.22.0)
set(CMAKE_AUTOMOC ON) set(CMAKE_AUTOMOC ON)
set(CMAKE_AUTOUIC ON) set(CMAKE_AUTOUIC ON)
@ -7,49 +7,84 @@ set(CMAKE_AUTORCC ON)
find_package(Qt5 REQUIRED COMPONENTS Core Gui Widgets Concurrent Network PrintSupport XmlPatterns) find_package(Qt5 REQUIRED COMPONENTS Core Gui Widgets Concurrent Network PrintSupport XmlPatterns)
# TODO: use system provided libraries to build # qscint
# current status: some header can not be found,for example: Scintilla.h
find_library(QSCINTILLA_LIB_PATH qscintilla2_qt5)
find_path(QSCINTILLA_INC_PATH qsciscintilla.h PATHS /usr/include/)
find_path(SCINTILLA_INC_PATH Scintilla.h PATHS /usr/include/)
if((${QSCINTILLA_LIB_PATH} STREQUAL "QSCINTILLA_LIB_PATH-NOTFOUND") OR
(${QSCINTILLA_INC_PATH} STREQUAL "QSCINTILLA_INC_PATH-NOTFOUND") OR
(${SCINTILLA_INC_PATH} STREQUAL "SCINTILLA_INC_PATH-NOTFOUND") )
set(NOTEPAD_USE_SYS_LIB OFF)
message("system libraries or header not found,build from local")
add_subdirectory(${PROJECT_SOURCE_DIR}/src/qscint) add_subdirectory(${PROJECT_SOURCE_DIR}/src/qscint)
else()
set(NOTEPAD_USE_SYS_LIB ON) #
message("use system libraries") # helloworld
message("QSCINTILLA_LIB_PATH:" ${QSCINTILLA_LIB_PATH}) add_subdirectory(${PROJECT_SOURCE_DIR}/src/plugin/helloworld)
message("QSCINTILLA_INC_PATH:" ${QSCINTILLA_INC_PATH})
message("SCINTILLA_INC_PATH:" ${SCINTILLA_INC_PATH}) # winUNICODETCHAR
if(CMAKE_HOST_WIN32)
add_definitions(-D_UNICODE -DUNICODE)
endif() endif()
if(${PLUGIN_EN})
if(${PLUGIN_EN} STREQUAL on)
add_definitions(-DNO_PLUGIN=1)
endif(${PLUGIN_EN})
endif()
file(GLOB UI_SRC ${PROJECT_SOURCE_DIR}/src/*.ui) file(GLOB UI_SRC ${PROJECT_SOURCE_DIR}/src/*.ui)
set(UI_SRC ${UI_SRC} ${PROJECT_SOURCE_DIR}/src/cceditor/ccnotepad.ui) set(UI_SRC ${UI_SRC} ${PROJECT_SOURCE_DIR}/src/cceditor/ccnotepad.ui)
aux_source_directory(${PROJECT_SOURCE_DIR}/src SRC) aux_source_directory(${PROJECT_SOURCE_DIR}/src SRC)
aux_source_directory(${PROJECT_SOURCE_DIR}/src/cceditor SRC) aux_source_directory(${PROJECT_SOURCE_DIR}/src/cceditor SRC)
add_executable(${PROJECT_NAME} ${SRC} ${UI_SRC} ${PROJECT_SOURCE_DIR}/src/RealCompare.qrc)
target_include_directories(${PROJECT_NAME} PRIVATE
${PROJECT_SOURCE_DIR}/src
${PROJECT_SOURCE_DIR}/src/cceditor
)
if(NOTEPAD_USE_SYS_LIB) if(CMAKE_HOST_WIN32)
target_include_directories(${PROJECT_NAME} PRIVATE ${QSCINTILLA_INC_PATH} ${SCINTILLA_INC_PATH}) # WIN32
list(APPEND WIN_RCS ${PROJECT_SOURCE_DIR}/src/RealCompareToMinGw.rc)
add_executable(${PROJECT_NAME} WIN32 ${WIN_RCS} ${SRC} ${UI_SRC} ${PROJECT_SOURCE_DIR}/src/RealCompare.qrc)
else()
add_executable(${PROJECT_NAME} ${SRC} ${UI_SRC} ${PROJECT_SOURCE_DIR}/src/RealCompare.qrc)
endif() endif()
target_link_libraries(${PROJECT_NAME} qscintilla2_qt5 Qt5::Core Qt5::Gui Qt5::Widgets Qt5::Concurrent Qt5::Network Qt5::PrintSupport Qt5::XmlPatterns) target_include_directories(${PROJECT_NAME} PRIVATE
${PROJECT_SOURCE_DIR}/src
${PROJECT_SOURCE_DIR}/src/cceditor
install( ${PROJECT_SOURCE_DIR}/src/qscint/src
TARGETS ${PROJECT_NAME} ${PROJECT_SOURCE_DIR}/src/qscint/src/Qsci
DESTINATION "bin" ${PROJECT_SOURCE_DIR}/src/qscint/scintilla/src
${PROJECT_SOURCE_DIR}/src/qscint/scintilla/include
${PROJECT_SOURCE_DIR}/src/qscint/scintilla/lexlib
${PROJECT_SOURCE_DIR}/src/qscint/scintilla/boostregex
) )
install(DIRECTORY ${PROJECT_SOURCE_DIR}/src/linux/usr target_link_libraries(${PROJECT_NAME} qscint Qt5::Core Qt5::Gui Qt5::Widgets Qt5::Concurrent Qt5::Network Qt5::PrintSupport Qt5::XmlPatterns)
DESTINATION "/")
include(${PROJECT_SOURCE_DIR}/cmake/package_config.cmake) # set(PROJECT_BINARY_DIR "${PROJECT_BINARY_DIR}/bin")
include(CPack) # set(EXECUTABLE_OUTPUT_PATH ${PROJECT_BINARY_DIR}/bin)
if(CMAKE_HOST_UNIX)
install(
TARGETS ${PROJECT_NAME}
DESTINATION "bin"
)
install(DIRECTORY ${PROJECT_SOURCE_DIR}/src/linux/usr
DESTINATION "/")
include(${PROJECT_SOURCE_DIR}/cmake/deb_package_config.cmake)
include(CPack)
elseif(CMAKE_HOST_WIN32)
install(TARGETS ${PROJECT_NAME}
DESTINATION "/")
install(DIRECTORY ${PROJECT_SOURCE_DIR}/build/bin/
DESTINATION "/")
#
set(CPACK_PACKAGE_NAME "NotePad--")
set(CPACK_PACKAGE_DESCRIPTION "NotePad--")
set(CPACK_PACKAGE_COPYRIGHT "Copyright (c) 2023")
set(CPACK_PACKAGE_VERSION "1.22.0")
set(CPACK_PACKAGE_VERSION_MAJOR "1")
set(CPACK_PACKAGE_VERSION_MINOR "22")
set(CPACK_PACKAGE_VERSION_PATCH "0")
include(${PROJECT_SOURCE_DIR}/cmake/nsis_package_config.cmake)
include(CPack)
endif()

17
Makefile Normal file
View File

@ -0,0 +1,17 @@
UNAME:=WIN32
UNAME:=$(shell uname)
# Win下使用Git Bash运行make
ifeq ($(UNAME), Linux)
all:linux
linux:
make -f linux.mk package
else
all:
make -f win.mk all
msvc:
make -f win.mk msvc
mingw:
make -f win.mk mingw
endif

View File

@ -0,0 +1,59 @@
set(CPACK_GENERATOR NSIS)
set(CPACK_PACKAGE_DESCRIPTION_SUMMARY "${PROJECT_NAME}")
#
set(CPACK_PACKAGE_CONTACT "XiaoPb")
set(P4_VERSION_INFO_CL_HIGH "0")
set(P4_VERSION_INFO_CL_LOW "0")
# set(CPACK_PACKAGE_VERSION_PATCH "0")
set (CPACK_PACKAGE_INSTALL_DIRECTORY "${CPACK_PACKAGE_NAME}")
set(CPACK_NSIS_DISPLAY_NAME "${CPACK_PACKAGE_NAME}V${CPACK_PACKAGE_VERSION_MAJOR}.${CPACK_PACKAGE_VERSION_MINOR}.${CPACK_PACKAGE_VERSION_PATCH}")
set(CPACK_NSIS_PACKAGE_NAME "${CPACK_PACKAGE_NAME}V${CPACK_PACKAGE_VERSION_MAJOR}.${CPACK_PACKAGE_VERSION_MINOR}.${CPACK_PACKAGE_VERSION_PATCH}")
set(CPACK_NSIS_ENABLE_UNINSTALL_BEFORE_INSTALL "ON")
set(CPACK_NSIS_MUI_ICON "${CMAKE_CURRENT_SOURCE_DIR}/src/Resources/ico/txt (9).ico")
set(CPACK_NSIS_MUI_UNIICON "${CMAKE_CURRENT_SOURCE_DIR}/src/Resources/ico/txt (9).ico")
set(CPACK_RESOURCE_FILE_LICENSE "${CMAKE_CURRENT_SOURCE_DIR}/License")
set (CPACK_PACKAGE_EXECUTABLES "${PROJECT_NAME}" "${PROJECT_NAME}" )
#
set (CPACK_NSIS_DEFINES "
${CPACK_NSIS_DEFINES}
VIProductVersion ${CPACK_PACKAGE_VERSION_MAJOR}.${CPACK_PACKAGE_VERSION_MINOR}.${P4_VERSION_INFO_CL_HIGH}.${P4_VERSION_INFO_CL_LOW}
VIFileVersion ${CPACK_PACKAGE_VERSION_MAJOR}.${CPACK_PACKAGE_VERSION_MINOR}.${P4_VERSION_INFO_CL_HIGH}.${P4_VERSION_INFO_CL_LOW}
VIAddVersionKey /LANG=0 \\\"ProductName\\\" \\\"${CPACK_PACKAGE_NAME}\\\"
VIAddVersionKey /LANG=0 \\\"ProductVersion\\\" \\\"v${CPACK_PACKAGE_VERSION_MAJOR}.${CPACK_PACKAGE_VERSION_MINOR}.${CPACK_PACKAGE_VERSION_PATCH}${CPACK_PACKAGE_BUILD_TYPE_REVISION}\\\"
VIAddVersionKey /LANG=0 \\\"Comments\\\" \\\"${CPACK_PACKAGE_DESCRIPTION}\\\"
VIAddVersionKey /LANG=0 \\\"CompanyName\\\" \\\"${CPACK_PACKAGE_VENDOR}\\\"
VIAddVersionKey /LANG=0 \\\"LegalCopyright\\\" \\\"${CPACK_PACKAGE_COPYRIGHT}\\\"
VIAddVersionKey /LANG=0 \\\"FileDescription\\\" \\\"${CPACK_PACKAGE_NAME} Installer\\\"
VIAddVersionKey /LANG=0 \\\"FileVersion\\\" \\\"v${CPACK_PACKAGE_VERSION_MAJOR}.${CPACK_PACKAGE_VERSION_MINOR}.${CPACK_PACKAGE_VERSION_PATCH}${CPACK_PACKAGE_BUILD_TYPE_REVISION}\\\"
"
)
#
set (CPACK_NSIS_EXTRA_INSTALL_COMMANDS "
WriteRegStr SHCTX \\\"Software\\\\Microsoft\\\\Windows\\\\CurrentVersion\\\\App Paths\\\\${PROJECT_NAME}\\\" \\\"\\\" \\\"$INSTDIR\\\\bin\\\\${PROJECT_NAME}.exe\\\"
WriteRegStr SHCTX \\\"Software\\\\Classes\\\\${PROJECT_NAME}\\\\shell\\\" \\\"\\\" \\\"open\\\"
WriteRegStr SHCTX \\\"Software\\\\Classes\\\\${PROJECT_NAME}\\\\shell\\\\open\\\\command\\\" \\\"\\\" \\\"$\\\\\\\"$INSTDIR\\\\bin\\\\${PROJECT_NAME}.exe$\\\\\\\" $\\\\\\\"%1$\\\\\\\"\\\"
WriteRegStr SHCTX \\\"Software\\\\Classes\\\\.txt\\\\OpenWithProgids\\\" \\\"${PROJECT_NAME}\\\" \\\"\\\"
WriteRegStr SHCTX \\\"Software\\\\Classes\\\\*\\\\shell\\\\${PROJECT_NAME}\\\" \\\"\\\" \\\"Edit with ${PROJECT_NAME}\\\"
WriteRegStr SHCTX \\\"Software\\\\Classes\\\\*\\\\shell\\\\${PROJECT_NAME}\\\" \\\"Icon\\\" \\\"$INSTDIR\\\\bin\\\\${PROJECT_NAME}.exe\\\"
WriteRegStr SHCTX \\\"Software\\\\Classes\\\\*\\\\shell\\\\${PROJECT_NAME}\\\\command\\\" \\\"\\\" \\\"$\\\\\\\"$INSTDIR\\\\bin\\\\${PROJECT_NAME}.exe$\\\\\\\" $\\\\\\\"%1$\\\\\\\"\\\"
")
#
set (CPACK_NSIS_EXTRA_UNINSTALL_COMMANDS "
Delete \\\"$DESKTOP\\\\${PROJECT_NAME}.lnk\\\"
Delete \\\"$SMPROGRAMS\\\\${PROJECT_NAME}.lnk\\\"
DeleteRegKey SHCTX \\\"Software\\\\Classes\\\\*\\\\shell\\\\${PROJECT_NAME}\\\"
DeleteRegKey SHCTX \\\"Software\\\\Microsoft\\\\Windows\\\\CurrentVersion\\\\App Paths\\\\bin\\\\${PROJECT_NAME}.exe\\\" \\\"\\\" \\\"$INSTDIR\\\\bin\\\\${PROJECT_NAME}.exe\\\"
DeleteRegKey SHCTX \\\"Software\\\\${PROJECT_NAME}\\\"
DeleteRegValue SHCTX \\\"Software\\\\Classes\\\\.txt\\\\OpenWithProgids\\\" \\\"${PROJECT_NAME}\\\"
DeleteRegKey SHCTX \\\"Software\\\\Classes\\\\${PROJECT_NAME}\\\"
")

42
linux.mk Normal file
View File

@ -0,0 +1,42 @@
CPUS=$(shell nproc)
CALENDAR=$(shell date '+%Y%m%d')
OSID=$(shell lsb_release -si)
OSRELEASE=$(shell lsb_release -sr)
SUFFIX=
ifneq ("$(OSID)", "")
SUFFIX=_$(OSID)$(OSRELEASE)
endif
PROJECT_NAME=notepad--
PACKAGE_NAME=com.hmja.notepad
all:
mkdir -p build
cd build && cmake ..
cd build && make -j$(CPUS)
run: all
exec $(shell find build/ -maxdepth 1 -type f -executable | grep $(PROJECT_NAME))
debug:
mkdir -p build
cd build && cmake -DCMAKE_BUILD_TYPE=Debug ..
cd build && make -j$(CPUS)
release:
mkdir -p build
cd build && cmake -DCMAKE_BUILD_TYPE=Release -DPLUGIN_EN=off -DPACKAGE_SUFFIX="$(SUFFIX)" ..
cd build && make -j$(CPUS)
package: release
cd build && make package
tree build/_CPack_Packages/Linux/DEB/$(PROJECT_NAME)-*
# dpkg-deb --contents build/$(PROJECT_NAME)$(SUFFIX).deb
builddeps:
cd build && make builddeps
cpus:
@echo "CPU数量: $(CPUS)"

Binary file not shown.

38
src/RealCompareToMinGw.rc Normal file
View File

@ -0,0 +1,38 @@
#include <windows.h>
IDI_ICON1 ICON DISCARDABLE ".\\Resources\\edit\\global\\ndd.ico"
LANGUAGE LANG_CHINESE, SUBLANG_CHINESE_SIMPLIFIED
VS_VERSION_INFO VERSIONINFO
FILEVERSION 1,22,0,0
PRODUCTVERSION 1,22,0,0
FILEFLAGSMASK 0x3fL
#ifdef _DEBUG
FILEFLAGS VS_FF_DEBUG
#else
FILEFLAGS 0x0L
#endif
FILEOS VOS__WINDOWS32
FILETYPE VFT_DLL
FILESUBTYPE 0x0L
BEGIN
BLOCK "StringFileInfo"
BEGIN
BLOCK "080404b0"
BEGIN
VALUE "FileDescription", "notepad-- v1.22.0\0"
VALUE "FileVersion", "1.22.0.0\0"
VALUE "LegalCopyright", "Copyright (C) 2020-2023\0"
VALUE "OriginalFilename", "Notepad--.exe\0"
VALUE "ProductName", "notepad-- \0"
VALUE "ProductVersion", "1.22.0.0\0"
END
END
BLOCK "VarFileInfo"
BEGIN
VALUE "Translation", 0x0804, 1200
END
END
/* End of Version info */

View File

@ -216,13 +216,13 @@ void ColumnEdit::slot_ok()
{ {
QByteArray s_space(cursorCol - lineEndCol, ' '); QByteArray s_space(cursorCol - lineEndCol, ' ');
lineData.append(s_space); lineData.append(s_space);
lineData.append(text); lineData.append(text.toUtf8());
} }
else else
{ {
int posAbs2Start = pEdit->execute(SCI_FINDCOLUMN, i, cursorCol); int posAbs2Start = pEdit->execute(SCI_FINDCOLUMN, i, cursorCol);
int posRelative2Start = posAbs2Start - lineBegin; int posRelative2Start = posAbs2Start - lineBegin;
lineData.insert(posRelative2Start, text); lineData.insert(posRelative2Start, text.toUtf8());
} }
pEdit->SendScintilla(SCI_SETTARGETRANGE, lineBegin, lineEnd); pEdit->SendScintilla(SCI_SETTARGETRANGE, lineBegin, lineEnd);

View File

@ -9,7 +9,7 @@ CTipWin::CTipWin(QWidget *parent)
this->setWindowFlags(Qt::ToolTip); this->setWindowFlags(Qt::ToolTip);
QPalette palette(this->palette()); QPalette palette(this->palette());
palette.setColor(QPalette::Background, QColor(0xfff29d)); palette.setColor(QPalette::Window, QColor(0xfff29d));
this->setPalette(palette); this->setPalette(palette);
} }

View File

@ -4,11 +4,13 @@
#define NDD_EXPORTDLL #define NDD_EXPORTDLL
#if defined(Q_OS_WIN) #if defined(Q_OS_WIN)
#if defined(NDD_EXPORTDLL) #if defined(NDD_EXPORTDLL)
#define NDD_EXPORT __declspec(dllexport) #define NDD_EXPORT __declspec(dllexport)
#else
#define NDD_EXPORT __declspec(dllimport)
#endif
#else #else
#define NDD_EXPORT __declspec(dllimport) #define NDD_EXPORT __attribute__((visibility("default")))
#endif
#endif #endif
struct ndd_proc_data struct ndd_proc_data

View File

@ -0,0 +1,42 @@
cmake_minimum_required(VERSION 3.16)
project(helloworld)
set(CMAKE_AUTOMOC ON)
set(CMAKE_AUTOUIC ON)
set(CMAKE_AUTORCC ON)
find_package(Qt5 REQUIRED COMPONENTS Core Gui Widgets Concurrent Network PrintSupport XmlPatterns)
add_definitions(-D_UNICODE -DUNICODE)
file(GLOB UI_SRC ${PROJECT_SOURCE_DIR}/*.ui)
file(GLOB SRC ${PROJECT_SOURCE_DIR}/*.cpp)
file(GLOB MOC_HEADER ${PROJECT_SOURCE_DIR}/*.h)
# add_executable(${PROJECT_NAME} ${IS_WIN} ${SRC} ${UI_SRC} ${PROJECT_SOURCE_DIR}/src/RealCompare.qrc)
add_library(${PROJECT_NAME} SHARED ${SRC} ${UI_SRC} ${MOC_HEADER})
target_include_directories(${PROJECT_NAME} PRIVATE
${PROJECT_SOURCE_DIR}
${PROJECT_SOURCE_DIR}/../../include
${PROJECT_SOURCE_DIR}/../../qscint/src
${PROJECT_SOURCE_DIR}/../../qscint/src/Qsci
${PROJECT_SOURCE_DIR}/../../qscint/scintilla/src
${PROJECT_SOURCE_DIR}/../../qscint/scintilla/include
${PROJECT_SOURCE_DIR}/../../qscint/scintilla/lexlib
${PROJECT_SOURCE_DIR}/../../qscint/scintilla/boostregex
)
target_link_libraries(${PROJECT_NAME} qscint Qt5::Core Qt5::Gui Qt5::Widgets Qt5::Concurrent Qt5::Network Qt5::PrintSupport Qt5::XmlPatterns)
# if(NOT DEFINED ${notepad--_BINARY_DIR})
# set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY ${notepad--_BINARY_DIR}/bin/plugin)
# set(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${notepad--_BINARY_DIR}/bin/plugin)
# set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${notepad--_BINARY_DIR}/bin/plugin)
# set(LIBRARY_OUTPUT_PATH ${notepad--_BINARY_DIR}/bin/plugin)
# set_target_properties(${PROJECT_NAME} PROPERTIES RUNTIME_OUTPUT_DIRECTORY ${notepad--_BINARY_DIR}/bin/plugin)
# endif()

View File

@ -8,11 +8,13 @@
#define NDD_EXPORTDLL #define NDD_EXPORTDLL
#if defined(Q_OS_WIN) #if defined(Q_OS_WIN)
#if defined(NDD_EXPORTDLL) #if defined(NDD_EXPORTDLL)
#define NDD_EXPORT __declspec(dllexport) #define NDD_EXPORT __declspec(dllexport)
#else
#define NDD_EXPORT __declspec(dllimport)
#endif
#else #else
#define NDD_EXPORT __declspec(dllimport) #define NDD_EXPORT __attribute__((visibility("default")))
#endif
#endif #endif
#ifdef __cplusplus #ifdef __cplusplus

View File

@ -7,11 +7,13 @@
#define NDD_EXPORTDLL #define NDD_EXPORTDLL
#if defined(Q_OS_WIN) #if defined(Q_OS_WIN)
#if defined(NDD_EXPORTDLL) #if defined(NDD_EXPORTDLL)
#define NDD_EXPORT __declspec(dllexport) #define NDD_EXPORT __declspec(dllexport)
#else
#define NDD_EXPORT __declspec(dllimport)
#endif
#else #else
#define NDD_EXPORT __declspec(dllimport) #define NDD_EXPORT __attribute__((visibility("default")))
#endif
#endif #endif
#ifdef __cplusplus #ifdef __cplusplus

View File

@ -1,5 +1,5 @@
cmake_minimum_required(VERSION 3.16) cmake_minimum_required(VERSION 3.16)
project(qscintilla2_qt5 CXX) project(qscint CXX)
set(CMAKE_AUTOMOC ON) set(CMAKE_AUTOMOC ON)
set(CMAKE_AUTOUIC ON) set(CMAKE_AUTOUIC ON)
@ -19,6 +19,9 @@ file(GLOB MOC_HEADER ${PROJECT_SOURCE_DIR}/src/Qsci/*.h)
add_library(${PROJECT_NAME} STATIC ${SRC} ${MOC_HEADER}) add_library(${PROJECT_NAME} STATIC ${SRC} ${MOC_HEADER})
# add_definitions(-DQSCINTILLA_MAKE_DLL)
# add_library(${PROJECT_NAME} SHARED ${SRC} ${MOC_HEADER})
target_compile_definitions(${PROJECT_NAME} PRIVATE SCINTILLA_QT SCI_LEXER INCLUDE_DEPRECATED_FEATURES) target_compile_definitions(${PROJECT_NAME} PRIVATE SCINTILLA_QT SCI_LEXER INCLUDE_DEPRECATED_FEATURES)
target_include_directories(${PROJECT_NAME} PRIVATE target_include_directories(${PROJECT_NAME} PRIVATE
@ -28,8 +31,24 @@ ${PROJECT_SOURCE_DIR}/scintilla/boostregex
target_include_directories(${PROJECT_NAME} PUBLIC target_include_directories(${PROJECT_NAME} PUBLIC
${PROJECT_SOURCE_DIR}/src ${PROJECT_SOURCE_DIR}/src
${PROJECT_SOURCE_DIR}/src/Qsci ${PROJECT_SOURCE_DIR}/src/Qsci
${PROJECT_SOURCE_DIR}/scintilla/src ${PROJECT_SOURCE_DIR}/scintilla/src
${PROJECT_SOURCE_DIR}/scintilla/include) ${PROJECT_SOURCE_DIR}/scintilla/include)
target_link_libraries(${PROJECT_NAME} Qt5::Core Qt5::Gui Qt5::Widgets Qt5::Concurrent Qt5::Network Qt5::PrintSupport) target_link_libraries(${PROJECT_NAME} Qt5::Core Qt5::Gui Qt5::Widgets Qt5::Concurrent Qt5::Network Qt5::PrintSupport)
if(${CMAKE_BUILD_TYPE} STREQUAL "Release")
set_target_properties(${PROJECT_NAME} PROPERTIES OUTPUT_NAME "qmyedit_qt5")
else()
set_target_properties(${PROJECT_NAME} PROPERTIES OUTPUT_NAME "qmyedit_qt5d")
endif()
# if(NOT DEFINED ${notepad--_BINARY_DIR})
# set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY ${notepad--_BINARY_DIR}/bin/plugin)
# set(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${notepad--_BINARY_DIR}/bin/plugin)
# set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${notepad--_BINARY_DIR}/bin/plugin)
# set(LIBRARY_OUTPUT_PATH ${notepad--_BINARY_DIR}/bin/plugin)
# set_target_properties(${PROJECT_NAME} PROPERTIES RUNTIME_OUTPUT_DIRECTORY ${notepad--_BINARY_DIR}/bin/plugin)
# endif()

5
win.bat Normal file
View File

@ -0,0 +1,5 @@
cd build/bin
windeployqt notepad--.exe
@REM copy .\src\qscint\libqscint.a .\%1\plugin
@REM copy .\src\plugin\^*\^*.dll .\%1\plugin

42
win.mk Normal file
View File

@ -0,0 +1,42 @@
# 基于 Git Bash 环境编写
# 设置编译链信息是为了避免环境存在多个Qt环境时编译异常
# 填入Qt的Mingw相关工具安装路径 不使用MINGW时可不填
# 填入Mingw Qt G++程序完整路径
Qt_MINGW_CXX_COMPILER:=d:/SOFT/Qt/Qt5.14.2/Tools/mingw730_64/bin/g++.exe
# 填入Mingw Qt GCC程序完整路径
Qt_MINGW_C_COMPILER:=d:/SOFT/Qt/Qt5.14.2/Tools/mingw730_64/bin/gcc.exe
# 填入Mingw Qt库查找路径
Qt_MINGW_PREFIX_PATH:=d:/SOFT/Qt/Qt5.14.2/5.14.2/mingw73_64
# 指定生成的Makefiles格式
Qt_MINGW_G:=CodeBlocks - MinGW Makefiles
# 填入Qt的msvc相关工具安装路径 不使用MSVC时可不填
# 填入Msvc Qt库查找路径
Qt_MSVC_PREFIX_PATH:=d:/CompilationTools/Qt/5.15.2/msvc2019_64
all:msvc
mingw:
cmake -G"${Qt_MINGW_G}" -Bbuild -DCMAKE_BUILD_TYPE=Release -DPLUGIN_EN=on -DCMAKE_PREFIX_PATH=${Qt_MINGW_PREFIX_PATH} -DCMAKE_CXX_COMPILER=${Qt_MINGW_CXX_COMPILER} -DCMAKE_C_COMPILER=${Qt_MINGW_C_COMPILER} .
cmake --build ./build --config=Release -- -j$$(nproc)
mkdir -p build/bin/plugin
cp -f build/NotePad--.exe build/bin/
cd build/bin && windeployqt --qmldir=${Qt_MINGW_PREFIX_PATH}/qml NotePad--.exe
cp -r -f build/src/*/*/*.dll build/bin/plugin
cp -r -f build/src/*/*.a build/bin/plugin
cd build && cpack --config CPackConfig.cmake
msvc:
cmake -Bbuild -DCMAKE_BUILD_TYPE=Release -DPLUGIN_EN=on -DCMAKE_PREFIX_PATH=${Qt_MSVC_PREFIX_PATH} .
cmake --build ./build --config=Release -j$$(nproc)
mkdir -p build/bin/plugin
cp -f build/Release/NotePad--.exe build/bin/
cd build/bin && windeployqt --qmldir=${Qt_MSVC_PREFIX_PATH}/qml NotePad--.exe
cp -r -f build/src/*/*/Release/*.dll build/bin/plugin
cp -r -f build/src/*/Release/*.lib build/bin/plugin
cd build && cpack --config CPackConfig.cmake