diff --git a/CHANGELOG.md b/CHANGELOG.md
index 3545002bb50c190004f567eb2d568712ddee608f..39dafaca498050086ccdadfbb516a97b206111a5 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -52,6 +52,12 @@ In order to build the DUNE core modules you need at least the following software
 
 ## Build System
 
+- Remove the `ALLOW_CXXFLAGS_OVERWRITE` configure option. The `CXXFLAGS`
+  overload is still turned on for the JIT compiled Python modules. See the
+  description of the MR
+  https://gitlab.dune-project.org/core/dune-common/-/merge_requests/1251
+  for more details on how to use this feature in the source modules and on
+  some new feature.
 - Remove deprecated `add_directory_test_target` function.
 
 - Do not overwrite the `add_test` cmake function with an error message.
diff --git a/cmake/modules/DuneProject.cmake b/cmake/modules/DuneProject.cmake
index 1586a7afa5a87a8230784f7f876a814a95259692..fab4f02ed211eea3cf87ed555d9c2150f34b0da8 100644
--- a/cmake/modules/DuneProject.cmake
+++ b/cmake/modules/DuneProject.cmake
@@ -336,9 +336,6 @@ endif()
     feature_summary(WHAT ALL)
   endif()
 
-  # check if CXX flag overloading has been enabled
-  # and write compiler script (see OverloadCompilerFlags.cmake)
-  finalize_compiler_script()
 endmacro(finalize_dune_project)
 
 
diff --git a/cmake/modules/OverloadCompilerFlags.cmake b/cmake/modules/OverloadCompilerFlags.cmake
index b59f10d6a0c49a11a1be0300fa2ca1cfd76e41c7..e7843f6e1fab02491d2948b297de08cb4d03ed4e 100644
--- a/cmake/modules/OverloadCompilerFlags.cmake
+++ b/cmake/modules/OverloadCompilerFlags.cmake
@@ -29,144 +29,10 @@ include_guard(GLOBAL)
 
 option(ALLOW_CXXFLAGS_OVERWRITE OFF)
 option(ALLOW_CFLAGS_OVERWRITE OFF)
-option(ALLOW_CXXFLAGS_OVERWRITE_FORCE OFF)
-option(ALLOW_CXXFLAGS_OVERWRITE_VERBOSE OFF)
-option(ALLOW_CFLAGS_OVERWRITE_VERBOSE OFF)
-
-if( DEFINED ENV{ALLOW_CXXFLAGS_OVERWRITE_VERBOSE} )
-  set(ALLOW_CXXFLAGS_OVERWRITE_VERBOSE ON )
-endif()
-
-if( ALLOW_CXXFLAGS_OVERWRITE_VERBOSE )
-  set(ALLOW_CXXFLAGS_OVERWRITE ON)
-endif()
-
-if( ALLOW_CFLAGS_OVERWRITE_VERBOSE )
-  set(ALLOW_CFLAGS_OVERWRITE ON)
-endif()
-
-set(WRITE_CXXFLAGS_COMPILER_SCRIPT FALSE)
-# write scripts if CMAKE_GENERATOR is Makefiles or if FORCE is on
-if(${CMAKE_GENERATOR} MATCHES ".*Unix Makefiles.*" OR ALLOW_CXXFLAGS_OVERWRITE_FORCE)
-  set(WRITE_CXXFLAGS_COMPILER_SCRIPT TRUE)
-endif()
-
-set(CXX_COMPILER_SCRIPT "${CMAKE_BINARY_DIR}/CXX_compiler.sh" )
-set(C_COMPILER_SCRIPT "${CMAKE_BINARY_DIR}/C_compiler.sh" )
-
-macro(find_extended_unix_commands)
-  include(FindUnixCommands)
-  set(FLAGSNAMES "ALLOW_CXXFLAGS_OVERWRITE and/or ALLOW_CFLAGS_OVERWRITE")
-  find_program (GREP_PROGRAM grep)
-  if(NOT GREP_PROGRAM)
-    message( SEND_ERROR "grep not found, please disable ${FLAGSNAMES}")
-  endif()
-  find_program (SED_PROGRAM  sed)
-  if(NOT SED_PROGRAM)
-    message( SEND_ERROR "sed not found, please disable ${FLAGSNAMES}")
-  endif()
-  find_program (CUT_PROGRAM  cut)
-  if(NOT CUT_PROGRAM)
-    message( SEND_ERROR "cut not found, please disable ${FLAGSNAMES}")
-  endif()
-  find_program (ENV_PROGRAM  env)
-  if(NOT ENV_PROGRAM)
-    message( SEND_ERROR "env not found, please disable ${FLAGSNAMES}")
-  endif()
-  find_program (ECHO_PROGRAM echo)
-  if(NOT ECHO_PROGRAM)
-    message( SEND_ERROR "echo not found, please disable ${FLAGSNAMES}")
-  endif()
-  find_program (CHMOD_PROGRAM chmod)
-  if(NOT CHMOD_PROGRAM)
-    message( SEND_ERROR "chmod not found, please disable ${FLAGSNAMES}")
-  endif()
-  mark_as_advanced(GREP_PROGRAM)
-  mark_as_advanced(SED_PROGRAM)
-  mark_as_advanced(CUT_PROGRAM)
-  mark_as_advanced(ENV_PROGRAM)
-  mark_as_advanced(ECHO_PROGRAM)
-  mark_as_advanced(CHMOD_PROGRAM)
-endmacro(find_extended_unix_commands)
 
 # init compiler script and store CXX flags
 macro(initialize_compiler_script)
-  if(ALLOW_CXXFLAGS_OVERWRITE AND WRITE_CXXFLAGS_COMPILER_SCRIPT)
-    # check for unix commands necessary
-    find_extended_unix_commands()
-    # set CXXFLAGS as environment variable
-    set( DEFAULT_CXXFLAGS ${CMAKE_CXX_FLAGS} CACHE STRING "default CXX flags")
-    set( CMAKE_CXX_FLAGS "" )
-    set( DEFAULT_CXX_COMPILER ${CMAKE_CXX_COMPILER} )
-    set( CXX_COMPILER_SCRIPT_FILE "#!${BASH}\nexec ${CMAKE_CXX_COMPILER} \"\$@\"")
-    file(WRITE ${CXX_COMPILER_SCRIPT} "${CXX_COMPILER_SCRIPT_FILE}")
-    execute_process(COMMAND ${CHMOD_PROGRAM} 755 ${CXX_COMPILER_SCRIPT})
-    set(CMAKE_CXX_COMPILER ${CXX_COMPILER_SCRIPT})
-  endif()
-  if(ALLOW_CFLAGS_OVERWRITE AND WRITE_CXXFLAGS_COMPILER_SCRIPT)
-    # check for unix commands necessary
-    find_extended_unix_commands()
-    # set CFLAGS as environment variable
-    set( DEFAULT_CFLAGS ${CMAKE_C_FLAGS} CACHE STRING "default C flags")
-    set( CMAKE_C_FLAGS "" )
-    set( DEFAULT_C_COMPILER ${CMAKE_C_COMPILER} )
-    set( C_COMPILER_SCRIPT_FILE "#!${BASH}\nexec ${CMAKE_C_COMPILER} \"\$@\"")
-    file(WRITE ${C_COMPILER_SCRIPT} "${C_COMPILER_SCRIPT_FILE}")
-    execute_process(COMMAND ${CHMOD_PROGRAM} 755 ${C_COMPILER_SCRIPT})
-    set(CMAKE_C_COMPILER ${C_COMPILER_SCRIPT})
-  endif()
-endmacro()
-
-# finalize compiler script and write it
-macro(finalize_compiler_script)
-  if( WRITE_CXXFLAGS_COMPILER_SCRIPT )
-    # check CXX compiler
-    if((ALLOW_CXXFLAGS_OVERWRITE))
-      set(COMPILERS "CXX")
-    endif()
-    # check C compiler
-    if((ALLOW_CFLAGS_OVERWRITE))
-      set(COMPILERS ${COMPILERS} "C")
-    endif()
-
-    # for the found compilers for flag overloading generate compiler script
-    foreach(COMP ${COMPILERS})
-      set( COMPILER_SCRIPT_FILE "#!${BASH}\nSED=${SED_PROGRAM}\nGREP=${GREP_PROGRAM}")
-      set( COMPILER_SCRIPT_FILE "${COMPILER_SCRIPT_FILE}\nCUT=${CUT_PROGRAM}\nENV=${ENV_PROGRAM}\nECHO=${ECHO_PROGRAM}")
-      set( COMPILER_SCRIPT_FILE "${COMPILER_SCRIPT_FILE}\n# store flags\nFLAGS=\"\$@\"")
-      set( COMPILER_SCRIPT_FILE "${COMPILER_SCRIPT_FILE}\nMAKE_EXECUTABLE_NEW=0\n")
-      set( COMPILER_SCRIPT_FILE "${COMPILER_SCRIPT_FILE}\nif [ \"\$${COMP}FLAGS\" == \"\" ]; then\n  # default ${COMP} flags\n  ${COMP}FLAGS=\"${DEFAULT_CXXFLAGS}\"\nfi\n")
-      set( COMPILER_SCRIPT_FILE "${COMPILER_SCRIPT_FILE}\nif [ \"\$EXTRA_${COMP}FLAGS\" != \"\" ]; then\n  # extra ${COMP} flags\n  ${COMP}FLAGS=\"$${COMP}FLAGS $EXTRA_${COMP}FLAGS\"\nfi\n")
-      # only for CXX we need to scan config.h for GRIDTYPE
-      if( ${COMP} STREQUAL "CXX" )
-        set( COMPILER_SCRIPT_FILE "${COMPILER_SCRIPT_FILE}\nGRIDS=\nCONFIG_H=${CMAKE_BINARY_DIR}/config.h")
-        set( COMPILER_SCRIPT_FILE "${COMPILER_SCRIPT_FILE}\nif [ \"\$GRIDTYPE\" != \"\" ]; then")
-        set( COMPILER_SCRIPT_FILE "${COMPILER_SCRIPT_FILE}\n  GRIDS=`\$GREP \"defined USED_[A-Z_]*_GRIDTYPE\" \$CONFIG_H | \$SED 's/\\(.*defined USED\\_\\)\\(.*\\)\\(\\_GRIDTYPE*\\)/\\2/g'`\nfi\n")
-      endif()
-      set( COMPILER_SCRIPT_FILE "${COMPILER_SCRIPT_FILE}\nOLDFLAGS=\$FLAGS\nFLAGS=")
-      set( COMPILER_SCRIPT_FILE "${COMPILER_SCRIPT_FILE}\nfor FLAG in \$OLDFLAGS; do")
-      set( COMPILER_SCRIPT_FILE "${COMPILER_SCRIPT_FILE}\n  NEWFLAG=\$FLAG\n  VARNAME=`\$ECHO \$FLAG | \$GREP \"\\-D\" | \$SED 's/-D//g'`")
-      # only for CXX we have GRIDTYPE
-      if( ${COMP} STREQUAL "CXX" )
-        set( COMPILER_SCRIPT_FILE "${COMPILER_SCRIPT_FILE}\n  for GRID in \$GRIDS; do\n    if [ \"\$VARNAME\" == \"\$GRID\" ]; then\n      NEWFLAG=\"-D\$GRIDTYPE\"\n      break\n    fi\n  done")
-      endif()
-      set( COMPILER_SCRIPT_FILE "${COMPILER_SCRIPT_FILE}\n  VARNAME=`\$ECHO \$VARNAME | \$GREP \"=\" | \$CUT -d \"=\" -f 1`")
-      set( COMPILER_SCRIPT_FILE "${COMPILER_SCRIPT_FILE}\n  if [ \"\$VARNAME\" != \"\" ]; then\n    VAR=`\$ENV | \$GREP \$VARNAME`\n    if [ \"\$VAR\" != \"\" ]; then")
-      set( COMPILER_SCRIPT_FILE "${COMPILER_SCRIPT_FILE}\n      # add variable from environment to flags list\n      NEWFLAG=\"-D\$VARNAME=\${!VARNAME}\"\n    fi\n  fi")
-      set( COMPILER_SCRIPT_FILE "${COMPILER_SCRIPT_FILE}\n  FLAGS=\"\$FLAGS \$NEWFLAG\"\ndone")
-      if( ${COMP} STREQUAL "CXX" AND ALLOW_CXXFLAGS_OVERWRITE_VERBOSE )
-        set( COMPILER_SCRIPT_FILE "${COMPILER_SCRIPT_FILE}\n\$ECHO \"${DEFAULT_${COMP}_COMPILER} \$${COMP}FLAGS \$FLAGS\"")
-      endif()
-      if( ${COMP} STREQUAL "C" AND ALLOW_CFLAGS_OVERWRITE_VERBOSE )
-        set( COMPILER_SCRIPT_FILE "${COMPILER_SCRIPT_FILE}\n\$ECHO \"${DEFAULT_${COMP}_COMPILER} \$${COMP}FLAGS \$FLAGS\"")
-      endif()
-      set( COMPILER_SCRIPT_FILE "${COMPILER_SCRIPT_FILE}\nexec ${DEFAULT_${COMP}_COMPILER} \$${COMP}FLAGS \$FLAGS")
-      message("-- Generating ${COMP} compiler script for ${COMP}FLAGS overloading on command line")
-      if( ${COMP} STREQUAL "CXX" )
-        file(WRITE ${CXX_COMPILER_SCRIPT} "${COMPILER_SCRIPT_FILE}")
-      else()
-        file(WRITE ${C_COMPILER_SCRIPT} "${COMPILER_SCRIPT_FILE}")
-      endif()
-    endforeach()
+  if(ALLOW_CXXFLAGS_OVERWRITE OR ALLOW_CFLAGS_OVERWRITE)
+    message(WARNING "ALLOW_CXXFLAGS_OVERWRITE is not longer included in the cmake build process (see MR 1251 in dune-common for details). Use dune-common/bin/compiler_launcher.sh instead! A description of usage is found there.")
   endif()
 endmacro()
diff --git a/python/CMakeLists.txt b/python/CMakeLists.txt
index bda21db9c3d5b87724e09daffa9e5cf67945544f..5db2b723970f71b245cfc42b81c492591c30d31a 100644
--- a/python/CMakeLists.txt
+++ b/python/CMakeLists.txt
@@ -8,7 +8,7 @@ configure_file(pyproject.toml.in pyproject.toml)
 
 dune_python_configure_bindings(
   PATH "."
-  CMAKE_METADATA_FLAGS DUNE_OPTS_FILE HAVE_MPI CMAKE_BUILD_TYPE CMAKE_CXX_COMPILER CMAKE_CXX_FLAGS CMAKE_C_COMPILER CMAKE_C_FLAGS CMAKE_PREFIX_PATH ALLOW_CXXFLAGS_OVERWRITE
+  CMAKE_METADATA_FLAGS DUNE_OPTS_FILE HAVE_MPI CMAKE_BUILD_TYPE CMAKE_CXX_COMPILER CMAKE_CXX_FLAGS CMAKE_C_COMPILER CMAKE_C_FLAGS CMAKE_PREFIX_PATH CMAKE_CXX_COMPILER_LAUNCHER
 )
 if(POLICY CMP0087)
   cmake_policy(SET CMP0087 NEW)
diff --git a/python/dune/generator/cmakebuilder.py b/python/dune/generator/cmakebuilder.py
index 93f01984a4aa743a4ce3841082f80c991dbf6888..d853590f204d1b9ef926c1080665530b594f1f47 100644
--- a/python/dune/generator/cmakebuilder.py
+++ b/python/dune/generator/cmakebuilder.py
@@ -119,9 +119,24 @@ class Builder:
             context["modules"]        = modules
             context["builddirs"]      = builddirs
             context["install_prefix"] = metaData.unique_value_across_modules("INSTALL_PREFIX")
-            context["cmake_flags"]    = getCMakeFlags()
-            context["cxx_compiler"]   = context["cmake_flags"].get("CMAKE_CXX_COMPILER","")
-            context["cxx_flags"]      = context["cmake_flags"].get("CMAKE_CXX_FLAGS","")
+            context["cmake_flags"]    = getCMakeFlags().copy()
+            context["dunepy_dir"]     = dunepy_dir
+
+            # to use the default launcher we move the CMAKE_CXX_FLAGS to DEFAULT_CXXFLAGS
+            # to get the compile command without CXX_FLAGS we then remove them
+            try:
+                cxxflags = context["cmake_flags"].pop("CMAKE_CXX_FLAGS")
+                context["DEFAULT_CXXFLAGS"] = cxxflags
+            except KeyError:
+                pass
+            # we also need to make sure that no 'build type' (is set to 'release' in the packaging framework skbuild)
+            # Note: this means the value can not be set by the user
+            #       perhaps we can find a better solution here but for now
+            #       if we keep it the launcher will not work with packages
+            try:
+                context["cmake_flags"].pop("CMAKE_BUILD_TYPE")
+            except KeyError:
+                pass
 
             # Find the correct template path
             path, _ = os.path.split(__file__)
@@ -146,10 +161,18 @@ class Builder:
                     if gen_file.endswith(".cmake") or gen_file.endswith("Makefile"): continue # issues due to template taken from build dir
 
                     os.makedirs(os.path.split(gen_file)[0], exist_ok=True)
-                    with open(gen_file, "w") as outfile:
+                    # make sure the launcher can be executed
+                    def opener(path,flags):
+                        if "compiler_launcher" in path:
+                            return os.open(path, flags, 0o774)
+                        else:
+                            return os.open(path, flags, 0o664)
+                    with open(gen_file, "w", opener=opener) as outfile:
                         outfile.write(env.get_template(relative_template_file).render(**context))
                         os.fsync(outfile) # make sure files are correctly synced before calling make or cmake
 
+        logger.debug("Context used to configure dune-py: {}".format(context))
+
         # return force variable because this might be needed in the overloaded versions
         return force
 
@@ -474,7 +497,24 @@ class MakefileBuilder(Builder):
                 # call base class dunepy_from_template (re-initialize)
                 force = Builder.generate_dunepy_from_template(dunepy_dir, force=True)
 
-                Builder.callCMake(["cmake"] + defaultCMakeFlags() + ["."],
+                # extract compiler launcher if provided by user
+                launcher = getCMakeFlags().get('CMAKE_CXX_COMPILER_LAUNCHER',
+                               os.path.join(dunepy_dir,"compiler_launcher.sh"))
+
+                # the default flags contain CXX_FLAGS but we need to keep
+                # those empty to get the correct compiler command
+                cmake_flags = defaultCMakeFlags(overwrite={'CMAKE_CXX_FLAGS':' '})
+                # the launcher might be given through a environment
+                # variable which is taken care of here
+                for flag in cmake_flags:
+                    if flag.find('CMAKE_CXX_COMPILER_LAUNCHER') > 0:
+                        launcher = flag.split("=")[1]
+
+                # adding CMAKE_EXPORT_COMPILE_COMMANDS=ON because only
+                # having that in the CMakeLists.txt file fails for some of
+                # the CI runs
+                # Builder.callCMake(["cmake"] + cmake_flags + ["."],
+                Builder.callCMake(["cmake","-DCMAKE_EXPORT_COMPILE_COMMANDS=ON","."],
                                   cwd=dunepy_dir,
                                   infoTxt="Configuring dune-py with CMake (make)",
                                   active=True, # print details anyway
@@ -518,16 +558,6 @@ class MakefileBuilder(Builder):
                 except CompileError:
                     deprecationMessage(dunepy_dir)
 
-                # now also generate compiler command
-                stdout, stderr = \
-                  Builder.callCMake(["cmake","-DCMAKE_EXPORT_COMPILE_COMMANDS=ON","."],
-                                     cwd=dunepy_dir,
-                                     env={**os.environ,
-                                          "CXXFLAGS":" ",
-                                          },
-                                     infoTxt="extract compiler command",
-                                     active=True, # print details anyway
-                                   )
                 ########################################################################
                 #   Write buildScript.sh
                 ########################################################################
@@ -538,13 +568,13 @@ class MakefileBuilder(Builder):
                 buildSourceName = os.path.join(buildDirBase,'build.make')
 
                 commandSourceName = os.path.join(dunepy_dir,'compile_commands.json')
-                # we do not need the buildScript template since the compiler command generated uses CXX_compiler.sh
                 with open(buildScriptName, "w") as buildScript:
                     # write bash line
                     buildScript.write("#!" + MakefileBuilder.bashCmd + "\n")
                     # write compiler commands
                     with open(commandSourceName) as commandFile:
                         compilerCmd = json.load(commandFile)[0]["command"]
+                    # replace target file
                     compilerCmd = compilerCmd.replace('extractCompiler', '$1')
                     # this line is extracted from build.make
                     usedBuildMake = False
@@ -564,8 +594,11 @@ class MakefileBuilder(Builder):
 
                     # forward errors so that compilation failure will be caught
                     buildScript.write('set -e\n')
-                    buildScript.write(compilerCmd)
-                    buildScript.write('\n')
+                    # add launcher before compiler
+                    buildScript.write('if [ "$DUNE_CXX_COMPILER_LAUNCHER" == "" ]; then\n')
+                    buildScript.write(' DUNE_CXX_COMPILER_LAUNCHER='+launcher+'\n')
+                    buildScript.write('fi\n')
+                    buildScript.write("$DUNE_CXX_COMPILER_LAUNCHER " + compilerCmd+"\n")
                     # write linker commands
                     with open(linkerSourceName, "r") as linkerSource:
                         linkerCmd = linkerSource.read()
@@ -601,7 +634,8 @@ class MakefileBuilder(Builder):
                                          replace(' python/dune/generated/',' ') # better to move the script to the root of dune-py then this can be kept
                     compilerCmd = compilerCmd.split(' ',1)
                     compilerCmd = compilerCmd[0] + " " + compilerCmd[1]
-                    buildScript.write(compilerCmd+"\n")
+                    # add launcher before compiler
+                    buildScript.write(launcher + " " + compilerCmd+"\n")
                     # this needs fixing: Issue is that at the linker line beginns with ': && '
                     linkerCmd = out[1].replace('extractCompiler','$1').\
                                        replace(' python/dune/generated/',' ') # better to move the script to the root of dune-py then this can be kept
diff --git a/python/dune/generator/template/CMakeLists.txt b/python/dune/generator/template/CMakeLists.txt
index 778028c466d665028b056b6b646bb56a1211fc55..824830457f7df319e0d132e5cd49d8bb461f077f 100644
--- a/python/dune/generator/template/CMakeLists.txt
+++ b/python/dune/generator/template/CMakeLists.txt
@@ -3,7 +3,7 @@
 
 add_subdirectory(python)
 
-set(templatefiles CMakeLists.txt.template dune.module.template config.h.cmake dune-py.pc.in)
+set(templatefiles CMakeLists.txt.template dune.module.template config.h.cmake dune-py.pc.in dune-compiler_launcher.sh compiler_launcher.sh.template)
 dune_symlink_to_source_files(FILES ${templatefiles})
 if (SKBUILD)
   install(FILES ${templatefiles} DESTINATION python/dune/generator/template)
diff --git a/python/dune/generator/template/CMakeLists.txt.template b/python/dune/generator/template/CMakeLists.txt.template
index 03bb8f39f9de9596f516a3600a1f37077e6c418f..bec3a5ee25191ac66a5fbf80db231a7ff41461f7 100644
--- a/python/dune/generator/template/CMakeLists.txt.template
+++ b/python/dune/generator/template/CMakeLists.txt.template
@@ -18,9 +18,7 @@ message("---- LOCK")
 file(LOCK ${lock})
 message("---- ACQUIRED")
 
-set(ALLOW_CXXFLAGS_OVERWRITE ON) 
-set(ALLOW_CXXFLAGS_OVERWRITE_FORCE ON)  
-set(DUNE_ENABLE_PYTHONBINDINGS ON)
+set(CMAKE_EXPORT_COMPILE_COMMANDS ON)
 set(CMAKE_PREFIX_PATH {{ install_prefix }})
 
 {% for mod, dir in builddirs.items() -%}
@@ -31,8 +29,16 @@ set({{ mod }}_DIR {{ dir }})
 
 {% for flag, value in cmake_flags.items() -%}
 {% if flag != "" %}
+# boolean flags need to be forced to be written to the cache
+# otherwise they will be overwritten by the default from dune-common
+{% if value == True %}
+set({{ flag }} TRUE CACHE BOOL "stored user config {{flag}}" FORCE)
+{% elif value == False %}
+set({{ flag }} FALSE CACHE BOOL "stored user config {{flag}}" FORCE)
+{% else %}
 set({{ flag }} "{{ value }}")
 {% endif %}
+{% endif %}
 {%- endfor %}
 
 project(dune-py C CXX)
diff --git a/python/dune/generator/template/compiler_launcher.sh.template b/python/dune/generator/template/compiler_launcher.sh.template
new file mode 100755
index 0000000000000000000000000000000000000000..e76f0509bda8a8d80ae1f53cd9e9ac001dfbd887
--- /dev/null
+++ b/python/dune/generator/template/compiler_launcher.sh.template
@@ -0,0 +1,5 @@
+#!/bin/bash
+# SPDX-FileCopyrightInfo: Copyright © DUNE Project contributors, see file LICENSE.md in module root
+# SPDX-License-Identifier: LicenseRef-GPL-2.0-only-with-DUNE-exception
+
+DEFAULT_CXXFLAGS="{{ DEFAULT_CXXFLAGS }}" {{ dunepy_dir }}/dune-compiler_launcher.sh $@
diff --git a/python/dune/generator/template/dune-compiler_launcher.sh b/python/dune/generator/template/dune-compiler_launcher.sh
new file mode 100755
index 0000000000000000000000000000000000000000..0567445c9ff4a924cbd11ca41d9b699a82350a93
--- /dev/null
+++ b/python/dune/generator/template/dune-compiler_launcher.sh
@@ -0,0 +1,84 @@
+#!/bin/bash
+# SPDX-FileCopyrightInfo: Copyright © DUNE Project contributors, see file LICENSE.md in module root
+# SPDX-License-Identifier: LicenseRef-GPL-2.0-only-with-DUNE-exception
+####################################################################################
+# Usage: Use this script as compiler launcher within cmake, i.e.
+#
+# -DCMAKE_CXX_COMPILER_LAUNCHER=path_to_dune/dune-common/python/dune/generator/template/dune-compiler_launcher.sh
+#
+# In addition set -DCMAKE_CXX_FLAGS="" to only get compiler flags added by the
+# cmake configuration. Set you own compiler flags by setting
+#
+# export DEFAULT_CXXFLAGS="-O3 -DNDEBUG -Wall"
+#
+# or whatever the default should be.
+#
+# Overload the CXXFLAGS when calling make by
+#
+# make target CXXFLAGS="-g"
+#
+# or
+#
+# make target GRIDTYPE=" .. "
+#
+#####################################################################################
+
+# set as environment variable or change here
+if [ "$DEFAULT_CXXFLAGS" == "" ]; then
+  # default CXX flags provided here
+  DEFAULT_CXXFLAGS="-O3 -DNDEBUG -Wall"
+fi
+
+SED=sed
+GREP=grep
+CUT=cut
+ENV=env
+ECHO=echo
+
+# store compiler, provided as first argument to script
+COMPILER=$1
+
+# store compiler flags
+FLAGS="${@:2}"
+
+if [ "$CXXFLAGS" == "" ]; then
+  # default CXX flags provided by user
+  CXXFLAGS="$DEFAULT_CXXFLAGS"
+fi
+
+if [ "$EXTRA_CXXFLAGS" != "" ]; then
+  # extra CXX flags
+  CXXFLAGS="$CXXFLAGS $EXTRA_CXXFLAGS"
+fi
+
+# check for available grid implementations
+GRIDS=
+if [ "$GRIDTYPE" != "" ]; then
+  CONFIG_H=config.h
+  GRIDS=`$GREP "defined USED_[A-Z_]*_GRIDTYPE" $CONFIG_H | $SED 's/\(.*defined USED\_\)\(.*\)\(\_GRIDTYPE*\)/\2/g'`
+fi
+
+OLDFLAGS=$FLAGS
+FLAGS=
+for FLAG in $OLDFLAGS; do
+  NEWFLAG=$FLAG
+  VARNAME=`$ECHO $FLAG | $GREP "\-D" | $SED 's/-D//g'`
+  for GRID in $GRIDS; do
+    if [ "$VARNAME" == "$GRID" ]; then
+      NEWFLAG="-D$GRIDTYPE"
+      break
+    fi
+  done
+  VARNAME=`$ECHO $VARNAME | $GREP "=" | $CUT -d "=" -f 1`
+  if [ "$VARNAME" != "" ]; then
+    VAR=`$ENV | $GREP $VARNAME`
+    if [ "$VAR" != "" ]; then
+      # add variable from environment to flags list
+      NEWFLAG="-D$VARNAME=${!VARNAME}"
+    fi
+  fi
+  FLAGS="$FLAGS $NEWFLAG"
+done
+# call compiler
+$ECHO "$COMPILER $CXXFLAGS $FLAGS"
+exec $COMPILER $CXXFLAGS $FLAGS
diff --git a/python/dune/packagemetadata.py b/python/dune/packagemetadata.py
index e5edc1f7cb69efbd193b2992db0116fa92586808..d5c934589cc79d71a4dd3b66efbcd924183f5b6f 100644
--- a/python/dune/packagemetadata.py
+++ b/python/dune/packagemetadata.py
@@ -324,17 +324,17 @@ def envCMakeFlags(flags=[]):
         flags += shlex.split(cmakeFlags)
     return flags
 
-def defaultCMakeFlags():
+def defaultCMakeFlags(overwrite=None):
     # defaults
     flags = dict([
         ('CMAKE_CXX_FLAGS', '-O3 -DNDEBUG'),              # same as release
         ('CMAKE_INSTALL_RPATH_USE_LINK_PATH', 'TRUE'),
-        ('DUNE_ENABLE_PYTHONBINDINGS', 'TRUE'),
-        ('ALLOW_CXXFLAGS_OVERWRITE', 'ON'),
         ('CMAKE_DISABLE_FIND_PACKAGE_LATEX', 'TRUE'),
         ('CMAKE_DISABLE_FIND_PACKAGE_Doxygen', 'TRUE'),
         ('INKSCAPE', 'FALSE'),
     ])
+    if overwrite is not None:
+        flags.update(overwrite)
     # if inVEnv():
     #     flags['DUNE_PYTHON_VIRTUALENV_PATH'] = sys.prefix
     flags = cmakeArguments(flags)  # make cmake command line out of dict
@@ -599,10 +599,8 @@ def _extractCMakeFlags():
         stdout, _ = proc.communicate()
         cmakeArgs = shlex.split(stdout.decode('utf-8'))
 
-    """
     # check environment variable
-    cmakeArgs += shlex.split(os.environ.get('CMAKE_FLAGS', ''))
-
+    cmakeArgs += shlex.split(os.environ.get('DUNE_CMAKE_FLAGS', ''))
     for y in cmakeArgs:
         try:
             k, v = y.split("=", 1)
@@ -611,7 +609,6 @@ def _extractCMakeFlags():
             cmakeFlags[k] = v.strip()
         except ValueError:  # no '=' in line
             pass
-    """
 
     # try to unify 'ON' and 'OFF' values
     for k, v in cmakeFlags.items():