Separating spaces are escaped by JOIN generator expression

classic Classic list List threaded Threaded
4 messages Options
Reply | Threaded
Open this post in threaded view
|

Separating spaces are escaped by JOIN generator expression

Andrey Pokrovskiy
Let's say:
set(WORDS "cat" "dog")
and then:
"<JOIN:${WORDS}, >"
which will produce "cat\ dog" instead of "cat dog".
Looks like a bug to me.

Minimal example to reproduce the issue.

File - CMakeLists.txt:

cmake_minimum_required(VERSION 3.1)

project(escape_me_not)

set(WORDS "cat" "dog")

add_custom_command(OUTPUT cage.zip COMMAND zip cage.zip "<JOIN:${WORDS}, >")

add_custom_target(escape_me_not ALL DEPENDS cage.zip)

File - cat:
A cat

File - dog:
A dog

After calling cmake in CMakeFiles/escape_me_not.dir/build.make:

zip cage.zip cat\ dog

After calling make:

zip warning: name not matched: cat dog

Does any workaround exists for that? Should I file a bug?


--

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
Reply | Threaded
Open this post in threaded view
|

Re: Separating spaces are escaped by JOIN generator expression

Dakeryas
I am facing the exact same issue when when joining libraries from a target for some CMake function defined by the Cern ROOT library (ROOT_GENERATE_DICTIONARY in that case). I am defining a list: list(APPEND DICTIONARY_INCLUDES " -I$<JOIN:$<TARGET_PROPERTY:MyLIBRARY,INTERFACE_INCLUDE_DIRECTORIES>, -I>") which is then passed to the ROOT function. I can see from the build error that all the includes have a backslash appended, i.e.: ... -I/home/user/lib1/include/\ -I/home/user/lib2/include/\ -I... The BUILD_INTERFACE vs INSTALL_INTERFACE is respected, everything seems to work aside from these nasty backlashes... If I save the command manually after seeing the error and perform a string replacement to remove the backlashes, I get the desired result. Is there any fix five years later?

Sent from the CMake mailing list archive at Nabble.com.

--

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
Reply | Threaded
Open this post in threaded view
|

Re: Separating spaces are escaped by JOIN generator expression

Marc CHEVRIER
If you want to define a list, try to use $<SEMICOLON> rather than a space to separate the items. This way, you will get a CMake list rather than a string: list(APPEND DICTIONARY_INCLUDES "-I$<JOIN:$<TARGET_PROPERTY:MyLIBRARY,INTERFACE_INCLUDE_DIRECTORIES>,$<SEMICOLON>-I>")
Le 5 août 2019 à 22:56 +0200, Dakeryas <[hidden email]>, a écrit :
I am facing the exact same issue when when joining libraries from a target for some CMake function defined by the Cern ROOT library (ROOT_GENERATE_DICTIONARY in that case). I am defining a list: list(APPEND DICTIONARY_INCLUDES " -I$<JOIN:$<TARGET_PROPERTY:MyLIBRARY,INTERFACE_INCLUDE_DIRECTORIES>, -I>") which is then passed to the ROOT function. I can see from the build error that all the includes have a backslash appended, i.e.: ... -I/home/user/lib1/include/\ -I/home/user/lib2/include/\ -I... The BUILD_INTERFACE vs INSTALL_INTERFACE is respected, everything seems to work aside from these nasty backlashes... If I save the command manually after seeing the error and perform a string replacement to remove the backlashes, I get the desired result. Is there any fix five years later?

Sent from the CMake mailing list archive at Nabble.com.
--

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

--

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
Reply | Threaded
Open this post in threaded view
|

Re: Separating spaces are escaped by JOIN generator expression

Marc CHEVRIER
This is the way to proceed...
Le 6 août 2019 à 17:23 +0200, Unknown Unknown <[hidden email]>, a écrit :
I am getting a further by combining your idea with a "add_custom_command" and using the "COMMAND_EXPAND_LISTS" trick I have just discovered. Essentially I have something like the following to get the desired results:

list(APPEND DICTIONARY_INCLUDES "-I$<JOIN:$<TARGET_PROPERTY:MyLibrary,INTERFACE_INCLUDE_DIRECTORIES>,$<SEMICOLON>-I>")

add_custom_command(
    OUTPUT ${DICTIONARY_SOURCE}
    COMMAND rootcling -f ${DICTIONARY_SOURCE}
                      -rml lib${PROJECT_NAME}.so
                      -rmf lib${PROJECT_NAME}.rootmap
                      -s lib${PROJECT_NAME}.so
                      -inlineInputHeader
                      "${DICTIONARY_INCLUDES}"
                      -I${CMAKE_CURRENT_SOURCE_DIR} ${DICTIONARY_HEADERS}
                      ${CMAKE_CURRENT_SOURCE_DIR}/${DICTIONARY_LINKDEF}
    DEPENDS  MyLibrary ${DICTIONARY_HEADERS} ${DICTIONARY_LINKDEF}
    COMMAND_EXPAND_LISTS
)

Le mar. 6 août 2019 à 02:56, Marc CHEVRIER <[hidden email]> a écrit :
Oops, I mean: $<SEMICOLON> To generate a semi-colon character (I.e.  ‘;’)
Le 6 août 2019 à 00:08 +0200, Unknown Unknown <[hidden email]>, a écrit :
Bonjour Marc,

Thanks for the reply! Now I get:
(add_custom_command):
  Error evaluating generator expression:

    $<SEMILOCON>

  Expression did not evaluate to a known generator expression

I am really just trying to join the INTERFACE_INCLUDE_DIRECTORIES of my target with the "- I" compiler include flags... I have since noticed that I don't get a list indeed, and that:
set(DICTIONARY_INCLUDES  " -I$<JOIN:$<TARGET_PROPERTY:MyLibrary,INTERFACE_INCLUDE_DIRECTORIES>, -I>")
does the exact same thing, i.e. the Make/Ninja command is almost perfect if it were not for those backslashes coming out of nowhere at the end of each include path!

Le lun. 5 août 2019 à 17:26, Marc CHEVRIER <[hidden email]> a écrit :
If you want to define a list, try to use $<SEMICOLON> rather than a space to separate the items. This way, you will get a CMake list rather than a string: list(APPEND DICTIONARY_INCLUDES "-I$<JOIN:$<TARGET_PROPERTY:MyLIBRARY,INTERFACE_INCLUDE_DIRECTORIES>,$<SEMICOLON>-I>")
Le 5 août 2019 à 22:56 +0200, Dakeryas <[hidden email]>, a écrit :
I am facing the exact same issue when when joining libraries from a target for some CMake function defined by the Cern ROOT library (ROOT_GENERATE_DICTIONARY in that case). I am defining a list: list(APPEND DICTIONARY_INCLUDES " -I$<JOIN:$<TARGET_PROPERTY:MyLIBRARY,INTERFACE_INCLUDE_DIRECTORIES>, -I>") which is then passed to the ROOT function. I can see from the build error that all the includes have a backslash appended, i.e.: ... -I/home/user/lib1/include/\ -I/home/user/lib2/include/\ -I... The BUILD_INTERFACE vs INSTALL_INTERFACE is respected, everything seems to work aside from these nasty backlashes... If I save the command manually after seeing the error and perform a string replacement to remove the backlashes, I get the desired result. Is there any fix five years later?

Sent from the CMake mailing list archive at Nabble.com.
--

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

--

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