1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349
|
cmake_minimum_required (VERSION 3.5.0)
project(pfstools)
set(CPACK_GENERATOR TGZ)
set(CPACK_SOURCE_GENERATOR TGZ)
# CPack version numbers for release tarball name.
set(CPACK_PACKAGE_VERSION_MAJOR 2)
set(CPACK_PACKAGE_VERSION_MINOR 1)
set(CPACK_PACKAGE_VERSION_PATCH 0)
set(CPACK_SOURCE_IGNORE_FILES
"~$"
"\\\\.cvsignore$"
"^${PROJECT_SOURCE_DIR}.*/CVS/"
"^${PROJECT_SOURCE_DIR}/debian/"
"^${PROJECT_SOURCE_DIR}/old/"
)
include( CPack )
#cmake_policy(SET CMP0074 NEW)
# This gets rid of some warning messages in MSVC
add_definitions(-D_CRT_SECURE_NO_WARNINGS)
#SET(ZLIB_DIR "C:/Users/manti/Documents/projects/vs2019_libs")
#SET(CMAKE_INCLUDE_PATH ${ZLIB_DIR}/include ${CMAKE_INCLUDE_PATH})
#SET(CMAKE_LIBRARY_PATH ${ZLIB_DIR}/ ${ZLIB_DIR}/lib ${CMAKE_LIBRARY_PATH})
#set(CMAKE_PREFIX_PATH "C:\\Qt\\5.15.2\\msvc2019_64")
if( "${CYGWIN}" STREQUAL "" )
set(CYGWIN 0)
endif( "${CYGWIN}" STREQUAL "" )
set (pfstools_VERSION_MAJOR ${CPACK_PACKAGE_VERSION_MAJOR})
set (pfstools_VERSION_MINOR ${CPACK_PACKAGE_VERSION_MINOR}.${CPACK_PACKAGE_VERSION_PATCH})
set (pfslib_version 1.2)
set(CMAKE_LEGACY_CYGWIN_WIN32 0)
set (MAN_DIR "${CMAKE_INSTALL_PREFIX}/share/man/man1" CACHE PATH "The directory where the man pages are")
include( CheckCXXSourceCompiles )
# ======== Check for OpenMP =======
find_package(OpenMP)
if( OPENMP_FOUND )
set( HAVE_OpenMP 1 )
else( OPENMP_FOUND )
set( HAVE_OpenMP 0 )
endif( OPENMP_FOUND )
# ======== Has branch prediction =======
check_cxx_source_compiles( "int main() { int x = 0; if( __builtin_expect((x),0) ) x = 1; return 0; }" HAS_BRANCH_PEDICTION )
if( HAS_BRANCH_PREDICTION )
set( BRANCH_PREDICTION 1 )
else( HAS_BRANCH_PREDICTION )
set( BRANCH_PREDICTION 0 )
endif( HAS_BRANCH_PREDICTION )
# ======== Find bash =======
# TODO: What if the check fails
find_program (BASH_EXECUTABLE bash PATHS /bin /usr/bin NO_DEFAULT_PATH)
message( "Using bash: ${BASH_EXECUTABLE}" )
# ======== Find perl =======
find_program (PERL_EXECUTABLE perl)
if( PERL_EXECUTABLE )
message( "Using perl: ${PERL_EXECUTABLE}" )
else( PERL_EXECUTABLE )
message( "Perl interpreter not found. Reading multiple exposures (pfsinhdrgen, pfsinme) will not work" )
endif( PERL_EXECUTABLE )
# ======== Build static or dynamic libraries =======
OPTION (BUILD_SHARED_LIBS "Build pfs as a shared library" OFF)
# TODO: Shared libs do not work with VS. Add declspec as explained at: http://www.cmake.org/Wiki/BuildingWinDLL
# Set the LIB_TYPE variable to STATIC
SET (LIB_TYPE STATIC)
IF (BUILD_SHARED_LIBS)
SET (LIB_TYPE SHARED)
ENDIF (BUILD_SHARED_LIBS)
# ======== Check for getopt, which is missing on Windows ========
check_cxx_source_compiles( "#include \"getopt.h\" \n int main() { return 0; }" HAS_GETOPT )
if( NOT HAS_GETOPT )
MESSAGE( STATUS "getopt not found, a replacement needs to be compiled. " )
set( GETOPT_INCLUDE "${PROJECT_SOURCE_DIR}/src/getopt" )
set( GETOPT_OBJECT "$<TARGET_OBJECTS:getopt>" )
else( NOT HAS_GETOPT )
MESSAGE( STATUS "getopt found. " )
set( GETOPT_INCLUDE ".") # work around, cannot pass empty string
set( GETOPT_OBJECT )
endif( NOT HAS_GETOPT )
set( CMAKE_MODULE_PATH ${PROJECT_SOURCE_DIR}/cmake )
# ======== OpenEXR ===========
OPTION(WITH_OpenEXR "Compile with OpenEXR library" ON)
if( WITH_OpenEXR )
find_package (OpenEXR)
if( NOT OPENEXR_FOUND )
MESSAGE( STATUS "OpenEXR not found. The following command will not be
compiled: pfsinexr pfsoutexr. " )
endif( NOT OPENEXR_FOUND )
endif( WITH_OpenEXR )
# ======== Image Magick ===========
OPTION(WITH_ImageMagick "Use ImageMagick library" ON)
if( WITH_ImageMagick )
find_package(ImageMagick COMPONENTS Magick++ MagickCore)
if( NOT ImageMagick_FOUND )
MESSAGE( STATUS "ImageMagick not found. The following commands will not be
compiled: pfsinimgmagick pfsoutimgmagick pfsouthdrhtml. " )
endif( NOT ImageMagick_FOUND )
else( WITH_ImageMagick )
set( ImageMagick_FOUND OFF )
endif( WITH_ImageMagick )
message( "ImageMagick CFLAGS: " ${ImageMagick_INCLUDE_DIRS} )
# ======== NetPBM ===========
#include( ${PROJECT_SRC_DIR}/cmake/FindNETPBM.cmake )
OPTION(WITH_NetPBM "Use NetPBM library" ON)
if( WITH_NetPBM )
find_package(NETPBM)
if( NOT NETPBM_FOUND )
MESSAGE( STATUS "NetPBM not found. The following commands will
not be compiled: pfsinppm pfsoutppm. " )
endif( NOT NETPBM_FOUND )
else( WITH_NetPBM )
set( NETPBM_FOUND OFF )
endif( WITH_NetPBM )
# ======== TIFF ===========
#include( ${PROJECT_SRC_DIR}/cmake/FindTIDD.cmake )
OPTION(WITH_TIFF "Use TIFF library" ON)
if( WITH_TIFF )
find_package(TIFF)
if( NOT TIFF_FOUND )
MESSAGE( STATUS "TIFF not found. The following commands will
not be compiled: pfsintiff pfsouttiff. " )
endif( NOT TIFF_FOUND )
else( WITH_TIFF )
set( NETPBM_FOUND OFF )
endif( WITH_TIFF )
# ======== QT ===========
OPTION(WITH_QT "Use QT library" ON)
if( WITH_QT )
find_package(Qt5 COMPONENTS Widgets)
if( NOT Qt5Widgets_FOUND)
MESSAGE( STATUS "Qt5 library not found. The following commands
will not be compiled: pfsview. " )
else( NOT Qt5Widgets_FOUND )
MESSAGE( STATUS "Qt5 found" )
endif( NOT Qt5Widgets_FOUND )
else( WITH_QT )
set( QT_FOUND OFF )
endif( WITH_QT )
# ======== Matlab ===========
OPTION(WITH_MATLAB "Compile Matlab MEX files" ON)
SET (MATLAB_DEST_DIR "${CMAKE_INSTALL_PREFIX}/share/pfstools/pfstools_matlab"
CACHE PATH "Copy matlab functions to this directory")
SET (MEXGCC ""
CACHE PATH "gcc compiler to use with MEX, for example MEXGCC=/usr/bin/gcc-4.7")
if( WITH_MATLAB )
find_package(MATLAB)
if( MATLAB_FOUND )
message(STATUS "matlab found. mex command: ${MATLAB_MEX}")
elseif( MATLAB_FOUND )
message( STATUS "Matlab or mex compiler not found. Matlab integration will not be compiled." )
endif( MATLAB_FOUND )
endif( WITH_MATLAB )
#include( FindPkgConfig.cmake )
# ======== OpenGL ===========
set(OpenGL_GL_PREFERENCE GLVND)
OPTION(WITH_pfsglview "Compile pfsglview, requires OpenGL and GLUT" ON)
if( WITH_pfsglview )
find_path(OPENGL_INCLUDE_DIR GL/gl.h )
find_package(OpenGL )
find_package(GLUT )
if( NOT OPENGL_FOUND )
MESSAGE( STATUS "OpenGL not found. The following command will not be
compiled: pfsglview. " )
endif( NOT OPENGL_FOUND )
if( NOT GLUT_FOUND )
MESSAGE( STATUS "GLUT not found. The following command will not be
compiled: pfsglview. " )
endif( NOT GLUT_FOUND )
endif( WITH_pfsglview )
# ========= FFTW ===========
OPTION(WITH_FFTW "Use fftw to speed up some operations" ON)
if( WITH_FFTW )
find_package (FFTW)
if( NOT FFTW_FOUND )
MESSAGE( STATUS "FFTW library not found. Acceleration for pfstmo_durand02 disabled. " )
set( HAVE_FFTW3F 0 )
set( HAVE_FFTW3 0 )
else( NOT FFTW_FOUND )
set( HAVE_FFTW3F 1 )
set( HAVE_FFTW3 1 )
endif( NOT FFTW_FOUND )
else( WITH_FFTW )
set( HAVE_FFTW3F 0 )
set( HAVE_FFTW3 0 )
endif( WITH_FFTW )
# ========= GSL ===========
OPTION(WITH_GSL "Use Gnu Scientific Libarary required for some TMOs" ON)
if( WITH_GSL )
find_package (GSL)
if( NOT GSL_FOUND )
MESSAGE( STATUS "GSL library not found. pfstmo_mantiuk08 will not be compiled." )
endif( NOT GSL_FOUND )
endif( WITH_GSL )
# ======== HDRVC ===========
# This is an experimental implementation of HDR-MPEG codec, not included in the official release.
OPTION(WITH_HDRVC "Compile HDRVC (internal release only)" OFF)
# ======== MKOCTFILE/OCTAVE ===========
OPTION(WITH_Octave "Compile Octave files" ON)
SET (OCTAVE_DEST_DIR "" CACHE PATH "Install octave .m and .oct files in this directory")
if( OCTAVE_DEST_DIR )
set( OCTAVE_OCT_DIR ${OCTAVE_DEST_DIR} )
set( OCTAVE_M_DIR ${OCTAVE_DEST_DIR} )
else( OCTAVE_DEST_DIR )
execute_process(COMMAND octave-config --print LOCALOCTFILEDIR OUTPUT_VARIABLE OCTAVE_OCT_DIR OUTPUT_STRIP_TRAILING_WHITESPACE)
set( OCTAVE_OCT_DIR "${OCTAVE_OCT_DIR}/pfstools" )
execute_process(COMMAND octave-config --print LOCALFCNFILEDIR OUTPUT_VARIABLE OCTAVE_M_DIR OUTPUT_STRIP_TRAILING_WHITESPACE)
set( OCTAVE_M_DIR "${OCTAVE_M_DIR}/pfstools" )
endif( OCTAVE_DEST_DIR )
if( WITH_Octave )
find_program(MKOCTFILE mkoctfile)
if(NOT MKOCTFILE)
message(STATUS "Failed to find mkoctfile. Maybe liboctave-dev is not installed.")
endif()
if(MKOCTFILE)
message(STATUS "mkoctfile found.")
endif()
endif( WITH_Octave )
# ======== OpenCV ===========
OPTION(WITH_OpenCV "Use OpenCV library requires for pfsalign" ON)
if( WITH_OpenCV )
find_package( OpenCV )
if( NOT OpenCV_FOUND )
message( "OpenCV library not found. 'pfsalign' will not be compiled" )
else( NOT OpenCV_FOUND )
message(STATUS "OpenCV library found.")
endif( NOT OpenCV_FOUND )
endif( WITH_OpenCV )
# ======== libexif ==========
find_package(EXIF)
if( NOT EXIF_FOUND )
message( "EXIF library (libexif) not found. 'pfsalign' will not be compiled" )
else( NOT EXIF_FOUND )
message(STATUS "libexif library found.")
endif( NOT EXIF_FOUND )
# ======== Config and sub dirs ===========
set(PKG_DATADIR "${CMAKE_INSTALL_PREFIX}/share/pfstools")
configure_file (
"${PROJECT_SOURCE_DIR}/cmake_config.h.in"
"${PROJECT_BINARY_DIR}/config.h"
)
add_subdirectory (src)
|