1 # Generate and configure translation files
2 # -----------------------------------------------------------------------------
3 # -----------------------------------------------------------------------------
4 # Based on https://gist.github.com/giraldeau/546ba5512a74dfe9d8ea0862d66db412
5 file(GLOB QBT_TS_FILES "${qBittorrent_SOURCE_DIR}/src/lang/*.ts")
6 set_source_files_properties(${QBT_TS_FILES} PROPERTIES OUTPUT_LOCATION "${qBittorrent_BINARY_DIR}/src/lang")
7 qt_add_translation(QBT_QM_FILES ${QBT_TS_FILES} OPTIONS -silent)
8 configure_file("${qBittorrent_SOURCE_DIR}/src/lang/lang.qrc" "${qBittorrent_BINARY_DIR}/src/lang/lang.qrc" COPYONLY)
11 file(GLOB QBT_WEBUI_TS_FILES "${qBittorrent_SOURCE_DIR}/src/webui/www/translations/*.ts")
12 set_source_files_properties(${QBT_WEBUI_TS_FILES}
13 PROPERTIES OUTPUT_LOCATION "${qBittorrent_BINARY_DIR}/src/webui/www/translations")
14 qt_add_translation(QBT_WEBUI_QM_FILES ${QBT_WEBUI_TS_FILES} OPTIONS -silent)
15 configure_file("${qBittorrent_SOURCE_DIR}/src/webui/www/translations/webui_translations.qrc"
16 "${qBittorrent_BINARY_DIR}/src/webui/www/translations/webui_translations.qrc" COPYONLY)
19 FILE(GLOB QT_TRANSLATIONS "${qBittorrent_SOURCE_DIR}/dist/qt-translations/qtbase_*.qm")
20 foreach(EXTRA_TRANSLATION IN ITEMS "fa" "gl" "lt" "pt" "sl" "sv" "zh_CN")
21 list(APPEND QT_TRANSLATIONS "${qBittorrent_SOURCE_DIR}/dist/qt-translations/qt_${EXTRA_TRANSLATION}.qm")
24 # Executable target configuration
25 # -----------------------------------------------------------------------------
26 # -----------------------------------------------------------------------------
27 add_executable(qbt_app)
29 target_sources(qbt_app PRIVATE
32 applicationinstancemanager.h
35 qtlocalpeer/qtlocalpeer.h
40 applicationinstancemanager.cpp
44 qtlocalpeer/qtlocalpeer.cpp
48 "${qBittorrent_SOURCE_DIR}/src/icons/icons.qrc"
49 "${qBittorrent_SOURCE_DIR}/src/searchengine/searchengine.qrc"
51 "${qBittorrent_BINARY_DIR}/src/lang/lang.qrc" # yes, it's supposed to be "*_BINARY_DIR"
54 target_link_libraries(qbt_app PRIVATE
58 set_target_properties(qbt_app PROPERTIES RUNTIME_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}")
60 set_target_properties(qbt_app PROPERTIES OUTPUT_NAME qbittorrent)
62 set_target_properties(qbt_app PROPERTIES OUTPUT_NAME qbittorrent-nox)
65 # Additional platform specific configuration
66 # -----------------------------------------------------------------------------
67 # -----------------------------------------------------------------------------
68 set_source_files_properties(${QT_TRANSLATIONS} PROPERTIES MACOSX_PACKAGE_LOCATION translations)
69 set_source_files_properties(
70 "${qBittorrent_SOURCE_DIR}/dist/mac/qt.conf"
71 "${qBittorrent_SOURCE_DIR}/dist/mac/qBitTorrentDocument.icns"
72 "${qBittorrent_SOURCE_DIR}/dist/mac/qbittorrent_mac.icns"
74 MACOSX_PACKAGE_LOCATION Resources
77 if (CMAKE_SYSTEM_NAME STREQUAL "Darwin")
78 # provide variables for substitution in dist/mac/Info.plist
79 get_target_property(EXECUTABLE_NAME qbt_app OUTPUT_NAME)
80 # This variable name should be changed once qmake is no longer used. Refer to the discussion in PR #14813
81 set(MACOSX_DEPLOYMENT_TARGET ${CMAKE_OSX_DEPLOYMENT_TARGET})
82 set_target_properties(qbt_app PROPERTIES
84 MACOSX_BUNDLE_BUNDLE_NAME "qBittorrent"
85 MACOSX_BUNDLE_INFO_PLIST ${qBittorrent_SOURCE_DIR}/dist/mac/Info.plist
87 target_sources(qbt_app PRIVATE
89 ${qBittorrent_SOURCE_DIR}/dist/mac/qt.conf
90 ${qBittorrent_SOURCE_DIR}/dist/mac/qBitTorrentDocument.icns
91 ${qBittorrent_SOURCE_DIR}/dist/mac/qbittorrent_mac.icns
93 elseif (CMAKE_SYSTEM_NAME STREQUAL "Windows")
94 set_target_properties(qbt_app PROPERTIES WIN32_EXECUTABLE ON)
96 target_sources(qbt_app PRIVATE ${qBittorrent_SOURCE_DIR}/src/qbittorrent_mingw.rc)
98 target_sources(qbt_app PRIVATE ${qBittorrent_SOURCE_DIR}/src/qbittorrent.rc)
100 target_sources(qbt_app PRIVATE ${qBittorrent_SOURCE_DIR}/src/qbittorrent.exe.manifest)
103 # Additional feature dependent configuration
104 # -----------------------------------------------------------------------------
105 # -----------------------------------------------------------------------------
107 target_compile_definitions(qbt_app PRIVATE STACKTRACE)
109 if (CMAKE_SYSTEM_NAME STREQUAL "Windows")
110 target_sources(qbt_app PRIVATE stacktrace_win.h)
113 qt_wrap_ui(STACKTRACE_UI_HEADERS stacktracedialog.ui)
115 target_sources(qbt_app PRIVATE
118 ${STACKTRACE_UI_HEADERS}
121 # UI headers will be generated in ${CMAKE_CURRENT_BINARY_DIR}
122 target_include_directories(qbt_app PRIVATE
123 ${CMAKE_CURRENT_BINARY_DIR}
127 # i686 arch on Windows requires frame pointer preservation
129 target_compile_options(qbt_app PRIVATE /Zi)
130 target_link_options(qbt_app PUBLIC LINKER:/DEBUG)
131 if (CMAKE_SIZEOF_VOID_P EQUAL 4)
132 target_compile_options(qbt_app PRIVATE /Oy)
135 if (CMAKE_SIZEOF_VOID_P EQUAL 4)
136 target_compile_options(qbt_app PRIVATE -fno-omit-frame-pointer)
140 target_link_libraries(qbt_app PUBLIC dbghelp)
142 target_sources(qbt_app PRIVATE stacktrace.h)
147 target_link_libraries(qbt_app PRIVATE qbt_gui)
148 if ((CMAKE_SYSTEM_NAME STREQUAL "Windows") OR (CMAKE_SYSTEM_NAME STREQUAL "Darwin"))
149 qt_import_plugins(qbt_app INCLUDE Qt::QSvgIconPlugin Qt::QSvgPlugin)
154 target_sources(qbt_app PRIVATE
155 ${QBT_WEBUI_QM_FILES}
156 ${qBittorrent_BINARY_DIR}/src/webui/www/translations/webui_translations.qrc # yes, it's supposed to be "*_BINARY_DIR"
158 target_link_libraries(qbt_app PRIVATE qbt_webui)
162 # -----------------------------------------------------------------------------
163 # -----------------------------------------------------------------------------
164 install(TARGETS qbt_app
165 RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}
171 install(FILES $<TARGET_PDB_FILE:qbt_app>
172 DESTINATION ${CMAKE_INSTALL_BINDIR}