4 # PLIB_FOUND, if false, do not try to link to PLIB
5 # PLIB_INCLUDE_DIR, where to find the headers
7 # $PLIBDIR is an environment variable that would
8 # correspond to the ./configure --prefix=$PLIBDIR
9 # used in building PLIB.
11 # Created by James Turner. This was influenced by the FindOpenAL.cmake module.
13 #=============================================================================
14 # Copyright 2005-2009 Kitware, Inc.
16 # Distributed under the OSI-approved BSD License (the "License");
17 # see accompanying file Copyright.txt for details.
19 # This software is distributed WITHOUT ANY WARRANTY; without even the
20 # implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
21 # See the License for more information.
22 #=============================================================================
23 # (To distributed this file outside of CMake, substitute the full
24 # License text for the above reference.)
26 # Per my request, CMake should search for frameworks first in
27 # the following order:
28 # ~/Library/Frameworks/OpenAL.framework/Headers
29 # /Library/Frameworks/OpenAL.framework/Headers
30 # /System/Library/Frameworks/OpenAL.framework/Headers
32 # On OS X, this will prefer the Framework version (if found) over others.
33 # People will have to manually change the cache values of
34 # OPENAL_LIBRARY to override this selection or set the CMake environment
35 # CMAKE_INCLUDE_PATH to modify the search paths.
37 set(save_FIND_FRAMEWORK ${CMAKE_FIND_FRAMEWORK})
38 set(CMAKE_FIND_FRAMEWORK ONLY)
39 FIND_PATH(PLIB_INCLUDE_DIR ul.h
40 PATH_SUFFIXES include/plib include
45 set(CMAKE_FIND_FRAMEWORK ${save_FIND_FRAMEWORK})
47 if(NOT PLIB_INCLUDE_DIR)
48 FIND_PATH(PLIB_INCLUDE_DIR plib/ul.h
58 message(STATUS ${PLIB_INCLUDE_DIR})
60 # check for dynamic framework on Mac ()
61 FIND_LIBRARY(PLIB_LIBRARIES
70 macro(find_static_component comp libs)
71 set(compLib "plib${comp}")
72 string(TOUPPER "PLIB_${comp}_LIBRARY" compLibName)
74 FIND_LIBRARY(${compLibName}
77 PATH_SUFFIXES lib64 lib libs64 libs libs/Win32 libs/Win64
84 set(componentLib ${${compLibName}})
85 if (NOT ${componentLib} STREQUAL "componentLib-NOTFOUND")
86 #message(STATUS "found ${componentLib}")
87 list(APPEND ${libs} ${componentLib})
88 #set(PLIB_LIBRARIES "${PLIB_LIBRARIES} ${componentLib}" PARENT_SCOPE)
92 if(${PLIB_LIBRARIES} STREQUAL "PLIB_LIBRARIES-NOTFOUND")
93 set(PLIB_LIBRARIES "") # clear value
95 # based on the contents of deps, add other required PLIB
96 # static library dependencies. Eg PUI requires SSG and FNT
97 set(outDeps ${PLIB_FIND_COMPONENTS})
99 foreach(c ${PLIB_FIND_COMPONENTS})
100 if (${c} STREQUAL "pu")
101 list(APPEND outDeps "fnt" "ssg" "sg")
102 elseif (${c} STREQUAL "puaux")
103 list(APPEND outDeps "pu" "fnt" "ssg" "sg")
104 elseif (${c} STREQUAL "ssg")
105 list(APPEND outDeps "sg")
109 list(APPEND outDeps "ul") # everything needs ul
110 list(REMOVE_DUPLICATES outDeps) # clean up
112 # look for traditional static libraries
113 foreach(component ${outDeps})
114 find_static_component(${component} PLIB_LIBRARIES)
118 list(FIND outDeps "js" haveJs)
119 if(${haveJs} GREATER -1)
120 message(STATUS "adding runtime JS dependencies")
122 # resolve frameworks to full paths
123 find_library(IOKIT_LIBRARY IOKit)
124 find_library(CF_LIBRARY CoreFoundation)
125 set(JS_LIBS ${IOKIT_LIBRARY} ${CF_LIBRARY})
127 find_library(WINMM_LIBRARY winmm)
128 set(JS_LIBS ${WINMM_LIBRARY})
129 elseif(CMAKE_SYSTEM_NAME MATCHES "Linux")
130 # anything needed here?
131 elseif(CMAKE_SYSTEM_NAME MATCHES "FreeBSD")
132 find_library(USBHID_LIBRARY usbhid)
133 # check_function_exists(hidinit)
134 set(JS_LIBS ${USBHID_LIBRARY})
136 message(WARNING "Unsupported platform for PLIB JS libs")
139 list(APPEND PLIB_LIBRARIES ${JS_LIBS})
142 include(FindPackageHandleStandardArgs)
143 FIND_PACKAGE_HANDLE_STANDARD_ARGS(PLIB DEFAULT_MSG PLIB_LIBRARIES PLIB_INCLUDE_DIR)