Use CXXFLAGS and INCLUDES when checking for dependencies.