Warning, /frameworks/kdelibs4support/cmake/modules/FindKdcraw.cmake is written in an unsupported language. File is not indexed.
0001 # Try to find the Kdcraw library 0002 # 0003 # Parameters: 0004 # KDCRAW_LOCAL_DIR - If you have put a local version of libkdcraw into 0005 # your source tree, set KDCRAW_LOCAL_DIR to the 0006 # relative path from the root of your source tree 0007 # to the libkdcraw local directory. 0008 # 0009 # Once done this will define 0010 # 0011 # KDCRAW_FOUND - System has libkdcraw 0012 # KDCRAW_INCLUDE_DIR - The libkdcraw include directory/directories (for #include <libkdcraw/...> style) 0013 # KDCRAW_LIBRARIES - Link these to use libkdcraw 0014 # KDCRAW_DEFINITIONS - Compiler switches required for using libkdcraw 0015 # KDCRAW_VERSION - Version of libkdcraw which was found 0016 # 0017 # Copyright (c) 2008-2011, Gilles Caulier, <caulier.gilles@gmail.com> 0018 # Copyright (c) 2011, Michael G. Hansen, <mike@mghansen.de> 0019 # 0020 # Redistribution and use is allowed according to the terms of the BSD license. 0021 # For details see the accompanying COPYING-CMAKE-SCRIPTS file. 0022 0023 # Kdcraw_FIND_QUIETLY and Kdcraw_FIND_REQUIRED may be defined by CMake. 0024 0025 if (KDCRAW_INCLUDE_DIR AND KDCRAW_LIBRARIES AND KDCRAW_DEFINITIONS AND KDCRAW_VERSION) 0026 0027 if (NOT Kdcraw_FIND_QUIETLY) 0028 message(STATUS "Found Kdcraw library in cache: ${KDCRAW_LIBRARIES}") 0029 endif (NOT Kdcraw_FIND_QUIETLY) 0030 0031 # in cache already 0032 set(KDCRAW_FOUND TRUE) 0033 0034 else (KDCRAW_INCLUDE_DIR AND KDCRAW_LIBRARIES AND KDCRAW_DEFINITIONS AND KDCRAW_VERSION) 0035 0036 if (NOT Kdcraw_FIND_QUIETLY) 0037 message(STATUS "Check for Kdcraw library in local sub-folder...") 0038 endif (NOT Kdcraw_FIND_QUIETLY) 0039 0040 # Check for a local version of the library. 0041 if (KDCRAW_LOCAL_DIR) 0042 find_file(KDCRAW_LOCAL_FOUND libkdcraw/version.h.cmake ${CMAKE_SOURCE_DIR}/${KDCRAW_LOCAL_DIR} NO_DEFAULT_PATH) 0043 if (NOT KDCRAW_LOCAL_FOUND) 0044 message(WARNING "KDCRAW_LOCAL_DIR specified as \"${KDCRAW_LOCAL_DIR}\" but libkdcraw could not be found there.") 0045 endif (NOT KDCRAW_LOCAL_FOUND) 0046 else (KDCRAW_LOCAL_DIR) 0047 find_file(KDCRAW_LOCAL_FOUND libkdcraw/version.h.cmake ${CMAKE_SOURCE_DIR}/libkdcraw NO_DEFAULT_PATH) 0048 if (KDCRAW_LOCAL_FOUND) 0049 set(KDCRAW_LOCAL_DIR libkdcraw) 0050 endif (KDCRAW_LOCAL_FOUND) 0051 find_file(KDCRAW_LOCAL_FOUND libkdcraw/version.h.cmake ${CMAKE_SOURCE_DIR}/libs/libkdcraw NO_DEFAULT_PATH) 0052 if (KDCRAW_LOCAL_FOUND) 0053 set(KDCRAW_LOCAL_DIR libs/libkdcraw) 0054 endif (KDCRAW_LOCAL_FOUND) 0055 endif (KDCRAW_LOCAL_DIR) 0056 0057 if (KDCRAW_LOCAL_FOUND) 0058 # We need two include directories: because the version.h file is put into the build directory 0059 # TODO KDCRAW_INCLUDE_DIR sounds like it should contain only one directory... 0060 set(KDCRAW_INCLUDE_DIR ${CMAKE_SOURCE_DIR}/${KDCRAW_LOCAL_DIR} ${CMAKE_BINARY_DIR}/${KDCRAW_LOCAL_DIR}) 0061 set(KDCRAW_DEFINITIONS "-I${CMAKE_SOURCE_DIR}/${KDCRAW_LOCAL_DIR}" "-I${CMAKE_BINARY_DIR}/${KDCRAW_LOCAL_DIR}") 0062 set(KDCRAW_LIBRARIES kdcraw) 0063 if (NOT Kdcraw_FIND_QUIETLY) 0064 message(STATUS "Found Kdcraw library in local sub-folder: ${CMAKE_SOURCE_DIR}/${KDCRAW_LOCAL_DIR}") 0065 endif (NOT Kdcraw_FIND_QUIETLY) 0066 set(KDCRAW_FOUND TRUE) 0067 0068 set(kdcraw_version_h_filename "${CMAKE_BINARY_DIR}/${KDCRAW_LOCAL_DIR}/libkdcraw/version.h") 0069 0070 else (KDCRAW_LOCAL_FOUND) 0071 if (NOT WIN32) 0072 if (NOT Kdcraw_FIND_QUIETLY) 0073 message(STATUS "Check Kdcraw library using pkg-config...") 0074 endif (NOT Kdcraw_FIND_QUIETLY) 0075 0076 # use FindPkgConfig to get the directories and then use these values 0077 # in the find_path() and find_library() calls 0078 include(FindPkgConfig) 0079 0080 pkg_check_modules(PC_KDCRAW libkdcraw) 0081 0082 if (PC_KDCRAW_FOUND) 0083 # make sure the version is >= 0.2.0 0084 # TODO: WHY? 0085 if (PC_KDCRAW_VERSION VERSION_LESS 0.2.0) 0086 message(STATUS "Found libkdcraw release < 0.2.0, too old") 0087 set(KDCRAW_VERSION_GOOD_FOUND FALSE) 0088 set(KDCRAW_FOUND FALSE) 0089 else (PC_KDCRAW_VERSION VERSION_LESS 0.2.0) 0090 set(KDCRAW_VERSION "${PC_KDCRAW_VERSION}") 0091 if (NOT Kdcraw_FIND_QUIETLY) 0092 message(STATUS "Found libkdcraw release ${KDCRAW_VERSION}") 0093 endif (NOT Kdcraw_FIND_QUIETLY) 0094 set(KDCRAW_VERSION_GOOD_FOUND TRUE) 0095 endif (PC_KDCRAW_VERSION VERSION_LESS 0.2.0) 0096 else (PC_KDCRAW_FOUND) 0097 set(KDCRAW_VERSION_GOOD_FOUND FALSE) 0098 endif (PC_KDCRAW_FOUND) 0099 else (NOT WIN32) 0100 # TODO: Why do we just assume the version is good? 0101 set(KDCRAW_VERSION_GOOD_FOUND TRUE) 0102 endif (NOT WIN32) 0103 0104 if (KDCRAW_VERSION_GOOD_FOUND) 0105 set(KDCRAW_DEFINITIONS "${PC_KDCRAW_CFLAGS_OTHER}") 0106 0107 find_path(KDCRAW_INCLUDE_DIR libkdcraw/version.h ${PC_KDCRAW_INCLUDE_DIRS}) 0108 set(kdcraw_version_h_filename "${KDCRAW_INCLUDE_DIR}/libkdcraw/version.h") 0109 0110 find_library(KDCRAW_LIBRARIES NAMES kdcraw HINTS ${PC_KDCRAW_LIBRARY_DIRS}) 0111 0112 if (KDCRAW_INCLUDE_DIR AND KDCRAW_LIBRARIES) 0113 set(KDCRAW_FOUND TRUE) 0114 else (KDCRAW_INCLUDE_DIR AND KDCRAW_LIBRARIES) 0115 set(KDCRAW_FOUND FALSE) 0116 endif (KDCRAW_INCLUDE_DIR AND KDCRAW_LIBRARIES) 0117 endif (KDCRAW_VERSION_GOOD_FOUND) 0118 0119 if (KDCRAW_FOUND) 0120 if (NOT Kdcraw_FIND_QUIETLY) 0121 message(STATUS "Found libkdcraw: ${KDCRAW_LIBRARIES}") 0122 endif (NOT Kdcraw_FIND_QUIETLY) 0123 else (KDCRAW_FOUND) 0124 if (Kdcraw_FIND_REQUIRED) 0125 if (NOT KDCRAW_INCLUDE_DIR) 0126 message(FATAL_ERROR "Could NOT find libkdcraw header files.") 0127 else(NOT KDCRAW_INCLUDE_DIR) 0128 message(FATAL_ERROR "Could NOT find libkdcraw library.") 0129 endif (NOT KDCRAW_INCLUDE_DIR) 0130 endif (Kdcraw_FIND_REQUIRED) 0131 endif (KDCRAW_FOUND) 0132 0133 endif (KDCRAW_LOCAL_FOUND) 0134 0135 if (KDCRAW_FOUND) 0136 # Find the version information, unless that was reported by pkg_search_module. 0137 if (NOT KDCRAW_VERSION) 0138 file(READ "${kdcraw_version_h_filename}" kdcraw_version_h_content) 0139 # This is the line we are trying to find: static const char kdcraw_version[] = "1.22.4-beta_5+dfsg"; 0140 string(REGEX REPLACE ".*char +kdcraw_version\\[\\] += +\"([^\"]+)\".*" "\\1" KDCRAW_VERSION "${kdcraw_version_h_content}") 0141 unset(kdcraw_version_h_content) 0142 0143 endif (NOT KDCRAW_VERSION) 0144 unset(kdcraw_version_h_filename) 0145 endif (KDCRAW_FOUND) 0146 0147 if (KDCRAW_FOUND) 0148 mark_as_advanced(KDCRAW_INCLUDE_DIR KDCRAW_LIBRARIES KDCRAW_DEFINITIONS KDCRAW_VERSION KDCRAW_FOUND) 0149 else (KDCRAW_FOUND) 0150 # The library was not found, reset all related variables. 0151 unset(KDCRAW_INCLUDE_DIR) 0152 unset(KDCRAW_LIBRARIES) 0153 unset(KDCRAW_DEFINITIONS) 0154 unset(KDCRAW_VERSION) 0155 endif (KDCRAW_FOUND) 0156 0157 endif (KDCRAW_INCLUDE_DIR AND KDCRAW_LIBRARIES AND KDCRAW_DEFINITIONS AND KDCRAW_VERSION)