diff --git a/SuperBuild/CMakeLists.txt b/SuperBuild/CMakeLists.txt index 083d4b08..75020d8b 100644 --- a/SuperBuild/CMakeLists.txt +++ b/SuperBuild/CMakeLists.txt @@ -10,37 +10,6 @@ endif() # Setup SuperBuild root location set(SB_ROOT_DIR ${CMAKE_CURRENT_SOURCE_DIR}) -if (WIN32) - if (NOT DEFINED CMAKE_TOOLCHAIN_FILE) - message(FATAL_ERROR "CMAKE_TOOLCHAIN_FILE not set. You need to set it to the path of vcpkg.cmake") - endif() - set(WIN32_CMAKE_ARGS "-DCMAKE_TOOLCHAIN_FILE=${CMAKE_TOOLCHAIN_FILE}") - set(PYTHON_HOME "${SB_ROOT_DIR}/../venv") - set(PYTHON_EXE_PATH "${PYTHON_HOME}/Scripts/python") - - # Use the GDAL version that comes with pip - set(GDAL_ROOT "${PYTHON_HOME}/Lib/site-packages/osgeo") - set(GDAL_LIBRARY "${GDAL_ROOT}/lib/gdal_i.lib") - set(GDAL_INCLUDE_DIR "${GDAL_ROOT}/include/gdal") - - # Also download missing headers :/ - if (NOT EXISTS "${GDAL_INCLUDE_DIR}/ogrsf_frmts.h") - file(DOWNLOAD "https://raw.githubusercontent.com/OSGeo/gdal/release/3.2/gdal/ogr/ogrsf_frmts/ogrsf_frmts.h" "${GDAL_INCLUDE_DIR}/ogrsf_frmts.h") - endif() - - # TODO: copy gdal302.dll to superbuild/install/bin - - set(WIN32_GDAL_ARGS -DGDAL_FOUND=TRUE -DGDAL_LIBRARY=${GDAL_LIBRARY} -DGDAL_INCLUDE_DIR=${GDAL_INCLUDE_DIR}) -else() - set(PYTHON_EXE_PATH "/usr/bin/python3") -endif() - -# Path to additional CMake modules -set(CMAKE_MODULE_PATH ${SB_ROOT_DIR}/cmake) - -include(ExternalProject) -include(ExternalProject-Setup) - ################################ # Setup SuperBuild directories # ################################ @@ -77,6 +46,40 @@ mark_as_advanced(SB_BINARY_DIR) message(STATUS "SuperBuild binary files will be located to: ${SB_BINARY_DIR}") +if (WIN32) + if (NOT DEFINED CMAKE_TOOLCHAIN_FILE) + message(FATAL_ERROR "CMAKE_TOOLCHAIN_FILE not set. You need to set it to the path of vcpkg.cmake") + endif() + get_filename_component(CMAKE_TOOLCHAIN_DIR ${CMAKE_TOOLCHAIN_FILE} DIRECTORY) + set(VCPKG_ROOT "${CMAKE_TOOLCHAIN_DIR}/../../") + set(WIN32_CMAKE_ARGS "-DCMAKE_TOOLCHAIN_FILE=${CMAKE_TOOLCHAIN_FILE}") + set(PYTHON_HOME "${SB_ROOT_DIR}/../venv") + set(PYTHON_EXE_PATH "${PYTHON_HOME}/Scripts/python") + + # Use the GDAL version that comes with pip + set(GDAL_ROOT "${PYTHON_HOME}/Lib/site-packages/osgeo") + set(GDAL_LIBRARY "${GDAL_ROOT}/lib/gdal_i.lib") + set(GDAL_INCLUDE_DIR "${GDAL_ROOT}/include/gdal") + + # Also download missing headers :/ + if (NOT EXISTS "${GDAL_INCLUDE_DIR}/ogrsf_frmts.h") + file(DOWNLOAD "https://raw.githubusercontent.com/OSGeo/gdal/release/3.2/gdal/ogr/ogrsf_frmts/ogrsf_frmts.h" "${GDAL_INCLUDE_DIR}/ogrsf_frmts.h") + endif() + + # Copy VCPKG DLLs + file(GLOB COPY_DLLS "${VCPKG_ROOT}/installed/x64-windows/bin/*.dll") + file(COPY ${COPY_DLLS} DESTINATION "${SB_INSTALL_DIR}/bin") + + set(WIN32_GDAL_ARGS -DGDAL_FOUND=TRUE -DGDAL_LIBRARY=${GDAL_LIBRARY} -DGDAL_INCLUDE_DIR=${GDAL_INCLUDE_DIR}) +else() + set(PYTHON_EXE_PATH "/usr/bin/python3") +endif() + +# Path to additional CMake modules +set(CMAKE_MODULE_PATH ${SB_ROOT_DIR}/cmake) + +include(ExternalProject) +include(ExternalProject-Setup) ######################################### # Download and install third party libs # @@ -131,11 +134,15 @@ set(custom_libs OpenSfM LASzip PDAL Untwine - Entwine MvsTexturing OpenMVS ) +# Build entwine only on Linux +if (NOT WIN32) + set(custom_libs ${custom_libs} Entwine) +endif() + externalproject_add(mve GIT_REPOSITORY https://github.com/OpenDroneMap/mve.git GIT_TAG 250 @@ -194,14 +201,9 @@ externalproject_add(dem2points ) externalproject_add(lastools - GIT_REPOSITORY https://github.com/LAStools/LAStools.git - GIT_TAG 2ef44281645999ec7217facec84a5913bbbbe165 + GIT_REPOSITORY https://github.com/OpenDroneMap/LAStools.git + GIT_TAG 250 + PREFIX ${SB_BINARY_DIR}/lastools SOURCE_DIR ${SB_SOURCE_DIR}/lastools - CONFIGURE_COMMAND "" - CMAKE_COMMAND "" - CMAKE_GENERATOR "" - UPDATE_COMMAND "" - BUILD_IN_SOURCE 1 - BUILD_COMMAND make -C LASlib -j${nproc} CXXFLAGS='-std=c++11' && make -C src -j${nproc} CXXFLAGS='-std=c++11' lasmerge - INSTALL_COMMAND install -m755 -D -t ${SB_INSTALL_DIR}/bin ${SB_SOURCE_DIR}/lastools/bin/lasmerge + CMAKE_ARGS -DCMAKE_INSTALL_PREFIX:PATH=${SB_INSTALL_DIR} ) diff --git a/SuperBuild/cmake/External-Entwine.cmake b/SuperBuild/cmake/External-Entwine.cmake index fbb36b9f..df565665 100644 --- a/SuperBuild/cmake/External-Entwine.cmake +++ b/SuperBuild/cmake/External-Entwine.cmake @@ -1,6 +1,10 @@ set(_proj_name entwine) set(_SB_BINARY_DIR "${SB_BINARY_DIR}/${_proj_name}") +if (NOT WIN32) + set(EXTRA_CMAKE_ARGS -DCMAKE_CXX_FLAGS=-isystem\ ${SB_SOURCE_DIR}/pdal) +endif() + ExternalProject_Add(${_proj_name} DEPENDS pdal PREFIX ${_SB_BINARY_DIR} @@ -15,7 +19,7 @@ ExternalProject_Add(${_proj_name} #--Configure step------------- SOURCE_DIR ${SB_SOURCE_DIR}/${_proj_name} CMAKE_ARGS - -DCMAKE_CXX_FLAGS=-isystem\ ${SB_SOURCE_DIR}/pdal + ${EXTRA_CMAKE_ARGS} -DADDITIONAL_LINK_DIRECTORIES_PATHS=${SB_INSTALL_DIR}/lib -DWITH_TESTS=OFF -DWITH_ZSTD=OFF diff --git a/SuperBuild/cmake/External-Untwine.cmake b/SuperBuild/cmake/External-Untwine.cmake index 840aa52f..df175120 100644 --- a/SuperBuild/cmake/External-Untwine.cmake +++ b/SuperBuild/cmake/External-Untwine.cmake @@ -8,8 +8,8 @@ ExternalProject_Add(${_proj_name} STAMP_DIR ${_SB_BINARY_DIR}/stamp #--Download step-------------- DOWNLOAD_DIR ${SB_DOWNLOAD_DIR} - GIT_REPOSITORY https://github.com/pierotofy/untwine/ - GIT_TAG insttgt + GIT_REPOSITORY https://github.com/hobu/untwine/ + GIT_TAG 20243113fc7e9a3056f4ec727cc1f69202669156 #--Update/Patch step---------- UPDATE_COMMAND "" #--Configure step------------- diff --git a/opendm/entwine.py b/opendm/entwine.py index 0585d24d..da2de87c 100644 --- a/opendm/entwine.py +++ b/opendm/entwine.py @@ -1,4 +1,5 @@ import os +import sys import shutil from pipes import quote from opendm import io @@ -27,13 +28,17 @@ def build(input_point_cloud_files, output_path, max_concurrency=8, rerun=False): if rerun: dir_cleanup() - # Attempt with entwine (faster, more memory hungry) - try: - build_entwine(input_point_cloud_files, tmpdir, output_path, max_concurrency=max_concurrency) - except Exception as e: - log.ODM_WARNING("Cannot build EPT using entwine (%s), attempting with untwine..." % str(e)) - dir_cleanup() + # On Windows we always use Untwine + if sys.platform == 'win32': build_untwine(input_point_cloud_files, tmpdir, output_path, max_concurrency=max_concurrency) + else: + # Attempt with entwine (faster, more memory hungry) + try: + build_entwine(input_point_cloud_files, tmpdir, output_path, max_concurrency=max_concurrency) + except Exception as e: + log.ODM_WARNING("Cannot build EPT using entwine (%s), attempting with untwine..." % str(e)) + dir_cleanup() + build_untwine(input_point_cloud_files, tmpdir, output_path, max_concurrency=max_concurrency) if os.path.exists(tmpdir): shutil.rmtree(tmpdir)