0

I want to move some cmake command to a funtion . But the command did not work in the function.
I test a file command and it works well directly in the CMakeLists.txt but not in the function abcde.
So what's wrong with the function?

function(abcde)
file(GLOB_RECURSE SOURCE_FILES src4/*.cpp)
endfunction()

# file(GLOB_RECURSE SOURCE_FILES src4/*.cpp) 
abcde()

Weird is that the function works well in the past few days and suddenly did not work. And my function has a few commands, some work and others don't work.

I use vs code and it's cmake tools extension.

Malloc
  • 659
  • 2
  • 9
  • 20
  • 2
    A function adds a **scope**. So `SOURCE_FILES` variable is set inside the function but not outside it. – Tsyvarev Apr 13 '20 at 14:42
  • @Tsyvarev thanks very mush, that'a the problem. But why it worked well in the past few days,which make me confused. – Malloc Apr 13 '20 at 23:37

0 Answers0