Use iree_cmake_extra_content to set compiler flags (#4930)

This reverts commit eac0c0490e52f93454c6a64460db794f8c3329a6.
This reverts commit c7d964e8d4ec5e9672db149b71f9db36b131163a.
diff --git a/build_tools/bazel_to_cmake/bazel_to_cmake.py b/build_tools/bazel_to_cmake/bazel_to_cmake.py
index de0c1db..15dc6ba 100755
--- a/build_tools/bazel_to_cmake/bazel_to_cmake.py
+++ b/build_tools/bazel_to_cmake/bazel_to_cmake.py
@@ -163,19 +163,9 @@
   if not os.path.isfile(build_file_path):
     return Status.NO_BUILD_FILE
 
-  preserve_lines = []
   if os.path.isfile(cmakelists_file_path):
-    with open(cmakelists_file_path, "rt") as f:
-      found_preserve_marker = False
+    with open(cmakelists_file_path) as f:
       for i, line in enumerate(f):
-        # Accumulate all lines on and after the special preserve marker.
-        if (not found_preserve_marker and
-            re.match(r"^### CMAKE PRESERVE ###\s*$", line)):
-          found_preserve_marker = True
-        if found_preserve_marker:
-          preserve_lines.append(line)
-          continue
-
         if EDIT_BLOCKING_PATTERN.search(line):
           if verbosity >= 1:
             log(f"Skipped. line {i + 1}: '{line.strip()}' prevents edits.",
@@ -195,9 +185,6 @@
       if write_files:
         with open(cmakelists_file_path, "wt") as cmakelists_file:
           cmakelists_file.write(converted_text)
-          if preserve_lines:
-            cmakelists_file.write("\n")
-            cmakelists_file.write("".join(preserve_lines))
       else:
         print(converted_text, end="")
     except (NameError, NotImplementedError) as e:
diff --git a/iree/compiler/Dialect/Flow/Transforms/BUILD b/iree/compiler/Dialect/Flow/Transforms/BUILD
index 0b859a5..d8afb12 100644
--- a/iree/compiler/Dialect/Flow/Transforms/BUILD
+++ b/iree/compiler/Dialect/Flow/Transforms/BUILD
@@ -12,6 +12,8 @@
 # See the License for the specific language governing permissions and
 # limitations under the License.
 
+load("//iree:build_defs.oss.bzl", "iree_cmake_extra_content")
+
 package(
     default_visibility = ["//visibility:public"],
     features = ["layering_check"],
@@ -93,3 +95,15 @@
         "@mlir-hlo//:unfuse_batch_norm",
     ],
 )
+
+# TODO(#4919): For an unknown reason, GCC's devirtualization optimization wreaks
+# havoc on this file. Needs to be further root caused. Seems to affect both 9.x
+# and 10.x.
+iree_cmake_extra_content(
+    content = """
+set_property(SOURCE
+  DispatchLinalgOnTensors.cpp
+  PROPERTY COMPILE_FLAGS $<$<CXX_COMPILER_ID:GNU>:-fno-devirtualize>)
+""",
+    inline = True,
+)
diff --git a/iree/compiler/Dialect/Flow/Transforms/CMakeLists.txt b/iree/compiler/Dialect/Flow/Transforms/CMakeLists.txt
index 3532d2c..f95fd02 100644
--- a/iree/compiler/Dialect/Flow/Transforms/CMakeLists.txt
+++ b/iree/compiler/Dialect/Flow/Transforms/CMakeLists.txt
@@ -71,11 +71,6 @@
   PUBLIC
 )
 
-### CMAKE PRESERVE ###
-
-# FIXME: https://github.com/google/iree/issues/4919
-# For an unknown reason, GCC's devirtualization optimization wreaks havoc on
-# this file. Needs to be further root caused. Seems to affect both 9.x and 10.x.
-set_source_files_properties(
+set_property(SOURCE
   DispatchLinalgOnTensors.cpp
-  PROPERTIES COMPILE_FLAGS $<$<CXX_COMPILER_ID:GNU>:-fno-devirtualize>)
+  PROPERTY COMPILE_FLAGS $<$<CXX_COMPILER_ID:GNU>:-fno-devirtualize>)