Add CMake config
Fix build with -Wl,--as-needed

Gentoo uses -Wl,--as-needed which causes the build to fail due to
incorrect link order.