diff --git a/Applications/DataExplorer/DataExplorer.cmake b/Applications/DataExplorer/DataExplorer.cmake
index 7e26c6f5acaa7d39b5327c1bf45f6a65cb5560f4..32c30d3cf0d0b690c0c1e757e36eff4c073f1324 100644
--- a/Applications/DataExplorer/DataExplorer.cmake
+++ b/Applications/DataExplorer/DataExplorer.cmake
@@ -55,7 +55,6 @@ target_link_libraries(DataExplorer
 
 
 if(OGS_USE_NETCDF)
-    add_definitions(-DOGS_USE_NETCDF)
     add_subdirectory(NetCdfDialog)
     target_link_libraries(DataExplorer NetCdfDialogLib)
 endif()
diff --git a/CMakeLists.txt b/CMakeLists.txt
index 81c012b7f62a26ca752e7ad2a99416c6c3a5bc16..9c85b5da193698e88d06416abc4dd573f96fab9f 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -96,7 +96,6 @@ endif() # GCC AND GPROF_PATH
 option(OGS_BUILD_GUI "Should the Data Explorer be built?" OFF)
 if(OGS_BUILD_GUI)
     add_definitions(-DOGS_BUILD_GUI)
-    option(OGS_USE_NETCDF "Add NetCDF support." OFF)
 endif()
 option(OGS_BUILD_UTILS "Should the utilities programms be built?" OFF)
 if(OGS_BUILD_UTILS AND OGS_USE_MPI)
@@ -116,6 +115,7 @@ option(OGS_NO_EXTERNAL_LIBS "Builds OGS without any external dependencies." OFF)
 option(OGS_INSITU "Builds OGS with insitu visualization capabilities." OFF)
 option(OGS_USE_LIS "Use Lis" OFF)
 option(OGS_USE_PETSC "Use PETSc routines" OFF)
+option(OGS_USE_NETCDF "Add NetCDF support." OFF)
 
 # Eigen
 option(OGS_USE_EIGEN "Use Eigen linear solver" ON)
diff --git a/scripts/cmake/Find.cmake b/scripts/cmake/Find.cmake
index 6be8db4d9969c8f6bdcbff06d7bb6ce8888a5789..bb0270d2c7c49776b301d3476ae1500d4308b602 100644
--- a/scripts/cmake/Find.cmake
+++ b/scripts/cmake/Find.cmake
@@ -116,7 +116,7 @@ if(OGS_USE_NETCDF)
     else()
         find_package(HDF5 REQUIRED COMPONENTS C HL)
     endif()
-
+    add_compile_options(-DOGS_USE_NETCDF)
 endif()
 
 # lapack