diff -Naur lensfun-0.3.4.orig/CMakeLists.txt lensfun-0.3.4/CMakeLists.txt
--- lensfun-0.3.4.orig/CMakeLists.txt	2023-07-12 20:24:04.000000000 +0200
+++ lensfun-0.3.4/CMakeLists.txt	2023-07-13 14:05:35.189568300 +0200
@@ -76,7 +76,7 @@
 ENDIF()
 
 # overwrite some folders before GNUInstallDirs is loaded
-IF (WIN32 AND NOT DEFINED CMAKE_INSTALL_DATAROOTDIR)
+IF (MSVC AND NOT DEFINED CMAKE_INSTALL_DATAROOTDIR)
     SET(CMAKE_INSTALL_DATAROOTDIR "$ENV{ALLUSERSPROFILE}" CACHE PATH "read-only architecture-independent data root (share)")
 ENDIF()
 
@@ -102,7 +102,7 @@
   ENDIF()
 ENDIF()
 
-IF(WIN32)
+IF(MSVC)
   INCLUDE_DIRECTORIES(${CMAKE_SOURCE_DIR}/libs/getopt)
   # base path for searching for glib on windows
   IF(NOT GLIB2_BASE_DIR)
@@ -205,7 +205,7 @@
   ADD_SUBDIRECTORY(docs)
 ENDIF()
 
-IF(WIN32 AND NOT BUILD_STATIC)
+IF(MSVC AND NOT BUILD_STATIC)
   FIND_FILE(GLIB2_DLL
             NAMES glib-2.0-0.dll glib-2.dll glib-2-vs9.dll
             PATHS "${GLIB2_BASE_DIR}/bin"
diff -Naur lensfun-0.3.4.orig/apps/CMakeLists.txt lensfun-0.3.4/apps/CMakeLists.txt
--- lensfun-0.3.4.orig/apps/CMakeLists.txt	2023-07-12 20:24:04.000000000 +0200
+++ lensfun-0.3.4/apps/CMakeLists.txt	2023-07-13 14:05:46.699178200 +0200
@@ -1,4 +1,4 @@
-IF(WIN32)
+IF(MSVC)
   SET(COMMON_LIBS getopt)
 ENDIF()
 
@@ -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=\$ENV{DESTDIR}${SETUP_PY_INSTALL_PREFIX})")
+    INSTALL(CODE "execute_process(COMMAND ${PYTHON} ${SETUP_PY} install --prefix=${SETUP_PY_INSTALL_PREFIX} --root=\$ENV{DESTDIR})")
 ENDIF(PYTHON)
diff -Naur lensfun-0.3.4.orig/libs/CMakeLists.txt lensfun-0.3.4/libs/CMakeLists.txt
--- lensfun-0.3.4.orig/libs/CMakeLists.txt	2023-07-12 20:24:04.000000000 +0200
+++ lensfun-0.3.4/libs/CMakeLists.txt	2023-07-13 14:05:06.378129200 +0200
@@ -5,6 +5,6 @@
 ADD_SUBDIRECTORY(lensfun)
 
 # also build getopt on windows
-IF(WIN32 AND BUILD_TESTS)
+IF(MSVC AND BUILD_LENSTOOL)
   ADD_SUBDIRECTORY(getopt)
 ENDIF()
diff -Naur lensfun-0.3.4.orig/libs/lensfun/CMakeLists.txt lensfun-0.3.4/libs/lensfun/CMakeLists.txt
--- lensfun-0.3.4.orig/libs/lensfun/CMakeLists.txt	2023-07-12 20:24:04.000000000 +0200
+++ lensfun-0.3.4/libs/lensfun/CMakeLists.txt	2023-07-13 13:56:57.125468200 +0200
@@ -24,6 +24,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})
 
