Skip to content

Commit 4a0bf14

Browse files
committed
Merge @tstenner cmake branch
2 parents a81bbc6 + 7021eff commit 4a0bf14

File tree

10 files changed

+405
-279
lines changed

10 files changed

+405
-279
lines changed

.appveyor.yml

Lines changed: 0 additions & 29 deletions
This file was deleted.

.github/workflows/cppcmake.yml

Lines changed: 92 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,92 @@
1+
name: CMake C++ CI
2+
3+
on:
4+
workflow_dispatch:
5+
push:
6+
branches: [ "master" ]
7+
tags: [ "v*.*" ]
8+
pull_request:
9+
branches: [ "master" ]
10+
release:
11+
types: [ "created" ]
12+
13+
env:
14+
LSL_RELEASE_URL: 'https://github.com/sccn/liblsl/releases/download/v1.16.1/'
15+
LSL_RELEASE: '1.16.1'
16+
# Customize the CMake build type here (Release, Debug, RelWithDebInfo, etc.)
17+
BUILD_TYPE: Release
18+
19+
defaults:
20+
run:
21+
shell: bash
22+
23+
# Check qt_ver on # https://download.qt.io/online/qtsdkrepository/
24+
jobs:
25+
build:
26+
name: ${{ matrix.config.name }}
27+
runs-on: ${{ matrix.config.os }}
28+
strategy:
29+
fail-fast: false
30+
matrix:
31+
config:
32+
- name: "windows-x64"
33+
os: "windows-latest"
34+
cmake_extra: "-T v142,host=x86"
35+
arch: "amd64"
36+
qt_arch: "win64_msvc2019_64"
37+
qt_ver: "6.4.0"
38+
- name: "windows-x86"
39+
os: "windows-latest"
40+
cmake_extra: "-T v142,host=x86 -A Win32"
41+
arch: "i386"
42+
qt_arch: "win32_msvc2019"
43+
qt_ver: "5.15.2"
44+
45+
steps:
46+
- uses: actions/checkout@v3
47+
48+
- name: Download liblsl
49+
run: |
50+
curl -L ${LSL_RELEASE_URL}/liblsl-${LSL_RELEASE}-Win_${{ matrix.config.arch}}.zip -o liblsl.zip
51+
7z x liblsl.zip -oLSL
52+
53+
- name: Install Qt
54+
uses: jurplel/[email protected]
55+
with:
56+
version: ${{ matrix.config.qt_ver }}
57+
arch: ${{ matrix.config.qt_arch }}
58+
59+
- name: Configure CMake
60+
# Configure CMake in a 'build' subdirectory. `CMAKE_BUILD_TYPE` is only required if you are using a single-configuration generator such as make.
61+
# See https://cmake.org/cmake/help/latest/variable/CMAKE_BUILD_TYPE.html?highlight=cmake_build_type
62+
run: |
63+
cmake --version
64+
cmake -S . -B build \
65+
-DCMAKE_BUILD_TYPE=${{env.BUILD_TYPE}} \
66+
-DCMAKE_INSTALL_PREFIX=${PWD}/install \
67+
-DCPACK_PACKAGE_DIRECTORY=${PWD}/package \
68+
-DLSL_INSTALL_ROOT=${PWD}/LSL/ \
69+
${{ matrix.config.cmake_extra }}
70+
71+
- name: make
72+
run: cmake --build build --config ${{env.BUILD_TYPE}} -j --target install
73+
74+
- name: package
75+
run: |
76+
export LD_LIBRARY_PATH=$Qt5_DIR/lib:$Qt6_DIR/lib:$LD_LIBRARY_PATH
77+
cmake --build build --config ${{env.BUILD_TYPE}} -j --target package
78+
cmake -E remove_directory package/_CPack_Packages
79+
80+
- name: Upload Artifacts
81+
uses: actions/upload-artifact@v3
82+
if: ${{ ! startsWith(github.ref, 'refs/tags/v') }}
83+
with:
84+
name: pkg-${{ matrix.config.name }}
85+
path: package
86+
87+
- name: Release
88+
uses: softprops/action-gh-release@v1
89+
if: startsWith(github.ref, 'refs/tags/v')
90+
with:
91+
files: |
92+
package/*

.gitignore

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,3 +6,6 @@ ui_*.h
66
/CMakeSettings.json
77
/out/
88
.DS_Store
9+
.idea/
10+
cmake-build-*/
11+
/install/

CMakeLists.txt

Lines changed: 71 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -1,51 +1,90 @@
1-
cmake_minimum_required(VERSION 3.10)
1+
cmake_minimum_required(VERSION 3.12)
22

33
project(SerialPort
4-
LANGUAGES CXX
5-
VERSION 1.13.0
6-
)
4+
DESCRIPTION "Read byte stream from COM port and emit as an LSL stream"
5+
HOMEPAGE_URL "https://github.com/labstreaminglayer/App-SerialPort/"
6+
LANGUAGES CXX
7+
VERSION 1.1.0
8+
)
9+
10+
set(CMAKE_CXX_STANDARD 17)
11+
set(CMAKE_CXX_STANDARD_REQUIRED On)
712

8-
# also look for CMake modules in the cmake subfolder
9-
list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/cmake")
13+
# Dependencies
1014

11-
# Find an installed liblsl in paths set by the user (LSL_INSTALL_ROOT)
12-
# and some default paths
15+
## LSL
1316
find_package(LSL REQUIRED
14-
HINTS ${LSL_INSTALL_ROOT}
15-
"${CMAKE_CURRENT_LIST_DIR}/../../LSL/liblsl/build/install"
16-
"${CMAKE_CURRENT_LIST_DIR}/../../LSL/liblsl/out/install/x64-Release"
17-
PATH_SUFFIXES share/LSL)
18-
get_filename_component(LSL_PATH ${LSL_CONFIG} DIRECTORY)
19-
message(STATUS "Found LSL lib in ${LSL_PATH}")
20-
LSLAPP_Setup_Boilerplate()
21-
22-
set(CMAKE_INCLUDE_CURRENT_DIR ON)
17+
HINTS ${LSL_INSTALL_ROOT}
18+
"${CMAKE_CURRENT_LIST_DIR}/../../LSL/liblsl/build/"
19+
"${CMAKE_CURRENT_LIST_DIR}/../../LSL/liblsl/build/install"
20+
"${CMAKE_CURRENT_LIST_DIR}/../../LSL/liblsl/out/build/x64-Release"
21+
"${CMAKE_CURRENT_LIST_DIR}/../../LSL/liblsl/out/install/x64-Release"
22+
"${CMAKE_CURRENT_LIST_DIR}/../../LSL/liblsl/cmake-build-release/install"
23+
PATH_SUFFIXES share/LSL
24+
)
25+
26+
## Qt
2327
set(CMAKE_AUTOMOC ON)
24-
set(CMAKE_AUTOUIC ON)
2528
set(CMAKE_AUTORCC ON)
29+
set(CMAKE_AUTOUIC ON)
30+
find_package(QT NAMES Qt6 Qt5 REQUIRED COMPONENTS Core)
31+
find_package(Qt${QT_VERSION_MAJOR} REQUIRED COMPONENTS Core Widgets)
2632

27-
find_package(Qt5 REQUIRED COMPONENTS Widgets)
28-
33+
## Threads
2934
find_package(Threads REQUIRED)
3035

31-
add_executable(${PROJECT_NAME} MACOSX_BUNDLE WIN32
32-
main.cpp
33-
mainwindow.cpp
34-
mainwindow.hpp
35-
mainwindow.ui
36+
37+
# Targets
38+
39+
add_executable(${PROJECT_NAME})
40+
41+
target_sources(${PROJECT_NAME} PRIVATE
42+
main.cpp
43+
mainwindow.cpp
44+
mainwindow.hpp
45+
mainwindow.ui
3646
)
3747

3848
target_link_libraries(${PROJECT_NAME}
39-
PRIVATE
40-
Qt5::Widgets
41-
Threads::Threads
42-
LSL::lsl
49+
PRIVATE
50+
Qt${QT_VERSION_MAJOR}::Core
51+
Qt${QT_VERSION_MAJOR}::Widgets
52+
Threads::Threads
53+
LSL::lsl
4354
)
4455

45-
target_compile_features(${PROJECT_NAME} PRIVATE cxx_std_14)
46-
4756
installLSLApp(${PROJECT_NAME})
4857
installLSLAuxFiles(${PROJECT_NAME}
49-
${PROJECT_NAME}.cfg
58+
${PROJECT_NAME}.cfg
59+
LICENSE
60+
README.md
5061
)
62+
63+
get_target_property(QT_QMAKE_EXECUTABLE Qt::qmake IMPORTED_LOCATION)
64+
get_filename_component(QT_WINDEPLOYQT_EXECUTABLE ${QT_QMAKE_EXECUTABLE} PATH)
65+
set(QT_WINDEPLOYQT_EXECUTABLE "${QT_WINDEPLOYQT_EXECUTABLE}/windeployqt.exe")
66+
67+
add_custom_command(
68+
TARGET ${PROJECT_NAME} POST_BUILD
69+
COMMAND ${QT_WINDEPLOYQT_EXECUTABLE}
70+
--no-translations --no-system-d3d-compiler
71+
--qmldir ${CMAKE_CURRENT_SOURCE_DIR}
72+
$<TARGET_FILE_DIR:${PROJECT_NAME}>)
73+
74+
add_custom_command(TARGET ${PROJECT_NAME} POST_BUILD
75+
COMMAND ${CMAKE_COMMAND} -E copy_if_different
76+
$<TARGET_FILE:LSL::lsl>
77+
$<TARGET_FILE_DIR:${PROJECT_NAME}>)
78+
79+
add_custom_command(
80+
TARGET ${PROJECT_NAME} POST_BUILD
81+
COMMAND ${CMAKE_COMMAND} -E copy
82+
${CMAKE_CURRENT_SOURCE_DIR}//${PROJECT_NAME}.cfg
83+
$<TARGET_FILE_DIR:${PROJECT_NAME}>)
84+
85+
if(Qt6_FOUND)
86+
qt_finalize_executable(${PROJECT_NAME})
87+
endif(Qt6_FOUND)
88+
89+
5190
LSLGenerateCPackConfig()

LICENSE

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
MIT License
2+
3+
Copyright (c) 2023 Chadwick Boulay
4+
5+
Permission is hereby granted, free of charge, to any person obtaining a copy
6+
of this software and associated documentation files (the "Software"), to deal
7+
in the Software without restriction, including without limitation the rights
8+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9+
copies of the Software, and to permit persons to whom the Software is
10+
furnished to do so, subject to the following conditions:
11+
12+
The above copyright notice and this permission notice shall be included in all
13+
copies or substantial portions of the Software.
14+
15+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21+
SOFTWARE.

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ The program reads a byte stream from a given COM port and emits it as an LSL str
66
* Start the SerialPort app. You should see a window like the following.
77
> ![serialport.png](serialport.png)
88
9-
* Make sure that your device is plugged in and that you know its COM port (you can usually check this in the Device Manage).
9+
* Make sure that your device is plugged in and that you know its COM port (you can usually check this in the Device Manager).
1010

1111
* Select the COM port and the BAUD rate (data rate). If you know the nominal sampling rate of your stream (in bytes per second), you can set this in the Stream Sampling Rate (0 means irregular/unknown).
1212

main.cpp

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,8 @@
22
#include <QApplication>
33

44
int main(int argc, char *argv[]) {
5-
QApplication a(argc, argv);
6-
MainWindow w(nullptr, argc > 1 ? argv[1] : nullptr);
7-
w.show();
8-
return a.exec();
9-
}
5+
QApplication a(argc, argv);
6+
MainWindow w(nullptr, argc > 1 ? argv[1] : nullptr);
7+
w.show();
8+
return a.exec();
9+
}

0 commit comments

Comments
 (0)