diff options
author | Alexander Neundorf <neundorf@kde.org> | 2010-09-26 11:27:17 +0000 |
---|---|---|
committer | Alexander Neundorf <neundorf@kde.org> | 2010-09-26 11:27:17 +0000 |
commit | e1eb5b5d4b989b2e07c96cb4ea463a4891b36bf1 (patch) | |
tree | a348ff74e64f46237b7b5ded4f638c72e45196cc | |
parent | 067428213344ff1067839e2e180848c1699c299d (diff) | |
download | extra-cmake-modules-e1eb5b5d4b989b2e07c96cb4ea463a4891b36bf1.tar.gz extra-cmake-modules-e1eb5b5d4b989b2e07c96cb4ea463a4891b36bf1.tar.bz2 |
-improve version checking for LCMS using the new mode of find_package_handle_standard_args()
Alex
svn path=/trunk/KDE/kdelibs/; revision=1179880
-rw-r--r-- | modules/FindLCMS.cmake | 48 |
1 files changed, 17 insertions, 31 deletions
diff --git a/modules/FindLCMS.cmake b/modules/FindLCMS.cmake index 2b1f3cd7..e321e86c 100644 --- a/modules/FindLCMS.cmake +++ b/modules/FindLCMS.cmake @@ -1,11 +1,13 @@ # - Find LCMS -# Find the LCMS includes and library +# Find the LCMS (Little Color Management System) library and includes and # This module defines # LCMS_INCLUDE_DIR, where to find lcms.h # LCMS_LIBRARIES, the libraries needed to use LCMS. # LCMS_VERSION, The value of LCMS_VERSION defined in lcms.h # LCMS_FOUND, If false, do not try to use LCMS. - +# +# The minimum required version of LCMS can be specified using the +# standard syntax, e.g. find_package(LCMS 1.1) # Copyright (c) 2008, Adrian Page, <adrian@pagenet.plus.com> # Copyright (c) 2009, Cyrille Berger, <cberger@cberger.net> @@ -23,50 +25,34 @@ if(NOT WIN32) endif(NOT WIN32) find_path(LCMS_INCLUDE_DIR lcms.h - PATHS + HINTS ${PC_LCMS_INCLUDEDIR} ${PC_LCMS_INCLUDE_DIRS} PATH_SUFFIXES lcms liblcms1 ) find_library(LCMS_LIBRARIES NAMES lcms liblcms lcms-1 liblcms-1 - PATHS + HINTS ${PC_LCMS_LIBDIR} ${PC_LCMS_LIBRARY_DIRS} PATH_SUFFIXES lcms ) -if(LCMS_INCLUDE_DIR AND LCMS_LIBRARIES) - set(LCMS_FOUND TRUE) -else(LCMS_INCLUDE_DIR AND LCMS_LIBRARIES) - set(LCMS_FOUND FALSE) -endif(LCMS_INCLUDE_DIR AND LCMS_LIBRARIES) - -if(LCMS_FOUND) +# Store the LCMS version number in the cache, so we don't have to search everytime again +if(LCMS_INCLUDE_DIR AND NOT LCMS_VERSION) file(READ ${LCMS_INCLUDE_DIR}/lcms.h LCMS_VERSION_CONTENT) string(REGEX MATCH "#define LCMS_VERSION[ ]*[0-9]*\n" LCMS_VERSION_MATCH ${LCMS_VERSION_CONTENT}) if(LCMS_VERSION_MATCH) - string(REGEX REPLACE "#define LCMS_VERSION[ ]*([0-9]*)\n" "\\1" LCMS_VERSION ${LCMS_VERSION_MATCH}) - if(NOT LCMS_FIND_QUIETLY) - string(SUBSTRING ${LCMS_VERSION} 0 1 LCMS_MAJOR_VERSION) - string(SUBSTRING ${LCMS_VERSION} 1 2 LCMS_MINOR_VERSION) - message(STATUS "Found lcms version ${LCMS_MAJOR_VERSION}.${LCMS_MINOR_VERSION}, ${LCMS_LIBRARIES}") - endif(NOT LCMS_FIND_QUIETLY) - else(LCMS_VERSION_MATCH) - if(NOT LCMS_FIND_QUIETLY) - message(STATUS "Found lcms but failed to find version ${LCMS_LIBRARIES}") - endif(NOT LCMS_FIND_QUIETLY) - set(LCMS_VERSION NOTFOUND) + string(REGEX REPLACE "#define LCMS_VERSION[ ]*([0-9]*)\n" "\\1" _LCMS_VERSION ${LCMS_VERSION_MATCH}) + string(SUBSTRING ${_LCMS_VERSION} 0 1 LCMS_MAJOR_VERSION) + string(SUBSTRING ${_LCMS_VERSION} 1 2 LCMS_MINOR_VERSION) endif(LCMS_VERSION_MATCH) -else(LCMS_FOUND) - if(NOT LCMS_FIND_QUIETLY) - if(LCMS_FIND_REQUIRED) - message(FATAL_ERROR "Required package lcms NOT found") - else(LCMS_FIND_REQUIRED) - message(STATUS "lcms NOT found") - endif(LCMS_FIND_REQUIRED) - endif(NOT LCMS_FIND_QUIETLY) -endif(LCMS_FOUND) + set(LCMS_VERSION "${LCMS_MAJOR_VERSION}.${LCMS_MINOR_VERSION}" CACHE STRING "Version number of lcms" FORCE) +endif(LCMS_INCLUDE_DIR AND NOT LCMS_VERSION) + +include(FindPackageHandleStandardArgs) +find_package_handle_standard_args(LCMS REQUIRED_VARS LCMS_LIBRARIES LCMS_INCLUDE_DIR + VERSION_VAR LCMS_VERSION ) mark_as_advanced(LCMS_INCLUDE_DIR LCMS_LIBRARIES LCMS_VERSION) |