You can just use CMake, it's pretty straightforward.
You need these things:
First, means to find out the configuration specifics. For example, if you know that some function is named differently on some platform, you can use TRY_COMPILE
to discover that:
TRY_COMPILE(HAVE_ALTERNATIVE_FUNC
${CMAKE_BINARY_DIR}
${CMAKE_SOURCE_DIR}/alternative_function_test.cpp
CMAKE_FLAGS -DINCLUDE_DIRECTORIES=xxx
)
where alternative_function_test.cpp
is a file in your source directory that compiles only with the alternative definition.
This will define variable HAVE_ALTERNATIVE_FUNC
if the compile succeeds.
Second, you need to make this definition affect your sources. Either you can add it to compile flags
IF(HAVE_TR1_RANDOM)
ADD_DEFINITIONS(-DHAVE_TR1_RANDOM)
ENDIF(HAVE_TR1_RANDOM)
or you can make a config.h
file. Create config.h.in
with the following line
#cmakedefine HAVE_ALTERNATIVE_FUNCS
and create a config.h
file by this line in CMakeLists.txt
(see CONFIGURE_FILE
)
CONFIGURE_FILE(config.h.in config.h @ONLY)
the #cmakedefine
will be translated to #define
or #undef
depending on the CMake variable.
BTW, for testing edianness, see this mail