The package sparsehash provides CMake targets: find_package(sparsehash CONFIG REQUIRED) target_link_libraries(main PRIVATE sparsehash::sparsehash)