From 094678885c654d246fd4aa3ebe9d3fcaa83e7c36 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Dan=20Hor=C3=A1k?= Date: Mon, 2 Jan 2017 14:13:00 +0100 Subject: [PATCH 1/5] use system KLT library if available --- CMakeLists.txt | 1 + cmake/modules/FindKLT.cmake | 73 +++++++++++++++++++++++++++++++++++++ rtengine/CMakeLists.txt | 12 ++++-- 3 files changed, 83 insertions(+), 3 deletions(-) create mode 100644 cmake/modules/FindKLT.cmake diff --git a/CMakeLists.txt b/CMakeLists.txt index 0173856b1..2efcd619b 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -256,6 +256,7 @@ find_package (JPEG REQUIRED) find_package (PNG REQUIRED) find_package (TIFF REQUIRED) find_package (ZLIB REQUIRED) +find_package (KLT) # link witz bzip if (WITH_BZIP) diff --git a/cmake/modules/FindKLT.cmake b/cmake/modules/FindKLT.cmake new file mode 100644 index 000000000..d01214645 --- /dev/null +++ b/cmake/modules/FindKLT.cmake @@ -0,0 +1,73 @@ +# - Try to find KLT +# Once done this will define +# +# KLT_FOUND - system has KLT +# KLT_INCLUDE_DIRS - the KLT include directory +# KLT_LIBRARIES - Link these to use KLT +# KLT_DEFINITIONS - Compiler switches required for using KLT +# +# Copyright (c) 2009 Andreas Schneider +# updated for KLT by Dan HorĂ¡k +# +# Redistribution and use is allowed according to the terms of the New +# BSD license. +# For details see the accompanying COPYING-CMAKE-SCRIPTS file. +# + + +if (KLT_LIBRARIES AND KLT_INCLUDE_DIRS) + # in cache already + set(KLT_FOUND TRUE) +else (KLT_LIBRARIES AND KLT_INCLUDE_DIRS) + + find_path(KLT_INCLUDE_DIR + NAMES + klt.h + PATHS + /usr/include + /usr/local/include + /opt/local/include + /sw/include + ${CMAKE_INSTALL_PREFIX}/include + PATH_SUFFIXES + klt + ) + mark_as_advanced(KLT_INCLUDE_DIR) + + find_library(KLT_LIBRARY + NAMES + klt + PATHS + /usr/lib64 + /usr/lib + /usr/local/lib + /opt/local/lib + /sw/lib + ${CMAKE_INSTALL_PREFIX}/lib + ) + mark_as_advanced(KLT_LIBRARY) + + set(KLT_INCLUDE_DIRS + ${KLT_INCLUDE_DIR} + ) + + set(KLT_LIBRARIES + ${KLT_LIBRARY} + ) + + if (KLT_INCLUDE_DIRS AND KLT_LIBRARIES) + set(KLT_FOUND TRUE) + endif (KLT_INCLUDE_DIRS AND KLT_LIBRARIES) + + if (KLT_FOUND) + if (NOT KLT_FIND_QUIETLY) + message(STATUS "Found KLT: ${KLT_LIBRARIES}") + endif (NOT KLT_FIND_QUIETLY) + else (KLT_FOUND) + message(STATUS "Could not find KLT, using internal code.") + endif (KLT_FOUND) + + mark_as_advanced(KLT_INCLUDE_DIRS KLT_LIBRARIES) + +endif (KLT_LIBRARIES AND KLT_INCLUDE_DIRS) + diff --git a/rtengine/CMakeLists.txt b/rtengine/CMakeLists.txt index 477ccecae..734780a06 100644 --- a/rtengine/CMakeLists.txt +++ b/rtengine/CMakeLists.txt @@ -20,12 +20,18 @@ set (RTENGINESOURCEFILES colortemp.cc curves.cc flatcurves.cc diagonalcurves.cc dirpyr_equalizer.cc calc_distort.cc lcp.cc dcp.cc ipretinex.cc cJSON.c camconst.cc - klt/convolve.cc klt/error.cc klt/klt.cc klt/klt_util.cc klt/pnmio.cc klt/pyramid.cc klt/selectGoodFeatures.cc - klt/storeFeatures.cc klt/trackFeatures.cc klt/writeFeatures.cc clutstore.cc ciecam02.cc ) +if (NOT KLT_FOUND) + set (RTENGINESOURCEFILES ${RTENGINESOURCEFILES} + klt/convolve.cc klt/error.cc klt/klt.cc klt/klt_util.cc klt/pnmio.cc klt/pyramid.cc klt/selectGoodFeatures.cc + klt/storeFeatures.cc klt/trackFeatures.cc klt/writeFeatures.cc + ) + set (KLT_LIBRARIES) +endif () + include_directories (BEFORE "${CMAKE_CURRENT_BINARY_DIR}") add_library (rtengine ${RTENGINESOURCEFILES}) @@ -40,6 +46,6 @@ set_target_properties (rtengine PROPERTIES COMPILE_FLAGS "${RTENGINE_CXX_FLAGS}" target_link_libraries (rtengine rtexif ${EXTRA_LIB} ${GOBJECT_LIBRARIES} ${GTHREAD_LIBRARIES} ${GLIB2_LIBRARIES} ${GLIBMM_LIBRARIES} ${LCMS_LIBRARIES} ${EXPAT_LIBRARIES} ${FFTW3F_LIBRARIES} ${IPTCDATA_LIBRARIES} - ${JPEG_LIBRARIES} ${PNG_LIBRARIES} ${TIFF_LIBRARIES} ${ZLIB_LIBRARIES}) + ${JPEG_LIBRARIES} ${PNG_LIBRARIES} ${TIFF_LIBRARIES} ${ZLIB_LIBRARIES} ${KLT_LIBRARIES}) install (FILES ${CAMCONSTSFILE} DESTINATION "${DATADIR}" PERMISSIONS OWNER_WRITE OWNER_READ GROUP_READ WORLD_READ) From 6b814115615b26b44fab3195d57b5d57ae63b92d Mon Sep 17 00:00:00 2001 From: Mattia Verga Date: Mon, 5 Jun 2017 17:59:36 +0200 Subject: [PATCH 2/5] Use option to let user choose to use system's KLT --- CMakeLists.txt | 5 ++++- rtengine/CMakeLists.txt | 2 +- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 2efcd619b..b77b688e7 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -256,7 +256,10 @@ find_package (JPEG REQUIRED) find_package (PNG REQUIRED) find_package (TIFF REQUIRED) find_package (ZLIB REQUIRED) -find_package (KLT) +option(USE_SYSTEM_KLT "Enable this option here or in cmake call if you want to use system's KLT libraries." OFF) +if (USE_SYSTEM_KLT) + find_package (KLT REQUIRED) +endif(USE_SYSTEM_KLT) # link witz bzip if (WITH_BZIP) diff --git a/rtengine/CMakeLists.txt b/rtengine/CMakeLists.txt index 734780a06..a30c19d2d 100644 --- a/rtengine/CMakeLists.txt +++ b/rtengine/CMakeLists.txt @@ -24,7 +24,7 @@ set (RTENGINESOURCEFILES colortemp.cc curves.cc flatcurves.cc diagonalcurves.cc ciecam02.cc ) -if (NOT KLT_FOUND) +if (NOT USE_SYSTEM_KLT) set (RTENGINESOURCEFILES ${RTENGINESOURCEFILES} klt/convolve.cc klt/error.cc klt/klt.cc klt/klt_util.cc klt/pnmio.cc klt/pyramid.cc klt/selectGoodFeatures.cc klt/storeFeatures.cc klt/trackFeatures.cc klt/writeFeatures.cc From a5e2107e40c4ab7c074e38d5bb1136b8fb0cc5be Mon Sep 17 00:00:00 2001 From: Mattia Verga Date: Mon, 5 Jun 2017 20:01:56 +0200 Subject: [PATCH 3/5] change klt not found message --- cmake/modules/FindKLT.cmake | 2 +- rtengine/CMakeLists.txt | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/cmake/modules/FindKLT.cmake b/cmake/modules/FindKLT.cmake index d01214645..d2aa773d9 100644 --- a/cmake/modules/FindKLT.cmake +++ b/cmake/modules/FindKLT.cmake @@ -64,7 +64,7 @@ else (KLT_LIBRARIES AND KLT_INCLUDE_DIRS) message(STATUS "Found KLT: ${KLT_LIBRARIES}") endif (NOT KLT_FIND_QUIETLY) else (KLT_FOUND) - message(STATUS "Could not find KLT, using internal code.") + message(STATUS "KLT not found.") endif (KLT_FOUND) mark_as_advanced(KLT_INCLUDE_DIRS KLT_LIBRARIES) diff --git a/rtengine/CMakeLists.txt b/rtengine/CMakeLists.txt index db02a9d4e..068d42a94 100644 --- a/rtengine/CMakeLists.txt +++ b/rtengine/CMakeLists.txt @@ -119,7 +119,7 @@ if (NOT USE_SYSTEM_KLT) set (KLT_LIBRARIES) endif () -include_directories (BEFORE "${CMAKE_CURRENT_BINARY_DIR}") +include_directories(BEFORE "${CMAKE_CURRENT_BINARY_DIR}") add_library(rtengine ${RTENGINESOURCEFILES}) add_dependencies(rtengine UpdateInfo) From 75812c900e58ee1c00ac732b0488409bd3cf9e17 Mon Sep 17 00:00:00 2001 From: Mattia Verga Date: Tue, 6 Jun 2017 10:20:37 +0200 Subject: [PATCH 4/5] Move and rename option accordingly to other already present --- CMakeLists.txt | 6 +++--- rtengine/CMakeLists.txt | 2 +- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 9c7cb8fcb..3f0723b93 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -113,6 +113,7 @@ option(WITH_MYFILE_MMAP "Build using memory mapped file" ON) option(WITH_LTO "Build with link-time optimizations" OFF) option(WITH_SAN "Build with run-time sanitizer" OFF) option(WITH_PROF "Build with profiling instrumentation" OFF) +option(WITH_SYSTEM_KLT "Build using system's KLT libraries." OFF) option(OPTION_OMP "Build with OpenMP support" ON) option(STRICT_MUTEX "True (recommended): MyMutex will behave like POSIX Mutex; False: MyMutex will behave like POSIX RecMutex; Note: forced to ON for Debug builds" ON) option(TRACE_MYRWMUTEX "Trace custom R/W Mutex (Debug builds only); redirecting std::out to a file is strongly recommended!" OFF) @@ -293,10 +294,9 @@ find_package(JPEG REQUIRED) find_package(PNG REQUIRED) find_package(TIFF REQUIRED) find_package(ZLIB REQUIRED) -option(USE_SYSTEM_KLT "Enable this option here or in cmake call if you want to use system's KLT libraries." OFF) -if (USE_SYSTEM_KLT) +if (WITH_SYSTEM_KLT) find_package (KLT REQUIRED) -endif(USE_SYSTEM_KLT) +endif(WITH_SYSTEM_KLT) # Link with bzip: if(WITH_BZIP) diff --git a/rtengine/CMakeLists.txt b/rtengine/CMakeLists.txt index 068d42a94..ea085d60e 100644 --- a/rtengine/CMakeLists.txt +++ b/rtengine/CMakeLists.txt @@ -111,7 +111,7 @@ set(RTENGINESOURCEFILES utils.cc ) -if (NOT USE_SYSTEM_KLT) +if (NOT WITH_SYSTEM_KLT) set (RTENGINESOURCEFILES ${RTENGINESOURCEFILES} klt/convolve.cc klt/error.cc klt/klt.cc klt/klt_util.cc klt/pnmio.cc klt/pyramid.cc klt/selectGoodFeatures.cc klt/storeFeatures.cc klt/trackFeatures.cc klt/writeFeatures.cc From cbb6bceb632e093d047811ee98c954baa8fbe7b2 Mon Sep 17 00:00:00 2001 From: Mattia Verga Date: Wed, 7 Jun 2017 07:40:48 +0200 Subject: [PATCH 5/5] Fix endif format and indentation --- CMakeLists.txt | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 3f0723b93..0b4f1284a 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -295,8 +295,8 @@ find_package(PNG REQUIRED) find_package(TIFF REQUIRED) find_package(ZLIB REQUIRED) if (WITH_SYSTEM_KLT) - find_package (KLT REQUIRED) -endif(WITH_SYSTEM_KLT) + find_package (KLT REQUIRED) +endif() # Link with bzip: if(WITH_BZIP)