CMake ignore Anaconda libraries

Anaconda Python puts its directions first on environment variable PATH, so CMake tends to prefer to find Anaconda libraries. The problem is Anaconda libraries are generally incompatible with the system or desired compiler. For certain libraries like HDF5, Anaconda is particularly problematic at interfering with CMake.

Fix by putting in CMakeLists.txt or in the custom Find*.cmake script code like:

# exclude Anaconda directories from search
    $ENV{CONDA_PREFIX}/Library/bin $ENV{CONDA_PREFIX}/Library/lib $ENV{CONDA_PREFIX}/Library/include
  list(APPEND CMAKE_IGNORE_PATH ${h5_ignore_path})

Assuming the rest of the CMake scripts may need to find Python with Conda, reverse the above ignore by:

# pop off ignored paths so rest of script can find Python
list(REMOVE_ITEM CMAKE_IGNORE_PATH ${h5_ignore_path})