2024-02-22 11:39:13 +08:00
set ( SFML_OS_ANDROID "" )
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 )
2023-08-16 02:58:24 +08:00
# detect the architecture
2024-02-22 11:39:13 +08:00
set ( ARCH_64BITS "" )
2023-08-16 02:58:24 +08:00
if ( CMAKE_SIZEOF_VOID_P EQUAL 4 )
2014-09-30 22:07:25 +08:00
set ( ARCH_32BITS 1 )
2023-08-16 02:58:24 +08:00
elseif ( CMAKE_SIZEOF_VOID_P EQUAL 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 )
2023-12-10 22:10:07 +08:00
2014-09-30 22:07:25 +08:00
if ( ANDROID )
set ( SFML_OS_ANDROID 1 )
2023-12-10 22:10:07 +08:00
2014-09-30 22:07:25 +08:00
# use the OpenGL ES implementation on Android
set ( OPENGL_ES 1 )
else ( )
set ( SFML_OS_LINUX 1 )
2023-12-10 22:10:07 +08:00
2014-09-30 22:07:25 +08:00
# 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 )
2023-12-10 22:10:07 +08:00
2014-09-30 22:07:25 +08:00
# 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 )
2023-12-10 22:10:07 +08:00
2017-12-27 05:34:33 +08:00
# don't use the OpenGL ES implementation on OpenBSD
set ( OPENGL_ES 0 )
2020-12-05 15:41:26 +08:00
elseif ( CMAKE_SYSTEM_NAME MATCHES "^NetBSD$" )
set ( SFML_OS_NETBSD 1 )
2023-12-10 22:10:07 +08:00
2020-12-05 15:41:26 +08:00
# don't use the OpenGL ES implementation on NetBSD
set ( OPENGL_ES 0 )
2023-04-04 05:36:33 +08:00
elseif ( ${ CMAKE_SYSTEM_NAME } STREQUAL "iOS" )
set ( SFML_OS_IOS 1 )
2023-12-11 12:40:07 +08:00
2023-04-04 05:36:33 +08:00
# As we want to find packages in our extlibs folder too
# we need to tell CMake we want to search there instead
set ( CMAKE_FIND_ROOT_PATH_MODE_LIBRARY NEVER )
set ( CMAKE_FIND_ROOT_PATH_MODE_INCLUDE NEVER )
set ( CMAKE_FIND_ROOT_PATH_MODE_PACKAGE NEVER )
set ( CMAKE_FIND_ROOT_PATH_MODE_PROGRAM NEVER )
2023-12-11 12:40:07 +08:00
2023-04-04 05:36:33 +08:00
# use the OpenGL ES implementation on iOS
set ( OPENGL_ES 1 )
2016-06-20 20:08:50 +08:00
elseif ( ${ CMAKE_SYSTEM_NAME } STREQUAL "Darwin" )
2023-02-12 12:49:05 +08:00
set ( SFML_OS_MACOS 1 )
2023-12-10 22:10:07 +08:00
2023-02-12 12:49:05 +08:00
# don't use the OpenGL ES implementation on macOS
2023-04-04 05:36:33 +08:00
set ( OPENGL_ES 0 )
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 )
2023-12-10 22:10:07 +08:00
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 ( )
2022-02-18 02:35:25 +08:00
# detect the compiler
2021-05-04 02:09:34 +08:00
# Note: The detection is order is important because:
# - Visual Studio can both use MSVC and Clang
# - GNUCXX can still be set on macOS when using Clang
if ( MSVC )
2014-09-30 22:07:25 +08:00
set ( SFML_COMPILER_MSVC 1 )
2021-05-04 02:09:34 +08:00
2022-10-13 11:35:20 +08:00
if ( CMAKE_CXX_COMPILER_ID MATCHES "Clang" )
set ( SFML_COMPILER_CLANG_CL 1 )
2021-05-04 02:09:34 +08:00
endif ( )
elseif ( CMAKE_CXX_COMPILER_ID MATCHES "Clang" )
set ( SFML_COMPILER_CLANG 1 )
2023-07-09 06:24:41 +08:00
elseif ( CMAKE_CXX_COMPILER_ID MATCHES "GNU" )
2021-05-04 02:09:34 +08:00
set ( SFML_COMPILER_GCC 1 )
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}" )
2014-09-30 22:07:25 +08:00
else ( )
2023-06-23 01:01:13 +08:00
message ( WARNING "Unrecognized compiler: ${CMAKE_CXX_COMPILER_ID}. Use at your own risk." )
2014-09-30 22:07:25 +08:00
endif ( )