Production cross sections of charged pions, kaons and antikaons have been measured in C+C and C+Au collisions at beam energies of 1.0 and 1.8 AGeV for different polar emission angles. The kaon and antikaon energy spectra can be described by Boltzmann distributions whereas the pion spectra exhibit an additional enhancement at low energies. The pion multiplicity per participating nucleon M(pi+)/A_part is a factor of about 3 smaller in C+Au than in C+C collisions at 1.0 AGeV whereas it differs only little for the C and the Au target at a beam energy of 1.8 AGeV. The K+ multiplicities per participating nucleon M(K+)/A_part are independent of the target size at 1 AGeV and at 1.8 AGeV. The K- multiplicity per participating nucleon M(K-)/A_part is reduced by a factor of about 2 in C+Au as compared to C+C collisions at 1.8 AGeV. This effect might be caused by the absorption of antikaons in the heavy target nucleus. Transport model calculations underestimate the K-/K+ ratio for C+C collisions at 1.8 AGeV by a factor of about 4 if in-medium modifications of K mesons are neglected.