Smoking is associated with reduced memory and with decline in cognitive function over the long term. Compared to people who continue smoking, people who stop smoking sooner have less decline.
From Sabia et al 2008:
smokers compared with those who never smoked were more likely to be in the lowest quintile of cognitive performance. After adjustment for multiple covariates, this risk remained for memory (OR, 1.37; 95% CI, 1.10-1.73)
From Sabia et al 2012:
Faster cognitive decline was observed among current smokers compared with never smokers in men (mean difference in 10-year decline in global cognition = −0.09 [95% CI, −0.15 to −0.03] and executive function = −0.11 [95% CI, −0.17 to −0.05]). Recent ex-smokers had greater decline in executive function (−0.08 [95% CI, −0.14 to −0.02]), while the decline in long-term ex-smokers was similar to that among never smokers.
In the second study, the effect was observed in men but not women.
Because these are not randomized studies (and indeed, randomizing people to smoke or not smoke over decades is not an ethical study that will ever be conducted), causality is difficult to infer, but they are strongly suggestive.
Because these are long-term studies, they say little about the acute effects of nicotine. Acutely, like other stimulants, nicotine can cause cognitive enhancement. However, long-term users become sensitive to being deprived of nicotine and require nicotine to get back to baseline. Smoking more and more and more to get a benefit is probably not a great idea, so there is no potential for nicotine to be used for long-term cognitive enhancement.
From Myers et al 2008:
Overnight tobacco deprivation resulted in impaired functioning on all cognitive tests and increased self-reports of tobacco craving and negative mood; nicotine normalized these deficits. In the nondeprived condition, nicotine enhanced performance on the continuous performance test (CPT) and an arithmetic test in a dose-related manner, but had no effect on working memory.
Myers, C. S., Taylor, R. C., Moolchan, E. T., & Heishman, S. J. (2008). Dose-related enhancement of mood and cognition in smokers administered nicotine nasal spray. Neuropsychopharmacology, 33(3), 588.
Sabia, S., Elbaz, A., Dugravot, A., Head, J., Shipley, M., Hagger-Johnson, G., ... & Singh-Manoux, A. (2012). Impact of smoking on cognitive decline in early old age: the Whitehall II cohort study. Archives of general psychiatry, 69(6), 627-635.
Sabia, S., Marmot, M., Dufouil, C., & Singh-Manoux, A. (2008). Smoking history and cognitive function in middle age from the Whitehall II study. Archives of internal medicine, 168(11), 1165-1173.