feat add protobuf
All checks were successful
linux-aarch64-cpu-gcc / linux-gcc-aarch64 (push) Successful in 1m57s
linux-x64-gcc / linux-gcc (Release) (push) Successful in 1m47s
linux-arm-gcc / linux-gcc-armhf (push) Successful in 1m58s
linux-mips64-gcc / linux-gcc-mips64el (Debug) (push) Successful in 2m22s
linux-x64-gcc / linux-gcc (Debug) (push) Successful in 2m39s
linux-mips64-gcc / linux-gcc-mips64el (Release) (push) Successful in 2m31s
All checks were successful
linux-aarch64-cpu-gcc / linux-gcc-aarch64 (push) Successful in 1m57s
linux-x64-gcc / linux-gcc (Release) (push) Successful in 1m47s
linux-arm-gcc / linux-gcc-armhf (push) Successful in 1m58s
linux-mips64-gcc / linux-gcc-mips64el (Debug) (push) Successful in 2m22s
linux-x64-gcc / linux-gcc (Debug) (push) Successful in 2m39s
linux-mips64-gcc / linux-gcc-mips64el (Release) (push) Successful in 2m31s
This commit is contained in:
parent
5c1056cbc8
commit
fdbce08c6c
@ -8,9 +8,9 @@ endif()
|
|||||||
# CMake policies
|
# CMake policies
|
||||||
cmake_policy(SET CMP0022 NEW)
|
cmake_policy(SET CMP0022 NEW)
|
||||||
# On MacOS use @rpath/ for target's install name prefix path
|
# On MacOS use @rpath/ for target's install name prefix path
|
||||||
if (POLICY CMP0042)
|
if(POLICY CMP0042)
|
||||||
cmake_policy(SET CMP0042 NEW)
|
cmake_policy(SET CMP0042 NEW)
|
||||||
endif ()
|
endif()
|
||||||
# Clear VERSION variables when no VERSION is given to project()
|
# Clear VERSION variables when no VERSION is given to project()
|
||||||
if(POLICY CMP0048)
|
if(POLICY CMP0048)
|
||||||
cmake_policy(SET CMP0048 NEW)
|
cmake_policy(SET CMP0048 NEW)
|
||||||
@ -27,13 +27,14 @@ if(protobuf_DEPRECATED_CMAKE_SUBDIRECTORY_USAGE)
|
|||||||
if(CMAKE_PROJECT_NAME STREQUAL "protobuf")
|
if(CMAKE_PROJECT_NAME STREQUAL "protobuf")
|
||||||
get_filename_component(CMAKE_SOURCE_DIR ${CMAKE_SOURCE_DIR} DIRECTORY)
|
get_filename_component(CMAKE_SOURCE_DIR ${CMAKE_SOURCE_DIR} DIRECTORY)
|
||||||
endif()
|
endif()
|
||||||
get_filename_component(CMAKE_CURRENT_SOURCE_DIR ${CMAKE_CURRENT_SOURCE_DIR} DIRECTORY)
|
get_filename_component(CMAKE_CURRENT_SOURCE_DIR ${CMAKE_CURRENT_SOURCE_DIR}
|
||||||
|
DIRECTORY)
|
||||||
get_filename_component(PROJECT_SOURCE_DIR ${PROJECT_SOURCE_DIR} DIRECTORY)
|
get_filename_component(PROJECT_SOURCE_DIR ${PROJECT_SOURCE_DIR} DIRECTORY)
|
||||||
get_filename_component(protobuf_SOURCE_DIR ${protobuf_SOURCE_DIR} DIRECTORY)
|
get_filename_component(protobuf_SOURCE_DIR ${protobuf_SOURCE_DIR} DIRECTORY)
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
# Add c++11 flags
|
# Add c++11 flags
|
||||||
if (CYGWIN)
|
if(CYGWIN)
|
||||||
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=gnu++11")
|
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=gnu++11")
|
||||||
else()
|
else()
|
||||||
set(CMAKE_CXX_STANDARD 11)
|
set(CMAKE_CXX_STANDARD 11)
|
||||||
@ -42,78 +43,88 @@ else()
|
|||||||
endif()
|
endif()
|
||||||
|
|
||||||
# The Intel compiler isn't able to deal with noinline member functions of
|
# The Intel compiler isn't able to deal with noinline member functions of
|
||||||
# template classes defined in headers. As such it spams the output with
|
# template classes defined in headers. As such it spams the output with warning
|
||||||
# warning #2196: routine is both "inline" and "noinline"
|
# #2196: routine is both "inline" and "noinline" This silences that warning.
|
||||||
# This silences that warning.
|
if(CMAKE_CXX_COMPILER_ID MATCHES Intel)
|
||||||
if (CMAKE_CXX_COMPILER_ID MATCHES Intel)
|
|
||||||
string(APPEND CMAKE_CXX_FLAGS " -diag-disable=2196")
|
string(APPEND CMAKE_CXX_FLAGS " -diag-disable=2196")
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
# Options
|
# Options
|
||||||
option(protobuf_INSTALL "Install protobuf binaries and files" ON)
|
option(protobuf_INSTALL "Install protobuf binaries and files" ON)
|
||||||
if(WITH_PROTOC)
|
if(WITH_PROTOC)
|
||||||
set(protobuf_PROTOC_EXE ${WITH_PROTOC} CACHE FILEPATH "Protocol Buffer Compiler executable" FORCE)
|
set(protobuf_PROTOC_EXE
|
||||||
|
${WITH_PROTOC}
|
||||||
|
CACHE FILEPATH "Protocol Buffer Compiler executable" FORCE)
|
||||||
endif()
|
endif()
|
||||||
option(protobuf_BUILD_TESTS "Build tests" OFF)
|
option(protobuf_BUILD_TESTS "Build tests" OFF)
|
||||||
option(protobuf_BUILD_CONFORMANCE "Build conformance tests" OFF)
|
option(protobuf_BUILD_CONFORMANCE "Build conformance tests" OFF)
|
||||||
option(protobuf_BUILD_EXAMPLES "Build examples" OFF)
|
option(protobuf_BUILD_EXAMPLES "Build examples" OFF)
|
||||||
option(protobuf_BUILD_PROTOC_BINARIES "Build libprotoc and protoc compiler" ON)
|
option(protobuf_BUILD_PROTOC_BINARIES "Build libprotoc and protoc compiler" OFF)
|
||||||
option(protobuf_BUILD_LIBPROTOC "Build libprotoc" OFF)
|
option(protobuf_BUILD_LIBPROTOC "Build libprotoc" OFF)
|
||||||
option(protobuf_DISABLE_RTTI "Remove runtime type information in the binaries" OFF)
|
option(protobuf_DISABLE_RTTI "Remove runtime type information in the binaries"
|
||||||
if (BUILD_SHARED_LIBS)
|
OFF)
|
||||||
|
if(BUILD_SHARED_LIBS)
|
||||||
set(protobuf_BUILD_SHARED_LIBS_DEFAULT ON)
|
set(protobuf_BUILD_SHARED_LIBS_DEFAULT ON)
|
||||||
else (BUILD_SHARED_LIBS)
|
else(BUILD_SHARED_LIBS)
|
||||||
set(protobuf_BUILD_SHARED_LIBS_DEFAULT OFF)
|
set(protobuf_BUILD_SHARED_LIBS_DEFAULT OFF)
|
||||||
endif (BUILD_SHARED_LIBS)
|
endif(BUILD_SHARED_LIBS)
|
||||||
option(protobuf_BUILD_SHARED_LIBS "Build Shared Libraries" ${protobuf_BUILD_SHARED_LIBS_DEFAULT})
|
option(protobuf_BUILD_SHARED_LIBS "Build Shared Libraries"
|
||||||
|
${protobuf_BUILD_SHARED_LIBS_DEFAULT})
|
||||||
include(CMakeDependentOption)
|
include(CMakeDependentOption)
|
||||||
cmake_dependent_option(protobuf_MSVC_STATIC_RUNTIME "Link static runtime libraries" ON
|
cmake_dependent_option(
|
||||||
|
protobuf_MSVC_STATIC_RUNTIME "Link static runtime libraries" ON
|
||||||
"NOT protobuf_BUILD_SHARED_LIBS" OFF)
|
"NOT protobuf_BUILD_SHARED_LIBS" OFF)
|
||||||
set(protobuf_WITH_ZLIB_DEFAULT OFF)
|
set(protobuf_WITH_ZLIB_DEFAULT OFF)
|
||||||
option(protobuf_WITH_ZLIB "Build with zlib support" ${protobuf_WITH_ZLIB_DEFAULT})
|
option(protobuf_WITH_ZLIB "Build with zlib support"
|
||||||
set(protobuf_DEBUG_POSTFIX "d"
|
${protobuf_WITH_ZLIB_DEFAULT})
|
||||||
CACHE STRING "Default debug postfix")
|
set(protobuf_DEBUG_POSTFIX
|
||||||
|
"d"
|
||||||
|
CACHE STRING "Default debug postfix")
|
||||||
mark_as_advanced(protobuf_DEBUG_POSTFIX)
|
mark_as_advanced(protobuf_DEBUG_POSTFIX)
|
||||||
# User options
|
# User options
|
||||||
include(${protobuf_SOURCE_DIR}/cmake/protobuf-options.cmake)
|
include(${protobuf_SOURCE_DIR}/cmake/protobuf-options.cmake)
|
||||||
|
|
||||||
# Overrides for option dependencies
|
# Overrides for option dependencies
|
||||||
if (protobuf_BUILD_PROTOC_BINARIES OR protobuf_BUILD_TESTS)
|
if(protobuf_BUILD_PROTOC_BINARIES OR protobuf_BUILD_TESTS)
|
||||||
set(protobuf_BUILD_LIBPROTOC ON)
|
set(protobuf_BUILD_LIBPROTOC ON)
|
||||||
endif ()
|
endif()
|
||||||
# Path to main configure script
|
# Path to main configure script
|
||||||
set(protobuf_CONFIGURE_SCRIPT "${protobuf_SOURCE_DIR}/configure.ac")
|
set(protobuf_CONFIGURE_SCRIPT "${protobuf_SOURCE_DIR}/configure.ac")
|
||||||
|
|
||||||
# Parse configure script
|
# Parse configure script
|
||||||
set(protobuf_AC_INIT_REGEX
|
set(protobuf_AC_INIT_REGEX
|
||||||
"^AC_INIT\\(\\[([^]]+)\\],\\[([^]]+)\\],\\[([^]]+)\\],\\[([^]]+)\\]\\)$")
|
"^AC_INIT\\(\\[([^]]+)\\],\\[([^]]+)\\],\\[([^]]+)\\],\\[([^]]+)\\]\\)$")
|
||||||
file(STRINGS "${protobuf_CONFIGURE_SCRIPT}" protobuf_AC_INIT_LINE
|
file(
|
||||||
LIMIT_COUNT 1 REGEX "^AC_INIT")
|
STRINGS "${protobuf_CONFIGURE_SCRIPT}" protobuf_AC_INIT_LINE
|
||||||
|
LIMIT_COUNT 1
|
||||||
|
REGEX "^AC_INIT")
|
||||||
# Description
|
# Description
|
||||||
string(REGEX REPLACE "${protobuf_AC_INIT_REGEX}" "\\1"
|
string(REGEX REPLACE "${protobuf_AC_INIT_REGEX}" "\\1" protobuf_DESCRIPTION
|
||||||
protobuf_DESCRIPTION "${protobuf_AC_INIT_LINE}")
|
"${protobuf_AC_INIT_LINE}")
|
||||||
# Version
|
# Version
|
||||||
string(REGEX REPLACE "${protobuf_AC_INIT_REGEX}" "\\2"
|
string(REGEX REPLACE "${protobuf_AC_INIT_REGEX}" "\\2" protobuf_VERSION_STRING
|
||||||
protobuf_VERSION_STRING "${protobuf_AC_INIT_LINE}")
|
"${protobuf_AC_INIT_LINE}")
|
||||||
# Contact
|
# Contact
|
||||||
string(REGEX REPLACE "${protobuf_AC_INIT_REGEX}" "\\3"
|
string(REGEX REPLACE "${protobuf_AC_INIT_REGEX}" "\\3" protobuf_CONTACT
|
||||||
protobuf_CONTACT "${protobuf_AC_INIT_LINE}")
|
"${protobuf_AC_INIT_LINE}")
|
||||||
# Parse version tweaks
|
# Parse version tweaks
|
||||||
set(protobuf_VERSION_REGEX "^([0-9]+)\\.([0-9]+)\\.([0-9]+)([-]rc[-]|\\.)?([0-9]*)$")
|
set(protobuf_VERSION_REGEX
|
||||||
string(REGEX REPLACE "${protobuf_VERSION_REGEX}" "\\1"
|
"^([0-9]+)\\.([0-9]+)\\.([0-9]+)([-]rc[-]|\\.)?([0-9]*)$")
|
||||||
protobuf_VERSION_MAJOR "${protobuf_VERSION_STRING}")
|
string(REGEX REPLACE "${protobuf_VERSION_REGEX}" "\\1" protobuf_VERSION_MAJOR
|
||||||
string(REGEX REPLACE "${protobuf_VERSION_REGEX}" "\\2"
|
"${protobuf_VERSION_STRING}")
|
||||||
protobuf_VERSION_MINOR "${protobuf_VERSION_STRING}")
|
string(REGEX REPLACE "${protobuf_VERSION_REGEX}" "\\2" protobuf_VERSION_MINOR
|
||||||
string(REGEX REPLACE "${protobuf_VERSION_REGEX}" "\\3"
|
"${protobuf_VERSION_STRING}")
|
||||||
protobuf_VERSION_PATCH "${protobuf_VERSION_STRING}")
|
string(REGEX REPLACE "${protobuf_VERSION_REGEX}" "\\3" protobuf_VERSION_PATCH
|
||||||
string(REGEX REPLACE "${protobuf_VERSION_REGEX}" "\\5"
|
"${protobuf_VERSION_STRING}")
|
||||||
protobuf_VERSION_PRERELEASE "${protobuf_VERSION_STRING}")
|
string(REGEX REPLACE "${protobuf_VERSION_REGEX}" "\\5"
|
||||||
|
protobuf_VERSION_PRERELEASE "${protobuf_VERSION_STRING}")
|
||||||
|
|
||||||
message(STATUS "${protobuf_VERSION_PRERELEASE}")
|
message(STATUS "${protobuf_VERSION_PRERELEASE}")
|
||||||
|
|
||||||
# Package version
|
# Package version
|
||||||
set(protobuf_VERSION
|
set(protobuf_VERSION
|
||||||
"${protobuf_VERSION_MAJOR}.${protobuf_VERSION_MINOR}.${protobuf_VERSION_PATCH}")
|
"${protobuf_VERSION_MAJOR}.${protobuf_VERSION_MINOR}.${protobuf_VERSION_PATCH}"
|
||||||
|
)
|
||||||
|
|
||||||
if(protobuf_VERSION_PRERELEASE)
|
if(protobuf_VERSION_PRERELEASE)
|
||||||
set(protobuf_VERSION "${protobuf_VERSION}.${protobuf_VERSION_PRERELEASE}")
|
set(protobuf_VERSION "${protobuf_VERSION}.${protobuf_VERSION_PRERELEASE}")
|
||||||
@ -125,19 +136,21 @@ message(STATUS "${protobuf_VERSION}")
|
|||||||
if(protobuf_VERBOSE)
|
if(protobuf_VERBOSE)
|
||||||
message(STATUS "Configuration script parsing status [")
|
message(STATUS "Configuration script parsing status [")
|
||||||
message(STATUS " Description : ${protobuf_DESCRIPTION}")
|
message(STATUS " Description : ${protobuf_DESCRIPTION}")
|
||||||
message(STATUS " Version : ${protobuf_VERSION} (${protobuf_VERSION_STRING})")
|
message(
|
||||||
|
STATUS " Version : ${protobuf_VERSION} (${protobuf_VERSION_STRING})")
|
||||||
message(STATUS " Contact : ${protobuf_CONTACT}")
|
message(STATUS " Contact : ${protobuf_CONTACT}")
|
||||||
message(STATUS "]")
|
message(STATUS "]")
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
add_definitions(-DGOOGLE_PROTOBUF_CMAKE_BUILD)
|
add_definitions(-DGOOGLE_PROTOBUF_CMAKE_BUILD)
|
||||||
|
|
||||||
if (protobuf_DISABLE_RTTI)
|
if(protobuf_DISABLE_RTTI)
|
||||||
add_definitions(-DGOOGLE_PROTOBUF_NO_RTTI=1)
|
add_definitions(-DGOOGLE_PROTOBUF_NO_RTTI=1)
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
file(WRITE ${CMAKE_CURRENT_BINARY_DIR}/cmaketest.map
|
file(
|
||||||
"{
|
WRITE ${CMAKE_CURRENT_BINARY_DIR}/cmaketest.map
|
||||||
|
"{
|
||||||
global:
|
global:
|
||||||
main;
|
main;
|
||||||
local:
|
local:
|
||||||
@ -146,16 +159,22 @@ file(WRITE ${CMAKE_CURRENT_BINARY_DIR}/cmaketest.map
|
|||||||
# CheckLinkerFlag module available in CMake >=3.18.
|
# CheckLinkerFlag module available in CMake >=3.18.
|
||||||
if(${CMAKE_VERSION} VERSION_GREATER 3.18 OR ${CMAKE_VERSION} VERSION_EQUAL 3.18)
|
if(${CMAKE_VERSION} VERSION_GREATER 3.18 OR ${CMAKE_VERSION} VERSION_EQUAL 3.18)
|
||||||
include(CheckLinkerFlag)
|
include(CheckLinkerFlag)
|
||||||
check_linker_flag(CXX -Wl,--version-script=${CMAKE_CURRENT_BINARY_DIR}/cmaketest.map protobuf_HAVE_LD_VERSION_SCRIPT)
|
check_linker_flag(
|
||||||
|
CXX -Wl,--version-script=${CMAKE_CURRENT_BINARY_DIR}/cmaketest.map
|
||||||
|
protobuf_HAVE_LD_VERSION_SCRIPT)
|
||||||
else()
|
else()
|
||||||
include(CheckCXXSourceCompiles)
|
include(CheckCXXSourceCompiles)
|
||||||
set(OLD_CMAKE_REQUIRED_FLAGS ${CMAKE_REQUIRED_FLAGS})
|
set(OLD_CMAKE_REQUIRED_FLAGS ${CMAKE_REQUIRED_FLAGS})
|
||||||
set(CMAKE_REQUIRED_FLAGS ${CMAKE_REQUIRED_FLAGS} -Wl,--version-script=${CMAKE_CURRENT_BINARY_DIR}/cmaketest.map)
|
set(CMAKE_REQUIRED_FLAGS
|
||||||
check_cxx_source_compiles("
|
${CMAKE_REQUIRED_FLAGS}
|
||||||
|
-Wl,--version-script=${CMAKE_CURRENT_BINARY_DIR}/cmaketest.map)
|
||||||
|
check_cxx_source_compiles(
|
||||||
|
"
|
||||||
int main() {
|
int main() {
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
" protobuf_HAVE_LD_VERSION_SCRIPT)
|
"
|
||||||
|
protobuf_HAVE_LD_VERSION_SCRIPT)
|
||||||
set(CMAKE_REQUIRED_FLAGS ${OLD_CMAKE_REQUIRED_FLAGS})
|
set(CMAKE_REQUIRED_FLAGS ${OLD_CMAKE_REQUIRED_FLAGS})
|
||||||
endif()
|
endif()
|
||||||
file(REMOVE ${CMAKE_CURRENT_BINARY_DIR}/cmaketest.map)
|
file(REMOVE ${CMAKE_CURRENT_BINARY_DIR}/cmaketest.map)
|
||||||
@ -163,84 +182,89 @@ file(REMOVE ${CMAKE_CURRENT_BINARY_DIR}/cmaketest.map)
|
|||||||
find_package(Threads REQUIRED)
|
find_package(Threads REQUIRED)
|
||||||
|
|
||||||
set(_protobuf_FIND_ZLIB)
|
set(_protobuf_FIND_ZLIB)
|
||||||
if (protobuf_WITH_ZLIB)
|
if(protobuf_WITH_ZLIB)
|
||||||
find_package(ZLIB)
|
find_package(ZLIB)
|
||||||
if (ZLIB_FOUND)
|
if(ZLIB_FOUND)
|
||||||
set(HAVE_ZLIB 1)
|
set(HAVE_ZLIB 1)
|
||||||
# FindZLIB module define ZLIB_INCLUDE_DIRS variable
|
# FindZLIB module define ZLIB_INCLUDE_DIRS variable Set
|
||||||
# Set ZLIB_INCLUDE_DIRECTORIES for compatible
|
# ZLIB_INCLUDE_DIRECTORIES for compatible
|
||||||
set(ZLIB_INCLUDE_DIRECTORIES ${ZLIB_INCLUDE_DIRECTORIES} ${ZLIB_INCLUDE_DIRS})
|
set(ZLIB_INCLUDE_DIRECTORIES ${ZLIB_INCLUDE_DIRECTORIES}
|
||||||
|
${ZLIB_INCLUDE_DIRS})
|
||||||
# Using imported target if exists
|
# Using imported target if exists
|
||||||
if (TARGET ZLIB::ZLIB)
|
if(TARGET ZLIB::ZLIB)
|
||||||
set(ZLIB_LIBRARIES ZLIB::ZLIB)
|
set(ZLIB_LIBRARIES ZLIB::ZLIB)
|
||||||
set(_protobuf_FIND_ZLIB "if(NOT ZLIB_FOUND)\n find_package(ZLIB)\nendif()")
|
set(_protobuf_FIND_ZLIB
|
||||||
endif (TARGET ZLIB::ZLIB)
|
"if(NOT ZLIB_FOUND)\n find_package(ZLIB)\nendif()")
|
||||||
else (ZLIB_FOUND)
|
endif(TARGET ZLIB::ZLIB)
|
||||||
|
else(ZLIB_FOUND)
|
||||||
set(HAVE_ZLIB 0)
|
set(HAVE_ZLIB 0)
|
||||||
# Explicitly set these to empty (override NOT_FOUND) so cmake doesn't
|
# Explicitly set these to empty (override NOT_FOUND) so cmake doesn't
|
||||||
# complain when we use them later.
|
# complain when we use them later.
|
||||||
set(ZLIB_INCLUDE_DIRECTORIES)
|
set(ZLIB_INCLUDE_DIRECTORIES)
|
||||||
set(ZLIB_LIBRARIES)
|
set(ZLIB_LIBRARIES)
|
||||||
endif (ZLIB_FOUND)
|
endif(ZLIB_FOUND)
|
||||||
endif (protobuf_WITH_ZLIB)
|
endif(protobuf_WITH_ZLIB)
|
||||||
|
|
||||||
if (HAVE_ZLIB)
|
if(HAVE_ZLIB)
|
||||||
add_definitions(-DHAVE_ZLIB)
|
add_definitions(-DHAVE_ZLIB)
|
||||||
endif (HAVE_ZLIB)
|
endif(HAVE_ZLIB)
|
||||||
|
|
||||||
# We need to link with libatomic on systems that do not have builtin atomics, or
|
# We need to link with libatomic on systems that do not have builtin atomics, or
|
||||||
# don't have builtin support for 8 byte atomics
|
# don't have builtin support for 8 byte atomics
|
||||||
set(protobuf_LINK_LIBATOMIC false)
|
set(protobuf_LINK_LIBATOMIC false)
|
||||||
if (NOT MSVC)
|
if(NOT MSVC)
|
||||||
include(CheckCXXSourceCompiles)
|
include(CheckCXXSourceCompiles)
|
||||||
set(OLD_CMAKE_REQUIRED_FLAGS ${CMAKE_REQUIRED_FLAGS})
|
set(OLD_CMAKE_REQUIRED_FLAGS ${CMAKE_REQUIRED_FLAGS})
|
||||||
set(CMAKE_REQUIRED_FLAGS ${CMAKE_REQUIRED_FLAGS} -std=c++11)
|
set(CMAKE_REQUIRED_FLAGS ${CMAKE_REQUIRED_FLAGS} -std=c++11)
|
||||||
check_cxx_source_compiles("
|
check_cxx_source_compiles(
|
||||||
|
"
|
||||||
#include <atomic>
|
#include <atomic>
|
||||||
int main() {
|
int main() {
|
||||||
return std::atomic<int64_t>{};
|
return std::atomic<int64_t>{};
|
||||||
}
|
}
|
||||||
" protobuf_HAVE_BUILTIN_ATOMICS)
|
"
|
||||||
if (NOT protobuf_HAVE_BUILTIN_ATOMICS)
|
protobuf_HAVE_BUILTIN_ATOMICS)
|
||||||
|
if(NOT protobuf_HAVE_BUILTIN_ATOMICS)
|
||||||
set(protobuf_LINK_LIBATOMIC true)
|
set(protobuf_LINK_LIBATOMIC true)
|
||||||
endif (NOT protobuf_HAVE_BUILTIN_ATOMICS)
|
endif(NOT protobuf_HAVE_BUILTIN_ATOMICS)
|
||||||
set(CMAKE_REQUIRED_FLAGS ${OLD_CMAKE_REQUIRED_FLAGS})
|
set(CMAKE_REQUIRED_FLAGS ${OLD_CMAKE_REQUIRED_FLAGS})
|
||||||
endif (NOT MSVC)
|
endif(NOT MSVC)
|
||||||
|
|
||||||
if (protobuf_BUILD_SHARED_LIBS)
|
if(protobuf_BUILD_SHARED_LIBS)
|
||||||
set(protobuf_SHARED_OR_STATIC "SHARED")
|
set(protobuf_SHARED_OR_STATIC "SHARED")
|
||||||
else (protobuf_BUILD_SHARED_LIBS)
|
else(protobuf_BUILD_SHARED_LIBS)
|
||||||
set(protobuf_SHARED_OR_STATIC "STATIC")
|
set(protobuf_SHARED_OR_STATIC "STATIC")
|
||||||
# The CMAKE_<LANG>_FLAGS(_<BUILD_TYPE>)? is meant to be user controlled.
|
# The CMAKE_<LANG>_FLAGS(_<BUILD_TYPE>)? is meant to be user controlled. Prior
|
||||||
# Prior to CMake 3.15, the MSVC runtime library was pushed into the same flags
|
# to CMake 3.15, the MSVC runtime library was pushed into the same flags
|
||||||
# making programmatic control difficult. Prefer the functionality in newer
|
# making programmatic control difficult. Prefer the functionality in newer
|
||||||
# CMake versions when available.
|
# CMake versions when available.
|
||||||
if(${CMAKE_VERSION} VERSION_GREATER 3.15 OR ${CMAKE_VERSION} VERSION_EQUAL 3.15)
|
if(${CMAKE_VERSION} VERSION_GREATER 3.15 OR ${CMAKE_VERSION} VERSION_EQUAL
|
||||||
if (protobuf_MSVC_STATIC_RUNTIME)
|
3.15)
|
||||||
set(CMAKE_MSVC_RUNTIME_LIBRARY MultiThreaded$<$<CONFIG:Debug>:Debug>)
|
if(protobuf_MSVC_STATIC_RUNTIME)
|
||||||
|
set(CMAKE_MSVC_RUNTIME_LIBRARY MultiThreaded$<$<CONFIG:Debug>:Debug>)
|
||||||
else()
|
else()
|
||||||
set(CMAKE_MSVC_RUNTIME_LIBRARY MultiThreaded$<$<CONFIG:Debug>:Debug>DLL)
|
set(CMAKE_MSVC_RUNTIME_LIBRARY MultiThreaded$<$<CONFIG:Debug>:Debug>DLL)
|
||||||
endif()
|
endif()
|
||||||
else()
|
else()
|
||||||
# In case we are building static libraries, link also the runtime library statically
|
# In case we are building static libraries, link also the runtime library
|
||||||
# so that MSVCR*.DLL is not required at runtime.
|
# statically so that MSVCR*.DLL is not required at runtime.
|
||||||
# https://msdn.microsoft.com/en-us/library/2kzt1wy3.aspx
|
# https://msdn.microsoft.com/en-us/library/2kzt1wy3.aspx This is achieved by
|
||||||
# This is achieved by replacing msvc option /MD with /MT and /MDd with /MTd
|
# replacing msvc option /MD with /MT and /MDd with /MTd
|
||||||
# http://www.cmake.org/Wiki/CMake_FAQ#How_can_I_build_my_MSVC_application_with_a_static_runtime.3F
|
# http://www.cmake.org/Wiki/CMake_FAQ#How_can_I_build_my_MSVC_application_with_a_static_runtime.3F
|
||||||
if (MSVC AND protobuf_MSVC_STATIC_RUNTIME)
|
if(MSVC AND protobuf_MSVC_STATIC_RUNTIME)
|
||||||
foreach(flag_var
|
foreach(flag_var
|
||||||
CMAKE_CXX_FLAGS CMAKE_CXX_FLAGS_DEBUG CMAKE_CXX_FLAGS_RELEASE
|
CMAKE_CXX_FLAGS CMAKE_CXX_FLAGS_DEBUG CMAKE_CXX_FLAGS_RELEASE
|
||||||
CMAKE_CXX_FLAGS_MINSIZEREL CMAKE_CXX_FLAGS_RELWITHDEBINFO)
|
CMAKE_CXX_FLAGS_MINSIZEREL CMAKE_CXX_FLAGS_RELWITHDEBINFO)
|
||||||
if(${flag_var} MATCHES "/MD")
|
if(${flag_var} MATCHES "/MD")
|
||||||
string(REGEX REPLACE "/MD" "/MT" ${flag_var} "${${flag_var}}")
|
string(REGEX REPLACE "/MD" "/MT" ${flag_var} "${${flag_var}}")
|
||||||
endif(${flag_var} MATCHES "/MD")
|
endif(${flag_var} MATCHES "/MD")
|
||||||
endforeach(flag_var)
|
endforeach(flag_var)
|
||||||
endif (MSVC AND protobuf_MSVC_STATIC_RUNTIME)
|
endif(MSVC AND protobuf_MSVC_STATIC_RUNTIME)
|
||||||
endif()
|
endif()
|
||||||
endif (protobuf_BUILD_SHARED_LIBS)
|
endif(protobuf_BUILD_SHARED_LIBS)
|
||||||
|
|
||||||
if (MSVC)
|
if(MSVC)
|
||||||
if (CMAKE_CXX_COMPILER_ID STREQUAL "MSVC")
|
if(CMAKE_CXX_COMPILER_ID STREQUAL "MSVC")
|
||||||
# Build with multiple processes
|
# Build with multiple processes
|
||||||
add_definitions(/MP)
|
add_definitions(/MP)
|
||||||
endif()
|
endif()
|
||||||
@ -249,102 +273,111 @@ if (MSVC)
|
|||||||
# MSVC warning suppressions
|
# MSVC warning suppressions
|
||||||
add_definitions(
|
add_definitions(
|
||||||
/wd4065 # switch statement contains 'default' but no 'case' labels
|
/wd4065 # switch statement contains 'default' but no 'case' labels
|
||||||
/wd4244 # 'conversion' conversion from 'type1' to 'type2', possible loss of data
|
/wd4244 # 'conversion' conversion from 'type1' to 'type2', possible loss of
|
||||||
/wd4251 # 'identifier' : class 'type' needs to have dll-interface to be used by clients of class 'type2'
|
# data
|
||||||
|
/wd4251 # 'identifier' : class 'type' needs to have dll-interface to be used
|
||||||
|
# by clients of class 'type2'
|
||||||
/wd4267 # 'var' : conversion from 'size_t' to 'type', possible loss of data
|
/wd4267 # 'var' : conversion from 'size_t' to 'type', possible loss of data
|
||||||
/wd4305 # 'identifier' : truncation from 'type1' to 'type2'
|
/wd4305 # 'identifier' : truncation from 'type1' to 'type2'
|
||||||
/wd4307 # 'operator' : integral constant overflow
|
/wd4307 # 'operator' : integral constant overflow
|
||||||
/wd4309 # 'conversion' : truncation of constant value
|
/wd4309 # 'conversion' : truncation of constant value
|
||||||
/wd4334 # 'operator' : result of 32-bit shift implicitly converted to 64 bits (was 64-bit shift intended?)
|
/wd4334 # 'operator' : result of 32-bit shift implicitly converted to 64
|
||||||
|
# bits (was 64-bit shift intended?)
|
||||||
/wd4355 # 'this' : used in base member initializer list
|
/wd4355 # 'this' : used in base member initializer list
|
||||||
/wd4506 # no definition for inline function 'function'
|
/wd4506 # no definition for inline function 'function'
|
||||||
/wd4800 # 'type' : forcing value to bool 'true' or 'false' (performance warning)
|
/wd4800 # 'type' : forcing value to bool 'true' or 'false' (performance
|
||||||
|
# warning)
|
||||||
/wd4996 # The compiler encountered a deprecated declaration.
|
/wd4996 # The compiler encountered a deprecated declaration.
|
||||||
)
|
)
|
||||||
# Allow big object
|
# Allow big object
|
||||||
add_definitions(/bigobj)
|
add_definitions(/bigobj)
|
||||||
string(REPLACE "/" "\\" PROTOBUF_SOURCE_WIN32_PATH ${protobuf_SOURCE_DIR})
|
string(REPLACE "/" "\\" PROTOBUF_SOURCE_WIN32_PATH ${protobuf_SOURCE_DIR})
|
||||||
string(REPLACE "/" "\\" PROTOBUF_BINARY_WIN32_PATH ${protobuf_BINARY_DIR})
|
string(REPLACE "/" "\\" PROTOBUF_BINARY_WIN32_PATH ${protobuf_BINARY_DIR})
|
||||||
string(REPLACE "." "," protobuf_RC_FILEVERSION "${protobuf_VERSION}")
|
string(REPLACE "." "," protobuf_RC_FILEVERSION "${protobuf_VERSION}")
|
||||||
configure_file(${protobuf_SOURCE_DIR}/cmake/extract_includes.bat.in extract_includes.bat)
|
configure_file(${protobuf_SOURCE_DIR}/cmake/extract_includes.bat.in
|
||||||
|
extract_includes.bat)
|
||||||
|
|
||||||
# Suppress linker warnings about files with no symbols defined.
|
# Suppress linker warnings about files with no symbols defined.
|
||||||
set(CMAKE_STATIC_LINKER_FLAGS "${CMAKE_STATIC_LINKER_FLAGS} /ignore:4221")
|
set(CMAKE_STATIC_LINKER_FLAGS "${CMAKE_STATIC_LINKER_FLAGS} /ignore:4221")
|
||||||
|
|
||||||
if (CMAKE_CXX_COMPILER_ID STREQUAL "MSVC")
|
if(CMAKE_CXX_COMPILER_ID STREQUAL "MSVC")
|
||||||
# Configure Resource Compiler
|
# Configure Resource Compiler
|
||||||
enable_language(RC)
|
enable_language(RC)
|
||||||
# use English language (0x409) in resource compiler
|
# use English language (0x409) in resource compiler
|
||||||
set(rc_flags "/l0x409")
|
set(rc_flags "/l0x409")
|
||||||
# fix rc.exe invocations because of usage of add_definitions()
|
# fix rc.exe invocations because of usage of add_definitions()
|
||||||
set(CMAKE_RC_COMPILE_OBJECT "<CMAKE_RC_COMPILER> ${rc_flags} <DEFINES> /fo<OBJECT> <SOURCE>")
|
set(CMAKE_RC_COMPILE_OBJECT
|
||||||
|
"<CMAKE_RC_COMPILER> ${rc_flags} <DEFINES> /fo<OBJECT> <SOURCE>")
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
# Generate the version.rc file used elsewhere.
|
# Generate the version.rc file used elsewhere.
|
||||||
configure_file(${protobuf_SOURCE_DIR}/cmake/version.rc.in ${CMAKE_CURRENT_BINARY_DIR}/version.rc @ONLY)
|
configure_file(${protobuf_SOURCE_DIR}/cmake/version.rc.in
|
||||||
|
${CMAKE_CURRENT_BINARY_DIR}/version.rc @ONLY)
|
||||||
set(protobuf_version_rc_file ${CMAKE_CURRENT_BINARY_DIR}/version.rc)
|
set(protobuf_version_rc_file ${CMAKE_CURRENT_BINARY_DIR}/version.rc)
|
||||||
|
|
||||||
# Add the "lib" prefix for generated .lib outputs.
|
# Add the "lib" prefix for generated .lib outputs.
|
||||||
set(LIB_PREFIX lib)
|
set(LIB_PREFIX lib)
|
||||||
else (MSVC)
|
else(MSVC)
|
||||||
# No version.rc file.
|
# No version.rc file.
|
||||||
set(protobuf_version_rc_file)
|
set(protobuf_version_rc_file)
|
||||||
|
|
||||||
# When building with "make", "lib" prefix will be added automatically by
|
# When building with "make", "lib" prefix will be added automatically by the
|
||||||
# the build tool.
|
# build tool.
|
||||||
set(LIB_PREFIX)
|
set(LIB_PREFIX)
|
||||||
endif (MSVC)
|
endif(MSVC)
|
||||||
|
|
||||||
include_directories(
|
include_directories(${ZLIB_INCLUDE_DIRECTORIES} ${protobuf_BINARY_DIR}
|
||||||
${ZLIB_INCLUDE_DIRECTORIES}
|
${protobuf_SOURCE_DIR}/src)
|
||||||
${protobuf_BINARY_DIR}
|
|
||||||
${protobuf_SOURCE_DIR}/src)
|
|
||||||
|
|
||||||
if (protobuf_UNICODE)
|
if(protobuf_UNICODE)
|
||||||
add_definitions(-DUNICODE -D_UNICODE)
|
add_definitions(-DUNICODE -D_UNICODE)
|
||||||
endif (protobuf_UNICODE)
|
endif(protobuf_UNICODE)
|
||||||
|
|
||||||
include(${protobuf_SOURCE_DIR}/cmake/libprotobuf-lite.cmake)
|
include(${protobuf_SOURCE_DIR}/cmake/libprotobuf-lite.cmake)
|
||||||
include(${protobuf_SOURCE_DIR}/cmake/libprotobuf.cmake)
|
include(${protobuf_SOURCE_DIR}/cmake/libprotobuf.cmake)
|
||||||
if (protobuf_BUILD_LIBPROTOC)
|
if(protobuf_BUILD_LIBPROTOC)
|
||||||
include(${protobuf_SOURCE_DIR}/cmake/libprotoc.cmake)
|
include(${protobuf_SOURCE_DIR}/cmake/libprotoc.cmake)
|
||||||
endif (protobuf_BUILD_LIBPROTOC)
|
endif(protobuf_BUILD_LIBPROTOC)
|
||||||
if (protobuf_BUILD_PROTOC_BINARIES)
|
if(protobuf_BUILD_PROTOC_BINARIES)
|
||||||
include(${protobuf_SOURCE_DIR}/cmake/protoc.cmake)
|
include(${protobuf_SOURCE_DIR}/cmake/protoc.cmake)
|
||||||
if (NOT DEFINED protobuf_PROTOC_EXE)
|
if(NOT DEFINED protobuf_PROTOC_EXE)
|
||||||
set(protobuf_PROTOC_EXE protoc)
|
set(protobuf_PROTOC_EXE protoc)
|
||||||
endif (NOT DEFINED protobuf_PROTOC_EXE)
|
endif(NOT DEFINED protobuf_PROTOC_EXE)
|
||||||
endif (protobuf_BUILD_PROTOC_BINARIES)
|
endif(protobuf_BUILD_PROTOC_BINARIES)
|
||||||
|
|
||||||
# Ensure we have a protoc executable if we need one
|
# Ensure we have a protoc executable if we need one
|
||||||
if (protobuf_BUILD_TESTS OR protobuf_BUILD_CONFORMANCE OR protobuf_BUILD_EXAMPLES)
|
if(protobuf_BUILD_TESTS
|
||||||
if (NOT DEFINED protobuf_PROTOC_EXE)
|
OR protobuf_BUILD_CONFORMANCE
|
||||||
|
OR protobuf_BUILD_EXAMPLES)
|
||||||
|
if(NOT DEFINED protobuf_PROTOC_EXE)
|
||||||
find_program(protobuf_PROTOC_EXE protoc)
|
find_program(protobuf_PROTOC_EXE protoc)
|
||||||
if (NOT protobuf_PROTOC_EXE)
|
if(NOT protobuf_PROTOC_EXE)
|
||||||
message(FATAL "Build requires 'protoc' but binary not found and not building protoc.")
|
message(
|
||||||
endif ()
|
FATAL
|
||||||
endif ()
|
"Build requires 'protoc' but binary not found and not building protoc.")
|
||||||
|
endif()
|
||||||
|
endif()
|
||||||
if(protobuf_VERBOSE)
|
if(protobuf_VERBOSE)
|
||||||
message(STATUS "Using protoc : ${protobuf_PROTOC_EXE}")
|
message(STATUS "Using protoc : ${protobuf_PROTOC_EXE}")
|
||||||
endif(protobuf_VERBOSE)
|
endif(protobuf_VERBOSE)
|
||||||
endif ()
|
endif()
|
||||||
|
|
||||||
if (protobuf_BUILD_TESTS)
|
if(protobuf_BUILD_TESTS)
|
||||||
enable_testing()
|
enable_testing()
|
||||||
include(${protobuf_SOURCE_DIR}/cmake/tests.cmake)
|
include(${protobuf_SOURCE_DIR}/cmake/tests.cmake)
|
||||||
endif (protobuf_BUILD_TESTS)
|
endif(protobuf_BUILD_TESTS)
|
||||||
|
|
||||||
if (protobuf_BUILD_CONFORMANCE)
|
if(protobuf_BUILD_CONFORMANCE)
|
||||||
include(${protobuf_SOURCE_DIR}/cmake/conformance.cmake)
|
include(${protobuf_SOURCE_DIR}/cmake/conformance.cmake)
|
||||||
endif (protobuf_BUILD_CONFORMANCE)
|
endif(protobuf_BUILD_CONFORMANCE)
|
||||||
|
|
||||||
if (protobuf_INSTALL)
|
if(protobuf_INSTALL)
|
||||||
include(${protobuf_SOURCE_DIR}/cmake/install.cmake)
|
include(${protobuf_SOURCE_DIR}/cmake/install.cmake)
|
||||||
endif (protobuf_INSTALL)
|
endif(protobuf_INSTALL)
|
||||||
|
|
||||||
if (protobuf_BUILD_EXAMPLES)
|
if(protobuf_BUILD_EXAMPLES)
|
||||||
include(${protobuf_SOURCE_DIR}/cmake/examples.cmake)
|
include(${protobuf_SOURCE_DIR}/cmake/examples.cmake)
|
||||||
endif (protobuf_BUILD_EXAMPLES)
|
endif(protobuf_BUILD_EXAMPLES)
|
||||||
|
|
||||||
if(protobuf_VERBOSE)
|
if(protobuf_VERBOSE)
|
||||||
message(STATUS "Protocol Buffers Configuring done")
|
message(STATUS "Protocol Buffers Configuring done")
|
||||||
|
@ -32,7 +32,7 @@ add_subdirectory(3party/minilua EXCLUDE_FROM_ALL)
|
|||||||
# add_subdirectory(3party/gperftools EXCLUDE_FROM_ALL)
|
# add_subdirectory(3party/gperftools EXCLUDE_FROM_ALL)
|
||||||
add_subdirectory(3party/asyncplusplus EXCLUDE_FROM_ALL)
|
add_subdirectory(3party/asyncplusplus EXCLUDE_FROM_ALL)
|
||||||
# add_subdirectory(3party/cppuprofile EXCLUDE_FROM_ALL)
|
# add_subdirectory(3party/cppuprofile EXCLUDE_FROM_ALL)
|
||||||
# add_subdirectory(3party/protobuf-3.21.12 EXCLUDE_FROM_ALL)
|
add_subdirectory(3party/protobuf-3.21.12 EXCLUDE_FROM_ALL)
|
||||||
if(NOT TARGET marl)
|
if(NOT TARGET marl)
|
||||||
add_subdirectory(3party/marl EXCLUDE_FROM_ALL)
|
add_subdirectory(3party/marl EXCLUDE_FROM_ALL)
|
||||||
endif()
|
endif()
|
||||||
@ -96,7 +96,7 @@ target_sources(
|
|||||||
|
|
||||||
target_link_libraries(
|
target_link_libraries(
|
||||||
sled
|
sled
|
||||||
PUBLIC rpc_core fmt marl Async++ minilua
|
PUBLIC rpc_core fmt marl Async++ minilua protobuf::libprotobuf
|
||||||
PRIVATE dl
|
PRIVATE dl
|
||||||
# protobuf::libprotobuf ${WHOLE_ARCHIVE_WRAPPER_START}
|
# protobuf::libprotobuf ${WHOLE_ARCHIVE_WRAPPER_START}
|
||||||
# tcmalloc_and_profiler_static ${WHOLE_ARCHIVE_WRAPPER_END}
|
# tcmalloc_and_profiler_static ${WHOLE_ARCHIVE_WRAPPER_END}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user