Skip to content

Commit 4170b1c

Browse files
Merge branch 'master' into pymem
2 parents c268585 + 37d8e5f commit 4170b1c

8 files changed

Lines changed: 173 additions & 97 deletions

File tree

.github/workflows/ci.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ jobs:
5050

5151

5252
steps:
53-
- uses: actions/checkout@v5
53+
- uses: actions/checkout@v6
5454
with:
5555
fetch-depth: 25
5656

@@ -112,6 +112,6 @@ jobs:
112112

113113
- name: Coverage Results
114114
if: matrix.config.do_coverage == 'ON'
115-
uses: codecov/codecov-action@v5.5.1
115+
uses: codecov/codecov-action@v5.5.2
116116
env:
117117
CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }}

.github/workflows/release.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ jobs:
1616
runs-on: ubuntu-latest
1717

1818
steps:
19-
- uses: actions/checkout@v5
19+
- uses: actions/checkout@v6
2020
with:
2121
fetch-depth: 25
2222

.github/workflows/windows.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ jobs:
2929
}
3030

3131
steps:
32-
- uses: actions/checkout@v5
32+
- uses: actions/checkout@v6
3333
with:
3434
fetch-depth: 25
3535

cmake_modules/FindQGLViewer.cmake

Lines changed: 145 additions & 45 deletions
Original file line numberDiff line numberDiff line change
@@ -1,51 +1,151 @@
1-
find_package(Qt5 COMPONENTS Core Xml OpenGL Gui Widgets QUIET)
2-
if(NOT Qt5_FOUND)
3-
message("Qt5 not found. Install it and set Qt5_DIR accordingly")
4-
if (WIN32)
5-
message(" In Windows, Qt5_DIR should be something like C:/Qt/5.4/msvc2013_64_opengl/lib/cmake/Qt5")
6-
endif()
7-
return()
1+
# Find QGLViewer: a C++ OpenGL widget for Qt
2+
# This module defines the following variables:
3+
# QGLVIEWER_FOUND - True if QGLViewer library is found
4+
# QGLVIEWER_INCLUDE_DIR - Include directories for QGLViewer
5+
# QGLVIEWER_LIBRARY - QGLViewer library
6+
# QGLVIEWER_VERSION - Version of QGLViewer if available
7+
8+
# Try pkg-config first (if available)
9+
find_package(PkgConfig QUIET)
10+
if(PkgConfig_FOUND)
11+
pkg_check_modules(QGLVIEWER QUIET QGLViewer)
812
endif()
913

10-
find_path(QGLVIEWER_INCLUDE_DIR qglviewer.h
11-
/usr/include/QGLViewer
12-
/opt/local/include/QGLViewer
13-
/usr/local/include/QGLViewer
14-
/sw/include/QGLViewer
15-
ENV QGLVIEWERROOT
14+
# If pkg-config didn't find it, search manually
15+
if(NOT QGLVIEWER_FOUND)
16+
# Try to find Qt5 (optional - QGLViewer may not be needed)
17+
find_package(Qt5 COMPONENTS Core Xml OpenGL Gui Widgets QUIET)
18+
if(NOT Qt5_FOUND)
19+
if(QGLViewer_FIND_REQUIRED)
20+
message(SEND_ERROR "Qt5 not found. Install it and set Qt5_DIR accordingly")
21+
if(WIN32)
22+
message(STATUS " In Windows, Qt5_DIR should be something like C:/Qt/5.4/msvc2013_64_opengl/lib/cmake/Qt5")
23+
endif()
24+
return()
25+
else()
26+
message(STATUS "Qt5 not found. QGLViewer support will be disabled (this is optional)")
27+
return()
28+
endif()
29+
endif()
30+
31+
# Find include directory
32+
find_path(QGLVIEWER_INCLUDE_DIR qglviewer.h
33+
HINTS ${QGLVIEWER_INCLUDE_DIRS}
34+
PATHS /usr/include/QGLViewer
35+
/opt/local/include/QGLViewer
36+
/usr/local/include/QGLViewer
37+
/sw/include/QGLViewer
38+
$ENV{QGLVIEWERROOT}/include
39+
$ENV{QGLVIEWERROOT}
40+
DOC "QGLViewer include directory"
41+
)
42+
43+
# Find release library
44+
find_library(QGLVIEWER_LIBRARY_RELEASE
45+
NAMES qglviewer QGLViewer qglviewer-qt5 QGLViewer-qt5
46+
HINTS ${QGLVIEWER_LIBRARY_DIRS}
47+
PATHS /usr/lib
48+
/usr/local/lib
49+
/opt/local/lib
50+
/sw/lib
51+
$ENV{QGLVIEWERROOT}/lib
52+
$ENV{QGLVIEWERROOT}/lib64
53+
$ENV{QGLVIEWERROOT}/lib/x64
54+
$ENV{QGLVIEWERROOT}/lib/win32
55+
PATH_SUFFIXES QGLViewer QGLViewer/release x64/Release Win32/Release
56+
DOC "QGLViewer release library"
57+
)
58+
59+
# Find debug library
60+
find_library(QGLVIEWER_LIBRARY_DEBUG
61+
NAMES dqglviewer dQGLViewer dqglviewer-qt5 dQGLViewer-qt5 QGLViewerd2
62+
HINTS ${QGLVIEWER_LIBRARY_DIRS}
63+
PATHS /usr/lib
64+
/usr/local/lib
65+
/opt/local/lib
66+
/sw/lib
67+
$ENV{QGLVIEWERROOT}/lib
68+
$ENV{QGLVIEWERROOT}/lib64
69+
$ENV{QGLVIEWERROOT}/lib/x64
70+
$ENV{QGLVIEWERROOT}/lib/win32
71+
PATH_SUFFIXES QGLViewer QGLViewer/debug x64/Debug Win32/Debug
72+
DOC "QGLViewer debug library"
1673
)
1774

18-
find_library(QGLVIEWER_LIBRARY_RELEASE
19-
NAMES qglviewer QGLViewer qglviewer-qt5 QGLViewer-qt5
20-
PATHS /usr/lib
21-
/usr/local/lib
22-
/opt/local/lib
23-
/sw/lib
24-
ENV QGLVIEWERROOT
25-
ENV LD_LIBRARY_PATH
26-
ENV LIBRARY_PATH
27-
PATH_SUFFIXES QGLViewer QGLViewer/release
28-
)
29-
find_library(QGLVIEWER_LIBRARY_DEBUG
30-
NAMES dqglviewer dQGLViewer dqglviewer-qt5 dQGLViewer-qt5 QGLViewerd2
31-
PATHS /usr/lib
32-
/usr/local/lib
33-
/opt/local/lib
34-
/sw/lib
35-
ENV QGLVIEWERROOT
36-
ENV LD_LIBRARY_PATH
37-
ENV LIBRARY_PATH
38-
PATH_SUFFIXES QGLViewer QGLViewer/debug
39-
)
40-
41-
if(QGLVIEWER_LIBRARY_RELEASE)
42-
if(QGLVIEWER_LIBRARY_DEBUG)
43-
set(QGLVIEWER_LIBRARY optimized ${QGLVIEWER_LIBRARY_RELEASE} debug ${QGLVIEWER_LIBRARY_DEBUG})
44-
else()
45-
set(QGLVIEWER_LIBRARY ${QGLVIEWER_LIBRARY_RELEASE})
75+
# Handle debug/release library selection
76+
if(QGLVIEWER_LIBRARY_RELEASE)
77+
if(QGLVIEWER_LIBRARY_DEBUG)
78+
set(QGLVIEWER_LIBRARY optimized ${QGLVIEWER_LIBRARY_RELEASE} debug ${QGLVIEWER_LIBRARY_DEBUG})
79+
else()
80+
set(QGLVIEWER_LIBRARY ${QGLVIEWER_LIBRARY_RELEASE})
81+
endif()
4682
endif()
47-
endif()
4883

49-
include(FindPackageHandleStandardArgs)
50-
find_package_handle_standard_args(QGLViewer DEFAULT_MSG
51-
QGLVIEWER_INCLUDE_DIR QGLVIEWER_LIBRARY)
84+
# Try to extract version from header and convert to semantic version
85+
if(QGLVIEWER_INCLUDE_DIR AND EXISTS "${QGLVIEWER_INCLUDE_DIR}/config.h")
86+
file(STRINGS "${QGLVIEWER_INCLUDE_DIR}/config.h" QGLVIEWER_VERSION_LINE
87+
REGEX "^#define QGLVIEWER_VERSION.*")
88+
if(QGLVIEWER_VERSION_LINE)
89+
# Extract hex value (format: 0xMMmmPP where MM=major, mm=minor, PP=patch)
90+
string(REGEX MATCH "0x[0-9a-fA-F]+" QGLVIEWER_VERSION_HEX "${QGLVIEWER_VERSION_LINE}")
91+
if(QGLVIEWER_VERSION_HEX)
92+
# Remove 0x prefix and extract 6-digit hex string
93+
string(SUBSTRING "${QGLVIEWER_VERSION_HEX}" 2 6 QGLVIEWER_VERSION_HEX_DIGITS)
94+
95+
# Extract major (bits 16-23, first 2 hex digits)
96+
string(SUBSTRING "${QGLVIEWER_VERSION_HEX_DIGITS}" 0 2 QGLVIEWER_VERSION_MAJOR_HEX)
97+
# Extract minor (bits 8-15, middle 2 hex digits)
98+
string(SUBSTRING "${QGLVIEWER_VERSION_HEX_DIGITS}" 2 2 QGLVIEWER_VERSION_MINOR_HEX)
99+
# Extract patch (bits 0-7, last 2 hex digits)
100+
string(SUBSTRING "${QGLVIEWER_VERSION_HEX_DIGITS}" 4 2 QGLVIEWER_VERSION_PATCH_HEX)
101+
102+
# Convert hex to decimal
103+
math(EXPR QGLVIEWER_VERSION_MAJOR "0x${QGLVIEWER_VERSION_MAJOR_HEX}")
104+
math(EXPR QGLVIEWER_VERSION_MINOR "0x${QGLVIEWER_VERSION_MINOR_HEX}")
105+
math(EXPR QGLVIEWER_VERSION_PATCH "0x${QGLVIEWER_VERSION_PATCH_HEX}")
106+
107+
# Assemble semantic version string
108+
set(QGLVIEWER_VERSION "${QGLVIEWER_VERSION_MAJOR}.${QGLVIEWER_VERSION_MINOR}.${QGLVIEWER_VERSION_PATCH}")
109+
endif()
110+
endif()
111+
endif()
112+
113+
# Standard find_package handling
114+
include(FindPackageHandleStandardArgs)
115+
find_package_handle_standard_args(QGLViewer
116+
REQUIRED_VARS QGLVIEWER_INCLUDE_DIR QGLVIEWER_LIBRARY
117+
VERSION_VAR QGLVIEWER_VERSION)
118+
119+
# Create modern CMake interface target
120+
if(QGLVIEWER_FOUND AND NOT TARGET QGLViewer::QGLViewer)
121+
add_library(QGLViewer::QGLViewer UNKNOWN IMPORTED)
122+
set_target_properties(QGLViewer::QGLViewer PROPERTIES
123+
IMPORTED_LOCATION "${QGLVIEWER_LIBRARY}"
124+
INTERFACE_INCLUDE_DIRECTORIES "${QGLVIEWER_INCLUDE_DIR}"
125+
INTERFACE_LINK_LIBRARIES "Qt5::Core;Qt5::Xml;Qt5::OpenGL;Qt5::Gui;Qt5::Widgets"
126+
)
127+
if(QGLVIEWER_LIBRARY_DEBUG)
128+
set_target_properties(QGLViewer::QGLViewer PROPERTIES
129+
IMPORTED_LOCATION_DEBUG "${QGLVIEWER_LIBRARY_DEBUG}"
130+
)
131+
endif()
132+
endif()
133+
134+
mark_as_advanced(
135+
QGLVIEWER_INCLUDE_DIR
136+
QGLVIEWER_LIBRARY
137+
QGLVIEWER_LIBRARY_RELEASE
138+
QGLVIEWER_LIBRARY_DEBUG
139+
QGLVIEWER_VERSION_HEX
140+
QGLVIEWER_VERSION_HEX_DIGITS
141+
QGLVIEWER_VERSION_MAJOR_HEX
142+
QGLVIEWER_VERSION_MINOR_HEX
143+
QGLVIEWER_VERSION_PATCH_HEX
144+
QGLVIEWER_VERSION_MAJOR
145+
QGLVIEWER_VERSION_MINOR
146+
QGLVIEWER_VERSION_PATCH
147+
QGLVIEWER_VERSION_LINE
148+
QGLVIEWER_INCLUDE_DIRS
149+
QGLVIEWER_LIBRARY_DIRS
150+
)
151+
endif()

g2o/apps/g2o_viewer/CMakeLists.txt

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2,13 +2,8 @@
22
if(Qt5_FOUND)
33
QT5_WRAP_UI(UI_HEADERS base_main_window.ui base_properties_widget.ui)
44
QT5_WRAP_CPP(UI_SOURCES main_window.h abstract_properties_widget.h)
5-
6-
include_directories(${Qt5Core_INCLUDE_DIRS} ${Qt5Xml_INCLUDE_DIRS} ${Qt5Gui_INCLUDE_DIRS} ${Qt5Widgets_INCLUDE_DIRS} ${Qt5OpenGL_INCLUDE_DIRS})
7-
string(APPEND qt5_includes_dirs "${Qt5Core_INCLUDE_DIRS} ${Qt5Xml_INCLUDE_DIRS} ${Qt5Gui_INCLUDE_DIRS} ${Qt5Widgets_INCLUDE_DIRS} ${Qt5OpenGL_INCLUDE_DIRS}")
8-
set(MY_QT_LIBRARIES ${Qt5Widgets_LIBRARIES} ${Qt5Core_LIBRARIES} ${Qt5Gui_LIBRARIES} ${Qt5Xml_LIBRARIES} ${Qt5OpenGL_LIBRARIES})
95
endif()
106

11-
include_directories(SYSTEM ${QGLVIEWER_INCLUDE_DIR})
127
include_directories(${CMAKE_CURRENT_SOURCE_DIR} ${CMAKE_CURRENT_BINARY_DIR})
138

149
add_library(viewer_library ${G2O_LIB_TYPE}
@@ -37,7 +32,7 @@ add_executable(g2o_viewer
3732

3833
set_target_properties(g2o_viewer PROPERTIES OUTPUT_NAME g2o_viewer)
3934

40-
target_link_libraries(viewer_library PUBLIC core g2o_cli_library ${QGLVIEWER_LIBRARY} ${MY_QT_LIBRARIES} ${OPENGL_LIBRARY})
35+
target_link_libraries(viewer_library PUBLIC core g2o_cli_library QGLViewer::QGLViewer)
4136
target_link_libraries(viewer_library PUBLIC opengl_helper)
4237
target_link_libraries(viewer_library PRIVATE CLI11::CLI11)
4338
target_link_libraries(g2o_viewer viewer_library)

g2o/apps/g2o_viewer/g2o_qglviewer.cpp

Lines changed: 11 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -22,21 +22,17 @@
2222

2323
#include "g2o/core/hyper_graph_action.h"
2424
#include "g2o/core/sparse_optimizer.h"
25+
#include "g2o/stuff/opengl_primitives.h"
2526

26-
// some macro helpers for identifying the version number of QGLViewer
27-
// QGLViewer changed some parts of its API in version 2.6.
28-
// The following preprocessor hack accounts for this. THIS SUCKS!!!
29-
#if (((QGLVIEWER_VERSION & 0xff0000) >> 16) >= 2 && \
30-
((QGLVIEWER_VERSION & 0x00ff00) >> 8) >= 6)
31-
#define qglv_real qreal
32-
#else
33-
#define qglv_real float
34-
#endif
27+
// Version comparison macro for QGLViewer
28+
// QGLVIEWER_VERSION format: 0xMMmmPP where MM=major, mm=minor, PP=patch
29+
#define QGLVIEWER_VERSION_AT_LEAST(major, minor) \
30+
((((QGLVIEWER_VERSION & 0xff0000) >> 16) > (major)) || \
31+
(((QGLVIEWER_VERSION & 0xff0000) >> 16) == (major) && \
32+
((QGLVIEWER_VERSION & 0x00ff00) >> 8) >= (minor)))
3533

36-
// Again, some API changes in QGLViewer which produce annoying text in the
37-
// console if the old API is used.
38-
#if (((QGLVIEWER_VERSION & 0xff0000) >> 16) >= 2 && \
39-
((QGLVIEWER_VERSION & 0x00ff00) >> 8) >= 5)
34+
// API changes in QGLViewer which produce a warning if the old API is used.
35+
#if QGLVIEWER_VERSION_AT_LEAST(2, 5)
4036
#define QGLVIEWER_DEPRECATED_MOUSEBINDING
4137
#endif
4238

@@ -68,6 +64,8 @@ class StandardCamera : public qglviewer::Camera {
6864
public:
6965
StandardCamera() = default;
7066

67+
using qglv_real = decltype(qglviewer::Camera().zNear());
68+
7169
qglv_real zNear() const override {
7270
if (standard_) return qglv_real(0.001);
7371
return Camera::zNear();

g2o/examples/slam2d/CMakeLists.txt

Lines changed: 1 addition & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,3 @@
1-
# qt components used (also by qglviewer): Core Gui Xml OpenGL Widgets
2-
include_directories(SYSTEM
3-
${QGLVIEWER_INCLUDE_DIR}
4-
${Qt5Core_INCLUDE_DIRS}
5-
${Qt5Gui_INCLUDE_DIRS}
6-
${Qt5Xml_INCLUDE_DIRS}
7-
${Qt5Widgets_INCLUDE_DIRS}
8-
${Qt5OpenGL_INCLUDE_DIRS}
9-
)
101
include_directories(${CMAKE_BINARY_DIR} ${CMAKE_CURRENT_BINARY_DIR} ${CMAKE_CURRENT_SOURCE_DIR})
112

123
QT5_WRAP_UI(UI_HEADERS base_main_window.ui)
@@ -32,10 +23,5 @@ if(Qt5_POSITION_INDEPENDENT_CODE)
3223
endif()
3324

3425
target_link_libraries(slam2d_g2o core solver_eigen types_slam2d opengl_helper
35-
${QGLVIEWER_LIBRARY}
36-
${Qt5Core_LIBRARIES}
37-
${Qt5Gui_LIBRARIES}
38-
${Qt5Xml_LIBRARIES}
39-
${Qt5Widgets_LIBRARIES}
40-
${Qt5OpenGL_LIBRARIES}
26+
QGLViewer::QGLViewer
4127
)

g2o/examples/slam2d/slam2d_viewer.cpp

Lines changed: 11 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -26,20 +26,15 @@
2626
#include "g2o/types/slam2d/vertex_point_xy.h"
2727
#include "g2o/types/slam2d/vertex_se2.h"
2828

29-
// some macro helpers for identifying the version number of QGLViewer
30-
// QGLViewer changed some parts of its API in version 2.6.
31-
// The following preprocessor hack accounts for this. THIS SUCKS!!!
32-
#if (((QGLVIEWER_VERSION & 0xff0000) >> 16) >= 2 && \
33-
((QGLVIEWER_VERSION & 0x00ff00) >> 8) >= 6)
34-
#define qglv_real qreal
35-
#else
36-
#define qglv_real float
37-
#endif
38-
39-
// Again, some API changes in QGLViewer which produce annoying text in the
40-
// console if the old API is used.
41-
#if (((QGLVIEWER_VERSION & 0xff0000) >> 16) >= 2 && \
42-
((QGLVIEWER_VERSION & 0x00ff00) >> 8) >= 5)
29+
// Version comparison macro for QGLViewer
30+
// QGLVIEWER_VERSION format: 0xMMmmPP where MM=major, mm=minor, PP=patch
31+
#define QGLVIEWER_VERSION_AT_LEAST(major, minor) \
32+
((((QGLVIEWER_VERSION & 0xff0000) >> 16) > (major)) || \
33+
(((QGLVIEWER_VERSION & 0xff0000) >> 16) == (major) && \
34+
((QGLVIEWER_VERSION & 0x00ff00) >> 8) >= (minor)))
35+
36+
// API changes in QGLViewer which produce a warning if the old API is used.
37+
#if QGLVIEWER_VERSION_AT_LEAST(2, 5)
4338
#define QGLVIEWER_DEPRECATED_MOUSEBINDING
4439
#endif
4540

@@ -54,6 +49,8 @@ class StandardCamera : public qglviewer::Camera {
5449
public:
5550
StandardCamera() = default;
5651

52+
using qglv_real = decltype(qglviewer::Camera().zNear());
53+
5754
qglv_real zNear() const override {
5855
if (standard_) return 0.001F;
5956
return Camera::zNear();

0 commit comments

Comments
 (0)