Skip to content

Commit

Permalink
Merge pull request #1 from naturerobots/humble-dev
Browse files Browse the repository at this point in the history
fix lvr2 for ROS humble and ubuntu 22
  • Loading branch information
amock authored Jan 18, 2024
2 parents a26993f + b3fcd2d commit 0f46c0b
Show file tree
Hide file tree
Showing 4 changed files with 131 additions and 104 deletions.
197 changes: 111 additions & 86 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,21 @@ project(LAS_VEGAS VERSION 2)

# OPTIONS
option(BUILD_EXAMPLES "Build the examples" OFF)
option(BUILD_VIEWER "Build lvr2_viewer" OFF)
option(BUILD_TOOLS "Build tools including lvr2_reconstruct" ON)
option(BUILD_TOOLS_EXPERIMENTAL "Build experimental tools" OFF)
option(WITH_DRACO "Build libraries with draco enabled" OFF)

set_property(GLOBAL PROPERTY USE_FOLDERS On)
set_property(GLOBAL PROPERTY FIND_LIBRARY_USE_LIB64_PATHS ON)


set(CMAKE_EXPORT_COMPILE_COMMANDS ON)

include(GNUInstallDirs)



set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/bin)
set(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/lib)
set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/lib)
Expand Down Expand Up @@ -158,58 +165,70 @@ endif()
#------------------------------------------------------------------------------
# Searching for Draco
#------------------------------------------------------------------------------
if(WITH_DRACO)
find_package(Draco)
if(draco_FOUND)
message(STATUS "Found Draco")
include_directories(${draco_INCLUDE_DIRS})
list(APPEND LVR2_DEFINITIONS -DLVR2_USE_DRACO)
endif(draco_FOUND)
else(WITH_DRACO)
set(draco_FOUND False)
endif(WITH_DRACO)

#------------------------------------------------------------------------------
# Searching for VTK
#------------------------------------------------------------------------------
set(VTK_QT_VERSION 5)
find_package(VTK REQUIRED)
if(BUILD_VIEWER)
#------
# Here I assume VTK is only required for the lvr2_viewer
# - VTK doesnt occur in the core library
#------

if(DEFINED VTK_MAJOR_VERSION AND VTK_MAJOR_VERSION VERSION_EQUAL "8")
# patched QVTKOpenGL header because of name clash with signals.
add_subdirectory(ext/QVTKOpenGLWidget)
include_directories(BEFORE ${QVTK_PATCHED_INCLUDE_DIR} )
list(APPEND LVR2_INSTALL_INCLUDE_DIRS ${QVTK_PATCHED_INCLUDE_DIR})
set(VTK_QT_VERSION 5)
find_package(VTK REQUIRED)

list(APPEND LVR2_DEFINITIONS -DLVR2_USE_VTK8)
endif()
if(DEFINED VTK_MAJOR_VERSION AND VTK_MAJOR_VERSION VERSION_EQUAL "8")
# patched QVTKOpenGL header because of name clash with signals.
add_subdirectory(ext/QVTKOpenGLWidget)
include_directories(BEFORE ${QVTK_PATCHED_INCLUDE_DIR} )
list(APPEND LVR2_INSTALL_INCLUDE_DIRS ${QVTK_PATCHED_INCLUDE_DIR})

if(DEFINED VTK_MAJOR_VERSION AND VTK_MAJOR_VERSION VERSION_LESS "6")
list(APPEND LVR2_DEFINITIONS -DLVR2_USE_VTK5)
endif()
list(APPEND LVR2_DEFINITIONS -DLVR2_USE_VTK8)
endif()

if(VTK_MAJOR_VERSION VERSION_EQUAL "7")
if(VTK_MINOR_VERSION VERSION_GREATER "0")
list(APPEND LVR2_DEFINITIONS -DLVR2_USE_VTK_GE_7_1)
endif()
endif()
if(DEFINED VTK_MAJOR_VERSION AND VTK_MAJOR_VERSION VERSION_LESS "6")
list(APPEND LVR2_DEFINITIONS -DLVR2_USE_VTK5)
endif()

if(VTK_MAJOR_VERSION VERSION_GREATER "7")
list(APPEND LVR2_DEFINITIONS -DLVR2_USE_VTK_GE_7_1)
endif()
if(VTK_MAJOR_VERSION VERSION_EQUAL "7")
if(VTK_MINOR_VERSION VERSION_GREATER "0")
list(APPEND LVR2_DEFINITIONS -DLVR2_USE_VTK_GE_7_1)
endif()
endif()

if(VTK_VERSION VERSION_GREATER "7")
if(VTK_MAJOR_VERSION VERSION_GREATER "7")
list(APPEND LVR2_DEFINITIONS -DLVR2_USE_VTK_GE_7_1)
endif()

list(APPEND LVR2_DEFINITIONS -DLVR2_USE_VTK_GE_7_1)
set(VTK_COMPONENTS "${VTK_AVAILABLE_COMPONENTS}")
set(VTK_HAS_QT OFF)
foreach(VTK_COMPONENT ${VTK_COMPONENTS})
if("${VTK_COMPONENT}" STREQUAL "GUISupportQt")
set(VTK_HAS_QT ON)
endif()
endforeach()
if(VTK_VERSION VERSION_GREATER "7")

message(STATUS "VTK > 7 found")
if(VTK_HAS_QT)
message(STATUS "Found VTK compoment QVTK")
list(APPEND LVR2_DEFINITIONS -DLVR2_USE_VTK_GE_7_1)
set(VTK_COMPONENTS "${VTK_AVAILABLE_COMPONENTS}")
set(VTK_HAS_QT OFF)
foreach(VTK_COMPONENT ${VTK_COMPONENTS})
if("${VTK_COMPONENT}" STREQUAL "GUISupportQt")
set(VTK_HAS_QT ON)
endif()
endforeach()

message(STATUS "VTK > 7 found")
if(VTK_HAS_QT)
message(STATUS "Found VTK compoment QVTK")
endif()
endif()
endif()

endif(BUILD_VIEWER)

#------------------------------------------------------------------------------
# Searching for NABO
Expand Down Expand Up @@ -470,12 +489,9 @@ endif()
###############################################################################
# HEADERS
###############################################################################

install(DIRECTORY include/lvr2 DESTINATION ${CMAKE_INSTALL_INCLUDEDIR})
list(APPEND LVR2_INSTALL_INCLUDE_DIRS ${CMAKE_INSTALL_PREFIX}/${CMAKE_INSTALL_INCLUDEDIR})



###############################################################################
# VTK use file include. Has to be called after all CUDA code
# was generated and compiled. The VTK definitions corrupt the
Expand All @@ -490,19 +506,20 @@ endif()
###############################################################################
# LVR2 VIEWER CHECKS
###############################################################################

find_package(Qt5 COMPONENTS Core Widgets Xml OpenGL)
if(Qt5_FOUND)
message(STATUS "Found QT5")
find_package(QVTK)
if(QVTK_FOUND)
message(STATUS "Found QVTK ${QVTK_INCLUDE_DIR}")
include_directories(${QVTK_INCLUDE_DIR})
add_subdirectory(src/tools/lvr2_viewer)
elseif(DEFINED VTK_VERSION AND VTK_VERSION VERSION_GREATER "7" AND VTK_HAS_QT)
add_subdirectory(src/tools/lvr2_viewer)
endif(QVTK_FOUND)
endif(Qt5_FOUND)
if(BUILD_VIEWER)
find_package(Qt5 COMPONENTS Core Widgets Xml OpenGL)
if(Qt5_FOUND)
message(STATUS "Found QT5")
find_package(QVTK)
if(QVTK_FOUND)
message(STATUS "Found QVTK ${QVTK_INCLUDE_DIR}")
include_directories(${QVTK_INCLUDE_DIR})
add_subdirectory(src/tools/lvr2_viewer)
elseif(DEFINED VTK_VERSION AND VTK_VERSION VERSION_GREATER "7" AND VTK_HAS_QT)
add_subdirectory(src/tools/lvr2_viewer)
endif(QVTK_FOUND)
endif(Qt5_FOUND)
endif(BUILD_VIEWER)

###############################################################################
# LVR2 ASCII VIEWER CHECKS
Expand Down Expand Up @@ -582,45 +599,51 @@ add_subdirectory(src/liblvr2)
# BINARIES
###############################################################################

add_subdirectory(src/tools/lvr2_reconstruct)
add_subdirectory(src/tools/lvr2_dmc_reconstruction)
add_subdirectory(src/tools/lvr2_gs_reconstruction)
add_subdirectory(src/tools/lvr2_largescale_reconstruct)
add_subdirectory(src/tools/lvr2_asciiconverter)
add_subdirectory(src/tools/lvr2_transform)
add_subdirectory(src/tools/lvr2_kaboom)
add_subdirectory(src/tools/lvr2_octree_test)
add_subdirectory(src/tools/lvr2_image_normals)
add_subdirectory(src/tools/lvr2_plymerger)
# add_subdirectory(src/tools/lvr2_hdf5_builder)
add_subdirectory(src/tools/lvr2_hdf5_builder_2)
add_subdirectory(src/tools/lvr2_hdf5_mesh_builder)
add_subdirectory(src/tools/lvr2_slam2hdf5)
add_subdirectory(src/tools/lvr2_hdf5togeotiff)
add_subdirectory(src/tools/lvr2_slam6d_merger)
add_subdirectory(src/tools/lvr2_chunking)
add_subdirectory(src/tools/lvr2_registration)
add_subdirectory(src/tools/lvr2_mesh_reducer)
add_subdirectory(src/tools/lvr2_chunking_server)
add_subdirectory(src/tools/lvr2_scanproject_parser)

if(CURSES_FOUND AND embree_FOUND)
add_subdirectory(src/tools/lvr2_ascii_viewer)
endif()
if(BUILD_TOOLS)
add_subdirectory(src/tools/lvr2_reconstruct)
add_subdirectory(src/tools/lvr2_mesh_reducer)
endif(BUILD_TOOLS)

if(BUILD_TOOLS_EXPERIMENTAL)
add_subdirectory(src/tools/lvr2_dmc_reconstruction)
add_subdirectory(src/tools/lvr2_gs_reconstruction)
add_subdirectory(src/tools/lvr2_largescale_reconstruct)
add_subdirectory(src/tools/lvr2_asciiconverter)
add_subdirectory(src/tools/lvr2_transform)
add_subdirectory(src/tools/lvr2_kaboom)
add_subdirectory(src/tools/lvr2_octree_test)
add_subdirectory(src/tools/lvr2_image_normals)
add_subdirectory(src/tools/lvr2_plymerger)
# add_subdirectory(src/tools/lvr2_hdf5_builder)
add_subdirectory(src/tools/lvr2_hdf5_builder_2)
add_subdirectory(src/tools/lvr2_hdf5_mesh_builder)
add_subdirectory(src/tools/lvr2_slam2hdf5)
add_subdirectory(src/tools/lvr2_hdf5togeotiff)
add_subdirectory(src/tools/lvr2_slam6d_merger)
add_subdirectory(src/tools/lvr2_chunking)
add_subdirectory(src/tools/lvr2_registration)
add_subdirectory(src/tools/lvr2_chunking_server)
add_subdirectory(src/tools/lvr2_scanproject_parser)

if(CURSES_FOUND AND embree_FOUND)
add_subdirectory(src/tools/lvr2_ascii_viewer)
endif()

if (RiVLib_FOUND)
#add_subdirectory(src/tools/lvr2_riegl_project_converter)
endif()
if (RiVLib_FOUND)
#add_subdirectory(src/tools/lvr2_riegl_project_converter)
endif()

if(CUDA_FOUND)
# cuda_include_directories(ext/CTPL)
add_subdirectory(src/tools/lvr2_cuda_normals)
endif()
if(CUDA_FOUND)
# cuda_include_directories(ext/CTPL)
add_subdirectory(src/tools/lvr2_cuda_normals)
endif()

if(OPENCL_FOUND)
add_subdirectory(src/tools/lvr2_cl_normals)
add_subdirectory(src/tools/lvr2_cl_sor)
endif()
if(OPENCL_FOUND)
add_subdirectory(src/tools/lvr2_cl_normals)
add_subdirectory(src/tools/lvr2_cl_sor)
endif()

endif(BUILD_TOOLS_EXPERIMENTAL)

if(BUILD_EXAMPLES)
add_subdirectory(examples)
Expand All @@ -633,7 +656,7 @@ endif()

include(CMakePackageConfigHelpers)
set(INCLUDE_INSTALL_DIR include/)
set(LIB_INSTALL_DIR lib/)
set(LIB_INSTALL_DIR lib)
set(SYSCONFIG_INSTALL_DIR etc/lvr2/)

install(EXPORT lvr2Targets
Expand Down Expand Up @@ -693,3 +716,5 @@ if( DOXYGEN_FOUND AND DOXYGEN_DOT_FOUND )
WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}
COMMENT "Generating API documentation with Doxygen" VERBATIM )
endif( DOXYGEN_FOUND AND DOXYGEN_DOT_FOUND )


8 changes: 6 additions & 2 deletions LVR2Config.cmake.in
Original file line number Diff line number Diff line change
Expand Up @@ -27,12 +27,16 @@ set(LVR2_DEFINITIONS @LVR2_DEFINITIONS@)

find_package(PkgConfig REQUIRED)

set(LVR2_LIB_DIR @CMAKE_INSTALL_PREFIX@/@CMAKE_INSTALL_LIBDIR@)

option(LVR2_USE_STATIC_LIBS OFF)
if(LVR2_USE_STATIC_LIBS)
find_library(LVR2_LIBRARY NAMES lvr2_static)
# find_library(LVR2_LIBRARY NAMES lvr2_static)
set(LVR2_LIBRARY ${LVR2_LIB_DIR}/liblvr2_static.so)
set(LVR2_LIBRARIES ${LVR2_LIBRARY})
else()
find_library(LVR2_LIBRARY NAMES lvr2)
# find_library(LVR2_LIBRARY NAMES lvr2)
set(LVR2_LIBRARY ${LVR2_LIB_DIR}/liblvr2.so)
set(LVR2_LIBRARIES ${LVR2_LIBRARY})
endif()

Expand Down
4 changes: 0 additions & 4 deletions package.xml
Original file line number Diff line number Diff line change
Expand Up @@ -31,15 +31,11 @@ The Las Vegas Surface Reconstruction Toolkit is an Open Source toolkit to recons
<depend>libgdal-dev</depend>
<depend>eigen</depend>
<depend>ocl-icd-opencl-dev</depend>
<depend>libvtk</depend>
<depend>libvtk-qt</depend>
<depend>boost</depend>
<depend>glut</depend>
<depend>libxi-dev</depend>
<depend>libxmu-dev</depend>
<depend>libhdf5-dev</depend>
<depend>qtbase5-dev</depend>
<depend>libqt5-opengl-dev</depend>
<depend>lz4</depend>
<depend>libopencv-dev</depend>
<depend>yaml-cpp</depend>
Expand Down
26 changes: 14 additions & 12 deletions src/liblvr2/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -198,18 +198,20 @@ set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fPIC")
reconstruction/cuda/CudaSurface.cu
)

# Fix broken VTK flags
get_directory_property(dir_defs DIRECTORY ${CMAKE_SOURCE_DIR} COMPILE_DEFINITIONS)
set(vtk_flags)
foreach(it ${dir_defs})
if(it MATCHES "vtk*")
list(APPEND vtk_flags ${it})
endif()
endforeach()

foreach(d ${vtk_flags})
remove_definitions(-D${d})
endforeach()
if(VTK_FOUND)
# Fix broken VTK flags
get_directory_property(dir_defs DIRECTORY ${CMAKE_SOURCE_DIR} COMPILE_DEFINITIONS)
set(vtk_flags)
foreach(it ${dir_defs})
if(it MATCHES "vtk*")
list(APPEND vtk_flags ${it})
endif()
endforeach()

foreach(d ${vtk_flags})
remove_definitions(-D${d})
endforeach()
endif(VTK_FOUND)

message(STATUS "Building static LVR CUDA library")
cuda_add_library(lvr2cuda_static STATIC ${LVR2_CUDA_SRC})
Expand Down

0 comments on commit 0f46c0b

Please sign in to comment.