Permalink
Browse files

Merge pull request #12 from sankhesh/cmake-SmartDeblur

Cmake smart deblur
  • Loading branch information...
2 parents 95c7d64 + 3758e4b commit 2e4d7e78753d7915986ec497f4be8842f1e11837 @Y-Vladimir committed Nov 11, 2012
View
@@ -0,0 +1,116 @@
+project(SmartDeblur)
+
+cmake_minimum_required(VERSION 2.8)
+
+#------------------------------------------------------------------------------
+# CPack
+#
+include(CPack)
+
+#------------------------------------------------------------------------------
+# Additional Qt libraries
+#
+set(QT_USE_QT3SUPPORT TRUE)
+set(QT_USE_QTNETWORK TRUE)
+set(QT_USE_QTWEBKIT TRUE)
+set(QT_USE_QTXML TRUE)
+
+#------------------------------------------------------------------------------
+# Find Qt
+#
+find_package(Qt4 REQUIRED)
+include(${QT_USE_FILE})
+
+
+#------------------------------------------------------------------------------
+# SmartDeblur UI
+#
+set(SmartDeblur_UI_SRCS
+ HelpDialog.ui
+ MainWindow.ui
+ )
+
+set(SmartDeblur_SRCS
+ CheckUpdatesThread.cpp
+ CheckUpdatesThread.h
+ DeconvolutionTool.cpp
+ DeconvolutionTool.h
+ HelpDialog.cpp
+ HelpDialog.h
+ ImageUtils.cpp
+ ImageUtils.h
+ MainWindow.cpp
+ MainWindow.h
+ WorkerThread.cpp
+ WorkerThread.h
+ main.cpp
+ )
+
+set(SmartDeblur_MOC_H
+ CheckUpdatesThread.h
+ DeconvolutionTool.h
+ HelpDialog.h
+ MainWindow.h
+ WorkerThread.h
+ )
+
+set(SmartDeblur_RESOURCES
+ MainResources.qrc
+ )
+
+QT4_WRAP_UI(SmartDeblur_UI_CXX ${SmartDeblur_UI_SRCS})
+QT4_WRAP_CPP(SmartDeblur_MOC_SRCS ${SmartDeblur_MOC_H})
+QT4_ADD_RESOURCES(SmartDeblur_QRC_SRCS ${SmartDeblur_RESOURCES})
+
+#------------------------------------------------------------------------------
+# FFTW
+#
+set(CMAKE_MODULE_PATH ${CMAKE_CURRENT_SOURCE_DIR}/FFTW)
+
+set(USE_SYSTEM_FFTW OFF
+ CACHE BOOL
+ "Use system FFTW")
+include(External_FFTW)
+
+include_directories(
+ ${CMAKE_CURRENT_BINARY_DIR}
+ ${FFTW_INCLUDES}
+ ${CMAKE_CURRENT_SOURCE_DIR}
+ ${QT_INCLUDES}
+ )
+
+add_subdirectory(Models)
+
+#------------------------------------------------------------------------------
+# SmartDeblur executable
+#
+add_executable(SmartDeblur
+ ${Models_SRCS}
+ ${SmartDeblur_MOC_H}
+ ${SmartDeblur_MOC_SRCS}
+ ${SmartDeblur_QRC_SRCS}
+ ${SmartDeblur_SRCS}
+ ${SmartDeblur_UI_CXX}
+ )
+
+add_dependencies(SmartDeblur FFTW)
+target_link_libraries(SmartDeblur
+ ${FFTW_LIBRARIES}
+ ${QT_LIBRARIES}
+ )
+
+install(TARGETS SmartDeblur
+ RUNTIME DESTINATION bin
+ LIBRARY DESTINATION lib
+ ARCHIVE DESTINATION lib
+ )
+
+#------------------------------------------------------------------------------
+# Copy libfftw3.dll file to install/bin in Windows
+#
+if(WIN32)
+ string(REPLACE ".lib" ".dll" FFTW_LIBRARY_DLL ${FFTW_LIBRARIES})
+ install(FILES ${FFTW_LIBRARY_DLL}
+ DESTINATION bin
+ )
+endif()
@@ -0,0 +1,82 @@
+#
+# Encapsulates building FFTW as an External Project.
+
+set(msg "ATTENTION: You have enabled the use of fftw,")
+set(msg "${msg} this library is distributed under a GPL license.")
+set(msg "${msg} By enabling this option, the binary of SmartDeblur")
+set(msg "${msg} that you are going to build will be covered by a GPL license,")
+set(msg "${msg} and so it will be any executable that you link against these libraries.")
+message("${msg}")
+
+set(FFTW_THREADS_CONFIGURATION --enable-threads)
+
+#--Some influential environment variables:
+#-- CC C compiler command
+#-- CFLAGS C compiler flags
+#-- LDFLAGS linker flags, e.g. -L<lib dir> if you have libraries in a
+#-- nonstandard directory <lib dir>
+#-- LIBS libraries to pass to the linker, e.g. -l<library>
+#-- CPPFLAGS C/C++/Objective C preprocessor flags, e.g. -I<include dir> if
+#-- you have headers in a nonstandard directory <include dir>
+#-- set(ENV{CC} "${CMAKE_C_COMPILER}")
+#-- set(ENV{CFLAGS} "${CMAKE_C_FLAGS} ${OPENMP_FLAG}")
+#-- set(ENV{LDFLAGS} "${CMAKE_C_FLAGS} ${OPENMP_FLAG}")
+#-- set(ENV{LIBS} "${CMAKE_EXE_LINKER_FLAGS} ${OPENMP_FLAG}")
+#-- set(ENV{CPPFLAGS} "${CMAKE_C_FLAGS} ${OPENMP_FLAG}")
+
+## Perhaps in the future a set of TryCompiles could be used here.
+set(FFTW_OPTIMIZATION_CONFIGURATION "" CACHE INTERNAL "architecture flags: --enable-sse --enable-sse2 --enable-altivec --enable-mips-ps --enable-cell")
+if(USE_SYSTEM_FFTW)
+ find_library(FFTW_LIBRARIES ${CMAKE_SHARED_LIBRARY_PREFIX}fftw3${CMAKE_SHARED_LIBRARY_SUFFIX})
+ find_path(FFTW_INCLUDES fftw3.h)
+else()
+ set(FFTW_COMPILER_FLAGS
+ CC=${CMAKE_C_COMPILER}
+ CXX=${CMAKE_CXX_COMPILER}
+ CFLAGS=${CMAKE_C_FLAGS}
+ CXXFLAGS=${CMAKE_CXX_FLAGS})
+
+ if(WIN32 AND NOT MINGW)
+ message("Can't build fftw as external project on Windows")
+ message("Using pre-compiled fftw library")
+ set(FFTW_LIBRARIES ${CMAKE_CURRENT_SOURCE_DIR}/FFTW/libs/libfftw3-3.lib)
+ set(FFTW_INCLUDES ${CMAKE_CURRENT_SOURCE_DIR}/FFTW)
+ else()
+ #
+ # fftw limitation -- can't be built in
+ # a directory with whitespace in its name.
+ if(${CMAKE_CURRENT_BINARY_DIR} MATCHES ".*[ \t].*")
+ message(FATAL_ERROR
+ "Can't build fftw in a directory with whitespace in its name")
+ endif()
+ set(FFTW_SHARED_FLAG --enable-shared)
+ set(FFTW_VERSION 3.3.2)
+ set(FFTW_MD5 "6977ee770ed68c85698c7168ffa6e178")
+ set(FFTW_URL_PRE "ftp://ftp.fftw.org/pub/fftw/fftw-")
+ set(FFTW_URL_POST ".tar.gz")
+ set(FFTW_INSTALL_DIR ${CMAKE_CURRENT_BINARY_DIR}/fftw/install)
+ set(FFTW_LIBRARIES_PATH ${FFTW_INSTALL_DIR}/lib/)
+ set(FFTW_LIBRARIES
+ ${FFTW_LIBRARIES_PATH}${CMAKE_SHARED_LIBRARY_PREFIX}fftw3${CMAKE_SHARED_LIBRARY_SUFFIX}
+ ${FFTW_LIBRARIES_PATH}${CMAKE_SHARED_LIBRARY_PREFIX}fftw3_threads${CMAKE_SHARED_LIBRARY_SUFFIX})
+
+ include(ExternalProject)
+ ExternalProject_add(FFTW
+ URL ${FFTW_URL_PRE}${FFTW_VERSION}${FFTW_URL_POST}
+ URL_MD5 ${FFTW_MD5}
+ SOURCE_DIR ${CMAKE_CURRENT_BINARY_DIR}/fftw/src
+ BINARY_DIR ${CMAKE_CURRENT_BINARY_DIR}/fftw/src
+ INSTALL_DIR ${FFTW_INSTALL_DIR}
+ UPDATE_COMMAND ""
+ CONFIGURE_COMMAND <SOURCE_DIR>/configure
+ ${FFTW_SHARED_FLAG}
+ ${FFTW_OPTIMIZATION_CONFIGURATION}
+ ${FFTW_THREADS_CONFIGURATION}
+ --disable-fortran
+ --prefix=<INSTALL_DIR>
+ ${FFTW_COMPILER_FLAGS}
+ )
+
+ set(FFTW_INCLUDES ${FFTW_INSTALL_DIR}/include)
+ endif()
+endif()
@@ -0,0 +1,7 @@
+set(Models_SRCS
+ Blur.h
+ FocusBlur.h
+ GaussianBlur.h
+ MotionBlur.h
+ ProcessingContext.h
+ )
View
@@ -1,49 +0,0 @@
-#-------------------------------------------------
-#
-# Project created by QtCreator 2012-05-19T18:47:06
-#
-#-------------------------------------------------
-
-QT += core gui network xml
-
-TARGET = SmartDeblur
-TEMPLATE = app
-
-
-SOURCES += main.cpp\
- MainWindow.cpp \
- DeconvolutionTool.cpp \
- WorkerThread.cpp \
- ImageUtils.cpp \
- MathUtlis.cpp \
- HelpDialog.cpp \
- CheckUpdatesThread.cpp
-
-HEADERS += MainWindow.h \
- FFTW/fftw3.h \
- DeconvolutionTool.h \
- WorkerThread.h \
- ImageUtils.h \
- Models/Blur.h \
- Models/FocusBlur.h \
- Models/MotionBlur.h \
- MathUtlis.h \
- Models/ProcessingContext.h \
- HelpDialog.h \
- Models/GaussianBlur.h \
- CheckUpdatesThread.h
-
-FORMS += MainWindow.ui \
- HelpDialog.ui
-
-win32: LIBS += -L$$PWD/FFTW/libs/ -llibfftw3-3
-unix: LIBS += -L$$/usr/lib/ -lfftw3_threads -lfftw3
-
-INCLUDEPATH += $$PWD/FFTW
-DEPENDPATH += $$PWD/FFTW
-
-RESOURCES += \
- MainResources.qrc
-
-RC_FILE = SmartDeblur.rc
-#CONFIG += console
Oops, something went wrong.

0 comments on commit 2e4d7e7

Please sign in to comment.