annotate OrthancFramework/Resources/CMake/SQLiteConfiguration.cmake @ 5651:c4e33e0f907b

merge
author Alain Mazy <am@orthanc.team>
date Wed, 05 Jun 2024 11:04:37 +0200
parents f7adfb22e20e
children 40f236ad829c
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
4120
304842a0d152 adding missing license headers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4044
diff changeset
1 # Orthanc - A Lightweight, RESTful DICOM Store
304842a0d152 adding missing license headers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4044
diff changeset
2 # Copyright (C) 2012-2016 Sebastien Jodogne, Medical Physics
304842a0d152 adding missing license headers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4044
diff changeset
3 # Department, University Hospital of Liege, Belgium
5640
f7adfb22e20e updated copyright, as Orthanc Team now replaces Osimis
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5485
diff changeset
4 # Copyright (C) 2017-2023 Osimis S.A., Belgium
f7adfb22e20e updated copyright, as Orthanc Team now replaces Osimis
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5485
diff changeset
5 # Copyright (C) 2024-2024 Orthanc Team SRL, Belgium
5485
48b8dae6dc77 upgrade to year 2024
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5434
diff changeset
6 # Copyright (C) 2021-2024 Sebastien Jodogne, ICTEAM UCLouvain, Belgium
4120
304842a0d152 adding missing license headers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4044
diff changeset
7 #
304842a0d152 adding missing license headers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4044
diff changeset
8 # This program is free software: you can redistribute it and/or
304842a0d152 adding missing license headers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4044
diff changeset
9 # modify it under the terms of the GNU Lesser General Public License
304842a0d152 adding missing license headers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4044
diff changeset
10 # as published by the Free Software Foundation, either version 3 of
304842a0d152 adding missing license headers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4044
diff changeset
11 # the License, or (at your option) any later version.
304842a0d152 adding missing license headers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4044
diff changeset
12 #
304842a0d152 adding missing license headers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4044
diff changeset
13 # This program is distributed in the hope that it will be useful, but
304842a0d152 adding missing license headers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4044
diff changeset
14 # WITHOUT ANY WARRANTY; without even the implied warranty of
304842a0d152 adding missing license headers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4044
diff changeset
15 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
304842a0d152 adding missing license headers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4044
diff changeset
16 # Lesser General Public License for more details.
304842a0d152 adding missing license headers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4044
diff changeset
17 #
304842a0d152 adding missing license headers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4044
diff changeset
18 # You should have received a copy of the GNU Lesser General Public
304842a0d152 adding missing license headers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4044
diff changeset
19 # License along with this program. If not, see
304842a0d152 adding missing license headers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4044
diff changeset
20 # <http://www.gnu.org/licenses/>.
304842a0d152 adding missing license headers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4044
diff changeset
21
304842a0d152 adding missing license headers
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 4044
diff changeset
22
1475
3a5b8ed2d859 fix for OS X
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1414
diff changeset
23 if (APPLE)
3a5b8ed2d859 fix for OS X
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1414
diff changeset
24 # Under OS X, the binaries must always be linked against the
3a5b8ed2d859 fix for OS X
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1414
diff changeset
25 # system-wide version of SQLite. Otherwise, if some Orthanc plugin
3a5b8ed2d859 fix for OS X
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1414
diff changeset
26 # also uses its own version of SQLite (such as orthanc-webviewer),
3a5b8ed2d859 fix for OS X
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1414
diff changeset
27 # this results in a crash in "sqlite3_mutex_enter(db->mutex);" (the
3a5b8ed2d859 fix for OS X
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1414
diff changeset
28 # mutex is not initialized), probably because the EXE and the DYNLIB
3a5b8ed2d859 fix for OS X
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1414
diff changeset
29 # share the same memory location for this mutex.
3a5b8ed2d859 fix for OS X
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1414
diff changeset
30 set(SQLITE_STATIC OFF)
3a5b8ed2d859 fix for OS X
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1414
diff changeset
31
3a5b8ed2d859 fix for OS X
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1414
diff changeset
32 elseif (STATIC_BUILD OR NOT USE_SYSTEM_SQLITE)
3a5b8ed2d859 fix for OS X
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1414
diff changeset
33 set(SQLITE_STATIC ON)
3a5b8ed2d859 fix for OS X
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1414
diff changeset
34 else()
3a5b8ed2d859 fix for OS X
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1414
diff changeset
35 set(SQLITE_STATIC OFF)
3a5b8ed2d859 fix for OS X
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1414
diff changeset
36 endif()
3a5b8ed2d859 fix for OS X
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1414
diff changeset
37
3a5b8ed2d859 fix for OS X
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1414
diff changeset
38
3a5b8ed2d859 fix for OS X
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1414
diff changeset
39 if (SQLITE_STATIC)
3291
508fa367c493 upgrade to sqlite amalgamation 3.27.1
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3133
diff changeset
40 SET(SQLITE_SOURCES_DIR ${CMAKE_BINARY_DIR}/sqlite-amalgamation-3270100)
508fa367c493 upgrade to sqlite amalgamation 3.27.1
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3133
diff changeset
41 SET(SQLITE_MD5 "16717b26358ba81f0bfdac07addc77da")
5434
aa1c09fa6632 changed location of third-party downloads
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5271
diff changeset
42 SET(SQLITE_URL "https://orthanc.uclouvain.be/downloads/third-party-downloads/sqlite-amalgamation-3270100.zip")
1537
fbf763bb1fa3 error detection in patches
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1475
diff changeset
43
3992
f9863630ec7f working on the shared library for Orthanc framework
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3833
diff changeset
44 set(ORTHANC_SQLITE_VERSION 3027001)
2302
f31dfb131dee fix backward compatibility with SQLite < 3.19.0
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2186
diff changeset
45
1537
fbf763bb1fa3 error detection in patches
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1475
diff changeset
46 DownloadPackage(${SQLITE_MD5} ${SQLITE_URL} "${SQLITE_SOURCES_DIR}")
735
ee0d5abf7958 dos2unix
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 634
diff changeset
47
1414
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1335
diff changeset
48 set(SQLITE_SOURCES
735
ee0d5abf7958 dos2unix
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 634
diff changeset
49 ${SQLITE_SOURCES_DIR}/sqlite3.c
ee0d5abf7958 dos2unix
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 634
diff changeset
50 )
ee0d5abf7958 dos2unix
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 634
diff changeset
51
ee0d5abf7958 dos2unix
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 634
diff changeset
52 add_definitions(
ee0d5abf7958 dos2unix
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 634
diff changeset
53 # For SQLite to run in the "Serialized" thread-safe mode
ee0d5abf7958 dos2unix
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 634
diff changeset
54 # http://www.sqlite.org/threadsafe.html
ee0d5abf7958 dos2unix
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 634
diff changeset
55 -DSQLITE_THREADSAFE=1
ee0d5abf7958 dos2unix
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 634
diff changeset
56 -DSQLITE_OMIT_LOAD_EXTENSION # Disable SQLite plugins
ee0d5abf7958 dos2unix
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 634
diff changeset
57 )
ee0d5abf7958 dos2unix
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 634
diff changeset
58
ee0d5abf7958 dos2unix
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 634
diff changeset
59 include_directories(
ee0d5abf7958 dos2unix
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 634
diff changeset
60 ${SQLITE_SOURCES_DIR}
ee0d5abf7958 dos2unix
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 634
diff changeset
61 )
ee0d5abf7958 dos2unix
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 634
diff changeset
62
ee0d5abf7958 dos2unix
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 634
diff changeset
63 source_group(ThirdParty\\SQLite REGULAR_EXPRESSION ${SQLITE_SOURCES_DIR}/.*)
ee0d5abf7958 dos2unix
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 634
diff changeset
64
ee0d5abf7958 dos2unix
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 634
diff changeset
65 else()
3833
a3e38994d95a compilation on mips qemu
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3291
diff changeset
66 CHECK_INCLUDE_FILE(sqlite3.h HAVE_SQLITE_H)
735
ee0d5abf7958 dos2unix
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 634
diff changeset
67 if (NOT HAVE_SQLITE_H)
ee0d5abf7958 dos2unix
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 634
diff changeset
68 message(FATAL_ERROR "Please install the libsqlite3-dev package")
ee0d5abf7958 dos2unix
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 634
diff changeset
69 endif()
ee0d5abf7958 dos2unix
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 634
diff changeset
70
3833
a3e38994d95a compilation on mips qemu
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3291
diff changeset
71 find_path(SQLITE_INCLUDE_DIR
a3e38994d95a compilation on mips qemu
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3291
diff changeset
72 NAMES sqlite3.h
a3e38994d95a compilation on mips qemu
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3291
diff changeset
73 PATHS
1335
4bed63189508 enhanced header lookup
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1334
diff changeset
74 /usr/include
4bed63189508 enhanced header lookup
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1334
diff changeset
75 /usr/local/include
4bed63189508 enhanced header lookup
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1334
diff changeset
76 )
1334
7f0aa3c0f659 code improvements
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 735
diff changeset
77 message("SQLite include dir: ${SQLITE_INCLUDE_DIR}")
7f0aa3c0f659 code improvements
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 735
diff changeset
78
735
ee0d5abf7958 dos2unix
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 634
diff changeset
79 # Autodetection of the version of SQLite
1334
7f0aa3c0f659 code improvements
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 735
diff changeset
80 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
81 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
82
f31dfb131dee fix backward compatibility with SQLite < 3.19.0
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2186
diff changeset
83 # Remove the trailing spaces to convert the string to a proper integer
3992
f9863630ec7f working on the shared library for Orthanc framework
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3833
diff changeset
84 string(STRIP ${SQLITE_VERSION_NUMBER2} ORTHANC_SQLITE_VERSION)
735
ee0d5abf7958 dos2unix
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 634
diff changeset
85
3992
f9863630ec7f working on the shared library for Orthanc framework
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3833
diff changeset
86 message("Detected version of SQLite: ${ORTHANC_SQLITE_VERSION}")
735
ee0d5abf7958 dos2unix
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 634
diff changeset
87
3992
f9863630ec7f working on the shared library for Orthanc framework
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3833
diff changeset
88 IF (${ORTHANC_SQLITE_VERSION} LESS 3007000)
735
ee0d5abf7958 dos2unix
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 634
diff changeset
89 # "sqlite3_create_function_v2" is not defined in SQLite < 3.7.0
ee0d5abf7958 dos2unix
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 634
diff changeset
90 message(FATAL_ERROR "SQLite version must be above 3.7.0. Please set the CMake variable USE_SYSTEM_SQLITE to OFF.")
ee0d5abf7958 dos2unix
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 634
diff changeset
91 ENDIF()
ee0d5abf7958 dos2unix
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 634
diff changeset
92
ee0d5abf7958 dos2unix
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 634
diff changeset
93 link_libraries(sqlite3)
ee0d5abf7958 dos2unix
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 634
diff changeset
94 endif()
3992
f9863630ec7f working on the shared library for Orthanc framework
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3833
diff changeset
95
f9863630ec7f working on the shared library for Orthanc framework
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3833
diff changeset
96
f9863630ec7f working on the shared library for Orthanc framework
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3833
diff changeset
97 add_definitions(
f9863630ec7f working on the shared library for Orthanc framework
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3833
diff changeset
98 -DORTHANC_SQLITE_VERSION=${ORTHANC_SQLITE_VERSION}
f9863630ec7f working on the shared library for Orthanc framework
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 3833
diff changeset
99 )