From c232f90d6e7be76af5e976fdcce41b148eb29f45 Mon Sep 17 00:00:00 2001 From: Gregory Hainaut Date: Fri, 3 Feb 2017 23:30:25 +0100 Subject: [PATCH] cmake: add an option to enable openCL Note: nothing work --- cmake/BuildParameters.cmake | 1 + cmake/CheckLib.cmake | 31 +++++++++++-------------------- cmake/SearchForStuff.cmake | 3 +++ plugins/GSdx/CMakeLists.txt | 8 ++++++++ 4 files changed, 23 insertions(+), 20 deletions(-) diff --git a/cmake/BuildParameters.cmake b/cmake/BuildParameters.cmake index fe61474ef4..c9715bebf4 100644 --- a/cmake/BuildParameters.cmake +++ b/cmake/BuildParameters.cmake @@ -35,6 +35,7 @@ option(USE_VTUNE "Plug VTUNE to profile GSdx JIT.") #------------------------------------------------------------------------------- option(GLSL_API "Replace ZZogl CG backend by GLSL (experimental option)") option(EGL_API "Use EGL on ZZogl/GSdx (experimental/developer option)") +option(OPENCL_API "Add OpenCL suppport on GSdx") option(REBUILD_SHADER "Rebuild GLSL/CG shader (developer option)") option(BUILD_REPLAY_LOADERS "Build GS replayer to ease testing (developer option)") option(GSDX_LEGACY "Build a GSdx legacy plugin compatible with GL3.3") diff --git a/cmake/CheckLib.cmake b/cmake/CheckLib.cmake index ad7cef1800..9884728fab 100644 --- a/cmake/CheckLib.cmake +++ b/cmake/CheckLib.cmake @@ -17,7 +17,7 @@ macro(check_lib var lib) # Make sure include directories for headers found using find_path below # are re-added when reconfiguring include_directories(${${var}_INCLUDE}) - _internal_message("-- ${var} found") + _internal_message("-- ${var} found pkg") else() find_library(${var}_LIBRARIES ${lib}) if(_arg_list) @@ -25,26 +25,17 @@ macro(check_lib var lib) else() set(${var}_INCLUDE FALSE) endif() - if (${lib}) - if(${var}_LIBRARIES AND ${var}_INCLUDE) - include_directories(${${var}_INCLUDE}) - _internal_message("-- ${var} found") - set(${var}_FOUND 1 CACHE INTERNAL "") - elseif(${var}_LIBRARIES) - _internal_message("-- ${var} not found (miss include)") - elseif(${var}_INCLUDE) - _internal_message("-- ${var} not found (miss lib)") - else() - _internal_message("-- ${var} not found") - endif() + + if(${var}_LIBRARIES AND ${var}_INCLUDE) + include_directories(${${var}_INCLUDE}) + _internal_message("-- ${var} found") + set(${var}_FOUND 1 CACHE INTERNAL "") + elseif(${var}_LIBRARIES) + _internal_message("-- ${var} not found (miss include)") + elseif(${var}_INCLUDE) + _internal_message("-- ${var} not found (miss lib)") else() - if(${var}_INCLUDE) - include_directories(${${var}_INCLUDE}) - _internal_message("-- ${var} found") - set(${var}_FOUND 1 CACHE INTERNAL "") - else() - _internal_message("-- ${var} not found") - endif() + _internal_message("-- ${var} not found") endif() endif() endmacro() diff --git a/cmake/SearchForStuff.cmake b/cmake/SearchForStuff.cmake index 42d7e12ba8..f805e4e249 100644 --- a/cmake/SearchForStuff.cmake +++ b/cmake/SearchForStuff.cmake @@ -92,6 +92,9 @@ endif() if(EGL_API) check_lib(EGL EGL EGL/egl.h) endif() +if(OPENCL_API) + check_lib(OPENCL OpenCL CL/cl.hpp) +endif() check_lib(PORTAUDIO portaudio portaudio.h pa_linux_alsa.h) check_lib(SOUNDTOUCH SoundTouch soundtouch/SoundTouch.h) diff --git a/plugins/GSdx/CMakeLists.txt b/plugins/GSdx/CMakeLists.txt index 4a3e5a2b26..29f7c85d1f 100644 --- a/plugins/GSdx/CMakeLists.txt +++ b/plugins/GSdx/CMakeLists.txt @@ -39,6 +39,10 @@ if(NOT USE_CLANG) set(GSdxFinalFlags ${GSdxFinalFlags} -fabi-version=6) endif() +if(OPENCL_API) + set(GSdxFinalFlags ${GSdxFinalFlags} -DENABLE_OPENCL) +endif() + set(GSdxSources GLLoader.cpp GLState.cpp @@ -210,6 +214,10 @@ if(USE_VTUNE) set(GSdxFinalLibs ${GSdxFinalLibs} ${VTUNE_LIBRARIES}) endif() +if(OPENCL_FOUND) + set(GSdxFinalLibs ${GSdxFinalLibs} ${OPENCL_LIBRARIES}) +endif() + # Generate Glsl header file. Protect with REBUILD_SHADER to avoid build-dependency on PERL if (REBUILD_SHADER) add_custom_command(OUTPUT res/glsl_source.h COMMAND perl ${CMAKE_SOURCE_DIR}/linux_various/glsl2h.pl)