2010-01-21 15:12:50 +00:00
#-------------------------------------------------------------------------------
2010-06-04 17:17:55 +00:00
# Search all libraries on the system
2010-01-21 15:12:50 +00:00
#-------------------------------------------------------------------------------
2010-08-02 07:33:11 +00:00
## Use cmake package to find module
2016-05-01 09:14:44 +00:00
if ( Linux )
find_package ( ALSA )
endif ( )
2020-11-16 07:09:17 +00:00
find_package ( PCAP )
find_package ( LibXml2 )
2016-09-18 20:40:51 +00:00
find_package ( Freetype ) # GSdx OSD
2011-01-20 20:45:07 +00:00
find_package ( Gettext ) # translation tool
2015-07-27 22:54:04 +00:00
if ( EXISTS ${ PROJECT_SOURCE_DIR } /.git )
find_package ( Git )
endif ( )
2015-05-17 19:57:33 +00:00
find_package ( LibLZMA )
2018-12-09 09:17:02 +00:00
# Using find_package OpenGL without either setting your opengl preference to GLVND or LEGACY
# is deprecated as of cmake 3.11.
set ( OpenGL_GL_PREFERENCE GLVND )
2010-06-04 17:17:55 +00:00
find_package ( OpenGL )
2015-07-27 22:54:04 +00:00
find_package ( PNG )
2016-12-04 17:46:02 +00:00
find_package ( Vtune )
2020-10-30 05:30:03 +00:00
2011-05-14 11:03:02 +00:00
# Does not require the module (allow to compile non-wx plugins)
2011-02-15 14:37:30 +00:00
# Force the unicode build (the variable is only supported on cmake 2.8.3 and above)
2011-05-09 20:32:50 +00:00
# Warning do not put any double-quote for the argument...
# set(wxWidgets_CONFIG_OPTIONS --unicode=yes --debug=yes) # In case someone want to debug inside wx
2014-03-26 10:37:49 +00:00
#
2013-03-05 12:38:22 +00:00
# Fedora uses an extra non-standard option ... Arch must be the first option.
2014-12-25 02:18:28 +00:00
# They do uname -m if missing so only fix for cross compilations.
# http://pkgs.fedoraproject.org/cgit/wxGTK.git/plain/wx-config
if ( Fedora AND CMAKE_CROSSCOMPILING )
set ( wxWidgets_CONFIG_OPTIONS --arch ${ PCSX2_TARGET_ARCHITECTURES } --unicode=yes )
2013-01-02 13:34:38 +00:00
else ( )
set ( wxWidgets_CONFIG_OPTIONS --unicode=yes )
endif ( )
2015-01-04 00:56:50 +00:00
2020-10-30 05:30:03 +00:00
# I'm removing the version check, because it excludes newer versions and requires specifically 3.0.
#list(APPEND wxWidgets_CONFIG_OPTIONS --version=3.0)
2015-01-09 12:10:11 +00:00
2020-11-03 13:13:06 +00:00
# The wx version must be specified so a mix of gtk2 and gtk3 isn't used
# as that can cause compile errors.
if ( GTK2_API AND NOT APPLE )
list ( APPEND wxWidgets_CONFIG_OPTIONS --toolkit=gtk2 )
elseif ( NOT APPLE )
list ( APPEND wxWidgets_CONFIG_OPTIONS --toolkit=gtk3 )
endif ( )
2015-01-09 12:10:11 +00:00
2015-01-09 12:44:26 +00:00
# wx2.8 => /usr/bin/wx-config-2.8
# lib32-wx2.8 => /usr/bin/wx-config32-2.8
# wx3.0 => /usr/bin/wx-config-3.0
2015-01-04 00:56:50 +00:00
# I'm going to take a wild guess and predict this:
2015-01-09 12:44:26 +00:00
# lib32-wx3.0 => /usr/bin/wx-config32-3.0
# FindwxWidgets only searches for wx-config.
2015-01-04 00:56:50 +00:00
if ( CMAKE_CROSSCOMPILING )
2015-01-04 20:08:12 +00:00
# May need to fix the filenames for lib32-wx3.0.
2016-04-17 15:14:21 +00:00
if ( ${ PCSX2_TARGET_ARCHITECTURES } MATCHES "i386" )
if ( Fedora AND EXISTS "/usr/bin/wx-config-3.0" )
set ( wxWidgets_CONFIG_EXECUTABLE "/usr/bin/wx-config-3.0" )
endif ( )
2017-05-08 07:52:57 +00:00
if ( EXISTS "/usr/bin/wx-config32" )
set ( wxWidgets_CONFIG_EXECUTABLE "/usr/bin/wx-config32" )
endif ( )
2016-04-17 15:14:21 +00:00
if ( EXISTS "/usr/bin/wx-config32-3.0" )
set ( wxWidgets_CONFIG_EXECUTABLE "/usr/bin/wx-config32-3.0" )
endif ( )
2015-01-04 00:56:50 +00:00
endif ( )
else ( )
2016-05-01 09:14:44 +00:00
if ( ${ CMAKE_SYSTEM_NAME } MATCHES "FreeBSD" )
2019-09-01 19:58:14 +00:00
set ( wxWidgets_CONFIG_EXECUTABLE "/usr/local/bin/wxgtk3u-3.0-config" )
2016-05-01 09:14:44 +00:00
endif ( )
2020-10-30 05:30:03 +00:00
if ( EXISTS "/usr/bin/wx-config-3.2" )
set ( wxWidgets_CONFIG_EXECUTABLE "/usr/bin/wx-config-3.2" )
endif ( )
if ( EXISTS "/usr/bin/wx-config-3.1" )
set ( wxWidgets_CONFIG_EXECUTABLE "/usr/bin/wx-config-3.1" )
endif ( )
2016-01-30 11:48:35 +00:00
if ( EXISTS "/usr/bin/wx-config-3.0" )
2015-01-09 03:27:16 +00:00
set ( wxWidgets_CONFIG_EXECUTABLE "/usr/bin/wx-config-3.0" )
2015-01-04 00:56:50 +00:00
endif ( )
2020-10-30 05:30:03 +00:00
if ( EXISTS "/usr/bin/wx-config" )
set ( wxWidgets_CONFIG_EXECUTABLE "/usr/bin/wx-config" )
endif ( )
2020-11-03 13:13:06 +00:00
if ( NOT GTK2_API AND EXISTS "/usr/bin/wx-config-gtk3" )
2020-10-30 05:30:03 +00:00
set ( wxWidgets_CONFIG_EXECUTABLE "/usr/bin/wx-config-gtk3" )
endif ( )
2015-01-04 00:56:50 +00:00
endif ( )
2010-08-02 07:33:11 +00:00
find_package ( wxWidgets COMPONENTS base core adv )
2012-08-15 10:22:19 +00:00
find_package ( ZLIB )
2010-08-02 07:33:11 +00:00
## Use pcsx2 package to find module
2011-09-06 19:07:55 +00:00
include ( FindLibc )
2014-08-04 16:15:10 +00:00
2020-11-02 11:21:00 +00:00
## Use pcsx2 package to find module
include ( Findlibsamplerate )
2020-11-02 20:30:13 +00:00
## Use pcsx2 package to find module
include ( FindPulseAudio )
2014-08-04 16:15:10 +00:00
## Use CheckLib package to find module
include ( CheckLib )
2014-12-28 06:41:57 +00:00
if ( Linux )
2020-08-09 03:39:56 +00:00
check_lib ( EGL EGL EGL/egl.h )
check_lib ( X11_XCB X11-xcb X11/Xlib-xcb.h )
2014-12-28 06:41:57 +00:00
check_lib ( AIO aio libaio.h )
2016-10-26 17:18:42 +00:00
# There are two udev pkg config files - udev.pc (wrong), libudev.pc (correct)
# When cross compiling, pkg-config will be skipped so we have to look for
# udev (it'll automatically be prefixed with lib). But when not cross
# compiling, we have to look for libudev.pc. Argh. Hence the silliness below.
if ( CMAKE_CROSSCOMPILING )
check_lib ( LIBUDEV udev libudev.h )
else ( )
check_lib ( LIBUDEV libudev libudev.h )
endif ( )
2014-12-28 06:41:57 +00:00
endif ( )
2020-05-07 15:31:48 +00:00
if ( PORTAUDIO_API )
check_lib ( PORTAUDIO portaudio portaudio.h pa_linux_alsa.h )
endif ( )
2014-08-04 16:15:10 +00:00
check_lib ( SOUNDTOUCH SoundTouch soundtouch/SoundTouch.h )
2010-06-04 17:17:55 +00:00
2014-12-07 11:19:14 +00:00
if ( SDL2_API )
2014-12-28 17:54:17 +00:00
check_lib ( SDL2 SDL2 SDL.h PATH_SUFFIXES SDL2 )
2014-12-07 11:19:14 +00:00
else ( )
# Tell cmake that we use SDL as a library and not as an application
set ( SDL_BUILDING_LIBRARY TRUE )
find_package ( SDL )
endif ( )
2014-12-28 06:41:57 +00:00
if ( UNIX )
2014-12-07 21:06:39 +00:00
find_package ( X11 )
# Most plugins (if not all) and PCSX2 core need gtk2, so set the required flags
2020-10-30 05:30:03 +00:00
if ( GTK2_API )
find_package ( GTK2 REQUIRED gtk )
2014-12-07 21:06:39 +00:00
else ( )
2020-10-30 05:30:03 +00:00
if ( CMAKE_CROSSCOMPILING )
find_package ( GTK3 REQUIRED gtk )
else ( )
check_lib ( GTK3 gtk+-3.0 gtk/gtk.h )
endif ( )
2014-12-07 21:06:39 +00:00
endif ( )
2021-05-13 11:17:10 +00:00
find_package ( XCB )
2014-12-07 21:06:39 +00:00
endif ( )
2010-06-04 17:17:55 +00:00
#----------------------------------------
2014-12-07 20:06:21 +00:00
# Use system include
2010-01-22 04:36:49 +00:00
#----------------------------------------
2014-12-28 06:41:57 +00:00
if ( UNIX )
2020-10-30 05:30:03 +00:00
if ( GTK3_FOUND )
include_directories ( ${ GTK3_INCLUDE_DIRS } )
2014-12-07 21:06:39 +00:00
# A lazy solution
set ( GTK2_LIBRARIES ${ GTK3_LIBRARIES } )
2020-10-30 05:30:03 +00:00
elseif ( GTK2_FOUND )
include_directories ( ${ GTK2_INCLUDE_DIRS } )
2014-04-17 18:24:12 +00:00
endif ( )
2010-01-22 04:36:49 +00:00
if ( X11_FOUND )
include_directories ( ${ X11_INCLUDE_DIR } )
2014-04-17 18:24:12 +00:00
endif ( )
endif ( )
2010-01-22 04:36:49 +00:00
if ( ALSA_FOUND )
include_directories ( ${ ALSA_INCLUDE_DIRS } )
2014-04-17 18:24:12 +00:00
endif ( )
2010-01-22 04:36:49 +00:00
if ( CG_FOUND )
2010-06-23 15:45:05 +00:00
include_directories ( ${ CG_INCLUDE_DIRS } )
2014-04-17 18:24:12 +00:00
endif ( )
2010-01-22 04:36:49 +00:00
2010-06-23 10:07:18 +00:00
if ( JPEG_FOUND )
include_directories ( ${ JPEG_INCLUDE_DIR } )
2014-04-17 18:24:12 +00:00
endif ( )
2010-06-23 10:07:18 +00:00
2010-01-22 04:36:49 +00:00
if ( GLEW_FOUND )
2010-10-30 11:24:03 +00:00
include_directories ( ${ GLEW_INCLUDE_DIR } )
2014-04-17 18:24:12 +00:00
endif ( )
2010-01-22 04:36:49 +00:00
2010-01-21 15:12:50 +00:00
if ( OPENGL_FOUND )
include_directories ( ${ OPENGL_INCLUDE_DIR } )
2014-04-17 18:24:12 +00:00
endif ( )
2010-01-21 15:12:50 +00:00
2014-12-07 11:19:14 +00:00
if ( SDL_FOUND AND NOT SDL2_API )
2010-01-21 15:12:50 +00:00
include_directories ( ${ SDL_INCLUDE_DIR } )
2014-04-17 18:24:12 +00:00
endif ( )
2010-01-21 15:12:50 +00:00
2016-12-04 17:46:02 +00:00
if ( USE_VTUNE AND VTUNE_FOUND )
include_directories ( ${ VTUNE_INCLUDE_DIRS } )
endif ( )
2010-06-04 17:17:55 +00:00
if ( wxWidgets_FOUND )
include ( ${ wxWidgets_USE_FILE } )
2014-04-17 18:24:12 +00:00
endif ( )
2010-06-04 17:17:55 +00:00
2018-10-03 04:37:34 +00:00
if ( PCAP_FOUND )
include_directories ( ${ PCAP_INCLUDE_DIR } )
endif ( )
2020-11-02 11:21:00 +00:00
if ( LIBSAMPLERATE_FOUND )
include_directories ( ${ LIBSAMPLERATE_INCLUDE_DIR } )
endif ( )
2020-11-02 20:30:13 +00:00
if ( PULSEAUDIO_FOUND )
include_directories ( ${ PULSEAUDIO_INCLUDE_DIR } )
endif ( )
2018-10-03 04:37:34 +00:00
if ( LIBXML2_FOUND )
include_directories ( ${ LIBXML2_INCLUDE_DIRS } )
endif ( )
2012-08-15 10:22:19 +00:00
if ( ZLIB_FOUND )
2010-06-04 17:17:55 +00:00
include_directories ( ${ ZLIB_INCLUDE_DIRS } )
2014-04-17 18:24:12 +00:00
endif ( )
2014-07-05 12:54:56 +00:00
2019-08-24 22:50:02 +00:00
find_package ( HarfBuzz )
2020-05-08 17:23:01 +00:00
if ( HarfBuzz_FOUND )
include_directories ( ${ HarfBuzz_INCLUDE_DIRS } )
2019-08-24 22:50:02 +00:00
endif ( )
2019-08-18 03:33:14 +00:00
2020-08-19 08:19:28 +00:00
set ( ACTUALLY_ENABLE_TESTS ${ ENABLE_TESTS } )
if ( ENABLE_TESTS )
if ( NOT EXISTS "${CMAKE_SOURCE_DIR}/3rdparty/gtest/CMakeLists.txt" )
message ( WARNING "ENABLE_TESTS was on but gtest was not found, unit tests will not be enabled" )
set ( ACTUALLY_ENABLE_TESTS Off )
endif ( )
endif ( )
2014-07-05 12:54:56 +00:00
#----------------------------------------
# Use project-wide include directories
#----------------------------------------
include_directories ( ${ CMAKE_SOURCE_DIR } /common/include
$ { C M A K E _ S O U R C E _ D I R } / c o m m o n / i n c l u d e / U t i l i t i e s
$ { C M A K E _ S O U R C E _ D I R } / c o m m o n / i n c l u d e / x 8 6 e m i t t e r
# File generated by Cmake
$ { C M A K E _ B I N A R Y _ D I R } / c o m m o n / i n c l u d e
)
2015-01-04 19:38:36 +00:00
#----------------------------------------
# Check correctness of the parameter
# Note: wxWidgets_INCLUDE_DIRS must be defined
#----------------------------------------
include ( ApiValidation )
2017-05-21 17:23:05 +00:00
2015-01-04 19:38:36 +00:00
WX_vs_SDL ( )
2017-05-21 17:23:05 +00:00
# Blacklist bad GCC
if ( GCC_VERSION VERSION_EQUAL "7.0" OR GCC_VERSION VERSION_EQUAL "7.1" )
GCC7_BUG ( )
endif ( )
2019-06-19 04:24:23 +00:00
2019-09-22 01:00:52 +00:00
if ( ( GCC_VERSION VERSION_EQUAL "9.0" OR GCC_VERSION VERSION_GREATER "9.0" ) AND GCC_VERSION LESS "9.2" )
2019-06-19 04:24:23 +00:00
message ( WARNING "
I t l o o k s l i k e y o u a r e c o m p i l i n g w i t h 9 . 0 . x o r 9 . 1 . x . U s i n g t h e s e v e r s i o n s i s n o t r e c o m m e n d e d ,
a s t h e r e i s a b u g k n o w n t o c a u s e t h e c o m p i l e r t o s e g f a u l t w h i l e c o m p i l i n g . S e e p a t c h
h t t p s : / / g i t w e b . g e n t o o . o r g / p r o j / g c c - p a t c h e s . g i t / c o m m i t / ? i d = 2 7 5 a b 7 1 4 6 3 7 a 6 4 6 7 2 c 6 6 3 0 c f d 7 4 4 a f 2 c 7 0 9 5 7 d 5 a
E v e n w i t h t h a t p a t c h , c o m p i l i n g w i t h L T O m a y s t i l l s e g f a u l t . U s e a t y o u r o w n r i s k !
T h i s t e x t b e i n g i n a c o m p i l e l o g i n a n o p e n i s s u e m a y c a u s e i t t o b e c l o s e d . " )
2020-05-07 15:31:48 +00:00
endif ( )
2020-11-09 00:28:43 +00:00
2021-03-14 18:38:14 +00:00
find_package ( fmt "7.1.3" QUIET )
2020-11-09 00:28:43 +00:00
if ( NOT fmt_FOUND )
if ( EXISTS "${CMAKE_SOURCE_DIR}/3rdparty/fmt/fmt/CMakeLists.txt" )
message ( STATUS "No system fmt was found. Using bundled" )
add_subdirectory ( 3rdparty/fmt/fmt )
else ( )
message ( FATAL_ERROR "No system or bundled fmt was found" )
endif ( )
else ( )
message ( STATUS "Found fmt: ${fmt_VERSION}" )
endif ( )
2020-11-27 18:59:31 +00:00
2020-12-06 19:39:25 +00:00
if ( USE_SYSTEM_YAML )
find_package ( yaml-cpp "0.6.3" QUIET )
if ( NOT yaml-cpp_FOUND )
message ( STATUS "No system yaml-cpp was found" )
set ( USE_SYSTEM_YAML OFF )
else ( )
message ( STATUS "Found yaml-cpp: ${yaml-cpp_VERSION}" )
message ( STATUS "Note that the latest release of yaml-cpp is very outdated, and the bundled submodule in the repo has over a year of bug fixes and as such is preferred." )
endif ( )
endif ( )
if ( NOT USE_SYSTEM_YAML )
2020-11-27 18:59:31 +00:00
if ( EXISTS "${CMAKE_SOURCE_DIR}/3rdparty/yaml-cpp/yaml-cpp/CMakeLists.txt" )
2020-12-06 19:39:25 +00:00
message ( STATUS "Using bundled yaml-cpp" )
2020-11-27 18:59:31 +00:00
add_subdirectory ( 3rdparty/yaml-cpp/yaml-cpp EXCLUDE_FROM_ALL )
else ( )
2020-12-06 19:39:25 +00:00
message ( FATAL_ERROR "No bundled yaml-cpp was found" )
2020-11-27 18:59:31 +00:00
endif ( )
endif ( )
2020-12-25 10:25:55 +00:00
add_subdirectory ( 3rdparty/libchdr/libchdr EXCLUDE_FROM_ALL )
include_directories ( 3rdparty/libchdr/libchdr/include )
2021-05-11 08:33:18 +00:00
#-------------------------------------------------------------------------------
# Dependency message print
#-------------------------------------------------------------------------------
set ( msg_dep_common_libs "check these libraries -> wxWidgets (>=3.0), aio" )
set ( msg_dep_pcsx2 "check these libraries -> wxWidgets (>=3.0), gtk2, zlib (>=1.2.4), pcsx2 common libs" )
set ( msg_dep_gsdx "check these libraries -> opengl, png (>=1.2), zlib (>=1.2.4), X11, liblzma" )
macro ( print_dep str dep )
if ( PACKAGE_MODE )
message ( FATAL_ERROR "${str}:${dep}" )
else ( )
message ( STATUS "${str}:${dep}" )
endif ( )
endmacro ( print_dep )
#-------------------------------------------------------------------------------
# Pcsx2 core & common libs
#-------------------------------------------------------------------------------
# Check for additional dependencies.
# If all dependencies are available, including OS, build it
#-------------------------------------------------------------------------------
if ( GTK2_FOUND OR GTK3_FOUND )
set ( GTKn_FOUND TRUE )
elseif ( APPLE ) # Not we have but that we don't change all if(gtkn) entries
set ( GTKn_FOUND TRUE )
else ( )
set ( GTKn_FOUND FALSE )
endif ( )
if ( SDL_FOUND OR SDL2_FOUND )
set ( SDLn_FOUND TRUE )
else ( )
set ( SDLn_FOUND FALSE )
endif ( )
if ( wxWidgets_FOUND )
set ( common_libs TRUE )
elseif ( NOT EXISTS "${CMAKE_SOURCE_DIR}/common/src" )
set ( common_libs FALSE )
else ( )
set ( common_libs FALSE )
print_dep ( "Skip build of common libraries: missing dependencies" "${msg_dep_common_libs}" )
endif ( )
# Common dependancy
if ( wxWidgets_FOUND AND ZLIB_FOUND AND common_libs AND NOT ( Linux AND NOT AIO_FOUND ) )
if ( OPENGL_FOUND AND X11_FOUND AND GTKn_FOUND AND ZLIB_FOUND AND PNG_FOUND AND FREETYPE_FOUND AND LIBLZMA_FOUND AND ( ( EGL_FOUND AND X11_XCB_FOUND ) OR APPLE ) )
set ( pcsx2_core TRUE )
else ( )
print_dep ( "Skip build of pcsx2 core: missing dependencies" "${msg_dep_pcsx2}" )
set ( pcsx2_core FALSE )
endif ( )
elseif ( NOT EXISTS "${CMAKE_SOURCE_DIR}/pcsx2" )
set ( pcsx2_core FALSE )
else ( )
set ( pcsx2_core FALSE )
print_dep ( "Skip build of pcsx2 core: missing dependencies" "${msg_dep_pcsx2}" )
endif ( )
# Linux, BSD, use gtk2, but not OSX
if ( UNIX AND pcsx2_core AND NOT GTKn_FOUND AND NOT APPLE )
set ( pcsx2_core FALSE )
print_dep ( "Skip build of pcsx2 core: missing dependencies" "${msg_dep_pcsx2}" )
endif ( )