WebAPI: Add `forced` parameter to `torrents/add`
[qBittorrent.git] / src / app / CMakeLists.txt
blobb5174aa45b168f6512c96d8a2e5b14f10bf64cfe
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}
8                                                      -ts ${QBT_TS_FILES}
9                     WORKING_DIRECTORY "${qBittorrent_SOURCE_DIR}"
10                     VERBATIM
11                     COMMAND_EXPAND_LISTS)
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)
21 if (WEBUI)
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)
28 endif()
30 # Executable target configuration
31 # -----------------------------------------------------------------------------
32 # -----------------------------------------------------------------------------
33 add_executable(qbt_app)
35 target_sources(qbt_app PRIVATE
36     # headers
37     application.h
38     applicationinstancemanager.h
39     cmdoptions.h
40     filelogger.h
41     legalnotice.h
42     qtlocalpeer/qtlocalpeer.h
43     signalhandler.h
44     upgrade.h
46     # sources
47     application.cpp
48     applicationinstancemanager.cpp
49     cmdoptions.cpp
50     filelogger.cpp
51     legalnotice.cpp
52     main.cpp
53     qtlocalpeer/qtlocalpeer.cpp
54     signalhandler.cpp
55     upgrade.cpp
57     # resources
58     "${qBittorrent_SOURCE_DIR}/src/icons/icons.qrc"
59     "${qBittorrent_SOURCE_DIR}/src/searchengine/searchengine.qrc"
60     ${QBT_QM_FILES}
61     "${qBittorrent_BINARY_DIR}/src/lang/lang.qrc" # yes, it's supposed to be "*_BINARY_DIR"
64 target_link_libraries(qbt_app PRIVATE
65     qbt_base
68 set_target_properties(qbt_app PROPERTIES RUNTIME_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}")
69 if (GUI)
70     set_target_properties(qbt_app PROPERTIES OUTPUT_NAME qbittorrent)
71 else()
72     set_target_properties(qbt_app PROPERTIES OUTPUT_NAME qbittorrent-nox)
73 endif()
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"
86             PROPERTIES
87                 MACOSX_PACKAGE_LOCATION Resources
88     )
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
94         MACOSX_BUNDLE ON
95         MACOSX_BUNDLE_BUNDLE_NAME "qBittorrent"
96         MACOSX_BUNDLE_INFO_PLIST ${qBittorrent_SOURCE_DIR}/dist/mac/Info.plist
97     )
98     target_sources(qbt_app PRIVATE
99         ${QT_TRANSLATIONS}
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
103     )
104 elseif (CMAKE_SYSTEM_NAME STREQUAL "Windows")
105     set_target_properties(qbt_app PROPERTIES WIN32_EXECUTABLE ON)
106     if (MINGW)
107         target_sources(qbt_app PRIVATE ${qBittorrent_SOURCE_DIR}/src/qbittorrent_mingw.rc)
108     else()
109         target_sources(qbt_app PRIVATE ${qBittorrent_SOURCE_DIR}/src/qbittorrent.rc)
110     endif()
111     target_sources(qbt_app PRIVATE ${qBittorrent_SOURCE_DIR}/src/qbittorrent.exe.manifest)
112 endif()
114 # Additional feature dependent configuration
115 # -----------------------------------------------------------------------------
116 # -----------------------------------------------------------------------------
117 if (GUI)
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)
121     endif()
122 endif()
124 if (STACKTRACE)
125     target_compile_definitions(qbt_app PRIVATE STACKTRACE)
127     target_sources(qbt_app PRIVATE
128         stacktrace.h
129         stacktrace.cpp
130     )
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")
139         if (MSVC)
140             target_compile_options(qbt_app PRIVATE /Zi)
141             target_link_options(qbt_app PUBLIC
142                 /DEBUG
143                 /PDBALTPATH:$<TARGET_PDB_FILE_NAME:qbt_app>
144             )
145         else()
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)
150             endif()
151         endif()
152     endif()
153 endif()
155 if (WEBUI)
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"
159     )
160     target_link_libraries(qbt_app PRIVATE qbt_webui)
161 endif()
163 # Installation
164 # -----------------------------------------------------------------------------
165 # -----------------------------------------------------------------------------
166 install(TARGETS qbt_app
167     RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}
168     BUNDLE  DESTINATION .
169     COMPONENT runtime
172 if (MSVC)
173     install(FILES $<TARGET_PDB_FILE:qbt_app>
174         DESTINATION ${CMAKE_INSTALL_BINDIR}
175         OPTIONAL
176     )
177 endif()