A collection of utility scripts to imitate autotools in CMake. Many of the
macros provided by this library write to a config.h
file in
${CMAKE_CURRENT_BINARY_DIR}
. This mimics the autoconf generation of a config
header.
The autoutils_check_decl
macro uses the CheckSymbolExists
module to determine if a given declaration exists. Optionally, a list of headers
to include may be given as a second argument to this macro. If the declaration
exists, set HAVE_DECL_X
to 1
and write #define HAVE_DECL_X 1
to
config.h
. Otherwise, set HAVE_DECL_X
to 0
and write
#define HAVE_DECL_X 0
to config.h
.
The autoutils_check_func
macro uses the CheckFunctionExists
module to determine if a given function exists. If the function exists, set
HAVE_X
to ON
and write #define HAVE_X
to config.h
. Otherwise, write
/* #undef HAVE_X */
to config.h
.
The autoutils_check_header
macro uses the CheckIncludeFile
module to determine if a given header exists. If the header exists, set HAVE_X
to ON
and write #define HAVE_X
to config.h
. Otherwise, write
/* #undef HAVE_X */
to config.h
.
The autoutils_check_lib
macro uses the CheckLibraryExists
module to determine if a given library exists. The arguments should be the
library name followed by a function provided by the library. If the library
exists, set HAVE_LIBX
to ON
and write #define HAVE_LIBX
to config.h
.
Otherwise, write /* #undef HAVE_LIBX */
to config.h
.
The autoutils_check_type
macro uses the CheckTypeSize
module to determine if a given type can be found. Optionally, a list of headers
to include may be given as a second argument to this macro. If the declaration
exists, set HAVE_X
to ON
and write #define HAVE_X
to config.h
.
Otherwise, write /* #define HAVE_X */
to config.h
.
The autoutils_includes_default
takes a variable name as its only argument. It checks for
a number of headers using the autoutils_check_header
macro. If a header exists, it is
appended to the given variable. This variable contains a list of reasonable
default include files for testing macros, symbols, etc. See autoconf's
Default Includes
for details.
autoutils_write_to_config_header
appends a given line to config.h
in
${CMAKE_CURRENT_BINARY_DIR}
.
By default, the generated config is located in
${CMAKE_CURRENT_BINARY_DIR}/config.h
, but can be set before calling any
modules using the cache variable autoutils_config_path
like so:
set(autoutils_config_path
"${CMAKE_CURRENT_BINARY_DIR}/some/other/location/config.h"
CACHE FILEPATH FORCE)