vcpkg/ports/colmap/portfile.cmake
2024-12-16 10:34:00 -05:00

107 lines
3.0 KiB
CMake

set(COLMAP_REF "aa087848a8bd09cebf3e3cc8a5732552f30c51ad") # v3.11.1
vcpkg_from_github(
OUT_SOURCE_PATH SOURCE_PATH
REPO colmap/colmap
REF "${VERSION}"
SHA512 1260db4346cc33c6c35efdee0157450fccef67dbc9de876fdc997c7cb90daec716e5ccec97df0a77e3e8686f43ec79f2c0a1523ea12eca2ee158347cb52dea48
HEAD_REF main
)
if (NOT TRIPLET_SYSTEM_ARCH STREQUAL "x64" AND ("cuda" IN_LIST FEATURES OR "cuda-redist" IN_LIST FEATURES))
message(FATAL_ERROR "Feature cuda and cuda-redist require x64 triplet.")
endif()
# set GIT_COMMIT_ID and GIT_COMMIT_DATE
if(DEFINED VCPKG_HEAD_VERSION)
set(GIT_COMMIT_ID "${VCPKG_HEAD_VERSION}")
else()
set(GIT_COMMIT_ID "${COLMAP_REF}")
endif()
string(TIMESTAMP COLMAP_GIT_COMMIT_DATE "%Y-%m-%d")
foreach(FEATURE ${FEATURE_OPTIONS})
message(STATUS "${FEATURE}")
endforeach()
set(CUDA_ENABLED OFF)
set(GUI_ENABLED OFF)
set(TESTS_ENABLED OFF)
set(CGAL_ENABLED OFF)
set(OPENMP_ENABLED ON)
if("cuda" IN_LIST FEATURES)
set(CUDA_ENABLED ON)
set(CUDA_ARCHITECTURES "native")
endif()
if("cuda-redist" IN_LIST FEATURES)
set(CUDA_ENABLED ON)
set(CUDA_ARCHITECTURES "all-major")
endif()
if("gui" IN_LIST FEATURES)
set(GUI_ENABLED ON)
endif()
if("tests" IN_LIST FEATURES)
set(TESTS_ENABLED ON)
endif()
if("cgal" IN_LIST FEATURES)
set(CGAL_ENABLED ON)
endif()
if (VCPKG_TARGET_IS_OSX AND VCPKG_TARGET_ARCHITECTURE MATCHES "arm")
set(OPENMP_ENABLED OFF)
endif()
vcpkg_cmake_configure(
SOURCE_PATH "${SOURCE_PATH}"
DISABLE_PARALLEL_CONFIGURE
OPTIONS
-DCUDA_ENABLED=${CUDA_ENABLED}
-DCMAKE_CUDA_ARCHITECTURES=${CUDA_ARCHITECTURES}
-DGUI_ENABLED=${GUI_ENABLED}
-DTESTS_ENABLED=${TESTS_ENABLED}
-DGIT_COMMIT_ID=${GIT_COMMIT_ID}
-DGIT_COMMIT_DATE=${COLMAP_GIT_COMMIT_DATE}
-DOPENMP_ENABLED=${OPENMP_ENABLED}
-DCGAL_ENABLED=${CGAL_ENABLED}
-DFETCH_POSELIB=OFF
)
vcpkg_cmake_install()
vcpkg_cmake_config_fixup()
file(GLOB TOOL_FILENAMES "${CURRENT_PACKAGES_DIR}/bin/*")
foreach(TOOL_FILENAME ${TOOL_FILENAMES})
get_filename_component(TEST_TOOL_NAME ${TOOL_FILENAME} NAME_WLE)
list(APPEND COLMAP_TOOL_NAMES "${TEST_TOOL_NAME}")
endforeach()
vcpkg_copy_tools(TOOL_NAMES ${COLMAP_TOOL_NAMES} AUTO_CLEAN)
# remove empty folders and unused files
file(REMOVE_RECURSE
"${CURRENT_PACKAGES_DIR}/debug/include"
"${CURRENT_PACKAGES_DIR}/debug/share"
"${CURRENT_PACKAGES_DIR}/include/colmap/exe"
"${CURRENT_PACKAGES_DIR}/include/colmap/tools"
"${CURRENT_PACKAGES_DIR}/include/colmap/ui/media"
"${CURRENT_PACKAGES_DIR}/include/colmap/ui/shaders"
"${CURRENT_PACKAGES_DIR}/COLMAP.bat"
"${CURRENT_PACKAGES_DIR}/RUN_TESTS.bat"
"${CURRENT_PACKAGES_DIR}/debug/COLMAP.bat"
"${CURRENT_PACKAGES_DIR}/debug/RUN_TESTS.bat"
"${CURRENT_PACKAGES_DIR}/debug/bin"
)
vcpkg_copy_pdbs()
vcpkg_install_copyright(FILE_LIST "${SOURCE_PATH}/COPYING.txt")
file(INSTALL "${CMAKE_CURRENT_LIST_DIR}/usage" DESTINATION "${CURRENT_PACKAGES_DIR}/share/${PORT}")