Skip to content

Commit

Permalink
Upgrade to Qt 6
Browse files Browse the repository at this point in the history
Upgraded code to Qt 6. Some cleaning in CMake files.
  • Loading branch information
przemek83 committed Aug 16, 2023
1 parent a8da4f4 commit 28f70d0
Show file tree
Hide file tree
Showing 34 changed files with 211 additions and 193 deletions.
128 changes: 60 additions & 68 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,30 +1,22 @@
cmake_minimum_required(VERSION 3.8)
cmake_minimum_required(VERSION 3.16)

project(volbx LANGUAGES CXX VERSION 2.0.0 DESCRIPTION "Graphical tool for data manipulation")
project(volbx
LANGUAGES CXX
VERSION 2.1.0
DESCRIPTION "Graphical tool for data manipulation"
HOMEPAGE_URL "https://github.com/przemek83/volbx")

set(CMAKE_INCLUDE_CURRENT_DIR ON)
set(CMAKE_AUTOUIC ON)
set(CMAKE_AUTOMOC ON)
set(CMAKE_AUTORCC ON)
set(CMAKE_CXX_STANDARD 17)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
set(CMAKE_CXX_EXTENSIONS OFF)

find_package(Threads REQUIRED)

# find Qt packages
find_package(Qt5 COMPONENTS Widgets Core Gui Network Xml Test REQUIRED)
add_definitions(${QT_DEFINITIONS})
find_package(Qt6 REQUIRED COMPONENTS Widgets Core Gui Network Xml Test)
qt_standard_project_setup()

# QWT
if(DEFINED ENV{QWT_ROOT})
message(STATUS "QWT_ROOT environment variable defined, using QWT_ROOT paths.")
# copy QWT dlls for easy launch
if (WIN32)
file(GLOB_RECURSE QWT_DLLS "$ENV{QWT_ROOT}/lib/*.dll" )
file(COPY ${QWT_DLLS} DESTINATION ${CMAKE_BINARY_DIR})
file(COPY ${QWT_DLLS} DESTINATION ${CMAKE_BINARY_DIR}/Tests)
endif()
else()
configure_file(CMakeLists.txt.qwt qwt/CMakeLists.txt)
execute_process(COMMAND ${CMAKE_COMMAND} -G "${CMAKE_GENERATOR}" .
Expand All @@ -39,30 +31,26 @@ else()
set(ENV{QWT_ROOT} ${CMAKE_BINARY_DIR}/qwt/install/)
endif()

set(THIRD_PARTY_LIBS zlib quazip wble qwtble eible)
foreach(file_i ${THIRD_PARTY_LIBS})
configure_file(CMakeLists.txt.${file_i} ${file_i}/CMakeLists.txt)
set(THIRD_PARTY_LIBS wble qwtble eible zlib quazip)
foreach(library ${THIRD_PARTY_LIBS})
configure_file(CMakeLists.txt.${library} ${library}/CMakeLists.txt)
execute_process(COMMAND ${CMAKE_COMMAND} -G ${CMAKE_GENERATOR} .
WORKING_DIRECTORY ${CMAKE_BINARY_DIR}/${file_i})
WORKING_DIRECTORY ${CMAKE_BINARY_DIR}/${library})
execute_process(COMMAND ${CMAKE_COMMAND} --build .
WORKING_DIRECTORY ${CMAKE_BINARY_DIR}/${file_i} )
endforeach(file_i)

# copy dlls for easy launch
if(WIN32)
file(GLOB_RECURSE DLLS "${CMAKE_BINARY_DIR}/*.dll" )
file(COPY ${DLLS} DESTINATION ${CMAKE_BINARY_DIR})
file(COPY ${DLLS} DESTINATION ${CMAKE_BINARY_DIR}/Tests)
endif()

# workaround for not working passing "CMAKE_ARGS -DCMAKE_INSTALL_PREFIX=<dir>" in ExternalProject_Add
set(workaround ON CACHE BOOL "" FORCE)
WORKING_DIRECTORY ${CMAKE_BINARY_DIR}/${library} )
endforeach(library)

include_directories($ENV{QWT_ROOT}/include)

foreach(file_i ${THIRD_PARTY_LIBS})
include_directories(${CMAKE_BINARY_DIR}/${file_i}/install/include)
endforeach(file_i)

set(ZLIB_ROOT ${CMAKE_BINARY_DIR}/zlib/install)
find_package(ZLIB REQUIRED)
list(APPEND CMAKE_PREFIX_PATH "${CMAKE_BINARY_DIR}/quazip/install/")
find_package(QuaZip-Qt6 CONFIG REQUIRED)

link_directories($ENV{QWT_ROOT}/lib)
link_directories(${CMAKE_BINARY_DIR}/zlib/install/bin)
link_directories(${CMAKE_BINARY_DIR}/quazip/install/lib)
Expand All @@ -85,61 +73,69 @@ add_subdirectory(Datasets)
add_subdirectory(ModelsAndViews)
add_subdirectory(Export)

set(${PROJECT_NAME}_SOURCES
set(SOURCES
Volbx/main.cpp
Volbx/Volbx.ico
Volbx/VolbxProperties.h
Volbx/VolbxProperties.rc
GUI/About.cpp
GUI/About.h
GUI/About.ui
GUI/CheckUpdates.cpp
GUI/CheckUpdates.h
GUI/CheckUpdates.ui
GUI/DockTitleBar.cpp
GUI/DockTitleBar.h
GUI/DockTitleBar.ui
GUI/Dock.cpp
GUI/Dock.h
GUI/Export.cpp
GUI/Export.h
GUI/Export.ui
GUI/FiltersDock.cpp
GUI/FiltersDock.h
GUI/Tab.cpp
GUI/Tab.h
GUI/TabWidget.cpp
GUI/TabWidget.h
GUI/PlotDock.cpp
GUI/PlotDock.h
GUI/SaveDatasetAs.cpp
GUI/SaveDatasetAs.h
GUI/SaveDatasetAs.ui
GUI/TabBar.cpp
GUI/TabBar.h
GUI/DataViewDock.cpp
GUI/DataViewDock.h
GUI/VolbxMain.cpp
GUI/VolbxMain.h
GUI/VolbxMain.ui
Import/ColumnsPreview.cpp
Import/ColumnsPreview.h
Import/DatasetVisualization.cpp
Import/DatasetVisualization.h
Import/DatasetVisualization.ui
Import/DatasetImportTab.cpp
Import/DatasetImportTab.h
Import/DatasetsListBrowser.cpp
Import/DatasetsListBrowser.h
Import/DatasetsListBrowser.ui
Import/ImportData.cpp
Import/ImportData.h
Import/ImportTab.cpp
Import/ImportTab.h
Import/SpreadsheetsImportTab.cpp
)
qt_add_resources(SOURCES Resources/Resources.qrc)

set(HEADERS
Volbx/VolbxProperties.h
GUI/About.h
GUI/CheckUpdates.h
GUI/DockTitleBar.h
GUI/Dock.h
GUI/Export.h
GUI/FiltersDock.h
GUI/Tab.h
GUI/TabWidget.h
GUI/PlotDock.h
GUI/SaveDatasetAs.h
GUI/TabBar.h
GUI/DataViewDock.h
GUI/VolbxMain.h
Import/ColumnsPreview.h
Import/DatasetVisualization.h
Import/DatasetImportTab.h
Import/DatasetsListBrowser.h
Import/ImportData.h
Import/ImportTab.h
Import/SpreadsheetsImportTab.h
)

set(UI
GUI/About.ui
GUI/CheckUpdates.ui
GUI/DockTitleBar.ui
GUI/Export.ui
GUI/SaveDatasetAs.ui
GUI/VolbxMain.ui
Import/SpreadsheetsImportTab.ui
)
Import/DatasetsListBrowser.ui
Import/DatasetVisualization.ui
)
source_group("UI Files" FILES ${UI})

# remove background console window.
if(WIN32)
Expand All @@ -149,19 +145,15 @@ if(APPLE)
set(GUI_TYPE MACOSX_BUNDLE)
endif(APPLE)

qt5_add_resources(RESOURCES Resources/Resources.qrc)
add_custom_target(generated_qrc DEPENDS ${RESOURCES})
add_executable(${PROJECT_NAME} ${GUI_TYPE} ${SOURCES} ${HEADERS} ${UI})

add_executable(${PROJECT_NAME} ${GUI_TYPE} ${${PROJECT_NAME}_SOURCES} ${RESOURCES} Volbx/VolbxProperties.rc)
add_dependencies(${PROJECT_NAME} generated_qrc)
target_link_libraries(${PROJECT_NAME} Threads::Threads shared common datasets modelsAndViews export wble qwtble eible Qt6::Core Qt6::Network Qt6::Widgets Qt6::Gui Qt6::Xml)

target_link_libraries(${PROJECT_NAME} Threads::Threads shared common datasets modelsAndViews export wble qwtble eible Qt5::Core Qt5::Network Qt5::Widgets Qt5::Gui Qt5::Xml)
if(WIN32)
target_link_libraries(${PROJECT_NAME} optimized qwt debug qwtd)
else()
target_link_libraries(${PROJECT_NAME} qwt)
endif()
target_link_libraries(${PROJECT_NAME} optimized Qt5Quazip debug Qt5Quazipd)

add_subdirectory(Update)

Expand Down
4 changes: 2 additions & 2 deletions CMakeLists.txt.eible
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
cmake_minimum_required(VERSION 3.8)
cmake_minimum_required(VERSION 3.16)

include(ExternalProject)

Expand All @@ -7,6 +7,6 @@ project(eible NONE)
ExternalProject_Add(eible
PREFIX eible
GIT_REPOSITORY https://github.com/przemek83/eible.git
GIT_TAG v1.0.0
GIT_TAG master
CMAKE_ARGS -DCMAKE_BUILD_TYPE=${CMAKE_BUILD_TYPE} -DCMAKE_INSTALL_PREFIX=${CMAKE_BINARY_DIR}/eible/install
)
6 changes: 4 additions & 2 deletions CMakeLists.txt.quazip
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
cmake_minimum_required(VERSION 3.8)
cmake_minimum_required(VERSION 3.16)

include(ExternalProject)

Expand All @@ -7,8 +7,10 @@ project(quazip NONE)
ExternalProject_Add(quazip
PREFIX quazip
GIT_REPOSITORY https://github.com/stachenov/quazip.git
GIT_TAG 9e6e827e01310c08f40979be192ba76295f4b6e4
GIT_TAG 9d3aa3ee948c1cde5a9f873ecbc3bb229c1182ee
CMAKE_ARGS -DCMAKE_BUILD_TYPE=${CMAKE_BUILD_TYPE}
-DCMAKE_INSTALL_PREFIX=${CMAKE_BINARY_DIR}/quazip/install
-DQUAZIP_QT_MAJOR_VERSION=6
-DZLIB_ROOT=${CMAKE_BINARY_DIR}/zlib/install
-DQUAZIP_BZIP2=OFF
)
7 changes: 4 additions & 3 deletions CMakeLists.txt.qwt
Original file line number Diff line number Diff line change
@@ -1,12 +1,13 @@
cmake_minimum_required(VERSION 3.8)
cmake_minimum_required(VERSION 3.16)

include(ExternalProject)

project(qwt NONE)

ExternalProject_Add(qwt
PREFIX qwt
SVN_REPOSITORY https://svn.code.sf.net/p/qwt/code/branches/qwt-6.1/
CONFIGURE_COMMAND ${QT_QMAKE_EXECUTABLE} ${CMAKE_BINARY_DIR}/qwt/qwt/src/qwt/qwt.pro
GIT_REPOSITORY https://git.code.sf.net/p/qwt/git
GIT_TAG 9e554a5e03bc3a1fe379bdddfa4d21ced2ed7995
CONFIGURE_COMMAND qmake ${CMAKE_BINARY_DIR}/qwt/qwt/src/qwt/qwt.pro
INSTALL_COMMAND ""
)
4 changes: 2 additions & 2 deletions CMakeLists.txt.qwtble
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
cmake_minimum_required(VERSION 3.8)
cmake_minimum_required(VERSION 3.16)

include(ExternalProject)

Expand All @@ -7,6 +7,6 @@ project(qwtble NONE)
ExternalProject_Add(qwtble
PREFIX qwtble
GIT_REPOSITORY https://github.com/przemek83/qwtble.git
GIT_TAG v1.0.0
GIT_TAG master
CMAKE_ARGS -DCMAKE_BUILD_TYPE=${CMAKE_BUILD_TYPE} -DCMAKE_INSTALL_PREFIX=${CMAKE_BINARY_DIR}/qwtble/install
)
4 changes: 2 additions & 2 deletions CMakeLists.txt.wble
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
cmake_minimum_required(VERSION 3.8)
cmake_minimum_required(VERSION 3.16)

include(ExternalProject)

Expand All @@ -7,6 +7,6 @@ project(wble NONE)
ExternalProject_Add(wble
PREFIX wble
GIT_REPOSITORY https://github.com/przemek83/wble.git
GIT_TAG v1.0.0
GIT_TAG master
CMAKE_ARGS -DCMAKE_BUILD_TYPE=${CMAKE_BUILD_TYPE} -DCMAKE_INSTALL_PREFIX=${CMAKE_BINARY_DIR}/wble/install
)
8 changes: 5 additions & 3 deletions CMakeLists.txt.zlib
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
cmake_minimum_required(VERSION 3.8)
cmake_minimum_required(VERSION 3.16)

include(ExternalProject)

Expand All @@ -7,6 +7,8 @@ project(zlib NONE)
ExternalProject_Add(zlib
PREFIX zlib
GIT_REPOSITORY https://github.com/madler/zlib.git
GIT_TAG 04f42ceca40f73e2978b50e93806c2a18c1281fc
CMAKE_ARGS -DCMAKE_BUILD_TYPE=${CMAKE_BUILD_TYPE} -DCMAKE_INSTALL_PREFIX=${CMAKE_BINARY_DIR}/zlib/install -DSTATIC=OFF
GIT_TAG v1.2.13
CMAKE_ARGS -DCMAKE_BUILD_TYPE=${CMAKE_BUILD_TYPE}
-DCMAKE_INSTALL_PREFIX=${CMAKE_BINARY_DIR}/zlib/install
-DSTATIC=OFF
)
19 changes: 11 additions & 8 deletions Common/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,19 +1,22 @@
project(common)

set(${PROJECT_NAME}_SOURCES
set(SOURCES
Configuration.cpp
Configuration.h
Constants.cpp
DatasetUtilities.cpp
TimeLogger.cpp
FileUtilities.cpp
)

set(HEADERS
Configuration.h
Constants.h
ColumnTag.h
DatasetUtilities.cpp
DatasetUtilities.h
TimeLogger.cpp
TimeLogger.h
FileUtilities.cpp
FileUtilities.h
)
)

ADD_LIBRARY(${PROJECT_NAME} STATIC ${${PROJECT_NAME}_SOURCES})
ADD_LIBRARY(${PROJECT_NAME} STATIC ${SOURCES} ${HEADERS})

target_link_libraries(${PROJECT_NAME} shared Qt5::Core)
target_link_libraries(${PROJECT_NAME} shared Qt6::Core)
2 changes: 1 addition & 1 deletion Common/FileUtilities.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ std::pair<bool, QString> loadFile(const QString& name)
return {false, ""};

QTextStream stream(&file);
stream.setCodec("UTF-8");
stream.setEncoding(QStringConverter::Utf8);
return {true, stream.readAll()};
}
} // namespace FileUtilities
19 changes: 11 additions & 8 deletions Datasets/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,18 +1,21 @@
project(datasets)

set(${PROJECT_NAME}_SOURCES
set(SOURCES
Dataset.cpp
Dataset.h
DatasetOds.cpp
DatasetOds.h
DatasetXlsx.cpp
DatasetXlsx.h
DatasetInner.cpp
DatasetInner.h
DatasetSpreadsheet.cpp
)

set(HEADERS
Dataset.h
DatasetOds.h
DatasetXlsx.h
DatasetInner.h
DatasetSpreadsheet.h
)
)

ADD_LIBRARY(${PROJECT_NAME} STATIC ${${PROJECT_NAME}_SOURCES})
ADD_LIBRARY(${PROJECT_NAME} STATIC ${SOURCES} ${HEADERS})

target_link_libraries(${PROJECT_NAME} eible shared common Qt5::Core Qt5::Xml)
target_link_libraries(${PROJECT_NAME} eible shared common Qt6::Core Qt6::Xml QuaZip::QuaZip)
6 changes: 3 additions & 3 deletions Datasets/Dataset.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@

Dataset::Dataset(QString name, QObject* parent)
: QObject(parent),
nullStringVariant_(QVariant::String),
nullStringVariant_(QMetaType(QMetaType::QString)),
name_(std::move(name))
{
}
Expand Down Expand Up @@ -92,7 +92,7 @@ QStringList Dataset::getStringList(Column column) const
if (row[column].isNull())
continue;

if (row[column].type() == QVariant::String)
if (row[column].typeId() == QMetaType::QString)
{
listToFill.append(row[column].toString());
continue;
Expand Down Expand Up @@ -238,7 +238,7 @@ void Dataset::updateSampleDataStrings(QVector<QVector<QVariant>>& data) const

for (auto& sampleDataRow : data)
{
if (sampleDataRow[i].type() != QVariant::Int)
if (sampleDataRow[i].typeId() != QMetaType::Int)
continue;

const int index{sampleDataRow[i].toInt()};
Expand Down
Loading

0 comments on commit 28f70d0

Please sign in to comment.