diff --git a/CMakeLists.txt b/CMakeLists.txt
index 3816bd16703d0fadee7cb5f965635ad7e69570f3..e52f6144da7fc1b3af8b3c9308377db980f64bef 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -625,12 +625,12 @@ if (MORSE_DISTRIB_DIR OR EXISTS "${CMAKE_SOURCE_DIR}/cmake_modules/")
                     message("-- ${Red}Looking for starpu with starpu_mpi_data_register"
                     " - starpu_mpi_data_register() test fails in StarPU${ColourReset}")
                     message("-- ${Red}Check in CMakeFiles/CMakeError.log to figure out why it fails${ColourReset}")
-                endif()
-                if (CHAMELEON_SIMULATION)
-                    # function detection fails due to conflicting main
-                    # definitions. We know that the StarPU-simgrid-MPI version
-                    # has it anyway.
-                    add_definitions(-DHAVE_STARPU_MPI_DATA_REGISTER)
+                    if (CHAMELEON_SIMULATION)
+                        # function detection fails due to conflicting main
+                        # definitions. We know that the StarPU-simgrid-MPI version
+                        # has it anyway.
+                        add_definitions(-DHAVE_STARPU_MPI_DATA_REGISTER)
+                    endif()
                 endif()
             endif()
             if(HWLOC_FOUND AND HWLOC_LIBRARY_DIRS)