execute_process(COMMAND ${PYTHON_EXECUTABLE} -c "import osgeo" RESULT_VARIABLE res OUTPUT_VARIABLE out ERROR_VARIABLE err)

if ( NOT ${res} EQUAL 0 )
 message("Could not detect osgeo, ${PYTHON_EXECUTABLE}")
 set( Gdal_FOUND 0 )
else ( NOT ${res} EQUAL 0 )
 execute_process(COMMAND "@PYTHON_EXECUTABLE@" -c "import osgeo;print osgeo.__version__" RESULT_VARIABLE res OUTPUT_VARIABLE out ERROR_VARIABLE err)
 if ( ${out} VERSION_LESS ${GDAL_MAJOR_MIN}.${GDAL_MINOR_MIN} )
   message("You need GDAL version ${GDAL_MAJOR_MIN}.${GDAL_MINOR_MIN} at minimum")
   set( Gdal_FOUND 0 )
 else ()
   set( Gdal_FOUND 1 )
 endif ()
endif ( NOT ${res} EQUAL 0 )
