PageRenderTime 39ms CodeModel.GetById 15ms RepoModel.GetById 0ms app.codeStats 0ms

/src/CMakeLists.txt

http://protobuf-c.googlecode.com/
CMake | 118 lines | 107 code | 11 blank | 0 comment | 9 complexity | 52681e7e15037a6d7f1ac977261109ca MD5 | raw file
Possible License(s): BSD-3-Clause
  1. set(BUILD_PROTOBUF_C_COMPILER ON
  2. CACHE BOOL "build protobuf-c compiler (aka protoc-c)")
  3. if ( BUILD_PROTOBUF_C_COMPILER )
  4. find_package(Protobuf REQUIRED)
  5. include_directories(${PROTOBUF_INCLUDE_DIRS} ${CMAKE_CURRENT_SOURCE_DIR})
  6. set(PROTOC_C_SOURCES
  7. google/protobuf/compiler/c/c_service.cc
  8. google/protobuf/compiler/c/c_helpers.cc
  9. google/protobuf/compiler/c/c_enum.cc
  10. google/protobuf/compiler/c/c_enum_field.cc
  11. google/protobuf/compiler/c/c_string_field.cc
  12. google/protobuf/compiler/c/c_primitive_field.cc
  13. google/protobuf/compiler/c/c_extension.cc
  14. google/protobuf/compiler/c/c_file.cc
  15. google/protobuf/compiler/c/c_field.cc
  16. google/protobuf/compiler/c/c_message.cc
  17. google/protobuf/compiler/c/c_generator.cc
  18. google/protobuf/compiler/c/c_message_field.cc
  19. google/protobuf/compiler/c/main.cc
  20. google/protobuf/compiler/c/c_bytes_field.cc)
  21. add_executable(protoc-c ${PROTOC_C_SOURCES})
  22. target_link_libraries(protoc-c ${PROTOBUF_LIBRARY}
  23. ${PROTOBUF_PROTOC_LIBRARY})
  24. if ( UNIX )
  25. find_package(Threads REQUIRED)
  26. target_link_libraries(protoc-c ${CMAKE_THREAD_LIBS_INIT})
  27. endif()
  28. install(TARGETS protoc-c DESTINATION ${PROTOBUF_C_INSTALL_BINDIR})
  29. endif()
  30. include(CheckIncludeFiles)
  31. check_include_files("alloca.h" HAVE_ALLOCA_H)
  32. check_include_files("malloc.h" HAVE_MALLOC_H)
  33. check_include_files("sys/poll.h" HAVE_SYS_POLL_H)
  34. check_include_files("sys/select.h" HAVE_SYS_SELECT_H)
  35. check_include_files("inttypes.h" HAVE_INTTYPES_H)
  36. check_include_files("sys/uio.h" HAVE_SYS_UIO_H)
  37. check_include_files("unistd.h" HAVE_UNISTD_H)
  38. check_include_files("io.h" HAVE_IO_H)
  39. include(TestBigEndian)
  40. test_big_endian(IS_BIG_ENDIAN)
  41. if ( NOT IS_BIG_ENDIAN )
  42. set(IS_LITTLE_ENDIAN 1)
  43. endif()
  44. add_definitions(-DHAVE_PROTOBUF_C_CONFIG_H=1)
  45. configure_file(google/protobuf-c/protobuf-c-config.h.in
  46. google/protobuf-c/protobuf-c-config.h)
  47. include_directories(${CMAKE_CURRENT_BINARY_DIR}/google/protobuf-c)
  48. set(BUILD_PROTOBUF_C_STATIC_LIB ON
  49. CACHE BOOL "build static protobuf-c library")
  50. set(BUILD_PROTOBUF_C_SHARED_LIB ON
  51. CACHE BOOL "build shared protobuf-c library")
  52. if ( WIN32 )
  53. set(PROTOBUF_C_SOURCES
  54. google/protobuf-c/protobuf-c-data-buffer.c
  55. google/protobuf-c/protobuf-c.c)
  56. else()
  57. set(PROTOBUF_C_SOURCES
  58. google/protobuf-c/protobuf-c-dispatch.c
  59. google/protobuf-c/protobuf-c-data-buffer.c
  60. google/protobuf-c/protobuf-c-rpc.c
  61. google/protobuf-c/protobuf-c.c)
  62. endif()
  63. if ( BUILD_PROTOBUF_C_STATIC_LIB )
  64. add_library(protobuf-c-static STATIC ${PROTOBUF_C_SOURCES})
  65. install(TARGETS protobuf-c-static
  66. ARCHIVE DESTINATION ${PROTOBUF_C_INSTALL_LIBDIR})
  67. set_target_properties(protobuf-c-static PROPERTIES OUTPUT_NAME protobuf-c)
  68. get_target_property(DIRECTORY protobuf-c-static ARCHIVE_OUTPUT_DIRECTORY)
  69. set_target_properties(protobuf-c-static PROPERTIES ARCHIVE_OUTPUT_DIRECTORY
  70. ${DIRECTORY}/static)
  71. endif()
  72. if ( BUILD_PROTOBUF_C_SHARED_LIB )
  73. add_library(protobuf-c-shared SHARED ${PROTOBUF_C_SOURCES})
  74. install(TARGETS protobuf-c-shared
  75. RUNTIME DESTINATION ${PROTOBUF_C_INSTALL_BINDIR}
  76. LIBRARY DESTINATION ${PROTOBUF_C_INSTALL_LIBDIR}
  77. ARCHIVE DESTINATION ${PROTOBUF_C_INSTALL_LIBDIR}/dllimport)
  78. set_target_properties(protobuf-c-shared PROPERTIES OUTPUT_NAME protobuf-c)
  79. set_target_properties(protobuf-c-shared PROPERTIES VERSION
  80. ${PROTOBUF_C_VERSION})
  81. get_target_property(DIRECTORY protobuf-c-shared ARCHIVE_OUTPUT_DIRECTORY)
  82. set_target_properties(protobuf-c-shared PROPERTIES ARCHIVE_OUTPUT_DIRECTORY
  83. ${DIRECTORY}/shared)
  84. get_target_property(DIRECTORY protobuf-c-shared LIBRARY_OUTPUT_DIRECTORY)
  85. set_target_properties(protobuf-c-shared PROPERTIES LIBRARY_OUTPUT_DIRECTORY
  86. ${DIRECTORY}/shared)
  87. if ( WIN32 )
  88. set_target_properties(protobuf-c-shared PROPERTIES COMPILE_DEFINITIONS
  89. "PROTOBUF_C_USE_SHARED_LIB;PROTOBUF_C_EXPORT")
  90. endif()
  91. endif()
  92. if ( BUILD_PROTOBUF_C_STATIC_LIB OR BUILD_PROTOBUF_C_SHARED_LIB )
  93. if ( WIN32 )
  94. set(PROTOBUF_C_PUBLIC_HEADERS
  95. google/protobuf-c/protobuf-c.h
  96. google/protobuf-c/protobuf-c-private.h)
  97. else()
  98. set(PROTOBUF_C_PUBLIC_HEADERS
  99. google/protobuf-c/protobuf-c.h
  100. google/protobuf-c/protobuf-c-private.h
  101. google/protobuf-c/protobuf-c-dispatch.h
  102. google/protobuf-c/protobuf-c-rpc.h)
  103. endif()
  104. install(FILES ${PROTOBUF_C_PUBLIC_HEADERS} DESTINATION
  105. ${PROTOBUF_C_INSTALL_INCLUDEDIR})
  106. endif()
  107. add_subdirectory(test)