|
@@ -1,13 +1,14 @@
|
|
|
# Filename: PackageConfig.cmake
|
|
# Filename: PackageConfig.cmake
|
|
|
#
|
|
#
|
|
|
-# This modules defines functions which find and configures libraries
|
|
|
|
|
-# and packages for Panda3Ds configuration file headers (.h files).
|
|
|
|
|
|
|
+# This module defines functions which find and configure libraries
|
|
|
|
|
+# and packages for Panda3D.
|
|
|
#
|
|
#
|
|
|
-# Assumes the file has already been found with find_package().
|
|
|
|
|
|
|
+# Assumes an attempt to find the package has already been made with
|
|
|
|
|
+# find_package(). (i.e. relies on packagename_FOUND variable)
|
|
|
#
|
|
#
|
|
|
# Function: package_option
|
|
# Function: package_option
|
|
|
# Usage:
|
|
# Usage:
|
|
|
-# package_option(package_name DOCSTRING
|
|
|
|
|
|
|
+# package_option(package_name package_doc_string
|
|
|
# [DEFAULT ON | OFF]
|
|
# [DEFAULT ON | OFF]
|
|
|
# [LICENSE license])
|
|
# [LICENSE license])
|
|
|
# Examples:
|
|
# Examples:
|
|
@@ -15,6 +16,24 @@
|
|
|
#
|
|
#
|
|
|
# If no default is given, the default in normal
|
|
# If no default is given, the default in normal
|
|
|
# builds is to enable all found third-party packages.
|
|
# builds is to enable all found third-party packages.
|
|
|
|
|
+# In builds for redistribution, there is the additional requirement that
|
|
|
|
|
+# the package be suitably-licensed.
|
|
|
|
|
+#
|
|
|
|
|
+#
|
|
|
|
|
+# Function: config_package
|
|
|
|
|
+# Usage:
|
|
|
|
|
+# config_package(package_name "Package description" ["Config summary"])
|
|
|
|
|
+# Examples:
|
|
|
|
|
+# config_package(OpenAL "OpenAL Audio Output")
|
|
|
|
|
+# config_package(ROCKET "Rocket" "without Python bindings")
|
|
|
|
|
+#
|
|
|
|
|
+#
|
|
|
|
|
+# Function: show_packages
|
|
|
|
|
+# Usage:
|
|
|
|
|
+# show_packages()
|
|
|
|
|
+#
|
|
|
|
|
+# This prints the package usage report using the information provided in
|
|
|
|
|
+# calls to config_package above.
|
|
|
#
|
|
#
|
|
|
#
|
|
#
|
|
|
# Function: target_use_packages
|
|
# Function: target_use_packages
|
|
@@ -24,10 +43,18 @@
|
|
|
# target_use_packages(mylib PYTHON PNG)
|
|
# target_use_packages(mylib PYTHON PNG)
|
|
|
#
|
|
#
|
|
|
|
|
|
|
|
-
|
|
|
|
|
#
|
|
#
|
|
|
# package_option
|
|
# package_option
|
|
|
#
|
|
#
|
|
|
|
|
+# In order to make sure no third-party licenses are inadvertently violated,
|
|
|
|
|
+# this imposes a few rules regarding license:
|
|
|
|
|
+# 1) If there is no license, no special restrictions.
|
|
|
|
|
+# 2) If there is a license, but the build is not flagged for redistribution,
|
|
|
|
|
+# no special restrictions.
|
|
|
|
|
+# 3) If there is a license, and this is for redistribution, the package is
|
|
|
|
|
+# forcibly defaulted off and must be explicitly enabled, unless the license
|
|
|
|
|
+# matches a list of licenses suitable for redistribution.
|
|
|
|
|
+#
|
|
|
function(package_option name)
|
|
function(package_option name)
|
|
|
# Parse the arguments.
|
|
# Parse the arguments.
|
|
|
set(command)
|
|
set(command)
|
|
@@ -104,6 +131,8 @@ function(package_option name)
|
|
|
set(PANDA_DID_SET_OPTION_${name} TRUE PARENT_SCOPE)
|
|
set(PANDA_DID_SET_OPTION_${name} TRUE PARENT_SCOPE)
|
|
|
endif()
|
|
endif()
|
|
|
|
|
|
|
|
|
|
+ set(PANDA_PACKAGE_DEFAULT_${name} "${default}")
|
|
|
|
|
+
|
|
|
# Create the option.
|
|
# Create the option.
|
|
|
option("HAVE_${name}" "${cache_string}" "${default}")
|
|
option("HAVE_${name}" "${cache_string}" "${default}")
|
|
|
if(HAVE_${name})
|
|
if(HAVE_${name})
|
|
@@ -115,6 +144,64 @@ function(package_option name)
|
|
|
endif()
|
|
endif()
|
|
|
endfunction()
|
|
endfunction()
|
|
|
|
|
|
|
|
|
|
+set(_ALL_CONFIG_PACKAGES CACHE INTERNAL "Internal variable")
|
|
|
|
|
+
|
|
|
|
|
+#
|
|
|
|
|
+# config_package
|
|
|
|
|
+#
|
|
|
|
|
+function(config_package name desc)
|
|
|
|
|
+ set(note "")
|
|
|
|
|
+ foreach(arg ${ARGN})
|
|
|
|
|
+ set(note "${arg}")
|
|
|
|
|
+ endforeach()
|
|
|
|
|
+
|
|
|
|
|
+ if(NOT PANDA_DID_SET_OPTION_${name})
|
|
|
|
|
+ message(SEND_ERROR "config_package(${name}) was called before package_option(${name}).
|
|
|
|
|
+ This is a bug in the cmake build scripts.")
|
|
|
|
|
+ endif()
|
|
|
|
|
+
|
|
|
|
|
+ list(FIND _ALL_CONFIG_PACKAGES "${name}" called_twice)
|
|
|
|
|
+ if(called_twice GREATER -1)
|
|
|
|
|
+ message(SEND_ERROR "config_package(${name}) was called twice.
|
|
|
|
|
+ This is a bug in the cmake build scripts.")
|
|
|
|
|
+ else()
|
|
|
|
|
+ list(APPEND _ALL_CONFIG_PACKAGES "${name}")
|
|
|
|
|
+ set(_ALL_CONFIG_PACKAGES "${_ALL_CONFIG_PACKAGES}" CACHE INTERNAL "Internal variable")
|
|
|
|
|
+ endif()
|
|
|
|
|
+
|
|
|
|
|
+ set(PANDA_PACKAGE_DESC_${name} "${desc}" PARENT_SCOPE)
|
|
|
|
|
+ set(PANDA_PACKAGE_NOTE_${name} "${note}" PARENT_SCOPE)
|
|
|
|
|
+endfunction()
|
|
|
|
|
+
|
|
|
|
|
+#
|
|
|
|
|
+# show_packages
|
|
|
|
|
+#
|
|
|
|
|
+function(show_packages)
|
|
|
|
|
+ message("")
|
|
|
|
|
+ message("Configuring support for the following optional third-party packages:")
|
|
|
|
|
+
|
|
|
|
|
+ foreach(package ${_ALL_CONFIG_PACKAGES})
|
|
|
|
|
+ set(desc "${PANDA_PACKAGE_DESC_${package}}")
|
|
|
|
|
+ set(note "${PANDA_PACKAGE_NOTE_${package}}")
|
|
|
|
|
+ if(HAVE_${package})
|
|
|
|
|
+ if(NOT note STREQUAL "")
|
|
|
|
|
+ message("+ ${desc} (${note})")
|
|
|
|
|
+ else()
|
|
|
|
|
+ message("+ ${desc}")
|
|
|
|
|
+ endif()
|
|
|
|
|
+ else()
|
|
|
|
|
+ if(NOT ${package}_FOUND)
|
|
|
|
|
+ set(reason "not found")
|
|
|
|
|
+ elseif(PANDA_PACKAGE_DEFAULT_${package})
|
|
|
|
|
+ set(reason "not requested")
|
|
|
|
|
+ else()
|
|
|
|
|
+ set(reason "disabled")
|
|
|
|
|
+ endif()
|
|
|
|
|
+ message("- ${desc} (${reason})")
|
|
|
|
|
+ endif()
|
|
|
|
|
+ endforeach()
|
|
|
|
|
+endfunction()
|
|
|
|
|
+
|
|
|
#
|
|
#
|
|
|
# target_use_packages
|
|
# target_use_packages
|
|
|
#
|
|
#
|