Automorphisms of nonpositively curved cube complexes, right-angled Artin groups and homology