diff --git a/src/libcprover-cpp/CMakeLists.txt b/src/libcprover-cpp/CMakeLists.txt index d32b4074bf5..cd8a336bb30 100644 --- a/src/libcprover-cpp/CMakeLists.txt +++ b/src/libcprover-cpp/CMakeLists.txt @@ -61,7 +61,20 @@ target_link_libraries(cprover-api-cpp set(DEPENDENCY_TARGETS "") foreach(dep ${LIBRARY_DEPENDENCIES}) if(TARGET ${dep}) - list(APPEND DEPENDENCY_TARGETS "$") + # Check if this is an IMPORTED target + get_target_property(is_imported ${dep} IMPORTED) + if(is_imported) + # For IMPORTED targets, get the library path from IMPORTED_LOCATION + get_target_property(dep_static_path ${dep} IMPORTED_LOCATION) + if(dep_static_path) + list(APPEND DEPENDENCY_TARGETS ${dep_static_path}) + else() + message(FATAL_ERROR "libcprover-cpp cannot be linked as IMPORTED dependency ${dep} does not have IMPORTED_LOCATION property set") + endif() + else() + # For regular targets, use TARGET_FILE generator expression + list(APPEND DEPENDENCY_TARGETS "$") + endif() else() find_library(dep_path ${dep}) string(REGEX REPLACE "[.]so$" ".a" dep_static_path ${dep_path})