[CMake] Querying CMake variables of external CMake projects

Konstantin Tokarev annulen at yandex.ru
Sat Jan 13 12:06:25 EST 2018



13.01.2018, 06:26, "Saad Khattak" <saadrustam at gmail.com>:
> Hi,
>
> Say I find LibA using find_package(LibA) and I now have access to LibA_DIR, which is the build folder of LibA. Is there a way I can query additional variables, such as LibA's source directory, install directory etc. i.e. variables that are defined by CMake when LibA was being generated/built by CMake?

If  find_package(LibA) provides you target "LibA" (i.e., cmake code under "if (TARGET LibA)"
condition is being executed), you can query various properties from it and expect them to
have sane values. See documentation on cmake properties.

If there is no LibA target, it probably means that find_package(LibA) is implemented via
FindLibA.cmake module, and you can only use variables that it sets (usually documented in
the beginning of module)

>
> Thanks,
> Saad
> ,--
>
> 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:
> https://cmake.org/mailman/listinfo/cmake


-- 
Regards,
Konstantin


More information about the CMake mailing list