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