Only run custom targets when needed.
Fix library targets output name.
Link libraries and trigger custon targets only when needed.