We study ultrathin films of 8CB in planar anchoring on a MoS2 inorganic substrate. We evidence an anchoring breakage for 60-nm-thick films, in favor of the homeotropic anchoring at the air interface. This allows one to determine the 8CB-MoS2 smectic anchoring energy. We then demonstrate for films thinner than 60 nm that, under the homeotropic bulk, an intermediate film remains in planar anchoring, associated with a melting of the smectic layers close to the substrate. Such a melting could be general for planar or tilted anchorings and we show that, for strong anchorings, the anchoring energy can be driven by the deformations of this intermediate nematic film.