Context. The current paradigm to explain the presence of Jupiter-like planets with small orbital periods (P < 10 days; hot Jupiters), which involves their formation beyond the snow line following inward migration, has been challenged by recent works that explore the possibility of in situ formation. Aims. We aim to test whether stars harbouring hot Jupiters and stars with more distant gas-giant planets show any chemical peculiarity that could be related to different formation processes. Methods. Our methodology is based on the analysis of high-resolution échelle spectra. Stellar parameters and abundances of C, O, Na, Mg, Al, Si, S, Ca, Sc, Ti, V, Cr, Mn, Co, Ni, Cu, and Zn for a sample of 88 planet hosts are derived. The sample is divided into stars hosting hot (a < 0.1 au) and cool (a > 0.1 au) Jupiter-like planets. The metallicity and abundance trends of the two sub-samples are compared and set in the context of current models of planet formation and migration. Results. Our results show that stars with hot Jupiters have higher metallicities than stars with cool distant gas-giant planets in the metallicity range +0.00/+0.20 dex. The data also shows a tendency of stars with cool Jupiters to show larger abundances of α elements. No abundance differences between stars with cool and hot Jupiters are found when considering iron peak, volatile elements or the C/O, and Mg/Si ratios. The corresponding p-values from the statistical tests comparing the cumulative distributions of cool and hot planet hosts are 0.20, <0.01, 0.81, and 0.16 for metallicity, α, iron-peak, and volatile elements, respectively. We confirm previous works suggesting that more distant planets show higher planetary masses as well as larger eccentricities. We note differences in age and spectral type between the hot and cool planet host samples that might affect the abundance comparison. Conclusions. The differences in the distribution of planetary mass, period, eccentricity, and stellar host metallicity suggest a different formation mechanism for hot and cool Jupiters. The slightly larger α abundances found in stars harbouring cool Jupiters might compensate their lower metallicities allowing the formation of gas-giant planets.