简体   繁体   中英

How to print a ; symbol using CMake command?

I am building Boost as an ExternalProject under CMake. I want to cross compile for arm. To do this, I am trying to write using gcc : arm : arm-linux-gnueabi ; to user-config.jam before the build step.

However, it seems to refuse to print a ; symbol. I can only assume that this is due to some sort of mangling by CMake passing the command to the shell. I tried to edit project-config.jam inline using sed , but had the same result. Now I'm trying to echo the line to user-config.jam.

Here is my ExternalProject command in CMakeLists.txt:

ExternalProject_Add(Boost
    URL https://downloads.sourceforge.net/project/boost/boost/1.59.0/boost_1_59_0.tar.gz
    SOURCE_DIR ${CMAKE_CURRENT_SOURCE_DIR}/downloads/boost_1_59_0
    BINARY_DIR ${CMAKE_CURRENT_SOURCE_DIR}/downloads/boost_1_59_0
    UPDATE_COMMAND ""
    PATCH_COMMAND ""

    CONFIGURE_COMMAND ./bootstrap.sh --prefix="${CMAKE_BINARY_DIR}/boost_1_59_0" --without-icu
    COMMAND echo using gcc : arm : arm-linux-gnueabi > ./user-config.jam
    COMMAND echo ; >> ./user-config.jam
    BUILD_COMMAND "./b2"
    INSTALL_COMMAND ./b2 install toolset=gcc-arm --prefix=${CMAKE_CURRENT_SOURCE_DIR}/deps/boost
    INSTALL_DIR ${CMAKE_CURRENT_SOURCE_DIR}/deps/boost
)

The verbose CMake prints:

cd /home/matthew/Desktop/arm/downloads/boost_1_59_0 && echo using gcc : arm : arm-linux-gnueabi > ./user-config.jam
cd /home/matthew/Desktop/arm/downloads/boost_1_59_0 && echo >> ./user-config.jam

You can see that it prints the using ... gnueabi line fine to user-config.jam. However, it seems to treat ; as an null character. It does the same thing when I use single and double quotes around the ; character as well.

The semicolon is the list delimiter for cmake. CMake 2.8.11 and greater have a special $ token:

COMMAND echo $<SEMICOLON> >> ./user-config.jam

As a side-note, you can make your cmake configuration more platform independent by using the cmake -E <command> :

COMMAND ${CMAKE_COMMAND} -E echo ...

It probably doesn't matter for echo, for other functionallity (creating/removing directories) it's something to keep in mind.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM