Mercurial > hg > orthanc
annotate Resources/CMake/SQLiteConfiguration.cmake @ 3200:1f4a2c58e7fa
set encoding to UTF-8, IBinaryFormatter
author | Sebastien Jodogne <s.jodogne@gmail.com> |
---|---|
date | Wed, 06 Feb 2019 13:51:20 +0100 |
parents | 0c2a8d5e0097 |
children | 508fa367c493 |
rev | line source |
---|---|
1475 | 1 if (APPLE) |
2 # Under OS X, the binaries must always be linked against the | |
3 # system-wide version of SQLite. Otherwise, if some Orthanc plugin | |
4 # also uses its own version of SQLite (such as orthanc-webviewer), | |
5 # this results in a crash in "sqlite3_mutex_enter(db->mutex);" (the | |
6 # mutex is not initialized), probably because the EXE and the DYNLIB | |
7 # share the same memory location for this mutex. | |
8 set(SQLITE_STATIC OFF) | |
9 | |
10 elseif (STATIC_BUILD OR NOT USE_SYSTEM_SQLITE) | |
11 set(SQLITE_STATIC ON) | |
12 else() | |
13 set(SQLITE_STATIC OFF) | |
14 endif() | |
15 | |
16 | |
17 if (SQLITE_STATIC) | |
2435
07dd79e70b79
Upgrade to SQLite amalgamation 3.21.0 in static builds
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2384
diff
changeset
|
18 SET(SQLITE_SOURCES_DIR ${CMAKE_BINARY_DIR}/sqlite-amalgamation-3210000) |
07dd79e70b79
Upgrade to SQLite amalgamation 3.21.0 in static builds
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2384
diff
changeset
|
19 SET(SQLITE_MD5 "fe330e88d81e77e1e61554a370ae5001") |
3133
0c2a8d5e0097
moving third-party dependencies to another server
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2435
diff
changeset
|
20 SET(SQLITE_URL "http://orthanc.osimis.io/ThirdPartyDownloads/sqlite-amalgamation-3210000.zip") |
1537
fbf763bb1fa3
error detection in patches
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1475
diff
changeset
|
21 |
2435
07dd79e70b79
Upgrade to SQLite amalgamation 3.21.0 in static builds
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2384
diff
changeset
|
22 add_definitions(-DORTHANC_SQLITE_VERSION=3021000) |
2302
f31dfb131dee
fix backward compatibility with SQLite < 3.19.0
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2186
diff
changeset
|
23 |
1537
fbf763bb1fa3
error detection in patches
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1475
diff
changeset
|
24 DownloadPackage(${SQLITE_MD5} ${SQLITE_URL} "${SQLITE_SOURCES_DIR}") |
735 | 25 |
1414 | 26 set(SQLITE_SOURCES |
735 | 27 ${SQLITE_SOURCES_DIR}/sqlite3.c |
28 ) | |
29 | |
30 add_definitions( | |
31 # For SQLite to run in the "Serialized" thread-safe mode | |
32 # http://www.sqlite.org/threadsafe.html | |
33 -DSQLITE_THREADSAFE=1 | |
34 -DSQLITE_OMIT_LOAD_EXTENSION # Disable SQLite plugins | |
35 ) | |
36 | |
37 include_directories( | |
38 ${SQLITE_SOURCES_DIR} | |
39 ) | |
40 | |
41 source_group(ThirdParty\\SQLite REGULAR_EXPRESSION ${SQLITE_SOURCES_DIR}/.*) | |
42 | |
43 else() | |
44 CHECK_INCLUDE_FILE_CXX(sqlite3.h HAVE_SQLITE_H) | |
45 if (NOT HAVE_SQLITE_H) | |
46 message(FATAL_ERROR "Please install the libsqlite3-dev package") | |
47 endif() | |
48 | |
1335
4bed63189508
enhanced header lookup
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1334
diff
changeset
|
49 find_path(SQLITE_INCLUDE_DIR sqlite3.h |
4bed63189508
enhanced header lookup
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1334
diff
changeset
|
50 /usr/include |
4bed63189508
enhanced header lookup
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1334
diff
changeset
|
51 /usr/local/include |
4bed63189508
enhanced header lookup
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1334
diff
changeset
|
52 ) |
1334 | 53 message("SQLite include dir: ${SQLITE_INCLUDE_DIR}") |
54 | |
735 | 55 # Autodetection of the version of SQLite |
1334 | 56 file(STRINGS "${SQLITE_INCLUDE_DIR}/sqlite3.h" SQLITE_VERSION_NUMBER1 REGEX "#define SQLITE_VERSION_NUMBER.*$") |
2302
f31dfb131dee
fix backward compatibility with SQLite < 3.19.0
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2186
diff
changeset
|
57 string(REGEX REPLACE "#define SQLITE_VERSION_NUMBER(.*)$" "\\1" SQLITE_VERSION_NUMBER2 ${SQLITE_VERSION_NUMBER1}) |
f31dfb131dee
fix backward compatibility with SQLite < 3.19.0
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2186
diff
changeset
|
58 |
f31dfb131dee
fix backward compatibility with SQLite < 3.19.0
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2186
diff
changeset
|
59 # Remove the trailing spaces to convert the string to a proper integer |
f31dfb131dee
fix backward compatibility with SQLite < 3.19.0
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2186
diff
changeset
|
60 string(STRIP ${SQLITE_VERSION_NUMBER2} SQLITE_VERSION_NUMBER) |
735 | 61 |
62 message("Detected version of SQLite: ${SQLITE_VERSION_NUMBER}") | |
63 | |
64 IF (${SQLITE_VERSION_NUMBER} LESS 3007000) | |
65 # "sqlite3_create_function_v2" is not defined in SQLite < 3.7.0 | |
66 message(FATAL_ERROR "SQLite version must be above 3.7.0. Please set the CMake variable USE_SYSTEM_SQLITE to OFF.") | |
67 ENDIF() | |
68 | |
2302
f31dfb131dee
fix backward compatibility with SQLite < 3.19.0
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2186
diff
changeset
|
69 add_definitions(-DORTHANC_SQLITE_VERSION=${SQLITE_VERSION_NUMBER}) |
f31dfb131dee
fix backward compatibility with SQLite < 3.19.0
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2186
diff
changeset
|
70 |
735 | 71 link_libraries(sqlite3) |
72 endif() |