  namespace RaptorQ {
  namespace Impl {
  
-+#pragma warning(push)
-+#pragma warning(disable : 4068) // MSVC unknown pragma
++#ifdef __clang__
  #pragma clang diagnostic push
  #pragma clang diagnostic ignored "-Wmissing-braces"
  #pragma clang diagnostic ignored "-Wglobal-constructors"
  #pragma clang diagnostic ignored "-Wexit-time-destructors"
-+#pragma warning(pop)
++#endif
  
  static const std::array<uint32_t, 31> degree_distribution = {
  							  0,    5243,  529531,  704294,  791675,  844104,
-@@ -39,7 +43,10 @@ static const std::array<uint32_t, 31> degree_distribution = {
+@@ -39,7 +42,9 @@ static const std::array<uint32_t, 31> degree_distribution = {
  						1010129, 1011876, 1013490, 1014983, 1016370, 1017662,
  						1048576};
  
-+#pragma warning(push)
-+#pragma warning(disable : 4068) // MSVC unknown pragma
++#ifdef __clang__
  #pragma clang diagnostic pop
-+#pragma warning(pop)
++#endif
  
  }	// namespace Impl
  }	// namespace RaptorQ

diff --git a/CMakeLists.txt b/CMakeLists.txt
index 262690e..34e69d7 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -20,31 +20,43 @@

-	SET(CMAKE_CXX_FLAGS_MINSIZEREL     "${CMAKE_CXX_FLAGS} -std=c++11 ${DETERMINISTIC} -fno-rtti -fno-exceptions -Wno-unknown-pragmas -Os -DNDEBUG -Wall -pedantic -Wno-padded -fstack-protector-all -fstrict-aliasing ")
-	SET(CMAKE_CXX_FLAGS_RELEASE        "${CMAKE_CXX_FLAGS} -std=c++11 ${DETERMINISTIC} -fno-rtti -fno-exceptions -Wno-unknown-pragmas -Ofast -fvisibility=hidden -fvisibility-inlines-hidden -O4 -DNDEBUG -Wall -pedantic -Wno-padded -fstack-protector-all -fstrict-aliasing -fwrapv -Wformat -Wformat-security -fPIE -fPIC ")
-	SET(CMAKE_CXX_FLAGS_RELWITHDEBINFO "${CMAKE_CXX_FLAGS} -std=c++11 ${DETERMINISTIC} -fno-rtti -fno-exceptions -Wno-unknown-pragmas -Ofast -g -fvisibility=hidden -fvisibility-inlines-hidden -O4 -DNDEBUG -Wall -pedantic -Wno-padded -fstack-protector-all -fstrict-aliasing -fwrapv -Wformat -Wformat-security -fPIE -fPIC ")
+	xpCheckCompilerFlags(CMAKE_CXX_FLAGS_MINSIZEREL "-Os -DNDEBUG")
+	xpCheckCompilerFlags(CMAKE_CXX_FLAGS_RELEASE "-Ofast -fvisibility=hidden -fvisibility-inlines-hidden -O4 -DNDEBUG -Wformat -Wformat-security -fPIE -fPIC")
+	xpCheckCompilerFlags(CMAKE_CXX_FLAGS_RELWITHDEBINFO "-Ofast -g -fvisibility=hidden -fvisibility-inlines-hidden -O4 -DNDEBUG -Wformat -Wformat-security -fPIE -fPIC")
 	ENDIF()
 	# else I do not know your compiler options :)
 ENDIF()
@@ -169,20 +259,22 @@ ENDIF()
 # set the proper options for that, too
 #
 IF(${CMAKE_C_COMPILER} MATCHES ".*clang.*")
