fixed: win vs2015 build
[opensg.git] / Source / Contrib / CgFXMaterial / CMake / FindCg.cmake
blobd9fb6f31d74bb11e98b001fe1bbfa952ae35e5fa
1 # - Find Cg Toolkit
2 # Find the native Cg Toolkit includes and library
3 # This module defines
4 #  CG_INCLUDE_DIR, where to find cg.h, etc.
5 #  CG_LIBRARIES, the libraries needed to use Cg Toolkit.
6 #  CG_FOUND, If false, do not try to use Cg.
7 # also defined, but not for general use are
8 #  CG_LIBRARY, where to find the Cg Toolkit library.
9 ##
10 # The following variables can be used to give CMake a hint where to find Cg:
11 # CG_ROOT
14 IF(APPLE)
15     FIND_LIBRARY(CG_LIBRARY Cg
16                  PATHS ${CG_ROOT} ENV CG_ROOT)
18     IF(CG_LIBRARY)
19       MARK_AS_ADVANCED (CG_LIBRARY)
20       SET(CG_LIBRARY_RELEASE ${CG_LIBRARY}/Cg)
21       SET(CG_LIBRARY_DEBUG ${CG_LIBRARY}/Cg)
22       SET(CG_GL_LIBRARY_RELEASE ${CG_LIBRARY}/Cg)
23       SET(CG_GL_LIBRARY_DEBUG ${CG_LIBRARY}/Cg)
24       SET(CG_INCLUDE_DIR ${CG_LIBRARY}/Headers)
25       SET(CG_LIBRARIES_FOUND TRUE)
26     ENDIF()
27 ELSE(APPLE)
28     FIND_PATH(CG_INCLUDE_DIR Cg/cg.h
29         PATHS ${CG_ROOT} ENV CG_ROOT
30         PATH_SUFFIXES include)
32     IF(CMAKE_SIZEOF_VOID_P EQUAL 8)
33       SET(_OSG_CG_PATH_SUFFIXES lib64 lib.x64)
34     ELSE(CMAKE_SIZEOF_VOID_P EQUAL 8)
35       SET(_OSG_CG_PATH_SUFFIXES lib)
36     ENDIF(CMAKE_SIZEOF_VOID_P EQUAL 8)
38     SET(CG_NAMES_RELEASE ${CG_NAMES_RELEASE} Cg)
39     FIND_LIBRARY(CG_LIBRARY_RELEASE NAMES ${CG_NAMES_RELEASE}
40         NO_DEFAULT_PATH
41         PATHS ${CG_ROOT} ENV CG_ROOT
42         PATH_SUFFIXES ${_OSG_CG_PATH_SUFFIXES})
44     SET(CG_NAMES_DEBUG ${CG_NAMES_DEBUG} Cgd)
45     FIND_LIBRARY(CG_LIBRARY_DEBUG NAMES ${CG_NAMES_DEBUG}
46         NO_DEFAULT_PATH
47         PATHS ${CG_ROOT} ENV CG_ROOT
48         PATH_SUFFIXES ${_OSG_CG_PATH_SUFFIXES})
50     SET(CG_GL_NAMES_RELEASE ${CG_GL_NAMES_RELEASE} CgGL)
51     FIND_LIBRARY(CG_GL_LIBRARY_RELEASE NAMES ${CG_GL_NAMES_RELEASE}
52         NO_DEFAULT_PATH
53         PATHS ${CG_ROOT} ENV CG_ROOT
54         PATH_SUFFIXES ${_OSG_CG_PATH_SUFFIXES})
56     SET(CG_GL_NAMES_DEBUG ${CG_GL_NAMES_DEBUG} CgGLd)
57     FIND_LIBRARY(CG_GL_LIBRARY_DEBUG NAMES ${CG_GL_NAMES_DEBUG}
58         NO_DEFAULT_PATH
59         PATHS ${CG_ROOT} ENV CG_ROOT
60         PATH_SUFFIXES ${_OSG_CG_PATH_SUFFIXES})
61 ENDIF (APPLE)
63 IF(NOT WIN32)
64   IF(CG_LIBRARY_DEBUG AND CG_GL_LIBRARY_DEBUG)
65     SET(CG_LIBRARIES_FOUND TRUE)
66     MARK_AS_ADVANCED(CG_LIBRARY_DEBUG)
67   ENDIF(CG_LIBRARY_DEBUG AND CG_GL_LIBRARY_DEBUG)
68 ENDIF(NOT WIN32)
70 IF(CG_LIBRARY_RELEASE AND CG_GL_LIBRARY_RELEASE)
71   SET(CG_LIBRARIES_FOUND TRUE)
72   MARK_AS_ADVANCED(CG_LIBRARY_RELEASE)
73   IF(WIN32)
74     MARK_AS_ADVANCED(CG_LIBRARY_DEBUG)
75     SET(CG_LIBRARY_DEBUG    ${CG_LIBRARY_RELEASE}    CACHE FILEPATH "" FORCE)
76     SET(CG_GL_LIBRARY_DEBUG ${CG_GL_LIBRARY_RELEASE} CACHE FILEPATH "" FORCE)
77   ENDIF(WIN32)
78 ENDIF(CG_LIBRARY_RELEASE AND CG_GL_LIBRARY_RELEASE)
80 # handle the QUIETLY and REQUIRED arguments and set CG_FOUND to TRUE if 
81 # all listed variables are TRUE
82 INCLUDE(FindPackageHandleStandardArgs)
83 FIND_PACKAGE_HANDLE_STANDARD_ARGS(CG DEFAULT_MSG 
84                                   CG_LIBRARIES_FOUND
85                                   CG_INCLUDE_DIR)