aboutsummaryrefslogtreecommitdiff
path: root/attic/modules/FindKDEWin.cmake
blob: 8f690737cb14d49449d1e1dad0ec6fc3a7e2f85c (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
# - Try to find the KDEWIN library
# 
# Once done this will define
#
#  KDEWIN_FOUND - system has KDEWIN
#  KDEWIN_INCLUDES - the KDEWIN include directories
#  KDEWIN_LIBRARIES - The libraries needed to use KDEWIN

# Copyright (c) 2006, Alexander Neundorf, <neundorf@kde.org>
# Copyright (c) 2007-2009, Ralf Habacker, <ralf.habacker@freenet.de>
#
# Redistribution and use is allowed according to the terms of the BSD license.
# For details see the accompanying COPYING-CMAKE-SCRIPTS file.


if (WIN32)

  if(WINCE)
    FIND_PACKAGE(WCECOMPAT REQUIRED)
  endif()
    
  if (NOT KDEWIN_LIBRARY)
 

    find_path(KDEWIN_INCLUDE_DIR kdewin_export.h
      ${KDE4_INCLUDE_DIR}
      ${CMAKE_INCLUDE_PATH}
      ${CMAKE_INSTALL_PREFIX}/include
    )
 
    # search for kdewin in the default install directory for applications (default of (n)make install)
    FILE(TO_CMAKE_PATH "${CMAKE_LIBRARY_PATH}" _cmakeLibraryPathCmakeStyle)

    string(TOLOWER "${CMAKE_BUILD_TYPE}" CMAKE_BUILD_TYPE_TOLOWER)
    if (CMAKE_BUILD_TYPE_TOLOWER MATCHES debug)
        set (LIBRARY_NAME kdewind)
    else()
        set (LIBRARY_NAME kdewin)
    endif (CMAKE_BUILD_TYPE_TOLOWER MATCHES debug)

    find_library(KDEWIN_LIBRARY
      NAMES ${LIBRARY_NAME}
      PATHS 
        ${KDE4_LIB_DIR}
        ${_cmakeLibraryPathCmakeStyle}
        ${CMAKE_INSTALL_PREFIX}/lib
      NO_SYSTEM_ENVIRONMENT_PATH
    )
  endif (NOT KDEWIN_LIBRARY)

  if (KDEWIN_LIBRARY AND KDEWIN_INCLUDE_DIR)
    set(KDEWIN_FOUND TRUE)
    # add needed system libs
    if(NOT WINCE)
        set(KDEWIN_LIBRARIES ${KDEWIN_LIBRARY} user32 shell32 ws2_32 netapi32 userenv)
    else()
         set(KDEWIN_LIBRARIES ${KDEWIN_LIBRARY} ws2 ${WCECOMPAT_LIBRARIES})
    endif()

    if (MINGW)
      #mingw compiler
      set(KDEWIN_INCLUDES ${KDEWIN_INCLUDE_DIR} ${KDEWIN_INCLUDE_DIR}/mingw ${QT_INCLUDES})
    else (MINGW)
      # msvc compiler
      # add the MS SDK include directory if available
      file(TO_CMAKE_PATH "$ENV{MSSDK}" MSSDK_DIR)
      if (WINCE)
        set(KDEWIN_INCLUDES ${KDEWIN_INCLUDE_DIR} ${KDEWIN_INCLUDE_DIR}/msvc ${WCECOMPAT_INCLUDE_DIR} ${QT_INCLUDES} ${MSSDK_DIR})
      else()
        set(KDEWIN_INCLUDES ${KDEWIN_INCLUDE_DIR} ${KDEWIN_INCLUDE_DIR}/msvc ${QT_INCLUDES} ${MSSDK_DIR})
      endif()
    endif (MINGW)

  endif (KDEWIN_LIBRARY AND KDEWIN_INCLUDE_DIR)
  # required for configure
  set(CMAKE_REQUIRED_INCLUDES ${CMAKE_REQUIRED_INCLUDES} ${KDEWIN_INCLUDES})
  set(CMAKE_REQUIRED_LIBRARIES ${CMAKE_REQUIRED_LIBRARIES} ${KDEWIN_LIBRARIES})      

  if (KDEWIN_FOUND)
    if (NOT KDEWin_FIND_QUIETLY)
      message(STATUS "Found KDEWin library: ${KDEWIN_LIBRARY}")
    endif (NOT KDEWin_FIND_QUIETLY)

  else (KDEWIN_FOUND)
    if (KDEWin_FIND_REQUIRED)
      message(FATAL_ERROR "Could NOT find KDEWin library\nPlease install it first")
    endif (KDEWin_FIND_REQUIRED)
  endif (KDEWIN_FOUND)
endif (WIN32)