diff options
Diffstat (limited to 'project/cmake/CMakeLists.txt')
| -rw-r--r-- | project/cmake/CMakeLists.txt | 367 |
1 files changed, 367 insertions, 0 deletions
diff --git a/project/cmake/CMakeLists.txt b/project/cmake/CMakeLists.txt new file mode 100644 index 0000000..03b3752 --- /dev/null +++ b/project/cmake/CMakeLists.txt | |||
| @@ -0,0 +1,367 @@ | |||
| 1 | cmake_minimum_required(VERSION 3.1) | ||
| 2 | project(kodi) | ||
| 3 | |||
| 4 | list(APPEND CMAKE_MODULE_PATH ${PROJECT_SOURCE_DIR}/modules) | ||
| 5 | if(DEPENDS_DIR) | ||
| 6 | list(APPEND CMAKE_PREFIX_PATH ${DEPENDS_DIR}) | ||
| 7 | endif() | ||
| 8 | |||
| 9 | set(CMAKE_CXX_STANDARD 11) | ||
| 10 | set(CMAKE_CXX_STANDARD_REQUIRED ON) | ||
| 11 | set(CMAKE_CXX_EXTENSIONS OFF) | ||
| 12 | |||
| 13 | # general | ||
| 14 | option(VERBOSE "Enable verbose output?" OFF) | ||
| 15 | option(ENABLE_DVDCSS "Enable libdvdcss support?" ON) | ||
| 16 | option(ENABLE_UPNP "Enable UPnP support?" ON) | ||
| 17 | option(ENABLE_NONFREE "Enable non-free components?" ON) | ||
| 18 | option(ENABLE_MICROHTTPD "Enable MicroHttpd webserver?" ON) | ||
| 19 | option(ENABLE_MYSQLCLIENT "Enable MySql support?" ON) | ||
| 20 | option(ENABLE_AVAHI "Enable Avahi support?" ON) | ||
| 21 | option(ENABLE_RTMP "Enable RTMP support?" ON) | ||
| 22 | option(ENABLE_BLURAY "Enable BluRay support?" ON) | ||
| 23 | option(ENABLE_PLIST "Enable AirPlay support?" ON) | ||
| 24 | option(ENABLE_NFS "Enable NFS support?" ON) | ||
| 25 | option(ENABLE_AIRTUNES "Enable AirTunes support?" ON) | ||
| 26 | option(ENABLE_CEC "Enable CEC support?" ON) | ||
| 27 | if(UNIX) | ||
| 28 | if(NOT APPLE) | ||
| 29 | option(ENABLE_INTERNAL_FFMPEG "Enable internal ffmpeg?" ON) | ||
| 30 | else() | ||
| 31 | option(ENABLE_VTB "Enable VTB support?" OFF) | ||
| 32 | endif() | ||
| 33 | option(FFMPEG_PATH "Path to external ffmpeg?" "") | ||
| 34 | option(ENABLE_INTERNAL_CROSSGUID "Enable internal crossguid?" ON) | ||
| 35 | option(ENABLE_ALSA "Enable ALSA support?" ON) | ||
| 36 | option(ENABLE_PULSEAUDIO "Enable PulseAudio support?" ON) | ||
| 37 | option(ENABLE_DBUS "Enable dbus support?" ON) | ||
| 38 | option(ENABLE_LIBUSB "Enable libusb support?" ON) | ||
| 39 | option(ENABLE_UDEV "Enable UDev support?" ON) | ||
| 40 | option(ENABLE_OPENGL "Enable OpenGL?" ON) | ||
| 41 | option(ENABLE_OPENGLES "Enable OpenGLES?" ON) | ||
| 42 | option(ENABLE_OPENSSL "Enable OpenSSL?" ON) | ||
| 43 | option(ENABLE_SDL "Enable SDL?" OFF) | ||
| 44 | option(ENABLE_X11 "Enable X11 support?" ON) | ||
| 45 | option(ENABLE_EGL "Enable EGL?" OFF) | ||
| 46 | option(ENABLE_VAAPI "Enable VAAPI support?" ON) | ||
| 47 | option(ENABLE_VDPAU "Enable VDPAU support?" ON) | ||
| 48 | option(ENABLE_OPTICAL "Enable optical support?" ON) | ||
| 49 | endif() | ||
| 50 | # System options | ||
| 51 | if(NOT WIN32) | ||
| 52 | option(WITH_ARCH "build with given arch" OFF) | ||
| 53 | option(WITH_CPU "build with given cpu" OFF) | ||
| 54 | option(ENABLE_CCACHE "Enable Ccache support" ON) | ||
| 55 | endif() | ||
| 56 | |||
| 57 | get_filename_component(CORE_SOURCE_DIR ${PROJECT_SOURCE_DIR}/../.. ABSOLUTE) | ||
| 58 | set(CORE_BUILD_DIR build) | ||
| 59 | |||
| 60 | include(scripts/common/generatorsetup.cmake) | ||
| 61 | include(scripts/common/addoptions.cmake) | ||
| 62 | include(scripts/common/archsetup.cmake) | ||
| 63 | include(scripts/common/macros.cmake) | ||
| 64 | include(scripts/common/managestring.cmake) | ||
| 65 | include(scripts/common/projectmacros.cmake) | ||
| 66 | include(scripts/common/pathsetup.cmake) | ||
| 67 | include(ExternalProject) | ||
| 68 | |||
| 69 | core_find_git_rev() | ||
| 70 | core_find_versions() | ||
| 71 | |||
| 72 | set(INCLUDES ${CORE_SOURCE_DIR} | ||
| 73 | ${CORE_SOURCE_DIR}/addons/library.xbmc.addon | ||
| 74 | ${CORE_SOURCE_DIR}/lib | ||
| 75 | ${CORE_SOURCE_DIR}/lib/gtest/include | ||
| 76 | ${CORE_SOURCE_DIR}/xbmc | ||
| 77 | ${CORE_SOURCE_DIR}/xbmc/${PLATFORM_DIR} | ||
| 78 | ${CORE_SOURCE_DIR}/xbmc/cores/VideoPlayer | ||
| 79 | ${CMAKE_BINARY_DIR}/${CORE_BUILD_DIR}) | ||
| 80 | |||
| 81 | find_package(PkgConfig) | ||
| 82 | if(CMAKE_CROSSCOMPILING) | ||
| 83 | if(PKG_CONFIG_EXECUTABLE) | ||
| 84 | message(STATUS "CMAKE_CROSSCOMPILING: ${CMAKE_CROSSCOMPILING}") | ||
| 85 | set(PKG_CONFIG_FOUND TRUE) | ||
| 86 | endif() | ||
| 87 | endif() | ||
| 88 | |||
| 89 | find_package(Threads REQUIRED) | ||
| 90 | list(APPEND DEPLIBS ${CMAKE_THREAD_LIBS_INIT}) | ||
| 91 | |||
| 92 | # Required dependencies | ||
| 93 | set(required_deps Sqlite3 FreeType PCRE Cpluff LibDvd | ||
| 94 | TinyXML Python Yajl Xslt | ||
| 95 | JPEG Lzo2 Fribidi TagLib FFMPEG CrossGUID) | ||
| 96 | if(NOT WIN32) | ||
| 97 | list(APPEND required_deps LibSmbClient ZLIB) | ||
| 98 | else() | ||
| 99 | list(APPEND required_deps D3DX11Effects) | ||
| 100 | endif() | ||
| 101 | if(CORE_SYSTEM_NAME STREQUAL android) | ||
| 102 | list(APPEND required_deps Zip) | ||
| 103 | endif() | ||
| 104 | |||
| 105 | # Optional dependencies | ||
| 106 | set(optional_deps MicroHttpd MySqlClient SSH | ||
| 107 | Alsa UDev Dbus Avahi | ||
| 108 | PulseAudio VDPAU VAAPI) | ||
| 109 | |||
| 110 | # Required, dyloaded deps | ||
| 111 | set(required_dyload Curl ASS) | ||
| 112 | |||
| 113 | # Optional, dyloaded deps | ||
| 114 | set(dyload_optional RTMP CEC Bluray Plist NFS) | ||
| 115 | |||
| 116 | # Required by shared objects we link | ||
| 117 | set(required_dep_libs PNG EXPAT) | ||
| 118 | |||
| 119 | # Required tools | ||
| 120 | find_package(TexturePacker REQUIRED) | ||
| 121 | find_package(JsonSchemaBuilder REQUIRED) | ||
| 122 | |||
| 123 | foreach(dep ${required_dep_libs}) | ||
| 124 | find_package(${dep} REQUIRED) | ||
| 125 | endforeach() | ||
| 126 | |||
| 127 | foreach(dep ${required_deps}) | ||
| 128 | core_require_dep(${dep}) | ||
| 129 | endforeach() | ||
| 130 | |||
| 131 | foreach(dep ${optional_deps}) | ||
| 132 | core_optional_dep(${dep}) | ||
| 133 | endforeach() | ||
| 134 | |||
| 135 | if(NOT UDEV_FOUND) | ||
| 136 | core_optional_dep(LibUSB) | ||
| 137 | endif() | ||
| 138 | |||
| 139 | foreach(dep ${required_dyload}) | ||
| 140 | core_require_dyload_dep(${dep}) | ||
| 141 | endforeach() | ||
| 142 | |||
| 143 | foreach(dep ${dyload_optional}) | ||
| 144 | core_optional_dyload_dep(${dep}) | ||
| 145 | endforeach() | ||
| 146 | |||
| 147 | if(ENABLE_OPENSSL) | ||
| 148 | core_require_dep(OpenSSL) | ||
| 149 | list(APPEND DEP_DEFINES "-DHAVE_OPENSSL=1") | ||
| 150 | endif() | ||
| 151 | |||
| 152 | if(ENABLE_UPNP) | ||
| 153 | list(APPEND DEP_DEFINES "-DUSE_UPNP=1") | ||
| 154 | endif() | ||
| 155 | |||
| 156 | if(ENABLE_NONFREE) | ||
| 157 | list(APPEND DEP_DEFINES "-DHAVE_XBMC_NONFREE=1") | ||
| 158 | endif() | ||
| 159 | |||
| 160 | if(ENABLE_OPTICAL) | ||
| 161 | list(APPEND DEP_DEFINES -DHAS_DVD_DRIVE) | ||
| 162 | core_require_dep(Cdio) | ||
| 163 | endif() | ||
| 164 | |||
| 165 | if(ENABLE_AIRTUNES) | ||
| 166 | find_package(Shairplay) | ||
| 167 | if(SHAIRPLAY_FOUND) | ||
| 168 | core_require_dyload_dep(Shairplay) | ||
| 169 | endif() | ||
| 170 | endif() | ||
| 171 | |||
| 172 | if(ENABLE_VTB) | ||
| 173 | list(APPEND DEP_DEFINES -DHAVE_VIDEOTOOLBOXDECODER=1) | ||
| 174 | endif() | ||
| 175 | |||
| 176 | if(NOT WIN32) | ||
| 177 | core_optional_dep(OpenGl) | ||
| 178 | if(OPENGL_FOUND) | ||
| 179 | if(NOT APPLE) | ||
| 180 | core_optional_dep(Sdl) | ||
| 181 | else() | ||
| 182 | core_require_dep(Sdl) | ||
| 183 | endif() | ||
| 184 | core_optional_dep(X ENABLE_X11) | ||
| 185 | core_optional_dep(XRandR ENABLE_X11) | ||
| 186 | else() | ||
| 187 | core_optional_dep(OpenGLES ENABLE_OPENGLES) | ||
| 188 | if(OPENGLES_FOUND) | ||
| 189 | core_optional_dep(EGL ENABLE_EGL) | ||
| 190 | core_optional_dep(OMX ENABLE_OMX) | ||
| 191 | core_optional_dep(AML ENABLE_AML) | ||
| 192 | core_optional_dep(X ENABLE_X11) | ||
| 193 | core_optional_dep(Sdl) | ||
| 194 | endif() | ||
| 195 | endif() | ||
| 196 | |||
| 197 | if(CORE_SYSTEM_NAME STREQUAL rbpi) | ||
| 198 | core_require_dep(MMAL) | ||
| 199 | endif() | ||
| 200 | endif() | ||
| 201 | |||
| 202 | if(ENABLE_CCACHE) | ||
| 203 | core_optional_dep(CCache) | ||
| 204 | endif() | ||
| 205 | |||
| 206 | # Compile Info | ||
| 207 | add_custom_command(OUTPUT ${CORE_BUILD_DIR}/xbmc/CompileInfo.cpp | ||
| 208 | COMMAND ${CMAKE_COMMAND} -DCORE_SOURCE_DIR=${CORE_SOURCE_DIR} | ||
| 209 | -DCORE_SYSTEM_NAME=${CORE_SYSTEM_NAME} | ||
| 210 | -DCORE_BUILD_DIR=${CORE_BUILD_DIR} | ||
| 211 | -DCMAKE_BINARY_DIR=${CMAKE_BINARY_DIR} | ||
| 212 | -DARCH_DEFINES="${ARCH_DEFINES}" | ||
| 213 | -DAPP_SCMID=${APP_SCMID} | ||
| 214 | -Dprefix=${CMAKE_BINARY_DIR}/${CORE_BUILD_DIR} | ||
| 215 | -P ${PROJECT_SOURCE_DIR}/scripts/common/generateversionedfiles.cmake | ||
| 216 | DEPENDS ${CORE_SOURCE_DIR}/version.txt | ||
| 217 | ${CORE_SOURCE_DIR}/addons/xbmc.addon/addon.xml.in | ||
| 218 | ${CORE_SOURCE_DIR}/addons/kodi.guilib/addon.xml.in | ||
| 219 | ${CORE_SOURCE_DIR}/xbmc/CompileInfo.cpp.in) | ||
| 220 | list(APPEND install_data addons/xbmc.addon/addon.xml) | ||
| 221 | add_library(compileinfo OBJECT ${CORE_BUILD_DIR}/xbmc/CompileInfo.cpp) | ||
| 222 | target_compile_options(compileinfo PRIVATE "${SYSTEM_DEFINES}") | ||
| 223 | |||
| 224 | # RC File | ||
| 225 | if(WIN32) | ||
| 226 | configure_file(${CORE_SOURCE_DIR}/xbmc/win32/XBMC_PC.rc.in | ||
| 227 | ${CORE_BUILD_DIR}/xbmc/win32/XBMC_PC.rc @ONLY) | ||
| 228 | add_library(resources OBJECT ${CORE_BUILD_DIR}/xbmc/win32/XBMC_PC.rc) | ||
| 229 | target_include_directories(resources PRIVATE ${CORE_SOURCE_DIR}/tools/windows/packaging/media) | ||
| 230 | set(RESOURCES $<TARGET_OBJECTS:resources>) | ||
| 231 | endif() | ||
| 232 | |||
| 233 | include_directories(${INCLUDES} ${SYSTEM_INCLUDES}) | ||
| 234 | add_compile_options(${ARCH_DEFINES} "${SYSTEM_DEFINES}" ${DEP_DEFINES} ${PATH_DEFINES}) | ||
| 235 | |||
| 236 | set(core_DEPENDS "" CACHE STRING "" FORCE) | ||
| 237 | set(test_archives "" CACHE STRING "" FORCE) | ||
| 238 | set(test_sources "" CACHE STRING "" FORCE) | ||
| 239 | mark_as_advanced(core_DEPENDS) | ||
| 240 | mark_as_advanced(test_archives) | ||
| 241 | mark_as_advanced(test_sources) | ||
| 242 | |||
| 243 | file(STRINGS ${PROJECT_SOURCE_DIR}/installdata/addon-bindings.txt bindings) | ||
| 244 | foreach(binding ${bindings}) | ||
| 245 | list(APPEND addon_bindings ${CORE_SOURCE_DIR}/${binding}) | ||
| 246 | endforeach() | ||
| 247 | |||
| 248 | add_subdirectory(${CORE_SOURCE_DIR}/lib/gtest ${CORE_BUILD_DIR}/gtest EXCLUDE_FROM_ALL) | ||
| 249 | |||
| 250 | # Subdirs | ||
| 251 | core_add_subdirs_from_filelist(${PROJECT_SOURCE_DIR}/treedata/common/*.txt | ||
| 252 | ${PROJECT_SOURCE_DIR}/treedata/${CORE_SYSTEM_NAME}/*.txt) | ||
| 253 | core_add_optional_subdirs_from_filelist(${PROJECT_SOURCE_DIR}/treedata/optional/common/*.txt | ||
| 254 | ${PROJECT_SOURCE_DIR}/treedata/optional/${CORE_SYSTEM_NAME}/*.txt) | ||
| 255 | |||
| 256 | # copy files to build tree | ||
| 257 | copy_files_from_filelist_to_buildtree(${PROJECT_SOURCE_DIR}/installdata/common/*.txt | ||
| 258 | ${PROJECT_SOURCE_DIR}/installdata/${CORE_SYSTEM_NAME}/*.txt) | ||
| 259 | |||
| 260 | list(APPEND SKINS "${CORE_SOURCE_DIR}/addons/skin.estuary\;${CORE_SOURCE_DIR}") | ||
| 261 | list(APPEND SKINS "${CORE_SOURCE_DIR}/addons/skin.estouchy\;${CORE_SOURCE_DIR}") | ||
| 262 | |||
| 263 | # These are skins that are copied into place from the source tree | ||
| 264 | foreach(skin ${SKINS}) | ||
| 265 | list(GET skin 0 dir) | ||
| 266 | list(GET skin 1 relative) | ||
| 267 | copy_skin_to_buildtree(${dir} ${relative}) | ||
| 268 | endforeach() | ||
| 269 | |||
| 270 | add_custom_target(pack-skins ALL | ||
| 271 | DEPENDS TexturePacker::TexturePacker export-files ${XBT_FILES}) | ||
| 272 | |||
| 273 | core_link_library(exif system/libexif) | ||
| 274 | if(CORE_SYSTEM_NAME STREQUAL linux) | ||
| 275 | core_link_library(sse4 system/libsse4) | ||
| 276 | endif() | ||
| 277 | |||
| 278 | core_link_library(XBMC_addon addons/library.xbmc.addon/libXBMC_addon) | ||
| 279 | core_link_library(XBMC_codec addons/library.xbmc.codec/libXBMC_codec) | ||
| 280 | core_link_library(KODI_guilib addons/library.kodi.guilib/libKODI_guilib) | ||
| 281 | core_link_library(KODI_adsp addons/library.kodi.adsp/libKODI_adsp) | ||
| 282 | core_link_library(XBMC_pvr addons/library.xbmc.pvr/libXBMC_pvr) | ||
| 283 | |||
| 284 | file(MAKE_DIRECTORY ${CMAKE_BINARY_DIR}/system/players/VideoPlayer) | ||
| 285 | add_custom_target(wrap-libraries ALL DEPENDS ${WRAP_FILES}) | ||
| 286 | |||
| 287 | set(LIBCEC_SONAME "${CEC_SONAME}") | ||
| 288 | if(NOT CORE_SYSTEM_NAME STREQUAL windows AND NOT CORE_SYSTEM_NAME STREQUAL android) | ||
| 289 | configure_file(${CORE_SOURCE_DIR}/xbmc/DllPaths_generated.h.in | ||
| 290 | ${CORE_BUILD_DIR}/DllPaths_generated.h @ONLY) | ||
| 291 | elseif(CORE_SYSTEM_NAME STREQUAL android) | ||
| 292 | configure_file(${CORE_SOURCE_DIR}/xbmc/DllPaths_generated_android.h.in | ||
| 293 | ${CORE_BUILD_DIR}/DllPaths_generated_android.h @ONLY) | ||
| 294 | endif() | ||
| 295 | |||
| 296 | # Codegen | ||
| 297 | add_subdirectory(${CORE_SOURCE_DIR}/xbmc/interfaces/swig build/swig) | ||
| 298 | |||
| 299 | # Other files (IDE) | ||
| 300 | set(OTHER_FILES README.md) | ||
| 301 | |||
| 302 | # main binary | ||
| 303 | add_executable(${APP_NAME_LC} ${CORE_MAIN_SOURCE} $<TARGET_OBJECTS:compileinfo> "${RESOURCES}" ${OTHER_FILES}) | ||
| 304 | whole_archive(_MAIN_LIBRARIES ${core_DEPENDS}) | ||
| 305 | target_link_libraries(${APP_NAME_LC} ${SYSTEM_LDFLAGS} ${_MAIN_LIBRARIES} ${DEPLIBS} ${CMAKE_DL_LIBS}) | ||
| 306 | unset(_MAIN_LIBRARIES) | ||
| 307 | add_dependencies(${APP_NAME_LC} export-files) | ||
| 308 | if(NOT WIN32) | ||
| 309 | set_target_properties(${APP_NAME_LC} PROPERTIES SUFFIX ".bin") | ||
| 310 | else() | ||
| 311 | set_target_properties(${APP_NAME_LC} PROPERTIES WIN32_EXECUTABLE ON) | ||
| 312 | copy_main_dlls_to_buildtree() | ||
| 313 | endif() | ||
| 314 | |||
| 315 | # testing | ||
| 316 | copy_files_from_filelist_to_buildtree(${PROJECT_SOURCE_DIR}/installdata/test-reference-data.txt 1) | ||
| 317 | add_executable(${APP_NAME_LC}-test EXCLUDE_FROM_ALL ${CORE_SOURCE_DIR}/xbmc/test/xbmc-test.cpp $<TARGET_OBJECTS:compileinfo>) | ||
| 318 | whole_archive(_TEST_LIBRARIES ${core_DEPENDS} gtest ${test_archives}) | ||
| 319 | target_link_libraries(${APP_NAME_LC}-test ${SYSTEM_LDFLAGS} ${_TEST_LIBRARIES} ${DEPLIBS} ${CMAKE_DL_LIBS}) | ||
| 320 | unset(_TEST_LIBRARIES) | ||
| 321 | add_dependencies(${APP_NAME_LC}-test export-files) | ||
| 322 | |||
| 323 | # make test and make check (cannot be executed when cross compiling) | ||
| 324 | if(NOT CMAKE_CROSSCOMPILING) | ||
| 325 | enable_testing() | ||
| 326 | gtest_add_tests(${APP_NAME_LC}-test "" ${test_sources}) | ||
| 327 | add_custom_target(check ${CMAKE_CTEST_COMMAND} WORKING_DIRECTORY ${PROJECT_BINARY_DIR}) | ||
| 328 | add_dependencies(check ${APP_NAME_LC}-test) | ||
| 329 | |||
| 330 | # For testing commit series | ||
| 331 | add_custom_target(check-commits ${CMAKE_COMMAND} -P ${PROJECT_SOURCE_DIR}/scripts/common/checkcommits.cmake | ||
| 332 | -DCMAKE_BINARY_DIR=${CMAKE_BINARY_DIR}) | ||
| 333 | endif() | ||
| 334 | |||
| 335 | # link wrapper | ||
| 336 | if(FFMPEG_LINK_EXECUTABLE) | ||
| 337 | set(CMAKE_CXX_LINK_EXECUTABLE "${FFMPEG_LINK_EXECUTABLE}") | ||
| 338 | endif() | ||
| 339 | |||
| 340 | # randr | ||
| 341 | if(ENABLE_X11 AND XRANDR_FOUND) | ||
| 342 | add_executable(kodi-xrandr ${CORE_SOURCE_DIR}/xbmc-xrandr.c) | ||
| 343 | target_link_libraries(kodi-xrandr ${SYSTEM_LDFLAGS} ${X_LIBRARIES} m ${XRANDR_LIBRARIES}) | ||
| 344 | endif() | ||
| 345 | |||
| 346 | # XBMCHelper | ||
| 347 | if(CORE_SYSTEM_TYPE STREQUAL darwin) | ||
| 348 | add_subdirectory(${CORE_SOURCE_DIR}/tools/EventClients/Clients/OSXRemote build/XBMCHelper) | ||
| 349 | endif() | ||
| 350 | |||
| 351 | include(scripts/${CORE_SYSTEM_NAME}/install.cmake) | ||
| 352 | |||
| 353 | # Status | ||
| 354 | message(STATUS "#---- CONFIGURATION ----#") | ||
| 355 | foreach(msg ${final_message}) | ||
| 356 | message(STATUS ${msg}) | ||
| 357 | endforeach() | ||
| 358 | |||
| 359 | if(VERBOSE) | ||
| 360 | message(STATUS "\n#---- Internal Variables ----# ") | ||
| 361 | message(STATUS "DEPLIBS: ${DEPLIBS}") | ||
| 362 | message(STATUS "SYSTEM_LDFLAGS: ${SYSTEM_LDFLAGS}") | ||
| 363 | message(STATUS "core_DEPENDS: ${core_DEPENDS}") | ||
| 364 | message(STATUS "CMAKE_DL_LIBS: ${CMAKE_DL_LIBS}") | ||
| 365 | endif() | ||
| 366 | message(STATUS "#-----------------------#") | ||
| 367 | |||
