--- lensfun-0.3.2/CMakeLists.txt.orig	2014-01-16 23:28:46.720800000 +0400
+++ lensfun-0.3.2/CMakeLists.txt	2014-01-16 23:30:53.424000000 +0400
@@ -73,7 +73,10 @@
   ENDIF()
 ENDIF()
 
-IF(WIN32)
+IF(MINGW)
+  INCLUDE_DIRECTORIES(${CMAKE_SOURCE_DIR}/libs/getopt)
+ENDIF()
+IF(MSVC)
   INCLUDE_DIRECTORIES(${CMAKE_SOURCE_DIR}/libs/getopt)
   # base path for searching for glib on windows
   IF(NOT GLIB2_BASE_DIR)R)
@@ -151,7 +151,7 @@
   ADD_SUBDIRECTORY(docs)
 ENDIF()
 
-IF(WIN32 AND NOT BUILD_STATIC)
+IF(MSVC AND NOT BUILD_STATIC)
   FIND_FILE(GLIB2_DLL 
             NAMES glib-2.dll glib-2-vs9.dll
             PATHS "${GLIB2_BASE_DIR}/bin"
--- lensfun-0.3.2/libs/CMakeLists.txt.orig	2014-01-17 00:56:47.952600000 +0400
+++ lensfun-0.3.2/libs/CMakeLists.txt	2014-01-17 00:56:59.746200000 +0400
@@ -5,6 +5,6 @@
 ADD_SUBDIRECTORY(lensfun)
 
 # also build getopt on windows
-IF(WIN32 AND BUILD_TESTS)
+IF(WIN32 AND BUILD_LENSTOOL)
   ADD_SUBDIRECTORY(getopt)
 ENDIF()
--- lensfun-0.3.2/libs/lensfun/CMakeLists.txt.orig	2014-01-17 00:56:47.952600000 +0400
+++ lensfun-0.3.2/libs/lensfun/CMakeLists.txt	2014-01-17 00:56:59.746200000 +0400
@@ -19,6 +19,8 @@
 
 IF(NOT HAVE_REGEX_H)
   TARGET_LINK_LIBRARIES(lensfun tre_regex)
+ELSE()
+  TARGET_LINK_LIBRARIES(lensfun regex)
 ENDIF()
 TARGET_LINK_LIBRARIES(lensfun ${GLIB2_LIBRARIES})
 
--- lensfun-0.3.2/apps/CMakeLists.txt.orig	2016-02-10 08:11:49.597956000 +0300
+++ lensfun-0.3.2/apps/CMakeLists.txt	2016-02-10 08:12:06.169641000 +0300
@@ -42,5 +42,5 @@
     IF(NOT DEFINED SETUP_PY_INSTALL_PREFIX)
       SET(SETUP_PY_INSTALL_PREFIX "${CMAKE_INSTALL_PREFIX}")
     ENDIF()
-    INSTALL(CODE "execute_process(COMMAND ${PYTHON} ${SETUP_PY} install --prefix=${SETUP_PY_INSTALL_PREFIX})")
+    INSTALL(CODE "execute_process(COMMAND ${PYTHON} ${SETUP_PY} install --prefix=${SETUP_PY_INSTALL_PREFIX} --root=\$ENV{DESTDIR})")
 ENDIF(PYTHON)
