Imported Upstream version 2.8.10.2
[platform/upstream/cmake.git] / Modules / Findosg_functions.cmake
1 #
2 # This CMake file contains two macros to assist with searching for OSG
3 # libraries and nodekits.  Please see FindOpenSceneGraph.cmake for full
4 # documentation.
5 #
6
7 #=============================================================================
8 # Copyright 2009 Kitware, Inc.
9 # Copyright 2009-2012 Philip Lowman <philip@yhbt.com>
10 #
11 # Distributed under the OSI-approved BSD License (the "License");
12 # see accompanying file Copyright.txt for details.
13 #
14 # This software is distributed WITHOUT ANY WARRANTY; without even the
15 # implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
16 # See the License for more information.
17 #=============================================================================
18 # (To distribute this file outside of CMake, substitute the full
19 #  License text for the above reference.)
20
21 #
22 # OSG_FIND_PATH
23 #
24 function(OSG_FIND_PATH module header)
25    string(TOUPPER ${module} module_uc)
26
27    # Try the user's environment request before anything else.
28    find_path(${module_uc}_INCLUDE_DIR ${header}
29        HINTS
30             ENV ${module_uc}_DIR
31             ENV OSG_DIR
32             ENV OSGDIR
33             ENV OSG_ROOT
34             ${${module_uc}_DIR}
35             ${OSG_DIR}
36        PATH_SUFFIXES include
37        PATHS
38             /sw # Fink
39             /opt/local # DarwinPorts
40             /opt/csw # Blastwave
41             /opt
42             /usr/freeware
43    )
44 endfunction()
45
46
47 #
48 # OSG_FIND_LIBRARY
49 #
50 function(OSG_FIND_LIBRARY module library)
51    string(TOUPPER ${module} module_uc)
52
53    find_library(${module_uc}_LIBRARY
54        NAMES ${library}
55        HINTS
56             ENV ${module_uc}_DIR
57             ENV OSG_DIR
58             ENV OSGDIR
59             ENV OSG_ROOT
60             ${${module_uc}_DIR}
61             ${OSG_DIR}
62        PATH_SUFFIXES lib
63        PATHS
64             /sw # Fink
65             /opt/local # DarwinPorts
66             /opt/csw # Blastwave
67             /opt
68             /usr/freeware
69    )
70
71    find_library(${module_uc}_LIBRARY_DEBUG
72        NAMES ${library}d
73        HINTS
74             ENV ${module_uc}_DIR
75             ENV OSG_DIR
76             ENV OSGDIR
77             ENV OSG_ROOT
78             ${${module_uc}_DIR}
79             ${OSG_DIR}
80        PATH_SUFFIXES lib
81        PATHS
82             /sw # Fink
83             /opt/local # DarwinPorts
84             /opt/csw # Blastwave
85             /opt
86             /usr/freeware
87     )
88
89    if(NOT ${module_uc}_LIBRARY_DEBUG)
90       # They don't have a debug library
91       set(${module_uc}_LIBRARY_DEBUG ${${module_uc}_LIBRARY} PARENT_SCOPE)
92       set(${module_uc}_LIBRARIES ${${module_uc}_LIBRARY} PARENT_SCOPE)
93    else()
94       # They really have a FOO_LIBRARY_DEBUG
95       set(${module_uc}_LIBRARIES
96           optimized ${${module_uc}_LIBRARY}
97           debug ${${module_uc}_LIBRARY_DEBUG}
98           PARENT_SCOPE
99       )
100    endif()
101 endfunction()
102
103 #
104 # OSG_MARK_AS_ADVANCED
105 # Just a convenience function for calling MARK_AS_ADVANCED
106 #
107 function(OSG_MARK_AS_ADVANCED _module)
108    string(TOUPPER ${_module} _module_UC)
109    mark_as_advanced(${_module_UC}_INCLUDE_DIR)
110    mark_as_advanced(${_module_UC}_LIBRARY)
111    mark_as_advanced(${_module_UC}_LIBRARY_DEBUG)
112 endfunction()