1
0
Fork 0

CMake: Windows PLIB fixes from Olaf Flebbe.

This commit is contained in:
James Turner 2011-01-01 21:22:37 +00:00
parent 4d1d215ded
commit 61c88af564
2 changed files with 90 additions and 61 deletions

View file

@ -47,6 +47,7 @@ option(ENABLE_LARCSIM "Set to ON to build FlightGear with LaRCsim FDM" ON)
option(ENABLE_YASIM "Set to ON to build FlightGear with YASIM FDM" ON)
option(ENABLE_JSBSIM "Set to ON to build FlightGear with JSBSim FDM" ON)
option(EVENT_INPUT "Set to ON to build FlightGear with event-based Input support" OFF)
option(MSVC_3RDPARTY_DIR "Location where the third-party dependencies are extracted" NOT_FOUND)
if(LOGGING)
# nothing
@ -71,6 +72,17 @@ else(EVENT_INPUT)
set(ENABLE_PLIB_JOYSTICK 1)
endif(EVENT_INPUT)
if (MSVC_3RDPARTY_DIR)
message(STATUS "3rdparty files located in ${MSVC_3RDPARTY_DIR}")
set (CMAKE_LIBRARY_PATH ${MSVC_3RDPARTY_DIR}/3rdParty/lib ${MSVC_3RDPARTY_DIR}/install/msvc90/OpenScenegraph/lib )
set (CMAKE_INCLUDE_PATH ${MSVC_3RDPARTY_DIR}/3rdParty/include ${MSVC_3RDPARTY_DIR}/install/msvc90/OpenScenegraph/include)
set (BOOST_ROOT ${MSVC_3RDPARTY_DIR}/boost_1_44_0)
set (OPENAL_INCLUDE_DIR ${MSVC_3RDPARTY_DIR}/3rdParty/include)
set (ALUT_INCLUDE_DIR ${MSVC_3RDPARTY_DIR}/3rdParty/include)
set (OPENAL_LIBRARY_DIR ${MSVC_3RDPARTY_DIR}/3rdParty/lib)
endif (MSVC_3RDPARTY_DIR)
# check required dependencies
if (MSVC)
# on MSVC, Olaf reports that the serialization library is required at
@ -89,6 +101,7 @@ find_package(OpenGL REQUIRED)
find_package(OpenAL REQUIRED)
find_package(ALUT REQUIRED)
find_package(OpenSceneGraph 2.8.2 REQUIRED osgText osgSim osgDB osgParticle osgFX osgUtil osgViewer osgGA)
find_package(PLIB REQUIRED puaux pu js fnt)
find_package(SimGear 2.0.0 REQUIRED)

View file

@ -67,76 +67,92 @@ 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}_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")
list(APPEND ${libs} ${componentLib})
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()
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" "ssg" "sg")
elseif (${c} STREQUAL "puaux")
list(APPEND outDeps ${PUNAME} "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()
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)
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})
endif()
include(FindPackageHandleStandardArgs)