How to set the global variable in a function for cmake?

后端 未结 5 1654
庸人自扰
庸人自扰 2020-12-15 19:14

I\'m writing a CMakeLists.txt to generate files and compile the generated files. I create a function to add some file path strings to a global list variable.

My CMak

5条回答
  •  一整个雨季
    2020-12-15 19:53

    PARENT_SCOPE is only for parent, it won't work if you have other non-parent script that want to see it as well.

    You need cache for the true "global-like" variable. In your case, use:

    SET(source_list  "${source_list}" CACHE INTERNAL "source_list")
    

提交回复
热议问题