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
77 macro(find_static_component comp libs)
78 # account for alternative Windows PLIB distribution naming
80 set(compLib "${comp}")
82 set(compLib "plib${comp}")
85 string(TOUPPER "PLIB_${comp}_LIBRARY" compLibName)
87 FIND_LIBRARY(${compLibName}
90 PATH_SUFFIXES lib64 lib libs64 libs libs/Win32 libs/Win64
97 set(componentLib ${${compLibName}})
98 if (NOT ${componentLib} STREQUAL "componentLib-NOTFOUND")
99 list(APPEND ${libs} ${componentLib})
103 if(${PLIB_LIBRARIES} STREQUAL "PLIB_LIBRARIES-NOTFOUND")
104 set(PLIB_LIBRARIES "") # clear value
106 # based on the contents of deps, add other required PLIB
107 # static library dependencies. Eg PUI requires SSG and FNT
108 set(outDeps ${PLIB_FIND_COMPONENTS})
110 foreach(c ${PLIB_FIND_COMPONENTS})
111 if (${c} STREQUAL "pu")
112 # handle MSVC confusion over pu/pui naming, by removing
113 # 'pu' and then adding it back
114 list(REMOVE_ITEM outDeps "pu")
115 list(APPEND outDeps ${PUNAME} "fnt" "ssg" "sg")
116 elseif (${c} STREQUAL "puaux")
117 list(APPEND outDeps ${PUNAME} "fnt" "ssg" "sg")
118 elseif (${c} STREQUAL "ssg")
119 list(APPEND outDeps "sg")
123 list(APPEND outDeps "ul") # everything needs ul
124 list(REMOVE_DUPLICATES outDeps) # clean up
128 # look for traditional static libraries
129 foreach(component ${outDeps})
130 find_static_component(${component} PLIB_LIBRARIES)
134 list(FIND outDeps "js" haveJs)
135 if(${haveJs} GREATER -1)
136 message(STATUS "adding runtime JS dependencies")
138 # resolve frameworks to full paths
139 find_library(IOKIT_LIBRARY IOKit)
140 find_library(CF_LIBRARY CoreFoundation)
141 set(JS_LIBS ${IOKIT_LIBRARY} ${CF_LIBRARY})
143 find_library(WINMM_LIBRARY winmm)
144 set(JS_LIBS ${WINMM_LIBRARY})
145 elseif(CMAKE_SYSTEM_NAME MATCHES "Linux")
146 # anything needed here?
147 elseif(CMAKE_SYSTEM_NAME MATCHES "FreeBSD")
148 find_library(USBHID_LIBRARY usbhid)
149 # check_function_exists(hidinit)
150 set(JS_LIBS ${USBHID_LIBRARY})
152 message(WARNING "Unsupported platform for PLIB JS libs")
155 list(APPEND PLIB_LIBRARIES ${JS_LIBS})
158 include(FindPackageHandleStandardArgs)
159 FIND_PACKAGE_HANDLE_STANDARD_ARGS(PLIB DEFAULT_MSG PLIB_LIBRARIES PLIB_INCLUDE_DIR)