Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

added: generate and install cmake helpers for addons

  • Loading branch information...
commit 398c33e28de26c41d87937f82d72bf6d42c062d0 1 parent 8e1eeb5
spiff authored
View
3  Makefile.in
@@ -596,6 +596,9 @@ endif
@for f in $(BINDINGS); do \
install -m 0644 $$f $(DESTDIR)$(includedir)/xbmc ; \
done
+ @for f in project/cmake/*.cmake; do \
+ install -m 0644 $$f $(DESTDIR)$(libdir)/xbmc; \
+ done
uninstall:
@echo "Removing XBMC..."
View
19 configure.in
@@ -6,6 +6,7 @@ AC_INIT([xbmc], [12.9.7], [http://trac.xbmc.org])
AC_CONFIG_HEADERS([xbmc/config.h])
AH_TOP([#pragma once])
m4_include([m4/ax_python_devel.m4])
+m4_include([m4/xbmc_arch.m4])
AC_CONFIG_AUX_DIR([build-aux])
AM_INIT_AUTOMAKE([foreign])
@@ -594,21 +595,17 @@ case $host in
;;
i*86*-linux-gnu*)
ARCH="i486-linux"
- AC_SUBST(ARCH_DEFINES, "-DTARGET_POSIX -DTARGET_LINUX -D_LINUX")
;;
x86_64-*-linux-gnu*)
ARCH="x86_64-linux"
- AC_SUBST(ARCH_DEFINES, "-DTARGET_POSIX -DTARGET_LINUX -D_LINUX")
;;
i386-*-freebsd*)
ARCH="x86-freebsd"
MAKE="gmake"
- AC_SUBST(ARCH_DEFINES, "-DTARGET_POSIX -DTARGET_FREEBSD -D_LINUX")
;;
amd64-*-freebsd*)
ARCH="x86_64-freebsd"
MAKE="gmake"
- AC_SUBST(ARCH_DEFINES, "-DTARGET_POSIX -DTARGET_FREEBSD -D_LINUX")
;;
arm-apple-darwin*)
use_joystick=no
@@ -628,14 +625,12 @@ case $host in
PYTHON_CPPFLAGS="-I${prefix}/include/python2.6"
PYTHON_SITE_PKG="${prefix}/lib/python2.6/site-packages"
PYTHON_NOVERSIONCHECK="no-check"
- AC_SUBST(ARCH_DEFINES, "-DTARGET_POSIX -DTARGET_DARWIN -DTARGET_DARWIN_IOS -D_LINUX")
;;
*86*-apple-darwin*)
use_joystick=no
use_vtbdecoder=no
use_texturepacker_native=yes
ARCH="x86-osx"
- AC_SUBST(ARCH_DEFINES, "-DTARGET_POSIX -DTARGET_DARWIN -DTARGET_DARWIN_OSX -D_LINUX")
;;
powerpc-apple-darwin*)
use_joystick=no
@@ -643,21 +638,17 @@ case $host in
use_crystalhd=no
ARCH="powerpc-osx"
use_arch="ppc"
- AC_SUBST(ARCH_DEFINES, "-DTARGET_POSIX -DTARGET_DARWIN -DTARGET_DARWIN_OSX -D_LINUX")
;;
powerpc-*-linux-gnu*)
ARCH="powerpc-linux"
- AC_SUBST(ARCH_DEFINES, "-DTARGET_POSIX -DTARGET_LINUX -D_LINUX -D_POWERPC")
;;
powerpc64-*-linux-gnu*)
ARCH="powerpc64-linux"
- AC_SUBST(ARCH_DEFINES, "-DTARGET_POSIX -DTARGET_LINUX -D_LINUX -D_POWERPC64")
;;
arm*-*-linux-gnu*)
use_texturepacker=no
ARCH="arm"
use_arch="arm"
- AC_SUBST(ARCH_DEFINES, "-DTARGET_POSIX -DTARGET_LINUX -D_LINUX")
ffmpeg_target_os=linux
use_joystick=no
use_neon=yes
@@ -684,7 +675,6 @@ case $host in
esac
AC_SUBST([ARCH])
-
check_sdl_arch=[`file $USE_TEXTUREPACKER_NATIVE_ROOT/lib/libSDL_image.dylib | awk '{print $NF}'`]
if test "x$check_sdl_arch" = "xi386" ; then
DARWIN_NATIVE_ARCH=-m32
@@ -697,7 +687,6 @@ if test "$target_platform" = "target_android" ; then
USE_ANDROID=1
use_texturepacker_native=yes
webserver_checkdepends=yes
- AC_SUBST(ARCH_DEFINES, "-DTARGET_POSIX -DTARGET_LINUX -D_LINUX -DTARGET_ANDROID")
CFLAGS="$CFLAGS -Wno-psabi"
CXXFLAGS="$CXXFLAGS -Wno-psabi"
AC_DEFINE(HAS_EGLGLES, [1], [Define if supporting EGL based GLES Framebuffer])
@@ -714,7 +703,6 @@ case $use_platform in
use_hardcoded_tables="yes"
use_alsa="no"
ARCH="arm"
- AC_SUBST(ARCH_DEFINES, "-DTARGET_POSIX -DTARGET_LINUX -D_LINUX -D_ARMEL -DTARGET_RASPBERRY_PI")
AC_DEFINE(HAS_EGLGLES, [1], [Define if supporting EGL based GLES Framebuffer])
USE_OMXLIB=1; AC_DEFINE([HAVE_OMXLIB],[1],["Define to 1 if OMX libs is enabled"])
CFLAGS="$CFLAGS"
@@ -723,6 +711,8 @@ case $use_platform in
;;
esac
+XBMC_SETUP_ARCH_DEFINES()
+
# check for GIT_REV
AC_CHECK_PROG(HAVE_GIT,git,"yes","no",)
if test "$GIT_REV" = ""; then
@@ -2409,7 +2399,8 @@ OUTPUT_FILES="Makefile \
xbmc/android/loader/Makefile \
xbmc/android/jni/Makefile \
xbmc/utils/Makefile \
- xbmc/main/Makefile"
+ xbmc/main/Makefile \
+ project/cmake/xbmc-config.cmake"
if test "$use_skin_touched" = "yes"; then
OUTPUT_FILES="$OUTPUT_FILES addons/skin.touched/media/Makefile"
View
51 m4/xbmc_arch.m4
@@ -0,0 +1,51 @@
+AC_DEFUN([XBMC_SETUP_ARCH_DEFINES],[
+
+# host detection and setup
+case $host in
+ i*86*-linux-gnu*)
+ AC_SUBST(ARCH_DEFINES, "-DTARGET_POSIX -DTARGET_LINUX -D_LINUX")
+ ;;
+ x86_64-*-linux-gnu*)
+ AC_SUBST(ARCH_DEFINES, "-DTARGET_POSIX -DTARGET_LINUX -D_LINUX")
+ ;;
+ i386-*-freebsd*)
+ AC_SUBST(ARCH_DEFINES, "-DTARGET_POSIX -DTARGET_FREEBSD -D_LINUX")
+ ;;
+ amd64-*-freebsd*)
+ AC_SUBST(ARCH_DEFINES, "-DTARGET_POSIX -DTARGET_FREEBSD -D_LINUX")
+ ;;
+ arm-apple-darwin*)
+ AC_SUBST(ARCH_DEFINES, "-DTARGET_POSIX -DTARGET_DARWIN -DTARGET_DARWIN_IOS -D_LINUX")
+ ;;
+ *86*-apple-darwin*)
+ AC_SUBST(ARCH_DEFINES, "-DTARGET_POSIX -DTARGET_DARWIN -DTARGET_DARWIN_OSX -D_LINUX")
+ ;;
+ powerpc-apple-darwin*)
+ AC_SUBST(ARCH_DEFINES, "-DTARGET_POSIX -DTARGET_DARWIN -DTARGET_DARWIN_OSX -D_LINUX")
+ ;;
+ powerpc-*-linux-gnu*)
+ AC_SUBST(ARCH_DEFINES, "-DTARGET_POSIX -DTARGET_LINUX -D_LINUX -D_POWERPC")
+ ;;
+ powerpc64-*-linux-gnu*)
+ AC_SUBST(ARCH_DEFINES, "-DTARGET_POSIX -DTARGET_LINUX -D_LINUX -D_POWERPC64")
+ ;;
+ arm*-*-linux-gnu*)
+ AC_SUBST(ARCH_DEFINES, "-DTARGET_POSIX -DTARGET_LINUX -D_LINUX")
+ ;;
+ arm*-*linux-android*)
+ AC_SUBST(ARCH_DEFINES, "-DTARGET_POSIX -DTARGET_LINUX -D_LINUX -DTARGET_ANDROID")
+ ;;
+ *)
+ AC_MSG_ERROR(unsupported host ($host))
+esac
+
+if test "$target_platform" = "target_android" ; then
+ AC_SUBST(ARCH_DEFINES, "-DTARGET_POSIX -DTARGET_LINUX -D_LINUX -DTARGET_ANDROID")
+fi
+
+case $use_platform in
+ raspberry-pi)
+ AC_SUBST(ARCH_DEFINES, "-DTARGET_POSIX -DTARGET_LINUX -D_LINUX -D_ARMEL -DTARGET_RASPBERRY_PI")
+ ;;
+esac
+])
View
82 project/cmake/AddOptions.cmake
@@ -0,0 +1,82 @@
+# - Add options without repeating them on the command line
+#
+# Synopsis:
+#
+# add_options (lang build opts)
+#
+# where:
+#
+# lang Name of the language whose compiler should receive the
+# options, e.g. CXX. If a comma-separated list is received
+# then the option is added for all those languages. Use the
+# special value ALL_LANGUAGES for these languages: CXX, C
+# and Fortran
+#
+# build Kind of build to which this options should apply,
+# such as DEBUG and RELEASE. This can also be a comma-
+# separated list. Use the special value ALL_BUILDS to apply
+# to all builds.
+#
+# opts List of options to add. Each should be quoted.
+#
+# Example:
+#
+# add_options (CXX RELEASE "-O3" "-DNDEBUG" "-Wall")
+
+function (add_options langs builds)
+ # special handling of empty language specification
+ if ("${langs}" STREQUAL "ALL_LANGUAGES")
+ set (langs CXX C Fortran)
+ endif ("${langs}" STREQUAL "ALL_LANGUAGES")
+ foreach (lang IN LISTS langs)
+ # prepend underscore if necessary
+ foreach (build IN LISTS builds)
+ if (NOT ("${build}" STREQUAL "ALL_BUILDS"))
+ set (_bld "_${build}")
+ string (TOUPPER "${_bld}" _bld)
+ else (NOT ("${build}" STREQUAL "ALL_BUILDS"))
+ set (_bld "")
+ endif (NOT ("${build}" STREQUAL "ALL_BUILDS"))
+ foreach (_opt IN LISTS ARGN)
+ set (_var "CMAKE_${lang}_FLAGS${_bld}")
+ #message (STATUS "Adding \"${_opt}\" to \${${_var}}")
+ # remove it first
+ string (REPLACE "${_opt}" "" _without "${${_var}}")
+ string (STRIP "${_without}" _without)
+ # we need to strip this one as well, so they are comparable
+ string (STRIP "${${_var}}" _stripped)
+ # if it wasn't there, then add it at the end
+ if ("${_without}" STREQUAL "${_stripped}")
+ # don't add any extra spaces if no options yet are set
+ if (NOT ${_stripped} STREQUAL "")
+ set (${_var} "${_stripped} ${_opt}")
+ else (NOT ${_stripped} STREQUAL "")
+ set (${_var} "${_opt}")
+ endif (NOT ${_stripped} STREQUAL "")
+ set (${_var} "${${_var}}" PARENT_SCOPE)
+ endif ("${_without}" STREQUAL "${_stripped}")
+ endforeach (_opt)
+ endforeach (build)
+ endforeach (lang)
+endfunction (add_options lang build)
+
+# set varname to flag unless user has specified something that matches regex
+function (set_default_option varname flag regex)
+ if (NOT "$ENV{CXXFLAGS}" MATCHES "${regex}"
+ AND NOT "${CMAKE_CXX_FLAGS}" MATCHES "${regex}"
+ AND NOT "${CMAKE_CXX_FLAGS_${CMAKE_BUILD_TYPE}}" MATCHES "${regex}")
+ set (${varname} ${flag} PARENT_SCOPE)
+ else (NOT "$ENV{CXXFLAGS}" MATCHES "${regex}"
+ AND NOT "${CMAKE_CXX_FLAGS}" MATCHES "${regex}"
+ AND NOT "${CMAKE_CXX_FLAGS_${CMAKE_BUILD_TYPE}}" MATCHES "${regex}")
+ set (${varname} PARENT_SCOPE)
+ endif (NOT "$ENV{CXXFLAGS}" MATCHES "${regex}"
+ AND NOT "${CMAKE_CXX_FLAGS}" MATCHES "${regex}"
+ AND NOT "${CMAKE_CXX_FLAGS_${CMAKE_BUILD_TYPE}}" MATCHES "${regex}")
+endfunction (set_default_option)
+
+# note: this must be called before project()
+macro (no_default_options)
+ # prevent the platform probe to set options
+ set (CMAKE_NOT_USING_CONFIG_FLAGS TRUE)
+endmacro (no_default_options)
View
64 project/cmake/xbmc-addon-helpers.cmake
@@ -0,0 +1,64 @@
+# Install an add-on in the appropriate way
+macro (install_addon target version)
+ IF(PACKAGE_ZIP OR PACKAGE_TGZ)
+ # Pack files together to create an archive
+ INSTALL(DIRECTORY ${target} DESTINATION ./)
+ IF(WIN32)
+ INSTALL(PROGRAMS ${CMAKE_BINARY_DIR}/${target}.dll DESTINATION ${target})
+ ELSE(WIN32)
+ INSTALL(TARGETS ${target} DESTINATION ${target})
+ ENDIF(WIN32)
+ IF(PACKAGE_ZIP)
+ SET(CPACK_GENERATOR "ZIP")
+ ENDIF(PACKAGE_ZIP)
+ IF(PACKAGE_TGZ)
+ SET(CPACK_GENERATOR "TGZ")
+ ENDIF(PACKAGE_TGZ)
+ SET(CPACK_INCLUDE_TOPLEVEL_DIRECTORY OFF)
+ SET(CPACK_PACKAGE_FILE_NAME ${target}-${version})
+ IF(CMAKE_BUILD_TYPE STREQUAL "Release")
+ SET(CPACK_STRIP_FILES TRUE)
+ ENDIF(CMAKE_BUILD_TYPE STREQUAL "Release")
+ INCLUDE(CPack)
+ ELSE(PACKAGE_ZIP OR PACKAGE_TGZ)
+ INSTALL(TARGETS ${target} DESTINATION lib/xbmc/addons/${target})
+ INSTALL(DIRECTORY ${target} DESTINATION share/xbmc/addons)
+ ENDIF(PACKAGE_ZIP OR PACKAGE_TGZ)
+endmacro()
+
+# Grab the version from a given add-on's addon.xml
+macro (addon_version dir prefix)
+ FILE(READ ${dir}/addon.xml ADDONXML)
+ STRING(REGEX MATCH "<addon[^>]*version.?=.?.[0-9\\.]+" VERSION_STRING ${ADDONXML})
+ STRING(REGEX REPLACE ".*version=.([0-9\\.]+).*" "\\1" ${prefix}_VERSION ${VERSION_STRING})
+ message(STATUS ${prefix}_VERSION=${${prefix}_VERSION})
+endmacro()
+
+# Prepare the add-on build environment
+macro (prepare_addon_environment)
+ IF(WIN32)
+ SET(BINDING_FILE ${XBMC_BINDINGS}.zip)
+ message (STATUS "downloading XBMC bindings: " ${BINDING_FILE})
+ file(DOWNLOAD http://mirrors.xbmc.org/build-deps/win32/${BINDING_FILE} ${CMAKE_BINARY_DIR}/downloads/${BINDING_FILE} STATUS STATUSLIST SHOW_PROGRESS)
+ LIST(GET STATUSLIST 0 VALUE)
+ IF(${VALUE} STRGREATER "0")
+ LIST(GET STATUSLIST 1 VALUE)
+ message (STATUS "failed to download XBMC bindings: " ${VALUE})
+ ENDIF(${VALUE} STRGREATER "0")
+ execute_process(
+ COMMAND ${CMAKE_COMMAND} -E tar xzf ${CMAKE_BINARY_DIR}/downloads/${BINDING_FILE}
+ )
+ ENDIF(WIN32)
+endmacro()
+
+# Build and link an add-on
+macro (build_addon target sources libs version)
+ ADD_LIBRARY(${target} ${${sources}})
+ TARGET_LINK_LIBRARIES(${target} ${${libs}})
+ SET_TARGET_PROPERTIES(${target} PROPERTIES VERSION ${${version}}
+ SOVERSION 13.0
+ PREFIX "")
+ IF(OS STREQUAL "android")
+ SET_TARGET_PROPERTIES(${target} PROPERTIES PREFIX "lib")
+ ENDIF(OS STREQUAL "android")
+endmacro()
View
10 project/cmake/xbmc-config.cmake.in
@@ -0,0 +1,10 @@
+SET(XBMC_INCLUDE_DIR @prefix@/include)
+LIST(APPEND CMAKE_MODULE_PATH @prefix@/lib/xbmc)
+ADD_DEFINITIONS(@ARCH_DEFINES@)
+
+include(xbmc-addon-helpers)
+include(AddOptions)
+prepare_addon_environment()
+
+OPTION(PACKAGE_ZIP "Package Zip file?" OFF)
+OPTION(PACKAGE_TGZ "Package TGZ file?" OFF)
View
1  tools/depends/Makefile.include.in
@@ -16,6 +16,7 @@ PREFIX=@prefix@/@deps_dir@
NATIVEPREFIX=@prefix@/@tool_dir@
OS=@platform_os@
CROSS_COMPILING=@cross_compiling@
+ARCH_DEFINES=@ARCH_DEFINES@
HAS_ZLIB=@has_zlib@
NEED_LIBICONV=@need_libiconv@
View
3  tools/depends/configure.in
@@ -4,6 +4,7 @@ AC_INIT([xbmc-depends], [2.00], [http://trac.xbmc.org])
AC_CONFIG_AUX_DIR([build-aux])
AC_CONFIG_FILES([target/config.site native/config.site.native Makefile.include target/Toolchain.cmake])
AC_CANONICAL_HOST
+m4_include([../../m4/xbmc_arch.m4])
AC_ARG_WITH([toolchain],
[AS_HELP_STRING([--with-toolchain],
@@ -244,6 +245,8 @@ case $host in
AC_MSG_ERROR(unsupported host ($use_host))
esac
+XBMC_SETUP_ARCH_DEFINES()
+
platform_cflags+=" $passed_cflags"
platform_ldflags+=" $passed_ldflags $LIBS"
platform_cxxflags+=" $passed_cxxflags"
View
4 tools/depends/target/xbmc-addon-bindings/Makefile
@@ -28,6 +28,10 @@ all: .installed-$(PLATFORM)
@for f in $(BINDINGS); do \
cp -f $(XBMCROOT)/$$f $(PREFIX)/include/xbmc ; \
done
+ @mkdir -p $(PREFIX)/lib/xbmc
+ @cat $(XBMCROOT)/project/cmake/xbmc-config.cmake.in | sed -e 's|@prefix@|$(PREFIX)|' -e 's|@ARCH_DEFINES@|$(ARCH_DEFINES)|' > $(PREFIX)/lib/xbmc/xbmc-config.cmake
+ @cp -f $(XBMCROOT)/project/cmake/xbmc-addon-helpers.cmake $(PREFIX)/lib/xbmc
+ @cp -f $(XBMCROOT)/project/cmake/AddOptions.cmake $(PREFIX)/lib/xbmc
@touch $@
clean:
Please sign in to comment.
Something went wrong with that request. Please try again.