The way that cocos2d-x does cross-platform is the traditional way: you have a core library written in a platform independent manner in a platform independent language (C++). By "written in a platform independent manner" we mean that at its lowest level it is written in terms of calls to functions that have different concrete implementations for the different platforms that it supports. There is then a thin shell of an executable that is in whatever the sort of the native language of the platform in question is (Objective-C on iOS, etc.) that does a minimum of initialization and then just calls into the library, and you the user of the framework, to the extent possible, write your game in terms of the platform independent methods exposed by the core library and/or platform independent wrappers around platform dependent functionality and thus that part of your game can be used as-is across platforms.
It is more or less impossible the layer this kind of architecture on to an existing platform-dependent codebase. Basically you can't do cross-platform like this after the fact without re-writing.