Specify Unicode for resource block (#15370)
[qBittorrent.git] / src / app / CMakeLists.txt
blobc43600fdd6cbf5e590a63f07b78be53b3f7ff0b3
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 qt5_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     qt5_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             target_sources(qbt_app PRIVATE
114                 stacktracedialog.h
115                 stacktracedialog.cpp
116                 stacktracedialog.ui
117             )
118         endif()
120         # i686 arch on Windows requires frame pointer preservation
121         if (MSVC)
122             target_compile_options(qbt_app PRIVATE /Zi)
123             target_link_options(qbt_app PUBLIC LINKER:/DEBUG)
124             if (CMAKE_SIZEOF_VOID_P EQUAL 4)
125                 target_compile_options(qbt_app PRIVATE /Oy)
126             endif()
127         else()
128             if (CMAKE_SIZEOF_VOID_P EQUAL 4)
129                 target_compile_options(qbt_app PRIVATE -fno-omit-frame-pointer)
130             endif()
131         endif()
133         target_link_libraries(qbt_app PUBLIC dbghelp)
134     else()
135         target_sources(qbt_app PRIVATE stacktrace.h)
136     endif()
137 endif()
139 if (GUI)
140     target_link_libraries(qbt_app PRIVATE qbt_gui)
141     if ((CMAKE_SYSTEM_NAME STREQUAL "Windows") OR (CMAKE_SYSTEM_NAME STREQUAL "Darwin"))
142         qt_import_plugins(qbt_app INCLUDE Qt5::QSvgIconPlugin Qt5::QSvgPlugin)
143     endif()
144 endif()
146 if (WEBUI)
147     target_sources(qbt_app PRIVATE
148         ${QBT_WEBUI_QM_FILES}
149         ${qBittorrent_BINARY_DIR}/src/webui/www/translations/webui_translations.qrc # yes, it's supposed to be "*_BINARY_DIR"
150     )
151     target_link_libraries(qbt_app PRIVATE qbt_webui)
152 endif()
154 # Installation
155 # -----------------------------------------------------------------------------
156 # -----------------------------------------------------------------------------
157 install(TARGETS qbt_app
158     RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}
159     BUNDLE  DESTINATION .
160     COMPONENT runtime
163 if (MSVC)
164     install(FILES $<TARGET_PDB_FILE:qbt_app>
165         DESTINATION ${CMAKE_INSTALL_BINDIR}
166         OPTIONAL
167     )
168 endif()