summaryrefslogtreecommitdiffstats
path: root/cmake/scripts/common/Platform.cmake
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-10 18:07:22 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-10 18:07:22 +0000
commitc04dcc2e7d834218ef2d4194331e383402495ae1 (patch)
tree7333e38d10d75386e60f336b80c2443c1166031d /cmake/scripts/common/Platform.cmake
parentInitial commit. (diff)
downloadkodi-c04dcc2e7d834218ef2d4194331e383402495ae1.tar.xz
kodi-c04dcc2e7d834218ef2d4194331e383402495ae1.zip
Adding upstream version 2:20.4+dfsg.upstream/2%20.4+dfsg
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'cmake/scripts/common/Platform.cmake')
-rw-r--r--cmake/scripts/common/Platform.cmake57
1 files changed, 57 insertions, 0 deletions
diff --git a/cmake/scripts/common/Platform.cmake b/cmake/scripts/common/Platform.cmake
new file mode 100644
index 0000000..397d8d4
--- /dev/null
+++ b/cmake/scripts/common/Platform.cmake
@@ -0,0 +1,57 @@
+if(NOT CORE_SYSTEM_NAME)
+ string(TOLOWER ${CMAKE_SYSTEM_NAME} CORE_SYSTEM_NAME)
+endif()
+
+if(CORE_SYSTEM_NAME STREQUAL linux OR CORE_SYSTEM_NAME STREQUAL freebsd)
+ # Set default CORE_PLATFORM_NAME to X11 WAYLAND GBM
+ # This is overridden by user setting -DCORE_PLATFORM_NAME=<platform>
+ set(_DEFAULT_PLATFORM X11 WAYLAND GBM)
+
+ if(NOT APP_RENDER_SYSTEM)
+ message(SEND_ERROR "You need to decide whether you want to use GL- or GLES-based rendering. Please set APP_RENDER_SYSTEM to either \"gl\" or \"gles\". For normal desktop systems, you will usually want to use \"gl\".")
+ endif()
+else()
+ string(TOLOWER ${CORE_SYSTEM_NAME} _DEFAULT_PLATFORM)
+endif()
+
+set(APP_BINARY_SUFFIX ".bin")
+
+#
+# Note: please do not use CORE_PLATFORM_NAME in any checks,
+# use the normalized to lower case CORE_PLATFORM_NAME_LC (see below) instead
+#
+if(NOT CORE_PLATFORM_NAME)
+ set(CORE_PLATFORM_NAME ${_DEFAULT_PLATFORM})
+endif()
+set(CORE_PLATFORM_NAME ${CORE_PLATFORM_NAME} CACHE STRING "Platform port to build" FORCE)
+unset(_DEFAULT_PLATFORM)
+
+string(REPLACE " " ";" CORE_PLATFORM_NAME "${CORE_PLATFORM_NAME}")
+foreach(platform IN LISTS CORE_PLATFORM_NAME)
+ string(TOLOWER ${platform} platform)
+ list(APPEND CORE_PLATFORM_NAME_LC ${platform})
+endforeach()
+
+string(REPLACE ";" " " CORE_PLATFORM_STRING "${CORE_PLATFORM_NAME_LC}")
+list(APPEND final_message "Platforms: ${CORE_PLATFORM_STRING}")
+
+if(CORE_SYSTEM_NAME STREQUAL linux OR CORE_SYSTEM_NAME STREQUAL freebsd)
+ list(LENGTH CORE_PLATFORM_NAME_LC PLATFORM_COUNT)
+ if(PLATFORM_COUNT EQUAL 1)
+ option(ENABLE_APP_AUTONAME "Enable renaming the binary according to windowing?" ON)
+ if(ENABLE_APP_AUTONAME)
+ set(APP_BINARY_SUFFIX "-${CORE_PLATFORM_NAME_LC}")
+ endif()
+ endif()
+endif()
+
+foreach(CORE_PLATFORM_LC IN LISTS CORE_PLATFORM_NAME_LC)
+ if(EXISTS ${CMAKE_SOURCE_DIR}/cmake/platform/${CORE_SYSTEM_NAME}/${CORE_PLATFORM_LC}.cmake)
+ include(${CMAKE_SOURCE_DIR}/cmake/platform/${CORE_SYSTEM_NAME}/${CORE_PLATFORM_LC}.cmake)
+ else()
+ file(GLOB _platformnames RELATIVE ${CMAKE_SOURCE_DIR}/cmake/platform/${CORE_SYSTEM_NAME}/
+ ${CMAKE_SOURCE_DIR}/cmake/platform/${CORE_SYSTEM_NAME}/*.cmake)
+ string(REPLACE ".cmake" " " _platformnames ${_platformnames})
+ message(FATAL_ERROR "invalid CORE_PLATFORM_NAME: ${CORE_PLATFORM_NAME_LC}\nValid platforms: ${_platformnames}")
+ endif()
+endforeach()