Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[cmake] Change the way how shared libraries are built #10130

Merged
merged 9 commits into from
Jul 21, 2016
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -367,6 +367,7 @@ lib/cpluff/stamp-h1
/tools/depends/target/libdvdread/native/
/tools/depends/target/Toolchain_binaddons.cmake
/tools/depends/target/config-binaddons.site
/tools/depends/target/binary-addons/native

# /tools/EventClients/
/tools/EventClients/*.pyc
Expand Down
11 changes: 6 additions & 5 deletions lib/UnrarXLib/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -41,12 +41,13 @@ set(SOURCES archive.cpp
unpack.cpp
volume.cpp)

core_add_library(unrarxlib)

if(CORE_SYSTEM_NAME STREQUAL windows)
add_library(unrarxlib STATIC ${SOURCES} ${HEADERS})
if(NOT CORE_SYSTEM_NAME STREQUAL windows)

This comment was marked as spam.

This comment was marked as spam.

target_compile_definitions(unrarxlib PRIVATE -DSILENT)
else()
target_compile_definitions(unrarxlib PRIVATE -D_XBMC)
add_precompiled_header(unrarxlib rar.hpp rar.cpp
EXCLUDE_SOURCES consio.cpp global.cpp)
else()
target_compile_definitions(unrarxlib PRIVATE -DSILENT)
endif()
set_target_properties(unrarxlib PROPERTIES FOLDER lib)
set(core_DEPENDS unrarxlib ${core_DEPENDS} CACHE STRING "" FORCE)
10 changes: 2 additions & 8 deletions lib/addons/library.kodi.adsp/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,8 +1,2 @@
set(SOURCES libKODI_adsp.cpp)

core_add_library(KODI_adsp NO_MAIN_DEPENDS)
set_target_properties(KODI_adsp PROPERTIES POSITION_INDEPENDENT_CODE True)
target_include_directories(KODI_adsp PRIVATE
${CMAKE_CURRENT_SOURCE_DIR}
${CORE_SOURCE_DIR}/xbmc/addons/kodi-addon-dev-kit/include/kodi
${CORE_SOURCE_DIR}/xbmc)
project(KODI_adsp)
core_add_addon_library(${PROJECT_NAME})
10 changes: 2 additions & 8 deletions lib/addons/library.kodi.audioengine/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,8 +1,2 @@
set(SOURCES libKODI_audioengine.cpp)

core_add_library(KODI_audioengine NO_MAIN_DEPENDS)
set_target_properties(KODI_audioengine PROPERTIES POSITION_INDEPENDENT_CODE True)
target_include_directories(KODI_audioengine PRIVATE
${CMAKE_CURRENT_SOURCE_DIR}
${CORE_SOURCE_DIR}/xbmc/addons/kodi-addon-dev-kit/include/kodi
${CORE_SOURCE_DIR}/xbmc)
project(KODI_audioengine)
core_add_addon_library(${PROJECT_NAME})
10 changes: 2 additions & 8 deletions lib/addons/library.kodi.guilib/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,8 +1,2 @@
set(SOURCES libKODI_guilib.cpp)

core_add_library(KODI_guilib NO_MAIN_DEPENDS)
set_target_properties(KODI_guilib PROPERTIES POSITION_INDEPENDENT_CODE True)
target_include_directories(KODI_guilib PRIVATE
${CMAKE_CURRENT_SOURCE_DIR}
${CORE_SOURCE_DIR}/xbmc/addons/kodi-addon-dev-kit/include/kodi
${CORE_SOURCE_DIR}/xbmc)
project(KODI_guilib)
core_add_addon_library(${PROJECT_NAME})
10 changes: 2 additions & 8 deletions lib/addons/library.kodi.inputstream/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,8 +1,2 @@
set(SOURCES libKODI_inputstream.cpp)

core_add_library(KODI_inputstream NO_MAIN_DEPENDS)
set_target_properties(KODI_inputstream PROPERTIES POSITION_INDEPENDENT_CODE True)
target_include_directories(KODI_inputstream PRIVATE
${CMAKE_CURRENT_SOURCE_DIR}
${CORE_SOURCE_DIR}/xbmc/addons/kodi-addon-dev-kit/include/kodi
${CORE_SOURCE_DIR}/xbmc)
project(KODI_inputstream)
core_add_addon_library(${PROJECT_NAME})
10 changes: 2 additions & 8 deletions lib/addons/library.kodi.peripheral/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,8 +1,2 @@
set(SOURCES libKODI_peripheral.cpp)

core_add_library(KODI_peripheral NO_MAIN_DEPENDS)
set_target_properties(KODI_peripheral PROPERTIES POSITION_INDEPENDENT_CODE True)
target_include_directories(KODI_peripheral PRIVATE
${CMAKE_CURRENT_SOURCE_DIR}
${CORE_SOURCE_DIR}/xbmc/addons/kodi-addon-dev-kit/include/kodi
${CORE_SOURCE_DIR}/xbmc)
project(KODI_peripheral)
core_add_addon_library(${PROJECT_NAME})
10 changes: 2 additions & 8 deletions lib/addons/library.xbmc.addon/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,8 +1,2 @@
set(SOURCES libXBMC_addon.cpp)

core_add_library(XBMC_addon NO_MAIN_DEPENDS)
set_target_properties(XBMC_addon PROPERTIES POSITION_INDEPENDENT_CODE True)
target_include_directories(XBMC_addon PRIVATE
${CMAKE_CURRENT_SOURCE_DIR}
${CORE_SOURCE_DIR}/xbmc/addons/kodi-addon-dev-kit/include/kodi
${CORE_SOURCE_DIR}/xbmc)
project(XBMC_addon)
core_add_addon_library(${PROJECT_NAME})
10 changes: 2 additions & 8 deletions lib/addons/library.xbmc.codec/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,8 +1,2 @@
set(SOURCES libXBMC_codec.cpp)

core_add_library(XBMC_codec NO_MAIN_DEPENDS)
set_target_properties(XBMC_codec PROPERTIES POSITION_INDEPENDENT_CODE True)
target_include_directories(XBMC_codec PRIVATE
${CMAKE_CURRENT_SOURCE_DIR}
${CORE_SOURCE_DIR}/xbmc/addons/kodi-addon-dev-kit/include/kodi
${CORE_SOURCE_DIR}/xbmc)
project(XBMC_codec)
core_add_addon_library(${PROJECT_NAME})
13 changes: 3 additions & 10 deletions lib/addons/library.xbmc.pvr/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,10 +1,3 @@
set(SOURCES libXBMC_pvr.cpp)

core_add_library(XBMC_pvr NO_MAIN_DEPENDS)
set_target_properties(XBMC_pvr PROPERTIES POSITION_INDEPENDENT_CODE True)
target_include_directories(XBMC_pvr PRIVATE
${CMAKE_CURRENT_SOURCE_DIR}
${CORE_SOURCE_DIR}/addons/library.xbmc.addon
${CORE_SOURCE_DIR}/xbmc
${CORE_SOURCE_DIR}/xbmc/addons/kodi-addon-dev-kit/include
${CORE_SOURCE_DIR}/xbmc/cores/VideoPlayer/DVDDemuxers)
project(XBMC_pvr)
core_add_addon_library(${PROJECT_NAME})
target_include_directories(${PROJECT_NAME} PRIVATE ${CORE_SOURCE_DIR}/xbmc/cores/VideoPlayer/DVDDemuxers)
29 changes: 16 additions & 13 deletions lib/libUPnP/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -70,15 +70,6 @@ set(SOURCES Platinum/Source/Core/PltAction.cpp
Platinum/Source/Devices/MediaConnect/PltMediaConnect.cpp
Neptune/Source/System/Posix/NptPosixEnvironment.cpp)

include_directories(Neptune/Source/Core
Platinum/Source/Core
Platinum/Source/Platinum
Platinum/Source/Devices/MediaConnect
Platinum/Source/Devices/MediaRenderer
Platinum/Source/Devices/MediaServer
Neptune/Source/System/Posix
Platinum/Source/Extras)

if(NOT CORE_SYSTEM_NAME STREQUAL windows)
list(APPEND SOURCES Neptune/Source/System/Posix/NptPosixSystem.cpp
Neptune/Source/System/Posix/NptSelectableMessageQueue.cpp
Expand All @@ -98,14 +89,26 @@ else()
Neptune/Source/System/Win32/NptWin32System.cpp
Neptune/Source/System/Win32/NptWin32Threads.cpp
Neptune/Source/System/Win32/NptWin32Time.cpp)
include_directories(Neptune/Source/System/Win32)
endif()

if(APPLE)
list(APPEND SOURCES Neptune/Source/System/Apple/NptAppleAutoreleasePool.mm
Neptune/Source/System/Apple/NptAppleLogConfig.mm)
endif()

add_definitions(-DNPT_CONFIG_ENABLE_LOGGING)

core_add_library(upnp)
add_library(upnp STATIC ${SOURCES} ${HEADERS})
target_compile_definitions(upnp PUBLIC -DNPT_CONFIG_ENABLE_LOGGING)
target_include_directories(upnp PUBLIC ${CMAKE_CURRENT_SOURCE_DIR}
Platinum/Source/Core
Platinum/Source/Platinum
Platinum/Source/Devices/MediaConnect
Platinum/Source/Devices/MediaRenderer
Platinum/Source/Devices/MediaServer
Platinum/Source/Extras
Neptune/Source/Core
Neptune/Source/System/Posix)
if(CORE_SYSTEM_NAME STREQUAL windows)
target_include_directories(upnp PRIVATE Neptune/Source/System/Win32)
endif()
set_target_properties(upnp PROPERTIES FOLDER lib)
set(core_DEPENDS upnp ${core_DEPENDS} CACHE STRING "" FORCE)
8 changes: 6 additions & 2 deletions lib/libexif/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,11 @@ set(SOURCES ExifParse.cpp
JpegParse.cpp
libexif.cpp)

set(CMAKE_POSITION_INDEPENDENT_CODE 1)
set(HEADERS ExifParse.h
IptcParse.h
JpegParse.h
libexif.h)

core_add_library(exif NO_MAIN_DEPENDS)
core_add_shared_library(exif WRAPPED)
target_compile_definitions(exif PRIVATE _LINUX _DLL)
set_target_properties(exif PROPERTIES FOLDER lib)
60 changes: 34 additions & 26 deletions project/cmake/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,11 @@ include(ExternalProject)
core_find_git_rev()
core_find_versions()

# Dynamically loaded libraries built with the project
add_custom_target(${APP_NAME_LC}-libraries)
set(LIBRARY_FILES "" CACHE STRING "" FORCE)
mark_as_advanced(LIBRARY_FILES)

set(INCLUDES ${CORE_SOURCE_DIR}
${CORE_SOURCE_DIR}/addons/library.xbmc.addon
${CORE_SOURCE_DIR}/lib
Expand Down Expand Up @@ -277,22 +282,7 @@ endforeach()
add_custom_target(pack-skins ALL
DEPENDS TexturePacker::TexturePacker export-files ${XBT_FILES})

core_link_library(exif system/libexif)
if(CORE_SYSTEM_NAME STREQUAL linux)
core_link_library(sse4 system/libsse4)
endif()

core_link_library(XBMC_addon addons/library.xbmc.addon/libXBMC_addon nowrap)
core_link_library(XBMC_codec addons/library.xbmc.codec/libXBMC_codec nowrap)
core_link_library(XBMC_pvr addons/library.xbmc.pvr/libXBMC_pvr nowrap)
core_link_library(KODI_adsp addons/library.kodi.adsp/libKODI_adsp nowrap)
core_link_library(KODI_audioengine addons/library.kodi.audioengine/libKODI_audioengine nowrap)
core_link_library(KODI_guilib addons/library.kodi.guilib/libKODI_guilib nowrap)
core_link_library(KODI_inputstream addons/library.kodi.inputstream/libKODI_inputstream nowrap)
core_link_library(KODI_peripheral addons/library.kodi.peripheral/libKODI_peripheral nowrap)

file(MAKE_DIRECTORY ${CMAKE_BINARY_DIR}/system/players/VideoPlayer)
add_custom_target(wrap-libraries ALL DEPENDS ${WRAP_FILES})

set(LIBCEC_SONAME "${CEC_SONAME}")
if(NOT CORE_SYSTEM_NAME STREQUAL windows AND NOT CORE_SYSTEM_NAME STREQUAL android)
Expand All @@ -312,16 +302,20 @@ set(OTHER_FILES README.md)
# main binary
if(NOT CORE_SYSTEM_NAME STREQUAL android)
add_executable(${APP_NAME_LC} ${CORE_MAIN_SOURCE} $<TARGET_OBJECTS:compileinfo> "${RESOURCES}" ${OTHER_FILES})
add_dependencies(${APP_NAME_LC} ${APP_NAME_LC}-libraries export-files pack-skins)
else()
add_library(${APP_NAME_LC} SHARED ${CORE_MAIN_SOURCE} $<TARGET_OBJECTS:compileinfo> "${RESOURCES}" ${OTHER_FILES})
# The libraries depend on the main shared library for wrapping. Because of this we cannot build
# the libraries as a dependency. This requires to build the all target on android (and not only kodi).
add_dependencies(${APP_NAME_LC} export-files pack-skins)
endif()
whole_archive(_MAIN_LIBRARIES ${core_DEPENDS})
target_link_libraries(${APP_NAME_LC} ${SYSTEM_LDFLAGS} ${_MAIN_LIBRARIES} ${DEPLIBS} ${CMAKE_DL_LIBS})
unset(_MAIN_LIBRARIES)
add_dependencies(${APP_NAME_LC} export-files)

if(WIN32)
set_target_properties(${APP_NAME_LC} PROPERTIES WIN32_EXECUTABLE ON)
set_property(DIRECTORY PROPERTY VS_STARTUP_PROJECT ${APP_NAME_LC})
copy_main_dlls_to_buildtree()
elseif(CORE_SYSTEM_NAME STREQUAL android)
# Nothing
Expand All @@ -335,7 +329,7 @@ add_executable(${APP_NAME_LC}-test EXCLUDE_FROM_ALL ${CORE_SOURCE_DIR}/xbmc/test
whole_archive(_TEST_LIBRARIES ${core_DEPENDS} gtest ${test_archives})
target_link_libraries(${APP_NAME_LC}-test ${SYSTEM_LDFLAGS} ${_TEST_LIBRARIES} ${DEPLIBS} ${CMAKE_DL_LIBS})
unset(_TEST_LIBRARIES)
add_dependencies(${APP_NAME_LC}-test export-files)
add_dependencies(${APP_NAME_LC}-test ${APP_NAME_LC}-libraries export-files)

# make test and make check (cannot be executed when cross compiling)
if(NOT CMAKE_CROSSCOMPILING)
Expand Down Expand Up @@ -366,15 +360,9 @@ if(FFMPEG_CREATE_SHARED_LIBRARY)
set(CMAKE_CXX_CREATE_SHARED_LIBRARY "${FFMPEG_CREATE_SHARED_LIBRARY}")
endif()

# randr
if(ENABLE_X11 AND XRANDR_FOUND)
add_executable(kodi-xrandr ${CORE_SOURCE_DIR}/xbmc-xrandr.c)
target_link_libraries(kodi-xrandr ${SYSTEM_LDFLAGS} ${X_LIBRARIES} m ${XRANDR_LIBRARIES})
endif()

# XBMCHelper
if(CORE_SYSTEM_NAME STREQUAL osx)
add_subdirectory(${CORE_SOURCE_DIR}/tools/EventClients/Clients/OSXRemote build/XBMCHelper)
# Platform specific additional extra targets
if(EXISTS ${PROJECT_SOURCE_DIR}/scripts/${CORE_SYSTEM_NAME}/ExtraTargets.cmake)
include(${PROJECT_SOURCE_DIR}/scripts/${CORE_SYSTEM_NAME}/ExtraTargets.cmake)
endif()

# WiiRemote
Expand All @@ -386,6 +374,26 @@ endif()

include(scripts/${CORE_SYSTEM_NAME}/Install.cmake)

# Create target that allows to build binary-addons.
# Use make binary-addons ADDONS="visualization.spectrum" to select the addons to build.
if(CMAKE_GENERATOR STREQUAL "Unix Makefiles")
if(CMAKE_CROSSCOMPILING)
set(_cross_args CROSS_COMPILING=yes TOOLCHAIN_FILE=${CMAKE_TOOLCHAIN_FILE})
endif()
if(NOT CORE_SYSTEM_NAME STREQUAL android)
set(_prefix ${CMAKE_BINARY_DIR}/addons)
set(_extra "CMAKE_EXTRA=-DPACKAGE_ZIP=ON")
else()
set(_prefix ${CMAKE_INSTALL_PREFIX})
endif()
add_custom_target(binary-addons
COMMAND $(MAKE) -C ${CORE_SOURCE_DIR}/tools/depends/target/binary-addons clean
COMMAND $(MAKE) -C ${CORE_SOURCE_DIR}/tools/depends/target/binary-addons VERBOSE=1 V=99
PREFIX=${_prefix} INSTALL_PREFIX=${_prefix} ${_cross_args} ${_extra})
unset(_cross_args)
unset(_prefix)
endif()

# Prepare add-on build env
foreach(binding ${addon_bindings})
get_filename_component(file ${binding} NAME)
Expand Down
7 changes: 4 additions & 3 deletions project/cmake/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,11 @@ The current version of the buildsystem is capable of building the main Kodi
executable (but no packaging or dependency management yet) for the following
platforms:

- Linux (GNU Makefiles)
- Windows (NMake Makefiles, Visual Studio 14 (2015))
- OSX (GNU Makefiles, Xcode)
- Linux (GNU Makefiles, Ninja)
- Windows (NMake Makefiles, Visual Studio 14 (2015), Ninja)
- OSX and IOS (GNU Makefiles, Xcode, Ninja)
- Android (GNU Makefiles)
- FreeBSD (GNU Makefiles)

Before building Kodi with CMake, please ensure that you have the platform
specific dependencies installed.
Expand Down
4 changes: 1 addition & 3 deletions project/cmake/modules/FindCpluff.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,7 @@ if(NOT WIN32)
--prefix=<INSTALL_DIR>
--host=${ARCH}
CFLAGS=${defines}
LDFLAGS=${ldflags}
BUILD_COMMAND ${CMAKE_MAKE_PROGRAM} V=1)
LDFLAGS=${ldflags})
ExternalProject_Add_Step(libcpluff autoreconf
DEPENDEES download update patch
DEPENDERS configure
Expand All @@ -33,7 +32,6 @@ if(NOT WIN32)
set(ldflags "${ldflags};-lexpat")
core_link_library(${CMAKE_BINARY_DIR}/${CORE_BUILD_DIR}/cpluff/lib/libcpluff.a
system/libcpluff libcpluff extras "${ldflags}")
set(WRAP_FILES ${WRAP_FILES} PARENT_SCOPE)
else()
ExternalProject_Add(libcpluff SOURCE_DIR ${CORE_SOURCE_DIR}/lib/cpluff
PREFIX ${CORE_BUILD_DIR}/cpluff
Expand Down
1 change: 1 addition & 0 deletions project/cmake/modules/FindFFMPEG.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,7 @@ else()
pkg_check_modules (FFMPEG ${FFMPEG_PKGS})
string(REGEX REPLACE "framework;" "framework " FFMPEG_LDFLAGS "${FFMPEG_LDFLAGS}")
set(FFMPEG_LIBRARIES ${FFMPEG_LDFLAGS})
add_custom_target(ffmpeg)
else()
find_path(FFMPEG_INCLUDE_DIRS libavcodec/avcodec.h PATH_SUFFIXES ffmpeg)
find_library(FFMPEG_LIBAVCODEC NAMES avcodec libavcodec PATH_SUFFIXES ffmpeg/libavcodec)
Expand Down
2 changes: 0 additions & 2 deletions project/cmake/modules/FindLibDvd.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -117,8 +117,6 @@ if(NOT WIN32)
add_dependencies(dvdnav dvdread)
core_link_library(${DVDNAV_LIBRARY} system/players/VideoPlayer/libdvdnav dvdnav)

set(WRAP_FILES ${WRAP_FILES} PARENT_SCOPE)

set(LIBDVD_INCLUDE_DIRS ${CMAKE_BINARY_DIR}/${CORE_BUILD_DIR}/libdvd/include)
set(LIBDVD_LIBRARIES ${DVDNAV_LIBRARY} ${DVDREAD_LIBRARY})
if(ENABLE_DVDCSS)
Expand Down
5 changes: 2 additions & 3 deletions project/cmake/scripts/android/Install.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,6 @@ function(add_bundle_file file destination relative)
file(REMOVE ${CMAKE_BINARY_DIR}/${CORE_BUILD_DIR}/BundleFiles.cmake)
add_custom_target(bundle_files COMMAND ${CMAKE_COMMAND} -P ${CMAKE_BINARY_DIR}/${CORE_BUILD_DIR}/BundleFiles.cmake)
add_dependencies(bundle bundle_files)
add_dependencies(bundle_files export-files pack-skins wrap-libraries generate_json_header)
endif()

string(REPLACE "${relative}/" "" outfile ${file})
Expand All @@ -75,8 +74,8 @@ foreach(file IN LISTS XBT_FILES install_data)
add_bundle_file(${CMAKE_BINARY_DIR}/${file} ${datarootdir}/${APP_NAME_LC} ${CMAKE_BINARY_DIR})
endforeach()

foreach(file IN LISTS WRAP_FILES)
add_bundle_file(${CMAKE_BINARY_DIR}/${file} ${libdir}/${APP_NAME_LC} ${CMAKE_BINARY_DIR})
foreach(library IN LISTS LIBRARY_FILES)
add_bundle_file(${library} ${libdir}/${APP_NAME_LC} ${CMAKE_BINARY_DIR})
endforeach()

foreach(lib IN LISTS required_dyload dyload_optional ITEMS Shairplay)
Expand Down
Loading