comparison OrthancFramework/Resources/CMake/ProtobufConfiguration.cmake @ 5188:4c6f0211caaf db-protobuf

compiling the protobuf compiler
author Sebastien Jodogne <s.jodogne@gmail.com>
date Sun, 26 Mar 2023 21:09:13 +0200
parents 9466c95f70c8
children c0f6c6fe1c47
comparison
equal deleted inserted replaced
5187:9466c95f70c8 5188:4c6f0211caaf
18 # License along with this program. If not, see 18 # License along with this program. If not, see
19 # <http://www.gnu.org/licenses/>. 19 # <http://www.gnu.org/licenses/>.
20 20
21 21
22 if (STATIC_BUILD OR NOT USE_SYSTEM_PROTOBUF) 22 if (STATIC_BUILD OR NOT USE_SYSTEM_PROTOBUF)
23 if (ENABLE_PROTOBUF_COMPILER)
24 include(ExternalProject)
25 externalproject_add(ProtobufCompiler
26 SOURCE_DIR "${CMAKE_SOURCE_DIR}/../OrthancFramework/Resources/ProtocolBuffers"
27 BINARY_DIR "${CMAKE_CURRENT_BINARY_DIR}/ProtobufCompiler-build"
28 # this helps triggering build when changing the external project
29 BUILD_ALWAYS 1
30 CMAKE_ARGS
31 -DCMAKE_BUILD_TYPE:STRING=${CMAKE_BUILD_TYPE}
32 -DCMAKE_INSTALL_PREFIX=${CMAKE_CURRENT_BINARY_DIR}
33 INSTALL_COMMAND ""
34 )
35 set(PROTOC_EXECUTABLE ${CMAKE_CURRENT_BINARY_DIR}/ProtobufCompiler-build/protoc)
36 endif()
37
23 include(${CMAKE_CURRENT_LIST_DIR}/../ProtocolBuffers/ProtobufLibrary.cmake) 38 include(${CMAKE_CURRENT_LIST_DIR}/../ProtocolBuffers/ProtobufLibrary.cmake)
24 source_group(ThirdParty\\Protobuf REGULAR_EXPRESSION ${PROTOBUF_SOURCE_DIR}/.*) 39 source_group(ThirdParty\\Protobuf REGULAR_EXPRESSION ${PROTOBUF_SOURCE_DIR}/.*)
25 40
26 else() 41 else()
27 find_program(PROTOC_EXECUTABLE protoc) 42 if (CMAKE_CROSSCOMPILING)
28 if (${PROTOC_EXECUTABLE} MATCHES "PROTOC_EXECUTABLE-NOTFOUND") 43 message(FATAL_ERROR "If cross-compiling, the static version of Protocol Buffers should be used to avoid version mismatch")
29 message(FATAL_ERROR "Please install the 'protoc' compiler for Protocol Buffers (package 'protobuf-compiler' on Debian/Ubuntu)") 44 endif()
45
46 if (ENABLE_PROTOBUF_COMPILER)
47 find_program(PROTOC_EXECUTABLE protoc)
48 if (${PROTOC_EXECUTABLE} MATCHES "PROTOC_EXECUTABLE-NOTFOUND")
49 message(FATAL_ERROR "Please install the 'protoc' compiler for Protocol Buffers (package 'protobuf-compiler' on Debian/Ubuntu)")
50 endif()
51 add_custom_target(ProtobufCompiler)
30 endif() 52 endif()
31 53
32 check_include_file_cxx(google/protobuf/any.h HAVE_PROTOBUF_H) 54 check_include_file_cxx(google/protobuf/any.h HAVE_PROTOBUF_H)
33 if (NOT HAVE_PROTOBUF_H) 55 if (NOT HAVE_PROTOBUF_H)
34 message(FATAL_ERROR "Please install the libprotobuf-dev package") 56 message(FATAL_ERROR "Please install the libprotobuf-dev package")