[CMake] Generator Expressions and FetchContent

Saad Khattak saadrustam at gmail.com
Sun Mar 18 12:44:52 EDT 2018


Absolutely. Please find the example project here:
https://github.com/samaursa/cmake_fetch_content_and_generator_expressions

The repository README also includes the output from running `./setup.sh`.

On Sat, Mar 17, 2018 at 6:47 PM Craig Scott <craig.scott at crascit.com> wrote:

> Can you provide a small project example that can be used to demonstrate
> your problem? The specifics of how you are doing things may be important.
>
>
> On Sun, Mar 18, 2018 at 8:12 AM, Saad Khattak <saadrustam at gmail.com>
> wrote:
>
>> Hi,
>>
>> ExternalProject_Add builds, generates and installs and thus any generator
>> expressions used will be expanded by the time another library uses it.
>>
>> For example, if I add a library LibA using ExternalProject_Add, I can
>> then query the target property INTERFACE_INCLUDE_DIRECTORIES and get the
>> include directory for the library:
>>
>> get_target_property(LibA_INCLUDE_DIRECTORIES LibA
>>   INTERFACE_INCLUDE_DIRECTORIES
>>   )
>>
>> This allows me to then use the variable LibA_INCLUDE_DIRECTORIES in my
>> CMake include(...) statements. However, with FetchContent, this is no
>> longer possible.
>>
>> The reason I would like to query a variable is because at project
>> generation time, I invoke FetchContent only if LibA is not found by
>> find_package(LibA).
>>
>> Thus, the include directory for LibA may be in the current build
>> directory (through FetchContent) OR it may be found in the folder where
>> LibA is cloned by the user and generated/built OR an INSTALL of LibA.
>>
>> Perhaps I should not be using `get_target_property` to get the a
>> library's include directory? Either way, would like some guidance in
>> solving this issue.
>>
>> Thank you,
>> 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
>>
>>
>
>
> --
> Craig Scott
> Melbourne, Australia
> https://crascit.com
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://cmake.org/pipermail/cmake/attachments/20180318/fe2adf42/attachment.html>


More information about the CMake mailing list