| 1 |
# Locate PLIB |
| 2 |
# This module defines |
| 3 |
# PLIB_LIBRARIES |
| 4 |
# PLIB_FOUND, if false, do not try to link to PLIB |
| 5 |
# PLIB_INCLUDE_DIR, where to find the headers |
| 6 |
# |
| 7 |
# $PLIBDIR is an environment variable that would |
| 8 |
# correspond to the ./configure --prefix=$PLIBDIR |
| 9 |
# used in building PLIB. |
| 10 |
# |
| 11 |
# Created by James Turner. This was influenced by the FindOpenAL.cmake module. |
| 12 |
|
| 13 |
#============================================================================= |
| 14 |
# Copyright 2005-2009 Kitware, Inc. |
| 15 |
# |
| 16 |
# Distributed under the OSI-approved BSD License (the "License"); |
| 17 |
# see accompanying file Copyright.txt for details. |
| 18 |
# |
| 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.) |
| 25 |
|
| 26 |
include(SelectLibraryConfigurations) |
| 27 |
|
| 28 |
FIND_PATH(PLIB_INCLUDE_DIR plib/ul.h |
| 29 |
PATH_SUFFIXES include |
| 30 |
HINTS $ENV{PLIBDIR} |
| 31 |
PATHS ${ADDITIONAL_LIBRARY_PATHS} |
| 32 |
) |
| 33 |
|
| 34 |
if (MSVC) |
| 35 |
set (PUNAME "pui") |
| 36 |
else (MSVC) |
| 37 |
set (PUNAME "pu") |
| 38 |
endif (MSVC) |
| 39 |
|
| 40 |
|
| 41 |
macro(find_static_component comp libs) |
| 42 |
# account for alternative Windows PLIB distribution naming |
| 43 |
if(MSVC) |
| 44 |
set(compLib "${comp}") |
| 45 |
else(MSVC) |
| 46 |
set(compLib "plib${comp}") |
| 47 |
endif(MSVC) |
| 48 |
|
| 49 |
string(TOUPPER "PLIB_${comp}" compLibBase) |
| 50 |
set( compLibName ${compLibBase}_LIBRARY ) |
| 51 |
|
| 52 |
FIND_LIBRARY(${compLibName}_DEBUG |
| 53 |
NAMES ${compLib}_d plib_${compLib}_d |
| 54 |
HINTS $ENV{PLIBDIR} |
| 55 |
PATH_SUFFIXES lib64 lib libs64 libs libs/Win32 libs/Win64 |
| 56 |
PATHS ${ADDITIONAL_LIBRARY_PATHS} |
| 57 |
) |
| 58 |
FIND_LIBRARY(${compLibName}_RELEASE |
| 59 |
NAMES ${compLib} plib_${compLib} |
| 60 |
HINTS $ENV{PLIBDIR} |
| 61 |
PATH_SUFFIXES lib64 lib libs64 libs libs/Win32 libs/Win64 |
| 62 |
PATHS ${ADDITIONAL_LIBRARY_PATHS} |
| 63 |
) |
| 64 |
select_library_configurations( ${compLibBase} ) |
| 65 |
|
| 66 |
set(componentLibRelease ${${compLibName}_RELEASE}) |
| 67 |
#message(STATUS "Simgear ${compLibName}_RELEASE ${componentLibRelease}") |
| 68 |
set(componentLibDebug ${${compLibName}_DEBUG}) |
| 69 |
#message(STATUS "Simgear ${compLibName}_DEBUG ${componentLibDebug}") |
| 70 |
if (NOT ${compLibName}_DEBUG) |
| 71 |
if (NOT ${compLibName}_RELEASE) |
| 72 |
#message(STATUS "found ${componentLib}") |
| 73 |
list(APPEND ${libs} ${componentLibRelease}) |
| 74 |
endif() |
| 75 |
else() |
| 76 |
list(APPEND ${libs} optimized ${componentLibRelease} debug ${componentLibDebug}) |
| 77 |
endif() |
| 78 |
endmacro() |
| 79 |
|
| 80 |
# based on the contents of deps, add other required PLIB |
| 81 |
# static library dependencies. Eg PUI requires FNT |
| 82 |
set(outDeps ${PLIB_FIND_COMPONENTS}) |
| 83 |
|
| 84 |
foreach(c ${PLIB_FIND_COMPONENTS}) |
| 85 |
if (${c} STREQUAL "pu") |
| 86 |
# handle MSVC confusion over pu/pui naming, by removing |
| 87 |
# 'pu' and then adding it back |
| 88 |
list(REMOVE_ITEM outDeps "pu" "fnt" "sg") |
| 89 |
list(APPEND outDeps ${PUNAME} "sg") |
| 90 |
elseif (${c} STREQUAL "puaux") |
| 91 |
list(APPEND outDeps ${PUNAME} "sg") |
| 92 |
elseif (${c} STREQUAL "ssg") |
| 93 |
list(APPEND outDeps "sg") |
| 94 |
endif() |
| 95 |
endforeach() |
| 96 |
|
| 97 |
list(APPEND outDeps "ul") # everything needs ul |
| 98 |
list(REMOVE_DUPLICATES outDeps) # clean up |
| 99 |
|
| 100 |
|
| 101 |
# look for traditional static libraries |
| 102 |
foreach(component ${outDeps}) |
| 103 |
find_static_component(${component} PLIB_LIBRARIES) |
| 104 |
endforeach() |
| 105 |
|
| 106 |
include(FindPackageHandleStandardArgs) |
| 107 |
FIND_PACKAGE_HANDLE_STANDARD_ARGS(PLIB DEFAULT_MSG PLIB_LIBRARIES PLIB_INCLUDE_DIR) |