I'm sure there is a way to do this, but I'm not seeing it. I need to test a compiler flag to know whether to enable it for our entire build. So I had planned on using test_compile(), but I don't see a way to pass additional compiler flags to test_compile() through CMAKE_FLAGS and there's no option to pass environment variables like CXXFLAGS with test_compile().
Also, when do the variables like CMAKE_CXX_FLAGS get set? I enable the CXX language and specify a required support for C++11, but if I dump CMAKE_CXX_FLAGS right after that there are no options such as -std=c++11 in the variable. I thought I could do something like ..