cmake: handle cases when cmake has pre-initialized CMAKE_INSTALL_PREFIX

While googling some cmake stuff I came across a thread where a user was having trouble with unexpected paths in CMAKE_INSTALL_PREFIX which were pre-initialized by cmake itself. I've never seen such cases but I thought better be safe than sorry as there's a way to detect that situation.