[CMake] Cmake inline macro?
Dizzy
dizzy at roedu.net
Sat Sep 15 05:10:28 EDT 2007
On Saturday 15 September 2007 02:30:38 Jack Kelly wrote:
> Gregory C. Sharp wrote:
> > Hi,
> >
> > Does Cmake have a macro that tests how a compiler
> > defines inline, such as autoconf's AC_C_INLINE?
> >
> > Thanks,
> > Greg
>
> Hi Greg,
>
> I couldn't find one, so I ported AC_C_INLINE to CMake. Since there's no
> equivalent of autoheader to make the config.h.in, I just used
> ADD_DEFINITIONS.
There is such a thing, you use configure_file() to replace variables from
a "config.h.in" (tho I name them usually "config.h.cmake") or #cmakedefine
placeholders. See the cmake man page on CONFIGURE_FILE.
> Should these sort of tests be collected somewhere?
>
> Here is a minimal working example. It tests the inline keyword, then
> __inline__ and then __inline. When it finds one that works, it will
> ADD_DEFINITIONS(-Dinline=${KEYWORD}) and if none work, it will
> ADD_DEFINITIONS(-Dinline=).
Create a "config.h.cmake" with the following contents:
#define inline ${INLINE_KEYWORD}
Use it with configure_file(config.h.cmake config.h) and make sure you
include "config.h" in your code.
That is of couse assuming that the variable holding the inline keyword (or ""
if there is no inline supported) is named INLINE_KEYWORD. Many macros output
their result into a user given variable so it fits well in the cmake style.
--
Mihai RUSU Email: dizzy at roedu.net
GPG : http://dizzy.roedu.net/dizzy-gpg.txt WWW: http://dizzy.roedu.net
"Linux is obsolete" -- AST
More information about the CMake
mailing list