From 1f94edb386d17c014d591d4bc17c9cd90ddcc6e5 Mon Sep 17 00:00:00 2001 From: Martin Valgur Date: Sat, 23 Mar 2024 19:55:56 +0200 Subject: [PATCH 1/8] colmap: new recipe --- recipes/colmap/all/colmap-conan-vars.cmake.in | 24 ++ recipes/colmap/all/conandata.yml | 4 + recipes/colmap/all/conanfile.py | 245 ++++++++++++++++++ .../colmap/all/test_package/CMakeLists.txt | 8 + recipes/colmap/all/test_package/conanfile.py | 26 ++ .../colmap/all/test_package/test_package.cpp | 10 + recipes/colmap/config.yml | 3 + 7 files changed, 320 insertions(+) create mode 100644 recipes/colmap/all/colmap-conan-vars.cmake.in create mode 100644 recipes/colmap/all/conandata.yml create mode 100644 recipes/colmap/all/conanfile.py create mode 100644 recipes/colmap/all/test_package/CMakeLists.txt create mode 100644 recipes/colmap/all/test_package/conanfile.py create mode 100644 recipes/colmap/all/test_package/test_package.cpp create mode 100644 recipes/colmap/config.yml diff --git a/recipes/colmap/all/colmap-conan-vars.cmake.in b/recipes/colmap/all/colmap-conan-vars.cmake.in new file mode 100644 index 0000000000000..80d1fa1085fbb --- /dev/null +++ b/recipes/colmap/all/colmap-conan-vars.cmake.in @@ -0,0 +1,24 @@ +set(COLMAP_FOUND TRUE) +set(COLMAP_VERSION "@COLMAP_VERSION@") + +set(COLMAP_CUDA_ENABLED @CUDA_ENABLED@) +if(COLMAP_CUDA_ENABLED) + enable_language(CUDA) + include(CMakeFindDependencyMacro) + if(CMAKE_VERSION VERSION_LESS 3.17) + find_dependency(CUDA REQUIRED) + macro(declare_imported_cuda_target module) + add_library(CUDA::${module} INTERFACE IMPORTED) + target_include_directories(CUDA::${module} INTERFACE ${CUDA_INCLUDE_DIRS}) + target_link_libraries(CUDA::${module} INTERFACE ${CUDA_${module}_LIBRARY} ${ARGN}) + endmacro() + declare_imported_cuda_target(cudart ${CUDA_LIBRARIES}) + declare_imported_cuda_target(curand ${CUDA_LIBRARIES}) + else() + find_dependency(CUDAToolkit REQUIRED) + endif() + + set_property(TARGET colmap::colmap_util_cuda PROPERTY INTERFACE_LINK_LIBRARIES CUDA::cudart APPEND) + set_property(TARGET colmap::colmap_mvs_cuda PROPERTY INTERFACE_LINK_LIBRARIES CUDA::cudart CUDA::curand APPEND) + set_property(TARGET colmap::colmap_sift_gpu PROPERTY INTERFACE_LINK_LIBRARIES CUDA::cudart CUDA::curand APPEND) +endif() diff --git a/recipes/colmap/all/conandata.yml b/recipes/colmap/all/conandata.yml new file mode 100644 index 0000000000000..b28678940b8c0 --- /dev/null +++ b/recipes/colmap/all/conandata.yml @@ -0,0 +1,4 @@ +sources: + "3.9.1": + url: "https://github.com/colmap/colmap/archive/refs/tags/3.9.1.tar.gz" + sha256: "f947ad80802baa8f00f30f26d316d8c608ab2626465eac1c81cf325d57879862" diff --git a/recipes/colmap/all/conanfile.py b/recipes/colmap/all/conanfile.py new file mode 100644 index 0000000000000..e1328d2e2ce0a --- /dev/null +++ b/recipes/colmap/all/conanfile.py @@ -0,0 +1,245 @@ +import os + +from conan import ConanFile +from conan.errors import ConanInvalidConfiguration +from conan.tools.build import check_min_cppstd +from conan.tools.cmake import CMake, CMakeDeps, CMakeToolchain, cmake_layout +from conan.tools.env import VirtualRunEnv, VirtualBuildEnv +from conan.tools.files import copy, get, rm, rmdir, replace_in_file, load, save +from conan.tools.scm import Version + +required_conan_version = ">=1.53.0" + + +class ColmapConan(ConanFile): + name = "colmap" + description = ("COLMAP is a general-purpose Structure-from-Motion (SfM) and " + "Multi-View Stereo (MVS) pipeline with a graphical and command-line interface.") + license = "BSD-3-Clause" + homepage = "https://colmap.github.io/" + url = "https://github.com/conan-io/conan-center-index" + topics = ("computer-vision", "structure-from-motion", "multi-view-stereo", "3d-reconstruction", "photogrammetry") + + package_type = "static-library" + settings = "os", "arch", "compiler", "build_type" + options = { + "fPIC": [True, False], + "cgal": [True, False], + "cuda": [True, False], + "gui": [True, False], + "ipo": [True, False], + "openmp": [True, False], + "tools": [True, False], + "cuda_architectures": ["native", "all-major", "all", "ANY"], + } + default_options = { + "fPIC": True, + "cgal": False, + "cuda": False, + "gui": False, + "ipo": True, + "openmp": True, + "tools": True, + "cuda_architectures": "all-major", + } + + @property + def _min_cppstd(self): + return 14 + + @property + def _compilers_minimum_version(self): + return { + "apple-clang": "10", + "clang": "7", + "gcc": "7", + "msvc": "191", + "Visual Studio": "15", + } + + def export_sources(self): + copy(self, "colmap-conan-vars.cmake.in", self.recipe_folder, self.export_sources_folder) + + def config_options(self): + if self.settings.os == "Windows": + del self.options.fPIC + + def configure(self): + if not self.options.cuda: + del self.options.cuda_architectures + + def layout(self): + cmake_layout(self, src_folder="src") + + def requirements(self): + self.requires("boost/1.84.0", transitive_headers=True, transitive_libs=True) + # Ceres 2.2.0 is not compatible as of v3.9.1 + self.requires("ceres-solver/2.1.0", transitive_headers=True, transitive_libs=True) + self.requires("eigen/3.4.0", transitive_headers=True, transitive_libs=True) + self.requires("flann/1.9.2", transitive_headers=True, transitive_libs=True) + self.requires("freeimage/3.18.0") + self.requires("glog/0.6.0", transitive_headers=True, transitive_libs=True) + self.requires("metis/5.2.1") + self.requires("sqlite3/3.45.3", transitive_headers=True, transitive_libs=True) + self.requires("lz4/1.9.4") + if self.options.openmp: + self.requires("llvm-openmp/17.0.6", transitive_headers=True, transitive_libs=True) + if self.options.cgal: + self.requires("cgal/5.6.1") + if self.options.gui: + self.requires("qt/5.15.13", transitive_headers=True, transitive_libs=True) + if self.options.gui or self.options.cuda: + self.requires("glew/2.2.0") + self.requires("opengl/system") + # TODO: unvendor VLFeat, PoissonRecon, LSD, SiftGPU + # self.requires("vlfeat/0.9.21", transitive_headers=True, transitive_libs=True) + + def validate(self): + if self.settings.compiler.get_safe("cppstd"): + check_min_cppstd(self, self._min_cppstd) + minimum_version = self._compilers_minimum_version.get(str(self.settings.compiler), False) + if minimum_version and Version(self.settings.compiler.version) < minimum_version: + raise ConanInvalidConfiguration( + f"{self.ref} requires C++{self._min_cppstd}, which your compiler does not support." + ) + + def build_requirements(self): + if self.options.cuda: + self.tool_requires("cmake/[>=3.24 <4]") + + def source(self): + get(self, **self.conan_data["sources"][self.version], strip_root=True) + + def generate(self): + tc = CMakeToolchain(self) + tc.variables["CCACHE_ENABLED"] = False + tc.variables["CGAL_ENABLED"] = self.options.cgal + tc.variables["CUDA_ENABLED"] = self.options.cuda + tc.variables["GUI_ENABLED"] = self.options.gui + tc.variables["IPO_ENABLED"] = self.options.ipo + tc.variables["OPENGL_ENABLED"] = self.options.gui + tc.variables["OPENMP_ENABLED"] = self.options.openmp + tc.variables["SIMD_ENABLED"] = True # only applied to VLFeat and when on x86 + tc.variables["TESTS_ENABLED"] = False + tc.variables["CMAKE_CUDA_ARCHITECTURES"] = self.options.get_safe("cuda_architectures", "") + tc.cache_variables["CMAKE_POLICY_DEFAULT_CMP0077"] = "NEW" + tc.generate() + + deps = CMakeDeps(self) + deps.set_property("cgal", "cmake_file_name", "CGAL") + deps.set_property("cgal", "cmake_target_aliases", ["CGAL"]) + deps.set_property("flann", "cmake_file_name", "FLANN") + deps.set_property("flann", "cmake_target_name", "flann") + deps.set_property("freeimage", "cmake_file_name", "FreeImage") + deps.set_property("freeimage::FreeImage", "cmake_target_name", "freeimage::FreeImage") + deps.set_property("glew", "cmake_file_name", "Glew") + deps.set_property("glew", "cmake_target_name", "GLEW::GLEW") + deps.set_property("glog", "cmake_file_name", "Glog") + deps.set_property("glog", "cmake_target_name", "glog::glog") + deps.set_property("lz4", "cmake_file_name", "LZ4") + deps.set_property("lz4", "cmake_target_name", "lz4") + deps.set_property("metis", "cmake_file_name", "Metis") + deps.set_property("metis", "cmake_target_name", "metis") + deps.generate() + + VirtualBuildEnv(self).generate() + + # FIXME: this is a hack for Freeimage and Metis transitive dep shared libs not being found for some reason + VirtualRunEnv(self).generate(scope="build") + + def _patch_sources(self): + for module in self.source_path.joinpath("cmake").glob("Find*.cmake"): + if module.name != "FindDependencies.cmake": + module.unlink() + find_dependencies = self.source_path.joinpath("cmake", "FindDependencies.cmake") + replace_in_file(self, find_dependencies, " QUIET", " REQUIRED") + + if not self.options.gui and not self.options.cuda: + # OpenGL and GLEW are not actually being used in this case + replace_in_file(self, find_dependencies, "find_package(Glew", "# find_package(Glew") + replace_in_file(self, find_dependencies, "find_package(OpenGL", "# find_package(OpenGL") + + if not self.options.tools: + replace_in_file(self, os.path.join(self.source_folder, "src", "colmap", "exe", "CMakeLists.txt"), + "COLMAP_ADD_EXECUTABLE(", "message(TRACE ") + replace_in_file(self, os.path.join(self.source_folder, "src", "colmap", "exe", "CMakeLists.txt"), + "set_target_properties(colmap_main ", "# set_target_properties(colmap_main ") + + def build(self): + self._patch_sources() + cmake = CMake(self) + cmake.configure() + cmake.build() + + def _write_cmake_module(self): + content = load(self, os.path.join(self.export_sources_folder, "colmap-conan-vars.cmake.in")) + content = content.replace("@COLMAP_VERSION@", self.version) + content = content.replace("@CUDA_ENABLED@", "TRUE" if self.options.cuda else "FALSE") + save(self, os.path.join(self.package_folder, "lib", "cmake", "colmap-conan-vars.cmake"), content) + + def package(self): + copy(self, "COPYING.txt", self.source_folder, os.path.join(self.package_folder, "licenses")) + cmake = CMake(self) + cmake.install() + rmdir(self, os.path.join(self.package_folder, "share")) + rm(self, "*.pdb", self.package_folder, recursive=True) + self._write_cmake_module() + + def package_info(self): + self.cpp_info.set_property("cmake_file_name", "colmap") + self.cpp_info.set_property("cmake_target_name", "colmap::colmap") + + module_rel_path = os.path.join("lib", "cmake", "colmap-conan-vars.cmake") + self.cpp_info.builddirs.append(os.path.join("lib", "cmake")) + self.cpp_info.set_property("cmake_build_modules", [module_rel_path]) + self.cpp_info.build_modules["cmake_find_package"] = [module_rel_path] + self.cpp_info.build_modules["cmake_find_package_multi"] = [module_rel_path] + + def _add_component(name, requires): + component = self.cpp_info.components[name] + component.set_property("cmake_target_name", f"colmap::colmap_{name}") + component.libs = [f"colmap_{name}"] + component.requires = requires + return component + + util = _add_component("util", requires=["boost::headers", "boost::filesystem", "eigen::eigen", "glog::glog", "sqlite3::sqlite3"]) + _add_component("controllers", requires=["util", "estimators", "feature", "image", "math", "mvs", "retrieval", "sfm", "scene", + "ceres-solver::ceres", "boost::program_options"]) + _add_component("estimators", requires=["util", "math", "feature", "geometry", "sensor", "image", "scene", "optim", "ceres-solver::ceres"]) + exe = _add_component("exe", requires=["util", "controllers", "estimators", "geometry", "optim", "scene"]) + feature = _add_component("feature", requires=["util", "math", "sensor", "vlfeat", "flann::flann", "lz4::lz4"]) + _add_component("geometry", requires=["util", "math"]) + _add_component("image", requires=["util", "sensor", "scene", "lsd"]) + _add_component("math", requires=["util", "metis::metis", "boost::graph"]) + mvs = _add_component("mvs", requires=["util", "scene", "sensor", "image", "poisson_recon"]) + _add_component("optim", requires=["math"]) + _add_component("retrieval", requires=["math", "estimators", "optim", "flann::flann", "lz4::lz4"]) + _add_component("scene", requires=["util", "sensor", "feature", "geometry"]) + _add_component("sensor", requires=["util", "vlfeat", "freeimage::FreeImage", "ceres-solver::ceres"]) + _add_component("sfm", requires=["geometry", "image", "scene", "estimators"]) + _add_component("lsd", requires=[]) + poisson_recon = _add_component("poisson_recon", requires=[]) + vlfeat = _add_component("vlfeat", requires=[]) + + if self.options.cgal: + mvs.requires.append("cgal::cgal") + + if self.options.gui: + _add_component("ui", requires=["util", "image", "scene", "controllers", "qt::Core", "qt::OpenGL", "qt::Widgets"]) + util.requires.extend(["qt::Core", "qt::OpenGL", "opengl::opengl"]) + feature.requires.extend(["qt::Widgets"]) + exe.requires.extend(["ui"]) + + if self.options.openmp: + poisson_recon.requires.append("llvm-openmp::llvm-openmp") + vlfeat.requires.append("llvm-openmp::llvm-openmp") + + if self.options.cuda: + # CUDA dependencies are exported in the CMake module + _add_component("util_cuda", requires=["util"]) + _add_component("mvs_cuda", requires=["mvs", "util_cuda"]) + exe.requires.extend(["util_cuda", "mvs_cuda"]) + + if self.options.gui or self.options.cuda: + _add_component("sift_gpu", requires=["opengl::opengl", "glew::glew"]) + feature.requires.extend(["sift_gpu"]) diff --git a/recipes/colmap/all/test_package/CMakeLists.txt b/recipes/colmap/all/test_package/CMakeLists.txt new file mode 100644 index 0000000000000..e46a81c198e33 --- /dev/null +++ b/recipes/colmap/all/test_package/CMakeLists.txt @@ -0,0 +1,8 @@ +cmake_minimum_required(VERSION 3.15) +project(test_package LANGUAGES CXX) + +find_package(colmap REQUIRED CONFIG) + +add_executable(${PROJECT_NAME} test_package.cpp) +target_link_libraries(${PROJECT_NAME} PRIVATE colmap::colmap) +target_compile_features(${PROJECT_NAME} PRIVATE cxx_std_14) diff --git a/recipes/colmap/all/test_package/conanfile.py b/recipes/colmap/all/test_package/conanfile.py new file mode 100644 index 0000000000000..ef5d7042163ec --- /dev/null +++ b/recipes/colmap/all/test_package/conanfile.py @@ -0,0 +1,26 @@ +from conan import ConanFile +from conan.tools.build import can_run +from conan.tools.cmake import cmake_layout, CMake +import os + + +class TestPackageConan(ConanFile): + settings = "os", "arch", "compiler", "build_type" + generators = "CMakeDeps", "CMakeToolchain", "VirtualRunEnv" + test_type = "explicit" + + def requirements(self): + self.requires(self.tested_reference_str) + + def layout(self): + cmake_layout(self) + + def build(self): + cmake = CMake(self) + cmake.configure() + cmake.build() + + def test(self): + if can_run(self): + bin_path = os.path.join(self.cpp.build.bindir, "test_package") + self.run(bin_path, env="conanrun") diff --git a/recipes/colmap/all/test_package/test_package.cpp b/recipes/colmap/all/test_package/test_package.cpp new file mode 100644 index 0000000000000..41956374f252a --- /dev/null +++ b/recipes/colmap/all/test_package/test_package.cpp @@ -0,0 +1,10 @@ +#include +#include +#include + +int main(int argc, char** argv) { + colmap::InitializeGlog(argv); + colmap::OptionManager options; + options.Parse(argc, argv); + colmap::Reconstruction reconstruction; +} diff --git a/recipes/colmap/config.yml b/recipes/colmap/config.yml new file mode 100644 index 0000000000000..93869f48e8b23 --- /dev/null +++ b/recipes/colmap/config.yml @@ -0,0 +1,3 @@ +versions: + "3.9.1": + folder: all From 68adec9ecd38009ecd558c684acf9a288bab20d8 Mon Sep 17 00:00:00 2001 From: Martin Valgur Date: Tue, 30 Apr 2024 13:00:41 +0300 Subject: [PATCH 2/8] colmap: add a workaround for current OpenMP support on CCI --- recipes/colmap/all/conanfile.py | 31 ++++++++++++++++++++++++++++--- 1 file changed, 28 insertions(+), 3 deletions(-) diff --git a/recipes/colmap/all/conanfile.py b/recipes/colmap/all/conanfile.py index e1328d2e2ce0a..228d2b8b55d43 100644 --- a/recipes/colmap/all/conanfile.py +++ b/recipes/colmap/all/conanfile.py @@ -6,6 +6,7 @@ from conan.tools.cmake import CMake, CMakeDeps, CMakeToolchain, cmake_layout from conan.tools.env import VirtualRunEnv, VirtualBuildEnv from conan.tools.files import copy, get, rm, rmdir, replace_in_file, load, save +from conan.tools.microsoft import is_msvc from conan.tools.scm import Version required_conan_version = ">=1.53.0" @@ -83,7 +84,8 @@ def requirements(self): self.requires("sqlite3/3.45.3", transitive_headers=True, transitive_libs=True) self.requires("lz4/1.9.4") if self.options.openmp: - self.requires("llvm-openmp/17.0.6", transitive_headers=True, transitive_libs=True) + if self.settings.compiler in ["clang", "apple-clang"]: + self.requires("llvm-openmp/17.0.6", transitive_headers=True, transitive_libs=True) if self.options.cgal: self.requires("cgal/5.6.1") if self.options.gui: @@ -185,6 +187,22 @@ def package(self): rm(self, "*.pdb", self.package_folder, recursive=True) self._write_cmake_module() + @property + def _openmp_flags(self): + if self.settings.compiler == "clang": + return ["-fopenmp=libomp"] + elif self.settings.compiler == "apple-clang": + return ["-Xclang", "-fopenmp"] + elif self.settings.compiler == "gcc": + return ["-fopenmp"] + elif self.settings.compiler == "intel-cc": + return ["-Qopenmp"] + elif self.settings.compiler == "sun-cc": + return ["-xopenmp"] + elif is_msvc(self): + return ["-openmp"] + return None + def package_info(self): self.cpp_info.set_property("cmake_file_name", "colmap") self.cpp_info.set_property("cmake_target_name", "colmap::colmap") @@ -231,8 +249,15 @@ def _add_component(name, requires): exe.requires.extend(["ui"]) if self.options.openmp: - poisson_recon.requires.append("llvm-openmp::llvm-openmp") - vlfeat.requires.append("llvm-openmp::llvm-openmp") + if self.settings.compiler in ["clang", "apple-clang"]: + poisson_recon.requires.append("llvm-openmp::llvm-openmp") + vlfeat.requires.append("llvm-openmp::llvm-openmp") + # TODO: these can be dropped after #22353 is merged + openmp_flags = self._openmp_flags + poisson_recon.cflags = openmp_flags + poisson_recon.cxxflags = openmp_flags + vlfeat.cflags = openmp_flags + vlfeat.cxxflags = openmp_flags if self.options.cuda: # CUDA dependencies are exported in the CMake module From 22f30660d75a91b92ec49e231df913abdd0a3f41 Mon Sep 17 00:00:00 2001 From: Martin Valgur Date: Mon, 8 Jul 2024 16:14:40 +0300 Subject: [PATCH 3/8] colmap: update llvm-openmp usage --- recipes/colmap/all/conanfile.py | 32 ++------------------------------ 1 file changed, 2 insertions(+), 30 deletions(-) diff --git a/recipes/colmap/all/conanfile.py b/recipes/colmap/all/conanfile.py index 228d2b8b55d43..1966df797d944 100644 --- a/recipes/colmap/all/conanfile.py +++ b/recipes/colmap/all/conanfile.py @@ -73,7 +73,7 @@ def layout(self): cmake_layout(self, src_folder="src") def requirements(self): - self.requires("boost/1.84.0", transitive_headers=True, transitive_libs=True) + self.requires("boost/1.85.0", transitive_headers=True, transitive_libs=True) # Ceres 2.2.0 is not compatible as of v3.9.1 self.requires("ceres-solver/2.1.0", transitive_headers=True, transitive_libs=True) self.requires("eigen/3.4.0", transitive_headers=True, transitive_libs=True) @@ -84,8 +84,7 @@ def requirements(self): self.requires("sqlite3/3.45.3", transitive_headers=True, transitive_libs=True) self.requires("lz4/1.9.4") if self.options.openmp: - if self.settings.compiler in ["clang", "apple-clang"]: - self.requires("llvm-openmp/17.0.6", transitive_headers=True, transitive_libs=True) + self.requires("llvm-openmp/18.1.8", transitive_headers=True, transitive_libs=True) if self.options.cgal: self.requires("cgal/5.6.1") if self.options.gui: @@ -187,22 +186,6 @@ def package(self): rm(self, "*.pdb", self.package_folder, recursive=True) self._write_cmake_module() - @property - def _openmp_flags(self): - if self.settings.compiler == "clang": - return ["-fopenmp=libomp"] - elif self.settings.compiler == "apple-clang": - return ["-Xclang", "-fopenmp"] - elif self.settings.compiler == "gcc": - return ["-fopenmp"] - elif self.settings.compiler == "intel-cc": - return ["-Qopenmp"] - elif self.settings.compiler == "sun-cc": - return ["-xopenmp"] - elif is_msvc(self): - return ["-openmp"] - return None - def package_info(self): self.cpp_info.set_property("cmake_file_name", "colmap") self.cpp_info.set_property("cmake_target_name", "colmap::colmap") @@ -248,17 +231,6 @@ def _add_component(name, requires): feature.requires.extend(["qt::Widgets"]) exe.requires.extend(["ui"]) - if self.options.openmp: - if self.settings.compiler in ["clang", "apple-clang"]: - poisson_recon.requires.append("llvm-openmp::llvm-openmp") - vlfeat.requires.append("llvm-openmp::llvm-openmp") - # TODO: these can be dropped after #22353 is merged - openmp_flags = self._openmp_flags - poisson_recon.cflags = openmp_flags - poisson_recon.cxxflags = openmp_flags - vlfeat.cflags = openmp_flags - vlfeat.cxxflags = openmp_flags - if self.options.cuda: # CUDA dependencies are exported in the CMake module _add_component("util_cuda", requires=["util"]) From 5aa07d83e32e85e55ddb94bb8dde2e4dcf78e011 Mon Sep 17 00:00:00 2001 From: Martin Valgur Date: Mon, 5 Aug 2024 17:58:55 +0300 Subject: [PATCH 4/8] colmap: update to v3.10 --- recipes/colmap/all/conandata.yml | 6 ++--- recipes/colmap/all/conanfile.py | 44 +++++++++++++++++--------------- 2 files changed, 27 insertions(+), 23 deletions(-) diff --git a/recipes/colmap/all/conandata.yml b/recipes/colmap/all/conandata.yml index b28678940b8c0..53dd20d1703b7 100644 --- a/recipes/colmap/all/conandata.yml +++ b/recipes/colmap/all/conandata.yml @@ -1,4 +1,4 @@ sources: - "3.9.1": - url: "https://github.com/colmap/colmap/archive/refs/tags/3.9.1.tar.gz" - sha256: "f947ad80802baa8f00f30f26d316d8c608ab2626465eac1c81cf325d57879862" + "3.10": + url: "https://github.com/colmap/colmap/archive/refs/tags/3.10.tar.gz" + sha256: "61850f323e201ab6a1abbfb0e4a8b3ba1c4cedbf55e0a5716bdea1df8ae1813a" diff --git a/recipes/colmap/all/conanfile.py b/recipes/colmap/all/conanfile.py index 1966df797d944..4cf17d1802646 100644 --- a/recipes/colmap/all/conanfile.py +++ b/recipes/colmap/all/conanfile.py @@ -6,7 +6,6 @@ from conan.tools.cmake import CMake, CMakeDeps, CMakeToolchain, cmake_layout from conan.tools.env import VirtualRunEnv, VirtualBuildEnv from conan.tools.files import copy, get, rm, rmdir, replace_in_file, load, save -from conan.tools.microsoft import is_msvc from conan.tools.scm import Version required_conan_version = ">=1.53.0" @@ -35,7 +34,7 @@ class ColmapConan(ConanFile): } default_options = { "fPIC": True, - "cgal": False, + "cgal": True, "cuda": False, "gui": False, "ipo": True, @@ -74,7 +73,7 @@ def layout(self): def requirements(self): self.requires("boost/1.85.0", transitive_headers=True, transitive_libs=True) - # Ceres 2.2.0 is not compatible as of v3.9.1 + # Ceres 2.2.0 is not compatible as of v3.10 self.requires("ceres-solver/2.1.0", transitive_headers=True, transitive_libs=True) self.requires("eigen/3.4.0", transitive_headers=True, transitive_libs=True) self.requires("flann/1.9.2", transitive_headers=True, transitive_libs=True) @@ -84,7 +83,7 @@ def requirements(self): self.requires("sqlite3/3.45.3", transitive_headers=True, transitive_libs=True) self.requires("lz4/1.9.4") if self.options.openmp: - self.requires("llvm-openmp/18.1.8", transitive_headers=True, transitive_libs=True) + self.requires("openmp/system", transitive_headers=True, transitive_libs=True) if self.options.cgal: self.requires("cgal/5.6.1") if self.options.gui: @@ -113,16 +112,16 @@ def source(self): def generate(self): tc = CMakeToolchain(self) - tc.variables["CCACHE_ENABLED"] = False - tc.variables["CGAL_ENABLED"] = self.options.cgal - tc.variables["CUDA_ENABLED"] = self.options.cuda - tc.variables["GUI_ENABLED"] = self.options.gui - tc.variables["IPO_ENABLED"] = self.options.ipo - tc.variables["OPENGL_ENABLED"] = self.options.gui - tc.variables["OPENMP_ENABLED"] = self.options.openmp - tc.variables["SIMD_ENABLED"] = True # only applied to VLFeat and when on x86 - tc.variables["TESTS_ENABLED"] = False - tc.variables["CMAKE_CUDA_ARCHITECTURES"] = self.options.get_safe("cuda_architectures", "") + tc.cache_variables["CCACHE_ENABLED"] = False + tc.cache_variables["CGAL_ENABLED"] = self.options.cgal + tc.cache_variables["CUDA_ENABLED"] = self.options.cuda + tc.cache_variables["GUI_ENABLED"] = self.options.gui + tc.cache_variables["IPO_ENABLED"] = self.options.ipo + tc.cache_variables["OPENGL_ENABLED"] = self.options.gui + tc.cache_variables["OPENMP_ENABLED"] = self.options.openmp + tc.cache_variables["SIMD_ENABLED"] = True # only applied to VLFeat and when on x86 + tc.cache_variables["TESTS_ENABLED"] = False + tc.cache_variables["CMAKE_CUDA_ARCHITECTURES"] = self.options.get_safe("cuda_architectures", "") tc.cache_variables["CMAKE_POLICY_DEFAULT_CMP0077"] = "NEW" tc.generate() @@ -206,18 +205,19 @@ def _add_component(name, requires): util = _add_component("util", requires=["boost::headers", "boost::filesystem", "eigen::eigen", "glog::glog", "sqlite3::sqlite3"]) _add_component("controllers", requires=["util", "estimators", "feature", "image", "math", "mvs", "retrieval", "sfm", "scene", "ceres-solver::ceres", "boost::program_options"]) - _add_component("estimators", requires=["util", "math", "feature", "geometry", "sensor", "image", "scene", "optim", "ceres-solver::ceres"]) + _add_component("estimators", requires=["util", "math", "feature_types", "geometry", "sensor", "image", "scene", "optim", "ceres-solver::ceres"]) exe = _add_component("exe", requires=["util", "controllers", "estimators", "geometry", "optim", "scene"]) - feature = _add_component("feature", requires=["util", "math", "sensor", "vlfeat", "flann::flann", "lz4::lz4"]) + _add_component("feature_types", requires=["util"]) + feature = _add_component("feature", requires=["util", "feature_types", "geometry", "retrieval", "scene", "math", "sensor", "vlfeat", "flann::flann", "lz4::lz4"]) _add_component("geometry", requires=["util", "math"]) _add_component("image", requires=["util", "sensor", "scene", "lsd"]) _add_component("math", requires=["util", "metis::metis", "boost::graph"]) mvs = _add_component("mvs", requires=["util", "scene", "sensor", "image", "poisson_recon"]) _add_component("optim", requires=["math"]) _add_component("retrieval", requires=["math", "estimators", "optim", "flann::flann", "lz4::lz4"]) - _add_component("scene", requires=["util", "sensor", "feature", "geometry"]) + _add_component("scene", requires=["util", "sensor", "feature_types", "geometry"]) _add_component("sensor", requires=["util", "vlfeat", "freeimage::FreeImage", "ceres-solver::ceres"]) - _add_component("sfm", requires=["geometry", "image", "scene", "estimators"]) + _add_component("sfm", requires=["util", "geometry", "image", "scene", "estimators"]) _add_component("lsd", requires=[]) poisson_recon = _add_component("poisson_recon", requires=[]) vlfeat = _add_component("vlfeat", requires=[]) @@ -226,11 +226,15 @@ def _add_component(name, requires): mvs.requires.append("cgal::cgal") if self.options.gui: - _add_component("ui", requires=["util", "image", "scene", "controllers", "qt::Core", "qt::OpenGL", "qt::Widgets"]) + _add_component("ui", requires=["util", "image", "scene", "controllers", "qt::qtCore", "qt::qtOpenGL", "qt::qtWidgets"]) util.requires.extend(["qt::Core", "qt::OpenGL", "opengl::opengl"]) - feature.requires.extend(["qt::Widgets"]) + feature.requires.extend(["qt::qtWidgets"]) exe.requires.extend(["ui"]) + if self.options.openmp: + poisson_recon.requires.append("openmp::openmp") + vlfeat.requires.append("openmp::openmp") + if self.options.cuda: # CUDA dependencies are exported in the CMake module _add_component("util_cuda", requires=["util"]) From c5bd3c4f258fb3d8d11403788ba8da1b1dfc1e40 Mon Sep 17 00:00:00 2001 From: Martin Valgur Date: Mon, 5 Aug 2024 17:55:10 +0300 Subject: [PATCH 5/8] colmap: update to v3.10 --- recipes/colmap/all/conanfile.py | 2 +- recipes/colmap/config.yml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/recipes/colmap/all/conanfile.py b/recipes/colmap/all/conanfile.py index 4cf17d1802646..552c2abd51bf8 100644 --- a/recipes/colmap/all/conanfile.py +++ b/recipes/colmap/all/conanfile.py @@ -72,7 +72,7 @@ def layout(self): cmake_layout(self, src_folder="src") def requirements(self): - self.requires("boost/1.85.0", transitive_headers=True, transitive_libs=True) + self.requires("boost/1.84.0", transitive_headers=True, transitive_libs=True) # Ceres 2.2.0 is not compatible as of v3.10 self.requires("ceres-solver/2.1.0", transitive_headers=True, transitive_libs=True) self.requires("eigen/3.4.0", transitive_headers=True, transitive_libs=True) diff --git a/recipes/colmap/config.yml b/recipes/colmap/config.yml index 93869f48e8b23..2eb3a1757895d 100644 --- a/recipes/colmap/config.yml +++ b/recipes/colmap/config.yml @@ -1,3 +1,3 @@ versions: - "3.9.1": + "3.10": folder: all From 1dcf59dee5192acb1f88b085a401a7fc85bc163b Mon Sep 17 00:00:00 2001 From: Martin Valgur Date: Wed, 28 Aug 2024 15:52:12 +0300 Subject: [PATCH 6/8] Use a version range for Qt dependencies --- recipes/colmap/all/conanfile.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/recipes/colmap/all/conanfile.py b/recipes/colmap/all/conanfile.py index 552c2abd51bf8..019fe8f1314d4 100644 --- a/recipes/colmap/all/conanfile.py +++ b/recipes/colmap/all/conanfile.py @@ -87,7 +87,7 @@ def requirements(self): if self.options.cgal: self.requires("cgal/5.6.1") if self.options.gui: - self.requires("qt/5.15.13", transitive_headers=True, transitive_libs=True) + self.requires("qt/[~5.15]", transitive_headers=True, transitive_libs=True) if self.options.gui or self.options.cuda: self.requires("glew/2.2.0") self.requires("opengl/system") From 721321c328e961ec6d629138a1720b628a66aeb5 Mon Sep 17 00:00:00 2001 From: Martin Valgur Date: Thu, 17 Oct 2024 23:16:36 +0300 Subject: [PATCH 7/8] Use a version range for sqlite3 to match qt/6.x recipe --- recipes/colmap/all/conanfile.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/recipes/colmap/all/conanfile.py b/recipes/colmap/all/conanfile.py index 019fe8f1314d4..b6bb5683e16fc 100644 --- a/recipes/colmap/all/conanfile.py +++ b/recipes/colmap/all/conanfile.py @@ -80,7 +80,7 @@ def requirements(self): self.requires("freeimage/3.18.0") self.requires("glog/0.6.0", transitive_headers=True, transitive_libs=True) self.requires("metis/5.2.1") - self.requires("sqlite3/3.45.3", transitive_headers=True, transitive_libs=True) + self.requires("sqlite3/[>=3.45.0 <4]", transitive_headers=True, transitive_libs=True) self.requires("lz4/1.9.4") if self.options.openmp: self.requires("openmp/system", transitive_headers=True, transitive_libs=True) From 7e38f4b11e33181d6fc856f898ca1a86fdf852e3 Mon Sep 17 00:00:00 2001 From: Martin Valgur Date: Mon, 11 Nov 2024 19:26:46 +0200 Subject: [PATCH 8/8] colmap: improve Qt support, drop legacy Conan v1 logic --- recipes/colmap/all/conanfile.py | 43 +++++++++------------------------ 1 file changed, 11 insertions(+), 32 deletions(-) diff --git a/recipes/colmap/all/conanfile.py b/recipes/colmap/all/conanfile.py index b6bb5683e16fc..4c06f99e94308 100644 --- a/recipes/colmap/all/conanfile.py +++ b/recipes/colmap/all/conanfile.py @@ -1,16 +1,12 @@ import os from conan import ConanFile -from conan.errors import ConanInvalidConfiguration -from conan.tools.build import check_min_cppstd +from conan.tools.build import check_min_cppstd, can_run from conan.tools.cmake import CMake, CMakeDeps, CMakeToolchain, cmake_layout -from conan.tools.env import VirtualRunEnv, VirtualBuildEnv from conan.tools.files import copy, get, rm, rmdir, replace_in_file, load, save -from conan.tools.scm import Version required_conan_version = ">=1.53.0" - class ColmapConan(ConanFile): name = "colmap" description = ("COLMAP is a general-purpose Structure-from-Motion (SfM) and " @@ -43,20 +39,6 @@ class ColmapConan(ConanFile): "cuda_architectures": "all-major", } - @property - def _min_cppstd(self): - return 14 - - @property - def _compilers_minimum_version(self): - return { - "apple-clang": "10", - "clang": "7", - "gcc": "7", - "msvc": "191", - "Visual Studio": "15", - } - def export_sources(self): copy(self, "colmap-conan-vars.cmake.in", self.recipe_folder, self.export_sources_folder) @@ -87,7 +69,8 @@ def requirements(self): if self.options.cgal: self.requires("cgal/5.6.1") if self.options.gui: - self.requires("qt/[~5.15]", transitive_headers=True, transitive_libs=True) + # Qt6 is not supported + self.requires("qt/[~5.15]", transitive_headers=True, transitive_libs=True, run=can_run(self)) if self.options.gui or self.options.cuda: self.requires("glew/2.2.0") self.requires("opengl/system") @@ -95,17 +78,13 @@ def requirements(self): # self.requires("vlfeat/0.9.21", transitive_headers=True, transitive_libs=True) def validate(self): - if self.settings.compiler.get_safe("cppstd"): - check_min_cppstd(self, self._min_cppstd) - minimum_version = self._compilers_minimum_version.get(str(self.settings.compiler), False) - if minimum_version and Version(self.settings.compiler.version) < minimum_version: - raise ConanInvalidConfiguration( - f"{self.ref} requires C++{self._min_cppstd}, which your compiler does not support." - ) + check_min_cppstd(self, 14) def build_requirements(self): if self.options.cuda: self.tool_requires("cmake/[>=3.24 <4]") + if self.options.gui and not can_run(self): + self.tool_requires("qt/") def source(self): get(self, **self.conan_data["sources"][self.version], strip_root=True) @@ -142,12 +121,12 @@ def generate(self): deps.set_property("metis", "cmake_target_name", "metis") deps.generate() - VirtualBuildEnv(self).generate() - - # FIXME: this is a hack for Freeimage and Metis transitive dep shared libs not being found for some reason - VirtualRunEnv(self).generate(scope="build") - def _patch_sources(self): + replace_in_file(self, os.path.join(self.source_folder, "CMakeLists.txt"), + "set(CMAKE_CXX_STANDARD 14)", "") + replace_in_file(self, os.path.join(self.source_folder, "CMakeLists.txt"), + "set(CMAKE_CUDA_STANDARD 14)", "") + for module in self.source_path.joinpath("cmake").glob("Find*.cmake"): if module.name != "FindDependencies.cmake": module.unlink()