2010-08-19 23:59:24 +08:00
|
|
|
|
|
|
|
# detect the OS
|
|
|
|
if(${CMAKE_SYSTEM_NAME} MATCHES "Windows")
|
|
|
|
set(WINDOWS 1)
|
2012-01-04 01:02:18 +08:00
|
|
|
|
|
|
|
# detect the architecture (note: this test won't work for cross-compilation)
|
|
|
|
include(CheckTypeSize)
|
|
|
|
check_type_size(void* SIZEOF_VOID_PTR)
|
2012-03-31 02:53:16 +08:00
|
|
|
if("${SIZEOF_VOID_PTR}" STREQUAL "4")
|
2012-01-04 01:02:18 +08:00
|
|
|
set(ARCH_32BITS 1)
|
2012-03-31 02:53:16 +08:00
|
|
|
elseif("${SIZEOF_VOID_PTR}" STREQUAL "8")
|
2012-01-04 01:02:18 +08:00
|
|
|
set(ARCH_64BITS 1)
|
|
|
|
else()
|
|
|
|
message(FATAL_ERROR "Unsupported architecture")
|
|
|
|
return()
|
|
|
|
endif()
|
2010-08-19 23:59:24 +08:00
|
|
|
elseif(${CMAKE_SYSTEM_NAME} MATCHES "Linux")
|
|
|
|
set(LINUX 1)
|
2011-09-14 23:58:51 +08:00
|
|
|
elseif(${CMAKE_SYSTEM_NAME} MATCHES "FreeBSD")
|
|
|
|
# FreeBSD compile path is the same as Linux
|
|
|
|
set(LINUX 1)
|
2010-08-19 23:59:24 +08:00
|
|
|
elseif(${CMAKE_SYSTEM_NAME} MATCHES "Darwin")
|
2011-09-14 23:58:51 +08:00
|
|
|
set(MACOSX 1)
|
|
|
|
|
|
|
|
# detect OS X version. (use '/usr/bin/sw_vers -productVersion' to extract V from '10.V.x'.)
|
|
|
|
EXEC_PROGRAM(/usr/bin/sw_vers ARGS -productVersion OUTPUT_VARIABLE MACOSX_VERSION_RAW)
|
|
|
|
STRING(REGEX REPLACE "10\\.([0-9]).*" "\\1" MACOSX_VERSION "${MACOSX_VERSION_RAW}")
|
|
|
|
if(${MACOSX_VERSION} LESS 5)
|
2011-12-29 23:20:21 +08:00
|
|
|
message(FATAL_ERROR "Unsupported version of OS X : ${MACOSX_VERSION_RAW}")
|
2011-09-14 23:58:51 +08:00
|
|
|
return()
|
|
|
|
endif()
|
2010-08-19 23:59:24 +08:00
|
|
|
else()
|
2011-12-29 23:20:21 +08:00
|
|
|
message(FATAL_ERROR "Unsupported operating system")
|
2010-08-19 23:59:24 +08:00
|
|
|
return()
|
|
|
|
endif()
|
|
|
|
|
|
|
|
# detect the compiler and its version
|
2011-12-29 05:20:15 +08:00
|
|
|
# Note: on some platforms (OS X), CMAKE_COMPILER_IS_GNUCXX is true
|
|
|
|
# even when CLANG is used, therefore the Clang test is done first
|
|
|
|
if(CMAKE_CXX_COMPILER MATCHES ".*clang[+][+]" OR CMAKE_CXX_COMPILER_ID STREQUAL "Clang")
|
|
|
|
# CMAKE_CXX_COMPILER_ID is an internal CMake variable subject to change,
|
|
|
|
# but there is no other way to detect CLang at the moment
|
|
|
|
set(COMPILER_CLANG 1)
|
|
|
|
execute_process(COMMAND "${CMAKE_CXX_COMPILER}" "--version" OUTPUT_VARIABLE CLANG_VERSION_OUTPUT)
|
|
|
|
string(REGEX REPLACE ".*clang version ([0-9]+\\.[0-9]+).*" "\\1" CLANG_VERSION "${CLANG_VERSION_OUTPUT}")
|
|
|
|
elseif(CMAKE_COMPILER_IS_GNUCXX)
|
2010-08-19 23:59:24 +08:00
|
|
|
set(COMPILER_GCC 1)
|
|
|
|
execute_process(COMMAND "${CMAKE_CXX_COMPILER}" "-dumpversion" OUTPUT_VARIABLE GCC_VERSION_OUTPUT)
|
|
|
|
string(REGEX REPLACE "([0-9]+\\.[0-9]+).*" "\\1" GCC_VERSION "${GCC_VERSION_OUTPUT}")
|
2011-12-29 04:39:23 +08:00
|
|
|
elseif(MSVC)
|
|
|
|
set(COMPILER_MSVC 1)
|
|
|
|
if(MSVC_VERSION EQUAL 1400)
|
|
|
|
set(MSVC_VERSION 2005)
|
|
|
|
elseif(MSVC_VERSION EQUAL 1500)
|
|
|
|
set(MSVC_VERSION 2008)
|
|
|
|
elseif(MSVC_VERSION EQUAL 1600)
|
|
|
|
set(MSVC_VERSION 2010)
|
2011-12-31 03:33:37 +08:00
|
|
|
elseif(MSVC_VERSION EQUAL 1700)
|
|
|
|
set(MSVC_VERSION 2011)
|
2011-12-29 04:39:23 +08:00
|
|
|
endif()
|
2010-08-19 23:59:24 +08:00
|
|
|
else()
|
2011-12-29 23:20:21 +08:00
|
|
|
message(FATAL_ERROR "Unsupported compiler")
|
2010-08-19 23:59:24 +08:00
|
|
|
return()
|
|
|
|
endif()
|
|
|
|
|
|
|
|
# define the install directory for miscellaneous files
|
|
|
|
if(WINDOWS)
|
|
|
|
set(INSTALL_MISC_DIR .)
|
|
|
|
elseif(UNIX)
|
|
|
|
set(INSTALL_MISC_DIR share/SFML)
|
|
|
|
endif()
|