2010-08-19 23:59:24 +08:00
|
|
|
# detect the OS
|
|
|
|
if(${CMAKE_SYSTEM_NAME} MATCHES "Windows")
|
2013-10-09 14:01:10 +08:00
|
|
|
set(SFML_OS_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()
|
2013-09-22 23:16:48 +08:00
|
|
|
endif()
|
2010-08-19 23:59:24 +08:00
|
|
|
elseif(${CMAKE_SYSTEM_NAME} MATCHES "Linux")
|
2013-09-22 23:16:48 +08:00
|
|
|
set(SFML_OS_UNIX 1)
|
|
|
|
if(ANDROID)
|
|
|
|
# use the OpenGL ES implementation on Android
|
|
|
|
set(OPENGL_ES 1)
|
|
|
|
set(SFML_OS_ANDROID 1)
|
|
|
|
else()
|
|
|
|
set(SFML_OS_LINUX 1)
|
|
|
|
endif()
|
2011-09-14 23:58:51 +08:00
|
|
|
elseif(${CMAKE_SYSTEM_NAME} MATCHES "FreeBSD")
|
2013-10-09 14:01:10 +08:00
|
|
|
set(SFML_OS_FREEBSD 1)
|
2013-08-20 03:53:50 +08:00
|
|
|
elseif(${CMAKE_SYSTEM_NAME} MATCHES "Darwin")
|
2013-08-30 05:45:13 +08:00
|
|
|
if(IOS)
|
|
|
|
set(SFML_OS_IOS 1)
|
|
|
|
|
|
|
|
# set the target framework and platforms
|
2013-09-06 19:32:22 +08:00
|
|
|
set(CMAKE_OSX_SYSROOT "iphoneos")
|
2013-08-30 05:45:13 +08:00
|
|
|
set(CMAKE_OSX_ARCHITECTURES "armv6;armv7;i386")
|
|
|
|
set(CMAKE_XCODE_EFFECTIVE_PLATFORMS "-iphoneos;-iphonesimulator")
|
2013-08-20 03:53:50 +08:00
|
|
|
|
|
|
|
# help the compiler detection script below
|
|
|
|
set(CMAKE_COMPILER_IS_GNUCXX 1)
|
2011-09-14 23:58:51 +08:00
|
|
|
|
2013-08-20 03:53:50 +08:00
|
|
|
# use the OpenGL ES implementation on iOS
|
|
|
|
set(OPENGL_ES 1)
|
|
|
|
else()
|
|
|
|
set(SFML_OS_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 7)
|
|
|
|
message(FATAL_ERROR "Unsupported version of OS X: ${MACOSX_VERSION_RAW}")
|
2013-09-22 23:16:48 +08:00
|
|
|
return()
|
2013-08-20 03:53:50 +08:00
|
|
|
endif()
|
2011-09-14 23:58:51 +08:00
|
|
|
endif()
|
2013-08-26 02:39:55 +08:00
|
|
|
elseif(${CMAKE_SYSTEM_NAME} MATCHES "Android")
|
|
|
|
set(SFML_OS_ANDROID 1)
|
|
|
|
|
|
|
|
# use the OpenGL ES implementation on Android
|
2013-09-22 23:16:48 +08:00
|
|
|
set(OPENGL_ES 1)
|
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
|
2013-10-09 14:01:10 +08:00
|
|
|
set(SFML_COMPILER_CLANG 1)
|
2011-12-29 05:20:15 +08:00
|
|
|
execute_process(COMMAND "${CMAKE_CXX_COMPILER}" "--version" OUTPUT_VARIABLE CLANG_VERSION_OUTPUT)
|
2013-10-09 14:01:10 +08:00
|
|
|
string(REGEX REPLACE ".*clang version ([0-9]+\\.[0-9]+).*" "\\1" SFML_CLANG_VERSION "${CLANG_VERSION_OUTPUT}")
|
2011-12-29 05:20:15 +08:00
|
|
|
elseif(CMAKE_COMPILER_IS_GNUCXX)
|
2013-10-09 14:01:10 +08:00
|
|
|
set(SFML_COMPILER_GCC 1)
|
2010-08-19 23:59:24 +08:00
|
|
|
execute_process(COMMAND "${CMAKE_CXX_COMPILER}" "-dumpversion" OUTPUT_VARIABLE GCC_VERSION_OUTPUT)
|
2013-10-09 14:01:10 +08:00
|
|
|
string(REGEX REPLACE "([0-9]+\\.[0-9]+).*" "\\1" SFML_GCC_VERSION "${GCC_VERSION_OUTPUT}")
|
2013-10-15 21:46:50 +08:00
|
|
|
execute_process(COMMAND "${CMAKE_CXX_COMPILER}" "--version" OUTPUT_VARIABLE GCC_COMPILER_VERSION)
|
|
|
|
string(REGEX MATCHALL ".*(tdm[64]*-[1-9]).*" SFML_COMPILER_GCC_TDM "${GCC_COMPILER_VERSION}")
|
2012-05-02 04:00:24 +08:00
|
|
|
execute_process(COMMAND "${CMAKE_CXX_COMPILER}" "-dumpmachine" OUTPUT_VARIABLE GCC_MACHINE)
|
|
|
|
string(STRIP "${GCC_MACHINE}" GCC_MACHINE)
|
|
|
|
if(${GCC_MACHINE} MATCHES ".*w64.*")
|
2013-10-09 14:01:10 +08:00
|
|
|
set(SFML_COMPILER_GCC_W64 1)
|
2012-05-02 04:00:24 +08:00
|
|
|
endif()
|
2011-12-29 04:39:23 +08:00
|
|
|
elseif(MSVC)
|
2013-10-09 14:01:10 +08:00
|
|
|
set(SFML_COMPILER_MSVC 1)
|
2011-12-29 04:39:23 +08:00
|
|
|
if(MSVC_VERSION EQUAL 1400)
|
2013-10-15 21:46:50 +08:00
|
|
|
set(SFML_MSVC_VERSION 8)
|
2013-10-15 13:55:01 +08:00
|
|
|
elseif(MSVC_VERSION EQUAL 1500)
|
2013-10-15 21:46:50 +08:00
|
|
|
set(SFML_MSVC_VERSION 9)
|
2013-10-15 13:55:01 +08:00
|
|
|
elseif(MSVC_VERSION EQUAL 1600)
|
2013-10-15 21:46:50 +08:00
|
|
|
set(SFML_MSVC_VERSION 10)
|
2013-10-15 13:55:01 +08:00
|
|
|
elseif(MSVC_VERSION EQUAL 1700)
|
2013-10-15 21:46:50 +08:00
|
|
|
set(SFML_MSVC_VERSION 11)
|
|
|
|
elseif(MSVC_VERSION EQUAL 1800)
|
|
|
|
set(SFML_MSVC_VERSION 12)
|
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()
|
2013-09-22 23:16:48 +08:00
|
|
|
|
|
|
|
# define the install directory for miscellaneous files
|
|
|
|
if(SFML_OS_WINDOWS)
|
2010-08-19 23:59:24 +08:00
|
|
|
set(INSTALL_MISC_DIR .)
|
2013-10-09 14:01:10 +08:00
|
|
|
elseif(SFML_OS_LINUX OR SFML_OS_FREEBSD OR SFML_OS_MACOSX)
|
2010-08-19 23:59:24 +08:00
|
|
|
set(INSTALL_MISC_DIR share/SFML)
|
2013-09-22 23:16:48 +08:00
|
|
|
elseif(SFML_OS_ANDROID)
|
|
|
|
set(INSTALL_MISC_DIR ${ANDROID_NDK}/sources/sfml)
|
2010-08-19 23:59:24 +08:00
|
|
|
endif()
|