~ubuntu-branches/ubuntu/oneiric/strigi/oneiric

« back to all changes in this revision

Viewing changes to cmake/FindLibraryWithDebug.cmake

  • Committer: Package Import Robot
  • Author(s): Felix Geyer
  • Date: 2011-09-24 17:12:15 UTC
  • mfrom: (1.2.6 upstream)
  • mto: This revision was merged to the branch mainline in revision 44.
  • Revision ID: package-import@ubuntu.com-20110924171215-zmbi1f77jntvz65h
Tags: upstream-0.7.6
ImportĀ upstreamĀ versionĀ 0.7.6

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
#
2
 
#  FIND_LIBRARY_WITH_DEBUG
3
 
#  -> enhanced FIND_LIBRARY to allow the search for an
4
 
#     optional debug library with a WIN32_DEBUG_POSTFIX similar
5
 
#     to CMAKE_DEBUG_POSTFIX when creating a shared lib
6
 
#     it has to be the second and third argument
7
 
#
8
 
# Copyright (c) 2007, Christian Ehrlicher, <ch.ehrlicher@gmx.de>
9
 
# Redistribution and use is allowed according to the terms of the BSD license.
10
 
# For details see the accompanying COPYING-CMAKE-SCRIPTS file.
11
 
 
12
 
MACRO(FIND_LIBRARY_WITH_DEBUG var_name win32_dbg_postfix_name dgb_postfix libname)
13
 
 
14
 
  IF(NOT ${win32_dbg_postfix_name} STREQUAL "WIN32_DEBUG_POSTFIX")
15
 
 
16
 
    # no WIN32_DEBUG_POSTFIX -> simply pass all arguments to FIND_LIBRARY
17
 
    FIND_LIBRARY(${var_name}
18
 
                 ${win32_dbg_postfix_name}
19
 
                 ${dgb_postfix}
20
 
                 ${libname}
21
 
                 ${ARGN}
22
 
    )
23
 
 
24
 
  ELSE(NOT ${win32_dbg_postfix_name} STREQUAL "WIN32_DEBUG_POSTFIX")
25
 
 
26
 
   IF(NOT WIN32)
27
 
     # on non-win32 we don't need to take care about WIN32_DEBUG_POSTFIX
28
 
 
29
 
     FIND_LIBRARY(${var_name} ${libname} ${ARGN})
30
 
 
31
 
   ELSE(NOT WIN32)
32
 
 
33
 
     # 1. get all possible libnames
34
 
     SET(args ${ARGN})
35
 
     SET(libnames_release "")
36
 
     SET(libnames_debug "")
37
 
 
38
 
     LIST(LENGTH args listCount)
39
 
 
40
 
     IF("${libname}" STREQUAL "NAMES")
41
 
       SET(append_rest 0)
42
 
       LIST(APPEND args " ")
43
 
 
44
 
       FOREACH(i RANGE ${listCount})
45
 
         LIST(GET args ${i} val)
46
 
 
47
 
         IF(append_rest)
48
 
           LIST(APPEND newargs ${val})
49
 
         ELSE(append_rest)
50
 
           IF("${val}" STREQUAL "PATHS")
51
 
             LIST(APPEND newargs ${val})
52
 
             SET(append_rest 1)
53
 
           ELSE("${val}" STREQUAL "PATHS")
54
 
             LIST(APPEND libnames_release "${val}")
55
 
             LIST(APPEND libnames_debug   "${val}${dgb_postfix}")
56
 
           ENDIF("${val}" STREQUAL "PATHS")
57
 
         ENDIF(append_rest)
58
 
 
59
 
       ENDFOREACH(i)
60
 
 
61
 
     ELSE("${libname}" STREQUAL "NAMES")
62
 
 
63
 
       # just one name
64
 
       LIST(APPEND libnames_release "${libname}")
65
 
       LIST(APPEND libnames_debug   "${libname}${dgb_postfix}")
66
 
 
67
 
       SET(newargs ${args})
68
 
 
69
 
     ENDIF("${libname}" STREQUAL "NAMES")
70
 
 
71
 
     # search the release lib
72
 
     FIND_LIBRARY(${var_name}_RELEASE
73
 
                  NAMES ${libnames_release}
74
 
                  ${newargs}
75
 
     )
76
 
 
77
 
     # search the debug lib
78
 
     FIND_LIBRARY(${var_name}_DEBUG
79
 
                  NAMES ${libnames_debug}
80
 
                  ${newargs}
81
 
     )
82
 
 
83
 
     IF(${var_name}_RELEASE AND ${var_name}_DEBUG)
84
 
 
85
 
       # both libs found
86
 
       SET(${var_name} optimized ${${var_name}_RELEASE}
87
 
                       debug     ${${var_name}_DEBUG})
88
 
 
89
 
     ELSE(${var_name}_RELEASE AND ${var_name}_DEBUG)
90
 
 
91
 
       IF(${var_name}_RELEASE)
92
 
 
93
 
         # only release found
94
 
         SET(${var_name} ${${var_name}_RELEASE})
95
 
 
96
 
       ELSE(${var_name}_RELEASE)
97
 
 
98
 
         # only debug (or nothing) found
99
 
         SET(${var_name} ${${var_name}_DEBUG})
100
 
 
101
 
       ENDIF(${var_name}_RELEASE)
102
 
       
103
 
     ENDIF(${var_name}_RELEASE AND ${var_name}_DEBUG)
104
 
 
105
 
     MARK_AS_ADVANCED(${var_name}_RELEASE)
106
 
     MARK_AS_ADVANCED(${var_name}_DEBUG)
107
 
 
108
 
   ENDIF(NOT WIN32)
109
 
 
110
 
  ENDIF(NOT ${win32_dbg_postfix_name} STREQUAL "WIN32_DEBUG_POSTFIX")
111
 
 
112
 
ENDMACRO(FIND_LIBRARY_WITH_DEBUG)