How to split strings across multiple lines in CMake?

后端 未结 7 1551
花落未央
花落未央 2021-01-06 19:03

I usually have a policy in my project, to never create lines in text files that exceed a line length of 80, so they are easily editable in all kinds of editors (you know the

7条回答
  •  生来不讨喜
    2021-01-06 19:34

    It's still a little verbose, but if the 80 char limit really bugs you then you could repeatedly append to the same variable:

    set(MYPROJ_VERSION_MAJOR "1")
    set(MYPROJ_VERSION_MINOR "0")
    set(MYPROJ_VERSION_PATCH "0")
    set(MYPROJ_VERSION_EXTRA "rc1")
    set(MYPROJ_VERSION "${MYPROJ_VERSION_MAJOR}.")
    set(MYPROJ_VERSION "${MYPROJ_VERSION}${MYPROJ_VERSION_MINOR}.")
    set(MYPROJ_VERSION "${MYPROJ_VERSION}${MYPROJ_VERSION_PATCH}-")
    set(MYPROJ_VERSION "${MYPROJ_VERSION}${MYPROJ_VERSION_EXTRA}")
    message(STATUS "version: ${MYPROJ_VERSION}")
    

    Gives output:

    $ cmake  ~/project/tmp
    -- version: 1.0.0-rc1
    -- Configuring done
    -- Generating done
    -- Build files have been written to: /home/rsanderson/build/temp
    

提交回复
热议问题