]> git.mxchange.org Git - flightgear.git/blobdiff - CMakeModules/FindPLIB.cmake
Canvas: Make path destroying more robust
[flightgear.git] / CMakeModules / FindPLIB.cmake
index 09188948ff2e3af93e4f4e6590b5c93260a6fb7b..da5463612aaf72eb7dec88449058e8195979a2fb 100644 (file)
@@ -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
@@ -82,9 +84,19 @@ macro(find_static_component comp libs)
       set(compLib "plib${comp}")
     endif(MSVC)
     
-    string(TOUPPER "PLIB_${comp}_LIBRARY" compLibName)
-    
-    FIND_LIBRARY(${compLibName}
+    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
@@ -93,10 +105,19 @@ macro(find_static_component comp libs)
       /usr
       /opt
     )
-    
-    set(componentLib ${${compLibName}})
-    if (NOT ${componentLib} STREQUAL "componentLib-NOTFOUND")
-        list(APPEND ${libs} ${componentLib})
+    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()
 
@@ -104,7 +125,7 @@ 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
+# static library dependencies. Eg PUI requires FNT
     set(outDeps ${PLIB_FIND_COMPONENTS})
     
     foreach(c ${PLIB_FIND_COMPONENTS})
@@ -112,9 +133,9 @@ if(${PLIB_LIBRARIES} STREQUAL "PLIB_LIBRARIES-NOTFOUND")
             # 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")
+            list(APPEND outDeps ${PUNAME} "fnt" "sg")
         elseif (${c} STREQUAL "puaux")
-            list(APPEND outDeps ${PUNAME} "fnt" "ssg" "sg")
+            list(APPEND outDeps ${PUNAME} "fnt" "sg")
         elseif (${c} STREQUAL "ssg")
             list(APPEND outDeps "sg")
         endif()
@@ -140,7 +161,7 @@ if(${haveJs} GREATER -1)
         find_library(CF_LIBRARY CoreFoundation)
         set(JS_LIBS ${IOKIT_LIBRARY} ${CF_LIBRARY})
     elseif(WIN32)
-        find_library(WINMM_LIBRARY winmm)
+        set(WINMM_LIBRARY winmm)
         set(JS_LIBS ${WINMM_LIBRARY})
     elseif(CMAKE_SYSTEM_NAME MATCHES "Linux")
         # anything needed here?