2014-09-30 22:07:25 +08:00
# detect the OS
2016-06-20 20:08:50 +08:00
if ( ${ CMAKE_SYSTEM_NAME } STREQUAL "Windows" )
2014-09-30 22:07:25 +08:00
set ( SFML_OS_WINDOWS 1 )
# don't use the OpenGL ES implementation on Windows
set ( OPENGL_ES 0 )
# detect the architecture (note: this test won't work for cross-compilation)
include ( CheckTypeSize )
check_type_size ( void* SIZEOF_VOID_PTR )
2016-06-20 20:08:50 +08:00
if ( ${ SIZEOF_VOID_PTR } STREQUAL "4" )
2014-09-30 22:07:25 +08:00
set ( ARCH_32BITS 1 )
2016-06-20 20:08:50 +08:00
elseif ( ${ SIZEOF_VOID_PTR } STREQUAL "8" )
2014-09-30 22:07:25 +08:00
set ( ARCH_64BITS 1 )
else ( )
message ( FATAL_ERROR "Unsupported architecture" )
return ( )
2013-09-22 23:16:48 +08:00
endif ( )
2016-06-20 20:08:50 +08:00
elseif ( ${ CMAKE_SYSTEM_NAME } STREQUAL "Linux" )
2013-09-22 23:16:48 +08:00
set ( SFML_OS_UNIX 1 )
2014-09-30 22:07:25 +08:00
if ( ANDROID )
set ( SFML_OS_ANDROID 1 )
# use the OpenGL ES implementation on Android
set ( OPENGL_ES 1 )
else ( )
set ( SFML_OS_LINUX 1 )
# don't use the OpenGL ES implementation on Linux
set ( OPENGL_ES 0 )
2013-09-22 23:16:48 +08:00
endif ( )
2016-08-12 04:46:26 +08:00
elseif ( CMAKE_SYSTEM_NAME MATCHES "^k?FreeBSD$" )
2014-09-30 22:07:25 +08:00
set ( SFML_OS_FREEBSD 1 )
# don't use the OpenGL ES implementation on FreeBSD
set ( OPENGL_ES 0 )
2017-12-27 05:34:33 +08:00
elseif ( CMAKE_SYSTEM_NAME MATCHES "^OpenBSD$" )
set ( SFML_OS_OPENBSD 1 )
# don't use the OpenGL ES implementation on OpenBSD
set ( OPENGL_ES 0 )
2016-06-20 20:08:50 +08:00
elseif ( ${ CMAKE_SYSTEM_NAME } STREQUAL "Darwin" )
2013-08-30 05:45:13 +08:00
if ( IOS )
set ( SFML_OS_IOS 1 )
2013-08-20 03:53:50 +08:00
2014-09-30 22:07:25 +08:00
# use the OpenGL ES implementation on iOS
set ( OPENGL_ES 1 )
else ( )
set ( SFML_OS_MACOSX 1 )
# don't use the OpenGL ES implementation on Mac OS X
set ( OPENGL_ES 0 )
# 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 )
2014-09-21 13:39:05 +08:00
STRING ( REGEX REPLACE "10\\.([0-9]+).*" "\\1" MACOSX_VERSION "${MACOSX_VERSION_RAW}" )
2014-09-30 22:07:25 +08:00
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 ( )
2014-09-30 22:07:25 +08:00
endif ( )
2016-06-20 20:08:50 +08:00
elseif ( ${ CMAKE_SYSTEM_NAME } STREQUAL "Android" )
2015-01-30 22:37:06 +08:00
set ( SFML_OS_ANDROID 1 )
2014-09-30 22:07:25 +08:00
# use the OpenGL ES implementation on Android
2013-09-22 23:16:48 +08:00
set ( OPENGL_ES 1 )
2016-09-22 21:26:07 +08:00
# comparing CMAKE_SYSTEM_NAME with "CYGWIN" generates a false warning depending on the CMake version
# let's avoid it so the actual error is more visible
elseif ( ${ CYGWIN } )
message ( FATAL_ERROR "Unfortunately SFML doesn't support Cygwin's 'hybrid' status between both Windows and Linux derivatives.\nIf you insist on using the GCC, please use a standalone build of MinGW without the Cygwin environment instead." )
2014-09-30 22:07:25 +08:00
else ( )
2016-06-20 20:08:50 +08:00
message ( FATAL_ERROR "Unsupported operating system or environment" )
2014-09-30 22:07:25 +08:00
return ( )
endif ( )
2016-12-20 05:16:07 +08:00
# check if OS or package system supports pkg-config
# this could be e.g. macports on mac or msys2 on windows etc.
find_package ( PkgConfig QUIET )
if ( PKG_CONFIG_EXECUTABLE )
if ( EXISTS "${CMAKE_INSTALL_PREFIX}/lib${LIB_SUFFIX}/pkgconfig" )
set ( SFML_OS_SUPPORTS_PKGCONFIG ON )
set ( SFML_OS_PKGCONFIG_DIR "/lib${LIB_SUFFIX}/pkgconfig" )
elseif ( EXISTS "${CMAKE_INSTALL_PREFIX}/libdata/pkgconfig" )
set ( SFML_OS_SUPPORTS_PKGCONFIG ON )
set ( SFML_OS_PKGCONFIG_DIR "/libdata/pkgconfig" )
endif ( )
endif ( )
2014-09-30 22:07:25 +08:00
# detect the compiler and its version
# Note: on some platforms (OS X), CMAKE_COMPILER_IS_GNUCXX is true
# even when CLANG is used, therefore the Clang test is done first
2018-03-21 02:46:57 +08:00
if ( CMAKE_CXX_COMPILER MATCHES "clang[+][+]" OR CMAKE_CXX_COMPILER_ID MATCHES "Clang" )
2014-09-30 22:07:25 +08:00
# 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 ( SFML_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" SFML_CLANG_VERSION "${CLANG_VERSION_OUTPUT}" )
elseif ( CMAKE_COMPILER_IS_GNUCXX )
set ( SFML_COMPILER_GCC 1 )
execute_process ( COMMAND "${CMAKE_CXX_COMPILER}" "-dumpversion" OUTPUT_VARIABLE GCC_VERSION_OUTPUT )
string ( REGEX REPLACE "([0-9]+\\.[0-9]+).*" "\\1" SFML_GCC_VERSION "${GCC_VERSION_OUTPUT}" )
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}" )
execute_process ( COMMAND "${CMAKE_CXX_COMPILER}" "-dumpmachine" OUTPUT_VARIABLE GCC_MACHINE )
string ( STRIP "${GCC_MACHINE}" GCC_MACHINE )
2016-06-20 20:08:50 +08:00
if ( GCC_MACHINE MATCHES ".*w64.*" )
2014-09-30 22:07:25 +08:00
set ( SFML_COMPILER_GCC_W64 1 )
endif ( )
elseif ( MSVC )
set ( SFML_COMPILER_MSVC 1 )
if ( MSVC_VERSION EQUAL 1400 )
set ( SFML_MSVC_VERSION 8 )
elseif ( MSVC_VERSION EQUAL 1500 )
set ( SFML_MSVC_VERSION 9 )
elseif ( MSVC_VERSION EQUAL 1600 )
set ( SFML_MSVC_VERSION 10 )
elseif ( MSVC_VERSION EQUAL 1700 )
set ( SFML_MSVC_VERSION 11 )
elseif ( MSVC_VERSION EQUAL 1800 )
set ( SFML_MSVC_VERSION 12 )
2015-08-13 00:33:41 +08:00
elseif ( MSVC_VERSION EQUAL 1900 )
set ( SFML_MSVC_VERSION 14 )
2014-09-30 22:07:25 +08:00
endif ( )
else ( )
message ( FATAL_ERROR "Unsupported compiler" )
return ( )
endif ( )
2017-12-27 05:34:33 +08:00
# define the install directory for miscellaneous files
if ( SFML_OS_WINDOWS OR SFML_OS_IOS )
set ( INSTALL_MISC_DIR . )
elseif ( SFML_OS_LINUX OR SFML_OS_FREEBSD OR SFML_OS_MACOSX OR SFML_OS_OPENBSD )
set ( INSTALL_MISC_DIR share/SFML )
elseif ( SFML_OS_ANDROID )
set ( INSTALL_MISC_DIR ${ ANDROID_NDK } /sources/sfml )
endif ( )