vcpkg/ports/colmap/portfile.cmake
Lily Wang be6e23343e
[colmap] Fix feature tests link glog (#39006)
Fixes #38897 
Should also fix issue https://github.com/microsoft/vcpkg/issues/38393.

- [x] Changes comply with the [maintainer
guide](https://github.com/microsoft/vcpkg-docs/blob/main/vcpkg/contributing/maintainer-guide.md).
- [ ] ~~SHA512s are updated for each updated download.~~
- [ ] ~~The "supports" clause reflects platforms that may be fixed by
this new version.~~
- [ ] ~~Any fixed [CI
baseline](https://github.com/microsoft/vcpkg/blob/master/scripts/ci.baseline.txt)
entries are removed from that file.~~
- [ ] ~~Any patches that are no longer applied are deleted from the
port's directory.~~
- [x] The version database is fixed by rerunning `./vcpkg x-add-version
--all` and committing the result.
- [x] Only one version is added to each modified port's versions file.

Feature `colmap[core,tests]` passed with following triplets:
```
x86-windows
x64-windows
x64-linux
```
Usage test passed on `x64-windows`.

---------

Co-authored-by: Lily Wang <v-lilywang@microsoft.com>
2024-05-29 23:38:15 -07:00

92 lines
2.7 KiB
CMake

set(COLMAP_REF "9c704e89ff0a80e797725e112011f9f69e5aa28f") # Oct 1, 2023
vcpkg_from_github(
OUT_SOURCE_PATH SOURCE_PATH
REPO colmap/colmap
REF "${COLMAP_REF}"
SHA512 6ece735c403304c14887cd9b2b13a7e36bf07155fa959748c09d74854e0da6338766c11e6a371c26f983ccdb29f93b2600d685c907a5a137fe20d798b26805d8
HEAD_REF main
PATCHES
fix-link-glog.patch
)
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")
set(CUDA_ENABLED OFF)
set(TESTS_ENABLED OFF)
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("tests" IN_LIST FEATURES)
set(TESTS_ENABLED ON)
endif()
set(OPENMP_ENABLED ON)
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}
-DTESTS_ENABLED=${TESTS_ENABLED}
-DGIT_COMMIT_ID=${GIT_COMMIT_ID}
-DGIT_COMMIT_DATE=${COLMAP_GIT_COMMIT_DATE}
-DOPENMP_ENABLED=${OPENMP_ENABLED}
)
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}")