diff --git a/cmake_support/OST.cmake b/cmake_support/OST.cmake
index f8f7c8100b999e8260061489c91f7b2c975fb08f..273cda3aa3a77ce2e3e4932553d5a75b5a074717 100644
--- a/cmake_support/OST.cmake
+++ b/cmake_support/OST.cmake
@@ -484,10 +484,9 @@ macro(compile_py_files module out_dir compiled_files_name)
     list(APPEND ${compiled_files_name} ${_out_file})
     get_filename_component(_in_name ${input_file} NAME)
     file(MAKE_DIRECTORY  ${out_dir})
-    add_custom_command(TARGET ${module}
+    add_custom_command(TARGET ${module} POST_BUILD
                        COMMAND ${Python_EXECUTABLE} -c "import py_compile;py_compile.compile(\"${_in_file}\",\"${_out_file}\",\"${_in_name}\",doraise=True)"
-                       VERBATIM DEPENDS ${input_file}
-                       )
+                       VERBATIM)
   endforeach()
 endmacro()