[cmake-developers] generator expressions with variable

Tim Blechmann tim at klingt.org
Sun Apr 20 04:12:42 EDT 2014


>> $<1:-I $<JOIN:a;b;c , -I>>
>>
>> though it does not matter, if the target is passed via variable or
>> directly.
>>
>> any idea?
>>
> 
> 
> Please provide a http://www.sscce.org/

see attached file!

origin/master gives me:
tim at moka-mac:~/dev/x/y$ ~/dev/cmake/bin/cmake -GNinja .. && ninja
-- The C compiler identification is AppleClang 5.1.0.5030040
-- The CXX compiler identification is AppleClang 5.1.0.5030040
-- Check for working C compiler using: Ninja
-- Check for working C compiler using: Ninja -- works
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - done
-- Check for working CXX compiler using: Ninja
-- Check for working CXX compiler using: Ninja -- works
-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - done
-- Configuring done
-- Generating done
-- Build files have been written to: /Users/tim/dev/x/y
ninja: error: build.ninja:53: bad $-escape (literal $ must be written as $$)
  PRE_LINK = cd /Users/tim/dev/x/y && echo $<1:-I$<JOIN:$ -I>> && cd /Us...
                                           ^ near here

same applies to 2.8.12.2.

the genex is:
$<$<BOOL:$<TARGET_PROPERTY:foo,INCLUDE_DIRECTORIES>>:-I$<JOIN:$<TARGET_PROPERTY:foo,INCLUDE_DIRECTORIES>,
-I>>


changing the genex to:
$<$<BOOL:$<TARGET_PROPERTY:foo,INCLUDE_DIRECTORIES>>:-I$<JOIN:
$<TARGET_PROPERTY:foo,INCLUDE_DIRECTORIES> , -I>>

it expands to:
$<1:-I$<JOIN: /Users/tim/dev/x/a;/Users/tim/dev/x/b;/Users/tim/dev/x/c ,
-I>>

hth,
tim
-------------- next part --------------
cmake_minimum_required(VERSION 2.8)


add_library(foo foo.cpp)
target_include_directories(foo PUBLIC a b c)

add_custom_command(
  TARGET foo
  PRE_BUILD
  COMMAND echo $< $<BOOL:$<TARGET_PROPERTY:foo,INCLUDE_DIRECTORIES>> :-I$<JOIN: $<TARGET_PROPERTY:foo,INCLUDE_DIRECTORIES> , -I>>
)


More information about the cmake-developers mailing list