Skip to content

Commit 01da687

Browse files
TurboGitcytrinox
authored andcommitted
Add LibRaw cmake support.
1 parent 559e1e1 commit 01da687

24 files changed

+1515
-13
lines changed

.gitmodules

+3
Original file line numberDiff line numberDiff line change
@@ -14,3 +14,6 @@
1414
[submodule "src/tests/integration"]
1515
path = src/tests/integration
1616
url = https://github.com/darktable-org/darktable-tests.git
17+
[submodule "src/external/LibRaw"]
18+
path = src/external/LibRaw
19+
url = https://github.com/LibRaw/LibRaw.git

src/CMakeLists.txt

+25-7
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ include(CheckCXXCompilerFlag)
55
include(CheckCSourceCompiles)
66
include(CheckCXXSymbolExists)
77

8+
89
#
910
# Add files for libdarktable
1011
#
@@ -382,14 +383,17 @@ if(USE_HEIF)
382383
endif()
383384
endif()
384385

386+
# For now we use the LibRaw submodule
385387
if (USE_LIBRAW)
386-
find_package(libraw 0.20.2)
387-
if (libraw_FOUND)
388-
list(APPEND LIBS ${libraw_LIBRARY})
389-
add_definitions(-DHAVE_LIBRAW=1)
390-
list(APPEND SOURCES "common/imageio_libraw.c")
391-
set(DT_SUPPORTED_EXTENSIONS ${DT_SUPPORTED_EXTENSIONS} libraw CACHE INTERNAL "")
392-
endif()
388+
# find_package(libraw 0.20.2)
389+
# if (libraw_FOUND)
390+
# list(APPEND LIBS ${libraw_LIBRARY})
391+
# add_definitions(-DHAVE_LIBRAW=1)
392+
# list(APPEND SOURCES "common/imageio_libraw.c")
393+
# set(DT_SUPPORTED_EXTENSIONS ${DT_SUPPORTED_EXTENSIONS} libraw CACHE INTERNAL "")
394+
# endif()
395+
add_definitions(-DHAVE_LIBRAW=1)
396+
list(APPEND SOURCES "common/imageio_libraw.c")
393397
endif()
394398

395399
if(USE_LENSFUN)
@@ -432,6 +436,10 @@ if (USE_ISOBMFF)
432436
# This must be manually enabled during exiv2 build and can be checked with
433437
# the EXV_ENABLE_BMFF symbol.
434438
check_cxx_symbol_exists(EXV_ENABLE_BMFF "exiv2/exiv2.hpp" HAVE_EXV_ENABLE_BMFF)
439+
# ??? This needs fix as we bypass the check for actual exiv2 version
440+
if(APPLE)
441+
set(HAVE_EXV_ENABLE_BMFF 1)
442+
endif()
435443
if(HAVE_EXV_ENABLE_BMFF)
436444
add_definitions(-DHAVE_LIBEXIV2_WITH_ISOBMFF=1)
437445
set(DT_SUPPORTED_EXTENSIONS ${DT_SUPPORTED_EXTENSIONS} cr3 CACHE INTERNAL "")
@@ -1033,3 +1041,13 @@ InstallDependencyFiles()
10331041

10341042
# Tell CPack about the components and group the data components together (CPACK_COMPONENT_${COMPONENT_NAME_ALL_CAPS}_GROUP).
10351043
set(CPACK_COMPONENTS_ALL DTApplication DTDebugSymbols DTDocuments)
1044+
1045+
if (USE_LIBRAW)
1046+
set(LIBRAW_PATH "${CMAKE_CURRENT_SOURCE_DIR}/external/LibRaw" CACHE STRING "Relative path to libraw directory (default=CMAKE_CURRENT_SOURCE_DIR)")
1047+
set(ENABLE_EXAMPLES OFF CACHE BOOLEAN "")
1048+
set(DT_SUPPORTED_EXTENSIONS ${DT_SUPPORTED_EXTENSIONS} libraw CACHE INTERNAL "")
1049+
1050+
# LibRaw sub-module
1051+
add_subdirectory(external/LibRaw-cmake)
1052+
target_link_libraries(lib_darktable PRIVATE libraw::libraw)
1053+
endif()

src/common/imageio_libraw.c

+5-5
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,7 @@ gboolean dt_libraw_lookup_makermodel(const char *maker, const char *model,
8383

8484
dt_imageio_retval_t dt_imageio_open_libraw(dt_image_t *img, const char *filename, dt_mipmap_buffer_t *mbuf)
8585
{
86-
int err;
86+
int err = 0;
8787
int libraw_err = 0;
8888
if(!_supported_image(filename)) return DT_IMAGEIO_FILE_CORRUPTED;
8989
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
131131
img->height = raw->sizes.raw_height;
132132

133133
// Apply crop parameters
134-
img->crop_x = raw->sizes.raw_inset_crop.cleft;
135-
img->crop_y = raw->sizes.raw_inset_crop.ctop;
136-
img->crop_width = raw->sizes.raw_width - raw->sizes.raw_inset_crop.cwidth - raw->sizes.raw_inset_crop.cleft;
137-
img->crop_height = raw->sizes.raw_height - raw->sizes.raw_inset_crop.cheight - raw->sizes.raw_inset_crop.ctop;
134+
img->crop_x = raw->sizes.raw_inset_crops[0].cleft;
135+
img->crop_y = raw->sizes.raw_inset_crops[0].ctop;
136+
img->crop_width = raw->sizes.raw_width - raw->sizes.raw_inset_crops[0].cwidth - raw->sizes.raw_inset_crops[0].cleft;
137+
img->crop_height = raw->sizes.raw_height - raw->sizes.raw_inset_crops[0].cheight - raw->sizes.raw_inset_crops[0].ctop;
138138

139139
// We can reuse the libraw filters property, it's already well-handled in dt.
140140
// It contains the BAYER filter pattern.

src/external/CMakeLists.txt

+1-1
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ add_subdirectory(rawspeed ${DARKTABLE_LIBDIR}/rawspeed)
4646
# Copying rawspeed resources to where dt expects them
4747
add_custom_target("deploy" ALL)
4848
SET(RAWSPEED_DATADIR "${CMAKE_CURRENT_SOURCE_DIR}/rawspeed/data")
49-
add_custom_command(TARGET "deploy" PRE_BUILD
49+
add_custom_command(TARGET "deploy" PRE_BUILD
5050
COMMAND ${CMAKE_COMMAND} -E make_directory ${DARKTABLE_DATADIR}/rawspeed/
5151
COMMAND ${CMAKE_COMMAND} -E copy ${RAWSPEED_DATADIR}/cameras.xml ${RAWSPEED_DATADIR}/showcameras.xsl ${DARKTABLE_DATADIR}/rawspeed/
5252
)

src/external/LibRaw

Submodule LibRaw added at 5bc2c67
+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
* text=auto
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
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

src/external/LibRaw-cmake/.gitignore

+2
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
/.project
2+
build

0 commit comments

Comments
 (0)