title: CMake cannot find library on Windows
body: <p>I Have this CMake script to find a library:</p>
  
  <pre><code>#  FANN_FOUND - system has fann
  #  FANN_INCLUDE_DIRS - the fann include directory
  #  FANN_LIBRARIES - Link these to use fann
  #  FANN_DEFINITIONS - Compiler switches required for using fann
  if(FANN_LIBRARIES AND FANN_INCLUDE_DIRS)
      set(FANN_FOUND TRUE)
  else()
  
      find_path(FANN_INCLUDE_DIR NAMES fann.h PATHS ${CMAKE_CURRENT_SOURCE_DIR}/FANN/include)
      set( _libraries doublefann fixedfann floatfann )
  
      foreach( _lib ${_libraries} )
          string( TOUPPER ${_lib} _name )
          find_library(${_name}_LIBRARY NAMES ${_lib} PATHS "${CMAKE_CURRENT_SOURCE_DIR}/FANN/lib")
      endforeach()
  
      set(FANN_INCLUDE_DIRS ${FANN_INCLUDE_DIR})
      message("${FANN_INCLUDE_DIR}")
      set(FANN_LIBRARIES ${FANN_LIBRARIES} ${DOUBLEFANN_LIBRARY}
      ${FIXEDFANN_LIBRARY} ${FLOATFANN_LIBRARY} )
  
      if( UNIX )
          set( FANN_LIBRARIES ${FANN_LIBRARIES} m )
      endif()
  
      if(FANN_INCLUDE_DIRS AND FANN_LIBRARIES)
          set(FANN_FOUND TRUE)
      endif()
  
      if(FANN_FOUND)
          if(NOT FANN_FIND_QUIETLY)
              message(STATUS "Found FANN:")
              message(STATUS "FANN_INCLUDE_DIRS: ${FANN_INCLUDE_DIRS}")
              message(STATUS "FANN_LIBRARIES: ${FANN_LIBRARIES}")
          endif()
       else()
           if(FANN_FIND_REQUIRED)
               message(FATAL_ERROR "Could not find FANN")
           endif()
       endif()
  
  mark_as_advanced(FANN_INCLUDE_DIRS FANN_LIBRARIES)
  endif()
  </code></pre>
  
  <p>The script is called <code>FindFANN.cmake</code> and it is called by my main script with the <code>find_package()</code> command. Now I have also printed the directories <code>"${CMAKE_CURRENT_SOURCE_DIR}/FANN/lib"</code> and <code>"${CMAKE_CURRENT_SOURCE_DIR}/FANN/include"</code> and they are right.
  However the libraries are not found and I cannot understand why.
  In <code>"${CMAKE_CURRENT_SOURCE_DIR}/FANN/lib"</code> I have:</p>
  
  <pre><code>fanndouble.dll
  fanndouble.lib
  fannfixed.dll
  fannfixed.lib
  fannfloat.dll
  fannfloat.lib
  </code></pre>
  
  <p>While in <code>"${CMAKE_CURRENT_SOURCE_DIR}/FANN/include"</code> I have <code>fann.h</code> among the others headers.</p>
  
  <p>I know this is not the best portable script, but for now I just need it to work...</p>
  
  <p>This is the exact output</p>
  
  <pre><code>$ cmake . -G "CodeBlocks - Unix Makefiles" 
  -- The C compiler identification is GNU 4.8.1
  -- The CXX compiler identification is GNU 4.8.1
  -- Check for working C compiler: c:/MinGW/bin/cc.exe
  -- Check for working C compiler: c:/MinGW/bin/cc.exe
  -- works
  -- Detecting C compiler ABI info
  -- Detecting C compiler ABI info - done
  -- Detecting C compile features
  -- Detecting C compile features - done 
  -- Check for working CXX compiler: c:/MinGW/bin/c++.exe 
  -- Check for working CXX compiler: c:/MinGW/bin/c++.exe -- works
  -- Detecting CXX compiler ABI info
  -- Detecting CXX compiler ABI info - done
  -- Detecting CXX compile features
  -- Detecting CXX compile features - done 
  CMake Error at cmake/Modules/FindFANN.cmake:91 (message): 
      Could not find FANN
  Call Stack (most recent call first):
      CMakeLists.txt:30 (find_package)
  
  -- Configuring incomplete, errors occurred!
  See also "C:/Users/Manuele/Documents/TicTacToe/CMakeFiles/CMakeOutput.log".
  </code></pre>
  
  <p>Here is my grep FANN CMakeCache.txt:</p>
  
  <pre><code>$ grep FANN CMakeCache.txt
  DOUBLEFANN.LIB_LIBRARY:FILEPATH=DOUBLEFANN.LIB_LIBRARY-NOTFOUND
  DOUBLEFANN_LIBRARY:FILEPATH=DOUBLEFANN_LIBRARY-NOTFOUND
  FANN_DIR:UNINITIALIZED=C:/Users/Manuele/Documents/TicTacToe/FANN/
  FANN_INCLUDE_DIR:PATH=c:/Users/Manuele/Documents/TicTacToe/FANN/include
  FIXEDFANN.LIB_LIBRARY:FILEPATH=FIXEDFANN.LIB_LIBRARY-NOTFOUND
  FIXEDFANN_LIBRARY:FILEPATH=FIXEDFANN_LIBRARY-NOTFOUND
  FLOATFANN.LIB_LIBRARY:FILEPATH=FLOATFANN.LIB_LIBRARY-NOTFOUND
  FLOATFANN_LIBRARY:FILEPATH=FLOATFANN_LIBRARY-NOTFOUND.
  </code></pre>