summaryrefslogtreecommitdiff
blob: ea7ca59b90a1e1645af6ae5ccfab18a8ca5a6e16 (plain)
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
From 414ad3a07f4bb9a4a6678d25e992d337771684b3 Mon Sep 17 00:00:00 2001
From: Nikoli <nikoli@lavabit.com>
Date: Wed, 22 Sep 2010 08:18:48 +0400
Subject: [PATCH] cmake: fix automagic, config installation; make examples and resources optional

---
 CMakeLists.txt                     |   30 ++++++++++++++++++----------
 examples/mandelbrot/CMakeLists.txt |    6 ++--
 examples/style/CMakeLists.txt      |    6 ++--
 src/CMakeLists.txt                 |   28 +++++++++++++++-----------
 src/Wt/CMakeLists.txt              |   12 ++++++++++-
 src/Wt/Dbo/backend/CMakeLists.txt  |   17 ++++++++++++---
 test/CMakeLists.txt                |   37 +++++++++++++++++++++--------------
 7 files changed, 87 insertions(+), 49 deletions(-)

diff --git a/CMakeLists.txt b/CMakeLists.txt
index 896bd2d..9c6f679 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -27,6 +27,10 @@ SET(WTDBOPOSTGRES_SOVERSION 23)
 #
 # Various things that must be configured by the user or packager ...
 #
+option(BUILD_EXAMPLES "Build examples" OFF)
+option(INSTALL_RESOURCES "Install resources directory" ON)
+option(ENABLE_GM "Enable GraphicsMagick, for supporting painting to raster images (PNG, GIF, ...) (WRasterImage)" ON)
+option(ENABLE_HARU "Enable Haru Free PDF Library, which is used to provide support for painting to PDF (WPdfImage)" ON)
 
 IF(NOT SHARED_LIBS)
   IF(WIN32)
@@ -296,11 +300,11 @@ IF (DOXYGEN_FOUND)
   ADD_DEPENDENCIES(doc doxygen-examples)
  ENDIF (DOXYGEN_FOUND)
 
-IF(WIN32)
-  SUBDIRS(src examples)
-ELSE(WIN32)
-  SUBDIRS(src EXCLUDE_FROM_ALL examples)
-ENDIF(WIN32)
+SUBDIRS(src)
+
+IF(BUILD_EXAMPLES)
+  SUBDIRS(examples)
+ENDIF(BUILD_EXAMPLES)
 
 IF(BUILD_TESTS)
   SUBDIRS(test)
@@ -313,20 +317,24 @@ ENDIF( NOT DEFINED WT_CMAKE_FINDER_INSTALL_DIR)
 INSTALL(FILES ${PROJECT_SOURCE_DIR}/cmake/FindWt.cmake DESTINATION
     ${CMAKE_INSTALL_PREFIX}/${WT_CMAKE_FINDER_INSTALL_DIR} )
 
+IF(INSTALL_RESOURCES)
 INSTALL(DIRECTORY ${PROJECT_SOURCE_DIR}/resources DESTINATION
     ${CMAKE_INSTALL_PREFIX}/share/Wt/)
+ENDIF(INSTALL_RESOURCES)
 
-IF(NOT EXISTS ${CONFIGDIR}/wt_config.xml)
+IF(NOT EXISTS ${DESTDIR}${CONFIGDIR}/wt_config.xml)
   INSTALL(FILES ${WT_BINARY_DIR}/wt_config.xml DESTINATION ${CONFIGDIR})
-ENDIF (NOT EXISTS ${CONFIGDIR}/wt_config.xml)
+ENDIF (NOT EXISTS ${DESTDIR}${CONFIGDIR}/wt_config.xml)
 
-IF(HARU_FOUND)
+IF(ENABLE_HARU AND HARU_FOUND)
+  SET(HAVE_HARU ON)
   SET(WT_HAS_WPDFIMAGE true)
-ENDIF(HARU_FOUND)
+ENDIF(ENABLE_HARU AND HARU_FOUND)
 
-IF(GM_FOUND)
+IF(ENABLE_GM AND GM_FOUND)
+  SET(HAVE_GM ON)
   SET(WT_HAS_WRASTERIMAGE true)
-ENDIF(GM_FOUND)
+ENDIF(ENABLE_GM AND GM_FOUND)
 
 # Compile time constants & make sure our build finds it
 FILE(MAKE_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/Wt)
diff --git a/examples/mandelbrot/CMakeLists.txt b/examples/mandelbrot/CMakeLists.txt
index 176cab6..64b8ff7 100644
--- a/examples/mandelbrot/CMakeLists.txt
+++ b/examples/mandelbrot/CMakeLists.txt
@@ -1,6 +1,6 @@
-IF(NOT GM_FOUND)
+IF(NOT HAVE_GM)
   MESSAGE(STATUS "** Not building mandelbrot example: requires Wt::WRasterImage.")
-ELSE(NOT GM_FOUND)
+ELSE(NOT HAVE_GM)
 
   WT_ADD_EXAMPLE(mandelbrot.wt MandelbrotImage.C MandelbrotExample.C)
 
@@ -11,5 +11,5 @@ ELSE(NOT GM_FOUND)
 
   ADD_DEPENDENCIES(mandelbrot.wt wt ${EXAMPLES_CONNECTOR})
 
-ENDIF(NOT GM_FOUND)
+ENDIF(NOT HAVE_GM)
 
diff --git a/examples/style/CMakeLists.txt b/examples/style/CMakeLists.txt
index 6443035..04a71f7 100644
--- a/examples/style/CMakeLists.txt
+++ b/examples/style/CMakeLists.txt
@@ -1,8 +1,8 @@
-IF(NOT GM_FOUND)
+IF(NOT HAVE_GM)
 
   MESSAGE(STATUS "** Not building style example: requires WRasterImage.")
 
-ELSE(NOT GM_FOUND)
+ELSE(NOT HAVE_GM)
 
   WT_ADD_EXAMPLE(styleexample.wt CornerImage.C RoundedWidget.C StyleExample.C)
 
@@ -12,5 +12,5 @@ ELSE(NOT GM_FOUND)
 
   ADD_DEPENDENCIES(styleexample.wt wt ${EXAMPLES_CONNECTOR})
 
-ENDIF(NOT GM_FOUND)
+ENDIF(NOT HAVE_GM)
 
diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt
index 7d11b67..4523540 100644
--- a/src/CMakeLists.txt
+++ b/src/CMakeLists.txt
@@ -238,33 +238,37 @@ IF (MULTI_THREADED_BUILD)
   SET(libsources ${libsources} web/SocketNotifier.C)
 ENDIF(MULTI_THREADED_BUILD)
 
-IF(HARU_FOUND)
+IF(HAVE_HARU)
   SET(libsources ${libsources} Wt/WPdfImage.C)
-ENDIF(HARU_FOUND)
+ENDIF(HAVE_HARU)
 
-IF(GM_FOUND)
+IF(HAVE_GM)
   SET(libsources ${libsources} Wt/WRasterImage.C)
-ENDIF(GM_FOUND)
+ENDIF(HAVE_GM)
 
 ADD_LIBRARY(wt ${libsources})
 TARGET_LINK_LIBRARIES(wt ${BOOST_WT_LIBRARIES})
 
-IF(HARU_FOUND)
+IF(HAVE_HARU)
   TARGET_LINK_LIBRARIES(wt ${HARU_LIBRARIES})
   INCLUDE_DIRECTORIES(${HARU_INCLUDE_DIRS})
-ELSE(HARU_FOUND)
+ELSE(HAVE_HARU)
   MESSAGE("** Disabling PDF support (WPdfImage): requires libharu.")
-  MESSAGE("   Indicate the location of your haru library using -DHARU_PREFIX=...")
-ENDIF(HARU_FOUND)
+  IF(ENABLE_HARU)
+    MESSAGE("   Indicate the location of your haru library using -DHARU_PREFIX=...")
+  ENDIF(ENABLE_HARU)
+ENDIF(HAVE_HARU)
 
-IF(GM_FOUND)
+IF(HAVE_GM)
   TARGET_LINK_LIBRARIES(wt ${GM_LIBRARIES})
   INCLUDE_DIRECTORIES(${GM_INCLUDE_DIRS})
   ADD_DEFINITIONS(-DHAVE_RASTER_IMAGE)
-ELSE(GM_FOUND)
+ELSE(HAVE_GM)
   MESSAGE("** Disabling raster image support (WRasterImage): requires graphicsmagick.")
-  MESSAGE("   Indicate the location of your graphicsmagick library using -DGM_PREFIX=...")
-ENDIF(GM_FOUND)
+  IF(ENABLE_GM)
+    MESSAGE("   Indicate the location of your graphicsmagick library using -DGM_PREFIX=...")
+  ENDIF(ENABLE_GM)
+ENDIF(HAVE_GM)
 
 IF(MULTI_THREADED_BUILD)
   TARGET_LINK_LIBRARIES(wt ${CMAKE_THREAD_LIBS_INIT})
diff --git a/src/Wt/CMakeLists.txt b/src/Wt/CMakeLists.txt
index d5a3c58..67faae8 100644
--- a/src/Wt/CMakeLists.txt
+++ b/src/Wt/CMakeLists.txt
@@ -1,4 +1,14 @@
-SUBDIRS(Dbo Ext Chart Http Test)
+SUBDIRS(Chart Http Test)
+
+# FIXME we should use (HAVE_SQLITE OR HAVE_POSTGRES)
+IF(ENABLE_SQLITE OR ENABLE_POSTGRES)
+  SUBDIRS(Dbo)
+ENDIF(ENABLE_SQLITE OR ENABLE_POSTGRES)
+
+option(ENABLE_EXT "Build Wt Ext library with JavaScript-only widgets (http://extjs.com/)" ON)
+IF(ENABLE_EXT)
+  SUBDIRS(Ext)
+ENDIF(ENABLE_EXT)
 
 INSTALL_FILES(/include/Wt "^W.*[^C~]$")
 #INSTALL(
diff --git a/src/Wt/Dbo/backend/CMakeLists.txt b/src/Wt/Dbo/backend/CMakeLists.txt
index 653a830..7668b90 100644
--- a/src/Wt/Dbo/backend/CMakeLists.txt
+++ b/src/Wt/Dbo/backend/CMakeLists.txt
@@ -1,3 +1,8 @@
+OPTION(ENABLE_SQLITE "Build SQLite3 backend for Wt::Dbo" ON)
+OPTION(ENABLE_POSTGRES "Build PostgreSQL backend for Wt::Dbo" OFF)
+
+IF(ENABLE_SQLITE)
+
 OPTION( USE_SYSTEM_SQLITE3 "Use system-wide Sqlite3 instead of Wt's version" OFF)
 
 IF(USE_SYSTEM_SQLITE3)
@@ -41,7 +46,9 @@ PROPERTIES
 INSTALL_FILES(/include/Wt/Dbo/backend "^Sqlite3$")
 INSTALL_FILES(/include/Wt/Dbo/backend "^.*Sqlite3.*h$")
 
-IF(POSTGRES_FOUND)
+ENDIF(ENABLE_SQLITE)
+
+IF(ENABLE_POSTGRES AND POSTGRES_FOUND)
   MESSAGE("** Wt::Dbo: building Postgres backend.")
   ADD_LIBRARY(wtdbopostgres
     Postgres.C
@@ -65,8 +72,10 @@ IF(POSTGRES_FOUND)
 
   INSTALL_FILES(/include/Wt/Dbo/backend "^Postgres$")
   INSTALL_FILES(/include/Wt/Dbo/backend "^.*Postgres.*h$")
-ELSE(POSTGRES_FOUND)
+ELSE(ENABLE_POSTGRES AND POSTGRES_FOUND)
   MESSAGE("** Wt::Dbo: not building Postgres backend.")
-  MESSAGE("    Indicate the location of your postgres installation using -DPOSTGRES_PREFIX=...")
-ENDIF(POSTGRES_FOUND)
+  IF(ENABLE_POSTGRES)
+    MESSAGE("    Indicate the location of your postgres installation using -DPOSTGRES_PREFIX=...")
+  ENDIF(ENABLE_POSTGRES)
+ENDIF(ENABLE_POSTGRES AND POSTGRES_FOUND)
 
diff --git a/test/CMakeLists.txt b/test/CMakeLists.txt
index d18ca2e..2a928ae 100644
--- a/test/CMakeLists.txt
+++ b/test/CMakeLists.txt
@@ -1,20 +1,27 @@
-ADD_EXECUTABLE(test
-  test.C
-  chart/WChartTest.C
-  dbo/DboTest.C
-  dbo/DboTest2.C
-  models/WBatchEditProxyModelTest.C
-  utf8/Utf8Test.C
-  wdatetime/WDateTimeTest.C
-)
+# Tests need sqlite
+IF(ENABLE_SQLITE)
 
-# SQLITE3 test
-TARGET_LINK_LIBRARIES(test wt wtdbo wtdbosqlite3)
-ADD_DEFINITIONS(-DSQLITE3)
+  ADD_EXECUTABLE(test
+    test.C
+    chart/WChartTest.C
+    dbo/DboTest.C
+    dbo/DboTest2.C
+    models/WBatchEditProxyModelTest.C
+    utf8/Utf8Test.C
+    wdatetime/WDateTimeTest.C
+  )
 
-# POSTGRES test
-#TARGET_LINK_LIBRARIES(test wt wtdbo wtdbopostgres)
-#ADD_DEFINITIONS(-DPOSTGRES)
+  # SQLITE3 test
+  TARGET_LINK_LIBRARIES(test wt wtdbo wtdbosqlite3)
+  ADD_DEFINITIONS(-DSQLITE3)
+
+ENDIF(ENABLE_SQLITE)
+
+## # POSTGRES test
+## IF(ENABLE_POSTGRES AND POSTGRES_FOUND)
+##   TARGET_LINK_LIBRARIES(test wt wtdbo wtdbopostgres)
+##   ADD_DEFINITIONS(-DPOSTGRES)
+## ENDIF(ENABLE_POSTGRES AND POSTGRES_FOUND)
 
 INCLUDE_DIRECTORIES(${WT_SOURCE_DIR}/src)
 
-- 
1.7.2.2