Skip to content
This repository
Browse code

added: generate and install cmake helpers for addons

  • Loading branch information...
commit 398c33e28de26c41d87937f82d72bf6d42c062d0 1 parent 8e1eeb5
authored August 07, 2013
3  Makefile.in
@@ -596,6 +596,9 @@ endif
596 596
 	@for f in $(BINDINGS); do \
597 597
 	  install -m 0644 $$f $(DESTDIR)$(includedir)/xbmc ; \
598 598
 	done
  599
+	@for f in project/cmake/*.cmake; do \
  600
+	  install -m 0644 $$f $(DESTDIR)$(libdir)/xbmc; \
  601
+	done
599 602
 
600 603
 uninstall:
601 604
 	@echo "Removing XBMC..."
19  configure.in
@@ -6,6 +6,7 @@ AC_INIT([xbmc], [12.9.7], [http://trac.xbmc.org])
6 6
 AC_CONFIG_HEADERS([xbmc/config.h])
7 7
 AH_TOP([#pragma once])
8 8
 m4_include([m4/ax_python_devel.m4])
  9
+m4_include([m4/xbmc_arch.m4])
9 10
 
10 11
 AC_CONFIG_AUX_DIR([build-aux])
11 12
 AM_INIT_AUTOMAKE([foreign])
@@ -594,21 +595,17 @@ case $host in
594 595
      ;;
595 596
   i*86*-linux-gnu*)
596 597
      ARCH="i486-linux"
597  
-     AC_SUBST(ARCH_DEFINES, "-DTARGET_POSIX -DTARGET_LINUX -D_LINUX")
598 598
      ;;
599 599
   x86_64-*-linux-gnu*)
600 600
      ARCH="x86_64-linux"
601  
-     AC_SUBST(ARCH_DEFINES, "-DTARGET_POSIX -DTARGET_LINUX -D_LINUX")
602 601
      ;;
603 602
   i386-*-freebsd*)
604 603
      ARCH="x86-freebsd"
605 604
      MAKE="gmake"
606  
-     AC_SUBST(ARCH_DEFINES, "-DTARGET_POSIX -DTARGET_FREEBSD -D_LINUX")
607 605
      ;;
608 606
   amd64-*-freebsd*)
609 607
      ARCH="x86_64-freebsd"
610 608
      MAKE="gmake"
611  
-     AC_SUBST(ARCH_DEFINES, "-DTARGET_POSIX -DTARGET_FREEBSD -D_LINUX")
612 609
      ;;
613 610
   arm-apple-darwin*)
614 611
      use_joystick=no
@@ -628,14 +625,12 @@ case $host in
628 625
      PYTHON_CPPFLAGS="-I${prefix}/include/python2.6"
629 626
      PYTHON_SITE_PKG="${prefix}/lib/python2.6/site-packages"
630 627
      PYTHON_NOVERSIONCHECK="no-check"
631  
-     AC_SUBST(ARCH_DEFINES, "-DTARGET_POSIX -DTARGET_DARWIN -DTARGET_DARWIN_IOS -D_LINUX")
632 628
      ;;
633 629
   *86*-apple-darwin*)
634 630
      use_joystick=no
635 631
      use_vtbdecoder=no
636 632
      use_texturepacker_native=yes
637 633
      ARCH="x86-osx"
638  
-     AC_SUBST(ARCH_DEFINES, "-DTARGET_POSIX -DTARGET_DARWIN -DTARGET_DARWIN_OSX -D_LINUX")
639 634
      ;;
640 635
   powerpc-apple-darwin*)
641 636
      use_joystick=no
@@ -643,21 +638,17 @@ case $host in
643 638
      use_crystalhd=no
644 639
      ARCH="powerpc-osx"
645 640
      use_arch="ppc"
646  
-     AC_SUBST(ARCH_DEFINES, "-DTARGET_POSIX -DTARGET_DARWIN -DTARGET_DARWIN_OSX -D_LINUX")
647 641
      ;;
648 642
   powerpc-*-linux-gnu*)
649 643
      ARCH="powerpc-linux"
650  
-     AC_SUBST(ARCH_DEFINES, "-DTARGET_POSIX -DTARGET_LINUX -D_LINUX -D_POWERPC")
651 644
      ;;
652 645
   powerpc64-*-linux-gnu*)
653 646
      ARCH="powerpc64-linux"
654  
-     AC_SUBST(ARCH_DEFINES, "-DTARGET_POSIX -DTARGET_LINUX -D_LINUX -D_POWERPC64")
655 647
      ;;
656 648
   arm*-*-linux-gnu*)
657 649
      use_texturepacker=no
658 650
      ARCH="arm"
659 651
      use_arch="arm"
660  
-     AC_SUBST(ARCH_DEFINES, "-DTARGET_POSIX -DTARGET_LINUX -D_LINUX")
661 652
      ffmpeg_target_os=linux
662 653
      use_joystick=no
663 654
      use_neon=yes
@@ -684,7 +675,6 @@ case $host in
684 675
 esac
685 676
 AC_SUBST([ARCH])
686 677
 
687  
-
688 678
 check_sdl_arch=[`file $USE_TEXTUREPACKER_NATIVE_ROOT/lib/libSDL_image.dylib | awk '{print $NF}'`]
689 679
 if test "x$check_sdl_arch" = "xi386" ; then
690 680
   DARWIN_NATIVE_ARCH=-m32
@@ -697,7 +687,6 @@ if test "$target_platform" = "target_android" ; then
697 687
   USE_ANDROID=1
698 688
   use_texturepacker_native=yes
699 689
   webserver_checkdepends=yes
700  
-  AC_SUBST(ARCH_DEFINES, "-DTARGET_POSIX -DTARGET_LINUX -D_LINUX -DTARGET_ANDROID")
701 690
   CFLAGS="$CFLAGS -Wno-psabi"
702 691
   CXXFLAGS="$CXXFLAGS -Wno-psabi"
703 692
   AC_DEFINE(HAS_EGLGLES, [1], [Define if supporting EGL based GLES Framebuffer])
@@ -714,7 +703,6 @@ case $use_platform in
714 703
      use_hardcoded_tables="yes"
715 704
      use_alsa="no"
716 705
      ARCH="arm"
717  
-     AC_SUBST(ARCH_DEFINES, "-DTARGET_POSIX -DTARGET_LINUX -D_LINUX -D_ARMEL -DTARGET_RASPBERRY_PI")
718 706
      AC_DEFINE(HAS_EGLGLES, [1], [Define if supporting EGL based GLES Framebuffer])
719 707
      USE_OMXLIB=1; AC_DEFINE([HAVE_OMXLIB],[1],["Define to 1 if OMX libs is enabled"])
720 708
      CFLAGS="$CFLAGS"
@@ -723,6 +711,8 @@ case $use_platform in
723 711
      ;;
724 712
 esac
725 713
 
  714
+XBMC_SETUP_ARCH_DEFINES()
  715
+
726 716
 # check for GIT_REV
727 717
 AC_CHECK_PROG(HAVE_GIT,git,"yes","no",)
728 718
 if test "$GIT_REV" = ""; then
@@ -2409,7 +2399,8 @@ OUTPUT_FILES="Makefile \
2409 2399
     xbmc/android/loader/Makefile \
2410 2400
     xbmc/android/jni/Makefile \
2411 2401
     xbmc/utils/Makefile \
2412  
-    xbmc/main/Makefile"
  2402
+    xbmc/main/Makefile \
  2403
+    project/cmake/xbmc-config.cmake"
2413 2404
 
2414 2405
 if test "$use_skin_touched" = "yes"; then
2415 2406
 OUTPUT_FILES="$OUTPUT_FILES addons/skin.touched/media/Makefile"
51  m4/xbmc_arch.m4
... ...
@@ -0,0 +1,51 @@
  1
+AC_DEFUN([XBMC_SETUP_ARCH_DEFINES],[
  2
+
  3
+# host detection and setup
  4
+case $host in
  5
+  i*86*-linux-gnu*)
  6
+     AC_SUBST(ARCH_DEFINES, "-DTARGET_POSIX -DTARGET_LINUX -D_LINUX")
  7
+     ;;
  8
+  x86_64-*-linux-gnu*)
  9
+     AC_SUBST(ARCH_DEFINES, "-DTARGET_POSIX -DTARGET_LINUX -D_LINUX")
  10
+     ;;
  11
+  i386-*-freebsd*)
  12
+     AC_SUBST(ARCH_DEFINES, "-DTARGET_POSIX -DTARGET_FREEBSD -D_LINUX")
  13
+     ;;
  14
+  amd64-*-freebsd*)
  15
+     AC_SUBST(ARCH_DEFINES, "-DTARGET_POSIX -DTARGET_FREEBSD -D_LINUX")
  16
+     ;;
  17
+  arm-apple-darwin*)
  18
+     AC_SUBST(ARCH_DEFINES, "-DTARGET_POSIX -DTARGET_DARWIN -DTARGET_DARWIN_IOS -D_LINUX")
  19
+     ;;
  20
+  *86*-apple-darwin*)
  21
+     AC_SUBST(ARCH_DEFINES, "-DTARGET_POSIX -DTARGET_DARWIN -DTARGET_DARWIN_OSX -D_LINUX")
  22
+     ;;
  23
+  powerpc-apple-darwin*)
  24
+     AC_SUBST(ARCH_DEFINES, "-DTARGET_POSIX -DTARGET_DARWIN -DTARGET_DARWIN_OSX -D_LINUX")
  25
+     ;;
  26
+  powerpc-*-linux-gnu*)
  27
+     AC_SUBST(ARCH_DEFINES, "-DTARGET_POSIX -DTARGET_LINUX -D_LINUX -D_POWERPC")
  28
+     ;;
  29
+  powerpc64-*-linux-gnu*)
  30
+     AC_SUBST(ARCH_DEFINES, "-DTARGET_POSIX -DTARGET_LINUX -D_LINUX -D_POWERPC64")
  31
+     ;;
  32
+  arm*-*-linux-gnu*)
  33
+     AC_SUBST(ARCH_DEFINES, "-DTARGET_POSIX -DTARGET_LINUX -D_LINUX")
  34
+     ;;
  35
+  arm*-*linux-android*)
  36
+     AC_SUBST(ARCH_DEFINES, "-DTARGET_POSIX -DTARGET_LINUX -D_LINUX -DTARGET_ANDROID")
  37
+     ;;
  38
+  *)
  39
+     AC_MSG_ERROR(unsupported host ($host))
  40
+esac
  41
+
  42
+if test "$target_platform" = "target_android" ; then
  43
+  AC_SUBST(ARCH_DEFINES, "-DTARGET_POSIX -DTARGET_LINUX -D_LINUX -DTARGET_ANDROID")
  44
+fi
  45
+
  46
+case $use_platform in
  47
+  raspberry-pi)
  48
+     AC_SUBST(ARCH_DEFINES, "-DTARGET_POSIX -DTARGET_LINUX -D_LINUX -D_ARMEL -DTARGET_RASPBERRY_PI")
  49
+     ;;
  50
+esac
  51
+])
82  project/cmake/AddOptions.cmake
... ...
@@ -0,0 +1,82 @@
  1
+# - Add options without repeating them on the command line
  2
+#
  3
+# Synopsis:
  4
+#
  5
+#	add_options (lang build opts)
  6
+#
  7
+# where:
  8
+#
  9
+#	lang       Name of the language whose compiler should receive the
  10
+#	           options, e.g. CXX. If a comma-separated list is received
  11
+#	           then the option is added for all those languages. Use the
  12
+#	           special value ALL_LANGUAGES for these languages: CXX, C
  13
+#	           and Fortran
  14
+#
  15
+#	build      Kind of build to which this options should apply,
  16
+#              such as DEBUG and RELEASE. This can also be a comma-
  17
+#	           separated list. Use the special value ALL_BUILDS to apply
  18
+#	           to all builds.
  19
+#
  20
+#	opts       List of options to add. Each should be quoted.
  21
+#
  22
+# Example:
  23
+#
  24
+#	add_options (CXX RELEASE "-O3" "-DNDEBUG" "-Wall")
  25
+
  26
+function (add_options langs builds)
  27
+  # special handling of empty language specification
  28
+  if ("${langs}" STREQUAL "ALL_LANGUAGES")
  29
+	set (langs CXX C Fortran)
  30
+  endif ("${langs}" STREQUAL "ALL_LANGUAGES")
  31
+  foreach (lang IN LISTS langs)
  32
+	# prepend underscore if necessary
  33
+	foreach (build IN LISTS builds)
  34
+	  if (NOT ("${build}" STREQUAL "ALL_BUILDS"))
  35
+		set (_bld "_${build}")
  36
+		string (TOUPPER "${_bld}" _bld)
  37
+	  else (NOT ("${build}" STREQUAL "ALL_BUILDS"))
  38
+		set (_bld "")
  39
+	  endif (NOT ("${build}" STREQUAL "ALL_BUILDS"))
  40
+	  foreach (_opt IN LISTS ARGN)
  41
+		set (_var "CMAKE_${lang}_FLAGS${_bld}")
  42
+		#message (STATUS "Adding \"${_opt}\" to \${${_var}}")
  43
+		# remove it first
  44
+		string (REPLACE "${_opt}" "" _without "${${_var}}")
  45
+		string (STRIP "${_without}" _without)
  46
+		# we need to strip this one as well, so they are comparable
  47
+		string (STRIP "${${_var}}" _stripped)
  48
+		# if it wasn't there, then add it at the end
  49
+		if ("${_without}" STREQUAL "${_stripped}")
  50
+		  # don't add any extra spaces if no options yet are set
  51
+		  if (NOT ${_stripped} STREQUAL "")
  52
+			set (${_var} "${_stripped} ${_opt}")
  53
+		  else (NOT ${_stripped} STREQUAL "")
  54
+			set (${_var} "${_opt}")
  55
+		  endif (NOT ${_stripped} STREQUAL "")
  56
+		  set (${_var} "${${_var}}" PARENT_SCOPE)
  57
+		endif ("${_without}" STREQUAL "${_stripped}")
  58
+	  endforeach (_opt)
  59
+	endforeach (build)
  60
+  endforeach (lang)
  61
+endfunction (add_options lang build)
  62
+
  63
+# set varname to flag unless user has specified something that matches regex
  64
+function (set_default_option varname flag regex)
  65
+  if (NOT "$ENV{CXXFLAGS}" MATCHES "${regex}"
  66
+	  AND NOT "${CMAKE_CXX_FLAGS}" MATCHES "${regex}"
  67
+	  AND NOT "${CMAKE_CXX_FLAGS_${CMAKE_BUILD_TYPE}}" MATCHES "${regex}")
  68
+	set (${varname} ${flag} PARENT_SCOPE)
  69
+  else (NOT "$ENV{CXXFLAGS}" MATCHES "${regex}"
  70
+	  AND NOT "${CMAKE_CXX_FLAGS}" MATCHES "${regex}"
  71
+	  AND NOT "${CMAKE_CXX_FLAGS_${CMAKE_BUILD_TYPE}}" MATCHES "${regex}")
  72
+	set (${varname} PARENT_SCOPE)
  73
+  endif (NOT "$ENV{CXXFLAGS}" MATCHES "${regex}"
  74
+	AND NOT "${CMAKE_CXX_FLAGS}" MATCHES "${regex}"
  75
+	AND NOT "${CMAKE_CXX_FLAGS_${CMAKE_BUILD_TYPE}}" MATCHES "${regex}")
  76
+endfunction (set_default_option)
  77
+
  78
+# note: this must be called before project()
  79
+macro (no_default_options)
  80
+  # prevent the platform probe to set options
  81
+  set (CMAKE_NOT_USING_CONFIG_FLAGS TRUE)
  82
+endmacro (no_default_options)
64  project/cmake/xbmc-addon-helpers.cmake
... ...
@@ -0,0 +1,64 @@
  1
+# Install an add-on in the appropriate way
  2
+macro (install_addon target version)
  3
+  IF(PACKAGE_ZIP OR PACKAGE_TGZ)
  4
+    # Pack files together to create an archive
  5
+    INSTALL(DIRECTORY ${target} DESTINATION ./)
  6
+    IF(WIN32)
  7
+      INSTALL(PROGRAMS ${CMAKE_BINARY_DIR}/${target}.dll DESTINATION ${target})
  8
+    ELSE(WIN32)
  9
+      INSTALL(TARGETS ${target} DESTINATION ${target})
  10
+    ENDIF(WIN32)
  11
+    IF(PACKAGE_ZIP)
  12
+      SET(CPACK_GENERATOR "ZIP")
  13
+    ENDIF(PACKAGE_ZIP)
  14
+    IF(PACKAGE_TGZ)
  15
+      SET(CPACK_GENERATOR "TGZ")
  16
+    ENDIF(PACKAGE_TGZ)
  17
+    SET(CPACK_INCLUDE_TOPLEVEL_DIRECTORY OFF)
  18
+    SET(CPACK_PACKAGE_FILE_NAME ${target}-${version})
  19
+    IF(CMAKE_BUILD_TYPE STREQUAL "Release")
  20
+      SET(CPACK_STRIP_FILES TRUE)
  21
+    ENDIF(CMAKE_BUILD_TYPE STREQUAL "Release")
  22
+    INCLUDE(CPack)
  23
+  ELSE(PACKAGE_ZIP OR PACKAGE_TGZ)
  24
+    INSTALL(TARGETS ${target} DESTINATION lib/xbmc/addons/${target})
  25
+    INSTALL(DIRECTORY ${target} DESTINATION share/xbmc/addons)
  26
+  ENDIF(PACKAGE_ZIP OR PACKAGE_TGZ)
  27
+endmacro()
  28
+
  29
+# Grab the version from a given add-on's addon.xml
  30
+macro (addon_version dir prefix)
  31
+  FILE(READ ${dir}/addon.xml ADDONXML)
  32
+  STRING(REGEX MATCH "<addon[^>]*version.?=.?.[0-9\\.]+" VERSION_STRING ${ADDONXML}) 
  33
+  STRING(REGEX REPLACE ".*version=.([0-9\\.]+).*" "\\1" ${prefix}_VERSION ${VERSION_STRING})
  34
+  message(STATUS ${prefix}_VERSION=${${prefix}_VERSION})
  35
+endmacro()
  36
+
  37
+# Prepare the add-on build environment
  38
+macro (prepare_addon_environment)
  39
+  IF(WIN32)
  40
+    SET(BINDING_FILE ${XBMC_BINDINGS}.zip)
  41
+    message (STATUS "downloading XBMC bindings: " ${BINDING_FILE})
  42
+    file(DOWNLOAD http://mirrors.xbmc.org/build-deps/win32/${BINDING_FILE} ${CMAKE_BINARY_DIR}/downloads/${BINDING_FILE} STATUS STATUSLIST SHOW_PROGRESS)
  43
+    LIST(GET STATUSLIST 0 VALUE)
  44
+    IF(${VALUE} STRGREATER "0")
  45
+      LIST(GET STATUSLIST 1 VALUE)
  46
+      message (STATUS "failed to download XBMC bindings: " ${VALUE})
  47
+    ENDIF(${VALUE} STRGREATER "0")
  48
+    execute_process(
  49
+      COMMAND ${CMAKE_COMMAND} -E tar xzf ${CMAKE_BINARY_DIR}/downloads/${BINDING_FILE}
  50
+    )
  51
+  ENDIF(WIN32)
  52
+endmacro()
  53
+
  54
+# Build and link an add-on
  55
+macro (build_addon target sources libs version)
  56
+  ADD_LIBRARY(${target} ${${sources}})
  57
+  TARGET_LINK_LIBRARIES(${target} ${${libs}})
  58
+  SET_TARGET_PROPERTIES(${target} PROPERTIES VERSION ${${version}}
  59
+                                             SOVERSION 13.0
  60
+                                             PREFIX "")
  61
+  IF(OS STREQUAL "android")
  62
+    SET_TARGET_PROPERTIES(${target} PROPERTIES PREFIX "lib")
  63
+  ENDIF(OS STREQUAL "android")
  64
+endmacro()
10  project/cmake/xbmc-config.cmake.in
... ...
@@ -0,0 +1,10 @@
  1
+SET(XBMC_INCLUDE_DIR @prefix@/include)
  2
+LIST(APPEND CMAKE_MODULE_PATH @prefix@/lib/xbmc)
  3
+ADD_DEFINITIONS(@ARCH_DEFINES@)
  4
+
  5
+include(xbmc-addon-helpers)
  6
+include(AddOptions)
  7
+prepare_addon_environment()
  8
+
  9
+OPTION(PACKAGE_ZIP "Package Zip file?" OFF)
  10
+OPTION(PACKAGE_TGZ "Package TGZ file?" OFF)
1  tools/depends/Makefile.include.in
@@ -16,6 +16,7 @@ PREFIX=@prefix@/@deps_dir@
16 16
 NATIVEPREFIX=@prefix@/@tool_dir@
17 17
 OS=@platform_os@
18 18
 CROSS_COMPILING=@cross_compiling@
  19
+ARCH_DEFINES=@ARCH_DEFINES@
19 20
 
20 21
 HAS_ZLIB=@has_zlib@
21 22
 NEED_LIBICONV=@need_libiconv@
3  tools/depends/configure.in
@@ -4,6 +4,7 @@ AC_INIT([xbmc-depends], [2.00], [http://trac.xbmc.org])
4 4
 AC_CONFIG_AUX_DIR([build-aux])
5 5
 AC_CONFIG_FILES([target/config.site native/config.site.native Makefile.include target/Toolchain.cmake])
6 6
 AC_CANONICAL_HOST
  7
+m4_include([../../m4/xbmc_arch.m4])
7 8
 
8 9
 AC_ARG_WITH([toolchain],
9 10
   [AS_HELP_STRING([--with-toolchain],
@@ -244,6 +245,8 @@ case $host in
244 245
     AC_MSG_ERROR(unsupported host ($use_host))
245 246
 esac
246 247
 
  248
+XBMC_SETUP_ARCH_DEFINES()
  249
+
247 250
 platform_cflags+=" $passed_cflags"
248 251
 platform_ldflags+=" $passed_ldflags $LIBS"
249 252
 platform_cxxflags+=" $passed_cxxflags"
4  tools/depends/target/xbmc-addon-bindings/Makefile
@@ -28,6 +28,10 @@ all: .installed-$(PLATFORM)
28 28
 	@for f in $(BINDINGS); do \
29 29
 	  cp -f $(XBMCROOT)/$$f $(PREFIX)/include/xbmc ; \
30 30
 	done
  31
+	@mkdir -p $(PREFIX)/lib/xbmc
  32
+	@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
  33
+	@cp -f $(XBMCROOT)/project/cmake/xbmc-addon-helpers.cmake $(PREFIX)/lib/xbmc
  34
+	@cp -f $(XBMCROOT)/project/cmake/AddOptions.cmake $(PREFIX)/lib/xbmc
31 35
 	@touch $@
32 36
 
33 37
 clean:

0 notes on commit 398c33e

Please sign in to comment.
Something went wrong with that request. Please try again.