From 4c3251ec645c8b71820dab7e51e612e5919d4e75 Mon Sep 17 00:00:00 2001 From: manuel Date: Sun, 23 Jul 2017 16:59:43 +0200 Subject: sync with upstream --- cmake/scripts/common/Platform.cmake | 32 ++++++++++++++++++++++++++++++++ 1 file changed, 32 insertions(+) create mode 100644 cmake/scripts/common/Platform.cmake (limited to 'cmake/scripts/common/Platform.cmake') 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 @@ +if(NOT CORE_SYSTEM_NAME) + string(TOLOWER ${CMAKE_SYSTEM_NAME} CORE_SYSTEM_NAME) +endif() + +if(CORE_SYSTEM_NAME STREQUAL linux) + # Set default CORE_PLATFORM_NAME to X11 + # This is overridden by user setting -DCORE_PLATFORM_NAME= + set(_DEFAULT_PLATFORM X11) +else() + string(TOLOWER ${CORE_SYSTEM_NAME} _DEFAULT_PLATFORM) +endif() + +# +# 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} CACHE STRING "Platform port to build") +endif() +unset(_DEFAULT_PLATFORM) +string(TOLOWER ${CORE_PLATFORM_NAME} CORE_PLATFORM_NAME_LC) + +list(APPEND final_message "Platform: ${CORE_PLATFORM_NAME}") +if(EXISTS ${CMAKE_SOURCE_DIR}/cmake/platform/${CORE_SYSTEM_NAME}/${CORE_PLATFORM_NAME_LC}.cmake) + include(${CMAKE_SOURCE_DIR}/cmake/platform/${CORE_SYSTEM_NAME}/${CORE_PLATFORM_NAME_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() + -- cgit v1.2.3