From 01da687868facd5b8bb221b65d3fc98e21d6797f Mon Sep 17 00:00:00 2001 From: Pascal Obry Date: Fri, 12 Nov 2021 08:22:21 +0100 Subject: [PATCH] Add LibRaw cmake support. --- .gitmodules | 3 + src/CMakeLists.txt | 32 +- src/common/imageio_libraw.c | 10 +- src/external/CMakeLists.txt | 2 +- src/external/LibRaw | 1 + src/external/LibRaw-cmake/.gitattributes | 1 + .../LibRaw-cmake/.github/workflows/ci.yml | 33 + src/external/LibRaw-cmake/.gitignore | 2 + src/external/LibRaw-cmake/CMakeLists.txt | 726 ++++++++++++++++++ src/external/LibRaw-cmake/INSTALL.CMAKE | 62 ++ src/external/LibRaw-cmake/LICENSE | 22 + src/external/LibRaw-cmake/README.md | 35 + .../LibRaw-cmake/cmake/data/libraw.lsm.cmake | 13 + .../LibRaw-cmake/cmake/data/libraw.pc.cmake | 12 + .../cmake/data/libraw_config.h.cmake | 50 ++ .../LibRaw-cmake/cmake/data/libraw_r.pc.cmake | 12 + .../LibRaw-cmake/cmake/librawConfig.cmake.in | 35 + .../LibRaw-cmake/cmake/modules/FindLCMS.cmake | 60 ++ .../cmake/modules/FindLCMS2.cmake | 72 ++ .../cmake/modules/FindLibRaw.cmake | 96 +++ .../cmake/modules/MacroBoolTo01.cmake | 20 + .../cmake/modules/MacroLogFeature.cmake | 159 ++++ .../modules/MacroOptionalFindPackage.cmake | 48 ++ .../cmake/modules/Uninstall.cmake | 22 + 24 files changed, 1515 insertions(+), 13 deletions(-) create mode 160000 src/external/LibRaw create mode 100644 src/external/LibRaw-cmake/.gitattributes create mode 100644 src/external/LibRaw-cmake/.github/workflows/ci.yml create mode 100644 src/external/LibRaw-cmake/.gitignore create mode 100644 src/external/LibRaw-cmake/CMakeLists.txt create mode 100644 src/external/LibRaw-cmake/INSTALL.CMAKE create mode 100644 src/external/LibRaw-cmake/LICENSE create mode 100644 src/external/LibRaw-cmake/README.md create mode 100644 src/external/LibRaw-cmake/cmake/data/libraw.lsm.cmake create mode 100644 src/external/LibRaw-cmake/cmake/data/libraw.pc.cmake create mode 100644 src/external/LibRaw-cmake/cmake/data/libraw_config.h.cmake create mode 100644 src/external/LibRaw-cmake/cmake/data/libraw_r.pc.cmake create mode 100644 src/external/LibRaw-cmake/cmake/librawConfig.cmake.in create mode 100644 src/external/LibRaw-cmake/cmake/modules/FindLCMS.cmake create mode 100644 src/external/LibRaw-cmake/cmake/modules/FindLCMS2.cmake create mode 100644 src/external/LibRaw-cmake/cmake/modules/FindLibRaw.cmake create mode 100644 src/external/LibRaw-cmake/cmake/modules/MacroBoolTo01.cmake create mode 100644 src/external/LibRaw-cmake/cmake/modules/MacroLogFeature.cmake create mode 100644 src/external/LibRaw-cmake/cmake/modules/MacroOptionalFindPackage.cmake create mode 100644 src/external/LibRaw-cmake/cmake/modules/Uninstall.cmake diff --git a/.gitmodules b/.gitmodules index 4e1b522fb81a..bf9defc57b06 100644 --- a/.gitmodules +++ b/.gitmodules @@ -14,3 +14,6 @@ [submodule "src/tests/integration"] path = src/tests/integration url = https://github.com/darktable-org/darktable-tests.git +[submodule "src/external/LibRaw"] + path = src/external/LibRaw + url = https://github.com/LibRaw/LibRaw.git diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 450bf25b497c..f0e4cea74703 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -5,6 +5,7 @@ include(CheckCXXCompilerFlag) include(CheckCSourceCompiles) include(CheckCXXSymbolExists) + # # Add files for libdarktable # @@ -382,14 +383,17 @@ if(USE_HEIF) endif() endif() +# For now we use the LibRaw submodule if (USE_LIBRAW) - find_package(libraw 0.20.2) - if (libraw_FOUND) - list(APPEND LIBS ${libraw_LIBRARY}) - add_definitions(-DHAVE_LIBRAW=1) - list(APPEND SOURCES "common/imageio_libraw.c") - set(DT_SUPPORTED_EXTENSIONS ${DT_SUPPORTED_EXTENSIONS} libraw CACHE INTERNAL "") - endif() +# find_package(libraw 0.20.2) +# if (libraw_FOUND) +# list(APPEND LIBS ${libraw_LIBRARY}) +# add_definitions(-DHAVE_LIBRAW=1) +# list(APPEND SOURCES "common/imageio_libraw.c") +# set(DT_SUPPORTED_EXTENSIONS ${DT_SUPPORTED_EXTENSIONS} libraw CACHE INTERNAL "") +# endif() + add_definitions(-DHAVE_LIBRAW=1) + list(APPEND SOURCES "common/imageio_libraw.c") endif() if(USE_LENSFUN) @@ -432,6 +436,10 @@ if (USE_ISOBMFF) # This must be manually enabled during exiv2 build and can be checked with # the EXV_ENABLE_BMFF symbol. check_cxx_symbol_exists(EXV_ENABLE_BMFF "exiv2/exiv2.hpp" HAVE_EXV_ENABLE_BMFF) + # ??? This needs fix as we bypass the check for actual exiv2 version + if(APPLE) + set(HAVE_EXV_ENABLE_BMFF 1) + endif() if(HAVE_EXV_ENABLE_BMFF) add_definitions(-DHAVE_LIBEXIV2_WITH_ISOBMFF=1) set(DT_SUPPORTED_EXTENSIONS ${DT_SUPPORTED_EXTENSIONS} cr3 CACHE INTERNAL "") @@ -1033,3 +1041,13 @@ InstallDependencyFiles() # Tell CPack about the components and group the data components together (CPACK_COMPONENT_${COMPONENT_NAME_ALL_CAPS}_GROUP). set(CPACK_COMPONENTS_ALL DTApplication DTDebugSymbols DTDocuments) + +if (USE_LIBRAW) + set(LIBRAW_PATH "${CMAKE_CURRENT_SOURCE_DIR}/external/LibRaw" CACHE STRING "Relative path to libraw directory (default=CMAKE_CURRENT_SOURCE_DIR)") + set(ENABLE_EXAMPLES OFF CACHE BOOLEAN "") + set(DT_SUPPORTED_EXTENSIONS ${DT_SUPPORTED_EXTENSIONS} libraw CACHE INTERNAL "") + + # LibRaw sub-module + add_subdirectory(external/LibRaw-cmake) + target_link_libraries(lib_darktable PRIVATE libraw::libraw) +endif() diff --git a/src/common/imageio_libraw.c b/src/common/imageio_libraw.c index 044a8d656f28..51ae51c95f4a 100644 --- a/src/common/imageio_libraw.c +++ b/src/common/imageio_libraw.c @@ -83,7 +83,7 @@ gboolean dt_libraw_lookup_makermodel(const char *maker, const char *model, dt_imageio_retval_t dt_imageio_open_libraw(dt_image_t *img, const char *filename, dt_mipmap_buffer_t *mbuf) { - int err; + int err = 0; int libraw_err = 0; if(!_supported_image(filename)) return DT_IMAGEIO_FILE_CORRUPTED; if(!img->exif_inited) (void)dt_exif_read(img, filename); @@ -131,10 +131,10 @@ dt_imageio_retval_t dt_imageio_open_libraw(dt_image_t *img, const char *filename img->height = raw->sizes.raw_height; // Apply crop parameters - img->crop_x = raw->sizes.raw_inset_crop.cleft; - img->crop_y = raw->sizes.raw_inset_crop.ctop; - img->crop_width = raw->sizes.raw_width - raw->sizes.raw_inset_crop.cwidth - raw->sizes.raw_inset_crop.cleft; - img->crop_height = raw->sizes.raw_height - raw->sizes.raw_inset_crop.cheight - raw->sizes.raw_inset_crop.ctop; + img->crop_x = raw->sizes.raw_inset_crops[0].cleft; + img->crop_y = raw->sizes.raw_inset_crops[0].ctop; + img->crop_width = raw->sizes.raw_width - raw->sizes.raw_inset_crops[0].cwidth - raw->sizes.raw_inset_crops[0].cleft; + img->crop_height = raw->sizes.raw_height - raw->sizes.raw_inset_crops[0].cheight - raw->sizes.raw_inset_crops[0].ctop; // We can reuse the libraw filters property, it's already well-handled in dt. // It contains the BAYER filter pattern. diff --git a/src/external/CMakeLists.txt b/src/external/CMakeLists.txt index 08e300a73bed..ea819776ce52 100644 --- a/src/external/CMakeLists.txt +++ b/src/external/CMakeLists.txt @@ -46,7 +46,7 @@ add_subdirectory(rawspeed ${DARKTABLE_LIBDIR}/rawspeed) # Copying rawspeed resources to where dt expects them add_custom_target("deploy" ALL) SET(RAWSPEED_DATADIR "${CMAKE_CURRENT_SOURCE_DIR}/rawspeed/data") -add_custom_command(TARGET "deploy" PRE_BUILD +add_custom_command(TARGET "deploy" PRE_BUILD COMMAND ${CMAKE_COMMAND} -E make_directory ${DARKTABLE_DATADIR}/rawspeed/ COMMAND ${CMAKE_COMMAND} -E copy ${RAWSPEED_DATADIR}/cameras.xml ${RAWSPEED_DATADIR}/showcameras.xsl ${DARKTABLE_DATADIR}/rawspeed/ ) diff --git a/src/external/LibRaw b/src/external/LibRaw new file mode 160000 index 000000000000..5bc2c67456fa --- /dev/null +++ b/src/external/LibRaw @@ -0,0 +1 @@ +Subproject commit 5bc2c67456fa759c11b41af635a37112d03d8eaf diff --git a/src/external/LibRaw-cmake/.gitattributes b/src/external/LibRaw-cmake/.gitattributes new file mode 100644 index 000000000000..176a458f94e0 --- /dev/null +++ b/src/external/LibRaw-cmake/.gitattributes @@ -0,0 +1 @@ +* text=auto diff --git a/src/external/LibRaw-cmake/.github/workflows/ci.yml b/src/external/LibRaw-cmake/.github/workflows/ci.yml new file mode 100644 index 000000000000..08dee2cce0ac --- /dev/null +++ b/src/external/LibRaw-cmake/.github/workflows/ci.yml @@ -0,0 +1,33 @@ +name: CI + +on: [push, pull_request, workflow_dispatch] + +env: + LIBRAW_GIT: https://github.com/LibRaw/LibRaw.git + +defaults: + run: + shell: bash + +jobs: + build: + strategy: + fail-fast: false + matrix: + os: [ubuntu-latest, macos-latest, windows-latest] + libraw_ref: ['0.20.2', 'master'] + + runs-on: ${{ matrix.os }} + + steps: + - uses: actions/checkout@v2 + + - run: git clone $LIBRAW_GIT -b ${{ matrix.libraw_ref }} + name: Clone LibRaw + + - run: | + mkdir build + cd build + cmake -DENABLE_OPENMP=OFF -DLIBRAW_PATH=$(pwd)/../LibRaw .. + cmake --build . + name: Build LibRaw diff --git a/src/external/LibRaw-cmake/.gitignore b/src/external/LibRaw-cmake/.gitignore new file mode 100644 index 000000000000..7b086376bbbf --- /dev/null +++ b/src/external/LibRaw-cmake/.gitignore @@ -0,0 +1,2 @@ +/.project +build \ No newline at end of file diff --git a/src/external/LibRaw-cmake/CMakeLists.txt b/src/external/LibRaw-cmake/CMakeLists.txt new file mode 100644 index 000000000000..4dd249953181 --- /dev/null +++ b/src/external/LibRaw-cmake/CMakeLists.txt @@ -0,0 +1,726 @@ +# =========================================================== +# +# This file is a part of Libraw project +# http://www.libraw.org +# +# @date 2013-09-07 +# @brief Library for reading and processing of RAW images +# +# @author Copyright (C) 2013 by Gilles Caulier +# caulier dot gilles at gmail dot com +# +# This program is free software; you can redistribute it +# and/or modify it under the terms of the GNU General +# Public License as published by the Free Software Foundation; +# either version 2, or (at your option) +# any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# ============================================================ + +cmake_minimum_required(VERSION 3.12..16) + + +# Determine if libraw is built as a subproject (using add_subdirectory) +# or if it is the master project. +set(MASTER_PROJECT OFF) +if (CMAKE_CURRENT_SOURCE_DIR STREQUAL CMAKE_SOURCE_DIR) + set(MASTER_PROJECT ON) + message(STATUS "CMake version: ${CMAKE_VERSION}") +endif () + +set(LIBRAW_PATH ${CMAKE_CURRENT_SOURCE_DIR} CACHE STRING "Relative path to libraw directory (default=CMAKE_CURRENT_SOURCE_DIR)") +if(NOT EXISTS "${LIBRAW_PATH}") + message(STATUS "LIBRAW_PATH=${LIBRAW_PATH}") + message(FATAL_ERROR "LIBRAW_PATH does not contain a valid path to the libraw home") +endif() + +file(TO_CMAKE_PATH "${LIBRAW_PATH}" LIBRAW_PATH) + +# ================================================================================================== +# Library version info extraction + +file(READ ${LIBRAW_PATH}/libraw/libraw_version.h _libraw_version_content) + +# API version strings +string(REGEX MATCH "#define LIBRAW_MAJOR_VERSION[ \t]*([0-9]*)\n" _version_major_match ${_libraw_version_content}) +set(RAW_LIB_MAJOR_VERSION "${CMAKE_MATCH_1}") + +string(REGEX MATCH "#define LIBRAW_MINOR_VERSION[ \t]*([0-9]*)\n" _version_minor_match ${_libraw_version_content}) +set(RAW_LIB_MINOR_VERSION "${CMAKE_MATCH_1}") + +string(REGEX MATCH "#define LIBRAW_PATCH_VERSION[ \t]*([0-9]*)\n" _version_patch_match ${_libraw_version_content}) +set(RAW_LIB_PATCH_VERSION "${CMAKE_MATCH_1}") + +# ABI version strings + +string(REGEX MATCH "#define LIBRAW_SHLIB_CURRENT[ \t]*([0-9]*)\n" _version_socur_match ${_libraw_version_content}) +set(RAW_LIB_SO_CUR_VERSION "${CMAKE_MATCH_1}") + +string(REGEX MATCH "#define LIBRAW_SHLIB_REVISION[ \t]*([0-9]*)\n" _version_sorev_match ${_libraw_version_content}) +set(RAW_LIB_SO_REV_VERSION "${CMAKE_MATCH_1}") + +string(REGEX MATCH "#define LIBRAW_SHLIB_AGE[ \t]*([0-9]*)\n" _version_soage_match ${_libraw_version_content}) +set(RAW_LIB_SO_AGE_VERSION "${CMAKE_MATCH_1}") + +# Set env. variables accordinly. +set(RAW_LIB_VERSION_STRING "${RAW_LIB_MAJOR_VERSION}.${RAW_LIB_MINOR_VERSION}.${RAW_LIB_PATCH_VERSION}") +set(RAW_LIB_VERSION_ID "0x${RAW_LIB_MAJOR_VERSION}${RAW_LIB_MINOR_VERSION}${RAW_LIB_PATCH_VERSION}") +set(RAW_LIB_SO_VERSION_STRING "${RAW_LIB_SO_CUR_VERSION}.${RAW_LIB_SO_REV_VERSION}.${RAW_LIB_SO_AGE_VERSION}") + +message(STATUS "LibRaw string version: ${RAW_LIB_VERSION_STRING}") +message(STATUS "LibRaw ID version: ${RAW_LIB_VERSION_ID}") +message(STATUS "LibRaw SO version: ${RAW_LIB_SO_VERSION_STRING}") + +project(libraw VERSION ${RAW_LIB_VERSION_STRING} LANGUAGES CXX) + +# ================================================================================================== +# Project Options +option(BUILD_SHARED_LIBS "Build library as shared library (default=ON)" OFF) +option(ENABLE_OPENMP "Build library with OpenMP support (default=ON)" ON) +option(ENABLE_LCMS "Build library with LCMS support (default=ON)" ON) +option(ENABLE_JASPER "Build library with libjasper support (default=ON)" ON) +option(ENABLE_EXAMPLES "Build library with sample command-line programs (default=ON)" ${MASTER_PROJECT}) +option(ENABLE_RAWSPEED "Build library with extra RawSpeed codec support (default=OFF)" OFF) +option(ENABLE_DCRAW_DEBUG "Build library with debug message from dcraw (default=OFF)" OFF) +option(ENABLE_X3FTOOLS "Build library with Foveon X3F support (default=OFF)" OFF) +option(ENABLE_6BY9RPI "Build library with Raspberry Pi RAW support (default=OFF)" OFF) +option(LIBRAW_UNINSTALL_TARGET "Add a custom target to ease removal of installed targets" ${MASTER_PROJECT}) +option(LIBRAW_INSTALL "Generate the install target." ${MASTER_PROJECT}) + +set(RAWSPEED_RPATH "RawSpeed" CACHE STRING + "Relative path to extra RawSpeed codec (default=RawSpeed)") + +set(RAWSPEED_PATH "${CMAKE_CURRENT_SOURCE_DIR}/${RAWSPEED_RPATH}") + +set(INSTALL_CMAKE_MODULE_PATH "share/libraw/cmake" CACHE STRING + "Path to install cmake module (default=share/libraw/cmake)") + +# ================================================================================================== +# General definitions rules + +set(LIB_SUFFIX "" CACHE STRING "Define suffix of lib directory name (32/64)" ) + +if(WIN32 AND NOT DEFINED CMAKE_DEBUG_POSTFIX) + set(CMAKE_DEBUG_POSTFIX "d") +endif() + +# To prevent warnings from M$ compiler +if(WIN32 AND MSVC) + add_definitions(-D_CRT_SECURE_NO_WARNINGS) + add_definitions(-D_ATL_SECURE_NO_WARNINGS) + add_definitions(-D_AFX_SECURE_NO_WARNINGS) +endif() + +# -- Check dependencies -------------------------------------------------------------------------------- + +set(CMAKE_MODULE_PATH ${CMAKE_CURRENT_SOURCE_DIR}/cmake/modules ${CMAKE_MODULE_PATH} ) + +INCLUDE(MacroBoolTo01) +INCLUDE(MacroLogFeature) +INCLUDE(MacroOptionalFindPackage) + +# Math library check + +if(NOT WIN32) + FIND_LIBRARY(MATH_LIBRARY m) +endif() + +# LCMS version 1 and 2 library check + +set(LCMS_SUPPORT_CAN_BE_COMPILED false) +set(LCMS2_FOUND false) +set(LCMS_FOUND false) + +if(ENABLE_LCMS) + message(STATUS "Check for LCMS2 availability...") + find_package(LCMS2) + if(LCMS2_FOUND AND (LCMS2_VERSION VERSION_EQUAL 2.1 OR LCMS2_VERSION VERSION_GREATER 2.1)) + message(STATUS "Found LCMS2 : ${LCMS2_LIBRARIES} ${LCMS2_INCLUDE_DIR}") + include_directories(${LCMS2_INCLUDE_DIR}) + MACRO_LOG_FEATURE(LCMS2_FOUND "LCMS2" "A small-footprint color management engine" "http://www.littlecms.com" FALSE "" "Needed by libkdcraw") + # Flag to compile Little CMS version 2 with LibRaw + add_definitions(-DUSE_LCMS2) + set(LCMS_SUPPORT_CAN_BE_COMPILED true) + else() + message(STATUS "Check for LCMS availability instead LCMS2...") + find_package(LCMS) + if(LCMS_FOUND) + message(STATUS "Found LCMS1: ${LCMS_LIBRARIES} ${LCMS_INCLUDE_DIR}") + include_directories(${LCMS_INCLUDE_DIR}) + MACRO_LOG_FEATURE(LCMS_FOUND "LCMS1" "A small-footprint color management engine" "http://www.littlecms.com" TRUE "" "Needed by libkdcraw") + # Flag to compile Little CMS version 1 with LibRaw + add_definitions(-DUSE_LCMS) + # For compatibility + set(LCMS2_LIBRARIES ${LCMS_LIBRARIES}) + set(LCMS_SUPPORT_CAN_BE_COMPILED true) + endif() + endif() +endif() + +# For registration to libraw_config.h +MACRO_BOOL_TO_01(LCMS_SUPPORT_CAN_BE_COMPILED LIBRAW_USE_LCMS) + +# zlib library check + +find_package(ZLIB) +find_package(JPEG) + +# Flag to use zlib with LibRaw DNG deflate codec +if(ZLIB_FOUND) + add_definitions(-DUSE_ZLIB) +endif() + +# For registration to libraw_config.h +MACRO_BOOL_TO_01(ZLIB_FOUND LIBRAW_USE_DNGDEFLATECODEC) + +# JPEG library check +find_package(JPEG) +if(JPEG_FOUND) + if (${JPEG_VERSION} LESS 80) + set(JPEG8_FOUND FALSE) + else() + set(JPEG8_FOUND TRUE) + endif() +endif() + +MACRO_LOG_FEATURE(JPEG8_FOUND "libjpeg" "JPEG image format support" "http://www.ijg.org" FALSE "80" "needed for the LibRaw DNG lossy codec") + +# Flag to use libjpeg with LibRaw DNG lossy codec +if(JPEG8_FOUND) + add_definitions(-DUSE_JPEG) + add_definitions(-DUSE_JPEG8) +endif() + +# For registration to libraw_config.h +MACRO_BOOL_TO_01(JPEG8_FOUND LIBRAW_USE_DNGLOSSYCODEC) + +if(ENABLE_OPENMP) + find_package(OpenMP REQUIRED) +endif() + +# For registration to libraw_config.h +MACRO_BOOL_TO_01(OpenMP_FOUND LIBRAW_USE_OPENMP) + +# Jasper library check +set(JASPER_FOUND false) +if(ENABLE_JASPER) + find_package(Jasper) + + # Flag to use libjasper with LibRaw RedCine codec + if(JASPER_FOUND) + add_definitions(-DUSE_JASPER) + include_directories(${JASPER_INCLUDE_DIR}) + endif() +endif() + +# For registration to libraw_config.h +MACRO_BOOL_TO_01(JASPER_FOUND LIBRAW_USE_REDCINECODEC) + +# For RawSpeed Codec Support + +set(RAWSPEED_FOUND false) +set(RAWSPEED_SUPPORT_CAN_BE_COMPILED false) + +if(ENABLE_RAWSPEED) + find_package(LibXml2) + find_package(Threads REQUIRED) + + message(STATUS "RawSpeed codec path: ${RAWSPEED_PATH}") + + if(EXISTS "${RAWSPEED_PATH}/Common.cpp") + set(RAWSPEED_FOUND true) + else() + message(STATUS "RawSpeed source code not found. Please checkout source code from RawStudio project website.") + endif() + + if(ENABLE_RAWSPEED AND RAWSPEED_FOUND AND JPEG8_FOUND AND LIBXML2_FOUND AND PTHREADS_FOUND) + + set(RAWSPEED_SUPPORT_CAN_BE_COMPILED true) + + else() + if(NOT JPEG8_FOUND) + message(STATUS "LibJPEG dependency not resolved. LibRaw cannot be compiled with RawSpeed codec") + endif() + + if(NOT LIBXML2_FOUND) + message(STATUS "LibXML2 dependency not resolved. LibRaw cannot be compiled with RawSpeed codec") + endif() + + if(NOT PTHREADS_FOUND) + message(STATUS "Pthreads dependency not resolved. LibRaw cannot be compiled with RawSpeed codec") + endif() + + endif() +endif() + +# For registration to libraw_config.h +MACRO_BOOL_TO_01(RAWSPEED_SUPPORT_CAN_BE_COMPILED LIBRAW_USE_RAWSPEED) + +# -- Compilation rules for RawSpeed library ------------------------------------------------------------- + +if(RAWSPEED_SUPPORT_CAN_BE_COMPILED) + include_directories(${RAWSPEED_PATH}) + + include_directories(${LIBXML2_INCLUDE_DIR} ${PTHREADS_INCLUDE_DIR}) + + # Flag to include RawSpeed codec with Libraw + add_definitions(-DUSE_RAWSPEED) + + add_definitions(${LIBXML2_DEFINITIONS} ${PTHREADS_DEFINITIONS}) + + set(librawspeed_LIB_SRCS ${RAWSPEED_PATH}/ArwDecoder.cpp + ${RAWSPEED_PATH}/BitPumpJPEG.cpp + ${RAWSPEED_PATH}/BitPumpMSB.cpp + ${RAWSPEED_PATH}/BitPumpMSB32.cpp + ${RAWSPEED_PATH}/BitPumpPlain.cpp + ${RAWSPEED_PATH}/BlackArea.cpp + ${RAWSPEED_PATH}/ByteStream.cpp + ${RAWSPEED_PATH}/ByteStreamSwap.cpp + ${RAWSPEED_PATH}/Camera.cpp + ${RAWSPEED_PATH}/CameraMetaData.cpp + ${RAWSPEED_PATH}/CameraMetadataException.cpp + ${RAWSPEED_PATH}/CameraSensorInfo.cpp + ${RAWSPEED_PATH}/ColorFilterArray.cpp + ${RAWSPEED_PATH}/Common.cpp + ${RAWSPEED_PATH}/Cr2Decoder.cpp + ${RAWSPEED_PATH}/DngDecoder.cpp + ${RAWSPEED_PATH}/DngDecoderSlices.cpp + ${RAWSPEED_PATH}/DngOpcodes.cpp + ${RAWSPEED_PATH}/FileIOException.cpp + ${RAWSPEED_PATH}/FileMap.cpp + ${RAWSPEED_PATH}/IOException.cpp + ${RAWSPEED_PATH}/LJpegDecompressor.cpp + ${RAWSPEED_PATH}/LJpegPlain.cpp + ${RAWSPEED_PATH}/NefDecoder.cpp + ${RAWSPEED_PATH}/NikonDecompressor.cpp + ${RAWSPEED_PATH}/OrfDecoder.cpp + ${RAWSPEED_PATH}/PefDecoder.cpp + ${RAWSPEED_PATH}/PentaxDecompressor.cpp + ${RAWSPEED_PATH}/RawDecoder.cpp + ${RAWSPEED_PATH}/RawDecoderException.cpp + ${RAWSPEED_PATH}/RawImage.cpp + ${RAWSPEED_PATH}/RawImageDataFloat.cpp + ${RAWSPEED_PATH}/RawImageDataU16.cpp + ${RAWSPEED_PATH}/RawParser.cpp + ${RAWSPEED_PATH}/Rw2Decoder.cpp + ${RAWSPEED_PATH}/SrwDecoder.cpp + ${RAWSPEED_PATH}/TiffEntry.cpp + ${RAWSPEED_PATH}/TiffEntryBE.cpp + ${RAWSPEED_PATH}/TiffIFD.cpp + ${RAWSPEED_PATH}/TiffIFDBE.cpp + ${RAWSPEED_PATH}/TiffParser.cpp + ${RAWSPEED_PATH}/TiffParserException.cpp + ${RAWSPEED_PATH}/TiffParserHeaderless.cpp + ${RAWSPEED_PATH}/TiffParserOlympus.cpp + ) + +endif() + +# -- Common LibRaw library compilation rules ------------------------------------------------------------------ + +# Flag to add debug print on the console +if(ENABLE_DCRAW_DEBUG) + add_definitions(-DDCRAW_VERBOSE) +endif() + +# For registration to libraw_config.h +MACRO_BOOL_TO_01(ENABLE_DCRAW_DEBUG LIBRAW_USE_DCRAW_DEBUG) + +# Flag to add Foveon X3F support +if(ENABLE_X3FTOOLS) + add_definitions(-DUSE_X3FTOOLS) +endif() + +# For registration to libraw_config.h +MACRO_BOOL_TO_01(ENABLE_X3FTOOLS LIBRAW_USE_X3FTOOLS) + +# Flag to add Raspberry Pi RAW support +if(ENABLE_6BY9RPI) + add_definitions(-DUSE_6BY9RPI) +endif() + +# For registration to libraw_config.h +MACRO_BOOL_TO_01(ENABLE_6BY9RPI LIBRAW_USE_6BY9RPI) + +# Create a config header for client application. +configure_file(${CMAKE_CURRENT_SOURCE_DIR}/cmake/data/libraw_config.h.cmake ${CMAKE_CURRENT_BINARY_DIR}/libraw_config.h) + +# Put the include dirs which are in the source or build tree +# before all other include dirs, so the headers in the sources +# are preferred over the already installed ones +set(CMAKE_INCLUDE_DIRECTORIES_PROJECT_BEFORE ON) + +include_directories(${CMAKE_CURRENT_BINARY_DIR}/ + ${LIBRAW_PATH}/ + ) + +# -- Log messages about configuration ------------------------------------------------------------------ + +message(STATUS "") +message(STATUS "----------------------------------------------------------------------------------") +message(STATUS " Libraw ${RAW_LIB_VERSION_STRING} configuration ") +message(STATUS "") + +if(OpenMP_FOUND) + message(STATUS " Libraw will be compiled with OpenMP support .................. YES") +else() + message(STATUS " Libraw will be compiled with OpenMP support .................. NO") +endif() + +if(LCMS_SUPPORT_CAN_BE_COMPILED) + message(STATUS " Libraw will be compiled with LCMS support .................... YES") +else() + message(STATUS " Libraw will be compiled with LCMS support .................... NO") +endif() + +if(ENABLE_EXAMPLES) + message(STATUS " Libraw will be compiled with example command-line programs ... YES") +else() + message(STATUS " Libraw will be compiled with example command-line programs ... NO") +endif() + +if(JASPER_FOUND) + message(STATUS " Libraw will be compiled with RedCine codec support ........... YES") +else() + message(STATUS " Libraw will be compiled with RedCine codec support ........... NO") +endif() + +if(ZLIB_FOUND) + message(STATUS " Libraw will be compiled with DNG deflate codec support ....... YES") +else() + message(STATUS " Libraw will be compiled with DNG deflate codec support ....... NO") +endif() + +if(JPEG8_FOUND) + message(STATUS " Libraw will be compiled with DNG lossy codec support ......... YES") +else() + message(STATUS " Libraw will be compiled with DNG lossy codec support ......... NO") +endif() + +if(RAWSPEED_SUPPORT_CAN_BE_COMPILED) + message(STATUS " Libraw will be compiled with RawSpeed support ................ YES") +else() + message(STATUS " Libraw will be compiled with RawSpeed support ................ NO") +endif() + +if(ENABLE_DCRAW_DEBUG) + message(STATUS " Libraw will be compiled with debug message from dcraw ........ YES") +else() + message(STATUS " Libraw will be compiled with debug message from dcraw ........ NO") +endif() + +if(ENABLE_X3FTOOLS) + message(STATUS " Libraw will be compiled with Foveon X3F support .............. YES") +else() + message(STATUS " Libraw will be compiled with Foveon X3F support .............. NO") +endif() + +if(ENABLE_6BY9RPI) + message(STATUS " Libraw will be compiled with Raspberry Pi RAW support ........ YES") +else() + message(STATUS " Libraw will be compiled with Raspberry Pi RAW support ........ NO") +endif() + +if(BUILD_SHARED_LIBS) + message(STATUS " Libraw will be compiled as a shared library") +else() + message(STATUS " Libraw will be compiled as a static library") +endif() + +message(STATUS "----------------------------------------------------------------------------------") +message(STATUS "") + +# -- Dedicated libraw target which does not support multi-threading --------------------------------------- + +if(RAW_LIB_VERSION_STRING VERSION_LESS 0.21) + set(libraw_LIB_SRCS ${LIBRAW_PATH}/internal/dcraw_common.cpp + ${LIBRAW_PATH}/internal/dcraw_fileio.cpp + ${LIBRAW_PATH}/internal/demosaic_packs.cpp + ${LIBRAW_PATH}/src/libraw_cxx.cpp + ${LIBRAW_PATH}/src/libraw_c_api.cpp + ${LIBRAW_PATH}/src/libraw_datastream.cpp + ) +else() + file(GLOB_RECURSE libraw_LIB_SRCS CONFIGURE_DEPENDS "${LIBRAW_PATH}/src/*.cpp") + + # Kill all warnings in LibRaw + set_source_files_properties( + ${libraw_LIB_SRCS} + PROPERTIES + COMPILE_FLAGS + "-w") + + # Exclude placeholder (stub) implementations + file(GLOB_RECURSE exclude_libraw_LIB_SRCS CONFIGURE_DEPENDS "${LIBRAW_PATH}/src/*_ph.cpp") + list(REMOVE_ITEM libraw_LIB_SRCS ${exclude_libraw_LIB_SRCS}) +endif() + +if(RAWSPEED_SUPPORT_CAN_BE_COMPILED) + set(libraw_LIB_SRCS ${libraw_LIB_SRCS} ${librawspeed_LIB_SRCS}) +endif() + + +add_library(raw ${libraw_LIB_SRCS}) +add_library(libraw::libraw ALIAS raw) +target_compile_definitions(raw PRIVATE LIBRAW_NOTHREADS) + +# Flag to export library symbols +if (WIN32) + target_compile_definitions(raw PRIVATE LIBRAW_BUILDLIB) +endif() + +# Static builds use LIBRAW_NODLL: +if(NOT BUILD_SHARED_LIBS) + target_compile_definitions(raw PUBLIC LIBRAW_NODLL) +endif() + +target_include_directories(raw + PUBLIC + $ + $) + +target_link_libraries(raw PUBLIC ${MATH_LIBRARY}) + +if(WIN32) + target_link_libraries(raw PUBLIC ws2_32) +endif() + +if(OpenMP_FOUND) + target_link_libraries(raw PUBLIC OpenMP::OpenMP_CXX) +endif() + +if(LCMS_SUPPORT_CAN_BE_COMPILED) + target_link_libraries(raw PUBLIC ${LCMS2_LIBRARIES}) +endif() + +if(ZLIB_FOUND) + target_link_libraries(raw PUBLIC ZLIB::ZLIB) +endif() + +if(JPEG8_FOUND) + target_link_libraries(raw PUBLIC JPEG::JPEG) +endif() + +if(JASPER_FOUND) + target_link_libraries(raw PUBLIC ${JASPER_LIBRARIES}) +endif() + +if(RAWSPEED_SUPPORT_CAN_BE_COMPILED) + target_link_libraries(raw PUBLIC ${LIBXML2_LIBRARIES}) +endif() + +set_target_properties(raw PROPERTIES VERSION ${RAW_LIB_SO_VERSION_STRING}) +set_target_properties(raw PROPERTIES SOVERSION ${RAW_LIB_SO_CUR_VERSION}) +set_target_properties(raw PROPERTIES OUTPUT_NAME "raw") +set_target_properties(raw PROPERTIES COMPILE_PDB_NAME "raw") + +# -- Dedicated libraw target to support multi-threading --------------------------------------------- + +set(libraw_r_LIB_SRCS ${libraw_LIB_SRCS}) + +add_library(raw_r ${libraw_r_LIB_SRCS}) +add_library(libraw::libraw_r ALIAS raw_r) + +# Flag to export library symbols +if(WIN32) + target_compile_definitions(raw_r PRIVATE LIBRAW_BUILDLIB) +endif() + +# Static builds use LIBRAW_NODLL: +if(NOT BUILD_SHARED_LIBS) + target_compile_definitions(raw_r PUBLIC LIBRAW_NODLL) +endif() + +# Always build position-independent code (PIC), even when building Libraw as a +# static library so that shared libraries can link against it, not just +# executables (PIC does not apply on Windows). +# Use set_target_properties() not append_target_property() here as +# POSITION_INDEPENDENT_CODE is a binary ON/OFF switch. +set_target_properties(raw PROPERTIES POSITION_INDEPENDENT_CODE ON) +set_target_properties(raw_r PROPERTIES POSITION_INDEPENDENT_CODE ON) + +target_link_libraries(raw_r PUBLIC ${MATH_LIBRARY}) +target_include_directories(raw_r + PUBLIC + $ + $) + +if(WIN32) + target_link_libraries(raw_r PUBLIC ws2_32) +endif() + +if(OpenMP_FOUND) + target_link_libraries(raw_r PUBLIC OpenMP::OpenMP_CXX) +endif() + +if(LCMS_SUPPORT_CAN_BE_COMPILED) + target_link_libraries(raw_r PUBLIC ${LCMS2_LIBRARIES}) +endif() + +if(ZLIB_FOUND) + target_link_libraries(raw_r PUBLIC ZLIB::ZLIB) +endif() + +if(JPEG8_FOUND) + target_link_libraries(raw_r PUBLIC JPEG::JPEG) +endif() + +if(JASPER_FOUND) + target_link_libraries(raw_r PUBLIC ${JASPER_LIBRARIES}) +endif() + +if(RAWSPEED_SUPPORT_CAN_BE_COMPILED) + target_link_libraries(raw_r PUBLIC ${LIBXML2_LIBRARIES} Threads::Threads) +endif() + +set_target_properties(raw_r PROPERTIES VERSION ${RAW_LIB_SO_VERSION_STRING}) +set_target_properties(raw_r PROPERTIES SOVERSION ${RAW_LIB_SO_CUR_VERSION}) +set_target_properties(raw_r PROPERTIES OUTPUT_NAME "raw_r") +set_target_properties(raw_r PROPERTIES COMPILE_PDB_NAME "raw_r") + +# -- Files to install ------------------------------------------------------------------------------------- +if (LIBRAW_INSTALL) + # Configure and install data file for packaging. + if(NOT WIN32) + configure_file(${CMAKE_CURRENT_SOURCE_DIR}/cmake/data/libraw.pc.cmake ${CMAKE_CURRENT_BINARY_DIR}/libraw.pc @ONLY) + install(FILES ${CMAKE_CURRENT_BINARY_DIR}/libraw.pc DESTINATION lib${LIB_SUFFIX}/pkgconfig) + + configure_file(${CMAKE_CURRENT_SOURCE_DIR}/cmake/data/libraw_r.pc.cmake ${CMAKE_CURRENT_BINARY_DIR}/libraw_r.pc @ONLY) + install(FILES ${CMAKE_CURRENT_BINARY_DIR}/libraw_r.pc DESTINATION lib${LIB_SUFFIX}/pkgconfig) + + configure_file(${CMAKE_CURRENT_SOURCE_DIR}/cmake/data/libraw.lsm.cmake ${CMAKE_CURRENT_BINARY_DIR}/libraw.lsm) + endif() + + # Install Shared header files. + install(FILES ${LIBRAW_PATH}/libraw/libraw.h + ${LIBRAW_PATH}/libraw/libraw_alloc.h + ${LIBRAW_PATH}/libraw/libraw_const.h + ${LIBRAW_PATH}/libraw/libraw_datastream.h + ${LIBRAW_PATH}/libraw/libraw_internal.h + ${LIBRAW_PATH}/libraw/libraw_types.h + ${LIBRAW_PATH}/libraw/libraw_version.h + ${CMAKE_CURRENT_BINARY_DIR}/libraw_config.h + DESTINATION include/libraw + COMPONENT Devel + ) + + # Install Shared binary files. + install(TARGETS raw raw_r + EXPORT ${PROJECT_NAME}Targets + RUNTIME DESTINATION bin + LIBRARY DESTINATION lib${LIB_SUFFIX} + ARCHIVE DESTINATION lib${LIB_SUFFIX} + ) + + if(NOT BUILD_SHARED_LIBS AND "${CMAKE_CXX_SIMULATE_ID}" STREQUAL "MSVC") + message("ClangCl does not support pdb generation with static libraries") + elseif(MSVC) + install(FILES ${PROJECT_BINARY_DIR}/raw.pdb ${PROJECT_BINARY_DIR}/raw_r.pdb + DESTINATION lib + CONFIGURATIONS Debug RelWithDebInfo + ) + endif() + + # Install find cmake script to the system for client applications. + install(FILES ${CMAKE_CURRENT_SOURCE_DIR}/cmake/modules/FindLibRaw.cmake + DESTINATION ${INSTALL_CMAKE_MODULE_PATH}) + + # Install doc data files. + if(NOT WIN32) + install(FILES ${LIBRAW_PATH}/COPYRIGHT + ${LIBRAW_PATH}/LICENSE.CDDL + ${LIBRAW_PATH}/LICENSE.LGPL + ${LIBRAW_PATH}/Changelog.txt + DESTINATION share/libraw + COMPONENT main + ) + endif() + + # Uninstall rules + if(LIBRAW_UNINSTALL_TARGET) + configure_file(${CMAKE_CURRENT_SOURCE_DIR}/cmake/modules/Uninstall.cmake ${CMAKE_BINARY_DIR}/cmake_uninstall.cmake COPYONLY) + add_custom_target(uninstall "${CMAKE_COMMAND}" -P "${CMAKE_BINARY_DIR}/cmake_uninstall.cmake") + endif() + + # Export the package for use from the build tree + export(TARGETS raw raw_r + NAMESPACE libraw:: FILE cmake/${PROJECT_NAME}Targets.cmake) + export(PACKAGE ${PROJECT_NAME}) + + include(CMakePackageConfigHelpers) + write_basic_package_version_file( + cmake/${PROJECT_NAME}ConfigVersion.cmake + VERSION ${PROJECT_VERSION} + COMPATIBILITY AnyNewerVersion) + + configure_package_config_file( + cmake/${PROJECT_NAME}Config.cmake.in + cmake/${PROJECT_NAME}Config.cmake + INSTALL_DESTINATION lib/cmake/) + + install(FILES + ${CMAKE_CURRENT_BINARY_DIR}/cmake/${PROJECT_NAME}Config.cmake + ${CMAKE_CURRENT_BINARY_DIR}/cmake/${PROJECT_NAME}ConfigVersion.cmake + DESTINATION lib/cmake/) + + install(EXPORT ${PROJECT_NAME}Targets + NAMESPACE libraw:: DESTINATION lib/cmake/) +endif(LIBRAW_INSTALL) + +# -- Compile LibRaw Examples -------------------------------------------------------------------------------- + +# add a small macro so that this is a bit cleaner +macro(LIBRAW_BUILD_SAMPLES) + set(_filename ${ARGV0}) + set(_rawlib ${ARGV1}) + string(REPLACE "." ";" _temp ${_filename}) + list(GET _temp 0 _target) + + set(${_target}_SRCS ${LIBRAW_PATH}/samples/${_filename}) + + add_executable(${_target} ${${_target}_SRCS}) + target_compile_options(${_target} PRIVATE -w) + + target_link_libraries(${_target} PRIVATE ${_rawlib}) + + if(${_rawlib} MATCHES "raw_r") + target_link_libraries(${_target} PUBLIC ${PTHREADS_LIBRARY}) + endif() + + install(TARGETS ${_target} + RUNTIME DESTINATION bin + LIBRARY DESTINATION lib${LIB_SUFFIX} + ARCHIVE DESTINATION lib${LIB_SUFFIX} + ) +endmacro(LIBRAW_BUILD_SAMPLES) + +if(ENABLE_EXAMPLES) + LIBRAW_BUILD_SAMPLES(simple_dcraw.cpp raw) + + if(EXISTS mem_image.cpp) + LIBRAW_BUILD_SAMPLES(mem_image.cpp raw) + else() + LIBRAW_BUILD_SAMPLES(mem_image_sample.cpp raw) + endif() + + LIBRAW_BUILD_SAMPLES(dcraw_emu.cpp raw) + LIBRAW_BUILD_SAMPLES(4channels.cpp raw) + LIBRAW_BUILD_SAMPLES(unprocessed_raw.cpp raw) + LIBRAW_BUILD_SAMPLES(raw-identify.cpp raw) + LIBRAW_BUILD_SAMPLES(multirender_test.cpp raw) + LIBRAW_BUILD_SAMPLES(postprocessing_benchmark.cpp raw) + + if(TARGET Threads::Threads) + if(WIN32) + LIBRAW_BUILD_SAMPLES(half_mt_win32.c raw_r) + else() + LIBRAW_BUILD_SAMPLES(dcraw_half.c raw_r) + LIBRAW_BUILD_SAMPLES(half_mt.c raw_r) + endif() + endif() +endif() diff --git a/src/external/LibRaw-cmake/INSTALL.CMAKE b/src/external/LibRaw-cmake/INSTALL.CMAKE new file mode 100644 index 000000000000..e000651d9cb9 --- /dev/null +++ b/src/external/LibRaw-cmake/INSTALL.CMAKE @@ -0,0 +1,62 @@ + +========= Installing LibRaw (CMake version) ========== + +I. Installation steps + +1. Unpack the distribution file: + + $ tar xzvf LibRaw-0.xx.yy.tar.gz + +2. Copy this LibRaw-cmake scripts in LibRaw-... folder + +3. Go to LibRaw folder and run ./configure and make: + + $ cd LibRaw-0.xx.yy + $ ./cmake [...optional args...] . + $ make + +4. install by run make install as root: + + $ sudo make install + + +II. ./cmake options + +-DENABLE_OPENMP=ON/OFF + + Enable/disable OpenMP support if compiler supports it. + OpenMP is enabled by default. + + +-DENABLE_LCMS=ON/OFF + + Enable/disable LCMS color engine support. If enabled, ./cmake will try to + find lcms library. Both LCMS-1.x and LCMS-2.x are supported + LCMS support is enabled by default + + +-DENABLE_EXAMPLES=ON/OFF + + Enables/disables examples compilation and installation. Enabled by default + + +-DENABLE_RAWSPEED=ON/OFF +-DRAWSPEED_RPATH=FOLDERNAME + + Enables/disables support of additional code from RawStudio project + You need to download RawSpeed source code to use this feature. + See README.RawSpeed.txt for details. + ./cmake will try to find RawSpeed code in: + + a) If folder is specified via -DRAWSPEED_RPATH=FOLDERNAME + command-line option, then only this folder will be checked. + + b) If no folder is specified in -DENABLE_RAWSPEED switch: + + ./RawSpeed (in LibRaw folder) + + + +-DENABLE_DCRAW_DEBUG=ON/OFF + + Enables/disables support of additional debug traces from dcraw operations. Disabled by default diff --git a/src/external/LibRaw-cmake/LICENSE b/src/external/LibRaw-cmake/LICENSE new file mode 100644 index 000000000000..4b417765f3a8 --- /dev/null +++ b/src/external/LibRaw-cmake/LICENSE @@ -0,0 +1,22 @@ +Redistribution and use in source and binary forms, with or without +modification, are permitted provided that the following conditions +are met: + +1. Redistributions of source code must retain the copyright + notice, this list of conditions and the following disclaimer. +2. Redistributions in binary form must reproduce the copyright + notice, this list of conditions and the following disclaimer in the + documentation and/or other materials provided with the distribution. +3. The name of the author may not be used to endorse or promote products + derived from this software without specific prior written permission. + +THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR +IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES +OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. +IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, +INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT +NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF +THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. diff --git a/src/external/LibRaw-cmake/README.md b/src/external/LibRaw-cmake/README.md new file mode 100644 index 000000000000..439e4dffa0b6 --- /dev/null +++ b/src/external/LibRaw-cmake/README.md @@ -0,0 +1,35 @@ +LibRaw-cmake +============ + +[![Build Status](https://travis-ci.org/LibRaw/LibRaw-cmake.svg?branch=master)](https://travis-ci.org/LibRaw/LibRaw-cmake) + +This is a separate repository for LibRaw CMake support scripts. +It is [unmaintained](https://github.com/LibRaw/LibRaw/issues/44#issuecomment-60344793) by the authors of LibRaw and relies solely on user contributions. +The current community-maintainer of this repository is [Maik Riechert](https://github.com/neothemachine). + +If you wish to contribute to it, please open an issue or submit a pull request in this repository. Do *not* submit issues or pull requests regarding CMake to the main [LibRaw repository](https://github.com/LibRaw/LibRaw). Also, try to keep CMake related discussions out of the [main forum](http://www.libraw.org/forum), instead use the issues for that. + +If you like to become a direct contributor with write permissions to this repository, please contact the [LibRaw authors](https://github.com/LibRaw). + +How to use +---------- +Just copy the contents of this repository into the root LibRaw folder and run cmake as usual. + +### Add as a submodule + +Add this repo and libraw as git submodules: + +`git submodule add https://github.com/LibRaw/LibRaw-cmake.git` + +`git submodule add https://github.com/LibRaw/LibRaw.git` + +In your CMakeLists.txt add + +```cmake +add_subdirectory(LibRaw-cmake) +target_link_libraries(ProjectName PRIVATE libraw::libraw) +``` + +Set the `LIBRAW_PATH` CMake variable to point to the **LibRaw** directory: + +`cmake -DLIBRAW_PATH=./LibRaw/` \ No newline at end of file diff --git a/src/external/LibRaw-cmake/cmake/data/libraw.lsm.cmake b/src/external/LibRaw-cmake/cmake/data/libraw.lsm.cmake new file mode 100644 index 000000000000..45dfb45b32d6 --- /dev/null +++ b/src/external/LibRaw-cmake/cmake/data/libraw.lsm.cmake @@ -0,0 +1,13 @@ +Begin4 +Title: ${PROJECT_NAME} +Version: ${RAW_LIB_VERSION_STRING} +Entered-date: 2013-09-08 +Description: Raw image decoder library +Keywords: Raw image digital camera demosaicing decoding +Author: Copyright 2008-2013 LibRaw LLC (info@libraw.org) +Maintained-by: +Primary-site: http://www.libraw.org +Original-site: +Platforms: Linux and other Unices, MacOs-X, Win32 +Copying-policy: GPL +End diff --git a/src/external/LibRaw-cmake/cmake/data/libraw.pc.cmake b/src/external/LibRaw-cmake/cmake/data/libraw.pc.cmake new file mode 100644 index 000000000000..aede5f267c40 --- /dev/null +++ b/src/external/LibRaw-cmake/cmake/data/libraw.pc.cmake @@ -0,0 +1,12 @@ +prefix=@CMAKE_INSTALL_PREFIX@ +exec_prefix=${prefix} +libdir=${prefix}/lib@LIB_SUFFIX@ +includedir=${prefix}/include/libraw + +Name: @PROJECT_NAME@ +Description: @PROJECT_NAME@ - Raw image decoder library (non-thread-safe) +URL: http://www.libraw.org +Requires: +Version: @RAW_LIB_VERSION_STRING@ +Libs: -L${libdir} -lraw +Cflags: -I${includedir} diff --git a/src/external/LibRaw-cmake/cmake/data/libraw_config.h.cmake b/src/external/LibRaw-cmake/cmake/data/libraw_config.h.cmake new file mode 100644 index 000000000000..4e4b3147f169 --- /dev/null +++ b/src/external/LibRaw-cmake/cmake/data/libraw_config.h.cmake @@ -0,0 +1,50 @@ +/* -*- C++ -*- + * File: libraw_version.h + * Copyright 2008-2013 LibRaw LLC (info@libraw.org) + * Created: Mon Sept 8, 2008 + * + * LibRaw C++ interface + * + +LibRaw is free software; you can redistribute it and/or modify +it under the terms of the one of two licenses as you choose: + +1. GNU LESSER GENERAL PUBLIC LICENSE version 2.1 +(See the file LICENSE.LGPL provided in LibRaw distribution archive for details). + +2. COMMON DEVELOPMENT AND DISTRIBUTION LICENSE (CDDL) Version 1.0 +(See the file LICENSE.CDDL provided in LibRaw distribution archive for details). + + */ + +#ifndef __LIBRAW_CONFIG_H +#define __LIBRAW_CONFIG_H + +/* Define to 1 if LibRaw have been compiled with DNG deflate codec support */ +#cmakedefine LIBRAW_USE_DNGDEFLATECODEC 1 + +/* Define to 1 if LibRaw have been compiled with DNG lossy codec support */ +#cmakedefine LIBRAW_USE_DNGLOSSYCODEC 1 + +/* Define to 1 if LibRaw have been compiled with OpenMP support */ +#cmakedefine LIBRAW_USE_OPENMP 1 + +/* Define to 1 if LibRaw have been compiled with LCMS support */ +#cmakedefine LIBRAW_USE_LCMS 1 + +/* Define to 1 if LibRaw have been compiled with RedCine codec support */ +#cmakedefine LIBRAW_USE_REDCINECODEC 1 + +/* Define to 1 if LibRaw have been compiled with RawSpeed codec support */ +#cmakedefine LIBRAW_USE_RAWSPEED 1 + +/* Define to 1 if LibRaw have been compiled with debug message from dcraw */ +#cmakedefine LIBRAW_USE_DCRAW_DEBUG 1 + +/* Define to 1 if LibRaw have been compiled with Foveon X3F support */ +#cmakedefine LIBRAW_USE_X3FTOOLS 1 + +/* Define to 1 if LibRaw have been compiled with Raspberry Pi RAW support */ +#cmakedefine LIBRAW_USE_6BY9RPI 1 + +#endif diff --git a/src/external/LibRaw-cmake/cmake/data/libraw_r.pc.cmake b/src/external/LibRaw-cmake/cmake/data/libraw_r.pc.cmake new file mode 100644 index 000000000000..16134e84a83e --- /dev/null +++ b/src/external/LibRaw-cmake/cmake/data/libraw_r.pc.cmake @@ -0,0 +1,12 @@ +prefix=@CMAKE_INSTALL_PREFIX@ +exec_prefix=${prefix} +libdir=${prefix}/lib@LIB_SUFFIX@ +includedir=${prefix}/include/libraw + +Name: @PROJECT_NAME@ +Description: @PROJECT_NAME@ - Raw image decoder library (thread-safe) +URL: http://www.libraw.org +Requires: +Version: @RAW_LIB_VERSION_STRING@ +Libs: -L${libdir} -lraw_r +Cflags: -I${includedir} diff --git a/src/external/LibRaw-cmake/cmake/librawConfig.cmake.in b/src/external/LibRaw-cmake/cmake/librawConfig.cmake.in new file mode 100644 index 000000000000..b1b58d8d63a1 --- /dev/null +++ b/src/external/LibRaw-cmake/cmake/librawConfig.cmake.in @@ -0,0 +1,35 @@ +include(CMakeFindDependencyMacro) + +if(@JASPER_FOUND@) + find_dependency(Jasper) +endif() + +if(@JPEG_FOUND@) + find_dependency(JPEG) +endif() +if(@ZLIB_FOUND@) + find_dependency(ZLIB) +endif() + +if(@LCMS_SUPPORT_CAN_BE_COMPILED@) + if(@LCMS2_FOUND@) + find_dependency(LCMS2) + elseif(@LCMS_FOUND@) + find_dependency(LCMS) + endif() +endif() + +if(@ENABLE_RAWSPEED@) + find_dependency(LibXml2) + find_dependency(Threads) +endif() + +if(@ENABLE_OPENMP@) + find_dependency(OpenMP) +endif() + + +@PACKAGE_INIT@ + +include("${CMAKE_CURRENT_LIST_DIR}/@PROJECT_NAME@Targets.cmake") +check_required_components("@PROJECT_NAME@") diff --git a/src/external/LibRaw-cmake/cmake/modules/FindLCMS.cmake b/src/external/LibRaw-cmake/cmake/modules/FindLCMS.cmake new file mode 100644 index 000000000000..d82d82e62285 --- /dev/null +++ b/src/external/LibRaw-cmake/cmake/modules/FindLCMS.cmake @@ -0,0 +1,60 @@ +# - Find LCMS +# 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_DOT_VERSION, The version number of the LCMS library, e.g. "1.19" +# LCMS_VERSION, Similar to LCMS_DOT_VERSION, but without the dots, e.g. "119" +# 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.10) + +# Copyright (c) 2008, Adrian Page, +# Copyright (c) 2009, Cyrille Berger, +# +# Redistribution and use is allowed according to the terms of the BSD license. +# For details see the accompanying LICENSE file. + + +# use pkg-config to get the directories and then use these values +# in the FIND_PATH() and FIND_LIBRARY() calls +if(NOT WIN32) + find_package(PkgConfig) + pkg_check_modules(PC_LCMS lcms) + set(LCMS_DEFINITIONS ${PC_LCMS_CFLAGS_OTHER}) +endif(NOT WIN32) + +find_path(LCMS_INCLUDE_DIR lcms.h + HINTS + ${PC_LCMS_INCLUDEDIR} + ${PC_LCMS_INCLUDE_DIRS} + PATH_SUFFIXES lcms liblcms1 +) + +find_library(LCMS_LIBRARIES NAMES lcms liblcms lcms-1 liblcms-1 + HINTS + ${PC_LCMS_LIBDIR} + ${PC_LCMS_LIBRARY_DIRS} + PATH_SUFFIXES lcms +) + +# Store the LCMS version number in the cache, so we don't have to search every time 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}) + string(SUBSTRING ${_LCMS_VERSION} 0 1 LCMS_MAJOR_VERSION) + string(SUBSTRING ${_LCMS_VERSION} 1 2 LCMS_MINOR_VERSION) + endif(LCMS_VERSION_MATCH) + set(LCMS_VERSION "${LCMS_MAJOR_VERSION}${LCMS_MINOR_VERSION}" CACHE STRING "Version number of lcms" FORCE) + set(LCMS_DOT_VERSION "${LCMS_MAJOR_VERSION}.${LCMS_MINOR_VERSION}" CACHE STRING "Version number of lcms split into components" 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_DOT_VERSION ) + +mark_as_advanced(LCMS_INCLUDE_DIR LCMS_LIBRARIES LCMS_VERSION) + diff --git a/src/external/LibRaw-cmake/cmake/modules/FindLCMS2.cmake b/src/external/LibRaw-cmake/cmake/modules/FindLCMS2.cmake new file mode 100644 index 000000000000..4e3e482d8fc8 --- /dev/null +++ b/src/external/LibRaw-cmake/cmake/modules/FindLCMS2.cmake @@ -0,0 +1,72 @@ +# - Find LCMS2 +# Find the LCMS2 includes and library +# This module defines +# LCMS2_INCLUDE_DIR, where to find lcms.h +# LCMS2_LIBRARIES, the libraries needed to use LCMS2. +# LCMS2_VERSION, The value of LCMS_VERSION defined in lcms.h +# LCMS2_FOUND, If false, do not try to use LCMS2. + + +# Copyright (c) 2008, Adrian Page, +# Copyright (c) 2009, Cyrille Berger, +# +# Redistribution and use is allowed according to the terms of the BSD license. +# For details see the accompanying LICENSE file. + + +# use pkg-config to get the directories and then use these values +# in the FIND_PATH() and FIND_LIBRARY() calls +if(NOT WIN32) + find_package(PkgConfig) + pkg_check_modules(PC_LCMS2 lcms2) + set(LCMS2_DEFINITIONS ${PC_LCMS2_CFLAGS_OTHER}) +endif(NOT WIN32) + +find_path(LCMS2_INCLUDE_DIR lcms2.h + PATHS + ${PC_LCMS2_INCLUDEDIR} + ${PC_LCMS2_INCLUDE_DIRS} + PATH_SUFFIXES lcms2 liblcms2 +) + +find_library(LCMS2_LIBRARIES NAMES lcms2 liblcms2 lcms-2 liblcms-2 + PATHS + ${PC_LCMS2_LIBDIR} + ${PC_LCMS2_LIBRARY_DIRS} + PATH_SUFFIXES lcms2 +) + +if(LCMS2_INCLUDE_DIR AND LCMS2_LIBRARIES) + set(LCMS2_FOUND TRUE) +else(LCMS2_INCLUDE_DIR AND LCMS2_LIBRARIES) + set(LCMS2_FOUND FALSE) +endif(LCMS2_INCLUDE_DIR AND LCMS2_LIBRARIES) + +if(LCMS2_FOUND) + file(READ ${LCMS2_INCLUDE_DIR}/lcms2.h LCMS2_VERSION_CONTENT) + string(REGEX MATCH "#define LCMS_VERSION[ ]*[0-9]*\n" LCMS2_VERSION_MATCH ${LCMS2_VERSION_CONTENT}) + if(LCMS2_VERSION_MATCH) + string(REGEX REPLACE "#define LCMS_VERSION[ ]*([0-9]*)\n" "\\1" LCMS2_VERSION ${LCMS2_VERSION_MATCH}) + if(NOT LCMS2_FIND_QUIETLY) + string(SUBSTRING ${LCMS2_VERSION} 0 1 LCMS2_MAJOR_VERSION) + string(SUBSTRING ${LCMS2_VERSION} 1 2 LCMS2_MINOR_VERSION) + message(STATUS "Found lcms version ${LCMS2_MAJOR_VERSION}.${LCMS2_MINOR_VERSION}, ${LCMS2_LIBRARIES}") + endif(NOT LCMS2_FIND_QUIETLY) + else(LCMS2_VERSION_MATCH) + if(NOT LCMS2_FIND_QUIETLY) + message(STATUS "Found lcms2 but failed to find version ${LCMS2_LIBRARIES}") + endif(NOT LCMS2_FIND_QUIETLY) + set(LCMS2_VERSION NOTFOUND) + endif(LCMS2_VERSION_MATCH) +else(LCMS2_FOUND) + if(NOT LCMS2_FIND_QUIETLY) + if(LCMS2_FIND_REQUIRED) + message(FATAL_ERROR "Required package lcms2 NOT found") + else(LCMS2_FIND_REQUIRED) + message(STATUS "lcms2 NOT found") + endif(LCMS2_FIND_REQUIRED) + endif(NOT LCMS2_FIND_QUIETLY) +endif(LCMS2_FOUND) + +mark_as_advanced(LCMS2_INCLUDE_DIR LCMS2_LIBRARIES LCMS2_VERSION) + diff --git a/src/external/LibRaw-cmake/cmake/modules/FindLibRaw.cmake b/src/external/LibRaw-cmake/cmake/modules/FindLibRaw.cmake new file mode 100644 index 000000000000..2ce71406bc6f --- /dev/null +++ b/src/external/LibRaw-cmake/cmake/modules/FindLibRaw.cmake @@ -0,0 +1,96 @@ +# - Find LibRaw +# Find the LibRaw library +# 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) +# +# Copyright (c) 2013, Pino Toscano +# Copyright (c) 2013, Gilles Caulier +# +# Redistribution and use is allowed according to the terms of the BSD license. +# For details see the accompanying LICENSE file. + +FIND_PACKAGE(PkgConfig) + +IF(PKG_CONFIG_FOUND) + PKG_CHECK_MODULES(PC_LIBRAW libraw) + SET(LibRaw_DEFINITIONS ${PC_LIBRAW_CFLAGS_OTHER}) + + PKG_CHECK_MODULES(PC_LIBRAW_R libraw_r) + SET(LibRaw_r_DEFINITIONS ${PC_LIBRAW_R_CFLAGS_OTHER}) +ENDIF() + +FIND_PATH(LibRaw_INCLUDE_DIR libraw.h + HINTS + ${PC_LIBRAW_INCLUDEDIR} + ${PC_LibRaw_INCLUDE_DIRS} + PATH_SUFFIXES libraw + ) + +FIND_LIBRARY(LibRaw_LIBRARY_RELEASE NAMES raw + HINTS + ${PC_LIBRAW_LIBDIR} + ${PC_LIBRAW_LIBRARY_DIRS} + ) + +FIND_LIBRARY(LibRaw_LIBRARY_DEBUG NAMES rawd + HINTS + ${PC_LIBRAW_LIBDIR} + ${PC_LIBRAW_LIBRARY_DIRS} + ) + +include(SelectLibraryConfigurations) +select_library_configurations(LibRaw) + +FIND_LIBRARY(LibRaw_r_LIBRARY_RELEASE NAMES raw_r + HINTS + ${PC_LIBRAW_R_LIBDIR} + ${PC_LIBRAW_R_LIBRARY_DIRS} + ) + +FIND_LIBRARY(LibRaw_r_LIBRARY_DEBUG NAMES raw_rd + HINTS + ${PC_LIBRAW_R_LIBDIR} + ${PC_LIBRAW_R_LIBRARY_DIRS} + ) + +select_library_configurations(LibRaw_r) + +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 + ) diff --git a/src/external/LibRaw-cmake/cmake/modules/MacroBoolTo01.cmake b/src/external/LibRaw-cmake/cmake/modules/MacroBoolTo01.cmake new file mode 100644 index 000000000000..a6f2fd8a3c13 --- /dev/null +++ b/src/external/LibRaw-cmake/cmake/modules/MacroBoolTo01.cmake @@ -0,0 +1,20 @@ +# MACRO_BOOL_TO_01( VAR RESULT0 ... RESULTN ) +# This macro evaluates its first argument +# and sets all the given vaiables either to 0 or 1 +# depending on the value of the first one + +# Copyright (c) 2006, Alexander Neundorf, +# +# Redistribution and use is allowed according to the terms of the BSD license. +# For details see the accompanying LICENSE file. + + +MACRO(MACRO_BOOL_TO_01 FOUND_VAR ) + FOREACH (_current_VAR ${ARGN}) + IF(${FOUND_VAR}) + SET(${_current_VAR} 1) + ELSE(${FOUND_VAR}) + SET(${_current_VAR} 0) + ENDIF(${FOUND_VAR}) + ENDFOREACH(_current_VAR) +ENDMACRO(MACRO_BOOL_TO_01) diff --git a/src/external/LibRaw-cmake/cmake/modules/MacroLogFeature.cmake b/src/external/LibRaw-cmake/cmake/modules/MacroLogFeature.cmake new file mode 100644 index 000000000000..5917a094e7e7 --- /dev/null +++ b/src/external/LibRaw-cmake/cmake/modules/MacroLogFeature.cmake @@ -0,0 +1,159 @@ +# This file defines the Feature Logging macros. +# +# MACRO_LOG_FEATURE(VAR FEATURE DESCRIPTION URL [REQUIRED [MIN_VERSION [COMMENTS]]]) +# Logs the information so that it can be displayed at the end +# of the configure run +# VAR : TRUE or FALSE, indicating whether the feature is supported +# FEATURE: name of the feature, e.g. "libjpeg" +# DESCRIPTION: description what this feature provides +# URL: home page +# REQUIRED: TRUE or FALSE, indicating whether the feature is required +# MIN_VERSION: minimum version number. empty string if unneeded +# COMMENTS: More info you may want to provide. empty string if unnecessary +# +# MACRO_DISPLAY_FEATURE_LOG() +# Call this to display the collected results. +# Exits CMake with a FATAL error message if a required feature is missing +# +# Example: +# +# INCLUDE(MacroLogFeature) +# +# FIND_PACKAGE(JPEG) +# MACRO_LOG_FEATURE(JPEG_FOUND "libjpeg" "Support JPEG images" "http://www.ijg.org" TRUE "3.2a" "") +# ... +# MACRO_DISPLAY_FEATURE_LOG() + +# Copyright (c) 2006, Alexander Neundorf, +# Copyright (c) 2006, Allen Winter, +# Copyright (c) 2009, Sebastian Trueg, +# +# Redistribution and use is allowed according to the terms of the BSD license. +# For details see the accompanying LICENSE file. + +IF (NOT _macroLogFeatureAlreadyIncluded) + SET(_file ${CMAKE_BINARY_DIR}/MissingRequirements.txt) + IF (EXISTS ${_file}) + FILE(REMOVE ${_file}) + ENDIF (EXISTS ${_file}) + + SET(_file ${CMAKE_BINARY_DIR}/EnabledFeatures.txt) + IF (EXISTS ${_file}) + FILE(REMOVE ${_file}) + ENDIF (EXISTS ${_file}) + + SET(_file ${CMAKE_BINARY_DIR}/DisabledFeatures.txt) + IF (EXISTS ${_file}) + FILE(REMOVE ${_file}) + ENDIF (EXISTS ${_file}) + + SET(_macroLogFeatureAlreadyIncluded TRUE) + + INCLUDE(FeatureSummary) + +ENDIF (NOT _macroLogFeatureAlreadyIncluded) + + +MACRO(MACRO_LOG_FEATURE _var _package _description _url ) # _required _minvers _comments) + + STRING(TOUPPER "${ARGV4}" _required) + SET(_minvers "${ARGV5}") + SET(_comments "${ARGV6}") + + IF (${_var}) + SET(_LOGFILENAME ${CMAKE_BINARY_DIR}/EnabledFeatures.txt) + ELSE (${_var}) + IF ("${_required}" STREQUAL "TRUE") + SET(_LOGFILENAME ${CMAKE_BINARY_DIR}/MissingRequirements.txt) + ELSE ("${_required}" STREQUAL "TRUE") + SET(_LOGFILENAME ${CMAKE_BINARY_DIR}/DisabledFeatures.txt) + ENDIF ("${_required}" STREQUAL "TRUE") + ENDIF (${_var}) + + SET(_logtext " * ${_package}") + + IF (NOT ${_var}) + IF (${_minvers} MATCHES ".*") + SET(_logtext "${_logtext} (${_minvers} or higher)") + ENDIF (${_minvers} MATCHES ".*") + SET(_logtext "${_logtext} <${_url}>\n ") + ELSE (NOT ${_var}) + SET(_logtext "${_logtext} - ") + ENDIF (NOT ${_var}) + + SET(_logtext "${_logtext}${_description}") + + IF (NOT ${_var}) + IF (${_comments} MATCHES ".*") + SET(_logtext "${_logtext}\n ${_comments}") + ENDIF (${_comments} MATCHES ".*") +# SET(_logtext "${_logtext}\n") #double-space missing features? + ENDIF (NOT ${_var}) + + FILE(APPEND "${_LOGFILENAME}" "${_logtext}\n") + + IF(COMMAND SET_PACKAGE_PROPERTIES) + SET_PACKAGE_PROPERTIES("${_package}" PROPERTIES URL "${_url}" DESCRIPTION "\"${_description}\"") + ELSEIF(COMMAND SET_PACKAGE_INFO) # in FeatureSummary.cmake since CMake 2.8.3 + SET_PACKAGE_INFO("${_package}" "\"${_description}\"" "${_url}" "\"${_comments}\"") + ENDIF(COMMAND SET_PACKAGE_PROPERTIES) + +ENDMACRO(MACRO_LOG_FEATURE) + + +MACRO(MACRO_DISPLAY_FEATURE_LOG) + IF(COMMAND FEATURE_SUMMARY) # in FeatureSummary.cmake since CMake 2.8.3 + FEATURE_SUMMARY(FILENAME ${CMAKE_CURRENT_BINARY_DIR}/FindPackageLog.txt + WHAT ALL) + ENDIF(COMMAND FEATURE_SUMMARY) + + SET(_missingFile ${CMAKE_BINARY_DIR}/MissingRequirements.txt) + SET(_enabledFile ${CMAKE_BINARY_DIR}/EnabledFeatures.txt) + SET(_disabledFile ${CMAKE_BINARY_DIR}/DisabledFeatures.txt) + + IF (EXISTS ${_missingFile} OR EXISTS ${_enabledFile} OR EXISTS ${_disabledFile}) + SET(_printSummary TRUE) + ENDIF (EXISTS ${_missingFile} OR EXISTS ${_enabledFile} OR EXISTS ${_disabledFile}) + + IF(_printSummary) + SET(_missingDeps 0) + IF (EXISTS ${_enabledFile}) + FILE(READ ${_enabledFile} _enabled) + FILE(REMOVE ${_enabledFile}) + SET(_summary "${_summary}\n-----------------------------------------------------------------------------\n-- The following external packages were located on your system.\n-- This installation will have the extra features provided by these packages.\n-----------------------------------------------------------------------------\n${_enabled}") + ENDIF (EXISTS ${_enabledFile}) + + + IF (EXISTS ${_disabledFile}) + SET(_missingDeps 1) + FILE(READ ${_disabledFile} _disabled) + FILE(REMOVE ${_disabledFile}) + SET(_summary "${_summary}\n-----------------------------------------------------------------------------\n-- The following OPTIONAL packages could NOT be located on your system.\n-- Consider installing them to enable more features from this software.\n-----------------------------------------------------------------------------\n${_disabled}") + ENDIF (EXISTS ${_disabledFile}) + + + IF (EXISTS ${_missingFile}) + SET(_missingDeps 1) + FILE(READ ${_missingFile} _requirements) + SET(_summary "${_summary}\n-----------------------------------------------------------------------------\n-- The following REQUIRED packages could NOT be located on your system.\n-- You must install these packages before continuing.\n-----------------------------------------------------------------------------\n${_requirements}") + FILE(REMOVE ${_missingFile}) + SET(_haveMissingReq 1) + ENDIF (EXISTS ${_missingFile}) + + + IF (NOT ${_missingDeps}) + SET(_summary "${_summary}\n-----------------------------------------------------------------------------\n-- Congratulations! All external packages have been found.") + ENDIF (NOT ${_missingDeps}) + + + MESSAGE(${_summary}) + MESSAGE("-----------------------------------------------------------------------------\n") + + + IF(_haveMissingReq) + MESSAGE(FATAL_ERROR "Exiting: Missing Requirements") + ENDIF(_haveMissingReq) + + ENDIF(_printSummary) + +ENDMACRO(MACRO_DISPLAY_FEATURE_LOG) diff --git a/src/external/LibRaw-cmake/cmake/modules/MacroOptionalFindPackage.cmake b/src/external/LibRaw-cmake/cmake/modules/MacroOptionalFindPackage.cmake new file mode 100644 index 000000000000..05fa1396d47e --- /dev/null +++ b/src/external/LibRaw-cmake/cmake/modules/MacroOptionalFindPackage.cmake @@ -0,0 +1,48 @@ +# - MACRO_OPTIONAL_FIND_PACKAGE() combines FIND_PACKAGE() with an OPTION() +# MACRO_OPTIONAL_FIND_PACKAGE( [QUIT] ) +# This macro is a combination of OPTION() and FIND_PACKAGE(), it +# works like FIND_PACKAGE(), but additionally it automatically creates +# an option name WITH_, which can be disabled via the cmake GUI. +# or via -DWITH_=OFF +# The standard _FOUND variables can be used in the same way +# as when using the normal FIND_PACKAGE() + +# Copyright (c) 2006-2010 Alexander Neundorf, +# +# Redistribution and use is allowed according to the terms of the BSD license. +# For details see the accompanying LICENSE file. + +# This is just a helper macro to set a bunch of variables empty. +# We don't know whether the package uses UPPERCASENAME or CamelCaseName, so we try both: +macro(_MOFP_SET_EMPTY_IF_DEFINED _name _var) + if(DEFINED ${_name}_${_var}) + set(${_name}_${_var} "") + endif(DEFINED ${_name}_${_var}) + + string(TOUPPER ${_name} _nameUpper) + if(DEFINED ${_nameUpper}_${_var}) + set(${_nameUpper}_${_var} "") + endif(DEFINED ${_nameUpper}_${_var}) +endmacro(_MOFP_SET_EMPTY_IF_DEFINED _package _var) + + +macro (MACRO_OPTIONAL_FIND_PACKAGE _name ) + option(WITH_${_name} "Search for ${_name} package" ON) + if (WITH_${_name}) + find_package(${_name} ${ARGN}) + else (WITH_${_name}) + string(TOUPPER ${_name} _nameUpper) + set(${_name}_FOUND FALSE) + set(${_nameUpper}_FOUND FALSE) + + _mofp_set_empty_if_defined(${_name} INCLUDE_DIRS) + _mofp_set_empty_if_defined(${_name} INCLUDE_DIR) + _mofp_set_empty_if_defined(${_name} INCLUDES) + _mofp_set_empty_if_defined(${_name} LIBRARY) + _mofp_set_empty_if_defined(${_name} LIBRARIES) + _mofp_set_empty_if_defined(${_name} LIBS) + _mofp_set_empty_if_defined(${_name} FLAGS) + _mofp_set_empty_if_defined(${_name} DEFINITIONS) + endif (WITH_${_name}) +endmacro (MACRO_OPTIONAL_FIND_PACKAGE) + diff --git a/src/external/LibRaw-cmake/cmake/modules/Uninstall.cmake b/src/external/LibRaw-cmake/cmake/modules/Uninstall.cmake new file mode 100644 index 000000000000..36dd9ba8e645 --- /dev/null +++ b/src/external/LibRaw-cmake/cmake/modules/Uninstall.cmake @@ -0,0 +1,22 @@ +IF(NOT EXISTS "@CMAKE_BINARY_DIR@/install_manifest.txt") + MESSAGE(FATAL_ERROR "Cannot find install manifest: \"@CMAKE_BINARY_DIR@/install_manifest.txt\"") +ENDIF(NOT EXISTS "@CMAKE_BINARY_DIR@/install_manifest.txt") + +FILE(READ "@CMAKE_BINARY_DIR@/install_manifest.txt" files) +STRING(REGEX REPLACE "\n" ";" files "${files}") +FOREACH(file ${files}) + MESSAGE(STATUS "Uninstalling \"${file}\"") + IF(EXISTS "${file}") + EXEC_PROGRAM( + "@CMAKE_COMMAND@" ARGS "-E remove \"${file}\"" + OUTPUT_VARIABLE rm_out + RETURN_VALUE rm_retval + ) + IF("${rm_retval}" STREQUAL 0) + ELSE("${rm_retval}" STREQUAL 0) + MESSAGE(FATAL_ERROR "Problem when removing \"${file}\"") + ENDIF("${rm_retval}" STREQUAL 0) + ELSE(EXISTS "${file}") + MESSAGE(STATUS "File \"${file}\" does not exist.") + ENDIF(EXISTS "${file}") +ENDFOREACH(file)