[CMake] Can cmake do configure tests?
Alexander Neundorf
a.neundorf-work at gmx.net
Thu Aug 6 16:21:43 EDT 2009
On Thursday 06 August 2009, Michael Jackson wrote:
> Here is some snippets from a project that I use: (hdf5)
>
> # Include all the necessary files for macros
> INCLUDE (${CMAKE_ROOT}/Modules/CheckFunctionExists.cmake)
> INCLUDE (${CMAKE_ROOT}/Modules/CheckIncludeFile.cmake)
> INCLUDE (${CMAKE_ROOT}/Modules/CheckIncludeFileCXX.cmake)
> INCLUDE (${CMAKE_ROOT}/Modules/CheckIncludeFiles.cmake)
> INCLUDE (${CMAKE_ROOT}/Modules/CheckLibraryExists.cmake)
> INCLUDE (${CMAKE_ROOT}/Modules/CheckSymbolExists.cmake)
> INCLUDE (${CMAKE_ROOT}/Modules/CheckTypeSize.cmake)
The above can be shortened to
INCLUDE (CheckFunctionExists)
INCLUDE (CheckIncludeFile)
INCLUDE (CheckIncludeFileCXX)
INCLUDE (CheckIncludeFiles)
INCLUDE (CheckLibraryExists)
INCLUDE (CheckSymbolExists)
INCLUDE (CheckTypeSize)
> CHECK_LIBRARY_EXISTS("ws2_32" printf HAVE_LIBWS2_32)
> CHECK_LIBRARY_EXISTS("wsock32" printf HAVE_LIBWSOCK32)
>
> CHECK_TYPE_SIZE(char SIZEOF_CHAR)
> CHECK_TYPE_SIZE(short SIZEOF_SHORT)
> CHECK_TYPE_SIZE(int SIZEOF_INT)
> CHECK_TYPE_SIZE(long SIZEOF_LONG)
>
> CHECK_FUNCTION_EXISTS(strdup HAVE_STRDUP)
> CHECK_FUNCTION_EXISTS(snprintf HAVE_SNPRINTF)
> CHECK_FUNCTION_EXISTS(system HAVE_SYSTEM)
>
> CHECK_SYMBOL_EXISTS(TIOCGWINSZ "sys/ioctl.h" HAVE_TIOCGWINSZ)
> CHECK_SYMBOL_EXISTS(TIOCGETD "sys/ioctl.h" HAVE_TIOCGETD)
and usually after all that you want to use the configure_file() command to
generate your specific config.h
Alex
More information about the CMake
mailing list