diff --git a/Common/CMakeLists.txt b/Common/CMakeLists.txt
index 440ddc255e843c77d4654833cb9c22d4d4123e15..453870f02997a48235ee7ec0075febffde06dfaf 100644
--- a/Common/CMakeLists.txt
+++ b/Common/CMakeLists.txt
@@ -24,14 +24,8 @@ set(SRC
   onelabUtils.cpp
   GamePad.cpp
   GmshRemote.cpp
+  gmshLocalNetworkClient.cpp
 )
 
-if(ENABLE_ONELAB AND NOT ENABLE_ONELAB2)
-  set(SRC
-    ${SRC}
-    gmshLocalNetworkClient.cpp
-  )
-endif(ENABLE_ONELAB AND NOT ENABLE_ONELAB2)
-
 file(GLOB HDR RELATIVE ${CMAKE_CURRENT_SOURCE_DIR} *.h) 
 append_gmsh_src(Common "${SRC};${HDR}")
diff --git a/Common/gmshLocalNetworkClient.cpp b/Common/gmshLocalNetworkClient.cpp
index 25db11c1df28f81f864fae95e5877f9bad6bc753..95b3e0b5630f6fd21645284099d1ed2f3054c572 100644
--- a/Common/gmshLocalNetworkClient.cpp
+++ b/Common/gmshLocalNetworkClient.cpp
@@ -3,19 +3,22 @@
 // See the LICENSE.txt file for license information. Please report all
 // bugs and problems to the public mailing list <gmsh@geuz.org>.
 
-#include "gmshLocalNetworkClient.h"
 #include "GmshConfig.h"
 #include "Gmsh.h"
 #include "Context.h"
 #include "OS.h"
 #include "StringUtils.h"
-#include "onelabUtils.h"
 #include "OpenFile.h"
 #include "CreateFile.h"
 #include "PView.h"
 #include "Options.h"
 #include "GModel.h"
 
+#if defined(HAVE_ONELAB)
+
+#include "gmshLocalNetworkClient.h"
+#include "onelabUtils.h"
+
 #if defined(HAVE_FLTK)
 #include "FlGui.h"
 #include "onelabGroup.h"
@@ -862,3 +865,4 @@ void solver_batch_cb(void *data)
   }
 }
 
+#endif
diff --git a/Common/gmshLocalNetworkClient.h b/Common/gmshLocalNetworkClient.h
index 76835f23fabdb907d7d4ca5cd81bac12d858bebc..3dce8eda92b9040f7d331eb540d3bc6e1240a43e 100644
--- a/Common/gmshLocalNetworkClient.h
+++ b/Common/gmshLocalNetworkClient.h
@@ -8,6 +8,10 @@
 
 #include <vector>
 #include <algorithm>
+#include "GmshConfig.h"
+
+#if defined(HAVE_ONELAB)
+
 #include "onelab.h"
 
 class gmshLocalNetworkClient : public onelab::localNetworkClient{
@@ -58,15 +62,9 @@ class gmshLocalNetworkClient : public onelab::localNetworkClient{
     }
     return n;
   }
-#ifdef HAVE_ONELAB2 // Useless code in onelab2
-  bool receiveMessage(gmshLocalNetworkClient *master){return true;}
-  bool run(){return true;}
-  bool kill(){return true;}
-#else
   bool receiveMessage(gmshLocalNetworkClient *master);
   bool run();
   bool kill();
-#endif
 };
 
 // FIXME: move this to onelabUtils
@@ -82,3 +80,5 @@ void resetDb(bool runGmshClient);
 void solver_batch_cb(void *data);
 
 #endif
+
+#endif