Strange issue with variables in a config-file cmake package

前端 未结 2 441
情歌与酒
情歌与酒 2020-12-20 19:46

We can use a cmake config file to import targets. For example given machinary including foobarConfig.cmake.in

set(FOOBAR_VERSION @VERSION@)

@PACKAG         


        
2条回答
  •  粉色の甜心
    2020-12-20 20:25

    Oops. This is embarrassing. I'd moved the generation code into a shell script and forgot to escape the variables!

    cat - >CMakeLists.txt <=$\n")
    
    EOF
    

    The question is still useful for providing source for the related question though.

    To answer my own questions:

    How can I find this problem? Avoid similar problems in the future? Create these files in a safe and canonical way?

    • https://en.wikipedia.org/wiki/Rubber_duck_debugging
    • Reduce the problem to a minimum reproducible example (preferably before posting on stack overflow)
    • Avoid (or at least take extra care) generating code from shell scripts
    • Reduce stress and get more sleep

提交回复
热议问题