CMakeLists.txt 6.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212
  1. include_directories(
  2. ${CMAKE_SOURCE_DIR}/external/qhttp/src
  3. ${CMAKE_SOURCE_DIR}/external/qslog
  4. ${CMAKE_SOURCE_DIR}/external/SPMediaKeyTap
  5. ${CMAKE_SOURCE_DIR}/external/HIDRemote
  6. ${CMAKE_SOURCE_DIR}/external/plistparser
  7. ${CMAKE_SOURCE_DIR}/external/letsmove
  8. ${CMAKE_SOURCE_DIR}/src/player
  9. core
  10. shared
  11. )
  12. set(CMAKE_AUTOMOC ON)
  13. add_definitions(-DPREFIX="${CMAKE_INSTALL_PREFIX}")
  14. find_package(Breakpad)
  15. if(BREAKPAD_FOUND)
  16. include_directories(${BREAKPAD_INCLUDE_DIR})
  17. set(BREAKPAD_LIBRARIES ${BREAKPAD_LIBRARY})
  18. if(UNIX)
  19. # cmake issue: breakpad-client.pc adds this, but cmake discards it
  20. set(BREAKPAD_LIBRARIES ${BREAKPAD_LIBRARIES} -lpthread)
  21. endif()
  22. endif()
  23. add_subdirectory(shared)
  24. add_subdirectory(core)
  25. add_subdirectory(display)
  26. add_subdirectory(player)
  27. add_subdirectory(utils)
  28. add_subdirectory(server)
  29. add_subdirectory(ui)
  30. add_subdirectory(input)
  31. add_subdirectory(system)
  32. add_subdirectory(breakpad)
  33. add_subdirectory(settings)
  34. add_subdirectory(power)
  35. add_subdirectory(remote)
  36. add_subdirectory(tools)
  37. get_property(ALL_SRCS GLOBAL PROPERTY SRCS_LIST)
  38. set(MAIN_SRCS main.cpp)
  39. source_group("Source Files" FILES ${MAIN_SRCS})
  40. set(SOURCES ${MAIN_SRCS} ${ALL_SRCS})
  41. # Set some Objective-C flags.
  42. # We need to force the Language to C instead of C++
  43. # and also make sure that we use ARC
  44. #
  45. foreach(S ${SOURCES})
  46. string(REGEX MATCH ".*\\.m$" MATCH_OBJC ${S})
  47. if(MATCH_OBJC)
  48. set_property(SOURCE ${S} PROPERTY COMPILE_FLAGS "-fobjc-arc")
  49. set_property(SOURCE ${S} PROPERTY LANGUAGE C)
  50. endif()
  51. endforeach(S SOURCE)
  52. foreach(sfile in ${ALL_SRCS})
  53. get_filename_component(REALNAME ${sfile} REALPATH)
  54. get_filename_component(DIRNAME ${REALNAME} DIRECTORY)
  55. string(REPLACE "${CMAKE_SOURCE_DIR}/src/" "" SUBDIR ${DIRNAME})
  56. string(TOLOWER ${SUBDIR} SUBDIR)
  57. string(REPLACE "/" "\\\\" GNAME ${SUBDIR})
  58. source_group("Source Files\\\\${GNAME}" FILES ${sfile})
  59. endforeach(sfile in ${ALL_SRCS})
  60. file(GLOB_RECURSE RESOURCE_FILES ${CMAKE_SOURCE_DIR}/resources/*)
  61. # generate resources.qrc from directory tree listings
  62. add_custom_command(OUTPUT resources.qrc
  63. COMMAND ${PYTHON_EXECUTABLE} ${CMAKE_SOURCE_DIR}/scripts/build-qt-resources.py
  64. ${CMAKE_CURRENT_BINARY_DIR}/resources.qrc
  65. /=${CMAKE_SOURCE_DIR}/resources/
  66. ui/webview.qml=${CMAKE_SOURCE_DIR}/src/ui/webview.qml
  67. COMMENT "Creating resources.qrc"
  68. DEPENDS ${CMAKE_SOURCE_DIR}/scripts/build-qt-resources.py
  69. ${RESOURCE_FILES}
  70. ${CMAKE_SOURCE_DIR}/src/ui/webview.qml
  71. )
  72. set_source_files_properties(resources.qrc PROPERTIES GENERATED TRUE)
  73. add_custom_command(OUTPUT qrc_resources.cpp
  74. COMMAND ${Qt5Core_RCC_EXECUTABLE} -name resources -o qrc_resources.cpp resources.qrc
  75. DEPENDS resources.qrc ${CMAKE_SOURCE_DIR}/src/ui/webview.qml ${RESOURCE_FILES}
  76. )
  77. set_source_files_properties(qrc_resources.cpp PROPERTIES GENERATED TRUE)
  78. list(APPEND RESOURCE_FILES qrc_resources.cpp)
  79. set(MACOSX_BUNDLE_ICON_FILE Plex.icns)
  80. set(MACOSX_BUNDLE_SHORT_VERSION_STRING ${VERSION_STRING})
  81. set(MACOSX_BUNDLE_BUNDLE_NAME "Plex Media Player")
  82. set(MACOSX_BUNDLE_BUNDLE_VERSION ${VERSION_STRING})
  83. set(MACOSX_BUNDLE_GUI_IDENTIFIER tv.plex.player)
  84. if(APPLE)
  85. if(HAVE_UPDATER)
  86. add_resources(TARGET ${MAIN_TARGET} SOURCES ${UPDATER_PATH} DEST ${INSTALL_RESOURCE_DIR})
  87. endif(HAVE_UPDATER)
  88. set_source_files_properties(
  89. input/apple/HIDRemote/HIDRemote.m
  90. PROPERTIES COMPILE_FLAGS -fno-objc-arc
  91. )
  92. # copy the qt.conf so that when running PMP from a debugger it finds the plugins and QML files
  93. if(EXISTS ${QTROOT}/bin/qt.conf)
  94. add_resources(TARGET ${MAIN_TARGET} SOURCES ${QTROOT}/bin/qt.conf DEST ${INSTALL_RESOURCE_DIR})
  95. endif()
  96. set(ICON_FILE ${CMAKE_SOURCE_DIR}/bundle/osx/${MACOSX_BUNDLE_ICON_FILE})
  97. list(APPEND RESOURCE_FILES ${ICON_FILE})
  98. set_source_files_properties(${ICON_FILE} PROPERTIES MACOSX_PACKAGE_LOCATION "Resources")
  99. endif()
  100. if(WIN32)
  101. list(APPEND RESOURCE_FILES ${CMAKE_SOURCE_DIR}/bundle/win/iconres.rc)
  102. endif()
  103. set(RESOURCE_ROOT .)
  104. if(APPLE)
  105. set(RESOURCE_ROOT Resources)
  106. endif()
  107. if(NOT DEFINED CONAN_WEB-CLIENT-TV_ROOT)
  108. message(FATAL_ERROR "Could not find the web-client! Run conan!")
  109. endif()
  110. add_resources(TARGET ${MAIN_TARGET} SOURCES ${CONAN_WEB-CLIENT-TV_ROOT}/tv DEST ${RESOURCE_ROOT}/web-client/tv)
  111. if(DEFINED CONAN_WEB-CLIENT-DESKTOP_ROOT)
  112. add_resources(TARGET ${MAIN_TARGET} SOURCES ${CONAN_WEB-CLIENT-DESKTOP_ROOT}/desktop DEST ${RESOURCE_ROOT}/web-client/desktop)
  113. endif()
  114. if(NOT APPLE)
  115. install(FILES ${QTROOT}/resources/qtwebengine_devtools_resources.pak DESTINATION resources)
  116. install(DIRECTORY ${CONAN_WEB-CLIENT-TV_ROOT}/tv DESTINATION ${INSTALL_RESOURCE_DIR}/web-client)
  117. if(DEFINED CONAN_WEB-CLIENT-DESKTOP_ROOT)
  118. install(DIRECTORY ${CONAN_WEB-CLIENT-DESKTOP_ROOT}/desktop DESTINATION ${INSTALL_RESOURCE_DIR}/web-client)
  119. endif()
  120. endif()
  121. if(XCODE)
  122. get_resources_source_list(${MAIN_TARGET} XCODE_RESOURCES)
  123. endif()
  124. get_property(BUNDLED_FILES GLOBAL PROPERTY CONFIG_BUNDLED_FILES)
  125. add_executable(${MAIN_TARGET} WIN32 MACOSX_BUNDLE ${SOURCES} ${BUNDLED_FILES} ${RESOURCE_FILES} ${XCODE_RESOURCES})
  126. std_target_properties(${MAIN_TARGET})
  127. set_target_properties(${MAIN_TARGET} PROPERTIES
  128. MACOSX_BUNDLE_INFO_PLIST ${CMAKE_SOURCE_DIR}/bundle/osx/Info.plist.in
  129. INSTALL_RPATH "${QTROOT}/lib"
  130. OUTPUT_NAME ${MAIN_NAME}
  131. )
  132. copy_resources(${MAIN_TARGET})
  133. clang_tidy(${MAIN_TARGET})
  134. find_library(MINIZIP_LIBRARY minizip)
  135. if(WIN32)
  136. # FindZLIB doesn't find this. (It might be possible to fix the minizip build
  137. # to not require this.)
  138. find_library(ZLIB_LIBRARIES zlibwapi)
  139. if(ZLIB_LIBRARIES)
  140. set(ZLIB_FOUND on)
  141. endif()
  142. else()
  143. include(FindZLIB)
  144. endif()
  145. if(ZLIB_FOUND AND MINIZIP_LIBRARY)
  146. message(STATUS "Using minizip")
  147. set(MINIZIP_LIBS ${MINIZIP_LIBRARY} ${ZLIB_LIBRARIES})
  148. add_definitions(-DHAVE_MINIZIP)
  149. else()
  150. if(ENABLE_CODECS)
  151. if (ZLIB_FOUND)
  152. message(FATAL_ERROR "minizip required in this configuration")
  153. else()
  154. message(FATAL_ERROR "zlib required in this configuration")
  155. endif()
  156. endif()
  157. endif()
  158. target_link_libraries(${MAIN_TARGET}
  159. shared
  160. qhttp
  161. qslog
  162. ${MPV_LIBRARY}
  163. ${OPENGL_LIBS}
  164. ${QT5_LIBRARIES}
  165. ${OS_LIBS}
  166. ${EXTRA_LIBS}
  167. ${X11_LIBRARIES}
  168. ${X11_Xrandr_LIB}
  169. ${BREAKPAD_LIBRARIES}
  170. ${ICU_LIBRARIES}
  171. ${CMAKE_THREAD_LIBS_INIT}
  172. ${RPI_LIBS}
  173. ${MINIZIP_LIBS}
  174. )
  175. install(TARGETS ${MAIN_TARGET} DESTINATION ${INSTALL_BIN_DIR})
  176. set(EXE "${MAIN_NAME}.app")
  177. set(LIBPATH ${CMAKE_FIND_ROOT_PATH})
  178. set(SOURCE_ROOT ${CMAKE_SOURCE_DIR})
  179. dumpsyms(${MAIN_TARGET} ${CMAKE_BINARY_DIR}/${MAIN_TARGET}.symbols)
  180. include(CompleteBundle)