CMakeLists.txt 5.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171
  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/plistparser
  6. ${CMAKE_SOURCE_DIR}/src/player
  7. shared
  8. )
  9. set(CMAKE_AUTOMOC ON)
  10. add_definitions(-DPREFIX="${CMAKE_INSTALL_PREFIX}")
  11. find_package(Breakpad)
  12. if(BREAKPAD_FOUND)
  13. include_directories(${BREAKPAD_INCLUDE_DIR})
  14. set(BREAKPAD_LIBRARIES ${BREAKPAD_LIBRARY})
  15. if(UNIX)
  16. # cmake issue: breakpad-client.pc adds this, but cmake discards it
  17. set(BREAKPAD_LIBRARIES ${BREAKPAD_LIBRARIES} -lpthread)
  18. endif()
  19. endif()
  20. add_subdirectory(shared)
  21. add_subdirectory(display)
  22. add_subdirectory(player)
  23. add_subdirectory(utils)
  24. add_subdirectory(server)
  25. add_subdirectory(ui)
  26. add_subdirectory(input)
  27. add_subdirectory(system)
  28. add_subdirectory(breakpad)
  29. add_subdirectory(settings)
  30. add_subdirectory(power)
  31. add_subdirectory(remote)
  32. add_subdirectory(tools)
  33. get_property(ALL_SRCS GLOBAL PROPERTY SRCS_LIST)
  34. set(MAIN_SRCS
  35. Version.h
  36. ComponentManager.cpp
  37. ComponentManager.h
  38. main.cpp
  39. )
  40. # add unix signal management classes
  41. if (UNIX)
  42. set(MAIN_SRCS ${MAIN_SRCS}
  43. SignalManager.h
  44. SignalManager.cpp
  45. )
  46. endif()
  47. source_group("Source Files" FILES ${MAIN_SRCS})
  48. set(SOURCES ${MAIN_SRCS} ${ALL_SRCS})
  49. # Set some Objective-C flags.
  50. # We need to force the Language to C instead of C++
  51. # and also make sure that we use ARC
  52. #
  53. foreach(S ${SOURCES})
  54. string(REGEX MATCH ".*\\.m$" MATCH_OBJC ${S})
  55. if(MATCH_OBJC)
  56. set_property(SOURCE ${S} PROPERTY COMPILE_FLAGS "-fobjc-arc")
  57. set_property(SOURCE ${S} PROPERTY LANGUAGE C)
  58. endif()
  59. endforeach(S SOURCE)
  60. foreach(sfile in ${ALL_SRCS})
  61. get_filename_component(REALNAME ${sfile} REALPATH)
  62. get_filename_component(DIRNAME ${REALNAME} DIRECTORY)
  63. string(REPLACE "${CMAKE_SOURCE_DIR}/src/" "" SUBDIR ${DIRNAME})
  64. string(TOLOWER ${SUBDIR} SUBDIR)
  65. string(REPLACE "/" "\\\\" GNAME ${SUBDIR})
  66. source_group("Source Files\\\\${GNAME}" FILES ${sfile})
  67. endforeach(sfile in ${ALL_SRCS})
  68. file(GLOB_RECURSE RESOURCE_FILES ${CMAKE_SOURCE_DIR}/resources/*)
  69. # generate resources.qrc from directory tree listings
  70. add_custom_command(OUTPUT resources.qrc
  71. COMMAND ${PYTHON_EXECUTABLE} ${CMAKE_SOURCE_DIR}/scripts/build-qt-resources.py
  72. ${CMAKE_CURRENT_BINARY_DIR}/resources.qrc
  73. /=${CMAKE_SOURCE_DIR}/resources/
  74. ui/webview.qml=${CMAKE_SOURCE_DIR}/src/ui/webview.qml
  75. COMMENT "Creating resources.qrc"
  76. DEPENDS ${CMAKE_SOURCE_DIR}/scripts/build-qt-resources.py
  77. ${RESOURCE_FILES}
  78. ${CMAKE_SOURCE_DIR}/src/ui/webview.qml
  79. )
  80. set_source_files_properties(resources.qrc PROPERTIES GENERATED TRUE)
  81. add_custom_command(OUTPUT qrc_resources.cpp
  82. COMMAND ${Qt5Core_RCC_EXECUTABLE} -name resources -o qrc_resources.cpp resources.qrc
  83. DEPENDS resources.qrc ${CMAKE_SOURCE_DIR}/src/ui/webview.qml ${RESOURCE_FILES}
  84. )
  85. set_source_files_properties(qrc_resources.cpp PROPERTIES GENERATED TRUE)
  86. # handle Web-Client resource
  87. include(WebClientResources)
  88. set_source_files_properties(${PROJECT_SOURCE_DIR}/bundle/osx/Plex.icns PROPERTIES MACOSX_PACKAGE_LOCATION Resources)
  89. list(APPEND RESOURCE_FILES qrc_resources.cpp ${WEB_CLIENT_CPP})
  90. if(APPLE)
  91. list(APPEND RESOURCE_FILES ${PROJECT_SOURCE_DIR}/bundle/osx/Plex.icns)
  92. if(HAVE_UPDATER)
  93. list(APPEND RESOURCE_FILES ${UPDATER_PATH})
  94. set_source_files_properties(${UPDATER_PATH} PROPERTIES MACOSX_PACKAGE_LOCATION Resources)
  95. endif(HAVE_UPDATER)
  96. set(PLISTPARSER plistparser)
  97. endif()
  98. set(MACOSX_BUNDLE_ICON_FILE Plex.icns)
  99. set(MACOSX_BUNDLE_SHORT_VERSION_STRING ${VERSION_STRING})
  100. set(MACOSX_BUNDLE_BUNDLE_NAME "Plex Media Player")
  101. set(MACOSX_BUNDLE_BUNDLE_VERSION ${VERSION_STRING})
  102. set(MACOSX_BUNDLE_GUI_IDENTIFIER tv.plex.player)
  103. if(WIN32)
  104. list(APPEND RESOURCE_FILES ${CMAKE_SOURCE_DIR}/bundle/win/iconres.rc)
  105. endif()
  106. get_property(BUNDLED_FILES GLOBAL PROPERTY CONFIG_BUNDLED_FILES)
  107. add_executable(${MAIN_TARGET} WIN32 MACOSX_BUNDLE ${SOURCES} ${BUNDLED_FILES} ${RESOURCE_FILES})
  108. set_target_properties(${MAIN_TARGET} PROPERTIES
  109. MACOSX_BUNDLE_INFO_PLIST ${CMAKE_SOURCE_DIR}/bundle/osx/Info.plist.in
  110. INSTALL_RPATH "${QTROOT}/lib"
  111. OUTPUT_NAME ${MAIN_NAME}
  112. CXX_STANDARD 11
  113. CXX_STANDARD_REQUIRED TRUE
  114. )
  115. # copy the qt.conf so that when running PMP from a debugger it finds the plugins and QML files
  116. if(APPLE)
  117. add_custom_command(
  118. TARGET ${MAIN_TARGET} POST_BUILD
  119. COMMAND ${CMAKE_COMMAND} -E copy ${QTROOT}/bin/qt.conf $<TARGET_FILE_DIR:${MAIN_TARGET}>/../Resources
  120. COMMENT "Copy qt.conf to main bundle"
  121. )
  122. endif(APPLE)
  123. target_link_libraries(${MAIN_TARGET}
  124. shared
  125. qhttp
  126. qslog
  127. ${PLISTPARSER}
  128. ${MPV_LIBRARY}
  129. ${OPENGL_LIBS}
  130. ${QT5_LIBRARIES}
  131. ${OS_LIBS}
  132. ${EXTRA_LIBS}
  133. ${X11_LIBRARIES}
  134. ${X11_Xrandr_LIB}
  135. ${BREAKPAD_LIBRARIES}
  136. ${ICU_LIBRARIES}
  137. ${CMAKE_THREAD_LIBS_INIT}
  138. ${RPI_LIBS}
  139. )
  140. install(TARGETS ${MAIN_TARGET} DESTINATION ${INSTALL_BIN_DIR})
  141. set(EXE "${MAIN_NAME}.app")
  142. set(LIBPATH ${CMAKE_FIND_ROOT_PATH})
  143. set(SOURCE_ROOT ${CMAKE_SOURCE_DIR})
  144. dumpsyms(${MAIN_TARGET} ${CMAKE_BINARY_DIR}/${MAIN_TARGET}.symbols)
  145. include(CompleteBundle)