My phone isnt compatible with Cyanogen mod how can i safely install CM? Xperia P 4.1.2 rooted.
There are basically two options: help to get it supported, or look for an unofficial build.
I wrote some notes about helping to get Cyanogenmod supported on your device in my answer to Why isn't there a Cyanogenmod stable ROM for my device?. If you already have the specialist skills needed for ROM porting, you can do this yourself, but even if you don't, other volunteers at the Cyanogenmod might be able to achieve it with your help.
The only alternative is if there's an unofficial build. Because Cyanogenmod is an open-source fork of AOSP, anyone with the skills and the hardware can port it for their device and release that build. Unofficial builds can commonly be found by searching the XDA-Developers forum. They don't have the same quality control, support community, or updates as regular CM builds, and of course with an unofficial build the risk of the ROM being backdoored (so the porter can access your phone illicitly) is much greater, but if you're willing to take those risks it provides another way to get Cyanogenmod.
If there's no unofficial build, or you don't like the risks I've described, and you're not willing to help get your device officially supported, then you can't use Cyanogenmod on your device.