├── .gitattributes ├── .gitignore ├── cmake ├── data │ ├── libraw.pc.cmake │ ├── libraw_r.pc.cmake │ └── libraw_config.h.cmake ├── modules │ ├── MacroBoolTo01.cmake │ ├── Uninstall.cmake │ ├── MacroOptionalFindPackage.cmake │ ├── FindLCMS.cmake │ ├── FindLCMS2.cmake │ ├── FindLibRaw.cmake │ └── MacroLogFeature.cmake └── librawConfig.cmake.in ├── .github └── workflows │ └── ci.yml ├── LICENSE ├── README.md ├── INSTALL.CMAKE └── CMakeLists.txt /.gitattributes: -------------------------------------------------------------------------------- 1 | * text=auto 2 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | /.project 2 | build -------------------------------------------------------------------------------- /cmake/data/libraw.pc.cmake: -------------------------------------------------------------------------------- 1 | prefix=@CMAKE_INSTALL_PREFIX@ 2 | exec_prefix=${prefix} 3 | libdir=${exec_prefix}/@CMAKE_INSTALL_LIBDIR@ 4 | includedir=${prefix}/@CMAKE_INSTALL_INCLUDEDIR@ 5 | 6 | Name: @PROJECT_NAME@ 7 | Description: Raw image decoder library (non-thread-safe) 8 | URL: http://www.libraw.org 9 | Requires: 10 | Version: @RAW_LIB_VERSION_STRING@ 11 | Libs: -L${libdir} -lraw 12 | Cflags: -I${includedir} -I${includedir}/libraw 13 | Libs.private: @LIBRAW_PC_LIBS_PRIVATE@ 14 | Requires.private: @LIBRAW_PC_REQUIRES_PRIVATE@ 15 | -------------------------------------------------------------------------------- /cmake/data/libraw_r.pc.cmake: -------------------------------------------------------------------------------- 1 | prefix=@CMAKE_INSTALL_PREFIX@ 2 | exec_prefix=${prefix} 3 | libdir=${exec_prefix}/@CMAKE_INSTALL_LIBDIR@ 4 | includedir=${prefix}/@CMAKE_INSTALL_INCLUDEDIR@ 5 | 6 | Name: @PROJECT_NAME@ 7 | Description: Raw image decoder library (thread-safe) 8 | URL: http://www.libraw.org 9 | Requires: 10 | Version: @RAW_LIB_VERSION_STRING@ 11 | Libs: -L${libdir} -lraw_r 12 | Cflags: -I${includedir} -I${includedir}/libraw 13 | Libs.private: @LIBRAW_PC_LIBS_PRIVATE@ 14 | Requires.private: @LIBRAW_PC_REQUIRES_PRIVATE@ 15 | -------------------------------------------------------------------------------- /cmake/modules/MacroBoolTo01.cmake: -------------------------------------------------------------------------------- 1 | # MACRO_BOOL_TO_01( VAR RESULT0 ... RESULTN ) 2 | # This macro evaluates its first argument 3 | # and sets all the given vaiables either to 0 or 1 4 | # depending on the value of the first one 5 | 6 | # Copyright (c) 2006, Alexander Neundorf, 7 | # 8 | # Redistribution and use is allowed according to the terms of the BSD license. 9 | # For details see the accompanying LICENSE file. 10 | 11 | 12 | MACRO(MACRO_BOOL_TO_01 FOUND_VAR ) 13 | FOREACH (_current_VAR ${ARGN}) 14 | IF(${FOUND_VAR}) 15 | SET(${_current_VAR} 1) 16 | ELSE(${FOUND_VAR}) 17 | SET(${_current_VAR} 0) 18 | ENDIF(${FOUND_VAR}) 19 | ENDFOREACH(_current_VAR) 20 | ENDMACRO(MACRO_BOOL_TO_01) 21 | -------------------------------------------------------------------------------- /cmake/librawConfig.cmake.in: -------------------------------------------------------------------------------- 1 | include(CMakeFindDependencyMacro) 2 | 3 | if(@JASPER_FOUND@) 4 | find_dependency(Jasper) 5 | endif() 6 | 7 | if(@JPEG_FOUND@) 8 | find_dependency(JPEG) 9 | endif() 10 | if(@ZLIB_FOUND@) 11 | find_dependency(ZLIB) 12 | endif() 13 | 14 | if(@LCMS_SUPPORT_CAN_BE_COMPILED@) 15 | if(@LCMS2_FOUND@) 16 | find_dependency(LCMS2) 17 | elseif(@LCMS_FOUND@) 18 | find_dependency(LCMS) 19 | endif() 20 | endif() 21 | 22 | if(@ENABLE_RAWSPEED@) 23 | find_dependency(LibXml2) 24 | find_dependency(Threads) 25 | endif() 26 | 27 | if(@ENABLE_OPENMP@) 28 | find_dependency(OpenMP) 29 | endif() 30 | 31 | 32 | @PACKAGE_INIT@ 33 | 34 | include("${CMAKE_CURRENT_LIST_DIR}/@PROJECT_NAME@Targets.cmake") 35 | check_required_components("@PROJECT_NAME@") 36 | -------------------------------------------------------------------------------- /.github/workflows/ci.yml: -------------------------------------------------------------------------------- 1 | name: CI 2 | 3 | on: [push, pull_request, workflow_dispatch] 4 | 5 | env: 6 | LIBRAW_GIT: https://github.com/LibRaw/LibRaw.git 7 | 8 | defaults: 9 | run: 10 | shell: bash 11 | 12 | jobs: 13 | build: 14 | strategy: 15 | fail-fast: false 16 | matrix: 17 | os: [ubuntu-latest, macos-latest, windows-latest] 18 | libraw_ref: ['0.20.2', 'master'] 19 | 20 | runs-on: ${{ matrix.os }} 21 | 22 | steps: 23 | - uses: actions/checkout@v2 24 | 25 | - run: git clone $LIBRAW_GIT -b ${{ matrix.libraw_ref }} 26 | name: Clone LibRaw 27 | 28 | - run: | 29 | mkdir build 30 | cd build 31 | cmake -DENABLE_OPENMP=OFF -DLIBRAW_PATH=$(pwd)/../LibRaw .. 32 | cmake --build . 33 | name: Build LibRaw 34 | -------------------------------------------------------------------------------- /cmake/modules/Uninstall.cmake: -------------------------------------------------------------------------------- 1 | IF(NOT EXISTS "@CMAKE_BINARY_DIR@/install_manifest.txt") 2 | MESSAGE(FATAL_ERROR "Cannot find install manifest: \"@CMAKE_BINARY_DIR@/install_manifest.txt\"") 3 | ENDIF(NOT EXISTS "@CMAKE_BINARY_DIR@/install_manifest.txt") 4 | 5 | FILE(READ "@CMAKE_BINARY_DIR@/install_manifest.txt" files) 6 | STRING(REGEX REPLACE "\n" ";" files "${files}") 7 | FOREACH(file ${files}) 8 | MESSAGE(STATUS "Uninstalling \"${file}\"") 9 | IF(EXISTS "${file}") 10 | EXEC_PROGRAM( 11 | "@CMAKE_COMMAND@" ARGS "-E remove \"${file}\"" 12 | OUTPUT_VARIABLE rm_out 13 | RETURN_VALUE rm_retval 14 | ) 15 | IF("${rm_retval}" STREQUAL 0) 16 | ELSE("${rm_retval}" STREQUAL 0) 17 | MESSAGE(FATAL_ERROR "Problem when removing \"${file}\"") 18 | ENDIF("${rm_retval}" STREQUAL 0) 19 | ELSE(EXISTS "${file}") 20 | MESSAGE(STATUS "File \"${file}\" does not exist.") 21 | ENDIF(EXISTS "${file}") 22 | ENDFOREACH(file) 23 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | Redistribution and use in source and binary forms, with or without 2 | modification, are permitted provided that the following conditions 3 | are met: 4 | 5 | 1. Redistributions of source code must retain the copyright 6 | notice, this list of conditions and the following disclaimer. 7 | 2. Redistributions in binary form must reproduce the copyright 8 | notice, this list of conditions and the following disclaimer in the 9 | documentation and/or other materials provided with the distribution. 10 | 3. The name of the author may not be used to endorse or promote products 11 | derived from this software without specific prior written permission. 12 | 13 | THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR 14 | IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES 15 | OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. 16 | IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, 17 | INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT 18 | NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 19 | DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 20 | THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 21 | (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF 22 | THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 23 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | LibRaw-cmake 2 | ============ 3 | 4 | [![Build Status](https://travis-ci.org/LibRaw/LibRaw-cmake.svg?branch=master)](https://travis-ci.org/LibRaw/LibRaw-cmake) 5 | 6 | This is a separate repository for LibRaw CMake support scripts. 7 | It is [unmaintained](https://github.com/LibRaw/LibRaw/issues/44#issuecomment-60344793) by the authors of LibRaw and relies solely on user contributions. 8 | The current community-maintainer of this repository is [Maik Riechert](https://github.com/neothemachine). 9 | 10 | 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. 11 | 12 | If you like to become a direct contributor with write permissions to this repository, please contact the [LibRaw authors](https://github.com/LibRaw). 13 | 14 | How to use 15 | ---------- 16 | Just copy the contents of this repository into the root LibRaw folder and run cmake as usual. 17 | 18 | ### Add as a submodule 19 | 20 | Add this repo and libraw as git submodules: 21 | 22 | `git submodule add https://github.com/LibRaw/LibRaw-cmake.git` 23 | 24 | `git submodule add https://github.com/LibRaw/LibRaw.git` 25 | 26 | In your CMakeLists.txt add 27 | 28 | ```cmake 29 | add_subdirectory(LibRaw-cmake) 30 | target_link_libraries(ProjectName PRIVATE libraw::libraw) 31 | ``` 32 | 33 | Set the `LIBRAW_PATH` CMake variable to point to the **LibRaw** directory: 34 | 35 | `cmake -DLIBRAW_PATH=./LibRaw/` -------------------------------------------------------------------------------- /INSTALL.CMAKE: -------------------------------------------------------------------------------- 1 | 2 | ========= Installing LibRaw (CMake version) ========== 3 | 4 | I. Installation steps 5 | 6 | 1. Unpack the distribution file: 7 | 8 | $ tar xzvf LibRaw-0.xx.yy.tar.gz 9 | 10 | 2. Copy this LibRaw-cmake scripts in LibRaw-... folder 11 | 12 | 3. Go to LibRaw folder and run ./configure and make: 13 | 14 | $ cd LibRaw-0.xx.yy 15 | $ ./cmake [...optional args...] . 16 | $ make 17 | 18 | 4. install by run make install as root: 19 | 20 | $ sudo make install 21 | 22 | 23 | II. ./cmake options 24 | 25 | -DENABLE_OPENMP=ON/OFF 26 | 27 | Enable/disable OpenMP support if compiler supports it. 28 | OpenMP is enabled by default. 29 | 30 | 31 | -DENABLE_LCMS=ON/OFF 32 | 33 | Enable/disable LCMS color engine support. If enabled, ./cmake will try to 34 | find lcms library. Both LCMS-1.x and LCMS-2.x are supported 35 | LCMS support is enabled by default 36 | 37 | 38 | -DENABLE_EXAMPLES=ON/OFF 39 | 40 | Enables/disables examples compilation and installation. Enabled by default 41 | 42 | 43 | -DENABLE_RAWSPEED=ON/OFF 44 | -DRAWSPEED_RPATH=FOLDERNAME 45 | 46 | Enables/disables support of additional code from RawStudio project 47 | You need to download RawSpeed source code to use this feature. 48 | See README.RawSpeed.txt for details. 49 | ./cmake will try to find RawSpeed code in: 50 | 51 | a) If folder is specified via -DRAWSPEED_RPATH=FOLDERNAME 52 | command-line option, then only this folder will be checked. 53 | 54 | b) If no folder is specified in -DENABLE_RAWSPEED switch: 55 | 56 | ./RawSpeed (in LibRaw folder) 57 | 58 | 59 | 60 | -DENABLE_DCRAW_DEBUG=ON/OFF 61 | 62 | Enables/disables support of additional debug traces from dcraw operations. Disabled by default 63 | -------------------------------------------------------------------------------- /cmake/data/libraw_config.h.cmake: -------------------------------------------------------------------------------- 1 | /* -*- C++ -*- 2 | * File: libraw_version.h 3 | * Copyright 2008-2013 LibRaw LLC (info@libraw.org) 4 | * Created: Mon Sept 8, 2008 5 | * 6 | * LibRaw C++ interface 7 | * 8 | 9 | LibRaw is free software; you can redistribute it and/or modify 10 | it under the terms of the one of two licenses as you choose: 11 | 12 | 1. GNU LESSER GENERAL PUBLIC LICENSE version 2.1 13 | (See the file LICENSE.LGPL provided in LibRaw distribution archive for details). 14 | 15 | 2. COMMON DEVELOPMENT AND DISTRIBUTION LICENSE (CDDL) Version 1.0 16 | (See the file LICENSE.CDDL provided in LibRaw distribution archive for details). 17 | 18 | */ 19 | 20 | #ifndef __LIBRAW_CONFIG_H 21 | #define __LIBRAW_CONFIG_H 22 | 23 | /* Define to 1 if LibRaw have been compiled with DNG deflate codec support */ 24 | #cmakedefine LIBRAW_USE_DNGDEFLATECODEC 1 25 | 26 | /* Define to 1 if LibRaw have been compiled with DNG lossy codec support */ 27 | #cmakedefine LIBRAW_USE_DNGLOSSYCODEC 1 28 | 29 | /* Define to 1 if LibRaw have been compiled with OpenMP support */ 30 | #cmakedefine LIBRAW_USE_OPENMP 1 31 | 32 | /* Define to 1 if LibRaw have been compiled with LCMS support */ 33 | #cmakedefine LIBRAW_USE_LCMS 1 34 | 35 | /* Define to 1 if LibRaw have been compiled with RedCine codec support */ 36 | #cmakedefine LIBRAW_USE_REDCINECODEC 1 37 | 38 | /* Define to 1 if LibRaw have been compiled with RawSpeed codec support */ 39 | #cmakedefine LIBRAW_USE_RAWSPEED 1 40 | 41 | /* Define to 1 if LibRaw have been compiled with debug message from dcraw */ 42 | #cmakedefine LIBRAW_USE_DCRAW_DEBUG 1 43 | 44 | /* Define to 1 if LibRaw have been compiled with Foveon X3F support */ 45 | #cmakedefine LIBRAW_USE_X3FTOOLS 1 46 | 47 | /* Define to 1 if LibRaw have been compiled with Raspberry Pi RAW support */ 48 | #cmakedefine LIBRAW_USE_6BY9RPI 1 49 | 50 | #endif 51 | -------------------------------------------------------------------------------- /cmake/modules/MacroOptionalFindPackage.cmake: -------------------------------------------------------------------------------- 1 | # - MACRO_OPTIONAL_FIND_PACKAGE() combines FIND_PACKAGE() with an OPTION() 2 | # MACRO_OPTIONAL_FIND_PACKAGE( [QUIT] ) 3 | # This macro is a combination of OPTION() and FIND_PACKAGE(), it 4 | # works like FIND_PACKAGE(), but additionally it automatically creates 5 | # an option name WITH_, which can be disabled via the cmake GUI. 6 | # or via -DWITH_=OFF 7 | # The standard _FOUND variables can be used in the same way 8 | # as when using the normal FIND_PACKAGE() 9 | 10 | # Copyright (c) 2006-2010 Alexander Neundorf, 11 | # 12 | # Redistribution and use is allowed according to the terms of the BSD license. 13 | # For details see the accompanying LICENSE file. 14 | 15 | # This is just a helper macro to set a bunch of variables empty. 16 | # We don't know whether the package uses UPPERCASENAME or CamelCaseName, so we try both: 17 | macro(_MOFP_SET_EMPTY_IF_DEFINED _name _var) 18 | if(DEFINED ${_name}_${_var}) 19 | set(${_name}_${_var} "") 20 | endif(DEFINED ${_name}_${_var}) 21 | 22 | string(TOUPPER ${_name} _nameUpper) 23 | if(DEFINED ${_nameUpper}_${_var}) 24 | set(${_nameUpper}_${_var} "") 25 | endif(DEFINED ${_nameUpper}_${_var}) 26 | endmacro(_MOFP_SET_EMPTY_IF_DEFINED _package _var) 27 | 28 | 29 | macro (MACRO_OPTIONAL_FIND_PACKAGE _name ) 30 | option(WITH_${_name} "Search for ${_name} package" ON) 31 | if (WITH_${_name}) 32 | find_package(${_name} ${ARGN}) 33 | else (WITH_${_name}) 34 | string(TOUPPER ${_name} _nameUpper) 35 | set(${_name}_FOUND FALSE) 36 | set(${_nameUpper}_FOUND FALSE) 37 | 38 | _mofp_set_empty_if_defined(${_name} INCLUDE_DIRS) 39 | _mofp_set_empty_if_defined(${_name} INCLUDE_DIR) 40 | _mofp_set_empty_if_defined(${_name} INCLUDES) 41 | _mofp_set_empty_if_defined(${_name} LIBRARY) 42 | _mofp_set_empty_if_defined(${_name} LIBRARIES) 43 | _mofp_set_empty_if_defined(${_name} LIBS) 44 | _mofp_set_empty_if_defined(${_name} FLAGS) 45 | _mofp_set_empty_if_defined(${_name} DEFINITIONS) 46 | endif (WITH_${_name}) 47 | endmacro (MACRO_OPTIONAL_FIND_PACKAGE) 48 | 49 | -------------------------------------------------------------------------------- /cmake/modules/FindLCMS.cmake: -------------------------------------------------------------------------------- 1 | # - Find LCMS 2 | # Find the LCMS (Little Color Management System) library and includes and 3 | # This module defines 4 | # LCMS_INCLUDE_DIR, where to find lcms.h 5 | # LCMS_LIBRARIES, the libraries needed to use LCMS. 6 | # LCMS_DOT_VERSION, The version number of the LCMS library, e.g. "1.19" 7 | # LCMS_VERSION, Similar to LCMS_DOT_VERSION, but without the dots, e.g. "119" 8 | # LCMS_FOUND, If false, do not try to use LCMS. 9 | # 10 | # The minimum required version of LCMS can be specified using the 11 | # standard syntax, e.g. find_package(LCMS 1.10) 12 | 13 | # Copyright (c) 2008, Adrian Page, 14 | # Copyright (c) 2009, Cyrille Berger, 15 | # 16 | # Redistribution and use is allowed according to the terms of the BSD license. 17 | # For details see the accompanying LICENSE file. 18 | 19 | 20 | # use pkg-config to get the directories and then use these values 21 | # in the FIND_PATH() and FIND_LIBRARY() calls 22 | if(NOT WIN32) 23 | find_package(PkgConfig) 24 | pkg_check_modules(PC_LCMS lcms) 25 | set(LCMS_DEFINITIONS ${PC_LCMS_CFLAGS_OTHER}) 26 | endif(NOT WIN32) 27 | 28 | find_path(LCMS_INCLUDE_DIR lcms.h 29 | HINTS 30 | ${PC_LCMS_INCLUDEDIR} 31 | ${PC_LCMS_INCLUDE_DIRS} 32 | PATH_SUFFIXES lcms liblcms1 33 | ) 34 | 35 | find_library(LCMS_LIBRARIES NAMES lcms liblcms lcms-1 liblcms-1 36 | HINTS 37 | ${PC_LCMS_LIBDIR} 38 | ${PC_LCMS_LIBRARY_DIRS} 39 | PATH_SUFFIXES lcms 40 | ) 41 | 42 | # Store the LCMS version number in the cache, so we don't have to search every time again 43 | if(LCMS_INCLUDE_DIR AND NOT LCMS_VERSION) 44 | file(READ ${LCMS_INCLUDE_DIR}/lcms.h LCMS_VERSION_CONTENT) 45 | string(REGEX MATCH "#define LCMS_VERSION[ ]*[0-9]*\n" LCMS_VERSION_MATCH ${LCMS_VERSION_CONTENT}) 46 | if(LCMS_VERSION_MATCH) 47 | string(REGEX REPLACE "#define LCMS_VERSION[ ]*([0-9]*)\n" "\\1" _LCMS_VERSION ${LCMS_VERSION_MATCH}) 48 | string(SUBSTRING ${_LCMS_VERSION} 0 1 LCMS_MAJOR_VERSION) 49 | string(SUBSTRING ${_LCMS_VERSION} 1 2 LCMS_MINOR_VERSION) 50 | endif(LCMS_VERSION_MATCH) 51 | set(LCMS_VERSION "${LCMS_MAJOR_VERSION}${LCMS_MINOR_VERSION}" CACHE STRING "Version number of lcms" FORCE) 52 | set(LCMS_DOT_VERSION "${LCMS_MAJOR_VERSION}.${LCMS_MINOR_VERSION}" CACHE STRING "Version number of lcms split into components" FORCE) 53 | endif(LCMS_INCLUDE_DIR AND NOT LCMS_VERSION) 54 | 55 | include(FindPackageHandleStandardArgs) 56 | find_package_handle_standard_args(LCMS REQUIRED_VARS LCMS_LIBRARIES LCMS_INCLUDE_DIR 57 | VERSION_VAR LCMS_DOT_VERSION ) 58 | 59 | mark_as_advanced(LCMS_INCLUDE_DIR LCMS_LIBRARIES LCMS_VERSION) 60 | 61 | -------------------------------------------------------------------------------- /cmake/modules/FindLCMS2.cmake: -------------------------------------------------------------------------------- 1 | # - Find LCMS2 2 | # Find the LCMS2 includes and library 3 | # This module defines 4 | # LCMS2_INCLUDE_DIR, where to find lcms.h 5 | # LCMS2_LIBRARIES, the libraries needed to use LCMS2. 6 | # LCMS2_VERSION, The value of LCMS_VERSION defined in lcms.h 7 | # LCMS2_FOUND, If false, do not try to use LCMS2. 8 | 9 | 10 | # Copyright (c) 2008, Adrian Page, 11 | # Copyright (c) 2009, Cyrille Berger, 12 | # 13 | # Redistribution and use is allowed according to the terms of the BSD license. 14 | # For details see the accompanying LICENSE file. 15 | 16 | 17 | # use pkg-config to get the directories and then use these values 18 | # in the FIND_PATH() and FIND_LIBRARY() calls 19 | if(NOT WIN32) 20 | find_package(PkgConfig) 21 | pkg_check_modules(PC_LCMS2 lcms2) 22 | set(LCMS2_DEFINITIONS ${PC_LCMS2_CFLAGS_OTHER}) 23 | endif(NOT WIN32) 24 | 25 | find_path(LCMS2_INCLUDE_DIR lcms2.h 26 | PATHS 27 | ${PC_LCMS2_INCLUDEDIR} 28 | ${PC_LCMS2_INCLUDE_DIRS} 29 | PATH_SUFFIXES lcms2 liblcms2 30 | ) 31 | 32 | find_library(LCMS2_LIBRARIES NAMES lcms2 liblcms2 lcms-2 liblcms-2 33 | PATHS 34 | ${PC_LCMS2_LIBDIR} 35 | ${PC_LCMS2_LIBRARY_DIRS} 36 | PATH_SUFFIXES lcms2 37 | ) 38 | 39 | if(LCMS2_INCLUDE_DIR AND LCMS2_LIBRARIES) 40 | set(LCMS2_FOUND TRUE) 41 | else(LCMS2_INCLUDE_DIR AND LCMS2_LIBRARIES) 42 | set(LCMS2_FOUND FALSE) 43 | endif(LCMS2_INCLUDE_DIR AND LCMS2_LIBRARIES) 44 | 45 | if(LCMS2_FOUND) 46 | file(READ ${LCMS2_INCLUDE_DIR}/lcms2.h LCMS2_VERSION_CONTENT) 47 | string(REGEX MATCH "#define LCMS_VERSION[ ]*[0-9]*\n" LCMS2_VERSION_MATCH ${LCMS2_VERSION_CONTENT}) 48 | if(LCMS2_VERSION_MATCH) 49 | string(REGEX REPLACE "#define LCMS_VERSION[ ]*([0-9]*)\n" "\\1" LCMS2_VERSION ${LCMS2_VERSION_MATCH}) 50 | if(NOT LCMS2_FIND_QUIETLY) 51 | string(SUBSTRING ${LCMS2_VERSION} 0 1 LCMS2_MAJOR_VERSION) 52 | string(SUBSTRING ${LCMS2_VERSION} 1 2 LCMS2_MINOR_VERSION) 53 | message(STATUS "Found lcms version ${LCMS2_MAJOR_VERSION}.${LCMS2_MINOR_VERSION}, ${LCMS2_LIBRARIES}") 54 | endif(NOT LCMS2_FIND_QUIETLY) 55 | else(LCMS2_VERSION_MATCH) 56 | if(NOT LCMS2_FIND_QUIETLY) 57 | message(STATUS "Found lcms2 but failed to find version ${LCMS2_LIBRARIES}") 58 | endif(NOT LCMS2_FIND_QUIETLY) 59 | set(LCMS2_VERSION NOTFOUND) 60 | endif(LCMS2_VERSION_MATCH) 61 | else(LCMS2_FOUND) 62 | if(NOT LCMS2_FIND_QUIETLY) 63 | if(LCMS2_FIND_REQUIRED) 64 | message(FATAL_ERROR "Required package lcms2 NOT found") 65 | else(LCMS2_FIND_REQUIRED) 66 | message(STATUS "lcms2 NOT found") 67 | endif(LCMS2_FIND_REQUIRED) 68 | endif(NOT LCMS2_FIND_QUIETLY) 69 | endif(LCMS2_FOUND) 70 | 71 | mark_as_advanced(LCMS2_INCLUDE_DIR LCMS2_LIBRARIES LCMS2_VERSION) 72 | 73 | -------------------------------------------------------------------------------- /cmake/modules/FindLibRaw.cmake: -------------------------------------------------------------------------------- 1 | # - Find LibRaw 2 | # Find the LibRaw library 3 | # This module defines 4 | # LibRaw_VERSION_STRING, the version string of LibRaw 5 | # LibRaw_INCLUDE_DIR, where to find libraw.h 6 | # LibRaw_LIBRARIES, the libraries needed to use LibRaw (non-thread-safe) 7 | # LibRaw_r_LIBRARIES, the libraries needed to use LibRaw (thread-safe) 8 | # LibRaw_DEFINITIONS, the definitions needed to use LibRaw (non-thread-safe) 9 | # LibRaw_r_DEFINITIONS, the definitions needed to use LibRaw (thread-safe) 10 | # 11 | # Copyright (c) 2013, Pino Toscano 12 | # Copyright (c) 2013, Gilles Caulier 13 | # 14 | # Redistribution and use is allowed according to the terms of the BSD license. 15 | # For details see the accompanying LICENSE file. 16 | 17 | FIND_PACKAGE(PkgConfig) 18 | 19 | IF(PKG_CONFIG_FOUND) 20 | PKG_CHECK_MODULES(PC_LIBRAW libraw) 21 | SET(LibRaw_DEFINITIONS ${PC_LIBRAW_CFLAGS_OTHER}) 22 | 23 | PKG_CHECK_MODULES(PC_LIBRAW_R libraw_r) 24 | SET(LibRaw_r_DEFINITIONS ${PC_LIBRAW_R_CFLAGS_OTHER}) 25 | ENDIF() 26 | 27 | FIND_PATH(LibRaw_INCLUDE_DIR libraw.h 28 | HINTS 29 | ${PC_LIBRAW_INCLUDEDIR} 30 | ${PC_LibRaw_INCLUDE_DIRS} 31 | PATH_SUFFIXES libraw 32 | ) 33 | 34 | FIND_LIBRARY(LibRaw_LIBRARY_RELEASE NAMES raw 35 | HINTS 36 | ${PC_LIBRAW_LIBDIR} 37 | ${PC_LIBRAW_LIBRARY_DIRS} 38 | ) 39 | 40 | FIND_LIBRARY(LibRaw_LIBRARY_DEBUG NAMES rawd 41 | HINTS 42 | ${PC_LIBRAW_LIBDIR} 43 | ${PC_LIBRAW_LIBRARY_DIRS} 44 | ) 45 | 46 | include(SelectLibraryConfigurations) 47 | select_library_configurations(LibRaw) 48 | 49 | FIND_LIBRARY(LibRaw_r_LIBRARY_RELEASE NAMES raw_r 50 | HINTS 51 | ${PC_LIBRAW_R_LIBDIR} 52 | ${PC_LIBRAW_R_LIBRARY_DIRS} 53 | ) 54 | 55 | FIND_LIBRARY(LibRaw_r_LIBRARY_DEBUG NAMES raw_rd 56 | HINTS 57 | ${PC_LIBRAW_R_LIBDIR} 58 | ${PC_LIBRAW_R_LIBRARY_DIRS} 59 | ) 60 | 61 | select_library_configurations(LibRaw_r) 62 | 63 | IF(LibRaw_INCLUDE_DIR) 64 | FILE(READ ${LibRaw_INCLUDE_DIR}/libraw_version.h _libraw_version_content) 65 | 66 | STRING(REGEX MATCH "#define LIBRAW_MAJOR_VERSION[ \t]*([0-9]*)\n" _version_major_match ${_libraw_version_content}) 67 | SET(_libraw_version_major "${CMAKE_MATCH_1}") 68 | 69 | STRING(REGEX MATCH "#define LIBRAW_MINOR_VERSION[ \t]*([0-9]*)\n" _version_minor_match ${_libraw_version_content}) 70 | SET(_libraw_version_minor "${CMAKE_MATCH_1}") 71 | 72 | STRING(REGEX MATCH "#define LIBRAW_PATCH_VERSION[ \t]*([0-9]*)\n" _version_patch_match ${_libraw_version_content}) 73 | SET(_libraw_version_patch "${CMAKE_MATCH_1}") 74 | 75 | IF(_version_major_match AND _version_minor_match AND _version_patch_match) 76 | SET(LibRaw_VERSION_STRING "${_libraw_version_major}.${_libraw_version_minor}.${_libraw_version_patch}") 77 | ELSE() 78 | IF(NOT LibRaw_FIND_QUIETLY) 79 | MESSAGE(STATUS "Failed to get version information from ${LibRaw_INCLUDE_DIR}/libraw_version.h") 80 | ENDIF() 81 | ENDIF() 82 | ENDIF() 83 | 84 | INCLUDE(FindPackageHandleStandardArgs) 85 | FIND_PACKAGE_HANDLE_STANDARD_ARGS(LibRaw 86 | REQUIRED_VARS LibRaw_LIBRARIES LibRaw_INCLUDE_DIR 87 | VERSION_VAR LibRaw_VERSION_STRING 88 | ) 89 | 90 | MARK_AS_ADVANCED(LibRaw_VERSION_STRING 91 | LibRaw_INCLUDE_DIR 92 | LibRaw_LIBRARIES 93 | LibRaw_r_LIBRARIES 94 | LibRaw_DEFINITIONS 95 | LibRaw_r_DEFINITIONS 96 | ) 97 | -------------------------------------------------------------------------------- /cmake/modules/MacroLogFeature.cmake: -------------------------------------------------------------------------------- 1 | # This file defines the Feature Logging macros. 2 | # 3 | # MACRO_LOG_FEATURE(VAR FEATURE DESCRIPTION URL [REQUIRED [MIN_VERSION [COMMENTS]]]) 4 | # Logs the information so that it can be displayed at the end 5 | # of the configure run 6 | # VAR : TRUE or FALSE, indicating whether the feature is supported 7 | # FEATURE: name of the feature, e.g. "libjpeg" 8 | # DESCRIPTION: description what this feature provides 9 | # URL: home page 10 | # REQUIRED: TRUE or FALSE, indicating whether the feature is required 11 | # MIN_VERSION: minimum version number. empty string if unneeded 12 | # COMMENTS: More info you may want to provide. empty string if unnecessary 13 | # 14 | # MACRO_DISPLAY_FEATURE_LOG() 15 | # Call this to display the collected results. 16 | # Exits CMake with a FATAL error message if a required feature is missing 17 | # 18 | # Example: 19 | # 20 | # INCLUDE(MacroLogFeature) 21 | # 22 | # FIND_PACKAGE(JPEG) 23 | # MACRO_LOG_FEATURE(JPEG_FOUND "libjpeg" "Support JPEG images" "http://www.ijg.org" TRUE "3.2a" "") 24 | # ... 25 | # MACRO_DISPLAY_FEATURE_LOG() 26 | 27 | # Copyright (c) 2006, Alexander Neundorf, 28 | # Copyright (c) 2006, Allen Winter, 29 | # Copyright (c) 2009, Sebastian Trueg, 30 | # 31 | # Redistribution and use is allowed according to the terms of the BSD license. 32 | # For details see the accompanying LICENSE file. 33 | 34 | IF (NOT _macroLogFeatureAlreadyIncluded) 35 | SET(_file ${CMAKE_BINARY_DIR}/MissingRequirements.txt) 36 | IF (EXISTS ${_file}) 37 | FILE(REMOVE ${_file}) 38 | ENDIF (EXISTS ${_file}) 39 | 40 | SET(_file ${CMAKE_BINARY_DIR}/EnabledFeatures.txt) 41 | IF (EXISTS ${_file}) 42 | FILE(REMOVE ${_file}) 43 | ENDIF (EXISTS ${_file}) 44 | 45 | SET(_file ${CMAKE_BINARY_DIR}/DisabledFeatures.txt) 46 | IF (EXISTS ${_file}) 47 | FILE(REMOVE ${_file}) 48 | ENDIF (EXISTS ${_file}) 49 | 50 | SET(_macroLogFeatureAlreadyIncluded TRUE) 51 | 52 | INCLUDE(FeatureSummary) 53 | 54 | ENDIF (NOT _macroLogFeatureAlreadyIncluded) 55 | 56 | 57 | MACRO(MACRO_LOG_FEATURE _var _package _description _url ) # _required _minvers _comments) 58 | 59 | STRING(TOUPPER "${ARGV4}" _required) 60 | SET(_minvers "${ARGV5}") 61 | SET(_comments "${ARGV6}") 62 | 63 | IF (${_var}) 64 | SET(_LOGFILENAME ${CMAKE_BINARY_DIR}/EnabledFeatures.txt) 65 | ELSE (${_var}) 66 | IF ("${_required}" STREQUAL "TRUE") 67 | SET(_LOGFILENAME ${CMAKE_BINARY_DIR}/MissingRequirements.txt) 68 | ELSE ("${_required}" STREQUAL "TRUE") 69 | SET(_LOGFILENAME ${CMAKE_BINARY_DIR}/DisabledFeatures.txt) 70 | ENDIF ("${_required}" STREQUAL "TRUE") 71 | ENDIF (${_var}) 72 | 73 | SET(_logtext " * ${_package}") 74 | 75 | IF (NOT ${_var}) 76 | IF (${_minvers} MATCHES ".*") 77 | SET(_logtext "${_logtext} (${_minvers} or higher)") 78 | ENDIF (${_minvers} MATCHES ".*") 79 | SET(_logtext "${_logtext} <${_url}>\n ") 80 | ELSE (NOT ${_var}) 81 | SET(_logtext "${_logtext} - ") 82 | ENDIF (NOT ${_var}) 83 | 84 | SET(_logtext "${_logtext}${_description}") 85 | 86 | IF (NOT ${_var}) 87 | IF (${_comments} MATCHES ".*") 88 | SET(_logtext "${_logtext}\n ${_comments}") 89 | ENDIF (${_comments} MATCHES ".*") 90 | # SET(_logtext "${_logtext}\n") #double-space missing features? 91 | ENDIF (NOT ${_var}) 92 | 93 | FILE(APPEND "${_LOGFILENAME}" "${_logtext}\n") 94 | 95 | IF(COMMAND SET_PACKAGE_PROPERTIES) 96 | SET_PACKAGE_PROPERTIES("${_package}" PROPERTIES URL "${_url}" DESCRIPTION "\"${_description}\"") 97 | ELSEIF(COMMAND SET_PACKAGE_INFO) # in FeatureSummary.cmake since CMake 2.8.3 98 | SET_PACKAGE_INFO("${_package}" "\"${_description}\"" "${_url}" "\"${_comments}\"") 99 | ENDIF(COMMAND SET_PACKAGE_PROPERTIES) 100 | 101 | ENDMACRO(MACRO_LOG_FEATURE) 102 | 103 | 104 | MACRO(MACRO_DISPLAY_FEATURE_LOG) 105 | IF(COMMAND FEATURE_SUMMARY) # in FeatureSummary.cmake since CMake 2.8.3 106 | FEATURE_SUMMARY(FILENAME ${CMAKE_CURRENT_BINARY_DIR}/FindPackageLog.txt 107 | WHAT ALL) 108 | ENDIF(COMMAND FEATURE_SUMMARY) 109 | 110 | SET(_missingFile ${CMAKE_BINARY_DIR}/MissingRequirements.txt) 111 | SET(_enabledFile ${CMAKE_BINARY_DIR}/EnabledFeatures.txt) 112 | SET(_disabledFile ${CMAKE_BINARY_DIR}/DisabledFeatures.txt) 113 | 114 | IF (EXISTS ${_missingFile} OR EXISTS ${_enabledFile} OR EXISTS ${_disabledFile}) 115 | SET(_printSummary TRUE) 116 | ENDIF (EXISTS ${_missingFile} OR EXISTS ${_enabledFile} OR EXISTS ${_disabledFile}) 117 | 118 | IF(_printSummary) 119 | SET(_missingDeps 0) 120 | IF (EXISTS ${_enabledFile}) 121 | FILE(READ ${_enabledFile} _enabled) 122 | FILE(REMOVE ${_enabledFile}) 123 | 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}") 124 | ENDIF (EXISTS ${_enabledFile}) 125 | 126 | 127 | IF (EXISTS ${_disabledFile}) 128 | SET(_missingDeps 1) 129 | FILE(READ ${_disabledFile} _disabled) 130 | FILE(REMOVE ${_disabledFile}) 131 | 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}") 132 | ENDIF (EXISTS ${_disabledFile}) 133 | 134 | 135 | IF (EXISTS ${_missingFile}) 136 | SET(_missingDeps 1) 137 | FILE(READ ${_missingFile} _requirements) 138 | 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}") 139 | FILE(REMOVE ${_missingFile}) 140 | SET(_haveMissingReq 1) 141 | ENDIF (EXISTS ${_missingFile}) 142 | 143 | 144 | IF (NOT ${_missingDeps}) 145 | SET(_summary "${_summary}\n-----------------------------------------------------------------------------\n-- Congratulations! All external packages have been found.") 146 | ENDIF (NOT ${_missingDeps}) 147 | 148 | 149 | MESSAGE(${_summary}) 150 | MESSAGE("-----------------------------------------------------------------------------\n") 151 | 152 | 153 | IF(_haveMissingReq) 154 | MESSAGE(FATAL_ERROR "Exiting: Missing Requirements") 155 | ENDIF(_haveMissingReq) 156 | 157 | ENDIF(_printSummary) 158 | 159 | ENDMACRO(MACRO_DISPLAY_FEATURE_LOG) 160 | -------------------------------------------------------------------------------- /CMakeLists.txt: -------------------------------------------------------------------------------- 1 | # =========================================================== 2 | # 3 | # This file is a part of Libraw project 4 | # http://www.libraw.org 5 | # 6 | # @date 2013-09-07 7 | # @brief Library for reading and processing of RAW images 8 | # 9 | # @author Copyright (C) 2013 by Gilles Caulier 10 | # caulier dot gilles at gmail dot com 11 | # 12 | # This program is free software; you can redistribute it 13 | # and/or modify it under the terms of the GNU General 14 | # Public License as published by the Free Software Foundation; 15 | # either version 2, or (at your option) 16 | # any later version. 17 | # 18 | # This program is distributed in the hope that it will be useful, 19 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 20 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 21 | # GNU General Public License for more details. 22 | # 23 | # ============================================================ 24 | 25 | cmake_minimum_required(VERSION 3.12..16) 26 | 27 | 28 | # Determine if libraw is built as a subproject (using add_subdirectory) 29 | # or if it is the master project. 30 | set(MASTER_PROJECT OFF) 31 | if (CMAKE_CURRENT_SOURCE_DIR STREQUAL CMAKE_SOURCE_DIR) 32 | set(MASTER_PROJECT ON) 33 | message(STATUS "CMake version: ${CMAKE_VERSION}") 34 | endif () 35 | 36 | set(LIBRAW_PATH ${CMAKE_CURRENT_SOURCE_DIR} CACHE STRING "Relative path to libraw directory (default=CMAKE_CURRENT_SOURCE_DIR)") 37 | if(NOT EXISTS "${LIBRAW_PATH}") 38 | message(STATUS "LIBRAW_PATH=${LIBRAW_PATH}") 39 | message(FATAL_ERROR "LIBRAW_PATH does not contain a valid path to the libraw home") 40 | endif() 41 | 42 | file(TO_CMAKE_PATH "${LIBRAW_PATH}" LIBRAW_PATH) 43 | 44 | # ================================================================================================== 45 | # Library version info extraction 46 | 47 | file(READ ${LIBRAW_PATH}/libraw/libraw_version.h _libraw_version_content) 48 | 49 | # API version strings 50 | string(REGEX MATCH "#define LIBRAW_MAJOR_VERSION[ \t]*([0-9]*)\n" _version_major_match ${_libraw_version_content}) 51 | set(RAW_LIB_MAJOR_VERSION "${CMAKE_MATCH_1}") 52 | 53 | string(REGEX MATCH "#define LIBRAW_MINOR_VERSION[ \t]*([0-9]*)\n" _version_minor_match ${_libraw_version_content}) 54 | set(RAW_LIB_MINOR_VERSION "${CMAKE_MATCH_1}") 55 | 56 | string(REGEX MATCH "#define LIBRAW_PATCH_VERSION[ \t]*([0-9]*)\n" _version_patch_match ${_libraw_version_content}) 57 | set(RAW_LIB_PATCH_VERSION "${CMAKE_MATCH_1}") 58 | 59 | # ABI version strings 60 | 61 | string(REGEX MATCH "#define LIBRAW_SHLIB_CURRENT[ \t]*([0-9]*)\n" _version_socur_match ${_libraw_version_content}) 62 | set(RAW_LIB_SO_CUR_VERSION "${CMAKE_MATCH_1}") 63 | 64 | string(REGEX MATCH "#define LIBRAW_SHLIB_REVISION[ \t]*([0-9]*)\n" _version_sorev_match ${_libraw_version_content}) 65 | set(RAW_LIB_SO_REV_VERSION "${CMAKE_MATCH_1}") 66 | 67 | string(REGEX MATCH "#define LIBRAW_SHLIB_AGE[ \t]*([0-9]*)\n" _version_soage_match ${_libraw_version_content}) 68 | set(RAW_LIB_SO_AGE_VERSION "${CMAKE_MATCH_1}") 69 | 70 | # Set env. variables accordinly. 71 | set(RAW_LIB_VERSION_STRING "${RAW_LIB_MAJOR_VERSION}.${RAW_LIB_MINOR_VERSION}.${RAW_LIB_PATCH_VERSION}") 72 | set(RAW_LIB_VERSION_ID "0x${RAW_LIB_MAJOR_VERSION}${RAW_LIB_MINOR_VERSION}${RAW_LIB_PATCH_VERSION}") 73 | set(RAW_LIB_SO_VERSION_STRING "${RAW_LIB_SO_CUR_VERSION}.${RAW_LIB_SO_REV_VERSION}.${RAW_LIB_SO_AGE_VERSION}") 74 | 75 | message(STATUS "LibRaw string version: ${RAW_LIB_VERSION_STRING}") 76 | message(STATUS "LibRaw ID version: ${RAW_LIB_VERSION_ID}") 77 | message(STATUS "LibRaw SO version: ${RAW_LIB_SO_VERSION_STRING}") 78 | 79 | project(libraw VERSION ${RAW_LIB_VERSION_STRING} LANGUAGES CXX) 80 | 81 | # ================================================================================================== 82 | # Project Options 83 | option(BUILD_SHARED_LIBS "Build library as shared library (default=ON)" ON) 84 | option(ENABLE_OPENMP "Build library with OpenMP support (default=ON)" ON) 85 | option(ENABLE_LCMS "Build library with LCMS support (default=ON)" ON) 86 | option(ENABLE_JASPER "Build library with libjasper support (default=ON)" ON) 87 | option(ENABLE_EXAMPLES "Build library with sample command-line programs (default=ON)" ${MASTER_PROJECT}) 88 | option(ENABLE_RAWSPEED "Build library with extra RawSpeed codec support (default=OFF)" OFF) 89 | option(ENABLE_DCRAW_DEBUG "Build library with debug message from dcraw (default=OFF)" OFF) 90 | option(ENABLE_X3FTOOLS "Build library with Foveon X3F support (default=OFF)" OFF) 91 | option(ENABLE_6BY9RPI "Build library with Raspberry Pi RAW support (default=OFF)" OFF) 92 | option(LIBRAW_UNINSTALL_TARGET "Add a custom target to ease removal of installed targets" ${MASTER_PROJECT}) 93 | option(LIBRAW_INSTALL "Generate the install target." ${MASTER_PROJECT}) 94 | 95 | set(RAWSPEED_RPATH "RawSpeed" CACHE STRING 96 | "Relative path to extra RawSpeed codec (default=RawSpeed)") 97 | 98 | set(RAWSPEED_PATH "${CMAKE_CURRENT_SOURCE_DIR}/${RAWSPEED_RPATH}") 99 | 100 | # ================================================================================================== 101 | # General definitions rules 102 | 103 | if(WIN32 AND NOT DEFINED CMAKE_DEBUG_POSTFIX) 104 | set(CMAKE_DEBUG_POSTFIX "d") 105 | endif() 106 | 107 | # To prevent warnings from M$ compiler 108 | if(MSVC) 109 | add_definitions(-D_CRT_SECURE_NO_WARNINGS) 110 | add_definitions(-D_ATL_SECURE_NO_WARNINGS) 111 | add_definitions(-D_AFX_SECURE_NO_WARNINGS) 112 | endif() 113 | 114 | # For variables in $ 115 | include(GNUInstallDirs) 116 | 117 | # -- Check dependencies -------------------------------------------------------------------------------- 118 | 119 | set(CMAKE_MODULE_PATH ${CMAKE_CURRENT_SOURCE_DIR}/cmake/modules ${CMAKE_MODULE_PATH} ) 120 | 121 | include(MacroBoolTo01) 122 | include(MacroLogFeature) 123 | include(MacroOptionalFindPackage) 124 | 125 | set(LIBRAW_PC_LIBS_PRIVATE "") 126 | set(LIBRAW_PC_REQUIRES_PRIVATE "") 127 | 128 | # Math library check 129 | 130 | if(NOT WIN32 AND NOT EMSCRIPTEN) 131 | FIND_LIBRARY(MATH_LIBRARY m) 132 | if(MATH_LIBRARY) 133 | string(APPEND LIBRAW_PC_LIBS_PRIVATE " -l${MATH_LIBRARY}") 134 | endif() 135 | endif() 136 | 137 | # LCMS version 1 and 2 library check 138 | 139 | set(LCMS_SUPPORT_CAN_BE_COMPILED false) 140 | set(LCMS2_FOUND false) 141 | set(LCMS_FOUND false) 142 | 143 | if(ENABLE_LCMS) 144 | message(STATUS "Check for LCMS2 availability...") 145 | find_package(LCMS2) 146 | if(LCMS2_FOUND AND (LCMS2_VERSION VERSION_EQUAL 2.1 OR LCMS2_VERSION VERSION_GREATER 2.1)) 147 | message(STATUS "Found LCMS2 : ${LCMS2_LIBRARIES} ${LCMS2_INCLUDE_DIR}") 148 | include_directories(${LCMS2_INCLUDE_DIR}) 149 | MACRO_LOG_FEATURE(LCMS2_FOUND "LCMS2" "A small-footprint color management engine" "http://www.littlecms.com" FALSE "" "Needed by libkdcraw") 150 | # Flag to compile Little CMS version 2 with LibRaw 151 | add_definitions(-DUSE_LCMS2) 152 | set(LCMS_SUPPORT_CAN_BE_COMPILED true) 153 | string(APPEND LIBRAW_PC_REQUIRES_PRIVATE " lcms2") 154 | else() 155 | message(STATUS "Check for LCMS availability instead LCMS2...") 156 | find_package(LCMS) 157 | if(LCMS_FOUND) 158 | message(STATUS "Found LCMS1: ${LCMS_LIBRARIES} ${LCMS_INCLUDE_DIR}") 159 | include_directories(${LCMS_INCLUDE_DIR}) 160 | MACRO_LOG_FEATURE(LCMS_FOUND "LCMS1" "A small-footprint color management engine" "http://www.littlecms.com" TRUE "" "Needed by libkdcraw") 161 | # Flag to compile Little CMS version 1 with LibRaw 162 | add_definitions(-DUSE_LCMS) 163 | # For compatibility 164 | set(LCMS2_LIBRARIES ${LCMS_LIBRARIES}) 165 | set(LCMS_SUPPORT_CAN_BE_COMPILED true) 166 | string(APPEND LIBRAW_PC_REQUIRES_PRIVATE " lcms") 167 | endif() 168 | endif() 169 | endif() 170 | 171 | # For registration to libraw_config.h 172 | MACRO_BOOL_TO_01(LCMS_SUPPORT_CAN_BE_COMPILED LIBRAW_USE_LCMS) 173 | 174 | # zlib library check 175 | 176 | find_package(ZLIB) 177 | find_package(JPEG) 178 | 179 | # Flag to use zlib with LibRaw DNG deflate codec 180 | if(ZLIB_FOUND) 181 | add_definitions(-DUSE_ZLIB) 182 | string(APPEND LIBRAW_PC_REQUIRES_PRIVATE " zlib") 183 | endif() 184 | 185 | # For registration to libraw_config.h 186 | MACRO_BOOL_TO_01(ZLIB_FOUND LIBRAW_USE_DNGDEFLATECODEC) 187 | 188 | # JPEG library check 189 | find_package(JPEG) 190 | if(JPEG_FOUND) 191 | if (${JPEG_VERSION} LESS 80) 192 | set(JPEG8_FOUND FALSE) 193 | else() 194 | set(JPEG8_FOUND TRUE) 195 | endif() 196 | endif() 197 | 198 | MACRO_LOG_FEATURE(JPEG8_FOUND "libjpeg" "JPEG image format support" "http://www.ijg.org" FALSE "80" "needed for the LibRaw DNG lossy codec") 199 | 200 | # Flag to use libjpeg with LibRaw DNG lossy codec 201 | if(JPEG8_FOUND) 202 | add_definitions(-DUSE_JPEG) 203 | add_definitions(-DUSE_JPEG8) 204 | string(APPEND LIBRAW_PC_REQUIRES_PRIVATE " libjpeg") 205 | endif() 206 | 207 | # For registration to libraw_config.h 208 | MACRO_BOOL_TO_01(JPEG8_FOUND LIBRAW_USE_DNGLOSSYCODEC) 209 | 210 | # OpenMP check 211 | set(OPENMP_SUPPORT_CAN_BE_COMPILED false) 212 | if(ENABLE_OPENMP) 213 | find_package(OpenMP) 214 | if(OpenMP_FOUND) 215 | set(OPENMP_SUPPORT_CAN_BE_COMPILED true) 216 | endif() 217 | endif() 218 | 219 | # For registration to libraw_config.h 220 | MACRO_BOOL_TO_01(OPENMP_SUPPORT_CAN_BE_COMPILED LIBRAW_USE_OPENMP) 221 | 222 | # Jasper library check 223 | set(JASPER_SUPPORT_CAN_BE_COMPILED false) 224 | if(RAW_LIB_VERSION_STRING VERSION_LESS 0.22 AND ENABLE_JASPER) 225 | find_package(Jasper) 226 | 227 | # Flag to use libjasper with LibRaw RedCine codec 228 | if(JASPER_FOUND) 229 | add_definitions(-DUSE_JASPER) 230 | include_directories(${JASPER_INCLUDE_DIR}) 231 | set(JASPER_SUPPORT_CAN_BE_COMPILED true) 232 | string(APPEND LIBRAW_PC_REQUIRES_PRIVATE " jasper") 233 | endif() 234 | endif() 235 | 236 | # For registration to libraw_config.h 237 | MACRO_BOOL_TO_01(JASPER_SUPPORT_CAN_BE_COMPILED LIBRAW_USE_REDCINECODEC) 238 | 239 | # For RawSpeed Codec Support 240 | 241 | set(RAWSPEED_FOUND false) 242 | set(RAWSPEED_SUPPORT_CAN_BE_COMPILED false) 243 | 244 | if(ENABLE_RAWSPEED) 245 | find_package(LibXml2) 246 | find_package(Threads REQUIRED) 247 | 248 | message(STATUS "RawSpeed codec path: ${RAWSPEED_PATH}") 249 | 250 | if(EXISTS "${RAWSPEED_PATH}/Common.cpp") 251 | set(RAWSPEED_FOUND true) 252 | else() 253 | message(STATUS "RawSpeed source code not found. Please checkout source code from RawStudio project website.") 254 | endif() 255 | 256 | if(ENABLE_RAWSPEED AND RAWSPEED_FOUND AND JPEG8_FOUND AND LIBXML2_FOUND AND PTHREADS_FOUND) 257 | 258 | set(RAWSPEED_SUPPORT_CAN_BE_COMPILED true) 259 | 260 | else() 261 | if(NOT JPEG8_FOUND) 262 | message(STATUS "LibJPEG dependency not resolved. LibRaw cannot be compiled with RawSpeed codec") 263 | endif() 264 | 265 | if(NOT LIBXML2_FOUND) 266 | message(STATUS "LibXML2 dependency not resolved. LibRaw cannot be compiled with RawSpeed codec") 267 | endif() 268 | 269 | if(NOT PTHREADS_FOUND) 270 | message(STATUS "Pthreads dependency not resolved. LibRaw cannot be compiled with RawSpeed codec") 271 | endif() 272 | 273 | endif() 274 | endif() 275 | 276 | # For registration to libraw_config.h 277 | MACRO_BOOL_TO_01(RAWSPEED_SUPPORT_CAN_BE_COMPILED LIBRAW_USE_RAWSPEED) 278 | 279 | # -- Compilation rules for RawSpeed library ------------------------------------------------------------- 280 | 281 | if(RAWSPEED_SUPPORT_CAN_BE_COMPILED) 282 | include_directories(${RAWSPEED_PATH}) 283 | 284 | include_directories(${LIBXML2_INCLUDE_DIR} ${PTHREADS_INCLUDE_DIR}) 285 | 286 | # Flag to include RawSpeed codec with Libraw 287 | add_definitions(-DUSE_RAWSPEED) 288 | 289 | add_definitions(${LIBXML2_DEFINITIONS} ${PTHREADS_DEFINITIONS}) 290 | 291 | set(librawspeed_LIB_SRCS ${RAWSPEED_PATH}/ArwDecoder.cpp 292 | ${RAWSPEED_PATH}/BitPumpJPEG.cpp 293 | ${RAWSPEED_PATH}/BitPumpMSB.cpp 294 | ${RAWSPEED_PATH}/BitPumpMSB32.cpp 295 | ${RAWSPEED_PATH}/BitPumpPlain.cpp 296 | ${RAWSPEED_PATH}/BlackArea.cpp 297 | ${RAWSPEED_PATH}/ByteStream.cpp 298 | ${RAWSPEED_PATH}/ByteStreamSwap.cpp 299 | ${RAWSPEED_PATH}/Camera.cpp 300 | ${RAWSPEED_PATH}/CameraMetaData.cpp 301 | ${RAWSPEED_PATH}/CameraMetadataException.cpp 302 | ${RAWSPEED_PATH}/CameraSensorInfo.cpp 303 | ${RAWSPEED_PATH}/ColorFilterArray.cpp 304 | ${RAWSPEED_PATH}/Common.cpp 305 | ${RAWSPEED_PATH}/Cr2Decoder.cpp 306 | ${RAWSPEED_PATH}/DngDecoder.cpp 307 | ${RAWSPEED_PATH}/DngDecoderSlices.cpp 308 | ${RAWSPEED_PATH}/DngOpcodes.cpp 309 | ${RAWSPEED_PATH}/FileIOException.cpp 310 | ${RAWSPEED_PATH}/FileMap.cpp 311 | ${RAWSPEED_PATH}/IOException.cpp 312 | ${RAWSPEED_PATH}/LJpegDecompressor.cpp 313 | ${RAWSPEED_PATH}/LJpegPlain.cpp 314 | ${RAWSPEED_PATH}/NefDecoder.cpp 315 | ${RAWSPEED_PATH}/NikonDecompressor.cpp 316 | ${RAWSPEED_PATH}/OrfDecoder.cpp 317 | ${RAWSPEED_PATH}/PefDecoder.cpp 318 | ${RAWSPEED_PATH}/PentaxDecompressor.cpp 319 | ${RAWSPEED_PATH}/RawDecoder.cpp 320 | ${RAWSPEED_PATH}/RawDecoderException.cpp 321 | ${RAWSPEED_PATH}/RawImage.cpp 322 | ${RAWSPEED_PATH}/RawImageDataFloat.cpp 323 | ${RAWSPEED_PATH}/RawImageDataU16.cpp 324 | ${RAWSPEED_PATH}/RawParser.cpp 325 | ${RAWSPEED_PATH}/Rw2Decoder.cpp 326 | ${RAWSPEED_PATH}/SrwDecoder.cpp 327 | ${RAWSPEED_PATH}/TiffEntry.cpp 328 | ${RAWSPEED_PATH}/TiffEntryBE.cpp 329 | ${RAWSPEED_PATH}/TiffIFD.cpp 330 | ${RAWSPEED_PATH}/TiffIFDBE.cpp 331 | ${RAWSPEED_PATH}/TiffParser.cpp 332 | ${RAWSPEED_PATH}/TiffParserException.cpp 333 | ${RAWSPEED_PATH}/TiffParserHeaderless.cpp 334 | ${RAWSPEED_PATH}/TiffParserOlympus.cpp 335 | ) 336 | 337 | endif() 338 | 339 | # -- Common LibRaw library compilation rules ------------------------------------------------------------------ 340 | 341 | # Flag to add debug print on the console 342 | if(ENABLE_DCRAW_DEBUG) 343 | add_definitions(-DDCRAW_VERBOSE) 344 | endif() 345 | 346 | # For registration to libraw_config.h 347 | MACRO_BOOL_TO_01(ENABLE_DCRAW_DEBUG LIBRAW_USE_DCRAW_DEBUG) 348 | 349 | # Flag to add Foveon X3F support 350 | if(ENABLE_X3FTOOLS) 351 | add_definitions(-DUSE_X3FTOOLS) 352 | endif() 353 | 354 | # For registration to libraw_config.h 355 | MACRO_BOOL_TO_01(ENABLE_X3FTOOLS LIBRAW_USE_X3FTOOLS) 356 | 357 | # Flag to add Raspberry Pi RAW support 358 | if(ENABLE_6BY9RPI) 359 | add_definitions(-DUSE_6BY9RPI) 360 | endif() 361 | 362 | # For registration to libraw_config.h 363 | MACRO_BOOL_TO_01(ENABLE_6BY9RPI LIBRAW_USE_6BY9RPI) 364 | 365 | # Create a config header for client application. 366 | configure_file(${CMAKE_CURRENT_SOURCE_DIR}/cmake/data/libraw_config.h.cmake ${CMAKE_CURRENT_BINARY_DIR}/libraw_config.h) 367 | 368 | # Put the include dirs which are in the source or build tree 369 | # before all other include dirs, so the headers in the sources 370 | # are preferred over the already installed ones 371 | set(CMAKE_INCLUDE_DIRECTORIES_PROJECT_BEFORE ON) 372 | 373 | include_directories(${CMAKE_CURRENT_BINARY_DIR}/ 374 | ${LIBRAW_PATH}/ 375 | ) 376 | 377 | # -- Log messages about configuration ------------------------------------------------------------------ 378 | 379 | message(STATUS "") 380 | message(STATUS "----------------------------------------------------------------------------------") 381 | message(STATUS " Libraw ${RAW_LIB_VERSION_STRING} configuration ") 382 | message(STATUS "") 383 | 384 | if(OPENMP_SUPPORT_CAN_BE_COMPILED) 385 | message(STATUS " Libraw will be compiled with OpenMP support .................. YES") 386 | else() 387 | message(STATUS " Libraw will be compiled with OpenMP support .................. NO") 388 | endif() 389 | 390 | if(LCMS_SUPPORT_CAN_BE_COMPILED) 391 | message(STATUS " Libraw will be compiled with LCMS support .................... YES") 392 | else() 393 | message(STATUS " Libraw will be compiled with LCMS support .................... NO") 394 | endif() 395 | 396 | if(ENABLE_EXAMPLES) 397 | message(STATUS " Libraw will be compiled with example command-line programs ... YES") 398 | else() 399 | message(STATUS " Libraw will be compiled with example command-line programs ... NO") 400 | endif() 401 | 402 | if(JASPER_SUPPORT_CAN_BE_COMPILED) 403 | message(STATUS " Libraw will be compiled with RedCine codec support ........... YES") 404 | else() 405 | message(STATUS " Libraw will be compiled with RedCine codec support ........... NO") 406 | endif() 407 | 408 | if(ZLIB_FOUND) 409 | message(STATUS " Libraw will be compiled with DNG deflate codec support ....... YES") 410 | else() 411 | message(STATUS " Libraw will be compiled with DNG deflate codec support ....... NO") 412 | endif() 413 | 414 | if(JPEG8_FOUND) 415 | message(STATUS " Libraw will be compiled with DNG lossy codec support ......... YES") 416 | else() 417 | message(STATUS " Libraw will be compiled with DNG lossy codec support ......... NO") 418 | endif() 419 | 420 | if(RAWSPEED_SUPPORT_CAN_BE_COMPILED) 421 | message(STATUS " Libraw will be compiled with RawSpeed support ................ YES") 422 | else() 423 | message(STATUS " Libraw will be compiled with RawSpeed support ................ NO") 424 | endif() 425 | 426 | if(ENABLE_DCRAW_DEBUG) 427 | message(STATUS " Libraw will be compiled with debug message from dcraw ........ YES") 428 | else() 429 | message(STATUS " Libraw will be compiled with debug message from dcraw ........ NO") 430 | endif() 431 | 432 | if(ENABLE_X3FTOOLS) 433 | message(STATUS " Libraw will be compiled with Foveon X3F support .............. YES") 434 | else() 435 | message(STATUS " Libraw will be compiled with Foveon X3F support .............. NO") 436 | endif() 437 | 438 | if(ENABLE_6BY9RPI) 439 | message(STATUS " Libraw will be compiled with Raspberry Pi RAW support ........ YES") 440 | else() 441 | message(STATUS " Libraw will be compiled with Raspberry Pi RAW support ........ NO") 442 | endif() 443 | 444 | if(BUILD_SHARED_LIBS) 445 | message(STATUS " Libraw will be compiled as a shared library") 446 | else() 447 | message(STATUS " Libraw will be compiled as a static library") 448 | endif() 449 | 450 | message(STATUS "----------------------------------------------------------------------------------") 451 | message(STATUS "") 452 | 453 | # -- Dedicated libraw target which does not support multi-threading --------------------------------------- 454 | 455 | if(RAW_LIB_VERSION_STRING VERSION_LESS 0.21) 456 | set(libraw_LIB_SRCS ${LIBRAW_PATH}/internal/dcraw_common.cpp 457 | ${LIBRAW_PATH}/internal/dcraw_fileio.cpp 458 | ${LIBRAW_PATH}/internal/demosaic_packs.cpp 459 | ${LIBRAW_PATH}/src/libraw_cxx.cpp 460 | ${LIBRAW_PATH}/src/libraw_c_api.cpp 461 | ${LIBRAW_PATH}/src/libraw_datastream.cpp 462 | ) 463 | else() 464 | file(GLOB_RECURSE libraw_LIB_SRCS CONFIGURE_DEPENDS "${LIBRAW_PATH}/src/*.cpp") 465 | 466 | # Exclude placeholder (stub) implementations 467 | file(GLOB_RECURSE exclude_libraw_LIB_SRCS CONFIGURE_DEPENDS "${LIBRAW_PATH}/src/*_ph.cpp") 468 | list(REMOVE_ITEM libraw_LIB_SRCS ${exclude_libraw_LIB_SRCS}) 469 | endif() 470 | 471 | if(RAWSPEED_SUPPORT_CAN_BE_COMPILED) 472 | set(libraw_LIB_SRCS ${libraw_LIB_SRCS} ${librawspeed_LIB_SRCS}) 473 | endif() 474 | 475 | 476 | add_library(raw ${libraw_LIB_SRCS}) 477 | add_library(libraw::libraw ALIAS raw) 478 | target_compile_definitions(raw PRIVATE LIBRAW_NOTHREADS) 479 | 480 | # Flag to export library symbols 481 | if (WIN32) 482 | target_compile_definitions(raw PRIVATE LIBRAW_BUILDLIB) 483 | endif() 484 | 485 | # Static builds use LIBRAW_NODLL: 486 | if(NOT BUILD_SHARED_LIBS) 487 | target_compile_definitions(raw PUBLIC LIBRAW_NODLL) 488 | endif() 489 | 490 | target_include_directories(raw 491 | PUBLIC 492 | $ 493 | $) 494 | 495 | target_link_libraries(raw PUBLIC ${MATH_LIBRARY}) 496 | 497 | if(WIN32) 498 | target_link_libraries(raw PUBLIC ws2_32) 499 | endif() 500 | 501 | if(OPENMP_SUPPORT_CAN_BE_COMPILED) 502 | target_link_libraries(raw PUBLIC OpenMP::OpenMP_CXX) 503 | if(MINGW) 504 | target_compile_definitions(raw PRIVATE LIBRAW_FORCE_OPENMP) 505 | endif() 506 | endif() 507 | 508 | if(LCMS_SUPPORT_CAN_BE_COMPILED) 509 | target_link_libraries(raw PUBLIC ${LCMS2_LIBRARIES}) 510 | endif() 511 | 512 | if(ZLIB_FOUND) 513 | target_link_libraries(raw PUBLIC ZLIB::ZLIB) 514 | endif() 515 | 516 | if(JPEG8_FOUND) 517 | target_link_libraries(raw PUBLIC JPEG::JPEG) 518 | endif() 519 | 520 | if(JASPER_SUPPORT_CAN_BE_COMPILED) 521 | target_link_libraries(raw PUBLIC ${JASPER_LIBRARIES}) 522 | endif() 523 | 524 | if(RAWSPEED_SUPPORT_CAN_BE_COMPILED) 525 | target_link_libraries(raw PUBLIC ${LIBXML2_LIBRARIES}) 526 | endif() 527 | 528 | set_target_properties(raw PROPERTIES VERSION ${RAW_LIB_SO_VERSION_STRING}) 529 | set_target_properties(raw PROPERTIES SOVERSION ${RAW_LIB_SO_CUR_VERSION}) 530 | set_target_properties(raw PROPERTIES OUTPUT_NAME "raw") 531 | set_target_properties(raw PROPERTIES COMPILE_PDB_NAME "raw") 532 | 533 | # -- Dedicated libraw target to support multi-threading --------------------------------------------- 534 | 535 | set(libraw_r_LIB_SRCS ${libraw_LIB_SRCS}) 536 | 537 | add_library(raw_r ${libraw_r_LIB_SRCS}) 538 | add_library(libraw::libraw_r ALIAS raw_r) 539 | 540 | # Flag to export library symbols 541 | if(WIN32) 542 | target_compile_definitions(raw_r PRIVATE LIBRAW_BUILDLIB) 543 | endif() 544 | 545 | # Static builds use LIBRAW_NODLL: 546 | if(NOT BUILD_SHARED_LIBS) 547 | target_compile_definitions(raw_r PUBLIC LIBRAW_NODLL) 548 | endif() 549 | 550 | # Always build position-independent code (PIC), even when building Libraw as a 551 | # static library so that shared libraries can link against it, not just 552 | # executables (PIC does not apply on Windows). 553 | # Use set_target_properties() not append_target_property() here as 554 | # POSITION_INDEPENDENT_CODE is a binary ON/OFF switch. 555 | set_target_properties(raw PROPERTIES POSITION_INDEPENDENT_CODE ON) 556 | set_target_properties(raw_r PROPERTIES POSITION_INDEPENDENT_CODE ON) 557 | 558 | target_link_libraries(raw_r PUBLIC ${MATH_LIBRARY}) 559 | target_include_directories(raw_r 560 | PUBLIC 561 | $ 562 | $) 563 | 564 | if(WIN32) 565 | target_link_libraries(raw_r PUBLIC ws2_32) 566 | endif() 567 | 568 | if(OPENMP_SUPPORT_CAN_BE_COMPILED) 569 | target_link_libraries(raw_r PUBLIC OpenMP::OpenMP_CXX) 570 | if(MINGW) 571 | target_compile_definitions(raw_r PRIVATE LIBRAW_FORCE_OPENMP) 572 | endif() 573 | endif() 574 | 575 | if(LCMS_SUPPORT_CAN_BE_COMPILED) 576 | target_link_libraries(raw_r PUBLIC ${LCMS2_LIBRARIES}) 577 | endif() 578 | 579 | if(ZLIB_FOUND) 580 | target_link_libraries(raw_r PUBLIC ZLIB::ZLIB) 581 | endif() 582 | 583 | if(JPEG8_FOUND) 584 | target_link_libraries(raw_r PUBLIC JPEG::JPEG) 585 | endif() 586 | 587 | if(JASPER_SUPPORT_CAN_BE_COMPILED) 588 | target_link_libraries(raw_r PUBLIC ${JASPER_LIBRARIES}) 589 | endif() 590 | 591 | if(RAWSPEED_SUPPORT_CAN_BE_COMPILED) 592 | target_link_libraries(raw_r PUBLIC ${LIBXML2_LIBRARIES} Threads::Threads) 593 | endif() 594 | 595 | set_target_properties(raw_r PROPERTIES VERSION ${RAW_LIB_SO_VERSION_STRING}) 596 | set_target_properties(raw_r PROPERTIES SOVERSION ${RAW_LIB_SO_CUR_VERSION}) 597 | set_target_properties(raw_r PROPERTIES OUTPUT_NAME "raw_r") 598 | set_target_properties(raw_r PROPERTIES COMPILE_PDB_NAME "raw_r") 599 | 600 | # -- Files to install ------------------------------------------------------------------------------------- 601 | if (LIBRAW_INSTALL) 602 | # Configure and install data file for packaging. 603 | configure_file(${CMAKE_CURRENT_SOURCE_DIR}/cmake/data/libraw.pc.cmake ${CMAKE_CURRENT_BINARY_DIR}/libraw.pc @ONLY) 604 | install(FILES ${CMAKE_CURRENT_BINARY_DIR}/libraw.pc DESTINATION ${CMAKE_INSTALL_LIBDIR}/pkgconfig) 605 | 606 | configure_file(${CMAKE_CURRENT_SOURCE_DIR}/cmake/data/libraw_r.pc.cmake ${CMAKE_CURRENT_BINARY_DIR}/libraw_r.pc @ONLY) 607 | install(FILES ${CMAKE_CURRENT_BINARY_DIR}/libraw_r.pc DESTINATION ${CMAKE_INSTALL_LIBDIR}/pkgconfig) 608 | 609 | # Install Shared header files. 610 | install(FILES ${LIBRAW_PATH}/libraw/libraw.h 611 | ${LIBRAW_PATH}/libraw/libraw_alloc.h 612 | ${LIBRAW_PATH}/libraw/libraw_const.h 613 | ${LIBRAW_PATH}/libraw/libraw_datastream.h 614 | ${LIBRAW_PATH}/libraw/libraw_internal.h 615 | ${LIBRAW_PATH}/libraw/libraw_types.h 616 | ${LIBRAW_PATH}/libraw/libraw_version.h 617 | ${CMAKE_CURRENT_BINARY_DIR}/libraw_config.h 618 | DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/libraw 619 | COMPONENT Devel 620 | ) 621 | 622 | # Install Shared binary files. 623 | install(TARGETS raw raw_r 624 | EXPORT ${PROJECT_NAME}Targets 625 | RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR} 626 | LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR} 627 | ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR} 628 | ) 629 | 630 | 631 | if(NOT BUILD_SHARED_LIBS AND "${CMAKE_CXX_SIMULATE_ID}" STREQUAL "MSVC") 632 | message("ClangCl does not support pdb generation with static libraries") 633 | elseif(MSVC) 634 | install(FILES ${PROJECT_BINARY_DIR}/raw.pdb ${PROJECT_BINARY_DIR}/raw_r.pdb 635 | DESTINATION ${CMAKE_INSTALL_LIBDIR} 636 | CONFIGURATIONS Debug RelWithDebInfo 637 | ) 638 | endif() 639 | 640 | # Install find cmake script to the system for client applications. 641 | install(FILES ${CMAKE_CURRENT_SOURCE_DIR}/cmake/modules/FindLibRaw.cmake 642 | DESTINATION ${CMAKE_INSTALL_DATADIR}/cmake/libraw) 643 | 644 | # Install doc data files. 645 | if(NOT MSVC) 646 | install(FILES ${LIBRAW_PATH}/COPYRIGHT 647 | ${LIBRAW_PATH}/LICENSE.CDDL 648 | ${LIBRAW_PATH}/LICENSE.LGPL 649 | ${LIBRAW_PATH}/Changelog.txt 650 | DESTINATION ${CMAKE_INSTALL_DOCDIR} 651 | COMPONENT main 652 | ) 653 | endif() 654 | 655 | # Uninstall rules 656 | if(LIBRAW_UNINSTALL_TARGET) 657 | configure_file(${CMAKE_CURRENT_SOURCE_DIR}/cmake/modules/Uninstall.cmake ${CMAKE_BINARY_DIR}/cmake_uninstall.cmake COPYONLY) 658 | add_custom_target(uninstall "${CMAKE_COMMAND}" -P "${CMAKE_BINARY_DIR}/cmake_uninstall.cmake") 659 | endif() 660 | 661 | # Export the package for use from the build tree 662 | export(TARGETS raw raw_r 663 | NAMESPACE libraw:: FILE cmake/${PROJECT_NAME}Targets.cmake) 664 | export(PACKAGE ${PROJECT_NAME}) 665 | 666 | include(CMakePackageConfigHelpers) 667 | write_basic_package_version_file( 668 | cmake/${PROJECT_NAME}ConfigVersion.cmake 669 | VERSION ${PROJECT_VERSION} 670 | COMPATIBILITY AnyNewerVersion) 671 | 672 | configure_package_config_file( 673 | cmake/${PROJECT_NAME}Config.cmake.in 674 | cmake/${PROJECT_NAME}Config.cmake 675 | INSTALL_DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake/) 676 | 677 | install(FILES 678 | ${CMAKE_CURRENT_BINARY_DIR}/cmake/${PROJECT_NAME}Config.cmake 679 | ${CMAKE_CURRENT_BINARY_DIR}/cmake/${PROJECT_NAME}ConfigVersion.cmake 680 | DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake/) 681 | 682 | install(EXPORT ${PROJECT_NAME}Targets 683 | NAMESPACE libraw:: DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake/) 684 | endif(LIBRAW_INSTALL) 685 | 686 | # -- Compile LibRaw Examples -------------------------------------------------------------------------------- 687 | 688 | # add a small macro so that this is a bit cleaner 689 | macro(LIBRAW_BUILD_SAMPLES) 690 | set(_filename ${ARGV0}) 691 | set(_rawlib ${ARGV1}) 692 | string(REPLACE "." ";" _temp ${_filename}) 693 | list(GET _temp 0 _target) 694 | 695 | set(${_target}_SRCS ${LIBRAW_PATH}/samples/${_filename}) 696 | 697 | add_executable(${_target} ${${_target}_SRCS}) 698 | target_compile_options(${_target} PRIVATE -w) 699 | 700 | target_link_libraries(${_target} PRIVATE ${_rawlib}) 701 | 702 | if(${_rawlib} MATCHES "raw_r") 703 | target_link_libraries(${_target} PUBLIC ${PTHREADS_LIBRARY}) 704 | endif() 705 | 706 | install(TARGETS ${_target} 707 | RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR} 708 | LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR} 709 | ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR} 710 | ) 711 | endmacro(LIBRAW_BUILD_SAMPLES) 712 | 713 | if(ENABLE_EXAMPLES) 714 | LIBRAW_BUILD_SAMPLES(simple_dcraw.cpp raw) 715 | 716 | if(EXISTS mem_image.cpp) 717 | LIBRAW_BUILD_SAMPLES(mem_image.cpp raw) 718 | else() 719 | LIBRAW_BUILD_SAMPLES(mem_image_sample.cpp raw) 720 | endif() 721 | 722 | LIBRAW_BUILD_SAMPLES(dcraw_emu.cpp raw) 723 | LIBRAW_BUILD_SAMPLES(4channels.cpp raw) 724 | LIBRAW_BUILD_SAMPLES(unprocessed_raw.cpp raw) 725 | LIBRAW_BUILD_SAMPLES(raw-identify.cpp raw) 726 | LIBRAW_BUILD_SAMPLES(multirender_test.cpp raw) 727 | LIBRAW_BUILD_SAMPLES(postprocessing_benchmark.cpp raw) 728 | 729 | if(TARGET Threads::Threads) 730 | if(MSVC) 731 | LIBRAW_BUILD_SAMPLES(half_mt_win32.c raw_r) 732 | else() 733 | LIBRAW_BUILD_SAMPLES(dcraw_half.c raw_r) 734 | LIBRAW_BUILD_SAMPLES(half_mt.c raw_r) 735 | endif() 736 | endif() 737 | endif() 738 | --------------------------------------------------------------------------------