set CMAKE_CXX_FLGAS composed of variables without parenthesis, not a good idea ?

Why does set(CMAKE_CXX_FLGAS "${CMAKE_CXX_FLAGS} ${extra_flags}") works, but set(CMAKE_CXX_FLGAS ${CMAKE_CXX_FLAGS} ${extra_flags}) doesn’t ?

In my case, I got the g++ error: " no input files because of the above.

CMAKE_CXX_FLAGS must be defined as a string, not a list.

The second example, without quotes, will be interpreted as a list so each item will be separated by a semi-colon.

For example, if CMAKE_CXX_FLAGS contains the string “-c -std=c++11” and extra_flags contains ‘-O2’ :

# quotes are not specified
set (CMAKE_CXX_FLAGS ${CMAKE_CXX_FLAGS} ${extra_flags})

Now CMAKE_CXX_FLAGS contains “-c;-std=c++11;-O2” which not what is expected.

Whereas the ; in bash/make would mean start a new command.