Merge lp:~ralsina/u1db/cmake into lp:u1db

Proposed by Roberto Alsina
Status: Merged
Approved by: Roberto Alsina
Approved revision: 340
Merged at revision: 333
Proposed branch: lp:~ralsina/u1db/cmake
Merge into: lp:u1db
Diff against target: 216 lines (+149/-16)
6 files modified
Makefile (+6/-5)
cmake/Modules/FindJSON.cmake (+32/-0)
cmake/Modules/FindOAUTH.cmake (+32/-0)
cmake/Modules/FindSqlite3.cmake (+31/-0)
setup.py (+3/-11)
src/CMakeLists.txt (+45/-0)
To merge this branch: bzr merge lp:~ralsina/u1db/cmake
Reviewer Review Type Date Requested Status
dobey (community) Approve
Eric Casteleijn (community) Approve
Review via email: mp+111076@code.launchpad.net

Commit message

Builds a real libu1db and then links the cythn extension to use it.

Description of the change

Builds a real libu1db and then links the cythn extension to use it.

To test, just run make

To post a comment you must log in.
lp:~ralsina/u1db/cmake updated
335. By Roberto Alsina

fix generated file path

336. By Roberto Alsina

make sqlite3 required

Revision history for this message
dobey (dobey) wrote :

Looks like it's not using pkg-config. Also there seems to be some case differences, using OAuth_FOO in one places and OAUTH_FOO in another.

Also, is there a reasonable way to have a versioned shared library? Like libu1db-1.0.so.1.0.0 on Linux, and I suppose u1db-1.0.dll on Windows?

review: Needs Fixing
lp:~ralsina/u1db/cmake updated
337. By Roberto Alsina

use -fPIC

338. By Roberto Alsina

use pkg-config

339. By Roberto Alsina

build static and shared libraries, add soname to shared one

Revision history for this message
Eric Casteleijn (thisfred) wrote :

Looks good to me and builds here. Would like Rodney's approval though since I am not well versed in the ways of make/cmake.

review: Approve
Revision history for this message
John A Meinel (jameinel) wrote :

Make sure it builds in a clean directory. It looks like you removed
building u1db_schema in the Makefile, but I dont see the step in the
CMakefiles. I could have just missed it.

John
=:->
On Jun 19, 2012 10:56 PM, "Eric Casteleijn" <email address hidden>
wrote:

> Review: Approve
>
> Looks good to me and builds here. Would like Rodney's approval though
> since I am not well versed in the ways of make/cmake.
> --
> https://code.launchpad.net/~ralsina/u1db/cmake/+merge/111076
> Your team Ubuntu One hackers is subscribed to branch lp:u1db.
>

Revision history for this message
John A Meinel (jameinel) wrote :

-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

On 6/20/2012 9:07 AM, John A Meinel wrote:
> Make sure it builds in a clean directory. It looks like you
> removed building u1db_schema in the Makefile, but I dont see the
> step in the CMakefiles. I could have just missed it.

(I did just miss it, on second review I see it.)

John
=:->

-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.9 (Cygwin)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org/

iEYEARECAAYFAk/hhvcACgkQJdeBCYSNAAPY8ACffcJX0t8F//B/YUchycOHDSUK
jC0An3tpAnCpH6t2jC1GGa489wfuAXDd
=0ycz
-----END PGP SIGNATURE-----

Revision history for this message
dobey (dobey) wrote :

I get this in a clean checkout:

gcc -pthread -fno-strict-aliasing -DNDEBUG -g -fwrapv -O2 -Wall -Wstrict-prototypes -Werror -fPIC -Iinclude -I/usr/include/python2.7 -c u1db/tests/c_backend_wrapper.c -o build/temp.linux-i686-2.7/u1db/tests/c_backend_wrapper.o
gcc -pthread -shared -Wl,-O1 -Wl,-Bsymbolic-functions -Wl,-Bsymbolic-functions -Wl,-z,relro -Werror build/temp.linux-i686-2.7/u1db/tests/c_backend_wrapper.o -Lsrc -lu1db -lsqlite3 -loauth -lcurl -ljson -o /home/dobey/Projects/canonical/u1db/cmake/u1db/tests/c_backend_wrapper.so
/usr/bin/ld: cannot find -lu1db
collect2: ld returned 1 exit status
error: command 'gcc' failed with exit status 1
make: *** [build-inplace] Error 1

This appears to be a result of having the library names be libu1db_shared.so and libu1db_static.a, because CMake is apparently unable to build both with the same lib name, in the same tree (http://www.cmake.org/pipermail/cmake/2006-February/008153.html).

review: Needs Fixing
Revision history for this message
Roberto Alsina (ralsina) wrote :

Oops, my bad, didn't test on a clean checkout. It's an easy fix, will have it early tomorrow.

lp:~ralsina/u1db/cmake updated
340. By Roberto Alsina

make shared/dynamic libraries an option

Revision history for this message
dobey (dobey) wrote :

I'm not really sure if I should vote Approve here or not. The build works and tests pass now, but there is no obvious way to get a clean tree back, and cmake doesn't seem to deal well when certain things change. There's also no way to actually install (or uninstall) the lib yet. But I don't want to hold it back either, if we're going to have to use cmake regardless.

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'Makefile'
2--- Makefile 2012-05-15 16:45:47 +0000
3+++ Makefile 2012-06-21 10:41:19 +0000
4@@ -4,14 +4,11 @@
5 check: build-inplace
6 python -m testtools.run discover
7
8-build-inplace: src/u1db_schema.c
9+build-inplace: build-cmake
10 export CFLAGS='-Werror';\
11 python setup.py build_ext -i
12
13-src/u1db_schema.c: u1db/backends/dbschema.sql sql_to_c.py
14- python sql_to_c.py u1db/backends/dbschema.sql u1db__schema src/u1db_schema.c
15-
16-build-debug: src/u1db_schema.c
17+build-debug: build-cmake
18 export CFLAGS='-Werror';\
19 python-dbg setup.py build_ext -i
20
21@@ -30,3 +27,7 @@
22
23 html-docs:
24 cd html-docs; make html
25+
26+build-cmake:
27+ export CFLAGS='-fPIC';\
28+ cd src; cmake . ; make
29
30=== added directory 'cmake'
31=== added directory 'cmake/Modules'
32=== added file 'cmake/Modules/FindJSON.cmake'
33--- cmake/Modules/FindJSON.cmake 1970-01-01 00:00:00 +0000
34+++ cmake/Modules/FindJSON.cmake 2012-06-21 10:41:19 +0000
35@@ -0,0 +1,32 @@
36+# - Try to find JSON
37+# Once done, this will define
38+#
39+# JSON_FOUND - system has JSON
40+# JSON_INCLUDE_DIRS - the JSON include directories
41+# JSON_LIBRARIES - link these to use JSON
42+
43+find_package(PkgConfig)
44+pkg_check_modules(PC_JSON json)
45+
46+FIND_PATH(JSON_INCLUDE_DIR json.h
47+ HINTS
48+ ${PC_JSON_INCLUDE_DIRS}
49+ /usr/include
50+ /usr/local/include
51+ /opt/local/include
52+ PATH_SUFFIXES json
53+)
54+
55+FIND_LIBRARY(JSON_LIBRARY
56+ NAMES ${JSON_NAMES} libjson.so libjson.dylib
57+ HINTS ${PC_JSON_LIBRARY_DIRS}
58+ /usr/lib /usr/local/lib /opt/local/lib
59+)
60+
61+include(FindPackageHandleStandardArgs)
62+find_package_handle_standard_args(JSON DEFAULT_MSG JSON_LIBRARY JSON_INCLUDE_DIR)
63+
64+IF(JSON_FOUND)
65+ SET(JSON_LIBRARIES ${JSON_LIBRARY})
66+ SET(JSON_INCLUDE_DIRS ${JSON_INCLUDE_DIR})
67+ENDIF(JSON_FOUND)
68
69=== added file 'cmake/Modules/FindOAUTH.cmake'
70--- cmake/Modules/FindOAUTH.cmake 1970-01-01 00:00:00 +0000
71+++ cmake/Modules/FindOAUTH.cmake 2012-06-21 10:41:19 +0000
72@@ -0,0 +1,32 @@
73+# - Try to find OAuth
74+# Once done, this will define
75+#
76+# OAuth_FOUND - system has Glib
77+# OAuth_INCLUDE_DIRS - the Glib include directories
78+# OAuth_LIBRARIES - link these to use Glib
79+
80+find_package(PkgConfig)
81+pkg_check_modules(PC_OAUTH oauth)
82+
83+FIND_PATH(OAuth_INCLUDE_DIR oauth.h
84+ HINTS
85+ ${PC_OAUTH_INCLUDE_DIRS}
86+ /usr/include
87+ /usr/local/include
88+ /opt/local/include
89+ PATH_SUFFIXES oauth
90+)
91+
92+FIND_LIBRARY(OAuth_LIBRARY
93+ NAMES ${OAuth_NAMES} liboauth.so liboauth.dylib
94+ HINTS ${PC_OAUTH_LIBRARY_DIRS}
95+ /usr/lib /usr/local/lib /opt/local/lib
96+)
97+
98+include(FindPackageHandleStandardArgs)
99+find_package_handle_standard_args(OAuth DEFAULT_MSG OAuth_LIBRARY OAuth_INCLUDE_DIR)
100+
101+IF(OAuth_FOUND)
102+ SET(OAuth_LIBRARIES ${OAuth_LIBRARY})
103+ SET(OAuth_INCLUDE_DIRS ${OAuth_INCLUDE_DIR})
104+ENDIF(OAuth_FOUND)
105
106=== added file 'cmake/Modules/FindSqlite3.cmake'
107--- cmake/Modules/FindSqlite3.cmake 1970-01-01 00:00:00 +0000
108+++ cmake/Modules/FindSqlite3.cmake 2012-06-21 10:41:19 +0000
109@@ -0,0 +1,31 @@
110+# - Try to find Sqlite3
111+# Once done, this will define
112+#
113+# Sqlite3_FOUND - system has Sqlite3
114+# Sqlite3_INCLUDE_DIRS - the Sqlite3 include directories
115+# Sqlite3_LIBRARIES - link these to use Sqlite3
116+
117+find_package(PkgConfig)
118+pkg_check_modules(PC_SQLITE3 sqlite3)
119+
120+FIND_PATH(Sqlite3_INCLUDE_DIR sqlite3.h
121+ HINTS
122+ ${PC_SQLITE3_INCLUDE_DIRS}
123+ /usr/include
124+ /usr/local/include
125+ /opt/local/include
126+)
127+
128+FIND_LIBRARY(Sqlite3_LIBRARY
129+ NAMES ${Sqlite3_NAMES} libsqlite3.so libsqlite3.dylib
130+ HINTS ${PC_SQLITE3_LIBRARY_DIRS}
131+ /usr/lib /usr/local/lib /opt/local/lib
132+)
133+
134+include(FindPackageHandleStandardArgs)
135+find_package_handle_standard_args(Sqlite3 DEFAULT_MSG Sqlite3_LIBRARY Sqlite3_INCLUDE_DIR)
136+
137+IF(Sqlite3_FOUND)
138+ SET(Sqlite3_LIBRARIES ${Sqlite3_LIBRARY})
139+ SET(Sqlite3_INCLUDE_DIRS ${Sqlite3_INCLUDE_DIR})
140+ENDIF(Sqlite3_FOUND)
141
142=== modified file 'setup.py'
143--- setup.py 2012-05-03 11:43:23 +0000
144+++ setup.py 2012-06-21 10:41:19 +0000
145@@ -84,18 +84,10 @@
146 extra_libs.append('json')
147 ext.append(Extension(
148 "u1db.tests.c_backend_wrapper",
149- ["u1db/tests/c_backend_wrapper.pyx",
150- "src/mkstemp_compat.c",
151- "src/u1db.c",
152- "src/u1db_http_sync_target.c",
153- "src/u1db_query.c",
154- "src/u1db_schema.c",
155- "src/u1db_sync_target.c",
156- "src/u1db_uuid.c",
157- "src/u1db_vectorclock.c",
158- ],
159+ ["u1db/tests/c_backend_wrapper.pyx"],
160 include_dirs=["include"],
161- libraries=['sqlite3', 'oauth'] + extra_libs,
162+ library_dirs=["src"],
163+ libraries=['u1db', 'sqlite3', 'oauth'] + extra_libs,
164 define_macros=[] + extra_defines,
165 ))
166
167
168=== added file 'src/CMakeLists.txt'
169--- src/CMakeLists.txt 1970-01-01 00:00:00 +0000
170+++ src/CMakeLists.txt 2012-06-21 10:41:19 +0000
171@@ -0,0 +1,45 @@
172+cmake_minimum_required (VERSION 2.6)
173+project (u1db)
174+
175+# Allow the developer to select if Dynamic or Static libraries are built
176+OPTION (BUILD_SHARED_LIBS "Build Shared Libraries" OFF)
177+
178+#Set the LIB_TYPE variable to STATIC
179+SET (LIB_TYPE STATIC)
180+IF (BUILD_SHARED_LIBS)
181+ # User wants to build Dynamic Libraries, so change the LIB_TYPE variable to CMake keyword 'SHARED'
182+ SET (LIB_TYPE SHARED)
183+ENDIF (BUILD_SHARED_LIBS)
184+
185+
186+set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${CMAKE_SOURCE_DIR}/../cmake/Modules/")
187+include_directories(${CMAKE_SOURCE_DIR}/../include)
188+
189+find_package(CURL REQUIRED)
190+if (CURL_FOUND)
191+ include_directories(${CURL_INCLUDE_DIRS})
192+endif (CURL_FOUND)
193+
194+find_package(OAUTH REQUIRED)
195+if (OAUTH_FOUND)
196+ include_directories(${OAUTH_INCLUDE_DIRS})
197+endif (OAUTH_FOUND)
198+
199+find_package(JSON REQUIRED)
200+if (JSON_FOUND)
201+ include_directories(${JSON_INCLUDE_DIRS})
202+endif (JSON_FOUND)
203+
204+find_package(Sqlite3 REQUIRED)
205+if (Sqlite3_FOUND)
206+ include_directories(${Sqlite3_INCLUDE_DIRS})
207+endif (Sqlite3_FOUND)
208+
209+add_custom_command (
210+ OUTPUT ${CMAKE_SOURCE_DIR}/u1db_schema.c
211+ COMMAND python ${CMAKE_SOURCE_DIR}/../sql_to_c.py ${CMAKE_SOURCE_DIR}/../u1db/backends/dbschema.sql u1db__schema ${CMAKE_SOURCE_DIR}/u1db_schema.c
212+ DEPENDS ${CMAKE_SOURCE_DIR}/../u1db/backends/dbschema.sql ${CMAKE_SOURCE_DIR}/../sql_to_c.py
213+ )
214+add_library (u1db ${LIB_TYPE} mkstemp_compat.c u1db.c u1db_http_sync_target.c u1db_query.c u1db_sync_target.c u1db_uuid.c u1db_vectorclock.c u1db_schema.c)
215+
216+SET_TARGET_PROPERTIES(u1db PROPERTIES SOVERSION 1)

Subscribers

People subscribed via source and target branches