unittests: Use the correct defines and global variables when building on CMake.