[CMake] How to link against libraries in subdirectory (windows workaround)

Alexander Neundorf a.neundorf-work at gmx.net
Mon Oct 31 15:54:12 EDT 2011


On Saturday 29 October 2011, Renato Utsch wrote:
> Hello!
> 
> Well, I am currently using cURL for a project of mine, but on windows I
> can't find the cURL library only using the find_package(CURL) provided with
> CMake, although it works fine with linux.
> 
> So, I created a directory named "deps" in my source directory. How can I
> make the find_package to look at this directory before looking at the
> default directories? Like:
> 
> # Look firstly at the /deps directory, if finds the libcurl.a and the
> include/curl folder set the CURL_FOUND macro and the other ones that the
> find_package() automatically provides...

You can set CMAKE_PREFIX_PATH so that it looks first in that subdir and then 
in the default dirs:

set(CMAKE_PREFIX_PATH ${CMAKE_PREFIX_PATH} ${CMAKE_SOURCE_DIR}/deps/ )

find_package(curl)
...etc.

Alex


More information about the CMake mailing list