Detect operating system in code rather than in cmake scripts.
Replaced CMakeLists.txt with PROJ.lua for the buildtool.
Fix compiler warnings.