[CMake] Can cmake do configure tests?

Michael Jackson mike.jackson at bluequartz.net
Thu Aug 6 09:06:40 EDT 2009


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)

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)


While there are standard tests that CMake can perform if you need  
something more specialized then you can write your own test.

HTH
_________________________________________________________
Mike Jackson                  mike.jackson at bluequartz.net
BlueQuartz Software                    www.bluequartz.net
Principal Software Engineer                  Dayton, Ohio



On Aug 5, 2009, at 9:03 PM, Joseph Garvin wrote:

> One of the cool features of autotools is configure tests -- actually  
> invoking the compiler on a small sample program and seeing if it's  
> successful. Does CMake do this or do you have to depend on #ifdef  
> SOME_PLATFORM blocks to enable/disable features?
> _______________________________________________
> Powered by www.kitware.com
>
> Visit other Kitware open-source projects at http://www.kitware.com/opensource/opensource.html
>
> Please keep messages on-topic and check the CMake FAQ at: http://www.cmake.org/Wiki/CMake_FAQ
>
> Follow this link to subscribe/unsubscribe:
> http://www.cmake.org/mailman/listinfo/cmake



More information about the CMake mailing list