2010-01-21 15:12:50 +00:00
#-------------------------------------------------------------------------------
# detectOperatingSystem
#-------------------------------------------------------------------------------
# This function detects on which OS cmake is run and set a flag to control the
# build process. Supported OS: Linux, MacOSX, Windows
2013-01-02 13:34:38 +00:00
#
# On linux, it also set a flag for specific distribution (ie Fedora)
2010-01-21 15:12:50 +00:00
#-------------------------------------------------------------------------------
function ( detectOperatingSystem )
2013-01-02 13:34:38 +00:00
# nothing detected yet
set ( MacOSX FALSE PARENT_SCOPE )
set ( Windows FALSE PARENT_SCOPE )
set ( Linux FALSE PARENT_SCOPE )
set ( Fedora FALSE PARENT_SCOPE )
2010-01-21 15:12:50 +00:00
2013-01-02 13:34:38 +00:00
# check if we are on Linux
if ( ${ CMAKE_SYSTEM_NAME } STREQUAL "Linux" )
set ( Linux TRUE PARENT_SCOPE )
2010-01-21 15:12:50 +00:00
2013-01-02 13:34:38 +00:00
if ( EXISTS /etc/os-release )
# Read the file without CR character
file ( STRINGS /etc/os-release OS_RELEASE )
if ( "${OS_RELEASE}" MATCHES "^.*ID=fedora.*$" )
set ( Fedora TRUE PARENT_SCOPE )
endif ( )
endif ( )
endif ( ${ CMAKE_SYSTEM_NAME } STREQUAL "Linux" )
2010-01-21 15:12:50 +00:00
2013-01-02 13:34:38 +00:00
# check if we are on MacOSX
if ( APPLE )
set ( MacOSX TRUE PARENT_SCOPE )
endif ( APPLE )
# check if we are on Windows
if ( ${ CMAKE_SYSTEM_NAME } STREQUAL "Windows" )
set ( Windows TRUE PARENT_SCOPE )
endif ( ${ CMAKE_SYSTEM_NAME } STREQUAL "Windows" )
endfunction ( detectOperatingSystem )
2013-06-28 10:43:50 +00:00
function ( write_svnrev_h )
2014-03-25 16:29:47 +00:00
if ( GIT_FOUND )
2014-03-30 13:35:24 +00:00
execute_process ( COMMAND git -C ${ CMAKE_SOURCE_DIR } show -s --format=%ci HEAD
2014-03-25 16:29:47 +00:00
O U T P U T _ V A R I A B L E t m p v a r _ W C _ I N F O
O U T P U T _ S T R I P _ T R A I L I N G _ W H I T E S P A C E )
# %2014-03-25 16:36:29 +0100
string ( REGEX REPLACE "[%:\\-]" "" tmpvar_WC_INFO "${tmpvar_WC_INFO}" )
string ( REGEX REPLACE "([0-9]+) ([0-9]+).*" "\\1\\2" tmpvar_WC_INFO "${tmpvar_WC_INFO}" )
2013-06-28 10:43:50 +00:00
2014-04-17 18:24:12 +00:00
if ( "${tmpvar_WC_INFO}" STREQUAL "" )
# For people with an older GIT version that migth not support '-C'
file ( WRITE ${ CMAKE_BINARY_DIR } /common/include/svnrev.h "#define SVN_REV 0ll \n#define SVN_MODS 0" )
else ( )
file ( WRITE ${ CMAKE_BINARY_DIR } /common/include/svnrev.h "#define SVN_REV ${tmpvar_WC_INFO}ll \n#define SVN_MODS 0" )
endif ( )
2013-06-28 10:43:50 +00:00
else ( )
2014-03-25 16:29:47 +00:00
file ( WRITE ${ CMAKE_BINARY_DIR } /common/include/svnrev.h "#define SVN_REV_UNKNOWN\n#define SVN_REV 0ll \n#define SVN_MODS 0" )
2013-06-28 10:43:50 +00:00
endif ( )
endfunction ( )
2013-07-06 09:42:46 +00:00
function ( check_compiler_version version_warn version_err )
if ( "${CMAKE_CXX_COMPILER_ID}" MATCHES "GNU" )
execute_process ( COMMAND ${ CMAKE_C_COMPILER } -dumpversion OUTPUT_VARIABLE GCC_VERSION )
string ( STRIP "${GCC_VERSION}" GCC_VERSION )
if ( GCC_VERSION VERSION_LESS ${ version_err } )
message ( FATAL_ERROR " PCSX2 doesn't support your old GCC ${ GCC_VERSION } ! Please upgrade it !
T h e m i n i m u m v e r s i o n i s $ { v e r s i o n _ e r r } b u t $ { v e r s i o n _ w a r n } i s w a r m l y r e c o m m e n d e d " )
else ( )
if ( GCC_VERSION VERSION_LESS ${ version_warn } )
message ( WARNING "PCSX2 will stop to support GCC ${GCC_VERSION} in a near future. Please upgrade it to GCC ${version_warn}." )
endif ( )
endif ( )
endif ( )
endfunction ( )
2014-03-30 14:25:11 +00:00
function ( check_no_parenthesis_in_path )
if ( "${CMAKE_BINARY_DIR}" MATCHES "[()]" OR "${CMAKE_SOURCE_DIR}" MATCHES "[()]" )
message ( FATAL_ERROR "Your path contains some parenthesis. Unfortunately Cmake doesn't support them correctly.\nPlease rename your directory to avoid '(' and ')' characters\n" )
endif ( )
endfunction ( )