[CMake] generator expressions

Micha Renner Micha.Renner at t-online.de
Wed Apr 8 03:26:17 EDT 2015


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





More information about the CMake mailing list