Browse Source

Enable package filtering by license in Distribution builds, and disable most packages by default in MinSizeRel builds.

kestred 12 years ago
parent
commit
bb19d8cb23
3 changed files with 51 additions and 7 deletions
  1. 36 4
      cmake/macros/PackageConfig.cmake
  2. 5 2
      dtool/Config.cmake
  3. 10 1
      dtool/PandaVersion.cmake

+ 36 - 4
cmake/macros/PackageConfig.cmake

@@ -7,11 +7,14 @@
 #
 # Function: package_option
 # Usage:
-#   package_option(package_name DOCSTRING [DEFAULT ON | OFF])
+#   package_option(package_name DOCSTRING
+#                  [DEFAULT ON | OFF]
+#                  [LICENSE license])
 # Examples:
-#   add_library(mylib ${SOURCES})
+#   package_option(LIBNAME "Enables LIBNAME support." DEFAULT OFF)
 #
-#       If no default is given, the default is whether the package was found.
+#       If no default is given, the default in normal
+#       builds is to enable all found third-party packages.
 #
 #
 # Function: target_use_packages
@@ -29,6 +32,7 @@ function(package_option name)
   # Parse the arguments.
   set(command)
   set(default)
+  set(license)
   set(cache_string)
 
   foreach(arg ${ARGN})
@@ -36,9 +40,16 @@ function(package_option name)
       set(default "${arg}")
       set(command)
 
+    elseif(command STREQUAL "LICENSE")
+      set(license "${arg}")
+      set(command)
+
     elseif(arg STREQUAL "DEFAULT")
       set(command "DEFAULT")
 
+    elseif(arg STREQUAL "LICENSE")
+      set(command "LICENSE")
+
     else()
       # Yes, a list, because semicolons can be in there, and
       # that gets split up into multiple args, so we have to
@@ -54,7 +65,28 @@ function(package_option name)
 
   # If the default is not set, we set it.
   if(NOT DEFINED default)
-    set(default "${${name}_FOUND}")
+    if(IS_DIST_BUILD)
+      # Accept things that don't have a configured license
+      if(license STREQUAL "")
+        set(default "${${name}_FOUND}")
+
+      else()
+        list(FIND PANDA_DIST_USE_LICENSES ${license} license_index)
+        # If the license isn't in the accept listed, don't use the package
+        if(license_index EQUAL -1)
+          set(default OFF)
+        else
+          set(default "${${name}_FOUND}")
+        endif()
+      endif()
+
+    elseif(IS_MINSIZE_BUILD)
+      set(default OFF)
+
+    else()
+      set(default "${${name}_FOUND}")
+
+    endif()
   endif()
 
   # If it was set by the user but not found, display an error.

+ 5 - 2
dtool/Config.cmake

@@ -74,6 +74,7 @@ else()
   set(DEFAULT_PATHSEP ":")
 endif()
 
+
 # Panda uses prc files for runtime configuration.  There are many
 # compiled-in options to customize the behavior of the prc config
 # system; most users won't need to change any of them.  Feel free to
@@ -410,7 +411,8 @@ If this is provided, Panda will use this library as the fundamental
 implementation of its own linmath library; otherwise, it will use
 its own internal implementation.  The primary advantage of using
 Eigen is SSE2 support, which is only activated if LINMATH_ALIGN
-is also enabled.")
+is also enabled."
+  LICENSE "MPL-2")
 
 option(LINMATH_ALIGN
   "This is required for activating SSE2 support using Eigen.
@@ -537,7 +539,8 @@ package_option(CGDX10 "Enable support for Nvidia Cg's DX10 API.")
 find_package(VRPN)
 
 package_option(VRPN
-  "Enables support for connecting to VRPN servers.")
+  "Enables support for connecting to VRPN servers."
+  LICENSE "Nvidia")
 
 
 # TODO: Helix

+ 10 - 1
dtool/PandaVersion.cmake

@@ -19,6 +19,14 @@ set(PANDA_DISTRIBUTOR homebuilt CACHE STRING
 It should be set by whoever provides a particular distribution of
 Panda.  If you build your own Panda, leave this unchanged.")
 
+set(PANDA_DIST_USE_LICENSES "BSD-3;BSD-2;MIT" CACHE STRING
+  "This is a list of allowed licenses for 3rd-party packages to build
+support for when performing a Distribution build of Panda3d.
+Note: This only is checked for packages that CMake has declared with a
+particular license. Some packages don't have a listed license because
+they are almost always required/used, or because they are only used in
+plugins that can be easily removed (eg. directx, ffmpeg, fmod, ...).")
+
 set(PANDA_PACKAGE_VERSION CACHE STRING
   "This string is used to describe the Panda3D \"package\" associated
 with this current build of Panda. It should increment with major
@@ -48,7 +56,8 @@ the first three matching the plugin version, and the fourth integer
 being incremented with each new Core API revision.")
 
 mark_as_advanced(PANDA_VERSION PANDA_OFFICIAL_VERSION
-  PANDA_PACKAGE_VERSION P3D_PLUGIN_VERSION P3D_COREAPI_VERSION)
+  PANDA_PACKAGE_VERSION P3D_PLUGIN_VERSION P3D_COREAPI_VERSION
+  PANDA_DIST_USE_LICENSES)
 
 # Separate the Panda3D version into its three components.
 string(REPLACE "." ";" PANDA_VERSION_LIST "${PANDA_VERSION}")