Errors in FindROOT.cmake -- "REMOVE_ITEM" and file not found

I tried to use FindROOT.cmake located in /etc/cmake. I encountered errors repeated like this:

CMake Error at /opt/daq/share/cmake/FindROOT.cmake:46 (list):
  list sub-command REMOVE_ITEM requires list to be present.
Call Stack (most recent call first):
  CMakeLists.txt:55 (include)

...

My env:
CMake: 3.0.2
Platform: ArchLinux

The problem can be simple fixed by this:

cmake FindROOT.cmake 
46c46,48
<     list(REMOVE_ITEM ROOT_FIND_COMPONENTS ${_cpt})
---
>     if(ROOT_FIND_COMPONENTS)
>       list(REMOVE_ITEM ROOT_FIND_COMPONENTS ${_cpt})
>     endif()

Another problem: If I use “LINKDEF” in “root_generate_dictionary”, then I will fail in error like this

[ 65%] Built target Analyzer
make[2]: *** No rule to make target '../libAnalyzerDisplay/linkFile-NOTFOUND', needed by 'libAnalyzerDisplay/TFancyHistogramCanvasDict.cxx'

It seems that “root_generate_dictionary” cannot handle the argument “*_LinkDef.h”

OK. All Fixed as this:

cmake FindROOT.cmake
46c46,48
<     list(REMOVE_ITEM ROOT_FIND_COMPONENTS ${_cpt})
---
>     if(ROOT_FIND_COMPONENTS)
>       list(REMOVE_ITEM ROOT_FIND_COMPONENTS ${_cpt})
>     endif()
81c83
<      set(includedirs ${includedirs} -I${d})
---
>     set(includedirs ${includedirs} -I${d})
94c96
<       find_file(headerFile ${fp} PATHS ${incdirs})
---
>       find_file(headerFile ${fp} PATHS ${incdirs} ${CMAKE_CURRENT_SOURCE_DIR})
101,102c103,104
<   foreach( f ${ARG_LINKDEF})
<     find_file(linkFile ${f} PATHS ${incdirs})
---
>   foreach(f ${ARG_LINKDEF})
>     find_file(linkFile ${f} PATHS ${incdirs} ${CMAKE_CURRENT_SOURCE_DIR})

The “FindROOT.cmake” doesn’t try to find headers and linkdefs from current source dir.