forked from jesperes/protobuf-cmake
-
Notifications
You must be signed in to change notification settings - Fork 3
/
CMakeLists.txt
107 lines (95 loc) · 3.13 KB
/
CMakeLists.txt
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
project(Protobuf)
cmake_minimum_required(VERSION 2.6)
set(CMAKE_MODULE_PATH ${CMAKE_CURRENT_SOURCE_DIR})
include(CheckIncludeFiles)
include(CheckCxxHashset)
include(CheckCxxHashmap)
check_include_files("pthread.h" HAVE_PTHREAD)
if(CMAKE_COMPILER_IS_GNUCXX OR CMAKE_CXX_COMPILER_ID STREQUAL "Clang")
include(CheckIncludeFileCXX)
set(CMAKE_REQUIRED_FLAGS "-std=c++11")
check_include_file_cxx("unordered_map" HAVE_UNORDERED_MAP)
check_include_file_cxx("tr1/unordered_map" HAVE_TR1_UNORDERED_MAP)
set(CMAKE_REQUIRED_FLAGS )
if(HAVE_UNORDERED_MAP)
add_definitions("-std=c++11") # For unordered_map
set(HASH_MAP_H "<unordered_map>")
set(HASH_MAP_CLASS "unordered_map")
set(HASH_NAMESPACE "std")
set(HAVE_HASH_MAP 1)
elseif(HAVE_TR1_UNORDERED_MAP)
add_definitions("-std=c++11") # For unordered_map
set(HASH_MAP_H "<tr1/unordered_map>")
set(HASH_MAP_CLASS "unordered_map")
set(HASH_NAMESPACE "std::tr1")
set(HAVE_HASH_MAP 1)
else()
CHECK_HASHMAP()
if(HAVE_GNU_EXT_HASH_MAP)
set(HASH_MAP_H "<ext/hash_map>")
set(HASH_NAMESPACE "__gnu_cxx")
set(HASH_MAP_CLASS "hash_map")
set(HAVE_HASH_MAP 1)
elseif(HAVE_STD_EXT_HASH_MAP)
set(HASH_MAP_H "<ext/hash_map>")
set(HASH_NAMESPACE "std")
set(HASH_MAP_CLASS "hash_map")
set(HAVE_HASH_MAP 1)
elseif(HAVE_GLOBAL_HASH_MAP)
set(HASH_MAP_H "<ext/hash_map>")
set(HASH_NAMESPACE "")
set(HASH_MAP_CLASS "hash_map")
set(HAVE_HASH_MAP 1)
else()
set(HAVE_HASH_MAP 0)
endif()
endif()
set(CMAKE_REQUIRED_FLAGS "-std=c++11")
check_include_file_cxx("unordered_set" HAVE_UNORDERED_SET)
check_include_file_cxx("tr1/unordered_set" HAVE_TR1_UNORDERED_SET)
set(CMAKE_REQUIRED_FLAGS )
if(HAVE_UNORDERED_SET)
set(HASH_SET_H "<unordered_set>")
set(HASH_SET_CLASS "unordered_set")
set(HAVE_HASH_SET 1)
elseif(HAVE_TR1_UNORDERED_SET)
add_definitions("-std=c++11")
set(HASH_SET_H "<tr1/unordered_set>")
set(HASH_SET_CLASS "unordered_set")
set(HAVE_HASH_SET 1)
else()
CHECK_HASHSET()
if(HAVE_GNU_EXT_HASH_SET)
set(HASH_SET_H "<ext/hash_set>")
set(HASH_NAMESPACE "__gnu_cxx")
set(HASH_SET_CLASS "hash_set")
set(HAVE_HASH_SET 1)
elseif(HAVE_STD_EXT_HASH_SET)
set(HASH_SET_H "<ext/hash_set>")
set(HASH_NAMESPACE "std")
set(HASH_SET_CLASS "hash_set")
set(HAVE_HASH_SET 1)
elseif(HAVE_GLOBAL_HASH_SET)
set(HASH_SET_H "<hash_set>")
set(HASH_NAMESPACE "")
set(HASH_SET_CLASS "hash_set")
set(HAVE_HASH_SET 1)
else()
set(HAVE_HASH_SET 0)
endif()
endif()
endif()
if(WIN32 AND BUILD_SHARED_LIBS AND MSVC)
add_definitions("-DPROTOBUF_USE_DLLS")
endif()
add_definitions("-D_GNU_SOURCE=1")
configure_file("config.h.in" "config.h")
include_directories(${CMAKE_CURRENT_BINARY_DIR})
option(PROTOBUF_ROOT "Location of protobuf sources.")
if (NOT PROTOBUF_ROOT)
message(FATAL_ERROR "PROTOBUF_ROOT must be set to the location of protobuf sources.")
endif()
message(STATUS "Protobuf sources in ${PROTOBUF_ROOT}")
add_subdirectory(libprotobuf)
add_subdirectory(libprotoc)
add_subdirectory(protoc)