Problem with findpackage(CURL REQUIRED) and precompiled curl 7.68.0 for Windows


I am using CMake 3.16.3 and having problems with the provided FindCurl.cmake script.
I have unzipped the precompiled version downloaded from the curl website in a given location and set both CMAKE_PREFIX_PATH and CMAKE_MODULE_PATH to that location.

CMake can locate the version and header files just fine, but fails with the library:
Could NOT find CURL (missing: CURL_LIBRARY) (found version "7.68.0")

I think it might be due to the fact that the precompiled package contains libcurl.a and libcurl.dll.a, while I am building with Visual Studio? However, since curl is a C Library, that should not be a problem.
Is this considered to be a bug in FindCurl.cmake or any tips on how I can make it correctly locate the library?

I restested with CMake 3.17.0-rc1 and it’s the same behavior.

The problem is effectively about the library suffix. Your package was built with mingw64 toolchain which use .dll.a as extension for import library and .a for static library.

With Visual Studio toolchain, expected extension for import and static libraries is .lib.
Try to extend variable CMAKE_FIND_LIBRARY_SUFFIXES with your suffixes.


It won’t help you directly here, but in case others come across this thread later or those generating the curl packages are interested, the GNUtoMS target property can be used to direct CMake to also generate a .lib from the .dll.a file. This would need to be done when building the library, not consuming it though and it requires the Visual Studio tools to be available.