X-Git-Url: https://git.mxchange.org/?a=blobdiff_plain;f=CMakeModules%2FFindPLIB.cmake;h=da5463612aaf72eb7dec88449058e8195979a2fb;hb=67f66dc86abe0070927127be62e216f2a6c5a05c;hp=5fadcaf7953cae661e2b589757f5cad0600bf390;hpb=a91ec5f9f91eb2ef83ed7f7bf8d0b0b91613ebf0;p=flightgear.git diff --git a/CMakeModules/FindPLIB.cmake b/CMakeModules/FindPLIB.cmake index 5fadcaf79..da5463612 100644 --- a/CMakeModules/FindPLIB.cmake +++ b/CMakeModules/FindPLIB.cmake @@ -34,6 +34,8 @@ # OPENAL_LIBRARY to override this selection or set the CMake environment # CMAKE_INCLUDE_PATH to modify the search paths. +include(SelectLibraryConfigurations) + set(save_FIND_FRAMEWORK ${CMAKE_FIND_FRAMEWORK}) set(CMAKE_FIND_FRAMEWORK ONLY) FIND_PATH(PLIB_INCLUDE_DIR ul.h @@ -67,76 +69,111 @@ FIND_LIBRARY(PLIB_LIBRARIES /Library/Frameworks ) +if (MSVC) + set (PUNAME "pui") +else (MSVC) + set (PUNAME "pu") +endif (MSVC) + + macro(find_static_component comp libs) - set(compLib "plib${comp}") - string(TOUPPER "PLIB_${comp}_LIBRARY" compLibName) - - FIND_LIBRARY(${compLibName} - NAMES ${compLib} - HINTS $ENV{PLIBDIR} - PATH_SUFFIXES lib64 lib libs64 libs libs/Win32 libs/Win64 - PATHS - /usr/local - /usr - /opt - ) - - set(componentLib ${${compLibName}}) - if (NOT ${componentLib} STREQUAL "componentLib-NOTFOUND") - #message(STATUS "found ${componentLib}") - list(APPEND ${libs} ${componentLib}) - #set(PLIB_LIBRARIES "${PLIB_LIBRARIES} ${componentLib}" PARENT_SCOPE) - endif() + # account for alternative Windows PLIB distribution naming + if(MSVC) + set(compLib "${comp}") + else(MSVC) + set(compLib "plib${comp}") + endif(MSVC) + + string(TOUPPER "PLIB_${comp}" compLibBase) + set( compLibName ${compLibBase}_LIBRARY ) + + FIND_LIBRARY(${compLibName}_DEBUG + NAMES ${compLib}_d + HINTS $ENV{PLIBDIR} + PATH_SUFFIXES lib64 lib libs64 libs libs/Win32 libs/Win64 + PATHS + /usr/local + /usr + /opt + ) + FIND_LIBRARY(${compLibName}_RELEASE + NAMES ${compLib} + HINTS $ENV{PLIBDIR} + PATH_SUFFIXES lib64 lib libs64 libs libs/Win32 libs/Win64 + PATHS + /usr/local + /usr + /opt + ) + select_library_configurations( ${compLibBase} ) + + set(componentLibRelease ${${compLibName}_RELEASE}) + #message(STATUS "Simgear ${compLibName}_RELEASE ${componentLibRelease}") + set(componentLibDebug ${${compLibName}_DEBUG}) + #message(STATUS "Simgear ${compLibName}_DEBUG ${componentLibDebug}") + if (NOT ${compLibName}_DEBUG) + if (NOT ${compLibName}_RELEASE) + #message(STATUS "found ${componentLib}") + list(APPEND ${libs} ${componentLibRelease}) + endif() + else() + list(APPEND ${libs} optimized ${componentLibRelease} debug ${componentLibDebug}) + endif() endmacro() -if(${PLIB_LIBRARIES} STREQUAL "PLIB_LIBRARIES-NOTFOUND") - set(PLIB_LIBRARIES "") # clear value - +if(${PLIB_LIBRARIES} STREQUAL "PLIB_LIBRARIES-NOTFOUND") + set(PLIB_LIBRARIES "") # clear value + # based on the contents of deps, add other required PLIB -# static library dependencies. Eg PUI requires SSG and FNT - set(outDeps ${PLIB_FIND_COMPONENTS}) - - foreach(c ${PLIB_FIND_COMPONENTS}) - if (${c} STREQUAL "pu") - list(APPEND outDeps "fnt" "ssg" "sg") - elseif (${c} STREQUAL "puaux") - list(APPEND outDeps "pu" "fnt" "ssg" "sg") - elseif (${c} STREQUAL "ssg") - list(APPEND outDeps "sg") - endif() - endforeach() - - list(APPEND outDeps "ul") # everything needs ul - list(REMOVE_DUPLICATES outDeps) # clean up - - # look for traditional static libraries - foreach(component ${outDeps}) - find_static_component(${component} PLIB_LIBRARIES) - endforeach() +# static library dependencies. Eg PUI requires FNT + set(outDeps ${PLIB_FIND_COMPONENTS}) + + foreach(c ${PLIB_FIND_COMPONENTS}) + if (${c} STREQUAL "pu") + # handle MSVC confusion over pu/pui naming, by removing + # 'pu' and then adding it back + list(REMOVE_ITEM outDeps "pu") + list(APPEND outDeps ${PUNAME} "fnt" "sg") + elseif (${c} STREQUAL "puaux") + list(APPEND outDeps ${PUNAME} "fnt" "sg") + elseif (${c} STREQUAL "ssg") + list(APPEND outDeps "sg") + endif() + endforeach() + + list(APPEND outDeps "ul") # everything needs ul + list(REMOVE_DUPLICATES outDeps) # clean up + + + + # look for traditional static libraries + foreach(component ${outDeps}) + find_static_component(${component} PLIB_LIBRARIES) + endforeach() endif() list(FIND outDeps "js" haveJs) if(${haveJs} GREATER -1) - message(STATUS "adding runtime JS dependencies") - if(APPLE) - # resolve frameworks to full paths - find_library(IOKIT_LIBRARY IOKit) - find_library(CF_LIBRARY CoreFoundation) - set(JS_LIBS ${IOKIT_LIBRARY} ${CF_LIBRARY}) - elseif(WIN32) - find_library(WINMM_LIBRARY winmm) - set(JS_LIBS ${WINMM_LIBRARY}) - elseif(CMAKE_SYSTEM_NAME MATCHES "Linux") - # anything needed here? - elseif(CMAKE_SYSTEM_NAME MATCHES "FreeBSD") - find_library(USBHID_LIBRARY usbhid) - # check_function_exists(hidinit) - set(JS_LIBS ${USBHID_LIBRARY}) - else() - message(WARNING "Unsupported platform for PLIB JS libs") - endif() - - list(APPEND PLIB_LIBRARIES ${JS_LIBS}) + message(STATUS "adding runtime JS dependencies") + if(APPLE) + # resolve frameworks to full paths + find_library(IOKIT_LIBRARY IOKit) + find_library(CF_LIBRARY CoreFoundation) + set(JS_LIBS ${IOKIT_LIBRARY} ${CF_LIBRARY}) + elseif(WIN32) + set(WINMM_LIBRARY winmm) + set(JS_LIBS ${WINMM_LIBRARY}) + elseif(CMAKE_SYSTEM_NAME MATCHES "Linux") + # anything needed here? + elseif(CMAKE_SYSTEM_NAME MATCHES "FreeBSD") + find_library(USBHID_LIBRARY usbhid) + # check_function_exists(hidinit) + set(JS_LIBS ${USBHID_LIBRARY}) + else() + message(WARNING "Unsupported platform for PLIB JS libs") + endif() + + list(APPEND PLIB_LIBRARIES ${JS_LIBS}) endif() include(FindPackageHandleStandardArgs)