Skip to content

Commit

Permalink
Do not build QGLViewer using CMake (OctoMap#225)
Browse files Browse the repository at this point in the history
  • Loading branch information
jnumm committed Jan 23, 2020
1 parent cacc362 commit 6219f5a
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 121 deletions.
4 changes: 1 addition & 3 deletions octovis/CMakeLists_src.txt
Original file line number Diff line number Diff line change
Expand Up @@ -57,9 +57,7 @@ else(OCTOVIS_QT5)
QT4_ADD_RESOURCES(viewer_RES src/icons.qrc)
endif(OCTOVIS_QT5)

#found QGLViewer lib dir
link_directories(${QGLViewer_LIBRARY_DIR})

#found QGLViewer include dir
INCLUDE_DIRECTORIES(
${QGLViewer_INCLUDE_DIR}
)
Expand Down
129 changes: 12 additions & 117 deletions octovis/CMakeModules/FindQGLViewer.cmake
Original file line number Diff line number Diff line change
@@ -1,126 +1,21 @@
# Find QGLViewer library
# Looks for a system-wide version of libQGLViewer (qglviewer-qt4 or 5 in Ubuntu).
# If none is found, it builds and uses the local copy in "extern"
#
# Many thanks to L. Ott for assistance!
# Looks for a system-wide version of libQGLViewer.
#
# QGLViewer_INCLUDE_DIR where to find the include files
# QGLViewer_LIBRARY_DIR where to find the libraries
# QGLViewer_LIBRARIES list of libraries to link
# QGLViewer_FOUND true if QGLViewer was found

SET( QGLViewer_FOUND 0 CACHE BOOL "Do we have QGLViewer?" )

FIND_PATH( QGLVIEWER_BASE_DIR qglviewer.h
${CMAKE_SOURCE_DIR}/src/extern/QGLViewer
${CMAKE_SOURCE_DIR}/octovis/src/extern/QGLViewer
)

FIND_PATH( QGLViewer_INCLUDE_DIR qglviewer.h
/usr/include/qglviewer-qt4
/usr/include/QGLViewer
/opt/local/include/QGLViewer
${QGLVIEWER_BASE_DIR}
)

IF( QT4_FOUND )
FIND_LIBRARY( QGLViewer_LIBRARY_DIR_UBUNTU NAMES qglviewer-qt4 QGLViewer-qt4)
ELSE()
FIND_LIBRARY( QGLViewer_LIBRARY_DIR_UBUNTU NAMES qglviewer-qt5 QGLViewer-qt5)
ENDIF()
FIND_LIBRARY( QGLViewer_LIBRARY_DIR_WINDOWS QGLViewer2 ${QGLVIEWER_BASE_DIR})
FIND_LIBRARY( QGLViewer_LIBRARY_DIR_OTHER QGLViewer ${QGLVIEWER_BASE_DIR})

SET( BUILD_LIB_FROM_SOURCE 0)

IF( QGLViewer_INCLUDE_DIR )

MESSAGE(STATUS "QGLViewer includes found in ${QGLViewer_INCLUDE_DIR}")
IF (QGLViewer_LIBRARY_DIR_UBUNTU)
MESSAGE(STATUS "QGLViewer library found in ${QGLViewer_LIBRARY_DIR_UBUNTU}")
SET( QGLViewer_LIBRARIES ${QGLViewer_LIBRARY_DIR_UBUNTU})
SET( QGLViewer_FOUND 1 CACHE BOOL "Do we have QGLViewer?" FORCE )
ELSEIF(QGLViewer_LIBRARY_DIR_WINDOWS)
MESSAGE(STATUS "QGLViewer2 found in ${QGLViewer_LIBRARY_DIR_WINDOWS}")
SET( QGLViewer_LIBRARIES ${QGLViewer_LIBRARY_DIR_WINDOWS})
SET( QGLViewer_FOUND 1 CACHE BOOL "Do we have QGLViewer?" FORCE )
ELSEIF(QGLViewer_LIBRARY_DIR_OTHER)
MESSAGE(STATUS "QGLViewer found in ${QGLViewer_LIBRARY_DIR_OTHER}")
SET( QGLViewer_LIBRARIES ${QGLViewer_LIBRARY_DIR_OTHER})
SET( QGLViewer_FOUND 1 CACHE BOOL "Do we have QGLViewer?" FORCE )
ELSE()
MESSAGE(STATUS "QGLViewer library not found.")
SET( BUILD_LIB_FROM_SOURCE 1)
SET( QGLViewer_FOUND 0 CACHE BOOL "Do we have QGLViewer?" FORCE )
ENDIF()

ELSE()
SET( BUILD_LIB_FROM_SOURCE 1)
ENDIF()

# build own libQGLViewer
IF(BUILD_LIB_FROM_SOURCE)

IF (WIN32)
MESSAGE("Cannot generate QGLViewer2 from source automatically.")
MESSAGE("Please build libQGLViewer from source, instructions to do so")
MESSAGE("can be found in octovis/README.txt")
MESSAGE("Please rerun CMAKE when you are ready.")

ELSE (WIN32)
IF(QGLVIEWER_BASE_DIR)
MESSAGE(STATUS "Trying to build libQGLViewer from source in ${QGLVIEWER_BASE_DIR}")

FIND_PROGRAM(QMAKE-QT4 qmake-qt4)
IF (QMAKE-QT4)
MESSAGE(STATUS "\t generating Makefile using qmake-qt4")
EXECUTE_PROCESS(
WORKING_DIRECTORY ${QGLVIEWER_BASE_DIR}
COMMAND qmake-qt4
OUTPUT_QUIET
)
ELSE(QMAKE-QT4)
MESSAGE(STATUS "\t generating Makefile using qmake")
EXECUTE_PROCESS(
WORKING_DIRECTORY ${QGLVIEWER_BASE_DIR}
COMMAND qmake-qt4
OUTPUT_QUIET
)
ENDIF(QMAKE-QT4)

MESSAGE(STATUS "\t building library (this may take some time...)")
EXECUTE_PROCESS(
WORKING_DIRECTORY ${QGLVIEWER_BASE_DIR}
COMMAND make
OUTPUT_QUIET
)
ENDIF(QGLVIEWER_BASE_DIR)
ENDIF(WIN32)

ELSE(BUILD_LIB_FROM_SOURCE)
IF (NOT QGLViewer_FOUND)
MESSAGE(STATUS "QGLViewer sources NOT found. Exiting.")
ENDIF ()
ENDIF(BUILD_LIB_FROM_SOURCE)
find_path(QGLViewer_INCLUDE_DIR
NAMES qglviewer.h
PATH_SUFFIXES QGLViewer)

# verify that QGLViewer lib was build if we didnt find it elsewhere
IF (NOT QGLViewer_FOUND)
#FIND_LIBRARY(QGLViewer_LIBRARY_DIR_OTHER QGLViewer ${QGLVIEWER_BASE_DIR})
FIND_PATH(QGLLIB libQGLViewer.so ${QGLVIEWER_BASE_DIR})
IF (NOT QGLLIB)
MESSAGE(WARNING "Could not find libQGLViewer.so, failed to build?")
SET( QGLViewer_FOUND 0 CACHE BOOL "Do we have QGLViewer?" FORCE )
ELSE()
MESSAGE(STATUS "Successfully built library in:\n${QGLLIB}")
SET( QGLViewer_INCLUDE_DIR ${QGLVIEWER_BASE_DIR} CACHE PATH "QGLViewer Include directory" FORCE)
SET( QGLViewer_LIBRARY_DIR ${QGLVIEWER_BASE_DIR} CACHE PATH "QGLViewer Library directory" FORCE)
# TODO: also include "m pthread QGLViewerGen QGLViewerUtility"?
SET( QGLViewer_LIBRARIES QGLViewer)
SET( QGLViewer_FOUND 1 CACHE BOOL "Do we have QGLViewer?" FORCE )
ENDIF()
ENDIF()
find_library(QGLViewer_LIBRARIES
NAMES QGLViewer QGLViewer2 QGLViewer-qt5 QGLViewer-qt4)

# You need to use qmake of QT4. You are using QT3 if you get:
include(FindPackageHandleStandardArgs)
find_package_handle_standard_args(
QGLViewer
DEFAULT_MSG
QGLViewer_LIBRARIES QGLViewer_INCLUDE_DIR)

#CMakeFiles/octovis.dir/ViewerWidget.cpp.o: In function `octomap::ViewerWidget::ViewerWidget(QWidget*)':
#ViewerWidget.cpp:(.text+0x1715): undefined reference to `QGLViewer::QGLViewer(QWidget*, QGLWidget const*, QFlags<Qt::WindowType>)'
mark_as_advanced(QGLViewer_INCLUDE_DIR QGLViewer_LIBRARIES)
2 changes: 1 addition & 1 deletion octovis/octovis-config.cmake.in
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ set(OCTOVIS_PATCH_VERSION "@OCTOVIS_PATCH_VERSION@")
set(OCTOVIS_VERSION "@OCTOVIS_VERSION@")

set_and_check(OCTOVIS_INCLUDE_DIRS "@PACKAGE_OCTOVIS_INCLUDE_DIRS@" "@QGLViewer_INCLUDE_DIR@")
set_and_check(OCTOVIS_LIBRARY_DIRS "@PACKAGE_OCTOVIS_LIB_DIR@" "@QGLViewer_LIBRARY_DIR@")
set_and_check(OCTOVIS_LIBRARY_DIRS "@PACKAGE_OCTOVIS_LIB_DIR@")

# Set library names as absolute paths:
set(OCTOVIS_LIBRARIES
Expand Down

0 comments on commit 6219f5a

Please sign in to comment.