annotate OrthancFramework/Resources/CMake/ProtobufConfiguration.cmake @ 5640:f7adfb22e20e

updated copyright, as Orthanc Team now replaces Osimis
author Sebastien Jodogne <s.jodogne@gmail.com>
date Thu, 30 May 2024 21:19:57 +0200
parents 48b8dae6dc77
children
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
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: 5207
diff changeset
6 # 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
7 #
9466c95f70c8 integrating Protobuf library into Orthanc server
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
8 # 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
9 # 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
10 # 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
11 # 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
12 #
9466c95f70c8 integrating Protobuf library into Orthanc server
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
13 # 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
14 # 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
15 # 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
16 # Lesser General Public License for more details.
9466c95f70c8 integrating Protobuf library into Orthanc server
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
17 #
9466c95f70c8 integrating Protobuf library into Orthanc server
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
18 # 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
19 # License along with this program. If not, see
9466c95f70c8 integrating Protobuf library into Orthanc server
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
20 # <http://www.gnu.org/licenses/>.
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
9466c95f70c8 integrating Protobuf library into Orthanc server
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
23 if (STATIC_BUILD OR NOT USE_SYSTEM_PROTOBUF)
5188
4c6f0211caaf compiling the protobuf compiler
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5187
diff changeset
24 if (ENABLE_PROTOBUF_COMPILER)
4c6f0211caaf compiling the protobuf compiler
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5187
diff changeset
25 include(ExternalProject)
4c6f0211caaf compiling the protobuf compiler
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5187
diff changeset
26 externalproject_add(ProtobufCompiler
5207
e7529e6241d2 first successful protobuf communication
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5192
diff changeset
27 SOURCE_DIR "${CMAKE_CURRENT_LIST_DIR}/../ProtocolBuffers"
5188
4c6f0211caaf compiling the protobuf compiler
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5187
diff changeset
28 BINARY_DIR "${CMAKE_CURRENT_BINARY_DIR}/ProtobufCompiler-build"
4c6f0211caaf compiling the protobuf compiler
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5187
diff changeset
29 # this helps triggering build when changing the external project
4c6f0211caaf compiling the protobuf compiler
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5187
diff changeset
30 BUILD_ALWAYS 1
4c6f0211caaf compiling the protobuf compiler
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5187
diff changeset
31 CMAKE_ARGS
4c6f0211caaf compiling the protobuf compiler
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5187
diff changeset
32 -DCMAKE_BUILD_TYPE:STRING=${CMAKE_BUILD_TYPE}
4c6f0211caaf compiling the protobuf compiler
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5187
diff changeset
33 -DCMAKE_INSTALL_PREFIX=${CMAKE_CURRENT_BINARY_DIR}
4c6f0211caaf compiling the protobuf compiler
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5187
diff changeset
34 )
5190
c0f6c6fe1c47 fix windows builds
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5188
diff changeset
35
c0f6c6fe1c47 fix windows builds
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5188
diff changeset
36 # The "protoc" compiler is built using "externalproject_add",
c0f6c6fe1c47 fix windows builds
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5188
diff changeset
37 # 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
38 if (CMAKE_HOST_SYSTEM_NAME STREQUAL "Windows")
c0f6c6fe1c47 fix windows builds
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5188
diff changeset
39 set(Suffix ".exe")
c0f6c6fe1c47 fix windows builds
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5188
diff changeset
40 else()
c0f6c6fe1c47 fix windows builds
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5188
diff changeset
41 set(Suffix "")
c0f6c6fe1c47 fix windows builds
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5188
diff changeset
42 endif()
5191
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5190
diff changeset
43
5192
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5191
diff changeset
44 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
45 endif()
4c6f0211caaf compiling the protobuf compiler
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5187
diff changeset
46
5187
9466c95f70c8 integrating Protobuf library into Orthanc server
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
47 include(${CMAKE_CURRENT_LIST_DIR}/../ProtocolBuffers/ProtobufLibrary.cmake)
9466c95f70c8 integrating Protobuf library into Orthanc server
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
48 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
49
9466c95f70c8 integrating Protobuf library into Orthanc server
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
50 else()
5188
4c6f0211caaf compiling the protobuf compiler
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5187
diff changeset
51 if (CMAKE_CROSSCOMPILING)
4c6f0211caaf compiling the protobuf compiler
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5187
diff changeset
52 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
53 endif()
4c6f0211caaf compiling the protobuf compiler
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5187
diff changeset
54
4c6f0211caaf compiling the protobuf compiler
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5187
diff changeset
55 if (ENABLE_PROTOBUF_COMPILER)
4c6f0211caaf compiling the protobuf compiler
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5187
diff changeset
56 find_program(PROTOC_EXECUTABLE protoc)
4c6f0211caaf compiling the protobuf compiler
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5187
diff changeset
57 if (${PROTOC_EXECUTABLE} MATCHES "PROTOC_EXECUTABLE-NOTFOUND")
4c6f0211caaf compiling the protobuf compiler
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5187
diff changeset
58 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
59 endif()
4c6f0211caaf compiling the protobuf compiler
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 5187
diff changeset
60 add_custom_target(ProtobufCompiler)
5187
9466c95f70c8 integrating Protobuf library into Orthanc server
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
61 endif()
9466c95f70c8 integrating Protobuf library into Orthanc server
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
62
9466c95f70c8 integrating Protobuf library into Orthanc server
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
63 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
64 if (NOT HAVE_PROTOBUF_H)
9466c95f70c8 integrating Protobuf library into Orthanc server
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
65 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
66 endif()
9466c95f70c8 integrating Protobuf library into Orthanc server
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
67
9466c95f70c8 integrating Protobuf library into Orthanc server
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
68 set(CMAKE_REQUIRED_LIBRARIES "protobuf")
9466c95f70c8 integrating Protobuf library into Orthanc server
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
69
9466c95f70c8 integrating Protobuf library into Orthanc server
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
70 include(CheckCXXSourceCompiles)
9466c95f70c8 integrating Protobuf library into Orthanc server
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
71 check_cxx_source_compiles(
9466c95f70c8 integrating Protobuf library into Orthanc server
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
72 "
9466c95f70c8 integrating Protobuf library into Orthanc server
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
73 #include <google/protobuf/descriptor.h>
9466c95f70c8 integrating Protobuf library into Orthanc server
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
74 int main()
9466c95f70c8 integrating Protobuf library into Orthanc server
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
75 {
9466c95f70c8 integrating Protobuf library into Orthanc server
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
76 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
77 }
9466c95f70c8 integrating Protobuf library into Orthanc server
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
78 " HAVE_PROTOBUF_LIB)
9466c95f70c8 integrating Protobuf library into Orthanc server
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
79 if (NOT HAVE_PROTOBUF_LIB)
9466c95f70c8 integrating Protobuf library into Orthanc server
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
80 message(FATAL_ERROR "Cannot find the protobuf library")
9466c95f70c8 integrating Protobuf library into Orthanc server
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
81 endif()
9466c95f70c8 integrating Protobuf library into Orthanc server
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
82
9466c95f70c8 integrating Protobuf library into Orthanc server
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
83 unset(CMAKE_REQUIRED_LIBRARIES)
9466c95f70c8 integrating Protobuf library into Orthanc server
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
84
9466c95f70c8 integrating Protobuf library into Orthanc server
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
85 link_libraries(protobuf)
9466c95f70c8 integrating Protobuf library into Orthanc server
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
86 endif()