curl / Mailing Lists / curl-library / Single Mail

curl-library

Re: CMake - How to best include libcurl

From: Noam Chitayat via curl-library <curl-library_at_cool.haxx.se>
Date: Thu, 13 Jul 2017 15:10:47 +0000

Thanks, Sergei. I actually did find a fix for that issue, thanks to a CMake
expert on the CPPLang Slack.
"set" on its own doesn't override config options, but the CACHE flag allows
it to.

Changing my "set" calls like so, I was able to include curl successfully:
```
set(HTTP_ONLY ON CACHE BOOL "")
set(CMAKE_USE_OPENSSL OFF CACHE BOOL "")
set(BUILD_CURL_EXE OFF CACHE BOOL "")
set(CURL_STATICLIB ON CACHE BOOL "")
set(CURL_ZLIB OFF CACHE BOOL "")
set(CMAKE_USE_LIBSSH2 OFF CACHE BOOL "")
```

On Thu, Jul 13, 2017 at 4:37 AM Sergei Nikulov via curl-library <
curl-library_at_cool.haxx.se> wrote:

> 2017-07-12 18:24 GMT+03:00 Nick Chambers via curl-library
> <curl-library_at_cool.haxx.se>:
> >
> > On Wed, Jul 12, 2017 at 8:21 AM Noam Chitayat via curl-library
> > <curl-library_at_cool.haxx.se> wrote:
> >>
> >> Hey folks!
> >>
> >> For the past little while, I've had curl statically linked into a
> project.
> >> The project Makefile invokes the autoconf script in curl and produces a
> >> static library. I'm now switching to CMake, but running into problems.
> >>
> >> My CMakeLists.txt has the following commands:
> >>
> >> ```
> >> set(HTTP_ONLY ON)
> >> set(CMAKE_USE_OPENSSL OFF)
> >> set(BUILD_CURL_EXE OFF)
> >> set(CURL_STATICLIB ON)
> >> set(CURL_ZLIB OFF)
> >> set(CMAKE_USE_LIBSSH2 OFF)
> >>
> >> add_subdirectory(curl)
> >> ```
> >
> >
> > Correct me if I'm wrong (I'm on mobile and it's been a while since I've
> done
> > CMAKE), but isn't set used for internal CMAKE variables, not preprocessor
> > directives/configure switches?
> >
>
> Nicholas, definitely.
> I believe it was from the time when CMake's folks create initial
> integration with curl.
>
> Noam, it is the bug.
> Unfortunately, options will be overridden in curl's CMakeLists.txt
> with variable 'openssl_default' which is 'ON' by default for
> Linux/Unix platforms.
>
> >
> > Nicholas Chambers
> >
> >
> > -------------------------------------------------------------------
> > Unsubscribe: https://cool.haxx.se/list/listinfo/curl-library
> > Etiquette: https://curl.haxx.se/mail/etiquette.html
>
>
>
> --
> Best Regards,
> Sergei Nikulov
> -------------------------------------------------------------------
> Unsubscribe: https://cool.haxx.se/list/listinfo/curl-library
> Etiquette: https://curl.haxx.se/mail/etiquette.html

-------------------------------------------------------------------
Unsubscribe: https://cool.haxx.se/list/listinfo/curl-library
Etiquette: https://curl.haxx.se/mail/etiquette.html
Received on 2017-07-13