annotate Resources/Orthanc/CMake/ProtobufConfiguration.cmake @ 456:0ac99983abfa pg-transactions

missing drop function
author Alain Mazy <am@osimis.io>
date Tue, 23 Jan 2024 16:50:55 +0100
parents e25f4500b531
children ecd0b719cff5
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
409
e25f4500b531 fix linking against system-wide Orthanc framework
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1 # Orthanc - A Lightweight, RESTful DICOM Store
e25f4500b531 fix linking against system-wide Orthanc framework
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
2 # Copyright (C) 2012-2016 Sebastien Jodogne, Medical Physics
e25f4500b531 fix linking against system-wide Orthanc framework
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
3 # Department, University Hospital of Liege, Belgium
e25f4500b531 fix linking against system-wide Orthanc framework
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
4 # Copyright (C) 2017-2023 Osimis S.A., Belgium
e25f4500b531 fix linking against system-wide Orthanc framework
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
5 # Copyright (C) 2021-2023 Sebastien Jodogne, ICTEAM UCLouvain, Belgium
e25f4500b531 fix linking against system-wide Orthanc framework
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
6 #
e25f4500b531 fix linking against system-wide Orthanc framework
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
7 # This program is free software: you can redistribute it and/or
e25f4500b531 fix linking against system-wide Orthanc framework
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
8 # modify it under the terms of the GNU Lesser General Public License
e25f4500b531 fix linking against system-wide Orthanc framework
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
9 # as published by the Free Software Foundation, either version 3 of
e25f4500b531 fix linking against system-wide Orthanc framework
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
10 # the License, or (at your option) any later version.
e25f4500b531 fix linking against system-wide Orthanc framework
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
11 #
e25f4500b531 fix linking against system-wide Orthanc framework
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
12 # This program is distributed in the hope that it will be useful, but
e25f4500b531 fix linking against system-wide Orthanc framework
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
13 # WITHOUT ANY WARRANTY; without even the implied warranty of
e25f4500b531 fix linking against system-wide Orthanc framework
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
14 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
e25f4500b531 fix linking against system-wide Orthanc framework
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
15 # Lesser General Public License for more details.
e25f4500b531 fix linking against system-wide Orthanc framework
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
16 #
e25f4500b531 fix linking against system-wide Orthanc framework
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
17 # You should have received a copy of the GNU Lesser General Public
e25f4500b531 fix linking against system-wide Orthanc framework
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
18 # License along with this program. If not, see
e25f4500b531 fix linking against system-wide Orthanc framework
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
19 # <http://www.gnu.org/licenses/>.
e25f4500b531 fix linking against system-wide Orthanc framework
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
20
e25f4500b531 fix linking against system-wide Orthanc framework
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
21
e25f4500b531 fix linking against system-wide Orthanc framework
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
22 if (STATIC_BUILD OR NOT USE_SYSTEM_PROTOBUF)
e25f4500b531 fix linking against system-wide Orthanc framework
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
23 if (ENABLE_PROTOBUF_COMPILER)
e25f4500b531 fix linking against system-wide Orthanc framework
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
24 include(ExternalProject)
e25f4500b531 fix linking against system-wide Orthanc framework
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
25 externalproject_add(ProtobufCompiler
e25f4500b531 fix linking against system-wide Orthanc framework
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
26 SOURCE_DIR "${CMAKE_CURRENT_LIST_DIR}/../ProtocolBuffers"
e25f4500b531 fix linking against system-wide Orthanc framework
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
27 BINARY_DIR "${CMAKE_CURRENT_BINARY_DIR}/ProtobufCompiler-build"
e25f4500b531 fix linking against system-wide Orthanc framework
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
28 # this helps triggering build when changing the external project
e25f4500b531 fix linking against system-wide Orthanc framework
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
29 BUILD_ALWAYS 1
e25f4500b531 fix linking against system-wide Orthanc framework
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
30 CMAKE_ARGS
e25f4500b531 fix linking against system-wide Orthanc framework
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
31 -DCMAKE_BUILD_TYPE:STRING=${CMAKE_BUILD_TYPE}
e25f4500b531 fix linking against system-wide Orthanc framework
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
32 -DCMAKE_INSTALL_PREFIX=${CMAKE_CURRENT_BINARY_DIR}
e25f4500b531 fix linking against system-wide Orthanc framework
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
33 )
e25f4500b531 fix linking against system-wide Orthanc framework
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
34
e25f4500b531 fix linking against system-wide Orthanc framework
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
35 # The "protoc" compiler is built using "externalproject_add",
e25f4500b531 fix linking against system-wide Orthanc framework
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
36 # which builds for the host platform, not for the target platform
e25f4500b531 fix linking against system-wide Orthanc framework
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
37 if (CMAKE_HOST_SYSTEM_NAME STREQUAL "Windows")
e25f4500b531 fix linking against system-wide Orthanc framework
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
38 set(Suffix ".exe")
e25f4500b531 fix linking against system-wide Orthanc framework
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
39 else()
e25f4500b531 fix linking against system-wide Orthanc framework
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
40 set(Suffix "")
e25f4500b531 fix linking against system-wide Orthanc framework
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
41 endif()
e25f4500b531 fix linking against system-wide Orthanc framework
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
42
e25f4500b531 fix linking against system-wide Orthanc framework
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
43 set(PROTOC_EXECUTABLE ${CMAKE_CURRENT_BINARY_DIR}/protoc${Suffix})
e25f4500b531 fix linking against system-wide Orthanc framework
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
44 endif()
e25f4500b531 fix linking against system-wide Orthanc framework
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
45
e25f4500b531 fix linking against system-wide Orthanc framework
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
46 include(${CMAKE_CURRENT_LIST_DIR}/../ProtocolBuffers/ProtobufLibrary.cmake)
e25f4500b531 fix linking against system-wide Orthanc framework
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
47 source_group(ThirdParty\\Protobuf REGULAR_EXPRESSION ${PROTOBUF_SOURCE_DIR}/.*)
e25f4500b531 fix linking against system-wide Orthanc framework
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
48
e25f4500b531 fix linking against system-wide Orthanc framework
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
49 else()
e25f4500b531 fix linking against system-wide Orthanc framework
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
50 if (CMAKE_CROSSCOMPILING)
e25f4500b531 fix linking against system-wide Orthanc framework
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
51 message(FATAL_ERROR "If cross-compiling, the static version of Protocol Buffers should be used to avoid version mismatch")
e25f4500b531 fix linking against system-wide Orthanc framework
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
52 endif()
e25f4500b531 fix linking against system-wide Orthanc framework
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
53
e25f4500b531 fix linking against system-wide Orthanc framework
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
54 if (ENABLE_PROTOBUF_COMPILER)
e25f4500b531 fix linking against system-wide Orthanc framework
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
55 find_program(PROTOC_EXECUTABLE protoc)
e25f4500b531 fix linking against system-wide Orthanc framework
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
56 if (${PROTOC_EXECUTABLE} MATCHES "PROTOC_EXECUTABLE-NOTFOUND")
e25f4500b531 fix linking against system-wide Orthanc framework
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
57 message(FATAL_ERROR "Please install the 'protoc' compiler for Protocol Buffers (package 'protobuf-compiler' on Debian/Ubuntu)")
e25f4500b531 fix linking against system-wide Orthanc framework
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
58 endif()
e25f4500b531 fix linking against system-wide Orthanc framework
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
59 add_custom_target(ProtobufCompiler)
e25f4500b531 fix linking against system-wide Orthanc framework
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
60 endif()
e25f4500b531 fix linking against system-wide Orthanc framework
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
61
e25f4500b531 fix linking against system-wide Orthanc framework
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
62 check_include_file_cxx(google/protobuf/any.h HAVE_PROTOBUF_H)
e25f4500b531 fix linking against system-wide Orthanc framework
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
63 if (NOT HAVE_PROTOBUF_H)
e25f4500b531 fix linking against system-wide Orthanc framework
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
64 message(FATAL_ERROR "Please install the libprotobuf-dev package")
e25f4500b531 fix linking against system-wide Orthanc framework
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
65 endif()
e25f4500b531 fix linking against system-wide Orthanc framework
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
66
e25f4500b531 fix linking against system-wide Orthanc framework
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
67 set(CMAKE_REQUIRED_LIBRARIES "protobuf")
e25f4500b531 fix linking against system-wide Orthanc framework
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
68
e25f4500b531 fix linking against system-wide Orthanc framework
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
69 include(CheckCXXSourceCompiles)
e25f4500b531 fix linking against system-wide Orthanc framework
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
70 check_cxx_source_compiles(
e25f4500b531 fix linking against system-wide Orthanc framework
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
71 "
e25f4500b531 fix linking against system-wide Orthanc framework
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
72 #include <google/protobuf/descriptor.h>
e25f4500b531 fix linking against system-wide Orthanc framework
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
73 int main()
e25f4500b531 fix linking against system-wide Orthanc framework
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
74 {
e25f4500b531 fix linking against system-wide Orthanc framework
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
75 google::protobuf::FieldDescriptor::TypeName(google::protobuf::FieldDescriptor::TYPE_FLOAT);
e25f4500b531 fix linking against system-wide Orthanc framework
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
76 }
e25f4500b531 fix linking against system-wide Orthanc framework
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
77 " HAVE_PROTOBUF_LIB)
e25f4500b531 fix linking against system-wide Orthanc framework
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
78 if (NOT HAVE_PROTOBUF_LIB)
e25f4500b531 fix linking against system-wide Orthanc framework
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
79 message(FATAL_ERROR "Cannot find the protobuf library")
e25f4500b531 fix linking against system-wide Orthanc framework
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
80 endif()
e25f4500b531 fix linking against system-wide Orthanc framework
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
81
e25f4500b531 fix linking against system-wide Orthanc framework
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
82 unset(CMAKE_REQUIRED_LIBRARIES)
e25f4500b531 fix linking against system-wide Orthanc framework
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
83
e25f4500b531 fix linking against system-wide Orthanc framework
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
84 link_libraries(protobuf)
e25f4500b531 fix linking against system-wide Orthanc framework
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
85 endif()