cmake: keep duplicate dependencies in order to fix gcc link order problems
tweaked dependency order in cmake files
Fixed GCC compilation problems