diff --git a/CMakeLists.txt b/CMakeLists.txt index 2276abc3..cb0ad164 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -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) @@ -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 @@ -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 @@ -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 @@ -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) @@ -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 @@ -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 ) + + diff --git a/LVR2Config.cmake.in b/LVR2Config.cmake.in index 85cd6a2a..aa92103f 100644 --- a/LVR2Config.cmake.in +++ b/LVR2Config.cmake.in @@ -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() diff --git a/package.xml b/package.xml index 9a02a1eb..ceddd69a 100644 --- a/package.xml +++ b/package.xml @@ -31,15 +31,11 @@ The Las Vegas Surface Reconstruction Toolkit is an Open Source toolkit to recons libgdal-dev eigen ocl-icd-opencl-dev - libvtk - libvtk-qt boost glut libxi-dev libxmu-dev libhdf5-dev - qtbase5-dev - libqt5-opengl-dev lz4 libopencv-dev yaml-cpp diff --git a/src/liblvr2/CMakeLists.txt b/src/liblvr2/CMakeLists.txt index 6d4e0759..9f667f4d 100644 --- a/src/liblvr2/CMakeLists.txt +++ b/src/liblvr2/CMakeLists.txt @@ -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})