A density functional theory is presented for the distribution of charged hard spheres (model for salt) around an infinite, rigid, and impenetrable charged cylinder (model for DNA or tobacco mosaic virus). The theory is based on a weighted density approach where the hard-sphere contribution to the one-particle correlation function is evaluated nonperturbatively using a position dependent effective density, and the ionic part is obtained through a second-order functional Taylor expansion around a uniform fluid. The theory is in good agreement with Monte Carlo simulations for the density distribution of monovalent, divalent, and mixed salts. For axial charge densities corresponding to DNA, the hypernetted chain integral equation theory is not as accurate as the density functional theory, but both liquid state approaches are superior to the Poisson-Boltzmann theory. For higher axial charge densities the density functional theory predicts interesting charge inversion effects that are absent in the nonlinear Poisson-Boltzmann theory.