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 include(SelectLibraryConfigurations)
39 set(save_FIND_FRAMEWORK ${CMAKE_FIND_FRAMEWORK})
40 set(CMAKE_FIND_FRAMEWORK ONLY)
41 FIND_PATH(PLIB_INCLUDE_DIR ul.h
42 PATH_SUFFIXES include/plib include
47 set(CMAKE_FIND_FRAMEWORK ${save_FIND_FRAMEWORK})
49 if(NOT PLIB_INCLUDE_DIR)
50 FIND_PATH(PLIB_INCLUDE_DIR plib/ul.h
60 message(STATUS ${PLIB_INCLUDE_DIR})
62 # check for dynamic framework on Mac ()
63 FIND_LIBRARY(PLIB_LIBRARIES
79 macro(find_static_component comp libs)
80 # account for alternative Windows PLIB distribution naming
82 set(compLib "${comp}")
84 set(compLib "plib${comp}")
87 string(TOUPPER "PLIB_${comp}" compLibBase)
88 set( compLibName ${compLibBase}_LIBRARY )
90 FIND_LIBRARY(${compLibName}_DEBUG
93 PATH_SUFFIXES lib64 lib libs64 libs libs/Win32 libs/Win64
99 FIND_LIBRARY(${compLibName}_RELEASE
102 PATH_SUFFIXES lib64 lib libs64 libs libs/Win32 libs/Win64
108 select_library_configurations( ${compLibBase} )
110 set(componentLibRelease ${${compLibName}_RELEASE})
111 #message(STATUS "Simgear ${compLibName}_RELEASE ${componentLibRelease}")
112 set(componentLibDebug ${${compLibName}_DEBUG})
113 #message(STATUS "Simgear ${compLibName}_DEBUG ${componentLibDebug}")
114 if (NOT ${compLibName}_DEBUG)
115 if (NOT ${compLibName}_RELEASE)
116 #message(STATUS "found ${componentLib}")
117 list(APPEND ${libs} ${componentLibRelease})
120 list(APPEND ${libs} optimized ${componentLibRelease} debug ${componentLibDebug})
124 if(${PLIB_LIBRARIES} STREQUAL "PLIB_LIBRARIES-NOTFOUND")
125 set(PLIB_LIBRARIES "") # clear value
127 # based on the contents of deps, add other required PLIB
128 # static library dependencies. Eg PUI requires SSG and FNT
129 set(outDeps ${PLIB_FIND_COMPONENTS})
131 foreach(c ${PLIB_FIND_COMPONENTS})
132 if (${c} STREQUAL "pu")
133 # handle MSVC confusion over pu/pui naming, by removing
134 # 'pu' and then adding it back
135 list(REMOVE_ITEM outDeps "pu")
136 list(APPEND outDeps ${PUNAME} "fnt" "ssg" "sg")
137 elseif (${c} STREQUAL "puaux")
138 list(APPEND outDeps ${PUNAME} "fnt" "ssg" "sg")
139 elseif (${c} STREQUAL "ssg")
140 list(APPEND outDeps "sg")
144 list(APPEND outDeps "ul") # everything needs ul
145 list(REMOVE_DUPLICATES outDeps) # clean up
149 # look for traditional static libraries
150 foreach(component ${outDeps})
151 find_static_component(${component} PLIB_LIBRARIES)
155 list(FIND outDeps "js" haveJs)
156 if(${haveJs} GREATER -1)
157 message(STATUS "adding runtime JS dependencies")
159 # resolve frameworks to full paths
160 find_library(IOKIT_LIBRARY IOKit)
161 find_library(CF_LIBRARY CoreFoundation)
162 set(JS_LIBS ${IOKIT_LIBRARY} ${CF_LIBRARY})
164 set(WINMM_LIBRARY winmm)
165 set(JS_LIBS ${WINMM_LIBRARY})
166 elseif(CMAKE_SYSTEM_NAME MATCHES "Linux")
167 # anything needed here?
168 elseif(CMAKE_SYSTEM_NAME MATCHES "FreeBSD")
169 find_library(USBHID_LIBRARY usbhid)
170 # check_function_exists(hidinit)
171 set(JS_LIBS ${USBHID_LIBRARY})
173 message(WARNING "Unsupported platform for PLIB JS libs")
176 list(APPEND PLIB_LIBRARIES ${JS_LIBS})
179 include(FindPackageHandleStandardArgs)
180 FIND_PACKAGE_HANDLE_STANDARD_ARGS(PLIB DEFAULT_MSG PLIB_LIBRARIES PLIB_INCLUDE_DIR)