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 -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 -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
41 qtlocalpeer/qtlocalpeer.h
47 applicationinstancemanager.cpp
51 qtlocalpeer/qtlocalpeer.cpp
56 "${qBittorrent_SOURCE_DIR}/src/icons/icons.qrc"
57 "${qBittorrent_SOURCE_DIR}/src/searchengine/searchengine.qrc"
59 "${qBittorrent_BINARY_DIR}/src/lang/lang.qrc" # yes, it's supposed to be "*_BINARY_DIR"
62 target_link_libraries(qbt_app PRIVATE
66 set_target_properties(qbt_app PROPERTIES RUNTIME_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}")
68 set_target_properties(qbt_app PROPERTIES OUTPUT_NAME qbittorrent)
70 set_target_properties(qbt_app PROPERTIES OUTPUT_NAME qbittorrent-nox)
73 # Additional platform specific configuration
74 # -----------------------------------------------------------------------------
75 # -----------------------------------------------------------------------------
76 if (CMAKE_SYSTEM_NAME STREQUAL "Darwin")
77 include(FindQtTranslations)
78 qbt_get_qt_translations(QT_TRANSLATIONS)
79 set_source_files_properties(${QT_TRANSLATIONS} PROPERTIES MACOSX_PACKAGE_LOCATION translations)
80 set_source_files_properties(
81 "${qBittorrent_SOURCE_DIR}/dist/mac/qt.conf"
82 "${qBittorrent_SOURCE_DIR}/dist/mac/qBitTorrentDocument.icns"
83 "${qBittorrent_SOURCE_DIR}/dist/mac/qbittorrent_mac.icns"
85 MACOSX_PACKAGE_LOCATION Resources
87 # provide variables for substitution in dist/mac/Info.plist
88 get_target_property(EXECUTABLE_NAME qbt_app OUTPUT_NAME)
89 # This variable name should be changed once qmake is no longer used. Refer to the discussion in PR #14813
90 set(MACOSX_DEPLOYMENT_TARGET ${CMAKE_OSX_DEPLOYMENT_TARGET})
91 set_target_properties(qbt_app PROPERTIES
93 MACOSX_BUNDLE_BUNDLE_NAME "qBittorrent"
94 MACOSX_BUNDLE_INFO_PLIST ${qBittorrent_SOURCE_DIR}/dist/mac/Info.plist
96 target_sources(qbt_app PRIVATE
98 ${qBittorrent_SOURCE_DIR}/dist/mac/qt.conf
99 ${qBittorrent_SOURCE_DIR}/dist/mac/qBitTorrentDocument.icns
100 ${qBittorrent_SOURCE_DIR}/dist/mac/qbittorrent_mac.icns
102 elseif (CMAKE_SYSTEM_NAME STREQUAL "Windows")
103 set_target_properties(qbt_app PROPERTIES WIN32_EXECUTABLE ON)
105 target_sources(qbt_app PRIVATE ${qBittorrent_SOURCE_DIR}/src/qbittorrent_mingw.rc)
107 target_sources(qbt_app PRIVATE ${qBittorrent_SOURCE_DIR}/src/qbittorrent.rc)
109 target_sources(qbt_app PRIVATE ${qBittorrent_SOURCE_DIR}/src/qbittorrent.exe.manifest)
112 # Additional feature dependent configuration
113 # -----------------------------------------------------------------------------
114 # -----------------------------------------------------------------------------
116 target_link_libraries(qbt_app PRIVATE qbt_gui)
117 if ((CMAKE_SYSTEM_NAME STREQUAL "Windows") OR (CMAKE_SYSTEM_NAME STREQUAL "Darwin"))
118 qt_import_plugins(qbt_app INCLUDE Qt::QSvgIconPlugin Qt::QSvgPlugin)
123 target_compile_definitions(qbt_app PRIVATE STACKTRACE)
125 target_sources(qbt_app PRIVATE
130 if (CMAKE_SYSTEM_NAME STREQUAL "Darwin")
131 target_compile_definitions(qbt_app PRIVATE BOOST_STACKTRACE_GNU_SOURCE_NOT_REQUIRED)
132 target_link_options(qbt_app PUBLIC -rdynamic)
133 elseif (CMAKE_SYSTEM_NAME STREQUAL "Linux")
134 target_link_libraries(qbt_app PUBLIC ${CMAKE_DL_LIBS})
135 target_link_options(qbt_app PUBLIC -rdynamic)
136 elseif (CMAKE_SYSTEM_NAME STREQUAL "Windows")
138 target_compile_options(qbt_app PRIVATE /Zi)
139 target_link_options(qbt_app PUBLIC
141 /PDBALTPATH:$<TARGET_PDB_FILE_NAME:qbt_app>
144 if (CMAKE_SIZEOF_VOID_P EQUAL 4)
145 target_compile_options(qbt_app PRIVATE /Oy-)
148 target_link_options(qbt_app PUBLIC LINKER:--export-dynamic)
150 if (CMAKE_SIZEOF_VOID_P EQUAL 4)
151 target_compile_options(qbt_app PRIVATE -fno-omit-frame-pointer)
158 target_sources(qbt_app PRIVATE
159 ${QBT_WEBUI_QM_FILES}
160 ${qBittorrent_BINARY_DIR}/src/webui/www/translations/webui_translations.qrc # yes, it's supposed to be "*_BINARY_DIR"
162 target_link_libraries(qbt_app PRIVATE qbt_webui)
166 # -----------------------------------------------------------------------------
167 # -----------------------------------------------------------------------------
168 install(TARGETS qbt_app
169 RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}
175 install(FILES $<TARGET_PDB_FILE:qbt_app>
176 DESTINATION ${CMAKE_INSTALL_BINDIR}