I use a third-party library that includes malloc_np.h. From what I found over the Internet, this means that the code should have compiled under FreeBSD, although just changing the include to malloc.hmade it compile under Linux (Ubuntu 13.10).
Now I am writing a CMake script for this library to create the corresponding make files (including the NMake make files for MSVC 2010).
What is the best way to achieve portability in such a scenario?
My current solution is to check:
${CMAKE_SYSTEM_NAME} STREQUAL "FreeBSD"
in the CMake script. Depending on the result, I give
add_definitions (-DINCLUDE_MALLOC_H="#include <malloc[_np].h>")
and use this macro in the source file instead #include <malloc_np.h>.
Is this a good practice?
Tarc