Automatic switch to GPU version during build

- updated CMake commands
- updated source code using macros