
#=============================================================================
# Copyright 2005-2009 Kitware, Inc.
#
# Distributed under the OSI-approved BSD License (the "License");
# see accompanying file Copyright.txt for details.
#
# This software is distributed WITHOUT ANY WARRANTY; without even the
# implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
# See the License for more information.
#=============================================================================
#  License text for the above reference.)
# 2014 Greg Jung. MSYS specific work to begin the program.
#  was just a generic find program with registry searches
#  (Mingw/msys installation does not now use the windows registry)
#  try to hook into the msys system includes, libraries
#
# this is found because it is IN $PATH
# basic CMakeMSYSFindMake.cmake:
	find_program(CMAKE_MAKE_PROGRAM make)
    mark_as_advanced(CMAKE_MAKE_PROGRAM)
#
find_path( _USR_PATH
   msys-1.0.dll
   ENV PATH
   NO_DEFAULT_PATH)
find_path( CMAKE_USR_PATH msys.bat 
   PATH ${_USR_PATH}/../
   NO_DEFAULT_PATH)
   
   
if(CMAKE_USR_PATH)
#  we seem to have a fully-qualified MSYS host system.
#  not just the stuff we can ram through 

   set(CMAKE_SYSTEM_PREFIX_PATH ${CMAKE_USR_PATH}/local;${CMAKE_USR_PATH} )
   message(STATUS
 " <cmakeMSYSfindmake> CMAKE_SYSTEM_PREFIX_PATH=${CMAKE_SYSTEM_PREFIX_PATH}")
      
   set( CMAKE_SYSTEM_INCLUDE_PATH)
   list(APPEND CMAKE_SYSTEM_INCLUDE_PATH
       ${CMAKE_USR_PATH}/local/include
       ${CMAKE_USR_PATH}/include
#   Windows API on Cygwin
		${CMAKE_USR_PATH}/include/w32api
       )

#   set( CMAKE_REQUIRED_INCLUDES ${CMAKE_SYSTEM_INCLUDE_PATH})
    set( CMAKE_SYSTEM_LIBRARY_PATH
        ${CMAKE_USR_PATH}/local/lib;
        ${CMAKE_USR_PATH}/lib;
#  Windows API on Cygwin
		${CMAKE_USR_PATH}/lib/w32api;
       )
else()
	message(" MSYS did not find msys-1.0.dll in \$PATH!")
endif(CMAKE_USR_PATH)