diff options
Diffstat (limited to 'cmake/scripts/common/Platform.cmake')
| -rw-r--r-- | cmake/scripts/common/Platform.cmake | 50 |
1 files changed, 35 insertions, 15 deletions
diff --git a/cmake/scripts/common/Platform.cmake b/cmake/scripts/common/Platform.cmake index 5ac233a..397d8d4 100644 --- a/cmake/scripts/common/Platform.cmake +++ b/cmake/scripts/common/Platform.cmake | |||
| @@ -3,10 +3,13 @@ if(NOT CORE_SYSTEM_NAME) | |||
| 3 | endif() | 3 | endif() |
| 4 | 4 | ||
| 5 | if(CORE_SYSTEM_NAME STREQUAL linux OR CORE_SYSTEM_NAME STREQUAL freebsd) | 5 | if(CORE_SYSTEM_NAME STREQUAL linux OR CORE_SYSTEM_NAME STREQUAL freebsd) |
| 6 | # Set default CORE_PLATFORM_NAME to X11 | 6 | # Set default CORE_PLATFORM_NAME to X11 WAYLAND GBM |
| 7 | # This is overridden by user setting -DCORE_PLATFORM_NAME=<platform> | 7 | # This is overridden by user setting -DCORE_PLATFORM_NAME=<platform> |
| 8 | set(_DEFAULT_PLATFORM X11) | 8 | set(_DEFAULT_PLATFORM X11 WAYLAND GBM) |
| 9 | option(ENABLE_APP_AUTONAME "Enable renaming the binary according to windowing?" ON) | 9 | |
| 10 | if(NOT APP_RENDER_SYSTEM) | ||
| 11 | 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\".") | ||
| 12 | endif() | ||
| 10 | else() | 13 | else() |
| 11 | string(TOLOWER ${CORE_SYSTEM_NAME} _DEFAULT_PLATFORM) | 14 | string(TOLOWER ${CORE_SYSTEM_NAME} _DEFAULT_PLATFORM) |
| 12 | endif() | 15 | endif() |
| @@ -18,20 +21,37 @@ set(APP_BINARY_SUFFIX ".bin") | |||
| 18 | # use the normalized to lower case CORE_PLATFORM_NAME_LC (see below) instead | 21 | # use the normalized to lower case CORE_PLATFORM_NAME_LC (see below) instead |
| 19 | # | 22 | # |
| 20 | if(NOT CORE_PLATFORM_NAME) | 23 | if(NOT CORE_PLATFORM_NAME) |
| 21 | set(CORE_PLATFORM_NAME ${_DEFAULT_PLATFORM} CACHE STRING "Platform port to build") | 24 | set(CORE_PLATFORM_NAME ${_DEFAULT_PLATFORM}) |
| 22 | endif() | 25 | endif() |
| 26 | set(CORE_PLATFORM_NAME ${CORE_PLATFORM_NAME} CACHE STRING "Platform port to build" FORCE) | ||
| 23 | unset(_DEFAULT_PLATFORM) | 27 | unset(_DEFAULT_PLATFORM) |
| 24 | string(TOLOWER ${CORE_PLATFORM_NAME} CORE_PLATFORM_NAME_LC) | ||
| 25 | 28 | ||
| 26 | list(APPEND final_message "Platform: ${CORE_PLATFORM_NAME}") | 29 | string(REPLACE " " ";" CORE_PLATFORM_NAME "${CORE_PLATFORM_NAME}") |
| 27 | if(EXISTS ${CMAKE_SOURCE_DIR}/cmake/platform/${CORE_SYSTEM_NAME}/${CORE_PLATFORM_NAME_LC}.cmake) | 30 | foreach(platform IN LISTS CORE_PLATFORM_NAME) |
| 28 | include(${CMAKE_SOURCE_DIR}/cmake/platform/${CORE_SYSTEM_NAME}/${CORE_PLATFORM_NAME_LC}.cmake) | 31 | string(TOLOWER ${platform} platform) |
| 29 | if(ENABLE_APP_AUTONAME) | 32 | list(APPEND CORE_PLATFORM_NAME_LC ${platform}) |
| 30 | set(APP_BINARY_SUFFIX "-${CORE_PLATFORM_NAME_LC}") | 33 | endforeach() |
| 34 | |||
| 35 | string(REPLACE ";" " " CORE_PLATFORM_STRING "${CORE_PLATFORM_NAME_LC}") | ||
| 36 | list(APPEND final_message "Platforms: ${CORE_PLATFORM_STRING}") | ||
| 37 | |||
| 38 | if(CORE_SYSTEM_NAME STREQUAL linux OR CORE_SYSTEM_NAME STREQUAL freebsd) | ||
| 39 | list(LENGTH CORE_PLATFORM_NAME_LC PLATFORM_COUNT) | ||
| 40 | if(PLATFORM_COUNT EQUAL 1) | ||
| 41 | option(ENABLE_APP_AUTONAME "Enable renaming the binary according to windowing?" ON) | ||
| 42 | if(ENABLE_APP_AUTONAME) | ||
| 43 | set(APP_BINARY_SUFFIX "-${CORE_PLATFORM_NAME_LC}") | ||
| 44 | endif() | ||
| 31 | endif() | 45 | endif() |
| 32 | else() | ||
| 33 | file(GLOB _platformnames RELATIVE ${CMAKE_SOURCE_DIR}/cmake/platform/${CORE_SYSTEM_NAME}/ | ||
| 34 | ${CMAKE_SOURCE_DIR}/cmake/platform/${CORE_SYSTEM_NAME}/*.cmake) | ||
| 35 | string(REPLACE ".cmake" " " _platformnames ${_platformnames}) | ||
| 36 | message(FATAL_ERROR "invalid CORE_PLATFORM_NAME: ${CORE_PLATFORM_NAME_LC}\nValid platforms: ${_platformnames}") | ||
| 37 | endif() | 46 | endif() |
| 47 | |||
| 48 | foreach(CORE_PLATFORM_LC IN LISTS CORE_PLATFORM_NAME_LC) | ||
| 49 | if(EXISTS ${CMAKE_SOURCE_DIR}/cmake/platform/${CORE_SYSTEM_NAME}/${CORE_PLATFORM_LC}.cmake) | ||
| 50 | include(${CMAKE_SOURCE_DIR}/cmake/platform/${CORE_SYSTEM_NAME}/${CORE_PLATFORM_LC}.cmake) | ||
| 51 | else() | ||
| 52 | file(GLOB _platformnames RELATIVE ${CMAKE_SOURCE_DIR}/cmake/platform/${CORE_SYSTEM_NAME}/ | ||
| 53 | ${CMAKE_SOURCE_DIR}/cmake/platform/${CORE_SYSTEM_NAME}/*.cmake) | ||
| 54 | string(REPLACE ".cmake" " " _platformnames ${_platformnames}) | ||
| 55 | message(FATAL_ERROR "invalid CORE_PLATFORM_NAME: ${CORE_PLATFORM_NAME_LC}\nValid platforms: ${_platformnames}") | ||
| 56 | endif() | ||
| 57 | endforeach() | ||
