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
|
This file is part of MXE. See LICENSE.md for licensing information.
Contains ad hoc patches for cross building.
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
From: Timothy Gu <timothygu99@gmail.com>
Date: Tue, 21 Oct 2014 18:24:56 -0700
Subject: [PATCH] build system: Detect POSIX regex lib more properly
Previously, if the regex lib has to be linked separately, as in the case
of MinGW/libgnurx, it is not detected properly, and build fails for shared
lib.
The imported FindRegex.cmake file is from
https://raw.githubusercontent.com/dubourg/openturns/master/cmake/FindRegex.cmake
and is licensed under the LGPL 3, same as this library.
Signed-off-by: Timothy Gu <timothygu99@gmail.com>
diff --git a/CMakeLists.txt b/CMakeLists.txt
index 1111111..2222222 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -20,15 +20,17 @@ SET(LENSFUN_DB_VERSION 1)
# check if some include are available
INCLUDE(CheckIncludeFiles)
-CHECK_INCLUDE_FILES(regex.h HAVE_REGEX_H)
+FIND_PACKAGE(Regex)
CHECK_INCLUDE_FILES(endian.h HAVE_ENDIAN_H)
# set include directories
INCLUDE_DIRECTORIES(${CMAKE_BINARY_DIR})
INCLUDE_DIRECTORIES(${CMAKE_SOURCE_DIR}/include/lensfun)
-IF(NOT HAVE_REGEX_H)
+IF(NOT REGEX_FOUND)
INCLUDE_DIRECTORIES(${CMAKE_SOURCE_DIR}/include/regex)
INCLUDE_DIRECTORIES(${CMAKE_SOURCE_DIR}/libs/regex)
+ELSE()
+ INCLUDE_DIRECTORIES(${REGEX_INCLUDE_DIR})
ENDIF()
# options controlling the build process
@@ -148,7 +150,7 @@ ADD_SUBDIRECTORY(apps)
# install include files
INSTALL(FILES ${CMAKE_BINARY_DIR}/lensfun.h DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/lensfun)
-IF(NOT HAVE_REGEX_H)
+IF(NOT REGEX_FOUND)
INSTALL(FILES include/regex/regex.h DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/regex)
ENDIF()
diff --git a/cmake/modules/FindRegex.cmake b/cmake/modules/FindRegex.cmake
new file mode 100644
index 1111111..2222222
--- /dev/null
+++ b/cmake/modules/FindRegex.cmake
@@ -0,0 +1,64 @@
+# -*- cmake -*-
+#
+# FindRegex.cmake: Try to find Regex
+#
+# Copyright (C) 2005-2014 Airbus-EDF-Phimeca
+#
+# This library is free software: you can redistribute it and/or modify
+# it under the terms of the GNU Lesser General Public License as published by
+# the Free Software Foundation, either version 3 of the License, or
+# (at your option) any later version.
+#
+# This library is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU Lesser General Public License for more details.
+#
+# You should have received a copy of the GNU Lesser General Public
+# along with this library. If not, see <http://www.gnu.org/licenses/>.
+#
+# @author dutka
+# @date 2010-02-04 16:44:49 +0100 (Thu, 04 Feb 2010)
+#
+#
+# - Try to find Regex
+# Once done this will define
+#
+# REGEX_FOUND - System has Regex
+# REGEX_INCLUDE_DIR - The Regex include directory
+# REGEX_LIBRARIES - The libraries needed to use Regex
+# REGEX_DEFINITIONS - Compiler switches required for using Regex
+
+IF (REGEX_INCLUDE_DIR AND REGEX_LIBRARIES)
+ # in cache already
+ SET(Regex_FIND_QUIETLY TRUE)
+ENDIF (REGEX_INCLUDE_DIR AND REGEX_LIBRARIES)
+
+#IF (NOT WIN32)
+# # use pkg-config to get the directories and then use these values
+# # in the FIND_PATH() and FIND_LIBRARY() calls
+# FIND_PACKAGE(PkgConfig)
+# PKG_CHECK_MODULES(PC_REGEX regex)
+# SET(REGEX_DEFINITIONS ${PC_REGEX_CFLAGS_OTHER})
+#ENDIF (NOT WIN32)
+
+FIND_PATH(REGEX_INCLUDE_DIR regex.h
+ HINTS
+ ${REGEX_INCLUDEDIR}
+ ${PC_LIBXML_INCLUDE_DIRS}
+ PATH_SUFFIXES regex
+ )
+
+FIND_LIBRARY(REGEX_LIBRARIES NAMES gnurx c regex
+ HINTS
+ ${PC_REGEX_LIBDIR}
+ ${PC_REGEX_LIBRARY_DIRS}
+ )
+
+INCLUDE(FindPackageHandleStandardArgs)
+
+# handle the QUIETLY and REQUIRED arguments and set REGEX_FOUND to TRUE if
+# all listed variables are TRUE
+FIND_PACKAGE_HANDLE_STANDARD_ARGS(Regex DEFAULT_MSG REGEX_LIBRARIES REGEX_INCLUDE_DIR)
+
+MARK_AS_ADVANCED(REGEX_INCLUDE_DIR REGEX_LIBRARIES)
diff --git a/libs/CMakeLists.txt b/libs/CMakeLists.txt
index 1111111..2222222 100644
--- a/libs/CMakeLists.txt
+++ b/libs/CMakeLists.txt
@@ -1,4 +1,4 @@
-IF(NOT HAVE_REGEX_H)
+IF(NOT REGEX_FOUND)
ADD_SUBDIRECTORY(regex)
ENDIF()
diff --git a/libs/lensfun/CMakeLists.txt b/libs/lensfun/CMakeLists.txt
index 1111111..2222222 100644
--- a/libs/lensfun/CMakeLists.txt
+++ b/libs/lensfun/CMakeLists.txt
@@ -17,8 +17,10 @@ ELSE()
ENDIF()
SET_TARGET_PROPERTIES(lensfun PROPERTIES SOVERSION "${VERSION_API}" VERSION "${VERSION_MAJOR}.${VERSION_MINOR}.${VERSION_MICRO}")
-IF(NOT HAVE_REGEX_H)
+IF(NOT REGEX_FOUND)
TARGET_LINK_LIBRARIES(lensfun tre_regex)
+ELSE()
+ TARGET_LINK_LIBRARIES(lensfun ${REGEX_LIBRARIES})
ENDIF()
TARGET_LINK_LIBRARIES(lensfun ${GLIB2_LIBRARIES})
diff --git a/libs/lensfun/lensfun.pc.cmake b/libs/lensfun/lensfun.pc.cmake
index 1111111..2222222 100644
--- a/libs/lensfun/lensfun.pc.cmake
+++ b/libs/lensfun/lensfun.pc.cmake
@@ -10,4 +10,5 @@ Description: A photographic lens database and access library
Version: @VERSION_MAJOR@.@VERSION_MINOR@.@VERSION_MICRO@.@VERSION_BUGFIX@
Requires.private: glib-2.0
Libs: -L${libdir} -llensfun
+Libs.private: @REGEX_LIBRARIES@
Cflags: -I${includedir} -I${includedir}/lensfun
diff --git a/libs/regex/CMakeLists.txt b/libs/regex/CMakeLists.txt
index 1111111..2222222 100644
--- a/libs/regex/CMakeLists.txt
+++ b/libs/regex/CMakeLists.txt
@@ -1,5 +1,5 @@
# build regex library
-IF(NOT HAVE_REGEX_H)
+IF(NOT REGEX_FOUND)
FILE(GLOB REGEX_SRC *.c *.h)
LIST(APPEND REGEX_SRC ../../include/regex/regex.h)
ADD_LIBRARY(tre_regex STATIC ${REGEX_SRC})
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
From: Timothy Gu <timothygu99@gmail.com>
Date: Tue, 21 Oct 2014 18:36:15 -0700
Subject: [PATCH] Only install glib DLL on MSVC
Signed-off-by: Timothy Gu <timothygu99@gmail.com>
diff --git a/CMakeLists.txt b/CMakeLists.txt
index 1111111..2222222 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -164,7 +164,7 @@ IF(BUILD_DOC)
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"
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
From: Timothy Gu <timothygu99@gmail.com>
Date: Tue, 21 Oct 2014 18:54:03 -0700
Subject: [PATCH] pkgconfig: Explicitly depend on libstdc++
Fixes MinGW static.
Signed-off-by: Timothy Gu <timothygu99@gmail.com>
diff --git a/libs/lensfun/lensfun.pc.cmake b/libs/lensfun/lensfun.pc.cmake
index 1111111..2222222 100644
--- a/libs/lensfun/lensfun.pc.cmake
+++ b/libs/lensfun/lensfun.pc.cmake
@@ -10,5 +10,5 @@ Description: A photographic lens database and access library
Version: @VERSION_MAJOR@.@VERSION_MINOR@.@VERSION_MICRO@.@VERSION_BUGFIX@
Requires.private: glib-2.0
Libs: -L${libdir} -llensfun
-Libs.private: @REGEX_LIBRARIES@
+Libs.private: @REGEX_LIBRARIES@ -lstdc++
Cflags: -I${includedir} -I${includedir}/lensfun
|