Skip to content

Commit

Permalink
Fix detection of suitesparse >=7.7
Browse files Browse the repository at this point in the history
  • Loading branch information
jlblancoc committed Jun 7, 2024
1 parent 912e484 commit 5832b55
Show file tree
Hide file tree
Showing 5 changed files with 35 additions and 10 deletions.
2 changes: 2 additions & 0 deletions .github/workflows/build-macos.yml
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,8 @@ jobs:
brew install nasm
brew install eigen
brew install opencv
brew install suite-sparse
brew ls suite-sparse
brew install assimp
echo "CC=clang" >> $GITHUB_ENV
echo "CXX=clang++" >> $GITHUB_ENV
Expand Down
11 changes: 11 additions & 0 deletions cmakemodules/FindSuiteSparse.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -138,6 +138,16 @@ macro(SuiteSparse_FIND_COMPONENTS )
set(suitesparseComp_ALT "cs") # Alternative name of CXSparse
endif()


if (APPLE)
# /opt/homebrew/Cellar/suite-sparse/7.7.0/include/suitesparse/cs.h
file(GLOB_RECURSE SUITESPARSE_CS_H_FILE /opt/homebrew/Cellar/cs.h)
get_filename_component(SUITESPARSE_CS_H_DIR "${SUITESPARSE_CS_H_FILE}" DIRECTORY)

message(STATUS "SUITESPARSE_CS_H_DIR: ${SUITESPARSE_CS_H_DIR}")
endif()


## try to find include dir (looking for very important header file)
find_path(SuiteSparse_${suitesparseCompUC}_INCLUDE_DIR
NAMES ${suitesparseComp}.h ${suitesparseCompLC}.h ${suitesparseCompUC}.h ${suitesparseComp_ALT}.h
Expand All @@ -157,6 +167,7 @@ macro(SuiteSparse_FIND_COMPONENTS )
${${suitesparseCompUC}_DIR}/include
${${suitesparseCompUC}_DIR}/${suitesparseComp}/include
${${suitesparseCompUC}_DIR}
${SUITESPARSE_CS_H_DIR}/
)
## check if found
if(NOT SuiteSparse_${suitesparseCompUC}_INCLUDE_DIR)
Expand Down
2 changes: 1 addition & 1 deletion cmakemodules/script_show_final_summary.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -142,7 +142,7 @@ SHOW_CONFIG_LINE_SYSTEM("OpenGL EGL " CMAKE_MRPT_HAS_EG
SHOW_CONFIG_LINE_SYSTEM("OpenGL GLES " CMAKE_MRPT_HAS_GLES "[Version: ${GLESV2_VERSION}]")
SHOW_CONFIG_LINE_SYSTEM("GLUT " CMAKE_MRPT_HAS_GLUT)
SHOW_CONFIG_LINE_SYSTEM("PCAP (Wireshark logs for Velodyne) " CMAKE_MRPT_HAS_LIBPCAP)
SHOW_CONFIG_LINE_SYSTEM("SuiteSparse " CMAKE_MRPT_HAS_SUITESPARSE)
SHOW_CONFIG_LINE_SYSTEM("SuiteSparse " CMAKE_MRPT_HAS_SUITESPARSE "[Version: ${SuiteSparse_VERSION}]")
SHOW_CONFIG_LINE_SYSTEM("tinyxml2 " CMAKE_MRPT_HAS_TINYXML2)
SHOW_CONFIG_LINE_SYSTEM("wxWidgets " CMAKE_MRPT_HAS_WXWIDGETS "[Version: ${wxWidgets_VERSION_STRING} ${CMAKE_WXWIDGETS_TOOLKIT_NAME}]")
message(STATUS "")
Expand Down
13 changes: 10 additions & 3 deletions cmakemodules/script_suitesparse.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,7 @@ if(NOT SuiteSparse_FOUND)
if(SUITESPARSE_USE_FIND_MODULE)
set(SuiteSparse_VERBOSE OFF)
find_package(SuiteSparse QUIET) # 2nd: Use FindSuiteSparse.cmake module
include_directories(${SuiteSparse_INCLUDE_DIRS})
endif(SUITESPARSE_USE_FIND_MODULE)
endif()
else()
if($ENV{VERBOSE})
message(STATUS "Find SuiteSparse : include(${USE_SuiteSparse})")
Expand All @@ -30,7 +29,15 @@ endif()

if(SuiteSparse_FOUND)
if($ENV{VERBOSE})
message(STATUS "SuiteSparse_LIBS: ${SuiteSparse_LIBRARIES}")
message(STATUS "SuiteSparse_LIBRARIES : ${SuiteSparse_LIBRARIES}")
message(STATUS "SuiteSparse_INCLUDE_DIRS : ${SuiteSparse_INCLUDE_DIRS}")
if (TARGET SuiteSparse::CXSparse)
set(x_ "DOES exist")
else()
set(x_ "Does NOT exist")
endif()
message(STATUS "SuiteSparse::CXSparse : ${x_}")
unset(x_)
endif()

set(CMAKE_MRPT_HAS_SUITESPARSE 1)
Expand Down
17 changes: 11 additions & 6 deletions libs/math/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -82,12 +82,17 @@ if(BUILD_mrpt-math)
# nanoflann:
target_link_libraries(math PUBLIC nanoflann::nanoflann)

if (NOT "${SuiteSparse_LIBRARIES}" STREQUAL "")
target_link_libraries(math PRIVATE ${SuiteSparse_LIBRARIES})
endif ()
if (NOT "${SuiteSparse_LIBRARIES}" STREQUAL "")
target_include_directories(math PUBLIC ${SuiteSparse_INCLUDE_DIRS})
endif ()
if (TARGET SuiteSparse::CXSparse)
# Modern cmake interface?
target_link_libraries(math PUBLIC SuiteSparse::CXSparse)
else()
if (NOT "${SuiteSparse_LIBRARIES}" STREQUAL "")
target_link_libraries(math PRIVATE ${SuiteSparse_LIBRARIES})
endif ()
if (NOT "${SuiteSparse_LIBRARIES}" STREQUAL "")
target_include_directories(math PUBLIC ${SuiteSparse_INCLUDE_DIRS})
endif ()
endif()

# Minimize debug info for this module:
#mrpt_reduced_debug_symbols(math)
Expand Down

0 comments on commit 5832b55

Please sign in to comment.