Mercurial > hg > orthanc
changeset 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 | 8d19e53cf23e |
children | 4c6f0211caaf |
files | OrthancFramework/Resources/CMake/OrthancFrameworkConfiguration.cmake OrthancFramework/Resources/CMake/OrthancFrameworkParameters.cmake OrthancFramework/Resources/CMake/ProtobufConfiguration.cmake OrthancFramework/Resources/ProtocolBuffers/CMakeLists.txt OrthancFramework/Resources/ProtocolBuffers/ProtobufLibrary.cmake OrthancServer/CMakeLists.txt |
diffstat | 6 files changed, 94 insertions(+), 10 deletions(-) [+] |
line wrap: on
line diff
--- a/OrthancFramework/Resources/CMake/OrthancFrameworkConfiguration.cmake Sun Mar 26 10:46:09 2023 +0200 +++ b/OrthancFramework/Resources/CMake/OrthancFrameworkConfiguration.cmake Sun Mar 26 11:59:03 2023 +0200 @@ -141,6 +141,11 @@ unset(ENABLE_DCMTK_LOG CACHE) endif() +if (NOT ENABLE_PROTOBUF) + unset(USE_SYSTEM_PROTOBUF CACHE) + add_definitions(-DORTHANC_ENABLE_PROTOBUF=0) +endif() + ##################################################################### ## List of source files @@ -476,6 +481,16 @@ endif() +## +## Google Protocol Buffers +## + +if (ENABLE_PROTOBUF) + include(${CMAKE_CURRENT_LIST_DIR}/ProtobufConfiguration.cmake) + add_definitions(-DORTHANC_ENABLE_PROTOBUF=1) +endif() + + ##################################################################### ## Inclusion of mandatory third-party dependencies @@ -712,6 +727,7 @@ ${LUA_SOURCES} ${MONGOOSE_SOURCES} ${OPENSSL_SOURCES} + ${PROTOBUF_LIBRARY_SOURCES} ${PUGIXML_SOURCES} ${SQLITE_SOURCES} ${UUID_SOURCES}
--- a/OrthancFramework/Resources/CMake/OrthancFrameworkParameters.cmake Sun Mar 26 10:46:09 2023 +0200 +++ b/OrthancFramework/Resources/CMake/OrthancFrameworkParameters.cmake Sun Mar 26 11:59:03 2023 +0200 @@ -70,6 +70,7 @@ set(USE_SYSTEM_LUA ON CACHE BOOL "Use the system version of Lua") set(USE_SYSTEM_MONGOOSE ON CACHE BOOL "Use the system version of Mongoose") set(USE_SYSTEM_OPENSSL ON CACHE BOOL "Use the system version of OpenSSL") +set(USE_SYSTEM_PROTOBUF ON CACHE BOOL "Use the system version of Google Protocol Buffers") set(USE_SYSTEM_PUGIXML ON CACHE BOOL "Use the system version of Pugixml") set(USE_SYSTEM_SQLITE ON CACHE BOOL "Use the system version of SQLite") set(USE_SYSTEM_UUID ON CACHE BOOL "Use the system version of the uuid library from e2fsprogs") @@ -123,6 +124,7 @@ set(ENABLE_LOCALE OFF CACHE INTERNAL "Enable support for locales (notably in Boost)") set(ENABLE_LUA OFF CACHE INTERNAL "Enable support of Lua scripting") set(ENABLE_PNG OFF CACHE INTERNAL "Enable support of PNG") +set(ENABLE_PROTOBUF OFF CACHE INTERNAL "Enable support for Google Protocol Buffers") set(ENABLE_PUGIXML OFF CACHE INTERNAL "Enable support of XML through Pugixml") set(ENABLE_SQLITE OFF CACHE INTERNAL "Enable support of SQLite databases") set(ENABLE_ZLIB OFF CACHE INTERNAL "Enable support of zlib")
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/OrthancFramework/Resources/CMake/ProtobufConfiguration.cmake Sun Mar 26 11:59:03 2023 +0200 @@ -0,0 +1,55 @@ +# Orthanc - A Lightweight, RESTful DICOM Store +# Copyright (C) 2012-2016 Sebastien Jodogne, Medical Physics +# Department, University Hospital of Liege, Belgium +# Copyright (C) 2017-2023 Osimis S.A., Belgium +# Copyright (C) 2021-2023 Sebastien Jodogne, ICTEAM UCLouvain, Belgium +# +# This program is free software: you can redistribute it and/or +# modify it under the terms of the GNU Lesser General Public License +# as published by the Free Software Foundation, either version 3 of +# the License, or (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, but +# WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +# Lesser General Public License for more details. +# +# You should have received a copy of the GNU Lesser General Public +# License along with this program. If not, see +# <http://www.gnu.org/licenses/>. + + +if (STATIC_BUILD OR NOT USE_SYSTEM_PROTOBUF) + include(${CMAKE_CURRENT_LIST_DIR}/../ProtocolBuffers/ProtobufLibrary.cmake) + source_group(ThirdParty\\Protobuf REGULAR_EXPRESSION ${PROTOBUF_SOURCE_DIR}/.*) + +else() + find_program(PROTOC_EXECUTABLE protoc) + if (${PROTOC_EXECUTABLE} MATCHES "PROTOC_EXECUTABLE-NOTFOUND") + message(FATAL_ERROR "Please install the 'protoc' compiler for Protocol Buffers (package 'protobuf-compiler' on Debian/Ubuntu)") + endif() + + check_include_file_cxx(google/protobuf/any.h HAVE_PROTOBUF_H) + if (NOT HAVE_PROTOBUF_H) + message(FATAL_ERROR "Please install the libprotobuf-dev package") + endif() + + set(CMAKE_REQUIRED_LIBRARIES "protobuf") + + include(CheckCXXSourceCompiles) + check_cxx_source_compiles( + " +#include <google/protobuf/descriptor.h> +int main() +{ + google::protobuf::FieldDescriptor::TypeName(google::protobuf::FieldDescriptor::TYPE_FLOAT); +} +" HAVE_PROTOBUF_LIB) + if (NOT HAVE_PROTOBUF_LIB) + message(FATAL_ERROR "Cannot find the protobuf library") + endif() + + unset(CMAKE_REQUIRED_LIBRARIES) + + link_libraries(protobuf) +endif()
--- a/OrthancFramework/Resources/ProtocolBuffers/CMakeLists.txt Sun Mar 26 10:46:09 2023 +0200 +++ b/OrthancFramework/Resources/ProtocolBuffers/CMakeLists.txt Sun Mar 26 11:59:03 2023 +0200 @@ -25,16 +25,12 @@ set(ALLOW_DOWNLOADS ON) +include(${CMAKE_SOURCE_DIR}/../CMake/DownloadPackage.cmake) include(${CMAKE_SOURCE_DIR}/../CMake/Compiler.cmake) + include(${CMAKE_SOURCE_DIR}/ProtobufLibrary.cmake) -include_directories( - ${PROTOBUF_SOURCE_DIR}/src - ) - -add_executable(protoc - ${PROTOBUF_LIBRARY_SOURCES} - +set(PROTOBUF_COMPILER_SOURCES ${PROTOBUF_SOURCE_DIR}/src/google/protobuf/compiler/code_generator.cc ${PROTOBUF_SOURCE_DIR}/src/google/protobuf/compiler/command_line_interface.cc ${PROTOBUF_SOURCE_DIR}/src/google/protobuf/compiler/cpp/cpp_enum.cc @@ -137,7 +133,12 @@ if (NOT CMAKE_SYSTEM_NAME STREQUAL "Windows") set_property( - SOURCE ${PROTOBUF_LIBRARY_SOURCES} + SOURCE ${PROTOBUF_COMPILER_SOURCES} PROPERTY COMPILE_DEFINITIONS "HAVE_PTHREAD=1" ) endif() + +add_executable(protoc + ${PROTOBUF_LIBRARY_SOURCES} + ${PROTOBUF_COMPILER_SOURCES} + )
--- a/OrthancFramework/Resources/ProtocolBuffers/ProtobufLibrary.cmake Sun Mar 26 10:46:09 2023 +0200 +++ b/OrthancFramework/Resources/ProtocolBuffers/ProtobufLibrary.cmake Sun Mar 26 11:59:03 2023 +0200 @@ -19,8 +19,6 @@ # <http://www.gnu.org/licenses/>. -include(${CMAKE_SOURCE_DIR}/../CMake/DownloadPackage.cmake) - DownloadPackage( "ca0d9b243e649d398a6b419acd35103a" "http://orthanc.uclouvain.be/third-party-downloads/protobuf-cpp-3.5.1.tar.gz" @@ -28,6 +26,10 @@ set(PROTOBUF_SOURCE_DIR ${CMAKE_CURRENT_BINARY_DIR}/protobuf-3.5.1) +include_directories( + ${PROTOBUF_SOURCE_DIR}/src + ) + set(PROTOBUF_LIBRARY_SOURCES ${PROTOBUF_SOURCE_DIR}/src/google/protobuf/any.cc ${PROTOBUF_SOURCE_DIR}/src/google/protobuf/any.pb.cc @@ -113,3 +115,10 @@ ${PROTOBUF_SOURCE_DIR}/src/google/protobuf/wire_format_lite.cc ${PROTOBUF_SOURCE_DIR}/src/google/protobuf/wrappers.pb.cc ) + +if (NOT CMAKE_SYSTEM_NAME STREQUAL "Windows") + set_property( + SOURCE ${PROTOBUF_LIBRARY_SOURCES} + PROPERTY COMPILE_DEFINITIONS "HAVE_PTHREAD=1" + ) +endif()
--- a/OrthancServer/CMakeLists.txt Sun Mar 26 10:46:09 2023 +0200 +++ b/OrthancServer/CMakeLists.txt Sun Mar 26 11:59:03 2023 +0200 @@ -41,6 +41,7 @@ set(ENABLE_LUA ON) set(ENABLE_OPENSSL_ENGINES ON) # OpenSSL engines are necessary for PKCS11 set(ENABLE_PNG ON) +set(ENABLE_PROTOBUF ON) set(ENABLE_PUGIXML ON) set(ENABLE_SQLITE ON) set(ENABLE_WEB_CLIENT ON)