Debian Codegraph @

octovis/CMakeModules/FindQGLViewer.cmake

raw
1 # Find QGLViewer library
2 # Looks for a system-wide version of libQGLViewer (qglviewer-qt4 or 5 in Ubuntu).
3 # If none is found, it builds and uses the local copy in "extern"
4 #
5 # Many thanks to L. Ott for assistance!
6 #
7 # QGLViewer_INCLUDE_DIR where to find the include files
8 # QGLViewer_LIBRARY_DIR where to find the libraries
9 # QGLViewer_LIBRARIES list of libraries to link
10 # QGLViewer_FOUND true if QGLViewer was found
11
12 SET( QGLViewer_FOUND 0 CACHE BOOL "Do we have QGLViewer?" )
13
14 FIND_PATH( QGLVIEWER_BASE_DIR qglviewer.h
15 ${CMAKE_SOURCE_DIR}/src/extern/QGLViewer
16 ${CMAKE_SOURCE_DIR}/octovis/src/extern/QGLViewer
17 )
18
19 FIND_PATH( QGLViewer_INCLUDE_DIR qglviewer.h
20 /usr/include/qglviewer-qt4
21 /usr/include/QGLViewer
22 /opt/local/include/QGLViewer
23 ${QGLVIEWER_BASE_DIR}
24 )
25
26 IF( QT4_FOUND )
27 FIND_LIBRARY( QGLViewer_LIBRARY_DIR_UBUNTU NAMES qglviewer-qt4 QGLViewer-qt4)
28 ELSE()
29 FIND_LIBRARY( QGLViewer_LIBRARY_DIR_UBUNTU NAMES qglviewer-qt5 QGLViewer-qt5)
30 ENDIF()
31 FIND_LIBRARY( QGLViewer_LIBRARY_DIR_WINDOWS QGLViewer2 ${QGLVIEWER_BASE_DIR})
32 FIND_LIBRARY( QGLViewer_LIBRARY_DIR_OTHER QGLViewer ${QGLVIEWER_BASE_DIR})
33
34 SET( BUILD_LIB_FROM_SOURCE 0)
35
36 IF( QGLViewer_INCLUDE_DIR )
37
38 MESSAGE(STATUS "QGLViewer includes found in ${QGLViewer_INCLUDE_DIR}")
39 IF (QGLViewer_LIBRARY_DIR_UBUNTU)
40 MESSAGE(STATUS "QGLViewer library found in ${QGLViewer_LIBRARY_DIR_UBUNTU}")
41 SET( QGLViewer_LIBRARIES ${QGLViewer_LIBRARY_DIR_UBUNTU})
42 SET( QGLViewer_FOUND 1 CACHE BOOL "Do we have QGLViewer?" FORCE )
43 ELSEIF(QGLViewer_LIBRARY_DIR_WINDOWS)
44 MESSAGE(STATUS "QGLViewer2 found in ${QGLViewer_LIBRARY_DIR_WINDOWS}")
45 SET( QGLViewer_LIBRARIES ${QGLViewer_LIBRARY_DIR_WINDOWS})
46 SET( QGLViewer_FOUND 1 CACHE BOOL "Do we have QGLViewer?" FORCE )
47 ELSEIF(QGLViewer_LIBRARY_DIR_OTHER)
48 MESSAGE(STATUS "QGLViewer found in ${QGLViewer_LIBRARY_DIR_OTHER}")
49 SET( QGLViewer_LIBRARIES ${QGLViewer_LIBRARY_DIR_OTHER})
50 SET( QGLViewer_FOUND 1 CACHE BOOL "Do we have QGLViewer?" FORCE )
51 ELSE()
52 MESSAGE(STATUS "QGLViewer library not found.")
53 SET( BUILD_LIB_FROM_SOURCE 1)
54 SET( QGLViewer_FOUND 0 CACHE BOOL "Do we have QGLViewer?" FORCE )
55 ENDIF()
56
57 ELSE()
58 SET( BUILD_LIB_FROM_SOURCE 1)
59 ENDIF()
60
61 # build own libQGLViewer
62 IF(BUILD_LIB_FROM_SOURCE)
63
64 IF (WIN32)
65 MESSAGE("Cannot generate QGLViewer2 from source automatically.")
66 MESSAGE("Please build libQGLViewer from source, instructions to do so")
67 MESSAGE("can be found in octovis/README.txt")
68 MESSAGE("Please rerun CMAKE when you are ready.")
69
70 ELSE (WIN32)
71 IF(QGLVIEWER_BASE_DIR)
72 MESSAGE(STATUS "Trying to build libQGLViewer from source in ${QGLVIEWER_BASE_DIR}")
73
74 FIND_PROGRAM(QMAKE-QT4 qmake-qt4)
75 IF (QMAKE-QT4)
76 MESSAGE(STATUS "\t generating Makefile using qmake-qt4")
77 EXECUTE_PROCESS(
78 WORKING_DIRECTORY ${QGLVIEWER_BASE_DIR}
79 COMMAND qmake-qt4
80 OUTPUT_QUIET
81 )
82 ELSE(QMAKE-QT4)
83 MESSAGE(STATUS "\t generating Makefile using qmake")
84 EXECUTE_PROCESS(
85 WORKING_DIRECTORY ${QGLVIEWER_BASE_DIR}
86 COMMAND qmake
87 OUTPUT_QUIET
88 )
89 ENDIF(QMAKE-QT4)
90
91 MESSAGE(STATUS "\t building library (this may take some time...)")
92 EXECUTE_PROCESS(
93 WORKING_DIRECTORY ${QGLVIEWER_BASE_DIR}
94 COMMAND make
95 OUTPUT_QUIET
96 )
97 ENDIF(QGLVIEWER_BASE_DIR)
98 ENDIF(WIN32)
99
100 ELSE(BUILD_LIB_FROM_SOURCE)
101 IF (NOT QGLViewer_FOUND)
102 MESSAGE(STATUS "QGLViewer sources NOT found. Exiting.")
103 ENDIF ()
104 ENDIF(BUILD_LIB_FROM_SOURCE)
105
106 # verify that QGLViewer lib was build if we didnt find it elsewhere
107 IF (NOT QGLViewer_FOUND)
108 #FIND_LIBRARY(QGLViewer_LIBRARY_DIR_OTHER QGLViewer ${QGLVIEWER_BASE_DIR})
109 FIND_PATH(QGLLIB libQGLViewer.so ${QGLVIEWER_BASE_DIR})
110 IF (NOT QGLLIB)
111 MESSAGE(WARNING "Could not find libQGLViewer.so, failed to build?")
112 SET( QGLViewer_FOUND 0 CACHE BOOL "Do we have QGLViewer?" FORCE )
113 ELSE()
114 MESSAGE(STATUS "Successfully built library in:\n${QGLLIB}")
115 SET( QGLViewer_INCLUDE_DIR ${QGLVIEWER_BASE_DIR} CACHE PATH "QGLViewer Include directory" FORCE)
116 SET( QGLViewer_LIBRARY_DIR ${QGLVIEWER_BASE_DIR} CACHE PATH "QGLViewer Library directory" FORCE)
117 # TODO: also include "m pthread QGLViewerGen QGLViewerUtility"?
118 SET( QGLViewer_LIBRARIES QGLViewer)
119 SET( QGLViewer_FOUND 1 CACHE BOOL "Do we have QGLViewer?" FORCE )
120 ENDIF()
121 ENDIF()
122
123 # You need to use qmake of QT4. You are using QT3 if you get:
124
125 #CMakeFiles/octovis.dir/ViewerWidget.cpp.o: In function `octomap::ViewerWidget::ViewerWidget(QWidget*)':
126 #ViewerWidget.cpp:(.text+0x1715): undefined reference to `QGLViewer::QGLViewer(QWidget*, QGLWidget const*, QFlags<Qt::WindowType>)'