How to make CURL works with CMake

Source: Internet
Author: User

How to make CURL works with CMake

Recently, I want to learn CURL, so downloaded it and compiled it, and use
CMake to manage the project, I wrote a CMakelists.txt as below:

Cmake_minimum_required (VERSION 2.8) Project (curltest) Find_package (CURL required) include_directories (${curl_ Include_dir}) Set (sources appMain.cpp) add_executable (curltest ${sources}) target_link_libraries (Curltest ${curl_ Libriries})



But it does not work, and CMake reported the It can not find CURL, I met
This situation before, so I set the environment variable for cmake like this:

Set libcurl_root= "CURL ' s Path"

But it does not work neither, and I am confused, what is wrong with me, and
How could I make it works?
So I configured the environment variable Cplus_include_path to Libcurl ' s
Path, it did not work neither.
Finally, I open the file findcurl.cmake and check content, I found that the
Content didn ' t point the path of Libcurl out, so I-modified sentence in
Findcurl.cmake:

Find_path (Curl_include_dir    NAMES curl/curl.h)


To

Find_path (curl_include_dir    NAMES curl/curl.h    PATHS $ENV {libcurl_root}/include)


And the sentece in Findcurl.cmake

Find_library (curl_library NAMES    CURL  # Windows MSVC prebuilts:    curllib    libcurl_imp    curllib_ Static  # Windows older "win32-msvc" prebuilts (libcurl.lib, e.g. Libcurl-7.15.5-win32-msvc.zip):    


To


and run:
Cmkae. -G "MinGW makefiles", it worked.

The conclution:
1. Don ' t trust the libraries so much.
2. Think more.

How to make CURL works with CMake

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.