cmake HAS_GL option, by default true, affect graphic and qglview

This commit is contained in:
2021-04-23 00:21:50 +03:00
parent 36a567dbeb
commit 159f0dd6c7
4 changed files with 20 additions and 4 deletions

View File

@@ -31,6 +31,7 @@ endif()
option(UTILS "Build various utils" ${_plugins_default_})
option(DESIGNER_PLUGINS "Build Qt designer plugins" ${_plugins_default_})
option(HAS_GL "Build with OpenGL" ${_plugins_default_})
macro(qad_library NAME _MODULES _LIBS)
shstk_qad_project(qad_${NAME} FALSE "qad" "${_MODULES}" "${_LIBS}" ${ARGN})

View File

@@ -1 +1,10 @@
qad_library(graphic "Gui;Widgets;OpenGL;OpenGLWidgets" "qad_widgets;${OPENGL_LIBRARIES}")
set(_mods Gui Widgets)
set(_libs qad_widgets)
if (HAS_GL)
list(APPEND _mods OpenGL OpenGLWidgets)
list(APPEND _libs ${OPENGL_LIBRARIES})
endif()
qad_library(graphic "${_mods}" "${_libs}")
if (NOT HAS_GL)
qad_target_compile_definitions(qad_graphic PRIVATE FORCE_NO_GL)
endif()

View File

@@ -15,7 +15,9 @@
# include <QRandomGenerator>
#endif
#ifndef Q_OS_ANDROID
# define HAS_GL
# ifndef FORCE_NO_GL
# define HAS_GL
# endif
#endif
#ifdef HAS_GL
# ifndef GL_MULTISAMPLE
@@ -361,7 +363,7 @@ void Graphic::canvasPaintEvent() {
if (grid)
drawGrid();
p.setRenderHint(QPainter::Antialiasing, aalias);
#ifndef ANDROID
#ifdef HAS_GL
if (isOGL) {
if (aalias) glEnable(GL_MULTISAMPLE);
else glDisable(GL_MULTISAMPLE);
@@ -1627,6 +1629,10 @@ void Graphic::on_graphic_buttonConfigure_clicked() {
conf->ui->comboStyleGrid->setCurrentIndex((int)grid_pen.style());
conf->ui->spinWidthGrid->setValue(grid_pen.widthF());
conf->ui->checkOGL->setChecked(isOGL);
#ifndef HAS_GL
conf->ui->checkOGL->setEnabled(false);
conf->ui->checkOGL->setChecked(false);
#endif
conf->ui->checkAAlias->setChecked(aalias);
conf->ui->checkInputs->setChecked(borderInputsVisible());
conf->ui->checkStatus->setChecked(statusVisible());

View File

@@ -1,4 +1,4 @@
if (((DEFINED QGLVIEW) AND QGLVIEW) OR (NOT DEFINED QGLVIEW))
if (((DEFINED QGLVIEW) AND QGLVIEW AND HAS_GL) OR (NOT DEFINED QGLVIEW))
find_package(OpenGL REQUIRED)
shstk_qad_project(qglview FALSE "qad" "Gui;OpenGL;Xml" "qad_widgets;qad_utils;${OPENGL_LIBRARIES}")
shstk_qad_install("qad" FALSE qglview "${out_HDR}" "${out_QM}")