[CMake] generator expressions

Robert Maynard robert.maynard at kitware.com
Wed Apr 8 11:34:34 EDT 2015


Hi Micha,

When using generator expressions inside target_include_directories you must
qualify all paths. Either by using absolute paths, or using one of the
helper variables that allows CMake to determine where the relative path
should be evaluated from.

This is all really well documented at:
http://www.cmake.org/cmake/help/v3.2/manual/cmake-buildsystem.7.html#include-directories-and-usage-requirements

On Wed, Apr 8, 2015 at 3:26 AM, Micha Renner <Micha.Renner at t-online.de>
wrote:

> Hi,
>
> I try to understand the concept of generator expressions with little
> avail.
>
> For the current project I thought, I could use them in combination with
> TARGET_INCLUDE_DIRECTORIES.
> Instead of writting
> IF(t1)
>         TARGET_INCLUDE_DIRECTORIES(cTest PRIVATE path/to/h1 PRIVATE
> path/to/h2)
> ELSE(t1)
>         TARGET_INCLUDE_DIRECTORIES(cTest PRIVATE path/to/h1)
> ENDIF(t1)
>
> it should be more elegant
>
> SET(t1 ON)
> ADD_EXECUTABLE(cTest CTest.c cTest.h)
> TARGET_INCLUDE_DIRECTORIES(cTest PRIVATE path/to/h1 $<
> $<BOOL:t1>:"PRIVATE path/to/h2")
>
> Of course this creates a major disaster.
>
> --------------------------
> CMake Warning (dev) in CMakeLists.txt:
>   Policy CMP0021 is not set: Fatal error on relative paths in
>   INCLUDE_DIRECTORIES target property.  Run "cmake --help-policy
> CMP0021" for
>   policy details.  Use the cmake_policy command to set the policy and
>   suppress this warning.
>
>   Found relative path while evaluating include directories of "cTest":
>
>     ""PRIVATE path/to/h2""
>
> This warning is for project developers.  Use -Wno-dev to suppress it.
>
> cmake:
> /home/gildemeister/Picture/work-c/CMakeSrc/cmake-3.2.1/Source/cmLocalGenerator.cxx:2923:
> std::string cmLocalGenerator::ConvertToRelativePath(const
> std::vector<std::basic_string<char> >&, const string&, bool): Assertion
> `in_remote[0] != '\"'' failed.
> Abgebrochen (Speicherabzug geschrieben)
> --------------------------
>
> Is there a way to solve this with a generator expression?
>
> Michael
>
>
>
> --
>
> 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
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://public.kitware.com/pipermail/cmake/attachments/20150408/8243ffd7/attachment.html>


More information about the CMake mailing list