Appending to CMAKE_C_FLAGS
Since CMake 3.4 you do:
string(APPEND CMAKE_CXX_FLAGS " -lglapi")
This very handy when you want to set the flags only for one language (C++ in the example above), but if you want to set the same flags for all languages, you can simply do:
add_compile_options(-lglapi)
Both commands change the flags for the whole directory, if you want to set the flags for only one target, do:
target_compile_options(my_lib PUBLIC -lglapi)
Flags on a target can either be PUBLIC, PRIVATE or INTERFACE, allowing to transitively forward the flags from one target to the other.
Try to do this instead:
if(SINGLE_MODE)
SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -lglapi")
SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -lglapi")
endif(SINGLE_MODE)
Then, you are sure you append -lglapi
to the existing ${CMAKE_CXX_FLAGS}
string. Else, looks like something like a CMake list is being created.