CMakeLists.txt 5.0 KB

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