Make the CMakeLists.txt more robust.

Handle "AMD64" -> "X86_64" arch, link against thread libraries if
required, and add an option to disable static builds.
Clip data for `M` message using the provided length.
Add travis envs to test static/non-static builds.