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