diff --git a/Common/CMakeLists.txt b/Common/CMakeLists.txt
index bceaadf8339117c640d78ac24e5843cd7f300293..440ddc255e843c77d4654833cb9c22d4d4123e15 100644
--- a/Common/CMakeLists.txt
+++ b/Common/CMakeLists.txt
@@ -23,12 +23,12 @@ set(SRC
   MallocUtils.cpp
   onelabUtils.cpp
   GamePad.cpp
+  GmshRemote.cpp
 )
 
 if(ENABLE_ONELAB AND NOT ENABLE_ONELAB2)
   set(SRC
     ${SRC}
-    GmshRemote.cpp
     gmshLocalNetworkClient.cpp
   )
 endif(ENABLE_ONELAB AND NOT ENABLE_ONELAB2)
diff --git a/Common/GmshRemote.cpp b/Common/GmshRemote.cpp
index 83b12456d7b730e51ff9ae266fe1f2d0263d61e1..6a970092308ac0c48135e7683273c3092f312ccf 100644
--- a/Common/GmshRemote.cpp
+++ b/Common/GmshRemote.cpp
@@ -19,7 +19,7 @@
 #include <sstream>
 #include "GmshMessage.h"
 
-#if defined(HAVE_ONELAB) && defined(HAVE_POST)
+#if defined(HAVE_ONELAB) && defined(HAVE_POST) && !defined(HAVE_ONELAB2)
 
 #include "onelab.h"
 #include "OpenFile.h"