I need to add various flags to my C and C ++ compilations in my CMake files (CMake 2.8.10.2). I see that some people use add_definitions , but from what I see, they are for preprocessor flags ( -D ). I have several flags that I do not want to pass to the preprocessor.
So, I tried to change CMAKE_C_FLAGS and CMAKE_CXX_FLAGS . I see that some people used something like:
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -new -flags -here")
but then I read in the cmake docs that this is less efficient, and the correct way to do this is to use list(APPEND ...) , for example:
list(APPEND CMAKE_C_FLAGS -new -flags -here)
However, when I do this, my compilation line contains flags separated by a semicolon, and is a syntax error. I read that lists are now stored internally, but I decided that cmake would consider this when I used the variable. It seems so basic; Am I doing something wrong? I mean, how good are these lists, if they cannot be used, if you don’t need a list of values separated by a semicolon (and who wants this, except that I think that Windows% PATH% settings or something yet)? Should I use the cited version, even if the documents offer less efficient / relevant?
source share