diff --git a/hpvm/projects/hpvm-rt/CMakeLists.txt b/hpvm/projects/hpvm-rt/CMakeLists.txt
index b8a1716f2a7c18c7e1dcb8d907c3585707c22386..02ab62fca57f66155ffafff0686634b3efe4f861 100644
--- a/hpvm/projects/hpvm-rt/CMakeLists.txt
+++ b/hpvm/projects/hpvm-rt/CMakeLists.txt
@@ -6,18 +6,20 @@ SET(CMAKE_CXX_STANDARD 11)
 # Defines ${OpenCL_INCLUDE_DIRS} and ${OpenCL_LIBRARY} if found
 find_package(OpenCL REQUIRED)
 
-add_llvm_library(hpvm-rt.ll hpvm-rt.cpp
-  DEPENDS
-  clang
-  llvm-dis
-)
-target_compile_options(hpvm-rt.ll PUBLIC -flto)
-target_include_directories(hpvm-rt.ll PRIVATE ${OpenCL_INCLUDE_DIRS})
-link_directories(${OpenCL_LIBRARY})
-
-add_custom_target(hpvm-rt.cpp.o ALL
-  COMMAND ar -x ${CMAKE_BINARY_DIR}/lib/libhpvm-rt.ll.a
-  COMMAND mv ${CMAKE_BINARY_DIR}/tools/hpvm/projects/hpvm-rt/hpvm-rt.cpp.o ${CMAKE_BINARY_DIR}/tools/hpvm/projects/hpvm-rt/hpvm-rt.bc
-  COMMAND  ${CMAKE_BINARY_DIR}/bin/llvm-dis  ${CMAKE_BINARY_DIR}/tools/hpvm/projects/hpvm-rt/hpvm-rt.bc)
+# This puts libhpvm-rt.a in lib/ which we don't care about
+# we want ${CMAKE_CURRENT_BINARY_DIR}/CMakeFiles/hpvm-rt.dir/hpvm-rt.cpp.o
+# which is a LLVM Bitcode file because of the -flto below.
+add_llvm_library(hpvm-rt hpvm-rt.cpp DEPENDS clang)
+target_compile_options(hpvm-rt PUBLIC -flto)
+target_include_directories(hpvm-rt PRIVATE ${OpenCL_INCLUDE_DIRS})
+target_link_directories(hpvm-rt PUBLIC ${OpenCL_LIBRARY})
 
-add_dependencies(hpvm-rt.cpp.o   hpvm-rt.ll)
+# Move and rename hpvm-rt.cpp.o to be an actual bc code
+add_custom_command(
+  OUTPUT "${CMAKE_CURRENT_BINARY_DIR}/hpvm-rt.bc" ALL
+  DEPENDS hpvm-rt
+  COMMAND cp
+    ${CMAKE_CURRENT_BINARY_DIR}/CMakeFiles/hpvm-rt.dir/hpvm-rt.cpp.o
+    ${CMAKE_CURRENT_BINARY_DIR}/hpvm-rt.bc
+)
+add_custom_target(hpvm-rt.bc ALL DEPENDS "${CMAKE_CURRENT_BINARY_DIR}/hpvm-rt.bc")