#!/usr/bin/cmake cmake_minimum_required (VERSION 3.18) # ------------------------------------------------------------------------------------------------- project( ProtoBuf VERSION 3.10.0 DESCRIPTION "Fast and small binary serialization format" ) include("../../BuildSystem/cmake/cplusplus.cmake") # ------------------------------------------------------------------------------------------------- if(NOT EXISTS ${PROJECT_SOURCE_DIR}/downloads/protobuf-cpp-3.10.0.tar.gz) message(STATUS "Downloading ProtoBuf sources") file( DOWNLOAD https://github.com/protocolbuffers/protobuf/releases/download/v3.10.0/protobuf-cpp-3.10.0.tar.gz ${PROJECT_SOURCE_DIR}/downloads/protobuf-cpp-3.10.0.tar.gz SHOW_PROGRESS EXPECTED_HASH SHA256=ffb91e102e8c389fba6fefec948421852979ae655ebb52e69859a6a3f4c5b61b ) endif() # ------------------------------------------------------------------------------------------------- if(NOT EXISTS ${PROJECT_SOURCE_DIR}/build) message(STATUS "Extracting ProtoBuf sources") file( ARCHIVE_EXTRACT INPUT ${PROJECT_SOURCE_DIR}/downloads/protobuf-cpp-3.10.0.tar.gz DESTINATION ${CMAKE_BINARY_DIR}/extract ) file( RENAME ${CMAKE_BINARY_DIR}/extract/protobuf-3.10.0 ${PROJECT_SOURCE_DIR}/build ) endif() # ------------------------------------------------------------------------------------------------- #file(READ "protobuf-sources" sourceFiles) # Yeah, this doens't work set( sourceFiles "build/src/google/protobuf/stubs/bytestream.cc" "build/src/google/protobuf/stubs/common.cc" "build/src/google/protobuf/stubs/int128.cc" "build/src/google/protobuf/io/io_win32.cc" "build/src/google/protobuf/stubs/status.cc" "build/src/google/protobuf/stubs/statusor.cc" "build/src/google/protobuf/stubs/stringpiece.cc" "build/src/google/protobuf/stubs/stringprintf.cc" "build/src/google/protobuf/stubs/structurally_valid.cc" "build/src/google/protobuf/stubs/strutil.cc" "build/src/google/protobuf/stubs/time.cc" "build/src/google/protobuf/any_lite.cc" "build/src/google/protobuf/arena.cc" "build/src/google/protobuf/extension_set.cc" "build/src/google/protobuf/generated_enum_util.cc" "build/src/google/protobuf/generated_message_util.cc" "build/src/google/protobuf/generated_message_table_driven_lite.cc" "build/src/google/protobuf/implicit_weak_message.cc" "build/src/google/protobuf/message_lite.cc" "build/src/google/protobuf/parse_context.cc" "build/src/google/protobuf/repeated_field.cc" "build/src/google/protobuf/wire_format_lite.cc" "build/src/google/protobuf/io/coded_stream.cc" "build/src/google/protobuf/io/strtod.cc" "build/src/google/protobuf/io/zero_copy_stream.cc" "build/src/google/protobuf/io/zero_copy_stream_impl.cc" "build/src/google/protobuf/io/zero_copy_stream_impl_lite.cc" "build/src/google/protobuf/any.pb.cc" "build/src/google/protobuf/api.pb.cc" "build/src/google/protobuf/stubs/mathlimits.cc" "build/src/google/protobuf/any.cc" "build/src/google/protobuf/descriptor.cc" "build/src/google/protobuf/descriptor_database.cc" "build/src/google/protobuf/descriptor.pb.cc" "build/src/google/protobuf/duration.pb.cc" "build/src/google/protobuf/dynamic_message.cc" "build/src/google/protobuf/empty.pb.cc" "build/src/google/protobuf/extension_set_heavy.cc" "build/src/google/protobuf/field_mask.pb.cc" "build/src/google/protobuf/generated_message_reflection.cc" "build/src/google/protobuf/generated_message_table_driven.cc" "build/src/google/protobuf/map_field.cc" "build/src/google/protobuf/message.cc" "build/src/google/protobuf/reflection_ops.cc" "build/src/google/protobuf/service.cc" "build/src/google/protobuf/source_context.pb.cc" "build/src/google/protobuf/struct.pb.cc" "build/src/google/protobuf/stubs/substitute.cc" "build/src/google/protobuf/text_format.cc" "build/src/google/protobuf/timestamp.pb.cc" "build/src/google/protobuf/type.pb.cc" "build/src/google/protobuf/unknown_field_set.cc" "build/src/google/protobuf/wire_format.cc" "build/src/google/protobuf/wrappers.pb.cc" "build/src/google/protobuf/io/gzip_stream.cc" "build/src/google/protobuf/io/printer.cc" "build/src/google/protobuf/io/tokenizer.cc" "build/src/google/protobuf/compiler/importer.cc" "build/src/google/protobuf/compiler/parser.cc" "build/src/google/protobuf/util/delimited_message_util.cc" "build/src/google/protobuf/util/field_comparator.cc" "build/src/google/protobuf/util/field_mask_util.cc" "build/src/google/protobuf/util/internal/datapiece.cc" "build/src/google/protobuf/util/internal/default_value_objectwriter.cc" "build/src/google/protobuf/util/internal/error_listener.cc" "build/src/google/protobuf/util/internal/field_mask_utility.cc" "build/src/google/protobuf/util/internal/json_escaping.cc" "build/src/google/protobuf/util/internal/json_objectwriter.cc" "build/src/google/protobuf/util/internal/json_stream_parser.cc" "build/src/google/protobuf/util/internal/object_writer.cc" "build/src/google/protobuf/util/internal/protostream_objectsource.cc" "build/src/google/protobuf/util/internal/protostream_objectwriter.cc" "build/src/google/protobuf/util/internal/proto_writer.cc" "build/src/google/protobuf/util/internal/type_info.cc" "build/src/google/protobuf/util/internal/type_info_test_helper.cc" "build/src/google/protobuf/util/internal/utility.cc" "build/src/google/protobuf/util/json_util.cc" "build/src/google/protobuf/util/message_differencer.cc" "build/src/google/protobuf/util/time_util.cc" "build/src/google/protobuf/util/type_resolver_util.cc" ) set( headerFiles "build/src/google/protobuf/proto3_lite_unittest.inc" "build/src/google/protobuf/map_lite_test_util.h" "build/src/google/protobuf/message_unittest.inc" "build/src/google/protobuf/io/io_win32.h" "build/src/google/protobuf/io/zero_copy_stream_impl_lite.h" "build/src/google/protobuf/io/gzip_stream.h" "build/src/google/protobuf/io/zero_copy_stream.h" "build/src/google/protobuf/io/coded_stream.h" "build/src/google/protobuf/io/zero_copy_stream_impl.h" "build/src/google/protobuf/io/strtod.h" "build/src/google/protobuf/io/tokenizer.h" "build/src/google/protobuf/io/gzip_stream_unittest.sh" "build/src/google/protobuf/io/printer.h" "build/src/google/protobuf/io/package_info.h" "build/src/google/protobuf/generated_message_reflection.h" "build/src/google/protobuf/map_type_handler.h" "build/src/google/protobuf/timestamp.pb.h" "build/src/google/protobuf/text_format.h" "build/src/google/protobuf/arena_test_util.h" "build/src/google/protobuf/util/message_differencer.h" "build/src/google/protobuf/util/delimited_message_util.h" "build/src/google/protobuf/util/type_resolver.h" "build/src/google/protobuf/util/internal/constants.h" "build/src/google/protobuf/util/internal/json_objectwriter.h" "build/src/google/protobuf/util/internal/mock_error_listener.h" "build/src/google/protobuf/util/internal/json_stream_parser.h" "build/src/google/protobuf/util/internal/json_escaping.h" "build/src/google/protobuf/util/internal/field_mask_utility.h" "build/src/google/protobuf/util/internal/structured_objectwriter.h" "build/src/google/protobuf/util/internal/datapiece.h" "build/src/google/protobuf/util/internal/utility.h" "build/src/google/protobuf/util/internal/expecting_objectwriter.h" "build/src/google/protobuf/util/internal/error_listener.h" "build/src/google/protobuf/util/internal/object_location_tracker.h" "build/src/google/protobuf/util/internal/proto_writer.h" "build/src/google/protobuf/util/internal/object_source.h" "build/src/google/protobuf/util/internal/type_info_test_helper.h" "build/src/google/protobuf/util/internal/protostream_objectwriter.h" "build/src/google/protobuf/util/internal/default_value_objectwriter.h" "build/src/google/protobuf/util/internal/object_writer.h" "build/src/google/protobuf/util/internal/type_info.h" "build/src/google/protobuf/util/internal/protostream_objectsource.h" "build/src/google/protobuf/util/internal/location_tracker.h" "build/src/google/protobuf/util/time_util.h" "build/src/google/protobuf/util/field_mask_util.h" "build/src/google/protobuf/util/json_util.h" "build/src/google/protobuf/util/type_resolver_util.h" "build/src/google/protobuf/util/field_comparator.h" "build/src/google/protobuf/util/package_info.h" "build/src/google/protobuf/map_test_util_impl.h" "build/src/google/protobuf/map_entry_lite.h" "build/src/google/protobuf/generated_message_table_driven.h" "build/src/google/protobuf/generated_message_table_driven_lite.h" "build/src/google/protobuf/descriptor_database.h" "build/src/google/protobuf/repeated_field.h" "build/src/google/protobuf/arena.h" "build/src/google/protobuf/testing/file.h" "build/src/google/protobuf/testing/googletest.h" "build/src/google/protobuf/implicit_weak_message.h" "build/src/google/protobuf/empty.pb.h" "build/src/google/protobuf/metadata.h" "build/src/google/protobuf/port_def.inc" "build/src/google/protobuf/reflection_ops.h" "build/src/google/protobuf/message.h" "build/src/google/protobuf/descriptor.h" "build/src/google/protobuf/field_mask.pb.h" "build/src/google/protobuf/service.h" "build/src/google/protobuf/message_lite.h" "build/src/google/protobuf/test_util.inc" "build/src/google/protobuf/metadata_lite.h" "build/src/google/protobuf/test_util.h" "build/src/google/protobuf/reflection.h" "build/src/google/protobuf/map_test_util.inc" "build/src/google/protobuf/map.h" "build/src/google/protobuf/wire_format_lite.h" "build/src/google/protobuf/dynamic_message.h" "build/src/google/protobuf/inlined_string_field.h" "build/src/google/protobuf/duration.pb.h" "build/src/google/protobuf/test_util2.h" "build/src/google/protobuf/wire_format.h" "build/src/google/protobuf/stubs/bytestream.h" "build/src/google/protobuf/stubs/mathutil.h" "build/src/google/protobuf/stubs/substitute.h" "build/src/google/protobuf/stubs/platform_macros.h" "build/src/google/protobuf/stubs/statusor.h" "build/src/google/protobuf/stubs/template_util.h" "build/src/google/protobuf/stubs/status.h" "build/src/google/protobuf/stubs/stringprintf.h" "build/src/google/protobuf/stubs/time.h" "build/src/google/protobuf/stubs/stringpiece.h" "build/src/google/protobuf/stubs/strutil.h" "build/src/google/protobuf/stubs/casts.h" "build/src/google/protobuf/stubs/mathlimits.h" "build/src/google/protobuf/stubs/fastmem.h" "build/src/google/protobuf/stubs/callback.h" "build/src/google/protobuf/stubs/port.h" "build/src/google/protobuf/stubs/mutex.h" "build/src/google/protobuf/stubs/once.h" "build/src/google/protobuf/stubs/common.h" "build/src/google/protobuf/stubs/map_util.h" "build/src/google/protobuf/stubs/hash.h" "build/src/google/protobuf/stubs/stl_util.h" "build/src/google/protobuf/stubs/logging.h" "build/src/google/protobuf/stubs/status_macros.h" "build/src/google/protobuf/stubs/int128.h" "build/src/google/protobuf/stubs/macros.h" "build/src/google/protobuf/map_test_util.h" "build/src/google/protobuf/api.pb.h" "build/src/google/protobuf/has_bits.h" "build/src/google/protobuf/extension_set_inl.h" "build/src/google/protobuf/source_context.pb.h" "build/src/google/protobuf/arenastring.h" "build/src/google/protobuf/map_entry.h" "build/src/google/protobuf/port.h" "build/src/google/protobuf/map_field.h" "build/src/google/protobuf/test_util_lite.h" "build/src/google/protobuf/any.pb.h" "build/src/google/protobuf/extension_set.h" "build/src/google/protobuf/struct.pb.h" "build/src/google/protobuf/parse_context.h" "build/src/google/protobuf/descriptor.pb.h" "build/src/google/protobuf/arena_impl.h" "build/src/google/protobuf/port_undef.inc" "build/src/google/protobuf/map_field_inl.h" "build/src/google/protobuf/generated_enum_reflection.h" "build/src/google/protobuf/generated_enum_util.h" "build/src/google/protobuf/wrappers.pb.h" "build/src/google/protobuf/generated_message_util.h" "build/src/google/protobuf/type.pb.h" "build/src/google/protobuf/any.h" "build/src/google/protobuf/unknown_field_set.h" "build/src/google/protobuf/map_field_lite.h" "build/src/google/protobuf/reflection_internal.h" "build/src/google/protobuf/package_info.h" ) set( executableFiles "build/src/google/protobuf/io/zero_copy_stream.cc" "build/src/google/protobuf/io/coded_stream.cc" "build/src/google/protobuf/io/zero_copy_stream_impl.cc" "build/src/google/protobuf/io/printer.cc" "build/src/google/protobuf/io/tokenizer.cc" "build/src/google/protobuf/io/io_win32.cc" "build/src/google/protobuf/io/gzip_stream.cc" "build/src/google/protobuf/io/zero_copy_stream_impl_lite.cc" "build/src/google/protobuf/io/strtod.cc" "build/src/google/protobuf/generated_message_table_driven.cc" "build/src/google/protobuf/generated_message_util.cc" "build/src/google/protobuf/any.pb.cc" "build/src/google/protobuf/extension_set_heavy.cc" "build/src/google/protobuf/empty.pb.cc" "build/src/google/protobuf/util/time_util.cc" "build/src/google/protobuf/util/field_mask_util.cc" "build/src/google/protobuf/util/delimited_message_util.cc" "build/src/google/protobuf/util/json_util.cc" "build/src/google/protobuf/util/field_comparator.cc" "build/src/google/protobuf/util/internal/field_mask_utility.cc" "build/src/google/protobuf/util/internal/json_objectwriter.cc" "build/src/google/protobuf/util/internal/datapiece.cc" "build/src/google/protobuf/util/internal/error_listener.cc" "build/src/google/protobuf/util/internal/object_writer.cc" "build/src/google/protobuf/util/internal/json_stream_parser.cc" "build/src/google/protobuf/util/internal/protostream_objectsource.cc" "build/src/google/protobuf/util/internal/proto_writer.cc" "build/src/google/protobuf/util/internal/utility.cc" "build/src/google/protobuf/util/internal/default_value_objectwriter.cc" "build/src/google/protobuf/util/internal/type_info_test_helper.cc" "build/src/google/protobuf/util/internal/type_info.cc" "build/src/google/protobuf/util/internal/json_escaping.cc" "build/src/google/protobuf/util/internal/protostream_objectwriter.cc" "build/src/google/protobuf/util/type_resolver_util.cc" "build/src/google/protobuf/util/message_differencer.cc" "build/src/google/protobuf/generated_message_reflection.cc" "build/src/google/protobuf/source_context.pb.cc" "build/src/google/protobuf/struct.pb.cc" "build/src/google/protobuf/map_field.cc" "build/src/google/protobuf/text_format.cc" "build/src/google/protobuf/reflection_ops.cc" "build/src/google/protobuf/implicit_weak_message.cc" "build/src/google/protobuf/field_mask.pb.cc" "build/src/google/protobuf/generated_enum_util.cc" "build/src/google/protobuf/wire_format.cc" "build/src/google/protobuf/any.cc" "build/src/google/protobuf/descriptor_database.cc" "build/src/google/protobuf/type.pb.cc" "build/src/google/protobuf/message_lite.cc" "build/src/google/protobuf/service.cc" "build/src/google/protobuf/message.cc" "build/src/google/protobuf/stubs/time.cc" "build/src/google/protobuf/stubs/structurally_valid.cc" "build/src/google/protobuf/stubs/mathlimits.cc" "build/src/google/protobuf/stubs/bytestream.cc" "build/src/google/protobuf/stubs/statusor.cc" "build/src/google/protobuf/stubs/stringpiece.cc" "build/src/google/protobuf/stubs/int128.cc" "build/src/google/protobuf/stubs/common.cc" "build/src/google/protobuf/stubs/substitute.cc" "build/src/google/protobuf/stubs/strutil.cc" "build/src/google/protobuf/stubs/status.cc" "build/src/google/protobuf/stubs/stringprintf.cc" "build/src/google/protobuf/timestamp.pb.cc" "build/src/google/protobuf/arena.cc" "build/src/google/protobuf/extension_set.cc" "build/src/google/protobuf/any_lite.cc" "build/src/google/protobuf/repeated_field.cc" "build/src/google/protobuf/unknown_field_set.cc" "build/src/google/protobuf/parse_context.cc" "build/src/google/protobuf/compiler/importer.cc" "build/src/google/protobuf/compiler/subprocess.cc" "build/src/google/protobuf/compiler/python/python_generator.cc" "build/src/google/protobuf/compiler/csharp/csharp_primitive_field.cc" "build/src/google/protobuf/compiler/csharp/csharp_enum_field.cc" "build/src/google/protobuf/compiler/csharp/csharp_reflection_class.cc" "build/src/google/protobuf/compiler/csharp/csharp_message.cc" "build/src/google/protobuf/compiler/csharp/csharp_map_field.cc" "build/src/google/protobuf/compiler/csharp/csharp_source_generator_base.cc" "build/src/google/protobuf/compiler/csharp/csharp_doc_comment.cc" "build/src/google/protobuf/compiler/csharp/csharp_wrapper_field.cc" "build/src/google/protobuf/compiler/csharp/csharp_field_base.cc" "build/src/google/protobuf/compiler/csharp/csharp_repeated_primitive_field.cc" "build/src/google/protobuf/compiler/csharp/csharp_enum.cc" "build/src/google/protobuf/compiler/csharp/csharp_repeated_message_field.cc" "build/src/google/protobuf/compiler/csharp/csharp_helpers.cc" "build/src/google/protobuf/compiler/csharp/csharp_repeated_enum_field.cc" "build/src/google/protobuf/compiler/csharp/csharp_generator.cc" "build/src/google/protobuf/compiler/csharp/csharp_message_field.cc" "build/src/google/protobuf/compiler/zip_writer.cc" "build/src/google/protobuf/compiler/plugin.cc" "build/src/google/protobuf/compiler/ruby/ruby_generator.cc" "build/src/google/protobuf/compiler/main.cc" "build/src/google/protobuf/compiler/java/java_string_field_lite.cc" "build/src/google/protobuf/compiler/java/java_primitive_field.cc" "build/src/google/protobuf/compiler/java/java_shared_code_generator.cc" "build/src/google/protobuf/compiler/java/java_message.cc" "build/src/google/protobuf/compiler/java/java_context.cc" "build/src/google/protobuf/compiler/java/java_generator.cc" "build/src/google/protobuf/compiler/java/java_doc_comment.cc" "build/src/google/protobuf/compiler/java/java_enum_field_lite.cc" "build/src/google/protobuf/compiler/java/java_primitive_field_lite.cc" "build/src/google/protobuf/compiler/java/java_extension.cc" "build/src/google/protobuf/compiler/java/java_extension_lite.cc" "build/src/google/protobuf/compiler/java/java_name_resolver.cc" "build/src/google/protobuf/compiler/java/java_map_field_lite.cc" "build/src/google/protobuf/compiler/java/java_file.cc" "build/src/google/protobuf/compiler/java/java_service.cc" "build/src/google/protobuf/compiler/java/java_field.cc" "build/src/google/protobuf/compiler/java/java_string_field.cc" "build/src/google/protobuf/compiler/java/java_enum_lite.cc" "build/src/google/protobuf/compiler/java/java_enum.cc" "build/src/google/protobuf/compiler/java/java_generator_factory.cc" "build/src/google/protobuf/compiler/java/java_message_builder.cc" "build/src/google/protobuf/compiler/java/java_helpers.cc" "build/src/google/protobuf/compiler/java/java_map_field.cc" "build/src/google/protobuf/compiler/java/java_message_field.cc" "build/src/google/protobuf/compiler/java/java_message_lite.cc" "build/src/google/protobuf/compiler/java/java_message_builder_lite.cc" "build/src/google/protobuf/compiler/java/java_message_field_lite.cc" "build/src/google/protobuf/compiler/java/java_enum_field.cc" "build/src/google/protobuf/compiler/command_line_interface.cc" "build/src/google/protobuf/compiler/js/js_generator.cc" "build/src/google/protobuf/compiler/js/well_known_types_embed.cc" "build/src/google/protobuf/compiler/parser.cc" "build/src/google/protobuf/compiler/code_generator.cc" "build/src/google/protobuf/compiler/objectivec/objectivec_message.cc" "build/src/google/protobuf/compiler/objectivec/objectivec_message_field.cc" "build/src/google/protobuf/compiler/objectivec/objectivec_field.cc" "build/src/google/protobuf/compiler/objectivec/objectivec_map_field.cc" "build/src/google/protobuf/compiler/objectivec/objectivec_extension.cc" "build/src/google/protobuf/compiler/objectivec/objectivec_generator.cc" "build/src/google/protobuf/compiler/objectivec/objectivec_primitive_field.cc" "build/src/google/protobuf/compiler/objectivec/objectivec_enum.cc" "build/src/google/protobuf/compiler/objectivec/objectivec_file.cc" "build/src/google/protobuf/compiler/objectivec/objectivec_oneof.cc" "build/src/google/protobuf/compiler/objectivec/objectivec_enum_field.cc" "build/src/google/protobuf/compiler/objectivec/objectivec_helpers.cc" "build/src/google/protobuf/compiler/cpp/cpp_file.cc" "build/src/google/protobuf/compiler/cpp/cpp_generator.cc" "build/src/google/protobuf/compiler/cpp/cpp_message_field.cc" "build/src/google/protobuf/compiler/cpp/cpp_padding_optimizer.cc" "build/src/google/protobuf/compiler/cpp/cpp_map_field.cc" "build/src/google/protobuf/compiler/cpp/cpp_primitive_field.cc" "build/src/google/protobuf/compiler/cpp/cpp_field.cc" "build/src/google/protobuf/compiler/cpp/cpp_string_field.cc" "build/src/google/protobuf/compiler/cpp/cpp_enum_field.cc" "build/src/google/protobuf/compiler/cpp/cpp_message.cc" "build/src/google/protobuf/compiler/cpp/cpp_enum.cc" "build/src/google/protobuf/compiler/cpp/cpp_service.cc" "build/src/google/protobuf/compiler/cpp/cpp_helpers.cc" "build/src/google/protobuf/compiler/cpp/cpp_extension.cc" "build/src/google/protobuf/compiler/plugin.pb.cc" "build/src/google/protobuf/compiler/php/php_generator.cc" "build/src/google/protobuf/descriptor.cc" "build/src/google/protobuf/duration.pb.cc" "build/src/google/protobuf/generated_message_table_driven_lite.cc" "build/src/google/protobuf/wrappers.pb.cc" "build/src/google/protobuf/api.pb.cc" "build/src/google/protobuf/descriptor.pb.cc" "build/src/google/protobuf/dynamic_message.cc" "build/src/google/protobuf/wire_format_lite.cc" ) # ------------------------------------------------------------------------------------------------- add_library(ProtoBuf STATIC) add_library(ProtoBuf::Static ALIAS ProtoBuf) target_compile_definitions( ProtoBuf PUBLIC HAVE_PTHREAD ) target_include_directories( ProtoBuf PUBLIC "build/src" ) target_sources( ProtoBuf PUBLIC ${headerFiles} PRIVATE ${sourceFiles} ) #set_target_properties(ProtoBuf PROPERTIES PREFIX "") set_target_properties(ProtoBuf PROPERTIES OUTPUT_NAME "protobuf") # ------------------------------------------------------------------------------------------------- add_executable(ProtoBufCompiler) target_compile_definitions( ProtoBufCompiler PUBLIC HAVE_PTHREAD ) target_include_directories( ProtoBufCompiler PUBLIC "build/src" ) target_sources( ProtoBufCompiler PUBLIC ${headerFiles} PRIVATE ${executableFiles} ) #set_target_properties(ProtoBuf PROPERTIES PREFIX "") set_target_properties(ProtoBufCompiler PROPERTIES OUTPUT_NAME "protoc") # ------------------------------------------------------------------------------------------------- install( DIRECTORY build/src/google/protobuf DESTINATION ${PROJECT_SOURCE_DIR}/Include FILES_MATCHING PATTERN "*.h" ) #install( # FILES ${headerFiles} # DESTINATION ${PROJECT_SOURCE_DIR}/Include #) install( TARGETS ProtoBuf ARCHIVE DESTINATION ${PROJECT_SOURCE_DIR}/bin/${NUCLEX_COMPILER_TAG} ) install( TARGETS ProtoBufCompiler RUNTIME DESTINATION ${PROJECT_SOURCE_DIR}/bin/${NUCLEX_COMPILER_TAG} ) # ------------------------------------------------------------------------------------------------- file( WRITE "${PROJECT_SOURCE_DIR}/ProtoBufConfig.cmake" "#!/usr/bin/cmake # Configuration to include ProtoBuf in a CMake-based project. If you want to # reference ProtoBuf as an externally compiled static library, do this: # # set(ProtoBuf_DIR \"../ThirdParty/protobuf\") # find_package(ProtoBuf REQUIRED CONFIG) # # target_link_libraries( # MyAwesomeProject # PRIVATE ProtoBuf::Static # ) # # Alternatively, if you want to build ProtoBuf together with your project, # use the normal CMakeLists.txt with CMake's add_subdirectory() command: # # add_subdirectory( # \"\${PROJECT_SOURCE_DIR}/../ThirdParty/protobuf\" # \"\${CMAKE_BINARY_DIR}/protobuf\" # ) # # target_link_libraries( # MyAwesomeProject # PRIVATE ProtoBuf # ) # # ------------------------------------------------------------------------------------------------- if(NOT DEFINED NUCLEX_COMPILER_TAG) message( FATAL_ERROR \"NUCLEX_COMPILER_TAG not defined! Include cplusplus.cmake before importing this package \\ in order to generate a tag identifying the platform/compiler/architecture/variant!\" ) endif() # ------------------------------------------------------------------------------------------------- if(NOT EXISTS \"\${CMAKE_CURRENT_LIST_DIR}/bin/\${NUCLEX_COMPILER_TAG}\") # TODO: Warn and link release build when compiling in debug mode # TODO: Warn and link build for older compiler version if found message( FATAL_ERROR \"Directory '\${CMAKE_CURRENT_LIST_DIR}/bin/\${NUCLEX_COMPILER_TAG}' not found. \\ Please either build and install this project before importing it via \\ find_package() or use this project's main CMakeFiles.txt via add_subdirectory()!\" ) endif() # ------------------------------------------------------------------------------------------------- add_library(ProtoBuf::Static STATIC IMPORTED) # This may cause warnings on recent GCC versions (10.0.0+?) with LTO because GCC detects # that the headers used during build (residing in build/) are not the same used when # linking the library (copies resising in Include/). # # CMake doesn't run the install step during build, so the only way to get the headers # in place before building would be by copying them rather than installing them. set_target_properties( ProtoBuf::Static PROPERTIES INTERFACE_INCLUDE_DIRECTORIES \"\${CMAKE_CURRENT_LIST_DIR}/Include\" IMPORTED_LINK_INTERFACE_LANGUAGES \"C\" ) if(WIN32) set_target_properties( ProtoBuf::Static PROPERTIES IMPORTED_LOCATION \"\${CMAKE_CURRENT_LIST_DIR}/bin/\${NUCLEX_COMPILER_TAG}/protobuf.lib\" ) else() set_target_properties( ProtoBuf::Static PROPERTIES IMPORTED_LOCATION \"\${CMAKE_CURRENT_LIST_DIR}/bin/\${NUCLEX_COMPILER_TAG}/libprotobuf.a\" ) endif() message(STATUS \"Imported ProtoBuf targets with binaries in '\${CMAKE_CURRENT_LIST_DIR}'\")" ) # -------------------------------------------------------------------------------------------------