Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

cant find_package(Ceres REQUIRED) on macos !!! #1040

Open
chennuo0125-HIT opened this issue Jan 5, 2024 · 8 comments
Open

cant find_package(Ceres REQUIRED) on macos !!! #1040

chennuo0125-HIT opened this issue Jan 5, 2024 · 8 comments
Assignees

Comments

@chennuo0125-HIT
Copy link

macos version: Sonoma 14.2.1
problem:
I make install ceres-solver 2.1.0 from source, and find_package(Ceres REQUIRED) in cmakelist demo, and I got follow problem:

CMake Error at /opt/homebrew/Cellar/cmake/3.28.1/share/cmake/Modules/FindPackageHandleStandardArgs.cmake:230 (message):
  Could NOT find OpenMP_C (missing: OpenMP_C_FLAGS OpenMP_C_LIB_NAMES)
Call Stack (most recent call first):
  /opt/homebrew/Cellar/cmake/3.28.1/share/cmake/Modules/FindPackageHandleStandardArgs.cmake:600 (_FPHSA_FAILURE_MESSAGE)
  /opt/homebrew/Cellar/cmake/3.28.1/share/cmake/Modules/FindOpenMP.cmake:580 (find_package_handle_standard_args)
  /opt/homebrew/Cellar/cmake/3.28.1/share/cmake/Modules/CMakeFindDependencyMacro.cmake:76 (find_package)
  /opt/homebrew/lib/cmake/SuiteSparse_config/SuiteSparse_configConfig.cmake:68 (find_dependency)
  /opt/homebrew/Cellar/cmake/3.28.1/share/cmake/Modules/CMakeFindDependencyMacro.cmake:76 (find_package)
  /opt/homebrew/lib/cmake/CXSparse/CXSparseConfig.cmake:78 (find_dependency)
  /opt/homebrew/Cellar/cmake/3.28.1/share/cmake/Modules/CMakeFindDependencyMacro.cmake:76 (find_package)
  /usr/local/lib/cmake/Ceres/CeresConfig.cmake:182 (find_dependency)
  CMakeLists.txt:124 (find_package)

but if I install ceres-solver 2.2.0 , and the result is ok.

why does this problem happen ?

@chennuo0125-HIT
Copy link
Author

@sandwichmaker could you tell me why above problem occured ?

@sergiud
Copy link
Contributor

sergiud commented Jan 17, 2024

The error stems from your Homebrew version of SuiteSparse not from Ceres:

/opt/homebrew/lib/cmake/SuiteSparse_config/SuiteSparse_configConfig.cmake:68 (find_dependency)

For some reason, the OpenMP C component is not usable. You could check the CMake configure log to identify the issue.

@chennuo0125-HIT
Copy link
Author

@sergiud if not ceres proplem, why can i replace ceres version solve the problem ?

@chennuo0125-HIT
Copy link
Author

@sergiud ceres 2.1.0 is ok, but ceres 2.2.0 not ok

@chennuo0125-HIT
Copy link
Author

Three people around me have all experienced this problem,we just run "brew update" and the problem occurred, my home brew version: Homebrew 4.0.23-12-ge986264

@sergiud
Copy link
Contributor

sergiud commented Jan 17, 2024

While Ceres 2.1.0 supported OpenMP as one of the threading backends, Ceres 2.2.0 removed OpenMP support in 06bfe6f. This is likely the reason why the issue no longer occurs in Ceres 2.2.0. However, even in 2.1.0 Ceres did nothing special here:

find_package(OpenMP REQUIRED)

Therefore, I suggest reporting the issue to Homebrew or SuiteSparse maintainers. There seems to be a conflict in the way OpenMP components are requested and used. Relying on a language specific version of OpenMP in the dependency chain can generally cause problems, e.g., if a CMake project that enables the use of a CXX compiler only also depends on a component requiring a C compiler (and vice versa).

@chennuo0125-HIT
Copy link
Author

chennuo0125-HIT commented Jan 18, 2024

@sergiud how can i remove OpenMP support in ceres 2.1.0 ?

@sergiud
Copy link
Contributor

sergiud commented Jan 18, 2024

You could try explicitly setting the CERES_THREADING_MODEL CMake variable, e.g., to CXX_THREADS to avoid Ceres invoking the above find_package call. Alternatively, you can unconditionally set the threading backend to CXX_THREADS here:

macro(set_ceres_threading_model CERES_THREADING_MODEL_TO_SET)
if ("${CERES_THREADING_MODEL_TO_SET}" STREQUAL "CXX_THREADS")
set_ceres_threading_model_to_cxx11_threads()
elseif ("${CERES_THREADING_MODEL_TO_SET}" STREQUAL "OPENMP")
set_ceres_threading_model_to_openmp()
elseif ("${CERES_THREADING_MODEL_TO_SET}" STREQUAL "NO_THREADS")
set_ceres_threading_model_to_no_threads()
else()
include(PrettyPrintCMakeList)
find_available_ceres_threading_models(_AVAILABLE_THREADING_MODELS)
pretty_print_cmake_list(
_AVAILABLE_THREADING_MODELS ${_AVAILABLE_THREADING_MODELS})
message(FATAL_ERROR "Unknown threading model specified: "
"'${CERES_THREADING_MODEL_TO_SET}'. Available threading models for "
"this platform are: ${_AVAILABLE_THREADING_MODELS}")
endif()
message("-- Using Ceres threading model: ${CERES_THREADING_MODEL_TO_SET}")
endmacro()

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants