Finding and including/linking external projects generated by CMake

classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view
|

Finding and including/linking external projects generated by CMake

Saad Khattak
Hi,

Let's say I have a project I cloned from github which uses CMake to build. What is the best way to link to said dependency assuming the dependency is already built and installed [1].

So let's say I have LibA that is a dependency to my ProjA. LibA has already been built. What would be the 'correct' way to find and include/link against LibA?

Currently, I inspect the install/ directory of the libraries, then specify the paths for the headers/libraries/DLLs manually. 

However, considering the project has been built by CMake and CMake knows where the include/lib/DLL files are, I am hoping that there is a way to get another CMake project to use some auto-generated CMake files to figure out the location of the headers and libraries (and DLLs) so that ultimately, the command boils down to:

find_library(LibA Path/To/Install)
# CMake now gives me variables such as LibA_INCLUDE_DIRS, LibA_LIB_DIRS or similar
# so that I can easily include and link to the library

Thanks,
Saad

[1] And in case it matters, for all dependencies I override the CMAKE_INSTALL_PREFIX to be at the root of the dependency. So, if I build LibA located at D:/Deps/LibA, the install folder will be D:/Deps/LibA/install/.  

--

Powered by www.kitware.com

Please keep messages on-topic and check the CMake FAQ at: http://www.cmake.org/Wiki/CMake_FAQ

Kitware offers various services to support the CMake community. For more information on each offering, please visit:

CMake Support: http://cmake.org/cmake/help/support.html
CMake Consulting: http://cmake.org/cmake/help/consulting.html
CMake Training Courses: http://cmake.org/cmake/help/training.html

Visit other Kitware open-source projects at http://www.kitware.com/opensource/opensource.html

Follow this link to subscribe/unsubscribe:
http://public.kitware.com/mailman/listinfo/cmake