annotate OrthancFramework/Resources/CMake/ProtobufConfiguration.cmake @ 5187:9466c95f70c8 db-protobuf

integrating Protobuf library into Orthanc server
author Sebastien Jodogne <s.jodogne@gmail.com>
date Sun, 26 Mar 2023 11:59:03 +0200
parents
children 4c6f0211caaf
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
5187
9466c95f70c8 integrating Protobuf library into Orthanc server
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1 # Orthanc - A Lightweight, RESTful DICOM Store
9466c95f70c8 integrating Protobuf library into Orthanc server
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
2 # Copyright (C) 2012-2016 Sebastien Jodogne, Medical Physics
9466c95f70c8 integrating Protobuf library into Orthanc server
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
3 # Department, University Hospital of Liege, Belgium
9466c95f70c8 integrating Protobuf library into Orthanc server
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
4 # Copyright (C) 2017-2023 Osimis S.A., Belgium
9466c95f70c8 integrating Protobuf library into Orthanc server
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
5 # Copyright (C) 2021-2023 Sebastien Jodogne, ICTEAM UCLouvain, Belgium
9466c95f70c8 integrating Protobuf library into Orthanc server
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
6 #
9466c95f70c8 integrating Protobuf library into Orthanc server
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
7 # This program is free software: you can redistribute it and/or
9466c95f70c8 integrating Protobuf library into Orthanc server
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
8 # modify it under the terms of the GNU Lesser General Public License
9466c95f70c8 integrating Protobuf library into Orthanc server
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
9 # as published by the Free Software Foundation, either version 3 of
9466c95f70c8 integrating Protobuf library into Orthanc server
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
10 # the License, or (at your option) any later version.
9466c95f70c8 integrating Protobuf library into Orthanc server
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
11 #
9466c95f70c8 integrating Protobuf library into Orthanc server
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
12 # This program is distributed in the hope that it will be useful, but
9466c95f70c8 integrating Protobuf library into Orthanc server
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
13 # WITHOUT ANY WARRANTY; without even the implied warranty of
9466c95f70c8 integrating Protobuf library into Orthanc server
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
14 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
9466c95f70c8 integrating Protobuf library into Orthanc server
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
15 # Lesser General Public License for more details.
9466c95f70c8 integrating Protobuf library into Orthanc server
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
16 #
9466c95f70c8 integrating Protobuf library into Orthanc server
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
17 # You should have received a copy of the GNU Lesser General Public
9466c95f70c8 integrating Protobuf library into Orthanc server
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
18 # License along with this program. If not, see
9466c95f70c8 integrating Protobuf library into Orthanc server
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
19 # <http://www.gnu.org/licenses/>.
9466c95f70c8 integrating Protobuf library into Orthanc server
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
20
9466c95f70c8 integrating Protobuf library into Orthanc server
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
21
9466c95f70c8 integrating Protobuf library into Orthanc server
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
22 if (STATIC_BUILD OR NOT USE_SYSTEM_PROTOBUF)
9466c95f70c8 integrating Protobuf library into Orthanc server
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
23 include(${CMAKE_CURRENT_LIST_DIR}/../ProtocolBuffers/ProtobufLibrary.cmake)
9466c95f70c8 integrating Protobuf library into Orthanc server
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
24 source_group(ThirdParty\\Protobuf REGULAR_EXPRESSION ${PROTOBUF_SOURCE_DIR}/.*)
9466c95f70c8 integrating Protobuf library into Orthanc server
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
25
9466c95f70c8 integrating Protobuf library into Orthanc server
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
26 else()
9466c95f70c8 integrating Protobuf library into Orthanc server
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
27 find_program(PROTOC_EXECUTABLE protoc)
9466c95f70c8 integrating Protobuf library into Orthanc server
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
28 if (${PROTOC_EXECUTABLE} MATCHES "PROTOC_EXECUTABLE-NOTFOUND")
9466c95f70c8 integrating Protobuf library into Orthanc server
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
29 message(FATAL_ERROR "Please install the 'protoc' compiler for Protocol Buffers (package 'protobuf-compiler' on Debian/Ubuntu)")
9466c95f70c8 integrating Protobuf library into Orthanc server
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
30 endif()
9466c95f70c8 integrating Protobuf library into Orthanc server
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
31
9466c95f70c8 integrating Protobuf library into Orthanc server
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
32 check_include_file_cxx(google/protobuf/any.h HAVE_PROTOBUF_H)
9466c95f70c8 integrating Protobuf library into Orthanc server
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
33 if (NOT HAVE_PROTOBUF_H)
9466c95f70c8 integrating Protobuf library into Orthanc server
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
34 message(FATAL_ERROR "Please install the libprotobuf-dev package")
9466c95f70c8 integrating Protobuf library into Orthanc server
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
35 endif()
9466c95f70c8 integrating Protobuf library into Orthanc server
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
36
9466c95f70c8 integrating Protobuf library into Orthanc server
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
37 set(CMAKE_REQUIRED_LIBRARIES "protobuf")
9466c95f70c8 integrating Protobuf library into Orthanc server
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
38
9466c95f70c8 integrating Protobuf library into Orthanc server
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
39 include(CheckCXXSourceCompiles)
9466c95f70c8 integrating Protobuf library into Orthanc server
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
40 check_cxx_source_compiles(
9466c95f70c8 integrating Protobuf library into Orthanc server
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
41 "
9466c95f70c8 integrating Protobuf library into Orthanc server
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
42 #include <google/protobuf/descriptor.h>
9466c95f70c8 integrating Protobuf library into Orthanc server
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
43 int main()
9466c95f70c8 integrating Protobuf library into Orthanc server
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
44 {
9466c95f70c8 integrating Protobuf library into Orthanc server
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
45 google::protobuf::FieldDescriptor::TypeName(google::protobuf::FieldDescriptor::TYPE_FLOAT);
9466c95f70c8 integrating Protobuf library into Orthanc server
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
46 }
9466c95f70c8 integrating Protobuf library into Orthanc server
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
47 " HAVE_PROTOBUF_LIB)
9466c95f70c8 integrating Protobuf library into Orthanc server
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
48 if (NOT HAVE_PROTOBUF_LIB)
9466c95f70c8 integrating Protobuf library into Orthanc server
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
49 message(FATAL_ERROR "Cannot find the protobuf library")
9466c95f70c8 integrating Protobuf library into Orthanc server
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
50 endif()
9466c95f70c8 integrating Protobuf library into Orthanc server
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
51
9466c95f70c8 integrating Protobuf library into Orthanc server
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
52 unset(CMAKE_REQUIRED_LIBRARIES)
9466c95f70c8 integrating Protobuf library into Orthanc server
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
53
9466c95f70c8 integrating Protobuf library into Orthanc server
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
54 link_libraries(protobuf)
9466c95f70c8 integrating Protobuf library into Orthanc server
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
55 endif()