CMake ignore Anaconda libraries

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

We fix this situation by putting in CMakeLists.txt, or in the custom Find*.cmake script code like:

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

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})