Querying CMake variables of external CMake projects

classic Classic list List threaded Threaded
3 messages Options
Reply | Threaded
Open this post in threaded view
|

Querying CMake variables of external CMake projects

Saad Khattak
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?

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
Reply | Threaded
Open this post in threaded view
|

Re: Querying CMake variables of external CMake projects

Konstantin Tokarev


13.01.2018, 06:26, "Saad Khattak" <[hidden email]>:
> 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
--

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
Reply | Threaded
Open this post in threaded view
|

Re: Querying CMake variables of external CMake projects

Saad Khattak
Thank you Konstantin. get_target_properties(...) works very well.

On Sat, Jan 13, 2018 at 12:06 PM Konstantin Tokarev <[hidden email]> wrote:


13.01.2018, 06:26, "Saad Khattak" <[hidden email]>:
> 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

--

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