PageRenderTime 50ms CodeModel.GetById 23ms RepoModel.GetById 0ms app.codeStats 0ms

/src/protobuf/CMakeLists.txt

http://decs.googlecode.com/
CMake | 129 lines | 108 code | 18 blank | 3 comment | 14 complexity | cbf1a5a0ccab7c8b30e2fd94eb78aca6 MD5 | raw file
Possible License(s): GPL-2.0, LGPL-2.1, LGPL-2.0
  1. set(PROTOBUF_DIR src)
  2. include( CheckIncludeFiles )
  3. include( CheckFunctionExists )
  4. include( FindThreads )
  5. include( FindZLIB )
  6. # We only need libprotobuf so we can disable zlib and not compile protoc.
  7. # Checking for hash_map and hash_set is tricky, but we do it anyways.
  8. if (NOT HASH_TEST_RUN)
  9. message(STATUS "Looking for hash_map and hash_set")
  10. foreach (HASH_NS stdext __gnu_cxx std "")
  11. foreach (HASH_HEADER "" ext/)
  12. if (NOT HASH_WORKS)
  13. file(WRITE
  14. ${CMAKE_BINARY_DIR}/CMakeTmp/testHashImpl.cpp
  15. "#include <${HASH_HEADER}hash_map>
  16. #include <${HASH_HEADER}hash_set>
  17. int main () { ${HASH_NS}::hash_map<int, int> m; ${HASH_NS}::hash_set<int> s; return 0; }"
  18. )
  19. try_compile(HASH_WORKS
  20. ${CMAKE_BINARY_DIR}
  21. ${CMAKE_BINARY_DIR}/CMakeTmp/testHashImpl.cpp
  22. )
  23. if (HASH_WORKS)
  24. set(HAVE_HASH_MAP 1 CACHE INTERNAL "Have hash_map")
  25. set(HAVE_HASH_SET 1 CACHE INTERNAL "Have hash_set")
  26. set(HASH_MAP_H <${HASH_HEADER}hash_map> CACHE INTERNAL "hash_map header")
  27. set(HASH_SET_H <${HASH_HEADER}hash_set> CACHE INTERNAL "hash_set header")
  28. set(HASH_NAMESPACE ${HASH_NS} CACHE INTERNAL "Namespace for hash_map/hash_set")
  29. endif (HASH_WORKS)
  30. endif (NOT HASH_WORKS)
  31. endforeach (HASH_HEADER "" ext/)
  32. endforeach (HASH_NS stdext __gnu_cxx "" std)
  33. if (HAVE_HASH_MAP)
  34. message(STATUS "Looking for hash_map and hash_set - found")
  35. else (HAVE_HASH_MAP)
  36. message(STATUS "Looking for hash_map and hash_set - not found.")
  37. set(HAVE_HASH_MAP "" CACHE INTERNAL "Have hash_map")
  38. set(HAVE_HASH_SET "" CACHE INTERNAL "Have hash_set")
  39. set(HASH_MAP_H "" CACHE INTERNAL "hash_map header")
  40. set(HASH_SET_H "" CACHE INTERNAL "hash_set header")
  41. set(HASH_NAMESPACE "" CACHE INTERNAL "Namespace for hash_map/hash_set")
  42. endif (HAVE_HASH_MAP)
  43. set(HASH_TEST_RUN 1 CACHE INTERNAL "Has run the hash map and hash set tests")
  44. endif (NOT HASH_TEST_RUN)
  45. check_include_files( dlfcn.h HAVE_DLFCN_H )
  46. check_include_files( fcntl.h HAVE_FCNTL_H )
  47. check_function_exists( ftruncate HAVE_FTRUNCATE )
  48. check_include_files( inttypes.h HAVE_INTTYPES_H )
  49. check_include_files( limits.h HAVE_LIMITS_H )
  50. check_include_files( memory.h HAVE_MEMORY_H )
  51. check_function_exists( memset HAVE_MEMSET )
  52. check_function_exists( mkdir HAVE_MKDIR )
  53. if (CMAKE_USE_PTHREADS_INIT)
  54. set(HAVE_PTHREAD 1 CACHE INTERNAL "Have POSIX threads")
  55. else (CMAKE_USE_PTHREADS_INIT)
  56. set(HAVE_PTHREAD "" CACHE INTERNAL "Have POSIX threads")
  57. endif (CMAKE_USE_PTHREADS_INIT)
  58. check_include_files( stdint.h HAVE_STDINT_H )
  59. check_include_files( stdlib.h HAVE_STDLIB_H )
  60. check_function_exists( strchr HAVE_STRCHR )
  61. check_function_exists( strerror HAVE_STRERROR )
  62. check_include_files( strings.h HAVE_STRINGS_H )
  63. check_include_files( string.h HAVE_STRING_H )
  64. check_function_exists( strtol HAVE_STRTOL )
  65. check_include_files( sys/stat.h HAVE_SYS_STAT_H )
  66. check_include_files( sys/types.h HAVE_SYS_TYPES_H )
  67. check_include_files( unistd.h HAVE_UNISTD_H )
  68. if (ZLIB_FOUND)
  69. set(HAVE_ZLIB 1 CACHE INTERNAL "Have ZLIB library")
  70. else (ZLIB_FOUND)
  71. set(HAVE_ZLIB "" CACHE INTERNAL "Have ZLIB library")
  72. endif (ZLIB_FOUND)
  73. configure_file( ${CMAKE_CURRENT_SOURCE_DIR}/config.h.in ${CMAKE_CURRENT_BINARY_DIR}/config.h )
  74. set(LIBPPROTOBUF_SOURCES
  75. ${PROTOBUF_DIR}/google/protobuf/stubs/common.cc
  76. ${PROTOBUF_DIR}/google/protobuf/stubs/once.cc
  77. ${PROTOBUF_DIR}/google/protobuf/stubs/hash.cc
  78. ${PROTOBUF_DIR}/google/protobuf/stubs/hash.h
  79. ${PROTOBUF_DIR}/google/protobuf/stubs/map-util.cc
  80. ${PROTOBUF_DIR}/google/protobuf/stubs/map-util.h
  81. ${PROTOBUF_DIR}/google/protobuf/stubs/stl_util-inl.cc
  82. ${PROTOBUF_DIR}/google/protobuf/stubs/stl_util-inl.h
  83. ${PROTOBUF_DIR}/google/protobuf/stubs/substitute.cc
  84. ${PROTOBUF_DIR}/google/protobuf/stubs/substitute.h
  85. ${PROTOBUF_DIR}/google/protobuf/stubs/strutil.cc
  86. ${PROTOBUF_DIR}/google/protobuf/stubs/strutil.h
  87. ${PROTOBUF_DIR}/google/protobuf/stubs/structurally_valid.cc
  88. ${PROTOBUF_DIR}/google/protobuf/descriptor.cc
  89. ${PROTOBUF_DIR}/google/protobuf/descriptor.pb.cc
  90. ${PROTOBUF_DIR}/google/protobuf/descriptor_database.cc
  91. ${PROTOBUF_DIR}/google/protobuf/dynamic_message.cc
  92. ${PROTOBUF_DIR}/google/protobuf/extension_set.cc
  93. ${PROTOBUF_DIR}/google/protobuf/generated_message_reflection.cc
  94. ${PROTOBUF_DIR}/google/protobuf/message.cc
  95. ${PROTOBUF_DIR}/google/protobuf/reflection_ops.cc
  96. ${PROTOBUF_DIR}/google/protobuf/repeated_field.cc
  97. ${PROTOBUF_DIR}/google/protobuf/service.cc
  98. ${PROTOBUF_DIR}/google/protobuf/text_format.cc
  99. ${PROTOBUF_DIR}/google/protobuf/unknown_field_set.cc
  100. ${PROTOBUF_DIR}/google/protobuf/wire_format.cc
  101. ${PROTOBUF_DIR}/google/protobuf/io/coded_stream.cc
  102. ${PROTOBUF_DIR}/google/protobuf/io/gzip_stream.cc
  103. ${PROTOBUF_DIR}/google/protobuf/io/printer.cc
  104. ${PROTOBUF_DIR}/google/protobuf/io/tokenizer.cc
  105. ${PROTOBUF_DIR}/google/protobuf/io/zero_copy_stream.cc
  106. ${PROTOBUF_DIR}/google/protobuf/io/zero_copy_stream_impl.cc
  107. ${PROTOBUF_DIR}/google/protobuf/compiler/importer.cc
  108. ${PROTOBUF_DIR}/google/protobuf/compiler/parser.cc
  109. )
  110. include_directories( . ${PROTOBUF_DIR} )
  111. add_library( protobuf STATIC ${LIBPPROTOBUF_SOURCES} )