Move platform definitions to CMake files

This fixes an error on Linux where the compiler couldn't find the
definition of Dl_info despite dlfcn.h being included.