With modern cmake, you can use add_compile_options
and target_compile_options
instead of setting the variable directly
Thus in your context you can write
add_compile_options(" -Wno-unused-variable -Wno-unused-function -Wno-error")
to add the compile options to all targets or simply
target_compile_options(LIBRARY_NAME SCOPE "-Wno-unused-variable -Wno-unused-function -Wno-error")
to set those options for one target.
If you need it to be cross platform
if(${PLATFORM_1})
add_compile_options("WARNING_FLAGS_FOR_PLATFORM1")
elseif(${PLATFORM_2})
add_compile_options("WARNING_FLAGS_FOR_PLATFORM2")
endif()
replace the variable by your required values