diff --git a/CMakeLists.txt b/CMakeLists.txt
index d368067f416fcaa6bf46079532c120ab9d9d31da..28a2fb476dbbb717bb723603752cd3258043ffbe 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -24,8 +24,10 @@ project(
   HOMEPAGE_URL https://gitlab.eclipse.org/eclipse/simopenpass/yase
   LANGUAGES CXX)
 
-option(Yase_BUILD_TESTS "Build the tests" ${Yase_IS_TOP_LEVEL})
 option(Yase_BUILD_DOCS "Build the documentation" ${Yase_IS_TOP_LEVEL})
+option(Yase_BUILD_TESTS "Build the tests" ${Yase_IS_TOP_LEVEL})
+option(Yase_ENABLE_WARNINGS "Enable compiler warnings" ${Yase_IS_TOP_LEVEL})
+option(Yase_ENABLE_WERROR "Fail on compiler warnings" ${Yase_IS_TOP_LEVEL})
 option(Yase_INSTALL "Enable installation" ${Yase_IS_TOP_LEVEL})
 
 include(CMakeDependentOption)
@@ -52,6 +54,62 @@ if(Yase_BUILD_TESTS)
   enable_testing()
 endif()
 
+if(MSVC)
+  if(Yase_ENABLE_WARNINGS)
+    add_compile_options(
+      /permissive-
+      /w14242
+      /w14254
+      /w14263
+      /w14265
+      /w14287
+      /w14296
+      /w14311
+      /w14545
+      /w14546
+      /w14547
+      /w14549
+      /w14555
+      /w14619
+      /w14640
+      /w14640
+      /w14826
+      /w14905
+      /w14906
+      /w14928
+      /W4
+      /we4289)
+  endif()
+  if(Yase_ENABLE_WERROR)
+    add_compile_options(/WX)
+  endif()
+else()
+  if(Yase_ENABLE_WARNINGS)
+    add_compile_options(
+      -pedantic
+      -Wall
+      -Wcast-align
+      -Wconversion
+      -Wdouble-promotion
+      -Wduplicated-branches
+      -Wduplicated-cond
+      -Wextra
+      -Wformat=2
+      -Wimplicit-fallthrough
+      -Wmisleading-indentation
+      -Wnon-virtual-dtor
+      -Wnull-dereference
+      -Wold-style-cast
+      -Woverloaded-virtual
+      -Wshadow
+      -Wsign-conversion
+      -Wunused)
+  endif()
+  if(Yase_ENABLE_WERROR)
+    add_compile_options(-Werror)
+  endif()
+endif()
+
 add_subdirectory(middle_end)
 
 export(