[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 16:52:07 CST 2011
branch "ice-package" has been updated
via b7aef9ec25d43849bff234ec63d8ab1047ac9faa (commit)
from f22ec20ea1e509b8cfd5479c8d89440a8b93acbd (commit)
Summary of changes:
modules/FindIce.cmake | 74 ++++++++++++-------
.../FindPackageComponentHandleStandardArgs.cmake | 51 ++++++++++++++
2 files changed, 98 insertions(+), 27 deletions(-)
create mode 100644 modules/FindPackageComponentHandleStandardArgs.cmake
- Log -----------------------------------------------------------------
commit b7aef9ec25d43849bff234ec63d8ab1047ac9faa
Author: Kevin P. Fleming <kpfleming at digium.com>
Date: Thu Jan 13 16:52:04 2011 -0600
... and now the ability to find component libraries works too.
diff --git a/modules/FindIce.cmake b/modules/FindIce.cmake
index 2fc9512..cf73699 100644
--- a/modules/FindIce.cmake
+++ b/modules/FindIce.cmake
@@ -9,12 +9,18 @@
# ICE_VERSION_MAJOR
# ICE_VERSION_MINOR
# ICE_VERSION_PATCH
-# ICE_Ice_FOUND
-# ICE_Ice_LIBRARY
-# ICE_Ice_LIBRARY_DEBUG
-# ICE_Ice_LIBRARY_RELEASE
+# ICE_ICE_FOUND
+# ICE_ICE_LIBRARY
+# ICE_ICE_LIBRARY_DEBUG
+# ICE_ICE_LIBRARY_RELEASE
+# for each component requested, sets (with <component> uppercased):
+# ICE_<component>_FOUND
+# ICE_<component>_LIBRARY
+# ICE_<component>_LIBRARY_DEBUG
+# ICE_<component>_LIBRARY_RELEASE
find_package(PackageHandleStandardArgs)
+find_package(PackageComponentHandleStandardArgs)
function(_ice_set_cache_path var value reason)
set(${var} ${value} CACHE PATH "${reason}" FORCE)
@@ -27,52 +33,56 @@ function(_ice_set_cache_string var value reason)
endfunction()
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")
+ string(TOUPPER "${library}" upper)
+ find_library(ICE_${upper}_LIBRARY_RELEASE NAMES "${library}" NO_DEFAULT_PATH PATHS "${ICE_DIR}" PATH_SUFFIXES "lib" "lib32" "lib64")
+ find_library(ICE_${upper}_LIBRARY_DEBUG NAMES "${library}${_ice_debug_suffix}" NO_DEFAULT_PATH PATHS "${ICE_DIR}" PATH_SUFFIXES "lib" "lib32" "lib64")
+ if(ICE_${upper}_LIBRARY_DEBUG OR ICE_${upper}_LIBRARY_RELEASE)
+ set(ICE_${upper}_FOUND ON CACHE STRING "The Ice ${library} library was found")
+ endif()
+
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} ")
+ "${library} library (release) found at ${ICE_${upper}_LIBRARY_RELEASE} "
+ "${library} library (debug) found at ${ICE_${upper}_LIBRARY_DEBUG} ")
endif()
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)
+# Lifted (and then modified) from FindBoost.cmake, which got it from FindQt4.cmake.
+function(_ice_adjust_lib_vars library)
+ string(TOUPPER "${library}" upper)
+ if(ICE_${upper}_LIBRARY_DEBUG AND ICE_${upper}_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})
+ set(ICE_${upper}_LIBRARY optimized ${ICE_${upper}_LIBRARY_RELEASE} debug ${ICE_${upper}_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})
+ set(ICE_${upper}_LIBRARY ${ICE_${upper}_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} CACHE FILEPATH "Path to a library." FORCE)
- set(ICE_${library}_LIBRARY ${ICE_${library}_LIBRARY_RELEASE})
+ if(ICE_${upper}_LIBRARY_RELEASE AND NOT ICE_${upper}_LIBRARY_DEBUG)
+ set(ICE_${upper}_LIBRARY_DEBUG ${ICE_${upper}_LIBRARY_RELEASE} CACHE FILEPATH "Path to a library." FORCE)
+ set(ICE_${upper}_LIBRARY ${ICE_${upper}_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} CACHE FILEPATH "Path to a library." FORCE)
- set(ICE_${library}_LIBRARY ${ICE_${library}_LIBRARY_DEBUG})
+ if(ICE_${upper}_LIBRARY_DEBUG AND NOT ICE_${upper}_LIBRARY_RELEASE)
+ set(ICE_${upper}_LIBRARY_RELEASE ${ICE_${upper}_LIBRARY_DEBUG} CACHE FILEPATH "Path to a library." FORCE)
+ set(ICE_${upper}_LIBRARY ${ICE_${upper}_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")
+ if(ICE_${upper}_LIBRARY)
+ set(ICE_${upper}_LIBRARY ${ICE_${upper}_LIBRARY} CACHE FILEPATH "The Ice ${library} library")
endif()
# Make variables changeble to the advanced user
- mark_as_advanced(ICE_${library}_LIBRARY ICE_${library}_LIBRARY_RELEASE ICE_${library}_LIBRARY_DEBUG)
-endmacro()
+ mark_as_advanced(ICE_${upper}_LIBRARY ICE_${upper}_LIBRARY_RELEASE ICE_${upper}_LIBRARY_DEBUG)
+endfunction()
if(NOT ICE_DIR)
if(NOT Ice_FIND_VERSION)
@@ -203,9 +213,19 @@ if(NOT ICE_DIR)
_ice_adjust_lib_vars(Ice)
endif()
-endif()
-find_package_handle_standard_args(Ice DEFAULT_MSG ICE_DIR ICE_SLICE_DIR ICE_INCLUDE_DIR)
+ find_package_handle_standard_args(Ice DEFAULT_MSG ICE_DIR ICE_SLICE_DIR ICE_INCLUDE_DIR)
+endif()
if(ICE_DIR)
+ foreach(component IN LISTS Ice_FIND_COMPONENTS)
+ string(TOUPPER "${component}" upper)
+ if(NOT ICE_${upper}_FOUND)
+ _ice_find_library("${component}")
+ endif()
+ if(ICE_${upper}_FOUND)
+ _ice_adjust_lib_vars("${component}")
+ endif()
+ find_package_component_handle_standard_args(Ice "${component}" DEFAULT_MSG ICE_${upper}_LIBRARY)
+ endforeach()
endif()
diff --git a/modules/FindPackageComponentHandleStandardArgs.cmake b/modules/FindPackageComponentHandleStandardArgs.cmake
new file mode 100644
index 0000000..d864014
--- /dev/null
+++ b/modules/FindPackageComponentHandleStandardArgs.cmake
@@ -0,0 +1,51 @@
+# FIND_PACKAGE_COMPONENT_HANDLE_STANDARD_ARGS(NAME COMPONENT (DEFAULT_MSG|"Custom failure message") VAR1 ... )
+# This macro is intended to be used in FindXXX.cmake modules files.
+# It handles the REQUIRED and QUIET argument to FIND_PACKAGE().
+# The package is found if all variables listed are TRUE.
+
+INCLUDE(FindPackageMessage)
+FUNCTION(FIND_PACKAGE_COMPONENT_HANDLE_STANDARD_ARGS _NAME _COMP _FAIL_MSG _VAR1 )
+
+ IF("${_FAIL_MSG}" STREQUAL "DEFAULT_MSG")
+ SET(_FAIL_MESSAGE "Could NOT find ${_NAME} component ${_COMP}")
+ ELSE("${_FAIL_MSG}" STREQUAL "DEFAULT_MSG")
+ SET(_FAIL_MESSAGE "${_FAIL_MSG}")
+ ENDIF("${_FAIL_MSG}" STREQUAL "DEFAULT_MSG")
+
+ STRING(TOUPPER ${_COMP} _COMP_UPPER)
+
+ # collect all variables which were not found, so they can be printed, so the
+ # user knows better what went wrong (#6375)
+ SET(MISSING_VARS "")
+ SET(DETAILS "")
+ SET(${_COMP_UPPER}_FOUND TRUE)
+ IF(NOT ${_VAR1})
+ SET(${_COMP_UPPER}_FOUND FALSE)
+ SET(MISSING_VARS " ${_VAR1}")
+ ELSE(NOT ${_VAR1})
+ SET(DETAILS "${DETAILS}[${${_VAR1}}]")
+ ENDIF(NOT ${_VAR1})
+
+ # check if all passed variables are valid
+ FOREACH(_CURRENT_VAR ${ARGN})
+ IF(NOT ${_CURRENT_VAR})
+ SET(${_COMP_UPPER}_FOUND FALSE)
+ SET(MISSING_VARS "${MISSING_VARS} ${_CURRENT_VAR}")
+ ELSE(NOT ${_CURRENT_VAR})
+ SET(DETAILS "${DETAILS}[${${_CURRENT_VAR}}]")
+ ENDIF(NOT ${_CURRENT_VAR})
+ ENDFOREACH(_CURRENT_VAR)
+
+ IF (${_COMP_UPPER}_FOUND)
+ FIND_PACKAGE_MESSAGE(${_NAME} "Found ${_NAME} component ${_COMP}: ${${_VAR1}}" "${DETAILS}")
+ ELSE (${_COMP_UPPER}_FOUND)
+ IF (${_NAME}_FIND_REQUIRED)
+ MESSAGE(FATAL_ERROR "${_FAIL_MESSAGE} (missing: ${MISSING_VARS})")
+ ELSE (${_NAME}_FIND_REQUIRED)
+ IF (NOT ${_NAME}_FIND_QUIETLY)
+ MESSAGE(STATUS "${_FAIL_MESSAGE} (missing: ${MISSING_VARS})")
+ ENDIF (NOT ${_NAME}_FIND_QUIETLY)
+ ENDIF (${_NAME}_FIND_REQUIRED)
+ ENDIF (${_COMP_UPPER}_FOUND)
+
+ENDFUNCTION(FIND_PACKAGE_COMPONENT_HANDLE_STANDARD_ARGS)
-----------------------------------------------------------------------
--
asterisk-scf/release/cmake.git
More information about the asterisk-scf-commits
mailing list