diff options
| author | Alexander Neundorf <neundorf@kde.org> | 2007-08-03 01:40:00 +0000 | 
|---|---|---|
| committer | Alexander Neundorf <neundorf@kde.org> | 2007-08-03 01:40:00 +0000 | 
| commit | ac081e93559fc128b739647478781a0159697f2f (patch) | |
| tree | 803c765691a398d2ba2a7aff31855b3ebf53103a /modules | |
| parent | 2b9a0f1b3d7a91d93a63d4cf85c2d08e71d0906d (diff) | |
| download | extra-cmake-modules-ac081e93559fc128b739647478781a0159697f2f.tar.gz extra-cmake-modules-ac081e93559fc128b739647478781a0159697f2f.tar.bz2 | |
-add FindPackageHandleStandardArgs.cmake from cmake cvs, which adds a macro for handling the QUIETLY and REQUIRED arguments
for FIND_PACKAGE() and which sets the foo_FOUND variable if all additional variables are TRUE
-use this new macro in FindStrigi.
-put the successful query of pkgfconfig for the strigi version in the cache, so it doesn't have to do it again the next time
-if pkgconfig doesn't find strigi at all, print a warning message but don't fail
Alex
svn path=/trunk/KDE/kdelibs/; revision=695818
Diffstat (limited to 'modules')
| -rw-r--r-- | modules/FindPackageHandleStandardArgs.cmake | 54 | ||||
| -rw-r--r-- | modules/FindStrigi.cmake | 68 | 
2 files changed, 82 insertions, 40 deletions
| diff --git a/modules/FindPackageHandleStandardArgs.cmake b/modules/FindPackageHandleStandardArgs.cmake new file mode 100644 index 00000000..3f5156cf --- /dev/null +++ b/modules/FindPackageHandleStandardArgs.cmake @@ -0,0 +1,54 @@ +# FIND_PACKAGE_HANDLE_STANDARD_ARGS(NAME (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() and +#    it also sets the <UPPERCASED_NAME>_FOUND variable. +#    The package is found if all variables listed are TRUE. +#    Example: +# +#    FIND_PACKAGE_HANDLE_STANDARD_ARGS(LibXml2 DEFAULT_MSG LIBXML2_LIBRARIES LIBXML2_INCLUDE_DIR) +# +#    LibXml2 is considered to be found, if both LIBXML2_LIBRARIES and  +#    LIBXML2_INCLUDE_DIR are valid. Then also LIBXML2_FOUND is set tto TRUE. +#    If it is not found and REQUIRED was used, it fails with FATAL_ERROR,  +#    independent whether QUIET was used or not. +#    If it is found, the location is reported using the VAR1 argument, so  +#    here a message "Found LibXml2: /usr/lib/libxml2.so" will be printed out. +#    If the second argument is DEFAULT_MSG, the message in the failure case will  +#    be "Could NOT find LibXml2", if you don't like this message you can specify +#    your own custom failure message there. + +MACRO(FIND_PACKAGE_HANDLE_STANDARD_ARGS _NAME _FAIL_MSG _VAR1 ) + +  IF("${_FAIL_MSG}" STREQUAL "DEFAULT_MSG") +    SET(_FAIL_MESSAGE "Could NOT find ${_NAME}") +  ELSE("${_FAIL_MSG}" STREQUAL "DEFAULT_MSG") +    SET(_FAIL_MESSAGE "${_FAIL_MSG}") +  ENDIF("${_FAIL_MSG}" STREQUAL "DEFAULT_MSG") + +  STRING(TOUPPER ${_NAME} _NAME_UPPER) + +  SET(${_NAME_UPPER}_FOUND TRUE) +  IF(NOT ${_VAR1}) +    SET(${_NAME_UPPER}_FOUND FALSE) +  ENDIF(NOT ${_VAR1}) + +  FOREACH(_CURRENT_VAR ${ARGN}) +    IF(NOT ${_CURRENT_VAR}) +      SET(${_NAME_UPPER}_FOUND FALSE) +    ENDIF(NOT ${_CURRENT_VAR}) +  ENDFOREACH(_CURRENT_VAR) + +  IF (${_NAME_UPPER}_FOUND) +    IF (NOT ${_NAME}_FIND_QUIETLY) +        MESSAGE(STATUS "Found ${_NAME}: ${${_VAR1}}") +    ENDIF (NOT ${_NAME}_FIND_QUIETLY) +  ELSE (${_NAME_UPPER}_FOUND) +    IF (${_NAME}_FIND_REQUIRED) +        MESSAGE(FATAL_ERROR "${_FAIL_MESSAGE}") +    ELSE (${_NAME}_FIND_REQUIRED) +      IF (NOT ${_NAME}_FIND_QUIETLY) +        MESSAGE(STATUS "${_FAIL_MESSAGE}") +      ENDIF (NOT ${_NAME}_FIND_QUIETLY) +    ENDIF (${_NAME}_FIND_REQUIRED) +  ENDIF (${_NAME_UPPER}_FOUND) +ENDMACRO(FIND_PACKAGE_HANDLE_STANDARD_ARGS) diff --git a/modules/FindStrigi.cmake b/modules/FindStrigi.cmake index c6c2a883..5c24aa58 100644 --- a/modules/FindStrigi.cmake +++ b/modules/FindStrigi.cmake @@ -14,64 +14,52 @@ if (WIN32)    file(TO_CMAKE_PATH "$ENV{PROGRAMFILES}" _program_FILES_DIR)  endif(WIN32) -FIND_PATH(STRIGI_INCLUDE_DIR strigi/streamanalyzer.h +find_path(STRIGI_INCLUDE_DIR strigi/streamanalyzer.h    PATHS    $ENV{STRIGI_HOME}/include    ${CMAKE_INSTALL_PREFIX}/include    ${_program_FILES_DIR}/strigi/include  ) -if (NOT WIN32) -   include(UsePkgConfig) - -   EXEC_PROGRAM(${PKGCONFIG_EXECUTABLE} ARGS --atleast-version=${STRIGI_MIN_VERSION} -      libstreamanalyzer RETURN_VALUE _return_VALUE OUTPUT_VARIABLE _pkgconfigDevNull ) - -   if(NOT _return_VALUE STREQUAL "0") -      message(STATUS "pkg-config query failed. did you set $PKG_CONFIG_PATH to the directory where strigi libstreamanalyzer.pc is installed?") -      message(FATAL_ERROR "Didn't find strigi >= ${STRIGI_MIN_VERSION}") -   else(NOT _return_VALUE STREQUAL "0") -     if(NOT Strigi_FIND_QUIETLY) -       message(STATUS "Found Strigi >= ${STRIGI_MIN_VERSION}") -     endif(NOT Strigi_FIND_QUIETLY) -   endif(NOT _return_VALUE STREQUAL "0") -endif (NOT WIN32) - -FIND_LIBRARY(STRIGI_STREAMANALYZER_LIBRARY NAMES streamanalyzer +find_library(STRIGI_STREAMANALYZER_LIBRARY NAMES streamanalyzer    PATHS    $ENV{STRIGI_HOME}/lib    ${CMAKE_INSTALL_PREFIX}/lib    ${_program_FILES_DIR}/strigi/lib  ) -FIND_LIBRARY(STRIGI_STREAMS_LIBRARY NAMES streams + +find_library(STRIGI_STREAMS_LIBRARY NAMES streams    PATHS    $ENV{STRIGI_HOME}/lib    ${CMAKE_INSTALL_PREFIX}/lib    ${_program_FILES_DIR}/strigi/lib  ) -IF(STRIGI_INCLUDE_DIR AND STRIGI_STREAMANALYZER_LIBRARY AND STRIGI_STREAMS_LIBRARY) -   SET(STRIGI_FOUND TRUE) -ENDIF(STRIGI_INCLUDE_DIR AND STRIGI_STREAMANALYZER_LIBRARY AND STRIGI_STREAMS_LIBRARY) +if (NOT WIN32 AND NOT HAVE_STRIGI_VERSION) +  include(UsePkgConfig) +  pkgconfig(libstreamanalyzer _dummyIncDir _dummyLinkDir _dummyLinkFlags _dummyCflags) -IF(STRIGI_FOUND) -  SET(STRIGI_LIBRARIES ${STRIGI_STREAMANALYZER_LIBRARY} ${STRIGI_STREAMS_LIBRARY}) +  # if pkgconfig found strigi, check the version, otherwise print a warning +  if(_dummyLinkFlags) -  IF(NOT Strigi_FIND_QUIETLY) -    MESSAGE(STATUS "Found Strigi: ${STRIGI_STREAMANALYZER_LIBRARY} ${STRIGI_STREAMS_LIBRARY} ") -  ENDIF(NOT Strigi_FIND_QUIETLY) -ELSE(STRIGI_FOUND) -  IF(NOT Strigi_FIND_QUIETLY) -    IF(NOT STRIGI_STREAMANALYZER_LIBRARY) -      MESSAGE(STATUS "Couldn't find Strigi streamanalyzer library in $ENV{STRIGI_HOME}/lib, ${CMAKE_INSTALL_PREFIX}/lib, ${_program_FILES_DIR}/strigi/lib") -    ENDIF(NOT STRIGI_STREAMANALYZER_LIBRARY) +    exec_program(${PKGCONFIG_EXECUTABLE} ARGS --atleast-version=${STRIGI_MIN_VERSION} +        libstreamanalyzer RETURN_VALUE _return_VALUE OUTPUT_VARIABLE _pkgconfigDevNull ) -    IF(NOT STRIGI_STREAMS_LIBRARY) -      MESSAGE(STATUS "Couldn't find Strigi streams library in $ENV{STRIGI_HOME}/lib, ${CMAKE_INSTALL_PREFIX}/lib, ${_program_FILES_DIR}/strigi/lib") -    ENDIF(NOT STRIGI_STREAMS_LIBRARY) -  ENDIF(NOT Strigi_FIND_QUIETLY) -  IF(Strigi_FIND_REQUIRED) -    MESSAGE(FATAL_ERROR "Could not find Strigi") -  ENDIF(Strigi_FIND_REQUIRED) -ENDIF(STRIGI_FOUND) +    if(NOT _return_VALUE STREQUAL "0") +      message(STATUS "pkg-config query failed. did you set $PKG_CONFIG_PATH to the directory where strigi libstreamanalyzer.pc is installed?") +      message(FATAL_ERROR "Didn't find strigi >= ${STRIGI_MIN_VERSION}") +    else(NOT _return_VALUE STREQUAL "0") +      set(HAVE_STRIGI_VERSION TRUE CACHE BOOL "Have strigi version returned by pkgconfig") +      if(NOT Strigi_FIND_QUIETLY) +        message(STATUS "Found Strigi >= ${STRIGI_MIN_VERSION}") +      endif(NOT Strigi_FIND_QUIETLY) +    endif(NOT _return_VALUE STREQUAL "0") +  else(_dummyLinkFlags) +    message(STATUS "pkgconfig didn't find strigi, couldn't check strigi version") +  endif(_dummyLinkFlags) +endif (NOT WIN32 AND NOT HAVE_STRIGI_VERSION) +include(FindPackageHandleStandardArgs) +find_package_handle_standard_args(Strigi   +                                  "Couldn't find Strigi streams library in $ENV{STRIGI_HOME}/lib, ${CMAKE_INSTALL_PREFIX}/lib, ${_program_FILES_DIR}/strigi/lib"   +                                  STRIGI_STREAMS_LIBRARY  STRIGI_STREAMANALYZER_LIBRARY  STRIGI_INCLUDE_DIR) | 
