The package bzip2 is compatible with built-in CMake targets: find_package(BZip2 REQUIRED) target_link_libraries(main PRIVATE BZip2::BZip2)