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

Could NOT find CURL cmake error, when using a cmake package manager, and including curl already #790

Closed
2 tasks
bsergean opened this issue Jan 18, 2023 · 4 comments

Comments

@bsergean
Copy link

Description

Our C++ build system uses cpm (which is based on cmake FetchContent). We bring in curl that way (with cpm), and after that we include sentry with cpm (see in the repro steps). When doing so we get a could not find curl cmake error.

This is a chicken and eggs problem, but maybe it could be solved. For some reason I didn't get it on my mac version which uses a more recent cmake.

When does the problem happen

  • [x ] During build
  • During run-time
  • When capturing a hard crash

Environment

  • OS: linux
  • Compiler: gcc-11
  • CMake version and config: [, SENTRY_BACKEND=breakpad]

Steps To Reproduce

set(sentry_version 5.3.0)
cpmaddpackage(
  NAME
  sentry
  VERSION
  ${sentry_version}
  OPTIONS
  "BUILD_SHARED_LIBS OFF"
  "SENTRY_TRANSPORT curl"   # Should be the default
  "SENTRY_BACKEND breakpad" # we could try crashpad, but it might have more dependencies 
  GIT_REPOSITORY
  "https://github.com/getsentry/sentry-native"
  GIT_TAG
  ${sentry_version})

then somewhere in your project, do `target_link_libraries(myproject sentry::sentry)

Log output

-- SENTRY_SDK_NAME=
CMake Error at /usr/local/cmake-3.21.4-linux-x86_64/share/cmake-3.21/Modules/FindPackageHandleStandardArgs.cmake:230 (message):
  Could NOT find CURL (missing: CURL_LIBRARY CURL_INCLUDE_DIR)
Call Stack (most recent call first):
  /usr/local/cmake-3.21.4-linux-x86_64/share/cmake-3.21/Modules/FindPackageHandleStandardArgs.cmake:594 (_FPHSA_FAILURE_MESSAGE)
  /usr/local/cmake-3.21.4-linux-x86_64/share/cmake-3.21/Modules/FindCURL.cmake:181 (find_package_handle_standard_args)
  build/_deps/sentry-src/CMakeLists.txt:277 (find_package)
@bsergean
Copy link
Author

I think the fact that it builds fine on macOS is because the developer tools include a curl headers + a curl library.

/Library/Developer/CommandLineTools/SDKs/MacOSX13.1.sdk/usr/include/curl/curl.h
/Library/Developer/CommandLineTools/SDKs/MacOSX12.3.sdk/usr/include/curl/curl.h

Maybe we should just install curl-dev with apt-get.

@supervacuus
Copy link
Collaborator

Maybe we should just install curl-dev with apt-get.

That is probably the quickest fix.

While I haven't worked with cpm yet, I would imagine that one could either set result variables like FindCURL does from the cpm-package configuration to let other packages add libcurl as if it was found via find_package. We also query the CURL_FOUND result variable not to let find_package run again if libcurl was already configured.

The other option would be to pass CMAKE_PREFIX_PATH into your sentry-native package configuration, with whatever the libcurl cpm-package provides as its build output.

@bsergean
Copy link
Author

bsergean commented Jan 20, 2023 via email

@bsergean
Copy link
Author

Setting CURL_FOUND to ON did the trick !

(Not sure how/whether this should be added to the doc)

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