We have investigated the baryon-mass content in a subsample of 19 clusters of galaxies extracted from the X-ray flux-limited sample HIFLUGCS according to their positions in the sky. For these clusters, we measured total masses and characteristic radii on the basis of a rich optical spectroscopic data set, the physical properties of the intracluster medium (ICM) using XMM-Newton and ROSAT X-ray data, and total (galaxy) stellar masses utilizing the SDSS DR7 multi-band imaging. The observed (hot) gas-mass fractions are almost constant in this mass range. We confirm that the stellar mass fraction decreases as the total mass increases and shows (20+/-4)% scatter; in addition, we show that it decreases as the central entropy increases. The latter behavior supports a twofold interpretation where heating from merging quenches the star-formation activity of galaxies in massive systems, and feedback from supernovae and/or radio galaxies drives a significant amount of gas to the regions beyond r_{500} or, alternatively, a substantially large amount of intracluster light (ICL) is associated with galaxies in nonrelaxed systems. Furthermore, less massive clusters are confirmed to host less gas per unit total mass; however, they exhibit higher mass fractions in metals, so that their ICM is more metal-rich. This again supports the interpretation that in the potential wells of low-mass systems the star-formation efficiency of galaxies was high or, alternatively, some gas is missing from the hot phase of the ICM. The former hypothesis is preferred as the main driver of the mass-dependent metal enrichment since the total mass-to-optical luminosity ratio increases as the total mass increases.