aboutsummaryrefslogtreecommitdiff
path: root/cmake/scripts/common
diff options
context:
space:
mode:
authorfuzzard <fuzzard@kodi.tv>2022-09-27 15:28:53 +1000
committerfuzzard <fuzzard@kodi.tv>2022-09-28 14:17:10 +1000
commit0699e2a4665ed773319e970bc972bcbda623b3ce (patch)
tree6fe80bc59b44bed0a0d8fce1077d7d7e619ea6f3 /cmake/scripts/common
parentddef8092ef0c247ae3ad0528e0b4c880fa475615 (diff)
[cmake] dependent_option function
This function allows us to handle in a generic way our use of internal lib state, and to then allow it to be overridden more easily by the user. cmake_dependent_option has proven too restrictive for our use of it.
Diffstat (limited to 'cmake/scripts/common')
-rw-r--r--cmake/scripts/common/DependencyOptions.cmake23
1 files changed, 23 insertions, 0 deletions
diff --git a/cmake/scripts/common/DependencyOptions.cmake b/cmake/scripts/common/DependencyOptions.cmake
new file mode 100644
index 0000000000..a45dcec553
--- /dev/null
+++ b/cmake/scripts/common/DependencyOptions.cmake
@@ -0,0 +1,23 @@
+# Set Option varname based on USE_INTERNAL_LIBS status
+#
+# Alternative to cmake_dependent_option
+# cmake_dependent_option is restrictive, in the fact that we cannot override the
+# set option value as a cache variable (-Dvar=foo)
+#
+# This allows us to have the same outcome as cmake_dependent_option whilst still allowing
+# user to override for platforms that would normally be forced ON
+#
+function(dependent_option varname optionmessage)
+
+ # If varname already set, accept that, as it was provided by the user
+ if(NOT DEFINED ${varname})
+ # Generally we only define USE_INTERNAL_LIBS as the exception for platforms
+ # we explicitly dont want to build internal libs (eg Linux/Freebsd)
+ if(NOT DEFINED USE_INTERNAL_LIBS)
+ option(${varname} ${optionmessage} ON)
+ else()
+ # Respect Value of USE_INTERNAL_LIBS for ON/OFF
+ option(${varname} ${optionmessage} ${USE_INTERNAL_LIBS})
+ endif()
+ endif()
+endfunction()