diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt
index 3c120aa..259a53d 100644
--- a/src/CMakeLists.txt
+++ b/src/CMakeLists.txt
@@ -308,7 +308,7 @@ target_link_libraries(kcov_system_lib
 add_custom_command(
     OUTPUT library.cc
     COMMAND "${CMAKE_CURRENT_SOURCE_DIR}/bin-to-c-source.py"
-            lib${SOLIB}.so
+            $<TARGET_FILE:${SOLIB}>
             __library
         > library.cc
     DEPENDS
