Move BUILD_MAIN section in main CMakelists to after code used to fetch and link against dependencies.