diff --git a/CMakeLists.txt b/CMakeLists.txt new file mode 100644 index 0000000..56eb73a --- /dev/null +++ b/CMakeLists.txt @@ -0,0 +1,81 @@ +############################################ +# # +# Improvements and feedbacks are welcome # +# # +# This file is released under GPL >= 3 # +# # +############################################ + + +cmake_minimum_required( VERSION 2.8.12 ) + + +#### general package setup + +project( libkdcraw ) +set( VERSION R14.1.0 ) + + +#### include essential cmake modules + +include( FindPkgConfig ) +include( CheckFunctionExists ) +include( CheckSymbolExists ) +include( CheckIncludeFile ) +include( CheckIncludeFileCXX ) +include( CheckLibraryExists ) +include( CheckCSourceCompiles ) +include( CheckCXXSourceCompiles ) + + +#### include our cmake modules + +set( CMAKE_MODULE_PATH "${CMAKE_SOURCE_DIR}/cmake/modules" ) +include( TDEMacros ) + + +##### setup install paths + +include( TDESetupPaths ) +tde_setup_paths( ) + + +##### optional stuff + +option( WITH_ALL_OPTIONS "Enable all optional support" OFF ) +option( WITH_GCC_VISIBILITY "Enable fvisibility and fvisibility-inlines-hidden" ${WITH_ALL_OPTIONS} ) +option( WITH_LCMS "Enable lcms support" ${WITH_ALL_OPTIONS} ) +option( WITH_OPENMP "Enable OpenMP support" ${WITH_ALL_OPTIONS} ) + + +##### user requested modules + +option( BUILD_ALL "Build all" ON ) +option( BUILD_KDCRAW "Build kdcraw program" OFF ) +option( BUILD_TESTS "Build test programs" OFF ) +option( BUILD_TRANSLATIONS "Build translations" ${BUILD_ALL} ) + + +##### configure checks + +include( ConfigureChecks.cmake ) + + +###### global compiler settings + +add_definitions( -DHAVE_CONFIG_H ) + +set( CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${TQT_CXX_FLAGS}" ) +set( CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} -Wl,--no-undefined" ) +set( CMAKE_MODULE_LINKER_FLAGS "${CMAKE_MODULE_LINKER_FLAGS} -Wl,--no-undefined" ) + + +##### directories + +add_subdirectory( ${PROJECT_NAME} ) +tde_conditional_add_subdirectory( BUILD_TRANSLATIONS po ) + + +##### write configure files + +configure_file( config.h.cmake config.h @ONLY ) diff --git a/ConfigureChecks.cmake b/ConfigureChecks.cmake new file mode 100644 index 0000000..d595f93 --- /dev/null +++ b/ConfigureChecks.cmake @@ -0,0 +1,80 @@ +########################################### +# # +# Improvements and feedback are welcome # +# # +# This file is released under GPL >= 3 # +# # +########################################### + +# required stuff +find_package( TQt ) +find_package( TDE ) + +tde_setup_architecture_flags( ) + +include(TestBigEndian) +test_big_endian(WORDS_BIGENDIAN) + +tde_setup_largefiles( ) + + +##### check for gcc visibility support + +if( WITH_GCC_VISIBILITY ) + tde_setup_gcc_visibility( ) +endif( WITH_GCC_VISIBILITY ) + + +##### check for lcms + +if( WITH_LCMS ) + check_include_file( lcms2.h HAVE_LCMS2_H ) + if( HAVE_LCMS2_H ) + pkg_search_module( LCMS lcms2 ) + set( LCMS_HEADER lcms2.h ) + else() + check_include_file( lcms.h HAVE_LCMS_H ) + if( HAVE_LCMS_H ) + pkg_search_module( LCMS lcms ) + set( LCMS_HEADER lcms.h ) + else() + tde_message_fatal( "lcms is requested, but was not found on your system" ) + endif() + endif() + set( USE_LCMS 1 ) +endif( WITH_LCMS ) + + +##### check for OpenMP + +if( WITH_OPENMP ) + if( CMAKE_CXX_COMPILER_ID MATCHES "GNU" ) + find_package( OpenMP ) + if( OPENMP_FOUND ) + set( CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${OpenMP_C_FLAGS}" ) + set( CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${OpenMP_CXX_FLAGS}" ) + else() + tde_message_fatal( "OpenMP is requested, but was not found on your system" ) + endif() + else() + tde_message_fatal( "OpenMP build is available for the GNU GCC compiler only" ) + endif() +endif( WITH_OPENMP ) + + +##### check for jpeg + +if( BUILD_KDCRAW ) + find_package( JPEG ) + + if( JPEG_FOUND ) + set( HAVE_JPEG 1 ) + else() + tde_message_fatal( "jpeg library is required, but was not found on your system" ) + endif() + +##### check for the math libc + + find_library( MATH_LIBC m ) + +endif( BUILD_KDCRAW ) diff --git a/config.h.cmake b/config.h.cmake new file mode 100644 index 0000000..cf3d263 --- /dev/null +++ b/config.h.cmake @@ -0,0 +1,17 @@ +#define VERSION "@VERSION@" + +// Defined if you have fvisibility and fvisibility-inlines-hidden support. +#cmakedefine __KDE_HAVE_GCC_VISIBILITY 1 + +/* Define WORDS_BIGENDIAN to 1 if your processor stores words with the most + significant byte first (like Motorola and SPARC, unlike Intel). */ +#cmakedefine WORDS_BIGENDIAN @WORDS_BIGENDIAN@ + +/* Define lcms header */ +#cmakedefine LCMS_HEADER <@LCMS_HEADER@> + +/* Defined for lcms support */ +#cmakedefine USE_LCMS 1 + +/* Defined if you have jpeg library */ +#cmakedefine HAVE_JPEG 1 diff --git a/libkdcraw/CMakeLists.txt b/libkdcraw/CMakeLists.txt new file mode 100644 index 0000000..4a7cf1f --- /dev/null +++ b/libkdcraw/CMakeLists.txt @@ -0,0 +1,20 @@ +add_subdirectory( libraw ) +add_subdirectory( libkdcraw ) +add_subdirectory( icons ) + +tde_conditional_add_subdirectory( BUILD_TESTS test ) +tde_conditional_add_subdirectory( BUILD_KDCRAW dcraw ) + + +##### other data + +string( REGEX REPLACE "^${CMAKE_INSTALL_PREFIX}" "\${prefix}" PC_EXEC_PREFIX ${EXEC_INSTALL_PREFIX} ) +string( REGEX REPLACE "^${CMAKE_INSTALL_PREFIX}" "\${prefix}" PC_INCLUDE_DIR ${INCLUDE_INSTALL_DIR} ) +string( REGEX REPLACE "^${CMAKE_INSTALL_PREFIX}" "\${prefix}" PC_LIB_DIR ${LIB_INSTALL_DIR} ) + +configure_file( ${PROJECT_NAME}.pc.cmake ${PROJECT_NAME}.pc @ONLY ) + +install( + FILES ${CMAKE_CURRENT_BINARY_DIR}/${PROJECT_NAME}.pc + DESTINATION ${PKGCONFIG_INSTALL_DIR} +) diff --git a/libkdcraw/dcraw/CMakeLists.txt b/libkdcraw/dcraw/CMakeLists.txt new file mode 100644 index 0000000..c24bfaa --- /dev/null +++ b/libkdcraw/dcraw/CMakeLists.txt @@ -0,0 +1,38 @@ +include_directories( + ${CMAKE_BINARY_DIR} + ${CMAKE_CURRENT_BINARY_DIR} + ${CMAKE_CURRENT_SOURCE_DIR} + ${TDE_INCLUDE_DIR} + ${TQT_INCLUDE_DIRS} + ${LCMS_INCLUDE_DIRS} + ${JPEG_INCLUDE_DIR} +) + +link_directories( + ${TQT_LIBRARY_DIRS} + ${TDE_LIB_DIR} +) + + +##### kdcraw (executable) + +tde_add_executable( kdcraw + + SOURCES + dcraw.c + LINK + ${LCMS_LIBRARIES} + ${JPEG_LIBRARIES} + ${MATH_LIBC} + + DESTINATION ${BIN_INSTALL_DIR} +) + + +##### other data + +INSTALL( + FILES kdcraw.1 + DESTINATION ${MAN_INSTALL_DIR}/man1 + COMPONENT doc +) diff --git a/libkdcraw/dcraw/dcraw.c b/libkdcraw/dcraw/dcraw.c index 2b55333..70964cd 100644 --- a/libkdcraw/dcraw/dcraw.c +++ b/libkdcraw/dcraw/dcraw.c @@ -22,10 +22,12 @@ $Revision: 1.399 $ $Date: 2008/03/05 01:29:34 $ */ +#ifdef HAVE_CONFIG_H +#include "config.h" +#endif -#define VERSION "8.83" +#define DCRAW_VERSION "8.83" -#define _GNU_SOURCE #define _USE_MATH_DEFINES #include #include @@ -39,12 +41,14 @@ #include #include #include +#include + /* NO_JPEG disables decoding of compressed Kodak DC120 files. NO_LCMS disables the "-p" option. */ -#include "config.h" -#ifndef NO_JPEG + +#ifdef HAVE_JPEG #include #endif #ifndef NO_LCMS @@ -100,6 +104,10 @@ typedef unsigned short ushort; access them are prefixed with "CLASS". Note that a thread-safe C++ class cannot have non-const static local variables. */ + +void swab(const void *restrict from, void *restrict to, ssize_t n); +void *memmem(const void *haystack, size_t haystacklen, const void *needle, size_t needlelen); + FILE *ifp; short order; char *ifname, *meta_data; @@ -2216,7 +2224,7 @@ void CLASS kodak_radc_load_raw() #undef FORYX #undef PREDICTOR -#ifdef NO_JPEG +#ifdef HAVE_JPEG void CLASS kodak_jpeg_load_raw() {} #else @@ -7641,7 +7649,7 @@ qt_common: } dng_skip: if (!load_raw || height < 22) is_raw = 0; -#ifdef NO_JPEG +#ifdef HAVE_JPEG if (load_raw == kodak_jpeg_load_raw) { fprintf (stderr,_("%s: You must link dcraw with libjpeg!!\n"), ifname); is_raw = 0; @@ -8044,7 +8052,7 @@ void CLASS tiff_head (struct tiff_hdr *th, int full) strncpy (th->desc, desc, 512); strncpy (th->make, make, 64); strncpy (th->model, model, 64); - strcpy (th->soft, "dcraw v"VERSION); + strcpy (th->soft, "dcraw v" DCRAW_VERSION); t = gmtime (×tamp); sprintf (th->date, "%04d:%02d:%02d %02d:%02d:%02d", t->tm_year+1900,t->tm_mon+1,t->tm_mday,t->tm_hour,t->tm_min,t->tm_sec); diff --git a/libkdcraw/icons/CMakeLists.txt b/libkdcraw/icons/CMakeLists.txt new file mode 100644 index 0000000..643654c --- /dev/null +++ b/libkdcraw/icons/CMakeLists.txt @@ -0,0 +1,3 @@ +##### icons + +tde_install_icons() diff --git a/libkdcraw/libkdcraw.pc.cmake b/libkdcraw/libkdcraw.pc.cmake new file mode 100644 index 0000000..46b826a --- /dev/null +++ b/libkdcraw/libkdcraw.pc.cmake @@ -0,0 +1,12 @@ +prefix=@CMAKE_INSTALL_PREFIX@ +exec_prefix=@PC_EXEC_PREFIX@ +libdir=@PC_LIB_DIR@ +includedir=@PC_INCLUDE_DIR@ + +Name: @PROJECT_NAME@ +Description: A C++ wrapper around LibRaw library to decode RAW pictures. This library is used by digiKam and kipi-plugins. +URL: https://mirror.git.trinitydesktop.org/gitea/TDE/libkdcraw +Requires: +Version: 0.1.9 +Libs: -L${libdir} -lkdcraw +Cflags: -I${includedir} diff --git a/libkdcraw/libkdcraw/CMakeLists.txt b/libkdcraw/libkdcraw/CMakeLists.txt new file mode 100644 index 0000000..0230ad0 --- /dev/null +++ b/libkdcraw/libkdcraw/CMakeLists.txt @@ -0,0 +1,49 @@ +include_directories( + ${CMAKE_BINARY_DIR} + ${CMAKE_CURRENT_BINARY_DIR} + ${CMAKE_CURRENT_SOURCE_DIR} + ${TDE_INCLUDE_DIR} + ${TQT_INCLUDE_DIRS} + ${CMAKE_SOURCE_DIR}/libkdcraw/libraw +) + +link_directories( + ${TQT_LIBRARY_DIRS} + ${TDE_LIB_DIR} +) + +set( _SRC_ kdcraw.cpp + kdcrawprivate.cpp + dcrawsettingswidget.cpp + rnuminput.cpp + rcombobox.cpp +) + + +##### kdcraw (shared) + +tde_add_library( kdcraw SHARED AUTOMOC + + SOURCES + ${_SRC_} + LINK + tdeui-shared + tdecore-shared + tdeio-shared + raw-static + + VERSION 4.0.3 + + DESTINATION ${LIB_INSTALL_DIR} +) + + +##### headers + +install( + FILES rawdecodingsettings.h kdcraw.h dcrawsettingswidget.h + rnuminput.h rcombobox.h dcrawinfocontainer.h rawfiles.h + libkdcraw_export.h version.h + + DESTINATION ${INCLUDE_INSTALL_DIR}/${PROJECT_NAME} +) diff --git a/libkdcraw/libkdcraw/libkdcraw_export.h b/libkdcraw/libkdcraw/libkdcraw_export.h index a7eeef2..8e73374 100644 --- a/libkdcraw/libkdcraw/libkdcraw_export.h +++ b/libkdcraw/libkdcraw/libkdcraw_export.h @@ -28,10 +28,16 @@ #endif #ifdef KDE_EXPORT -#define LIBKDCRAW_EXPORT KDE_EXPORT +# define LIBKDCRAW_NO_EXPORT KDE_NO_EXPORT +# define LIBKDCRAW_EXPORT KDE_EXPORT #else -#define LIBKDCRAW_EXPORT +# ifdef __KDE_HAVE_GCC_VISIBILITY +# define LIBKDCRAW_NO_EXPORT __attribute__ ((visibility("hidden"))) +# define LIBKDCRAW_EXPORT __attribute__ ((visibility("default"))) +# else +# define LIBKDCRAW_NO_EXPORT +# define LIBKDCRAW_EXPORT +# endif #endif #endif /* _LIBKDCRAW_EXPORT_H */ - diff --git a/libkdcraw/libraw/CMakeLists.txt b/libkdcraw/libraw/CMakeLists.txt new file mode 100644 index 0000000..5ef466a --- /dev/null +++ b/libkdcraw/libraw/CMakeLists.txt @@ -0,0 +1,29 @@ +include_directories( + ${CMAKE_BINARY_DIR} + ${CMAKE_CURRENT_BINARY_DIR} + ${CMAKE_CURRENT_SOURCE_DIR} + ${TDE_INCLUDE_DIR} + ${TQT_INCLUDE_DIRS} + ${LCMS_INCLUDE_DIRS} +) + +link_directories( + ${TQT_LIBRARY_DIRS} + ${TDE_LIB_DIR} +) + + +##### raw (static) + +tde_add_library( raw STATIC_PIC AUTOMOC + + SOURCES + src/libraw_cxx.cpp + src/libraw_c_api.cpp + internal/dcraw_common.cpp + internal/dcraw_fileio.cpp + internal/foveon.cpp + LINK + ${LCMS_LIBRARIES} + +) diff --git a/libkdcraw/libraw/internal/dcraw_common.cpp b/libkdcraw/libraw/internal/dcraw_common.cpp index 13fa1df..215a76b 100644 --- a/libkdcraw/libraw/internal/dcraw_common.cpp +++ b/libkdcraw/libraw/internal/dcraw_common.cpp @@ -4,6 +4,9 @@ Look into original file (probably http://cybercom.net/~dcoffin/dcraw/dcraw.c) for copyright information. */ +#ifdef HAVE_CONFIG_H +#include "config.h" +#endif #define CLASS LibRaw:: #include "libraw/libraw_types.h" @@ -8190,7 +8193,7 @@ void CLASS tiff_head (struct tiff_hdr *th, int full) strncpy (th->t_desc, desc, 512); strncpy (th->t_make, make, 64); strncpy (th->t_model, model, 64); - strcpy (th->soft, "dcraw v" VERSION); + strcpy (th->soft, "dcraw v" DCRAW_VERSION); t = gmtime (×tamp); sprintf (th->date, "%04d:%02d:%02d %02d:%02d:%02d", t->tm_year+1900,t->tm_mon+1,t->tm_mday,t->tm_hour,t->tm_min,t->tm_sec); diff --git a/libkdcraw/libraw/internal/defines.h b/libkdcraw/libraw/internal/defines.h index 462874a..9986b2f 100644 --- a/libkdcraw/libraw/internal/defines.h +++ b/libkdcraw/libraw/internal/defines.h @@ -4,12 +4,14 @@ Look into original file (probably http://cybercom.net/~dcoffin/dcraw/dcraw.c) for copyright information. */ +#ifdef HAVE_CONFIG_H +#include "config.h" +#endif #define NO_JPEG -#define VERSION "8.93" - -#define _GNU_SOURCE +#define DCRAW_VERSION "8.93" #define _USE_MATH_DEFINES + #include #include #include @@ -22,6 +24,7 @@ #include #include #include + #ifdef _OPENMP #include #endif @@ -29,7 +32,6 @@ NO_JPEG disables decoding of compressed Kodak DC120 files. NO_LCMS disables the "-p" option. */ -#include "config.h" #ifndef NO_JPEG #include #endif diff --git a/libkdcraw/libraw/libraw/libraw.h b/libkdcraw/libraw/libraw/libraw.h index 10c2683..8e64345 100644 --- a/libkdcraw/libraw/libraw/libraw.h +++ b/libkdcraw/libraw/libraw/libraw.h @@ -24,6 +24,10 @@ #ifndef _LIBRAW_CLASS_H #define _LIBRAW_CLASS_H +#ifdef HAVE_CONFIG_H +#include "config.h" +#endif + #include #include #include diff --git a/libkdcraw/libraw/libraw/libraw_types.h b/libkdcraw/libraw/libraw/libraw_types.h index c666939..2a9e1bc 100644 --- a/libkdcraw/libraw/libraw/libraw_types.h +++ b/libkdcraw/libraw/libraw/libraw_types.h @@ -24,6 +24,10 @@ #ifndef _LIBRAW_TYPES_H #define _LIBRAW_TYPES_H +#ifdef HAVE_CONFIG_H +#include "config.h" +#endif + #ifndef WIN32 #include #endif diff --git a/libkdcraw/libraw/samples/dcraw_emu.cpp b/libkdcraw/libraw/samples/dcraw_emu.cpp index bf82efa..f882805 100644 --- a/libkdcraw/libraw/samples/dcraw_emu.cpp +++ b/libkdcraw/libraw/samples/dcraw_emu.cpp @@ -20,6 +20,10 @@ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA * 02110-1301, USA. */ +#ifdef HAVE_CONFIG_H +#include "config.h" +#endif + #include #include #include @@ -37,6 +41,9 @@ #define snprintf _snprintf #endif +#ifdef _OPENMP +#include +#endif void usage(const char *prog) { diff --git a/libkdcraw/test/CMakeLists.txt b/libkdcraw/test/CMakeLists.txt new file mode 100644 index 0000000..c412d45 --- /dev/null +++ b/libkdcraw/test/CMakeLists.txt @@ -0,0 +1,66 @@ +include_directories( + ${CMAKE_BINARY_DIR} + ${CMAKE_CURRENT_BINARY_DIR} + ${CMAKE_CURRENT_SOURCE_DIR} + ${CMAKE_SOURCE_DIR}/libkdcraw/libraw + ${CMAKE_SOURCE_DIR}/libkdcraw/libkdcraw +) + + +##### test programs + +tde_add_executable( raw2png AUTOMOC + + SOURCES + raw2png.cpp + LINK + kdcraw-shared +) + +tde_add_executable( identify AUTOMOC + + SOURCES + ../libraw/samples/identify.cpp + LINK + raw-static +) + +tde_add_executable( simple_dcraw AUTOMOC + + SOURCES + ../libraw/samples/simple_dcraw.cpp + LINK + raw-static +) + +tde_add_executable( mem_image AUTOMOC + + SOURCES + ../libraw/samples/mem_image.cpp + LINK + raw-static +) + +tde_add_executable( 4channels AUTOMOC + + SOURCES + ../libraw/samples/4channels.cpp + LINK + raw-static +) + +tde_add_executable( unprocessed_raw AUTOMOC + + SOURCES + ../libraw/samples/unprocessed_raw.cpp + LINK + raw-static +) + +tde_add_executable( dcraw_emu AUTOMOC + + SOURCES + ../libraw/samples/dcraw_emu.cpp + LINK + raw-static +) diff --git a/libkdcraw/test/raw2png.cpp b/libkdcraw/test/raw2png.cpp index 4828264..3c13555 100644 --- a/libkdcraw/test/raw2png.cpp +++ b/libkdcraw/test/raw2png.cpp @@ -28,17 +28,9 @@ // KDE includes. -#include "tdeversion.h" - -#if KDE_IS_VERSION(4,0,0) -#include "tqdebug.h" -#define PRINT_DEBUG tqDebug() -#define ENDL -#else -#include "kdebug.h" +#include #define PRINT_DEBUG kdDebug() #define ENDL << endl -#endif // Local includes. diff --git a/po/CMakeLists.txt b/po/CMakeLists.txt new file mode 100644 index 0000000..0e8b8f9 --- /dev/null +++ b/po/CMakeLists.txt @@ -0,0 +1,8 @@ +file( GLOB_RECURSE po_files RELATIVE ${CMAKE_CURRENT_SOURCE_DIR} ./*/*.po ) + +foreach( _po ${po_files} ) + string( REGEX REPLACE "/.*" "" _lang ${_po} ) + if( "${_linguas}" MATCHES "^;*$" OR ";${_linguas};" MATCHES ";${_lang};" ) + tde_create_translation( FILES ${_po} LANG ${_lang} ) + endif() +endforeach()