diff --git a/cmake/modules/AddPythonLibsFlags.cmake b/cmake/modules/AddPythonLibsFlags.cmake
index c114f1ec84fef69409019cc02d8657a95f973697..da4a1bca36e1e5d6923fc52206c1289718bd93ca 100644
--- a/cmake/modules/AddPythonLibsFlags.cmake
+++ b/cmake/modules/AddPythonLibsFlags.cmake
@@ -13,12 +13,8 @@ function(add_dune_pythonlibs_flags _targets)
         if(Python3_FOUND)
             target_link_libraries(${_target} PUBLIC ${Python3_LIBRARIES})
             set_property(TARGET ${_target} APPEND PROPERTY INCLUDE_DIRECTORIES ${Python3_INCLUDE_DIRS})
-        # backward compatibility with 2.7 core tests
-        elseif(PYTHONLIBS_FOUND)
-            target_link_libraries(${_target} PUBLIC ${PYTHON_LIBRARIES})
-            set_property(TARGET ${_target} APPEND PROPERTY INCLUDE_DIRECTORIES ${PYTHON_INCLUDE_DIRS})
-        endif()
             set_property(TARGET ${_target} APPEND PROPERTY COMPILE_DEFINITIONS "HAVE_PYTHON")
             set_property(TARGET ${_target} APPEND PROPERTY COMPILE_OPTIONS "-fno-strict-aliasing")
+        endif()
     endforeach(_target ${_targets})
 endfunction(add_dune_pythonlibs_flags)