You need to create a file similar to config.h.in . Sort of
#cmakedefine HAVE_FEATURE_A @ Feature_A_FOUND@
Then you must declare the variables Feature_A_FOUND , Feature_B_FOUND , B_BITSIZE in your CMake code and call
configure_file(config.h.in config.h)
which will lead to the creation of a config.h file similar to the autotools file. If the variable is not found or set to false, the line will be commented out. Otherwise, the value will be inserted. Assume Feature_A_FOUND=A-NOTFOUND ΒΈ Feature_B_FOUND=/usr/lib/b , B_BITSIZE=64 , which leads to
#define HAVE_FEATURE_B /usr/lib/b #define HAVE_FEATURE_BITS 64
HAVE_FEATURE_B will probably be better defined as #cmakedefine01 , resulting in 0 or 1 depending on the value of the variable.
In general, you can create each config.h file generated by Autotools, since CMake is more flexible. But this requires more work, and you cannot automatically get config.h, but you must write the .in file yourself.
Documentation: https://cmake.org/cmake/help/v3.6/command/configure_file.html
source share