1 file(GLOB QBT_TS_FILES "${qBittorrent_SOURCE_DIR}/src/lang/*.ts")
2 # Custom target to update .ts files and include new strings from source files
3 # Depends on Qt's LinguistTools
4 get_target_property(QT_LUPDATE_EXECUTABLE Qt::lupdate IMPORTED_LOCATION)
5 add_custom_target(qbt_update_translations
6 COMMAND ${QT_LUPDATE_EXECUTABLE} -extensions ui,c,c++,cc,cpp,cxx,ch,h,h++,hh,hpp,hxx
7 ${qBittorrent_SOURCE_DIR}
9 WORKING_DIRECTORY "${qBittorrent_SOURCE_DIR}"
13 # Generate and configure translation files
14 # -----------------------------------------------------------------------------
15 # -----------------------------------------------------------------------------
16 # Based on https://gist.github.com/giraldeau/546ba5512a74dfe9d8ea0862d66db412
17 set_source_files_properties(${QBT_TS_FILES} PROPERTIES OUTPUT_LOCATION "${qBittorrent_BINARY_DIR}/src/lang")
18 qt_add_translation(QBT_QM_FILES ${QBT_TS_FILES} OPTIONS -removeidentical -silent)
19 configure_file("${qBittorrent_SOURCE_DIR}/src/lang/lang.qrc" "${qBittorrent_BINARY_DIR}/src/lang/lang.qrc" COPYONLY)
22 file(GLOB QBT_WEBUI_TS_FILES "${qBittorrent_SOURCE_DIR}/src/webui/www/translations/*.ts")
23 set_source_files_properties(${QBT_WEBUI_TS_FILES}
24 PROPERTIES OUTPUT_LOCATION "${qBittorrent_BINARY_DIR}/src/webui/www/translations")
25 qt_add_translation(QBT_WEBUI_QM_FILES ${QBT_WEBUI_TS_FILES} OPTIONS -removeidentical -silent)
26 configure_file("${qBittorrent_SOURCE_DIR}/src/webui/www/translations/webui_translations.qrc"
27 "${qBittorrent_BINARY_DIR}/src/webui/www/translations/webui_translations.qrc" COPYONLY)
30 # Executable target configuration
31 # -----------------------------------------------------------------------------
32 # -----------------------------------------------------------------------------
33 add_executable(qbt_app)
35 target_sources(qbt_app PRIVATE
38 applicationinstancemanager.h
42 qtlocalpeer/qtlocalpeer.h
48 applicationinstancemanager.cpp
53 qtlocalpeer/qtlocalpeer.cpp
58 "${qBittorrent_SOURCE_DIR}/src/icons/icons.qrc"
59 "${qBittorrent_SOURCE_DIR}/src/searchengine/searchengine.qrc"
61 "${qBittorrent_BINARY_DIR}/src/lang/lang.qrc" # yes, it's supposed to be "*_BINARY_DIR"
64 target_link_libraries(qbt_app PRIVATE
68 set_target_properties(qbt_app PROPERTIES RUNTIME_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}")
70 set_target_properties(qbt_app PROPERTIES OUTPUT_NAME qbittorrent)
72 set_target_properties(qbt_app PROPERTIES OUTPUT_NAME qbittorrent-nox)
75 # Additional platform specific configuration
76 # -----------------------------------------------------------------------------
77 # -----------------------------------------------------------------------------
78 if (CMAKE_SYSTEM_NAME STREQUAL "Darwin")
79 include(FindQtTranslations)
80 qbt_get_qt_translations(QT_TRANSLATIONS)
81 set_source_files_properties(${QT_TRANSLATIONS} PROPERTIES MACOSX_PACKAGE_LOCATION translations)
82 set_source_files_properties(
83 "${qBittorrent_SOURCE_DIR}/dist/mac/qt.conf"
84 "${qBittorrent_SOURCE_DIR}/dist/mac/qBitTorrentDocument.icns"
85 "${qBittorrent_SOURCE_DIR}/dist/mac/qbittorrent_mac.icns"
87 MACOSX_PACKAGE_LOCATION Resources
89 # provide variables for substitution in dist/mac/Info.plist
90 get_target_property(EXECUTABLE_NAME qbt_app OUTPUT_NAME)
91 # This variable name should be changed once qmake is no longer used. Refer to the discussion in PR #14813
92 set(MACOSX_DEPLOYMENT_TARGET ${CMAKE_OSX_DEPLOYMENT_TARGET})
93 set_target_properties(qbt_app PROPERTIES
95 MACOSX_BUNDLE_BUNDLE_NAME "qBittorrent"
96 MACOSX_BUNDLE_INFO_PLIST ${qBittorrent_SOURCE_DIR}/dist/mac/Info.plist
98 target_sources(qbt_app PRIVATE
100 ${qBittorrent_SOURCE_DIR}/dist/mac/qt.conf
101 ${qBittorrent_SOURCE_DIR}/dist/mac/qBitTorrentDocument.icns
102 ${qBittorrent_SOURCE_DIR}/dist/mac/qbittorrent_mac.icns
104 elseif (CMAKE_SYSTEM_NAME STREQUAL "Windows")
105 set_target_properties(qbt_app PROPERTIES WIN32_EXECUTABLE ON)
107 target_sources(qbt_app PRIVATE ${qBittorrent_SOURCE_DIR}/src/qbittorrent_mingw.rc)
109 target_sources(qbt_app PRIVATE ${qBittorrent_SOURCE_DIR}/src/qbittorrent.rc)
111 target_sources(qbt_app PRIVATE ${qBittorrent_SOURCE_DIR}/src/qbittorrent.exe.manifest)
114 # Additional feature dependent configuration
115 # -----------------------------------------------------------------------------
116 # -----------------------------------------------------------------------------
118 target_link_libraries(qbt_app PRIVATE qbt_gui)
119 if ((CMAKE_SYSTEM_NAME STREQUAL "Windows") OR (CMAKE_SYSTEM_NAME STREQUAL "Darwin"))
120 qt_import_plugins(qbt_app INCLUDE Qt::QSvgIconPlugin Qt::QSvgPlugin)
125 target_compile_definitions(qbt_app PRIVATE STACKTRACE)
127 target_sources(qbt_app PRIVATE
132 if (CMAKE_SYSTEM_NAME STREQUAL "Darwin")
133 target_compile_definitions(qbt_app PRIVATE BOOST_STACKTRACE_GNU_SOURCE_NOT_REQUIRED)
134 target_link_options(qbt_app PUBLIC -rdynamic)
135 elseif (CMAKE_SYSTEM_NAME STREQUAL "Linux")
136 target_link_libraries(qbt_app PUBLIC ${CMAKE_DL_LIBS})
137 target_link_options(qbt_app PUBLIC -rdynamic)
138 elseif (CMAKE_SYSTEM_NAME STREQUAL "Windows")
140 target_compile_options(qbt_app PRIVATE /Zi)
141 target_link_options(qbt_app PUBLIC
143 /PDBALTPATH:$<TARGET_PDB_FILE_NAME:qbt_app>
146 target_link_options(qbt_app PUBLIC LINKER:--export-dynamic)
148 if (CMAKE_SIZEOF_VOID_P EQUAL 4)
149 target_compile_options(qbt_app PRIVATE -fno-omit-frame-pointer)
156 target_sources(qbt_app PRIVATE
157 ${QBT_WEBUI_QM_FILES}
158 ${qBittorrent_BINARY_DIR}/src/webui/www/translations/webui_translations.qrc # yes, it's supposed to be "*_BINARY_DIR"
160 target_link_libraries(qbt_app PRIVATE qbt_webui)
164 # -----------------------------------------------------------------------------
165 # -----------------------------------------------------------------------------
166 install(TARGETS qbt_app
167 RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}
173 install(FILES $<TARGET_PDB_FILE:qbt_app>
174 DESTINATION ${CMAKE_INSTALL_BINDIR}