#
# Find the KDevelop Platform modules and sets various variables accordingly
#
# Example usage of this module:
# find_package(KDevPlatform 1.0.0 REQUIRED)
# 
# The version number and REQUIRED flag are optional. You can set CMAKE_PREFIX_PATH
# variable to help it find the required files and directories

# KDevPlatform_FOUND                   - set to TRUE if the platform was found and the version is compatible FALSE otherwise
#
# KDevPlatform_VERSION                 - The version number of kdevplatform
# KDevPlatform_VERSION_MAJOR           - The major version number of kdevplatform
# KDevPlatform_VERSION_MINOR           - The minor version number of kdevplatform
# KDevPlatform_VERSION_PATCH           - The patch version number of kdevplatform
# KDevPlatform_INCLUDE_DIR             - include dir of the platform, for example /usr/include/kdevplatform
# KDevPlatform_INTERFACES_LIBRARY      - interfaces module library
# KDevPlatform_LANGUAGE_LIBRARY        - language module library
# KDevPlatform_OUTPUTVIEW_LIBRARY      - outputview module library
# KDevPlatform_PROJECT_LIBRARY         - project module library
# KDevPlatform_SUBLIME_LIBRARY         - sublime module library
# KDevPlatform_SHELL_LIBRARY           - shell module library
# KDevPlatform_UTIL_LIBRARY            - util module library
# KDevPlatform_VCS_LIBRARY             - vcs module library
# KDevPlatform_VERITAS_LIBRARY         - test module library
# KDevPlatform_SOURCEFORMATTER_LIBRARY - source formatter library
#
# Copyright 2007 Andreas Pakulat <apaku@gmx.de>
# Copyright 2008 Alexander Neundorf <neundorf@kde.org>
# Copyright 2008 Matthew Woehlke <mw_triad@users.sourceforge.net>
# Redistribution and use is allowed according to the terms of the BSD license.

set( _args )
if( KDevPlatform_FIND_VERSION_MAJOR )
    set( _args ${KDevPlatform_FIND_VERSION_MAJOR} )
    if( KDevPlatform_FIND_VERSION_MINOR )
        set( _args ${_args}.${KDevPlatform_FIND_VERSION_MINOR} )
        if( KDevPlatform_FIND_VERSION_PATCH )
            set( _args ${_args}.${KDevPlatform_FIND_VERSION_PATCH} )
        endif( KDevPlatform_FIND_VERSION_PATCH )
    endif( KDevPlatform_FIND_VERSION_MINOR )
endif( KDevPlatform_FIND_VERSION_MAJOR )

file(TO_CMAKE_PATH "$ENV{CMAKE_PREFIX_PATH}" _env_CMAKE_PREFIX_PATH)
file(TO_CMAKE_PATH "$ENV{CMAKE_LIBRARY_PATH}" _env_CMAKE_LIBRARY_PATH)
set(KDevPlatform_SEARCH_PATHS
    ${_env_CMAKE_PREFIX_PATH} ${CMAKE_PREFIX_PATH} ${CMAKE_SYSTEM_PREFIX_PATH}
    ${_env_CMAKE_LIBRARY_PATH} ${CMAKE_LIBRARY_PATH} ${CMAKE_SYSTEM_LIBRARY_PATH}
    ${CMAKE_INSTALL_PREFIX}
    )
find_file(KDevPlatform_CONFIG_FILE NAMES KDevPlatformConfig.cmake
                                   PATH_SUFFIXES kdevplatform lib/kdevplatform lib64/kdevplatform
                                   PATHS ${KDevPlatform_SEARCH_PATHS}
                                   NO_DEFAULT_PATH )

if(KDevPlatform_CONFIG_FILE)
   include(${KDevPlatform_CONFIG_FILE})
endif(KDevPlatform_CONFIG_FILE)

include(FindPackageHandleStandardArgs)
find_package_handle_standard_args(KDevPlatform "Did not find KDevPlatform libraries. Searched for KDevPlatformConfig.cmake in '${KDevPlatform_SEARCH_PATHS}' using suffixes kdevplatform lib/kdevplatform lib64/kdevplatform." KDevPlatform_INCLUDE_DIR)
