Skip to content

Commit bbc6d2a

Browse files
author
moebius
committed
Added GLEWDEFINITIONS plugin macro.
Use openflipper_plugin( GLEWDEFINITIONS GL_BUFFER_UPDATE_BARRIER_BIT GL_SHADER_IMAGE_ACCESS_BARRIER_BIT ) to check for glew dependencies closes #2258 closes #2353
1 parent 63e833b commit bbc6d2a

File tree

2 files changed

+56
-2
lines changed

2 files changed

+56
-2
lines changed

OpenFlipper/cmake/plugin.cmake

Lines changed: 33 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@
2626
# INCDIRS = additional include directories
2727
# ADDSRC = additional source files
2828
# INSTALLDATA = directories that will be installed into the openflipper data directory
29+
# GLEWDEFINITIONS = Checks glew if it defines the given definitions
2930
#
3031
# TRANSLATION_LANGUAGES = language codes for translation
3132
# TRANSLATION_ADDFILES = additional files that should be included into the translation files
@@ -67,7 +68,7 @@ endmacro ()
6768
# parse plugin macro parameter
6869
macro (_get_plugin_parameters _prefix)
6970
set (_current_var _foo)
70-
set (_supported_var DIRS DEPS OPTDEPS LDFLAGSADD CFLAGSADD CDEFINITIONSADD LIBRARIES LIBDIRS INCDIRS ADDSRC INSTALLDATA TRANSLATION_LANGUAGES TRANSLATION_ADDFILES)
71+
set (_supported_var DIRS DEPS OPTDEPS LDFLAGSADD CFLAGSADD CDEFINITIONSADD LIBRARIES LIBDIRS INCDIRS ADDSRC INSTALLDATA GLEWDEFINITIONS TRANSLATION_LANGUAGES TRANSLATION_ADDFILES)
7172
set (_supported_flags LICENSEMANAGER)
7273
foreach (_val ${_supported_var})
7374
set (${_prefix}_${_val})
@@ -367,7 +368,31 @@ macro (_plugin_licensemanagement)
367368
endif()
368369
endmacro ()
369370

371+
#======================================================
372+
# check dependencies in GLEW library
373+
# _prefix : prefix used ( usually the plugin name )
374+
#======================================================
375+
macro (_check_plugin_glew_deps _prefix )
376+
377+
foreach (_extension ${${_prefix}_GLEWDEFINITIONS})
378+
379+
acg_test_glew_definition( ${_extension} ${_prefix}_GLEW_HAS_DEFINITION_${_extension} )
380+
381+
# If the dependency is not found, we disable the plugin
382+
if(NOT ${_prefix}_GLEW_HAS_DEFINITION_${_extension} )
383+
set (${_prefix}_HAS_DEPS FALSE)
384+
acg_set (_${_prefix}_MISSING_DEPS "${_${_prefix}_MISSING_DEPS} GLEW extension ${_extension}")
385+
endif()
386+
387+
endforeach()
388+
389+
endmacro ()
390+
391+
392+
393+
#======================================================
370394
# main function
395+
#======================================================
371396
function (_build_openflipper_plugin plugin)
372397

373398
acg_set (OPENFLIPPER_${_PLUGIN}_BUILD "0")
@@ -394,6 +419,12 @@ function (_build_openflipper_plugin plugin)
394419
set (${_PLUGIN}_HAS_DEPS)
395420
_check_plugin_deps (${_PLUGIN} FALSE ${${_PLUGIN}_DEPS})
396421

422+
#============================================================================================
423+
# CHECK for GLEW definitions
424+
#============================================================================================
425+
426+
_check_plugin_glew_deps (${_PLUGIN})
427+
397428

398429
#============================================================================================
399430
# Remember Lib dirs for bundle generation
@@ -727,4 +758,4 @@ macro (openflipper_plugin)
727758
endmacro ()
728759

729760
# No stupid abundance of "Boost version" messages, please.
730-
SET (Boost_FIND_QUIETLY TRUE PARENT_SCOPE)
761+
SET (Boost_FIND_QUIETLY TRUE PARENT_SCOPE)

cmake/ACGCommon.cmake

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -957,3 +957,26 @@ function (generate_qhp_file files_loc plugin_name)
957957
endif()
958958
endforeach()
959959
endfunction()
960+
961+
function(acg_test_glew_definition _def _out)
962+
include(CheckCXXSourceRuns)
963+
set(CMAKE_REQUIRED_INCLUDES ${GLEW_INCLUDE_DIRS})
964+
set(CMAKE_REQUIRED_LIBRARIES ${GLEW_LIBRARIES})
965+
set(CMAKE_REQUIRED_DEFINITIONS -DCHECKING=${_def})
966+
if(GLEW_FOUND)
967+
if(NOT ${_out})
968+
unset(${_out} CACHE) #clear cache, if previous test failed and try again
969+
endif()
970+
CHECK_CXX_SOURCE_RUNS("
971+
#include <GL/glew.h>
972+
int main()
973+
{
974+
#ifdef ${_def}
975+
return 0;
976+
#else
977+
return 1;
978+
#endif
979+
}"
980+
${_out})
981+
endif()
982+
endfunction()

0 commit comments

Comments
 (0)