Added extra if loop to CMakeLists to compile on mac