[asterisk-scf-commits] asterisk-scf/release/cmake.git branch "ice-package" updated.

Commits to the Asterisk SCF project code repositories asterisk-scf-commits at lists.digium.com
Thu Jan 13 14:14:13 CST 2011


branch "ice-package" has been updated
       via  f52483c9a01c9c775f25fa810d35cd77bca507f8 (commit)
      from  f0e2117bb12b6560a746e5cc5147919541addddb (commit)

Summary of changes:
 modules/FindIce.cmake |  114 +++++++++++++++++++++++++++++++++++++++----------
 1 files changed, 91 insertions(+), 23 deletions(-)


- Log -----------------------------------------------------------------
commit f52483c9a01c9c775f25fa810d35cd77bca507f8
Author: Kevin P. Fleming <kpfleming at digium.com>
Date:   Thu Jan 13 14:14:10 2011 -0600

    Various cleanup and start actually finding libraries.

diff --git a/modules/FindIce.cmake b/modules/FindIce.cmake
index ca05b5c..d9b2f31 100644
--- a/modules/FindIce.cmake
+++ b/modules/FindIce.cmake
@@ -5,19 +5,76 @@
 # ICE_INCLUDE_DIR
 # ICE_SLICE_DIR
 # ICE_CXX_FLAGS
+# ICE_Ice_LIBRARY
+# ICE_Ice_LIBRARY_DEBUG
+# ICE_Ice_LIBRARY_RELEASE
+#
+# todo:
+# ICE_VERSION
+# ICE_VERSION_MAJOR
+# ICE_VERSION_MINOR
+# ICE_VERSION_PATCH
 
 find_package(PackageHandleStandardArgs)
 
-macro(set_cache_path var value reason)
+function(_ice_set_cache_path var value reason)
   set(${var} ${value} CACHE PATH "${reason}" FORCE)
   mark_as_advanced(FORCE ${var})
-endmacro()
+endfunction()
 
-macro(set_cache_string var value reason)
+function(_ice_set_cache_string var value reason)
   set(${var} ${value} CACHE STRING "${reason}" FORCE)
   mark_as_advanced(FORCE ${var})
+endfunction()
+
+# Lifted from FindBoost.cmake, which got it from FindQt4.cmake.
+
+macro(_ice_adjust_lib_vars library)
+  if(ICE_${library}_LIBRARY_DEBUG AND ICE_${library}_LIBRARY_RELEASE)
+    # if the generator supports configuration types then set
+    # optimized and debug libraries, or if the CMAKE_BUILD_TYPE has a value
+    if(CMAKE_CONFIGURATION_TYPES OR CMAKE_BUILD_TYPE)
+      set(ICE_${library}_LIBRARY optimized ${ICE_${library}_LIBRARY_RELEASE} debug ${ICE_${library}_LIBRARY_DEBUG})
+    else()
+      # if there are no configuration types and CMAKE_BUILD_TYPE has no value
+      # then just use the release libraries
+      set(ICE_${library}_LIBRARY ${ICE_${library}_LIBRARY_RELEASE})
+    endif()
+  endif()
+
+  # if only the release version was found, set the debug variable also to the release version
+  if(ICE_${library}_LIBRARY_RELEASE AND NOT ICE_${library}_LIBRARY_DEBUG)
+    set(ICE_${library}_LIBRARY_DEBUG ${ICE_${library}_LIBRARY_RELEASE})
+    set(ICE_${library}_LIBRARY       ${ICE_${library}_LIBRARY_RELEASE})
+  endif()
+
+  # if only the debug version was found, set the release variable also to the debug version
+  if(ICE_${library}_LIBRARY_DEBUG AND NOT ICE_${library}_LIBRARY_RELEASE)
+    set(ICE_${library}_LIBRARY_RELEASE ${ICE_${library}_LIBRARY_DEBUG})
+    set(ICE_${library}_LIBRARY         ${ICE_${library}_LIBRARY_DEBUG})
+  endif()
+  
+  if(ICE_${library}_LIBRARY)
+    set(ICE_${library}_LIBRARY ${ICE_${library}_LIBRARY} CACHE FILEPATH "The Ice ${library} library")
+    set(ICE_${library}_FOUND ON CACHE INTERNAL "Whether the Ice ${library} library was found")
+  endif()
+
+  # Make variables changeble to the advanced user
+  mark_as_advanced(ICE_${library}_LIBRARY ICE_${library}_LIBRARY_RELEASE ICE_${library}_LIBRARY_DEBUG)
 endmacro()
 
+function(_ice_find_library library)
+  find_library(ICE_${library}_LIBRARY_RELEASE NAMES "${library}" NO_DEFAULT_PATH PATHS "${ICE_DIR}" PATH_SUFFIXES "lib" "lib32" "lib64")
+  find_library(ICE_${library}_LIBRARY_DEBUG NAMES "${library}${_ice_debug_suffix}" NO_DEFAULT_PATH PATHS "${ICE_DIR}" PATH_SUFFIXES "lib" "lib32" "lib64")
+  
+  if(Ice_DEBUG)
+    message(STATUS
+      "[ ${CMAKE_CURRENT_LIST_FILE}:${CMAKE_CURRENT_LIST_LINE} ] "
+      "${library} library (release) found at ${ICE_${library}_LIBRARY_RELEASE} "
+      "${library} library (debug) found at ${ICE_${library}_LIBRARY_DEBUG} ")
+  endif()
+endfunction()
+
 if(NOT ICE_DIR)
   if(NOT Ice_FIND_VERSION)
     find_package_handle_standard_args(Ice "Major and minor version numbers (at least) must be supplied to find Ice." ICE_DIR)
@@ -26,24 +83,24 @@ if(NOT ICE_DIR)
   if($ENV{ICE_HOME})
     # if ICE_HOME is set, we will only look there; if the version present there
     # does not satisfy the requested version, then the search will fail
-    list(APPEND candidate_directories "$ENV{ICE_HOME}")
+    list(APPEND _ice_candidate_dirs "$ENV{ICE_HOME}")
   else()
     if(Ice_FIND_VERSION_EXACT)
       # we prefer to find an Ice directory without a patch version specified if possible, so put
       # that in the list first
-      list(APPEND candidate_versions
+      list(APPEND _ice_candidate_versions
 	"${Ice_FIND_VERSION_MAJOR}.${Ice_FIND_VERSION_MINOR}"
 	"${Ice_FIND_VERSION_MAJOR}.${Ice_FIND_VERSION_MINOR}.${Ice_FIND_VERSION_PATCH}")
     else()
       # we prefer to find an Ice directory without a patch version specified if possible, so put
       # that in the list first
-      list(APPEND candidate_versions
+      list(APPEND _ice_candidate_versions
 	"${Ice_FIND_VERSION_MAJOR}.${Ice_FIND_VERSION_MINOR}")
 
       # next, search for any patch version greater-than or equal-to what was requested
-      foreach(patch "10" "9" "8" "7" "6" "5" "4" "3" "2" "1" "0")
+      foreach(patch RANGE 10 0 -1)
 	if(NOT "${Ice_FIND_VERSION_MAJOR}.${Ice_FIND_VERSION_MINOR}.${patch}" VERSION_LESS "${Ice_FIND_VERSION}")
-	  list(APPEND candidate_versions
+	  list(APPEND _ice_candidate_versions
 	    "${Ice_FIND_VERSION_MAJOR}.${Ice_FIND_VERSION_MINOR}.${patch}")
 	endif()
       endforeach()
@@ -51,11 +108,11 @@ if(NOT ICE_DIR)
     endif()
 
     # now convert each candidate version into a directory path
-    foreach(version ${candidate_versions})
+    foreach(version IN LISTS _ice_candidate_versions)
       if(WIN32)
-	list(APPEND candidate_directories "C:/Ice-${version}")
+	list(APPEND _ice_candidate_dirs "C:/Ice-${version}")
       elseif(UNIX)
-	list(APPEND candidate_directories "/opt/Ice-${version}")
+	list(APPEND _ice_candidate_dirs "/opt/Ice-${version}")
       endif()
     endforeach()
 
@@ -64,14 +121,14 @@ if(NOT ICE_DIR)
   if(Ice_DEBUG)
     message(STATUS
       "[ ${CMAKE_CURRENT_LIST_FILE}:${CMAKE_CURRENT_LIST_LINE} ] "
-      "will search for Ice in these directories: ${candidate_directories}")
+      "will search for Ice in these directories: ${_ice_candidate_dirs}")
   endif()
 
   # since we may find a copy of Ice with a directory name that matches one of our candidates
   # but does not provide an adequate version, we have to be prepared to search repeatedly
   # until either an adequate version is found or all the candidates are exhausted
   while(NOT ICE_DIR)
-    find_path(ICE_INCLUDE_DIR NAMES "IceUtil/Config.h" PATHS ${candidate_directories} PATH_SUFFIXES "include" NO_DEFAULT_PATH)
+    find_path(ICE_INCLUDE_DIR NAMES "IceUtil/Config.h" PATHS ${_ice_candidate_dirs} PATH_SUFFIXES "include" NO_DEFAULT_PATH)
 
     # if nothing was found, then stop now
     if(NOT ICE_INCLUDE_DIR)
@@ -84,39 +141,39 @@ if(NOT ICE_DIR)
         "found Ice includes at: ${ICE_INCLUDE_DIR}")
     endif()
 
-    get_filename_component(possible_ice_dir "${ICE_INCLUDE_DIR}" PATH)
+    get_filename_component(_ice_possible_dir "${ICE_INCLUDE_DIR}" PATH)
 
     # now check the embedded version in the IceUtil/Config.h file to ensure it
     # satisfies the version requested
-    file(READ "${ICE_INCLUDE_DIR}/IceUtil/Config.h" config_contents)
-    string(REGEX REPLACE ".*#define.*ICE_STRING_VERSION.*\"([0-9]+\\.[0-9]+\\.[0-9]+)\".*" "\\1" ice_version "${config_contents}")
+    file(READ "${ICE_INCLUDE_DIR}/IceUtil/Config.h" _ice_config_contents)
+    string(REGEX REPLACE ".*#define.*ICE_STRING_VERSION.*\"([0-9]+\\.[0-9]+\\.[0-9]+)\".*" "\\1" _ice_config_version "${_ice_config_contents}")
 
     if(Ice_DEBUG)
       message(STATUS
 	"[ ${CMAKE_CURRENT_LIST_FILE}:${CMAKE_CURRENT_LIST_LINE} ] "
-        "Ice version detected: ${ice_version}")
+        "Ice version detected: ${_ice_config_version}")
     endif()
 
     if(NOT Ice_FIND_VERSION_EXACT)
-      set_cache_path(ICE_DIR "${possible_ice_dir}" "Location of Ice")
+      _ice_set_cache_path(ICE_DIR "${_ice_possible_dir}" "Location of Ice")
       break()
     endif()
 
-    if(${ice_version} VERSION_EQUAL ${Ice_FIND_VERSION})
-      set_cache_path(ICE_DIR "${possible_ice_dir}" "Location of Ice")
+    if(${_ice_config_version} VERSION_EQUAL ${Ice_FIND_VERSION})
+      _ice_set_cache_path(ICE_DIR "${_ice_possible_dir}" "Location of Ice")
       break()
     endif()
 
     if(Ice_DEBUG)
       message(STATUS
 	"[ ${CMAKE_CURRENT_LIST_FILE}:${CMAKE_CURRENT_LIST_LINE} ] "
-	"Ice version ${ice_version} does not match requested ${Ice_FIND_VERSION}")
+	"Ice version ${_ice_config_version} does not match requested ${Ice_FIND_VERSION}")
     endif()
 
     # we are in EXACT find mode, and the version in the directory found
     # does not satisfy the requested version... so remove this directory
     # as a candidate and try again
-    list(REMOVE_ITEM candidate_directories ${possible_ice_dir})
+    list(REMOVE_ITEM _ice_candidate_dirs ${_ice_possible_dir})
     unset(ICE_INCLUDE_DIR CACHE)
   endwhile()
 
@@ -134,9 +191,20 @@ if(NOT ICE_DIR)
     # the benefit of having warnings emitted by the headers NOT treated as errors, even if the compiler has been told
     # to do so. This is being utilized so that Ice itself does not have to be updated to be C++0x safe.
     if(CMAKE_COMPILER_IS_GNUCXX)
-      set_cache_string(ICE_CXX_FLAGS "-isystem ${ICE_INCLUDE_DIR}" "Ice-specific compiler flags")
+      _ice_set_cache_string(ICE_CXX_FLAGS "-isystem ${ICE_INCLUDE_DIR}" "Ice-specific compiler flags")
     endif()
+
+    if(WIN32)
+      set(_ice_debug_suffix "d")
+    endif()
+
+    _ice_find_library(Ice)
+    _ice_adjust_lib_vars(Ice)
+
   endif()
 endif()
 
 find_package_handle_standard_args(Ice DEFAULT_MSG ICE_DIR ICE_SLICE_DIR ICE_INCLUDE_DIR)
+
+if(ICE_DIR)
+endif()

-----------------------------------------------------------------------


-- 
asterisk-scf/release/cmake.git



More information about the asterisk-scf-commits mailing list