diff --git a/CMakeLists.txt b/CMakeLists.txt
index 6e6658a67578747c45d2baded065b17de8c1437f..ff57b145fac6fc5d07de15401acb722bbe5b97b6 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -21,6 +21,7 @@ project(gmsh CXX C)
 # e.g. "cmake -DDEFAULT=0 -DENABLE_POST=1 -DENABLE_PARSER=1")
 set(DEFAULT ON CACHE INTERNAL "Default value for enabled-by-default options")
 
+option(ENABLE_3M "Enable 3M" OFF)
 option(ENABLE_ACIS "Enable ACIS geometrical models" ${DEFAULT})
 option(ENABLE_ANN "Enable ANN to compute Approximate Nearest Neighbors" ${DEFAULT})
 option(ENABLE_APP_BUNDLE "Create .app bundle on Mac when installing" ${DEFAULT})
@@ -456,11 +457,11 @@ if(HAVE_FLTK OR HAVE_QT OR ENABLE_GRAPHICS)
     set_config_option(HAVE_MPEG_ENCODE "Mpeg")
   endif(ENABLE_MPEG_ENCODE)
 
-  if(EXISTS ${CMAKE_CURRENT_SOURCE_DIR}/contrib/3M)
+  if(ENABLE_3M AND EXISTS ${CMAKE_CURRENT_SOURCE_DIR}/contrib/3M)
     add_subdirectory(contrib/3M)
     include_directories(contrib/3M)
     set_config_option(HAVE_3M "3M")
-  endif(EXISTS ${CMAKE_CURRENT_SOURCE_DIR}/contrib/3M)
+  endif(ENABLE_3M AND EXISTS ${CMAKE_CURRENT_SOURCE_DIR}/contrib/3M)
 
   if(ENABLE_OSMESA)
     find_library(OSMESA_LIB OSMesa)