Update CMakeLists.txt, fix compilation errors with mingw32, fix impl. of `zthread_id`