1
# cmake/modules/qt.cmake
3
# Copyright (C) 2009 Alan W. Irwin
5
# This file is part of PLplot.
7
# PLplot is free software; you can redistribute it and/or modify
8
# it under the terms of the GNU Library General Public License as published
9
# by the Free Software Foundation; version 2 of the License.
11
# PLplot is distributed in the hope that it will be useful,
12
# but WITHOUT ANY WARRANTY; without even the implied warranty of
13
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14
# GNU Library General Public License for more details.
16
# You should have received a copy of the GNU Library General Public License
17
# along with the file PLplot; if not, write to the Free Software
18
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
20
# Module for determining all configuration variables related to the qt
21
# device driver, the plplotqt library, and the plplot_pyqt4 Python extension
23
# The following variables are set/modified:
24
# PLD_bmpqt - ON means the bmpqt device is enabled.
25
# PLD_jpgqt - ON means the jpgqt device is enabled.
26
# PLD_pngqt - ON means the pngqt device is enabled.
27
# PLD_ppmqt - ON means the ppmqt device is enabled.
28
# PLD_tiffqt - ON means the tiffqt device is enabled.
29
# PLD_epsqt - ON means the epsqt device is enabled.
30
# PLD_pdfqt - ON means the pdfqt device is enabled.
31
# PLD_qtwidget - ON means the qtwidget device is enabled.
32
# PLD_svgqt - ON means the svgqt device is enabled.
33
# PLD_extqt - ON means the extqt device is enabled.
34
# PLD_memqt - ON means the memqt device is enabled.
35
# qt_COMPILE_FLAGS - individual COMPILE_FLAGS required to compile wxwidgets
37
# qt_LINK_FLAGS - list of full path names of libraries and
38
# qt_TARGETS - list of targets which the qt dynamic device
40
# linker flags for dynamic wxwidgets device driver.
41
# qt_RPATH - RPATH directory list for qt device driver.
42
# DRIVERS_LINK_FLAGS - list of device LINK_FLAGS for case when
43
# ENABLE_DYNDRIVERS OFF. (qt_TARGETS not included
44
# since source code used instead of this target
45
# for ENABLE_DYNDRIVERS OFF.)
46
# qt_SOURCE - list of source files to be appended to qt.cpp.
47
# ENABLE_qt - ON means the plplot_qt library is enabled.
48
# ENABLE_pyqt4 - ON means the plplot_pyqt4 Python extension module
50
# SIP_EXECUTABLE - full path for sip
51
# PYQT_SIP_DIR - sip system directory
52
# PYQT_SIP_FLAGS - sip command flags
54
# valgrind shows severe memory management problems with qt_example and
55
# qt_example either segfaults or hangs when ENABLE_DYNDRIVERS is OFF.
56
# I presume this is due to some linking issue for that case, but for
57
# now disable PLD_extqt when ENABLE_DYNDRIVERS is OFF until someone can
58
# investigate this issue further.
60
if(PLD_extqt AND NOT ENABLE_DYNDRIVERS)
61
message(STATUS "WARNING: ENABLE_DYNDRIVERS is OFF so force PLD_extqt to be OFF")
62
set(PLD_extqt OFF CACHE BOOL "Enable Qt ext device" FORCE)
63
endif(PLD_extqt AND NOT ENABLE_DYNDRIVERS)
65
if(PLD_bmpqt OR PLD_jpgqt OR PLD_pngqt OR PLD_ppmqt OR PLD_tiffqt OR PLD_epsqt OR PLD_pdfqt OR PLD_qtwidget OR PLD_svgqt OR PLD_extqt OR PLD_memqt)
67
endif(PLD_bmpqt OR PLD_jpgqt OR PLD_pngqt OR PLD_ppmqt OR PLD_tiffqt OR PLD_epsqt OR PLD_pdfqt OR PLD_qtwidget OR PLD_svgqt OR PLD_extqt OR PLD_memqt)
70
if(NOT CMAKE_CXX_COMPILER_WORKS)
71
message(STATUS "WARNING: no working C++ compiler so "
72
"disabling all qt devices."
74
set(ANY_QT_DEVICE OFF)
75
endif(NOT CMAKE_CXX_COMPILER_WORKS)
81
if(PLD_svgqt AND ${QT_VERSION_MINOR} GREATER 2)
83
endif(PLD_svgqt AND ${QT_VERSION_MINOR} GREATER 2)
84
# Do not include(${QT_USE_FILE}) here because it contaminates ALL
85
# build environments with Qt flags from the top-level directory on
86
# down. Instead include(${QT_USE_FILE}) only in certain subdirectories
87
# where it is necessary.
89
foreach(DIR ${QT_INCLUDES})
90
set(qt_COMPILE_FLAGS "${qt_COMPILE_FLAGS} -I${DIR}")
91
endforeach(DIR ${QT_INCLUDES})
94
set(qt_RPATH ${QT_LIBRARY_DIR})
95
filter_rpath(qt_RPATH)
96
#message("qt_LIBRARY_DIR = ${qt_LIBRARY_DIR}")
98
message(STATUS "WARNING: Qt4 development environment not found so "
99
"disabling all qt devices."
101
set(ANY_QT_DEVICE OFF)
105
if(NOT ANY_QT_DEVICE)
106
set(PLD_bmpqt OFF CACHE BOOL "Enable Qt Windows bmp device" FORCE)
107
set(PLD_jpgqt OFF CACHE BOOL "Enable Qt jpg device" FORCE)
108
set(PLD_pngqt OFF CACHE BOOL "Enable Qt png device" FORCE)
109
set(PLD_ppmqt OFF CACHE BOOL "Enable Qt ppm device" FORCE)
110
set(PLD_tiffqt OFF CACHE BOOL "Enable Qt tiff device" FORCE)
111
set(PLD_epsqt OFF CACHE BOOL "Enable Qt EPS device" FORCE)
112
set(PLD_pdfqt OFF CACHE BOOL "Enable Qt PDF device" FORCE)
113
set(PLD_qtwidget OFF CACHE BOOL "Enable Qt interactive device" FORCE)
114
set(PLD_svgqt OFF CACHE BOOL "Enable Qt SVG device" FORCE)
115
set(PLD_extqt OFF CACHE BOOL "Enable Qt ext device" FORCE)
116
set(PLD_memqt OFF CACHE BOOL "Enable Qt mem device" FORCE)
117
endif(NOT ANY_QT_DEVICE)
119
if(DEFAULT_NO_BINDINGS)
120
option(ENABLE_qt "Enable Qt bindings" OFF)
121
option(ENABLE_pyqt4 "Enable pyqt4 Python extension module" OFF)
122
else(DEFAULT_NO_BINDINGS)
123
option(ENABLE_qt "Enable Qt bindings" ON)
124
option(ENABLE_pyqt4 "Enable pyqt4 Python extension module" ON)
125
endif(DEFAULT_NO_BINDINGS)
127
if(ENABLE_qt AND NOT PLD_extqt)
129
"WARNING: PLD_extqt is OFF so "
130
"setting ENABLE_qt to OFF."
132
set(ENABLE_qt OFF CACHE BOOL "Enable Qt bindings" FORCE)
133
endif(ENABLE_qt AND NOT PLD_extqt)
135
if(ENABLE_pyqt4 AND NOT ENABLE_python)
137
"WARNING: ENABLE_python is OFF so "
138
"setting ENABLE_pyqt4 to OFF."
140
set(ENABLE_pyqt4 OFF CACHE BOOL "Enable pyqt4 Python extension module " FORCE)
141
endif(ENABLE_pyqt4 AND NOT ENABLE_python)
143
if(ENABLE_pyqt4 AND NOT ENABLE_qt)
145
"WARNING: ENABLE_qt is OFF so "
146
"setting ENABLE_pyqt4 to OFF."
148
set(ENABLE_pyqt4 OFF CACHE BOOL "Enable pyqt4 Python extension module " FORCE)
149
endif(ENABLE_pyqt4 AND NOT ENABLE_qt)
158
if(ENABLE_DYNDRIVERS)
161
set(qt_TARGETS plplotqt${LIB_TAG})
163
# if qt disabled, then must include full source and forget
164
# qt_TARGETS for this dynamic device.
165
set(qt_SOURCE ${CMAKE_SOURCE_DIR}/bindings/qt_gui/plqt.cpp)
167
else(ENABLE_DYNDRIVERS)
168
# N.B. no qt_TARGETS here since use appropriate source code (see below)
169
# instead to break circular linking.
170
set(DRIVERS_LINK_FLAGS ${DRIVERS_LINK_FLAGS} ${qt_LINK_FLAGS})
171
set(qt_SOURCE ${CMAKE_SOURCE_DIR}/bindings/qt_gui/plqt.cpp)
172
endif(ENABLE_DYNDRIVERS)
176
find_program(SIP_EXECUTABLE sip)
177
if(NOT SIP_EXECUTABLE)
179
"WARNING: sip not found so setting ENABLE_pyqt4 to OFF."
181
set(ENABLE_pyqt4 OFF CACHE BOOL "Enable pyqt4 Python extension module " FORCE)
182
endif(NOT SIP_EXECUTABLE)
187
COMMAND ${PYTHON_EXECUTABLE} -c "from PyQt4 import pyqtconfig; print pyqtconfig.Configuration().pyqt_sip_dir"
188
OUTPUT_VARIABLE PYQT_SIP_DIR
189
RESULT_VARIABLE PYQT_SIP_DIR_ERR
190
OUTPUT_STRIP_TRAILING_WHITESPACE
194
"WARNING: could not find sip directory so setting ENABLE_pyqt4 to OFF."
196
set(ENABLE_pyqt4 OFF CACHE BOOL "Enable pyqt4 Python extension module " FORCE)
197
endif(PYQT_SIP_DIR_ERR)
202
COMMAND ${PYTHON_EXECUTABLE} -c "from PyQt4 import pyqtconfig; print pyqtconfig.Configuration().pyqt_sip_flags"
203
OUTPUT_VARIABLE PYQT_SIP_FLAGS
204
RESULT_VARIABLE PYQT_SIP_FLAGS_ERR
205
OUTPUT_STRIP_TRAILING_WHITESPACE
207
if(PYQT_SIP_FLAGS_ERR)
209
"WARNING: could not find sip flags so setting ENABLE_pyqt4 to OFF."
211
set(ENABLE_pyqt4 OFF CACHE BOOL "Enable pyqt4 Python extension module " FORCE)
212
endif(PYQT_SIP_FLAGS_ERR)
213
# Must change from blank-delimited string to CMake list so that sip
214
# COMMAND will work properly with these flags later on.
215
string(REGEX REPLACE " " ";"PYQT_SIP_FLAGS "${PYQT_SIP_FLAGS}")