Refactor lib cmake