From e5227fdb75074616d8c326706b729c9316b33360 Mon Sep 17 00:00:00 2001 From: Chris Lalancette Date: Sun, 17 Mar 2024 17:40:43 -0400 Subject: [PATCH] Updates to compile cleanly on ROS 2 Rolling on Ubuntu 24.04 (#415) * Update minimum to CMake 3.5. Newer CMake complains about anything older than that, and CMake 3.5 was released in 2016. Signed-off-by: Chris Lalancette * Cleanup stderr output from CMake. Calling message("mystring") in CMake, by default, outputs to stderr. Since these are generally informational messages, change this to message(STATUS "mystring"), which prints to stdout instead. This should quite down warnings when building with colcon (and on the ROS 2 buildfarm). Signed-off-by: Chris Lalancette * Add in a variable to control how OpenGL is found. Newer versions of CMake have changed how finding OpenGL works. If you don't specify anything at all, they will complain that you haven't told them how to find OpenGL. Work around this by explicitly setting OpenGL_GL_PREFERENCE to LEGACY, which tells CMake how you want to find OpenGL. This quiets the warning. Signed-off-by: Chris Lalancette * Switch away from 0 for Qt::WindowFlags. Apparently modern Qt has deprecated using an integer to initialize Qt::Flags objects. Instead, use the default constructor which should do the same thing. Signed-off-by: Chris Lalancette --------- Signed-off-by: Chris Lalancette --- dynamicEDT3D/CMakeLists.txt | 4 ++-- dynamicEDT3D/CMakeModules/CompilerSettings.cmake | 6 +++--- octomap/CMakeLists.txt | 4 ++-- octomap/CMakeModules/CompilerSettings.cmake | 2 +- octovis/CMakeLists.txt | 3 ++- octovis/CMakeModules/CompilerSettings.cmake | 4 ++-- octovis/src/extern/QGLViewer/qglviewer.h | 6 +++--- 7 files changed, 15 insertions(+), 14 deletions(-) diff --git a/dynamicEDT3D/CMakeLists.txt b/dynamicEDT3D/CMakeLists.txt index 0f899e4c..834a1d09 100644 --- a/dynamicEDT3D/CMakeLists.txt +++ b/dynamicEDT3D/CMakeLists.txt @@ -1,4 +1,4 @@ -CMAKE_MINIMUM_REQUIRED(VERSION 3.0.2) +CMAKE_MINIMUM_REQUIRED(VERSION 3.5) PROJECT(dynamicEDT3D) include(CTest) @@ -170,7 +170,7 @@ ENDIF(DOXYGEN_FOUND) INCLUDE(CPackSettings) # Finished: -MESSAGE ("\n") +MESSAGE (STATUS "\n") MESSAGE (STATUS "Compile dynamicEDT3D using: make") MESSAGE (STATUS "Install dynamicEDT3D using: make install") MESSAGE (STATUS " (be sure to set the correct CMAKE_INSTALL_PREFIX before)") diff --git a/dynamicEDT3D/CMakeModules/CompilerSettings.cmake b/dynamicEDT3D/CMakeModules/CompilerSettings.cmake index 51f1ebee..e2e6b4f5 100644 --- a/dynamicEDT3D/CMakeModules/CompilerSettings.cmake +++ b/dynamicEDT3D/CMakeModules/CompilerSettings.cmake @@ -4,13 +4,13 @@ IF(NOT CMAKE_CONFIGURATION_TYPES AND NOT CMAKE_BUILD_TYPE) SET(CMAKE_BUILD_TYPE Release) ENDIF(NOT CMAKE_CONFIGURATION_TYPES AND NOT CMAKE_BUILD_TYPE) -MESSAGE ("\n") +MESSAGE (STATUS "\n") MESSAGE (STATUS "${PROJECT_NAME} building as ${CMAKE_BUILD_TYPE}") # OCTOMAP_OMP = enable OpenMP # SET(OCTOMAP_OMP 1 CACHE BOOL "Enable/disable OpenMP") # IF($ENV{OCTOMAP_OMP}) -# SET(OCTOMAP_OMP $ENV{OCTOMAP_OMP}) +# SET(OCTOMAP_OMP $ENV{OCTOMAP_OMP}) # MESSAGE(STATUS "Found OCTOMAP_OMP=${OCTOMAP_OMP}") # ENDIF($ENV{OCTOMAP_OMP}) @@ -21,7 +21,7 @@ IF (CMAKE_COMPILER_IS_GNUCC) SET (CMAKE_CXX_FLAGS_RELEASE "-O3 -funroll-loops -DNDEBUG") SET (CMAKE_CXX_FLAGS_DEBUG "-O0 -g") # Shared object compilation under 64bit (vtable) - ADD_DEFINITIONS(-fPIC) + ADD_DEFINITIONS(-fPIC) # IF(OCTOMAP_OMP) # SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -fopenmp") # SET(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS} -fopenmp") diff --git a/octomap/CMakeLists.txt b/octomap/CMakeLists.txt index 12cb1f33..fc3bd6e7 100644 --- a/octomap/CMakeLists.txt +++ b/octomap/CMakeLists.txt @@ -1,4 +1,4 @@ -CMAKE_MINIMUM_REQUIRED(VERSION 3.0.2) +CMAKE_MINIMUM_REQUIRED(VERSION 3.5) PROJECT( octomap ) include(CTest) @@ -173,7 +173,7 @@ ENDIF(DOXYGEN_FOUND) INCLUDE(CPackSettings) # Finished: -MESSAGE ("\n") +MESSAGE (STATUS "\n") MESSAGE (STATUS "Compile octomap using: make") MESSAGE (STATUS "Install octomap using: make install") MESSAGE (STATUS " (be sure to set the correct CMAKE_INSTALL_PREFIX before)") diff --git a/octomap/CMakeModules/CompilerSettings.cmake b/octomap/CMakeModules/CompilerSettings.cmake index f4bab3e9..bae0cc48 100644 --- a/octomap/CMakeModules/CompilerSettings.cmake +++ b/octomap/CMakeModules/CompilerSettings.cmake @@ -4,7 +4,7 @@ IF(NOT CMAKE_CONFIGURATION_TYPES AND NOT CMAKE_BUILD_TYPE) SET(CMAKE_BUILD_TYPE Release) ENDIF(NOT CMAKE_CONFIGURATION_TYPES AND NOT CMAKE_BUILD_TYPE) -MESSAGE ("\n") +MESSAGE (STATUS "\n") MESSAGE (STATUS "${PROJECT_NAME} building as ${CMAKE_BUILD_TYPE}") # COMPILER FLAGS diff --git a/octovis/CMakeLists.txt b/octovis/CMakeLists.txt index e1e4f52a..892e29fa 100644 --- a/octovis/CMakeLists.txt +++ b/octovis/CMakeLists.txt @@ -1,4 +1,4 @@ -CMAKE_MINIMUM_REQUIRED(VERSION 3.0.2) +CMAKE_MINIMUM_REQUIRED(VERSION 3.5) PROJECT( octovis ) include(CTest) @@ -68,6 +68,7 @@ SET( BUILD_VIEWER 0) option(OCTOVIS_QT5 "Link Octovis against Qt5?" ON) # Look for required libraries: +set(OpenGL_GL_PREFERENCE LEGACY) FIND_PACKAGE(OpenGL) if(NOT OCTOVIS_QT5) FIND_PACKAGE(Qt4) diff --git a/octovis/CMakeModules/CompilerSettings.cmake b/octovis/CMakeModules/CompilerSettings.cmake index 759902f9..51f689b0 100644 --- a/octovis/CMakeModules/CompilerSettings.cmake +++ b/octovis/CMakeModules/CompilerSettings.cmake @@ -4,13 +4,13 @@ IF(NOT CMAKE_CONFIGURATION_TYPES AND NOT CMAKE_BUILD_TYPE) SET(CMAKE_BUILD_TYPE Release) ENDIF(NOT CMAKE_CONFIGURATION_TYPES AND NOT CMAKE_BUILD_TYPE) -MESSAGE ("\n") +MESSAGE (STATUS "\n") MESSAGE (STATUS "${PROJECT_NAME} building as ${CMAKE_BUILD_TYPE}") # OCTOMAP_OMP = enable OpenMP # SET(OCTOMAP_OMP 1 CACHE BOOL "Enable/disable OpenMP") # IF($ENV{OCTOMAP_OMP}) -# SET(OCTOMAP_OMP $ENV{OCTOMAP_OMP}) +# SET(OCTOMAP_OMP $ENV{OCTOMAP_OMP}) # MESSAGE(STATUS "Found OCTOMAP_OMP=${OCTOMAP_OMP}") # ENDIF($ENV{OCTOMAP_OMP}) diff --git a/octovis/src/extern/QGLViewer/qglviewer.h b/octovis/src/extern/QGLViewer/qglviewer.h index 561a1ea7..586ac457 100644 --- a/octovis/src/extern/QGLViewer/qglviewer.h +++ b/octovis/src/extern/QGLViewer/qglviewer.h @@ -81,9 +81,9 @@ class QGLVIEWER_EXPORT QGLViewer : public QGLWidget #else - explicit QGLViewer(QWidget* parent=0, const QGLWidget* shareWidget=0, Qt::WindowFlags flags=0); - explicit QGLViewer(QGLContext *context, QWidget* parent=0, const QGLWidget* shareWidget=0, Qt::WindowFlags flags=0); - explicit QGLViewer(const QGLFormat& format, QWidget* parent=0, const QGLWidget* shareWidget=0, Qt::WindowFlags flags=0); + explicit QGLViewer(QWidget* parent=0, const QGLWidget* shareWidget=0, Qt::WindowFlags flags=Qt::WindowFlags()); + explicit QGLViewer(QGLContext *context, QWidget* parent=0, const QGLWidget* shareWidget=0, Qt::WindowFlags flags=Qt::WindowFlags()); + explicit QGLViewer(const QGLFormat& format, QWidget* parent=0, const QGLWidget* shareWidget=0, Qt::WindowFlags flags=Qt::WindowFlags()); #endif virtual ~QGLViewer();