Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

#136: Move from qmake to CMake #166

Merged
merged 8 commits into from
Mar 9, 2024
Merged
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
2 changes: 1 addition & 1 deletion LICENSE
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
MIT License

Copyright (c) 2023 Aaron Tan
Copyright (c) 2024 Aaron Tan

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
Expand Down
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ craft libs/qt/qtspeech
craft karchive
```
3. Set up Qt Creator with a kit from Craft, following instructions [here](https://community.kde.org/Craft#Using_Craft_with_an_IDE).
4. Open Jyut Dictionary in Qt Creator, and add DEFINES+="PORTABLE" to the QMake configuration if you would like to isolate your debug build from any system files.
4. Open CMakeLists.txt in Qt Creator, and define `CMAKE_CXX_FLAGS` as `-DPORTABLE -DDEBUG` in the CMake configuration if you would like to isolate your debug build from any system files.
5. Compile and run!

#### Ubuntu: Manual Git clone + Qt Creator
Expand All @@ -108,7 +108,7 @@ cmake .. -DCMAKE_BUILD_TYPE=release -DCMAKE_INSTALL_PREFIX=~/Qt/5.15.2/gcc_64
make
sudo make install
```
3. Open Jyut Dictionary in Qt Creator, and add DEFINES+="PORTABLE" to the QMake configuration if you would like to isolate your debug build from any system files.
3. Open CMakeLists.txt in Qt Creator, and define `CMAKE_CXX_FLAGS` as `-DPORTABLE -DDEBUG` in the CMake configuration if you would like to isolate your debug build from any system files.
4. Compile and run!

## Packaging for release
Expand Down
232 changes: 232 additions & 0 deletions src/jyut-dict/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,232 @@
cmake_minimum_required(VERSION 3.5)

project(CantoneseDictionary VERSION 2.23.0408 LANGUAGES CXX)

set(CMAKE_AUTOUIC ON)
set(CMAKE_AUTOMOC ON)
set(CMAKE_AUTORCC ON)

set(CMAKE_CXX_STANDARD 17)
set(CMAKE_CXX_STANDARD_REQUIRED ON)

find_package(QT NAMES Qt6 Qt5 REQUIRED COMPONENTS
LinguistTools
Multimedia
Network
Sql
Svg
TextToSpeech
Widgets)
find_package(Qt${QT_VERSION_MAJOR} REQUIRED COMPONENTS
LinguistTools
Multimedia
Network
Sql
Svg
TextToSpeech
Widgets)
find_package(KF5Archive)

set(TS_FILES
resources/translations/jyutdictionary-en.ts
resources/translations/jyutdictionary-fr.ts
resources/translations/jyutdictionary-fr_CA.ts
resources/translations/jyutdictionary-yue_Hans.ts
resources/translations/jyutdictionary-yue_Hant.ts
resources/translations/jyutdictionary-zh_Hans.ts
resources/translations/jyutdictionary-zh_Hant.ts
resources/translations/jyutdictionary-zh_Hans_HK.ts
resources/translations/jyutdictionary-zh_Hant_HK.ts)

set(PROJECT_SOURCES
components/definitioncard/definitioncardsection.cpp
components/definitioncard/definitioncardwidget.cpp
components/definitioncard/definitioncontentwidget.cpp
components/definitioncard/definitionheaderwidget.cpp
components/dictionarylist/dictionarylistdelegate.cpp
components/dictionarylist/dictionarylistmodel.cpp
components/dictionarylist/dictionarylistview.cpp
components/entrysearchresult/resultlistdelegate.cpp
components/entrysearchresult/resultlistmodel.cpp
components/entrysearchresult/resultlistview.cpp
components/entryview/entryactionwidget.cpp
components/entryview/entrycontentwidget.cpp
components/entryview/entryheaderwidget.cpp
components/entryview/entryscrollarea.cpp
components/entryview/entryscrollareawidget.cpp
components/entryview/entryviewsentencecardsection.cpp
components/favouritewindow/favouritesplitter.cpp
components/historyview/searchhistorylistdelegate.cpp
components/historyview/searchhistorylistmodel.cpp
components/historyview/searchhistorylistview.cpp
components/historyview/searchhistorytab.cpp
components/historyview/viewhistorylistdelegate.cpp
components/historyview/viewhistorylistmodel.cpp
components/historyview/viewhistorylistview.cpp
components/historyview/viewhistorytab.cpp
components/layouts/flowlayout.cpp
components/magnifywindow/magnifyscrollarea.cpp
components/magnifywindow/magnifyscrollareawidget.cpp
components/mainwindow/mainsplitter.cpp
components/mainwindow/maintoolbar.cpp
components/mainwindow/searchlineedit.cpp
components/mainwindow/searchoptionsradiogroupbox.cpp
components/related/relatedbutton.cpp
components/related/relatedbuttoncontentwidget.cpp
components/related/relatedbuttonheaderwidget.cpp
components/related/relatedsection.cpp
components/sentencecard/loadingwidget.cpp
components/sentencecard/sentencecardwidget.cpp
components/sentencecard/sentencecontentwidget.cpp
components/sentencecard/sentenceheaderwidget.cpp
components/sentencesearchresult/sentenceresultlistdelegate.cpp
components/sentencesearchresult/sentenceresultlistmodel.cpp
components/sentencesearchresult/sentenceresultlistview.cpp
components/sentenceview/sentencescrollarea.cpp
components/sentenceview/sentencescrollareawidget.cpp
components/sentenceview/sentenceviewcontentwidget.cpp
components/sentenceview/sentenceviewheaderwidget.cpp
components/sentenceview/sentenceviewsentencecardsection.cpp
components/sentencewindow/sentencesplitter.cpp
components/settings/advancedtab.cpp
components/settings/contacttab.cpp
components/settings/dictionarytab.cpp
components/settings/settingstab.cpp
components/settings/texttab.cpp
dialogs/defaultdialog.cpp
dialogs/dictionarytabfailuredialog.cpp
dialogs/downloadaudiodialog.cpp
dialogs/downloadresultdialog.cpp
dialogs/entryspeakerrordialog.cpp
dialogs/exportdatabasedialog.cpp
dialogs/noupdatedialog.cpp
dialogs/overwriteconflictingdictionarydialog.cpp
dialogs/resetsettingsdialog.cpp
dialogs/restoredatabasedialog.cpp
logic/database/queryparseutils.cpp
logic/database/sqldatabasemanager.cpp
logic/database/sqldatabaseutils.cpp
logic/database/sqluserdatautils.cpp
logic/database/sqluserhistoryutils.cpp
logic/dictionary/dictionarymetadata.cpp
logic/dictionary/dictionarysource.cpp
logic/download/downloader.cpp
logic/entry/definitionsset.cpp
logic/entry/entry.cpp
logic/entry/entryspeaker.cpp
logic/search/searchoptionsmediator.cpp
logic/search/sqlsearch.cpp
logic/sentence/sentenceset.cpp
logic/sentence/sourcesentence.cpp
logic/settings/settings.cpp
logic/settings/settingsutils.cpp
logic/update/jyutdictionaryreleasechecker.cpp
logic/utils/chineseutils.cpp
logic/utils/scriptdetector.cpp
logic/utils/utils.cpp
logic/utils/utils_qt.cpp
main.cpp
windows/aboutwindow.cpp
windows/historywindow.cpp
windows/mainwindow.cpp
windows/settingswindow.cpp
windows/updatewindow.cpp
${TS_FILES}
)

include_directories(
${CMAKE_SOURCE_DIR}
)

if(${QT_VERSION_MAJOR} GREATER_EQUAL 6)
qt_add_executable(CantoneseDictionary
MANUAL_FINALIZATION
${PROJECT_SOURCES}
resources/resource.qrc
)

# qt_create_translation(QM_FILES ${CMAKE_SOURCE_DIR} ${TS_FILES})
else()
add_executable(CantoneseDictionary
${PROJECT_SOURCES}
resources/resource.qrc
)

# qt5_create_translation(QM_FILES ${CMAKE_SOURCE_DIR} ${TS_FILES})
endif()

target_link_libraries(CantoneseDictionary
PRIVATE Qt${QT_VERSION_MAJOR}::Widgets
PRIVATE Qt${QT_VERSION_MAJOR}::Multimedia
PRIVATE Qt${QT_VERSION_MAJOR}::Network
PRIVATE Qt${QT_VERSION_MAJOR}::Sql
PRIVATE Qt${QT_VERSION_MAJOR}::Svg
PRIVATE Qt${QT_VERSION_MAJOR}::TextToSpeech
PRIVATE KF5::Archive
)

add_subdirectory(
logic/utils/test/TestChineseUtils
)
add_subdirectory(
logic/utils/test/TestScriptDetector
)

set_target_properties(CantoneseDictionary PROPERTIES
MACOSX_BUNDLE_INFO_PLIST ${CMAKE_SOURCE_DIR}/platform/mac/Info.plist
MACOSX_BUNDLE TRUE
WIN32_EXECUTABLE TRUE
)

if (APPLE)
target_link_libraries(CantoneseDictionary PRIVATE "-framework AppKit")
TARGET_SOURCES(CantoneseDictionary
PRIVATE logic/utils/utils_mac.mm
PRIVATE resources/db/dict.db
PRIVATE resources/db/user.db
PRIVATE resources/licenses/FLOW_LAYOUT_LICENSE.txt
PRIVATE resources/settings/settings.ini
PRIVATE resources/icon/icon.icns
PRIVATE platform/mac/en.lproj/InfoPlist.strings
PRIVATE platform/mac/fr.lproj/InfoPlist.strings
PRIVATE platform/mac/yue_Hans.lproj/InfoPlist.strings
PRIVATE platform/mac/yue_Hant.lproj/InfoPlist.strings
PRIVATE platform/mac/zh_Hans.lproj/InfoPlist.strings
PRIVATE platform/mac/zh_Hant.lproj/InfoPlist.strings)

set_property(SOURCE resources/db/dict.db PROPERTY MACOSX_PACKAGE_LOCATION "Resources")
set_property(SOURCE resources/db/user.db PROPERTY MACOSX_PACKAGE_LOCATION "Resources")
set_property(SOURCE resources/licenses/FLOW_LAYOUT_LICENSE.txt PROPERTY MACOSX_PACKAGE_LOCATION "Resources/Licenses")
set_property(SOURCE resources/settings/settings.ini PROPERTY MACOSX_PACKAGE_LOCATION "Resources")
set_property(SOURCE resources/icon/icon.icns PROPERTY MACOSX_PACKAGE_LOCATION "Resources")
set_property(SOURCE platform/mac/en.lproj/InfoPlist.strings PROPERTY MACOSX_PACKAGE_LOCATION "Resources/en.lproj")
set_property(SOURCE platform/mac/fr.lproj/InfoPlist.strings PROPERTY MACOSX_PACKAGE_LOCATION "Resources/fr.lproj")
set_property(SOURCE platform/mac/yue_Hans.lproj/InfoPlist.strings PROPERTY MACOSX_PACKAGE_LOCATION "Resources/yue-Hans.lproj")
set_property(SOURCE platform/mac/yue_Hant.lproj/InfoPlist.strings PROPERTY MACOSX_PACKAGE_LOCATION "Resources/yue-Hant.lproj")
set_property(SOURCE platform/mac/zh_Hans.lproj/InfoPlist.strings PROPERTY MACOSX_PACKAGE_LOCATION "Resources/zh-hans.lproj")
set_property(SOURCE platform/mac/zh_Hant.lproj/InfoPlist.strings PROPERTY MACOSX_PACKAGE_LOCATION "Resources/zh-hant.lproj")
elseif (UNIX)
TARGET_SOURCES(CantoneseDictionary PRIVATE logic/utils/utils_linux.cpp)
configure_file(resources/db/dict.db dict.db COPYONLY)
configure_file(resources/db/user.db user.db COPYONLY)
configure_file(resources/licenses/FLOW_LAYOUT_LICENSE.txt FLOW_LAYOUT_LICENSE.txt COPYONLY)
configure_file(resources/settings/settings.ini settings.ini COPYONLY)
elseif (WIN32)
enable_language("RC")
TARGET_SOURCES(CantoneseDictionary PRIVATE
logic/utils/utils_windows.cpp
platform/windows/app.rc)
configure_file(resources/db/dict.db dict.db COPYONLY)
configure_file(resources/db/user.db user.db COPYONLY)
configure_file(resources/licenses/FLOW_LAYOUT_LICENSE.txt FLOW_LAYOUT_LICENSE.txt COPYONLY)
configure_file(resources/settings/settings.ini settings.ini COPYONLY)
endif()

install(TARGETS CantoneseDictionary
BUNDLE DESTINATION .
LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR})

if(QT_VERSION_MAJOR EQUAL 6)
qt_finalize_executable(test)
endif()

Loading