2014-09-08 16:50:01 -04:00
|
|
|
SET(PACKAGE protobuf-c)
|
|
|
|
SET(PACKAGE_NAME protobuf-c)
|
2023-11-25 18:05:10 -05:00
|
|
|
SET(PACKAGE_VERSION 1.5.0)
|
2020-05-08 18:54:22 -07:00
|
|
|
SET(PACKAGE_URL https://github.com/protobuf-c/protobuf-c)
|
|
|
|
SET(PACKAGE_DESCRIPTION "Protocol Buffers implementation in C")
|
2014-09-08 16:50:01 -04:00
|
|
|
|
2021-03-12 15:59:33 -08:00
|
|
|
CMAKE_MINIMUM_REQUIRED(VERSION 3.10 FATAL_ERROR)
|
2023-09-11 00:06:48 +02:00
|
|
|
cmake_policy(SET CMP0074 NEW)
|
|
|
|
cmake_policy(SET CMP0091 NEW)
|
2023-09-11 12:16:14 +02:00
|
|
|
cmake_policy(SET CMP0112 NEW)
|
2014-09-08 16:50:01 -04:00
|
|
|
|
2023-09-11 00:06:48 +02:00
|
|
|
PROJECT(protobuf-c C CXX)
|
|
|
|
|
|
|
|
if (MSVC AND NOT BUILD_SHARED_LIBS)
|
|
|
|
SET(Protobuf_USE_STATIC_LIBS ON)
|
|
|
|
endif (MSVC AND NOT BUILD_SHARED_LIBS)
|
|
|
|
|
|
|
|
FIND_PACKAGE(Protobuf REQUIRED)
|
2023-09-11 12:16:14 +02:00
|
|
|
file(REAL_PATH "${PROTOBUF_INCLUDE_DIR}" PROTOBUF_INCLUDE_DIR)
|
2023-09-11 00:06:48 +02:00
|
|
|
INCLUDE_DIRECTORIES(${PROTOBUF_INCLUDE_DIR})
|
|
|
|
|
2023-09-18 17:54:31 +02:00
|
|
|
find_package(absl CONFIG)
|
2023-09-11 12:16:14 +02:00
|
|
|
|
2023-09-11 00:06:48 +02:00
|
|
|
# for static protobuf libraries include the dependencies
|
|
|
|
if (Protobuf_USE_STATIC_LIBS)
|
2023-09-11 12:16:14 +02:00
|
|
|
get_property(protobuf_ABSL_USED_TARGETS DIRECTORY "${CMAKE_CURRENT_LIST_DIR}" PROPERTY IMPORTED_TARGETS)
|
|
|
|
list(FILTER protobuf_ABSL_USED_TARGETS INCLUDE REGEX "absl::")
|
2023-09-11 00:06:48 +02:00
|
|
|
|
2023-09-18 17:54:31 +02:00
|
|
|
find_package(utf8_range CONFIG)
|
2023-09-11 00:06:48 +02:00
|
|
|
|
|
|
|
set(protobuf_UTF8_USED_TARGETS
|
2023-09-18 17:54:31 +02:00
|
|
|
$<TARGET_NAME_IF_EXISTS:utf8_range::utf8_validity>
|
|
|
|
$<TARGET_NAME_IF_EXISTS:utf8_range::utf8_range>
|
2023-09-11 00:06:48 +02:00
|
|
|
)
|
2023-09-11 12:16:14 +02:00
|
|
|
elseif(WIN32)
|
2023-09-18 17:54:31 +02:00
|
|
|
set(protobuf_ABSL_USED_TARGETS $<TARGET_NAME_IF_EXISTS:absl::abseil_dll>)
|
2023-09-11 00:06:48 +02:00
|
|
|
endif()
|
2014-09-08 16:50:01 -04:00
|
|
|
|
2016-11-27 12:39:37 +02:00
|
|
|
#options
|
2020-05-09 15:08:25 -07:00
|
|
|
option(BUILD_PROTOC "Build protoc-gen-c" ON)
|
2020-05-12 15:23:31 +01:00
|
|
|
if(CMAKE_BUILD_TYPE MATCHES Debug)
|
|
|
|
option(BUILD_TESTS "Build tests" ON)
|
|
|
|
else()
|
|
|
|
option(BUILD_TESTS "Build tests" OFF)
|
|
|
|
endif()
|
2016-11-27 12:39:37 +02:00
|
|
|
|
2014-09-08 16:50:01 -04:00
|
|
|
INCLUDE(TestBigEndian)
|
|
|
|
TEST_BIG_ENDIAN(WORDS_BIGENDIAN)
|
|
|
|
|
2021-04-09 23:39:02 -06:00
|
|
|
include(GNUInstallDirs)
|
|
|
|
|
|
|
|
set(PROTOBUF_C_TARGETS "protobuf-c")
|
2014-09-08 16:50:01 -04:00
|
|
|
SET(PACKAGE_STRING "${PACKAGE_NAME} ${PACKAGE_VERSION}")
|
|
|
|
ADD_DEFINITIONS(-DPACKAGE_VERSION="${PACKAGE_VERSION}")
|
|
|
|
ADD_DEFINITIONS(-DPACKAGE_STRING="${PACKAGE_STRING}")
|
2019-09-17 13:29:14 +02:00
|
|
|
if (${WORDS_BIGENDIAN})
|
|
|
|
ADD_DEFINITIONS(-DWORDS_BIGENDIAN)
|
|
|
|
endif()
|
2014-09-08 16:50:01 -04:00
|
|
|
|
2021-03-12 15:59:33 -08:00
|
|
|
IF (MSVC AND BUILD_SHARED_LIBS)
|
|
|
|
ADD_DEFINITIONS(-DPROTOBUF_C_USE_SHARED_LIB)
|
|
|
|
ENDIF (MSVC AND BUILD_SHARED_LIBS)
|
|
|
|
|
2017-04-10 18:13:48 +05:00
|
|
|
if(MSVC)
|
2014-09-08 16:50:01 -04:00
|
|
|
# using Visual Studio C++
|
|
|
|
SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} /wd4267 /wd4244")
|
|
|
|
SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /wd4267 /wd4244")
|
2023-09-11 00:06:48 +02:00
|
|
|
|
|
|
|
# Allow matching protobuf runtime dependency
|
|
|
|
if(NOT BUILD_SHARED_LIBS)
|
|
|
|
set(CMAKE_MSVC_RUNTIME_LIBRARY "MultiThreaded$<$<CONFIG:Debug>:Debug>")
|
|
|
|
endif(NOT BUILD_SHARED_LIBS)
|
|
|
|
|
2014-09-08 16:50:01 -04:00
|
|
|
ENDIF()
|
|
|
|
|
2016-07-28 18:19:48 -07:00
|
|
|
get_filename_component(MAIN_DIR ${CMAKE_CURRENT_SOURCE_DIR} PATH)
|
2014-09-08 16:50:01 -04:00
|
|
|
SET(TEST_DIR ${MAIN_DIR}/t)
|
|
|
|
|
|
|
|
MESSAGE(${MAIN_DIR})
|
|
|
|
|
|
|
|
SET (PC_SOURCES
|
|
|
|
${MAIN_DIR}/protobuf-c/protobuf-c.c
|
|
|
|
${MAIN_DIR}/protobuf-c/protobuf-c.h)
|
|
|
|
|
|
|
|
ADD_LIBRARY(protobuf-c ${PC_SOURCES})
|
2021-02-08 13:58:52 +01:00
|
|
|
set_target_properties(protobuf-c PROPERTIES COMPILE_PDB_NAME protobuf-c)
|
2021-04-09 23:39:02 -06:00
|
|
|
target_include_directories(protobuf-c
|
|
|
|
PUBLIC
|
|
|
|
$<BUILD_INTERFACE:${MAIN_DIR}>
|
|
|
|
$<INSTALL_INTERFACE:${CMAKE_INSTALL_INCLUDEDIR}>
|
|
|
|
)
|
2021-03-12 15:59:33 -08:00
|
|
|
IF (MSVC AND BUILD_SHARED_LIBS)
|
|
|
|
TARGET_COMPILE_DEFINITIONS(protobuf-c PRIVATE -DPROTOBUF_C_EXPORT)
|
|
|
|
ENDIF (MSVC AND BUILD_SHARED_LIBS)
|
2023-09-11 00:06:48 +02:00
|
|
|
target_link_libraries(protobuf-c ${protobuf_ABSL_USED_TARGETS} ${protobuf_UTF8_USED_TARGETS})
|
|
|
|
target_compile_features(protobuf-c PRIVATE cxx_std_17)
|
2014-09-08 16:50:01 -04:00
|
|
|
|
|
|
|
INCLUDE_DIRECTORIES(${MAIN_DIR})
|
|
|
|
INCLUDE_DIRECTORIES(${MAIN_DIR}/protobuf-c)
|
2020-05-09 15:08:25 -07:00
|
|
|
|
|
|
|
IF(BUILD_PROTOC)
|
2021-07-28 14:26:58 +02:00
|
|
|
INCLUDE_DIRECTORIES(${CMAKE_CURRENT_BINARY_DIR}) # for generated files
|
2014-09-08 16:50:01 -04:00
|
|
|
|
2020-05-09 15:08:25 -07:00
|
|
|
ENDIF()
|
2017-04-10 18:13:48 +05:00
|
|
|
|
2021-03-12 15:59:33 -08:00
|
|
|
if (MSVC AND NOT BUILD_SHARED_LIBS)
|
2016-11-27 12:39:37 +02:00
|
|
|
# In case we are building static libraries, link also the runtime library statically
|
|
|
|
# so that MSVCR*.DLL is not required at runtime.
|
|
|
|
# https://msdn.microsoft.com/en-us/library/2kzt1wy3.aspx
|
|
|
|
# This is achieved by 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
|
|
|
|
foreach(flag_var
|
|
|
|
CMAKE_CXX_FLAGS CMAKE_CXX_FLAGS_DEBUG CMAKE_CXX_FLAGS_RELEASE
|
2018-11-12 17:43:59 +02:00
|
|
|
CMAKE_CXX_FLAGS_MINSIZEREL CMAKE_CXX_FLAGS_RELWITHDEBINFO
|
|
|
|
CMAKE_C_FLAGS CMAKE_C_FLAGS_DEBUG CMAKE_C_FLAGS_RELEASE
|
|
|
|
CMAKE_C_FLAGS_MINSIZEREL CMAKE_FLAGS_RELWITHDEBINFO)
|
2016-11-27 12:39:37 +02:00
|
|
|
if(${flag_var} MATCHES "/MD")
|
|
|
|
string(REGEX REPLACE "/MD" "/MT" ${flag_var} "${${flag_var}}")
|
|
|
|
endif(${flag_var} MATCHES "/MD")
|
|
|
|
endforeach(flag_var)
|
2021-03-12 15:59:33 -08:00
|
|
|
endif (MSVC AND NOT BUILD_SHARED_LIBS)
|
2020-05-09 14:27:03 -07:00
|
|
|
|
2023-09-11 12:16:14 +02:00
|
|
|
if(WIN32)
|
|
|
|
# Modify the environment to hint protoc where the plugin is
|
|
|
|
# prepend to PATH because github host runners have abseil dll pre-installed.
|
|
|
|
# Use %PATH% instead of actually inserting it. On Github runners the PATH is so long
|
|
|
|
# it makes the NMake generated commands to fail.
|
|
|
|
set(OS_PATH_VARIABLE "$<TARGET_FILE_DIR:protoc-gen-c>\\;%PATH%")
|
|
|
|
|
|
|
|
if(BUILD_SHARED_LIBS)
|
|
|
|
set(OS_PATH_VARIABLE "$<TARGET_FILE_DIR:protobuf::protoc>\\;${OS_PATH_VARIABLE}")
|
2023-09-18 17:54:31 +02:00
|
|
|
if (TARGET absl::abseil_dll)
|
|
|
|
set(OS_PATH_VARIABLE "$<TARGET_FILE_DIR:absl::abseil_dll>\\;${OS_PATH_VARIABLE}")
|
|
|
|
endif()
|
2023-09-11 12:16:14 +02:00
|
|
|
endif()
|
|
|
|
|
|
|
|
else(WIN32)
|
|
|
|
|
|
|
|
set(OS_PATH_VARIABLE "$ENV{PATH}" )
|
|
|
|
set(OS_PATH_VARIABLE "$<TARGET_FILE_DIR:protoc-gen-c>:${OS_PATH_VARIABLE}")
|
|
|
|
|
|
|
|
endif(WIN32)
|
|
|
|
|
2020-05-09 15:08:25 -07:00
|
|
|
IF(BUILD_PROTOC)
|
2023-07-02 22:58:48 -04:00
|
|
|
SET(CMAKE_CXX_STANDARD 17)
|
2020-05-09 14:27:03 -07:00
|
|
|
SET(CMAKE_CXX_STANDARD_REQUIRED ON)
|
|
|
|
SET(CMAKE_CXX_EXTENSIONS OFF)
|
2023-09-11 12:16:14 +02:00
|
|
|
|
|
|
|
add_custom_target(protoc-generated-files
|
|
|
|
COMMAND ${CMAKE_COMMAND} -E env PATH="${OS_PATH_VARIABLE}" -- ${PROTOBUF_PROTOC_EXECUTABLE}
|
|
|
|
--cpp_out ${CMAKE_CURRENT_BINARY_DIR} -I${PROTOBUF_INCLUDE_DIR}
|
|
|
|
-I${MAIN_DIR} ${MAIN_DIR}/protobuf-c/protobuf-c.proto
|
|
|
|
COMMENT Running protoc on ${MAIN_DIR}/protobuf-c/protobuf-c.proto
|
|
|
|
BYPRODUCTS protobuf-c/protobuf-c.pb.cc protobuf-c/protobuf-c.pb.h
|
|
|
|
SOURCES ${MAIN_DIR}/protobuf-c/protobuf-c.proto
|
|
|
|
)
|
|
|
|
|
|
|
|
file(GLOB PROTOC_GEN_C_SRC ${MAIN_DIR}/protoc-c/*.h ${MAIN_DIR}/protoc-c/*.cc )
|
|
|
|
add_executable(protoc-gen-c
|
|
|
|
${PROTOC_GEN_C_SRC}
|
|
|
|
${CMAKE_CURRENT_BINARY_DIR}/protobuf-c/protobuf-c.pb.cc
|
|
|
|
${CMAKE_CURRENT_BINARY_DIR}/protobuf-c/protobuf-c.pb.h
|
|
|
|
)
|
|
|
|
add_dependencies(protoc-gen-c protoc-generated-files)
|
2021-04-09 23:39:02 -06:00
|
|
|
target_include_directories(protoc-gen-c
|
|
|
|
PUBLIC
|
|
|
|
$<BUILD_INTERFACE:${MAIN_DIR}>
|
|
|
|
$<INSTALL_INTERFACE:${CMAKE_INSTALL_INCLUDEDIR}>
|
|
|
|
)
|
2023-09-11 00:06:48 +02:00
|
|
|
target_link_libraries(protoc-gen-c
|
|
|
|
protobuf::libprotoc
|
|
|
|
protobuf::libprotobuf
|
|
|
|
${protobuf_ABSL_USED_TARGETS}
|
|
|
|
${protobuf_UTF8_USED_TARGETS}
|
|
|
|
)
|
|
|
|
|
|
|
|
target_compile_features(protoc-gen-c PRIVATE cxx_std_17)
|
2016-02-09 15:08:54 +01:00
|
|
|
|
2021-03-12 15:59:33 -08:00
|
|
|
IF (MSVC AND BUILD_SHARED_LIBS)
|
|
|
|
TARGET_COMPILE_DEFINITIONS(protoc-gen-c PRIVATE -DPROTOBUF_USE_DLLS)
|
|
|
|
GET_FILENAME_COMPONENT(PROTOBUF_DLL_DIR ${PROTOBUF_PROTOC_EXECUTABLE} DIRECTORY)
|
|
|
|
FILE(GLOB PROTOBUF_DLLS ${PROTOBUF_DLL_DIR}/*.dll)
|
2021-07-28 14:26:58 +02:00
|
|
|
FILE(COPY ${PROTOBUF_DLLS} DESTINATION ${CMAKE_CURRENT_BINARY_DIR})
|
2021-03-12 15:59:33 -08:00
|
|
|
ENDIF (MSVC AND BUILD_SHARED_LIBS)
|
|
|
|
|
2023-09-11 12:16:14 +02:00
|
|
|
FUNCTION(GENERATE_TEST_SOURCES PROTO_FILE SRC HDR)
|
|
|
|
ADD_CUSTOM_COMMAND(OUTPUT ${SRC} ${HDR}
|
|
|
|
COMMAND ${CMAKE_COMMAND}
|
|
|
|
ARGS -E env PATH="${OS_PATH_VARIABLE}" -- ${PROTOBUF_PROTOC_EXECUTABLE}
|
|
|
|
--plugin=$<TARGET_FILE_NAME:protoc-gen-c> -I${MAIN_DIR} ${PROTO_FILE} --c_out=${CMAKE_CURRENT_BINARY_DIR}
|
|
|
|
DEPENDS protoc-gen-c)
|
|
|
|
ENDFUNCTION()
|
2017-04-10 18:13:48 +05:00
|
|
|
|
2020-05-12 15:23:31 +01:00
|
|
|
IF(BUILD_TESTS)
|
2017-04-10 18:13:48 +05:00
|
|
|
ENABLE_TESTING()
|
|
|
|
|
|
|
|
GENERATE_TEST_SOURCES(${TEST_DIR}/test.proto t/test.pb-c.c t/test.pb-c.h)
|
2014-09-08 16:50:01 -04:00
|
|
|
|
|
|
|
ADD_EXECUTABLE(test-generated-code ${TEST_DIR}/generated-code/test-generated-code.c t/test.pb-c.c t/test.pb-c.h )
|
|
|
|
TARGET_LINK_LIBRARIES(test-generated-code protobuf-c)
|
|
|
|
|
|
|
|
ADD_CUSTOM_COMMAND(OUTPUT t/test-full.pb.cc t/test-full.pb.h
|
2023-09-11 12:16:14 +02:00
|
|
|
COMMAND ${CMAKE_COMMAND}
|
|
|
|
ARGS -E env PATH="${OS_PATH_VARIABLE}" -- ${PROTOBUF_PROTOC_EXECUTABLE}
|
|
|
|
--cpp_out ${CMAKE_CURRENT_BINARY_DIR} -I${MAIN_DIR} ${TEST_DIR}/test-full.proto
|
|
|
|
)
|
2014-09-08 16:50:01 -04:00
|
|
|
|
2017-04-10 18:13:48 +05:00
|
|
|
GENERATE_TEST_SOURCES(${TEST_DIR}/test-full.proto t/test-full.pb-c.c t/test-full.pb-c.h)
|
2014-09-08 16:50:01 -04:00
|
|
|
|
2021-03-19 18:54:16 -07:00
|
|
|
ADD_EXECUTABLE(cxx-generate-packed-data ${TEST_DIR}/generated-code2/cxx-generate-packed-data.cc t/test-full.pb.h t/test-full.pb.cc protobuf-c/protobuf-c.pb.cc protobuf-c/protobuf-c.pb.h)
|
2023-09-11 00:06:48 +02:00
|
|
|
TARGET_LINK_LIBRARIES(cxx-generate-packed-data
|
|
|
|
${PROTOBUF_LIBRARY}
|
|
|
|
${protobuf_ABSL_USED_TARGETS}
|
|
|
|
${protobuf_UTF8_USED_TARGETS}
|
|
|
|
)
|
2021-03-12 15:59:33 -08:00
|
|
|
IF (MSVC AND BUILD_SHARED_LIBS)
|
|
|
|
TARGET_COMPILE_DEFINITIONS(cxx-generate-packed-data PRIVATE -DPROTOBUF_USE_DLLS)
|
|
|
|
ENDIF (MSVC AND BUILD_SHARED_LIBS)
|
2014-09-08 16:50:01 -04:00
|
|
|
|
2021-07-28 14:26:58 +02:00
|
|
|
FILE(MAKE_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/t/generated-code2)
|
2014-09-08 16:50:01 -04:00
|
|
|
ADD_CUSTOM_COMMAND(OUTPUT t/generated-code2/test-full-cxx-output.inc
|
2023-09-11 12:16:14 +02:00
|
|
|
COMMAND ${CMAKE_COMMAND}
|
|
|
|
ARGS -E env PATH="${OS_PATH_VARIABLE}" -- cxx-generate-packed-data
|
|
|
|
">t/generated-code2/test-full-cxx-output.inc"
|
|
|
|
DEPENDS cxx-generate-packed-data
|
|
|
|
)
|
2014-09-08 16:50:01 -04:00
|
|
|
|
2017-04-10 18:13:48 +05:00
|
|
|
GENERATE_TEST_SOURCES(${TEST_DIR}/test-optimized.proto t/test-optimized.pb-c.c t/test-optimized.pb-c.h)
|
2016-02-09 15:08:54 +01:00
|
|
|
|
|
|
|
ADD_EXECUTABLE(test-generated-code2 ${TEST_DIR}/generated-code2/test-generated-code2.c t/generated-code2/test-full-cxx-output.inc t/test-full.pb-c.h t/test-full.pb-c.c t/test-optimized.pb-c.h t/test-optimized.pb-c.c)
|
|
|
|
TARGET_LINK_LIBRARIES(test-generated-code2 protobuf-c)
|
2014-09-08 16:50:01 -04:00
|
|
|
|
2017-04-10 18:13:48 +05:00
|
|
|
GENERATE_TEST_SOURCES(${TEST_DIR}/issue220/issue220.proto t/issue220/issue220.pb-c.c t/issue220/issue220.pb-c.h)
|
|
|
|
ADD_EXECUTABLE(test-issue220 ${TEST_DIR}/issue220/issue220.c t/issue220/issue220.pb-c.c t/issue220/issue220.pb-c.h)
|
|
|
|
TARGET_LINK_LIBRARIES(test-issue220 protobuf-c)
|
|
|
|
|
|
|
|
GENERATE_TEST_SOURCES(${TEST_DIR}/issue251/issue251.proto t/issue251/issue251.pb-c.c t/issue251/issue251.pb-c.h)
|
|
|
|
ADD_EXECUTABLE(test-issue251 ${TEST_DIR}/issue251/issue251.c t/issue251/issue251.pb-c.c t/issue251/issue251.pb-c.h)
|
|
|
|
TARGET_LINK_LIBRARIES(test-issue251 protobuf-c)
|
|
|
|
|
2014-09-08 16:50:01 -04:00
|
|
|
ADD_EXECUTABLE(test-version ${TEST_DIR}/version/version.c)
|
|
|
|
TARGET_LINK_LIBRARIES(test-version protobuf-c)
|
|
|
|
|
2017-04-10 18:13:48 +05:00
|
|
|
GENERATE_TEST_SOURCES(${TEST_DIR}/test-proto3.proto t/test-proto3.pb-c.c t/test-proto3.pb-c.h)
|
|
|
|
ADD_EXECUTABLE(test-generated-code3 ${TEST_DIR}/generated-code/test-generated-code.c t/test-proto3.pb-c.c t/test-proto3.pb-c.h)
|
|
|
|
TARGET_COMPILE_DEFINITIONS(test-generated-code3 PUBLIC -DPROTO3)
|
|
|
|
TARGET_LINK_LIBRARIES(test-generated-code3 protobuf-c)
|
|
|
|
|
2020-05-13 13:32:48 -07:00
|
|
|
ENDIF() # BUILD_TESTS
|
2014-09-08 16:50:01 -04:00
|
|
|
|
2020-05-08 18:55:03 -07:00
|
|
|
# https://github.com/protocolbuffers/protobuf/issues/5107
|
|
|
|
IF(CMAKE_HOST_UNIX)
|
|
|
|
FIND_PACKAGE(Threads REQUIRED)
|
|
|
|
TARGET_LINK_LIBRARIES(protoc-gen-c ${CMAKE_THREAD_LIBS_INIT})
|
2020-05-13 13:32:48 -07:00
|
|
|
IF(BUILD_TESTS)
|
2020-05-08 18:55:03 -07:00
|
|
|
TARGET_LINK_LIBRARIES(cxx-generate-packed-data ${CMAKE_THREAD_LIBS_INIT})
|
|
|
|
ENDIF()
|
|
|
|
ENDIF()
|
|
|
|
|
2021-04-09 23:39:02 -06:00
|
|
|
list(APPEND PROTOBUF_C_TARGETS "protoc-gen-c")
|
2020-05-09 15:08:25 -07:00
|
|
|
ENDIF() # BUILD_PROTOC
|
|
|
|
|
2021-04-09 23:39:02 -06:00
|
|
|
install(TARGETS ${PROTOBUF_C_TARGETS}
|
|
|
|
EXPORT protobuf-c-targets
|
|
|
|
LIBRARY DESTINATION lib
|
|
|
|
ARCHIVE DESTINATION lib
|
|
|
|
RUNTIME DESTINATION bin
|
|
|
|
)
|
|
|
|
|
2021-03-19 18:54:16 -07:00
|
|
|
INSTALL(FILES ${MAIN_DIR}/protobuf-c/protobuf-c.h ${MAIN_DIR}/protobuf-c/protobuf-c.proto DESTINATION include/protobuf-c)
|
2014-09-08 16:50:01 -04:00
|
|
|
INSTALL(FILES ${MAIN_DIR}/protobuf-c/protobuf-c.h DESTINATION include)
|
2021-07-28 14:26:58 +02:00
|
|
|
INSTALL(FILES ${CMAKE_CURRENT_BINARY_DIR}/protobuf-c.pdb DESTINATION lib OPTIONAL)
|
2016-02-09 15:08:54 +01:00
|
|
|
|
2020-05-08 18:54:22 -07:00
|
|
|
SET(prefix ${CMAKE_INSTALL_PREFIX})
|
|
|
|
SET(exec_prefix \${prefix})
|
|
|
|
SET(bindir \${exec_prefix}/${CMAKE_INSTALL_BINDIR})
|
|
|
|
SET(libdir \${exec_prefix}/${CMAKE_INSTALL_LIBDIR})
|
|
|
|
SET(includedir \${prefix}/${CMAKE_INSTALL_INCLUDEDIR})
|
|
|
|
CONFIGURE_FILE(${MAIN_DIR}/protobuf-c/libprotobuf-c.pc.in libprotobuf-c.pc @ONLY)
|
2021-07-28 14:26:58 +02:00
|
|
|
INSTALL(FILES ${CMAKE_CURRENT_BINARY_DIR}/libprotobuf-c.pc DESTINATION ${CMAKE_INSTALL_LIBDIR}/pkgconfig)
|
2020-05-08 18:54:22 -07:00
|
|
|
|
2021-04-09 23:39:02 -06:00
|
|
|
install(EXPORT protobuf-c-targets
|
|
|
|
NAMESPACE protobuf-c::
|
|
|
|
DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake/protobuf-c
|
|
|
|
)
|
|
|
|
|
|
|
|
include(CMakePackageConfigHelpers)
|
|
|
|
configure_package_config_file(${CMAKE_CURRENT_SOURCE_DIR}/Config.cmake.in
|
|
|
|
"${CMAKE_CURRENT_BINARY_DIR}/protobuf-c-config.cmake"
|
|
|
|
INSTALL_DESTINATION "lib/cmake/protobuf-c"
|
|
|
|
)
|
|
|
|
|
|
|
|
write_basic_package_version_file(protobuf-c-config-version.cmake
|
|
|
|
VERSION ${PACKAGE_VERSION}
|
|
|
|
COMPATIBILITY SameMajorVersion
|
|
|
|
)
|
|
|
|
|
|
|
|
install(FILES ${CMAKE_CURRENT_BINARY_DIR}/protobuf-c-config.cmake ${CMAKE_CURRENT_BINARY_DIR}/protobuf-c-config-version.cmake
|
|
|
|
DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake/protobuf-c
|
|
|
|
)
|
|
|
|
|
|
|
|
export(EXPORT protobuf-c-targets
|
|
|
|
FILE "${CMAKE_CURRENT_BINARY_DIR}/protobuf-c-targets.cmake"
|
|
|
|
)
|
|
|
|
|
2020-05-13 13:32:48 -07:00
|
|
|
IF(BUILD_TESTS)
|
2014-09-08 16:50:01 -04:00
|
|
|
INCLUDE(Dart)
|
|
|
|
|
|
|
|
SET(DART_TESTING_TIMEOUT 5)
|
|
|
|
ADD_TEST(test-generated-code test-generated-code)
|
|
|
|
ADD_TEST(test-generated-code2 test-generated-code2)
|
2017-04-10 18:13:48 +05:00
|
|
|
ADD_TEST(test-generated-code3 test-generated-code3)
|
|
|
|
ADD_TEST(test-issue220 test-issue220)
|
|
|
|
ADD_TEST(test-issue251 test-issue251)
|
2014-09-08 16:50:01 -04:00
|
|
|
ADD_TEST(test-version test-version)
|
2023-09-11 00:31:37 +02:00
|
|
|
|
|
|
|
if(WIN32)
|
|
|
|
set_tests_properties(
|
|
|
|
test-generated-code
|
|
|
|
test-generated-code2
|
|
|
|
test-generated-code3
|
|
|
|
test-issue220
|
|
|
|
test-issue251
|
|
|
|
test-version
|
|
|
|
PROPERTIES ENVIRONMENT "PATH=${WINDOWS_PATH_VARIABLE}\\;$<TARGET_FILE_DIR:protoc-gen-c>" )
|
|
|
|
endif(WIN32)
|
|
|
|
|
2020-05-13 13:32:48 -07:00
|
|
|
ENDIF()
|
2014-09-08 16:50:01 -04:00
|
|
|
|
|
|
|
INCLUDE(CPack)
|