I\'m using CMake for a project that comes in two versions, one of which requires -lglapi and the other does not.
So far the lines we used look like that:
Just for the particular case where you want to add compiler and linker options (like for --coverage option), the following syntax add the flags to both the linker and compiler:
SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} --coverage")
SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} --coverage")
(above commands add --coverage option to both compiler and flags options for C and C++)
Otherwise, if you prefer to use new CMake commands (add_compile_options and add_link_options), don't forget to add to the linker option too:
add_compile_options(--coverage)
add_link_options(--coverage)
(above commands add --coverage option to both compiler and flags options for C and C++)