You can target military objectives like certain infrastructure to disable it, but you’re not allowed to target civilians. The rules of war just says when civilian casualties aren’t punishable. You have to take measures to ensure attacks are as precise as you can make them and with as little collateral damage as possible.
“eliminate every human because they might be an enemy” is not a valid military objective.