Skip to content

Commit

Permalink
Add CMake
Browse files Browse the repository at this point in the history
  • Loading branch information
KangLin committed Aug 7, 2023
1 parent 1ca1c26 commit cd101db
Show file tree
Hide file tree
Showing 61 changed files with 18,410 additions and 357 deletions.
56 changes: 29 additions & 27 deletions .github/workflows/android.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,8 @@ jobs:
strategy:
matrix:
BUILD_TYPE: [Release]
qt_arch: [android_arm64_v8a, android_armv7, android_x86_64]
qt_version: [5.12.12]
qt_arch: [android_arm64_v8a, android_armv7, android_x86_64, android_x86]
qt_version: [6.6.0]
include:
- BUILD_TYPE: Release
qt_arch: android_arm64_v8a
Expand All @@ -27,18 +27,22 @@ jobs:
qt_arch: android_x86_64
VCPKG_TARGET_TRIPLET: x64-android

- BUILD_TYPE: Release
qt_arch: android_x86
VCPKG_TARGET_TRIPLET: x32-android

runs-on: ubuntu-latest

env:
artifact_name: build_android
SOURCE_DIR: ${{github.workspace}}/.cache/source
TOOSL_DIR: ${{github.workspace}}/.cache/tools
INSTALL_DIR: ${{github.workspace}}/.cache/install_${{matrix.BUILD_TYPE}}_${{matrix.qt_arch}}
SerialPortAssistant_VERSION: v0.5.14
VCPKGGITCOMMITID: 1286cac8751e13bb289061b7e3b89eb4c3f613a2
SerialPortAssistant_VERSION: v0.5.15
VCPKGGITCOMMITID: 2f6176ce98fee807a207dc9e8fec213f111c291b
ANDROID_PLATFORM: android-23
ANDROID_NATIVE_API_LEVEL: 23
qt_modules: qtwebengine
qt_modules: qtscxml qtserialport qtwebview

# Map the job outputs to step outputs
outputs:
Expand Down Expand Up @@ -103,6 +107,7 @@ jobs:
cached: '${{ steps.cache-qt.outputs.cache-hit }}' # optional, default is false

- name: run-vcpkg
if: false
uses: lukka/[email protected]
with:
# Indicates whether to only setup vcpkg (i.e. installing it and setting the environment variables VCPKG_ROOT, RUNVCPK_VCPKG_ROOT), without installing any port.
Expand All @@ -121,19 +126,30 @@ jobs:
working-directory: ${{env.SOURCE_DIR}}
run: |
git clone https://github.com/KangLin/RabbitCommon.git
- name: build SerialPortAssistant
working-directory: ${{github.workspace}}/build
env:
RabbitCommon_DIR: ${{env.SOURCE_DIR}}/RabbitCommon
QT_ROOT: ${{env.Qt5_DIR}}
run: |
${QT_ROOT}/bin/qmake ${{github.workspace}} \
"CONFIG+=${{matrix.BUILD_TYPE}}"
make
make install INSTALL_ROOT=`pwd`/android-build
sudo chmod 777 ${Qt6_DIR}/bin/qt-cmake
${Qt6_DIR}/bin/qt-cmake .. \
-DCMARK_SHARED=OFF \
-DCMARK_TESTS=OFF \
-DCMARK_STATIC=ON \
-DCMAKE_BUILD_TYPE=${{matrix.BUILD_TYPE}} \
-DQT_HOST_PATH=${Qt6_DIR}/../gcc_64 \
-DANDROID_PLATFORM=${{env.ANDROID_PLATFORM}} \
-DANDROID_NATIVE_API_LEVEL=${{env.ANDROID_NATIVE_API_LEVEL}} \
-DQt6LinguistTools_DIR=${Qt6_DIR}/../gcc_64/lib/cmake/Qt6LinguistTools \
-DCMAKE_INSTALL_PREFIX=`pwd`/install
cmake --build . --config ${{matrix.BUILD_TYPE}} --target all
APK_FILE=`find . -name "android-*.apk"`
cp $APK_FILE SerialPortAssistant_${{env.SerialPortAssistant_VERSION}}_${{matrix.qt_arch}}_qt${{matrix.qt_version}}_${{matrix.BUILD_TYPE}}.apk
- name: Package
if: ${{matrix.BUILD_TYPE == 'Release'}}
if: false
env:
QT_ROOT: ${{env.Qt5_DIR}}
RabbitCommon_DIR: ${{env.SOURCE_DIR}}/RabbitCommon
Expand Down Expand Up @@ -165,20 +181,6 @@ jobs:
if: ${{ matrix.BUILD_TYPE == 'Release' }}
uses: actions/upload-artifact@v2
with:
name: SerialPortAssistant_${{matrix.ANDROID_ABI}}_${{env.SerialPortAssistant_VERSION}}.apk
name: ${{ env.artifact_name }}
path: |
${{github.workspace}}/SerialPortAssistant_${{matrix.ANDROID_ABI}}_${{env.SerialPortAssistant_VERSION}}.apk
${{github.workspace}}/update_android_${{matrix.ANDROID_ABI}}.xml
- name: Upload To Github Release
if: ${{ matrix.BUILD_TYPE == 'Release' && startsWith(github.ref, 'refs/tags/') }}
uses: softprops/action-gh-release@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
prerelease: true
body: |
[:cn: 修改日志](ChangeLog_zh_CN.md) [:us: Change log](ChangeLog.md)
files: |
${{github.workspace}}/SerialPortAssistant_${{matrix.ANDROID_ABI}}_${{env.SerialPortAssistant_VERSION}}.apk
${{github.workspace}}/update_android_${{matrix.ANDROID_ABI}}.xml
${{github.workspace}}/build/SerialPortAssistant_${{env.SerialPortAssistant_VERSION}}_${{matrix.qt_arch}}_qt${{matrix.qt_version}}_${{matrix.BUILD_TYPE}}.apk
19 changes: 13 additions & 6 deletions .github/workflows/macos.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,13 +16,14 @@ jobs:
matrix:
# Customize the CMake build type here (Release, Debug, RelWithDebInfo, etc.)
BUILD_TYPE: [Release, Debug]
qt_version: [6.5.0, 5.15.2, 5.12.12]
qt_version: [6.5.2, 5.15.2, 5.12.12]
include:
- qt_version: 6.5.0
- qt_version: 6.5.2
qt_modules: qtscxml qtserialport webchannel positioning macextras

- qt_version: 5.15.2
qt_modules: ""

- qt_version: 5.12.12
qt_modules: ""

Expand All @@ -36,7 +37,7 @@ jobs:
qt_modules: qtwebengine ${{matrix.qt_modules}}
SerialPortAssistant_VERSION: v1.0.9
artifact_name: build_macos
VCPKGGITCOMMITID: 1286cac8751e13bb289061b7e3b89eb4c3f613a2
VCPKGGITCOMMITID: 2f6176ce98fee807a207dc9e8fec213f111c291b

# Map the job outputs to step outputs
outputs:
Expand Down Expand Up @@ -83,7 +84,7 @@ jobs:
uses: actions/cache@v1 # not v2!
with:
path: ${{env.TOOSL_DIR}}/qt
key: qt${{matrix.qt_version}}-${{matrix.qt_arch}}
key: qt${{matrix.qt_version}}_macos

- name: Install Qt
# You may pin to the exact commit or the version.
Expand All @@ -107,8 +108,14 @@ jobs:
RabbitCommon_DIR: ${{env.SOURCE_DIR}}/RabbitCommon
PKG_CONFIG_PATH: ${{env.INSTALL_DIR}}/lib/pkgconfig
run: |
qmake ${{github.workspace}}/SerialPortAssistant.pro CONFIG*=${{matrix.BUILD_TYPE}} RabbitCommon_DIR=${{env.RabbitCommon_DIR}} prefix=${{github.workspace}}/build/install
make install -j$(sysctl -n hw.ncpu)
cmake ${{github.workspace}} \
-DCMARK_SHARED=OFF \
-DCMARK_TESTS=OFF \
-DCMARK_STATIC=ON \
-DCMAKE_BUILD_TYPE=${{ matrix.BUILD_TYPE }} \
-DCMAKE_INSTALL_PREFIX=${{ github.workspace }}/build/install \
-DCMAKE_PREFIX_PATH=${{env.INSTALL_DIR}}/lib/cmake
cmake --build . --config ${{ matrix.BUILD_TYPE }} --target install
7z a SerialPortAssistant_${{env.SerialPortAssistant_VERSION}}_macos.zip install/.
- name: Update artifact
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/mingw.yml
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ jobs:
SOURCE_DIR: ${{github.workspace}}\.cache\source
TOOSL_DIR: ${{github.workspace}}\.cache\tools
INSTALL_DIR: ${{github.workspace}}\.cache\install_mingw
SerialPortAssistant_VERSION: v0.5.14
SerialPortAssistant_VERSION: v0.5.15
artifact_name: build_mingw

# Map the job outputs to step outputs
Expand Down
57 changes: 42 additions & 15 deletions .github/workflows/msvc.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,9 @@ jobs:
strategy:
matrix:
BUILD_TYPE: [Release, Debug]
qt_version: [6.5.1, 5.15.2, 5.12.12]
qt_version: [6.5.2, 5.15.2, 5.12.12]
include:
- qt_version: 6.5.1
- qt_version: 6.5.2
triplet: x64-windows
VCPKG_PLATFORM_TOOLSET: v142
qt_arch: win64_msvc2019_64
Expand Down Expand Up @@ -42,8 +42,8 @@ jobs:
CMAKE_GENERATOR: "Visual Studio 17 2022"
VCPKG_PLATFORM_TOOLSET: ${{matrix.VCPKG_PLATFORM_TOOLSET}}
CMAKE_GENERATOR_PLATFORM: ${{matrix.CMAKE_GENERATOR_PLATFORM}}
SerialPortAssistant_VERSION: v0.5.14
VCPKGGITCOMMITID: 1286cac8751e13bb289061b7e3b89eb4c3f613a2
SerialPortAssistant_VERSION: v0.5.15
VCPKGGITCOMMITID: 2f6176ce98fee807a207dc9e8fec213f111c291b
qt_modules: qtwebengine ${{matrix.qt_modules}}
artifact_name: build_msvc

Expand Down Expand Up @@ -144,31 +144,58 @@ jobs:
# arch: ${{ matrix.CMAKE_GENERATOR_PLATFORM }}
# vsversion: ${{ matrix.vc_version }}

- name: Setup Visual Studio Tools
uses: egor-tensin/vs-shell@v2
with:
arch: ${{ matrix.CMAKE_GENERATOR_PLATFORM }}
# - name: Setup Visual Studio Tools
# uses: egor-tensin/vs-shell@v2
# with:
# arch: ${{ matrix.CMAKE_GENERATOR_PLATFORM }}

- name: Install jom
run: choco install jom
# - name: Install jom
# run: choco install jom

- name: build SerialPortAssistant
working-directory: ${{github.workspace}}/build
env:
RabbitCommon_DIR: ${{env.SOURCE_DIR}}/RabbitCommon
#Log4Qt_DIR: ${{env.INSTALL_DIR}}
run: |
qmake ${{github.workspace}}/SerialPortAssistant.pro CONFIG*=${{matrix.BUILD_TYPE}} RabbitCommon_DIR=${{env.RabbitCommon_DIR}} prefix=${{github.workspace}}/build/install
jom
jom install
cmake ${{github.workspace}} ^
-A ${{matrix.CMAKE_GENERATOR_PLATFORM}} ^
-T ${{matrix.VCPKG_PLATFORM_TOOLSET}} ^
-DCMARK_SHARED=OFF ^
-DCMARK_TESTS=OFF ^
-DCMARK_STATIC=ON ^
-DCMAKE_BUILD_TYPE=${{matrix.BUILD_TYPE}} ^
-DCMAKE_INSTALL_PREFIX=${{github.workspace}}/build/install ^
-DCMAKE_TOOLCHAIN_FILE=${{env.VCPKG_ROOT}}/scripts/buildsystems/vcpkg.cmake ^
-DVCPKG_VERBOSE=ON ^
-DX_VCPKG_APPLOCAL_DEPS_INSTALL=ON
cmake --build . --config ${{matrix.BUILD_TYPE}}
cmake --install . --config ${{matrix.BUILD_TYPE}} --component=Application
cmake --install . --config ${{matrix.BUILD_TYPE}} --component=Runtime
cmake --install . --config ${{matrix.BUILD_TYPE}} --component=DependLibraries
copy /Y ${{env.INSTALL_DIR}}\bin\*.dll install\bin
copy /Y ${{env.INSTALL_DIR}}\lib\*.dll install\bin
makensis Install.nsi
copy /Y SerialPortAssistant_Setup_${{env.SerialPortAssistant_VERSION}}.exe SerialPortAssistant_${{env.SerialPortAssistant_VERSION}}_qt${{matrix.qt_version}}_Setup.exe
- name: Update artifact
- name: XML
working-directory: ${{github.workspace}}/build
if: ${{ matrix.BUILD_TYPE == 'Release' && '6.5.2' == matrix.qt_version }}
run: |
${{github.workspace}}\build\install\bin\SerialPortAssistant.exe ^
-f "update_windows.xml" ^
-u https://github.com/KangLin/SerialPortAssistant/releases/download/${{env.SerialPortAssistant_VERSION}}/SerialPortAssistant_${{env.SerialPortAssistant_VERSION}}_qt${{matrix.qt_version}}_Setup.exe;https://sourceforge.net/projects/SerialPortAssistant/files/${{env.SerialPortAssistant_VERSION}}/SerialPortAssistant_${{env.SerialPortAssistant_VERSION}}_qt${{matrix.qt_version}}_Setup.exe ^
--pf SerialPortAssistant_${{env.SerialPortAssistant_VERSION}}_qt${{matrix.qt_version}}_Setup.exe ^
-m "${{env.SerialPortAssistant_VERSION}}"
- name: Update artifact
if: ${{ matrix.BUILD_TYPE == 'Release' }}
uses: actions/upload-artifact@v3
with:
name: ${{ env.artifact_name }}
path: |
${{github.workspace}}\build\SerialPortAssistant_Setup_${{env.SerialPortAssistant_VERSION}}.exe
${{github.workspace}}\build\SerialPortAssistant_${{env.SerialPortAssistant_VERSION}}_qt${{matrix.qt_version}}_Setup.exe
${{github.workspace}}\build\update_windows.xml
# - name: Upload To Github Release
# if: ${{ matrix.BUILD_TYPE == 'Release' && '5.12.12' == matrix.qt_version && startsWith(github.ref, 'refs/tags/') }}
Expand Down
20 changes: 4 additions & 16 deletions .github/workflows/ubuntu.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ jobs:
SOURCE_DIR: ${{github.workspace}}/.cache/source
TOOSL_DIR: ${{github.workspace}}/.cache/tools
INSTALL_DIR: ${{github.workspace}}/.cache/install_ubuntu_${{matrix.BUILD_TYPE}}
SerialPortAssistant_VERSION: 0.5.14
SerialPortAssistant_VERSION: 0.5.15
artifact_name: build_ubuntu

# Map the job outputs to step outputs
Expand Down Expand Up @@ -50,6 +50,7 @@ jobs:
libglu1-mesa-dev libpulse-mainloop-glib0 \
cmake debhelper fakeroot \
qttools5-dev qttools5-dev-tools qtbase5-dev qtbase5-dev-tools \
qtwebengine5-dev \
libqt5serialport5-dev \
libxkbcommon-dev libxkbcommon-x11-dev xorg-dev libx11-xcb-dev \
libx11-dev libxfixes-dev
Expand Down Expand Up @@ -120,18 +121,5 @@ jobs:
with:
name: ${{ env.artifact_name }}
path: |
${{github.workspace}}/build/serialportassistant_${{env.SerialPortAssistant_VERSION}}_amd64.deb
${{github.workspace}}/build/update_linux.xml
# - name: Upload To Github Release
# if: ${{ startsWith(github.ref, 'refs/tags/') }}
# uses: softprops/action-gh-release@v1
# env:
# GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
# with:
# prerelease: true
# body: |
# [:cn: 修改日志](ChangeLog_zh_CN.md) [:us: Change log](ChangeLog.md)
# files: |
# serialportassistant_${{env.SerialPortAssistant_VERSION}}_amd64.deb
# update_linux.xml
${{github.workspace}}/serialportassistant_${{env.SerialPortAssistant_VERSION}}_amd64.deb
${{github.workspace}}/update_linux.xml
2 changes: 1 addition & 1 deletion App/App.pro
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ isEmpty(SerialPortAssistant_VERSION) {
}
}
isEmpty(SerialPortAssistant_VERSION){
SerialPortAssistant_VERSION="v0.5.14"
SerialPortAssistant_VERSION="v0.5.15"
}
message("SerialPortAssistant_VERSION:$$SerialPortAssistant_VERSION")
message("SerialPortAssistant_Revision:$$SerialPortAssistant_Revision")
Expand Down
42 changes: 42 additions & 0 deletions App/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
# Author: Kang Lin <[email protected]>

project(SerialPortAssistant)

set(HEADER_FILES
MainWindow.h
Global/Global.h
Common/Tool.h
SendFile.h
${CMAKE_SOURCE_DIR}/3th_lib/Control/lightbutton.h
)
set(SOURCE_FILES
MainWindow.cpp
Main.cpp
Global/Global.cpp
Common/Tool.cpp
SendFile.cpp
${CMAKE_SOURCE_DIR}/3th_lib/Control/lightbutton.cpp
)
set(SOURCE_UI_FILES
MainWindow.ui
)
set(RESOURCE_FILES Resource/Resource.qrc)
if(WIN32)
list(APPEND RESOURCE_FILES AppIcon.rc)
endif()

ADD_TARGET(NAME ${PROJECT_NAME}
ISEXE
ISWINDOWS
SOURCE_FILES ${SOURCE_FILES} ${SOURCE_UI_FILES} ${HEADER_FILES} ${RESOURCE_FILES}
INCLUDE_DIRS
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}> # See: http://www.it1352.com/478094.html
$<BUILD_INTERFACE:${CMAKE_CURRENT_BINARY_DIR}>
$<BUILD_INTERFACE:${CMAKE_BINARY_DIR}>
$<BUILD_INTERFACE:${CMAKE_SOURCE_DIR}/3th_lib/Control>
PRIVATE_LIBS RabbitCommon ${QT_LIBRARIES}
PRIVATE_DEFINITIONS SerialPortAssistant_VERSION="${SerialPortAssistant_VERSION}"
SerialPortAssistant_REVISION="${SerialPortAssistant_REVISION}"
RABBITCOMMON
VERSION ${SerialPortAssistant_VERSION}
)
9 changes: 1 addition & 8 deletions App/Main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -33,14 +33,7 @@ int main(int argc, char *argv[])
#if defined (_DEBUG)
Q_INIT_RESOURCE(translations_SerialPortAssistant);
#endif

#if (QT_VERSION > QT_VERSION_CHECK(5,6,0))
QApplication::setAttribute(Qt::AA_EnableHighDpiScaling);
#endif
#if defined(Q_OS_ANDROID) && QT_VERSION >= QT_VERSION_CHECK(5, 7, 0) && QT_VERSION < QT_VERSION_CHECK(6, 0, 0)
QtAndroid::hideSplashScreen();
#endif


QApplication a(argc, argv);
a.setApplicationName("SerialPortAssistant");

Expand Down
6 changes: 3 additions & 3 deletions App/MainWindow.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -858,9 +858,9 @@ void CMainWindow::on_actionAbout_A_triggered()
about->m_AppIcon = QImage(":/icon/AppIcon");
about->m_szHomePage = "https://github.com/KangLin/SerialPortAssistant";
about->m_szCopyrightStartTime = "2017";
#ifdef SerialPortAssistant_Revision
about->m_szVersionRevision = SerialPortAssistant_Revision;
#endif
#ifdef SerialPortAssistant_Revision
about->m_szVersionRevision = SerialPortAssistant_Revision;
#endif
#if defined(BUILD_QUIWidget) && !defined(Q_OS_ANDROID)
QUIWidget* quiwidget = new QUIWidget(nullptr, true);
quiwidget->setMainWidget(about);
Expand Down
4 changes: 2 additions & 2 deletions App/MainWindow.h
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,8 @@ Module Name:
#define MAINWINDOW_H

#include <QMainWindow>
#include <QtSerialPort/QSerialPortInfo>
#include <QtSerialPort/QSerialPort>
#include <QSerialPortInfo>
#include <QSerialPort>
#include <QTimer>
#include <QMenu>
#include <QMap>
Expand Down
Loading

0 comments on commit cd101db

Please sign in to comment.