summaryrefslogtreecommitdiffstats
path: root/cmake/scripts/common/Platform.cmake
diff options
context:
space:
mode:
Diffstat (limited to 'cmake/scripts/common/Platform.cmake')
-rw-r--r--cmake/scripts/common/Platform.cmake32
1 files changed, 32 insertions, 0 deletions
diff --git a/cmake/scripts/common/Platform.cmake b/cmake/scripts/common/Platform.cmake
new file mode 100644
index 0000000..b19b7e5
--- /dev/null
+++ b/cmake/scripts/common/Platform.cmake
@@ -0,0 +1,32 @@
1if(NOT CORE_SYSTEM_NAME)
2 string(TOLOWER ${CMAKE_SYSTEM_NAME} CORE_SYSTEM_NAME)
3endif()
4
5if(CORE_SYSTEM_NAME STREQUAL linux)
6 # Set default CORE_PLATFORM_NAME to X11
7 # This is overridden by user setting -DCORE_PLATFORM_NAME=<platform>
8 set(_DEFAULT_PLATFORM X11)
9else()
10 string(TOLOWER ${CORE_SYSTEM_NAME} _DEFAULT_PLATFORM)
11endif()
12
13#
14# Note: please do not use CORE_PLATFORM_NAME in any checks,
15# use the normalized to lower case CORE_PLATFORM_NAME_LC (see below) instead
16#
17if(NOT CORE_PLATFORM_NAME)
18 set(CORE_PLATFORM_NAME ${_DEFAULT_PLATFORM} CACHE STRING "Platform port to build")
19endif()
20unset(_DEFAULT_PLATFORM)
21string(TOLOWER ${CORE_PLATFORM_NAME} CORE_PLATFORM_NAME_LC)
22
23list(APPEND final_message "Platform: ${CORE_PLATFORM_NAME}")
24if(EXISTS ${CMAKE_SOURCE_DIR}/cmake/platform/${CORE_SYSTEM_NAME}/${CORE_PLATFORM_NAME_LC}.cmake)
25 include(${CMAKE_SOURCE_DIR}/cmake/platform/${CORE_SYSTEM_NAME}/${CORE_PLATFORM_NAME_LC}.cmake)
26else()
27 file(GLOB _platformnames RELATIVE ${CMAKE_SOURCE_DIR}/cmake/platform/${CORE_SYSTEM_NAME}/
28 ${CMAKE_SOURCE_DIR}/cmake/platform/${CORE_SYSTEM_NAME}/*.cmake)
29 string(REPLACE ".cmake" " " _platformnames ${_platformnames})
30 message(FATAL_ERROR "invalid CORE_PLATFORM_NAME: ${CORE_PLATFORM_NAME_LC}\nValid platforms: ${_platformnames}")
31endif()
32