[flang] Create intrinsics modules directory (contd.)

Use -module-dir rather than WORKING_DIRECTORY because we are potentially
creating the working directory in this custom command.

GitOrigin-RevId: bcf95cbb2ce428d7b6d41d29a198889dc02617a7
diff --git a/tools/f18/CMakeLists.txt b/tools/f18/CMakeLists.txt
index 25f633e..fc84bbf 100644
--- a/tools/f18/CMakeLists.txt
+++ b/tools/f18/CMakeLists.txt
@@ -47,8 +47,8 @@
   endif()
   add_custom_command(OUTPUT ${base}.mod
     COMMAND ${CMAKE_COMMAND} -E make_directory ${FLANG_INTRINSIC_MODULES_DIR}
-    COMMAND f18 -fsyntax-only ${FLANG_SOURCE_DIR}/module/${filename}.f90
-    WORKING_DIRECTORY ${FLANG_INTRINSIC_MODULES_DIR}
+    COMMAND f18 -fsyntax-only -module-dir ${FLANG_INTRINSIC_MODULES_DIR}
+      ${FLANG_SOURCE_DIR}/module/${filename}.f90
     DEPENDS f18 ${FLANG_SOURCE_DIR}/module/${filename}.f90 ${depends}
   )
   add_custom_command(OUTPUT ${base}.f18.mod