[CMake] Building Mac kext from CMake

Tim Schooley tim at sbdev.net
Thu Jul 10 07:00:39 EDT 2008


Hi Sean,

Sean McBride wrote:
> On 7/9/08 5:06 PM, Tim Schooley said:
> 
>> I have a kernel extension that I would like to build from CMake
>> in order to include it in CPack.
> 
> You are very likely the first to try that, and I'd be surprised if it
> went smoothly.  IIRC, building kexts requires several non-typical
> compiler/linker flags.  IMHO, CMake's strength is its cross-platform
> nature.  A Mac OS X kext by its very nature is not portable, and I don't
> quite 'get' why you'd want to use CMake.
> 

Thanks for the reply. I probably didn't give enough information on what
I'm trying to do.

I have an application that compiles in both Linux and Mac OS X. The
majority of the code is user-space (all of which is portable), and the
only niggling thing with the build system is the kernel stuff. There are
Linux kernel modules, and a single Mac OS X kernel extension.

Currently, the Linux kernel modules are built within CMake using a
custom command to launch "Kbuild", the Linux kernel build system. I've
had to manually specify each output file in order to aid cleaning, since
Kbuild is in-source-tree (hence it spams my source tree).

The Mac OS X kernel extension required me to use XCode to set up the
build environment for kernel extensions, which use many compiler
specifics/tricks. I don't really want to go down the route of attempting
to compile the kext from _within_ CMake, as it would be costly in time
to investigate this. Instead, I simply want to launch xcodebuild, and
use the output as an install target for CPack to pick up on.

Although by the looks of it, CPack isn't quite ready for our requirements.

Kind regards,

Tim



More information about the CMake mailing list