mirror of
https://bitbucket.org/smil3y/kdelibs.git
synced 2025-02-23 18:32:49 +00:00
generic: rewrite LibRaw CMake module
Signed-off-by: Ivailo Monev <xakepa10@gmail.com>
This commit is contained in:
parent
ddfc92dc1e
commit
63087f5ce3
3 changed files with 37 additions and 77 deletions
|
@ -1,79 +1,44 @@
|
|||
# - Find LibRaw
|
||||
# Find the LibRaw library <http://www.libraw.org>
|
||||
# This module defines
|
||||
# LibRaw_VERSION_STRING, the version string of LibRaw
|
||||
# LibRaw_INCLUDE_DIR, where to find libraw.h
|
||||
# LibRaw_LIBRARIES, the libraries needed to use LibRaw (non-thread-safe)
|
||||
# LibRaw_r_LIBRARIES, the libraries needed to use LibRaw (thread-safe)
|
||||
# LibRaw_DEFINITIONS, the definitions needed to use LibRaw (non-thread-safe)
|
||||
# LibRaw_r_DEFINITIONS, the definitions needed to use LibRaw (thread-safe)
|
||||
# - Try to find LibRaw library
|
||||
#
|
||||
# Copyright (c) 2013, Pino Toscano <pino at kde dot org>
|
||||
# Copyright (c) 2013, Gilles Caulier <caulier dot gilles at gmail dot com>
|
||||
# Once done this will define
|
||||
#
|
||||
# LIBRAW_FOUND - system has LibRaw
|
||||
# LIBRAW_INCLUDE_DIR - the LibRaw include directory
|
||||
# LIBRAW_LIBRARIES - the libraries needed to use LibRaw
|
||||
# LIBRAW_DEFINITIONS - compiler switches required for using LibRaw
|
||||
#
|
||||
# Copyright (c) 2021, Ivailo Monev, <xakepa10@gmail.com>
|
||||
#
|
||||
# Redistribution and use is allowed according to the terms of the BSD license.
|
||||
# For details see the accompanying COPYING-CMAKE-SCRIPTS file.
|
||||
|
||||
FIND_PACKAGE(PkgConfig)
|
||||
if(NOT WIN32)
|
||||
include(FindPkgConfig)
|
||||
pkg_check_modules(PC_LIBRAW QUIET libraw_r)
|
||||
|
||||
IF(PKG_CONFIG_FOUND)
|
||||
PKG_CHECK_MODULES(PC_LIBRAW libraw)
|
||||
SET(LibRaw_DEFINITIONS ${PC_LIBRAW_CFLAGS_OTHER})
|
||||
set(LIBRAW_INCLUDE_DIR ${PC_LIBRAW_INCLUDE_DIRS})
|
||||
set(LIBRAW_LIBRARIES ${PC_LIBRAW_LIBRARIES})
|
||||
endif()
|
||||
|
||||
PKG_CHECK_MODULES(PC_LIBRAW_R libraw_r)
|
||||
SET(LibRaw_r_DEFINITIONS ${PC_LIBRAW_R_CFLAGS_OTHER})
|
||||
ENDIF()
|
||||
set(LIBRAW_VERSION ${PC_LIBRAW_VERSION})
|
||||
set(LIBRAW_DEFINITIONS ${PC_LIBRAW_CFLAGS_OTHER})
|
||||
|
||||
FIND_PATH(LibRaw_INCLUDE_DIR libraw.h
|
||||
HINTS
|
||||
${PC_LIBRAW_INCLUDEDIR}
|
||||
${PC_LibRaw_INCLUDE_DIRS}
|
||||
PATH_SUFFIXES libraw
|
||||
)
|
||||
if(NOT LIBRAW_INCLUDE_DIR OR NOT LIBRAW_LIBRARIES)
|
||||
find_path(LIBRAW_INCLUDE_DIR
|
||||
NAMES libraw.h
|
||||
HINTS $ENV{LIBRAWDIR}/include
|
||||
)
|
||||
|
||||
FIND_LIBRARY(LibRaw_LIBRARIES NAMES raw
|
||||
HINTS
|
||||
${PC_LIBRAW_LIBDIR}
|
||||
${PC_LIBRAW_LIBRARY_DIRS}
|
||||
)
|
||||
find_library(LIBRAW_LIBRARIES
|
||||
NAMES raw_r
|
||||
HINTS $ENV{LIBRAWDIR}/lib
|
||||
)
|
||||
endif()
|
||||
|
||||
FIND_LIBRARY(LibRaw_r_LIBRARIES NAMES raw_r
|
||||
HINTS
|
||||
${PC_LIBRAW_R_LIBDIR}
|
||||
${PC_LIBRAW_R_LIBRARY_DIRS}
|
||||
)
|
||||
include(FindPackageHandleStandardArgs)
|
||||
find_package_handle_standard_args(LibRaw
|
||||
VERSION_VAR LIBRAW_VERSION
|
||||
REQUIRED_VARS LIBRAW_LIBRARIES LIBRAW_INCLUDE_DIR
|
||||
)
|
||||
|
||||
IF(LibRaw_INCLUDE_DIR)
|
||||
FILE(READ ${LibRaw_INCLUDE_DIR}/libraw_version.h _libraw_version_content)
|
||||
|
||||
STRING(REGEX MATCH "#define LIBRAW_MAJOR_VERSION[ \t]*([0-9]*)\n" _version_major_match ${_libraw_version_content})
|
||||
SET(_libraw_version_major "${CMAKE_MATCH_1}")
|
||||
|
||||
STRING(REGEX MATCH "#define LIBRAW_MINOR_VERSION[ \t]*([0-9]*)\n" _version_minor_match ${_libraw_version_content})
|
||||
SET(_libraw_version_minor "${CMAKE_MATCH_1}")
|
||||
|
||||
STRING(REGEX MATCH "#define LIBRAW_PATCH_VERSION[ \t]*([0-9]*)\n" _version_patch_match ${_libraw_version_content})
|
||||
SET(_libraw_version_patch "${CMAKE_MATCH_1}")
|
||||
|
||||
IF(_version_major_match AND _version_minor_match AND _version_patch_match)
|
||||
SET(LibRaw_VERSION_STRING "${_libraw_version_major}.${_libraw_version_minor}.${_libraw_version_patch}")
|
||||
ELSE()
|
||||
IF(NOT LibRaw_FIND_QUIETLY)
|
||||
MESSAGE(STATUS "Failed to get version information from ${LibRaw_INCLUDE_DIR}/libraw_version.h")
|
||||
ENDIF()
|
||||
ENDIF()
|
||||
ENDIF()
|
||||
|
||||
INCLUDE(FindPackageHandleStandardArgs)
|
||||
FIND_PACKAGE_HANDLE_STANDARD_ARGS(LibRaw
|
||||
REQUIRED_VARS LibRaw_LIBRARIES LibRaw_INCLUDE_DIR
|
||||
VERSION_VAR LibRaw_VERSION_STRING
|
||||
)
|
||||
|
||||
MARK_AS_ADVANCED(LibRaw_VERSION_STRING
|
||||
LibRaw_INCLUDE_DIR
|
||||
LibRaw_LIBRARIES
|
||||
LibRaw_r_LIBRARIES
|
||||
LibRaw_DEFINITIONS
|
||||
LibRaw_r_DEFINITIONS
|
||||
)
|
||||
mark_as_advanced(LIBRAW_INCLUDE_DIR LIBRAW_LIBRARIES)
|
||||
|
|
|
@ -35,10 +35,7 @@ SET_PACKAGE_PROPERTIES(LibRaw PROPERTIES
|
|||
PURPOSE "Required to build libkdcraw"
|
||||
)
|
||||
|
||||
# Check LibRaw config header.
|
||||
MESSAGE(STATUS "LibRaw version: ${LibRaw_VERSION_STRING}")
|
||||
|
||||
IF(EXISTS "${LibRaw_INCLUDE_DIR}/libraw_config.h")
|
||||
IF(EXISTS "${LIBRAW_INCLUDE_DIR}/libraw_config.h")
|
||||
ADD_DEFINITIONS(-DLIBRAW_HAS_CONFIG)
|
||||
MESSAGE(STATUS "LibRaw config file exists: yes")
|
||||
ELSE()
|
||||
|
@ -47,8 +44,7 @@ ENDIF()
|
|||
|
||||
ADD_DEFINITIONS(
|
||||
${QT_QTDBUS_DEFINITIONS}
|
||||
${LibRaw_DEFINITIONS}
|
||||
${LibRaw_r_DEFINITIONS}
|
||||
${LIBRAW_DEFINITIONS}
|
||||
-DKDE_DEFAULT_DEBUG_AREA=51002
|
||||
)
|
||||
|
||||
|
@ -58,7 +54,7 @@ INCLUDE_DIRECTORIES(
|
|||
${QDBUS_INCLUDE_DIRS}
|
||||
${KDE4_KDECORE_INCLUDES}
|
||||
${KDE4_KIO_INCLUDES}
|
||||
${LibRaw_INCLUDE_DIR}
|
||||
${LIBRAW_INCLUDE_DIR}
|
||||
)
|
||||
|
||||
# ==================================================================================================
|
||||
|
@ -87,4 +83,3 @@ INSTALL(
|
|||
${CMAKE_CURRENT_BINARY_DIR}/libkdcraw.pc
|
||||
DESTINATION ${LIB_INSTALL_DIR}/pkgconfig
|
||||
)
|
||||
|
||||
|
|
|
@ -44,7 +44,7 @@ set(kdcraw_LIB_SRCS
|
|||
add_library(kdcraw ${LIBRARY_TYPE} ${kdcraw_LIB_SRCS})
|
||||
|
||||
target_link_libraries(kdcraw PRIVATE
|
||||
${LibRaw_r_LIBRARIES}
|
||||
${LIBRAW_LIBRARIES}
|
||||
)
|
||||
|
||||
target_link_libraries(kdcraw PUBLIC
|
||||
|
|
Loading…
Add table
Reference in a new issue