PROJECT(protobuff) SET(LIB_PROTOBUFF_INC_FILES ${CMAKE_CURRENT_SOURCE_DIR}/src/google/protobuf/io/coded_stream.h ${CMAKE_CURRENT_SOURCE_DIR}/src/google/protobuf/io/coded_stream_inl.h ${CMAKE_CURRENT_SOURCE_DIR}/src/google/protobuf/stubs/common.h # ${CMAKE_CURRENT_SOURCE_DIR}/vsprojects/config.h ${CMAKE_CURRENT_SOURCE_DIR}/src/google/protobuf/descriptor.h ${CMAKE_CURRENT_SOURCE_DIR}/src/google/protobuf/descriptor.pb.h ${CMAKE_CURRENT_SOURCE_DIR}/src/google/protobuf/descriptor_database.h ${CMAKE_CURRENT_SOURCE_DIR}/src/google/protobuf/dynamic_message.h ${CMAKE_CURRENT_SOURCE_DIR}/src/google/protobuf/extension_set.h ${CMAKE_CURRENT_SOURCE_DIR}/src/google/protobuf/generated_message_reflection.h ${CMAKE_CURRENT_SOURCE_DIR}/src/google/protobuf/generated_message_util.h ${CMAKE_CURRENT_SOURCE_DIR}/src/google/protobuf/io/gzip_stream.h ${CMAKE_CURRENT_SOURCE_DIR}/src/google/protobuf/stubs/hash.h ${CMAKE_CURRENT_SOURCE_DIR}/src/google/protobuf/compiler/importer.h ${CMAKE_CURRENT_SOURCE_DIR}/src/google/protobuf/stubs/map-util.h ${CMAKE_CURRENT_SOURCE_DIR}/src/google/protobuf/message.h ${CMAKE_CURRENT_SOURCE_DIR}/src/google/protobuf/message_lite.h ${CMAKE_CURRENT_SOURCE_DIR}/src/google/protobuf/stubs/atomicops.h # ${CMAKE_CURRENT_SOURCE_DIR}/src/google/protobuf/stubs/atomicops_internals_x86_msvc.h ${CMAKE_CURRENT_SOURCE_DIR}/src/google/protobuf/stubs/platform_macros.h ${CMAKE_CURRENT_SOURCE_DIR}/src/google/protobuf/stubs/once.h ${CMAKE_CURRENT_SOURCE_DIR}/src/google/protobuf/compiler/parser.h ${CMAKE_CURRENT_SOURCE_DIR}/src/google/protobuf/io/printer.h ${CMAKE_CURRENT_SOURCE_DIR}/src/google/protobuf/reflection_ops.h ${CMAKE_CURRENT_SOURCE_DIR}/src/google/protobuf/repeated_field.h ${CMAKE_CURRENT_SOURCE_DIR}/src/google/protobuf/service.h ${CMAKE_CURRENT_SOURCE_DIR}/src/google/protobuf/stubs/stl_util.h ${CMAKE_CURRENT_SOURCE_DIR}/src/google/protobuf/stubs/stringprintf.h ${CMAKE_CURRENT_SOURCE_DIR}/src/google/protobuf/stubs/template_util.h ${CMAKE_CURRENT_SOURCE_DIR}/src/google/protobuf/stubs/type_traits.h ${CMAKE_CURRENT_SOURCE_DIR}/src/google/protobuf/stubs/strutil.h ${CMAKE_CURRENT_SOURCE_DIR}/src/google/protobuf/stubs/substitute.h ${CMAKE_CURRENT_SOURCE_DIR}/src/google/protobuf/text_format.h ${CMAKE_CURRENT_SOURCE_DIR}/src/google/protobuf/io/tokenizer.h ${CMAKE_CURRENT_SOURCE_DIR}/src/google/protobuf/unknown_field_set.h ${CMAKE_CURRENT_SOURCE_DIR}/src/google/protobuf/wire_format.h ${CMAKE_CURRENT_SOURCE_DIR}/src/google/protobuf/wire_format_lite.h ${CMAKE_CURRENT_SOURCE_DIR}/src/google/protobuf/wire_format_lite_inl.h ${CMAKE_CURRENT_SOURCE_DIR}/src/google/protobuf/io/zero_copy_stream.h ${CMAKE_CURRENT_SOURCE_DIR}/src/google/protobuf/io/zero_copy_stream_impl.h ${CMAKE_CURRENT_SOURCE_DIR}/src/google/protobuf/io/zero_copy_stream_impl_lite.h ) SET(LIB_PROTOBUFF_SRC_FILES ${CMAKE_CURRENT_SOURCE_DIR}/src/google/protobuf/io/coded_stream.cc ${CMAKE_CURRENT_SOURCE_DIR}/src/google/protobuf/stubs/common.cc ${CMAKE_CURRENT_SOURCE_DIR}/src/google/protobuf/descriptor.cc ${CMAKE_CURRENT_SOURCE_DIR}/src/google/protobuf/descriptor.pb.cc ${CMAKE_CURRENT_SOURCE_DIR}/src/google/protobuf/descriptor_database.cc ${CMAKE_CURRENT_SOURCE_DIR}/src/google/protobuf/dynamic_message.cc ${CMAKE_CURRENT_SOURCE_DIR}/src/google/protobuf/extension_set.cc ${CMAKE_CURRENT_SOURCE_DIR}/src/google/protobuf/extension_set_heavy.cc ${CMAKE_CURRENT_SOURCE_DIR}/src/google/protobuf/generated_message_reflection.cc ${CMAKE_CURRENT_SOURCE_DIR}/src/google/protobuf/generated_message_util.cc ${CMAKE_CURRENT_SOURCE_DIR}/src/google/protobuf/io/gzip_stream.cc ${CMAKE_CURRENT_SOURCE_DIR}/src/google/protobuf/compiler/importer.cc ${CMAKE_CURRENT_SOURCE_DIR}/src/google/protobuf/message.cc ${CMAKE_CURRENT_SOURCE_DIR}/src/google/protobuf/message_lite.cc ${CMAKE_CURRENT_SOURCE_DIR}/src/google/protobuf/stubs/once.cc # ${CMAKE_CURRENT_SOURCE_DIR}/src/google/protobuf/stubs/atomicops_internals_x86_msvc.cc ${CMAKE_CURRENT_SOURCE_DIR}/src/google/protobuf/compiler/parser.cc ${CMAKE_CURRENT_SOURCE_DIR}/src/google/protobuf/io/printer.cc ${CMAKE_CURRENT_SOURCE_DIR}/src/google/protobuf/reflection_ops.cc ${CMAKE_CURRENT_SOURCE_DIR}/src/google/protobuf/repeated_field.cc ${CMAKE_CURRENT_SOURCE_DIR}/src/google/protobuf/service.cc ${CMAKE_CURRENT_SOURCE_DIR}/src/google/protobuf/stubs/structurally_valid.cc ${CMAKE_CURRENT_SOURCE_DIR}/src/google/protobuf/stubs/strutil.cc ${CMAKE_CURRENT_SOURCE_DIR}/src/google/protobuf/stubs/substitute.cc ${CMAKE_CURRENT_SOURCE_DIR}/src/google/protobuf/text_format.cc ${CMAKE_CURRENT_SOURCE_DIR}/src/google/protobuf/io/tokenizer.cc ${CMAKE_CURRENT_SOURCE_DIR}/src/google/protobuf/unknown_field_set.cc ${CMAKE_CURRENT_SOURCE_DIR}/src/google/protobuf/wire_format.cc ${CMAKE_CURRENT_SOURCE_DIR}/src/google/protobuf/wire_format_lite.cc ${CMAKE_CURRENT_SOURCE_DIR}/src/google/protobuf/io/zero_copy_stream.cc ${CMAKE_CURRENT_SOURCE_DIR}/src/google/protobuf/io/zero_copy_stream_impl.cc ${CMAKE_CURRENT_SOURCE_DIR}/src/google/protobuf/io/zero_copy_stream_impl_lite.cc ${CMAKE_CURRENT_SOURCE_DIR}/src/google/protobuf/stubs/stringprintf.cc ) IF(MINGW) MESSAGE(STATUS "mingw compiler") SET(LIB_PROTOBUFF_INC_FILES ${LIB_PROTOBUFF_INC_FILES} "${CMAKE_CURRENT_SOURCE_DIR}/src/google/protobuf/stubs/atomicops_internals_x86_gcc.h" "${CMAKE_CURRENT_SOURCE_DIR}/config.h") SET(LIB_PROTOBUFF_SRC_FILES ${LIB_PROTOBUFF_SRC_FILES} "${CMAKE_CURRENT_SOURCE_DIR}/src/google/protobuf/stubs/atomicops_internals_x86_gcc.cc") ENDIF(MINGW) IF(MSVC) SET(LIB_PROTOBUFF_INC_FILES ${LIB_PROTOBUFF_INC_FILES} "${CMAKE_CURRENT_SOURCE_DIR}/src/google/protobuf/stubs/atomicops_internals_x86_msvc.h" "${CMAKE_CURRENT_SOURCE_DIR}/vsprojects/config.h") SET(LIB_PROTOBUFF_SRC_FILES ${LIB_PROTOBUFF_SRC_FILES} "${CMAKE_CURRENT_SOURCE_DIR}/src/google/protobuf/stubs/atomicops_internals_x86_msvc.cc") ENDIF(MSVC) include_directories(${CMAKE_CURRENT_SOURCE_DIR}/src ${CMAKE_CURRENT_SOURCE_DIR}/vsprojects) IF(MSVC) INCLUDE_DIRECTORIES(${CMAKE_CURRENT_SOURCE_DIR}/vsprojects) ENDIF(MSVC) IF(MINGW) INCLUDE_DIRECTORIES(${CMAKE_CURRENT_SOURCE_DIR}/) #fix strdup function see:http://stackoverflow.com/questions/5573775/strdup-error-on-g-with-c0x set(CMAKE_CXX_FLAGS ${CMAKE_CXX_FLAGS} "-std=gnu++0x") #set(CMAKE_CXX_FLAGS ${CMAKE_CXX_FLAGS} "-std=c++0x") ENDIF(MINGW) ADD_LIBRARY(protobuf STATIC ${LIB_PROTOBUFF_INC_FILES} ${LIB_PROTOBUFF_SRC_FILES}) #------------------------------------------------------------------------------------------------------ SET(PROTOC_INC_FILES ${CMAKE_CURRENT_SOURCE_DIR}/src/google/protobuf/compiler/code_generator.h ${CMAKE_CURRENT_SOURCE_DIR}/src/google/protobuf/compiler/command_line_interface.h ${CMAKE_CURRENT_SOURCE_DIR}/src/google/protobuf/compiler/subprocess.h ${CMAKE_CURRENT_SOURCE_DIR}/src/google/protobuf/compiler/zip_writer.h ${CMAKE_CURRENT_SOURCE_DIR}/src/google/protobuf/compiler/plugin.h ${CMAKE_CURRENT_SOURCE_DIR}/src/google/protobuf/compiler/plugin.pb.h ${CMAKE_CURRENT_SOURCE_DIR}/src/google/protobuf/compiler/cpp/cpp_enum.h ${CMAKE_CURRENT_SOURCE_DIR}/src/google/protobuf/compiler/cpp/cpp_enum_field.h ${CMAKE_CURRENT_SOURCE_DIR}/src/google/protobuf/compiler/cpp/cpp_extension.h ${CMAKE_CURRENT_SOURCE_DIR}/src/google/protobuf/compiler/cpp/cpp_field.h ${CMAKE_CURRENT_SOURCE_DIR}/src/google/protobuf/compiler/cpp/cpp_file.h ${CMAKE_CURRENT_SOURCE_DIR}/src/google/protobuf/compiler/cpp/cpp_generator.h ${CMAKE_CURRENT_SOURCE_DIR}/src/google/protobuf/compiler/cpp/cpp_helpers.h ${CMAKE_CURRENT_SOURCE_DIR}/src/google/protobuf/compiler/cpp/cpp_message.h ${CMAKE_CURRENT_SOURCE_DIR}/src/google/protobuf/compiler/cpp/cpp_message_field.h ${CMAKE_CURRENT_SOURCE_DIR}/src/google/protobuf/compiler/cpp/cpp_options.h ${CMAKE_CURRENT_SOURCE_DIR}/src/google/protobuf/compiler/cpp/cpp_primitive_field.h ${CMAKE_CURRENT_SOURCE_DIR}/src/google/protobuf/compiler/cpp/cpp_service.h ${CMAKE_CURRENT_SOURCE_DIR}/src/google/protobuf/compiler/cpp/cpp_string_field.h ${CMAKE_CURRENT_SOURCE_DIR}/src/google/protobuf/compiler/java/java_enum.h ${CMAKE_CURRENT_SOURCE_DIR}/src/google/protobuf/compiler/java/java_enum_field.h ${CMAKE_CURRENT_SOURCE_DIR}/src/google/protobuf/compiler/java/java_extension.h ${CMAKE_CURRENT_SOURCE_DIR}/src/google/protobuf/compiler/java/java_field.h ${CMAKE_CURRENT_SOURCE_DIR}/src/google/protobuf/compiler/java/java_file.h ${CMAKE_CURRENT_SOURCE_DIR}/src/google/protobuf/compiler/java/java_generator.h ${CMAKE_CURRENT_SOURCE_DIR}/src/google/protobuf/compiler/java/java_helpers.h ${CMAKE_CURRENT_SOURCE_DIR}/src/google/protobuf/compiler/java/java_message.h ${CMAKE_CURRENT_SOURCE_DIR}/src/google/protobuf/compiler/java/java_message_field.h ${CMAKE_CURRENT_SOURCE_DIR}/src/google/protobuf/compiler/java/java_primitive_field.h ${CMAKE_CURRENT_SOURCE_DIR}/src/google/protobuf/compiler/java/java_service.h ${CMAKE_CURRENT_SOURCE_DIR}/src/google/protobuf/compiler/java/java_string_field.h ${CMAKE_CURRENT_SOURCE_DIR}/src/google/protobuf/compiler/java/java_doc_comment.h ${CMAKE_CURRENT_SOURCE_DIR}/src/google/protobuf/compiler/python/python_generator.h ) SET(PROTOC_SRC_FILES ${CMAKE_CURRENT_SOURCE_DIR}/src/google/protobuf/compiler/java/java_doc_comment.cc ${CMAKE_CURRENT_SOURCE_DIR}/src/google/protobuf/compiler/code_generator.cc ${CMAKE_CURRENT_SOURCE_DIR}/src/google/protobuf/compiler/command_line_interface.cc ${CMAKE_CURRENT_SOURCE_DIR}/src/google/protobuf/compiler/subprocess.cc ${CMAKE_CURRENT_SOURCE_DIR}/src/google/protobuf/compiler/zip_writer.cc ${CMAKE_CURRENT_SOURCE_DIR}/src/google/protobuf/compiler/plugin.cc ${CMAKE_CURRENT_SOURCE_DIR}/src/google/protobuf/compiler/plugin.pb.cc ${CMAKE_CURRENT_SOURCE_DIR}/src/google/protobuf/compiler/cpp/cpp_enum.cc ${CMAKE_CURRENT_SOURCE_DIR}/src/google/protobuf/compiler/cpp/cpp_enum_field.cc ${CMAKE_CURRENT_SOURCE_DIR}/src/google/protobuf/compiler/cpp/cpp_extension.cc ${CMAKE_CURRENT_SOURCE_DIR}/src/google/protobuf/compiler/cpp/cpp_field.cc ${CMAKE_CURRENT_SOURCE_DIR}/src/google/protobuf/compiler/cpp/cpp_file.cc ${CMAKE_CURRENT_SOURCE_DIR}/src/google/protobuf/compiler/cpp/cpp_generator.cc ${CMAKE_CURRENT_SOURCE_DIR}/src/google/protobuf/compiler/cpp/cpp_helpers.cc ${CMAKE_CURRENT_SOURCE_DIR}/src/google/protobuf/compiler/cpp/cpp_message.cc ${CMAKE_CURRENT_SOURCE_DIR}/src/google/protobuf/compiler/cpp/cpp_message_field.cc ${CMAKE_CURRENT_SOURCE_DIR}/src/google/protobuf/compiler/cpp/cpp_primitive_field.cc ${CMAKE_CURRENT_SOURCE_DIR}/src/google/protobuf/compiler/cpp/cpp_service.cc ${CMAKE_CURRENT_SOURCE_DIR}/src/google/protobuf/compiler/cpp/cpp_string_field.cc ${CMAKE_CURRENT_SOURCE_DIR}/src/google/protobuf/compiler/java/java_enum.cc ${CMAKE_CURRENT_SOURCE_DIR}/src/google/protobuf/compiler/java/java_enum_field.cc ${CMAKE_CURRENT_SOURCE_DIR}/src/google/protobuf/compiler/java/java_extension.cc ${CMAKE_CURRENT_SOURCE_DIR}/src/google/protobuf/compiler/java/java_field.cc ${CMAKE_CURRENT_SOURCE_DIR}/src/google/protobuf/compiler/java/java_file.cc ${CMAKE_CURRENT_SOURCE_DIR}/src/google/protobuf/compiler/java/java_generator.cc ${CMAKE_CURRENT_SOURCE_DIR}/src/google/protobuf/compiler/java/java_helpers.cc ${CMAKE_CURRENT_SOURCE_DIR}/src/google/protobuf/compiler/java/java_message.cc ${CMAKE_CURRENT_SOURCE_DIR}/src/google/protobuf/compiler/java/java_message_field.cc ${CMAKE_CURRENT_SOURCE_DIR}/src/google/protobuf/compiler/java/java_primitive_field.cc ${CMAKE_CURRENT_SOURCE_DIR}/src/google/protobuf/compiler/java/java_service.cc ${CMAKE_CURRENT_SOURCE_DIR}/src/google/protobuf/compiler/java/java_string_field.cc ${CMAKE_CURRENT_SOURCE_DIR}/src/google/protobuf/compiler/python/python_generator.cc ${CMAKE_CURRENT_SOURCE_DIR}/src/google/protobuf/compiler/main.cc ) ADD_EXECUTABLE(protoc ${PROTOC_INC_FILES} ${PROTOC_SRC_FILES}) TARGET_LINK_LIBRARIES(protoc protobuf)
2. config.h for mingw
/* config.h. Generated from config.h.in by configure. */ /* config.h.in. Generated from configure.ac by autoheader. */ /* the name of <hash_map> */ #define HASH_MAP_CLASS unordered_map /* the location of <unordered_map> or <hash_map> */ #define HASH_MAP_H <tr1/unordered_map> /* the namespace of hash_map/hash_set */ #define HASH_NAMESPACE std::tr1 /* the name of <hash_set> */ #define HASH_SET_CLASS unordered_set /* the location of <unordered_set> or <hash_set> */ #define HASH_SET_H <tr1/unordered_set> /* Define to 1 if you have the <dlfcn.h> header file. */ /* #undef HAVE_DLFCN_H */ /* Define to 1 if you have the <fcntl.h> header file. */ #define HAVE_FCNTL_H 1 /* Define to 1 if you have the `ftruncate' function. */ #define HAVE_FTRUNCATE 1 /* define if the compiler has hash_map */ #define HAVE_HASH_MAP 1 /* define if the compiler has hash_set */ #define HAVE_HASH_SET 1 /* Define to 1 if you have the <inttypes.h> header file. */ #define HAVE_INTTYPES_H 1 /* Define to 1 if you have the <limits.h> header file. */ #define HAVE_LIMITS_H 1 /* Define to 1 if you have the <memory.h> header file. */ #define HAVE_MEMORY_H 1 /* Define to 1 if you have the `memset' function. */ #define HAVE_MEMSET 1 /* Define to 1 if you have the `mkdir' function. */ #define HAVE_MKDIR 1 /* Define if you have POSIX threads libraries and header files. */ /* #undef HAVE_PTHREAD */ /* Define to 1 if you have the <stdint.h> header file. */ #define HAVE_STDINT_H 1 /* Define to 1 if you have the <stdlib.h> header file. */ #define HAVE_STDLIB_H 1 /* Define to 1 if you have the `strchr' function. */ #define HAVE_STRCHR 1 /* Define to 1 if you have the `strerror' function. */ #define HAVE_STRERROR 1 /* Define to 1 if you have the <strings.h> header file. */ #define HAVE_STRINGS_H 1 /* Define to 1 if you have the <string.h> header file. */ #define HAVE_STRING_H 1 /* Define to 1 if you have the `strtol' function. */ #define HAVE_STRTOL 1 /* Define to 1 if you have the <sys/stat.h> header file. */ #define HAVE_SYS_STAT_H 1 /* Define to 1 if you have the <sys/types.h> header file. */ #define HAVE_SYS_TYPES_H 1 /* Define to 1 if you have the <unistd.h> header file. */ #define HAVE_UNISTD_H 1 /* Enable classes using zlib compression. */ /* #undef HAVE_ZLIB */ /* Define to the sub-directory in which libtool stores uninstalled libraries. */ #define LT_OBJDIR ".libs/" /* Name of package */ #define PACKAGE "protobuf" /* Define to the address where bug reports for this package should be sent. */ #define PACKAGE_BUGREPORT "[email protected]" /* Define to the full name of this package. */ #define PACKAGE_NAME "Protocol Buffers" /* Define to the full name and version of this package. */ #define PACKAGE_STRING "Protocol Buffers 2.5.0" /* Define to the one symbol short name of this package. */ #define PACKAGE_TARNAME "protobuf" /* Define to the home page for this package. */ #define PACKAGE_URL "" /* Define to the version of this package. */ #define PACKAGE_VERSION "2.5.0" /* Define to necessary symbol if this constant uses a non-standard name on your system. */ /* #undef PTHREAD_CREATE_JOINABLE */ /* Define to 1 if you have the ANSI C header files. */ #define STDC_HEADERS 1 /* Enable extensions on AIX 3, Interix. */ #ifndef _ALL_SOURCE # define _ALL_SOURCE 1 #endif /* Enable GNU extensions on systems that have them. */ #ifndef _GNU_SOURCE # define _GNU_SOURCE 1 #endif /* Enable threading extensions on Solaris. */ #ifndef _POSIX_PTHREAD_SEMANTICS # define _POSIX_PTHREAD_SEMANTICS 1 #endif /* Enable extensions on HP NonStop. */ #ifndef _TANDEM_SOURCE # define _TANDEM_SOURCE 1 #endif /* Enable general extensions on Solaris. */ #ifndef __EXTENSIONS__ # define __EXTENSIONS__ 1 #endif /* Version number of package */ #define VERSION "2.5.0" /* Define to 1 if on MINIX. */ /* #undef _MINIX */ /* Define to 2 if the system does not provide POSIX.1 features except with this defined. */ /* #undef _POSIX_1_SOURCE */ /* Define to 1 if you need to in order for `stat' and other things to work. */ /* #undef _POSIX_SOURCE */实际上不需要config.h,在hash.h 里line:42(version 2.5.0)
#if defined(HAVE_HASH_MAP) && defined(HAVE_HASH_SET)改为
#if 0 // defined(HAVE_HASH_MAP) && defined(HAVE_HASH_SET)
这样就不需要 std::tr1::unordered_map等,tr1类
3. 还有一条要注意 ,在cmakelists.txt里,有
set(CMAKE_CXX_FLAGS ${CMAKE_CXX_FLAGS} "-std=gnu++0x")