Sync translations from Transifex and run lupdate
[qBittorrent.git] / src / app / CMakeLists.txt
blob036e5d9990fc6c34fa8b019971acdc2243a23c1a
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)
10 if (WEBUI)
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)
17 endif()
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")
22 endforeach()
24 # Executable target configuration
25 # -----------------------------------------------------------------------------
26 # -----------------------------------------------------------------------------
27 add_executable(qbt_app)
29 target_sources(qbt_app PRIVATE
30     # headers
31     application.h
32     applicationinstancemanager.h
33     cmdoptions.h
34     filelogger.h
35     qtlocalpeer/qtlocalpeer.h
36     upgrade.h
38     # sources
39     application.cpp
40     applicationinstancemanager.cpp
41     cmdoptions.cpp
42     filelogger.cpp
43     main.cpp
44     qtlocalpeer/qtlocalpeer.cpp
45     upgrade.cpp
47     # resources
48     "${qBittorrent_SOURCE_DIR}/src/icons/icons.qrc"
49     "${qBittorrent_SOURCE_DIR}/src/searchengine/searchengine.qrc"
50     ${QBT_QM_FILES}
51     "${qBittorrent_BINARY_DIR}/src/lang/lang.qrc" # yes, it's supposed to be "*_BINARY_DIR"
54 target_link_libraries(qbt_app PRIVATE
55     qbt_base
58 set_target_properties(qbt_app PROPERTIES RUNTIME_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}")
59 if (GUI)
60     set_target_properties(qbt_app PROPERTIES OUTPUT_NAME qbittorrent)
61 else()
62     set_target_properties(qbt_app PROPERTIES OUTPUT_NAME qbittorrent-nox)
63 endif()
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"
73         PROPERTIES
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
83         MACOSX_BUNDLE ON
84         MACOSX_BUNDLE_BUNDLE_NAME "qBittorrent"
85         MACOSX_BUNDLE_INFO_PLIST ${qBittorrent_SOURCE_DIR}/dist/mac/Info.plist
86     )
87     target_sources(qbt_app PRIVATE
88         ${QT_TRANSLATIONS}
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
92     )
93 elseif (CMAKE_SYSTEM_NAME STREQUAL "Windows")
94     set_target_properties(qbt_app PROPERTIES WIN32_EXECUTABLE ON)
95     if (MINGW)
96         target_sources(qbt_app PRIVATE ${qBittorrent_SOURCE_DIR}/src/qbittorrent_mingw.rc)
97     else()
98         target_sources(qbt_app PRIVATE ${qBittorrent_SOURCE_DIR}/src/qbittorrent.rc)
99     endif()
100     target_sources(qbt_app PRIVATE ${qBittorrent_SOURCE_DIR}/src/qbittorrent.exe.manifest)
101 endif()
103 # Additional feature dependent configuration
104 # -----------------------------------------------------------------------------
105 # -----------------------------------------------------------------------------
106 if (STACKTRACE)
107     target_compile_definitions(qbt_app PRIVATE STACKTRACE)
109     if (CMAKE_SYSTEM_NAME STREQUAL "Windows")
110         target_sources(qbt_app PRIVATE stacktrace_win.h)
112         if (GUI)
113             qt_wrap_ui(STACKTRACE_UI_HEADERS stacktracedialog.ui)
115             target_sources(qbt_app PRIVATE
116                 stacktracedialog.h
117                 stacktracedialog.cpp
118                 ${STACKTRACE_UI_HEADERS}
119             )
121             # UI headers will be generated in ${CMAKE_CURRENT_BINARY_DIR}
122             target_include_directories(qbt_app PRIVATE
123                 ${CMAKE_CURRENT_BINARY_DIR}
124             )
125         endif()
127         # i686 arch on Windows requires frame pointer preservation
128         if (MSVC)
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)
133             endif()
134         else()
135             if (CMAKE_SIZEOF_VOID_P EQUAL 4)
136                 target_compile_options(qbt_app PRIVATE -fno-omit-frame-pointer)
137             endif()
138         endif()
140         target_link_libraries(qbt_app PUBLIC dbghelp)
141     else()
142         target_sources(qbt_app PRIVATE stacktrace.h)
143     endif()
144 endif()
146 if (GUI)
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)
150     endif()
151 endif()
153 if (WEBUI)
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"
157     )
158     target_link_libraries(qbt_app PRIVATE qbt_webui)
159 endif()
161 # Installation
162 # -----------------------------------------------------------------------------
163 # -----------------------------------------------------------------------------
164 install(TARGETS qbt_app
165     RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}
166     BUNDLE  DESTINATION .
167     COMPONENT runtime
170 if (MSVC)
171     install(FILES $<TARGET_PDB_FILE:qbt_app>
172         DESTINATION ${CMAKE_INSTALL_BINDIR}
173         OPTIONAL
174     )
175 endif()