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