Skip to content

Commit

Permalink
Merge pull request #50 from OpenDDS/add_qt6_build_support
Browse files Browse the repository at this point in the history
Add Initial Qt6 Build Support
  • Loading branch information
jrw972 authored Dec 2, 2024
2 parents 3b411e8 + b07bdac commit fb968ec
Show file tree
Hide file tree
Showing 7 changed files with 61 additions and 32 deletions.
21 changes: 14 additions & 7 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,8 @@ jobs:
- windows-2019
- ubuntu-22.04
- ubuntu-20.04
- macos-14
- macos-13
- macos-12

runs-on: ${{ matrix.runner }}

Expand Down Expand Up @@ -102,7 +102,11 @@ jobs:
echo "LD_LIBRARY_PATH=$LD_LIBRARY_PATH:$GITHUB_WORKSPACE/ACE_TAO/ACE/lib:$GITHUB_WORKSPACE/OpenDDS/lib" >> $GITHUB_ENV
CONFIG_OPTIONS+=" --no-tests --std=c++17 --ipv6 --security"
if [ '${{ runner.os }}' == 'macOS' ]; then
CONFIG_OPTIONS+=" --xerces3=$(brew --prefix xerces-c) --openssl=/usr/local/opt/[email protected]"
if [ '${{ matrix.runner }}' == 'macos-13' ]; then
CONFIG_OPTIONS+=" --xerces3=$(brew --prefix xerces-c) --openssl=/usr/local/opt/[email protected]"
else
CONFIG_OPTIONS+=" --xerces3=$(brew --prefix xerces-c) --openssl=$(brew --prefix openssl)"
fi
fi
echo "CONFIG_OPTIONS=$CONFIG_OPTIONS" >> $GITHUB_ENV
export COMPILER_VERSION=$(c++ --version 2>&1 | head -n 1)
Expand Down Expand Up @@ -217,13 +221,15 @@ jobs:
run: |-
cmake -DBUILD_TYPE=debug -DVCPKG_INSTALLED_DIR=%VCPKG_INSTALLED_DIR% -DVCPKG_DEFAULT_TRIPLET=%VCPKG_DEFAULT_TRIPLET% -P BuildQwt.cmake
# Build opendds-monitor
- name: 'Set Up Problem Matcher (Windows)'
if: runner.os == 'Windows'
uses: ammaraskar/[email protected]
# Set up problem matchers
- name: 'Set Up Problem Matcher (Linux / macOS)'
if: runner.os == 'Linux' || runner.os == 'macOS'
uses: ammaraskar/[email protected]
- name: 'Set Up Problem Matcher (Windows)'
if: runner.os == 'Windows'
uses: ammaraskar/[email protected]

# Build opendds-monitor
- name: 'Build opendds-monitor (Linux / macOS)'
if: runner.os == 'Linux' || runner.os == 'macOS'
shell: bash
Expand All @@ -235,7 +241,8 @@ jobs:
cd build
CMAKE_ARGS=""
if [ '${{ runner.os }}' == 'macOS' ]; then
CMAKE_ARGS+=" -DQt5_DIR=$(brew --prefix qt@5)/lib/cmake/Qt5"
export QWT_DIR=$(brew --prefix qwt-qt5)
CMAKE_ARGS+=" -DCMAKE_PREFIX_PATH=$(brew --prefix qt@5)"
fi
cmake $CMAKE_ARGS ..
cmake --build . -t all -t managed_testapp -t unmanaged_testapp
Expand Down
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
build/*
CMakeLists.txt.user
51 changes: 31 additions & 20 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,8 @@ else()
set(qt_optional_components DBus)
endif()

find_package(Qt5 REQUIRED COMPONENTS Core Widgets Gui PrintSupport Svg OpenGL OPTIONAL_COMPONENTS ${qt_optional_components})
find_package(QT NAMES Qt5 Qt6 REQUIRED COMPONENTS Core Widgets Gui PrintSupport Svg OpenGL OPTIONAL_COMPONENTS ${qt_optional_components})
find_package(Qt${QT_VERSION_MAJOR} REQUIRED COMPONENTS Core Widgets Gui PrintSupport Svg OpenGL OPTIONAL_COMPONENTS ${qt_optional_components})

if(QWT_IS_LOCAL)
set(QWT_LIBRARY ${PROJECT_SOURCE_DIR}/qwt/lib/qwt$<$<CONFIG:DEBUG>:d>.lib)
Expand Down Expand Up @@ -78,21 +79,31 @@ if(WIN32)
list(APPEND SOURCE ddsmon.rc)
endif(WIN32)

qt5_add_resources(RESOURCES ddsmon.qrc)
if (NOT Qt6_FOUND)
qt5_add_resources(RESOURCES ddsmon.qrc)
else()
qt_add_resources(RESOURCES ddsmon.qrc)
endif()

qt5_wrap_cpp(MOC_SOURCE
src/graph_page.h
src/log_page.h
src/main_window.h
src/participant_page.h
src/participant_table_model.h
src/publication_monitor.h
src/recorder_dialog.h
src/subscription_monitor.h
src/table_page.h
src/topic_table_model.h
set(MOC_SOURCE_LIST
src/graph_page.h
src/log_page.h
src/main_window.h
src/participant_page.h
src/participant_table_model.h
src/publication_monitor.h
src/recorder_dialog.h
src/subscription_monitor.h
src/table_page.h
src/topic_table_model.h
)

if (NOT Qt6_FOUND)
qt5_wrap_cpp(MOC_SOURCE ${MOC_SOURCE_LIST})
else()
qt_wrap_cpp(MOC_SOURCE ${MOC_SOURCE_LIST})
endif()

add_executable(monitor
${SOURCE}
${HEADER}
Expand Down Expand Up @@ -124,13 +135,13 @@ target_compile_options(monitor PRIVATE $<$<OR:$<CXX_COMPILER_ID:Clang>,$<CXX_COM
target_link_libraries(monitor
OpenDDW
${QWT_LIBRARY}
Qt5::PrintSupport
Qt5::Widgets
Qt5::Core
Qt5::Gui
Qt5::Svg
Qt5::OpenGL
$<$<NOT:$<PLATFORM_ID:Windows>>:Qt5::DBus>
Qt${QT_VERSION_MAJOR}::PrintSupport
Qt${QT_VERSION_MAJOR}::Widgets
Qt${QT_VERSION_MAJOR}::Core
Qt${QT_VERSION_MAJOR}::Gui
Qt${QT_VERSION_MAJOR}::Svg
Qt${QT_VERSION_MAJOR}::OpenGL
$<$<NOT:$<PLATFORM_ID:Windows>>:Qt${QT_VERSION_MAJOR}::DBus>
)

target_include_directories(monitor PRIVATE
Expand Down
4 changes: 4 additions & 0 deletions src/main_window.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -279,7 +279,11 @@ void DDSMonitorMainWindow::parseCmd()
for (int i = 1; i < argList.count(); i++)
{
argString = argList.at(i);
#if (QT_VERSION < QT_VERSION_CHECK(6, 0, 0))
argString.remove(QRegExp("^-*")); // Remove any - prefix
#else
argString.remove(QRegularExpression("^-*")); // Remove any - prefix
#endif

// Help!
if (argString == "h" || argString == "help")
Expand Down
8 changes: 7 additions & 1 deletion src/recorder_dialog.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,12 @@

#include <QFileDialog>
#include <QMessageBox>
#include <QTextCodec>
#include <QSettings>
#include <QTime>

#if (QT_VERSION < QT_VERSION_CHECK(6, 0, 0))
#include <QTextCodec>
#endif

//------------------------------------------------------------------------------
RecorderDialog::RecorderDialog(const QString& topicName,
Expand Down Expand Up @@ -152,7 +154,11 @@ void RecorderDialog::on_recordButton_clicked()

// Prepare the output stream
m_outputStream.setDevice(&m_outputFile);
#if (QT_VERSION < QT_VERSION_CHECK(6, 0, 0))
m_outputStream.setCodec(QTextCodec::codecForName("UTF-8"));
#else
m_outputStream.setEncoding(QStringConverter::Utf8);
#endif
m_outputStream.setRealNumberNotation(QTextStream::FixedNotation);
m_outputStream.setRealNumberPrecision(6);

Expand Down
6 changes: 3 additions & 3 deletions src/topic_table_model.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -407,7 +407,7 @@ void TopicTableModel::parseData(const std::shared_ptr<OpenDynamicData> data)
{
wchar_t tmpValue[2] = { 0, 0 };
tmpValue[0] = child->getValue<wchar_t>();
dataRow->value = ACE_Wide_To_Ascii(tmpValue).char_rep();
dataRow->value = QString(ACE_Wide_To_Ascii(tmpValue).char_rep());
break;
}
case CORBA::tk_octet:
Expand Down Expand Up @@ -619,14 +619,14 @@ void TopicTableModel::setDataRow(DataRow* const data_row,
case CORBA::tk_char: {
CORBA::Char value[2] = { 0, 0 };
if (check_rc(data->get_char8_value(value[0], id), "get_char8_value failed")) {
data_row->value = value;
data_row->value = QString(value);
}
break;
}
case CORBA::tk_wchar: {
CORBA::WChar value[2] = { 0, 0 };
if (check_rc(data->get_char16_value(value[0], id), "get_char16_value failed")) {
data_row->value = ACE_Wide_To_Ascii(value).char_rep();
data_row->value = QString(ACE_Wide_To_Ascii(value).char_rep());
}
break;
}
Expand Down
2 changes: 1 addition & 1 deletion test/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ cmake_minimum_required(VERSION 3.20)
project(opendds-monitor-tests VERSION 0.0.1 LANGUAGES CXX)

add_library(test_common INTERFACE)
target_compile_options(test_common INTERFACE $<$<OR:$<CXX_COMPILER_ID:Clang>,$<CXX_COMPILER_ID:AppleClang>,$<CXX_COMPILER_ID:GNU>>: -Wall -Wpedantic -Wno-unused -Wextra -Wcast-align -Wcast-qual -Wctor-dtor-privacy -Wdisabled-optimization -Wformat=2 -Winit-self -Wmissing-include-dirs -Woverloaded-virtual -Wredundant-decls -Wshadow -Wsign-conversion -Wstrict-overflow=5 -Wundef -Werror> $<$<CXX_COMPILER_ID:MSVC>: /W4>)
target_compile_options(test_common INTERFACE $<$<OR:$<CXX_COMPILER_ID:Clang>,$<CXX_COMPILER_ID:AppleClang>,$<CXX_COMPILER_ID:GNU>>: -Wall -Wextra -Wpedantic -Wno-unused -Wunused-parameter> $<$<CXX_COMPILER_ID:MSVC>: /W4>)
if (MSVC)
target_compile_definitions(test_common INTERFACE _CRT_SECURE_NO_WARNINGS)
else()
Expand Down

0 comments on commit fb968ec

Please sign in to comment.