diff --git a/CMakeLists.txt b/CMakeLists.txt
index 84b98c9f739365133773b097993cbd3083eaf6e8..960c8c8512d2d18dbd7464ddb873e9afa87c188d 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -121,6 +121,11 @@ IF(OGS_USE_EIGEN)
 	ENDIF()
 ENDIF()
 
+IF(OGS_BUILD_GUI)
+	ADD_DEFINITIONS(-DOGS_BUILD_GUI)
+	ADD_SUBDIRECTORY(Gui)
+ENDIF() # OGS_BUILD_GUI
+
 ADD_SUBDIRECTORY( AssemblerLib )
 ADD_SUBDIRECTORY( BaseLib )
 # TODO This is a hack but we have to make sure that Boost is built first
@@ -141,10 +146,6 @@ IF( OGS_BUILD_TESTS AND NOT IS_SUBPROJECT )
 		ADD_SUBDIRECTORY( SimpleTests/SolverTests )
 	ENDIF()
 ENDIF() # OGS_BUILD_TESTS
-IF(OGS_BUILD_GUI)
-	ADD_DEFINITIONS(-DOGS_BUILD_GUI)
-	ADD_SUBDIRECTORY(Gui)
-ENDIF() # OGS_BUILD_GUI
 IF(OGS_BUILD_UTILS AND NOT IS_SUBPROJECT)
 	ADD_SUBDIRECTORY( Utils/SimpleMeshCreation )
 	ADD_SUBDIRECTORY( Utils/FileConverter )