Skip to content

Commit

Permalink
g2o: more robust SuiteSparse detection
Browse files Browse the repository at this point in the history
  • Loading branch information
valgur committed Jul 8, 2024
1 parent ea4da53 commit f88b2cf
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 8 deletions.
8 changes: 8 additions & 0 deletions recipes/g2o/all/FindSuiteSparse.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
# Simplified replacement for https://github.com/RainerKuemmerle/g2o/blob/master/cmake_modules/FindSuiteSparse.cmake

if (G2O_USE_CHOLMOD)
find_package(CHOLMOD REQUIRED CONFIG)
add_library(SuiteSparse::Partition ALIAS SuiteSparse::CHOLMOD)
set(SuiteSparse_FOUND TRUE)
set(SuiteSparse_CHOLMOD_FOUND TRUE)
endif()
10 changes: 2 additions & 8 deletions recipes/g2o/all/conanfile.py
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,7 @@ def _compilers_minimum_version(self):

def export_sources(self):
export_conandata_patches(self)
copy(self, "FindSuiteSparse.cmake", self.recipe_folder, self.export_sources_folder)

def config_options(self):
if self.settings.os == "Windows":
Expand Down Expand Up @@ -180,14 +181,6 @@ def generate(self):
tc.variables["DISABLE_SSE4_2"] = not self.options.sse4_2
tc.variables["DISABLE_SSE4_A"] = not self.options.sse4_a

if self.options.with_cholmod:
tc.variables["CMAKE_FIND_LIBRARY_PREFIXES"] = ";".join([
dep.package_folder.replace("\\", "/")
for dep_name, dep in self.dependencies.items() if dep_name.ref.name.startswith("suitesparse-")
])
# Newest CHOLMOD uses vendored METIS with renamed symbols, which FindSuiteSparse.cmake fails to detect
tc.variables["SuiteSparse_CHOLMOD_USES_METIS"] = True

tc.generate()

deps = CMakeDeps(self)
Expand All @@ -198,6 +191,7 @@ def generate(self):

def _patch_sources(self):
apply_conandata_patches(self)
copy(self, "FindSuiteSparse.cmake", self.export_sources_folder, os.path.join(self.source_folder, "cmake_modules"))
save(self, os.path.join(self.source_folder, "g2o", "EXTERNAL", "CMakeLists.txt"), "")
replace_in_file(self, os.path.join(self.source_folder, "CMakeLists.txt"),
"find_package(CSparse)", "find_package(CSPARSE)")
Expand Down

0 comments on commit f88b2cf

Please sign in to comment.