diff --git a/CMakeLists.txt b/CMakeLists.txt
index acfedc84e1..321ebddfb9 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -83,11 +83,6 @@ if(USE_MOLD)
         endif()
 endif()
 
-check_c_compiler_flag("-fexceptions" HAVE_FEXCEPTIONS)
-if (NOT HAVE_FEXCEPTIONS)
-    message(FATAL_ERROR "Missing required compiler flag: -fexceptions.")
-endif()
-
 set(CONFIG_H_DIR ${CMAKE_BINARY_DIR})
 set(CONFIG_H ${CONFIG_H_DIR}/config.h)
 
diff --git a/packaging/cmake/Modules/NetdataCompilerFlags.cmake b/packaging/cmake/Modules/NetdataCompilerFlags.cmake
index 04f94d4aee..5e44137b17 100644
--- a/packaging/cmake/Modules/NetdataCompilerFlags.cmake
+++ b/packaging/cmake/Modules/NetdataCompilerFlags.cmake
@@ -69,6 +69,26 @@ function(add_double_extra_compiler_flag match flag1 flag2)
         endif()
 endfunction()
 
+# Add a required extra compiler flag to C and C++ flags.
+#
+# Similar logic as add_simple_extra_compiler_flag, but ignores existing
+# instances and throws an error if the flag is not supported.
+function(add_required_compiler_flag flag)
+  set(CMAKE_REQUIRED_FLAGS "-Werror")
+
+  make_cpp_safe_name("${flag}" flag_name)
+
+  check_c_compiler_flag("${flag}" HAVE_C_${flag_name})
+  check_cxx_compiler_flag("${flag}" HAVE_CXX_${flag_name})
+
+  if(HAVE_C_${flag_name} AND HAVE_CXX_${flag_name})
+    add_compile_options("${flag}")
+    add_link_options("${flag}")
+  else()
+    message(FATAL_ERROR "${flag} support is required to build Netdata")
+  endif()
+endfunction()
+
 if(CMAKE_BUILD_TYPE STREQUAL "Debug")
         option(DISABLE_HARDENING "Disable adding extra compiler flags for hardening" TRUE)
 else()
@@ -84,6 +104,8 @@ endif()
 
 set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${CMAKE_C_FLAGS}")
 
+add_required_compiler_flag("-fexceptions")
+
 if(NOT ${DISABLE_HARDENING})
         add_double_extra_compiler_flag("stack-protector" "-fstack-protector-strong" "-fstack-protector")
         add_double_extra_compiler_flag("_FORTIFY_SOURCE" "-D_FORTIFY_SOURCE=3" "-D_FORTIFY_SOURCE=2")
diff --git a/src/daemon/main.c b/src/daemon/main.c
index 4d61070e9a..9977802828 100644
--- a/src/daemon/main.c
+++ b/src/daemon/main.c
@@ -228,11 +228,6 @@ int unittest_prepare_rrd(const char **user) {
 }
 
 int netdata_main(int argc, char **argv) {
-#if !defined(HAVE_FEXCEPTIONS)
-    fprintf(stderr, "Netdata has been compiled without these required compiler flags: -fexceptions.\n");
-    exit(1);
-#endif
-
     string_init();
     analytics_init();