From 800262fc14df55b8f0526c7235fe1903de270a68 Mon Sep 17 00:00:00 2001 From: Gregory Hainaut Date: Sun, 7 Dec 2014 22:06:39 +0100 Subject: [PATCH] cmake: add a new GTK3.0 option Thanks #micove for the patch --- build.sh | 11 ++++++++--- cmake/BuildParameters.cmake | 2 ++ cmake/CheckLib.cmake | 6 +++++- cmake/SearchForStuff.cmake | 20 ++++++++++++++------ 4 files changed, 29 insertions(+), 10 deletions(-) diff --git a/build.sh b/build.sh index f6c4494879..078def965c 100755 --- a/build.sh +++ b/build.sh @@ -41,6 +41,7 @@ for ARG in "$@"; do --asan ) flags+=(-DUSE_ASAN=TRUE) ;; --wx28 ) flags+=(-DWX28_API=TRUE) ;; --wx30 ) flags+=(-DWX28_API=FALSE) ;; + --gtk3 ) flags+=(-DGTK3_API=TRUE) ;; --64-bit-dont-work ) flags+=(-D64BIT_BUILD_DONT_WORK=TRUE) ;; --no-simd ) flags+=(-DDISABLE_ADVANCE_SIMD=TRUE) ;; -D* ) flags+=($ARG) ;; @@ -51,21 +52,25 @@ for ARG in "$@"; do echo "--dev / --devel : Build PCSX2 as a Development build." echo "--debug : Build PCSX2 as a Debug build." echo "--release : Build PCSX2 as a Release build." + echo echo "--clean : Do a clean build." + echo "--extra : Build all plugins" + echo echo "** Developper option **" echo "--clang : Build with Clang/llvm" - echo "--extra : Build all plugins" - echo "--asan : Enable with Address sanitizer" + echo "--asan : Enable Address sanitizer" echo echo "--wx28 : Force wxWidget 2.8" echo "--wx30 : Allow to use wxWidget 3.0" echo "--glsl : Replace CG backend of ZZogl by GLSL" echo "--egl : Replace GLX by EGL (ZZogl plugins only)" echo "--sdl2 : Build with SDL2 (crash if wx is linked to SDL1)" - echo "--gles : Replace openGL backend of GSdx by openGLES3" + echo "--gles : Replace openGL backend of GSdx by openGLES3.1" echo + echo "** Hardcode Developper option **" echo "--64-bit-dont-work : Don't use it!" echo "--no-simd : Only allow sse2" + echo "--gtk3 : replace GTK2 by GTK3" exit 1 esac done diff --git a/cmake/BuildParameters.cmake b/cmake/BuildParameters.cmake index 2d6e5849be..e1570045bc 100644 --- a/cmake/BuildParameters.cmake +++ b/cmake/BuildParameters.cmake @@ -34,6 +34,7 @@ option(XDG_STD "Use XDG standard path instead of the standard PCSX2 path") option(EXTRA_PLUGINS "Build various 'extra' plugins") option(SDL2_API "Use SDL2 on spu2x and onepad") option(WX28_API "Force wxWidget 2.8 lib") +option(GTK3_API "Use GTK3 api") if(PACKAGE_MODE) if(NOT DEFINED PLUGIN_DIR) @@ -239,6 +240,7 @@ else() set(ASAN_FLAG "") endif() +# Note: -DGTK_DISABLE_DEPRECATED can be used to test a build without gtk deprecated feature. It could be useful to port to a newer API set(DEFAULT_GCC_FLAG "${ARCH_FLAG} ${COMMON_FLAG} ${DEFAULT_WARNINGS} ${HARDENING_FLAG} ${DEBUG_FLAG} ${ASAN_FLAG}") # c++ only flags set(DEFAULT_CPP_FLAG "${DEFAULT_GCC_FLAG} -Wno-invalid-offsetof") diff --git a/cmake/CheckLib.cmake b/cmake/CheckLib.cmake index 4fe63f2463..1b7e7f1778 100644 --- a/cmake/CheckLib.cmake +++ b/cmake/CheckLib.cmake @@ -29,7 +29,11 @@ macro(check_lib var lib) include_directories(${${var}_INCLUDE}) _internal_message("-- ${lib} found") set(${var}_FOUND 1 CACHE INTERNAL "") - else() + elseif(${var}_LIBRARIES) + _internal_message("-- ${lib} not found (miss include)") + elseif(${var}_INCLUDE) + _internal_message("-- ${lib} not found (miss lib)") + else() _internal_message("-- ${lib} not found") endif() endif() diff --git a/cmake/SearchForStuff.cmake b/cmake/SearchForStuff.cmake index 9e224db9e5..fb018b1a9d 100644 --- a/cmake/SearchForStuff.cmake +++ b/cmake/SearchForStuff.cmake @@ -1,12 +1,6 @@ #------------------------------------------------------------------------------- # Search all libraries on the system #------------------------------------------------------------------------------- -if(Linux) - # Most plugins (if not all) and PCSX2 core need gtk2, so set the required flags - find_package(GTK2 REQUIRED gtk) - find_package(X11) -endif() - ## Use cmake package to find module find_package(ALSA) find_package(BZip2) @@ -50,12 +44,26 @@ else() find_package(SDL) endif() +if (Linux) + find_package(X11) + # Most plugins (if not all) and PCSX2 core need gtk2, so set the required flags + if (GTK3_API) + check_lib(GTK3 gtk+-3.0 gtk/gtk.h) + else() + find_package(GTK2 REQUIRED gtk) + endif() +endif() + #---------------------------------------- # Use system include #---------------------------------------- if(Linux) if(GTK2_FOUND) include_directories(${GTK2_INCLUDE_DIRS}) + elseif(GTK3_FOUND) + include_directories(${GTK3_INCLUDE_DIRS}) + # A lazy solution + set(GTK2_LIBRARIES ${GTK3_LIBRARIES}) endif() if(X11_FOUND)