aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorwsnipex <wsnipex@a1.net>2017-07-13 21:15:22 -0700
committerLukas Rusak <lorusak@gmail.com>2017-07-15 08:51:48 -0700
commit4dfc7a8997c3bed8b700e0af858b78c1c8fe3796 (patch)
treec07e2b180ec2cb12ac5980c2dd6985d7cc910e96
parentf28d41c6d1057203e5a105f896e5cfb152aa4ab7 (diff)
[cmake] move platform check to it's own script
-rw-r--r--CMakeLists.txt29
-rw-r--r--cmake/scripts/common/ArchSetup.cmake3
-rw-r--r--cmake/scripts/common/Platform.cmake32
3 files changed, 33 insertions, 31 deletions
diff --git a/CMakeLists.txt b/CMakeLists.txt
index a4e8e0690a..38af6f0268 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -24,6 +24,7 @@ endif()
include(cmake/modules/extra/ECMEnableSanitizers.cmake)
include(cmake/scripts/common/GeneratorSetup.cmake)
include(cmake/scripts/common/AddOptions.cmake)
+include(cmake/scripts/common/Platform.cmake)
include(cmake/scripts/common/ArchSetup.cmake)
include(cmake/scripts/common/Macros.cmake)
include(cmake/scripts/common/ProjectMacros.cmake)
@@ -93,34 +94,6 @@ endif()
find_package(Threads REQUIRED QUIET)
list(APPEND DEPLIBS ${CMAKE_THREAD_LIBS_INIT})
-# Platform
-if(CORE_SYSTEM_NAME STREQUAL linux)
- # Set default CORE_PLATFORM_NAME to X11
- # This is overridden by user setting -DCORE_PLATFORM_NAME=<platform>
- 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()
foreach(dep ${PLATFORM_REQUIRED_DEPS})
# We need to specify ENABLE_${PLATFORM_REQUIRED_DEPS} in order for the
diff --git a/cmake/scripts/common/ArchSetup.cmake b/cmake/scripts/common/ArchSetup.cmake
index 8d5dba8bbe..357c14ca1c 100644
--- a/cmake/scripts/common/ArchSetup.cmake
+++ b/cmake/scripts/common/ArchSetup.cmake
@@ -54,9 +54,6 @@ endmacro()
# -------- Main script ---------
message(STATUS "System type: ${CMAKE_SYSTEM_NAME}")
-if(NOT CORE_SYSTEM_NAME)
- string(TOLOWER ${CMAKE_SYSTEM_NAME} CORE_SYSTEM_NAME)
-endif()
if(WITH_CPU)
set(CPU ${WITH_CPU})
diff --git a/cmake/scripts/common/Platform.cmake b/cmake/scripts/common/Platform.cmake
new file mode 100644
index 0000000000..b19b7e5c02
--- /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=<platform>
+ 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()
+