Hi,
i am trying the example of the Output Expressions from here:
 
https://cmake.org/cmake/help/v3.5/manual/cmake-generator-expressions.7.html
 
But i have problems getting it working. It either fails with
 
ninja: error: build.ninja:83: bad $-escape (literal $ must be written as $$)
  COMMAND = cd /tmp/bug/build && /usr/bin/c++ -E -P -MMD -I$<JOIN:$ -I> ...
                                                           ^ near here

if i omit the start and end quote of the -I$<JOIN... statement or it fails to build my example because of the escaped space in -I/tmp\ -I
 
[1/1] cd /tmp/bug/build && /usr/bin/c++ -E -P -MMD -I/tmp\ -I/tmp/bug/build dummy.cpp -o dummy.i
FAILED: cd /tmp/bug/build && /usr/bin/c++ -E -P -MMD -I/tmp\ -I/tmp/bug/build dummy.cpp -o dummy.i
dummy.cpp:1:19: fatal error: dummy.h: No such file or directory
 
Removing the backslash in build.ninja with escaped version it works. I attached a reproducer. I tried it with linux. Run it in a build directory with

cmake -GNinja <path_to_cmakefile>
ninja custom
 
What am i doing wrong or is it a bug?
 Jerry
 
## reproducer ##
cmake_minimum_required(VERSION 3.2)
add_library(dummy dummy.cpp)
target_include_directories(dummy PUBLIC /tmp)
target_include_directories(dummy PUBLIC ${CMAKE_BINARY_DIR})
add_custom_target(custom
  ${CMAKE_CXX_COMPILER} -E -P -MMD
  "-I$<JOIN:$<TARGET_PROPERTY:dummy,INCLUDE_DIRECTORIES>, -I>"
  dummy.cpp -o dummy.i
)
FILE(WRITE ${CMAKE_BINARY_DIR}/dummy.cpp "#include <dummy.h>\nint main(void){return 0;}\n")
FILE(WRITE ${CMAKE_BINARY_DIR}/dummy.h "void foo() {}\n")
 
-- 

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-developers

Reply via email to