summaryrefslogtreecommitdiffstats
path: root/Modules/CMakeDetermineSystem.cmake
diff options
context:
space:
mode:
Diffstat (limited to 'Modules/CMakeDetermineSystem.cmake')
-rw-r--r--Modules/CMakeDetermineSystem.cmake79
1 files changed, 51 insertions, 28 deletions
diff --git a/Modules/CMakeDetermineSystem.cmake b/Modules/CMakeDetermineSystem.cmake
index e7559e2..3ad4a60 100644
--- a/Modules/CMakeDetermineSystem.cmake
+++ b/Modules/CMakeDetermineSystem.cmake
@@ -25,37 +25,60 @@
# Ultrix ULTRIX
# cygwin CYGWIN_NT-5.1
# MacOSX Darwin
-IF(UNIX)
- FIND_PROGRAM(CMAKE_UNAME uname /bin /usr/bin /usr/local/bin )
- IF(CMAKE_UNAME)
- EXEC_PROGRAM(uname ARGS -s OUTPUT_VARIABLE CMAKE_SYSTEM_NAME)
- EXEC_PROGRAM(uname ARGS -r OUTPUT_VARIABLE CMAKE_SYSTEM_VERSION)
- IF(CMAKE_SYSTEM_NAME MATCHES "Linux")
- EXEC_PROGRAM(uname ARGS -m OUTPUT_VARIABLE CMAKE_SYSTEM_PROCESSOR
- RETURN_VALUE val)
- ELSE(CMAKE_SYSTEM_NAME MATCHES "Linux")
- EXEC_PROGRAM(uname ARGS -p OUTPUT_VARIABLE CMAKE_SYSTEM_PROCESSOR
- RETURN_VALUE val)
- IF("${val}" GREATER 0)
+
+IF(CMAKE_TOOLCHAIN_FILE)
+ # at first try to load it as path relative to the directory from which cmake has been run
+ INCLUDE("${CMAKE_BINARY_DIR}/${CMAKE_TOOLCHAIN_FILE}" OPTIONAL RESULT_VARIABLE _INCLUDED_TOOLCHAIN_FILE)
+ IF(NOT _INCLUDED_TOOLCHAIN_FILE)
+ # if the file isn't found there, check the default locations
+ INCLUDE("${CMAKE_TOOLCHAIN_FILE}" OPTIONAL RESULT_VARIABLE _INCLUDED_TOOLCHAIN_FILE)
+ ENDIF(NOT _INCLUDED_TOOLCHAIN_FILE)
+
+ IF(_INCLUDED_TOOLCHAIN_FILE)
+ SET(CMAKE_TOOLCHAIN_FILE "${_INCLUDED_TOOLCHAIN_FILE}")
+ ELSE(_INCLUDED_TOOLCHAIN_FILE)
+ MESSAGE(FATAL_ERROR "Could not find toolchain file: ${CMAKE_TOOLCHAIN_FILE}")
+ ENDIF(_INCLUDED_TOOLCHAIN_FILE)
+
+ IF(NOT DEFINED CMAKE_CROSSCOMPILING)
+ SET(CMAKE_CROSSCOMPILING TRUE)
+ ENDIF(NOT DEFINED CMAKE_CROSSCOMPILING)
+ENDIF(CMAKE_TOOLCHAIN_FILE)
+
+IF(NOT CMAKE_SYSTEM_NAME)
+ IF(UNIX)
+ FIND_PROGRAM(CMAKE_UNAME uname /bin /usr/bin /usr/local/bin )
+ IF(CMAKE_UNAME)
+ EXEC_PROGRAM(uname ARGS -s OUTPUT_VARIABLE CMAKE_SYSTEM_NAME)
+ EXEC_PROGRAM(uname ARGS -r OUTPUT_VARIABLE CMAKE_SYSTEM_VERSION)
+ IF(CMAKE_SYSTEM_NAME MATCHES "Linux")
EXEC_PROGRAM(uname ARGS -m OUTPUT_VARIABLE CMAKE_SYSTEM_PROCESSOR
RETURN_VALUE val)
+ ELSE(CMAKE_SYSTEM_NAME MATCHES "Linux")
+ EXEC_PROGRAM(uname ARGS -p OUTPUT_VARIABLE CMAKE_SYSTEM_PROCESSOR
+ RETURN_VALUE val)
+ IF("${val}" GREATER 0)
+ EXEC_PROGRAM(uname ARGS -m OUTPUT_VARIABLE CMAKE_SYSTEM_PROCESSOR
+ RETURN_VALUE val)
+ ENDIF("${val}" GREATER 0)
+ ENDIF(CMAKE_SYSTEM_NAME MATCHES "Linux")
+ # check the return of the last uname -m or -p
+ IF("${val}" GREATER 0)
+ SET(CMAKE_SYSTEM_PROCESSOR "unknown")
ENDIF("${val}" GREATER 0)
- ENDIF(CMAKE_SYSTEM_NAME MATCHES "Linux")
- # check the return of the last uname -m or -p
- IF("${val}" GREATER 0)
- SET(CMAKE_SYSTEM_PROCESSOR "unknown")
- ENDIF("${val}" GREATER 0)
- SET(CMAKE_UNAME ${CMAKE_UNAME} CACHE INTERNAL "uname command")
- # processor may have double quote in the name, and that needs to be removed
- STRING(REGEX REPLACE "\"" "" CMAKE_SYSTEM_PROCESSOR "${CMAKE_SYSTEM_PROCESSOR}")
- STRING(REGEX REPLACE "/" "_" CMAKE_SYSTEM_PROCESSOR "${CMAKE_SYSTEM_PROCESSOR}")
- ENDIF(CMAKE_UNAME)
-ELSE(UNIX)
- IF(WIN32)
- SET (CMAKE_SYSTEM_NAME "Windows")
- SET (CMAKE_SYSTEM_PROCESSOR "$ENV{PROCESSOR_ARCHITECTURE}")
- ENDIF(WIN32)
-ENDIF(UNIX)
+ SET(CMAKE_UNAME ${CMAKE_UNAME} CACHE INTERNAL "uname command")
+ # processor may have double quote in the name, and that needs to be removed
+ STRING(REGEX REPLACE "\"" "" CMAKE_SYSTEM_PROCESSOR "${CMAKE_SYSTEM_PROCESSOR}")
+ STRING(REGEX REPLACE "/" "_" CMAKE_SYSTEM_PROCESSOR "${CMAKE_SYSTEM_PROCESSOR}")
+ ENDIF(CMAKE_UNAME)
+ ELSE(UNIX)
+ IF(WIN32)
+ SET (CMAKE_SYSTEM_NAME "Windows")
+ SET (CMAKE_SYSTEM_PROCESSOR "$ENV{PROCESSOR_ARCHITECTURE}")
+ ENDIF(WIN32)
+ ENDIF(UNIX)
+ENDIF(NOT CMAKE_SYSTEM_NAME)
+
IF(NOT CMAKE_SYSTEM_NAME)
SET(CMAKE_SYSTEM_NAME "UnknownOS")