mongo-cxx-driver provides CMake targets: find_package(bsoncxx CONFIG REQUIRED) target_link_libraries(main PRIVATE $,mongo::bsoncxx_static,mongo::bsoncxx_shared>) find_package(mongocxx CONFIG REQUIRED) target_link_libraries(main PRIVATE $,mongo::mongocxx_static,mongo::mongocxx_shared>)