annotate OrthancFramework/Resources/CMake/ProtobufConfiguration.cmake @ 5579:77570cce8855 find-refactoring

removed redundant FindResponse::resourceId_
author Sebastien Jodogne <s.jodogne@gmail.com>
date Sat, 27 Apr 2024 11:31:39 +0200
parents 48b8dae6dc77
children f7adfb22e20e
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
5485
48b8dae6dc77 upgrade to year 2024
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5207
diff changeset
4 # Copyright (C) 2017-2024 Osimis S.A., Belgium
48b8dae6dc77 upgrade to year 2024
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5207
diff changeset
5 # Copyright (C) 2021-2024 Sebastien Jodogne, ICTEAM UCLouvain, Belgium
5187
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)
5188
4c6f0211caaf compiling the protobuf compiler
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5187
diff changeset
23 if (ENABLE_PROTOBUF_COMPILER)
4c6f0211caaf compiling the protobuf compiler
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5187
diff changeset
24 include(ExternalProject)
4c6f0211caaf compiling the protobuf compiler
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5187
diff changeset
25 externalproject_add(ProtobufCompiler
5207
e7529e6241d2 first successful protobuf communication
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5192
diff changeset
26 SOURCE_DIR "${CMAKE_CURRENT_LIST_DIR}/../ProtocolBuffers"
5188
4c6f0211caaf compiling the protobuf compiler
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5187
diff changeset
27 BINARY_DIR "${CMAKE_CURRENT_BINARY_DIR}/ProtobufCompiler-build"
4c6f0211caaf compiling the protobuf compiler
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5187
diff changeset
28 # this helps triggering build when changing the external project
4c6f0211caaf compiling the protobuf compiler
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5187
diff changeset
29 BUILD_ALWAYS 1
4c6f0211caaf compiling the protobuf compiler
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5187
diff changeset
30 CMAKE_ARGS
4c6f0211caaf compiling the protobuf compiler
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5187
diff changeset
31 -DCMAKE_BUILD_TYPE:STRING=${CMAKE_BUILD_TYPE}
4c6f0211caaf compiling the protobuf compiler
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5187
diff changeset
32 -DCMAKE_INSTALL_PREFIX=${CMAKE_CURRENT_BINARY_DIR}
4c6f0211caaf compiling the protobuf compiler
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5187
diff changeset
33 )
5190
c0f6c6fe1c47 fix windows builds
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5188
diff changeset
34
c0f6c6fe1c47 fix windows builds
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5188
diff changeset
35 # The "protoc" compiler is built using "externalproject_add",
c0f6c6fe1c47 fix windows builds
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5188
diff changeset
36 # which builds for the host platform, not for the target platform
c0f6c6fe1c47 fix windows builds
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5188
diff changeset
37 if (CMAKE_HOST_SYSTEM_NAME STREQUAL "Windows")
c0f6c6fe1c47 fix windows builds
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5188
diff changeset
38 set(Suffix ".exe")
c0f6c6fe1c47 fix windows builds
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5188
diff changeset
39 else()
c0f6c6fe1c47 fix windows builds
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5188
diff changeset
40 set(Suffix "")
c0f6c6fe1c47 fix windows builds
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5188
diff changeset
41 endif()
5191
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5190
diff changeset
42
5192
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5191
diff changeset
43 set(PROTOC_EXECUTABLE ${CMAKE_CURRENT_BINARY_DIR}/protoc${Suffix})
5188
4c6f0211caaf compiling the protobuf compiler
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5187
diff changeset
44 endif()
4c6f0211caaf compiling the protobuf compiler
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5187
diff changeset
45
5187
9466c95f70c8 integrating Protobuf library into Orthanc server
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
46 include(${CMAKE_CURRENT_LIST_DIR}/../ProtocolBuffers/ProtobufLibrary.cmake)
9466c95f70c8 integrating Protobuf library into Orthanc server
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
47 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
48
9466c95f70c8 integrating Protobuf library into Orthanc server
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
49 else()
5188
4c6f0211caaf compiling the protobuf compiler
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5187
diff changeset
50 if (CMAKE_CROSSCOMPILING)
4c6f0211caaf compiling the protobuf compiler
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5187
diff changeset
51 message(FATAL_ERROR "If cross-compiling, the static version of Protocol Buffers should be used to avoid version mismatch")
4c6f0211caaf compiling the protobuf compiler
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5187
diff changeset
52 endif()
4c6f0211caaf compiling the protobuf compiler
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5187
diff changeset
53
4c6f0211caaf compiling the protobuf compiler
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5187
diff changeset
54 if (ENABLE_PROTOBUF_COMPILER)
4c6f0211caaf compiling the protobuf compiler
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5187
diff changeset
55 find_program(PROTOC_EXECUTABLE protoc)
4c6f0211caaf compiling the protobuf compiler
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5187
diff changeset
56 if (${PROTOC_EXECUTABLE} MATCHES "PROTOC_EXECUTABLE-NOTFOUND")
4c6f0211caaf compiling the protobuf compiler
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5187
diff changeset
57 message(FATAL_ERROR "Please install the 'protoc' compiler for Protocol Buffers (package 'protobuf-compiler' on Debian/Ubuntu)")
4c6f0211caaf compiling the protobuf compiler
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5187
diff changeset
58 endif()
4c6f0211caaf compiling the protobuf compiler
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5187
diff changeset
59 add_custom_target(ProtobufCompiler)
5187
9466c95f70c8 integrating Protobuf library into Orthanc server
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
60 endif()
9466c95f70c8 integrating Protobuf library into Orthanc server
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
61
9466c95f70c8 integrating Protobuf library into Orthanc server
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
62 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
63 if (NOT HAVE_PROTOBUF_H)
9466c95f70c8 integrating Protobuf library into Orthanc server
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
64 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
65 endif()
9466c95f70c8 integrating Protobuf library into Orthanc server
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
66
9466c95f70c8 integrating Protobuf library into Orthanc server
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
67 set(CMAKE_REQUIRED_LIBRARIES "protobuf")
9466c95f70c8 integrating Protobuf library into Orthanc server
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
68
9466c95f70c8 integrating Protobuf library into Orthanc server
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
69 include(CheckCXXSourceCompiles)
9466c95f70c8 integrating Protobuf library into Orthanc server
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
70 check_cxx_source_compiles(
9466c95f70c8 integrating Protobuf library into Orthanc server
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
71 "
9466c95f70c8 integrating Protobuf library into Orthanc server
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
72 #include <google/protobuf/descriptor.h>
9466c95f70c8 integrating Protobuf library into Orthanc server
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
73 int main()
9466c95f70c8 integrating Protobuf library into Orthanc server
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
74 {
9466c95f70c8 integrating Protobuf library into Orthanc server
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
75 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
76 }
9466c95f70c8 integrating Protobuf library into Orthanc server
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
77 " HAVE_PROTOBUF_LIB)
9466c95f70c8 integrating Protobuf library into Orthanc server
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
78 if (NOT HAVE_PROTOBUF_LIB)
9466c95f70c8 integrating Protobuf library into Orthanc server
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
79 message(FATAL_ERROR "Cannot find the protobuf library")
9466c95f70c8 integrating Protobuf library into Orthanc server
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
80 endif()
9466c95f70c8 integrating Protobuf library into Orthanc server
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
81
9466c95f70c8 integrating Protobuf library into Orthanc server
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
82 unset(CMAKE_REQUIRED_LIBRARIES)
9466c95f70c8 integrating Protobuf library into Orthanc server
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
83
9466c95f70c8 integrating Protobuf library into Orthanc server
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
84 link_libraries(protobuf)
9466c95f70c8 integrating Protobuf library into Orthanc server
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
85 endif()