2012-01-20 12:21:29 -07:00
|
|
|
PROJECT(protobuf)
|
|
|
|
|
|
|
|
#Protocol buffers use C++0x hash maps, so we need to look for those. This is a rewrite of stl_hash.m4 in CMake.
|
2012-01-19 15:44:01 -07:00
|
|
|
IF(CMAKE_COMPILER_IS_GNUCC)
|
2015-08-31 09:25:44 -06:00
|
|
|
SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++0x")
|
2016-06-28 06:13:46 -06:00
|
|
|
ENDIF()
|
|
|
|
|
2018-05-13 15:55:38 -06:00
|
|
|
SET(HASH_MAP_H <unordered_map>)
|
|
|
|
SET(HASH_SET_H <unordered_map>)
|
|
|
|
SET(HASH_NAMESPACE std)
|
2016-06-28 06:13:46 -06:00
|
|
|
SET(HASH_MAP_CLASS unordered_map)
|
2018-05-13 15:55:38 -06:00
|
|
|
SET(HASH_SET_CLASS unordered_set)
|
|
|
|
SET(HAVE_HASH_MAP 1)
|
|
|
|
SET(HAVE_HASH_SET 1)
|
2012-01-19 15:44:01 -07:00
|
|
|
|
2016-06-28 06:13:46 -06:00
|
|
|
IF (HAVE_HASH_MAP EQUAL 0)
|
|
|
|
MESSAGE(SEND_ERROR "Could not find a working hash map implementation. Please install GCC >= 4.4, and all necessary 32-bit C++ development libraries.")
|
|
|
|
ENDIF()
|
2012-01-19 15:44:01 -07:00
|
|
|
|
2016-06-28 06:13:46 -06:00
|
|
|
IF(UNIX)
|
2016-09-14 23:37:07 -06:00
|
|
|
FIND_PACKAGE(Threads REQUIRED)
|
2012-01-19 15:44:01 -07:00
|
|
|
ENDIF()
|
|
|
|
|
2012-08-17 05:02:31 -06:00
|
|
|
CONFIGURE_FILE("${CMAKE_CURRENT_SOURCE_DIR}/config.h.in" "${CMAKE_CURRENT_BINARY_DIR}/config.h")
|
2012-01-19 15:44:01 -07:00
|
|
|
|
|
|
|
SET(LIBPROTOBUF_LITE_HDRS
|
|
|
|
google/protobuf/io/coded_stream.h
|
|
|
|
google/protobuf/io/coded_stream_inl.h
|
|
|
|
google/protobuf/stubs/common.h
|
2012-08-17 05:02:31 -06:00
|
|
|
${CMAKE_CURRENT_BINARY_DIR}/config.h
|
2012-01-19 15:44:01 -07:00
|
|
|
google/protobuf/extension_set.h
|
|
|
|
google/protobuf/generated_message_util.h
|
|
|
|
google/protobuf/stubs/hash.h
|
|
|
|
google/protobuf/stubs/map-util.h
|
|
|
|
google/protobuf/message_lite.h
|
|
|
|
google/protobuf/stubs/once.h
|
|
|
|
google/protobuf/repeated_field.h
|
|
|
|
google/protobuf/stubs/stl_util-inl.h
|
|
|
|
google/protobuf/wire_format_lite.h
|
|
|
|
google/protobuf/wire_format_lite_inl.h
|
|
|
|
google/protobuf/io/zero_copy_stream.h
|
|
|
|
google/protobuf/io/zero_copy_stream_impl_lite.h
|
2012-03-09 08:46:21 -07:00
|
|
|
google/protobuf/io/gzip_stream.h
|
|
|
|
google/protobuf/io/zero_copy_stream_impl.h
|
2012-01-19 15:44:01 -07:00
|
|
|
)
|
|
|
|
|
|
|
|
SET(LIBPROTOBUF_FULL_HDRS
|
|
|
|
google/protobuf/descriptor.h
|
|
|
|
google/protobuf/descriptor.pb.h
|
|
|
|
google/protobuf/descriptor_database.h
|
|
|
|
google/protobuf/dynamic_message.h
|
|
|
|
google/protobuf/generated_message_reflection.h
|
|
|
|
google/protobuf/compiler/importer.h
|
|
|
|
google/protobuf/message.h
|
|
|
|
google/protobuf/compiler/parser.h
|
|
|
|
google/protobuf/io/printer.h
|
|
|
|
google/protobuf/reflection_ops.h
|
|
|
|
google/protobuf/service.h
|
|
|
|
google/protobuf/stubs/strutil.h
|
|
|
|
google/protobuf/stubs/substitute.h
|
|
|
|
google/protobuf/text_format.h
|
|
|
|
google/protobuf/io/tokenizer.h
|
|
|
|
google/protobuf/unknown_field_set.h
|
|
|
|
google/protobuf/wire_format.h
|
|
|
|
)
|
|
|
|
|
|
|
|
LIST(APPEND LIBPROTOBUF_FULL_HDRS ${LIBPROTOBUF_LITE_HDRS})
|
|
|
|
|
|
|
|
SET(LIBPROTOBUF_LITE_SRCS
|
|
|
|
google/protobuf/io/coded_stream.cc
|
|
|
|
google/protobuf/stubs/common.cc
|
|
|
|
google/protobuf/extension_set.cc
|
|
|
|
google/protobuf/generated_message_util.cc
|
|
|
|
google/protobuf/message_lite.cc
|
|
|
|
google/protobuf/stubs/once.cc
|
|
|
|
google/protobuf/repeated_field.cc
|
|
|
|
google/protobuf/wire_format_lite.cc
|
|
|
|
google/protobuf/io/zero_copy_stream.cc
|
|
|
|
google/protobuf/io/zero_copy_stream_impl_lite.cc
|
2012-03-09 08:46:21 -07:00
|
|
|
google/protobuf/io/gzip_stream.cc
|
|
|
|
google/protobuf/io/zero_copy_stream_impl.cc
|
2012-01-19 15:44:01 -07:00
|
|
|
)
|
|
|
|
|
|
|
|
SET(LIBPROTOBUF_FULL_SRCS
|
|
|
|
google/protobuf/descriptor.cc
|
|
|
|
google/protobuf/descriptor.pb.cc
|
|
|
|
google/protobuf/descriptor_database.cc
|
|
|
|
google/protobuf/dynamic_message.cc
|
|
|
|
google/protobuf/extension_set_heavy.cc
|
|
|
|
google/protobuf/generated_message_reflection.cc
|
|
|
|
google/protobuf/compiler/importer.cc
|
2012-03-10 07:31:46 -07:00
|
|
|
google/protobuf/io/gzip_stream.cc
|
2012-01-19 15:44:01 -07:00
|
|
|
google/protobuf/message.cc
|
|
|
|
google/protobuf/compiler/parser.cc
|
|
|
|
google/protobuf/io/printer.cc
|
|
|
|
google/protobuf/reflection_ops.cc
|
|
|
|
google/protobuf/service.cc
|
|
|
|
google/protobuf/stubs/structurally_valid.cc
|
|
|
|
google/protobuf/stubs/strutil.cc
|
|
|
|
google/protobuf/stubs/substitute.cc
|
|
|
|
google/protobuf/text_format.cc
|
|
|
|
google/protobuf/io/tokenizer.cc
|
|
|
|
google/protobuf/unknown_field_set.cc
|
|
|
|
google/protobuf/wire_format.cc
|
2012-03-10 07:31:46 -07:00
|
|
|
google/protobuf/io/zero_copy_stream_impl.cc
|
2012-01-19 15:44:01 -07:00
|
|
|
)
|
|
|
|
|
|
|
|
SET(LIBPROTOC_HDRS
|
|
|
|
google/protobuf/compiler/code_generator.h
|
|
|
|
google/protobuf/compiler/command_line_interface.h
|
|
|
|
google/protobuf/compiler/cpp/cpp_enum.h
|
|
|
|
google/protobuf/compiler/cpp/cpp_enum_field.h
|
|
|
|
google/protobuf/compiler/cpp/cpp_extension.h
|
|
|
|
google/protobuf/compiler/cpp/cpp_field.h
|
|
|
|
google/protobuf/compiler/cpp/cpp_file.h
|
|
|
|
google/protobuf/compiler/cpp/cpp_generator.h
|
|
|
|
google/protobuf/compiler/cpp/cpp_helpers.h
|
|
|
|
google/protobuf/compiler/cpp/cpp_message.h
|
|
|
|
google/protobuf/compiler/cpp/cpp_message_field.h
|
|
|
|
google/protobuf/compiler/cpp/cpp_primitive_field.h
|
|
|
|
google/protobuf/compiler/cpp/cpp_service.h
|
|
|
|
google/protobuf/compiler/cpp/cpp_string_field.h
|
|
|
|
google/protobuf/compiler/plugin.h
|
|
|
|
google/protobuf/compiler/plugin.pb.h
|
|
|
|
google/protobuf/compiler/subprocess.h
|
|
|
|
google/protobuf/compiler/zip_writer.h
|
|
|
|
)
|
|
|
|
|
|
|
|
SET(LIBPROTOC_SRCS
|
|
|
|
google/protobuf/compiler/code_generator.cc
|
|
|
|
google/protobuf/compiler/command_line_interface.cc
|
|
|
|
google/protobuf/compiler/cpp/cpp_enum.cc
|
|
|
|
google/protobuf/compiler/cpp/cpp_enum_field.cc
|
|
|
|
google/protobuf/compiler/cpp/cpp_extension.cc
|
|
|
|
google/protobuf/compiler/cpp/cpp_field.cc
|
|
|
|
google/protobuf/compiler/cpp/cpp_file.cc
|
|
|
|
google/protobuf/compiler/cpp/cpp_generator.cc
|
|
|
|
google/protobuf/compiler/cpp/cpp_helpers.cc
|
|
|
|
google/protobuf/compiler/cpp/cpp_message.cc
|
|
|
|
google/protobuf/compiler/cpp/cpp_message_field.cc
|
|
|
|
google/protobuf/compiler/cpp/cpp_primitive_field.cc
|
|
|
|
google/protobuf/compiler/cpp/cpp_service.cc
|
|
|
|
google/protobuf/compiler/cpp/cpp_string_field.cc
|
|
|
|
google/protobuf/compiler/plugin.cc
|
|
|
|
google/protobuf/compiler/plugin.pb.cc
|
|
|
|
google/protobuf/compiler/subprocess.cc
|
|
|
|
google/protobuf/compiler/zip_writer.cc
|
|
|
|
)
|
|
|
|
|
|
|
|
LIST(APPEND LIBPROTOBUF_FULL_SRCS ${LIBPROTOBUF_LITE_SRCS})
|
|
|
|
|
2012-05-23 12:10:57 -06:00
|
|
|
IF(CMAKE_COMPILER_IS_GNUCC)
|
2015-11-05 19:52:04 -07:00
|
|
|
SET(CMAKE_CXX_FLAGS_RELWITHDEBINFO "${CMAKE_CXX_FLAGS_RELWITHDEBINFO} -Wno-sign-compare")
|
2018-04-05 12:58:10 -06:00
|
|
|
SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wno-unused-result -Wno-unused-local-typedefs -Wno-misleading-indentation")
|
2016-07-31 18:01:52 -06:00
|
|
|
ELSEIF(MSVC)
|
|
|
|
# Disable warnings for integer conversion to smaller type
|
|
|
|
SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /wd4267")
|
2012-05-23 12:10:57 -06:00
|
|
|
ENDIF()
|
2012-04-20 03:30:37 -06:00
|
|
|
|
2012-01-19 15:44:01 -07:00
|
|
|
INCLUDE_DIRECTORIES(${CMAKE_CURRENT_SOURCE_DIR})
|
2012-03-13 07:46:48 -06:00
|
|
|
SET(PROTOBUF_INCLUDE_DIRS ${CMAKE_CURRENT_SOURCE_DIR})
|
2012-03-10 07:31:46 -07:00
|
|
|
INCLUDE_DIRECTORIES(${ZLIB_INCLUDE_DIRS})
|
2012-08-17 05:02:31 -06:00
|
|
|
include_directories(${CMAKE_CURRENT_BINARY_DIR})
|
2012-01-20 12:21:29 -07:00
|
|
|
|
2012-03-09 08:46:21 -07:00
|
|
|
# Protobuf shared libraries
|
|
|
|
|
|
|
|
ADD_LIBRARY(protobuf SHARED ${LIBPROTOBUF_FULL_SRCS} ${LIBPROTOBUF_FULL_HDRS})
|
2012-03-13 07:46:48 -06:00
|
|
|
IDE_FOLDER(protobuf "Depends")
|
2012-03-09 08:46:21 -07:00
|
|
|
ADD_LIBRARY(protobuf-lite SHARED ${LIBPROTOBUF_LITE_SRCS} ${LIBPROTOBUF_LITE_HDRS})
|
2012-03-13 07:46:48 -06:00
|
|
|
IDE_FOLDER(protobuf-lite "Depends")
|
2012-03-09 08:46:21 -07:00
|
|
|
|
|
|
|
SET_TARGET_PROPERTIES(protobuf PROPERTIES COMPILE_DEFINITIONS LIBPROTOBUF_EXPORTS)
|
|
|
|
SET_TARGET_PROPERTIES(protobuf-lite PROPERTIES COMPILE_DEFINITIONS LIBPROTOBUF_EXPORTS)
|
|
|
|
|
2012-03-10 07:31:46 -07:00
|
|
|
TARGET_LINK_LIBRARIES(protobuf ${CMAKE_THREAD_LIBS_INIT} ${ZLIB_LIBRARIES})
|
|
|
|
TARGET_LINK_LIBRARIES(protobuf-lite ${CMAKE_THREAD_LIBS_INIT} ${ZLIB_LIBRARIES})
|
2012-03-09 08:46:21 -07:00
|
|
|
|
|
|
|
install(TARGETS protobuf-lite
|
2012-03-13 07:46:48 -06:00
|
|
|
LIBRARY DESTINATION ${DFHACK_LIBRARY_DESTINATION}
|
|
|
|
RUNTIME DESTINATION ${DFHACK_LIBRARY_DESTINATION})
|
2012-03-09 08:46:21 -07:00
|
|
|
|
2016-01-18 07:22:08 -07:00
|
|
|
IF(NOT CMAKE_CROSSCOMPILING)
|
|
|
|
# Protobuf compiler shared library
|
2012-03-09 08:46:21 -07:00
|
|
|
|
2016-01-18 07:22:08 -07:00
|
|
|
ADD_LIBRARY(protoc SHARED ${LIBPROTOC_SRCS} ${LIBPROTOC_HDRS})
|
|
|
|
IDE_FOLDER(protoc "Depends")
|
2012-03-09 08:46:21 -07:00
|
|
|
|
2016-01-18 07:22:08 -07:00
|
|
|
SET_TARGET_PROPERTIES(protoc PROPERTIES COMPILE_DEFINITIONS LIBPROTOC_EXPORTS)
|
|
|
|
TARGET_LINK_LIBRARIES(protoc protobuf)
|
2012-03-09 08:46:21 -07:00
|
|
|
|
2016-01-18 07:22:08 -07:00
|
|
|
# Protobuf compiler executable
|
2012-03-09 08:46:21 -07:00
|
|
|
|
2016-01-08 19:08:26 -07:00
|
|
|
ADD_EXECUTABLE(protoc-bin google/protobuf/compiler/main.cc google/protobuf/compiler/command_line_interface.h google/protobuf/compiler/cpp/cpp_generator.h)
|
|
|
|
IDE_FOLDER(protoc-bin "Depends")
|
2012-03-09 08:46:21 -07:00
|
|
|
|
2016-01-08 19:08:26 -07:00
|
|
|
SET_TARGET_PROPERTIES(protoc-bin PROPERTIES OUTPUT_NAME protoc)
|
|
|
|
TARGET_LINK_LIBRARIES(protoc-bin protoc)
|
|
|
|
|
|
|
|
EXPORT(TARGETS protoc-bin FILE ${CMAKE_BINARY_DIR}/ImportExecutables.cmake )
|
2016-09-08 15:12:42 -06:00
|
|
|
ENDIF()
|