Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 14 additions & 0 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,13 @@ jobs:
with:
submodules: true

- name: Install Qt
uses: jurplel/install-qt-action@v4
with:
version: '6.9.2'
arch: 'win64_msvc2022_64'
cache: true

- name: Setup VCPKG
shell: pwsh
run: |
Expand Down Expand Up @@ -101,6 +108,13 @@ jobs:
# glibtoolize requires libtool
run: brew install autoconf autoconf-archive automake libtool

- name: Install Qt
uses: jurplel/install-qt-action@v4
with:
version: '6.9.2'
arch: 'clang_64'
cache: true

- name: Setup VCPKG
shell: bash
run: |
Expand Down
53 changes: 19 additions & 34 deletions ArpamGuiQt/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2,26 +2,10 @@ project(ArpamGuiQt VERSION 1.0.0 LANGUAGES CXX)

set(EXE_NAME ArpamGuiQt)

find_package(Qt6 CONFIG REQUIRED COMPONENTS Widgets Gui)
find_package(Qt6 CONFIG REQUIRED COMPONENTS Widgets Gui PrintSupport)
qt_standard_project_setup()
set(CMAKE_AUTOMOC ON)

# Manually include QCustomPlot
find_path(QCUSTOMPLOT_INCLUDE_DIR qcustomplot.h PATH_SUFFIXES qcustomplot)
if (WIN32)
find_library(QCUSTOMPLOT_LIBRARY NAMES qcustomplot2)
find_library(QCUSTOMPLOT_LIBRARY_DEBUG NAMES qcustomplotd2)
set(QCUSTOMPLOT_LIBRARY "$<IF:$<CONFIG:Debug>,${QCUSTOMPLOT_LIBRARY_DEBUG},${QCUSTOMPLOT_LIBRARY}>")
else ()
find_library(QCUSTOMPLOT_LIBRARY NAMES qcustomplot)
endif()

if (QCUSTOMPLOT_INCLUDE_DIR AND QCUSTOMPLOT_LIBRARY)
message(STATUS "Found QCustomPlot: ${QCUSTOMPLOT_LIBRARY}")
else()
message(FATAL_ERROR "Could not find QCustomPlot")
endif()

### Icons
# https://doc.qt.io/qt-6/appicon.html
# The MACOSX_BUNDLE_ICON_FILE variable is added to the Info.plist
Expand All @@ -45,9 +29,6 @@ add_definitions(-DARPAM_COMPILE_TIME="${CURRENT_TIME}")
add_definitions(-DARPAM_COMPILER_NAME="${CMAKE_CXX_COMPILER_ID}")
add_definitions(-DARPAM_COMPILER_VERSION="${CMAKE_CXX_COMPILER_VERSION}")

# Use QCustomPlot as a shared library
add_definitions(-DQCUSTOMPLOT_USE_LIBRARY)

### Source files
qt_add_executable(${EXE_NAME}
src/main.cpp
Expand Down Expand Up @@ -126,10 +107,7 @@ qt_add_resources(${EXE_NAME} styles
resources/styles/styles.qss
)

target_include_directories(${EXE_NAME} PRIVATE
src
${QCUSTOMPLOT_INCLUDE_DIR}
)
target_include_directories(${EXE_NAME} PRIVATE src)

find_package(fmt CONFIG REQUIRED)
find_package(FFTW3 CONFIG REQUIRED)
Expand All @@ -139,9 +117,9 @@ find_package(KFR CONFIG REQUIRED)
target_link_libraries(${EXE_NAME} PRIVATE
libuspam
fmt::fmt
Qt::Widgets
Qt::Gui
${QCUSTOMPLOT_LIBRARY}
Qt6::Widgets
Qt6::Gui
qcustomplot
FFTW3::fftw3
FFTW3::fftw3f
kfr
Expand Down Expand Up @@ -192,12 +170,20 @@ if (WIN32)
message(STATUS "ArpamGuiQt will build with NI support")
message(STATUS "NI_DAQMX_INCLUDE_DIR ${NI_DAQMX_INCLUDE_DIR}")

set(NI_DAQMX_LIBS
set(_ni_candidate_libs
${NI_DAQMX_LIB_DIR}/NIDAQmx.lib
${NI_DAQMX_LIB_DIR}/nip2p.lib
${NI_DAQMX_LIB_DIR}/nisyscfg.lib
${NI_DAQMX_LIB_DIR}/nivision.lib
)
set(NI_DAQMX_LIBS "")
foreach(_lib ${_ni_candidate_libs})
if (EXISTS "${_lib}")
list(APPEND NI_DAQMX_LIBS "${_lib}")
else()
message(STATUS "NI-DAQmx: skipping missing lib ${_lib}")
endif()
endforeach()

target_compile_definitions(${EXE_NAME} PRIVATE ARPAM_HAS_NI)
target_include_directories(${EXE_NAME} PRIVATE ${NI_DAQMX_INCLUDE_DIR})
Expand All @@ -219,14 +205,13 @@ if (WIN32)
WIN32_EXECUTABLE ON
)

# Determine the path to windeployqt
set(WINDEPLOYQT_PATH "${Qt6_DIR}/../../tools/Qt6/bin")
set(WINDEPLOYQT_EXE "${WINDEPLOYQT_PATH}/windeployqt.exe")
set(WINDEPLOYQT_DEBUG_EXE "${WINDEPLOYQT_PATH}/windeployqt.debug.bat")
# Locate windeployqt alongside qmake (works for both vcpkg and aqtinstall Qt)
get_target_property(_qt_qmake Qt6::qmake IMPORTED_LOCATION)
cmake_path(GET _qt_qmake PARENT_PATH _qt_bin_dir)
find_program(WINDEPLOYQT windeployqt HINTS "${_qt_bin_dir}" REQUIRED)

# Add post build command to call windeployqt
add_custom_command(TARGET ${EXE_NAME} POST_BUILD
COMMAND "$<IF:$<CONFIG:Debug>,${WINDEPLOYQT_DEBUG_EXE},${WINDEPLOYQT_EXE}>"
COMMAND "${WINDEPLOYQT}"
--verbose 1
"$<TARGET_FILE:${EXE_NAME}>"
)
Expand Down
2 changes: 2 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,8 @@ project(ARPAM_gui

enable_testing()

add_subdirectory(third_party/qcustomplot)

# Build libarpam
add_subdirectory(libuspam)

Expand Down
5 changes: 4 additions & 1 deletion CMakePresets.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,10 @@
"name": "base",
"hidden": true,
"binaryDir": "build/${presetName}",
"toolchainFile": "$env{VCPKG_ROOT}/scripts/buildsystems/vcpkg.cmake"
"toolchainFile": "$env{VCPKG_ROOT}/scripts/buildsystems/vcpkg.cmake",
"cacheVariables": {
"CMAKE_PREFIX_PATH": "$env{QT_ROOT_DIR}"
}
},
{
"name": "win64-cl-base",
Expand Down
42 changes: 42 additions & 0 deletions scripts/install-qt.ps1
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
# Install Qt 6 via aqtinstall and set QT_ROOT_DIR as a persistent user env var.
# Run once on a new machine; afterwards cmake --preset win64 works without extra args.
#
# Usage: pwsh scripts/install-qt.ps1 [-InstallDir <path>]

param(
[string]$InstallDir = "C:\Qt"
)

$QT_VERSION = "6.9.2"
$QT_ARCH = "win64_msvc2022_64"
$QT_ROOT = "$InstallDir\$QT_VERSION\msvc2022_64"

# 1. Ensure aqt is available
if (-not (Get-Command aqt -ErrorAction SilentlyContinue)) {
Write-Host "Installing aqtinstall via uv tool..."
uv tool install aqtinstall
if ($LASTEXITCODE -ne 0) { Write-Error "Failed to install aqtinstall"; exit 1 }
}

# 2. Install Qt if not already present
if (Test-Path "$QT_ROOT\lib\cmake\Qt6\Qt6Config.cmake") {
Write-Host "Qt $QT_VERSION already installed at $QT_ROOT"
} else {
Write-Host "Installing Qt $QT_VERSION ($QT_ARCH) to $InstallDir ..."
aqt install-qt windows desktop $QT_VERSION $QT_ARCH -O $InstallDir
if ($LASTEXITCODE -ne 0) { Write-Error "Qt installation failed"; exit 1 }
}

# 3. Persist QT_ROOT_DIR for the current user so cmake --preset works without extra args
$current = [System.Environment]::GetEnvironmentVariable("QT_ROOT_DIR", "User")
if ($current -ne $QT_ROOT) {
[System.Environment]::SetEnvironmentVariable("QT_ROOT_DIR", $QT_ROOT, "User")
Write-Host "Set user env var QT_ROOT_DIR=$QT_ROOT"
Write-Host "Restart your terminal (or re-source your profile) for the change to take effect."
} else {
Write-Host "QT_ROOT_DIR already set to $QT_ROOT"
}

# Also export into the current session so cmake works immediately without a restart
$env:QT_ROOT_DIR = $QT_ROOT
Write-Host "QT_ROOT_DIR is available in this session: $env:QT_ROOT_DIR"
44 changes: 44 additions & 0 deletions scripts/install-qt.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
#!/usr/bin/env bash
# Install Qt 6 via aqtinstall and add QT_ROOT_DIR to your shell profile.
# Run once on a new machine; afterwards cmake --preset clang works without extra args.
#
# Usage: bash scripts/install-qt.sh [install_dir]

set -euo pipefail

QT_VERSION="6.9.2"
QT_ARCH="clang_64"
INSTALL_DIR="${1:-$HOME/Qt}"
QT_ROOT="$INSTALL_DIR/$QT_VERSION/macos"

# 1. Ensure aqt is available
if ! command -v aqt &>/dev/null; then
echo "Installing aqtinstall via uv tool..."
uv tool install aqtinstall
fi

# 2. Install Qt if not already present
if [ -f "$QT_ROOT/lib/cmake/Qt6/Qt6Config.cmake" ]; then
echo "Qt $QT_VERSION already installed at $QT_ROOT"
else
echo "Installing Qt $QT_VERSION ($QT_ARCH) to $INSTALL_DIR ..."
aqt install-qt mac desktop "$QT_VERSION" "$QT_ARCH" -O "$INSTALL_DIR"
fi

# 3. Persist QT_ROOT_DIR in shell profile
EXPORT_LINE="export QT_ROOT_DIR=\"$QT_ROOT\""
PROFILE="${HOME}/.zshrc"
[ -n "${BASH_VERSION:-}" ] && PROFILE="${HOME}/.bashrc"

if grep -qF "QT_ROOT_DIR" "$PROFILE" 2>/dev/null; then
echo "QT_ROOT_DIR already present in $PROFILE"
else
echo "" >> "$PROFILE"
echo "# Qt (set by scripts/install-qt.sh)" >> "$PROFILE"
echo "$EXPORT_LINE" >> "$PROFILE"
echo "Added QT_ROOT_DIR to $PROFILE — restart your terminal or run: source $PROFILE"
fi

# Export into the current session so cmake works immediately
export QT_ROOT_DIR="$QT_ROOT"
echo "QT_ROOT_DIR is available in this session: $QT_ROOT_DIR"
6 changes: 6 additions & 0 deletions third_party/qcustomplot/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
find_package(Qt6 REQUIRED COMPONENTS Widgets PrintSupport)

add_library(qcustomplot STATIC qcustomplot.cpp)
target_include_directories(qcustomplot PUBLIC ${CMAKE_CURRENT_SOURCE_DIR})
target_link_libraries(qcustomplot PUBLIC Qt6::Widgets Qt6::PrintSupport)
set_target_properties(qcustomplot PROPERTIES AUTOMOC ON CXX_STANDARD 17)
Loading
Loading